diff --git a/README.md b/README.md index c1dab9fc50..3356f8f991 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ The easiest way to get started is to use Maven, just add the following entries t ```html - 8.0.2 + REPLACE_WITH_DESIRED_ITEXT_VERSION @@ -94,53 +94,55 @@ This is a small subset of examples to get you started. For more advanced example Some of the output PDF files will be incorrectly displayed by the GitHub previewer, so be sure to download them to see the correct results. -| Description | Link | -|--------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| **Basic layout** | | -| Change text properties | [Java](https://github.com/itext/i7js-examples/blob/master/src/main/java/com/itextpdf/samples/sandbox/layout/ParagraphTextWithStyle.java), [PDF](https://github.com/itext/i7js-examples/blob/master/cmpfiles/sandbox/layout/cmp_paragraphTextWithStyle.pdf) | +| Description | Link | +|--------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| **Basic layout** | | +| Change text properties | [Java](https://github.com/itext/i7js-examples/blob/master/src/main/java/com/itextpdf/samples/sandbox/layout/ParagraphTextWithStyle.java), [PDF](https://github.com/itext/i7js-examples/blob/master/cmpfiles/sandbox/layout/cmp_paragraphTextWithStyle.pdf) | | Creating a simple table | [Java](https://github.com/itext/i7js-examples/blob/master/src/main/java/com/itextpdf/samples/sandbox/tables/SimpleTable9.java), [PDF](https://github.com/itext/i7js-examples/blob/master/cmpfiles/sandbox/tables/cmp_simple_table9.pdf) | | Add an image to a PDF document | [Java](https://github.com/itext/i7js-examples/blob/master/src/main/java/com/itextpdf/samples/sandbox/images/MultipleImages.java), [PDF](https://github.com/itext/i7js-examples/blob/master/cmpfiles/sandbox/images/cmp_multiple_images.pdf) | | Create a list | [Java](https://github.com/itext/i7js-examples/blob/master/src/main/java/com/itextpdf/samples/sandbox/objects/NestedLists.java), [PDF](https://github.com/itext/i7js-examples/blob/master/cmpfiles/sandbox/objects/cmp_nested_list.pdf) | | Add a watermark | [Java](https://github.com/itext/i7js-examples/blob/master/src/main/java/com/itextpdf/samples/sandbox/events/Watermarking.java), [PDF](https://github.com/itext/i7js-examples/blob/master/cmpfiles/sandbox/events/cmp_watermarkings.pdf) | | Add links to navigate within a document | [Java](https://github.com/itext/i7js-examples/blob/master/src/main/java/com/itextpdf/samples/sandbox/annotations/AddLinkAnnotation5.java), [PDF](https://github.com/itext/i7js-examples/blob/master/cmpfiles/sandbox/annotations/cmp_add_link_annotation5.pdf) | -| Create a popup annotation | [Java](https://github.com/itext/i7js-examples/blob/master/src/main/java/com/itextpdf/samples/sandbox/annotations/MovePopup.java), [PDF](https://github.com/itext/i7js-examples/blob/master/cmpfiles/sandbox/annotations/cmp_move_popup.pdf) | -| Change font | [Java](https://github.com/itext/i7js-examples/blob/master/src/main/java/com/itextpdf/samples/sandbox/layout/ParagraphTextWithStyle.java) | -| Add form fields | [Java](https://kb.itextpdf.com/home/it7kb/examples/forms-in-itext-core-8-0-0) | -
| | -| **General document settings** | | +| Create a popup annotation | [Java](https://github.com/itext/i7js-examples/blob/master/src/main/java/com/itextpdf/samples/sandbox/annotations/MovePopup.java), [PDF](https://github.com/itext/i7js-examples/blob/master/cmpfiles/sandbox/annotations/cmp_move_popup.pdf) | +| Change font | [Java](https://github.com/itext/i7js-examples/blob/master/src/main/java/com/itextpdf/samples/sandbox/layout/ParagraphTextWithStyle.java) | +| Add form fields | [Java](https://kb.itextpdf.com/home/it7kb/examples/forms-in-itext-core-8-0-0) | +
| | +| **General document settings** | | | Change page size and margin | [Java](https://github.com/itext/i7js-examples/blob/master/src/main/java/com/itextpdf/samples/sandbox/layout/PageSizeAndMargins.java), [PDF](https://github.com/itext/i7js-examples/blob/master/cmpfiles/sandbox/layout/cmp_pageSizeAndMargins.pdf) | -| Write PDF to byte array instead of to disk | [Java](https://stackoverflow.com/a/67411657/10015628) | -| Change page rotation | [Java](https://github.com/itext/i7js-examples/blob/master/src/main/java/com/itextpdf/samples/sandbox/events/PageRotation.java), [PDF](https://github.com/itext/i7js-examples/blob/master/cmpfiles/sandbox/events/cmp_page_rotation.pdf) | +| Write PDF to byte array instead of to disk | [Java](https://stackoverflow.com/a/67411657/10015628) | +| Change page rotation | [Java](https://github.com/itext/i7js-examples/blob/master/src/main/java/com/itextpdf/samples/sandbox/events/PageRotation.java), [PDF](https://github.com/itext/i7js-examples/blob/master/cmpfiles/sandbox/events/cmp_page_rotation.pdf) | | Add header and footer | [Java](https://github.com/itext/i7js-examples/blob/master/src/main/java/com/itextpdf/samples/sandbox/events/TextFooter.java), [PDF](https://github.com/itext/i7js-examples/blob/master/cmpfiles/sandbox/events/cmp_text_footer.pdf) | | Merge documents | [Java](https://github.com/itext/i7js-examples/blob/master/src/main/java/com/itextpdf/samples/sandbox/merge/AddCover1.java), [PDF](https://github.com/itext/i7js-examples/blob/master/cmpfiles/sandbox/merge/cmp_add_cover.pdf) | -| Flatten annotations | [Java](https://kb.itextpdf.com/home/it7kb/examples/high-level-annotation-flattening) | -|
| | -| **PDF/UA, PDF/A** | | +| Flatten annotations | [Java](https://kb.itextpdf.com/home/it7kb/examples/high-level-annotation-flattening) | +|
| | +| **PDF/UA, PDF/A** | | | Create PDF/UA document | [Java](https://github.com/itext/i7js-examples/blob/master/src/main/java/com/itextpdf/samples/sandbox/pdfua/PdfUA.java), [PDF](https://github.com/itext/i7js-examples/blob/master/cmpfiles/sandbox/pdfua/cmp_pdf_ua.pdf) | -| Create PDF/A-3 document | [Java](https://github.com/itext/i7js-examples/blob/master/src/main/java/com/itextpdf/samples/sandbox/pdfa/PdfA3.java) | -|
| | -| **FIPS** | | -| Enable FIPS | [Java](https://kb.itextpdf.com/home/it7kb/releases/release-itext-core-8-0-0/breaking-changes-for-itext-core-8-0-0/bouncy-castle-changes) | -| FIPS SHA3 example | [Java](https://kb.itextpdf.com/home/it7kb/examples/fips-sha3-examples-for-itext-core-8-0-0) | -|
| | -| **Convert HTML and CSS to PDF** | [Link to repo](https://github.com/itext/i7j-pdfhtml) | -| Convert simple HTML doc to PDF | [Java](https://kb.itextpdf.com/home/it7kb/ebooks/itext-7-converting-html-to-pdf-with-pdfhtml) | -|
| | -| **Secure redaction of content** | [Link to repo](https://github.com/itext/i7j-pdfsweep) | -| Redacting content | [Java](https://kb.itextpdf.com/home/it7kb/examples/removing-content-with-pdfsweep) | -| Redact based on regex | [Java](https://itextpdf.com/products/pdf-redaction-pdfsweep) | -|
| | -| **Support complex writing systems** | [Link to docs](https://itextpdf.com/products/pdfcalligraph) | -| Add Arabic text | [Java](https://github.com/itext/i7js-examples/blob/master/src/main/java/com/itextpdf/samples/sandbox/typography/arabic/ArabicWordSpacing.java), [PDF](https://github.com/itext/i7js-examples/blob/master/cmpfiles/sandbox/typography/cmp_ArabicWordSpacing.pdf) | -|
| | -| **Optimizing PDFs** | [Link to docs](https://itextpdf.com/products/compress-pdf-pdfoptimizer) | -| Reduce size of PDF | [Java](https://itextpdf.com/products/compress-pdf-pdfoptimizer) | -|
| | -| **XFA flattening** | [Link to docs](https://itextpdf.com/products/flatten-pdf-pdfxfa) | -| Flatten an XFA document | [Java](https://itextpdf.com/products/flatten-pdf-pdfxfa) | -|
| | -| **RUPS** | [Link to repo](https://github.com/itext/i7j-rups) | -| Debug a PDF | [Java](https://github.com/itext/i7j-rups/releases/latest) | +| Create PDF/A-3 document | [Java](https://github.com/itext/i7js-examples/blob/master/src/main/java/com/itextpdf/samples/sandbox/pdfa/PdfA3.java) | +| Create PDF/A-4 document | [Java](https://github.com/itext/i7js-examples/blob/develop/src/main/java/com/itextpdf/samples/sandbox/pdfa/PdfA4.java) | +| Create WTPDF document | [Java](https://github.com/itext/i7js-examples/blob/develop/src/main/java/com/itextpdf/samples/sandbox/pdfua/Wtpdf.java) | +|
| | +| **FIPS** | | +| Enable FIPS | [Java](https://kb.itextpdf.com/home/it7kb/releases/release-itext-core-8-0-0/breaking-changes-for-itext-core-8-0-0/bouncy-castle-changes) | +| FIPS SHA3 example | [Java](https://kb.itextpdf.com/home/it7kb/examples/fips-sha3-examples-for-itext-core-8-0-0) | +|
| | +| **Convert HTML and CSS to PDF** | [Link to repo](https://github.com/itext/i7j-pdfhtml) | +| Convert simple HTML doc to PDF | [Java](https://kb.itextpdf.com/home/it7kb/ebooks/itext-7-converting-html-to-pdf-with-pdfhtml) | +|
| | +| **Secure redaction of content** | [Link to repo](https://github.com/itext/i7j-pdfsweep) | +| Redacting content | [Java](https://kb.itextpdf.com/home/it7kb/examples/removing-content-with-pdfsweep) | +| Redact based on regex | [Java](https://itextpdf.com/products/pdf-redaction-pdfsweep) | +|
| | +| **Support complex writing systems** | [Link to docs](https://itextpdf.com/products/pdfcalligraph) | +| Add Arabic text | [Java](https://github.com/itext/i7js-examples/blob/master/src/main/java/com/itextpdf/samples/sandbox/typography/arabic/ArabicWordSpacing.java), [PDF](https://github.com/itext/i7js-examples/blob/master/cmpfiles/sandbox/typography/cmp_ArabicWordSpacing.pdf) | +|
| | +| **Optimizing PDFs** | [Link to docs](https://itextpdf.com/products/compress-pdf-pdfoptimizer) | +| Reduce size of PDF | [Java](https://itextpdf.com/products/compress-pdf-pdfoptimizer) | +|
| | +| **XFA flattening** | [Link to docs](https://itextpdf.com/products/flatten-pdf-pdfxfa) | +| Flatten an XFA document | [Java](https://itextpdf.com/products/flatten-pdf-pdfxfa) | +|
| | +| **RUPS** | [Link to repo](https://github.com/itext/i7j-rups) | +| Debug a PDF | [Java](https://github.com/itext/i7j-rups/releases/latest) | ### FAQs, tutorials, etc. ### Check out the [iText Knowledge Base](https://kb.itextpdf.com) for the [iText Jump-start tutorial](https://kb.itextpdf.com/home/it7kb/ebooks/itext-jump-start-tutorial-for-java) and other tutorials, [FAQs](https://kb.itextpdf.com/home/it7kb/faq) and more. For specific information and examples relating to digital signatures and iText, make sure to check the [Digital Signatures Hub](https://kb.itextpdf.com/home/it7kb/digital-signatures-hub). diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000000..152327a4d9 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,39 @@ +# iText Security Policy + +## Reporting a Vulnerability + +We are committed to maintaining the security of our software. If you discover a security vulnerability, we encourage you to report it to us as soon as possible. + +To report a vulnerability, please visit our [Vulnerability Reporting Page](https://itextpdf.com/report-vulnerability), or email [vulnerability@apryse.com](vulnerability@apryse.com). If you do not receive a response in 2 business days, please follow up as we may not have received your message. + +We follow the procedure of Coordinated Vulnerability Disclosure (CVD) and, to protect the ecosystem, we request that those reporting do the same. Please visit the above page for more information, and follow the steps below to ensure that your report is handled promptly and appropriately: + +1. **Do not disclose the vulnerability publicly** until we have had a chance to address it. +2. **Provide a detailed description** of the vulnerability, including steps to reproduce it, if possible. +3. **Include any relevant information** such as the version of iText Core you are using, your operating system, and any other pertinent details. + +## Security Updates and Patches + + When a vulnerability is reported, we will: + +1. **Investigate and verify** the vulnerability. +2. **Develop and test** a fix for the vulnerability. +3. **Release a patch** as soon as possible. + +## Known Vulnerabilities + +The iText Knowledge Base has a page for known [Common Vulnerabilities and Exposures](https://kb.itextpdf.com/itext/cves) (CVEs), please check it to ensure your vulnerability has not already been disclosed or addressed. + +## Supported product lines + +See [Compatibility Matrix](https://kb.itextpdf.com/itext/compatibility-matrix) + +## Security Best Practices + +To help ensure the security of your applications using iText Core, we recommend the following best practices: + +1. **Keep iText Core up to date** by regularly checking for and applying updates. +2. **Review and follow** our security guidelines for secure usage. +3. **Monitor your applications** for any unusual activity and investigate any anomalies promptly. + +Thank you for helping us keep iText secure! diff --git a/barcodes/pom.xml b/barcodes/pom.xml index 8566a96289..8d2b5ef694 100644 --- a/barcodes/pom.xml +++ b/barcodes/pom.xml @@ -5,7 +5,7 @@ com.itextpdf root - 8.0.5 + 9.0.0 barcodes diff --git a/barcodes/src/main/java/com/itextpdf/barcodes/BarcodeDataMatrix.java b/barcodes/src/main/java/com/itextpdf/barcodes/BarcodeDataMatrix.java index c9b24ea3b8..c0343604d4 100644 --- a/barcodes/src/main/java/com/itextpdf/barcodes/BarcodeDataMatrix.java +++ b/barcodes/src/main/java/com/itextpdf/barcodes/BarcodeDataMatrix.java @@ -373,28 +373,30 @@ public int setCode(byte[] text, int textOffset, int textSize) { switchMode = new int[6][textSize - extOut]; if (height == 0 || width == 0) { last = dmSizes[dmSizes.length - 1]; - e = getEncodation(text, textOffset + extOut, textSize - extOut, data, extCount, last.dataSize - extCount, options, false); + e = getEncodation(text, textOffset + extOut, textSize - extOut, data, + extCount, last.getDataSize() - extCount, options, false); if (e < 0) { return DM_ERROR_TEXT_TOO_BIG; } e += extCount; for (k = 0; k < dmSizes.length; ++k) { - if (dmSizes[k].dataSize >= e) + if (dmSizes[k].getDataSize() >= e) break; } dm = dmSizes[k]; - height = dm.height; - width = dm.width; + height = dm.getHeight(); + width = dm.getWidth(); } else { for (k = 0; k < dmSizes.length; ++k) { - if (height == dmSizes[k].height && width == dmSizes[k].width) + if (height == dmSizes[k].getHeight() && width == dmSizes[k].getWidth()) break; } if (k == dmSizes.length) { return DM_ERROR_INVALID_SQUARE; } dm = dmSizes[k]; - e = getEncodation(text, textOffset + extOut, textSize - extOut, data, extCount, dm.dataSize - extCount, options, true); + e = getEncodation(text, textOffset + extOut, textSize - extOut, data, + extCount, dm.getDataSize() - extCount, options, true); if (e < 0) { return DM_ERROR_TEXT_TOO_BIG; } @@ -403,11 +405,12 @@ public int setCode(byte[] text, int textOffset, int textSize) { if ((options & DM_TEST) != 0) { return DM_NO_ERROR; } - image = new byte[(dm.width + 2 * ws + 7) / 8 * (dm.height + 2 * ws)]; - makePadding(data, e, dm.dataSize - e); - place = Placement.doPlacement(dm.height - dm.height / dm.heightSection * 2, dm.width - dm.width / dm.widthSection * 2); - full = dm.dataSize + (dm.dataSize + 2) / dm.dataBlock * dm.errorBlock; - ReedSolomon.generateECC(data, dm.dataSize, dm.dataBlock, dm.errorBlock); + image = new byte[(dm.getWidth() + 2 * ws + 7) / 8 * (dm.getHeight() + 2 * ws)]; + makePadding(data, e, dm.getDataSize() - e); + place = Placement.doPlacement(dm.getHeight() - dm.getHeight() / + dm.getHeightSection() * 2, dm.getWidth() - dm.getWidth() / dm.getWidthSection() * 2); + full = dm.getDataSize() + (dm.getDataSize() + 2) / dm.getDataBlock() * dm.getErrorBlock(); + ReedSolomon.generateECC(data, dm.getDataSize(), dm.getDataBlock(), dm.getErrorBlock()); draw(data, full, dm); return DM_NO_ERROR; } @@ -849,8 +852,8 @@ private int EdifactEncodation(byte[] text, int textOffset, int textLength, byte[ if (!sizeFixed && (symbolIndex == text.length - 1 || symbolIndex < 0) && textLength % 4 < 3) { dataSize = Integer.MAX_VALUE; for (int i = 0; i < dmSizes.length; ++i) { - if (dmSizes[i].dataSize >= dataRequired + textLength % 4) { - dataSize = dmSizes[i].dataSize; + if (dmSizes[i].getDataSize() >= dataRequired + textLength % 4) { + dataSize = dmSizes[i].getDataSize(); break; } } @@ -990,8 +993,8 @@ private int EdifactEncodation(byte[] text, int textOffset, int textLength, byte[ if (!sizeFixed && (symbolIndex == text.length - 1 || symbolIndex < 0)) { dataSize = Integer.MAX_VALUE; for (int i = 0; i < dmSizes.length; ++i) { - if (dmSizes[i].dataSize >= dataOffset + ptrOut + (3 - pedi / 6)) { - dataSize = dmSizes[i].dataSize; + if (dmSizes[i].getDataSize() >= dataOffset + ptrOut + (3 - pedi / 6)) { + dataSize = dmSizes[i].getDataSize(); break; } } @@ -1183,38 +1186,38 @@ private void setBit(int x, int y, int xByte) { private void draw(byte[] data, int dataSize, DmParams dm) { int i, j, p, x, y, xs, ys, z; - int xByte = (dm.width + ws * 2 + 7) / 8; + int xByte = (dm.getWidth() + ws * 2 + 7) / 8; Arrays.fill(image, (byte) 0); //alignment patterns //dotted horizontal line - for (i = ws; i < dm.height + ws; i += dm.heightSection) { - for (j = ws; j < dm.width + ws; j += 2) { + for (i = ws; i < dm.getHeight() + ws; i += dm.getHeightSection()) { + for (j = ws; j < dm.getWidth() + ws; j += 2) { setBit(j, i, xByte); } } //solid horizontal line - for (i = dm.heightSection - 1 + ws; i < dm.height + ws; i += dm.heightSection) { - for (j = ws; j < dm.width + ws; ++j) { + for (i = dm.getHeightSection() - 1 + ws; i < dm.getHeight() + ws; i += dm.getHeightSection()) { + for (j = ws; j < dm.getWidth() + ws; ++j) { setBit(j, i, xByte); } } //solid vertical line - for (i = ws; i < dm.width + ws; i += dm.widthSection) { - for (j = ws; j < dm.height + ws; ++j) { + for (i = ws; i < dm.getWidth() + ws; i += dm.getWidthSection()) { + for (j = ws; j < dm.getHeight() + ws; ++j) { setBit(i, j, xByte); } } //dotted vertical line - for (i = dm.widthSection - 1 + ws; i < dm.width + ws; i += dm.widthSection) { - for (j = 1 + ws; j < dm.height + ws; j += 2) { + for (i = dm.getWidthSection() - 1 + ws; i < dm.getWidth() + ws; i += dm.getWidthSection()) { + for (j = 1 + ws; j < dm.getHeight() + ws; j += 2) { setBit(i, j, xByte); } } p = 0; - for (ys = 0; ys < dm.height; ys += dm.heightSection) { - for (y = 1; y < dm.heightSection - 1; ++y) { - for (xs = 0; xs < dm.width; xs += dm.widthSection) { - for (x = 1; x < dm.widthSection - 1; ++x) { + for (ys = 0; ys < dm.getHeight(); ys += dm.getHeightSection()) { + for (y = 1; y < dm.getHeightSection() - 1; ++y) { + for (xs = 0; xs < dm.getWidth(); xs += dm.getWidthSection()) { + for (x = 1; x < dm.getWidthSection() - 1; ++x) { z = place[p++]; if (z == 1 || z > 1 && (data[z / 8 - 1] & 0xff & 128 >> z % 8) != 0) setBit(x + xs + ws, y + ys + ws, xByte); diff --git a/barcodes/src/main/java/com/itextpdf/barcodes/BarcodePDF417.java b/barcodes/src/main/java/com/itextpdf/barcodes/BarcodePDF417.java index 819f99b00c..8ac3f5ce3f 100644 --- a/barcodes/src/main/java/com/itextpdf/barcodes/BarcodePDF417.java +++ b/barcodes/src/main/java/com/itextpdf/barcodes/BarcodePDF417.java @@ -1267,7 +1267,7 @@ protected int getTextTypeAndValue(int maxLength, int idx) { protected boolean checkSegmentType(Segment segment, char type) { if (segment == null) return false; - return segment.type == type; + return segment.getType() == type; } /** @@ -1280,7 +1280,7 @@ protected boolean checkSegmentType(Segment segment, char type) { protected int getSegmentLength(Segment segment) { if (segment == null) return 0; - return segment.end - segment.start; + return segment.getEnd() - segment.getStart(); } @@ -1332,19 +1332,19 @@ protected void assemble() { cwPtr = 1; for (k = 0; k < segmentList.size(); ++k) { Segment v = segmentList.get(k); - switch (v.type) { + switch (v.getType()) { case 'T': if (k != 0) codewords[cwPtr++] = TEXT_MODE; - textCompaction(v.start, getSegmentLength(v)); + textCompaction(v.getStart(), getSegmentLength(v)); break; case 'N': codewords[cwPtr++] = NUMERIC_MODE; - numberCompaction(v.start, getSegmentLength(v)); + numberCompaction(v.getStart(), getSegmentLength(v)); break; case 'B': codewords[cwPtr++] = getSegmentLength(v) % 6 != 0 ? BYTE_MODE : BYTE_MODE_6; - byteCompaction(v.start, getSegmentLength(v)); + byteCompaction(v.getStart(), getSegmentLength(v)); break; } } @@ -1384,12 +1384,12 @@ protected void dumpList() { int len = getSegmentLength(v); char[] c = new char[len]; for (int j = 0; j < len; ++j) { - c[j] = (char) (code[v.start + j] & 0xff); + c[j] = (char) (code[v.getStart() + j] & 0xff); if (c[j] == '\r') c[j] = '\n'; } StringBuffer sb = new StringBuffer(); - sb.append(v.type); + sb.append(v.getType()); sb.append(c); System.out.println(sb.toString()); } @@ -1501,7 +1501,7 @@ void breakString() { if (checkSegmentType(v, 'B') && getSegmentLength(v) == 1) { if (checkSegmentType(vp, 'T') && checkSegmentType(vn, 'T') && getSegmentLength(vp) + getSegmentLength(vn) >= 3) { - vp.end = vn.end; + vp.setEnd(vn.getEnd()); segmentList.remove(k); segmentList.remove(k); k = -1; @@ -1518,13 +1518,13 @@ && getSegmentLength(vp) + getSegmentLength(vn) >= 3) { boolean redo = false; if (checkSegmentType(vp, 'B') && getSegmentLength(vp) == 1 || checkSegmentType(vp, 'T')) { redo = true; - v.start = vp.start; + v.setStart(vp.getStart()); segmentList.remove(k - 1); --k; } if (checkSegmentType(vn, 'B') && getSegmentLength(vn) == 1 || checkSegmentType(vn, 'T')) { redo = true; - v.end = vn.end; + v.setEnd(vn.getEnd()); segmentList.remove(k + 1); } if (redo) { @@ -1542,13 +1542,13 @@ && getSegmentLength(vp) + getSegmentLength(vn) >= 3) { boolean redo = false; if (checkSegmentType(vp, 'T') && getSegmentLength(vp) < 5 || checkSegmentType(vp, 'B')) { redo = true; - v.start = vp.start; + v.setStart(vp.getStart()); segmentList.remove(k - 1); --k; } if (checkSegmentType(vn, 'T') && getSegmentLength(vn) < 5 || checkSegmentType(vn, 'B')) { redo = true; - v.end = vn.end; + v.setEnd(vn.getEnd()); segmentList.remove(k + 1); } if (redo) { @@ -1558,14 +1558,14 @@ && getSegmentLength(vp) + getSegmentLength(vn) >= 3) { } } // check if all numbers - if (segmentList.size() == 1 && (v = segmentList.get(0)).type == 'T' && getSegmentLength(v) >= 8) { - for (k = v.start; k < v.end; ++k) { + if (segmentList.size() == 1 && (v = segmentList.get(0)).getType() == 'T' && getSegmentLength(v) >= 8) { + for (k = v.getStart(); k < v.getEnd(); ++k) { c = (char) (code[k] & 0xff); if (c < '0' || c > '9') break; } - if (k == v.end) - v.type = 'N'; + if (k == v.getEnd()) + v.setType('N'); } } @@ -1789,9 +1789,9 @@ private void textCompaction(byte[] input, int start, int length) { * A container that encapsulates all data needed for a segment. */ protected static class Segment { - public char type; - public int start; - public int end; + private char type; + private int start; + private int end; /** * Creates a new {@link Segment} instance. @@ -1805,6 +1805,60 @@ public Segment(char type, int start, int end) { this.start = start; this.end = end; } + + /** + * Retrieves the type of the segment. + * + * @return segment type + */ + public char getType() { + return type; + } + + /** + * Sets the type of the segment. + * + * @param type segment type + */ + public void setType(char type) { + this.type = type; + } + + /** + * Retrieves the start of the segment. + * + * @return segment start + */ + public int getStart() { + return start; + } + + /** + * Sets the start of the segment. + * + * @param start segment start + */ + public void setStart(int start) { + this.start = start; + } + + /** + * Retrieves the end of the segment. + * + * @return segment end + */ + public int getEnd() { + return end; + } + + /** + * Sets the end of the segment. + * + * @param end segment end + */ + public void setEnd(int end) { + this.end = end; + } } /** diff --git a/barcodes/src/main/java/com/itextpdf/barcodes/BarcodePostnet.java b/barcodes/src/main/java/com/itextpdf/barcodes/BarcodePostnet.java index 3a52f5bc3e..229799dbb9 100644 --- a/barcodes/src/main/java/com/itextpdf/barcodes/BarcodePostnet.java +++ b/barcodes/src/main/java/com/itextpdf/barcodes/BarcodePostnet.java @@ -35,8 +35,8 @@ This file is part of the iText (R) project. */ public class BarcodePostnet extends Barcode1D { - public static int TYPE_POSTNET = 1; - public static int TYPE_PLANET = 2; + public static final int TYPE_POSTNET = 1; + public static final int TYPE_PLANET = 2; /** * The bars for each character. diff --git a/barcodes/src/main/java/com/itextpdf/barcodes/dmcode/DmParams.java b/barcodes/src/main/java/com/itextpdf/barcodes/dmcode/DmParams.java index eba43ba94d..a4418d8f0d 100644 --- a/barcodes/src/main/java/com/itextpdf/barcodes/dmcode/DmParams.java +++ b/barcodes/src/main/java/com/itextpdf/barcodes/dmcode/DmParams.java @@ -47,11 +47,76 @@ public DmParams(int height, int width, int heightSection, int widthSection, int this.errorBlock = errorBlock; } - public int height; - public int width; - public int heightSection; - public int widthSection; - public int dataSize; - public int dataBlock; - public int errorBlock; + private final int height; + + private final int width; + + private final int heightSection; + private final int widthSection; + private final int dataSize; + private final int dataBlock; + private final int errorBlock; + + /** + * Retrieves the height of DmParams object. + * + * @return total height value + */ + public int getHeight() { + return height; + } + + /** + * Retrieves the width of DmParams object. + * + * @return total width value + */ + public int getWidth() { + return width; + } + + /** + * Retrieves the height of a single section. + * + * @return total height value + */ + public int getHeightSection() { + return heightSection; + } + + /** + * Retrieves the width of a single section. + * + * @return total width value + */ + public int getWidthSection() { + return widthSection; + } + + /** + * Retrieves the size of the data. + * + * @return data size value + */ + public int getDataSize() { + return dataSize; + } + + /** + * Retrieves the size of the data block. + * + * @return data block size value + */ + public int getDataBlock() { + return dataBlock; + } + + /** + * Retrieves the size of the error block. + * + * @return error block size value + */ + public int getErrorBlock() { + return errorBlock; + } } diff --git a/barcodes/src/test/java/com/itextpdf/barcodes/Barcode128Test.java b/barcodes/src/test/java/com/itextpdf/barcodes/Barcode128Test.java index 3e10ed4232..54f0b06906 100644 --- a/barcodes/src/test/java/com/itextpdf/barcodes/Barcode128Test.java +++ b/barcodes/src/test/java/com/itextpdf/barcodes/Barcode128Test.java @@ -31,28 +31,27 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.canvas.PdfCanvas; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class Barcode128Test extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/barcodes/"; public static final String destinationFolder = "./target/test/com/itextpdf/barcodes/Barcode128/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(destinationFolder); } @@ -75,7 +74,7 @@ public void barcode01Test() throws IOException, PdfException, InterruptedExcepti document.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_")); } @Test @@ -96,12 +95,12 @@ public void barcode02Test() throws IOException, PdfException, InterruptedExcepti document.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_")); } @Test public void barcodeRawValueGenerationTest01() { - Assert.assertEquals(new String(new byte[] {103, 17, 18, 19, 20, 21, 17, 18, 19, 20, 21}), Barcode128.getRawText("1234512345", false, Barcode128.Barcode128CodeSet.A)); + Assertions.assertEquals(new String(new byte[] {103, 17, 18, 19, 20, 21, 17, 18, 19, 20, 21}), Barcode128.getRawText("1234512345", false, Barcode128.Barcode128CodeSet.A)); } } diff --git a/barcodes/src/test/java/com/itextpdf/barcodes/Barcode39Test.java b/barcodes/src/test/java/com/itextpdf/barcodes/Barcode39Test.java index be74c41c1a..b398b23ea5 100644 --- a/barcodes/src/test/java/com/itextpdf/barcodes/Barcode39Test.java +++ b/barcodes/src/test/java/com/itextpdf/barcodes/Barcode39Test.java @@ -32,28 +32,27 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.canvas.PdfCanvas; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class Barcode39Test extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/barcodes/"; public static final String destinationFolder = "./target/test/com/itextpdf/barcodes/Barcode39/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(destinationFolder); } @@ -74,7 +73,7 @@ public void barcode01Test() throws IOException, PdfException, InterruptedExcepti document.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_")); } @Test @@ -93,7 +92,7 @@ public void barcode02Test() throws IOException, PdfException, InterruptedExcepti document.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_")); } @Test @@ -102,7 +101,7 @@ public void barcode03Test() { Barcode39 barcode = new Barcode39(document); try { barcode.getBarsCode39("9781935*182610"); - Assert.fail("IllegalArgumentException expected"); + Assertions.fail("IllegalArgumentException expected"); } catch (IllegalArgumentException ignored) { } diff --git a/barcodes/src/test/java/com/itextpdf/barcodes/BarcodeCodabarTest.java b/barcodes/src/test/java/com/itextpdf/barcodes/BarcodeCodabarTest.java index 071e69557e..9e4edfdf3f 100644 --- a/barcodes/src/test/java/com/itextpdf/barcodes/BarcodeCodabarTest.java +++ b/barcodes/src/test/java/com/itextpdf/barcodes/BarcodeCodabarTest.java @@ -31,28 +31,27 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.canvas.PdfCanvas; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.ByteArrayOutputStream; import java.io.IOException; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class BarcodeCodabarTest extends ExtendedITextTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/barcodes/"; private static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/barcodes/Codabar/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(DESTINATION_FOLDER); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(DESTINATION_FOLDER); } @@ -74,7 +73,7 @@ public void barcode01Test() throws IOException, PdfException, InterruptedExcepti document.close(); - Assert.assertNull(new CompareTool() + Assertions.assertNull(new CompareTool() .compareByContent(DESTINATION_FOLDER + filename, SOURCE_FOLDER + "cmp_" + filename, DESTINATION_FOLDER, "diff_")); } @@ -83,9 +82,9 @@ public void barcode01Test() throws IOException, PdfException, InterruptedExcepti public void barcodeHasNoAbcdAsStartCharacterTest() { PdfDocument pdfDocument = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); BarcodeCodabar codabar = new BarcodeCodabar(pdfDocument); - Exception exception = Assert.assertThrows(IllegalArgumentException.class, + Exception exception = Assertions.assertThrows(IllegalArgumentException.class, () -> codabar.getBarsCodabar("qbcd")); - Assert.assertEquals(BarcodesExceptionMessageConstant.CODABAR_MUST_HAVE_ONE_ABCD_AS_START_STOP_CHARACTER, + Assertions.assertEquals(BarcodesExceptionMessageConstant.CODABAR_MUST_HAVE_ONE_ABCD_AS_START_STOP_CHARACTER, exception.getMessage()); } @@ -93,9 +92,9 @@ public void barcodeHasNoAbcdAsStartCharacterTest() { public void barcodeHasNoAbcdAsStopCharacterTest() { PdfDocument pdfDocument = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); BarcodeCodabar codabar = new BarcodeCodabar(pdfDocument); - Exception exception = Assert.assertThrows(IllegalArgumentException.class, + Exception exception = Assertions.assertThrows(IllegalArgumentException.class, () -> codabar.getBarsCodabar("abcf")); - Assert.assertEquals(BarcodesExceptionMessageConstant.CODABAR_MUST_HAVE_ONE_ABCD_AS_START_STOP_CHARACTER, + Assertions.assertEquals(BarcodesExceptionMessageConstant.CODABAR_MUST_HAVE_ONE_ABCD_AS_START_STOP_CHARACTER, exception.getMessage()); } @@ -103,9 +102,9 @@ public void barcodeHasNoAbcdAsStopCharacterTest() { public void barcodeHasNoAbcdAsStartAndStopCharacterTest() { PdfDocument pdfDocument = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); BarcodeCodabar codabar = new BarcodeCodabar(pdfDocument); - Exception exception = Assert.assertThrows(IllegalArgumentException.class, + Exception exception = Assertions.assertThrows(IllegalArgumentException.class, () -> codabar.getBarsCodabar("qbcq")); - Assert.assertEquals(BarcodesExceptionMessageConstant.CODABAR_MUST_HAVE_ONE_ABCD_AS_START_STOP_CHARACTER, + Assertions.assertEquals(BarcodesExceptionMessageConstant.CODABAR_MUST_HAVE_ONE_ABCD_AS_START_STOP_CHARACTER, exception.getMessage()); } @@ -113,9 +112,9 @@ public void barcodeHasNoAbcdAsStartAndStopCharacterTest() { public void barcodeHasNoStartAndStopCharacterTest() { PdfDocument pdfDocument = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); BarcodeCodabar codabar = new BarcodeCodabar(pdfDocument); - Exception exception = Assert.assertThrows(IllegalArgumentException.class, + Exception exception = Assertions.assertThrows(IllegalArgumentException.class, () -> codabar.getBarsCodabar("")); - Assert.assertEquals(BarcodesExceptionMessageConstant.CODABAR_MUST_HAVE_AT_LEAST_START_AND_STOP_CHARACTER, + Assertions.assertEquals(BarcodesExceptionMessageConstant.CODABAR_MUST_HAVE_AT_LEAST_START_AND_STOP_CHARACTER, exception.getMessage()); } } diff --git a/barcodes/src/test/java/com/itextpdf/barcodes/BarcodeDataMatrixTest.java b/barcodes/src/test/java/com/itextpdf/barcodes/BarcodeDataMatrixTest.java index 9d08804dc5..9c6ce81ddb 100644 --- a/barcodes/src/test/java/com/itextpdf/barcodes/BarcodeDataMatrixTest.java +++ b/barcodes/src/test/java/com/itextpdf/barcodes/BarcodeDataMatrixTest.java @@ -31,27 +31,26 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.canvas.PdfCanvas; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class BarcodeDataMatrixTest extends ExtendedITextTest { public static final String destinationFolder = "./target/test/com/itextpdf/barcodes/BarcodeDataMatrix/"; public static final String sourceFolder = "./src/test/resources/com/itextpdf/barcodes/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(destinationFolder); } @@ -69,7 +68,7 @@ public void barcode01Test() throws IOException, PdfException, InterruptedExcepti barcode.placeBarcode(canvas, ColorConstants.GREEN, 5); document.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_")); } @Test @@ -84,7 +83,7 @@ public void barcode02Test() throws IOException, PdfException, InterruptedExcepti barcode2.placeBarcode(canvas, ColorConstants.GREEN, 10); document.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_")); } @Test @@ -103,7 +102,7 @@ public void barcode03Test() throws IOException, PdfException, InterruptedExcepti barcode3.placeBarcode(canvas, ColorConstants.BLACK, 10); document.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_")); } @Test @@ -122,7 +121,7 @@ public void barcode04Test() throws IOException, PdfException, InterruptedExcepti barcode3.placeBarcode(canvas, ColorConstants.BLACK, 10); document.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_")); } @Test @@ -141,7 +140,7 @@ public void barcode05Test() throws IOException, PdfException, InterruptedExcepti barcode3.placeBarcode(canvas, ColorConstants.BLACK, 10); document.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_")); } @Test @@ -160,7 +159,7 @@ public void barcode06Test() throws IOException, PdfException, InterruptedExcepti barcode3.placeBarcode(canvas, ColorConstants.BLACK, 10); document.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_")); } @Test @@ -174,7 +173,7 @@ public void barcode07Test() { int result = bc.setCode(aCode); - Assert.assertEquals(result, BarcodeDataMatrix.DM_ERROR_TEXT_TOO_BIG); + Assertions.assertEquals(result, BarcodeDataMatrix.DM_ERROR_TEXT_TOO_BIG); } @Test @@ -184,7 +183,7 @@ public void barcode08Test() { barcodeDataMatrix.setHeight(18); int result = barcodeDataMatrix.setCode("AbcdFFghijklmnopqrstuWXSQ"); - Assert.assertEquals(BarcodeDataMatrix.DM_ERROR_TEXT_TOO_BIG, result); + Assertions.assertEquals(BarcodeDataMatrix.DM_ERROR_TEXT_TOO_BIG, result); } @Test @@ -194,7 +193,7 @@ public void barcode09Test() { barcodeDataMatrix.setHeight(17); int result = barcodeDataMatrix.setCode("AbcdFFghijklmnopqrstuWXSQ"); - Assert.assertEquals(BarcodeDataMatrix.DM_ERROR_INVALID_SQUARE, result); + Assertions.assertEquals(BarcodeDataMatrix.DM_ERROR_INVALID_SQUARE, result); } @Test @@ -204,7 +203,7 @@ public void barcode10Test() { barcodeDataMatrix.setHeight(12); int result = barcodeDataMatrix.setCode("AbcdFFghijklmnopqrstuWXSQ"); - Assert.assertEquals(BarcodeDataMatrix.DM_ERROR_TEXT_TOO_BIG, result); + Assertions.assertEquals(BarcodeDataMatrix.DM_ERROR_TEXT_TOO_BIG, result); } @Test @@ -215,7 +214,7 @@ public void barcode11Test() { byte[] str = "AbcdFFghijklmnop".getBytes(); int result = barcodeDataMatrix.setCode(str, 0, str.length); - Assert.assertEquals(BarcodeDataMatrix.DM_NO_ERROR, result); + Assertions.assertEquals(BarcodeDataMatrix.DM_NO_ERROR, result); } @Test @@ -225,7 +224,7 @@ public void barcode12Test() { barcodeDataMatrix.setHeight(18); byte[] str = "AbcdFFghijklmnop".getBytes(); - Exception e = Assert.assertThrows(IndexOutOfBoundsException.class, () -> barcodeDataMatrix.setCode(str, -1, str.length)); + Exception e = Assertions.assertThrows(IndexOutOfBoundsException.class, () -> barcodeDataMatrix.setCode(str, -1, str.length)); } @Test @@ -235,7 +234,7 @@ public void barcode13Test() { barcodeDataMatrix.setHeight(18); byte[] str = "AbcdFFghijklmnop".getBytes(); - Assert.assertThrows(IndexOutOfBoundsException.class, () -> barcodeDataMatrix.setCode(str, 0, str.length + 1)); + Assertions.assertThrows(IndexOutOfBoundsException.class, () -> barcodeDataMatrix.setCode(str, 0, str.length + 1)); } @Test @@ -245,7 +244,7 @@ public void barcode14Test() { barcodeDataMatrix.setHeight(18); byte[] str = "AbcdFFghijklmnop".getBytes(); - Assert.assertThrows(IndexOutOfBoundsException.class, () -> barcodeDataMatrix.setCode(str, 0, -1)); + Assertions.assertThrows(IndexOutOfBoundsException.class, () -> barcodeDataMatrix.setCode(str, 0, -1)); } @Test @@ -256,7 +255,7 @@ public void barcode15Test() { byte[] str = "AbcdFFghijklmnop".getBytes(); int result = barcodeDataMatrix.setCode(str, str.length, 0); - Assert.assertEquals(BarcodeDataMatrix.DM_NO_ERROR, result); + Assertions.assertEquals(BarcodeDataMatrix.DM_NO_ERROR, result); } @Test @@ -271,6 +270,6 @@ public void barcode16Test() throws IOException, PdfException, InterruptedExcepti barcode.placeBarcode(canvas, ColorConstants.BLACK, 3); document.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder)); } } diff --git a/barcodes/src/test/java/com/itextpdf/barcodes/BarcodeEANTest.java b/barcodes/src/test/java/com/itextpdf/barcodes/BarcodeEANTest.java index b8b591d490..dee3bcbba9 100644 --- a/barcodes/src/test/java/com/itextpdf/barcodes/BarcodeEANTest.java +++ b/barcodes/src/test/java/com/itextpdf/barcodes/BarcodeEANTest.java @@ -31,26 +31,25 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.canvas.PdfCanvas; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class BarcodeEANTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/barcodes/"; public static final String destinationFolder = "./target/test/com/itextpdf/barcodes/BarcodeEAN/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(destinationFolder); } @@ -73,7 +72,7 @@ public void barcode01Test() throws IOException, PdfException, InterruptedExcepti document.close(); - Assert.assertNull(new CompareTool() + Assertions.assertNull(new CompareTool() .compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_")); } @@ -96,7 +95,7 @@ public void barcode02Test() throws IOException, PdfException, InterruptedExcepti document.close(); - Assert.assertNull(new CompareTool() + Assertions.assertNull(new CompareTool() .compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_")); } @@ -122,7 +121,7 @@ public void barcode03Test() throws IOException, PdfException, InterruptedExcepti document.close(); - Assert.assertNull(new CompareTool() + Assertions.assertNull(new CompareTool() .compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_")); } @@ -144,7 +143,7 @@ public void placeBarcodeUPCATest() throws IOException, PdfException, Interrupted document.close(); - Assert.assertNull(new CompareTool() + Assertions.assertNull(new CompareTool() .compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_")); } @@ -166,7 +165,7 @@ public void placeBarcodeUPCETest() throws IOException, PdfException, Interrupted document.close(); - Assert.assertNull(new CompareTool() + Assertions.assertNull(new CompareTool() .compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_")); } @@ -188,7 +187,7 @@ public void placeBarcodeSUPP2Test() throws IOException, PdfException, Interrupte document.close(); - Assert.assertNull(new CompareTool() + Assertions.assertNull(new CompareTool() .compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_")); } @@ -210,7 +209,7 @@ public void placeBarcodeSUPP5Test() throws IOException, PdfException, Interrupte document.close(); - Assert.assertNull(new CompareTool() + Assertions.assertNull(new CompareTool() .compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_")); } diff --git a/barcodes/src/test/java/com/itextpdf/barcodes/BarcodeEANUnitTest.java b/barcodes/src/test/java/com/itextpdf/barcodes/BarcodeEANUnitTest.java index d04335b7eb..fdcffc9f7e 100644 --- a/barcodes/src/test/java/com/itextpdf/barcodes/BarcodeEANUnitTest.java +++ b/barcodes/src/test/java/com/itextpdf/barcodes/BarcodeEANUnitTest.java @@ -27,14 +27,13 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfWriter; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.ByteArrayOutputStream; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class BarcodeEANUnitTest extends ExtendedITextTest { public static final float EPS = 0.0001f; @@ -43,91 +42,91 @@ public class BarcodeEANUnitTest extends ExtendedITextTest { public void calculateEANParityTest() throws PdfException { int expectedParity = BarcodeEAN.calculateEANParity("1234567890"); - Assert.assertEquals(5, expectedParity); + Assertions.assertEquals(5, expectedParity); } @Test public void convertUPCAtoUPCEIncorrectTextTest() throws PdfException { String expectedUpce = BarcodeEAN.convertUPCAtoUPCE("HelloWorld"); - Assert.assertNull(expectedUpce); + Assertions.assertNull(expectedUpce); } @Test public void convertUPCAtoUPCE12DigitsStartNotWith0Or1Test() throws PdfException { String expectedUpce = BarcodeEAN.convertUPCAtoUPCE("025272730706"); - Assert.assertNull(expectedUpce); + Assertions.assertNull(expectedUpce); } @Test public void convertUPCAtoUPCEFrom3Position00000Test() throws PdfException { String expectedUpce = BarcodeEAN.convertUPCAtoUPCE("012000005706"); - Assert.assertEquals("01257006", expectedUpce); + Assertions.assertEquals("01257006", expectedUpce); } @Test public void convertUPCAtoUPCEFrom3Position10000Test() throws PdfException { String expectedUpce = BarcodeEAN.convertUPCAtoUPCE("012100005706"); - Assert.assertEquals("01257016", expectedUpce); + Assertions.assertEquals("01257016", expectedUpce); } @Test public void convertUPCAtoUPCEFrom3Position20000Test() throws PdfException { String expectedUpce = BarcodeEAN.convertUPCAtoUPCE("012200005706"); - Assert.assertEquals("01257026", expectedUpce); + Assertions.assertEquals("01257026", expectedUpce); } @Test public void convertUPCAtoUPCEFrom3Position000NullTest() throws PdfException { String expectedUpce = BarcodeEAN.convertUPCAtoUPCE("012000111706"); - Assert.assertNull(expectedUpce); + Assertions.assertNull(expectedUpce); } @Test public void convertUPCAtoUPCEFrom4Position00NullTest() throws PdfException { String expectedUpce = BarcodeEAN.convertUPCAtoUPCE("012300111706"); - Assert.assertNull(expectedUpce); + Assertions.assertNull(expectedUpce); } @Test public void convertUPCAtoUPCEFrom4Position00000Test() throws PdfException { String expectedUpce = BarcodeEAN.convertUPCAtoUPCE("012300000706"); - Assert.assertEquals("01237036", expectedUpce); + Assertions.assertEquals("01237036", expectedUpce); } @Test public void convertUPCAtoUPCEFrom5Position0NullTest() throws PdfException { String expectedUpce = BarcodeEAN.convertUPCAtoUPCE("012340111706"); - Assert.assertNull(expectedUpce); + Assertions.assertNull(expectedUpce); } @Test public void convertUPCAtoUPCEFrom5Position00000Test() throws PdfException { String expectedUpce = BarcodeEAN.convertUPCAtoUPCE("012340000006"); - Assert.assertEquals("01234046", expectedUpce); + Assertions.assertEquals("01234046", expectedUpce); } @Test public void convertUPCAtoUPCE10PositionBiggerThan5NullTest() throws PdfException { String expectedUpce = BarcodeEAN.convertUPCAtoUPCE("011111111711"); - Assert.assertNull(expectedUpce); + Assertions.assertNull(expectedUpce); } @Test public void convertUPCAtoUPCE10PositionBiggerThan5Test() throws PdfException { String expectedUpce = BarcodeEAN.convertUPCAtoUPCE("011111000090"); - Assert.assertEquals("01111190", expectedUpce); + Assertions.assertEquals("01111190", expectedUpce); } @Test @@ -135,9 +134,9 @@ public void getBarsUPCETest() throws PdfException { String expectedBytes = "111212211411132132141111312111111"; byte[] bytes = BarcodeEAN.getBarsUPCE("12345678"); - Assert.assertEquals(33, bytes.length); + Assertions.assertEquals(33, bytes.length); for (int i = 0; i < expectedBytes.length(); i++) { - Assert.assertEquals(expectedBytes.charAt(i) - '0', bytes[i]); + Assertions.assertEquals(expectedBytes.charAt(i) - '0', bytes[i]); } } @@ -146,9 +145,9 @@ public void getBarsSupplemental2Test() throws PdfException { String expectedBytes = "1121222113211"; byte[] bytes = BarcodeEAN.getBarsSupplemental2("10"); - Assert.assertEquals(13, bytes.length); + Assertions.assertEquals(13, bytes.length); for (int i = 0; i < expectedBytes.length(); i++) { - Assert.assertEquals(expectedBytes.charAt(i) - '0', bytes[i]); + Assertions.assertEquals(expectedBytes.charAt(i) - '0', bytes[i]); } } @@ -164,8 +163,8 @@ public void getBarcodeSizeUPCATest() throws PdfException { Rectangle barcodeSize = barcode.getBarcodeSize(); - Assert.assertEquals(expectedRectangle.getWidth(), barcodeSize.getWidth(), EPS); - Assert.assertEquals(expectedRectangle.getHeight(), barcodeSize.getHeight(), EPS); + Assertions.assertEquals(expectedRectangle.getWidth(), barcodeSize.getWidth(), EPS); + Assertions.assertEquals(expectedRectangle.getHeight(), barcodeSize.getHeight(), EPS); } @Test @@ -180,8 +179,8 @@ public void getBarcodeSizeUPCETest() throws PdfException { Rectangle barcodeSize = barcode.getBarcodeSize(); - Assert.assertEquals(expectedRectangle.getWidth(), barcodeSize.getWidth(), EPS); - Assert.assertEquals(expectedRectangle.getHeight(), barcodeSize.getHeight(), EPS); + Assertions.assertEquals(expectedRectangle.getWidth(), barcodeSize.getWidth(), EPS); + Assertions.assertEquals(expectedRectangle.getHeight(), barcodeSize.getHeight(), EPS); } @Test @@ -196,8 +195,8 @@ public void getBarcodeSizeSUPP2Test() throws PdfException { Rectangle barcodeSize = barcode.getBarcodeSize(); - Assert.assertEquals(expectedRectangle.getWidth(), barcodeSize.getWidth(), EPS); - Assert.assertEquals(expectedRectangle.getHeight(), barcodeSize.getHeight(), EPS); + Assertions.assertEquals(expectedRectangle.getWidth(), barcodeSize.getWidth(), EPS); + Assertions.assertEquals(expectedRectangle.getHeight(), barcodeSize.getHeight(), EPS); } @Test @@ -211,7 +210,7 @@ public void getBarcodeSizeIncorrectTypeTest() throws PdfException { barcode.setCodeType(1234); // We do expect an exception here - Exception e = Assert.assertThrows(PdfException.class, () -> barcode.getBarcodeSize()); - Assert.assertEquals("Invalid code type", e.getMessage()); + Exception e = Assertions.assertThrows(PdfException.class, () -> barcode.getBarcodeSize()); + Assertions.assertEquals("Invalid code type", e.getMessage()); } } diff --git a/barcodes/src/test/java/com/itextpdf/barcodes/BarcodeInter25Test.java b/barcodes/src/test/java/com/itextpdf/barcodes/BarcodeInter25Test.java index 07a86401a3..04c998914c 100644 --- a/barcodes/src/test/java/com/itextpdf/barcodes/BarcodeInter25Test.java +++ b/barcodes/src/test/java/com/itextpdf/barcodes/BarcodeInter25Test.java @@ -31,28 +31,27 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.canvas.PdfCanvas; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class BarcodeInter25Test extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/barcodes/"; public static final String destinationFolder = "./target/test/com/itextpdf/barcodes/BarcodeInter25/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(destinationFolder); } @@ -73,7 +72,7 @@ public void barcode01Test() throws IOException, PdfException, InterruptedExcepti barcode.placeBarcode(canvas, ColorConstants.BLUE, ColorConstants.GREEN); document.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_")); } } diff --git a/barcodes/src/test/java/com/itextpdf/barcodes/BarcodeMSITest.java b/barcodes/src/test/java/com/itextpdf/barcodes/BarcodeMSITest.java index a53c67d5d0..1d02945ce6 100644 --- a/barcodes/src/test/java/com/itextpdf/barcodes/BarcodeMSITest.java +++ b/barcodes/src/test/java/com/itextpdf/barcodes/BarcodeMSITest.java @@ -31,29 +31,28 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.canvas.PdfCanvas; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class BarcodeMSITest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/barcodes/"; public static final String destinationFolder = "./target/test/com/itextpdf/barcodes/BarcodeMSI/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(destinationFolder); } @@ -71,7 +70,7 @@ public void barcode01Test() throws IOException, PdfException, InterruptedExcepti barcode.setTextAlignment(Barcode1D.ALIGN_LEFT); barcode.placeBarcode(canvas, ColorConstants.BLACK, ColorConstants.WHITE); document.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff01_")); + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff01_")); } @@ -87,7 +86,7 @@ public void barcode02Test() throws IOException, InterruptedException { barcode.setTextAlignment(Barcode1D.ALIGN_LEFT); barcode.placeBarcode(canvas, ColorConstants.BLACK, ColorConstants.WHITE); document.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff02_")); + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff02_")); } @Test @@ -103,7 +102,7 @@ public void barcodeAlignRightTest() throws IOException, InterruptedException { barcode.setTextAlignment(Barcode1D.ALIGN_RIGHT); barcode.placeBarcode(canvas, ColorConstants.BLACK, ColorConstants.RED); document.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff01_")); + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff01_")); } @Test @@ -119,7 +118,7 @@ public void barcodeAlignCenterTest() throws IOException, InterruptedException { barcode.setTextAlignment(Barcode1D.ALIGN_CENTER); barcode.placeBarcode(canvas, ColorConstants.BLACK, ColorConstants.RED); document.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff01_")); + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff01_")); } @Test @@ -127,7 +126,7 @@ public void barcode03Test() { byte[] expected = {1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1}; byte[] barcodeBytes = BarcodeMSI.getBarsMSI("1234"); boolean isEqual = java.util.Arrays.equals(expected, barcodeBytes); - Assert.assertTrue(isEqual); + Assertions.assertTrue(isEqual); } @Test @@ -135,6 +134,6 @@ public void barcode04Test() { String code = "0987654321"; int expectedChecksum = 7; int checksum = BarcodeMSI.getChecksum(code); - Assert.assertEquals(checksum, expectedChecksum); + Assertions.assertEquals(checksum, expectedChecksum); } } diff --git a/barcodes/src/test/java/com/itextpdf/barcodes/BarcodeMultiThreadingTest.java b/barcodes/src/test/java/com/itextpdf/barcodes/BarcodeMultiThreadingTest.java index 869ca0fefa..a17556c07c 100644 --- a/barcodes/src/test/java/com/itextpdf/barcodes/BarcodeMultiThreadingTest.java +++ b/barcodes/src/test/java/com/itextpdf/barcodes/BarcodeMultiThreadingTest.java @@ -23,12 +23,14 @@ This file is part of the iText (R) project. package com.itextpdf.barcodes; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; -@Category(UnitTest.class) +import java.util.concurrent.TimeUnit; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Timeout; + +@Tag("UnitTest") public class BarcodeMultiThreadingTest extends ExtendedITextTest { private static class DataMatrixThread extends Thread { @@ -40,11 +42,12 @@ public void run() { bc.setHeight(10); int result = bc.setCode("AB01"); - Assert.assertEquals(BarcodeDataMatrix.DM_NO_ERROR, result); + Assertions.assertEquals(BarcodeDataMatrix.DM_NO_ERROR, result); } } - @Test(timeout = 10000) + @Timeout(unit = TimeUnit.MILLISECONDS, value = 10000) + @Test public void test() throws InterruptedException { Thread[] threads = new DataMatrixThread[20]; for (int i = 0; i < threads.length; i++) { diff --git a/barcodes/src/test/java/com/itextpdf/barcodes/BarcodePDF417Test.java b/barcodes/src/test/java/com/itextpdf/barcodes/BarcodePDF417Test.java index f44e60b8a9..1b73ab84a4 100644 --- a/barcodes/src/test/java/com/itextpdf/barcodes/BarcodePDF417Test.java +++ b/barcodes/src/test/java/com/itextpdf/barcodes/BarcodePDF417Test.java @@ -37,28 +37,27 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.xobject.PdfFormXObject; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.ByteArrayOutputStream; import java.io.IOException; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class BarcodePDF417Test extends ExtendedITextTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/barcodes/"; private static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/barcodes/BarcodePDF417/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(DESTINATION_FOLDER); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(DESTINATION_FOLDER); } @@ -83,7 +82,7 @@ public void barcode01Test() throws IOException, PdfException, InterruptedExcepti document.close(); - Assert.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + filename, SOURCE_FOLDER + "cmp_" + filename, + Assertions.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + filename, SOURCE_FOLDER + "cmp_" + filename, DESTINATION_FOLDER, "diff_")); } @@ -107,7 +106,7 @@ public void barcode02Test() throws IOException, PdfException, InterruptedExcepti document.close(); - Assert.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + filename, SOURCE_FOLDER + "cmp_" + filename, + Assertions.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + filename, SOURCE_FOLDER + "cmp_" + filename, DESTINATION_FOLDER, "diff_")); } @@ -124,7 +123,7 @@ public void macroPDF417Test01() throws IOException, InterruptedException { pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + filename, SOURCE_FOLDER + "cmp_" + filename, + Assertions.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + filename, SOURCE_FOLDER + "cmp_" + filename, DESTINATION_FOLDER, "diff_")); } @@ -149,7 +148,7 @@ public void barcode417AspectRatioTest() { document.close(); - Assert.assertEquals(10, barcode.getAspectRatio(), 0); + Assertions.assertEquals(10, barcode.getAspectRatio(), 0); } @Test @@ -174,7 +173,7 @@ public void barcode417DefaultParamsTest() { document.close(); - Assert.assertEquals(0.5, barcode.getAspectRatio(), 0); + Assertions.assertEquals(0.5, barcode.getAspectRatio(), 0); } // Android-Conversion-Skip-Block-Start (java.awt library isn't available on Android) @@ -202,7 +201,7 @@ public void barcode417CreateAWTImageTest() throws IOException, InterruptedExcept document.close(); - Assert.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + filename, + Assertions.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + filename, SOURCE_FOLDER + "cmp_" + filename, DESTINATION_FOLDER)); } @@ -228,7 +227,7 @@ public void barcode417XObjectTest() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + filename, + Assertions.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + filename, SOURCE_FOLDER + "cmp_" + filename, DESTINATION_FOLDER)); } // Android-Conversion-Skip-Block-End @@ -254,7 +253,7 @@ public void barcode417YHeightTest() { document.close(); - Assert.assertEquals(15, barcode.getYHeight(), 0); + Assertions.assertEquals(15, barcode.getYHeight(), 0); } @Test @@ -282,7 +281,7 @@ public void barcode417CodeReuseTest() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + filename, + Assertions.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + filename, SOURCE_FOLDER + "cmp_" + filename, DESTINATION_FOLDER)); } @@ -302,7 +301,7 @@ public void barcode417NumbersTest() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + filename, + Assertions.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + filename, SOURCE_FOLDER + "cmp_" + filename, DESTINATION_FOLDER)); } @@ -322,7 +321,7 @@ public void barcode417ByteLessThanSixSizeNumbersTest() throws IOException, Inter document.close(); - Assert.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + filename, + Assertions.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + filename, SOURCE_FOLDER + "cmp_" + filename, DESTINATION_FOLDER)); } @@ -342,7 +341,7 @@ public void barcode417ByteMoreThanSixSizeNumbersTest() throws IOException, Inter document.close(); - Assert.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + filename, + Assertions.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + filename, SOURCE_FOLDER + "cmp_" + filename, DESTINATION_FOLDER)); } @@ -359,7 +358,7 @@ public void barcode417CodeRowsWithBarcodeGenerationTest() { barcode.setCodeRows(150); barcode.placeBarcode(canvas, null); - Assert.assertEquals(8, barcode.getCodeRows()); + Assertions.assertEquals(8, barcode.getCodeRows()); } @Test @@ -375,7 +374,7 @@ public void barcode417CodeColumnsWithBarcodeGenerationTest() { barcode.setCodeColumns(150); barcode.placeBarcode(canvas, null); - Assert.assertEquals(1, barcode.getCodeColumns()); + Assertions.assertEquals(1, barcode.getCodeColumns()); } @Test @@ -391,7 +390,7 @@ public void barcode417CodeWordsWithBarcodeGenerationTest() { barcode.setLenCodewords(150); barcode.placeBarcode(canvas, null); - Assert.assertEquals(8, barcode.getLenCodewords()); + Assertions.assertEquals(8, barcode.getLenCodewords()); } @Test @@ -407,7 +406,7 @@ public void barcode417ErrorLevelWithBarcodeGenerationTest() { barcode.setErrorLevel(3); barcode.placeBarcode(canvas, null); - Assert.assertEquals(2, barcode.getErrorLevel()); + Assertions.assertEquals(2, barcode.getErrorLevel()); } @Test @@ -423,7 +422,7 @@ public void barcode417OptionsWithBarcodeGenerationTest() { barcode.setOptions(63); barcode.placeBarcode(canvas, null); - Assert.assertEquals(63, barcode.getOptions()); + Assertions.assertEquals(63, barcode.getOptions()); } @Test @@ -438,20 +437,20 @@ public void barcode417OptionsWithBarcodeGenerationInvalidSizeTest() { BarcodePDF417 barcode = new BarcodePDF417(); barcode.setOptions(64); - Exception e = Assert.assertThrows(PdfException.class, + Exception e = Assertions.assertThrows(PdfException.class, () -> barcode.placeBarcode(canvas, null) ); - Assert.assertEquals("Invalid codeword size.", e.getMessage()); - Assert.assertEquals(64, barcode.getOptions()); + Assertions.assertEquals("Invalid codeword size.", e.getMessage()); + Assertions.assertEquals(64, barcode.getOptions()); } @Test public void lenCodewordsIsNotEnoughTest() { BarcodePDF417 barcodePDF417 = new BarcodePDF417(); barcodePDF417.setOptions(BarcodePDF417.PDF417_USE_RAW_CODEWORDS); - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> barcodePDF417.paintCode()); - Assert.assertEquals(BarcodesExceptionMessageConstant.INVALID_CODEWORD_SIZE, exception.getMessage()); + Assertions.assertEquals(BarcodesExceptionMessageConstant.INVALID_CODEWORD_SIZE, exception.getMessage()); } @Test @@ -460,9 +459,9 @@ public void lenCodewordsIsTooSmallTest() { barcodePDF417.setOptions(BarcodePDF417.PDF417_USE_RAW_CODEWORDS); // lenCodeWords should be bigger than 1 barcodePDF417.setLenCodewords(0); - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> barcodePDF417.paintCode()); - Assert.assertEquals(BarcodesExceptionMessageConstant.INVALID_CODEWORD_SIZE, exception.getMessage()); + Assertions.assertEquals(BarcodesExceptionMessageConstant.INVALID_CODEWORD_SIZE, exception.getMessage()); } @Test @@ -471,9 +470,9 @@ public void lenCodewordsMoreThanMaxDataCodewordsTest() { barcodePDF417.setOptions(BarcodePDF417.PDF417_USE_RAW_CODEWORDS); // lenCodeWords should be smaller than MAX_DATA_CODEWORDS barcodePDF417.setLenCodewords(927); - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> barcodePDF417.paintCode()); - Assert.assertEquals(BarcodesExceptionMessageConstant.INVALID_CODEWORD_SIZE, exception.getMessage()); + Assertions.assertEquals(BarcodesExceptionMessageConstant.INVALID_CODEWORD_SIZE, exception.getMessage()); } @Test @@ -502,7 +501,7 @@ public void ccittImageFromBarcodeTest() throws IOException, InterruptedException document.close(); - Assert.assertNull( + Assertions.assertNull( new CompareTool().compareByContent(DESTINATION_FOLDER + filename, SOURCE_FOLDER + "cmp_" + filename, DESTINATION_FOLDER, "diff_")); } diff --git a/barcodes/src/test/java/com/itextpdf/barcodes/BarcodePDF417UnitTest.java b/barcodes/src/test/java/com/itextpdf/barcodes/BarcodePDF417UnitTest.java index c633faaea6..a69c16cf43 100644 --- a/barcodes/src/test/java/com/itextpdf/barcodes/BarcodePDF417UnitTest.java +++ b/barcodes/src/test/java/com/itextpdf/barcodes/BarcodePDF417UnitTest.java @@ -23,13 +23,12 @@ This file is part of the iText (R) project. package com.itextpdf.barcodes; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class BarcodePDF417UnitTest extends ExtendedITextTest { @Test @@ -37,7 +36,7 @@ public void barcode417CodeRowsTest() { BarcodePDF417 barcode = new BarcodePDF417(); barcode.setCodeRows(150); - Assert.assertEquals(150, barcode.getCodeRows()); + Assertions.assertEquals(150, barcode.getCodeRows()); } @Test @@ -45,7 +44,7 @@ public void barcode417CodeColumnsTest() { BarcodePDF417 barcode = new BarcodePDF417(); barcode.setCodeColumns(150); - Assert.assertEquals(150, barcode.getCodeColumns()); + Assertions.assertEquals(150, barcode.getCodeColumns()); } @Test @@ -53,7 +52,7 @@ public void barcode417CodeWordsTest() { BarcodePDF417 barcode = new BarcodePDF417(); barcode.setLenCodewords(150); - Assert.assertEquals(150, barcode.getLenCodewords()); + Assertions.assertEquals(150, barcode.getLenCodewords()); } @Test @@ -61,14 +60,14 @@ public void barcode417ErrorLevelTest() { BarcodePDF417 barcode = new BarcodePDF417(); barcode.setErrorLevel(3); - Assert.assertEquals(3, barcode.getErrorLevel()); + Assertions.assertEquals(3, barcode.getErrorLevel()); } @Test public void barcode417GetCodeWordsTest() { BarcodePDF417 barcode = new BarcodePDF417(); - Assert.assertEquals(928, barcode.getCodewords().length); + Assertions.assertEquals(928, barcode.getCodewords().length); } @Test @@ -76,7 +75,7 @@ public void barcode417OptionsTest() { BarcodePDF417 barcode = new BarcodePDF417(); barcode.setOptions(100); - Assert.assertEquals(100, barcode.getOptions()); + Assertions.assertEquals(100, barcode.getOptions()); } @Test @@ -88,6 +87,6 @@ public void barcode417MaxSquareTest() { BarcodePDF417 barcode = new BarcodePDF417(); barcode.setCode(text); - Assert.assertEquals(928, barcode.getMaxSquare()); + Assertions.assertEquals(928, barcode.getMaxSquare()); } } diff --git a/barcodes/src/test/java/com/itextpdf/barcodes/BarcodePostnetTest.java b/barcodes/src/test/java/com/itextpdf/barcodes/BarcodePostnetTest.java index 2b7f4cad9a..296e7ef47b 100644 --- a/barcodes/src/test/java/com/itextpdf/barcodes/BarcodePostnetTest.java +++ b/barcodes/src/test/java/com/itextpdf/barcodes/BarcodePostnetTest.java @@ -29,28 +29,27 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.canvas.PdfCanvas; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class BarcodePostnetTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/barcodes/"; public static final String destinationFolder = "./target/test/com/itextpdf/barcodes/BarcodePostnet/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(destinationFolder); } @@ -70,7 +69,7 @@ public void barcode01Test() throws IOException, PdfException, InterruptedExcepti codePlanet.placeBarcode(canvas, null, null); document.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_")); } } diff --git a/barcodes/src/test/java/com/itextpdf/barcodes/BarcodeQRCodeTest.java b/barcodes/src/test/java/com/itextpdf/barcodes/BarcodeQRCodeTest.java index 2e62f4f179..cf1c3f1b05 100644 --- a/barcodes/src/test/java/com/itextpdf/barcodes/BarcodeQRCodeTest.java +++ b/barcodes/src/test/java/com/itextpdf/barcodes/BarcodeQRCodeTest.java @@ -32,30 +32,29 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.canvas.PdfCanvas; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; import java.util.HashMap; import java.util.Map; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class BarcodeQRCodeTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/barcodes/"; public static final String destinationFolder = "./target/test/com/itextpdf/barcodes/BarcodeQRCode/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(destinationFolder); } @@ -75,7 +74,7 @@ public void barcode01Test() throws IOException, PdfException, InterruptedExcepti barcode.placeBarcode(canvas, ColorConstants.GRAY, 12); document.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_")); } @Test @@ -91,7 +90,7 @@ public void barcode02Test() throws IOException, PdfException, InterruptedExcepti BarcodeQRCode barcode1 = new BarcodeQRCode("дима", hints); barcode1.placeBarcode(canvas, ColorConstants.GRAY, 12); document.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_")); } @Test @@ -109,7 +108,7 @@ public void barcodeVersioningTest() throws IOException, PdfException, Interrupte barcode1.placeBarcode(canvas, ColorConstants.GRAY, 3); } document.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_")); } diff --git a/barcodes/src/test/java/com/itextpdf/barcodes/BarcodeUnitTest.java b/barcodes/src/test/java/com/itextpdf/barcodes/BarcodeUnitTest.java index 51f5e311cc..0db934891a 100644 --- a/barcodes/src/test/java/com/itextpdf/barcodes/BarcodeUnitTest.java +++ b/barcodes/src/test/java/com/itextpdf/barcodes/BarcodeUnitTest.java @@ -27,12 +27,11 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfWriter; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class BarcodeUnitTest extends ExtendedITextTest { private static final double EPS = 0.0001; @@ -47,8 +46,8 @@ public void BarcodeMSIGetBarcodeSizeWithChecksumTest() { barcode.setCode("123456789"); barcode.setGenerateChecksum(true); Rectangle barcodeSize = barcode.getBarcodeSize(); - Assert.assertEquals(33.656, barcodeSize.getHeight(), EPS); - Assert.assertEquals(101.6, barcodeSize.getWidth(), EPS); + Assertions.assertEquals(33.656, barcodeSize.getHeight(), EPS); + Assertions.assertEquals(101.6, barcodeSize.getWidth(), EPS); } @Test @@ -61,7 +60,7 @@ public void BarcodeMSIGetBarcodeSizeWithoutChecksumTest() { barcode.setCode("123456789"); barcode.setGenerateChecksum(false); Rectangle barcodeSize = barcode.getBarcodeSize(); - Assert.assertEquals(33.656, barcodeSize.getHeight(), EPS); - Assert.assertEquals(92.0, barcodeSize.getWidth(), EPS); + Assertions.assertEquals(33.656, barcodeSize.getHeight(), EPS); + Assertions.assertEquals(92.0, barcodeSize.getWidth(), EPS); } } diff --git a/bouncy-castle-adapter/pom.xml b/bouncy-castle-adapter/pom.xml index 86ae66ec2f..39d0ec4cda 100644 --- a/bouncy-castle-adapter/pom.xml +++ b/bouncy-castle-adapter/pom.xml @@ -5,7 +5,7 @@ com.itextpdf root - 8.0.5 + 9.0.0 bouncy-castle-adapter diff --git a/bouncy-castle-adapter/src/main/java/com/itextpdf/bouncycastle/BouncyCastleFactory.java b/bouncy-castle-adapter/src/main/java/com/itextpdf/bouncycastle/BouncyCastleFactory.java index 522ef7dce9..1453fc6361 100644 --- a/bouncy-castle-adapter/src/main/java/com/itextpdf/bouncycastle/BouncyCastleFactory.java +++ b/bouncy-castle-adapter/src/main/java/com/itextpdf/bouncycastle/BouncyCastleFactory.java @@ -114,6 +114,7 @@ This file is part of the iText (R) project. import com.itextpdf.bouncycastle.cms.jcajce.JcaSimpleSignerInfoVerifierBuilderBC; import com.itextpdf.bouncycastle.cms.jcajce.JceKeyAgreeEnvelopedRecipientBC; import com.itextpdf.bouncycastle.cms.jcajce.JceKeyTransEnvelopedRecipientBC; +import com.itextpdf.bouncycastle.crypto.modes.GCMBlockCipherBC; import com.itextpdf.bouncycastle.openssl.PEMParserBC; import com.itextpdf.bouncycastle.openssl.jcajce.JcaPEMKeyConverterBC; import com.itextpdf.bouncycastle.openssl.jcajce.JceOpenSSLPKCS8DecryptorProviderBuilderBC; @@ -221,6 +222,7 @@ This file is part of the iText (R) project. import com.itextpdf.commons.bouncycastle.cms.jcajce.IJcaSimpleSignerInfoVerifierBuilder; import com.itextpdf.commons.bouncycastle.cms.jcajce.IJceKeyAgreeEnvelopedRecipient; import com.itextpdf.commons.bouncycastle.cms.jcajce.IJceKeyTransEnvelopedRecipient; +import com.itextpdf.commons.bouncycastle.crypto.modes.IGCMBlockCipher; import com.itextpdf.commons.bouncycastle.openssl.IPEMParser; import com.itextpdf.commons.bouncycastle.openssl.jcajce.IJcaPEMKeyConverter; import com.itextpdf.commons.bouncycastle.openssl.jcajce.IJceOpenSSLPKCS8DecryptorProviderBuilder; @@ -245,6 +247,7 @@ This file is part of the iText (R) project. import java.math.BigInteger; import java.security.GeneralSecurityException; import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; import java.security.PrivateKey; import java.security.Provider; import java.security.PublicKey; @@ -257,6 +260,8 @@ This file is part of the iText (R) project. import java.util.List; import java.util.Set; import javax.crypto.Cipher; +import javax.crypto.Mac; +import javax.crypto.spec.SecretKeySpec; import org.bouncycastle.asn1.ASN1BitString; import org.bouncycastle.asn1.ASN1Enumerated; import org.bouncycastle.asn1.ASN1GeneralizedTime; @@ -314,6 +319,11 @@ This file is part of the iText (R) project. import org.bouncycastle.cms.jcajce.JcaSimpleSignerInfoVerifierBuilder; import org.bouncycastle.cms.jcajce.JceKeyAgreeEnvelopedRecipient; import org.bouncycastle.cms.jcajce.JceKeyTransEnvelopedRecipient; +import org.bouncycastle.crypto.digests.SHA256Digest; +import org.bouncycastle.crypto.generators.HKDFBytesGenerator; +import org.bouncycastle.crypto.params.HKDFParameters; +import org.bouncycastle.crypto.engines.AESEngine; +import org.bouncycastle.crypto.modes.GCMBlockCipher; import org.bouncycastle.jce.provider.BouncyCastleProvider; import org.bouncycastle.openssl.PEMParser; import org.bouncycastle.openssl.jcajce.JcaPEMKeyConverter; @@ -1576,6 +1586,15 @@ public IX500Name createX500Name(String s) { return new X500NameBC(new X500Name(s)); } + /** + * {@inheritDoc} + */ + @Override + public IX500Name createX500Name(IASN1Sequence s) { + return new X500NameBC(X500Name.getInstance(((ASN1SequenceBC) s).getASN1Sequence())); + } + + /** * {@inheritDoc} */ @@ -1846,8 +1865,64 @@ public byte[] createCipherBytes(X509Certificate x509certificate, byte[] abyte0, return cipher.doFinal(abyte0); } + /** + * {@inheritDoc} + */ @Override public void isEncryptionFeatureSupported(int encryptionType, boolean withCertificate) { //All features supported } + + /** + * {@inheritDoc} + */ + @Override + public byte[] generateHKDF(byte[] inputKey, byte[] salt, byte[] info) { + HKDFBytesGenerator hkdfBytesGenerator = new HKDFBytesGenerator(new SHA256Digest()); + HKDFParameters hkdfParameters = new HKDFParameters(inputKey, salt, info); + hkdfBytesGenerator.init(hkdfParameters); + byte[] hkdf = new byte[32]; + hkdfBytesGenerator.generateBytes(hkdf, 0, 32); + + return hkdf; + } + + /** + * {@inheritDoc} + */ + @Override + public byte[] generateHMACSHA256Token(byte[] key, byte[] data) throws NoSuchAlgorithmException, InvalidKeyException { + Mac mac = Mac.getInstance("HMacSHA256", this.getProvider()); + mac.init(new SecretKeySpec(key, "RawBytes")); + return mac.doFinal(data); + } + + /** + * {@inheritDoc} + */ + @Override + public byte[] generateEncryptedKeyWithAES256NoPad(byte[] key, byte[] kek) throws GeneralSecurityException { + Cipher cipher = Cipher.getInstance("AESWrap", this.getProvider()); + cipher.init(Cipher.WRAP_MODE, new SecretKeySpec(kek, "AESWrap")); + return cipher.wrap(new SecretKeySpec(key, "AESWrap")); + } + + /** + * {@inheritDoc} + */ + @Override + public byte[] generateDecryptedKeyWithAES256NoPad(byte[] key, byte[] kek) throws GeneralSecurityException { + Cipher cipher = Cipher.getInstance("AESWrap", this.getProvider()); + cipher.init(Cipher.UNWRAP_MODE, new SecretKeySpec(kek, "AESWrap")); + return cipher.unwrap(key, "AESWrap", Cipher.SECRET_KEY).getEncoded(); + } + + /** + * {@inheritDoc} + */ + @Override + public IGCMBlockCipher createGCMBlockCipher() { + GCMBlockCipher cipher = (GCMBlockCipher) GCMBlockCipher.newInstance(AESEngine.newInstance()); + return new GCMBlockCipherBC(cipher); + } } diff --git a/bouncy-castle-adapter/src/main/java/com/itextpdf/bouncycastle/asn1/ASN1EncodableVectorBC.java b/bouncy-castle-adapter/src/main/java/com/itextpdf/bouncycastle/asn1/ASN1EncodableVectorBC.java index 9d84acfd54..61f224ed13 100644 --- a/bouncy-castle-adapter/src/main/java/com/itextpdf/bouncycastle/asn1/ASN1EncodableVectorBC.java +++ b/bouncy-castle-adapter/src/main/java/com/itextpdf/bouncycastle/asn1/ASN1EncodableVectorBC.java @@ -121,6 +121,14 @@ public void addOptional(IAlgorithmIdentifier element) { } } + /** + * {@inheritDoc} + */ + @Override + public int size() { + return encodableVector.size(); + } + /** * Indicates whether some other object is "equal to" this one. Compares wrapped objects. */ diff --git a/bouncy-castle-adapter/src/main/java/com/itextpdf/bouncycastle/asn1/x500/X500NameBC.java b/bouncy-castle-adapter/src/main/java/com/itextpdf/bouncycastle/asn1/x500/X500NameBC.java index 83cd27d117..068fda270d 100644 --- a/bouncy-castle-adapter/src/main/java/com/itextpdf/bouncycastle/asn1/x500/X500NameBC.java +++ b/bouncy-castle-adapter/src/main/java/com/itextpdf/bouncycastle/asn1/x500/X500NameBC.java @@ -25,6 +25,8 @@ This file is part of the iText (R) project. import com.itextpdf.bouncycastle.asn1.ASN1EncodableBC; import com.itextpdf.commons.bouncycastle.asn1.x500.IX500Name; +import java.io.IOException; +import javax.security.auth.x500.X500Principal; import org.bouncycastle.asn1.x500.X500Name; /** @@ -48,4 +50,16 @@ public X500NameBC(X500Name x500Name) { public X500Name getX500Name() { return (X500Name) getEncodable(); } + + + // expected format CN=iTextTestOcspResponder,O=iText,C=BY + @Override + public String getName(){ + try { + return new X500Principal(getX500Name().getEncoded()).getName(); + } catch (IOException e) { + // should never happen + throw new RuntimeException(e); + } + } } diff --git a/bouncy-castle-adapter/src/main/java/com/itextpdf/bouncycastle/cert/ocsp/BasicOCSPRespBC.java b/bouncy-castle-adapter/src/main/java/com/itextpdf/bouncycastle/cert/ocsp/BasicOCSPRespBC.java index 6f01fdbdf2..00f7a4c658 100644 --- a/bouncy-castle-adapter/src/main/java/com/itextpdf/bouncycastle/cert/ocsp/BasicOCSPRespBC.java +++ b/bouncy-castle-adapter/src/main/java/com/itextpdf/bouncycastle/cert/ocsp/BasicOCSPRespBC.java @@ -30,6 +30,7 @@ This file is part of the iText (R) project. import com.itextpdf.commons.bouncycastle.asn1.IASN1ObjectIdentifier; import com.itextpdf.commons.bouncycastle.cert.IX509CertificateHolder; import com.itextpdf.commons.bouncycastle.cert.ocsp.IBasicOCSPResp; +import com.itextpdf.commons.bouncycastle.cert.ocsp.IRespID; import com.itextpdf.commons.bouncycastle.cert.ocsp.ISingleResp; import com.itextpdf.commons.bouncycastle.operator.IContentVerifierProvider; @@ -135,6 +136,14 @@ public IASN1Encodable getExtensionParsedValue(IASN1ObjectIdentifier objectIdenti return new ASN1EncodableBC(extension == null ? null : extension.getParsedValue()); } + /** + * {@inheritDoc} + */ + @Override + public IRespID getResponderId() { + return new RespIDBC(basicOCSPResp.getResponderId()); + } + /** * Indicates whether some other object is "equal to" this one. Compares wrapped objects. */ diff --git a/bouncy-castle-adapter/src/main/java/com/itextpdf/bouncycastle/cert/ocsp/RespIDBC.java b/bouncy-castle-adapter/src/main/java/com/itextpdf/bouncycastle/cert/ocsp/RespIDBC.java index e4a4ed72ef..d478b33d22 100644 --- a/bouncy-castle-adapter/src/main/java/com/itextpdf/bouncycastle/cert/ocsp/RespIDBC.java +++ b/bouncy-castle-adapter/src/main/java/com/itextpdf/bouncycastle/cert/ocsp/RespIDBC.java @@ -25,6 +25,7 @@ This file is part of the iText (R) project. import com.itextpdf.bouncycastle.asn1.x500.X500NameBC; import com.itextpdf.commons.bouncycastle.asn1.x500.IX500Name; import com.itextpdf.commons.bouncycastle.cert.ocsp.IRespID; +import com.itextpdf.commons.bouncycastle.cert.ocsp.IResponderID; import java.util.Objects; import org.bouncycastle.cert.ocsp.RespID; @@ -62,6 +63,15 @@ public RespID getRespID() { return respID; } + /** + * {@inheritDoc} + */ + @Override + public IResponderID toASN1Primitive() { + return new ResponderIDBC(respID.toASN1Primitive()); + } + + /** * Indicates whether some other object is "equal to" this one. Compares wrapped objects. */ diff --git a/bouncy-castle-adapter/src/main/java/com/itextpdf/bouncycastle/cert/ocsp/ResponderIDBC.java b/bouncy-castle-adapter/src/main/java/com/itextpdf/bouncycastle/cert/ocsp/ResponderIDBC.java new file mode 100644 index 0000000000..60c2d2463c --- /dev/null +++ b/bouncy-castle-adapter/src/main/java/com/itextpdf/bouncycastle/cert/ocsp/ResponderIDBC.java @@ -0,0 +1,62 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.bouncycastle.cert.ocsp; + +import com.itextpdf.bouncycastle.asn1.x500.X500NameBC; +import com.itextpdf.commons.bouncycastle.asn1.x500.IX500Name; +import com.itextpdf.commons.bouncycastle.cert.ocsp.IResponderID; + +import org.bouncycastle.asn1.ocsp.ResponderID; + +/** + * Wrapper class for {@link ResponderID}. + */ +public class ResponderIDBC implements IResponderID { + private final ResponderID responderID; + + /** + * Creates new wrapper instance for {@link ResponderID}. + * + * @param responderID {@link ResponderID} to be wrapped + */ + public ResponderIDBC(ResponderID responderID) { + this.responderID = responderID; + } + + /** + * {@inheritDoc} + */ + @Override + public IX500Name getName() { + return new X500NameBC(responderID.getName()); + } + + /** + * Gets actual org.bouncycastle object being wrapped. + * + * @return wrapped {@link ResponderID}. + */ + public ResponderID getResponderID() { + return responderID; + } +} diff --git a/bouncy-castle-adapter/src/main/java/com/itextpdf/bouncycastle/crypto/modes/GCMBlockCipherBC.java b/bouncy-castle-adapter/src/main/java/com/itextpdf/bouncycastle/crypto/modes/GCMBlockCipherBC.java new file mode 100644 index 0000000000..8b7bb6fb75 --- /dev/null +++ b/bouncy-castle-adapter/src/main/java/com/itextpdf/bouncycastle/crypto/modes/GCMBlockCipherBC.java @@ -0,0 +1,132 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.bouncycastle.crypto.modes; + +import com.itextpdf.commons.bouncycastle.crypto.modes.IGCMBlockCipher; +import org.bouncycastle.crypto.InvalidCipherTextException; +import org.bouncycastle.crypto.modes.GCMBlockCipher; +import org.bouncycastle.crypto.params.AEADParameters; +import org.bouncycastle.crypto.params.KeyParameter; + +import java.util.Objects; + +/** + * This class provides the functionality of a cryptographic cipher of aes-gcm for encryption and decryption via + * wrapping the corresponding {@code GCMBlockCipher} class from bouncy-castle. + */ +public class GCMBlockCipherBC implements IGCMBlockCipher { + private final GCMBlockCipher cipher; + + /** + * Creates new wrapper for {@link GCMBlockCipher} aes-gcm block cipher class. + * + * @param cipher bouncy-castle class to wrap + */ + public GCMBlockCipherBC(GCMBlockCipher cipher) { + this.cipher = cipher; + } + + /** + * Gets actual org.bouncycastle object being wrapped. + * + * @return wrapped {@link GCMBlockCipher} + */ + public GCMBlockCipher getCipher() { + return cipher; + } + + /** + * {@inheritDoc} + */ + @Override + public void init(boolean forEncryption, byte[] key, int macSizeBits, byte[] iv) { + cipher.init(forEncryption, new AEADParameters(new KeyParameter(key), macSizeBits, iv)); + } + + /** + * {@inheritDoc} + */ + @Override + public int getUpdateOutputSize(int len) { + return cipher.getUpdateOutputSize(len); + } + + /** + * {@inheritDoc} + */ + @Override + public void processBytes(byte[] input, int inputOffset, int len, byte[] output, int outOffset) { + cipher.processBytes(input, inputOffset, len, output, outOffset); + } + + /** + * {@inheritDoc} + */ + @Override + public int getOutputSize(int len) { + return cipher.getOutputSize(len); + } + + /** + * {@inheritDoc} + */ + @Override + public void doFinal(byte[] plainText, int i) { + try { + cipher.doFinal(plainText, i); + } catch (InvalidCipherTextException e) { + throw new IllegalArgumentException(e.getMessage(), e); + } + } + + /** + * {@inheritDoc} + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GCMBlockCipherBC that = (GCMBlockCipherBC) o; + return Objects.equals(cipher, that.cipher); + } + + /** + * {@inheritDoc} + */ + @Override + public int hashCode() { + return Objects.hash(cipher); + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return cipher.toString(); + } +} diff --git a/bouncy-castle-connector/pom.xml b/bouncy-castle-connector/pom.xml index 88407f26fe..bbd6e3bd4c 100644 --- a/bouncy-castle-connector/pom.xml +++ b/bouncy-castle-connector/pom.xml @@ -5,7 +5,7 @@ com.itextpdf root - 8.0.5 + 9.0.0 bouncy-castle-connector diff --git a/bouncy-castle-connector/src/main/java/com/itextpdf/bouncycastleconnector/BouncyCastleDefaultFactory.java b/bouncy-castle-connector/src/main/java/com/itextpdf/bouncycastleconnector/BouncyCastleDefaultFactory.java index c42950a972..81d3b18e17 100644 --- a/bouncy-castle-connector/src/main/java/com/itextpdf/bouncycastleconnector/BouncyCastleDefaultFactory.java +++ b/bouncy-castle-connector/src/main/java/com/itextpdf/bouncycastleconnector/BouncyCastleDefaultFactory.java @@ -117,6 +117,7 @@ This file is part of the iText (R) project. import com.itextpdf.commons.bouncycastle.cms.jcajce.IJcaSimpleSignerInfoVerifierBuilder; import com.itextpdf.commons.bouncycastle.cms.jcajce.IJceKeyAgreeEnvelopedRecipient; import com.itextpdf.commons.bouncycastle.cms.jcajce.IJceKeyTransEnvelopedRecipient; +import com.itextpdf.commons.bouncycastle.crypto.modes.IGCMBlockCipher; import com.itextpdf.commons.bouncycastle.openssl.IPEMParser; import com.itextpdf.commons.bouncycastle.openssl.jcajce.IJcaPEMKeyConverter; import com.itextpdf.commons.bouncycastle.openssl.jcajce.IJceOpenSSLPKCS8DecryptorProviderBuilder; @@ -831,6 +832,11 @@ public IX500Name createX500Name(String s) { throw new UnsupportedOperationException(BouncyCastleLogMessageConstant.BOUNCY_CASTLE_DEPENDENCY_MUST_PRESENT); } + @Override + public IX500Name createX500Name(IASN1Sequence s) { + throw new UnsupportedOperationException(BouncyCastleLogMessageConstant.BOUNCY_CASTLE_DEPENDENCY_MUST_PRESENT); + } + @Override public IRespID createRespID(IX500Name x500Name) { throw new UnsupportedOperationException(BouncyCastleLogMessageConstant.BOUNCY_CASTLE_DEPENDENCY_MUST_PRESENT); @@ -992,4 +998,29 @@ public byte[] createCipherBytes(X509Certificate x509certificate, byte[] abyte0, public void isEncryptionFeatureSupported(int encryptionType, boolean withCertificate) { throw new UnsupportedOperationException(BouncyCastleLogMessageConstant.BOUNCY_CASTLE_DEPENDENCY_MUST_PRESENT); } + + @Override + public byte[] generateHKDF(byte[] inputKey, byte[] salt, byte[] info) { + throw new UnsupportedOperationException(BouncyCastleLogMessageConstant.BOUNCY_CASTLE_DEPENDENCY_MUST_PRESENT); + } + + @Override + public byte[] generateHMACSHA256Token(byte[] key, byte[] data) { + throw new UnsupportedOperationException(BouncyCastleLogMessageConstant.BOUNCY_CASTLE_DEPENDENCY_MUST_PRESENT); + } + + @Override + public byte[] generateEncryptedKeyWithAES256NoPad(byte[] key, byte[] kek) { + throw new UnsupportedOperationException(BouncyCastleLogMessageConstant.BOUNCY_CASTLE_DEPENDENCY_MUST_PRESENT); + } + + @Override + public byte[] generateDecryptedKeyWithAES256NoPad(byte[] key, byte[] kek) { + throw new UnsupportedOperationException(BouncyCastleLogMessageConstant.BOUNCY_CASTLE_DEPENDENCY_MUST_PRESENT); + } + + @Override + public IGCMBlockCipher createGCMBlockCipher() { + throw new UnsupportedOperationException(BouncyCastleLogMessageConstant.BOUNCY_CASTLE_DEPENDENCY_MUST_PRESENT); + } } diff --git a/bouncy-castle-connector/src/main/java/com/itextpdf/bouncycastleconnector/BouncyCastleFactoryCreator.java b/bouncy-castle-connector/src/main/java/com/itextpdf/bouncycastleconnector/BouncyCastleFactoryCreator.java index ab28ecb8a1..7a2a26452c 100644 --- a/bouncy-castle-connector/src/main/java/com/itextpdf/bouncycastleconnector/BouncyCastleFactoryCreator.java +++ b/bouncy-castle-connector/src/main/java/com/itextpdf/bouncycastleconnector/BouncyCastleFactoryCreator.java @@ -43,7 +43,7 @@ public final class BouncyCastleFactoryCreator { private static IBouncyCastleFactory factory; - private static Map> factories = new LinkedHashMap<>(); + private static final Map> FACTORIES = new LinkedHashMap<>(); private static final String FACTORY_ENVIRONMENT_VARIABLE_NAME = "ITEXT_BOUNCY_CASTLE_FACTORY_NAME"; @@ -53,12 +53,12 @@ public final class BouncyCastleFactoryCreator { populateFactoriesMap(); String factoryName = SystemUtil.getPropertyOrEnvironmentVariable(FACTORY_ENVIRONMENT_VARIABLE_NAME); - Supplier systemVariableFactoryCreator = factories.get(factoryName); + Supplier systemVariableFactoryCreator = FACTORIES.get(factoryName); if (systemVariableFactoryCreator != null) { tryCreateFactory(systemVariableFactoryCreator); } - for (Supplier factorySupplier : factories.values()) { + for (Supplier factorySupplier : FACTORIES.values()) { if (factory != null) { break; } @@ -106,7 +106,7 @@ private static void createFactory(Supplier factoryCreator) } private static void populateFactoriesMap() { - factories.put("bouncy-castle", () -> new BouncyCastleFactory()); - factories.put("bouncy-castle-fips", () -> new BouncyCastleFipsFactory()); // Android-Conversion-Skip-Line (BC FIPS isn't supported on Android) + FACTORIES.put("bouncy-castle", () -> new BouncyCastleFactory()); + FACTORIES.put("bouncy-castle-fips", () -> new BouncyCastleFipsFactory()); // Android-Conversion-Skip-Line (BC FIPS isn't supported on Android) } } diff --git a/bouncy-castle-fips-adapter/pom.xml b/bouncy-castle-fips-adapter/pom.xml index 4efea998fb..ea2563f94c 100644 --- a/bouncy-castle-fips-adapter/pom.xml +++ b/bouncy-castle-fips-adapter/pom.xml @@ -5,7 +5,7 @@ com.itextpdf root - 8.0.5 + 9.0.0 bouncy-castle-fips-adapter @@ -14,8 +14,8 @@ https://itextpdf.com/ - 1.0.2.4 - 1.0.7 + 2.0.0 + 2.0.7 **/* **/* diff --git a/bouncy-castle-fips-adapter/src/main/java/com/itextpdf/bouncycastlefips/BouncyCastleFipsFactory.java b/bouncy-castle-fips-adapter/src/main/java/com/itextpdf/bouncycastlefips/BouncyCastleFipsFactory.java index 5b64670188..60b5163225 100644 --- a/bouncy-castle-fips-adapter/src/main/java/com/itextpdf/bouncycastlefips/BouncyCastleFipsFactory.java +++ b/bouncy-castle-fips-adapter/src/main/java/com/itextpdf/bouncycastlefips/BouncyCastleFipsFactory.java @@ -115,6 +115,7 @@ This file is part of the iText (R) project. import com.itextpdf.bouncycastlefips.cms.jcajce.JceKeyAgreeEnvelopedRecipientBCFips; import com.itextpdf.bouncycastlefips.cms.jcajce.JceKeyTransEnvelopedRecipientBCFips; import com.itextpdf.bouncycastlefips.crypto.fips.FipsUnapprovedOperationErrorBCFips; +import com.itextpdf.bouncycastlefips.crypto.modes.GCMBlockCipherBCFips; import com.itextpdf.bouncycastlefips.openssl.PEMParserBCFips; import com.itextpdf.bouncycastlefips.openssl.jcajce.JcaPEMKeyConverterBCFips; import com.itextpdf.bouncycastlefips.openssl.jcajce.JceOpenSSLPKCS8DecryptorProviderBuilderBCFips; @@ -222,6 +223,7 @@ This file is part of the iText (R) project. import com.itextpdf.commons.bouncycastle.cms.jcajce.IJcaSimpleSignerInfoVerifierBuilder; import com.itextpdf.commons.bouncycastle.cms.jcajce.IJceKeyAgreeEnvelopedRecipient; import com.itextpdf.commons.bouncycastle.cms.jcajce.IJceKeyTransEnvelopedRecipient; +import com.itextpdf.commons.bouncycastle.crypto.modes.IGCMBlockCipher; import com.itextpdf.commons.bouncycastle.openssl.IPEMParser; import com.itextpdf.commons.bouncycastle.openssl.jcajce.IJcaPEMKeyConverter; import com.itextpdf.commons.bouncycastle.openssl.jcajce.IJceOpenSSLPKCS8DecryptorProviderBuilder; @@ -245,6 +247,8 @@ This file is part of the iText (R) project. import java.io.Reader; import java.math.BigInteger; import java.security.GeneralSecurityException; +import java.security.NoSuchProviderException; +import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import java.security.PrivateKey; import java.security.Provider; @@ -258,6 +262,8 @@ This file is part of the iText (R) project. import java.util.List; import java.util.Set; import javax.crypto.Cipher; +import javax.crypto.NoSuchPaddingException; +import javax.crypto.Mac; import javax.crypto.spec.SecretKeySpec; import org.bouncycastle.asn1.ASN1BitString; import org.bouncycastle.asn1.ASN1Enumerated; @@ -274,8 +280,6 @@ This file is part of the iText (R) project. import org.bouncycastle.asn1.ASN1UTCTime; import org.bouncycastle.asn1.DERIA5String; import org.bouncycastle.asn1.DEROctetString; -import org.bouncycastle.asn1.DEROutputStream; -import org.bouncycastle.asn1.DLOutputStream; import org.bouncycastle.asn1.cms.Attribute; import org.bouncycastle.asn1.cms.ContentInfo; import org.bouncycastle.asn1.esf.SigPolicyQualifierInfo; @@ -319,6 +323,12 @@ This file is part of the iText (R) project. import org.bouncycastle.cms.jcajce.JceKeyAgreeEnvelopedRecipient; import org.bouncycastle.cms.jcajce.JceKeyTransEnvelopedRecipient; import org.bouncycastle.crypto.CryptoServicesRegistrar; +import org.bouncycastle.crypto.KDFCalculator; +import org.bouncycastle.crypto.fips.FipsKDF; +import org.bouncycastle.crypto.fips.FipsKDF.AgreementKDFPRF; +import org.bouncycastle.crypto.fips.FipsKDF.AgreementKDFParameters; +import org.bouncycastle.crypto.fips.FipsKDF.AgreementOperatorFactory; +import org.bouncycastle.crypto.fips.FipsKDF.HKDFKeyBuilder; import org.bouncycastle.crypto.fips.FipsUnapprovedOperationError; import org.bouncycastle.jcajce.provider.BouncyCastleFipsProvider; import org.bouncycastle.openssl.PEMParser; @@ -607,12 +617,7 @@ public IASN1OutputStream createASN1OutputStream(OutputStream stream) { */ @Override public IASN1OutputStream createASN1OutputStream(OutputStream outputStream, String asn1Encoding) { - if ("DER".equals(asn1Encoding)) { - return new ASN1OutputStreamBCFips(new DEROutputStream(outputStream)); - } else { - return new ASN1OutputStreamBCFips("DL".equals(asn1Encoding) ? new DLOutputStream(outputStream) - : new ASN1OutputStream(outputStream)); - } + return new ASN1OutputStreamBCFips(ASN1OutputStream.create(outputStream, asn1Encoding)); } /** @@ -869,7 +874,7 @@ public IAlgorithmIdentifier createAlgorithmIdentifier(IASN1ObjectIdentifier algo */ @Override public IAlgorithmIdentifier createAlgorithmIdentifier(IASN1ObjectIdentifier algorithm, - IASN1Encodable parameters) { + IASN1Encodable parameters) { ASN1ObjectIdentifierBCFips algorithmBCFips = (ASN1ObjectIdentifierBCFips) algorithm; ASN1EncodableBCFips encodableBCFips = (ASN1EncodableBCFips) parameters; return new AlgorithmIdentifierBCFips( @@ -974,8 +979,8 @@ public IJcaDigestCalculatorProviderBuilder createJcaDigestCalculatorProviderBuil */ @Override public ICertificateID createCertificateID(IDigestCalculator digestCalculator, - IX509CertificateHolder certificateHolder, - BigInteger bigInteger) throws OCSPExceptionBCFips { + IX509CertificateHolder certificateHolder, + BigInteger bigInteger) throws OCSPExceptionBCFips { return new CertificateIDBCFips(digestCalculator, certificateHolder, bigInteger); } @@ -1009,7 +1014,7 @@ public IJcaX509CertificateHolder createJcaX509CertificateHolder(X509Certificate */ @Override public IExtension createExtension(IASN1ObjectIdentifier objectIdentifier, - boolean critical, IASN1OctetString octetString) { + boolean critical, IASN1OctetString octetString) { return new ExtensionBCFips(new Extension(((ASN1ObjectIdentifierBCFips) objectIdentifier) .getASN1ObjectIdentifier(), critical, ((ASN1OctetStringBCFips) octetString).getOctetString())); } @@ -1063,7 +1068,7 @@ public IOCSPReqBuilder createOCSPReqBuilder() { */ @Override public ISigPolicyQualifierInfo createSigPolicyQualifierInfo(IASN1ObjectIdentifier objectIdentifier, - IDERIA5String string) { + IDERIA5String string) { return new SigPolicyQualifierInfoBCFips(objectIdentifier, string); } @@ -1136,7 +1141,7 @@ public IOCSPResponse createOCSPResponse(IOCSPResponseStatus respStatus, IRespons */ @Override public IResponseBytes createResponseBytes(IASN1ObjectIdentifier asn1ObjectIdentifier, - IDEROctetString derOctetString) { + IDEROctetString derOctetString) { return new ResponseBytesBCFips(asn1ObjectIdentifier, derOctetString); } @@ -1272,7 +1277,7 @@ public IDistributionPointName createDistributionPointName() { @Override public IDistributionPointName createDistributionPointName(IGeneralNames generalNames) { return new DistributionPointNameBCFips( - new DistributionPointName(((GeneralNamesBCFips)generalNames).getGeneralNames())); + new DistributionPointName(((GeneralNamesBCFips) generalNames).getGeneralNames())); } /** @@ -1300,7 +1305,7 @@ public IGeneralName createGeneralName() { */ @Override public IOtherHashAlgAndValue createOtherHashAlgAndValue(IAlgorithmIdentifier algorithmIdentifier, - IASN1OctetString octetString) { + IASN1OctetString octetString) { return new OtherHashAlgAndValueBCFips(algorithmIdentifier, octetString); } @@ -1309,7 +1314,7 @@ public IOtherHashAlgAndValue createOtherHashAlgAndValue(IAlgorithmIdentifier alg */ @Override public ISignaturePolicyId createSignaturePolicyId(IASN1ObjectIdentifier objectIdentifier, - IOtherHashAlgAndValue algAndValue) { + IOtherHashAlgAndValue algAndValue) { return new SignaturePolicyIdBCFips(objectIdentifier, algAndValue); } @@ -1318,8 +1323,8 @@ public ISignaturePolicyId createSignaturePolicyId(IASN1ObjectIdentifier objectId */ @Override public ISignaturePolicyId createSignaturePolicyId(IASN1ObjectIdentifier objectIdentifier, - IOtherHashAlgAndValue algAndValue, - ISigPolicyQualifierInfo... policyQualifiers) { + IOtherHashAlgAndValue algAndValue, + ISigPolicyQualifierInfo... policyQualifiers) { SigPolicyQualifierInfo[] qualifierInfos = new SigPolicyQualifierInfo[policyQualifiers.length]; for (int i = 0; i < qualifierInfos.length; ++i) { qualifierInfos[i] = ((SigPolicyQualifierInfoBCFips) policyQualifiers[i]).getQualifierInfo(); @@ -1340,7 +1345,7 @@ public ISignaturePolicyIdentifier createSignaturePolicyIdentifier(ISignaturePoli */ @Override public IEnvelopedData createEnvelopedData(IOriginatorInfo originatorInfo, IASN1Set set, - IEncryptedContentInfo encryptedContentInfo, IASN1Set set1) { + IEncryptedContentInfo encryptedContentInfo, IASN1Set set1) { return new EnvelopedDataBCFips(originatorInfo, set, encryptedContentInfo, set1); } @@ -1357,7 +1362,7 @@ public IRecipientInfo createRecipientInfo(IKeyTransRecipientInfo keyTransRecipie */ @Override public IEncryptedContentInfo createEncryptedContentInfo(IASN1ObjectIdentifier data, - IAlgorithmIdentifier algorithmIdentifier, IASN1OctetString octetString) { + IAlgorithmIdentifier algorithmIdentifier, IASN1OctetString octetString) { return new EncryptedContentInfoBCFips(data, algorithmIdentifier, octetString); } @@ -1398,7 +1403,7 @@ public IRecipientIdentifier createRecipientIdentifier(IIssuerAndSerialNumber iss */ @Override public IKeyTransRecipientInfo createKeyTransRecipientInfo(IRecipientIdentifier recipientIdentifier, - IAlgorithmIdentifier algorithmIdentifier, IASN1OctetString octetString) { + IAlgorithmIdentifier algorithmIdentifier, IASN1OctetString octetString) { return new KeyTransRecipientInfoBCFips(recipientIdentifier, algorithmIdentifier, octetString); } @@ -1523,7 +1528,7 @@ public IJcaCertStore createJcaCertStore(List certificates) throws C */ @Override public ITimeStampResponseGenerator createTimeStampResponseGenerator(ITimeStampTokenGenerator tokenGenerator, - Set algorithms) { + Set algorithms) { return new TimeStampResponseGeneratorBCFips(tokenGenerator, algorithms); } @@ -1557,7 +1562,7 @@ public IJcaSignerInfoGeneratorBuilder createJcaSignerInfoGeneratorBuilder( */ @Override public ITimeStampTokenGenerator createTimeStampTokenGenerator(ISignerInfoGenerator siGen, IDigestCalculator dgCalc, - IASN1ObjectIdentifier policy) throws TSPExceptionBCFips { + IASN1ObjectIdentifier policy) throws TSPExceptionBCFips { return new TimeStampTokenGeneratorBCFips(siGen, dgCalc, policy); } @@ -1586,6 +1591,15 @@ public IX500Name createX500Name(String s) { return new X500NameBCFips(new X500Name(s)); } + /** + * {@inheritDoc} + */ + @Override + public IX500Name createX500Name(IASN1Sequence s) { + return new X500NameBCFips(X500Name.getInstance(((ASN1SequenceBCFips) s).getASN1Sequence())); + + } + /** * {@inheritDoc} */ @@ -1623,7 +1637,7 @@ public IX509v2CRLBuilder createX509v2CRLBuilder(IX500Name x500Name, Date date) { */ @Override public IJcaX509v3CertificateBuilder createJcaX509v3CertificateBuilder(X509Certificate signingCert, - BigInteger certSerialNumber, Date startDate, Date endDate, IX500Name subjectDnName, PublicKey publicKey) { + BigInteger certSerialNumber, Date startDate, Date endDate, IX500Name subjectDnName, PublicKey publicKey) { return new JcaX509v3CertificateBuilderBCFips(signingCert, certSerialNumber, startDate, endDate, subjectDnName, publicKey); } @@ -1845,7 +1859,7 @@ public boolean isInApprovedOnlyMode() { */ @Override public byte[] createCipherBytes(X509Certificate x509certificate, byte[] abyte0, - IAlgorithmIdentifier algorithmIdentifier) + IAlgorithmIdentifier algorithmIdentifier) throws GeneralSecurityException { Cipher cipher; try { @@ -1861,8 +1875,70 @@ public byte[] createCipherBytes(X509Certificate x509certificate, byte[] abyte0, return cipher.wrap(new SecretKeySpec(abyte0, "AES")); } + /** + * {@inheritDoc} + */ @Override public void isEncryptionFeatureSupported(int encryptionType, boolean withCertificate) { //All features supported } + + /** + * {@inheritDoc} + */ + @Override + public byte[] generateHKDF(byte[] inputKey, byte[] salt, byte[] info) { + HKDFKeyBuilder hkdfKeyBuilder = FipsKDF.HKDF_KEY_BUILDER.withSalt(salt).withPrf(AgreementKDFPRF.SHA256_HMAC); + byte[] extractedKey = hkdfKeyBuilder.build(inputKey).getKey(); + AgreementOperatorFactory factory = new AgreementOperatorFactory(); + KDFCalculator kdfCalculator = factory.createKDFCalculator(FipsKDF.HKDF.withPRF( + AgreementKDFPRF.SHA256_HMAC).using(extractedKey).withIV(info)); + byte[] hkdf = new byte[32]; + kdfCalculator.generateBytes(hkdf); + return hkdf; + } + + /** + * {@inheritDoc} + */ + @Override + public byte[] generateHMACSHA256Token(byte[] key, byte[] data) throws NoSuchAlgorithmException, InvalidKeyException { + Mac mac = Mac.getInstance("HMacSHA256", this.getProvider()); + mac.init(new SecretKeySpec(key, "RawBytes")); + return mac.doFinal(data); + } + + /** + * {@inheritDoc} + */ + @Override + public byte[] generateEncryptedKeyWithAES256NoPad(byte[] key, byte[] kek) throws GeneralSecurityException { + Cipher cipher = Cipher.getInstance("AESWrap", this.getProvider()); + cipher.init(Cipher.WRAP_MODE, new SecretKeySpec(kek, "AESWrap")); + return cipher.wrap(new SecretKeySpec(key, "AESWrap")); + } + + /** + * {@inheritDoc} + */ + @Override + public byte[] generateDecryptedKeyWithAES256NoPad(byte[] key, byte[] kek) throws GeneralSecurityException { + Cipher cipher = Cipher.getInstance("AESWrap", this.getProvider()); + cipher.init(Cipher.UNWRAP_MODE, new SecretKeySpec(kek, "AESWrap")); + return cipher.unwrap(key, "AESWrap", Cipher.SECRET_KEY).getEncoded(); + } + + /** + * {@inheritDoc} + */ + @Override + public IGCMBlockCipher createGCMBlockCipher() { + Cipher cipher = null; + try { + cipher = Cipher.getInstance("AES/GCM/NoPadding", getProviderName()); + } catch (NoSuchAlgorithmException | NoSuchProviderException | NoSuchPaddingException e) { + // Ignore. + } + return new GCMBlockCipherBCFips(cipher); + } } diff --git a/bouncy-castle-fips-adapter/src/main/java/com/itextpdf/bouncycastlefips/BouncyCastleFipsTestConstantsFactory.java b/bouncy-castle-fips-adapter/src/main/java/com/itextpdf/bouncycastlefips/BouncyCastleFipsTestConstantsFactory.java index 7c5835538e..2f2027f4ab 100644 --- a/bouncy-castle-fips-adapter/src/main/java/com/itextpdf/bouncycastlefips/BouncyCastleFipsTestConstantsFactory.java +++ b/bouncy-castle-fips-adapter/src/main/java/com/itextpdf/bouncycastlefips/BouncyCastleFipsTestConstantsFactory.java @@ -32,6 +32,6 @@ class BouncyCastleFipsTestConstantsFactory implements IBouncyCastleTestConstants @Override public String getCertificateInfoTestConst() { - return "DEF length 8 object truncated by 4"; + return "corrupted stream - out of bounds length found: 8 >= 6"; } } diff --git a/bouncy-castle-fips-adapter/src/main/java/com/itextpdf/bouncycastlefips/asn1/ASN1EncodableVectorBCFips.java b/bouncy-castle-fips-adapter/src/main/java/com/itextpdf/bouncycastlefips/asn1/ASN1EncodableVectorBCFips.java index 317a8cf356..fe33bcdc5f 100644 --- a/bouncy-castle-fips-adapter/src/main/java/com/itextpdf/bouncycastlefips/asn1/ASN1EncodableVectorBCFips.java +++ b/bouncy-castle-fips-adapter/src/main/java/com/itextpdf/bouncycastlefips/asn1/ASN1EncodableVectorBCFips.java @@ -120,6 +120,14 @@ public void addOptional(IAlgorithmIdentifier element) { } } + /** + * {@inheritDoc} + */ + @Override + public int size() { + return encodableVector.size(); + } + /** * Indicates whether some other object is "equal to" this one. Compares wrapped objects. */ diff --git a/bouncy-castle-fips-adapter/src/main/java/com/itextpdf/bouncycastlefips/asn1/ASN1OutputStreamBCFips.java b/bouncy-castle-fips-adapter/src/main/java/com/itextpdf/bouncycastlefips/asn1/ASN1OutputStreamBCFips.java index 3eafb3f904..c3170f45ff 100644 --- a/bouncy-castle-fips-adapter/src/main/java/com/itextpdf/bouncycastlefips/asn1/ASN1OutputStreamBCFips.java +++ b/bouncy-castle-fips-adapter/src/main/java/com/itextpdf/bouncycastlefips/asn1/ASN1OutputStreamBCFips.java @@ -42,7 +42,7 @@ public class ASN1OutputStreamBCFips implements IASN1OutputStream { * @param stream OutputStream to create {@link ASN1OutputStream} to be wrapped */ public ASN1OutputStreamBCFips(OutputStream stream) { - this.stream = new ASN1OutputStream(stream); + this.stream = ASN1OutputStream.create(stream); } /** diff --git a/bouncy-castle-fips-adapter/src/main/java/com/itextpdf/bouncycastlefips/asn1/x500/X500NameBCFips.java b/bouncy-castle-fips-adapter/src/main/java/com/itextpdf/bouncycastlefips/asn1/x500/X500NameBCFips.java index 41d6f36acb..aa2cf677a2 100644 --- a/bouncy-castle-fips-adapter/src/main/java/com/itextpdf/bouncycastlefips/asn1/x500/X500NameBCFips.java +++ b/bouncy-castle-fips-adapter/src/main/java/com/itextpdf/bouncycastlefips/asn1/x500/X500NameBCFips.java @@ -25,6 +25,8 @@ This file is part of the iText (R) project. import com.itextpdf.bouncycastlefips.asn1.ASN1EncodableBCFips; import com.itextpdf.commons.bouncycastle.asn1.x500.IX500Name; +import java.io.IOException; +import javax.security.auth.x500.X500Principal; import org.bouncycastle.asn1.x500.X500Name; /** @@ -48,4 +50,14 @@ public X500NameBCFips(X500Name x500Name) { public X500Name getX500Name() { return (X500Name) getEncodable(); } + + @Override + public String getName(){ + try { + return new X500Principal(getX500Name().getEncoded()).getName(); + } catch (IOException e) { + // should never happen + throw new RuntimeException(e); + } + } } diff --git a/bouncy-castle-fips-adapter/src/main/java/com/itextpdf/bouncycastlefips/cert/ocsp/BasicOCSPRespBCFips.java b/bouncy-castle-fips-adapter/src/main/java/com/itextpdf/bouncycastlefips/cert/ocsp/BasicOCSPRespBCFips.java index 5e2eef7a2e..fc1b60a7da 100644 --- a/bouncy-castle-fips-adapter/src/main/java/com/itextpdf/bouncycastlefips/cert/ocsp/BasicOCSPRespBCFips.java +++ b/bouncy-castle-fips-adapter/src/main/java/com/itextpdf/bouncycastlefips/cert/ocsp/BasicOCSPRespBCFips.java @@ -30,13 +30,13 @@ This file is part of the iText (R) project. import com.itextpdf.commons.bouncycastle.asn1.IASN1ObjectIdentifier; import com.itextpdf.commons.bouncycastle.cert.IX509CertificateHolder; import com.itextpdf.commons.bouncycastle.cert.ocsp.IBasicOCSPResp; +import com.itextpdf.commons.bouncycastle.cert.ocsp.IRespID; import com.itextpdf.commons.bouncycastle.cert.ocsp.ISingleResp; import com.itextpdf.commons.bouncycastle.operator.IContentVerifierProvider; import java.io.IOException; import java.util.Date; import java.util.Objects; - import org.bouncycastle.asn1.x509.Extension; import org.bouncycastle.cert.X509CertificateHolder; import org.bouncycastle.cert.ocsp.BasicOCSPResp; @@ -134,6 +134,14 @@ public IASN1Encodable getExtensionParsedValue(IASN1ObjectIdentifier objectIdenti return new ASN1EncodableBCFips(extension == null ? null : extension.getParsedValue()); } + /** + * {@inheritDoc} + */ + @Override + public IRespID getResponderId() { + return new RespIDBCFips(basicOCSPResp.getResponderId()); + } + /** * Indicates whether some other object is "equal to" this one. Compares wrapped objects. */ diff --git a/bouncy-castle-fips-adapter/src/main/java/com/itextpdf/bouncycastlefips/cert/ocsp/RespIDBCFips.java b/bouncy-castle-fips-adapter/src/main/java/com/itextpdf/bouncycastlefips/cert/ocsp/RespIDBCFips.java index b8c4d9e336..0ae0d19a77 100644 --- a/bouncy-castle-fips-adapter/src/main/java/com/itextpdf/bouncycastlefips/cert/ocsp/RespIDBCFips.java +++ b/bouncy-castle-fips-adapter/src/main/java/com/itextpdf/bouncycastlefips/cert/ocsp/RespIDBCFips.java @@ -25,6 +25,7 @@ This file is part of the iText (R) project. import com.itextpdf.bouncycastlefips.asn1.x500.X500NameBCFips; import com.itextpdf.commons.bouncycastle.asn1.x500.IX500Name; import com.itextpdf.commons.bouncycastle.cert.ocsp.IRespID; +import com.itextpdf.commons.bouncycastle.cert.ocsp.IResponderID; import java.util.Objects; import org.bouncycastle.cert.ocsp.RespID; @@ -53,6 +54,14 @@ public RespIDBCFips(IX500Name x500Name) { this(new RespID(((X500NameBCFips) x500Name).getX500Name())); } + /** + * {@inheritDoc} + */ + @Override + public IResponderID toASN1Primitive() { + return new ResponderIDBCFips(respID.toASN1Primitive()); + } + /** * Gets actual org.bouncycastle object being wrapped. * @@ -92,4 +101,5 @@ public int hashCode() { public String toString() { return respID.toString(); } + } diff --git a/bouncy-castle-fips-adapter/src/main/java/com/itextpdf/bouncycastlefips/cert/ocsp/ResponderIDBCFips.java b/bouncy-castle-fips-adapter/src/main/java/com/itextpdf/bouncycastlefips/cert/ocsp/ResponderIDBCFips.java new file mode 100644 index 0000000000..9f44006203 --- /dev/null +++ b/bouncy-castle-fips-adapter/src/main/java/com/itextpdf/bouncycastlefips/cert/ocsp/ResponderIDBCFips.java @@ -0,0 +1,62 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.bouncycastlefips.cert.ocsp; + +import com.itextpdf.bouncycastlefips.asn1.x500.X500NameBCFips; +import com.itextpdf.commons.bouncycastle.asn1.x500.IX500Name; +import com.itextpdf.commons.bouncycastle.cert.ocsp.IResponderID; + +import org.bouncycastle.asn1.ocsp.ResponderID; + +/** + * Wrapper class for {@link ResponderID}. + */ +public class ResponderIDBCFips implements IResponderID { + private final ResponderID responderID; + + /** + * Creates new wrapper instance for {@link ResponderID}. + * + * @param responderID {@link ResponderID} to be wrapped + */ + public ResponderIDBCFips(ResponderID responderID) { + this.responderID = responderID; + } + + /** + * {@inheritDoc} + */ + @Override + public IX500Name getName() { + return new X500NameBCFips(responderID.getName()); + } + + /** + * Gets actual org.bouncycastle object being wrapped. + * + * @return wrapped {@link ResponderID}. + */ + public ResponderID getResponderID() { + return responderID; + } +} diff --git a/bouncy-castle-fips-adapter/src/main/java/com/itextpdf/bouncycastlefips/crypto/modes/GCMBlockCipherBCFips.java b/bouncy-castle-fips-adapter/src/main/java/com/itextpdf/bouncycastlefips/crypto/modes/GCMBlockCipherBCFips.java new file mode 100644 index 0000000000..25574ae9db --- /dev/null +++ b/bouncy-castle-fips-adapter/src/main/java/com/itextpdf/bouncycastlefips/crypto/modes/GCMBlockCipherBCFips.java @@ -0,0 +1,139 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.bouncycastlefips.crypto.modes; + +import com.itextpdf.commons.bouncycastle.crypto.modes.IGCMBlockCipher; +import javax.crypto.Cipher; +import javax.crypto.spec.GCMParameterSpec; +import javax.crypto.spec.SecretKeySpec; +import java.security.GeneralSecurityException; +import java.util.Objects; + +/** + * This class provides the functionality of a cryptographic cipher of aes-gcm for encryption and decryption via + * wrapping and correctly populating {@link Cipher} class. + */ +public class GCMBlockCipherBCFips implements IGCMBlockCipher { + private final Cipher cipher; + private boolean forEncryption; + private int macSize; + + /** + * Creates new aes-gcm block cipher class. + * + * @param cipher crypto instance to populate for aes-gcm encryption + */ + public GCMBlockCipherBCFips(Cipher cipher) { + this.cipher = cipher; + } + + /** + * Gets actual aes-gcm cipher being wrapped. + * + * @return wrapped {@link Cipher} + */ + public Cipher getCipher() { + return cipher; + } + + /** + * {@inheritDoc} + */ + @Override + public void init(boolean forEncryption, byte[] key, int macSizeBits, byte[] iv) throws GeneralSecurityException { + cipher.init(forEncryption ? Cipher.ENCRYPT_MODE : Cipher.DECRYPT_MODE, + new SecretKeySpec(key, "AES"), new GCMParameterSpec(macSizeBits, iv)); + this.forEncryption = forEncryption; + this.macSize = macSizeBits / 8; + } + + /** + * {@inheritDoc} + */ + @Override + public int getUpdateOutputSize(int len) { + int size; + if (this.forEncryption) { + size = getOutputSize(len) - this.macSize; + } else { + size = getOutputSize(len); + } + + return size - size % 16; + } + + /** + * {@inheritDoc} + */ + @Override + public void processBytes(byte[] input, int inputOffset, int len, byte[] output, int outOffset) throws GeneralSecurityException { + cipher.update(input, inputOffset, len, output, outOffset); + } + + /** + * {@inheritDoc} + */ + @Override + public int getOutputSize(int len) { + return cipher.getOutputSize(len); + } + + /** + * {@inheritDoc} + */ + @Override + public void doFinal(byte[] plainText, int i) throws GeneralSecurityException { + cipher.doFinal(plainText, i); + } + + /** + * {@inheritDoc} + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GCMBlockCipherBCFips that = (GCMBlockCipherBCFips) o; + return Objects.equals(cipher, that.cipher); + } + + /** + * {@inheritDoc} + */ + @Override + public int hashCode() { + return Objects.hash(cipher); + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return cipher.toString(); + } +} diff --git a/bouncy-castle-fips-adapter/src/main/java/com/itextpdf/bouncycastlefips/tsp/TimeStampRequestGeneratorBCFips.java b/bouncy-castle-fips-adapter/src/main/java/com/itextpdf/bouncycastlefips/tsp/TimeStampRequestGeneratorBCFips.java index 92e2882bf5..60d145fb66 100644 --- a/bouncy-castle-fips-adapter/src/main/java/com/itextpdf/bouncycastlefips/tsp/TimeStampRequestGeneratorBCFips.java +++ b/bouncy-castle-fips-adapter/src/main/java/com/itextpdf/bouncycastlefips/tsp/TimeStampRequestGeneratorBCFips.java @@ -29,6 +29,7 @@ This file is part of the iText (R) project. import java.math.BigInteger; import java.util.Objects; +import org.bouncycastle.asn1.ASN1ObjectIdentifier; import org.bouncycastle.tsp.TimeStampRequestGenerator; /** @@ -68,7 +69,7 @@ public void setCertReq(boolean var1) { */ @Override public void setReqPolicy(String reqPolicy) { - requestGenerator.setReqPolicy(reqPolicy); + requestGenerator.setReqPolicy(new ASN1ObjectIdentifier(reqPolicy)); } /** diff --git a/commons/pom.xml b/commons/pom.xml index ffd184a730..15d2d0d72c 100644 --- a/commons/pom.xml +++ b/commons/pom.xml @@ -5,7 +5,7 @@ com.itextpdf root - 8.0.5 + 9.0.0 commons diff --git a/commons/src/main/java/com/itextpdf/commons/actions/EventManager.java b/commons/src/main/java/com/itextpdf/commons/actions/EventManager.java index 76aad0e5db..397482425b 100644 --- a/commons/src/main/java/com/itextpdf/commons/actions/EventManager.java +++ b/commons/src/main/java/com/itextpdf/commons/actions/EventManager.java @@ -44,7 +44,7 @@ private EventManager() { } /** - * Allows an access to the instance of EventManager. + * Allows access to the instance of EventManager. * * @return the instance of the class */ diff --git a/commons/src/main/java/com/itextpdf/commons/actions/IEvent.java b/commons/src/main/java/com/itextpdf/commons/actions/IEvent.java index e9651280b5..de5cab0e07 100644 --- a/commons/src/main/java/com/itextpdf/commons/actions/IEvent.java +++ b/commons/src/main/java/com/itextpdf/commons/actions/IEvent.java @@ -24,7 +24,6 @@ This file is part of the iText (R) project. /** * Base marker interface for any generated event of any source. - * */ public interface IEvent { } diff --git a/commons/src/main/java/com/itextpdf/commons/actions/data/CommonsProductData.java b/commons/src/main/java/com/itextpdf/commons/actions/data/CommonsProductData.java index 0e97fd68e9..8f444b9ba1 100644 --- a/commons/src/main/java/com/itextpdf/commons/actions/data/CommonsProductData.java +++ b/commons/src/main/java/com/itextpdf/commons/actions/data/CommonsProductData.java @@ -28,7 +28,7 @@ This file is part of the iText (R) project. public final class CommonsProductData { static final String COMMONS_PUBLIC_PRODUCT_NAME = "Commons"; static final String COMMONS_PRODUCT_NAME = "commons"; - static final String COMMONS_VERSION = "8.0.5"; + static final String COMMONS_VERSION = "9.0.0"; static final String MINIMAL_COMPATIBLE_LICENSEKEY_VERSION = "4.1.0"; static final int COMMONS_COPYRIGHT_SINCE = 2000; static final int COMMONS_COPYRIGHT_TO = 2024; diff --git a/commons/src/main/java/com/itextpdf/commons/bouncycastle/IBouncyCastleFactory.java b/commons/src/main/java/com/itextpdf/commons/bouncycastle/IBouncyCastleFactory.java index d5e7f2d0ae..5bea97831a 100644 --- a/commons/src/main/java/com/itextpdf/commons/bouncycastle/IBouncyCastleFactory.java +++ b/commons/src/main/java/com/itextpdf/commons/bouncycastle/IBouncyCastleFactory.java @@ -115,6 +115,7 @@ This file is part of the iText (R) project. import com.itextpdf.commons.bouncycastle.cms.jcajce.IJcaSimpleSignerInfoVerifierBuilder; import com.itextpdf.commons.bouncycastle.cms.jcajce.IJceKeyAgreeEnvelopedRecipient; import com.itextpdf.commons.bouncycastle.cms.jcajce.IJceKeyTransEnvelopedRecipient; +import com.itextpdf.commons.bouncycastle.crypto.modes.IGCMBlockCipher; import com.itextpdf.commons.bouncycastle.openssl.IPEMParser; import com.itextpdf.commons.bouncycastle.openssl.jcajce.IJcaPEMKeyConverter; import com.itextpdf.commons.bouncycastle.openssl.jcajce.IJceOpenSSLPKCS8DecryptorProviderBuilder; @@ -137,6 +138,8 @@ This file is part of the iText (R) project. import java.io.Reader; import java.math.BigInteger; import java.security.GeneralSecurityException; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; import java.security.PrivateKey; import java.security.Provider; import java.security.PublicKey; @@ -1382,6 +1385,15 @@ ITimeStampTokenGenerator createTimeStampTokenGenerator(ISignerInfoGenerator siGe */ IX500Name createX500Name(String s); + /** + * Create X500 Name wrapper from {@link IASN1Sequence}. + * + * @param s {@link IASN1Sequence} to create X500 Name wrapper from + * + * @return created X500 Name wrapper + */ + IX500Name createX500Name(IASN1Sequence s); + /** * Create resp ID wrapper from X500 Name wrapper. * @@ -1677,4 +1689,59 @@ byte[] createCipherBytes(X509Certificate x509certificate, byte[] abyte0, IAlgori * @param withCertificate true when used with a certificate, false otherwise */ void isEncryptionFeatureSupported(int encryptionAlgorithm, boolean withCertificate); + + /** + * Generates byte array based on extract-and-expand key derivation function, using provided parameters. + * + * @param inputKey {@code byte[]} input key material + * @param salt {@code byte[]} salt + * @param info {@code byte[]} info + * + * @return {@code byte[]} key derivation function result. + */ + byte[] generateHKDF(byte[] inputKey, byte[] salt, byte[] info); + + /** + * Generates byte array based MAC token according to HMACSHA256 algorithm. + * + * @param key {@code byte[]} MAC key + * @param data {@code byte[]} data to be encrypted + * + * @return byte array based MAC token. + * + * @throws NoSuchAlgorithmException if there is no such algorithm. + * @throws InvalidKeyException if key is invalid. + */ + byte[] generateHMACSHA256Token(byte[] key, byte[] data) throws NoSuchAlgorithmException, InvalidKeyException; + + /** + * Generates encrypted key based on AES256 without padding wrapping algorithm. + * + * @param key key to be encrypted + * @param kek key encryption key to be used + * + * @return encrypted key. + * + * @throws GeneralSecurityException in case of encryption related exceptions. + */ + byte[] generateEncryptedKeyWithAES256NoPad(byte[] key, byte[] kek) throws GeneralSecurityException; + + /** + * Generates decrypted key based on AES256 without padding unwrapping algorithm. + * + * @param key key to be decrypted + * @param kek key encryption key to be used + * + * @return decrypted key. + * + * @throws GeneralSecurityException in case of encryption related exceptions. + */ + byte[] generateDecryptedKeyWithAES256NoPad(byte[] key, byte[] kek) throws GeneralSecurityException; + + /** + * Returns a Block Cipher object that implements the aes-gcm transformation. + * + * @return {@link IGCMBlockCipher} instance with provider specific implementation + */ + IGCMBlockCipher createGCMBlockCipher(); } diff --git a/commons/src/main/java/com/itextpdf/commons/bouncycastle/asn1/IASN1EncodableVector.java b/commons/src/main/java/com/itextpdf/commons/bouncycastle/asn1/IASN1EncodableVector.java index 34b12c7d5f..1566f1223e 100644 --- a/commons/src/main/java/com/itextpdf/commons/bouncycastle/asn1/IASN1EncodableVector.java +++ b/commons/src/main/java/com/itextpdf/commons/bouncycastle/asn1/IASN1EncodableVector.java @@ -71,4 +71,11 @@ public interface IASN1EncodableVector { * @param element AlgorithmIdentifier wrapper. */ void addOptional(IAlgorithmIdentifier element); + + /** + * Calls actual {@code size} method for the wrapped ASN1EncodableVector object. + * + * @return {@code int} representing current vector size + */ + int size(); } diff --git a/commons/src/main/java/com/itextpdf/commons/bouncycastle/asn1/x500/IX500Name.java b/commons/src/main/java/com/itextpdf/commons/bouncycastle/asn1/x500/IX500Name.java index 8ae58e48a7..d3768ed987 100644 --- a/commons/src/main/java/com/itextpdf/commons/bouncycastle/asn1/x500/IX500Name.java +++ b/commons/src/main/java/com/itextpdf/commons/bouncycastle/asn1/x500/IX500Name.java @@ -29,4 +29,10 @@ This file is part of the iText (R) project. * to switch between bouncy-castle and bouncy-castle FIPS implementations. */ public interface IX500Name extends IASN1Encodable { + /** + * Gets the RFC2253 name. + * + * @return the RFC2253 name + */ + String getName(); } diff --git a/commons/src/main/java/com/itextpdf/commons/bouncycastle/cert/ocsp/IBasicOCSPResp.java b/commons/src/main/java/com/itextpdf/commons/bouncycastle/cert/ocsp/IBasicOCSPResp.java index 239f975967..86f6583e40 100644 --- a/commons/src/main/java/com/itextpdf/commons/bouncycastle/cert/ocsp/IBasicOCSPResp.java +++ b/commons/src/main/java/com/itextpdf/commons/bouncycastle/cert/ocsp/IBasicOCSPResp.java @@ -85,4 +85,12 @@ public interface IBasicOCSPResp { * @return wrapped extension parsed value. */ IASN1Encodable getExtensionParsedValue(IASN1ObjectIdentifier objectIdentifier); + + + /** + * Calls actual {@code getEncoded} method for the wrapped BasicOCSPResp object. + * + * @return the Responder Id + */ + IRespID getResponderId(); } diff --git a/commons/src/main/java/com/itextpdf/commons/bouncycastle/cert/ocsp/IRespID.java b/commons/src/main/java/com/itextpdf/commons/bouncycastle/cert/ocsp/IRespID.java index 93c5f0e96b..a4161e3707 100644 --- a/commons/src/main/java/com/itextpdf/commons/bouncycastle/cert/ocsp/IRespID.java +++ b/commons/src/main/java/com/itextpdf/commons/bouncycastle/cert/ocsp/IRespID.java @@ -27,4 +27,10 @@ This file is part of the iText (R) project. * to switch between bouncy-castle and bouncy-castle FIPS implementations. */ public interface IRespID { + /** + * Calls actual {@code toASN1Primitive} method for the wrapped BasicOCSPResp object. + * + * @return Responder ID as a ASN1 primitive. + */ + IResponderID toASN1Primitive(); } diff --git a/kernel/src/main/java/com/itextpdf/kernel/events/IEventHandler.java b/commons/src/main/java/com/itextpdf/commons/bouncycastle/cert/ocsp/IResponderID.java similarity index 70% rename from kernel/src/main/java/com/itextpdf/kernel/events/IEventHandler.java rename to commons/src/main/java/com/itextpdf/commons/bouncycastle/cert/ocsp/IResponderID.java index a0870266ab..c723b95d4a 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/events/IEventHandler.java +++ b/commons/src/main/java/com/itextpdf/commons/bouncycastle/cert/ocsp/IResponderID.java @@ -20,19 +20,19 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.kernel.events; +package com.itextpdf.commons.bouncycastle.cert.ocsp; + +import com.itextpdf.commons.bouncycastle.asn1.x500.IX500Name; /** - * Interface for handling events. EventHandlers are added to the {@link EventDispatcher}. + * This interface represents the wrapper for ResponderID that provides the ability + * to switch between bouncy-castle and bouncy-castle FIPS implementations. */ -public interface IEventHandler { - +public interface IResponderID { /** - * Hook for handling events. Implementations can access the PdfDocument instance - * associated to the specified Event or, if available, the PdfPage instance. + * Calls actual {@code getName} method for the wrapped BasicOCSPResp object. * - * @param event the Event that needs to be processed + * @return wrapped X500NAme. */ - void handleEvent(Event event); - + IX500Name getName(); } diff --git a/commons/src/main/java/com/itextpdf/commons/bouncycastle/crypto/modes/IGCMBlockCipher.java b/commons/src/main/java/com/itextpdf/commons/bouncycastle/crypto/modes/IGCMBlockCipher.java new file mode 100644 index 0000000000..ca6d3d43f2 --- /dev/null +++ b/commons/src/main/java/com/itextpdf/commons/bouncycastle/crypto/modes/IGCMBlockCipher.java @@ -0,0 +1,90 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.commons.bouncycastle.crypto.modes; + +import java.security.GeneralSecurityException; + +/** + * Interface for aes-gcm cryptographic ciphers. + */ +public interface IGCMBlockCipher { + + /** + * Initialize this cipher with a key and a set of algorithm parameters. + * + * @param forEncryption true to use encrypt mode, false to use decrypt mode + * @param key the encryption key + * @param macSizeBits MAC size, MAC sizes from 32 bits to 128 bits (must be a multiple of 8) + * @param iv the IV source buffer + * + * @throws GeneralSecurityException in case any error during encryption or decryption + */ + void init(boolean forEncryption, byte[] key, int macSizeBits, byte[] iv) throws GeneralSecurityException; + + /** + * Returns the length in bytes that an output buffer would need to be in order to hold the result of + * the next update operation, given the input length (in bytes). + * + * @param len input length (in bytes) + * + * @return output length in bytes + */ + int getUpdateOutputSize(int len); + + /** + * Perform a multiple-part encryption or decryption operation (depending on how this cipher was initialized), + * processing another data part. + * + * @param input the input buffer + * @param inputOffset the offset in input where the input starts + * @param len the input length + * @param output the buffer for the result + * @param outOffset the offset in output where the result is stored + * + * @throws GeneralSecurityException in case any error during encryption or decryption + */ + void processBytes(byte[] input, int inputOffset, int len, byte[] output, int outOffset) + throws GeneralSecurityException; + + /** + * Returns the length in bytes that an output buffer would need to be in order to hold the result of + * the next doFinal operation, given the input length (in bytes). + * + * @param len input length (in bytes) + * + * @return output length in bytes + */ + int getOutputSize(int len); + + /** + * Finishes a multiple-part encryption or decryption operation, depending on how this cipher was initialized. + * Input data that may have been buffered during a previous update operation is processed, also + * the authentication tag is appended in the case of encryption, or verified in the case of decryption. + * + * @param plainText the buffer for the result + * @param i the offset in output where the result is stored + * + * @throws GeneralSecurityException in case any error during encryption or decryption + */ + void doFinal(byte[] plainText, int i) throws GeneralSecurityException; +} diff --git a/commons/src/main/java/com/itextpdf/commons/datastructures/ISimpleList.java b/commons/src/main/java/com/itextpdf/commons/datastructures/ISimpleList.java new file mode 100644 index 0000000000..0a0d006ab9 --- /dev/null +++ b/commons/src/main/java/com/itextpdf/commons/datastructures/ISimpleList.java @@ -0,0 +1,96 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.commons.datastructures; + +/** + * Interface for a simple list abstraction. + *

+ * This interface is a subset of the {@link java.util.List} interface. + * It is intended to be used in cases where the full {@link java.util.List} interface is not needed. + * + * @param The type of elements in this list. + */ +public interface ISimpleList { + /** + * Adds an element to the end of the list. + * + * @param element the element to add + */ + void add(T element); + + /** + * Adds an element to the list at the specified index. + * + * @param index the index at which to add the element + * @param element the element to add + */ + void add(int index, T element); + + /** + * Returns the element at the specified index. + * + * @param index the index of the element to return + * @return the element at the specified index + */ + T get(int index); + + /** + * Replaces the element at the specified index with the specified element. + * + * @param index the index of the element to replace + * @param element the element to be stored at the specified index + * @return the element previously at the specified index + */ + T set(int index, T element); + + /** + * Returns the index of the first occurrence of the specified element in the list, + * or -1 if the list does not contain the element. + * + * @param element the element to search for + * @return the index of the first occurrence of the specified element in the list, + * or -1 if the list does not contain the element + */ + int indexOf(Object element); + + /** + * Removes the element at the specified index. + * + * @param index the index of the element to be removed + */ + void remove(int index); + + /** + * Returns the number of elements in the list. + * + * @return the number of elements in the list + */ + int size(); + + /** + * Returns {@code true} if the list contains no elements, false otherwise. + * + * @return {@code true} if the list contains no elements, false otherwise + */ + boolean isEmpty(); +} diff --git a/commons/src/main/java/com/itextpdf/commons/datastructures/NullUnlimitedList.java b/commons/src/main/java/com/itextpdf/commons/datastructures/NullUnlimitedList.java new file mode 100644 index 0000000000..32078858fc --- /dev/null +++ b/commons/src/main/java/com/itextpdf/commons/datastructures/NullUnlimitedList.java @@ -0,0 +1,167 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.commons.datastructures; + + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + +/** + * The class represents a list which allows null elements, but doesn't allocate a memory for them, in the rest of + * cases it behaves like usual {@link ArrayList} and should have the same complexity (because keys are unique + * integers, so collisions are impossible). + * + * @param elements of the list + */ +public final class NullUnlimitedList implements ISimpleList { + private final Map map = new HashMap<>(); + private int size = 0; + + /** + * Creates a new instance of {@link NullUnlimitedList}. + */ + public NullUnlimitedList() { + // Empty constructor + } + + /** + * {@inheritDoc} + */ + @Override + public void add(T element) { + if (element == null) { + size++; + } else { + int position = size++; + map.put(position, element); + } + } + + /** + * {@inheritDoc} + * In worth scenario O(n^2) but it is mostly impossible because keys shouldn't have + * collisions at all (they are integers). So in average should be O(n). + */ + @Override + public void add(int index, T element) { + if (index < 0 || index > size) { + return; + } + size++; + // Shifts the element currently at that position (if any) and any + // subsequent elements to the right (adds one to their indices). + T previous = map.get(index); + for (int i = index + 1; i < size; i++) { + T currentToAdd = previous; + previous = map.get(i); + this.set(i, currentToAdd); + } + + this.set(index, element); + } + + /** + * {@inheritDoc} + * average O(1), worth O(n) (mostly impossible in case when keys are integers) + */ + @Override + public T get(int index) { + return map.get(index); + } + + /** + * {@inheritDoc} + * average O(1), worth O(n) (mostly impossible in case when keys are integers) + */ + @Override + public T set(int index, T element) { + if (element == null) { + map.remove(index); + } else { + map.put(index, element); + } + return element; + } + + /** + * {@inheritDoc} + */ + @Override + public int indexOf(Object element) { + if (element == null) { + for (int i = 0; i < size; i++) { + if (!map.containsKey(i)) { + return i; + } + } + return -1; + } + for (Map.Entry entry : map.entrySet()) { + if (element.equals(entry.getValue())) { + return entry.getKey(); + } + } + return -1; + } + + /** + * In worth scenario O(n^2) but it is mostly impossible because keys shouldn't have + * collisions at all (they are integers). So in average should be O(n). + * + * @param index the index of the element to be removed + */ + @Override + public void remove(int index) { + if (index < 0 || index >= size) { + return; + } + map.remove(index); + // Shifts any subsequent elements to the left (subtracts one from their indices). + T previous = map.get(size - 1); + final int offset = 2; + for (int i = size - offset; i >= index; i--) { + T current = previous; + previous = map.get(i); + this.set(i, current); + } + map.remove(--size); + } + + /** + * @return the size of the list + */ + @Override + public int size() { + return size; + } + + /** + * @return true if the list is empty, false otherwise + */ + @Override + public boolean isEmpty() { + return size == 0; + } + +} diff --git a/commons/src/main/java/com/itextpdf/commons/datastructures/SimpleArrayList.java b/commons/src/main/java/com/itextpdf/commons/datastructures/SimpleArrayList.java new file mode 100644 index 0000000000..344d50bfe6 --- /dev/null +++ b/commons/src/main/java/com/itextpdf/commons/datastructures/SimpleArrayList.java @@ -0,0 +1,117 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.commons.datastructures; + +import java.util.ArrayList; + +/** + * Portable implementation of {@link ArrayList}. + * + * @param the type of elements in this list + */ +public class SimpleArrayList implements ISimpleList { + + private final ArrayList list; + + /** + * Creates a new instance of {@link SimpleArrayList}. + */ + public SimpleArrayList() { + this.list = new ArrayList<>(); + } + + /** + * Creates a new instance of {@link SimpleArrayList} with the specified initial capacity. + * + * @param initialCapacity the initial capacity of the list + */ + public SimpleArrayList(int initialCapacity) { + this.list = new ArrayList<>(initialCapacity); + } + + /** + * {@inheritDoc} + */ + @Override + public void add(T element) { + list.add(element); + } + + /** + * {@inheritDoc} + */ + @Override + public void add(int index, T element) { + list.add(index, element); + } + + /** + * {@inheritDoc} + */ + @Override + public T get(int index) { + return list.get(index); + } + + /** + * {@inheritDoc} + */ + @Override + public T set(int index, T element) { + T value = list.get(index); + list.set(index, element); + return value; + } + + /** + * {@inheritDoc} + */ + @Override + public int indexOf(Object element) { + return list.indexOf((T) element); + } + + /** + * {@inheritDoc} + */ + @Override + public void remove(int index) { + list.remove(index); + } + + /** + * {@inheritDoc} + */ + @Override + public int size() { + return list.size(); + } + + /** + * {@inheritDoc} + */ + @Override + public boolean isEmpty() { + return list.isEmpty(); + } +} diff --git a/commons/src/main/java/com/itextpdf/commons/utils/DIContainerConfigurations.java b/commons/src/main/java/com/itextpdf/commons/utils/DIContainerConfigurations.java index 3b78f8db92..3770338587 100644 --- a/commons/src/main/java/com/itextpdf/commons/utils/DIContainerConfigurations.java +++ b/commons/src/main/java/com/itextpdf/commons/utils/DIContainerConfigurations.java @@ -32,7 +32,8 @@ private DIContainerConfigurations() { } private static final String[] DEFAULT_CONFIGURATIONS_CLASS = new String[] { - "com.itextpdf.forms.util.RegisterDefaultDiContainer" + "com.itextpdf.forms.util.RegisterDefaultDiContainer", + "com.itextpdf.kernel.utils.RegisterDefaultDiContainer" }; /** diff --git a/commons/src/main/java/com/itextpdf/commons/utils/FileUtil.java b/commons/src/main/java/com/itextpdf/commons/utils/FileUtil.java index 55bf1d1665..6e9c31479a 100644 --- a/commons/src/main/java/com/itextpdf/commons/utils/FileUtil.java +++ b/commons/src/main/java/com/itextpdf/commons/utils/FileUtil.java @@ -211,8 +211,8 @@ public static PrintWriter createPrintWriter(OutputStream output, * * @throws FileNotFoundException if file not found. */ - public static java.io.OutputStream getBufferedOutputStream(String filename) throws FileNotFoundException { - return new BufferedOutputStream(new FileOutputStream(filename)); + public static OutputStream getBufferedOutputStream(String filename) throws IOException { + return new BufferedOutputStream(getFileOutputStream(filename)); } /** @@ -267,10 +267,10 @@ public static File createTempFile(String path) throws IOException { * * @return {@code FileOutputStream} instance. * - * @throws FileNotFoundException in case file not found. + @throws IOException in file reading errors. */ - public static FileOutputStream getFileOutputStream(File tempFile) throws FileNotFoundException { - return new FileOutputStream(tempFile); + public static OutputStream getFileOutputStream(File tempFile) throws IOException { + return Files.newOutputStream(tempFile.toPath()); } /** diff --git a/commons/src/test/java/com/itextpdf/commons/actions/AbstractContextBasedEventHandlerTest.java b/commons/src/test/java/com/itextpdf/commons/actions/AbstractContextBasedEventHandlerTest.java index a4cc2918ca..f1748c3afd 100644 --- a/commons/src/test/java/com/itextpdf/commons/actions/AbstractContextBasedEventHandlerTest.java +++ b/commons/src/test/java/com/itextpdf/commons/actions/AbstractContextBasedEventHandlerTest.java @@ -28,13 +28,12 @@ This file is part of the iText (R) project. import com.itextpdf.commons.ecosystem.ITextTestEvent; import com.itextpdf.commons.ecosystem.TestMetaInfo; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class AbstractContextBasedEventHandlerTest extends ExtendedITextTest { @Test @@ -43,7 +42,7 @@ public void coreEventProcessedByHandlerTest() { handler.onEvent(new ITextTestEvent(new SequenceId(), null, "test-event", ProductNameConstant.ITEXT_CORE)); - Assert.assertTrue(handler.wasInvoked()); + Assertions.assertTrue(handler.wasInvoked()); } @Test @@ -52,7 +51,7 @@ public void anotherProductEventNotProcessedByHandlerTest() { handler.onEvent(new ITextTestEvent(new SequenceId(), null, "test-event", ProductNameConstant.PDF_HTML)); - Assert.assertTrue(handler.wasInvoked()); + Assertions.assertTrue(handler.wasInvoked()); } @Test @@ -61,14 +60,14 @@ public void eventWithMetaInfoTest() { handler.onEvent(new ITextTestEvent(new SequenceId(), new TestMetaInfo("meta info from iTextCore"), "test-event", ProductNameConstant.ITEXT_CORE)); - Assert.assertTrue(handler.wasInvoked()); + Assertions.assertTrue(handler.wasInvoked()); } @Test public void notITextEventIsIgnoredTest() { TestEventHandler handler = new TestEventHandler(UnknownContext.PERMISSIVE); handler.onEvent(new UnknownEvent()); - Assert.assertFalse(handler.wasInvoked()); + Assertions.assertFalse(handler.wasInvoked()); } private static class TestEventHandler extends AbstractContextBasedEventHandler { diff --git a/commons/src/test/java/com/itextpdf/commons/actions/AbstractContextBasedITextEventTest.java b/commons/src/test/java/com/itextpdf/commons/actions/AbstractContextBasedITextEventTest.java index 40e8dcb3c6..89925ae61f 100644 --- a/commons/src/test/java/com/itextpdf/commons/actions/AbstractContextBasedITextEventTest.java +++ b/commons/src/test/java/com/itextpdf/commons/actions/AbstractContextBasedITextEventTest.java @@ -26,15 +26,13 @@ This file is part of the iText (R) project. import com.itextpdf.commons.actions.data.CommonsProductData; import com.itextpdf.commons.actions.data.ProductData; import com.itextpdf.commons.ecosystem.TestMetaInfo; -import com.itextpdf.commons.exceptions.CommonsExceptionMessageConstant; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class AbstractContextBasedITextEventTest extends ExtendedITextTest { @Test @@ -44,7 +42,7 @@ public void setMetaInfoTest() { TestMetaInfo metaInfoAfter = new TestMetaInfo("meta-info-after"); e.setMetaInfo(metaInfoAfter); - Assert.assertSame(metaInfoAfter, e.getMetaInfo()); + Assertions.assertSame(metaInfoAfter, e.getMetaInfo()); } @Test @@ -54,9 +52,9 @@ public void resetMetaInfoForbiddenTest() { BasicAbstractContextBasedITextEvent e = new BasicAbstractContextBasedITextEvent(CommonsProductData.getInstance(), metaInfoBefore); - Assert.assertSame(metaInfoBefore, e.getMetaInfo()); + Assertions.assertSame(metaInfoBefore, e.getMetaInfo()); - Assert.assertFalse(e.setMetaInfo(metaInfoAfter)); + Assertions.assertFalse(e.setMetaInfo(metaInfoAfter)); } private static class BasicAbstractContextBasedITextEvent extends AbstractContextBasedITextEvent { diff --git a/commons/src/test/java/com/itextpdf/commons/actions/AbstractITextConfigurationEventTest.java b/commons/src/test/java/com/itextpdf/commons/actions/AbstractITextConfigurationEventTest.java index 57355e62b5..913fc045ca 100644 --- a/commons/src/test/java/com/itextpdf/commons/actions/AbstractITextConfigurationEventTest.java +++ b/commons/src/test/java/com/itextpdf/commons/actions/AbstractITextConfigurationEventTest.java @@ -27,19 +27,18 @@ This file is part of the iText (R) project. import com.itextpdf.commons.actions.processors.ITextProductEventProcessor; import com.itextpdf.commons.actions.sequence.SequenceId; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.After; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.util.List; import java.util.Map; -@Category(UnitTest.class) +@Tag("UnitTest") public class AbstractITextConfigurationEventTest extends ExtendedITextTest { - @After + @AfterEach public void after() { ProductEventHandler.INSTANCE.clearProcessors(); } @@ -51,8 +50,8 @@ public void addProcessorTest() { event.addProcessor(processor); Map processors = ProductEventHandler.INSTANCE.getProcessors(); - Assert.assertEquals(1, processors.size()); - Assert.assertTrue(processors.values().contains(processor)); + Assertions.assertEquals(1, processors.size()); + Assertions.assertTrue(processors.values().contains(processor)); } @Test @@ -61,7 +60,7 @@ public void getProcessorsTest() { ITextProductEventProcessor processor = new TestITextProductEventProcessor(); event.addProcessor(processor); - Assert.assertEquals(ProductEventHandler.INSTANCE.getProcessors(), event.getProcessors()); + Assertions.assertEquals(ProductEventHandler.INSTANCE.getProcessors(), event.getProcessors()); } @Test @@ -73,7 +72,7 @@ public void removeProcessorTest() { event.removeProcessor(processor.getProductName()); Map processors = ProductEventHandler.INSTANCE.getProcessors(); - Assert.assertEquals(0, processors.size()); + Assertions.assertEquals(0, processors.size()); } @Test @@ -82,7 +81,7 @@ public void getActiveProcessorTest() { ITextProductEventProcessor processor = new TestITextProductEventProcessor(); event.addProcessor(processor); - Assert.assertEquals(processor, event.getActiveProcessor(processor.getProductName())); + Assertions.assertEquals(processor, event.getActiveProcessor(processor.getProductName())); } @Test @@ -93,8 +92,8 @@ public void addEventTest() { configurationEvent.addEvent(id, processEvent); List events = ProductEventHandler.INSTANCE.getEvents(id); - Assert.assertEquals(1, events.size()); - Assert.assertEquals(processEvent, events.get(0)); + Assertions.assertEquals(1, events.size()); + Assertions.assertEquals(processEvent, events.get(0)); } @Test @@ -104,7 +103,7 @@ public void getEventsTest() { configurationEvent.addEvent(id, new TestAbstractProductProcessITextEvent()); configurationEvent.addEvent(id, new TestAbstractProductProcessITextEvent()); - Assert.assertEquals(ProductEventHandler.INSTANCE.getEvents(id), configurationEvent.getEvents(id)); + Assertions.assertEquals(ProductEventHandler.INSTANCE.getEvents(id), configurationEvent.getEvents(id)); } static class TestAbstractITextConfigurationEvent extends AbstractITextConfigurationEvent { diff --git a/commons/src/test/java/com/itextpdf/commons/actions/AbstractProductITextEventTest.java b/commons/src/test/java/com/itextpdf/commons/actions/AbstractProductITextEventTest.java index bb2fade3d3..281e00c593 100644 --- a/commons/src/test/java/com/itextpdf/commons/actions/AbstractProductITextEventTest.java +++ b/commons/src/test/java/com/itextpdf/commons/actions/AbstractProductITextEventTest.java @@ -23,17 +23,16 @@ This file is part of the iText (R) project. package com.itextpdf.commons.actions; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class AbstractProductITextEventTest extends ExtendedITextTest { @Test public void nullProductDataTest() { Exception exception = - Assert.assertThrows(IllegalStateException.class, () -> new AbstractProductITextEvent(null) {}); - Assert.assertEquals("ProductData shouldn't be null.", exception.getMessage()); + Assertions.assertThrows(IllegalStateException.class, () -> new AbstractProductITextEvent(null) {}); + Assertions.assertEquals("ProductData shouldn't be null.", exception.getMessage()); } } diff --git a/commons/src/test/java/com/itextpdf/commons/actions/AbstractStatisticsEventTest.java b/commons/src/test/java/com/itextpdf/commons/actions/AbstractStatisticsEventTest.java index e951d00955..8bf5a04aee 100644 --- a/commons/src/test/java/com/itextpdf/commons/actions/AbstractStatisticsEventTest.java +++ b/commons/src/test/java/com/itextpdf/commons/actions/AbstractStatisticsEventTest.java @@ -27,15 +27,14 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.util.Collections; import java.util.List; -@Category(UnitTest.class) +@Tag("UnitTest") public class AbstractStatisticsEventTest extends ExtendedITextTest { @Test public void constructorTest() { @@ -43,11 +42,11 @@ public void constructorTest() { new DummyStatisticsEvent(new ProductData("public name", "product name", "version", 15, 3000)); ProductData data = dummyEvent.getProductData(); - Assert.assertEquals("public name", data.getPublicProductName()); - Assert.assertEquals("product name", data.getProductName()); - Assert.assertEquals("version", data.getVersion()); - Assert.assertEquals(15, data.getSinceCopyrightYear()); - Assert.assertEquals(3000, data.getToCopyrightYear()); + Assertions.assertEquals("public name", data.getPublicProductName()); + Assertions.assertEquals("product name", data.getProductName()); + Assertions.assertEquals("version", data.getVersion()); + Assertions.assertEquals(15, data.getSinceCopyrightYear()); + Assertions.assertEquals(3000, data.getToCopyrightYear()); } @Test @@ -56,7 +55,7 @@ public void createStatisticsAggregatorFromNameTest() { DummyStatisticsEvent dummyEvent = new DummyStatisticsEvent(new ProductData("public name", "product name", "version", 15, 3000)); - Assert.assertNull(dummyEvent.createStatisticsAggregatorFromName("statisticsName")); + Assertions.assertNull(dummyEvent.createStatisticsAggregatorFromName("statisticsName")); } static class DummyStatisticsEvent extends AbstractStatisticsEvent { diff --git a/commons/src/test/java/com/itextpdf/commons/actions/EventManagerTest.java b/commons/src/test/java/com/itextpdf/commons/actions/EventManagerTest.java index 4294f9ed3f..3623da4d26 100644 --- a/commons/src/test/java/com/itextpdf/commons/actions/EventManagerTest.java +++ b/commons/src/test/java/com/itextpdf/commons/actions/EventManagerTest.java @@ -33,18 +33,17 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.UnitTest; import java.util.List; -import org.junit.After; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class EventManagerTest extends ExtendedITextTest { - @After + @AfterEach public void afterEach() { ProductProcessorFactoryKeeper.restoreDefaultProductProcessorFactory(); } @@ -70,15 +69,15 @@ public void throwSomeExceptionsTest() { try { eventManager.onEvent(new ITextTestEvent(sequenceId, null, "test-event", ProductNameConstant.ITEXT_CORE)); } catch (AggregatedException e) { - Assert.assertEquals("Error during event processing:\n" + Assertions.assertEquals("Error during event processing:\n" + "0) ThrowArithmeticExpHandler\n" + "1) ThrowIllegalArgumentExpHandler\n", e.getMessage()); List aggregatedExceptions = e.getAggregatedExceptions(); - Assert.assertEquals(2, aggregatedExceptions.size()); - Assert.assertEquals("ThrowArithmeticExpHandler", aggregatedExceptions.get(0).getMessage()); - Assert.assertEquals("ThrowIllegalArgumentExpHandler", aggregatedExceptions.get(1).getMessage()); + Assertions.assertEquals(2, aggregatedExceptions.size()); + Assertions.assertEquals("ThrowArithmeticExpHandler", aggregatedExceptions.get(0).getMessage()); + Assertions.assertEquals("ThrowIllegalArgumentExpHandler", aggregatedExceptions.get(1).getMessage()); } eventManager.unregister(handler1); @@ -92,10 +91,10 @@ public void throwOneUncheckedExceptionsTest() { eventManager.register(handler1); try { SequenceId sequenceId = new SequenceId(); - Exception exception = Assert.assertThrows(ArithmeticException.class, + Exception exception = Assertions.assertThrows(ArithmeticException.class, () -> eventManager.onEvent( new ITextTestEvent(sequenceId, null, "test-event", ProductNameConstant.ITEXT_CORE))); - Assert.assertEquals("ThrowArithmeticExpHandler", exception.getMessage()); + Assertions.assertEquals("ThrowArithmeticExpHandler", exception.getMessage()); } finally { eventManager.unregister(handler1); } @@ -106,24 +105,24 @@ public void configureHandlersTest() { EventManager eventManager = EventManager.getInstance(); IEventHandler handler = new ThrowArithmeticExpHandler(); - Assert.assertFalse(eventManager.isRegistered(handler)); + Assertions.assertFalse(eventManager.isRegistered(handler)); eventManager.register(handler); - Assert.assertTrue(eventManager.isRegistered(handler)); + Assertions.assertTrue(eventManager.isRegistered(handler)); - Assert.assertTrue(eventManager.unregister(handler)); - Assert.assertFalse(eventManager.isRegistered(handler)); + Assertions.assertTrue(eventManager.unregister(handler)); + Assertions.assertFalse(eventManager.isRegistered(handler)); - Assert.assertFalse(eventManager.unregister(handler)); + Assertions.assertFalse(eventManager.unregister(handler)); } @Test public void turningOffAgplTest() { IProductProcessorFactory defaultProductProcessorFactory = ProductProcessorFactoryKeeper.getProductProcessorFactory(); - Assert.assertTrue(defaultProductProcessorFactory instanceof DefaultProductProcessorFactory); + Assertions.assertTrue(defaultProductProcessorFactory instanceof DefaultProductProcessorFactory); EventManager.acknowledgeAgplUsageDisableWarningMessage(); IProductProcessorFactory underAgplProductProcessorFactory1 = ProductProcessorFactoryKeeper.getProductProcessorFactory(); - Assert.assertTrue(underAgplProductProcessorFactory1 instanceof UnderAgplProductProcessorFactory); + Assertions.assertTrue(underAgplProductProcessorFactory1 instanceof UnderAgplProductProcessorFactory); } private static class ThrowArithmeticExpHandler implements IEventHandler { diff --git a/commons/src/test/java/com/itextpdf/commons/actions/ProductEventHandlerIntegrationTest.java b/commons/src/test/java/com/itextpdf/commons/actions/ProductEventHandlerIntegrationTest.java index 5dada564b8..00badee136 100644 --- a/commons/src/test/java/com/itextpdf/commons/actions/ProductEventHandlerIntegrationTest.java +++ b/commons/src/test/java/com/itextpdf/commons/actions/ProductEventHandlerIntegrationTest.java @@ -27,27 +27,26 @@ This file is part of the iText (R) project. import com.itextpdf.commons.actions.sequence.SequenceId; import com.itextpdf.commons.ecosystem.ITextTestEvent; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.ByteArrayOutputStream; import java.io.PrintStream; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class ProductEventHandlerIntegrationTest extends ExtendedITextTest { private PrintStream outBackup; - @Before + @BeforeEach public void initTest() { outBackup = System.out; ProductEventHandler.INSTANCE.clearProcessors(); } - @After + @AfterEach public void afterEach() { System.setOut(outBackup); ProductProcessorFactoryKeeper.restoreDefaultProductProcessorFactory(); @@ -66,7 +65,7 @@ public void removeAGPLLoggingTest() { SequenceId sequenceId = new SequenceId(); - Assert.assertTrue(handler.getEvents(sequenceId).isEmpty()); + Assertions.assertTrue(handler.getEvents(sequenceId).isEmpty()); ITextTestEvent event = new ITextTestEvent(sequenceId, null, "test-event", ProductNameConstant.ITEXT_CORE); EventManager.getInstance().onEvent(event); @@ -74,10 +73,10 @@ public void removeAGPLLoggingTest() { ConfirmEvent confirmEvent = new ConfirmEvent(sequenceId, event); EventManager.getInstance().onEvent(confirmEvent); - Assert.assertEquals(1, handler.getEvents(sequenceId).size()); - Assert.assertTrue(handler.getEvents(sequenceId).get(0) instanceof ConfirmedEventWrapper); - Assert.assertEquals(event, ((ConfirmedEventWrapper) handler.getEvents(sequenceId).get(0)).getEvent()); + Assertions.assertEquals(1, handler.getEvents(sequenceId).size()); + Assertions.assertTrue(handler.getEvents(sequenceId).get(0) instanceof ConfirmedEventWrapper); + Assertions.assertEquals(event, ((ConfirmedEventWrapper) handler.getEvents(sequenceId).get(0)).getEvent()); } - Assert.assertEquals("", testOut.toString()); + Assertions.assertEquals("", testOut.toString()); } } diff --git a/commons/src/test/java/com/itextpdf/commons/actions/ProductEventHandlerTest.java b/commons/src/test/java/com/itextpdf/commons/actions/ProductEventHandlerTest.java index 27c63104d0..22fbd4da7a 100644 --- a/commons/src/test/java/com/itextpdf/commons/actions/ProductEventHandlerTest.java +++ b/commons/src/test/java/com/itextpdf/commons/actions/ProductEventHandlerTest.java @@ -34,22 +34,21 @@ This file is part of the iText (R) project. import com.itextpdf.commons.utils.MessageFormatUtil; import com.itextpdf.test.AssertUtil; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class ProductEventHandlerTest extends ExtendedITextTest { - @Before + @BeforeEach public void clearProcessors() { ProductEventHandler.INSTANCE.clearProcessors(); } - @After + @AfterEach public void afterEach() { ProductProcessorFactoryKeeper.restoreDefaultProductProcessorFactory(); } @@ -59,9 +58,9 @@ public void unknownProductTest() { ProductEventHandler handler = ProductEventHandler.INSTANCE; AbstractContextBasedITextEvent event = new ITextTestEvent(new SequenceId(), null, "test-event", "Unknown Product"); - Exception ex = Assert.assertThrows(UnknownProductException.class, + Exception ex = Assertions.assertThrows(UnknownProductException.class, () -> handler.onAcceptedEvent(event)); - Assert.assertEquals(MessageFormatUtil.format(UnknownProductException.UNKNOWN_PRODUCT, "Unknown Product"), + Assertions.assertEquals(MessageFormatUtil.format(UnknownProductException.UNKNOWN_PRODUCT, "Unknown Product"), ex.getMessage()); } @@ -71,18 +70,18 @@ public void sequenceIdBasedEventTest() { SequenceId sequenceId = new SequenceId(); - Assert.assertTrue(handler.getEvents(sequenceId).isEmpty()); + Assertions.assertTrue(handler.getEvents(sequenceId).isEmpty()); handler.onAcceptedEvent(new ITextTestEvent(sequenceId, null, "test-event", ProductNameConstant.ITEXT_CORE)); - Assert.assertEquals(1, handler.getEvents(sequenceId).size()); + Assertions.assertEquals(1, handler.getEvents(sequenceId).size()); AbstractProductProcessITextEvent event = handler.getEvents(sequenceId).get(0); - Assert.assertEquals(sequenceId.getId(), event.getSequenceId().getId()); - Assert.assertNull(event.getMetaInfo()); - Assert.assertEquals("test-event", event.getEventType()); - Assert.assertEquals(ProductNameConstant.ITEXT_CORE, event.getProductName()); + Assertions.assertEquals(sequenceId.getId(), event.getSequenceId().getId()); + Assertions.assertNull(event.getMetaInfo()); + Assertions.assertEquals("test-event", event.getEventType()); + Assertions.assertEquals(ProductNameConstant.ITEXT_CORE, event.getProductName()); } @Test @@ -91,19 +90,19 @@ public void reportEventSeveralTimesTest() { SequenceId sequenceId = new SequenceId(); - Assert.assertTrue(handler.getEvents(sequenceId).isEmpty()); + Assertions.assertTrue(handler.getEvents(sequenceId).isEmpty()); ITextTestEvent event = new ITextTestEvent(sequenceId, null, "test-event", ProductNameConstant.ITEXT_CORE); EventManager.getInstance().onEvent(event); - Assert.assertEquals(1, handler.getEvents(sequenceId).size()); - Assert.assertEquals(event, handler.getEvents(sequenceId).get(0)); + Assertions.assertEquals(1, handler.getEvents(sequenceId).size()); + Assertions.assertEquals(event, handler.getEvents(sequenceId).get(0)); EventManager.getInstance().onEvent(event); - Assert.assertEquals(2, handler.getEvents(sequenceId).size()); - Assert.assertEquals(event, handler.getEvents(sequenceId).get(0)); - Assert.assertEquals(event, handler.getEvents(sequenceId).get(1)); + Assertions.assertEquals(2, handler.getEvents(sequenceId).size()); + Assertions.assertEquals(event, handler.getEvents(sequenceId).get(0)); + Assertions.assertEquals(event, handler.getEvents(sequenceId).get(1)); } @Test @@ -112,7 +111,7 @@ public void confirmEventTest() { SequenceId sequenceId = new SequenceId(); - Assert.assertTrue(handler.getEvents(sequenceId).isEmpty()); + Assertions.assertTrue(handler.getEvents(sequenceId).isEmpty()); ITextTestEvent event = new ITextTestEvent(sequenceId, null, "test-event", ProductNameConstant.ITEXT_CORE); @@ -121,9 +120,9 @@ public void confirmEventTest() { ConfirmEvent confirmEvent = new ConfirmEvent(sequenceId, event); EventManager.getInstance().onEvent(confirmEvent); - Assert.assertEquals(1, handler.getEvents(sequenceId).size()); - Assert.assertTrue(handler.getEvents(sequenceId).get(0) instanceof ConfirmedEventWrapper); - Assert.assertEquals(event, ((ConfirmedEventWrapper) handler.getEvents(sequenceId).get(0)).getEvent()); + Assertions.assertEquals(1, handler.getEvents(sequenceId).size()); + Assertions.assertTrue(handler.getEvents(sequenceId).get(0) instanceof ConfirmedEventWrapper); + Assertions.assertEquals(event, ((ConfirmedEventWrapper) handler.getEvents(sequenceId).get(0)).getEvent()); } @Test @@ -135,7 +134,7 @@ public void settingCustomProcessFactoryTest() { ProductEventHandler handler = ProductEventHandler.INSTANCE; ITextProductEventProcessor activeProcessor = handler.getActiveProcessor(ProductNameConstant.ITEXT_CORE); - Assert.assertTrue(activeProcessor instanceof TestProductEventProcessor); + Assertions.assertTrue(activeProcessor instanceof TestProductEventProcessor); } @Test @@ -147,9 +146,9 @@ public void repeatEventHandlingWithFiveExceptionOnProcessingTest() { AbstractContextBasedITextEvent event = new ITextTestEvent(new SequenceId(), null, "test", ProductNameConstant.ITEXT_CORE); - Exception e = Assert.assertThrows(ProductEventHandlerRepeatException.class, + Exception e = Assertions.assertThrows(ProductEventHandlerRepeatException.class, () -> handler.onAcceptedEvent(event)); - Assert.assertEquals("customMessage5", e.getMessage()); + Assertions.assertEquals("customMessage5", e.getMessage()); } @Test diff --git a/commons/src/test/java/com/itextpdf/commons/actions/ProductProcessorFactoryKeeperTest.java b/commons/src/test/java/com/itextpdf/commons/actions/ProductProcessorFactoryKeeperTest.java index 864845f076..ebd3ec999d 100644 --- a/commons/src/test/java/com/itextpdf/commons/actions/ProductProcessorFactoryKeeperTest.java +++ b/commons/src/test/java/com/itextpdf/commons/actions/ProductProcessorFactoryKeeperTest.java @@ -26,17 +26,16 @@ This file is part of the iText (R) project. import com.itextpdf.commons.actions.processors.IProductProcessorFactory; import com.itextpdf.commons.actions.processors.UnderAgplProductProcessorFactory; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.After; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class ProductProcessorFactoryKeeperTest extends ExtendedITextTest { - @After + @AfterEach public void afterEach() { ProductProcessorFactoryKeeper.restoreDefaultProductProcessorFactory(); } @@ -44,17 +43,17 @@ public void afterEach() { @Test public void gettingDefaultFactoryFromKeeper() { IProductProcessorFactory productProcessorFactory = ProductProcessorFactoryKeeper.getProductProcessorFactory(); - Assert.assertTrue(productProcessorFactory instanceof DefaultProductProcessorFactory); + Assertions.assertTrue(productProcessorFactory instanceof DefaultProductProcessorFactory); } @Test public void restoringDefaultFactory() { ProductProcessorFactoryKeeper.setProductProcessorFactory(new UnderAgplProductProcessorFactory()); - Assert.assertTrue(ProductProcessorFactoryKeeper.getProductProcessorFactory() + Assertions.assertTrue(ProductProcessorFactoryKeeper.getProductProcessorFactory() instanceof UnderAgplProductProcessorFactory); ProductProcessorFactoryKeeper.restoreDefaultProductProcessorFactory(); - Assert.assertTrue(ProductProcessorFactoryKeeper.getProductProcessorFactory() + Assertions.assertTrue(ProductProcessorFactoryKeeper.getProductProcessorFactory() instanceof DefaultProductProcessorFactory); } } diff --git a/commons/src/test/java/com/itextpdf/commons/actions/confirmations/ConfirmEventTest.java b/commons/src/test/java/com/itextpdf/commons/actions/confirmations/ConfirmEventTest.java index e328fab8b8..850fe4ccc5 100644 --- a/commons/src/test/java/com/itextpdf/commons/actions/confirmations/ConfirmEventTest.java +++ b/commons/src/test/java/com/itextpdf/commons/actions/confirmations/ConfirmEventTest.java @@ -26,13 +26,12 @@ This file is part of the iText (R) project. import com.itextpdf.commons.ecosystem.TestMetaInfo; import com.itextpdf.commons.actions.sequence.SequenceId; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class ConfirmEventTest extends ExtendedITextTest { @Test public void constructorWithSequenceIdTest() { @@ -40,13 +39,13 @@ public void constructorWithSequenceIdTest() { ITextTestEvent iTextTestEvent = new ITextTestEvent(new SequenceId(), new TestMetaInfo(""), "eventType", "productName"); ConfirmEvent confirmEvent = new ConfirmEvent(sequenceId, iTextTestEvent); - Assert.assertSame(iTextTestEvent, confirmEvent.getConfirmedEvent()); - Assert.assertEquals("eventType", confirmEvent.getEventType()); - Assert.assertEquals("productName", confirmEvent.getProductName()); - Assert.assertSame(sequenceId, confirmEvent.getSequenceId()); - Assert.assertEquals(EventConfirmationType.UNCONFIRMABLE, confirmEvent.getConfirmationType()); - Assert.assertNotNull(confirmEvent.getProductData()); - Assert.assertEquals(ITextTestEvent.class, confirmEvent.getClassFromContext()); + Assertions.assertSame(iTextTestEvent, confirmEvent.getConfirmedEvent()); + Assertions.assertEquals("eventType", confirmEvent.getEventType()); + Assertions.assertEquals("productName", confirmEvent.getProductName()); + Assertions.assertSame(sequenceId, confirmEvent.getSequenceId()); + Assertions.assertEquals(EventConfirmationType.UNCONFIRMABLE, confirmEvent.getConfirmationType()); + Assertions.assertNotNull(confirmEvent.getProductData()); + Assertions.assertEquals(ITextTestEvent.class, confirmEvent.getClassFromContext()); } @Test @@ -54,13 +53,13 @@ public void constructorWithoutSequenceIdTest() { ITextTestEvent iTextTestEvent = new ITextTestEvent(new SequenceId(), new TestMetaInfo(""), "eventType", "productName"); ConfirmEvent confirmEvent = new ConfirmEvent(iTextTestEvent); - Assert.assertSame(iTextTestEvent, confirmEvent.getConfirmedEvent()); - Assert.assertEquals("eventType", confirmEvent.getEventType()); - Assert.assertEquals("productName", confirmEvent.getProductName()); - Assert.assertSame(iTextTestEvent.getSequenceId(), confirmEvent.getSequenceId()); - Assert.assertEquals(EventConfirmationType.UNCONFIRMABLE, confirmEvent.getConfirmationType()); - Assert.assertNotNull(confirmEvent.getProductData()); - Assert.assertEquals(ITextTestEvent.class, confirmEvent.getClassFromContext()); + Assertions.assertSame(iTextTestEvent, confirmEvent.getConfirmedEvent()); + Assertions.assertEquals("eventType", confirmEvent.getEventType()); + Assertions.assertEquals("productName", confirmEvent.getProductName()); + Assertions.assertSame(iTextTestEvent.getSequenceId(), confirmEvent.getSequenceId()); + Assertions.assertEquals(EventConfirmationType.UNCONFIRMABLE, confirmEvent.getConfirmationType()); + Assertions.assertNotNull(confirmEvent.getProductData()); + Assertions.assertEquals(ITextTestEvent.class, confirmEvent.getClassFromContext()); } @Test @@ -69,14 +68,14 @@ public void confirmEventInsideOtherConfirmEventTest() { ConfirmEvent child = new ConfirmEvent(iTextTestEvent.getSequenceId(), iTextTestEvent); ConfirmEvent confirmEvent = new ConfirmEvent(child); - Assert.assertSame(iTextTestEvent, confirmEvent.getConfirmedEvent()); + Assertions.assertSame(iTextTestEvent, confirmEvent.getConfirmedEvent()); - Assert.assertSame(iTextTestEvent, confirmEvent.getConfirmedEvent()); - Assert.assertEquals("eventType", confirmEvent.getEventType()); - Assert.assertEquals("productName", confirmEvent.getProductName()); - Assert.assertSame(iTextTestEvent.getSequenceId(), confirmEvent.getSequenceId()); - Assert.assertEquals(EventConfirmationType.UNCONFIRMABLE, confirmEvent.getConfirmationType()); - Assert.assertNotNull(confirmEvent.getProductData()); - Assert.assertEquals(ITextTestEvent.class, confirmEvent.getClassFromContext()); + Assertions.assertSame(iTextTestEvent, confirmEvent.getConfirmedEvent()); + Assertions.assertEquals("eventType", confirmEvent.getEventType()); + Assertions.assertEquals("productName", confirmEvent.getProductName()); + Assertions.assertSame(iTextTestEvent.getSequenceId(), confirmEvent.getSequenceId()); + Assertions.assertEquals(EventConfirmationType.UNCONFIRMABLE, confirmEvent.getConfirmationType()); + Assertions.assertNotNull(confirmEvent.getProductData()); + Assertions.assertEquals(ITextTestEvent.class, confirmEvent.getClassFromContext()); } } diff --git a/commons/src/test/java/com/itextpdf/commons/actions/contexts/ContextManagerTest.java b/commons/src/test/java/com/itextpdf/commons/actions/contexts/ContextManagerTest.java index 252e57c90d..1c5d27f039 100644 --- a/commons/src/test/java/com/itextpdf/commons/actions/contexts/ContextManagerTest.java +++ b/commons/src/test/java/com/itextpdf/commons/actions/contexts/ContextManagerTest.java @@ -24,16 +24,15 @@ This file is part of the iText (R) project. import com.itextpdf.commons.actions.NamespaceConstant; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.util.Arrays; import java.util.Collections; import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class ContextManagerTest extends ExtendedITextTest { @Test @@ -41,7 +40,7 @@ public void getRecognisedNamespaceForSpecificNamespaceTest() { String outerNamespaces = NamespaceConstant.ITEXT.toLowerCase(); String innerNamespaces = NamespaceConstant.PDF_HTML.toLowerCase(); - Assert.assertTrue(innerNamespaces.startsWith(outerNamespaces)); + Assertions.assertTrue(innerNamespaces.startsWith(outerNamespaces)); ContextManager managerOuterBeforeInner = new ContextManager(); managerOuterBeforeInner @@ -49,9 +48,9 @@ public void getRecognisedNamespaceForSpecificNamespaceTest() { managerOuterBeforeInner .registerGenericContext(Collections.singletonList(innerNamespaces), Collections.emptyList()); - Assert.assertEquals(outerNamespaces, + Assertions.assertEquals(outerNamespaces, managerOuterBeforeInner.getRecognisedNamespace(outerNamespaces)); - Assert.assertEquals(innerNamespaces, + Assertions.assertEquals(innerNamespaces, managerOuterBeforeInner.getRecognisedNamespace(innerNamespaces)); ContextManager managerInnerBeforeOuter = new ContextManager(); @@ -60,9 +59,9 @@ public void getRecognisedNamespaceForSpecificNamespaceTest() { managerInnerBeforeOuter .registerGenericContext(Collections.singletonList(outerNamespaces), Collections.emptyList()); - Assert.assertEquals(outerNamespaces, + Assertions.assertEquals(outerNamespaces, managerInnerBeforeOuter.getRecognisedNamespace(outerNamespaces)); - Assert.assertEquals(innerNamespaces, + Assertions.assertEquals(innerNamespaces, managerInnerBeforeOuter.getRecognisedNamespace(innerNamespaces)); } @@ -70,7 +69,7 @@ public void getRecognisedNamespaceForSpecificNamespaceTest() { public void notRegisteredNamespaceTest() { String notRegisteredNamespace = "com.hello.world"; - Assert.assertNull(ContextManager.getInstance().getRecognisedNamespace(notRegisteredNamespace)); + Assertions.assertNull(ContextManager.getInstance().getRecognisedNamespace(notRegisteredNamespace)); } @Test @@ -83,27 +82,27 @@ public void unregisterNamespaceTest() { ); ContextManager manager = new ContextManager(); - Assert.assertNull(manager.getRecognisedNamespace(testNamespace)); - Assert.assertNull(manager.getRecognisedNamespace(testNamespaceWithCapitals)); + Assertions.assertNull(manager.getRecognisedNamespace(testNamespace)); + Assertions.assertNull(manager.getRecognisedNamespace(testNamespaceWithCapitals)); manager.registerGenericContext(testNamespaces, Arrays.asList("myProduct")); - Assert.assertEquals(testNamespace, + Assertions.assertEquals(testNamespace, manager.getRecognisedNamespace(testNamespace + ".MyClass")); - Assert.assertEquals(testNamespaceWithCapitals.toLowerCase(), + Assertions.assertEquals(testNamespaceWithCapitals.toLowerCase(), manager.getRecognisedNamespace(testNamespaceWithCapitals + ".MyClass")); manager.unregisterContext(testNamespaces); - Assert.assertNull(manager.getRecognisedNamespace(testNamespace)); - Assert.assertNull(manager.getRecognisedNamespace(testNamespaceWithCapitals)); + Assertions.assertNull(manager.getRecognisedNamespace(testNamespace)); + Assertions.assertNull(manager.getRecognisedNamespace(testNamespaceWithCapitals)); } @Test public void registeredNamespaceTest() { String registeredNamespace = NamespaceConstant.CORE_LAYOUT + "custompackage"; - Assert.assertEquals(NamespaceConstant.CORE_LAYOUT.toLowerCase(), + Assertions.assertEquals(NamespaceConstant.CORE_LAYOUT.toLowerCase(), ContextManager.getInstance().getRecognisedNamespace(registeredNamespace)); } } diff --git a/commons/src/test/java/com/itextpdf/commons/actions/data/CommonsProductDataTest.java b/commons/src/test/java/com/itextpdf/commons/actions/data/CommonsProductDataTest.java index de4cdfc5da..cfdfeb6dd2 100644 --- a/commons/src/test/java/com/itextpdf/commons/actions/data/CommonsProductDataTest.java +++ b/commons/src/test/java/com/itextpdf/commons/actions/data/CommonsProductDataTest.java @@ -23,24 +23,23 @@ This file is part of the iText (R) project. package com.itextpdf.commons.actions.data; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class CommonsProductDataTest extends ExtendedITextTest { @Test public void getInstanceTest() { ProductData commonsProductData = CommonsProductData.getInstance(); - Assert.assertEquals(CommonsProductData.COMMONS_PUBLIC_PRODUCT_NAME, commonsProductData.getPublicProductName()); - Assert.assertEquals(CommonsProductData.COMMONS_PRODUCT_NAME, commonsProductData.getProductName()); - Assert.assertEquals(CommonsProductData.COMMONS_VERSION, commonsProductData.getVersion()); - Assert.assertEquals(CommonsProductData.MINIMAL_COMPATIBLE_LICENSEKEY_VERSION, + Assertions.assertEquals(CommonsProductData.COMMONS_PUBLIC_PRODUCT_NAME, commonsProductData.getPublicProductName()); + Assertions.assertEquals(CommonsProductData.COMMONS_PRODUCT_NAME, commonsProductData.getProductName()); + Assertions.assertEquals(CommonsProductData.COMMONS_VERSION, commonsProductData.getVersion()); + Assertions.assertEquals(CommonsProductData.MINIMAL_COMPATIBLE_LICENSEKEY_VERSION, commonsProductData.getMinCompatibleLicensingModuleVersion()); - Assert.assertEquals(CommonsProductData.COMMONS_COPYRIGHT_SINCE, commonsProductData.getSinceCopyrightYear()); - Assert.assertEquals(CommonsProductData.COMMONS_COPYRIGHT_TO, commonsProductData.getToCopyrightYear()); + Assertions.assertEquals(CommonsProductData.COMMONS_COPYRIGHT_SINCE, commonsProductData.getSinceCopyrightYear()); + Assertions.assertEquals(CommonsProductData.COMMONS_COPYRIGHT_TO, commonsProductData.getToCopyrightYear()); } } diff --git a/commons/src/test/java/com/itextpdf/commons/actions/data/ProductDataTest.java b/commons/src/test/java/com/itextpdf/commons/actions/data/ProductDataTest.java index 97687f31c6..40c7c03c43 100644 --- a/commons/src/test/java/com/itextpdf/commons/actions/data/ProductDataTest.java +++ b/commons/src/test/java/com/itextpdf/commons/actions/data/ProductDataTest.java @@ -23,35 +23,34 @@ This file is part of the iText (R) project. package com.itextpdf.commons.actions.data; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class ProductDataTest extends ExtendedITextTest { @Test public void productDataCreationTest() { ProductData productData = new ProductData("publicProductName", "productName", "1.2", 1900, 2100); - Assert.assertEquals("publicProductName", productData.getPublicProductName()); - Assert.assertEquals("productName", productData.getProductName()); - Assert.assertEquals("1.2", productData.getVersion()); - Assert.assertEquals(1900, productData.getSinceCopyrightYear()); - Assert.assertEquals(2100, productData.getToCopyrightYear()); + Assertions.assertEquals("publicProductName", productData.getPublicProductName()); + Assertions.assertEquals("productName", productData.getProductName()); + Assertions.assertEquals("1.2", productData.getVersion()); + Assertions.assertEquals(1900, productData.getSinceCopyrightYear()); + Assertions.assertEquals(2100, productData.getToCopyrightYear()); } @Test public void productDataAnotherCreationTest() { ProductData productData = new ProductData("publicProductName", "productName", "1.2", "4.0.0", 1900, 2100); - Assert.assertEquals("publicProductName", productData.getPublicProductName()); - Assert.assertEquals("productName", productData.getProductName()); - Assert.assertEquals("1.2", productData.getVersion()); - Assert.assertEquals("4.0.0", productData.getMinCompatibleLicensingModuleVersion()); - Assert.assertEquals(1900, productData.getSinceCopyrightYear()); - Assert.assertEquals(2100, productData.getToCopyrightYear()); + Assertions.assertEquals("publicProductName", productData.getPublicProductName()); + Assertions.assertEquals("productName", productData.getProductName()); + Assertions.assertEquals("1.2", productData.getVersion()); + Assertions.assertEquals("4.0.0", productData.getMinCompatibleLicensingModuleVersion()); + Assertions.assertEquals(1900, productData.getSinceCopyrightYear()); + Assertions.assertEquals(2100, productData.getToCopyrightYear()); } @Test @@ -59,10 +58,10 @@ public void equalsTest() { ProductData a = new ProductData("publicProductName", "productName", "1.2", 1900, 2100); ProductData b = new ProductData("publicProductName", "productName", "1.2", 1900, 2100); - Assert.assertEquals(a, a); + Assertions.assertEquals(a, a); - Assert.assertEquals(a, b); - Assert.assertEquals(b, a); + Assertions.assertEquals(a, b); + Assertions.assertEquals(b, a); } @Test @@ -70,7 +69,7 @@ public void notEqualsTest() { ProductData a = new ProductData("publicProductName", "productName", "1.2", 1900, 2100); ProductData d = new ProductData("publicProductName", "productName", "1.2", 1910, 2110); - Assert.assertNotEquals(a, d); + Assertions.assertNotEquals(a, d); } @Test @@ -78,11 +77,11 @@ public void hashCodeTest() { ProductData a = new ProductData("publicProductName", "productName", "1.2", 1900, 2100); ProductData b = new ProductData("publicProductName", "productName", "1.2", 1900, 2100); - Assert.assertEquals(a, b); - Assert.assertEquals(a.hashCode(), b.hashCode()); + Assertions.assertEquals(a, b); + Assertions.assertEquals(a.hashCode(), b.hashCode()); int h1 = a.hashCode(); int h2 = a.hashCode(); - Assert.assertEquals(h1, h2); + Assertions.assertEquals(h1, h2); } } diff --git a/commons/src/test/java/com/itextpdf/commons/actions/processors/DefaultITextProductEventProcessorTest.java b/commons/src/test/java/com/itextpdf/commons/actions/processors/DefaultITextProductEventProcessorTest.java index 400cccf9c2..cf142b44a2 100644 --- a/commons/src/test/java/com/itextpdf/commons/actions/processors/DefaultITextProductEventProcessorTest.java +++ b/commons/src/test/java/com/itextpdf/commons/actions/processors/DefaultITextProductEventProcessorTest.java @@ -32,20 +32,19 @@ This file is part of the iText (R) project. import com.itextpdf.test.LogLevelConstants; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class DefaultITextProductEventProcessorTest extends ExtendedITextTest { @Test public void constructorWithNullProductNameTest() { Exception e = - Assert.assertThrows(IllegalArgumentException.class, () -> new DefaultITextProductEventProcessor(null)); - Assert.assertEquals(CommonsExceptionMessageConstant.PRODUCT_NAME_CAN_NOT_BE_NULL, e.getMessage()); + Assertions.assertThrows(IllegalArgumentException.class, () -> new DefaultITextProductEventProcessor(null)); + Assertions.assertEquals(CommonsExceptionMessageConstant.PRODUCT_NAME_CAN_NOT_BE_NULL, e.getMessage()); } @Test diff --git a/commons/src/test/java/com/itextpdf/commons/actions/processors/DefaultProductProcessorFactoryTest.java b/commons/src/test/java/com/itextpdf/commons/actions/processors/DefaultProductProcessorFactoryTest.java index c746b1c9df..411935e1c1 100644 --- a/commons/src/test/java/com/itextpdf/commons/actions/processors/DefaultProductProcessorFactoryTest.java +++ b/commons/src/test/java/com/itextpdf/commons/actions/processors/DefaultProductProcessorFactoryTest.java @@ -24,20 +24,19 @@ This file is part of the iText (R) project. import com.itextpdf.commons.actions.ProductNameConstant; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class DefaultProductProcessorFactoryTest extends ExtendedITextTest { @Test public void createDefaultProductProcessor() { DefaultProductProcessorFactory defaultProductProcessorFactory = new DefaultProductProcessorFactory(); ITextProductEventProcessor processor = defaultProductProcessorFactory.createProcessor(ProductNameConstant.ITEXT_CORE); - Assert.assertNotNull(processor); - Assert.assertTrue(processor instanceof DefaultITextProductEventProcessor); + Assertions.assertNotNull(processor); + Assertions.assertTrue(processor instanceof DefaultITextProductEventProcessor); } } diff --git a/commons/src/test/java/com/itextpdf/commons/actions/processors/UnderAgplITextProductEventProcessorTest.java b/commons/src/test/java/com/itextpdf/commons/actions/processors/UnderAgplITextProductEventProcessorTest.java index 731c76950a..61a47a7104 100644 --- a/commons/src/test/java/com/itextpdf/commons/actions/processors/UnderAgplITextProductEventProcessorTest.java +++ b/commons/src/test/java/com/itextpdf/commons/actions/processors/UnderAgplITextProductEventProcessorTest.java @@ -29,12 +29,11 @@ This file is part of the iText (R) project. import com.itextpdf.commons.ecosystem.ITextTestEvent; import com.itextpdf.test.AssertUtil; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class UnderAgplITextProductEventProcessorTest extends ExtendedITextTest { @Test diff --git a/commons/src/test/java/com/itextpdf/commons/actions/processors/UnderAgplProductProcessorFactoryTest.java b/commons/src/test/java/com/itextpdf/commons/actions/processors/UnderAgplProductProcessorFactoryTest.java index 380e02e3d0..935225e94d 100644 --- a/commons/src/test/java/com/itextpdf/commons/actions/processors/UnderAgplProductProcessorFactoryTest.java +++ b/commons/src/test/java/com/itextpdf/commons/actions/processors/UnderAgplProductProcessorFactoryTest.java @@ -24,20 +24,19 @@ This file is part of the iText (R) project. import com.itextpdf.commons.actions.ProductNameConstant; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class UnderAgplProductProcessorFactoryTest extends ExtendedITextTest { @Test public void createUnderAgplProductProcessor() { UnderAgplProductProcessorFactory underAgplProductProcessorFactory = new UnderAgplProductProcessorFactory(); ITextProductEventProcessor processor = underAgplProductProcessorFactory.createProcessor(ProductNameConstant.ITEXT_CORE); - Assert.assertNotNull(processor); - Assert.assertTrue(processor instanceof UnderAgplITextProductEventProcessor); + Assertions.assertNotNull(processor); + Assertions.assertTrue(processor instanceof UnderAgplITextProductEventProcessor); } } diff --git a/commons/src/test/java/com/itextpdf/commons/actions/producer/CopyrightSincePlaceholderPopulatorTest.java b/commons/src/test/java/com/itextpdf/commons/actions/producer/CopyrightSincePlaceholderPopulatorTest.java index 4ddc3cda52..79202a08b8 100644 --- a/commons/src/test/java/com/itextpdf/commons/actions/producer/CopyrightSincePlaceholderPopulatorTest.java +++ b/commons/src/test/java/com/itextpdf/commons/actions/producer/CopyrightSincePlaceholderPopulatorTest.java @@ -27,15 +27,14 @@ This file is part of the iText (R) project. import com.itextpdf.commons.ecosystem.ITextTestEvent; import com.itextpdf.commons.actions.sequence.SequenceId; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.util.ArrayList; import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class CopyrightSincePlaceholderPopulatorTest extends ExtendedITextTest { private CopyrightSincePlaceholderPopulator populator = new CopyrightSincePlaceholderPopulator(); @@ -43,21 +42,21 @@ public class CopyrightSincePlaceholderPopulatorTest extends ExtendedITextTest { public void oneEventTest() { List events = getEvents(1994); String result = populator.populate(events, null); - Assert.assertEquals("1994", result); + Assertions.assertEquals("1994", result); } @Test public void severalEventsTest() { List events = getEvents(2012, 1994, 1998); String result = populator.populate(events, null); - Assert.assertEquals("1994", result); + Assertions.assertEquals("1994", result); } @Test public void severalEventsWithSameYearTest() { List events = getEvents(1992, 1998, 1992, 1998); String result = populator.populate(events, null); - Assert.assertEquals("1992", result); + Assertions.assertEquals("1992", result); } diff --git a/commons/src/test/java/com/itextpdf/commons/actions/producer/CopyrightToPlaceholderPopulatorTest.java b/commons/src/test/java/com/itextpdf/commons/actions/producer/CopyrightToPlaceholderPopulatorTest.java index e1501c8277..656413c709 100644 --- a/commons/src/test/java/com/itextpdf/commons/actions/producer/CopyrightToPlaceholderPopulatorTest.java +++ b/commons/src/test/java/com/itextpdf/commons/actions/producer/CopyrightToPlaceholderPopulatorTest.java @@ -27,15 +27,14 @@ This file is part of the iText (R) project. import com.itextpdf.commons.ecosystem.ITextTestEvent; import com.itextpdf.commons.actions.sequence.SequenceId; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.util.ArrayList; import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class CopyrightToPlaceholderPopulatorTest extends ExtendedITextTest { private CopyrightToPlaceholderPopulator populator = new CopyrightToPlaceholderPopulator(); @@ -43,21 +42,21 @@ public class CopyrightToPlaceholderPopulatorTest extends ExtendedITextTest { public void oneEventTest() { List events = getEvents(2010); String result = populator.populate(events, null); - Assert.assertEquals("2010", result); + Assertions.assertEquals("2010", result); } @Test public void severalEventsTest() { List events = getEvents(2007, 2030, 2020); String result = populator.populate(events, null); - Assert.assertEquals("2030", result); + Assertions.assertEquals("2030", result); } @Test public void severalEventsWithSameYearTest() { List events = getEvents(2009, 1998, 2009, 1998); String result = populator.populate(events, null); - Assert.assertEquals("2009", result); + Assertions.assertEquals("2009", result); } diff --git a/commons/src/test/java/com/itextpdf/commons/actions/producer/CurrentDatePlaceholderPopulatorTest.java b/commons/src/test/java/com/itextpdf/commons/actions/producer/CurrentDatePlaceholderPopulatorTest.java index 9de823c590..1a60efd3fa 100644 --- a/commons/src/test/java/com/itextpdf/commons/actions/producer/CurrentDatePlaceholderPopulatorTest.java +++ b/commons/src/test/java/com/itextpdf/commons/actions/producer/CurrentDatePlaceholderPopulatorTest.java @@ -27,82 +27,81 @@ This file is part of the iText (R) project. import com.itextpdf.commons.utils.MessageFormatUtil; import com.itextpdf.test.AssertUtil; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.util.Date; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class CurrentDatePlaceholderPopulatorTest extends ExtendedITextTest { private final CurrentDatePlaceholderPopulator populator = new CurrentDatePlaceholderPopulator(); @Test public void nullTest() { - Exception exception = Assert.assertThrows(IllegalArgumentException.class, + Exception exception = Assertions.assertThrows(IllegalArgumentException.class, () -> populator.populate(null, null)); - Assert.assertEquals(MessageFormatUtil.format(CommonsExceptionMessageConstant.INVALID_USAGE_FORMAT_REQUIRED, "currentDate"), + Assertions.assertEquals(MessageFormatUtil.format(CommonsExceptionMessageConstant.INVALID_USAGE_FORMAT_REQUIRED, "currentDate"), exception.getMessage()); } @Test public void plainTextTest() { String result = populator.populate(null, "'plain text'"); - Assert.assertEquals("plain text", result); + Assertions.assertEquals("plain text", result); } @Test public void plainTextWithIgnoredBackSlashesTest() { String result = populator.populate(null, "'\\p\\l\\a\\i\\n \\t\\e\\x\\t'"); - Assert.assertEquals("plain text", result); + Assertions.assertEquals("plain text", result); } @Test public void plainTextWithEscapedBackSlashesTest() { String result = populator.populate(null, "'plain\\\\text'"); - Assert.assertEquals("plain\\text", result); + Assertions.assertEquals("plain\\text", result); } @Test public void plainTextWithEscapedApostrophesTest() { String result = populator.populate(null, "'plain\\'text'"); - Assert.assertEquals("plain'text", result); + Assertions.assertEquals("plain'text", result); } @Test public void plainTextSeveralQuotedStringsTest() { String result = populator.populate(null, "'plain'' ''text'"); - Assert.assertEquals("plain text", result); + Assertions.assertEquals("plain text", result); } @Test public void plainTextWithUnquotedCharactersTest() { String result = populator.populate(null, "'plain text'$$$"); - Assert.assertEquals("plain text$$$", result); + Assertions.assertEquals("plain text$$$", result); } @Test public void plainTextEndlessQuotationErrorTest() { - Exception exception = Assert.assertThrows(IllegalArgumentException.class, + Exception exception = Assertions.assertThrows(IllegalArgumentException.class, () -> populator.populate(null, "'plain text")); - Assert.assertEquals(CommonsExceptionMessageConstant.PATTERN_CONTAINS_OPEN_QUOTATION, + Assertions.assertEquals(CommonsExceptionMessageConstant.PATTERN_CONTAINS_OPEN_QUOTATION, exception.getMessage()); } @Test public void plainTextMultipleQuotationsEndlessQuotationErrorTest() { - Exception exception = Assert.assertThrows(IllegalArgumentException.class, + Exception exception = Assertions.assertThrows(IllegalArgumentException.class, () -> populator.populate(null, "'plain'' ''text")); - Assert.assertEquals(CommonsExceptionMessageConstant.PATTERN_CONTAINS_OPEN_QUOTATION, + Assertions.assertEquals(CommonsExceptionMessageConstant.PATTERN_CONTAINS_OPEN_QUOTATION, exception.getMessage()); } @Test public void plainTextEscapedApostropheEndlessQuotationErrorTest() { - Exception exception = Assert.assertThrows(IllegalArgumentException.class, + Exception exception = Assertions.assertThrows(IllegalArgumentException.class, () -> populator.populate(null, "'plain text\\'")); - Assert.assertEquals(CommonsExceptionMessageConstant.PATTERN_CONTAINS_OPEN_QUOTATION, + Assertions.assertEquals(CommonsExceptionMessageConstant.PATTERN_CONTAINS_OPEN_QUOTATION, exception.getMessage()); } @@ -118,30 +117,30 @@ public void validComponentsComparisonTest() { Date date = DateTimeUtil.getCurrentTimeDate(); String result = populator.populate(null, "dd MM yy yyyy HH"); String expectedResult = DateTimeUtil.format(date, "dd MM yy yyyy HH"); - Assert.assertEquals(expectedResult, result); + Assertions.assertEquals(expectedResult, result); } @Test public void unexpectedLetterComponentTest() { - Exception exception = Assert.assertThrows(IllegalArgumentException.class, + Exception exception = Assertions.assertThrows(IllegalArgumentException.class, () -> populator.populate(null, "dd MM tyy yyyy HH")); - Assert.assertEquals(MessageFormatUtil.format(CommonsExceptionMessageConstant.PATTERN_CONTAINS_UNEXPECTED_COMPONENT, "t"), + Assertions.assertEquals(MessageFormatUtil.format(CommonsExceptionMessageConstant.PATTERN_CONTAINS_UNEXPECTED_COMPONENT, "t"), exception.getMessage()); } @Test public void unexpectedLongComponentTest() { - Exception exception = Assert.assertThrows(IllegalArgumentException.class, + Exception exception = Assertions.assertThrows(IllegalArgumentException.class, () -> populator.populate(null, "dd MMMMM yy yyyy HH")); - Assert.assertEquals(MessageFormatUtil.format(CommonsExceptionMessageConstant.PATTERN_CONTAINS_UNEXPECTED_COMPONENT, "MMMMM"), + Assertions.assertEquals(MessageFormatUtil.format(CommonsExceptionMessageConstant.PATTERN_CONTAINS_UNEXPECTED_COMPONENT, "MMMMM"), exception.getMessage()); } @Test public void unexpectedShortComponentTest() { - Exception exception = Assert.assertThrows(IllegalArgumentException.class, + Exception exception = Assertions.assertThrows(IllegalArgumentException.class, () -> populator.populate(null, "dd MM y yyyy HH")); - Assert.assertEquals(MessageFormatUtil.format(CommonsExceptionMessageConstant.PATTERN_CONTAINS_UNEXPECTED_COMPONENT, "y"), + Assertions.assertEquals(MessageFormatUtil.format(CommonsExceptionMessageConstant.PATTERN_CONTAINS_UNEXPECTED_COMPONENT, "y"), exception.getMessage()); } } diff --git a/commons/src/test/java/com/itextpdf/commons/actions/producer/ProducerBuilderTest.java b/commons/src/test/java/com/itextpdf/commons/actions/producer/ProducerBuilderTest.java index 90083ad7a5..386a532b32 100644 --- a/commons/src/test/java/com/itextpdf/commons/actions/producer/ProducerBuilderTest.java +++ b/commons/src/test/java/com/itextpdf/commons/actions/producer/ProducerBuilderTest.java @@ -35,31 +35,30 @@ This file is part of the iText (R) project. import com.itextpdf.test.LogLevelConstants; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.UnitTest; import java.util.ArrayList; import java.util.Collections; import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class ProducerBuilderTest extends ExtendedITextTest { @Test public void emptyEventsProducerLineTest() { - Exception exception = Assert.assertThrows(IllegalArgumentException.class, + Exception exception = Assertions.assertThrows(IllegalArgumentException.class, () -> ProducerBuilder.modifyProducer(Collections.emptyList(), null)); - Assert.assertEquals(CommonsExceptionMessageConstant.NO_EVENTS_WERE_REGISTERED_FOR_THE_DOCUMENT, + Assertions.assertEquals(CommonsExceptionMessageConstant.NO_EVENTS_WERE_REGISTERED_FOR_THE_DOCUMENT, exception.getMessage()); } @Test public void nullEventsProducerLineTest() { - Exception exception = Assert.assertThrows(IllegalArgumentException.class, + Exception exception = Assertions.assertThrows(IllegalArgumentException.class, () -> ProducerBuilder.modifyProducer((List)null, null)); - Assert.assertEquals(CommonsExceptionMessageConstant.NO_EVENTS_WERE_REGISTERED_FOR_THE_DOCUMENT, + Assertions.assertEquals(CommonsExceptionMessageConstant.NO_EVENTS_WERE_REGISTERED_FOR_THE_DOCUMENT, exception.getMessage()); } @@ -68,7 +67,7 @@ public void plainTextNewProducerLineTest() { List events = getEvents("Plain Text", 1, 2, 3); String newProducerLine = ProducerBuilder.modifyProducer(events, null); - Assert.assertEquals("Plain Text", newProducerLine); + Assertions.assertEquals("Plain Text", newProducerLine); } @Test @@ -76,7 +75,7 @@ public void plainTextEmptyOldProducerLineTest() { List events = getEvents("Plain Text", 1, 2, 3); String newProducerLine = ProducerBuilder.modifyProducer(events, ""); - Assert.assertEquals("Plain Text", newProducerLine); + Assertions.assertEquals("Plain Text", newProducerLine); } @Test @@ -84,7 +83,7 @@ public void plainTextExistingOldProducerLineTest() { List events = getEvents("Plain Text", 1, 2, 3); String newProducerLine = ProducerBuilder.modifyProducer(events, "Old producer"); - Assert.assertEquals("Old producer; modified using Plain Text", newProducerLine); + Assertions.assertEquals("Old producer; modified using Plain Text", newProducerLine); } @Test @@ -92,7 +91,7 @@ public void plainTextExistingOldProducerWithModifiedPartLineTest() { List events = getEvents("New Author", 1, 2, 3); String newProducerLine = ProducerBuilder.modifyProducer(events, "Old producer; modified using Plain Text"); - Assert.assertEquals("Old producer; modified using Plain Text; modified using New Author", newProducerLine); + Assertions.assertEquals("Old producer; modified using Plain Text; modified using New Author", newProducerLine); } @@ -101,7 +100,7 @@ public void copyrightSinceProducerLineTest() { List events = getEvents("Prod. since ${copyrightSince}", 1, 2, 3); String newProducerLine = ProducerBuilder.modifyProducer(events, null); - Assert.assertEquals("Prod. since 1901", newProducerLine); + Assertions.assertEquals("Prod. since 1901", newProducerLine); } @Test @@ -109,7 +108,7 @@ public void copyrightToProducerLineTest() { List events = getEvents("All rights reserved, ${copyrightTo}", 1, 2, 3); String newProducerLine = ProducerBuilder.modifyProducer(events, null); - Assert.assertEquals("All rights reserved, 2103", newProducerLine); + Assertions.assertEquals("All rights reserved, 2103", newProducerLine); } @Test @@ -117,7 +116,7 @@ public void currentDateProducerLineTest() { List events = getEvents("Created at ${currentDate:yyyy}", 1, 2, 3); String newProducerLine = ProducerBuilder.modifyProducer(events, null); - Assert.assertEquals("Created at " + DateTimeUtil.format(DateTimeUtil.getCurrentTimeDate(), "yyyy"), newProducerLine); + Assertions.assertEquals("Created at " + DateTimeUtil.format(DateTimeUtil.getCurrentTimeDate(), "yyyy"), newProducerLine); } @Test @@ -126,7 +125,7 @@ public void currentDateComplexFormatProducerLineTest() { String newProducerLine = ProducerBuilder.modifyProducer(events, null); String currentYear = DateTimeUtil.format(DateTimeUtil.getCurrentTimeDate(), "yyyy"); - Assert.assertEquals("Created at " + currentYear + ", {'yes::yes', " + currentYear, newProducerLine); + Assertions.assertEquals("Created at " + currentYear + ", {'yes::yes', " + currentYear, newProducerLine); } @Test @@ -134,15 +133,15 @@ public void currentDatePlaceholderFormatProducerLineTest() { List events = getEvents("Created at ${currentDate:'${currentDate'}", 1, 2, 3); String newProducerLine = ProducerBuilder.modifyProducer(events, null); - Assert.assertEquals("Created at ${currentDate", newProducerLine); + Assertions.assertEquals("Created at ${currentDate", newProducerLine); } @Test public void currentDateNoFormatProducerLineTest() { List events = getEvents("Created at ${currentDate}", 1, 2, 3); - Exception exception = Assert.assertThrows(IllegalArgumentException.class, + Exception exception = Assertions.assertThrows(IllegalArgumentException.class, () -> ProducerBuilder.modifyProducer(events, null)); - Assert.assertEquals(MessageFormatUtil.format(CommonsExceptionMessageConstant.INVALID_USAGE_FORMAT_REQUIRED, "currentDate"), + Assertions.assertEquals(MessageFormatUtil.format(CommonsExceptionMessageConstant.INVALID_USAGE_FORMAT_REQUIRED, "currentDate"), exception.getMessage()); } @@ -151,7 +150,7 @@ public void currentDateEmptyFormatProducerLineTest() { List events = getEvents("Created at ${currentDate:}", 1, 2, 3); String newProducerLine = ProducerBuilder.modifyProducer(events, null); - Assert.assertEquals("Created at ", newProducerLine); + Assertions.assertEquals("Created at ", newProducerLine); } @Test @@ -159,7 +158,7 @@ public void usedProductsProducerLineTest() { List events = getEvents("Used products: ${usedProducts:P #V (T 'version')}", 1, 2, 3); String newProducerLine = ProducerBuilder.modifyProducer(events, null); - Assert.assertEquals( + Assertions.assertEquals( "Used products: product1 #1.0 (type1 version), product2 #2.0 (type2 version), product3 #3.0 (type3 version)", newProducerLine); } @@ -167,9 +166,9 @@ public void usedProductsProducerLineTest() { @Test public void usedProductsEmptyFormatProducerLineTest() { List events = getEvents("Used products: ${usedProducts}", 1, 2, 3); - Exception exception = Assert.assertThrows(IllegalArgumentException.class, + Exception exception = Assertions.assertThrows(IllegalArgumentException.class, () -> ProducerBuilder.modifyProducer(events, null)); - Assert.assertEquals(MessageFormatUtil.format(CommonsExceptionMessageConstant.INVALID_USAGE_FORMAT_REQUIRED, "usedProducts"), + Assertions.assertEquals(MessageFormatUtil.format(CommonsExceptionMessageConstant.INVALID_USAGE_FORMAT_REQUIRED, "usedProducts"), exception.getMessage()); } @@ -182,7 +181,7 @@ public void unknownPlaceHoldersTest() { getEvents("${plchldr}|${plchldrWithParam:param}|${plchldrWithWeirdParam::$$:'''\\''}", 1, 2, 3); String newProducerLine = ProducerBuilder.modifyProducer(events, null); - Assert.assertEquals("||", newProducerLine); + Assertions.assertEquals("||", newProducerLine); } @Test @@ -191,7 +190,7 @@ public void modifiedUsingEqualsCurrentProducerTest() { String newProducerLine = ProducerBuilder.modifyProducer(events , "Old producer; modified using some Author"); - Assert.assertEquals("Old producer; modified using some Author", newProducerLine); + Assertions.assertEquals("Old producer; modified using some Author", newProducerLine); } @Test @@ -200,7 +199,7 @@ public void prevModifiedUsingEqualsCurrentProducerTest() { String newProducerLine = ProducerBuilder.modifyProducer(events , "Old producer; modified using some Author; modified using another tool"); - Assert.assertEquals("Old producer; modified using some Author; modified using another tool; " + + Assertions.assertEquals("Old producer; modified using some Author; modified using another tool; " + "modified using some Author", newProducerLine); } @@ -210,7 +209,7 @@ public void severalModifiedUsingEqualsCurrentProducerTest() { String newProducerLine = ProducerBuilder.modifyProducer(events , "Old producer; modified using some Author; modified using some Author"); - Assert.assertEquals("Old producer; modified using some Author; modified using some Author", newProducerLine); + Assertions.assertEquals("Old producer; modified using some Author; modified using some Author", newProducerLine); } @Test @@ -218,7 +217,7 @@ public void oldProducerEqualsCurrentProducerTest() { List events = getEvents("some Author", 1, 2, 3); String newProducerLine = ProducerBuilder.modifyProducer(events, "some Author"); - Assert.assertEquals("some Author", newProducerLine); + Assertions.assertEquals("some Author", newProducerLine); } private List getEvents(String initialProducerLine, int ... indexes) { diff --git a/commons/src/test/java/com/itextpdf/commons/actions/producer/UsedProductsPlaceholderPopulatorTest.java b/commons/src/test/java/com/itextpdf/commons/actions/producer/UsedProductsPlaceholderPopulatorTest.java index 7004ffebf0..97ee787aa7 100644 --- a/commons/src/test/java/com/itextpdf/commons/actions/producer/UsedProductsPlaceholderPopulatorTest.java +++ b/commons/src/test/java/com/itextpdf/commons/actions/producer/UsedProductsPlaceholderPopulatorTest.java @@ -29,98 +29,97 @@ This file is part of the iText (R) project. import com.itextpdf.commons.exceptions.CommonsExceptionMessageConstant; import com.itextpdf.commons.utils.MessageFormatUtil; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class UsedProductsPlaceholderPopulatorTest extends ExtendedITextTest { private final UsedProductsPlaceholderPopulator populator = new UsedProductsPlaceholderPopulator(); @Test public void nullTest() { - Exception exception = Assert.assertThrows(IllegalArgumentException.class, + Exception exception = Assertions.assertThrows(IllegalArgumentException.class, () -> populator.populate(getEvents(1), null)); - Assert.assertEquals(MessageFormatUtil.format(CommonsExceptionMessageConstant.INVALID_USAGE_FORMAT_REQUIRED, "usedProducts"), + Assertions.assertEquals(MessageFormatUtil.format(CommonsExceptionMessageConstant.INVALID_USAGE_FORMAT_REQUIRED, "usedProducts"), exception.getMessage()); } @Test public void plainTextTest() { String result = populator.populate(getEvents(0), "'plain text'"); - Assert.assertEquals("plain text", result); + Assertions.assertEquals("plain text", result); } @Test public void plainTextMultipleEventsMergedTest() { String result = populator.populate(getEvents(1, 2, 3, 4), "'plain text'"); - Assert.assertEquals("plain text", result); + Assertions.assertEquals("plain text", result); } @Test public void productNameOneEventTest() { String result = populator.populate(getEvents(0), "P"); - Assert.assertEquals("product0", result); + Assertions.assertEquals("product0", result); } @Test public void productNameSeveralEventsTest() { String result = populator.populate(getEvents(0, 1, 2), "P"); - Assert.assertEquals("product0, product1, product2", result); + Assertions.assertEquals("product0, product1, product2", result); } @Test public void sameProductsMergedTest() { String result = populator.populate(getEvents(0, 1, 0, 1, 2), "P"); - Assert.assertEquals("product0, product1, product2", result); + Assertions.assertEquals("product0, product1, product2", result); } @Test public void versionOneEventTest() { String result = populator.populate(getEvents(1), "V"); - Assert.assertEquals("1.0", result); + Assertions.assertEquals("1.0", result); } @Test public void versionSeveralEventsTest() { String result = populator.populate(getEvents(1, 2, 3), "V"); - Assert.assertEquals("1.0, 2.0, 3.0", result); + Assertions.assertEquals("1.0, 2.0, 3.0", result); } @Test public void sameVersionsMergedTest() { String result = populator.populate(getEvents(1, 2, 1, 2, 3), "V"); - Assert.assertEquals("1.0, 2.0, 3.0", result); + Assertions.assertEquals("1.0, 2.0, 3.0", result); } @Test public void typeOneEventTest() { String result = populator.populate(getEvents(1), "T"); - Assert.assertEquals("type1", result); + Assertions.assertEquals("type1", result); } @Test public void typeSeveralEventsTest() { String result = populator.populate(getEvents(1, 2, 3), "T"); - Assert.assertEquals("type1, type2, type3", result); + Assertions.assertEquals("type1, type2, type3", result); } @Test public void sameTypesMergedTest() { String result = populator.populate(getEvents(1, 2, 1, 2, 3), "T"); - Assert.assertEquals("type1, type2, type3", result); + Assertions.assertEquals("type1, type2, type3", result); } @Test public void complexFormatTest() { String result = populator.populate(getEvents(1, 2, 1, 2, 3), "'module:'P #V (T)"); - Assert.assertEquals("module:product1 #1.0 (type1), module:product2 #2.0 (type2), module:product3 #3.0 (type3)", result); + Assertions.assertEquals("module:product1 #1.0 (type1), module:product2 #2.0 (type2), module:product3 #3.0 (type3)", result); } @Test @@ -130,14 +129,14 @@ public void humanReadableNormalizationTest() { new ITextTestEvent(new SequenceId(), productData, null, "testing"), "nonproduction", "iText product"); String result = populator.populate(Arrays.asList(event), "'module:'P #V (T)"); - Assert.assertEquals("module:public-name #1.0.0 (non-production)", result); + Assertions.assertEquals("module:public-name #1.0.0 (non-production)", result); } @Test public void invalidLetterFormatTest() { - Exception exception = Assert.assertThrows(IllegalArgumentException.class, + Exception exception = Assertions.assertThrows(IllegalArgumentException.class, () -> populator.populate(getEvents(1), "PVTX")); - Assert.assertEquals( + Assertions.assertEquals( MessageFormatUtil.format(CommonsExceptionMessageConstant.PATTERN_CONTAINS_UNEXPECTED_CHARACTER, "X"), exception.getMessage()); } diff --git a/commons/src/test/java/com/itextpdf/commons/actions/sequence/SequenceIdManagerTest.java b/commons/src/test/java/com/itextpdf/commons/actions/sequence/SequenceIdManagerTest.java index ec8031bbe0..f09218a91e 100644 --- a/commons/src/test/java/com/itextpdf/commons/actions/sequence/SequenceIdManagerTest.java +++ b/commons/src/test/java/com/itextpdf/commons/actions/sequence/SequenceIdManagerTest.java @@ -25,23 +25,22 @@ This file is part of the iText (R) project. import com.itextpdf.commons.exceptions.CommonsExceptionMessageConstant; import com.itextpdf.commons.utils.MessageFormatUtil; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class SequenceIdManagerTest extends ExtendedITextTest { @Test public void setIdentifier() { IdentifiableElement element = new IdentifiableElement(); - Assert.assertNull(SequenceIdManager.getSequenceId(element)); + Assertions.assertNull(SequenceIdManager.getSequenceId(element)); SequenceId sequenceId = new SequenceId(); SequenceIdManager.setSequenceId(element, sequenceId); - Assert.assertEquals(sequenceId, SequenceIdManager.getSequenceId(element)); + Assertions.assertEquals(sequenceId, SequenceIdManager.getSequenceId(element)); } @Test @@ -51,10 +50,10 @@ public void overrideIdentifierTest() { SequenceId sequenceId2 = new SequenceId(); SequenceIdManager.setSequenceId(element, sequenceId1); - Exception e = Assert.assertThrows(IllegalStateException.class, + Exception e = Assertions.assertThrows(IllegalStateException.class, () -> SequenceIdManager.setSequenceId(element, sequenceId2)); - Assert.assertEquals(MessageFormatUtil.format(CommonsExceptionMessageConstant.ELEMENT_ALREADY_HAS_IDENTIFIER, + Assertions.assertEquals(MessageFormatUtil.format(CommonsExceptionMessageConstant.ELEMENT_ALREADY_HAS_IDENTIFIER, sequenceId1.getId(), sequenceId2.getId()), e.getMessage()); } diff --git a/commons/src/test/java/com/itextpdf/commons/actions/sequence/SequenceIdTest.java b/commons/src/test/java/com/itextpdf/commons/actions/sequence/SequenceIdTest.java index ab29afe153..18db11bf30 100644 --- a/commons/src/test/java/com/itextpdf/commons/actions/sequence/SequenceIdTest.java +++ b/commons/src/test/java/com/itextpdf/commons/actions/sequence/SequenceIdTest.java @@ -23,19 +23,18 @@ This file is part of the iText (R) project. package com.itextpdf.commons.actions.sequence; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class SequenceIdTest extends ExtendedITextTest { @Test public void differentIdsCreatedTest() { SequenceId sequenceId1 = new SequenceId(); SequenceId sequenceId2 = new SequenceId(); - Assert.assertNotEquals(sequenceId1.getId(), sequenceId2.getId()); + Assertions.assertNotEquals(sequenceId1.getId(), sequenceId2.getId()); } } diff --git a/commons/src/test/java/com/itextpdf/commons/datastructures/BiMapTest.java b/commons/src/test/java/com/itextpdf/commons/datastructures/BiMapTest.java index b91adcede4..74a270be41 100644 --- a/commons/src/test/java/com/itextpdf/commons/datastructures/BiMapTest.java +++ b/commons/src/test/java/com/itextpdf/commons/datastructures/BiMapTest.java @@ -23,33 +23,32 @@ This file is part of the iText (R) project. package com.itextpdf.commons.datastructures; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class BiMapTest extends ExtendedITextTest { @Test public void sizeTest01() { BiMap map = new BiMap(); - Assert.assertEquals(0, map.size()); + Assertions.assertEquals(0, map.size()); } @Test public void sizeTest02() { BiMap map = new BiMap(); map.put("a", 1); - Assert.assertEquals(1, map.size()); + Assertions.assertEquals(1, map.size()); } @Test public void isEmptyTest01() { BiMap map = new BiMap(); map.put("a", 1); - Assert.assertFalse(map.isEmpty()); + Assertions.assertFalse(map.isEmpty()); } @@ -57,8 +56,8 @@ public void isEmptyTest01() { public void putTest() { BiMap map = new BiMap(); map.put("a", 1); - Assert.assertEquals(1, (int) map.getByKey("a")); - Assert.assertEquals("a", map.getByValue(1)); + Assertions.assertEquals(1, (int) map.getByKey("a")); + Assertions.assertEquals("a", map.getByValue(1)); } @Test @@ -66,8 +65,8 @@ public void putOnExistingKey() { BiMap map = new BiMap(); map.put("a", 1); map.put("a", 2); - Assert.assertEquals(2, (int) map.getByKey("a")); - Assert.assertEquals("a", map.getByValue(2)); + Assertions.assertEquals(2, (int) map.getByKey("a")); + Assertions.assertEquals("a", map.getByValue(2)); } @Test @@ -75,8 +74,8 @@ public void putOnExistingValue() { BiMap map = new BiMap(); map.put("a", 1); map.put("b", 1); - Assert.assertEquals(1, (int) map.getByKey("b")); - Assert.assertEquals("b", map.getByValue(1)); + Assertions.assertEquals(1, (int) map.getByKey("b")); + Assertions.assertEquals("b", map.getByValue(1)); } @Test @@ -84,8 +83,8 @@ public void putOnExistingKeyAndValue() { BiMap map = new BiMap(); map.put("a", 1); map.put("a", 1); - Assert.assertEquals(1, (int) map.getByKey("a")); - Assert.assertEquals("a", map.getByValue(1)); + Assertions.assertEquals(1, (int) map.getByKey("a")); + Assertions.assertEquals("a", map.getByValue(1)); } @Test @@ -94,13 +93,13 @@ public void putMultipleValues() { map.put("a", 1); map.put("b", 2); map.put("c", 3); - Assert.assertEquals(1, (int) map.getByKey("a")); - Assert.assertEquals("a", map.getByValue(1)); - Assert.assertEquals(2, (int) map.getByKey("b")); - Assert.assertEquals("b", map.getByValue(2)); - Assert.assertEquals(3, (int) map.getByKey("c")); - Assert.assertEquals("c", map.getByValue(3)); - Assert.assertEquals(3, map.size()); + Assertions.assertEquals(1, (int) map.getByKey("a")); + Assertions.assertEquals("a", map.getByValue(1)); + Assertions.assertEquals(2, (int) map.getByKey("b")); + Assertions.assertEquals("b", map.getByValue(2)); + Assertions.assertEquals(3, (int) map.getByKey("c")); + Assertions.assertEquals("c", map.getByValue(3)); + Assertions.assertEquals(3, map.size()); } @@ -109,35 +108,35 @@ public void clearTest() { BiMap map = new BiMap(); map.put("a", 1); map.clear(); - Assert.assertEquals(0, map.size()); + Assertions.assertEquals(0, map.size()); } @Test public void containsKeyTest() { BiMap map = new BiMap(); map.put("a", 1); - Assert.assertTrue(map.containsKey("a")); + Assertions.assertTrue(map.containsKey("a")); } @Test public void containsValueTest() { BiMap map = new BiMap(); map.put("a", 1); - Assert.assertTrue(map.containsValue(1)); + Assertions.assertTrue(map.containsValue(1)); } @Test public void getByValue() { BiMap map = new BiMap(); map.put("a", 1); - Assert.assertEquals(1, (int) map.getByKey("a")); + Assertions.assertEquals(1, (int) map.getByKey("a")); } @Test public void getByKey() { BiMap map = new BiMap(); map.put("a", 1); - Assert.assertEquals("a", map.getByValue(1)); + Assertions.assertEquals("a", map.getByValue(1)); } @Test @@ -145,7 +144,7 @@ public void removeByKey() { BiMap map = new BiMap(); map.put("a", 1); map.removeByKey("a"); - Assert.assertEquals(0, map.size()); + Assertions.assertEquals(0, map.size()); } @Test @@ -153,7 +152,7 @@ public void removeByValue() { BiMap map = new BiMap(); map.put("a", 1); map.removeByValue(1); - Assert.assertEquals(0, map.size()); + Assertions.assertEquals(0, map.size()); } @Test @@ -161,7 +160,7 @@ public void removeOnEmptyMap() { BiMap map = new BiMap(); map.removeByKey("a"); map.removeByValue(1); - Assert.assertEquals(0, map.size()); + Assertions.assertEquals(0, map.size()); } } diff --git a/commons/src/test/java/com/itextpdf/commons/datastructures/ConcurrentWeakMapTest.java b/commons/src/test/java/com/itextpdf/commons/datastructures/ConcurrentWeakMapTest.java index 8dd99c86a5..ccffedd0f4 100644 --- a/commons/src/test/java/com/itextpdf/commons/datastructures/ConcurrentWeakMapTest.java +++ b/commons/src/test/java/com/itextpdf/commons/datastructures/ConcurrentWeakMapTest.java @@ -23,16 +23,15 @@ This file is part of the iText (R) project. package com.itextpdf.commons.datastructures; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.util.Collection; import java.util.HashMap; import java.util.Map; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class ConcurrentWeakMapTest extends ExtendedITextTest { @Test public void sizeTest() { @@ -41,69 +40,69 @@ public void sizeTest() { map.put(3, 0); map.put(6, 2); map.put(5, 2); - Assert.assertEquals(3, map.size()); + Assertions.assertEquals(3, map.size()); } @Test public void isEmptyMapNotEmptyTest() { ConcurrentWeakMap map = new ConcurrentWeakMap<>(); map.put(5, 6); - Assert.assertFalse(map.isEmpty()); + Assertions.assertFalse(map.isEmpty()); } @Test public void isEmptyMapEmptyTest() { ConcurrentWeakMap map = new ConcurrentWeakMap<>(); - Assert.assertTrue(map.isEmpty()); + Assertions.assertTrue(map.isEmpty()); } @Test public void containsKeyTrueTest() { ConcurrentWeakMap map = new ConcurrentWeakMap<>(); map.put(5, 6); - Assert.assertTrue(map.containsKey(5)); + Assertions.assertTrue(map.containsKey(5)); } @Test public void containsKeyFalseTest() { ConcurrentWeakMap map = new ConcurrentWeakMap<>(); map.put(5, 6); - Assert.assertFalse(map.containsKey(6)); + Assertions.assertFalse(map.containsKey(6)); } @Test public void containsValueTrueTest() { ConcurrentWeakMap map = new ConcurrentWeakMap<>(); map.put(5, 6); - Assert.assertTrue(map.containsValue(6)); + Assertions.assertTrue(map.containsValue(6)); } @Test public void containsValueFalseTest() { ConcurrentWeakMap map = new ConcurrentWeakMap<>(); map.put(5, 6); - Assert.assertFalse(map.containsValue(5)); + Assertions.assertFalse(map.containsValue(5)); } @Test public void getTest() { ConcurrentWeakMap map = new ConcurrentWeakMap<>(); map.put(5, 6); - Assert.assertEquals(6, (int) map.get(5)); + Assertions.assertEquals(6, (int) map.get(5)); } @Test public void putTest() { ConcurrentWeakMap map = new ConcurrentWeakMap<>(); map.put(5, 6); - Assert.assertEquals(6, (int) map.put(5, 10)); + Assertions.assertEquals(6, (int) map.put(5, 10)); } @Test public void removeTest() { ConcurrentWeakMap map = new ConcurrentWeakMap<>(); map.put(5, 6); - Assert.assertEquals(6, (int) map.remove(5)); + Assertions.assertEquals(6, (int) map.remove(5)); } @Test @@ -118,8 +117,8 @@ public void putAllTest() { map.putAll(anotherMap); - Assert.assertEquals(10, (int) map.get(5)); - Assert.assertEquals(3, map.size()); + Assertions.assertEquals(10, (int) map.get(5)); + Assertions.assertEquals(3, map.size()); } @Test @@ -131,7 +130,7 @@ public void clearTest() { map.clear(); - Assert.assertEquals(0, map.size()); + Assertions.assertEquals(0, map.size()); } @Test @@ -146,7 +145,7 @@ public void keySetTest() { map.putAll(anotherMap); - Assert.assertEquals(anotherMap.keySet(), map.keySet()); + Assertions.assertEquals(anotherMap.keySet(), map.keySet()); } @Test @@ -162,9 +161,9 @@ public void valuesTest() { map.putAll(anotherMap); Collection values = map.values(); - Assert.assertEquals(3, values.size()); - Assert.assertTrue(values.contains(10)); - Assert.assertFalse(values.contains(6)); + Assertions.assertEquals(3, values.size()); + Assertions.assertTrue(values.contains(10)); + Assertions.assertFalse(values.contains(6)); } @Test @@ -179,6 +178,6 @@ public void entrySetTest() { map.putAll(anotherMap); - Assert.assertEquals(anotherMap.entrySet(), map.entrySet()); + Assertions.assertEquals(anotherMap.entrySet(), map.entrySet()); } } diff --git a/commons/src/test/java/com/itextpdf/commons/datastructures/Tuple2Test.java b/commons/src/test/java/com/itextpdf/commons/datastructures/Tuple2Test.java index 884885c6ae..1fc5d83ad0 100644 --- a/commons/src/test/java/com/itextpdf/commons/datastructures/Tuple2Test.java +++ b/commons/src/test/java/com/itextpdf/commons/datastructures/Tuple2Test.java @@ -23,14 +23,13 @@ This file is part of the iText (R) project. package com.itextpdf.commons.datastructures; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; -@Category(UnitTest.class) +@Tag("UnitTest") public class Tuple2Test extends ExtendedITextTest { @Test diff --git a/commons/src/test/java/com/itextpdf/commons/datastructures/portable/NullUnlimitedListTest.java b/commons/src/test/java/com/itextpdf/commons/datastructures/portable/NullUnlimitedListTest.java new file mode 100644 index 0000000000..0dbe8eaedd --- /dev/null +++ b/commons/src/test/java/com/itextpdf/commons/datastructures/portable/NullUnlimitedListTest.java @@ -0,0 +1,239 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.commons.datastructures.portable; + + +import com.itextpdf.commons.datastructures.ISimpleList; +import com.itextpdf.commons.datastructures.NullUnlimitedList; +import com.itextpdf.commons.datastructures.SimpleArrayList; +import com.itextpdf.test.ExtendedITextTest; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +import java.util.ArrayList; +import java.util.List; +import java.util.function.Consumer; + +@Tag("UnitTest") +public class NullUnlimitedListTest extends ExtendedITextTest { + + + @Test + public void nullUnlimitedListAddTest() { + NullUnlimitedList list = new NullUnlimitedList<>(); + list.add("hey"); + list.add("bye"); + Assertions.assertEquals(2, list.size()); + list.add(-1, "hello"); + list.add(3, "goodbye"); + Assertions.assertEquals(2, list.size()); + } + + @Test + public void nullUnlimitedListIndexOfTest() { + NullUnlimitedList list = new NullUnlimitedList<>(); + list.add("hey"); + list.add(null); + list.add("bye"); + list.add(null); + Assertions.assertEquals(4, list.size()); + Assertions.assertEquals(1, list.indexOf(null)); + } + + @Test + public void nullUnlimitedListRemoveTest() { + NullUnlimitedList list = new NullUnlimitedList<>(); + list.add("hey"); + list.add("bye"); + Assertions.assertEquals(2, list.size()); + list.remove(-1); + list.remove(2); + Assertions.assertEquals(2, list.size()); + } + + @Test + public void testIsEmpty() { + NullUnlimitedList list = new NullUnlimitedList<>(); + Assertions.assertTrue(list.isEmpty()); + list.add("hey"); + Assertions.assertFalse(list.isEmpty()); + } + + @Test + public void testSameBehaviour01() { + List>> actionList = new ArrayList<>(); + actionList.add((list) -> list.add("1")); + actionList.add((list) -> list.add(null)); + actionList.add((list) -> list.add("1")); + actionList.add((list) -> list.add("1")); + actionList.add((list) -> Assertions.assertEquals(1, list.indexOf(null))); + + executeActions(actionList); + } + + @Test + public void testSameBehaviour02() { + List>> actionList = new ArrayList<>(); + actionList.add((list) -> list.add("1")); + actionList.add((list) -> list.add(null)); + actionList.add((list) -> list.add("1")); + actionList.add((list) -> list.add("1")); + actionList.add((list) -> Assertions.assertEquals(4, list.size())); + + executeActions(actionList); + } + + @Test + public void testSameBehaviour03() { + List>> actionList = new ArrayList<>(); + actionList.add((list) -> list.add("1")); + actionList.add((list) -> list.add(null)); + actionList.add((list) -> list.add("1")); + actionList.add((list) -> list.add("1")); + actionList.add((list) -> list.add(null)); + actionList.add((list) -> list.set(1, "4")); + actionList.add((list) -> Assertions.assertEquals(list.get(1), "4")); + + executeActions(actionList); + } + + @Test + public void testSameBehaviour04() { + List>> actionList = new ArrayList<>(); + actionList.add((list) -> list.add("1")); + actionList.add((list) -> list.add(null)); + actionList.add((list) -> list.add("1")); + actionList.add((list) -> list.add("1")); + actionList.add((list) -> list.add(null)); + actionList.add((list) -> Assertions.assertEquals(1, list.indexOf(null))); + + executeActions(actionList); + } + + + @Test + public void testSameBehaviour05() { + List>> actionList = new ArrayList<>(); + actionList.add((list) -> list.add("1")); + actionList.add((list) -> list.add("1")); + actionList.add((list) -> list.add("1")); + actionList.add((list) -> list.add("1")); + actionList.add((list) -> list.add("1")); + actionList.add((list) -> Assertions.assertEquals(-1, list.indexOf(null))); + + executeActions(actionList); + } + + @Test + public void testSameBehaviour06() { + List>> actionList = new ArrayList<>(); + actionList.add((list) -> list.add("1")); + actionList.add((list) -> list.add("2")); + actionList.add((list) -> list.add("3")); + actionList.add((list) -> list.add("4")); + actionList.add((list) -> list.add("5")); + actionList.add((list) -> Assertions.assertEquals(4, list.indexOf("5"))); + + executeActions(actionList); + } + + + @Test + public void testSameBehaviour07() { + List>> actionList = new ArrayList<>(); + actionList.add((list) -> list.add("1")); + actionList.add((list) -> list.add("2")); + actionList.add((list) -> list.add("3")); + actionList.add((list) -> list.add("4")); + actionList.add((list) -> list.add("5")); + actionList.add((list) -> Assertions.assertEquals(-1, list.indexOf("6"))); + + executeActions(actionList); + } + + + @Test + public void testSameBehaviour08() { + List>> actionList = new ArrayList<>(); + actionList.add((list) -> list.add("1")); + actionList.add((list) -> list.add("2")); + actionList.add((list) -> list.add("3")); + actionList.add((list) -> list.add("4")); + actionList.add((list) -> list.add(2, "5")); + actionList.add((list) -> Assertions.assertEquals(5, list.size())); + + executeActions(actionList); + } + + @Test + public void testSameBehaviour09() { + List>> actionList = new ArrayList<>(); + actionList.add((list) -> list.add("1")); + actionList.add((list) -> list.add("2")); + actionList.add((list) -> list.add("3")); + actionList.add((list) -> list.add("4")); + actionList.add((list) -> list.set(2, null)); + actionList.add((list) -> Assertions.assertEquals(4, list.size())); + + executeActions(actionList); + } + + @Test + public void testSameBehaviour10() { + List>> actionList = new ArrayList<>(); + actionList.add((list) -> list.add("1")); + actionList.add((list) -> list.add("2")); + actionList.add((list) -> list.add("3")); + actionList.add((list) -> list.add("4")); + actionList.add((list) -> list.remove(2)); + actionList.add((list) -> Assertions.assertEquals(3, list.size())); + + executeActions(actionList); + } + + @Test + public void testSameBehaviour11() { + List>> actionList = new ArrayList<>(); + actionList.add((list) -> Assertions.assertTrue(list.isEmpty())); + actionList.add((list) -> list.add("1")); + actionList.add((list) -> Assertions.assertFalse(list.isEmpty())); + actionList.add((list) -> list.add("2")); + actionList.add((list) -> list.add("3")); + actionList.add((list) -> list.add("4")); + actionList.add((list) -> Assertions.assertFalse(list.isEmpty())); + + executeActions(actionList); + } + + public void executeActions(List>> actionList) { + NullUnlimitedList list = new NullUnlimitedList<>(); + SimpleArrayList list2 = new SimpleArrayList<>(); + for (Consumer> action : actionList) { + action.accept(list); + action.accept(list2); + } + } + + +} \ No newline at end of file diff --git a/commons/src/test/java/com/itextpdf/commons/datastructures/portable/SimpleArrayListTest.java b/commons/src/test/java/com/itextpdf/commons/datastructures/portable/SimpleArrayListTest.java new file mode 100644 index 0000000000..f50377ab61 --- /dev/null +++ b/commons/src/test/java/com/itextpdf/commons/datastructures/portable/SimpleArrayListTest.java @@ -0,0 +1,116 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.commons.datastructures.portable; + +import com.itextpdf.commons.datastructures.SimpleArrayList; +import com.itextpdf.test.ExtendedITextTest; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +@Tag("UnitTest") +public class SimpleArrayListTest extends ExtendedITextTest { + + @Test + public void add01() { + SimpleArrayList list = new SimpleArrayList<>(); + list.add(1); + list.add(2); + list.add(3); + assertEquals(3, list.size()); + assertEquals(1, list.get(0)); + assertEquals(2, list.get(1)); + assertEquals(3, list.get(2)); + } + + @Test + public void add02() { + SimpleArrayList list = new SimpleArrayList<>(); + list.add(1); + list.add(3); + list.add(2, 2); + assertEquals(3, list.size()); + } + + + @Test + public void set01() { + SimpleArrayList list = new SimpleArrayList<>(); + list.add(1); + list.add(2); + list.add(3); + assertEquals(2, list.set(1, 4)); + assertEquals(4, list.get(1)); + } + + + @Test + public void indexOf01() { + SimpleArrayList list = new SimpleArrayList<>(); + list.add(1); + list.add(2); + list.add(3); + assertEquals(0, list.indexOf(1)); + assertEquals(1, list.indexOf(2)); + assertEquals(2, list.indexOf(3)); + } + + @Test + public void remove() { + SimpleArrayList list = new SimpleArrayList<>(); + list.add(1); + list.add(2); + list.add(3); + list.remove(1); + assertEquals(2, list.size()); + assertEquals(1, list.get(0)); + assertEquals(3, list.get(1)); + } + + @Test + public void size() { + SimpleArrayList list = new SimpleArrayList<>(); + list.add(1); + list.add(2); + list.add(3); + assertEquals(3, list.size()); + } + + @Test + public void initializeWithCapacity() { + SimpleArrayList list = new SimpleArrayList<>(20); + list.add(1); + list.add(2); + list.add(3); + assertEquals(3, list.size()); + } + + @Test + public void isEmpty() { + SimpleArrayList list = new SimpleArrayList<>(); + assertTrue(list.isEmpty()); + list.add(1); + assertFalse(list.isEmpty()); + } +} \ No newline at end of file diff --git a/commons/src/test/java/com/itextpdf/commons/exceptions/AggregatedExceptionTest.java b/commons/src/test/java/com/itextpdf/commons/exceptions/AggregatedExceptionTest.java index a6eb0882d8..dcc0c3bdd8 100644 --- a/commons/src/test/java/com/itextpdf/commons/exceptions/AggregatedExceptionTest.java +++ b/commons/src/test/java/com/itextpdf/commons/exceptions/AggregatedExceptionTest.java @@ -23,15 +23,14 @@ This file is part of the iText (R) project. package com.itextpdf.commons.exceptions; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.util.ArrayList; import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class AggregatedExceptionTest extends ExtendedITextTest { @Test @@ -42,8 +41,8 @@ public void aggregatedMessageWithGeneralMessageTest() { exceptions.add(new CustomException("Message 3")); AggregatedException exception = new AggregatedException("General message", exceptions); - Assert.assertEquals(exceptions, exception.getAggregatedExceptions()); - Assert.assertEquals("General message:\n" + Assertions.assertEquals(exceptions, exception.getAggregatedExceptions()); + Assertions.assertEquals("General message:\n" + "0) Message 1\n" + "1) Message 2\n" + "2) Message 3\n", exception.getMessage()); @@ -57,7 +56,7 @@ public void aggregatedMessageWithoutGeneralMessageTest() { exceptions.add(new CustomException("Message 3")); AggregatedException exception = new AggregatedException(exceptions); - Assert.assertEquals("Aggregated message:\n" + Assertions.assertEquals("Aggregated message:\n" + "0) Message 1\n" + "1) Message 2\n" + "2) Message 3\n", exception.getMessage()); diff --git a/commons/src/test/java/com/itextpdf/commons/exceptions/ITextExceptionTest.java b/commons/src/test/java/com/itextpdf/commons/exceptions/ITextExceptionTest.java index 607a8e467e..7627bf8240 100644 --- a/commons/src/test/java/com/itextpdf/commons/exceptions/ITextExceptionTest.java +++ b/commons/src/test/java/com/itextpdf/commons/exceptions/ITextExceptionTest.java @@ -23,37 +23,36 @@ This file is part of the iText (R) project. package com.itextpdf.commons.exceptions; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class ITextExceptionTest extends ExtendedITextTest { @Test public void noParametersConstructorTest() { - Exception exception = Assert.assertThrows(ITextException.class, () -> { + Exception exception = Assertions.assertThrows(ITextException.class, () -> { throw new ITextException(); }); - Assert.assertEquals(CommonsExceptionMessageConstant.UNKNOWN_ITEXT_EXCEPTION, exception.getMessage()); + Assertions.assertEquals(CommonsExceptionMessageConstant.UNKNOWN_ITEXT_EXCEPTION, exception.getMessage()); } @Test public void stringConstructorTest() { - Exception exception = Assert.assertThrows(ITextException.class, () -> { + Exception exception = Assertions.assertThrows(ITextException.class, () -> { throw new ITextException("message"); }); - Assert.assertEquals("message", exception.getMessage()); + Assertions.assertEquals("message", exception.getMessage()); } @Test public void throwableConstructorTest() { RuntimeException cause = new RuntimeException("cause"); - Exception exception = Assert.assertThrows(ITextException.class, () -> { + Exception exception = Assertions.assertThrows(ITextException.class, () -> { throw new ITextException(cause); }); - Assert.assertEquals(CommonsExceptionMessageConstant.UNKNOWN_ITEXT_EXCEPTION, exception.getMessage()); - Assert.assertEquals(cause, exception.getCause()); + Assertions.assertEquals(CommonsExceptionMessageConstant.UNKNOWN_ITEXT_EXCEPTION, exception.getMessage()); + Assertions.assertEquals(cause, exception.getCause()); } } diff --git a/commons/src/test/java/com/itextpdf/commons/utils/Base64Test.java b/commons/src/test/java/com/itextpdf/commons/utils/Base64Test.java index 2e60771e77..fd6052cf90 100644 --- a/commons/src/test/java/com/itextpdf/commons/utils/Base64Test.java +++ b/commons/src/test/java/com/itextpdf/commons/utils/Base64Test.java @@ -23,23 +23,22 @@ This file is part of the iText (R) project. package com.itextpdf.commons.utils; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class Base64Test extends ExtendedITextTest { @Test public void testEncodeObjectForNullObject() { - Assert.assertEquals("rO0ABXA=", Base64.encodeObject(null)); + Assertions.assertEquals("rO0ABXA=", Base64.encodeObject(null)); } @Test public void testDecodeForSourceIsEmptyArray() { - Assert.assertEquals("", Base64.encodeBytes(new byte[] {})); + Assertions.assertEquals("", Base64.encodeBytes(new byte[] {})); } @Test @@ -61,8 +60,8 @@ public void testDecodeForSourceIsEmptyArrayGzip() { String generatedHeader = generatedBase64.substring(startIndexHeader, endIndexHeaderWithoutOsFlag); String generatedFooter = generatedBase64.substring(startIndexFooter, endIndexFooter); - Assert.assertEquals(expectedHeaderWithoutOsFlag, generatedHeader); - Assert.assertEquals(expectedFooter, generatedFooter); + Assertions.assertEquals(expectedHeaderWithoutOsFlag, generatedHeader); + Assertions.assertEquals(expectedFooter, generatedFooter); } } diff --git a/commons/src/test/java/com/itextpdf/commons/utils/DIContainerTest.java b/commons/src/test/java/com/itextpdf/commons/utils/DIContainerTest.java index 56443aaceb..9a85c3307a 100644 --- a/commons/src/test/java/com/itextpdf/commons/utils/DIContainerTest.java +++ b/commons/src/test/java/com/itextpdf/commons/utils/DIContainerTest.java @@ -23,27 +23,26 @@ This file is part of the iText (R) project. package com.itextpdf.commons.utils; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class DIContainerTest extends ExtendedITextTest { @Test public void testGetRegisteredInstance() { DIContainer di = new DIContainer(); di.register(String.class, "hello"); - Assert.assertEquals("hello", di.getInstance(String.class)); + Assertions.assertEquals("hello", di.getInstance(String.class)); } @Test public void testRegisterDefaultInstance() { DIContainer.registerDefault(String.class, () -> "hello"); DIContainer di = new DIContainer(); - Assert.assertEquals("hello", di.getInstance(String.class)); + Assertions.assertEquals("hello", di.getInstance(String.class)); } } diff --git a/commons/src/test/java/com/itextpdf/commons/utils/DateTimeUtilTest.java b/commons/src/test/java/com/itextpdf/commons/utils/DateTimeUtilTest.java index e8f6254d84..148d74c325 100644 --- a/commons/src/test/java/com/itextpdf/commons/utils/DateTimeUtilTest.java +++ b/commons/src/test/java/com/itextpdf/commons/utils/DateTimeUtilTest.java @@ -23,17 +23,16 @@ This file is part of the iText (R) project. package com.itextpdf.commons.utils; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class DateTimeUtilTest extends ExtendedITextTest { private static final double ZERO_DELTA = 1e-6; @@ -43,13 +42,13 @@ public class DateTimeUtilTest extends ExtendedITextTest { public void getCurrentTest() { long nowEpoch = new Date().getTime(); long nowDateTimeUtilEpoch = DateTimeUtil.getCurrentTimeDate().getTime(); - Assert.assertEquals(nowEpoch, nowDateTimeUtilEpoch, ONE_SECOND_DELTA); + Assertions.assertEquals(nowEpoch, nowDateTimeUtilEpoch, ONE_SECOND_DELTA); } @Test public void isInPastTest() { Date date = new Date(1); - Assert.assertTrue(DateTimeUtil.isInPast(date)); + Assertions.assertTrue(DateTimeUtil.isInPast(date)); } @Test @@ -61,28 +60,28 @@ public void parseDateAndGetUtcMillisFromEpochTest() { long offset = DateTimeUtil.getCurrentTimeZoneOffset(date); - Assert.assertEquals(1588636800000d - offset, millisFromEpochTo2020_05_05, ZERO_DELTA); + Assertions.assertEquals(1588636800000d - offset, millisFromEpochTo2020_05_05, ZERO_DELTA); } @Test public void getCalenderForNullDateTest() { Calendar result = DateTimeUtil.getCalendar(null); - Assert.assertNull(result); + Assertions.assertNull(result); } @Test public void getCalenderTest() { Date testDate = DateTimeUtil.getCurrentTimeDate(); Calendar result = DateTimeUtil.getCalendar(testDate); - Assert.assertNotNull(result); - Assert.assertEquals(testDate, result.getTime()); + Assertions.assertNotNull(result); + Assertions.assertEquals(testDate, result.getTime()); } @Test public void addMillisToDateTest() { Date almostCurrentTime = new Date(new Date().getTime() - 2000); long twoSeconds = 2000; - Assert.assertEquals(new Date().getTime(), + Assertions.assertEquals(new Date().getTime(), DateTimeUtil.addMillisToDate(almostCurrentTime, twoSeconds).getTime(), ONE_SECOND_DELTA); } @@ -91,7 +90,7 @@ public void compareUtcMillisFromEpochWithNullParamAndCurrentTimeTest() { double getUtcMillisFromEpochWithNullParam = DateTimeUtil.getUtcMillisFromEpoch(null); double millisFromEpochToCurrentTime = DateTimeUtil.getUtcMillisFromEpoch(DateTimeUtil.getCurrentTimeCalendar()); - Assert.assertEquals(millisFromEpochToCurrentTime, getUtcMillisFromEpochWithNullParam, ONE_SECOND_DELTA); + Assertions.assertEquals(millisFromEpochToCurrentTime, getUtcMillisFromEpochWithNullParam, ONE_SECOND_DELTA); } @Test @@ -101,7 +100,7 @@ public void parseDateAndGetRelativeTimeTest() { long offset = DateTimeUtil.getCurrentTimeZoneOffset(date); - Assert.assertEquals(1588636800000d - offset, relativeTime, ZERO_DELTA); + Assertions.assertEquals(1588636800000d - offset, relativeTime, ZERO_DELTA); } @Test @@ -111,7 +110,7 @@ public void addYearPositiveValueTest () { Date newDate = DateTimeUtil.addYearsToDate(originalDate.getTime(), 5); - Assert.assertEquals(2005, newDate.getYear()); + Assertions.assertEquals(2005, newDate.getYear()); } @Test @@ -121,6 +120,6 @@ public void addYearNegativeValueTest () { Date newDate = DateTimeUtil.addYearsToDate(originalDate.getTime(), -3); - Assert.assertEquals(1997, newDate.getYear()); + Assertions.assertEquals(1997, newDate.getYear()); } } diff --git a/commons/src/test/java/com/itextpdf/commons/utils/FileUtilTest.java b/commons/src/test/java/com/itextpdf/commons/utils/FileUtilTest.java new file mode 100644 index 0000000000..bae409e00a --- /dev/null +++ b/commons/src/test/java/com/itextpdf/commons/utils/FileUtilTest.java @@ -0,0 +1,74 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.commons.utils; + +import com.itextpdf.test.ExtendedITextTest; + +import java.io.File; +import java.io.IOException; +import java.io.OutputStream; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +@Tag("UnitTest") +public class FileUtilTest extends ExtendedITextTest { + + public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/commons/utils/FileUtilTest/"; + + @BeforeAll + public static void beforeClass() { + createOrClearDestinationFolder(DESTINATION_FOLDER); + } + + @Test + public void getBufferedOutputStreamTest() throws IOException { + String filePath = DESTINATION_FOLDER + "bufferedOutput.txt"; + String text = "Hello world!"; + + try (OutputStream out = FileUtil.getBufferedOutputStream(filePath)) { + out.write(text.getBytes(StandardCharsets.UTF_8)); + } + + byte[] resultBytes = Files.readAllBytes(Paths.get(filePath)); + Assertions.assertEquals(text, new String(resultBytes, StandardCharsets.UTF_8)); + } + + @Test + public void getFileOutputStreamTest() throws IOException { + String filePath = DESTINATION_FOLDER + "fileOutput.txt"; + File file = new File(filePath); + String text = "Hello world!"; + + try (OutputStream out = FileUtil.getFileOutputStream(file)) { + out.write(text.getBytes(StandardCharsets.UTF_8)); + } + + byte[] resultBytes = Files.readAllBytes(Paths.get(filePath)); + Assertions.assertEquals(text, new String(resultBytes, StandardCharsets.UTF_8)); + } +} \ No newline at end of file diff --git a/commons/src/test/java/com/itextpdf/commons/utils/JsonUtilTest.java b/commons/src/test/java/com/itextpdf/commons/utils/JsonUtilTest.java index 56191896d1..c4fd95c99f 100644 --- a/commons/src/test/java/com/itextpdf/commons/utils/JsonUtilTest.java +++ b/commons/src/test/java/com/itextpdf/commons/utils/JsonUtilTest.java @@ -27,7 +27,6 @@ This file is part of the iText (R) project. import com.itextpdf.test.LogLevelConstants; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.UnitTest; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.core.type.TypeReference; @@ -42,11 +41,11 @@ This file is part of the iText (R) project. import java.util.LinkedHashMap; import java.util.Map; import java.util.Objects; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class JsonUtilTest extends ExtendedITextTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/commons/utils/JsonUtilTest/"; @@ -61,14 +60,14 @@ public class JsonUtilTest extends ExtendedITextTest { @Test public void utf8CharsetStringTest() { - Assert.assertEquals("\"©\"", JsonUtil.serializeToString("©")); + Assertions.assertEquals("\"©\"", JsonUtil.serializeToString("©")); } @Test public void utf8CharsetStreamTest() throws UnsupportedEncodingException { final ByteArrayOutputStream byteArray = new ByteArrayOutputStream(); JsonUtil.serializeToStream(byteArray, "©"); - Assert.assertEquals("\"©\"", + Assertions.assertEquals("\"©\"", EncodingUtil.convertToString(byteArray.toByteArray(), "UTF-8")); } @@ -80,7 +79,7 @@ public void serializeInstanceWithEnumStringTest() throws IOException { String resultString = JsonUtil.serializeToString(classWithEnum); String cmpString = getJsonStringFromFile(cmp); - Assert.assertTrue(JsonUtil.areTwoJsonObjectEquals(cmpString, resultString)); + Assertions.assertTrue(JsonUtil.areTwoJsonObjectEquals(cmpString, resultString)); } @Test @@ -100,7 +99,7 @@ public void serializeInstanceWithEnumStreamTest() throws IOException { JsonUtil.serializeToStream(serializationResult, createClassWithEnumObject()); serializationResult.flush(); - Assert.assertArrayEquals(baos.toByteArray(), serializationResult.toByteArray()); + Assertions.assertArrayEquals(baos.toByteArray(), serializationResult.toByteArray()); } } @@ -112,7 +111,7 @@ public void serializeToMinimalInstanceWithEnumStringTest() throws IOException { String resultString = JsonUtil.serializeToMinimalString(classWithEnum); String compareString = getJsonStringFromFile(cmp); - Assert.assertTrue(JsonUtil.areTwoJsonObjectEquals(compareString, resultString)); + Assertions.assertTrue(JsonUtil.areTwoJsonObjectEquals(compareString, resultString)); } @Test @@ -132,7 +131,7 @@ public void serializeToMinimalInstanceWithEnumStreamTest() throws IOException { JsonUtil.serializeToMinimalStream(serializationResult, createClassWithEnumObject()); serializationResult.flush(); - Assert.assertArrayEquals(baos.toByteArray(), serializationResult.toByteArray()); + Assertions.assertArrayEquals(baos.toByteArray(), serializationResult.toByteArray()); } } @@ -144,7 +143,7 @@ public void serializeStringWithLineBreakStringTest() throws IOException { String resultString = JsonUtil.serializeToString(stringsForSerialization); String cmpString = getJsonStringFromFile(cmp); - Assert.assertEquals(cmpString,resultString); + Assertions.assertEquals(cmpString,resultString); } @Test @@ -156,7 +155,7 @@ public void serializeStringWithLineBreakStreamTest() throws IOException { ByteArrayOutputStream serializationResult = new ByteArrayOutputStream()) { JsonUtil.serializeToStream(serializationResult, createStringWithLineBreaks()); - Assert.assertArrayEquals(baos.toByteArray(), serializationResult.toByteArray()); + Assertions.assertArrayEquals(baos.toByteArray(), serializationResult.toByteArray()); } } @@ -168,7 +167,7 @@ public void serializeToMinimalStringWithLineBreakStringTest() throws IOException String resultString = JsonUtil.serializeToMinimalString(stringsForSerialization); String cmpString = getJsonStringFromFile(cmp); - Assert.assertEquals(cmpString,resultString); + Assertions.assertEquals(cmpString,resultString); } @Test @@ -180,7 +179,7 @@ public void serializeToMinimalStringWithLineBreakStreamTest() throws IOException ByteArrayOutputStream serializationResult = new ByteArrayOutputStream()) { JsonUtil.serializeToMinimalStream(serializationResult, createStringWithLineBreaks()); - Assert.assertArrayEquals(baos.toByteArray(), serializationResult.toByteArray()); + Assertions.assertArrayEquals(baos.toByteArray(), serializationResult.toByteArray()); } } @@ -192,7 +191,7 @@ public void serializeComplexStructureStringTest() throws IOException { String resultString = JsonUtil.serializeToString(complexStructure); String compareString = getJsonStringFromFile(cmp); - Assert.assertTrue(JsonUtil.areTwoJsonObjectEquals(compareString, resultString)); + Assertions.assertTrue(JsonUtil.areTwoJsonObjectEquals(compareString, resultString)); } @Test @@ -211,8 +210,8 @@ public void serializeComplexStructureStreamTest() throws IOException { ByteArrayOutputStream serializationResult = new ByteArrayOutputStream()) { JsonUtil.serializeToStream(serializationResult, createComplexStructureObject()); - Assert.assertNotEquals(0, serializationResult.size()); - Assert.assertArrayEquals(baos.toByteArray(), serializationResult.toByteArray()); + Assertions.assertNotEquals(0, serializationResult.size()); + Assertions.assertArrayEquals(baos.toByteArray(), serializationResult.toByteArray()); } } @@ -224,7 +223,7 @@ public void serializeToMinimalComplexStructureStringTest() throws IOException { String resultString = JsonUtil.serializeToMinimalString(complexStructure); String compareString = getJsonStringFromFile(cmp); - Assert.assertTrue(JsonUtil.areTwoJsonObjectEquals(compareString, resultString)); + Assertions.assertTrue(JsonUtil.areTwoJsonObjectEquals(compareString, resultString)); } @Test @@ -243,8 +242,8 @@ public void serializeToMinimalComplexStructureStreamTest() throws IOException { ByteArrayOutputStream serializationResult = new ByteArrayOutputStream()) { JsonUtil.serializeToMinimalStream(serializationResult, createComplexStructureObject()); - Assert.assertNotEquals(0, serializationResult.size()); - Assert.assertArrayEquals(baos.toByteArray(), serializationResult.toByteArray()); + Assertions.assertNotEquals(0, serializationResult.size()); + Assertions.assertArrayEquals(baos.toByteArray(), serializationResult.toByteArray()); } } @@ -257,7 +256,7 @@ public void serializeWithNullFieldsStringTest() throws IOException { String resultString = JsonUtil.serializeToString(complexStructure); String compareString = getJsonStringFromFile(cmp); - Assert.assertTrue(JsonUtil.areTwoJsonObjectEquals(compareString, resultString)); + Assertions.assertTrue(JsonUtil.areTwoJsonObjectEquals(compareString, resultString)); } @Test @@ -270,7 +269,7 @@ public void serializeWithNullFieldsStreamTest() throws IOException { JsonUtil.serializeToStream(serializationResult, createClassWithDefaultValueObject(null, 4, null)); - Assert.assertArrayEquals(baos.toByteArray(), serializationResult.toByteArray()); + Assertions.assertArrayEquals(baos.toByteArray(), serializationResult.toByteArray()); } } @@ -283,7 +282,7 @@ public void serializeToMinimalWithNullFieldsStringTest() throws IOException { String resultString = JsonUtil.serializeToMinimalString(complexStructure); String compareString = getJsonStringFromFile(cmp); - Assert.assertTrue(JsonUtil.areTwoJsonObjectEquals(compareString, resultString)); + Assertions.assertTrue(JsonUtil.areTwoJsonObjectEquals(compareString, resultString)); } @Test @@ -296,7 +295,7 @@ public void serializeToMinimalWithNullFieldsStreamTest() throws IOException { JsonUtil.serializeToMinimalStream(serializationResult, createClassWithDefaultValueObject(null, 4, null)); - Assert.assertArrayEquals(baos.toByteArray(), serializationResult.toByteArray()); + Assertions.assertArrayEquals(baos.toByteArray(), serializationResult.toByteArray()); } } @@ -311,7 +310,7 @@ public void deserializeInvalidJsonFileStringTest() throws IOException { String jsonString = getJsonStringFromFile(source); String resultStr = JsonUtil.deserializeFromString(jsonString, String.class); - Assert.assertNull(resultStr); + Assertions.assertNull(resultStr); } @Test @@ -324,7 +323,7 @@ public void deserializeInvalidJsonFileStreamTest() throws IOException { try (InputStream inputStream = FileUtil.getInputStreamForFile(source)) { String resultStr = JsonUtil.deserializeFromStream(inputStream, String.class); - Assert.assertNull(resultStr); + Assertions.assertNull(resultStr); } } @@ -336,7 +335,7 @@ public void deserializeWithDefaultValueStringTest() throws IOException { ClassWithDefaultValue instance = JsonUtil.deserializeFromString(jsonString, ClassWithDefaultValue.class); - Assert.assertEquals(createClassWithDefaultValueObject(null, 2, 5.0), instance); + Assertions.assertEquals(createClassWithDefaultValueObject(null, 2, 5.0), instance); } @Test @@ -346,7 +345,7 @@ public void deserializeWithDefaultValueStreamTest() throws IOException { try (InputStream inputStream = FileUtil.getInputStreamForFile(source)) { ClassWithDefaultValue instance = JsonUtil.deserializeFromStream(inputStream, ClassWithDefaultValue.class); - Assert.assertEquals(createClassWithDefaultValueObject(null, 2, 5.0), instance); + Assertions.assertEquals(createClassWithDefaultValueObject(null, 2, 5.0), instance); } } @@ -359,7 +358,7 @@ public void deserializeComplexStructureStringTest() throws IOException { ComplexStructure complexStructure = JsonUtil.deserializeFromString(jsonString, ComplexStructure.class); - Assert.assertEquals(createComplexStructureObject(), complexStructure); + Assertions.assertEquals(createComplexStructureObject(), complexStructure); } @Test @@ -370,7 +369,7 @@ public void deserializeComplexStructureStreamTest() throws IOException { ComplexStructure complexStructure = JsonUtil.deserializeFromStream(inputStream, ComplexStructure.class); - Assert.assertEquals(createComplexStructureObject(), complexStructure); + Assertions.assertEquals(createComplexStructureObject(), complexStructure); } } @@ -382,7 +381,7 @@ public void deserializeInstanceWithEnumStringTest() throws IOException { ClassWithEnum classWithEnum = JsonUtil.deserializeFromString(jsonString, ClassWithEnum.class); - Assert.assertEquals(createClassWithEnumObject(), classWithEnum); + Assertions.assertEquals(createClassWithEnumObject(), classWithEnum); } @Test @@ -393,7 +392,7 @@ public void deserializeInstanceWithEnumStreamTest() throws IOException { ClassWithEnum classWithEnum = JsonUtil .deserializeFromStream(inputStream, ClassWithEnum.class); - Assert.assertEquals(createClassWithEnumObject(), classWithEnum); + Assertions.assertEquals(createClassWithEnumObject(), classWithEnum); } } @@ -406,7 +405,7 @@ public void deserializeWithUnknownPropertiesStringTest() throws IOException { ClassWithDefaultValue instance = JsonUtil.deserializeFromString(jsonString, ClassWithDefaultValue.class); - Assert.assertEquals( + Assertions.assertEquals( createClassWithDefaultValueObject("some small string", 8, 26.0), instance); } @@ -418,8 +417,8 @@ public void deserializeWithUnknownPropertiesStreamTest() throws IOException { ClassWithDefaultValue instance = JsonUtil.deserializeFromStream(inputStream, ClassWithDefaultValue.class); - Assert.assertNotNull(instance); - Assert.assertEquals( + Assertions.assertNotNull(instance); + Assertions.assertEquals( createClassWithDefaultValueObject("some small string", 8, 26.0), instance); } } @@ -433,7 +432,7 @@ public void deserializeWithDefaultValueTypeReferenceStreamTest() throws IOExcept JsonUtil.deserializeFromStream(inputStream, new TypeReference() { }); - Assert.assertEquals(createClassWithDefaultValueObject(null, 2, 5.0), instance); + Assertions.assertEquals(createClassWithDefaultValueObject(null, 2, 5.0), instance); } } @@ -447,7 +446,7 @@ public void deserializeWithDefaultValueTypeReferenceStringTest() throws IOExcept JsonUtil.deserializeFromString(jsonString, new TypeReference() { }); - Assert.assertEquals(createClassWithDefaultValueObject(null, 2, 5.0), instance); + Assertions.assertEquals(createClassWithDefaultValueObject(null, 2, 5.0), instance); } private String getJsonStringFromFile(String pathToFile) throws IOException { diff --git a/commons/src/test/java/com/itextpdf/commons/utils/MapUtilTest.java b/commons/src/test/java/com/itextpdf/commons/utils/MapUtilTest.java index bfbda31588..e65a6d0994 100644 --- a/commons/src/test/java/com/itextpdf/commons/utils/MapUtilTest.java +++ b/commons/src/test/java/com/itextpdf/commons/utils/MapUtilTest.java @@ -23,33 +23,32 @@ This file is part of the iText (R) project. package com.itextpdf.commons.utils; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.TreeMap; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class MapUtilTest extends ExtendedITextTest { @Test public void nullMapsAreEqualTest() { - Assert.assertTrue(MapUtil.equals(null, null)); + Assertions.assertTrue(MapUtil.equals(null, null)); } @Test public void nullMapIsNotEqualToEmptyMapTest() { - Assert.assertFalse(MapUtil.equals(new HashMap(), null)); - Assert.assertFalse(MapUtil.equals(null, new HashMap())); + Assertions.assertFalse(MapUtil.equals(new HashMap(), null)); + Assertions.assertFalse(MapUtil.equals(null, new HashMap())); } @Test public void mapsOfDifferentTypesAreNotEqualTest() { - Assert.assertFalse(MapUtil.equals(new HashMap(), new TreeMap<>())); + Assertions.assertFalse(MapUtil.equals(new HashMap(), new TreeMap<>())); } @Test @@ -61,7 +60,7 @@ public void mapsOfDifferentSizeAreNotEqualTest() { m2.put("m1", "m1"); m2.put("m2", "m2"); - Assert.assertFalse(MapUtil.equals(m1, m2)); + Assertions.assertFalse(MapUtil.equals(m1, m2)); } @Test @@ -69,7 +68,7 @@ public void nullValueInMapTest() { Map m1 = Collections.singletonMap("nullKey", null); Map m2 = Collections.singletonMap("notNullKey", "notNull"); - Assert.assertFalse(MapUtil.equals(m1, m2)); + Assertions.assertFalse(MapUtil.equals(m1, m2)); } @Test @@ -79,7 +78,7 @@ public void mapsWithDifferentKeysAreNotEqualTest() { Map m2 = new HashMap<>(); m2.put("m2", "value"); - Assert.assertFalse(MapUtil.equals(m1, m2)); + Assertions.assertFalse(MapUtil.equals(m1, m2)); } @Test @@ -89,7 +88,7 @@ public void mapsWithDifferentValuesAreNotEqualTest() { Map m2 = new HashMap<>(); m2.put("key", "m2"); - Assert.assertFalse(MapUtil.equals(m1, m2)); + Assertions.assertFalse(MapUtil.equals(m1, m2)); } @Test @@ -99,33 +98,33 @@ public void equalArraysTest() { Map m2 = new HashMap<>(); m2.put("key", "value"); - Assert.assertTrue(MapUtil.equals(m1, m2)); + Assertions.assertTrue(MapUtil.equals(m1, m2)); } @Test public void putIfNotNullTest() { Map m1 = new HashMap<>(); MapUtil.putIfNotNull(m1, "key", null); - Assert.assertTrue(m1.isEmpty()); + Assertions.assertTrue(m1.isEmpty()); MapUtil.putIfNotNull(m1, "key", "value"); - Assert.assertFalse(m1.isEmpty()); - Assert.assertEquals("value", m1.get("key")); + Assertions.assertFalse(m1.isEmpty()); + Assertions.assertEquals("value", m1.get("key")); } @Test public void nullMapsEqualEqualHashCodeTest() { - Assert.assertEquals(MapUtil.getHashCode((Map)null), MapUtil.getHashCode((Map)null)); + Assertions.assertEquals(MapUtil.getHashCode((Map)null), MapUtil.getHashCode((Map)null)); } @Test public void nullMapEmptyMapDiffHashCodeTest() { - Assert.assertEquals(MapUtil.getHashCode((Map)null), MapUtil.getHashCode(new HashMap())); + Assertions.assertEquals(MapUtil.getHashCode((Map)null), MapUtil.getHashCode(new HashMap())); } @Test public void mapsOfDifferentTypesHashCodeTest() { - Assert.assertEquals(MapUtil.getHashCode(new TreeMap<>()), + Assertions.assertEquals(MapUtil.getHashCode(new TreeMap<>()), MapUtil.getHashCode(new HashMap())); } @@ -136,7 +135,7 @@ public void equalMapsHashCodeTest() { Map m2 = new HashMap<>(); m2.put("key", "value"); - Assert.assertEquals(MapUtil.getHashCode(m1), MapUtil.getHashCode(m2)); + Assertions.assertEquals(MapUtil.getHashCode(m1), MapUtil.getHashCode(m2)); } @Test @@ -156,7 +155,7 @@ public void mapsMergeTest() { expectedMap.put(2, 15); expectedMap.put(3, 10); expectedMap.put(4, 5); - Assert.assertEquals(expectedMap, destination); + Assertions.assertEquals(expectedMap, destination); } @Test @@ -168,6 +167,6 @@ public void sameMapsMergeTest() { Map expectedMap = new HashMap<>(map); MapUtil.merge(map, map, (d, s) -> d + s); - Assert.assertEquals(expectedMap, map); + Assertions.assertEquals(expectedMap, map); } } diff --git a/commons/src/test/java/com/itextpdf/commons/utils/MessageFormatUtilTest.java b/commons/src/test/java/com/itextpdf/commons/utils/MessageFormatUtilTest.java index ac0c823e43..ef9c7a4e20 100644 --- a/commons/src/test/java/com/itextpdf/commons/utils/MessageFormatUtilTest.java +++ b/commons/src/test/java/com/itextpdf/commons/utils/MessageFormatUtilTest.java @@ -26,28 +26,14 @@ This file is part of the iText (R) project. import java.util.Arrays; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(Parameterized.class) -@Category(UnitTest.class) +@Tag("UnitTest") public class MessageFormatUtilTest extends ExtendedITextTest { - private String expectedResult; - private String pattern; - private Object[] arguments; - - public MessageFormatUtilTest(Object expectedResult, Object pattern, Object arguments, Object name) { - this.expectedResult = (String) expectedResult; - this.pattern = (String) pattern; - this.arguments = (Object[]) arguments; - } - - @Parameterized.Parameters(name = "{index}: {3} format: {1}; {0}") public static Iterable dataSource() { return Arrays.asList(new Object[][]{ {"Plain message with params 1 test", "Plain message with params {0} {1}", new Object[]{1, "test"}, "test with simple params"}, @@ -63,8 +49,9 @@ public static Iterable dataSource() { }); } - @Test - public void testFormatting() { - Assert.assertEquals(expectedResult, MessageFormatUtil.format(pattern, arguments)); + @ParameterizedTest(name = "{index}: {3} format: {1}; {0}") + @MethodSource("dataSource") + public void testFormatting(String expectedResult, String pattern, Object[] arguments, String name) { + Assertions.assertEquals(expectedResult, MessageFormatUtil.format(pattern, arguments)); } } diff --git a/commons/src/test/java/com/itextpdf/commons/utils/PlaceHolderTextUtilTest.java b/commons/src/test/java/com/itextpdf/commons/utils/PlaceHolderTextUtilTest.java index 90be7a4a9d..2987324f2d 100644 --- a/commons/src/test/java/com/itextpdf/commons/utils/PlaceHolderTextUtilTest.java +++ b/commons/src/test/java/com/itextpdf/commons/utils/PlaceHolderTextUtilTest.java @@ -24,15 +24,14 @@ This file is part of the iText (R) project. import com.itextpdf.commons.utils.PlaceHolderTextUtil.PlaceHolderTextBy; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; -@Category(UnitTest.class) +@Tag("UnitTest") public class PlaceHolderTextUtilTest extends ExtendedITextTest { @Test diff --git a/commons/src/test/java/com/itextpdf/commons/utils/ProcessInfoTest.java b/commons/src/test/java/com/itextpdf/commons/utils/ProcessInfoTest.java index 67db144d8c..80fe5acc85 100644 --- a/commons/src/test/java/com/itextpdf/commons/utils/ProcessInfoTest.java +++ b/commons/src/test/java/com/itextpdf/commons/utils/ProcessInfoTest.java @@ -23,13 +23,12 @@ This file is part of the iText (R) project. package com.itextpdf.commons.utils; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class ProcessInfoTest extends ExtendedITextTest { @Test @@ -37,7 +36,7 @@ public void getExitCodeTest() { int exitCode = 1; ProcessInfo processInfo = new ProcessInfo(exitCode, null, null); - Assert.assertEquals(exitCode, processInfo.getExitCode()); + Assertions.assertEquals(exitCode, processInfo.getExitCode()); } @Test @@ -45,7 +44,7 @@ public void getProcessStdOutput() { String stdOutput = "output"; ProcessInfo processInfo = new ProcessInfo(0, stdOutput, null); - Assert.assertEquals(stdOutput, processInfo.getProcessStdOutput()); + Assertions.assertEquals(stdOutput, processInfo.getProcessStdOutput()); } @Test @@ -53,6 +52,6 @@ public void getProcessErrOutput() { String stdOutput = "output"; ProcessInfo processInfo = new ProcessInfo(0, null, stdOutput); - Assert.assertEquals(stdOutput, processInfo.getProcessErrOutput()); + Assertions.assertEquals(stdOutput, processInfo.getProcessErrOutput()); } } diff --git a/commons/src/test/java/com/itextpdf/commons/utils/StringUtilTest.java b/commons/src/test/java/com/itextpdf/commons/utils/StringUtilTest.java index 36be14fd17..c91dd10b0a 100644 --- a/commons/src/test/java/com/itextpdf/commons/utils/StringUtilTest.java +++ b/commons/src/test/java/com/itextpdf/commons/utils/StringUtilTest.java @@ -23,17 +23,16 @@ This file is part of the iText (R) project. package com.itextpdf.commons.utils; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.util.regex.Pattern; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; /** * At the moment there is no StringUtil class in Java, but there is one in C# and we are testing */ -@Category(UnitTest.class) +@Tag("UnitTest") public class StringUtilTest extends ExtendedITextTest { private static final char SPLIT_PERIOD = '.'; @@ -50,7 +49,7 @@ public void patternSplitTest01() { String source = "a01aa78ab89b"; String[] expected = new String[] {"a01", "a", "a78", "a", "b89", "b"}; String[] result = pattern.split(source); - Assert.assertArrayEquals(expected, result); + Assertions.assertArrayEquals(expected, result); } @Test @@ -59,7 +58,7 @@ public void patternSplitTest02() { String source = ""; String[] expected = new String[] {""}; String[] result = pattern.split(source); - Assert.assertArrayEquals(expected, result); + Assertions.assertArrayEquals(expected, result); } @Test @@ -68,7 +67,7 @@ public void stringSplitTest01() { String source = "a01aa78ab89b"; String[] expected = new String[] {"a01", "a", "a78", "a", "b89", "b"}; String[] result = source.split("(?=[ab])"); - Assert.assertArrayEquals(expected, result); + Assertions.assertArrayEquals(expected, result); } @Test @@ -76,7 +75,7 @@ public void stringSplitTest02() { String source = ""; String[] expected = new String[] {""}; String[] result = source.split("(?=[ab])"); - Assert.assertArrayEquals(expected, result); + Assertions.assertArrayEquals(expected, result); } @Test @@ -86,14 +85,14 @@ public void splitKeepEmptyParts01() { "" }; String[] result = StringSplitUtil.splitKeepTrailingWhiteSpace(source, SPLIT_PERIOD); - Assert.assertArrayEquals(source.split(String.valueOf(SPLIT_PERIOD)), result); - Assert.assertArrayEquals(expected, result); + Assertions.assertArrayEquals(source.split(String.valueOf(SPLIT_PERIOD)), result); + Assertions.assertArrayEquals(expected, result); } @Test public void splitKeepEmptyParts02() { String source = null; - Assert.assertThrows(Exception.class, + Assertions.assertThrows(Exception.class, () -> StringSplitUtil.splitKeepTrailingWhiteSpace(source, SPLIT_PERIOD)); } @@ -102,7 +101,7 @@ public void splitKeepEmptyParts03() { String source = "test.test1"; String[] expected = new String[] {"test", "test1"}; String[] result = StringSplitUtil.splitKeepTrailingWhiteSpace(source, SPLIT_PERIOD); - Assert.assertArrayEquals(expected, result); + Assertions.assertArrayEquals(expected, result); } @@ -111,7 +110,7 @@ public void splitKeepEmptyParts04() { String source = "test..test1"; String[] expected = new String[] {"test", "", "test1"}; String[] result = StringSplitUtil.splitKeepTrailingWhiteSpace(source, SPLIT_PERIOD); - Assert.assertArrayEquals(expected, result); + Assertions.assertArrayEquals(expected, result); } @Test @@ -119,7 +118,7 @@ public void splitKeepEmptyParts05() { String source = "test...test1"; String[] expected = new String[] {"test", "", "", "test1"}; String[] result = StringSplitUtil.splitKeepTrailingWhiteSpace(source, SPLIT_PERIOD); - Assert.assertArrayEquals(expected, result); + Assertions.assertArrayEquals(expected, result); } @Test @@ -127,7 +126,7 @@ public void splitKeepEmptyParts06() { String source = ".test1"; String[] expected = new String[] {"", "test1"}; String[] result = StringSplitUtil.splitKeepTrailingWhiteSpace(source, SPLIT_PERIOD); - Assert.assertArrayEquals(expected, result); + Assertions.assertArrayEquals(expected, result); } @Test @@ -135,7 +134,7 @@ public void splitKeepEmptyPartsDifferentBehaviour01() { String source = "test."; String[] expected = new String[] {"test", ""}; String[] result = StringSplitUtil.splitKeepTrailingWhiteSpace(source, SPLIT_PERIOD); - Assert.assertArrayEquals(expected, result); + Assertions.assertArrayEquals(expected, result); } @Test @@ -143,7 +142,7 @@ public void splitKeepEmptyPartsDifferentBehaviour02() { String source = "test.."; String[] expected = new String[] {"test", "", ""}; String[] result = StringSplitUtil.splitKeepTrailingWhiteSpace(source, SPLIT_PERIOD); - Assert.assertArrayEquals(expected, result); + Assertions.assertArrayEquals(expected, result); } } diff --git a/commons/src/test/java/com/itextpdf/commons/utils/SystemUtilTest.java b/commons/src/test/java/com/itextpdf/commons/utils/SystemUtilTest.java index 0c33087e8d..3d0b979506 100644 --- a/commons/src/test/java/com/itextpdf/commons/utils/SystemUtilTest.java +++ b/commons/src/test/java/com/itextpdf/commons/utils/SystemUtilTest.java @@ -23,7 +23,6 @@ This file is part of the iText (R) project. package com.itextpdf.commons.utils; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -33,12 +32,12 @@ This file is part of the iText (R) project. import java.util.Arrays; import java.util.Collections; import java.util.List; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class SystemUtilTest extends ExtendedITextTest { private static final String MAGICK_COMPARE_ENVIRONMENT_VARIABLE = "ITEXT_MAGICK_COMPARE_EXEC"; private static final String MAGICK_COMPARE_ENVIRONMENT_VARIABLE_LEGACY = "compareExec"; @@ -50,7 +49,7 @@ public class SystemUtilTest extends ExtendedITextTest { // This is empty file that used to check the logic for existed execution file private final static String STUB_EXEC_FILE = SOURCE_FOLDER + "folder with space/stubFile"; - @Before + @BeforeEach public void setUp() { createOrClearDestinationFolder(DESTINATION_FOLDER); } @@ -58,7 +57,7 @@ public void setUp() { @Test public void prepareProcessArgumentsStubExecFileTest() { List processArguments = SystemUtil.prepareProcessArguments(STUB_EXEC_FILE, "param1 param2"); - Assert.assertEquals(Arrays.asList( + Assertions.assertEquals(Arrays.asList( "./src/test/resources/com/itextpdf/commons/utils/SystemUtilTest/folder with space/stubFile", "param1", "param2"), processArguments); @@ -68,7 +67,7 @@ public void prepareProcessArgumentsStubExecFileTest() { public void prepareProcessArgumentsStubExecFileInQuotesTest() { String testLine = "\"" + STUB_EXEC_FILE + "\"" + " compare"; List processArguments = SystemUtil.prepareProcessArguments(testLine, "param1 param2"); - Assert.assertEquals(Arrays.asList( + Assertions.assertEquals(Arrays.asList( "./src/test/resources/com/itextpdf/commons/utils/SystemUtilTest/folder with space/stubFile", "compare", "param1", "param2"), processArguments); @@ -77,7 +76,7 @@ public void prepareProcessArgumentsStubExecFileInQuotesTest() { @Test public void prepareProcessArgumentsGsTest() { List processArguments = SystemUtil.prepareProcessArguments("gs", "param1 param2"); - Assert.assertEquals(Arrays.asList( + Assertions.assertEquals(Arrays.asList( "gs", "param1", "param2"), processArguments); } @@ -85,7 +84,7 @@ public void prepareProcessArgumentsGsTest() { @Test public void prepareProcessArgumentsMagickCompareTest() { List processArguments = SystemUtil.prepareProcessArguments("magick compare", "param1 param2"); - Assert.assertEquals(Arrays.asList( + Assertions.assertEquals(Arrays.asList( "magick", "compare", "param1", "param2"), processArguments); } @@ -94,7 +93,7 @@ public void prepareProcessArgumentsMagickCompareTest() { public void splitIntoProcessArgumentsPathInQuotesTest() { List processArguments = SystemUtil .splitIntoProcessArguments("\"C:\\Test directory with spaces\\file.exe\""); - Assert.assertEquals(Collections.singletonList( + Assertions.assertEquals(Collections.singletonList( "C:\\Test directory with spaces\\file.exe"), processArguments); } @@ -103,7 +102,7 @@ public void splitIntoProcessArgumentsPathInQuotesTest() { public void splitIntoProcessArgumentsGsParamsTest() { List processArguments = SystemUtil.splitIntoProcessArguments( " -dSAFER -dNOPAUSE -dBATCH -sDEVICE=png16m -r150 -sOutputFile='./target/test/com/itextpdf/kernel/utils/CompareToolTest/cmp_simple_pdf_with_space .pdf-%03d.png' './src/test/resources/com/itextpdf/kernel/utils/CompareToolTest/cmp_simple_pdf_with_space .pdf'"); - Assert.assertEquals(Arrays.asList( + Assertions.assertEquals(Arrays.asList( "-dSAFER", "-dNOPAUSE", "-dBATCH", "-sDEVICE=png16m", "-r150", "-sOutputFile=./target/test/com/itextpdf/kernel/utils/CompareToolTest/cmp_simple_pdf_with_space .pdf-%03d.png", "./src/test/resources/com/itextpdf/kernel/utils/CompareToolTest/cmp_simple_pdf_with_space .pdf"), @@ -114,7 +113,7 @@ public void splitIntoProcessArgumentsGsParamsTest() { public void splitIntoProcessArgumentsMagickCompareParamsTest() { List processArguments = SystemUtil.splitIntoProcessArguments( "'D:\\itext\\java\\itextcore\\kernel\\.\\target\\test\\com\\itextpdf\\kernel\\utils\\CompareToolTest\\simple_pdf.pdf-001.png' 'D:\\itext\\java\\itextcore\\kernel\\.\\target\\test\\com\\itextpdf\\kernel\\utils\\CompareToolTest\\cmp_simple_pdf_with_space .pdf-001.png' './target/test/com/itextpdf/kernel/utils/CompareToolTest/diff_simple_pdf.pdf_1.png'"); - Assert.assertEquals(Arrays.asList( + Assertions.assertEquals(Arrays.asList( "D:\\itext\\java\\itextcore\\kernel\\.\\target\\test\\com\\itextpdf\\kernel\\utils\\CompareToolTest\\simple_pdf.pdf-001.png", "D:\\itext\\java\\itextcore\\kernel\\.\\target\\test\\com\\itextpdf\\kernel\\utils\\CompareToolTest\\cmp_simple_pdf_with_space .pdf-001.png", "./target/test/com/itextpdf/kernel/utils/CompareToolTest/diff_simple_pdf.pdf_1.png"), @@ -125,14 +124,14 @@ public void splitIntoProcessArgumentsMagickCompareParamsTest() { // There is no similar test in the C# version, since no way was found to test the Process class. public void printProcessErrorsOutputTest() throws IOException { StringBuilder stringBuilder = SystemUtil.printProcessErrorsOutput(new TestProcess()); - Assert.assertEquals("This is error info", stringBuilder.toString()); + Assertions.assertEquals("This is error info", stringBuilder.toString()); } @Test // There is no similar test in the C# version, since no way was found to test the Process class. public void getProcessOutputTest() throws IOException { String result = SystemUtil.getProcessOutput(new TestProcess()); - Assert.assertEquals("This is process info\n" + Assertions.assertEquals("This is process info\n" + "This is error info", result); } @@ -140,7 +139,7 @@ public void getProcessOutputTest() throws IOException { // There is no similar test in the C# version, since no way was found to test the Process class. public void getProcessOutputEmptyTest() throws IOException { String result = SystemUtil.getProcessOutput(new EmptyTestProcess()); - Assert.assertEquals("This is error info", result); + Assertions.assertEquals("This is error info", result); } @Test @@ -162,8 +161,8 @@ public void runProcessAndWaitWithWorkingDirectoryTest() throws IOException, Inte .append(diff).append("'"); boolean result = SystemUtil.runProcessAndWait(imageMagickPath, currCompareParams.toString(), SOURCE_FOLDER); - Assert.assertFalse(result); - Assert.assertTrue(FileUtil.fileExists(diff)); + Assertions.assertFalse(result); + Assertions.assertTrue(FileUtil.fileExists(diff)); } @Test @@ -176,8 +175,8 @@ public void runProcessAndGetProcessInfoTest() throws IOException, InterruptedExc ProcessInfo processInfo = SystemUtil.runProcessAndGetProcessInfo(imageMagickPath,"--version"); - Assert.assertNotNull(processInfo); - Assert.assertEquals(0, processInfo.getExitCode()); + Assertions.assertNotNull(processInfo); + Assertions.assertEquals(0, processInfo.getExitCode()); } diff --git a/commons/src/test/java/com/itextpdf/commons/utils/ZipFileReaderTest.java b/commons/src/test/java/com/itextpdf/commons/utils/ZipFileReaderTest.java index 12e34be2ca..309fa6a3e6 100644 --- a/commons/src/test/java/com/itextpdf/commons/utils/ZipFileReaderTest.java +++ b/commons/src/test/java/com/itextpdf/commons/utils/ZipFileReaderTest.java @@ -27,34 +27,33 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.util.Set; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class ZipFileReaderTest extends ExtendedITextTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/commons/utils/ZipFileReaderTest/"; @Test public void constructorWithNullPathTest() { - Exception ex = Assert.assertThrows(IOException.class, () -> new ZipFileReader(null)); - Assert.assertEquals(CommonsExceptionMessageConstant.FILE_NAME_CAN_NOT_BE_NULL, ex.getMessage()); + Exception ex = Assertions.assertThrows(IOException.class, () -> new ZipFileReader(null)); + Assertions.assertEquals(CommonsExceptionMessageConstant.FILE_NAME_CAN_NOT_BE_NULL, ex.getMessage()); } @Test public void constructorWithInvalidPathTest() { - Assert.assertThrows(Exception.class, () -> new ZipFileReader("invalidPath")); + Assertions.assertThrows(Exception.class, () -> new ZipFileReader("invalidPath")); } @Test public void constructorWithNonZipPathTest() { - Assert.assertThrows(Exception.class, () -> new ZipFileReader(SOURCE_FOLDER + "firstFile.txt")); + Assertions.assertThrows(Exception.class, () -> new ZipFileReader(SOURCE_FOLDER + "firstFile.txt")); } @Test @@ -63,7 +62,7 @@ public void getFileNamesFromEmptyZipTest() throws IOException { try (ZipFileReader fileReader = new ZipFileReader(SOURCE_FOLDER + "emptyZip.zip")) { Set nameSet = fileReader.getFileNames(); - Assert.assertTrue(nameSet.isEmpty()); + Assertions.assertTrue(nameSet.isEmpty()); } } @@ -72,14 +71,14 @@ public void getFileNamesFromZipTest() throws IOException { try (ZipFileReader fileReader = new ZipFileReader(SOURCE_FOLDER + "archive.zip")) { Set nameSet = fileReader.getFileNames(); - Assert.assertNotNull(nameSet); - Assert.assertEquals(6, nameSet.size()); - Assert.assertTrue(nameSet.contains("firstFile.txt")); - Assert.assertTrue(nameSet.contains("secondFile.txt")); - Assert.assertTrue(nameSet.contains("subfolder/thirdFile.txt")); - Assert.assertTrue(nameSet.contains("subfolder/fourthFile.txt")); - Assert.assertTrue(nameSet.contains("subfolder/subsubfolder/fifthFile.txt")); - Assert.assertTrue(nameSet.contains("subfolder/subsubfolder/sixthFile.txt")); + Assertions.assertNotNull(nameSet); + Assertions.assertEquals(6, nameSet.size()); + Assertions.assertTrue(nameSet.contains("firstFile.txt")); + Assertions.assertTrue(nameSet.contains("secondFile.txt")); + Assertions.assertTrue(nameSet.contains("subfolder/thirdFile.txt")); + Assertions.assertTrue(nameSet.contains("subfolder/fourthFile.txt")); + Assertions.assertTrue(nameSet.contains("subfolder/subsubfolder/fifthFile.txt")); + Assertions.assertTrue(nameSet.contains("subfolder/subsubfolder/sixthFile.txt")); } } @@ -91,8 +90,8 @@ public void getFileNamesFromZipBombBySettingThresholdSizeTest() throws IOExcepti fileReader.setThresholdSize(10000); Set nameSet = fileReader.getFileNames(); - Assert.assertNotNull(nameSet); - Assert.assertEquals(0, nameSet.size()); + Assertions.assertNotNull(nameSet); + Assertions.assertEquals(0, nameSet.size()); } } @@ -103,8 +102,8 @@ public void getFileNamesFromZipBombBySettingThresholdRatioTest() throws IOExcept fileReader.setThresholdRatio(5); Set nameSet = fileReader.getFileNames(); - Assert.assertNotNull(nameSet); - Assert.assertEquals(0, nameSet.size()); + Assertions.assertNotNull(nameSet); + Assertions.assertEquals(0, nameSet.size()); } } @@ -115,8 +114,8 @@ public void getFileNamesFromZipBombBySettingThresholdEntriesTest() throws IOExce fileReader.setThresholdEntries(5); Set nameSet = fileReader.getFileNames(); - Assert.assertNotNull(nameSet); - Assert.assertTrue(nameSet.size() <= 5); + Assertions.assertNotNull(nameSet); + Assertions.assertTrue(nameSet.size() <= 5); } } @@ -124,8 +123,8 @@ public void getFileNamesFromZipBombBySettingThresholdEntriesTest() throws IOExce public void readFromZipWithNullPathTest() throws IOException { try (ZipFileReader reader = new ZipFileReader(SOURCE_FOLDER + "archive.zip")) { - Exception ex = Assert.assertThrows(IOException.class, () -> reader.readFromZip(null)); - Assert.assertEquals(CommonsExceptionMessageConstant.FILE_NAME_CAN_NOT_BE_NULL, ex.getMessage()); + Exception ex = Assertions.assertThrows(IOException.class, () -> reader.readFromZip(null)); + Assertions.assertEquals(CommonsExceptionMessageConstant.FILE_NAME_CAN_NOT_BE_NULL, ex.getMessage()); } } @@ -134,8 +133,8 @@ public void readFromZipWithNotExistingPathTest() throws IOException { final String fileName = "name"; try (ZipFileReader reader = new ZipFileReader(SOURCE_FOLDER + "archive.zip")) { - Exception ex = Assert.assertThrows(IOException.class, () -> reader.readFromZip(fileName)); - Assert.assertEquals(MessageFormatUtil + Exception ex = Assertions.assertThrows(IOException.class, () -> reader.readFromZip(fileName)); + Assertions.assertEquals(MessageFormatUtil .format(CommonsExceptionMessageConstant.ZIP_ENTRY_NOT_FOUND, fileName), ex.getMessage()); } } @@ -145,8 +144,8 @@ public void readFromZipWithInvalidPathTest() throws IOException { final String fileName = "thirdFile.txt"; try (ZipFileReader reader = new ZipFileReader(SOURCE_FOLDER + "archive.zip")) { - Exception ex = Assert.assertThrows(IOException.class, () -> reader.readFromZip(fileName)); - Assert.assertEquals(MessageFormatUtil + Exception ex = Assertions.assertThrows(IOException.class, () -> reader.readFromZip(fileName)); + Assertions.assertEquals(MessageFormatUtil .format(CommonsExceptionMessageConstant.ZIP_ENTRY_NOT_FOUND, fileName), ex.getMessage()); } } @@ -156,8 +155,8 @@ public void readFromZipWithPathAtRootTest() throws IOException { try (ZipFileReader reader = new ZipFileReader(SOURCE_FOLDER + "archive.zip"); InputStream inputStream = reader.readFromZip("firstFile.txt")) { - Assert.assertNotNull(inputStream); - Assert.assertEquals("1", convertInputStreamToString(inputStream)); + Assertions.assertNotNull(inputStream); + Assertions.assertEquals("1", convertInputStreamToString(inputStream)); } } @@ -166,8 +165,8 @@ public void readFromZipWithFileInSubFolderTest() throws IOException { try (ZipFileReader reader = new ZipFileReader(SOURCE_FOLDER + "archive.zip"); InputStream inputStream = reader.readFromZip("subfolder/thirdFile.txt")) { - Assert.assertNotNull(inputStream); - Assert.assertEquals("3", convertInputStreamToString(inputStream)); + Assertions.assertNotNull(inputStream); + Assertions.assertEquals("3", convertInputStreamToString(inputStream)); } } @@ -176,8 +175,8 @@ public void readFromZipWithFileInSubSubFolderPathTest() throws IOException { try (ZipFileReader reader = new ZipFileReader(SOURCE_FOLDER + "archive.zip"); InputStream inputStream = reader.readFromZip("subfolder/subsubfolder/fifthFile.txt")) { - Assert.assertNotNull(inputStream); - Assert.assertEquals("5", convertInputStreamToString(inputStream)); + Assertions.assertNotNull(inputStream); + Assertions.assertEquals("5", convertInputStreamToString(inputStream)); } } @@ -185,7 +184,7 @@ public void readFromZipWithFileInSubSubFolderPathTest() throws IOException { public void readFromZipWithClosedReaderTest() throws IOException { ZipFileReader reader = new ZipFileReader(SOURCE_FOLDER + "archive.zip"); reader.close(); - Assert.assertThrows(IllegalStateException.class, + Assertions.assertThrows(IllegalStateException.class, () -> reader.readFromZip("subfolder/subsubfolder/fifthFile.txt")); } diff --git a/commons/src/test/java/com/itextpdf/commons/utils/ZipFileWriterTest.java b/commons/src/test/java/com/itextpdf/commons/utils/ZipFileWriterTest.java index f2fce7fd7b..6dacfac2f2 100644 --- a/commons/src/test/java/com/itextpdf/commons/utils/ZipFileWriterTest.java +++ b/commons/src/test/java/com/itextpdf/commons/utils/ZipFileWriterTest.java @@ -24,7 +24,6 @@ This file is part of the iText (R) project. import com.itextpdf.commons.exceptions.CommonsExceptionMessageConstant; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -34,31 +33,31 @@ This file is part of the iText (R) project. import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.Set; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class ZipFileWriterTest extends ExtendedITextTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/commons/utils/ZipFileWriter/"; private static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/commons/utils/ZipFileWriter/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(DESTINATION_FOLDER); } @Test public void constructorWithNullPathTest() { - Exception ex = Assert.assertThrows(IOException.class, () -> new ZipFileWriter(null)); - Assert.assertEquals(CommonsExceptionMessageConstant.FILE_NAME_CAN_NOT_BE_NULL, ex.getMessage()); + Exception ex = Assertions.assertThrows(IOException.class, () -> new ZipFileWriter(null)); + Assertions.assertEquals(CommonsExceptionMessageConstant.FILE_NAME_CAN_NOT_BE_NULL, ex.getMessage()); } @Test public void constructorWithNotExistingDirsInPathTest() { - Assert.assertThrows(IOException.class, () -> new ZipFileWriter( + Assertions.assertThrows(IOException.class, () -> new ZipFileWriter( DESTINATION_FOLDER + "notExistingDir/archive.zip")); } @@ -67,9 +66,9 @@ public void constructorWithAlreadyExistedFilePathTest() throws IOException { final String fileName = "constructorWithAlreadyExistedFilePath.zip"; FileUtil.copy(SOURCE_FOLDER + fileName, DESTINATION_FOLDER + fileName); - Exception ex = Assert.assertThrows(IOException.class, + Exception ex = Assertions.assertThrows(IOException.class, () -> new ZipFileWriter(DESTINATION_FOLDER + fileName)); - Assert.assertEquals( + Assertions.assertEquals( MessageFormatUtil.format(CommonsExceptionMessageConstant.FILE_NAME_ALREADY_EXIST, DESTINATION_FOLDER + fileName), ex.getMessage()); @@ -80,9 +79,9 @@ public void constructorWithNotZipFileTest() throws IOException { final String fileName = "testFile.txt"; FileUtil.copy(SOURCE_FOLDER + fileName, DESTINATION_FOLDER + fileName); - Exception ex = Assert.assertThrows(IOException.class, + Exception ex = Assertions.assertThrows(IOException.class, () -> new ZipFileWriter(DESTINATION_FOLDER + fileName)); - Assert.assertEquals( + Assertions.assertEquals( MessageFormatUtil.format(CommonsExceptionMessageConstant.FILE_NAME_ALREADY_EXIST, DESTINATION_FOLDER + fileName), ex.getMessage()); } @@ -92,8 +91,8 @@ public void constructorWithDirectoryPathTest() throws IOException { final String pathToDirectory = DESTINATION_FOLDER + "constructorWithDirectoryPath/"; FileUtil.createDirectories(pathToDirectory); - Exception ex = Assert.assertThrows(IOException.class, () -> new ZipFileWriter(pathToDirectory)); - Assert.assertEquals( + Exception ex = Assertions.assertThrows(IOException.class, () -> new ZipFileWriter(pathToDirectory)); + Assertions.assertEquals( MessageFormatUtil.format(CommonsExceptionMessageConstant.FILE_NAME_ALREADY_EXIST, pathToDirectory), ex.getMessage()); } @@ -105,11 +104,11 @@ public void emptyZipCreationTest() throws IOException { ZipFileWriter writer = new ZipFileWriter(pathToFile); writer.close(); - Assert.assertTrue(FileUtil.fileExists(pathToFile)); + Assertions.assertTrue(FileUtil.fileExists(pathToFile)); // We are not using ZipFileWriter in ZipFileReader tests, so we don't have testing cycles here. try (ZipFileReader zip = new ZipFileReader(pathToFile)) { - Assert.assertTrue(zip.getFileNames().isEmpty()); + Assertions.assertTrue(zip.getFileNames().isEmpty()); } } @@ -119,9 +118,9 @@ public void addNullFileEntryTest() throws IOException { final String pathToFile = DESTINATION_FOLDER + "addNullFileEntry.zip"; try (ZipFileWriter writer = new ZipFileWriter(pathToFile)) { - Exception ex = Assert.assertThrows(IOException.class, + Exception ex = Assertions.assertThrows(IOException.class, () -> writer.addEntry("fileName.txt", (File) null)); - Assert.assertEquals(CommonsExceptionMessageConstant.FILE_SHOULD_EXIST, ex.getMessage()); + Assertions.assertEquals(CommonsExceptionMessageConstant.FILE_SHOULD_EXIST, ex.getMessage()); } } @@ -130,7 +129,7 @@ public void addNullFileEntryTest() throws IOException { public void addEntryWithNotExistingFileTest() throws IOException { try (ZipFileWriter writer = new ZipFileWriter( DESTINATION_FOLDER + "addEntryWithNotExistingFile.zip")) { - Assert.assertThrows(IOException.class, + Assertions.assertThrows(IOException.class, () -> writer.addEntry("fileName", new File(SOURCE_FOLDER + "invalidPath"))); } } @@ -141,9 +140,9 @@ public void addNullStreamEntryTest() throws IOException { final String pathToFile = DESTINATION_FOLDER + "addNullStreamEntry.zip"; try (ZipFileWriter writer = new ZipFileWriter(pathToFile)) { - Exception ex = Assert.assertThrows(IOException.class, + Exception ex = Assertions.assertThrows(IOException.class, () -> writer.addEntry("fileName.txt", (InputStream) null)); - Assert.assertEquals(CommonsExceptionMessageConstant.STREAM_CAN_NOT_BE_NULL, ex.getMessage()); + Assertions.assertEquals(CommonsExceptionMessageConstant.STREAM_CAN_NOT_BE_NULL, ex.getMessage()); } } @@ -153,9 +152,9 @@ public void addNullJsonEntryTest() throws IOException { final String pathToFile = DESTINATION_FOLDER + "addNullJsonEntry.zip"; try (ZipFileWriter writer = new ZipFileWriter(pathToFile)) { - Exception ex = Assert.assertThrows(IOException.class, + Exception ex = Assertions.assertThrows(IOException.class, () -> writer.addJsonEntry("fileName.txt", null)); - Assert.assertEquals(CommonsExceptionMessageConstant.JSON_OBJECT_CAN_NOT_BE_NULL, ex.getMessage()); + Assertions.assertEquals(CommonsExceptionMessageConstant.JSON_OBJECT_CAN_NOT_BE_NULL, ex.getMessage()); } } @@ -167,7 +166,7 @@ public void addEntryWhenWriterIsClosedTest() throws IOException { ZipFileWriter writer = new ZipFileWriter(pathToFile); writer.close(); - Assert.assertThrows(Exception.class, + Assertions.assertThrows(Exception.class, () -> writer.addEntry("firstName", new File(SOURCE_FOLDER + "testFile.txt"))); } @@ -186,9 +185,9 @@ public void addTextFileEntryTest() throws IOException { InputStream streamWithFile = FileUtil.getInputStreamForFile(textFilePath)) { Set fileNames = reader.getFileNames(); - Assert.assertEquals(1, fileNames.size()); - Assert.assertTrue(fileNames.contains(fileNameInZip)); - Assert.assertTrue(compareStreams(streamWithFile, streamFromZip)); + Assertions.assertEquals(1, fileNames.size()); + Assertions.assertTrue(fileNames.contains(fileNameInZip)); + Assertions.assertTrue(compareStreams(streamWithFile, streamFromZip)); } } @@ -207,9 +206,9 @@ public void addInputStreamEntryInSubfolderTest() throws IOException { InputStream streamWithFile = FileUtil.getInputStreamForFile(textFilePath)) { Set fileNames = reader.getFileNames(); - Assert.assertEquals(1, fileNames.size()); - Assert.assertTrue(fileNames.contains(fileNameInZip)); - Assert.assertTrue(compareStreams(streamWithFile, streamFromZip)); + Assertions.assertEquals(1, fileNames.size()); + Assertions.assertTrue(fileNames.contains(fileNameInZip)); + Assertions.assertTrue(compareStreams(streamWithFile, streamFromZip)); } } @@ -228,9 +227,9 @@ public void addJsonEntryTest() throws IOException { InputStream compareStream = new ByteArrayInputStream(compareString.getBytes(StandardCharsets.UTF_8))) { Set fileNames = reader.getFileNames(); - Assert.assertEquals(1, fileNames.size()); - Assert.assertTrue(fileNames.contains(fileNameInZip)); - Assert.assertTrue(compareStreams(compareStream, streamFromZip)); + Assertions.assertEquals(1, fileNames.size()); + Assertions.assertTrue(fileNames.contains(fileNameInZip)); + Assertions.assertTrue(compareStreams(compareStream, streamFromZip)); } } @@ -241,7 +240,7 @@ public void addEntryWithSameFilePathTwiceTest() throws IOException { try (ZipFileWriter writer = new ZipFileWriter(pathToFile)) { writer.addJsonEntry(fileNameInZip, "©"); - Assert.assertThrows(IOException.class, () -> writer.addJsonEntry(fileNameInZip, "aaa")); + Assertions.assertThrows(IOException.class, () -> writer.addJsonEntry(fileNameInZip, "aaa")); } } @@ -270,14 +269,14 @@ public void addSeveralEntriesToZipTest() throws IOException { InputStream streamWithJsonFromZip = reader.readFromZip(thirdFileNameInZip); InputStream compareStream = new ByteArrayInputStream(compareString.getBytes(StandardCharsets.UTF_8))) { Set fileNames = reader.getFileNames(); - Assert.assertEquals(3, fileNames.size()); - Assert.assertTrue(fileNames.contains(firstFileNameInZip)); - Assert.assertTrue(fileNames.contains(secondFileNameInZip)); - Assert.assertTrue(fileNames.contains(thirdFileNameInZip)); - - Assert.assertTrue(compareStreams(streamWithFirstFile, streamWithFirstFromZip)); - Assert.assertTrue(compareStreams(streamWithSecondFile, streamWithSecondFromZip)); - Assert.assertTrue(compareStreams(compareStream, streamWithJsonFromZip)); + Assertions.assertEquals(3, fileNames.size()); + Assertions.assertTrue(fileNames.contains(firstFileNameInZip)); + Assertions.assertTrue(fileNames.contains(secondFileNameInZip)); + Assertions.assertTrue(fileNames.contains(thirdFileNameInZip)); + + Assertions.assertTrue(compareStreams(streamWithFirstFile, streamWithFirstFromZip)); + Assertions.assertTrue(compareStreams(streamWithSecondFile, streamWithSecondFromZip)); + Assertions.assertTrue(compareStreams(compareStream, streamWithJsonFromZip)); } } @@ -288,9 +287,9 @@ public void addEntryWithNullFileNameTest() throws IOException { final String firstTextFilePath = SOURCE_FOLDER + "testFile.txt"; try (ZipFileWriter writer = new ZipFileWriter(pathToFile)) { - Exception ex = Assert.assertThrows(IOException.class, + Exception ex = Assertions.assertThrows(IOException.class, () -> writer.addEntry(null, new File(firstTextFilePath))); - Assert.assertEquals(CommonsExceptionMessageConstant.FILE_NAME_SHOULD_BE_UNIQUE, ex.getMessage()); + Assertions.assertEquals(CommonsExceptionMessageConstant.FILE_NAME_SHOULD_BE_UNIQUE, ex.getMessage()); } } diff --git a/font-asian/pom.xml b/font-asian/pom.xml index 3dc53fe68e..6d8c146a42 100644 --- a/font-asian/pom.xml +++ b/font-asian/pom.xml @@ -5,7 +5,7 @@ com.itextpdf root - 8.0.5 + 9.0.0 font-asian diff --git a/forms/pom.xml b/forms/pom.xml index 90525d9823..54ec2d0bff 100644 --- a/forms/pom.xml +++ b/forms/pom.xml @@ -5,7 +5,7 @@ com.itextpdf root - 8.0.5 + 9.0.0 forms diff --git a/forms/src/main/java/com/itextpdf/forms/PdfAcroForm.java b/forms/src/main/java/com/itextpdf/forms/PdfAcroForm.java index 83a0baf4d9..240c60f1b7 100644 --- a/forms/src/main/java/com/itextpdf/forms/PdfAcroForm.java +++ b/forms/src/main/java/com/itextpdf/forms/PdfAcroForm.java @@ -39,7 +39,6 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.geom.AffineTransform; import com.itextpdf.kernel.geom.Point; import com.itextpdf.kernel.geom.Rectangle; -import com.itextpdf.kernel.pdf.IsoKey; import com.itextpdf.kernel.pdf.PdfArray; import com.itextpdf.kernel.pdf.PdfBoolean; import com.itextpdf.kernel.pdf.PdfDictionary; @@ -1232,10 +1231,10 @@ private AffineTransform calcFieldAppTransformToAnnotRect(PdfFormXObject xObject, -Float.MAX_VALUE, -Float.MAX_VALUE, }; for (Point p : transformedAppBoxPoints) { - transformedRectArr[0] = (float) Math.min(transformedRectArr[0], p.x); - transformedRectArr[1] = (float) Math.min(transformedRectArr[1], p.y); - transformedRectArr[2] = (float) Math.max(transformedRectArr[2], p.x); - transformedRectArr[3] = (float) Math.max(transformedRectArr[3], p.y); + transformedRectArr[0] = (float) Math.min(transformedRectArr[0], p.getX()); + transformedRectArr[1] = (float) Math.min(transformedRectArr[1], p.getY()); + transformedRectArr[2] = (float) Math.max(transformedRectArr[2], p.getX()); + transformedRectArr[3] = (float) Math.max(transformedRectArr[3], p.getY()); } transformedRect = new Rectangle(transformedRectArr[0], transformedRectArr[1], transformedRectArr[2] - transformedRectArr[0], transformedRectArr[3] - transformedRectArr[1]); diff --git a/forms/src/main/java/com/itextpdf/forms/fields/AbstractPdfFormField.java b/forms/src/main/java/com/itextpdf/forms/fields/AbstractPdfFormField.java index 16243fa745..e3e77bc005 100644 --- a/forms/src/main/java/com/itextpdf/forms/fields/AbstractPdfFormField.java +++ b/forms/src/main/java/com/itextpdf/forms/fields/AbstractPdfFormField.java @@ -31,8 +31,7 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.colors.DeviceGray; import com.itextpdf.kernel.colors.DeviceRgb; import com.itextpdf.kernel.font.PdfFont; -import com.itextpdf.kernel.pdf.IConformanceLevel; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfConformance; import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfName; @@ -84,13 +83,7 @@ public abstract class AbstractPdfFormField extends PdfObjectWrapper> { */ private final String formFieldName; /** - * Conformance level of the form field. + * Conformance of the form field. */ - private IConformanceLevel conformanceLevel = null; + private PdfConformance conformance = null; /** * Creates builder for {@link PdfFormField} creation. @@ -56,7 +55,7 @@ protected FormFieldBuilder(PdfDocument document, String formFieldName) { this.document = document; this.formFieldName = formFieldName; if (document != null) { - this.conformanceLevel = document.getConformanceLevel(); + this.conformance = document.getConformance(); } } @@ -79,55 +78,23 @@ public String getFormFieldName() { } /** - * Gets conformance level for form field creation. + * Gets conformance for form field creation. * - * @return instance of {@link PdfAConformanceLevel} to be used for form field creation - * @deprecated since 8.0.4 will return {@link IConformanceLevel} in next major release + * @return instance of {@link PdfConformance} to be used for form field creation */ - @Deprecated - public PdfAConformanceLevel getConformanceLevel() { - if (conformanceLevel instanceof PdfAConformanceLevel){ - return (PdfAConformanceLevel) conformanceLevel; - } - return null; + public PdfConformance getConformance() { + return conformance; } /** - * Gets conformance level for form field creation. + * Sets conformance for form field creation. * - * @return instance of {@link IConformanceLevel} to be used for form field creation + * @param conformance Instance of {@link PdfConformance} to be used for form field creation. * - * @deprecated since 8.0.4 will be renamed to getConformanceLevel() - */ - @Deprecated - public IConformanceLevel getGenericConformanceLevel() { - return conformanceLevel; - } - - /** - * Sets conformance level for form field creation. - * - * @param conformanceLevel instance of {@link PdfAConformanceLevel} to be used for form field creation * @return this builder - * - * @deprecated since 8.0.4 conformance level param will change to {@link IConformanceLevel} - */ - @Deprecated - public T setConformanceLevel(PdfAConformanceLevel conformanceLevel) { - this.conformanceLevel = conformanceLevel; - return getThis(); - } - - /** - * Sets conformance level for form field creation. - * - * @param conformanceLevel Instance of {@link IConformanceLevel} to be used for form field creation. - * @return This builder. - * @deprecated since 8.0.4 will be renamed to setConformanceLevel */ - @Deprecated - public T setGenericConformanceLevel(IConformanceLevel conformanceLevel) { - this.conformanceLevel = conformanceLevel; + public T setConformance(PdfConformance conformance) { + this.conformance = conformance; return getThis(); } diff --git a/forms/src/main/java/com/itextpdf/forms/fields/NonTerminalFormFieldBuilder.java b/forms/src/main/java/com/itextpdf/forms/fields/NonTerminalFormFieldBuilder.java index 25303efd71..75b9c0775a 100644 --- a/forms/src/main/java/com/itextpdf/forms/fields/NonTerminalFormFieldBuilder.java +++ b/forms/src/main/java/com/itextpdf/forms/fields/NonTerminalFormFieldBuilder.java @@ -46,7 +46,7 @@ public NonTerminalFormFieldBuilder(PdfDocument document, String formFieldName) { */ public PdfFormField createNonTerminalFormField() { PdfFormField field = PdfFormCreator.createFormField(getDocument()); - field.pdfConformanceLevel = getGenericConformanceLevel(); + field.pdfConformance = getConformance(); field.setFieldName(getFormFieldName()); return field; } diff --git a/forms/src/main/java/com/itextpdf/forms/fields/PdfFormAnnotation.java b/forms/src/main/java/com/itextpdf/forms/fields/PdfFormAnnotation.java index 33cb3d419b..70b2ab3a35 100644 --- a/forms/src/main/java/com/itextpdf/forms/fields/PdfFormAnnotation.java +++ b/forms/src/main/java/com/itextpdf/forms/fields/PdfFormAnnotation.java @@ -161,9 +161,8 @@ public static PdfFormAnnotation makeFormAnnotation(PdfObject pdfObject, PdfDocum } field.makeIndirect(document); - if (document != null && document.getReader() != null - && document.getReader().getPdfAConformanceLevel() != null) { - field.pdfConformanceLevel = document.getReader().getPdfAConformanceLevel(); + if (document != null) { + field.pdfConformance = document.getConformance(); } return field; @@ -422,15 +421,13 @@ public float getBorderWidth() { * @return The edited {@link PdfFormAnnotation}. */ public PdfFormAnnotation setBorderWidth(float borderWidth) { - // Acrobat doesn't support float border width therefore we round it. - int roundedBorderWidth = (int) Math.round(borderWidth); PdfDictionary bs = getWidget().getBorderStyle(); if (bs == null) { bs = new PdfDictionary(); put(PdfName.BS, bs); } - bs.put(PdfName.W, new PdfNumber(roundedBorderWidth)); - this.borderWidth = roundedBorderWidth; + bs.put(PdfName.W, new PdfNumber(borderWidth)); + this.borderWidth = borderWidth; regenerateField(); return this; @@ -446,7 +443,7 @@ public Border getBorder() { Border border = FormBorderFactory.getBorder( this.getWidget().getBorderStyle(), borderWidth, borderColor, backgroundColor); if (border == null && borderWidth > 0 && borderColor != null) { - border = new SolidBorder(borderColor, Math.max(1, borderWidth)); + border = new SolidBorder(borderColor, borderWidth); } return border; } @@ -514,9 +511,9 @@ public PdfFormAnnotation setPage(int pageNum) { *

* Also note that the model element won't be used for annotations for choice form field. * - * @param element model element to set. + * @param element model element to set * - * @return this {@link PdfFormAnnotation}. + * @return this {@link PdfFormAnnotation} */ public PdfFormAnnotation setFormFieldElement(IFormField element) { this.formFieldElement = element; @@ -805,12 +802,15 @@ protected void drawListFormFieldAndSaveAppearance() { return; } + boolean multiselect = parent.getFieldFlag(PdfChoiceFormField.FF_MULTI_SELECT); if (!(formFieldElement instanceof ListBoxField)) { // Create it once and reset properties during each widget regeneration. - formFieldElement = new ListBoxField("", 0, parent.getFieldFlag(PdfChoiceFormField.FF_MULTI_SELECT)); + formFieldElement = new ListBoxField(parent.getPartialFieldName().toUnicodeString(), 0, multiselect); } - formFieldElement.setProperty(FormProperty.FORM_FIELD_MULTIPLE, - parent.getFieldFlag(PdfChoiceFormField.FF_MULTI_SELECT)); + formFieldElement.setProperty(FormProperty.FORM_FIELD_MULTIPLE, multiselect); + ((ListBoxField) formFieldElement).setTopIndex(parent instanceof PdfChoiceFormField && + ((PdfChoiceFormField) parent).getTopIndex() != null ? + ((PdfChoiceFormField) parent).getTopIndex().intValue() : 0); PdfArray indices = getParent().getAsArray(PdfName.I); PdfArray options = parent.getOptions(); @@ -834,13 +834,24 @@ protected void drawListFormFieldAndSaveAppearance() { final boolean selected = indices != null && indices.contains(new PdfNumber(index)); SelectFieldItem existingItem = ((ListBoxField) formFieldElement).getOption(exportValue); if (existingItem == null) { - existingItem = new SelectFieldItem(exportValue, displayValue); + existingItem = displayValue == null ? new SelectFieldItem(exportValue) : + new SelectFieldItem(exportValue, displayValue); ((ListBoxField) formFieldElement).addOption(existingItem); } existingItem.getElement().setProperty(Property.TEXT_ALIGNMENT, parent.getJustification()); existingItem.getElement().setProperty(Property.OVERFLOW_Y, OverflowPropertyValue.VISIBLE); existingItem.getElement().setProperty(Property.OVERFLOW_X, OverflowPropertyValue.VISIBLE); existingItem.getElement().setProperty(FormProperty.FORM_FIELD_SELECTED, selected); + // Workaround for com.itextpdf.forms.form.renderer.SelectFieldListBoxRenderer.applySelectedStyle: + // in HTML rendering mode we want to draw gray background for flattened fields and blue one for interactive, + // but here we temporarily flatten formFieldElement, so blue background property is explicitly set to + // the selected item. We also need to clear background property for not selected items in case field + // is regenerated with modified indices list. + if (selected && (multiselect || index == indices.getAsNumber(indices.size() - 1).intValue())) { + existingItem.getElement().setProperty(Property.BACKGROUND, new Background(new DeviceRgb(169, 204, 225))); + } else { + existingItem.getElement().setProperty(Property.BACKGROUND, null); + } } formFieldElement.setProperty(Property.FONT, getFont()); @@ -884,9 +895,18 @@ protected void drawTextFormFieldAndSaveAppearance() { if (parent.isMultiline()) { formFieldElement.setProperty(Property.FONT_SIZE, UnitValue.createPointValue(getFontSize())); } else { - formFieldElement.setProperty(Property.FONT_SIZE, - UnitValue.createPointValue(getFontSize(new PdfArray(rectangle), parent.getValueAsString()))); + float fontSize = getFontSize(new PdfArray(rectangle), parent.getValueAsString()); + if (fontSize != 0) { + // We want to always draw the text using the given font size even if it's not fit into layout area. + // Without setting this property the height of the drawn field will be 0 which is unexpected. + formFieldElement.setProperty(Property.FORCED_PLACEMENT, true); + } + formFieldElement.setProperty(Property.FONT_SIZE, UnitValue.createPointValue(fontSize)); value = value.replaceAll(LINE_ENDINGS_REGEXP, " "); + ((InputField) formFieldElement).setComb(this.isCombTextFormField()); + ((InputField) formFieldElement).setMaxLen((parent instanceof PdfTextFormField ? (PdfTextFormField) parent : + PdfFormCreator.createTextFormField(parent.getPdfObject())).getMaxLen()); + ((InputField)formFieldElement).useAsPassword(parent.isPassword()); } formFieldElement.setValue(value); formFieldElement.setProperty(Property.FONT, getFont()); @@ -927,7 +947,7 @@ protected void drawComboBoxAndSaveAppearance() { return; } if (!(formFieldElement instanceof ComboBoxField)) { - formFieldElement = new ComboBoxField(""); + formFieldElement = new ComboBoxField(parent.getPartialFieldName().toUnicodeString()); } ComboBoxField comboBoxField = (ComboBoxField) formFieldElement; @@ -1007,7 +1027,7 @@ protected void drawCheckBoxAndSaveAppearance(String onStateName) { final Canvas canvasOff = new Canvas(xObjectOff, getDocument()); setMetaInfoToCanvas(canvasOff); canvasOff.add(formFieldElement); - if (getPdfConformanceLevel() == null) { + if (getPdfConformance() == null || !getPdfConformance().isPdfAOrUa()) { xObjectOff.getResources().addFont(getDocument(), getFont()); } normalAppearance.put(new PdfName(OFF_STATE_VALUE), xObjectOff.getPdfObject()); @@ -1060,20 +1080,13 @@ boolean regenerateWidget() { final PdfName type = parent.getFormType(); retrieveStyles(); - if ((PdfName.Ch.equals(type) && parent.getFieldFlag(PdfChoiceFormField.FF_COMBO)) - || this.isCombTextFormField()) { - if (parent.getFieldFlag(PdfChoiceFormField.FF_COMBO) && formFieldElement != null) { + if (PdfName.Ch.equals(type)) { + if (parent.getFieldFlag(PdfChoiceFormField.FF_COMBO)) { drawComboBoxAndSaveAppearance(); return true; } - return TextAndChoiceLegacyDrawer.regenerateTextAndChoiceField(this); - } else if (PdfName.Ch.equals(type) && !parent.getFieldFlag(PdfChoiceFormField.FF_COMBO)) { - if (formFieldElement != null) { - drawListFormFieldAndSaveAppearance(); - return true; - } else { - return TextAndChoiceLegacyDrawer.regenerateTextAndChoiceField(this); - } + drawListFormFieldAndSaveAppearance(); + return true; } else if (PdfName.Tx.equals(type)) { drawTextFormFieldAndSaveAppearance(); return true; @@ -1167,14 +1180,17 @@ float getFontSize(PdfArray bBox, String value) { private boolean isCombTextFormField() { final PdfName type = parent.getFormType(); - if (PdfName.Tx.equals(type) && parent.getFieldFlag(PdfTextFormField.FF_COMB)) { - int maxLen = PdfFormCreator.createTextFormField(parent.getPdfObject()).getMaxLen(); - if (maxLen == 0 || parent.isMultiline()) { - LOGGER.error( - MessageFormatUtil.format(IoLogMessageConstant.COMB_FLAG_MAY_BE_SET_ONLY_IF_MAXLEN_IS_PRESENT)); - return false; + if (PdfName.Tx.equals(type)) { + PdfTextFormField textField = parent instanceof PdfTextFormField ? (PdfTextFormField) parent : + PdfFormCreator.createTextFormField(parent.getPdfObject()); + if (textField.isComb()) { + if (textField.getMaxLen() == 0 || + textField.isMultiline() || textField.isPassword() || textField.isFileSelect()) { + LOGGER.error(IoLogMessageConstant.COMB_FLAG_MAY_BE_SET_ONLY_IF_MAXLEN_IS_PRESENT); + return false; + } + return true; } - return true; } return false; } @@ -1227,7 +1243,7 @@ private void createCheckBox() { formFieldElement.setProperty(Property.FONT_SIZE, UnitValue.createPointValue(getFontSize())); setModelElementProperties(getRect(getPdfObject())); - ((CheckBox) formFieldElement).setPdfConformanceLevel(getPdfConformanceLevel()); + ((CheckBox) formFieldElement).setPdfConformance(getPdfConformance()); ((CheckBox) formFieldElement).setCheckBoxType(parent.checkType.getValue()); } @@ -1235,7 +1251,10 @@ private void setModelElementProperties(Rectangle rectangle) { if (backgroundColor != null) { formFieldElement.setProperty(Property.BACKGROUND, new Background(backgroundColor)); } - formFieldElement.setProperty(Property.BORDER, getBorder()); + formFieldElement.setProperty(Property.BORDER_TOP, getBorder()); + formFieldElement.setProperty(Property.BORDER_RIGHT, getBorder()); + formFieldElement.setProperty(Property.BORDER_BOTTOM, getBorder()); + formFieldElement.setProperty(Property.BORDER_LEFT, getBorder()); // Set fixed size BoxSizingPropertyValue boxSizing = formFieldElement.getProperty(Property.BOX_SIZING); // Borders and paddings are already taken into account for rectangle area, but shouldn't be included into width diff --git a/forms/src/main/java/com/itextpdf/forms/fields/PdfFormField.java b/forms/src/main/java/com/itextpdf/forms/fields/PdfFormField.java index 9c15b510c0..9be4c7034d 100644 --- a/forms/src/main/java/com/itextpdf/forms/fields/PdfFormField.java +++ b/forms/src/main/java/com/itextpdf/forms/fields/PdfFormField.java @@ -32,7 +32,7 @@ This file is part of the iText (R) project. import com.itextpdf.io.font.constants.StandardFonts; import com.itextpdf.io.image.ImageData; import com.itextpdf.io.image.ImageDataFactory; -import com.itextpdf.io.source.OutputStream; +import com.itextpdf.io.source.HighPrecisionOutputStream; import com.itextpdf.kernel.colors.Color; import com.itextpdf.kernel.colors.DeviceCmyk; import com.itextpdf.kernel.colors.DeviceGray; @@ -255,9 +255,8 @@ public static PdfFormField makeFormField(PdfObject pdfObject, PdfDocument docume } field.makeIndirect(document); - if (document != null && document.getReader() != null && - document.getReader().getPdfAConformanceLevel() != null) { - field.pdfConformanceLevel = document.getReader().getPdfAConformanceLevel(); + if (document != null) { + field.pdfConformance = document.getConformance(); } return field; @@ -1068,7 +1067,7 @@ public PdfFormField setCheckType(CheckBoxType checkType) { checkType = CheckBoxType.CROSS; } this.checkType = new NullableContainer<>(checkType); - if (getPdfConformanceLevel() != null) { + if (getPdfConformance() != null && getPdfConformance().isPdfAOrUa()) { return this; } try { @@ -1312,7 +1311,7 @@ private static PdfString generateDefaultAppearance(PdfName font, float fontSize, assert font != null; ByteArrayOutputStream output = new ByteArrayOutputStream(); - PdfOutputStream pdfStream = new PdfOutputStream(new OutputStream<>(output)); + PdfOutputStream pdfStream = new PdfOutputStream(new HighPrecisionOutputStream<>(output)); final byte[] g = new byte[]{(byte) 'g'}; final byte[] rg = new byte[]{(byte) 'r', (byte) 'g'}; final byte[] k = new byte[]{(byte) 'k'}; diff --git a/forms/src/main/java/com/itextpdf/forms/fields/PdfFormFieldMergeUtil.java b/forms/src/main/java/com/itextpdf/forms/fields/PdfFormFieldMergeUtil.java index a7cccafe66..4e8590afc7 100644 --- a/forms/src/main/java/com/itextpdf/forms/fields/PdfFormFieldMergeUtil.java +++ b/forms/src/main/java/com/itextpdf/forms/fields/PdfFormFieldMergeUtil.java @@ -54,7 +54,7 @@ public static void mergeKidsWithSameNames(PdfFormField parentField, boolean thro return; } PdfArray kids = parent.getAsArray(PdfName.Kids); - if (kids == null || kids.size() == 0) { + if (kids == null || kids.isEmpty()) { return; } Map addedKids = new LinkedHashMap<>(); @@ -91,6 +91,10 @@ public static void mergeKidsWithSameNames(PdfFormField parentField, boolean thro */ public static boolean mergeTwoFieldsWithTheSameNames(PdfFormField firstField, PdfFormField secondField, boolean throwExceptionOnError) { + if (firstField.getPdfObject() == secondField.getPdfObject()) { + // We don't need to perform any strategy on duplicated references, we can just always remove them. + return true; + } final OnDuplicateFormFieldNameStrategy onDuplicateFormFieldNameStrategy = firstField.getDocument() .getDiContainer() .getInstance(OnDuplicateFormFieldNameStrategy.class); diff --git a/forms/src/main/java/com/itextpdf/forms/fields/PdfTextFormField.java b/forms/src/main/java/com/itextpdf/forms/fields/PdfTextFormField.java index 802a9c1c21..0ec792203b 100644 --- a/forms/src/main/java/com/itextpdf/forms/fields/PdfTextFormField.java +++ b/forms/src/main/java/com/itextpdf/forms/fields/PdfTextFormField.java @@ -174,7 +174,8 @@ public PdfTextFormField setScroll(boolean scroll) { * and if the Multiline, Password, and FileSelect flags are clear. * If true, the field is automatically divided into as many equally spaced positions, * or combs, as the value of MaxLen, and the text is laid out into those combs. - * @return whether or not combing is enabled + * + * @return {@code true} if combing is enabled, {@code false} otherwise */ public boolean isComb() { return getFieldFlag(FF_COMB); diff --git a/forms/src/main/java/com/itextpdf/forms/fields/PushButtonFormFieldBuilder.java b/forms/src/main/java/com/itextpdf/forms/fields/PushButtonFormFieldBuilder.java index fb72358d8c..741819dadc 100644 --- a/forms/src/main/java/com/itextpdf/forms/fields/PushButtonFormFieldBuilder.java +++ b/forms/src/main/java/com/itextpdf/forms/fields/PushButtonFormFieldBuilder.java @@ -81,7 +81,7 @@ public PdfButtonFormField createPushButton() { } else { annotation = new PdfWidgetAnnotation(getWidgetRectangle()); field = PdfFormCreator.createButtonFormField(annotation, getDocument()); - if (null != getGenericConformanceLevel()) { + if (null != getConformance() && getConformance().isPdfAOrUa()) { annotation.setFlag(PdfAnnotation.PRINT); } } @@ -89,7 +89,7 @@ public PdfButtonFormField createPushButton() { if (this.getFont() != null) { field.setFont(this.getFont()); } - field.pdfConformanceLevel = getGenericConformanceLevel(); + field.pdfConformance = getConformance(); field.setPushButton(true); field.setFieldName(getFormFieldName()); field.text = caption; diff --git a/forms/src/main/java/com/itextpdf/forms/fields/RadioFormFieldBuilder.java b/forms/src/main/java/com/itextpdf/forms/fields/RadioFormFieldBuilder.java index 7c518f83cf..4a9a67f494 100644 --- a/forms/src/main/java/com/itextpdf/forms/fields/RadioFormFieldBuilder.java +++ b/forms/src/main/java/com/itextpdf/forms/fields/RadioFormFieldBuilder.java @@ -54,7 +54,7 @@ public RadioFormFieldBuilder(PdfDocument document, String radioGroupFormFieldNam public PdfButtonFormField createRadioGroup() { PdfButtonFormField radioGroup = PdfFormCreator.createButtonFormField(getDocument()); radioGroup.disableFieldRegeneration(); - radioGroup.pdfConformanceLevel = getGenericConformanceLevel(); + radioGroup.pdfConformance = getConformance(); radioGroup.setFieldName(getFormFieldName()); radioGroup.setFieldFlags(PdfButtonFormField.FF_RADIO); radioGroup.enableFieldRegeneration(); @@ -84,12 +84,12 @@ public PdfFormAnnotation createRadioButton(String appearanceName, Rectangle rect final PdfName appearancePdfName = new PdfName(appearanceName); final PdfWidgetAnnotation annotation = new PdfWidgetAnnotation(widgetRectangle); annotation.setAppearanceState(appearancePdfName); - if (getGenericConformanceLevel() != null) { + if (getConformance() != null && getConformance().isPdfAOrUa()) { annotation.setFlag(PdfAnnotation.PRINT); } PdfFormAnnotation radio = PdfFormCreator.createFormAnnotation(annotation, getDocument()); setPageToField(radio); - radio.pdfConformanceLevel = getGenericConformanceLevel(); + radio.pdfConformance = getConformance(); return radio; } diff --git a/forms/src/main/java/com/itextpdf/forms/fields/SignatureFormFieldBuilder.java b/forms/src/main/java/com/itextpdf/forms/fields/SignatureFormFieldBuilder.java index d469a0f7ba..e63f8cee62 100644 --- a/forms/src/main/java/com/itextpdf/forms/fields/SignatureFormFieldBuilder.java +++ b/forms/src/main/java/com/itextpdf/forms/fields/SignatureFormFieldBuilder.java @@ -52,7 +52,7 @@ public PdfSignatureFormField createSignature() { signatureFormField = PdfFormCreator.createSignatureFormField(getDocument()); } else { PdfWidgetAnnotation annotation = new PdfWidgetAnnotation(getWidgetRectangle()); - if (getGenericConformanceLevel() != null) { + if (getConformance() != null && getConformance().isPdfAOrUa()) { annotation.setFlag(PdfAnnotation.PRINT); } signatureFormField = PdfFormCreator.createSignatureFormField(annotation, getDocument()); @@ -63,7 +63,7 @@ public PdfSignatureFormField createSignature() { if (getFont() != null) { signatureFormField.font = getFont(); } - signatureFormField.pdfConformanceLevel = getGenericConformanceLevel(); + signatureFormField.pdfConformance = getConformance(); signatureFormField.setFieldName(getFormFieldName()); return signatureFormField; } diff --git a/forms/src/main/java/com/itextpdf/forms/fields/TextAndChoiceLegacyDrawer.java b/forms/src/main/java/com/itextpdf/forms/fields/TextAndChoiceLegacyDrawer.java deleted file mode 100644 index 37c1aef16e..0000000000 --- a/forms/src/main/java/com/itextpdf/forms/fields/TextAndChoiceLegacyDrawer.java +++ /dev/null @@ -1,430 +0,0 @@ -/* - This file is part of the iText (R) project. - Copyright (c) 1998-2024 Apryse Group NV - Authors: Apryse Software. - - This program is offered under a commercial and under the AGPL license. - For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. - - AGPL licensing: - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . - */ -package com.itextpdf.forms.fields; - -import com.itextpdf.forms.logs.FormsLogMessageConstants; -import com.itextpdf.kernel.colors.ColorConstants; -import com.itextpdf.kernel.colors.DeviceRgb; -import com.itextpdf.kernel.font.PdfFont; -import com.itextpdf.kernel.geom.Matrix; -import com.itextpdf.kernel.geom.Rectangle; -import com.itextpdf.kernel.pdf.PdfArray; -import com.itextpdf.kernel.pdf.PdfDictionary; -import com.itextpdf.kernel.pdf.PdfName; -import com.itextpdf.kernel.pdf.PdfNumber; -import com.itextpdf.kernel.pdf.PdfObject; -import com.itextpdf.kernel.pdf.PdfPage; -import com.itextpdf.kernel.pdf.PdfResources; -import com.itextpdf.kernel.pdf.PdfStream; -import com.itextpdf.kernel.pdf.annot.PdfAnnotation; -import com.itextpdf.kernel.pdf.canvas.PdfCanvas; -import com.itextpdf.kernel.pdf.xobject.PdfFormXObject; -import com.itextpdf.layout.Canvas; -import com.itextpdf.layout.Style; -import com.itextpdf.layout.element.Div; -import com.itextpdf.layout.element.Paragraph; -import com.itextpdf.layout.properties.Leading; -import com.itextpdf.layout.properties.Property; -import com.itextpdf.layout.properties.TextAlignment; -import com.itextpdf.layout.properties.TransparentColor; -import com.itextpdf.layout.properties.VerticalAlignment; - -import java.util.List; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -final class TextAndChoiceLegacyDrawer { - - private static final Logger LOGGER = LoggerFactory.getLogger(TextAndChoiceLegacyDrawer.class); - - private TextAndChoiceLegacyDrawer() { - //Empty constructor. - } - - static boolean regenerateTextAndChoiceField(PdfFormAnnotation formAnnotation) { - String value = formAnnotation.parent.getDisplayValue(); - final PdfName type = formAnnotation.parent.getFormType(); - - PdfPage page = PdfAnnotation.makeAnnotation(formAnnotation.getPdfObject()).getPage(); - PdfArray bBox = formAnnotation.getPdfObject().getAsArray(PdfName.Rect); - - //Apply Page rotation - int pageRotation = 0; - if (page != null) { - pageRotation = page.getRotation(); - //Clockwise, so negative - pageRotation *= -1; - } - PdfArray matrix; - if (pageRotation % 90 == 0) { - //Cast angle to [-360, 360] - double angle = pageRotation % 360; - //Get angle in radians - angle = degreeToRadians(angle); - Rectangle initialBboxRectangle = bBox.toRectangle(); - //rotate the bounding box - Rectangle rect = initialBboxRectangle.clone(); - //Calculate origin offset - double translationWidth = 0; - double translationHeight = 0; - if (angle >= -1 * Math.PI && angle <= -1 * Math.PI / 2) { - translationWidth = rect.getWidth(); - } - if (angle <= -1 * Math.PI) { - translationHeight = rect.getHeight(); - } - - //Store rotation and translation in the matrix - matrix = new PdfArray( - new double[] {Math.cos(angle), -Math.sin(angle), Math.sin(angle), Math.cos(angle), translationWidth, - translationHeight}); - // If the angle is a multiple of 90 and not a multiple of 180, height and width of the bounding box - // need to be switched - if (angle % (Math.PI / 2) == 0 && angle % (Math.PI) != 0) { - rect.setWidth(initialBboxRectangle.getHeight()); - rect.setHeight(initialBboxRectangle.getWidth()); - } - // Adapt origin - rect.setX(rect.getX() + (float) translationWidth); - rect.setY(rect.getY() + (float) translationHeight); - //Copy Bounding box - bBox = new PdfArray(rect); - } else { - //Avoid NPE when handling corrupt pdfs - LOGGER.error(FormsLogMessageConstants.INCORRECT_PAGE_ROTATION); - matrix = new PdfArray(new double[] {1, 0, 0, 1, 0, 0}); - } - //Apply field rotation - float fieldRotation = 0; - if (formAnnotation.getPdfObject().getAsDictionary(PdfName.MK) != null - && formAnnotation.getPdfObject().getAsDictionary(PdfName.MK).get(PdfName.R) != null) { - fieldRotation = (float) formAnnotation.getPdfObject().getAsDictionary(PdfName.MK).getAsFloat(PdfName.R); - //Get relative field rotation - fieldRotation += pageRotation; - } - if (fieldRotation % 90 == 0) { - Rectangle initialBboxRectangle = bBox.toRectangle(); - //Cast angle to [-360, 360] - double angle = fieldRotation % 360; - //Get angle in radians - angle = degreeToRadians(angle); - //Calculate origin offset - double translationWidth = calculateTranslationWidthAfterFieldRot(initialBboxRectangle, - degreeToRadians(pageRotation), angle); - double translationHeight = calculateTranslationHeightAfterFieldRot(initialBboxRectangle, - degreeToRadians(pageRotation), angle); - - //Concatenate rotation and translation into the matrix - Matrix currentMatrix = new Matrix(matrix.getAsNumber(0).floatValue(), - matrix.getAsNumber(1).floatValue(), - matrix.getAsNumber(2).floatValue(), - matrix.getAsNumber(3).floatValue(), - matrix.getAsNumber(4).floatValue(), - matrix.getAsNumber(5).floatValue()); - Matrix toConcatenate = new Matrix((float) Math.cos(angle), - (float) (-Math.sin(angle)), - (float) (Math.sin(angle)), - (float) (Math.cos(angle)), - (float) translationWidth, - (float) translationHeight); - currentMatrix = currentMatrix.multiply(toConcatenate); - matrix = new PdfArray( - new float[] {currentMatrix.get(0), currentMatrix.get(1), currentMatrix.get(3), currentMatrix.get(4), - currentMatrix.get(6), currentMatrix.get(7)}); - - // Construct bounding box - Rectangle rect = initialBboxRectangle.clone(); - // If the angle is a multiple of 90 and not a multiple of 180, height and width of the bounding box - // need to be switched - if (angle % (Math.PI / 2) == 0 && angle % (Math.PI) != 0) { - rect.setWidth(initialBboxRectangle.getHeight()); - rect.setHeight(initialBboxRectangle.getWidth()); - } - rect.setX(rect.getX() + (float) translationWidth); - rect.setY(rect.getY() + (float) translationHeight); - // Copy Bounding box - bBox = new PdfArray(rect); - } - // Create appearance - Rectangle bboxRectangle = bBox.toRectangle(); - PdfFormXObject appearance = new PdfFormXObject(new Rectangle(0, 0, bboxRectangle.getWidth(), - bboxRectangle.getHeight())); - appearance.put(PdfName.Matrix, matrix); - //Create text appearance - if (PdfName.Tx.equals(type)) { - drawCombTextAppearance(formAnnotation, bboxRectangle, formAnnotation.getFont(), - formAnnotation.getFontSize(bBox, value), value, appearance); - } else { - int topIndex = 0; - if (!formAnnotation.parent.getFieldFlag(PdfChoiceFormField.FF_COMBO)) { - PdfNumber topIndexNum = formAnnotation.getParent().getAsNumber(PdfName.TI); - PdfArray options = formAnnotation.parent.getOptions(); - if (null != options) { - topIndex = null != topIndexNum ? topIndexNum.intValue() : 0; - PdfArray visibleOptions = topIndex > 0 - ? new PdfArray(options.subList(topIndex, options.size())) : (PdfArray) options.clone(); - value = PdfFormField.optionsArrayToString(visibleOptions); - } - } - drawChoiceAppearance(formAnnotation, bboxRectangle, formAnnotation.getFontSize(bBox, value), - value, appearance, topIndex); - } - PdfDictionary ap = new PdfDictionary(); - ap.put(PdfName.N, appearance.getPdfObject()); - ap.setModified(); - formAnnotation.put(PdfName.AP, ap); - - return true; - } - - static void drawChoiceAppearance(PdfFormAnnotation formAnnotation, Rectangle rect, float fontSize, String value, - PdfFormXObject appearance, int topIndex) { - PdfStream stream = (PdfStream) new PdfStream().makeIndirect(formAnnotation.getDocument()); - PdfResources resources = appearance.getResources(); - PdfCanvas canvas = new PdfCanvas(stream, resources, formAnnotation.getDocument()); - - float width = rect.getWidth(); - float height = rect.getHeight(); - float widthBorder = 6.0f; - float heightBorder = 2.0f; - - formAnnotation.drawBorder(canvas, appearance, width, height); - canvas. - beginVariableText(). - saveState(). - rectangle(3, 3, width - widthBorder, height - heightBorder). - clip(). - endPath(); - - Canvas modelCanvas = new Canvas(canvas, new Rectangle(3, 0, Math.max(0, width - widthBorder), - Math.max(0, height - heightBorder))); - modelCanvas.setProperty(Property.APPEARANCE_STREAM_LAYOUT, Boolean.TRUE); - - PdfFormAnnotation.setMetaInfoToCanvas(modelCanvas); - - Div div = new Div(); - if (formAnnotation.parent.getFieldFlag(PdfChoiceFormField.FF_COMBO)) { - div.setVerticalAlignment(VerticalAlignment.MIDDLE); - } - div.setHeight(Math.max(0, height - heightBorder)); - List strings = formAnnotation.getFont().splitString(value, fontSize, width - widthBorder); - for (int index = 0; index < strings.size(); index++) { - Boolean isFull = modelCanvas.getRenderer().getPropertyAsBoolean(Property.FULL); - if (Boolean.TRUE.equals(isFull)) { - break; - } - - Paragraph paragraph = new Paragraph(strings.get(index)).setFont(formAnnotation.getFont()) - .setFontSize(fontSize).setMargins(0, 0, 0, 0).setMultipliedLeading(1); - paragraph.setProperty(Property.FORCED_PLACEMENT, Boolean.TRUE); - paragraph.setTextAlignment(formAnnotation.parent.getJustification()); - - if (formAnnotation.getColor() != null) { - paragraph.setFontColor(formAnnotation.getColor()); - } - if (!formAnnotation.parent.getFieldFlag(PdfChoiceFormField.FF_COMBO)) { - PdfArray indices = formAnnotation.getParent().getAsArray(PdfName.I); - if (indices != null && indices.size() > 0) { - for (PdfObject ind : indices) { - if (!ind.isNumber()) { - continue; - } - if (((PdfNumber) ind).getValue() == index + topIndex) { - paragraph.setBackgroundColor(new DeviceRgb(10, 36, 106)); - paragraph.setFontColor(ColorConstants.LIGHT_GRAY); - } - } - } - } - div.add(paragraph); - } - modelCanvas.add(div); - canvas. - restoreState(). - endVariableText(); - - appearance.getPdfObject().setData(stream.getBytes()); - } - - static private void drawCombTextAppearance(PdfFormAnnotation formAnnotation, Rectangle rect, PdfFont font, - float fontSize, String value, PdfFormXObject appearance) { - PdfStream stream = (PdfStream) new PdfStream().makeIndirect(formAnnotation.getDocument()); - PdfResources resources = appearance.getResources(); - PdfCanvas canvas = new PdfCanvas(stream, resources, formAnnotation.getDocument()); - - float height = rect.getHeight(); - float width = rect.getWidth(); - PdfFormXObject xObject = new PdfFormXObject(new Rectangle(0, 0, width, height)); - formAnnotation.drawBorder(canvas, xObject, width, height); - if (formAnnotation.parent.isPassword()) { - value = obfuscatePassword(value); - } - - canvas. - beginVariableText(). - saveState(). - endPath(); - - Canvas modelCanvas = new Canvas(canvas, new Rectangle(0, -height, 0, 2 * height)); - modelCanvas.setProperty(Property.APPEARANCE_STREAM_LAYOUT, Boolean.TRUE); - - PdfFormAnnotation.setMetaInfoToCanvas(modelCanvas); - - Style paragraphStyle = new Style().setFont(font).setFontSize(fontSize); - paragraphStyle.setProperty(Property.LEADING, new Leading(Leading.MULTIPLIED, 1)); - if (formAnnotation.getColor() != null) { - paragraphStyle.setProperty(Property.FONT_COLOR, new TransparentColor(formAnnotation.getColor())); - } - - int maxLen = PdfFormCreator.createTextFormField(formAnnotation.parent.getPdfObject()).getMaxLen(); - // check if /Comb has been set - float widthPerCharacter = width / maxLen; - int numberOfCharacters = Math.min(maxLen, value.length()); - - int start; - TextAlignment textAlignment = formAnnotation.parent.getJustification() == null ? - TextAlignment.LEFT : formAnnotation.parent.getJustification(); - switch (textAlignment) { - case RIGHT: - start = (maxLen - numberOfCharacters); - break; - case CENTER: - start = (maxLen - numberOfCharacters) / 2; - break; - default: - start = 0; - } - float startOffset = widthPerCharacter * (start + 0.5f); - for (int i = 0; i < numberOfCharacters; i++) { - modelCanvas.showTextAligned(new Paragraph(value.substring(i, i + 1)).addStyle(paragraphStyle), - startOffset + widthPerCharacter * i, rect.getHeight() / 2, TextAlignment.CENTER, - VerticalAlignment.MIDDLE); - } - canvas. - restoreState(). - endVariableText(); - - appearance.getPdfObject().setData(stream.getBytes()); - } - - private static String obfuscatePassword(String text) { - char[] pchar = new char[text.length()]; - for (int i = 0; i < text.length(); i++) { - pchar[i] = '*'; - } - return new String(pchar); - } - - private static float calculateTranslationHeightAfterFieldRot(Rectangle bBox, double pageRotation, - double relFieldRotation) { - if (relFieldRotation == 0) { - return 0.0f; - } - if (pageRotation == 0) { - if (relFieldRotation == Math.PI / 2) { - return bBox.getHeight(); - } - if (relFieldRotation == Math.PI) { - return bBox.getHeight(); - } - - } - if (pageRotation == -Math.PI / 2) { - if (relFieldRotation == -Math.PI / 2) { - return bBox.getWidth() - bBox.getHeight(); - } - if (relFieldRotation == Math.PI / 2) { - return bBox.getHeight(); - } - if (relFieldRotation == Math.PI) { - return bBox.getWidth(); - } - - } - if (pageRotation == -Math.PI) { - if (relFieldRotation == -1 * Math.PI) { - return bBox.getHeight(); - } - if (relFieldRotation == -1 * Math.PI / 2) { - return bBox.getHeight() - bBox.getWidth(); - } - - if (relFieldRotation == Math.PI / 2) { - return bBox.getWidth(); - } - } - if (pageRotation == -3 * Math.PI / 2) { - if (relFieldRotation == -3 * Math.PI / 2) { - return bBox.getWidth(); - } - if (relFieldRotation == -Math.PI) { - return bBox.getWidth(); - } - } - - return 0.0f; - } - - private static float calculateTranslationWidthAfterFieldRot(Rectangle bBox, double pageRotation, - double relFieldRotation) { - if (relFieldRotation == 0) { - return 0.0f; - } - if (pageRotation == 0 && (relFieldRotation == Math.PI || relFieldRotation == 3 * Math.PI / 2)) { - return bBox.getWidth(); - } - if (pageRotation == -Math.PI / 2) { - if (relFieldRotation == -Math.PI / 2 || relFieldRotation == Math.PI) { - return bBox.getHeight(); - } - } - - if (pageRotation == -Math.PI) { - if (relFieldRotation == -1 * Math.PI) { - return bBox.getWidth(); - } - if (relFieldRotation == -1 * Math.PI / 2) { - return bBox.getHeight(); - } - if (relFieldRotation == Math.PI / 2) { - return -1 * (bBox.getHeight() - bBox.getWidth()); - } - } - if (pageRotation == -3 * Math.PI / 2) { - if (relFieldRotation == -3 * Math.PI / 2) { - return -1 * (bBox.getWidth() - bBox.getHeight()); - } - if (relFieldRotation == -Math.PI) { - return bBox.getHeight(); - } - if (relFieldRotation == -Math.PI / 2) { - return bBox.getWidth(); - } - } - return 0.0f; - } - - private static double degreeToRadians(double angle) { - return Math.PI * angle / 180.0; - } -} diff --git a/forms/src/main/java/com/itextpdf/forms/fields/TextFormFieldBuilder.java b/forms/src/main/java/com/itextpdf/forms/fields/TextFormFieldBuilder.java index 19c5d9cc23..6f71e7a0f1 100644 --- a/forms/src/main/java/com/itextpdf/forms/fields/TextFormFieldBuilder.java +++ b/forms/src/main/java/com/itextpdf/forms/fields/TextFormFieldBuilder.java @@ -58,7 +58,7 @@ private PdfTextFormField createText(boolean multiline) { field = PdfFormCreator.createTextFormField(getDocument()); } else { PdfWidgetAnnotation annotation = new PdfWidgetAnnotation(getWidgetRectangle()); - if (null != getGenericConformanceLevel()) { + if (null != getConformance() && getConformance().isPdfAOrUa()) { annotation.setFlag(PdfAnnotation.PRINT); } field = PdfFormCreator.createTextFormField(annotation, getDocument()); @@ -68,7 +68,7 @@ private PdfTextFormField createText(boolean multiline) { field.setFont(getFont()); } field.disableFieldRegeneration(); - field.pdfConformanceLevel = getGenericConformanceLevel(); + field.pdfConformance = getConformance(); field.setMultiline(multiline); field.setFieldName(getFormFieldName()); field.setValue(TEXT_FORM_FIELD_DEFAULT_VALUE); diff --git a/forms/src/main/java/com/itextpdf/forms/fields/properties/SignedAppearanceText.java b/forms/src/main/java/com/itextpdf/forms/fields/properties/SignedAppearanceText.java index cc1e4c9242..c3b9d57005 100644 --- a/forms/src/main/java/com/itextpdf/forms/fields/properties/SignedAppearanceText.java +++ b/forms/src/main/java/com/itextpdf/forms/fields/properties/SignedAppearanceText.java @@ -79,7 +79,10 @@ public String getReasonLine() { * @return this same {@link SignedAppearanceText} instance. */ public SignedAppearanceText setReasonLine(String reason) { - this.reason = reason.trim(); + if (reason != null) { + reason = reason.trim(); + } + this.reason = reason; return this; } @@ -99,12 +102,15 @@ public String getLocationLine() { * Note, that this location won't be passed to the signature dictionary. If none is set, value set by * {@code PdfSigner#setLocation} will be used. * - * @param location new signing location. + * @param location new signing location * - * @return this same {@link SignedAppearanceText} instance. + * @return this same {@link SignedAppearanceText} instance */ public SignedAppearanceText setLocationLine(String location) { - this.location = location.trim(); + if (location != null) { + location = location.trim(); + } + this.location = location; return this; } @@ -114,19 +120,22 @@ public SignedAppearanceText setLocationLine(String location) { *

* Note, that the signer name will be replaced by the one from the signing certificate during the actual signing. * - * @param signedBy name of the signer. + * @param signedBy name of the signer * - * @return this same {@link SignedAppearanceText} instance. + * @return this same {@link SignedAppearanceText} instance */ public SignedAppearanceText setSignedBy(String signedBy) { - this.signedBy = signedBy.trim(); + if (signedBy != null) { + signedBy = signedBy.trim(); + } + this.signedBy = signedBy; return this; } /** * Gets the name of the signer from the certificate. * - * @return signedBy name of the signer. + * @return signedBy name of the signer */ public String getSignedBy() { return signedBy; @@ -147,8 +156,9 @@ public java.util.Calendar getSignDate() { *

* Note, that the signing date will be replaced by the one from the {@code PdfSigner} during the signing. * - * @param signDate new signature date. - * @return this same {@link SignedAppearanceText} instance. + * @param signDate new signature date + * + * @return this same {@link SignedAppearanceText} instance */ public SignedAppearanceText setSignDate(java.util.Calendar signDate) { this.signDate = signDate; @@ -159,7 +169,7 @@ public SignedAppearanceText setSignDate(java.util.Calendar signDate) { /** * Generates the signature description text based on the provided parameters. * - * @return signature description. + * @return signature description */ public String generateDescriptionText() { final StringBuilder buf = new StringBuilder(); diff --git a/forms/src/main/java/com/itextpdf/forms/form/FormProperty.java b/forms/src/main/java/com/itextpdf/forms/form/FormProperty.java index 498cff7609..227f0a76f4 100644 --- a/forms/src/main/java/com/itextpdf/forms/form/FormProperty.java +++ b/forms/src/main/java/com/itextpdf/forms/form/FormProperty.java @@ -60,10 +60,6 @@ public final class FormProperty { /** The Constant FORM_FIELD_LABEL. */ public static final int FORM_FIELD_LABEL = PROPERTY_START + 10; - /** The Constant FORM_ACCESSIBILITY_LANGUAGE. */ - @Deprecated() - public static final int FORM_ACCESSIBILITY_LANGUAGE = PROPERTY_START + 11; - /** The Constant FORM_FIELD_RADIO_GROUP_NAME. */ public static final int FORM_FIELD_RADIO_GROUP_NAME = PROPERTY_START + 12; @@ -77,6 +73,15 @@ public final class FormProperty { /** The Constant FORM_CONFORMANCE_LEVEL. */ public static final int FORM_CONFORMANCE_LEVEL = PROPERTY_START + 15; + + /** The Constant LIST_BOX_TOP_INDEX representing the index of the first visible option in a scrollable list. */ + public static final int LIST_BOX_TOP_INDEX = PROPERTY_START + 16; + + /** The Constant TEXT_FIELD_COMB_FLAG representing {@code Comb} flag for the text field. */ + public static final int TEXT_FIELD_COMB_FLAG = PROPERTY_START + 17; + + /** The Constant TEXT_FIELD_MAX_LEN representing the maximum length of the field's text, in characters. */ + public static final int TEXT_FIELD_MAX_LEN = PROPERTY_START + 18; private FormProperty() { // Empty constructor. diff --git a/forms/src/main/java/com/itextpdf/forms/form/element/AbstractSelectField.java b/forms/src/main/java/com/itextpdf/forms/form/element/AbstractSelectField.java index a7bcd38674..7d23409146 100644 --- a/forms/src/main/java/com/itextpdf/forms/form/element/AbstractSelectField.java +++ b/forms/src/main/java/com/itextpdf/forms/form/element/AbstractSelectField.java @@ -23,9 +23,6 @@ This file is part of the iText (R) project. package com.itextpdf.forms.form.element; import com.itextpdf.forms.form.FormProperty; -import com.itextpdf.layout.element.IBlockElement; -import com.itextpdf.layout.element.IElement; -import com.itextpdf.layout.element.Text; import java.util.ArrayList; import java.util.List; @@ -46,19 +43,6 @@ protected AbstractSelectField(String id) { super(id); } - /** - * Add a container with options. This might be a container for options group. - * - * @param optionElement a container with options - * - * @deprecated starting from 8.0.1. - */ - @Deprecated - public void addOption(IBlockElement optionElement) { - String value = tryAndExtractText(optionElement); - addOption(new SelectFieldItem(value, optionElement)); - } - /** * Add an option to the element. * @@ -84,18 +68,17 @@ public void addOption(SelectFieldItem option, boolean selected) { * * @return a list of options. */ - public List getItems() { + public List getOptions() { return options; } - /** * Gets the total amount of options available. * * @return the number of options in the element. */ public int optionsCount() { - return this.getItems().size(); + return this.getOptions().size(); } /** @@ -124,22 +107,6 @@ public SelectFieldItem getOption(String value) { return null; } - /** - * Gets a list of containers with option(s). Every container might be a container for options group. - * - * @return a list of containers with options. - * - * @deprecated starting from 8.0.1. - */ - @Deprecated - public List getOptions() { - List blockElements = new ArrayList<>(); - for (SelectFieldItem option : options) { - blockElements.add(option.getElement()); - } - return blockElements; - } - /** * Checks if the field has options with export and display values. * @@ -153,21 +120,4 @@ public boolean hasExportAndDisplayValues() { } return false; } - - private String tryAndExtractText(IBlockElement optionElement) { - String label = optionElement.getProperty(FormProperty.FORM_FIELD_LABEL); - if (label != null) { - return label; - } - - for (IElement child : optionElement.getChildren()) { - if (child instanceof Text) { - return ((Text) child).getText(); - } else if (child instanceof IBlockElement) { - return tryAndExtractText((IBlockElement) child); - } - } - return ""; - } } - diff --git a/forms/src/main/java/com/itextpdf/forms/form/element/CheckBox.java b/forms/src/main/java/com/itextpdf/forms/form/element/CheckBox.java index 56fc402939..71bafb48e9 100644 --- a/forms/src/main/java/com/itextpdf/forms/form/element/CheckBox.java +++ b/forms/src/main/java/com/itextpdf/forms/form/element/CheckBox.java @@ -28,9 +28,7 @@ This file is part of the iText (R) project. import com.itextpdf.forms.form.FormProperty; import com.itextpdf.forms.form.renderer.CheckBoxRenderer; import com.itextpdf.forms.logs.FormsLogMessageConstants; -import com.itextpdf.kernel.pdf.IConformanceLevel; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; -import com.itextpdf.kernel.pdf.tagging.PdfStructureAttributes; +import com.itextpdf.kernel.pdf.PdfConformance; import com.itextpdf.kernel.pdf.tagutils.AccessibilityProperties; import com.itextpdf.layout.properties.BoxSizingPropertyValue; import com.itextpdf.layout.properties.Property; @@ -59,7 +57,6 @@ public CheckBox(String id) { setChecked(false); } - /** * Sets the checked state of the checkbox. * @@ -73,32 +70,17 @@ public CheckBox setChecked(boolean checked) { } /** - * Sets the PDF/A conformance level for the checkbox. - * This method is deprecated use setPdfConformanceLevel. - * @param conformanceLevel The PDF/A conformance level to set. - * - * @return This checkbox instance. - */ - @Deprecated() - public CheckBox setPdfAConformanceLevel(PdfAConformanceLevel conformanceLevel) { - setProperty(FormProperty.FORM_CONFORMANCE_LEVEL, conformanceLevel); - return this; - } - - /** - * Sets the conformance level for the checkbox. + * Sets the conformance for the checkbox. * - * @param conformanceLevel The PDF/A conformance level to set. + * @param conformance The PDF conformance to set. * - * @return tThis checkbox instance. + * @return this checkbox instance */ - public CheckBox setPdfConformanceLevel(IConformanceLevel conformanceLevel) { - setProperty(FormProperty.FORM_CONFORMANCE_LEVEL, conformanceLevel); + public CheckBox setPdfConformance(PdfConformance conformance) { + setProperty(FormProperty.FORM_CONFORMANCE_LEVEL, conformance); return this; } - - /** * Sets the icon of the checkbox. * diff --git a/forms/src/main/java/com/itextpdf/forms/form/element/ComboBoxField.java b/forms/src/main/java/com/itextpdf/forms/form/element/ComboBoxField.java index a520665ea4..1031cbe8e6 100644 --- a/forms/src/main/java/com/itextpdf/forms/form/element/ComboBoxField.java +++ b/forms/src/main/java/com/itextpdf/forms/form/element/ComboBoxField.java @@ -71,12 +71,12 @@ public String getSelectedExportValue() { * @throws IndexOutOfBoundsException if the index is out of bounds. */ public ComboBoxField setSelected(int index) { - if (index < 0 || index >= this.getItems().size()) { + if (index < 0 || index >= this.getOptions().size()) { String message = MessageFormatUtil.format(FormsExceptionMessageConstant.INDEX_OUT_OF_BOUNDS, index, - this.getItems().size()); + this.getOptions().size()); throw new IndexOutOfBoundsException(message); } - setSelected(this.getItems().get(index)); + setSelected(this.getOptions().get(index)); return this; } @@ -91,7 +91,7 @@ public ComboBoxField setSelected(String value) { clearSelected(); selectedExportValue = value; boolean found = false; - for (SelectFieldItem option : this.getItems()) { + for (SelectFieldItem option : this.getOptions()) { if (option.getExportValue().equals(value)) { if (!found) { option.getElement().setProperty(FormProperty.FORM_FIELD_SELECTED, true); @@ -128,7 +128,7 @@ public ComboBoxField setSelected(SelectFieldItem item) { @Override public void addOption(SelectFieldItem option) { boolean found = false; - for (SelectFieldItem item : this.getItems()) { + for (SelectFieldItem item : this.getOptions()) { if (item.getExportValue().equals(option.getExportValue())) { found = true; break; @@ -150,7 +150,7 @@ public SelectFieldItem getSelectedOption() { if (selectedExportValue == null) { return null; } - for (SelectFieldItem option : this.getItems()) { + for (SelectFieldItem option : this.getOptions()) { if (option.getExportValue().equals(selectedExportValue)) { return option; } @@ -177,7 +177,7 @@ protected IRenderer makeNewRenderer() { private void clearSelected() { this.selectedExportValue = null; - for (SelectFieldItem option : this.getItems()) { + for (SelectFieldItem option : this.getOptions()) { option.getElement().deleteOwnProperty(FormProperty.FORM_FIELD_SELECTED); } } diff --git a/forms/src/main/java/com/itextpdf/forms/form/element/IFormField.java b/forms/src/main/java/com/itextpdf/forms/form/element/IFormField.java index 4e0803ebb3..dfe6722761 100644 --- a/forms/src/main/java/com/itextpdf/forms/form/element/IFormField.java +++ b/forms/src/main/java/com/itextpdf/forms/form/element/IFormField.java @@ -32,9 +32,9 @@ public interface IFormField extends IBlockElement { /** * Sets the {@link FormProperty#FORM_FIELD_VALUE} property. * - * @param value string value of the property to be set. + * @param value string value of the property to be set * - * @return this same {@link IFormField} instance. + * @return this same {@link IFormField} instance */ IFormField setValue(String value); @@ -42,34 +42,34 @@ public interface IFormField extends IBlockElement { * Set the form field to be interactive and added into Acroform instead of drawing it on a page. * * @param interactive {@code true} if the form field element shall be added into Acroform, {@code false} otherwise. - * By default, the form field element is not interactive and drawn on a page. + * By default, the form field element is not interactive and drawn on a page * - * @return this same {@link IFormField} instance. + * @return this same {@link IFormField} instance */ IFormField setInteractive(boolean interactive); /** * Gets the id. * - * @return the id. + * @return the id */ String getId(); /** * Set the form field's width. * - * @param width form field's width. + * @param width form field's width * - * @return this {@link FormField} element. + * @return this {@link FormField} element */ IFormField setWidth(float width); /** * Set the form field's height. * - * @param height form field's height. + * @param height form field's height * - * @return this {@link FormField} element. + * @return this {@link FormField} element */ IFormField setHeight(float height); } diff --git a/forms/src/main/java/com/itextpdf/forms/form/element/InputField.java b/forms/src/main/java/com/itextpdf/forms/form/element/InputField.java index 7b96c3ee2c..b0f467907e 100644 --- a/forms/src/main/java/com/itextpdf/forms/form/element/InputField.java +++ b/forms/src/main/java/com/itextpdf/forms/form/element/InputField.java @@ -108,6 +108,10 @@ public T1 getDefaultProperty(int property) { return (T1) (Object) false; case FormProperty.FORM_FIELD_SIZE: return (T1) (Object) 20; + case FormProperty.TEXT_FIELD_COMB_FLAG: + return (T1) (Object) false; + case FormProperty.TEXT_FIELD_MAX_LEN: + return (T1) (Object) 0; default: return super.getDefaultProperty(property); } @@ -126,9 +130,9 @@ public int getRotation() { * Set rotation of the input field. * * @param rotation new rotation value, counterclockwise. Must be a multiple of 90 degrees. - * It has sense only in interactive mode, see {@link FormField#setInteractive}. + * It has sense only in interactive mode, see {@link FormField#setInteractive} * - * @return the edited {@link InputField}. + * @return the edited {@link InputField} */ public InputField setRotation(int rotation) { if (rotation % 90 != 0) { @@ -139,6 +143,35 @@ public InputField setRotation(int rotation) { return this; } + /** + * Sets {@code Comb} flag for the text field. Meaningful only if the MaxLen entry is present in the text field + * dictionary and if the Multiline, Password and FileSelect flags are clear. + * + *

+ * If true, the field is automatically divided into as many equally spaced positions, or combs, + * as the value of MaxLen, and the text is laid out into those combs. + * + * @param isComb boolean value specifying whether to enable combing + * + * @return this {@link InputField} instance + */ + public InputField setComb(boolean isComb) { + setProperty(FormProperty.TEXT_FIELD_COMB_FLAG, isComb); + return this; + } + + /** + * Sets the maximum length of the field's text, in characters. + * + * @param maxLen the current maximum text length + * + * @return this {@link InputField} instance + */ + public InputField setMaxLen(int maxLen) { + setProperty(FormProperty.TEXT_FIELD_MAX_LEN, maxLen); + return this; + } + /** * {@inheritDoc} */ diff --git a/forms/src/main/java/com/itextpdf/forms/form/element/ListBoxField.java b/forms/src/main/java/com/itextpdf/forms/form/element/ListBoxField.java index 3d5c95f779..ae838844ec 100644 --- a/forms/src/main/java/com/itextpdf/forms/form/element/ListBoxField.java +++ b/forms/src/main/java/com/itextpdf/forms/form/element/ListBoxField.java @@ -73,6 +73,8 @@ public T1 getDefaultProperty(int property) { return (T1) (Object) false; case FormProperty.FORM_FIELD_SIZE: return (T1) (Object) 4; + case FormProperty.LIST_BOX_TOP_INDEX: + return (T1) (Object) 0; default: return super.getDefaultProperty(property); } @@ -119,6 +121,18 @@ public List getSelectedStrings() { return selectedStrings; } + /** + * Sets the index of the first visible option in a scrollable list. + * + * @param topIndex the index of the first option + * + * @return this {@link ListBoxField} instance + */ + public ListBoxField setTopIndex(int topIndex) { + setProperty(FormProperty.LIST_BOX_TOP_INDEX, topIndex); + return this; + } + /** * {@inheritDoc} */ diff --git a/forms/src/main/java/com/itextpdf/forms/form/element/SignatureFieldAppearance.java b/forms/src/main/java/com/itextpdf/forms/form/element/SignatureFieldAppearance.java index 866007a372..0e1f16e4d1 100644 --- a/forms/src/main/java/com/itextpdf/forms/form/element/SignatureFieldAppearance.java +++ b/forms/src/main/java/com/itextpdf/forms/form/element/SignatureFieldAppearance.java @@ -66,12 +66,17 @@ public class SignatureFieldAppearance extends FormField - * Usually means that instead of glyphs '*' will be shown in case of flatten field. - * - *

- * If the field is not flatten, value will be ignored. - * - * @param isPassword {@code true} is this field shall be considered as password, {@code false} otherwise - * - * @return this input field - */ - public TextArea useAsPassword(boolean isPassword) { - setProperty(FormProperty.FORM_FIELD_PASSWORD_FLAG, isPassword); - return this; - } - /* (non-Javadoc) * @see FormField#getDefaultProperty(int) */ diff --git a/forms/src/main/java/com/itextpdf/forms/form/renderer/AbstractFormFieldRenderer.java b/forms/src/main/java/com/itextpdf/forms/form/renderer/AbstractFormFieldRenderer.java index 822ad7c979..39e35cf9d2 100644 --- a/forms/src/main/java/com/itextpdf/forms/form/renderer/AbstractFormFieldRenderer.java +++ b/forms/src/main/java/com/itextpdf/forms/form/renderer/AbstractFormFieldRenderer.java @@ -27,8 +27,7 @@ This file is part of the iText (R) project. import com.itextpdf.forms.form.element.IFormField; import com.itextpdf.forms.logs.FormsLogMessageConstants; import com.itextpdf.kernel.geom.Rectangle; -import com.itextpdf.kernel.pdf.IConformanceLevel; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfConformance; import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.canvas.PdfCanvas; import com.itextpdf.kernel.pdf.tagging.StandardRoles; @@ -42,16 +41,12 @@ This file is part of the iText (R) project. import com.itextpdf.layout.minmaxwidth.MinMaxWidth; import com.itextpdf.layout.properties.OverflowPropertyValue; import com.itextpdf.layout.properties.Property; -import com.itextpdf.layout.properties.UnitValue; import com.itextpdf.layout.renderer.BlockRenderer; import com.itextpdf.layout.renderer.DrawContext; import com.itextpdf.layout.renderer.IRenderer; import com.itextpdf.layout.tagging.IAccessibleElement; -import java.util.HashMap; import java.util.List; -import java.util.Map; -import java.util.Map.Entry; import org.slf4j.LoggerFactory; /** @@ -285,58 +280,34 @@ protected boolean isRendererFit(float availableWidth, float availableHeight) { } /** - * Gets the accessibility language. + * Gets the accessibility language using {@link IAccessibleElement#getAccessibilityProperties()}. * * @return the accessibility language. - * @deprecated use {@link IAccessibleElement#getAccessibilityProperties()} instead */ - @Deprecated() protected String getLang() { String language = null; if (this.getModelElement() instanceof IAccessibleElement) { language = ((IAccessibleElement) this.getModelElement()).getAccessibilityProperties().getLanguage(); } - if (language == null) { - language = this.getProperty(FormProperty.FORM_ACCESSIBILITY_LANGUAGE); - } return language; } /** - * Gets the conformance level. If the conformance level is not set, the conformance level of the document is used. - * - * @param document the document - * - * @return the conformance level or null if the conformance level is not set. - * - * @deprecated since 8.0.4 will return {@link IConformanceLevel} - */ - @Deprecated - protected PdfAConformanceLevel getConformanceLevel(PdfDocument document) { - return PdfAConformanceLevel.getPDFAConformance(this.getProperty( - FormProperty.FORM_CONFORMANCE_LEVEL), document); - } - - /** - * Gets the conformance level. If the conformance level is not set, the conformance level of the document is used. + * Gets the conformance. If the conformance is not set, the conformance of the document is used. * * @param document the document * - * @return the conformance level or null if the conformance level is not set. - * - * @deprecated since 8.0.4 will be renamed to getConformanceLevel() + * @return the conformance or null if the conformance is not set. */ - @Deprecated - protected IConformanceLevel getGenericConformanceLevel(PdfDocument document) { - final IConformanceLevel conformanceLevel = this.getProperty( - FormProperty.FORM_CONFORMANCE_LEVEL); - if (conformanceLevel != null) { - return conformanceLevel; + protected PdfConformance getConformance(PdfDocument document) { + final PdfConformance conformance = this.getProperty(FormProperty.FORM_CONFORMANCE_LEVEL); + if (conformance != null) { + return conformance; } if (document == null) { return null; } - return document.getConformanceLevel(); + return document.getConformance(); } /** diff --git a/forms/src/main/java/com/itextpdf/forms/form/renderer/AbstractSelectFieldRenderer.java b/forms/src/main/java/com/itextpdf/forms/form/renderer/AbstractSelectFieldRenderer.java index 2dc3b80719..3f5589dd26 100644 --- a/forms/src/main/java/com/itextpdf/forms/form/renderer/AbstractSelectFieldRenderer.java +++ b/forms/src/main/java/com/itextpdf/forms/form/renderer/AbstractSelectFieldRenderer.java @@ -29,8 +29,7 @@ This file is part of the iText (R) project. import com.itextpdf.forms.form.element.IFormField; import com.itextpdf.forms.form.element.SelectFieldItem; import com.itextpdf.kernel.geom.Rectangle; -import com.itextpdf.kernel.pdf.IConformanceLevel; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfConformance; import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.tagging.StandardRoles; import com.itextpdf.kernel.pdf.tagutils.AccessibilityProperties; @@ -60,7 +59,6 @@ public abstract class AbstractSelectFieldRenderer extends BlockRenderer { */ protected AbstractSelectFieldRenderer(AbstractSelectField modelElement) { super(modelElement); - addChild(createFlatRenderer()); } /** @@ -68,6 +66,9 @@ protected AbstractSelectFieldRenderer(AbstractSelectField modelElement) { */ @Override public LayoutResult layout(LayoutContext layoutContext) { + childRenderers.clear(); + addChild(createFlatRenderer()); + // Resolve width here in case it's relative, while parent width is still intact. // If it's inline-block context, relative width is already resolved. Float width = retrieveWidth(layoutContext.getArea().getBBox().getWidth()); @@ -84,7 +85,7 @@ public LayoutResult layout(LayoutContext layoutContext) { final boolean isForcedPlacement = Boolean.TRUE.equals(getPropertyAsBoolean(Property.FORCED_PLACEMENT)); LayoutResult layoutResult = super.layout(new LayoutContext(area, layoutContext.getMarginsCollapseInfo(), layoutContext.getFloatRendererAreas(), layoutContext.isClippedHeight())); - if (isForcedPlacement){ + if (isForcedPlacement) { // Restore the Property.FORCED_PLACEMENT value as it was before super.layout setProperty(Property.FORCED_PLACEMENT, true); } @@ -148,7 +149,7 @@ public void drawChildren(DrawContext drawContext) { } /** - * Gets the accessibility language. + * Gets the accessibility language using {@link IAccessibleElement#getAccessibilityProperties()}. * * @return the accessibility language. */ @@ -157,9 +158,6 @@ protected String getLang() { if (this.getModelElement() instanceof IAccessibleElement) { language = ((IAccessibleElement) this.getModelElement()).getAccessibilityProperties().getLanguage(); } - if (language == null){ - language = this.getProperty(FormProperty.FORM_ACCESSIBILITY_LANGUAGE); - } return language; } @@ -240,7 +238,7 @@ protected String getModelId() { * @param field {@link AbstractSelectField} to retrieve the options from */ protected void setupBuilderValues(ChoiceFormFieldBuilder builder, AbstractSelectField field) { - List options = field.getItems(); + List options = field.getOptions(); if (options.isEmpty()) { builder.setOptions(new String[0]); return; @@ -290,42 +288,23 @@ protected float getFinalSelectFieldHeight(float availableHeight, float actualHei } /** - * Gets the conformance level. If the conformance level is not set, the conformance level of the document is used. + * Gets the conformance. If the conformance is not set, the conformance of the document is used. * * @param document the document * - * @return the conformance level or null if the conformance level is not set. - * @deprecated since 8.0.4 will be return {@link IConformanceLevel} + * @return the conformance or null if the conformance is not set. */ - @Deprecated - protected PdfAConformanceLevel getConformanceLevel(PdfDocument document) { - return PdfAConformanceLevel.getPDFAConformance(this.getProperty( - FormProperty.FORM_CONFORMANCE_LEVEL),document); - } - - /** - * Gets the conformance level. If the conformance level is not set, the conformance level of the document is used. - * - * @param document the document - * - * @return the conformance level or null if the conformance level is not set. - * - * @deprecated since 8.0.4 will be renamed to getConformanceLevel() - */ - @Deprecated - protected IConformanceLevel getGenericConformanceLevel(PdfDocument document) { - final IConformanceLevel conformanceLevel = this.getProperty( - FormProperty.FORM_CONFORMANCE_LEVEL); - if (conformanceLevel != null) { - return conformanceLevel; + protected PdfConformance getConformance(PdfDocument document) { + final PdfConformance conformance = this.getProperty(FormProperty.FORM_CONFORMANCE_LEVEL); + if (conformance != null) { + return conformance; } if (document == null) { return null; } - return document.getConformanceLevel(); + return document.getConformance(); } - /** * Gets options that are marked as selected from the select field options subtree. * diff --git a/forms/src/main/java/com/itextpdf/forms/form/renderer/ButtonRenderer.java b/forms/src/main/java/com/itextpdf/forms/form/renderer/ButtonRenderer.java index 3076d79964..83988c0d1a 100644 --- a/forms/src/main/java/com/itextpdf/forms/form/renderer/ButtonRenderer.java +++ b/forms/src/main/java/com/itextpdf/forms/form/renderer/ButtonRenderer.java @@ -272,7 +272,7 @@ protected void applyAcroField(DrawContext drawContext) { modelElement.setProperty(Property.RENDERING_MODE, this.getProperty(Property.RENDERING_MODE)); final PdfButtonFormField button = new PushButtonFormFieldBuilder(doc, name).setWidgetRectangle(area) .setFont(font) - .setGenericConformanceLevel(getGenericConformanceLevel(doc)) + .setConformance(getConformance(doc)) .createPushButton(); button.disableFieldRegeneration(); button.setFontSize(fontSizeValue); diff --git a/forms/src/main/java/com/itextpdf/forms/form/renderer/CheckBoxRenderer.java b/forms/src/main/java/com/itextpdf/forms/form/renderer/CheckBoxRenderer.java index 05381253ea..c02ce26dcf 100644 --- a/forms/src/main/java/com/itextpdf/forms/form/renderer/CheckBoxRenderer.java +++ b/forms/src/main/java/com/itextpdf/forms/form/renderer/CheckBoxRenderer.java @@ -36,8 +36,7 @@ This file is part of the iText (R) project. import com.itextpdf.forms.util.BorderStyleUtil; import com.itextpdf.forms.util.FormFieldRendererUtil; import com.itextpdf.kernel.geom.Rectangle; -import com.itextpdf.kernel.pdf.IConformanceLevel; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfConformance; import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfPage; import com.itextpdf.kernel.pdf.canvas.PdfCanvas; @@ -103,19 +102,6 @@ public RenderingMode getRenderingMode() { return RenderingMode.DEFAULT_LAYOUT_MODE; } - /** - * Returns whether or not the checkbox is in PDF/A mode. - * - * @return true if the checkbox is in PDF/A mode, false otherwise - * - * @deprecated since 8.0.4 will be removed - */ - @Deprecated - public boolean isPdfA() { - IConformanceLevel conformanceLevel = this.getProperty(FormProperty.FORM_CONFORMANCE_LEVEL); - return conformanceLevel instanceof PdfAConformanceLevel; - } - /** * Gets the checkBoxType. * @@ -128,7 +114,6 @@ public CheckBoxType getCheckBoxType() { return CheckBoxType.CROSS; } - /** * creates a ICheckBoxRenderingStrategy based on the current settings. * @@ -137,8 +122,8 @@ public CheckBoxType getCheckBoxType() { public ICheckBoxRenderingStrategy createCheckBoxRenderStrategy() { // html rendering is PDFA compliant this means we don't have to check if its PDFA. ICheckBoxRenderingStrategy renderingStrategy; - boolean isConformantPdfDocument = - this.getProperty(FormProperty.FORM_CONFORMANCE_LEVEL) != null; + final PdfConformance conformance = this.getProperty(FormProperty.FORM_CONFORMANCE_LEVEL); + boolean isConformantPdfDocument = conformance != null && conformance.isPdfAOrUa(); if (getRenderingMode() == RenderingMode.HTML_MODE) { renderingStrategy = new HtmlCheckBoxRenderingStrategy(); } else if (getRenderingMode() == RenderingMode.DEFAULT_LAYOUT_MODE && isConformantPdfDocument) { @@ -240,7 +225,10 @@ public IRenderer createFlatRenderer() { paragraph.setProperty(Property.BOX_SIZING, this.getProperty(Property.BOX_SIZING)); modelElement.setProperty(Property.RENDERING_MODE, this.getProperty(Property.RENDERING_MODE)); - paragraph.setBorder(this.getProperty(Property.BORDER)); + paragraph.setBorderTop(this.getProperty(Property.BORDER_TOP)); + paragraph.setBorderRight(this.getProperty(Property.BORDER_RIGHT)); + paragraph.setBorderBottom(this.getProperty(Property.BORDER_BOTTOM)); + paragraph.setBorderLeft(this.getProperty(Property.BORDER_LEFT)); paragraph.setProperty(Property.BACKGROUND, this.getProperty(Property.BACKGROUND)); //In html 2 pdf rendering the boxes height width ratio is always 1:1 @@ -264,7 +252,7 @@ protected void applyAcroField(DrawContext drawContext) { final Map properties = FormFieldRendererUtil.removeProperties(this.modelElement); final PdfPage page = doc.getPage(occupiedArea.getPageNumber()); final CheckBoxFormFieldBuilder builder = new CheckBoxFormFieldBuilder(doc, name).setWidgetRectangle(area) - .setGenericConformanceLevel(this.getProperty(FormProperty.FORM_CONFORMANCE_LEVEL)); + .setConformance(this.getProperty(FormProperty.FORM_CONFORMANCE_LEVEL)); if (this.hasProperty(FormProperty.FORM_CHECKBOX_TYPE)) { builder.setCheckType((CheckBoxType) this.getProperty(FormProperty.FORM_CHECKBOX_TYPE)); diff --git a/forms/src/main/java/com/itextpdf/forms/form/renderer/InputFieldRenderer.java b/forms/src/main/java/com/itextpdf/forms/form/renderer/InputFieldRenderer.java index 89a4ca4bb5..3c16091b44 100644 --- a/forms/src/main/java/com/itextpdf/forms/form/renderer/InputFieldRenderer.java +++ b/forms/src/main/java/com/itextpdf/forms/form/renderer/InputFieldRenderer.java @@ -24,7 +24,7 @@ This file is part of the iText (R) project. import com.itextpdf.commons.utils.MessageFormatUtil; import com.itextpdf.forms.fields.PdfFormCreator; -import com.itextpdf.forms.fields.PdfFormField; +import com.itextpdf.forms.fields.PdfTextFormField; import com.itextpdf.forms.fields.TextFormFieldBuilder; import com.itextpdf.forms.form.FormProperty; import com.itextpdf.forms.form.element.InputField; @@ -35,12 +35,15 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfPage; import com.itextpdf.kernel.pdf.PdfString; +import com.itextpdf.layout.element.Paragraph; +import com.itextpdf.layout.element.Text; import com.itextpdf.layout.font.FontProvider; import com.itextpdf.layout.layout.LayoutContext; import com.itextpdf.layout.minmaxwidth.MinMaxWidth; import com.itextpdf.layout.properties.BoxSizingPropertyValue; import com.itextpdf.layout.properties.Property; import com.itextpdf.layout.properties.RenderingMode; +import com.itextpdf.layout.properties.TextAlignment; import com.itextpdf.layout.properties.UnitValue; import com.itextpdf.layout.renderer.DrawContext; import com.itextpdf.layout.renderer.IRenderer; @@ -57,6 +60,8 @@ This file is part of the iText (R) project. */ public class InputFieldRenderer extends AbstractOneLineTextFieldRenderer { + private static final float DEFAULT_COMB_PADDING = 0; + /** * Creates a new {@link InputFieldRenderer} instance. * @@ -104,8 +109,47 @@ IRenderer createParagraphRenderer(String defaultValue) { && !((InputField) modelElement).getPlaceholder().isEmpty()) { return ((InputField) modelElement).getPlaceholder().createRendererSubTree(); } + if (defaultValue.isEmpty()) { + defaultValue = "\u00a0"; + } + IRenderer flatRenderer; + if (isComb()) { + setProperty(Property.PADDING_LEFT, UnitValue.createPointValue(DEFAULT_COMB_PADDING)); + setProperty(Property.PADDING_RIGHT, UnitValue.createPointValue(DEFAULT_COMB_PADDING)); + + int maxLen = getMaxLen(); + int numberOfCharacters = Math.min(maxLen, defaultValue.length()); + + int start; + TextAlignment textAlignment = this.getProperty(Property.TEXT_ALIGNMENT, TextAlignment.LEFT); + switch (textAlignment) { + case RIGHT: + start = (maxLen - numberOfCharacters); + break; + case CENTER: + start = (maxLen - numberOfCharacters) / 2; + break; + default: + start = 0; + } + Paragraph paragraph = new Paragraph(); + for (int i = 0; i < start; i++) { + paragraph.add(getSubParagraph("", maxLen)); + } + for (int i = 0; i < numberOfCharacters; i++) { + paragraph.add(getSubParagraph(defaultValue.substring(i, i + 1), maxLen)); + } + for (int i = start + numberOfCharacters; i < maxLen; i++) { + paragraph.add(getSubParagraph("", maxLen)); + } + flatRenderer = paragraph.setMargin(0).createRendererSubTree(); + } else { + Text text = new Text(defaultValue); + FormFieldValueNonTrimmingTextRenderer nextRenderer = new FormFieldValueNonTrimmingTextRenderer(text); + text.setNextRenderer(nextRenderer); - IRenderer flatRenderer = super.createParagraphRenderer(defaultValue); + flatRenderer = new Paragraph(text).setMargin(0).createRendererSubTree(); + } flatRenderer.setProperty(Property.NO_SOFT_WRAP_INLINE, true); return flatRenderer; } @@ -176,18 +220,22 @@ protected void applyAcroField(DrawContext drawContext) { // Default html2pdf input field appearance differs from the default one for form fields. // That's why we got rid of several properties we set by default during InputField instance creation. modelElement.setProperty(Property.BOX_SIZING, BoxSizingPropertyValue.BORDER_BOX); - final PdfFormField inputField = new TextFormFieldBuilder(doc, name).setWidgetRectangle(area) + final PdfTextFormField inputField = new TextFormFieldBuilder(doc, name).setWidgetRectangle(area) .setFont(font) - .setGenericConformanceLevel(getGenericConformanceLevel(doc)) + .setConformance(getConformance(doc)) .createText(); inputField.disableFieldRegeneration(); inputField.setValue(value); inputField.setFontSize(fontSizeValue); if (password) { - inputField.setFieldFlag(PdfFormField.FF_PASSWORD, true); + inputField.setPassword(true); } else { inputField.setDefaultValue(new PdfString(value)); } + if (isComb()) { + inputField.setComb(true); + inputField.setMaxLen(getMaxLen()); + } final int rotation = ((InputField)modelElement).getRotation(); if (rotation != 0) { inputField.getFirstFormAnnotation().setRotation(rotation); @@ -251,6 +299,36 @@ protected boolean setMinMaxWidthBasedOnFixedWidth(MinMaxWidth minMaxWidth) { return result; } + private static Paragraph getSubParagraph(String value, int maxLen) { + Text text = new Text(value); + FormFieldValueNonTrimmingTextRenderer nextRenderer = new FormFieldValueNonTrimmingTextRenderer(text); + text.setNextRenderer(nextRenderer); + + return new Paragraph(text) + .setTextAlignment(TextAlignment.CENTER) + .setWidth(UnitValue.createPercentValue((float) 100 / maxLen)) + .setHeight(UnitValue.createPercentValue(100)) + .setMargin(0); + } + + /** + * Checks if the input field is a comb field. + * + * @return true, if the input field is a comb field + */ + private boolean isComb() { + return (boolean) this.getProperty(FormProperty.TEXT_FIELD_COMB_FLAG, false); + } + + /** + * Gets the maximum length of the field's text, in characters. + * + * @return the current maximum text length + */ + private int getMaxLen() { + return (int) this.getProperty(FormProperty.TEXT_FIELD_MAX_LEN, 0); + } + /** * Obfuscates the content of a password input field. * diff --git a/forms/src/main/java/com/itextpdf/forms/form/renderer/RadioRenderer.java b/forms/src/main/java/com/itextpdf/forms/form/renderer/RadioRenderer.java index dd7dab313d..6bc58fb6aa 100644 --- a/forms/src/main/java/com/itextpdf/forms/form/renderer/RadioRenderer.java +++ b/forms/src/main/java/com/itextpdf/forms/form/renderer/RadioRenderer.java @@ -142,7 +142,10 @@ protected IRenderer createFlatRenderer() { .setVerticalAlignment(DEFAULT_VERTICAL_ALIGNMENT) .setMargin(0); paragraph.setProperty(Property.BOX_SIZING, this.getProperty(Property.BOX_SIZING)); - paragraph.setBorder(this.getProperty(Property.BORDER)); + paragraph.setBorderTop(this.getProperty(Property.BORDER_TOP)); + paragraph.setBorderRight(this.getProperty(Property.BORDER_RIGHT)); + paragraph.setBorderBottom(this.getProperty(Property.BORDER_BOTTOM)); + paragraph.setBorderLeft(this.getProperty(Property.BORDER_LEFT)); paragraph.setProperty(Property.BACKGROUND, this.getProperty(Property.BACKGROUND)); paragraph.setBorderRadius(new BorderRadius(UnitValue.createPercentValue(50))); @@ -185,7 +188,7 @@ protected void applyAcroField(DrawContext drawContext) { PdfButtonFormField radioGroup = (PdfButtonFormField) form.getField(groupName); if (null == radioGroup) { radioGroup = new RadioFormFieldBuilder(doc, groupName) - .setGenericConformanceLevel(getGenericConformanceLevel(doc)) + .setConformance(getConformance(doc)) .createRadioGroup(); radioGroup.disableFieldRegeneration(); radioGroup.setValue(PdfFormAnnotation.OFF_STATE_VALUE); @@ -197,7 +200,7 @@ protected void applyAcroField(DrawContext drawContext) { } PdfFormAnnotation radio = new RadioFormFieldBuilder(doc, null) - .setGenericConformanceLevel(getGenericConformanceLevel(doc)) + .setConformance(getConformance(doc)) .createRadioButton(getModelId(), area); radio.disableFieldRegeneration(); @@ -248,11 +251,14 @@ public void drawChildren(DrawContext drawContext) { canvas.openTag(tp.getTagReference()); } Rectangle rectangle = getOccupiedArea().getBBox().clone(); - Border border = this.getProperty(Property.BORDER); - if (border != null) { - rectangle.applyMargins(border.getWidth(), border.getWidth(), border.getWidth(), border.getWidth(), - false); - } + Border borderTop = this.getProperty(Property.BORDER_TOP); + Border borderRight = this.getProperty(Property.BORDER_RIGHT); + Border borderBottom = this.getProperty(Property.BORDER_BOTTOM); + Border borderLeft = this.getProperty(Property.BORDER_LEFT); + rectangle.applyMargins(borderTop == null ? 0 : borderTop.getWidth(), + borderRight == null ? 0 : borderRight.getWidth(), + borderBottom == null ? 0 : borderBottom.getWidth(), + borderLeft == null ? 0 : borderLeft.getWidth(), false); final float radius = Math.min(rectangle.getWidth(), rectangle.getHeight()) / 2; canvas.saveState(); canvas.setFillColor(DEFAULT_CHECKED_COLOR); diff --git a/forms/src/main/java/com/itextpdf/forms/form/renderer/SelectFieldComboBoxRenderer.java b/forms/src/main/java/com/itextpdf/forms/form/renderer/SelectFieldComboBoxRenderer.java index 3c03dda2c8..13ceb33f03 100644 --- a/forms/src/main/java/com/itextpdf/forms/form/renderer/SelectFieldComboBoxRenderer.java +++ b/forms/src/main/java/com/itextpdf/forms/form/renderer/SelectFieldComboBoxRenderer.java @@ -117,7 +117,7 @@ protected void applyAcroField(DrawContext drawContext) { final ChoiceFormFieldBuilder builder = new ChoiceFormFieldBuilder(doc, name).setWidgetRectangle(area) .setFont(font) - .setGenericConformanceLevel(getGenericConformanceLevel(doc)); + .setConformance(getConformance(doc)); applyMargins(area, false); final Map properties = FormFieldRendererUtil.removeProperties(this.modelElement); @@ -178,7 +178,7 @@ private UnitValue getFontSize() { private IRenderer createFlatRenderer(boolean addAllOptionsToChildren) { AbstractSelectField selectField = (AbstractSelectField) modelElement; - List options = selectField.getItems(); + List options = selectField.getOptions(); Div pseudoContainer = new Div(); for (SelectFieldItem option : options) { @@ -281,7 +281,7 @@ private void processLangAttribute(Paragraph optionFlatElement, IRenderer origina IPropertyContainer propertyContainer = originalOptionRenderer.getModelElement(); if (propertyContainer instanceof IAccessibleElement) { String lang = ((IAccessibleElement) propertyContainer).getAccessibilityProperties().getLanguage(); - AccessibilityProperties properties = ((IAccessibleElement) optionFlatElement).getAccessibilityProperties(); + AccessibilityProperties properties = optionFlatElement.getAccessibilityProperties(); if (properties.getLanguage() == null) { properties.setLanguage(lang); } diff --git a/forms/src/main/java/com/itextpdf/forms/form/renderer/SelectFieldListBoxRenderer.java b/forms/src/main/java/com/itextpdf/forms/form/renderer/SelectFieldListBoxRenderer.java index 4a3e36cd72..77420ec162 100644 --- a/forms/src/main/java/com/itextpdf/forms/form/renderer/SelectFieldListBoxRenderer.java +++ b/forms/src/main/java/com/itextpdf/forms/form/renderer/SelectFieldListBoxRenderer.java @@ -29,6 +29,7 @@ This file is part of the iText (R) project. import com.itextpdf.forms.form.FormProperty; import com.itextpdf.forms.form.element.AbstractSelectField; import com.itextpdf.forms.form.element.ListBoxField; +import com.itextpdf.forms.form.element.SelectFieldItem; import com.itextpdf.forms.util.BorderStyleUtil; import com.itextpdf.forms.util.FormFieldRendererUtil; import com.itextpdf.io.logs.IoLogMessageConstant; @@ -40,7 +41,6 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfPage; import com.itextpdf.kernel.pdf.tagutils.AccessibilityProperties; import com.itextpdf.layout.element.Div; -import com.itextpdf.layout.element.IBlockElement; import com.itextpdf.layout.element.Paragraph; import com.itextpdf.layout.font.FontProvider; import com.itextpdf.layout.layout.LayoutContext; @@ -125,11 +125,13 @@ protected boolean allowLastYLineRecursiveExtraction() { @Override protected IRenderer createFlatRenderer() { AbstractSelectField selectField = (AbstractSelectField) modelElement; - List options = selectField.getOptions(); + List options = selectField.getOptions(); Div optionsContainer = new Div(); - for (IBlockElement option : options) { - optionsContainer.add(option); + int topIndex = (int) this.getProperty(FormProperty.LIST_BOX_TOP_INDEX, 0); + List visibleOptions = topIndex > 0 ? options.subList(topIndex, options.size()) : options; + for (SelectFieldItem option : visibleOptions) { + optionsContainer.add(option.getElement()); } String lang = getLang(); if (lang != null) { @@ -206,7 +208,7 @@ protected void applyAcroField(DrawContext drawContext) { ListBoxField lbModelElement = (ListBoxField) modelElement; List selectedOptions = lbModelElement.getSelectedStrings(); ChoiceFormFieldBuilder builder = new ChoiceFormFieldBuilder(doc, getModelId()) - .setGenericConformanceLevel(getGenericConformanceLevel(doc)) + .setConformance(getConformance(doc)) .setFont(font) .setWidgetRectangle(area); setupBuilderValues(builder, lbModelElement); @@ -217,6 +219,11 @@ protected void applyAcroField(DrawContext drawContext) { choiceField.setMultiSelect(isMultiple()); choiceField.setListSelected(selectedOptions.toArray(new String[selectedOptions.size()])); + Integer topIndex = modelElement.getOwnProperty(FormProperty.LIST_BOX_TOP_INDEX); + if (topIndex != null) { + choiceField.setTopIndex((int) topIndex); + } + TransparentColor color = getPropertyAsTransparentColor(Property.FONT_COLOR); if (color != null) { choiceField.setColor(color.getColor()); @@ -304,7 +311,13 @@ private boolean isMultiple() { } private void applySelectedStyle(IRenderer selectedOption) { - selectedOption.setProperty(Property.BACKGROUND, new Background(new DeviceRgb(0, 120, 215))); + RenderingMode mode = this.getProperty(Property.RENDERING_MODE); + if (RenderingMode.HTML_MODE.equals(mode) && isFlatten() && + selectedOption.getProperty(Property.BACKGROUND) == null) { + selectedOption.setProperty(Property.BACKGROUND, new Background(new DeviceRgb(206,206,206))); + } else { + selectedOption.setProperty(Property.BACKGROUND, new Background(new DeviceRgb(169, 204, 225))); + } setFontColorRecursively(selectedOption); } @@ -314,7 +327,7 @@ private void applySelectedStyle(IRenderer selectedOption) { * otherwise it will be not applied due to the css resolving mechanism. */ private void setFontColorRecursively(IRenderer selectedOption) { - selectedOption.setProperty(Property.FONT_COLOR, new TransparentColor(ColorConstants.WHITE)); + selectedOption.setProperty(Property.FONT_COLOR, new TransparentColor(ColorConstants.BLACK)); for (IRenderer renderer : selectedOption.getChildRenderers()) { setFontColorRecursively(renderer); } diff --git a/forms/src/main/java/com/itextpdf/forms/form/renderer/SignatureAppearanceRenderer.java b/forms/src/main/java/com/itextpdf/forms/form/renderer/SignatureAppearanceRenderer.java index 611c9bf73b..ceda2c49e0 100644 --- a/forms/src/main/java/com/itextpdf/forms/form/renderer/SignatureAppearanceRenderer.java +++ b/forms/src/main/java/com/itextpdf/forms/form/renderer/SignatureAppearanceRenderer.java @@ -257,7 +257,7 @@ protected void applyAcroField(DrawContext drawContext) { modelElement.setProperty(Property.FONT_PROVIDER, this.getProperty(Property.FONT_PROVIDER)); modelElement.setProperty(Property.RENDERING_MODE, this.getProperty(Property.RENDERING_MODE)); final PdfSignatureFormField sigField = new SignatureFormFieldBuilder(doc, name).setWidgetRectangle(area) - .setGenericConformanceLevel(getGenericConformanceLevel(doc)) + .setConformance(getConformance(doc)) .setFont(font) .createSignature(); sigField.disableFieldRegeneration(); diff --git a/forms/src/main/java/com/itextpdf/forms/form/renderer/TextAreaRenderer.java b/forms/src/main/java/com/itextpdf/forms/form/renderer/TextAreaRenderer.java index 86b48d5520..8015b87ac9 100644 --- a/forms/src/main/java/com/itextpdf/forms/form/renderer/TextAreaRenderer.java +++ b/forms/src/main/java/com/itextpdf/forms/form/renderer/TextAreaRenderer.java @@ -203,7 +203,7 @@ protected void applyAcroField(DrawContext drawContext) { // That's why we got rid of several properties we set by default during TextArea instance creation. modelElement.setProperty(Property.BOX_SIZING, BoxSizingPropertyValue.BORDER_BOX); final PdfFormField inputField = new TextFormFieldBuilder(doc, name).setWidgetRectangle(area) - .setGenericConformanceLevel(getGenericConformanceLevel(doc)) + .setConformance(getConformance(doc)) .setFont(font) .createMultilineText(); inputField.disableFieldRegeneration(); diff --git a/forms/src/main/java/com/itextpdf/forms/form/renderer/checkboximpl/PdfCheckBoxRenderingStrategy.java b/forms/src/main/java/com/itextpdf/forms/form/renderer/checkboximpl/PdfCheckBoxRenderingStrategy.java index 0c5570e42b..ac45a13ea8 100644 --- a/forms/src/main/java/com/itextpdf/forms/form/renderer/checkboximpl/PdfCheckBoxRenderingStrategy.java +++ b/forms/src/main/java/com/itextpdf/forms/form/renderer/checkboximpl/PdfCheckBoxRenderingStrategy.java @@ -71,33 +71,57 @@ public void drawCheckBoxContent(DrawContext drawContext, CheckBoxRenderer checkB if (!checkBoxRenderer.isBoxChecked()) { return; } - float borderWidth = CheckBoxRenderer.DEFAULT_BORDER_WIDTH; - final Border border = checkBoxRenderer.getProperty(Property.BORDER); - if (border != null) { - borderWidth = border.getWidth(); - rectangle.applyMargins(borderWidth, borderWidth, borderWidth, borderWidth, true); - } + Border borderTop = checkBoxRenderer.getProperty(Property.BORDER_TOP); + Border borderRight = checkBoxRenderer.getProperty(Property.BORDER_RIGHT); + Border borderBottom = checkBoxRenderer.getProperty(Property.BORDER_BOTTOM); + Border borderLeft = checkBoxRenderer.getProperty(Property.BORDER_LEFT); + rectangle.applyMargins(borderTop == null ? 0 : borderTop.getWidth(), + borderRight == null ? 0 : borderRight.getWidth(), + borderBottom == null ? 0 : borderBottom.getWidth(), + borderLeft == null ? 0 : borderLeft.getWidth(), true); final PdfCanvas canvas = drawContext.getCanvas(); canvas.saveState(); canvas.setFillColor(ColorConstants.BLACK); // matrix transformation to draw the checkbox in the right place // because we come here with relative and not absolute coordinates canvas.concatMatrix(1, 0, 0, 1, rectangle.getLeft(), rectangle.getBottom()); - final CheckBoxType checkBoxType = checkBoxRenderer.getCheckBoxType(); if (checkBoxType == CheckBoxType.CROSS || checkBoxType == null) { - final float customBorderWidth = border == null ? 1 : borderWidth; + final float customBorderWidth = retrieveBorderWidth(1, borderTop, borderRight, borderBottom, borderLeft); DrawingUtil.drawCross(canvas, rectangle.getWidth(), rectangle.getHeight(), customBorderWidth); } else { final String text = ZAPFDINGBATS_CHECKBOX_MAPPING.getByKey(checkBoxType); final PdfFont fontContainingSymbols = loadFontContainingSymbols(); - float fontSize = calculateFontSize(checkBoxRenderer, fontContainingSymbols, text, rectangle, borderWidth); + float fontSize = calculateFontSize(checkBoxRenderer, fontContainingSymbols, text, rectangle, + retrieveBorderWidth(CheckBoxRenderer.DEFAULT_BORDER_WIDTH, + borderTop, borderRight, borderBottom, borderLeft)); drawZapfdingbatsIcon(fontContainingSymbols, text, fontSize, rectangle, canvas); } canvas.restoreState(); } + private static float retrieveBorderWidth(float defaultWidth, Border borderTop, Border borderRight, Border borderBottom, + Border borderLeft) { + if (borderTop == null && borderRight == null && borderBottom == null && borderLeft == null) { + return defaultWidth; + } + float borderWidth = 0; + if (borderTop != null) { + borderWidth = Math.max(borderWidth, borderTop.getWidth()); + } + if (borderRight != null) { + borderWidth = Math.max(borderWidth, borderRight.getWidth()); + } + if (borderBottom != null) { + borderWidth = Math.max(borderWidth, borderBottom.getWidth()); + } + if (borderLeft != null) { + borderWidth = Math.max(borderWidth, borderLeft.getWidth()); + } + return borderWidth; + } + private PdfFont loadFontContainingSymbols() { try { return PdfFontFactory.createFont(StandardFonts.ZAPFDINGBATS); diff --git a/forms/src/main/java/com/itextpdf/forms/util/BorderStyleUtil.java b/forms/src/main/java/com/itextpdf/forms/util/BorderStyleUtil.java index f4602b5732..f8c43b85fa 100644 --- a/forms/src/main/java/com/itextpdf/forms/util/BorderStyleUtil.java +++ b/forms/src/main/java/com/itextpdf/forms/util/BorderStyleUtil.java @@ -43,11 +43,8 @@ public final class BorderStyleUtil { * @param annotation the annotation to set border characteristics to. */ public static void applyBorderProperty(IPropertyContainer container, PdfFormAnnotation annotation) { - Border border = container.getProperty(Property.BORDER); - if (border == null) { - // For now, we set left border to an annotation, but appropriate borders for an element will be drawn. - border = container.getProperty(Property.BORDER_LEFT); - } + // For now, we set left border to an annotation, but appropriate borders for an element will be drawn. + Border border = container.getProperty(Property.BORDER_LEFT); if (border != null) { annotation.setBorderStyle(transformBorderTypeToBorderStyleDictionary(border.getType())); annotation.setBorderColor(border.getColor()); diff --git a/forms/src/test/java/com/itextpdf/forms/FlatteningRotatedTest.java b/forms/src/test/java/com/itextpdf/forms/FlatteningRotatedTest.java index 74b899d824..6fa82a2ff1 100644 --- a/forms/src/test/java/com/itextpdf/forms/FlatteningRotatedTest.java +++ b/forms/src/test/java/com/itextpdf/forms/FlatteningRotatedTest.java @@ -30,28 +30,22 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfWriter; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; import java.util.ArrayList; import java.util.Collection; import java.util.List; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(Parameterized.class) -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class FlatteningRotatedTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/forms/FlatteningRotatedTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/forms/FlatteningRotatedTest/"; - private final String inputPdfFileName; - - @Parameterized.Parameters(name = "{0}") public static Collection inputFileNames() { List inputFileNames = new ArrayList(); for (int pageRot = 0; pageRot < 360; pageRot += 90) { @@ -62,17 +56,14 @@ public static Collection inputFileNames() { return inputFileNames; } - public FlatteningRotatedTest(Object inputPdfFileName) { - this.inputPdfFileName = (String) inputPdfFileName; - } - - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } - @Test - public void formFlatteningTest_DefaultAppearanceGeneration_Rot() throws IOException, InterruptedException { + @ParameterizedTest(name = "{0}") + @MethodSource("inputFileNames") + public void formFlatteningTest_DefaultAppearanceGeneration_Rot(String inputPdfFileName) throws IOException, InterruptedException { String src = sourceFolder + inputPdfFileName + ".pdf"; String dest = destinationFolder + inputPdfFileName + ".pdf"; String dest_flattened = destinationFolder + inputPdfFileName + "_flattened.pdf"; @@ -87,11 +78,11 @@ public void formFlatteningTest_DefaultAppearanceGeneration_Rot() throws IOExcept field.getFirstFormAnnotation().setBorderColor(ColorConstants.BLUE); } } - Assert.assertNull(new CompareTool().compareByContent(dest, cmp, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(dest, cmp, destinationFolder, "diff_")); try (PdfDocument doc = new PdfDocument(new PdfReader(dest), new PdfWriter(dest_flattened))) { PdfFormCreator.getAcroForm(doc, true).flattenFields(); } - Assert.assertNull(new CompareTool().compareByContent(dest_flattened, cmp_flattened, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(dest_flattened, cmp_flattened, destinationFolder, "diff_")); } } diff --git a/forms/src/test/java/com/itextpdf/forms/FlatteningTest.java b/forms/src/test/java/com/itextpdf/forms/FlatteningTest.java index 5a7e49649c..c225ebe7d8 100644 --- a/forms/src/test/java/com/itextpdf/forms/FlatteningTest.java +++ b/forms/src/test/java/com/itextpdf/forms/FlatteningTest.java @@ -34,20 +34,18 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; - +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class FlatteningTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/forms/FlatteningTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/forms/FlatteningTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } @@ -63,7 +61,7 @@ public void flatteningFormFieldNoSubtypeInAPTest() throws IOException, Interrupt PdfFormCreator.getAcroForm(doc, false).flattenFields(); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(dest, cmp, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(dest, cmp, destinationFolder, "diff_")); } @Test @@ -80,7 +78,7 @@ public void formFlatteningTestWithoutNEntry() throws IOException, InterruptedExc acroForm.flattenFields(); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(dest, cmp, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(dest, cmp, destinationFolder, "diff_")); } @Test @@ -95,6 +93,6 @@ public void hiddenFieldsFlatten() throws IOException { acroForm.flattenFields(); String textAfterFlatten = PdfTextExtractor.getTextFromPage(document.getPage(1)); document.close(); - Assert.assertTrue("Pdf does not contain the expected text", textAfterFlatten.contains("hiddenFieldValue")); + Assertions.assertTrue(textAfterFlatten.contains("hiddenFieldValue"), "Pdf does not contain the expected text"); } } diff --git a/forms/src/test/java/com/itextpdf/forms/FlatteningWithNullKidElementTest.java b/forms/src/test/java/com/itextpdf/forms/FlatteningWithNullKidElementTest.java index 3b361c8399..cad3c95f85 100644 --- a/forms/src/test/java/com/itextpdf/forms/FlatteningWithNullKidElementTest.java +++ b/forms/src/test/java/com/itextpdf/forms/FlatteningWithNullKidElementTest.java @@ -27,20 +27,18 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfReader; import com.itextpdf.kernel.pdf.PdfWriter; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; - +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class FlatteningWithNullKidElementTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/forms/FlatteningWithNullKidElementTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/forms/FlatteningWithNullKidElementTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } @@ -64,7 +62,7 @@ public void formFlatteningTestWithNullKidElement() throws IOException { fail=true; } - Assert.assertFalse(fail); + Assertions.assertFalse(fail); } diff --git a/forms/src/test/java/com/itextpdf/forms/FormFieldAppendTest.java b/forms/src/test/java/com/itextpdf/forms/FormFieldAppendTest.java index 131eb0dd6e..cb4c13b3f3 100644 --- a/forms/src/test/java/com/itextpdf/forms/FormFieldAppendTest.java +++ b/forms/src/test/java/com/itextpdf/forms/FormFieldAppendTest.java @@ -30,23 +30,20 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.StampingProperties; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; - -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; import java.io.File; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class FormFieldAppendTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/forms/FormFieldAppendTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/forms/FormFieldAppendTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } @@ -76,7 +73,7 @@ public void formFillingAppend_form_empty_Test() throws IOException, InterruptedE CompareTool compareTool = new CompareTool(); String errorMessage = compareTool.compareByContent(filename, sourceFolder + "cmp_formFillingAppend_form_empty.pdf", destinationFolder, "diff_"); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -104,7 +101,7 @@ public void formFillingAppend_form_filled_Test() throws IOException, Interrupted CompareTool compareTool = new CompareTool(); String errorMessage = compareTool.compareByContent(filename, sourceFolder + "cmp_formFillingAppend_form_filled.pdf", destinationFolder, "diff_"); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } diff --git a/forms/src/test/java/com/itextpdf/forms/FormFieldFlatteningTest.java b/forms/src/test/java/com/itextpdf/forms/FormFieldFlatteningTest.java index 433ca73427..8f882481d3 100644 --- a/forms/src/test/java/com/itextpdf/forms/FormFieldFlatteningTest.java +++ b/forms/src/test/java/com/itextpdf/forms/FormFieldFlatteningTest.java @@ -37,22 +37,21 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.ByteArrayOutputStream; import java.io.IOException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class FormFieldFlatteningTest extends ExtendedITextTest { public static final String destinationFolder = "./target/test/com/itextpdf/forms/FormFieldFlatteningTest/"; public static final String sourceFolder = "./src/test/resources/com/itextpdf/forms/FormFieldFlatteningTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } @@ -65,7 +64,7 @@ public void getFieldsForFlatteningTest() throws IOException { PdfAcroForm form = PdfFormCreator.getAcroForm(pdfDoc, false); - Assert.assertEquals(0, form.getFieldsForFlattening().size()); + Assertions.assertEquals(0, form.getFieldsForFlattening().size()); form.partialFormFlattening("radioName"); form.partialFormFlattening("Text1"); @@ -73,9 +72,9 @@ public void getFieldsForFlatteningTest() throws IOException { PdfFormField radioNameField = form.getField("radioName"); PdfFormField text1Field = form.getField("Text1"); - Assert.assertEquals(2, form.getFieldsForFlattening().size()); - Assert.assertTrue(form.getFieldsForFlattening().contains(radioNameField)); - Assert.assertTrue(form.getFieldsForFlattening().contains(text1Field)); + Assertions.assertEquals(2, form.getFieldsForFlattening().size()); + Assertions.assertTrue(form.getFieldsForFlattening().contains(radioNameField)); + Assertions.assertTrue(form.getFieldsForFlattening().contains(text1Field)); form.flattenFields(); pdfDoc.close(); @@ -83,7 +82,7 @@ public void getFieldsForFlatteningTest() throws IOException { PdfDocument outPdfDoc = new PdfDocument(new PdfReader(outPdfName)); PdfAcroForm outPdfForm = PdfFormCreator.getAcroForm(outPdfDoc, false); - Assert.assertEquals(2, outPdfForm.getAllFormFields().size()); + Assertions.assertEquals(2, outPdfForm.getAllFormFields().size()); outPdfDoc.close(); } @@ -116,7 +115,7 @@ public void multiLineFormFieldClippingTest() throws IOException, InterruptedExce form.flattenFields(); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(dest, cmp, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(dest, cmp, destinationFolder, "diff_")); } @Test @@ -174,7 +173,7 @@ private static void flattenFieldsAndCompare(String srcFile, String outFile) "diff_"); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -234,7 +233,7 @@ private static void fillTextFieldsThenFlattenThenCompare(String testName) throws form.flattenFields(); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(dest, cmp, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(dest, cmp, destinationFolder, "diff_")); } @Test @@ -257,7 +256,7 @@ public void flattenReadOnly() throws IOException { isReadOnly = (isReadOnly && field.isReadOnly()); } pdfDoc.close(); - Assert.assertTrue(isReadOnly); + Assertions.assertTrue(isReadOnly); } @Test diff --git a/forms/src/test/java/com/itextpdf/forms/FormFieldsTaggingTest.java b/forms/src/test/java/com/itextpdf/forms/FormFieldsTaggingTest.java index 3552ad63d5..7f2d455bf2 100644 --- a/forms/src/test/java/com/itextpdf/forms/FormFieldsTaggingTest.java +++ b/forms/src/test/java/com/itextpdf/forms/FormFieldsTaggingTest.java @@ -38,23 +38,22 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; import javax.xml.parsers.ParserConfigurationException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import org.xml.sax.SAXException; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class FormFieldsTaggingTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/forms/FormFieldsTaggingTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/forms/FormFieldsTaggingTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } @@ -333,13 +332,13 @@ private void compareOutput(String outFileName, String cmpFileName) throws Interr CompareTool compareTool = new CompareTool(); String compareResult = compareTool.compareTagStructures(outFileName, cmpFileName); if (compareResult != null) { - Assert.fail(compareResult); + Assertions.fail(compareResult); } compareResult = compareTool.compareByContent(outFileName, cmpFileName, destinationFolder, "diff" + outFileName); if (compareResult != null) { - Assert.fail(compareResult); + Assertions.fail(compareResult); } } } diff --git a/forms/src/test/java/com/itextpdf/forms/PdfAcroFormInAppendModeTest.java b/forms/src/test/java/com/itextpdf/forms/PdfAcroFormInAppendModeTest.java index 4613790070..83ad5052a4 100644 --- a/forms/src/test/java/com/itextpdf/forms/PdfAcroFormInAppendModeTest.java +++ b/forms/src/test/java/com/itextpdf/forms/PdfAcroFormInAppendModeTest.java @@ -35,15 +35,14 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.StampingProperties; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfAcroFormInAppendModeTest extends ExtendedITextTest { private static final String TEST_NAME = "PdfAcroFormInAppendModeTest/"; private static final String DESTINATION_DIR = "./target/test/com/itextpdf/forms/" + TEST_NAME; @@ -53,7 +52,7 @@ public class PdfAcroFormInAppendModeTest extends ExtendedITextTest { private static final String INPUT_FILE_WITH_INDIRECT_FIELDS_ARRAY = SOURCE_DIR + "inputFileWithIndirectFieldsArray.pdf"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(DESTINATION_DIR); } @@ -195,7 +194,7 @@ public void addFieldToDirectAcroFormTest() throws IOException, InterruptedExcept } private static void compareWithCmp(String outputFile) throws IOException, InterruptedException { - Assert.assertNull(new CompareTool() + Assertions.assertNull(new CompareTool() .compareByContent(DESTINATION_DIR + outputFile, SOURCE_DIR + "cmp_" + outputFile, DESTINATION_DIR, "diff_")); } diff --git a/forms/src/test/java/com/itextpdf/forms/PdfAcroFormIntegrationTest.java b/forms/src/test/java/com/itextpdf/forms/PdfAcroFormIntegrationTest.java index cc18ebfb43..5cbdeccd08 100644 --- a/forms/src/test/java/com/itextpdf/forms/PdfAcroFormIntegrationTest.java +++ b/forms/src/test/java/com/itextpdf/forms/PdfAcroFormIntegrationTest.java @@ -38,20 +38,18 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; - +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfAcroFormIntegrationTest extends ExtendedITextTest { public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/forms/PdfAcroFormIntegrationTest/"; public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/forms/PdfAcroFormIntegrationTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(DESTINATION_FOLDER); } @@ -60,8 +58,24 @@ public static void beforeClass() { public void orphanedNamelessFormFieldTest() throws IOException { try (PdfDocument pdfDoc = new PdfDocument(new PdfReader(SOURCE_FOLDER + "orphanedFormField.pdf"))) { PdfAcroForm form = PdfFormCreator.getAcroForm(pdfDoc, true); - Assert.assertEquals(3, form.getRootFormFields().size()); + Assertions.assertEquals(3, form.getRootFormFields().size()); + } + } + + @Test + public void formWithSameFieldReferencesTest() throws IOException, InterruptedException { + String srcFileName = SOURCE_FOLDER + "formWithSameFieldReferences.pdf"; + String cmpFileName = SOURCE_FOLDER + "cmp_formWithSameFieldReferences.pdf"; + String outFileName = DESTINATION_FOLDER + "formWithSameFieldReferences.pdf"; + + try (PdfDocument sourceDoc = new PdfDocument(new PdfReader(srcFileName), new PdfWriter(outFileName))) { + PdfAcroForm acroForm = PdfFormCreator.getAcroForm(sourceDoc, true); + + Assertions.assertEquals(1, acroForm.getFields().size()); + Assertions.assertNull(acroForm.getField("Field").getKids()); } + + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff_")); } @Test @@ -73,18 +87,18 @@ public void mergeMergedFieldsWithTheSameNamesTest() throws IOException, Interrup try (PdfDocument sourceDoc = new PdfDocument(new PdfReader(srcFileName), new PdfWriter(outFileName))) { PdfAcroForm acroForm = PdfFormCreator.getAcroForm(sourceDoc, true); - Assert.assertEquals(1, acroForm.getFields().size()); - Assert.assertNull(acroForm.getField("Field").getKids()); + Assertions.assertEquals(1, acroForm.getFields().size()); + Assertions.assertNull(acroForm.getField("Field").getKids()); PdfFormField field = acroForm.copyField("Field"); field.getPdfObject().put(PdfName.Rect, new PdfArray(new Rectangle(210, 490, 150, 22))); acroForm.addField(field); - Assert.assertEquals(1, acroForm.getFields().size()); - Assert.assertEquals(2, acroForm.getField("Field").getKids().size()); + Assertions.assertEquals(1, acroForm.getFields().size()); + Assertions.assertEquals(2, acroForm.getField("Field").getKids().size()); } - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff_")); } @Test @@ -107,10 +121,10 @@ public void allowAddingFieldsWithTheSameNamesButDifferentValuesTest() throws IOE root.addKid(firstField); root.addKid(secondField, false); - Assert.assertEquals(1, acroForm.getFields().size()); - Assert.assertEquals(2, root.getKids().size()); + Assertions.assertEquals(1, acroForm.getFields().size()); + Assertions.assertEquals(2, root.getKids().size()); } - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff_")); } @Test @@ -118,15 +132,15 @@ public void processFieldsWithTheSameNamesButDifferentValuesInReadingModeTest() t String srcFileName = SOURCE_FOLDER + "cmp_fieldsWithTheSameNamesButDifferentValues.pdf"; try (PdfDocument document = new PdfDocument(new PdfReader(srcFileName))) { PdfAcroForm acroForm = PdfFormCreator.getAcroForm(document, true); - Assert.assertEquals(1, acroForm.getFields().size()); + Assertions.assertEquals(1, acroForm.getFields().size()); PdfFormField root = acroForm.getField("root"); - Assert.assertEquals(2, root.getKids().size()); + Assertions.assertEquals(2, root.getKids().size()); root.getChildField("field").setValue("field"); PdfFormCreator.getAcroForm(document, true); // Check that fields weren't merged - Assert.assertEquals(2, root.getKids().size()); + Assertions.assertEquals(2, root.getKids().size()); } } @@ -137,15 +151,15 @@ public void processFieldsWithTheSameNamesInWritingModeTest() throws IOException String outFileName = DESTINATION_FOLDER + "processFieldsWithTheSameNamesInWritingMode.pdf"; try (PdfDocument document = new PdfDocument(new PdfReader(srcFileName), new PdfWriter(outFileName))) { PdfAcroForm acroForm = PdfFormCreator.getAcroForm(document, true); - Assert.assertEquals(1, acroForm.getFields().size()); + Assertions.assertEquals(1, acroForm.getFields().size()); PdfFormField root = acroForm.getField("root"); - Assert.assertEquals(2, root.getKids().size()); + Assertions.assertEquals(2, root.getKids().size()); root.getChildField("field").setValue("field"); PdfFormCreator.getAcroForm(document, true); // Check that fields were merged - Assert.assertEquals(1, root.getKids().size()); + Assertions.assertEquals(1, root.getKids().size()); } } @@ -165,11 +179,11 @@ public void disableFieldRegenerationTest() throws IOException, InterruptedExcept .setBorderColor(new DeviceRgb(51, 0, 102)).setBorderWidth(5); } } - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff_")); try (PdfDocument document = new PdfDocument(new PdfReader(cmpFileName), new PdfWriter(outFileName2))) { PdfFormCreator.getAcroForm(document, true).enableRegenerationForAllFields(); } - Assert.assertNull(new CompareTool().compareByContent(outFileName2, cmpFileName2, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName2, cmpFileName2, DESTINATION_FOLDER, "diff_")); } @Test @@ -187,6 +201,6 @@ public void enableFieldRegenerationTest() throws IOException, InterruptedExcepti } acroForm.enableRegenerationForAllFields(); } - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff_")); } } diff --git a/forms/src/test/java/com/itextpdf/forms/PdfAcroFormTest.java b/forms/src/test/java/com/itextpdf/forms/PdfAcroFormTest.java index c81f156456..98a168b5e5 100644 --- a/forms/src/test/java/com/itextpdf/forms/PdfAcroFormTest.java +++ b/forms/src/test/java/com/itextpdf/forms/PdfAcroFormTest.java @@ -51,14 +51,12 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; - +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.util.List; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfAcroFormTest extends ExtendedITextTest { @Test @@ -72,9 +70,9 @@ public void setSignatureFlagsTest() { PdfObject sigFlags = acroForm.getPdfObject().get(PdfName.SigFlags); outputDoc.close(); - Assert.assertEquals(new PdfNumber(65), sigFlags); - Assert.assertTrue(isModified); - Assert.assertTrue(isReleaseForbidden); + Assertions.assertEquals(new PdfNumber(65), sigFlags); + Assertions.assertTrue(isModified); + Assertions.assertTrue(isReleaseForbidden); } } @@ -91,9 +89,9 @@ public void addChildToFormFieldTest() { .setWidgetRectangle(new Rectangle(100, 300, 200, 20)).createText(); root.addKid(child); acroForm.addField(root); - Assert.assertEquals(2, acroForm.fields.size()); + Assertions.assertEquals(2, acroForm.fields.size()); PdfArray fieldKids = root.getKids(); - Assert.assertEquals(2, fieldKids.size()); + Assertions.assertEquals(2, fieldKids.size()); } } @@ -110,9 +108,9 @@ public void addChildToWidgetTest() { .setWidgetRectangle(new Rectangle(36, 696, 20, 20)).createText(); text.addKid(childText); acroForm.addField(text); - Assert.assertEquals(1, acroForm.fields.size()); + Assertions.assertEquals(1, acroForm.fields.size()); List fieldKids = text.getChildFields(); - Assert.assertEquals(2, fieldKids.size()); + Assertions.assertEquals(2, fieldKids.size()); } } @@ -131,7 +129,7 @@ public void getFormFieldChildTest() { root.addKid(child); acroForm.addField(root); PdfFormField childField = acroForm.getField("root.child"); - Assert.assertEquals("root.child", childField.getFieldName().toString()); + Assertions.assertEquals("root.child", childField.getFieldName().toString()); } } @@ -156,7 +154,7 @@ public void getFormFieldWithEqualChildNamesTest() { root.addKid(child); acroForm.addField(root); PdfFormField childField = acroForm.getField("root.field.field.another_name"); - Assert.assertEquals("root.field.field.another_name", childField.getFieldName().toString()); + Assertions.assertEquals("root.field.field.another_name", childField.getFieldName().toString()); } } @@ -176,7 +174,7 @@ public void changeFieldNameTest() { acroForm.addField(root); acroForm.getField("root").setFieldName("diff"); PdfFormField childField = PdfFormCreator.getAcroForm(outputDoc, true).getField("diff.child"); - Assert.assertEquals("diff.child", childField.getFieldName().toString()); + Assertions.assertEquals("diff.child", childField.getFieldName().toString()); } } @@ -202,8 +200,8 @@ public void removeChildFromFormFieldTest() { root.addKid(child); acroForm.addField(root); acroForm.removeField("root.child.aaaaa"); - Assert.assertEquals(2, acroForm.fields.size()); - Assert.assertEquals(2, root.getKids().size()); + Assertions.assertEquals(2, acroForm.fields.size()); + Assertions.assertEquals(2, root.getKids().size()); } } @@ -238,10 +236,10 @@ public void getChildFromFormFieldWithDifferentAmountOfChildrenTest() { root.addKid(child); acroForm.addField(root); PdfFormField childField = acroForm.getField("root.child.aaaaa.child2"); - Assert.assertEquals("root.child.aaaaa.child2", childField.getFieldName().toString()); + Assertions.assertEquals("root.child.aaaaa.child2", childField.getFieldName().toString()); - Assert.assertEquals(2, acroForm.getFields().size()); - Assert.assertEquals(2, root.getKids().size()); + Assertions.assertEquals(2, acroForm.getFields().size()); + Assertions.assertEquals(2, root.getKids().size()); } } @@ -250,22 +248,22 @@ public void checkFormFieldsSizeTest() { try(PdfDocument outputDoc = createDocument()) { outputDoc.addNewPage(); PdfAcroForm acroForm = PdfFormCreator.getAcroForm(outputDoc, true); - Assert.assertEquals(0, acroForm.getAllFormFields().size()); - Assert.assertEquals(0, acroForm.getAllFormFieldsAndAnnotations().size()); + Assertions.assertEquals(0, acroForm.getAllFormFields().size()); + Assertions.assertEquals(0, acroForm.getAllFormFieldsAndAnnotations().size()); PdfDictionary fieldDict = new PdfDictionary(); fieldDict.put(PdfName.FT, PdfName.Tx); PdfFormField field = PdfFormField.makeFormField(fieldDict.makeIndirect(outputDoc), outputDoc); field.setFieldName("Field1"); acroForm.addField(field); - Assert.assertEquals(1, acroForm.getAllFormFields().size()); - Assert.assertEquals(1, acroForm.getAllFormFieldsAndAnnotations().size()); + Assertions.assertEquals(1, acroForm.getAllFormFields().size()); + Assertions.assertEquals(1, acroForm.getAllFormFieldsAndAnnotations().size()); PdfDictionary annotDict = new PdfDictionary(); annotDict.put(PdfName.Subtype, PdfName.Widget); field.addKid(PdfFormAnnotation.makeFormAnnotation(annotDict, outputDoc)); - Assert.assertEquals(1, acroForm.getAllFormFields().size()); - Assert.assertEquals(2, acroForm.getAllFormFieldsAndAnnotations().size()); + Assertions.assertEquals(1, acroForm.getAllFormFields().size()); + Assertions.assertEquals(2, acroForm.getAllFormFieldsAndAnnotations().size()); } } @@ -298,9 +296,9 @@ public void fieldKidsWithTheSameNamesTest() { root.addKid(sameChild); acroForm.addField(root); - Assert.assertEquals(1, acroForm.getFields().size()); - Assert.assertEquals(1, root.getKids().size()); - Assert.assertEquals(2, child.getKids().size()); + Assertions.assertEquals(1, acroForm.getFields().size()); + Assertions.assertEquals(1, root.getKids().size()); + Assertions.assertEquals(2, child.getKids().size()); } } @@ -313,17 +311,17 @@ public void namelessFieldTest() { PdfDictionary fieldDict = new PdfDictionary(); fieldDict.put(PdfName.FT, PdfName.Tx); PdfFormField field = PdfFormField.makeFormField(fieldDict.makeIndirect(outputDoc), outputDoc); - Exception e = Assert.assertThrows(PdfException.class, () -> acroForm.addField(field)); - Assert.assertEquals(FormsExceptionMessageConstant.FORM_FIELD_MUST_HAVE_A_NAME, e.getMessage()); + Exception e = Assertions.assertThrows(PdfException.class, () -> acroForm.addField(field)); + Assertions.assertEquals(FormsExceptionMessageConstant.FORM_FIELD_MUST_HAVE_A_NAME, e.getMessage()); outputDoc.addNewPage(); PdfPage page = outputDoc.getLastPage(); - e = Assert.assertThrows(PdfException.class, () -> acroForm.addField(field, page)); - Assert.assertEquals(FormsExceptionMessageConstant.FORM_FIELD_MUST_HAVE_A_NAME, e.getMessage()); + e = Assertions.assertThrows(PdfException.class, () -> acroForm.addField(field, page)); + Assertions.assertEquals(FormsExceptionMessageConstant.FORM_FIELD_MUST_HAVE_A_NAME, e.getMessage()); acroForm.addField(field, page, false); - Assert.assertEquals(0, acroForm.getRootFormFields().size()); + Assertions.assertEquals(0, acroForm.getRootFormFields().size()); } } @@ -348,8 +346,8 @@ public void addRootFieldsWithTheSameNamesTest() { acroForm.addField(root); acroForm.addField(sameRoot); - Assert.assertEquals(1, acroForm.getFields().size()); - Assert.assertEquals(2, root.getKids().size()); + Assertions.assertEquals(1, acroForm.getFields().size()); + Assertions.assertEquals(2, root.getKids().size()); } } @@ -369,9 +367,9 @@ public void addMergedRootFieldsWithTheSameNamesTest() { acroForm.addField(firstField); acroForm.addField(secondField); - Assert.assertEquals(1, acroForm.getFields().size()); - Assert.assertEquals(2, acroForm.getField("root").getKids().size()); - Assert.assertEquals(2, acroForm.getField("root").getChildFields().size()); + Assertions.assertEquals(1, acroForm.getFields().size()); + Assertions.assertEquals(2, acroForm.getField("root").getKids().size()); + Assertions.assertEquals(2, acroForm.getField("root").getChildFields().size()); } } @@ -388,8 +386,8 @@ public void addFieldsWithTheSameNamesButDifferentValuesTest() { acroForm.addField(firstField); - Exception e = Assert.assertThrows(PdfException.class, () -> acroForm.addField(secondField)); - Assert.assertEquals(MessageFormatUtil.format(FormsExceptionMessageConstant.CANNOT_MERGE_FORMFIELDS, "root"), + Exception e = Assertions.assertThrows(PdfException.class, () -> acroForm.addField(secondField)); + Assertions.assertEquals(MessageFormatUtil.format(FormsExceptionMessageConstant.CANNOT_MERGE_FORMFIELDS, "root"), e.getMessage()); } } @@ -409,12 +407,12 @@ public void addRootFieldWithMergedFieldKidTest() { firstField.addKid(mergedField); acroForm.addField(firstField); - Assert.assertEquals(1, acroForm.getFields().size()); - Assert.assertEquals(1, acroForm.getField("root").getKids().size()); + Assertions.assertEquals(1, acroForm.getFields().size()); + Assertions.assertEquals(1, acroForm.getField("root").getKids().size()); - Assert.assertTrue(PdfFormAnnotationUtil.isPureWidgetOrMergedField( + Assertions.assertTrue(PdfFormAnnotationUtil.isPureWidgetOrMergedField( (PdfDictionary) acroForm.getField("root").getKids().get(0))); - Assert.assertFalse(PdfFormAnnotationUtil.isPureWidget( + Assertions.assertFalse(PdfFormAnnotationUtil.isPureWidget( (PdfDictionary) acroForm.getField("root").getKids().get(0))); } } @@ -439,17 +437,17 @@ public void addRootFieldWithDirtyNamedAnnotationsTest() { rootField.addKid(firstDirtyAnnot); rootField.addKid(secondDirtyAnnot); - Assert.assertEquals(1, rootField.getKids().size()); - Assert.assertEquals(2, firstDirtyAnnot.getKids().size()); + Assertions.assertEquals(1, rootField.getKids().size()); + Assertions.assertEquals(2, firstDirtyAnnot.getKids().size()); acroForm.addField(rootField); - Assert.assertEquals(1, acroForm.getFields().size()); + Assertions.assertEquals(1, acroForm.getFields().size()); PdfArray fieldKids = acroForm.getField("root").getKids(); - Assert.assertEquals(1, fieldKids.size()); + Assertions.assertEquals(1, fieldKids.size()); - Assert.assertFalse(PdfFormAnnotationUtil.isPureWidget((PdfDictionary) fieldKids.get(0))); + Assertions.assertFalse(PdfFormAnnotationUtil.isPureWidget((PdfDictionary) fieldKids.get(0))); } } @@ -478,18 +476,18 @@ public void addRootFieldWithDirtyUnnamedAnnotationsTest() { rootField.addKid(firstDirtyAnnot); rootField.addKid(secondDirtyAnnot); - Assert.assertEquals(1, rootField.getKids().size()); - Assert.assertEquals(2, firstDirtyAnnot.getKids().size()); + Assertions.assertEquals(1, rootField.getKids().size()); + Assertions.assertEquals(2, firstDirtyAnnot.getKids().size()); acroForm.addField(rootField); - Assert.assertEquals(1, acroForm.getFields().size()); + Assertions.assertEquals(1, acroForm.getFields().size()); PdfArray fieldKids = acroForm.getField("root").getKids(); - Assert.assertEquals(2, fieldKids.size()); + Assertions.assertEquals(2, fieldKids.size()); - Assert.assertTrue(PdfFormAnnotationUtil.isPureWidget((PdfDictionary) fieldKids.get(0))); - Assert.assertTrue(PdfFormAnnotationUtil.isPureWidget((PdfDictionary) fieldKids.get(1))); + Assertions.assertTrue(PdfFormAnnotationUtil.isPureWidget((PdfDictionary) fieldKids.get(0))); + Assertions.assertTrue(PdfFormAnnotationUtil.isPureWidget((PdfDictionary) fieldKids.get(1))); } } @@ -520,9 +518,9 @@ public void mergeFieldsWhenKidsWasFlushedTest() { acroForm = PdfFormCreator.getAcroForm(outputDoc, true); acroForm.addField(thirdField); - Assert.assertEquals(1, acroForm.getFields().size()); - Assert.assertEquals(3, acroForm.getField("root").getKids().size()); - Assert.assertEquals(2, acroForm.getField("root").getChildFields().size()); + Assertions.assertEquals(1, acroForm.getFields().size()); + Assertions.assertEquals(3, acroForm.getField("root").getKids().size()); + Assertions.assertEquals(2, acroForm.getField("root").getChildFields().size()); } } @@ -536,15 +534,15 @@ public void addMergedRootFieldTest() { .setWidgetRectangle(new Rectangle(100, 500, 200, 30)) .createText().setValue("root"); - Assert.assertEquals(0, page.getAnnotsSize()); + Assertions.assertEquals(0, page.getAnnotsSize()); acroForm.addField(mergedField); - Assert.assertEquals(1, page.getAnnotsSize()); + Assertions.assertEquals(1, page.getAnnotsSize()); - Assert.assertEquals(1, acroForm.getFields().size()); + Assertions.assertEquals(1, acroForm.getFields().size()); PdfFormField root = acroForm.getField("root"); - Assert.assertNull(root.getKids()); - Assert.assertTrue(PdfFormAnnotationUtil.isPureWidgetOrMergedField(root.getPdfObject())); - Assert.assertFalse(PdfFormAnnotationUtil.isPureWidget(root.getPdfObject())); + Assertions.assertNull(root.getKids()); + Assertions.assertTrue(PdfFormAnnotationUtil.isPureWidgetOrMergedField(root.getPdfObject())); + Assertions.assertFalse(PdfFormAnnotationUtil.isPureWidget(root.getPdfObject())); } } @@ -561,9 +559,9 @@ public void setCalculationOrderTest() { PdfObject calculationOrder = acroForm.getPdfObject().get(PdfName.CO); outputDoc.close(); - Assert.assertEquals(calculationOrderArray, calculationOrder); - Assert.assertTrue(isModified); - Assert.assertTrue(isReleaseForbidden); + Assertions.assertEquals(calculationOrderArray, calculationOrder); + Assertions.assertTrue(isModified); + Assertions.assertTrue(isReleaseForbidden); } } @@ -579,9 +577,9 @@ public void setDefaultAppearanceTest() { PdfObject calculationOrder = acroForm.getPdfObject().get(PdfName.DA); outputDoc.close(); - Assert.assertEquals(new PdfString("default appearance"), calculationOrder); - Assert.assertTrue(isModified); - Assert.assertTrue(isReleaseForbidden); + Assertions.assertEquals(new PdfString("default appearance"), calculationOrder); + Assertions.assertTrue(isModified); + Assertions.assertTrue(isReleaseForbidden); } } @@ -597,9 +595,9 @@ public void setDefaultJustificationTest() { PdfObject defaultJustification = acroForm.getPdfObject().get(PdfName.Q); outputDoc.close(); - Assert.assertEquals(new PdfNumber(14), defaultJustification); - Assert.assertTrue(isModified); - Assert.assertTrue(isReleaseForbidden); + Assertions.assertEquals(new PdfNumber(14), defaultJustification); + Assertions.assertTrue(isModified); + Assertions.assertTrue(isReleaseForbidden); } } @@ -617,9 +615,9 @@ public void setDefaultResourcesTest() { PdfObject defaultResourcesDict = acroForm.getPdfObject().get(PdfName.DR); outputDoc.close(); - Assert.assertEquals(dictionary, defaultResourcesDict); - Assert.assertTrue(isModified); - Assert.assertTrue(isReleaseForbidden); + Assertions.assertEquals(dictionary, defaultResourcesDict); + Assertions.assertTrue(isModified); + Assertions.assertTrue(isReleaseForbidden); } } @@ -636,9 +634,9 @@ public void setNeedAppearancesTest() { outputDoc.close(); - Assert.assertEquals(new PdfBoolean(false), needAppearance); - Assert.assertTrue(isModified); - Assert.assertTrue(isReleaseForbidden); + Assertions.assertEquals(new PdfBoolean(false), needAppearance); + Assertions.assertTrue(isModified); + Assertions.assertTrue(isReleaseForbidden); } } @@ -659,9 +657,9 @@ public void setNeedAppearancesInPdf2Test() { outputDoc.close(); - Assert.assertNull(needAppearance); - Assert.assertTrue(isModified); - Assert.assertTrue(isReleaseForbidden); + Assertions.assertNull(needAppearance); + Assertions.assertTrue(isModified); + Assertions.assertTrue(isReleaseForbidden); } @Test @@ -678,10 +676,10 @@ public void setGenerateAppearanceTest() { Object needAppearances = acroForm.getPdfObject().get(PdfName.NeedAppearances); outputDoc.close(); - Assert.assertNull(needAppearances); - Assert.assertTrue(isGenerateAppearance); - Assert.assertTrue(isModified); - Assert.assertTrue(isReleaseForbidden); + Assertions.assertNull(needAppearances); + Assertions.assertTrue(isGenerateAppearance); + Assertions.assertTrue(isModified); + Assertions.assertTrue(isReleaseForbidden); } } @@ -698,9 +696,9 @@ public void setXFAResourcePdfArrayTest() { PdfObject xfaObject = acroForm.getPdfObject().get(PdfName.XFA); outputDoc.close(); - Assert.assertEquals(array, xfaObject); - Assert.assertTrue(isModified); - Assert.assertTrue(isReleaseForbidden); + Assertions.assertEquals(array, xfaObject); + Assertions.assertTrue(isModified); + Assertions.assertTrue(isReleaseForbidden); } } @@ -717,9 +715,9 @@ public void setXFAResourcePdfStreamTest() { PdfObject xfaObject = acroForm.getPdfObject().get(PdfName.XFA); outputDoc.close(); - Assert.assertEquals(stream, xfaObject); - Assert.assertTrue(isModified); - Assert.assertTrue(isReleaseForbidden); + Assertions.assertEquals(stream, xfaObject); + Assertions.assertTrue(isModified); + Assertions.assertTrue(isReleaseForbidden); } } @@ -735,7 +733,7 @@ public void replaceFormFieldRootLevelReplacesExistingFieldTest() { assert field != null; acroForm.addField(field); - Assert.assertEquals(1, acroForm.getRootFormFields().size()); + Assertions.assertEquals(1, acroForm.getRootFormFields().size()); PdfDictionary fieldDictReplace = new PdfDictionary(); @@ -744,8 +742,8 @@ public void replaceFormFieldRootLevelReplacesExistingFieldTest() { PdfFormField fieldReplace = PdfFormField.makeFormField(fieldDictReplace.makeIndirect(outputDoc), outputDoc); acroForm.replaceField("field1", fieldReplace); - Assert.assertEquals(1, acroForm.getRootFormFields().size()); - Assert.assertEquals("field2", acroForm.getField("field2").getFieldName().toUnicodeString()); + Assertions.assertEquals(1, acroForm.getRootFormFields().size()); + Assertions.assertEquals("field2", acroForm.getField("field2").getFieldName().toUnicodeString()); } } @@ -763,7 +761,7 @@ public void replaceWithNullNameLogsErrorTest(){ assert field != null; acroForm.addField(field); - Assert.assertEquals(1, acroForm.getRootFormFields().size()); + Assertions.assertEquals(1, acroForm.getRootFormFields().size()); PdfDictionary fieldDictReplace = new PdfDictionary(); @@ -772,7 +770,7 @@ public void replaceWithNullNameLogsErrorTest(){ PdfFormField fieldReplace = PdfFormField.makeFormField(fieldDictReplace.makeIndirect(outputDoc), outputDoc); acroForm.replaceField(null, fieldReplace); - Assert.assertEquals(1, acroForm.getRootFormFields().size()); + Assertions.assertEquals(1, acroForm.getRootFormFields().size()); } } @@ -797,7 +795,7 @@ public void replaceFormFieldOneDeepReplacesExistingFieldTest() { field.addKid(fieldChild); acroForm.addField(field); - Assert.assertEquals(1, acroForm.getRootFormFields().size()); + Assertions.assertEquals(1, acroForm.getRootFormFields().size()); PdfDictionary fieldDictReplace = new PdfDictionary(); @@ -806,8 +804,8 @@ public void replaceFormFieldOneDeepReplacesExistingFieldTest() { PdfFormField fieldReplace = PdfFormField.makeFormField(fieldDictReplace.makeIndirect(outputDoc), outputDoc); acroForm.replaceField("field1.child1", fieldReplace); - Assert.assertEquals(1, acroForm.getRootFormFields().size()); - Assert.assertEquals("field1.field2", acroForm.getField("field1.field2").getFieldName().toUnicodeString()); + Assertions.assertEquals(1, acroForm.getRootFormFields().size()); + Assertions.assertEquals("field1.field2", acroForm.getField("field1.field2").getFieldName().toUnicodeString()); } } diff --git a/forms/src/test/java/com/itextpdf/forms/PdfCheckBoxFieldTest.java b/forms/src/test/java/com/itextpdf/forms/PdfCheckBoxFieldTest.java index b3a190ee23..c127199e8f 100644 --- a/forms/src/test/java/com/itextpdf/forms/PdfCheckBoxFieldTest.java +++ b/forms/src/test/java/com/itextpdf/forms/PdfCheckBoxFieldTest.java @@ -43,24 +43,23 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.canvas.PdfCanvas; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; import java.util.Arrays; import java.util.List; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfCheckBoxFieldTest extends ExtendedITextTest { public static final String destinationFolder = "./target/test/com/itextpdf/forms/PdfCheckBoxFieldTest/"; public static final String sourceFolder = "./src/test/resources/com/itextpdf/forms/PdfCheckBoxFieldTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } @@ -79,7 +78,7 @@ public void checkBoxFontSizeTest01() throws IOException, InterruptedException { CompareTool compareTool = new CompareTool(); String errorMessage = compareTool.compareByContent(outPdf, cmpPdf, destinationFolder, "diff_"); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -107,7 +106,7 @@ public void checkBoxFontSizeTest02() throws IOException, InterruptedException { CompareTool compareTool = new CompareTool(); String errorMessage = compareTool.compareByContent(outPdf, cmpPdf, destinationFolder, "diff_"); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -125,7 +124,7 @@ public void checkBoxFontSizeTest03() throws IOException, InterruptedException { CompareTool compareTool = new CompareTool(); String errorMessage = compareTool.compareByContent(outPdf, cmpPdf, destinationFolder, "diff_"); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -157,7 +156,7 @@ public void checkBoxFontSizeTest04() throws IOException, InterruptedException { CompareTool compareTool = new CompareTool(); String errorMessage = compareTool.compareByContent(outPdf, cmpPdf, destinationFolder, "diff_"); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -176,7 +175,7 @@ public void checkBoxFontSizeTest05() throws IOException, InterruptedException { CompareTool compareTool = new CompareTool(); String errorMessage = compareTool.compareByContent(outPdf, cmpPdf, destinationFolder, "diff_"); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -196,7 +195,7 @@ public void checkBoxToggleTest01() throws IOException, InterruptedException { CompareTool compareTool = new CompareTool(); String errorMessage = compareTool.compareByContent(outPdf, cmpPdf, destinationFolder, "diff_"); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -216,7 +215,7 @@ public void checkBoxToggleTest02() throws IOException, InterruptedException { CompareTool compareTool = new CompareTool(); String errorMessage = compareTool.compareByContent(outPdf, cmpPdf, destinationFolder, "diff_"); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -243,7 +242,7 @@ public void keepCheckTypeTest() throws IOException, InterruptedException { form.getField("checkField").setValue("Yes"); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); } @Test @@ -275,7 +274,7 @@ public void appearanceRegenerationTest() throws IOException, InterruptedExceptio form.addField(checkBox1); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); } @Test @@ -293,7 +292,7 @@ public void setValueForMutuallyExclusiveCheckBoxTest() throws IOException, Inter checkBoxField.setValue("1"); checkBoxField.setValue("2"); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); } @Test @@ -307,7 +306,7 @@ public void changeOnStateAppearanceNameForCheckBoxWidgetTest() throws IOExceptio checkBoxField.setValue("3"); checkBoxField.getFirstFormAnnotation().setCheckBoxAppearanceOnStateName("3"); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); } @Test @@ -322,7 +321,7 @@ public void changeOnStateAppearanceNameSeveralTimesTest() throws IOException, In checkBoxField.getFirstFormAnnotation().setCheckBoxAppearanceOnStateName("3"); checkBoxField.getFirstFormAnnotation().setCheckBoxAppearanceOnStateName("1"); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); } @Test @@ -338,25 +337,25 @@ public void checkBoxWidgetAppearanceTest() throws IOException, InterruptedExcept // Default case widget.setCheckBoxAppearanceOnStateName("initial"); - Assert.assertTrue(Arrays.asList(widget.getAppearanceStates()).contains("initial")); - Assert.assertEquals("Off", widget.getPdfObject().getAsName(PdfName.AS).getValue()); + Assertions.assertTrue(Arrays.asList(widget.getAppearanceStates()).contains("initial")); + Assertions.assertEquals("Off", widget.getPdfObject().getAsName(PdfName.AS).getValue()); // Setting value changes on state name and appearance state for widget checkBox.setValue("value"); - Assert.assertTrue(Arrays.asList(widget.getAppearanceStates()).contains("value")); - Assert.assertEquals("value", widget.getPdfObject().getAsName(PdfName.AS).getValue()); + Assertions.assertTrue(Arrays.asList(widget.getAppearanceStates()).contains("value")); + Assertions.assertEquals("value", widget.getPdfObject().getAsName(PdfName.AS).getValue()); // Setting value generates normal appearance and changes appearance state for widget widget.getWidget().setNormalAppearance(new PdfDictionary()); checkBox.setValue("new_value"); List appearanceStates = Arrays.asList(widget.getAppearanceStates()); - Assert.assertTrue(appearanceStates.contains("new_value")); - Assert.assertTrue(appearanceStates.contains("Off")); - Assert.assertEquals("new_value", widget.getPdfObject().getAsName(PdfName.AS).getValue()); + Assertions.assertTrue(appearanceStates.contains("new_value")); + Assertions.assertTrue(appearanceStates.contains("Off")); + Assertions.assertEquals("new_value", widget.getPdfObject().getAsName(PdfName.AS).getValue()); acroForm.addField(checkBox); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); } @Test @@ -371,26 +370,26 @@ public void setInvalidCheckBoxOnAppearanceTest() throws IOException, Interrupted PdfFormAnnotation widget = checkBox.getFirstFormAnnotation(); checkBox.setValue("value"); List appearanceStates = Arrays.asList(widget.getAppearanceStates()); - Assert.assertTrue(appearanceStates.contains("value")); - Assert.assertTrue(appearanceStates.contains("Off")); - Assert.assertEquals("value", widget.getPdfObject().getAsName(PdfName.AS).getValue()); + Assertions.assertTrue(appearanceStates.contains("value")); + Assertions.assertTrue(appearanceStates.contains("Off")); + Assertions.assertEquals("value", widget.getPdfObject().getAsName(PdfName.AS).getValue()); // Setting invalid appearance name for on state does nothing widget.setCheckBoxAppearanceOnStateName("Off"); appearanceStates = Arrays.asList(widget.getAppearanceStates()); - Assert.assertTrue(appearanceStates.contains("value")); - Assert.assertTrue(appearanceStates.contains("Off")); - Assert.assertEquals("value", widget.getPdfObject().getAsName(PdfName.AS).getValue()); + Assertions.assertTrue(appearanceStates.contains("value")); + Assertions.assertTrue(appearanceStates.contains("Off")); + Assertions.assertEquals("value", widget.getPdfObject().getAsName(PdfName.AS).getValue()); widget.setCheckBoxAppearanceOnStateName(""); appearanceStates = Arrays.asList(widget.getAppearanceStates()); - Assert.assertTrue(appearanceStates.contains("value")); - Assert.assertTrue(appearanceStates.contains("Off")); - Assert.assertEquals("value", widget.getPdfObject().getAsName(PdfName.AS).getValue()); + Assertions.assertTrue(appearanceStates.contains("value")); + Assertions.assertTrue(appearanceStates.contains("Off")); + Assertions.assertEquals("value", widget.getPdfObject().getAsName(PdfName.AS).getValue()); acroForm.addField(checkBox); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); } @Test @@ -409,7 +408,7 @@ public void createMutuallyExclusiveCheckBoxesTest() throws IOException, Interrup checkBox.getChildFormAnnotations().get(1).setCheckBoxAppearanceOnStateName("2"); acroForm.addField(checkBox); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); } @Test @@ -423,11 +422,11 @@ public void createNotMutuallyExclusiveCheckBoxTest() throws IOException, Interru .setWidgetRectangle(new Rectangle(10, 650, 40, 20)).createCheckBox(); checkBox.setValue("1"); checkBox.addKid(new PdfWidgetAnnotation(new Rectangle(60, 650, 40, 20))); - Assert.assertNull(checkBox.getWidgets().get(1).getNormalAppearanceObject()); + Assertions.assertNull(checkBox.getWidgets().get(1).getNormalAppearanceObject()); checkBox.setValue("2"); acroForm.addField(checkBox); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); } private void addCheckBox(PdfDocument pdfDoc, float fontSize, float yPos, float checkBoxW, float checkBoxH) diff --git a/forms/src/test/java/com/itextpdf/forms/PdfChoiceFieldTest.java b/forms/src/test/java/com/itextpdf/forms/PdfChoiceFieldTest.java index 494a6e09ed..b1de91a219 100644 --- a/forms/src/test/java/com/itextpdf/forms/PdfChoiceFieldTest.java +++ b/forms/src/test/java/com/itextpdf/forms/PdfChoiceFieldTest.java @@ -26,8 +26,8 @@ This file is part of the iText (R) project. import com.itextpdf.forms.fields.PdfChoiceFormField; import com.itextpdf.forms.fields.PdfFormCreator; import com.itextpdf.forms.fields.PdfFormField; -import com.itextpdf.io.logs.IoLogMessageConstant; import com.itextpdf.io.font.PdfEncodings; +import com.itextpdf.io.logs.IoLogMessageConstant; import com.itextpdf.kernel.colors.ColorConstants; import com.itextpdf.kernel.font.PdfFont; import com.itextpdf.kernel.font.PdfFontFactory; @@ -44,21 +44,20 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfChoiceFieldTest extends ExtendedITextTest { public static final String destinationFolder = "./target/test/com/itextpdf/forms/PdfChoiceFieldTest/"; public static final String sourceFolder = "./src/test/resources/com/itextpdf/forms/PdfChoiceFieldTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } @@ -78,7 +77,7 @@ public void choiceFieldsWithUnicodeTest() throws IOException, InterruptedExcepti // 规 PdfFormField field = new ChoiceFormFieldBuilder(pdfDoc, "combo1") .setWidgetRectangle(new Rectangle(36, 666, 40, 80)).setOptions(new String[]{"\u89c4", "\u89c9"}) - .setGenericConformanceLevel(null).createComboBox() + .setConformance(null).createComboBox() .setValue("\u89c4"); field.setFont(font); field.getFirstFormAnnotation().setBorderColor(ColorConstants.BLACK); @@ -87,7 +86,7 @@ public void choiceFieldsWithUnicodeTest() throws IOException, InterruptedExcepti // 觉 field = new ChoiceFormFieldBuilder(pdfDoc, "combo2") .setWidgetRectangle(new Rectangle(136, 666, 40, 80)).setOptions(new String[]{"\u89c4", "\u89c9"}) - .setGenericConformanceLevel(null).createComboBox(); + .setConformance(null).createComboBox(); field.setValue("\u89c4").setFont(font); field.setValue("\u89c9"); field.getFirstFormAnnotation().setBorderColor(ColorConstants.BLACK); @@ -96,7 +95,7 @@ public void choiceFieldsWithUnicodeTest() throws IOException, InterruptedExcepti // 规 field = new ChoiceFormFieldBuilder(pdfDoc, "list1") .setWidgetRectangle(new Rectangle(236, 666, 50, 80)).setOptions(new String[]{"\u89c4", "\u89c9"}) - .setGenericConformanceLevel(null).createList() + .setConformance(null).createList() .setValue("\u89c4"); field.setFont(font); field.getFirstFormAnnotation().setBorderColor(ColorConstants.BLACK); @@ -105,7 +104,7 @@ public void choiceFieldsWithUnicodeTest() throws IOException, InterruptedExcepti // 觉 field = new ChoiceFormFieldBuilder(pdfDoc, "list2") .setWidgetRectangle(new Rectangle(336, 666, 50, 80)).setOptions(new String[]{"\u89c4", "\u89c9"}) - .setGenericConformanceLevel(null).createList(); + .setConformance(null).createList(); field.setValue("\u89c4").setFont(font); field.setValue("\u89c9"); field.getFirstFormAnnotation().setBorderColor(ColorConstants.BLACK); @@ -116,7 +115,7 @@ public void choiceFieldsWithUnicodeTest() throws IOException, InterruptedExcepti CompareTool compareTool = new CompareTool(); String errorMessage = compareTool.compareByContent(outPdf, cmpPdf, destinationFolder); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -138,11 +137,11 @@ public void choiceFieldsSetValueTest() throws IOException, InterruptedException PdfArray expectedIndicesSecond = new PdfArray(new int[] {2}); CompareTool compareTool = new CompareTool(); - Assert.assertTrue(compareTool.compareArrays(indicesFirst, expectedIndicesFirst)); - Assert.assertTrue(compareTool.compareArrays(indicesSecond, expectedIndicesSecond)); + Assertions.assertTrue(compareTool.compareArrays(indicesFirst, expectedIndicesFirst)); + Assertions.assertTrue(compareTool.compareArrays(indicesSecond, expectedIndicesSecond)); pdfDocument.close(); - Assert.assertNull(compareTool.compareByContent(outPdf, cmpPdf, destinationFolder)); + Assertions.assertNull(compareTool.compareByContent(outPdf, cmpPdf, destinationFolder)); } @Test @@ -156,7 +155,7 @@ public void comboNoHighlightCenteredTextOfChosenFirstItemTest() throws IOExcepti // flattening is only used for the sake of ease to see what appearance is generated by iText form.flattenFields(); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder)); } @Test @@ -168,7 +167,7 @@ public void noWarningOnValueNotOfOptComboEditTest() throws IOException, Interrup PdfAcroForm form = PdfFormCreator.getAcroForm(pdfDocument, false); form.getField("First").setValue("Value not of /Opt array"); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder)); } @Test @@ -182,24 +181,24 @@ public void multiSelectByValueTest() throws IOException, InterruptedException { PdfAcroForm form = PdfFormCreator.getAcroForm(document, true); PdfChoiceFormField choice = (PdfChoiceFormField) new ChoiceFormFieldBuilder(document, "choice") .setWidgetRectangle(new Rectangle(336, 666, 50, 80)).setOptions(new String[]{"one", "two", "three", "four"}) - .setGenericConformanceLevel(null).createList() + .setConformance(null).createList() .setValue("two").setFont(null); choice.getFirstFormAnnotation().setBorderColor(ColorConstants.BLACK); choice.setMultiSelect(true); choice.setListSelected(new String[] {"one", "three", "eins", "drei"}); - Assert.assertArrayEquals(new int[] {0, 2}, choice.getIndices().toIntArray()); + Assertions.assertArrayEquals(new int[] {0, 2}, choice.getIndices().toIntArray()); PdfArray values = (PdfArray) choice.getValue(); String[] valuesAsStrings = new String [values.size()]; for (int i = 0; i < values.size(); i++) { valuesAsStrings[i] = values.getAsString(i).toUnicodeString(); } - Assert.assertArrayEquals(new String[] {"one", "three", "eins", "drei"}, valuesAsStrings); + Assertions.assertArrayEquals(new String[] {"one", "three", "eins", "drei"}, valuesAsStrings); form.addField(choice); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder)); } @Test @@ -214,7 +213,7 @@ public void corruptedOptAndValueSetToNullTest() throws IOException, InterruptedE choice.setListSelected(new String[] {null, "three"}); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder)); } @Test @@ -230,11 +229,11 @@ public void multiSelectByValueRemoveIKeyTest() throws IOException, InterruptedEx PdfAcroForm form = PdfFormCreator.getAcroForm(document, true); PdfFormField field = form.getField("choice"); field.setValue(value); - Assert.assertNull(field.getPdfObject().get(PdfName.I)); + Assertions.assertNull(field.getPdfObject().get(PdfName.I)); CompareTool compareTool = new CompareTool(); - Assert.assertTrue(compareTool.compareStrings(new PdfString(value), field.getPdfObject().getAsString(PdfName.V))); + Assertions.assertTrue(compareTool.compareStrings(new PdfString(value), field.getPdfObject().getAsString(PdfName.V))); document.close(); - Assert.assertNull(compareTool.compareByContent(outPdf, cmpPdf, destinationFolder)); + Assertions.assertNull(compareTool.compareByContent(outPdf, cmpPdf, destinationFolder)); } @Test @@ -247,7 +246,7 @@ public void multiSelectByIndexOutOfBoundsTest() throws IOException, InterruptedE PdfChoiceFormField field = (PdfChoiceFormField) form.getField("choice"); field.setListSelected(new int[] {5}); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder)); } @Test @@ -278,7 +277,7 @@ public void notInstanceOfPdfChoiceFormFieldTest() throws IOException, Interrupte form.addField(field); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder)); } @Test @@ -293,7 +292,7 @@ public void topIndexTest() throws IOException, InterruptedException { int topIndex = field.getIndices().getAsNumber(0).intValue(); field.setTopIndex(topIndex); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder)); } @Test @@ -318,6 +317,6 @@ public void longOptionWrappedIntoTwoLinesTest() throws IOException, InterruptedE pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } } diff --git a/forms/src/test/java/com/itextpdf/forms/PdfEncryptionTest.java b/forms/src/test/java/com/itextpdf/forms/PdfEncryptionTest.java index ae3296ea6e..eb8b154bf2 100644 --- a/forms/src/test/java/com/itextpdf/forms/PdfEncryptionTest.java +++ b/forms/src/test/java/com/itextpdf/forms/PdfEncryptionTest.java @@ -22,6 +22,7 @@ This file is part of the iText (R) project. */ package com.itextpdf.forms; +import com.itextpdf.bouncycastleconnector.BouncyCastleFactoryCreator; import com.itextpdf.forms.fields.PdfButtonFormField; import com.itextpdf.forms.fields.PdfFormAnnotation; import com.itextpdf.forms.fields.PdfFormCreator; @@ -41,17 +42,16 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.BouncyCastleIntegrationTest; - -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import java.security.Security; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; import java.nio.charset.StandardCharsets; -@Category(BouncyCastleIntegrationTest.class) +@Tag("BouncyCastleIntegrationTest") public class PdfEncryptionTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/forms/PdfEncryptionTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/forms/PdfEncryptionTest/"; @@ -66,9 +66,10 @@ public class PdfEncryptionTest extends ExtendedITextTest { */ public static byte[] OWNER = "World".getBytes(StandardCharsets.ISO_8859_1); - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); + Security.addProvider(BouncyCastleFactoryCreator.getFactory().getProvider()); } // Custom entry in Info dictionary is used because standard entried are gone into metadata in PDF 2.0 @@ -129,7 +130,7 @@ public void encryptAes256Pdf2PermissionsTest01() throws InterruptedException, IO CompareTool compareTool = new CompareTool(); String errorMessage = compareTool.compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_", USER, USER); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -176,7 +177,7 @@ public void encryptAes256Pdf2PermissionsTest02() throws InterruptedException, IO CompareTool compareTool = new CompareTool(); String errorMessage = compareTool.compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_", USER, USER); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } } diff --git a/forms/src/test/java/com/itextpdf/forms/PdfFormCopyTest.java b/forms/src/test/java/com/itextpdf/forms/PdfFormCopyTest.java index 2dfa62974e..658c1941a8 100644 --- a/forms/src/test/java/com/itextpdf/forms/PdfFormCopyTest.java +++ b/forms/src/test/java/com/itextpdf/forms/PdfFormCopyTest.java @@ -33,22 +33,20 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; - -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfFormCopyTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/forms/PdfFormCopyTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/forms/PdfFormCopyTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } @@ -76,7 +74,7 @@ public void copyFieldsTest01() throws IOException, InterruptedException { pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(filename, sourceFolder + "cmp_copyFields01.pdf", destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, sourceFolder + "cmp_copyFields01.pdf", destinationFolder, "diff_")); } @Test @@ -93,7 +91,7 @@ public void copyFieldsTest02() throws IOException, InterruptedException { pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(filename, sourceFolder + "cmp_copyFields02.pdf", destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, sourceFolder + "cmp_copyFields02.pdf", destinationFolder, "diff_")); } @Test @@ -110,7 +108,7 @@ public void copyFieldsTest03() throws IOException, InterruptedException { pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(filename, sourceFolder + "cmp_copyFields03.pdf", destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, sourceFolder + "cmp_copyFields03.pdf", destinationFolder, "diff_")); } @Test @@ -131,7 +129,7 @@ public void largeFileTest() throws IOException, InterruptedException { pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(filename, sourceFolder + "cmp_copyLargeFile.pdf", destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, sourceFolder + "cmp_copyLargeFile.pdf", destinationFolder, "diff_")); } @Test @@ -149,8 +147,8 @@ public void copyFieldsTest04() throws IOException { srcDoc.copyPagesTo(1, srcDoc.getNumberOfPages(), destDoc, formCopier); PdfAcroForm form = PdfFormCreator.getAcroForm(destDoc, false); - Assert.assertEquals(1, form.getFields().size()); - Assert.assertNotNull(form.getField("Name1")); + Assertions.assertEquals(1, form.getFields().size()); + Assertions.assertNotNull(form.getField("Name1")); destDoc.close(); } @@ -166,7 +164,7 @@ public void copyFieldsTest05() throws IOException, InterruptedException { destDoc.addPage(srcDoc.getFirstPage().copyTo(destDoc, new PdfPageFormCopier())); destDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(destFilename, sourceFolder + "cmp_copyFields05.pdf", destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destFilename, sourceFolder + "cmp_copyFields05.pdf", destinationFolder, "diff_")); } @@ -197,7 +195,7 @@ public void copyMultipleSubfieldsTest01() throws IOException, InterruptedExcepti destDoc.close(); srcDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(destFilename, sourceFolder + "cmp_copyMultipleSubfieldsTest01.pdf", destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destFilename, sourceFolder + "cmp_copyMultipleSubfieldsTest01.pdf", destinationFolder, "diff_")); } @Test @@ -224,7 +222,7 @@ public void copyMultipleSubfieldsTest02() throws IOException, InterruptedExcepti destDoc.close(); srcDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(destFilename, sourceFolder + "cmp_copyMultipleSubfieldsTest02.pdf", destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destFilename, sourceFolder + "cmp_copyMultipleSubfieldsTest02.pdf", destinationFolder, "diff_")); } @Test @@ -251,7 +249,7 @@ public void copyMultipleSubfieldsTest03() throws IOException, InterruptedExcepti destDoc.close(); srcDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(destFilename, sourceFolder + "cmp_copyMultipleSubfieldsTest03.pdf", destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destFilename, sourceFolder + "cmp_copyMultipleSubfieldsTest03.pdf", destinationFolder, "diff_")); } @@ -282,7 +280,7 @@ public void copyMultipleSubfieldsSmartModeTest01() throws IOException, Interrupt destDoc.close(); srcDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(destFilename, sourceFolder + "cmp_copyMultipleSubfieldsSmartModeTest01.pdf", destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destFilename, sourceFolder + "cmp_copyMultipleSubfieldsSmartModeTest01.pdf", destinationFolder, "diff_")); } @Test @@ -304,7 +302,7 @@ public void copyFieldsTest06() throws IOException, InterruptedException { destDoc.close(); srcDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(destFilename, sourceFolder + "cmp_copyFields06.pdf", destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destFilename, sourceFolder + "cmp_copyFields06.pdf", destinationFolder, "diff_")); } @Test @@ -326,7 +324,7 @@ public void copyFieldsTest07() throws IOException, InterruptedException { } destDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(destFilename, sourceFolder + "cmp_copyFields07.pdf", destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destFilename, sourceFolder + "cmp_copyFields07.pdf", destinationFolder, "diff_")); } @Test @@ -354,7 +352,7 @@ public void copyFieldsTest08() throws IOException, InterruptedException { pdfDoc.close(); // comparing with cmp_copyFields01.pdf on purpose: result should be the same as in the first test - Assert.assertNull(new CompareTool().compareByContent(filename, sourceFolder + "cmp_copyFields01.pdf", destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, sourceFolder + "cmp_copyFields01.pdf", destinationFolder, "diff_")); } @Test @@ -373,7 +371,7 @@ public void copyFieldsTest09() throws IOException, InterruptedException { } destDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(destFilename, sourceFolder + "cmp_copyFields09.pdf", destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destFilename, sourceFolder + "cmp_copyFields09.pdf", destinationFolder, "diff_")); } @Test @@ -390,7 +388,7 @@ public void copyFieldsTest10() throws IOException, InterruptedException { } destDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(destFilename, sourceFolder + "cmp_copyFields10.pdf", destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destFilename, sourceFolder + "cmp_copyFields10.pdf", destinationFolder, "diff_")); } @Test @@ -412,7 +410,7 @@ public void copyFieldsTest11() throws IOException, InterruptedException { destDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(destFilename, sourceFolder + "cmp_copyFields11.pdf", destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destFilename, sourceFolder + "cmp_copyFields11.pdf", destinationFolder, "diff_")); } @Test @@ -434,7 +432,7 @@ public void copyFieldsTest12() throws IOException, InterruptedException { destDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(destFilename, sourceFolder + "cmp_copyFields12.pdf", destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destFilename, sourceFolder + "cmp_copyFields12.pdf", destinationFolder, "diff_")); } @Test @@ -458,7 +456,7 @@ public void copyFieldsTest13() throws IOException, InterruptedException { destDoc.close(); srcDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(destFilename, sourceFolder + "cmp_copyFields13.pdf", destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destFilename, sourceFolder + "cmp_copyFields13.pdf", destinationFolder, "diff_")); } @@ -471,7 +469,7 @@ public void copyPagesWithInheritedResources() throws IOException, InterruptedExc target.initializeOutlines(); source.copyPagesTo(1, source.getNumberOfPages(), target, new PdfPageFormCopier()); target.close(); - Assert.assertNull(new CompareTool().compareByContent(destFile, sourceFolder + "cmp_AnnotationSampleStandard_copy.pdf", destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destFile, sourceFolder + "cmp_AnnotationSampleStandard_copy.pdf", destinationFolder, "diff_")); } @Test @@ -482,7 +480,7 @@ public void unnamedFieldsHierarchyTest() throws IOException, InterruptedExceptio PdfDocument merged = new PdfDocument(new PdfWriter(destFilename)); src.copyPagesTo(1, 1, merged, new PdfPageFormCopier()); merged.close(); - Assert.assertNull(new CompareTool().compareByContent(destFilename, sourceFolder + "cmp_unnamedFieldsHierarchyTest.pdf", destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destFilename, sourceFolder + "cmp_unnamedFieldsHierarchyTest.pdf", destinationFolder, "diff_")); } @Test @@ -512,7 +510,7 @@ public void copyAndEditTextFields() throws IOException, InterruptedException { destDoc.close(); srcDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(destFilename, cmpFileName, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destFilename, cmpFileName, destinationFolder, "diff_")); } @Test @@ -540,7 +538,7 @@ public void copyAndEditCheckboxes() throws IOException, InterruptedException { destDoc.close(); srcDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(destFilename, cmpFileName, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destFilename, cmpFileName, destinationFolder, "diff_")); } @Test @@ -566,7 +564,7 @@ public void copyAndEditRadioButtons() throws IOException, InterruptedException { destDoc.close(); srcDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(destFilename, cmpFileName, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destFilename, cmpFileName, destinationFolder, "diff_")); } @Test @@ -590,7 +588,7 @@ public void mergeMergedFieldAndMergedFieldTest() throws IOException, Interrupted sourceDoc1.copyPagesTo(1, sourceDoc1.getNumberOfPages(), resultPdfDocument, formCopier); } - Assert.assertNull(new CompareTool().compareByContent(destFilename, cmpFileName, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destFilename, cmpFileName, destinationFolder, "diff_")); } @Test @@ -617,7 +615,7 @@ public void mergeMergedFieldAndTwoWidgetsTest() throws IOException, InterruptedE sourceDoc2.copyPagesTo(1, sourceDoc2.getNumberOfPages(), resultPdfDocument, formCopier); } - Assert.assertNull(new CompareTool().compareByContent(destFilename, cmpFileName, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destFilename, cmpFileName, destinationFolder, "diff_")); } @Test @@ -644,7 +642,7 @@ public void mergeTwoWidgetsAndMergedFieldTest() throws IOException, InterruptedE sourceDoc1.copyPagesTo(1, sourceDoc1.getNumberOfPages(), resultPdfDocument, formCopier); } - Assert.assertNull(new CompareTool().compareByContent(destFilename, cmpFileName, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destFilename, cmpFileName, destinationFolder, "diff_")); } @Test @@ -668,7 +666,7 @@ public void mergeTwoWidgetsAndTwoWidgetsTest() throws IOException, InterruptedEx sourceDoc2.copyPagesTo(1, sourceDoc2.getNumberOfPages(), resultPdfDocument, formCopier); } - Assert.assertNull(new CompareTool().compareByContent(destFilename, cmpFileName, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destFilename, cmpFileName, destinationFolder, "diff_")); } @Test @@ -686,7 +684,7 @@ public void complexFieldsHierarchyTest() throws IOException, InterruptedExceptio pdfDoc.copyPagesTo(1, pdfDoc.getNumberOfPages(), pdfDocMerged, new PdfPageFormCopier()); } - Assert.assertNull(new CompareTool().compareByContent(destFilename, cmpFileName, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destFilename, cmpFileName, destinationFolder, "diff_")); } @Test @@ -698,6 +696,6 @@ public void widgetContainsNoTEntryTest() throws IOException, InterruptedExceptio PdfDocument resultPdfDocument = new PdfDocument(new PdfWriter(destFileName)); sourcePdfDocument.copyPagesTo(1, sourcePdfDocument.getNumberOfPages(), resultPdfDocument, new PdfPageFormCopier()); resultPdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(destFileName, cmpFileName, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destFileName, cmpFileName, destinationFolder, "diff_")); } } diff --git a/forms/src/test/java/com/itextpdf/forms/PdfFormCopyWithGotoTest.java b/forms/src/test/java/com/itextpdf/forms/PdfFormCopyWithGotoTest.java index 1ca514ac54..4a1b735a82 100644 --- a/forms/src/test/java/com/itextpdf/forms/PdfFormCopyWithGotoTest.java +++ b/forms/src/test/java/com/itextpdf/forms/PdfFormCopyWithGotoTest.java @@ -30,16 +30,15 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.annot.PdfWidgetAnnotation; import com.itextpdf.kernel.pdf.navigation.PdfDestination; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; import java.nio.file.Paths; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfFormCopyWithGotoTest extends ExtendedITextTest { public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/forms/PdfFormCopyWithGotoTest/"; @@ -62,7 +61,7 @@ This file is part of the iText (R) project. SOURCE_FOLDER + "LinkWidgetAAMouseUpNamedDestination.pdf"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(DESTINATION_FOLDER); } @@ -92,9 +91,9 @@ public void testLinkWidgetNamedDestinationMissing() throws IOException, Interrup break; } } - Assert.assertNull(((PdfWidgetAnnotation) annot).getAction()); + Assertions.assertNull(((PdfWidgetAnnotation) annot).getAction()); // verify wether name is removed - Assert.assertTrue(resultDoc.getCatalog().getNameTree(PdfName.Dests).getNames().isEmpty()); + Assertions.assertTrue(resultDoc.getCatalog().getNameTree(PdfName.Dests).getNames().isEmpty()); } @Test @@ -123,11 +122,11 @@ public void testLinkWidgetNamedDestinationTargetBecomesPage5() throws IOExceptio break; } } - Assert.assertNotNull(annot); + Assertions.assertNotNull(annot); PdfDestination dest = PdfDestination.makeDestination( ((PdfWidgetAnnotation) annot).getAction().get(PdfName.D)); - Assert.assertEquals(resultDoc.getPage(5).getPdfObject(), + Assertions.assertEquals(resultDoc.getPage(5).getPdfObject(), dest.getDestinationPage(resultDoc.getCatalog().getNameTree(PdfName.Dests))); } @@ -157,9 +156,9 @@ public void testLinkWidgetExplicitDestinationMissing() throws IOException, Inter break; } } - Assert.assertNull(((PdfWidgetAnnotation) annot).getAction()); + Assertions.assertNull(((PdfWidgetAnnotation) annot).getAction()); // verify wether name is removed - Assert.assertTrue(resultDoc.getCatalog().getNameTree(PdfName.Dests).getNames().isEmpty()); + Assertions.assertTrue(resultDoc.getCatalog().getNameTree(PdfName.Dests).getNames().isEmpty()); } @Test @@ -188,11 +187,11 @@ public void testLinkWidgetExplicitDestinationTargetBecomesPage5() throws IOExcep break; } } - Assert.assertNotNull(annot); + Assertions.assertNotNull(annot); PdfDestination dest = PdfDestination.makeDestination( ((PdfWidgetAnnotation) annot).getAction().get(PdfName.D)); - Assert.assertEquals(resultDoc.getPage(5).getPdfObject(), + Assertions.assertEquals(resultDoc.getPage(5).getPdfObject(), dest.getDestinationPage(resultDoc.getCatalog().getNameTree(PdfName.Dests))); } @@ -222,9 +221,9 @@ public void testLinkWidgetAAUpNamedDestinationMissing() throws IOException, Inte break; } } - Assert.assertNull(((PdfWidgetAnnotation) annot).getAction()); + Assertions.assertNull(((PdfWidgetAnnotation) annot).getAction()); // verify wether name is removed - Assert.assertTrue(resultDoc.getCatalog().getNameTree(PdfName.Dests).getNames().isEmpty()); + Assertions.assertTrue(resultDoc.getCatalog().getNameTree(PdfName.Dests).getNames().isEmpty()); } @Test @@ -253,11 +252,11 @@ public void testLinkWidgetAAUpNamedDestinationTargetBecomesPage5() throws IOExce break; } } - Assert.assertNotNull(annot); + Assertions.assertNotNull(annot); PdfDestination dest = PdfDestination.makeDestination( ((PdfWidgetAnnotation) annot).getAdditionalAction().getAsDictionary(PdfName.U).get(PdfName.D)); - Assert.assertEquals(resultDoc.getPage(5).getPdfObject(), + Assertions.assertEquals(resultDoc.getPage(5).getPdfObject(), dest.getDestinationPage(resultDoc.getCatalog().getNameTree(PdfName.Dests))); } @@ -288,9 +287,9 @@ public void testLinkWidgetAAUpExplicitDestinationMissing() throws IOException, I break; } } - Assert.assertNull(((PdfWidgetAnnotation) annot).getAction()); + Assertions.assertNull(((PdfWidgetAnnotation) annot).getAction()); // verify wether name is removed - Assert.assertTrue(resultDoc.getCatalog().getNameTree(PdfName.Dests).getNames().isEmpty()); + Assertions.assertTrue(resultDoc.getCatalog().getNameTree(PdfName.Dests).getNames().isEmpty()); } @Test @@ -319,11 +318,11 @@ public void testLinkWidgetAAUpExplicitDestinationTargetBecomesPage5() throws IOE break; } } - Assert.assertNotNull(annot); + Assertions.assertNotNull(annot); PdfDestination dest = PdfDestination.makeDestination( ((PdfWidgetAnnotation) annot).getAdditionalAction().getAsDictionary(PdfName.U).get(PdfName.D)); - Assert.assertEquals(resultDoc.getPage(5).getPdfObject(), + Assertions.assertEquals(resultDoc.getPage(5).getPdfObject(), dest.getDestinationPage(resultDoc.getCatalog().getNameTree(PdfName.Dests))); } @@ -353,9 +352,9 @@ public void testLinkWidgetAADownNamedDestinationMissing() throws IOException, In break; } } - Assert.assertNull(((PdfWidgetAnnotation) annot).getAction()); + Assertions.assertNull(((PdfWidgetAnnotation) annot).getAction()); // verify wether name is removed - Assert.assertTrue(resultDoc.getCatalog().getNameTree(PdfName.Dests).getNames().isEmpty()); + Assertions.assertTrue(resultDoc.getCatalog().getNameTree(PdfName.Dests).getNames().isEmpty()); } @Test @@ -384,11 +383,11 @@ public void testLinkWidgetAADownNamedDestinationTargetBecomesPage5() throws IOEx break; } } - Assert.assertNotNull(annot); + Assertions.assertNotNull(annot); PdfDestination dest = PdfDestination.makeDestination( ((PdfWidgetAnnotation) annot).getAdditionalAction().getAsDictionary(PdfName.D).get(PdfName.D)); - Assert.assertEquals(resultDoc.getPage(5).getPdfObject(), + Assertions.assertEquals(resultDoc.getPage(5).getPdfObject(), dest.getDestinationPage(resultDoc.getCatalog().getNameTree(PdfName.Dests))); } @@ -419,9 +418,9 @@ public void testLinkWidgetAADownExplicitDestinationMissing() throws IOException, break; } } - Assert.assertNull(((PdfWidgetAnnotation) annot).getAction()); + Assertions.assertNull(((PdfWidgetAnnotation) annot).getAction()); // verify wether name is removed - Assert.assertTrue(resultDoc.getCatalog().getNameTree(PdfName.Dests).getNames().isEmpty()); + Assertions.assertTrue(resultDoc.getCatalog().getNameTree(PdfName.Dests).getNames().isEmpty()); } @Test @@ -450,11 +449,11 @@ public void testLinkWidgetAADownExplicitDestinationTargetBecomesPage5() throws I break; } } - Assert.assertNotNull(annot); + Assertions.assertNotNull(annot); PdfDestination dest = PdfDestination.makeDestination( ((PdfWidgetAnnotation) annot).getAdditionalAction().getAsDictionary(PdfName.D).get(PdfName.D)); - Assert.assertEquals(resultDoc.getPage(5).getPdfObject(), + Assertions.assertEquals(resultDoc.getPage(5).getPdfObject(), dest.getDestinationPage(resultDoc.getCatalog().getNameTree(PdfName.Dests))); } diff --git a/forms/src/test/java/com/itextpdf/forms/PdfFormFieldMultilineTextTest.java b/forms/src/test/java/com/itextpdf/forms/PdfFormFieldMultilineTextTest.java index 9894bb7d69..6b7b0c4061 100644 --- a/forms/src/test/java/com/itextpdf/forms/PdfFormFieldMultilineTextTest.java +++ b/forms/src/test/java/com/itextpdf/forms/PdfFormFieldMultilineTextTest.java @@ -38,28 +38,27 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.layout.properties.TextAlignment; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; import java.util.Map; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfFormFieldMultilineTextTest extends ExtendedITextTest { public static final String destinationFolder = "./target/test/com/itextpdf/forms/PdfFormFieldMultilineTextTest/"; public static final String sourceFolder = "./src/test/resources/com/itextpdf/forms/PdfFormFieldMultilineTextTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } - @AfterClass + @AfterAll public static void afterClass() { } @@ -90,7 +89,7 @@ public void multilineFormFieldTest() throws IOException, InterruptedException { .compareByContent(filename, sourceFolder + "cmp_multilineFormFieldTest.pdf", destinationFolder, "diff_"); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -115,7 +114,7 @@ public void multilineTextFieldWithAlignmentTest() throws IOException, Interrupte CompareTool compareTool = new CompareTool(); String errorMessage = compareTool.compareByContent(outPdf, cmpPdf, destinationFolder, "diff_"); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -140,7 +139,7 @@ public void multilineFormFieldNewLineTest() throws IOException, InterruptedExcep CompareTool compareTool = new CompareTool(); String errorMessage = compareTool.compareByContent(outPdf, cmpPdf, destinationFolder, "diff_"); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -164,7 +163,7 @@ public void multilineFormFieldNewLineFontType3Test() throws IOException, Interru CompareTool compareTool = new CompareTool(); String errorMessage = compareTool.compareByContent(outPdf, cmpPdf, destinationFolder, "diff_"); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -193,7 +192,7 @@ public void notFittingByHeightTest() throws IOException, InterruptedException { .compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_"); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -227,7 +226,7 @@ public void borderWidthIndentMultilineTest() throws IOException, InterruptedExce .compareByContent(filename, sourceFolder + "cmp_borderWidthIndentMultilineTest.pdf", destinationFolder, "diff_"); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -251,7 +250,7 @@ public void formFieldFilledWithStringTest() throws IOException, InterruptedExcep acroForm.addField(form); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "formFieldWithStringTest.pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "formFieldWithStringTest.pdf", sourceFolder + "cmp_formFieldWithStringTest.pdf", destinationFolder, "diff_")); } @@ -277,7 +276,7 @@ public void multilineTextFieldLeadingSpacesAreNotTrimmedTest() throws IOExceptio CompareTool compareTool = new CompareTool(); String errorMessage = compareTool.compareByContent(filename, sourceFolder + "cmp_multilineTextFieldLeadingSpacesAreNotTrimmed.pdf", destinationFolder, "diff_"); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -303,7 +302,7 @@ public void multilineTextFieldRedundantSpacesAreTrimmedTest() throws IOException CompareTool compareTool = new CompareTool(); String errorMessage = compareTool.compareByContent(filename, sourceFolder + "cmp_multilineTextFieldRedundantSpacesAreTrimmedTest.pdf", destinationFolder, "diff_"); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } } diff --git a/forms/src/test/java/com/itextpdf/forms/PdfFormFieldTest.java b/forms/src/test/java/com/itextpdf/forms/PdfFormFieldTest.java index 1ca90ecd7d..e4ab667d18 100644 --- a/forms/src/test/java/com/itextpdf/forms/PdfFormFieldTest.java +++ b/forms/src/test/java/com/itextpdf/forms/PdfFormFieldTest.java @@ -69,23 +69,22 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.ByteArrayInputStream; import java.io.IOException; import java.util.Map; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfFormFieldTest extends ExtendedITextTest { public static final String destinationFolder = "./target/test/com/itextpdf/forms/PdfFormFieldTest/"; public static final String sourceFolder = "./src/test/resources/com/itextpdf/forms/PdfFormFieldTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } @@ -109,9 +108,9 @@ public void formFieldTest01() throws IOException { Map fields = form.getAllFormFields(); PdfFormField field = fields.get("Text1"); - Assert.assertEquals(4, fields.size()); - Assert.assertEquals("Text1", field.getFieldName().toUnicodeString()); - Assert.assertEquals("TestField", field.getValue().toString()); + Assertions.assertEquals(4, fields.size()); + Assertions.assertEquals("Text1", field.getFieldName().toUnicodeString()); + Assertions.assertEquals("TestField", field.getValue().toString()); } @Test @@ -131,7 +130,7 @@ public void formFieldTest02() throws IOException, InterruptedException { CompareTool compareTool = new CompareTool(); String errorMessage = compareTool.compareByContent(filename, sourceFolder + "cmp_formFieldTest02.pdf", destinationFolder, "diff_"); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -156,7 +155,7 @@ public void formFieldTest03() throws IOException, InterruptedException { CompareTool compareTool = new CompareTool(); String errorMessage = compareTool.compareByContent(filename, sourceFolder + "cmp_formFieldTest03.pdf", destinationFolder, "diff_"); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -180,7 +179,7 @@ public void formFieldTest04() throws IOException, InterruptedException { CompareTool compareTool = new CompareTool(); String errorMessage = compareTool.compareByContent(filename, sourceFolder + "cmp_formFieldTest04.pdf", destinationFolder, "diff_"); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -203,7 +202,7 @@ public void formFieldWithFloatBorderTest() throws IOException, InterruptedExcept form.addField(textFormField); } - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @Test @@ -229,7 +228,7 @@ public void textFieldLeadingSpacesAreNotTrimmedTest() throws IOException, Interr String errorMessage = compareTool.compareByContent(filename, sourceFolder + "cmp_textFieldLeadingSpacesAreNotTrimmed.pdf", destinationFolder, "diff_"); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -241,7 +240,7 @@ public void unicodeFormFieldTest() throws IOException { Map formFields = form.getAllFormFields(); // 帐号1: account number 1 String fieldName = "\u5E10\u53F71"; - Assert.assertEquals(fieldName, formFields.keySet().toArray(new String[1])[0]); + Assertions.assertEquals(fieldName, formFields.keySet().toArray(new String[1])[0]); } @Test @@ -251,7 +250,7 @@ public void unicodeFormFieldTest2() throws IOException { PdfAcroForm form = PdfFormCreator.getAcroForm(pdfDoc, true); // 帐号1: account number 1 String fieldName = "\u5E10\u53F71"; - Assert.assertNotNull(form.getField(fieldName)); + Assertions.assertNotNull(form.getField(fieldName)); } @Test @@ -261,7 +260,7 @@ public void textFieldValueInStreamTest() throws IOException { PdfAcroForm form = PdfFormCreator.getAcroForm(pdfDoc, true); String fieldValue = form.getField("fieldName").getValueAsString(); // Trailing newline is not trimmed which seems to match Acrobat's behavior on copy-paste - Assert.assertEquals("some value\n", fieldValue); + Assertions.assertEquals("some value\n", fieldValue); } @Test @@ -293,7 +292,7 @@ public void choiceFieldTest01() throws IOException, InterruptedException { CompareTool compareTool = new CompareTool(); String errorMessage = compareTool.compareByContent(filename, sourceFolder + "cmp_choiceFieldTest01.pdf", destinationFolder, "diff_"); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -335,7 +334,7 @@ public void buttonFieldTest01() throws IOException, InterruptedException { CompareTool compareTool = new CompareTool(); String errorMessage = compareTool.compareByContent(filename, sourceFolder + "cmp_buttonFieldTest01.pdf", destinationFolder, "diff_"); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -364,7 +363,7 @@ public void defaultRadiobuttonFieldTest() throws IOException, InterruptedExcepti pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(filename, sourceFolder + "cmp_" + file, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, sourceFolder + "cmp_" + file, destinationFolder, "diff_")); } @Test @@ -400,7 +399,7 @@ public void customizedRadiobuttonFieldTest() throws IOException, InterruptedExce pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(filename, sourceFolder + "cmp_" + file, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, sourceFolder + "cmp_" + file, destinationFolder, "diff_")); } @Test @@ -438,7 +437,7 @@ public void customizedRadiobuttonWithGroupRegeneratingFieldTest() throws IOExcep pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(filename, sourceFolder + "cmp_" + file, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, sourceFolder + "cmp_" + file, destinationFolder, "diff_")); } @Test @@ -465,7 +464,7 @@ public void customizedPushButtonFieldTest() throws IOException, InterruptedExcep pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(filename, sourceFolder + "cmp_" + file, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, sourceFolder + "cmp_" + file, destinationFolder, "diff_")); } @Test @@ -492,7 +491,7 @@ public void customizedPushButtonField2Test() throws IOException, InterruptedExce pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(filename, sourceFolder + "cmp_" + file, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, sourceFolder + "cmp_" + file, destinationFolder, "diff_")); } @Test @@ -519,7 +518,7 @@ public void customizedPushButtonField3Test() throws IOException, InterruptedExce pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(filename, sourceFolder + "cmp_" + file, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, sourceFolder + "cmp_" + file, destinationFolder, "diff_")); } @Test @@ -536,7 +535,7 @@ public void buttonFieldTest02() throws IOException, InterruptedException { CompareTool compareTool = new CompareTool(); String errorMessage = compareTool.compareByContent(filename, sourceFolder + "cmp_buttonFieldTest02.pdf", destinationFolder, "diff_"); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -555,7 +554,7 @@ public void realFontSizeRegenerateAppearanceTest() throws IOException, Interrupt CompareTool compareTool = new CompareTool(); String errorMessage = compareTool.compareByContent(destFilename, sourceFolder + "cmp_realFontSizeRegenerateAppearance.pdf", destinationFolder, "diff_"); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -577,7 +576,7 @@ public void addFieldWithKidsTest() { form.addField(root); - Assert.assertEquals(3, form.getAllFormFields().size()); + Assertions.assertEquals(3, form.getAllFormFields().size()); } @Test @@ -601,7 +600,7 @@ public void fillFormWithDefaultResources() throws IOException, InterruptedExcept CompareTool compareTool = new CompareTool(); String errorMessage = compareTool.compareByContent(outPdf, cmpPdf, destinationFolder, "diff_"); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -626,7 +625,7 @@ public void fillFormTwiceWithoutResources() throws IOException, InterruptedExcep CompareTool compareTool = new CompareTool(); String errorMessage = compareTool.compareByContent(outPdf, cmpPdf, destinationFolder, "diff_"); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -650,7 +649,7 @@ public void autoScaleFontSizeInFormFields() throws IOException, InterruptedExcep CompareTool compareTool = new CompareTool(); String errorMessage = compareTool.compareByContent(outPdf, cmpPdf, destinationFolder, "diff_"); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -670,7 +669,7 @@ public void acroFieldDictionaryNoFields() throws IOException, InterruptedExcepti CompareTool compareTool = new CompareTool(); String errorMessage = compareTool.compareByContent(outPdf, cmpPdf, destinationFolder, "diff_"); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -690,7 +689,7 @@ public void regenerateAppearance() throws IOException, InterruptedException { } } document.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + output, + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + output, sourceFolder + "cmp_" + output, destinationFolder, "diff")); } @@ -706,7 +705,7 @@ public void regenerateAppearance2() throws IOException, InterruptedException { PdfFormField field = acro.getField("number"); field.setValue("20150044DR"); document.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + output, + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + output, sourceFolder + "cmp_" + output, destinationFolder, "diff")); } @@ -731,7 +730,7 @@ public void flushedPagesTest() throws IOException, InterruptedException { CompareTool compareTool = new CompareTool(); String errorMessage = compareTool.compareByContent(filename, sourceFolder + "cmp_flushedPagesTest.pdf", destinationFolder, "diff_"); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -761,7 +760,7 @@ public void fillFormWithDefaultResourcesUpdateFont() throws IOException, Interru CompareTool compareTool = new CompareTool(); String errorMessage = compareTool.compareByContent(outPdf, cmpPdf, destinationFolder, "diff_"); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -788,7 +787,7 @@ public void formRegenerateWithInvalidDefaultAppearance01() throws IOException, I CompareTool compareTool = new CompareTool(); String errorMessage = compareTool.compareByContent(outPdf, cmpPdf, destinationFolder, "diff_"); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -820,7 +819,7 @@ public void fillFieldWithHebrewCase1() throws IOException, InterruptedException pdfDoc.close(); - Assert.assertNull( + Assertions.assertNull( new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff" + testName + "_")); } @@ -859,7 +858,7 @@ public void fillFieldWithHebrewCase2() throws IOException, InterruptedException fillAcroForm(pdfDocument, text); pdfDocument.close(); - Assert.assertNull( + Assertions.assertNull( new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff" + testName + "_")); } @@ -887,7 +886,7 @@ public void fillFieldWithHebrewCase3() throws IOException, InterruptedException pdfDoc.close(); - Assert.assertNull( + Assertions.assertNull( new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff" + testName + "_")); } @@ -922,7 +921,7 @@ public void fillFieldWithHebrewCase4() throws IOException, InterruptedException fillAcroForm(pdfDocument, text); pdfDocument.close(); - Assert.assertNull( + Assertions.assertNull( new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff" + testName + "_")); } @@ -947,7 +946,7 @@ public void fillFormWithSameEmptyObjsForAppearance() throws IOException, Interru CompareTool compareTool = new CompareTool(); String errorMessage = compareTool.compareByContent(outPdf, cmpPdf, destinationFolder, "diff_"); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -986,7 +985,7 @@ public void dashedBorderAppearanceTest() throws IOException, InterruptedExceptio CompareTool compareTool = new CompareTool(); String errorMessage = compareTool.compareByContent(outPdf, cmpPdf, destinationFolder, "diff_"); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -1016,7 +1015,7 @@ public void noMaxLenWithSetCombFlagTest() throws IOException, InterruptedExcepti CompareTool compareTool = new CompareTool(); String errorMessage = compareTool.compareByContent(outPdf, cmpPdf, destinationFolder, "diff_"); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -1041,7 +1040,7 @@ public void maxLenWithSetCombFlagAppearanceTest() throws IOException, Interrupte CompareTool compareTool = new CompareTool(); String errorMessage = compareTool.compareByContent(outPdf, cmpPdf, destinationFolder, "diff_"); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -1061,7 +1060,7 @@ public void preserveFontPropsTest() throws IOException, InterruptedException { CompareTool compareTool = new CompareTool(); String errorMessage = compareTool.compareByContent(outPdf, cmpPdf, destinationFolder, "diff_"); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -1082,7 +1081,7 @@ public void fontAutoSizeButtonFieldTest() throws IOException, InterruptedExcepti form.addField(button); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); } @Test @@ -1101,7 +1100,7 @@ public void maxLenInheritanceTest() throws IOException, InterruptedException { CompareTool compareTool = new CompareTool(); String errorMessage = compareTool.compareByContent(outPdf, cmpPdf, destinationFolder, "diff_"); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -1118,7 +1117,7 @@ public void maxLenDeepInheritanceTest() throws IOException, InterruptedException destDoc.close(); - Assert.assertNull( + Assertions.assertNull( new CompareTool().compareByContent(destFilename, cmpFilename, destinationFolder, "diff_")); } @@ -1137,7 +1136,7 @@ public void maxLenColoredTest() throws IOException, InterruptedException { CompareTool compareTool = new CompareTool(); String errorMessage = compareTool.compareByContent(outPdf, cmpPdf, destinationFolder, "diff_"); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -1164,7 +1163,7 @@ public void regenerateMaxLenCombTest() throws IOException, InterruptedException CompareTool compareTool = new CompareTool(); String errorMessage = compareTool.compareByContent(outPdf, cmpPdf, destinationFolder, "diff_"); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -1197,7 +1196,7 @@ public void wrapPrecedingContentOnFlattenTest() throws IOException, InterruptedE CompareTool compareTool = new CompareTool(); String errorMessage = compareTool.compareByContent(filename, sourceFolder + "cmp_wrapPrecedingContentOnFlattenTest.pdf", destinationFolder, "diff_"); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -1223,10 +1222,13 @@ public void pdfWithDifferentFieldsTest() throws IOException, InterruptedExceptio // list PdfChoiceFormField f = new ChoiceFormFieldBuilder(pdfDoc, "combo") .setWidgetRectangle(new Rectangle(36, 556, 50, 100)).setOptions(new String[]{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"}).createList(); + f.disableFieldRegeneration(); f.setValue("9", true); f.setValue("4"); f.setTopIndex(2); f.setListSelected(new String[]{"3", "5"}); + f.setMultiSelect(true); + f.enableFieldRegeneration(); form.addField(f); // push button form.addField(new PushButtonFormFieldBuilder(pdfDoc, "push button") @@ -1256,7 +1258,7 @@ public void pdfWithDifferentFieldsTest() throws IOException, InterruptedExceptio pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(fileName, sourceFolder + "cmp_pdfWithDifferentFieldsTest.pdf", destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(fileName, sourceFolder + "cmp_pdfWithDifferentFieldsTest.pdf", destinationFolder, "diff_")); } @Test @@ -1291,15 +1293,15 @@ public void textFieldWithWideUnicodeRange() throws IOException, InterruptedExcep pdfDoc.close(); - Assert.assertNull( + Assertions.assertNull( new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_")); } @Test public void testMakeField() { - Assert.assertNull(PdfFormField.makeFormField(new PdfNumber(1), null)); - Assert.assertNull(PdfFormField.makeFormField(new PdfArray(), null)); + Assertions.assertNull(PdfFormField.makeFormField(new PdfNumber(1), null)); + Assertions.assertNull(PdfFormField.makeFormField(new PdfArray(), null)); } @Test @@ -1324,7 +1326,7 @@ public void testDaInAppendMode() throws IOException { da = ((PdfDictionary) pdfDoc.getPdfObject(objectNumber)).getAsString(PdfName.DA); } - Assert.assertEquals("/F1 35 Tf 1 0 1 rg", da.toString()); + Assertions.assertEquals("/F1 35 Tf 1 0 1 rg", da.toString()); } @Test @@ -1351,19 +1353,19 @@ public void setPageNewField() throws IOException { PdfDocument resPdf = new PdfDocument(new PdfReader(filename)); PdfArray fieldsArr = resPdf.getCatalog().getPdfObject() .getAsDictionary(PdfName.AcroForm).getAsArray(PdfName.Fields); - Assert.assertEquals(1, fieldsArr.size()); + Assertions.assertEquals(1, fieldsArr.size()); PdfDictionary field = fieldsArr.getAsDictionary(0); PdfDictionary fieldP = field.getAsDictionary(PdfName.P); - Assert.assertEquals(resPdf.getPage(2).getPdfObject(), fieldP); + Assertions.assertEquals(resPdf.getPage(2).getPdfObject(), fieldP); - Assert.assertNull(resPdf.getPage(1).getPdfObject().getAsArray(PdfName.Annots)); + Assertions.assertNull(resPdf.getPage(1).getPdfObject().getAsArray(PdfName.Annots)); PdfArray secondPageAnnots = resPdf.getPage(2).getPdfObject().getAsArray(PdfName.Annots); - Assert.assertEquals(1, secondPageAnnots.size()); - Assert.assertEquals(field, secondPageAnnots.get(0)); + Assertions.assertEquals(1, secondPageAnnots.size()); + Assertions.assertEquals(field, secondPageAnnots.get(0)); - Assert.assertNull(resPdf.getPage(3).getPdfObject().getAsArray(PdfName.Annots)); + Assertions.assertNull(resPdf.getPage(3).getPdfObject().getAsArray(PdfName.Annots)); } private void createAcroForm(PdfDocument pdfDoc, PdfAcroForm form, PdfFont font, String text, int offSet) { @@ -1416,13 +1418,12 @@ public void setFont2Ways() throws IOException, InterruptedException { pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @Test // Acrobat removes /NeedAppearances flag when document is opened and suggests to resave the document at once. - @LogMessages(messages = {@LogMessage(messageTemplate = LayoutLogMessageConstant.ELEMENT_DOES_NOT_FIT_AREA), - @LogMessage(messageTemplate = FormsLogMessageConstants.INPUT_FIELD_DOES_NOT_FIT)}) + @LogMessages(messages = {@LogMessage(messageTemplate = FormsLogMessageConstants.INPUT_FIELD_DOES_NOT_FIT)}) public void appendModeAppearance() throws IOException, InterruptedException { String inputFile = "appendModeAppearance.pdf"; String outputFile = "appendModeAppearance.pdf"; @@ -1443,7 +1444,7 @@ public void appendModeAppearance() throws IOException, InterruptedException { pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + outputFile, + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + outputFile, sourceFolder + "cmp_" + outputFile, destinationFolder, "diff_")); } @@ -1457,7 +1458,7 @@ public void fillUnmergedTextFormField() throws IOException, InterruptedException fillAcroForm(pdfDocument, text); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "fillUnmergedTextFormField.pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "fillUnmergedTextFormField.pdf", sourceFolder + "cmp_" + "fillUnmergedTextFormField.pdf", destinationFolder, "diff_")); } @@ -1488,7 +1489,7 @@ public void choiceFieldAutoSize01Test() throws IOException, InterruptedException CompareTool compareTool = new CompareTool(); String errorMessage = compareTool.compareByContent(filename, sourceFolder + "cmp_choiceFieldAutoSize01Test.pdf", destinationFolder, "diff_"); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -1513,7 +1514,7 @@ public void choiceFieldAutoSize02Test() throws IOException, InterruptedException CompareTool compareTool = new CompareTool(); String errorMessage = compareTool.compareByContent(filename, sourceFolder + "cmp_choiceFieldAutoSize02Test.pdf", destinationFolder, "diff_"); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -1545,7 +1546,7 @@ public void borderWidthIndentSingleLineTest() throws IOException, InterruptedExc CompareTool compareTool = new CompareTool(); String errorMessage = compareTool.compareByContent(filename, sourceFolder + "cmp_borderWidthIndentSingleLineTest.pdf", destinationFolder, "diff_"); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -1568,7 +1569,7 @@ public void releaseAcroformTest() throws IOException, InterruptedException { form.release(); } - Assert.assertNull(new CompareTool().compareByContent(outStampingRelease, outPureStamping, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outStampingRelease, outPureStamping, destinationFolder)); } @Test @@ -1587,12 +1588,12 @@ public void addChildToFormFieldTest() throws InterruptedException, IOException { root.addKid(child); acroForm.addField(root); - Assert.assertEquals(2, acroForm.fields.size()); + Assertions.assertEquals(2, acroForm.fields.size()); PdfArray fieldKids = root.getKids(); - Assert.assertEquals(2, fieldKids.size()); + Assertions.assertEquals(2, fieldKids.size()); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder)); } @Test @@ -1615,7 +1616,7 @@ public void duplicateFormTest() throws IOException, InterruptedException { pdfAcroForm.getField("checkbox").setValue("Off"); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); } @Test @@ -1628,13 +1629,13 @@ public void getValueTest() throws IOException, InterruptedException { for (AbstractPdfFormField field : acroForm.getAllFormFieldsAndAnnotations()) { if (field instanceof PdfFormField && "child".equals(field.getPdfObject().get(PdfName.V).toString())) { // Child has value "root" still because it doesn't contain T entry - Assert.assertEquals("root", ((PdfFormField) field).getValue().toString()); + Assertions.assertEquals("root", ((PdfFormField) field).getValue().toString()); } field.regenerateField(); } } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); } @Test @@ -1694,7 +1695,7 @@ public void setValueWithDisplayTest() throws IOException, InterruptedException { acroForm.addField(checkBoxField); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); } @Test @@ -1711,7 +1712,7 @@ public void setNullValueTest() throws IOException, InterruptedException { acroForm.addField(textField); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); } @Test @@ -1719,7 +1720,7 @@ public void getSigFlagsTest() { try (PdfDocument doc = new PdfDocument(new PdfWriter(new ByteArrayOutputStream()))) { PdfAcroForm form = PdfFormCreator.getAcroForm(doc, true); form.setSignatureFlag(1); - Assert.assertEquals(1, form.getSignatureFlags()); + Assertions.assertEquals(1, form.getSignatureFlags()); } } @@ -1743,33 +1744,33 @@ public void disableRegenerationForTheRootFieldTest() throws IOException, Interru .setBorderWidth(3).setBorderColor(ColorConstants.DARK_GRAY).setBackgroundColor(ColorConstants.PINK) .setVisibility(PdfFormAnnotation.VISIBLE); - Assert.assertEquals(0, root.getCounter()); - Assert.assertEquals(0, parent.getCounter()); - Assert.assertEquals(0, child.getCounter()); + Assertions.assertEquals(0, root.getCounter()); + Assertions.assertEquals(0, parent.getCounter()); + Assertions.assertEquals(0, child.getCounter()); root.enableFieldRegeneration(); - Assert.assertEquals(1, root.getCounter()); - Assert.assertEquals(1, parent.getCounter()); - Assert.assertEquals(1, child.getCounter()); + Assertions.assertEquals(1, root.getCounter()); + Assertions.assertEquals(1, parent.getCounter()); + Assertions.assertEquals(1, child.getCounter()); // Disable only root field regeneration root.disableCurrentFieldRegeneration(); root.regenerateField(); - Assert.assertEquals(1, root.getCounter()); - Assert.assertEquals(2, parent.getCounter()); - Assert.assertEquals(2, child.getCounter()); + Assertions.assertEquals(1, root.getCounter()); + Assertions.assertEquals(2, parent.getCounter()); + Assertions.assertEquals(2, child.getCounter()); root.enableCurrentFieldRegeneration(); - Assert.assertEquals(2, root.getCounter()); - Assert.assertEquals(3, parent.getCounter()); - Assert.assertEquals(3, child.getCounter()); + Assertions.assertEquals(2, root.getCounter()); + Assertions.assertEquals(3, parent.getCounter()); + Assertions.assertEquals(3, child.getCounter()); form.addField(root); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder)); } @Test @@ -1793,33 +1794,33 @@ public void disableRegenerationForTheMiddleFieldTest() throws IOException, Inter .setVisibility(PdfFormAnnotation.VISIBLE); root.regenerateField(); - Assert.assertEquals(1, root.getCounter()); - Assert.assertEquals(0, parent.getCounter()); - Assert.assertEquals(0, child.getCounter()); + Assertions.assertEquals(1, root.getCounter()); + Assertions.assertEquals(0, parent.getCounter()); + Assertions.assertEquals(0, child.getCounter()); parent.enableFieldRegeneration(); - Assert.assertEquals(1, root.getCounter()); - Assert.assertEquals(1, parent.getCounter()); - Assert.assertEquals(1, child.getCounter()); + Assertions.assertEquals(1, root.getCounter()); + Assertions.assertEquals(1, parent.getCounter()); + Assertions.assertEquals(1, child.getCounter()); // Disable only parent field regeneration parent.disableCurrentFieldRegeneration(); root.regenerateField(); - Assert.assertEquals(2, root.getCounter()); - Assert.assertEquals(1, parent.getCounter()); - Assert.assertEquals(2, child.getCounter()); + Assertions.assertEquals(2, root.getCounter()); + Assertions.assertEquals(1, parent.getCounter()); + Assertions.assertEquals(2, child.getCounter()); parent.enableCurrentFieldRegeneration(); - Assert.assertEquals(2, root.getCounter()); - Assert.assertEquals(2, parent.getCounter()); - Assert.assertEquals(3, child.getCounter()); + Assertions.assertEquals(2, root.getCounter()); + Assertions.assertEquals(2, parent.getCounter()); + Assertions.assertEquals(3, child.getCounter()); form.addField(root); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder)); } @Test @@ -1842,15 +1843,15 @@ public void disableChildRegenerationTest() throws IOException, InterruptedExcept .setBackgroundColor(ColorConstants.BLUE); root.regenerateField(); - Assert.assertEquals(1, root.getCounter()); - Assert.assertEquals(1, parent.getCounter()); - Assert.assertEquals(0, child.getCounter()); + Assertions.assertEquals(1, root.getCounter()); + Assertions.assertEquals(1, parent.getCounter()); + Assertions.assertEquals(0, child.getCounter()); child.enableFieldRegeneration(); - Assert.assertEquals(1, root.getCounter()); - Assert.assertEquals(1, parent.getCounter()); - Assert.assertEquals(1, child.getCounter()); + Assertions.assertEquals(1, root.getCounter()); + Assertions.assertEquals(1, parent.getCounter()); + Assertions.assertEquals(1, child.getCounter()); // Disable only child field regeneration (so widget should be regenerated) child.disableCurrentFieldRegeneration(); @@ -1859,13 +1860,13 @@ public void disableChildRegenerationTest() throws IOException, InterruptedExcept .setBorderWidth(3).setBorderColor(ColorConstants.DARK_GRAY).setBackgroundColor(ColorConstants.PINK) .setVisibility(PdfFormAnnotation.VISIBLE); - Assert.assertEquals(1, root.getCounter()); - Assert.assertEquals(1, parent.getCounter()); - Assert.assertEquals(1, child.getCounter()); + Assertions.assertEquals(1, root.getCounter()); + Assertions.assertEquals(1, parent.getCounter()); + Assertions.assertEquals(1, child.getCounter()); form.addField(root); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder)); } @Test @@ -1905,7 +1906,7 @@ public void signatureLayersTest() throws IOException, InterruptedException { form.addField(signField); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(fileName, sourceFolder + "cmp_signatureLayersTest.pdf", + Assertions.assertNull(new CompareTool().compareByContent(fileName, sourceFolder + "cmp_signatureLayersTest.pdf", destinationFolder, "diff_")); } @@ -1931,7 +1932,7 @@ public void pdfWithSignatureFieldTest() throws IOException, InterruptedException pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(fileName, + Assertions.assertNull(new CompareTool().compareByContent(fileName, sourceFolder + "cmp_pdfWithSignatureFieldTest.pdf", destinationFolder, "diff_")); } @@ -1959,7 +1960,7 @@ public void pdfWithSignatureAndFontInBuilderFieldTest() throws IOException, Inte pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(fileName, + Assertions.assertNull(new CompareTool().compareByContent(fileName, sourceFolder + "cmp_pdfWithSignatureAndFontInBuilderFieldTest.pdf", destinationFolder, "diff_")); } diff --git a/forms/src/test/java/com/itextpdf/forms/PdfFormFieldTextTest.java b/forms/src/test/java/com/itextpdf/forms/PdfFormFieldTextTest.java index 32fbf72830..da6d80d9dc 100644 --- a/forms/src/test/java/com/itextpdf/forms/PdfFormFieldTextTest.java +++ b/forms/src/test/java/com/itextpdf/forms/PdfFormFieldTextTest.java @@ -39,23 +39,22 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfWriter; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; import java.util.Map; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfFormFieldTextTest extends ExtendedITextTest { public static final String destinationFolder = "./target/test/com/itextpdf/forms/PdfFormFieldTextTest/"; public static final String sourceFolder = "./src/test/resources/com/itextpdf/forms/PdfFormFieldTextTest/"; private static final String TEXT = "Some text in Russian \u0442\u0435\u043A\u0441\u0442 (text)"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } @@ -73,7 +72,7 @@ public void fillFormWithAutosizeTest() throws IOException, InterruptedException fields.get("Second field").setValue("surname surname surname surname surname surname"); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); } @Test @@ -89,7 +88,7 @@ public void defaultAppearanceExtractionForNotMergedFieldsTest() throws IOExcepti String errorMessage = compareTool.compareByContent(destinationFolder + "defaultAppearanceExtractionTest.pdf", sourceFolder + "cmp_defaultAppearanceExtractionTest.pdf", destinationFolder, "diff_"); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -116,11 +115,13 @@ public void fontsResourcesHelvFontTest() throws IOException { PdfObject actualFieldDAFont = document.getCatalog().getPdfObject().getAsDictionary(PdfName.AcroForm) .getAsArray(PdfName.Fields).getAsDictionary(0).get(PdfName.DA); - Assert.assertEquals("There is no Helvetica font within DR key", new PdfName("Helvetica"), - actualDocumentFonts.getAsDictionary(new PdfName("F1")).get(PdfName.BaseFont)); - Assert.assertEquals("There is no NotoSans font within DR key.", new PdfName("NotoSans"), - actualDocumentFonts.getAsDictionary(new PdfName("F2")).get(PdfName.BaseFont)); - Assert.assertEquals("There is no NotoSans(/F2) font within Fields DA key", expectedFieldsDAFont, actualFieldDAFont); + Assertions.assertEquals(new PdfName("Helvetica"), + actualDocumentFonts.getAsDictionary(new PdfName("F1")).get(PdfName.BaseFont), + "There is no Helvetica font within DR key"); + Assertions.assertEquals(new PdfName("NotoSans"), + actualDocumentFonts.getAsDictionary(new PdfName("F2")).get(PdfName.BaseFont), + "There is no NotoSans font within DR key."); + Assertions.assertEquals(expectedFieldsDAFont, actualFieldDAFont, "There is no NotoSans(/F2) font within Fields DA key"); document.close(); @@ -153,14 +154,17 @@ public void fontsResourcesHelvCourierNotoFontTest() throws IOException { PdfObject actualFieldDAFont = document.getCatalog().getPdfObject().getAsDictionary(PdfName.AcroForm) .getAsArray(PdfName.Fields).getAsDictionary(0).get(PdfName.DA); - Assert.assertEquals("There is no Helvetica font within DR key", new PdfName("Helvetica"), - actualDocumentFonts.getAsDictionary(new PdfName("F1")).get(PdfName.BaseFont)); - Assert.assertEquals("There is no Courier font within DR key.", new PdfName("Courier"), - actualDocumentFonts.getAsDictionary(new PdfName("F2")).get(PdfName.BaseFont)); - Assert.assertEquals("There is no NotoSans font within DR key.", new PdfName("NotoSans"), - actualDocumentFonts.getAsDictionary(new PdfName("F3")).get(PdfName.BaseFont)); - Assert.assertEquals("There is no Helvetica(/F1) font within AcroForm DA key", expectedAcroformDAFont, actualAcroFormDAFont); - Assert.assertEquals("There is no NotoSans(/F3) font within Fields DA key", expectedFieldsDAFont, actualFieldDAFont); + Assertions.assertEquals(new PdfName("Helvetica"), + actualDocumentFonts.getAsDictionary(new PdfName("F1")).get(PdfName.BaseFont), + "There is no Helvetica font within DR key"); + Assertions.assertEquals(new PdfName("Courier"), + actualDocumentFonts.getAsDictionary(new PdfName("F2")).get(PdfName.BaseFont), + "There is no Courier font within DR key."); + Assertions.assertEquals(new PdfName("NotoSans"), + actualDocumentFonts.getAsDictionary(new PdfName("F3")).get(PdfName.BaseFont), + "There is no NotoSans font within DR key."); + Assertions.assertEquals(expectedAcroformDAFont, actualAcroFormDAFont, "There is no Helvetica(/F1) font within AcroForm DA key"); + Assertions.assertEquals(expectedFieldsDAFont, actualFieldDAFont, "There is no NotoSans(/F3) font within Fields DA key"); document.close(); @@ -186,6 +190,6 @@ public void lineEndingsTest() throws IOException, InterruptedException { form.addField(field2); } - Assert.assertNull(new CompareTool().compareByContent(destFilename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destFilename, cmpFilename, destinationFolder, "diff_")); } } diff --git a/forms/src/test/java/com/itextpdf/forms/PdfFormFieldsHierarchyTest.java b/forms/src/test/java/com/itextpdf/forms/PdfFormFieldsHierarchyTest.java index 11dbe13e3d..de5848c766 100644 --- a/forms/src/test/java/com/itextpdf/forms/PdfFormFieldsHierarchyTest.java +++ b/forms/src/test/java/com/itextpdf/forms/PdfFormFieldsHierarchyTest.java @@ -29,23 +29,21 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfWriter; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; import java.util.Map; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; - -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfFormFieldsHierarchyTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/forms/PdfFormFieldsHierarchyTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/forms/PdfFormFieldsHierarchyTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } @@ -72,7 +70,7 @@ public void fillingFormWithKidsTest() throws IOException, InterruptedException { CompareTool compareTool = new CompareTool(); String errorMessage = compareTool.compareByContent(outPdf, cmpPdf, destinationFolder); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -93,7 +91,7 @@ public void autosizeInheritedDAFormFieldsTest() throws IOException, InterruptedE pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(inPdf, + Assertions.assertNull(new CompareTool().compareByContent(inPdf, sourceFolder + "cmp_autosizeInheritedDAFormFields.pdf", destinationFolder, "diff_")); } @@ -112,7 +110,7 @@ public void autosizeInheritedDAFormFieldsWithKidsTest() throws IOException, Inte pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(inPdf, + Assertions.assertNull(new CompareTool().compareByContent(inPdf, sourceFolder + "cmp_autosizeInheritedDAFormFieldsWithKids.pdf", destinationFolder, inPdf)); } @@ -134,7 +132,7 @@ public void alignmentInheritanceInFieldsTest() throws IOException, InterruptedEx pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(fileName, sourceFolder + "cmp_" + name + ".pdf", + Assertions.assertNull(new CompareTool().compareByContent(fileName, sourceFolder + "cmp_" + name + ".pdf", destinationFolder + name, "diff_")); } } diff --git a/forms/src/test/java/com/itextpdf/forms/PdfUA2FormTest.java b/forms/src/test/java/com/itextpdf/forms/PdfUA2FormTest.java index fbe58e34ee..424b4f3ed2 100644 --- a/forms/src/test/java/com/itextpdf/forms/PdfUA2FormTest.java +++ b/forms/src/test/java/com/itextpdf/forms/PdfUA2FormTest.java @@ -53,25 +53,24 @@ This file is part of the iText (R) project. import com.itextpdf.layout.element.Div; import com.itextpdf.layout.element.Paragraph; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import com.itextpdf.test.pdfa.VeraPdfValidator; // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) import java.io.ByteArrayInputStream; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; +import static org.junit.jupiter.api.Assertions.fail; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfUA2FormTest extends ExtendedITextTest { public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/forms/PdfUA2FormTest/"; public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/forms//PdfUA2FormTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(DESTINATION_FOLDER); } @@ -197,7 +196,7 @@ private void createSimplePdfUA2Document(PdfDocument pdfDocument) throws IOExcept } private void compareAndValidate(String outPdf, String cmpPdf) throws IOException, InterruptedException { - Assert.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) String result = new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_"); if (result != null) { fail(result); diff --git a/forms/src/test/java/com/itextpdf/forms/Utf8FormsTest.java b/forms/src/test/java/com/itextpdf/forms/Utf8FormsTest.java index 7e8ba95a44..56fff0db28 100644 --- a/forms/src/test/java/com/itextpdf/forms/Utf8FormsTest.java +++ b/forms/src/test/java/com/itextpdf/forms/Utf8FormsTest.java @@ -36,22 +36,20 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfWriter; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; - +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.util.Map; -@Category(UnitTest.class) +@Tag("UnitTest") public class Utf8FormsTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/forms/Utf8FormsTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/forms/Utf8FormsTest/"; public static final String FONT = "./src/test/resources/com/itextpdf/forms/Utf8FormsTest/NotoSansCJKsc-Regular.otf"; - @Before + @BeforeEach public void before() { createDestinationFolder(destinationFolder); } @@ -65,7 +63,7 @@ public void readUtf8FieldName() throws java.io.IOException { pdfDoc.close(); for (String fldName : fields.keySet()) { // لا - Assert.assertEquals("\u0644\u0627", fldName); + Assertions.assertEquals("\u0644\u0627", fldName); } pdfDoc.close(); } @@ -79,7 +77,7 @@ public void readUtf8TextAnnot() throws java.io.IOException { pdfDoc.close(); for (String fldName : fields.keySet()) { // 福昕 福昕UTF8 - Assert.assertEquals("\u798F\u6615 \u798F\u6615UTF8", fields.get(fldName).getValueAsString()); + Assertions.assertEquals("\u798F\u6615 \u798F\u6615UTF8", fields.get(fldName).getValueAsString()); } } @@ -99,6 +97,6 @@ public void writeUtf8FieldNameAndValue() throws java.io.IOException, Interrupted field.regenerateField(); form.addField(field); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "writeUtf8FieldNameAndValue.pdf", sourceFolder + "cmp_writeUtf8FieldNameAndValue.pdf", destinationFolder, "diffFieldNameAndValue_")); + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "writeUtf8FieldNameAndValue.pdf", sourceFolder + "cmp_writeUtf8FieldNameAndValue.pdf", destinationFolder, "diffFieldNameAndValue_")); } } diff --git a/forms/src/test/java/com/itextpdf/forms/XfdfReaderTest.java b/forms/src/test/java/com/itextpdf/forms/XfdfReaderTest.java index 3c6bf55a49..1c46bbd71d 100644 --- a/forms/src/test/java/com/itextpdf/forms/XfdfReaderTest.java +++ b/forms/src/test/java/com/itextpdf/forms/XfdfReaderTest.java @@ -33,25 +33,24 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; import javax.xml.parsers.ParserConfigurationException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import org.xml.sax.SAXException; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class XfdfReaderTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/forms/XfdfReaderTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/forms/XfdfReaderTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } @@ -67,7 +66,7 @@ public void xfdfNoFields() throws IOException, ParserConfigurationException, SAX XfdfObject xfdfObject = factory.createXfdfObject(FileUtil.getInputStreamForFile(xfdfFilename)); xfdfObject.mergeToPdf(pdfDocument, sourceFolder + "xfdfNoFields.pdf"); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfNoFields.pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfNoFields.pdf", sourceFolder + "cmp_xfdfNoFields.pdf", destinationFolder, "diff_")); } @@ -81,7 +80,7 @@ public void xfdfNoFieldsNoFAttributes() throws IOException, ParserConfigurationE XfdfObject xfdfObject = factory.createXfdfObject(FileUtil.getInputStreamForFile(xfdfFilename)); xfdfObject.mergeToPdf(pdfDocument, sourceFolder + "xfdfNoFieldsNoFAttributes.pdf"); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfNoFieldsNoFAttributes.pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfNoFieldsNoFAttributes.pdf", sourceFolder + "cmp_xfdfNoFieldsNoFAttributes.pdf", destinationFolder, "diff_")); } @@ -95,7 +94,7 @@ public void xfdfNoFieldsNoIdsAttributes() throws IOException, ParserConfiguratio XfdfObject xfdfObject = factory.createXfdfObject(FileUtil.getInputStreamForFile(xfdfFilename)); xfdfObject.mergeToPdf(pdfDocument, sourceFolder + "xfdfNoFieldsNoIdsAttributes.pdf"); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfNoFieldsNoIdsAttributes.pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfNoFieldsNoIdsAttributes.pdf", sourceFolder + "cmp_xfdfNoFieldsNoIdsAttributes.pdf", destinationFolder, "diff_")); } @@ -109,7 +108,7 @@ public void xfdfWithFieldsWithValue() throws IOException, ParserConfigurationExc XfdfObject xfdfObject = factory.createXfdfObject(FileUtil.getInputStreamForFile(xfdfFilename)); xfdfObject.mergeToPdf(pdfDocument, sourceFolder + "xfdfWithFieldsWithValue.pdf"); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfWithFieldsWithValue.pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfWithFieldsWithValue.pdf", sourceFolder + "cmp_xfdfWithFieldsWithValue.pdf", destinationFolder, "diff_")); } @@ -127,7 +126,7 @@ public void xfdfValueRichText() throws IOException, ParserConfigurationException XfdfObject xfdfObject = factory.createXfdfObject(FileUtil.getInputStreamForFile(xfdfFilename)); xfdfObject.mergeToPdf(pdfDocument, sourceFolder + "xfdfValueRichText.pdf"); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfValueRichText.pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfValueRichText.pdf", sourceFolder + "cmp_xfdfValueRichText.pdf", destinationFolder, "diff_")); } @@ -144,7 +143,7 @@ public void xfdfHierarchyFieldsTest() throws IOException, ParserConfigurationExc XfdfObject xfdfObject = factory.createXfdfObject(FileUtil.getInputStreamForFile(xfdfFilename)); xfdfObject.mergeToPdf(pdfDocument, sourceFolder + "hierarchy_fields.pdf"); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "hierarchy_fields.pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "hierarchy_fields.pdf", sourceFolder + "cmp_hierarchy_fields.pdf", destinationFolder, "diff_")); } @@ -161,7 +160,7 @@ public void xfdfWithFieldsWithValueParentAndChild() throws IOException, ParserCo XfdfObject xfdfObject = factory.createXfdfObject(FileUtil.getInputStreamForFile(xfdfFilename)); xfdfObject.mergeToPdf(pdfDocument, sourceFolder + "xfdfWithFieldsWithValueParentAndChild.pdf"); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfWithFieldsWithValueParentAndChild.pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfWithFieldsWithValueParentAndChild.pdf", sourceFolder + "cmp_xfdfWithFieldsWithValueParentAndChild.pdf", destinationFolder, "diff_")); } @@ -174,7 +173,7 @@ public void xfdfAnnotationHighlightedText() throws IOException, ParserConfigurat XfdfObject xfdfObject = factory.createXfdfObject(FileUtil.getInputStreamForFile(xfdfFilename)); xfdfObject.mergeToPdf(pdfDocument, "xfdfAnnotationHighlightedText.pdf"); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfAnnotationHighlightedText.pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfAnnotationHighlightedText.pdf", sourceFolder + "cmp_xfdfAnnotationHighlightedText.pdf", destinationFolder, "diff_")); } @@ -188,7 +187,7 @@ public void xfdfAnnotationUnderlineText() throws IOException, ParserConfiguratio XfdfObject xfdfObject = factory.createXfdfObject(FileUtil.getInputStreamForFile(xfdfFilename)); xfdfObject.mergeToPdf(pdfDocument, sourceFolder + "xfdfAnnotationUnderlineText.pdf"); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfAnnotationUnderlineText.pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfAnnotationUnderlineText.pdf", sourceFolder + "cmp_xfdfAnnotationUnderlineText.pdf", destinationFolder, "diff_")); } @@ -202,7 +201,7 @@ public void xfdfAnnotationUnderlineTextRectWithTwoCoords() throws IOException, P XfdfObject xfdfObject = factory.createXfdfObject(FileUtil.getInputStreamForFile(xfdfFilename)); xfdfObject.mergeToPdf(pdfDocument, sourceFolder + "xfdfAnnotationUnderlineTextRectWithTwoCoords.pdf"); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfAnnotationUnderlineTextRectWithTwoCoords.pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfAnnotationUnderlineTextRectWithTwoCoords.pdf", sourceFolder + "cmp_xfdfAnnotationUnderlineTextRectWithTwoCoords.pdf", destinationFolder, "diff_")); } @@ -216,7 +215,7 @@ public void xfdfAnnotationUnderlinePopupAllFlags() throws IOException, ParserCon XfdfObject xfdfObject = factory.createXfdfObject(FileUtil.getInputStreamForFile(xfdfFilename)); xfdfObject.mergeToPdf(pdfDocument, sourceFolder + "xfdfAnnotationUnderlinePopupAllFlags.pdf"); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfAnnotationUnderlinePopupAllFlags.pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfAnnotationUnderlinePopupAllFlags.pdf", sourceFolder + "cmp_xfdfAnnotationUnderlinePopupAllFlags.pdf", destinationFolder, "diff_")); } @@ -230,7 +229,7 @@ public void xfdfAnnotationText() throws IOException, ParserConfigurationExceptio XfdfObject xfdfObject = factory.createXfdfObject(FileUtil.getInputStreamForFile(xfdfFilename)); xfdfObject.mergeToPdf(pdfDocument, sourceFolder + "xfdfAnnotationText.pdf"); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfAnnotationText.pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfAnnotationText.pdf", sourceFolder + "cmp_xfdfAnnotationText.pdf", destinationFolder, "diff_")); } @@ -244,7 +243,7 @@ public void xfdfAnnotationStrikeout() throws IOException, ParserConfigurationExc XfdfObject xfdfObject = factory.createXfdfObject(FileUtil.getInputStreamForFile(xfdfFilename)); xfdfObject.mergeToPdf(pdfDocument, sourceFolder + "xfdfAnnotationStrikeout.pdf"); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfAnnotationStrikeout.pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfAnnotationStrikeout.pdf", sourceFolder + "cmp_xfdfAnnotationStrikeout.pdf", destinationFolder, "diff_")); } @@ -258,7 +257,7 @@ public void xfdfAnnotationSquigglyText() throws IOException, ParserConfiguration XfdfObject xfdfObject = factory.createXfdfObject(FileUtil.getInputStreamForFile(xfdfFilename)); xfdfObject.mergeToPdf(pdfDocument, sourceFolder + "xfdfAnnotationSquigglyText.pdf"); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfAnnotationSquigglyText.pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfAnnotationSquigglyText.pdf", sourceFolder + "cmp_xfdfAnnotationSquigglyText.pdf", destinationFolder, "diff_")); } @@ -276,7 +275,7 @@ public void xfdfAnnotationLine() throws IOException, ParserConfigurationExceptio XfdfObject xfdfObject = factory.createXfdfObject(FileUtil.getInputStreamForFile(xfdfFilename)); xfdfObject.mergeToPdf(pdfDocument, sourceFolder + "xfdfAnnotationLine.pdf"); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfAnnotationLine.pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfAnnotationLine.pdf", sourceFolder + "cmp_xfdfAnnotationLine.pdf", destinationFolder, "diff_")); } @@ -290,7 +289,7 @@ public void xfdfAnnotationCircle() throws IOException, ParserConfigurationExcept XfdfObject xfdfObject = factory.createXfdfObject(FileUtil.getInputStreamForFile(xfdfFilename)); xfdfObject.mergeToPdf(pdfDocument, sourceFolder + "xfdfAnnotationCircle.pdf"); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfAnnotationCircle.pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfAnnotationCircle.pdf", sourceFolder + "cmp_xfdfAnnotationCircle.pdf", destinationFolder, "diff_")); } @@ -304,7 +303,7 @@ public void xfdfAnnotationSquare() throws IOException, ParserConfigurationExcept XfdfObject xfdfObject = factory.createXfdfObject(FileUtil.getInputStreamForFile(xfdfFilename)); xfdfObject.mergeToPdf(pdfDocument, sourceFolder + "xfdfAnnotationSquare.pdf"); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfAnnotationSquare.pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfAnnotationSquare.pdf", sourceFolder + "cmp_xfdfAnnotationSquare.pdf", destinationFolder, "diff_")); } @@ -318,7 +317,7 @@ public void xfdfAnnotationCaret() throws IOException, ParserConfigurationExcepti XfdfObject xfdfObject = factory.createXfdfObject(FileUtil.getInputStreamForFile(xfdfFilename)); xfdfObject.mergeToPdf(pdfDocument, sourceFolder + "xfdfAnnotationCaret.pdf"); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfAnnotationCaret.pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfAnnotationCaret.pdf", sourceFolder + "cmp_xfdfAnnotationCaret.pdf", destinationFolder, "diff_")); } @@ -332,7 +331,7 @@ public void xfdfAnnotationPolygon() throws IOException, ParserConfigurationExcep XfdfObject xfdfObject = factory.createXfdfObject(FileUtil.getInputStreamForFile(xfdfFilename)); xfdfObject.mergeToPdf(pdfDocument, sourceFolder + "xfdfAnnotationPolygon.pdf"); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfAnnotationPolygon.pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfAnnotationPolygon.pdf", sourceFolder + "cmp_xfdfAnnotationPolygon.pdf", destinationFolder, "diff_")); } @@ -346,7 +345,7 @@ public void xfdfAnnotationPolyline() throws IOException, ParserConfigurationExce XfdfObject xfdfObject = factory.createXfdfObject(FileUtil.getInputStreamForFile(xfdfFilename)); xfdfObject.mergeToPdf(pdfDocument, sourceFolder + "xfdfAnnotationPolyline.pdf"); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfAnnotationPolyline.pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfAnnotationPolyline.pdf", sourceFolder + "cmp_xfdfAnnotationPolyline.pdf", destinationFolder, "diff_")); } @@ -360,7 +359,7 @@ public void xfdfAnnotationStamp() throws IOException, ParserConfigurationExcepti XfdfObject xfdfObject = factory.createXfdfObject(FileUtil.getInputStreamForFile(xfdfFilename)); xfdfObject.mergeToPdf(pdfDocument, sourceFolder + "xfdfAnnotationStamp.pdf"); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfAnnotationStamp.pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfAnnotationStamp.pdf", sourceFolder + "cmp_xfdfAnnotationStamp.pdf", destinationFolder, "diff_")); } @@ -375,7 +374,7 @@ public void xfdfAnnotationInk() throws IOException, ParserConfigurationException XfdfObject xfdfObject = factory.createXfdfObject(FileUtil.getInputStreamForFile(xfdfFilename)); xfdfObject.mergeToPdf(pdfDocument, sourceFolder + "xfdfAnnotationInk.pdf"); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfAnnotationInk.pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfAnnotationInk.pdf", sourceFolder + "cmp_xfdfAnnotationInk.pdf", destinationFolder, "diff_")); } @@ -389,7 +388,7 @@ public void xfdfAnnotationFreeText() throws IOException, ParserConfigurationExce XfdfObject xfdfObject = factory.createXfdfObject(FileUtil.getInputStreamForFile(xfdfFilename)); xfdfObject.mergeToPdf(pdfDocument, sourceFolder + "xfdfAnnotationFreeText.pdf"); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfAnnotationFreeText.pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfAnnotationFreeText.pdf", sourceFolder + "cmp_xfdfAnnotationFreeText.pdf", destinationFolder, "diff_")); } @@ -404,7 +403,7 @@ public void xfdfAnnotationFileAttachment() throws IOException, ParserConfigurati XfdfObject xfdfObject = factory.createXfdfObject(FileUtil.getInputStreamForFile(xfdfFilename)); xfdfObject.mergeToPdf(pdfDocument, sourceFolder + "xfdfAnnotationFileAttachment.pdf"); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfAnnotationFileAttachment.pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfAnnotationFileAttachment.pdf", sourceFolder + "cmp_xfdfAnnotationFileAttachment.pdf", destinationFolder, "diff_")); } @@ -419,7 +418,7 @@ public void xfdfAnnotationSound() throws IOException, ParserConfigurationExcepti XfdfObject xfdfObject = factory.createXfdfObject(FileUtil.getInputStreamForFile(xfdfFilename)); xfdfObject.mergeToPdf(pdfDocument, sourceFolder + "xfdfAnnotationSound.pdf"); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfAnnotationSound.pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfAnnotationSound.pdf", sourceFolder + "cmp_xfdfAnnotationSound.pdf", destinationFolder, "diff_")); } @@ -433,7 +432,7 @@ public void xfdfAnnotationLink() throws IOException, ParserConfigurationExceptio XfdfObject xfdfObject = factory.createXfdfObject(FileUtil.getInputStreamForFile(xfdfFilename)); xfdfObject.mergeToPdf(pdfDocument, sourceFolder + "xfdfAnnotationLink.pdf"); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfAnnotationLink.pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfAnnotationLink.pdf", sourceFolder + "cmp_xfdfAnnotationLink.pdf", destinationFolder, "diff_")); } @@ -448,7 +447,7 @@ public void xfdfAnnotationRedact() throws IOException, ParserConfigurationExcept XfdfObject xfdfObject = factory.createXfdfObject(FileUtil.getInputStreamForFile(xfdfFilename)); xfdfObject.mergeToPdf(pdfDocument, sourceFolder + "xfdfAnnotationRedact.pdf"); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfAnnotationRedact.pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfAnnotationRedact.pdf", sourceFolder + "cmp_xfdfAnnotationRedact.pdf", destinationFolder, "diff_")); } @@ -463,7 +462,7 @@ public void xfdfAnnotationProjection() throws IOException, ParserConfigurationEx XfdfObject xfdfObject = factory.createXfdfObject(FileUtil.getInputStreamForFile(xfdfFilename)); xfdfObject.mergeToPdf(pdfDocument, sourceFolder + "xfdfAnnotationProjection.pdf"); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfAnnotationProjection.pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfAnnotationProjection.pdf", sourceFolder + "cmp_xfdfAnnotationProjection.pdf", destinationFolder, "diff_")); } @@ -477,7 +476,7 @@ public void xfdfAnnotationLinkAllParams() throws IOException, ParserConfiguratio XfdfObject xfdfObject = factory.createXfdfObject(FileUtil.getInputStreamForFile(xfdfFilename)); xfdfObject.mergeToPdf(pdfDocument, sourceFolder + "xfdfAnnotationLinkAllParams.pdf"); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfAnnotationLinkAllParams.pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfAnnotationLinkAllParams.pdf", sourceFolder + "cmp_xfdfAnnotationLinkAllParams.pdf", destinationFolder, "diff_")); } @@ -494,7 +493,7 @@ public void xfdfAnnotationReplaceText() throws IOException, ParserConfigurationE XfdfObject xfdfObject = factory.createXfdfObject(FileUtil.getInputStreamForFile(xfdfFilename)); xfdfObject.mergeToPdf(pdfDocument, sourceFolder + "xfdfAnnotationReplaceText.pdf"); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfAnnotationReplaceText.pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfAnnotationReplaceText.pdf", sourceFolder + "cmp_xfdfAnnotationReplaceText.pdf", destinationFolder, "diff_")); } @@ -512,7 +511,7 @@ public void xfdfAnnotationArrow() throws IOException, ParserConfigurationExcepti XfdfObject xfdfObject = factory.createXfdfObject(FileUtil.getInputStreamForFile(xfdfFilename)); xfdfObject.mergeToPdf(pdfDocument, sourceFolder + "xfdfAnnotationArrow.pdf"); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfAnnotationArrow.pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfAnnotationArrow.pdf", sourceFolder + "cmp_xfdfAnnotationArrow.pdf", destinationFolder, "diff_")); } @@ -527,7 +526,7 @@ public void xfdfAnnotationCallout() throws IOException, ParserConfigurationExcep XfdfObject xfdfObject = factory.createXfdfObject(FileUtil.getInputStreamForFile(xfdfFilename)); xfdfObject.mergeToPdf(pdfDocument, sourceFolder + "xfdfAnnotationCallout.pdf"); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfAnnotationCallout.pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfAnnotationCallout.pdf", sourceFolder + "cmp_xfdfAnnotationCallout.pdf", destinationFolder, "diff_")); } @@ -544,7 +543,7 @@ public void xfdfAnnotationCloud() throws IOException, ParserConfigurationExcepti XfdfObject xfdfObject = factory.createXfdfObject(FileUtil.getInputStreamForFile(xfdfFilename)); xfdfObject.mergeToPdf(pdfDocument, sourceFolder + "xfdfAnnotationCloud.pdf"); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfAnnotationCloud.pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfAnnotationCloud.pdf", sourceFolder + "cmp_xfdfAnnotationCloud.pdf", destinationFolder, "diff_")); } @@ -561,7 +560,7 @@ public void xfdfAnnotationCloudNested() throws IOException, ParserConfigurationE XfdfObject xfdfObject = factory.createXfdfObject(FileUtil.getInputStreamForFile(xfdfFilename)); xfdfObject.mergeToPdf(pdfDocument, sourceFolder + "xfdfAnnotationCloudNested.pdf"); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfAnnotationCloudNested.pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfAnnotationCloudNested.pdf", sourceFolder + "cmp_xfdfAnnotationCloudNested.pdf", destinationFolder, "diff_")); } @@ -576,7 +575,7 @@ public void xfdfAnnotationTextBoxAllParams() throws IOException, ParserConfigura XfdfObject xfdfObject = factory.createXfdfObject(FileUtil.getInputStreamForFile(xfdfFilename)); xfdfObject.mergeToPdf(pdfDocument, sourceFolder + "xfdfAnnotationTextBoxAllParams.pdf"); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfAnnotationTextBoxAllParams.pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfAnnotationTextBoxAllParams.pdf", sourceFolder + "cmp_xfdfAnnotationTextBoxAllParams.pdf", destinationFolder, "diff_")); } @@ -591,7 +590,7 @@ public void xfdfJavaScriptForms() throws IOException, ParserConfigurationExcepti XfdfObject xfdfObject = factory.createXfdfObject(FileUtil.getInputStreamForFile(xfdfFilename)); xfdfObject.mergeToPdf(pdfDocument, sourceFolder + "xfdfJavaScriptForms.pdf"); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfJavaScriptForms.pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfJavaScriptForms.pdf", sourceFolder + "cmp_xfdfJavaScriptForms.pdf", destinationFolder, "diff_")); } @@ -605,7 +604,7 @@ public void xfdfFormsFieldParams() throws IOException, ParserConfigurationExcept XfdfObject xfdfObject = factory.createXfdfObject(FileUtil.getInputStreamForFile(xfdfFilename)); xfdfObject.mergeToPdf(pdfDocument, sourceFolder + "xfdfFormsFieldParams.pdf"); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfFormsFieldParams.pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfFormsFieldParams.pdf", sourceFolder + "cmp_xfdfFormsFieldParams.pdf", destinationFolder, "diff_")); } @@ -620,7 +619,7 @@ public void xfdfAnnotationAttrColor() throws IOException, ParserConfigurationExc XfdfObject xfdfObject = factory.createXfdfObject(FileUtil.getInputStreamForFile(xfdfFilename)); xfdfObject.mergeToPdf(pdfDocument, sourceFolder + "xfdfAnnotationAttrColor.pdf"); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfAnnotationAttrColor.pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfAnnotationAttrColor.pdf", sourceFolder + "cmp_xfdfAnnotationAttrColor.pdf", destinationFolder, "diff_")); } @@ -634,7 +633,7 @@ public void xfdfAnnotationAttrFlagsOpacity() throws IOException, ParserConfigura XfdfObject xfdfObject = factory.createXfdfObject(FileUtil.getInputStreamForFile(xfdfFilename)); xfdfObject.mergeToPdf(pdfDocument, sourceFolder + "xfdfAnnotationAttrFlagsOpacity.pdf"); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfAnnotationAttrFlagsOpacity.pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfAnnotationAttrFlagsOpacity.pdf", sourceFolder + "cmp_xfdfAnnotationAttrFlagsOpacity.pdf", destinationFolder, "diff_")); } @@ -651,7 +650,7 @@ public void xfdfAnnotationAttrTitle() throws IOException, ParserConfigurationExc XfdfObject xfdfObject = factory.createXfdfObject(FileUtil.getInputStreamForFile(xfdfFilename)); xfdfObject.mergeToPdf(pdfDocument, sourceFolder + "xfdfAnnotationAttrTitle.pdf"); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfAnnotationAttrTitle.pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfAnnotationAttrTitle.pdf", sourceFolder + "cmp_xfdfAnnotationAttrTitle.pdf", destinationFolder, "diff_")); } @@ -666,7 +665,7 @@ public void xfdfReferenceFor3DMeasurement() throws IOException, ParserConfigurat XfdfObject xfdfObject = factory.createXfdfObject(FileUtil.getInputStreamForFile(xfdfFilename)); xfdfObject.mergeToPdf(pdfDocument, sourceFolder + "xfdfReferenceFor3DMeasurement.pdf"); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfReferenceFor3DMeasurement.pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfReferenceFor3DMeasurement.pdf", sourceFolder + "cmp_xfdfReferenceFor3DMeasurement.pdf", destinationFolder, "diff_")); } @@ -681,7 +680,7 @@ public void xfdfReferenceFor3DAngular() throws IOException, ParserConfigurationE XfdfObject xfdfObject = factory.createXfdfObject(FileUtil.getInputStreamForFile(xfdfFilename)); xfdfObject.mergeToPdf(pdfDocument, sourceFolder + "xfdfReferenceFor3DAngular.pdf"); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfReferenceFor3DAngular.pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfReferenceFor3DAngular.pdf", sourceFolder + "cmp_xfdfReferenceFor3DAngular.pdf", destinationFolder, "diff_")); } @@ -696,7 +695,7 @@ public void xfdfReferenceFor3DRadial() throws IOException, ParserConfigurationEx XfdfObject xfdfObject = factory.createXfdfObject(FileUtil.getInputStreamForFile(xfdfFilename)); xfdfObject.mergeToPdf(pdfDocument, sourceFolder + "xfdfReferenceFor3DRadial.pdf"); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfReferenceFor3DRadial.pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfReferenceFor3DRadial.pdf", sourceFolder + "cmp_xfdfReferenceFor3DRadial.pdf", destinationFolder, "diff_")); } @@ -711,7 +710,7 @@ public void xfdfSubelementContents() throws IOException, ParserConfigurationExce XfdfObject xfdfObject = factory.createXfdfObject(FileUtil.getInputStreamForFile(xfdfFilename)); xfdfObject.mergeToPdf(pdfDocument, sourceFolder + "xfdfSubelementContents.pdf"); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfSubelementContents.pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfSubelementContents.pdf", sourceFolder + "cmp_xfdfSubelementContents.pdf", destinationFolder, "diff_")); } @@ -726,7 +725,7 @@ public void xfdfSubelementOverlayAppearance() throws IOException, ParserConfigur XfdfObject xfdfObject = factory.createXfdfObject(FileUtil.getInputStreamForFile(xfdfFilename)); xfdfObject.mergeToPdf(pdfDocument, sourceFolder + "xfdfSubelementOverlayAppearance.pdf"); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfSubelementOverlayAppearance.pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfSubelementOverlayAppearance.pdf", sourceFolder + "cmp_xfdfSubelementOverlayAppearance.pdf", destinationFolder, "diff_")); } @@ -741,7 +740,7 @@ public void xfdfButton() throws IOException, ParserConfigurationException, SAXEx XfdfObject xfdfObject = factory.createXfdfObject(FileUtil.getInputStreamForFile(xfdfFilename)); xfdfObject.mergeToPdf(pdfDocument, sourceFolder + "xfdfButton.pdf"); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfButton.pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfButton.pdf", sourceFolder + "cmp_xfdfButton.pdf", destinationFolder, "diff_")); } @@ -756,7 +755,7 @@ public void xfdfCheckBox() throws IOException, ParserConfigurationException, SAX XfdfObject xfdfObject = factory.createXfdfObject(FileUtil.getInputStreamForFile(xfdfFilename)); xfdfObject.mergeToPdf(pdfDocument, sourceFolder + "xfdfCheckBox.pdf"); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfCheckBox.pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfCheckBox.pdf", sourceFolder + "cmp_xfdfCheckBox.pdf", destinationFolder, "diff_")); } @@ -771,7 +770,7 @@ public void xfdfList() throws IOException, ParserConfigurationException, SAXExce XfdfObject xfdfObject = factory.createXfdfObject(FileUtil.getInputStreamForFile(xfdfFilename)); xfdfObject.mergeToPdf(pdfDocument, sourceFolder + "xfdfList.pdf"); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfList.pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfList.pdf", sourceFolder + "cmp_xfdfList.pdf", destinationFolder, "diff_")); } @@ -786,7 +785,7 @@ public void xfdfDropDown() throws IOException, ParserConfigurationException, SAX XfdfObject xfdfObject = factory.createXfdfObject(FileUtil.getInputStreamForFile(xfdfFilename)); xfdfObject.mergeToPdf(pdfDocument, sourceFolder + "xfdfDropDown.pdf"); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfDropDown.pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfDropDown.pdf", sourceFolder + "cmp_xfdfDropDown.pdf", destinationFolder, "diff_")); } @@ -802,7 +801,7 @@ public void xfdfBorderStyleAttributesTest() throws IOException, ParserConfigurat XfdfObject xfdfObject = factory.createXfdfObject(FileUtil.getInputStreamForFile(xfdfFilename)); xfdfObject.mergeToPdf(document, sourceFolder + "xfdfAnnotationsTemplate.pdf"); } - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfBorderStyleAttributes.pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfBorderStyleAttributes.pdf", sourceFolder + "cmp_xfdfBorderStyleAttributes.pdf", destinationFolder, "diff_")); } @@ -819,7 +818,7 @@ public void xfdfAnnotationAttributesTest() throws IOException, ParserConfigurati XfdfObject xfdfObject = factory.createXfdfObject(FileUtil.getInputStreamForFile(xfdfFilename)); xfdfObject.mergeToPdf(document, sourceFolder + "xfdfAnnotationsTemplate.pdf"); } - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfAnnotationAttributes.pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "xfdfAnnotationAttributes.pdf", sourceFolder + "cmp_xfdfAnnotationAttributes.pdf", destinationFolder, "diff_")); } @@ -837,7 +836,7 @@ public void xfdfOnlyRequiredAnnotationAttributesTest() throws IOException, Parse XfdfObject xfdfObject = factory.createXfdfObject(FileUtil.getInputStreamForFile(xfdfFilename)); xfdfObject.mergeToPdf(document, sourceFolder + "xfdfAnnotationsTemplate.pdf"); } - Assert.assertNull(new CompareTool().compareByContent( + Assertions.assertNull(new CompareTool().compareByContent( destinationFolder + "xfdfOnlyRequiredAnnotationAttributes.pdf", sourceFolder + "cmp_xfdfOnlyRequiredAnnotationAttributes.pdf", destinationFolder, "diff_")); } @@ -855,7 +854,7 @@ public void xfdfInReplyToTest() throws IOException, ParserConfigurationException XfdfObject xfdfObject = factory.createXfdfObject(FileUtil.getInputStreamForFile(xfdfFilename)); xfdfObject.mergeToPdf(document, sourceFolder + "xfdfAnnotationHighlightedText.pdf"); } - Assert.assertNull(new CompareTool().compareByContent( + Assertions.assertNull(new CompareTool().compareByContent( destinationFolder + "xfdfInReplyTo.pdf", sourceFolder + "cmp_xfdfInReplyTo.pdf", destinationFolder, "diff_")); } diff --git a/forms/src/test/java/com/itextpdf/forms/XfdfUnitTest.java b/forms/src/test/java/com/itextpdf/forms/XfdfUnitTest.java index a65a0b3817..6b29c22aeb 100644 --- a/forms/src/test/java/com/itextpdf/forms/XfdfUnitTest.java +++ b/forms/src/test/java/com/itextpdf/forms/XfdfUnitTest.java @@ -25,20 +25,19 @@ This file is part of the iText (R) project. import com.itextpdf.forms.xfdf.FitObject; import com.itextpdf.forms.exceptions.XfdfException; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class XfdfUnitTest extends ExtendedITextTest { @Test public void fitObjectWithEmptyPageTest(){ - Exception e = Assert.assertThrows(XfdfException.class, + Exception e = Assertions.assertThrows(XfdfException.class, () -> new FitObject(null) ); - Assert.assertEquals(XfdfException.PAGE_IS_MISSING, e.getMessage()); + Assertions.assertEquals(XfdfException.PAGE_IS_MISSING, e.getMessage()); } } diff --git a/forms/src/test/java/com/itextpdf/forms/XfdfWriterTest.java b/forms/src/test/java/com/itextpdf/forms/XfdfWriterTest.java index d3733c8673..0d1e4e9e35 100644 --- a/forms/src/test/java/com/itextpdf/forms/XfdfWriterTest.java +++ b/forms/src/test/java/com/itextpdf/forms/XfdfWriterTest.java @@ -33,25 +33,24 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfReader; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.FileInputStream; import java.io.IOException; import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.TransformerException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import org.xml.sax.SAXException; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class XfdfWriterTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/forms/XfdfWriterTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/forms/XfdfWriterTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } @@ -71,7 +70,7 @@ public void simpleFormWithOneFieldTest() if (!new CompareTool().compareXmls(destinationFolder + "simpleFormWithOneField.xfdf", sourceFolder + "cmp_simpleFormWithOneField.xfdf")) - Assert.fail("Xfdf files are not equal"); + Assertions.fail("Xfdf files are not equal"); } @Test @@ -89,7 +88,7 @@ public void simpleFormWithMultipleFieldsTest() if (!new CompareTool().compareXmls(destinationFolder + "simpleFormWithMultipleFields.xfdf", sourceFolder + "cmp_simpleFormWithMultipleFields.xfdf")) - Assert.fail("Xfdf files are not equal"); + Assertions.fail("Xfdf files are not equal"); } @@ -109,7 +108,7 @@ public void xfdfValueRichText() if (!new CompareTool().compareXmls(destinationFolder + "xfdfValueRichText.xfdf", sourceFolder + "cmp_xfdfValueRichText.xfdf")) - Assert.fail("Xfdf files are not equal"); + Assertions.fail("Xfdf files are not equal"); } @@ -128,7 +127,7 @@ public void xfdfHierarchyFields() if (!new CompareTool().compareXmls(destinationFolder + "xfdfHierarchyFields.xfdf", sourceFolder + "cmp_xfdfHierarchyFields.xfdf")) - Assert.fail("Xfdf files are not equal"); + Assertions.fail("Xfdf files are not equal"); } @Test @@ -145,7 +144,7 @@ public void xfdfFreeText() throws IOException, ParserConfigurationException, SAX if (!new CompareTool().compareXmls(destinationFolder + "xfdfFreeText.xfdf", sourceFolder + "cmp_xfdfFreeText.xfdf")) - Assert.fail("Xfdf files are not equal"); + Assertions.fail("Xfdf files are not equal"); } @Test @@ -163,7 +162,7 @@ public void xfdfHighlightedText() if (!new CompareTool().compareXmls(destinationFolder + "xfdfHighlightedText.xfdf", sourceFolder + "cmp_xfdfHighlightedText.xfdf")) - Assert.fail("Xfdf files are not equal"); + Assertions.fail("Xfdf files are not equal"); } @Test @@ -181,7 +180,7 @@ public void xfdfUnderlineText() if (!new CompareTool().compareXmls(destinationFolder + "xfdfUnderlineText.xfdf", sourceFolder + "cmp_xfdfUnderlineText.xfdf")) - Assert.fail("Xfdf files are not equal"); + Assertions.fail("Xfdf files are not equal"); } @Test @@ -199,7 +198,7 @@ public void xfdfPopupNewFlags() if (!new CompareTool().compareXmls(destinationFolder + "xfdfPopupNewFlags.xfdf", sourceFolder + "cmp_xfdfPopupNewFlags.xfdf")) - Assert.fail("Xfdf files are not equal"); + Assertions.fail("Xfdf files are not equal"); } @Test @@ -216,7 +215,7 @@ public void xfdfStrikeout() throws IOException, ParserConfigurationException, SA if (!new CompareTool().compareXmls(destinationFolder + "xfdfStrikeout.xfdf", sourceFolder + "cmp_xfdfStrikeout.xfdf")) - Assert.fail("Xfdf files are not equal"); + Assertions.fail("Xfdf files are not equal"); } @Test @@ -234,7 +233,7 @@ public void xfdfSquigglyText() if (!new CompareTool().compareXmls(destinationFolder + "xfdfSquigglyText.xfdf", sourceFolder + "cmp_xfdfSquigglyText.xfdf")) - Assert.fail("Xfdf files are not equal"); + Assertions.fail("Xfdf files are not equal"); } @Test @@ -250,7 +249,7 @@ public void xfdfLine() throws IOException, ParserConfigurationException, SAXExce if (!new CompareTool().compareXmls(destinationFolder + "xfdfLine.xfdf", sourceFolder + "cmp_xfdfLine.xfdf")) - Assert.fail("Xfdf files are not equal"); + Assertions.fail("Xfdf files are not equal"); } @Test @@ -266,7 +265,7 @@ public void xfdfCircle() throws IOException, ParserConfigurationException, SAXEx if (!new CompareTool().compareXmls(destinationFolder + "xfdfCircle.xfdf", sourceFolder + "cmp_xfdfCircle.xfdf")) - Assert.fail("Xfdf files are not equal"); + Assertions.fail("Xfdf files are not equal"); } @Test @@ -282,7 +281,7 @@ public void xfdfSquare() throws IOException, ParserConfigurationException, SAXEx if (!new CompareTool().compareXmls(destinationFolder + "xfdfSquare.xfdf", sourceFolder + "cmp_xfdfSquare.xfdf")) - Assert.fail("Xfdf files are not equal"); + Assertions.fail("Xfdf files are not equal"); } @Test @@ -300,7 +299,7 @@ public void xfdfSquareAndCircleInteriorColor() if (!new CompareTool().compareXmls(destinationFolder + "xfdfSquareAndCircleInteriorColor.xfdf", sourceFolder + "cmp_xfdfSquareAndCircleInteriorColor.xfdf")) - Assert.fail("Xfdf files are not equal"); + Assertions.fail("Xfdf files are not equal"); } @Test @@ -317,7 +316,7 @@ public void xfdfCaret() throws IOException, ParserConfigurationException, SAXExc if (!new CompareTool().compareXmls(destinationFolder + "xfdfCaret.xfdf", sourceFolder + "cmp_xfdfCaret.xfdf")) - Assert.fail("Xfdf files are not equal"); + Assertions.fail("Xfdf files are not equal"); } @Test @@ -334,7 +333,7 @@ public void xfdfPolygon() throws IOException, ParserConfigurationException, SAXE if (!new CompareTool().compareXmls(destinationFolder + "xfdfPolygon.xfdf", sourceFolder + "cmp_xfdfPolygon.xfdf")) - Assert.fail("Xfdf files are not equal"); + Assertions.fail("Xfdf files are not equal"); } @Test @@ -352,7 +351,7 @@ public void xfdfPolyline() throws IOException, ParserConfigurationException, SAX if (!new CompareTool().compareXmls(destinationFolder + "xfdfPolyline.xfdf", sourceFolder + "cmp_xfdfPolyline.xfdf")) - Assert.fail("Xfdf files are not equal"); + Assertions.fail("Xfdf files are not equal"); } @Test @@ -368,7 +367,7 @@ public void xfdfStamp() throws IOException, ParserConfigurationException, SAXExc if (!new CompareTool().compareXmls(destinationFolder + "xfdfStamp.xfdf", sourceFolder + "cmp_xfdfStamp.xfdf")) - Assert.fail("Xfdf files are not equal"); + Assertions.fail("Xfdf files are not equal"); } @Test @@ -386,7 +385,7 @@ public void xfdfStampWithAppearance() if (!new CompareTool().compareXmls(destinationFolder + "xfdfStampWithAppearance.xfdf", sourceFolder + "cmp_xfdfStampWithAppearance.xfdf")) - Assert.fail("Xfdf files are not equal"); + Assertions.fail("Xfdf files are not equal"); } @Test @@ -403,7 +402,7 @@ public void xfdfInk() throws IOException, ParserConfigurationException, SAXExcep if (!new CompareTool().compareXmls(destinationFolder + "xfdfInk.xfdf", sourceFolder + "cmp_xfdfInk.xfdf")) - Assert.fail("Xfdf files are not equal"); + Assertions.fail("Xfdf files are not equal"); } @Test @@ -422,7 +421,7 @@ public void xfdfFileAttachment() if (!new CompareTool().compareXmls(destinationFolder + "xfdfFileAttachment.xfdf", sourceFolder + "cmp_xfdfFileAttachment.xfdf")) - Assert.fail("Xfdf files are not equal"); + Assertions.fail("Xfdf files are not equal"); } @Test @@ -439,7 +438,7 @@ public void xfdfSound() throws IOException, ParserConfigurationException, SAXExc if (!new CompareTool().compareXmls(destinationFolder + "xfdfSound.xfdf", sourceFolder + "cmp_xfdfSound.xfdf")) - Assert.fail("Xfdf files are not equal"); + Assertions.fail("Xfdf files are not equal"); } @Test @@ -455,7 +454,7 @@ public void xfdfLink() throws IOException, ParserConfigurationException, SAXExce if (!new CompareTool().compareXmls(destinationFolder + "xfdfLink.xfdf", sourceFolder + "cmp_xfdfLink.xfdf")) - Assert.fail("Xfdf files are not equal"); + Assertions.fail("Xfdf files are not equal"); } @Test @@ -473,7 +472,7 @@ public void xfdfLinkBorderStyle() if (!new CompareTool().compareXmls(destinationFolder + "xfdfLinkBorderStyle.xfdf", sourceFolder + "cmp_xfdfLinkBorderStyle.xfdf")) - Assert.fail("Xfdf files are not equal"); + Assertions.fail("Xfdf files are not equal"); } @Test @@ -490,7 +489,7 @@ public void xfdfLinkDest() throws IOException, ParserConfigurationException, SAX if (!new CompareTool().compareXmls(destinationFolder + "xfdfLinkDest.xfdf", sourceFolder + "cmp_xfdfLinkDest.xfdf")) - Assert.fail("Xfdf files are not equal"); + Assertions.fail("Xfdf files are not equal"); } @Test @@ -507,7 +506,7 @@ public void xfdfLinkDestFit() throws IOException, ParserConfigurationException, if (!new CompareTool().compareXmls(destinationFolder + "xfdfLinkDestFit.xfdf", sourceFolder + "cmp_xfdfLinkDestFit.xfdf")) - Assert.fail("Xfdf files are not equal"); + Assertions.fail("Xfdf files are not equal"); } @Test @@ -525,7 +524,7 @@ public void xfdfLinkDestFitB() if (!new CompareTool().compareXmls(destinationFolder + "xfdfLinkDestFitB.xfdf", sourceFolder + "cmp_xfdfLinkDestFitB.xfdf")) - Assert.fail("Xfdf files are not equal"); + Assertions.fail("Xfdf files are not equal"); } @Test @@ -543,7 +542,7 @@ public void xfdfLinkDestFitR() if (!new CompareTool().compareXmls(destinationFolder + "xfdfLinkDestFitR.xfdf", sourceFolder + "cmp_xfdfLinkDestFitR.xfdf")) - Assert.fail("Xfdf files are not equal"); + Assertions.fail("Xfdf files are not equal"); } @Test @@ -561,7 +560,7 @@ public void xfdfLinkDestFitH() if (!new CompareTool().compareXmls(destinationFolder + "xfdfLinkDestFitH.xfdf", sourceFolder + "cmp_xfdfLinkDestFitH.xfdf")) - Assert.fail("Xfdf files are not equal"); + Assertions.fail("Xfdf files are not equal"); } @Test @@ -579,7 +578,7 @@ public void xfdfLinkDestFitBH() if (!new CompareTool().compareXmls(destinationFolder + "xfdfLinkDestFitBH.xfdf", sourceFolder + "cmp_xfdfLinkDestFitBH.xfdf")) - Assert.fail("Xfdf files are not equal"); + Assertions.fail("Xfdf files are not equal"); } @Test @@ -597,7 +596,7 @@ public void xfdfLinkDestFitBV() if (!new CompareTool().compareXmls(destinationFolder + "xfdfLinkDestFitBV.xfdf", sourceFolder + "cmp_xfdfLinkDestFitBV.xfdf")) - Assert.fail("Xfdf files are not equal"); + Assertions.fail("Xfdf files are not equal"); } @Test @@ -615,7 +614,7 @@ public void xfdfLinkDestFitV() if (!new CompareTool().compareXmls(destinationFolder + "xfdfLinkDestFitV.xfdf", sourceFolder + "cmp_xfdfLinkDestFitV.xfdf")) - Assert.fail("Xfdf files are not equal"); + Assertions.fail("Xfdf files are not equal"); } @Test @@ -632,7 +631,7 @@ public void xfdfRedact() throws IOException, ParserConfigurationException, SAXEx if (!new CompareTool().compareXmls(destinationFolder + "xfdfRedact.xfdf", sourceFolder + "cmp_xfdfRedact.xfdf")) - Assert.fail("Xfdf files are not equal"); + Assertions.fail("Xfdf files are not equal"); } @Test @@ -650,7 +649,7 @@ public void xfdfProjection() throws IOException, ParserConfigurationException, S if (!new CompareTool().compareXmls(destinationFolder + "xfdfProjection.xfdf", sourceFolder + "cmp_xfdfProjection.xfdf")) - Assert.fail("Xfdf files are not equal"); + Assertions.fail("Xfdf files are not equal"); } @Test @@ -668,7 +667,7 @@ public void xfdfLinkAllParams() if (!new CompareTool().compareXmls(destinationFolder + "xfdfLinkAllParams.xfdf", sourceFolder + "cmp_xfdfLinkAllParams.xfdf")) - Assert.fail("Xfdf files are not equal"); + Assertions.fail("Xfdf files are not equal"); } @Test @@ -686,7 +685,7 @@ public void xfdfReplaceText() throws IOException, ParserConfigurationException, if (!new CompareTool().compareXmls(destinationFolder + "xfdfReplaceText.xfdf", sourceFolder + "cmp_xfdfReplaceText.xfdf")) - Assert.fail("Xfdf files are not equal"); + Assertions.fail("Xfdf files are not equal"); } @Test @@ -703,7 +702,7 @@ public void xfdfArrow() throws IOException, ParserConfigurationException, SAXExc if (!new CompareTool().compareXmls(destinationFolder + "xfdfArrow.xfdf", sourceFolder + "cmp_xfdfArrow.xfdf")) - Assert.fail("Xfdf files are not equal"); + Assertions.fail("Xfdf files are not equal"); } @Test @@ -720,7 +719,7 @@ public void xfdfCallout() throws IOException, ParserConfigurationException, SAXE if (!new CompareTool().compareXmls(destinationFolder + "xfdfCallout.xfdf", sourceFolder + "cmp_xfdfCallout.xfdf")) - Assert.fail("Xfdf files are not equal"); + Assertions.fail("Xfdf files are not equal"); } @Test @@ -737,7 +736,7 @@ public void xfdfCloud() throws IOException, ParserConfigurationException, SAXExc if (!new CompareTool().compareXmls(destinationFolder + "xfdfCloud.xfdf", sourceFolder + "cmp_xfdfCloud.xfdf")) - Assert.fail("Xfdf files are not equal"); + Assertions.fail("Xfdf files are not equal"); } @Test @@ -755,7 +754,7 @@ public void xfdfCloudNested() throws IOException, ParserConfigurationException, if (!new CompareTool().compareXmls(destinationFolder + "xfdfCloudNested.xfdf", sourceFolder + "cmp_xfdfCloudNested.xfdf")) - Assert.fail("Xfdf files are not equal"); + Assertions.fail("Xfdf files are not equal"); } @Test @@ -774,7 +773,7 @@ public void xfdfTextBoxAllParams() if (!new CompareTool().compareXmls(destinationFolder + "xfdfTextBoxAllParams.xfdf", sourceFolder + "cmp_xfdfTextBoxAllParams.xfdf")) - Assert.fail("Xfdf files are not equal"); + Assertions.fail("Xfdf files are not equal"); } @Test @@ -793,7 +792,7 @@ public void xfdfJavaScriptForms() if (!new CompareTool().compareXmls(destinationFolder + "xfdfJavaScriptForms.xfdf", sourceFolder + "cmp_xfdfJavaScriptForms.xfdf")) - Assert.fail("Xfdf files are not equal"); + Assertions.fail("Xfdf files are not equal"); } @Test @@ -811,7 +810,7 @@ public void xfdfAttrColor() throws IOException, ParserConfigurationException, SA if (!new CompareTool().compareXmls(destinationFolder + "xfdfAttrColor.xfdf", sourceFolder + "cmp_xfdfAttrColor.xfdf")) - Assert.fail("Xfdf files are not equal"); + Assertions.fail("Xfdf files are not equal"); } @Test @@ -830,7 +829,7 @@ public void xfdfAttrFlagsOpacity() if (!new CompareTool().compareXmls(destinationFolder + "xfdfAttrFlagsOpacity.xfdf", sourceFolder + "cmp_xfdfAttrFlagsOpacity.xfdf")) - Assert.fail("Xfdf files are not equal"); + Assertions.fail("Xfdf files are not equal"); } @Test @@ -848,7 +847,7 @@ public void xfdfAttrTitle() throws IOException, ParserConfigurationException, SA if (!new CompareTool().compareXmls(destinationFolder + "xfdfAttrTitle.xfdf", sourceFolder + "cmp_xfdfAttrTitle.xfdf")) - Assert.fail("Xfdf files are not equal"); + Assertions.fail("Xfdf files are not equal"); } @Test @@ -865,7 +864,7 @@ public void xfdfReferenceFor3DMeasurement() if (!new CompareTool().compareXmls(destinationFolder + "xfdfReferenceFor3DMeasurement.xfdf", sourceFolder + "cmp_xfdfReferenceFor3DMeasurement.xfdf")) - Assert.fail("Xfdf files are not equal"); + Assertions.fail("Xfdf files are not equal"); } @Test @@ -884,7 +883,7 @@ public void xfdfReferenceFor3DAngular() if (!new CompareTool().compareXmls(destinationFolder + "xfdfReferenceFor3DAngular.xfdf", sourceFolder + "cmp_xfdfReferenceFor3DAngular.xfdf")) - Assert.fail("Xfdf files are not equal"); + Assertions.fail("Xfdf files are not equal"); } @Test @@ -903,7 +902,7 @@ public void xfdfReferenceFor3DRadial() if (!new CompareTool().compareXmls(destinationFolder + "xfdfReferenceFor3DRadial.xfdf", sourceFolder + "cmp_xfdfReferenceFor3DRadial.xfdf")) - Assert.fail("Xfdf files are not equal"); + Assertions.fail("Xfdf files are not equal"); } @Test @@ -922,7 +921,7 @@ public void xfdfSubelementContents() if (!new CompareTool().compareXmls(destinationFolder + "xfdfSubelementContents.xfdf", sourceFolder + "cmp_xfdfSubelementContents.xfdf")) - Assert.fail("Xfdf files are not equal"); + Assertions.fail("Xfdf files are not equal"); } @Test @@ -942,7 +941,7 @@ public void xfdfSubelementOverlayAppearance() if (!new CompareTool().compareXmls(destinationFolder + "xfdfSubelementOverlayAppearance.xfdf", sourceFolder + "cmp_xfdfSubelementOverlayAppearance.xfdf")) - Assert.fail("Xfdf files are not equal"); + Assertions.fail("Xfdf files are not equal"); } @Test @@ -961,7 +960,7 @@ public void xfdfButton() throws IOException, ParserConfigurationException, SAXEx if (!new CompareTool().compareXmls(destinationFolder + "xfdfButton.xfdf", sourceFolder + "cmp_xfdfButton.xfdf")) - Assert.fail("Xfdf files are not equal"); + Assertions.fail("Xfdf files are not equal"); } @Test @@ -980,7 +979,7 @@ public void xfdfCheckBox() throws IOException, ParserConfigurationException, SAX if (!new CompareTool().compareXmls(destinationFolder + "xfdfCheckBox.xfdf", sourceFolder + "cmp_xfdfCheckBox.xfdf")) - Assert.fail("Xfdf files are not equal"); + Assertions.fail("Xfdf files are not equal"); } @Test @@ -996,7 +995,7 @@ public void xfdfList() throws IOException, ParserConfigurationException, SAXExce if (!new CompareTool().compareXmls(destinationFolder + "xfdfList.xfdf", sourceFolder + "cmp_xfdfList.xfdf")) - Assert.fail("Xfdf files are not equal"); + Assertions.fail("Xfdf files are not equal"); } @Test @@ -1015,7 +1014,7 @@ public void xfdfDropDown() throws IOException, ParserConfigurationException, SAX if (!new CompareTool().compareXmls(destinationFolder + "xfdfDropDown.xfdf", sourceFolder + "cmp_xfdfDropDown.xfdf")) - Assert.fail("Xfdf files are not equal"); + Assertions.fail("Xfdf files are not equal"); } @Test @@ -1033,14 +1032,14 @@ public void xfdfEmptyAttributeTest() { String valuePresent = "value"; String valueAbsent = null; - Exception e = Assert.assertThrows(XfdfException.class, + Exception e = Assertions.assertThrows(XfdfException.class, () -> annot.addAttribute(new AttributeObject(nameAbsent, valuePresent)) ); - Assert.assertEquals(XfdfException.ATTRIBUTE_NAME_OR_VALUE_MISSING, e.getMessage()); - Exception e2 = Assert.assertThrows(XfdfException.class, + Assertions.assertEquals(XfdfException.ATTRIBUTE_NAME_OR_VALUE_MISSING, e.getMessage()); + Exception e2 = Assertions.assertThrows(XfdfException.class, () -> annot.addAttribute(new AttributeObject(namePresent, valueAbsent)) ); - Assert.assertEquals(XfdfException.ATTRIBUTE_NAME_OR_VALUE_MISSING, e2.getMessage()); + Assertions.assertEquals(XfdfException.ATTRIBUTE_NAME_OR_VALUE_MISSING, e2.getMessage()); } @Test @@ -1057,7 +1056,7 @@ public void xfdfAnnotationAttributesTest() throws IOException, ParserConfigurati } if (!new CompareTool().compareXmls(destinationFolder + "xfdfAnnotationAttributes.xfdf", sourceFolder + "xfdfAnnotationAttributes.xfdf")) - Assert.fail("Xfdf files are not equal"); + Assertions.fail("Xfdf files are not equal"); } @Test @@ -1074,6 +1073,6 @@ public void xfdfOnlyRequiredAnnotationAttributesTest() throws IOException, Parse } if (!new CompareTool().compareXmls(destinationFolder + "xfdfOnlyRequiredAnnotationAttributes.xfdf", sourceFolder + "xfdfOnlyRequiredAnnotationAttributes.xfdf")) - Assert.fail("Xfdf files are not equal"); + Assertions.fail("Xfdf files are not equal"); } } diff --git a/forms/src/test/java/com/itextpdf/forms/fields/CheckBoxFormFieldBuilderTest.java b/forms/src/test/java/com/itextpdf/forms/fields/CheckBoxFormFieldBuilderTest.java index f61d5ba2a1..fae9c2fdce 100644 --- a/forms/src/test/java/com/itextpdf/forms/fields/CheckBoxFormFieldBuilderTest.java +++ b/forms/src/test/java/com/itextpdf/forms/fields/CheckBoxFormFieldBuilderTest.java @@ -24,8 +24,8 @@ This file is part of the iText (R) project. import com.itextpdf.forms.fields.properties.CheckBoxType; import com.itextpdf.kernel.geom.Rectangle; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; import com.itextpdf.kernel.pdf.PdfArray; +import com.itextpdf.kernel.pdf.PdfConformance; import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfName; @@ -35,15 +35,14 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.annot.PdfWidgetAnnotation; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; import java.io.ByteArrayOutputStream; import java.util.List; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(UnitTest.class) +@Tag("UnitTest") public class CheckBoxFormFieldBuilderTest extends ExtendedITextTest { private static final PdfDocument DUMMY_DOCUMENT = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); private static final String DUMMY_NAME = "dummy name"; @@ -53,8 +52,8 @@ public class CheckBoxFormFieldBuilderTest extends ExtendedITextTest { public void constructorTest() { CheckBoxFormFieldBuilder builder = new CheckBoxFormFieldBuilder(DUMMY_DOCUMENT, DUMMY_NAME); - Assert.assertSame(DUMMY_DOCUMENT, builder.getDocument()); - Assert.assertSame(DUMMY_NAME, builder.getFormFieldName()); + Assertions.assertSame(DUMMY_DOCUMENT, builder.getDocument()); + Assertions.assertSame(DUMMY_NAME, builder.getFormFieldName()); } @Test @@ -62,7 +61,7 @@ public void setGetCheckType() { CheckBoxFormFieldBuilder builder = new CheckBoxFormFieldBuilder(DUMMY_DOCUMENT, DUMMY_NAME); builder.setCheckType(CheckBoxType.DIAMOND); - Assert.assertEquals(CheckBoxType.DIAMOND, builder.getCheckType()); + Assertions.assertEquals(CheckBoxType.DIAMOND, builder.getCheckType()); } @Test @@ -84,7 +83,7 @@ public void createCheckBoxWithoutWidgetTest() { @Test public void createCheckBoxWithConformanceLevelTest() { PdfButtonFormField checkBoxFormField = new CheckBoxFormFieldBuilder(DUMMY_DOCUMENT, DUMMY_NAME) - .setWidgetRectangle(DUMMY_RECTANGLE).setGenericConformanceLevel(PdfAConformanceLevel.PDF_A_1A) + .setWidgetRectangle(DUMMY_RECTANGLE).setConformance(PdfConformance.PDF_A_1A) .createCheckBox(); compareCheckBoxes(checkBoxFormField, true); @@ -96,17 +95,17 @@ private static void compareCheckBoxes(PdfButtonFormField checkBoxFormField, bool List widgets = checkBoxFormField.getWidgets(); if (widgetExpected) { - Assert.assertEquals(1, widgets.size()); + Assertions.assertEquals(1, widgets.size()); PdfWidgetAnnotation annotation = widgets.get(0); - Assert.assertTrue(DUMMY_RECTANGLE.equalsWithEpsilon(annotation.getRectangle().toRectangle())); + Assertions.assertTrue(DUMMY_RECTANGLE.equalsWithEpsilon(annotation.getRectangle().toRectangle())); PdfArray kids = new PdfArray(); kids.add(annotation.getPdfObject()); putIfAbsent(expectedDictionary, PdfName.Kids, kids); } else { - Assert.assertEquals(0, widgets.size()); + Assertions.assertEquals(0, widgets.size()); } putIfAbsent(expectedDictionary, PdfName.FT, PdfName.Btn); @@ -115,7 +114,7 @@ private static void compareCheckBoxes(PdfButtonFormField checkBoxFormField, bool expectedDictionary.makeIndirect(DUMMY_DOCUMENT); checkBoxFormField.makeIndirect(DUMMY_DOCUMENT); - Assert.assertNull( + Assertions.assertNull( new CompareTool().compareDictionariesStructure(expectedDictionary, checkBoxFormField.getPdfObject())); } diff --git a/forms/src/test/java/com/itextpdf/forms/fields/ChoiceFormFieldBuilderTest.java b/forms/src/test/java/com/itextpdf/forms/fields/ChoiceFormFieldBuilderTest.java index b3392c96ac..432a416ba0 100644 --- a/forms/src/test/java/com/itextpdf/forms/fields/ChoiceFormFieldBuilderTest.java +++ b/forms/src/test/java/com/itextpdf/forms/fields/ChoiceFormFieldBuilderTest.java @@ -25,8 +25,8 @@ This file is part of the iText (R) project. import com.itextpdf.forms.exceptions.FormsExceptionMessageConstant; import com.itextpdf.io.font.PdfEncodings; import com.itextpdf.kernel.geom.Rectangle; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; import com.itextpdf.kernel.pdf.PdfArray; +import com.itextpdf.kernel.pdf.PdfConformance; import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfName; @@ -37,16 +37,15 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.annot.PdfWidgetAnnotation; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.ByteArrayOutputStream; import java.util.Arrays; import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(UnitTest.class) +@Tag("UnitTest") public class ChoiceFormFieldBuilderTest extends ExtendedITextTest { private static final PdfDocument DUMMY_DOCUMENT = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); private static final String DUMMY_NAME = "dummy name"; @@ -57,8 +56,8 @@ public class ChoiceFormFieldBuilderTest extends ExtendedITextTest { public void constructorTest() { ChoiceFormFieldBuilder builder = new ChoiceFormFieldBuilder(DUMMY_DOCUMENT, DUMMY_NAME); - Assert.assertSame(DUMMY_DOCUMENT, builder.getDocument()); - Assert.assertSame(DUMMY_NAME, builder.getFormFieldName()); + Assertions.assertSame(DUMMY_DOCUMENT, builder.getDocument()); + Assertions.assertSame(DUMMY_NAME, builder.getFormFieldName()); } @Test @@ -67,7 +66,7 @@ public void setGetOptionsAsPdfArrayTest() { builder.setOptions(DUMMY_OPTIONS); - Assert.assertSame(DUMMY_OPTIONS, builder.getOptions()); + Assertions.assertSame(DUMMY_OPTIONS, builder.getOptions()); } @Test @@ -79,7 +78,7 @@ public void setGetOptionsAsStringArrayTest() { builder.setOptions(options); for (int i = 0; i < options.length; ++i) { - Assert.assertEquals( + Assertions.assertEquals( new PdfString(options[i], PdfEncodings.UNICODE_BIG), builder.getOptions().getAsString(i)); } } @@ -94,7 +93,7 @@ public void setGetOptionsAsTwoDimensionalStringArrayTest() { for (int i = 0; i < options.length; ++i) { for (int j = 0; j < options[i].length; ++j) { - Assert.assertEquals( + Assertions.assertEquals( new PdfString(options[i][j], PdfEncodings.UNICODE_BIG), builder.getOptions().getAsArray(i).getAsString(j)); } @@ -107,8 +106,8 @@ public void setGetOptionsAsIllegalTwoDimensionalStringArrayTest() { String[][] options = new String[][]{new String[]{"option1", "option2", "option3"}}; - Exception exception = Assert.assertThrows(IllegalArgumentException.class, () -> builder.setOptions(options)); - Assert.assertEquals(FormsExceptionMessageConstant.INNER_ARRAY_SHALL_HAVE_TWO_ELEMENTS, exception.getMessage()); + Exception exception = Assertions.assertThrows(IllegalArgumentException.class, () -> builder.setOptions(options)); + Assertions.assertEquals(FormsExceptionMessageConstant.INNER_ARRAY_SHALL_HAVE_TWO_ELEMENTS, exception.getMessage()); } @Test @@ -129,7 +128,7 @@ public void createComboBoxWithoutWidgetTest() { @Test public void createComboBoxWithConformanceLevelTest() { PdfChoiceFormField choiceFormField = new ChoiceFormFieldBuilder(DUMMY_DOCUMENT, DUMMY_NAME) - .setWidgetRectangle(DUMMY_RECTANGLE).setGenericConformanceLevel(PdfAConformanceLevel.PDF_A_1A) + .setWidgetRectangle(DUMMY_RECTANGLE).setConformance(PdfConformance.PDF_A_1A) .createComboBox(); compareChoices(new PdfDictionary(), choiceFormField, true); @@ -179,7 +178,7 @@ public void createListWithoutWidgetTest() { public void createListWithConformanceLevelTest() { PdfChoiceFormField choiceFormField = new ChoiceFormFieldBuilder(DUMMY_DOCUMENT, DUMMY_NAME) .setWidgetRectangle(DUMMY_RECTANGLE) - .setGenericConformanceLevel(PdfAConformanceLevel.PDF_A_1A).createList(); + .setConformance(PdfConformance.PDF_A_1A).createList(); PdfDictionary expectedDictionary = new PdfDictionary(); expectedDictionary.put(PdfName.Ff, new PdfNumber(0)); @@ -215,17 +214,17 @@ private static void compareChoices(PdfDictionary expectedDictionary, List widgets = choiceFormField.getWidgets(); if (widgetExpected) { - Assert.assertEquals(1, widgets.size()); + Assertions.assertEquals(1, widgets.size()); PdfWidgetAnnotation annotation = widgets.get(0); - Assert.assertTrue(DUMMY_RECTANGLE.equalsWithEpsilon(annotation.getRectangle().toRectangle())); + Assertions.assertTrue(DUMMY_RECTANGLE.equalsWithEpsilon(annotation.getRectangle().toRectangle())); PdfArray kids = new PdfArray(); kids.add(annotation.getPdfObject()); putIfAbsent(expectedDictionary, PdfName.Kids, kids); } else { - Assert.assertEquals(0, widgets.size()); + Assertions.assertEquals(0, widgets.size()); } putIfAbsent(expectedDictionary, PdfName.FT, PdfName.Ch); @@ -237,7 +236,7 @@ private static void compareChoices(PdfDictionary expectedDictionary, expectedDictionary.makeIndirect(DUMMY_DOCUMENT); choiceFormField.makeIndirect(DUMMY_DOCUMENT); - Assert.assertNull( + Assertions.assertNull( new CompareTool().compareDictionariesStructure(expectedDictionary, choiceFormField.getPdfObject())); } diff --git a/forms/src/test/java/com/itextpdf/forms/fields/FieldsRotationTest.java b/forms/src/test/java/com/itextpdf/forms/fields/FieldsRotationTest.java index 69b02b0c65..576f93276e 100644 --- a/forms/src/test/java/com/itextpdf/forms/fields/FieldsRotationTest.java +++ b/forms/src/test/java/com/itextpdf/forms/fields/FieldsRotationTest.java @@ -32,42 +32,26 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.layout.Document; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import java.io.FileNotFoundException; import java.io.IOException; import java.util.Arrays; -@RunWith(Parameterized.class) -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class FieldsRotationTest extends ExtendedITextTest { public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/forms/fields/FieldsRotationTest/"; public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/forms/fields/FieldsRotationTest/"; - private final int[] pageRotation; - private final int[] fieldRotation; - private final boolean ignorePageRotation; - private final String testName; - - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(DESTINATION_FOLDER); } - public FieldsRotationTest(Object pageRotation, Object fieldRotation, Object ignorePageRotation, Object testName) { - this.pageRotation = (int[]) pageRotation; - this.fieldRotation = (int[]) fieldRotation; - this.ignorePageRotation = (boolean) ignorePageRotation; - this.testName = (String) testName; - } - - @Parameterized.Parameters(name = "{3}; ignore page rotation: {2}") public static Iterable rotationRelatedProperties() { return Arrays.asList(new Object[][]{ {new int[]{360, 90, 180, 270}, new int[]{0, 0, 0, 0}, true, "fieldsOnRotatedPagesDefault"}, @@ -80,17 +64,20 @@ public static Iterable rotationRelatedProperties() { }); } - @Test - public void fieldRotationTest() throws IOException, InterruptedException { + @ParameterizedTest(name = "{3}; ignore page rotation: {2}") + @MethodSource("rotationRelatedProperties") + public void fieldRotationTest(int[] pageRotation, int[] fieldRotation, boolean ignorePageRotation, String testName) + throws IOException, InterruptedException { String outFileName = DESTINATION_FOLDER + testName + ".pdf"; String cmpFileName = SOURCE_FOLDER + "cmp_" + testName + ".pdf"; - fillForm(outFileName); + fillForm(pageRotation, fieldRotation, ignorePageRotation, outFileName); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } - private void fillForm(String outPdf) throws FileNotFoundException { + private void fillForm(int[] pageRotation, int[] fieldRotation, boolean ignorePageRotation, String outPdf) + throws IOException { try (Document document = new Document(new PdfDocument(new PdfWriter(outPdf)))) { PdfAcroForm form = PdfFormCreator.getAcroForm(document.getPdfDocument(), true); diff --git a/forms/src/test/java/com/itextpdf/forms/fields/FormFieldBuilderTest.java b/forms/src/test/java/com/itextpdf/forms/fields/FormFieldBuilderTest.java index 42dbd6344b..ccebaeb0fc 100644 --- a/forms/src/test/java/com/itextpdf/forms/fields/FormFieldBuilderTest.java +++ b/forms/src/test/java/com/itextpdf/forms/fields/FormFieldBuilderTest.java @@ -22,19 +22,19 @@ This file is part of the iText (R) project. */ package com.itextpdf.forms.fields; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfAConformance; +import com.itextpdf.kernel.pdf.PdfConformance; import com.itextpdf.kernel.pdf.PdfDocument; -import com.itextpdf.kernel.pdf.PdfUAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfUAConformance; import com.itextpdf.kernel.pdf.PdfWriter; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; import java.io.ByteArrayOutputStream; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(UnitTest.class) +@Tag("UnitTest") public class FormFieldBuilderTest extends ExtendedITextTest { private static final PdfDocument DUMMY_DOCUMENT = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); private static final String DUMMY_NAME = "dummy name"; @@ -43,31 +43,22 @@ public class FormFieldBuilderTest extends ExtendedITextTest { public void constructorTest() { TestBuilder builder = new TestBuilder(DUMMY_DOCUMENT, DUMMY_NAME); - Assert.assertSame(DUMMY_DOCUMENT, builder.getDocument()); - Assert.assertSame(DUMMY_NAME, builder.getFormFieldName()); + Assertions.assertSame(DUMMY_DOCUMENT, builder.getDocument()); + Assertions.assertSame(DUMMY_NAME, builder.getFormFieldName()); } - @Test public void getSetConformanceLevelTest() { TestBuilder builder = new TestBuilder(DUMMY_DOCUMENT, DUMMY_NAME); - builder.setGenericConformanceLevel(PdfAConformanceLevel.PDF_A_1A); - Assert.assertSame(PdfAConformanceLevel.PDF_A_1A, builder.getGenericConformanceLevel()); - } - - @Test - public void getSetConformanceLevelDepreceatedTest() { - TestBuilder builder = new TestBuilder(DUMMY_DOCUMENT, DUMMY_NAME); - builder.setConformanceLevel(PdfAConformanceLevel.PDF_A_1A); - Assert.assertSame(PdfAConformanceLevel.PDF_A_1A, builder.getConformanceLevel()); + builder.setConformance(PdfConformance.PDF_A_1A); + Assertions.assertSame(PdfAConformance.PDF_A_1A, builder.getConformance().getAConformance()); } - @Test - public void getSetConformanceLevelDifferentTest() { + public void getSetConformanceLevelPdfUATest() { TestBuilder builder = new TestBuilder(DUMMY_DOCUMENT, DUMMY_NAME); - builder.setGenericConformanceLevel(PdfUAConformanceLevel.PDFUA_1); - Assert.assertNull(builder.getConformanceLevel()); + builder.setConformance(PdfConformance.PDF_UA_1); + Assertions.assertSame(PdfUAConformance.PDF_UA_1, builder.getConformance().getUAConformance()); } private static class TestBuilder extends FormFieldBuilder { diff --git a/forms/src/test/java/com/itextpdf/forms/fields/FormsMetaInfoStaticContainerTest.java b/forms/src/test/java/com/itextpdf/forms/fields/FormsMetaInfoStaticContainerTest.java index f97a0eb73f..a179db29c3 100644 --- a/forms/src/test/java/com/itextpdf/forms/fields/FormsMetaInfoStaticContainerTest.java +++ b/forms/src/test/java/com/itextpdf/forms/fields/FormsMetaInfoStaticContainerTest.java @@ -25,12 +25,11 @@ This file is part of the iText (R) project. import com.itextpdf.commons.actions.contexts.IMetaInfo; import com.itextpdf.layout.renderer.MetaInfoContainer; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class FormsMetaInfoStaticContainerTest extends ExtendedITextTest { @Test @@ -39,15 +38,15 @@ public void useMetaInfoDuringTheActionOneThreadTest() { MetaInfoContainer metaInfo2 = new MetaInfoContainer(new IMetaInfo() {}); FormsMetaInfoStaticContainer.useMetaInfoDuringTheAction(metaInfo1, () -> { - Assert.assertSame(metaInfo1, FormsMetaInfoStaticContainer.getMetaInfoForLayout()); + Assertions.assertSame(metaInfo1, FormsMetaInfoStaticContainer.getMetaInfoForLayout()); FormsMetaInfoStaticContainer.useMetaInfoDuringTheAction(metaInfo2, - () -> Assert.assertSame(metaInfo2, FormsMetaInfoStaticContainer.getMetaInfoForLayout())); + () -> Assertions.assertSame(metaInfo2, FormsMetaInfoStaticContainer.getMetaInfoForLayout())); - Assert.assertNull(FormsMetaInfoStaticContainer.getMetaInfoForLayout()); + Assertions.assertNull(FormsMetaInfoStaticContainer.getMetaInfoForLayout()); }); - Assert.assertNull(FormsMetaInfoStaticContainer.getMetaInfoForLayout()); + Assertions.assertNull(FormsMetaInfoStaticContainer.getMetaInfoForLayout()); } @Test @@ -60,9 +59,9 @@ public void useMetaInfoDuringTheActionSeveralThreadsTest() throws InterruptedExc thread.start(); thread.join(); - Assert.assertFalse(metaInfoCheckClass1.isCheckFailed()); - Assert.assertFalse(metaInfoCheckClass2.isCheckFailed()); - Assert.assertFalse(metaInfoCheckClass3.isCheckFailed()); + Assertions.assertFalse(metaInfoCheckClass1.isCheckFailed()); + Assertions.assertFalse(metaInfoCheckClass2.isCheckFailed()); + Assertions.assertFalse(metaInfoCheckClass3.isCheckFailed()); } private static class MetaInfoCheckClass { diff --git a/forms/src/test/java/com/itextpdf/forms/fields/NonTerminalFormFieldBuilderTest.java b/forms/src/test/java/com/itextpdf/forms/fields/NonTerminalFormFieldBuilderTest.java index b49e759698..ec2c63cce0 100644 --- a/forms/src/test/java/com/itextpdf/forms/fields/NonTerminalFormFieldBuilderTest.java +++ b/forms/src/test/java/com/itextpdf/forms/fields/NonTerminalFormFieldBuilderTest.java @@ -32,15 +32,13 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.annot.PdfWidgetAnnotation; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; - +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.ByteArrayOutputStream; import java.util.List; -@Category(UnitTest.class) +@Tag("UnitTest") public class NonTerminalFormFieldBuilderTest extends ExtendedITextTest { private static final PdfDocument DUMMY_DOCUMENT = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); private static final String DUMMY_NAME = "dummy name"; @@ -49,8 +47,8 @@ public class NonTerminalFormFieldBuilderTest extends ExtendedITextTest { public void constructorTest() { NonTerminalFormFieldBuilder builder = new NonTerminalFormFieldBuilder(DUMMY_DOCUMENT, DUMMY_NAME); - Assert.assertSame(DUMMY_DOCUMENT, builder.getDocument()); - Assert.assertSame(DUMMY_NAME, builder.getFormFieldName()); + Assertions.assertSame(DUMMY_DOCUMENT, builder.getDocument()); + Assertions.assertSame(DUMMY_NAME, builder.getFormFieldName()); } @Test @@ -66,13 +64,13 @@ private static void compareNonTerminalFormFields(PdfFormField nonTerminalFormFie List widgets = nonTerminalFormField.getWidgets(); - Assert.assertEquals(0, widgets.size()); + Assertions.assertEquals(0, widgets.size()); putIfAbsent(expectedDictionary, PdfName.T, new PdfString(DUMMY_NAME)); expectedDictionary.makeIndirect(DUMMY_DOCUMENT); nonTerminalFormField.makeIndirect(DUMMY_DOCUMENT); - Assert.assertNull(new CompareTool().compareDictionariesStructure( + Assertions.assertNull(new CompareTool().compareDictionariesStructure( expectedDictionary, nonTerminalFormField.getPdfObject())); } diff --git a/forms/src/test/java/com/itextpdf/forms/fields/PdfFormCreatorTest.java b/forms/src/test/java/com/itextpdf/forms/fields/PdfFormCreatorTest.java index 413eb3fd57..5bb7fa1b84 100644 --- a/forms/src/test/java/com/itextpdf/forms/fields/PdfFormCreatorTest.java +++ b/forms/src/test/java/com/itextpdf/forms/fields/PdfFormCreatorTest.java @@ -30,13 +30,12 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfWriter; import com.itextpdf.kernel.pdf.annot.PdfWidgetAnnotation; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfFormCreatorTest extends ExtendedITextTest { @Test public void getAcroFormTest() { @@ -52,7 +51,7 @@ public PdfAcroForm getAcroForm(PdfDocument document, boolean createIfNotExist) { try (PdfDocument document = new PdfDocument(new PdfWriter(new ByteArrayOutputStream()))) { PdfAcroForm acroForm = PdfFormCreator.getAcroForm(document, true); - Assert.assertNull(acroForm); + Assertions.assertNull(acroForm); } finally { PdfFormCreator.setFactory(new PdfFormFactory()); } @@ -75,7 +74,7 @@ public PdfTextFormField createTextFormField(PdfWidgetAnnotation widgetAnnotation try (PdfDocument document = new PdfDocument(new PdfWriter(new ByteArrayOutputStream()))) { PdfFormField text = new TextFormFieldBuilder(document, "name").setWidgetRectangle(new Rectangle(100, 100)).createText(); - Assert.assertEquals(ColorConstants.RED, text.getColor()); + Assertions.assertEquals(ColorConstants.RED, text.getColor()); } finally { PdfFormCreator.setFactory(new PdfFormFactory()); } diff --git a/forms/src/test/java/com/itextpdf/forms/fields/PdfFormFieldIntegrationTest.java b/forms/src/test/java/com/itextpdf/forms/fields/PdfFormFieldIntegrationTest.java index ab69fc7af3..401169e6c3 100644 --- a/forms/src/test/java/com/itextpdf/forms/fields/PdfFormFieldIntegrationTest.java +++ b/forms/src/test/java/com/itextpdf/forms/fields/PdfFormFieldIntegrationTest.java @@ -30,21 +30,20 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.xobject.PdfFormXObject; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfFormFieldIntegrationTest extends ExtendedITextTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/forms/fields/PdfFormFieldIntegrationTest/"; private static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/forms/fields/PdfFormFieldIntegrationTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(DESTINATION_FOLDER); } @@ -65,6 +64,6 @@ public void addFormXObjectToPushButtonTest() throws IOException, InterruptedExce pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); } } diff --git a/forms/src/test/java/com/itextpdf/forms/fields/PdfFormFieldNameTest.java b/forms/src/test/java/com/itextpdf/forms/fields/PdfFormFieldNameTest.java index 34290293fe..6196b9d881 100644 --- a/forms/src/test/java/com/itextpdf/forms/fields/PdfFormFieldNameTest.java +++ b/forms/src/test/java/com/itextpdf/forms/fields/PdfFormFieldNameTest.java @@ -33,32 +33,31 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfFormFieldNameTest extends ExtendedITextTest { private PdfDocument outputDoc; private PdfAcroForm acroForm; - @Before + @BeforeEach public void init() { outputDoc = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); outputDoc.addNewPage(); acroForm = PdfFormCreator.getAcroForm(outputDoc, true); } - @After + @AfterEach public void shutdown() { outputDoc.close(); } @@ -79,12 +78,12 @@ public void getFormFieldWithNormalNames() { PdfFormField child2RecoveredField = acroForm.getField("root.child1.child2"); //ASSERT - Assert.assertEquals(root, rootRecoveredField); - Assert.assertEquals("root", rootRecoveredField.getFieldName().toString()); - Assert.assertEquals(child1, child1RecoveredField); - Assert.assertEquals("root.child1", child1RecoveredField.getFieldName().toString()); - Assert.assertEquals(child2, child2RecoveredField); - Assert.assertEquals("root.child1.child2", child2RecoveredField.getFieldName().toString()); + Assertions.assertEquals(root, rootRecoveredField); + Assertions.assertEquals("root", rootRecoveredField.getFieldName().toString()); + Assertions.assertEquals(child1, child1RecoveredField); + Assertions.assertEquals("root.child1", child1RecoveredField.getFieldName().toString()); + Assertions.assertEquals(child2, child2RecoveredField); + Assertions.assertEquals("root.child1.child2", child2RecoveredField.getFieldName().toString()); } @Test @@ -102,12 +101,12 @@ public void getFormFieldWithNormalNamesRootIsEmpty() { PdfFormField child1RecoveredField = acroForm.getField(".child1"); PdfFormField child2RecoveredField = acroForm.getField(".child1.child2"); //ASSERT - Assert.assertEquals(root, rootRecoveredField); - Assert.assertEquals("", rootRecoveredField.getFieldName().toString()); - Assert.assertEquals(child1, child1RecoveredField); - Assert.assertEquals(".child1", child1RecoveredField.getFieldName().toString()); - Assert.assertEquals(child2, child2RecoveredField); - Assert.assertEquals(".child1.child2", child2RecoveredField.getFieldName().toString()); + Assertions.assertEquals(root, rootRecoveredField); + Assertions.assertEquals("", rootRecoveredField.getFieldName().toString()); + Assertions.assertEquals(child1, child1RecoveredField); + Assertions.assertEquals(".child1", child1RecoveredField.getFieldName().toString()); + Assertions.assertEquals(child2, child2RecoveredField); + Assertions.assertEquals(".child1.child2", child2RecoveredField.getFieldName().toString()); } @Test @@ -122,10 +121,10 @@ public void getFormFieldWithWhiteSpaceInNames() { PdfFormField rootRecoveredField = acroForm.getField("ro\tot"); PdfFormField child1RecoveredField = acroForm.getField("ro\tot.child 1"); //ASSERT - Assert.assertEquals(root, rootRecoveredField); - Assert.assertEquals("ro\tot", rootRecoveredField.getFieldName().toString()); - Assert.assertEquals(child1, child1RecoveredField); - Assert.assertEquals("ro\tot.child 1", child1RecoveredField.getFieldName().toString()); + Assertions.assertEquals(root, rootRecoveredField); + Assertions.assertEquals("ro\tot", rootRecoveredField.getFieldName().toString()); + Assertions.assertEquals(child1, child1RecoveredField); + Assertions.assertEquals("ro\tot.child 1", child1RecoveredField.getFieldName().toString()); } @Test @@ -143,12 +142,12 @@ public void getFormFieldWithEmptyStringAsName() { PdfFormField child1RecoveredField = acroForm.getField("root."); PdfFormField child2RecoveredField = acroForm.getField("root..child2"); //ASSERT - Assert.assertEquals(root, rootRecoveredField); - Assert.assertEquals("root", rootRecoveredField.getFieldName().toString()); - Assert.assertEquals(child1, child1RecoveredField); - Assert.assertEquals("root.", child1RecoveredField.getFieldName().toString()); - Assert.assertEquals(child2, child2RecoveredField); - Assert.assertEquals("root..child2", child2RecoveredField.getFieldName().toString()); + Assertions.assertEquals(root, rootRecoveredField); + Assertions.assertEquals("root", rootRecoveredField.getFieldName().toString()); + Assertions.assertEquals(child1, child1RecoveredField); + Assertions.assertEquals("root.", child1RecoveredField.getFieldName().toString()); + Assertions.assertEquals(child2, child2RecoveredField); + Assertions.assertEquals("root..child2", child2RecoveredField.getFieldName().toString()); } @@ -167,12 +166,12 @@ public void getFormFieldWithTwoEmptyStringAsName() { PdfFormField child1RecoveredField = acroForm.getField("root."); PdfFormField child2RecoveredField = acroForm.getField("root.."); //ASSERT - Assert.assertEquals(root, rootRecoveredField); - Assert.assertEquals("root", rootRecoveredField.getFieldName().toString()); - Assert.assertEquals(child1, child1RecoveredField); - Assert.assertEquals("root.", child1RecoveredField.getFieldName().toString()); - Assert.assertEquals(child2, child2RecoveredField); - Assert.assertEquals("root..", child2RecoveredField.getFieldName().toString()); + Assertions.assertEquals(root, rootRecoveredField); + Assertions.assertEquals("root", rootRecoveredField.getFieldName().toString()); + Assertions.assertEquals(child1, child1RecoveredField); + Assertions.assertEquals("root.", child1RecoveredField.getFieldName().toString()); + Assertions.assertEquals(child2, child2RecoveredField); + Assertions.assertEquals("root..", child2RecoveredField.getFieldName().toString()); } @Test @@ -193,14 +192,14 @@ public void getFormFieldWithTwoEmptyStringAsNameFollowedByActualName() { PdfFormField child2RecoveredField = acroForm.getField("root.."); PdfFormField child3RecoveredField = acroForm.getField("root...child3"); //ASSERT - Assert.assertEquals(root, rootRecoveredField); - Assert.assertEquals("root", rootRecoveredField.getFieldName().toString()); - Assert.assertEquals(child1, child1RecoveredField); - Assert.assertEquals("root.", child1RecoveredField.getFieldName().toString()); - Assert.assertEquals(child2, child2RecoveredField); - Assert.assertEquals("root..", child2RecoveredField.getFieldName().toString()); - Assert.assertEquals(child3, child3RecoveredField); - Assert.assertEquals("root...child3", child3RecoveredField.getFieldName().toString()); + Assertions.assertEquals(root, rootRecoveredField); + Assertions.assertEquals("root", rootRecoveredField.getFieldName().toString()); + Assertions.assertEquals(child1, child1RecoveredField); + Assertions.assertEquals("root.", child1RecoveredField.getFieldName().toString()); + Assertions.assertEquals(child2, child2RecoveredField); + Assertions.assertEquals("root..", child2RecoveredField.getFieldName().toString()); + Assertions.assertEquals(child3, child3RecoveredField); + Assertions.assertEquals("root...child3", child3RecoveredField.getFieldName().toString()); } @@ -223,14 +222,14 @@ public void getFormFieldWithAlternatingFilledInStartWithRootFilledIn() { PdfFormField child2RecoveredField = acroForm.getField("root..child2"); PdfFormField child3RecoveredField = acroForm.getField("root..child2."); //ASSERT - Assert.assertEquals(root, rootRecoveredField); - Assert.assertEquals("root", rootRecoveredField.getFieldName().toString()); - Assert.assertEquals(child1, child1RecoveredField); - Assert.assertEquals("root.", child1RecoveredField.getFieldName().toString()); - Assert.assertEquals(child2, child2RecoveredField); - Assert.assertEquals("root..child2", child2RecoveredField.getFieldName().toString()); - Assert.assertEquals(child3, child3RecoveredField); - Assert.assertEquals("root..child2.", child3RecoveredField.getFieldName().toString()); + Assertions.assertEquals(root, rootRecoveredField); + Assertions.assertEquals("root", rootRecoveredField.getFieldName().toString()); + Assertions.assertEquals(child1, child1RecoveredField); + Assertions.assertEquals("root.", child1RecoveredField.getFieldName().toString()); + Assertions.assertEquals(child2, child2RecoveredField); + Assertions.assertEquals("root..child2", child2RecoveredField.getFieldName().toString()); + Assertions.assertEquals(child3, child3RecoveredField); + Assertions.assertEquals("root..child2.", child3RecoveredField.getFieldName().toString()); } @Test @@ -252,15 +251,15 @@ public void getFormFieldWithAlternatingFilledInStartWithRootEmpty() { PdfFormField child2RecoveredField = acroForm.getField(".child1."); PdfFormField child3RecoveredField = acroForm.getField(".child1..child3"); //ASSERT - Assert.assertEquals(root, rootRecoveredField); - Assert.assertEquals("", rootRecoveredField.getFieldName().toString()); + Assertions.assertEquals(root, rootRecoveredField); + Assertions.assertEquals("", rootRecoveredField.getFieldName().toString()); - Assert.assertEquals(child1, child1RecoveredField); - Assert.assertEquals(".child1", child1RecoveredField.getFieldName().toString()); - Assert.assertEquals(child2, child2RecoveredField); - Assert.assertEquals(".child1.", child2RecoveredField.getFieldName().toString()); - Assert.assertEquals(child3, child3RecoveredField); - Assert.assertEquals(".child1..child3", child3RecoveredField.getFieldName().toString()); + Assertions.assertEquals(child1, child1RecoveredField); + Assertions.assertEquals(".child1", child1RecoveredField.getFieldName().toString()); + Assertions.assertEquals(child2, child2RecoveredField); + Assertions.assertEquals(".child1.", child2RecoveredField.getFieldName().toString()); + Assertions.assertEquals(child3, child3RecoveredField); + Assertions.assertEquals(".child1..child3", child3RecoveredField.getFieldName().toString()); } @@ -280,8 +279,8 @@ public void removeFieldWithEmptyNameCorrectlyRemoved() { //ASSERT PdfFormField rootRecoveredField = acroForm.getField("root"); - Assert.assertFalse(rootRecoveredField.getChildFields().contains(child1)); - Assert.assertTrue(rootRecoveredField.getChildFields().contains(child2)); + Assertions.assertFalse(rootRecoveredField.getChildFields().contains(child1)); + Assertions.assertTrue(rootRecoveredField.getChildFields().contains(child2)); } @Test @@ -302,8 +301,8 @@ public void removeFieldWithEmptyName2DeepCorrectlyRemoved() { //ASSERT PdfFormField rootRecoveredField = acroForm.getField("root"); - Assert.assertTrue(rootRecoveredField.getChildFields().contains(child1)); - Assert.assertFalse(rootRecoveredField.getChildFields().contains(child2)); + Assertions.assertTrue(rootRecoveredField.getChildFields().contains(child1)); + Assertions.assertFalse(rootRecoveredField.getChildFields().contains(child2)); } @Test @@ -324,8 +323,8 @@ public void removeFieldWith2EmptyNamesCorrectlyRemoved() { //ASSERT PdfFormField rootRecoveredField = acroForm.getField("root"); - Assert.assertTrue(rootRecoveredField.getChildFields().contains(child1)); - Assert.assertFalse(rootRecoveredField.getChildFields().contains(child2)); + Assertions.assertTrue(rootRecoveredField.getChildFields().contains(child1)); + Assertions.assertFalse(rootRecoveredField.getChildFields().contains(child2)); } @Test @@ -347,9 +346,9 @@ public void getFormFieldWithAllEmptyNamesCorrectlyRemoved() { //ASSERT PdfFormField rootRecoveredField = acroForm.getField(""); - Assert.assertTrue(rootRecoveredField.getChildFields().contains(child1)); - Assert.assertFalse(rootRecoveredField.getChildFields().contains(child2)); - Assert.assertEquals(sizeBeforeRemoval - 1, acroForm.getAllFormFields().size()); + Assertions.assertTrue(rootRecoveredField.getChildFields().contains(child1)); + Assertions.assertFalse(rootRecoveredField.getChildFields().contains(child2)); + Assertions.assertEquals(sizeBeforeRemoval - 1, acroForm.getAllFormFields().size()); } @@ -370,7 +369,7 @@ public void removeFormFieldRemoveEmptyRootNoFieldsAnyMore() { acroForm.removeField(""); //ASSERT - Assert.assertEquals(0, acroForm.getAllFormFields().size()); + Assertions.assertEquals(0, acroForm.getAllFormFields().size()); } @@ -384,7 +383,7 @@ public void renameFieldToEmptyNamesGetsRenamed() { //ACT acroForm.renameField("root.child1", ""); //ASSERT - Assert.assertEquals("root.", child1.getFieldName().toUnicodeString()); + Assertions.assertEquals("root.", child1.getFieldName().toUnicodeString()); } @Test @@ -398,7 +397,7 @@ public void renameFieldWithEmptyNameGetsRenamed() { acroForm.renameField("root", ""); acroForm.renameField(".newName", ""); //ASSERT - Assert.assertEquals(".", child1.getFieldName().toUnicodeString()); + Assertions.assertEquals(".", child1.getFieldName().toUnicodeString()); } @@ -415,7 +414,7 @@ public void renameFieldWithNotFoundNameLogsWarning() { acroForm.addField(root); //ACT acroForm.renameField("root.", ""); - Assert.assertEquals("root.newName", child1.getFieldName().toUnicodeString()); + Assertions.assertEquals("root.newName", child1.getFieldName().toUnicodeString()); } @Test @@ -433,7 +432,7 @@ public void renameFieldWithNotFoundNameLogsError() { acroForm.renameField("root", ""); acroForm.renameField("root.newName", ""); //ASSERT - Assert.assertEquals(".newName", child1.getFieldName().toUnicodeString()); + Assertions.assertEquals(".newName", child1.getFieldName().toUnicodeString()); } @Test @@ -448,7 +447,7 @@ public void renameFieldWithEmptyName2DeepGetRenamed() { //ACT acroForm.renameField("root..", "newName"); //ASSERT - Assert.assertEquals("root..newName", child2.getFieldName().toUnicodeString()); + Assertions.assertEquals("root..newName", child2.getFieldName().toUnicodeString()); } @Test @@ -463,7 +462,7 @@ public void renameFieldWithEmptyNameRootDeepGetRenamed() { //ACT acroForm.renameField("..", "newName"); //ASSERT - Assert.assertEquals("..newName", child2.getFieldName().toUnicodeString()); + Assertions.assertEquals("..newName", child2.getFieldName().toUnicodeString()); } @Test @@ -477,14 +476,14 @@ public void renameFieldRenameAllFromEmpty() { acroForm.addField(root); //ACT acroForm.renameField("", "newName"); - Assert.assertNull(acroForm.getField("")); - Assert.assertNotNull(acroForm.getField("newName")); + Assertions.assertNull(acroForm.getField("")); + Assertions.assertNotNull(acroForm.getField("newName")); acroForm.renameField("newName.", "newName"); - Assert.assertEquals("newName.newName", child1.getFieldName().toUnicodeString()); + Assertions.assertEquals("newName.newName", child1.getFieldName().toUnicodeString()); //ASSERT acroForm.renameField("newName.newName.", "newName"); - Assert.assertEquals("newName.newName.newName", child2.getFieldName().toUnicodeString()); + Assertions.assertEquals("newName.newName.newName", child2.getFieldName().toUnicodeString()); } @Test @@ -497,7 +496,7 @@ public void renameMultipleTimesInLoop() { //ACT for (int i = 0; i < 100; i++) { acroForm.renameField("root." + (i - 1), "" + i); - Assert.assertEquals("root." + i, child1.getFieldName().toUnicodeString()); + Assertions.assertEquals("root." + i, child1.getFieldName().toUnicodeString()); } } @@ -509,8 +508,8 @@ public void copyFieldWithEmptyNamesWork() { root.addKid(child1); acroForm.addField(root); PdfFormField copy = acroForm.copyField("root."); - Assert.assertNotNull( copy); - Assert.assertEquals("root.", copy.getFieldName().toUnicodeString()); + Assertions.assertNotNull( copy); + Assertions.assertEquals("root.", copy.getFieldName().toUnicodeString()); } @Test @@ -522,7 +521,7 @@ public void copyFieldWithEmptyNames2DeepWork() { root.addKid(child1); acroForm.addField(root); PdfFormField copy = acroForm.copyField("root.."); - Assert.assertNotNull(copy); + Assertions.assertNotNull(copy); } @@ -535,8 +534,8 @@ public void replaceFieldReplacesItInTheChild() { PdfFormField toReplace = addDefaultTextFormField(outputDoc, "toReplace"); acroForm.replaceField("root.child", toReplace); - Assert.assertNull(acroForm.getField("toReplace")); - Assert.assertNotNull(acroForm.getField("root.toReplace")); + Assertions.assertNull(acroForm.getField("toReplace")); + Assertions.assertNotNull(acroForm.getField("root.toReplace")); } @Test @@ -548,8 +547,8 @@ public void replaceFieldReplacesItInTheChildWithChildNameEmpty() { PdfFormField toReplace = addDefaultTextFormField(outputDoc, "toReplace"); acroForm.replaceField("root.", toReplace); - Assert.assertNull(acroForm.getField("toReplace")); - Assert.assertNotNull(acroForm.getField("root.toReplace")); + Assertions.assertNull(acroForm.getField("toReplace")); + Assertions.assertNotNull(acroForm.getField("root.toReplace")); } @Test @@ -574,10 +573,10 @@ public void copyFormFieldWithoutName() throws IOException { PdfPageFormCopier pdfPageFormCopier = new PdfPageFormCopier(); loaded.copyPagesTo(1, 1, newDoc, pdfPageFormCopier); PdfAcroForm form = PdfFormCreator.getAcroForm(outputDoc, false); - Assert.assertNotNull(form); - Assert.assertEquals(2, form.getAllFormFields().size()); - Assert.assertNotNull(form.getField("root.")); - Assert.assertNotNull(form.getField("root")); + Assertions.assertNotNull(form); + Assertions.assertEquals(2, form.getAllFormFields().size()); + Assertions.assertNotNull(form.getField("root.")); + Assertions.assertNotNull(form.getField("root")); } } @@ -604,10 +603,10 @@ public void copyFormFieldWithoutRootName() throws IOException { PdfPageFormCopier pdfPageFormCopier = new PdfPageFormCopier(); loaded.copyPagesTo(1, 1, newDoc, pdfPageFormCopier); PdfAcroForm form = PdfFormCreator.getAcroForm(outputDoc, false); - Assert.assertNotNull(form); - Assert.assertEquals(2, form.getAllFormFields().size()); - Assert.assertNotNull(form.getField(".")); - Assert.assertNotNull(form.getField("")); + Assertions.assertNotNull(form); + Assertions.assertEquals(2, form.getAllFormFields().size()); + Assertions.assertNotNull(form.getField(".")); + Assertions.assertNotNull(form.getField("")); } } @@ -637,10 +636,10 @@ public void copyFormFieldWithoutNameAdded2timesOverwritesTheFirst() throws IOExc PdfPageFormCopier pdfPageFormCopier = new PdfPageFormCopier(); loaded.copyPagesTo(1, 1, newDoc, pdfPageFormCopier); PdfAcroForm form = PdfFormCreator.getAcroForm(outputDoc, false); - Assert.assertNotNull(form); - Assert.assertEquals(2, form.getAllFormFields().size()); - Assert.assertNotNull(form.getField("root.")); - Assert.assertNotNull(form.getField("root")); + Assertions.assertNotNull(form); + Assertions.assertEquals(2, form.getAllFormFields().size()); + Assertions.assertNotNull(form.getField("root.")); + Assertions.assertNotNull(form.getField("root")); } } @@ -652,7 +651,7 @@ public void addingSiblingsSameNameMergesFieldsTogether() { root.addKid(child1); root.addKid(child2); acroForm.addField(root); - Assert.assertEquals(2, root.getChildFields().size()); + Assertions.assertEquals(2, root.getChildFields().size()); } @Test @@ -663,7 +662,7 @@ public void addingSiblingsSameEmptyNamesMergesFieldsTogether() { root.addKid(child1); root.addKid(child2); acroForm.addField(root); - Assert.assertEquals(2, root.getChildFields().size()); + Assertions.assertEquals(2, root.getChildFields().size()); } private static PdfFormField addDefaultTextFormField(PdfDocument doc, String name) { diff --git a/forms/src/test/java/com/itextpdf/forms/fields/PdfFormFieldUnitTest.java b/forms/src/test/java/com/itextpdf/forms/fields/PdfFormFieldUnitTest.java index 760ee5fb29..be65371031 100644 --- a/forms/src/test/java/com/itextpdf/forms/fields/PdfFormFieldUnitTest.java +++ b/forms/src/test/java/com/itextpdf/forms/fields/PdfFormFieldUnitTest.java @@ -34,20 +34,19 @@ This file is part of the iText (R) project. import com.itextpdf.layout.properties.Property; import com.itextpdf.layout.renderer.MetaInfoContainer; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfFormFieldUnitTest extends ExtendedITextTest { @Test public void cannotGetRectangleIfKidsIsNullTest() { PdfDocument pdfDocument = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); PdfFormField pdfFormField = PdfFormCreator.createFormField(pdfDocument); - Assert.assertNull(pdfFormField.getFirstFormAnnotation()); + Assertions.assertNull(pdfFormField.getFirstFormAnnotation()); } @Test @@ -58,7 +57,7 @@ public void setMetaInfoToCanvasMetaInfoUsedTest() { FormsMetaInfoStaticContainer.useMetaInfoDuringTheAction(metaInfoContainer, () -> PdfFormAnnotation.setMetaInfoToCanvas(canvas)); - Assert.assertSame(metaInfoContainer, canvas.getProperty(Property.META_INFO)); + Assertions.assertSame(metaInfoContainer, canvas.getProperty(Property.META_INFO)); } @Test @@ -66,7 +65,7 @@ public void setMetaInfoToCanvasMetaInfoNotUsedTest() { Canvas canvas = createCanvas(); PdfFormAnnotation.setMetaInfoToCanvas(canvas); - Assert.assertNull(canvas.getProperty(Property.META_INFO)); + Assertions.assertNull(canvas.getProperty(Property.META_INFO)); } private static Canvas createCanvas() { diff --git a/forms/src/test/java/com/itextpdf/forms/fields/PushButtonFormFieldBuilderTest.java b/forms/src/test/java/com/itextpdf/forms/fields/PushButtonFormFieldBuilderTest.java index 60a0d028bf..4a87be0602 100644 --- a/forms/src/test/java/com/itextpdf/forms/fields/PushButtonFormFieldBuilderTest.java +++ b/forms/src/test/java/com/itextpdf/forms/fields/PushButtonFormFieldBuilderTest.java @@ -23,8 +23,8 @@ This file is part of the iText (R) project. package com.itextpdf.forms.fields; import com.itextpdf.kernel.geom.Rectangle; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; import com.itextpdf.kernel.pdf.PdfArray; +import com.itextpdf.kernel.pdf.PdfConformance; import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfName; @@ -35,15 +35,14 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.annot.PdfWidgetAnnotation; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.ByteArrayOutputStream; import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(UnitTest.class) +@Tag("UnitTest") public class PushButtonFormFieldBuilderTest extends ExtendedITextTest { private static final PdfDocument DUMMY_DOCUMENT = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); @@ -54,8 +53,8 @@ public class PushButtonFormFieldBuilderTest extends ExtendedITextTest { public void constructorTest() { PushButtonFormFieldBuilder builder = new PushButtonFormFieldBuilder(DUMMY_DOCUMENT, DUMMY_NAME); - Assert.assertSame(DUMMY_DOCUMENT, builder.getDocument()); - Assert.assertSame(DUMMY_NAME, builder.getFormFieldName()); + Assertions.assertSame(DUMMY_DOCUMENT, builder.getDocument()); + Assertions.assertSame(DUMMY_NAME, builder.getFormFieldName()); } @Test @@ -63,7 +62,7 @@ public void setGetCaptionType() { PushButtonFormFieldBuilder builder = new PushButtonFormFieldBuilder(DUMMY_DOCUMENT, DUMMY_NAME); builder.setCaption("Caption"); - Assert.assertEquals("Caption", builder.getCaption()); + Assertions.assertEquals("Caption", builder.getCaption()); } @Test @@ -85,7 +84,7 @@ public void createPushButtonWithoutWidgetTest() { @Test public void createPushButtonWithConformanceLevelTest() { PdfButtonFormField pushButtonFormField = new PushButtonFormFieldBuilder(DUMMY_DOCUMENT, DUMMY_NAME) - .setWidgetRectangle(DUMMY_RECTANGLE).setGenericConformanceLevel(PdfAConformanceLevel.PDF_A_1A) + .setWidgetRectangle(DUMMY_RECTANGLE).setConformance(PdfConformance.PDF_A_1A) .createPushButton(); comparePushButtons(pushButtonFormField, true); @@ -97,17 +96,17 @@ private static void comparePushButtons(PdfButtonFormField pushButtonFormField, b List widgets = pushButtonFormField.getWidgets(); if (widgetExpected) { - Assert.assertEquals(1, widgets.size()); + Assertions.assertEquals(1, widgets.size()); PdfWidgetAnnotation annotation = widgets.get(0); - Assert.assertTrue(DUMMY_RECTANGLE.equalsWithEpsilon(annotation.getRectangle().toRectangle())); + Assertions.assertTrue(DUMMY_RECTANGLE.equalsWithEpsilon(annotation.getRectangle().toRectangle())); PdfArray kids = new PdfArray(); kids.add(annotation.getPdfObject()); putIfAbsent(expectedDictionary, PdfName.Kids, kids); } else { - Assert.assertEquals(0, widgets.size()); + Assertions.assertEquals(0, widgets.size()); } putIfAbsent(expectedDictionary, PdfName.FT, PdfName.Btn); @@ -117,7 +116,7 @@ private static void comparePushButtons(PdfButtonFormField pushButtonFormField, b expectedDictionary.makeIndirect(DUMMY_DOCUMENT); pushButtonFormField.makeIndirect(DUMMY_DOCUMENT); - Assert.assertNull( + Assertions.assertNull( new CompareTool().compareDictionariesStructure(expectedDictionary, pushButtonFormField.getPdfObject())); } diff --git a/forms/src/test/java/com/itextpdf/forms/fields/RadioFormFieldBuilderTest.java b/forms/src/test/java/com/itextpdf/forms/fields/RadioFormFieldBuilderTest.java index 81faec4909..b7e0330539 100644 --- a/forms/src/test/java/com/itextpdf/forms/fields/RadioFormFieldBuilderTest.java +++ b/forms/src/test/java/com/itextpdf/forms/fields/RadioFormFieldBuilderTest.java @@ -25,8 +25,8 @@ This file is part of the iText (R) project. import com.itextpdf.forms.PdfAcroForm; import com.itextpdf.kernel.exceptions.PdfException; import com.itextpdf.kernel.geom.Rectangle; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; import com.itextpdf.kernel.pdf.PdfArray; +import com.itextpdf.kernel.pdf.PdfConformance; import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfName; @@ -38,16 +38,15 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.annot.PdfWidgetAnnotation; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.ByteArrayOutputStream; import java.util.ArrayList; import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(UnitTest.class) +@Tag("UnitTest") public class RadioFormFieldBuilderTest extends ExtendedITextTest { private static final PdfDocument DUMMY_DOCUMENT = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); @@ -60,8 +59,8 @@ public class RadioFormFieldBuilderTest extends ExtendedITextTest { @Test public void twoParametersConstructorTest() { RadioFormFieldBuilder builder = new RadioFormFieldBuilder(DUMMY_DOCUMENT, DUMMY_NAME); - Assert.assertSame(DUMMY_DOCUMENT, builder.getDocument()); - Assert.assertSame(DUMMY_NAME, builder.getFormFieldName()); + Assertions.assertSame(DUMMY_DOCUMENT, builder.getDocument()); + Assertions.assertSame(DUMMY_NAME, builder.getFormFieldName()); } @Test @@ -92,10 +91,10 @@ public void createRadioButtonWithWidgetUseSetWidgetRectangleTest() { @Test public void createRadioButtonWithEmptyAppearanceNameThrowsExceptionTest() { RadioFormFieldBuilder builder = new RadioFormFieldBuilder(DUMMY_DOCUMENT, DUMMY_NAME); - Assert.assertThrows(PdfException.class, () -> { + Assertions.assertThrows(PdfException.class, () -> { builder.createRadioButton(null, DUMMY_RECTANGLE); }); - Assert.assertThrows(PdfException.class, () -> { + Assertions.assertThrows(PdfException.class, () -> { builder.createRadioButton("", DUMMY_RECTANGLE); }); @@ -126,7 +125,7 @@ public void create2RadioButtonWithWidgetAddedToRadioGroupTest() { compareRadioButtons(radioAnnotation, radioGroup, true); compareRadioButtons(radioAnnotation2, radioGroup, true); - Assert.assertEquals(2, radioGroup.getWidgets().size()); + Assertions.assertEquals(2, radioGroup.getWidgets().size()); } @@ -144,11 +143,11 @@ public void create2RadioButtonWithWidgetAddedToRadioGroupOneSelectedTest() { radioGroup.addKid(radioAnnotation); radioGroup.addKid(radioAnnotation2); - Assert.assertEquals(PdfFormAnnotation.OFF_STATE_VALUE, radioAnnotation2.getAppearanceStates()[0]); - Assert.assertEquals(DUMMY_APPEARANCE_NAME, radioAnnotation.getPdfObject().getAsName(PdfName.AS).getValue()); + Assertions.assertEquals(PdfFormAnnotation.OFF_STATE_VALUE, radioAnnotation2.getAppearanceStates()[0]); + Assertions.assertEquals(DUMMY_APPEARANCE_NAME, radioAnnotation.getPdfObject().getAsName(PdfName.AS).getValue()); compareRadioButtons(radioAnnotation, radioGroup, true); compareRadioButtons(radioAnnotation2, radioGroup, true); - Assert.assertEquals(2, radioGroup.getWidgets().size()); + Assertions.assertEquals(2, radioGroup.getWidgets().size()); } @Test @@ -164,7 +163,7 @@ public void createRadioButtonWithoutWidgetTest() { @Test public void createRadioButtonWithoutWidgetThrowsExceptionTest() { RadioFormFieldBuilder builder = new RadioFormFieldBuilder(DUMMY_DOCUMENT, DUMMY_NAME); - Assert.assertThrows(PdfException.class,()->{ + Assertions.assertThrows(PdfException.class,()->{ PdfFormAnnotation radioAnnotation = builder .createRadioButton(DUMMY_APPEARANCE_NAME, null); }); @@ -175,7 +174,7 @@ public void createRadioButtonWithConformanceLevelTest() { RadioFormFieldBuilder builder = new RadioFormFieldBuilder(DUMMY_DOCUMENT, DUMMY_NAME); PdfButtonFormField radioGroup = builder.createRadioGroup(); PdfFormAnnotation radioAnnotation = builder - .setGenericConformanceLevel(PdfAConformanceLevel.PDF_A_1A) + .setConformance(PdfConformance.PDF_A_1A) .createRadioButton(DUMMY_APPEARANCE_NAME, DUMMY_RECTANGLE); compareRadioButtons(radioAnnotation, radioGroup, false); } @@ -186,7 +185,7 @@ public void createRadioButtonWithConformanceLevelAddedToGroupTest() { RadioFormFieldBuilder builder = new RadioFormFieldBuilder(DUMMY_DOCUMENT, DUMMY_NAME); PdfButtonFormField radioGroup = builder.createRadioGroup(); PdfFormAnnotation radioAnnotation = builder - .setGenericConformanceLevel(PdfAConformanceLevel.PDF_A_1A) + .setConformance(PdfConformance.PDF_A_1A) .createRadioButton(DUMMY_APPEARANCE_NAME, DUMMY_RECTANGLE); radioGroup.addKid(radioAnnotation); compareRadioButtons(radioAnnotation, radioGroup, true); @@ -201,7 +200,7 @@ private static void compareRadioGroups(PdfButtonFormField radioGroupFormField) { expectedDictionary.makeIndirect(DUMMY_DOCUMENT); radioGroupFormField.makeIndirect(DUMMY_DOCUMENT); - Assert.assertNull( + Assertions.assertNull( new CompareTool().compareDictionariesStructure(expectedDictionary, radioGroupFormField.getPdfObject())); } @@ -214,7 +213,7 @@ public void createRadioButtonShouldNotContainTerminalFieldKeys() { .createRadioButton(DUMMY_APPEARANCE_NAME, DUMMY_RECTANGLE); form.addField(radioGroup); - Assert.assertTrue(PdfFormAnnotationUtil.isPureWidget(radioAnnotation.getPdfObject())); + Assertions.assertTrue(PdfFormAnnotationUtil.isPureWidget(radioAnnotation.getPdfObject())); } } @@ -227,8 +226,8 @@ public void createRadioButtonButDontAddToGroupGroupContainsNoRadioButton() { .createRadioButton(DUMMY_APPEARANCE_NAME, DUMMY_RECTANGLE); form.addField(radioGroup); - Assert.assertNull(radioGroup.getPdfObject().get(PdfName.Kids)); - Assert.assertEquals(0, radioGroup.getWidgets().size()); + Assertions.assertNull(radioGroup.getPdfObject().get(PdfName.Kids)); + Assertions.assertEquals(0, radioGroup.getWidgets().size()); } } @@ -244,9 +243,9 @@ public void createRadioButtonAddToGroupGroupContainsOneRadioButton() { radioGroup.addKid(radioAnnotation); form.addField(radioGroup); //In the previous implementation the radio buttons got added as kids, we want to avoid this - Assert.assertNull(radioGroup.getKids()); + Assertions.assertNull(radioGroup.getKids()); // It should now contain one single radio button - Assert.assertEquals(1, radioGroup.getWidgets().size()); + Assertions.assertEquals(1, radioGroup.getWidgets().size()); } } @@ -262,9 +261,9 @@ private static void compareRadioButtons(PdfFormAnnotation radioButtonFormField, // if a rectangle is assigned in the builder than we should check it if (radioButtonFormField.getWidget().getRectangle() != null && radioButtonFormField.getWidget().getRectangle().toRectangle() != null) { - Assert.assertEquals(1, widgets.size()); + Assertions.assertEquals(1, widgets.size()); PdfWidgetAnnotation annotation = widgets.get(0); - Assert.assertTrue(DUMMY_RECTANGLE.equalsWithEpsilon(annotation.getRectangle().toRectangle())); + Assertions.assertTrue(DUMMY_RECTANGLE.equalsWithEpsilon(annotation.getRectangle().toRectangle())); putIfAbsent(expectedDictionary, PdfName.Rect, new PdfArray(DUMMY_RECTANGLE)); // if the radiobutton has been added to the radiogroup we expect the AP to be generated @@ -273,9 +272,8 @@ private static void compareRadioButtons(PdfFormAnnotation radioButtonFormField, radioButtonFormField.getPdfObject().getAsDictionary(PdfName.AP)); } } - if (radioButtonFormField.pdfConformanceLevel != null) { - putIfAbsent(expectedDictionary, PdfName.F, - new PdfNumber(PdfAnnotation.PRINT)); + if (radioButtonFormField.pdfConformance != null && radioButtonFormField.pdfConformance.isPdfAOrUa()) { + putIfAbsent(expectedDictionary, PdfName.F, new PdfNumber(PdfAnnotation.PRINT)); } // for the AS key if it's added to the group we expect it to be off or the value if the radiogroup was selected // if its was not added we expect it to be the value @@ -296,7 +294,7 @@ private static void compareRadioButtons(PdfFormAnnotation radioButtonFormField, expectedDictionary.makeIndirect(DUMMY_DOCUMENT); radioButtonFormField.makeIndirect(DUMMY_DOCUMENT); - Assert.assertNull(new CompareTool().compareDictionariesStructure( + Assertions.assertNull(new CompareTool().compareDictionariesStructure( expectedDictionary, radioButtonFormField.getPdfObject())); } diff --git a/forms/src/test/java/com/itextpdf/forms/fields/SignatureFormFieldBuilderTest.java b/forms/src/test/java/com/itextpdf/forms/fields/SignatureFormFieldBuilderTest.java index 76f6c524cb..68f3701429 100644 --- a/forms/src/test/java/com/itextpdf/forms/fields/SignatureFormFieldBuilderTest.java +++ b/forms/src/test/java/com/itextpdf/forms/fields/SignatureFormFieldBuilderTest.java @@ -23,8 +23,8 @@ This file is part of the iText (R) project. package com.itextpdf.forms.fields; import com.itextpdf.kernel.geom.Rectangle; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; import com.itextpdf.kernel.pdf.PdfArray; +import com.itextpdf.kernel.pdf.PdfConformance; import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfName; @@ -34,15 +34,14 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.annot.PdfWidgetAnnotation; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; import java.io.ByteArrayOutputStream; import java.util.List; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(UnitTest.class) +@Tag("UnitTest") public class SignatureFormFieldBuilderTest extends ExtendedITextTest { private static final PdfDocument DUMMY_DOCUMENT = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); @@ -53,8 +52,8 @@ public class SignatureFormFieldBuilderTest extends ExtendedITextTest { public void constructorTest() { SignatureFormFieldBuilder builder = new SignatureFormFieldBuilder(DUMMY_DOCUMENT, DUMMY_NAME); - Assert.assertSame(DUMMY_DOCUMENT, builder.getDocument()); - Assert.assertSame(DUMMY_NAME, builder.getFormFieldName()); + Assertions.assertSame(DUMMY_DOCUMENT, builder.getDocument()); + Assertions.assertSame(DUMMY_NAME, builder.getFormFieldName()); } @Test @@ -76,7 +75,7 @@ public void createSignatureWithoutWidgetTest() { @Test public void createSignatureWithConformanceLevelTest() { PdfSignatureFormField signatureFormField = new SignatureFormFieldBuilder(DUMMY_DOCUMENT, DUMMY_NAME) - .setWidgetRectangle(DUMMY_RECTANGLE).setGenericConformanceLevel(PdfAConformanceLevel.PDF_A_1A) + .setWidgetRectangle(DUMMY_RECTANGLE).setConformance(PdfConformance.PDF_A_1A) .createSignature(); compareSignatures(signatureFormField, true); @@ -88,17 +87,17 @@ private static void compareSignatures(PdfSignatureFormField signatureFormField, List widgets = signatureFormField.getWidgets(); if (widgetExpected) { - Assert.assertEquals(1, widgets.size()); + Assertions.assertEquals(1, widgets.size()); PdfWidgetAnnotation annotation = widgets.get(0); - Assert.assertTrue(DUMMY_RECTANGLE.equalsWithEpsilon(annotation.getRectangle().toRectangle())); + Assertions.assertTrue(DUMMY_RECTANGLE.equalsWithEpsilon(annotation.getRectangle().toRectangle())); PdfArray kids = new PdfArray(); kids.add(annotation.getPdfObject()); putIfAbsent(expectedDictionary, PdfName.Kids, kids); } else { - Assert.assertEquals(0, widgets.size()); + Assertions.assertEquals(0, widgets.size()); } putIfAbsent(expectedDictionary, PdfName.FT, PdfName.Sig); @@ -106,7 +105,7 @@ private static void compareSignatures(PdfSignatureFormField signatureFormField, expectedDictionary.makeIndirect(DUMMY_DOCUMENT); signatureFormField.makeIndirect(DUMMY_DOCUMENT); - Assert.assertNull( + Assertions.assertNull( new CompareTool().compareDictionariesStructure(expectedDictionary, signatureFormField.getPdfObject())); } diff --git a/forms/src/test/java/com/itextpdf/forms/fields/TerminalFormFieldBuilderTest.java b/forms/src/test/java/com/itextpdf/forms/fields/TerminalFormFieldBuilderTest.java index ebe6a74a01..fd6e1ed8ec 100644 --- a/forms/src/test/java/com/itextpdf/forms/fields/TerminalFormFieldBuilderTest.java +++ b/forms/src/test/java/com/itextpdf/forms/fields/TerminalFormFieldBuilderTest.java @@ -28,14 +28,12 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfPage; import com.itextpdf.kernel.pdf.PdfWriter; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; - +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.ByteArrayOutputStream; -@Category(UnitTest.class) +@Tag("UnitTest") public class TerminalFormFieldBuilderTest extends ExtendedITextTest { private static final PdfDocument DUMMY_DOCUMENT = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); @@ -46,8 +44,8 @@ public class TerminalFormFieldBuilderTest extends ExtendedITextTest { public void constructorTest() { TestBuilder builder = new TestBuilder(DUMMY_DOCUMENT, DUMMY_NAME); - Assert.assertSame(DUMMY_DOCUMENT, builder.getDocument()); - Assert.assertSame(DUMMY_NAME, builder.getFormFieldName()); + Assertions.assertSame(DUMMY_DOCUMENT, builder.getDocument()); + Assertions.assertSame(DUMMY_NAME, builder.getFormFieldName()); } @Test @@ -55,7 +53,7 @@ public void getSetWidgetTest() { TestBuilder builder = new TestBuilder(DUMMY_DOCUMENT, DUMMY_NAME); builder.setWidgetRectangle(DUMMY_RECTANGLE); - Assert.assertSame(DUMMY_RECTANGLE, builder.getWidgetRectangle()); + Assertions.assertSame(DUMMY_RECTANGLE, builder.getWidgetRectangle()); } @Test @@ -64,11 +62,11 @@ public void getSetPageTest() { PdfPage page = DUMMY_DOCUMENT.addNewPage(); builder.setPage(page); - Assert.assertEquals(1, builder.getPage()); + Assertions.assertEquals(1, builder.getPage()); builder.setPage(5); - Assert.assertEquals(5, builder.getPage()); + Assertions.assertEquals(5, builder.getPage()); } @Test @@ -79,7 +77,7 @@ public void setPageToFieldTest() { PdfFormAnnotation formFieldAnnot = new PdfFormAnnotation((PdfDictionary)new PdfDictionary().makeIndirect(DUMMY_DOCUMENT)) { @Override public PdfFormAnnotation setPage(int pageNum) { - Assert.assertEquals(5, pageNum); + Assertions.assertEquals(5, pageNum); return this; } }; diff --git a/forms/src/test/java/com/itextpdf/forms/fields/TextFormFieldBuilderTest.java b/forms/src/test/java/com/itextpdf/forms/fields/TextFormFieldBuilderTest.java index 9a4b3b28ae..1c68af8970 100644 --- a/forms/src/test/java/com/itextpdf/forms/fields/TextFormFieldBuilderTest.java +++ b/forms/src/test/java/com/itextpdf/forms/fields/TextFormFieldBuilderTest.java @@ -23,8 +23,8 @@ This file is part of the iText (R) project. package com.itextpdf.forms.fields; import com.itextpdf.kernel.geom.Rectangle; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; import com.itextpdf.kernel.pdf.PdfArray; +import com.itextpdf.kernel.pdf.PdfConformance; import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfName; @@ -35,15 +35,14 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.annot.PdfWidgetAnnotation; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; import java.io.ByteArrayOutputStream; import java.util.List; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(UnitTest.class) +@Tag("UnitTest") public class TextFormFieldBuilderTest extends ExtendedITextTest { private static final PdfDocument DUMMY_DOCUMENT = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); private static final String DUMMY_NAME = "dummy name"; @@ -53,8 +52,8 @@ public class TextFormFieldBuilderTest extends ExtendedITextTest { public void constructorTest() { TextFormFieldBuilder builder = new TextFormFieldBuilder(DUMMY_DOCUMENT, DUMMY_NAME); - Assert.assertSame(DUMMY_DOCUMENT, builder.getDocument()); - Assert.assertSame(DUMMY_NAME, builder.getFormFieldName()); + Assertions.assertSame(DUMMY_DOCUMENT, builder.getDocument()); + Assertions.assertSame(DUMMY_NAME, builder.getFormFieldName()); } @Test @@ -81,7 +80,7 @@ public void createTextWithoutWidgetTest() { @Test public void createTextWithConformanceLevelTest() { PdfTextFormField textFormField = new TextFormFieldBuilder(DUMMY_DOCUMENT, DUMMY_NAME) - .setWidgetRectangle(DUMMY_RECTANGLE).setGenericConformanceLevel(PdfAConformanceLevel.PDF_A_1A).createText(); + .setWidgetRectangle(DUMMY_RECTANGLE).setConformance(PdfConformance.PDF_A_1A).createText(); PdfDictionary expectedDictionary = new PdfDictionary(); expectedDictionary.put(PdfName.Ff, new PdfNumber(0)); @@ -113,7 +112,7 @@ public void createMultilineTextWithoutWidgetTest() { @Test public void createMultilineTextWithConformanceLevelTest() { PdfTextFormField textFormField = new TextFormFieldBuilder(DUMMY_DOCUMENT, DUMMY_NAME) - .setWidgetRectangle(DUMMY_RECTANGLE).setGenericConformanceLevel(PdfAConformanceLevel.PDF_A_1A) + .setWidgetRectangle(DUMMY_RECTANGLE).setConformance(PdfConformance.PDF_A_1A) .createMultilineText(); PdfDictionary expectedDictionary = new PdfDictionary(); @@ -127,17 +126,17 @@ private static void compareTexts(PdfDictionary expectedDictionary, List widgets = textFormField.getWidgets(); if (widgetExpected) { - Assert.assertEquals(1, widgets.size()); + Assertions.assertEquals(1, widgets.size()); PdfWidgetAnnotation annotation = widgets.get(0); - Assert.assertTrue(DUMMY_RECTANGLE.equalsWithEpsilon(annotation.getRectangle().toRectangle())); + Assertions.assertTrue(DUMMY_RECTANGLE.equalsWithEpsilon(annotation.getRectangle().toRectangle())); PdfArray kids = new PdfArray(); kids.add(annotation.getPdfObject()); putIfAbsent(expectedDictionary, PdfName.Kids, kids); } else { - Assert.assertEquals(0, widgets.size()); + Assertions.assertEquals(0, widgets.size()); } putIfAbsent(expectedDictionary, PdfName.FT, PdfName.Tx); @@ -147,7 +146,7 @@ private static void compareTexts(PdfDictionary expectedDictionary, expectedDictionary.makeIndirect(DUMMY_DOCUMENT); textFormField.makeIndirect(DUMMY_DOCUMENT); - Assert.assertNull( + Assertions.assertNull( new CompareTool().compareDictionariesStructure(expectedDictionary, textFormField.getPdfObject())); } diff --git a/forms/src/test/java/com/itextpdf/forms/fields/merging/OnDuplicateFormFieldNameStrategyTest.java b/forms/src/test/java/com/itextpdf/forms/fields/merging/OnDuplicateFormFieldNameStrategyTest.java index 6a04555bef..7b5e081c4b 100644 --- a/forms/src/test/java/com/itextpdf/forms/fields/merging/OnDuplicateFormFieldNameStrategyTest.java +++ b/forms/src/test/java/com/itextpdf/forms/fields/merging/OnDuplicateFormFieldNameStrategyTest.java @@ -45,22 +45,21 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.ByteArrayOutputStream; import java.io.IOException; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class OnDuplicateFormFieldNameStrategyTest extends ExtendedITextTest { private final static String DESTINATION_FOLDER = "./target/test/com/itextpdf/forms/merging/"; private final static String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/forms/merging/"; - @Before + @BeforeEach public void setUp() { createDestinationFolder(DESTINATION_FOLDER); } @@ -74,7 +73,7 @@ public void alwaysThrowExceptionOnDuplicateFormFieldName01() { form.addField(field1); PdfButtonFormField field2 = new CheckBoxFormFieldBuilder(pdfDocument, "test").createCheckBox(); - Assert.assertThrows(PdfException.class, () -> form.addField(field2)); + Assertions.assertThrows(PdfException.class, () -> form.addField(field2)); pdfDocument.close(); } @@ -86,8 +85,8 @@ public void alwaysThrowExceptionOnDuplicateFormFieldName02() { form.addField(new CheckBoxFormFieldBuilder(pdfDocument, "test").createCheckBox()); form.addField(new CheckBoxFormFieldBuilder(pdfDocument, "test1").createCheckBox()); - Assert.assertNotNull(form.getField("test")); - Assert.assertNotNull(form.getField("test1")); + Assertions.assertNotNull(form.getField("test")); + Assertions.assertNotNull(form.getField("test1")); pdfDocument.close(); } @@ -117,13 +116,13 @@ public void incrementFieldNameEven() throws IOException, InterruptedException { PdfFormField field3 = form.getField("test_1"); PdfFormField field4 = form.getField("bingbong_1"); - Assert.assertNotNull(field1); - Assert.assertNotNull(field2); - Assert.assertNotNull(field3); - Assert.assertNotNull(field4); + Assertions.assertNotNull(field1); + Assertions.assertNotNull(field2); + Assertions.assertNotNull(field3); + Assertions.assertNotNull(field4); } - Assert.assertNull(new CompareTool().compareByContent(destination, + Assertions.assertNull(new CompareTool().compareByContent(destination, SOURCE_FOLDER + "cmp_incrementalFieldNameEven.pdf", DESTINATION_FOLDER, "diff_")); } @@ -153,10 +152,10 @@ public void testAddFormFieldWithoutConfiguration() throws IOException, Interrupt field1.addKid(child1); field1.addKid(child2); PdfAcroForm.getAcroForm(pdfDocument, true).addField(field1); - Assert.assertEquals(2, field1.getKids().size()); + Assertions.assertEquals(2, field1.getKids().size()); } - Assert.assertNull(new CompareTool().compareByContent(destination, + Assertions.assertNull(new CompareTool().compareByContent(destination, SOURCE_FOLDER + "cmp_testAddFormFieldWithoutConfiguration.pdf", DESTINATION_FOLDER, "diff_")); } @@ -190,16 +189,16 @@ public void incrementFieldNameUnEven() throws IOException, InterruptedException PdfFormField field5 = form.getField("test_2"); PdfFormField field6 = form.getField("bingbong_2"); - Assert.assertNotNull(field1); - Assert.assertNotNull(field2); - Assert.assertNotNull(field3); - Assert.assertNotNull(field4); - Assert.assertNotNull(field5); - Assert.assertNotNull(field6); + Assertions.assertNotNull(field1); + Assertions.assertNotNull(field2); + Assertions.assertNotNull(field3); + Assertions.assertNotNull(field4); + Assertions.assertNotNull(field5); + Assertions.assertNotNull(field6); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(destination, + Assertions.assertNull(new CompareTool().compareByContent(destination, SOURCE_FOLDER + "cmp_incrementFieldNameUnEven.pdf", DESTINATION_FOLDER, "diff_")); } @@ -208,7 +207,7 @@ public void incrementFieldNameUnEven() throws IOException, InterruptedException public void addIndexDotOperatorThrowsException() { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try (PdfDocument pdfDocument = new PdfDocument(new PdfWriter(baos))) { - Assert.assertThrows(IllegalArgumentException.class, () -> { + Assertions.assertThrows(IllegalArgumentException.class, () -> { PdfAcroForm form = PdfAcroForm.getAcroForm(pdfDocument, true, new AddIndexStrategy(".")); }); } @@ -218,7 +217,7 @@ public void addIndexDotOperatorThrowsException() { public void addIndexNullOperatorThrowsException() { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try (PdfDocument pdfDocument = new PdfDocument(new PdfWriter(baos))) { - Assert.assertThrows(IllegalArgumentException.class, () -> { + Assertions.assertThrows(IllegalArgumentException.class, () -> { PdfAcroForm form = PdfAcroForm.getAcroForm(pdfDocument, true, new AddIndexStrategy(null)); }); } @@ -227,7 +226,7 @@ public void addIndexNullOperatorThrowsException() { @Test public void invalidParamsToExecuteNull() { - Assert.assertFalse(new AddIndexStrategy().execute(null, null, false)); + Assertions.assertFalse(new AddIndexStrategy().execute(null, null, false)); } @Test @@ -254,10 +253,10 @@ public void flattenReadOnlyAddIndexTo() throws IOException, InterruptedException } int amount = form.getAllFormFields().size(); pdfDoc.close(); - Assert.assertTrue(isReadOnly); - Assert.assertEquals(4, amount); + Assertions.assertTrue(isReadOnly); + Assertions.assertEquals(4, amount); - Assert.assertNull(new CompareTool().compareByContent(destination, + Assertions.assertNull(new CompareTool().compareByContent(destination, SOURCE_FOLDER + "cmp_flattenReadOnlyAddIndexTo.pdf", DESTINATION_FOLDER, "diff_")); } @@ -283,7 +282,7 @@ public PdfAcroForm getAcroForm(PdfDocument document, boolean createIfNotExist) { doc.add(new CheckBox("test").setInteractive(true)); } - Assert.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + "add_index.pdf", + Assertions.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + "add_index.pdf", SOURCE_FOLDER + "cmp_add_index.pdf", DESTINATION_FOLDER, "diff_")); } finally { diff --git a/forms/src/test/java/com/itextpdf/forms/form/element/AccessibleElementTest.java b/forms/src/test/java/com/itextpdf/forms/form/element/AccessibleElementTest.java index 254af5403b..f099580e94 100644 --- a/forms/src/test/java/com/itextpdf/forms/form/element/AccessibleElementTest.java +++ b/forms/src/test/java/com/itextpdf/forms/form/element/AccessibleElementTest.java @@ -22,7 +22,6 @@ This file is part of the iText (R) project. */ package com.itextpdf.forms.form.element; -import com.itextpdf.forms.form.FormProperty; import com.itextpdf.io.source.ByteArrayOutputStream; import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.kernel.pdf.PdfDocument; @@ -35,30 +34,19 @@ This file is part of the iText (R) project. import com.itextpdf.layout.element.IBlockElement; import com.itextpdf.layout.tagging.IAccessibleElement; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.function.Supplier; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; -@Category(IntegrationTest.class) -@RunWith(Parameterized.class) +@Tag("IntegrationTest") public class AccessibleElementTest extends ExtendedITextTest { - private final TestContainer testContainer; - - public AccessibleElementTest(TestContainer index) { - this.testContainer = index; - } - - - @Parameterized.Parameters(name = "{0}") public static Collection getDataTestFixtureData() { int amountOfEntries = 8; List data = new ArrayList<>(); @@ -68,8 +56,8 @@ public static Collection getDataTestFixtureData() { return data; } - private Supplier getDataToTest(int index){ - switch (index){ + private Supplier getDataToTest(int index) { + switch (index) { case 0: return () -> new InputField("inputField"); case 1: @@ -97,8 +85,9 @@ private Supplier getDataToTest(int index){ } } - @Test - public void testInteractive() { + @ParameterizedTest(name = "{0}") + @MethodSource("getDataTestFixtureData") + public void testInteractive(TestContainer testContainer) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PdfDocument pdfDocument = new PdfDocument(new PdfWriter(baos)); pdfDocument.setTagged(); @@ -116,15 +105,16 @@ public void testInteractive() { IStructureNode kid = documentStruct.getKids().get(0); PdfStructElem elem = (PdfStructElem) kid; PdfDictionary obj = elem.getPdfObject(); - Assert.assertEquals(PdfName.Form, elem.getRole()); - Assert.assertTrue(obj.containsKey(PdfName.Lang)); - Assert.assertEquals("en", obj.getAsString(PdfName.Lang).getValue()); + Assertions.assertEquals(PdfName.Form, elem.getRole()); + Assertions.assertTrue(obj.containsKey(PdfName.Lang)); + Assertions.assertEquals("en", obj.getAsString(PdfName.Lang).getValue()); document.close(); pdfDocument.close(); } - @Test - public void testNonInteractive() { + @ParameterizedTest(name = "{0}") + @MethodSource("getDataTestFixtureData") + public void testNonInteractive(TestContainer testContainer) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PdfDocument pdfDocument = new PdfDocument(new PdfWriter(baos)); pdfDocument.setTagged(); @@ -141,15 +131,16 @@ public void testNonInteractive() { IStructureNode kid = documentStruct.getKids().get(0); PdfStructElem elem = (PdfStructElem) kid; PdfDictionary obj = elem.getPdfObject(); - Assert.assertEquals(PdfName.Form, elem.getRole()); - Assert.assertTrue(obj.containsKey(PdfName.Lang)); - Assert.assertEquals("en", obj.getAsString(PdfName.Lang).getValue()); + Assertions.assertEquals(PdfName.Form, elem.getRole()); + Assertions.assertTrue(obj.containsKey(PdfName.Lang)); + Assertions.assertEquals("en", obj.getAsString(PdfName.Lang).getValue()); document.close(); pdfDocument.close(); } - @Test - public void testInteractiveProperty() { + @ParameterizedTest(name = "{0}") + @MethodSource("getDataTestFixtureData") + public void testInteractiveProperty(TestContainer testContainer) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PdfDocument pdfDocument = new PdfDocument(new PdfWriter(baos)); pdfDocument.setTagged(); @@ -157,9 +148,10 @@ public void testInteractiveProperty() { IFormField element = getDataToTest(testContainer.index).get(); - element.setProperty(FormProperty.FORM_ACCESSIBILITY_LANGUAGE, "en"); IFormField formField = (IFormField) element; formField.setInteractive(true); + IAccessibleElement accessibleElement = (IAccessibleElement) formField; + accessibleElement.getAccessibilityProperties().setLanguage("en"); document.add((IBlockElement) element); @@ -168,9 +160,9 @@ public void testInteractiveProperty() { IStructureNode kid = documentStruct.getKids().get(0); PdfStructElem elem = (PdfStructElem) kid; PdfDictionary obj = elem.getPdfObject(); - Assert.assertEquals(PdfName.Form, elem.getRole()); - Assert.assertTrue(obj.containsKey(PdfName.Lang)); - Assert.assertEquals("en", obj.getAsString(PdfName.Lang).getValue()); + Assertions.assertEquals(PdfName.Form, elem.getRole()); + Assertions.assertTrue(obj.containsKey(PdfName.Lang)); + Assertions.assertEquals("en", obj.getAsString(PdfName.Lang).getValue()); document.close(); pdfDocument.close(); } @@ -185,7 +177,7 @@ public TestContainer(int index) { @Override public String toString() { - switch (index){ + switch (index) { case 0: return "InputField"; case 1: diff --git a/forms/src/test/java/com/itextpdf/forms/form/element/ButtonColorTest.java b/forms/src/test/java/com/itextpdf/forms/form/element/ButtonColorTest.java index efd224c394..9043595f60 100644 --- a/forms/src/test/java/com/itextpdf/forms/form/element/ButtonColorTest.java +++ b/forms/src/test/java/com/itextpdf/forms/form/element/ButtonColorTest.java @@ -34,16 +34,14 @@ This file is part of the iText (R) project. import com.itextpdf.layout.properties.Property; import com.itextpdf.layout.properties.TransparentColor; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; - +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.FileOutputStream; import java.io.IOException; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class ButtonColorTest extends ExtendedITextTest { public static final String SOURCE_FOLDER = @@ -51,7 +49,7 @@ public class ButtonColorTest extends ExtendedITextTest { public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/forms/form/element/ButtonColorTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(DESTINATION_FOLDER); } @@ -90,6 +88,6 @@ private static void drawButtons(String outPdf, String cmpPdf, Color color) throw document.add(inputButton); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } } diff --git a/forms/src/test/java/com/itextpdf/forms/form/element/ButtonTest.java b/forms/src/test/java/com/itextpdf/forms/form/element/ButtonTest.java index aa15dfd811..36de71bbf3 100644 --- a/forms/src/test/java/com/itextpdf/forms/form/element/ButtonTest.java +++ b/forms/src/test/java/com/itextpdf/forms/form/element/ButtonTest.java @@ -55,22 +55,21 @@ This file is part of the iText (R) project. import com.itextpdf.layout.properties.UnitValue; import com.itextpdf.layout.properties.VerticalAlignment; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class ButtonTest extends ExtendedITextTest { public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/forms/form/element/ButtonTest/"; public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/forms/form/element/ButtonTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(DESTINATION_FOLDER); } @@ -82,7 +81,7 @@ public void basicButtonTest() throws IOException, InterruptedException { try (Document document = new Document(new PdfDocument(new PdfWriter(outPdf)))) { Button formButton = new Button("form button"); - formButton.setProperty(FormProperty.FORM_FIELD_FLATTEN, false); + formButton.setProperty(FormProperty.FORM_FIELD_FLATTEN, Boolean.FALSE); formButton.add(new Paragraph("form button")); formButton.add(new Paragraph("paragraph with yellow border inside button") .setBorder(new SolidBorder(ColorConstants.YELLOW, 1))); @@ -91,14 +90,14 @@ public void basicButtonTest() throws IOException, InterruptedException { document.add(new Paragraph("")); Button flattenButton = new Button("flatten button"); - flattenButton.setProperty(FormProperty.FORM_FIELD_FLATTEN, true); + flattenButton.setProperty(FormProperty.FORM_FIELD_FLATTEN, Boolean.TRUE); flattenButton.add(new Paragraph("flatten button")); flattenButton.add(new Paragraph("paragraph with pink border inside button") .setBorder(new SolidBorder(ColorConstants.PINK, 1))); document.add(flattenButton); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -109,7 +108,7 @@ public void basicButtonTestWithFontDiffersOnParagraph() throws IOException, Inte try (Document document = new Document(new PdfDocument(new PdfWriter(outPdf)))) { Button formButton = new Button("form button"); - formButton.setProperty(FormProperty.FORM_FIELD_FLATTEN, false); + formButton.setProperty(FormProperty.FORM_FIELD_FLATTEN, Boolean.FALSE); formButton.setFont(PdfFontFactory.createFont(StandardFonts.HELVETICA_BOLD)); formButton.add(new Paragraph("form button")); formButton.add(new Paragraph("paragraph with yellow border inside button") @@ -120,7 +119,7 @@ public void basicButtonTestWithFontDiffersOnParagraph() throws IOException, Inte document.add(new Paragraph("")); Button flattenButton = new Button("flatten button"); - flattenButton.setProperty(FormProperty.FORM_FIELD_FLATTEN, true); + flattenButton.setProperty(FormProperty.FORM_FIELD_FLATTEN, Boolean.TRUE); flattenButton.add(new Paragraph("flatten button")); flattenButton.setFont(PdfFontFactory.createFont(StandardFonts.HELVETICA_BOLD)); @@ -130,7 +129,7 @@ public void basicButtonTestWithFontDiffersOnParagraph() throws IOException, Inte document.add(flattenButton); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -141,7 +140,7 @@ public void basicButtonTestWithFont() throws IOException, InterruptedException { try (Document document = new Document(new PdfDocument(new PdfWriter(outPdf)))) { Button formButton = new Button("form button"); - formButton.setProperty(FormProperty.FORM_FIELD_FLATTEN, false); + formButton.setProperty(FormProperty.FORM_FIELD_FLATTEN, Boolean.FALSE); formButton.setFont(PdfFontFactory.createFont(StandardFonts.HELVETICA_BOLD)); formButton.add(new Paragraph("form button")); formButton.add(new Paragraph("paragraph with yellow border inside button") @@ -151,7 +150,7 @@ public void basicButtonTestWithFont() throws IOException, InterruptedException { document.add(new Paragraph("")); Button flattenButton = new Button("flatten button"); - flattenButton.setProperty(FormProperty.FORM_FIELD_FLATTEN, true); + flattenButton.setProperty(FormProperty.FORM_FIELD_FLATTEN, Boolean.TRUE); flattenButton.add(new Paragraph("flatten button")); flattenButton.setFont(PdfFontFactory.createFont(StandardFonts.HELVETICA_BOLD)); @@ -160,7 +159,7 @@ public void basicButtonTestWithFont() throws IOException, InterruptedException { document.add(flattenButton); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -170,7 +169,7 @@ public void customizedButtonTest() throws IOException, InterruptedException { try (Document document = new Document(new PdfDocument(new PdfWriter(outPdf)))) { Button formButton = new Button("form button"); - formButton.setProperty(FormProperty.FORM_FIELD_FLATTEN, false); + formButton.setProperty(FormProperty.FORM_FIELD_FLATTEN, Boolean.FALSE); formButton.setValue("form button"); formButton.setFontColor(ColorConstants.BLUE); formButton.setBackgroundColor(ColorConstants.YELLOW); @@ -180,7 +179,7 @@ public void customizedButtonTest() throws IOException, InterruptedException { document.add(new Paragraph("")); Button flattenButton = new Button("flatten button"); - flattenButton.setProperty(FormProperty.FORM_FIELD_FLATTEN, true); + flattenButton.setProperty(FormProperty.FORM_FIELD_FLATTEN, Boolean.TRUE); flattenButton.setValue("flatten button"); flattenButton.setFontColor(ColorConstants.BLUE); flattenButton.setBackgroundColor(ColorConstants.YELLOW); @@ -188,7 +187,7 @@ public void customizedButtonTest() throws IOException, InterruptedException { document.add(flattenButton); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -198,14 +197,14 @@ public void buttonVerticalAlignmentTest() throws IOException, InterruptedExcepti try (Document document = new Document(new PdfDocument(new PdfWriter(outPdf)))) { Button formButton = new Button("form button"); - formButton.setProperty(FormProperty.FORM_FIELD_FLATTEN, false); + formButton.setProperty(FormProperty.FORM_FIELD_FLATTEN, Boolean.FALSE); formButton.setValue("capture on bottom"); formButton.setProperty(Property.VERTICAL_ALIGNMENT, VerticalAlignment.BOTTOM); formButton.setProperty(Property.HEIGHT, UnitValue.createPointValue(100)); document.add(formButton); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -217,7 +216,7 @@ public void addButtonInTwoWaysTest() throws IOException, InterruptedException { try (Document document = new Document(new PdfDocument(new PdfWriter(outPdf)))) { // Create push button using html element Button formButton = new Button("button"); - formButton.setProperty(FormProperty.FORM_FIELD_FLATTEN, false); + formButton.setProperty(FormProperty.FORM_FIELD_FLATTEN, Boolean.FALSE); formButton.setProperty(Property.WIDTH, UnitValue.createPointValue(100)); formButton.setProperty(Property.HEIGHT, UnitValue.createPointValue(100)); formButton.add(new Image(new PdfImageXObject(ImageDataFactory.create( @@ -240,7 +239,7 @@ public void addButtonInTwoWaysTest() throws IOException, InterruptedException { form.addField(button); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -286,7 +285,7 @@ public void borderBoxesTest() throws IOException, InterruptedException { document.add(flattenButton2); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -339,22 +338,22 @@ public void borderTypesTest() throws IOException, InterruptedException { document.add(button4); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test public void isFlattenTest() { Button button = new Button("button"); - button.setProperty(FormProperty.FORM_FIELD_FLATTEN, false); + button.setProperty(FormProperty.FORM_FIELD_FLATTEN, Boolean.FALSE); ButtonRenderer buttonRenderer = new ButtonRenderer(button); - Assert.assertFalse(buttonRenderer.isFlatten()); - button.setProperty(FormProperty.FORM_FIELD_FLATTEN, true); - Assert.assertTrue(buttonRenderer.isFlatten()); + Assertions.assertFalse(buttonRenderer.isFlatten()); + button.setProperty(FormProperty.FORM_FIELD_FLATTEN, Boolean.TRUE); + Assertions.assertTrue(buttonRenderer.isFlatten()); InputField inputField = new InputField("input"); - inputField.setProperty(FormProperty.FORM_FIELD_FLATTEN, false); + inputField.setProperty(FormProperty.FORM_FIELD_FLATTEN, Boolean.FALSE); button.add(inputField); buttonRenderer = (ButtonRenderer) button.createRendererSubTree(); - Assert.assertTrue(((InputFieldRenderer)buttonRenderer.getChildRenderers().get(0) + Assertions.assertTrue(((InputFieldRenderer)buttonRenderer.getChildRenderers().get(0) .setParent(buttonRenderer)).isFlatten()); } } diff --git a/forms/src/test/java/com/itextpdf/forms/form/element/CheckBoxTest.java b/forms/src/test/java/com/itextpdf/forms/form/element/CheckBoxTest.java index 0ea25c1cd5..6b147b9d32 100644 --- a/forms/src/test/java/com/itextpdf/forms/form/element/CheckBoxTest.java +++ b/forms/src/test/java/com/itextpdf/forms/form/element/CheckBoxTest.java @@ -36,7 +36,7 @@ This file is part of the iText (R) project. import com.itextpdf.io.util.EnumUtil; import com.itextpdf.kernel.colors.ColorConstants; import com.itextpdf.kernel.geom.Rectangle; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfConformance; import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfPage; import com.itextpdf.kernel.pdf.PdfReader; @@ -55,7 +55,6 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -64,24 +63,24 @@ This file is part of the iText (R) project. import java.util.List; import java.util.Map.Entry; import java.util.function.Consumer; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class CheckBoxTest extends ExtendedITextTest { public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/forms/form/element/CheckBoxTest/"; public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/forms/form/element/CheckBoxTest/"; private int counter = 0; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(DESTINATION_FOLDER); } - @Before + @BeforeEach public void before() { counter = 0; } @@ -91,7 +90,7 @@ public void before() { public void renderingModeDefaultValueTest() { CheckBox checkBoxPdf = new CheckBox("test"); CheckBoxRenderer rendererPdf = (CheckBoxRenderer) checkBoxPdf.getRenderer(); - Assert.assertEquals(RenderingMode.DEFAULT_LAYOUT_MODE, rendererPdf.getRenderingMode()); + Assertions.assertEquals(RenderingMode.DEFAULT_LAYOUT_MODE, rendererPdf.getRenderingMode()); } @Test @@ -99,13 +98,13 @@ public void setRenderingModeReturnsToDefaultMode() { CheckBox checkBoxPdf = new CheckBox("test"); checkBoxPdf.setProperty(Property.RENDERING_MODE, null); CheckBoxRenderer rendererPdf = (CheckBoxRenderer) checkBoxPdf.getRenderer(); - Assert.assertEquals(RenderingMode.DEFAULT_LAYOUT_MODE, rendererPdf.getRenderingMode()); + Assertions.assertEquals(RenderingMode.DEFAULT_LAYOUT_MODE, rendererPdf.getRenderingMode()); CheckBox checkBoxHtml = new CheckBox("test"); checkBoxHtml.setProperty(Property.RENDERING_MODE, RenderingMode.HTML_MODE); checkBoxHtml.setProperty(Property.RENDERING_MODE, null); CheckBoxRenderer rendererHtml = (CheckBoxRenderer) checkBoxHtml.getRenderer(); - Assert.assertEquals(RenderingMode.DEFAULT_LAYOUT_MODE, rendererHtml.getRenderingMode()); + Assertions.assertEquals(RenderingMode.DEFAULT_LAYOUT_MODE, rendererHtml.getRenderingMode()); } @Test @@ -113,18 +112,18 @@ public void setRenderingModeTest() { CheckBox checkBoxPdf = new CheckBox("test"); checkBoxPdf.setProperty(Property.RENDERING_MODE, RenderingMode.HTML_MODE); CheckBoxRenderer rendererPdf = (CheckBoxRenderer) checkBoxPdf.getRenderer(); - Assert.assertEquals(RenderingMode.HTML_MODE, rendererPdf.getRenderingMode()); + Assertions.assertEquals(RenderingMode.HTML_MODE, rendererPdf.getRenderingMode()); } @Test public void checkBoxSetCheckedTest() { CheckBox checkBox = new CheckBox("test"); CheckBoxRenderer renderer = (CheckBoxRenderer) checkBox.getRenderer(); - Assert.assertFalse(renderer.isBoxChecked()); + Assertions.assertFalse(renderer.isBoxChecked()); checkBox.setChecked(true); - Assert.assertTrue(renderer.isBoxChecked()); + Assertions.assertTrue(renderer.isBoxChecked()); checkBox.setChecked(false); - Assert.assertFalse(renderer.isBoxChecked()); + Assertions.assertFalse(renderer.isBoxChecked()); } @Test @@ -132,16 +131,16 @@ public void createCheckBoxFactoryDefaultPdfTest() { CheckBox checkBox = new CheckBox("test"); CheckBoxRenderer renderer = (CheckBoxRenderer) checkBox.getRenderer(); ICheckBoxRenderingStrategy strategy = renderer.createCheckBoxRenderStrategy(); - Assert.assertTrue(strategy instanceof PdfCheckBoxRenderingStrategy); + Assertions.assertTrue(strategy instanceof PdfCheckBoxRenderingStrategy); } @Test public void createCheckBoxFactoryPdfATest() { CheckBox checkBox = new CheckBox("test"); - checkBox.setPdfAConformanceLevel(PdfAConformanceLevel.PDF_A_1B); + checkBox.setPdfConformance(PdfConformance.PDF_A_1B); CheckBoxRenderer renderer = (CheckBoxRenderer) checkBox.getRenderer(); ICheckBoxRenderingStrategy strategy = renderer.createCheckBoxRenderStrategy(); - Assert.assertTrue(strategy instanceof PdfACheckBoxRenderingStrategy); + Assertions.assertTrue(strategy instanceof PdfACheckBoxRenderingStrategy); } @Test @@ -150,33 +149,17 @@ public void createCheckBoxFactoryHtmlTest() { checkBox.setProperty(Property.RENDERING_MODE, RenderingMode.HTML_MODE); CheckBoxRenderer renderer = (CheckBoxRenderer) checkBox.getRenderer(); ICheckBoxRenderingStrategy strategy = renderer.createCheckBoxRenderStrategy(); - Assert.assertTrue(strategy instanceof HtmlCheckBoxRenderingStrategy); + Assertions.assertTrue(strategy instanceof HtmlCheckBoxRenderingStrategy); } @Test public void createCheckBoxFactoryHtmlWithPdfATest() { CheckBox checkBox = new CheckBox("test"); checkBox.setProperty(Property.RENDERING_MODE, RenderingMode.HTML_MODE); - checkBox.setPdfAConformanceLevel(PdfAConformanceLevel.PDF_A_1B); + checkBox.setPdfConformance(PdfConformance.PDF_A_1B); CheckBoxRenderer renderer = (CheckBoxRenderer) checkBox.getRenderer(); ICheckBoxRenderingStrategy strategy = renderer.createCheckBoxRenderStrategy(); - Assert.assertTrue(strategy instanceof HtmlCheckBoxRenderingStrategy); - } - - @Test - public void isPdfATest() { - CheckBox checkBox = new CheckBox("test"); - - CheckBoxRenderer rendererPdf2 = (CheckBoxRenderer) checkBox.getRenderer(); - Assert.assertFalse(rendererPdf2.isPdfA()); - - checkBox.setPdfAConformanceLevel(PdfAConformanceLevel.PDF_A_1B); - CheckBoxRenderer rendererPdf = (CheckBoxRenderer) checkBox.getRenderer(); - Assert.assertTrue(rendererPdf.isPdfA()); - - checkBox.setPdfAConformanceLevel(null); - CheckBoxRenderer rendererPdf1 = (CheckBoxRenderer) checkBox.getRenderer(); - Assert.assertFalse(rendererPdf1.isPdfA()); + Assertions.assertTrue(strategy instanceof HtmlCheckBoxRenderingStrategy); } @Test @@ -193,8 +176,8 @@ public void checkBoxInHtmlModeKeeps1on1RatioAndTakesMaxValue() { UnitValue heightUnitValue = renderer.getPropertyAsUnitValue(Property.HEIGHT); UnitValue widthUnitValue = renderer.getPropertyAsUnitValue(Property.WIDTH); - Assert.assertEquals(height, heightUnitValue.getValue(), 0); - Assert.assertEquals(height, widthUnitValue.getValue(), 0); + Assertions.assertEquals(height, heightUnitValue.getValue(), 0); + Assertions.assertEquals(height, widthUnitValue.getValue(), 0); } @Test @@ -226,7 +209,7 @@ public void basicCheckBoxDrawingTestHtmlMode() throws IOException, InterruptedEx checkBoxsetAndInteractive.setInteractive(true); document.add(checkBoxsetAndInteractive); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -256,7 +239,7 @@ public void basicCheckBoxDrawingTestPdfMode() throws IOException, InterruptedExc document.add(checkBoxsetInteractive); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -265,25 +248,25 @@ public void basicCheckBoxDrawingTestPdfAMode() throws IOException, InterruptedEx String cmpPdf = SOURCE_FOLDER + "cmp_basicCheckBoxPdfA.pdf"; try (Document document = new Document(new PdfDocument(new PdfWriter(outPdf)))) { //should be invisble because there is no default border - CheckBox checkBoxUnset = new CheckBox("test").setPdfAConformanceLevel(PdfAConformanceLevel.PDF_A_1B); + CheckBox checkBoxUnset = new CheckBox("test").setPdfConformance(PdfConformance.PDF_A_1B); document.add(checkBoxUnset); - CheckBox checkBoxset = new CheckBox("test").setPdfAConformanceLevel(PdfAConformanceLevel.PDF_A_1B); + CheckBox checkBoxset = new CheckBox("test").setPdfConformance(PdfConformance.PDF_A_1B); checkBoxset.setChecked(true); document.add(checkBoxset); - CheckBox checkBoxUnsetInteractive = new CheckBox("test1").setPdfAConformanceLevel( - PdfAConformanceLevel.PDF_A_1B); + CheckBox checkBoxUnsetInteractive = new CheckBox("test1").setPdfConformance( + PdfConformance.PDF_A_1B); checkBoxUnsetInteractive.setInteractive(true); document.add(checkBoxUnsetInteractive); - CheckBox checkBoxsetInteractive = new CheckBox("test2").setPdfAConformanceLevel( - PdfAConformanceLevel.PDF_A_1B); + CheckBox checkBoxsetInteractive = new CheckBox("test2").setPdfConformance( + PdfConformance.PDF_A_1B); checkBoxsetInteractive.setInteractive(true); checkBoxsetInteractive.setChecked(true); document.add(checkBoxsetInteractive); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -299,7 +282,7 @@ public void basicCheckBoxSetSize() throws IOException, InterruptedException { }); } } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -316,7 +299,7 @@ public void basicCheckBoxSetSizeNegativeValueFallsBackToDefaultValue() throws IO checkBox.setSize(-1); }); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -336,7 +319,7 @@ public void basicCheckBoxSetBorderTest() throws IOException, InterruptedExceptio checkBox.setBorder(new SolidBorder(ColorConstants.BLUE, 3)); }); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -349,7 +332,7 @@ public void basicCheckBoxSetBackgroundTest() throws IOException, InterruptedExce checkBox.setBackgroundColor(ColorConstants.MAGENTA); }); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -375,7 +358,7 @@ public void setBorderTestSmallDefaultsToMinValue() throws IOException, Interrupt document.add(checkBox); } } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -389,12 +372,12 @@ public void checkBoxSetCheckTypes() throws IOException, InterruptedException { checkBox.setCheckBoxType(enumConstant); }); generateCheckBoxes(document, checkBox -> { - checkBox.setPdfAConformanceLevel(PdfAConformanceLevel.PDF_A_1B); + checkBox.setPdfConformance(PdfConformance.PDF_A_1B); checkBox.setCheckBoxType(enumConstant); }); } } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @@ -407,12 +390,12 @@ public void setPdfAConformanceLevel() throws IOException, InterruptedException { for (CheckBoxType enumConstant : EnumUtil.getAllValuesOfEnum(CheckBoxType.class)) { generateCheckBoxes(document, checkBox -> { checkBox.setSize(20); - checkBox.setPdfAConformanceLevel(PdfAConformanceLevel.PDF_A_3B); + checkBox.setPdfConformance(PdfConformance.PDF_A_3B); checkBox.setCheckBoxType(enumConstant); }); } } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -436,7 +419,7 @@ public void removingFormFieldsLeavesNoVisualTrace() throws IOException, Interrup } pdfDocument.close(); // all non flattend acroform fields should be removed - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -460,7 +443,7 @@ public void checkBoxWithMarginsTest() throws IOException, InterruptedException { document.add(div); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -506,7 +489,7 @@ public void borderBoxesTest() throws IOException, InterruptedException { document.add(flattenCheckBox2); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -538,7 +521,7 @@ public void addFieldWithTwoWidgetsTest() throws IOException, InterruptedExceptio document.add(checkBox2); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -561,7 +544,7 @@ public void multiPageCheckboxFieldTest() throws IOException, InterruptedExceptio } } } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } private void generateCheckBoxesForAllRenderingModes(Document document, Consumer alterFunction) { @@ -573,7 +556,7 @@ private void generateCheckBoxesForAllRenderingModes(Document document, Consumer< document.add(new Paragraph("Pdfa rendering mode")); generateCheckBoxes(document, (checkBox) -> { checkBox.setProperty(Property.RENDERING_MODE, RenderingMode.DEFAULT_LAYOUT_MODE); - checkBox.setPdfAConformanceLevel(PdfAConformanceLevel.PDF_A_1B); + checkBox.setPdfConformance(PdfConformance.PDF_A_1B); alterFunction.accept(checkBox); }); @@ -596,7 +579,40 @@ public void basicCheckBoxTagged() throws IOException, InterruptedException { generateCheckBoxes(document, checkBox -> { }); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + } + + @Test + public void setBordersTest() throws IOException, InterruptedException { + String outPdf = DESTINATION_FOLDER + "checkBoxSetBorders.pdf"; + String cmpPdf = SOURCE_FOLDER + "cmp_checkBoxSetBorders.pdf"; + try (Document document = new Document(new PdfDocument(new PdfWriter(outPdf)))) { + final Float[] i = {.1f, .2f, .3f, .4f}; + document.add(new Paragraph("Test different borders")); + for (int j = 0; j < 30; j++) { + i[0] += .03f; + i[1] += .05f; + i[2] += .07f; + i[3] += .09f; + CheckBox checkBox = new CheckBox("test" + j); + checkBox.setChecked(true); + checkBox.setSize(20); + if (j % 2 == 0) { + checkBox.setBorderRight(new SolidBorder(ColorConstants.GREEN, (float) i[0])); + } + if (j % 3 == 0) { + checkBox.setBorderLeft(new SolidBorder(ColorConstants.PINK, (float) i[1])); + } + if (j % 5 == 0 || j == 1 || j == 13 || j == 19 || j == 29) { + checkBox.setBorderTop(new SolidBorder(ColorConstants.CYAN, (float) i[2])); + } + if (j % 7 == 0 || j == 11 || j == 17 || j == 23) { + checkBox.setBorderBottom(new SolidBorder(ColorConstants.YELLOW, (float) i[3])); + } + document.add(checkBox); + } + } + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } private List generateCheckBoxes(Document document, Consumer alterFunction) { diff --git a/forms/src/test/java/com/itextpdf/forms/form/element/ComboBoxFieldTest.java b/forms/src/test/java/com/itextpdf/forms/form/element/ComboBoxFieldTest.java index 80610a7fa8..6d72e68f78 100644 --- a/forms/src/test/java/com/itextpdf/forms/form/element/ComboBoxFieldTest.java +++ b/forms/src/test/java/com/itextpdf/forms/form/element/ComboBoxFieldTest.java @@ -39,24 +39,23 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; import java.util.ArrayList; import java.util.List; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class ComboBoxFieldTest extends ExtendedITextTest { public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/forms/form/element/ComboBoxFieldTest/"; public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/forms/form/element/ComboBoxFieldTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(DESTINATION_FOLDER); } @@ -86,7 +85,7 @@ public void emptyComboBoxFieldTest() throws IOException, InterruptedException { document.add(comboBoxWithBorderAndBackgroundColor); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @@ -124,7 +123,7 @@ public void basicComboBoxFieldTest() throws IOException, InterruptedException { } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @@ -163,7 +162,7 @@ public void basicComboBoxFieldWithBordersTest() throws IOException, InterruptedE } } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -201,7 +200,7 @@ public void basicComboBoxFieldWithBackgroundTest() throws IOException, Interrupt } } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -212,7 +211,7 @@ public void comboBoxFieldWithoutSelectionTest() throws IOException, InterruptedE try (Document document = new Document(new PdfDocument(new PdfWriter(outPdf)))) { ComboBoxField flattenComboBoxFieldWithFont = new ComboBoxField("flatten combo box field with font"); - flattenComboBoxFieldWithFont.setProperty(FormProperty.FORM_FIELD_FLATTEN, true); + flattenComboBoxFieldWithFont.setProperty(FormProperty.FORM_FIELD_FLATTEN, Boolean.TRUE); flattenComboBoxFieldWithFont.setBackgroundColor(ColorConstants.RED); flattenComboBoxFieldWithFont.addOption(new SelectFieldItem("option 1")); flattenComboBoxFieldWithFont.addOption(new SelectFieldItem("option 2")); @@ -220,7 +219,7 @@ public void comboBoxFieldWithoutSelectionTest() throws IOException, InterruptedE ComboBoxField flattenComboBoxFieldWithPercentFont = new ComboBoxField( "flatten combo box field with percent font"); - flattenComboBoxFieldWithPercentFont.setProperty(FormProperty.FORM_FIELD_FLATTEN, true); + flattenComboBoxFieldWithPercentFont.setProperty(FormProperty.FORM_FIELD_FLATTEN, Boolean.TRUE); flattenComboBoxFieldWithPercentFont.setBackgroundColor(ColorConstants.RED); flattenComboBoxFieldWithPercentFont.addOption(new SelectFieldItem("option 1")); flattenComboBoxFieldWithPercentFont.addOption(new SelectFieldItem("option 2")); @@ -228,7 +227,7 @@ public void comboBoxFieldWithoutSelectionTest() throws IOException, InterruptedE document.add(flattenComboBoxFieldWithPercentFont); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -247,7 +246,7 @@ public void comboBoxFieldWithHeightTest() throws IOException, InterruptedExcepti document.add(flattenComboBoxField); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -265,7 +264,7 @@ public void comboBoxFieldWithMinHeightTest() throws IOException, InterruptedExce document.add(flattenComboBoxField); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -282,7 +281,7 @@ public void comboBoxFieldWithMaxHeightTest() throws IOException, InterruptedExce document.add(flattenComboBoxField); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -298,7 +297,7 @@ public void comboBoxFieldCannotFitTest() throws IOException, InterruptedExceptio document.add(div); ComboBoxField flattenComboBoxField = new ComboBoxField("flatten combo box cannot fit"); - flattenComboBoxField.setProperty(FormProperty.FORM_FIELD_FLATTEN, true); + flattenComboBoxField.setProperty(FormProperty.FORM_FIELD_FLATTEN, Boolean.TRUE); flattenComboBoxField.setBackgroundColor(ColorConstants.RED); flattenComboBoxField.addOption(new SelectFieldItem("option 1")); flattenComboBoxField.addOption(new SelectFieldItem("option 2")); @@ -306,7 +305,7 @@ public void comboBoxFieldCannotFitTest() throws IOException, InterruptedExceptio document.add(flattenComboBoxField); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -320,12 +319,11 @@ public void comboBoxFieldWithLangTest() throws IOException, InterruptedException flattenComboBoxField.addOption(new SelectFieldItem("option 2")); flattenComboBoxField.setSelected("option 1"); - //TODO DEVSIX-8205 Use setLanguage method from AccessibilityProperties - flattenComboBoxField.setProperty(FormProperty.FORM_ACCESSIBILITY_LANGUAGE, "random_lang"); + flattenComboBoxField.getAccessibilityProperties().setLanguage("random_lang"); document.add(flattenComboBoxField); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -356,7 +354,7 @@ public void setFontSizeTest() throws IOException, InterruptedException { document.add(flattenComboBoxFieldSelected); } } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -374,7 +372,7 @@ public void nonSelectedInHtml2PdfSelectsFirstTest() throws IOException, Interrup formComboBoxFieldSelected.addOption(new SelectFieldItem("option 2")); document.add(formComboBoxFieldSelected); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -405,7 +403,7 @@ public void setFontColorTest() throws IOException, InterruptedException { document.add(flattenComboBoxFieldSelected); } } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @@ -415,7 +413,7 @@ public void noneSelectedIsNullTest() { comboBoxField.addOption(new SelectFieldItem("option 1")); comboBoxField.addOption(new SelectFieldItem("option 2")); - Assert.assertNull(comboBoxField.getSelectedOption()); + Assertions.assertNull(comboBoxField.getSelectedOption()); } @Test @@ -426,8 +424,8 @@ public void setSelectedByExportValueTest() { comboBoxField.addOption(new SelectFieldItem("option 3")); comboBoxField.setSelected("option 1"); - Assert.assertEquals("option 1", comboBoxField.getSelectedOption().getDisplayValue()); - Assert.assertEquals("option 1", comboBoxField.getSelectedOption().getExportValue()); + Assertions.assertEquals("option 1", comboBoxField.getSelectedOption().getDisplayValue()); + Assertions.assertEquals("option 1", comboBoxField.getSelectedOption().getExportValue()); } @@ -439,7 +437,7 @@ public void setSelectedByDisplayValueTest() { comboBoxField.addOption(new SelectFieldItem("option 3", "3")); comboBoxField.setSelected("1"); - Assert.assertNull(comboBoxField.getSelectedOption()); + Assertions.assertNull(comboBoxField.getSelectedOption()); } @Test @@ -450,8 +448,8 @@ public void setSelectByDisplayValueTest() { comboBoxField.addOption(new SelectFieldItem("option 3", "3")); comboBoxField.setSelected("option 1"); - Assert.assertEquals("option 1", comboBoxField.getSelectedOption().getExportValue()); - Assert.assertEquals("1", comboBoxField.getSelectedOption().getDisplayValue()); + Assertions.assertEquals("option 1", comboBoxField.getSelectedOption().getExportValue()); + Assertions.assertEquals("1", comboBoxField.getSelectedOption().getDisplayValue()); } @Test @@ -462,8 +460,8 @@ public void setSelectedByIndexTest() { comboBoxField.addOption(new SelectFieldItem("option 3")); comboBoxField.setSelected(1); - Assert.assertEquals("option 2", comboBoxField.getSelectedOption().getDisplayValue()); - Assert.assertEquals("option 2", comboBoxField.getSelectedOption().getExportValue()); + Assertions.assertEquals("option 2", comboBoxField.getSelectedOption().getDisplayValue()); + Assertions.assertEquals("option 2", comboBoxField.getSelectedOption().getExportValue()); } @Test @@ -473,7 +471,7 @@ public void setSelectedByIndexOutOfBoundsTest() { comboBoxField.addOption(new SelectFieldItem("option 2")); comboBoxField.addOption(new SelectFieldItem("option 3")); - Assert.assertThrows(IndexOutOfBoundsException.class, () -> comboBoxField.setSelected(3)); + Assertions.assertThrows(IndexOutOfBoundsException.class, () -> comboBoxField.setSelected(3)); } @Test @@ -482,7 +480,7 @@ public void setSelectByIndexNegativeOutOfBoundsTest() { comboBoxField.addOption(new SelectFieldItem("option 1")); comboBoxField.addOption(new SelectFieldItem("option 2")); comboBoxField.addOption(new SelectFieldItem("option 3")); - Assert.assertThrows(IndexOutOfBoundsException.class, () -> comboBoxField.setSelected(-1)); + Assertions.assertThrows(IndexOutOfBoundsException.class, () -> comboBoxField.setSelected(-1)); } @Test @@ -494,8 +492,8 @@ public void setBySelectFieldItem() { comboBoxField.addOption(new SelectFieldItem("option 3", "3")); comboBoxField.setSelected(option1); - Assert.assertEquals("option 1", comboBoxField.getSelectedOption().getExportValue()); - Assert.assertEquals("1", comboBoxField.getSelectedOption().getDisplayValue()); + Assertions.assertEquals("option 1", comboBoxField.getSelectedOption().getExportValue()); + Assertions.assertEquals("1", comboBoxField.getSelectedOption().getDisplayValue()); } @Test @@ -505,7 +503,7 @@ public void setBySelectFieldItemNullTest() { comboBoxField.addOption(new SelectFieldItem("option 2", "2")); comboBoxField.setSelected((SelectFieldItem) null); - Assert.assertNull(comboBoxField.getSelectedOption()); + Assertions.assertNull(comboBoxField.getSelectedOption()); } @Test @@ -515,7 +513,7 @@ public void setBySelectFieldItemNotInOptionsTest() { comboBoxField.addOption(new SelectFieldItem("option 2", "2")); comboBoxField.setSelected(new SelectFieldItem("option 3", "3")); - Assert.assertNull(comboBoxField.getSelectedOption()); + Assertions.assertNull(comboBoxField.getSelectedOption()); } @Test @@ -526,7 +524,7 @@ public void addingOptionsWithSameExportValuesLogsWarningTest() { ComboBoxField comboBoxField = new ComboBoxField("test"); comboBoxField.addOption(new SelectFieldItem("option 1", "1")); comboBoxField.addOption(new SelectFieldItem("option 1", "2")); - Assert.assertEquals(2, comboBoxField.getItems().size()); + Assertions.assertEquals(2, comboBoxField.getOptions().size()); } @@ -535,13 +533,13 @@ public void addingWithDuplicateDisplayValueTest() { ComboBoxField comboBoxField = new ComboBoxField("test"); comboBoxField.addOption(new SelectFieldItem("option 1", "1")); comboBoxField.addOption(new SelectFieldItem("option 2", "1")); - Assert.assertEquals(2, comboBoxField.getItems().size()); + Assertions.assertEquals(2, comboBoxField.getOptions().size()); } @Test public void addingOptionWithNullExportValueTest() { ComboBoxField comboBoxField = new ComboBoxField("test"); - Assert.assertThrows(IllegalArgumentException.class, + Assertions.assertThrows(IllegalArgumentException.class, () -> comboBoxField.addOption(new SelectFieldItem("option 1", (String) null))); } @@ -580,7 +578,7 @@ public void basicComboBoxFieldTaggedTest() throws IOException, InterruptedExcept } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } diff --git a/forms/src/test/java/com/itextpdf/forms/form/element/FixedPositionTest.java b/forms/src/test/java/com/itextpdf/forms/form/element/FixedPositionTest.java index d9b7bcbf69..d8ad71f7e6 100644 --- a/forms/src/test/java/com/itextpdf/forms/form/element/FixedPositionTest.java +++ b/forms/src/test/java/com/itextpdf/forms/form/element/FixedPositionTest.java @@ -45,20 +45,18 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; import java.net.MalformedURLException; import java.util.ArrayList; import java.util.List; import java.util.function.Supplier; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; - -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class FixedPositionTest extends ExtendedITextTest { public static final String SOURCE_FOLDER = @@ -68,7 +66,7 @@ public class FixedPositionTest extends ExtendedITextTest { public static final String IMG_FOLDER = "./src/test/resources/com/itextpdf/forms/form/element/SignatureFieldAppearanceTest/"; - @BeforeClass + @BeforeAll public static void setUp() { createDestinationFolder(DESTINATION_FOLDER); } @@ -97,7 +95,7 @@ public void nonInteractive() throws IOException, InterruptedException { document.close(); } - Assert.assertNull(new CompareTool().compareByContent(outputFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outputFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -122,7 +120,7 @@ public void nonInteractiveOnSpecificPage() throws IOException, InterruptedExcept document.close(); } - Assert.assertNull(new CompareTool().compareByContent(outputFileName, cmpFileName, DESTINATION_FOLDER, + Assertions.assertNull(new CompareTool().compareByContent(outputFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @@ -148,7 +146,7 @@ public void interactive() throws IOException, InterruptedException { document.close(); } - Assert.assertNull(new CompareTool().compareByContent(outputFileName, cmpFileName, DESTINATION_FOLDER, + Assertions.assertNull(new CompareTool().compareByContent(outputFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @@ -176,7 +174,7 @@ public void interactiveOnPage() throws IOException, InterruptedException { document.close(); } - Assert.assertNull(new CompareTool().compareByContent(outputFileName, cmpFileName, DESTINATION_FOLDER, + Assertions.assertNull(new CompareTool().compareByContent(outputFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @@ -201,7 +199,7 @@ public void interactiveWidthOutOfBounds() throws IOException, InterruptedExcepti } document.close(); } - Assert.assertNull(new CompareTool().compareByContent(outputFileName, cmpFileName, DESTINATION_FOLDER, + Assertions.assertNull(new CompareTool().compareByContent(outputFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @@ -233,7 +231,7 @@ public void interactiveMarginLeft() throws IOException, InterruptedException { } document.close(); } - Assert.assertNull(new CompareTool().compareByContent(outputFileName, cmpFileName, DESTINATION_FOLDER, + Assertions.assertNull(new CompareTool().compareByContent(outputFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @@ -265,7 +263,7 @@ public void interactiveMarginTop() throws IOException, InterruptedException { } document.close(); } - Assert.assertNull(new CompareTool().compareByContent(outputFileName, cmpFileName, DESTINATION_FOLDER, + Assertions.assertNull(new CompareTool().compareByContent(outputFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @@ -294,7 +292,7 @@ public void width() throws IOException, InterruptedException { } document.close(); } - Assert.assertNull(new CompareTool().compareByContent(outputFileName, cmpFileName, DESTINATION_FOLDER, + Assertions.assertNull(new CompareTool().compareByContent(outputFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @@ -322,7 +320,7 @@ public void padding() throws IOException, InterruptedException { } document.close(); } - Assert.assertNull(new CompareTool().compareByContent(outputFileName, cmpFileName, DESTINATION_FOLDER, + Assertions.assertNull(new CompareTool().compareByContent(outputFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } diff --git a/forms/src/test/java/com/itextpdf/forms/form/element/InputButtonTest.java b/forms/src/test/java/com/itextpdf/forms/form/element/InputButtonTest.java index 3ddd08fbcf..d96a842f84 100644 --- a/forms/src/test/java/com/itextpdf/forms/form/element/InputButtonTest.java +++ b/forms/src/test/java/com/itextpdf/forms/form/element/InputButtonTest.java @@ -44,22 +44,20 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; - +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class InputButtonTest extends ExtendedITextTest { public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/forms/form/element/InputButtonTest/"; public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/forms/form/element/InputButtonTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(DESTINATION_FOLDER); } @@ -71,19 +69,19 @@ public void basicInputButtonTest() throws IOException, InterruptedException { try (Document document = new Document(new PdfDocument(new PdfWriter(outPdf)))) { Button formInputButton = new Button("form input button"); - formInputButton.setProperty(FormProperty.FORM_FIELD_FLATTEN, false); + formInputButton.setProperty(FormProperty.FORM_FIELD_FLATTEN, Boolean.FALSE); formInputButton.setSingleLineValue("form input button"); document.add(formInputButton); document.add(new Paragraph("")); Button flattenInputButton = new Button("flatten input button"); - flattenInputButton.setProperty(FormProperty.FORM_FIELD_FLATTEN, true); + flattenInputButton.setProperty(FormProperty.FORM_FIELD_FLATTEN, Boolean.TRUE); flattenInputButton.setSingleLineValue("flatten input button"); document.add(flattenInputButton); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -93,7 +91,7 @@ public void customizedInputButtonTest() throws IOException, InterruptedException try (Document document = new Document(new PdfDocument(new PdfWriter(outPdf)))) { Button formInputButton = new Button("form input button"); - formInputButton.setProperty(FormProperty.FORM_FIELD_FLATTEN, false); + formInputButton.setProperty(FormProperty.FORM_FIELD_FLATTEN, Boolean.FALSE); formInputButton.setSingleLineValue("form input button"); formInputButton.setFontColor(ColorConstants.BLUE); formInputButton.setBackgroundColor(ColorConstants.YELLOW); @@ -103,7 +101,7 @@ public void customizedInputButtonTest() throws IOException, InterruptedException document.add(new Paragraph("")); Button flattenInputButton = new Button("flatten input button"); - flattenInputButton.setProperty(FormProperty.FORM_FIELD_FLATTEN, true); + flattenInputButton.setProperty(FormProperty.FORM_FIELD_FLATTEN, Boolean.TRUE); flattenInputButton.setSingleLineValue("flatten input button"); flattenInputButton.setFontColor(ColorConstants.BLUE); flattenInputButton.setBackgroundColor(ColorConstants.YELLOW); @@ -111,7 +109,7 @@ public void customizedInputButtonTest() throws IOException, InterruptedException document.add(flattenInputButton); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -122,7 +120,7 @@ public void addInputButtonInTwoWaysTest() throws IOException, InterruptedExcepti try (Document document = new Document(new PdfDocument(new PdfWriter(outPdf)))) { // Create push button using html element Button formInputButton = new Button("button"); - formInputButton.setProperty(FormProperty.FORM_FIELD_FLATTEN, false); + formInputButton.setProperty(FormProperty.FORM_FIELD_FLATTEN, Boolean.FALSE); formInputButton.setSingleLineValue("html input button"); formInputButton.setFontColor(ColorConstants.BLUE); formInputButton.setBackgroundColor(ColorConstants.YELLOW); @@ -141,7 +139,7 @@ public void addInputButtonInTwoWaysTest() throws IOException, InterruptedExcepti form.addField(button); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -151,14 +149,14 @@ public void inputButtonIsSplitTest() throws IOException, InterruptedException { try (Document document = new Document(new PdfDocument(new PdfWriter(outPdf)))) { Button formInputButton = new Button("button"); - formInputButton.setProperty(FormProperty.FORM_FIELD_FLATTEN, false); + formInputButton.setProperty(FormProperty.FORM_FIELD_FLATTEN, Boolean.FALSE); formInputButton.setProperty(Property.WIDTH, UnitValue.createPointValue(280)); formInputButton.setProperty(Property.HEIGHT, UnitValue.createPointValue(30)); formInputButton.setSingleLineValue("text with default font size longer than button width won't be split"); document.add(formInputButton); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -172,14 +170,14 @@ public void inputButtonIsForcedSplitTest() throws IOException, InterruptedExcept try (Document document = new Document(new PdfDocument(new PdfWriter(outPdf)))) { Button formInputButton = new Button("button"); - formInputButton.setProperty(FormProperty.FORM_FIELD_FLATTEN, false); + formInputButton.setProperty(FormProperty.FORM_FIELD_FLATTEN, Boolean.FALSE); formInputButton.setProperty(Property.WIDTH, UnitValue.createPointValue(280)); formInputButton.setProperty(Property.HEIGHT, UnitValue.createPointValue(30)); formInputButton.setSingleLineValue("text with line break\n which will be split"); document.add(formInputButton); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -189,7 +187,7 @@ public void inputButtonWithPaddingsTest() throws IOException, InterruptedExcepti try (Document document = new Document(new PdfDocument(new PdfWriter(outPdf)))) { Button formInputButton = new Button("button"); - formInputButton.setProperty(FormProperty.FORM_FIELD_FLATTEN, false); + formInputButton.setProperty(FormProperty.FORM_FIELD_FLATTEN, Boolean.FALSE); formInputButton.setProperty(Property.PADDING_BOTTOM, UnitValue.createPointValue(15)); formInputButton.setProperty(Property.PADDING_TOP, UnitValue.createPointValue(15)); formInputButton.setFontSize(50); @@ -197,7 +195,7 @@ public void inputButtonWithPaddingsTest() throws IOException, InterruptedExcepti document.add(formInputButton); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -208,7 +206,7 @@ public void inputButtonWithMarginsPaddingsTest() throws IOException, Interrupted try (Document document = new Document(new PdfDocument(new PdfWriter(outPdf)))) { Div div = new Div().setBackgroundColor(ColorConstants.PINK); Button formInputButton = new Button("button"); - formInputButton.setProperty(FormProperty.FORM_FIELD_FLATTEN, false); + formInputButton.setProperty(FormProperty.FORM_FIELD_FLATTEN, Boolean.FALSE); formInputButton.setProperty(Property.PADDING_BOTTOM, UnitValue.createPointValue(20)); formInputButton.setProperty(Property.PADDING_TOP, UnitValue.createPointValue(20)); formInputButton.setProperty(Property.PADDING_LEFT, UnitValue.createPointValue(20)); @@ -224,6 +222,6 @@ public void inputButtonWithMarginsPaddingsTest() throws IOException, Interrupted document.add(div); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } } diff --git a/forms/src/test/java/com/itextpdf/forms/form/element/InputFieldTest.java b/forms/src/test/java/com/itextpdf/forms/form/element/InputFieldTest.java index dd2c63d13c..833b1c025e 100644 --- a/forms/src/test/java/com/itextpdf/forms/form/element/InputFieldTest.java +++ b/forms/src/test/java/com/itextpdf/forms/form/element/InputFieldTest.java @@ -45,22 +45,21 @@ This file is part of the iText (R) project. import com.itextpdf.layout.properties.TextAlignment; import com.itextpdf.layout.properties.UnitValue; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class InputFieldTest extends ExtendedITextTest { public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/forms/form/element/InputFieldTest/"; public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/forms/form/element/InputFieldTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(DESTINATION_FOLDER); } @@ -72,17 +71,17 @@ public void basicInputFieldTest() throws IOException, InterruptedException { try (Document document = new Document(new PdfDocument(new PdfWriter(outPdf)))) { InputField formInputField = new InputField("form input field"); - formInputField.setProperty(FormProperty.FORM_FIELD_FLATTEN, false); + formInputField.setProperty(FormProperty.FORM_FIELD_FLATTEN, Boolean.FALSE); formInputField.setProperty(FormProperty.FORM_FIELD_VALUE, "form input field"); document.add(formInputField); InputField flattenInputField = new InputField("flatten input field"); - flattenInputField.setProperty(FormProperty.FORM_FIELD_FLATTEN, true); + flattenInputField.setProperty(FormProperty.FORM_FIELD_FLATTEN, Boolean.TRUE); flattenInputField.setProperty(FormProperty.FORM_FIELD_VALUE, "flatten input field"); document.add(flattenInputField); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -94,11 +93,11 @@ public void noValueInputFieldTest() throws IOException, InterruptedException { InputField flattenInputField = new InputField("no value input field"); flattenInputField.setProperty(FormProperty.FORM_FIELD_FLATTEN, null); flattenInputField.setProperty(FormProperty.FORM_FIELD_VALUE, null); - flattenInputField.setProperty(Property.BORDER, new SolidBorder(2f)); + flattenInputField.setBorder(new SolidBorder(2f)); document.add(flattenInputField); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -114,13 +113,13 @@ public void inputFieldDoesNotFitTest() throws IOException, InterruptedException document.add(div); InputField flattenInputField = new InputField("input field does not fit"); - flattenInputField.setProperty(FormProperty.FORM_FIELD_FLATTEN, true); + flattenInputField.setProperty(FormProperty.FORM_FIELD_FLATTEN, Boolean.TRUE); flattenInputField.setProperty(FormProperty.FORM_FIELD_VALUE, "input field does not fit"); - flattenInputField.setProperty(Property.BORDER, new SolidBorder(2f)); + flattenInputField.setBorder(new SolidBorder(2f)); document.add(flattenInputField); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -131,15 +130,15 @@ public void inputFieldWithLangTest() throws IOException, InterruptedException { try (Document document = new Document(new PdfDocument(new PdfWriter(outPdf)))) { document.getPdfDocument().setTagged(); InputField flattenInputField = new InputField("input field with lang"); - flattenInputField.setProperty(FormProperty.FORM_FIELD_FLATTEN, false); + flattenInputField.setProperty(FormProperty.FORM_FIELD_FLATTEN, Boolean.FALSE); flattenInputField.setProperty(FormProperty.FORM_FIELD_VALUE, "input field with lang"); - flattenInputField.setProperty(FormProperty.FORM_ACCESSIBILITY_LANGUAGE, "random_lang"); - flattenInputField.setProperty(Property.BORDER, new SolidBorder(2f)); + flattenInputField.getAccessibilityProperties().setLanguage("random_lang"); + flattenInputField.setBorder(new SolidBorder(2f)); document.add(flattenInputField); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -150,15 +149,15 @@ public void inputFieldWithNullLangTest() throws IOException, InterruptedExceptio try (Document document = new Document(new PdfDocument(new PdfWriter(outPdf)))) { document.getPdfDocument().setTagged(); InputField flattenInputField = new InputField("input field with null lang"); - flattenInputField.setProperty(FormProperty.FORM_FIELD_FLATTEN, false); + flattenInputField.setProperty(FormProperty.FORM_FIELD_FLATTEN, Boolean.FALSE); flattenInputField.setProperty(FormProperty.FORM_FIELD_VALUE, "input field with null lang"); - flattenInputField.setProperty(FormProperty.FORM_ACCESSIBILITY_LANGUAGE, null); - flattenInputField.setProperty(Property.BORDER, new SolidBorder(2f)); + flattenInputField.getAccessibilityProperties().setLanguage(null); + flattenInputField.setBorder(new SolidBorder(2f)); document.add(flattenInputField); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -168,21 +167,21 @@ public void inputFieldWithPasswordTest() throws IOException, InterruptedExceptio try (Document document = new Document(new PdfDocument(new PdfWriter(outPdf)))) { InputField formInputField = new InputField("form input field with password"); - formInputField.setProperty(FormProperty.FORM_FIELD_FLATTEN, false); + formInputField.setProperty(FormProperty.FORM_FIELD_FLATTEN, Boolean.FALSE); formInputField.setProperty(FormProperty.FORM_FIELD_VALUE, "form input field with password"); - formInputField.setProperty(Property.BORDER, new SolidBorder(2f)); - formInputField.setProperty(FormProperty.FORM_FIELD_PASSWORD_FLAG, true); + formInputField.setBorder(new SolidBorder(2f)); + formInputField.setProperty(FormProperty.FORM_FIELD_PASSWORD_FLAG, Boolean.TRUE); document.add(formInputField); InputField flattenInputField = new InputField("flatten input field with password"); - flattenInputField.setProperty(FormProperty.FORM_FIELD_FLATTEN, true); + flattenInputField.setProperty(FormProperty.FORM_FIELD_FLATTEN, Boolean.TRUE); flattenInputField.setProperty(FormProperty.FORM_FIELD_VALUE, "flatten input field with password"); - flattenInputField.setProperty(Property.BORDER, new SolidBorder(2f)); - flattenInputField.setProperty(FormProperty.FORM_FIELD_PASSWORD_FLAG, true); + flattenInputField.setBorder(new SolidBorder(2f)); + flattenInputField.setProperty(FormProperty.FORM_FIELD_PASSWORD_FLAG, Boolean.TRUE); document.add(flattenInputField); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -192,14 +191,14 @@ public void heightInputFieldTest() throws IOException, InterruptedException { try (Document document = new Document(new PdfDocument(new PdfWriter(outPdf)))) { InputField flattenInputField = new InputField("flatten input field with height"); - flattenInputField.setProperty(FormProperty.FORM_FIELD_FLATTEN, true); + flattenInputField.setProperty(FormProperty.FORM_FIELD_FLATTEN, Boolean.TRUE); flattenInputField.setProperty(FormProperty.FORM_FIELD_VALUE, "flatten input field with height"); flattenInputField.setProperty(Property.HEIGHT, new UnitValue(UnitValue.POINT, 100)); - flattenInputField.setProperty(Property.BORDER, new SolidBorder(2f)); + flattenInputField.setBorder(new SolidBorder(2f)); document.add(flattenInputField); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -209,14 +208,14 @@ public void minHeightInputFieldTest() throws IOException, InterruptedException { try (Document document = new Document(new PdfDocument(new PdfWriter(outPdf)))) { InputField flattenInputField = new InputField("flatten input field with height"); - flattenInputField.setProperty(FormProperty.FORM_FIELD_FLATTEN, true); + flattenInputField.setProperty(FormProperty.FORM_FIELD_FLATTEN, Boolean.TRUE); flattenInputField.setProperty(FormProperty.FORM_FIELD_VALUE, "flatten input field with height"); flattenInputField.setProperty(Property.MIN_HEIGHT, new UnitValue(UnitValue.POINT, 100)); - flattenInputField.setProperty(Property.BORDER, new SolidBorder(2f)); + flattenInputField.setBorder(new SolidBorder(2f)); document.add(flattenInputField); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -226,14 +225,14 @@ public void maxHeightInputFieldTest() throws IOException, InterruptedException { try (Document document = new Document(new PdfDocument(new PdfWriter(outPdf)))) { InputField flattenInputField = new InputField("flatten input field with height"); - flattenInputField.setProperty(FormProperty.FORM_FIELD_FLATTEN, true); + flattenInputField.setProperty(FormProperty.FORM_FIELD_FLATTEN, Boolean.TRUE); flattenInputField.setProperty(FormProperty.FORM_FIELD_VALUE, "flatten input field with height"); flattenInputField.setProperty(Property.MAX_HEIGHT, new UnitValue(UnitValue.POINT, 10)); - flattenInputField.setProperty(Property.BORDER, new SolidBorder(2f)); + flattenInputField.setBorder(new SolidBorder(2f)); document.add(flattenInputField); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -249,7 +248,7 @@ public void inputFieldWithJustificationTest() throws IOException, InterruptedExc document.add(flattenInputField); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -265,7 +264,7 @@ public void inputFieldWithBorderTest() throws IOException, InterruptedException document.add(flattenInputField); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -312,12 +311,12 @@ public void rotationTest() throws IOException, InterruptedException { document.add(inputField270); InputField inputField45 = new InputField("1"); - Exception exception = Assert.assertThrows(IllegalArgumentException.class, + Exception exception = Assertions.assertThrows(IllegalArgumentException.class, () -> inputField45.setRotation(45)); - Assert.assertEquals(FormsExceptionMessageConstant.INVALID_ROTATION_VALUE, exception.getMessage()); + Assertions.assertEquals(FormsExceptionMessageConstant.INVALID_ROTATION_VALUE, exception.getMessage()); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER, "diff")); } @Test @@ -363,7 +362,7 @@ public void borderBoxesTest() throws IOException, InterruptedException { document.add(flattenInputField2); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -379,7 +378,7 @@ public void setFontInputFieldTest() throws IOException, InterruptedException { inputField.setValue("Some value"); document.add(inputField); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -403,7 +402,7 @@ public void multiPageInputFieldTest() throws IOException, InterruptedException { } } } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -428,6 +427,6 @@ public void multiPageInputFieldFormFlushTest() throws IOException, InterruptedEx form = PdfAcroForm.getAcroForm(document, true); } } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } } diff --git a/forms/src/test/java/com/itextpdf/forms/form/element/ListBoxFieldTest.java b/forms/src/test/java/com/itextpdf/forms/form/element/ListBoxFieldTest.java index 6421d300f8..f7a8709a05 100644 --- a/forms/src/test/java/com/itextpdf/forms/form/element/ListBoxFieldTest.java +++ b/forms/src/test/java/com/itextpdf/forms/form/element/ListBoxFieldTest.java @@ -30,7 +30,6 @@ This file is part of the iText (R) project. import com.itextpdf.io.font.constants.StandardFonts; import com.itextpdf.io.logs.IoLogMessageConstant; import com.itextpdf.kernel.colors.ColorConstants; -import com.itextpdf.kernel.exceptions.PdfException; import com.itextpdf.kernel.font.PdfFontFactory; import com.itextpdf.kernel.geom.Rectangle; import com.itextpdf.kernel.pdf.PdfArray; @@ -51,23 +50,22 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.ByteArrayOutputStream; import java.io.IOException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class ListBoxFieldTest extends ExtendedITextTest { public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/forms/form/element/ListBoxFieldTest/"; public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/forms/form/element/ListBoxFieldTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(DESTINATION_FOLDER); } @@ -79,12 +77,12 @@ public void emptyListBoxFieldTest() throws IOException, InterruptedException { try (Document document = new Document(new PdfDocument(new PdfWriter(outPdf)))) { ListBoxField flattenListBoxField = new ListBoxField("flatten empty list box field", 0, false); - flattenListBoxField.setProperty(FormProperty.FORM_FIELD_FLATTEN, true); + flattenListBoxField.setProperty(FormProperty.FORM_FIELD_FLATTEN, Boolean.TRUE); flattenListBoxField.setBackgroundColor(ColorConstants.RED); document.add(flattenListBoxField); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -100,13 +98,13 @@ public void basicListBoxFieldTest() throws IOException, InterruptedException { document.add(formListBoxField); ListBoxField flattenListBoxField = new ListBoxField("flatten list box field", 2, false); - flattenListBoxField.setProperty(FormProperty.FORM_FIELD_FLATTEN, true); + flattenListBoxField.setProperty(FormProperty.FORM_FIELD_FLATTEN, Boolean.TRUE); flattenListBoxField.addOption("option 1", false); flattenListBoxField.addOption("option 2", true); document.add(flattenListBoxField); Paragraph option3 = new Paragraph("option 3"); - option3.setProperty(FormProperty.FORM_FIELD_SELECTED, true); + option3.setProperty(FormProperty.FORM_FIELD_SELECTED, Boolean.TRUE); option3.setMargin(0); option3.setMultipliedLeading(2); @@ -115,11 +113,11 @@ public void basicListBoxFieldTest() throws IOException, InterruptedException { flattenListBoxFieldWithMultipleSelection.setInteractive(false); flattenListBoxFieldWithMultipleSelection.addOption("option 1", false); flattenListBoxFieldWithMultipleSelection.addOption("option 2", true); - flattenListBoxFieldWithMultipleSelection.addOption(option3); + flattenListBoxFieldWithMultipleSelection.addOption(new SelectFieldItem("option 3", option3)); document.add(flattenListBoxFieldWithMultipleSelection); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -163,7 +161,7 @@ public void listBoxFieldWithFontSizeTest() throws IOException, InterruptedExcept document.add(flattenListBoxFieldWithPercentFont); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -177,15 +175,15 @@ public void listBoxFieldWithMarginsTest() throws IOException, InterruptedExcepti option1.setMargin(4); Paragraph option2 = new Paragraph("option 2"); - option2.setProperty(FormProperty.FORM_FIELD_SELECTED, true); + option2.setProperty(FormProperty.FORM_FIELD_SELECTED, Boolean.TRUE); option2.setProperty(FormProperty.FORM_FIELD_LABEL, "option 2"); option2.setMargin(4); ListBoxField listBoxField = new ListBoxField("list box field with margins", 1, false); listBoxField.setInteractive(false); listBoxField.setBackgroundColor(ColorConstants.RED); - listBoxField.addOption(option1); - listBoxField.addOption(option2); + listBoxField.addOption(new SelectFieldItem("option 1", option1)); + listBoxField.addOption(new SelectFieldItem("option 2", option2)); document.add(listBoxField); document.add(new Paragraph("line break")); @@ -197,7 +195,7 @@ public void listBoxFieldWithMarginsTest() throws IOException, InterruptedExcepti document.add(listBoxField.setInteractive(true)); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -219,7 +217,7 @@ public void listBoxFieldWithHeightTest() throws IOException, InterruptedExceptio document.add(listBoxField.setInteractive(true)); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -241,7 +239,7 @@ public void listBoxFieldWithMinHeightTest() throws IOException, InterruptedExcep document.add(listBoxField.setInteractive(true)); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -264,7 +262,7 @@ public void listBoxFieldWithMaxHeightTest() throws IOException, InterruptedExcep document.add(listBoxField.setInteractive(true)); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -287,7 +285,7 @@ public void listBoxFieldCannotFitTest() throws IOException, InterruptedException document.add(listBoxField); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -297,7 +295,7 @@ public void listBoxFieldCannotFitByWidthTest() throws IOException, InterruptedEx try (Document document = new Document(new PdfDocument(new PdfWriter(outPdf)))) { Paragraph option1 = new Paragraph("option 1"); - option1.setProperty(FormProperty.FORM_FIELD_SELECTED, true); + option1.setProperty(FormProperty.FORM_FIELD_SELECTED, Boolean.TRUE); option1.setProperty(FormProperty.FORM_FIELD_LABEL, "option 1"); Paragraph option2 = new Paragraph("option 2"); @@ -308,8 +306,8 @@ public void listBoxFieldCannotFitByWidthTest() throws IOException, InterruptedEx listBoxField.setBackgroundColor(ColorConstants.RED); listBoxField.setProperty(Property.WIDTH, UnitValue.createPointValue(600)); listBoxField.setBorder(new SolidBorder(20)); - listBoxField.addOption(option1); - listBoxField.addOption(option2); + listBoxField.addOption(new SelectFieldItem("option 1", option1)); + listBoxField.addOption(new SelectFieldItem("option 2", option2)); document.add(listBoxField); document.add(new Paragraph("Line break")); @@ -317,7 +315,7 @@ public void listBoxFieldCannotFitByWidthTest() throws IOException, InterruptedEx document.add(listBoxField.setInteractive(true)); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -332,7 +330,7 @@ public void listBoxFieldWithLangTest() throws IOException, InterruptedException listBoxField.setBackgroundColor(ColorConstants.RED); listBoxField.addOption("option 1"); listBoxField.addOption("option 2"); - listBoxField.setProperty(FormProperty.FORM_ACCESSIBILITY_LANGUAGE, "random_lang"); + listBoxField.getAccessibilityProperties().setLanguage("random_lang"); document.add(listBoxField); document.add(new Paragraph("Line break")); @@ -340,7 +338,7 @@ public void listBoxFieldWithLangTest() throws IOException, InterruptedException document.add(listBoxField.setInteractive(true)); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -363,7 +361,7 @@ public void colorsBordersTest() throws IOException, InterruptedException { document.add(listBoxField.setInteractive(true)); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -393,7 +391,7 @@ public void longListTest() throws IOException, InterruptedException { document.add(listBoxField.setInteractive(true)); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -439,7 +437,7 @@ public void justificationTest() throws IOException, InterruptedException { document.add(rightListBoxField.setInteractive(true)); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -461,7 +459,7 @@ public void exportValueTest() throws IOException, InterruptedException { document.add(listBoxField.setInteractive(true)); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -499,7 +497,7 @@ public void invalidOptionsTest() throws IOException, InterruptedException { PdfAcroForm.getAcroForm(doc, true).addField(field); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -516,7 +514,7 @@ public void listBoxIsBiggerThanPage() throws IOException, InterruptedException { document.add(list); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -533,7 +531,7 @@ public void listBoxIsBiggerThanPageNonI() throws IOException, InterruptedExcepti document.add(list); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -548,21 +546,21 @@ public void invalidOptionsExceptionTest() throws IOException, InterruptedExcepti option1.add(new PdfString("English3")); PdfArray options = new PdfArray(); options.add(option1); - Exception e = Assert.assertThrows(IllegalArgumentException.class, () -> builder.setOptions(options)); - Assert.assertEquals(FormsExceptionMessageConstant.INNER_ARRAY_SHALL_HAVE_TWO_ELEMENTS, e.getMessage()); + Exception e = Assertions.assertThrows(IllegalArgumentException.class, () -> builder.setOptions(options)); + Assertions.assertEquals(FormsExceptionMessageConstant.INNER_ARRAY_SHALL_HAVE_TWO_ELEMENTS, e.getMessage()); options.clear(); option1 = new PdfArray(); option1.add(new PdfString("English")); option1.add(new PdfNumber(1)); options.add(option1); - e = Assert.assertThrows(IllegalArgumentException.class, () -> builder.setOptions(options)); - Assert.assertEquals(FormsExceptionMessageConstant.OPTION_ELEMENT_MUST_BE_STRING_OR_ARRAY, e.getMessage()); + e = Assertions.assertThrows(IllegalArgumentException.class, () -> builder.setOptions(options)); + Assertions.assertEquals(FormsExceptionMessageConstant.OPTION_ELEMENT_MUST_BE_STRING_OR_ARRAY, e.getMessage()); PdfArray options2 = new PdfArray(); options2.add(new PdfNumber(1)); - e = Assert.assertThrows(IllegalArgumentException.class, () -> builder.setOptions(options2)); - Assert.assertEquals(FormsExceptionMessageConstant.OPTION_ELEMENT_MUST_BE_STRING_OR_ARRAY, e.getMessage()); + e = Assertions.assertThrows(IllegalArgumentException.class, () -> builder.setOptions(options2)); + Assertions.assertEquals(FormsExceptionMessageConstant.OPTION_ELEMENT_MUST_BE_STRING_OR_ARRAY, e.getMessage()); } } } diff --git a/forms/src/test/java/com/itextpdf/forms/form/element/RadioTest.java b/forms/src/test/java/com/itextpdf/forms/form/element/RadioTest.java index be4d9daaa2..eac56b8543 100644 --- a/forms/src/test/java/com/itextpdf/forms/form/element/RadioTest.java +++ b/forms/src/test/java/com/itextpdf/forms/form/element/RadioTest.java @@ -50,23 +50,22 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.ByteArrayOutputStream; import java.io.IOException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class RadioTest extends ExtendedITextTest { public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/forms/form/element/RadioTest/"; public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/forms/form/element/RadioTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(DESTINATION_FOLDER); } @@ -92,7 +91,7 @@ public void basicRadioTest() throws IOException, InterruptedException { document.add(flattenRadio2); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -117,7 +116,7 @@ public void basicRadioTaggedTest() throws IOException, InterruptedException { document.add(flattenRadio2); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -125,8 +124,8 @@ public void emptyNameTest() { try (Document document = new Document(new PdfDocument(new PdfWriter(new ByteArrayOutputStream())))) { Radio formRadio = createRadioButton("radio button 1", null, null, null, true, false); - Exception e = Assert.assertThrows(PdfException.class, () -> document.add(formRadio)); - Assert.assertEquals(FormsExceptionMessageConstant.EMPTY_RADIO_GROUP_NAME, e.getMessage()); + Exception e = Assertions.assertThrows(PdfException.class, () -> document.add(formRadio)); + Assertions.assertEquals(FormsExceptionMessageConstant.EMPTY_RADIO_GROUP_NAME, e.getMessage()); } } @@ -135,8 +134,8 @@ public void emptyValueTest() { try (Document document = new Document(new PdfDocument(new PdfWriter(new ByteArrayOutputStream())))) { Radio formRadio = createRadioButton("", "radioGroup", null, null, true, false); - Exception e = Assert.assertThrows(PdfException.class, () -> document.add(formRadio)); - Assert.assertEquals(FormsExceptionMessageConstant.APEARANCE_NAME_MUST_BE_PROVIDED, e.getMessage()); + Exception e = Assertions.assertThrows(PdfException.class, () -> document.add(formRadio)); + Assertions.assertEquals(FormsExceptionMessageConstant.APEARANCE_NAME_MUST_BE_PROVIDED, e.getMessage()); } } @@ -156,7 +155,7 @@ public void mergeWithExistingFieldTest() throws IOException, InterruptedExceptio document.add(formRadio2); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -211,7 +210,7 @@ public void borderBackgroundTest() throws IOException, InterruptedException { document.add(flattenRadio5); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -245,7 +244,7 @@ public void borderBoxesTest() throws IOException, InterruptedException { document.add(flattenRadio2); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -261,7 +260,7 @@ public void dottedBorderTest() throws IOException, InterruptedException { Radio formRadio2 = createRadioButton("formRadio2", "form radio group", new DottedBorder(ColorConstants.BLUE, 3), ColorConstants.GREEN, false, false); - formRadio2.setSize(20).setProperty(FormProperty.FORM_FIELD_RADIO_BORDER_CIRCLE, false); + formRadio2.setSize(20).setProperty(FormProperty.FORM_FIELD_RADIO_BORDER_CIRCLE, Boolean.FALSE); document.add(formRadio2); Radio flattenRadio1 = createRadioButton("flattenRadio1", "flatten radio group", @@ -271,11 +270,11 @@ public void dottedBorderTest() throws IOException, InterruptedException { Radio flattenRadio2 = createRadioButton("flattenRadio2", "flatten radio group", new DottedBorder(ColorConstants.BLUE, 3), ColorConstants.GREEN, false, true); - flattenRadio2.setSize(20).setProperty(FormProperty.FORM_FIELD_RADIO_BORDER_CIRCLE, false); + flattenRadio2.setSize(20).setProperty(FormProperty.FORM_FIELD_RADIO_BORDER_CIRCLE, Boolean.FALSE); document.add(flattenRadio2); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } // This is the test for TODO: DEVSIX-7425 - Border radius 50% doesn't draw rounded borders @@ -288,16 +287,16 @@ public void formFieldRadioBorderCircleTest() throws IOException, InterruptedExce try (Document document = new Document(new PdfDocument(new PdfWriter(outPdf)))) { Radio flattenRadio1 = createRadioButton("flattenRadio1", "flatten radio group", new SolidBorder(ColorConstants.LIGHT_GRAY, 1), ColorConstants.GREEN, false, true); - flattenRadio1.setProperty(FormProperty.FORM_FIELD_RADIO_BORDER_CIRCLE, true); + flattenRadio1.setProperty(FormProperty.FORM_FIELD_RADIO_BORDER_CIRCLE, Boolean.TRUE); document.add(flattenRadio1); Radio flattenRadio2 = createRadioButton("flattenRadio2", "flatten radio group", new SolidBorder(ColorConstants.LIGHT_GRAY, 1), ColorConstants.GREEN, false, true); - flattenRadio2.setProperty(FormProperty.FORM_FIELD_RADIO_BORDER_CIRCLE, false); + flattenRadio2.setProperty(FormProperty.FORM_FIELD_RADIO_BORDER_CIRCLE, Boolean.FALSE); document.add(flattenRadio2); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -314,7 +313,7 @@ public void bigRadioButtonTest() throws IOException, InterruptedException { document.add(flattenRadio1); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -335,7 +334,7 @@ public void radioWithMarginsTest() throws IOException, InterruptedException { document.add(div); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -353,17 +352,17 @@ public void radioWithPaddingsTest() throws IOException, InterruptedException { radio.setProperty(Property.PADDING_RIGHT, UnitValue.createPointValue(20)); // Paddings are always 0 for radio buttons - Assert.assertEquals(radio.getProperty(Property.PADDING_BOTTOM), UnitValue.createPointValue(0)); - Assert.assertEquals(radio.getProperty(Property.PADDING_TOP), UnitValue.createPointValue(0)); - Assert.assertEquals(radio.getProperty(Property.PADDING_LEFT), UnitValue.createPointValue(0)); - Assert.assertEquals(radio.getProperty(Property.PADDING_RIGHT), UnitValue.createPointValue(0)); + Assertions.assertEquals(radio.getProperty(Property.PADDING_BOTTOM), UnitValue.createPointValue(0)); + Assertions.assertEquals(radio.getProperty(Property.PADDING_TOP), UnitValue.createPointValue(0)); + Assertions.assertEquals(radio.getProperty(Property.PADDING_LEFT), UnitValue.createPointValue(0)); + Assertions.assertEquals(radio.getProperty(Property.PADDING_RIGHT), UnitValue.createPointValue(0)); radio.setSize(100); div.add(radio); document.add(div); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -388,7 +387,7 @@ public void multiPageRadioFieldTest() throws IOException, InterruptedException { } } } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } static private Radio createRadioButton(String name, String groupName, Border border, Color backgroundColor, diff --git a/forms/src/test/java/com/itextpdf/forms/form/element/SelectFieldItemTest.java b/forms/src/test/java/com/itextpdf/forms/form/element/SelectFieldItemTest.java index a28e8c5e0b..1104dfe914 100644 --- a/forms/src/test/java/com/itextpdf/forms/form/element/SelectFieldItemTest.java +++ b/forms/src/test/java/com/itextpdf/forms/form/element/SelectFieldItemTest.java @@ -26,48 +26,47 @@ This file is part of the iText (R) project. import com.itextpdf.layout.element.Paragraph; import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.ITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class SelectFieldItemTest extends ExtendedITextTest { @Test public void newSelectFieldItem2ParamConstructorTest() { SelectFieldItem item = new SelectFieldItem("exportValue", "displayValue"); - Assert.assertEquals("exportValue", item.getExportValue()); - Assert.assertEquals("displayValue", item.getDisplayValue()); + Assertions.assertEquals("exportValue", item.getExportValue()); + Assertions.assertEquals("displayValue", item.getDisplayValue()); } @Test public void newSelectFieldItem1ParamConstructorTest() { SelectFieldItem item = new SelectFieldItem("exportValue"); - Assert.assertEquals("exportValue", item.getExportValue()); - Assert.assertEquals("exportValue", item.getDisplayValue()); + Assertions.assertEquals("exportValue", item.getExportValue()); + Assertions.assertEquals("exportValue", item.getDisplayValue()); } @Test public void newSelectFieldItem3ParamConstructorTest1() { SelectFieldItem item = new SelectFieldItem("exportValue", "displayValue", new Paragraph("displayValue")); - Assert.assertEquals("exportValue", item.getExportValue()); - Assert.assertEquals("displayValue", item.getDisplayValue()); - Assert.assertTrue(item.getElement() instanceof Paragraph); + Assertions.assertEquals("exportValue", item.getExportValue()); + Assertions.assertEquals("displayValue", item.getDisplayValue()); + Assertions.assertTrue(item.getElement() instanceof Paragraph); } @Test public void newSelectFieldItem3ParamConstructorTest2() { - Assert.assertThrows(PdfException.class, () -> { + Assertions.assertThrows(PdfException.class, () -> { new SelectFieldItem("exportValue", "displayValue", null); }); } @Test public void newSelectFieldItem3ParamConstructorTest3() { - Assert.assertThrows(PdfException.class, () -> { + Assertions.assertThrows(PdfException.class, () -> { new SelectFieldItem(null, "displayValue", new Paragraph("displayValue")); }); } @@ -75,30 +74,30 @@ public void newSelectFieldItem3ParamConstructorTest3() { @Test public void hasExportAndDisplayValuesTest01() { SelectFieldItem item = new SelectFieldItem("exportValue", "displayValue"); - Assert.assertTrue(item.hasExportAndDisplayValues()); + Assertions.assertTrue(item.hasExportAndDisplayValues()); } @Test public void hasExportAndDisplayValuesTest02() { SelectFieldItem item = new SelectFieldItem("exportValue"); - Assert.assertFalse(item.hasExportAndDisplayValues()); + Assertions.assertFalse(item.hasExportAndDisplayValues()); } @Test public void hasExportAndDisplayValuesTest03() { SelectFieldItem item = new SelectFieldItem("exportValue", new Paragraph("displayValue")); - Assert.assertFalse(item.hasExportAndDisplayValues()); + Assertions.assertFalse(item.hasExportAndDisplayValues()); } @Test public void hasExportAndDisplayValuesTest04() { SelectFieldItem item = new SelectFieldItem("exportValue", null, new Paragraph("displayValue")); - Assert.assertFalse(item.hasExportAndDisplayValues()); + Assertions.assertFalse(item.hasExportAndDisplayValues()); } @Test public void hasExportAndDisplayValuesTest05() { SelectFieldItem item = new SelectFieldItem("exportValue", "displayValue", new Paragraph("displayValue")); - Assert.assertTrue(item.hasExportAndDisplayValues()); + Assertions.assertTrue(item.hasExportAndDisplayValues()); } } diff --git a/forms/src/test/java/com/itextpdf/forms/form/element/SignatureFieldAppearanceTest.java b/forms/src/test/java/com/itextpdf/forms/form/element/SignatureFieldAppearanceTest.java index b293bd904a..214f43a81b 100644 --- a/forms/src/test/java/com/itextpdf/forms/form/element/SignatureFieldAppearanceTest.java +++ b/forms/src/test/java/com/itextpdf/forms/form/element/SignatureFieldAppearanceTest.java @@ -66,23 +66,22 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.FileNotFoundException; import java.io.IOException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class SignatureFieldAppearanceTest extends ExtendedITextTest { public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/forms/form/element/SignatureFieldAppearanceTest/"; public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/forms/form/element/SignatureFieldAppearanceTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(DESTINATION_FOLDER); } @@ -108,7 +107,7 @@ public void basicSigFieldTest() throws IOException, InterruptedException { document.add(flattenSigField); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -129,7 +128,7 @@ public void invisibleSigFieldTest() throws IOException, InterruptedException { document.add(formSigField); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -163,7 +162,45 @@ public void customizedSigFieldTest() throws IOException, InterruptedException { document.add(flattenSigField); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + } + + @Test + public void emptySigFieldAppearanceTest() throws IOException, InterruptedException { + String outPdf = DESTINATION_FOLDER + "emptySigFieldAppearance.pdf"; + String cmpPdf = SOURCE_FOLDER + "cmp_emptySigFieldAppearance.pdf"; + + try (Document document = new Document(new PdfDocument(new PdfWriter(outPdf)))) { + SignedAppearanceText description = new SignedAppearanceText() + .setSignedBy(null).setLocationLine(null).setReasonLine(null); + + SignatureFieldAppearance formSigField = new SignatureFieldAppearance("Signature1").setContent(description); + formSigField.setBackgroundColor(ColorConstants.LIGHT_GRAY); + formSigField.setBorder(new SolidBorder(ColorConstants.GREEN, 2)); + formSigField.setHeight(100).setWidth(200); + document.add(formSigField); + } + + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + } + + @Test + public void ignoreSignDateAndReasonInAppearanceTest() throws IOException, InterruptedException { + String outPdf = DESTINATION_FOLDER + "ignoreSignDateAndReasonInAppearance.pdf"; + String cmpPdf = SOURCE_FOLDER + "cmp_ignoreSignDateAndReasonInAppearance.pdf"; + + try (Document document = new Document(new PdfDocument(new PdfWriter(outPdf)))) { + SignedAppearanceText description = new SignedAppearanceText() + .setSignedBy("Signer Name").setLocationLine("Test Location").setReasonLine(null); + + SignatureFieldAppearance formSigField = new SignatureFieldAppearance("Signature1").setContent(description); + formSigField.setBackgroundColor(ColorConstants.LIGHT_GRAY); + formSigField.setBorder(new SolidBorder(ColorConstants.GREEN, 2)); + formSigField.setHeight(100).setWidth(200); + document.add(formSigField); + } + + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -204,7 +241,7 @@ public void signatureFieldVerticalAlignmentTest() throws IOException, Interrupte document.add(topSigField); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -225,7 +262,7 @@ public void sigFieldWithGraphicAndDescriptionModeTest() throws IOException, Inte document.add(formSigField); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -243,7 +280,7 @@ public void sigFieldWithGraphicModeTest() throws IOException, InterruptedExcepti document.add(formSigField); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -264,7 +301,7 @@ public void sigFieldWithNameAndDescriptionModeHorizontalTest() throws IOExceptio document.add(formSigField); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -285,7 +322,7 @@ public void sigFieldWithNameAndDescriptionModeVerticalTest() throws IOException, document.add(formSigField); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -331,7 +368,7 @@ public void borderBoxesTest() throws IOException, InterruptedException { document.add(flattenSigField2); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -391,7 +428,7 @@ public void borderTypesTest() throws IOException, InterruptedException { PdfFormCreator.getAcroForm(document.getPdfDocument(), false).flattenFields(); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -404,11 +441,11 @@ public void fontSizeTest() throws IOException, InterruptedException { sigField.setContent("test"); document.add(sigField); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test - public void fontNullCustomCheck() throws FileNotFoundException { + public void fontNullCustomCheck() throws IOException { String outPdf = DESTINATION_FOLDER + "fontNullCustomCheck.pdf"; PdfDocument pdfDoc = new PdfDocument(new PdfWriter(outPdf)) { @Override @@ -423,8 +460,8 @@ public PdfFont getDefaultFont() { sigField.setInteractive(true); sigField.setBorder(new SolidBorder(ColorConstants.GREEN, 1)); - Exception e = Assert.assertThrows(IllegalStateException.class, () -> document.add(sigField)); - Assert.assertEquals(LayoutExceptionMessageConstant.INVALID_FONT_PROPERTY_VALUE, e.getMessage()); + Exception e = Assertions.assertThrows(IllegalStateException.class, () -> document.add(sigField)); + Assertions.assertEquals(LayoutExceptionMessageConstant.INVALID_FONT_PROPERTY_VALUE, e.getMessage()); } @@ -468,7 +505,7 @@ public void signatureOnRotatedPagesTest() throws IOException, InterruptedExcepti form.flattenFields(); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -503,7 +540,7 @@ public void customModeTest() throws IOException, InterruptedException { document.add(appearance); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -516,6 +553,6 @@ public void flattenEmptySignatureTest() throws IOException, InterruptedException PdfAcroForm acroForm = PdfFormCreator.getAcroForm(document, false); acroForm.flattenFields(); } - Assert.assertNull(new CompareTool().compareVisually(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareVisually(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); } } diff --git a/forms/src/test/java/com/itextpdf/forms/form/element/TextAreaTest.java b/forms/src/test/java/com/itextpdf/forms/form/element/TextAreaTest.java index 5cf4d0a20f..b858e98b9f 100644 --- a/forms/src/test/java/com/itextpdf/forms/form/element/TextAreaTest.java +++ b/forms/src/test/java/com/itextpdf/forms/form/element/TextAreaTest.java @@ -39,22 +39,21 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class TextAreaTest extends ExtendedITextTest { public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/forms/form/element/TextAreaTest/"; public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/forms/form/element/TextAreaTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(DESTINATION_FOLDER); } @@ -66,17 +65,17 @@ public void basicTextAreaTest() throws IOException, InterruptedException { try (Document document = new Document(new PdfDocument(new PdfWriter(outPdf)))) { TextArea formTextArea = new TextArea("form text area"); - formTextArea.setProperty(FormProperty.FORM_FIELD_FLATTEN, false); + formTextArea.setProperty(FormProperty.FORM_FIELD_FLATTEN, Boolean.FALSE); formTextArea.setProperty(FormProperty.FORM_FIELD_VALUE, "form\ntext\narea"); document.add(formTextArea); TextArea flattenTextArea = new TextArea("flatten text area"); - flattenTextArea.setProperty(FormProperty.FORM_FIELD_FLATTEN, true); + flattenTextArea.setProperty(FormProperty.FORM_FIELD_FLATTEN, Boolean.TRUE); flattenTextArea.setProperty(FormProperty.FORM_FIELD_VALUE, "flatten\ntext\narea"); document.add(flattenTextArea); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -88,19 +87,19 @@ public void percentFontTextAreaTest() throws IOException, InterruptedException { try (Document document = new Document(new PdfDocument(new PdfWriter(outPdf)))) { TextArea formTextArea = new TextArea("form text area"); - formTextArea.setProperty(FormProperty.FORM_FIELD_FLATTEN, false); + formTextArea.setProperty(FormProperty.FORM_FIELD_FLATTEN, Boolean.FALSE); formTextArea.setProperty(FormProperty.FORM_FIELD_VALUE, "form\ntext\narea"); formTextArea.setProperty(Property.FONT_SIZE, UnitValue.createPercentValue(10)); document.add(formTextArea); TextArea flattenTextArea = new TextArea("flatten text area"); - flattenTextArea.setProperty(FormProperty.FORM_FIELD_FLATTEN, true); + flattenTextArea.setProperty(FormProperty.FORM_FIELD_FLATTEN, Boolean.TRUE); flattenTextArea.setProperty(FormProperty.FORM_FIELD_VALUE, "flatten\ntext\narea"); formTextArea.setProperty(Property.FONT_SIZE, UnitValue.createPercentValue(10)); document.add(flattenTextArea); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -110,14 +109,14 @@ public void heightTextAreaTest() throws IOException, InterruptedException { try (Document document = new Document(new PdfDocument(new PdfWriter(outPdf)))) { TextArea flattenTextArea = new TextArea("flatten text area with height"); - flattenTextArea.setProperty(FormProperty.FORM_FIELD_FLATTEN, true); + flattenTextArea.setProperty(FormProperty.FORM_FIELD_FLATTEN, Boolean.TRUE); flattenTextArea.setProperty(FormProperty.FORM_FIELD_VALUE, "flatten\ntext area\nwith height"); flattenTextArea.setProperty(Property.HEIGHT, new UnitValue(UnitValue.POINT, 100)); - flattenTextArea.setProperty(Property.BORDER, new SolidBorder(2f)); + flattenTextArea.setBorder(new SolidBorder(2f)); document.add(flattenTextArea); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -127,14 +126,14 @@ public void minHeightTextAreaTest() throws IOException, InterruptedException { try (Document document = new Document(new PdfDocument(new PdfWriter(outPdf)))) { TextArea flattenTextArea = new TextArea("flatten text area with height"); - flattenTextArea.setProperty(FormProperty.FORM_FIELD_FLATTEN, true); + flattenTextArea.setProperty(FormProperty.FORM_FIELD_FLATTEN, Boolean.TRUE); flattenTextArea.setProperty(FormProperty.FORM_FIELD_VALUE, "flatten\ntext area\nwith height"); flattenTextArea.setProperty(Property.MIN_HEIGHT, new UnitValue(UnitValue.POINT, 100)); - flattenTextArea.setProperty(Property.BORDER, new SolidBorder(2f)); + flattenTextArea.setBorder(new SolidBorder(2f)); document.add(flattenTextArea); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -172,7 +171,7 @@ public void hugeMarginPaddingBorderTest() throws IOException, InterruptedExcepti document.add(flattenTextArea); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -192,11 +191,11 @@ public void textAreaDoesNotFitTest() throws IOException, InterruptedException { textArea.setProperty(FormProperty.FORM_FIELD_VALUE, "some text to not\nbe able to fit in on the page\nmore text just text\nreally big height"); textArea.setHeight(50); - textArea.setProperty(Property.BORDER, new SolidBorder(2f)); + textArea.setBorder(new SolidBorder(2f)); document.add(textArea); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -211,7 +210,7 @@ public void textAreaWith0FontSizeDoesNotFitTest() throws IOException, Interrupte textArea.setInteractive(true); textArea.setProperty(FormProperty.FORM_FIELD_VALUE, "Font\n size \nof this\nText Area will \nbe approximated\nbased on the content"); - textArea.setProperty(Property.BORDER, new SolidBorder(1f)); + textArea.setBorder(new SolidBorder(1f)); textArea.setFontSize(0); textArea.setHeight(75); document.add(textArea); @@ -222,13 +221,13 @@ public void textAreaWith0FontSizeDoesNotFitTest() throws IOException, Interrupte flattenTextArea.setInteractive(false); flattenTextArea.setProperty(FormProperty.FORM_FIELD_VALUE, "Font\n size \nof this\nText Area will \nbe approximated\nbased on the content"); - flattenTextArea.setProperty(Property.BORDER, new SolidBorder(1f)); + flattenTextArea.setBorder(new SolidBorder(1f)); flattenTextArea.setFontSize(0); flattenTextArea.setHeight(75); document.add(flattenTextArea); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -241,7 +240,7 @@ public void textAreaWith0FontSizeFitsTest() throws IOException, InterruptedExcep textArea.setInteractive(true); textArea.setProperty(FormProperty.FORM_FIELD_VALUE, "Font\n size \nof this\nText Area will \nbe approximated\nbased on the content"); - textArea.setProperty(Property.BORDER, new SolidBorder(1f)); + textArea.setBorder(new SolidBorder(1f)); textArea.setFontSize(0); textArea.setHeight(75); document.add(textArea); @@ -250,13 +249,13 @@ public void textAreaWith0FontSizeFitsTest() throws IOException, InterruptedExcep flattenTextArea.setInteractive(false); flattenTextArea.setProperty(FormProperty.FORM_FIELD_VALUE, "Font\n size \nof this\nText Area will \nbe approximated\nbased on the content"); - flattenTextArea.setProperty(Property.BORDER, new SolidBorder(1f)); + flattenTextArea.setBorder(new SolidBorder(1f)); flattenTextArea.setFontSize(0); flattenTextArea.setHeight(75); document.add(flattenTextArea); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -269,7 +268,7 @@ public void textAreaWith0FontSizeWithoutHeightTest() throws IOException, Interru textArea.setInteractive(true); textArea.setProperty(FormProperty.FORM_FIELD_VALUE, "Font\n size \nof this\nText Area will not " + "\nbe approximated\nbased on the content\nbecause height is not set"); - textArea.setProperty(Property.BORDER, new SolidBorder(1f)); + textArea.setBorder(new SolidBorder(1f)); textArea.setFontSize(0); document.add(textArea); @@ -277,12 +276,12 @@ public void textAreaWith0FontSizeWithoutHeightTest() throws IOException, Interru flattenTextArea.setInteractive(false); flattenTextArea.setProperty(FormProperty.FORM_FIELD_VALUE, "Font\n size \nof this\nText Area will not " + "\nbe approximated\nbased on the content\nbecause height is not set"); - flattenTextArea.setProperty(Property.BORDER, new SolidBorder(1f)); + flattenTextArea.setBorder(new SolidBorder(1f)); flattenTextArea.setFontSize(0); document.add(flattenTextArea); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -295,11 +294,11 @@ public void textAreaWithBorderLessThan1Test() throws IOException, InterruptedExc textArea.setInteractive(true); textArea.setProperty(FormProperty.FORM_FIELD_VALUE, "Is border visible?\nAnd after clicking on the field?\nIt should be by the way"); - textArea.setProperty(Property.BORDER, new SolidBorder(0.5f)); + textArea.setBorder(new SolidBorder(0.5f)); document.add(textArea); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -321,7 +320,7 @@ public void textAreaWithJustificationTest() throws IOException, InterruptedExcep document.add(flattenedTextArea); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -344,7 +343,7 @@ public void textAreaWithCustomBorderTest() throws IOException, InterruptedExcept document.add(flattenedTextArea); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -354,14 +353,14 @@ public void maxHeightTextAreaTest() throws IOException, InterruptedException { try (Document document = new Document(new PdfDocument(new PdfWriter(outPdf)))) { TextArea flattenTextArea = new TextArea("flatten text area with height"); - flattenTextArea.setProperty(FormProperty.FORM_FIELD_FLATTEN, true); + flattenTextArea.setProperty(FormProperty.FORM_FIELD_FLATTEN, Boolean.TRUE); flattenTextArea.setProperty(FormProperty.FORM_FIELD_VALUE, "flatten\ntext area\nwith height"); flattenTextArea.setProperty(Property.MAX_HEIGHT, new UnitValue(UnitValue.POINT, 28)); - flattenTextArea.setProperty(Property.BORDER, new SolidBorder(2f)); + flattenTextArea.setBorder(new SolidBorder(2f)); document.add(flattenTextArea); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -398,6 +397,6 @@ public void textAreaWithCustomLeadingTest() throws IOException, InterruptedExcep document.add(flattenedTextArea2); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } } diff --git a/forms/src/test/java/com/itextpdf/forms/form/renderer/InputFieldRendererTest.java b/forms/src/test/java/com/itextpdf/forms/form/renderer/InputFieldRendererTest.java index 7f1908b640..eb150199bd 100644 --- a/forms/src/test/java/com/itextpdf/forms/form/renderer/InputFieldRendererTest.java +++ b/forms/src/test/java/com/itextpdf/forms/form/renderer/InputFieldRendererTest.java @@ -25,7 +25,8 @@ This file is part of the iText (R) project. import com.itextpdf.forms.form.FormProperty; import com.itextpdf.forms.form.element.InputField; import com.itextpdf.io.source.ByteArrayOutputStream; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfAConformance; +import com.itextpdf.kernel.pdf.PdfConformance; import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfWriter; import com.itextpdf.layout.element.Paragraph; @@ -35,13 +36,12 @@ This file is part of the iText (R) project. import com.itextpdf.layout.renderer.IRenderer; import com.itextpdf.layout.renderer.ParagraphRenderer; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(UnitTest.class) +@Tag("UnitTest") public class InputFieldRendererTest extends ExtendedITextTest { private static final double EPS = 0.0001; @@ -51,7 +51,7 @@ public void nullPasswordTest() { InputFieldRenderer inputFieldRenderer = new InputFieldRenderer(new InputField("")); inputFieldRenderer.setProperty(FormProperty.FORM_FIELD_PASSWORD_FLAG, null); - Assert.assertFalse(inputFieldRenderer.isPassword()); + Assertions.assertFalse(inputFieldRenderer.isPassword()); } @Test @@ -59,7 +59,7 @@ public void nullSizeTest() { InputFieldRenderer inputFieldRenderer = new InputFieldRenderer(new InputField("")); inputFieldRenderer.setProperty(FormProperty.FORM_FIELD_SIZE, null); - Assert.assertEquals(20, inputFieldRenderer.getSize()); + Assertions.assertEquals(20, inputFieldRenderer.getSize()); } @Test @@ -68,9 +68,9 @@ public void setMinMaxWidthBasedOnFixedWidthWithAbsoluteWidthTest() { areaRenderer.setProperty(Property.FONT_SIZE, UnitValue.createPointValue(10)); MinMaxWidth minMaxWidth = new MinMaxWidth(); - Assert.assertTrue(areaRenderer.callSetMinMaxWidthBasedOnFixedWidth(minMaxWidth)); - Assert.assertEquals(122, minMaxWidth.getChildrenMaxWidth(), EPS); - Assert.assertEquals(122, minMaxWidth.getChildrenMinWidth(), EPS); + Assertions.assertTrue(areaRenderer.callSetMinMaxWidthBasedOnFixedWidth(minMaxWidth)); + Assertions.assertEquals(122, minMaxWidth.getChildrenMaxWidth(), EPS); + Assertions.assertEquals(122, minMaxWidth.getChildrenMinWidth(), EPS); } @Test @@ -80,9 +80,9 @@ public void setMinMaxWidthBasedOnFixedWidthWithoutAbsoluteWidthTest() { areaRenderer.setProperty(Property.FONT_SIZE, UnitValue.createPointValue(10)); MinMaxWidth minMaxWidth = new MinMaxWidth(); - Assert.assertTrue(areaRenderer.callSetMinMaxWidthBasedOnFixedWidth(minMaxWidth)); - Assert.assertEquals(122, minMaxWidth.getChildrenMaxWidth(), EPS); - Assert.assertEquals(0, minMaxWidth.getChildrenMinWidth(), EPS); + Assertions.assertTrue(areaRenderer.callSetMinMaxWidthBasedOnFixedWidth(minMaxWidth)); + Assertions.assertEquals(122, minMaxWidth.getChildrenMaxWidth(), EPS); + Assertions.assertEquals(0, minMaxWidth.getChildrenMinWidth(), EPS); } @Test @@ -92,31 +92,32 @@ public void setMinMaxWidthBasedOnFixedWidthWithoutAbsoluteWidthOnElementTest() { areaRenderer.setProperty(Property.FONT_SIZE, UnitValue.createPointValue(10)); MinMaxWidth minMaxWidth = new MinMaxWidth(); - Assert.assertTrue(areaRenderer.callSetMinMaxWidthBasedOnFixedWidth(minMaxWidth)); - Assert.assertEquals(122, minMaxWidth.getChildrenMaxWidth(), EPS); - Assert.assertEquals(0, minMaxWidth.getChildrenMinWidth(), EPS); + Assertions.assertTrue(areaRenderer.callSetMinMaxWidthBasedOnFixedWidth(minMaxWidth)); + Assertions.assertEquals(122, minMaxWidth.getChildrenMaxWidth(), EPS); + Assertions.assertEquals(0, minMaxWidth.getChildrenMinWidth(), EPS); } @Test public void pdfAConformanceLevelTest() { InputFieldRenderer inputFieldRenderer = new InputFieldRenderer(new InputField("")); - Assert.assertNull(inputFieldRenderer.getGenericConformanceLevel(null)); + Assertions.assertNull(inputFieldRenderer.getConformance(null)); } @Test public void pdfAConformanceLevelWithDocumentTest() { PdfDocument pdfDocument = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); InputFieldRenderer inputFieldRenderer = new InputFieldRenderer(new InputField("")); - Assert.assertNull(inputFieldRenderer.getGenericConformanceLevel(pdfDocument)); + Assertions.assertNotNull(inputFieldRenderer.getConformance(pdfDocument)); + Assertions.assertFalse(inputFieldRenderer.getConformance(pdfDocument).isPdfAOrUa()); } @Test public void pdfAConformanceLevelWithConformanceLevelTest() { PdfDocument pdfDocument = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); InputFieldRenderer inputFieldRenderer = new InputFieldRenderer(new InputField("")); - inputFieldRenderer.setProperty(FormProperty.FORM_CONFORMANCE_LEVEL, PdfAConformanceLevel.PDF_A_1B); - Assert.assertEquals(PdfAConformanceLevel.PDF_A_1B, inputFieldRenderer.getGenericConformanceLevel(pdfDocument)); + inputFieldRenderer.setProperty(FormProperty.FORM_CONFORMANCE_LEVEL, PdfConformance.PDF_A_1B); + Assertions.assertEquals(PdfAConformance.PDF_A_1B, inputFieldRenderer.getConformance(pdfDocument).getAConformance()); } @Test @@ -124,7 +125,7 @@ public void createParagraphRendererTest() { InputFieldRenderer inputFieldRendererWithoutPlaceholder = new InputFieldRenderer(new InputField("")); IRenderer paragraphRender = inputFieldRendererWithoutPlaceholder.createParagraphRenderer(""); - Assert.assertTrue(paragraphRender instanceof ParagraphRenderer); + Assertions.assertTrue(paragraphRender instanceof ParagraphRenderer); InputField inputFieldWithEmptyPlaceholder = new InputField(""); inputFieldWithEmptyPlaceholder.setPlaceholder(new Paragraph() { @@ -136,8 +137,8 @@ public IRenderer createRendererSubTree() { InputFieldRenderer inputFieldRendererWithEmptyPlaceholder = new InputFieldRenderer(inputFieldWithEmptyPlaceholder); paragraphRender = inputFieldRendererWithEmptyPlaceholder.createParagraphRenderer(""); - Assert.assertTrue(paragraphRender instanceof ParagraphRenderer); - Assert.assertFalse(paragraphRender instanceof CustomParagraphRenderer); + Assertions.assertTrue(paragraphRender instanceof ParagraphRenderer); + Assertions.assertFalse(paragraphRender instanceof CustomParagraphRenderer); InputField inputFieldWithPlaceholder = new InputField(""); inputFieldWithPlaceholder.setPlaceholder(new Paragraph() { @@ -154,7 +155,7 @@ public IRenderer createRendererSubTree() { InputFieldRenderer inputFieldRendererWithPlaceholder = new InputFieldRenderer(inputFieldWithPlaceholder); paragraphRender = inputFieldRendererWithPlaceholder.createParagraphRenderer(""); - Assert.assertTrue(paragraphRender instanceof CustomParagraphRenderer); + Assertions.assertTrue(paragraphRender instanceof CustomParagraphRenderer); } private static class CustomParagraphRenderer extends ParagraphRenderer { diff --git a/forms/src/test/java/com/itextpdf/forms/form/renderer/SelectFieldListBoxRendererTest.java b/forms/src/test/java/com/itextpdf/forms/form/renderer/SelectFieldListBoxRendererTest.java index 31c08a6c2b..f1bfb7b1ad 100644 --- a/forms/src/test/java/com/itextpdf/forms/form/renderer/SelectFieldListBoxRendererTest.java +++ b/forms/src/test/java/com/itextpdf/forms/form/renderer/SelectFieldListBoxRendererTest.java @@ -26,18 +26,17 @@ This file is part of the iText (R) project. import com.itextpdf.forms.form.element.AbstractSelectField; import com.itextpdf.forms.form.element.ListBoxField; import com.itextpdf.io.source.ByteArrayOutputStream; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfConformance; import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfWriter; import com.itextpdf.layout.renderer.IRenderer; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(UnitTest.class) +@Tag("UnitTest") public class SelectFieldListBoxRendererTest extends ExtendedITextTest { @Test @@ -45,7 +44,7 @@ public void getNextRendererTest() { SelectFieldListBoxRenderer listBoxRenderer = new SelectFieldListBoxRenderer(new ListBoxField("", 0, false)); IRenderer nextRenderer = listBoxRenderer.getNextRenderer(); - Assert.assertTrue(nextRenderer instanceof SelectFieldListBoxRenderer); + Assertions.assertTrue(nextRenderer instanceof SelectFieldListBoxRenderer); } @Test @@ -54,28 +53,29 @@ public void allowLastYLineRecursiveExtractionTest() { new CustomSelectFieldListBoxRenderer(new ListBoxField("", 0, false)); boolean lastY = listBoxRenderer.callAllowLastYLineRecursiveExtraction(); - Assert.assertFalse(lastY); + Assertions.assertFalse(lastY); } @Test public void pdfAConformanceLevelTest() { SelectFieldListBoxRenderer renderer = new SelectFieldListBoxRenderer(new ListBoxField("", 1, false)); - Assert.assertNull(renderer.getGenericConformanceLevel(null)); + Assertions.assertNull(renderer.getConformance(null)); } @Test public void pdfAConformanceLevelWithDocumentTest() { PdfDocument pdfDocument = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); SelectFieldListBoxRenderer renderer = new SelectFieldListBoxRenderer(new ListBoxField("", 1, false)); - Assert.assertNull(renderer.getGenericConformanceLevel(pdfDocument)); + Assertions.assertNotNull(renderer.getConformance(pdfDocument)); + Assertions.assertFalse(renderer.getConformance(pdfDocument).isPdfAOrUa()); } @Test public void pdfAConformanceLevelWithConformanceLevelTest() { PdfDocument pdfDocument = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); SelectFieldListBoxRenderer renderer = new SelectFieldListBoxRenderer(new ListBoxField("", 1, false)); - renderer.setProperty(FormProperty.FORM_CONFORMANCE_LEVEL, PdfAConformanceLevel.PDF_A_1B); - Assert.assertEquals(PdfAConformanceLevel.PDF_A_1B, renderer.getGenericConformanceLevel(pdfDocument)); + renderer.setProperty(FormProperty.FORM_CONFORMANCE_LEVEL, PdfConformance.PDF_A_1B); + Assertions.assertEquals(PdfConformance.PDF_A_1B, renderer.getConformance(pdfDocument)); } private static class CustomSelectFieldListBoxRenderer extends SelectFieldListBoxRenderer { diff --git a/forms/src/test/java/com/itextpdf/forms/form/renderer/TextAreaRendererTest.java b/forms/src/test/java/com/itextpdf/forms/form/renderer/TextAreaRendererTest.java index 5af8823bd5..1608cc722c 100644 --- a/forms/src/test/java/com/itextpdf/forms/form/renderer/TextAreaRendererTest.java +++ b/forms/src/test/java/com/itextpdf/forms/form/renderer/TextAreaRendererTest.java @@ -31,13 +31,12 @@ This file is part of the iText (R) project. import com.itextpdf.layout.properties.UnitValue; import com.itextpdf.layout.renderer.IRenderer; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class TextAreaRendererTest extends ExtendedITextTest { private static final double EPS = 0.0001; @@ -47,7 +46,7 @@ public void colsPropertyIsSetToNullTest() { TextAreaRenderer areaRenderer = new TextAreaRenderer(new TextArea("")); areaRenderer.setProperty(FormProperty.FORM_FIELD_COLS, null); - Assert.assertEquals(20, areaRenderer.getCols()); + Assertions.assertEquals(20, areaRenderer.getCols()); } @Test @@ -55,7 +54,7 @@ public void colsPropertyIsSetToZeroTest() { TextAreaRenderer areaRenderer = new TextAreaRenderer(new TextArea("")); areaRenderer.setProperty(FormProperty.FORM_FIELD_COLS, 0); - Assert.assertEquals(20, areaRenderer.getCols()); + Assertions.assertEquals(20, areaRenderer.getCols()); } @Test @@ -63,7 +62,7 @@ public void rowsPropertyIsSetToNullTest() { TextAreaRenderer areaRenderer = new TextAreaRenderer(new TextArea("")); areaRenderer.setProperty(FormProperty.FORM_FIELD_ROWS, null); - Assert.assertEquals(2, areaRenderer.getRows()); + Assertions.assertEquals(2, areaRenderer.getRows()); } @Test @@ -71,7 +70,7 @@ public void rowsPropertyIsSetToZeroTest() { TextAreaRenderer areaRenderer = new TextAreaRenderer(new TextArea("")); areaRenderer.setProperty(FormProperty.FORM_FIELD_ROWS, 0); - Assert.assertEquals(2, areaRenderer.getRows()); + Assertions.assertEquals(2, areaRenderer.getRows()); } @Test @@ -79,7 +78,7 @@ public void getRendererTest() { TextAreaRenderer areaRenderer = new TextAreaRenderer(new TextArea("")); IRenderer nextRenderer = areaRenderer.getNextRenderer(); - Assert.assertTrue(nextRenderer instanceof TextAreaRenderer); + Assertions.assertTrue(nextRenderer instanceof TextAreaRenderer); } @Test @@ -88,9 +87,9 @@ public void setMinMaxWidthBasedOnFixedWidthWithAbsoluteWidthTest() { areaRenderer.setProperty(Property.FONT_SIZE, UnitValue.createPointValue(10)); MinMaxWidth minMaxWidth = new MinMaxWidth(); - Assert.assertTrue(areaRenderer.callSetMinMaxWidthBasedOnFixedWidth(minMaxWidth)); - Assert.assertEquals(122, minMaxWidth.getChildrenMaxWidth(), EPS); - Assert.assertEquals(122, minMaxWidth.getChildrenMinWidth(), EPS); + Assertions.assertTrue(areaRenderer.callSetMinMaxWidthBasedOnFixedWidth(minMaxWidth)); + Assertions.assertEquals(122, minMaxWidth.getChildrenMaxWidth(), EPS); + Assertions.assertEquals(122, minMaxWidth.getChildrenMinWidth(), EPS); } @Test @@ -100,9 +99,9 @@ public void setMinMaxWidthBasedOnFixedWidthWithoutAbsoluteWidthTest() { areaRenderer.setProperty(Property.FONT_SIZE, UnitValue.createPointValue(10)); MinMaxWidth minMaxWidth = new MinMaxWidth(); - Assert.assertTrue(areaRenderer.callSetMinMaxWidthBasedOnFixedWidth(minMaxWidth)); - Assert.assertEquals(122, minMaxWidth.getChildrenMaxWidth(), EPS); - Assert.assertEquals(122, minMaxWidth.getChildrenMinWidth(), EPS); + Assertions.assertTrue(areaRenderer.callSetMinMaxWidthBasedOnFixedWidth(minMaxWidth)); + Assertions.assertEquals(122, minMaxWidth.getChildrenMaxWidth(), EPS); + Assertions.assertEquals(122, minMaxWidth.getChildrenMinWidth(), EPS); } @Test @@ -112,9 +111,9 @@ public void setMinMaxWidthBasedOnFixedWidthWithoutAbsoluteWidthOnElementTest() { areaRenderer.setProperty(Property.FONT_SIZE, UnitValue.createPointValue(10)); MinMaxWidth minMaxWidth = new MinMaxWidth(); - Assert.assertTrue(areaRenderer.callSetMinMaxWidthBasedOnFixedWidth(minMaxWidth)); - Assert.assertEquals(122, minMaxWidth.getChildrenMaxWidth(), EPS); - Assert.assertEquals(122, minMaxWidth.getChildrenMinWidth(), EPS); + Assertions.assertTrue(areaRenderer.callSetMinMaxWidthBasedOnFixedWidth(minMaxWidth)); + Assertions.assertEquals(122, minMaxWidth.getChildrenMaxWidth(), EPS); + Assertions.assertEquals(122, minMaxWidth.getChildrenMinWidth(), EPS); } @Test @@ -122,7 +121,7 @@ public void getLastYLineRecursivelyNoOccupiedAreaTest() { CustomTextAreaRenderer areaRenderer = new CustomTextAreaRenderer(new TextArea("")); Float lastY = areaRenderer.callGetLastYLineRecursively(); - Assert.assertNull(lastY); + Assertions.assertNull(lastY); } @Test @@ -131,7 +130,7 @@ public void getLastYLineRecursivelyEmptyOccupiedAreaTest() { areaRenderer.setOccupiedArea(new LayoutArea(1, null)); Float lastY = areaRenderer.callGetLastYLineRecursively(); - Assert.assertNull(lastY); + Assertions.assertNull(lastY); } @Test @@ -140,7 +139,7 @@ public void getLastYLineRecursivelyWithOccupiedAreaTest() { areaRenderer.setOccupiedArea(new LayoutArea(1, new Rectangle(100, 100, 100, 100))); Float lastY = areaRenderer.callGetLastYLineRecursively(); - Assert.assertEquals(100, lastY, EPS); + Assertions.assertEquals(100, lastY, EPS); } private static class CustomTextAreaRenderer extends TextAreaRenderer { diff --git a/forms/src/test/java/com/itextpdf/forms/util/RegisterDefaultDiContainerTest.java b/forms/src/test/java/com/itextpdf/forms/util/RegisterDefaultDiContainerTest.java index 98be2cffde..b0cd5b97cd 100644 --- a/forms/src/test/java/com/itextpdf/forms/util/RegisterDefaultDiContainerTest.java +++ b/forms/src/test/java/com/itextpdf/forms/util/RegisterDefaultDiContainerTest.java @@ -28,14 +28,12 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfWriter; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; - -@Category(UnitTest.class) +@Tag("UnitTest") public class RegisterDefaultDiContainerTest extends ExtendedITextTest { @Test @@ -43,6 +41,6 @@ public void testDefaultRegistrationFormsModule() { PdfDocument pdfDocument = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); OnDuplicateFormFieldNameStrategy strategy = pdfDocument.getDiContainer() .getInstance(OnDuplicateFormFieldNameStrategy.class); - Assert.assertEquals(MergeFieldsStrategy.class, strategy.getClass()); + Assertions.assertEquals(MergeFieldsStrategy.class, strategy.getClass()); } } diff --git a/forms/src/test/java/com/itextpdf/forms/widget/AppearanceCharacteristicsTest.java b/forms/src/test/java/com/itextpdf/forms/widget/AppearanceCharacteristicsTest.java index 77cd55d188..2d045ab5e7 100644 --- a/forms/src/test/java/com/itextpdf/forms/widget/AppearanceCharacteristicsTest.java +++ b/forms/src/test/java/com/itextpdf/forms/widget/AppearanceCharacteristicsTest.java @@ -36,24 +36,22 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.annot.PdfAnnotation; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; import java.util.Map; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; - -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class AppearanceCharacteristicsTest extends ExtendedITextTest { public static final String destinationFolder = "./target/test/com/itextpdf/forms/widget/AppearanceCharacteristicsTest/"; public static final String sourceFolder = "./src/test/resources/com/itextpdf/forms/widget/AppearanceCharacteristicsTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } @@ -103,7 +101,7 @@ public void formFieldBordersTest() throws IOException, InterruptedException { form.addField(beveledField); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder)); } @Test @@ -121,7 +119,7 @@ public void beveledBorderWithBackgroundTest() throws IOException, InterruptedExc form.addField(formField); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder)); } @Test @@ -139,7 +137,7 @@ public void dashedBorderWithBackgroundTest() throws IOException, InterruptedExce form.addField(formField); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder)); } @Test @@ -179,7 +177,7 @@ public void textStartsAfterFieldBorderTest() throws IOException, InterruptedExce form.addField(simpleFormField); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); } @Test @@ -196,7 +194,7 @@ public void fillFormWithRotatedFieldAndPageTest() throws IOException, Interrupte String errorMessage = new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_"); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -230,7 +228,7 @@ public void borderStyleInCreatedFormFieldsTest() throws IOException, Interrupted form.flattenFields(); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder)); } @Test @@ -251,6 +249,6 @@ public void updatingBorderStyleInFormFieldsTest() throws IOException, Interrupte form.flattenFields(); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder)); } } diff --git a/forms/src/test/java/com/itextpdf/forms/xfa/XFAFormTest.java b/forms/src/test/java/com/itextpdf/forms/xfa/XFAFormTest.java index 6ff625b74b..d083a9820d 100644 --- a/forms/src/test/java/com/itextpdf/forms/xfa/XFAFormTest.java +++ b/forms/src/test/java/com/itextpdf/forms/xfa/XFAFormTest.java @@ -31,23 +31,22 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.AssertUtil; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import org.w3c.dom.Node; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class XFAFormTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/forms/xfa/XFAFormTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/forms/xfa/XFAFormTest/"; public static final String XML = sourceFolder + "xfa.xml"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } @@ -63,7 +62,7 @@ public void createEmptyXFAFormTest01() throws IOException, InterruptedException doc.addNewPage(); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -77,7 +76,7 @@ public void createEmptyXFAFormTest02() throws IOException, InterruptedException doc.addNewPage(); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -91,7 +90,7 @@ public void createXFAFormTest() throws IOException, InterruptedException { doc.addNewPage(); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -109,7 +108,7 @@ public void findFieldName() throws IOException { XfaForm xfaForm = acroForm.getXfaForm(); xfaForm.findFieldName("TextField1"); String secondRun = xfaForm.findFieldName("TextField1"); - Assert.assertNotNull(secondRun); + Assertions.assertNotNull(secondRun); } @Test @@ -119,7 +118,7 @@ public void findFieldNameWithoutDataSet() throws IOException { PdfAcroForm acroForm = PdfFormCreator.getAcroForm(pdfDocument, true); XfaForm xfaForm = acroForm.getXfaForm(); String name = xfaForm.findFieldName("TextField1"); - Assert.assertNull(name); + Assertions.assertNull(name); } @Test @@ -130,8 +129,8 @@ public void extractXFADataTest() throws IOException { XfaForm xfa = new XfaForm(pdfDocument); Node node = xfa.findDatasetsNode("Number1"); - Assert.assertNotNull(node); - Assert.assertEquals("Number1", node.getNodeName()); + Assertions.assertNotNull(node); + Assertions.assertEquals("Number1", node.getNodeName()); } @Test @@ -139,8 +138,8 @@ public void extractNodeTextByPathText() throws IOException { String inFileName = sourceFolder + "TextField1.pdf"; try (PdfDocument pdfDocument = new PdfDocument(new PdfReader(inFileName))) { XfaForm xfaForm = new XfaForm(pdfDocument); - Assert.assertEquals("Test", xfaForm.getNodeTextByPath("xdp.datasets.data.form1")); - Assert.assertNull(xfaForm.getNodeTextByPath("xdp.datasets.noElement")); + Assertions.assertEquals("Test", xfaForm.getNodeTextByPath("xdp.datasets.data.form1")); + Assertions.assertNull(xfaForm.getNodeTextByPath("xdp.datasets.noElement")); } } } diff --git a/forms/src/test/java/com/itextpdf/forms/xfa/XfaSecurityTest.java b/forms/src/test/java/com/itextpdf/forms/xfa/XfaSecurityTest.java index 6f89bd51e8..23f0e68636 100644 --- a/forms/src/test/java/com/itextpdf/forms/xfa/XfaSecurityTest.java +++ b/forms/src/test/java/com/itextpdf/forms/xfa/XfaSecurityTest.java @@ -22,29 +22,26 @@ This file is part of the iText (R) project. */ package com.itextpdf.forms.xfa; -import com.itextpdf.forms.PdfAcroForm; import com.itextpdf.forms.fields.PdfFormCreator; import com.itextpdf.kernel.exceptions.PdfException; import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfReader; import com.itextpdf.kernel.pdf.PdfWriter; -import com.itextpdf.kernel.utils.DefaultSafeXmlParserFactory; import com.itextpdf.kernel.utils.XmlProcessorCreator; import com.itextpdf.test.ExceptionTestUtil; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.nio.charset.StandardCharsets; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class XfaSecurityTest extends ExtendedITextTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/forms/xfa/XfaSecurityTest/"; @@ -58,7 +55,7 @@ public class XfaSecurityTest extends ExtendedITextTest { + " uuid=\"36ac5111-55c5-4172-b0c1-0cbd783e2fcf\">\n" + "\n"; - @Before + @BeforeEach public void resetXmlParserFactoryToDefault() { XmlProcessorCreator.setXmlParserFactory(null); } @@ -84,10 +81,10 @@ public void xfaExternalFileCustomFactoryTest() throws IOException { XmlProcessorCreator.setXmlParserFactory(new SecurityTestXmlParserFactory()); try (PdfDocument pdfDoc = new PdfDocument(new PdfReader(inFileName), new PdfWriter(new ByteArrayOutputStream()))) { - Exception e = Assert.assertThrows(PdfException.class, + Exception e = Assertions.assertThrows(PdfException.class, () -> PdfFormCreator.getAcroForm(pdfDoc, true) ); - Assert.assertEquals(ExceptionTestUtil.getXxeTestMessage(), e.getMessage()); + Assertions.assertEquals(ExceptionTestUtil.getXxeTestMessage(), e.getMessage()); } } @@ -95,16 +92,16 @@ public void xfaExternalFileCustomFactoryTest() throws IOException { public void xfaExternalFileXfaFormTest() throws IOException { String inFileName = SOURCE_FOLDER + "xfaExternalFile.pdf"; try (PdfDocument pdfDoc = new PdfDocument(new PdfReader(inFileName))) { - Exception e = Assert.assertThrows(PdfException.class, () -> new XfaForm(pdfDoc)); - Assert.assertEquals(DTD_EXCEPTION_MESSAGE, e.getMessage()); + Exception e = Assertions.assertThrows(PdfException.class, () -> new XfaForm(pdfDoc)); + Assertions.assertEquals(DTD_EXCEPTION_MESSAGE, e.getMessage()); } } @Test public void xfaWithDtdXfaFormTest() throws IOException { try (InputStream inputStream = new ByteArrayInputStream(XFA_WITH_DTD_XML.getBytes(StandardCharsets.UTF_8))) { - Exception e = Assert.assertThrows(PdfException.class, () -> new XfaForm(inputStream)); - Assert.assertEquals(DTD_EXCEPTION_MESSAGE, e.getMessage()); + Exception e = Assertions.assertThrows(PdfException.class, () -> new XfaForm(inputStream)); + Assertions.assertEquals(DTD_EXCEPTION_MESSAGE, e.getMessage()); } } @@ -112,18 +109,18 @@ public void xfaWithDtdXfaFormTest() throws IOException { public void fillXfaFormTest() throws IOException { try (InputStream inputStream = new ByteArrayInputStream(XFA_WITH_DTD_XML.getBytes(StandardCharsets.UTF_8))) { XfaForm form = new XfaForm(); - Exception e = Assert.assertThrows(PdfException.class, () -> form.fillXfaForm(inputStream, true)); - Assert.assertEquals(DTD_EXCEPTION_MESSAGE, e.getMessage()); + Exception e = Assertions.assertThrows(PdfException.class, () -> form.fillXfaForm(inputStream, true)); + Assertions.assertEquals(DTD_EXCEPTION_MESSAGE, e.getMessage()); } } private void xfaSecurityExceptionTest(String inputFileName) throws IOException { try (PdfDocument pdfDoc = new PdfDocument(new PdfReader(inputFileName), new PdfWriter(new ByteArrayOutputStream()))) { - Exception e = Assert.assertThrows(PdfException.class, + Exception e = Assertions.assertThrows(PdfException.class, () -> PdfFormCreator.getAcroForm(pdfDoc, true) ); - Assert.assertEquals(DTD_EXCEPTION_MESSAGE, e.getMessage()); + Assertions.assertEquals(DTD_EXCEPTION_MESSAGE, e.getMessage()); } } } diff --git a/forms/src/test/java/com/itextpdf/forms/xfdf/XfdfReaderUnitTest.java b/forms/src/test/java/com/itextpdf/forms/xfdf/XfdfReaderUnitTest.java index 9b5c15e428..f8b9cbffba 100644 --- a/forms/src/test/java/com/itextpdf/forms/xfdf/XfdfReaderUnitTest.java +++ b/forms/src/test/java/com/itextpdf/forms/xfdf/XfdfReaderUnitTest.java @@ -32,16 +32,14 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.ByteArrayOutputStream; import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; - -@Category(UnitTest.class) +@Tag("UnitTest") public class XfdfReaderUnitTest extends ExtendedITextTest { @Test @@ -72,9 +70,9 @@ public void xfdfSquareAnnotationWithoutFringe(){ xfdfReader.mergeXfdfIntoPdf(xfdfObject, pdfDocument, "smth"); List annotations = pdfDocument.getPage(1).getAnnotations(); - Assert.assertNotNull(annotations); - Assert.assertEquals(1, annotations.size()); - Assert.assertEquals(PdfName.Square, annotations.get(0).getSubtype()); + Assertions.assertNotNull(annotations); + Assertions.assertEquals(1, annotations.size()); + Assertions.assertEquals(PdfName.Square, annotations.get(0).getSubtype()); pdfDocument.close(); } diff --git a/forms/src/test/java/com/itextpdf/forms/xfdf/XfdfSecurityTest.java b/forms/src/test/java/com/itextpdf/forms/xfdf/XfdfSecurityTest.java index 450b91ba57..2aa5591021 100644 --- a/forms/src/test/java/com/itextpdf/forms/xfdf/XfdfSecurityTest.java +++ b/forms/src/test/java/com/itextpdf/forms/xfdf/XfdfSecurityTest.java @@ -27,17 +27,16 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.utils.XmlProcessorCreator; import com.itextpdf.test.ExceptionTestUtil; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.nio.charset.StandardCharsets; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class XfdfSecurityTest extends ExtendedITextTest { private static final String XFDF_WITH_XXE = " \n" @@ -59,10 +58,10 @@ public void xxeVulnerabilityXfdfTest() throws IOException { XmlProcessorCreator.setXmlParserFactory(null); try (InputStream inputStream = new ByteArrayInputStream(XFDF_WITH_XXE.getBytes(StandardCharsets.UTF_8))) { - Exception e = Assert.assertThrows(PdfException.class, + Exception e = Assertions.assertThrows(PdfException.class, () -> XfdfFileUtils.createXfdfDocumentFromStream(inputStream) ); - Assert.assertEquals(ExceptionTestUtil.getDoctypeIsDisallowedExceptionMessage(), e.getMessage()); + Assertions.assertEquals(ExceptionTestUtil.getDoctypeIsDisallowedExceptionMessage(), e.getMessage()); } } @@ -71,10 +70,10 @@ public void xxeVulnerabilityXfdfCustomXmlParserTest() throws IOException { XmlProcessorCreator.setXmlParserFactory(new SecurityTestXmlParserFactory()); try (InputStream inputStream = new ByteArrayInputStream(XFDF_WITH_XXE.getBytes(StandardCharsets.UTF_8))) { - Exception e = Assert.assertThrows(PdfException.class, + Exception e = Assertions.assertThrows(PdfException.class, () -> XfdfFileUtils.createXfdfDocumentFromStream(inputStream) ); - Assert.assertEquals("Test message", e.getMessage()); + Assertions.assertEquals("Test message", e.getMessage()); } } @@ -82,9 +81,9 @@ public void xxeVulnerabilityXfdfCustomXmlParserTest() public void customXmlParserCreateNewXfdfDocumentExceptionTest() throws IOException { XmlProcessorCreator.setXmlParserFactory(new ExceptionTestXmlParserFactory()); - Exception e = Assert.assertThrows(PdfException.class, + Exception e = Assertions.assertThrows(PdfException.class, () -> XfdfFileUtils.createNewXfdfDocument() ); - Assert.assertEquals(ExceptionTestUtil.getXxeTestMessage(), e.getMessage()); + Assertions.assertEquals(ExceptionTestUtil.getXxeTestMessage(), e.getMessage()); } } diff --git a/forms/src/test/java/com/itextpdf/forms/xfdf/XfdfWriterUnitTest.java b/forms/src/test/java/com/itextpdf/forms/xfdf/XfdfWriterUnitTest.java index e597c04923..ca8667f665 100644 --- a/forms/src/test/java/com/itextpdf/forms/xfdf/XfdfWriterUnitTest.java +++ b/forms/src/test/java/com/itextpdf/forms/xfdf/XfdfWriterUnitTest.java @@ -23,19 +23,18 @@ This file is part of the iText (R) project. package com.itextpdf.forms.xfdf; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.util.ArrayList; import java.util.List; import javax.xml.parsers.ParserConfigurationException; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; -@Category(UnitTest.class) +@Tag("UnitTest") public class XfdfWriterUnitTest extends ExtendedITextTest { @Test @@ -55,8 +54,8 @@ public void fieldEmptyValueUnitTest() throws ParserConfigurationException { Node childOfFields = fields.getFirstChild(); - Assert.assertNotNull(childOfFields); - Assert.assertNull(childOfFields.getFirstChild()); + Assertions.assertNotNull(childOfFields); + Assertions.assertNull(childOfFields.getFirstChild()); } @Test @@ -75,8 +74,8 @@ public void fieldNullValueUnitTest() throws ParserConfigurationException { Node childOfFields = fields.getFirstChild(); - Assert.assertNotNull(childOfFields); - Assert.assertNull(childOfFields.getFirstChild()); + Assertions.assertNotNull(childOfFields); + Assertions.assertNull(childOfFields.getFirstChild()); } @Test @@ -96,8 +95,8 @@ public void fieldWithValueUnitTest() throws ParserConfigurationException { Node childOfFields = fields.getFirstChild(); - Assert.assertNotNull(childOfFields); - Assert.assertEquals("value", childOfFields.getFirstChild().getNodeName()); - Assert.assertEquals("testValue", childOfFields.getFirstChild().getTextContent()); + Assertions.assertNotNull(childOfFields); + Assertions.assertEquals("value", childOfFields.getFirstChild().getNodeName()); + Assertions.assertEquals("testValue", childOfFields.getFirstChild().getTextContent()); } } diff --git a/forms/src/test/resources/com/itextpdf/forms/FormFieldAppendTest/Form_Filled.pdf b/forms/src/test/resources/com/itextpdf/forms/FormFieldAppendTest/Form_Filled.pdf deleted file mode 100644 index c6dfa036c8..0000000000 Binary files a/forms/src/test/resources/com/itextpdf/forms/FormFieldAppendTest/Form_Filled.pdf and /dev/null differ diff --git a/forms/src/test/resources/com/itextpdf/forms/PdfAcroFormIntegrationTest/cmp_formWithSameFieldReferences.pdf b/forms/src/test/resources/com/itextpdf/forms/PdfAcroFormIntegrationTest/cmp_formWithSameFieldReferences.pdf new file mode 100644 index 0000000000..ea4260551c Binary files /dev/null and b/forms/src/test/resources/com/itextpdf/forms/PdfAcroFormIntegrationTest/cmp_formWithSameFieldReferences.pdf differ diff --git a/forms/src/test/resources/com/itextpdf/forms/PdfAcroFormIntegrationTest/formWithSameFieldReferences.pdf b/forms/src/test/resources/com/itextpdf/forms/PdfAcroFormIntegrationTest/formWithSameFieldReferences.pdf new file mode 100644 index 0000000000..045ce2d8e0 Binary files /dev/null and b/forms/src/test/resources/com/itextpdf/forms/PdfAcroFormIntegrationTest/formWithSameFieldReferences.pdf differ diff --git a/forms/src/test/resources/com/itextpdf/forms/PdfChoiceFieldTest/cmp_choiceFieldsSetValueTest.pdf b/forms/src/test/resources/com/itextpdf/forms/PdfChoiceFieldTest/cmp_choiceFieldsSetValueTest.pdf index e486ae965c..504a2fbb96 100644 Binary files a/forms/src/test/resources/com/itextpdf/forms/PdfChoiceFieldTest/cmp_choiceFieldsSetValueTest.pdf and b/forms/src/test/resources/com/itextpdf/forms/PdfChoiceFieldTest/cmp_choiceFieldsSetValueTest.pdf differ diff --git a/forms/src/test/resources/com/itextpdf/forms/PdfChoiceFieldTest/cmp_choiceFieldsWithUnicodeTest.pdf b/forms/src/test/resources/com/itextpdf/forms/PdfChoiceFieldTest/cmp_choiceFieldsWithUnicodeTest.pdf index 12aebb8013..9f87d03e36 100644 Binary files a/forms/src/test/resources/com/itextpdf/forms/PdfChoiceFieldTest/cmp_choiceFieldsWithUnicodeTest.pdf and b/forms/src/test/resources/com/itextpdf/forms/PdfChoiceFieldTest/cmp_choiceFieldsWithUnicodeTest.pdf differ diff --git a/forms/src/test/resources/com/itextpdf/forms/PdfChoiceFieldTest/cmp_comboNoHighlightCenteredTextOfChosenFirstItemTest.pdf b/forms/src/test/resources/com/itextpdf/forms/PdfChoiceFieldTest/cmp_comboNoHighlightCenteredTextOfChosenFirstItemTest.pdf index a38e49cc5d..234af1ce9a 100644 Binary files a/forms/src/test/resources/com/itextpdf/forms/PdfChoiceFieldTest/cmp_comboNoHighlightCenteredTextOfChosenFirstItemTest.pdf and b/forms/src/test/resources/com/itextpdf/forms/PdfChoiceFieldTest/cmp_comboNoHighlightCenteredTextOfChosenFirstItemTest.pdf differ diff --git a/forms/src/test/resources/com/itextpdf/forms/PdfChoiceFieldTest/cmp_corruptedOptAndValueSetToNullTest.pdf b/forms/src/test/resources/com/itextpdf/forms/PdfChoiceFieldTest/cmp_corruptedOptAndValueSetToNullTest.pdf index 955b6ff46c..b2d908e99e 100644 Binary files a/forms/src/test/resources/com/itextpdf/forms/PdfChoiceFieldTest/cmp_corruptedOptAndValueSetToNullTest.pdf and b/forms/src/test/resources/com/itextpdf/forms/PdfChoiceFieldTest/cmp_corruptedOptAndValueSetToNullTest.pdf differ diff --git a/forms/src/test/resources/com/itextpdf/forms/PdfChoiceFieldTest/cmp_longOptionWrappedIntoTwoLinesTest.pdf b/forms/src/test/resources/com/itextpdf/forms/PdfChoiceFieldTest/cmp_longOptionWrappedIntoTwoLinesTest.pdf index f77abb317a..5fdd28ee68 100644 Binary files a/forms/src/test/resources/com/itextpdf/forms/PdfChoiceFieldTest/cmp_longOptionWrappedIntoTwoLinesTest.pdf and b/forms/src/test/resources/com/itextpdf/forms/PdfChoiceFieldTest/cmp_longOptionWrappedIntoTwoLinesTest.pdf differ diff --git a/forms/src/test/resources/com/itextpdf/forms/PdfChoiceFieldTest/cmp_multiSelectByIndexOutOfBoundsTest.pdf b/forms/src/test/resources/com/itextpdf/forms/PdfChoiceFieldTest/cmp_multiSelectByIndexOutOfBoundsTest.pdf index 45e7b2be1d..610912e700 100644 Binary files a/forms/src/test/resources/com/itextpdf/forms/PdfChoiceFieldTest/cmp_multiSelectByIndexOutOfBoundsTest.pdf and b/forms/src/test/resources/com/itextpdf/forms/PdfChoiceFieldTest/cmp_multiSelectByIndexOutOfBoundsTest.pdf differ diff --git a/forms/src/test/resources/com/itextpdf/forms/PdfChoiceFieldTest/cmp_multiSelectByValueTest.pdf b/forms/src/test/resources/com/itextpdf/forms/PdfChoiceFieldTest/cmp_multiSelectByValueTest.pdf index ffc4015922..df10ca14dd 100644 Binary files a/forms/src/test/resources/com/itextpdf/forms/PdfChoiceFieldTest/cmp_multiSelectByValueTest.pdf and b/forms/src/test/resources/com/itextpdf/forms/PdfChoiceFieldTest/cmp_multiSelectByValueTest.pdf differ diff --git a/forms/src/test/resources/com/itextpdf/forms/PdfChoiceFieldTest/cmp_noWarningOnValueNotOfOptComboEditTest.pdf b/forms/src/test/resources/com/itextpdf/forms/PdfChoiceFieldTest/cmp_noWarningOnValueNotOfOptComboEditTest.pdf index 48b01bb850..5722b654e8 100644 Binary files a/forms/src/test/resources/com/itextpdf/forms/PdfChoiceFieldTest/cmp_noWarningOnValueNotOfOptComboEditTest.pdf and b/forms/src/test/resources/com/itextpdf/forms/PdfChoiceFieldTest/cmp_noWarningOnValueNotOfOptComboEditTest.pdf differ diff --git a/forms/src/test/resources/com/itextpdf/forms/PdfChoiceFieldTest/cmp_notInstanceOfPdfChoiceFormFieldTest.pdf b/forms/src/test/resources/com/itextpdf/forms/PdfChoiceFieldTest/cmp_notInstanceOfPdfChoiceFormFieldTest.pdf index 959b0cf421..523c29b0b1 100644 Binary files a/forms/src/test/resources/com/itextpdf/forms/PdfChoiceFieldTest/cmp_notInstanceOfPdfChoiceFormFieldTest.pdf and b/forms/src/test/resources/com/itextpdf/forms/PdfChoiceFieldTest/cmp_notInstanceOfPdfChoiceFormFieldTest.pdf differ diff --git a/forms/src/test/resources/com/itextpdf/forms/PdfChoiceFieldTest/cmp_selectByValueRemoveIKeyTest.pdf b/forms/src/test/resources/com/itextpdf/forms/PdfChoiceFieldTest/cmp_selectByValueRemoveIKeyTest.pdf index ddcb212d4e..fdc407fd3a 100644 Binary files a/forms/src/test/resources/com/itextpdf/forms/PdfChoiceFieldTest/cmp_selectByValueRemoveIKeyTest.pdf and b/forms/src/test/resources/com/itextpdf/forms/PdfChoiceFieldTest/cmp_selectByValueRemoveIKeyTest.pdf differ diff --git a/forms/src/test/resources/com/itextpdf/forms/PdfChoiceFieldTest/cmp_topIndexTest.pdf b/forms/src/test/resources/com/itextpdf/forms/PdfChoiceFieldTest/cmp_topIndexTest.pdf index 88f28dc0a5..127407f80b 100644 Binary files a/forms/src/test/resources/com/itextpdf/forms/PdfChoiceFieldTest/cmp_topIndexTest.pdf and b/forms/src/test/resources/com/itextpdf/forms/PdfChoiceFieldTest/cmp_topIndexTest.pdf differ diff --git a/forms/src/test/resources/com/itextpdf/forms/PdfEncryptionTest/cmp_encryptAes256Pdf2PermissionsTest01.pdf b/forms/src/test/resources/com/itextpdf/forms/PdfEncryptionTest/cmp_encryptAes256Pdf2PermissionsTest01.pdf index ba3567db40..5635669094 100644 Binary files a/forms/src/test/resources/com/itextpdf/forms/PdfEncryptionTest/cmp_encryptAes256Pdf2PermissionsTest01.pdf and b/forms/src/test/resources/com/itextpdf/forms/PdfEncryptionTest/cmp_encryptAes256Pdf2PermissionsTest01.pdf differ diff --git a/forms/src/test/resources/com/itextpdf/forms/PdfEncryptionTest/cmp_encryptAes256Pdf2PermissionsTest02.pdf b/forms/src/test/resources/com/itextpdf/forms/PdfEncryptionTest/cmp_encryptAes256Pdf2PermissionsTest02.pdf index 6da4cf233f..e554cbc19f 100644 Binary files a/forms/src/test/resources/com/itextpdf/forms/PdfEncryptionTest/cmp_encryptAes256Pdf2PermissionsTest02.pdf and b/forms/src/test/resources/com/itextpdf/forms/PdfEncryptionTest/cmp_encryptAes256Pdf2PermissionsTest02.pdf differ diff --git a/forms/src/test/resources/com/itextpdf/forms/PdfFormCopyTest/cmp_copyFields08.pdf b/forms/src/test/resources/com/itextpdf/forms/PdfFormCopyTest/cmp_copyFields08.pdf deleted file mode 100644 index fb0e612306..0000000000 Binary files a/forms/src/test/resources/com/itextpdf/forms/PdfFormCopyTest/cmp_copyFields08.pdf and /dev/null differ diff --git a/forms/src/test/resources/com/itextpdf/forms/PdfFormCopyTest/copyFields12.pdf b/forms/src/test/resources/com/itextpdf/forms/PdfFormCopyTest/copyFields12.pdf deleted file mode 100644 index 1da7d68446..0000000000 Binary files a/forms/src/test/resources/com/itextpdf/forms/PdfFormCopyTest/copyFields12.pdf and /dev/null differ diff --git a/forms/src/test/resources/com/itextpdf/forms/PdfFormFieldTest/FreeSans.ttf b/forms/src/test/resources/com/itextpdf/forms/PdfFormFieldTest/FreeSans.ttf deleted file mode 100644 index 4b06bd7822..0000000000 Binary files a/forms/src/test/resources/com/itextpdf/forms/PdfFormFieldTest/FreeSans.ttf and /dev/null differ diff --git a/forms/src/test/resources/com/itextpdf/forms/PdfFormFieldTest/blank.pdf b/forms/src/test/resources/com/itextpdf/forms/PdfFormFieldTest/blank.pdf deleted file mode 100644 index 9bce695a05..0000000000 Binary files a/forms/src/test/resources/com/itextpdf/forms/PdfFormFieldTest/blank.pdf and /dev/null differ diff --git a/forms/src/test/resources/com/itextpdf/forms/PdfFormFieldTest/cmp_choiceFieldAutoSize01Test.pdf b/forms/src/test/resources/com/itextpdf/forms/PdfFormFieldTest/cmp_choiceFieldAutoSize01Test.pdf index 7af2298409..9f66295c44 100644 Binary files a/forms/src/test/resources/com/itextpdf/forms/PdfFormFieldTest/cmp_choiceFieldAutoSize01Test.pdf and b/forms/src/test/resources/com/itextpdf/forms/PdfFormFieldTest/cmp_choiceFieldAutoSize01Test.pdf differ diff --git a/forms/src/test/resources/com/itextpdf/forms/PdfFormFieldTest/cmp_choiceFieldAutoSize02Test.pdf b/forms/src/test/resources/com/itextpdf/forms/PdfFormFieldTest/cmp_choiceFieldAutoSize02Test.pdf index e6b295a72e..5fa41700d9 100644 Binary files a/forms/src/test/resources/com/itextpdf/forms/PdfFormFieldTest/cmp_choiceFieldAutoSize02Test.pdf and b/forms/src/test/resources/com/itextpdf/forms/PdfFormFieldTest/cmp_choiceFieldAutoSize02Test.pdf differ diff --git a/forms/src/test/resources/com/itextpdf/forms/PdfFormFieldTest/cmp_choiceFieldTest01.pdf b/forms/src/test/resources/com/itextpdf/forms/PdfFormFieldTest/cmp_choiceFieldTest01.pdf index fd731e932b..62aa5fd424 100644 Binary files a/forms/src/test/resources/com/itextpdf/forms/PdfFormFieldTest/cmp_choiceFieldTest01.pdf and b/forms/src/test/resources/com/itextpdf/forms/PdfFormFieldTest/cmp_choiceFieldTest01.pdf differ diff --git a/forms/src/test/resources/com/itextpdf/forms/PdfFormFieldTest/cmp_formFieldWithFloatBorder.pdf b/forms/src/test/resources/com/itextpdf/forms/PdfFormFieldTest/cmp_formFieldWithFloatBorder.pdf index eda29e9c8e..4c51a6e25d 100644 Binary files a/forms/src/test/resources/com/itextpdf/forms/PdfFormFieldTest/cmp_formFieldWithFloatBorder.pdf and b/forms/src/test/resources/com/itextpdf/forms/PdfFormFieldTest/cmp_formFieldWithFloatBorder.pdf differ diff --git a/forms/src/test/resources/com/itextpdf/forms/PdfFormFieldTest/cmp_maxLenColoredTest.pdf b/forms/src/test/resources/com/itextpdf/forms/PdfFormFieldTest/cmp_maxLenColoredTest.pdf index 9be43336d5..294e248d67 100644 Binary files a/forms/src/test/resources/com/itextpdf/forms/PdfFormFieldTest/cmp_maxLenColoredTest.pdf and b/forms/src/test/resources/com/itextpdf/forms/PdfFormFieldTest/cmp_maxLenColoredTest.pdf differ diff --git a/forms/src/test/resources/com/itextpdf/forms/PdfFormFieldTest/cmp_maxLenDeepInheritanceTest.pdf b/forms/src/test/resources/com/itextpdf/forms/PdfFormFieldTest/cmp_maxLenDeepInheritanceTest.pdf index 2a078731f2..762f7f115f 100644 Binary files a/forms/src/test/resources/com/itextpdf/forms/PdfFormFieldTest/cmp_maxLenDeepInheritanceTest.pdf and b/forms/src/test/resources/com/itextpdf/forms/PdfFormFieldTest/cmp_maxLenDeepInheritanceTest.pdf differ diff --git a/forms/src/test/resources/com/itextpdf/forms/PdfFormFieldTest/cmp_maxLenInheritanceTest.pdf b/forms/src/test/resources/com/itextpdf/forms/PdfFormFieldTest/cmp_maxLenInheritanceTest.pdf index 1044150545..35a9ef00da 100644 Binary files a/forms/src/test/resources/com/itextpdf/forms/PdfFormFieldTest/cmp_maxLenInheritanceTest.pdf and b/forms/src/test/resources/com/itextpdf/forms/PdfFormFieldTest/cmp_maxLenInheritanceTest.pdf differ diff --git a/forms/src/test/resources/com/itextpdf/forms/PdfFormFieldTest/cmp_maxLenWithSetCombFlagAppearanceTest.pdf b/forms/src/test/resources/com/itextpdf/forms/PdfFormFieldTest/cmp_maxLenWithSetCombFlagAppearanceTest.pdf index 2eaf41080a..5a36797ec4 100644 Binary files a/forms/src/test/resources/com/itextpdf/forms/PdfFormFieldTest/cmp_maxLenWithSetCombFlagAppearanceTest.pdf and b/forms/src/test/resources/com/itextpdf/forms/PdfFormFieldTest/cmp_maxLenWithSetCombFlagAppearanceTest.pdf differ diff --git a/forms/src/test/resources/com/itextpdf/forms/PdfFormFieldTest/cmp_noMaxLenWithSetCombFlagTest.pdf b/forms/src/test/resources/com/itextpdf/forms/PdfFormFieldTest/cmp_noMaxLenWithSetCombFlagTest.pdf index 7918f1b2ff..0034cbe7a4 100644 Binary files a/forms/src/test/resources/com/itextpdf/forms/PdfFormFieldTest/cmp_noMaxLenWithSetCombFlagTest.pdf and b/forms/src/test/resources/com/itextpdf/forms/PdfFormFieldTest/cmp_noMaxLenWithSetCombFlagTest.pdf differ diff --git a/forms/src/test/resources/com/itextpdf/forms/PdfFormFieldTest/cmp_pdfWithDifferentFieldsTest.pdf b/forms/src/test/resources/com/itextpdf/forms/PdfFormFieldTest/cmp_pdfWithDifferentFieldsTest.pdf index 47b9dc46e2..6a15677748 100644 Binary files a/forms/src/test/resources/com/itextpdf/forms/PdfFormFieldTest/cmp_pdfWithDifferentFieldsTest.pdf and b/forms/src/test/resources/com/itextpdf/forms/PdfFormFieldTest/cmp_pdfWithDifferentFieldsTest.pdf differ diff --git a/forms/src/test/resources/com/itextpdf/forms/PdfFormFieldTest/cmp_regenerateMaxLenCombTest.pdf b/forms/src/test/resources/com/itextpdf/forms/PdfFormFieldTest/cmp_regenerateMaxLenCombTest.pdf index ff9d7db8c3..950c609c82 100644 Binary files a/forms/src/test/resources/com/itextpdf/forms/PdfFormFieldTest/cmp_regenerateMaxLenCombTest.pdf and b/forms/src/test/resources/com/itextpdf/forms/PdfFormFieldTest/cmp_regenerateMaxLenCombTest.pdf differ diff --git a/forms/src/test/resources/com/itextpdf/forms/PdfFormFieldTest/cmp_setNeedAppearancesInAppendModeTest.pdf b/forms/src/test/resources/com/itextpdf/forms/PdfFormFieldTest/cmp_setNeedAppearancesInAppendModeTest.pdf deleted file mode 100644 index 3a2f4c8a26..0000000000 Binary files a/forms/src/test/resources/com/itextpdf/forms/PdfFormFieldTest/cmp_setNeedAppearancesInAppendModeTest.pdf and /dev/null differ diff --git a/forms/src/test/resources/com/itextpdf/forms/PdfFormFieldTest/cmp_setSignatureFlagsInAppendModeTest.pdf b/forms/src/test/resources/com/itextpdf/forms/PdfFormFieldTest/cmp_setSignatureFlagsInAppendModeTest.pdf deleted file mode 100644 index 9cd116a644..0000000000 Binary files a/forms/src/test/resources/com/itextpdf/forms/PdfFormFieldTest/cmp_setSignatureFlagsInAppendModeTest.pdf and /dev/null differ diff --git a/forms/src/test/resources/com/itextpdf/forms/PdfFormFieldTest/cmp_setValueWithDisplayTest.pdf b/forms/src/test/resources/com/itextpdf/forms/PdfFormFieldTest/cmp_setValueWithDisplayTest.pdf index 7a456b4fe4..845d123400 100644 Binary files a/forms/src/test/resources/com/itextpdf/forms/PdfFormFieldTest/cmp_setValueWithDisplayTest.pdf and b/forms/src/test/resources/com/itextpdf/forms/PdfFormFieldTest/cmp_setValueWithDisplayTest.pdf differ diff --git a/forms/src/test/resources/com/itextpdf/forms/PdfFormFieldTest/fontAutoSizeButtonFieldTest.pdf b/forms/src/test/resources/com/itextpdf/forms/PdfFormFieldTest/fontAutoSizeButtonFieldTest.pdf deleted file mode 100644 index 7e83cedfb9..0000000000 Binary files a/forms/src/test/resources/com/itextpdf/forms/PdfFormFieldTest/fontAutoSizeButtonFieldTest.pdf and /dev/null differ diff --git a/forms/src/test/resources/com/itextpdf/forms/XfdfReaderTest/cmp_xfdfDropDown.pdf b/forms/src/test/resources/com/itextpdf/forms/XfdfReaderTest/cmp_xfdfDropDown.pdf index 0218a7c84b..c57e22b437 100644 Binary files a/forms/src/test/resources/com/itextpdf/forms/XfdfReaderTest/cmp_xfdfDropDown.pdf and b/forms/src/test/resources/com/itextpdf/forms/XfdfReaderTest/cmp_xfdfDropDown.pdf differ diff --git a/forms/src/test/resources/com/itextpdf/forms/XfdfReaderTest/cmp_xfdfList.pdf b/forms/src/test/resources/com/itextpdf/forms/XfdfReaderTest/cmp_xfdfList.pdf index db29b7fb5f..27637b7755 100644 Binary files a/forms/src/test/resources/com/itextpdf/forms/XfdfReaderTest/cmp_xfdfList.pdf and b/forms/src/test/resources/com/itextpdf/forms/XfdfReaderTest/cmp_xfdfList.pdf differ diff --git a/forms/src/test/resources/com/itextpdf/forms/XfdfReaderTest/data.xfdf b/forms/src/test/resources/com/itextpdf/forms/XfdfReaderTest/data.xfdf deleted file mode 100644 index 02c346fcb5..0000000000 --- a/forms/src/test/resources/com/itextpdf/forms/XfdfReaderTest/data.xfdf +++ /dev/null @@ -1,13 +0,0 @@ - - - -Santaaimonce -Developer -Alphabet Street -Minneapolis -Minnesota -Use iText to fill out interactive form using data stored in XFDF file. -If you are a C# developer, use iTextSharp. - - - \ No newline at end of file diff --git a/forms/src/test/resources/com/itextpdf/forms/XfdfReaderTest/list_register.xfdf b/forms/src/test/resources/com/itextpdf/forms/XfdfReaderTest/list_register.xfdf deleted file mode 100644 index 5e26322aa0..0000000000 --- a/forms/src/test/resources/com/itextpdf/forms/XfdfReaderTest/list_register.xfdf +++ /dev/null @@ -1,19 +0,0 @@ - - - - -Bruno Lowagie - - -Baeyensstraat 121, -Sint-Amandsberg - - -9040 - - -bruno@lowagie.com - - - - \ No newline at end of file diff --git a/forms/src/test/resources/com/itextpdf/forms/XfdfReaderTest/pdf_without_data.pdf b/forms/src/test/resources/com/itextpdf/forms/XfdfReaderTest/pdf_without_data.pdf deleted file mode 100644 index 0324e8cfa2..0000000000 Binary files a/forms/src/test/resources/com/itextpdf/forms/XfdfReaderTest/pdf_without_data.pdf and /dev/null differ diff --git a/forms/src/test/resources/com/itextpdf/forms/XfdfReaderTest/register.xfdf b/forms/src/test/resources/com/itextpdf/forms/XfdfReaderTest/register.xfdf deleted file mode 100644 index f38e5f4251..0000000000 --- a/forms/src/test/resources/com/itextpdf/forms/XfdfReaderTest/register.xfdf +++ /dev/null @@ -1,18 +0,0 @@ - - - - -Bruno Lowagie - - -Baeyensstraat 121, Sint-Amandsberg - - -9040 - - -bruno@lowagie.com - - - - \ No newline at end of file diff --git a/forms/src/test/resources/com/itextpdf/forms/XfdfReaderTest/submit_me_form_book_9.pdf b/forms/src/test/resources/com/itextpdf/forms/XfdfReaderTest/submit_me_form_book_9.pdf deleted file mode 100644 index 8cb3ca99e9..0000000000 Binary files a/forms/src/test/resources/com/itextpdf/forms/XfdfReaderTest/submit_me_form_book_9.pdf and /dev/null differ diff --git a/forms/src/test/resources/com/itextpdf/forms/XfdfReaderTest/submit_me_form_book_9.xfdf b/forms/src/test/resources/com/itextpdf/forms/XfdfReaderTest/submit_me_form_book_9.xfdf deleted file mode 100644 index ebef9e06f4..0000000000 --- a/forms/src/test/resources/com/itextpdf/forms/XfdfReaderTest/submit_me_form_book_9.xfdf +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - -blowagie - - -Bruno Lowagie - - - -I like to wathc movies! - - - - - \ No newline at end of file diff --git a/forms/src/test/resources/com/itextpdf/forms/XfdfWriterTest/Requisition_Fillable.pdf b/forms/src/test/resources/com/itextpdf/forms/XfdfWriterTest/Requisition_Fillable.pdf deleted file mode 100644 index 0324e8cfa2..0000000000 Binary files a/forms/src/test/resources/com/itextpdf/forms/XfdfWriterTest/Requisition_Fillable.pdf and /dev/null differ diff --git a/forms/src/test/resources/com/itextpdf/forms/XfdfWriterTest/cmp_fieldEmptyValueTest.xfdf b/forms/src/test/resources/com/itextpdf/forms/XfdfWriterTest/cmp_fieldEmptyValueTest.xfdf deleted file mode 100644 index d99d49a607..0000000000 --- a/forms/src/test/resources/com/itextpdf/forms/XfdfWriterTest/cmp_fieldEmptyValueTest.xfdf +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/forms/src/test/resources/com/itextpdf/forms/XfdfWriterTest/cmp_fieldNullValueTest.xfdf b/forms/src/test/resources/com/itextpdf/forms/XfdfWriterTest/cmp_fieldNullValueTest.xfdf deleted file mode 100644 index d99d49a607..0000000000 --- a/forms/src/test/resources/com/itextpdf/forms/XfdfWriterTest/cmp_fieldNullValueTest.xfdf +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/forms/src/test/resources/com/itextpdf/forms/XfdfWriterTest/cmp_formFieldTest.xfdf b/forms/src/test/resources/com/itextpdf/forms/XfdfWriterTest/cmp_formFieldTest.xfdf deleted file mode 100644 index db5ba5fc59..0000000000 --- a/forms/src/test/resources/com/itextpdf/forms/XfdfWriterTest/cmp_formFieldTest.xfdf +++ /dev/null @@ -1,20 +0,0 @@ - - - - - -Да - - -some value in courier font - - - TestField - - - aa - - - - \ No newline at end of file diff --git a/forms/src/test/resources/com/itextpdf/forms/XfdfWriterTest/cmp_xfdfHighlightedText_preprocessed.xfdf b/forms/src/test/resources/com/itextpdf/forms/XfdfWriterTest/cmp_xfdfHighlightedText_preprocessed.xfdf deleted file mode 100644 index b982c13b7b..0000000000 --- a/forms/src/test/resources/com/itextpdf/forms/XfdfWriterTest/cmp_xfdfHighlightedText_preprocessed.xfdf +++ /dev/null @@ -1 +0,0 @@ -Marked set by AlexAnnotation 1 \ No newline at end of file diff --git a/forms/src/test/resources/com/itextpdf/forms/XfdfWriterTest/data.xfdf b/forms/src/test/resources/com/itextpdf/forms/XfdfWriterTest/data.xfdf deleted file mode 100644 index 02c346fcb5..0000000000 --- a/forms/src/test/resources/com/itextpdf/forms/XfdfWriterTest/data.xfdf +++ /dev/null @@ -1,13 +0,0 @@ - - - -Santaaimonce -Developer -Alphabet Street -Minneapolis -Minnesota -Use iText to fill out interactive form using data stored in XFDF file. -If you are a C# developer, use iTextSharp. - - - \ No newline at end of file diff --git a/forms/src/test/resources/com/itextpdf/forms/XfdfWriterTest/formFieldTest04_data.xfdf b/forms/src/test/resources/com/itextpdf/forms/XfdfWriterTest/formFieldTest04_data.xfdf deleted file mode 100644 index 7c261caa8e..0000000000 --- a/forms/src/test/resources/com/itextpdf/forms/XfdfWriterTest/formFieldTest04_data.xfdf +++ /dev/null @@ -1,24 +0,0 @@ - -Даsome value in courier fontTestFieldaa \ No newline at end of file diff --git a/forms/src/test/resources/com/itextpdf/forms/XfdfWriterTest/hierarchy_fields.xfdf b/forms/src/test/resources/com/itextpdf/forms/XfdfWriterTest/hierarchy_fields.xfdf deleted file mode 100644 index ef517adee4..0000000000 --- a/forms/src/test/resources/com/itextpdf/forms/XfdfWriterTest/hierarchy_fields.xfdf +++ /dev/null @@ -1,22 +0,0 @@ - -test - - -some other value - - - \ No newline at end of file diff --git a/forms/src/test/resources/com/itextpdf/forms/XfdfWriterTest/myout.pdf b/forms/src/test/resources/com/itextpdf/forms/XfdfWriterTest/myout.pdf deleted file mode 100644 index 6e56cfa3d2..0000000000 Binary files a/forms/src/test/resources/com/itextpdf/forms/XfdfWriterTest/myout.pdf and /dev/null differ diff --git a/forms/src/test/resources/com/itextpdf/forms/XfdfWriterTest/simpleFormWithOneField_data.xfdf b/forms/src/test/resources/com/itextpdf/forms/XfdfWriterTest/simpleFormWithOneField_data.xfdf deleted file mode 100644 index 0bcea6479a..0000000000 --- a/forms/src/test/resources/com/itextpdf/forms/XfdfWriterTest/simpleFormWithOneField_data.xfdf +++ /dev/null @@ -1,12 +0,0 @@ - -中学生 \ No newline at end of file diff --git a/forms/src/test/resources/com/itextpdf/forms/XfdfWriterTest/submit_me_form_book_9.xfdf b/forms/src/test/resources/com/itextpdf/forms/XfdfWriterTest/submit_me_form_book_9.xfdf deleted file mode 100644 index 275ce5113c..0000000000 --- a/forms/src/test/resources/com/itextpdf/forms/XfdfWriterTest/submit_me_form_book_9.xfdf +++ /dev/null @@ -1,19 +0,0 @@ - - - - - -blowagie - - -Bruno Lowagie - - -I like to wathc movies! - - - - - \ No newline at end of file diff --git a/forms/src/test/resources/com/itextpdf/forms/XfdfWriterTest/xfdfFormsFieldParams.pdf b/forms/src/test/resources/com/itextpdf/forms/XfdfWriterTest/xfdfFormsFieldParams.pdf deleted file mode 100644 index f19c7fbe19..0000000000 Binary files a/forms/src/test/resources/com/itextpdf/forms/XfdfWriterTest/xfdfFormsFieldParams.pdf and /dev/null differ diff --git a/forms/src/test/resources/com/itextpdf/forms/XfdfWriterTest/xfdfHighlightedTexttestforannotation.pdf b/forms/src/test/resources/com/itextpdf/forms/XfdfWriterTest/xfdfHighlightedTexttestforannotation.pdf deleted file mode 100644 index 7d638083ba..0000000000 Binary files a/forms/src/test/resources/com/itextpdf/forms/XfdfWriterTest/xfdfHighlightedTexttestforannotation.pdf and /dev/null differ diff --git a/forms/src/test/resources/com/itextpdf/forms/form/element/CheckBoxTest/cmp_checkBoxSetBorders.pdf b/forms/src/test/resources/com/itextpdf/forms/form/element/CheckBoxTest/cmp_checkBoxSetBorders.pdf new file mode 100644 index 0000000000..a3d49ee6a3 Binary files /dev/null and b/forms/src/test/resources/com/itextpdf/forms/form/element/CheckBoxTest/cmp_checkBoxSetBorders.pdf differ diff --git a/forms/src/test/resources/com/itextpdf/forms/form/element/CheckBoxTest/cmp_checkBox_setSmallBorder.pdf b/forms/src/test/resources/com/itextpdf/forms/form/element/CheckBoxTest/cmp_checkBox_setSmallBorder.pdf index bb04a15862..acde402c8e 100644 Binary files a/forms/src/test/resources/com/itextpdf/forms/form/element/CheckBoxTest/cmp_checkBox_setSmallBorder.pdf and b/forms/src/test/resources/com/itextpdf/forms/form/element/CheckBoxTest/cmp_checkBox_setSmallBorder.pdf differ diff --git a/forms/src/test/resources/com/itextpdf/forms/form/element/CheckBoxTest/cmp_setBorder.pdf b/forms/src/test/resources/com/itextpdf/forms/form/element/CheckBoxTest/cmp_setBorder.pdf index 03ac13d6b9..67618f771c 100644 Binary files a/forms/src/test/resources/com/itextpdf/forms/form/element/CheckBoxTest/cmp_setBorder.pdf and b/forms/src/test/resources/com/itextpdf/forms/form/element/CheckBoxTest/cmp_setBorder.pdf differ diff --git a/forms/src/test/resources/com/itextpdf/forms/form/element/CheckBoxTest/setSize_CheckBox_checked.pdf b/forms/src/test/resources/com/itextpdf/forms/form/element/CheckBoxTest/setSize_CheckBox_checked.pdf deleted file mode 100644 index 896b3ecce9..0000000000 Binary files a/forms/src/test/resources/com/itextpdf/forms/form/element/CheckBoxTest/setSize_CheckBox_checked.pdf and /dev/null differ diff --git a/forms/src/test/resources/com/itextpdf/forms/form/element/ComboBoxFieldTest/cmp_basicComboBoxBorderTest.pdf b/forms/src/test/resources/com/itextpdf/forms/form/element/ComboBoxFieldTest/cmp_basicComboBoxBorderTest.pdf index 73bee9d725..734e493aad 100644 Binary files a/forms/src/test/resources/com/itextpdf/forms/form/element/ComboBoxFieldTest/cmp_basicComboBoxBorderTest.pdf and b/forms/src/test/resources/com/itextpdf/forms/form/element/ComboBoxFieldTest/cmp_basicComboBoxBorderTest.pdf differ diff --git a/forms/src/test/resources/com/itextpdf/forms/form/element/ListBoxFieldTest/cmp_basicListBoxField.pdf b/forms/src/test/resources/com/itextpdf/forms/form/element/ListBoxFieldTest/cmp_basicListBoxField.pdf index f3d1ce83cf..ad543c9f93 100644 Binary files a/forms/src/test/resources/com/itextpdf/forms/form/element/ListBoxFieldTest/cmp_basicListBoxField.pdf and b/forms/src/test/resources/com/itextpdf/forms/form/element/ListBoxFieldTest/cmp_basicListBoxField.pdf differ diff --git a/forms/src/test/resources/com/itextpdf/forms/form/element/ListBoxFieldTest/cmp_colorsBorders.pdf b/forms/src/test/resources/com/itextpdf/forms/form/element/ListBoxFieldTest/cmp_colorsBorders.pdf index 59e98de8e6..1f683ffd8f 100644 Binary files a/forms/src/test/resources/com/itextpdf/forms/form/element/ListBoxFieldTest/cmp_colorsBorders.pdf and b/forms/src/test/resources/com/itextpdf/forms/form/element/ListBoxFieldTest/cmp_colorsBorders.pdf differ diff --git a/forms/src/test/resources/com/itextpdf/forms/form/element/ListBoxFieldTest/cmp_exportValue.pdf b/forms/src/test/resources/com/itextpdf/forms/form/element/ListBoxFieldTest/cmp_exportValue.pdf index 7ab9e1885f..23596f7f12 100644 Binary files a/forms/src/test/resources/com/itextpdf/forms/form/element/ListBoxFieldTest/cmp_exportValue.pdf and b/forms/src/test/resources/com/itextpdf/forms/form/element/ListBoxFieldTest/cmp_exportValue.pdf differ diff --git a/forms/src/test/resources/com/itextpdf/forms/form/element/ListBoxFieldTest/cmp_justification.pdf b/forms/src/test/resources/com/itextpdf/forms/form/element/ListBoxFieldTest/cmp_justification.pdf index 6de476c24e..7da2d6ce5c 100644 Binary files a/forms/src/test/resources/com/itextpdf/forms/form/element/ListBoxFieldTest/cmp_justification.pdf and b/forms/src/test/resources/com/itextpdf/forms/form/element/ListBoxFieldTest/cmp_justification.pdf differ diff --git a/forms/src/test/resources/com/itextpdf/forms/form/element/ListBoxFieldTest/cmp_listBoxFieldCannotFit.pdf b/forms/src/test/resources/com/itextpdf/forms/form/element/ListBoxFieldTest/cmp_listBoxFieldCannotFit.pdf index b0747fe97a..938d787215 100644 Binary files a/forms/src/test/resources/com/itextpdf/forms/form/element/ListBoxFieldTest/cmp_listBoxFieldCannotFit.pdf and b/forms/src/test/resources/com/itextpdf/forms/form/element/ListBoxFieldTest/cmp_listBoxFieldCannotFit.pdf differ diff --git a/forms/src/test/resources/com/itextpdf/forms/form/element/ListBoxFieldTest/cmp_listBoxFieldCannotFitByWidth.pdf b/forms/src/test/resources/com/itextpdf/forms/form/element/ListBoxFieldTest/cmp_listBoxFieldCannotFitByWidth.pdf index b1729f065a..876f01f603 100644 Binary files a/forms/src/test/resources/com/itextpdf/forms/form/element/ListBoxFieldTest/cmp_listBoxFieldCannotFitByWidth.pdf and b/forms/src/test/resources/com/itextpdf/forms/form/element/ListBoxFieldTest/cmp_listBoxFieldCannotFitByWidth.pdf differ diff --git a/forms/src/test/resources/com/itextpdf/forms/form/element/ListBoxFieldTest/cmp_listBoxFieldWithHeight.pdf b/forms/src/test/resources/com/itextpdf/forms/form/element/ListBoxFieldTest/cmp_listBoxFieldWithHeight.pdf index e02d5b1b4b..c0ae115524 100644 Binary files a/forms/src/test/resources/com/itextpdf/forms/form/element/ListBoxFieldTest/cmp_listBoxFieldWithHeight.pdf and b/forms/src/test/resources/com/itextpdf/forms/form/element/ListBoxFieldTest/cmp_listBoxFieldWithHeight.pdf differ diff --git a/forms/src/test/resources/com/itextpdf/forms/form/element/ListBoxFieldTest/cmp_listBoxFieldWithLang.pdf b/forms/src/test/resources/com/itextpdf/forms/form/element/ListBoxFieldTest/cmp_listBoxFieldWithLang.pdf index 4d83d96e23..19d7aea156 100644 Binary files a/forms/src/test/resources/com/itextpdf/forms/form/element/ListBoxFieldTest/cmp_listBoxFieldWithLang.pdf and b/forms/src/test/resources/com/itextpdf/forms/form/element/ListBoxFieldTest/cmp_listBoxFieldWithLang.pdf differ diff --git a/forms/src/test/resources/com/itextpdf/forms/form/element/ListBoxFieldTest/cmp_listBoxFieldWithMargins.pdf b/forms/src/test/resources/com/itextpdf/forms/form/element/ListBoxFieldTest/cmp_listBoxFieldWithMargins.pdf index df56acf0b0..f9de9bd764 100644 Binary files a/forms/src/test/resources/com/itextpdf/forms/form/element/ListBoxFieldTest/cmp_listBoxFieldWithMargins.pdf and b/forms/src/test/resources/com/itextpdf/forms/form/element/ListBoxFieldTest/cmp_listBoxFieldWithMargins.pdf differ diff --git a/forms/src/test/resources/com/itextpdf/forms/form/element/ListBoxFieldTest/cmp_listBoxFieldWithMaxHeight.pdf b/forms/src/test/resources/com/itextpdf/forms/form/element/ListBoxFieldTest/cmp_listBoxFieldWithMaxHeight.pdf index 470ad0c7ba..14ef2bc145 100644 Binary files a/forms/src/test/resources/com/itextpdf/forms/form/element/ListBoxFieldTest/cmp_listBoxFieldWithMaxHeight.pdf and b/forms/src/test/resources/com/itextpdf/forms/form/element/ListBoxFieldTest/cmp_listBoxFieldWithMaxHeight.pdf differ diff --git a/forms/src/test/resources/com/itextpdf/forms/form/element/ListBoxFieldTest/cmp_listBoxFieldWithMinHeight.pdf b/forms/src/test/resources/com/itextpdf/forms/form/element/ListBoxFieldTest/cmp_listBoxFieldWithMinHeight.pdf index a23c786345..88ac402017 100644 Binary files a/forms/src/test/resources/com/itextpdf/forms/form/element/ListBoxFieldTest/cmp_listBoxFieldWithMinHeight.pdf and b/forms/src/test/resources/com/itextpdf/forms/form/element/ListBoxFieldTest/cmp_listBoxFieldWithMinHeight.pdf differ diff --git a/forms/src/test/resources/com/itextpdf/forms/form/element/ListBoxFieldTest/cmp_longList.pdf b/forms/src/test/resources/com/itextpdf/forms/form/element/ListBoxFieldTest/cmp_longList.pdf index c2e67df2dd..ca8ab0d367 100644 Binary files a/forms/src/test/resources/com/itextpdf/forms/form/element/ListBoxFieldTest/cmp_longList.pdf and b/forms/src/test/resources/com/itextpdf/forms/form/element/ListBoxFieldTest/cmp_longList.pdf differ diff --git a/forms/src/test/resources/com/itextpdf/forms/form/element/SignatureFieldAppearanceTest/cmp_emptySigFieldAppearance.pdf b/forms/src/test/resources/com/itextpdf/forms/form/element/SignatureFieldAppearanceTest/cmp_emptySigFieldAppearance.pdf new file mode 100644 index 0000000000..9110617e77 Binary files /dev/null and b/forms/src/test/resources/com/itextpdf/forms/form/element/SignatureFieldAppearanceTest/cmp_emptySigFieldAppearance.pdf differ diff --git a/forms/src/test/resources/com/itextpdf/forms/form/element/SignatureFieldAppearanceTest/cmp_ignoreSignDateAndReasonInAppearance.pdf b/forms/src/test/resources/com/itextpdf/forms/form/element/SignatureFieldAppearanceTest/cmp_ignoreSignDateAndReasonInAppearance.pdf new file mode 100644 index 0000000000..8b781d8589 Binary files /dev/null and b/forms/src/test/resources/com/itextpdf/forms/form/element/SignatureFieldAppearanceTest/cmp_ignoreSignDateAndReasonInAppearance.pdf differ diff --git a/forms/src/test/resources/com/itextpdf/forms/form/element/SignatureFieldAppearanceTest/cmp_sigFieldWithNameAndDescriptionMode.pdf b/forms/src/test/resources/com/itextpdf/forms/form/element/SignatureFieldAppearanceTest/cmp_sigFieldWithNameAndDescriptionMode.pdf deleted file mode 100644 index 36d47ba91f..0000000000 Binary files a/forms/src/test/resources/com/itextpdf/forms/form/element/SignatureFieldAppearanceTest/cmp_sigFieldWithNameAndDescriptionMode.pdf and /dev/null differ diff --git a/forms/src/test/resources/com/itextpdf/forms/form/element/TextAreaTest/cmp_textAreaWithBorderLessThan1.pdf b/forms/src/test/resources/com/itextpdf/forms/form/element/TextAreaTest/cmp_textAreaWithBorderLessThan1.pdf index 2798fb5ec1..3aaf1c7af1 100644 Binary files a/forms/src/test/resources/com/itextpdf/forms/form/element/TextAreaTest/cmp_textAreaWithBorderLessThan1.pdf and b/forms/src/test/resources/com/itextpdf/forms/form/element/TextAreaTest/cmp_textAreaWithBorderLessThan1.pdf differ diff --git a/forms/src/test/resources/com/itextpdf/forms/widget/AppearanceCharacteristicsTest/changeBorderStyle.pdf b/forms/src/test/resources/com/itextpdf/forms/widget/AppearanceCharacteristicsTest/changeBorderStyle.pdf deleted file mode 100644 index 9f6e63ec36..0000000000 Binary files a/forms/src/test/resources/com/itextpdf/forms/widget/AppearanceCharacteristicsTest/changeBorderStyle.pdf and /dev/null differ diff --git a/forms/src/test/resources/com/itextpdf/forms/widget/AppearanceCharacteristicsTest/cmp_updatingDocumentWithUnderlineFieldBorder.pdf b/forms/src/test/resources/com/itextpdf/forms/widget/AppearanceCharacteristicsTest/cmp_updatingDocumentWithUnderlineFieldBorder.pdf deleted file mode 100644 index d4c3da3e44..0000000000 Binary files a/forms/src/test/resources/com/itextpdf/forms/widget/AppearanceCharacteristicsTest/cmp_updatingDocumentWithUnderlineFieldBorder.pdf and /dev/null differ diff --git a/forms/src/test/resources/com/itextpdf/forms/widget/AppearanceCharacteristicsTest/documentWithUnderlineFieldBorder.pdf b/forms/src/test/resources/com/itextpdf/forms/widget/AppearanceCharacteristicsTest/documentWithUnderlineFieldBorder.pdf deleted file mode 100644 index cd6e1f0111..0000000000 Binary files a/forms/src/test/resources/com/itextpdf/forms/widget/AppearanceCharacteristicsTest/documentWithUnderlineFieldBorder.pdf and /dev/null differ diff --git a/hyph/pom.xml b/hyph/pom.xml index 59e85b1099..a19fed7609 100644 --- a/hyph/pom.xml +++ b/hyph/pom.xml @@ -5,7 +5,7 @@ com.itextpdf root - 8.0.5 + 9.0.0 hyph diff --git a/io/pom.xml b/io/pom.xml index 68826f8470..6dc23585ae 100644 --- a/io/pom.xml +++ b/io/pom.xml @@ -5,7 +5,7 @@ com.itextpdf root - 8.0.5 + 9.0.0 io diff --git a/io/src/main/java/com/itextpdf/io/codec/Jbig2SegmentReader.java b/io/src/main/java/com/itextpdf/io/codec/Jbig2SegmentReader.java index 8b502bf69f..90695bfde2 100644 --- a/io/src/main/java/com/itextpdf/io/codec/Jbig2SegmentReader.java +++ b/io/src/main/java/com/itextpdf/io/codec/Jbig2SegmentReader.java @@ -102,18 +102,18 @@ public class Jbig2SegmentReader { */ public static class Jbig2Segment implements Comparable { - public final int segmentNumber; - public long dataLength = -1; - public int page = -1; - public int[] referredToSegmentNumbers = null; - public boolean[] segmentRetentionFlags = null; - public int type = -1; - public boolean deferredNonRetain = false; - public int countOfReferredToSegments = -1; - public byte[] data = null; - public byte[] headerData = null; - public boolean page_association_size = false; - public int page_association_offset = -1; + private final int segmentNumber; + private long dataLength = -1; + private int page = -1; + private int[] referredToSegmentNumbers = null; + private boolean[] segmentRetentionFlags = null; + private int type = -1; + private boolean deferredNonRetain = false; + private int countOfReferredToSegments = -1; + private byte[] data = null; + private byte[] headerData = null; + private boolean pageAssociationSize = false; + private int pageAssociationOffset = -1; public Jbig2Segment(int segment_number) { this.segmentNumber = segment_number; @@ -123,24 +123,274 @@ public int compareTo(Jbig2Segment s) { return this.segmentNumber - s.segmentNumber; } + /** + * Retrieves the data length of a JBig2Segment object. + * + * @return data length value + */ + public long getDataLength() { + return dataLength; + } + + /** + * Sets the data length of a JBig2Segment object. + * + * @param dataLength data length value + */ + public void setDataLength(long dataLength) { + this.dataLength = dataLength; + } + + /** + * Retrieves the page number of a JBig2Segment object. + * + * @return page number + */ + public int getPage() { + return page; + } + + /** + * Sets the page number of a JBig2Segment object. + * + * @param page page number + */ + public void setPage(int page) { + this.page = page; + } + + /** + * Retrieves the referred-to segment numbers of a JBig2Segment object. + * + * @return Every referred-to segment number + */ + public int[] getReferredToSegmentNumbers() { + return referredToSegmentNumbers; + } + + /** + * Sets the referred-to segment numbers of a JBig2Segment object. + * + * @param referredToSegmentNumbers Referred-to segment numbers + */ + public void setReferredToSegmentNumbers(int[] referredToSegmentNumbers) { + this.referredToSegmentNumbers = referredToSegmentNumbers; + } + + /** + * Retrieves segment retention flags of a JBig2Segment object. + * + * @return Every segment retention flag value + */ + public boolean[] getSegmentRetentionFlags() { + return segmentRetentionFlags; + } + + /** + * Sets segment retention flags of a JBig2Segment object. + * + * @param segmentRetentionFlags Segment retention flag values + */ + public void setSegmentRetentionFlags(boolean[] segmentRetentionFlags) { + this.segmentRetentionFlags = segmentRetentionFlags; + } + + /** + * Retrieves type of the JBig2Segment object. + * + * @return Type value + */ + public int getType() { + return type; + } + + /** + * Sets type of the JBig2Segment object. + * @param type Type value + */ + public void setType(int type) { + this.type = type; + } + + /** + * Retrieves whether the object is deferred without retention. + * Default value is false. + * + * @return true if deferred without retention, false otherwise + */ + public boolean isDeferredNonRetain() { + return deferredNonRetain; + } + + /** + * Sets whether the JBig2Segments object is deferred without retention. + * + * @param deferredNonRetain true for deferred without retention, false otherwise + */ + public void setDeferredNonRetain(boolean deferredNonRetain) { + this.deferredNonRetain = deferredNonRetain; + } + + /** + * Retrieves the count of the referred-to segments. + * + * @return count of referred-to segments + */ + public int getCountOfReferredToSegments() { + return countOfReferredToSegments; + } + + /** + * Sets the count of referred-to segments of the JBig2Segment object. + * + * @param countOfReferredToSegments count of referred segments + */ + public void setCountOfReferredToSegments(int countOfReferredToSegments) { + this.countOfReferredToSegments = countOfReferredToSegments; + } + /** + * Retrieves data of the JBig2Segment object. + * + * @return data bytes + */ + public byte[] getData() { + return data; + } + + /** + * Sets data of the JBig2Segment object. + * + * @param data data bytes + */ + public void setData(byte[] data) { + this.data = data; + } + + /** + * Retrieves header data of the JBig2Segment object. + * + * @return header data bytes + */ + public byte[] getHeaderData() { + return headerData; + } + + /** + * Sets header data of the JBig2Segment object. + * + * @param headerData header date bytes + */ + public void setHeaderData(byte[] headerData) { + this.headerData = headerData; + } + + /** + * Retrieves page association size of the JBig2Segment object. + * + * @return page association size value + */ + public boolean isPageAssociationSize() { + return pageAssociationSize; + } + + /** + * Sets page association size of the JBig2Segment object. + * + * @param pageAssociationSize page association size + */ + public void setPageAssociationSize(boolean pageAssociationSize) { + this.pageAssociationSize = pageAssociationSize; + } + + /** + * Retrieves the page association offset of the JBig2Segment object. + * + * @return page association offset value + */ + public int getPageAssociationOffset() { + return pageAssociationOffset; + } + + /** + * Sets page association offset of the JBig2Segment object. + * + * @param pageAssociationOffset page association offset + */ + public void setPageAssociationOffset(int pageAssociationOffset) { + this.pageAssociationOffset = pageAssociationOffset; + } + + /** + * Retrieves the segment number of the JBig2Segment object. + * + * @return segment number + */ + public int getSegmentNumber() { + return segmentNumber; + } } /** * Inner class that holds information about a JBIG2 page. */ public static class Jbig2Page { - public final int page; + private final int page; private final Jbig2SegmentReader sr; private final Map segs = new TreeMap<>(); - public int pageBitmapWidth = -1; - public int pageBitmapHeight = -1; + private int pageBitmapWidth = -1; + private int pageBitmapHeight = -1; public Jbig2Page(int page, Jbig2SegmentReader sr) { this.page = page; this.sr = sr; } + /** + * Retrieves the page number of the Jbig2Page object. + * + * @return page number + */ + public int getPage() { + return page; + } + + /** + * Retrieves page bitmap width of the Jbig2Page object. + * + * @return width of page bitmap + */ + public int getPageBitmapWidth() { + return pageBitmapWidth; + } + + /** + * Sets page bitmap width of the JBig2Page object. + * + * @param pageBitmapWidth page bitmap width + */ + public void setPageBitmapWidth(int pageBitmapWidth) { + this.pageBitmapWidth = pageBitmapWidth; + } + + /** + * Retrieves page bitmap height of the JBig2Page object. + * + * @return height of the page bitmap + */ + public int getPageBitmapHeight() { + return pageBitmapHeight; + } + + /** + * Sets the height of the page bitmap of a Jbig2Page object. + * + * @param pageBitmapHeight height of the page bitmap + */ + public void setPageBitmapHeight(int pageBitmapHeight) { + this.pageBitmapHeight = pageBitmapHeight; + } + /** * return as a single byte array the header-data for each segment in segment number * order, EMBEDDED organization, but I am putting the needed segments in SEQUENTIAL organization. @@ -158,33 +408,33 @@ public byte[] getData(boolean for_embedding) throws java.io.IOException { // pdf reference 1.4, section 3.3.6 Jbig2Decode Filter // D.3 Embedded organisation if (for_embedding && - (s.type == END_OF_FILE || s.type == END_OF_PAGE)) { + (s.getType() == END_OF_FILE || s.getType() == END_OF_PAGE)) { continue; } if (for_embedding) { // change the page association to page 1 - byte[] headerData_emb = copyByteArray(s.headerData); - if (s.page_association_size) { - headerData_emb[s.page_association_offset] = 0x0; - headerData_emb[s.page_association_offset + 1] = 0x0; - headerData_emb[s.page_association_offset + 2] = 0x0; - headerData_emb[s.page_association_offset + 3] = 0x1; + byte[] headerDataEmb = copyByteArray(s.getHeaderData()); + if (s.isPageAssociationSize()) { + headerDataEmb[s.getPageAssociationOffset()] = 0x0; + headerDataEmb[s.getPageAssociationOffset() + 1] = 0x0; + headerDataEmb[s.getPageAssociationOffset() + 2] = 0x0; + headerDataEmb[s.getPageAssociationOffset() + 3] = 0x1; } else { - headerData_emb[s.page_association_offset] = 0x1; + headerDataEmb[s.getPageAssociationOffset()] = 0x1; } - os.write(headerData_emb); + os.write(headerDataEmb); } else { - os.write(s.headerData); + os.write(s.getHeaderData()); } - os.write(s.data); + os.write(s.getData()); } os.close(); return os.toByteArray(); } public void addSegment(Jbig2Segment s) { - segs.put(s.segmentNumber, s); + segs.put(s.getSegmentNumber(), s); } } @@ -212,15 +462,15 @@ public void read() throws java.io.IOException { do { Jbig2Segment tmp = readHeader(); readSegment(tmp); - segments.put(tmp.segmentNumber, tmp); + segments.put(tmp.getSegmentNumber(), tmp); } while (this.ra.getPosition() < this.ra.length()); } else { // D.2 Jbig2Segment tmp; do { tmp = readHeader(); - segments.put(tmp.segmentNumber, tmp); - } while (tmp.type != END_OF_FILE); + segments.put(tmp.getSegmentNumber(), tmp); + } while (tmp.getType() != END_OF_FILE); for (int integer : segments.keySet()) { readSegment(segments.get(integer)); } @@ -231,27 +481,28 @@ void readSegment(Jbig2Segment s) throws java.io.IOException { int ptr = (int) ra.getPosition(); //TODO DEVSIX-6406 7.2.7 not supported - if (s.dataLength == 0xffffffffl) { + if (s.getDataLength() == 0xffffffffl) { return; } - byte[] data = new byte[(int) s.dataLength]; + byte[] data = new byte[(int) s.getDataLength()]; ra.read(data); - s.data = data; + s.setData(data); - if (s.type == PAGE_INFORMATION) { + if (s.getType() == PAGE_INFORMATION) { int last = (int) ra.getPosition(); ra.seek(ptr); int page_bitmap_width = ra.readInt(); int page_bitmap_height = ra.readInt(); ra.seek(last); - Jbig2Page p = pages.get(s.page); + Jbig2Page p = pages.get(s.getPage()); if (p == null) { - throw new IOException("Referring to widht or height of a page we haven't seen yet: {0}").setMessageParams(s.page); + throw new IOException("Referring to widht or height of a page we haven't seen yet: {0}") + .setMessageParams(s.getPage()); } - p.pageBitmapWidth = page_bitmap_width; - p.pageBitmapHeight = page_bitmap_height; + p.setPageBitmapWidth(page_bitmap_width); + p.setPageBitmapHeight(page_bitmap_height); } } @@ -264,10 +515,10 @@ Jbig2Segment readHeader() throws java.io.IOException { // 7.2.3 int segment_header_flags = ra.read(); boolean deferred_non_retain = (segment_header_flags & 0x80) == 0x80; - s.deferredNonRetain = deferred_non_retain; + s.setDeferredNonRetain(deferred_non_retain); boolean page_association_size = (segment_header_flags & 0x40) == 0x40; int segment_type = segment_header_flags & 0x3f; - s.type = segment_type; + s.setType(segment_type); //7.2.4 int referred_to_byte0 = ra.read(); @@ -304,8 +555,8 @@ Jbig2Segment readHeader() throws java.io.IOException { .setMessageParams(segment_number, ptr); } - s.segmentRetentionFlags = segment_retention_flags; - s.countOfReferredToSegments = count_of_referred_to_segments; + s.setSegmentRetentionFlags(segment_retention_flags); + s.setCountOfReferredToSegments(count_of_referred_to_segments); // 7.2.5 referred_to_segment_numbers = new int[count_of_referred_to_segments + 1]; @@ -318,7 +569,7 @@ Jbig2Segment readHeader() throws java.io.IOException { referred_to_segment_numbers[i] = (int) ra.readUnsignedInt(); } } - s.referredToSegmentNumbers = referred_to_segment_numbers; + s.setReferredToSegmentNumbers(referred_to_segment_numbers); // 7.2.6 int segment_page_association; @@ -332,10 +583,10 @@ Jbig2Segment readHeader() throws java.io.IOException { throw new IOException("Page {0} is invalid for segment {1} starting at {2}") .setMessageParams(segment_page_association, segment_number, ptr); } - s.page = segment_page_association; + s.setPage(segment_page_association); // so we can change the page association at embedding time. - s.page_association_size = page_association_size; - s.page_association_offset = page_association_offset; + s.setPageAssociationSize(page_association_size); + s.setPageAssociationOffset(page_association_offset); if (segment_page_association > 0 && !pages.containsKey(segment_page_association)) { pages.put(segment_page_association, new Jbig2Page(segment_page_association, this)); @@ -349,13 +600,13 @@ Jbig2Segment readHeader() throws java.io.IOException { // 7.2.7 long segment_data_length = ra.readUnsignedInt(); //TODO DEVSIX-6406 the 0xffffffff value that might be here, and how to understand those afflicted segments - s.dataLength = segment_data_length; + s.setDataLength(segment_data_length); int end_ptr = (int) ra.getPosition(); ra.seek(ptr); byte[] header_data = new byte[end_ptr - ptr]; ra.read(header_data); - s.headerData = header_data; + s.setHeaderData(header_data); return s; } @@ -392,11 +643,11 @@ public int numberOfPages() { } public int getPageHeight(int i) { - return pages.get(i).pageBitmapHeight; + return pages.get(i).getPageBitmapHeight(); } public int getPageWidth(int i) { - return pages.get(i).pageBitmapWidth; + return pages.get(i).getPageBitmapWidth(); } public Jbig2Page getPage(int page) { @@ -410,11 +661,11 @@ public byte[] getGlobal(boolean for_embedding){ for (Object element : globals) { Jbig2Segment s = (Jbig2Segment) element; if (for_embedding && - (s.type == END_OF_FILE || s.type == END_OF_PAGE)) { + (s.getType() == END_OF_FILE || s.getType() == END_OF_PAGE)) { continue; } - os.write(s.headerData); - os.write(s.data); + os.write(s.getHeaderData()); + os.write(s.getData()); } if (os.size() > 0) { diff --git a/io/src/main/java/com/itextpdf/io/font/CFFFont.java b/io/src/main/java/com/itextpdf/io/font/CFFFont.java index a15127d376..c5a7feb0c1 100644 --- a/io/src/main/java/com/itextpdf/io/font/CFFFont.java +++ b/io/src/main/java/com/itextpdf/io/font/CFFFont.java @@ -345,7 +345,16 @@ public void xref() {} } protected static abstract class OffsetItem extends Item { - public int value; + private int offset; + + /** + * Retrieves offset of an OffsetItem object. + * + * @return offset value + */ + public int getOffset() { + return offset; + } /** * Set the value of an offset item that was initially unknown. @@ -353,7 +362,7 @@ protected static abstract class OffsetItem extends Item { * * @param offset offset to set */ - public void set(int offset) { this.value = offset; } + public void setOffset(int offset) { this.offset = offset; } } @@ -361,8 +370,9 @@ protected static abstract class OffsetItem extends Item { */ protected static final class RangeItem extends Item { - public int offset, length; - private RandomAccessFileOrArray buf; + private final int offset; + private final int length; + private final RandomAccessFileOrArray buf; public RangeItem(RandomAccessFileOrArray buf, int offset, int length) { this.offset = offset; this.length = length; @@ -394,8 +404,8 @@ public void emit(byte[] buffer) { * variable-size representation. */ protected static final class IndexOffsetItem extends OffsetItem { - public final int size; - public IndexOffsetItem(int size, int value) {this.size=size; this.value=value;} + private final int size; + public IndexOffsetItem(int size, int value) {this.size=size; this.setOffset(value);} public IndexOffsetItem(int size) {this.size=size; } @Override @@ -407,7 +417,7 @@ public void increment(int[] currentOffset) { public void emit(byte[] buffer) { if (size >= 1 && size <= 4) { for (int i = 0; i < size; i++) { - buffer[myOffset + i] = (byte) (value >>> ((size - 1 - i) << 3) & 0xFF); + buffer[myOffset + i] = (byte) (super.getOffset() >>> ((size - 1 - i) << 3) & 0xFF); } } } @@ -418,8 +428,8 @@ public IndexBaseItem() {} } protected static final class IndexMarkerItem extends Item { - private OffsetItem offItem; - private IndexBaseItem indexBase; + private final OffsetItem offItem; + private final IndexBaseItem indexBase; public IndexMarkerItem(OffsetItem offItem, IndexBaseItem indexBase) { this.offItem = offItem; this.indexBase = indexBase; @@ -427,13 +437,13 @@ public IndexMarkerItem(OffsetItem offItem, IndexBaseItem indexBase) { @Override public void xref() { //System.err.println("index marker item, base="+indexBase.myOffset+" my="+this.myOffset); - offItem.set(this.myOffset-indexBase.myOffset+1); + offItem.setOffset(this.myOffset-indexBase.myOffset+1); } } protected static final class SubrMarkerItem extends Item { - private OffsetItem offItem; - private IndexBaseItem indexBase; + private final OffsetItem offItem; + private final IndexBaseItem indexBase; public SubrMarkerItem(OffsetItem offItem, IndexBaseItem indexBase) { this.offItem = offItem; this.indexBase = indexBase; @@ -441,7 +451,7 @@ public SubrMarkerItem(OffsetItem offItem, IndexBaseItem indexBase) { @Override public void xref() { //System.err.println("index marker item, base="+indexBase.myOffset+" my="+this.myOffset); - offItem.set(this.myOffset-indexBase.myOffset); + offItem.setOffset(this.myOffset-indexBase.myOffset); } } @@ -463,10 +473,10 @@ public void increment(int[] currentOffset) { public void emit(byte[] buffer) { if (size==5) { buffer[myOffset] = 29; - buffer[myOffset+1] = (byte) (value >>> 24 & 0xff); - buffer[myOffset+2] = (byte) (value >>> 16 & 0xff); - buffer[myOffset+3] = (byte) (value >>> 8 & 0xff); - buffer[myOffset+4] = (byte) (value >>> 0 & 0xff); + buffer[myOffset+1] = (byte) (super.getOffset() >>> 24 & 0xff); + buffer[myOffset+2] = (byte) (super.getOffset() >>> 16 & 0xff); + buffer[myOffset+3] = (byte) (super.getOffset() >>> 8 & 0xff); + buffer[myOffset+4] = (byte) (super.getOffset() >>> 0 & 0xff); } } } @@ -475,7 +485,7 @@ public void emit(byte[] buffer) { */ protected static final class UInt24Item extends Item { - public int value; + private final int value; public UInt24Item(int value) {this.value=value;} @Override @@ -496,7 +506,7 @@ public void emit(byte[] buffer) { */ protected static final class UInt32Item extends Item { - public int value; + private final int value; public UInt32Item(int value) {this.value=value;} @Override @@ -518,7 +528,7 @@ public void emit(byte[] buffer) { */ protected static final class UInt16Item extends Item { - public char value; + private final char value; public UInt16Item(char value) {this.value = value;} @Override @@ -541,7 +551,7 @@ public void emit(byte[] buffer) { */ protected static final class UInt8Item extends Item { - public char value; + private final char value; public UInt8Item(char value) {this.value=value;} @Override @@ -558,7 +568,7 @@ public void emit(byte[] buffer) { } protected static final class StringItem extends Item { - public String s; + private final String s; public StringItem(String s) {this.s=s;} @Override @@ -580,9 +590,28 @@ public void emit(byte[] buffer) { */ protected static final class DictNumberItem extends Item { - public final int value; - public int size = 5; + private final int value; + private int size = 5; public DictNumberItem(int value) {this.value=value;} + + /** + * Retrieves the size of a DictNumberItem. + * + * @return size value + */ + public int getSize() { + return size; + } + + /** + * Sets the size of a DictNumberItem. + * + * @param size size value + */ + public void setSize(int size) { + this.size = size; + } + @Override public void increment(int[] currentOffset) { super.increment(currentOffset); @@ -610,7 +639,7 @@ protected static final class MarkerItem extends Item { public MarkerItem(OffsetItem pointerToMarker) {p=pointerToMarker;} @Override public void xref() { - p.set(this.myOffset); + p.setOffset(this.myOffset); } } @@ -652,7 +681,7 @@ public byte[] getCID(String fontName) { int j; for (j=0; j l = new LinkedList(); @@ -669,9 +698,9 @@ public byte[] getCID(String fontName) l.addLast(new RangeItem(buf,0,hdrSize)); int nglyphs=-1, nstrings=-1; - if ( ! fonts[j].isCID ) { + if ( ! fonts[j].isCID() ) { // count the glyphs - seek(fonts[j].charstringsOffset); + seek(fonts[j].getCharstringsOffset()); nglyphs = getCard16(); seek(stringIndexOffset); nstrings = getCard16()+standardStrings.length; @@ -686,8 +715,8 @@ public byte[] getCID(String fontName) l.addLast(new UInt8Item((char)1)); // first offset l.addLast(new UInt8Item((char)1)); - l.addLast(new UInt8Item((char)( 1+fonts[j].name.length() ))); - l.addLast(new StringItem(fonts[j].name)); + l.addLast(new UInt8Item((char)( 1+fonts[j].getName().length() ))); + l.addLast(new StringItem(fonts[j].getName())); // create the topdict Index @@ -717,7 +746,7 @@ public byte[] getCID(String fontName) OffsetItem fdarrayRef = new DictOffsetItem(); OffsetItem fdselectRef = new DictOffsetItem(); - if ( !fonts[j].isCID ) { + if ( !fonts[j].isCID() ) { // create a ROS key l.addLast(new DictNumberItem(nstrings)); @@ -764,9 +793,9 @@ public byte[] getCID(String fontName) || "FDArray".equals(key) || "charset".equals(key) || "CharStrings".equals(key) - ) { + ) { - // just drop them + // just drop them } else { l.addLast(new RangeItem(buf,p1,p2-p1)); } @@ -778,10 +807,10 @@ public byte[] getCID(String fontName) // We need 3 more strings: Registry, Ordering, and a FontName for one FD. // The total length is at most "Adobe"+"Identity"+63 = 76 - if (fonts[j].isCID) { + if (fonts[j].isCID()) { l.addLast(getEntireIndexRange(stringIndexOffset)); } else { - String fdFontName = fonts[j].name+"-OneRange"; + String fdFontName = fonts[j].getName()+"-OneRange"; if (fdFontName.length() > 127) fdFontName = fdFontName.substring(0,127); String extraStrings = "Adobe"+"Identity"+fdFontName; @@ -823,7 +852,7 @@ public byte[] getCID(String fontName) // deal with fdarray, fdselect, and the font descriptors - if (fonts[j].isCID) { + if (fonts[j].isCID()) { // copy the FDArray, FDSelect, charset } else { // create FDSelect @@ -875,7 +904,7 @@ public byte[] getCID(String fontName) //l.addLast(new UInt8Item((char)12)); //l.addLast(new UInt8Item((char)38)); // FontName - l.addLast(new DictNumberItem(fonts[j].privateLength)); + l.addLast(new DictNumberItem(fonts[j].getPrivateLength())); OffsetItem privateRef = new DictOffsetItem(); l.addLast(privateRef); // Private @@ -889,17 +918,17 @@ public byte[] getCID(String fontName) // copy the private dict and the local subroutines. // the length of the private dict seems to NOT include // the local subroutines. - l.addLast(new RangeItem(buf,fonts[j].privateOffset,fonts[j].privateLength)); - if (fonts[j].privateSubrs >= 0) { + l.addLast(new RangeItem(buf,fonts[j].getPrivateOffset(),fonts[j].getPrivateLength())); + if (fonts[j].getPrivateSubrs() >= 0) { //System.err.println("has subrs="+fonts[j].privateSubrs+" ,len="+fonts[j].privateLength); - l.addLast(getEntireIndexRange(fonts[j].privateSubrs)); + l.addLast(getEntireIndexRange(fonts[j].getPrivateSubrs())); } } // copy the charstring index l.addLast(new MarkerItem(charstringsRef)); - l.addLast(getEntireIndexRange(fonts[j].charstringsOffset)); + l.addLast(getEntireIndexRange(fonts[j].getCharstringsOffset())); // now create the new CFF font @@ -931,14 +960,14 @@ public boolean isCID() { public boolean isCID(String fontName) { int j; for (j=0; j"); } @@ -1085,16 +1654,16 @@ public CFFFont(byte[] cff) { getDictItem(); if (key=="FullName") { //System.err.println("getting fullname sid = "+((Integer)args[0]).intValue()); - fonts[j].fullName = getString((char)((Integer)args[0]).intValue()); + fonts[j].setFullName(getString((char)((Integer)args[0]).intValue())); //System.err.println("got it"); } else if (key=="ROS") - fonts[j].isCID = true; + fonts[j].setCID(true); else if (key=="Private") { - fonts[j].privateLength = (int) ((Integer)args[0]).intValue(); - fonts[j].privateOffset = (int) ((Integer)args[1]).intValue(); + fonts[j].setPrivateLength((int) ((Integer)args[0]).intValue()); + fonts[j].setPrivateOffset((int) ((Integer)args[1]).intValue()); } else if (key=="charset"){ - fonts[j].charsetOffset = (int) ((Integer)args[0]).intValue(); + fonts[j].setCharsetOffset((int) ((Integer)args[0]).intValue()); } // else if (key=="Encoding"){ @@ -1105,39 +1674,39 @@ else if (key=="charset"){ // } // } else if (key=="CharStrings") { - fonts[j].charstringsOffset = (int) ((Integer)args[0]).intValue(); + fonts[j].setCharstringsOffset((int) ((Integer)args[0]).intValue()); //System.err.println("charstrings "+fonts[j].charstringsOffset); // Added by Oren & Ygal int p = getPosition(); - fonts[j].charstringsOffsets = getIndex(fonts[j].charstringsOffset); + fonts[j].setCharstringsOffsets(getIndex(fonts[j].getCharstringsOffset())); seek(p); } else if (key=="FDArray") - fonts[j].fdarrayOffset = (int) ((Integer)args[0]).intValue(); + fonts[j].setFdarrayOffset((int) ((Integer)args[0]).intValue()); else if (key=="FDSelect") - fonts[j].fdselectOffset = (int) ((Integer)args[0]).intValue(); + fonts[j].setFdselectOffset((int) ((Integer)args[0]).intValue()); else if (key=="CharstringType") - fonts[j].CharstringType = (int) ((Integer)args[0]).intValue(); + fonts[j].setCharstringType((int) ((Integer)args[0]).intValue()); } // private dict - if (fonts[j].privateOffset >= 0) { + if (fonts[j].getPrivateOffset() >= 0) { //System.err.println("PRIVATE::"); - seek(fonts[j].privateOffset); - while (getPosition() < fonts[j].privateOffset+fonts[j].privateLength) { + seek(fonts[j].getPrivateOffset()); + while (getPosition() < fonts[j].getPrivateOffset()+fonts[j].getPrivateLength()) { getDictItem(); if (key=="Subrs") //Add the private offset to the lsubrs since the offset is // relative to the beginning of the PrivateDict - fonts[j].privateSubrs = (int) ((Integer)args[0]).intValue()+fonts[j].privateOffset; + fonts[j].setPrivateSubrs((int) ((Integer)args[0]).intValue()+fonts[j].getPrivateOffset()); } } // fdarray index - if (fonts[j].fdarrayOffset >= 0) { - int[] fdarrayOffsets = getIndex(fonts[j].fdarrayOffset); + if (fonts[j].getFdarrayOffset() >= 0) { + int[] fdarrayOffsets = getIndex(fonts[j].getFdarrayOffset()); - fonts[j].fdprivateOffsets = new int[fdarrayOffsets.length-1]; - fonts[j].fdprivateLengths = new int[fdarrayOffsets.length-1]; + fonts[j].setFdprivateOffsets(new int[fdarrayOffsets.length-1]); + fonts[j].setFdprivateLengths(new int[fdarrayOffsets.length-1]); //System.err.println("FD Font::"); @@ -1146,8 +1715,12 @@ else if (key=="CharstringType") while (getPosition() < fdarrayOffsets[k+1]) { getDictItem(); if (key=="Private") { - fonts[j].fdprivateLengths[k] = (int) ((Integer)args[0]).intValue(); - fonts[j].fdprivateOffsets[k] = (int) ((Integer)args[1]).intValue(); + int[] fdprivateLengths = fonts[j].getFdprivateLengths(); + fdprivateLengths[k] = (int)((Integer)args[0]).intValue(); + fonts[j].setFdprivateLengths(fdprivateLengths); + int[] fdprivateOffsets = fonts[j].getFdprivateOffsets(); + fdprivateOffsets[k] = (int)((Integer)args[1]).intValue(); + fonts[j].setFdprivateOffsets(fdprivateOffsets); } } } diff --git a/io/src/main/java/com/itextpdf/io/font/CFFFontSubset.java b/io/src/main/java/com/itextpdf/io/font/CFFFontSubset.java index e5db0ccac8..8478f5bfd2 100644 --- a/io/src/main/java/com/itextpdf/io/font/CFFFontSubset.java +++ b/io/src/main/java/com/itextpdf/io/font/CFFFontSubset.java @@ -163,32 +163,32 @@ public CFFFontSubset(byte[] cff, Set GlyphsUsed) { for (int i = 0; i < fonts.length; ++i) { // Read the number of glyphs in the font - seek(fonts[i].charstringsOffset); - fonts[i].nglyphs = getCard16(); + seek(fonts[i].getCharstringsOffset()); + fonts[i].setNglyphs(getCard16()); // Jump to the count field of the String Index seek(stringIndexOffset); - fonts[i].nstrings = getCard16() + standardStrings.length; + fonts[i].setNstrings(getCard16() + standardStrings.length); // For each font save the offset array of the charstring - fonts[i].charstringsOffsets = getIndex(fonts[i].charstringsOffset); + fonts[i].setCharstringsOffsets(getIndex(fonts[i].getCharstringsOffset())); if (isCidParsingRequired) { - initGlyphIdToCharacterIdArray(i, fonts[i].nglyphs, fonts[i].charsetOffset); + initGlyphIdToCharacterIdArray(i, fonts[i].getNglyphs(), fonts[i].getCharsetOffset()); } // Process the FDSelect if exist - if (fonts[i].fdselectOffset >= 0) { + if (fonts[i].getFdselectOffset() >= 0) { // Process the FDSelect readFDSelect(i); // Build the FDArrayUsed Map BuildFDArrayUsed(i); } - if (fonts[i].isCID) + if (fonts[i].isCID()) // Build the FD Array used Map ReadFDArray(i); // compute the charset length - fonts[i].CharsetLength = CountCharset(fonts[i].charsetOffset, fonts[i].nglyphs); + fonts[i].setCharsetLength(CountCharset(fonts[i].getCharsetOffset(), fonts[i].getNglyphs())); } } @@ -253,23 +253,23 @@ int CountRange(int NumofGlyphs, int Type) { */ protected void readFDSelect(int Font) { // Restore the number of glyphs - int NumOfGlyphs = fonts[Font].nglyphs; - int[] FDSelect = new int[NumOfGlyphs]; + int numOfGlyphs = fonts[Font].getNglyphs(); + int[] FDSelect = new int[numOfGlyphs]; // Go to the beginning of the FDSelect - seek(fonts[Font].fdselectOffset); + seek(fonts[Font].getFdselectOffset()); // Read the FDSelect's format - fonts[Font].FDSelectFormat = getCard8(); + fonts[Font].setFDSelectFormat(getCard8()); - switch (fonts[Font].FDSelectFormat) { + switch (fonts[Font].getFDSelectFormat()) { // Format==0 means each glyph has an entry that indicated // its FD. case 0: - for (int i = 0; i < NumOfGlyphs; i++) { + for (int i = 0; i < numOfGlyphs; i++) { FDSelect[i] = getCard8(); } // The FDSelect's Length is one for each glyph + the format // for later use - fonts[Font].FDSelectLength = fonts[Font].nglyphs + 1; + fonts[Font].setFDSelectLength(fonts[Font].getNglyphs() + 1); break; case 3: // Format==3 means the ranges version @@ -293,13 +293,13 @@ protected void readFDSelect(int Font) { first = last; } // Store the length for later use - fonts[Font].FDSelectLength = 1 + 2 + nRanges * 3 + 2; + fonts[Font].setFDSelectLength(1 + 2 + nRanges * 3 + 2); break; default: break; } // Save the FDSelect of the font - fonts[Font].FDSelect = FDSelect; + fonts[Font].setFDSelect(FDSelect); } /** @@ -308,13 +308,13 @@ protected void readFDSelect(int Font) { * @param Font the Number of font being processed */ protected void BuildFDArrayUsed(int Font) { - int[] FDSelect = fonts[Font].FDSelect; + int[] fdSelect = fonts[Font].getFDSelect(); // For each glyph used for (Integer glyphsInList1 : glyphsInList) { // Pop the glyphs index int glyph = (int) glyphsInList1; // Pop the glyph's FD - int FD = FDSelect[glyph]; + int FD = fdSelect[glyph]; // Put the FD index into the FDArrayUsed Map FDArrayUsed.add(FD); } @@ -326,14 +326,14 @@ protected void BuildFDArrayUsed(int Font) { * @param Font the Number of font being processed */ protected void ReadFDArray(int Font) { - seek(fonts[Font].fdarrayOffset); - fonts[Font].FDArrayCount = getCard16(); - fonts[Font].FDArrayOffsize = getCard8(); + seek(fonts[Font].getFdarrayOffset()); + fonts[Font].setFDArrayCount(getCard16()); + fonts[Font].setFDArrayOffsize(getCard8()); // Since we will change values inside the FDArray objects // We increase its offsize to prevent errors - if (fonts[Font].FDArrayOffsize < 4) - fonts[Font].FDArrayOffsize++; - fonts[Font].FDArrayOffsets = getIndex(fonts[Font].fdarrayOffset); + if (fonts[Font].getFDArrayOffsize() < 4) + fonts[Font].setFDArrayOffsize(fonts[Font].getFDArrayOffsize() + 1); + fonts[Font].setFDArrayOffsets(getIndex(fonts[Font].getFdarrayOffset())); } @@ -349,7 +349,7 @@ public byte[] Process(String fontName) { // Find the Font that we will be dealing with int j; for (j = 0; j < fonts.length; j++) - if (fontName.equals(fonts[j].name)) break; + if (fontName.equals(fonts[j].getName())) break; if (j == fonts.length) return null; // Calc the bias for the global subrs @@ -395,7 +395,7 @@ protected int CalcBias(int Offset, int Font) { seek(Offset); int nSubrs = getCard16(); // If type==1 -> bias=0 - if (fonts[Font].CharstringType == 1) + if (fonts[Font].getCharstringType() == 1) return 0; // else calc according to the count else if (nSubrs < 1240) @@ -413,7 +413,7 @@ else if (nSubrs < 33900) * @throws java.io.IOException if an I/O error occurs */ protected void BuildNewCharString(int FontIndex) throws java.io.IOException { - NewCharStringsIndex = BuildNewIndex(fonts[FontIndex].charstringsOffsets, GlyphsUsed, ENDCHAR_OP); + NewCharStringsIndex = BuildNewIndex(fonts[FontIndex].getCharstringsOffsets(), GlyphsUsed, ENDCHAR_OP); } /** @@ -427,17 +427,17 @@ protected void BuildNewCharString(int FontIndex) throws java.io.IOException { protected void BuildNewLGSubrs(int Font) throws java.io.IOException { // If the font is CID then the lsubrs are divided into FontDicts. // for each FD array the lsubrs will be subsetted. - if (fonts[Font].isCID) { + if (fonts[Font].isCID()) { // Init the Map-array and the list-array to hold the subrs used // in each private dict. - hSubrsUsed = new GenericArray<>(fonts[Font].fdprivateOffsets.length); - lSubrsUsed = new GenericArray<>(fonts[Font].fdprivateOffsets.length); + hSubrsUsed = new GenericArray<>(fonts[Font].getFdprivateOffsets().length); + lSubrsUsed = new GenericArray<>(fonts[Font].getFdprivateOffsets().length); // A [][] which will store the byte array for each new FD Array lsubs index - NewLSubrsIndex = new byte[fonts[Font].fdprivateOffsets.length][]; + NewLSubrsIndex = new byte[fonts[Font].getFdprivateOffsets().length][]; // An array to hold the offset for each Lsubr index - fonts[Font].PrivateSubrsOffset = new int[fonts[Font].fdprivateOffsets.length]; + fonts[Font].setPrivateSubrsOffset(new int[fonts[Font].getFdprivateOffsets().length]); // A [][] which will store the offset array for each lsubr index - fonts[Font].PrivateSubrsOffsetsArray = new int[fonts[Font].fdprivateOffsets.length][]; + fonts[Font].setPrivateSubrsOffsetsArray(new int[fonts[Font].getFdprivateOffsets().length][]); // Put the FDarrayUsed into a list List FDInList = new ArrayList<>(FDArrayUsed); @@ -451,29 +451,32 @@ protected void BuildNewLGSubrs(int Font) throws java.io.IOException { // store both the offset for the index and its offset array BuildFDSubrsOffsets(Font, FD); // Verify that FDPrivate has a LSubrs index - if (fonts[Font].PrivateSubrsOffset[FD] >= 0) { + if (fonts[Font].getPrivateSubrsOffset()[FD] >= 0) { //Scans the Charstring data storing the used Local and Global subroutines // by the glyphs. Scans the Subrs recursively. - BuildSubrUsed(Font, FD, fonts[Font].PrivateSubrsOffset[FD], fonts[Font].PrivateSubrsOffsetsArray[FD], hSubrsUsed.get(FD), lSubrsUsed.get(FD)); + BuildSubrUsed(Font, FD, fonts[Font].getPrivateSubrsOffset()[FD], + fonts[Font].getPrivateSubrsOffsetsArray()[FD], hSubrsUsed.get(FD), lSubrsUsed.get(FD)); // Builds the New Local Subrs index - NewLSubrsIndex[FD] = BuildNewIndex(fonts[Font].PrivateSubrsOffsetsArray[FD], hSubrsUsed.get(FD), RETURN_OP); + NewLSubrsIndex[FD] = BuildNewIndex(fonts[Font].getPrivateSubrsOffsetsArray()[FD], + hSubrsUsed.get(FD), RETURN_OP); } } } // If the font is not CID && the Private Subr exists then subset: - else if (fonts[Font].privateSubrs >= 0) { + else if (fonts[Font].getPrivateSubrs() >= 0) { // Build the subrs offsets; - fonts[Font].SubrsOffsets = getIndex(fonts[Font].privateSubrs); + fonts[Font].setSubrsOffsets(getIndex(fonts[Font].getPrivateSubrs())); //Scans the Charstring data storing the used Local and Global subroutines // by the glyphs. Scans the Subrs recursively. - BuildSubrUsed(Font, -1, fonts[Font].privateSubrs, fonts[Font].SubrsOffsets, hSubrsUsedNonCID, lSubrsUsedNonCID); + BuildSubrUsed(Font, -1, fonts[Font].getPrivateSubrs(), fonts[Font].getSubrsOffsets(), + hSubrsUsedNonCID, lSubrsUsedNonCID); } // For all fonts subset the Global Subroutines // Scan the Global Subr Map recursively on the Gsubrs BuildGSubrsUsed(Font); - if (fonts[Font].privateSubrs >= 0) + if (fonts[Font].getPrivateSubrs() >= 0) // Builds the New Local Subrs index - NewSubrsIndexNonCID = BuildNewIndex(fonts[Font].SubrsOffsets, hSubrsUsedNonCID, RETURN_OP); + NewSubrsIndexNonCID = BuildNewIndex(fonts[Font].getSubrsOffsets(), hSubrsUsedNonCID, RETURN_OP); //Builds the New Global Subrs index // NOTE We copy all global subroutines to index here. // In some fonts (see NotoSansCJKjp-Bold.otf, Version 1.004;PS 1.004;hotconv 1.0.82;makeotf.lib2.5.63406) @@ -492,19 +495,28 @@ else if (fonts[Font].privateSubrs >= 0) { */ protected void BuildFDSubrsOffsets(int Font, int FD) { // Initiate to -1 to indicate lsubr operator present - fonts[Font].PrivateSubrsOffset[FD] = -1; + int[] privateSubrsOffset = fonts[Font].getPrivateSubrsOffset(); + privateSubrsOffset[FD] = -1; + fonts[Font].setPrivateSubrsOffset(privateSubrsOffset); // Goto beginning of objects - seek(fonts[Font].fdprivateOffsets[FD]); + seek(fonts[Font].getFdprivateOffsets()[FD]); // While in the same object: - while (getPosition() < fonts[Font].fdprivateOffsets[FD] + fonts[Font].fdprivateLengths[FD]) { + while (getPosition() < fonts[Font].getFdprivateOffsets()[FD] + fonts[Font].getFdprivateLengths()[FD]) { getDictItem(); // If the dictItem is the "Subrs" then find and store offset, - if ("Subrs".equals(key)) - fonts[Font].PrivateSubrsOffset[FD] = (int) ((Integer) args[0]) + fonts[Font].fdprivateOffsets[FD]; + if ("Subrs".equals(key)) { + privateSubrsOffset = fonts[Font].getPrivateSubrsOffset(); + privateSubrsOffset[FD] = (int) ((Integer) args[0]) + + fonts[Font].getFdprivateOffsets()[FD]; + fonts[Font].setPrivateSubrsOffset(privateSubrsOffset); + } } //Read the lsubr index if the lsubr was found - if (fonts[Font].PrivateSubrsOffset[FD] >= 0) - fonts[Font].PrivateSubrsOffsetsArray[FD] = getIndex(fonts[Font].PrivateSubrsOffset[FD]); + if (fonts[Font].getPrivateSubrsOffset()[FD] >= 0) { + int[][] privateSubrsOffsetsArray = fonts[Font].getPrivateSubrsOffsetsArray(); + privateSubrsOffsetsArray[FD] = getIndex(fonts[Font].getPrivateSubrsOffset()[FD]); + fonts[Font].setPrivateSubrsOffsetsArray(privateSubrsOffsetsArray); + } } /** @@ -527,23 +539,23 @@ protected void BuildSubrUsed(int Font, int FD, int SubrOffset, int[] SubrsOffset // For each glyph used find its GID, start & end pos for (Integer usedGlyph : glyphsInList) { int glyph = (int) usedGlyph; - int Start = fonts[Font].charstringsOffsets[glyph]; - int End = fonts[Font].charstringsOffsets[glyph + 1]; + int start = fonts[Font].getCharstringsOffsets()[glyph]; + int end = fonts[Font].getCharstringsOffsets()[glyph + 1]; // IF CID: if (FD >= 0) { EmptyStack(); NumOfHints = 0; // Using FDSELECT find the FD Array the glyph belongs to. - int GlyphFD = fonts[Font].FDSelect[glyph]; + int glyphFD = fonts[Font].getFDSelect()[glyph]; // If the Glyph is part of the FD being processed - if (GlyphFD == FD) + if (glyphFD == FD) // Find the Subrs called by the glyph and insert to hash: - ReadASubr(Start, End, GBias, LBias, hSubr, lSubr, SubrsOffsets); + ReadASubr(start, end, GBias, LBias, hSubr, lSubr, SubrsOffsets); } else // If the font is not CID //Find the Subrs called by the glyph and insert to hash: - ReadASubr(Start, End, GBias, LBias, hSubr, lSubr, SubrsOffsets); + ReadASubr(start, end, GBias, LBias, hSubr, lSubr, SubrsOffsets); } // For all Lsubrs used, check recursively for Lsubr & Gsubr used for (int i = 0; i < lSubr.size(); i++) { @@ -568,8 +580,8 @@ protected void BuildSubrUsed(int Font, int FD, int SubrOffset, int[] SubrsOffset protected void BuildGSubrsUsed(int Font) { int LBias = 0; int SizeOfNonCIDSubrsUsed = 0; - if (fonts[Font].privateSubrs >= 0) { - LBias = CalcBias(fonts[Font].privateSubrs, Font); + if (fonts[Font].getPrivateSubrs() >= 0) { + LBias = CalcBias(fonts[Font].getPrivateSubrs(), Font); SizeOfNonCIDSubrsUsed = lSubrsUsedNonCID.size(); } @@ -582,19 +594,20 @@ protected void BuildGSubrsUsed(int Font) { int Start = gsubrOffsets[Subr]; int End = gsubrOffsets[Subr + 1]; - if (fonts[Font].isCID) + if (fonts[Font].isCID()) ReadASubr(Start, End, GBias, 0, hGSubrsUsed, lGSubrsUsed, null); else { - ReadASubr(Start, End, GBias, LBias, hSubrsUsedNonCID, lSubrsUsedNonCID, fonts[Font].SubrsOffsets); + ReadASubr(Start, End, GBias, LBias, hSubrsUsedNonCID, lSubrsUsedNonCID, fonts[Font].getSubrsOffsets()); if (SizeOfNonCIDSubrsUsed < lSubrsUsedNonCID.size()) { for (int j = SizeOfNonCIDSubrsUsed; j < lSubrsUsedNonCID.size(); j++) { //Pop the value + check valid - int LSubr = (int) lSubrsUsedNonCID.get(j); - if (LSubr < fonts[Font].SubrsOffsets.length - 1 && LSubr >= 0) { + int lSubr = (int) lSubrsUsedNonCID.get(j); + if (lSubr < fonts[Font].getSubrsOffsets().length - 1 && lSubr >= 0) { // Read the subr and process - int LStart = fonts[Font].SubrsOffsets[LSubr]; - int LEnd = fonts[Font].SubrsOffsets[LSubr + 1]; - ReadASubr(LStart, LEnd, GBias, LBias, hSubrsUsedNonCID, lSubrsUsedNonCID, fonts[Font].SubrsOffsets); + int lStart = fonts[Font].getSubrsOffsets()[lSubr]; + int lEnd = fonts[Font].getSubrsOffsets()[lSubr + 1]; + ReadASubr(lStart, lEnd, GBias, LBias, hSubrsUsedNonCID, lSubrsUsedNonCID, + fonts[Font].getSubrsOffsets()); } } SizeOfNonCIDSubrsUsed = lSubrsUsedNonCID.size(); @@ -1102,8 +1115,8 @@ protected byte[] BuildNewFile(int Font) { // create a name index BuildIndexHeader(1, 1, 1); - OutputList.addLast(new UInt8Item((char) (1 + fonts[Font].name.length()))); - OutputList.addLast(new StringItem(fonts[Font].name)); + OutputList.addLast(new UInt8Item((char) (1 + fonts[Font].getName().length()))); + OutputList.addLast(new StringItem(fonts[Font].getName())); // create the topdict Index BuildIndexHeader(1, 2, 1); @@ -1120,15 +1133,15 @@ protected byte[] BuildNewFile(int Font) { OffsetItem privateRef = new DictOffsetItem(); // If the font is not CID create the following keys - if (!fonts[Font].isCID) { + if (!fonts[Font].isCID()) { // create a ROS key - OutputList.addLast(new DictNumberItem(fonts[Font].nstrings)); - OutputList.addLast(new DictNumberItem(fonts[Font].nstrings + 1)); + OutputList.addLast(new DictNumberItem(fonts[Font].getNstrings())); + OutputList.addLast(new DictNumberItem(fonts[Font].getNstrings() + 1)); OutputList.addLast(new DictNumberItem(0)); OutputList.addLast(new UInt8Item((char) 12)); OutputList.addLast(new UInt8Item((char) 30)); // create a CIDCount key - OutputList.addLast(new DictNumberItem(fonts[Font].nglyphs)); + OutputList.addLast(new DictNumberItem(fonts[Font].getNglyphs())); OutputList.addLast(new UInt8Item((char) 12)); OutputList.addLast(new UInt8Item((char) 34)); // Sivan's comments @@ -1150,7 +1163,7 @@ protected byte[] BuildNewFile(int Font) { || "FDArray".equals(key) || "charset".equals(key) || "CharStrings".equals(key) - ) { + ) { } else { //OtherWise copy key "as is" to the output list OutputList.addLast(new RangeItem(buf, p1, p2 - p1)); @@ -1164,7 +1177,7 @@ protected byte[] BuildNewFile(int Font) { // Copy the string index - if (fonts[Font].isCID) + if (fonts[Font].isCID()) OutputList.addLast(getEntireIndexRange(stringIndexOffset)); // If the font is not CID we need to append new strings. // We need 3 more strings: Registry, Ordering, and a FontName for one FD. @@ -1177,27 +1190,28 @@ protected byte[] BuildNewFile(int Font) { // deal with fdarray, fdselect, and the font descriptors // If the font is CID: - if (fonts[Font].isCID) { + if (fonts[Font].isCID()) { // copy the FDArray, FDSelect, charset // Copy FDSelect // Mark the beginning OutputList.addLast(new MarkerItem(fdselectRef)); // If an FDSelect exists copy it - if (fonts[Font].fdselectOffset >= 0) - OutputList.addLast(new RangeItem(buf, fonts[Font].fdselectOffset, fonts[Font].FDSelectLength)); + if (fonts[Font].getFdselectOffset() >= 0) + OutputList.addLast(new RangeItem(buf, fonts[Font].getFdselectOffset(), + fonts[Font].getFDSelectLength())); // Else create a new one else - CreateFDSelect(fdselectRef, fonts[Font].nglyphs); + CreateFDSelect(fdselectRef, fonts[Font].getNglyphs()); // Copy the Charset // Mark the beginning and copy entirely OutputList.addLast(new MarkerItem(charsetRef)); - OutputList.addLast(new RangeItem(buf, fonts[Font].charsetOffset, fonts[Font].CharsetLength)); + OutputList.addLast(new RangeItem(buf, fonts[Font].getCharsetOffset(), fonts[Font].getCharsetLength())); // Copy the FDArray // If an FDArray exists - if (fonts[Font].fdarrayOffset >= 0) { + if (fonts[Font].getFdarrayOffset() >= 0) { // Mark the beginning OutputList.addLast(new MarkerItem(fdarrayRef)); // Build a new FDArray with its private dicts and their LSubrs @@ -1210,15 +1224,15 @@ protected byte[] BuildNewFile(int Font) { // If the font is not CID else { // create FDSelect - CreateFDSelect(fdselectRef, fonts[Font].nglyphs); + CreateFDSelect(fdselectRef, fonts[Font].getNglyphs()); // recreate a new charset - CreateCharset(charsetRef, fonts[Font].nglyphs); + CreateCharset(charsetRef, fonts[Font].getNglyphs()); // create a font dict index (fdarray) CreateFDArray(fdarrayRef, privateRef, Font); } // if a private dict exists insert its subsetted version - if (fonts[Font].privateOffset >= 0) { + if (fonts[Font].getPrivateOffset() >= 0) { // Mark the beginning of the private dict IndexBaseItem PrivateBase = new IndexBaseItem(); OutputList.addLast(PrivateBase); @@ -1339,7 +1353,7 @@ protected void CreateKeys(OffsetItem fdarrayRef, OffsetItem fdselectRef, OffsetI * @param Font the font */ protected void CreateNewStringIndex(int Font) { - String fdFontName = fonts[Font].name + "-OneRange"; + String fdFontName = fonts[Font].getName() + "-OneRange"; if (fdFontName.length() > 127) fdFontName = fdFontName.substring(0, 127); String extraStrings = "Adobe" + "Identity" + fdFontName; @@ -1447,13 +1461,13 @@ protected void CreateFDArray(OffsetItem fdarrayRef, OffsetItem privateRef, int F OutputList.addLast(privateBase); // Calc the new size of the private after subsetting // Origianl size - int NewSize = fonts[Font].privateLength; + int newSize = fonts[Font].getPrivateLength(); // Calc the original size of the Subr offset in the private - int OrgSubrsOffsetSize = CalcSubrOffsetSize(fonts[Font].privateOffset, fonts[Font].privateLength); + int orgSubrsOffsetSize = CalcSubrOffsetSize(fonts[Font].getPrivateOffset(), fonts[Font].getPrivateLength()); // Increase the ptivate's size - if (OrgSubrsOffsetSize != 0) - NewSize += 5 - OrgSubrsOffsetSize; - OutputList.addLast(new DictNumberItem(NewSize)); + if (orgSubrsOffsetSize != 0) + newSize += 5 - orgSubrsOffsetSize; + OutputList.addLast(new DictNumberItem(newSize)); OutputList.addLast(privateRef); // Private OutputList.addLast(new UInt8Item((char) 18)); @@ -1468,9 +1482,9 @@ protected void CreateFDArray(OffsetItem fdarrayRef, OffsetItem privateRef, int F */ void Reconstruct(int Font) { // Init for later use - OffsetItem[] fdPrivate = new DictOffsetItem[fonts[Font].FDArrayOffsets.length - 1]; - IndexBaseItem[] fdPrivateBase = new IndexBaseItem[fonts[Font].fdprivateOffsets.length]; - OffsetItem[] fdSubrs = new DictOffsetItem[fonts[Font].fdprivateOffsets.length]; + OffsetItem[] fdPrivate = new DictOffsetItem[fonts[Font].getFDArrayOffsets().length - 1]; + IndexBaseItem[] fdPrivateBase = new IndexBaseItem[fonts[Font].getFdprivateOffsets().length]; + OffsetItem[] fdSubrs = new DictOffsetItem[fonts[Font].getFdprivateOffsets().length]; // Reconstruct each type ReconstructFDArray(Font, fdPrivate); ReconstructPrivateDict(Font, fdPrivate, fdPrivateBase, fdSubrs); @@ -1485,12 +1499,12 @@ void Reconstruct(int Font) { */ void ReconstructFDArray(int Font, OffsetItem[] fdPrivate) { // Build the header of the index - BuildIndexHeader(fonts[Font].FDArrayCount, fonts[Font].FDArrayOffsize, 1); + BuildIndexHeader(fonts[Font].getFDArrayCount(), fonts[Font].getFDArrayOffsize(), 1); // For each offset create an Offset Item - OffsetItem[] fdOffsets = new IndexOffsetItem[fonts[Font].FDArrayOffsets.length - 1]; - for (int i = 0; i < fonts[Font].FDArrayOffsets.length - 1; i++) { - fdOffsets[i] = new IndexOffsetItem(fonts[Font].FDArrayOffsize); + OffsetItem[] fdOffsets = new IndexOffsetItem[fonts[Font].getFDArrayOffsets().length - 1]; + for (int i = 0; i < fonts[Font].getFDArrayOffsets().length - 1; i++) { + fdOffsets[i] = new IndexOffsetItem(fonts[Font].getFDArrayOffsize()); OutputList.addLast(fdOffsets[i]); } @@ -1502,12 +1516,12 @@ void ReconstructFDArray(int Font, OffsetItem[] fdPrivate) { // if is used build a new one by changing the private object // Else do nothing // At the end of each object mark its ending (Even if wasn't written) - for (int k = 0; k < fonts[Font].FDArrayOffsets.length - 1; k++) { + for (int k = 0; k < fonts[Font].getFDArrayOffsets().length - 1; k++) { // if (FDArrayUsed.contains(Integer.valueOf(k))) // { // Goto beginning of objects - seek(fonts[Font].FDArrayOffsets[k]); - while (getPosition() < fonts[Font].FDArrayOffsets[k + 1]) { + seek(fonts[Font].getFDArrayOffsets()[k]); + while (getPosition() < fonts[Font].getFDArrayOffsets()[k + 1]) { int p1 = getPosition(); getDictItem(); int p2 = getPosition(); @@ -1515,14 +1529,15 @@ void ReconstructFDArray(int Font, OffsetItem[] fdPrivate) { // use marker for offset and write operator number if ("Private".equals(key)) { // Save the original length of the private dict - int NewSize = (int) ((Integer) args[0]); + int newSize = (int)((Integer) args[0]); // Save the size of the offset to the subrs in that private - int OrgSubrsOffsetSize = CalcSubrOffsetSize(fonts[Font].fdprivateOffsets[k], fonts[Font].fdprivateLengths[k]); + int orgSubrsOffsetSize = CalcSubrOffsetSize(fonts[Font].getFdprivateOffsets()[k], + fonts[Font].getFdprivateLengths()[k]); // Increase the private's length accordingly - if (OrgSubrsOffsetSize != 0) - NewSize += 5 - OrgSubrsOffsetSize; + if (orgSubrsOffsetSize != 0) + newSize += 5 - orgSubrsOffsetSize; // Insert the new size, OffsetItem and operator key number - OutputList.addLast(new DictNumberItem(NewSize)); + OutputList.addLast(new DictNumberItem(newSize)); fdPrivate[k] = new DictOffsetItem(); OutputList.addLast(fdPrivate[k]); // Private @@ -1549,12 +1564,12 @@ void ReconstructFDArray(int Font, OffsetItem[] fdPrivate) { * @param fdSubrs OffsetItem array one element for each private */ void ReconstructPrivateDict(int Font, OffsetItem[] fdPrivate, IndexBaseItem[] fdPrivateBase, - OffsetItem[] fdSubrs) { + OffsetItem[] fdSubrs) { // For each fdarray private dict check if that FD is used. // if is used build a new one by changing the subrs offset // Else do nothing - for (int i = 0; i < fonts[Font].fdprivateOffsets.length; i++) { + for (int i = 0; i < fonts[Font].getFdprivateOffsets().length; i++) { // if (FDArrayUsed.contains(Integer.valueOf(i))) // { // Mark beginning @@ -1562,8 +1577,8 @@ void ReconstructPrivateDict(int Font, OffsetItem[] fdPrivate, IndexBaseItem[] fd fdPrivateBase[i] = new IndexBaseItem(); OutputList.addLast(fdPrivateBase[i]); // Goto beginning of objects - seek(fonts[Font].fdprivateOffsets[i]); - while (getPosition() < fonts[Font].fdprivateOffsets[i] + fonts[Font].fdprivateLengths[i]) { + seek(fonts[Font].getFdprivateOffsets()[i]); + while (getPosition() < fonts[Font].getFdprivateOffsets()[i] + fonts[Font].getFdprivateLengths()[i]) { int p1 = getPosition(); getDictItem(); int p2 = getPosition(); @@ -1592,12 +1607,12 @@ void ReconstructPrivateDict(int Font, OffsetItem[] fdPrivate, IndexBaseItem[] fd */ void ReconstructPrivateSubrs(int Font, IndexBaseItem[] fdPrivateBase, - OffsetItem[] fdSubrs) { + OffsetItem[] fdSubrs) { // For each private dict - for (int i = 0; i < fonts[Font].fdprivateLengths.length; i++) { + for (int i = 0; i < fonts[Font].getFdprivateLengths().length; i++) { // If that private dict's Subrs are used insert the new LSubrs // computed earlier - if (fdSubrs[i] != null && fonts[Font].PrivateSubrsOffset[i] >= 0) { + if (fdSubrs[i] != null && fonts[Font].getPrivateSubrsOffset()[i] >= 0) { OutputList.addLast(new SubrMarkerItem(fdSubrs[i], fdPrivateBase[i])); if (NewLSubrsIndex[i] != null) OutputList.addLast(new RangeItem(new RandomAccessFileOrArray(rasFactory.createSource(NewLSubrsIndex[i])), 0, NewLSubrsIndex[i].length)); @@ -1669,8 +1684,8 @@ protected int countEntireIndexRange(int indexOffset) { */ void CreateNonCIDPrivate(int Font, OffsetItem Subr) { // Go to the beginning of the private dict and read until the end - seek(fonts[Font].privateOffset); - while (getPosition() < fonts[Font].privateOffset + fonts[Font].privateLength) { + seek(fonts[Font].getPrivateOffset()); + while (getPosition() < fonts[Font].getPrivateOffset() + fonts[Font].getPrivateLength()) { int p1 = getPosition(); getDictItem(); int p2 = getPosition(); @@ -1724,14 +1739,14 @@ int getCidForGlyphId(int gid) { * @return CID value */ int getCidForGlyphId(int fontIndex, int gid) { - if (fonts[fontIndex].gidToCid == null) { + if (fonts[fontIndex].getGidToCid() == null) { return gid; } // gidToCid mapping starts with value corresponding to gid == 1, becuase .notdef is omitted int index = gid - 1; - return index >= 0 && index < fonts[fontIndex].gidToCid.length - ? fonts[fontIndex].gidToCid[index] + return index >= 0 && index < fonts[fontIndex].getGidToCid().length + ? fonts[fontIndex].getGidToCid()[index] : gid; } @@ -1751,13 +1766,15 @@ private void initGlyphIdToCharacterIdArray(int fontIndex, int numOfGlyphs, int o // .notdef is omitted, therefore remaining number of elements is one less than overall number int numOfElements = numOfGlyphs - 1; - fonts[fontIndex].gidToCid = new int[numOfElements]; + fonts[fontIndex].setGidToCid(new int[numOfElements]); switch (format) { case 0: for (int i = 0; i < numOfElements; i++) { int cid = getCard16(); - fonts[fontIndex].gidToCid[i] = cid; + int[] gidToCid = fonts[fontIndex].getGidToCid(); + gidToCid[i] = cid; + fonts[fontIndex].setGidToCid(gidToCid); } break; case 1: @@ -1767,7 +1784,9 @@ private void initGlyphIdToCharacterIdArray(int fontIndex, int numOfGlyphs, int o int first = getCard16(); int nLeft = format == 1 ? getCard8() : getCard16(); for (int i = 0; i <= nLeft && start < numOfElements; i++) { - fonts[fontIndex].gidToCid[start++] = first + i; + int[] gidToCid = fonts[fontIndex].getGidToCid(); + gidToCid[start++] = first + i; + fonts[fontIndex].setGidToCid(gidToCid); } } break; diff --git a/io/src/main/java/com/itextpdf/io/font/FontCache.java b/io/src/main/java/com/itextpdf/io/font/FontCache.java index d509d77e80..ce51545fd4 100644 --- a/io/src/main/java/com/itextpdf/io/font/FontCache.java +++ b/io/src/main/java/com/itextpdf/io/font/FontCache.java @@ -34,87 +34,7 @@ This file is part of the iText (R) project. public class FontCache { - private static Map fontCache = new ConcurrentHashMap<>(); - - /** - * Checks if the font with the given name and encoding is one - * of the predefined CID fonts. - * - * @param fontName the font name. - * @return {@code true} if it is CJKFont. - * @deprecated in favour of {@link CjkResourceLoader}. - */ - @Deprecated - protected static boolean isPredefinedCidFont(String fontName) { - return CjkResourceLoader.isPredefinedCidFont(fontName); - } - - /** - * Finds a CJK font family which is compatible to the given CMap. - * - * @param cmap a name of the CMap for which compatible font is searched. - * @return a CJK font name if there's known compatible font for the given cmap name, or null otherwise. - * @deprecated in favour of {@link CjkResourceLoader}. - */ - @Deprecated - public static String getCompatibleCidFont(String cmap) { - return CjkResourceLoader.getCompatibleCidFont(cmap); - } - - /** - * Finds all CMap names that belong to the same registry to which a given - * font belongs. - * - * @param fontName a name of the font for which CMap's are searched. - * @return a set of CMap names corresponding to the given font. - * @deprecated in favour of {@link CjkResourceLoader}. - */ - @Deprecated - public static Set getCompatibleCmaps(String fontName) { - return CjkResourceLoader.getCompatibleCmaps(fontName); - } - - @Deprecated - public static Map> getAllPredefinedCidFonts() { - return CjkResourceLoader.getAllPredefinedCidFonts(); - } - - @Deprecated - public static Map> getRegistryNames() { - return CjkResourceLoader.getRegistryNames(); - } - - /** - * Parses CMap with a given name producing it in a form of cid to unicode mapping. - * - * @param uniMap a CMap name. It is expected that CMap identified by this name defines unicode to cid mapping. - * @return an object for convenient mapping from cid to unicode. If no CMap was found for provided name an exception is thrown. - * @deprecated in favour of {@link CjkResourceLoader}. - */ - @Deprecated - public static CMapCidUni getCid2UniCmap(String uniMap) { - return CjkResourceLoader.getCid2UniCmap(uniMap); - } - - @Deprecated - public static CMapUniCid getUni2CidCmap(String uniMap) { - return CjkResourceLoader.getUni2CidCmap(uniMap); - } - - @Deprecated - public static CMapByteCid getByte2CidCmap(String cmap) { - return CjkResourceLoader.getByte2CidCmap(cmap); - } - - @Deprecated - public static CMapCidToCodepoint getCidToCodepointCmap(String cmap) { - return CjkResourceLoader.getCidToCodepointCmap(cmap); - } - - @Deprecated - public static CMapCodepointToCid getCodepointToCidCmap(String uniMap) { - return CjkResourceLoader.getCodepointToCidCmap(uniMap); - } + private static final Map fontCache = new ConcurrentHashMap<>(); /** * Clears the cache by removing fonts that were added via {@link #saveFont(FontProgram, String)}. diff --git a/io/src/main/java/com/itextpdf/io/font/OpenTypeParser.java b/io/src/main/java/com/itextpdf/io/font/OpenTypeParser.java index f76cdc9e58..e590588e86 100644 --- a/io/src/main/java/com/itextpdf/io/font/OpenTypeParser.java +++ b/io/src/main/java/com/itextpdf/io/font/OpenTypeParser.java @@ -819,6 +819,7 @@ private void readCmapTable() throws java.io.IOException { int map31 = 0; int map30 = 0; int mapExt = 0; + int map03 = 0; cmaps = new CmapTable(); for (int k = 0; k < num_tables; ++k) { int platId = raf.readUnsignedShort(); @@ -833,6 +834,8 @@ private void readCmapTable() throws java.io.IOException { mapExt = offset; } else if (platId == 1 && platSpecId == 0) { map10 = offset; + } else if (platId == 0 && platSpecId == 3) { + map03 = offset; } } if (map10 > 0) { @@ -850,6 +853,24 @@ private void readCmapTable() throws java.io.IOException { break; } } + if (map03 > 0) { + // Unicode platform, Unicode >2.0 semantics, expect format 4 or 6 subtable + raf.seek(table_location[0] + map03); + int format = raf.readUnsignedShort(); + + // We treat this table as equivalent to (platformId = 3, encodingId = 1) + // for downstream processing, since both are intended to address the Unicode BMP. + // Note that only one of these encoding subtables is used at a time. If multiple encoding subtables + // are found, the ‘cmap’ parsing software determines which one to use. + switch (format) { + case 4: + cmaps.cmap31 = readFormat4(false); + break; + case 6: + cmaps.cmap31 = readFormat6(); + break; + } + } if (map31 > 0) { raf.seek(table_location[0] + map31); int format = raf.readUnsignedShort(); diff --git a/io/src/main/java/com/itextpdf/io/font/cmap/CMapByteCid.java b/io/src/main/java/com/itextpdf/io/font/cmap/CMapByteCid.java index 4ad4257947..f4314c8386 100644 --- a/io/src/main/java/com/itextpdf/io/font/cmap/CMapByteCid.java +++ b/io/src/main/java/com/itextpdf/io/font/cmap/CMapByteCid.java @@ -32,16 +32,52 @@ public class CMapByteCid extends AbstractCMap { protected static class Cursor { - public int offset; - public int length; + private int offset; + private int length; public Cursor(int offset, int length) { this.offset = offset; this.length = length; } + + /** + * Retrieves the offset of the object. + * + * @return offset value + */ + public int getOffset() { + return offset; + } + + /** + * Sets the offset of the object. + * + * @param offset offset value + */ + public void setOffset(int offset) { + this.offset = offset; + } + + /** + * Retrieves the length of the object. + * + * @return length value + */ + public int getLength() { + return length; + } + + /** + * Sets the length value of the object. + * + * @param length length value + */ + public void setLength(int length) { + this.length = length; + } } - private List planes = new ArrayList<>(); + private final List planes = new ArrayList<>(); public CMapByteCid() { planes.add(new int[256]); @@ -73,11 +109,12 @@ public String decodeSequence(byte[] cidBytes, int offset, int length) { } protected int decodeSingle(byte[] cidBytes, Cursor cursor) { - int end = cursor.offset + cursor.length; + int end = cursor.getOffset() + cursor.getLength(); int currentPlane = 0; - while (cursor.offset < end) { - int one = cidBytes[cursor.offset++] & 0xff; - cursor.length--; + while (cursor.getOffset() < end) { + int one = cidBytes[cursor.getOffset()] & 0xff; + cursor.setOffset(cursor.getOffset() + 1); + cursor.setLength(cursor.getLength() - 1); int[] plane = planes.get(currentPlane); int cid = plane[one]; if ((cid & 0x8000) == 0) { diff --git a/io/src/main/java/com/itextpdf/io/font/cmap/CMapContentParser.java b/io/src/main/java/com/itextpdf/io/font/cmap/CMapContentParser.java index 76d50fce68..4d8fb0e4f5 100644 --- a/io/src/main/java/com/itextpdf/io/font/cmap/CMapContentParser.java +++ b/io/src/main/java/com/itextpdf/io/font/cmap/CMapContentParser.java @@ -182,18 +182,6 @@ public boolean nextValidToken() throws java.io.IOException { return false; } - /** - * Use {@link PdfNameUtil#decodeName(byte[])} instead. - * - * @param content to decode - * @return decoded content - * @deprecated - */ - @Deprecated - protected static String decodeName(byte[] content) { - return PdfNameUtil.decodeName(content); - } - private static String toHex4(int n) { String s = "0000" + Integer.toHexString(n); return s.substring(s.length() - 4); diff --git a/io/src/main/java/com/itextpdf/io/font/cmap/CMapToUnicode.java b/io/src/main/java/com/itextpdf/io/font/cmap/CMapToUnicode.java index 88f5a37357..e0c71211d1 100644 --- a/io/src/main/java/com/itextpdf/io/font/cmap/CMapToUnicode.java +++ b/io/src/main/java/com/itextpdf/io/font/cmap/CMapToUnicode.java @@ -40,7 +40,7 @@ This file is part of the iText (R) project. */ public class CMapToUnicode extends AbstractCMap { - public static CMapToUnicode EmptyCMapToUnicodeMap = new CMapToUnicode(true); + public static final CMapToUnicode EMPTY_CMAP = new CMapToUnicode(true); private final Map byteMappings; diff --git a/io/src/main/java/com/itextpdf/io/font/constants/FontDescriptorFlags.java b/io/src/main/java/com/itextpdf/io/font/constants/FontDescriptorFlags.java index 5df93c359c..61af783a03 100644 --- a/io/src/main/java/com/itextpdf/io/font/constants/FontDescriptorFlags.java +++ b/io/src/main/java/com/itextpdf/io/font/constants/FontDescriptorFlags.java @@ -29,13 +29,13 @@ public final class FontDescriptorFlags { private FontDescriptorFlags() { } - public static int FixedPitch = 1; - public static int Serif = 1 << 1; - public static int Symbolic = 1 << 2; - public static int Script = 1 << 3; - public static int Nonsymbolic = 1 << 5; - public static int Italic = 1 << 6; - public static int AllCap = 1 << 16; - public static int SmallCap = 1 << 17; - public static int ForceBold = 1 << 18; + public static final int FIXED_PITCH = 1; + public static final int SERIF = 1 << 1; + public static final int SYMBOLIC = 1 << 2; + public static final int SCRIPT = 1 << 3; + public static final int NONSYMBOLIC = 1 << 5; + public static final int ITALIC = 1 << 6; + public static final int ALL_CAP = 1 << 16; + public static final int SMALL_CAP = 1 << 17; + public static final int FORCE_BOLD = 1 << 18; } diff --git a/io/src/main/java/com/itextpdf/io/font/otf/ActualTextIterator.java b/io/src/main/java/com/itextpdf/io/font/otf/ActualTextIterator.java index e389869219..f4b316f2d1 100644 --- a/io/src/main/java/com/itextpdf/io/font/otf/ActualTextIterator.java +++ b/io/src/main/java/com/itextpdf/io/font/otf/ActualTextIterator.java @@ -32,7 +32,7 @@ public class ActualTextIterator implements Iterator { public ActualTextIterator(GlyphLine glyphLine) { this.glyphLine = glyphLine; - this.pos = glyphLine.start; + this.pos = glyphLine.getStart(); } public ActualTextIterator(GlyphLine glyphLine, int start, int end) { @@ -43,30 +43,30 @@ public ActualTextIterator(GlyphLine glyphLine, int start, int end) { @Override public boolean hasNext() { - return pos < glyphLine.end; + return pos < glyphLine.getEnd(); } @Override public GlyphLine.GlyphLinePart next() { if (glyphLine.actualText == null) { - GlyphLine.GlyphLinePart result = new GlyphLine.GlyphLinePart(pos, glyphLine.end, null); - pos = glyphLine.end; + GlyphLine.GlyphLinePart result = new GlyphLine.GlyphLinePart(pos, glyphLine.getEnd(), null); + pos = glyphLine.getEnd(); return result; } else { GlyphLine.GlyphLinePart currentResult = nextGlyphLinePart(pos); if (currentResult == null) { return null; } - pos = currentResult.end; + pos = currentResult.getEnd(); if (!glyphLinePartNeedsActualText(currentResult)) { - currentResult.actualText = null; + currentResult.setActualText(null); // Try to add more pieces without "actual text" - while (pos < glyphLine.end) { + while (pos < glyphLine.getEnd()) { GlyphLine.GlyphLinePart nextResult = nextGlyphLinePart(pos); if (nextResult != null && !glyphLinePartNeedsActualText(nextResult)) { - currentResult.end = nextResult.end; - pos = nextResult.end; + currentResult.setEnd(nextResult.getEnd()); + pos = nextResult.getEnd(); } else { break; } @@ -82,24 +82,24 @@ public void remove() { } private GlyphLine.GlyphLinePart nextGlyphLinePart(int pos) { - if (pos >= glyphLine.end) { + if (pos >= glyphLine.getEnd()) { return null; } int startPos = pos; GlyphLine.ActualText startActualText = glyphLine.actualText.get(pos); - while (pos < glyphLine.end && glyphLine.actualText.get(pos) == startActualText) { + while (pos < glyphLine.getEnd() && glyphLine.actualText.get(pos) == startActualText) { pos++; } - return new GlyphLine.GlyphLinePart(startPos, pos, startActualText != null ? startActualText.value : null); + return new GlyphLine.GlyphLinePart(startPos, pos, startActualText != null ? startActualText.getValue() : null); } private boolean glyphLinePartNeedsActualText(GlyphLine.GlyphLinePart glyphLinePart) { - if (glyphLinePart.actualText == null) { + if (glyphLinePart.getActualText() == null) { return false; } boolean needsActualText = false; StringBuilder toUnicodeMapResult = new StringBuilder(); - for (int i = glyphLinePart.start; i < glyphLinePart.end; i++) { + for (int i = glyphLinePart.getStart(); i < glyphLinePart.getEnd(); i++) { Glyph currentGlyph = glyphLine.glyphs.get(i); if (!currentGlyph.hasValidUnicode()) { needsActualText = true; @@ -108,6 +108,6 @@ private boolean glyphLinePartNeedsActualText(GlyphLine.GlyphLinePart glyphLinePa toUnicodeMapResult.append(TextUtil.convertFromUtf32(currentGlyph.getUnicode())); } - return needsActualText || !toUnicodeMapResult.toString().equals(glyphLinePart.actualText); + return needsActualText || !toUnicodeMapResult.toString().equals(glyphLinePart.getActualText()); } } diff --git a/io/src/main/java/com/itextpdf/io/font/otf/ChainingContextualTable.java b/io/src/main/java/com/itextpdf/io/font/otf/ChainingContextualTable.java index e99136633a..80eb4c1a88 100644 --- a/io/src/main/java/com/itextpdf/io/font/otf/ChainingContextualTable.java +++ b/io/src/main/java/com/itextpdf/io/font/otf/ChainingContextualTable.java @@ -32,11 +32,11 @@ protected ChainingContextualTable(OpenTypeFontTableReader openReader, int lookup @Override public T getMatchingContextRule(GlyphLine line) { - if (line.idx >= line.end) { + if (line.getIdx() >= line.getEnd()) { return null; } - Glyph g = line.get(line.idx); + Glyph g = line.get(line.getIdx()); List rules = getSetOfRulesForStartGlyph(g.getCode()); for (T rule : rules) { int lastGlyphIndex = checkIfContextMatch(line, rule); @@ -45,8 +45,8 @@ public T getMatchingContextRule(GlyphLine line) { && checkIfLookaheadContextMatch(line, rule, lastGlyphIndex) && checkIfBacktrackContextMatch(line, rule)) { - line.start = line.idx; - line.end = lastGlyphIndex + 1; + line.setStart(line.getIdx()); + line.setEnd(lastGlyphIndex + 1); return rule; } } @@ -65,11 +65,11 @@ && checkIfBacktrackContextMatch(line, rule)) { */ protected boolean checkIfLookaheadContextMatch(GlyphLine line, T rule, int startIdx) { OpenTableLookup.GlyphIndexer gidx = new OpenTableLookup.GlyphIndexer(); - gidx.line = line; - gidx.idx = startIdx; + gidx.setLine(line); + gidx.setIdx(startIdx); for (int j = 0; j < rule.getLookaheadContextLength(); ++j) { gidx.nextGlyph(openReader, lookupFlag); - if (gidx.glyph == null || !rule.isGlyphMatchesLookahead(gidx.glyph.getCode(), j)) { + if (gidx.getGlyph() == null || !rule.isGlyphMatchesLookahead(gidx.getGlyph().getCode(), j)) { return false; } } @@ -85,11 +85,11 @@ protected boolean checkIfLookaheadContextMatch(GlyphLine line, T rule, int start */ protected boolean checkIfBacktrackContextMatch(GlyphLine line, T rule) { OpenTableLookup.GlyphIndexer gidx = new OpenTableLookup.GlyphIndexer(); - gidx.line = line; - gidx.idx = line.idx; + gidx.setLine(line); + gidx.setIdx(line.getIdx()); for (int j = 0; j < rule.getBacktrackContextLength(); ++j) { gidx.previousGlyph(openReader, lookupFlag); - if (gidx.glyph == null || !rule.isGlyphMatchesBacktrack(gidx.glyph.getCode(), j)) { + if (gidx.getGlyph() == null || !rule.isGlyphMatchesBacktrack(gidx.getGlyph().getCode(), j)) { return false; } } diff --git a/io/src/main/java/com/itextpdf/io/font/otf/ContextualTable.java b/io/src/main/java/com/itextpdf/io/font/otf/ContextualTable.java index e17c425482..bd1c594180 100644 --- a/io/src/main/java/com/itextpdf/io/font/otf/ContextualTable.java +++ b/io/src/main/java/com/itextpdf/io/font/otf/ContextualTable.java @@ -45,17 +45,17 @@ protected ContextualTable(OpenTypeFontTableReader openReader, int lookupFlag) { * @return matching context rule or null, if none was found. */ public T getMatchingContextRule(GlyphLine line) { - if (line.idx >= line.end) { + if (line.getIdx() >= line.getEnd()) { return null; } - Glyph g = line.get(line.idx); + Glyph g = line.get(line.getIdx()); List rules = getSetOfRulesForStartGlyph(g.getCode()); for (T rule : rules) { int lastGlyphIndex = checkIfContextMatch(line, rule); if (lastGlyphIndex != -1) { - line.start = line.idx; - line.end = lastGlyphIndex + 1; + line.setStart(line.getIdx()); + line.setEnd(lastGlyphIndex + 1); return rule; } } @@ -83,20 +83,20 @@ public T getMatchingContextRule(GlyphLine line) { protected int checkIfContextMatch(GlyphLine line, T rule) { int j; OpenTableLookup.GlyphIndexer gidx = new OpenTableLookup.GlyphIndexer(); - gidx.line = line; - gidx.idx = line.idx; + gidx.setLine(line); + gidx.setIdx(line.getIdx()); //Note, that starting index shall be 1 for (j = 1; j < rule.getContextLength(); ++j) { gidx.nextGlyph(openReader, lookupFlag); - if (gidx.glyph == null || !rule.isGlyphMatchesInput(gidx.glyph.getCode(), j)) { + if (gidx.getGlyph() == null || !rule.isGlyphMatchesInput(gidx.getGlyph().getCode(), j)) { break; } } boolean isMatch = j == rule.getContextLength(); if (isMatch) { - return gidx.idx; + return gidx.getIdx(); } else { return -1; } diff --git a/io/src/main/java/com/itextpdf/io/font/otf/FeatureRecord.java b/io/src/main/java/com/itextpdf/io/font/otf/FeatureRecord.java index e2ccb1a601..3839f50f0b 100644 --- a/io/src/main/java/com/itextpdf/io/font/otf/FeatureRecord.java +++ b/io/src/main/java/com/itextpdf/io/font/otf/FeatureRecord.java @@ -23,6 +23,42 @@ This file is part of the iText (R) project. package com.itextpdf.io.font.otf; public class FeatureRecord { - public String tag; - public int[] lookups; + private String tag; + private int[] lookups; + + /** + * Retrieves the tag of the feature record. + * + * @return tag + */ + public String getTag() { + return tag; + } + + /** + * Sets the tag of the feature record. + * + * @param tag tag + */ + public void setTag(String tag) { + this.tag = tag; + } + + /** + * Retrieves the lookups of the feature record. + * + * @return lookups + */ + public int[] getLookups() { + return lookups; + } + + /** + * Sets the lookups of the feature record. + * + * @param lookups lookups + */ + public void setLookups(int[] lookups) { + this.lookups = lookups; + } } diff --git a/io/src/main/java/com/itextpdf/io/font/otf/GlyphLine.java b/io/src/main/java/com/itextpdf/io/font/otf/GlyphLine.java index bb8fd2049b..098f0a33ba 100644 --- a/io/src/main/java/com/itextpdf/io/font/otf/GlyphLine.java +++ b/io/src/main/java/com/itextpdf/io/font/otf/GlyphLine.java @@ -29,9 +29,9 @@ This file is part of the iText (R) project. import java.util.List; public class GlyphLine { - public int start; - public int end; - public int idx; + private int start; + private int end; + private int idx; protected List glyphs; protected List actualText; @@ -106,6 +106,60 @@ public GlyphLine(GlyphLine other, int start, int end) { this.idx = other.idx - start; } + /** + * Retrieves the start of the glyph line. + * + * @return start of glyph line + */ + public int getStart() { + return start; + } + + /** + * Sets the start of the glyph line. + * + * @param start start of glyph line + */ + public void setStart(int start) { + this.start = start; + } + + /** + * Retrieves the end of the glyph line. + * + * @return end of glyph line + */ + public int getEnd() { + return end; + } + + /** + * Sets the end of the glyph line. + * + * @param end end of glyph line + */ + public void setEnd(int end) { + this.end = end; + } + + /** + * Retrieves the idx of the glyph line. + * + * @return idx of glyph line + */ + public int getIdx() { + return idx; + } + + /** + * Sets the idx of the glyph line. + * + * @param idx idx of glyph line + */ + public void setIdx(int idx) { + this.idx = idx; + } + /** * Get the unicode string representation of the GlyphLine slice. * @@ -118,10 +172,10 @@ public String toUnicodeString(int start, int end) { StringBuilder str = new StringBuilder(); while (iter.hasNext()) { GlyphLinePart part = iter.next(); - if (part.actualText != null) { - str.append(part.actualText); + if (part.getActualText() != null) { + str.append(part.getActualText()); } else { - for (int i = part.start; i < part.end; i++) { + for (int i = part.getStart(); i < part.getEnd(); i++) { str.append(glyphs.get(i).getUnicodeChars()); } } @@ -143,9 +197,9 @@ public String toString() { */ public GlyphLine copy(int left, int right) { GlyphLine glyphLine = new GlyphLine(); - glyphLine.start = 0; - glyphLine.end = right - left; - glyphLine.glyphs = new ArrayList<>(glyphs.subList(left, right)); + glyphLine.setStart(0); + glyphLine.setEnd(right - left); + glyphLine.setGlyphs(new ArrayList<>(glyphs.subList(left, right))); glyphLine.actualText = actualText == null ? null : new ArrayList<>(actualText.subList(left, right)); return glyphLine; } @@ -194,9 +248,9 @@ public void add(GlyphLine other) { actualText.add(null); } } - actualText.addAll(other.actualText.subList(other.start, other.end)); + actualText.addAll(other.actualText.subList(other.getStart(), other.getEnd())); } - glyphs.addAll(other.glyphs.subList(other.start, other.end)); + glyphs.addAll(other.glyphs.subList(other.getStart(), other.getEnd())); if (null != actualText) { while (actualText.size() < glyphs.size()) { actualText.add(null); @@ -222,8 +276,8 @@ public void replaceContent(GlyphLine other) { } else { actualText = null; } - start = other.start; - end = other.end; + start = other.getStart(); + end = other.getEnd(); } public int size() { @@ -232,8 +286,8 @@ public int size() { public void substituteManyToOne(OpenTypeFontTableReader tableReader, int lookupFlag, int rightPartLen, int substitutionGlyphIndex) { OpenTableLookup.GlyphIndexer gidx = new OpenTableLookup.GlyphIndexer(); - gidx.line = this; - gidx.idx = idx; + gidx.setLine(this); + gidx.setIdx(idx); StringBuilder chars = new StringBuilder(); Glyph currentGlyph = glyphs.get(idx); @@ -245,13 +299,14 @@ public void substituteManyToOne(OpenTypeFontTableReader tableReader, int lookupF for (int j = 0; j < rightPartLen; ++j) { gidx.nextGlyph(tableReader, lookupFlag); - currentGlyph = glyphs.get(gidx.idx); + currentGlyph = glyphs.get(gidx.getIdx()); if (currentGlyph.getChars() != null) { chars.append(currentGlyph.getChars()); } else if (currentGlyph.hasValidUnicode()) { chars.append(TextUtil.convertFromUtf32(currentGlyph.getUnicode())); } - removeGlyph(gidx.idx--); + removeGlyph(gidx.getIdx()); + gidx.setIdx(gidx.getIdx() - 1); } char[] newChars = new char[chars.length()]; chars.getChars(0, chars.length(), newChars, 0); @@ -410,22 +465,115 @@ public interface IGlyphLineFilter { } public static class GlyphLinePart { - public int start; - public int end; + private int start; + private int end; // Might be null if it's not necessary - public String actualText; - public boolean reversed; - + private String actualText; + private boolean reversed; + + /** + * Creates a glyph line part object with given start and end values. + * Actual text is set to null. + * + * @param start start value of the glyph line part + * @param end end value of the glyph line part + */ public GlyphLinePart(int start, int end) { this(start, end, null); } + /** + * Creates a glyph line part object with given start, end and actual text values. + * + * @param start start value of the glyph line part + * @param end end value of the glyph line part + * @param actualText actual text + */ public GlyphLinePart(int start, int end, String actualText) { this.start = start; this.end = end; this.actualText = actualText; } + /** + * Retrieves the start of the glyph line part. + * + * @return start value of glyph line part + */ + public int getStart() { + return start; + } + + /** + * Sets the start of the glyph line part. + * + * @param start start of the glyph line part + * + * @return Altered glyph line part object + */ + public GlyphLinePart setStart(int start) { + this.start = start; + return this; + } + + /** + * Retrieves the end of the glyph line part. + * + * @return end value of glyph line part + */ + public int getEnd() { + return end; + } + + /** + * Sets the end of the glyph line part. + * + * @param end end value of glyph line part + * + * @return Altered glyph line part object + */ + public GlyphLinePart setEnd(int end) { + this.end = end; + return this; + } + + /** + * Retrieves the actual text of the glyph line part. + * + * @return Actual text of glyph line part + */ + public String getActualText() { + return actualText; + } + + /** + * Sets the actual text of the glyph line part. + * + * @param actualText Actual text of glyph line part + * + * @return Altered Glyph line part object + */ + public GlyphLinePart setActualText(String actualText) { + this.actualText = actualText; + return this; + } + + /** + * Retrieves whether the glyph line part is reversed. + * + * @return True if it is reversed, false otherwise. + */ + public boolean isReversed() { + return reversed; + } + + /** + * Sets whether the glyph line part is reversed. + * + * @param reversed true if it should be reversed, false otherwise + * + * @return Altered glyph line part object + */ public GlyphLinePart setReversed(boolean reversed) { this.reversed = reversed; return this; @@ -433,12 +581,21 @@ public GlyphLinePart setReversed(boolean reversed) { } protected static class ActualText { - public String value; + private final String value; public ActualText(String value) { this.value = value; } + /** + * Retrieves the value of the actual text. + * + * @return actual text value + */ + public String getValue() { + return value; + } + @Override public boolean equals(Object obj) { if (this == obj) { @@ -448,7 +605,7 @@ public boolean equals(Object obj) { return false; } ActualText other = (ActualText) obj; - return value == null && other.value == null || value.equals(other.value); + return value == null && other.getValue() == null || value.equals(other.getValue()); } @Override diff --git a/io/src/main/java/com/itextpdf/io/font/otf/GposAnchor.java b/io/src/main/java/com/itextpdf/io/font/otf/GposAnchor.java index 9550e80591..0c85fdcd35 100644 --- a/io/src/main/java/com/itextpdf/io/font/otf/GposAnchor.java +++ b/io/src/main/java/com/itextpdf/io/font/otf/GposAnchor.java @@ -24,14 +24,55 @@ This file is part of the iText (R) project. public class GposAnchor { - public int XCoordinate; - public int YCoordinate; + private int xCoordinate; + private int yCoordinate; public GposAnchor() { } - + + /** + * Creates a Gpos Anchor object based on a given Gpos Anchor object. + * + * @param other other Gpos Anchor object + */ public GposAnchor(GposAnchor other) { - this.XCoordinate = other.XCoordinate; - this.YCoordinate = other.YCoordinate; + this.xCoordinate = other.xCoordinate; + this.yCoordinate = other.yCoordinate; + } + + /** + * Retrieves the X coordinate of the Gpos Anchor. + * + * @return X coordinate + */ + public int getXCoordinate() { + return xCoordinate; + } + + /** + * Sets the x coordinate of the Gpos Anchor. + * + * @param xCoordinate X coordinate + */ + public void setXCoordinate(int xCoordinate) { + this.xCoordinate = xCoordinate; + } + + /** + * Retrieves the Y coordinate of the Gpos Anchor. + * + * @return Y coordinate + */ + public int getYCoordinate() { + return yCoordinate; + } + + /** + * Sets the Y coordinate of the Gpos Anchor. + * + * @param yCoordinate Y coordinate + */ + public void setYCoordinate(int yCoordinate) { + this.yCoordinate = yCoordinate; } } diff --git a/io/src/main/java/com/itextpdf/io/font/otf/GposLookupType1.java b/io/src/main/java/com/itextpdf/io/font/otf/GposLookupType1.java index 6113698396..611ea2704e 100644 --- a/io/src/main/java/com/itextpdf/io/font/otf/GposLookupType1.java +++ b/io/src/main/java/com/itextpdf/io/font/otf/GposLookupType1.java @@ -43,24 +43,24 @@ public GposLookupType1(OpenTypeFontTableReader openReader, int lookupFlag, int[] @Override public boolean transformOne(GlyphLine line) { - if (line.idx >= line.end) { + if (line.getIdx() >= line.getEnd()) { return false; } - if (openReader.isSkip(line.get(line.idx).getCode(), lookupFlag)) { - line.idx++; + if (openReader.isSkip(line.get(line.getIdx()).getCode(), lookupFlag)) { + line.setIdx(line.getIdx()+1); return false; } - int glyphCode = line.get(line.idx).getCode(); + int glyphCode = line.get(line.getIdx()).getCode(); boolean positionApplied = false; GposValueRecord valueRecord = valueRecordMap.get(glyphCode); if (valueRecord != null) { - Glyph newGlyph = new Glyph(line.get(line.idx)); - newGlyph.setXAdvance((short)(newGlyph.getXAdvance() + valueRecord.XAdvance)); - newGlyph.setYAdvance((short)(newGlyph.getYAdvance() + valueRecord.YAdvance)); - line.set(line.idx, newGlyph); + Glyph newGlyph = new Glyph(line.get(line.getIdx())); + newGlyph.setXAdvance((short)(newGlyph.getXAdvance() + valueRecord.getXAdvance())); + newGlyph.setYAdvance((short)(newGlyph.getYAdvance() + valueRecord.getYAdvance())); + line.set(line.getIdx(), newGlyph); positionApplied = true; } - line.idx++; + line.setIdx(line.getIdx()+1); return positionApplied; } diff --git a/io/src/main/java/com/itextpdf/io/font/otf/GposLookupType2.java b/io/src/main/java/com/itextpdf/io/font/otf/GposLookupType2.java index d02fde0c28..4ef6e328ea 100644 --- a/io/src/main/java/com/itextpdf/io/font/otf/GposLookupType2.java +++ b/io/src/main/java/com/itextpdf/io/font/otf/GposLookupType2.java @@ -45,17 +45,17 @@ public GposLookupType2(OpenTypeFontTableReader openReader, int lookupFlag, int[] @Override public boolean transformOne(GlyphLine line) { - if (line.idx >= line.end) + if (line.getIdx() >= line.getEnd()) return false; - if (openReader.isSkip(line.get(line.idx).getCode(), lookupFlag)) { - line.idx++; + if (openReader.isSkip(line.get(line.getIdx()).getCode(), lookupFlag)) { + line.setIdx(line.getIdx()+1); return false; } for (OpenTableLookup lookup : listRules) { if (lookup.transformOne(line)) return true; } - ++line.idx; + line.setIdx(line.getIdx()+1); return false; } @@ -88,23 +88,25 @@ public PairPosAdjustmentFormat1(OpenTypeFontTableReader openReader, int lookupFl } public boolean transformOne(GlyphLine line) { - if (line.idx >= line.end || line.idx < line.start) + if (line.getIdx() >= line.getEnd() || line.getIdx() < line.getStart()) return false; boolean changed = false; - Glyph g1 = line.get(line.idx); + Glyph g1 = line.get(line.getIdx()); Map m = gposMap.get(g1.getCode()); if (m != null) { GlyphIndexer gi = new GlyphIndexer(); - gi.line = line; - gi.idx = line.idx; + gi.setLine(line); + gi.setIdx(line.getIdx()); gi.nextGlyph(openReader, lookupFlag); - if (gi.glyph != null) { - PairValueFormat pv = m.get(gi.glyph.getCode()); + if (gi.getGlyph() != null) { + PairValueFormat pv = m.get(gi.getGlyph().getCode()); if (pv != null) { - Glyph g2 = gi.glyph; - line.set(line.idx, new Glyph(g1, 0, 0, pv.first.XAdvance, pv.first.YAdvance, 0)); - line.set(gi.idx, new Glyph(g2, 0, 0, pv.second.XAdvance, pv.second.YAdvance, 0)); - line.idx = gi.idx; + Glyph g2 = gi.getGlyph(); + line.set(line.getIdx(), new Glyph(g1, 0, 0, pv.getFirst().getXAdvance(), + pv.getFirst().getYAdvance(), 0)); + line.set(gi.getIdx(), new Glyph(g2, 0, 0, pv.getSecond().getXAdvance(), + pv.getSecond().getYAdvance(), 0)); + line.setIdx(gi.getIdx()); changed = true; } } @@ -127,8 +129,8 @@ protected void readFormat(int subTableLocation) throws java.io.IOException { for (int j = 0; j < pairValueCount; ++j) { int glyph2 = openReader.rf.readUnsignedShort(); PairValueFormat pair = new PairValueFormat(); - pair.first = OtfReadCommon.readGposValueRecord(openReader, valueFormat1); - pair.second = OtfReadCommon.readGposValueRecord(openReader, valueFormat2); + pair.setFirst(OtfReadCommon.readGposValueRecord(openReader, valueFormat1)); + pair.setSecond(OtfReadCommon.readGposValueRecord(openReader, valueFormat2)); pairs.put(glyph2, pair); } } @@ -152,9 +154,9 @@ public PairPosAdjustmentFormat2(OpenTypeFontTableReader openReader, int lookupFl } public boolean transformOne(GlyphLine line) { - if (line.idx >= line.end || line.idx < line.start) + if (line.getIdx() >= line.getEnd() || line.getIdx() < line.getStart()) return false; - Glyph g1 = line.get(line.idx); + Glyph g1 = line.get(line.getIdx()); if (!coverageSet.contains(g1.getCode())) return false; int c1 = classDef1.getOtfClass(g1.getCode()); @@ -162,19 +164,19 @@ public boolean transformOne(GlyphLine line) { if (pvs == null) return false; GlyphIndexer gi = new GlyphIndexer(); - gi.line = line; - gi.idx = line.idx; + gi.setLine(line); + gi.setIdx(line.getIdx()); gi.nextGlyph(openReader, lookupFlag); - if (gi.glyph == null) + if (gi.getGlyph() == null) return false; - Glyph g2 = gi.glyph; + Glyph g2 = gi.getGlyph(); int c2 = classDef2.getOtfClass(g2.getCode()); if (c2 >= pvs.length) return false; PairValueFormat pv = pvs[c2]; - line.set(line.idx, new Glyph(g1, 0, 0, pv.first.XAdvance, pv.first.YAdvance, 0)); - line.set(gi.idx, new Glyph(g2, 0, 0, pv.second.XAdvance, pv.second.YAdvance, 0)); - line.idx = gi.idx; + line.set(line.getIdx(), new Glyph(g1, 0, 0, pv.getFirst().getXAdvance(), pv.getFirst().getYAdvance(), 0)); + line.set(gi.getIdx(), new Glyph(g2, 0, 0, pv.getSecond().getXAdvance(), pv.getSecond().getYAdvance(), 0)); + line.setIdx(gi.getIdx()); return true; } @@ -192,8 +194,8 @@ protected void readFormat(int subTableLocation) throws java.io.IOException { posSubs.put(k, pairs); for (int j = 0; j < class2Count; ++j) { PairValueFormat pair = new PairValueFormat(); - pair.first = OtfReadCommon.readGposValueRecord(openReader, valueFormat1); - pair.second = OtfReadCommon.readGposValueRecord(openReader, valueFormat2); + pair.setFirst(OtfReadCommon.readGposValueRecord(openReader, valueFormat1)); + pair.setSecond(OtfReadCommon.readGposValueRecord(openReader, valueFormat2)); pairs[j] = pair; } } @@ -210,7 +212,43 @@ protected void readSubTable(int subTableLocation) { } private static class PairValueFormat { - public GposValueRecord first; - public GposValueRecord second; + private GposValueRecord first; + private GposValueRecord second; + + /** + * Retrieves the first object of the pair. + * + * @return first object + */ + public GposValueRecord getFirst() { + return first; + } + + /** + * Sets the first object of the pair. + * + * @param first first object + */ + public void setFirst(GposValueRecord first) { + this.first = first; + } + + /** + * Retrieves the second object of the pair. + * + * @return second object + */ + public GposValueRecord getSecond() { + return second; + } + + /** + * Sets the second object of the pair. + * + * @param second second object + */ + public void setSecond(GposValueRecord second) { + this.second = second; + } } } diff --git a/io/src/main/java/com/itextpdf/io/font/otf/GposLookupType4.java b/io/src/main/java/com/itextpdf/io/font/otf/GposLookupType4.java index bb7082a685..3132c711e5 100644 --- a/io/src/main/java/com/itextpdf/io/font/otf/GposLookupType4.java +++ b/io/src/main/java/com/itextpdf/io/font/otf/GposLookupType4.java @@ -43,62 +43,62 @@ public GposLookupType4(OpenTypeFontTableReader openReader, int lookupFlag, int[] @Override public boolean transformOne(GlyphLine line) { - if (line.idx >= line.end) { + if (line.getIdx() >= line.getEnd()) { return false; } - if (openReader.isSkip(line.get(line.idx).getCode(), lookupFlag)) { - line.idx++; + if (openReader.isSkip(line.get(line.getIdx()).getCode(), lookupFlag)) { + line.setIdx(line.getIdx()+1); return false; } boolean changed = false; GlyphIndexer gi = null; for (MarkToBase mb : marksbases) { - OtfMarkRecord omr = mb.marks.get(line.get(line.idx).getCode()); + OtfMarkRecord omr = mb.marks.get(line.get(line.getIdx()).getCode()); if (omr == null) continue; if (gi == null) { gi = new GlyphIndexer(); - gi.idx = line.idx; - gi.line = line; + gi.setIdx(line.getIdx()); + gi.setLine(line); while (true) { gi.previousGlyph(openReader, lookupFlag); - if (gi.glyph == null) { + if (gi.getGlyph() == null) { break; } // not mark => base glyph - if (openReader.getGlyphClass(gi.glyph.getCode()) != OtfClass.GLYPH_MARK) { + if (openReader.getGlyphClass(gi.getGlyph().getCode()) != OtfClass.GLYPH_MARK) { break; } } - if (gi.glyph == null) { + if (gi.getGlyph() == null) { break; } } - GposAnchor[] gpas = mb.bases.get(gi.glyph.getCode()); + GposAnchor[] gpas = mb.bases.get(gi.getGlyph().getCode()); if (gpas == null) { continue; } - int markClass = omr.markClass; + int markClass = omr.getMarkClass(); int xPlacement = 0; int yPlacement = 0; GposAnchor baseAnchor = gpas[markClass]; if (baseAnchor != null) { - xPlacement = baseAnchor.XCoordinate; - yPlacement = baseAnchor.YCoordinate; + xPlacement = baseAnchor.getXCoordinate(); + yPlacement = baseAnchor.getYCoordinate(); } - GposAnchor markAnchor = omr.anchor; + GposAnchor markAnchor = omr.getAnchor(); if (markAnchor != null) { - xPlacement -= markAnchor.XCoordinate; - yPlacement -= markAnchor.YCoordinate; + xPlacement -= markAnchor.getXCoordinate(); + yPlacement -= markAnchor.getYCoordinate(); } - line.set(line.idx, new Glyph(line.get(line.idx), + line.set(line.getIdx(), new Glyph(line.get(line.getIdx()), xPlacement, yPlacement, - 0, 0, gi.idx - line.idx)); + 0, 0, gi.getIdx() - line.getIdx())); changed = true; break; } - line.idx++; + line.setIdx(line.getIdx()+1); return changed; } diff --git a/io/src/main/java/com/itextpdf/io/font/otf/GposLookupType5.java b/io/src/main/java/com/itextpdf/io/font/otf/GposLookupType5.java index f923c2ea01..c2b2583316 100644 --- a/io/src/main/java/com/itextpdf/io/font/otf/GposLookupType5.java +++ b/io/src/main/java/com/itextpdf/io/font/otf/GposLookupType5.java @@ -43,42 +43,42 @@ public GposLookupType5(OpenTypeFontTableReader openReader, int lookupFlag, int[] @Override public boolean transformOne(GlyphLine line) { - if (line.idx >= line.end) + if (line.getIdx() >= line.getEnd()) return false; - if (openReader.isSkip(line.get(line.idx).getCode(), lookupFlag)) { - line.idx++; + if (openReader.isSkip(line.get(line.getIdx()).getCode(), lookupFlag)) { + line.setIdx(line.getIdx()+1); return false; } boolean changed = false; GlyphIndexer ligatureGlyphIndexer = null; for (MarkToLigature mb : marksligatures) { - OtfMarkRecord omr = mb.marks.get(line.get(line.idx).getCode()); + OtfMarkRecord omr = mb.marks.get(line.get(line.getIdx()).getCode()); if (omr == null) continue; if (ligatureGlyphIndexer == null) { ligatureGlyphIndexer = new GlyphIndexer(); - ligatureGlyphIndexer.idx = line.idx; - ligatureGlyphIndexer.line = line; + ligatureGlyphIndexer.setIdx(line.getIdx()); + ligatureGlyphIndexer.setLine(line); while (true) { ligatureGlyphIndexer.previousGlyph(openReader, lookupFlag); - if (ligatureGlyphIndexer.glyph == null) { + if (ligatureGlyphIndexer.getGlyph() == null) { break; } // not mark => ligature glyph - if (!mb.marks.containsKey(ligatureGlyphIndexer.glyph.getCode())) { + if (!mb.marks.containsKey(ligatureGlyphIndexer.getGlyph().getCode())) { break; } } - if (ligatureGlyphIndexer.glyph == null) { + if (ligatureGlyphIndexer.getGlyph() == null) { break; } } - List componentAnchors = mb.ligatures.get(ligatureGlyphIndexer.glyph.getCode()); + List componentAnchors = mb.ligatures.get(ligatureGlyphIndexer.getGlyph().getCode()); if (componentAnchors == null) { continue; } - int markClass = omr.markClass; + int markClass = omr.getMarkClass(); // TODO DEVSIX-3732 For complex cases like (glyph1, glyph2, mark, glyph3) and // (glyph1, mark, glyph2, glyph3) when the base glyphs compose a ligature and the mark // is attached to the ligature afterwards, mark should be placed in the corresponding anchor @@ -95,11 +95,11 @@ public boolean transformOne(GlyphLine line) { for (int component = componentAnchors.size() - 1; component >= 0; component--) { if (componentAnchors.get(component)[markClass] != null) { GposAnchor baseAnchor = componentAnchors.get(component)[markClass]; - GposAnchor markAnchor = omr.anchor; - line.set(line.idx, new Glyph(line.get(line.idx), - baseAnchor.XCoordinate - markAnchor.XCoordinate, - baseAnchor.YCoordinate - markAnchor.YCoordinate, - 0, 0, ligatureGlyphIndexer.idx - line.idx)); + GposAnchor markAnchor = omr.getAnchor(); + line.set(line.getIdx(), new Glyph(line.get(line.getIdx()), + baseAnchor.getXCoordinate() - markAnchor.getXCoordinate(), + baseAnchor.getYCoordinate() - markAnchor.getYCoordinate(), + 0, 0, ligatureGlyphIndexer.getIdx() - line.getIdx())); changed = true; break; } @@ -108,7 +108,7 @@ public boolean transformOne(GlyphLine line) { break; } - line.idx++; + line.setIdx(line.getIdx()+1); return changed; } diff --git a/io/src/main/java/com/itextpdf/io/font/otf/GposLookupType6.java b/io/src/main/java/com/itextpdf/io/font/otf/GposLookupType6.java index e856166c67..95a2e4d9da 100644 --- a/io/src/main/java/com/itextpdf/io/font/otf/GposLookupType6.java +++ b/io/src/main/java/com/itextpdf/io/font/otf/GposLookupType6.java @@ -43,30 +43,30 @@ public GposLookupType6(OpenTypeFontTableReader openReader, int lookupFlag, int[] @Override public boolean transformOne(GlyphLine line) { - if (line.idx >= line.end) + if (line.getIdx() >= line.getEnd()) return false; - if (openReader.isSkip(line.get(line.idx).getCode(), lookupFlag)) { - line.idx++; + if (openReader.isSkip(line.get(line.getIdx()).getCode(), lookupFlag)) { + line.setIdx(line.getIdx()+1); return false; } boolean changed = false; GlyphIndexer gi = null; for (MarkToBaseMark mb : marksbases) { - OtfMarkRecord omr = mb.marks.get(line.get(line.idx).getCode()); + OtfMarkRecord omr = mb.marks.get(line.get(line.getIdx()).getCode()); if (omr == null) continue; if (gi == null) { gi = new GlyphIndexer(); - gi.idx = line.idx; - gi.line = line; + gi.setIdx(line.getIdx()); + gi.setLine(line); while (true) { - int prev = gi.idx; + int prev = gi.getIdx(); // avoid attaching this mark glyph to another very distant mark glyph boolean foundBaseGlyph = false; gi.previousGlyph(openReader, lookupFlag); - if (gi.idx != -1) { - for (int i = gi.idx; i < prev; i++) { + if (gi.getIdx() != -1) { + for (int i = gi.getIdx(); i < prev; i++) { if (openReader.getGlyphClass(line.get(i).getCode()) == OtfClass.GLYPH_BASE) { foundBaseGlyph = true; break; @@ -74,31 +74,31 @@ public boolean transformOne(GlyphLine line) { } } if (foundBaseGlyph) { - gi.glyph = null; + gi.setGlyph(null); break; } - if (gi.glyph == null) + if (gi.getGlyph() == null) break; - if (mb.baseMarks.containsKey(gi.glyph.getCode())) + if (mb.baseMarks.containsKey(gi.getGlyph().getCode())) break; } - if (gi.glyph == null) + if (gi.getGlyph() == null) break; } - GposAnchor[] gpas = mb.baseMarks.get(gi.glyph.getCode()); + GposAnchor[] gpas = mb.baseMarks.get(gi.getGlyph().getCode()); if (gpas == null) continue; - int markClass = omr.markClass; + int markClass = omr.getMarkClass(); GposAnchor baseAnchor = gpas[markClass]; - GposAnchor markAnchor = omr.anchor; - line.set(line.idx, new Glyph(line.get(line.idx), - -markAnchor.XCoordinate + baseAnchor.XCoordinate, - -markAnchor.YCoordinate + baseAnchor.YCoordinate, - 0, 0, gi.idx - line.idx)); + GposAnchor markAnchor = omr.getAnchor(); + line.set(line.getIdx(), new Glyph(line.get(line.getIdx()), + -markAnchor.getXCoordinate() + baseAnchor.getXCoordinate(), + -markAnchor.getYCoordinate() + baseAnchor.getYCoordinate(), + 0, 0, gi.getIdx() - line.getIdx())); changed = true; break; } - line.idx++; + line.setIdx(line.getIdx()+1); return changed; } diff --git a/io/src/main/java/com/itextpdf/io/font/otf/GposLookupType7.java b/io/src/main/java/com/itextpdf/io/font/otf/GposLookupType7.java index 8bac1f1244..d8c00b34a9 100644 --- a/io/src/main/java/com/itextpdf/io/font/otf/GposLookupType7.java +++ b/io/src/main/java/com/itextpdf/io/font/otf/GposLookupType7.java @@ -53,9 +53,9 @@ public GposLookupType7(OpenTypeFontTableReader openReader, int lookupFlag, int[] @Override public boolean transformOne(GlyphLine line) { boolean changed = false; - int oldLineStart = line.start; - int oldLineEnd = line.end; - int initialLineIndex = line.idx; + int oldLineStart = line.getStart(); + int oldLineEnd = line.getEnd(); + int initialLineIndex = line.getIdx(); for (ContextualTable subTable : subTables) { ContextualPositionRule contextRule = subTable.getMatchingContextRule(line); @@ -63,31 +63,31 @@ public boolean transformOne(GlyphLine line) { continue; } - int lineEndBeforeTransformations = line.end; + int lineEndBeforeTransformations = line.getEnd(); PosLookupRecord[] posLookupRecords = contextRule.getPosLookupRecords(); GlyphIndexer gidx = new GlyphIndexer(); - gidx.line = line; + gidx.setLine(line); for (PosLookupRecord posRecord : posLookupRecords) { // There could be some skipped glyphs inside the context sequence, therefore currently GlyphIndexer and // nextGlyph method are used to get to the glyph at "substRecord.sequenceIndex" index - gidx.idx = initialLineIndex; + gidx.setIdx(initialLineIndex); for (int i = 0; i < posRecord.sequenceIndex; ++i) { gidx.nextGlyph(openReader, lookupFlag); } - line.idx = gidx.idx; + line.setIdx(gidx.getIdx()); OpenTableLookup lookupTable = openReader.getLookupTable(posRecord.lookupListIndex); changed = lookupTable.transformOne(line) || changed; } - line.idx = line.end; - line.start = oldLineStart; - int lenDelta = lineEndBeforeTransformations - line.end; - line.end = oldLineEnd - lenDelta; + line.setIdx(line.getEnd()); + line.setStart(oldLineStart); + int lenDelta = lineEndBeforeTransformations - line.getEnd(); + line.setEnd(oldLineEnd - lenDelta); return changed; } - line.idx++; + line.setIdx(line.getIdx()+1); return changed; } diff --git a/io/src/main/java/com/itextpdf/io/font/otf/GposValueRecord.java b/io/src/main/java/com/itextpdf/io/font/otf/GposValueRecord.java index 423376bb84..ec478b72b1 100644 --- a/io/src/main/java/com/itextpdf/io/font/otf/GposValueRecord.java +++ b/io/src/main/java/com/itextpdf/io/font/otf/GposValueRecord.java @@ -23,8 +23,80 @@ This file is part of the iText (R) project. package com.itextpdf.io.font.otf; public class GposValueRecord { - public int XPlacement; - public int YPlacement; - public int XAdvance; - public int YAdvance; + private int xPlacement; + private int yPlacement; + private int xAdvance; + private int yAdvance; + + /** + * Retrieves the X placement of the Gpos value record. + * + * @return X placement + */ + public int getXPlacement() { + return xPlacement; + } + + /** + * Sets the X placement of the Gpos value record. + * + * @param xPlacement X placement + */ + public void setXPlacement(int xPlacement) { + this.xPlacement = xPlacement; + } + + /** + * Retrieves the Y placement of the Gpos value record. + * + * @return Y placement + */ + public int getYPlacement() { + return yPlacement; + } + + /** + * Sets the Y placement of the Gpos value record. + * + * @param yPlacement Y placement + */ + public void setYPlacement(int yPlacement) { + this.yPlacement = yPlacement; + } + + /** + * Retrieves the X advance of the Gpos value record. + * + * @return x advance + */ + public int getXAdvance() { + return xAdvance; + } + + /** + * Sets the X advance of the Gpos value record. + * + * @param xAdvance X advance + */ + public void setXAdvance(int xAdvance) { + this.xAdvance = xAdvance; + } + + /** + * Retrieves the Y advance of the Gpos value record. + * + * @return Y advance + */ + public int getYAdvance() { + return yAdvance; + } + + /** + * Sets the Y advance of the Gpos value record. + * + * @param yAdvance Y advance + */ + public void setYAdvance(int yAdvance) { + this.yAdvance = yAdvance; + } } diff --git a/io/src/main/java/com/itextpdf/io/font/otf/GsubLookupType1.java b/io/src/main/java/com/itextpdf/io/font/otf/GsubLookupType1.java index 3e8dec7d39..ee6c29761b 100644 --- a/io/src/main/java/com/itextpdf/io/font/otf/GsubLookupType1.java +++ b/io/src/main/java/com/itextpdf/io/font/otf/GsubLookupType1.java @@ -38,10 +38,10 @@ public GsubLookupType1(OpenTypeFontTableReader openReader, int lookupFlag, int[] @Override public boolean transformOne(GlyphLine line) { - if (line.idx >= line.end) { + if (line.getIdx() >= line.getEnd()) { return false; } - Glyph g = line.get(line.idx); + Glyph g = line.get(line.getIdx()); boolean changed = false; if (!openReader.isSkip(g.getCode(), lookupFlag)) { int substCode = substMap.get(g.getCode()); @@ -52,7 +52,7 @@ public boolean transformOne(GlyphLine line) { changed = true; } } - line.idx++; + line.setIdx(line.getIdx()+1); return changed; } diff --git a/io/src/main/java/com/itextpdf/io/font/otf/GsubLookupType2.java b/io/src/main/java/com/itextpdf/io/font/otf/GsubLookupType2.java index 070e8b3e21..4982d59b36 100644 --- a/io/src/main/java/com/itextpdf/io/font/otf/GsubLookupType2.java +++ b/io/src/main/java/com/itextpdf/io/font/otf/GsubLookupType2.java @@ -41,10 +41,10 @@ public GsubLookupType2(OpenTypeFontTableReader openReader, int lookupFlag, int[] @Override public boolean transformOne(GlyphLine line) { - if (line.idx >= line.end) { + if (line.getIdx() >= line.getEnd()) { return false; } - Glyph g = line.get(line.idx); + Glyph g = line.get(line.getIdx()); boolean changed = false; if (!openReader.isSkip(g.getCode(), lookupFlag)) { int[] substSequence = substMap.get(g.getCode()); @@ -56,7 +56,7 @@ public boolean transformOne(GlyphLine line) { } } } - line.idx++; + line.setIdx(line.getIdx()+1); return changed; } diff --git a/io/src/main/java/com/itextpdf/io/font/otf/GsubLookupType3.java b/io/src/main/java/com/itextpdf/io/font/otf/GsubLookupType3.java index 26757a6cc7..604616813b 100644 --- a/io/src/main/java/com/itextpdf/io/font/otf/GsubLookupType3.java +++ b/io/src/main/java/com/itextpdf/io/font/otf/GsubLookupType3.java @@ -41,10 +41,10 @@ public GsubLookupType3(OpenTypeFontTableReader openReader, int lookupFlag, int[] @Override public boolean transformOne(GlyphLine line) { - if (line.idx >= line.end) { + if (line.getIdx() >= line.getEnd()) { return false; } - Glyph g = line.get(line.idx); + Glyph g = line.get(line.getIdx()); boolean changed = false; if (!openReader.isSkip(g.getCode(), lookupFlag)) { int[] substCode = substMap.get(g.getCode()); @@ -55,7 +55,7 @@ public boolean transformOne(GlyphLine line) { changed = true; } } - line.idx++; + line.setIdx(line.getIdx()+1); return changed; } diff --git a/io/src/main/java/com/itextpdf/io/font/otf/GsubLookupType4.java b/io/src/main/java/com/itextpdf/io/font/otf/GsubLookupType4.java index 0cbabdb524..366dca0488 100644 --- a/io/src/main/java/com/itextpdf/io/font/otf/GsubLookupType4.java +++ b/io/src/main/java/com/itextpdf/io/font/otf/GsubLookupType4.java @@ -45,21 +45,21 @@ public GsubLookupType4(OpenTypeFontTableReader openReader, int lookupFlag, int[] @Override public boolean transformOne(GlyphLine line) { - if (line.idx >= line.end) + if (line.getIdx() >= line.getEnd()) return false; boolean changed = false; - Glyph g = line.get(line.idx); + Glyph g = line.get(line.getIdx()); boolean match = false; if (ligatures.containsKey(g.getCode()) && !openReader.isSkip(g.getCode(), lookupFlag)) { GlyphIndexer gidx = new GlyphIndexer(); - gidx.line = line; + gidx.setLine(line); List ligs = ligatures.get(g.getCode()); for (int[] lig : ligs) { match = true; - gidx.idx = line.idx; + gidx.setIdx(line.getIdx()); for (int j = 1; j < lig.length; ++j) { gidx.nextGlyph(openReader, lookupFlag); - if (gidx.glyph == null || gidx.glyph.getCode() != lig[j]) { + if (gidx.getGlyph() == null || gidx.getGlyph().getCode() != lig[j]) { match = false; break; } @@ -73,7 +73,7 @@ public boolean transformOne(GlyphLine line) { if (match) { changed = true; } - line.idx++; + line.setIdx(line.getIdx()+1); return changed; } diff --git a/io/src/main/java/com/itextpdf/io/font/otf/GsubLookupType5.java b/io/src/main/java/com/itextpdf/io/font/otf/GsubLookupType5.java index df25c4348c..0b8d782e88 100644 --- a/io/src/main/java/com/itextpdf/io/font/otf/GsubLookupType5.java +++ b/io/src/main/java/com/itextpdf/io/font/otf/GsubLookupType5.java @@ -49,9 +49,9 @@ protected GsubLookupType5(OpenTypeFontTableReader openReader, int lookupFlag, in @Override public boolean transformOne(GlyphLine line) { boolean changed = false; - int oldLineStart = line.start; - int oldLineEnd = line.end; - int initialLineIndex = line.idx; + int oldLineStart = line.getStart(); + int oldLineEnd = line.getEnd(); + int initialLineIndex = line.getIdx(); for (ContextualTable subTable : subTables) { ContextualSubstRule contextRule = subTable.getMatchingContextRule(line); @@ -59,31 +59,31 @@ public boolean transformOne(GlyphLine line) { continue; } - int lineEndBeforeSubstitutions = line.end; + int lineEndBeforeSubstitutions = line.getEnd(); SubstLookupRecord[] substLookupRecords = contextRule.getSubstLookupRecords(); GlyphIndexer gidx = new GlyphIndexer(); - gidx.line = line; + gidx.setLine(line); for (SubstLookupRecord substRecord : substLookupRecords) { // There could be some skipped glyphs inside the context sequence, therefore currently GlyphIndexer and // nextGlyph method are used to get to the glyph at "substRecord.sequenceIndex" index - gidx.idx = initialLineIndex; + gidx.setIdx(initialLineIndex); for (int i = 0; i < substRecord.sequenceIndex; ++i) { gidx.nextGlyph(openReader, lookupFlag); } - line.idx = gidx.idx; + line.setIdx(gidx.getIdx()); OpenTableLookup lookupTable = openReader.getLookupTable(substRecord.lookupListIndex); changed = lookupTable.transformOne(line) || changed; } - line.idx = line.end; - line.start = oldLineStart; - int lenDelta = lineEndBeforeSubstitutions - line.end; - line.end = oldLineEnd - lenDelta; + line.setIdx(line.getEnd()); + line.setStart(oldLineStart); + int lenDelta = lineEndBeforeSubstitutions - line.getEnd(); + line.setEnd(oldLineEnd - lenDelta); return changed; } - ++line.idx; + line.setIdx(line.getIdx()+1); return changed; } diff --git a/io/src/main/java/com/itextpdf/io/font/otf/LanguageRecord.java b/io/src/main/java/com/itextpdf/io/font/otf/LanguageRecord.java index 0e9eea1fc8..791b7af113 100644 --- a/io/src/main/java/com/itextpdf/io/font/otf/LanguageRecord.java +++ b/io/src/main/java/com/itextpdf/io/font/otf/LanguageRecord.java @@ -23,7 +23,61 @@ This file is part of the iText (R) project. package com.itextpdf.io.font.otf; public class LanguageRecord { - public String tag; - public int featureRequired; - public int[] features; + private String tag; + private int featureRequired; + private int[] features; + + /** + * Retrieves the tag of the language record. + * + * @return tag of record + */ + public String getTag() { + return tag; + } + + /** + * Sets the tag of the language record. + * + * @param tag tag of record + */ + public void setTag(String tag) { + this.tag = tag; + } + + /** + * Retrieves the feature required of the language record. + * + * @return feature required + */ + public int getFeatureRequired() { + return featureRequired; + } + + /** + * Sets the feature required of the language record. + * + * @param featureRequired feature required + */ + public void setFeatureRequired(int featureRequired) { + this.featureRequired = featureRequired; + } + + /** + * Retrieves the features of the language record. + * + * @return features + */ + public int[] getFeatures() { + return features; + } + + /** + * Sets the features of the language record. + * + * @param features features + */ + public void setFeatures(int[] features) { + this.features = features; + } } diff --git a/io/src/main/java/com/itextpdf/io/font/otf/OpenTableLookup.java b/io/src/main/java/com/itextpdf/io/font/otf/OpenTableLookup.java index 565cf181e4..58158612d6 100644 --- a/io/src/main/java/com/itextpdf/io/font/otf/OpenTableLookup.java +++ b/io/src/main/java/com/itextpdf/io/font/otf/OpenTableLookup.java @@ -43,8 +43,8 @@ public int getLookupFlag() { public boolean transformLine(GlyphLine line) { boolean changed = false; - line.idx = line.start; - while (line.idx < line.end && line.idx >= line.start) { + line.setIdx(line.getStart()); + while (line.getIdx() < line.getEnd() && line.getIdx() >= line.getStart()) { changed = transformOne(line) || changed; } return changed; @@ -63,13 +63,67 @@ protected void readSubTables() throws java.io.IOException { protected abstract void readSubTable(int subTableLocation) throws java.io.IOException; public static class GlyphIndexer { - public GlyphLine line; - public Glyph glyph; - public int idx; + private GlyphLine line; + private Glyph glyph; + private int idx; + + /** + * Retrieves the glyph line of the object. + * + * @return glyph line + */ + public GlyphLine getLine() { + return line; + } + + /** + * Sets the glyph line of the object. + * + * @param line glyph line + */ + public void setLine(GlyphLine line) { + this.line = line; + } + + /** + * Retrieves the glyph of the object. + * + * @return glyph + */ + public Glyph getGlyph() { + return glyph; + } + + /** + * Sets the glyph of the object. + * + * @param glyph glyph + */ + public void setGlyph(Glyph glyph) { + this.glyph = glyph; + } + + /** + * Retrieves the idx of the glyph indexer. + * + * @return idx + */ + public int getIdx() { + return idx; + } + + /** + * Sets the idx of the glyph indexer. + * + * @param idx idx + */ + public void setIdx(int idx) { + this.idx = idx; + } public void nextGlyph(OpenTypeFontTableReader openReader, int lookupFlag) { glyph = null; - while (++idx < line.end) { + while (++idx < line.getEnd()) { Glyph g = line.get(idx); if (!openReader.isSkip(g.getCode(), lookupFlag)) { glyph = g; @@ -80,7 +134,7 @@ public void nextGlyph(OpenTypeFontTableReader openReader, int lookupFlag) { public void previousGlyph(OpenTypeFontTableReader openReader, int lookupFlag) { glyph = null; - while (--idx >= line.start) { + while (--idx >= line.getStart()) { Glyph g = line.get(idx); if (!openReader.isSkip(g.getCode(), lookupFlag)) { glyph = g; diff --git a/io/src/main/java/com/itextpdf/io/font/otf/OpenTypeFeature.java b/io/src/main/java/com/itextpdf/io/font/otf/OpenTypeFeature.java index 6e408de071..cd37926059 100644 --- a/io/src/main/java/com/itextpdf/io/font/otf/OpenTypeFeature.java +++ b/io/src/main/java/com/itextpdf/io/font/otf/OpenTypeFeature.java @@ -36,11 +36,11 @@ public OpenTypeFeature(OpenTypeFontTableReader openTypeReader, int locationFeatu TagAndLocation[] tagsLocs = openTypeReader.readTagAndLocations(locationFeatureTable); for (TagAndLocation tagLoc : tagsLocs) { // +2 don't use FeatureParams - openTypeReader.rf.seek(tagLoc.location + 2L); + openTypeReader.rf.seek(tagLoc.getLocation() + 2L); int lookupCount = openTypeReader.rf.readUnsignedShort(); FeatureRecord rec = new FeatureRecord(); - rec.tag = tagLoc.tag; - rec.lookups = openTypeReader.readUShortArray(lookupCount); + rec.setTag(tagLoc.getTag()); + rec.setLookups(openTypeReader.readUShortArray(lookupCount)); records.add(rec); } } diff --git a/io/src/main/java/com/itextpdf/io/font/otf/OpenTypeFontTableReader.java b/io/src/main/java/com/itextpdf/io/font/otf/OpenTypeFontTableReader.java index 144a7d2c94..bc3b7d31fc 100644 --- a/io/src/main/java/com/itextpdf/io/font/otf/OpenTypeFontTableReader.java +++ b/io/src/main/java/com/itextpdf/io/font/otf/OpenTypeFontTableReader.java @@ -78,7 +78,7 @@ public List getFeatures(String[] scripts, String language) { return null; } List ret = new ArrayList(); - for (int f : rec.features) { + for (int f : rec.getFeatures()) { ret.add(featuresType.getRecord(f)); } return ret; @@ -95,7 +95,7 @@ public List getSpecificFeatures(List features, Str } List recs = new ArrayList(); for (FeatureRecord rec : features) { - if (hs.contains(rec.tag)) { + if (hs.contains(rec.getTag())) { recs.add(rec); } } @@ -106,13 +106,13 @@ public FeatureRecord getRequiredFeature(String[] scripts, String language) { LanguageRecord rec = scriptsType.getLanguageRecord(scripts, language); if (rec == null) return null; - return featuresType.getRecord(rec.featureRequired); + return featuresType.getRecord(rec.getFeatureRequired()); } public List getLookups(FeatureRecord[] features) { IntHashtable hash = new IntHashtable(); for (FeatureRecord rec : features) { - for (int idx : rec.lookups) { + for (int idx : rec.getLookups()) { hash.put(idx, 1); } } @@ -124,8 +124,8 @@ public List getLookups(FeatureRecord[] features) { } public List getLookups(FeatureRecord feature) { - List ret = new ArrayList<>(feature.lookups.length); - for (int idx : feature.lookups) { + List ret = new ArrayList<>(feature.getLookups().length); + for (int idx : feature.getLookups()) { ret.add(lookupList.get(idx)); } return ret; @@ -152,14 +152,14 @@ public LanguageRecord getLanguageRecord(String otfScriptTag, String langTag) { return null; } for (final ScriptRecord record : getScriptRecords()) { - if (!otfScriptTag.equals(record.tag)) { + if (!otfScriptTag.equals(record.getTag())) { continue; } if (langTag == null) { - return record.defaultLanguage; + return record.getDefaultLanguage(); } - for (final LanguageRecord lang : record.languages) { - if (langTag.equals(lang.tag)) { + for (final LanguageRecord lang : record.getLanguages()) { + if (langTag.equals(lang.getTag())) { return lang; } } @@ -204,8 +204,8 @@ protected TagAndLocation[] readTagAndLocations(int baseLocation) throws java.io. TagAndLocation[] tagslLocs = new TagAndLocation[count]; for (int k = 0; k < count; ++k) { TagAndLocation tl = new TagAndLocation(); - tl.tag = rf.readString(4, "utf-8"); - tl.location = rf.readUnsignedShort() + baseLocation; + tl.setTag(rf.readString(4, "utf-8")); + tl.setLocation(rf.readUnsignedShort() + baseLocation); tagslLocs[k] = tl; } return tagslLocs; diff --git a/io/src/main/java/com/itextpdf/io/font/otf/OpenTypeScript.java b/io/src/main/java/com/itextpdf/io/font/otf/OpenTypeScript.java index 48de819adc..3066a741d0 100644 --- a/io/src/main/java/com/itextpdf/io/font/otf/OpenTypeScript.java +++ b/io/src/main/java/com/itextpdf/io/font/otf/OpenTypeScript.java @@ -50,14 +50,14 @@ public LanguageRecord getLanguageRecord(String[] scripts, String language) { ScriptRecord scriptFound = null; ScriptRecord scriptDefault = null; for (ScriptRecord sr : records) { - if (DEFAULT_SCRIPT.equals(sr.tag)) { + if (DEFAULT_SCRIPT.equals(sr.getTag())) { scriptDefault = sr; break; } } for (String script : scripts) { for (ScriptRecord sr : records) { - if (sr.tag.equals(script)) { + if (sr.getTag().equals(script)) { scriptFound = sr; break; } @@ -76,36 +76,38 @@ public LanguageRecord getLanguageRecord(String[] scripts, String language) { return null; } LanguageRecord lang = null; - for (LanguageRecord lr : scriptFound.languages) { - if (lr.tag.equals(language)) { + for (LanguageRecord lr : scriptFound.getLanguages()) { + if (lr.getTag().equals(language)) { lang = lr; break; } } if (lang == null) { - lang = scriptFound.defaultLanguage; + lang = scriptFound.getDefaultLanguage(); } return lang; } private void readScriptRecord(TagAndLocation tagLoc) throws java.io.IOException { - openTypeReader.rf.seek(tagLoc.location); + openTypeReader.rf.seek(tagLoc.getLocation()); int locationDefaultLanguage = openTypeReader.rf.readUnsignedShort(); if (locationDefaultLanguage > 0) { - locationDefaultLanguage += tagLoc.location; + locationDefaultLanguage += tagLoc.getLocation(); } - TagAndLocation[] tagsLocs = openTypeReader.readTagAndLocations(tagLoc.location); + TagAndLocation[] tagsLocs = openTypeReader.readTagAndLocations(tagLoc.getLocation()); ScriptRecord srec = new ScriptRecord(); - srec.tag = tagLoc.tag; - srec.languages = new LanguageRecord[tagsLocs.length]; + srec.setTag(tagLoc.getTag()); + srec.setLanguages(new LanguageRecord[tagsLocs.length]); for (int k = 0; k < tagsLocs.length; ++k) { - srec.languages[k] = readLanguageRecord(tagsLocs[k]); + LanguageRecord[] languages = srec.getLanguages(); + languages[k] = readLanguageRecord(tagsLocs[k]); + srec.setLanguages(languages); } if (locationDefaultLanguage > 0) { TagAndLocation t = new TagAndLocation(); - t.tag = ""; - t.location = locationDefaultLanguage; - srec.defaultLanguage = readLanguageRecord(t); + t.setTag(""); + t.setLocation(locationDefaultLanguage); + srec.setDefaultLanguage(readLanguageRecord(t)); } records.add(srec); } @@ -113,11 +115,11 @@ private void readScriptRecord(TagAndLocation tagLoc) throws java.io.IOException private LanguageRecord readLanguageRecord(TagAndLocation tagLoc) throws java.io.IOException { LanguageRecord rec = new LanguageRecord(); //skip lookup order - openTypeReader.rf.seek(tagLoc.location + 2); - rec.featureRequired = openTypeReader.rf.readUnsignedShort(); + openTypeReader.rf.seek(tagLoc.getLocation() + 2L); + rec.setFeatureRequired(openTypeReader.rf.readUnsignedShort()); int count = openTypeReader.rf.readUnsignedShort(); - rec.features = openTypeReader.readUShortArray(count); - rec.tag = tagLoc.tag; + rec.setFeatures(openTypeReader.readUShortArray(count)); + rec.setTag(tagLoc.getTag()); return rec; } } diff --git a/io/src/main/java/com/itextpdf/io/font/otf/OtfMarkRecord.java b/io/src/main/java/com/itextpdf/io/font/otf/OtfMarkRecord.java index 19fc8a5f69..80f38efcf3 100644 --- a/io/src/main/java/com/itextpdf/io/font/otf/OtfMarkRecord.java +++ b/io/src/main/java/com/itextpdf/io/font/otf/OtfMarkRecord.java @@ -23,6 +23,42 @@ This file is part of the iText (R) project. package com.itextpdf.io.font.otf; public class OtfMarkRecord { - public int markClass; - public GposAnchor anchor; + private int markClass; + private GposAnchor anchor; + + /** + * Retrieves the mark class of the OtfMarkRecord. + * + * @return mark class + */ + public int getMarkClass() { + return markClass; + } + + /** + * Sets the mark class of the OtfMarkRecord. + * + * @param markClass mark class + */ + public void setMarkClass(int markClass) { + this.markClass = markClass; + } + + /** + * Retrieves the anchor of the OtfMarkRecord. + * + * @return anchor + */ + public GposAnchor getAnchor() { + return anchor; + } + + /** + * Sets the anchor of the OtfMarkRecord. + * + * @param anchor anchor + */ + public void setAnchor(GposAnchor anchor) { + this.anchor = anchor; + } } diff --git a/io/src/main/java/com/itextpdf/io/font/otf/OtfReadCommon.java b/io/src/main/java/com/itextpdf/io/font/otf/OtfReadCommon.java index 221fc215c8..7153cbd317 100644 --- a/io/src/main/java/com/itextpdf/io/font/otf/OtfReadCommon.java +++ b/io/src/main/java/com/itextpdf/io/font/otf/OtfReadCommon.java @@ -94,20 +94,20 @@ public static GposValueRecord readGposValueRecord(OpenTypeFontTableReader tableR throws java.io.IOException { GposValueRecord vr = new GposValueRecord(); if ((mask & 0x0001) != 0) { - vr.XPlacement = - FontProgram.convertGlyphSpaceToTextSpace(tableReader.rf.readShort()) / tableReader.getUnitsPerEm(); + vr.setXPlacement( + FontProgram.convertGlyphSpaceToTextSpace(tableReader.rf.readShort()) / tableReader.getUnitsPerEm()); } if ((mask & 0x0002) != 0) { - vr.YPlacement = - FontProgram.convertGlyphSpaceToTextSpace(tableReader.rf.readShort()) / tableReader.getUnitsPerEm(); + vr.setYPlacement( + FontProgram.convertGlyphSpaceToTextSpace(tableReader.rf.readShort()) / tableReader.getUnitsPerEm()); } if ((mask & 0x0004) != 0) { - vr.XAdvance = - FontProgram.convertGlyphSpaceToTextSpace(tableReader.rf.readShort()) / tableReader.getUnitsPerEm(); + vr.setXAdvance( + FontProgram.convertGlyphSpaceToTextSpace(tableReader.rf.readShort()) / tableReader.getUnitsPerEm()); } if ((mask & 0x0008) != 0) { - vr.YAdvance = - FontProgram.convertGlyphSpaceToTextSpace(tableReader.rf.readShort()) / tableReader.getUnitsPerEm(); + vr.setYAdvance( + FontProgram.convertGlyphSpaceToTextSpace(tableReader.rf.readShort()) / tableReader.getUnitsPerEm()); } if ((mask & 0x0010) != 0) { tableReader.rf.skip(2); @@ -136,10 +136,10 @@ public static GposAnchor readGposAnchor(OpenTypeFontTableReader tableReader, int switch (format) { default: t = new GposAnchor(); - t.XCoordinate = FontProgram.convertGlyphSpaceToTextSpace(tableReader.rf.readShort()) - / tableReader.getUnitsPerEm(); - t.YCoordinate = FontProgram.convertGlyphSpaceToTextSpace(tableReader.rf.readShort()) - / tableReader.getUnitsPerEm(); + t.setXCoordinate(FontProgram.convertGlyphSpaceToTextSpace(tableReader.rf.readShort()) + / tableReader.getUnitsPerEm()); + t.setYCoordinate(FontProgram.convertGlyphSpaceToTextSpace(tableReader.rf.readShort()) + / tableReader.getUnitsPerEm()); break; } @@ -160,8 +160,8 @@ public static List readMarkArray(OpenTypeFontTableReader tableRea List marks = new ArrayList(); for (int k = 0; k < markCount; ++k) { OtfMarkRecord rec = new OtfMarkRecord(); - rec.markClass = classes[k]; - rec.anchor = readGposAnchor(tableReader, locations[k]); + rec.setMarkClass(classes[k]); + rec.setAnchor(readGposAnchor(tableReader, locations[k])); marks.add(rec); } return marks; diff --git a/io/src/main/java/com/itextpdf/io/font/otf/ScriptRecord.java b/io/src/main/java/com/itextpdf/io/font/otf/ScriptRecord.java index 97744d0d04..0bea968fed 100644 --- a/io/src/main/java/com/itextpdf/io/font/otf/ScriptRecord.java +++ b/io/src/main/java/com/itextpdf/io/font/otf/ScriptRecord.java @@ -23,7 +23,61 @@ This file is part of the iText (R) project. package com.itextpdf.io.font.otf; public class ScriptRecord { - public String tag; - public LanguageRecord defaultLanguage; - public LanguageRecord[] languages; + private String tag; + private LanguageRecord defaultLanguage; + private LanguageRecord[] languages; + + /** + * Retrieves the tag of the Script Record. + * + * @return tag of record + */ + public String getTag() { + return tag; + } + + /** + * Sets the tag of the Script Record. + * + * @param tag tag of record + */ + public void setTag(String tag) { + this.tag = tag; + } + + /** + * Retrieves the default language of the Script Record. + * + * @return default language + */ + public LanguageRecord getDefaultLanguage() { + return defaultLanguage; + } + + /** + * Sets the default language of the Script Record. + * + * @param defaultLanguage default language + */ + public void setDefaultLanguage(LanguageRecord defaultLanguage) { + this.defaultLanguage = defaultLanguage; + } + + /** + * Retrieves the languages of the Script Record. + * + * @return languages + */ + public LanguageRecord[] getLanguages() { + return languages; + } + + /** + * Sets the languages of the Script Record. + * + * @param languages languages + */ + public void setLanguages(LanguageRecord[] languages) { + this.languages = languages; + } } diff --git a/io/src/main/java/com/itextpdf/io/font/otf/TagAndLocation.java b/io/src/main/java/com/itextpdf/io/font/otf/TagAndLocation.java index bef8f06858..757ae3c700 100644 --- a/io/src/main/java/com/itextpdf/io/font/otf/TagAndLocation.java +++ b/io/src/main/java/com/itextpdf/io/font/otf/TagAndLocation.java @@ -23,6 +23,42 @@ This file is part of the iText (R) project. package com.itextpdf.io.font.otf; public class TagAndLocation { - public String tag; - public int location; + private String tag; + private int location; + + /** + * Retrieves the tag of the object. + * + * @return tag + */ + public String getTag() { + return tag; + } + + /** + * Sets the tag of the object. + * + * @param tag tag + */ + public void setTag(String tag) { + this.tag = tag; + } + + /** + * Retrieves the location of the object. + * + * @return location + */ + public int getLocation() { + return location; + } + + /** + * Sets the location of the object. + * + * @param location location + */ + public void setLocation(int location) { + this.location = location; + } } diff --git a/io/src/main/java/com/itextpdf/io/image/Jbig2ImageHelper.java b/io/src/main/java/com/itextpdf/io/image/Jbig2ImageHelper.java index 38e2e8313b..1626b24f29 100644 --- a/io/src/main/java/com/itextpdf/io/image/Jbig2ImageHelper.java +++ b/io/src/main/java/com/itextpdf/io/image/Jbig2ImageHelper.java @@ -68,8 +68,8 @@ public static void processImage(ImageData jbig2) { Jbig2SegmentReader.Jbig2Page p = sr.getPage(image.getPage()); raf.close(); - image.setHeight(p.pageBitmapHeight); - image.setWidth(p.pageBitmapWidth); + image.setHeight(p.getPageBitmapHeight()); + image.setWidth(p.getPageBitmapWidth()); image.setBpc(1); image.setColorEncodingComponentsNumber(1); diff --git a/io/src/main/java/com/itextpdf/io/image/Jpeg2000ImageData.java b/io/src/main/java/com/itextpdf/io/image/Jpeg2000ImageData.java index 291bb41382..fc4463aed8 100644 --- a/io/src/main/java/com/itextpdf/io/image/Jpeg2000ImageData.java +++ b/io/src/main/java/com/itextpdf/io/image/Jpeg2000ImageData.java @@ -33,11 +33,101 @@ This file is part of the iText (R) project. public class Jpeg2000ImageData extends ImageData { public static class Parameters { - public int numOfComps; - public List colorSpecBoxes = null; - public boolean isJp2 = false; - public boolean isJpxBaseline = false; - public byte[] bpcBoxData; + private int numOfComps; + private List colorSpecBoxes = null; + private boolean isJp2 = false; + private boolean isJpxBaseline = false; + private byte[] bpcBoxData; + + /** + * Retrieves number of components of the object. + * + * @return number of components + */ + public int getNumOfComps() { + return numOfComps; + } + + /** + * Sets number of components of the object. + * + * @param numOfComps number of components + */ + public void setNumOfComps(int numOfComps) { + this.numOfComps = numOfComps; + } + + /** + * Retrieves the color spec boxes of the object. + * + * @return color spec boxes + */ + public List getColorSpecBoxes() { + return colorSpecBoxes; + } + + /** + * Sets the color spec boxes of the object. + * + * @param colorSpecBoxes color spec boxes + */ + public void setColorSpecBoxes(List colorSpecBoxes) { + this.colorSpecBoxes = colorSpecBoxes; + } + + /** + * Retrieves whether the object is a Jp2. + * + * @return true if it is a jp2, otherwise false + */ + public boolean isJp2() { + return isJp2; + } + + /** + * Sets whether the object is a jp2. + * + * @param jp2 true is it is a jp2, otherwise false + */ + public void setJp2(boolean jp2) { + isJp2 = jp2; + } + + /** + * Retrieves whether jpx is baseline. + * + * @return true if jpx is baseline, false otherwise + */ + public boolean isJpxBaseline() { + return isJpxBaseline; + } + + /** + * Sets whether jpx is baseline. + * + * @param jpxBaseline true if jpx is baseline, false otherwise + */ + public void setJpxBaseline(boolean jpxBaseline) { + isJpxBaseline = jpxBaseline; + } + + /** + * Retrieves the bits per component of the box data. + * + * @return bits per component + */ + public byte[] getBpcBoxData() { + return bpcBoxData; + } + + /** + * Sets the bits per component of the box data. + * + * @param bpcBoxData bits per component + */ + public void setBpcBoxData(byte[] bpcBoxData) { + this.bpcBoxData = bpcBoxData; + } } public static class ColorSpecBox extends ArrayList { diff --git a/io/src/main/java/com/itextpdf/io/image/Jpeg2000ImageHelper.java b/io/src/main/java/com/itextpdf/io/image/Jpeg2000ImageHelper.java index de9b16c2d4..116eda4bae 100644 --- a/io/src/main/java/com/itextpdf/io/image/Jpeg2000ImageHelper.java +++ b/io/src/main/java/com/itextpdf/io/image/Jpeg2000ImageHelper.java @@ -24,11 +24,13 @@ This file is part of the iText (R) project. import com.itextpdf.io.exceptions.IOException; import com.itextpdf.io.exceptions.IoExceptionMessageConstant; +import com.itextpdf.io.image.Jpeg2000ImageData.ColorSpecBox; import com.itextpdf.io.util.StreamUtil; import java.io.ByteArrayInputStream; import java.io.InputStream; import java.util.ArrayList; +import java.util.List; final class Jpeg2000ImageHelper { @@ -78,7 +80,7 @@ private static void processParameters(Jpeg2000ImageData jp2) { Jpeg2000Box box = new Jpeg2000Box(); box.length = cio_read(4, jpeg2000Stream); if (box.length == 0x0000000c) { - jp2.parameters.isJp2 = true; + jp2.parameters.setJp2(true); box.type = cio_read(4, jpeg2000Stream); if (JP2_JP != box.type) { throw new IOException(IoExceptionMessageConstant.EXPECTED_JP_MARKER); @@ -94,7 +96,7 @@ private static void processParameters(Jpeg2000ImageData jp2) { StreamUtil.skip(jpeg2000Stream, 8); for (int i = 4; i < box.length / 4; ++i) { if (cio_read(4, jpeg2000Stream) == JPX_JPXB) { - jp2.parameters.isJpxBaseline = true; + jp2.parameters.setJpxBaseline(true); } } @@ -114,18 +116,20 @@ private static void processParameters(Jpeg2000ImageData jp2) { } jp2.setHeight(cio_read(4, jpeg2000Stream)); jp2.setWidth(cio_read(4, jpeg2000Stream)); - jp2.parameters.numOfComps = cio_read(2, jpeg2000Stream); + jp2.parameters.setNumOfComps(cio_read(2, jpeg2000Stream)); jp2.setBpc(cio_read(1, jpeg2000Stream)); StreamUtil.skip(jpeg2000Stream, 3); jp2_read_boxhdr(box, jpeg2000Stream); if (box.type == JP2_BPCC) { - jp2.parameters.bpcBoxData = new byte[box.length - 8]; - jpeg2000Stream.read(jp2.parameters.bpcBoxData, 0, box.length - 8); + jp2.parameters.setBpcBoxData(new byte[box.length - 8]); + jpeg2000Stream.read(jp2.parameters.getBpcBoxData(), 0, box.length - 8); } else if (box.type == JP2_COLR) { do { - if (jp2.parameters.colorSpecBoxes == null) - jp2.parameters.colorSpecBoxes = new ArrayList(); - jp2.parameters.colorSpecBoxes.add(jp2_read_colr(box, jpeg2000Stream)); + if (jp2.parameters.getColorSpecBoxes() == null) + jp2.parameters.setColorSpecBoxes(new ArrayList<>()); + List colorSpecBoxes = jp2.parameters.getColorSpecBoxes(); + colorSpecBoxes.add(jp2_read_colr(box, jpeg2000Stream)); + jp2.parameters.setColorSpecBoxes(colorSpecBoxes); try { jp2_read_boxhdr(box, jpeg2000Stream); } catch (ZeroBoxSizeException ioe) { diff --git a/io/src/main/java/com/itextpdf/io/image/RawImageHelper.java b/io/src/main/java/com/itextpdf/io/image/RawImageHelper.java index 7010aecfa3..27ece4a879 100644 --- a/io/src/main/java/com/itextpdf/io/image/RawImageHelper.java +++ b/io/src/main/java/com/itextpdf/io/image/RawImageHelper.java @@ -48,13 +48,13 @@ public static void updateImageAttributes(RawImageData image, Map if (k != 0) decodeparms.put("K", k); if ((colorSpace & RawImageData.CCITT_BLACKIS1) != 0) - decodeparms.put("BlackIs1", true); + decodeparms.put("BlackIs1", Boolean.TRUE); if ((colorSpace & RawImageData.CCITT_ENCODEDBYTEALIGN) != 0) - decodeparms.put("EncodedByteAlign", true); + decodeparms.put("EncodedByteAlign", Boolean.TRUE); if ((colorSpace & RawImageData.CCITT_ENDOFLINE) != 0) - decodeparms.put("EndOfLine", true); + decodeparms.put("EndOfLine", Boolean.TRUE); if ((colorSpace & RawImageData.CCITT_ENDOFBLOCK) != 0) - decodeparms.put("EndOfBlock", false); + decodeparms.put("EndOfBlock", Boolean.FALSE); decodeparms.put("Columns", image.getWidth()); decodeparms.put("Rows", image.getHeight()); image.decodeParms = decodeparms; diff --git a/io/src/main/java/com/itextpdf/io/logs/IoLogMessageConstant.java b/io/src/main/java/com/itextpdf/io/logs/IoLogMessageConstant.java index e440ca92e9..baf01727d0 100644 --- a/io/src/main/java/com/itextpdf/io/logs/IoLogMessageConstant.java +++ b/io/src/main/java/com/itextpdf/io/logs/IoLogMessageConstant.java @@ -476,13 +476,11 @@ public final class IoLogMessageConstant { public static final String XFDF_UNSUPPORTED_ANNOTATION_ATTRIBUTE = "Xfdf unsupported attribute type"; - @Deprecated - // replaced by com.itextpdf.kernel.logs.KernelLogMessageConstant#XOBJECT_STRUCT_PARENT_INDEX_MISSED_AND_RECREATED - public static final String XOBJECT_HAS_NO_STRUCT_PARENTS = "XObject has no StructParents entry in its stream, no " - + "entry in ParentTree will be created for the corresponding structure elements"; + public static final String XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT = "Error occurred while " + + "reading cross reference table. Cross reference table will be rebuilt. No additional information available"; - public static final String XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT = - "Error occurred while reading cross reference table. Cross reference table will be rebuilt."; + public static final String XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT_WITH_CAUSE = "Error occurred while " + + "reading cross reference table. Cross reference table will be rebuilt. Reason: {0}"; private IoLogMessageConstant() { //Private constructor will prevent the instantiation of this class directly diff --git a/io/src/main/java/com/itextpdf/io/source/ByteArrayOutputStream.java b/io/src/main/java/com/itextpdf/io/source/ByteArrayOutputStream.java index 6e1da02a76..cd4a6959a7 100644 --- a/io/src/main/java/com/itextpdf/io/source/ByteArrayOutputStream.java +++ b/io/src/main/java/com/itextpdf/io/source/ByteArrayOutputStream.java @@ -22,7 +22,7 @@ This file is part of the iText (R) project. */ package com.itextpdf.io.source; -public class ByteArrayOutputStream extends java.io.ByteArrayOutputStream{ +public class ByteArrayOutputStream extends java.io.ByteArrayOutputStream { public ByteArrayOutputStream() { super(); diff --git a/io/src/main/java/com/itextpdf/io/source/OutputStream.java b/io/src/main/java/com/itextpdf/io/source/HighPrecisionOutputStream.java similarity index 89% rename from io/src/main/java/com/itextpdf/io/source/OutputStream.java rename to io/src/main/java/com/itextpdf/io/source/HighPrecisionOutputStream.java index 46ff0d301e..126d2f6139 100644 --- a/io/src/main/java/com/itextpdf/io/source/OutputStream.java +++ b/io/src/main/java/com/itextpdf/io/source/HighPrecisionOutputStream.java @@ -25,11 +25,15 @@ This file is part of the iText (R) project. import com.itextpdf.io.exceptions.IOException; import com.itextpdf.io.exceptions.IoExceptionMessageConstant; +/** + * Output stream based on {@link java.io.OutputStream} for which it is possible to set high precision in order to write + * all floats and doubles with high precision. + * + * @param {@link java.io.OutputStream} + */ +public class HighPrecisionOutputStream extends java.io.OutputStream { -public class OutputStream extends java.io.OutputStream { - - - //long=19 + max frac=6 => 26 => round to 32. + // long=19 + max frac=6 => 26 => round to 32. private final ByteBuffer numBuffer = new ByteBuffer(32); private Boolean localHighPrecision; protected java.io.OutputStream outputStream = null; @@ -46,10 +50,10 @@ public static boolean getHighPrecision() { } /** - * Sets global high precision setting for all {@link OutputStream} instances. + * Sets global high precision setting for all {@link HighPrecisionOutputStream} instances. * * @param value if true, all floats and double will be written with high precision - * in all {@link OutputStream} instances. + * in all {@link HighPrecisionOutputStream} instances. */ public static void setHighPrecision(boolean value) { ByteUtils.HighPrecision = value; @@ -65,36 +69,29 @@ public boolean getLocalHighPrecision() { } /** - * Sets local high precision setting for the {@link OutputStream}. + * Sets local high precision setting for the {@link HighPrecisionOutputStream}. * Global {@link ByteUtils#HighPrecision} setting will be overridden by this one. * * @param value if true, all floats and double will be written with high precision - * in the underlying {@link OutputStream}. + * in the underlying {@link HighPrecisionOutputStream}. */ public void setLocalHighPrecision(boolean value) { this.localHighPrecision = value; } /** - * Creates a new {@link OutputStream} instance + * Creates a new {@link HighPrecisionOutputStream} instance * based on {@link java.io.OutputStream} instance. * - * @param outputStream the {@link OutputStream} instance. + * @param outputStream the {@link HighPrecisionOutputStream} instance. */ - public OutputStream(java.io.OutputStream outputStream) { + public HighPrecisionOutputStream(java.io.OutputStream outputStream) { super(); this.outputStream = outputStream; } /** - * Do not use this constructor. This is only for internal usage. - */ - protected OutputStream() { - super(); - } - - /** - * Creates a new {@link OutputStream} instance + * Creates a new {@link HighPrecisionOutputStream} instance * based on {@link java.io.OutputStream} instance and precision setting value. * * @param outputStream the {@link java.io.OutputStream} instance. @@ -103,7 +100,7 @@ protected OutputStream() { * Global {@link ByteUtils#HighPrecision} setting * will be overridden by this one. */ - public OutputStream(java.io.OutputStream outputStream, boolean localHighPrecision) { + public HighPrecisionOutputStream(java.io.OutputStream outputStream, boolean localHighPrecision) { super(); this.outputStream = outputStream; this.localHighPrecision = localHighPrecision; @@ -303,7 +300,7 @@ public T writeString(String value) { } /** - * See {@link OutputStream#write(byte[])}. + * See {@link HighPrecisionOutputStream#write(byte[])}. * * @param b byte array to write. * @@ -321,7 +318,7 @@ public T writeBytes(byte[] b) { } /** - * See {@link OutputStream#write(byte[], int, int)}. + * See {@link HighPrecisionOutputStream#write(byte[], int, int)}. * * @param b the data to write. * @param off the start offset in the data. @@ -369,7 +366,7 @@ public boolean isCloseStream() { } /** - * Sets internal {@link java.io.OutputStream} to be closed after {@link OutputStream#close()}. + * Sets internal {@link java.io.OutputStream} to be closed after {@link HighPrecisionOutputStream#close()}. * * @param closeStream true if stream needs to be closed, false if it's done manually. */ @@ -395,8 +392,8 @@ public void assignBytes(byte[] bytes, int count) { /** * See {@link ByteArrayOutputStream#reset()}. * - * @throws com.itextpdf.io.exceptions.IOException if internal {@link OutputStream}. - * is not a {@link ByteArrayOutputStream} instance. + * @throws com.itextpdf.io.exceptions.IOException if internal {@link HighPrecisionOutputStream} is not + * a {@link ByteArrayOutputStream} instance. */ public void reset() { if (outputStream instanceof ByteArrayOutputStream) { diff --git a/io/src/main/java/com/itextpdf/io/source/PdfTokenizer.java b/io/src/main/java/com/itextpdf/io/source/PdfTokenizer.java index ff02b6dbee..e417964983 100644 --- a/io/src/main/java/com/itextpdf/io/source/PdfTokenizer.java +++ b/io/src/main/java/com/itextpdf/io/source/PdfTokenizer.java @@ -28,6 +28,7 @@ This file is part of the iText (R) project. import com.itextpdf.io.logs.IoLogMessageConstant; import java.io.Closeable; +import java.nio.charset.StandardCharsets; import java.util.Arrays; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -51,7 +52,32 @@ public enum TokenType { EndOfFile } - public static final boolean[] delims = { + public static final byte[] Obj = ByteUtils.getIsoBytes("obj"); + public static final byte[] R = ByteUtils.getIsoBytes("R"); + public static final byte[] Xref = ByteUtils.getIsoBytes("xref"); + public static final byte[] Startxref = ByteUtils.getIsoBytes("startxref"); + public static final byte[] Stream = ByteUtils.getIsoBytes("stream"); + public static final byte[] Trailer = ByteUtils.getIsoBytes("trailer"); + public static final byte[] N = ByteUtils.getIsoBytes("n"); + public static final byte[] F = ByteUtils.getIsoBytes("f"); + public static final byte[] Null = ByteUtils.getIsoBytes("null"); + public static final byte[] True = ByteUtils.getIsoBytes("true"); + public static final byte[] False = ByteUtils.getIsoBytes("false"); + + protected TokenType type; + protected int reference; + protected int generation; + protected boolean hexString; + protected ByteBuffer outBuf; + + private final RandomAccessFileOrArray file; + /** + * Streams are closed automatically. + */ + private boolean closeStream = true; + + + private static final boolean[] delims = { true, true, false, false, false, false, false, false, false, false, true, true, false, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, @@ -79,31 +105,6 @@ public enum TokenType { false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - - public static final byte[] Obj = ByteUtils.getIsoBytes("obj"); - public static final byte[] R = ByteUtils.getIsoBytes("R"); - public static final byte[] Xref = ByteUtils.getIsoBytes("xref"); - public static final byte[] Startxref = ByteUtils.getIsoBytes("startxref"); - public static final byte[] Stream = ByteUtils.getIsoBytes("stream"); - public static final byte[] Trailer = ByteUtils.getIsoBytes("trailer"); - public static final byte[] N = ByteUtils.getIsoBytes("n"); - public static final byte[] F = ByteUtils.getIsoBytes("f"); - public static final byte[] Null = ByteUtils.getIsoBytes("null"); - public static final byte[] True = ByteUtils.getIsoBytes("true"); - public static final byte[] False = ByteUtils.getIsoBytes("false"); - - protected TokenType type; - protected int reference; - protected int generation; - protected boolean hexString; - protected ByteBuffer outBuf; - - private final RandomAccessFileOrArray file; - /** - * Streams are closed automatically. - */ - private boolean closeStream = true; - /** * Creates a PdfTokenizer for the specified {@link RandomAccessFileOrArray}. * The beginning of the file is read to determine the location of the header, and the data source is adjusted @@ -141,6 +142,27 @@ public int read() throws java.io.IOException { return file.read(); } + /** + * Gets the next byte of pdf source without moving source position. + * + * @return the byte, or -1 if EOF is reached + * @throws java.io.IOException in case of any reading error. + */ + public int peek() throws java.io.IOException { + return file.peek(); + } + + /** + * Gets the next {@code buffer.length} bytes of pdf source without moving source position. + * + * @param buffer buffer to store read bytes + * @return the number of read bytes. If it is less than {@code buffer.length} it means EOF has been reached. + * @throws java.io.IOException in case of any reading error. + */ + public int peek(byte[] buffer) throws java.io.IOException { + return file.peek(buffer); + } + public String readString(int size) throws java.io.IOException { StringBuilder buf = new StringBuilder(); int ch; @@ -254,10 +276,22 @@ public long getNextEof() throws java.io.IOException { do { long currentPosition = file.getPosition(); str = readString(arrLength); - long eofPosition = str.indexOf("%%EOF"); + int eofPosition = str.indexOf("%%EOF"); if (eofPosition >= 0) { - // 6 stands for '%%EOF' length + 1 - return currentPosition + eofPosition + 6; + // Now we want to also include following EOL bytes. + file.seek(currentPosition + eofPosition + 5); + // We only allow 4 next bytes to be EOL markers. + String remainingBytes = readString(4); + int eolCount = 0; + for (byte b : remainingBytes.getBytes(StandardCharsets.UTF_8)) { + if (b == '\n' || b == '\r') { + eolCount++; + } else { + return currentPosition + eofPosition + eolCount + 5; + } + } + // 5 stands for '%%EOF' length + return currentPosition + eofPosition + eolCount + 5; } // Change current position to ensure '%%EOF' is not cut in half. file.seek(file.getPosition() - 4); diff --git a/io/src/main/java/com/itextpdf/io/source/RandomAccessFileOrArray.java b/io/src/main/java/com/itextpdf/io/source/RandomAccessFileOrArray.java index 8027b68972..a4bde6dd89 100644 --- a/io/src/main/java/com/itextpdf/io/source/RandomAccessFileOrArray.java +++ b/io/src/main/java/com/itextpdf/io/source/RandomAccessFileOrArray.java @@ -31,14 +31,6 @@ This file is part of the iText (R) project. */ public class RandomAccessFileOrArray implements DataInput { - - - /** - * When true the file access is not done through a memory mapped file. Use it if the file - * is too big to be mapped in your address space. - */ - public static boolean plainRandomAccess = false; - /** * The source that backs this object */ @@ -115,6 +107,44 @@ public int read() throws java.io.IOException { return byteSource.get(byteSourcePosition++); } + /** + * Gets the next byte without moving current position. + * + * @return the next byte, or -1 if EOF is reached + * @throws java.io.IOException in case of any reading error. + */ + public int peek() throws java.io.IOException { + if (isBack) { + return back & 0xff; + } + return byteSource.get(byteSourcePosition); + } + + /** + * Gets the next {@code buffer.length} bytes without moving current position. + * + * @param buffer buffer to store read bytes + * @return the number of read bytes. If it is less than {@code buffer.length} it means EOF has been reached. + * @throws java.io.IOException in case of any reading error. + */ + public int peek(byte[] buffer) throws java.io.IOException { + int offset = 0; + int length = buffer.length; + int count = 0; + if (isBack && length > 0) { + buffer[offset++] = back; + --length; + ++count; + } + if (length > 0) { + int byteSourceCount = byteSource.get(byteSourcePosition, buffer, offset, length); + if (byteSourceCount > 0) { + count += byteSourceCount; + } + } + return count; + } + /** * Reads the specified amount of bytes to the buffer applying the offset. * diff --git a/io/src/main/java/com/itextpdf/io/util/GhostscriptHelper.java b/io/src/main/java/com/itextpdf/io/util/GhostscriptHelper.java index 9989b0aad1..6c00ba1a54 100644 --- a/io/src/main/java/com/itextpdf/io/util/GhostscriptHelper.java +++ b/io/src/main/java/com/itextpdf/io/util/GhostscriptHelper.java @@ -47,9 +47,6 @@ public class GhostscriptHelper { */ public static final String GHOSTSCRIPT_ENVIRONMENT_VARIABLE = "ITEXT_GS_EXEC"; - @Deprecated - static final String GHOSTSCRIPT_ENVIRONMENT_VARIABLE_LEGACY = "gsExec"; - static final String GHOSTSCRIPT_KEYWORD = "GPL Ghostscript"; private static final String TEMP_FILE_PREFIX = "itext_gs_io_temp"; @@ -79,10 +76,6 @@ public GhostscriptHelper(String newGsExec) { gsExec = newGsExec; if (gsExec == null) { gsExec = SystemUtil.getPropertyOrEnvironmentVariable(GHOSTSCRIPT_ENVIRONMENT_VARIABLE); - - if (gsExec == null) { - gsExec = SystemUtil.getPropertyOrEnvironmentVariable(GHOSTSCRIPT_ENVIRONMENT_VARIABLE_LEGACY); - } } if (!CliCommandUtil.isVersionCommandExecutable(gsExec, GHOSTSCRIPT_KEYWORD)) { diff --git a/io/src/main/java/com/itextpdf/io/util/ImageMagickHelper.java b/io/src/main/java/com/itextpdf/io/util/ImageMagickHelper.java index 1b24e88881..6309095e51 100644 --- a/io/src/main/java/com/itextpdf/io/util/ImageMagickHelper.java +++ b/io/src/main/java/com/itextpdf/io/util/ImageMagickHelper.java @@ -46,9 +46,6 @@ public class ImageMagickHelper { */ public static final String MAGICK_COMPARE_ENVIRONMENT_VARIABLE = "ITEXT_MAGICK_COMPARE_EXEC"; - @Deprecated - static final String MAGICK_COMPARE_ENVIRONMENT_VARIABLE_LEGACY = "compareExec"; - static final String MAGICK_COMPARE_KEYWORD = "ImageMagick Studio LLC"; private static final String TEMP_FILE_PREFIX = "itext_im_io_temp"; @@ -75,9 +72,6 @@ public ImageMagickHelper(String newCompareExec) { compareExec = newCompareExec; if (compareExec == null) { compareExec = SystemUtil.getPropertyOrEnvironmentVariable(MAGICK_COMPARE_ENVIRONMENT_VARIABLE); - if (compareExec == null) { - compareExec = SystemUtil.getPropertyOrEnvironmentVariable(MAGICK_COMPARE_ENVIRONMENT_VARIABLE_LEGACY); - } } if (!CliCommandUtil.isVersionCommandExecutable(compareExec, MAGICK_COMPARE_KEYWORD)) { diff --git a/io/src/main/java/com/itextpdf/io/util/XmlUtil.java b/io/src/main/java/com/itextpdf/io/util/XmlUtil.java index 592c8605a0..60b89cf999 100644 --- a/io/src/main/java/com/itextpdf/io/util/XmlUtil.java +++ b/io/src/main/java/com/itextpdf/io/util/XmlUtil.java @@ -33,7 +33,7 @@ This file is part of the iText (R) project. /** * This file is a helper class for internal usage only. - * Be aware that its API and functionality may be changed in future. + * Be aware that its API and functionality may be changed in the future. */ public final class XmlUtil { diff --git a/io/src/test/java/com/itextpdf/io/AdobeGlyphListTest.java b/io/src/test/java/com/itextpdf/io/AdobeGlyphListTest.java index 07867b78f9..52cb77ac5e 100644 --- a/io/src/test/java/com/itextpdf/io/AdobeGlyphListTest.java +++ b/io/src/test/java/com/itextpdf/io/AdobeGlyphListTest.java @@ -24,17 +24,16 @@ This file is part of the iText (R) project. import com.itextpdf.io.font.AdobeGlyphList; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class AdobeGlyphListTest extends ExtendedITextTest { @Test public void testGlyphListCount() { - Assert.assertEquals(4200, AdobeGlyphList.getNameToUnicodeLength()); - Assert.assertEquals(3680, AdobeGlyphList.getUnicodeToNameLength()); + Assertions.assertEquals(4200, AdobeGlyphList.getNameToUnicodeLength()); + Assertions.assertEquals(3680, AdobeGlyphList.getUnicodeToNameLength()); } } diff --git a/io/src/test/java/com/itextpdf/io/UtilitiesTest.java b/io/src/test/java/com/itextpdf/io/UtilitiesTest.java index 7584cc7dab..9c64a0fdc9 100644 --- a/io/src/test/java/com/itextpdf/io/UtilitiesTest.java +++ b/io/src/test/java/com/itextpdf/io/UtilitiesTest.java @@ -25,12 +25,11 @@ This file is part of the iText (R) project. import com.itextpdf.io.util.ArrayUtil; import com.itextpdf.io.util.ResourceUtil; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class UtilitiesTest extends ExtendedITextTest { @Test public void testShortener() { @@ -38,11 +37,11 @@ public void testShortener() { byte[] dest = new byte[]{1, 2, 3, 4, 5}; byte[] test = ArrayUtil.shortenArray(src, 5); - Assert.assertArrayEquals(dest, test); + Assertions.assertArrayEquals(dest, test); } @Test public void invalidResource() { - Assert.assertNull(ResourceUtil.getResourceStream("some-random-resource.zzz")); + Assertions.assertNull(ResourceUtil.getResourceStream("some-random-resource.zzz")); } } diff --git a/io/src/test/java/com/itextpdf/io/codec/brotli/dec/BitReaderTest.java b/io/src/test/java/com/itextpdf/io/codec/brotli/dec/BitReaderTest.java index 132f852685..7419f46582 100644 --- a/io/src/test/java/com/itextpdf/io/codec/brotli/dec/BitReaderTest.java +++ b/io/src/test/java/com/itextpdf/io/codec/brotli/dec/BitReaderTest.java @@ -6,19 +6,18 @@ package com.itextpdf.io.codec.brotli.dec; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; import java.io.ByteArrayInputStream; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; /** * Tests for {@link BitReader}. */ -@Category(UnitTest.class) +@Tag("UnitTest") public class BitReaderTest extends ExtendedITextTest{ @Test diff --git a/io/src/test/java/com/itextpdf/io/codec/brotli/dec/DecodeTest.java b/io/src/test/java/com/itextpdf/io/codec/brotli/dec/DecodeTest.java index bc35659194..473746a103 100644 --- a/io/src/test/java/com/itextpdf/io/codec/brotli/dec/DecodeTest.java +++ b/io/src/test/java/com/itextpdf/io/codec/brotli/dec/DecodeTest.java @@ -6,21 +6,20 @@ package com.itextpdf.io.codec.brotli.dec; -import static org.junit.Assert.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; /** * Tests for {@link Decode}. */ -@Category(UnitTest.class) +@Tag("UnitTest") public class DecodeTest extends ExtendedITextTest{ private byte[] decompress(byte[] data, boolean byByte) throws IOException { diff --git a/io/src/test/java/com/itextpdf/io/codec/brotli/dec/DictionaryTest.java b/io/src/test/java/com/itextpdf/io/codec/brotli/dec/DictionaryTest.java index 40d693dc39..4658ceb33c 100644 --- a/io/src/test/java/com/itextpdf/io/codec/brotli/dec/DictionaryTest.java +++ b/io/src/test/java/com/itextpdf/io/codec/brotli/dec/DictionaryTest.java @@ -6,23 +6,19 @@ package com.itextpdf.io.codec.brotli.dec; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.nio.ByteBuffer; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; /** * Tests for {@link Dictionary}. */ -@Category(UnitTest.class) -@RunWith(JUnit4.class) +@Tag("UnitTest") public class DictionaryTest extends ExtendedITextTest { @Test diff --git a/io/src/test/java/com/itextpdf/io/codec/brotli/dec/EnumTest.java b/io/src/test/java/com/itextpdf/io/codec/brotli/dec/EnumTest.java index 690f5d532a..56862e6cb0 100644 --- a/io/src/test/java/com/itextpdf/io/codec/brotli/dec/EnumTest.java +++ b/io/src/test/java/com/itextpdf/io/codec/brotli/dec/EnumTest.java @@ -6,27 +6,23 @@ package com.itextpdf.io.codec.brotli.dec; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.fail; import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.util.TreeSet; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; /** * Tests for Enum-like classes. */ -@Category(UnitTest.class) -@RunWith(JUnit4.class) +@Tag("UnitTest") public class EnumTest extends ExtendedITextTest { @Test diff --git a/io/src/test/java/com/itextpdf/io/codec/brotli/dec/SynthTest.java b/io/src/test/java/com/itextpdf/io/codec/brotli/dec/SynthTest.java index 2c683048b7..9dfe585cff 100644 --- a/io/src/test/java/com/itextpdf/io/codec/brotli/dec/SynthTest.java +++ b/io/src/test/java/com/itextpdf/io/codec/brotli/dec/SynthTest.java @@ -6,22 +6,21 @@ package com.itextpdf.io.codec.brotli.dec; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.fail; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; /** * Tests for {@link Decode}. */ -@Category(UnitTest.class) +@Tag("UnitTest") public class SynthTest extends ExtendedITextTest{ private byte[] decompress(byte[] data) throws IOException { diff --git a/io/src/test/java/com/itextpdf/io/codec/brotli/dec/TransformTest.java b/io/src/test/java/com/itextpdf/io/codec/brotli/dec/TransformTest.java index 9b5c2ae3e5..4d775fa2a6 100644 --- a/io/src/test/java/com/itextpdf/io/codec/brotli/dec/TransformTest.java +++ b/io/src/test/java/com/itextpdf/io/codec/brotli/dec/TransformTest.java @@ -6,20 +6,19 @@ package com.itextpdf.io.codec.brotli.dec; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.nio.ByteBuffer; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; /** * Tests for {@link Transform}. */ -@Category(UnitTest.class) +@Tag("UnitTest") public class TransformTest extends ExtendedITextTest{ private static long crc64(byte[] data) { diff --git a/io/src/test/java/com/itextpdf/io/font/CFFFontSubsetIntegrationTest.java b/io/src/test/java/com/itextpdf/io/font/CFFFontSubsetIntegrationTest.java index 45d9a69c49..b10b88d67b 100644 --- a/io/src/test/java/com/itextpdf/io/font/CFFFontSubsetIntegrationTest.java +++ b/io/src/test/java/com/itextpdf/io/font/CFFFontSubsetIntegrationTest.java @@ -25,7 +25,6 @@ This file is part of the iText (R) project. import com.itextpdf.io.source.RandomAccessFileOrArray; import com.itextpdf.io.source.RandomAccessSourceFactory; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.FileOutputStream; import java.io.IOException; @@ -36,11 +35,11 @@ This file is part of the iText (R) project. import java.util.Collections; import java.util.HashSet; import java.util.Set; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class CFFFontSubsetIntegrationTest extends ExtendedITextTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/io/font/CFFFontSubsetIntegrationTest/"; @@ -66,10 +65,10 @@ public void subsetNotoSansCjkJpBoldNoUsedGlyphsTest() throws IOException { subsetNotoSansCjkJpBoldCff(CJK_JP_BOLD_PATH, CJK_JP_BOLD_CFF_OFFSET, CJK_JP_BOLD_CFF_LENGTH, glyphsUsed); int expectedSubsetLength = 279337; - Assert.assertEquals(expectedSubsetLength, cffSubsetBytes.length); + Assertions.assertEquals(expectedSubsetLength, cffSubsetBytes.length); byte[] cmpBytes = Files.readAllBytes(Paths.get(cmpCff)); - Assert.assertArrayEquals(cmpBytes, cffSubsetBytes); + Assertions.assertArrayEquals(cmpBytes, cffSubsetBytes); } @Test @@ -87,10 +86,10 @@ public void subsetNotoSansCjkJpBoldTwoUsedGlyphsTest() throws IOException { subsetNotoSansCjkJpBoldCff(CJK_JP_BOLD_PATH, CJK_JP_BOLD_CFF_OFFSET, CJK_JP_BOLD_CFF_LENGTH, glyphsUsed); int expectedSubsetLength = 365381; - Assert.assertEquals(expectedSubsetLength, cffSubsetBytes.length); + Assertions.assertEquals(expectedSubsetLength, cffSubsetBytes.length); byte[] cmpBytes = Files.readAllBytes(Paths.get(cmpCff)); - Assert.assertArrayEquals(cmpBytes, cffSubsetBytes); + Assertions.assertArrayEquals(cmpBytes, cffSubsetBytes); } @Test @@ -104,10 +103,10 @@ public void subsetNotoSansJpRegularOneUsedGlyphTest() throws IOException { subsetNotoSansCjkJpBoldCff(JP_REGULAR_PATH, JP_REGULAR_CFF_OFFSET, JP_REGULAR_CFF_LENGTH, glyphsUsed); int expectedSubsetLength = 121796; - Assert.assertEquals(expectedSubsetLength, cffSubsetBytes.length); + Assertions.assertEquals(expectedSubsetLength, cffSubsetBytes.length); byte[] cmpBytes = Files.readAllBytes(Paths.get(SOURCE_FOLDER + "subsetNotoSansJPRegularOneUsedGlyph.cff")); - Assert.assertArrayEquals(cmpBytes, cffSubsetBytes); + Assertions.assertArrayEquals(cmpBytes, cffSubsetBytes); } @Test @@ -120,8 +119,8 @@ public void subsetNonCidCFFFontRangeCheck() throws IOException { CFFFont result = new CFFFont(cffSubsetBytes); int expectedCharsetLength = 255; // skip over the format ID (1 byte) and the first SID (2 bytes) - result.seek(result.fonts[0].charsetOffset + 3); - Assert.assertEquals(expectedCharsetLength - 2, result.getCard16()); + result.seek(result.fonts[0].getCharsetOffset() + 3); + Assertions.assertEquals(expectedCharsetLength - 2, result.getCard16()); } private byte[] subsetNotoSansCjkJpBoldCff(String otfFile, int offsetToCff, int cffLength, diff --git a/io/src/test/java/com/itextpdf/io/font/CFFFontTest.java b/io/src/test/java/com/itextpdf/io/font/CFFFontTest.java index d9d59f5103..26679b42ba 100644 --- a/io/src/test/java/com/itextpdf/io/font/CFFFontTest.java +++ b/io/src/test/java/com/itextpdf/io/font/CFFFontTest.java @@ -25,14 +25,13 @@ This file is part of the iText (R) project. import com.itextpdf.io.source.RandomAccessFileOrArray; import com.itextpdf.io.source.RandomAccessSourceFactory; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.IOException; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class CFFFontTest extends ExtendedITextTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/io/font/sharedFontsResourceFiles/"; @@ -55,13 +54,13 @@ public void seekTest() throws IOException { cffFont.seek(0); // Get int (bin 0000 0001 0000 0000 0000 0100 0000 0011) - Assert.assertEquals(16778243, cffFont.getInt()); + Assertions.assertEquals(16778243, cffFont.getInt()); cffFont.seek(0); // Gets the first short (bin 0000 0001 0000 0000) - Assert.assertEquals(256, cffFont.getShort()); + Assertions.assertEquals(256, cffFont.getShort()); cffFont.seek(2); // Gets the second short (bin 0000 0100 0000 0011) - Assert.assertEquals(1027, cffFont.getShort()); + Assertions.assertEquals(1027, cffFont.getShort()); } @Test @@ -82,8 +81,8 @@ public void getPositionTest() throws IOException { cffFont.seek(0); - Assert.assertEquals(0, cffFont.getPosition()); + Assertions.assertEquals(0, cffFont.getPosition()); cffFont.seek(16); - Assert.assertEquals(16, cffFont.getPosition()); + Assertions.assertEquals(16, cffFont.getPosition()); } } diff --git a/io/src/test/java/com/itextpdf/io/font/CjkResourceLoaderNoFontAsianTest.java b/io/src/test/java/com/itextpdf/io/font/CjkResourceLoaderNoFontAsianTest.java index fca5d80171..843e2a158a 100644 --- a/io/src/test/java/com/itextpdf/io/font/CjkResourceLoaderNoFontAsianTest.java +++ b/io/src/test/java/com/itextpdf/io/font/CjkResourceLoaderNoFontAsianTest.java @@ -25,25 +25,24 @@ This file is part of the iText (R) project. import com.itextpdf.io.exceptions.IOException; import com.itextpdf.io.font.cmap.CMapLocationResource; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") // Android-Conversion-Skip-File (TODO DEVSIX-7376 investigate why CjkResourceLoaderNoFontAsianTest is skipped on Android) public class CjkResourceLoaderNoFontAsianTest extends ExtendedITextTest { - @BeforeClass + @BeforeAll public static void beforeClass() { // Here we mimic the absence of font asian CjkResourceLoader.setCmapLocation(new DummyCMapLocationResource()); } - @AfterClass + @AfterAll public static void afterClass() { CjkResourceLoader.setCmapLocation(new CMapLocationResource()); } @@ -52,56 +51,56 @@ public static void afterClass() { public void getCompatibleCidFontNoFontAsian() { // Without font-asian module in the class path // any value passed into a method is expected to return null. - Assert.assertNull(CjkResourceLoader.getCompatibleCidFont("78-RKSJ-V")); + Assertions.assertNull(CjkResourceLoader.getCompatibleCidFont("78-RKSJ-V")); } @Test public void isPredefinedCidFontNoFontAsian() { // Without font-asian module in the class path // any value passed into a method is expected to return false. - Assert.assertFalse(CjkResourceLoader.isPredefinedCidFont("KozMinPro-Regular")); + Assertions.assertFalse(CjkResourceLoader.isPredefinedCidFont("KozMinPro-Regular")); } @Test public void getCompatibleCmapsNoFontAsian() { // Without font-asian module in the class path // any value passed into a method is expected to return null. - Assert.assertNull(CjkResourceLoader.getCompatibleCmaps("HeiseiKakuGo-W5")); + Assertions.assertNull(CjkResourceLoader.getCompatibleCmaps("HeiseiKakuGo-W5")); } @Test public void getRegistryNamesNoFontAsian() { // Without font-asian module in the class path // registry names collection is expected to be empty. - Assert.assertTrue(CjkResourceLoader.getRegistryNames().isEmpty()); + Assertions.assertTrue(CjkResourceLoader.getRegistryNames().isEmpty()); } @Test public void getCid2UniCMapNoFontAsian() { // Without font-asian module in the class path // no CMap can be found. - Assert.assertThrows(IOException.class, () -> CjkResourceLoader.getCid2UniCmap("UniJIS-UTF16-H")); + Assertions.assertThrows(IOException.class, () -> CjkResourceLoader.getCid2UniCmap("UniJIS-UTF16-H")); } @Test public void getUni2CidCMapNoFontAsian() { // Without font-asian module in the class path // no CMap can be found. - Assert.assertThrows(IOException.class, () -> CjkResourceLoader.getUni2CidCmap("UniJIS-UTF16-H")); + Assertions.assertThrows(IOException.class, () -> CjkResourceLoader.getUni2CidCmap("UniJIS-UTF16-H")); } @Test public void getByte2CidCMapNoFontAsian() { // Without font-asian module in the class path // no CMap can be found. - Assert.assertThrows(IOException.class, () -> CjkResourceLoader.getByte2CidCmap("78ms-RKSJ-H")); + Assertions.assertThrows(IOException.class, () -> CjkResourceLoader.getByte2CidCmap("78ms-RKSJ-H")); } @Test public void getCid2ByteCMapNoFontAsian() { // Without font-asian module in the class path // no CMap can be found. - Assert.assertThrows(IOException.class, () -> CjkResourceLoader.getCidToCodepointCmap("78ms-RKSJ-H")); + Assertions.assertThrows(IOException.class, () -> CjkResourceLoader.getCidToCodepointCmap("78ms-RKSJ-H")); } private static class DummyCMapLocationResource extends CMapLocationResource { diff --git a/io/src/test/java/com/itextpdf/io/font/CjkResourceLoaderTest.java b/io/src/test/java/com/itextpdf/io/font/CjkResourceLoaderTest.java index e467f8a865..b048566017 100644 --- a/io/src/test/java/com/itextpdf/io/font/CjkResourceLoaderTest.java +++ b/io/src/test/java/com/itextpdf/io/font/CjkResourceLoaderTest.java @@ -27,15 +27,14 @@ This file is part of the iText (R) project. import com.itextpdf.io.font.cmap.CMapCidUni; import com.itextpdf.io.font.cmap.CMapCodepointToCid; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.util.Map; import java.util.Set; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class CjkResourceLoaderTest extends ExtendedITextTest { @Test @@ -43,34 +42,34 @@ public void getCompatibleCidFont() { String expected = "HeiseiMin-W3"; String compatibleCidFont = CjkResourceLoader.getCompatibleCidFont("78-RKSJ-V"); - Assert.assertEquals(expected, compatibleCidFont); + Assertions.assertEquals(expected, compatibleCidFont); } @Test public void getCompatibleCmaps() { Set compatibleCmaps = CjkResourceLoader.getCompatibleCmaps("HeiseiKakuGo-W5"); - Assert.assertEquals(66, compatibleCmaps.size()); - Assert.assertTrue(compatibleCmaps.contains("78-RKSJ-V")); + Assertions.assertEquals(66, compatibleCmaps.size()); + Assertions.assertTrue(compatibleCmaps.contains("78-RKSJ-V")); } @Test public void getRegistryNames() { Map> registryNames = CjkResourceLoader.getRegistryNames(); - Assert.assertEquals(9, registryNames.size()); - Assert.assertTrue(registryNames.containsKey("Adobe_Japan1")); - Assert.assertTrue(registryNames.get("Adobe_Japan1").contains("78-RKSJ-V")); + Assertions.assertEquals(9, registryNames.size()); + Assertions.assertTrue(registryNames.containsKey("Adobe_Japan1")); + Assertions.assertTrue(registryNames.get("Adobe_Japan1").contains("78-RKSJ-V")); } @Test public void getCid2UniCMap() { CMapCidUni cid2UniCmap = CjkResourceLoader.getCid2UniCmap("UniJIS-UTF16-H"); - Assert.assertEquals(0x00b5, cid2UniCmap.lookup(159)); + Assertions.assertEquals(0x00b5, cid2UniCmap.lookup(159)); } @Test public void getUni2CidCMap() { CMapCodepointToCid uni2CidCmap = CjkResourceLoader.getCodepointToCidCmap("UniJIS-UTF16-H"); - Assert.assertEquals(159, uni2CidCmap.lookup(0x00b5)); + Assertions.assertEquals(159, uni2CidCmap.lookup(0x00b5)); } @Test @@ -83,7 +82,7 @@ public void getByte2CidCMap() { String actual = byte2CidCmap.decodeSequence(byteCodeBytes, 0, 2); String expected = new String(new char[]{cid}); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test @@ -94,6 +93,6 @@ public void getCid2ByteCMap() { byte[] actual = cid2Byte.lookup(cid); byte[] expected = {(byte) ((byteCode & 0xFF00) >> 8), (byte) (byteCode & 0xFF)}; - Assert.assertArrayEquals(expected, actual); + Assertions.assertArrayEquals(expected, actual); } } diff --git a/io/src/test/java/com/itextpdf/io/font/FontCacheTest.java b/io/src/test/java/com/itextpdf/io/font/FontCacheTest.java index f966651133..7d13532a30 100644 --- a/io/src/test/java/com/itextpdf/io/font/FontCacheTest.java +++ b/io/src/test/java/com/itextpdf/io/font/FontCacheTest.java @@ -24,18 +24,17 @@ This file is part of the iText (R) project. import com.itextpdf.io.font.otf.Glyph; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.nio.charset.StandardCharsets; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class FontCacheTest extends ExtendedITextTest { - @Before + @BeforeEach public void before() { FontCache.clearSavedFonts(); } @@ -43,14 +42,14 @@ public void before() { @Test public void clearFontCacheTest() { String fontName = "FreeSans.ttf"; - Assert.assertNull(FontCache.getFont(fontName)); + Assertions.assertNull(FontCache.getFont(fontName)); FontProgram fontProgram = new FontProgramMock(); FontCache.saveFont(fontProgram, fontName); - Assert.assertEquals(fontProgram, FontCache.getFont(fontName)); + Assertions.assertEquals(fontProgram, FontCache.getFont(fontName)); FontCache.clearSavedFonts(); - Assert.assertNull(FontCache.getFont(fontName)); + Assertions.assertNull(FontCache.getFont(fontName)); } @Test @@ -60,14 +59,14 @@ public void fontStringTtcCacheKeyTest() { FontCacheKey ttc0 = FontCacheKey.create(fontName, 0); FontCacheKey ttc1 = FontCacheKey.create(fontName, 1); - Assert.assertNull(FontCache.getFont(ttc0)); - Assert.assertNull(FontCache.getFont(ttc1)); + Assertions.assertNull(FontCache.getFont(ttc0)); + Assertions.assertNull(FontCache.getFont(ttc1)); FontProgram fontProgram = new FontProgramMock(); FontCache.saveFont(fontProgram, ttc1); - Assert.assertNull(FontCache.getFont(ttc0)); - Assert.assertEquals(fontProgram, FontCache.getFont(ttc1)); + Assertions.assertNull(FontCache.getFont(ttc0)); + Assertions.assertEquals(fontProgram, FontCache.getFont(ttc1)); } @Test @@ -80,18 +79,18 @@ public void fontBytesTtcCacheKeyTest() { FontCacheKey otherTtc0 = FontCacheKey.create(otherFontBytes, 1); FontCacheKey normal = FontCacheKey.create(normalFontBytes); - Assert.assertNull(FontCache.getFont(ttc0)); - Assert.assertNull(FontCache.getFont(otherTtc0)); - Assert.assertNull(FontCache.getFont(normal)); + Assertions.assertNull(FontCache.getFont(ttc0)); + Assertions.assertNull(FontCache.getFont(otherTtc0)); + Assertions.assertNull(FontCache.getFont(normal)); FontProgram otherTtc0MockFontProgram = new FontProgramMock(); FontProgram normalMockFontProgram = new FontProgramMock(); FontCache.saveFont(otherTtc0MockFontProgram, otherTtc0); FontCache.saveFont(normalMockFontProgram, normal); - Assert.assertNull(FontCache.getFont(ttc0)); - Assert.assertEquals(otherTtc0MockFontProgram, FontCache.getFont(otherTtc0)); - Assert.assertEquals(normalMockFontProgram, FontCache.getFont(normal)); + Assertions.assertNull(FontCache.getFont(ttc0)); + Assertions.assertEquals(otherTtc0MockFontProgram, FontCache.getFont(otherTtc0)); + Assertions.assertEquals(normalMockFontProgram, FontCache.getFont(normal)); } private static class FontProgramMock extends FontProgram { diff --git a/io/src/test/java/com/itextpdf/io/font/FontEncodingTest.java b/io/src/test/java/com/itextpdf/io/font/FontEncodingTest.java index be471db175..4a18c30701 100644 --- a/io/src/test/java/com/itextpdf/io/font/FontEncodingTest.java +++ b/io/src/test/java/com/itextpdf/io/font/FontEncodingTest.java @@ -23,13 +23,12 @@ This file is part of the iText (R) project. package com.itextpdf.io.font; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class FontEncodingTest extends ExtendedITextTest { @Test @@ -39,7 +38,7 @@ public void notSetDifferenceToMinus1IndexTest() { String[] initialDifferences = (String[]) encoding.differences.clone(); encoding.setDifference(-1, "a"); - Assert.assertArrayEquals(initialDifferences, encoding.differences); + Assertions.assertArrayEquals(initialDifferences, encoding.differences); } @Test @@ -49,7 +48,7 @@ public void notSetDifferenceTo256IndexTest() { String[] initialDifferences = (String[]) encoding.differences.clone(); encoding.setDifference(256, "a"); - Assert.assertArrayEquals(initialDifferences, encoding.differences); + Assertions.assertArrayEquals(initialDifferences, encoding.differences); } @Test @@ -58,7 +57,7 @@ public void setDifferenceToZeroIndexTest() { encoding.setDifference(0, "a"); - Assert.assertEquals("a", encoding.differences[0]); + Assertions.assertEquals("a", encoding.differences[0]); } @Test @@ -67,14 +66,14 @@ public void setDifferenceTo255IndexTest() { encoding.setDifference(255, "a"); - Assert.assertEquals("a", encoding.differences[255]); + Assertions.assertEquals("a", encoding.differences[255]); } @Test public void getNullDifferenceTest() { FontEncoding encoding = FontEncoding.createEmptyFontEncoding(); - Assert.assertNull(encoding.getDifference(0)); + Assertions.assertNull(encoding.getDifference(0)); } @Test @@ -83,12 +82,12 @@ public void setDifferenceAndGetTest() { encoding.setDifference(0, "a"); - Assert.assertEquals("a", encoding.getDifference(0)); + Assertions.assertEquals("a", encoding.getDifference(0)); } @Test public void fontSpecificEncodingTest() { FontEncoding encoding = FontEncoding.createFontSpecificEncoding(); - Assert.assertTrue(encoding.isFontSpecific()); + Assertions.assertTrue(encoding.isFontSpecific()); } } diff --git a/io/src/test/java/com/itextpdf/io/font/FontProgramDescriptorFactoryTest.java b/io/src/test/java/com/itextpdf/io/font/FontProgramDescriptorFactoryTest.java index 80069afac2..2c7952278a 100644 --- a/io/src/test/java/com/itextpdf/io/font/FontProgramDescriptorFactoryTest.java +++ b/io/src/test/java/com/itextpdf/io/font/FontProgramDescriptorFactoryTest.java @@ -23,30 +23,29 @@ This file is part of the iText (R) project. package com.itextpdf.io.font; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class FontProgramDescriptorFactoryTest extends ExtendedITextTest { @Test public void kozminNamesTest() { FontProgramDescriptor descriptor = FontProgramDescriptorFactory.fetchDescriptor("KozMinPro-Regular"); - Assert.assertEquals("KozMinPro-Regular", descriptor.getFontName()); - Assert.assertEquals("KozMinPro-Regular".toLowerCase(), descriptor.getFullNameLowerCase()); - Assert.assertEquals(400, descriptor.getFontWeight()); + Assertions.assertEquals("KozMinPro-Regular", descriptor.getFontName()); + Assertions.assertEquals("KozMinPro-Regular".toLowerCase(), descriptor.getFullNameLowerCase()); + Assertions.assertEquals(400, descriptor.getFontWeight()); } @Test public void helveticaNamesTest() { FontProgramDescriptor descriptor = FontProgramDescriptorFactory.fetchDescriptor("Helvetica"); - Assert.assertEquals("Helvetica", descriptor.getFontName()); - Assert.assertEquals("helvetica", descriptor.getFullNameLowerCase()); - Assert.assertEquals("helvetica", descriptor.getFullNameLowerCase()); - Assert.assertEquals(500, descriptor.getFontWeight()); + Assertions.assertEquals("Helvetica", descriptor.getFontName()); + Assertions.assertEquals("helvetica", descriptor.getFullNameLowerCase()); + Assertions.assertEquals("helvetica", descriptor.getFullNameLowerCase()); + Assertions.assertEquals(500, descriptor.getFontWeight()); } } diff --git a/io/src/test/java/com/itextpdf/io/font/FontProgramTest.java b/io/src/test/java/com/itextpdf/io/font/FontProgramTest.java index ae2cadcd68..4c9a222e69 100644 --- a/io/src/test/java/com/itextpdf/io/font/FontProgramTest.java +++ b/io/src/test/java/com/itextpdf/io/font/FontProgramTest.java @@ -27,33 +27,32 @@ This file is part of the iText (R) project. import com.itextpdf.commons.utils.MessageFormatUtil; import com.itextpdf.io.font.otf.Glyph; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; -@Category(UnitTest.class) +@Tag("UnitTest") public class FontProgramTest extends ExtendedITextTest { private static final String notExistingFont = "some-font.ttf"; @Test public void exceptionMessageTest() throws IOException { - Exception e = Assert.assertThrows(java.io.IOException.class, + Exception e = Assertions.assertThrows(java.io.IOException.class, () -> FontProgramFactory.createFont(notExistingFont) ); - Assert.assertEquals(MessageFormatUtil.format(IoExceptionMessageConstant.NOT_FOUND_AS_FILE_OR_RESOURCE, notExistingFont), e.getMessage()); + Assertions.assertEquals(MessageFormatUtil.format(IoExceptionMessageConstant.NOT_FOUND_AS_FILE_OR_RESOURCE, notExistingFont), e.getMessage()); } @Test public void boldTest() throws IOException { FontProgram fp = FontProgramFactory.createFont(StandardFonts.HELVETICA); fp.setBold(true); - Assert.assertTrue("Bold expected", (fp.getPdfFontFlags() & (1 << 18)) != 0); + Assertions.assertTrue((fp.getPdfFontFlags() & (1 << 18)) != 0, "Bold expected"); fp.setBold(false); - Assert.assertTrue("Not Bold expected", (fp.getPdfFontFlags() & (1 << 18)) == 0); + Assertions.assertTrue((fp.getPdfFontFlags() & (1 << 18)) == 0, "Not Bold expected"); } @Test @@ -63,9 +62,9 @@ public void registerDirectoryOpenTypeTest() { FontCache.clearSavedFonts(); FontProgramFactory.registerFontDirectory("./src/test/resources/com/itextpdf/io/font/otf/"); - Assert.assertEquals(43, FontProgramFactory.getRegisteredFonts().size()); - Assert.assertNull(FontCache.getFont("./src/test/resources/com/itextpdf/io/font/otf/FreeSansBold.ttf")); - Assert.assertTrue(FontProgramFactory.getRegisteredFonts().contains("free sans lihavoitu")); + Assertions.assertEquals(43, FontProgramFactory.getRegisteredFonts().size()); + Assertions.assertNull(FontCache.getFont("./src/test/resources/com/itextpdf/io/font/otf/FreeSansBold.ttf")); + Assertions.assertTrue(FontProgramFactory.getRegisteredFonts().contains("free sans lihavoitu")); } @Test @@ -73,8 +72,8 @@ public void registerDirectoryType1Test() throws IOException { FontProgramFactory.registerFontDirectory("./src/test/resources/com/itextpdf/io/font/type1/"); FontProgram computerModern = FontProgramFactory.createRegisteredFont("computer modern"); FontProgram cmr10 = FontProgramFactory.createRegisteredFont("cmr10"); - Assert.assertNotNull(computerModern); - Assert.assertNotNull(cmr10); + Assertions.assertNotNull(computerModern); + Assertions.assertNotNull(cmr10); } @Test @@ -84,17 +83,17 @@ public void cidFontWithCmapTest() throws IOException { FontProgram fp = FontProgramFactory.createFont("KozMinPro-Regular", "UniJIS-UCS2-HW-H", true); Glyph glyph = fp.getGlyph(space); - Assert.assertArrayEquals(new char[] {space}, glyph.getUnicodeChars()); - Assert.assertEquals(32, glyph.getUnicode()); - Assert.assertEquals(231, glyph.getCode()); - Assert.assertEquals(500, glyph.getWidth()); + Assertions.assertArrayEquals(new char[] {space}, glyph.getUnicodeChars()); + Assertions.assertEquals(32, glyph.getUnicode()); + Assertions.assertEquals(231, glyph.getCode()); + Assertions.assertEquals(500, glyph.getWidth()); fp = FontProgramFactory.createFont("KozMinPro-Regular", null, true); glyph = fp.getGlyph(space); - Assert.assertArrayEquals(new char[] {space}, glyph.getUnicodeChars()); - Assert.assertEquals(32, glyph.getUnicode()); - Assert.assertEquals(1, glyph.getCode()); - Assert.assertEquals(278, glyph.getWidth()); + Assertions.assertArrayEquals(new char[] {space}, glyph.getUnicodeChars()); + Assertions.assertEquals(32, glyph.getUnicode()); + Assertions.assertEquals(1, glyph.getCode()); + Assertions.assertEquals(278, glyph.getWidth()); } } diff --git a/io/src/test/java/com/itextpdf/io/font/LoadAllAsianFontsTest.java b/io/src/test/java/com/itextpdf/io/font/LoadAllAsianFontsTest.java new file mode 100644 index 0000000000..233c64c322 --- /dev/null +++ b/io/src/test/java/com/itextpdf/io/font/LoadAllAsianFontsTest.java @@ -0,0 +1,270 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.io.font; + +import com.itextpdf.io.font.cmap.AbstractCMap; +import com.itextpdf.io.logs.IoLogMessageConstant; +import com.itextpdf.test.ExtendedITextTest; +import com.itextpdf.test.annotations.LogMessages; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +@Tag("IntegrationTest") +public class LoadAllAsianFontsTest extends ExtendedITextTest { + + @ParameterizedTest(name = "{index}: {0} {1}") + @MethodSource("data") + // TODO DEVSIX-8619 All cmap parsing errors should be fixed and this logging should then be removed + @LogMessages(messages = { + @com.itextpdf.test.annotations.LogMessage(messageTemplate = IoLogMessageConstant.UNKNOWN_ERROR_WHILE_PROCESSING_CMAP, ignore = true), + + }) + public void testAsianFonts(String cmapName, String ordering) { + checkFontAsianCmap(cmapName, ordering); + } + + public static Collection data() { + List result = new ArrayList<>(); + result.add(new Object[]{"78-EUC-H", "Japan1"}); + result.add(new Object[]{"78-EUC-V", "Japan1"}); + result.add(new Object[]{"78-H", "Japan1"}); + result.add(new Object[]{"78-RKSJ-H", "Japan1"}); + result.add(new Object[]{"78-RKSJ-V", "Japan1"}); + result.add(new Object[]{"78-V", "Japan1"}); + result.add(new Object[]{"78ms-RKSJ-H", "Japan1"}); + result.add(new Object[]{"78ms-RKSJ-V", "Japan1"}); + result.add(new Object[]{"83pv-RKSJ-H", "Japan1"}); + result.add(new Object[]{"90ms-RKSJ-H", "Japan1"}); + result.add(new Object[]{"90ms-RKSJ-V", "Japan1"}); + result.add(new Object[]{"90msp-RKSJ-H", "Japan1"}); + result.add(new Object[]{"90msp-RKSJ-V", "Japan1"}); + result.add(new Object[]{"90pv-RKSJ-H", "Japan1"}); + result.add(new Object[]{"90pv-RKSJ-V", "Japan1"}); + result.add(new Object[]{"Add-H", "Japan1"}); + result.add(new Object[]{"Add-RKSJ-H", "Japan1"}); + result.add(new Object[]{"Add-RKSJ-V", "Japan1"}); + result.add(new Object[]{"Add-V", "Japan1"}); + + result.add(new Object[]{"Adobe-CNS1-0", "CNS1"}); + result.add(new Object[]{"Adobe-CNS1-1", "CNS1"}); + result.add(new Object[]{"Adobe-CNS1-2", "CNS1"}); + result.add(new Object[]{"Adobe-CNS1-3", "CNS1"}); + result.add(new Object[]{"Adobe-CNS1-4", "CNS1"}); + result.add(new Object[]{"Adobe-CNS1-5", "CNS1"}); + result.add(new Object[]{"Adobe-CNS1-6", "CNS1"}); + result.add(new Object[]{"Adobe-CNS1-7", "CNS1"}); + + result.add(new Object[]{"Adobe-GB1-0", "GB1"}); + result.add(new Object[]{"Adobe-GB1-1", "GB1"}); + result.add(new Object[]{"Adobe-GB1-2", "GB1"}); + result.add(new Object[]{"Adobe-GB1-3", "GB1"}); + result.add(new Object[]{"Adobe-GB1-4", "GB1"}); + result.add(new Object[]{"Adobe-GB1-5", "GB1"}); + + result.add(new Object[]{"Adobe-Japan1-0", "Japan1"}); + result.add(new Object[]{"Adobe-Japan1-1", "Japan1"}); + result.add(new Object[]{"Adobe-Japan1-2", "Japan1"}); + result.add(new Object[]{"Adobe-Japan1-3", "Japan1"}); + result.add(new Object[]{"Adobe-Japan1-4", "Japan1"}); + result.add(new Object[]{"Adobe-Japan1-5", "Japan1"}); + result.add(new Object[]{"Adobe-Japan1-6", "Japan1"}); + result.add(new Object[]{"Adobe-Japan1-7", "Japan1"}); + + result.add(new Object[]{"Adobe-Korea1-0", "Korea1"}); + result.add(new Object[]{"Adobe-Korea1-1", "Korea1"}); + result.add(new Object[]{"Adobe-Korea1-2", "Korea1"}); + + result.add(new Object[]{"Adobe-KR-0", "KR"}); + result.add(new Object[]{"Adobe-KR-1", "KR"}); + result.add(new Object[]{"Adobe-KR-2", "KR"}); + result.add(new Object[]{"Adobe-KR-3", "KR"}); + result.add(new Object[]{"Adobe-KR-4", "KR"}); + result.add(new Object[]{"Adobe-KR-5", "KR"}); + result.add(new Object[]{"Adobe-KR-6", "KR"}); + result.add(new Object[]{"Adobe-KR-7", "KR"}); + result.add(new Object[]{"Adobe-KR-8", "KR"}); + result.add(new Object[]{"Adobe-KR-9", "KR"}); + + result.add(new Object[]{"B5-H", "CNS1"}); + result.add(new Object[]{"B5-V", "CNS1"}); + result.add(new Object[]{"B5pc-H", "CNS1"}); + result.add(new Object[]{"B5pc-V", "CNS1"}); + result.add(new Object[]{"CNS1-H", "CNS1"}); + result.add(new Object[]{"CNS1-V", "CNS1"}); + result.add(new Object[]{"CNS2-H", "CNS1"}); + result.add(new Object[]{"CNS2-V", "CNS1"}); + result.add(new Object[]{"CNS-EUC-H", "CNS1"}); + result.add(new Object[]{"CNS-EUC-V", "CNS1"}); + result.add(new Object[]{"ETen-B5-H", "CNS1"}); + result.add(new Object[]{"ETen-B5-V", "CNS1"}); + result.add(new Object[]{"ETenms-B5-H", "CNS1"}); + result.add(new Object[]{"ETenms-B5-V", "CNS1"}); + result.add(new Object[]{"ETHK-B5-H", "CNS1"}); + result.add(new Object[]{"ETHK-B5-V", "CNS1"}); + + result.add(new Object[]{"EUC-H", "Japan1"}); + result.add(new Object[]{"EUC-V", "Japan1"}); + result.add(new Object[]{"Ext-H", "Japan1"}); + result.add(new Object[]{"Ext-RKSJ-H", "Japan1"}); + result.add(new Object[]{"Ext-RKSJ-V", "Japan1"}); + result.add(new Object[]{"Ext-V", "Japan1"}); + + result.add(new Object[]{"GB-EUC-H", "GB1"}); + result.add(new Object[]{"GB-EUC-V", "GB1"}); + result.add(new Object[]{"GBK2K-H", "GB1"}); + result.add(new Object[]{"GBK2K-V", "GB1"}); + result.add(new Object[]{"GBK-EUC-H", "GB1"}); + result.add(new Object[]{"GBK-EUC-V", "GB1"}); + result.add(new Object[]{"GBKp-EUC-H", "GB1"}); + result.add(new Object[]{"GBKp-EUC-V", "GB1"}); + result.add(new Object[]{"GBpc-EUC-H", "GB1"}); + result.add(new Object[]{"GBpc-EUC-V", "GB1"}); + result.add(new Object[]{"GBT-EUC-H", "GB1"}); + result.add(new Object[]{"GBT-EUC-V", "GB1"}); + result.add(new Object[]{"GBT-H", "GB1"}); + result.add(new Object[]{"GBT-V", "GB1"}); + result.add(new Object[]{"GBTpc-EUC-H", "GB1"}); + result.add(new Object[]{"GBTpc-EUC-V", "GB1"}); + + result.add(new Object[]{"H", "Japan1"}); + result.add(new Object[]{"Hankaku", "Japan1"}); + result.add(new Object[]{"Hiragana", "Japan1"}); + + result.add(new Object[]{"HKdla-B5-H", "CNS1"}); + result.add(new Object[]{"HKdla-B5-V", "CNS1"}); + result.add(new Object[]{"HKdlb-B5-H", "CNS1"}); + result.add(new Object[]{"HKdlb-B5-V", "CNS1"}); + result.add(new Object[]{"HKgccs-B5-H", "CNS1"}); + result.add(new Object[]{"HKgccs-B5-V", "CNS1"}); + result.add(new Object[]{"HKm314-B5-H", "CNS1"}); + result.add(new Object[]{"HKm314-B5-V", "CNS1"}); + result.add(new Object[]{"HKm471-B5-H", "CNS1"}); + result.add(new Object[]{"HKm471-B5-V", "CNS1"}); + result.add(new Object[]{"HKscs-B5-H", "CNS1"}); + result.add(new Object[]{"HKscs-B5-V", "CNS1"}); + + result.add(new Object[]{"Identity-H", "Identity"}); + result.add(new Object[]{"Identity-V", "Identity"}); + + result.add(new Object[]{"Katakana", "Japan1"}); + + result.add(new Object[]{"KSC-EUC-H", "Korea1"}); + result.add(new Object[]{"KSC-EUC-V", "Korea1"}); + result.add(new Object[]{"KSC-H", "Korea1"}); + result.add(new Object[]{"KSC-Johab-H", "Korea1"}); + result.add(new Object[]{"KSC-Johab-V", "Korea1"}); + result.add(new Object[]{"KSC-V", "Korea1"}); + result.add(new Object[]{"KSCms-UHC-H", "Korea1"}); + result.add(new Object[]{"KSCms-UHC-HW-H", "Korea1"}); + result.add(new Object[]{"KSCms-UHC-HW-V", "Korea1"}); + result.add(new Object[]{"KSCms-UHC-V", "Korea1"}); + result.add(new Object[]{"KSCpc-EUC-H", "Korea1"}); + result.add(new Object[]{"KSCpc-EUC-V", "Korea1"}); + + result.add(new Object[]{"NWP-H", "Japan1"}); + result.add(new Object[]{"NWP-V", "Japan1"}); + result.add(new Object[]{"RKSJ-H", "Japan1"}); + result.add(new Object[]{"RKSJ-V", "Japan1"}); + result.add(new Object[]{"Roman", "Japan1"}); + + result.add(new Object[]{"UniAKR-UTF8-H", "KR"}); + result.add(new Object[]{"UniAKR-UTF16-H", "KR"}); + result.add(new Object[]{"UniAKR-UTF32-H", "KR"}); + + result.add(new Object[]{"UniCNS-UCS2-H", "CNS1"}); + result.add(new Object[]{"UniCNS-UCS2-V", "CNS1"}); + result.add(new Object[]{"UniCNS-UTF8-H", "CNS1"}); + result.add(new Object[]{"UniCNS-UTF8-V", "CNS1"}); + result.add(new Object[]{"UniCNS-UTF16-H", "CNS1"}); + result.add(new Object[]{"UniCNS-UTF16-V", "CNS1"}); + result.add(new Object[]{"UniCNS-UTF32-H", "CNS1"}); + result.add(new Object[]{"UniCNS-UTF32-V", "CNS1"}); + + result.add(new Object[]{"UniGB-UCS2-H", "GB1"}); + result.add(new Object[]{"UniGB-UCS2-V", "GB1"}); + result.add(new Object[]{"UniGB-UTF8-H", "GB1"}); + result.add(new Object[]{"UniGB-UTF8-V", "GB1"}); + result.add(new Object[]{"UniGB-UTF16-H", "GB1"}); + result.add(new Object[]{"UniGB-UTF16-V", "GB1"}); + result.add(new Object[]{"UniGB-UTF32-H", "GB1"}); + result.add(new Object[]{"UniGB-UTF32-V", "GB1"}); + + result.add(new Object[]{"UniJIS2004-UTF8-H", "Japan1"}); + result.add(new Object[]{"UniJIS2004-UTF8-V", "Japan1"}); + result.add(new Object[]{"UniJIS2004-UTF16-H", "Japan1"}); + result.add(new Object[]{"UniJIS2004-UTF16-V", "Japan1"}); + result.add(new Object[]{"UniJIS2004-UTF32-H", "Japan1"}); + result.add(new Object[]{"UniJIS2004-UTF32-V", "Japan1"}); + result.add(new Object[]{"UniJIS-UCS2-H", "Japan1"}); + result.add(new Object[]{"UniJIS-UCS2-HW-H", "Japan1"}); + result.add(new Object[]{"UniJIS-UCS2-HW-V", "Japan1"}); + result.add(new Object[]{"UniJIS-UCS2-V", "Japan1"}); + result.add(new Object[]{"UniJIS-UTF8-H", "Japan1"}); + result.add(new Object[]{"UniJIS-UTF8-V", "Japan1"}); + result.add(new Object[]{"UniJIS-UTF16-H", "Japan1"}); + result.add(new Object[]{"UniJIS-UTF16-V", "Japan1"}); + result.add(new Object[]{"UniJIS-UTF32-H", "Japan1"}); + result.add(new Object[]{"UniJIS-UTF32-V", "Japan1"}); + result.add(new Object[]{"UniJISPro-UCS2-HW-V", "Japan1"}); + result.add(new Object[]{"UniJISPro-UCS2-V", "Japan1"}); + result.add(new Object[]{"UniJISPro-UTF8-V", "Japan1"}); + result.add(new Object[]{"UniJISX0213-UTF32-H", "Japan1"}); + result.add(new Object[]{"UniJISX0213-UTF32-V", "Japan1"}); + result.add(new Object[]{"UniJISX02132004-UTF32-H", "Japan1"}); + result.add(new Object[]{"UniJISX02132004-UTF32-V", "Japan1"}); + + result.add(new Object[]{"UniKS-UCS2-H", "Korea1"}); + result.add(new Object[]{"UniKS-UCS2-V", "Korea1"}); + result.add(new Object[]{"UniKS-UTF8-H", "Korea1"}); + result.add(new Object[]{"UniKS-UTF8-V", "Korea1"}); + result.add(new Object[]{"UniKS-UTF16-H", "Korea1"}); + result.add(new Object[]{"UniKS-UTF16-V", "Korea1"}); + result.add(new Object[]{"UniKS-UTF32-H", "Korea1"}); + result.add(new Object[]{"UniKS-UTF32-V", "Korea1"}); + + result.add(new Object[]{"V", "Japan1"}); + result.add(new Object[]{"WP-Symbol", "Japan1"}); + + result.add(new Object[]{ResourceTestUtil.normalizeResourceName("toUnicode/Adobe-CNS1-UCS2"), "Adobe_CNS1_UCS2"}); + result.add(new Object[]{ResourceTestUtil.normalizeResourceName("toUnicode/Adobe-GB1-UCS2"), "Adobe_GB1_UCS2"}); + result.add(new Object[]{ResourceTestUtil.normalizeResourceName("toUnicode/Adobe-Japan1-UCS2"), "Adobe_Japan1_UCS2"}); + result.add(new Object[]{ResourceTestUtil.normalizeResourceName("toUnicode/Adobe-Korea1-UCS2"), "Adobe_Korea1_UCS2"}); + result.add(new Object[]{ResourceTestUtil.normalizeResourceName("toUnicode/Adobe-KR-UCS2"), "Adobe_KR_UCS2"}); + + return result; + } + + private void checkFontAsianCmap(String cmapName, String ordering) { + AbstractCMap cmap = CjkResourceLoader.getUni2CidCmap(cmapName); + Assertions.assertTrue(cmapName.endsWith(cmap.getName())); + Assertions.assertEquals(ordering, cmap.getOrdering()); + } + + +} diff --git a/io/src/test/java/com/itextpdf/io/font/MonospaceFontTest.java b/io/src/test/java/com/itextpdf/io/font/MonospaceFontTest.java index fb290fbd49..9338f9ac7d 100644 --- a/io/src/test/java/com/itextpdf/io/font/MonospaceFontTest.java +++ b/io/src/test/java/com/itextpdf/io/font/MonospaceFontTest.java @@ -23,31 +23,30 @@ This file is part of the iText (R) project. package com.itextpdf.io.font; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class MonospaceFontTest extends ExtendedITextTest { private static final String sourceFolder = "./src/test/resources/com/itextpdf/io/font/MonospaceFontTest/"; @Test public void openMono() throws java.io.IOException { TrueTypeFont font = new TrueTypeFont(sourceFolder + "DejaVuSansMono.ttf"); - Assert.assertNotNull(font.getGlyph('A')); + Assertions.assertNotNull(font.getGlyph('A')); } @Test public void openSans() throws java.io.IOException { TrueTypeFont font = new TrueTypeFont(sourceFolder + "DejaVuSans.ttf"); - Assert.assertNotNull(font.getGlyph('A')); + Assertions.assertNotNull(font.getGlyph('A')); } @Test public void openSerif() throws java.io.IOException { TrueTypeFont font = new TrueTypeFont(sourceFolder + "DejaVuSerif.ttf"); - Assert.assertNotNull(font.getGlyph('A')); + Assertions.assertNotNull(font.getGlyph('A')); } } diff --git a/io/src/test/java/com/itextpdf/io/font/PdfEncodingsTest.java b/io/src/test/java/com/itextpdf/io/font/PdfEncodingsTest.java index 995e1f4b2d..35886257e0 100644 --- a/io/src/test/java/com/itextpdf/io/font/PdfEncodingsTest.java +++ b/io/src/test/java/com/itextpdf/io/font/PdfEncodingsTest.java @@ -23,19 +23,18 @@ This file is part of the iText (R) project. package com.itextpdf.io.font; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfEncodingsTest extends ExtendedITextTest { @Test public void convertToBytesNoEncodingTest() { - Assert.assertArrayEquals(new byte[]{(byte) 194}, PdfEncodings.convertToBytes('Â', null)); - Assert.assertArrayEquals(new byte[]{(byte) 194}, PdfEncodings.convertToBytes('Â', "")); - Assert.assertArrayEquals(new byte[]{(byte) 194}, PdfEncodings.convertToBytes('Â', "symboltt")); + Assertions.assertArrayEquals(new byte[]{(byte) 194}, PdfEncodings.convertToBytes('Â', null)); + Assertions.assertArrayEquals(new byte[]{(byte) 194}, PdfEncodings.convertToBytes('Â', "")); + Assertions.assertArrayEquals(new byte[]{(byte) 194}, PdfEncodings.convertToBytes('Â', "symboltt")); } } diff --git a/pdftest/src/main/java/com/itextpdf/test/annotations/type/BouncyCastleUnitTest.java b/io/src/test/java/com/itextpdf/io/font/ResourceTestUtil.java similarity index 83% rename from pdftest/src/main/java/com/itextpdf/test/annotations/type/BouncyCastleUnitTest.java rename to io/src/test/java/com/itextpdf/io/font/ResourceTestUtil.java index 97c3e69cba..ea0f09c0d7 100644 --- a/pdftest/src/main/java/com/itextpdf/test/annotations/type/BouncyCastleUnitTest.java +++ b/io/src/test/java/com/itextpdf/io/font/ResourceTestUtil.java @@ -20,10 +20,11 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.test.annotations.type; +package com.itextpdf.io.font; -/** - * Unit tests which need to be run with several different bouncy-castle dependencies. - */ -public interface BouncyCastleUnitTest extends UnitTest { +class ResourceTestUtil { + + public static String normalizeResourceName(String resourceName) { + return resourceName; + } } diff --git a/io/src/test/java/com/itextpdf/io/font/TrueTypeFontTest.java b/io/src/test/java/com/itextpdf/io/font/TrueTypeFontTest.java index d66838a148..3d729a7b3a 100644 --- a/io/src/test/java/com/itextpdf/io/font/TrueTypeFontTest.java +++ b/io/src/test/java/com/itextpdf/io/font/TrueTypeFontTest.java @@ -24,7 +24,6 @@ This file is part of the iText (R) project. import com.itextpdf.io.font.otf.Glyph; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.IOException; import java.util.ArrayList; @@ -33,11 +32,11 @@ This file is part of the iText (R) project. import java.util.HashSet; import java.util.List; import java.util.Set; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class TrueTypeFontTest extends ExtendedITextTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/io/font/sharedFontsResourceFiles/"; @@ -49,9 +48,9 @@ public void notoSansJpCmapTest() throws IOException, InterruptedException { FontProgram fontProgram = FontProgramFactory.createFont(SOURCE_FOLDER + "NotoSansJP-Regular_charsetDataFormat0.otf"); Glyph glyph = fontProgram.getGlyph(jpChar); - Assert.assertArrayEquals(new char[] {jpChar}, glyph.getUnicodeChars()); - Assert.assertEquals(20449, glyph.getUnicode()); - Assert.assertEquals(10195, glyph.getCode()); + Assertions.assertArrayEquals(new char[] {jpChar}, glyph.getUnicodeChars()); + Assertions.assertEquals(20449, glyph.getUnicode()); + Assertions.assertEquals(10195, glyph.getCode()); } @Test @@ -62,9 +61,9 @@ public void notoSansScCmapTest() throws IOException { FontProgram fontProgram = FontProgramFactory.createFont(SOURCE_FOLDER + "NotoSansSC-Regular.otf"); Glyph glyph = fontProgram.getGlyph(chChar); - Assert.assertArrayEquals(new char[] {chChar}, glyph.getUnicodeChars()); - Assert.assertEquals(26131, glyph.getUnicode()); - Assert.assertEquals(20292, glyph.getCode()); + Assertions.assertArrayEquals(new char[] {chChar}, glyph.getUnicodeChars()); + Assertions.assertEquals(26131, glyph.getUnicode()); + Assertions.assertEquals(20292, glyph.getCode()); } @Test @@ -75,9 +74,9 @@ public void notoSansTcCmapTest() throws IOException { FontProgram fontProgram = FontProgramFactory.createFont(SOURCE_FOLDER + "NotoSansTC-Regular.otf"); Glyph glyph = fontProgram.getGlyph(chChar); - Assert.assertArrayEquals(new char[] {chChar}, glyph.getUnicodeChars()); - Assert.assertEquals(26131, glyph.getUnicode()); - Assert.assertEquals(20292, glyph.getCode()); + Assertions.assertArrayEquals(new char[] {chChar}, glyph.getUnicodeChars()); + Assertions.assertEquals(26131, glyph.getUnicode()); + Assertions.assertEquals(20292, glyph.getCode()); } @Test @@ -92,7 +91,29 @@ public void notoSansScMapGlyphsCidsToGidsTest() throws IOException { HashSet glyphs = new HashSet<>(Collections.singletonList(charCidInFont)); Set actualResult = trueTypeFontProgram.mapGlyphsCidsToGids(glyphs); - Assert.assertEquals(1, actualResult.size()); - Assert.assertTrue(actualResult.contains(charGidInFont)); + Assertions.assertEquals(1, actualResult.size()); + Assertions.assertTrue(actualResult.contains(charGidInFont)); + } + + @Test + public void cmapPlatform0PlatEnc3Format4Test() throws IOException { + FontProgram fontProgram = FontProgramFactory.createFont(SOURCE_FOLDER + "glyphs.ttf"); + checkCmapTableEntry(fontProgram, 'f', 2); + checkCmapTableEntry(fontProgram, 'i', 3); + } + + @Test + public void cmapPlatform0PlatEnc3Format6Test() throws IOException { + FontProgram fontProgram = FontProgramFactory.createFont(SOURCE_FOLDER + "glyphs-fmt-6.ttf"); + checkCmapTableEntry(fontProgram, 'f', 2); + checkCmapTableEntry(fontProgram, 'i', 3); + } + + private void checkCmapTableEntry(FontProgram fontProgram, char uniChar, int expectedGlyphId) { + + Glyph glyph = fontProgram.getGlyph(uniChar); + + Assertions.assertEquals(expectedGlyphId, glyph.getCode()); + Assertions.assertArrayEquals(new char[]{uniChar}, glyph.getUnicodeChars()); } } diff --git a/io/src/test/java/com/itextpdf/io/font/Type1FontTest.java b/io/src/test/java/com/itextpdf/io/font/Type1FontTest.java index 9d72270a39..cc2b3c9290 100644 --- a/io/src/test/java/com/itextpdf/io/font/Type1FontTest.java +++ b/io/src/test/java/com/itextpdf/io/font/Type1FontTest.java @@ -23,24 +23,23 @@ This file is part of the iText (R) project. package com.itextpdf.io.font; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.IOException; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class Type1FontTest extends ExtendedITextTest { @Test public void fillUsingEncodingTest() throws IOException { FontEncoding fontEncoding = FontEncoding.createFontEncoding("WinAnsiEncoding"); Type1Font type1StdFont = (Type1Font) FontProgramFactory.createFont("Helvetica", true); - Assert.assertEquals(149, type1StdFont.codeToGlyph.size()); + Assertions.assertEquals(149, type1StdFont.codeToGlyph.size()); type1StdFont.initializeGlyphs(fontEncoding); - Assert.assertEquals(217, type1StdFont.codeToGlyph.size()); - Assert.assertEquals(0x2013, type1StdFont.codeToGlyph.get(150).getUnicode()); - Assert.assertArrayEquals(new char[]{(char)0x2013}, type1StdFont.codeToGlyph.get(150).getChars()); + Assertions.assertEquals(217, type1StdFont.codeToGlyph.size()); + Assertions.assertEquals(0x2013, type1StdFont.codeToGlyph.get(150).getUnicode()); + Assertions.assertArrayEquals(new char[]{(char)0x2013}, type1StdFont.codeToGlyph.get(150).getChars()); } } diff --git a/io/src/test/java/com/itextpdf/io/font/cmap/CMapByteCidTest.java b/io/src/test/java/com/itextpdf/io/font/cmap/CMapByteCidTest.java index 4a0ecc1663..2c86347ffc 100644 --- a/io/src/test/java/com/itextpdf/io/font/cmap/CMapByteCidTest.java +++ b/io/src/test/java/com/itextpdf/io/font/cmap/CMapByteCidTest.java @@ -23,12 +23,11 @@ This file is part of the iText (R) project. package com.itextpdf.io.font.cmap; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class CMapByteCidTest extends ExtendedITextTest { @Test @@ -45,6 +44,6 @@ public void addCharAndDecodeByteCodeTest() { String actual = cMapByteCid.decodeSequence(byteCodeBytes, 0, 2); String expected = new String(new char[]{(char) cid}); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } } diff --git a/io/src/test/java/com/itextpdf/io/font/cmap/CMapCidToCodepointTest.java b/io/src/test/java/com/itextpdf/io/font/cmap/CMapCidToCodepointTest.java index 93d4951230..7c0a97ef3a 100644 --- a/io/src/test/java/com/itextpdf/io/font/cmap/CMapCidToCodepointTest.java +++ b/io/src/test/java/com/itextpdf/io/font/cmap/CMapCidToCodepointTest.java @@ -24,24 +24,23 @@ This file is part of the iText (R) project. import com.itextpdf.io.util.IntHashtable; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class CMapCidToCodepointTest extends ExtendedITextTest { @Test public void addCharAndLookupTest() { CMapCidToCodepoint cidToCode = new CMapCidToCodepoint(); - Assert.assertArrayEquals(new byte[0], cidToCode.lookup(14)); + Assertions.assertArrayEquals(new byte[0], cidToCode.lookup(14)); cidToCode.addChar(new String(new byte[] {32, 17}), new CMapObject(CMapObject.NUMBER, 14)); cidToCode.addChar(new String(new byte[] {32, 19}), new CMapObject(CMapObject.STRING, "some text")); - Assert.assertArrayEquals(new byte[] {32, 17}, cidToCode.lookup(14)); - Assert.assertArrayEquals(new byte[0], cidToCode.lookup(1)); + Assertions.assertArrayEquals(new byte[] {32, 17}, cidToCode.lookup(14)); + Assertions.assertArrayEquals(new byte[0], cidToCode.lookup(1)); } @Test @@ -51,23 +50,23 @@ public void getReverseMapTest() { cidToCode.addChar(new String(new byte[] {32, 18}), new CMapObject(CMapObject.NUMBER, 15)); IntHashtable table = cidToCode.getReversMap(); - Assert.assertEquals(2, table.size()); - Assert.assertEquals(14, table.get(8209)); - Assert.assertEquals(15, table.get(8210)); + Assertions.assertEquals(2, table.size()); + Assertions.assertEquals(14, table.get(8209)); + Assertions.assertEquals(15, table.get(8210)); } @Test public void addAndGetCodeSpaceRangeTest() { CMapCidToCodepoint cidToCode = new CMapCidToCodepoint(); - Assert.assertTrue(cidToCode.getCodeSpaceRanges().isEmpty()); + Assertions.assertTrue(cidToCode.getCodeSpaceRanges().isEmpty()); cidToCode.addCodeSpaceRange(new byte[] {11}, new byte[] {12, 13}); cidToCode.addCodeSpaceRange(null, new byte[] {}); List codeSpaceRanges = cidToCode.getCodeSpaceRanges(); - Assert.assertEquals(4, codeSpaceRanges.size()); - Assert.assertArrayEquals(new byte[] {11}, codeSpaceRanges.get(0)); - Assert.assertArrayEquals(new byte[] {12, 13}, codeSpaceRanges.get(1)); - Assert.assertNull(codeSpaceRanges.get(2)); - Assert.assertArrayEquals(new byte[] {}, codeSpaceRanges.get(3)); + Assertions.assertEquals(4, codeSpaceRanges.size()); + Assertions.assertArrayEquals(new byte[] {11}, codeSpaceRanges.get(0)); + Assertions.assertArrayEquals(new byte[] {12, 13}, codeSpaceRanges.get(1)); + Assertions.assertNull(codeSpaceRanges.get(2)); + Assertions.assertArrayEquals(new byte[] {}, codeSpaceRanges.get(3)); } } diff --git a/io/src/test/java/com/itextpdf/io/font/cmap/CMapCodepointToCidTest.java b/io/src/test/java/com/itextpdf/io/font/cmap/CMapCodepointToCidTest.java index 20e1ac659e..b1c013437a 100644 --- a/io/src/test/java/com/itextpdf/io/font/cmap/CMapCodepointToCidTest.java +++ b/io/src/test/java/com/itextpdf/io/font/cmap/CMapCodepointToCidTest.java @@ -23,13 +23,12 @@ This file is part of the iText (R) project. package com.itextpdf.io.font.cmap; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class CMapCodepointToCidTest extends ExtendedITextTest { @Test public void reverseConstructorTest() { @@ -38,19 +37,19 @@ public void reverseConstructorTest() { cidToCode.addChar(new String(new byte[] {32, 18}), new CMapObject(CMapObject.NUMBER, 15)); CMapCodepointToCid codeToCid = new CMapCodepointToCid(cidToCode); - Assert.assertEquals(14, codeToCid.lookup(8209)); - Assert.assertEquals(15, codeToCid.lookup(8210)); + Assertions.assertEquals(14, codeToCid.lookup(8209)); + Assertions.assertEquals(15, codeToCid.lookup(8210)); } @Test public void addCharAndLookupTest() { CMapCodepointToCid codeToCid = new CMapCodepointToCid(); - Assert.assertEquals(0, codeToCid.lookup(8209)); + Assertions.assertEquals(0, codeToCid.lookup(8209)); codeToCid.addChar(new String(new byte[] {32, 17}), new CMapObject(CMapObject.NUMBER, 14)); codeToCid.addChar(new String(new byte[] {32, 19}), new CMapObject(CMapObject.STRING, "some text")); - Assert.assertEquals(14, codeToCid.lookup(8209)); - Assert.assertEquals(0, codeToCid.lookup(1)); + Assertions.assertEquals(14, codeToCid.lookup(8209)); + Assertions.assertEquals(0, codeToCid.lookup(1)); } } diff --git a/kernel/src/main/java/com/itextpdf/kernel/events/Event.java b/io/src/test/java/com/itextpdf/io/font/cmap/CMapToUnicodeTest.java similarity index 66% rename from kernel/src/main/java/com/itextpdf/kernel/events/Event.java rename to io/src/test/java/com/itextpdf/io/font/cmap/CMapToUnicodeTest.java index 7c0ff141ad..c77a4dec64 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/events/Event.java +++ b/io/src/test/java/com/itextpdf/io/font/cmap/CMapToUnicodeTest.java @@ -20,33 +20,21 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.kernel.events; +package com.itextpdf.io.font.cmap; -/** - * Describes abstract event. - */ -public class Event { - - /** - * A type of event. - */ - protected String type; - - /** - * Creates an event of the specified type. - * - * @param type type of event - */ - public Event(String type) { - this.type = type; - } +import com.itextpdf.test.ExtendedITextTest; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; +import static com.itextpdf.io.font.cmap.CMapToUnicode.EMPTY_CMAP; + +@Tag("UnitTest") +public class CMapToUnicodeTest extends ExtendedITextTest { - /** - * Returns the type of this event. - * - * @return type of this event - */ - public String getType() { - return type; + @Test + public void emptyCmapVarTest() { + Assertions.assertNotNull(EMPTY_CMAP); + Assertions.assertFalse(EMPTY_CMAP.hasByteMappings(), "Cmap has no two byte mappings"); } } diff --git a/io/src/test/java/com/itextpdf/io/font/cmap/StandardCMapCharsetsTest.java b/io/src/test/java/com/itextpdf/io/font/cmap/StandardCMapCharsetsTest.java index 5ecd8c0149..5120720155 100644 --- a/io/src/test/java/com/itextpdf/io/font/cmap/StandardCMapCharsetsTest.java +++ b/io/src/test/java/com/itextpdf/io/font/cmap/StandardCMapCharsetsTest.java @@ -27,13 +27,12 @@ This file is part of the iText (R) project. import com.itextpdf.io.source.ByteBuffer; import com.itextpdf.io.util.TextUtil; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class StandardCMapCharsetsTest extends ExtendedITextTest { private static final String TEST_STRING_WITH_DIFFERENT_UNICODES = "eр؊\u0E84\uA515뀏"; @@ -55,7 +54,7 @@ public void ucs2EncodingStringTest() { byte[] actual = encoder.encodeUnicodeCodePoint(cp); buffer.append(actual); } - Assert.assertArrayEquals(BYTES_REPRESENTATION_OF_TEST_STRING, buffer.toByteArray()); + Assertions.assertArrayEquals(BYTES_REPRESENTATION_OF_TEST_STRING, buffer.toByteArray()); } @Test public void ucs2TryToEncodeSymbolNotFromBmpStringTest() { @@ -64,9 +63,9 @@ public void ucs2TryToEncodeSymbolNotFromBmpStringTest() { // It is U+10437 symbol (Deseret Small Letter Yee) String str = "\uD801\uDC37"; int cp = TextUtil.convertToUtf32(str)[0]; - Exception e = Assert.assertThrows(ITextException.class, () -> + Exception e = Assertions.assertThrows(ITextException.class, () -> encoder.encodeUnicodeCodePoint(cp)); - Assert.assertEquals(IoExceptionMessageConstant.ONLY_BMP_ENCODING, e.getMessage()); + Assertions.assertEquals(IoExceptionMessageConstant.ONLY_BMP_ENCODING, e.getMessage()); } @Test public void ucs2EncodingCodePointTest() { @@ -74,7 +73,7 @@ public void ucs2EncodingCodePointTest() { // U+0E84 (Lao Letter Kho Tam) from BMP int codePoint = 3716; byte[] actual = encoder.encodeUnicodeCodePoint(codePoint); - Assert.assertArrayEquals(new byte[] {14, (byte)0x84}, actual); + Assertions.assertArrayEquals(new byte[] {14, (byte)0x84}, actual); } @Test @@ -85,7 +84,7 @@ public void utf16EncodingStringTest() { byte[] actual = encoder.encodeUnicodeCodePoint(cp); buffer.append(actual); } - Assert.assertArrayEquals(BYTES_REPRESENTATION_OF_TEST_STRING, buffer.toByteArray()); + Assertions.assertArrayEquals(BYTES_REPRESENTATION_OF_TEST_STRING, buffer.toByteArray()); // UTF-16 represents full BMP, so all symbols should be correctly processed } @Test @@ -95,7 +94,7 @@ public void utf16TryToEncodeSymbolNotFromBmpStringTest() { // It is U+10437 symbol (Deseret Small Letter Yee) String str = "\uD801\uDC37"; byte[] actual = encoder.encodeUnicodeCodePoint(TextUtil.convertToUtf32(str)[0]); - Assert.assertArrayEquals(new byte[] {(byte)0xD8, 1, (byte)0xDC, 55}, actual); + Assertions.assertArrayEquals(new byte[] {(byte)0xD8, 1, (byte)0xDC, 55}, actual); } @Test @@ -103,8 +102,8 @@ public void ucs2TryToEncodeSymbolNotFromBmpCodePointTest() { CMapCharsetEncoder encoder = StandardCMapCharsets.getEncoder("UniGB-UCS2-H"); // It is U+10437 symbol (Deseret Small Letter Yee) outside BMP int codePoint = 66615; - Exception e = Assert.assertThrows(ITextException.class, () -> encoder.encodeUnicodeCodePoint(codePoint)); - Assert.assertEquals(IoExceptionMessageConstant.ONLY_BMP_ENCODING, e.getMessage()); + Exception e = Assertions.assertThrows(ITextException.class, () -> encoder.encodeUnicodeCodePoint(codePoint)); + Assertions.assertEquals(IoExceptionMessageConstant.ONLY_BMP_ENCODING, e.getMessage()); } @Test @@ -113,7 +112,7 @@ public void udf16EncodingCodePointTest() { // U+0E84 (Lao Letter Kho Tam) from BMP int codePoint = 3716; byte[] actual = encoder.encodeUnicodeCodePoint(codePoint); - Assert.assertArrayEquals(new byte[] {14, (byte)0x84}, actual); + Assertions.assertArrayEquals(new byte[] {14, (byte)0x84}, actual); } @Test @@ -122,7 +121,7 @@ public void udf16TryToEncodeSymbolNotFromBmpCodePointTest() { // It is U+10437 symbol (Deseret Small Letter Yee) outside BMP int codePoint = 66615; byte[] actual = encoder.encodeUnicodeCodePoint(codePoint); - Assert.assertArrayEquals(new byte[] {(byte)0xD8, 1, (byte)0xDC, 55}, actual); + Assertions.assertArrayEquals(new byte[] {(byte)0xD8, 1, (byte)0xDC, 55}, actual); } @Test @@ -130,7 +129,7 @@ public void charsetEncodersDisabledTest() { try { StandardCMapCharsets.disableCharsetEncoders(); CMapCharsetEncoder encoder = StandardCMapCharsets.getEncoder("UniGB-UTF16-H"); - Assert.assertNull(encoder); + Assertions.assertNull(encoder); } finally { StandardCMapCharsets.enableCharsetEncoders(); } @@ -141,11 +140,11 @@ public void charsetEncodersReEnabledTest() { try { StandardCMapCharsets.disableCharsetEncoders(); CMapCharsetEncoder encoder = StandardCMapCharsets.getEncoder("UniGB-UTF16-H"); - Assert.assertNull(encoder); + Assertions.assertNull(encoder); } finally { StandardCMapCharsets.enableCharsetEncoders(); CMapCharsetEncoder encoder = StandardCMapCharsets.getEncoder("UniGB-UTF16-H"); - Assert.assertNotNull(encoder); + Assertions.assertNotNull(encoder); } } } diff --git a/io/src/test/java/com/itextpdf/io/font/otf/ActualTextIteratorTest.java b/io/src/test/java/com/itextpdf/io/font/otf/ActualTextIteratorTest.java index ab3173991e..f6f4f31338 100644 --- a/io/src/test/java/com/itextpdf/io/font/otf/ActualTextIteratorTest.java +++ b/io/src/test/java/com/itextpdf/io/font/otf/ActualTextIteratorTest.java @@ -22,15 +22,19 @@ This file is part of the iText (R) project. */ package com.itextpdf.io.font.otf; +import com.itextpdf.io.font.otf.GlyphLine.GlyphLinePart; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.Collections; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.util.Arrays; -@Category(UnitTest.class) +@Tag("UnitTest") public class ActualTextIteratorTest extends ExtendedITextTest { @Test @@ -41,7 +45,50 @@ public void testActualTestParts() { ActualTextIterator actualTextIterator = new ActualTextIterator(glyphLine); GlyphLine.GlyphLinePart part = actualTextIterator.next(); // When actual text is the same as the result by text extraction, we should omit redundant actual text in the content stream - Assert.assertNull(part.actualText); + Assertions.assertNull(part.getActualText()); + } + @Test + public void nextCurrentResNullTest() { + Glyph glyph = new Glyph(200, 200, '\u002d'); + GlyphLine glyphLine = new GlyphLine(Arrays.asList(glyph, null, glyph)); + glyphLine.setActualText(0, 1, "\u002d"); + ActualTextIterator actualTextIterator = new ActualTextIterator(glyphLine); + actualTextIterator.next(); + GlyphLinePart secondNext = actualTextIterator.next(); + Assertions.assertNull(secondNext); + } + + @Test + public void nextIterationTest() { + Glyph glyph = new Glyph(200, 200, '\u002d'); + GlyphLine glyphLine = new GlyphLine(Arrays.asList(glyph, glyph, glyph)); + glyphLine.setActualText(0, 1, "\u002d"); + ActualTextIterator actualTextIterator = new ActualTextIterator(glyphLine); + GlyphLinePart next = actualTextIterator.next(); + Assertions.assertEquals(3, next.getEnd()); } + @Test + public void nextWithNegativeEndTest() { + Glyph glyph = new Glyph(200, 200, '\u002d'); + GlyphLine glyphLine = new GlyphLine(Arrays.asList(glyph, glyph, glyph)); + glyphLine.setActualText(0, 1, "\u002d"); + glyphLine.setEnd(-1); + ActualTextIterator actualTextIterator = new ActualTextIterator(glyphLine); + GlyphLinePart next = actualTextIterator.next(); + Assertions.assertNull(next); + } + + @Test + public void nextWithInvalidUnicodeTest() { + Glyph glyph = new Glyph(200, 200, 0); + Glyph glyphinvalid = new Glyph(200, 200, null); + + GlyphLine glyphLine = new GlyphLine(Arrays.asList(glyph, glyphinvalid)); + glyphLine.setActualText(1, 2, "X"); + + ActualTextIterator actualTextIterator = new ActualTextIterator(glyphLine); + GlyphLinePart next = actualTextIterator.next(); + Assertions.assertNull(next.getActualText()); + } } diff --git a/io/src/test/java/com/itextpdf/io/font/otf/GlyphLinePartTest.java b/io/src/test/java/com/itextpdf/io/font/otf/GlyphLinePartTest.java new file mode 100644 index 0000000000..7327422f53 --- /dev/null +++ b/io/src/test/java/com/itextpdf/io/font/otf/GlyphLinePartTest.java @@ -0,0 +1,47 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.io.font.otf; + +import com.itextpdf.io.font.otf.GlyphLine.GlyphLinePart; +import com.itextpdf.test.ExtendedITextTest; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +@Tag("UnitTest") +public class GlyphLinePartTest extends ExtendedITextTest { + + @Test + public void customGlyphLinePartTest() { + GlyphLine.GlyphLinePart part = new GlyphLinePart(0, 4); + part.setStart(1); + part.setEnd(5); + part.setReversed(false); + + Assertions.assertEquals(1, part.getStart()); + Assertions.assertEquals(5, part.getEnd()); + Assertions.assertFalse(part.isReversed()); + } +} + diff --git a/io/src/test/java/com/itextpdf/io/font/otf/GlyphLineTest.java b/io/src/test/java/com/itextpdf/io/font/otf/GlyphLineTest.java index 9230665b6d..e6bce2ba14 100644 --- a/io/src/test/java/com/itextpdf/io/font/otf/GlyphLineTest.java +++ b/io/src/test/java/com/itextpdf/io/font/otf/GlyphLineTest.java @@ -26,19 +26,20 @@ This file is part of the iText (R) project. import com.itextpdf.io.font.TrueTypeFont; import com.itextpdf.io.util.StreamUtil; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class GlyphLineTest extends ExtendedITextTest { + public static final String FREESANS_FONT_PATH = "./src/test/resources/com/itextpdf/io/font/otf/FreeSans.ttf"; + private static List constructGlyphListFromString(String text, TrueTypeFont font) { List glyphList = new ArrayList<>(); char[] chars = text.toCharArray(); @@ -59,62 +60,59 @@ public void testEquals() { one.add(glyph); two.add(glyph); - one.end++; - two.end++; + one.setEnd(one.getEnd() +1); + two.setEnd(two.getEnd() +1); - Assert.assertTrue(one.equals(two)); + Assertions.assertTrue(one.equals(two)); } @Test public void testOtherLinesAddition() throws IOException { - byte[] ttf = StreamUtil.inputStreamToArray(FileUtil.getInputStreamForFile("./src/test/resources/com/itextpdf/io/font/otf/FreeSans.ttf")); - TrueTypeFont font = new TrueTypeFont(ttf); + TrueTypeFont font = initializeFont(); GlyphLine containerLine = new GlyphLine(constructGlyphListFromString("Viva France!", font)); GlyphLine childLine1 = new GlyphLine(constructGlyphListFromString(" Liberte", font)); containerLine.add(childLine1); - Assert.assertEquals(containerLine.end, 12); - containerLine.end = 20; + Assertions.assertEquals(12, containerLine.getEnd()); + containerLine.setEnd(20); GlyphLine childLine2 = new GlyphLine(constructGlyphListFromString(" Egalite", font)); containerLine.add(childLine2); - Assert.assertEquals(containerLine.end, 20); - containerLine.start = 10; + Assertions.assertEquals(20, containerLine.getEnd()); + containerLine.setStart(10); GlyphLine childLine3 = new GlyphLine(constructGlyphListFromString(" Fraternite", font)); containerLine.add(childLine3); - Assert.assertEquals(containerLine.start, 10); - containerLine.start = 0; + Assertions.assertEquals(10, containerLine.getStart()); + containerLine.setStart(0); containerLine.add(constructGlyphListFromString("!", font).get(0)); - containerLine.end = 40; - Assert.assertEquals(containerLine.glyphs.size(), 40); + containerLine.setEnd(40); + Assertions.assertEquals(40, containerLine.glyphs.size()); } @Test public void testAdditionWithActualText() throws IOException { - byte[] ttf = StreamUtil.inputStreamToArray(FileUtil.getInputStreamForFile("./src/test/resources/com/itextpdf/io/font/otf/FreeSans.ttf")); - TrueTypeFont font = new TrueTypeFont(ttf); + TrueTypeFont font = initializeFont(); List glyphs = constructGlyphListFromString("Viva France!", font); GlyphLine containerLine = new GlyphLine(glyphs); - Assert.assertNull(containerLine.actualText); + Assertions.assertNull(containerLine.actualText); containerLine.setActualText(0, 1, "TEST"); - Assert.assertNotNull(containerLine.actualText); - Assert.assertEquals(12, containerLine.actualText.size()); - Assert.assertEquals("TEST", containerLine.actualText.get(0).value); + Assertions.assertNotNull(containerLine.actualText); + Assertions.assertEquals(12, containerLine.actualText.size()); + Assertions.assertEquals("TEST", containerLine.actualText.get(0).getValue()); containerLine.add(new GlyphLine(glyphs)); - Assert.assertEquals(24, containerLine.actualText.size()); + Assertions.assertEquals(24, containerLine.actualText.size()); for (int i = 13; i < 24; i++) { - Assert.assertNull(containerLine.actualText.get(i)); + Assertions.assertNull(containerLine.actualText.get(i)); } } @Test public void testOtherLinesWithActualTextAddition() throws IOException { - byte[] ttf = StreamUtil.inputStreamToArray(FileUtil.getInputStreamForFile("./src/test/resources/com/itextpdf/io/font/otf/FreeSans.ttf")); - TrueTypeFont font = new TrueTypeFont(ttf); + TrueTypeFont font = initializeFont(); GlyphLine containerLine = new GlyphLine(constructGlyphListFromString("France", font)); @@ -122,20 +120,19 @@ public void testOtherLinesWithActualTextAddition() throws IOException { childLine.setActualText(3, 10, "Viva"); containerLine.add(childLine); - containerLine.end = 16; + containerLine.setEnd(16); for (int i = 0; i < 9; i++) { - Assert.assertNull(containerLine.actualText.get(i)); + Assertions.assertNull(containerLine.actualText.get(i)); } for (int i = 9; i < 16; i++) { - Assert.assertEquals("Viva", containerLine.actualText.get(i).value); + Assertions.assertEquals("Viva", containerLine.actualText.get(i).getValue()); } - Assert.assertEquals("France---Viva", containerLine.toString()); + Assertions.assertEquals("France---Viva", containerLine.toString()); } @Test public void testOtherLinesWithActualTextAddition02() throws IOException { - byte[] ttf = StreamUtil.inputStreamToArray(FileUtil.getInputStreamForFile("./src/test/resources/com/itextpdf/io/font/otf/FreeSans.ttf")); - TrueTypeFont font = new TrueTypeFont(ttf); + TrueTypeFont font = initializeFont(); GlyphLine containerLine = new GlyphLine(constructGlyphListFromString("France", font)); containerLine.setActualText(1, 5, "id"); @@ -144,24 +141,23 @@ public void testOtherLinesWithActualTextAddition02() throws IOException { childLine.setActualText(3, 10, "Viva"); containerLine.add(childLine); - containerLine.end = 16; - Assert.assertNull(containerLine.actualText.get(0)); + containerLine.setEnd(16); + Assertions.assertNull(containerLine.actualText.get(0)); for (int i = 1; i < 5; i++) { - Assert.assertEquals("id", containerLine.actualText.get(i).value); + Assertions.assertEquals("id", containerLine.actualText.get(i).getValue()); } for (int i = 5; i < 9; i++) { - Assert.assertNull(containerLine.actualText.get(i)); + Assertions.assertNull(containerLine.actualText.get(i)); } for (int i = 9; i < 16; i++) { - Assert.assertEquals("Viva", containerLine.actualText.get(i).value); + Assertions.assertEquals("Viva", containerLine.actualText.get(i).getValue()); } - Assert.assertEquals("Fide---Viva", containerLine.toString()); + Assertions.assertEquals("Fide---Viva", containerLine.toString()); } @Test public void testContentReplacingWithNullActualText() throws IOException { - byte[] ttf = StreamUtil.inputStreamToArray(FileUtil.getInputStreamForFile("./src/test/resources/com/itextpdf/io/font/otf/FreeSans.ttf")); - TrueTypeFont font = new TrueTypeFont(ttf); + TrueTypeFont font = initializeFont(); GlyphLine lineToBeReplaced = new GlyphLine(constructGlyphListFromString("Byelorussia", font)); lineToBeReplaced.setActualText(1, 2, "e"); @@ -170,7 +166,7 @@ public void testContentReplacingWithNullActualText() throws IOException { lineToBeReplaced.replaceContent(lineToBeCopied); // Test that no exception has been thrown. Also check the content. - Assert.assertEquals("Belarus", lineToBeReplaced.toString()); + Assertions.assertEquals("Belarus", lineToBeReplaced.toString()); } @Test @@ -178,53 +174,258 @@ public void testActualTextForSubstitutedGlyphProcessingInSubstituteOneToMany01() String expectedActualTextForFirstGlyph = "0"; String expectedActualTextForSecondGlyph = "A"; - byte[] ttf = StreamUtil.inputStreamToArray(FileUtil.getInputStreamForFile("./src/test/resources/com/itextpdf/io/font/otf/FreeSans.ttf")); - TrueTypeFont font = new TrueTypeFont(ttf); + TrueTypeFont font = initializeFont(); // no actual text for the second glyph is set - it should be created during substitution GlyphLine line = new GlyphLine(constructGlyphListFromString("AA", font)); line.setActualText(0, 1, expectedActualTextForFirstGlyph); - line.idx = 1; + line.setIdx(1); line.substituteOneToMany(font.getGsubTable(), new int[] {39, 40}); - Assert.assertNotNull(line.actualText); - Assert.assertEquals(3, line.actualText.size()); - Assert.assertSame(line.actualText.get(1), line.actualText.get(2)); - Assert.assertEquals(expectedActualTextForSecondGlyph, line.actualText.get(1).value); + Assertions.assertNotNull(line.actualText); + Assertions.assertEquals(3, line.actualText.size()); + Assertions.assertSame(line.actualText.get(1), line.actualText.get(2)); + Assertions.assertEquals(expectedActualTextForSecondGlyph, line.actualText.get(1).getValue()); // check that it hasn't been corrupted - Assert.assertEquals(expectedActualTextForFirstGlyph, line.actualText.get(0).value); + Assertions.assertEquals(expectedActualTextForFirstGlyph, line.actualText.get(0).getValue()); } @Test public void testActualTextForSubstitutedGlyphProcessingInSubstituteOneToMany02() throws IOException { String expectedActualTextForFirstGlyph = "A"; - byte[] ttf = StreamUtil.inputStreamToArray(FileUtil.getInputStreamForFile("./src/test/resources/com/itextpdf/io/font/otf/FreeSans.ttf")); - TrueTypeFont font = new TrueTypeFont(ttf); + TrueTypeFont font = initializeFont(); GlyphLine line = new GlyphLine(constructGlyphListFromString("A", font)); line.setActualText(0, 1, expectedActualTextForFirstGlyph); line.substituteOneToMany(font.getGsubTable(), new int[] {39, 40}); - Assert.assertNotNull(line.actualText); - Assert.assertEquals(2, line.actualText.size()); - Assert.assertSame(line.actualText.get(0), line.actualText.get(1)); - Assert.assertEquals(expectedActualTextForFirstGlyph, line.actualText.get(0).value); + Assertions.assertNotNull(line.actualText); + Assertions.assertEquals(2, line.actualText.size()); + Assertions.assertSame(line.actualText.get(0), line.actualText.get(1)); + Assertions.assertEquals(expectedActualTextForFirstGlyph, line.actualText.get(0).getValue()); } @Test public void testActualTextForSubstitutedGlyphProcessingInSubstituteOneToMany03() throws IOException { - byte[] ttf = StreamUtil.inputStreamToArray(FileUtil.getInputStreamForFile("./src/test/resources/com/itextpdf/io/font/otf/FreeSans.ttf")); - TrueTypeFont font = new TrueTypeFont(ttf); + TrueTypeFont font = initializeFont(); // no actual text is set GlyphLine line = new GlyphLine(constructGlyphListFromString("A", font)); line.substituteOneToMany(font.getGsubTable(), new int[] {39, 40}); - Assert.assertNull(line.actualText); + Assertions.assertNull(line.actualText); + } + + @Test + public void defaultConstructorTest() { + GlyphLine glyphLine = new GlyphLine(); + Assertions.assertEquals(0, glyphLine.getStart()); + Assertions.assertEquals(0, glyphLine.getEnd()); + Assertions.assertEquals(0, glyphLine.getIdx()); + } + + @Test + public void otherConstructorTest() throws IOException { + TrueTypeFont font = initializeFont(); + + GlyphLine otherLine = new GlyphLine(constructGlyphListFromString("A test otherLine", font)); + GlyphLine glyphLine = new GlyphLine(otherLine); + + Assertions.assertEquals(0, glyphLine.getStart()); + Assertions.assertEquals(16, glyphLine.getEnd()); + Assertions.assertEquals(0, glyphLine.getIdx()); + Assertions.assertEquals("A test otherLine", glyphLine.toString()); + } + + @Test + public void startEndConstructorTest() throws IOException { + TrueTypeFont font = initializeFont(); + + GlyphLine otherLine = new GlyphLine(constructGlyphListFromString("A test otherLine", font)); + GlyphLine glyphLine = new GlyphLine(otherLine, 2, 16); + + Assertions.assertEquals(0, glyphLine.getStart()); + Assertions.assertEquals(14, glyphLine.getEnd()); + Assertions.assertEquals(-2, glyphLine.getIdx()); + Assertions.assertEquals("test otherLine", glyphLine.toString()); + } + + @Test + public void startEndAndActualTextTest() throws IOException { + TrueTypeFont font = initializeFont(); + + GlyphLine glyphLine = new GlyphLine(constructGlyphListFromString("XXX otherLine", font)); + glyphLine.setActualText(0, 3, "txt"); + + GlyphLine other = new GlyphLine(glyphLine, 0, 13); + + Assertions.assertEquals("txt otherLine", other.toString()); + } + + @Test + public void copyGlyphLineTest() throws IOException { + TrueTypeFont font = initializeFont(); + + GlyphLine glyphLine = new GlyphLine(constructGlyphListFromString("A test otherLine", font)); + GlyphLine copyLine = glyphLine.copy(2, 6); + + Assertions.assertEquals(0, copyLine.getStart()); + Assertions.assertEquals(4, copyLine.getEnd()); + Assertions.assertEquals(0, copyLine.getIdx()); + Assertions.assertEquals("test", copyLine.toString()); + } + + @Test + public void copyWithActualTextGlyphLineTest() throws IOException { + TrueTypeFont font = initializeFont(); + + GlyphLine glyphLine = new GlyphLine(constructGlyphListFromString("XXX otherLine", font)); + glyphLine.setActualText(0, 3, "txt"); + GlyphLine copyLine = glyphLine.copy(0, 3); + + Assertions.assertEquals(0, copyLine.getStart()); + Assertions.assertEquals(3, copyLine.getEnd()); + Assertions.assertEquals(0, copyLine.getIdx()); + Assertions.assertEquals("txt", copyLine.toString()); + } + + @Test + public void addIndexedGlyphLineTest() throws IOException { + TrueTypeFont font = initializeFont(); + + GlyphLine glyphLine = new GlyphLine(constructGlyphListFromString("A test otherLine", font)); + Glyph glyph = new Glyph(200, 200, 200); + glyphLine.add(0, glyph); + + Assertions.assertEquals(0, glyphLine.getStart()); + Assertions.assertEquals(16, glyphLine.getEnd()); + Assertions.assertEquals(0, glyphLine.getIdx()); + Assertions.assertEquals("ÈA test otherLin", glyphLine.toString()); + } + + @Test + public void addIndexedGlyphLineActualTextTest() throws IOException { + TrueTypeFont font = initializeFont(); + + GlyphLine glyphLine = new GlyphLine(constructGlyphListFromString("XXX otherLine", font)); + glyphLine.setActualText(0, 3, "txt"); + Glyph glyph = new Glyph(200, 200, 200); + glyphLine.add(0, glyph); + + Assertions.assertEquals(0, glyphLine.getStart()); + Assertions.assertEquals(13, glyphLine.getEnd()); + Assertions.assertEquals(0, glyphLine.getIdx()); + Assertions.assertEquals("Ètxt otherLin", glyphLine.toString()); + } + + @Test + public void replaceGlyphInLineTest() throws IOException { + TrueTypeFont font = initializeFont(); + + GlyphLine glyphLine = new GlyphLine(constructGlyphListFromString("A test otherLine", font)); + Glyph glyph = new Glyph(200, 200, 200); + glyphLine.set(0, glyph); + + Assertions.assertEquals(0, glyphLine.getStart()); + Assertions.assertEquals(16, glyphLine.getEnd()); + Assertions.assertEquals(0, glyphLine.getIdx()); + Assertions.assertEquals("È test otherLine", glyphLine.toString()); + } + + @Test + public void replaceGlyphLineNoActualTextTest() throws IOException { + TrueTypeFont font = initializeFont(); + + GlyphLine glyphLine = new GlyphLine(constructGlyphListFromString("A test otherLine", font)); + + GlyphLine replaceLine = new GlyphLine(constructGlyphListFromString("different text", font)); + replaceLine.setActualText(0, 14, "different text"); + glyphLine.replaceContent(replaceLine); + + Assertions.assertEquals(0, glyphLine.getStart()); + Assertions.assertEquals(14, glyphLine.getEnd()); + Assertions.assertEquals(0, glyphLine.getIdx()); + Assertions.assertEquals("different text", glyphLine.toString()); + } + + @Test + public void replaceGlyphLineWithActualTextTest() throws IOException { + TrueTypeFont font = initializeFont(); + + GlyphLine glyphLine = new GlyphLine(constructGlyphListFromString("A test otherLine", font)); + glyphLine.setActualText(0, 14, "A test otherLine"); + + GlyphLine replaceLine = new GlyphLine(constructGlyphListFromString("different text", font)); + replaceLine.setActualText(0, 14, "different text"); + glyphLine.replaceContent(replaceLine); + + Assertions.assertEquals(0, glyphLine.getStart()); + Assertions.assertEquals(14, glyphLine.getEnd()); + Assertions.assertEquals(0, glyphLine.getIdx()); + Assertions.assertEquals("different text", glyphLine.toString()); + } + + @Test + public void nullEqualsTest() throws IOException { + TrueTypeFont font = initializeFont(); + + GlyphLine glyphLine = new GlyphLine(constructGlyphListFromString("A test otherLine", font)); + boolean equals = glyphLine.equals(null); + Assertions.assertFalse(equals); + } + + @Test + public void equalsItselfTest() throws IOException { + TrueTypeFont font = initializeFont(); + + GlyphLine glyphLine = new GlyphLine(constructGlyphListFromString("A test otherLine", font)); + boolean equals = glyphLine.equals(glyphLine); + Assertions.assertTrue(equals); + } + + + @Test + public void equalGlyphLinesTest() throws IOException { + TrueTypeFont font = initializeFont(); + + GlyphLine first = new GlyphLine(constructGlyphListFromString("A test otherLine", font)); + first.setActualText(0, 14, "A test otherLine"); + GlyphLine second = new GlyphLine(constructGlyphListFromString("A test otherLine", font)); + second.setActualText(0, 14, "A test otherLine"); + boolean equals = first.equals(second); + Assertions.assertTrue(equals); + } + + @Test + public void diffStartEndEqualsTest() throws IOException { + TrueTypeFont font = initializeFont(); + + GlyphLine first = new GlyphLine(constructGlyphListFromString("A test otherLine", font)); + GlyphLine second = new GlyphLine(constructGlyphListFromString("A test otherLine", font)); + second.setEnd(3); + second.setStart(1); + boolean equals = first.equals(second); + Assertions.assertFalse(equals); + } + + @Test + public void diffActualTextEqualsTest() throws IOException { + TrueTypeFont font = initializeFont(); + + GlyphLine first = new GlyphLine(constructGlyphListFromString("A test otherLine", font)); + first.setActualText(0, 3, "txt"); + GlyphLine second = new GlyphLine(constructGlyphListFromString("A test otherLine", font)); + boolean equals = first.equals(second); + Assertions.assertFalse(equals); + } + + private TrueTypeFont initializeFont() throws IOException { + byte[] ttf = StreamUtil.inputStreamToArray(FileUtil.getInputStreamForFile(FREESANS_FONT_PATH)); + return new TrueTypeFont(ttf); } } diff --git a/io/src/test/java/com/itextpdf/io/font/otf/GlyphTest.java b/io/src/test/java/com/itextpdf/io/font/otf/GlyphTest.java index 5c28157898..6cd0f6dd7e 100644 --- a/io/src/test/java/com/itextpdf/io/font/otf/GlyphTest.java +++ b/io/src/test/java/com/itextpdf/io/font/otf/GlyphTest.java @@ -23,42 +23,41 @@ This file is part of the iText (R) project. package com.itextpdf.io.font.otf; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.IOException; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class GlyphTest extends ExtendedITextTest { @Test public void hasPlacementIfAnchorDeltaNonZeroTest() { Glyph glyph = createDummyGlyph(); - Assert.assertEquals(0, glyph.getXPlacement()); - Assert.assertEquals(0, glyph.getYPlacement()); - Assert.assertEquals(0, glyph.getAnchorDelta()); - Assert.assertFalse(glyph.hasPlacement()); + Assertions.assertEquals(0, glyph.getXPlacement()); + Assertions.assertEquals(0, glyph.getYPlacement()); + Assertions.assertEquals(0, glyph.getAnchorDelta()); + Assertions.assertFalse(glyph.hasPlacement()); glyph.setAnchorDelta((short) 10); - Assert.assertTrue(glyph.hasPlacement()); + Assertions.assertTrue(glyph.hasPlacement()); } @Test public void hasOffsetsIfAnchorDeltaNonZeroTest() { Glyph glyph = createDummyGlyph(); - Assert.assertEquals(0, glyph.getXPlacement()); - Assert.assertEquals(0, glyph.getYPlacement()); - Assert.assertEquals(0, glyph.getAnchorDelta()); - Assert.assertFalse(glyph.hasOffsets()); + Assertions.assertEquals(0, glyph.getXPlacement()); + Assertions.assertEquals(0, glyph.getYPlacement()); + Assertions.assertEquals(0, glyph.getAnchorDelta()); + Assertions.assertFalse(glyph.hasOffsets()); glyph.setAnchorDelta((short) 10); - Assert.assertTrue(glyph.hasOffsets()); + Assertions.assertTrue(glyph.hasOffsets()); } private static Glyph createDummyGlyph() { diff --git a/io/src/test/java/com/itextpdf/io/font/otf/GposLookupType1Test.java b/io/src/test/java/com/itextpdf/io/font/otf/GposLookupType1Test.java index a9c4733370..0eaf08af4a 100644 --- a/io/src/test/java/com/itextpdf/io/font/otf/GposLookupType1Test.java +++ b/io/src/test/java/com/itextpdf/io/font/otf/GposLookupType1Test.java @@ -25,16 +25,15 @@ This file is part of the iText (R) project. import com.itextpdf.io.font.FontProgramFactory; import com.itextpdf.io.font.TrueTypeFont; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; import java.util.Arrays; import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class GposLookupType1Test extends ExtendedITextTest { private static final String RESOURCE_FOLDER = "./src/test/resources/com/itextpdf/io/font/otf/GposLookupType1Test/"; @@ -47,13 +46,13 @@ public void verifyXAdvanceIsAppliedSubFormat1() throws IOException { new Glyph(fontProgram.getGlyphByCode(5))); GlyphLine gl = new GlyphLine(glyphs); - gl.idx = 0; + gl.setIdx(0); - Assert.assertEquals(0, gl.get(0).getXAdvance()); + Assertions.assertEquals(0, gl.get(0).getXAdvance()); - Assert.assertTrue(lookup.transformOne(gl)); + Assertions.assertTrue(lookup.transformOne(gl)); - Assert.assertEquals(219, gl.get(0).getXAdvance()); + Assertions.assertEquals(219, gl.get(0).getXAdvance()); } @Test @@ -65,13 +64,13 @@ public void verifyPositionIsNotAppliedForIrrelevantGlyphSubFormat1() throws IOEx new Glyph(fontProgram.getGlyphByCode(174))); GlyphLine gl = new GlyphLine(glyphs); - gl.idx = 0; + gl.setIdx(0); - Assert.assertEquals(0, gl.get(0).getXAdvance()); + Assertions.assertEquals(0, gl.get(0).getXAdvance()); - Assert.assertFalse(lookup.transformOne(gl)); + Assertions.assertFalse(lookup.transformOne(gl)); - Assert.assertEquals(0, gl.get(0).getXAdvance()); + Assertions.assertEquals(0, gl.get(0).getXAdvance()); } @Test @@ -83,18 +82,18 @@ public void verifyDifferentXAdvanceIsAppliedSubFormat2() throws IOException { List glyphs = Arrays.asList(new Glyph(fontProgram.getGlyphByCode(401)), new Glyph(fontProgram.getGlyphByCode(5))); GlyphLine gl = new GlyphLine(glyphs); - Assert.assertEquals(0, gl.get(0).getXAdvance()); - Assert.assertTrue(lookup.transformOne(gl)); - Assert.assertEquals(109, gl.get(0).getXAdvance()); + Assertions.assertEquals(0, gl.get(0).getXAdvance()); + Assertions.assertTrue(lookup.transformOne(gl)); + Assertions.assertEquals(109, gl.get(0).getXAdvance()); // Subtable type 2 defines different GposValueRecords for different coverage glyphs glyphs = Arrays.asList(new Glyph(fontProgram.getGlyphByCode(508)), new Glyph(fontProgram.getGlyphByCode(5))); gl = new GlyphLine(glyphs); - Assert.assertEquals(0, gl.get(0).getXAdvance()); - Assert.assertTrue(lookup.transformOne(gl)); - Assert.assertEquals(158, gl.get(0).getXAdvance()); + Assertions.assertEquals(0, gl.get(0).getXAdvance()); + Assertions.assertTrue(lookup.transformOne(gl)); + Assertions.assertEquals(158, gl.get(0).getXAdvance()); } } diff --git a/io/src/test/java/com/itextpdf/io/font/otf/GposLookupType2Test.java b/io/src/test/java/com/itextpdf/io/font/otf/GposLookupType2Test.java new file mode 100644 index 0000000000..dba855bc36 --- /dev/null +++ b/io/src/test/java/com/itextpdf/io/font/otf/GposLookupType2Test.java @@ -0,0 +1,72 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.io.font.otf; + +import com.itextpdf.io.font.TrueTypeFont; +import com.itextpdf.test.ExtendedITextTest; + +import java.io.IOException; +import java.util.Arrays; +import java.util.List; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +@Tag("IntegrationTest") +public class GposLookupType2Test extends ExtendedITextTest { + private static final String RESOURCE_FOLDER = "./src/test/resources/com/itextpdf/io/font/otf/GposLookupType2Test/"; + private static final String DEJAVU_FONT_PATH = RESOURCE_FOLDER + "DejaVuSans.ttf"; + @Test + public void idxEqualToEndLineGpos2Test() throws IOException { + TrueTypeFont font = new TrueTypeFont(DEJAVU_FONT_PATH); + + GlyphPositioningTableReader gposTableReader = font.getGposTable(); + GposLookupType2 lookup = (GposLookupType2) gposTableReader.getLookupTable(15); + + + List glyphs = Arrays.asList(new Glyph(font.getGlyphByCode(174)), + new Glyph(font.getGlyphByCode(5))); + GlyphLine gl = new GlyphLine(glyphs); + gl.setIdx(2); + + boolean transform = lookup.transformOne(gl); + Assertions.assertFalse(transform); + } + + @Test + public void idxSmallerThanEndLineGpos2Test() throws IOException { + TrueTypeFont font = new TrueTypeFont(DEJAVU_FONT_PATH); + + GlyphPositioningTableReader gposTableReader = font.getGposTable(); + GposLookupType2 lookup = (GposLookupType2) gposTableReader.getLookupTable(15); + + + List glyphs = Arrays.asList(new Glyph(font.getGlyphByCode(174)), + new Glyph(font.getGlyphByCode(5))); + GlyphLine gl = new GlyphLine(glyphs); + gl.setIdx(0); + + boolean transform = lookup.transformOne(gl); + Assertions.assertFalse(transform); + } +} diff --git a/io/src/test/java/com/itextpdf/io/font/otf/GposLookupType4Test.java b/io/src/test/java/com/itextpdf/io/font/otf/GposLookupType4Test.java index 03e18440d2..68c610dcf6 100644 --- a/io/src/test/java/com/itextpdf/io/font/otf/GposLookupType4Test.java +++ b/io/src/test/java/com/itextpdf/io/font/otf/GposLookupType4Test.java @@ -25,16 +25,15 @@ This file is part of the iText (R) project. import com.itextpdf.io.font.FontProgramFactory; import com.itextpdf.io.font.TrueTypeFont; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; import java.util.Arrays; import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class GposLookupType4Test extends ExtendedITextTest { private static final String RESOURCE_FOLDER = "./src/test/resources/com/itextpdf/io/font/otf/GposLookupType4Test/"; @@ -47,14 +46,14 @@ public void verifyMarkToBaseAttachment() throws IOException { List glyphs = Arrays.asList(new Glyph(fontProgram.getGlyphByCode(163)), new Glyph(fontProgram.getGlyphByCode(207)), new Glyph(fontProgram.getGlyphByCode(213))); GlyphLine gl = new GlyphLine(glyphs); - gl.idx = 2; + gl.setIdx(2); - Assert.assertEquals(0, gl.get(2).getXPlacement()); - Assert.assertEquals(0, gl.get(2).getAnchorDelta()); + Assertions.assertEquals(0, gl.get(2).getXPlacement()); + Assertions.assertEquals(0, gl.get(2).getAnchorDelta()); lookup.transformOne(gl); - Assert.assertEquals(364, gl.get(2).getXPlacement()); - Assert.assertEquals(-2, gl.get(2).getAnchorDelta()); + Assertions.assertEquals(364, gl.get(2).getXPlacement()); + Assertions.assertEquals(-2, gl.get(2).getAnchorDelta()); } } diff --git a/io/src/test/java/com/itextpdf/io/font/otf/GposLookupType5Test.java b/io/src/test/java/com/itextpdf/io/font/otf/GposLookupType5Test.java index 78158e01e9..93d35900f6 100644 --- a/io/src/test/java/com/itextpdf/io/font/otf/GposLookupType5Test.java +++ b/io/src/test/java/com/itextpdf/io/font/otf/GposLookupType5Test.java @@ -25,16 +25,16 @@ This file is part of the iText (R) project. import com.itextpdf.io.font.FontProgramFactory; import com.itextpdf.io.font.TrueTypeFont; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; import java.util.Arrays; +import java.util.Collections; import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class GposLookupType5Test extends ExtendedITextTest { private static final String RESOURCE_FOLDER = "./src/test/resources/com/itextpdf/io/font/otf/GposLookupType5Test/"; @@ -46,14 +46,14 @@ public void verifyMarkToBaseAttachment() throws IOException { GposLookupType5 lookup = (GposLookupType5) gposTableReader.getLookupTable(0); List glyphs = Arrays.asList(new Glyph(fontProgram.getGlyphByCode(445)), new Glyph(fontProgram.getGlyphByCode(394))); GlyphLine gl = new GlyphLine(glyphs); - gl.idx = 1; + gl.setIdx(1); lookup.transformOne(gl); - Assert.assertEquals(2, gl.size()); - Assert.assertEquals(445, gl.get(0).getCode()); - Assert.assertEquals(394, gl.get(1).getCode()); - Assert.assertEquals(-1, gl.get(1).getAnchorDelta()); - Assert.assertEquals(756, gl.get(1).getXPlacement()); + Assertions.assertEquals(2, gl.size()); + Assertions.assertEquals(445, gl.get(0).getCode()); + Assertions.assertEquals(394, gl.get(1).getCode()); + Assertions.assertEquals(-1, gl.get(1).getAnchorDelta()); + Assertions.assertEquals(756, gl.get(1).getXPlacement()); } @Test @@ -66,14 +66,14 @@ public void testSelectingCorrectAttachmentAlternative() throws IOException { GlyphPositioningTableReader gposTableReader = fontProgram.getGposTable(); GposLookupType5 lookup = (GposLookupType5) gposTableReader.getLookupTable(3); - glyphLine.idx = 1; + glyphLine.setIdx(1); lookup.transformOne(glyphLine); - Assert.assertEquals(2, glyphLine.size()); - Assert.assertEquals(513, glyphLine.get(0).getCode()); - Assert.assertEquals(75, glyphLine.get(1).getCode()); - Assert.assertEquals(-1, glyphLine.get(1).getAnchorDelta()); - Assert.assertEquals(-22, glyphLine.get(1).getXPlacement()); + Assertions.assertEquals(2, glyphLine.size()); + Assertions.assertEquals(513, glyphLine.get(0).getCode()); + Assertions.assertEquals(75, glyphLine.get(1).getCode()); + Assertions.assertEquals(-1, glyphLine.get(1).getAnchorDelta()); + Assertions.assertEquals(-22, glyphLine.get(1).getXPlacement()); } @Test @@ -83,14 +83,25 @@ public void testThatNoTransformationsAppliedForNonRelevantGlyphs() throws IOExce GlyphPositioningTableReader gposTableReader = fontProgram.getGposTable(); GposLookupType5 lookup = (GposLookupType5) gposTableReader.getLookupTable(3); - glyphLine.idx = 1; + glyphLine.setIdx(1); lookup.transformOne(glyphLine); - Assert.assertEquals(2, glyphLine.size()); - Assert.assertEquals(1490, glyphLine.get(0).getCode()); - Assert.assertEquals(75, glyphLine.get(1).getCode()); - Assert.assertEquals(0, glyphLine.get(1).getAnchorDelta()); - Assert.assertEquals(0, glyphLine.get(1).getXPlacement()); + Assertions.assertEquals(2, glyphLine.size()); + Assertions.assertEquals(1490, glyphLine.get(0).getCode()); + Assertions.assertEquals(75, glyphLine.get(1).getCode()); + Assertions.assertEquals(0, glyphLine.get(1).getAnchorDelta()); + Assertions.assertEquals(0, glyphLine.get(1).getXPlacement()); } + @Test + public void idxBiggerThanLineEndTest() throws IOException { + TrueTypeFont fontProgram = (TrueTypeFont)FontProgramFactory.createFont(RESOURCE_FOLDER + "NotoNaskhArabic-Regular.ttf"); + GlyphLine glyphLine = new GlyphLine(Collections.singletonList(fontProgram.getGlyph(203))); + GlyphPositioningTableReader gposTableReader = fontProgram.getGposTable(); + GposLookupType5 lookup = (GposLookupType5) gposTableReader.getLookupTable(3); + + glyphLine.setIdx(10); + + Assertions.assertFalse(lookup.transformOne(glyphLine)); + } } diff --git a/io/src/test/java/com/itextpdf/io/font/otf/GposLookupType6Test.java b/io/src/test/java/com/itextpdf/io/font/otf/GposLookupType6Test.java new file mode 100644 index 0000000000..bf6d108517 --- /dev/null +++ b/io/src/test/java/com/itextpdf/io/font/otf/GposLookupType6Test.java @@ -0,0 +1,72 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.io.font.otf; + +import com.itextpdf.io.font.FontProgramFactory; +import com.itextpdf.io.font.TrueTypeFont; +import com.itextpdf.test.ExtendedITextTest; + +import java.io.IOException; +import java.util.Arrays; +import java.util.List; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +@Tag("IntegrationTest") +public class GposLookupType6Test extends ExtendedITextTest { + + private static final String RESOURCE_FOLDER = "./src/test/resources/com/itextpdf/io/font/otf/"; + + private static final String FREE_SANS_FONT_PATH = RESOURCE_FOLDER + "FreeSans.ttf"; + + @Test + public void idxEqualToEndLineGpos6Test() throws IOException { + TrueTypeFont fontProgram = (TrueTypeFont) FontProgramFactory.createFont(FREE_SANS_FONT_PATH); + GlyphPositioningTableReader gposTableReader = fontProgram.getGposTable(); + GposLookupType6 lookup = new GposLookupType6(gposTableReader, 0, new int[0]); + List glyphs = Arrays.asList(new Glyph(fontProgram.getGlyphByCode(445)), + new Glyph(fontProgram.getGlyphByCode(394))); + GlyphLine gl = new GlyphLine(glyphs); + gl.setIdx(2); + boolean transform = lookup.transformOne(gl); + Assertions.assertFalse(transform); + } + + @Test + public void idxSmallerThanEndLineGpos6Test() throws IOException { + TrueTypeFont font = new TrueTypeFont(FREE_SANS_FONT_PATH); + + GlyphPositioningTableReader gposTableReader = font.getGposTable(); + GposLookupType6 lookup = new GposLookupType6(gposTableReader, 0, new int[0]); + + + List glyphs = Arrays.asList(new Glyph(font.getGlyphByCode(174)), + new Glyph(font.getGlyphByCode(5))); + GlyphLine gl = new GlyphLine(glyphs); + gl.setIdx(0); + + boolean transform = lookup.transformOne(gl); + Assertions.assertFalse(transform); + } +} diff --git a/io/src/test/java/com/itextpdf/io/font/otf/GposLookupType7Test.java b/io/src/test/java/com/itextpdf/io/font/otf/GposLookupType7Test.java index e81eb2483c..3d6413e0bd 100644 --- a/io/src/test/java/com/itextpdf/io/font/otf/GposLookupType7Test.java +++ b/io/src/test/java/com/itextpdf/io/font/otf/GposLookupType7Test.java @@ -25,16 +25,15 @@ This file is part of the iText (R) project. import com.itextpdf.io.font.FontProgramFactory; import com.itextpdf.io.font.TrueTypeFont; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; import java.util.Arrays; import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class GposLookupType7Test extends ExtendedITextTest { private static final String RESOURCE_FOLDER = "./src/test/resources/com/itextpdf/io/font/otf/GposLookupType7Test/"; @@ -48,9 +47,9 @@ public void verifyXAdvanceIsAppliedForContextualPositioning() throws IOException GlyphLine gl = new GlyphLine(glyphs); - Assert.assertEquals(0, gl.get(1).getXAdvance()); - Assert.assertTrue(lookup.transformLine(gl)); - Assert.assertEquals(219, gl.get(1).getXAdvance()); + Assertions.assertEquals(0, gl.get(1).getXAdvance()); + Assertions.assertTrue(lookup.transformLine(gl)); + Assertions.assertEquals(219, gl.get(1).getXAdvance()); } @Test @@ -63,10 +62,10 @@ public void verifyXAdvanceIsNotAppliedForUnsatisfiedContextualPositioning() thro GlyphLine gl = new GlyphLine(glyphs); - Assert.assertFalse(lookup.transformLine(gl)); + Assertions.assertFalse(lookup.transformLine(gl)); for (int i = 0; i < gl.size(); i++) { - Assert.assertEquals(0, gl.get(i).getXAdvance()); - Assert.assertEquals(0, gl.get(i).getYAdvance()); + Assertions.assertEquals(0, gl.get(i).getXAdvance()); + Assertions.assertEquals(0, gl.get(i).getYAdvance()); } } diff --git a/io/src/test/java/com/itextpdf/io/font/otf/GposLookupType8Test.java b/io/src/test/java/com/itextpdf/io/font/otf/GposLookupType8Test.java index 483906e4da..034b6867f5 100644 --- a/io/src/test/java/com/itextpdf/io/font/otf/GposLookupType8Test.java +++ b/io/src/test/java/com/itextpdf/io/font/otf/GposLookupType8Test.java @@ -25,16 +25,15 @@ This file is part of the iText (R) project. import com.itextpdf.io.font.FontProgramFactory; import com.itextpdf.io.font.TrueTypeFont; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; import java.util.Arrays; import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class GposLookupType8Test extends ExtendedITextTest { private static final String RESOURCE_FOLDER = "./src/test/resources/com/itextpdf/io/font/otf/GposLookupType8Test/"; @@ -50,9 +49,9 @@ public void verifyXAdvanceIsAppliedForContextualPositioning() throws IOException GposLookupType8 lookup = (GposLookupType8) gposTableReader.getLookupTable(92); - Assert.assertEquals(0, gl.get(2).getXAdvance()); - Assert.assertTrue(lookup.transformLine(gl)); - Assert.assertEquals(28, gl.get(2).getXAdvance()); + Assertions.assertEquals(0, gl.get(2).getXAdvance()); + Assertions.assertTrue(lookup.transformLine(gl)); + Assertions.assertEquals(28, gl.get(2).getXAdvance()); } @Test @@ -73,9 +72,9 @@ public void verifyXAdvanceIsAppliedForPosTableLookup8Format2() throws IOExceptio GposLookupType8 lookup = (GposLookupType8) gposTableReader.getLookupTable(0); - Assert.assertEquals(0, gl.get(1).getXAdvance()); - Assert.assertTrue(lookup.transformLine(gl)); - Assert.assertEquals(134, gl.get(1).getXAdvance()); + Assertions.assertEquals(0, gl.get(1).getXAdvance()); + Assertions.assertTrue(lookup.transformLine(gl)); + Assertions.assertEquals(134, gl.get(1).getXAdvance()); } @Test @@ -89,10 +88,10 @@ public void verifyXAdvanceIsNotAppliedForUnsatisfiedContextualPositioning() thro GposLookupType8 lookup = (GposLookupType8) gposTableReader.getLookupTable(92); - Assert.assertFalse(lookup.transformLine(gl)); + Assertions.assertFalse(lookup.transformLine(gl)); for (int i = 0; i < gl.size(); i++) { - Assert.assertEquals(0, gl.get(i).getXAdvance()); - Assert.assertEquals(0, gl.get(i).getYAdvance()); + Assertions.assertEquals(0, gl.get(i).getXAdvance()); + Assertions.assertEquals(0, gl.get(i).getYAdvance()); } } diff --git a/io/src/test/java/com/itextpdf/io/font/otf/GsubLookupType4Test.java b/io/src/test/java/com/itextpdf/io/font/otf/GsubLookupType4Test.java index a0a6c35790..b2a01cb719 100644 --- a/io/src/test/java/com/itextpdf/io/font/otf/GsubLookupType4Test.java +++ b/io/src/test/java/com/itextpdf/io/font/otf/GsubLookupType4Test.java @@ -25,16 +25,15 @@ This file is part of the iText (R) project. import com.itextpdf.io.font.FontProgramFactory; import com.itextpdf.io.font.TrueTypeFont; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; import java.util.Arrays; import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class GsubLookupType4Test extends ExtendedITextTest { private static final String RESOURCE_FOLDER = "./src/test/resources/com/itextpdf/io/font/otf/GsubLookupType4Test/"; @@ -52,11 +51,30 @@ public void testNoIndexOutOfBound() throws IOException { new Glyph(1, 1, 1)); GlyphLine gl = new GlyphLine(glyphs); - gl.idx = gl.end; + gl.setIdx(gl.getEnd()); GsubLookupType4 lookup = (GsubLookupType4) gsubTableReader.getLookupTable(6); //Assert that no exception is thrown if gl.idx = gl.end - Assert.assertFalse(lookup.transformOne(gl)); + Assertions.assertFalse(lookup.transformOne(gl)); + } + + @Test + public void noTransformationTest() throws IOException { + TrueTypeFont fontProgram = (TrueTypeFont) FontProgramFactory.createFont(RESOURCE_FOLDER + "DejaVuSansMono.ttf"); + GlyphSubstitutionTableReader gsubTableReader = fontProgram.getGsubTable(); + + List glyphs = Arrays.asList(new Glyph(1, 1, 1), + new Glyph(1, 1, 1), + new Glyph(1, 1, 1), + new Glyph(1, 1, 1), + new Glyph(1, 1, 1), + new Glyph(1, 1, 1)); + + GlyphLine gl = new GlyphLine(glyphs); + gl.setIdx(3); + + GsubLookupType4 lookup = (GsubLookupType4) gsubTableReader.getLookupTable(6); + Assertions.assertFalse(lookup.transformOne(gl)); } } diff --git a/io/src/test/java/com/itextpdf/io/font/otf/GsubLookupType6Test.java b/io/src/test/java/com/itextpdf/io/font/otf/GsubLookupType6Test.java index 3e2a3765f5..bbf3984e84 100644 --- a/io/src/test/java/com/itextpdf/io/font/otf/GsubLookupType6Test.java +++ b/io/src/test/java/com/itextpdf/io/font/otf/GsubLookupType6Test.java @@ -25,16 +25,15 @@ This file is part of the iText (R) project. import com.itextpdf.io.font.FontProgramFactory; import com.itextpdf.io.font.TrueTypeFont; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; import java.util.Arrays; import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class GsubLookupType6Test extends ExtendedITextTest { private static final String RESOURCE_FOLDER = "./src/test/resources/com/itextpdf/io/font/otf/GsubLookupType6Test/"; @@ -54,9 +53,9 @@ public void testSubstitutionApplied() throws IOException { GsubLookupType6 lookup = (GsubLookupType6) gsubTableReader.getLookupTable(57); - Assert.assertEquals(233, gl.get(0).getCode()); - Assert.assertTrue(lookup.transformLine(gl)); - Assert.assertEquals(234, gl.get(0).getCode()); + Assertions.assertEquals(233, gl.get(0).getCode()); + Assertions.assertTrue(lookup.transformLine(gl)); + Assertions.assertEquals(234, gl.get(0).getCode()); } @Test @@ -74,9 +73,9 @@ public void testSubstitutionNotApplied() throws IOException { GsubLookupType6 lookup = (GsubLookupType6) gsubTableReader.getLookupTable(54); - Assert.assertEquals(233, gl.get(0).getCode()); - Assert.assertFalse(lookup.transformLine(gl)); - Assert.assertEquals(233, gl.get(0).getCode()); + Assertions.assertEquals(233, gl.get(0).getCode()); + Assertions.assertFalse(lookup.transformLine(gl)); + Assertions.assertEquals(233, gl.get(0).getCode()); } diff --git a/io/src/test/java/com/itextpdf/io/font/otf/LanguageRecordTest.java b/io/src/test/java/com/itextpdf/io/font/otf/LanguageRecordTest.java new file mode 100644 index 0000000000..e9b1cade4f --- /dev/null +++ b/io/src/test/java/com/itextpdf/io/font/otf/LanguageRecordTest.java @@ -0,0 +1,59 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.io.font.otf; + +import com.itextpdf.test.ExtendedITextTest; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +@Tag("UnitTest") +public class LanguageRecordTest extends ExtendedITextTest { + + @Test + public void featuresRequiredTest() { + LanguageRecord languageRecord = new LanguageRecord(); + languageRecord.setFeatureRequired(1); + + Assertions.assertEquals(1, languageRecord.getFeatureRequired()); + } + + @Test + public void taggingTest() { + LanguageRecord languageRecord = new LanguageRecord(); + languageRecord.setTag("tagname"); + + Assertions.assertEquals("tagname", languageRecord.getTag()); + } + + @Test + public void featuresTest() { + LanguageRecord languageRecord = new LanguageRecord(); + int[] features = new int[2]; + languageRecord.setFeatures(features); + + Assertions.assertEquals(2, languageRecord.getFeatures().length); + } +} + diff --git a/io/src/test/java/com/itextpdf/io/font/otf/OpenTableLookupTest.java b/io/src/test/java/com/itextpdf/io/font/otf/OpenTableLookupTest.java new file mode 100644 index 0000000000..0b804f24c6 --- /dev/null +++ b/io/src/test/java/com/itextpdf/io/font/otf/OpenTableLookupTest.java @@ -0,0 +1,69 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.io.font.otf; + +import com.itextpdf.io.font.otf.OpenTableLookup.GlyphIndexer; +import com.itextpdf.test.ExtendedITextTest; + +import java.util.Collections; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +@Tag("UnitTest") +public class OpenTableLookupTest extends ExtendedITextTest { + + @Test + public void idxTest() { + GlyphIndexer glyphIndexer = new GlyphIndexer(); + glyphIndexer.setIdx(2); + + Assertions.assertEquals(2, glyphIndexer.getIdx()); + } + + @Test + public void glyphTest() { + Glyph glyph = new Glyph(200, 200, 200); + + GlyphIndexer glyphIndexer = new GlyphIndexer(); + glyphIndexer.setGlyph(glyph); + + Assertions.assertEquals(200, glyphIndexer.getGlyph().getWidth()); + Assertions.assertEquals(200, glyphIndexer.getGlyph().getCode()); + Assertions.assertEquals(200, glyphIndexer.getGlyph().getUnicode()); + } + + @Test + public void glyphLineTest() { + Glyph glyph = new Glyph(200, 200, 200); + GlyphLine glyphLine = new GlyphLine(Collections.singletonList(glyph)); + + GlyphIndexer glyphIndexer = new GlyphIndexer(); + glyphIndexer.setLine(glyphLine); + + Assertions.assertEquals(0, glyphIndexer.getLine().getIdx()); + Assertions.assertEquals(0, glyphIndexer.getLine().getStart()); + Assertions.assertEquals(1, glyphIndexer.getLine().getEnd()); + } +} + diff --git a/io/src/test/java/com/itextpdf/io/font/otf/OpenTypeFontTableReaderTest.java b/io/src/test/java/com/itextpdf/io/font/otf/OpenTypeFontTableReaderTest.java index 4dd842c966..8db0f675f4 100644 --- a/io/src/test/java/com/itextpdf/io/font/otf/OpenTypeFontTableReaderTest.java +++ b/io/src/test/java/com/itextpdf/io/font/otf/OpenTypeFontTableReaderTest.java @@ -25,57 +25,158 @@ This file is part of the iText (R) project. import com.itextpdf.io.font.FontProgramFactory; import com.itextpdf.io.font.TrueTypeFont; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; +import java.util.ArrayList; import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; -@Category(UnitTest.class) +@Tag("UnitTest") public class OpenTypeFontTableReaderTest extends ExtendedITextTest { private static final String RESOURCE_FOLDER = "./src/test/resources/com/itextpdf/io/font/otf/OpenTypeFontTableReaderTest/"; + private static final String FONTS_FOLDER = "./src/test/resources/com/itextpdf/io/font/sharedFontsResourceFiles/"; + + + + private static final String CJK_JP_BOLD_PATH = FONTS_FOLDER + "NotoSansCJKjp-Bold.otf"; + + private static final String SANS_MYANMAR_REGULAR_PATH = RESOURCE_FOLDER + "NotoSansMyanmar-Regular.ttf"; + + @Test public void testFetchLangSysByTag() throws IOException { - TrueTypeFont fontProgram = (TrueTypeFont) FontProgramFactory.createFont(RESOURCE_FOLDER + "NotoSansMyanmar-Regular.ttf"); + TrueTypeFont fontProgram = (TrueTypeFont) FontProgramFactory.createFont(SANS_MYANMAR_REGULAR_PATH); GlyphSubstitutionTableReader gsub = fontProgram.getGsubTable(); ScriptRecord mym2 = gsub.getScriptRecords().get(0); - Assert.assertEquals("mym2", mym2.tag); + Assertions.assertEquals("mym2", mym2.getTag()); // default LangSys has no tag - Assert.assertEquals("", gsub.getLanguageRecord("mym2").tag); - Assert.assertEquals(LanguageTags.SGAW_KAREN, gsub.getLanguageRecord("mym2", LanguageTags.SGAW_KAREN).tag); - Assert.assertEquals(LanguageTags.MON, gsub.getLanguageRecord("mym2", LanguageTags.MON).tag); + Assertions.assertEquals("", gsub.getLanguageRecord("mym2").getTag()); + Assertions.assertEquals(LanguageTags.SGAW_KAREN, gsub.getLanguageRecord("mym2", LanguageTags.SGAW_KAREN).getTag()); + Assertions.assertEquals(LanguageTags.MON, gsub.getLanguageRecord("mym2", LanguageTags.MON).getTag()); - Assert.assertNull(gsub.getLanguageRecord(null)); - Assert.assertNull(gsub.getLanguageRecord("mym3")); - Assert.assertNull(gsub.getLanguageRecord("mym3", LanguageTags.SGAW_KAREN)); + Assertions.assertNull(gsub.getLanguageRecord(null)); + Assertions.assertNull(gsub.getLanguageRecord("mym3")); + Assertions.assertNull(gsub.getLanguageRecord("mym3", LanguageTags.SGAW_KAREN)); } @Test public void testGetLookupsArray() throws IOException { - TrueTypeFont fontProgram = (TrueTypeFont) FontProgramFactory.createFont(RESOURCE_FOLDER + "NotoSansMyanmar-Regular.ttf"); + TrueTypeFont fontProgram = (TrueTypeFont) FontProgramFactory.createFont(SANS_MYANMAR_REGULAR_PATH); GlyphSubstitutionTableReader gsub = fontProgram.getGsubTable(); FeatureRecord firstRecord = new FeatureRecord(); - firstRecord.lookups = new int[]{5, 2}; - firstRecord.tag = "1"; + firstRecord.setLookups(new int[]{5, 2}); + firstRecord.setTag("1"); FeatureRecord secondRecord = new FeatureRecord(); - secondRecord.lookups = new int[]{4, 10}; - secondRecord.tag = "2"; + secondRecord.setLookups(new int[]{4, 10}); + secondRecord.setTag("2"); FeatureRecord[] records = new FeatureRecord[]{firstRecord, secondRecord}; int[] lookupsLocations = gsub.getLookups(firstRecord).stream().mapToInt(record -> record.subTableLocations[0]).toArray(); int[] expected = new int[]{142610, 142436}; - Assert.assertArrayEquals(expected, lookupsLocations); + Assertions.assertArrayEquals(expected, lookupsLocations); lookupsLocations = gsub.getLookups(records).stream().mapToInt(record -> record.subTableLocations[0]).toArray(); expected = new int[]{142436, 142538, 142610, 143908}; - Assert.assertArrayEquals(expected, lookupsLocations); + Assertions.assertArrayEquals(expected, lookupsLocations); + } + + @Test + public void getNegativeIdxTest() throws IOException { + GlyphPositioningTableReader gposTableReader = getGPosTableReader(SANS_MYANMAR_REGULAR_PATH); + GposLookupType1 lookup = (GposLookupType1) gposTableReader.getLookupTable(-1); + Assertions.assertNull(lookup); + } + + @Test + public void getFeatureRecordsTest() throws IOException { + GlyphPositioningTableReader gposTableReader = getGPosTableReader(SANS_MYANMAR_REGULAR_PATH); + List lookup = gposTableReader.getFeatureRecords(); + Assertions.assertEquals(3, lookup.size()); + } + + @Test + public void getFeaturesNullTest() throws IOException { + GlyphPositioningTableReader gposTableReader = getGPosTableReader(SANS_MYANMAR_REGULAR_PATH); + String[] scripts = new String[0]; + List lookup = gposTableReader.getFeatures(scripts, "null"); + Assertions.assertNull(lookup); + } + + @Test + public void getRequiredFeaturesNullTest() throws IOException { + GlyphPositioningTableReader gposTableReader = getGPosTableReader(SANS_MYANMAR_REGULAR_PATH); + String[] scripts = new String[1]; + scripts[0] = "test"; + FeatureRecord requiredFeature = gposTableReader.getRequiredFeature(scripts, "null"); + Assertions.assertNull(requiredFeature); + } + + @Test + public void defaultLangTest() throws IOException { + GlyphPositioningTableReader gposTableReader = getGPosTableReader(CJK_JP_BOLD_PATH); + String[] scripts = new String[7]; + scripts[0] = "DFLT"; + + List featureRecords = gposTableReader.getFeatures(scripts, ""); + + Assertions.assertEquals(8, featureRecords.size()); + } + + @Test + public void nullStringArrayScriptsTest() throws IOException { + GlyphPositioningTableReader gposTableReader = getGPosTableReader(CJK_JP_BOLD_PATH); + String[] scripts = new String[7]; + List featureRecords = gposTableReader.getFeatures(scripts, ""); + + Assertions.assertEquals(8, featureRecords.size()); + } + + @Test + public void nonDefTest() throws IOException { + GlyphPositioningTableReader gposTableReader = getGPosTableReader(SANS_MYANMAR_REGULAR_PATH); + String[] scripts = new String[7]; + scripts[2] = "DFLT"; + List featureRecords = gposTableReader.getFeatures(scripts, ""); + + Assertions.assertEquals(3, featureRecords.size()); + } + + @Test + public void testFetchLangSysByTag2() throws IOException { + TrueTypeFont fontProgram = (TrueTypeFont) FontProgramFactory.createFont(SANS_MYANMAR_REGULAR_PATH); + GlyphSubstitutionTableReader gsub = fontProgram.getGsubTable(); + Assertions.assertNull(gsub.getLanguageRecord("mym2", LanguageTags.ARABIC)); + } + + @Test + public void specificEqualsNullTest() throws IOException { + GlyphPositioningTableReader gPosTableReader = getGPosTableReader(CJK_JP_BOLD_PATH); + List test = new ArrayList<>(); + test.add(new FeatureRecord()); + List specificFeatures = gPosTableReader.getSpecificFeatures(test, null); + Assertions.assertEquals(test, specificFeatures); + } + + @Test + public void specificFeaturesTest() throws IOException { + GlyphPositioningTableReader gPosTableReader = getGPosTableReader(CJK_JP_BOLD_PATH); + String[] specific = new String[1]; + List test = new ArrayList<>(); + test.add(new FeatureRecord()); + List specificFeatures = gPosTableReader.getSpecificFeatures(test, specific); + Assertions.assertEquals(test, specificFeatures); + } + + private GlyphPositioningTableReader getGPosTableReader(String fontPath) throws IOException { + TrueTypeFont fontProgram = (TrueTypeFont) FontProgramFactory.createFont(fontPath); + return fontProgram.getGposTable(); } } diff --git a/io/src/test/java/com/itextpdf/io/font/otf/OpenTypeGdefTableReaderTest.java b/io/src/test/java/com/itextpdf/io/font/otf/OpenTypeGdefTableReaderTest.java index 8d9cf2f9c1..d13626a8ad 100644 --- a/io/src/test/java/com/itextpdf/io/font/otf/OpenTypeGdefTableReaderTest.java +++ b/io/src/test/java/com/itextpdf/io/font/otf/OpenTypeGdefTableReaderTest.java @@ -25,14 +25,13 @@ This file is part of the iText (R) project. import com.itextpdf.io.font.FontProgramFactory; import com.itextpdf.io.font.TrueTypeFont; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class OpenTypeGdefTableReaderTest extends ExtendedITextTest { private static final String RESOURCE_FOLDER = "./src/test/resources/com/itextpdf/io/font/otf/OpenTypeGdefTableReaderTest/"; @@ -42,8 +41,8 @@ public void testLookupFlagWithMarkAttachmentTypeAndMarkGlyphWithoutMarkAttachmen TrueTypeFont fontProgram = (TrueTypeFont)FontProgramFactory.createFont(RESOURCE_FOLDER + fontName); OpenTypeGdefTableReader gdef = fontProgram.getGdefTable(); int glyphCode = 207; - Assert.assertEquals(OtfClass.GLYPH_MARK, gdef.getGlyphClassTable().getOtfClass(glyphCode)); - Assert.assertTrue(gdef.isSkip(glyphCode, (1 << 8) | OpenTypeGdefTableReader.FLAG_IGNORE_BASE)); + Assertions.assertEquals(OtfClass.GLYPH_MARK, gdef.getGlyphClassTable().getOtfClass(glyphCode)); + Assertions.assertTrue(gdef.isSkip(glyphCode, (1 << 8) | OpenTypeGdefTableReader.FLAG_IGNORE_BASE)); } @Test @@ -52,8 +51,8 @@ public void testLookupFlagWithMarkAttachmentTypeAndMarkGlyphWithSameMarkAttachme TrueTypeFont fontProgram = (TrueTypeFont)FontProgramFactory.createFont(RESOURCE_FOLDER + fontName); OpenTypeGdefTableReader gdef = fontProgram.getGdefTable(); int glyphCode = 151; - Assert.assertEquals(OtfClass.GLYPH_MARK, gdef.getGlyphClassTable().getOtfClass(glyphCode)); - Assert.assertFalse(gdef.isSkip(glyphCode, (1 << 8) | OpenTypeGdefTableReader.FLAG_IGNORE_BASE)); + Assertions.assertEquals(OtfClass.GLYPH_MARK, gdef.getGlyphClassTable().getOtfClass(glyphCode)); + Assertions.assertFalse(gdef.isSkip(glyphCode, (1 << 8) | OpenTypeGdefTableReader.FLAG_IGNORE_BASE)); } @Test @@ -62,8 +61,8 @@ public void testLookupFlagWithMarkAttachmentTypeAndBaseGlyph() throws IOExceptio TrueTypeFont fontProgram = (TrueTypeFont)FontProgramFactory.createFont(RESOURCE_FOLDER + fontName); OpenTypeGdefTableReader gdef = fontProgram.getGdefTable(); int glyphCode = 165; - Assert.assertEquals(OtfClass.GLYPH_BASE, gdef.getGlyphClassTable().getOtfClass(glyphCode)); - Assert.assertFalse(gdef.isSkip(glyphCode, (1 << 8))); + Assertions.assertEquals(OtfClass.GLYPH_BASE, gdef.getGlyphClassTable().getOtfClass(glyphCode)); + Assertions.assertFalse(gdef.isSkip(glyphCode, (1 << 8))); } } diff --git a/io/src/test/java/com/itextpdf/io/font/otf/OtfReadCommonTest.java b/io/src/test/java/com/itextpdf/io/font/otf/OtfReadCommonTest.java index f558bbff4d..601aee020b 100644 --- a/io/src/test/java/com/itextpdf/io/font/otf/OtfReadCommonTest.java +++ b/io/src/test/java/com/itextpdf/io/font/otf/OtfReadCommonTest.java @@ -28,17 +28,16 @@ This file is part of the iText (R) project. import com.itextpdf.io.source.RandomAccessFileOrArray; import com.itextpdf.io.source.RandomAccessSourceFactory; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.util.Map; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; import java.util.List; -@Category(UnitTest.class) +@Tag("UnitTest") public class OtfReadCommonTest extends ExtendedITextTest { private static final String RESOURCE_FOLDER = "./src/test/resources/com/itextpdf/io/font/otf/OtfReadCommonTest/"; @@ -54,12 +53,12 @@ public void testReadCoverageFormat1() throws IOException { RandomAccessFileOrArray rf = new RandomAccessFileOrArray( new RandomAccessSourceFactory().createBestSource(path)); List glyphIds = OtfReadCommon.readCoverageFormat(rf, 0); - Assert.assertEquals(5, glyphIds.size()); - Assert.assertEquals(0x38, (int) glyphIds.get(0)); - Assert.assertEquals(0x3B, (int) glyphIds.get(1)); - Assert.assertEquals(0x41, (int) glyphIds.get(2)); - Assert.assertEquals(0x1042, (int) glyphIds.get(3)); - Assert.assertEquals(0xA04A, (int) glyphIds.get(4)); + Assertions.assertEquals(5, glyphIds.size()); + Assertions.assertEquals(0x38, (int) glyphIds.get(0)); + Assertions.assertEquals(0x3B, (int) glyphIds.get(1)); + Assertions.assertEquals(0x41, (int) glyphIds.get(2)); + Assertions.assertEquals(0x1042, (int) glyphIds.get(3)); + Assertions.assertEquals(0xA04A, (int) glyphIds.get(4)); } @Test @@ -71,9 +70,9 @@ public void testReadCoverageFormat2() throws IOException { RandomAccessFileOrArray rf = new RandomAccessFileOrArray( new RandomAccessSourceFactory().createBestSource(path)); List glyphIds = OtfReadCommon.readCoverageFormat(rf, 0); - Assert.assertEquals(10, glyphIds.size()); - Assert.assertEquals(0xA04E, (int) glyphIds.get(0)); - Assert.assertEquals(0xA057, (int) glyphIds.get(9)); + Assertions.assertEquals(10, glyphIds.size()); + Assertions.assertEquals(0xA04E, (int) glyphIds.get(0)); + Assertions.assertEquals(0xA057, (int) glyphIds.get(9)); } @Test @@ -82,10 +81,10 @@ public void testConversionGlyphToTextSpace() throws IOException { null, null, 1); // at 15 we fill up all values GposValueRecord valueRecord = OtfReadCommon.readGposValueRecord(gposTableReader, 15); - Assert.assertEquals(2000,valueRecord.XAdvance); - Assert.assertEquals(2000,valueRecord.XPlacement); - Assert.assertEquals(2000,valueRecord.YAdvance); - Assert.assertEquals(2000,valueRecord.YPlacement); + Assertions.assertEquals(2000,valueRecord.getXAdvance()); + Assertions.assertEquals(2000,valueRecord.getXPlacement()); + Assertions.assertEquals(2000,valueRecord.getYAdvance()); + Assertions.assertEquals(2000,valueRecord.getYPlacement()); } class OpenTypeFontTableReaderTest extends OpenTypeFontTableReader { diff --git a/io/src/test/java/com/itextpdf/io/font/woff2/SimpleWoff2DecodeTest.java b/io/src/test/java/com/itextpdf/io/font/woff2/SimpleWoff2DecodeTest.java index 18c6567524..2a6f83e351 100644 --- a/io/src/test/java/com/itextpdf/io/font/woff2/SimpleWoff2DecodeTest.java +++ b/io/src/test/java/com/itextpdf/io/font/woff2/SimpleWoff2DecodeTest.java @@ -22,8 +22,8 @@ This file is part of the iText (R) project. */ package com.itextpdf.io.font.woff2; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import java.io.IOException; @@ -32,7 +32,7 @@ public class SimpleWoff2DecodeTest extends Woff2DecodeTest { private static final String sourceFolder = "./src/test/resources/com/itextpdf/io/font/woff2/SimpleWoff2Decode/"; private static final String targetFolder = "./target/test/com/itextpdf/io/font/woff2/SimpleWoff2Decode/"; - @BeforeClass + @BeforeAll public static void setUp() { if (DEBUG) { createOrClearDestinationFolder(targetFolder); diff --git a/io/src/test/java/com/itextpdf/io/font/woff2/Woff2DecodeTest.java b/io/src/test/java/com/itextpdf/io/font/woff2/Woff2DecodeTest.java index 8795eb2933..d1309d0880 100644 --- a/io/src/test/java/com/itextpdf/io/font/woff2/Woff2DecodeTest.java +++ b/io/src/test/java/com/itextpdf/io/font/woff2/Woff2DecodeTest.java @@ -25,15 +25,14 @@ This file is part of the iText (R) project. import com.itextpdf.commons.utils.FileUtil; import com.itextpdf.io.exceptions.FontCompressionException; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; -@Category(UnitTest.class) +@Tag("UnitTest") public abstract class Woff2DecodeTest extends ExtendedITextTest { protected static boolean DEBUG = true; @@ -51,12 +50,12 @@ protected final void runTest(String fileName, String sourceFolder, String target try { in = readFile(sourceFolder + inFile); if (isFontValid) { - Assert.assertTrue(Woff2Converter.isWoff2Font(in)); + Assertions.assertTrue(Woff2Converter.isWoff2Font(in)); } out = Woff2Converter.convert(in); cmp = readFile(sourceFolder + cmpFile); - Assert.assertTrue("Only valid fonts should reach this", isFontValid); - Assert.assertArrayEquals(cmp, out); + Assertions.assertTrue(isFontValid, "Only valid fonts should reach this"); + Assertions.assertArrayEquals(cmp, out); } catch (FontCompressionException e) { if (isFontValid) { throw e; diff --git a/io/src/test/java/com/itextpdf/io/font/woff2/w3c/W3CWoff2DecodeTest.java b/io/src/test/java/com/itextpdf/io/font/woff2/w3c/W3CWoff2DecodeTest.java index 9c4dd2a29f..3439053f05 100644 --- a/io/src/test/java/com/itextpdf/io/font/woff2/w3c/W3CWoff2DecodeTest.java +++ b/io/src/test/java/com/itextpdf/io/font/woff2/w3c/W3CWoff2DecodeTest.java @@ -23,8 +23,8 @@ This file is part of the iText (R) project. package com.itextpdf.io.font.woff2.w3c; import com.itextpdf.io.font.woff2.Woff2DecodeTest; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.File; import java.io.IOException; @@ -39,7 +39,7 @@ public abstract class W3CWoff2DecodeTest extends Woff2DecodeTest{ protected abstract boolean isFontValid(); - @Before + @BeforeEach public void setUp() { if (isDebug()) { createOrClearDestinationFolder(getDestinationFolder()); diff --git a/io/src/test/java/com/itextpdf/io/font/woff2/w3c/decoder/ValidationOff012Test.java b/io/src/test/java/com/itextpdf/io/font/woff2/w3c/decoder/ValidationOff012Test.java index 1b1bea19e9..5c450ae912 100644 --- a/io/src/test/java/com/itextpdf/io/font/woff2/w3c/decoder/ValidationOff012Test.java +++ b/io/src/test/java/com/itextpdf/io/font/woff2/w3c/decoder/ValidationOff012Test.java @@ -23,7 +23,6 @@ This file is part of the iText (R) project. package com.itextpdf.io.font.woff2.w3c.decoder; import com.itextpdf.io.font.woff2.w3c.W3CWoff2DecodeTest; -import org.junit.Ignore; public class ValidationOff012Test extends W3CWoff2DecodeTest { @Override diff --git a/io/src/test/java/com/itextpdf/io/image/BmpTest.java b/io/src/test/java/com/itextpdf/io/image/BmpTest.java index 843fd04a47..3b66799ca5 100644 --- a/io/src/test/java/com/itextpdf/io/image/BmpTest.java +++ b/io/src/test/java/com/itextpdf/io/image/BmpTest.java @@ -26,15 +26,14 @@ This file is part of the iText (R) project. import com.itextpdf.io.util.StreamUtil; import com.itextpdf.io.util.UrlUtil; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.IOException; import java.io.InputStream; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class BmpTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/io/image/"; @@ -42,18 +41,18 @@ public class BmpTest extends ExtendedITextTest { @Test public void openBmp1() throws IOException { ImageData img = ImageDataFactory.create(sourceFolder + "WP_20140410_001.bmp"); - Assert.assertEquals(2592, img.getWidth(), 0); - Assert.assertEquals(1456, img.getHeight(), 0); - Assert.assertEquals(8, img.getBpc()); + Assertions.assertEquals(2592, img.getWidth(), 0); + Assertions.assertEquals(1456, img.getHeight(), 0); + Assertions.assertEquals(8, img.getBpc()); } @Test public void openBmp2() throws IOException { // Test this a more specific entry point ImageData img = ImageDataFactory.createBmp(UrlUtil.toURL(sourceFolder + "WP_20140410_001_gray.bmp"), false); - Assert.assertEquals(2592, img.getWidth(), 0); - Assert.assertEquals(1456, img.getHeight(), 0); - Assert.assertEquals(8, img.getBpc()); + Assertions.assertEquals(2592, img.getWidth(), 0); + Assertions.assertEquals(1456, img.getHeight(), 0); + Assertions.assertEquals(8, img.getBpc()); } @Test @@ -63,9 +62,9 @@ public void openBmp3() throws IOException { byte[] imageBytes = StreamUtil.inputStreamToArray(fis); // Test this a more specific entry point ImageData img = ImageDataFactory.createBmp(imageBytes, false); - Assert.assertEquals(2592, img.getWidth(), 0); - Assert.assertEquals(1456, img.getHeight(), 0); - Assert.assertEquals(1, img.getBpc()); + Assertions.assertEquals(2592, img.getWidth(), 0); + Assertions.assertEquals(1456, img.getHeight(), 0); + Assertions.assertEquals(1, img.getBpc()); } } } diff --git a/io/src/test/java/com/itextpdf/io/image/GifTest.java b/io/src/test/java/com/itextpdf/io/image/GifTest.java index 741b5d3c3b..b8370307fb 100644 --- a/io/src/test/java/com/itextpdf/io/image/GifTest.java +++ b/io/src/test/java/com/itextpdf/io/image/GifTest.java @@ -29,15 +29,14 @@ This file is part of the iText (R) project. import com.itextpdf.io.util.StreamUtil; import com.itextpdf.io.util.UrlUtil; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.InputStream; import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class GifTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/io/image/GifTest/"; @@ -46,16 +45,16 @@ public void gifImageTest() throws IOException, java.io.IOException { try (InputStream file = FileUtil.getInputStreamForFile(sourceFolder + "WP_20140410_001.gif")) { byte[] fileContent = StreamUtil.inputStreamToArray(file); ImageData img = ImageDataFactory.createGif(fileContent).getFrames().get(0); - Assert.assertTrue(img.isRawImage()); - Assert.assertEquals(ImageType.GIF, img.getOriginalType()); + Assertions.assertTrue(img.isRawImage()); + Assertions.assertEquals(ImageType.GIF, img.getOriginalType()); } } @Test public void gifImageFrameOutOfBoundsTest() throws java.io.IOException { - Exception e = Assert.assertThrows(IOException.class, + Exception e = Assertions.assertThrows(IOException.class, () -> ImageDataFactory.createGifFrame(UrlUtil.toURL(sourceFolder + "image-2frames.gif"), 3)); - Assert.assertEquals(MessageFormatUtil.format(IoExceptionMessageConstant.CANNOT_FIND_FRAME, 2), e.getMessage()); + Assertions.assertEquals(MessageFormatUtil.format(IoExceptionMessageConstant.CANNOT_FIND_FRAME, 2), e.getMessage()); } @Test @@ -64,11 +63,11 @@ public void gifImageSpecificFrameTest() throws IOException, java.io.IOException try (InputStream file = FileUtil.getInputStreamForFile(imageFilePath)) { byte[] fileContent = StreamUtil.inputStreamToArray(file); ImageData img = ImageDataFactory.createGifFrame(fileContent, 2); - Assert.assertEquals(100, (int)img.getWidth()); - Assert.assertEquals(100, (int)img.getHeight()); + Assertions.assertEquals(100, (int)img.getWidth()); + Assertions.assertEquals(100, (int)img.getHeight()); ImageData imgFromUrl = ImageDataFactory.createGifFrame(UrlUtil.toURL(imageFilePath), 2); - Assert.assertArrayEquals(img.getData(), imgFromUrl.getData()); + Assertions.assertArrayEquals(img.getData(), imgFromUrl.getData()); } } @@ -78,12 +77,12 @@ public void gifImageReadingAllFramesTest() throws IOException, java.io.IOExcepti try (InputStream file = FileUtil.getInputStreamForFile(imageFilePath)) { byte[] fileContent = StreamUtil.inputStreamToArray(file); List frames = ImageDataFactory.createGifFrames(fileContent); - Assert.assertEquals(2, frames.size()); - Assert.assertNotEquals(frames.get(0).getData(), frames.get(1).getData()); + Assertions.assertEquals(2, frames.size()); + Assertions.assertNotEquals(frames.get(0).getData(), frames.get(1).getData()); List framesFromUrl = ImageDataFactory.createGifFrames(UrlUtil.toURL(imageFilePath)); - Assert.assertArrayEquals(frames.get(0).getData(), framesFromUrl.get(0).getData()); - Assert.assertArrayEquals(frames.get(1).getData(), framesFromUrl.get(1).getData()); + Assertions.assertArrayEquals(frames.get(0).getData(), framesFromUrl.get(0).getData()); + Assertions.assertArrayEquals(frames.get(1).getData(), framesFromUrl.get(1).getData()); } } } diff --git a/io/src/test/java/com/itextpdf/io/image/ImageDataFactoryTest.java b/io/src/test/java/com/itextpdf/io/image/ImageDataFactoryTest.java index b7e3f32a44..003d5f2f51 100644 --- a/io/src/test/java/com/itextpdf/io/image/ImageDataFactoryTest.java +++ b/io/src/test/java/com/itextpdf/io/image/ImageDataFactoryTest.java @@ -25,16 +25,15 @@ This file is part of the iText (R) project. import com.itextpdf.io.util.StreamUtil; import com.itextpdf.io.util.UrlUtil; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.IOException; import java.io.InputStream; import java.net.URL; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class ImageDataFactoryTest extends ExtendedITextTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/io/image/ImageDataFactoryTest/"; @@ -45,7 +44,7 @@ public void testGetColorEncodingComponentsNumber() { byte data[] = new byte[1]; ImageData raw = ImageDataFactory.create(1, 1, 1, 8, data, null); - Assert.assertEquals(1, raw.getColorEncodingComponentsNumber()); + Assertions.assertEquals(1, raw.getColorEncodingComponentsNumber()); } @Test @@ -54,7 +53,7 @@ public void testSetColorEncodingComponentsNumber() { ImageData raw = ImageDataFactory.create(1, 1, 1, 8, data, null); raw.setColorEncodingComponentsNumber(3); - Assert.assertEquals(3, raw.getColorEncodingComponentsNumber()); + Assertions.assertEquals(3, raw.getColorEncodingComponentsNumber()); } @Test @@ -62,7 +61,7 @@ public void testGetColorEncodingComponentsNumberCCITT() { byte data[] = new byte[1]; ImageData raw = ImageDataFactory.create(1, 1, false, 0x100, 1, data, null); - Assert.assertEquals(1, raw.getColorEncodingComponentsNumber()); + Assertions.assertEquals(1, raw.getColorEncodingComponentsNumber()); } @Test @@ -87,13 +86,13 @@ public void testImageTypeSupportTiffFile() throws IOException { @Test public void testImageTypeSupportWmfType() { - Assert.assertFalse(ImageDataFactory.isSupportedType(ImageType.WMF)); + Assertions.assertFalse(ImageDataFactory.isSupportedType(ImageType.WMF)); } private void testImageTypeSupport(URL location, boolean expectedResult) throws IOException { - Assert.assertEquals(expectedResult, ImageDataFactory.isSupportedType(location)); + Assertions.assertEquals(expectedResult, ImageDataFactory.isSupportedType(location)); try (InputStream inputStream = UrlUtil.openStream(location)) { - Assert.assertEquals(expectedResult, ImageDataFactory.isSupportedType(StreamUtil.inputStreamToArray(inputStream))); + Assertions.assertEquals(expectedResult, ImageDataFactory.isSupportedType(StreamUtil.inputStreamToArray(inputStream))); } } diff --git a/io/src/test/java/com/itextpdf/io/image/ImageTypeDetectorTest.java b/io/src/test/java/com/itextpdf/io/image/ImageTypeDetectorTest.java index 7aa1ac85d6..ea61b77b23 100644 --- a/io/src/test/java/com/itextpdf/io/image/ImageTypeDetectorTest.java +++ b/io/src/test/java/com/itextpdf/io/image/ImageTypeDetectorTest.java @@ -26,17 +26,16 @@ This file is part of the iText (R) project. import com.itextpdf.io.util.StreamUtil; import com.itextpdf.io.util.UrlUtil; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.IOException; import java.io.InputStream; import java.net.MalformedURLException; import java.net.URL; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class ImageTypeDetectorTest extends ExtendedITextTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/io/image/ImageTypeDetectorTest/"; @@ -71,7 +70,7 @@ public void testUrlWmf() throws MalformedURLException { public void testNullUrl() throws MalformedURLException { URL url = UrlUtil.toURL("not existing path"); - Assert.assertThrows(com.itextpdf.io.exceptions.IOException.class, + Assertions.assertThrows(com.itextpdf.io.exceptions.IOException.class, () -> ImageTypeDetector.detectImageType(url) ); } @@ -108,7 +107,7 @@ public void testStreamClosed() throws IOException { // A common exception is expected instead of com.itextpdf.io.exceptions.IOException, because in .NET // the thrown exception is different - Assert.assertThrows(Exception.class, () -> ImageTypeDetector.detectImageType(stream)); + Assertions.assertThrows(Exception.class, () -> ImageTypeDetector.detectImageType(stream)); } @Test @@ -142,14 +141,14 @@ public void testBytesWmf() throws IOException { } private static void testURL(URL location, ImageType expectedType) { - Assert.assertEquals(expectedType, ImageTypeDetector.detectImageType(location)); + Assertions.assertEquals(expectedType, ImageTypeDetector.detectImageType(location)); } private static void testStream(InputStream stream, ImageType expectedType) { - Assert.assertEquals(expectedType, ImageTypeDetector.detectImageType(stream)); + Assertions.assertEquals(expectedType, ImageTypeDetector.detectImageType(stream)); } private static void testBytes(byte[] bytes, ImageType expectedType) { - Assert.assertEquals(expectedType, ImageTypeDetector.detectImageType(bytes)); + Assertions.assertEquals(expectedType, ImageTypeDetector.detectImageType(bytes)); } } diff --git a/io/src/test/java/com/itextpdf/io/image/Jbig2Test.java b/io/src/test/java/com/itextpdf/io/image/Jbig2Test.java index 288ee0ca9e..b1e8825547 100644 --- a/io/src/test/java/com/itextpdf/io/image/Jbig2Test.java +++ b/io/src/test/java/com/itextpdf/io/image/Jbig2Test.java @@ -26,15 +26,14 @@ This file is part of the iText (R) project. import com.itextpdf.io.util.StreamUtil; import com.itextpdf.io.util.UrlUtil; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.IOException; import java.io.InputStream; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class Jbig2Test extends ExtendedITextTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/io/image/Jbig2Test/"; @@ -44,23 +43,23 @@ public void testReadingJbigFromBytes() throws IOException { try (InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "image.jb2")) { byte[] inputImage = StreamUtil.inputStreamToArray(is); ImageData imageData = ImageDataFactory.createJbig2(inputImage, 1); - Assert.assertEquals(100, (int)imageData.getHeight()); - Assert.assertEquals(100, (int)imageData.getWidth()); + Assertions.assertEquals(100, (int)imageData.getHeight()); + Assertions.assertEquals(100, (int)imageData.getWidth()); } } @Test public void testReadingJbigFromUrl() throws IOException { ImageData imageData = ImageDataFactory.createJbig2(UrlUtil.toURL(SOURCE_FOLDER + "image.jb2"), 1); - Assert.assertEquals("JBIG2Decode", imageData.getFilter()); - Assert.assertEquals(1, imageData.getBpc()); + Assertions.assertEquals("JBIG2Decode", imageData.getFilter()); + Assertions.assertEquals(1, imageData.getBpc()); } @Test public void testCreatingJbigFromCommonMethodByUrl() throws IOException { ImageData imageData = ImageDataFactory.create(UrlUtil.toURL(SOURCE_FOLDER + "image.jb2")); - Assert.assertTrue(imageData instanceof Jbig2ImageData); - Assert.assertEquals(1, ((Jbig2ImageData) imageData).getPage()); + Assertions.assertTrue(imageData instanceof Jbig2ImageData); + Assertions.assertEquals(1, ((Jbig2ImageData) imageData).getPage()); } @Test @@ -70,7 +69,7 @@ public void testCreatingJbigFromCommonMethodByUrlAndBytesProducesSameResult() th try (InputStream fis = FileUtil.getInputStreamForFile(imageFilePath)) { byte[] imageBytes = StreamUtil.inputStreamToArray(fis); ImageData imageDataFromBytes = ImageDataFactory.create(imageBytes); - Assert.assertArrayEquals(imageDataFromBytes.getData(), imageDataFromUrl.getData()); + Assertions.assertArrayEquals(imageDataFromBytes.getData(), imageDataFromUrl.getData()); } } diff --git a/io/src/test/java/com/itextpdf/io/image/Jpeg2000Test.java b/io/src/test/java/com/itextpdf/io/image/Jpeg2000Test.java index 90ebbf2c2a..e4d985dce4 100644 --- a/io/src/test/java/com/itextpdf/io/image/Jpeg2000Test.java +++ b/io/src/test/java/com/itextpdf/io/image/Jpeg2000Test.java @@ -26,13 +26,12 @@ This file is part of the iText (R) project. import com.itextpdf.io.exceptions.IoExceptionMessageConstant; import com.itextpdf.io.util.UrlUtil; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class Jpeg2000Test extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/io/image/"; @@ -43,15 +42,15 @@ public void openJpeg2000_1() throws java.io.IOException { // Test a more specific entry point ImageDataFactory.createJpeg2000(UrlUtil.toURL(sourceFolder + "bee.jp2")); } catch (IOException e) { - Assert.assertEquals(IoExceptionMessageConstant.UNSUPPORTED_BOX_SIZE_EQ_EQ_0, e.getMessage()); + Assertions.assertEquals(IoExceptionMessageConstant.UNSUPPORTED_BOX_SIZE_EQ_EQ_0, e.getMessage()); } } @Test public void openJpeg2000_2() throws java.io.IOException { ImageData img = ImageDataFactory.create(sourceFolder + "bee.jpc"); - Assert.assertEquals(640, img.getWidth(), 0); - Assert.assertEquals(800, img.getHeight(), 0); - Assert.assertEquals(7, img.getBpc()); + Assertions.assertEquals(640, img.getWidth(), 0); + Assertions.assertEquals(800, img.getHeight(), 0); + Assertions.assertEquals(7, img.getBpc()); } } diff --git a/io/src/test/java/com/itextpdf/io/image/JpegImageHelperTest.java b/io/src/test/java/com/itextpdf/io/image/JpegImageHelperTest.java index b1e4a268a1..63436c2c32 100644 --- a/io/src/test/java/com/itextpdf/io/image/JpegImageHelperTest.java +++ b/io/src/test/java/com/itextpdf/io/image/JpegImageHelperTest.java @@ -30,14 +30,13 @@ This file is part of the iText (R) project. import com.itextpdf.test.LogLevelConstants; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.IOException; import java.io.InputStream; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class JpegImageHelperTest extends ExtendedITextTest { public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/io/image/"; diff --git a/io/src/test/java/com/itextpdf/io/image/JpegTest.java b/io/src/test/java/com/itextpdf/io/image/JpegTest.java index 7e2d88a11a..8901852638 100644 --- a/io/src/test/java/com/itextpdf/io/image/JpegTest.java +++ b/io/src/test/java/com/itextpdf/io/image/JpegTest.java @@ -26,15 +26,14 @@ This file is part of the iText (R) project. import com.itextpdf.io.util.StreamUtil; import com.itextpdf.io.util.UrlUtil; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.IOException; import java.io.InputStream; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class JpegTest extends ExtendedITextTest { public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/io/image/"; @@ -44,9 +43,9 @@ public void openJpeg1() throws IOException { try (InputStream fis = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "WP_20140410_001.jpg")) { // Test this a more specific entry point ImageData img = ImageDataFactory.createJpeg(StreamUtil.inputStreamToArray(fis)); - Assert.assertEquals(2592, img.getWidth(), 0); - Assert.assertEquals(1456, img.getHeight(), 0); - Assert.assertEquals(8, img.getBpc()); + Assertions.assertEquals(2592, img.getWidth(), 0); + Assertions.assertEquals(1456, img.getHeight(), 0); + Assertions.assertEquals(8, img.getBpc()); } } @@ -54,9 +53,9 @@ public void openJpeg1() throws IOException { public void openJpeg2() throws IOException { // Test this a more specific entry point ImageData img = ImageDataFactory.createJpeg(UrlUtil.toURL(SOURCE_FOLDER + "WP_20140410_001_gray.jpg")); - Assert.assertEquals(2592, img.getWidth(), 0); - Assert.assertEquals(1456, img.getHeight(), 0); - Assert.assertEquals(8, img.getBpc()); + Assertions.assertEquals(2592, img.getWidth(), 0); + Assertions.assertEquals(1456, img.getHeight(), 0); + Assertions.assertEquals(8, img.getBpc()); } @Test @@ -64,33 +63,33 @@ public void openJpeg3() throws IOException { try (InputStream fis = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "WP_20140410_001_monochrome.jpg")) { // Test this a more specific entry point ImageData img = ImageDataFactory.create(StreamUtil.inputStreamToArray(fis)); - Assert.assertEquals(2592, img.getWidth(), 0); - Assert.assertEquals(1456, img.getHeight(), 0); - Assert.assertEquals(8, img.getBpc()); + Assertions.assertEquals(2592, img.getWidth(), 0); + Assertions.assertEquals(1456, img.getHeight(), 0); + Assertions.assertEquals(8, img.getBpc()); } } @Test public void openJpeg4() throws IOException { ImageData img = ImageDataFactory.create(SOURCE_FOLDER + "WP_20140410_001_negate.jpg"); - Assert.assertEquals(2592, img.getWidth(), 0); - Assert.assertEquals(1456, img.getHeight(), 0); - Assert.assertEquals(8, img.getBpc()); + Assertions.assertEquals(2592, img.getWidth(), 0); + Assertions.assertEquals(1456, img.getHeight(), 0); + Assertions.assertEquals(8, img.getBpc()); } @Test public void openJpeg5() throws IOException { ImageData img = ImageDataFactory.create(SOURCE_FOLDER + "WP_20140410_001_year1900.jpg"); - Assert.assertEquals(2592, img.getWidth(), 0); - Assert.assertEquals(1456, img.getHeight(), 0); - Assert.assertEquals(8, img.getBpc()); + Assertions.assertEquals(2592, img.getWidth(), 0); + Assertions.assertEquals(1456, img.getHeight(), 0); + Assertions.assertEquals(8, img.getBpc()); } @Test public void openJpeg6() throws IOException { ImageData img = ImageDataFactory.create(SOURCE_FOLDER + "WP_20140410_001_year1980.jpg"); - Assert.assertEquals(2592, img.getWidth(), 0); - Assert.assertEquals(1456, img.getHeight(), 0); - Assert.assertEquals(8, img.getBpc()); + Assertions.assertEquals(2592, img.getWidth(), 0); + Assertions.assertEquals(1456, img.getHeight(), 0); + Assertions.assertEquals(8, img.getBpc()); } } diff --git a/io/src/test/java/com/itextpdf/io/image/PngTest.java b/io/src/test/java/com/itextpdf/io/image/PngTest.java index 553797ab00..80fc4fbc54 100644 --- a/io/src/test/java/com/itextpdf/io/image/PngTest.java +++ b/io/src/test/java/com/itextpdf/io/image/PngTest.java @@ -26,190 +26,189 @@ This file is part of the iText (R) project. import com.itextpdf.io.util.StreamUtil; import com.itextpdf.io.util.UrlUtil; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.IOException; import java.io.InputStream; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PngTest extends ExtendedITextTest { private static final String sourceFolder = "./src/test/resources/com/itextpdf/io/image/PngTest/"; @Test public void grayscale8BpcDepthImageTest() throws IOException { ImageData img = ImageDataFactory.create(sourceFolder + "grayscale8Bpc.png"); - Assert.assertEquals(ImageType.PNG, img.getOriginalType()); - Assert.assertEquals(100, img.getWidth(), 0); - Assert.assertEquals(100, img.getHeight(), 0); - Assert.assertEquals(8, img.getBpc()); - Assert.assertEquals(1, img.getColorEncodingComponentsNumber()); - Assert.assertEquals(0, ((PngImageData)img).getColorType()); + Assertions.assertEquals(ImageType.PNG, img.getOriginalType()); + Assertions.assertEquals(100, img.getWidth(), 0); + Assertions.assertEquals(100, img.getHeight(), 0); + Assertions.assertEquals(8, img.getBpc()); + Assertions.assertEquals(1, img.getColorEncodingComponentsNumber()); + Assertions.assertEquals(0, ((PngImageData)img).getColorType()); } @Test // iText explicitly processes 16bit images as 8bit public void grayscale16BpcDepthImageTest() throws IOException { ImageData img = ImageDataFactory.create(sourceFolder + "grayscale16Bpc.png"); - Assert.assertEquals(ImageType.PNG, img.getOriginalType()); - Assert.assertEquals(100, img.getWidth(), 0); - Assert.assertEquals(100, img.getHeight(), 0); - Assert.assertEquals(8, img.getBpc()); - Assert.assertEquals(1, img.getColorEncodingComponentsNumber()); - Assert.assertEquals(0, ((PngImageData)img).getColorType()); + Assertions.assertEquals(ImageType.PNG, img.getOriginalType()); + Assertions.assertEquals(100, img.getWidth(), 0); + Assertions.assertEquals(100, img.getHeight(), 0); + Assertions.assertEquals(8, img.getBpc()); + Assertions.assertEquals(1, img.getColorEncodingComponentsNumber()); + Assertions.assertEquals(0, ((PngImageData)img).getColorType()); } @Test public void graya8BpcDepthImageTest() throws IOException { ImageData img = ImageDataFactory.create(sourceFolder + "graya8Bpc.png"); - Assert.assertEquals(ImageType.PNG, img.getOriginalType()); - Assert.assertEquals(100, img.getWidth(), 0); - Assert.assertEquals(100, img.getHeight(), 0); - Assert.assertEquals(8, img.getBpc()); - Assert.assertEquals(1, img.getColorEncodingComponentsNumber()); - Assert.assertEquals(4, ((PngImageData)img).getColorType()); - Assert.assertNotNull(img.getImageMask()); - Assert.assertEquals(1, img.getImageMask().getColorEncodingComponentsNumber()); - Assert.assertEquals(8, img.getImageMask().getBpc()); + Assertions.assertEquals(ImageType.PNG, img.getOriginalType()); + Assertions.assertEquals(100, img.getWidth(), 0); + Assertions.assertEquals(100, img.getHeight(), 0); + Assertions.assertEquals(8, img.getBpc()); + Assertions.assertEquals(1, img.getColorEncodingComponentsNumber()); + Assertions.assertEquals(4, ((PngImageData)img).getColorType()); + Assertions.assertNotNull(img.getImageMask()); + Assertions.assertEquals(1, img.getImageMask().getColorEncodingComponentsNumber()); + Assertions.assertEquals(8, img.getImageMask().getBpc()); } @Test public void graya8BpcDepthWithoutEmbeddedProfileImageTest() throws IOException { ImageData img = ImageDataFactory.create(sourceFolder + "graya8BpcWithoutProfile.png"); - Assert.assertEquals(ImageType.PNG, img.getOriginalType()); - Assert.assertEquals(100, img.getWidth(), 0); - Assert.assertEquals(100, img.getHeight(), 0); - Assert.assertEquals(8, img.getBpc()); - Assert.assertEquals(1, img.getColorEncodingComponentsNumber()); - Assert.assertEquals(4, ((PngImageData) img).getColorType()); - Assert.assertNotNull(img.getImageMask()); - Assert.assertEquals(1, img.getImageMask().getColorEncodingComponentsNumber()); - Assert.assertEquals(8, img.getImageMask().getBpc()); - Assert.assertNull(img.getProfile()); + Assertions.assertEquals(ImageType.PNG, img.getOriginalType()); + Assertions.assertEquals(100, img.getWidth(), 0); + Assertions.assertEquals(100, img.getHeight(), 0); + Assertions.assertEquals(8, img.getBpc()); + Assertions.assertEquals(1, img.getColorEncodingComponentsNumber()); + Assertions.assertEquals(4, ((PngImageData) img).getColorType()); + Assertions.assertNotNull(img.getImageMask()); + Assertions.assertEquals(1, img.getImageMask().getColorEncodingComponentsNumber()); + Assertions.assertEquals(8, img.getImageMask().getBpc()); + Assertions.assertNull(img.getProfile()); } @Test public void graya8BpcAddColorToAlphaImageTest() throws IOException { ImageData img = ImageDataFactory.create(sourceFolder + "graya8BpcAddColorToAlpha.png"); - Assert.assertEquals(ImageType.PNG, img.getOriginalType()); - Assert.assertEquals(100, img.getWidth(), 0); - Assert.assertEquals(100, img.getHeight(), 0); - Assert.assertEquals(8, img.getBpc()); - Assert.assertEquals(1, img.getColorEncodingComponentsNumber()); + Assertions.assertEquals(ImageType.PNG, img.getOriginalType()); + Assertions.assertEquals(100, img.getWidth(), 0); + Assertions.assertEquals(100, img.getHeight(), 0); + Assertions.assertEquals(8, img.getBpc()); + Assertions.assertEquals(1, img.getColorEncodingComponentsNumber()); } @Test public void rgb8BpcDepthImageTest() throws IOException { ImageData img = ImageDataFactory.create(sourceFolder + "rgb8Bpc.png"); - Assert.assertEquals(ImageType.PNG, img.getOriginalType()); - Assert.assertEquals(100, img.getWidth(), 0); - Assert.assertEquals(100, img.getHeight(), 0); - Assert.assertEquals(8, img.getBpc()); - Assert.assertEquals(3, img.getColorEncodingComponentsNumber()); + Assertions.assertEquals(ImageType.PNG, img.getOriginalType()); + Assertions.assertEquals(100, img.getWidth(), 0); + Assertions.assertEquals(100, img.getHeight(), 0); + Assertions.assertEquals(8, img.getBpc()); + Assertions.assertEquals(3, img.getColorEncodingComponentsNumber()); } @Test // iText explicitly processes 16bit images as 8bit public void rgb16BpcDepthImageTest() throws IOException { ImageData img = ImageDataFactory.create(sourceFolder + "rgb16Bpc.png"); - Assert.assertEquals(ImageType.PNG, img.getOriginalType()); - Assert.assertEquals(100, img.getWidth(), 0); - Assert.assertEquals(100, img.getHeight(), 0); - Assert.assertEquals(8, img.getBpc()); - Assert.assertEquals(3, img.getColorEncodingComponentsNumber()); - Assert.assertEquals(2, ((PngImageData)img).getColorType()); + Assertions.assertEquals(ImageType.PNG, img.getOriginalType()); + Assertions.assertEquals(100, img.getWidth(), 0); + Assertions.assertEquals(100, img.getHeight(), 0); + Assertions.assertEquals(8, img.getBpc()); + Assertions.assertEquals(3, img.getColorEncodingComponentsNumber()); + Assertions.assertEquals(2, ((PngImageData)img).getColorType()); } @Test public void rgbWithoutSaveColorProfileImageTest() throws IOException { ImageData img = ImageDataFactory.create(sourceFolder + "rgbWithoutSaveColorProfile.png"); - Assert.assertEquals(ImageType.PNG, img.getOriginalType()); - Assert.assertEquals(100, img.getWidth(), 0); - Assert.assertEquals(100, img.getHeight(), 0); - Assert.assertEquals(8, img.getBpc()); - Assert.assertEquals(3, img.getColorEncodingComponentsNumber()); - Assert.assertEquals(2, ((PngImageData)img).getColorType()); - Assert.assertNull(img.getProfile()); + Assertions.assertEquals(ImageType.PNG, img.getOriginalType()); + Assertions.assertEquals(100, img.getWidth(), 0); + Assertions.assertEquals(100, img.getHeight(), 0); + Assertions.assertEquals(8, img.getBpc()); + Assertions.assertEquals(3, img.getColorEncodingComponentsNumber()); + Assertions.assertEquals(2, ((PngImageData)img).getColorType()); + Assertions.assertNull(img.getProfile()); } @Test public void rgba8BpcDepthImageTest() throws IOException { ImageData img = ImageDataFactory.create(sourceFolder + "rgba8Bpc.png"); - Assert.assertEquals(ImageType.PNG, img.getOriginalType()); - Assert.assertEquals(100, img.getWidth(), 0); - Assert.assertEquals(100, img.getHeight(), 0); - Assert.assertEquals(8, img.getBpc()); - Assert.assertEquals(3, img.getColorEncodingComponentsNumber()); - Assert.assertEquals(6, ((PngImageData)img).getColorType()); - Assert.assertNotNull(img.getImageMask()); - Assert.assertEquals(1, img.getImageMask().getColorEncodingComponentsNumber()); - Assert.assertEquals(8, img.getImageMask().getBpc()); + Assertions.assertEquals(ImageType.PNG, img.getOriginalType()); + Assertions.assertEquals(100, img.getWidth(), 0); + Assertions.assertEquals(100, img.getHeight(), 0); + Assertions.assertEquals(8, img.getBpc()); + Assertions.assertEquals(3, img.getColorEncodingComponentsNumber()); + Assertions.assertEquals(6, ((PngImageData)img).getColorType()); + Assertions.assertNotNull(img.getImageMask()); + Assertions.assertEquals(1, img.getImageMask().getColorEncodingComponentsNumber()); + Assertions.assertEquals(8, img.getImageMask().getBpc()); } @Test // iText explicitly processes 16bit images as 8bit public void rgba16BpcDepthImageTest() throws IOException { ImageData img = ImageDataFactory.create(sourceFolder + "rgba16Bpc.png"); - Assert.assertEquals(ImageType.PNG, img.getOriginalType()); - Assert.assertEquals(100, img.getWidth(), 0); - Assert.assertEquals(100, img.getHeight(), 0); - Assert.assertEquals(8, img.getBpc()); - Assert.assertEquals(3, img.getColorEncodingComponentsNumber()); - Assert.assertEquals(6, ((PngImageData)img).getColorType()); - Assert.assertNotNull(img.getImageMask()); - Assert.assertEquals(1, img.getImageMask().getColorEncodingComponentsNumber()); - Assert.assertEquals(8, img.getImageMask().getBpc()); + Assertions.assertEquals(ImageType.PNG, img.getOriginalType()); + Assertions.assertEquals(100, img.getWidth(), 0); + Assertions.assertEquals(100, img.getHeight(), 0); + Assertions.assertEquals(8, img.getBpc()); + Assertions.assertEquals(3, img.getColorEncodingComponentsNumber()); + Assertions.assertEquals(6, ((PngImageData)img).getColorType()); + Assertions.assertNotNull(img.getImageMask()); + Assertions.assertEquals(1, img.getImageMask().getColorEncodingComponentsNumber()); + Assertions.assertEquals(8, img.getImageMask().getBpc()); } @Test public void indexed2BpcImageTest() throws IOException { ImageData img = ImageDataFactory.create(sourceFolder + "indexed2BpcImage.png"); - Assert.assertEquals(ImageType.PNG, img.getOriginalType()); - Assert.assertEquals(346, img.getWidth(), 0); - Assert.assertEquals(49, img.getHeight(), 0); - Assert.assertEquals(2, img.getBpc()); + Assertions.assertEquals(ImageType.PNG, img.getOriginalType()); + Assertions.assertEquals(346, img.getWidth(), 0); + Assertions.assertEquals(49, img.getHeight(), 0); + Assertions.assertEquals(2, img.getBpc()); //Indexed colorspace contains one component indeed - Assert.assertEquals(1, img.getColorEncodingComponentsNumber()); - Assert.assertEquals(3, ((PngImageData)img).getColorType()); + Assertions.assertEquals(1, img.getColorEncodingComponentsNumber()); + Assertions.assertEquals(3, ((PngImageData)img).getColorType()); } @Test public void indexed1BpcImageTest() throws IOException { ImageData img = ImageDataFactory.create(sourceFolder + "indexed1BpcImage.png"); - Assert.assertEquals(ImageType.PNG, img.getOriginalType()); - Assert.assertEquals(100, img.getWidth(), 0); - Assert.assertEquals(100, img.getHeight(), 0); - Assert.assertEquals(1, img.getBpc()); + Assertions.assertEquals(ImageType.PNG, img.getOriginalType()); + Assertions.assertEquals(100, img.getWidth(), 0); + Assertions.assertEquals(100, img.getHeight(), 0); + Assertions.assertEquals(1, img.getBpc()); //Indexed colorspace contains one component indeed - Assert.assertEquals(1, img.getColorEncodingComponentsNumber()); - Assert.assertEquals(3, ((PngImageData)img).getColorType()); + Assertions.assertEquals(1, img.getColorEncodingComponentsNumber()); + Assertions.assertEquals(3, ((PngImageData)img).getColorType()); } @Test public void indexed2BpcWithAlphaChannelTest() throws IOException { ImageData img = ImageDataFactory.create(sourceFolder + "indexed2BpcWithAlphaChannel.png"); - Assert.assertEquals(ImageType.PNG, img.getOriginalType()); - Assert.assertEquals(346, img.getWidth(), 0); - Assert.assertEquals(49, img.getHeight(), 0); - Assert.assertEquals(2, img.getBpc()); + Assertions.assertEquals(ImageType.PNG, img.getOriginalType()); + Assertions.assertEquals(346, img.getWidth(), 0); + Assertions.assertEquals(49, img.getHeight(), 0); + Assertions.assertEquals(2, img.getBpc()); //Indexed colorspace contains one component indeed - Assert.assertEquals(1, img.getColorEncodingComponentsNumber()); - Assert.assertEquals(3, ((PngImageData)img).getColorType()); + Assertions.assertEquals(1, img.getColorEncodingComponentsNumber()); + Assertions.assertEquals(3, ((PngImageData)img).getColorType()); } @Test public void grayscaleSimpleTransparencyImageTest() throws IOException { ImageData img = ImageDataFactory.create(sourceFolder + "grayscaleSimpleTransparencyImage.png"); - Assert.assertEquals(ImageType.PNG, img.getOriginalType()); - Assert.assertEquals(200, img.getWidth(), 0); - Assert.assertEquals(200, img.getHeight(), 0); - Assert.assertEquals(8, img.getBpc()); - Assert.assertEquals(1, img.getColorEncodingComponentsNumber()); - Assert.assertEquals(0, ((PngImageData)img).getColorType()); - Assert.assertNotNull(img.getImageAttributes().entrySet()); - Assert.assertEquals("[0 0]", img.getImageAttributes() + Assertions.assertEquals(ImageType.PNG, img.getOriginalType()); + Assertions.assertEquals(200, img.getWidth(), 0); + Assertions.assertEquals(200, img.getHeight(), 0); + Assertions.assertEquals(8, img.getBpc()); + Assertions.assertEquals(1, img.getColorEncodingComponentsNumber()); + Assertions.assertEquals(0, ((PngImageData)img).getColorType()); + Assertions.assertNotNull(img.getImageAttributes().entrySet()); + Assertions.assertEquals("[0 0]", img.getImageAttributes() .get(PngImageHelperConstants.MASK)); } @@ -217,83 +216,83 @@ public void grayscaleSimpleTransparencyImageTest() throws IOException { @Test public void rgbSimpleTransparencyImageTest() throws IOException { ImageData img = ImageDataFactory.create(sourceFolder + "rgbSimpleTransparencyImage.png"); - Assert.assertEquals(ImageType.PNG, img.getOriginalType()); - Assert.assertEquals(600, img.getWidth(), 0); - Assert.assertEquals(100, img.getHeight(), 0); - Assert.assertEquals(8, img.getBpc()); - Assert.assertEquals(3, img.getColorEncodingComponentsNumber()); - Assert.assertEquals(2, ((PngImageData)img).getColorType()); - Assert.assertNotNull(img.getImageAttributes().entrySet()); - Assert.assertEquals("[255 255 0 0 0 0]", img.getImageAttributes() + Assertions.assertEquals(ImageType.PNG, img.getOriginalType()); + Assertions.assertEquals(600, img.getWidth(), 0); + Assertions.assertEquals(100, img.getHeight(), 0); + Assertions.assertEquals(8, img.getBpc()); + Assertions.assertEquals(3, img.getColorEncodingComponentsNumber()); + Assertions.assertEquals(2, ((PngImageData)img).getColorType()); + Assertions.assertNotNull(img.getImageAttributes().entrySet()); + Assertions.assertEquals("[255 255 0 0 0 0]", img.getImageAttributes() .get(PngImageHelperConstants.MASK)); } @Test public void indexedAddColorToAlphaImageTest() throws IOException { ImageData img = ImageDataFactory.create(sourceFolder + "indexedAddColorToAlpha.png"); - Assert.assertEquals(ImageType.PNG, img.getOriginalType()); - Assert.assertEquals(346, img.getWidth(), 0); - Assert.assertEquals(49, img.getHeight(), 0); - Assert.assertEquals(2, img.getBpc()); + Assertions.assertEquals(ImageType.PNG, img.getOriginalType()); + Assertions.assertEquals(346, img.getWidth(), 0); + Assertions.assertEquals(49, img.getHeight(), 0); + Assertions.assertEquals(2, img.getBpc()); //Indexed colorspace contains one component indeed - Assert.assertEquals(1, img.getColorEncodingComponentsNumber()); - Assert.assertEquals(3, ((PngImageData)img).getColorType()); - Assert.assertNotNull(img.getImageAttributes().entrySet()); - Assert.assertEquals(0, ((int[])img.getImageAttributes() + Assertions.assertEquals(1, img.getColorEncodingComponentsNumber()); + Assertions.assertEquals(3, ((PngImageData)img).getColorType()); + Assertions.assertNotNull(img.getImageAttributes().entrySet()); + Assertions.assertEquals(0, ((int[])img.getImageAttributes() .get(PngImageHelperConstants.MASK))[0]); - Assert.assertEquals(0, ((int[])img.getImageAttributes() + Assertions.assertEquals(0, ((int[])img.getImageAttributes() .get(PngImageHelperConstants.MASK))[1]); } @Test public void size50Px30DpiImageTest() throws IOException { ImageData img = ImageDataFactory.create(sourceFolder + "size50Px30Dpi.png"); - Assert.assertEquals(ImageType.PNG, img.getOriginalType()); - Assert.assertEquals(50, img.getWidth(), 0); - Assert.assertEquals(50, img.getHeight(), 0); - Assert.assertEquals(30, img.getDpiX()); - Assert.assertEquals(30, img.getDpiY()); + Assertions.assertEquals(ImageType.PNG, img.getOriginalType()); + Assertions.assertEquals(50, img.getWidth(), 0); + Assertions.assertEquals(50, img.getHeight(), 0); + Assertions.assertEquals(30, img.getDpiX()); + Assertions.assertEquals(30, img.getDpiY()); } @Test public void size50Px300DpiImageTest() throws IOException { ImageData img = ImageDataFactory.create(sourceFolder + "size50Px300Dpi.png"); - Assert.assertEquals(ImageType.PNG, img.getOriginalType()); - Assert.assertEquals(50, img.getWidth(), 0); - Assert.assertEquals(50, img.getHeight(), 0); - Assert.assertEquals(300, img.getDpiX()); - Assert.assertEquals(300, img.getDpiY()); + Assertions.assertEquals(ImageType.PNG, img.getOriginalType()); + Assertions.assertEquals(50, img.getWidth(), 0); + Assertions.assertEquals(50, img.getHeight(), 0); + Assertions.assertEquals(300, img.getDpiX()); + Assertions.assertEquals(300, img.getDpiY()); } @Test public void size150Px72DpiImageTest() throws IOException { ImageData img = ImageDataFactory.create(sourceFolder + "size150Px72Dpi.png"); - Assert.assertEquals(ImageType.PNG, img.getOriginalType()); - Assert.assertEquals(150, img.getWidth(), 0); - Assert.assertEquals(150, img.getHeight(), 0); - Assert.assertEquals(72, img.getDpiX()); - Assert.assertEquals(72, img.getDpiY()); + Assertions.assertEquals(ImageType.PNG, img.getOriginalType()); + Assertions.assertEquals(150, img.getWidth(), 0); + Assertions.assertEquals(150, img.getHeight(), 0); + Assertions.assertEquals(72, img.getDpiX()); + Assertions.assertEquals(72, img.getDpiY()); } @Test public void size300Px72DpiImageTest() throws IOException { ImageData img = ImageDataFactory.create(sourceFolder + "size300Px72Dpi.png"); - Assert.assertEquals(ImageType.PNG, img.getOriginalType()); - Assert.assertEquals(300, img.getWidth(), 0); - Assert.assertEquals(300, img.getHeight(), 0); - Assert.assertEquals(72, img.getDpiX()); - Assert.assertEquals(72, img.getDpiY()); + Assertions.assertEquals(ImageType.PNG, img.getOriginalType()); + Assertions.assertEquals(300, img.getWidth(), 0); + Assertions.assertEquals(300, img.getHeight(), 0); + Assertions.assertEquals(72, img.getDpiX()); + Assertions.assertEquals(72, img.getDpiY()); } @Test public void size300Px300DpiImageTest() throws IOException { // Test a more specific entry point ImageData img = ImageDataFactory.createPng(UrlUtil.toURL(sourceFolder + "size300Px300Dpi.png")); - Assert.assertEquals(ImageType.PNG, img.getOriginalType()); - Assert.assertEquals(300, img.getWidth(), 0); - Assert.assertEquals(300, img.getHeight(), 0); - Assert.assertEquals(300, img.getDpiX()); - Assert.assertEquals(300, img.getDpiY()); + Assertions.assertEquals(ImageType.PNG, img.getOriginalType()); + Assertions.assertEquals(300, img.getWidth(), 0); + Assertions.assertEquals(300, img.getHeight(), 0); + Assertions.assertEquals(300, img.getDpiX()); + Assertions.assertEquals(300, img.getDpiY()); } @Test @@ -302,22 +301,22 @@ public void sRGBImageTest() throws IOException { byte[] imageBytes = StreamUtil.inputStreamToArray(fis); // Test a more specific entry point ImageData img = ImageDataFactory.createPng(imageBytes); - Assert.assertEquals(ImageType.PNG, img.getOriginalType()); - Assert.assertEquals(50, img.getWidth(), 0); - Assert.assertEquals(50, img.getHeight(), 0); - Assert.assertEquals(96, img.getDpiX()); - Assert.assertEquals(96, img.getDpiY()); - Assert.assertEquals(2.2, ((PngImageData) img).getGamma(), 0.0001f); + Assertions.assertEquals(ImageType.PNG, img.getOriginalType()); + Assertions.assertEquals(50, img.getWidth(), 0); + Assertions.assertEquals(50, img.getHeight(), 0); + Assertions.assertEquals(96, img.getDpiX()); + Assertions.assertEquals(96, img.getDpiY()); + Assertions.assertEquals(2.2, ((PngImageData) img).getGamma(), 0.0001f); PngChromaticities pngChromaticities = ((PngImageData) img).getPngChromaticities(); - Assert.assertEquals(0.3127f, pngChromaticities.getXW(), 0.0001f); - Assert.assertEquals(0.329f, pngChromaticities.getYW(), 0.0001f); - Assert.assertEquals(0.64f, pngChromaticities.getXR(), 0.0001f); - Assert.assertEquals(0.33f, pngChromaticities.getYR(), 0.0001f); - Assert.assertEquals(0.3f, pngChromaticities.getXG(), 0.0001f); - Assert.assertEquals(0.6f, pngChromaticities.getYG(), 0.0001f); - Assert.assertEquals(0.15f, pngChromaticities.getXB(), 0.0001f); - Assert.assertEquals(0.06f, pngChromaticities.getYB(), 0.0001f); + Assertions.assertEquals(0.3127f, pngChromaticities.getXW(), 0.0001f); + Assertions.assertEquals(0.329f, pngChromaticities.getYW(), 0.0001f); + Assertions.assertEquals(0.64f, pngChromaticities.getXR(), 0.0001f); + Assertions.assertEquals(0.33f, pngChromaticities.getYR(), 0.0001f); + Assertions.assertEquals(0.3f, pngChromaticities.getXG(), 0.0001f); + Assertions.assertEquals(0.6f, pngChromaticities.getYG(), 0.0001f); + Assertions.assertEquals(0.15f, pngChromaticities.getXB(), 0.0001f); + Assertions.assertEquals(0.06f, pngChromaticities.getYB(), 0.0001f); } } } diff --git a/io/src/test/java/com/itextpdf/io/image/RawImageHelperTest.java b/io/src/test/java/com/itextpdf/io/image/RawImageHelperTest.java new file mode 100644 index 0000000000..5109a94607 --- /dev/null +++ b/io/src/test/java/com/itextpdf/io/image/RawImageHelperTest.java @@ -0,0 +1,77 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.io.image; + +import com.itextpdf.test.ExtendedITextTest; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; + +@Tag("UnitTest") +public class RawImageHelperTest extends ExtendedITextTest { + + @Test + public void oneBitBlackPixelsTest() { + PngImageData pngImageData1 = new PngImageData(new byte[1]); + pngImageData1.setTypeCcitt(256); + pngImageData1.setColorEncodingComponentsNumber(RawImageData.CCITT_BLACKIS1); + RawImageHelper.updateImageAttributes(pngImageData1, null); + + Boolean blackIs1 = (Boolean) pngImageData1.getDecodeParms().get("BlackIs1"); + Assertions.assertTrue(blackIs1, "CCITT_BLACKIS1 is false."); + } + + @Test + public void extraZeroBitsBeforeEncodedLineTest() { + PngImageData pngImageData1 = new PngImageData(new byte[1]); + pngImageData1.setTypeCcitt(256); + pngImageData1.setColorEncodingComponentsNumber(RawImageData.CCITT_ENCODEDBYTEALIGN); + RawImageHelper.updateImageAttributes(pngImageData1, null); + + Boolean blackIs1 = (Boolean) pngImageData1.getDecodeParms().get("EncodedByteAlign"); + Assertions.assertTrue(blackIs1, "CCITT_ENCODEDBYTEALIGN is false."); + } + + @Test + public void endOfLineBitsPresentTest() { + PngImageData pngImageData1 = new PngImageData(new byte[1]); + pngImageData1.setTypeCcitt(256); + pngImageData1.setColorEncodingComponentsNumber(RawImageData.CCITT_ENDOFLINE); + RawImageHelper.updateImageAttributes(pngImageData1, null); + + Boolean blackIs1 = (Boolean) pngImageData1.getDecodeParms().get("EndOfLine"); + Assertions.assertTrue(blackIs1, "CCITT_ENDOFLINE is false."); + } + + @Test + public void endOfBlockPatternFalseTest() { + PngImageData pngImageData1 = new PngImageData(new byte[1]); + pngImageData1.setTypeCcitt(256); + pngImageData1.setColorEncodingComponentsNumber(RawImageData.CCITT_ENDOFBLOCK); + RawImageHelper.updateImageAttributes(pngImageData1, null); + + Boolean blackIs1 = (Boolean) pngImageData1.getDecodeParms().get("EndOfBlock"); + Assertions.assertFalse(blackIs1, "CCITT_ENDOFBLOCK is true."); + } +} diff --git a/io/src/test/java/com/itextpdf/io/image/TiffTest.java b/io/src/test/java/com/itextpdf/io/image/TiffTest.java index c1ceb40f2a..a1285590e7 100644 --- a/io/src/test/java/com/itextpdf/io/image/TiffTest.java +++ b/io/src/test/java/com/itextpdf/io/image/TiffTest.java @@ -31,17 +31,16 @@ This file is part of the iText (R) project. import com.itextpdf.io.util.StreamUtil; import com.itextpdf.io.util.UrlUtil; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.IOException; import java.net.MalformedURLException; import java.nio.file.Files; import java.nio.file.Paths; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class TiffTest extends ExtendedITextTest { private static final double DELTA = 1e-5; @@ -52,9 +51,9 @@ public void openTiff1() throws IOException { byte[] imageBytes = StreamUtil.inputStreamToArray(FileUtil.getInputStreamForFile(SOURCE_FOLDER + "WP_20140410_001.tif")); // Test a more specific entry point ImageData img = ImageDataFactory.createTiff(imageBytes, false, 1, false); - Assert.assertEquals(2592, img.getWidth(), 0); - Assert.assertEquals(1456, img.getHeight(), 0); - Assert.assertEquals(8, img.getBpc()); + Assertions.assertEquals(2592, img.getWidth(), 0); + Assertions.assertEquals(1456, img.getHeight(), 0); + Assertions.assertEquals(8, img.getBpc()); } @Test @@ -69,36 +68,36 @@ public void openTiff2() throws IOException { public void openTiff3() throws IOException { ImageData img = ImageDataFactory.create(SOURCE_FOLDER + "WP_20140410_001_monochrome.tiff"); - Assert.assertEquals(2592, img.getWidth(), 0); - Assert.assertEquals(1456, img.getHeight(), 0); - Assert.assertEquals(8, img.getBpc()); + Assertions.assertEquals(2592, img.getWidth(), 0); + Assertions.assertEquals(1456, img.getHeight(), 0); + Assertions.assertEquals(8, img.getBpc()); } @Test public void openTiff4() throws IOException { ImageData img = ImageDataFactory.create(SOURCE_FOLDER + "WP_20140410_001_negate.tiff"); - Assert.assertEquals(2592, img.getWidth(), 0); - Assert.assertEquals(1456, img.getHeight(), 0); - Assert.assertEquals(8, img.getBpc()); + Assertions.assertEquals(2592, img.getWidth(), 0); + Assertions.assertEquals(1456, img.getHeight(), 0); + Assertions.assertEquals(8, img.getBpc()); } @Test public void openTiff5() throws IOException { ImageData img = ImageDataFactory.create(SOURCE_FOLDER + "WP_20140410_001_year1900.tiff"); - Assert.assertEquals(2592, img.getWidth(), 0); - Assert.assertEquals(1456, img.getHeight(), 0); - Assert.assertEquals(8, img.getBpc()); + Assertions.assertEquals(2592, img.getWidth(), 0); + Assertions.assertEquals(1456, img.getHeight(), 0); + Assertions.assertEquals(8, img.getBpc()); } @Test public void openTiff6() throws IOException { ImageData img = ImageDataFactory.create(SOURCE_FOLDER + "WP_20140410_001_year1980.tiff"); - Assert.assertEquals(2592, img.getWidth(), 0); - Assert.assertEquals(1456, img.getHeight(), 0); - Assert.assertEquals(8, img.getBpc()); + Assertions.assertEquals(2592, img.getWidth(), 0); + Assertions.assertEquals(1456, img.getHeight(), 0); + Assertions.assertEquals(8, img.getBpc()); } @Test @@ -108,7 +107,7 @@ public void getStringDataFromTiff() throws IOException { new RandomAccessSourceFactory().createSource(bytes)), 0); String[] stringArray = new String[] {"iText? 7.1.7-SNAPSHOT ?2000-2019 iText Group NV (AGPL-version)\u0000"}; - Assert.assertArrayEquals(stringArray, dir.getField(305).getAsStrings()); + Assertions.assertArrayEquals(stringArray, dir.getField(305).getAsStrings()); } @Test @@ -135,10 +134,10 @@ public void group3Compression2DCreateTiffImageTest() throws MalformedURLExceptio public void group3CompressionEolErrorCreateTiffImageTest() throws MalformedURLException { String sourceFile = SOURCE_FOLDER + "group3CompressionImageWithEolError.tif"; - Exception e = Assert.assertThrows(com.itextpdf.io.exceptions.IOException.class, + Exception e = Assertions.assertThrows(com.itextpdf.io.exceptions.IOException.class, () -> createTiff(sourceFile, 1, 1024D, 768D)); - Assert.assertEquals(MessageFormatUtil.format( + Assertions.assertEquals(MessageFormatUtil.format( IoExceptionMessageConstant.CANNOT_READ_TIFF_IMAGE), e.getMessage()); } @@ -147,9 +146,9 @@ public void group3CompressionEolErrorCreateTiffImageTest() throws MalformedURLEx public void group3CompressionCreateImageDataTest() throws MalformedURLException { String sourceFile = SOURCE_FOLDER + "group3CompressionImage.tif"; ImageData img = ImageDataFactory.create(UrlUtil.toURL(SOURCE_FOLDER + "group3CompressionImage.tif")); - Assert.assertEquals(1024, img.getWidth(), 0); - Assert.assertEquals(768, img.getHeight(), 0); - Assert.assertEquals(1, img.getBpc()); + Assertions.assertEquals(1024, img.getWidth(), 0); + Assertions.assertEquals(768, img.getHeight(), 0); + Assertions.assertEquals(1, img.getBpc()); } @Test @@ -197,69 +196,69 @@ public void adobeDeflateCompression8BitRgbTest() throws IOException { @Test // TODO: DEVSIX-5791 (update test when support for adobeDeflate compression tiff image will be realized) public void adobeDeflateComp16BitMinIsBlackCreateTiffTest() { - Exception e = Assert.assertThrows(com.itextpdf.io.exceptions.IOException.class, + Exception e = Assertions.assertThrows(com.itextpdf.io.exceptions.IOException.class, () -> ImageDataFactory.createTiff(UrlUtil.toURL( SOURCE_FOLDER + "adobeDeflateCompression16BitMinIsBlack.tif"), false, 1, false)); - Assert.assertEquals(MessageFormatUtil.format( + Assertions.assertEquals(MessageFormatUtil.format( IoExceptionMessageConstant.CANNOT_READ_TIFF_IMAGE), e.getMessage()); } @Test // TODO: DEVSIX-5791 (update test when support for adobeDeflate compression tiff image will be realized) public void adobeDeflateComp16BitMinIsBlackCreateImageTest() { - Exception e = Assert.assertThrows(com.itextpdf.io.exceptions.IOException.class, + Exception e = Assertions.assertThrows(com.itextpdf.io.exceptions.IOException.class, () -> ImageDataFactory.create(UrlUtil.toURL( SOURCE_FOLDER + "adobeDeflateCompression16BitMinIsBlack.tif"))); - Assert.assertEquals(MessageFormatUtil.format( + Assertions.assertEquals(MessageFormatUtil.format( IoExceptionMessageConstant.CANNOT_READ_TIFF_IMAGE), e.getMessage()); } @Test // TODO: DEVSIX-5791 (update test when support for adobeDeflate compression tiff image will be realized) public void adobeDeflateComp16BitMinIsWhiteCreateTiffTest() { - Exception e = Assert.assertThrows(com.itextpdf.io.exceptions.IOException.class, + Exception e = Assertions.assertThrows(com.itextpdf.io.exceptions.IOException.class, () -> ImageDataFactory.createTiff(UrlUtil.toURL( SOURCE_FOLDER + "adobeDeflateCompression16BitMinIsWhite.tif"), false, 1, false)); - Assert.assertEquals(MessageFormatUtil.format( + Assertions.assertEquals(MessageFormatUtil.format( IoExceptionMessageConstant.CANNOT_READ_TIFF_IMAGE), e.getMessage()); } @Test // TODO: DEVSIX-5791 (update test when support for adobeDeflate compression tiff image will be realized) public void adobeDeflateComp16BitMinIsWhiteCreateImageTest() { - Exception e = Assert.assertThrows(com.itextpdf.io.exceptions.IOException.class, + Exception e = Assertions.assertThrows(com.itextpdf.io.exceptions.IOException.class, () -> ImageDataFactory.create(UrlUtil.toURL( SOURCE_FOLDER + "adobeDeflateCompression16BitMinIsWhite.tif"))); - Assert.assertEquals(MessageFormatUtil.format( + Assertions.assertEquals(MessageFormatUtil.format( IoExceptionMessageConstant.CANNOT_READ_TIFF_IMAGE), e.getMessage()); } @Test // TODO: DEVSIX-5791 (update test when support for adobeDeflate compression tiff image will be realized) public void adobeDeflateCompression16BitRgbCreateTiffTest() { - Exception e = Assert.assertThrows(com.itextpdf.io.exceptions.IOException.class, + Exception e = Assertions.assertThrows(com.itextpdf.io.exceptions.IOException.class, () -> ImageDataFactory.createTiff(UrlUtil.toURL( SOURCE_FOLDER + "adobeDeflateCompression16BitRgb.tif"), false, 1, false)); - Assert.assertEquals(MessageFormatUtil.format( + Assertions.assertEquals(MessageFormatUtil.format( IoExceptionMessageConstant.CANNOT_READ_TIFF_IMAGE), e.getMessage()); } @Test // TODO: DEVSIX-5791 (update test when support for adobeDeflate compression tiff image will be realized) public void adobeDeflateCompression16BitRgbCreateImageTest() { - Exception e = Assert.assertThrows(com.itextpdf.io.exceptions.IOException.class, + Exception e = Assertions.assertThrows(com.itextpdf.io.exceptions.IOException.class, () -> ImageDataFactory.create(UrlUtil.toURL( SOURCE_FOLDER + "adobeDeflateCompression16BitRgb.tif"))); - Assert.assertEquals(MessageFormatUtil.format( + Assertions.assertEquals(MessageFormatUtil.format( IoExceptionMessageConstant.CANNOT_READ_TIFF_IMAGE), e.getMessage()); } @@ -331,8 +330,8 @@ private static void createTiff (String sourceFile, int bpc, double width, double ImageData img = ImageDataFactory.createTiff(UrlUtil.toURL(sourceFile), false, 1, false); - Assert.assertEquals(bpc, img.getBpc(), DELTA); - Assert.assertEquals(width, img.getWidth(), DELTA); - Assert.assertEquals(height, img.getHeight(), DELTA); + Assertions.assertEquals(bpc, img.getBpc(), DELTA); + Assertions.assertEquals(width, img.getWidth(), DELTA); + Assertions.assertEquals(height, img.getHeight(), DELTA); } } diff --git a/io/src/test/java/com/itextpdf/io/source/ByteBufferRandomAccessSourceTest.java b/io/src/test/java/com/itextpdf/io/source/ByteBufferRandomAccessSourceTest.java index a8d588519c..a7e2243d96 100644 --- a/io/src/test/java/com/itextpdf/io/source/ByteBufferRandomAccessSourceTest.java +++ b/io/src/test/java/com/itextpdf/io/source/ByteBufferRandomAccessSourceTest.java @@ -24,7 +24,6 @@ This file is part of the iText (R) project. import com.itextpdf.test.AssertUtil; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.IOException; import java.io.RandomAccessFile; @@ -38,11 +37,11 @@ This file is part of the iText (R) project. import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class ByteBufferRandomAccessSourceTest extends ExtendedITextTest { private final static String SOURCE_FILE = "./src/test/resources/com/itextpdf/io/source/RAF.txt"; @@ -85,15 +84,15 @@ public void readIntFromFile() throws IOException { IRandomAccessSource source = new ByteBufferRandomAccessSource( channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size())); - Assert.assertEquals(13, source.length()); - Assert.assertEquals(72, source.get(0)); - Assert.assertEquals(44, source.get(5)); - Assert.assertEquals(33, source.get(12)); - Assert.assertEquals(100, source.get(11)); - Assert.assertEquals(-1, source.get(13)); + Assertions.assertEquals(13, source.length()); + Assertions.assertEquals(72, source.get(0)); + Assertions.assertEquals(44, source.get(5)); + Assertions.assertEquals(33, source.get(12)); + Assertions.assertEquals(100, source.get(11)); + Assertions.assertEquals(-1, source.get(13)); long position = Integer.MAX_VALUE + 1L; - Assert.assertThrows(IllegalArgumentException.class, () -> source.get(position)); + Assertions.assertThrows(IllegalArgumentException.class, () -> source.get(position)); } } @@ -108,15 +107,15 @@ public void readBytesFromFile() throws IOException { byte[] expected = new byte[] {72, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100, 33}; byte[] result = new byte[13]; source.get(0, result, 0, 13); - Assert.assertArrayEquals(expected, result); + Assertions.assertArrayEquals(expected, result); expected = new byte[] {111, 44, 32, 119, 111, 114, 108, 100}; result = new byte[8]; source.get(4, result, 0, 8); - Assert.assertArrayEquals(expected, result); + Assertions.assertArrayEquals(expected, result); long position = Integer.MAX_VALUE + 1L; - Assert.assertThrows(IllegalArgumentException.class, () -> source.get(position, new byte[6], 2, 4)); + Assertions.assertThrows(IllegalArgumentException.class, () -> source.get(position, new byte[6], 2, 4)); } } @@ -143,8 +142,8 @@ public void readFileWithMultipleThreadsTest() throws InterruptedException, Execu List result1 = future1.get(); List result2 = future2.get(); - Assert.assertEquals(expected, result1); - Assert.assertEquals(expected, result2); + Assertions.assertEquals(expected, result1); + Assertions.assertEquals(expected, result2); } } diff --git a/io/src/test/java/com/itextpdf/io/source/OutputStreamTest.java b/io/src/test/java/com/itextpdf/io/source/HighPrecisionOutputStreamTest.java similarity index 64% rename from io/src/test/java/com/itextpdf/io/source/OutputStreamTest.java rename to io/src/test/java/com/itextpdf/io/source/HighPrecisionOutputStreamTest.java index 93141c7e7f..45ed06823b 100644 --- a/io/src/test/java/com/itextpdf/io/source/OutputStreamTest.java +++ b/io/src/test/java/com/itextpdf/io/source/HighPrecisionOutputStreamTest.java @@ -27,19 +27,19 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.FileOutputStream; +import java.io.OutputStream; import java.nio.charset.StandardCharsets; import java.util.Objects; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; -@Category(UnitTest.class) -public class OutputStreamTest extends ExtendedITextTest { +@Tag("UnitTest") +public class HighPrecisionOutputStreamTest extends ExtendedITextTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/io/source/OSTEST.txt"; private static java.io.OutputStream IO_EXCEPTION_OUTPUT_STREAM; @@ -58,12 +58,12 @@ public void changePrecisionTest() throws IOException { //the data is random double expected = 0.100001d; try (ByteArrayOutputStream bytes = new ByteArrayOutputStream(); - OutputStream stream - = new OutputStream<>(bytes, false)) { + HighPrecisionOutputStream stream + = new HighPrecisionOutputStream<>(bytes, false)) { stream.setLocalHighPrecision(true); stream.writeDouble(expected); stream.flush(); - Assert.assertEquals(Objects.toString(expected), new String(bytes.toByteArray(), StandardCharsets.UTF_8)); + Assertions.assertEquals(Objects.toString(expected), new String(bytes.toByteArray(), StandardCharsets.UTF_8)); } } @@ -72,12 +72,12 @@ public void changePrecisionToFalseTest() throws IOException { //the data is random double expected = 0.000002d; try (ByteArrayOutputStream bytes = new ByteArrayOutputStream(); - OutputStream stream - = new OutputStream<>(bytes, false)) { + HighPrecisionOutputStream stream + = new HighPrecisionOutputStream<>(bytes, false)) { stream.setLocalHighPrecision(false); stream.writeDouble(expected); stream.flush(); - Assert.assertEquals("0", new String(bytes.toByteArray(), StandardCharsets.UTF_8)); + Assertions.assertEquals("0", new String(bytes.toByteArray(), StandardCharsets.UTF_8)); } } @@ -89,11 +89,11 @@ public void writeNanTest() throws IOException { //the data is random String expected = "0"; try (ByteArrayOutputStream bytes = new ByteArrayOutputStream(); - OutputStream stream - = new OutputStream<>(bytes)) { + HighPrecisionOutputStream stream + = new HighPrecisionOutputStream<>(bytes)) { stream.writeDouble(Double.NaN); stream.flush(); - Assert.assertEquals(expected, new String(bytes.toByteArray(), StandardCharsets.UTF_8)); + Assertions.assertEquals(expected, new String(bytes.toByteArray(), StandardCharsets.UTF_8)); } } @@ -102,11 +102,11 @@ public void writeValidByteArrayTest() throws IOException { //the data is random byte[] expected = new byte[] {(byte) 68, (byte) 14, (byte) 173, (byte) 105}; try (ByteArrayOutputStream bytes = new ByteArrayOutputStream(); - OutputStream stream - = new OutputStream<>(bytes)) { + HighPrecisionOutputStream stream + = new HighPrecisionOutputStream<>(bytes)) { stream.write(expected); stream.flush(); - Assert.assertArrayEquals(expected, bytes.toByteArray()); + Assertions.assertArrayEquals(expected, bytes.toByteArray()); } } @@ -115,11 +115,11 @@ public void writeValidBytesArrayTest() throws IOException { //the data is random byte[] expected = new byte[] {(byte) 15, (byte) 233, (byte) 58, (byte) 97}; try (ByteArrayOutputStream bytes = new ByteArrayOutputStream(); - OutputStream stream - = new OutputStream<>(bytes)) { + HighPrecisionOutputStream stream + = new HighPrecisionOutputStream<>(bytes)) { stream.writeBytes(expected); stream.flush(); - Assert.assertArrayEquals(expected, bytes.toByteArray()); + Assertions.assertArrayEquals(expected, bytes.toByteArray()); } } @@ -128,11 +128,11 @@ public void writeSingleValidByteTest() throws IOException { //the data is random byte expected = (byte) 193; try (ByteArrayOutputStream bytes = new ByteArrayOutputStream(); - OutputStream stream - = new OutputStream<>(bytes)) { + HighPrecisionOutputStream stream + = new HighPrecisionOutputStream<>(bytes)) { stream.writeByte(expected); stream.flush(); - Assert.assertArrayEquals(new byte[] {expected}, bytes.toByteArray()); + Assertions.assertArrayEquals(new byte[] {expected}, bytes.toByteArray()); } } @@ -141,11 +141,11 @@ public void writeSingleValidIntegerTest() throws IOException { //the data is random int expected = 1695609641; try (ByteArrayOutputStream bytes = new ByteArrayOutputStream(); - OutputStream stream - = new OutputStream<>(bytes)) { + HighPrecisionOutputStream stream + = new HighPrecisionOutputStream<>(bytes)) { stream.writeInteger(expected); stream.flush(); - Assert.assertEquals(Objects.toString(expected), new String(bytes.toByteArray(), StandardCharsets.UTF_8)); + Assertions.assertEquals(Objects.toString(expected), new String(bytes.toByteArray(), StandardCharsets.UTF_8)); } } @@ -154,11 +154,11 @@ public void writeSingleValidLongTest() throws IOException { //the data is random long expected = 1695609641552L; try (ByteArrayOutputStream bytes = new ByteArrayOutputStream(); - OutputStream stream - = new OutputStream<>(bytes)) { + HighPrecisionOutputStream stream + = new HighPrecisionOutputStream<>(bytes)) { stream.writeLong(expected); stream.flush(); - Assert.assertEquals(Objects.toString(expected), new String(bytes.toByteArray(), StandardCharsets.UTF_8)); + Assertions.assertEquals(Objects.toString(expected), new String(bytes.toByteArray(), StandardCharsets.UTF_8)); } } @@ -167,11 +167,11 @@ public void writeValidFloatsArrayTest() throws IOException { //the data is random float[] expected = new float[] {12.05f, 0.001f}; try (ByteArrayOutputStream bytes = new ByteArrayOutputStream(); - OutputStream stream - = new OutputStream<>(bytes)) { + HighPrecisionOutputStream stream + = new HighPrecisionOutputStream<>(bytes)) { stream.writeFloats(expected); stream.flush(); - Assert.assertEquals(expected[0] + " " + expected[1], new String(bytes.toByteArray(), StandardCharsets.UTF_8)); + Assertions.assertEquals(expected[0] + " " + expected[1], new String(bytes.toByteArray(), StandardCharsets.UTF_8)); } } @@ -180,22 +180,22 @@ public void writeValidBytesWithOffsetTest() throws IOException { //the data is random byte[] expected = new byte[] {(byte) 233, (byte) 58}; try (ByteArrayOutputStream bytes = new ByteArrayOutputStream(); - OutputStream stream - = new OutputStream<>(bytes)) { + HighPrecisionOutputStream stream + = new HighPrecisionOutputStream<>(bytes)) { stream.writeBytes(new byte[] {(byte) 15, (byte) 233, (byte) 58, (byte) 97}, 1, 2); stream.flush(); - Assert.assertArrayEquals(expected, bytes.toByteArray()); + Assertions.assertArrayEquals(expected, bytes.toByteArray()); } } @Test() public void writeBytesIOExceptionTest() throws IOException { //Testing that the exception is thrown, not using specific one because of .NET compatability - Assert.assertThrows(Exception.class,() -> { + Assertions.assertThrows(Exception.class,() -> { byte[] bytesToWrite = new byte[] {(byte) 71}; try (java.io.OutputStream bytes = IO_EXCEPTION_OUTPUT_STREAM; - OutputStream stream - = new OutputStream<>(bytes)) { + HighPrecisionOutputStream stream + = new HighPrecisionOutputStream<>(bytes)) { stream.writeBytes(bytesToWrite); } }); @@ -204,11 +204,11 @@ public void writeBytesIOExceptionTest() throws IOException { @Test() public void writeByteIOExceptionTest() throws IOException { //Testing that the exception is thrown, not using specific one because of .NET compatability - Assert.assertThrows(Exception.class,() -> { + Assertions.assertThrows(Exception.class,() -> { byte byteToWrite = (byte) 71; try (java.io.OutputStream bytes = IO_EXCEPTION_OUTPUT_STREAM; - OutputStream stream - = new OutputStream<>(bytes)) { + HighPrecisionOutputStream stream + = new HighPrecisionOutputStream<>(bytes)) { stream.writeByte(byteToWrite); } }); @@ -217,12 +217,12 @@ public void writeByteIOExceptionTest() throws IOException { @Test() public void writeByteIntIOExceptionTest() throws IOException { //Testing that the exception is thrown, not using specific one because of .NET compatability - Assert.assertThrows(Exception.class,() -> { + Assertions.assertThrows(Exception.class,() -> { //the data is random int byteToWrite = 71; try (java.io.OutputStream bytes = IO_EXCEPTION_OUTPUT_STREAM; - OutputStream stream - = new OutputStream<>(bytes)) { + HighPrecisionOutputStream stream + = new HighPrecisionOutputStream<>(bytes)) { stream.writeByte(byteToWrite); } }); @@ -231,12 +231,12 @@ public void writeByteIntIOExceptionTest() throws IOException { @Test() public void writeDoubleIOExceptionTest() throws IOException { //Testing that the exception is thrown, not using specific one because of .NET compatability - Assert.assertThrows(Exception.class,() -> { + Assertions.assertThrows(Exception.class,() -> { //the data is random double num = 55.55d; try (java.io.OutputStream bytes = IO_EXCEPTION_OUTPUT_STREAM; - OutputStream stream - = new OutputStream<>(bytes)) { + HighPrecisionOutputStream stream + = new HighPrecisionOutputStream<>(bytes)) { stream.writeDouble(num); } }); @@ -245,12 +245,12 @@ public void writeDoubleIOExceptionTest() throws IOException { @Test() public void writeLongIOExceptionTest() throws IOException { //Testing that the exception is thrown, not using specific one because of .NET compatability - Assert.assertThrows(Exception.class,() -> { + Assertions.assertThrows(Exception.class,() -> { //the data is random long num = 55L; try (java.io.OutputStream bytes = IO_EXCEPTION_OUTPUT_STREAM; - OutputStream stream - = new OutputStream<>(bytes)) { + HighPrecisionOutputStream stream + = new HighPrecisionOutputStream<>(bytes)) { stream.writeLong(num); } }); @@ -260,12 +260,12 @@ public void writeLongIOExceptionTest() throws IOException { public void writeValidStringTest() throws IOException { String expected = "Test string to write"; try (ByteArrayOutputStream bytes = new ByteArrayOutputStream(); - OutputStream stream - = new OutputStream<>(bytes)) { + HighPrecisionOutputStream stream + = new HighPrecisionOutputStream<>(bytes)) { stream.writeString(expected); stream.writeNewLine(); stream.flush(); - Assert.assertEquals(expected + '\n', new String(bytes.toByteArray(), StandardCharsets.UTF_8)); + Assertions.assertEquals(expected + '\n', new String(bytes.toByteArray(), StandardCharsets.UTF_8)); } } @@ -273,8 +273,8 @@ public void writeValidStringTest() throws IOException { public void gettersAndSettersTest() throws IOException { AssertUtil.doesNotThrow(() -> { //testing that stream is not closed, if setCloseStream is false - OutputStream stream - = new OutputStream<>(null); + HighPrecisionOutputStream stream + = new HighPrecisionOutputStream<>(null); stream.setCloseStream(false); stream.close(); }); @@ -285,22 +285,22 @@ public void assignBytesArrayTest() throws IOException { //the data is random byte[] expected = new byte[] {(byte) 15, (byte) 233, (byte) 58, (byte) 97}; try (ByteArrayOutputStream bytes = new ByteArrayOutputStream(); - OutputStream stream - = new OutputStream<>(bytes)) { + HighPrecisionOutputStream stream + = new HighPrecisionOutputStream<>(bytes)) { stream.assignBytes(expected, 4); - Assert.assertArrayEquals(expected, bytes.toByteArray()); + Assertions.assertArrayEquals(expected, bytes.toByteArray()); } } @Test public void assignBytesExceptionTest() throws IOException { //Testing that the exception is thrown, not using specific one because of .NET compatability - Assert.assertThrows(Exception.class,() -> { + Assertions.assertThrows(Exception.class,() -> { //the data is random byte[] bytes = new byte[] {(byte) 15, (byte) 233, (byte) 58, (byte) 97}; try (java.io.OutputStream outputStream = IO_EXCEPTION_OUTPUT_STREAM; - OutputStream stream - = new OutputStream<>(outputStream)) { + HighPrecisionOutputStream stream + = new HighPrecisionOutputStream<>(outputStream)) { stream.assignBytes(bytes, 4); } }); @@ -310,8 +310,8 @@ public void assignBytesExceptionTest() throws IOException { public void resetTestNoException() throws IOException { AssertUtil.doesNotThrow(() -> { try (ByteArrayOutputStream bytes = new ByteArrayOutputStream(); - OutputStream stream - = new OutputStream<>(bytes)) { + HighPrecisionOutputStream stream + = new HighPrecisionOutputStream<>(bytes)) { stream.writeBytes(new byte[] {(byte) 15, (byte) 233, (byte) 58, (byte) 97}); stream.flush(); stream.reset(); @@ -322,10 +322,10 @@ public void resetTestNoException() throws IOException { @Test public void resetExceptionTest() throws IOException { //Testing that the exception is thrown, not using specific one because of .NET compatability - Assert.assertThrows(Exception.class,() -> { + Assertions.assertThrows(Exception.class,() -> { try (java.io.OutputStream bytes = IO_EXCEPTION_OUTPUT_STREAM; - OutputStream stream - = new OutputStream<>(bytes)) { + HighPrecisionOutputStream stream + = new HighPrecisionOutputStream<>(bytes)) { stream.reset(); } }); @@ -334,20 +334,20 @@ public void resetExceptionTest() throws IOException { @Test public void localHighPrecisionOverridesGlobalTest() throws IOException { - boolean highPrecision = OutputStream.getHighPrecision(); + boolean highPrecision = HighPrecisionOutputStream.getHighPrecision(); //the data is random double numberToWrite = 2.000002d; try (ByteArrayOutputStream bytes = new ByteArrayOutputStream(); - OutputStream stream - = new OutputStream<>(bytes, false)) { - OutputStream.setHighPrecision(true); + HighPrecisionOutputStream stream + = new HighPrecisionOutputStream<>(bytes, false)) { + HighPrecisionOutputStream.setHighPrecision(true); stream.setLocalHighPrecision(false); stream.writeDouble(numberToWrite); stream.flush(); - Assert.assertEquals("2", new String(bytes.toByteArray(), StandardCharsets.UTF_8)); + Assertions.assertEquals("2", new String(bytes.toByteArray(), StandardCharsets.UTF_8)); } finally { - OutputStream.setHighPrecision(highPrecision); + HighPrecisionOutputStream.setHighPrecision(highPrecision); } } } diff --git a/io/src/test/java/com/itextpdf/io/source/PagedChannelRandomAccessSourceTest.java b/io/src/test/java/com/itextpdf/io/source/PagedChannelRandomAccessSourceTest.java index 81ef1ec00f..4fd14c3765 100644 --- a/io/src/test/java/com/itextpdf/io/source/PagedChannelRandomAccessSourceTest.java +++ b/io/src/test/java/com/itextpdf/io/source/PagedChannelRandomAccessSourceTest.java @@ -23,17 +23,16 @@ This file is part of the iText (R) project. package com.itextpdf.io.source; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; import java.io.RandomAccessFile; import java.nio.ByteBuffer; import java.nio.channels.FileChannel; -@Category(UnitTest.class) +@Tag("UnitTest") public class PagedChannelRandomAccessSourceTest extends ExtendedITextTest { private final static String SOURCE_FILE = "./src/test/resources/com/itextpdf/io/source/RAF.txt"; @@ -46,12 +45,12 @@ public void readBytesFromFileTest() throws IOException { byte[] expected = new byte[] {72, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100, 33}; byte[] result = new byte[13]; source.get(0, result, 0, 13); - Assert.assertArrayEquals(expected, result); + Assertions.assertArrayEquals(expected, result); expected = new byte[] {111, 44, 32, 119, 111, 114, 108, 100}; result = new byte[8]; source.get(4, result, 0, 8); - Assert.assertArrayEquals(expected, result); + Assertions.assertArrayEquals(expected, result); } } @@ -61,12 +60,12 @@ public void readIntFromFileTest() throws IOException { try (RandomAccessFile raf = new RandomAccessFile(SOURCE_FILE, "r")) { FileChannel channel = raf.getChannel(); source = new PagedChannelRandomAccessSource(channel, 10, 1); - Assert.assertEquals(13, source.length()); - Assert.assertEquals(72, source.get(0)); - Assert.assertEquals(44, source.get(5)); - Assert.assertEquals(33, source.get(12)); - Assert.assertEquals(100, source.get(11)); - Assert.assertEquals(-1, source.get(13)); + Assertions.assertEquals(13, source.length()); + Assertions.assertEquals(72, source.get(0)); + Assertions.assertEquals(44, source.get(5)); + Assertions.assertEquals(33, source.get(12)); + Assertions.assertEquals(100, source.get(11)); + Assertions.assertEquals(-1, source.get(13)); } } diff --git a/io/src/test/java/com/itextpdf/io/source/PdfTokenizerTest.java b/io/src/test/java/com/itextpdf/io/source/PdfTokenizerTest.java index 2377a5742e..3e31e9c575 100644 --- a/io/src/test/java/com/itextpdf/io/source/PdfTokenizerTest.java +++ b/io/src/test/java/com/itextpdf/io/source/PdfTokenizerTest.java @@ -25,16 +25,15 @@ This file is part of the iText (R) project. import com.itextpdf.commons.utils.MessageFormatUtil; import com.itextpdf.io.source.PdfTokenizer.TokenType; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.IOException; import java.nio.charset.StandardCharsets; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import static com.itextpdf.io.exceptions.IoExceptionMessageConstant.ERROR_AT_FILE_POINTER; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfTokenizerTest extends ExtendedITextTest { private static final String sourceFolder = "./src/test/resources/com/itextpdf/io/util/"; @@ -50,22 +49,61 @@ public void seekTest() throws IOException { tok.seek(0); tok.nextValidToken(); - Assert.assertEquals(expectedTypes[0], tok.getTokenType()); - Assert.assertEquals("Name1", tok.getStringValue()); + Assertions.assertEquals(expectedTypes[0], tok.getTokenType()); + Assertions.assertEquals("Name1", tok.getStringValue()); tok.seek(7); tok.nextValidToken(); - Assert.assertEquals(expectedTypes[1], tok.getTokenType()); - Assert.assertEquals("70", tok.getStringValue()); + Assertions.assertEquals(expectedTypes[1], tok.getTokenType()); + Assertions.assertEquals("70", tok.getStringValue()); tok.seek(8); tok.nextValidToken(); - Assert.assertEquals(expectedTypes[1], tok.getTokenType()); - Assert.assertEquals("0", tok.getStringValue()); + Assertions.assertEquals(expectedTypes[1], tok.getTokenType()); + Assertions.assertEquals("0", tok.getStringValue()); tok.seek(9); tok.nextValidToken(); - Assert.assertEquals(expectedTypes[2], tok.getTokenType()); + Assertions.assertEquals(expectedTypes[2], tok.getTokenType()); + } + + @Test + public void peekTest() throws IOException { + String data = "/Name1 70"; + + PdfTokenizer tokenizer = new PdfTokenizer(new RandomAccessFileOrArray( + new RandomAccessSourceFactory().createSource(data.getBytes(StandardCharsets.ISO_8859_1)))); + + tokenizer.seek(0); + int symbol = tokenizer.peek(); + Assertions.assertEquals((int)'/', symbol); + Assertions.assertEquals(0, tokenizer.getPosition()); + + tokenizer.seek(7); + symbol = tokenizer.peek(); + Assertions.assertEquals((int)'7', symbol); + Assertions.assertEquals(7, tokenizer.getPosition()); + + tokenizer.seek(9); + symbol = tokenizer.peek(); + Assertions.assertEquals(-1, symbol); + Assertions.assertEquals(9, tokenizer.getPosition()); + + byte[] name = new byte[6]; + tokenizer.seek(0); + int read = tokenizer.peek(name); + byte[] expected = "/Name1".getBytes(); + Assertions.assertArrayEquals(expected, name); + Assertions.assertEquals(0, tokenizer.getPosition()); + Assertions.assertEquals(6, read); + + byte[] bigBuffer = new byte[13]; + read = tokenizer.peek(bigBuffer); + expected = new byte[] {(byte) 47, (byte) 78, (byte) 97, (byte) 109, (byte) 101, (byte) 49, (byte) 32, + (byte) 55, (byte) 48, (byte) 0, (byte) 0, (byte) 0, (byte) 0}; + Assertions.assertArrayEquals(expected, bigBuffer); + Assertions.assertEquals(0, tokenizer.getPosition()); + Assertions.assertEquals(9, read); } @Test @@ -77,8 +115,8 @@ public void getLongValueTest() throws IOException { factory.createSource(data.getBytes(StandardCharsets.ISO_8859_1)))); tok.nextValidToken(); - Assert.assertEquals(TokenType.Number, tok.getTokenType()); - Assert.assertEquals(21474836470L, tok.getLongValue()); + Assertions.assertEquals(TokenType.Number, tok.getTokenType()); + Assertions.assertEquals(21474836470L, tok.getLongValue()); } @Test @@ -90,8 +128,8 @@ public void getIntValueTest() throws IOException { factory.createSource(data.getBytes(StandardCharsets.ISO_8859_1)))); tok.nextValidToken(); - Assert.assertEquals(TokenType.Number, tok.getTokenType()); - Assert.assertEquals(15, tok.getIntValue()); + Assertions.assertEquals(TokenType.Number, tok.getTokenType()); + Assertions.assertEquals(15, tok.getIntValue()); } @Test @@ -102,11 +140,11 @@ public void getPositionTest() throws IOException { PdfTokenizer tok = new PdfTokenizer(new RandomAccessFileOrArray( factory.createSource(data.getBytes(StandardCharsets.ISO_8859_1)))); - Assert.assertEquals(0, tok.getPosition()); + Assertions.assertEquals(0, tok.getPosition()); tok.nextValidToken(); - Assert.assertEquals(6, tok.getPosition()); + Assertions.assertEquals(6, tok.getPosition()); tok.nextValidToken(); - Assert.assertEquals(11, tok.getPosition()); + Assertions.assertEquals(11, tok.getPosition()); } @Test @@ -117,7 +155,7 @@ public void lengthTest() throws IOException { PdfTokenizer tok = new PdfTokenizer(new RandomAccessFileOrArray( factory.createSource(data.getBytes(StandardCharsets.ISO_8859_1)))); - Assert.assertEquals(6, tok.length()); + Assertions.assertEquals(6, tok.length()); } @Test @@ -128,7 +166,7 @@ public void lengthTwoTokenTest() throws IOException { PdfTokenizer tok = new PdfTokenizer(new RandomAccessFileOrArray( factory.createSource(data.getBytes(StandardCharsets.ISO_8859_1)))); - Assert.assertEquals(9, tok.length()); + Assertions.assertEquals(9, tok.length()); } @Test @@ -144,7 +182,7 @@ public void readTest() throws IOException { (byte) tok.read(), (byte) tok.read(), (byte) tok.read(), (byte) tok.read() }; - Assert.assertEquals("/Name1 ", new String(read)); + Assertions.assertEquals("/Name1 ", new String(read)); } @Test @@ -155,7 +193,7 @@ public void readStringFullTest() throws IOException { PdfTokenizer tok = new PdfTokenizer(new RandomAccessFileOrArray( factory.createSource(data.getBytes(StandardCharsets.ISO_8859_1)))); - Assert.assertEquals(data, tok.readString(data.length())); + Assertions.assertEquals(data, tok.readString(data.length())); } @Test @@ -166,7 +204,7 @@ public void readStringShortTest() throws IOException { PdfTokenizer tok = new PdfTokenizer(new RandomAccessFileOrArray( factory.createSource(data.getBytes(StandardCharsets.ISO_8859_1)))); - Assert.assertEquals("/Name", tok.readString(5)); + Assertions.assertEquals("/Name", tok.readString(5)); } @Test @@ -177,7 +215,7 @@ public void readStringLongerThenDataTest() throws IOException { PdfTokenizer tok = new PdfTokenizer(new RandomAccessFileOrArray( factory.createSource(data.getBytes(StandardCharsets.ISO_8859_1)))); - Assert.assertEquals(data, tok.readString(data.length() + 10)); + Assertions.assertEquals(data, tok.readString(data.length() + 10)); } @Test @@ -189,7 +227,7 @@ public void readFullyPartThenReadStringTest() throws IOException { factory.createSource(data.getBytes(StandardCharsets.ISO_8859_1)))); tok.readFully(new byte[6]); - Assert.assertEquals(" 15", tok.readString(data.length())); + Assertions.assertEquals(" 15", tok.readString(data.length())); } @Test @@ -201,7 +239,7 @@ public void readFullyThenReadStringTest() throws IOException { factory.createSource(data.getBytes(StandardCharsets.ISO_8859_1)))); tok.readFully(new byte[7]); - Assert.assertEquals("15", tok.readString(data.length())); + Assertions.assertEquals("15", tok.readString(data.length())); } @Test @@ -212,7 +250,7 @@ public void getNextEofShortTextTest() throws IOException { try (PdfTokenizer tok = new PdfTokenizer(new RandomAccessFileOrArray( factory.createSource(data.getBytes(StandardCharsets.ISO_8859_1))))) { long eofPosition = tok.getNextEof(); - Assert.assertEquals(data.length() + 1, eofPosition); + Assertions.assertEquals(data.length(), eofPosition); } } @@ -229,7 +267,7 @@ public void getNextEofLongTextTest() throws IOException { try (PdfTokenizer tok = new PdfTokenizer(new RandomAccessFileOrArray( factory.createSource(stringBuilder.toString().getBytes(StandardCharsets.ISO_8859_1))))) { long eofPosition = tok.getNextEof(); - Assert.assertEquals(data.length() * 20 + 6, eofPosition); + Assertions.assertEquals(data.length() * 20 + 5, eofPosition); } } @@ -247,7 +285,7 @@ public void getNextEofWhichIsCutTest() throws IOException { try (PdfTokenizer tok = new PdfTokenizer(new RandomAccessFileOrArray( factory.createSource(stringBuilder.toString().getBytes(StandardCharsets.ISO_8859_1))))) { long eofPosition = tok.getNextEof(); - Assert.assertEquals(124 + 6, eofPosition); + Assertions.assertEquals(124 + 5, eofPosition); } } @@ -259,7 +297,19 @@ public void getNextEofSeveralEofTest() throws IOException { try (PdfTokenizer tok = new PdfTokenizer(new RandomAccessFileOrArray( factory.createSource(data.getBytes(StandardCharsets.ISO_8859_1))))) { long eofPosition = tok.getNextEof(); - Assert.assertEquals(data.indexOf("%%EOF") + 6, eofPosition); + Assertions.assertEquals(data.indexOf("%%EOF") + 5, eofPosition); + } + } + + @Test + public void getNextEofFollowedByEOLTest() throws IOException { + String data = "some text to test \ngetting end of\n file logic%%EOF\n\r\r\n\r\r\n"; + + RandomAccessSourceFactory factory = new RandomAccessSourceFactory(); + try (PdfTokenizer tok = new PdfTokenizer(new RandomAccessFileOrArray( + factory.createSource(data.getBytes(StandardCharsets.ISO_8859_1))))) { + long eofPosition = tok.getNextEof(); + Assertions.assertEquals(data.indexOf("%%EOF") + 4 + 5, eofPosition); } } @@ -270,7 +320,7 @@ public void getNextEofNoEofTest() throws IOException { RandomAccessSourceFactory factory = new RandomAccessSourceFactory(); try (PdfTokenizer tok = new PdfTokenizer(new RandomAccessFileOrArray( factory.createSource(data.getBytes(StandardCharsets.ISO_8859_1))))) { - Assert.assertThrows(com.itextpdf.io.exceptions.IOException.class, () -> tok.getNextEof()); + Assertions.assertThrows(com.itextpdf.io.exceptions.IOException.class, () -> tok.getNextEof()); } } @@ -283,13 +333,13 @@ public void getDecodedStringContentTest() throws IOException { factory.createSource(data.getBytes(StandardCharsets.ISO_8859_1)))); tok.nextToken(); - Assert.assertEquals("Name1", new String(tok.getDecodedStringContent())); + Assertions.assertEquals("Name1", new String(tok.getDecodedStringContent())); tok.nextToken(); - Assert.assertEquals("15", new String(tok.getDecodedStringContent())); + Assertions.assertEquals("15", new String(tok.getDecodedStringContent())); tok.nextToken(); - Assert.assertEquals("", new String(tok.getDecodedStringContent())); + Assertions.assertEquals("", new String(tok.getDecodedStringContent())); } @Test @@ -301,8 +351,8 @@ public void getDecodedStringContentHexTest() throws IOException { factory.createSource(data.getBytes(StandardCharsets.ISO_8859_1)))); tok.nextToken(); - Assert.assertTrue(tok.isHexString()); - Assert.assertEquals("some hex string", new String(tok.getDecodedStringContent())); + Assertions.assertTrue(tok.isHexString()); + Assertions.assertEquals("some hex string", new String(tok.getDecodedStringContent())); } @Test @@ -311,10 +361,10 @@ public void throwErrorTest() { PdfTokenizer tok = new PdfTokenizer(new RandomAccessFileOrArray( factory.createSource("/Name1".getBytes(StandardCharsets.ISO_8859_1)))); - Exception e = Assert.assertThrows(com.itextpdf.io.exceptions.IOException.class, + Exception e = Assertions.assertThrows(com.itextpdf.io.exceptions.IOException.class, () -> tok.throwError(ERROR_AT_FILE_POINTER, 0) ); - Assert.assertEquals(MessageFormatUtil.format(ERROR_AT_FILE_POINTER, 0), e.getMessage()); + Assertions.assertEquals(MessageFormatUtil.format(ERROR_AT_FILE_POINTER, 0), e.getMessage()); } @Test @@ -358,7 +408,7 @@ public void tokenValueEqualsToTest() throws IOException { PdfTokenizer tok = new PdfTokenizer(new RandomAccessFileOrArray(factory.createSource(data.getBytes(StandardCharsets.ISO_8859_1)))); tok.nextToken(); - Assert.assertTrue(tok.tokenValueEqualsTo(data.getBytes(StandardCharsets.ISO_8859_1))); + Assertions.assertTrue(tok.tokenValueEqualsTo(data.getBytes(StandardCharsets.ISO_8859_1))); } @Test @@ -369,7 +419,7 @@ public void tokenValueEqualsToNullTest() throws IOException { PdfTokenizer tok = new PdfTokenizer(new RandomAccessFileOrArray(factory.createSource(data.getBytes(StandardCharsets.ISO_8859_1)))); tok.nextToken(); - Assert.assertFalse(tok.tokenValueEqualsTo(null)); + Assertions.assertFalse(tok.tokenValueEqualsTo(null)); } @Test @@ -380,7 +430,7 @@ public void tokenValueEqualsToNotSameStringTest() throws IOException { PdfTokenizer tok = new PdfTokenizer(new RandomAccessFileOrArray(factory.createSource(data.getBytes(StandardCharsets.ISO_8859_1)))); tok.nextToken(); - Assert.assertFalse(tok.tokenValueEqualsTo((data + "s").getBytes(StandardCharsets.ISO_8859_1))); + Assertions.assertFalse(tok.tokenValueEqualsTo((data + "s").getBytes(StandardCharsets.ISO_8859_1))); } @Test @@ -391,7 +441,7 @@ public void tokenValueEqualsToNotCaseSensitiveStringTest() throws IOException { PdfTokenizer tok = new PdfTokenizer(new RandomAccessFileOrArray(factory.createSource(data.getBytes(StandardCharsets.ISO_8859_1)))); tok.nextToken(); - Assert.assertFalse(tok.tokenValueEqualsTo("Somestring".getBytes(StandardCharsets.ISO_8859_1))); + Assertions.assertFalse(tok.tokenValueEqualsTo("Somestring".getBytes(StandardCharsets.ISO_8859_1))); } @Test @@ -399,7 +449,7 @@ public void checkPdfHeaderTest() throws IOException { RandomAccessSourceFactory factory = new RandomAccessSourceFactory(); PdfTokenizer tok = new PdfTokenizer(new RandomAccessFileOrArray(factory.createBestSource(sourceFolder + "test.pdf"))); - Assert.assertEquals("PDF-1.7", tok.checkPdfHeader()); + Assertions.assertEquals("PDF-1.7", tok.checkPdfHeader()); } @Test @@ -407,7 +457,7 @@ public void getHeaderOffsetTest() throws IOException { RandomAccessSourceFactory factory = new RandomAccessSourceFactory(); PdfTokenizer tok = new PdfTokenizer(new RandomAccessFileOrArray(factory.createBestSource(sourceFolder + "test.pdf"))); - Assert.assertEquals(0, tok.getHeaderOffset()); + Assertions.assertEquals(0, tok.getHeaderOffset()); } @Test @@ -423,90 +473,90 @@ public void primitivesTest() throws Exception { PdfTokenizer tok = new PdfTokenizer(new RandomAccessFileOrArray(factory.createSource(data.getBytes(StandardCharsets.ISO_8859_1)))); tok.nextValidToken(); - Assert.assertEquals(PdfTokenizer.TokenType.StartDic, tok.getTokenType()); + Assertions.assertEquals(PdfTokenizer.TokenType.StartDic, tok.getTokenType()); tok.nextValidToken(); - Assert.assertEquals(PdfTokenizer.TokenType.Name, tok.getTokenType()); - Assert.assertEquals("Size", new String(tok.getByteContent())); + Assertions.assertEquals(PdfTokenizer.TokenType.Name, tok.getTokenType()); + Assertions.assertEquals("Size", new String(tok.getByteContent())); tok.nextValidToken(); - Assert.assertEquals(PdfTokenizer.TokenType.Number, tok.getTokenType()); - Assert.assertEquals("70.", new String(tok.getByteContent())); + Assertions.assertEquals(PdfTokenizer.TokenType.Number, tok.getTokenType()); + Assertions.assertEquals("70.", new String(tok.getByteContent())); tok.nextValidToken(); - Assert.assertEquals(PdfTokenizer.TokenType.Name, tok.getTokenType()); - Assert.assertEquals("Value#20", new String(tok.getByteContent())); + Assertions.assertEquals(PdfTokenizer.TokenType.Name, tok.getTokenType()); + Assertions.assertEquals("Value#20", new String(tok.getByteContent())); tok.nextValidToken(); - Assert.assertEquals(PdfTokenizer.TokenType.Number, tok.getTokenType()); - Assert.assertEquals(".1", new String(tok.getByteContent())); + Assertions.assertEquals(PdfTokenizer.TokenType.Number, tok.getTokenType()); + Assertions.assertEquals(".1", new String(tok.getByteContent())); tok.nextValidToken(); - Assert.assertEquals(PdfTokenizer.TokenType.Name, tok.getTokenType()); - Assert.assertEquals("Root", new String(tok.getByteContent())); + Assertions.assertEquals(PdfTokenizer.TokenType.Name, tok.getTokenType()); + Assertions.assertEquals("Root", new String(tok.getByteContent())); tok.nextValidToken(); - Assert.assertEquals(PdfTokenizer.TokenType.Ref, tok.getTokenType()); - Assert.assertEquals("46 0 R", "" + tok.getObjNr() + " " + tok.getGenNr() + Assertions.assertEquals(PdfTokenizer.TokenType.Ref, tok.getTokenType()); + Assertions.assertEquals("46 0 R", "" + tok.getObjNr() + " " + tok.getGenNr() + " " + new String(tok.getByteContent())); tok.nextValidToken(); - Assert.assertEquals(PdfTokenizer.TokenType.Name, tok.getTokenType()); - Assert.assertEquals("Info", new String(tok.getByteContent())); + Assertions.assertEquals(PdfTokenizer.TokenType.Name, tok.getTokenType()); + Assertions.assertEquals("Info", new String(tok.getByteContent())); tok.nextValidToken(); - Assert.assertEquals(PdfTokenizer.TokenType.Ref, tok.getTokenType()); - Assert.assertEquals("44 0 R", "" + tok.getObjNr() + " " + tok.getGenNr() + Assertions.assertEquals(PdfTokenizer.TokenType.Ref, tok.getTokenType()); + Assertions.assertEquals("44 0 R", "" + tok.getObjNr() + " " + tok.getGenNr() + " " + new String(tok.getByteContent())); tok.nextValidToken(); - Assert.assertEquals(PdfTokenizer.TokenType.Name, tok.getTokenType()); - Assert.assertEquals("ID", new String(tok.getByteContent())); + Assertions.assertEquals(PdfTokenizer.TokenType.Name, tok.getTokenType()); + Assertions.assertEquals("ID", new String(tok.getByteContent())); tok.nextValidToken(); - Assert.assertEquals(PdfTokenizer.TokenType.StartArray, tok.getTokenType()); + Assertions.assertEquals(PdfTokenizer.TokenType.StartArray, tok.getTokenType()); tok.nextValidToken(); - Assert.assertEquals(PdfTokenizer.TokenType.String, tok.getTokenType()); - Assert.assertTrue(tok.isHexString()); - Assert.assertEquals("736f6d652068657820737472696e672", new String(tok.getByteContent())); + Assertions.assertEquals(PdfTokenizer.TokenType.String, tok.getTokenType()); + Assertions.assertTrue(tok.isHexString()); + Assertions.assertEquals("736f6d652068657820737472696e672", new String(tok.getByteContent())); tok.nextValidToken(); - Assert.assertEquals(PdfTokenizer.TokenType.String, tok.getTokenType()); - Assert.assertFalse(tok.isHexString()); - Assert.assertEquals("some simple string ", new String(tok.getByteContent())); + Assertions.assertEquals(PdfTokenizer.TokenType.String, tok.getTokenType()); + Assertions.assertFalse(tok.isHexString()); + Assertions.assertEquals("some simple string ", new String(tok.getByteContent())); tok.nextValidToken(); - Assert.assertEquals(PdfTokenizer.TokenType.String, tok.getTokenType()); - Assert.assertTrue(tok.isHexString()); - Assert.assertEquals("8C2547D58D4BD2C6F3D32B830BE3259D2", new String(tok.getByteContent())); + Assertions.assertEquals(PdfTokenizer.TokenType.String, tok.getTokenType()); + Assertions.assertTrue(tok.isHexString()); + Assertions.assertEquals("8C2547D58D4BD2C6F3D32B830BE3259D2", new String(tok.getByteContent())); tok.nextValidToken(); - Assert.assertEquals(PdfTokenizer.TokenType.Number, tok.getTokenType()); - Assert.assertEquals("-70.1", new String(tok.getByteContent())); + Assertions.assertEquals(PdfTokenizer.TokenType.Number, tok.getTokenType()); + Assertions.assertEquals("-70.1", new String(tok.getByteContent())); tok.nextValidToken(); - Assert.assertEquals(PdfTokenizer.TokenType.Number, tok.getTokenType()); - Assert.assertEquals("-0.2", new String(tok.getByteContent())); + Assertions.assertEquals(PdfTokenizer.TokenType.Number, tok.getTokenType()); + Assertions.assertEquals("-0.2", new String(tok.getByteContent())); tok.nextValidToken(); - Assert.assertEquals(PdfTokenizer.TokenType.EndArray, tok.getTokenType()); + Assertions.assertEquals(PdfTokenizer.TokenType.EndArray, tok.getTokenType()); tok.nextValidToken(); - Assert.assertEquals(PdfTokenizer.TokenType.Name, tok.getTokenType()); - Assert.assertEquals("Name1", new String(tok.getByteContent())); + Assertions.assertEquals(PdfTokenizer.TokenType.Name, tok.getTokenType()); + Assertions.assertEquals("Name1", new String(tok.getByteContent())); tok.nextValidToken(); - Assert.assertEquals(PdfTokenizer.TokenType.Number, tok.getTokenType()); - Assert.assertEquals("0", new String(tok.getByteContent())); + Assertions.assertEquals(PdfTokenizer.TokenType.Number, tok.getTokenType()); + Assertions.assertEquals("0", new String(tok.getByteContent())); tok.nextValidToken(); - Assert.assertEquals(PdfTokenizer.TokenType.Name, tok.getTokenType()); - Assert.assertEquals("Prev", new String(tok.getByteContent())); + Assertions.assertEquals(PdfTokenizer.TokenType.Name, tok.getTokenType()); + Assertions.assertEquals("Prev", new String(tok.getByteContent())); tok.nextValidToken(); - Assert.assertEquals(PdfTokenizer.TokenType.Number, tok.getTokenType()); - Assert.assertEquals("-116.23", new String(tok.getByteContent())); + Assertions.assertEquals(PdfTokenizer.TokenType.Number, tok.getTokenType()); + Assertions.assertEquals("-116.23", new String(tok.getByteContent())); } @Test @@ -514,7 +564,7 @@ public void octalNumberLong1Test() { // 49 equal to string "1", octal 1 equals to 1 in decimal byte[] bytes = new byte[] {92, 49}; byte[] result = PdfTokenizer.decodeStringContent(bytes, false); - Assert.assertArrayEquals(new byte[] {1}, result); + Assertions.assertArrayEquals(new byte[] {1}, result); } @Test @@ -522,7 +572,7 @@ public void octalNumberLong2Test() { // 49 50 equal to string "12", octal 12 equals to 10 in decimal byte[] bytes = new byte[] {92, 49, 50}; byte[] result = PdfTokenizer.decodeStringContent(bytes, false); - Assert.assertArrayEquals(new byte[] {10}, result); + Assertions.assertArrayEquals(new byte[] {10}, result); } @Test @@ -530,7 +580,7 @@ public void octalNumberLong3Test() { // 49 50 51 equal to string "123", octal 123 equals to 83 in decimal byte[] bytes = new byte[] {92, 49, 50, 51}; byte[] result = PdfTokenizer.decodeStringContent(bytes, false); - Assert.assertArrayEquals(new byte[] {83}, result); + Assertions.assertArrayEquals(new byte[] {83}, result); } @Test @@ -538,7 +588,7 @@ public void slashAfterShortOctalTest() { // \0\( byte[] bytes = new byte[] {92, 48, 92, 40}; byte[] result = PdfTokenizer.decodeStringContent(bytes, false); - Assert.assertArrayEquals(new byte[] {0, 40}, result); + Assertions.assertArrayEquals(new byte[] {0, 40}, result); } @Test @@ -546,7 +596,7 @@ public void notOctalAfterShortOctalTest() { // \0& byte[] bytes = new byte[] {92, 48, 26}; byte[] result = PdfTokenizer.decodeStringContent(bytes, false); - Assert.assertArrayEquals(new byte[] {0, 26}, result); + Assertions.assertArrayEquals(new byte[] {0, 26}, result); } @Test @@ -554,7 +604,7 @@ public void notOctalAfterShortOctalTest2() { // \12& byte[] bytes = new byte[] {92, 49, 50, 26}; byte[] result = PdfTokenizer.decodeStringContent(bytes, false); - Assert.assertArrayEquals(new byte[] {10, 26}, result); + Assertions.assertArrayEquals(new byte[] {10, 26}, result); } @Test @@ -562,7 +612,7 @@ public void twoShortOctalsWithGarbageTest() { // \0\23 + 4 which should not be taken into account byte[] bytes = new byte[] {92, 48, 92, 50, 51, 52}; byte[] result = PdfTokenizer.decodeStringContent(bytes, 0, 4, false); - Assert.assertArrayEquals(new byte[] {0, 19}, result); + Assertions.assertArrayEquals(new byte[] {0, 19}, result); } private void checkTokenTypes(String data, TokenType... expectedTypes) throws Exception { @@ -572,7 +622,7 @@ private void checkTokenTypes(String data, TokenType... expectedTypes) throws Exc for (int i = 0; i < expectedTypes.length; i++) { tok.nextValidToken(); - Assert.assertEquals("Position " + i, expectedTypes[i], tok.getTokenType()); + Assertions.assertEquals(expectedTypes[i], tok.getTokenType(), "Position " + i); } } @@ -583,7 +633,7 @@ private void checkTokenValues(String data, byte[]... expectedValues) throws Exce for (int i = 0; i < expectedValues.length; i++) { tok.nextValidToken(); - Assert.assertArrayEquals("Position " + i, expectedValues[i], tok.getByteContent()); + Assertions.assertArrayEquals(expectedValues[i], tok.getByteContent(), "Position " + i); } } } diff --git a/io/src/test/java/com/itextpdf/io/source/RAFRandomAccessSourceTest.java b/io/src/test/java/com/itextpdf/io/source/RAFRandomAccessSourceTest.java index ef89baaed6..70a88fee0d 100644 --- a/io/src/test/java/com/itextpdf/io/source/RAFRandomAccessSourceTest.java +++ b/io/src/test/java/com/itextpdf/io/source/RAFRandomAccessSourceTest.java @@ -24,16 +24,15 @@ This file is part of the iText (R) project. import com.itextpdf.commons.utils.FileUtil; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.File; import java.io.IOException; import java.io.RandomAccessFile; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class RAFRandomAccessSourceTest extends ExtendedITextTest { private final static String SOURCE_FILE = "./src/test/resources/com/itextpdf/io/source/RAF.txt"; @@ -46,7 +45,7 @@ public void getByIndexTest() throws IOException { try (RandomAccessFile raf = FileUtil.getRandomAccessFile(file)) { RAFRandomAccessSource source = new RAFRandomAccessSource(raf); for (int i = 0; i < content.length; i++) { - Assert.assertEquals(content[i], source.get(i)); + Assertions.assertEquals(content[i], source.get(i)); } } } @@ -58,8 +57,8 @@ public void getByIndexOutOfBoundsTest() throws IOException { try (RandomAccessFile raf = FileUtil.getRandomAccessFile(file)) { RAFRandomAccessSource source = new RAFRandomAccessSource(raf); - Assert.assertNotEquals(-1, source.get(indexOutOfBounds - 1)); - Assert.assertEquals(-1, source.get(indexOutOfBounds)); + Assertions.assertNotEquals(-1, source.get(indexOutOfBounds - 1)); + Assertions.assertEquals(-1, source.get(indexOutOfBounds)); } } @@ -75,9 +74,9 @@ public void getArrayByIndexesTest() throws IOException { int read = source.get(beginIndex, dest, 0, length); - Assert.assertEquals(length, read); + Assertions.assertEquals(length, read); for (int i = 0; i < length; i++) { - Assert.assertEquals(content[beginIndex + i], dest[i]); + Assertions.assertEquals(content[beginIndex + i], dest[i]); } } } @@ -94,9 +93,9 @@ public void getArrayByIndexesNotEnoughBytesTest() throws IOException { byte[] dest = new byte[24]; int read = source.get(beginIndex, dest, 0, length); - Assert.assertEquals(expectedLength, read); + Assertions.assertEquals(expectedLength, read); for (int i = 0; i < expectedLength; i++) { - Assert.assertEquals(content[beginIndex + i], dest[i]); + Assertions.assertEquals(content[beginIndex + i], dest[i]); } } } @@ -114,9 +113,9 @@ public void getArrayByIndexesWithOffsetTest() throws IOException { int read = source.get(beginIndex, dest, offset, length); - Assert.assertEquals(length, read); + Assertions.assertEquals(length, read); for (int i = 0; i < length; i++) { - Assert.assertEquals(content[beginIndex + i], dest[offset + i]); + Assertions.assertEquals(content[beginIndex + i], dest[offset + i]); } } } @@ -133,9 +132,9 @@ public void getArrayByIndexesOutOfBounds() throws IOException { int read = source.get(beginIndex, dest, 0, length); - Assert.assertEquals(-1, read); + Assertions.assertEquals(-1, read); for (int i = 0; i < dest.length; i++) { - Assert.assertEquals(0, dest[i]); + Assertions.assertEquals(0, dest[i]); } } } diff --git a/io/src/test/java/com/itextpdf/io/source/RandomAccessSourceFactoryTest.java b/io/src/test/java/com/itextpdf/io/source/RandomAccessSourceFactoryTest.java index c35ed00f1a..1319c8a384 100644 --- a/io/src/test/java/com/itextpdf/io/source/RandomAccessSourceFactoryTest.java +++ b/io/src/test/java/com/itextpdf/io/source/RandomAccessSourceFactoryTest.java @@ -25,15 +25,14 @@ This file is part of the iText (R) project. import com.itextpdf.commons.utils.FileUtil; import com.itextpdf.io.exceptions.IoExceptionMessageConstant; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.IOException; import java.io.InputStream; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class RandomAccessSourceFactoryTest extends ExtendedITextTest { private final static String SOURCE_FILE = "./src/test/resources/com/itextpdf/io/source/RAF.txt"; @@ -51,18 +50,18 @@ public void readRASInputStreamClosedTest() throws IOException { extractedRandomAccessSource.close(); - Exception e = Assert.assertThrows(IllegalStateException.class, () -> rasInputStream.read()); - Assert.assertEquals(IoExceptionMessageConstant.ALREADY_CLOSED, e.getMessage()); + Exception e = Assertions.assertThrows(IllegalStateException.class, () -> rasInputStream.read()); + Assertions.assertEquals(IoExceptionMessageConstant.ALREADY_CLOSED, e.getMessage()); - e = Assert.assertThrows(IllegalStateException.class, + e = Assertions.assertThrows(IllegalStateException.class, () -> randomAccessSource.get(0)); - Assert.assertEquals(IoExceptionMessageConstant.ALREADY_CLOSED, e.getMessage()); - e = Assert.assertThrows(IllegalStateException.class, + Assertions.assertEquals(IoExceptionMessageConstant.ALREADY_CLOSED, e.getMessage()); + e = Assertions.assertThrows(IllegalStateException.class, () -> randomAccessSource.get(0, new byte[10], 0, 10)); - Assert.assertEquals(IoExceptionMessageConstant.ALREADY_CLOSED, e.getMessage()); - e = Assert.assertThrows(IllegalStateException.class, + Assertions.assertEquals(IoExceptionMessageConstant.ALREADY_CLOSED, e.getMessage()); + e = Assertions.assertThrows(IllegalStateException.class, () -> randomAccessSource.length()); - Assert.assertEquals(IoExceptionMessageConstant.ALREADY_CLOSED, e.getMessage()); + Assertions.assertEquals(IoExceptionMessageConstant.ALREADY_CLOSED, e.getMessage()); } } @@ -76,9 +75,9 @@ public void readRASInputStreamTest() throws IOException { IRandomAccessSource extractedRandomAccessSource = new RandomAccessSourceFactory() .extractOrCreateSource(rasInputStream); - Assert.assertEquals(72, rasInputStream.read()); - Assert.assertEquals(72, extractedRandomAccessSource.get(0)); - Assert.assertEquals(extractedRandomAccessSource, rasInputStream.getSource()); + Assertions.assertEquals(72, rasInputStream.read()); + Assertions.assertEquals(72, extractedRandomAccessSource.get(0)); + Assertions.assertEquals(extractedRandomAccessSource, rasInputStream.getSource()); } } } diff --git a/io/src/test/java/com/itextpdf/io/source/WriteNumbersTest.java b/io/src/test/java/com/itextpdf/io/source/WriteNumbersTest.java index b2840350b2..6d9ebaf35f 100644 --- a/io/src/test/java/com/itextpdf/io/source/WriteNumbersTest.java +++ b/io/src/test/java/com/itextpdf/io/source/WriteNumbersTest.java @@ -27,16 +27,15 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.UnitTest; import java.nio.charset.StandardCharsets; import java.util.Random; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class WriteNumbersTest extends ExtendedITextTest { public static double round(double value, int places) { @@ -56,7 +55,7 @@ public void writeNumber1Test() { byte[] actuals = ByteUtils.getIsoBytes(d); byte[] expecteds = DecimalFormatUtil.formatNumber(d, "0.##").getBytes(StandardCharsets.ISO_8859_1); String message = "Expects: " + new String(expecteds) + ", actual: " + new String(actuals) + " \\\\ "+ d; - Assert.assertArrayEquals(message, expecteds, actuals); + Assertions.assertArrayEquals(expecteds, actuals, message); } } @@ -70,7 +69,7 @@ public void writeNumber2Test() { byte[] actuals = ByteUtils.getIsoBytes(d); byte[] expecteds = DecimalFormatUtil.formatNumber(d, "0.#####").getBytes(StandardCharsets.ISO_8859_1); String message = "Expects: " + new String(expecteds) + ", actual: " + new String(actuals) + " \\\\ " + d; - Assert.assertArrayEquals(message, expecteds, actuals); + Assertions.assertArrayEquals(expecteds, actuals, message); } } @@ -83,7 +82,7 @@ public void writeNumber3Test() { byte[] actuals = ByteUtils.getIsoBytes(d); byte[] expecteds = DecimalFormatUtil.formatNumber(d, "0").getBytes(StandardCharsets.ISO_8859_1); String message = "Expects: " + new String(expecteds) + ", actual: " + new String(actuals) + " \\\\ "+ d; - Assert.assertArrayEquals(message, expecteds, actuals); + Assertions.assertArrayEquals(expecteds, actuals, message); } } @@ -96,7 +95,7 @@ public void writeNanTest() { byte[] expecteds = DecimalFormatUtil.formatNumber(0, "0.##").getBytes(StandardCharsets.ISO_8859_1); String message = "Expects: " + new String(expecteds) + ", actual: " + new String(actuals) + " \\\\ "+ d; - Assert.assertArrayEquals(message, expecteds, actuals); + Assertions.assertArrayEquals(expecteds, actuals, message); } @Test @@ -108,6 +107,6 @@ public void writeNanHighPrecisionTest() { byte[] expecteds = DecimalFormatUtil.formatNumber(0, "0.##").getBytes(StandardCharsets.ISO_8859_1); String message = "Expects: " + new String(expecteds) + ", actual: " + new String(actuals) + " \\\\ "+ d; - Assert.assertArrayEquals(message, expecteds, actuals); + Assertions.assertArrayEquals(expecteds, actuals, message); } } diff --git a/io/src/test/java/com/itextpdf/io/source/WriteStringsTest.java b/io/src/test/java/com/itextpdf/io/source/WriteStringsTest.java index 2f8af308fe..43b8e26d13 100644 --- a/io/src/test/java/com/itextpdf/io/source/WriteStringsTest.java +++ b/io/src/test/java/com/itextpdf/io/source/WriteStringsTest.java @@ -23,34 +23,33 @@ This file is part of the iText (R) project. package com.itextpdf.io.source; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.nio.charset.StandardCharsets; -@Category(UnitTest.class) +@Tag("UnitTest") public class WriteStringsTest extends ExtendedITextTest { @Test public void writeStringTest() { String str = "SomeString"; byte[] content = ByteUtils.getIsoBytes(str); - Assert.assertArrayEquals(str.getBytes(StandardCharsets.ISO_8859_1), content); + Assertions.assertArrayEquals(str.getBytes(StandardCharsets.ISO_8859_1), content); } @Test public void writeNameTest() { String str = "SomeName"; byte[] content = ByteUtils.getIsoBytes((byte) '/', str); - Assert.assertArrayEquals(("/" + str).getBytes(StandardCharsets.ISO_8859_1), content); + Assertions.assertArrayEquals(("/" + str).getBytes(StandardCharsets.ISO_8859_1), content); } @Test public void writePdfStringTest() { String str = "Some PdfString"; byte[] content = ByteUtils.getIsoBytes((byte) '(', str, (byte) ')'); - Assert.assertArrayEquals(("(" + str + ")").getBytes(StandardCharsets.ISO_8859_1), content); + Assertions.assertArrayEquals(("(" + str + ")").getBytes(StandardCharsets.ISO_8859_1), content); } } diff --git a/io/src/test/java/com/itextpdf/io/util/DateTimeUtilTest.java b/io/src/test/java/com/itextpdf/io/util/DateTimeUtilTest.java index be742a1edf..de13cd4524 100644 --- a/io/src/test/java/com/itextpdf/io/util/DateTimeUtilTest.java +++ b/io/src/test/java/com/itextpdf/io/util/DateTimeUtilTest.java @@ -24,21 +24,20 @@ This file is part of the iText (R) project. import com.itextpdf.commons.utils.DateTimeUtil; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.util.Calendar; import java.util.Date; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class DateTimeUtilTest extends ExtendedITextTest { @Test public void wrappingDateWithCalendarTest() { Date currentDate = DateTimeUtil.getCurrentTimeDate(); Calendar currentCalendar = DateTimeUtil.getCalendar(currentDate); - Assert.assertEquals(0, currentCalendar.getTime().compareTo(currentDate)); + Assertions.assertEquals(0, currentCalendar.getTime().compareTo(currentDate)); } } diff --git a/io/src/test/java/com/itextpdf/io/util/EnumUtilTest.java b/io/src/test/java/com/itextpdf/io/util/EnumUtilTest.java index b143a8346d..846ecfc644 100644 --- a/io/src/test/java/com/itextpdf/io/util/EnumUtilTest.java +++ b/io/src/test/java/com/itextpdf/io/util/EnumUtilTest.java @@ -23,29 +23,28 @@ This file is part of the iText (R) project. package com.itextpdf.io.util; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class EnumUtilTest extends ExtendedITextTest { @Test public void testEnumUtilSameAmount() { - Assert.assertEquals(3, EnumUtil.getAllValuesOfEnum(TestEnum1.class).size()); + Assertions.assertEquals(3, EnumUtil.getAllValuesOfEnum(TestEnum1.class).size()); } @Test public void testEnumUtilSameValues() { List list = EnumUtil.getAllValuesOfEnum(TestEnum1.class); - Assert.assertTrue(list.contains(TestEnum1.A)); - Assert.assertTrue(list.contains(TestEnum1.B)); - Assert.assertTrue(list.contains(TestEnum1.C)); - Assert.assertEquals(TestEnum1.A, list.get(0)); - Assert.assertEquals(TestEnum1.B, list.get(1)); - Assert.assertEquals(TestEnum1.C, list.get(2)); + Assertions.assertTrue(list.contains(TestEnum1.A)); + Assertions.assertTrue(list.contains(TestEnum1.B)); + Assertions.assertTrue(list.contains(TestEnum1.C)); + Assertions.assertEquals(TestEnum1.A, list.get(0)); + Assertions.assertEquals(TestEnum1.B, list.get(1)); + Assertions.assertEquals(TestEnum1.C, list.get(2)); } } diff --git a/io/src/test/java/com/itextpdf/io/util/GhostScriptHelperUnitTest.java b/io/src/test/java/com/itextpdf/io/util/GhostScriptHelperUnitTest.java index 596fb35097..1623d5ea05 100644 --- a/io/src/test/java/com/itextpdf/io/util/GhostScriptHelperUnitTest.java +++ b/io/src/test/java/com/itextpdf/io/util/GhostScriptHelperUnitTest.java @@ -23,55 +23,54 @@ This file is part of the iText (R) project. package com.itextpdf.io.util; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class GhostScriptHelperUnitTest extends ExtendedITextTest { @Test public void verifyEmptyPageList() { String testPageList = ""; - Assert.assertFalse(GhostscriptHelper.validatePageList(testPageList)); + Assertions.assertFalse(GhostscriptHelper.validatePageList(testPageList)); } @Test public void verifyNullPageList() { String testPageList = null; - Assert.assertTrue(GhostscriptHelper.validatePageList(testPageList)); + Assertions.assertTrue(GhostscriptHelper.validatePageList(testPageList)); } @Test public void verifyPageListWithLeadingSpaces() { String testPageList = " 1"; - Assert.assertFalse(GhostscriptHelper.validatePageList(testPageList)); + Assertions.assertFalse(GhostscriptHelper.validatePageList(testPageList)); } @Test public void verifyPageListWithTrailingSpaces() { String testPageList = "1 "; - Assert.assertFalse(GhostscriptHelper.validatePageList(testPageList)); + Assertions.assertFalse(GhostscriptHelper.validatePageList(testPageList)); } @Test public void verifyValidPageListWithSeveralPages() { String testPageList = "1,2,3"; - Assert.assertTrue(GhostscriptHelper.validatePageList(testPageList)); + Assertions.assertTrue(GhostscriptHelper.validatePageList(testPageList)); } @Test public void verifyValidPageListOfOnePage() { String testPageList = "2"; - Assert.assertTrue(GhostscriptHelper.validatePageList(testPageList)); + Assertions.assertTrue(GhostscriptHelper.validatePageList(testPageList)); } @Test @@ -81,7 +80,7 @@ public void verifyValidPageListOfOnePage() { public void verifyPageListWithNegativePages() { String testPageList = "-2"; - Assert.assertFalse(GhostscriptHelper.validatePageList(testPageList)); + Assertions.assertFalse(GhostscriptHelper.validatePageList(testPageList)); } @Test @@ -91,7 +90,7 @@ public void verifyPageListWithNegativePages() { public void verifyPageListWithSomeNegativePagesInTheMiddle() { String testPageList = "1,-2,3"; - Assert.assertFalse(GhostscriptHelper.validatePageList(testPageList)); + Assertions.assertFalse(GhostscriptHelper.validatePageList(testPageList)); } @Test @@ -101,21 +100,21 @@ public void verifyPageListWithSomeNegativePagesInTheMiddle() { public void verifyPageListWithSomeNegativePagesAtTheEnd() { String testPageList = "1,-2"; - Assert.assertFalse(GhostscriptHelper.validatePageList(testPageList)); + Assertions.assertFalse(GhostscriptHelper.validatePageList(testPageList)); } @Test public void verifyPageListWithOnlyPageZero() { String testPageList = "0"; - Assert.assertTrue(GhostscriptHelper.validatePageList(testPageList)); + Assertions.assertTrue(GhostscriptHelper.validatePageList(testPageList)); } @Test public void verifyPageListWithOneOfPagesBeingZero() { String testPageList = "3,0,2"; - Assert.assertTrue(GhostscriptHelper.validatePageList(testPageList)); + Assertions.assertTrue(GhostscriptHelper.validatePageList(testPageList)); } @Test @@ -123,13 +122,13 @@ public void verifyPageListWithOneOfPagesBeingZero() { public void verifyValidPageListWithDescendingOrder() { String testPageList = "3,2,1"; - Assert.assertTrue(GhostscriptHelper.validatePageList(testPageList)); + Assertions.assertTrue(GhostscriptHelper.validatePageList(testPageList)); } @Test public void verifyTextInPageList() { String testPageList = "1,hello,2"; - Assert.assertFalse(GhostscriptHelper.validatePageList(testPageList)); + Assertions.assertFalse(GhostscriptHelper.validatePageList(testPageList)); } } diff --git a/io/src/test/java/com/itextpdf/io/util/GhostscriptHelperTest.java b/io/src/test/java/com/itextpdf/io/util/GhostscriptHelperTest.java index f4291bd046..b36f94605c 100644 --- a/io/src/test/java/com/itextpdf/io/util/GhostscriptHelperTest.java +++ b/io/src/test/java/com/itextpdf/io/util/GhostscriptHelperTest.java @@ -26,18 +26,17 @@ This file is part of the iText (R) project. import com.itextpdf.commons.utils.SystemUtil; import com.itextpdf.io.exceptions.IoExceptionMessageConstant; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; import java.io.PrintStream; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") // Android-Conversion-Skip-File (ghostscript isn't available on Android) public class GhostscriptHelperTest extends ExtendedITextTest { private final static String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/io/util/GhostscriptHelperTest/"; @@ -47,7 +46,7 @@ public class GhostscriptHelperTest extends ExtendedITextTest { // The value of this threshold should be definitely less than the length of the help message. private static final int SYSTEM_OUT_LENGTH_LIMIT = 450; - @Before + @BeforeEach public void setUp() { createOrClearDestinationFolder(DESTINATION_FOLDER); } @@ -55,35 +54,31 @@ public void setUp() { @Test public void ghostScriptEnvVarIsDefault() { GhostscriptHelper ghostscriptHelper = new GhostscriptHelper(); - Assert.assertNotNull(ghostscriptHelper.getCliExecutionCommand()); + Assertions.assertNotNull(ghostscriptHelper.getCliExecutionCommand()); } @Test public void ghostScriptEnvVarIsExplicitlySpecified() { String gsExec = SystemUtil.getPropertyOrEnvironmentVariable(GhostscriptHelper.GHOSTSCRIPT_ENVIRONMENT_VARIABLE); - if (gsExec == null) { - gsExec = SystemUtil - .getPropertyOrEnvironmentVariable(GhostscriptHelper.GHOSTSCRIPT_ENVIRONMENT_VARIABLE_LEGACY); - } GhostscriptHelper ghostscriptHelper = new GhostscriptHelper(gsExec); - Assert.assertNotNull(ghostscriptHelper.getCliExecutionCommand()); + Assertions.assertNotNull(ghostscriptHelper.getCliExecutionCommand()); } @Test public void ghostScriptEnvVarIsNull() { GhostscriptHelper ghostscriptHelper = new GhostscriptHelper(null); - Assert.assertNotNull(ghostscriptHelper.getCliExecutionCommand()); + Assertions.assertNotNull(ghostscriptHelper.getCliExecutionCommand()); } @Test public void ghostScriptEnvVarIsIncorrect() { - Exception e = Assert.assertThrows(IllegalArgumentException.class, + Exception e = Assertions.assertThrows(IllegalArgumentException.class, () -> new GhostscriptHelper("-") ); - Assert.assertEquals(IoExceptionMessageConstant.GS_ENVIRONMENT_VARIABLE_IS_NOT_SPECIFIED, e.getMessage()); + Assertions.assertEquals(IoExceptionMessageConstant.GS_ENVIRONMENT_VARIABLE_IS_NOT_SPECIFIED, e.getMessage()); } @Test @@ -93,11 +88,11 @@ public void runGhostScriptIncorrectOutputDirectory() throws IOException, Interru GhostscriptHelper ghostscriptHelper = new GhostscriptHelper(); - Exception e = Assert.assertThrows(IllegalArgumentException.class, + Exception e = Assertions.assertThrows(IllegalArgumentException.class, () -> ghostscriptHelper.runGhostScriptImageGeneration(inputPdf, "-", "outputPageImage.png", "1") ); - Assert.assertEquals(exceptionMessage, e.getMessage()); + Assertions.assertEquals(exceptionMessage, e.getMessage()); } @Test @@ -108,11 +103,11 @@ public void runGhostScriptIncorrectParams() { GhostscriptHelper ghostscriptHelper = new GhostscriptHelper(); - Exception e = Assert.assertThrows(IllegalArgumentException.class, + Exception e = Assertions.assertThrows(IllegalArgumentException.class, () -> ghostscriptHelper.runGhostScriptImageGeneration(inputPdf, DESTINATION_FOLDER, "outputPageImage.png", invalidPageList) ); - Assert.assertEquals(exceptionMessage, e.getMessage()); + Assertions.assertEquals(exceptionMessage, e.getMessage()); } @Test @@ -123,8 +118,8 @@ public void runGhostScriptTestForSpecificPage() throws IOException, InterruptedE ghostscriptHelper.runGhostScriptImageGeneration(inputPdf, DESTINATION_FOLDER, "specificPage", "1"); - Assert.assertEquals(1, FileUtil.listFilesInDirectory(DESTINATION_FOLDER, true).length); - Assert.assertTrue(FileUtil.fileExists(DESTINATION_FOLDER + "specificPage-001.png")); + Assertions.assertEquals(1, FileUtil.listFilesInDirectory(DESTINATION_FOLDER, true).length); + Assertions.assertTrue(FileUtil.fileExists(DESTINATION_FOLDER + "specificPage-001.png")); } @Test @@ -136,10 +131,10 @@ public void runGhostScriptTestForSeveralSpecificPages() throws IOException, Inte ghostscriptHelper.runGhostScriptImageGeneration(inputPdf, DESTINATION_FOLDER, imageFileName, "1,3"); - Assert.assertEquals(2, FileUtil.listFilesInDirectory(DESTINATION_FOLDER, true).length); - Assert.assertTrue( + Assertions.assertEquals(2, FileUtil.listFilesInDirectory(DESTINATION_FOLDER, true).length); + Assertions.assertTrue( FileUtil.fileExists(DESTINATION_FOLDER + "imageHandlerUtilTest.pdf_severalSpecificPages-001.png")); - Assert.assertTrue( + Assertions.assertTrue( FileUtil.fileExists(DESTINATION_FOLDER + "imageHandlerUtilTest.pdf_severalSpecificPages-002.png")); } @@ -151,10 +146,10 @@ public void runGhostScriptTestForAllPages() throws IOException, InterruptedExcep String imageFileName = new File(inputPdf).getName() + "_allPages"; ghostscriptHelper.runGhostScriptImageGeneration(inputPdf, DESTINATION_FOLDER, imageFileName); - Assert.assertEquals(3, FileUtil.listFilesInDirectory(DESTINATION_FOLDER, true).length); - Assert.assertTrue(FileUtil.fileExists(DESTINATION_FOLDER + "imageHandlerUtilTest.pdf_allPages-001.png")); - Assert.assertTrue(FileUtil.fileExists(DESTINATION_FOLDER + "imageHandlerUtilTest.pdf_allPages-002.png")); - Assert.assertTrue(FileUtil.fileExists(DESTINATION_FOLDER + "imageHandlerUtilTest.pdf_allPages-003.png")); + Assertions.assertEquals(3, FileUtil.listFilesInDirectory(DESTINATION_FOLDER, true).length); + Assertions.assertTrue(FileUtil.fileExists(DESTINATION_FOLDER + "imageHandlerUtilTest.pdf_allPages-001.png")); + Assertions.assertTrue(FileUtil.fileExists(DESTINATION_FOLDER + "imageHandlerUtilTest.pdf_allPages-002.png")); + Assertions.assertTrue(FileUtil.fileExists(DESTINATION_FOLDER + "imageHandlerUtilTest.pdf_allPages-003.png")); } @Test @@ -175,8 +170,8 @@ public void dSaferParamInGhostScriptHelperTest() throws IOException, Interrupted String maliciousResult1 = DESTINATION_FOLDER + "output1.txt"; String maliciousResult2 = DESTINATION_FOLDER + "output2.txt"; - Assert.assertFalse(FileUtil.fileExists(maliciousResult1)); - Assert.assertFalse(FileUtil.fileExists(maliciousResult2)); + Assertions.assertFalse(FileUtil.fileExists(maliciousResult1)); + Assertions.assertFalse(FileUtil.fileExists(maliciousResult2)); } @Test @@ -190,10 +185,10 @@ public void ghostScriptImageGenerationTest() throws IOException, InterruptedExce GhostscriptHelper ghostscriptHelper = new GhostscriptHelper(); ghostscriptHelper.runGhostScriptImageGeneration(psFile, DESTINATION_FOLDER, name); - Assert.assertTrue(FileUtil.fileExists(resultantImage)); + Assertions.assertTrue(FileUtil.fileExists(resultantImage)); ImageMagickHelper imageMagickHelper = new ImageMagickHelper(); - Assert.assertTrue(imageMagickHelper.runImageMagickImageCompare(resultantImage, cmpResultantImage, diff)); + Assertions.assertTrue(imageMagickHelper.runImageMagickImageCompare(resultantImage, cmpResultantImage, diff)); } @Test @@ -206,7 +201,7 @@ public void pdfCallsHelpTest() { // In .NET the type of the thrown exception is different, therefore we just check here that // any exception has been thrown. - Assert.assertThrows(Exception.class, () -> + Assertions.assertThrows(Exception.class, () -> ghostscriptHelper.runGhostScriptImageGeneration(inputPdf, DESTINATION_FOLDER, outputImagePattern)); } @@ -228,7 +223,7 @@ public void outputImageCallsHelpTest() throws IOException { } finally { System.out.flush(); StandardOutUtil.restoreStandardOut(storedPrintStream); - Assert.assertTrue(baos.toByteArray().length < SYSTEM_OUT_LENGTH_LIMIT); + Assertions.assertTrue(baos.toByteArray().length < SYSTEM_OUT_LENGTH_LIMIT); baos.close(); } } @@ -244,7 +239,7 @@ public void pageListCallsHelpTest() { // In .NET the type of the thrown exception is different, therefore we just check here that // any exception has been thrown. - Assert.assertThrows(Exception.class, () -> + Assertions.assertThrows(Exception.class, () -> ghostscriptHelper.runGhostScriptImageGeneration(inputPdf, DESTINATION_FOLDER, outputImagePattern, pageList)); } @@ -259,7 +254,7 @@ public void nonExistingDestinationFolder() { // In .NET the type of the thrown exception is different, therefore we just check here that // any exception has been thrown. - Assert.assertThrows(Exception.class, + Assertions.assertThrows(Exception.class, () -> ghostscriptHelper.runGhostScriptImageGeneration(inputPdf, destinationFolder, outputImagePattern)); } diff --git a/io/src/test/java/com/itextpdf/io/util/ImageMagickHelperTest.java b/io/src/test/java/com/itextpdf/io/util/ImageMagickHelperTest.java index 100be09b2f..b7ee7785fd 100644 --- a/io/src/test/java/com/itextpdf/io/util/ImageMagickHelperTest.java +++ b/io/src/test/java/com/itextpdf/io/util/ImageMagickHelperTest.java @@ -26,17 +26,16 @@ This file is part of the iText (R) project. import com.itextpdf.commons.utils.SystemUtil; import com.itextpdf.io.exceptions.IoExceptionMessageConstant; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.PrintStream; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") // Android-Conversion-Skip-File (imagemagick isn't available on Android) public class ImageMagickHelperTest extends ExtendedITextTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/io/util/ImageMagickHelperTest/"; @@ -49,7 +48,7 @@ public class ImageMagickHelperTest extends ExtendedITextTest { // less than the length of the help message. private static final int SYSTEM_OUT_LENGTH_LIMIT = 50; - @Before + @BeforeEach public void setUp() { createOrClearDestinationFolder(DESTINATION_FOLDER); } @@ -57,21 +56,17 @@ public void setUp() { @Test public void imageMagickEnvVarIsDefault() { ImageMagickHelper imageMagickHelper = new ImageMagickHelper(); - Assert.assertNotNull(imageMagickHelper.getCliExecutionCommand()); + Assertions.assertNotNull(imageMagickHelper.getCliExecutionCommand()); } @Test public void imageMagickEnvVarIsExplicitlySpecified() { String compareExec = SystemUtil .getPropertyOrEnvironmentVariable(ImageMagickHelper.MAGICK_COMPARE_ENVIRONMENT_VARIABLE); - if (compareExec == null) { - compareExec = SystemUtil - .getPropertyOrEnvironmentVariable(ImageMagickHelper.MAGICK_COMPARE_ENVIRONMENT_VARIABLE_LEGACY); - } ImageMagickHelper imageMagickHelper = new ImageMagickHelper(compareExec); - Assert.assertNotNull(imageMagickHelper.getCliExecutionCommand()); + Assertions.assertNotNull(imageMagickHelper.getCliExecutionCommand()); } @Test @@ -83,16 +78,16 @@ public void imageMagickEnvVarIsNull() throws IOException, InterruptedException { ImageMagickHelper imageMagickHelper = new ImageMagickHelper(null); boolean result = imageMagickHelper.runImageMagickImageCompare(inputImage, cmpImage, diff); - Assert.assertTrue(result); - Assert.assertTrue(FileUtil.fileExists(diff)); + Assertions.assertTrue(result); + Assertions.assertTrue(FileUtil.fileExists(diff)); } @Test public void imageMagickEnvVarIsIncorrect() { - Exception e = Assert.assertThrows(IllegalArgumentException.class, + Exception e = Assertions.assertThrows(IllegalArgumentException.class, () -> new ImageMagickHelper("-") ); - Assert.assertEquals(IoExceptionMessageConstant.COMPARE_COMMAND_SPECIFIED_INCORRECTLY, e.getMessage()); + Assertions.assertEquals(IoExceptionMessageConstant.COMPARE_COMMAND_SPECIFIED_INCORRECTLY, e.getMessage()); } @Test @@ -104,8 +99,8 @@ public void runImageMagickForEqualImages() throws IOException, InterruptedExcept ImageMagickHelper imageMagickHelper = new ImageMagickHelper(); boolean result = imageMagickHelper.runImageMagickImageCompare(inputImage, cmpImage, diff); - Assert.assertTrue(result); - Assert.assertTrue(FileUtil.fileExists(diff)); + Assertions.assertTrue(result); + Assertions.assertTrue(FileUtil.fileExists(diff)); } @Test @@ -117,8 +112,8 @@ public void runImageMagickForEqualImagesWithFuzzParam() throws IOException, Inte ImageMagickHelper imageMagickHelper = new ImageMagickHelper(); boolean result = imageMagickHelper.runImageMagickImageCompare(inputImage, cmpImage, diff, "0.5"); - Assert.assertTrue(result); - Assert.assertTrue(FileUtil.fileExists(diff)); + Assertions.assertTrue(result); + Assertions.assertTrue(FileUtil.fileExists(diff)); } @Test @@ -130,8 +125,8 @@ public void runImageMagickForDifferentImages() throws IOException, InterruptedEx ImageMagickHelper imageMagickHelper = new ImageMagickHelper(); boolean result = imageMagickHelper.runImageMagickImageCompare(inputImage, cmpImage, diff); - Assert.assertFalse(result); - Assert.assertTrue(FileUtil.fileExists(diff)); + Assertions.assertFalse(result); + Assertions.assertTrue(FileUtil.fileExists(diff)); } @Test @@ -143,8 +138,8 @@ public void runImageMagickForDifferentImagesWithFuzzParamNotEqual() throws IOExc ImageMagickHelper imageMagickHelper = new ImageMagickHelper(); boolean result = imageMagickHelper.runImageMagickImageCompare(inputImage, cmpImage, diff, "0.1"); - Assert.assertFalse(result); - Assert.assertTrue(FileUtil.fileExists(diff)); + Assertions.assertFalse(result); + Assertions.assertTrue(FileUtil.fileExists(diff)); } @Test @@ -156,8 +151,8 @@ public void runImageMagickForDifferentImagesWithFuzzParamEqual() throws IOExcept ImageMagickHelper imageMagickHelper = new ImageMagickHelper(); boolean result = imageMagickHelper.runImageMagickImageCompare(inputImage, cmpImage, diff, "2.1"); - Assert.assertTrue(result); - Assert.assertTrue(FileUtil.fileExists(diff)); + Assertions.assertTrue(result); + Assertions.assertTrue(FileUtil.fileExists(diff)); } @Test @@ -175,14 +170,14 @@ public void outImageCallsHelpTest() { // In .NET the type of the thrown exception is different, therefore we just check here that // any exception has been thrown. - Assert.assertThrows(Exception.class, + Assertions.assertThrows(Exception.class, () -> imageMagickHelper.runImageMagickImageCompare(outImage, cmpImage, diff)); // Previously a lengthy help message was printed System.out.flush(); - Assert.assertTrue(baos.toByteArray().length < SYSTEM_OUT_LENGTH_LIMIT); + Assertions.assertTrue(baos.toByteArray().length < SYSTEM_OUT_LENGTH_LIMIT); } catch (IOException e) { - Assert.fail("No exception is excepted here."); + Assertions.fail("No exception is excepted here."); } finally { StandardOutUtil.restoreStandardOut(storedPrintStream); } @@ -202,14 +197,14 @@ public void cmpImageCallsHelpTest() { // In .NET the type of the thrown exception is different, therefore we just check here that // any exception has been thrown. - Assert.assertThrows(Exception.class, + Assertions.assertThrows(Exception.class, () -> imageMagickHelper.runImageMagickImageCompare(outImage, cmpImage, diff)); // Previously a lengthy help message was printed System.out.flush(); - Assert.assertTrue(baos.toByteArray().length < SYSTEM_OUT_LENGTH_LIMIT); + Assertions.assertTrue(baos.toByteArray().length < SYSTEM_OUT_LENGTH_LIMIT); } catch (IOException e) { - Assert.fail("No exception is excepted here."); + Assertions.fail("No exception is excepted here."); } finally { StandardOutUtil.restoreStandardOut(storedPrintStream); } @@ -231,14 +226,14 @@ public void fuzzinessCallsHelpTest() { // In .NET the type of the thrown exception is different, therefore we just check here that // any exception has been thrown. - Assert.assertThrows(Exception.class, + Assertions.assertThrows(Exception.class, () -> imageMagickHelper.runImageMagickImageCompare(outImage, cmpImage, diff, fuzziness)); // Previously a lengthy help message was printed System.out.flush(); - Assert.assertTrue(baos.toByteArray().length < SYSTEM_OUT_LENGTH_LIMIT); + Assertions.assertTrue(baos.toByteArray().length < SYSTEM_OUT_LENGTH_LIMIT); } catch (IOException e) { - Assert.fail("No exception is excepted here."); + Assertions.fail("No exception is excepted here."); } finally { StandardOutUtil.restoreStandardOut(storedPrintStream); } @@ -254,7 +249,7 @@ public void passOutAndCmpAndDiffAsOutTest() throws IOException, InterruptedExcep String diff = DESTINATION_FOLDER + "diff_equalImages.png"; ImageMagickHelper imageMagickHelper = new ImageMagickHelper(); - Assert.assertThrows(Exception.class, + Assertions.assertThrows(Exception.class, () -> imageMagickHelper.runImageMagickImageCompare( image + "' '" + differentImage + "' '" + diff, image, @@ -271,7 +266,7 @@ public void passCmpAndDiffAsDiffTest() throws IOException, InterruptedException String secondDiff = DESTINATION_FOLDER + "diff_secondEqualImages.png"; ImageMagickHelper imageMagickHelper = new ImageMagickHelper(); - Assert.assertThrows(Exception.class, + Assertions.assertThrows(Exception.class, () -> imageMagickHelper.runImageMagickImageCompare( image, image + "' '" + secondDiff, @@ -289,7 +284,7 @@ public void passFuzzinessAsOutTest() { String diff = DESTINATION_FOLDER + "diff.png"; ImageMagickHelper imageMagickHelper = new ImageMagickHelper(); - Assert.assertThrows(Exception.class, () -> + Assertions.assertThrows(Exception.class, () -> imageMagickHelper.runImageMagickImageCompare( image + "' -metric AE -fuzz 1% '" + differentImage + "' '" + diff, image, @@ -312,19 +307,19 @@ public void compareEqualsImagesAndCheckFuzzinessTest() { image, diff, "1"); - Assert.assertTrue(result); - Assert.assertTrue(FileUtil.fileExists(diff)); + Assertions.assertTrue(result); + Assertions.assertTrue(FileUtil.fileExists(diff)); System.out.flush(); String output = new String(baos.toByteArray()).trim(); // This check is implemented in such a peculiar way because of .NET autoporting - Assert.assertEquals('0', output.charAt(output.length() - 1)); + Assertions.assertEquals('0', output.charAt(output.length() - 1)); if (output.length() > 1) { - Assert.assertFalse(Character.isDigit(output.charAt(output.length() - 2))); + Assertions.assertFalse(Character.isDigit(output.charAt(output.length() - 2))); } } catch (Exception e) { - Assert.fail("No exception is expected here."); + Assertions.fail("No exception is expected here."); } finally { StandardOutUtil.restoreStandardOut(storedPrintStream); } @@ -341,8 +336,8 @@ public void compareEqualImagesAndGetResult() throws InterruptedException, IOExce diff, "1"); - Assert.assertTrue(result.isComparingResultSuccessful()); - Assert.assertEquals(0, result.getDiffPixels()); + Assertions.assertTrue(result.isComparingResultSuccessful()); + Assertions.assertEquals(0, result.getDiffPixels()); } @Test @@ -356,7 +351,7 @@ public void compareDifferentImagesAndGetResult() throws InterruptedException, IO image2, diff, "1"); - Assert.assertFalse(result.isComparingResultSuccessful()); + Assertions.assertFalse(result.isComparingResultSuccessful()); } @Test @@ -372,7 +367,7 @@ public void runImageMagickImageCompareEqualWithThreshold() throws IOException, I "0", 0); - Assert.assertTrue(result); + Assertions.assertTrue(result); } @Test @@ -388,7 +383,7 @@ public void runImageMagickImageCompareWithEnoughThreshold() throws IOException, "20", 2000000); - Assert.assertTrue(result); + Assertions.assertTrue(result); } @Test @@ -404,7 +399,7 @@ public void runImageMagickImageCompareWithNotEnoughThreshold() throws IOExceptio "20", 2000); - Assert.assertFalse(result); + Assertions.assertFalse(result); } } diff --git a/io/src/test/java/com/itextpdf/io/util/ImageMagickHelperUnitTest.java b/io/src/test/java/com/itextpdf/io/util/ImageMagickHelperUnitTest.java index 3912f478b3..7b9d5ebe54 100644 --- a/io/src/test/java/com/itextpdf/io/util/ImageMagickHelperUnitTest.java +++ b/io/src/test/java/com/itextpdf/io/util/ImageMagickHelperUnitTest.java @@ -23,75 +23,74 @@ This file is part of the iText (R) project. package com.itextpdf.io.util; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class ImageMagickHelperUnitTest extends ExtendedITextTest { @Test public void verifyValidIntegerFuzzValue() { String testFuzzValue = "10"; - Assert.assertTrue(ImageMagickHelper.validateFuzziness(testFuzzValue)); + Assertions.assertTrue(ImageMagickHelper.validateFuzziness(testFuzzValue)); } @Test public void verifyValidDecimalFuzzValue() { String testFuzzValue = "10.5"; - Assert.assertTrue(ImageMagickHelper.validateFuzziness(testFuzzValue)); + Assertions.assertTrue(ImageMagickHelper.validateFuzziness(testFuzzValue)); } @Test public void verifyFuzzIntegerValueGT100() { String testFuzzValue = "200"; - Assert.assertTrue(ImageMagickHelper.validateFuzziness(testFuzzValue)); + Assertions.assertTrue(ImageMagickHelper.validateFuzziness(testFuzzValue)); } @Test public void verifyFuzzDecimalValueGT100() { String testFuzzValue = "200.5"; - Assert.assertTrue(ImageMagickHelper.validateFuzziness(testFuzzValue)); + Assertions.assertTrue(ImageMagickHelper.validateFuzziness(testFuzzValue)); } @Test public void verifyNegativeIntegerFuzzValue() { String testFuzzValue = "-10"; - Assert.assertFalse(ImageMagickHelper.validateFuzziness(testFuzzValue)); + Assertions.assertFalse(ImageMagickHelper.validateFuzziness(testFuzzValue)); } @Test public void verifyNegativeDecimalFuzzValue() { String testFuzzValue = "-10.5"; - Assert.assertFalse(ImageMagickHelper.validateFuzziness(testFuzzValue)); + Assertions.assertFalse(ImageMagickHelper.validateFuzziness(testFuzzValue)); } @Test public void verifyEmptyFuzzValue() { String testFuzzValue = ""; - Assert.assertFalse(ImageMagickHelper.validateFuzziness(testFuzzValue)); + Assertions.assertFalse(ImageMagickHelper.validateFuzziness(testFuzzValue)); } @Test public void verifyNullFuzzValue() { String testFuzzValue = null; - Assert.assertTrue(ImageMagickHelper.validateFuzziness(testFuzzValue)); + Assertions.assertTrue(ImageMagickHelper.validateFuzziness(testFuzzValue)); } @Test public void verifySomeTextInFuzzValue() { String testFuzzValue = "10hello"; - Assert.assertFalse(ImageMagickHelper.validateFuzziness(testFuzzValue)); + Assertions.assertFalse(ImageMagickHelper.validateFuzziness(testFuzzValue)); } } diff --git a/io/src/test/java/com/itextpdf/io/util/IntHashtableTest.java b/io/src/test/java/com/itextpdf/io/util/IntHashtableTest.java index 2b15078c2c..60707a0879 100644 --- a/io/src/test/java/com/itextpdf/io/util/IntHashtableTest.java +++ b/io/src/test/java/com/itextpdf/io/util/IntHashtableTest.java @@ -23,13 +23,12 @@ This file is part of the iText (R) project. package com.itextpdf.io.util; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class IntHashtableTest extends ExtendedITextTest { @Test @@ -38,10 +37,10 @@ public void cloneTest() throws CloneNotSupportedException { IntHashtable clonedTable = (IntHashtable) hashtable.clone(); int[] keysArray = hashtable.getKeys(); int[] clonedKeysArray = clonedTable.getKeys(); - Assert.assertEquals(keysArray.length, clonedKeysArray.length); + Assertions.assertEquals(keysArray.length, clonedKeysArray.length); for (int i = 0; i < keysArray.length; i++) { - Assert.assertEquals(keysArray[i], clonedKeysArray[i]); - Assert.assertEquals(hashtable.get(keysArray[i]), clonedTable.get(clonedKeysArray[i])); + Assertions.assertEquals(keysArray[i], clonedKeysArray[i]); + Assertions.assertEquals(hashtable.get(keysArray[i]), clonedTable.get(clonedKeysArray[i])); } } @@ -49,7 +48,7 @@ public void cloneTest() throws CloneNotSupportedException { public void countIsEqualTest() throws CloneNotSupportedException { IntHashtable hashtable = fillTable(); IntHashtable clonedTable = (IntHashtable) hashtable.clone(); - Assert.assertEquals(hashtable.count, clonedTable.count); + Assertions.assertEquals(hashtable.count, clonedTable.count); } private static IntHashtable fillTable() { diff --git a/io/src/test/java/com/itextpdf/io/util/MatcherTest.java b/io/src/test/java/com/itextpdf/io/util/MatcherTest.java index 7355042895..b849ffb634 100644 --- a/io/src/test/java/com/itextpdf/io/util/MatcherTest.java +++ b/io/src/test/java/com/itextpdf/io/util/MatcherTest.java @@ -23,19 +23,18 @@ This file is part of the iText (R) project. package com.itextpdf.io.util; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; /** * At the moment there is no com.itextpdf.io.util.Matcher class in Java (as we use * java.util.regex.Matcher), but there is one in C# that we are testing */ -@Category(UnitTest.class) +@Tag("UnitTest") public class MatcherTest extends ExtendedITextTest { private static final String PATTERN_STRING = "(a+)(b+)?"; @@ -45,51 +44,51 @@ public class MatcherTest extends ExtendedITextTest { @Test public void matchesTest() { Matcher matched = FULL_MATCH_PATTERN.matcher("aaabbb"); - Assert.assertTrue(matched.matches()); + Assertions.assertTrue(matched.matches()); Matcher notMatched = FULL_MATCH_PATTERN.matcher("aaacbbb"); - Assert.assertFalse(notMatched.matches()); + Assertions.assertFalse(notMatched.matches()); } @Test public void twoGroupsFindTest() { Matcher matcher = PATTERN.matcher("aabbcaaacc"); - Assert.assertTrue(matcher.find()); - Assert.assertEquals(0, matcher.start()); - Assert.assertEquals(4, matcher.end()); - Assert.assertEquals("aabb", matcher.group()); - Assert.assertEquals("aabb", matcher.group(0)); - Assert.assertEquals("aa", matcher.group(1)); - Assert.assertEquals("bb", matcher.group(2)); - Assert.assertTrue(matcher.find()); - Assert.assertEquals(5, matcher.start()); - Assert.assertEquals(8, matcher.end()); - Assert.assertEquals("aaa", matcher.group()); - Assert.assertEquals("aaa", matcher.group(0)); - Assert.assertEquals("aaa", matcher.group(1)); - Assert.assertNull(matcher.group(2)); - Assert.assertFalse(matcher.find()); + Assertions.assertTrue(matcher.find()); + Assertions.assertEquals(0, matcher.start()); + Assertions.assertEquals(4, matcher.end()); + Assertions.assertEquals("aabb", matcher.group()); + Assertions.assertEquals("aabb", matcher.group(0)); + Assertions.assertEquals("aa", matcher.group(1)); + Assertions.assertEquals("bb", matcher.group(2)); + Assertions.assertTrue(matcher.find()); + Assertions.assertEquals(5, matcher.start()); + Assertions.assertEquals(8, matcher.end()); + Assertions.assertEquals("aaa", matcher.group()); + Assertions.assertEquals("aaa", matcher.group(0)); + Assertions.assertEquals("aaa", matcher.group(1)); + Assertions.assertNull(matcher.group(2)); + Assertions.assertFalse(matcher.find()); } @Test public void twoGroupsFindWithIndexTest() { Matcher matcher = PATTERN.matcher("aabbcaaacc"); - Assert.assertTrue(matcher.find(6)); - Assert.assertEquals(6, matcher.start()); - Assert.assertEquals(8, matcher.end()); - Assert.assertEquals("aa", matcher.group()); - Assert.assertEquals("aa", matcher.group(0)); - Assert.assertEquals("aa", matcher.group(1)); - Assert.assertNull(matcher.group(2)); - Assert.assertFalse(matcher.find()); - Assert.assertFalse(matcher.find(9)); + Assertions.assertTrue(matcher.find(6)); + Assertions.assertEquals(6, matcher.start()); + Assertions.assertEquals(8, matcher.end()); + Assertions.assertEquals("aa", matcher.group()); + Assertions.assertEquals("aa", matcher.group(0)); + Assertions.assertEquals("aa", matcher.group(1)); + Assertions.assertNull(matcher.group(2)); + Assertions.assertFalse(matcher.find()); + Assertions.assertFalse(matcher.find(9)); } @Test public void startBeforeSearchTest() { Matcher matcher = PATTERN.matcher("aabb"); - Assert.assertThrows(IllegalStateException.class, () -> matcher.start()); + Assertions.assertThrows(IllegalStateException.class, () -> matcher.start()); } @Test @@ -99,14 +98,14 @@ public void startWhenFindFailsTest() { while (matcher.find()) { } - Assert.assertThrows(IllegalStateException.class, () -> matcher.start()); + Assertions.assertThrows(IllegalStateException.class, () -> matcher.start()); } @Test public void endBeforeSearchTest() { Matcher matcher = PATTERN.matcher("aabb"); - Assert.assertThrows(IllegalStateException.class, () -> matcher.end()); + Assertions.assertThrows(IllegalStateException.class, () -> matcher.end()); } @Test @@ -116,14 +115,14 @@ public void endWhenFindFailsTest() { while (matcher.find()) { } - Assert.assertThrows(IllegalStateException.class, () -> matcher.end()); + Assertions.assertThrows(IllegalStateException.class, () -> matcher.end()); } @Test public void groupBeforeSearchTest() { Matcher matcher = PATTERN.matcher("aabb"); - Assert.assertThrows(IllegalStateException.class, () -> matcher.group()); + Assertions.assertThrows(IllegalStateException.class, () -> matcher.group()); } @Test @@ -133,14 +132,14 @@ public void groupWhenFindFailsTest() { while (matcher.find()) { } - Assert.assertThrows(IllegalStateException.class, () -> matcher.group()); + Assertions.assertThrows(IllegalStateException.class, () -> matcher.group()); } @Test public void groupWithIndexBeforeSearchTest() { Matcher matcher = PATTERN.matcher("aabb"); - Assert.assertThrows(IllegalStateException.class, () -> matcher.group(0)); + Assertions.assertThrows(IllegalStateException.class, () -> matcher.group(0)); } @Test @@ -150,30 +149,30 @@ public void groupWithIndexWhenFindFailsTest() { while (matcher.find()) { } - Assert.assertThrows(IllegalStateException.class, () -> matcher.group(0)); + Assertions.assertThrows(IllegalStateException.class, () -> matcher.group(0)); } @Test public void groupNegativeIndexTest() { Matcher matcher = PATTERN.matcher("aabb"); - Assert.assertTrue(matcher.find()); + Assertions.assertTrue(matcher.find()); - Assert.assertThrows(IndexOutOfBoundsException.class, () -> matcher.group(-1)); + Assertions.assertThrows(IndexOutOfBoundsException.class, () -> matcher.group(-1)); } @Test public void groupIndexGraterThanGroupCountTest() { Matcher matcher = PATTERN.matcher("aabb"); - Assert.assertTrue(matcher.find()); + Assertions.assertTrue(matcher.find()); - Assert.assertThrows(IndexOutOfBoundsException.class, () -> matcher.group(3)); + Assertions.assertThrows(IndexOutOfBoundsException.class, () -> matcher.group(3)); } @Test public void findNegativeIndexTest() { Matcher matcher = PATTERN.matcher("aabb"); - Assert.assertThrows(IndexOutOfBoundsException.class, () -> matcher.find(-1)); + Assertions.assertThrows(IndexOutOfBoundsException.class, () -> matcher.find(-1)); } @Test @@ -181,14 +180,14 @@ public void findIndexGraterThanInputLengthTest() { String input = "aabb"; Matcher matcher = PATTERN.matcher(input); - Assert.assertThrows(IndexOutOfBoundsException.class, () -> matcher.find(input.length() + 1)); + Assertions.assertThrows(IndexOutOfBoundsException.class, () -> matcher.find(input.length() + 1)); } @Test public void findIndexEqualInputLengthTest() { String input = "aabb"; Matcher matcher = PATTERN.matcher(input); - Assert.assertFalse(matcher.find(input.length())); + Assertions.assertFalse(matcher.find(input.length())); } @Test @@ -196,11 +195,11 @@ public void matchesFullyAndOnceTest() { String testPattern = "(\\d+)-(\\d+)?"; String input = "5-15"; Matcher matcher = Pattern.compile(testPattern).matcher(input); - Assert.assertTrue(matcher.find()); - Assert.assertEquals("5-15", matcher.group(0)); - Assert.assertEquals("5", matcher.group(1)); - Assert.assertEquals("15", matcher.group(2)); - Assert.assertFalse(matcher.find()); + Assertions.assertTrue(matcher.find()); + Assertions.assertEquals("5-15", matcher.group(0)); + Assertions.assertEquals("5", matcher.group(1)); + Assertions.assertEquals("15", matcher.group(2)); + Assertions.assertFalse(matcher.find()); } @Test @@ -208,11 +207,11 @@ public void matchesOnceTest() { String testPattern = "(\\d+)-(\\d+)?"; String input = "5-15-"; Matcher matcher = Pattern.compile(testPattern).matcher(input); - Assert.assertTrue(matcher.find()); - Assert.assertEquals("5-15", matcher.group(0)); - Assert.assertEquals("5", matcher.group(1)); - Assert.assertEquals("15", matcher.group(2)); - Assert.assertFalse(matcher.find()); + Assertions.assertTrue(matcher.find()); + Assertions.assertEquals("5-15", matcher.group(0)); + Assertions.assertEquals("5", matcher.group(1)); + Assertions.assertEquals("15", matcher.group(2)); + Assertions.assertFalse(matcher.find()); } @Test @@ -220,11 +219,11 @@ public void matchesTwiceTest() { String testPattern = "a*b"; String input = "abb"; Matcher matcher = Pattern.compile(testPattern).matcher(input); - Assert.assertTrue(matcher.find()); - Assert.assertEquals("ab", matcher.group(0)); - Assert.assertTrue(matcher.find()); - Assert.assertEquals("b", matcher.group(0)); - Assert.assertFalse(matcher.find()); + Assertions.assertTrue(matcher.find()); + Assertions.assertEquals("ab", matcher.group(0)); + Assertions.assertTrue(matcher.find()); + Assertions.assertEquals("b", matcher.group(0)); + Assertions.assertFalse(matcher.find()); } @Test @@ -232,11 +231,11 @@ public void matchesTwiceEmptyMatchTest() { String testPattern = "a*b*"; String input = "abb"; Matcher matcher = Pattern.compile(testPattern).matcher(input); - Assert.assertTrue(matcher.find()); - Assert.assertEquals("abb", matcher.group(0)); - Assert.assertTrue(matcher.find()); - Assert.assertEquals("", matcher.group(0)); - Assert.assertFalse(matcher.find()); + Assertions.assertTrue(matcher.find()); + Assertions.assertEquals("abb", matcher.group(0)); + Assertions.assertTrue(matcher.find()); + Assertions.assertEquals("", matcher.group(0)); + Assertions.assertFalse(matcher.find()); } @Test @@ -244,11 +243,11 @@ public void groupOutOfBoundsTest() { String testPattern = "(\\d+)"; String input = "123"; Matcher matcher = Pattern.compile(testPattern).matcher(input); - Assert.assertTrue(matcher.find()); - Assert.assertEquals("123", matcher.group(0)); - Assert.assertEquals("123", matcher.group(1)); + Assertions.assertTrue(matcher.find()); + Assertions.assertEquals("123", matcher.group(0)); + Assertions.assertEquals("123", matcher.group(1)); - Assert.assertThrows(IndexOutOfBoundsException.class, () -> matcher.group(2)); + Assertions.assertThrows(IndexOutOfBoundsException.class, () -> matcher.group(2)); } @Test @@ -256,9 +255,9 @@ public void groupWhenNoMatchTest() { String testPattern = "(\\d+)"; String input = "abc"; Matcher matcher = Pattern.compile(testPattern).matcher(input); - Assert.assertFalse(matcher.find()); + Assertions.assertFalse(matcher.find()); - Assert.assertThrows(IllegalStateException.class, () -> matcher.group(0)); + Assertions.assertThrows(IllegalStateException.class, () -> matcher.group(0)); } @Test @@ -266,13 +265,13 @@ public void alternativeGroupsTest() { String testPattern = "((\\d+)|(ab))cd(a*)e"; String input = "abcdefg"; Matcher matcher = Pattern.compile(testPattern).matcher(input); - Assert.assertTrue(matcher.find()); - Assert.assertEquals("abcde", matcher.group(0)); - Assert.assertEquals("ab", matcher.group(1)); - Assert.assertNull(matcher.group(2)); - Assert.assertEquals("ab", matcher.group(3)); - Assert.assertEquals("", matcher.group(4)); - Assert.assertFalse(matcher.find()); + Assertions.assertTrue(matcher.find()); + Assertions.assertEquals("abcde", matcher.group(0)); + Assertions.assertEquals("ab", matcher.group(1)); + Assertions.assertNull(matcher.group(2)); + Assertions.assertEquals("ab", matcher.group(3)); + Assertions.assertEquals("", matcher.group(4)); + Assertions.assertFalse(matcher.find()); } @Test @@ -280,9 +279,9 @@ public void startEndIndicesTest() { String testPattern = "cd"; String input = "abcde"; Matcher matcher = Pattern.compile(testPattern).matcher(input); - Assert.assertTrue(matcher.find()); - Assert.assertEquals(2, matcher.start()); - Assert.assertEquals(4, matcher.end()); + Assertions.assertTrue(matcher.find()); + Assertions.assertEquals(2, matcher.start()); + Assertions.assertEquals(4, matcher.end()); } @Test @@ -291,8 +290,8 @@ public void startIndexNotFoundTest() { String input = "abcde"; Matcher matcher = Pattern.compile(testPattern).matcher(input); - Assert.assertFalse(matcher.find()); - Assert.assertThrows(IllegalStateException.class, () -> matcher.start()); + Assertions.assertFalse(matcher.find()); + Assertions.assertThrows(IllegalStateException.class, () -> matcher.start()); } @Test @@ -301,8 +300,8 @@ public void endIndexNotFoundTest() { String input = "abcde"; Matcher matcher = Pattern.compile(testPattern).matcher(input); - Assert.assertFalse(matcher.find()); - Assert.assertThrows(IllegalStateException.class, () -> matcher.end()); + Assertions.assertFalse(matcher.find()); + Assertions.assertThrows(IllegalStateException.class, () -> matcher.end()); } @Test @@ -311,11 +310,11 @@ public void findMatchStartingFromIndexTest() { String input = "00abcde"; int startIndex = 3; Matcher matcher = Pattern.compile(testPattern).matcher(input); - Assert.assertTrue(matcher.find(startIndex)); - Assert.assertEquals("bc", matcher.group(0)); - Assert.assertEquals(3, matcher.start()); - Assert.assertEquals(5, matcher.end()); - Assert.assertFalse(matcher.find()); + Assertions.assertTrue(matcher.find(startIndex)); + Assertions.assertEquals("bc", matcher.group(0)); + Assertions.assertEquals(3, matcher.start()); + Assertions.assertEquals(5, matcher.end()); + Assertions.assertFalse(matcher.find()); } @Test @@ -324,13 +323,13 @@ public void findNextMatchStartingFromIndexTest() { String input = "ab00abcde"; Matcher matcher = Pattern.compile(testPattern).matcher(input); - Assert.assertTrue(matcher.find()); + Assertions.assertTrue(matcher.find()); int startIndex = 5; - Assert.assertTrue(matcher.find(startIndex)); - Assert.assertEquals("bc", matcher.group(0)); - Assert.assertEquals(5, matcher.start()); - Assert.assertEquals(7, matcher.end()); - Assert.assertFalse(matcher.find()); + Assertions.assertTrue(matcher.find(startIndex)); + Assertions.assertEquals("bc", matcher.group(0)); + Assertions.assertEquals(5, matcher.start()); + Assertions.assertEquals(7, matcher.end()); + Assertions.assertFalse(matcher.find()); } @Test @@ -339,7 +338,7 @@ public void findMatchStartingFromAfterInputStringTest() { String input = "cab"; int startIndex = 3; Matcher matcher = Pattern.compile(testPattern).matcher(input); - Assert.assertFalse(matcher.find(startIndex)); + Assertions.assertFalse(matcher.find(startIndex)); } @Test @@ -347,9 +346,9 @@ public void findNextMatchStartingFromAfterInputStringTest() { String testPattern = "ab"; String input = "abc"; Matcher matcher = Pattern.compile(testPattern).matcher(input); - Assert.assertTrue(matcher.find()); + Assertions.assertTrue(matcher.find()); int startIndex = 3; - Assert.assertFalse(matcher.find(startIndex)); + Assertions.assertFalse(matcher.find(startIndex)); } @Test @@ -359,7 +358,7 @@ public void findMatchStartingFromIndexOutOfBoundsTest() { int startIndex = 4; Matcher matcher = Pattern.compile(testPattern).matcher(input); - Assert.assertThrows(IndexOutOfBoundsException.class, () -> matcher.find(startIndex)); + Assertions.assertThrows(IndexOutOfBoundsException.class, () -> matcher.find(startIndex)); } @Test @@ -368,11 +367,11 @@ public void findNextMatchStartingFromIndexOutOfBoundsTest() { String input = "cab"; Matcher matcher = Pattern.compile(testPattern).matcher(input); - Assert.assertTrue(matcher.find()); + Assertions.assertTrue(matcher.find()); int startIndex = 4; - Assert.assertThrows(IndexOutOfBoundsException.class, () -> matcher.find(startIndex)); + Assertions.assertThrows(IndexOutOfBoundsException.class, () -> matcher.find(startIndex)); } @Test @@ -382,7 +381,7 @@ public void findMatchStartingFromNegativeIndexTest() { int startIndex = -1; Matcher matcher = Pattern.compile(testPattern).matcher(input); - Assert.assertThrows(IndexOutOfBoundsException.class, () -> matcher.find(startIndex)); + Assertions.assertThrows(IndexOutOfBoundsException.class, () -> matcher.find(startIndex)); } @Test @@ -391,11 +390,11 @@ public void findNextMatchStartingFromNegativeIndexTest() { String input = "cab"; Matcher matcher = Pattern.compile(testPattern).matcher(input); - Assert.assertTrue(matcher.find()); + Assertions.assertTrue(matcher.find()); int startIndex = -1; - Assert.assertThrows(IndexOutOfBoundsException.class, () -> matcher.find(startIndex)); + Assertions.assertThrows(IndexOutOfBoundsException.class, () -> matcher.find(startIndex)); } @Test @@ -405,17 +404,17 @@ public void findNextMatchStartingFromIndexContinuouslyTest() { int startIndex1 = 2; Matcher matcher = Pattern.compile(testPattern).matcher(input); - Assert.assertTrue(matcher.find(startIndex1)); - Assert.assertEquals(4, matcher.start()); - Assert.assertEquals(6, matcher.end()); + Assertions.assertTrue(matcher.find(startIndex1)); + Assertions.assertEquals(4, matcher.start()); + Assertions.assertEquals(6, matcher.end()); int startIndex2 = 7; - Assert.assertTrue(matcher.find(startIndex2)); - Assert.assertEquals(7, matcher.start()); - Assert.assertEquals(9, matcher.end()); + Assertions.assertTrue(matcher.find(startIndex2)); + Assertions.assertEquals(7, matcher.start()); + Assertions.assertEquals(9, matcher.end()); int startIndex3 = input.length(); - Assert.assertFalse(matcher.find(startIndex3)); + Assertions.assertFalse(matcher.find(startIndex3)); } @Test @@ -425,42 +424,42 @@ public void findNextMatchStartingFromIndexMovingBackwardsTest() { int startIndex1 = 7; Matcher matcher = Pattern.compile(testPattern).matcher(input); - Assert.assertTrue(matcher.find(startIndex1)); - Assert.assertEquals(7, matcher.start()); - Assert.assertEquals(9, matcher.end()); + Assertions.assertTrue(matcher.find(startIndex1)); + Assertions.assertEquals(7, matcher.start()); + Assertions.assertEquals(9, matcher.end()); int startIndex2 = 4; - Assert.assertTrue(matcher.find(startIndex2)); - Assert.assertEquals(4, matcher.start()); - Assert.assertEquals(6, matcher.end()); + Assertions.assertTrue(matcher.find(startIndex2)); + Assertions.assertEquals(4, matcher.start()); + Assertions.assertEquals(6, matcher.end()); int startIndex3 = 1; - Assert.assertTrue(matcher.find(startIndex3)); - Assert.assertEquals(1, matcher.start()); - Assert.assertEquals(3, matcher.end()); + Assertions.assertTrue(matcher.find(startIndex3)); + Assertions.assertEquals(1, matcher.start()); + Assertions.assertEquals(3, matcher.end()); - Assert.assertTrue(matcher.find()); - Assert.assertEquals(4, matcher.start()); - Assert.assertEquals(6, matcher.end()); + Assertions.assertTrue(matcher.find()); + Assertions.assertEquals(4, matcher.start()); + Assertions.assertEquals(6, matcher.end()); int startIndex4 = input.length(); - Assert.assertFalse(matcher.find(startIndex4)); + Assertions.assertFalse(matcher.find(startIndex4)); } @Test public void matchesSuccessAfterFindFinish() { Matcher matcher = PATTERN.matcher("aaabbb"); - Assert.assertTrue(matcher.find()); - Assert.assertFalse(matcher.find()); - Assert.assertTrue(matcher.matches()); - Assert.assertFalse(matcher.find()); + Assertions.assertTrue(matcher.find()); + Assertions.assertFalse(matcher.find()); + Assertions.assertTrue(matcher.matches()); + Assertions.assertFalse(matcher.find()); } @Test public void findAfterMatchesSuccess() { Matcher matcher = PATTERN.matcher("aaabbb"); - Assert.assertTrue(matcher.matches()); - Assert.assertFalse(matcher.find()); + Assertions.assertTrue(matcher.matches()); + Assertions.assertFalse(matcher.find()); } @Test @@ -469,9 +468,9 @@ public void regionTest() { matcher.region(6, 13); // abbbbbb [6, 13) - Assert.assertTrue(matcher.find()); - Assert.assertFalse(matcher.find()); - Assert.assertTrue(matcher.matches()); + Assertions.assertTrue(matcher.find()); + Assertions.assertFalse(matcher.find()); + Assertions.assertTrue(matcher.matches()); } @Test @@ -479,56 +478,56 @@ public void regionSeveralMatchesTest() { Matcher matcher = PATTERN.matcher("abbbbbabababbbbbbbbbbb"); matcher.region(6, 13); // ab [6, 8) - Assert.assertTrue(matcher.find()); + Assertions.assertTrue(matcher.find()); // ab [8, 10) - Assert.assertTrue(matcher.find()); + Assertions.assertTrue(matcher.find()); // abb [10, 13) - Assert.assertTrue(matcher.find()); - Assert.assertFalse(matcher.find()); - Assert.assertFalse(matcher.matches()); + Assertions.assertTrue(matcher.find()); + Assertions.assertFalse(matcher.find()); + Assertions.assertFalse(matcher.matches()); } @Test public void stringMatchesButRegionDoesNotMatchTest() { Matcher matcher = PATTERN.matcher("abbbbbbbbbbbbbbbbbbbbb"); - Assert.assertTrue(matcher.matches()); + Assertions.assertTrue(matcher.matches()); matcher.region(6, 13); - Assert.assertFalse(matcher.matches()); + Assertions.assertFalse(matcher.matches()); } @Test public void negativeStartOfRegionTest() { Matcher matcher = PATTERN.matcher("abbbbbbbbbbbbbbbbbbbbb"); - Assert.assertThrows(IndexOutOfBoundsException.class, () -> matcher.region(-1, 10)); + Assertions.assertThrows(IndexOutOfBoundsException.class, () -> matcher.region(-1, 10)); } @Test public void tooLargeStartOfRegionTest() { Matcher matcher = PATTERN.matcher("abbbbbbbbbbbbbbbbbbbbb"); - Assert.assertThrows(IndexOutOfBoundsException.class, () -> matcher.region(24, 24)); + Assertions.assertThrows(IndexOutOfBoundsException.class, () -> matcher.region(24, 24)); } @Test public void negativeEndOfRegionTest() { Matcher matcher = PATTERN.matcher("abbbbbbbbbbbbbbbbbbbbb"); - Assert.assertThrows(IndexOutOfBoundsException.class, () -> matcher.region(1, -1)); + Assertions.assertThrows(IndexOutOfBoundsException.class, () -> matcher.region(1, -1)); } @Test public void tooLargeEndOfRegionTest() { Matcher matcher = PATTERN.matcher("abbbbbbbbbbbbbbbbbbbbb"); - Assert.assertThrows(IndexOutOfBoundsException.class, () -> matcher.region(1, 24)); + Assertions.assertThrows(IndexOutOfBoundsException.class, () -> matcher.region(1, 24)); } @Test public void endGreaterThenStartRegionTest() { Matcher matcher = PATTERN.matcher("abbbbbbbbbbbbbbbbbbbbb"); - Assert.assertThrows(IndexOutOfBoundsException.class, () -> matcher.region(10, 9)); + Assertions.assertThrows(IndexOutOfBoundsException.class, () -> matcher.region(10, 9)); } @Test @@ -536,7 +535,7 @@ public void startAndEndEqualRegionTest() { Matcher matcher = PATTERN.matcher("abbbbbbbbbbbbbbbbbbbbb"); matcher.region(9, 9); // *empty string* [9, 9) - Assert.assertFalse(matcher.matches()); + Assertions.assertFalse(matcher.matches()); } @Test @@ -545,7 +544,7 @@ public void startAndEndEqualRegionMatchTest() { Matcher matcher = patternAcceptingEmptyString.matcher("abbbbbbbbbbbbbbbbbbbbb"); matcher.region(9, 9); // *empty string* [9, 9) - Assert.assertTrue(matcher.matches()); + Assertions.assertTrue(matcher.matches()); } @Test @@ -553,16 +552,16 @@ public void severalRegionCallsTest() { Matcher matcher = PATTERN.matcher("abbbbbabababbbbbbbbbbb"); matcher.region(6, 13); // abababb [6, 13) - Assert.assertFalse(matcher.matches()); + Assertions.assertFalse(matcher.matches()); matcher.region(0, 3); // abb [0, 3) - Assert.assertTrue(matcher.matches()); + Assertions.assertTrue(matcher.matches()); matcher.region(0, 4); // abbb [0, 4) - Assert.assertTrue(matcher.matches()); + Assertions.assertTrue(matcher.matches()); matcher.region(0, 7); // abbbbba [0, 7) - Assert.assertFalse(matcher.matches()); + Assertions.assertFalse(matcher.matches()); } @Test @@ -570,9 +569,9 @@ public void startEndFullRegionMatchesTest() { Matcher matcher = PATTERN.matcher("abbbbbabbbbbbbbbbbbbbb"); matcher.region(6, 13); // ab [6, 13) - Assert.assertTrue(matcher.find()); - Assert.assertEquals(6, matcher.start()); - Assert.assertEquals(13, matcher.end()); + Assertions.assertTrue(matcher.find()); + Assertions.assertEquals(6, matcher.start()); + Assertions.assertEquals(13, matcher.end()); } @Test @@ -580,9 +579,9 @@ public void startEndPartiallyRegionMatchesTest() { Matcher matcher = PATTERN.matcher("abbbbbbbbabbabbbbbbbbb"); matcher.region(6, 13); // abb [9, 12) - Assert.assertTrue(matcher.find()); - Assert.assertEquals(9, matcher.start()); - Assert.assertEquals(12, matcher.end()); + Assertions.assertTrue(matcher.find()); + Assertions.assertEquals(9, matcher.start()); + Assertions.assertEquals(12, matcher.end()); } @Test @@ -590,8 +589,8 @@ public void startRegionDoesNotMatchesTest() { Matcher matcher = PATTERN.matcher("abbbbbbbbbbbbbbbbbbbbb"); matcher.region(6, 13); - Assert.assertFalse(matcher.find()); - Assert.assertThrows(IllegalStateException.class, () -> matcher.start()); + Assertions.assertFalse(matcher.find()); + Assertions.assertThrows(IllegalStateException.class, () -> matcher.start()); } @Test @@ -599,8 +598,8 @@ public void endRegionDoesNotMatchesTest() { Matcher matcher = PATTERN.matcher("abbbbbbbbbbbbbbbbbbbbb"); matcher.region(6, 13); - Assert.assertFalse(matcher.find()); - Assert.assertThrows(IllegalStateException.class, () -> matcher.end()); + Assertions.assertFalse(matcher.find()); + Assertions.assertThrows(IllegalStateException.class, () -> matcher.end()); } @Test @@ -608,29 +607,29 @@ public void groupsAndRegionTest() { Matcher matcher = PATTERN.matcher("abbbbbabababbbbbbbbbbb"); matcher.region(6, 8); // ab [6, 8) - Assert.assertTrue(matcher.find()); - Assert.assertEquals("ab", matcher.group()); - Assert.assertEquals("ab", matcher.group(0)); - Assert.assertEquals("a", matcher.group(1)); - Assert.assertEquals("b", matcher.group(2)); + Assertions.assertTrue(matcher.find()); + Assertions.assertEquals("ab", matcher.group()); + Assertions.assertEquals("ab", matcher.group(0)); + Assertions.assertEquals("a", matcher.group(1)); + Assertions.assertEquals("b", matcher.group(2)); } @Test public void regionResetsSearchTest() { Matcher matcher = PATTERN.matcher("bbbbbbabbbbbbbbbabbbbb"); // abbbbbbbbb [6, 16) - Assert.assertTrue(matcher.find()); - Assert.assertEquals(6, matcher.start()); - Assert.assertEquals(16, matcher.end()); + Assertions.assertTrue(matcher.find()); + Assertions.assertEquals(6, matcher.start()); + Assertions.assertEquals(16, matcher.end()); // abbbbb [16, 22) - Assert.assertTrue(matcher.find()); - Assert.assertEquals(16, matcher.start()); - Assert.assertEquals(22, matcher.end()); + Assertions.assertTrue(matcher.find()); + Assertions.assertEquals(16, matcher.start()); + Assertions.assertEquals(22, matcher.end()); matcher.region(6, 13); // abbbbbb [6, 16) - Assert.assertTrue(matcher.find()); - Assert.assertEquals(6, matcher.start()); - Assert.assertEquals(13, matcher.end()); + Assertions.assertTrue(matcher.find()); + Assertions.assertEquals(6, matcher.start()); + Assertions.assertEquals(13, matcher.end()); } @Test @@ -638,11 +637,11 @@ public void findWithParamResetsRegionTest() { Matcher matcher = PATTERN.matcher("abbbbbbbbbbbbbbbbbbbbb"); matcher.region(6, 13); // bbbbbbb [6, 13) - Assert.assertFalse(matcher.find()); - Assert.assertTrue(matcher.find(0)); - Assert.assertEquals("abbbbbbbbbbbbbbbbbbbbb", matcher.group()); - Assert.assertEquals(0, matcher.start()); - Assert.assertEquals(22, matcher.end()); + Assertions.assertFalse(matcher.find()); + Assertions.assertTrue(matcher.find(0)); + Assertions.assertEquals("abbbbbbbbbbbbbbbbbbbbb", matcher.group()); + Assertions.assertEquals(0, matcher.start()); + Assertions.assertEquals(22, matcher.end()); } @Test @@ -651,7 +650,7 @@ public void startAfterRegionThrowsExceptionTest() { matcher.find(); matcher.region(6, 13); - Assert.assertThrows(IllegalStateException.class, () -> matcher.start()); + Assertions.assertThrows(IllegalStateException.class, () -> matcher.start()); } @Test @@ -660,7 +659,7 @@ public void endAfterRegionThrowsExceptionTest() { matcher.find(); matcher.region(6, 13); - Assert.assertThrows(IllegalStateException.class, () -> matcher.end()); + Assertions.assertThrows(IllegalStateException.class, () -> matcher.end()); } @Test @@ -669,7 +668,7 @@ public void groupAfterRegionThrowsExceptionTest() { matcher.find(); matcher.region(6, 13); - Assert.assertThrows(IllegalStateException.class, () -> matcher.group()); + Assertions.assertThrows(IllegalStateException.class, () -> matcher.group()); } } diff --git a/io/src/test/java/com/itextpdf/io/util/PdfNameUtilTest.java b/io/src/test/java/com/itextpdf/io/util/PdfNameUtilTest.java index 1fb3ee39ec..a0d07774fb 100644 --- a/io/src/test/java/com/itextpdf/io/util/PdfNameUtilTest.java +++ b/io/src/test/java/com/itextpdf/io/util/PdfNameUtilTest.java @@ -23,24 +23,23 @@ This file is part of the iText (R) project. package com.itextpdf.io.util; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfNameUtilTest extends ExtendedITextTest { @Test public void decodeNameTest(){ // /#C3#9Cberschrift_1 byte[] name1Content = new byte[] {35, 67, 51, 35, 57, 67, 98, 101, 114, 115, 99, 104, 114, 105, 102, 116, 95, 49}; - Assert.assertEquals("Ã\u009Cberschrift_1", PdfNameUtil.decodeName(name1Content)); + Assertions.assertEquals("Ã\u009Cberschrift_1", PdfNameUtil.decodeName(name1Content)); // /TOC-1 byte[] name2Content = new byte[] {84, 79, 67, 45, 49}; - Assert.assertEquals("TOC-1", PdfNameUtil.decodeName(name2Content)); + Assertions.assertEquals("TOC-1", PdfNameUtil.decodeName(name2Content)); // /NormalParagraphStyle byte[] name3Content = new byte[] {78, 111, 114, 109, 97, 108, 80, 97, 114, 97, 103, 114, 97, 112, 104, 83, 116, 121, 108, 101}; - Assert.assertEquals("NormalParagraphStyle", PdfNameUtil.decodeName(name3Content)); + Assertions.assertEquals("NormalParagraphStyle", PdfNameUtil.decodeName(name3Content)); } } diff --git a/io/src/test/java/com/itextpdf/io/util/TextUtilTest.java b/io/src/test/java/com/itextpdf/io/util/TextUtilTest.java index b6f9524482..89092b2be1 100644 --- a/io/src/test/java/com/itextpdf/io/util/TextUtilTest.java +++ b/io/src/test/java/com/itextpdf/io/util/TextUtilTest.java @@ -25,21 +25,20 @@ This file is part of the iText (R) project. import com.itextpdf.io.font.otf.Glyph; import com.itextpdf.io.font.otf.GlyphLine; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.util.Arrays; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class TextUtilTest extends ExtendedITextTest { private Glyph carriageReturn; private Glyph lineFeed; - @Before + @BeforeEach public void before() { this.carriageReturn = new Glyph(0, 0, '\r'); this.lineFeed = new Glyph(0, 0, '\n'); @@ -84,42 +83,42 @@ public void carriageReturnPrecededByTextFollowedByLineFeedTest() { @Test public void isLetterPositiveTest() { Glyph glyph = new Glyph(0, 0, 'a'); - Assert.assertTrue(TextUtil.isLetterOrDigit(glyph)); + Assertions.assertTrue(TextUtil.isLetterOrDigit(glyph)); } @Test public void isDigitPositiveTest() { Glyph glyph = new Glyph(0, 0, '8'); - Assert.assertTrue(TextUtil.isLetterOrDigit(glyph)); + Assertions.assertTrue(TextUtil.isLetterOrDigit(glyph)); } @Test public void isLetterOrDigitNegativeTest() { Glyph glyph = new Glyph(0, 0, '-'); - Assert.assertFalse(TextUtil.isLetterOrDigit(glyph)); + Assertions.assertFalse(TextUtil.isLetterOrDigit(glyph)); } @Test public void isMarkPositiveTest() { // TAI THAM SIGN KHUEN TONE-3 Glyph glyph = new Glyph(0, 0, 0x1A77); - Assert.assertTrue(TextUtil.isMark(glyph)); + Assertions.assertTrue(TextUtil.isMark(glyph)); } @Test public void isMarkNegativeTest() { Glyph glyph = new Glyph(0, 0, '-'); - Assert.assertFalse(TextUtil.isMark(glyph)); + Assertions.assertFalse(TextUtil.isMark(glyph)); } @Test public void isDiacriticTest() { - Assert.assertTrue(TextUtil.isDiacritic("\u0303".charAt(0))); - Assert.assertFalse(TextUtil.isDiacritic("\u006b".charAt(0))); + Assertions.assertTrue(TextUtil.isDiacritic("\u0303".charAt(0))); + Assertions.assertFalse(TextUtil.isDiacritic("\u006b".charAt(0))); } private void helper(boolean expected, int currentCRPosition, Glyph...glyphs) { GlyphLine glyphLine = new GlyphLine(Arrays.asList(glyphs)); - Assert.assertTrue(expected == TextUtil.isCarriageReturnFollowedByLineFeed(glyphLine, currentCRPosition)); + Assertions.assertTrue(expected == TextUtil.isCarriageReturnFollowedByLineFeed(glyphLine, currentCRPosition)); } } diff --git a/io/src/test/java/com/itextpdf/io/util/UrlUtilTest.java b/io/src/test/java/com/itextpdf/io/util/UrlUtilTest.java index b7156c6f4c..6302fb1fde 100644 --- a/io/src/test/java/com/itextpdf/io/util/UrlUtilTest.java +++ b/io/src/test/java/com/itextpdf/io/util/UrlUtilTest.java @@ -24,7 +24,6 @@ This file is part of the iText (R) project. import com.itextpdf.commons.utils.FileUtil; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.File; import java.io.IOException; @@ -39,17 +38,17 @@ This file is part of the iText (R) project. // Android-Conversion-Skip-Line (Security provider is required for working getFinalConnection through SSL on Android) // Android-Conversion-Replace import java.security.Security; // Android-Conversion-Replace import org.bouncycastle.jce.provider.BouncyCastleProvider; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class UrlUtilTest extends ExtendedITextTest { private static final String destinationFolder = "./target/test/com/itextpdf/io/UrlUtilTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { // Android-Conversion-Skip-Line (Security provider is required for working getFinalConnection through SSL on Android) // Android-Conversion-Replace Security.addProvider(new BouncyCastleProvider()); @@ -67,9 +66,9 @@ public void getFinalConnectionWhileRedirectingTest() throws IOException { try { finalConnection = UrlUtil.getFinalConnection(initialUrl); - Assert.assertNotNull(finalConnection); - Assert.assertNotEquals(initialUrl, finalConnection.getURL()); - Assert.assertEquals(expectedURL, finalConnection.getURL()); + Assertions.assertNotNull(finalConnection); + Assertions.assertNotEquals(initialUrl, finalConnection.getURL()); + Assertions.assertEquals(expectedURL, finalConnection.getURL()); } finally { finalConnection.getInputStream().close(); } @@ -81,7 +80,7 @@ public void getFinalConnectionWhileRedirectingTest() throws IOException { public void getInputStreamOfFinalConnectionThrowExceptionTest() throws IOException { URL invalidUrl = new URL("http://itextpdf"); - Assert.assertThrows(UnknownHostException.class, () -> UrlUtil.getInputStreamOfFinalConnection(invalidUrl)); + Assertions.assertThrows(UnknownHostException.class, () -> UrlUtil.getInputStreamOfFinalConnection(invalidUrl)); } // This test checks that when we pass valid url and trying get stream related to final redirected url, it would @@ -91,7 +90,7 @@ public void getInputStreamOfFinalConnectionTest() throws IOException { URL initialUrl = new URL("http://itextpdf.com"); InputStream streamOfFinalConnectionOfInvalidUrl = UrlUtil.getInputStreamOfFinalConnection(initialUrl); - Assert.assertNotNull(streamOfFinalConnectionOfInvalidUrl); + Assertions.assertNotNull(streamOfFinalConnectionOfInvalidUrl); } @Test @@ -101,20 +100,20 @@ public void getBaseUriTest() throws IOException { // Android-Conversion-Skip-Line (TODO DEVSIX-7371 investigate different behavior of a few iTextCore tests on Java and Android) String expected = absolutePathRoot + destinationFolder; // Android-Conversion-Replace String expected = absolutePathRoot + destinationFolder.substring(1); File tempFile = FileUtil.createTempFile(destinationFolder); - Assert.assertEquals(expected, FileUtil.getParentDirectoryUri(tempFile)); + Assertions.assertEquals(expected, FileUtil.getParentDirectoryUri(tempFile)); } @Test public void nullBaseUriTest() throws IOException { String expected = ""; File tempFile = null; - Assert.assertEquals(expected, FileUtil.getParentDirectoryUri(tempFile)); + Assertions.assertEquals(expected, FileUtil.getParentDirectoryUri(tempFile)); } @Test public void toAbsoluteUriTest() throws IOException, URISyntaxException { String expected = "http://itextpdf.com/"; - Assert.assertEquals(expected, UrlUtil.toAbsoluteURI(new URI(expected))); + Assertions.assertEquals(expected, UrlUtil.toAbsoluteURI(new URI(expected))); } @Test @@ -123,7 +122,7 @@ public void openStreamTest() throws IOException { InputStream openStream = UrlUtil.openStream(new File(resPath).toURI().toURL()); String actual = new String(StreamUtil.inputStreamToArray(openStream), StandardCharsets.UTF_8); - Assert.assertEquals("Hello world from text file!", actual); + Assertions.assertEquals("Hello world from text file!", actual); } } diff --git a/io/src/test/java/com/itextpdf/io/util/XmlUtilTest.java b/io/src/test/java/com/itextpdf/io/util/XmlUtilTest.java index 5b2c2f3731..479846610b 100644 --- a/io/src/test/java/com/itextpdf/io/util/XmlUtilTest.java +++ b/io/src/test/java/com/itextpdf/io/util/XmlUtilTest.java @@ -23,25 +23,24 @@ This file is part of the iText (R) project. package com.itextpdf.io.util; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; // Android-Conversion-Skip-Line (Directly use xerces library to unify behavior with vanilla java (where xerces is implemented into JRE)) // Android-Conversion-Replace import org.apache.xerces.jaxp.DocumentBuilderFactoryImpl; // Android-Conversion-Replace import org.apache.xerces.jaxp.SAXParserFactoryImpl; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import org.w3c.dom.Document; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.SAXParserFactory; -@Category(UnitTest.class) +@Tag("UnitTest") public class XmlUtilTest extends ExtendedITextTest { @Test public void initNewXmlDocumentTest() throws Exception { Document doc = XmlUtil.initNewXmlDocument(); - Assert.assertNotNull(doc); + Assertions.assertNotNull(doc); } @Test @@ -49,7 +48,7 @@ public void getDocumentBuilderFactoryTest() { DocumentBuilderFactory factory = XmlUtil.getDocumentBuilderFactory(); // Android-Conversion-Skip-Line (Directly use xerces library to unify behavior with vanilla java (where xerces is implemented into JRE)) - Assert.assertEquals(DocumentBuilderFactory.newInstance().getClass(), factory.getClass()); // Android-Conversion-Replace Assert.assertEquals(DocumentBuilderFactoryImpl.class, factory.getClass()); + Assertions.assertEquals(DocumentBuilderFactory.newInstance().getClass(), factory.getClass()); // Android-Conversion-Replace Assertions.assertEquals(DocumentBuilderFactoryImpl.class, factory.getClass()); } @Test @@ -57,6 +56,6 @@ public void createSAXParserFactoryTest() { SAXParserFactory factory = XmlUtil.createSAXParserFactory(); // Android-Conversion-Skip-Line (Directly use xerces library to unify behavior with vanilla java (where xerces is implemented into JRE)) - Assert.assertEquals(SAXParserFactory.newInstance().getClass(), factory.getClass()); // Android-Conversion-Replace Assert.assertEquals(SAXParserFactoryImpl.class, factory.getClass()); + Assertions.assertEquals(SAXParserFactory.newInstance().getClass(), factory.getClass()); // Android-Conversion-Replace Assertions.assertEquals(SAXParserFactoryImpl.class, factory.getClass()); } } diff --git a/io/src/test/java/com/itextpdf/io/util/ZlibUtilTest.java b/io/src/test/java/com/itextpdf/io/util/ZlibUtilTest.java index 397806ef39..007d0f1774 100644 --- a/io/src/test/java/com/itextpdf/io/util/ZlibUtilTest.java +++ b/io/src/test/java/com/itextpdf/io/util/ZlibUtilTest.java @@ -26,22 +26,21 @@ This file is part of the iText (R) project. import com.itextpdf.commons.utils.ZipFileReader; import com.itextpdf.io.source.DeflaterOutputStream; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.InputStream; import java.io.OutputStream; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class ZlibUtilTest extends ExtendedITextTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/io/util/"; private static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/io/util/"; - @Before + @BeforeEach public void setUp() { createOrClearDestinationFolder(DESTINATION_FOLDER); } @@ -72,7 +71,7 @@ public void arrayIndexOutOfBoundsDeflateTest() throws Exception { } } - Assert.assertTrue(FileUtil.fileExists(DESTINATION_FOLDER + "jzlib.fail.zz")); - Assert.assertTrue(FileUtil.isFileNotEmpty(DESTINATION_FOLDER + "jzlib.fail.zz")); + Assertions.assertTrue(FileUtil.fileExists(DESTINATION_FOLDER + "jzlib.fail.zz")); + Assertions.assertTrue(FileUtil.isFileNotEmpty(DESTINATION_FOLDER + "jzlib.fail.zz")); } } diff --git a/io/src/test/resources/com/itextpdf/io/font/otf/GposLookupType2Test/BitstreamCopyright.txt b/io/src/test/resources/com/itextpdf/io/font/otf/GposLookupType2Test/BitstreamCopyright.txt new file mode 100644 index 0000000000..ce8e3a19b1 --- /dev/null +++ b/io/src/test/resources/com/itextpdf/io/font/otf/GposLookupType2Test/BitstreamCopyright.txt @@ -0,0 +1,15 @@ +Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Bitstream Vera is a trademark of Bitstream, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy of the fonts accompanying this license ("Fonts") and associated documentation files (the "Font Software"), to reproduce and distribute the Font Software, including without limitation the rights to use, copy, merge, publish, distribute, and/or sell copies of the Font Software, and to permit persons to whom the Font Software is furnished to do so, subject to the following conditions: + +The above copyright and trademark notices and this permission notice shall be included in all copies of one or more of the Font Software typefaces. + +The Font Software may be modified, altered, or added to, and in particular the designs of glyphs or characters in the Fonts may be modified and additional glyphs or characters may be added to the Fonts, only if the fonts are renamed to names not containing either the words "Bitstream" or the word "Vera". + +This License becomes null and void to the extent applicable to Fonts or Font Software that has been modified and is distributed under the "Bitstream Vera" names. + +The Font Software may be sold as part of a larger software package but no copy of one or more of the Font Software typefaces may be sold by itself. + +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL BITSTREAM OR THE GNOME FOUNDATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE. + +Except as contained in this notice, the names of Gnome, the Gnome Foundation, and Bitstream Inc., shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Font Software without prior written authorization from the Gnome Foundation or Bitstream Inc., respectively. For further information, contact: fonts at gnome dot org. \ No newline at end of file diff --git a/io/src/test/resources/com/itextpdf/io/font/otf/GposLookupType2Test/DejaVuSans.ttf b/io/src/test/resources/com/itextpdf/io/font/otf/GposLookupType2Test/DejaVuSans.ttf new file mode 100644 index 0000000000..e5f7eecce4 Binary files /dev/null and b/io/src/test/resources/com/itextpdf/io/font/otf/GposLookupType2Test/DejaVuSans.ttf differ diff --git a/io/src/test/resources/com/itextpdf/io/font/otf/GposLookupType2Test/LICENSE_OFL.txt b/io/src/test/resources/com/itextpdf/io/font/otf/GposLookupType2Test/LICENSE_OFL.txt new file mode 100644 index 0000000000..d952d62c06 --- /dev/null +++ b/io/src/test/resources/com/itextpdf/io/font/otf/GposLookupType2Test/LICENSE_OFL.txt @@ -0,0 +1,92 @@ +This Font Software is licensed under the SIL Open Font License, +Version 1.1. + +This license is copied below, and is also available with a FAQ at: +http://scripts.sil.org/OFL + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font +creation efforts of academic and linguistic communities, and to +provide a free and open framework in which fonts may be shared and +improved in partnership with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply to +any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software +components as distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, +deleting, or substituting -- in part or in whole -- any of the +components of the Original Version, by changing formats or by porting +the Font Software to a new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, +modify, redistribute, and sell modified and unmodified copies of the +Font Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, in +Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the +corresponding Copyright Holder. This restriction only applies to the +primary font name as presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created using +the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/io/src/test/resources/com/itextpdf/io/font/otf/GposLookupType2Test/NOTICE.txt b/io/src/test/resources/com/itextpdf/io/font/otf/GposLookupType2Test/NOTICE.txt new file mode 100644 index 0000000000..afc7fd35ee --- /dev/null +++ b/io/src/test/resources/com/itextpdf/io/font/otf/GposLookupType2Test/NOTICE.txt @@ -0,0 +1,3 @@ +This software uses the following test resources under the following licenses: +| NotoSansMyanmar-Regular.ttf | OFL-1.1 | LICENSE-OFL.txt | +| DejaVuSans.ttf | BitstreamCopyright | BitstreamCopyright.txt | diff --git a/io/src/test/resources/com/itextpdf/io/font/otf/GposLookupType2Test/NotoSansMyanmar-Regular.ttf b/io/src/test/resources/com/itextpdf/io/font/otf/GposLookupType2Test/NotoSansMyanmar-Regular.ttf new file mode 100644 index 0000000000..e70e237f6d Binary files /dev/null and b/io/src/test/resources/com/itextpdf/io/font/otf/GposLookupType2Test/NotoSansMyanmar-Regular.ttf differ diff --git a/io/src/test/resources/com/itextpdf/io/font/sharedFontsResourceFiles/NOTICE.txt b/io/src/test/resources/com/itextpdf/io/font/sharedFontsResourceFiles/NOTICE.txt index 1bd85853dd..1a10901d9c 100644 --- a/io/src/test/resources/com/itextpdf/io/font/sharedFontsResourceFiles/NOTICE.txt +++ b/io/src/test/resources/com/itextpdf/io/font/sharedFontsResourceFiles/NOTICE.txt @@ -3,4 +3,5 @@ This software uses the following test resources under the following licenses: | NotoSansTC-Regular.otf | OFL-1.1 | OFL.txt | Based on commit 165c01b46ea533872e002e0785ff17e44f6d97d8 (30.04.2021) from repository: "https://github.com/googlefonts/noto-cjk" | NotoSansSC-Regular.otf | OFL-1.1 | OFL.txt | Based on commit 165c01b46ea533872e002e0785ff17e44f6d97d8 (30.04.2021) from repository: "https://github.com/googlefonts/noto-cjk" | NotoSansCJKjp-Bold.otf | OFL-1.1 | OFL.txt | Based on commit 165c01b46ea533872e002e0785ff17e44f6d97d8 (30.04.2021) from repository: "https://github.com/googlefonts/noto-cjk" -| Puritan2 | OFL-1.1 | OFL.txt | \ No newline at end of file +| Puritan2 | OFL-1.1 | OFL.txt | +| glyphs.ttf, glyphs-fmt-6.ttf | MIT | Derived from https://github.com/RazrFalcon/ttf-parser/tree/337e7d1c08b06478a84c4345f4f289fc2cb9210c/tests/fonts-src | diff --git a/io/src/test/resources/com/itextpdf/io/font/sharedFontsResourceFiles/glyphs-fmt-6.ttf b/io/src/test/resources/com/itextpdf/io/font/sharedFontsResourceFiles/glyphs-fmt-6.ttf new file mode 100644 index 0000000000..941a4cd173 Binary files /dev/null and b/io/src/test/resources/com/itextpdf/io/font/sharedFontsResourceFiles/glyphs-fmt-6.ttf differ diff --git a/io/src/test/resources/com/itextpdf/io/font/sharedFontsResourceFiles/glyphs.ttf b/io/src/test/resources/com/itextpdf/io/font/sharedFontsResourceFiles/glyphs.ttf new file mode 100644 index 0000000000..60436aeb3c Binary files /dev/null and b/io/src/test/resources/com/itextpdf/io/font/sharedFontsResourceFiles/glyphs.ttf differ diff --git a/io/src/test/resources/com/itextpdf/io/font/woff2/w3c/format/cmp_tabledata-transform-glyf-loca-001.ttf b/io/src/test/resources/com/itextpdf/io/font/woff2/w3c/format/cmp_tabledata-transform-glyf-loca-001.ttf deleted file mode 100644 index 65803816de..0000000000 Binary files a/io/src/test/resources/com/itextpdf/io/font/woff2/w3c/format/cmp_tabledata-transform-glyf-loca-001.ttf and /dev/null differ diff --git a/io/src/test/resources/com/itextpdf/io/image/ImageTypeDetectorTest/image.png b/io/src/test/resources/com/itextpdf/io/image/ImageTypeDetectorTest/image.png deleted file mode 100644 index 002a133c4e..0000000000 Binary files a/io/src/test/resources/com/itextpdf/io/image/ImageTypeDetectorTest/image.png and /dev/null differ diff --git a/itext7core/pom.xml b/itext7core/pom.xml index e2a32cfb2e..06d05d8e90 100644 --- a/itext7core/pom.xml +++ b/itext7core/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.itextpdf itext7-core - 8.0.5 + 9.0.0 pom iText 7 Core A Free Java-PDF library diff --git a/itextcore/pom.xml b/itextcore/pom.xml index 4b66079e6f..c7f8f4abad 100644 --- a/itextcore/pom.xml +++ b/itextcore/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.itextpdf itext-core - 8.0.5 + 9.0.0 pom iText Core A Free Java-PDF library diff --git a/kernel/pom.xml b/kernel/pom.xml index a9ccbc4e02..dd2f966bb2 100644 --- a/kernel/pom.xml +++ b/kernel/pom.xml @@ -5,7 +5,7 @@ com.itextpdf root - 8.0.5 + 9.0.0 kernel diff --git a/kernel/src/main/java/com/itextpdf/kernel/actions/data/ITextCoreProductData.java b/kernel/src/main/java/com/itextpdf/kernel/actions/data/ITextCoreProductData.java index f6a3a18d80..97fc206e86 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/actions/data/ITextCoreProductData.java +++ b/kernel/src/main/java/com/itextpdf/kernel/actions/data/ITextCoreProductData.java @@ -30,7 +30,7 @@ This file is part of the iText (R) project. */ public final class ITextCoreProductData { private static final String CORE_PUBLIC_PRODUCT_NAME = "Core"; - private static final String CORE_VERSION = "8.0.5"; + private static final String CORE_VERSION = "9.0.0"; private static final int CORE_COPYRIGHT_SINCE = 2000; private static final int CORE_COPYRIGHT_TO = 2024; diff --git a/kernel/src/main/java/com/itextpdf/kernel/actions/events/AddFingerPrintEvent.java b/kernel/src/main/java/com/itextpdf/kernel/actions/events/AddFingerPrintEvent.java new file mode 100644 index 0000000000..c9169d69f1 --- /dev/null +++ b/kernel/src/main/java/com/itextpdf/kernel/actions/events/AddFingerPrintEvent.java @@ -0,0 +1,108 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.actions.events; + +import com.itextpdf.commons.actions.AbstractITextConfigurationEvent; +import com.itextpdf.commons.actions.data.ProductData; +import com.itextpdf.commons.actions.processors.ITextProductEventProcessor; +import com.itextpdf.commons.utils.MessageFormatUtil; +import com.itextpdf.kernel.actions.data.ITextCoreProductData; +import com.itextpdf.kernel.logs.KernelLogMessageConstant; +import com.itextpdf.kernel.pdf.FingerPrint; +import com.itextpdf.kernel.pdf.PdfDocument; +import com.itextpdf.kernel.pdf.PdfWriter; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.lang.ref.WeakReference; +import java.util.Collection; + +/** + * This class is responsible for adding a fingerprint. + */ +public final class AddFingerPrintEvent extends AbstractITextConfigurationEvent { + + private final WeakReference document; + + private static final Logger LOGGER = LoggerFactory.getLogger(AddFingerPrintEvent.class); + + private static final String AGPL_MODE = "AGPL"; + + /** + * Creates a new instance of the AddFingerPrintEvent. + * + * @param document document in which the fingerprint will be added + */ + public AddFingerPrintEvent(PdfDocument document) { + super(); + this.document = new WeakReference<>(document); + } + + /** + * Adds fingerprint to the document. + */ + @Override + public void doAction() { + final PdfDocument pdfDocument = (PdfDocument) document.get(); + if (pdfDocument == null) { + return; + } + + final FingerPrint fingerPrint = pdfDocument.getFingerPrint(); + final Collection products = fingerPrint.getProducts(); + //if fingerprint is disabled and all licence types isn't AGPL then no actions required + if (!fingerPrint.isFingerPrintEnabled()) { + boolean nonAGPLMode = true; + for (ProductData productData : products) { + ITextProductEventProcessor processor = getActiveProcessor(productData.getProductName()); + if (processor == null){ + continue; + } + + if (AGPL_MODE.equals(processor.getUsageType())) { + nonAGPLMode = false; + break; + } + } + + if (nonAGPLMode) { + return; + } + + LOGGER.warn(KernelLogMessageConstant.FINGERPRINT_DISABLED_BUT_NO_REQUIRED_LICENCE); + } + + + PdfWriter writer = pdfDocument.getWriter(); + if (products.isEmpty()) { + writer.writeString(MessageFormatUtil + .format("%iText-{0}-no-registered-products\n", ITextCoreProductData.getInstance().getVersion())); + return; + } + + for (ProductData productData : products) { + writer.writeString(MessageFormatUtil + .format("%iText-{0}-{1}\n", productData.getPublicProductName(), productData.getVersion())); + } + } +} diff --git a/kernel/src/main/java/com/itextpdf/kernel/colors/gradients/AbstractLinearGradientBuilder.java b/kernel/src/main/java/com/itextpdf/kernel/colors/gradients/AbstractLinearGradientBuilder.java index e901abe7e6..1515deed08 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/colors/gradients/AbstractLinearGradientBuilder.java +++ b/kernel/src/main/java/com/itextpdf/kernel/colors/gradients/AbstractLinearGradientBuilder.java @@ -36,7 +36,7 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.colorspace.PdfDeviceCs; import com.itextpdf.kernel.pdf.colorspace.PdfPattern; -import com.itextpdf.kernel.pdf.colorspace.PdfShading; +import com.itextpdf.kernel.pdf.colorspace.shading.PdfAxialShading; import com.itextpdf.kernel.pdf.function.AbstractPdfFunction; import com.itextpdf.kernel.pdf.function.IPdfFunction; import com.itextpdf.kernel.pdf.function.PdfType2Function; @@ -166,7 +166,7 @@ public Color buildColor(Rectangle targetBoundingBox, AffineTransform contextTran } } - PdfShading.Axial axial = createAxialShading(baseCoordinatesVector, this.stops, this.spreadMethod, + PdfAxialShading axial = createAxialShading(baseCoordinatesVector, this.stops, this.spreadMethod, targetBoundingBox); if (axial == null) { return null; @@ -268,12 +268,12 @@ protected static Point[] createCoordinatesForNewDomain(double[] newDomain, Point baseVector[0].getLocation(), baseVector[1].getLocation() }; - targetCoords[0].translate(xDiff * newDomain[0], yDiff * newDomain[0]); - targetCoords[1].translate(xDiff * (newDomain[1] - 1), yDiff * (newDomain[1] - 1)); + targetCoords[0].move(xDiff * newDomain[0], yDiff * newDomain[0]); + targetCoords[1].move(xDiff * (newDomain[1] - 1), yDiff * (newDomain[1] - 1)); return targetCoords; } - private static PdfShading.Axial createAxialShading(Point[] baseCoordinatesVector, + private static PdfAxialShading createAxialShading(Point[] baseCoordinatesVector, List stops, GradientSpreadMethod spreadMethod, Rectangle targetBoundingBox) { double baseVectorLength = baseCoordinatesVector[1].distance(baseCoordinatesVector[0]); @@ -315,7 +315,7 @@ private static PdfShading.Axial createAxialShading(Point[] baseCoordinatesVector actualCoordinates = createCoordinatesForNewDomain(coordinatesDomain, baseCoordinatesVector); } - return new PdfShading.Axial( + return new PdfAxialShading( new PdfDeviceCs.Rgb(), createCoordsPdfArray(actualCoordinates), new PdfArray(coordinatesDomain), diff --git a/kernel/src/main/java/com/itextpdf/kernel/crypto/AESGCMCipher.java b/kernel/src/main/java/com/itextpdf/kernel/crypto/AESGCMCipher.java new file mode 100644 index 0000000000..0c2bb4adc3 --- /dev/null +++ b/kernel/src/main/java/com/itextpdf/kernel/crypto/AESGCMCipher.java @@ -0,0 +1,100 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.crypto; + +import com.itextpdf.bouncycastleconnector.BouncyCastleFactoryCreator; +import com.itextpdf.commons.bouncycastle.IBouncyCastleFactory; +import com.itextpdf.commons.bouncycastle.crypto.modes.IGCMBlockCipher; +import com.itextpdf.kernel.exceptions.KernelExceptionMessageConstant; +import com.itextpdf.kernel.exceptions.PdfException; +import java.security.GeneralSecurityException; + +/** + * Creates an Advanced Encryption Standard-Galois/Counter Mode (AES-GCM) Cipher. + */ +public class AESGCMCipher { + public static final int MAC_SIZE_BITS = 128; + + private static final IBouncyCastleFactory BOUNCY_CASTLE_FACTORY = BouncyCastleFactoryCreator.getFactory(); + + private final IGCMBlockCipher cipher; + + /** + * Creates a new instance of {@link AESGCMCipher}. + * + * @param forEncryption if true the cipher is initialised for + * encryption, if false for decryption + * @param key the key to be used in the cipher + * @param iv initialization vector to be used in cipher + */ + public AESGCMCipher(boolean forEncryption, byte[] key, byte[] iv) { + try { + cipher = BOUNCY_CASTLE_FACTORY.createGCMBlockCipher(); + cipher.init(forEncryption, key, MAC_SIZE_BITS, iv); + } catch (GeneralSecurityException e) { + throw new PdfException(KernelExceptionMessageConstant.ERROR_WHILE_INITIALIZING_AES_CIPHER, e); + } + } + + /** + * Continues a multiple-part encryption or decryption operation + * (depending on how this cipher was initialized), processing another data + * part. + * + *

+ * The first {@code len} bytes in the {@code b} input buffer, starting at {@code off} offset inclusive, + * are processed, and the result is stored in a new buffer. + * + * @param b the input buffer + * @param off the offset in {@code b} where the input starts + * @param len the input length + * + * @return the new buffer with the result + */ + public byte[] update(byte[] b, int off, int len) { + byte[] cipherBuffer = new byte[cipher.getUpdateOutputSize(len)]; + try { + cipher.processBytes(b, off, len, cipherBuffer, 0); + } catch (GeneralSecurityException e) { + throw new PdfException(KernelExceptionMessageConstant.PDF_ENCRYPTION, e); + } + return cipherBuffer; + } + + /** + * Finishes a multiple-part encryption or decryption operation, depending on how this cipher was initialized + * and resets underlying cipher object to the state it was in when previously + * initialized via a call to init. + * + * @return final bytes array + */ + public byte[] doFinal() { + byte[] cipherBuffer = new byte[cipher.getOutputSize(0)]; + try { + cipher.doFinal(cipherBuffer, 0); + return cipherBuffer; + } catch (GeneralSecurityException | IllegalArgumentException e) { + throw new PdfException(KernelExceptionMessageConstant.PDF_ENCRYPTION, e); + } + } +} diff --git a/kernel/src/main/java/com/itextpdf/kernel/crypto/AesGcmDecryptor.java b/kernel/src/main/java/com/itextpdf/kernel/crypto/AesGcmDecryptor.java new file mode 100644 index 0000000000..cfa8277da7 --- /dev/null +++ b/kernel/src/main/java/com/itextpdf/kernel/crypto/AesGcmDecryptor.java @@ -0,0 +1,87 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.crypto; + +/** + * Class for decrypting aes-gcm encrypted bytes. + */ +public class AesGcmDecryptor implements IDecryptor { + private AESGCMCipher cipher; + private final byte[] key; + private boolean initiated; + private final byte[] iv = new byte[12]; + private int ivptr; + + /** + * Creates a new instance of {@link com.itextpdf.kernel.crypto.AesGcmDecryptor}. + * + * @param key the byte array containing the key for decryption + * @param off offset of the key in the byte array + * @param len the length of the key in the byte array + */ + public AesGcmDecryptor(byte[] key, int off, int len) { + this.key = new byte[len]; + System.arraycopy(key, off, this.key, 0, len); + } + + /** + * Continues a multiple-part decryption operation, processing another data part and initializing aes-gcm cipher if + * this method called for the first time. + * + * @param b the input buffer + * @param off the offset in input where the input starts + * @param len the input length + * + * @return decrypted bytes array + */ + public byte[] update(byte[] b, int off, int len) { + if (!initiated) { + int left = Math.min(iv.length - ivptr, len); + System.arraycopy(b, off, iv, ivptr, left); + off += left; + len -= left; + ivptr += left; + if (ivptr == iv.length) { + cipher = new AESGCMCipher(false, key, iv); + initiated = true; + } + if (len == 0) { + return null; + } + } + return cipher.update(b, off, len); + } + + /** + * Finishes a multiple-part decryption operation. + * + * @return input data that may have been buffered during a previous update operation + */ + public byte[] finish() { + if (cipher != null) { + return cipher.doFinal(); + } else { + return null; + } + } +} diff --git a/kernel/src/main/java/com/itextpdf/kernel/crypto/CryptoUtil.java b/kernel/src/main/java/com/itextpdf/kernel/crypto/CryptoUtil.java index e9b5063565..201958a46c 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/crypto/CryptoUtil.java +++ b/kernel/src/main/java/com/itextpdf/kernel/crypto/CryptoUtil.java @@ -31,6 +31,9 @@ This file is part of the iText (R) project. import java.io.InputStream; import java.io.OutputStream; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.security.NoSuchProviderException; import java.security.cert.Certificate; import java.security.cert.CertificateException; import java.security.cert.CertificateFactory; @@ -69,4 +72,13 @@ public static IASN1OutputStream createAsn1OutputStream(OutputStream outputStream } return BOUNCY_CASTLE_FACTORY.createASN1OutputStream(outputStream, asn1Encoding); } + + static MessageDigest getMessageDigest(String hashAlgorithm, String provider) + throws NoSuchAlgorithmException, NoSuchProviderException { + if (provider == null || provider.startsWith("SunPKCS11") || provider.startsWith("SunMSCAPI")) { + return MessageDigest.getInstance(DigestAlgorithms.normalizeDigestName(hashAlgorithm)); + } else { + return MessageDigest.getInstance(hashAlgorithm, provider); + } + } } diff --git a/sign/src/main/java/com/itextpdf/signatures/DigestAlgorithms.java b/kernel/src/main/java/com/itextpdf/kernel/crypto/DigestAlgorithms.java similarity index 78% rename from sign/src/main/java/com/itextpdf/signatures/DigestAlgorithms.java rename to kernel/src/main/java/com/itextpdf/kernel/crypto/DigestAlgorithms.java index f71f96796d..837c6c6f7e 100644 --- a/sign/src/main/java/com/itextpdf/signatures/DigestAlgorithms.java +++ b/kernel/src/main/java/com/itextpdf/kernel/crypto/DigestAlgorithms.java @@ -20,14 +20,12 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.signatures; +package com.itextpdf.kernel.crypto; import com.itextpdf.bouncycastleconnector.BouncyCastleFactoryCreator; import com.itextpdf.commons.bouncycastle.IBouncyCastleFactory; -import com.itextpdf.signatures.exceptions.SignExceptionMessageConstant; -import com.itextpdf.signatures.logs.SignLogMessageConstant; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import com.itextpdf.kernel.exceptions.KernelExceptionMessageConstant; +import com.itextpdf.kernel.logs.KernelLogMessageConstant; import java.io.IOException; import java.io.InputStream; @@ -37,6 +35,8 @@ This file is part of the iText (R) project. import java.security.NoSuchProviderException; import java.util.HashMap; import java.util.Map; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Class that contains a map with the different message digest algorithms. @@ -123,10 +123,10 @@ public class DigestAlgorithms { digestNames.put("1.2.840.113549.2.5", "MD5"); digestNames.put("1.2.840.113549.2.2", "MD2"); digestNames.put("1.3.14.3.2.26", "SHA1"); - digestNames.put("2.16.840.1.101.3.4.2.4", "SHA224"); - digestNames.put("2.16.840.1.101.3.4.2.1", "SHA256"); - digestNames.put("2.16.840.1.101.3.4.2.2", "SHA384"); - digestNames.put("2.16.840.1.101.3.4.2.3", "SHA512"); + digestNames.put(OID.SHA_224, "SHA224"); + digestNames.put(OID.SHA_256, "SHA256"); + digestNames.put(OID.SHA_384, "SHA384"); + digestNames.put(OID.SHA_512, "SHA512"); digestNames.put("1.3.36.3.2.2", "RIPEMD128"); digestNames.put("1.3.36.3.2.1", "RIPEMD160"); digestNames.put("1.3.36.3.2.3", "RIPEMD256"); @@ -137,8 +137,6 @@ public class DigestAlgorithms { digestNames.put("1.2.840.113549.1.1.11", "SHA256"); digestNames.put("1.2.840.113549.1.1.12", "SHA384"); digestNames.put("1.2.840.113549.1.1.13", "SHA512"); - digestNames.put("1.2.840.113549.2.5", "MD5"); - digestNames.put("1.2.840.113549.2.2", "MD2"); digestNames.put("1.2.840.10040.4.3", "SHA1"); digestNames.put("2.16.840.1.101.3.4.3.1", "SHA224"); digestNames.put("2.16.840.1.101.3.4.3.2", "SHA256"); @@ -148,11 +146,11 @@ public class DigestAlgorithms { digestNames.put("1.3.36.3.3.1.2", "RIPEMD160"); digestNames.put("1.3.36.3.3.1.4", "RIPEMD256"); digestNames.put("1.2.643.2.2.9", "GOST3411"); - digestNames.put("2.16.840.1.101.3.4.2.7", "SHA3-224"); - digestNames.put("2.16.840.1.101.3.4.2.8", "SHA3-256"); - digestNames.put("2.16.840.1.101.3.4.2.9", "SHA3-384"); - digestNames.put("2.16.840.1.101.3.4.2.10", "SHA3-512"); - digestNames.put("2.16.840.1.101.3.4.2.12", "SHAKE256"); + digestNames.put(OID.SHA3_224, "SHA3-224"); + digestNames.put(OID.SHA3_256, "SHA3-256"); + digestNames.put(OID.SHA3_384, "SHA3-384"); + digestNames.put(OID.SHA3_512, "SHA3-512"); + digestNames.put(OID.SHAKE_256, "SHAKE256"); fixNames.put("SHA256", SHA256); fixNames.put("SHA384", SHA384); @@ -164,14 +162,14 @@ public class DigestAlgorithms { allowedDigests.put("MD-5", "1.2.840.113549.2.5"); allowedDigests.put("SHA1", "1.3.14.3.2.26"); allowedDigests.put("SHA-1", "1.3.14.3.2.26"); - allowedDigests.put("SHA224", "2.16.840.1.101.3.4.2.4"); - allowedDigests.put("SHA-224", "2.16.840.1.101.3.4.2.4"); - allowedDigests.put("SHA256", "2.16.840.1.101.3.4.2.1"); - allowedDigests.put("SHA-256", "2.16.840.1.101.3.4.2.1"); - allowedDigests.put("SHA384", "2.16.840.1.101.3.4.2.2"); - allowedDigests.put("SHA-384", "2.16.840.1.101.3.4.2.2"); - allowedDigests.put("SHA512", "2.16.840.1.101.3.4.2.3"); - allowedDigests.put("SHA-512", "2.16.840.1.101.3.4.2.3"); + allowedDigests.put("SHA224", OID.SHA_224); + allowedDigests.put("SHA-224", OID.SHA_224); + allowedDigests.put("SHA256", OID.SHA_256); + allowedDigests.put("SHA-256", OID.SHA_256); + allowedDigests.put("SHA384", OID.SHA_384); + allowedDigests.put("SHA-384", OID.SHA_384); + allowedDigests.put("SHA512", OID.SHA_512); + allowedDigests.put("SHA-512", OID.SHA_512); allowedDigests.put("RIPEMD128", "1.3.36.3.2.2"); allowedDigests.put("RIPEMD-128", "1.3.36.3.2.2"); allowedDigests.put("RIPEMD160", "1.3.36.3.2.1"); @@ -179,11 +177,11 @@ public class DigestAlgorithms { allowedDigests.put("RIPEMD256", "1.3.36.3.2.3"); allowedDigests.put("RIPEMD-256", "1.3.36.3.2.3"); allowedDigests.put("GOST3411", "1.2.643.2.2.9"); - allowedDigests.put("SHA3-224", "2.16.840.1.101.3.4.2.7"); - allowedDigests.put("SHA3-256", "2.16.840.1.101.3.4.2.8"); - allowedDigests.put("SHA3-384", "2.16.840.1.101.3.4.2.9"); - allowedDigests.put("SHA3-512", "2.16.840.1.101.3.4.2.10"); - allowedDigests.put("SHAKE256", "2.16.840.1.101.3.4.2.12"); + allowedDigests.put("SHA3-224", OID.SHA3_224); + allowedDigests.put("SHA3-256", OID.SHA3_256); + allowedDigests.put("SHA3-384", OID.SHA3_384); + allowedDigests.put("SHA3-512", OID.SHA3_512); + allowedDigests.put("SHAKE256", OID.SHAKE_256); bitLengths.put("MD2", 128); bitLengths.put("MD-2", 128); @@ -217,7 +215,9 @@ public class DigestAlgorithms { * * @param digestOid oid of the digest algorithm * @param provider the provider you want to use to create the hash + * * @return MessageDigest object + * * @throws NoSuchAlgorithmException thrown when a particular cryptographic algorithm is * requested but is not available in the environment * @throws NoSuchProviderException thrown when a particular security provider is @@ -233,7 +233,9 @@ public static MessageDigest getMessageDigestFromOid(String digestOid, String pro * * @param hashAlgorithm the algorithm you want to use to create a hash * @param provider the provider you want to use to create the hash + * * @return a MessageDigest object + * * @throws NoSuchAlgorithmException thrown when a particular cryptographic algorithm is * requested but is not available in the environment * @throws NoSuchProviderException thrown when a particular security provider is @@ -241,7 +243,7 @@ public static MessageDigest getMessageDigestFromOid(String digestOid, String pro */ public static MessageDigest getMessageDigest(String hashAlgorithm, String provider) throws NoSuchAlgorithmException, NoSuchProviderException { - return SignUtils.getMessageDigest(hashAlgorithm, provider); + return CryptoUtil.getMessageDigest(hashAlgorithm, provider); } /** @@ -250,7 +252,9 @@ public static MessageDigest getMessageDigest(String hashAlgorithm, String provid * @param data the message of which you want to create a hash * @param hashAlgorithm the algorithm used to create the hash * @param provider the provider used to create the hash + * * @return the hash + * * @throws GeneralSecurityException when requested cryptographic algorithm or security provider * is not available * @throws IOException signals that an I/O exception has occurred @@ -262,11 +266,13 @@ public static byte[] digest(InputStream data, String hashAlgorithm, String provi } /** - * Create a digest based on the inputstream. + * Create a digest based on the input stream. * * @param data data to be digested * @param messageDigest algorithm to be used + * * @return digest of the data + * * @throws IOException signals that an I/O exception has occurred */ public static byte[] digest(InputStream data, MessageDigest messageDigest) @@ -279,29 +285,6 @@ public static byte[] digest(InputStream data, MessageDigest messageDigest) return messageDigest.digest(); } - /** - * Create a digest based on the inputstream. - * - * @param data data to be digested - * @param hashAlgorithm algorithm to be used - * @param externalDigest external digest to be used - * - * @return digest of the data. - * - * @throws IOException signals that an I/O exception has occurred. - * @throws GeneralSecurityException when something goes wrong in calculating the digest. - */ - public static byte[] digest(InputStream data, String hashAlgorithm, IExternalDigest externalDigest) - throws IOException, GeneralSecurityException { - byte[] buf = new byte[8192]; - int n; - MessageDigest messageDigest = SignUtils.getMessageDigest(hashAlgorithm, externalDigest); - while ((n = data.read(buf)) > 0) { - messageDigest.update(buf, 0, n); - } - return messageDigest.digest(); - } - /** * Gets the digest name for a certain id. * @@ -314,7 +297,7 @@ public static String getDigest(String oid) { if (ret == null) { try { String digest = getMessageDigest(oid, BOUNCY_CASTLE_FACTORY.getProviderName()).getAlgorithm(); - LOGGER.warn(SignLogMessageConstant.ALGORITHM_NOT_FROM_SPEC); + LOGGER.warn(KernelLogMessageConstant.ALGORITHM_NOT_FROM_SPEC); return digest; } catch (Exception e) { return oid; @@ -328,6 +311,7 @@ public static String getDigest(String oid) { * Normalize the digest name. * * @param algo the name to be normalized + * * @return normalized name */ public static String normalizeDigestName(String algo) { @@ -341,13 +325,14 @@ public static String normalizeDigestName(String algo) { * Returns the id of a digest algorithms that is allowed in PDF, * or null if it isn't allowed. * - * @param name The name of the digest algorithm. - * @return An oid. + * @param name the name of the digest algorithm + * + * @return an oid */ public static String getAllowedDigest(String name) { if (name == null) { throw new IllegalArgumentException( - SignExceptionMessageConstant.THE_NAME_OF_THE_DIGEST_ALGORITHM_IS_NULL); + KernelExceptionMessageConstant.THE_NAME_OF_THE_DIGEST_ALGORITHM_IS_NULL); } String allowedDigest = allowedDigests.get(name.toUpperCase()); if (allowedDigest != null) { @@ -355,7 +340,7 @@ public static String getAllowedDigest(String name) { } allowedDigest = BOUNCY_CASTLE_FACTORY.getDigestAlgorithmOid(name.toUpperCase()); if (allowedDigest != null) { - LOGGER.warn(SignLogMessageConstant.ALGORITHM_NOT_FROM_SPEC); + LOGGER.warn(KernelLogMessageConstant.ALGORITHM_NOT_FROM_SPEC); } return allowedDigest; } @@ -364,12 +349,13 @@ public static String getAllowedDigest(String name) { * Retrieve the output length in bits of the given digest algorithm. * * @param name the name of the digest algorithm + * * @return the length of the output of the algorithm in bits */ public static int getOutputBitLength(String name) { if (name == null) { throw new IllegalArgumentException( - SignExceptionMessageConstant.THE_NAME_OF_THE_DIGEST_ALGORITHM_IS_NULL); + KernelExceptionMessageConstant.THE_NAME_OF_THE_DIGEST_ALGORITHM_IS_NULL); } return bitLengths.get(name).intValue(); } diff --git a/sign/src/main/java/com/itextpdf/signatures/OID.java b/kernel/src/main/java/com/itextpdf/kernel/crypto/OID.java similarity index 71% rename from sign/src/main/java/com/itextpdf/signatures/OID.java rename to kernel/src/main/java/com/itextpdf/kernel/crypto/OID.java index 12f2550541..1cabbbff62 100644 --- a/sign/src/main/java/com/itextpdf/signatures/OID.java +++ b/kernel/src/main/java/com/itextpdf/kernel/crypto/OID.java @@ -20,7 +20,7 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.signatures; +package com.itextpdf.kernel.crypto; import java.util.Arrays; import java.util.Collections; @@ -31,6 +31,45 @@ This file is part of the iText (R) project. * Class containing all the OID values used by iText. */ public final class OID { + public static final String PKCS7_DATA = "1.2.840.113549.1.7.1"; + public static final String PKCS7_SIGNED_DATA = "1.2.840.113549.1.7.2"; + public static final String RSA = "1.2.840.113549.1.1.1"; + public static final String RSASSA_PSS = "1.2.840.113549.1.1.10"; + public static final String RSA_WITH_SHA256 = "1.2.840.113549.1.1.11"; + public static final String AA_SIGNING_CERTIFICATE_V1 = "1.2.840.113549.1.9.16.2.12"; + public static final String AA_SIGNING_CERTIFICATE_V2 = "1.2.840.113549.1.9.16.2.47"; + public static final String MGF1 = "1.2.840.113549.1.1.8"; + public static final String AA_TIME_STAMP_TOKEN = "1.2.840.113549.1.9.16.2.14"; + public static final String AUTHENTICATED_DATA = "1.2.840.113549.1.9.16.1.2"; + public static final String CONTENT_TYPE = "1.2.840.113549.1.9.3"; + public static final String MESSAGE_DIGEST = "1.2.840.113549.1.9.4"; + public static final String SIGNING_TIME = "1.2.840.113549.1.9.5"; + public static final String CMS_ALGORITHM_PROTECTION = "1.2.840.113549.1.9.52"; + public static final String DSA = "1.2.840.10040.4.1"; + public static final String ECDSA = "1.2.840.10045.2.1"; + public static final String ADBE_REVOCATION = "1.2.840.113583.1.1.8"; + public static final String TSA = "1.2.840.113583.1.1.9.1"; + + public static final String RSA_WITH_SHA3_512 = "2.16.840.1.101.3.4.3.16"; + public static final String SHA_224 = "2.16.840.1.101.3.4.2.4"; + public static final String SHA_256 = "2.16.840.1.101.3.4.2.1"; + public static final String SHA_384 = "2.16.840.1.101.3.4.2.2"; + public static final String SHA_512 = "2.16.840.1.101.3.4.2.3"; + public static final String SHA3_224 = "2.16.840.1.101.3.4.2.7"; + public static final String SHA3_256 = "2.16.840.1.101.3.4.2.8"; + public static final String SHA3_384 = "2.16.840.1.101.3.4.2.9"; + public static final String SHA3_512 = "2.16.840.1.101.3.4.2.10"; + public static final String SHAKE_256 = "2.16.840.1.101.3.4.2.12"; + + public static final String ED25519 = "1.3.101.112"; + public static final String ED448 = "1.3.101.113"; + public static final String OCSP = "1.3.6.1.5.5.7.48.1"; + public static final String CA_ISSUERS = "1.3.6.1.5.5.7.48.2"; + public static final String RI_OCSP_RESPONSE = "1.3.6.1.5.5.7.16.2"; + + public static final String KDF_PDF_MAC_WRAP_KDF = "1.0.32004.1.1"; + public static final String CT_PDF_MAC_INTEGRITY_INFO = "1.0.32004.1.0"; + private OID() { // Empty on purpose. Avoiding instantiation of this class. @@ -140,6 +179,10 @@ public static final class X509Extensions { */ public static final String VALIDITY_ASSURED_SHORT_TERM = "0.4.0.194121.2.1"; + /** + * Extension for certificates from RFC 9608 which indicates that no revocation information is available. + */ + public static final String NO_REV_AVAILABLE = "2.5.29.56"; /** * According to https://tools.ietf.org/html/rfc5280 4.2. "Certificate Extensions": diff --git a/kernel/src/main/java/com/itextpdf/kernel/crypto/OutputStreamAesGcmEncryption.java b/kernel/src/main/java/com/itextpdf/kernel/crypto/OutputStreamAesGcmEncryption.java new file mode 100644 index 0000000000..7057041f93 --- /dev/null +++ b/kernel/src/main/java/com/itextpdf/kernel/crypto/OutputStreamAesGcmEncryption.java @@ -0,0 +1,112 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.crypto; + +import com.itextpdf.kernel.exceptions.KernelExceptionMessageConstant; +import com.itextpdf.kernel.exceptions.PdfException; + +import java.io.IOException; +import java.security.SecureRandom; + +/** + * An output stream accepts output bytes and sends them to underlying {@link OutputStreamEncryption} instance. + */ +public class OutputStreamAesGcmEncryption extends OutputStreamEncryption { + private final AESGCMCipher cipher; + private boolean finished; + private static final SecureRandom rng = new SecureRandom(); + + /** + * Creates a new instance of {@link OutputStreamAesGcmEncryption}. + * + * @param out the {@link java.io.OutputStream} instance to be used as the destination for the encrypted content + * @param key the byte array containing the key for encryption + * @param noncePart a 7 byte nonce + */ + public OutputStreamAesGcmEncryption(java.io.OutputStream out, byte[] key, byte[] noncePart) { + super(out); + byte[] iv = new byte[12]; + byte[] randomPart = new byte[5]; + synchronized (rng) { + rng.nextBytes(randomPart); + } + System.arraycopy(randomPart, 0, iv, 0, 5); + System.arraycopy(noncePart, 0, iv, 5, 7); + cipher = new AESGCMCipher(true, key, iv); + try { + out.write(iv); + } catch (IOException e) { + throw new PdfException(KernelExceptionMessageConstant.PDF_ENCRYPTION, e); + } + } + + /** + * Writes {@code len} bytes from the specified byte array + * starting at offset {@code off} to this output stream. + * The general contract for {@code write(b, off, len)} is that + * some bytes in the array {@code b} are written to the + * output stream in order; element {@code b[off]} is the first + * byte written and {@code b[off+len-1]} is the last byte written + * by this operation. + *

+ * The {@code write} method of {@code OutputStream} calls + * the write method of one argument on each of the bytes to be + * written out. Subclasses are encouraged to override this method and + * provide a more efficient implementation. + *

+ * If {@code off} is negative, or {@code len} is negative, or + * {@code off+len} is greater than the length of the array + * {@code b}, then an IndexOutOfBoundsException is thrown. + * + * @param b the data + * @param off the start offset in the data + * @param len the number of bytes to write + * + * @throws IOException if an I/O error occurs. In particular, + * an {@code IOException} is thrown if the output + * stream is closed + */ + public void write(byte[] b, int off, int len) throws IOException { + byte[] cipherBuffer = cipher.update(b, off, len); + if (cipherBuffer.length != 0) { + out.write(cipherBuffer, 0, cipherBuffer.length); + } + } + + /** + * Finishes and dispose all resources used for writing in encrypted stream. + * Input data that may have been buffered during a previous update operation is processed, + * with padding (if requested) being applied and authentication tag is appended. + */ + public void finish() { + if (!finished) { + finished = true; + byte[] cipherBuffer = cipher.doFinal(); + try { + out.write(cipherBuffer, 0, cipherBuffer.length); + } catch (IOException e) { + throw new PdfException(KernelExceptionMessageConstant.PDF_ENCRYPTION, e); + } + } + } +} diff --git a/kernel/src/main/java/com/itextpdf/kernel/crypto/securityhandler/PubKeySecurityHandler.java b/kernel/src/main/java/com/itextpdf/kernel/crypto/securityhandler/PubKeySecurityHandler.java index fac179b849..c62d7d6594 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/crypto/securityhandler/PubKeySecurityHandler.java +++ b/kernel/src/main/java/com/itextpdf/kernel/crypto/securityhandler/PubKeySecurityHandler.java @@ -210,14 +210,11 @@ private byte[] getEncodedRecipient(int index) throws IOException, GeneralSecurit //constants permissions: PdfWriter.AllowCopy | PdfWriter.AllowPrinting | PdfWriter.AllowScreenReaders | // PdfWriter.AllowAssembly; int permission = recipient.getPermission(); - // NOTE! Added while porting to itext - // Previous strange code was: - // int revision = 3; - // permission |= revision == 3 ? 0xfffff0c0 : 0xffffffc0; - // revision value never changed, so code have been replaced to this: - permission |= 0xfffff0c0; - permission &= 0xfffffffc; - permission += 1; + // Force set 1 to 1, 7, 8 bits and all bits above 13. + // Basically to all not used bits. + // Bit 13 we do not touch. It's handled separately in PdfEncryption. + // Not sure about bit 1. But we always set it to 1 so let's not change for now. + permission |= 0xffffe0c1; byte[] pkcs7input = new byte[24]; diff --git a/kernel/src/main/java/com/itextpdf/kernel/crypto/securityhandler/PubSecHandlerUsingAes128.java b/kernel/src/main/java/com/itextpdf/kernel/crypto/securityhandler/PubSecHandlerUsingAes128.java index c3f6d79018..e2a098ad37 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/crypto/securityhandler/PubSecHandlerUsingAes128.java +++ b/kernel/src/main/java/com/itextpdf/kernel/crypto/securityhandler/PubSecHandlerUsingAes128.java @@ -91,7 +91,6 @@ protected void setPubSecSpecificHandlerDicEntries(PdfDictionary encryptionDictio encryptionDictionary.put(PdfName.Filter, PdfName.Adobe_PubSec); encryptionDictionary.put(PdfName.SubFilter, PdfName.Adbe_pkcs7_s5); - encryptionDictionary.put(PdfName.R, new PdfNumber(4)); encryptionDictionary.put(PdfName.V, new PdfNumber(4)); PdfArray recipients = createRecipientsArray(); diff --git a/kernel/src/main/java/com/itextpdf/kernel/crypto/securityhandler/PubSecHandlerUsingAes256.java b/kernel/src/main/java/com/itextpdf/kernel/crypto/securityhandler/PubSecHandlerUsingAes256.java index d8c080447e..ca0bd801b7 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/crypto/securityhandler/PubSecHandlerUsingAes256.java +++ b/kernel/src/main/java/com/itextpdf/kernel/crypto/securityhandler/PubSecHandlerUsingAes256.java @@ -33,12 +33,16 @@ This file is part of the iText (R) project. public class PubSecHandlerUsingAes256 extends PubSecHandlerUsingAes128 { - public PubSecHandlerUsingAes256(PdfDictionary encryptionDictionary, Certificate[] certs, int[] permissions, boolean encryptMetadata, boolean embeddedFilesOnly) { + public PubSecHandlerUsingAes256(PdfDictionary encryptionDictionary, Certificate[] certs, int[] permissions, + boolean encryptMetadata, boolean embeddedFilesOnly) { super(encryptionDictionary, certs, permissions, encryptMetadata, embeddedFilesOnly); } - public PubSecHandlerUsingAes256(PdfDictionary encryptionDictionary, Key certificateKey, Certificate certificate, String certificateKeyProvider, IExternalDecryptionProcess externalDecryptionProcess, boolean encryptMetadata) { - super(encryptionDictionary, certificateKey, certificate, certificateKeyProvider, externalDecryptionProcess, encryptMetadata); + public PubSecHandlerUsingAes256(PdfDictionary encryptionDictionary, Key certificateKey, Certificate certificate, + String certificateKeyProvider, IExternalDecryptionProcess externalDecryptionProcess, + boolean encryptMetadata) { + super(encryptionDictionary, certificateKey, certificate, certificateKeyProvider, externalDecryptionProcess, + encryptMetadata); } @Override @@ -57,12 +61,19 @@ protected void initKey(byte[] globalKey, int keyLength) { } @Override - protected void setPubSecSpecificHandlerDicEntries(PdfDictionary encryptionDictionary, boolean encryptMetadata, boolean embeddedFilesOnly) { + protected void setPubSecSpecificHandlerDicEntries(PdfDictionary encryptionDictionary, boolean encryptMetadata, + boolean embeddedFilesOnly) { + int version = 5; + PdfName filter = PdfName.AESV3; + setEncryptionDictEntries(encryptionDictionary, encryptMetadata, embeddedFilesOnly, version, filter); + } + + void setEncryptionDictEntries(PdfDictionary encryptionDictionary, boolean encryptMetadata, + boolean embeddedFilesOnly, int version, PdfName cryptFilter) { encryptionDictionary.put(PdfName.Filter, PdfName.Adobe_PubSec); encryptionDictionary.put(PdfName.SubFilter, PdfName.Adbe_pkcs7_s5); - encryptionDictionary.put(PdfName.R, new PdfNumber(5)); - encryptionDictionary.put(PdfName.V, new PdfNumber(5)); + encryptionDictionary.put(PdfName.V, new PdfNumber(version)); PdfArray recipients = createRecipientsArray(); PdfDictionary stdcf = new PdfDictionary(); @@ -70,7 +81,7 @@ protected void setPubSecSpecificHandlerDicEntries(PdfDictionary encryptionDictio if (!encryptMetadata) { stdcf.put(PdfName.EncryptMetadata, PdfBoolean.FALSE); } - stdcf.put(PdfName.CFM, PdfName.AESV3); + stdcf.put(PdfName.CFM, cryptFilter); stdcf.put(PdfName.Length, new PdfNumber(256)); PdfDictionary cf = new PdfDictionary(); cf.put(PdfName.DefaultCryptFilter, stdcf); diff --git a/kernel/src/main/java/com/itextpdf/kernel/crypto/securityhandler/PubSecHandlerUsingAesGcm.java b/kernel/src/main/java/com/itextpdf/kernel/crypto/securityhandler/PubSecHandlerUsingAesGcm.java new file mode 100644 index 0000000000..b2d3ab1c50 --- /dev/null +++ b/kernel/src/main/java/com/itextpdf/kernel/crypto/securityhandler/PubSecHandlerUsingAesGcm.java @@ -0,0 +1,116 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.crypto.securityhandler; + +import com.itextpdf.kernel.crypto.AesGcmDecryptor; +import com.itextpdf.kernel.crypto.IDecryptor; +import com.itextpdf.kernel.crypto.OutputStreamAesGcmEncryption; +import com.itextpdf.kernel.crypto.OutputStreamEncryption; +import com.itextpdf.kernel.pdf.PdfDictionary; +import com.itextpdf.kernel.pdf.PdfName; +import com.itextpdf.kernel.security.IExternalDecryptionProcess; + +import java.io.OutputStream; +import java.security.Key; +import java.security.cert.Certificate; + +/** + * Public-key security handler with Advanced Encryption Standard-Galois/Counter Mode (AES-GCM) encryption algorithm. + */ +public class PubSecHandlerUsingAesGcm extends PubSecHandlerUsingAes256 { + + protected byte[] noncePart = null; + protected int inObjectNonceCounter = 0; + + /** + * Creates new {@link PubSecHandlerUsingAesGcm} instance for encryption. + * + * @param encryptionDictionary document's encryption dictionary + * @param certs recipients' X.509 public key certificates + * @param permissions access permissions provided to each recipient + * @param encryptMetadata indicates whether the document-level metadata stream shall be encrypted + * @param embeddedFilesOnly indicates whether embedded files shall be encrypted in an otherwise unencrypted document + */ + public PubSecHandlerUsingAesGcm(PdfDictionary encryptionDictionary, Certificate[] certs, int[] permissions, + boolean encryptMetadata, boolean embeddedFilesOnly) { + super(encryptionDictionary, certs, permissions, encryptMetadata, embeddedFilesOnly); + } + + /** + * Creates new {@link PubSecHandlerUsingAesGcm} instance for decryption. + * + * @param encryptionDictionary document's encryption dictionary + * @param certificateKey the recipient private {@link Key} to the certificate + * @param certificate the recipient {@link Certificate}, serves as recipient identifier + * @param certificateKeyProvider the certificate key provider id + * for {@link java.security.Security#getProvider(String)} + * @param externalDecryptionProcess the external decryption process to be used + * @param encryptMetadata indicates whether the document-level metadata stream shall be encrypted + */ + public PubSecHandlerUsingAesGcm(PdfDictionary encryptionDictionary, Key certificateKey, Certificate certificate, + String certificateKeyProvider, IExternalDecryptionProcess externalDecryptionProcess, + boolean encryptMetadata) { + super(encryptionDictionary, certificateKey, certificate, certificateKeyProvider, externalDecryptionProcess, + encryptMetadata); + } + + @Override + public void setHashKeyForNextObject(int objNumber, int objGeneration) { + // Make sure the same IV is never used twice in the same file. We do this by turning the objId/objGen into a + // 5-byte nonce (with generation restricted to 1 byte instead of 2) plus an in-object 2-byte counter that + // increments each time a new string is encrypted within the same object. The remaining 5 bytes will be + // generated randomly using a strong PRNG. + // This is very different from the situation with AES-CBC, where randomness is paramount. + // GCM uses a variation of counter mode, so making sure the IV is unique is more important than randomness. + this.inObjectNonceCounter = 0; + this.noncePart = new byte[]{ + 0, 0, + (byte) (objGeneration), + (byte) (objNumber >>> 24), + (byte) (objNumber >>> 16), + (byte) (objNumber >>> 8), + (byte) (objNumber), + }; + } + + @Override + public OutputStreamEncryption getEncryptionStream(OutputStream os) { + int ctr = inObjectNonceCounter; + noncePart[0] = (byte) (ctr >>> 8); + noncePart[1] = (byte) ctr; + return new OutputStreamAesGcmEncryption(os, nextObjectKey, noncePart); + } + + @Override + public IDecryptor getDecryptor() { + return new AesGcmDecryptor(nextObjectKey, 0, nextObjectKeySize); + } + + @Override + protected void setPubSecSpecificHandlerDicEntries(PdfDictionary encryptionDictionary, boolean encryptMetadata, + boolean embeddedFilesOnly) { + int version = 6; + PdfName filter = PdfName.AESV4; + setEncryptionDictEntries(encryptionDictionary, encryptMetadata, embeddedFilesOnly, version, filter); + } +} diff --git a/kernel/src/main/java/com/itextpdf/kernel/crypto/securityhandler/PubSecHandlerUsingStandard128.java b/kernel/src/main/java/com/itextpdf/kernel/crypto/securityhandler/PubSecHandlerUsingStandard128.java index bdb3db12ff..a939a905e4 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/crypto/securityhandler/PubSecHandlerUsingStandard128.java +++ b/kernel/src/main/java/com/itextpdf/kernel/crypto/securityhandler/PubSecHandlerUsingStandard128.java @@ -49,12 +49,10 @@ protected void setPubSecSpecificHandlerDicEntries(PdfDictionary encryptionDictio encryptionDictionary.put(PdfName.Filter, PdfName.Adobe_PubSec); PdfArray recipients = createRecipientsArray(); if (encryptMetadata) { - encryptionDictionary.put(PdfName.R, new PdfNumber(3)); encryptionDictionary.put(PdfName.V, new PdfNumber(2)); encryptionDictionary.put(PdfName.SubFilter, PdfName.Adbe_pkcs7_s4); encryptionDictionary.put(PdfName.Recipients, recipients); } else { - encryptionDictionary.put(PdfName.R, new PdfNumber(4)); encryptionDictionary.put(PdfName.V, new PdfNumber(4)); encryptionDictionary.put(PdfName.SubFilter, PdfName.Adbe_pkcs7_s5); diff --git a/kernel/src/main/java/com/itextpdf/kernel/crypto/securityhandler/PubSecHandlerUsingStandard40.java b/kernel/src/main/java/com/itextpdf/kernel/crypto/securityhandler/PubSecHandlerUsingStandard40.java index bfa0f5de04..cffb61e95b 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/crypto/securityhandler/PubSecHandlerUsingStandard40.java +++ b/kernel/src/main/java/com/itextpdf/kernel/crypto/securityhandler/PubSecHandlerUsingStandard40.java @@ -69,7 +69,6 @@ protected void initKey(byte[] globalKey, int keyLength) { protected void setPubSecSpecificHandlerDicEntries(PdfDictionary encryptionDictionary, boolean encryptMetadata, boolean embeddedFilesOnly) { encryptionDictionary.put(PdfName.Filter, PdfName.Adobe_PubSec); - encryptionDictionary.put(PdfName.R, new PdfNumber(2)); PdfArray recipients = createRecipientsArray(); encryptionDictionary.put(PdfName.V, new PdfNumber(1)); diff --git a/kernel/src/main/java/com/itextpdf/kernel/crypto/securityhandler/SecurityHandler.java b/kernel/src/main/java/com/itextpdf/kernel/crypto/securityhandler/SecurityHandler.java index 6cd800694c..37864f951a 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/crypto/securityhandler/SecurityHandler.java +++ b/kernel/src/main/java/com/itextpdf/kernel/crypto/securityhandler/SecurityHandler.java @@ -31,6 +31,7 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.logs.KernelLogMessageConstant; import java.security.MessageDigest; +import java.util.Arrays; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -91,10 +92,40 @@ public void setHashKeyForNextObject(int objNumber, int objGeneration) { } } + /** + * Gets a stream wrapper, responsible for encryption. + * + * @param os {@link java.io.OutputStream} to be wrapped + * + * @return {@link OutputStreamEncryption}, responsible for encryption. + */ public abstract OutputStreamEncryption getEncryptionStream(java.io.OutputStream os); + /** + * Gets decryptor object. + * + * @return {@link IDecryptor} + */ public abstract IDecryptor getDecryptor(); + /** + * Gets encryption key for a particular object/generation. + * + * @return encryption key for a particular object/generation. + */ + public byte[] getNextObjectKey() { + return Arrays.copyOf(nextObjectKey, nextObjectKey.length); + } + + /** + * Gets global encryption key. + * + * @return global encryption key. + */ + public byte[] getMkey() { + return Arrays.copyOf(mkey, mkey.length); + } + private void safeInitMessageDigest() { try { md5 = MessageDigest.getInstance("MD5"); diff --git a/kernel/src/main/java/com/itextpdf/kernel/crypto/securityhandler/StandardHandlerUsingAes256.java b/kernel/src/main/java/com/itextpdf/kernel/crypto/securityhandler/StandardHandlerUsingAes256.java index f788e0789f..cfd6b6290c 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/crypto/securityhandler/StandardHandlerUsingAes256.java +++ b/kernel/src/main/java/com/itextpdf/kernel/crypto/securityhandler/StandardHandlerUsingAes256.java @@ -49,25 +49,30 @@ This file is part of the iText (R) project. public class StandardHandlerUsingAes256 extends StandardSecurityHandler { - private static final int VALIDATION_SALT_OFFSET = 32; private static final int KEY_SALT_OFFSET = 40; private static final int SALT_LENGTH = 8; - private boolean isPdf2; protected boolean encryptMetadata; - + private boolean isPdf2; public StandardHandlerUsingAes256(PdfDictionary encryptionDictionary, byte[] userPassword, byte[] ownerPassword, - int permissions, boolean encryptMetadata, boolean embeddedFilesOnly, PdfVersion version) { + int permissions, boolean encryptMetadata, boolean embeddedFilesOnly, + PdfVersion version) { isPdf2 = version != null && version.compareTo(PdfVersion.PDF_2_0) >= 0; - initKeyAndFillDictionary(encryptionDictionary, userPassword, ownerPassword, permissions, encryptMetadata, embeddedFilesOnly); + initKeyAndFillDictionary(encryptionDictionary, userPassword, ownerPassword, permissions, encryptMetadata, + embeddedFilesOnly); } public StandardHandlerUsingAes256(PdfDictionary encryptionDictionary, byte[] password) { initKeyAndReadDictionary(encryptionDictionary, password); } + /** + * Checks whether the document-level metadata stream will be encrypted. + * + * @return {@code true} if the document-level metadata stream shall be encrypted, {@code false} otherwise + */ public boolean isEncryptMetadata() { return encryptMetadata; } @@ -87,6 +92,61 @@ public IDecryptor getDecryptor() { return new AesDecryptor(nextObjectKey, 0, nextObjectKeySize); } + /** + * {@inheritDoc} + */ + @Override + public void setPermissions(int permissions, PdfDictionary encryptionDictionary) { + super.setPermissions(permissions, encryptionDictionary); + + byte[] aes256Perms = getAes256Perms(permissions, isEncryptMetadata()); + encryptionDictionary.put(PdfName.Perms, new PdfLiteral(StreamUtil.createEscapedString(aes256Perms))); + } + + void setAES256DicEntries(PdfDictionary encryptionDictionary, byte[] oeKey, byte[] ueKey, byte[] aes256Perms, + boolean encryptMetadata, boolean embeddedFilesOnly) { + int version = 5; + int rAes256 = 5; + int rAes256Pdf2 = 6; + int revision = isPdf2 ? rAes256Pdf2 : rAes256; + PdfName cryptoFilter = PdfName.AESV3; + setEncryptionDictionaryEntries(encryptionDictionary, oeKey, ueKey, aes256Perms, encryptMetadata, + embeddedFilesOnly, version, revision, cryptoFilter); + } + + void setEncryptionDictionaryEntries(PdfDictionary encryptionDictionary, byte[] oeKey, byte[] ueKey, + byte[] aes256Perms, boolean encryptMetadata, boolean embeddedFilesOnly, + int version, int revision, PdfName cryptoFilter) { + encryptionDictionary.put(PdfName.OE, new PdfLiteral(StreamUtil.createEscapedString(oeKey))); + encryptionDictionary.put(PdfName.UE, new PdfLiteral(StreamUtil.createEscapedString(ueKey))); + encryptionDictionary.put(PdfName.Perms, new PdfLiteral(StreamUtil.createEscapedString(aes256Perms))); + encryptionDictionary.put(PdfName.R, new PdfNumber(revision)); + encryptionDictionary.put(PdfName.V, new PdfNumber(version)); + PdfDictionary stdcf = new PdfDictionary(); + stdcf.put(PdfName.Length, new PdfNumber(32)); + if (!encryptMetadata) { + encryptionDictionary.put(PdfName.EncryptMetadata, PdfBoolean.FALSE); + } + if (embeddedFilesOnly) { + stdcf.put(PdfName.AuthEvent, PdfName.EFOpen); + encryptionDictionary.put(PdfName.EFF, PdfName.StdCF); + encryptionDictionary.put(PdfName.StrF, PdfName.Identity); + encryptionDictionary.put(PdfName.StmF, PdfName.Identity); + } else { + stdcf.put(PdfName.AuthEvent, PdfName.DocOpen); + encryptionDictionary.put(PdfName.StrF, PdfName.StdCF); + encryptionDictionary.put(PdfName.StmF, PdfName.StdCF); + } + stdcf.put(PdfName.CFM, cryptoFilter); + PdfDictionary cf = new PdfDictionary(); + cf.put(PdfName.StdCF, stdcf); + encryptionDictionary.put(PdfName.CF, cf); + } + + boolean isPdf2(PdfDictionary encryptionDictionary) { + return encryptionDictionary.getAsNumber(PdfName.R).getValue() == 6; + } + private void initKeyAndFillDictionary(PdfDictionary encryptionDictionary, byte[] userPassword, byte[] ownerPassword, int permissions, boolean encryptMetadata, boolean embeddedFilesOnly) { ownerPassword = generateOwnerPasswordIfNullOrEmpty(ownerPassword); @@ -142,21 +202,7 @@ private void initKeyAndFillDictionary(PdfDictionary encryptionDictionary, byte[] // Algorithm 10 - byte[] permsp = IVGenerator.getIV(16); - permsp[0] = (byte) permissions; - permsp[1] = (byte) (permissions >> 8); - permsp[2] = (byte) (permissions >> 16); - permsp[3] = (byte) (permissions >> 24); - permsp[4] = (byte) (255); - permsp[5] = (byte) (255); - permsp[6] = (byte) (255); - permsp[7] = (byte) (255); - permsp[8] = encryptMetadata ? (byte) 'T' : (byte) 'F'; - permsp[9] = (byte) 'a'; - permsp[10] = (byte) 'd'; - permsp[11] = (byte) 'b'; - ac = new AESCipherCBCnoPad(true, nextObjectKey); - aes256Perms = ac.processBlock(permsp, 0, permsp.length); + aes256Perms = getAes256Perms(permissions, encryptMetadata); this.permissions = permissions; this.encryptMetadata = encryptMetadata; @@ -167,35 +213,26 @@ private void initKeyAndFillDictionary(PdfDictionary encryptionDictionary, byte[] } } - private void setAES256DicEntries(PdfDictionary encryptionDictionary, byte[] oeKey, byte[] ueKey, byte[] aes256Perms, - boolean encryptMetadata, boolean embeddedFilesOnly) { - int vAes256 = 5; - int rAes256 = 5; - int rAes256Pdf2 = 6; - encryptionDictionary.put(PdfName.OE, new PdfLiteral(StreamUtil.createEscapedString(oeKey))); - encryptionDictionary.put(PdfName.UE, new PdfLiteral(StreamUtil.createEscapedString(ueKey))); - encryptionDictionary.put(PdfName.Perms, new PdfLiteral(StreamUtil.createEscapedString(aes256Perms))); - encryptionDictionary.put(PdfName.R, new PdfNumber(isPdf2 ? rAes256Pdf2 : rAes256)); - encryptionDictionary.put(PdfName.V, new PdfNumber(vAes256)); - PdfDictionary stdcf = new PdfDictionary(); - stdcf.put(PdfName.Length, new PdfNumber(32)); - if (!encryptMetadata) { - encryptionDictionary.put(PdfName.EncryptMetadata, PdfBoolean.FALSE); - } - if (embeddedFilesOnly) { - stdcf.put(PdfName.AuthEvent, PdfName.EFOpen); - encryptionDictionary.put(PdfName.EFF, PdfName.StdCF); - encryptionDictionary.put(PdfName.StrF, PdfName.Identity); - encryptionDictionary.put(PdfName.StmF, PdfName.Identity); - } else { - stdcf.put(PdfName.AuthEvent, PdfName.DocOpen); - encryptionDictionary.put(PdfName.StrF, PdfName.StdCF); - encryptionDictionary.put(PdfName.StmF, PdfName.StdCF); - } - stdcf.put(PdfName.CFM, PdfName.AESV3); - PdfDictionary cf = new PdfDictionary(); - cf.put(PdfName.StdCF, stdcf); - encryptionDictionary.put(PdfName.CF, cf); + private byte[] getAes256Perms(int permissions, boolean encryptMetadata) { + byte[] aes256Perms; + AESCipherCBCnoPad ac; + byte[] permsp = IVGenerator.getIV(16); + permsp[0] = (byte) permissions; + permsp[1] = (byte) (permissions >> 8); + permsp[2] = (byte) (permissions >> 16); + permsp[3] = (byte) (permissions >> 24); + permsp[4] = (byte) (255); + permsp[5] = (byte) (255); + permsp[6] = (byte) (255); + permsp[7] = (byte) (255); + permsp[8] = encryptMetadata ? (byte) 'T' : (byte) 'F'; + permsp[9] = (byte) 'a'; + permsp[10] = (byte) 'd'; + permsp[11] = (byte) 'b'; + ac = new AESCipherCBCnoPad(true, nextObjectKey); + aes256Perms = ac.processBlock(permsp, 0, permsp.length); + + return aes256Perms; } private void initKeyAndReadDictionary(PdfDictionary encryptionDictionary, byte[] password) { @@ -206,10 +243,10 @@ private void initKeyAndReadDictionary(PdfDictionary encryptionDictionary, byte[] password = Arrays.copyOf(password, 127); } - isPdf2 = encryptionDictionary.getAsNumber(PdfName.R).getValue() == 6; + isPdf2 = isPdf2(encryptionDictionary); - //truncate user and owner passwords to 48 bytes where the first 32 bytes - //are a hash value, next 8 bytes are validation salt and final 8 bytes are the key salt + // Truncate user and owner passwords to 48 bytes where the first 32 bytes + // are a hash value, next 8 bytes are validation salt and final 8 bytes are the key salt byte[] oValue = truncateArray(getIsoBytes(encryptionDictionary.getAsString(PdfName.O))); byte[] uValue = truncateArray(getIsoBytes(encryptionDictionary.getAsString(PdfName.U))); byte[] oeValue = getIsoBytes(encryptionDictionary.getAsString(PdfName.OE)); @@ -217,12 +254,12 @@ private void initKeyAndReadDictionary(PdfDictionary encryptionDictionary, byte[] byte[] perms = getIsoBytes(encryptionDictionary.getAsString(PdfName.Perms)); PdfNumber pValue = (PdfNumber) encryptionDictionary.get(PdfName.P); - this.permissions = pValue.longValue(); + this.permissions = pValue.intValue(); byte[] hash; hash = computeHash(password, oValue, VALIDATION_SALT_OFFSET, SALT_LENGTH, uValue); - usedOwnerPassword = compareArray(hash, oValue, 32); + usedOwnerPassword = equalsArray(hash, oValue, 32); if (usedOwnerPassword) { hash = computeHash(password, oValue, KEY_SALT_OFFSET, SALT_LENGTH, uValue); @@ -230,7 +267,7 @@ private void initKeyAndReadDictionary(PdfDictionary encryptionDictionary, byte[] nextObjectKey = ac.processBlock(oeValue, 0, oeValue.length); } else { hash = computeHash(password, uValue, VALIDATION_SALT_OFFSET, SALT_LENGTH); - if (!compareArray(hash, uValue, 32)) { + if (!equalsArray(hash, uValue, 32)) { throw new BadPasswordException(KernelExceptionMessageConstant.BAD_USER_PASSWORD); } hash = computeHash(password, uValue, KEY_SALT_OFFSET, SALT_LENGTH); @@ -241,14 +278,16 @@ private void initKeyAndReadDictionary(PdfDictionary encryptionDictionary, byte[] AESCipherCBCnoPad ac = new AESCipherCBCnoPad(false, nextObjectKey); byte[] decPerms = ac.processBlock(perms, 0, perms.length); - if (decPerms[9] != (byte) 'a' || decPerms[10] != (byte) 'd' || decPerms[11] != (byte) 'b') + if (decPerms[9] != (byte) 'a' || decPerms[10] != (byte) 'd' || decPerms[11] != (byte) 'b') { throw new BadPasswordException(KernelExceptionMessageConstant.BAD_USER_PASSWORD); + } int permissionsDecoded = (decPerms[0] & 0xff) | ((decPerms[1] & 0xff) << 8) | ((decPerms[2] & 0xff) << 16) | ((decPerms[3] & 0xff) << 24); boolean encryptMetadata = decPerms[8] == (byte) 'T'; Boolean encryptMetadataEntry = encryptionDictionary.getAsBool(PdfName.EncryptMetadata); - if (permissionsDecoded != permissions || encryptMetadataEntry != null && encryptMetadata != encryptMetadataEntry) { + if (permissionsDecoded != permissions || encryptMetadataEntry != null && + encryptMetadata != encryptMetadataEntry) { Logger logger = LoggerFactory.getLogger(StandardHandlerUsingAes256.class); logger.error(IoLogMessageConstant.ENCRYPTION_ENTRIES_P_AND_ENCRYPT_METADATA_NOT_CORRESPOND_PERMS_ENTRY); } @@ -261,11 +300,13 @@ private void initKeyAndReadDictionary(PdfDictionary encryptionDictionary, byte[] } } - private byte[] computeHash(byte[] password, byte[] salt, int saltOffset, int saltLen) throws NoSuchAlgorithmException { + private byte[] computeHash(byte[] password, byte[] salt, int saltOffset, int saltLen) + throws NoSuchAlgorithmException { return computeHash(password, salt, saltOffset, saltLen, null); } - private byte[] computeHash(byte[] password, byte[] salt, int saltOffset, int saltLen, byte[] userKey) throws NoSuchAlgorithmException { + private byte[] computeHash(byte[] password, byte[] salt, int saltOffset, int saltLen, byte[] userKey) + throws NoSuchAlgorithmException { MessageDigest mdSha256 = MessageDigest.getInstance("SHA-256"); mdSha256.update(password); @@ -301,7 +342,8 @@ private byte[] computeHash(byte[] password, byte[] salt, int saltOffset, int sal } // b) - AESCipherCBCnoPad cipher = new AESCipherCBCnoPad(true, Arrays.copyOf(k, 16), Arrays.copyOfRange(k, 16, 32)); + AESCipherCBCnoPad cipher = + new AESCipherCBCnoPad(true, Arrays.copyOf(k, 16), Arrays.copyOfRange(k, 16, 32)); byte[] e = cipher.processBlock(k1, 0, k1.length); // c) @@ -321,6 +363,7 @@ private byte[] computeHash(byte[] password, byte[] salt, int saltOffset, int sal } // d) + assert md != null; k = md.digest(e); ++roundNum; @@ -340,15 +383,6 @@ private byte[] computeHash(byte[] password, byte[] salt, int saltOffset, int sal return k; } - private static boolean compareArray(byte[] a, byte[] b, int len) { - for (int k = 0; k < len; ++k) { - if (a[k] != b[k]) { - return false; - } - } - return true; - } - private byte[] truncateArray(byte[] array) { if (array.length == 48) { return array; diff --git a/kernel/src/main/java/com/itextpdf/kernel/crypto/securityhandler/StandardHandlerUsingAesGcm.java b/kernel/src/main/java/com/itextpdf/kernel/crypto/securityhandler/StandardHandlerUsingAesGcm.java new file mode 100644 index 0000000000..a3f5e34a5e --- /dev/null +++ b/kernel/src/main/java/com/itextpdf/kernel/crypto/securityhandler/StandardHandlerUsingAesGcm.java @@ -0,0 +1,114 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.crypto.securityhandler; + +import com.itextpdf.kernel.crypto.AesGcmDecryptor; +import com.itextpdf.kernel.crypto.IDecryptor; +import com.itextpdf.kernel.crypto.OutputStreamAesGcmEncryption; +import com.itextpdf.kernel.crypto.OutputStreamEncryption; +import com.itextpdf.kernel.pdf.PdfDictionary; +import com.itextpdf.kernel.pdf.PdfName; +import com.itextpdf.kernel.pdf.PdfVersion; + +import java.io.OutputStream; + +/** + * Standard security handler with Advanced Encryption Standard-Galois/Counter Mode (AES-GCM) encryption algorithm. + */ +public class StandardHandlerUsingAesGcm extends StandardHandlerUsingAes256 { + + protected byte[] noncePart = null; + protected int inObjectNonceCounter = 0; + + /** + * Creates new {@link StandardHandlerUsingAesGcm} instance for encryption. + * + * @param encryptionDictionary document's encryption dictionary + * @param userPassword user password + * @param ownerPassword owner password + * @param permissions access permissions + * @param encryptMetadata indicates whether the document-level metadata stream shall be encrypted + * @param embeddedFilesOnly indicates whether embedded files shall be encrypted in an otherwise unencrypted document + */ + public StandardHandlerUsingAesGcm(PdfDictionary encryptionDictionary, byte[] userPassword, byte[] ownerPassword, + int permissions, boolean encryptMetadata, boolean embeddedFilesOnly) { + super(encryptionDictionary, userPassword, ownerPassword, permissions, encryptMetadata, embeddedFilesOnly, PdfVersion.PDF_2_0); + } + + /** + * Creates new {@link StandardHandlerUsingAesGcm} instance for decryption. + * + * @param encryptionDictionary document's encryption dictionary + * @param password owner or user password to decrypt the document + */ + public StandardHandlerUsingAesGcm(PdfDictionary encryptionDictionary, byte[] password) { + super(encryptionDictionary, password); + } + + @Override + public void setHashKeyForNextObject(int objNumber, int objGeneration) { + // Make sure the same IV is never used twice in the same file. We do this by turning the objId/objGen into a + // 5-byte nonce (with generation restricted to 1 byte instead of 2) plus an in-object 2-byte counter that + // increments each time a new string is encrypted within the same object. The remaining 5 bytes will be + // generated randomly using a strong PRNG. + // This is very different from the situation with AES-CBC, where randomness is paramount. GCM uses a variation + // of counter mode, so making sure the IV is unique is more important than randomness. + this.inObjectNonceCounter = 0; + this.noncePart = new byte[]{ + 0, 0, + (byte) (objGeneration), + (byte) (objNumber >>> 24), + (byte) (objNumber >>> 16), + (byte) (objNumber >>> 8), + (byte) (objNumber), + }; + } + + @Override + public OutputStreamEncryption getEncryptionStream(OutputStream os) { + int ctr = inObjectNonceCounter; + noncePart[0] = (byte) (ctr >>> 8); + noncePart[1] = (byte) ctr; + return new OutputStreamAesGcmEncryption(os, nextObjectKey, noncePart); + } + + @Override + public IDecryptor getDecryptor() { + return new AesGcmDecryptor(nextObjectKey, 0, nextObjectKeySize); + } + + @Override + void setAES256DicEntries(PdfDictionary encryptionDictionary, byte[] oeKey, byte[] ueKey, byte[] aes256Perms, + boolean encryptMetadata, boolean embeddedFilesOnly) { + int version = 6; + int revision = 7; + PdfName cryptoFilter = PdfName.AESV4; + setEncryptionDictionaryEntries(encryptionDictionary, oeKey, ueKey, aes256Perms, encryptMetadata, embeddedFilesOnly, + version, revision, cryptoFilter); + } + + @Override + boolean isPdf2(PdfDictionary encryptionDictionary) { + return true; + } +} diff --git a/kernel/src/main/java/com/itextpdf/kernel/crypto/securityhandler/StandardHandlerUsingStandard40.java b/kernel/src/main/java/com/itextpdf/kernel/crypto/securityhandler/StandardHandlerUsingStandard40.java index ab01bce970..117cad9e29 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/crypto/securityhandler/StandardHandlerUsingStandard40.java +++ b/kernel/src/main/java/com/itextpdf/kernel/crypto/securityhandler/StandardHandlerUsingStandard40.java @@ -171,7 +171,7 @@ private void initKeyAndReadDictionary(PdfDictionary encryptionDictionary, byte[] byte[] oValue = getIsoBytes(encryptionDictionary.getAsString(PdfName.O)); PdfNumber pValue = (PdfNumber) encryptionDictionary.get(PdfName.P); - this.permissions = pValue.longValue(); + this.permissions = pValue.intValue(); this.documentId = documentId; keyLength = getKeyLength(encryptionDictionary); diff --git a/kernel/src/main/java/com/itextpdf/kernel/crypto/securityhandler/StandardSecurityHandler.java b/kernel/src/main/java/com/itextpdf/kernel/crypto/securityhandler/StandardSecurityHandler.java index c38618f2f9..3b39067d13 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/crypto/securityhandler/StandardSecurityHandler.java +++ b/kernel/src/main/java/com/itextpdf/kernel/crypto/securityhandler/StandardSecurityHandler.java @@ -34,16 +34,27 @@ This file is part of the iText (R) project. public abstract class StandardSecurityHandler extends SecurityHandler { protected static final int PERMS_MASK_1_FOR_REVISION_2 = 0xffffffc0; - protected static final int PERMS_MASK_1_FOR_REVISION_3_OR_GREATER = 0xfffff0c0; + protected static final int PERMS_MASK_1_FOR_REVISION_3_OR_GREATER = 0xffffe0c0; protected static final int PERMS_MASK_2 = 0xfffffffc; - protected long permissions; + protected int permissions; protected boolean usedOwnerPassword = true; - public long getPermissions() { + public int getPermissions() { return permissions; } + /** + * Updates encryption dictionary with the security permissions provided. + * + * @param permissions new permissions to set + * @param encryptionDictionary encryption dictionary to update + */ + public void setPermissions(int permissions, PdfDictionary encryptionDictionary) { + this.permissions = permissions; + encryptionDictionary.put(PdfName.P, new PdfNumber(permissions)); + } + public boolean isUsedOwnerPassword() { return usedOwnerPassword; } diff --git a/kernel/src/main/java/com/itextpdf/kernel/di/pagetree/DefaultPageTreeListFactory.java b/kernel/src/main/java/com/itextpdf/kernel/di/pagetree/DefaultPageTreeListFactory.java new file mode 100644 index 0000000000..7d20fe4d20 --- /dev/null +++ b/kernel/src/main/java/com/itextpdf/kernel/di/pagetree/DefaultPageTreeListFactory.java @@ -0,0 +1,86 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.di.pagetree; + +import com.itextpdf.commons.datastructures.ISimpleList; +import com.itextpdf.commons.datastructures.NullUnlimitedList; +import com.itextpdf.commons.datastructures.SimpleArrayList; +import com.itextpdf.kernel.pdf.PdfDictionary; +import com.itextpdf.kernel.pdf.PdfName; +import com.itextpdf.kernel.pdf.PdfNumber; + +/** + * This class is a default implementation of {@link IPageTreeListFactory} that is used as a default. + *

+ * This class will create an arraylist when in creation mode. + * In reading and editing mode, it will create a NullUnlimitedList if the count is greater than the + * maxEntriesBeforeSwitchingToNullUnlimitedList. This is to prevent potential OOM exceptions when loading a document + * with a large number of pages where only a few pages are needed. + */ +public class DefaultPageTreeListFactory implements IPageTreeListFactory { + + private final int maxEntriesBeforeSwitchingToNullUnlimitedList; + + /** + * Creates a new instance of DefaultPageTreeListFactory. + * + * @param maxEntriesBeforeSwitchingToNullUnlimitedList the maximum number of entries before switching to + * a NullUnlimitedList. + */ + public DefaultPageTreeListFactory(int maxEntriesBeforeSwitchingToNullUnlimitedList) { + this.maxEntriesBeforeSwitchingToNullUnlimitedList = maxEntriesBeforeSwitchingToNullUnlimitedList; + } + + /** + * Creates a list based on the count value in the pages dictionary. If the count value is greater than the + * maxEntriesBeforeSwitchingToNullUnlimitedList, a NullUnlimitedList is created. This is to optimize memory usage + * when loading a document with a large number of pages where only a few pages are needed. + * + * @param pagesDictionary The pages dictionary + * @param The type of the list + * @return The list + */ + @Override + public ISimpleList createList(PdfDictionary pagesDictionary) { + //If dictionary is null, it means we are dealing with document creation. + if (pagesDictionary == null) { + return new SimpleArrayList<>(); + } + PdfNumber count = pagesDictionary.getAsNumber(PdfName.Count); + if (count == null) { + //If count is null, it means we are dealing with a possible corrupted document. + //In this case we use NullUnlimitedList to avoid creating a huge list. + return new NullUnlimitedList<>(); + } + int countValue = count.intValue(); + if (countValue > maxEntriesBeforeSwitchingToNullUnlimitedList) { + return new NullUnlimitedList<>(); + } + if (countValue < 0) { + //If count is negative, it means we are dealing with a possible corrupted document. + return new NullUnlimitedList<>(); + } + //Initial capacity is set to count value to avoid resizing of the list. + return new SimpleArrayList<>(countValue); + } +} diff --git a/kernel/src/main/java/com/itextpdf/kernel/di/pagetree/IPageTreeListFactory.java b/kernel/src/main/java/com/itextpdf/kernel/di/pagetree/IPageTreeListFactory.java new file mode 100644 index 0000000000..4c7812ad36 --- /dev/null +++ b/kernel/src/main/java/com/itextpdf/kernel/di/pagetree/IPageTreeListFactory.java @@ -0,0 +1,45 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.di.pagetree; + + +import com.itextpdf.commons.datastructures.ISimpleList; +import com.itextpdf.kernel.pdf.PdfDictionary; + +/** + * This interface is used to create a list of pages from a pages dictionary. + */ +public interface IPageTreeListFactory { + + /** + * Creates a list based on the value of the pages dictionary. + * If null, it means we are dealing with document creation. In other cases the pdf document pages + * dictionary will be passed. + * + * @param pagesDictionary The pages dictionary + * @param The type of the list + * @return The list + */ + ISimpleList createList(PdfDictionary pagesDictionary); +} + diff --git a/kernel/src/main/java/com/itextpdf/kernel/events/EventDispatcher.java b/kernel/src/main/java/com/itextpdf/kernel/events/EventDispatcher.java deleted file mode 100644 index 36e7e1d62b..0000000000 --- a/kernel/src/main/java/com/itextpdf/kernel/events/EventDispatcher.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - This file is part of the iText (R) project. - Copyright (c) 1998-2024 Apryse Group NV - Authors: Apryse Software. - - This program is offered under a commercial and under the AGPL license. - For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. - - AGPL licensing: - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . - */ -package com.itextpdf.kernel.events; - -import java.util.ArrayList; -import java.util.List; -import java.util.HashMap; -import java.util.Map; - -/** - * IEventDispatcher implementation that forwards Events to registered {@link com.itextpdf.kernel.events.IEventHandler} - * implementations. - */ -public class EventDispatcher implements IEventDispatcher { - - - protected Map> eventHandlers = new HashMap<>(); - - @Override - public void addEventHandler(String type, IEventHandler handler) { - removeEventHandler(type, handler); - List handlers = eventHandlers.get(type); - if (handlers == null) { - handlers = new ArrayList<>(); - eventHandlers.put(type, handlers); - } - handlers.add(handler); - } - - @Override - public void dispatchEvent(Event event) { - dispatchEvent(event, false); - } - - @Override - public void dispatchEvent(Event event, boolean delayed) { - List handlers = eventHandlers.get(event.getType()); - if (handlers != null) { - for (IEventHandler handler : handlers) { - handler.handleEvent(event); - } - } - } - - @Override - public boolean hasEventHandler(String type) { - return eventHandlers.containsKey(type); - } - - @Override - public void removeEventHandler(String type, IEventHandler handler) { - List handlers = eventHandlers.get(type); - if (handlers == null) - return; - handlers.remove(handler); - if (handlers.size() == 0) - eventHandlers.remove(type); - } - - @Override - public void removeAllHandlers() { - eventHandlers.clear(); - } -} diff --git a/kernel/src/main/java/com/itextpdf/kernel/events/IEventDispatcher.java b/kernel/src/main/java/com/itextpdf/kernel/events/IEventDispatcher.java deleted file mode 100644 index ea73643636..0000000000 --- a/kernel/src/main/java/com/itextpdf/kernel/events/IEventDispatcher.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - This file is part of the iText (R) project. - Copyright (c) 1998-2024 Apryse Group NV - Authors: Apryse Software. - - This program is offered under a commercial and under the AGPL license. - For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. - - AGPL licensing: - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . - */ -package com.itextpdf.kernel.events; - -/** - * Event dispatcher interface. - */ -public interface IEventDispatcher { - - /** - * Adds new event handler. - * - * @param type a type of event to be handled - * @param handler event handler - */ - void addEventHandler(String type, IEventHandler handler); - - /** - * Dispatches an event. - * - * @param event the {@link Event} to be dispatched - */ - void dispatchEvent(Event event); - - /** - * Dispatches a delayed event. - * Sometimes event cannot be handled immediately because event handler has not been set yet. - * In this case event is placed into event ques of dispatcher and is waiting until handler is assigned. - * - * @param event the {@link Event} to be dispatched - * @param delayed flag whether {@link Event} delayed or not - */ - void dispatchEvent(Event event, boolean delayed); - - /** - * Checks if event dispatcher as an event handler assigned for a certain event type. - * - * @param type a type of the {@link Event} - * @return true if event dispatcher as an event handler assigned for a certain event type - */ - boolean hasEventHandler(String type); - - /** - * Removes event handler. - * - * @param type a type of the {@link Event} - * @param handler event handler {@link IEventHandler} - */ - void removeEventHandler(String type, IEventHandler handler); - - /** - * Remove all event handlers. - */ - void removeAllHandlers(); -} diff --git a/kernel/src/main/java/com/itextpdf/kernel/exceptions/KernelExceptionMessageConstant.java b/kernel/src/main/java/com/itextpdf/kernel/exceptions/KernelExceptionMessageConstant.java index ef3f017ced..4d3bfae27a 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/exceptions/KernelExceptionMessageConstant.java +++ b/kernel/src/main/java/com/itextpdf/kernel/exceptions/KernelExceptionMessageConstant.java @@ -79,6 +79,8 @@ public final class KernelExceptionMessageConstant { public static final String CANNOT_RETRIEVE_MEDIA_BOX_ATTRIBUTE = "Invalid PDF. There is no media box attribute " + "for page or its parents."; public static final String CANNOT_FIND_IMAGE_DATA_OR_EI = "Cannot find image data or EI."; + public static final String UNSUPPORTED_ENCODING_FOR_INLINE_IMAGE + = "Cannot parse inline image: {0} encoding is unsupported."; public static final String CANNOT_FLUSH_DOCUMENT_ROOT_TAG_BEFORE_DOCUMENT_IS_CLOSED = "Cannot flush document root " + "tag before document is closed."; public static final String CANNOT_FLUSH_OBJECT = "Cannot flush object."; @@ -124,6 +126,10 @@ public final class KernelExceptionMessageConstant { + "method."; public static final String CF_NOT_FOUND_ENCRYPTION = "/CF not found (encryption)"; public static final String COLOR_SPACE_NOT_FOUND = "ColorSpace not found."; + public static final String CONTAINER_EMBEDDING_EXCEPTION = + "IOException occurred while trying to embed MAC container into document output stream."; + public static final String CONTAINER_GENERATION_EXCEPTION = "Exception occurred during MAC container generation."; + public static final String CONTAINER_PARSING_EXCEPTION = "Exception occurred during MAC container parsing."; public static final String CONTENT_STREAM_MUST_NOT_INVOKE_OPERATORS_THAT_SPECIFY_COLORS_OR_OTHER_COLOR_RELATED_PARAMETERS = "Content stream must not invoke operators that specify colors or other color related parameters in " + "the graphics state."; @@ -140,6 +146,8 @@ public final class KernelExceptionMessageConstant { public static final String DEFAULT_CRYPT_FILTER_NOT_FOUND_ENCRYPTION = "/DefaultCryptFilter not found " + "(encryption)."; public static final String THIS_DICTIONARY_KEY_IS_NOT_A_NAME = "Dictionary key {0} is not a name."; + public static final String DIGEST_NOT_SUPPORTED = + "This digest algorithm is not supported for MAC integrity protection."; public static final String DICTIONARY_DOES_NOT_HAVE_SUPPORTED_FONT_DATA = "Dictionary doesn't have supported font " + "data."; public static final String DOCUMENT_CLOSED_IT_IS_IMPOSSIBLE_TO_EXECUTE_ACTION = "Document was closed. It is " @@ -208,7 +216,7 @@ public final class KernelExceptionMessageConstant { public static final String INCORRECT_NUMBER_OF_COMPONENTS = "Incorrect number of components."; public static final String INVALID_CROSS_REFERENCE_ENTRY_IN_THIS_XREF_SUBSECTION = "Invalid cross reference entry " + "in this xref subsection."; - public static final String INVALID_INDIRECT_REFERENCE = "Invalid indirect reference {0}."; + public static final String INVALID_INDIRECT_REFERENCE = "Invalid indirect reference {0} {1} R."; public static final String INVALID_INPUT_FOR_TYPE_2_FUNCTION = "Invalid input value for PDF Type 2 Function, value should be a single number."; @@ -259,6 +267,23 @@ public final class KernelExceptionMessageConstant { public static final String IO_EXCEPTION_WHILE_CREATING_FONT = "I/O exception while creating Font"; public static final String LZW_DECODER_EXCEPTION = "LZW decoder exception."; public static final String LZW_FLAVOUR_NOT_SUPPORTED = "LZW flavour not supported."; + public static final String MAC_ALGORITHM_NOT_SUPPORTED = "This MAC algorithm is not supported."; + public static final String MAC_ATTRIBUTE_NOT_SPECIFIED = + "Signature doesn't contain unsigned MAC attribute, which is required in \"attached to signature\" mode."; + public static final String MAC_EXTRACTION_EXCEPTION = + "Exception occurred during signature parsing. It is not possible to extract MAC."; + public static final String MAC_LOCATION_NOT_SPECIFIED = "AuthCode dictionary doesn't contain MACLocation entry."; + public static final String MAC_NOT_SPECIFIED = + "AuthCode dictionary doesn't contain MAC entry, which is required in standalone mode."; + public static final String MAC_FOR_ENCRYPTION_5 = + "MAC integrity protection is only supported for encryption algorithms of version 5 or higher."; + public static final String MAC_FOR_PDF_2 = "MAC integrity protection is only supported for PDF 2.0 or higher."; + public static final String MAC_PERMS_WITHOUT_MAC = "Permissions bit 13 is set to zero, " + + "which indicates that MAC integrity protection is enabled. However MAC container wasn't found."; + public static final String MAC_VALIDATION_EXCEPTION = "Unexpected exception occurred during MAC token validation."; + public static final String MAC_VALIDATION_FAILED = + "MAC integrity protection was compromised. Document content was modified."; + public static final String MAC_VALIDATION_NO_SALT = "MAC token validation failed. Salt is not found."; public static final String MISSING_REQUIRED_FIELD_IN_FONT_DICTIONARY = "Missing required field {0} in font dictionary."; public static final String MUST_BE_A_TAGGED_DOCUMENT = "Must be a tagged document."; @@ -321,6 +346,8 @@ public final class KernelExceptionMessageConstant { public static final String RESOURCES_DO_NOT_CONTAIN_EXTGSTATE_ENTRY_UNABLE_TO_PROCESS_THIS_OPERATOR = "Resources " + "do not contain ExtGState entry. Unable to process operator {0}."; public static final String SHADING_TYPE_NOT_FOUND = "Shading type not found."; + public static final String SIG_OBJ_REF_NOT_SPECIFIED = + "AuthCode dictionary doesn't contain SigObjRef entry, which is required in signature mode."; public static final String STDCF_NOT_FOUND_ENCRYPTION = "/StdCF not found (encryption)"; public static final String STREAM_SHALL_END_WITH_ENDSTREAM = "Stream shall end with endstream keyword."; public static final String STRUCT_PARENT_INDEX_NOT_FOUND_IN_TAGGED_OBJECT = "StructParent index not found in " @@ -345,6 +372,7 @@ public final class KernelExceptionMessageConstant { + "TagTreePointer is in invalid state: it points at removed element use TagTreePointer#moveToRoot."; public static final String THERE_IS_NO_ASSOCIATE_PDF_WRITER_FOR_MAKING_INDIRECTS = "There is no associate " + "PdfWriter for making indirects."; + public static final String THE_NAME_OF_THE_DIGEST_ALGORITHM_IS_NULL = "The name of the digest algorithm is null."; public static final String THIS_DECODE_PARAMETER_TYPE_IS_NOT_SUPPORTED = "Decode parameter type {0} is not " + "supported."; public static final String THIS_FILTER_IS_NOT_SUPPORTED = "Filter {0} is not supported."; @@ -359,8 +387,6 @@ public final class KernelExceptionMessageConstant { + "operators."; public static final String UNBALANCED_LAYER_OPERATORS = "Unbalanced layer operators."; public static final String UNBALANCED_SAVE_RESTORE_STATE_OPERATORS = "Unbalanced save restore state operators."; - public static final String UNEXPECTED_CHARACTER_FOUND_AFTER_ID_IN_INLINE_IMAGE = "Unexpected character {0} " - + "found after ID in inline image."; public static final String UNEXPECTED_COLOR_SPACE = "Unexpected ColorSpace: {0}."; public static final String UNEXPECTED_END_OF_FILE = "Unexpected end of file."; public static final String UNEXPECTED_TOKEN = "unexpected {0} was encountered."; @@ -377,6 +403,7 @@ public final class KernelExceptionMessageConstant { "When adding object reference to the tag tree, it must be connected to not flushed object."; public static final String WHITE_POINT_IS_INCORRECTLY_SPECIFIED = "White point is incorrectly specified."; public static final String WMF_IMAGE_EXCEPTION = "WMF image exception."; + public static final String WRAP_ALGORITHM_NOT_SUPPORTED = "This wrapping algorithm is not supported."; public static final String WRONG_MEDIA_BOX_SIZE_TOO_FEW_ARGUMENTS = "Wrong media box size: {0}. Need at least 4 " + "arguments"; public static final String XREF_PREV_SHALL_BE_DIRECT_NUMBER_OBJECT = "Prev pointer in xref structure shall be " @@ -446,6 +473,17 @@ public final class KernelExceptionMessageConstant { public static final String INVALID_OBJECT_STREAM_NUMBER = "Unable to read object {0} with object stream " + "number {1} and index {2} from object stream."; + //TODO DEVSIX-8490 remove this exception message when implemented + public static final String UNABLE_TO_ADD_SECOND_PARENT_LAYER = "Unable to add second parent layer to " + + "{0} ocg layer"; + + //TODO DEVSIX-8490 remove this exception message when implemented + public static final String UNABLE_TO_REMOVE_DUPLICATE_LAYER = "Unable to remove duplicated layer {0} " + + "because it has child layers."; + + public static final String TYPE_SHOULD_NOT_BE_NULL = "ClassArgument type should not be null"; + public static final String INSTANCE_SHOULD_NOT_BE_NULL = "Instance should not be null"; + private KernelExceptionMessageConstant() { } } diff --git a/kernel/src/main/java/com/itextpdf/kernel/font/FontUtil.java b/kernel/src/main/java/com/itextpdf/kernel/font/FontUtil.java index cc2aea909d..3316fd11e9 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/font/FontUtil.java +++ b/kernel/src/main/java/com/itextpdf/kernel/font/FontUtil.java @@ -76,7 +76,7 @@ static CMapToUnicode processToUnicode(PdfObject toUnicode) { CMapParser.parseCid("", cMapToUnicode, lb); } catch (Exception e) { LOGGER.error(IoLogMessageConstant.UNKNOWN_ERROR_WHILE_PROCESSING_CMAP, e); - cMapToUnicode = CMapToUnicode.EmptyCMapToUnicodeMap; + cMapToUnicode = CMapToUnicode.EMPTY_CMAP; } } else if (PdfName.IdentityH.equals(toUnicode)) { cMapToUnicode = CMapToUnicode.getIdentity(); diff --git a/kernel/src/main/java/com/itextpdf/kernel/font/PdfSimpleFont.java b/kernel/src/main/java/com/itextpdf/kernel/font/PdfSimpleFont.java index 2ac49fcfac..53c4fe23b4 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/font/PdfSimpleFont.java +++ b/kernel/src/main/java/com/itextpdf/kernel/font/PdfSimpleFont.java @@ -318,7 +318,7 @@ public boolean appendDecodedCodesToGlyphsList(List list, PdfString charac public float getContentWidth(PdfString content) { float width = 0; GlyphLine glyphLine = decodeIntoGlyphLine(content); - for (int i = glyphLine.start; i < glyphLine.end; i++) { + for (int i = glyphLine.getStart(); i < glyphLine.getEnd(); i++) { width += glyphLine.get(i).getWidth(); } return width; @@ -470,10 +470,10 @@ protected PdfDictionary getFontDescriptor(String fontName) { addFontStream(fontDescriptor); int flags = fontProgram.getPdfFontFlags(); // reset both flags - flags &= ~(FontDescriptorFlags.Symbolic | FontDescriptorFlags.Nonsymbolic); + flags &= ~(FontDescriptorFlags.SYMBOLIC | FontDescriptorFlags.NONSYMBOLIC); // set fontSpecific based on font encoding flags |= fontEncoding.isFontSpecific() ? - FontDescriptorFlags.Symbolic : FontDescriptorFlags.Nonsymbolic; + FontDescriptorFlags.SYMBOLIC : FontDescriptorFlags.NONSYMBOLIC; fontDescriptor.put(PdfName.Flags, new PdfNumber(flags)); return fontDescriptor; diff --git a/kernel/src/main/java/com/itextpdf/kernel/font/PdfType0Font.java b/kernel/src/main/java/com/itextpdf/kernel/font/PdfType0Font.java index 70d058966f..d49f2b1e59 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/font/PdfType0Font.java +++ b/kernel/src/main/java/com/itextpdf/kernel/font/PdfType0Font.java @@ -41,7 +41,7 @@ This file is part of the iText (R) project. import com.itextpdf.io.logs.IoLogMessageConstant; import com.itextpdf.io.source.ByteArrayOutputStream; import com.itextpdf.io.source.ByteBuffer; -import com.itextpdf.io.source.OutputStream; +import com.itextpdf.io.source.HighPrecisionOutputStream; import com.itextpdf.io.util.StreamUtil; import com.itextpdf.io.util.TextUtil; import com.itextpdf.kernel.exceptions.KernelExceptionMessageConstant; @@ -367,20 +367,20 @@ public byte[] convertToBytes(GlyphLine glyphLine) { CMapCharsetEncoder encoder = StandardCMapCharsets.getEncoder(cmapEncoding.getCmapName()); if (encoder == null) { int totalByteCount = 0; - for (int i = glyphLine.start; i < glyphLine.end; i++) { + for (int i = glyphLine.getStart(); i < glyphLine.getEnd(); i++) { totalByteCount += cmapEncoding.getCmapBytesLength(glyphLine.get(i).getCode()); } // perform actual conversion byte[] bytes = new byte[totalByteCount]; int offset = 0; - for (int i = glyphLine.start; i < glyphLine.end; i++) { + for (int i = glyphLine.getStart(); i < glyphLine.getEnd(); i++) { usedGlyphs.add(glyphLine.get(i).getCode()); offset = cmapEncoding.fillCmapBytes(glyphLine.get(i).getCode(), bytes, offset); } return bytes; } else { java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream(); - for (int i = glyphLine.start; i < glyphLine.end; i++) { + for (int i = glyphLine.getStart(); i < glyphLine.getEnd(); i++) { Glyph g = glyphLine.get(i); usedGlyphs.add(g.getCode()); byte[] encodedBit = encoder.encodeUnicodeCodePoint(g.getUnicode()); @@ -676,7 +676,7 @@ public boolean appendDecodedCodesToGlyphsList(List list, PdfString charac public float getContentWidth(PdfString content) { float width = 0; GlyphLine glyphLine = decodeIntoGlyphLine(content); - for (int i = glyphLine.start; i < glyphLine.end; i++) { + for (int i = glyphLine.getStart(); i < glyphLine.getEnd(); i++) { width += glyphLine.get(i).getWidth(); } return width; @@ -912,7 +912,7 @@ protected PdfDictionary getCidFont(PdfDictionary fontDescriptor, String fontName private PdfObject generateWidthsArray() { ByteArrayOutputStream bytes = new ByteArrayOutputStream(); - OutputStream stream = new OutputStream<>(bytes); + HighPrecisionOutputStream stream = new HighPrecisionOutputStream<>(bytes); stream.writeByte('['); int lastNumber = -10; boolean firstTime = true; @@ -947,7 +947,8 @@ private PdfObject generateWidthsArray() { * @return the stream representing this CMap or null */ public PdfStream getToUnicode() { - OutputStream stream = new OutputStream<>(new ByteArrayOutputStream()); + HighPrecisionOutputStream stream = + new HighPrecisionOutputStream<>(new ByteArrayOutputStream()); stream.writeString("/CIDInit /ProcSet findresource begin\n" + "12 dict begin\n" + "begincmap\n" + @@ -987,7 +988,7 @@ public PdfStream getToUnicode() { return new PdfStream(((ByteArrayOutputStream)stream.getOutputStream()).toByteArray()); } - private int writeBfrange(OutputStream stream, List range) { + private static int writeBfrange(HighPrecisionOutputStream stream, List range) { if (range.isEmpty()) return 0; stream.writeInteger(range.size()); stream.writeString(" beginbfrange\n"); diff --git a/kernel/src/main/java/com/itextpdf/kernel/font/PdfType3Font.java b/kernel/src/main/java/com/itextpdf/kernel/font/PdfType3Font.java index 7c7fd16b98..d6284319e6 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/font/PdfType3Font.java +++ b/kernel/src/main/java/com/itextpdf/kernel/font/PdfType3Font.java @@ -365,10 +365,10 @@ protected PdfDictionary getFontDescriptor(String fontName) { int flags = fontProgram.getPdfFontFlags(); // reset both flags - flags &= ~(FontDescriptorFlags.Symbolic | FontDescriptorFlags.Nonsymbolic); + flags &= ~(FontDescriptorFlags.SYMBOLIC | FontDescriptorFlags.NONSYMBOLIC); // set fontSpecific based on font encoding flags |= fontEncoding.isFontSpecific() ? - FontDescriptorFlags.Symbolic : FontDescriptorFlags.Nonsymbolic; + FontDescriptorFlags.SYMBOLIC : FontDescriptorFlags.NONSYMBOLIC; fontDescriptor.put(PdfName.Flags, new PdfNumber(flags)); return fontDescriptor; diff --git a/kernel/src/main/java/com/itextpdf/kernel/geom/AffineTransform.java b/kernel/src/main/java/com/itextpdf/kernel/geom/AffineTransform.java index 29d974afdd..2e3db017b5 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/geom/AffineTransform.java +++ b/kernel/src/main/java/com/itextpdf/kernel/geom/AffineTransform.java @@ -24,6 +24,11 @@ This file is part of the iText (R) project. import java.util.Objects; +/** + * The {@link AffineTransform} class represents an affine transformation, + * which is a combination of linear transformations such as translation, + * scaling, rotation, and shearing which allows preservation of the straightness of lines. + */ public class AffineTransform implements Cloneable { @@ -102,12 +107,22 @@ public class AffineTransform implements Cloneable { */ int type; + /** + * Create an empty {@link AffineTransform} instance. + * The default type is for the transformation is {@code TYPE_IDENTITY} + */ public AffineTransform() { type = TYPE_IDENTITY; m00 = m11 = 1; m10 = m01 = m02 = m12 = 0; } + /** + * Will create a new {@link AffineTransform} instance with the values provided from the original + * {@link AffineTransform} instance. + * + * @param t The AffineTransform class to be used. + */ public AffineTransform(AffineTransform t) { this.type = t.type; this.m00 = t.m00; @@ -118,6 +133,17 @@ public AffineTransform(AffineTransform t) { this.m12 = t.m12; } + /** + * Create an {@link AffineTransform} instance with the values provided. + * The default type is for the transformation is {@code TYPE_UNKNOWN} + * + * @param m00 The value of the first row and first column of the matrix. + * @param m10 The value of the second row and first column of the matrix. + * @param m01 The value of the first row and second column of the matrix. + * @param m11 The value of the second row and second column of the matrix. + * @param m02 The value of the first row and third column of the matrix. + * @param m12 The value of the second row and third column of the matrix. + */ public AffineTransform(double m00, double m10, double m01, double m11, double m02, double m12) { this.type = TYPE_UNKNOWN; this.m00 = m00; @@ -128,6 +154,12 @@ public AffineTransform(double m00, double m10, double m01, double m11, double m0 this.m12 = m12; } + /** + * Create an {@link AffineTransform} instance with the values provided. + * The default type is for the transformation is {@code TYPE_UNKNOWN} + * + * @param matrix The array of values to be used for the transformation matrix. + */ public AffineTransform(float[] matrix) { this.type = TYPE_UNKNOWN; m00 = matrix[0]; @@ -140,6 +172,12 @@ public AffineTransform(float[] matrix) { } } + /** + * Create an {@link AffineTransform} instance with the values provided. + * The default type is for the transformation is {@code TYPE_UNKNOWN} + * + * @param matrix The array of values to be used for the transformation matrix. + */ public AffineTransform(double[] matrix) { this.type = TYPE_UNKNOWN; m00 = matrix[0]; @@ -216,34 +254,74 @@ public int getType() { return type; } + /** + * Gets the scale factor of the x-axis. + * + * @return the scale factor of the x-axis. + */ public double getScaleX() { return m00; } + /** + * Gets the scale factor of the y-axis. + * + * @return the scale factor of the y-axis. + */ public double getScaleY() { return m11; } + /** + * Gets the shear factor of the x-axis. + * + * @return the shear factor of the x-axis. + */ public double getShearX() { return m01; } + /** + * Gets the shear factor of the y-axis. + * + * @return the shear factor of the y-axis. + */ public double getShearY() { return m10; } + /** + * Gets translation factor of the x-axis. + * + * @return the translation factor of the x-axis. + */ public double getTranslateX() { return m02; } + /** + * Gets translation factor of the y-axis. + * + * @return the translation factor of the y-axis. + */ public double getTranslateY() { return m12; } + /** + * Gets whether this {@link AffineTransform} is an identity transformation. + * + * @return {@code true} if this {@link AffineTransform} is an identity transformation, {@code false} otherwise. + */ public boolean isIdentity() { return getType() == TYPE_IDENTITY; } + /** + * Fills the matrix parameter with the values of this {@link AffineTransform} instance. + * + * @param matrix the array to be filled with the values of this {@link AffineTransform} instance. + */ public void getMatrix(float[] matrix) { matrix[0] = (float) m00; matrix[1] = (float) m10; @@ -255,6 +333,11 @@ public void getMatrix(float[] matrix) { } } + /** + * Fills the matrix parameter with the values of this {@link AffineTransform} instance. + * + * @param matrix the array to be filled with the values of this {@link AffineTransform} instance. + */ public void getMatrix(double[] matrix) { matrix[0] = m00; matrix[1] = m10; @@ -266,10 +349,26 @@ public void getMatrix(double[] matrix) { } } + /** + * Gets the determinant of the matrix representation of this {@link AffineTransform}. + * + * @return the determinant of the matrix representation of this {@link AffineTransform}. + */ public double getDeterminant() { return m00 * m11 - m01 * m10; } + /** + * Sets the values of this {@link AffineTransform} instance to the values provided. + * The type of the transformation is set to {@code TYPE_UNKNOWN}. + * + * @param m00 The value of the first row and first column of the matrix. + * @param m10 The value of the second row and first column of the matrix. + * @param m01 The value of the first row and second column of the matrix. + * @param m11 The value of the second row and second column of the matrix. + * @param m02 The value of the first row and third column of the matrix. + * @param m12 The value of the second row and third column of the matrix. + */ public void setTransform(float m00, float m10, float m01, float m11, float m02, float m12) { this.type = TYPE_UNKNOWN; this.m00 = m00; @@ -280,6 +379,17 @@ public void setTransform(float m00, float m10, float m01, float m11, float m02, this.m12 = m12; } + /** + * Sets the values of this {@link AffineTransform} instance to the values provided. + * The type of the transformation is set to {@code TYPE_UNKNOWN}. + * + * @param m00 The value of the first row and first column of the matrix. + * @param m10 The value of the second row and first column of the matrix. + * @param m01 The value of the first row and second column of the matrix. + * @param m11 The value of the second row and second column of the matrix. + * @param m02 The value of the first row and third column of the matrix. + * @param m12 The value of the second row and third column of the matrix. + */ public void setTransform(double m00, double m10, double m01, double m11, double m02, double m12) { this.type = TYPE_UNKNOWN; this.m00 = m00; @@ -290,17 +400,31 @@ public void setTransform(double m00, double m10, double m01, double m11, double this.m12 = m12; } + /** + * Sets the values of this {@link AffineTransform} instance to the values provided. + * + * @param t The {@link AffineTransform} instance to be used. + */ public void setTransform(AffineTransform t) { type = t.type; setTransform(t.m00, t.m10, t.m01, t.m11, t.m02, t.m12); } + /** + * Sets this {@link AffineTransform} to the identity transformation. + */ public void setToIdentity() { type = TYPE_IDENTITY; m00 = m11 = 1; m10 = m01 = m02 = m12 = 0; } + /** + * Sets this {@link AffineTransform} to represent a translation transformation. + * + * @param mx The value of the translation on the x-axis. + * @param my The value of the translation on the y-axis. + */ public void setToTranslation(double mx, double my) { m00 = m11 = 1; m01 = m10 = 0; @@ -313,6 +437,12 @@ public void setToTranslation(double mx, double my) { } } + /** + * Sets this {@link AffineTransform} to represent a scale transformation. + * + * @param scx The value of the scale factor on the x-axis. + * @param scy The value of the scale factor on the y-axis. + */ public void setToScale(double scx, double scy) { m00 = scx; m11 = scy; @@ -324,6 +454,12 @@ public void setToScale(double scx, double scy) { } } + /** + * Sets this {@link AffineTransform} to represent a shear transformation. + * + * @param shx The value of the shear factor on the x-axis. + * @param shy The value of the shear factor on the y-axis. + */ public void setToShear(double shx, double shy) { m00 = m11 = 1; m02 = m12 = 0; @@ -363,8 +499,8 @@ public void setToRotation(double angle) { * using the passed point as the center of rotation * * @param angle angle to rotate over in radians - * @param px x-coordinate of center of rotation - * @param py y-coordinate of center of rotation + * @param px x-coordinate of center of rotation + * @param py y-coordinate of center of rotation */ public void setToRotation(double angle, double px, double py) { setToRotation(angle); @@ -373,18 +509,40 @@ public void setToRotation(double angle, double px, double py) { type = TYPE_UNKNOWN; } + + /** + * Get a new {@link AffineTransform} instance representing a translation over the passed values + * + * @param mx x-coordinate of translation + * @param my y-coordinate of translation + * @return {@link AffineTransform} representing the translation + */ public static AffineTransform getTranslateInstance(double mx, double my) { AffineTransform t = new AffineTransform(); t.setToTranslation(mx, my); return t; } + /** + * Get a new {@link AffineTransform} instance representing a scale over the passed values + * + * @param scx scale factor on the x-axis + * @param scY scale factor on the y-axis + * @return {@link AffineTransform} representing the scale + */ public static AffineTransform getScaleInstance(double scx, double scY) { AffineTransform t = new AffineTransform(); t.setToScale(scx, scY); return t; } + /** + * Get a new {@link AffineTransform} instance representing a shear over the passed values + * + * @param shx shear factor on the x-axis + * @param shy shear factor on the y-axis + * @return {@link AffineTransform} representing the shear + */ public static AffineTransform getShearInstance(double shx, double shy) { AffineTransform m = new AffineTransform(); m.setToShear(shx, shy); @@ -408,8 +566,8 @@ public static AffineTransform getRotateInstance(double angle) { * using the passed point as the center of rotation * * @param angle angle in radians to rotate over - * @param x x-coordinate of center of rotation - * @param y y-coordinate of center of rotation + * @param x x-coordinate of center of rotation + * @param y y-coordinate of center of rotation * @return {@link AffineTransform} representing the rotation */ public static AffineTransform getRotateInstance(double angle, double x, double y) { @@ -442,9 +600,10 @@ public void rotate(double angle) { /** * Add a counter-clockwise rotation to this transformation, * using the passed point as the center of rotation + * * @param angle angle in radians to rotate over - * @param px x-coordinate of center of rotation - * @param py y-coordinate of center of rotation + * @param px x-coordinate of center of rotation + * @param py y-coordinate of center of rotation */ public void rotate(double angle, double px, double py) { concatenate(AffineTransform.getRotateInstance(angle, px, py)); @@ -453,8 +612,8 @@ public void rotate(double angle, double px, double py) { /** * Multiply matrix of two AffineTransform objects * - * @param t1 - the AffineTransform object is a multiplicand - * @param t2 - the AffineTransform object is a multiplier + * @param t1 - the AffineTransform object is a multiplicand. + * @param t2 - the AffineTransform object is a multiplier. * @return an AffineTransform object that is a result of t1 multiplied by matrix t2. */ AffineTransform multiply(AffineTransform t1, AffineTransform t2) { @@ -467,14 +626,30 @@ AffineTransform multiply(AffineTransform t1, AffineTransform t2) { t1.m02 * t2.m10 + t1.m12 * t2.m11 + t2.m12); } + /** + * Multiply matrix of two AffineTransform objects + * + * @param t - the AffineTransform object is a multiplier. + */ public void concatenate(AffineTransform t) { setTransform(multiply(t, this)); } + /** + * Multiply matrix of two AffineTransform objects + * + * @param t - the AffineTransform object is a multiplicand. + */ public void preConcatenate(AffineTransform t) { setTransform(multiply(this, t)); } + /** + * Creates a new {@link AffineTransform} object that is invert of this {@link AffineTransform} object. + * + * @return a new {@link AffineTransform} object that is invert of this {@link AffineTransform} object. + * @throws NoninvertibleTransformException if this {@link AffineTransform} object cannot be inverted. + */ public AffineTransform createInverse() throws NoninvertibleTransformException { double det = getDeterminant(); if (Math.abs(det) < ZERO) { @@ -492,6 +667,13 @@ public AffineTransform createInverse() throws NoninvertibleTransformException { ); } + /** + * Transform the point according to the values of this {@link AffineTransform} object. + * + * @param src The point to be transformed. + * @param dst The point that will hold the result of the transformation. + * @return The point that holds the result of the transformation. + */ public Point transform(Point src, Point dst) { if (dst == null) { dst = new Point(); @@ -504,6 +686,15 @@ public Point transform(Point src, Point dst) { return dst; } + /** + * Transform the array of points according to the values of this {@link AffineTransform} object. + * + * @param src The array of points to be transformed. + * @param srcOff The offset of the first point in the array. + * @param dst The array of points that will hold the result of the transformation. + * @param dstOff The offset of the first point in the destination array. + * @param length The number of points to be transformed. + */ public void transform(Point[] src, int srcOff, Point[] dst, int dstOff, int length) { while (--length >= 0) { Point srcPoint = src[srcOff++]; @@ -518,6 +709,15 @@ public void transform(Point[] src, int srcOff, Point[] dst, int dstOff, int leng } } + /** + * Transform the array of points according to the values of this {@link AffineTransform} object. + * + * @param src The array of points to be transformed. + * @param srcOff The offset of the first point in the array. + * @param dst The array of points that will hold the result of the transformation. + * @param dstOff The offset of the first point in the destination array. + * @param length The number of points to be transformed. + */ public void transform(double[] src, int srcOff, double[] dst, int dstOff, int length) { int step = 2; if (src == dst && srcOff < dstOff && dstOff < srcOff + length * 2) { @@ -535,6 +735,15 @@ public void transform(double[] src, int srcOff, double[] dst, int dstOff, int le } } + /** + * Transform the array of points according to the values of this {@link AffineTransform} object. + * + * @param src The array of points to be transformed. + * @param srcOff The offset of the first point in the array. + * @param dst The array of points that will hold the result of the transformation. + * @param dstOff The offset of the first point in the destination array. + * @param length The number of points to be transformed. + */ public void transform(float[] src, int srcOff, float[] dst, int dstOff, int length) { int step = 2; if (src == dst && srcOff < dstOff && dstOff < srcOff + length * 2) { @@ -552,6 +761,15 @@ public void transform(float[] src, int srcOff, float[] dst, int dstOff, int leng } } + /** + * Transform the array of points according to the values of this {@link AffineTransform} object. + * + * @param src The array of points to be transformed. + * @param srcOff The offset of the first point in the array. + * @param dst The array of points that will hold the result of the transformation. + * @param dstOff The offset of the first point in the destination array. + * @param length The number of points to be transformed. + */ public void transform(float[] src, int srcOff, double[] dst, int dstOff, int length) { while (--length >= 0) { float x = src[srcOff++]; @@ -561,6 +779,15 @@ public void transform(float[] src, int srcOff, double[] dst, int dstOff, int len } } + /** + * Transform the array of points according to the values of this {@link AffineTransform} object. + * + * @param src The array of points to be transformed. + * @param srcOff The offset of the first point in the array. + * @param dst The array of points that will hold the result of the transformation. + * @param dstOff The offset of the first point in the destination array. + * @param length The number of points to be transformed. + */ public void transform(double[] src, int srcOff, float[] dst, int dstOff, int length) { while (--length >= 0) { double x = src[srcOff++]; @@ -570,6 +797,13 @@ public void transform(double[] src, int srcOff, float[] dst, int dstOff, int len } } + /** + * Performs the transformation on the source point and stores the result in the destination point. + * + * @param src The source point to be transformed. + * @param dst The destination point that will hold the result of the transformation. + * @return The modified destination point. + */ public Point deltaTransform(Point src, Point dst) { if (dst == null) { dst = new Point(); @@ -582,6 +816,16 @@ public Point deltaTransform(Point src, Point dst) { return dst; } + /** + * Performs the delta transformation on the source array of points and stores the result in + * the destination array of points. + * + * @param src The source array of data to be transformed. + * @param srcOff The offset of the first point in the source array. + * @param dst The destination array of data that will hold the result of the transformation. + * @param dstOff The offset of the first point in the destination array. + * @param length The number of points to be transformed. + */ public void deltaTransform(double[] src, int srcOff, double[] dst, int dstOff, int length) { while (--length >= 0) { double x = src[srcOff++]; @@ -591,6 +835,14 @@ public void deltaTransform(double[] src, int srcOff, double[] dst, int dstOff, i } } + /** + * Performs the inverse transformation on the source point and stores the result in the destination point. + * + * @param src The source point to be transformed. + * @param dst The destination point that will hold the result of the transformation. + * @return The modified destination point. + * @throws NoninvertibleTransformException if the matrix cannot be inverted. + */ public Point inverseTransform(Point src, Point dst) throws NoninvertibleTransformException { double det = getDeterminant(); if (Math.abs(det) < ZERO) { @@ -610,6 +862,17 @@ public Point inverseTransform(Point src, Point dst) throws NoninvertibleTransfor return dst; } + /** + * Performs the inverse transformation on the source array of points and stores the result + * in the destination array of points. + * + * @param src The source array of data to be transformed. + * @param srcOff The offset of the first point in the source array. + * @param dst The destination array of data that will hold the result of the transformation. + * @param dstOff The offset of the first point in the destination array. + * @param length The number of points to be transformed. + * @throws NoninvertibleTransformException if the matrix cannot be inverted. + */ public void inverseTransform(double[] src, int srcOff, double[] dst, int dstOff, int length) throws NoninvertibleTransformException { double det = getDeterminant(); @@ -627,6 +890,17 @@ public void inverseTransform(double[] src, int srcOff, double[] dst, int dstOff, } } + /** + * Performs the inverse transformation on the source array of points and stores the result + * in the destination array of points. + * + * @param src The source array of data to be transformed. + * @param srcOff The offset of the first point in the source array. + * @param dst The destination array of data that will hold the result of the transformation. + * @param dstOff The offset of the first point in the destination array. + * @param length The number of points to be transformed. + * @throws NoninvertibleTransformException if the matrix cannot be inverted. + */ public void inverseTransform(float[] src, int srcOff, float[] dst, int dstOff, int length) throws NoninvertibleTransformException { float det = (float) getDeterminant(); @@ -657,6 +931,15 @@ public AffineTransform clone() throws CloneNotSupportedException { } + /** + * Compares this AffineTransform with the specified Object. + * If the object is the same as this AffineTransform, this method returns true. + * Otherwise, this method checks if the Object is an instance of AffineTransform and if the values of the two + * AffineTransforms are equal. + * + * @param o The object to compare this AffineTransform with. + * @return {@code true} if the object is the same as this AffineTransform, {@code false} otherwise. + */ @Override public boolean equals(Object o) { if (this == o) @@ -675,6 +958,11 @@ public boolean equals(Object o) { Double.compare(that.m12, m12) == 0; } + /** + * Returns a hash code value for the object. + * + * @return a hash code value for this object. + */ @Override public int hashCode() { return Objects.hash(m00, m10, m01, m11, m02, m12); diff --git a/kernel/src/main/java/com/itextpdf/kernel/geom/Point.java b/kernel/src/main/java/com/itextpdf/kernel/geom/Point.java index 280a0f974a..3fca4d3ec6 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/geom/Point.java +++ b/kernel/src/main/java/com/itextpdf/kernel/geom/Point.java @@ -26,113 +26,125 @@ import com.itextpdf.commons.utils.MessageFormatUtil; import com.itextpdf.io.util.HashCode; +/** + * Class that represent point object with x and y coordinates. + */ public class Point implements Cloneable { + private double x; + private double y; - - public double x; - public double y; - + /** + * Instantiates a new {@link Point} instance with 0 x and y. + */ public Point() { setLocation(0, 0); } - public Point(int x, int y) { - setLocation(x, y); - } - + /** + * Instantiates a new {@link Point} instance based on passed x and y. + * + * @param x the x coordinates of the point + * @param y the y coordinates of the point + */ public Point(double x, double y) { setLocation(x, y); } - public Point(Point p) { - setLocation(p.x, p.y); - } - - @Override - public boolean equals(Object obj) { - if (obj == this) { - return true; - } - if (obj instanceof Point) { - Point p = (Point)obj; - return x == p.x && y == p.y; - } - return false; - } - - @Override - public String toString() { - //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - return MessageFormatUtil.format("Point: [x={0},y={1}]", x, y); - } - + /** + * Gets x coordinate of the point. + * + * @return the x coordinate + */ public double getX() { return x; } + /** + * Gets y coordinate of the point. + * + * @return the y coordinate + */ public double getY() { return y; } + /** + * Gets location of point by creating a new copy. + * + * @return the copy of this point + */ public Point getLocation() { return new Point(x, y); } - public void setLocation(Point p) { - setLocation(p.x, p.y); - } - - public void setLocation(int x, int y) { - setLocation((double)x, (double)y); - } - + /** + * Sets x and y double coordinates of the point. + * + * @param x the x coordinate + * @param y the y coordinate + */ public void setLocation(double x, double y) { this.x = x; this.y = y; } - public void move(double x, double y) { - setLocation(x, y); - } - - public void translate(double dx, double dy) { + /** + * Moves the point by the specified offset. + * + * @param dx the x-axis offset + * @param dy the y-axis offset + */ + public void move(double dx, double dy) { x += dx; y += dy; } - - @Override - public int hashCode() { - HashCode hash = new HashCode(); - hash.append(getX()); - hash.append(getY()); - return hash.hashCode(); - } - - public static double distanceSq(double x1, double y1, double x2, double y2) { - x2 -= x1; - y2 -= y1; - return x2 * x2 + y2 * y2; - } - - public double distanceSq(double px, double py) { - return distanceSq(getX(), getY(), px, py); + /** + * The distance between this point and the second point which is defined by passed x and y coordinates. + * + * @param px the x coordinate of the second point + * @param py the y coordinate of the second point + * + * @return the distance between points + */ + public double distance(double px, double py) { + return Math.sqrt(distanceSq(getX(), getY(), px, py)); } - public double distanceSq(Point p) { - return distanceSq(getX(), getY(), p.getX(), p.getY()); + /** + * The distance between this point and the second point. + * + * @param p the second point to calculate distance + * + * @return the distance between points + */ + public double distance(Point p) { + return distance(p.getX(), p.getY()); } - public static double distance(double x1, double y1, double x2, double y2) { - return Math.sqrt(distanceSq(x1, y1, x2, y2)); + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (obj instanceof Point) { + Point p = (Point)obj; + return x == p.x && y == p.y; + } + return false; } - public double distance(double px, double py) { - return Math.sqrt(distanceSq(px, py)); + @Override + public String toString() { + return MessageFormatUtil.format("Point: [x={0},y={1}]", x, y); } - public double distance(Point p) { - return Math.sqrt(distanceSq(p)); + @Override + public int hashCode() { + HashCode hash = new HashCode(); + hash.append(getX()); + hash.append(getY()); + return hash.hashCode(); } @SuppressWarnings("CloneDoesntCallSuperClone") @@ -140,5 +152,11 @@ public double distance(Point p) { public Object clone() { return new Point(x, y); } + + private static double distanceSq(double x1, double y1, double x2, double y2) { + x2 -= x1; + y2 -= y1; + return x2 * x2 + y2 * y2; + } } diff --git a/kernel/src/main/java/com/itextpdf/kernel/logs/KernelLogMessageConstant.java b/kernel/src/main/java/com/itextpdf/kernel/logs/KernelLogMessageConstant.java index 698f9c3e46..69901d75c4 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/logs/KernelLogMessageConstant.java +++ b/kernel/src/main/java/com/itextpdf/kernel/logs/KernelLogMessageConstant.java @@ -98,6 +98,18 @@ public final class KernelLogMessageConstant { public static final String XOBJECT_STRUCT_PARENT_INDEX_MISSED_AND_RECREATED = "XObject has no StructParents index in its stream, so index is recreated"; + //TODO DEVSIX-8490 remove this log message when implemented + public static final String DUPLICATE_ENTRIES_IN_ORDER_ARRAY_REMOVED = "Duplicated entries in order array are " + + "removed"; + + public static final String FINGERPRINT_DISABLED_BUT_NO_REQUIRED_LICENCE = "Fingerprint disabling is only " + + "available in non AGPL mode. Fingerprint will be added at the end of the document."; + public static final String ALGORITHM_NOT_FROM_SPEC = + "Requested algorithm might not be supported by the pdf specification."; + + public static final String MEMORYLIMITAWAREHANDLER_OVERRIDE_CREATENEWINSTANCE_METHOD = + "MemoryLimitsAwareHandler#createNewInstance method must be overriden."; + private KernelLogMessageConstant() { //Private constructor will prevent the instantiation of this class directly } diff --git a/kernel/src/main/java/com/itextpdf/kernel/mac/AbstractMacIntegrityProtector.java b/kernel/src/main/java/com/itextpdf/kernel/mac/AbstractMacIntegrityProtector.java new file mode 100644 index 0000000000..a74a6b8673 --- /dev/null +++ b/kernel/src/main/java/com/itextpdf/kernel/mac/AbstractMacIntegrityProtector.java @@ -0,0 +1,393 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.mac; + +import com.itextpdf.bouncycastleconnector.BouncyCastleFactoryCreator; +import com.itextpdf.commons.bouncycastle.IBouncyCastleFactory; +import com.itextpdf.commons.bouncycastle.asn1.IASN1EncodableVector; +import com.itextpdf.commons.bouncycastle.asn1.IDERSequence; +import com.itextpdf.commons.bouncycastle.asn1.IDERSet; +import com.itextpdf.io.source.IRandomAccessSource; +import com.itextpdf.io.source.RASInputStream; +import com.itextpdf.io.source.RandomAccessSourceFactory; +import com.itextpdf.kernel.crypto.DigestAlgorithms; +import com.itextpdf.kernel.crypto.OID; +import com.itextpdf.kernel.exceptions.KernelExceptionMessageConstant; +import com.itextpdf.kernel.exceptions.PdfException; +import com.itextpdf.kernel.mac.MacProperties.MacDigestAlgorithm; +import com.itextpdf.kernel.pdf.PdfDictionary; +import com.itextpdf.kernel.pdf.PdfDocument; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.security.GeneralSecurityException; +import java.security.InvalidKeyException; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.security.NoSuchProviderException; +import java.util.Arrays; + +/** + * Class responsible for integrity protection in encrypted documents, which uses MAC container. + */ +public abstract class AbstractMacIntegrityProtector { + private static final IBouncyCastleFactory BC_FACTORY = BouncyCastleFactoryCreator.getFactory(); + + private static final String PDF_MAC = "PDFMAC"; + + protected final PdfDocument document; + protected final MacProperties macProperties; + protected byte[] kdfSalt = null; + protected byte[] fileEncryptionKey = new byte[0]; + private final MacContainerReader macContainerReader; + + /** + * Creates {@link AbstractMacIntegrityProtector} instance from the provided {@link MacProperties}. + * + * @param document {@link PdfDocument} for which integrity protection is required + * @param macProperties {@link MacProperties} used to provide MAC algorithm properties + */ + protected AbstractMacIntegrityProtector(PdfDocument document, MacProperties macProperties) { + this.document = document; + this.macContainerReader = null; + this.macProperties = macProperties; + } + + /** + * Creates {@link AbstractMacIntegrityProtector} instance from the Auth dictionary. + * + * @param document {@link PdfDocument} for which integrity protection is required + * @param authDictionary {@link PdfDictionary} representing Auth dictionary in which MAC container is stored + */ + protected AbstractMacIntegrityProtector(PdfDocument document, PdfDictionary authDictionary) { + this.document = document; + this.macContainerReader = MacContainerReader.getInstance(authDictionary); + this.macProperties = new MacProperties(getMacDigestAlgorithm(macContainerReader.parseDigestAlgorithm())); + } + + /** + * Sets file encryption key to be used during MAC calculation. + * + * @param fileEncryptionKey {@code byte[]} file encryption key bytes + */ + public void setFileEncryptionKey(byte[] fileEncryptionKey) { + this.fileEncryptionKey = fileEncryptionKey; + } + + /** + * Gets KDF salt bytes, which are used during MAC key encryption. + * + * @return {@code byte[]} KDF salt bytes. + */ + public byte[] getKdfSalt() { + if (kdfSalt == null) { + kdfSalt = generateRandomBytes(32); + } + return Arrays.copyOf(kdfSalt, kdfSalt.length); + } + + /** + * Sets KDF salt bytes, to be used during MAC key encryption. + * + * @param kdfSalt {@code byte[]} KDF salt bytes. + */ + public void setKdfSalt(byte[] kdfSalt) { + this.kdfSalt = Arrays.copyOf(kdfSalt, kdfSalt.length); + } + + /** + * Validates MAC container integrity. This method throws {@link PdfException} in case of any modifications, + * introduced to the document in question, after MAC container is integrated. + */ + public void validateMacToken() { + if (kdfSalt == null) { + throw new MacValidationException(KernelExceptionMessageConstant.MAC_VALIDATION_NO_SALT); + } + try { + byte[] macKey = generateDecryptedKey(macContainerReader.parseMacKey()); + long[] byteRange = macContainerReader.getByteRange(); + byte[] dataDigest; + IRandomAccessSource randomAccessSource = document.getReader().getSafeFile().createSourceView(); + try (InputStream rg = new RASInputStream( + new RandomAccessSourceFactory().createRanged(randomAccessSource, byteRange))) { + dataDigest = digestBytes(rg); + } + + byte[] expectedData = macContainerReader.parseAuthAttributes().getEncoded(); + byte[] expectedMac = generateMac(macKey, expectedData); + byte[] signatureDigest = digestBytes(macContainerReader.getSignature()); + byte[] expectedMessageDigest = createMessageDigestSequence( + createPdfMacIntegrityInfo(dataDigest, signatureDigest)).getEncoded(); + + byte[] actualMessageDigest = macContainerReader.parseMessageDigest().getEncoded(); + byte[] actualMac = macContainerReader.parseMac(); + + if (!Arrays.equals(expectedMac, actualMac) || + !Arrays.equals(expectedMessageDigest, actualMessageDigest)) { + throw new MacValidationException(KernelExceptionMessageConstant.MAC_VALIDATION_FAILED); + } + } catch (PdfException e) { + throw e; + } catch (Exception e) { + throw new MacValidationException(KernelExceptionMessageConstant.MAC_VALIDATION_EXCEPTION, e); + } + } + + /** + * Digests provided bytes based on hash algorithm, specified for this class instance. + * + * @param bytes {@code byte[]} to be digested + * + * @return digested bytes. + * + * @throws NoSuchAlgorithmException in case of digesting algorithm related exceptions + * @throws IOException in case of input-output related exceptions + * @throws NoSuchProviderException thrown when a particular security provider is + * requested but is not available in the environment + */ + protected byte[] digestBytes(byte[] bytes) throws NoSuchAlgorithmException, IOException, NoSuchProviderException { + return bytes == null ? null : digestBytes(new ByteArrayInputStream(bytes)); + } + + /** + * Digests provided input stream based on hash algorithm, specified for this class instance. + * + * @param inputStream {@link InputStream} to be digested + * + * @return digested bytes. + * + * @throws NoSuchAlgorithmException in case of digesting algorithm related exceptions + * @throws IOException in case of input-output related exceptions + * @throws NoSuchProviderException thrown when a particular security provider is + * requested but is not available in the environment + */ + protected byte[] digestBytes(InputStream inputStream) + throws NoSuchAlgorithmException, IOException, NoSuchProviderException { + + if (inputStream == null) { + return null; + } + final String algorithm = MacProperties.macDigestAlgorithmToString(macProperties.getMacDigestAlgorithm()); + MessageDigest digest = DigestAlgorithms.getMessageDigest(algorithm, BC_FACTORY.getProviderName()); + byte[] buf = new byte[8192]; + int rd; + while ((rd = inputStream.read(buf, 0, buf.length)) > 0) { + digest.update(buf, 0, rd); + } + return digest.digest(); + } + + /** + * Creates MAC container as ASN1 object based on data digest, MAC key and signature parameters. + * + * @param dataDigest data digest as {@code byte[]} to be used during MAC container creation + * @param macKey MAC key as {@code byte[]} to be used during MAC container creation + * @param signature signature value as {@code byte[]} to be used during MAC container creation + * + * @return MAC container as {@link IDERSequence}. + * + * @throws GeneralSecurityException in case of security related exceptions + * @throws IOException in case of input-output related exceptions + */ + protected IDERSequence createMacContainer(byte[] dataDigest, byte[] macKey, byte[] signature) + throws GeneralSecurityException, IOException { + IASN1EncodableVector contentInfoV = BC_FACTORY.createASN1EncodableVector(); + contentInfoV.add(BC_FACTORY.createASN1ObjectIdentifier(OID.AUTHENTICATED_DATA)); + + // Recipient info + IASN1EncodableVector recInfoV = BC_FACTORY.createASN1EncodableVector(); + recInfoV.add(BC_FACTORY.createASN1Integer(0)); // version + recInfoV.add(BC_FACTORY.createDERTaggedObject(0, + BC_FACTORY.createASN1ObjectIdentifier(OID.KDF_PDF_MAC_WRAP_KDF))); + recInfoV.add(BC_FACTORY.createDERSequence(BC_FACTORY.createASN1ObjectIdentifier(getKeyWrappingAlgorithmOid()))); + + ////////////////////// KEK + + byte[] macKek = BC_FACTORY.generateHKDF(fileEncryptionKey, kdfSalt, PDF_MAC.getBytes(StandardCharsets.UTF_8)); + byte[] encryptedKey = generateEncryptedKey(macKey, macKek); + + recInfoV.add(BC_FACTORY.createDEROctetString(encryptedKey)); + + // Digest info + byte[] messageBytes = createPdfMacIntegrityInfo(dataDigest, signature == null ? null : digestBytes(signature)); + + // Encapsulated content info + IASN1EncodableVector encapContentInfoV = BC_FACTORY.createASN1EncodableVector(); + encapContentInfoV.add(BC_FACTORY.createASN1ObjectIdentifier(OID.CT_PDF_MAC_INTEGRITY_INFO)); + encapContentInfoV.add(BC_FACTORY.createDERTaggedObject(0, BC_FACTORY.createDEROctetString(messageBytes))); + + IDERSet authAttrs = createAuthAttributes(messageBytes); + + // Create mac + byte[] data = authAttrs.getEncoded(); + byte[] mac = generateMac(macKey, data); + + // Auth data + IASN1EncodableVector authDataV = BC_FACTORY.createASN1EncodableVector(); + authDataV.add(BC_FACTORY.createASN1Integer(0)); // version + authDataV.add(BC_FACTORY.createDERSet(BC_FACTORY.createDERTaggedObject(false, 3, + BC_FACTORY.createDERSequence(recInfoV)))); + + authDataV.add(BC_FACTORY.createDERSequence(BC_FACTORY.createASN1ObjectIdentifier(getMacAlgorithmOid()))); + final String algorithm = MacProperties.macDigestAlgorithmToString(macProperties.getMacDigestAlgorithm()); + final String macDigestOid = DigestAlgorithms.getAllowedDigest(algorithm); + authDataV.add(BC_FACTORY.createDERTaggedObject(false, 1, + BC_FACTORY.createDERSequence(BC_FACTORY.createASN1ObjectIdentifier(macDigestOid)))); + authDataV.add(BC_FACTORY.createDERSequence(encapContentInfoV)); + authDataV.add(BC_FACTORY.createDERTaggedObject(false, 2, authAttrs)); + authDataV.add(BC_FACTORY.createDEROctetString(mac)); + + contentInfoV.add(BC_FACTORY.createDERTaggedObject(0, BC_FACTORY.createDERSequence(authDataV))); + return BC_FACTORY.createDERSequence(contentInfoV); + } + + private byte[] generateMac(byte[] macKey, byte[] data) throws NoSuchAlgorithmException, InvalidKeyException { + switch (macProperties.getMacAlgorithm()) { + case HMAC_WITH_SHA_256: + return BC_FACTORY.generateHMACSHA256Token(macKey, data); + default: + throw new PdfException(KernelExceptionMessageConstant.MAC_ALGORITHM_NOT_SUPPORTED); + } + } + + private byte[] generateEncryptedKey(byte[] macKey, byte[] macKek) throws GeneralSecurityException { + switch (macProperties.getKeyWrappingAlgorithm()) { + case AES_256_NO_PADD: + return BC_FACTORY.generateEncryptedKeyWithAES256NoPad(macKey, macKek); + default: + throw new PdfException(KernelExceptionMessageConstant.WRAP_ALGORITHM_NOT_SUPPORTED); + } + } + + private byte[] generateDecryptedKey(byte[] encryptedMacKey) throws GeneralSecurityException { + byte[] macKek = BC_FACTORY.generateHKDF(fileEncryptionKey, kdfSalt, PDF_MAC.getBytes(StandardCharsets.UTF_8)); + switch (macProperties.getKeyWrappingAlgorithm()) { + case AES_256_NO_PADD: + return BC_FACTORY.generateDecryptedKeyWithAES256NoPad(encryptedMacKey, macKek); + default: + throw new PdfException(KernelExceptionMessageConstant.WRAP_ALGORITHM_NOT_SUPPORTED); + } + } + + private String getMacAlgorithmOid() { + switch (macProperties.getMacAlgorithm()) { + case HMAC_WITH_SHA_256: + return "1.2.840.113549.2.9"; + default: + throw new PdfException(KernelExceptionMessageConstant.MAC_ALGORITHM_NOT_SUPPORTED); + } + } + + private String getKeyWrappingAlgorithmOid() { + switch (macProperties.getKeyWrappingAlgorithm()) { + case AES_256_NO_PADD: + return "2.16.840.1.101.3.4.1.45"; + default: + throw new PdfException(KernelExceptionMessageConstant.WRAP_ALGORITHM_NOT_SUPPORTED); + } + } + + private IDERSequence createMessageDigestSequence(byte[] messageBytes) + throws NoSuchAlgorithmException, IOException, NoSuchProviderException { + + final String algorithm = MacProperties.macDigestAlgorithmToString(macProperties.getMacDigestAlgorithm()); + // Hash messageBytes to get messageDigest attribute + MessageDigest digest = DigestAlgorithms.getMessageDigest(algorithm, BC_FACTORY.getProviderName()); + digest.update(messageBytes); + byte[] messageDigest = digestBytes(messageBytes); + + // Message digest + IASN1EncodableVector messageDigestV = BC_FACTORY.createASN1EncodableVector(); + messageDigestV.add(BC_FACTORY.createASN1ObjectIdentifier(OID.MESSAGE_DIGEST)); + messageDigestV.add(BC_FACTORY.createDERSet(BC_FACTORY.createDEROctetString(messageDigest))); + + return BC_FACTORY.createDERSequence(messageDigestV); + } + + private IDERSet createAuthAttributes(byte[] messageBytes) + throws NoSuchAlgorithmException, IOException, NoSuchProviderException { + + // Content type - mac integrity info + IASN1EncodableVector contentTypeInfoV = BC_FACTORY.createASN1EncodableVector(); + contentTypeInfoV.add(BC_FACTORY.createASN1ObjectIdentifier(OID.CONTENT_TYPE)); + contentTypeInfoV.add(BC_FACTORY.createDERSet( + BC_FACTORY.createASN1ObjectIdentifier(OID.CT_PDF_MAC_INTEGRITY_INFO))); + + IASN1EncodableVector algorithmsInfoV = BC_FACTORY.createASN1EncodableVector(); + final String algorithm = MacProperties.macDigestAlgorithmToString(macProperties.getMacDigestAlgorithm()); + final String macDigestOid = DigestAlgorithms.getAllowedDigest(algorithm); + algorithmsInfoV.add(BC_FACTORY.createDERSequence(BC_FACTORY.createASN1ObjectIdentifier(macDigestOid))); + algorithmsInfoV.add(BC_FACTORY.createDERTaggedObject(2, + BC_FACTORY.createASN1ObjectIdentifier(getMacAlgorithmOid()))); + + // CMS algorithm protection + IASN1EncodableVector algoProtectionInfoV = BC_FACTORY.createASN1EncodableVector(); + algoProtectionInfoV.add(BC_FACTORY.createASN1ObjectIdentifier(OID.CMS_ALGORITHM_PROTECTION)); + algoProtectionInfoV.add(BC_FACTORY.createDERSet(BC_FACTORY.createDERSequence(algorithmsInfoV))); + + IASN1EncodableVector authAttrsV = BC_FACTORY.createASN1EncodableVector(); + authAttrsV.add(BC_FACTORY.createDERSequence(contentTypeInfoV)); + authAttrsV.add(BC_FACTORY.createDERSequence(algoProtectionInfoV)); + authAttrsV.add(createMessageDigestSequence(messageBytes)); + + return BC_FACTORY.createDERSet(authAttrsV); + } + + private static byte[] createPdfMacIntegrityInfo(byte[] dataDigest, byte[] signatureDigest) throws IOException { + IASN1EncodableVector digestInfoV = BC_FACTORY.createASN1EncodableVector(); + digestInfoV.add(BC_FACTORY.createASN1Integer(0)); + digestInfoV.add(BC_FACTORY.createDEROctetString(dataDigest)); + if (signatureDigest != null) { + digestInfoV.add(BC_FACTORY.createDERTaggedObject(false, 0, + BC_FACTORY.createDEROctetString(signatureDigest))); + } + return BC_FACTORY.createDERSequence(digestInfoV).getEncoded(); + } + + protected static byte[] generateRandomBytes(int length) { + byte[] randomBytes = new byte[length]; + BC_FACTORY.getSecureRandom().nextBytes(randomBytes); + return randomBytes; + } + + private static MacDigestAlgorithm getMacDigestAlgorithm(String oid) { + switch (oid) { + case OID.SHA_256: + return MacDigestAlgorithm.SHA_256; + case OID.SHA_384: + return MacDigestAlgorithm.SHA_384; + case OID.SHA_512: + return MacDigestAlgorithm.SHA_512; + case OID.SHA3_256: + return MacDigestAlgorithm.SHA3_256; + case OID.SHA3_384: + return MacDigestAlgorithm.SHA3_384; + case OID.SHA3_512: + return MacDigestAlgorithm.SHA3_512; + default: + throw new PdfException(KernelExceptionMessageConstant.DIGEST_NOT_SUPPORTED); + } + } +} diff --git a/kernel/src/main/java/com/itextpdf/kernel/mac/IMacContainerLocator.java b/kernel/src/main/java/com/itextpdf/kernel/mac/IMacContainerLocator.java new file mode 100644 index 0000000000..4661aeb8f9 --- /dev/null +++ b/kernel/src/main/java/com/itextpdf/kernel/mac/IMacContainerLocator.java @@ -0,0 +1,73 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.mac; + +import com.itextpdf.kernel.pdf.PdfDictionary; +import com.itextpdf.kernel.pdf.PdfDocument; + +/** + * Strategy interface, which is responsible for {@link AbstractMacIntegrityProtector} container location. + * Expected to be used in {@link com.itextpdf.commons.utils.DIContainer}. + */ +public interface IMacContainerLocator { + /** + * Locates {@link AbstractMacIntegrityProtector} container. + * + * @param macIntegrityProtector {@link AbstractMacIntegrityProtector} container to be located + */ + void locateMacContainer(AbstractMacIntegrityProtector macIntegrityProtector); + + /** + * Indicates, if MAC container was already located. + * + * @return {@code true} if MAC container was already located, {@code false} otherwise + */ + boolean isMacContainerLocated(); + + /** + * Creates {@link AbstractMacIntegrityProtector} from explicitly provided MAC properties. + * + * @param document {@link PdfDocument} for which MAC container shall be created + * @param macProperties {@link MacProperties} to be used for MAC container creation + * + * @return {@link AbstractMacIntegrityProtector} which specific implementation depends on interface implementation. + */ + AbstractMacIntegrityProtector createMacIntegrityProtector(PdfDocument document, MacProperties macProperties); + + /** + * Creates {@link AbstractMacIntegrityProtector} from already existing AuthCode dictionary. + * + * @param document {@link PdfDocument} for which MAC container shall be created + * @param authDictionary AuthCode {@link PdfDictionary} which contains MAC related information + * + * @return {@link AbstractMacIntegrityProtector} which specific implementation depends on interface implementation. + */ + AbstractMacIntegrityProtector createMacIntegrityProtector(PdfDocument document, PdfDictionary authDictionary); + + /** + * Handles MAC validation error. + * + * @param exception {@link MacValidationException} to handle. + */ + void handleMacValidationError(MacValidationException exception); +} diff --git a/kernel/src/main/java/com/itextpdf/kernel/mac/MacContainerReader.java b/kernel/src/main/java/com/itextpdf/kernel/mac/MacContainerReader.java new file mode 100644 index 0000000000..c74afe15f9 --- /dev/null +++ b/kernel/src/main/java/com/itextpdf/kernel/mac/MacContainerReader.java @@ -0,0 +1,128 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.mac; + +import com.itextpdf.bouncycastleconnector.BouncyCastleFactoryCreator; +import com.itextpdf.commons.bouncycastle.IBouncyCastleFactory; +import com.itextpdf.commons.bouncycastle.asn1.IASN1InputStream; +import com.itextpdf.commons.bouncycastle.asn1.IASN1ObjectIdentifier; +import com.itextpdf.commons.bouncycastle.asn1.IASN1OctetString; +import com.itextpdf.commons.bouncycastle.asn1.IASN1Primitive; +import com.itextpdf.commons.bouncycastle.asn1.IASN1Sequence; +import com.itextpdf.commons.bouncycastle.asn1.IASN1Set; +import com.itextpdf.kernel.exceptions.KernelExceptionMessageConstant; +import com.itextpdf.kernel.exceptions.PdfException; +import com.itextpdf.kernel.pdf.PdfDictionary; +import com.itextpdf.kernel.pdf.PdfName; + +import java.io.ByteArrayInputStream; +import java.io.IOException; + +abstract class MacContainerReader { + private static final IBouncyCastleFactory BC_FACTORY = BouncyCastleFactoryCreator.getFactory(); + + private final byte[] macContainer; + private final long[] byteRange; + private final byte[] signature; + + MacContainerReader(PdfDictionary authDictionary) { + this.macContainer = parseMacContainer(authDictionary); + this.byteRange = parseByteRange(authDictionary); + this.signature = parseSignature(authDictionary); + } + + static MacContainerReader getInstance(PdfDictionary authDictionary) { + PdfName macLocation = authDictionary.getAsName(PdfName.MACLocation); + if (PdfName.Standalone.equals(macLocation)) { + return new MacStandaloneContainerReader(authDictionary); + } else if (PdfName.AttachedToSig.equals(macLocation)) { + return new MacSignatureContainerReader(authDictionary); + } + throw new PdfException(KernelExceptionMessageConstant.MAC_LOCATION_NOT_SPECIFIED); + } + + abstract byte[] parseSignature(PdfDictionary authDictionary); + + abstract long[] parseByteRange(PdfDictionary authDictionary); + + abstract byte[] parseMacContainer(PdfDictionary authDictionary); + + long[] getByteRange() { + return byteRange; + } + + byte[] getSignature() { + return signature; + } + + byte[] parseMac() { + IASN1Sequence authDataSequence = getAuthDataSequence(); + return BC_FACTORY.createASN1OctetString(authDataSequence.getObjectAt(6)).getOctets(); + } + + IASN1Set parseAuthAttributes() { + IASN1Sequence authDataSequence = getAuthDataSequence(); + return BC_FACTORY.createASN1Set(BC_FACTORY.createASN1TaggedObject(authDataSequence.getObjectAt(5)), false); + } + + IASN1Sequence parseMessageDigest() { + IASN1Set authAttributes = parseAuthAttributes(); + return BC_FACTORY.createASN1Sequence(authAttributes.getObjectAt(2)); + } + + byte[] parseMacKey() { + IASN1Sequence authDataSequence = getAuthDataSequence(); + IASN1Sequence recInfo = BC_FACTORY.createASN1Sequence(BC_FACTORY.createASN1TaggedObject( + BC_FACTORY.createASN1Set(authDataSequence.getObjectAt(1)).getObjectAt(0)).getObject()); + IASN1OctetString encryptedKey = BC_FACTORY.createASN1OctetString(recInfo.getObjectAt(3)); + + return encryptedKey.getOctets(); + } + + String parseDigestAlgorithm() { + IASN1Sequence authDataSequence = getAuthDataSequence(); + IASN1Primitive digestAlgorithmContainer = + BC_FACTORY.createASN1TaggedObject(authDataSequence.getObjectAt(3)).getObject(); + IASN1ObjectIdentifier digestAlgorithm; + if (BC_FACTORY.createASN1ObjectIdentifier(digestAlgorithmContainer) != null) { + digestAlgorithm = BC_FACTORY.createASN1ObjectIdentifier(digestAlgorithmContainer); + } else { + digestAlgorithm = BC_FACTORY.createASN1ObjectIdentifier( + BC_FACTORY.createASN1Sequence(digestAlgorithmContainer).getObjectAt(0)); + } + + return digestAlgorithm.getId(); + } + + private IASN1Sequence getAuthDataSequence() { + IASN1Sequence contentInfoSequence; + try (IASN1InputStream din = + BC_FACTORY.createASN1InputStream(new ByteArrayInputStream(macContainer))) { + contentInfoSequence = BC_FACTORY.createASN1Sequence(din.readObject()); + } catch (IOException e) { + throw new PdfException(KernelExceptionMessageConstant.CONTAINER_PARSING_EXCEPTION, e); + } + return BC_FACTORY.createASN1Sequence(BC_FACTORY.createASN1TaggedObject( + contentInfoSequence.getObjectAt(1)).getObject()); + } +} diff --git a/kernel/src/main/java/com/itextpdf/kernel/mac/MacPdfObject.java b/kernel/src/main/java/com/itextpdf/kernel/mac/MacPdfObject.java new file mode 100644 index 0000000000..e4676e1957 --- /dev/null +++ b/kernel/src/main/java/com/itextpdf/kernel/mac/MacPdfObject.java @@ -0,0 +1,68 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.mac; + +import com.itextpdf.kernel.pdf.PdfDictionary; +import com.itextpdf.kernel.pdf.PdfLiteral; +import com.itextpdf.kernel.pdf.PdfName; +import com.itextpdf.kernel.pdf.PdfObject; +import com.itextpdf.kernel.pdf.PdfObjectWrapper; + +class MacPdfObject extends PdfObjectWrapper { + MacPdfObject(int macContainerSize) { + super(new PdfDictionary()); + PdfLiteral macPlaceholder = new PdfLiteral(macContainerSize); + PdfLiteral byteRangePlaceholder = new PdfLiteral(80); + + getPdfObject().put(PdfName.MACLocation, PdfName.Standalone); + getPdfObject().put(PdfName.MAC, macPlaceholder); + getPdfObject().put(PdfName.ByteRange, byteRangePlaceholder); + } + + long[] computeByteRange(long totalLength) { + PdfLiteral macPlaceholder = getMacPlaceholder(); + long macStart = macPlaceholder.getPosition(); + long macLength = macPlaceholder.getBytesCount(); + long macEnd = macStart + macLength; + return new long[] {0, macStart, macEnd, totalLength - macEnd}; + } + + long getByteRangePosition() { + return getByteRangePlaceholder().getPosition(); + } + + private PdfLiteral getMacPlaceholder() { + PdfObject mac = getPdfObject().get(PdfName.MAC); + return (PdfLiteral) mac; + } + + private PdfLiteral getByteRangePlaceholder() { + PdfObject br = getPdfObject().get(PdfName.ByteRange); + return (PdfLiteral) br; + } + + @Override + protected boolean isWrappedObjectMustBeIndirect() { + return false; + } +} diff --git a/kernel/src/main/java/com/itextpdf/kernel/mac/MacProperties.java b/kernel/src/main/java/com/itextpdf/kernel/mac/MacProperties.java new file mode 100644 index 0000000000..24710ff9bc --- /dev/null +++ b/kernel/src/main/java/com/itextpdf/kernel/mac/MacProperties.java @@ -0,0 +1,129 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.mac; + +/** + * Class which contains configurable properties for MAC integrity protection mechanism. + */ +public class MacProperties { + private final MacDigestAlgorithm macDigestAlgorithm; + private final MacAlgorithm macAlgorithm; + private final KeyWrappingAlgorithm keyWrappingAlgorithm; + + /** + * Creates {@link MacProperties} class containing provided {@link MacDigestAlgorithm}. + * For other properties default values are used. + * + * @param macDigestAlgorithm {@link MacDigestAlgorithm} to be used in MAC integrity protection algorithm + */ + public MacProperties(MacDigestAlgorithm macDigestAlgorithm) { + this(macDigestAlgorithm, MacAlgorithm.HMAC_WITH_SHA_256, KeyWrappingAlgorithm.AES_256_NO_PADD); + } + + /** + * Creates {@link MacProperties} class containing provided properties. + * + * @param macDigestAlgorithm {@link MacDigestAlgorithm} to be used in MAC integrity protection algorithm + * @param macAlgorithm {@link MacAlgorithm} to be used in MAC integrity protection algorithm + * @param keyWrappingAlgorithm {@link KeyWrappingAlgorithm} to be used in MAC integrity protection algorithm + */ + public MacProperties(MacDigestAlgorithm macDigestAlgorithm, MacAlgorithm macAlgorithm, + KeyWrappingAlgorithm keyWrappingAlgorithm) { + this.macDigestAlgorithm = macDigestAlgorithm; + this.macAlgorithm = macAlgorithm; + this.keyWrappingAlgorithm = keyWrappingAlgorithm; + } + + /** + * Gets {@link MacDigestAlgorithm} to be used in MAC integrity protection algorithm. + * + * @return {@link MacDigestAlgorithm} to be used in MAC integrity protection algorithm + */ + public MacDigestAlgorithm getMacDigestAlgorithm() { + return macDigestAlgorithm; + } + + /** + * Gets {@link MacAlgorithm} to be used in MAC integrity protection algorithm. + * + * @return {@link MacAlgorithm} to be used in MAC integrity protection algorithm + */ + public MacAlgorithm getMacAlgorithm() { + return macAlgorithm; + } + + /** + * Gets {@link KeyWrappingAlgorithm} to be used in MAC integrity protection algorithm. + * + * @return {@link KeyWrappingAlgorithm} to be used in MAC integrity protection algorithm + */ + public KeyWrappingAlgorithm getKeyWrappingAlgorithm() { + return keyWrappingAlgorithm; + } + + /** + * Message digest algorithms, which can be used in MAC integrity protection algorithm. + */ + public enum MacDigestAlgorithm { + SHA_256, + SHA_384, + SHA_512, + SHA3_256, + SHA3_384, + SHA3_512; + } + + // We can't use here enum with fields, because .NET doesn't support it, and enum + // will be ported to class, and EnumUtil.getAllValuesOfEnum won't work with class + public static String macDigestAlgorithmToString(MacDigestAlgorithm macDigestAlgorithm) { + switch (macDigestAlgorithm) { + case SHA_256: + return "SHA256"; + case SHA_384: + return "SHA384"; + case SHA_512: + return "SHA512"; + case SHA3_256: + return "SHA3-256"; + case SHA3_384: + return "SHA3-384"; + case SHA3_512: + return "SHA3-512"; + } + return null; + } + + /** + * MAC algorithms, which can be used during integrity protection operation. + */ + public enum MacAlgorithm { + HMAC_WITH_SHA_256 + } + + /** + * Key wrapping algorithms, which can be used in MAC integrity protection algorithm. + */ + public enum KeyWrappingAlgorithm { + AES_256_NO_PADD + } +} diff --git a/kernel/src/main/java/com/itextpdf/kernel/mac/MacSignatureContainerReader.java b/kernel/src/main/java/com/itextpdf/kernel/mac/MacSignatureContainerReader.java new file mode 100644 index 0000000000..b870e19f4b --- /dev/null +++ b/kernel/src/main/java/com/itextpdf/kernel/mac/MacSignatureContainerReader.java @@ -0,0 +1,141 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.mac; + +import com.itextpdf.bouncycastleconnector.BouncyCastleFactoryCreator; +import com.itextpdf.commons.bouncycastle.IBouncyCastleFactory; +import com.itextpdf.commons.bouncycastle.asn1.IASN1InputStream; +import com.itextpdf.commons.bouncycastle.asn1.IASN1ObjectIdentifier; +import com.itextpdf.commons.bouncycastle.asn1.IASN1Sequence; +import com.itextpdf.commons.bouncycastle.asn1.IASN1Set; +import com.itextpdf.commons.bouncycastle.asn1.IASN1TaggedObject; +import com.itextpdf.commons.bouncycastle.asn1.IDEROctetString; +import com.itextpdf.kernel.exceptions.KernelExceptionMessageConstant; +import com.itextpdf.kernel.exceptions.PdfException; +import com.itextpdf.kernel.pdf.PdfDictionary; +import com.itextpdf.kernel.pdf.PdfName; +import com.itextpdf.kernel.pdf.PdfString; + +import java.io.ByteArrayInputStream; +import java.io.IOException; + +class MacSignatureContainerReader extends MacContainerReader { + private static final IBouncyCastleFactory BC_FACTORY = BouncyCastleFactoryCreator.getFactory(); + private static final String ID_ATTR_PDF_MAC_DATA = "1.0.32004.1.2"; + + MacSignatureContainerReader(PdfDictionary authDictionary) { + super(authDictionary); + } + + @Override + byte[] parseSignature(PdfDictionary authDictionary) { + PdfDictionary signatureDictionary = getSignatureDictionary(authDictionary); + PdfString contentsString = signatureDictionary.getAsString(PdfName.Contents); + contentsString.markAsUnencryptedObject(); + return parseSignatureValueFromSignatureContainer(contentsString.getValueBytes()); + } + + @Override + long[] parseByteRange(PdfDictionary authDictionary) { + PdfDictionary signatureDictionary = getSignatureDictionary(authDictionary); + return signatureDictionary.getAsArray(PdfName.ByteRange).toLongArray(); + } + + @Override + byte[] parseMacContainer(PdfDictionary authDictionary) { + PdfDictionary signatureDictionary = getSignatureDictionary(authDictionary); + PdfString contentsString = signatureDictionary.getAsString(PdfName.Contents); + contentsString.markAsUnencryptedObject(); + return parseMacContainerFromSignatureContainer(contentsString.getValueBytes()); + } + + private static byte[] parseSignatureValueFromSignatureContainer(byte[] signature) { + try { + IASN1Sequence signerInfoSeq = parseSignerInfoSequence(signature); + + int signatureValueIndex = 3; + IASN1TaggedObject taggedSignedAttributes = + BC_FACTORY.createASN1TaggedObject(signerInfoSeq.getObjectAt(signatureValueIndex)); + if (taggedSignedAttributes != null) { + ++signatureValueIndex; + } + IDEROctetString signatureDataOS = BC_FACTORY.createDEROctetString( + signerInfoSeq.getObjectAt(++signatureValueIndex)); + return signatureDataOS.getOctets(); + } catch (Exception e) { + throw new PdfException(KernelExceptionMessageConstant.MAC_EXTRACTION_EXCEPTION, e); + } + } + + private static byte[] parseMacContainerFromSignatureContainer(byte[] signature) { + try { + IASN1Sequence signerInfoSeq = parseSignerInfoSequence(signature); + + int unsignedAttributesIndex = 3; + IASN1TaggedObject taggedSignedAttributes = + BC_FACTORY.createASN1TaggedObject(signerInfoSeq.getObjectAt(unsignedAttributesIndex)); + if (taggedSignedAttributes != null) { + ++unsignedAttributesIndex; + } + unsignedAttributesIndex += 2; + if (signerInfoSeq.size() > unsignedAttributesIndex) { + IASN1Set unsignedAttributes = BC_FACTORY.createASN1Set(BC_FACTORY.createASN1TaggedObject( + signerInfoSeq.getObjectAt(unsignedAttributesIndex)), false); + for (int i = 0; i < unsignedAttributes.size(); i++) { + IASN1Sequence attrSeq = BC_FACTORY.createASN1Sequence(unsignedAttributes.getObjectAt(i)); + IASN1ObjectIdentifier attrType = BC_FACTORY.createASN1ObjectIdentifier(attrSeq.getObjectAt(0)); + if (ID_ATTR_PDF_MAC_DATA.equals(attrType.getId())) { + IASN1Set macSet = BC_FACTORY.createASN1Set(attrSeq.getObjectAt(1)); + return macSet.getObjectAt(0).toASN1Primitive().getEncoded(); + } + } + } + } catch (Exception e) { + throw new PdfException(KernelExceptionMessageConstant.MAC_EXTRACTION_EXCEPTION, e); + } + throw new PdfException(KernelExceptionMessageConstant.MAC_ATTRIBUTE_NOT_SPECIFIED); + } + + private static PdfDictionary getSignatureDictionary(PdfDictionary authDictionary) { + if (authDictionary.getAsDictionary(PdfName.SigObjRef) == null) { + throw new PdfException(KernelExceptionMessageConstant.SIG_OBJ_REF_NOT_SPECIFIED); + } + return authDictionary.getAsDictionary(PdfName.SigObjRef); + } + + private static IASN1Sequence parseSignerInfoSequence(byte[] signature) throws IOException { + try (IASN1InputStream is = BC_FACTORY.createASN1InputStream(new ByteArrayInputStream(signature))) { + IASN1Sequence contentInfo = BC_FACTORY.createASN1Sequence(is.readObject()); + IASN1Sequence signedData = BC_FACTORY.createASN1Sequence( + BC_FACTORY.createASN1TaggedObject(contentInfo.getObjectAt(1)).getObject()); + + int signerInfoIndex = 4; + IASN1TaggedObject taggedObj = BC_FACTORY.createASN1TaggedObject(signedData.getObjectAt(signerInfoIndex)); + if (taggedObj != null) { + ++signerInfoIndex; + } + return BC_FACTORY.createASN1Sequence(BC_FACTORY.createASN1Set( + signedData.getObjectAt(signerInfoIndex)).getObjectAt(0)); + } + } +} diff --git a/kernel/src/main/java/com/itextpdf/kernel/mac/MacStandaloneContainerReader.java b/kernel/src/main/java/com/itextpdf/kernel/mac/MacStandaloneContainerReader.java new file mode 100644 index 0000000000..3470d42e00 --- /dev/null +++ b/kernel/src/main/java/com/itextpdf/kernel/mac/MacStandaloneContainerReader.java @@ -0,0 +1,52 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.mac; + +import com.itextpdf.kernel.exceptions.KernelExceptionMessageConstant; +import com.itextpdf.kernel.exceptions.PdfException; +import com.itextpdf.kernel.pdf.PdfDictionary; +import com.itextpdf.kernel.pdf.PdfName; + +class MacStandaloneContainerReader extends MacContainerReader { + MacStandaloneContainerReader(PdfDictionary authDictionary) { + super(authDictionary); + } + + @Override + byte[] parseSignature(PdfDictionary authDictionary) { + return null; + } + + @Override + long[] parseByteRange(PdfDictionary authDictionary) { + return authDictionary.getAsArray(PdfName.ByteRange).toLongArray(); + } + + @Override + byte[] parseMacContainer(PdfDictionary authDictionary) { + if (authDictionary.getAsString(PdfName.MAC) == null) { + throw new PdfException(KernelExceptionMessageConstant.MAC_NOT_SPECIFIED); + } + return authDictionary.getAsString(PdfName.MAC).getValueBytes(); + } +} diff --git a/kernel/src/main/java/com/itextpdf/kernel/mac/MacValidationException.java b/kernel/src/main/java/com/itextpdf/kernel/mac/MacValidationException.java new file mode 100644 index 0000000000..4cd039b224 --- /dev/null +++ b/kernel/src/main/java/com/itextpdf/kernel/mac/MacValidationException.java @@ -0,0 +1,50 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.mac; + +import com.itextpdf.kernel.exceptions.PdfException; + +/** + * Exception class for MAC validation errors. + */ +public class MacValidationException extends PdfException { + + /** + * Creates a new instance of {@link MacValidationException}. + * + * @param message the exception message + */ + public MacValidationException(String message) { + super(message); + } + + /** + * Creates a new instance of{@link MacValidationException}. + * + * @param message the exception message + * @param cause the cause (which is saved for later retrieval by {@link #getCause()} method) + */ + public MacValidationException(String message, Throwable cause) { + super(message, cause); + } +} diff --git a/kernel/src/main/java/com/itextpdf/kernel/mac/StandaloneMacContainerLocator.java b/kernel/src/main/java/com/itextpdf/kernel/mac/StandaloneMacContainerLocator.java new file mode 100644 index 0000000000..65749663f4 --- /dev/null +++ b/kernel/src/main/java/com/itextpdf/kernel/mac/StandaloneMacContainerLocator.java @@ -0,0 +1,76 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.mac; + +import com.itextpdf.kernel.pdf.PdfDictionary; +import com.itextpdf.kernel.pdf.PdfDocument; + +/** + * Default {@link AbstractMacIntegrityProtector} location strategy, which locates MAC container in document's trailer. + */ +public class StandaloneMacContainerLocator implements IMacContainerLocator { + private boolean macContainerLocated = false; + + /** + * {@inheritDoc}. + */ + @Override + public void locateMacContainer(AbstractMacIntegrityProtector macIntegrityProtector) { + ((StandaloneMacIntegrityProtector) macIntegrityProtector).prepareDocument(); + macContainerLocated = true; + } + + /** + * {@inheritDoc}. + */ + @Override + public boolean isMacContainerLocated() { + return macContainerLocated; + } + + /** + * {@inheritDoc}. + */ + @Override + public AbstractMacIntegrityProtector createMacIntegrityProtector(PdfDocument document, + MacProperties macProperties) { + return new StandaloneMacIntegrityProtector(document, macProperties); + } + + /** + * {@inheritDoc}. + */ + @Override + public AbstractMacIntegrityProtector createMacIntegrityProtector(PdfDocument document, + PdfDictionary authDictionary) { + return new StandaloneMacIntegrityProtector(document, authDictionary); + } + + /** + * {@inheritDoc} + */ + @Override + public void handleMacValidationError(MacValidationException exception) { + throw exception; + } +} diff --git a/kernel/src/main/java/com/itextpdf/kernel/mac/StandaloneMacIntegrityProtector.java b/kernel/src/main/java/com/itextpdf/kernel/mac/StandaloneMacIntegrityProtector.java new file mode 100644 index 0000000000..40c03654ac --- /dev/null +++ b/kernel/src/main/java/com/itextpdf/kernel/mac/StandaloneMacIntegrityProtector.java @@ -0,0 +1,131 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.mac; + +import com.itextpdf.io.source.IRandomAccessSource; +import com.itextpdf.io.source.RASInputStream; +import com.itextpdf.io.source.RandomAccessSourceFactory; +import com.itextpdf.kernel.pdf.event.AbstractPdfDocumentEventHandler; +import com.itextpdf.kernel.pdf.event.AbstractPdfDocumentEvent; +import com.itextpdf.kernel.pdf.event.PdfDocumentEvent; +import com.itextpdf.kernel.exceptions.KernelExceptionMessageConstant; +import com.itextpdf.kernel.exceptions.PdfException; +import com.itextpdf.kernel.pdf.PdfDictionary; +import com.itextpdf.kernel.pdf.PdfDocument; +import com.itextpdf.kernel.pdf.PdfName; +import com.itextpdf.kernel.pdf.PdfOutputStream; +import com.itextpdf.kernel.pdf.PdfString; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.security.GeneralSecurityException; + +/** + * Class responsible for integrity protection in encrypted documents, which uses MAC container in the standalone mode. + */ +class StandaloneMacIntegrityProtector extends AbstractMacIntegrityProtector { + private MacPdfObject macPdfObject; + + StandaloneMacIntegrityProtector(PdfDocument document, MacProperties macProperties) { + super(document, macProperties); + } + + StandaloneMacIntegrityProtector(PdfDocument document, PdfDictionary authDictionary) { + super(document, authDictionary); + } + + void prepareDocument() { + document.addEventHandler(PdfDocumentEvent.START_DOCUMENT_CLOSING, + new StandaloneMacIntegrityProtector.StandaloneMacPdfObjectAdder()); + document.addEventHandler(PdfDocumentEvent.START_WRITER_CLOSING, + new StandaloneMacIntegrityProtector.StandaloneMacContainerEmbedder()); + } + + private void embedMacContainerInTrailer() throws IOException { + byte[] documentBytes = getDocumentByteArrayOutputStream().toByteArray(); + long[] byteRange = macPdfObject.computeByteRange(documentBytes.length); + + long byteRangePosition = macPdfObject.getByteRangePosition(); + ByteArrayOutputStream localBaos = new ByteArrayOutputStream(); + PdfOutputStream os = new PdfOutputStream(localBaos); + os.write('['); + for (long l : byteRange) { + os.writeLong(l).write(' '); + } + os.write(']'); + System.arraycopy(localBaos.toByteArray(), 0, documentBytes, (int) byteRangePosition, localBaos.size()); + + byte[] mac = createDocumentDigestAndMacContainer(documentBytes, byteRange); + PdfString macString = new PdfString(mac).setHexWriting(true); + + // fill in the MAC + localBaos.reset(); + os.write(macString); + System.arraycopy(localBaos.toByteArray(), 0, documentBytes, (int) byteRange[1], localBaos.size()); + getDocumentByteArrayOutputStream().reset(); + document.getWriter().getOutputStream().write(documentBytes, 0, documentBytes.length); + } + + private byte[] createDocumentDigestAndMacContainer(byte[] documentBytes, long[] byteRange) throws IOException { + IRandomAccessSource ras = new RandomAccessSourceFactory().createSource(documentBytes); + try (InputStream rg = new RASInputStream(new RandomAccessSourceFactory().createRanged(ras, byteRange))) { + byte[] dataDigest = digestBytes(rg); + return createMacContainer(dataDigest, generateRandomBytes(32), null).getEncoded(); + } catch (GeneralSecurityException e) { + throw new PdfException(KernelExceptionMessageConstant.CONTAINER_GENERATION_EXCEPTION, e); + } + } + + private int getContainerSizeEstimate() { + try { + return createMacContainer(digestBytes(new byte[0]), generateRandomBytes(32), null) + .getEncoded().length * 2 + 2; + } catch (GeneralSecurityException | IOException e) { + throw new PdfException(KernelExceptionMessageConstant.CONTAINER_GENERATION_EXCEPTION, e); + } + } + + private ByteArrayOutputStream getDocumentByteArrayOutputStream() { + return ((ByteArrayOutputStream) document.getWriter().getOutputStream()); + } + + private final class StandaloneMacPdfObjectAdder extends AbstractPdfDocumentEventHandler { + @Override + public void onAcceptedEvent(AbstractPdfDocumentEvent event) { + macPdfObject = new MacPdfObject(getContainerSizeEstimate()); + document.getTrailer().put(PdfName.AuthCode, macPdfObject.getPdfObject()); + } + } + + private final class StandaloneMacContainerEmbedder extends AbstractPdfDocumentEventHandler { + @Override + public void onAcceptedEvent(AbstractPdfDocumentEvent event) { + try { + embedMacContainerInTrailer(); + } catch (IOException e) { + throw new PdfException(KernelExceptionMessageConstant.CONTAINER_EMBEDDING_EXCEPTION, e); + } + } + } +} diff --git a/kernel/src/main/java/com/itextpdf/kernel/numbering/RomanNumbering.java b/kernel/src/main/java/com/itextpdf/kernel/numbering/RomanNumbering.java index 45787d1362..e8ccfafa63 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/numbering/RomanNumbering.java +++ b/kernel/src/main/java/com/itextpdf/kernel/numbering/RomanNumbering.java @@ -103,9 +103,9 @@ protected static String convert(int index) { // loop over the array with values for m-d-c-l-x-v-i RomanDigit dig = ROMAN_DIGITS[pos]; // adding as many digits as we can - while (index >= dig.value) { - buf.append(dig.digit); - index -= dig.value; + while (index >= dig.getValue()) { + buf.append(dig.getDigit()); + index -= dig.getValue(); } // we have the complete number if (index <= 0) { @@ -113,12 +113,12 @@ protected static String convert(int index) { } // look for the next digit that can be used in a special way int j = pos; - while (!ROMAN_DIGITS[++j].pre) ; + while (!ROMAN_DIGITS[++j].isPre()) ; // does the special notation apply? - if (index + ROMAN_DIGITS[j].value >= dig.value) { - buf.append(ROMAN_DIGITS[j].digit).append(dig.digit); - index -= dig.value - ROMAN_DIGITS[j].value; + if (index + ROMAN_DIGITS[j].getValue() >= dig.getValue()) { + buf.append(ROMAN_DIGITS[j].getDigit()).append(dig.getDigit()); + index -= dig.getValue() - ROMAN_DIGITS[j].getValue(); } pos++; } @@ -133,17 +133,17 @@ private static class RomanDigit { /** * part of a roman number */ - public char digit; + private final char digit; /** * value of the roman digit */ - public int value; + private final int value; /** * can the digit be used as a prefix */ - public boolean pre; + private final boolean pre; /** * Constructs a roman digit @@ -157,5 +157,32 @@ private static class RomanDigit { this.value = value; this.pre = pre; } + + /** + * Retrieves the roman digit. + * + * @return roman digit + */ + public char getDigit() { + return digit; + } + + /** + * Retrieves the value of the roman digit. + * + * @return value + */ + public int getValue() { + return value; + } + + /** + * Retrieves whether the roman digit can be used as prefix. + * + * @return true if it can, false otherwise + */ + public boolean isPre() { + return pre; + } } } diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/DefaultFontStrategy.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/DefaultFontStrategy.java new file mode 100644 index 0000000000..a999b92fc1 --- /dev/null +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/DefaultFontStrategy.java @@ -0,0 +1,71 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.pdf; + +import com.itextpdf.io.logs.IoLogMessageConstant; +import com.itextpdf.kernel.font.PdfFont; +import com.itextpdf.kernel.font.PdfFontFactory; + +import java.io.IOException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * The class defines a default font strategy for {@link PdfDocument} + * which is used in the scope of {@link PdfDocument#getDefaultFont()}. + */ +public class DefaultFontStrategy { + private final PdfDocument pdfDocument; + private PdfFont defaultFont = null; + + /** + * Instantiates a new instance of {@link DefaultFontStrategy} which + * will be used for passed {@link PdfDocument} instance. + * + * @param pdfDocument the pdf document for which the strategy will be used to + */ + public DefaultFontStrategy(PdfDocument pdfDocument) { + this.pdfDocument = pdfDocument; + } + + /** + * Gets default font. + * + * @return the {@link PdfFont} instance + */ + public PdfFont getFont() { + if (defaultFont == null) { + try { + defaultFont = PdfFontFactory.createFont(); + if (pdfDocument.getWriter() != null) { + defaultFont.makeIndirect(pdfDocument); + } + } catch (IOException e) { + Logger logger = LoggerFactory.getLogger(DefaultFontStrategy.class); + logger.error(IoLogMessageConstant.EXCEPTION_WHILE_CREATING_DEFAULT_FONT, e); + defaultFont = null; + } + } + return defaultFont; + } +} diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/DocumentInfoHelper.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/DocumentInfoHelper.java new file mode 100644 index 0000000000..9d917d698d --- /dev/null +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/DocumentInfoHelper.java @@ -0,0 +1,47 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.pdf; + +/** + * The class is helper which used inside {@link PdfDocument} to properly configure PDF document's info dictionary. + */ +public class DocumentInfoHelper { + /** + * If document info dictionary should be added to the trailer. + * + * @return {@code true} if should be added, otherwise {@code false} + */ + public boolean shouldAddDocumentInfoToTrailer() { + return true; + } + + /** + * Adjusts document info before it's flushing and adding to the trailer + * if required, see {@link #shouldAddDocumentInfoToTrailer()}. + * + * @param documentInfo the {@link PdfDocumentInfo} instance to adjust + */ + public void adjustDocumentInfo(PdfDocumentInfo documentInfo) { + // do nothing + } +} diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/DocumentProperties.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/DocumentProperties.java index 4ad138cb7a..9edd84b1d3 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/pdf/DocumentProperties.java +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/DocumentProperties.java @@ -23,6 +23,9 @@ This file is part of the iText (R) project. package com.itextpdf.kernel.pdf; import com.itextpdf.commons.actions.contexts.IMetaInfo; +import com.itextpdf.kernel.exceptions.KernelExceptionMessageConstant; + +import java.util.HashMap; /** * Class with additional properties for {@link PdfDocument} processing. @@ -33,6 +36,8 @@ public class DocumentProperties { protected IMetaInfo metaInfo = null; + HashMap, Object> dependencies = new HashMap<>(); + /** * Default constructor, use provided setters for configuration options. */ @@ -67,4 +72,22 @@ public DocumentProperties setEventCountingMetaInfo(IMetaInfo metaInfo) { public boolean isEventCountingMetaInfoSet() { return this.metaInfo != null; } + + /** + * Register custom dependency for the document. + * + * @param clazz Type of the dependency. + * @param instance The instance of the dependency. + * @return this {@link DocumentProperties} instance + */ + public DocumentProperties registerDependency(Class clazz, Object instance) { + if (clazz == null) { + throw new IllegalArgumentException(KernelExceptionMessageConstant.TYPE_SHOULD_NOT_BE_NULL); + } + if (instance == null) { + throw new IllegalArgumentException(KernelExceptionMessageConstant.INSTANCE_SHOULD_NOT_BE_NULL); + } + dependencies.put(clazz, instance); + return this; + } } diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/EncryptionConstants.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/EncryptionConstants.java index 0989efd35d..62602f38a7 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/pdf/EncryptionConstants.java +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/EncryptionConstants.java @@ -46,6 +46,10 @@ private EncryptionConstants() { * Type of encryption. AES encryption algorithm will be used with the key length of 256 bits. */ public static final int ENCRYPTION_AES_256 = 3; + /** + * Type of encryption. Advanced Encryption Standard-Galois/Counter Mode (AES-GCM) encryption algorithm. + */ + public static final int ENCRYPTION_AES_GCM = 4; /** * Add this to the mode to keep the metadata in clear text. */ diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/EncryptionProperties.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/EncryptionProperties.java index a94d283dd6..d3cb4111b9 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/pdf/EncryptionProperties.java +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/EncryptionProperties.java @@ -22,6 +22,9 @@ This file is part of the iText (R) project. */ package com.itextpdf.kernel.pdf; +import com.itextpdf.kernel.mac.MacProperties; +import com.itextpdf.kernel.mac.MacProperties.MacDigestAlgorithm; + import java.security.SecureRandom; import java.security.cert.Certificate; @@ -42,6 +45,13 @@ public class EncryptionProperties { protected Certificate[] publicCertificates; protected int[] publicKeyEncryptPermissions; + /** + * {@link MacProperties} class to configure MAC integrity protection properties. + */ + protected MacProperties macProperties; + + static final MacProperties DEFAULT_MAC_PROPERTIES = new MacProperties(MacDigestAlgorithm.SHA3_512); + /** * Sets the encryption options for the document. * @@ -78,6 +88,48 @@ public class EncryptionProperties { */ public EncryptionProperties setStandardEncryption(byte[] userPassword, byte[] ownerPassword, int permissions, int encryptionAlgorithm) { + return setStandardEncryption(userPassword, ownerPassword, permissions, encryptionAlgorithm, + DEFAULT_MAC_PROPERTIES); + } + + /** + * Sets the encryption options for the document. + * + * @param userPassword the user password. Can be null or of zero length, which is equal to + * omitting the user password + * @param ownerPassword the owner password. If it's null or empty, iText will generate + * a random string to be used as the owner password + * @param permissions the user permissions. The open permissions for the document can be + * {@link EncryptionConstants#ALLOW_PRINTING}, + * {@link EncryptionConstants#ALLOW_MODIFY_CONTENTS}, + * {@link EncryptionConstants#ALLOW_COPY}, + * {@link EncryptionConstants#ALLOW_MODIFY_ANNOTATIONS}, + * {@link EncryptionConstants#ALLOW_FILL_IN}, + * {@link EncryptionConstants#ALLOW_SCREENREADERS}, + * {@link EncryptionConstants#ALLOW_ASSEMBLY} and + * {@link EncryptionConstants#ALLOW_DEGRADED_PRINTING}. + * The permissions can be combined by ORing them + * @param encryptionAlgorithm the type of encryption. It can be one of + * {@link EncryptionConstants#STANDARD_ENCRYPTION_40}, + * {@link EncryptionConstants#STANDARD_ENCRYPTION_128}, + * {@link EncryptionConstants#ENCRYPTION_AES_128} or + * {@link EncryptionConstants#ENCRYPTION_AES_256}. + * Optionally {@link EncryptionConstants#DO_NOT_ENCRYPT_METADATA} can be OEed + * to output the metadata in cleartext. + * {@link EncryptionConstants#EMBEDDED_FILES_ONLY} can be ORed as well. + * Please be aware that the passed encryption types may override permissions: + * {@link EncryptionConstants#STANDARD_ENCRYPTION_40} implicitly sets + * {@link EncryptionConstants#DO_NOT_ENCRYPT_METADATA} and + * {@link EncryptionConstants#EMBEDDED_FILES_ONLY} as false; + * {@link EncryptionConstants#STANDARD_ENCRYPTION_128} implicitly sets + * {@link EncryptionConstants#EMBEDDED_FILES_ONLY} as false; + * @param macProperties {@link MacProperties} class to configure MAC integrity protection properties. + * Pass {@code null} if you want to disable MAC protection for any reason + * + * @return this {@link EncryptionProperties} + */ + public EncryptionProperties setStandardEncryption(byte[] userPassword, byte[] ownerPassword, int permissions, + int encryptionAlgorithm, MacProperties macProperties) { clearEncryption(); this.userPassword = userPassword; if (ownerPassword != null) { @@ -88,6 +140,7 @@ public EncryptionProperties setStandardEncryption(byte[] userPassword, byte[] ow } this.standardEncryptPermissions = permissions; this.encryptionAlgorithm = encryptionAlgorithm; + this.macProperties = macProperties; return this; } @@ -124,14 +177,18 @@ public EncryptionProperties setStandardEncryption(byte[] userPassword, byte[] ow * {@link EncryptionConstants#EMBEDDED_FILES_ONLY} as false; * {@link EncryptionConstants#STANDARD_ENCRYPTION_128} implicitly sets * {@link EncryptionConstants#EMBEDDED_FILES_ONLY} as false; + * @param macProperties {@link MacProperties} class to configure MAC integrity protection properties. + * Pass {@code null} if you want to disable MAC protection for any reason + * * @return this {@link EncryptionProperties} */ public EncryptionProperties setPublicKeyEncryption(Certificate[] certs, int[] permissions, - int encryptionAlgorithm) { + int encryptionAlgorithm, MacProperties macProperties) { clearEncryption(); this.publicCertificates = certs; this.publicKeyEncryptPermissions = permissions; this.encryptionAlgorithm = encryptionAlgorithm; + this.macProperties = macProperties; return this; } @@ -149,6 +206,7 @@ private void clearEncryption() { this.publicKeyEncryptPermissions = null; this.userPassword = null; this.ownerPassword = null; + this.macProperties = null; } private static void randomBytes(byte[] bytes) { diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/FingerPrint.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/FingerPrint.java index 64410f3184..5492564729 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/pdf/FingerPrint.java +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/FingerPrint.java @@ -26,19 +26,19 @@ This file is part of the iText (R) project. import java.util.Collection; import java.util.Collections; -import java.util.HashSet; import java.util.LinkedHashSet; import java.util.Set; /** * Data container for debugging information. This class keeps a record of every registered product that - * was involved in the creation of a certain PDF file. This information can then be used to log to the - * logger or to the file. + * was involved in the creation of a certain PDF file. */ public class FingerPrint { private Set productDataSet; + private boolean fingerPrintEnabled = true; + /** * Default constructor. Initializes the productDataSet. */ @@ -46,6 +46,24 @@ public FingerPrint() { this.productDataSet = new LinkedHashSet<>(); } + /** + * This method is used to disable iText fingerprint. + * IText fingerPrint can only be disabled if all products are in non AGPL mode. + * + */ + public void disableFingerPrint() { + fingerPrintEnabled = false; + } + + /** + * This method is used to check iText fingerprint state. + * + * @return true if fingerprint will be added to the document + */ + public boolean isFingerPrintEnabled() { + return fingerPrintEnabled; + } + /** * Registers a product to be added to the fingerprint or other debugging info. * diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/MemoryLimitsAwareHandler.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/MemoryLimitsAwareHandler.java index 55dad5559d..b1199635ad 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/pdf/MemoryLimitsAwareHandler.java +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/MemoryLimitsAwareHandler.java @@ -24,8 +24,11 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.exceptions.KernelExceptionMessageConstant; import com.itextpdf.kernel.exceptions.MemoryLimitsAwareException; +import com.itextpdf.kernel.logs.KernelLogMessageConstant; import java.util.HashSet; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * A {@link MemoryLimitsAwareHandler} handles memory allocation and prevents decompressed @@ -38,6 +41,7 @@ This file is part of the iText (R) project. */ public class MemoryLimitsAwareHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(MemoryLimitsAwareHandler.class); private static final int SINGLE_SCALE_COEFFICIENT = 100; private static final int SUM_SCALE_COEFFICIENT = 500; @@ -88,6 +92,25 @@ private MemoryLimitsAwareHandler(int maxSizeOfSingleDecompressedPdfStream, long this.maxXObjectsSizePerPage = maxXObjectsSizePerPage; } + /** + * Creates a new instance of {@link MemoryLimitsAwareHandler} by copying settings from this instance + * of {@link MemoryLimitsAwareHandler}. + * + * @return a new instance of {@link MemoryLimitsAwareHandler}. + */ + public MemoryLimitsAwareHandler createNewInstance() { + MemoryLimitsAwareHandler to = new MemoryLimitsAwareHandler(); + to.maxSizeOfSingleDecompressedPdfStream = this.maxSizeOfSingleDecompressedPdfStream; + to.maxSizeOfDecompressedPdfStreamsSum = this.maxSizeOfDecompressedPdfStreamsSum; + to.maxNumberOfElementsInXrefStructure = this.maxNumberOfElementsInXrefStructure; + to.maxXObjectsSizePerPage = this.maxXObjectsSizePerPage; + if (this.getClass() != MemoryLimitsAwareHandler.class) { + LOGGER.warn(KernelLogMessageConstant.MEMORYLIMITAWAREHANDLER_OVERRIDE_CREATENEWINSTANCE_METHOD); + } + + return to; + } + /** * Gets the maximum allowed size which can be occupied by a single decompressed pdf stream. * diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/OcgPropertiesCopier.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/OcgPropertiesCopier.java index b95caccf19..0a3cd1b6ed 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/pdf/OcgPropertiesCopier.java +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/OcgPropertiesCopier.java @@ -46,32 +46,59 @@ private OcgPropertiesCopier() { // Empty constructor } - public static void copyOCGProperties(PdfDocument fromDocument, PdfDocument toDocument, Map page2page) { + /** + * Copy unique page OCGs stored inside annotations/xobjects/resources from source pages to destination pages. + * + * @param sourceDocument document from which OCGs should be copied + * @param destinationDocument document to which OCGs should be copied + * @param sourceToDestPageMapping page mapping, linking source pages to destination ones + */ + public static void copyOCGProperties(PdfDocument sourceDocument, PdfDocument destinationDocument, + Map sourceToDestPageMapping) { try { // Configs are not copied - - PdfDictionary toOcProperties = toDocument.getCatalog().getPdfObject().getAsDictionary(PdfName.OCProperties); - final Set fromOcgsToCopy = OcgPropertiesCopier - .getAllUsedNonFlushedOCGs(page2page, toOcProperties); - if (fromOcgsToCopy.isEmpty()) { + PdfDictionary toOcProperties = destinationDocument.getCatalog().getPdfObject().getAsDictionary(PdfName.OCProperties); + final Set ocgsToCopy = OcgPropertiesCopier + .getAllUsedNonFlushedOCGs(sourceToDestPageMapping, toOcProperties); + if (ocgsToCopy.isEmpty()) { return; } // Reset ocProperties field in order to create it a new at the // method end using the new (merged) OCProperties dictionary - toOcProperties = toDocument.getCatalog().fillAndGetOcPropertiesDictionary(); - final PdfDictionary fromOcProperties = fromDocument.getCatalog().getPdfObject() + toOcProperties = destinationDocument.getCatalog().fillAndGetOcPropertiesDictionary(); + final PdfDictionary fromOcProperties = sourceDocument.getCatalog().getPdfObject() .getAsDictionary(PdfName.OCProperties); - OcgPropertiesCopier.copyOCGs(fromOcgsToCopy, toOcProperties, toDocument); + OcgPropertiesCopier.copyOCGs(ocgsToCopy, toOcProperties, destinationDocument); - OcgPropertiesCopier.copyDDictionary(fromOcgsToCopy, fromOcProperties.getAsDictionary(PdfName.D), - toOcProperties, toDocument); + OcgPropertiesCopier.copyDDictionary(ocgsToCopy, fromOcProperties.getAsDictionary(PdfName.D), + toOcProperties, destinationDocument); } catch (Exception e) { LOGGER.error(MessageFormatUtil.format(IoLogMessageConstant.OCG_COPYING_ERROR, e.toString())); } } + /** + * Get all OCGs from a given page annotations/xobjects/resources, including ones already stored in catalog + * + * @param page where to search for OCGs. + * @return set of indirect references pointing to found OCGs. + */ + static Set getOCGsFromPage(PdfPage page) { + //Using linked hash set for elements order consistency (e.g. in tests) + final Set ocgs = new LinkedHashSet<>(); + final List annotations = page.getAnnotations(); + for (PdfAnnotation annotation : annotations) { + //Pass null instead of catalog OCProperties value, to include ocg clashing with catalog + getUsedNonFlushedOCGsFromAnnotation(annotation, annotation, ocgs, null); + } + final PdfDictionary resources = page.getPdfObject().getAsDictionary(PdfName.Resources); + OcgPropertiesCopier.getUsedNonFlushedOCGsFromResources(resources, resources, ocgs, + null, new HashSet<>()); + return ocgs; + } + private static Set getAllUsedNonFlushedOCGs(Map page2page, PdfDictionary toOcProperties) { // NOTE: the PDF is considered to be valid and therefore the presence of OСG in OCProperties.OCGs is not checked final Set fromUsedOcgs = new LinkedHashSet<>(); @@ -87,20 +114,10 @@ private static Set getAllUsedNonFlushedOCGs(Map fromAnnotations = fromPage.getAnnotations(); for (int j = 0; j < toAnnotations.size(); j++) { if (!toAnnotations.get(j).isFlushed()) { - final PdfDictionary toAnnotDict = toAnnotations.get(j).getPdfObject(); - final PdfDictionary fromAnnotDict = fromAnnotations.get(j).getPdfObject(); final PdfAnnotation toAnnot = toAnnotations.get(j); final PdfAnnotation fromAnnot = fromAnnotations.get(j); - if (!toAnnotDict.isFlushed()) { - OcgPropertiesCopier.getUsedNonFlushedOCGsFromOcDict(toAnnotDict.getAsDictionary(PdfName.OC), - fromAnnotDict.getAsDictionary(PdfName.OC), fromUsedOcgs, toOcProperties); - - OcgPropertiesCopier.getUsedNonFlushedOCGsFromXObject(toAnnot.getNormalAppearanceObject(), - fromAnnot.getNormalAppearanceObject(), fromUsedOcgs, toOcProperties, new HashSet<>()); - OcgPropertiesCopier.getUsedNonFlushedOCGsFromXObject(toAnnot.getRolloverAppearanceObject(), - fromAnnot.getRolloverAppearanceObject(), fromUsedOcgs, toOcProperties, new HashSet<>()); - OcgPropertiesCopier.getUsedNonFlushedOCGsFromXObject(toAnnot.getDownAppearanceObject(), - fromAnnot.getDownAppearanceObject(), fromUsedOcgs, toOcProperties, new HashSet<>()); + if (!toAnnot.getPdfObject().isFlushed()) { + getUsedNonFlushedOCGsFromAnnotation(toAnnot, fromAnnot, fromUsedOcgs, toOcProperties); } } } @@ -113,6 +130,17 @@ private static Set getAllUsedNonFlushedOCGs(Map fromUsedOcgs, PdfDictionary toOcProperties) { + OcgPropertiesCopier.getUsedNonFlushedOCGsFromOcDict(toAnnot.getPdfObject().getAsDictionary(PdfName.OC), + fromAnnot.getPdfObject().getAsDictionary(PdfName.OC), fromUsedOcgs, toOcProperties); + OcgPropertiesCopier.getUsedNonFlushedOCGsFromXObject(toAnnot.getNormalAppearanceObject(), + fromAnnot.getNormalAppearanceObject(), fromUsedOcgs, toOcProperties, new HashSet<>()); + OcgPropertiesCopier.getUsedNonFlushedOCGsFromXObject(toAnnot.getRolloverAppearanceObject(), + fromAnnot.getRolloverAppearanceObject(), fromUsedOcgs, toOcProperties, new HashSet<>()); + OcgPropertiesCopier.getUsedNonFlushedOCGsFromXObject(toAnnot.getDownAppearanceObject(), + fromAnnot.getDownAppearanceObject(), fromUsedOcgs, toOcProperties, new HashSet<>()); + } + private static void getUsedNonFlushedOCGsFromResources(PdfDictionary toResources, PdfDictionary fromResources, Set fromUsedOcgs, PdfDictionary toOcProperties, Set visitedObjects) { if (toResources != null && !toResources.isFlushed()) { diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/PageContentRotationHelper.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/PageContentRotationHelper.java new file mode 100644 index 0000000000..daac60a5c4 --- /dev/null +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/PageContentRotationHelper.java @@ -0,0 +1,62 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.pdf; + +/** + * Helper class to specify or check whether inverse matrix is already applied to the page content stream in case + * page rotation is applied and {@link PdfPage#setIgnorePageRotationForContent(boolean)} is set to {@code true}. + * + *

+ * Page rotation inverse matrix rotates content into the opposite direction from page rotation direction + * in order to give the impression of the not rotated text. It should be applied only once for the page. + */ +public final class PageContentRotationHelper { + + /** + * Checks if page rotation inverse matrix (which rotates content into the opposite direction from the page rotation + * direction in order to give the impression of the not rotated text) is already applied to the page content stream. + * See {@link PdfPage#setIgnorePageRotationForContent(boolean)}. + * + * @param page {@link PdfPage} to check applied content rotation for + * + * @return {@code true} if inverse matrix is already applied, {@code false} otherwise + */ + public static boolean isPageRotationInverseMatrixWritten(PdfPage page) { + return page.isPageRotationInverseMatrixWritten(); + } + + /** + * Specify that inverse matrix (which rotates content into the opposite direction from the page rotation + * direction in order to give the impression of the not rotated text) is applied to the page content stream. + * See {@link PdfPage#setIgnorePageRotationForContent(boolean)}. + * + * @param page {@link PdfPage} for which to specify that content rotation is applied + */ + public static void setPageRotationInverseMatrixWritten(PdfPage page) { + page.setPageRotationInverseMatrixWritten(); + } + + private PageContentRotationHelper() { + // Private constructor will prevent the instantiation of this class directly. + } +} diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/PageFlushingHelper.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/PageFlushingHelper.java index 1dc168b1ec..a19fc39fcb 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/pdf/PageFlushingHelper.java +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/PageFlushingHelper.java @@ -22,7 +22,7 @@ This file is part of the iText (R) project. */ package com.itextpdf.kernel.pdf; -import com.itextpdf.kernel.events.PdfDocumentEvent; +import com.itextpdf.kernel.pdf.event.PdfDocumentEvent; import com.itextpdf.kernel.exceptions.KernelExceptionMessageConstant; import com.itextpdf.kernel.pdf.canvas.parser.PdfCanvasProcessor; import com.itextpdf.kernel.pdf.layer.PdfLayer; diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfAConformance.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfAConformance.java new file mode 100644 index 0000000000..cb8bea6152 --- /dev/null +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfAConformance.java @@ -0,0 +1,86 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.pdf; + +/** + * PDF/A is a special variant of PDF designed specifically for long-term document preservation (the “A” stands for archive). + * + *

+ * The class contains an enumeration of all the PDF/A conformance currently supported by iText. + */ +public enum PdfAConformance { + /** PDF/A-1A **/ + PDF_A_1A("1", "A"), + /** PDF/A-1B **/ + PDF_A_1B("1", "B"), + /** PDF/A-2A **/ + PDF_A_2A("2", "A"), + /** PDF/A-2B **/ + PDF_A_2B("2", "B"), + /** PDF/A-2U **/ + PDF_A_2U("2", "U"), + /** PDF/A-3A **/ + PDF_A_3A("3", "A"), + /** PDF/A-3B **/ + PDF_A_3B("3", "B"), + /** PDF/A-3U **/ + PDF_A_3U("3", "U"), + /** PDF/A-4 **/ + PDF_A_4("4", null), + /** PDF/A-4E **/ + PDF_A_4E("4", "E"), + /** PDF/A-4F **/ + PDF_A_4F("4", "F"); + + private final String part; + private final String level; + + /** + * Creates a new {@link PdfAConformance} instance. + * + * @param part the part of the PDF/A conformance + * @param level the level of the PDF/A conformance + */ + PdfAConformance(String part, String level) { + this.part = part; + this.level = level; + } + + /** + * Get the part of the PDF/A conformance. + * + * @return the part of the PDF/A conformance + */ + public String getPart() { + return this.part; + } + + /** + * Get the level of the PDF/A conformance. + * + * @return the level of the PDF/A conformance + */ + public String getLevel() { + return this.level; + } +} diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfAConformanceLevel.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfAConformanceLevel.java deleted file mode 100644 index 4952621819..0000000000 --- a/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfAConformanceLevel.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - This file is part of the iText (R) project. - Copyright (c) 1998-2024 Apryse Group NV - Authors: Apryse Software. - - This program is offered under a commercial and under the AGPL license. - For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. - - AGPL licensing: - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . - */ -package com.itextpdf.kernel.pdf; - -import com.itextpdf.kernel.xmp.XMPConst; -import com.itextpdf.kernel.xmp.XMPException; -import com.itextpdf.kernel.xmp.XMPMeta; -import com.itextpdf.kernel.xmp.properties.XMPProperty; - - -/** - * Enumeration of all the PDF/A conformance levels. - */ -public class PdfAConformanceLevel implements IConformanceLevel { - - public static final PdfAConformanceLevel PDF_A_1A = new PdfAConformanceLevel("1", "A"); - public static final PdfAConformanceLevel PDF_A_1B = new PdfAConformanceLevel("1", "B"); - public static final PdfAConformanceLevel PDF_A_2A = new PdfAConformanceLevel("2", "A"); - public static final PdfAConformanceLevel PDF_A_2B = new PdfAConformanceLevel("2", "B"); - public static final PdfAConformanceLevel PDF_A_2U = new PdfAConformanceLevel("2", "U"); - public static final PdfAConformanceLevel PDF_A_3A = new PdfAConformanceLevel("3", "A"); - public static final PdfAConformanceLevel PDF_A_3B = new PdfAConformanceLevel("3", "B"); - public static final PdfAConformanceLevel PDF_A_3U = new PdfAConformanceLevel("3", "U"); - public static final PdfAConformanceLevel PDF_A_4 = new PdfAConformanceLevel("4", null); - public static final PdfAConformanceLevel PDF_A_4E = new PdfAConformanceLevel("4", "E"); - public static final PdfAConformanceLevel PDF_A_4F = new PdfAConformanceLevel("4", "F"); - public static final String PDF_A_4_REVISION = "2020"; - - private final String conformance; - private final String part; - - private PdfAConformanceLevel(String part, String conformance) { - this.conformance = conformance; - this.part = part; - } - - public String getConformance() { - return conformance; - } - - public String getPart() { - return part; - } - - public static PdfAConformanceLevel getConformanceLevel(String part, String conformance) { - String lowLetter = conformance == null ? null : conformance.toUpperCase(); - boolean aLevel = "A".equals(lowLetter); - boolean bLevel = "B".equals(lowLetter); - boolean uLevel = "U".equals(lowLetter); - boolean eLevel = "E".equals(lowLetter); - boolean fLevel = "F".equals(lowLetter); - - switch (part) { - case "1": - if (aLevel) - return PdfAConformanceLevel.PDF_A_1A; - if (bLevel) - return PdfAConformanceLevel.PDF_A_1B; - break; - case "2": - if (aLevel) - return PdfAConformanceLevel.PDF_A_2A; - if (bLevel) - return PdfAConformanceLevel.PDF_A_2B; - if (uLevel) - return PdfAConformanceLevel.PDF_A_2U; - break; - case "3": - if (aLevel) - return PdfAConformanceLevel.PDF_A_3A; - if (bLevel) - return PdfAConformanceLevel.PDF_A_3B; - if (uLevel) - return PdfAConformanceLevel.PDF_A_3U; - break; - case "4": - if (eLevel) - return PdfAConformanceLevel.PDF_A_4E; - if (fLevel) - return PdfAConformanceLevel.PDF_A_4F; - return PdfAConformanceLevel.PDF_A_4; - } - return null; - } - - public static PdfAConformanceLevel getConformanceLevel(XMPMeta meta) { - XMPProperty conformanceXmpProperty = null; - XMPProperty partXmpProperty = null; - try { - conformanceXmpProperty = meta.getProperty(XMPConst.NS_PDFA_ID, XMPConst.CONFORMANCE); - partXmpProperty = meta.getProperty(XMPConst.NS_PDFA_ID, XMPConst.PART); - } catch (XMPException ignored) { - } - if (partXmpProperty == null || (conformanceXmpProperty == null && !"4".equals(partXmpProperty.getValue()))) { - return null; - } else { - return getConformanceLevel(partXmpProperty.getValue(), - conformanceXmpProperty == null ? null : conformanceXmpProperty.getValue()); - } - } - - /** - * Gets the PdfA conformance level. - * @param possibleConformance the possible candidate for {@link PdfAConformanceLevel} - * @param document the document - * @return the conformance level or null if it's not PDFA - * - * @deprecated since 8.0.4 Will be removed in next major release - */ - @Deprecated - public static PdfAConformanceLevel getPDFAConformance(IConformanceLevel possibleConformance, PdfDocument document){ - if (possibleConformance instanceof PdfAConformanceLevel) { - return (PdfAConformanceLevel) possibleConformance; - } - if (document == null) { - return null; - } - if (document.getConformanceLevel() instanceof PdfAConformanceLevel) { - return (PdfAConformanceLevel) document.getConformanceLevel(); - } - return null; - } -} diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfCatalog.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfCatalog.java index a5325ccfa1..0362023605 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfCatalog.java +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfCatalog.java @@ -347,7 +347,7 @@ public void setLang(PdfString lang) { } /** - * Add an extensions dictionary containing developer prefix identification and version + * Adds an extensions dictionary containing developer prefix identification and version * numbers for developer extensions that occur in this document. * See ISO 32000-1, Table 28 – Entries in the catalog dictionary. * @@ -396,6 +396,39 @@ public void addDeveloperExtension(PdfDeveloperExtension extension) { } } + /** + * Removes an extensions dictionary containing developer prefix identification and version + * numbers for developer extensions that do not occur in this document. + * See ISO 32000-1, Table 28 – Entries in the catalog dictionary. + * + * @param extension developer extension to be removed from the document + */ + public void removeDeveloperExtension(PdfDeveloperExtension extension) { + PdfDictionary extensions = getPdfObject().getAsDictionary(PdfName.Extensions); + if (extensions == null) { + return; + } + + if (extension.isMultiValued()) { + PdfArray existingExtensionArray = extensions.getAsArray(extension.getPrefix()); + if (existingExtensionArray == null) { + return; + } + + for (int i = 0; i < existingExtensionArray.size(); i++) { + PdfDictionary pdfDict = existingExtensionArray.getAsDictionary(i); + // for array-based extensions, we check for membership only, since comparison doesn't make sense + if (pdfDict.getAsNumber(PdfName.ExtensionLevel).intValue() == extension.getExtensionLevel()) { + existingExtensionArray.remove(i); + existingExtensionArray.setModified(); + return; + } + } + } else { + extensions.remove(extension.getPrefix()); + } + } + /** * Gets collection dictionary that a conforming reader shall use to enhance the presentation of file attachments * stored in the PDF document. diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfConformance.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfConformance.java new file mode 100644 index 0000000000..da1787a574 --- /dev/null +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfConformance.java @@ -0,0 +1,343 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.pdf; + +import com.itextpdf.kernel.xmp.XMPConst; +import com.itextpdf.kernel.xmp.XMPException; +import com.itextpdf.kernel.xmp.XMPMeta; +import com.itextpdf.kernel.xmp.XMPMetaFactory; +import com.itextpdf.kernel.xmp.XMPUtils; +import com.itextpdf.kernel.xmp.options.PropertyOptions; +import com.itextpdf.kernel.xmp.properties.XMPProperty; + +/** + * The class represents possible PDF document conformance. + */ +public class PdfConformance { + public static final String PDF_A_4_REVISION = "2020"; + + public static final PdfConformance PDF_A_1A = new PdfConformance(PdfAConformance.PDF_A_1A); + public static final PdfConformance PDF_A_1B = new PdfConformance(PdfAConformance.PDF_A_1B); + public static final PdfConformance PDF_A_2A = new PdfConformance(PdfAConformance.PDF_A_2A); + public static final PdfConformance PDF_A_2B = new PdfConformance(PdfAConformance.PDF_A_2B); + public static final PdfConformance PDF_A_2U = new PdfConformance(PdfAConformance.PDF_A_2U); + public static final PdfConformance PDF_A_3A = new PdfConformance(PdfAConformance.PDF_A_3A); + public static final PdfConformance PDF_A_3B = new PdfConformance(PdfAConformance.PDF_A_3B); + public static final PdfConformance PDF_A_3U = new PdfConformance(PdfAConformance.PDF_A_3U); + public static final PdfConformance PDF_A_4 = new PdfConformance(PdfAConformance.PDF_A_4); + public static final PdfConformance PDF_A_4E = new PdfConformance(PdfAConformance.PDF_A_4E); + public static final PdfConformance PDF_A_4F = new PdfConformance(PdfAConformance.PDF_A_4F); + + public static final PdfConformance PDF_UA_1 = new PdfConformance(PdfUAConformance.PDF_UA_1); + + public static final PdfConformance PDF_NONE_CONFORMANCE = new PdfConformance(); + + private final PdfAConformance aConformance; + private final PdfUAConformance uaConformance; + + /** + * Creates a new {@link PdfConformance} instance based on PDF/A and PDF/UA conformance. + * + * @param aConformance the PDF/A conformance + * @param uaConformance the PDF/UA conformance + */ + public PdfConformance(PdfAConformance aConformance, PdfUAConformance uaConformance) { + this.aConformance = aConformance; + this.uaConformance = uaConformance; + } + + /** + * Creates a new {@link PdfConformance} instance based on only PDF/A conformance. + * + * @param aConformance the PDF/A conformance + */ + public PdfConformance(PdfAConformance aConformance) { + this.aConformance = aConformance; + this.uaConformance = null; + } + + /** + * Creates a new {@link PdfConformance} instance based on only PDF/UA conformance. + * + * @param uaConformance the PDF/UA conformance + */ + public PdfConformance(PdfUAConformance uaConformance) { + this.uaConformance = uaConformance; + this.aConformance = null; + } + + /** + * Creates a new {@link PdfConformance} instance without PDF/A or PDF/UA conformance. + */ + public PdfConformance() { + this.aConformance = null; + this.uaConformance = null; + } + + /** + * Checks if any PDF/A conformance is specified. + * + * @return {@code true} if PDF/A conformance is specified, otherwise {@code false} + */ + public boolean isPdfA() { + return aConformance != null; + } + + /** + * Checks if any PDF/UA conformance is specified. + * + * @return {@code true} if PDF/UA conformance is specified, otherwise {@code false} + */ + public boolean isPdfUA() { + return uaConformance != null; + } + + /** + * Checks if any PDF/A or PDF/UA conformance is specified. + * + * @return {@code true} if PDF/A or PDF/UA conformance is specified, otherwise {@code false} + */ + public boolean isPdfAOrUa() { + return isPdfA() || isPdfUA(); + } + + /** + * Gets the {@link PdfAConformance} instance if specified. + * + * @return the specified {@link PdfAConformance} instance or {@code null}. + */ + public PdfAConformance getAConformance() { + return aConformance; + } + + /** + * Gets the {@link PdfUAConformance} instance if specified. + * + * @return the specified {@link PdfUAConformance} instance or {@code null}. + */ + public PdfUAConformance getUAConformance() { + return uaConformance; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PdfConformance that = (PdfConformance) o; + return aConformance == that.aConformance && uaConformance == that.uaConformance; + } + + @Override + public int hashCode() { + int result = aConformance == null ? 0 : aConformance.hashCode(); + result = 31 * result + (uaConformance == null ? 0 : uaConformance.hashCode()); + return result; + } + + /** + * Gets {@link PdfConformance} instance from {@link XMPMeta}. + * + * @param meta the meta data to parse + * + * @return the {@link PdfConformance} instance + */ + public static PdfConformance getConformance(XMPMeta meta) { + if (meta == null) { + return PdfConformance.PDF_NONE_CONFORMANCE; + } + XMPProperty conformanceAXmpProperty = null; + XMPProperty partAXmpProperty = null; + PdfAConformance aLevel = null; + try { + conformanceAXmpProperty = meta.getProperty(XMPConst.NS_PDFA_ID, XMPConst.CONFORMANCE); + partAXmpProperty = meta.getProperty(XMPConst.NS_PDFA_ID, XMPConst.PART); + } catch (XMPException ignored) { + } + if (partAXmpProperty != null && (conformanceAXmpProperty != null || "4".equals(partAXmpProperty.getValue()))) { + aLevel = getAConformance(partAXmpProperty.getValue(), + conformanceAXmpProperty == null ? null : conformanceAXmpProperty.getValue()); + } + + XMPProperty partUAXmpProperty = null; + PdfUAConformance uaLevel = null; + try { + partUAXmpProperty = meta.getProperty(XMPConst.NS_PDFUA_ID, XMPConst.PART); + } catch (XMPException ignored) { + } + if (partUAXmpProperty != null) { + uaLevel = getUAConformance(partUAXmpProperty.getValue()); + } + + return new PdfConformance(aLevel, uaLevel); + } + + /** + * Sets required fields into XMP metadata according to passed PDF conformance. + * + * @param xmpMeta the xmp metadata to which required PDF conformance fields will be set + * @param conformance the PDF conformance according to which XMP will be updated + * + * @throws XMPException if the file is not well-formed XML or if the parsing fails + */ + public static void setConformanceToXmp(XMPMeta xmpMeta, PdfConformance conformance) throws XMPException { + if (conformance == null) { + return; + } + // Don't set any property if property value was set, so if + // smth was invalid in source document, it will be left as is. + // But if e.g. for PDF/A-4 revision wasn't specified, we will fix it. + if (conformance.isPdfUA()) { + if (xmpMeta.getProperty(XMPConst.NS_PDFUA_ID, XMPConst.PART) == null) { + xmpMeta.setPropertyInteger(XMPConst.NS_PDFUA_ID, XMPConst.PART, 1, + new PropertyOptions(PropertyOptions.SEPARATE_NODE)); + } + } + if (conformance.isPdfA()) { + final PdfAConformance aLevel = conformance.getAConformance(); + if (xmpMeta.getProperty(XMPConst.NS_PDFA_ID, XMPConst.PART) == null) { + xmpMeta.setProperty(XMPConst.NS_PDFA_ID, XMPConst.PART, aLevel.getPart()); + } + if (aLevel.getLevel() != null && xmpMeta.getProperty(XMPConst.NS_PDFA_ID, XMPConst.CONFORMANCE) == null) { + xmpMeta.setProperty(XMPConst.NS_PDFA_ID, XMPConst.CONFORMANCE, aLevel.getLevel()); + } + if ("4".equals(aLevel.getPart()) && xmpMeta.getProperty(XMPConst.NS_PDFA_ID, XMPConst.REV) == null) { + xmpMeta.setProperty(XMPConst.NS_PDFA_ID, XMPConst.REV, PdfConformance.PDF_A_4_REVISION); + } + + if (xmpMeta.getPropertyInteger(XMPConst.NS_PDFUA_ID, XMPConst.PART) != null) { + XMPMeta taggedExtensionMeta = XMPMetaFactory.parseFromString(PDF_UA_EXTENSION); + XMPUtils.appendProperties(taggedExtensionMeta, xmpMeta, true, false); + } + } + } + + /** + * Gets an instance of {@link PdfAConformance} based on passed part and level. + * + * @param part the part of PDF/A conformance + * @param level the level of PDF/A conformance + * + * @return the {@link PdfAConformance} instance or {@code null} if there is no PDF/A conformance for passed parameters + */ + public static PdfAConformance getAConformance(String part, String level) { + String lowLetter = level == null ? null : level.toUpperCase(); + boolean aLevel = "A".equals(lowLetter); + boolean bLevel = "B".equals(lowLetter); + boolean uLevel = "U".equals(lowLetter); + boolean eLevel = "E".equals(lowLetter); + boolean fLevel = "F".equals(lowLetter); + + switch (part) { + case "1": + if (aLevel) { + return PdfAConformance.PDF_A_1A; + } + if (bLevel) { + return PdfAConformance.PDF_A_1B; + } + break; + case "2": + if (aLevel) { + return PdfAConformance.PDF_A_2A; + } + if (bLevel) { + return PdfAConformance.PDF_A_2B; + } + if (uLevel) { + return PdfAConformance.PDF_A_2U; + } + break; + case "3": + if (aLevel) { + return PdfAConformance.PDF_A_3A; + } + if (bLevel) { + return PdfAConformance.PDF_A_3B; + } + if (uLevel) { + return PdfAConformance.PDF_A_3U; + } + break; + case "4": + if (eLevel) { + return PdfAConformance.PDF_A_4E; + } + if (fLevel) { + return PdfAConformance.PDF_A_4F; + } + return PdfAConformance.PDF_A_4; + } + return null; + } + + private static PdfUAConformance getUAConformance(String part) { + if ("1".equals(part)) { + return PdfUAConformance.PDF_UA_1; + } + return null; + } + + private static final String PDF_UA_EXTENSION = + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " pdfuaid\n" + + " PDF/UA identification schema\n" + + " \n" + + " \n" + + " \n" + + " internal\n" + + " PDF/UA version identifier\n" + + " part\n" + + " Integer\n" + + " \n" + + " \n" + + " internal\n" + + " PDF/UA amendment identifier\n" + + " amd\n" + + " Text\n" + + " \n" + + " \n" + + " internal\n" + + " PDF/UA corrigenda identifier\n" + + " corr\n" + + " Text\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " "; + +} diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfDeveloperExtension.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfDeveloperExtension.java index f24e14f232..9224347744 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfDeveloperExtension.java +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfDeveloperExtension.java @@ -66,6 +66,24 @@ public class PdfDeveloperExtension { ":2022", true); + /** An instance of this class for ISO/TS 32004. */ + public static final PdfDeveloperExtension ISO_32004 = new PdfDeveloperExtension( + PdfName.ISO_, + PdfName.Pdf_Version_2_0, + 32004, + "https://www.iso.org/standard/45877.html", + ":2024", + true); + + /** An instance of this class for ISO/TS 32003. */ + public static final PdfDeveloperExtension ISO_32003 = new PdfDeveloperExtension( + PdfName.ISO_, + PdfName.Pdf_Version_2_0, + 32003, + "https://www.iso.org/standard/45876.html", + ":2023", + true); + /** The prefix used in the Extensions dictionary added to the Catalog. */ protected PdfName prefix; diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfDocument.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfDocument.java index d40db2517c..6a9d7c8594 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfDocument.java +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfDocument.java @@ -23,6 +23,7 @@ This file is part of the iText (R) project. package com.itextpdf.kernel.pdf; import com.itextpdf.commons.actions.EventManager; +import com.itextpdf.commons.actions.IEventHandler; import com.itextpdf.commons.actions.confirmations.ConfirmEvent; import com.itextpdf.commons.actions.confirmations.EventConfirmationType; import com.itextpdf.commons.actions.data.ProductData; @@ -30,15 +31,13 @@ This file is part of the iText (R) project. import com.itextpdf.commons.utils.DIContainer; import com.itextpdf.commons.utils.MessageFormatUtil; import com.itextpdf.io.logs.IoLogMessageConstant; +import com.itextpdf.io.source.ByteArrayOutputStream; import com.itextpdf.io.source.ByteUtils; import com.itextpdf.io.source.RandomAccessFileOrArray; import com.itextpdf.kernel.actions.data.ITextCoreProductData; import com.itextpdf.kernel.actions.events.FlushPdfDocumentEvent; import com.itextpdf.kernel.actions.events.ITextCoreProductEvent; import com.itextpdf.kernel.colors.Color; -import com.itextpdf.kernel.events.EventDispatcher; -import com.itextpdf.kernel.events.IEventDispatcher; -import com.itextpdf.kernel.events.PdfDocumentEvent; import com.itextpdf.kernel.exceptions.BadPasswordException; import com.itextpdf.kernel.exceptions.KernelExceptionMessageConstant; import com.itextpdf.kernel.exceptions.MemoryLimitsAwareException; @@ -52,8 +51,10 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfReader.StrictnessLevel; import com.itextpdf.kernel.pdf.annot.PdfAnnotation; import com.itextpdf.kernel.pdf.annot.PdfWidgetAnnotation; -import com.itextpdf.kernel.pdf.canvas.CanvasGraphicsState; import com.itextpdf.kernel.pdf.collection.PdfCollection; +import com.itextpdf.kernel.pdf.event.AbstractPdfDocumentEvent; +import com.itextpdf.kernel.pdf.event.AbstractPdfDocumentEventHandler; +import com.itextpdf.kernel.pdf.event.PdfDocumentEvent; import com.itextpdf.kernel.pdf.filespec.PdfEncryptedPayloadFileSpecFactory; import com.itextpdf.kernel.pdf.filespec.PdfFileSpec; import com.itextpdf.kernel.pdf.navigation.PdfDestination; @@ -61,24 +62,27 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.statistics.SizeOfPdfStatisticsEvent; import com.itextpdf.kernel.pdf.tagging.PdfStructTreeRoot; import com.itextpdf.kernel.pdf.tagutils.TagStructureContext; -import com.itextpdf.kernel.utils.ValidationContainer; -import com.itextpdf.kernel.utils.ValidationContext; +import com.itextpdf.kernel.validation.IValidationContext; +import com.itextpdf.kernel.validation.ValidationContainer; +import com.itextpdf.kernel.validation.context.CryptoValidationContext; +import com.itextpdf.kernel.validation.context.PdfDocumentValidationContext; import com.itextpdf.kernel.xmp.PdfConst; import com.itextpdf.kernel.xmp.XMPConst; import com.itextpdf.kernel.xmp.XMPException; import com.itextpdf.kernel.xmp.XMPMeta; import com.itextpdf.kernel.xmp.XMPMetaFactory; -import com.itextpdf.kernel.xmp.options.PropertyOptions; import com.itextpdf.kernel.xmp.options.SerializeOptions; import java.io.Closeable; import java.io.IOException; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedHashMap; +import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; @@ -89,25 +93,27 @@ This file is part of the iText (R) project. /** * Main enter point to work with PDF document. */ -public class PdfDocument implements IEventDispatcher, Closeable { - // +public class PdfDocument implements Closeable { private static final PdfName[] PDF_NAMES_TO_REMOVE_FROM_ORIGINAL_TRAILER = new PdfName[] { - PdfName.Encrypt, - PdfName.Size, - PdfName.Prev, - PdfName.Root, - PdfName.Info, - PdfName.ID, - PdfName.XRefStm, + PdfName.Encrypt, + PdfName.Size, + PdfName.Prev, + PdfName.Root, + PdfName.Info, + PdfName.ID, + PdfName.XRefStm, + PdfName.AuthCode }; - private static final IPdfPageFactory pdfPageFactory = new PdfPageFactory(); + private static final Logger LOGGER = LoggerFactory.getLogger(PdfDocument.class); + protected final StampingProperties properties; /** * List of indirect objects used in the document. */ final PdfXrefTable xref = new PdfXrefTable(); private final Map documentFonts = new HashMap<>(); + private final Set documentHandlers = new LinkedHashSet<>(); private final SequenceId documentId; /** * To be adjusted destinations. @@ -116,7 +122,6 @@ public class PdfDocument implements IEventDispatcher, Closeable { */ private final List pendingDestinationMutations = new ArrayList(); - protected EventDispatcher eventDispatcher = new EventDispatcher(); /** * PdfWriter associated with the document. * Not null if document opened either in writing or stamping mode. @@ -128,10 +133,6 @@ public class PdfDocument implements IEventDispatcher, Closeable { * Not null if document is opened either in reading or stamping mode. */ protected PdfReader reader = null; - /** - * XMP Metadata for the document. - */ - protected byte[] xmpMetadata = null; /** * Document catalog. */ @@ -140,14 +141,11 @@ public class PdfDocument implements IEventDispatcher, Closeable { * Document trailed. */ protected PdfDictionary trailer = null; - /** - * Document info. - */ - protected PdfDocumentInfo info = null; /** * Document version. */ protected PdfVersion pdfVersion = PdfVersion.PDF_1_7; + protected PdfConformance pdfConformance = PdfConformance.PDF_NONE_CONFORMANCE; protected FingerPrint fingerPrint; protected SerializeOptions serializeOptions = new SerializeOptions(); protected PdfStructTreeRoot structTreeRoot; @@ -161,6 +159,10 @@ public class PdfDocument implements IEventDispatcher, Closeable { */ protected boolean flushUnusedObjects = false; protected TagStructureContext tagStructureContext; + + protected DocumentInfoHelper documentInfoHelper = new DocumentInfoHelper(); + protected DefaultFontStrategy defaultFontStrategy = new DefaultFontStrategy(this); + protected IPdfPageFactory pdfPageFactory = new PdfPageFactory(); /** * Cache of already serialized objects from this document for smart mode. */ @@ -182,8 +184,20 @@ public class PdfDocument implements IEventDispatcher, Closeable { * The original modified (second) id when the document is read initially. */ private PdfString modifiedDocumentId; - private PdfFont defaultFont = null; private EncryptedEmbeddedStreamsHandler encryptedEmbeddedStreamsHandler; + /** + * Document info. + */ + private PdfDocumentInfo info = null; + /** + * XMP Metadata bytes for the document. + */ + private byte[] xmpMetadataBytes = null; + /** + * XMP Metadata which is used to prevent bytes deserialization for a few times on the same bytes. + */ + private XMPMeta xmpMetadata = null; + private final DIContainer diContainer = new DIContainer(); @@ -208,9 +222,7 @@ public PdfDocument(PdfReader reader, DocumentProperties properties) { } documentId = new SequenceId(); this.reader = reader; - // default values of the StampingProperties doesn't affect anything - this.properties = new StampingProperties(); - this.properties.setEventCountingMetaInfo(properties.metaInfo); + this.properties = new StampingProperties(properties); open(null); } @@ -237,9 +249,7 @@ public PdfDocument(PdfWriter writer, DocumentProperties properties) { } documentId = new SequenceId(); this.writer = writer; - // default values of the StampingProperties doesn't affect anything - this.properties = new StampingProperties(); - this.properties.setEventCountingMetaInfo(properties.metaInfo); + this.properties = new StampingProperties(properties); open(writer.properties.pdfVersion); } @@ -275,80 +285,155 @@ public PdfDocument(PdfReader reader, PdfWriter writer, StampingProperties proper boolean writerHasEncryption = writerHasEncryption(); if (properties.appendMode && writerHasEncryption) { - Logger logger = LoggerFactory.getLogger(PdfDocument.class); - logger.warn(IoLogMessageConstant.WRITER_ENCRYPTION_IS_IGNORED_APPEND); + LOGGER.warn(IoLogMessageConstant.WRITER_ENCRYPTION_IS_IGNORED_APPEND); } if (properties.preserveEncryption && writerHasEncryption) { - Logger logger = LoggerFactory.getLogger(PdfDocument.class); - logger.warn(IoLogMessageConstant.WRITER_ENCRYPTION_IS_IGNORED_PRESERVE); + LOGGER.warn(IoLogMessageConstant.WRITER_ENCRYPTION_IS_IGNORED_PRESERVE); } open(writer.properties.pdfVersion); } + /** + * Checks if the document closing has been started or not. + * + * @return {@code true} if closing process has been started, otherwise {@code false} + */ + public boolean isClosing() { + return isClosing; + } + /** * Sets the XMP Metadata. + *

+ * The XMP Metadata values are synchronized with information dictionary. * - * @param xmpMeta the xmpMetadata to set + * @param xmpMeta the xmpMetadata to set * @param serializeOptions serialization options * * @throws XMPException on serialization errors */ public void setXmpMetadata(XMPMeta xmpMeta, SerializeOptions serializeOptions) throws XMPException { this.serializeOptions = serializeOptions; - setXmpMetadata(XMPMetaFactory.serializeToBuffer(xmpMeta, serializeOptions)); + this.xmpMetadataBytes = XMPMetaFactory.serializeToBuffer(xmpMeta, serializeOptions); + this.xmpMetadata = xmpMeta; + } + + /** + * Sets the XMP Metadata. + *

+ * The XMP Metadata values are synchronized with information dictionary. + *

+ * {@link PdfDocument#serializeOptions} will be used for serialization, they + * can be changed by {@link PdfDocument#setSerializeOptions(SerializeOptions)}. + * + * @param xmpMeta the xmpMetadata to set + * + * @throws XMPException on serialization errors + */ + public void setXmpMetadata(XMPMeta xmpMeta) throws XMPException { + setXmpMetadata(xmpMeta, serializeOptions); } /** - * Use this method to set the XMP Metadata. + * Sets the XMP Metadata. + *

+ * The XMP Metadata values are synchronized with information dictionary. * - * @param xmpMetadata The xmpMetadata to set. + * @param xmpMetadata the xmpMetadata bytes to set */ protected void setXmpMetadata(byte[] xmpMetadata) { - this.xmpMetadata = xmpMetadata; + this.xmpMetadataBytes = xmpMetadata; + this.xmpMetadata = null; + try { + getXmpMetadata(); + } catch (XMPException e) { + LOGGER.error(IoLogMessageConstant.EXCEPTION_WHILE_UPDATING_XMPMETADATA, e); + } } /** - * Sets the XMP Metadata. + * Gets XMP Metadata. + *

+ * XMP Metadata is lazy initialized. It will be initialized during the first call of this method. + *

+ * To update XMP Metadata of the document, use {@link PdfDocument#setXmpMetadata(XMPMeta)} method. * - * @param xmpMeta the xmpMetadata to set + * @return existed XMP Metadata * * @throws XMPException on serialization errors */ - public void setXmpMetadata(XMPMeta xmpMeta) throws XMPException { - serializeOptions.setPadding(2000); - setXmpMetadata(xmpMeta, serializeOptions); + public XMPMeta getXmpMetadata() throws XMPException { + return getXmpMetadata(false); } /** - * Gets XMPMetadata. + * Gets XMP Metadata or create a new one. + *

+ * XMP Metadata is lazy initialized. It will be initialized during the first call of this method. + *

+ * To update XMP Metadata of the document, use {@link PdfDocument#setXmpMetadata(XMPMeta)} method. * - * @return the XMPMetadata + * @param createNew if true, create a new empty XMP Metadata if it did not present + * + * @return existed or newly created XMP Metadata + * + * @throws XMPException on serialization errors */ - public byte[] getXmpMetadata() { - return getXmpMetadata(false); + public XMPMeta getXmpMetadata(boolean createNew) throws XMPException { + if (xmpMetadata == null) { + final byte[] bytes = getXmpMetadataBytes(createNew); + xmpMetadata = bytes == null ? null : XMPMetaFactory.parseFromBuffer(bytes); + } + return xmpMetadata; } /** - * Gets XMPMetadata or create a new one. + * Gets XMP Metadata. + *

+ * XMP Metadata is lazy initialized. It will be initialized during the first call of this method. + *

+ * To update XMP Metadata of the document, use {@link PdfDocument#setXmpMetadata(XMPMeta)} method. * - * @param createNew if true, create a new empty XMPMetadata if it did not present. + * @return existed XMP Metadata bytes + */ + public byte[] getXmpMetadataBytes() { + return getXmpMetadataBytes(false); + } + + /** + * Gets XMP Metadata or create a new one. + *

+ * XMP Metadata is lazy initialized. It will be initialized during the first call of this method. + *

+ * To update XMP Metadata of the document, use {@link PdfDocument#setXmpMetadata(XMPMeta)} method. * - * @return existed or newly created XMPMetadata byte array. + * @param createNew if true, create a new empty XMP Metadata if it did not present + * + * @return existed or newly created XMP Metadata byte array */ - public byte[] getXmpMetadata(boolean createNew) { - if (xmpMetadata == null && createNew) { + public byte[] getXmpMetadataBytes(boolean createNew) { + checkClosingStatus(); + if (xmpMetadataBytes == null) { + PdfStream xmpMetadataStream = catalog.getPdfObject().getAsStream(PdfName.Metadata); + if (xmpMetadataStream != null) { + xmpMetadataBytes = xmpMetadataStream.getBytes(); + } + } + if (createNew && xmpMetadataBytes == null) { XMPMeta xmpMeta = XMPMetaFactory.create(); xmpMeta.setObjectName(XMPConst.TAG_XMPMETA); xmpMeta.setObjectName(""); - addCustomMetadataExtensions(xmpMeta); try { xmpMeta.setProperty(XMPConst.NS_DC, PdfConst.Format, "application/pdf"); setXmpMetadata(xmpMeta); } catch (XMPException ignored) { } } - return xmpMetadata; + if (xmpMetadataBytes == null) { + return null; + } + return Arrays.copyOf(xmpMetadataBytes, xmpMetadataBytes.length); } /** @@ -671,17 +756,22 @@ public DIContainer getDiContainer() { /** * Gets document information dictionary. + *

* {@link PdfDocument#info} is lazy initialized. It will be initialized during the first call of this method. + *

+ * The information dictionary values are synchronized with document XMP Metadata. * * @return document information dictionary. */ public PdfDocumentInfo getDocumentInfo() { checkClosingStatus(); if (info == null) { - PdfObject infoDict = trailer.get(PdfName.Info); - info = new PdfDocumentInfo( - infoDict instanceof PdfDictionary ? (PdfDictionary) infoDict : new PdfDictionary(), this); - XmpMetaInfoConverter.appendMetadataToInfo(xmpMetadata, info); + PdfDictionary infoDict = trailer == null ? null : trailer.getAsDictionary(PdfName.Info); + info = new PdfDocumentInfo(infoDict == null ? new PdfDictionary() : infoDict, this); + try { + XmpMetaInfoConverter.appendMetadataToInfo(getXmpMetadata(), info); + } catch (XMPException ignored) { + } } return info; } @@ -691,7 +781,7 @@ public PdfDocumentInfo getDocumentInfo() { *

* In order to set originalDocumentId {@link WriterProperties#setInitialDocumentId} should be used * - * @return original dccument id + * @return original document id */ public PdfString getOriginalDocumentId() { return originalDocumentId; @@ -730,51 +820,53 @@ public void setDefaultPageSize(PageSize pageSize) { } /** - * {@inheritDoc} - */ - @Override - public void addEventHandler(String type, com.itextpdf.kernel.events.IEventHandler handler) { - eventDispatcher.addEventHandler(type, handler); - } - - /** - * {@inheritDoc} + * Adds new event handler. + * + * @param type a type of event to be handled + * @param handler event handler */ - @Override - public void dispatchEvent(com.itextpdf.kernel.events.Event event) { - eventDispatcher.dispatchEvent(event); + public void addEventHandler(String type, AbstractPdfDocumentEventHandler handler) { + handler.addType(type); + documentHandlers.add(handler); } /** - * {@inheritDoc} + * Dispatches an event. + * + * @param event the {@link AbstractPdfDocumentEvent} to be dispatched */ - @Override - public void dispatchEvent(com.itextpdf.kernel.events.Event event, boolean delayed) { - eventDispatcher.dispatchEvent(event, delayed); + public void dispatchEvent(AbstractPdfDocumentEvent event) { + event.setDocument(this); + for (final IEventHandler handler : documentHandlers) { + handler.onEvent(event); + } } /** - * {@inheritDoc} + * Checks if provided event handler assigned for this document. + * + * @param handler the {@link AbstractPdfDocumentEventHandler} to check + * + * @return {@code true} if event handler is assigned for this document, {@code false} otherwise */ - @Override - public boolean hasEventHandler(String type) { - return eventDispatcher.hasEventHandler(type); + public boolean hasEventHandler(AbstractPdfDocumentEventHandler handler) { + return documentHandlers.contains(handler); } /** - * {@inheritDoc} + * Removes event handler. + * + * @param handler {@link AbstractPdfDocumentEventHandler} event handler to remove for this document */ - @Override - public void removeEventHandler(String type, com.itextpdf.kernel.events.IEventHandler handler) { - eventDispatcher.removeEventHandler(type, handler); + public void removeEventHandler(AbstractPdfDocumentEventHandler handler) { + documentHandlers.remove(handler); } /** - * {@inheritDoc} + * Removes all event handlers for this document. */ - @Override public void removeAllHandlers() { - eventDispatcher.removeAllHandlers(); + documentHandlers.clear(); } /** @@ -857,6 +949,7 @@ public void close() { ITextCoreProductData.getInstance())); // The event will prepare document for flushing, i.e. will set an appropriate producer line manager.onEvent(new FlushPdfDocumentEvent(this)); + dispatchEvent(new PdfDocumentEvent(PdfDocumentEvent.START_DOCUMENT_CLOSING)); updateXmpMetadata(); // In PDF 2.0, all the values except CreationDate and ModDate are deprecated. Remove them now @@ -865,16 +958,16 @@ public void close() { getDocumentInfo().getPdfObject().remove(deprecatedKey); } } - if (getXmpMetadata() != null) { + if (getXmpMetadataBytes() != null) { PdfStream xmp = catalog.getPdfObject().getAsStream(PdfName.Metadata); if (isAppendMode() && xmp != null && !xmp.isFlushed() && xmp.getIndirectReference() != null) { // Use existing object for append mode - xmp.setData(xmpMetadata); + xmp.setData(getXmpMetadataBytes()); xmp.setModified(); } else { // Create new object xmp = (PdfStream) new PdfStream().makeIndirect(this); - xmp.getOutputStream().write(xmpMetadata); + xmp.getOutputStream().write(getXmpMetadataBytes()); catalog.getPdfObject().put(PdfName.Metadata, xmp); catalog.setModified(); } @@ -891,7 +984,7 @@ public void close() { catalog.getPdfObject().put(PdfName.OCProperties, catalog.getOCProperties(false).getPdfObject()); } - checkIsoConformance(); + checkIsoConformance(new PdfDocumentValidationContext(this, getDocumentFonts())); if (getNumberOfPages() == 0) { // Add new page here, not in PdfPagesTree#generateTree method, so that any page @@ -901,6 +994,14 @@ public void close() { PdfObject crypto = null; final Set forbiddenToFlush = new HashSet<>(); + documentInfoHelper.adjustDocumentInfo(getDocumentInfo()); + // The following 2 operators prevent the possible inconsistency between root and info + // entries existing in the trailer object and corresponding fields. This inconsistency + // may appear when user gets trailer and explicitly sets new root or info dictionaries. + if (documentInfoHelper.shouldAddDocumentInfoToTrailer()) { + trailer.put(PdfName.Info, getDocumentInfo().getPdfObject()); + } + trailer.put(PdfName.Root, catalog.getPdfObject()); if (properties.appendMode) { if (structTreeRoot != null) { tryFlushTagStructure(true); @@ -921,11 +1022,13 @@ public void close() { } PdfObject pageRoot = catalog.getPageTree().generateTree(); - flushInfoDictionary(properties.appendMode); if (catalog.getPdfObject().isModified() || pageRoot.isModified()) { catalog.put(PdfName.Pages, pageRoot); catalog.getPdfObject().flush(false); } + if (getDocumentInfo().getPdfObject().isModified()) { + getDocumentInfo().getPdfObject().flush(false); + } flushFonts(); if (writer.crypto != null) { @@ -973,8 +1076,8 @@ public void close() { if (structTreeRoot != null) { tryFlushTagStructure(false); } - flushInfoDictionary(properties.appendMode); catalog.getPdfObject().flush(false); + getDocumentInfo().getPdfObject().flush(false); flushFonts(); if (writer.crypto != null) { @@ -1003,18 +1106,13 @@ public void close() { // To avoid encryption of XrefStream and Encryption dictionary remove crypto. // NOTE. No need in reverting, because it is the last operation with the document. writer.crypto = null; - checkIsoConformance(crypto, IsoKey.CRYPTO); + checkIsoConformance(new CryptoValidationContext(crypto)); if (!properties.appendMode && crypto != null) { // no need to flush crypto in append mode, it shall not have changed in this case crypto.flush(false); } - // The following operator prevents the possible inconsistency between root and info - // entries existing in the trailer object and corresponding fields. This inconsistency - // may appear when user gets trailer and explicitly sets new root or info dictionaries. - trailer.put(PdfName.Root, catalog.getPdfObject()); - //By this time original and modified document ids should always be not null due to initializing in // either writer properties, or in the writer init section on document open or from pdfreader. So we // shouldn't worry about it being null next @@ -1023,21 +1121,22 @@ public void close() { xref.writeXrefTableAndTrailer(this, fileId, crypto); writer.flush(); if (writer.getOutputStream() instanceof CountOutputStream) { - long amountOfBytes = ((CountOutputStream) writer.getOutputStream()).getAmountOfWrittenBytes(); + final long amountOfBytes = ((CountOutputStream) writer.getOutputStream()).getAmountOfWrittenBytes(); + manager.onEvent(new SizeOfPdfStatisticsEvent(amountOfBytes, ITextCoreProductData.getInstance())); + } else if (writer.getOutputStream() instanceof ByteArrayOutputStream) { + final long amountOfBytes = ((ByteArrayOutputStream) writer.getOutputStream()).size(); manager.onEvent(new SizeOfPdfStatisticsEvent(amountOfBytes, ITextCoreProductData.getInstance())); } } catalog.getPageTree().clearPageRefs(); - removeAllHandlers(); } catch (IOException e) { throw new PdfException(KernelExceptionMessageConstant.CANNOT_CLOSE_DOCUMENT, e, this); } finally { if (writer != null && isCloseWriter()) { try { - writer.close(); + writer.finish(); } catch (Exception e) { - Logger logger = LoggerFactory.getLogger(PdfDocument.class); - logger.error(IoLogMessageConstant.PDF_WRITER_CLOSING_FAILED, e); + LOGGER.error(IoLogMessageConstant.PDF_WRITER_CLOSING_FAILED, e); } } @@ -1045,8 +1144,7 @@ public void close() { try { reader.close(); } catch (Exception e) { - Logger logger = LoggerFactory.getLogger(PdfDocument.class); - logger.error(IoLogMessageConstant.PDF_READER_CLOSING_FAILED, e); + LOGGER.error(IoLogMessageConstant.PDF_READER_CLOSING_FAILED, e); } } @@ -1153,15 +1251,14 @@ public TagStructureContext getTagStructureContext() { public List copyPagesTo(int pageFrom, int pageTo, PdfDocument toDocument, int insertBeforePage) { return copyPagesTo(pageFrom, pageTo, toDocument, insertBeforePage, null); } - - + /** - * Get the {@link IConformanceLevel} + * Get the {@link PdfConformance} * - * @return the {@link IConformanceLevel} will be null if the document does not have a conformance level specified + * @return the document conformance */ - public IConformanceLevel getConformanceLevel() { - return null; + public PdfConformance getConformance() { + return pdfConformance; } /** @@ -1355,8 +1452,7 @@ public List copyPagesTo(List pagesToCopy, PdfDocument toDocume ((IPdfPageFormCopier) copier).recreateAcroformToProcessCopiedFields(toDocument); } } else { - Logger logger = LoggerFactory.getLogger(PdfDocument.class); - logger.warn(IoLogMessageConstant.NOT_TAGGED_PAGES_IN_TAGGED_DOCUMENT); + LOGGER.warn(IoLogMessageConstant.NOT_TAGGED_PAGES_IN_TAGGED_DOCUMENT); } } if (catalog.isOutlineMode()) { @@ -1523,7 +1619,7 @@ public void addNamedDestination(String key, PdfObject value) { public void addNamedDestination(PdfString key, PdfObject value) { checkClosingStatus(); if (value.isArray() && ((PdfArray) value).get(0).isNumber()) { - LoggerFactory.getLogger(PdfDocument.class).warn(IoLogMessageConstant.INVALID_DESTINATION_TYPE); + LOGGER.warn(IoLogMessageConstant.INVALID_DESTINATION_TYPE); } catalog.addNamedDestination(key, value); } @@ -1577,39 +1673,7 @@ public void addOutputIntent(PdfOutputIntent outputIntent) { outputIntents.add(outputIntent.getPdfObject()); } - /** - * Checks whether PDF document conforms a specific standard. - * - * @param obj An object to conform. - * @param key type of object to conform. - */ - public void checkIsoConformance(Object obj, IsoKey key) { - checkIsoConformance(obj, key, null, null); - } - - /** - * Checks whether PDF document conforms a specific standard. - * - * @param obj an object to conform. - * @param key type of object to conform. - * @param resources {@link PdfResources} associated with an object to check. - * @param contentStream current content stream - */ - public void checkIsoConformance(Object obj, IsoKey key, PdfResources resources, PdfStream contentStream) { - checkIsoConformance(obj, key, resources, contentStream, null); - } - - /** - * Checks whether PDF document conforms a specific standard. - * - * @param obj an object to conform. - * @param key type of object to conform. - * @param resources {@link PdfResources} associated with an object to check. - * @param contentStream current content stream. - * @param extra extra data required for the check. - */ - public void checkIsoConformance(Object obj, IsoKey key, PdfResources resources, PdfStream contentStream, - Object extra) { + public void checkIsoConformance(IValidationContext validationContext) { if (!this.getDiContainer().isRegistered(ValidationContainer.class)) { return; } @@ -1617,17 +1681,7 @@ public void checkIsoConformance(Object obj, IsoKey key, PdfResources resources, if (container == null) { return; } - container.validate(obj, key, resources, contentStream, extra); - } - - /** - * Checks whether PDF document conforms a specific standard. - * Shall be overridden. - * - * @param gState a {@link CanvasGraphicsState} object to conform. - * @param resources {@link PdfResources} associated with an object to check. - */ - public void checkShowTextIsoConformance(CanvasGraphicsState gState, PdfResources resources) { + container.validate(validationContext); } /** @@ -1658,8 +1712,7 @@ public void addFileAttachment(String key, PdfFileSpec fs) { */ public void addAssociatedFile(String description, PdfFileSpec fs) { if (null == ((PdfDictionary) fs.getPdfObject()).get(PdfName.AFRelationship)) { - Logger logger = LoggerFactory.getLogger(PdfDocument.class); - logger.error(IoLogMessageConstant.ASSOCIATED_FILE_SPEC_SHALL_INCLUDE_AFRELATIONSHIP); + LOGGER.error(IoLogMessageConstant.ASSOCIATED_FILE_SPEC_SHALL_INCLUDE_AFRELATIONSHIP); } PdfArray afArray = catalog.getPdfObject().getAsArray(PdfName.AF); @@ -1714,7 +1767,7 @@ public PdfEncryptedPayloadDocument getEncryptedPayloadDocument() { } } } catch (PdfException e) { - LoggerFactory.getLogger(getClass()).error(e.getMessage()); + LOGGER.error(e.getMessage()); } } } @@ -1737,8 +1790,7 @@ public void setEncryptedPayload(PdfFileSpec fs) { throw new PdfException(KernelExceptionMessageConstant.CANNOT_SET_ENCRYPTED_PAYLOAD_TO_ENCRYPTED_DOCUMENT); } if (!PdfName.EncryptedPayload.equals(((PdfDictionary) fs.getPdfObject()).get(PdfName.AFRelationship))) { - LoggerFactory.getLogger(getClass()) - .error(IoLogMessageConstant.ENCRYPTED_PAYLOAD_FILE_SPEC_SHALL_HAVE_AFRELATIONSHIP_FILED_EQUAL_TO_ENCRYPTED_PAYLOAD); + LOGGER.error(IoLogMessageConstant.ENCRYPTED_PAYLOAD_FILE_SPEC_SHALL_HAVE_AFRELATIONSHIP_FILED_EQUAL_TO_ENCRYPTED_PAYLOAD); } PdfEncryptedPayload encryptedPayload = PdfEncryptedPayload.extractFrom(fs); if (encryptedPayload == null) { @@ -1747,8 +1799,7 @@ public void setEncryptedPayload(PdfFileSpec fs) { } PdfCollection collection = getCatalog().getCollection(); if (collection != null) { - LoggerFactory.getLogger(getClass()) - .warn(IoLogMessageConstant.COLLECTION_DICTIONARY_ALREADY_EXISTS_IT_WILL_BE_MODIFIED); + LOGGER.warn(IoLogMessageConstant.COLLECTION_DICTIONARY_ALREADY_EXISTS_IT_WILL_BE_MODIFIED); } else { collection = new PdfCollection(); getCatalog().setCollection(collection); @@ -1868,19 +1919,7 @@ public PdfFont getFont(PdfDictionary dictionary) { * @return instance of {@link PdfFont} or {@code null} on error. */ public PdfFont getDefaultFont() { - if (defaultFont == null) { - try { - defaultFont = PdfFontFactory.createFont(); - if (writer != null) { - defaultFont.makeIndirect(this); - } - } catch (IOException e) { - Logger logger = LoggerFactory.getLogger(PdfDocument.class); - logger.error(IoLogMessageConstant.EXCEPTION_WHILE_CREATING_DEFAULT_FONT, e); - defaultFont = null; - } - } - return defaultFont; + return defaultFontStrategy.getFont(); } /** @@ -1994,34 +2033,6 @@ protected void storeDestinationToReaddress(PdfDestination destination, pendingDestinationMutations.add(new DestinationMutationInfo(destination, onPageAvailable, onPageNotAvailable)); } - /** - * Checks whether PDF document conforms to a specific standard. - */ - protected void checkIsoConformance() { - if (!this.getDiContainer().isRegistered(ValidationContainer.class)) { - return; - } - ValidationContainer container = this.getDiContainer().getInstance(ValidationContainer.class); - if (container == null) { - return; - } - ValidationContext context = new ValidationContext() - .withPdfDocument(this) - .withFonts(getDocumentFonts()); - container.validate(context); - } - - /** - * Mark an object with {@link PdfObject#MUST_BE_FLUSHED}. - * - * @param pdfObject an object to mark. - */ - protected void markObjectAsMustBeFlushed(PdfObject pdfObject) { - if (pdfObject.getIndirectReference() != null) { - pdfObject.getIndirectReference().setState(PdfObject.MUST_BE_FLUSHED); - } - } - /** * Flush an object. * @@ -2031,7 +2042,18 @@ protected void markObjectAsMustBeFlushed(PdfObject pdfObject) { * @throws IOException on error. */ protected void flushObject(PdfObject pdfObject, boolean canBeInObjStm) throws IOException { - writer.flushObject(pdfObject, canBeInObjStm); + boolean flushAllowed = true; + if (!isClosing && this.getDiContainer().isRegistered(ValidationContainer.class)) { + ValidationContainer container = this.getDiContainer().getInstance(ValidationContainer.class); + if (container != null) { + flushAllowed = container.isPdfObjectChecked(pdfObject); + } + } + if (isClosing || flushAllowed) { + writer.flushObject(pdfObject, canBeInObjStm); + } else if (pdfObject.getIndirectReference() != null) { + pdfObject.getIndirectReference().setState(PdfObject.MUST_BE_FLUSHED); + } } /** @@ -2042,6 +2064,11 @@ protected void flushObject(PdfObject pdfObject, boolean canBeInObjStm) throws IO * or {@code null} otherwise */ protected void open(PdfVersion newPdfVersion) { + if (properties != null){ + for (Class aClass : properties.dependencies.keySet()) { + diContainer.register(aClass, properties.dependencies.get(aClass)); + } + } this.fingerPrint = new FingerPrint(); this.encryptedEmbeddedStreamsHandler = new EncryptedEmbeddedStreamsHandler(this); @@ -2077,16 +2104,6 @@ protected void open(PdfVersion newPdfVersion) { } catalog = new PdfCatalog(catalogDictionary); updatePdfVersionFromCatalog(); - PdfStream xmpMetadataStream = catalog.getPdfObject().getAsStream(PdfName.Metadata); - if (xmpMetadataStream != null) { - xmpMetadata = xmpMetadataStream.getBytes(); - if (!this.getClass().equals(PdfDocument.class)) { - // TODO DEVSIX-5292 If somebody extends PdfDocument we have to initialize document info - // and conformance level to provide compatibility. This code block shall be removed - reader.getPdfAConformanceLevel(); - getDocumentInfo(); - } - } PdfDictionary str = catalog.getPdfObject().getAsDictionary(PdfName.StructTreeRoot); if (str != null) { @@ -2096,11 +2113,17 @@ protected void open(PdfVersion newPdfVersion) { throw new PdfException( KernelExceptionMessageConstant.APPEND_MODE_REQUIRES_A_DOCUMENT_WITHOUT_ERRORS_EVEN_IF_RECOVERY_IS_POSSIBLE); } + pdfConformance = reader.getPdfConformance(); } xref.initFreeReferencesList(this); if (writer != null) { + if (writer.properties.addPdfAXmpMetadata != null || writer.properties.addPdfUaXmpMetadata != null) { + pdfConformance = new PdfConformance(writer.properties.addPdfAXmpMetadata, + writer.properties.addPdfUaXmpMetadata); + } + enableByteArrayWritingMode(); if (reader != null && reader.hasXrefStm() && writer.properties.isFullCompression == null) { - writer.properties.isFullCompression = true; + writer.properties.isFullCompression = Boolean.TRUE; } if (reader != null && !reader.isOpenedWithFullPermission()) { throw new BadPasswordException(BadPasswordException.PdfReaderNotOpenedWithOwnerPassword); @@ -2111,7 +2134,8 @@ protected void open(PdfVersion newPdfVersion) { writer.document = this; if (reader == null) { catalog = new PdfCatalog(this); - info = new PdfDocumentInfo(this).addCreationDate(); + // initialize document info + getDocumentInfo().addCreationDate(); } getDocumentInfo().addModDate(); @@ -2120,7 +2144,7 @@ protected void open(PdfVersion newPdfVersion) { } // We keep the original trailer of the document to preserve the original document keys, // but we have to remove all standard keys that can occur in the trailer to avoid invalid pdfs - if (trailer.size() > 0) { + if (!trailer.isEmpty()) { for (final PdfName key : PdfDocument.PDF_NAMES_TO_REMOVE_FROM_ORIGINAL_TRAILER) { trailer.remove(key); } @@ -2176,6 +2200,10 @@ protected void open(PdfVersion newPdfVersion) { overrideFullCompressionInWriterProperties(writer.properties, reader.hasXrefStm()); writer.crypto = reader.decrypt; + if (writer.crypto != null) { + writer.crypto.checkEncryptionRequirements(this); + writer.crypto.configureEncryptionParametersFromWriter(this); + } if (newPdfVersion != null) { // In PDF 1.4, a PDF version can also be specified in the Version entry of the document catalog, @@ -2210,16 +2238,8 @@ protected void open(PdfVersion newPdfVersion) { if (!embeddedStreamsSavedOnReading && writer.crypto.isEmbeddedFilesOnly()) { encryptedEmbeddedStreamsHandler.storeAllEmbeddedStreams(); } - if (writer.crypto.getCryptoMode() < EncryptionConstants.ENCRYPTION_AES_256) { - VersionConforming.validatePdfVersionForDeprecatedFeatureLogWarn(this, PdfVersion.PDF_2_0, - VersionConforming.DEPRECATED_ENCRYPTION_ALGORITHMS); - } else if (writer.crypto.getCryptoMode() == EncryptionConstants.ENCRYPTION_AES_256) { - PdfNumber r = writer.crypto.getPdfObject().getAsNumber(PdfName.R); - if (r != null && r.intValue() == 5) { - VersionConforming.validatePdfVersionForDeprecatedFeatureLogWarn(this, PdfVersion.PDF_2_0, - VersionConforming.DEPRECATED_AES256_REVISION); - } - } + writer.crypto.checkEncryptionRequirements(this); + writer.crypto.configureEncryptionParametersFromWriter(this); } } if (EventConfirmationType.ON_DEMAND == event.getConfirmationType()) { @@ -2231,31 +2251,6 @@ protected void open(PdfVersion newPdfVersion) { } } - /** - * Adds custom XMP metadata extension. Useful for PDF/UA, ZUGFeRD, etc. - * - * @param xmpMeta {@link XMPMeta} to add custom metadata to. - */ - protected void addCustomMetadataExtensions(XMPMeta xmpMeta) { - } - - /** - * Flush info dictionary if needed. - * - * @param appendMode true if the document is edited in append mode. - */ - protected void flushInfoDictionary(boolean appendMode) { - PdfObject infoDictObj = getDocumentInfo().getPdfObject(); - if (!appendMode || infoDictObj.isModified()) { - infoDictObj.flush(false); - } - - // The following operator prevents the possible inconsistency between root and info - // entries existing in the trailer object and corresponding fields. This inconsistency - // may appear when user gets trailer and explicitly sets new root or info dictionaries. - trailer.put(PdfName.Info, infoDictObj); - } - /** * Updates XMP metadata. * Shall be overridden. @@ -2264,13 +2259,13 @@ protected void updateXmpMetadata() { try { // We add PDF producer info in any case, and the valid way to do it for PDF 2.0 in only in metadata, not // in the info dictionary. - if (xmpMetadata != null || writer.properties.addXmpMetadata + if (getXmpMetadataBytes() != null || writer.properties.addXmpMetadata || pdfVersion.compareTo(PdfVersion.PDF_2_0) >= 0) { - setXmpMetadata(updateDefaultXmpMetadata()); + final XMPMeta xmpMeta = updateDefaultXmpMetadata(); + setXmpMetadata(xmpMeta); } } catch (XMPException e) { - Logger logger = LoggerFactory.getLogger(PdfDocument.class); - logger.error(IoLogMessageConstant.EXCEPTION_WHILE_UPDATING_XMPMETADATA, e); + LOGGER.error(IoLogMessageConstant.EXCEPTION_WHILE_UPDATING_XMPMETADATA, e); } } @@ -2282,15 +2277,9 @@ protected void updateXmpMetadata() { * @throws XMPException if the file is not well-formed XML or if parsing fails. */ protected XMPMeta updateDefaultXmpMetadata() throws XMPException { - XMPMeta xmpMeta = XMPMetaFactory.parseFromBuffer(getXmpMetadata(true)); + XMPMeta xmpMeta = getXmpMetadata(true); XmpMetaInfoConverter.appendDocumentInfoToMetadata(getDocumentInfo(), xmpMeta); - - if (isTagged() && writer.properties.addUAXmpMetadata && !isXmpMetaHasProperty(xmpMeta, XMPConst.NS_PDFUA_ID, - XMPConst.PART)) { - xmpMeta.setPropertyInteger(XMPConst.NS_PDFUA_ID, XMPConst.PART, 1, - new PropertyOptions(PropertyOptions.SEPARATE_NODE)); - } - + PdfConformance.setConformanceToXmp(xmpMeta, pdfConformance); return xmpMeta; } @@ -2391,8 +2380,7 @@ protected void tryInitTagStructure(PdfDictionary str) { } catch (Exception e) { structTreeRoot = null; structParentIndex = -1; - Logger logger = LoggerFactory.getLogger(PdfDocument.class); - logger.error(IoLogMessageConstant.TAG_STRUCTURE_INIT_FAILED, e); + LOGGER.error(IoLogMessageConstant.TAG_STRUCTURE_INIT_FAILED, e); } } @@ -2417,6 +2405,19 @@ boolean hasAcroForm() { return getCatalog().getPdfObject().containsKey(PdfName.AcroForm); } + private void enableByteArrayWritingMode() { + if (properties.appendMode || properties.preserveEncryption) { + if (reader.decrypt != null && reader.decrypt.getMacContainer() != null) { + writer.enableByteArrayWritingMode(); + } + } else if (writer.properties.encryptionProperties != null && + writer.properties.encryptionProperties.macProperties != null && + writer.properties.pdfVersion != null && + PdfVersion.PDF_2_0.compareTo(writer.properties.pdfVersion) <= 0) { + writer.enableByteArrayWritingMode(); + } + } + private void tryFlushTagStructure(boolean isAppendMode) { try { if (tagStructureContext != null) { @@ -2606,8 +2607,7 @@ private void readDocumentIds() { private void processReadingError(String errorMessage) { if (StrictnessLevel.CONSERVATIVE.isStricter(reader.getStrictnessLevel())) { - Logger logger = LoggerFactory.getLogger(PdfDocument.class); - logger.error(errorMessage); + LOGGER.error(errorMessage); } else { throw new PdfException(errorMessage); } @@ -2616,19 +2616,13 @@ private void processReadingError(String errorMessage) { private static void overrideFullCompressionInWriterProperties(WriterProperties properties, boolean readerHasXrefStream) { if (Boolean.TRUE == properties.isFullCompression && !readerHasXrefStream) { - Logger logger = LoggerFactory.getLogger(PdfDocument.class); - logger.warn(KernelLogMessageConstant.FULL_COMPRESSION_APPEND_MODE_XREF_TABLE_INCONSISTENCY); + LOGGER.warn(KernelLogMessageConstant.FULL_COMPRESSION_APPEND_MODE_XREF_TABLE_INCONSISTENCY); } else if (Boolean.FALSE == properties.isFullCompression && readerHasXrefStream) { - Logger logger = LoggerFactory.getLogger(PdfDocument.class); - logger.warn(KernelLogMessageConstant.FULL_COMPRESSION_APPEND_MODE_XREF_STREAM_INCONSISTENCY); + LOGGER.warn(KernelLogMessageConstant.FULL_COMPRESSION_APPEND_MODE_XREF_STREAM_INCONSISTENCY); } properties.isFullCompression = readerHasXrefStream; } - private static boolean isXmpMetaHasProperty(XMPMeta xmpMeta, String schemaNS, String propName) throws XMPException { - return xmpMeta.getProperty(schemaNS, propName) != null; - } - private static class DestinationMutationInfo { private final PdfDestination originalDestination; private final Consumer onDestinationAvailable; diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfDocumentInfo.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfDocumentInfo.java index ed003a2c44..a1790ee708 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfDocumentInfo.java +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfDocumentInfo.java @@ -28,11 +28,11 @@ This file is part of the iText (R) project. public class PdfDocumentInfo { - static final PdfName PDF20_DEPRECATED_KEYS[] = new PdfName[] {PdfName.Title, PdfName.Author, PdfName.Subject, PdfName.Keywords, - PdfName.Creator, PdfName.Producer, PdfName.Trapped}; + static final PdfName[] PDF20_DEPRECATED_KEYS = new PdfName[] {PdfName.Title, PdfName.Author, PdfName.Subject, + PdfName.Keywords, PdfName.Creator, PdfName.Producer, PdfName.Trapped}; - private PdfDictionary infoDictionary; + private final PdfDictionary infoDictionary; /** * Create a PdfDocumentInfo based on the passed PdfDictionary. @@ -46,15 +46,6 @@ public class PdfDocumentInfo { } } - /** - * Create a default, empty PdfDocumentInfo and link it to the passed PdfDocument - * - * @param pdfDocument document the info will belong to - */ - PdfDocumentInfo(PdfDocument pdfDocument) { - this(new PdfDictionary(), pdfDocument); - } - public PdfDocumentInfo setTitle(String title) { return put(PdfName.Title, new PdfString(title, PdfEncodings.UNICODE_BIG)); } diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfEncryption.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfEncryption.java index fae26ad61b..b6c60b740c 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfEncryption.java +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfEncryption.java @@ -29,17 +29,22 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.crypto.securityhandler.PubKeySecurityHandler; import com.itextpdf.kernel.crypto.securityhandler.PubSecHandlerUsingAes128; import com.itextpdf.kernel.crypto.securityhandler.PubSecHandlerUsingAes256; +import com.itextpdf.kernel.crypto.securityhandler.PubSecHandlerUsingAesGcm; import com.itextpdf.kernel.crypto.securityhandler.PubSecHandlerUsingStandard128; import com.itextpdf.kernel.crypto.securityhandler.PubSecHandlerUsingStandard40; import com.itextpdf.kernel.crypto.securityhandler.SecurityHandler; import com.itextpdf.kernel.crypto.securityhandler.StandardHandlerUsingAes128; import com.itextpdf.kernel.crypto.securityhandler.StandardHandlerUsingAes256; +import com.itextpdf.kernel.crypto.securityhandler.StandardHandlerUsingAesGcm; import com.itextpdf.kernel.crypto.securityhandler.StandardHandlerUsingStandard128; import com.itextpdf.kernel.crypto.securityhandler.StandardHandlerUsingStandard40; import com.itextpdf.kernel.crypto.securityhandler.StandardSecurityHandler; import com.itextpdf.kernel.exceptions.KernelExceptionMessageConstant; import com.itextpdf.kernel.exceptions.PdfException; +import com.itextpdf.kernel.mac.IMacContainerLocator; +import com.itextpdf.kernel.mac.MacValidationException; import com.itextpdf.kernel.security.IExternalDecryptionProcess; +import com.itextpdf.kernel.mac.AbstractMacIntegrityProtector; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -54,19 +59,21 @@ public class PdfEncryption extends PdfObjectWrapper { private static final int STANDARD_ENCRYPTION_128 = 3; private static final int AES_128 = 4; private static final int AES_256 = 5; + private static final int AES_GCM = 6; private static final int DEFAULT_KEY_LENGTH = 40; + private static final int MAC_ENABLED = ~(1 << 12); + private static final int MAC_DISABLED = 1 << 12; private static long seq = SystemUtil.getTimeBasedSeed(); private int cryptoMode; - private Long permissions; + private Integer permissions; private boolean encryptMetadata; private boolean embeddedFilesOnly; - private byte[] documentId; - private SecurityHandler securityHandler; + private AbstractMacIntegrityProtector macContainer; /** * Creates the encryption. @@ -102,39 +109,49 @@ public class PdfEncryption extends PdfObjectWrapper { * {@link EncryptionConstants#EMBEDDED_FILES_ONLY} as false; * @param documentId document id which will be used for encryption * @param version the {@link PdfVersion} of the target document for encryption + * @param macContainer {@link AbstractMacIntegrityProtector} class for MAC integrity protection */ - public PdfEncryption(byte[] userPassword, byte[] ownerPassword, int permissions, int encryptionType, byte[] documentId, PdfVersion version) { + public PdfEncryption(byte[] userPassword, byte[] ownerPassword, int permissions, int encryptionType, + byte[] documentId, PdfVersion version, AbstractMacIntegrityProtector macContainer) { super(new PdfDictionary()); + this.macContainer = macContainer; this.documentId = documentId; if (version != null && version.compareTo(PdfVersion.PDF_2_0) >= 0) { permissions = fixAccessibilityPermissionPdf20(permissions); } + permissions = configureAccessibilityPermissionsForMac(permissions); int revision = setCryptoMode(encryptionType); switch (revision) { case STANDARD_ENCRYPTION_40: - StandardHandlerUsingStandard40 handlerStd40 = new StandardHandlerUsingStandard40(this.getPdfObject(), userPassword, ownerPassword, - permissions, encryptMetadata, embeddedFilesOnly, documentId); + StandardHandlerUsingStandard40 handlerStd40 = new StandardHandlerUsingStandard40(this.getPdfObject(), + userPassword, ownerPassword, permissions, encryptMetadata, embeddedFilesOnly, documentId); this.permissions = handlerStd40.getPermissions(); securityHandler = handlerStd40; break; case STANDARD_ENCRYPTION_128: - StandardHandlerUsingStandard128 handlerStd128 = new StandardHandlerUsingStandard128(this.getPdfObject(), userPassword, ownerPassword, - permissions, encryptMetadata, embeddedFilesOnly, documentId); + StandardHandlerUsingStandard128 handlerStd128 = new StandardHandlerUsingStandard128(this.getPdfObject(), + userPassword, ownerPassword, permissions, encryptMetadata, embeddedFilesOnly, documentId); this.permissions = handlerStd128.getPermissions(); securityHandler = handlerStd128; break; case AES_128: - StandardHandlerUsingAes128 handlerAes128 = new StandardHandlerUsingAes128(this.getPdfObject(), userPassword, ownerPassword, - permissions, encryptMetadata, embeddedFilesOnly, documentId); + StandardHandlerUsingAes128 handlerAes128 = new StandardHandlerUsingAes128(this.getPdfObject(), + userPassword, ownerPassword, permissions, encryptMetadata, embeddedFilesOnly, documentId); this.permissions = handlerAes128.getPermissions(); securityHandler = handlerAes128; break; case AES_256: - StandardHandlerUsingAes256 handlerAes256 = new StandardHandlerUsingAes256(this.getPdfObject(), userPassword, ownerPassword, - permissions, encryptMetadata, embeddedFilesOnly, version); + StandardHandlerUsingAes256 handlerAes256 = new StandardHandlerUsingAes256(this.getPdfObject(), + userPassword, ownerPassword, permissions, encryptMetadata, embeddedFilesOnly, version); this.permissions = handlerAes256.getPermissions(); securityHandler = handlerAes256; break; + case AES_GCM: + StandardHandlerUsingAesGcm handlerAesGcm = new StandardHandlerUsingAesGcm(this.getPdfObject(), userPassword, ownerPassword, + permissions, encryptMetadata, embeddedFilesOnly); + this.permissions = handlerAesGcm.getPermissions(); + securityHandler = handlerAesGcm; + break; } } @@ -172,31 +189,49 @@ public PdfEncryption(byte[] userPassword, byte[] ownerPassword, int permissions, * {@link EncryptionConstants#EMBEDDED_FILES_ONLY} as false; * * @param version the {@link PdfVersion} of the target document for encryption + * @param macContainer {@link AbstractMacIntegrityProtector} class for MAC integrity protection */ - public PdfEncryption(Certificate[] certs, int[] permissions, int encryptionType, PdfVersion version) { + public PdfEncryption(Certificate[] certs, int[] permissions, int encryptionType, PdfVersion version, + AbstractMacIntegrityProtector macContainer) { super(new PdfDictionary()); - if (version != null && version.compareTo(PdfVersion.PDF_2_0) >= 0) { - for (int i = 0; i < permissions.length; i++) { + this.macContainer = macContainer; + for (int i = 0; i < permissions.length; i++) { + if (version != null && version.compareTo(PdfVersion.PDF_2_0) >= 0) { permissions[i] = fixAccessibilityPermissionPdf20(permissions[i]); } + permissions[i] = configureAccessibilityPermissionsForMac(permissions[i]); } int revision = setCryptoMode(encryptionType); switch (revision) { case STANDARD_ENCRYPTION_40: - securityHandler = new PubSecHandlerUsingStandard40(this.getPdfObject(), certs, permissions, encryptMetadata, embeddedFilesOnly); + securityHandler = new PubSecHandlerUsingStandard40(this.getPdfObject(), certs, permissions, + encryptMetadata, embeddedFilesOnly); break; case STANDARD_ENCRYPTION_128: - securityHandler = new PubSecHandlerUsingStandard128(this.getPdfObject(), certs, permissions, encryptMetadata, embeddedFilesOnly); + securityHandler = new PubSecHandlerUsingStandard128(this.getPdfObject(), certs, permissions, + encryptMetadata, embeddedFilesOnly); break; case AES_128: - securityHandler = new PubSecHandlerUsingAes128(this.getPdfObject(), certs, permissions, encryptMetadata, embeddedFilesOnly); + securityHandler = new PubSecHandlerUsingAes128(this.getPdfObject(), certs, permissions, + encryptMetadata, embeddedFilesOnly); break; case AES_256: - securityHandler = new PubSecHandlerUsingAes256(this.getPdfObject(), certs, permissions, encryptMetadata, embeddedFilesOnly); + securityHandler = new PubSecHandlerUsingAes256(this.getPdfObject(), certs, permissions, + encryptMetadata, embeddedFilesOnly); + break; + case AES_GCM: + securityHandler = new PubSecHandlerUsingAesGcm(this.getPdfObject(), certs, permissions, encryptMetadata, embeddedFilesOnly); break; } } + /** + * Creates {@link PdfEncryption} instance based on already existing standard encryption dictionary. + * + * @param pdfDict {@link PdfDictionary}, which represents encryption dictionary + * @param password {@code byte[]}, which represents encryption password + * @param documentId original file ID, the first element in {@link PdfName#ID} key of trailer + */ public PdfEncryption(PdfDictionary pdfDict, byte[] password, byte[] documentId) { super(pdfDict); setForbidRelease(); @@ -205,31 +240,50 @@ public PdfEncryption(PdfDictionary pdfDict, byte[] password, byte[] documentId) int revision = readAndSetCryptoModeForStdHandler(pdfDict); switch (revision) { case STANDARD_ENCRYPTION_40: - StandardHandlerUsingStandard40 handlerStd40 = new StandardHandlerUsingStandard40(this.getPdfObject(), password, documentId, encryptMetadata); + StandardHandlerUsingStandard40 handlerStd40 = new StandardHandlerUsingStandard40(this.getPdfObject(), + password, documentId, encryptMetadata); permissions = handlerStd40.getPermissions(); securityHandler = handlerStd40; break; case STANDARD_ENCRYPTION_128: - StandardHandlerUsingStandard128 handlerStd128 = new StandardHandlerUsingStandard128(this.getPdfObject(), password, documentId, encryptMetadata); + StandardHandlerUsingStandard128 handlerStd128 = new StandardHandlerUsingStandard128(this.getPdfObject(), + password, documentId, encryptMetadata); permissions = handlerStd128.getPermissions(); securityHandler = handlerStd128; break; case AES_128: - StandardHandlerUsingAes128 handlerAes128 = new StandardHandlerUsingAes128(this.getPdfObject(), password, documentId, encryptMetadata); + StandardHandlerUsingAes128 handlerAes128 = new StandardHandlerUsingAes128(this.getPdfObject(), password, + documentId, encryptMetadata); permissions = handlerAes128.getPermissions(); securityHandler = handlerAes128; break; case AES_256: - StandardHandlerUsingAes256 aes256Handler = new StandardHandlerUsingAes256(this.getPdfObject(), password); + StandardHandlerUsingAes256 aes256Handler = new StandardHandlerUsingAes256(this.getPdfObject(), + password); permissions = aes256Handler.getPermissions(); encryptMetadata = aes256Handler.isEncryptMetadata(); securityHandler = aes256Handler; break; + case AES_GCM: + StandardHandlerUsingAesGcm aesGcmHandler = new StandardHandlerUsingAesGcm(this.getPdfObject(), password); + permissions = aesGcmHandler.getPermissions(); + encryptMetadata = aesGcmHandler.isEncryptMetadata(); + securityHandler = aesGcmHandler; + break; } } + /** + * Creates {@link PdfEncryption} instance based on already existing public encryption dictionary. + * + * @param pdfDict {@link PdfDictionary}, which represents encryption dictionary + * @param certificateKey the recipient private {@link Key} to the certificate + * @param certificate the recipient {@link Certificate}, which serves as recipient identifier + * @param certificateKeyProvider the certificate key provider id for {@link java.security.Security#getProvider} + * @param externalDecryptionProcess {@link IExternalDecryptionProcess} the external decryption process to be used + */ public PdfEncryption(PdfDictionary pdfDict, Key certificateKey, Certificate certificate, - String certificateKeyProvider, IExternalDecryptionProcess externalDecryptionProcess) { + String certificateKeyProvider, IExternalDecryptionProcess externalDecryptionProcess) { super(pdfDict); setForbidRelease(); int revision = readAndSetCryptoModeForPubSecHandler(pdfDict); @@ -250,6 +304,10 @@ public PdfEncryption(PdfDictionary pdfDict, Key certificateKey, Certificate cert securityHandler = new PubSecHandlerUsingAes256(this.getPdfObject(), certificateKey, certificate, certificateKeyProvider, externalDecryptionProcess, encryptMetadata); break; + case AES_GCM: + securityHandler = new PubSecHandlerUsingAesGcm(this.getPdfObject(), certificateKey, certificate, + certificateKeyProvider, externalDecryptionProcess, encryptMetadata); + break; } } @@ -274,32 +332,17 @@ public static byte[] generateNewDocumentId() { * * @param id the first id * @param modified whether the document has been changed or not - * @return PdfObject containing the two entries. + * + * @return PdfObject containing the two entries */ public static PdfObject createInfoId(byte[] id, boolean modified) { - if ( modified ) { - return createInfoId(id, generateNewDocumentId()); + if (modified) { + return createInfoId(id, generateNewDocumentId(), false); } else { - return createInfoId(id, id); + return createInfoId(id, id, false); } } - /** - * Creates a PdfLiteral that contains an array of two id entries. These entries are both hexadecimal - * strings containing 16 hex characters. The first entry is the original id, the second entry - * should be different from the first one if the document has changed. - * - * @param firstId the first id - * @param secondId the second id - * - * @return PdfObject containing the two entries. - * @deprecated Use {@link #createInfoId(byte[], byte[], boolean)} instead - */ - @Deprecated - public static PdfObject createInfoId(byte[] firstId, byte[] secondId) { - return createInfoId(firstId, secondId, false); - } - /** * Creates a PdfLiteral that contains an array of two id entries. These entries are both hexadecimal * strings containing up to 16 hex characters. The first entry is the original id, the second entry @@ -324,11 +367,13 @@ public static PdfObject createInfoId(byte[] firstId, byte[] secondId, boolean pr ByteBuffer buf = new ByteBuffer(90); buf.append('[').append('<'); - for (int k = 0; k < firstId.length; ++k) - buf.appendHex(firstId[k]); + for (byte value : firstId) { + buf.appendHex(value); + } buf.append('>').append('<'); - for (int k = 0; k < secondId.length; ++k) - buf.appendHex(secondId[k]); + for (byte b : secondId) { + buf.appendHex(b); + } buf.append('>').append(']'); return new PdfLiteral(buf.toByteArray()); @@ -349,7 +394,7 @@ private static byte[] padByteArrayTo16(byte[] documentId) { * * @return the encryption permissions, an unsigned 32-bit quantity. */ - public Long getPermissions() { + public Integer getPermissions() { return permissions; } @@ -363,6 +408,16 @@ public int getCryptoMode() { return cryptoMode; } + /** + * Gets encryption algorithm. + * + * @return the encryption algorithm + * @see EncryptionConstants + */ + public int getEncryptionAlgorithm() { + return cryptoMode & EncryptionConstants.ENCRYPTION_MASK; + } + public boolean isMetadataEncrypted() { return encryptMetadata; } @@ -467,7 +522,8 @@ private int setCryptoMode(int mode) { private int setCryptoMode(int mode, int length) { int revision; cryptoMode = mode; - encryptMetadata = (mode & EncryptionConstants.DO_NOT_ENCRYPT_METADATA) != EncryptionConstants.DO_NOT_ENCRYPT_METADATA; + encryptMetadata = + (mode & EncryptionConstants.DO_NOT_ENCRYPT_METADATA) != EncryptionConstants.DO_NOT_ENCRYPT_METADATA; embeddedFilesOnly = (mode & EncryptionConstants.EMBEDDED_FILES_ONLY) == EncryptionConstants.EMBEDDED_FILES_ONLY; mode &= EncryptionConstants.ENCRYPTION_MASK; switch (mode) { @@ -493,6 +549,10 @@ private int setCryptoMode(int mode, int length) { setKeyLength(256); revision = AES_256; break; + case EncryptionConstants.ENCRYPTION_AES_GCM: + setKeyLength(256); + revision = AES_GCM; + break; default: throw new PdfException(KernelExceptionMessageConstant.NO_VALID_ENCRYPTION_MODE); } @@ -552,6 +612,32 @@ private int readAndSetCryptoModeForStdHandler(PdfDictionary encDict) { cryptoMode |= EncryptionConstants.EMBEDDED_FILES_ONLY; } break; + case 7: + // (ISO/TS 32003) The security handler defines the use of encryption + // and decryption in the same way as when the value of R is 6, and declares at least + // one crypt filter using the AESV4 method. + PdfDictionary cfDic = encDict.getAsDictionary(PdfName.CF); + if (cfDic == null) { + throw new PdfException(KernelExceptionMessageConstant.CF_NOT_FOUND_ENCRYPTION); + } + cfDic = (PdfDictionary) cfDic.get(PdfName.StdCF); + if (cfDic == null) { + throw new PdfException(KernelExceptionMessageConstant.STDCF_NOT_FOUND_ENCRYPTION); + } + if (PdfName.AESV4.equals(cfDic.get(PdfName.CFM))) { + cryptoMode = EncryptionConstants.ENCRYPTION_AES_GCM; + length = 256; + } else { + throw new PdfException(KernelExceptionMessageConstant.NO_COMPATIBLE_ENCRYPTION_FOUND); + } + PdfBoolean em7 = encDict.getAsBoolean(PdfName.EncryptMetadata); + if (em7 != null && !em7.getValue()) { + cryptoMode |= EncryptionConstants.DO_NOT_ENCRYPT_METADATA; + } + if (embeddedFilesOnlyMode) { + cryptoMode |= EncryptionConstants.EMBEDDED_FILES_ONLY; + } + break; default: throw new PdfException(KernelExceptionMessageConstant.UNKNOWN_ENCRYPTION_TYPE_R) .setMessageParams(rValue); @@ -563,7 +649,7 @@ private int readAndSetCryptoModeForStdHandler(PdfDictionary encDict) { private int readAndSetCryptoModeForPubSecHandler(PdfDictionary encDict) { int cryptoMode; - int length = 0; + int length; PdfNumber vValue = encDict.getAsNumber(PdfName.V); if (vValue == null) @@ -610,12 +696,46 @@ private int readAndSetCryptoModeForPubSecHandler(PdfDictionary encDict) { cryptoMode |= EncryptionConstants.EMBEDDED_FILES_ONLY; } break; + case 6: + // (ISO/TS 32003) The security handler defines the use of encryption + // and decryption in the same way as when the value of V is 5, and declares at least + // one crypt filter using the AESV4 method. + PdfDictionary cfDic = encDict.getAsDictionary(PdfName.CF); + if (cfDic == null) { + throw new PdfException(KernelExceptionMessageConstant.CF_NOT_FOUND_ENCRYPTION); + } + cfDic = (PdfDictionary) cfDic.get(PdfName.DefaultCryptFilter); + if (cfDic == null) { + throw new PdfException(KernelExceptionMessageConstant.DEFAULT_CRYPT_FILTER_NOT_FOUND_ENCRYPTION); + } + if (PdfName.AESV4.equals(cfDic.get(PdfName.CFM))) { + cryptoMode = EncryptionConstants.ENCRYPTION_AES_GCM; + length = 256; + } else { + throw new PdfException(KernelExceptionMessageConstant.NO_COMPATIBLE_ENCRYPTION_FOUND); + } + PdfBoolean encrM = cfDic.getAsBoolean(PdfName.EncryptMetadata); + if (encrM != null && !encrM.getValue()) { + cryptoMode |= EncryptionConstants.DO_NOT_ENCRYPT_METADATA; + } + if (embeddedFilesOnlyMode) { + cryptoMode |= EncryptionConstants.EMBEDDED_FILES_ONLY; + } + break; default: throw new PdfException(KernelExceptionMessageConstant.UNKNOWN_ENCRYPTION_TYPE_V, vValue); } return setCryptoMode(cryptoMode, length); } + private int configureAccessibilityPermissionsForMac(int permissions) { + if (macContainer == null) { + return permissions | MAC_DISABLED; + } else { + return permissions & MAC_ENABLED; + } + } + static boolean readEmbeddedFilesOnlyFromEncryptDictionary(PdfDictionary encDict) { PdfName embeddedFilesFilter = encDict.getAsName(PdfName.EFF); boolean encryptEmbeddedFiles = !PdfName.Identity.equals(embeddedFilesFilter) && embeddedFilesFilter != null; @@ -633,7 +753,7 @@ static boolean readEmbeddedFilesOnlyFromEncryptDictionary(PdfDictionary encDict) return false; } - private int fixAccessibilityPermissionPdf20(int permissions) { + private static int fixAccessibilityPermissionPdf20(int permissions) { // This bit was previously used to determine whether // content could be extracted for the purposes of accessibility, // however, that restriction has been deprecated in PDF 2.0. PDF @@ -643,4 +763,125 @@ private int fixAccessibilityPermissionPdf20(int permissions) { return permissions | EncryptionConstants.ALLOW_SCREENREADERS; } + void checkEncryptionRequirements(PdfDocument document) { + if (macContainer != null) { + if (document.getPdfVersion() == null || document.getPdfVersion().compareTo(PdfVersion.PDF_2_0) < 0) { + throw new PdfException(KernelExceptionMessageConstant.MAC_FOR_PDF_2); + } + if (this.getPdfObject().getAsNumber(PdfName.V) != null && + this.getPdfObject().getAsNumber(PdfName.V).intValue() < 5) { + throw new PdfException(KernelExceptionMessageConstant.MAC_FOR_ENCRYPTION_5); + } + } + + final int encryption = getEncryptionAlgorithm(); + if (encryption < EncryptionConstants.ENCRYPTION_AES_256) { + VersionConforming.validatePdfVersionForDeprecatedFeatureLogWarn(document, PdfVersion.PDF_2_0, + VersionConforming.DEPRECATED_ENCRYPTION_ALGORITHMS); + } else if (encryption == EncryptionConstants.ENCRYPTION_AES_256) { + PdfNumber r = getPdfObject().getAsNumber(PdfName.R); + if (r != null && r.intValue() == 5) { + VersionConforming.validatePdfVersionForDeprecatedFeatureLogWarn(document, PdfVersion.PDF_2_0, + VersionConforming.DEPRECATED_AES256_REVISION); + } + } else if (encryption == EncryptionConstants.ENCRYPTION_AES_GCM) { + VersionConforming.validatePdfVersionForNotSupportedFeatureLogError(document, PdfVersion.PDF_2_0, + VersionConforming.NOT_SUPPORTED_AES_GCM); + } + } + + void configureEncryptionParametersFromWriter(PdfDocument document) { + if (macContainer != null) { + macContainer.setFileEncryptionKey(securityHandler.getMkey().length == 0 ? + securityHandler.getNextObjectKey() : securityHandler.getMkey()); + + document.getDiContainer().getInstance(IMacContainerLocator.class).locateMacContainer(macContainer); + document.getCatalog().addDeveloperExtension(PdfDeveloperExtension.ISO_32004); + PdfString kdfSalt = getPdfObject().getAsString(PdfName.KDFSalt); + if (kdfSalt == null) { + getPdfObject().put(PdfName.KDFSalt, new PdfString(macContainer.getKdfSalt()).setHexWriting(true)); + getPdfObject().setModified(); + } + } else { + document.getCatalog().removeDeveloperExtension(PdfDeveloperExtension.ISO_32004); + } + + if (getEncryptionAlgorithm() == EncryptionConstants.ENCRYPTION_AES_GCM) { + document.getCatalog().addDeveloperExtension(PdfDeveloperExtension.ISO_32003); + } else { + document.getCatalog().removeDeveloperExtension(PdfDeveloperExtension.ISO_32003); + } + } + + AbstractMacIntegrityProtector getMacContainer() { + return macContainer; + } + + void configureEncryptionParametersFromReader(PdfDocument document, PdfDictionary trailer) { + PdfVersion sourceVersion = document.getReader().headerPdfVersion; + PdfVersion destVersion = sourceVersion; + if (document.getWriter() != null && document.getWriter().getProperties().pdfVersion != null) { + destVersion = document.getWriter().getProperties().pdfVersion; + } + try { + if (trailer.getAsDictionary(PdfName.AuthCode) != null) { + macContainer = document.getDiContainer().getInstance(IMacContainerLocator.class) + .createMacIntegrityProtector(document, trailer.getAsDictionary(PdfName.AuthCode)); + macContainer.setFileEncryptionKey(securityHandler.getMkey().length == 0 ? + securityHandler.getNextObjectKey() : securityHandler.getMkey()); + PdfString kdfSalt = getPdfObject().getAsString(PdfName.KDFSalt); + if (kdfSalt != null) { + macContainer.setKdfSalt(kdfSalt.getValueBytes()); + } + macContainer.validateMacToken(); + + // Disable MAC for writing if explicitly requested. In append mode we cannot disable it because it will + // remove MAC protection from all previous revisions also for knowledgeable attackers + // TODO DEVSIX-8635 - Verify MAC permission and embed MAC in stamping mode for public key encryption + if (document.properties.disableMac && !document.properties.appendMode && + securityHandler instanceof StandardSecurityHandler) { + macContainer = null; + updateMacPermission(); + } + } else if (PdfVersion.PDF_2_0.compareTo(destVersion) <= 0 && + permissions != null && (permissions & MAC_DISABLED) == 0) { + // TODO DEVSIX-8635 - Verify MAC permission and embed MAC in stamping mode for public key encryption + throw new MacValidationException(KernelExceptionMessageConstant.MAC_PERMS_WITHOUT_MAC); + } else if (!document.properties.disableMac && !document.properties.appendMode && + securityHandler instanceof StandardSecurityHandler) { + // TODO DEVSIX-8635 - Verify MAC permission and embed MAC in stamping mode for public key encryption + + // This is the branch responsible for embedding MAC into the documents without MAC + // Do not embed MAC in append mode as it does not add extra security + + PdfNumber vValue = getPdfObject().getAsNumber(PdfName.V); + if (vValue == null) { + throw new PdfException(KernelExceptionMessageConstant.ILLEGAL_V_VALUE); + } + final int v = vValue.intValue(); + // We do not support MAC for increasing PDF version to 2.0 (old encryption do not support it) + // and decreasing from 2.0 (not supported by the spec) + // v >= 5 stands for supported encryption algorithms for MAC being used + if (PdfVersion.PDF_2_0.compareTo(destVersion) <= 0 && PdfVersion.PDF_2_0.compareTo(sourceVersion) <= 0 + && v >= 5) { + macContainer = document.getDiContainer().getInstance(IMacContainerLocator.class) + .createMacIntegrityProtector(document, EncryptionProperties.DEFAULT_MAC_PROPERTIES); + + updateMacPermission(); + } + } + } catch (MacValidationException exception) { + document.getDiContainer().getInstance(IMacContainerLocator.class).handleMacValidationError(exception); + } + } + + private void updateMacPermission() { + // We don't parse permissions on reading for PubSec currently + if (permissions != null) { + permissions = configureAccessibilityPermissionsForMac(permissions.intValue()); + if (securityHandler instanceof StandardSecurityHandler) { + ((StandardSecurityHandler) securityHandler).setPermissions(permissions.intValue(), this.getPdfObject()); + } + } + } } diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfLiteral.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfLiteral.java index 41f09ffb3a..f56370fdad 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfLiteral.java +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfLiteral.java @@ -29,8 +29,6 @@ This file is part of the iText (R) project. import java.util.Arrays; public class PdfLiteral extends PdfPrimitiveObject { - - private long position; public PdfLiteral(byte[] content) { diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfName.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfName.java index bc92ee4ee8..969d00eaec 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfName.java +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfName.java @@ -85,6 +85,7 @@ public class PdfName extends PdfPrimitiveObject implements Comparable { public static final PdfName Adobe_PubSec = createDirectName("Adobe.PubSec"); public static final PdfName AESV2 = createDirectName("AESV2"); public static final PdfName AESV3 = createDirectName("AESV3"); + public static final PdfName AESV4 = createDirectName("AESV4"); public static final PdfName AF = createDirectName("AF"); public static final PdfName AFRelationship = createDirectName("AFRelationship"); public static final PdfName After = createDirectName("After"); @@ -123,7 +124,9 @@ public class PdfName extends PdfPrimitiveObject implements Comparable { public static final PdfName ASCIIHexDecode = createDirectName("ASCIIHexDecode"); public static final PdfName Aside = createDirectName("Aside"); public static final PdfName AsIs = createDirectName("AsIs"); + public static final PdfName AttachedToSig = createDirectName("AttachedToSig"); public static final PdfName AuthEvent = createDirectName("AuthEvent"); + public static final PdfName AuthCode = createDirectName("AuthCode"); public static final PdfName Author = createDirectName("Author"); public static final PdfName B = createDirectName("B"); public static final PdfName BackgroundColor = createDirectName("BackgroundColor"); @@ -465,6 +468,7 @@ public class PdfName extends PdfPrimitiveObject implements Comparable { public static final PdfName JS = createDirectName("JS"); public static final PdfName Justify = createDirectName("Justify"); public static final PdfName K = createDirectName("K"); + public static final PdfName KDFSalt = createDirectName("KDFSalt"); public static final PdfName Keywords = createDirectName("Keywords"); public static final PdfName Kids = createDirectName("Kids"); public static final PdfName L2R = createDirectName("L2R"); @@ -510,6 +514,8 @@ public class PdfName extends PdfPrimitiveObject implements Comparable { public static final PdfName LW = createDirectName("LW"); public static final PdfName LZWDecode = createDirectName("LZWDecode"); public static final PdfName M = createDirectName("M"); + public static final PdfName MAC = createDirectName("MAC"); + public static final PdfName MACLocation = createDirectName("MACLocation"); public static final PdfName MacExpertEncoding = createDirectName("MacExpertEncoding"); public static final PdfName MacRomanEncoding = createDirectName("MacRomanEncoding"); public static final PdfName Marked = createDirectName("Marked"); @@ -748,6 +754,7 @@ public class PdfName extends PdfPrimitiveObject implements Comparable { public static final PdfName SigFieldLock = createDirectName("SigFieldLock"); public static final PdfName SigFlags = createDirectName("SigFlags"); public static final PdfName Signed = createDirectName("Signed"); + public static final PdfName SigObjRef = createDirectName("SigObjRef"); public static final PdfName SigRef = createDirectName("SigRef"); public static final PdfName Simplex = createDirectName("Simplex"); public static final PdfName SinglePage = createDirectName("SinglePage"); @@ -767,6 +774,7 @@ public class PdfName extends PdfPrimitiveObject implements Comparable { public static final PdfName SpaceAfter = createDirectName("SpaceAfter"); public static final PdfName Square = createDirectName("Square"); public static final PdfName Squiggly = createDirectName("Squiggly"); + public static final PdfName Standalone = createDirectName("Standalone"); public static final PdfName St = createDirectName("St"); public static final PdfName Stamp = createDirectName("Stamp"); public static final PdfName StampImage = createDirectName("StampImage"); @@ -937,7 +945,7 @@ public class PdfName extends PdfPrimitiveObject implements Comparable { /** * map strings to all known static names */ - public static Map staticNames; + public static final Map staticNames; /** * Use reflection to cache all the public static final names so diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfObject.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfObject.java index d718acca53..837aec7256 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfObject.java +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfObject.java @@ -28,6 +28,7 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.exceptions.PdfException; import com.itextpdf.kernel.utils.ICopyFilter; import com.itextpdf.kernel.utils.NullCopyFilter; +import com.itextpdf.kernel.validation.context.PdfObjectValidationContext; import java.io.IOException; import org.slf4j.Logger; @@ -75,9 +76,9 @@ public abstract class PdfObject { protected static final short ORIGINAL_OBJECT_STREAM = 1 << 4; /** - * For internal usage only. Marks objects that shall be written to the output document. - * Option is needed to build the correct PDF objects tree when closing the document. - * As a result it avoids writing unused (removed) objects. + * Marks objects that shall be written to the output document. Shouldn't be used on purpose + * since this flag is handled internally: option is needed to build the correct PDF objects + * tree when closing the document. As a result it avoids writing unused (removed) objects. */ protected static final short MUST_BE_FLUSHED = 1 << 5; @@ -162,7 +163,7 @@ public final void flush(boolean canBeInObjStm) { logger.info(IoLogMessageConstant.PDF_OBJECT_FLUSHING_NOT_PERFORMED); return; } - document.checkIsoConformance(this, IsoKey.PDF_OBJECT); + document.checkIsoConformance(new PdfObjectValidationContext(this)); document.flushObject(this, canBeInObjStm && getType() != STREAM && getType() != INDIRECT_REFERENCE && getIndirectReference().getGenNumber() == 0); } diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfOutline.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfOutline.java index fdea648b57..761aa9b05b 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfOutline.java +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfOutline.java @@ -39,11 +39,11 @@ public class PdfOutline { /** * A flag for displaying the outline item’s text with italic font. */ - public static int FLAG_ITALIC = 1; + public static final int FLAG_ITALIC = 1; /** * A flag for displaying the outline item’s text with bold font. */ - public static int FLAG_BOLD = 2; + public static final int FLAG_BOLD = 2; private List children = new ArrayList<>(); private String title; diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfOutputStream.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfOutputStream.java index 21f067306f..c901fa97d0 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfOutputStream.java +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfOutputStream.java @@ -26,7 +26,7 @@ This file is part of the iText (R) project. import com.itextpdf.io.source.ByteArrayOutputStream; import com.itextpdf.io.source.ByteUtils; import com.itextpdf.io.source.DeflaterOutputStream; -import com.itextpdf.io.source.OutputStream; +import com.itextpdf.io.source.HighPrecisionOutputStream; import com.itextpdf.kernel.exceptions.PdfException; import com.itextpdf.kernel.crypto.OutputStreamEncryption; import com.itextpdf.kernel.exceptions.KernelExceptionMessageConstant; @@ -36,7 +36,7 @@ This file is part of the iText (R) project. import org.slf4j.LoggerFactory; import java.io.IOException; -public class PdfOutputStream extends OutputStream { +public class PdfOutputStream extends HighPrecisionOutputStream { private static final byte[] stream = ByteUtils.getIsoBytes("stream\n"); diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfPage.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfPage.java index 56ec585b39..d79af1924c 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfPage.java +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfPage.java @@ -24,7 +24,7 @@ This file is part of the iText (R) project. import com.itextpdf.commons.utils.MessageFormatUtil; import com.itextpdf.io.logs.IoLogMessageConstant; -import com.itextpdf.kernel.events.PdfDocumentEvent; +import com.itextpdf.kernel.pdf.event.PdfDocumentEvent; import com.itextpdf.kernel.exceptions.KernelExceptionMessageConstant; import com.itextpdf.kernel.exceptions.PdfException; import com.itextpdf.kernel.geom.PageSize; @@ -36,6 +36,7 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.annot.PdfPrinterMarkAnnotation; import com.itextpdf.kernel.pdf.annot.PdfWidgetAnnotation; import com.itextpdf.kernel.pdf.filespec.PdfFileSpec; +import com.itextpdf.kernel.pdf.layer.PdfLayer; import com.itextpdf.kernel.pdf.tagging.PdfStructTreeRoot; import com.itextpdf.kernel.pdf.tagging.StandardRoles; import com.itextpdf.kernel.pdf.tagutils.TagStructureContext; @@ -44,6 +45,7 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.xobject.PdfImageXObject; import com.itextpdf.kernel.utils.ICopyFilter; import com.itextpdf.kernel.utils.NullCopyFilter; +import com.itextpdf.kernel.validation.context.PdfPageValidationContext; import com.itextpdf.kernel.xmp.XMPException; import com.itextpdf.kernel.xmp.XMPMeta; import com.itextpdf.kernel.xmp.XMPMetaFactory; @@ -52,7 +54,11 @@ This file is part of the iText (R) project. import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; +import java.util.HashSet; +import java.util.LinkedHashSet; import java.util.List; +import java.util.Set; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -83,6 +89,7 @@ public class PdfPage extends PdfObjectWrapper { * Automatically rotate new content if the page has a rotation ( is disabled by default ) */ private boolean ignorePageRotationForContent = false; + /** * See {@link #isPageRotationInverseMatrixWritten()}. */ @@ -240,7 +247,7 @@ public PdfStream newContentStreamBefore() { } /** - * Creates new {@link PdfStream} object and puts it at the end of Contents array + * Creates new {@link PdfStream} object and puts it at the end of {@code Contents} array * (if Contents object is {@link PdfStream} it will be replaced with one-element array). * * @return Created {@link PdfStream} object. @@ -419,6 +426,24 @@ public PdfPage copyTo(PdfDocument toDocument, IPdfPageExtraCopier copier, return copyTo(page, toDocument, copier); } + /** + * Get all pdf layers stored under this page's annotations/xobjects/resources. + * Note that it will include all layers, even those already stored under /OCProperties entry in catalog. + * To get only unique layers, you can simply exclude ocgs, which already present in catalog. + * + * @return set of pdf layers, associated with this page. + */ + public Set getPdfLayers() { + Set ocgs = OcgPropertiesCopier.getOCGsFromPage(this); + Set result = new LinkedHashSet<>(); + for (PdfIndirectReference ocg : ocgs) { + if (ocg.getRefersTo() != null && ocg.getRefersTo().isDictionary()) { + result.add(new PdfLayer((PdfDictionary) ocg.getRefersTo())); + } + } + return result; + } + /** * Copies page as FormXObject to the specified document. * @@ -512,7 +537,7 @@ public void flush(boolean flushResourcesContentStreams) { put(PdfName.Resources, resources.getPdfObject()); } if (flushResourcesContentStreams) { - getDocument().checkIsoConformance(this, IsoKey.PAGE); + getDocument().checkIsoConformance(new PdfPageValidationContext(this)); flushResourcesContentStreams(); } @@ -1165,32 +1190,6 @@ public PdfPage remove(PdfName key) { return this; } - /** - * This flag is meaningful for the case, when page rotation is applied and ignorePageRotationForContent - * is set to true. NOTE: It is needed for the internal usage. - *

- * This flag defines if inverse matrix (which rotates content into the opposite direction from page rotation - * direction in order to give the impression of the not rotated text) is already applied to the page content stream. - * See {@link #setIgnorePageRotationForContent(boolean)} - * - * @return true, if inverse matrix is already applied, false otherwise. - */ - public boolean isPageRotationInverseMatrixWritten() { - return pageRotationInverseMatrixWritten; - } - - /** - * NOTE: For internal usage! Use this method only if you know what you are doing. - *

- * This method is called when inverse matrix (which rotates content into the opposite direction from page rotation - * direction in order to give the impression of the not rotated text) is applied to the page content stream. - * See {@link #setIgnorePageRotationForContent(boolean)} - */ - public void setPageRotationInverseMatrixWritten() { - // this method specifically return void to discourage it's unintended usage - pageRotationInverseMatrixWritten = true; - } - /** * Adds file associated with PDF page and identifies the relationship between them. *

@@ -1268,6 +1267,26 @@ void releaseInstanceFields() { parentPages = null; } + /** + * Checks if page rotation inverse matrix (which rotates content into the opposite direction from page rotation + * direction in order to give the impression of the not rotated text) is already applied to the page content stream. + * See {@link #setIgnorePageRotationForContent(boolean)} and {@link PageContentRotationHelper}. + * + * @return {@code true} if inverse matrix is already applied, {@code false} otherwise + */ + boolean isPageRotationInverseMatrixWritten() { + return pageRotationInverseMatrixWritten; + } + + /** + * Specifies that page rotation inverse matrix (which rotates content into the opposite direction from page rotation + * direction in order to give the impression of the not rotated text) is applied to the page content stream. + * See {@link #setIgnorePageRotationForContent(boolean)} and {@link PageContentRotationHelper}. + */ + void setPageRotationInverseMatrixWritten() { + pageRotationInverseMatrixWritten = true; + } + @Override protected boolean isWrappedObjectMustBeIndirect() { return true; diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfPagesTree.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfPagesTree.java index 0b31e50905..17e0f25e19 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfPagesTree.java +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfPagesTree.java @@ -22,17 +22,18 @@ This file is part of the iText (R) project. */ package com.itextpdf.kernel.pdf; +import com.itextpdf.commons.datastructures.ISimpleList; +import com.itextpdf.kernel.di.pagetree.IPageTreeListFactory; import com.itextpdf.commons.utils.MessageFormatUtil; import com.itextpdf.io.logs.IoLogMessageConstant; import com.itextpdf.kernel.exceptions.KernelExceptionMessageConstant; import com.itextpdf.kernel.exceptions.PdfException; import java.util.ArrayList; -import java.util.HashMap; import java.util.HashSet; import java.util.List; -import java.util.Map; import java.util.Set; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -45,10 +46,10 @@ class PdfPagesTree { private final int leafSize = DEFAULT_LEAF_SIZE; - private NullUnlimitedList pageRefs; + private ISimpleList pageRefs; private List parents; - private NullUnlimitedList pages; - private PdfDocument document; + private ISimpleList pages; + private final PdfDocument document; private boolean generated = false; private PdfPages root; @@ -61,15 +62,16 @@ class PdfPagesTree { */ public PdfPagesTree(PdfCatalog pdfCatalog) { this.document = pdfCatalog.getDocument(); - this.pageRefs = new NullUnlimitedList<>(); this.parents = new ArrayList<>(); - this.pages = new NullUnlimitedList<>(); + IPageTreeListFactory pageTreeFactory = document.getDiContainer().getInstance(IPageTreeListFactory.class); if (pdfCatalog.getPdfObject().containsKey(PdfName.Pages)) { PdfDictionary pages = pdfCatalog.getPdfObject().getAsDictionary(PdfName.Pages); if (pages == null) { throw new PdfException( KernelExceptionMessageConstant.INVALID_PAGE_STRUCTURE_PAGES_MUST_BE_PDF_DICTIONARY); } + this.pages = pageTreeFactory.createList(pages); + this.pageRefs = pageTreeFactory.createList(pages); this.root = new PdfPages(0, Integer.MAX_VALUE, pages, null); parents.add(this.root); for (int i = 0; i < this.root.getCount(); i++) { @@ -79,6 +81,8 @@ public PdfPagesTree(PdfCatalog pdfCatalog) { } else { this.root = null; this.parents.add(new PdfPages(0, this.document)); + this.pages = pageTreeFactory.createList(null); + this.pageRefs = pageTreeFactory.createList(null); } //in read mode we will create PdfPages from 0 to Count // and reserve null indexes for pageRefs and pages. @@ -88,7 +92,6 @@ public PdfPagesTree(PdfCatalog pdfCatalog) { * Returns the {@link PdfPage} at the specified position in this list. * * @param pageNum one-based index of the element to return - * * @return the {@link PdfPage} at the specified position in this list */ public PdfPage getPage(int pageNum) { @@ -129,7 +132,6 @@ public PdfPage getPage(int pageNum) { * Returns the {@link PdfPage} by page's PdfDictionary. * * @param pageDictionary page's PdfDictionary - * * @return the {@code PdfPage} object, that wraps {@code pageDictionary}. */ public PdfPage getPage(PdfDictionary pageDictionary) { @@ -242,7 +244,6 @@ public void addPage(int index, PdfPage pdfPage) { * indices). * * @param pageNum the one-based index of the PdfPage to be removed - * * @return the page that was removed from the list */ public PdfPage removePage(int pageNum) { @@ -270,7 +271,6 @@ void releasePage(int pageNumber) { * Generate PdfPages tree. * * @return root {@link PdfPages} - * * @throws PdfException in case empty document */ protected PdfObject generateTree() { @@ -512,99 +512,5 @@ private void correctPdfPagesFromProperty(int index, int correction) { } } } - - /** - * The class represents a list which allows null elements, but doesn't allocate a memory for them, in the rest of - * cases it behaves like usual {@link ArrayList} and should have the same complexity (because keys are unique - * integers, so collisions are impossible). Class doesn't implement {@code List} interface because it provides - * only methods which are in use in {@link PdfPagesTree} class. - * - * @param elements of the list - */ - static final class NullUnlimitedList { - private final Map map = new HashMap<>(); - private int size = 0; - - // O(1) - public void add(T element) { - if (element == null) { - size++; - return; - } - map.put(size++, element); - } - - // In worth scenario O(n^2) but it is mostly impossible because keys shouldn't have - // collisions at all (they are integers). So in average should be O(n). - public void add(int index, T element) { - if (index < 0 || index > size) { - return; - } - size++; - // Shifts the element currently at that position (if any) and any - // subsequent elements to the right (adds one to their indices). - T previous = map.get(index); - for (int i = index + 1; i < size; i++) { - T currentToAdd = previous; - previous = map.get(i); - this.set(i, currentToAdd); - } - - this.set(index, element); - } - - // average O(1), worth O(n) (mostly impossible in case when keys are integers) - public T get(int index) { - return map.get(index); - } - - // average O(1), worth O(n) (mostly impossible in case when keys are integers) - public void set(int index, T element) { - if (element == null) { - map.remove(index); - } else { - map.put(index, element); - } - } - - // O(n) - public int indexOf(T element) { - if (element == null) { - for (int i = 0; i < size; i++) { - if (!map.containsKey(i)) { - return i; - } - } - return -1; - } - for (Map.Entry entry : map.entrySet()) { - if (element.equals(entry.getValue())) { - return entry.getKey(); - } - } - return -1; - } - - // In worth scenario O(n^2) but it is mostly impossible because keys shouldn't have - // collisions at all (they are integers). So in average should be O(n). - public void remove(int index) { - if (index < 0 || index >= size) { - return; - } - map.remove(index); - // Shifts any subsequent elements to the left (subtracts one from their indices). - T previous = map.get(size - 1); - for (int i = size - 2; i >= index; i--) { - T current = previous; - previous = map.get(i); - this.set(i, current); - } - map.remove(--size); - } - - // O(1) - public int size() { - return size; - } - } } + diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfReader.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfReader.java index 657e3b069c..ca2689841e 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfReader.java +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfReader.java @@ -22,6 +22,7 @@ This file is part of the iText (R) project. */ package com.itextpdf.kernel.pdf; +import com.itextpdf.commons.utils.MessageFormatUtil; import com.itextpdf.io.logs.IoLogMessageConstant; import com.itextpdf.io.source.ByteBuffer; import com.itextpdf.io.source.ByteUtils; @@ -31,18 +32,16 @@ This file is part of the iText (R) project. import com.itextpdf.io.source.RandomAccessFileOrArray; import com.itextpdf.io.source.RandomAccessSourceFactory; import com.itextpdf.io.source.WindowRandomAccessSource; -import com.itextpdf.commons.utils.MessageFormatUtil; +import com.itextpdf.kernel.crypto.securityhandler.UnsupportedSecurityHandlerException; import com.itextpdf.kernel.exceptions.InvalidXRefPrevException; +import com.itextpdf.kernel.exceptions.KernelExceptionMessageConstant; import com.itextpdf.kernel.exceptions.MemoryLimitsAwareException; import com.itextpdf.kernel.exceptions.PdfException; -import com.itextpdf.kernel.crypto.securityhandler.UnsupportedSecurityHandlerException; -import com.itextpdf.kernel.exceptions.KernelExceptionMessageConstant; import com.itextpdf.kernel.exceptions.XrefCycledReferencesException; import com.itextpdf.kernel.pdf.filters.FilterHandlers; import com.itextpdf.kernel.pdf.filters.IFilterHandler; import com.itextpdf.kernel.xmp.XMPException; import com.itextpdf.kernel.xmp.XMPMeta; -import com.itextpdf.kernel.xmp.XMPMetaFactory; import java.io.ByteArrayInputStream; import java.io.Closeable; @@ -50,8 +49,8 @@ This file is part of the iText (R) project. import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; -import java.util.HashSet; import java.nio.charset.StandardCharsets; +import java.util.HashSet; import java.util.Map; import java.util.Set; import org.slf4j.Logger; @@ -85,8 +84,6 @@ public class PdfReader implements Closeable { //indicate nearest first Indirect reference object which includes current reading the object, using for PdfString decrypt private PdfIndirectReference currentIndirectReference; - private XMPMeta xmpMeta; - private XrefProcessor xrefProcessor = new XrefProcessor(); protected PdfTokenizer tokens; @@ -99,7 +96,6 @@ public class PdfReader implements Closeable { protected long eofPos; protected PdfDictionary trailer; protected PdfDocument pdfDocument; - protected PdfAConformanceLevel pdfAConformanceLevel; protected ReaderProperties properties; @@ -108,6 +104,10 @@ public class PdfReader implements Closeable { protected boolean hybridXref = false; protected boolean fixedXref = false; protected boolean xrefStm = false; + + private XMPMeta xmpMeta; + private PdfConformance pdfConformance; + /** * Constructs a new PdfReader. * @@ -587,10 +587,10 @@ public boolean isOpenedWithFullPermission() { * {@link WriterProperties#setStandardEncryption(byte[], byte[], int, int)}. * See ISO 32000-1, Table 22 for more details. * - * @return the encryption permissions, an unsigned 32-bit quantity. + * @return the encryption permissions. * @throws PdfException if the method has been invoked before the PDF document was read. */ - public long getPermissions() { + public int getPermissions() { /* !pdfDocument.getXref().isReadingCompleted() can be used for encryption properties as well, * because decrypt object is initialized in private readDecryptObj method which is called in our code @@ -601,9 +601,9 @@ public long getPermissions() { throw new PdfException(KernelExceptionMessageConstant.DOCUMENT_HAS_NOT_BEEN_READ_YET); } - long perm = 0; + int perm = 0; if (encrypted && decrypt.getPermissions() != null) { - perm = (long) decrypt.getPermissions(); + perm = decrypt.getPermissions().intValue(); } return perm; } @@ -627,32 +627,29 @@ public int getCryptoMode() { } /** - * Gets the declared PDF/A conformance level of the source document that is being read. + * Gets the declared PDF conformance of the source document that is being read. * Note that this information is provided via XMP metadata and is not verified by iText. - * {@link PdfReader#pdfAConformanceLevel} is lazy initialized. + * Conformance is lazy initialized. * It will be initialized during the first call of this method. * - * @return conformance level of the source document, or {@code null} if no PDF/A - * conformance level information is specified. + * @return conformance of the source document */ - public PdfAConformanceLevel getPdfAConformanceLevel() { - if (pdfAConformanceLevel == null) { + public PdfConformance getPdfConformance() { + if (pdfConformance == null) { if (pdfDocument == null || !pdfDocument.getXref().isReadingCompleted()) { throw new PdfException(KernelExceptionMessageConstant.DOCUMENT_HAS_NOT_BEEN_READ_YET); } try { if (xmpMeta == null && pdfDocument.getXmpMetadata() != null) { - xmpMeta = XMPMetaFactory.parseFromBuffer(pdfDocument.getXmpMetadata()); - } - if (xmpMeta != null) { - pdfAConformanceLevel = PdfAConformanceLevel.getConformanceLevel(xmpMeta); + xmpMeta = pdfDocument.getXmpMetadata(); } + pdfConformance = PdfConformance.getConformance(xmpMeta); } catch (XMPException ignored) { } } - return pdfAConformanceLevel; + return pdfConformance; } /** @@ -735,6 +732,15 @@ public boolean isEncrypted() { return encrypted; } + /** + * Gets a copy of {@link ReaderProperties} used to create this instance of {@link PdfReader}. + * + * @return a copy of {@link ReaderProperties} used to create this instance of {@link PdfReader} + */ + public ReaderProperties getPropertiesCopy() { + return new ReaderProperties(properties); + } + /** * Parses the entire PDF * @@ -756,9 +762,7 @@ protected void readPdf() throws IOException { throw ex; } catch (RuntimeException ex) { if (StrictnessLevel.CONSERVATIVE.isStricter(this.getStrictnessLevel())) { - Logger logger = LoggerFactory.getLogger(PdfReader.class); - logger.error(IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT, ex); - + logXrefException(ex); rebuildXref(); } else { throw ex; @@ -865,8 +869,9 @@ protected PdfObject readReference(boolean readAsDirect) { tokens.getGenNr())); return createPdfNullInstance(readAsDirect); } else { - throw new PdfException(KernelExceptionMessageConstant.INVALID_INDIRECT_REFERENCE, - MessageFormatUtil.format("{0} {1} R", reference.getObjNumber(), reference.getGenNumber())); + throw new PdfException(MessageFormatUtil.format( + KernelExceptionMessageConstant.INVALID_INDIRECT_REFERENCE + , reference.getObjNumber(), reference.getGenNumber()), reference); } } } else { @@ -1439,7 +1444,6 @@ private void readDecryptObj() { if (enc == null) return; encrypted = true; - PdfName filter = enc.getAsName(PdfName.Filter); if (PdfName.Adobe_PubSec.equals(filter)) { if (properties.certificate == null) { @@ -1453,6 +1457,8 @@ private void readDecryptObj() { } else { throw new UnsupportedSecurityHandlerException(MessageFormatUtil.format(KernelExceptionMessageConstant.UNSUPPORTED_SECURITY_HANDLER, filter)); } + + decrypt.configureEncryptionParametersFromReader(pdfDocument, trailer); } private PdfObject readObject(PdfIndirectReference reference, boolean fixXref) { @@ -1611,6 +1617,21 @@ private void processXref(PdfXrefTable xrefTable) throws IOException { } } + private static void logXrefException(RuntimeException ex) { + Logger logger = LoggerFactory.getLogger(PdfReader.class); + if (ex.getCause() != null) { + logger.error(MessageFormatUtil.format( + IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT_WITH_CAUSE + , ex.getCause().getMessage())); + } else if (ex.getMessage() !=null) { + logger.error(MessageFormatUtil.format( + IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT_WITH_CAUSE + , ex.getMessage())); + } else { + logger.error(IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT); + } + } + protected static class ReusableRandomAccessSource implements IRandomAccessSource { private ByteBuffer buffer; diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfResources.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfResources.java index 19eb8a3c1a..97a6be11f8 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfResources.java +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfResources.java @@ -25,7 +25,7 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.font.PdfFont; import com.itextpdf.kernel.pdf.colorspace.PdfColorSpace; import com.itextpdf.kernel.pdf.colorspace.PdfPattern; -import com.itextpdf.kernel.pdf.colorspace.PdfShading; +import com.itextpdf.kernel.pdf.colorspace.shading.AbstractPdfShading; import com.itextpdf.kernel.pdf.extgstate.PdfExtGState; import com.itextpdf.kernel.pdf.xobject.PdfFormXObject; import com.itextpdf.kernel.pdf.xobject.PdfImageXObject; @@ -35,7 +35,6 @@ This file is part of the iText (R) project. import java.util.Map; import java.util.Set; import java.util.TreeSet; -import static java.util.Collections.emptySet; /** * Wrapper class that represent resource dictionary - that define named resources @@ -253,12 +252,12 @@ public PdfPattern getPattern(PdfName name) { } /** - * Adds {@link PdfShading} object to the resources. + * Adds {@link AbstractPdfShading} object to the resources. * - * @param shading the {@link PdfShading} to add. + * @param shading the {@link AbstractPdfShading} to add. * @return added shading resource name. */ - public PdfName addShading(PdfShading shading) { + public PdfName addShading(AbstractPdfShading shading) { return addResource(shading, shadingNamesGen); } @@ -272,9 +271,9 @@ public PdfName addShading(PdfDictionary shading) { return addResource(shading, shadingNamesGen); } - public PdfShading getShading(PdfName name) { + public AbstractPdfShading getShading(PdfName name) { PdfObject shading = getResourceObject(PdfName.Shading, name); - return shading instanceof PdfDictionary ? PdfShading.makeShading((PdfDictionary) shading) : null; + return shading instanceof PdfDictionary ? AbstractPdfShading.makeShading((PdfDictionary) shading) : null; } protected boolean isReadOnly() { diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfRevisionsReader.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfRevisionsReader.java index c667de42fd..24e821ace4 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfRevisionsReader.java +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfRevisionsReader.java @@ -77,7 +77,7 @@ public List getAllRevisions() throws IOException { raf.createSourceView(), 0, raf.length()); try (InputStream inputStream = new RASInputStream(source); - PdfReader newReader = new PdfReader(inputStream); + PdfReader newReader = new PdfReader(inputStream, reader.getPropertiesCopy()); PdfDocument newDocument = new PdfDocument(newReader, new DocumentProperties().setEventCountingMetaInfo(metaInfo))) { newDocument.getXref().unmarkReadingCompleted(); diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/tagutils/TagTreeIteratorElementApprover.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfUAConformance.java similarity index 61% rename from kernel/src/main/java/com/itextpdf/kernel/pdf/tagutils/TagTreeIteratorElementApprover.java rename to kernel/src/main/java/com/itextpdf/kernel/pdf/PdfUAConformance.java index 5d7ec02883..2b0674d1cc 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/pdf/tagutils/TagTreeIteratorElementApprover.java +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfUAConformance.java @@ -20,30 +20,33 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.kernel.pdf.tagutils; - -import com.itextpdf.kernel.pdf.tagging.IStructureNode; +package com.itextpdf.kernel.pdf; /** - * Element checker for {@link TagTreeIterator}. - * It is used to check whether specific element should be traversed. + * PDF/UA is a conformance for PDF files that ensures the files are accessible to all users. + * It contains an enumeration of all the PDF/UA conformance currently supported by iText. */ -public class TagTreeIteratorElementApprover { +public enum PdfUAConformance { + /** PDF/UA-1 conformance **/ + PDF_UA_1("1"); + + private final String part; /** - * Creates a new instance of {@link TagTreeIteratorElementApprover} + * Creates a new {@link PdfUAConformance} instance. + * + * @param part the part of the PDF/UA conformance */ - public TagTreeIteratorElementApprover() { - // Empty constructor + PdfUAConformance(String part) { + this.part = part; } /** - * Checks whether the element should be traversed. + * Get the part of the PDF/UA conformance. * - * @param elem the element to check - * @return {@code true} if the element should be traversed, {@code false otherwise} + * @return the part of the PDF/UA conformance */ - public boolean approve(IStructureNode elem) { - return elem != null; + public String getPart() { + return this.part; } } diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfWriter.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfWriter.java index 7f6f0790c9..5bb4009378 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfWriter.java +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfWriter.java @@ -24,11 +24,18 @@ This file is part of the iText (R) project. import com.itextpdf.commons.utils.FileUtil; import com.itextpdf.io.logs.IoLogMessageConstant; +import com.itextpdf.io.source.ByteArrayOutputStream; import com.itextpdf.io.source.ByteUtils; +import com.itextpdf.kernel.exceptions.PdfException; +import com.itextpdf.kernel.mac.AbstractMacIntegrityProtector; +import com.itextpdf.kernel.mac.IMacContainerLocator; +import com.itextpdf.kernel.pdf.event.PdfDocumentEvent; import com.itextpdf.kernel.utils.ICopyFilter; import com.itextpdf.kernel.utils.NullCopyFilter; import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.OutputStream; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; @@ -38,8 +45,8 @@ This file is part of the iText (R) project. import org.slf4j.LoggerFactory; public class PdfWriter extends PdfOutputStream { - private static final byte[] obj = ByteUtils.getIsoBytes(" obj\n"); - private static final byte[] endobj = ByteUtils.getIsoBytes("\nendobj\n"); + private static final byte[] OBJ = ByteUtils.getIsoBytes(" obj\n"); + private static final byte[] ENDOBJ = ByteUtils.getIsoBytes("\nendobj\n"); protected WriterProperties properties; //forewarned is forearmed @@ -54,11 +61,12 @@ public class PdfWriter extends PdfOutputStream { * It stores hashes of the indirect reference from the source document and the corresponding * indirect references of the copied objects from the new document. */ - private Map copiedObjects = new LinkedHashMap<>(); + private final Map copiedObjects = new LinkedHashMap<>(); /** * Is used in smart mode to serialize and store serialized objects content. */ - private SmartModePdfObjectsSerializer smartModeSerializer = new SmartModePdfObjectsSerializer(); + private final SmartModePdfObjectsSerializer smartModeSerializer = new SmartModePdfObjectsSerializer(); + private OutputStream originalOutputStream; /** * Create a PdfWriter writing to the passed File and with default writer properties. @@ -69,7 +77,7 @@ public class PdfWriter extends PdfOutputStream { * rather than a regular file, does not exist but cannot * be created, or cannot be opened for any other reason */ - public PdfWriter(java.io.File file) throws FileNotFoundException { + public PdfWriter(java.io.File file) throws IOException { this(file.getAbsolutePath()); } @@ -82,6 +90,13 @@ public PdfWriter(java.io.OutputStream os) { this(os, new WriterProperties()); } + /** + * Creates {@link PdfWriter} instance, which writes to the passed {@link OutputStream}, + * using provided {@link WriterProperties}. + * + * @param os {@link OutputStream} in which writing should happen + * @param properties {@link WriterProperties} to be used during the writing + */ public PdfWriter(java.io.OutputStream os, WriterProperties properties) { super(new CountOutputStream(FileUtil.wrapWithBufferedOutputStream(os))); this.properties = properties; @@ -96,7 +111,7 @@ public PdfWriter(java.io.OutputStream os, WriterProperties properties) { * rather than a regular file, does not exist but cannot * be created, or cannot be opened for any other reason */ - public PdfWriter(String filename) throws FileNotFoundException { + public PdfWriter(String filename) throws IOException { this(filename, new WriterProperties()); } @@ -110,7 +125,7 @@ public PdfWriter(String filename) throws FileNotFoundException { * rather than a regular file, does not exist but cannot * be created, or cannot be opened for any other reason */ - public PdfWriter(String filename, WriterProperties properties) throws FileNotFoundException { + public PdfWriter(String filename, WriterProperties properties) throws IOException { this(FileUtil.getBufferedOutputStream(filename), properties); } @@ -146,6 +161,15 @@ public PdfWriter setCompressionLevel(int compressionLevel) { return this; } + /** + * Gets defined pdf version for the document. + * + * @return version for the document + */ + public PdfVersion getPdfVersion() { + return properties.pdfVersion; + } + /** * Gets the writer properties. * @@ -173,16 +197,40 @@ public PdfWriter setSmartMode(boolean smartMode) { return this; } + /** + * Initializes {@link PdfEncryption} object if any encryption is specified in {@link WriterProperties}. + * + * @param version {@link PdfVersion} version of the document in question + */ protected void initCryptoIfSpecified(PdfVersion version) { EncryptionProperties encryptProps = properties.encryptionProperties; + // Suppress MAC properties for PDF version < 2.0 and old deprecated encryption algorithms + // if default ones have been passed to WriterProperties + final int encryptionAlgorithm = crypto == null ? + (encryptProps.encryptionAlgorithm & EncryptionConstants.ENCRYPTION_MASK) : + crypto.getEncryptionAlgorithm(); + if (document.properties.disableMac) { + encryptProps.macProperties = null; + } + if (encryptProps.macProperties == EncryptionProperties.DEFAULT_MAC_PROPERTIES) { + if (version == null || version.compareTo(PdfVersion.PDF_2_0) < 0 || + encryptionAlgorithm < EncryptionConstants.ENCRYPTION_AES_256) { + encryptProps.macProperties = null; + } + } + + AbstractMacIntegrityProtector mac = encryptProps.macProperties == null ? null : document.getDiContainer() + .getInstance(IMacContainerLocator.class) + .createMacIntegrityProtector(document, encryptProps.macProperties); if (properties.isStandardEncryptionUsed()) { crypto = new PdfEncryption(encryptProps.userPassword, encryptProps.ownerPassword, encryptProps.standardEncryptPermissions, encryptProps.encryptionAlgorithm, - ByteUtils.getIsoBytes(this.document.getOriginalDocumentId().getValue()), version); + ByteUtils.getIsoBytes(this.document.getOriginalDocumentId().getValue()), + version, mac); } else if (properties.isPublicKeyEncryptionUsed()) { - crypto = new PdfEncryption(encryptProps.publicCertificates, - encryptProps.publicKeyEncryptPermissions, encryptProps.encryptionAlgorithm, version); + crypto = new PdfEncryption(encryptProps.publicCertificates, encryptProps.publicKeyEncryptPermissions, + encryptProps.encryptionAlgorithm, version, mac); } } @@ -310,9 +358,9 @@ protected void writeToBody(PdfObject pdfObj) { } writeInteger(pdfObj.getIndirectReference().getObjNumber()). writeSpace(). - writeInteger(pdfObj.getIndirectReference().getGenNumber()).writeBytes(obj); + writeInteger(pdfObj.getIndirectReference().getGenNumber()).writeBytes(OBJ); write(pdfObj); - writeBytes(endobj); + writeBytes(ENDOBJ); } /** @@ -383,6 +431,19 @@ protected void flushModifiedWaitingObjects(Set forbiddenTo } } + void finish() throws IOException { + if (document != null && !document.isClosed()) { + // Writer is always closed as part of document closing + document.dispatchEvent(new PdfDocumentEvent(PdfDocumentEvent.START_WRITER_CLOSING)); + + if (isByteArrayWritingMode()) { + completeByteArrayWritingMode(); + } + } + + close(); + } + /** * Gets the current object stream. * @@ -422,6 +483,25 @@ void flushCopiedObjects(long docId) { } } + void enableByteArrayWritingMode() { + if (isByteArrayWritingMode()) { + throw new PdfException("Byte array writing mode is already enabled"); + } else { + this.originalOutputStream = this.outputStream; + this.outputStream = new ByteArrayOutputStream(); + } + } + + private void completeByteArrayWritingMode() throws IOException { + byte[] baos = ((ByteArrayOutputStream) getOutputStream()).toByteArray(); + originalOutputStream.write(baos, 0, baos.length); + originalOutputStream.close(); + } + + private boolean isByteArrayWritingMode() { + return originalOutputStream != null; + } + private void markArrayContentToFlush(PdfArray array) { for (int i = 0; i < array.size(); i++) { markObjectToFlush(array.get(i, false)); diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfXrefTable.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfXrefTable.java index 7a0423a203..c8953f17f6 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfXrefTable.java +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfXrefTable.java @@ -22,18 +22,17 @@ This file is part of the iText (R) project. */ package com.itextpdf.kernel.pdf; -import com.itextpdf.commons.actions.data.ProductData; -import com.itextpdf.commons.utils.MessageFormatUtil; +import com.itextpdf.commons.actions.EventManager; import com.itextpdf.io.logs.IoLogMessageConstant; import com.itextpdf.io.source.ByteUtils; -import com.itextpdf.kernel.actions.data.ITextCoreProductData; +import com.itextpdf.kernel.actions.events.AddFingerPrintEvent; import com.itextpdf.kernel.exceptions.KernelExceptionMessageConstant; import com.itextpdf.kernel.exceptions.PdfException; +import com.itextpdf.kernel.validation.context.XrefTableValidationContext; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collection; import java.util.List; import java.util.Map; import java.util.TreeMap; @@ -185,28 +184,6 @@ public PdfIndirectReference get(int index) { return xref[index]; } - /** - * Convenience method to write the fingerprint preceding the trailer. - * The fingerprint contains information on iText products used in the generation or manipulation - * of an outputted PDF file. - * - * @param document pdfDocument to write the fingerprint to - */ - protected static void writeKeyInfo(PdfDocument document) { - PdfWriter writer = document.getWriter(); - - final Collection products = document.getFingerPrint().getProducts(); - if (products.isEmpty()) { - writer.writeString(MessageFormatUtil - .format("%iText-{0}-no-registered-products\n", ITextCoreProductData.getInstance().getVersion())); - } else { - for (ProductData productData : products) { - writer.writeString(MessageFormatUtil - .format("%iText-{0}-{1}\n", productData.getPublicProductName(), productData.getVersion())); - } - } - } - /** * Creates next available indirect reference. * @@ -306,7 +283,7 @@ protected void writeXrefTableAndTrailer(PdfDocument document, PdfObject fileId, return; } - document.checkIsoConformance(this, IsoKey.XREF_TABLE); + document.checkIsoConformance(new XrefTableValidationContext(this)); long startxref = writer.getCurrentPos(); long xRefStmPos = -1; @@ -320,7 +297,9 @@ protected void writeXrefTableAndTrailer(PdfDocument document, PdfObject fileId, int offsetSize = getOffsetSize(Math.max(startxref, size())); xrefStream.put(PdfName.W, new PdfArray( Arrays.asList((PdfObject) new PdfNumber(1), new PdfNumber(offsetSize), new PdfNumber(2)))); - xrefStream.put(PdfName.Info, document.getDocumentInfo().getPdfObject()); + if (document.getTrailer().get(PdfName.Info) != null) { + xrefStream.put(PdfName.Info, document.getTrailer().get(PdfName.Info)); + } xrefStream.put(PdfName.Root, document.getCatalog().getPdfObject()); PdfArray index = new PdfArray(); for (Integer section : sections) { @@ -402,8 +381,10 @@ protected void writeXrefTableAndTrailer(PdfDocument document, PdfObject fileId, if (xRefStmPos != -1) { trailer.put(PdfName.XRefStm, new PdfNumber(xRefStmPos)); } - if (crypto != null) + if (crypto != null) { trailer.put(PdfName.Encrypt, crypto); + } + writer.writeString("trailer\n"); if (document.properties.appendMode) { PdfNumber lastXref = new PdfNumber(document.reader.getLastXref()); @@ -412,7 +393,7 @@ protected void writeXrefTableAndTrailer(PdfDocument document, PdfObject fileId, writer.write(document.getTrailer()); writer.write('\n'); } - writeKeyInfo(document); + EventManager.getInstance().onEvent(new AddFingerPrintEvent(document)); writer.writeString("startxref\n"). writeLong(startxref). writeString("\n%%EOF\n"); diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/ReaderProperties.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/ReaderProperties.java index 4e1de6889f..d57245b002 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/pdf/ReaderProperties.java +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/ReaderProperties.java @@ -26,23 +26,38 @@ This file is part of the iText (R) project. import java.security.Key; import java.security.cert.Certificate; +import java.util.Arrays; +/** + * The class representing various properties used to read PDF documents. + */ public class ReaderProperties { - - //added by ujihara for decryption protected byte[] password; - - //added by Aiken Sam for certificate decryption protected Key certificateKey; - //added by Aiken Sam for certificate decryption protected Certificate certificate; - //added by Aiken Sam for certificate decryption protected String certificateKeyProvider; protected IExternalDecryptionProcess externalDecryptionProcess; - protected MemoryLimitsAwareHandler memoryLimitsAwareHandler; + /** + * Creates an instance of {@link ReaderProperties}. + */ + public ReaderProperties() { + // Empty constructor + } + + ReaderProperties(ReaderProperties readerProperties) { + this.password = readerProperties.password == null ? null : + Arrays.copyOf(readerProperties.password, readerProperties.password.length); + this.certificateKey = readerProperties.certificateKey; + this.certificate = readerProperties.certificate; + this.certificateKeyProvider = readerProperties.certificateKeyProvider; + this.externalDecryptionProcess = readerProperties.externalDecryptionProcess; + this.memoryLimitsAwareHandler = readerProperties.memoryLimitsAwareHandler == null ? null : + readerProperties.memoryLimitsAwareHandler.createNewInstance(); + } + /** * Defines the password which will be used if the document is encrypted with standard encryption. * This could be either user or owner password. @@ -95,14 +110,6 @@ public ReaderProperties setPublicKeySecurityParams(Certificate certificate, IExt return this; } - private void clearEncryptionParams() { - this.password = null; - this.certificate = null; - this.certificateKey = null; - this.certificateKeyProvider = null; - this.externalDecryptionProcess = null; - } - /** * Sets the memory handler which will be used to handle decompressed PDF streams. * @@ -114,4 +121,11 @@ public ReaderProperties setMemoryLimitsAwareHandler(MemoryLimitsAwareHandler mem return this; } + private void clearEncryptionParams() { + this.password = null; + this.certificate = null; + this.certificateKey = null; + this.certificateKeyProvider = null; + this.externalDecryptionProcess = null; + } } diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/StampingProperties.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/StampingProperties.java index ec969a2e4b..1b7a16129f 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/pdf/StampingProperties.java +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/StampingProperties.java @@ -24,10 +24,9 @@ This file is part of the iText (R) project. public class StampingProperties extends DocumentProperties { - - protected boolean appendMode = false; protected boolean preserveEncryption = false; + protected boolean disableMac = false; public StampingProperties() { } @@ -36,10 +35,17 @@ public StampingProperties(StampingProperties other) { super(other); this.appendMode = other.appendMode; this.preserveEncryption = other.preserveEncryption; + this.disableMac = other.disableMac; + } + + StampingProperties(DocumentProperties documentProperties) { + super(documentProperties); + this.dependencies = documentProperties.dependencies; } /** * Defines if the document will be edited in append mode. + * * @return this {@link StampingProperties} instance */ public StampingProperties useAppendMode() { @@ -50,10 +56,24 @@ public StampingProperties useAppendMode() { /** * Defines if the encryption of the original document (if it was encrypted) will be preserved. * By default, the resultant document doesn't preserve the original encryption. + * * @return this {@link StampingProperties} instance */ public StampingProperties preserveEncryption() { this.preserveEncryption = true; return this; } + + /** + * Disables MAC token in the output PDF-2.0 document. + * By default, MAC token will be embedded. + * This property does not remove MAC token from existing document in append mode because it removes MAC protection + * from all previous revisions also. + * + * @return this {@link StampingProperties} instance + */ + public StampingProperties disableMac() { + this.disableMac = true; + return this; + } } diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/VersionConforming.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/VersionConforming.java index 789381bdb3..a9a3889193 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/pdf/VersionConforming.java +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/VersionConforming.java @@ -34,6 +34,8 @@ public class VersionConforming { public static final String DEPRECATED_ENCRYPTION_ALGORITHMS = "Encryption algorithms STANDARD_ENCRYPTION_40, STANDARD_ENCRYPTION_128 and ENCRYPTION_AES_128 (see com.itextpdf.kernel.pdf.EncryptionConstants) are deprecated in PDF 2.0. It is highly recommended not to use it."; public static final String DEPRECATED_NEED_APPEARANCES_IN_ACROFORM = "NeedAppearances has been deprecated in PDF 2.0. Appearance streams are required in PDF 2.0."; public static final String DEPRECATED_XFA_FORMS = "XFA is deprecated in PDF 2.0. The XFA form will not be written to the document"; + public static final String NOT_SUPPORTED_AES_GCM = "Advanced Encryption Standard-Galois/Counter Mode " + + "(AES-GCM) encryption algorithm is supported starting from PDF 2.0."; private static final Logger logger = LoggerFactory.getLogger(VersionConforming.class); @@ -66,6 +68,23 @@ public static boolean validatePdfVersionForDeprecatedFeatureLogError(PdfDocument } } - + /** + * Logs error message in case provided PDF document version is earlier than specified expected starting version. + * + * @param document PDF document to check version for + * @param expectedStartVersion starting version since which new feature is supported + * @param notSupportedFeatureLogMessage error message to log + * + * @return boolean value specifying whether validation passed ({@code true}) or failed ({@code false}) + */ + public static boolean validatePdfVersionForNotSupportedFeatureLogError(PdfDocument document, + PdfVersion expectedStartVersion, + String notSupportedFeatureLogMessage) { + if (document.getPdfVersion().compareTo(expectedStartVersion) >= 0) { + return true; + } + logger.error(notSupportedFeatureLogMessage); + return false; + } } diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/WriterProperties.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/WriterProperties.java index 6556cc82ab..35891ce02b 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/pdf/WriterProperties.java +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/WriterProperties.java @@ -23,12 +23,12 @@ This file is part of the iText (R) project. package com.itextpdf.kernel.pdf; import com.itextpdf.bouncycastleconnector.BouncyCastleFactoryCreator; +import com.itextpdf.kernel.mac.MacProperties; import java.security.cert.Certificate; public class WriterProperties { - protected int compressionLevel; /** @@ -42,7 +42,8 @@ public class WriterProperties { */ protected boolean smartMode; protected boolean addXmpMetadata; - protected boolean addUAXmpMetadata; + protected PdfAConformance addPdfAXmpMetadata = null; + protected PdfUAConformance addPdfUaXmpMetadata = null; protected PdfVersion pdfVersion; protected EncryptionProperties encryptionProperties; /** @@ -57,7 +58,6 @@ public class WriterProperties { public WriterProperties() { smartMode = false; - addUAXmpMetadata = false; compressionLevel = CompressionConstants.DEFAULT_COMPRESSION; isFullCompression = null; encryptionProperties = new EncryptionProperties(); @@ -101,6 +101,48 @@ public WriterProperties addXmpMetadata() { return this; } + /** + * Adds PDF/A XMP metadata to the PDF document. + * + *

+ * This method calls {@link #addXmpMetadata()} implicitly. + * + *

+ * NOTE: Calling this method only affects the XMP metadata, but doesn't enable any additional checks that the + * created document meets all PDF/A requirements. When using this method make sure you are familiar with PDF/A + * document requirements. If you are not sure, use dedicated iText PDF/A module to create valid PDF/A documents. + * + * @param aConformance the PDF/A conformance which will be added to XMP metadata + * + * @return this {@link WriterProperties} instance + */ + public WriterProperties addPdfAXmpMetadata(PdfAConformance aConformance) { + this.addPdfAXmpMetadata = aConformance; + addXmpMetadata(); + return this; + } + + /** + * Adds PDF/UA XMP metadata to the PDF document. + * + *

+ * This method calls {@link #addXmpMetadata()} implicitly. + * + *

+ * NOTE: Calling this method only affects the XMP metadata, but doesn't enable any additional checks that the + * created document meets all PDF/UA requirements. When using this method make sure you are familiar with PDF/UA + * document requirements. If you are not sure, use dedicated iText PDF/UA module to create valid PDF/UA documents. + * + * @param uaConformance the PDF/UA conformance which will be added to XMP metadata + * + * @return this {@link WriterProperties} instance + */ + public WriterProperties addPdfUaXmpMetadata(PdfUAConformance uaConformance) { + this.addPdfUaXmpMetadata = uaConformance; + addXmpMetadata(); + return this; + } + /** * Defines the level of compression for the document. * See {@link CompressionConstants} @@ -157,10 +199,56 @@ public WriterProperties setFullCompressionMode(boolean fullCompressionMode) { * {@link EncryptionConstants#EMBEDDED_FILES_ONLY} as false; * {@link EncryptionConstants#STANDARD_ENCRYPTION_128} implicitly sets * {@link EncryptionConstants#EMBEDDED_FILES_ONLY} as false; + * * @return this {@link WriterProperties} instance */ - public WriterProperties setStandardEncryption(byte[] userPassword, byte[] ownerPassword, int permissions, int encryptionAlgorithm) { - encryptionProperties.setStandardEncryption(userPassword, ownerPassword, permissions, encryptionAlgorithm); + public WriterProperties setStandardEncryption(byte[] userPassword, byte[] ownerPassword, int permissions, + int encryptionAlgorithm) { + return setStandardEncryption(userPassword, ownerPassword, permissions, encryptionAlgorithm, + EncryptionProperties.DEFAULT_MAC_PROPERTIES); + } + + /** + * Sets the encryption options for the document. + * + * @param userPassword the user password. Can be null or of zero length, which is equal to + * omitting the user password + * @param ownerPassword the owner password. If it's null or empty, iText will generate + * a random string to be used as the owner password + * @param permissions the user permissions + * The open permissions for the document can be + * {@link EncryptionConstants#ALLOW_PRINTING}, + * {@link EncryptionConstants#ALLOW_MODIFY_CONTENTS}, + * {@link EncryptionConstants#ALLOW_COPY}, + * {@link EncryptionConstants#ALLOW_MODIFY_ANNOTATIONS}, + * {@link EncryptionConstants#ALLOW_FILL_IN}, + * {@link EncryptionConstants#ALLOW_SCREENREADERS}, + * {@link EncryptionConstants#ALLOW_ASSEMBLY} and + * {@link EncryptionConstants#ALLOW_DEGRADED_PRINTING}. + * The permissions can be combined by ORing them + * @param encryptionAlgorithm the type of encryption. It can be one of + * {@link EncryptionConstants#STANDARD_ENCRYPTION_40}, + * {@link EncryptionConstants#STANDARD_ENCRYPTION_128}, + * {@link EncryptionConstants#ENCRYPTION_AES_128} + * or {@link EncryptionConstants#ENCRYPTION_AES_256}. + * Optionally {@link EncryptionConstants#DO_NOT_ENCRYPT_METADATA} can be ORed + * to output the metadata in cleartext. + * {@link EncryptionConstants#EMBEDDED_FILES_ONLY} can be ORed as well. + * Please be aware that the passed encryption types may override permissions: + * {@link EncryptionConstants#STANDARD_ENCRYPTION_40} implicitly sets + * {@link EncryptionConstants#DO_NOT_ENCRYPT_METADATA} and + * {@link EncryptionConstants#EMBEDDED_FILES_ONLY} as false; + * {@link EncryptionConstants#STANDARD_ENCRYPTION_128} implicitly sets + * {@link EncryptionConstants#EMBEDDED_FILES_ONLY} as false; + * @param macProperties {@link MacProperties} class to configure MAC integrity protection properties. + * Pass {@code null} if you want to disable MAC protection for any reason + * + * @return this {@link WriterProperties} instance + */ + public WriterProperties setStandardEncryption(byte[] userPassword, byte[] ownerPassword, int permissions, + int encryptionAlgorithm, MacProperties macProperties) { + encryptionProperties.setStandardEncryption( + userPassword, ownerPassword, permissions, encryptionAlgorithm, macProperties); return this; } @@ -194,21 +282,66 @@ public WriterProperties setStandardEncryption(byte[] userPassword, byte[] ownerP * {@link EncryptionConstants#EMBEDDED_FILES_ONLY} as false; * {@link EncryptionConstants#STANDARD_ENCRYPTION_128} implicitly sets * {@link EncryptionConstants#EMBEDDED_FILES_ONLY} as false; + * * @return this {@link WriterProperties} instance */ public WriterProperties setPublicKeyEncryption(Certificate[] certs, int[] permissions, int encryptionAlgorithm) { + return setPublicKeyEncryption(certs, permissions, encryptionAlgorithm, + EncryptionProperties.DEFAULT_MAC_PROPERTIES); + } + + /** + * Sets the certificate encryption options for the document. An array of one or more public certificates + * must be provided together with an array of the same size for the permissions for each certificate. + * + * @param certs the public certificates to be used for the encryption + * @param permissions the user permissions for each of the certificates + * The open permissions for the document can be + * {@link EncryptionConstants#ALLOW_PRINTING}, + * {@link EncryptionConstants#ALLOW_MODIFY_CONTENTS}, + * {@link EncryptionConstants#ALLOW_COPY}, + * {@link EncryptionConstants#ALLOW_MODIFY_ANNOTATIONS}, + * {@link EncryptionConstants#ALLOW_FILL_IN}, + * {@link EncryptionConstants#ALLOW_SCREENREADERS}, + * {@link EncryptionConstants#ALLOW_ASSEMBLY} and + * {@link EncryptionConstants#ALLOW_DEGRADED_PRINTING}. + * The permissions can be combined by ORing them + * @param encryptionAlgorithm the type of encryption. It can be one of + * {@link EncryptionConstants#STANDARD_ENCRYPTION_40}, + * {@link EncryptionConstants#STANDARD_ENCRYPTION_128}, + * {@link EncryptionConstants#ENCRYPTION_AES_128} + * or {@link EncryptionConstants#ENCRYPTION_AES_256}. + * Optionally {@link EncryptionConstants#DO_NOT_ENCRYPT_METADATA} can be ORed + * to output the metadata in cleartext. + * {@link EncryptionConstants#EMBEDDED_FILES_ONLY} can be ORed as well. + * Please be aware that the passed encryption types may override permissions: + * {@link EncryptionConstants#STANDARD_ENCRYPTION_40} implicitly sets + * {@link EncryptionConstants#DO_NOT_ENCRYPT_METADATA} and + * {@link EncryptionConstants#EMBEDDED_FILES_ONLY} as false; + * {@link EncryptionConstants#STANDARD_ENCRYPTION_128} implicitly sets + * {@link EncryptionConstants#EMBEDDED_FILES_ONLY} as false; + * @param macProperties {@link MacProperties} class to configure MAC integrity protection properties. + * Pass {@code null} if you want to disable MAC protection for any reason + * + * @return this {@link WriterProperties} instance + */ + public WriterProperties setPublicKeyEncryption(Certificate[] certs, int[] permissions, int encryptionAlgorithm, + MacProperties macProperties) { BouncyCastleFactoryCreator.getFactory().isEncryptionFeatureSupported(encryptionAlgorithm, true); - encryptionProperties.setPublicKeyEncryption(certs, permissions, encryptionAlgorithm); + encryptionProperties.setPublicKeyEncryption(certs, permissions, encryptionAlgorithm, macProperties); return this; } /** - * The /ID entry of a document contains an array with two entries. The first one (initial id) represents the initial document id. + * The /ID entry of a document contains an array with two entries. + * The first one (initial id) represents the initial document id. * It's a permanent identifier based on the contents of the file at the time it was originally created * and does not change when the file is incrementally updated. - * To help ensure the uniqueness of file identifiers, it is recommend to be computed by means of a message digest algorithm such as MD5. + * To help ensure the uniqueness of file identifiers, + * it is recommended to be computed by means of a message digest algorithm such as MD5. * - * iText will by default keep the existing initial id. But if you'd like you can set this id yourself using this setter. + * iText will by default keep the existing initial id. + * But if you'd like you can set this id yourself using this setter. * * @param initialDocumentId the new initial document id * @return this {@link WriterProperties} instance @@ -231,19 +364,6 @@ public WriterProperties setModifiedDocumentId(PdfString modifiedDocumentId) { return this; } - /** - * This method marks the document as PDF/UA and sets related flags is XMPMetaData. - * This method calls {@link #addXmpMetadata()} implicitly. - * NOTE: iText does not validate PDF/UA, which means we don't check if created PDF meets all PDF/UA requirements. - * Don't use this method if you are not familiar with PDF/UA specification in order to avoid creation of non-conformant PDF/UA file. - * - * @return this {@link WriterProperties} instance - */ - public WriterProperties addUAXmpMetadata() { - this.addUAXmpMetadata = true; - return addXmpMetadata(); - } - boolean isStandardEncryptionUsed() { return encryptionProperties.isStandardEncryptionUsed(); } diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/XmpMetaInfoConverter.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/XmpMetaInfoConverter.java index 2b4f2f81e6..5fca9b94c9 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/pdf/XmpMetaInfoConverter.java +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/XmpMetaInfoConverter.java @@ -27,7 +27,6 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.xmp.XMPConst; import com.itextpdf.kernel.xmp.XMPException; import com.itextpdf.kernel.xmp.XMPMeta; -import com.itextpdf.kernel.xmp.XMPMetaFactory; import com.itextpdf.kernel.xmp.options.PropertyOptions; import com.itextpdf.kernel.xmp.properties.XMPProperty; @@ -36,11 +35,9 @@ class XmpMetaInfoConverter { private XmpMetaInfoConverter() { } - static void appendMetadataToInfo(byte[] xmpMetadata, PdfDocumentInfo info) { - if (xmpMetadata != null) { + static void appendMetadataToInfo(XMPMeta meta, PdfDocumentInfo info) { + if (meta != null) { try { - XMPMeta meta = XMPMetaFactory.parseFromBuffer(xmpMetadata); - XMPProperty title = meta.getLocalizedText(XMPConst.NS_DC, PdfConst.Title, XMPConst.X_DEFAULT, XMPConst.X_DEFAULT); if (title != null) { info.setTitle(title.getValue()); diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/canvas/PdfCanvas.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/canvas/PdfCanvas.java index f7d35aec62..54120e1f34 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/pdf/canvas/PdfCanvas.java +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/canvas/PdfCanvas.java @@ -43,7 +43,7 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.geom.AffineTransform; import com.itextpdf.kernel.geom.Rectangle; import com.itextpdf.kernel.geom.Vector; -import com.itextpdf.kernel.pdf.IsoKey; +import com.itextpdf.kernel.pdf.PageContentRotationHelper; import com.itextpdf.kernel.pdf.PdfArray; import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.kernel.pdf.PdfDocument; @@ -60,7 +60,7 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.colorspace.PdfColorSpace; import com.itextpdf.kernel.pdf.colorspace.PdfDeviceCs; import com.itextpdf.kernel.pdf.colorspace.PdfPattern; -import com.itextpdf.kernel.pdf.colorspace.PdfShading; +import com.itextpdf.kernel.pdf.colorspace.shading.AbstractPdfShading; import com.itextpdf.kernel.pdf.colorspace.PdfSpecialCs; import com.itextpdf.kernel.pdf.extgstate.PdfExtGState; import com.itextpdf.kernel.pdf.layer.IPdfOCG; @@ -70,6 +70,16 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.xobject.PdfFormXObject; import com.itextpdf.kernel.pdf.xobject.PdfImageXObject; import com.itextpdf.kernel.pdf.xobject.PdfXObject; +import com.itextpdf.kernel.validation.context.CanvasBmcValidationContext; +import com.itextpdf.kernel.validation.context.CanvasStackValidationContext; +import com.itextpdf.kernel.validation.context.CanvasWritingContentValidationContext; +import com.itextpdf.kernel.validation.context.ExtendedGStateValidationContext; +import com.itextpdf.kernel.validation.context.FillColorValidationContext; +import com.itextpdf.kernel.validation.context.FontGlyphsGStateValidationContext; +import com.itextpdf.kernel.validation.context.FontValidationContext; +import com.itextpdf.kernel.validation.context.InlineImageValidationContext; +import com.itextpdf.kernel.validation.context.RenderingIntentValidationContext; +import com.itextpdf.kernel.validation.context.StrokeColorValidationContext; import java.util.ArrayList; import java.util.Iterator; @@ -234,9 +244,9 @@ public PdfCanvas(PdfPage page, boolean wrapOldContent) { contentStream.getOutputStream().writeBytes(ByteUtils.getIsoBytes("Q\n")); } if (page.getRotation() != 0 && page.isIgnorePageRotationForContent() - && (wrapOldContent || !page.isPageRotationInverseMatrixWritten())) { + && (wrapOldContent || !PageContentRotationHelper.isPageRotationInverseMatrixWritten(page))) { applyRotation(page); - page.setPageRotationInverseMatrixWritten(); + PageContentRotationHelper.setPageRotationInverseMatrixWritten(page); } this.drawingOnPage = true; } @@ -315,7 +325,7 @@ public void release() { * @return current canvas. */ public PdfCanvas saveState() { - document.checkIsoConformance('q', IsoKey.CANVAS_STACK); + document.checkIsoConformance(new CanvasStackValidationContext('q')); gsStack.push(currentGs); currentGs = new CanvasGraphicsState(currentGs); contentStream.getOutputStream().writeBytes(q); @@ -328,7 +338,7 @@ public PdfCanvas saveState() { * @return current canvas. */ public PdfCanvas restoreState() { - document.checkIsoConformance('Q', IsoKey.CANVAS_STACK); + document.checkIsoConformance(new CanvasStackValidationContext('Q')); if (gsStack.isEmpty()) { throw new PdfException(KernelExceptionMessageConstant.UNBALANCED_SAVE_RESTORE_STATE_OPERATORS); } @@ -723,7 +733,7 @@ public PdfCanvas showText(GlyphLine text) { */ public PdfCanvas showText(GlyphLine text, Iterator iterator) { checkDefaultDeviceGrayBlackColor(getColorKeyForText()); - document.checkIsoConformance(currentGs, IsoKey.FONT_GLYPHS, null, contentStream); + document.checkIsoConformance(new FontGlyphsGStateValidationContext(currentGs, contentStream)); this.checkIsoConformanceWritingOnContent(); PdfFont font; if ((font = currentGs.getFont()) == null) { @@ -731,7 +741,7 @@ public PdfCanvas showText(GlyphLine text, Iterator iter KernelExceptionMessageConstant.FONT_AND_SIZE_MUST_BE_SET_BEFORE_WRITING_ANY_TEXT, currentGs); } - document.checkIsoConformance(text.toString(), IsoKey.FONT, null, null, currentGs.getFont()); + document.checkIsoConformance(new FontValidationContext(text.toString(), currentGs.getFont())); final float fontSize = FontProgram.convertTextSpaceToGlyphSpace(currentGs.getFontSize()); float charSpacing = currentGs.getCharSpacing(); @@ -739,15 +749,16 @@ public PdfCanvas showText(GlyphLine text, Iterator iter List glyphLineParts = iteratorToList(iterator); for (int partIndex = 0; partIndex < glyphLineParts.size(); ++partIndex) { GlyphLine.GlyphLinePart glyphLinePart = glyphLineParts.get(partIndex); - if (glyphLinePart.actualText != null) { + if (glyphLinePart.getActualText() != null) { PdfDictionary properties = new PdfDictionary(); - properties.put(PdfName.ActualText, new PdfString(glyphLinePart.actualText, PdfEncodings.UNICODE_BIG).setHexWriting(true)); + properties.put(PdfName.ActualText, new PdfString(glyphLinePart.getActualText(), + PdfEncodings.UNICODE_BIG).setHexWriting(true)); beginMarkedContent(PdfName.Span, properties); - } else if (glyphLinePart.reversed) { + } else if (glyphLinePart.isReversed()) { beginMarkedContent(PdfName.ReversedChars); } - int sub = glyphLinePart.start; - for (int i = glyphLinePart.start; i < glyphLinePart.end; i++) { + int sub = glyphLinePart.getStart(); + for (int i = glyphLinePart.getStart(); i < glyphLinePart.getEnd(); i++) { Glyph glyph = text.get(i); if (glyph.hasOffsets()) { if (i - 1 - sub >= 0) { @@ -827,18 +838,18 @@ public PdfCanvas showText(GlyphLine text, Iterator iter sub = i + 1; } } - if (glyphLinePart.end - sub > 0) { - font.writeText(text, sub, glyphLinePart.end - 1, contentStream.getOutputStream()); + if (glyphLinePart.getEnd() - sub > 0) { + font.writeText(text, sub, glyphLinePart.getEnd() - 1, contentStream.getOutputStream()); contentStream.getOutputStream().writeBytes(Tj); } - if (glyphLinePart.actualText != null) { + if (glyphLinePart.getActualText() != null) { endMarkedContent(); - } else if (glyphLinePart.reversed) { + } else if (glyphLinePart.isReversed()) { endMarkedContent(); } - if (glyphLinePart.end > sub && partIndex + 1 < glyphLineParts.size()) { + if (glyphLinePart.getEnd() > sub && partIndex + 1 < glyphLineParts.size()) { contentStream.getOutputStream() - .writeFloat(getSubrangeWidth(text, sub, glyphLinePart.end - 1), true) + .writeFloat(getSubrangeWidth(text, sub, glyphLinePart.getEnd() - 1), true) .writeSpace() .writeFloat(0) .writeSpace() @@ -909,7 +920,7 @@ private float getWordSpacingAddition(Glyph glyph) { */ public PdfCanvas showText(PdfArray textArray) { checkDefaultDeviceGrayBlackColor(getColorKeyForText()); - document.checkIsoConformance(currentGs, IsoKey.FONT_GLYPHS, null, contentStream); + document.checkIsoConformance(new FontGlyphsGStateValidationContext(currentGs, contentStream)); this.checkIsoConformanceWritingOnContent(); if (currentGs.getFont() == null) { throw new PdfException( @@ -923,7 +934,7 @@ public PdfCanvas showText(PdfArray textArray) { text.append(obj); } } - document.checkIsoConformance(text.toString(), IsoKey.FONT, null, null, currentGs.getFont()); + document.checkIsoConformance(new FontValidationContext(text.toString(), currentGs.getFont())); contentStream.getOutputStream().writeBytes(ByteUtils.getIsoBytes("[")); for (PdfObject obj : textArray) { @@ -1269,7 +1280,7 @@ public PdfCanvas circle(double x, double y, double r) { * @param shading a shading object to be painted * @return current canvas. */ - public PdfCanvas paintShading(PdfShading shading) { + public PdfCanvas paintShading(AbstractPdfShading shading) { PdfName shadingName = resources.addShading(shading); contentStream.getOutputStream().write((PdfObject) shadingName).writeSpace().writeBytes(sh); return this; @@ -1583,7 +1594,7 @@ public PdfCanvas setLineDash(float[] array, float phase) { * @return current canvas. */ public PdfCanvas setRenderingIntent(PdfName renderingIntent) { - document.checkIsoConformance(renderingIntent, IsoKey.RENDERING_INTENT); + document.checkIsoConformance(new RenderingIntentValidationContext(renderingIntent)); if (renderingIntent.equals(currentGs.getRenderingIntent())) return this; currentGs.setRenderingIntent(renderingIntent); @@ -1703,7 +1714,11 @@ else if (colorSpace.getPdfObject().isIndirect()) { } contentStream.getOutputStream().writeFloats(colorValue).writeSpace().writeBytes(fill ? scn : SCN); } - document.checkIsoConformance(currentGs, fill ? IsoKey.FILL_COLOR : IsoKey.STROKE_COLOR, resources, contentStream); + if (fill) { + document.checkIsoConformance(new FillColorValidationContext(currentGs, resources, contentStream)); + } else { + document.checkIsoConformance(new StrokeColorValidationContext(currentGs, resources, contentStream)); + } return this; } @@ -1920,6 +1935,7 @@ public PdfCanvas endLayer() { * @see #concatMatrix(double, double, double, double, double, double) */ public PdfXObject addImageWithTransformationMatrix(ImageData image, float a, float b, float c, float d, float e, float f) { + checkIsoConformanceWritingOnContent(); return addImageWithTransformationMatrix(image, a, b, c, d, e, f, false); } @@ -1941,6 +1957,7 @@ public PdfXObject addImageWithTransformationMatrix(ImageData image, float a, flo * @see #concatMatrix(double, double, double, double, double, double) */ public PdfXObject addImageWithTransformationMatrix(ImageData image, float a, float b, float c, float d, float e, float f, boolean asInline) { + checkIsoConformanceWritingOnContent(); if (image.getOriginalType() == ImageType.WMF) { WmfImageHelper wmf = new WmfImageHelper(image); PdfXObject xObject = wmf.createFormXObject(document); @@ -1975,6 +1992,7 @@ public PdfXObject addImageWithTransformationMatrix(ImageData image, float a, flo * @see PdfXObject#calculateProportionallyFitRectangleWithHeight(PdfXObject, float, float, float) */ public PdfXObject addImageFittedIntoRectangle(ImageData image, Rectangle rect, boolean asInline) { + checkIsoConformanceWritingOnContent(); return addImageWithTransformationMatrix(image, rect.getWidth(), 0, 0, rect.getHeight(), rect.getX(), rect.getY(), asInline); } @@ -1989,6 +2007,7 @@ public PdfXObject addImageFittedIntoRectangle(ImageData image, Rectangle rect, b * @return the created imageXObject or null in case of in-line image (asInline = true) */ public PdfXObject addImageAt(ImageData image, float x, float y, boolean asInline) { + checkIsoConformanceWritingOnContent(); if (image.getOriginalType() == ImageType.WMF) { WmfImageHelper wmf = new WmfImageHelper(image); PdfXObject xObject = wmf.createFormXObject(document); @@ -2024,6 +2043,7 @@ public PdfXObject addImageAt(ImageData image, float x, float y, boolean asInline * @see #concatMatrix(double, double, double, double, double, double) */ public PdfCanvas addXObjectWithTransformationMatrix(PdfXObject xObject, float a, float b, float c, float d, float e, float f) { + checkIsoConformanceWritingOnContent(); if (xObject instanceof PdfFormXObject) { return addFormWithTransformationMatrix((PdfFormXObject) xObject, a, b, c, d, e, f, true); } else if (xObject instanceof PdfImageXObject) { @@ -2042,6 +2062,7 @@ public PdfCanvas addXObjectWithTransformationMatrix(PdfXObject xObject, float a, * @return the current canvas */ public PdfCanvas addXObjectAt(PdfXObject xObject, float x, float y) { + checkIsoConformanceWritingOnContent(); if (xObject instanceof PdfFormXObject) { return addFormAt((PdfFormXObject) xObject, x, y); } else if (xObject instanceof PdfImageXObject) { @@ -2061,6 +2082,7 @@ public PdfCanvas addXObjectAt(PdfXObject xObject, float x, float y) { * @see PdfXObject#calculateProportionallyFitRectangleWithHeight(PdfXObject, float, float, float) */ public PdfCanvas addXObjectFittedIntoRectangle(PdfXObject xObject, Rectangle rect) { + checkIsoConformanceWritingOnContent(); if (xObject instanceof PdfFormXObject) { return addFormFittedIntoRectangle((PdfFormXObject) xObject, rect); } else if (xObject instanceof PdfImageXObject) { @@ -2081,6 +2103,7 @@ public PdfCanvas addXObjectFittedIntoRectangle(PdfXObject xObject, Rectangle rec * @return the current canvas */ public PdfCanvas addXObject(PdfXObject xObject) { + checkIsoConformanceWritingOnContent(); if (xObject instanceof PdfFormXObject) { return addFormWithTransformationMatrix((PdfFormXObject) xObject, 1, 0, 0, 1, 0, 0, false); } else if (xObject instanceof PdfImageXObject) { @@ -2101,7 +2124,7 @@ public PdfCanvas setExtGState(PdfExtGState extGState) { currentGs.updateFromExtGState(extGState, document); PdfName name = resources.addExtGState(extGState); contentStream.getOutputStream().write(name).writeSpace().writeBytes(gs); - document.checkIsoConformance(currentGs, IsoKey.EXTENDED_GRAPHICS_STATE, null, contentStream); + document.checkIsoConformance(new ExtendedGStateValidationContext(currentGs, contentStream)); return this; } @@ -2146,7 +2169,7 @@ public PdfCanvas beginMarkedContent(PdfName tag, PdfDictionary properties) { } final Tuple2 tuple2 = new Tuple2<>(tag, properties); if (this.drawingOnPage){ - document.checkIsoConformance(tagStructureStack, IsoKey.CANVAS_BEGIN_MARKED_CONTENT, null, null, tuple2); + document.checkIsoConformance(new CanvasBmcValidationContext(tagStructureStack, tuple2)); } tagStructureStack.push(tuple2); return this; @@ -2260,12 +2283,14 @@ public PdfStream getContentStream() { * @param f an element of the transformation matrix */ protected void addInlineImage(PdfImageXObject imageXObject, float a, float b, float c, float d, float e, float f) { - document.checkIsoConformance(imageXObject.getPdfObject(), IsoKey.INLINE_IMAGE, resources, contentStream); + document.checkIsoConformance(new InlineImageValidationContext(imageXObject.getPdfObject(), resources)); + checkIsoConformanceWritingOnContent(); saveState(); concatMatrix(a, b, c, d, e, f); PdfOutputStream os = contentStream.getOutputStream(); os.writeBytes(BI); byte[] imageBytes = imageXObject.getPdfObject().getBytes(false); + saveColorSpaceToPageResourcesIfNeeded(imageXObject.getPdfObject()); for (Map.Entry entry : imageXObject.getPdfObject().entrySet()) { PdfName key = entry.getKey(); if (!PdfName.Type.equals(key) && !PdfName.Subtype.equals(key) && !PdfName.Length.equals(key)) { @@ -2282,6 +2307,24 @@ protected void addInlineImage(PdfImageXObject imageXObject, float a, float b, fl restoreState(); } + private void saveColorSpaceToPageResourcesIfNeeded(PdfStream image) { + PdfObject colorSpace = image.get(PdfName.ColorSpace); + //The colour space specified by the ColorSpace (or CS) entry shall be one of the standard device colour spaces + //(DeviceGray, DeviceRGB, or DeviceCMYK). + if (colorSpace == null + || colorSpace.equals(PdfName.DeviceGray) + || colorSpace.equals(PdfName.DeviceRGB) + || colorSpace.equals(PdfName.DeviceCMYK)) { + return; + } + //PDF 1.2: the value of the ColorSpace entry may also be the name of a colour space in the ColorSpace + //subdictionary of the current resource dictionary. In this case, the name may designate any colour space + //that can be used with an image XObject. + PdfName name = resources.addColorSpace(colorSpace); + image.remove(PdfName.ColorSpace); + image.put(PdfName.ColorSpace, name); + } + /** * Adds {@link PdfFormXObject} to canvas. * @@ -2418,20 +2461,20 @@ private PdfStream ensureStreamDataIsReadyToBeProcessed(PdfStream stream) { * @param text the text to write. */ private void showTextInt(String text) { - document.checkIsoConformance(currentGs, IsoKey.FONT_GLYPHS, null, contentStream); + document.checkIsoConformance(new FontGlyphsGStateValidationContext(currentGs, contentStream)); if (currentGs.getFont() == null) { throw new PdfException( KernelExceptionMessageConstant.FONT_AND_SIZE_MUST_BE_SET_BEFORE_WRITING_ANY_TEXT, currentGs); } this.checkIsoConformanceWritingOnContent(); - document.checkIsoConformance(text, IsoKey.FONT, null, null, currentGs.getFont()); + document.checkIsoConformance(new FontValidationContext(text, currentGs.getFont())); currentGs.getFont().writeText(text, contentStream.getOutputStream()); } private void checkIsoConformanceWritingOnContent(){ if (this.drawingOnPage){ - document.checkIsoConformance(tagStructureStack, IsoKey.CANVAS_WRITING_CONTENT); + document.checkIsoConformance(new CanvasWritingContentValidationContext(tagStructureStack)); } } @@ -2509,11 +2552,11 @@ private void checkDefaultDeviceGrayBlackColor(CheckColorMode checkColorMode) { // But it's still important to do not check fill color if it's not used and vice versa if (currentGs.getFillColor() == DeviceGray.BLACK && (checkColorMode == CheckColorMode.FILL || checkColorMode == CheckColorMode.FILL_AND_STROKE)) { - document.checkIsoConformance(currentGs, IsoKey.FILL_COLOR, resources, contentStream); + document.checkIsoConformance(new FillColorValidationContext(currentGs, resources, contentStream)); defaultDeviceGrayBlackColorCheckRequired = false; } else if (currentGs.getStrokeColor() == DeviceGray.BLACK && (checkColorMode == CheckColorMode.STROKE || checkColorMode == CheckColorMode.FILL_AND_STROKE)) { - document.checkIsoConformance(currentGs, IsoKey.STROKE_COLOR, resources, contentStream); + document.checkIsoConformance(new StrokeColorValidationContext(currentGs, resources, contentStream)); defaultDeviceGrayBlackColorCheckRequired = false; } else { // Nothing diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/canvas/parser/ParserGraphicsState.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/canvas/parser/ParserGraphicsState.java index 63dca56416..c77a591d9e 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/pdf/canvas/parser/ParserGraphicsState.java +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/canvas/parser/ParserGraphicsState.java @@ -72,6 +72,7 @@ public void updateCtm(Matrix newCtm) { /** * Intersects the current clipping path with the given path. * + *

* Note: Coordinates of the given path should be in * the transformed user space. * @@ -89,18 +90,20 @@ public void clip(Path path, int fillingRule) { pathCopy.closeAllSubpaths(); IClipper clipper = new DefaultClipper(); - ClipperBridge.addPath(clipper, clippingPath, IClipper.PolyType.SUBJECT); - ClipperBridge.addPath(clipper, pathCopy, IClipper.PolyType.CLIP); + ClipperBridge clipperBridge = new ClipperBridge(clippingPath, pathCopy); + clipperBridge.addPath(clipper, clippingPath, IClipper.PolyType.SUBJECT); + clipperBridge.addPath(clipper, pathCopy, IClipper.PolyType.CLIP); PolyTree resultTree = new PolyTree(); clipper.execute(IClipper.ClipType.INTERSECTION, resultTree, IClipper.PolyFillType.NON_ZERO, ClipperBridge.getFillType(fillingRule)); - clippingPath = ClipperBridge.convertToPath(resultTree); + clippingPath = clipperBridge.convertToPath(resultTree); } /** * Getter for the current clipping path. * + *

* Note: The returned clipping path is in the transformed user space, so * if you want to get it in default user space, apply transformation matrix ({@link CanvasGraphicsState#getCtm()}). * @@ -113,6 +116,7 @@ public Path getClippingPath() { /** * Sets the current clipping path to the specified path. * + *

* Note:This method doesn't modify existing clipping path, * it simply replaces it with the new one instead. * diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/canvas/parser/clipper/ClipperBridge.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/canvas/parser/clipper/ClipperBridge.java index 61dd4bd5a2..db8deb6d16 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/pdf/canvas/parser/clipper/ClipperBridge.java +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/canvas/parser/clipper/ClipperBridge.java @@ -30,8 +30,9 @@ This file is part of the iText (R) project. import java.util.List; /** - * This class contains variety of methods allowing to convert iText - * abstractions into the abstractions of the Clipper library and vise versa. + * This class contains a variety of methods allowing the conversion of iText + * abstractions into abstractions of the Clipper library, and vice versa. + * *

* For example: *

    @@ -41,17 +42,78 @@ This file is part of the iText (R) project. *
*/ public final class ClipperBridge { + private static final long MAX_ALLOWED_VALUE = 0x3FFFFFFFFFFFFFL; /** * Since the clipper library uses integer coordinates, we should convert * our floating point numbers into fixed point numbers by multiplying by * this coefficient. Vary it to adjust the preciseness of the calculations. + * + *

+ * Note that if this value is specified, it will be used for all ClipperBridge instances and + * dynamic float multiplier calculation will be disabled. + * */ - //TODO DEVSIX-5770 make this constant a single non-static configuration - public static double floatMultiplier = Math.pow(10, 14); + public static Double floatMultiplier; - private ClipperBridge() { - //empty constructor + private double approximatedFloatMultiplier = Math.pow(10, 14); + + /** + * Creates new {@link ClipperBridge} instance with default float multiplier value which is 10^14. + * + *

+ * Since the clipper library uses integer coordinates, we should convert our floating point numbers into fixed + * point numbers by multiplying by float multiplier coefficient. It is possible to vary it to adjust the preciseness + * of the calculations: if static {@link #floatMultiplier} is specified, it will be used for all ClipperBridge + * instances and default value will be ignored. + */ + public ClipperBridge() { + // Empty constructor. + } + + /** + * Creates new {@link ClipperBridge} instance with adjusted float multiplier value. This instance will work + * correctly with the provided paths only. + * + *

+ * Since the clipper library uses integer coordinates, we should convert our floating point numbers into fixed + * point numbers by multiplying by float multiplier coefficient. It is calculated automatically, however + * it is possible to vary it to adjust the preciseness of the calculations: if static {@link #floatMultiplier} is + * specified, it will be used for all ClipperBridge instances and automatic calculation won't work. + * + * @param paths paths to calculate multiplier coefficient to convert floating point numbers into fixed point numbers + */ + public ClipperBridge(com.itextpdf.kernel.geom.Path... paths) { + if (floatMultiplier == null) { + List pointsList = new ArrayList<>(); + for (com.itextpdf.kernel.geom.Path path : paths) { + for (Subpath subpath : path.getSubpaths()) { + if (!subpath.isSinglePointClosed() && !subpath.isSinglePointOpen()) { + pointsList.addAll(subpath.getPiecewiseLinearApproximation()); + } + } + } + calculateFloatMultiplier(pointsList.toArray(new com.itextpdf.kernel.geom.Point[0])); + } + } + + /** + * Creates new {@link ClipperBridge} instance with adjusted float multiplier value. This instance will work + * correctly with the provided point only. + * + *

+ * Since the clipper library uses integer coordinates, we should convert our floating point numbers into fixed + * point numbers by multiplying by float multiplier coefficient. It is calculated automatically, however + * it is possible to vary it to adjust the preciseness of the calculations: if static {@link #floatMultiplier} is + * specified, it will be used for all ClipperBridge instances and automatic calculation won't work. + * + * @param points points to calculate multiplier coefficient to convert floating point numbers + * into fixed point numbers + */ + public ClipperBridge(com.itextpdf.kernel.geom.Point[]... points) { + if (floatMultiplier == null) { + calculateFloatMultiplier(points); + } } /** @@ -61,7 +123,7 @@ private ClipperBridge() { * @param result {@link PolyTree} object to convert * @return resultant {@link com.itextpdf.kernel.geom.Path} object */ - public static com.itextpdf.kernel.geom.Path convertToPath(PolyTree result) { + public com.itextpdf.kernel.geom.Path convertToPath(PolyTree result) { com.itextpdf.kernel.geom.Path path = new com.itextpdf.kernel.geom.Path(); PolyNode node = result.getFirst(); @@ -79,7 +141,7 @@ public static com.itextpdf.kernel.geom.Path convertToPath(PolyTree result) { * @param path The {@link com.itextpdf.kernel.geom.Path} object to be added to the {@link IClipper}. * @param polyType See {@link IClipper.PolyType}. */ - public static void addPath(IClipper clipper, com.itextpdf.kernel.geom.Path path, IClipper.PolyType polyType) { + public void addPath(IClipper clipper, com.itextpdf.kernel.geom.Path path, IClipper.PolyType polyType) { for (Subpath subpath : path.getSubpaths()) { if (!subpath.isSinglePointClosed() && !subpath.isSinglePointOpen()) { List linearApproxPoints = subpath.getPiecewiseLinearApproximation(); @@ -101,7 +163,8 @@ public static void addPath(IClipper clipper, com.itextpdf.kernel.geom.Path path, * {@link IClipper.EndType#OPEN_ROUND} * @return {@link java.util.List} consisting of all degenerate iText {@link Subpath}s of the path. */ - public static List addPath(ClipperOffset offset, com.itextpdf.kernel.geom.Path path, IClipper.JoinType joinType, IClipper.EndType endType) { + public List addPath(ClipperOffset offset, com.itextpdf.kernel.geom.Path path, IClipper.JoinType joinType, + IClipper.EndType endType) { List degenerateSubpaths = new ArrayList<>(); for (Subpath subpath : path.getSubpaths()) { @@ -135,13 +198,13 @@ public static List addPath(ClipperOffset offset, com.itextpdf.kernel.ge * @param points the list of {@link Point.LongPoint} objects to convert * @return the resultant list of {@link com.itextpdf.kernel.geom.Point} objects. */ - public static List convertToFloatPoints(List points) { + public List convertToFloatPoints(List points) { List convertedPoints = new ArrayList<>(points.size()); for (Point.LongPoint point : points) { convertedPoints.add(new com.itextpdf.kernel.geom.Point( - point.getX() / floatMultiplier, - point.getY() / floatMultiplier + point.getX() / getFloatMultiplier(), + point.getY() / getFloatMultiplier() )); } @@ -155,13 +218,13 @@ public static List convertToFloatPoints(List convertToLongPoints(List points) { + public List convertToLongPoints(List points) { List convertedPoints = new ArrayList<>(points.size()); for (com.itextpdf.kernel.geom.Point point : points) { convertedPoints.add(new Point.LongPoint( - floatMultiplier * point.getX(), - floatMultiplier * point.getY() + getFloatMultiplier() * point.getX(), + getFloatMultiplier() * point.getY() )); } @@ -238,7 +301,8 @@ public static IClipper.PolyFillType getFillType(int fillingRule) { * path is a subject of clipping or a part of the clipping polygon. * @return true if polygon path was successfully added, false otherwise. */ - public static boolean addPolygonToClipper(IClipper clipper, com.itextpdf.kernel.geom.Point[] polyVertices, IClipper.PolyType polyType) { + public boolean addPolygonToClipper(IClipper clipper, com.itextpdf.kernel.geom.Point[] polyVertices, + IClipper.PolyType polyType) { return clipper.addPath(new Path(convertToLongPoints(new ArrayList<>(Arrays.asList(polyVertices)))), polyType, true); } @@ -257,7 +321,7 @@ public static boolean addPolygonToClipper(IClipper clipper, com.itextpdf.kernel. * to clipper path and added to the clipper instance. * @return true if polyline path was successfully added, false otherwise. */ - public static boolean addPolylineSubjectToClipper(IClipper clipper, com.itextpdf.kernel.geom.Point[] lineVertices) { + public boolean addPolylineSubjectToClipper(IClipper clipper, com.itextpdf.kernel.geom.Point[] lineVertices) { return clipper.addPath(new Path(convertToLongPoints(new ArrayList<>(Arrays.asList(lineVertices)))), IClipper.PolyType.SUBJECT, false); } @@ -267,8 +331,8 @@ public static boolean addPolylineSubjectToClipper(IClipper clipper, com.itextpdf * * @return the width of the rectangle. */ - public static float longRectCalculateWidth(LongRect rect) { - return (float) (Math.abs(rect.left - rect.right) / ClipperBridge.floatMultiplier); + public float longRectCalculateWidth(LongRect rect) { + return (float) (Math.abs(rect.left - rect.right) / getFloatMultiplier()); } /** @@ -277,11 +341,23 @@ public static float longRectCalculateWidth(LongRect rect) { * * @return the height of the rectangle. */ - public static float longRectCalculateHeight(LongRect rect) { - return (float) (Math.abs(rect.top - rect.bottom) / ClipperBridge.floatMultiplier); + public float longRectCalculateHeight(LongRect rect) { + return (float) (Math.abs(rect.top - rect.bottom) / getFloatMultiplier()); + } + + /** + * Gets multiplier coefficient for converting our floating point numbers into fixed point numbers. + * + * @return multiplier coefficient for converting our floating point numbers into fixed point numbers + */ + public double getFloatMultiplier() { + if (floatMultiplier == null) { + return approximatedFloatMultiplier; + } + return (double) floatMultiplier; } - static void addContour(com.itextpdf.kernel.geom.Path path, List contour, boolean close) { + void addContour(com.itextpdf.kernel.geom.Path path, List contour, boolean close) { List floatContour = convertToFloatPoints(contour); com.itextpdf.kernel.geom.Point point = floatContour.get(0); path.moveTo((float) point.getX(), (float) point.getY()); @@ -295,4 +371,19 @@ static void addContour(com.itextpdf.kernel.geom.Path path, List path.closeSubpath(); } } + + private void calculateFloatMultiplier(com.itextpdf.kernel.geom.Point[]... points) { + double maxPoint = 0; + for (com.itextpdf.kernel.geom.Point[] pointsArray : points) { + for (com.itextpdf.kernel.geom.Point point : pointsArray) { + maxPoint = Math.max(maxPoint, Math.abs(point.getX())); + maxPoint = Math.max(maxPoint, Math.abs(point.getY())); + } + } + // The significand of the double type is approximately 15 to 17 decimal digits for most platforms. + double epsilon = 1E-16; + if (maxPoint > epsilon) { + this.approximatedFloatMultiplier = Math.floor(MAX_ALLOWED_VALUE / maxPoint); + } + } } diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/canvas/parser/data/TextRenderInfo.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/canvas/parser/data/TextRenderInfo.java index 6fa9f2f22a..dba9f08f6b 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/pdf/canvas/parser/data/TextRenderInfo.java +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/canvas/parser/data/TextRenderInfo.java @@ -106,10 +106,10 @@ public String getText() { if (text == null) { GlyphLine gl = gs.getFont().decodeIntoGlyphLine(string); if (!isReversedChars()) { - text = gl.toUnicodeString(gl.start, gl.end); + text = gl.toUnicodeString(gl.getStart(), gl.getEnd()); } else { - StringBuilder sb = new StringBuilder(gl.end - gl.start); - for (int i = gl.end - 1; i >= gl.start; i--) { + StringBuilder sb = new StringBuilder(gl.getEnd() - gl.getStart()); + for (int i = gl.getEnd() - 1; i >= gl.getStart(); i--) { sb.append(gl.get(i).getUnicodeChars()); } text = sb.toString(); @@ -521,7 +521,7 @@ private PdfString[] splitString(PdfString string) { // Number of bytes forming one glyph can be arbitrary from [1; 4] range List strings = new ArrayList<>(); GlyphLine glyphLine = gs.getFont().decodeIntoGlyphLine(string); - for (int i = glyphLine.start; i < glyphLine.end; i++) { + for (int i = glyphLine.getStart(); i < glyphLine.getEnd(); i++) { strings.add(new PdfString(gs.getFont().convertToBytes(glyphLine.get(i)))); } return strings.toArray(new PdfString[strings.size()]); diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/canvas/parser/listener/DefaultPdfTextLocation.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/canvas/parser/listener/DefaultPdfTextLocation.java index 621b77c253..20da898ac2 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/pdf/canvas/parser/listener/DefaultPdfTextLocation.java +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/canvas/parser/listener/DefaultPdfTextLocation.java @@ -28,44 +28,55 @@ This file is part of the iText (R) project. * This class acts as a default implementation of IPdfTextLocation */ public class DefaultPdfTextLocation implements IPdfTextLocation { - - private int pageNr; private Rectangle rectangle; private String text; - public DefaultPdfTextLocation(int pageNr, Rectangle rect, String text) { - this.pageNr = pageNr; + /** + * Creates new pdf text location. + * + * @param rect text rectangle on pdf canvas + * @param text actual text on designated area of canvas + */ + public DefaultPdfTextLocation(Rectangle rect, String text) { this.rectangle = rect; this.text = text; } + /** + * {@inheritDoc} + */ @Override public Rectangle getRectangle() { return rectangle; } + /** + * Sets text rectangle (occupied area) for this pdf text location. + * + * @param rectangle new text rectangle + * @return this {@code DefaultPdfTextLocation} instance + */ public DefaultPdfTextLocation setRectangle(Rectangle rectangle) { this.rectangle = rectangle; return this; } + /** + * {@inheritDoc} + */ @Override public String getText() { return text; } + /** + * Sets text for this pdf text location. + * + * @param text new text + * @return this {@code DefaultPdfTextLocation} instance + */ public DefaultPdfTextLocation setText(String text) { this.text = text; return this; } - - @Override - public int getPageNumber() { - return pageNr; - } - - public DefaultPdfTextLocation setPageNr(int pageNr) { - this.pageNr = pageNr; - return this; - } } diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/canvas/parser/listener/IPdfTextLocation.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/canvas/parser/listener/IPdfTextLocation.java index c45e69e69e..5e12225a09 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/pdf/canvas/parser/listener/IPdfTextLocation.java +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/canvas/parser/listener/IPdfTextLocation.java @@ -39,12 +39,4 @@ public interface IPdfTextLocation { * @return the text */ String getText(); - - /** - * Get the page number of the page on which the text is located - * - * @return the page number, or 0 if no page number was set - */ - int getPageNumber(); - } diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/canvas/parser/listener/RegexBasedLocationExtractionStrategy.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/canvas/parser/listener/RegexBasedLocationExtractionStrategy.java index cdccf83867..d069097b05 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/pdf/canvas/parser/listener/RegexBasedLocationExtractionStrategy.java +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/canvas/parser/listener/RegexBasedLocationExtractionStrategy.java @@ -40,11 +40,27 @@ This file is part of the iText (R) project. /** * This class is designed to search for the occurrences of a regular expression and return the resultant rectangles. + * Do note that this class holds all text locations and can't be used for processing multiple pages. + * If you want to extract text from several pages of pdf document you have to create a new instance + * of {@link RegexBasedLocationExtractionStrategy} for each page. + *

+ * Here is an example of usage with new instance per each page: + * + * PdfDocument document = new PdfDocument(new PdfReader("...")); + * for (int i = 1; i <= document.getNumberOfPages(); ++i) { + * RegexBasedLocationExtractionStrategy extractionStrategy = new RegexBasedLocationExtractionStrategy(""); + * PdfCanvasProcessor processor = new PdfCanvasProcessor(extractionStrategy); + * processor.processPageContent(document.getPage(i)); + * for (IPdfTextLocation location : extractionStrategy.getResultantLocations()) { + * //process locations ... + * } + * } + * */ public class RegexBasedLocationExtractionStrategy implements ILocationExtractionStrategy { private static final float EPS = 1.0E-4F; - private Pattern pattern; - private List parseResult = new ArrayList<>(); + private final Pattern pattern; + private final List parseResult = new ArrayList<>(); public RegexBasedLocationExtractionStrategy(String regex) { this.pattern = Pattern.compile(regex); @@ -54,6 +70,9 @@ public RegexBasedLocationExtractionStrategy(Pattern pattern) { this.pattern = pattern; } + /** + * {@inheritDoc} + */ @Override public Collection getResultantLocations() { // align characters in "logical" order @@ -70,7 +89,7 @@ public Collection getResultantLocations() { Integer endIndex = getEndIndex(txt.indexMap, mat.end() - 1); if (startIndex != null && endIndex != null && startIndex <= endIndex) { for (Rectangle r : toRectangles(parseResult.subList(startIndex.intValue(), endIndex.intValue() + 1))) { - retval.add(new DefaultPdfTextLocation(0, r, mat.group(0))); + retval.add(new DefaultPdfTextLocation(r, mat.group(0))); } } } @@ -88,29 +107,20 @@ public Collection getResultantLocations() { return retval; } - private void removeDuplicates(List sortedList) { - IPdfTextLocation lastItem = null; - int orgSize = sortedList.size(); - for (int i = orgSize - 1; i >= 0; i--) { - IPdfTextLocation currItem = sortedList.get(i); - Rectangle currRect = currItem.getRectangle(); - if (lastItem != null && currRect.equalsWithEpsilon(lastItem.getRectangle())) { - sortedList.remove(currItem); - } - lastItem = currItem; - } - } - + /** + * {@inheritDoc} + */ @Override public void eventOccurred(IEventData data, EventType type) { - if (data instanceof TextRenderInfo) { - parseResult.addAll(toCRI((TextRenderInfo) data)); - } + parseResult.addAll(toCRI((TextRenderInfo) data)); } + /** + * {@inheritDoc} + */ @Override public Set getSupportedEvents() { - return null; + return Collections.singleton(EventType.RENDER_TEXT); } /** @@ -169,6 +179,19 @@ protected List toRectangles(List cris) { return retval; } + private void removeDuplicates(List sortedList) { + IPdfTextLocation lastItem = null; + int orgSize = sortedList.size(); + for (int i = orgSize - 1; i >= 0; i--) { + IPdfTextLocation currItem = sortedList.get(i); + Rectangle currRect = currItem.getRectangle(); + if (lastItem != null && currRect.equalsWithEpsilon(lastItem.getRectangle())) { + sortedList.remove(currItem); + } + lastItem = currItem; + } + } + private static Integer getStartIndex(Map indexMap, int index, String txt) { while (!indexMap.containsKey(index) && index < txt.length()) { diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/canvas/parser/util/InlineImageParsingUtils.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/canvas/parser/util/InlineImageParsingUtils.java index e73e95a033..92aaa0e45a 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/pdf/canvas/parser/util/InlineImageParsingUtils.java +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/canvas/parser/util/InlineImageParsingUtils.java @@ -22,6 +22,7 @@ This file is part of the iText (R) project. */ package com.itextpdf.kernel.pdf.canvas.parser.util; +import com.itextpdf.commons.utils.MessageFormatUtil; import com.itextpdf.io.source.PdfTokenizer; import com.itextpdf.kernel.exceptions.PdfException; import com.itextpdf.kernel.exceptions.KernelExceptionMessageConstant; @@ -32,10 +33,11 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfObject; import com.itextpdf.kernel.pdf.PdfReader; import com.itextpdf.kernel.pdf.PdfStream; -import com.itextpdf.kernel.pdf.filters.DoNothingFilter; import com.itextpdf.kernel.pdf.filters.FilterHandlers; import com.itextpdf.kernel.pdf.filters.IFilterHandler; import com.itextpdf.kernel.pdf.filters.FlateDecodeStrictFilter; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -47,7 +49,7 @@ This file is part of the iText (R) project. */ public final class InlineImageParsingUtils { - private static final byte[] EI = new byte[]{(byte)'E', (byte)'I'}; + private static final Logger LOGGER = LoggerFactory.getLogger(InlineImageParsingUtils.class); private InlineImageParsingUtils() { } @@ -166,12 +168,23 @@ static int getComponentsPerPixel(PdfName colorSpaceName, PdfDictionary colorSpac return getComponentsPerPixel(tempName, colorSpaceDic); } } else { - if (PdfName.Indexed.equals(colorSpace.getAsName(0))) { + if (PdfName.Indexed.equals(colorSpace.getAsName(0)) + || PdfName.CalGray.equals(colorSpace.getAsName(0)) + || PdfName.Pattern.equals(colorSpace.getAsName(0)) + || PdfName.Separation.equals(colorSpace.getAsName(0))) { return 1; } + if (PdfName.CalRGB.equals(colorSpace.getAsName(0)) + || PdfName.Lab.equals(colorSpace.getAsName(0))) { + return 3; + } if (PdfName.ICCBased.equals(colorSpace.getAsName(0))) { return colorSpace.getAsStream(1).getAsNumber(PdfName.N).intValue(); } + if (PdfName.DeviceN.equals(colorSpace.getAsName(0))) { + //Checking colorants dict size + return colorSpace.getAsArray(1).size(); + } } } @@ -199,11 +212,11 @@ private static PdfDictionary parseDictionary(PdfCanvasParser ps) throws IOExcept dict.put(resolvedKey, getAlternateValue(resolvedKey, value)); } - int ch = ps.getTokeniser().read(); - if (!PdfTokenizer.isWhitespace(ch)) - throw new InlineImageParseException( - KernelExceptionMessageConstant.UNEXPECTED_CHARACTER_FOUND_AFTER_ID_IN_INLINE_IMAGE - ).setMessageParams(ch); + int ch = ps.getTokeniser().peek(); + //ASCIIHexDecode and ASCII85Decode are not required to have a whitespace after ID operator + if (PdfTokenizer.isWhitespace(ch)) { + ps.getTokeniser().read(); + } return dict; } @@ -273,8 +286,9 @@ private static int computeBytesPerRow(PdfDictionary imageDictionary, PdfDictiona private static byte[] parseUnfilteredSamples(PdfDictionary imageDictionary, PdfDictionary colorSpaceDic, PdfCanvasParser ps) throws IOException { // special case: when no filter is specified, we just read the number of bits // per component, multiplied by the width and height. - if (imageDictionary.containsKey(PdfName.Filter)) + if (imageDictionary.containsKey(PdfName.Filter)) { throw new IllegalArgumentException("Dictionary contains filters"); + } PdfNumber h = imageDictionary.getAsNumber(PdfName.Height); @@ -326,43 +340,105 @@ private static byte[] parseUnfilteredSamples(PdfDictionary imageDictionary, PdfD private static byte[] parseSamples(PdfDictionary imageDictionary, PdfDictionary colorSpaceDic, PdfCanvasParser ps) throws IOException { // by the time we get to here, we have already parsed the ID operator + //If image is unfiltered then we can calculate exact number of bytes it occupies if (!imageDictionary.containsKey(PdfName.Filter) && imageColorSpaceIsKnown(imageDictionary, colorSpaceDic)) { return parseUnfilteredSamples(imageDictionary, colorSpaceDic, ps); } - - // read all content until we reach an EI operator followed by whitespace. - // then decode the content stream to check that bytes that were parsed are really all image bytes - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - int ch; - int found = 0; - PdfTokenizer tokeniser = ps.getTokeniser(); - while ((ch = tokeniser.read()) != -1) { - if (ch == 'E') { - // probably some bytes were preserved so write them - baos.write(EI, 0, found); - // just preserve 'E' and do not write it immediately - found = 1; - } else if (found == 1 && ch == 'I') { - // just preserve 'EI' and do not write it immediately - found = 2; - } else { - if (found == 2 && PdfTokenizer.isWhitespace(ch)) { - byte[] tmp = baos.toByteArray(); - if (inlineImageStreamBytesAreComplete(tmp, imageDictionary)) { - return tmp; - } + PdfTokenizer tokenizer = ps.getTokeniser(); + ByteArrayOutputStream imageStream = new ByteArrayOutputStream(); + int lastByte = tokenizer.read(); + int currentByte = tokenizer.read(); + // PDF spec is unclear about how to parse inline images. Should a whitespace + // appear before EI or not, so reading until EI or EOF. + while(currentByte != -1) { + if (lastByte == 'E' + && currentByte == 'I' + && PdfTokenizer.isWhitespace(tokenizer.peek()) + && !followedByBinaryData(tokenizer)) { + byte[] image = imageStream.toByteArray(); + //Try to decode inline image as an additional safeguard and also to check for unsupported encodings + if (inlineImageStreamBytesAreComplete(image, imageDictionary)) { + return image; } - // probably some bytes were preserved so write them - baos.write(EI, 0, found); - baos.write(ch); - found = 0; } + imageStream.write(lastByte); + lastByte = currentByte; + currentByte = tokenizer.read(); } + //If EOF was encountered than image was not parsed throw new InlineImageParseException(KernelExceptionMessageConstant.CANNOT_FIND_IMAGE_DATA_OR_EI); } + /** + * Check whether next several bytes of tokenizer contain binary data. + * This method probes 10 bytes and tries to find pdf operator in them. + * + * @param tokenizer pdf tokenizer. + * + * @return true if next 10 bytes is binary data, false if they're most likely pdf operators. + * + * @throws IOException if any I/O error occurs + */ + private static boolean followedByBinaryData(PdfTokenizer tokenizer) throws IOException { + byte[] testSequence = new byte[10]; + tokenizer.peek(testSequence); + // We don't need to cleanup possible zeroes at the end, they aer whitespaces + // so can't break our logic in followedByBinaryData(byteArr) + boolean isBinaryData = false; + int operatorStart = -1; + int operatorEnd = -1; + + for (int i = 0; i < testSequence.length; ++i) { + final byte b = testSequence[i]; + //Checking for ASCII and Unicode common control characters except spaces: + // 0x00 0x10 + //0x00 NUL DLE + //0x01 SOH DC1 + //0x02 STX DC2 + //0x03 ETX DC3 + //0x04 EOT DC4 + //0x05 ENQ NAK + //0x06 ACK SYN + //0x07 BEL ETB + //0x08 BS CAN + //0x09 HT EM + //0x0A LF SUB + //0x0B VT ESC + //0x0C FF FS + //0x0D CR GS + //0x0E SO RS + //0x0F SI US + //0x7F DEL -> we have binary data + // Also if we have any byte > 0x7f (byte < 0) than we treat it also as binary data + // because pdf operators are in range 0x0 - 0x7f + if (b < 0x20 && !PdfTokenizer.isWhitespace(b)) { + isBinaryData = true; + break; + } + // try to find PDF operator start and end + if (operatorStart == -1 && !PdfTokenizer.isWhitespace(b)) { + operatorStart = i; + } + if (operatorStart != -1 && PdfTokenizer.isWhitespace(b)) { + operatorEnd = i; + break; + } + } + if (operatorEnd == -1 && operatorStart != -1) { + operatorEnd = testSequence.length; + } + //checking for any ASCII sequence here having less than 3 bytes length, because it most likely a pdf operator. + if (operatorEnd - operatorStart > 3) { + isBinaryData = true; + } + //if no operator start & end was found than it means only whitespaces were encountered or eof was reached + //earlier, so returning false in that case, it's highly unlikely inline image will have a lot of whitespaces in + //its data. + return isBinaryData; + } + private static boolean imageColorSpaceIsKnown(PdfDictionary imageDictionary, PdfDictionary colorSpaceDic) { PdfName cs = imageDictionary.getAsName(PdfName.ColorSpace); if (cs == null || cs.equals(PdfName.DeviceGray) || cs.equals(PdfName.DeviceRGB) || cs.equals(PdfName.DeviceCMYK)) @@ -384,12 +460,29 @@ private static boolean imageColorSpaceIsKnown(PdfDictionary imageDictionary, Pdf private static boolean inlineImageStreamBytesAreComplete(byte[] samples, PdfDictionary imageDictionary) { try { Map filters = new HashMap<>(FilterHandlers.getDefaultFilterHandlers()); - filters.put(PdfName.JBIG2Decode, new DoNothingFilter()); + // According to pdf spec JPXDecode and JBIG2Decode are unsupported for inline images encoding + filters.put(PdfName.JPXDecode, new UnsupportedFilter(PdfName.JPXDecode.getValue())); + filters.put(PdfName.JBIG2Decode, new UnsupportedFilter(PdfName.JBIG2Decode.getValue())); filters.put(PdfName.FlateDecode, new FlateDecodeStrictFilter()); PdfReader.decodeBytes(samples, imageDictionary, filters); + return true; } catch (Exception ex) { return false; } - return true; + } + + private static class UnsupportedFilter implements IFilterHandler { + private final String name; + + public UnsupportedFilter(String name) { + this.name = name; + } + + @Override + public byte[] decode(byte[] b, PdfName filterName, PdfObject decodeParams, PdfDictionary streamDictionary) { + LOGGER.error(MessageFormatUtil.format( + KernelExceptionMessageConstant.UNSUPPORTED_ENCODING_FOR_INLINE_IMAGE, name)); + throw new UnsupportedOperationException(); + } } } diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/canvas/wmf/MetaDo.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/canvas/wmf/MetaDo.java index 20d8bf412f..a1d6a0849c 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/pdf/canvas/wmf/MetaDo.java +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/canvas/wmf/MetaDo.java @@ -122,12 +122,12 @@ public class MetaDo { /** * PdfCanvas of the MetaDo object. */ - public PdfCanvas cb; + private final PdfCanvas cb; /** * The InputMeta instance containing the data. */ - public InputMeta in; + private final InputMeta in; int left; int top; diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/canvas/wmf/MetaState.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/canvas/wmf/MetaState.java index fd8e98014b..3e8525fec0 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/pdf/canvas/wmf/MetaState.java +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/canvas/wmf/MetaState.java @@ -57,92 +57,92 @@ public class MetaState { /** * Stack of saved states. */ - public Stack savedStates; + private Stack savedStates; /** * List of MetaObjects. */ - public List MetaObjects; + private List metaObjects; /** * Current Point. */ - public Point currentPoint; + private Point currentPoint; /** * Current Pen. */ - public MetaPen currentPen; + private MetaPen currentPen; /** * Current Brush. */ - public MetaBrush currentBrush; + private MetaBrush currentBrush; /** * Current Font. */ - public MetaFont currentFont; + private MetaFont currentFont; /** * The current background color. Default value is DeviceRgb#WHITE. */ - public Color currentBackgroundColor = ColorConstants.WHITE; + private Color currentBackgroundColor = ColorConstants.WHITE; /** * Current text color. Default value is DeviceRgb#BLACK. */ - public Color currentTextColor = ColorConstants.BLACK; + private Color currentTextColor = ColorConstants.BLACK; /** * The current background mode. Default value is OPAQUE. */ - public int backgroundMode = OPAQUE; + private int backgroundMode = OPAQUE; /** * Current polygon fill mode. Default value is ALTERNATE. */ - public int polyFillMode = ALTERNATE; + private int polyFillMode = ALTERNATE; /** * Curent line join. Default value is 1. */ - public int lineJoin = 1; + private int lineJoin = 1; /** * Current text alignment. */ - public int textAlign; + private int textAlign; /** * Current offset for Wx. */ - public int offsetWx; + private int offsetWx; /** * Current offset for Wy. */ - public int offsetWy; + private int offsetWy; /** * Current extent for Wx. */ - public int extentWx; + private int extentWx; /** * Current extent for Wy. */ - public int extentWy; + private int extentWy; /** * Current x value for scaling. */ - public float scalingX; + private float scalingX; /** * Current y value for scaling. */ - public float scalingY; + private float scalingY; /** @@ -150,7 +150,7 @@ public class MetaState { */ public MetaState() { savedStates = new Stack<>(); - MetaObjects = new ArrayList<>(); + metaObjects = new ArrayList<>(); currentPoint = new Point(0, 0); currentPen = new MetaPen(); currentBrush = new MetaBrush(); @@ -173,7 +173,7 @@ public MetaState(MetaState state) { */ public void setMetaState(MetaState state) { savedStates = state.savedStates; - MetaObjects = state.MetaObjects; + metaObjects = state.metaObjects; currentPoint = state.currentPoint; currentPen = state.currentPen; currentBrush = state.currentBrush; @@ -198,13 +198,13 @@ public void setMetaState(MetaState state) { * @param object MetaObject to be added */ public void addMetaObject(MetaObject object) { - for (int k = 0; k < MetaObjects.size(); ++k) { - if (MetaObjects.get(k) == null) { - MetaObjects.set(k, object); + for (int k = 0; k < metaObjects.size(); ++k) { + if (metaObjects.get(k) == null) { + metaObjects.set(k, object); return; } } - MetaObjects.add(object); + metaObjects.add(object); } /** @@ -214,7 +214,7 @@ public void addMetaObject(MetaObject object) { * @param cb PdfCanvas to prepare */ public void selectMetaObject(int index, PdfCanvas cb) { - MetaObject obj = MetaObjects.get(index); + MetaObject obj = metaObjects.get(index); if (obj == null) return; int style; @@ -273,7 +273,7 @@ else if (style == MetaBrush.BS_HATCHED) { * @param index index of the MetaObject to delete */ public void deleteMetaObject(int index) { - MetaObjects.set(index, null); + metaObjects.set(index, null); } /** diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/colorspace/PdfPattern.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/colorspace/PdfPattern.java index ff0ab220f5..3fed6f0c6e 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/pdf/colorspace/PdfPattern.java +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/colorspace/PdfPattern.java @@ -31,6 +31,7 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfObjectWrapper; import com.itextpdf.kernel.pdf.PdfResources; import com.itextpdf.kernel.pdf.PdfStream; +import com.itextpdf.kernel.pdf.colorspace.shading.AbstractPdfShading; /** * Dictionary wrapper that represent special type of color space, that uses pattern objects @@ -427,10 +428,10 @@ public Shading(PdfDictionary pdfObject) { /** * Creates a new instance of Shading Pattern. * - * @param shading the {@link PdfShading} that specifies the details of a particular + * @param shading the {@link AbstractPdfShading} that specifies the details of a particular * gradient fill */ - public Shading(com.itextpdf.kernel.pdf.colorspace.PdfShading shading) { + public Shading(AbstractPdfShading shading) { super(new PdfDictionary()); getPdfObject().put(PdfName.Type, PdfName.Pattern); getPdfObject().put(PdfName.PatternType, new PdfNumber(2)); @@ -438,20 +439,20 @@ public Shading(com.itextpdf.kernel.pdf.colorspace.PdfShading shading) { } /** - * Gets the dictionary of the pattern's {@link PdfShading}. + * Gets the dictionary of the pattern's {@link AbstractPdfShading}. * - * @return the dictionary of the pattern's {@link PdfShading} + * @return the dictionary of the pattern's {@link AbstractPdfShading} */ public PdfDictionary getShading() { return (PdfDictionary) getPdfObject().get(PdfName.Shading); } /** - * Sets the {@link PdfShading} that specifies the details of a particular gradient fill. + * Sets the {@link AbstractPdfShading} that specifies the details of a particular gradient fill. * - * @param shading the {@link PdfShading} that specifies the details of a particular gradient fill + * @param shading the {@link AbstractPdfShading} that specifies the details of a particular gradient fill */ - public void setShading(com.itextpdf.kernel.pdf.colorspace.PdfShading shading) { + public void setShading(AbstractPdfShading shading) { getPdfObject().put(PdfName.Shading, shading.getPdfObject()); setModified(); } @@ -459,7 +460,7 @@ public void setShading(com.itextpdf.kernel.pdf.colorspace.PdfShading shading) { /** * Sets the dictionary which specifies the details of a particular gradient fill. * - * @param shading the dictionary of the pattern's {@link PdfShading} + * @param shading the dictionary of the pattern's {@link AbstractPdfShading} */ public void setShading(PdfDictionary shading) { getPdfObject().put(PdfName.Shading, shading); diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/colorspace/PdfShading.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/colorspace/PdfShading.java deleted file mode 100644 index 901d4aefba..0000000000 --- a/kernel/src/main/java/com/itextpdf/kernel/pdf/colorspace/PdfShading.java +++ /dev/null @@ -1,1441 +0,0 @@ -/* - This file is part of the iText (R) project. - Copyright (c) 1998-2024 Apryse Group NV - Authors: Apryse Software. - - This program is offered under a commercial and under the AGPL license. - For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. - - AGPL licensing: - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . - */ -package com.itextpdf.kernel.pdf.colorspace; - -import com.itextpdf.kernel.exceptions.KernelExceptionMessageConstant; -import com.itextpdf.kernel.exceptions.PdfException; -import com.itextpdf.kernel.pdf.PdfArray; -import com.itextpdf.kernel.pdf.PdfDictionary; -import com.itextpdf.kernel.pdf.PdfDocument; -import com.itextpdf.kernel.pdf.PdfName; -import com.itextpdf.kernel.pdf.PdfNumber; -import com.itextpdf.kernel.pdf.PdfObject; -import com.itextpdf.kernel.pdf.PdfObjectWrapper; -import com.itextpdf.kernel.pdf.PdfStream; -import com.itextpdf.kernel.pdf.function.IPdfFunction; -import com.itextpdf.kernel.pdf.function.PdfType2Function; - -/** - * The abstract PdfShading class that represents the Shading Dictionary PDF object. - */ -public abstract class PdfShading extends PdfObjectWrapper { - - /** - * constants of shading type (see ISO-320001 Table 78) - */ - static final class ShadingType { - /** The int value of function-based shading type*/ - public static final int FUNCTION_BASED = 1; - /** The int value of axial shading type*/ - public static final int AXIAL = 2; - /** The int value of radial shading type*/ - public static final int RADIAL = 3; - /** The int value of free-form Gouraud-shaded triangle mesh shading type*/ - public static final int FREE_FORM_GOURAUD_SHADED_TRIANGLE_MESH = 4; - /** The int value of lattice-form Gouraud-shaded triangle mesh shading type*/ - public static final int LATTICE_FORM_GOURAUD_SHADED_TRIANGLE_MESH = 5; - /** The int value of coons patch meshes shading type*/ - public static final int COONS_PATCH_MESH = 6; - /** The int value of tensor-product patch meshes shading type*/ - public static final int TENSOR_PRODUCT_PATCH_MESH = 7; - - private ShadingType() { } - } - - /** - * Creates the {@link PdfShading} object from the existing {@link PdfDictionary} with corresponding type. - * - * @param shadingDictionary {@link PdfDictionary} from which the {@link PdfShading} object will be created. - * @return Created {@link PdfShading} object. - */ - public static PdfShading makeShading(PdfDictionary shadingDictionary) { - if (!shadingDictionary.containsKey(PdfName.ShadingType)) { - throw new PdfException(KernelExceptionMessageConstant.SHADING_TYPE_NOT_FOUND); - } - if (!shadingDictionary.containsKey(PdfName.ColorSpace)) { - throw new PdfException(KernelExceptionMessageConstant.COLOR_SPACE_NOT_FOUND); - } - - PdfShading shading; - switch (shadingDictionary.getAsNumber(PdfName.ShadingType).intValue()) { - case ShadingType.FUNCTION_BASED: - shading = new FunctionBased(shadingDictionary); - break; - case ShadingType.AXIAL: - shading = new Axial(shadingDictionary); - break; - case ShadingType.RADIAL: - shading = new Radial(shadingDictionary); - break; - case ShadingType.FREE_FORM_GOURAUD_SHADED_TRIANGLE_MESH: - if (!shadingDictionary.isStream()) { - throw new PdfException(KernelExceptionMessageConstant.UNEXPECTED_SHADING_TYPE); - } - shading = new FreeFormGouraudShadedTriangleMesh((PdfStream) shadingDictionary); - break; - case ShadingType.LATTICE_FORM_GOURAUD_SHADED_TRIANGLE_MESH: - if (!shadingDictionary.isStream()) { - throw new PdfException(KernelExceptionMessageConstant.UNEXPECTED_SHADING_TYPE); - } - shading = new LatticeFormGouraudShadedTriangleMesh((PdfStream) shadingDictionary); - break; - case ShadingType.COONS_PATCH_MESH: - if (!shadingDictionary.isStream()) { - throw new PdfException(KernelExceptionMessageConstant.UNEXPECTED_SHADING_TYPE); - } - shading = new CoonsPatchMesh((PdfStream) shadingDictionary); - break; - case ShadingType.TENSOR_PRODUCT_PATCH_MESH: - if (!shadingDictionary.isStream()) { - throw new PdfException(KernelExceptionMessageConstant.UNEXPECTED_SHADING_TYPE); - } - shading = new TensorProductPatchMesh((PdfStream) shadingDictionary); - break; - default: - throw new PdfException(KernelExceptionMessageConstant.UNEXPECTED_SHADING_TYPE); - } - return shading; - } - - /** - * Creates the {@link PdfShading} object from the existing {@link PdfDictionary}. - * - * @param pdfObject {@link PdfDictionary} from which the {@link PdfShading} object will be created. - */ - protected PdfShading(PdfDictionary pdfObject) { - super(pdfObject); - } - - /** - * Creates the {@link PdfShading} object from the existing {@link PdfDictionary}, - * using provided type and colorspace. - * - * @param pdfObject {@link PdfDictionary} from which the {@link PdfShading} object will be created. - * @param type type with which this {@link PdfShading} object will be created. - * @param colorSpace {@link PdfColorSpace} with which this {@link PdfShading} object will be created. - */ - protected PdfShading(PdfDictionary pdfObject, int type, PdfColorSpace colorSpace) { - super(pdfObject); - getPdfObject().put(PdfName.ShadingType, new PdfNumber(type)); - if (colorSpace instanceof PdfSpecialCs.Pattern) { - throw new IllegalArgumentException("colorSpace"); - } - getPdfObject().put(PdfName.ColorSpace, colorSpace.getPdfObject()); - } - - /** - * Gets the shading type. - * - * @return int value of {@link PdfName#ShadingType}. - */ - public int getShadingType() { - return (int) getPdfObject().getAsInt(PdfName.ShadingType); - } - - /** - * Gets the color space in which colour values shall be expressed. - * - * @return {@link PdfObject} Color space - */ - public PdfObject getColorSpace() { - return getPdfObject().get(PdfName.ColorSpace); - } - - /** - * Gets the function PdfObject that represents color transitions - * across the shading geometry. - * - * @return {@link PdfObject} Function - */ - public PdfObject getFunction() { - return getPdfObject().get(PdfName.Function); - } - - /** - * Sets the function that represents color transitions - * across the shading geometry as one object. - * - * @param function The {@link IPdfFunction} to set. - */ - public void setFunction(IPdfFunction function) { - getPdfObject().put(PdfName.Function, function.getAsPdfObject()); - setModified(); - } - - /** - * Sets the function object that represents color transitions - * across the shading geometry as an array of functions. - * - * @param functions The array of {@link IPdfFunction} to be set. - */ - public void setFunction(IPdfFunction[] functions) { - PdfArray arr = new PdfArray(); - for (IPdfFunction func : functions) { - arr.add(func.getAsPdfObject()); - } - getPdfObject().put(PdfName.Function, arr); - setModified(); - } - - /** - * To manually flush a {@code PdfObject} behind this wrapper, you have to ensure - * that this object is added to the document, i.e. it has an indirect reference. - * Basically this means that before flushing you need to explicitly call {@link #makeIndirect(PdfDocument)}. - * For example: wrapperInstance.makeIndirect(document).flush(); - * Note that not every wrapper require this, only those that have such warning in documentation. - */ - @Override - public void flush() { - super.flush(); - } - - /** - * {@inheritDoc} - */ - @Override - protected boolean isWrappedObjectMustBeIndirect() { - return true; - } - - /** - * The class that extends {@link PdfShading} class and is in charge of Shading Dictionary with function-based type, - * that defines color at every point in the domain by a specified mathematical function. - */ - public static class FunctionBased extends PdfShading { - - - /** - * Creates the new instance of the class from the existing {@link PdfDictionary}. - * - * @param pdfDictionary from which this {@link FunctionBased} will be created - */ - protected FunctionBased(PdfDictionary pdfDictionary) { - super(pdfDictionary); - } - - /** - * Creates the new instance of the class. - * - * @param colorSpace the {@link PdfColorSpace} object in which colour values shall be expressed. - * @param function the {@link IPdfFunction}, that is used to calculate color transitions. - */ - public FunctionBased(PdfColorSpace colorSpace, IPdfFunction function) { - this(colorSpace.getPdfObject(), function); - } - - /** - * Creates the new instance of the class. - * - * @param colorSpace the {@link PdfObject}, that represents color space in which colour values shall be expressed. - * @param function the {@link IPdfFunction}, that is used to calculate color transitions. - */ - public FunctionBased(PdfObject colorSpace, IPdfFunction function) { - super(new PdfDictionary(), ShadingType.FUNCTION_BASED, PdfColorSpace.makeColorSpace(colorSpace)); - - setFunction(function); - } - - /** - * Gets the {@link PdfArray} domain rectangle object that establishes an internal coordinate space - * for the shading that is independent of the target coordinate space in which it shall be painted. - * - * @return {@link PdfArray} domain rectangle. - */ - public PdfArray getDomain() { - return getPdfObject().getAsArray(PdfName.Domain); - } - - /** - * Sets the {@link PdfArray} domain rectangle object that establishes an internal coordinate space - * for the shading that is independent of the target coordinate space in which it shall be painted. - * - * @param xmin the Xmin coordinate of rectangle. - * @param xmax the Xmax coordinate of rectangle. - * @param ymin the Ymin coordinate of rectangle. - * @param ymax the Ymax coordinate of rectangle. - */ - public void setDomain(float xmin, float xmax, float ymin, float ymax) { - setDomain(new PdfArray(new float[] {xmin, xmax, ymin, ymax})); - } - - /** - * Sets the {@link PdfArray} domain rectangle object that establishes an internal coordinate space - * for the shading that is independent of the target coordinate space in which it shall be painted. - * - * @param domain the {@link PdfArray} domain rectangle object to be set. - */ - public void setDomain(PdfArray domain) { - getPdfObject().put(PdfName.Domain, domain); - setModified(); - } - - /** - * Gets the {@link PdfArray} of floats that represents the transformation matrix that maps the domain rectangle - * into a corresponding figure in the target coordinate space. - * - * @return the {@link PdfArray} of transformation matrix (identical matrix by default). - */ - public PdfArray getMatrix() { - PdfArray matrix = getPdfObject().getAsArray(PdfName.Matrix); - if (matrix == null) { - matrix = new PdfArray(new float[]{1, 0, 0, 1, 0, 0}); - setMatrix(matrix); - } - return matrix; - } - - /** - * Sets the array of floats that represents the transformation matrix that maps the domain rectangle - * into a corresponding figure in the target coordinate space. - * - * @param matrix the {@code float[]} of transformation matrix to be set. - */ - public void setMatrix(float[] matrix) { - setMatrix(new PdfArray(matrix)); - } - - /** - * Sets the array of floats that represents the transformation matrix that maps the domain rectangle - * into a corresponding figure in the target coordinate space. - * - * @param matrix the {@link PdfArray} transformation matrix object to be set. - */ - public void setMatrix(PdfArray matrix) { - getPdfObject().put(PdfName.Matrix, matrix); - setModified(); - } - } - - /** - * The class that extends {@link PdfShading} class and is in charge of Shading Dictionary with axial type, - * that define a colour blend that varies along a linear axis between two endpoints - * and extends indefinitely perpendicular to that axis. - */ - public static class Axial extends PdfShading { - - - /** - * Creates the new instance of the class from the existing {@link PdfDictionary}. - * - * @param pdfDictionary from which this {@link Axial} will be created - */ - protected Axial(PdfDictionary pdfDictionary) { - super(pdfDictionary); - } - - /** - * Creates the new instance of the class. - * - * @param cs the {@link PdfColorSpace} object in which colour values shall be expressed. - * The special Pattern space isn't excepted. - * @param x0 the start coordinate of X axis expressed in the shading's target coordinate space. - * @param y0 the start coordinate of Y axis expressed in the shading's target coordinate space. - * @param color0 the {@code float[]} that represents the color in the start point. - * @param x1 the end coordinate of X axis expressed in the shading's target coordinate space. - * @param y1 the end coordinate of Y axis expressed in the shading's target coordinate space. - * @param color1 the {@code float[]} that represents the color in the end point. - */ - public Axial(PdfColorSpace cs, float x0, float y0, float[] color0, float x1, float y1, float[] color1) { - super(new PdfDictionary(), ShadingType.AXIAL, cs); - - setCoords(x0, y0, x1, y1); - IPdfFunction func = new PdfType2Function(new float[] {0, 1}, null, color0, color1, 1); - setFunction(func); - } - - /** - * Creates the new instance of the class. - * - * @param cs the {@link PdfColorSpace} object in which colour values shall be expressed. - * The special Pattern space isn't excepted. - * @param x0 the start coordinate of X axis expressed in the shading's target coordinate space. - * @param y0 the start coordinate of Y axis expressed in the shading's target coordinate space. - * @param color0 the {@code float[]} that represents the color in the start point. - * @param x1 the end coordinate of X axis expressed in the shading's target coordinate space. - * @param y1 the end coordinate of Y axis expressed in the shading's target coordinate space. - * @param color1 the {@code float[]} that represents the color in the end point. - * @param extend the array of two booleans that specified whether to extend the shading - * beyond the starting and ending points of the axis, respectively. - */ - public Axial(PdfColorSpace cs, float x0, float y0, float[] color0, float x1, float y1, float[] color1, boolean[] extend) { - this(cs, x0, y0, color0, x1, y1, color1); - - if (extend == null || extend.length != 2) - throw new IllegalArgumentException("extend"); - - setExtend(extend[0], extend[1]); - } - - /** - * Creates the new instance of the class. - * - * @param cs the {@link PdfColorSpace} object in which colour values shall be expressed. - * The special Pattern space isn't excepted. - * @param coords the {@link PdfArray} of four numbers [x0 y0 x1 y1] that specified the starting - * and the endings coordinates of thew axis, expressed in the shading's target coordinate space. - * @param function the {@link IPdfFunction} object, that is used to calculate color transitions. - */ - public Axial(PdfColorSpace cs, PdfArray coords, IPdfFunction function) { - this(cs, coords, null, function); - } - - /** - * Creates the new instance of the class. - * - * @param cs the {@link PdfColorSpace} object in which colour values shall be expressed. - * The special Pattern space isn't excepted. - * @param coords the {@link PdfArray} of four numbers [x0 y0 x1 y1] that specified - * the starting and the endings coordinates of thew axis, expressed - * in the shading's target coordinate space. - * @param domain the {@link PdfArray} of two numbers [t0 t1] specifying the limiting values - * of a parametric variable t which is considered to vary linearly between - * these two values and becomes the input argument to the colour function. - * @param function the {@link IPdfFunction} object, that is used to calculate color transitions. - */ - public Axial(PdfColorSpace cs, PdfArray coords, PdfArray domain, IPdfFunction function) { - super(new PdfDictionary(), ShadingType.AXIAL, cs); - setCoords(coords); - if (domain != null) { - setDomain(domain); - } - setFunction(function); - } - - - /** - * Gets the Coords object - a {@link PdfArray} of four numbers [x0 y0 x1 y1] that specified the starting - * and the endings coordinates of thew axis, expressed in the shading's target coordinate space. - * - * @return the {@link PdfArray} Coords object. - */ - public PdfArray getCoords() { - return getPdfObject().getAsArray(PdfName.Coords); - } - - /** - * Sets the Choords object with the four params expressed in the shading's target coordinate space. - * - * @param x0 the start coordinate of X axis to be set. - * @param y0 the start coordinate of Y axis to be set. - * @param x1 the end coordinate of X axis to be set. - * @param y1 the end coordinate of Y axis to be set. - */ - public void setCoords(float x0, float y0, float x1, float y1) { - setCoords(new PdfArray(new float[] {x0, y0, x1, y1})); - } - - /** - * Sets the Choords object with the {@link PdfArray} of four numbers [x0 y0 x1 y1], - * that specified the starting and the endings coordinates of thew axis, - * expressed in the shading's target coordinate space. - * - * @param coords the Chords {@link PdfArray} to be set. - */ - public void setCoords(PdfArray coords) { - getPdfObject().put(PdfName.Coords, coords); - setModified(); - } - - /** - * Gets the {@link PdfArray} of two {@code float} [t0, t1] that represent the limiting values of a parametric - * variable t, that becomes an input of color function(s). - * - * @return the {@link PdfArray} of Domain object ([0.0 1.0] by default) - */ - public PdfArray getDomain() { - PdfArray domain = getPdfObject().getAsArray(PdfName.Domain); - if (domain == null) { - domain = new PdfArray(new float[]{0, 1}); - setDomain(domain); - } - return domain; - } - - /** - * Sets the Domain with the array of two {@code float} [t0, t1] that represent the limiting values - * of a parametric variable t, that becomes an input of color function(s). - * - * @param t0 first limit of variable t - * @param t1 second limit of variable t - */ - public void setDomain(float t0, float t1) { - setDomain(new PdfArray(new float[] {t0, t1})); - } - - /** - * Sets the Domain with the {@link PdfArray} of two {@code float} [t0, t1] that represent the limiting values - * of a parametric variable t, that becomes an input of color function(s). - * - * @param domain the {@link PdfArray} that represents domain - */ - public void setDomain(PdfArray domain) { - getPdfObject().put(PdfName.Domain, domain); - setModified(); - } - - /** - * Gets the {@link PdfArray} of two {@code boolean} that specified whether to extend the shading - * beyond the starting and ending points of the axis, respectively. - * - * @return the {@link PdfArray} of Extended object ([false false] by default) - */ - public PdfArray getExtend() { - PdfArray extend = getPdfObject().getAsArray(PdfName.Extend); - if (extend == null) { - extend = new PdfArray(new boolean[]{false, false}); - setExtend(extend); - } - return extend; - } - - /** - * Sets the Extend object with the two {@code boolean} value. - * - * @param extendStart if true will extend shading beyond the starting point of Coords - * @param extendEnd if true will extend shading beyond the ending point of Coords - */ - public void setExtend(boolean extendStart, boolean extendEnd) { - setExtend(new PdfArray(new boolean[] {extendStart, extendEnd})); - } - - /** - * Sets the Extend object with the {@link PdfArray} of two {@code boolean}. - * If first is true shading will extend beyond the starting point of Coords. - * If second is true shading will extend beyond the ending point of Coords. - * - * @param extend the {@link PdfArray} representing Extend object - */ - public void setExtend(PdfArray extend) { - getPdfObject().put(PdfName.Extend, extend); - setModified(); - } - } - - /** - * The class that extends {@link PdfShading} class and is in charge of Shading Dictionary with radial type, - * that define a colour blend that varies between two circles. - * This type of shading shall not be used with an Indexed colour space - */ - public static class Radial extends PdfShading { - - - /** - * Creates the new instance of the class from the existing {@link PdfDictionary}. - * - * @param pdfDictionary from which this {@link Radial} will be created - */ - protected Radial(PdfDictionary pdfDictionary) { - super(pdfDictionary); - } - - /** - * Creates the new instance of the class. - * - * @param cs the {@link PdfColorSpace} object in which colour values shall be expressed. - * The Indexed color space isn't excepted. - * @param x0 the X coordinate of starting circle's centre, expressed in in the shading’s target coordinate space. - * @param y0 the Y coordinate of starting circle's centre, expressed in in the shading’s target coordinate space. - * @param r0 the radius of starting circle's centre, should be greater or equal to 0. - * If 0 then starting circle is treated as point. - * If both radii are 0, nothing shall be painted. - * @param color0 the {@code float[]} that represents the color in the start circle. - * @param x1 the X coordinate of ending circle's centre, expressed in in the shading’s target coordinate space. - * @param y1 the Y coordinate of ending circle's centre, expressed in in the shading’s target coordinate space. - * @param r1 the radius of ending circle's centre, should be greater or equal to 0. - * If 0 then ending circle is treated as point. - * If both radii are 0, nothing shall be painted. - * @param color1 the {@code float[]} that represents the color in the end circle. - */ - public Radial(PdfColorSpace cs, float x0, float y0, float r0, float[] color0, float x1, float y1, float r1, float[] color1) { - super(new PdfDictionary(), ShadingType.RADIAL, cs); - - setCoords(x0, y0, r0, x1, y1, r1); - IPdfFunction func = new PdfType2Function(new float[] {0, 1}, null, - color0, color1, 1); - setFunction(func); - } - - /** - * Creates the new instance of the class. - * - * @param cs the {@link PdfColorSpace} object in which colour values shall be expressed. - * The Indexed color space isn't excepted. - * @param x0 the X coordinate of starting circle's centre, expressed in in the shading’s target coordinate space. - * @param y0 the Y coordinate of starting circle's centre, expressed in in the shading’s target coordinate space. - * @param r0 the radius of starting circle's centre, should be greater or equal to 0. - * If 0 then starting circle is treated as point. - * If both radii are 0, nothing shall be painted. - * @param color0 the {@code float[]} that represents the color in the start circle. - * @param x1 the X coordinate of ending circle's centre, expressed in in the shading’s target coordinate space. - * @param y1 the Y coordinate of ending circle's centre, expressed in in the shading’s target coordinate space. - * @param r1 the radius of ending circle's centre, should be greater or equal to 0. - * If 0 then ending circle is treated as point. - * If both radii are 0, nothing shall be painted. - * @param color1 the {@code float[]} that represents the color in the end circle. - * @param extend the array of two {@code boolean} that specified whether to extend the shading - * beyond the starting and ending points of the axis, respectively. - */ - public Radial(PdfColorSpace cs, float x0, float y0, float r0, float[] color0, float x1, float y1, float r1, float[] color1, boolean[] extend) { - this(cs, x0, y0, r0, color0, x1, y1, r1, color1); - - if (extend == null || extend.length != 2) - throw new IllegalArgumentException("extend"); - - setExtend(extend[0], extend[1]); - } - - /** - * Creates the new instance of the class. - * - * @param cs the {@link PdfColorSpace} object in which colour values shall be expressed. - * The Indexed color space isn't excepted. - * @param coords the {@link PdfArray} of of six numbers [x0 y0 r0 x1 y1 r1], - * specifying the centres and radii of the starting and ending circles, - * expressed in the shading’s target coordinate space. - * The radii r0 and r1 shall both be greater than or equal to 0. - * If one radius is 0, the corresponding circle shall be treated as a point; - * if both are 0, nothing shall be painted. - * @param function the {@link IPdfFunction} object, that is used to calculate color transitions. - */ - public Radial(PdfColorSpace cs, PdfArray coords, IPdfFunction function) { - super(new PdfDictionary(), ShadingType.RADIAL, cs); - setCoords(coords); - setFunction(function); - } - - /** - * Gets the coords {@link PdfArray} object - an array of six numbers [x0 y0 r0 x1 y1 r1], - * specifying the centres and radii of the starting and ending circles, - * expressed in the shading’s target coordinate space. - * The radii r0 and r1 shall both be greater than or equal to 0. - * If one radius is 0, the corresponding circle shall be treated as a point; - * if both are 0, nothing shall be painted. - * - * @return the {@link PdfArray} coords object. - */ - public PdfArray getCoords() { - return getPdfObject().getAsArray(PdfName.Coords); - } - - /** - * Sets the coords object. - * - * @param x0 the X coordinate of starting circle's centre, expressed in in the shading’s target coordinate space. - * @param y0 the Y coordinate of starting circle's centre, expressed in in the shading’s target coordinate space. - * @param r0 the radius of starting circle's centre, should be greater or equal to 0. - * If 0 then starting circle is treated as point. - * If both radii are 0, nothing shall be painted. - * @param x1 the X coordinate of ending circle's centre, expressed in in the shading’s target coordinate space. - * @param y1 the Y coordinate of ending circle's centre, expressed in in the shading’s target coordinate space. - * @param r1 the radius of ending circle's centre, should be greater or equal to 0. - * If 0 then ending circle is treated as point. - * If both radii are 0, nothing shall be painted. - */ - public void setCoords(float x0, float y0, float r0, float x1, float y1, float r1) { - setCoords(new PdfArray(new float[] {x0, y0, r0, x1, y1, r1})); - } - - /** - * Sets the coords {@link PdfArray} object - an array of six numbers [x0 y0 r0 x1 y1 r1], - * specifying the centres and radii of the starting and ending circles, - * expressed in the shading’s target coordinate space. - * The radii r0 and r1 shall both be greater than or equal to 0. - * If one radius is 0, the corresponding circle shall be treated as a point; - * if both are 0, nothing shall be painted. - * - * @param coords - {@link PdfArray} choords object to be set. - */ - public void setCoords(PdfArray coords) { - getPdfObject().put(PdfName.Coords, coords); - setModified(); - } - - /** - * Gets the {@link PdfArray} of two {@code float} [t0, t1] that represent the limiting values of a parametric - * variable t, that becomes an input of color function(s). - * - * @return the {@link PdfArray} of Domain object ([0.0 1.0] by default) - */ - public PdfArray getDomain() { - PdfArray domain = getPdfObject().getAsArray(PdfName.Domain); - if (domain == null) { - domain = new PdfArray(new float[]{0, 1}); - setDomain(domain); - } - return domain; - } - - /** - * Sets the Domain with the array of two {@code float} [t0, t1] that represent the limiting values - * of a parametric variable t, that becomes an input of color function(s). - * - * @param t0 first limit of variable t - * @param t1 second limit of variable t - */ - public void setDomain(float t0, float t1) { - setDomain(new PdfArray(new float[] {t0, t1})); - } - - /** - * Sets the Domain with the {@link PdfArray} of two {@code float} [t0, t1] that represent the limiting values - * of a parametric variable t, that becomes an input of color function(s). - * - * @param domain the {@link PdfArray} that represents domain - */ - public void setDomain(PdfArray domain) { - getPdfObject().put(PdfName.Domain, domain); - setModified(); - } - - /** - * Gets the {@link PdfArray} of two {@code boolean} that specified whether to extend the shading - * beyond the starting and ending circles of the axis, respectively. - * - * @return the {@link PdfArray} of Extended object ([false false] by default) - */ - public PdfArray getExtend() { - PdfArray extend = getPdfObject().getAsArray(PdfName.Extend); - if (extend == null) { - extend = new PdfArray(new boolean[]{false, false}); - setExtend(extend); - } - return extend; - } - - /** - * Sets the Extend object with the two {@code boolean} value. - * - * @param extendStart if true will extend shading beyond the starting circle of Coords. - * @param extendEnd if true will extend shading beyond the ending circle of Coords. - */ - public void setExtend(boolean extendStart, boolean extendEnd) { - setExtend(new PdfArray(new boolean[] {extendStart, extendEnd})); - } - - /** - * Sets the Extend object with the {@link PdfArray} of two {@code boolean}. - * If first is true shading will extend beyond the starting circle of Coords. - * If second is true shading will extend beyond the ending circle of Coords. - * - * @param extend the {@link PdfArray} representing Extend object - */ - public void setExtend(PdfArray extend) { - getPdfObject().put(PdfName.Extend, extend); - setModified(); - } - } - - /** - * The class that extends {@link PdfShading} class and is in charge of Shading Dictionary with - * free-form Gouraud-shaded triangle mesh type. - * - * The area to be shaded is defined by a path composed entirely of triangles. - * The colour at each vertex of the triangles is specified, - * and a technique known as Gouraud interpolation is used to colour the interiors. - * - * The object shall be represented as stream containing a sequence of vertex data. - * Each vertex is specified by the following values, in the order shown: - * f x y c1 ... cn where: - * f - the vertex's edge flag, that determines the vertex is connected to other vertices of the triangle mesh. - * For full description, see ISO-320001 Paragraph 8.7.4.5.5 - * x, y - vertex's horizontal and vertical coordinates, expressed in the shading's target coordinate space. - * c1...cn - vertex's colour components. - * - * If the shading dictionary includes a Function entry, only a single parametric value, t, - * shall be specified for each vertex in place of the colour components c1...cn. - */ - public static class FreeFormGouraudShadedTriangleMesh extends PdfShading { - - - /** - * Creates the new instance of the class from the existing {@link PdfStream}. - * - * @param pdfStream from which this {@link FreeFormGouraudShadedTriangleMesh} will be created - */ - protected FreeFormGouraudShadedTriangleMesh(PdfStream pdfStream) { - super(pdfStream); - } - - /** - * Creates the new instance of the class. - * - * @param cs the {@link PdfColorSpace} object in which colour values shall be expressed. - * The special Pattern space isn't excepted. - * @param bitsPerCoordinate the number of bits used to represent each vertex coordinate. - * The value shall be 1, 2, 4, 8, 12, 16, 24, or 32. - * @param bitsPerComponent the number of bits used to represent each colour component. - * The value shall be 1, 2, 4, 8, 12, or 16. - * @param bitsPerFlag the number of bits used to represent the edge flag for each vertex. - * The value of BitsPerFlag shall be 2, 4, or 8, - * but only the least significant 2 bits in each flag value shall be used. - * The value for the edge flag shall be 0, 1, or 2. - * @param decode the {@code int[]} of numbers specifying how to map vertex coordinates and colour components - * into the appropriate ranges of values. The ranges shall be specified as follows: - * [x_min x_max y_min y_max c1_min c1_max … cn_min cn_max]. - * Only one pair of color values shall be specified if a Function entry is present. - */ - public FreeFormGouraudShadedTriangleMesh(PdfColorSpace cs, int bitsPerCoordinate, int bitsPerComponent, int bitsPerFlag, float[] decode) { - this(cs, bitsPerCoordinate, bitsPerComponent, bitsPerFlag, new PdfArray(decode)); - } - - /** - * Creates the new instance of the class. - * - * @param cs the {@link PdfColorSpace} object in which colour values shall be expressed. - * The special Pattern space isn't excepted. - * @param bitsPerCoordinate the number of bits used to represent each vertex coordinate. - * The value shall be 1, 2, 4, 8, 12, 16, 24, or 32. - * @param bitsPerComponent the number of bits used to represent each colour component. - * The value shall be 1, 2, 4, 8, 12, or 16. - * @param bitsPerFlag the number of bits used to represent the edge flag for each vertex. - * The value of BitsPerFlag shall be 2, 4, or 8, - * but only the least significant 2 bits in each flag value shall be used. - * The value for the edge flag shall be 0, 1, or 2. - * @param decode the {@link PdfArray} of numbers specifying how to map vertex coordinates and colour components - * into the appropriate ranges of values. The ranges shall be specified as follows: - * [x_min x_max y_min y_max c1_min c1_max … cn_min cn_max]. - * Only one pair of color values shall be specified if a Function entry is present. - */ - public FreeFormGouraudShadedTriangleMesh(PdfColorSpace cs, int bitsPerCoordinate, int bitsPerComponent, int bitsPerFlag, PdfArray decode) { - super(new PdfStream(), ShadingType.FREE_FORM_GOURAUD_SHADED_TRIANGLE_MESH, cs); - - setBitsPerCoordinate(bitsPerCoordinate); - setBitsPerComponent(bitsPerComponent); - setBitsPerFlag(bitsPerFlag); - setDecode(decode); - } - - /** - * Gets the number of bits used to represent each vertex coordinate. - * - * @return the number of bits. Can be 1, 2, 4, 8, 12, 16, 24, or 32. - */ - public int getBitsPerCoordinate() { - return (int) getPdfObject().getAsInt(PdfName.BitsPerCoordinate); - } - - /** - * Sets the number of bits used to represent each vertex coordinate. - * - * @param bitsPerCoordinate the number of bits to be set. Shall be 1, 2, 4, 8, 12, 16, 24, or 32. - */ - public void setBitsPerCoordinate(int bitsPerCoordinate) { - getPdfObject().put(PdfName.BitsPerCoordinate, new PdfNumber(bitsPerCoordinate)); - setModified(); - } - - /** - * Gets the number of bits used to represent each colour component. - * - * @return the number of bits. Can be 1, 2, 4, 8, 12, or 16. - */ - public int getBitsPerComponent() { - return (int) getPdfObject().getAsInt(PdfName.BitsPerComponent); - } - - /** - * Sets the number of bits used to represent each colour component. - * - * @param bitsPerComponent the number of bits to be set. Shall be 1, 2, 4, 8, 12, or 16. - */ - public void setBitsPerComponent(int bitsPerComponent) { - getPdfObject().put(PdfName.BitsPerComponent, new PdfNumber(bitsPerComponent)); - setModified(); - } - - /** - * Gets the number of bits used to represent the edge flag for each vertex. - * But only the least significant 2 bits in each flag value shall be used. - * The valid flag values are 0, 1 or 2. - * - * @return the number of bits. Can be 2, 4 or 8. - */ - public int getBitsPerFlag() { - return (int) getPdfObject().getAsInt(PdfName.BitsPerFlag); - } - - /** - * Sets the number of bits used to represent the edge flag for each vertex. - * But only the least significant 2 bits in each flag value shall be used. - * The valid flag values are 0, 1 or 2. - * - * @param bitsPerFlag the number of bits to be set. Shall be 2, 4 or 8. - */ - public void setBitsPerFlag(int bitsPerFlag) { - getPdfObject().put(PdfName.BitsPerFlag, new PdfNumber(bitsPerFlag)); - setModified(); - } - - /** - * Gets the {@link PdfArray} of numbers specifying how to map vertex coordinates and colour components - * into the appropriate ranges of values. The ranges shall be specified as follows: - * [x_min x_max y_min y_max c1_min c1_max … cn_min cn_max]. - * Only one pair of color values shall be specified if a Function entry is present. - * - * @return the {@link PdfArray} Decode object. - */ - public PdfArray getDecode() { - return getPdfObject().getAsArray(PdfName.Decode); - } - - /** - * Sets the {@code float[]} of numbers specifying how to map vertex coordinates and colour components - * into the appropriate ranges of values. The ranges shall be specified as follows: - * [x_min x_max y_min y_max c1_min c1_max … cn_min cn_max]. - * Only one pair of color values shall be specified if a Function entry is present. - * - * @param decode the {@code float[]} of Decode object to set. - */ - public void setDecode(float[] decode) { - setDecode(new PdfArray(decode)); - } - - /** - * Sets the {@link PdfArray} of numbers specifying how to map vertex coordinates and colour components - * into the appropriate ranges of values. The ranges shall be specified as follows: - * [x_min x_max y_min y_max c1_min c1_max … cn_min cn_max]. - * Only one pair of color values shall be specified if a Function entry is present. - * - * @param decode the {@link PdfArray} Decode object to set. - */ - public void setDecode(PdfArray decode) { - getPdfObject().put(PdfName.Decode, decode); - setModified(); - } - } - - /** - * The class that extends {@link PdfShading} class and is in charge of Shading Dictionary with - * lattice-form Gouraud-shaded triangle mesh type. - * - * This type is similar to {@link FreeFormGouraudShadedTriangleMesh} but instead of using free-form geometry, - * the vertices are arranged in a pseudorectangular lattice, - * which is topologically equivalent to a rectangular grid. - * The vertices are organized into rows, which need not be geometrically linear. - * - * The verticals data in stream is similar to {@link FreeFormGouraudShadedTriangleMesh}, - * except there is no edge flag. - */ - public static class LatticeFormGouraudShadedTriangleMesh extends PdfShading { - - - /** - * Creates the new instance of the class from the existing {@link PdfStream}. - * - * @param pdfStream from which this {@link LatticeFormGouraudShadedTriangleMesh} will be created - */ - protected LatticeFormGouraudShadedTriangleMesh(PdfStream pdfStream) { - super(pdfStream); - } - - /** - * Creates the new instance of the class. - * - * @param cs the {@link PdfColorSpace} object in which colour values shall be expressed. - * The special Pattern space isn't excepted. - * @param bitsPerCoordinate the number of bits used to represent each vertex coordinate. - * The value shall be 1, 2, 4, 8, 12, 16, 24, or 32. - * @param bitsPerComponent the number of bits used to represent each colour component. - * The value shall be 1, 2, 4, 8, 12, or 16. - * @param verticesPerRow the number of vertices in each row of the lattice (shall be > 1). - * The number of rows need not be specified. - * @param decode the {@code int[]} of numbers specifying how to map vertex coordinates and colour components - * into the appropriate ranges of values. The ranges shall be specified as follows: - * [x_min x_max y_min y_max c1_min c1_max … cn_min cn_max]. - * Only one pair of color values shall be specified if a Function entry is present. - */ - public LatticeFormGouraudShadedTriangleMesh(PdfColorSpace cs, int bitsPerCoordinate, int bitsPerComponent, int verticesPerRow, float[] decode) { - this(cs, bitsPerCoordinate, bitsPerComponent, verticesPerRow, new PdfArray(decode)); - } - - /** - * Creates the new instance of the class. - * - * @param cs the {@link PdfColorSpace} object in which colour values shall be expressed. - * The special Pattern space isn't excepted. - * @param bitsPerCoordinate the number of bits used to represent each vertex coordinate. - * The value shall be 1, 2, 4, 8, 12, 16, 24, or 32. - * @param bitsPerComponent the number of bits used to represent each colour component. - * The value shall be 1, 2, 4, 8, 12, or 16. - * @param verticesPerRow the number of vertices in each row of the lattice (shall be > 1). - * The number of rows need not be specified. - * @param decode the {@link PdfArray} of numbers specifying how to map vertex coordinates and colour components - * into the appropriate ranges of values. The ranges shall be specified as follows: - * [x_min x_max y_min y_max c1_min c1_max … cn_min cn_max]. - * Only one pair of color values shall be specified if a Function entry is present. - */ - public LatticeFormGouraudShadedTriangleMesh(PdfColorSpace cs, int bitsPerCoordinate, int bitsPerComponent, int verticesPerRow, PdfArray decode) { - super(new PdfStream(), ShadingType.LATTICE_FORM_GOURAUD_SHADED_TRIANGLE_MESH, cs); - - setBitsPerCoordinate(bitsPerCoordinate); - setBitsPerComponent(bitsPerComponent); - setVerticesPerRow(verticesPerRow); - setDecode(decode); - } - - /** - * Gets the number of bits used to represent each vertex coordinate. - * - * @return the number of bits. Can be 1, 2, 4, 8, 12, 16, 24, or 32. - */ - public int getBitsPerCoordinate() { - return (int) getPdfObject().getAsInt(PdfName.BitsPerCoordinate); - } - - /** - * Sets the number of bits used to represent each vertex coordinate. - * - * @param bitsPerCoordinate the number of bits to be set. Shall be 1, 2, 4, 8, 12, 16, 24, or 32. - */ - public void setBitsPerCoordinate(int bitsPerCoordinate) { - getPdfObject().put(PdfName.BitsPerCoordinate, new PdfNumber(bitsPerCoordinate)); - setModified(); - } - - /** - * Gets the number of bits used to represent each colour component. - * - * @return the number of bits. Can be 1, 2, 4, 8, 12, or 16. - */ - public int getBitsPerComponent() { - return (int) getPdfObject().getAsInt(PdfName.BitsPerComponent); - } - - /** - * Sets the number of bits used to represent each colour component. - * - * @param bitsPerComponent the number of bits to be set. Shall be 1, 2, 4, 8, 12, or 16. - */ - public void setBitsPerComponent(int bitsPerComponent) { - getPdfObject().put(PdfName.BitsPerComponent, new PdfNumber(bitsPerComponent)); - setModified(); - } - - /** - * Gets the number of vertices in each row of the lattice. - * - * @return the number of vertices. Can only be greater than 1. - */ - public int getVerticesPerRow() { - return (int) getPdfObject().getAsInt(PdfName.VerticesPerRow); - } - - /** - * Sets the number of vertices in each row of the lattice. - * The number of rows need not be specified. - * - * @param verticesPerRow the number of vertices to be set. Shall be greater than 1. - */ - public void setVerticesPerRow(int verticesPerRow) { - getPdfObject().put(PdfName.VerticesPerRow, new PdfNumber(verticesPerRow)); - setModified(); - } - - /** - * Gets the {@link PdfArray} of numbers specifying how to map vertex coordinates and colour components - * into the appropriate ranges of values. The ranges shall be specified as follows: - * [x_min x_max y_min y_max c1_min c1_max … cn_min cn_max]. - * Only one pair of color values shall be specified if a Function entry is present. - * - * @return the {@link PdfArray} Decode object. - */ - public PdfArray getDecode() { - return getPdfObject().getAsArray(PdfName.Decode); - } - - /** - * Sets the {@code float[]} of numbers specifying how to map vertex coordinates and colour components - * into the appropriate ranges of values. The ranges shall be specified as follows: - * [x_min x_max y_min y_max c1_min c1_max … cn_min cn_max]. - * Only one pair of color values shall be specified if a Function entry is present. - * - * @param decode the {@code float[]} of Decode object to set. - */ - public void setDecode(float[] decode) { - setDecode(new PdfArray(decode)); - } - - /** - * Sets the {@link PdfArray} of numbers specifying how to map vertex coordinates and colour components - * into the appropriate ranges of values. The ranges shall be specified as follows: - * [x_min x_max y_min y_max c1_min c1_max … cn_min cn_max]. - * Only one pair of color values shall be specified if a Function entry is present. - * - * @param decode the {@link PdfArray} Decode object to set. - */ - public void setDecode(PdfArray decode) { - getPdfObject().put(PdfName.Decode, decode); - setModified(); - } - } - - /** - * The class that extends {@link PdfShading} class and is in charge of Shading Dictionary with - * Coons Patch mesh type. - * - * This type of shading is constructed from one or more colour patches, each bounded by four cubic Bézier curves. - * Degenerate Bézier curves are allowed and are useful for certain graphical effects. - * At least one complete patch shall be specified. - * - * The shape of patch is defined by 12 control points. - * - * Colours are specified for each corner of the unit square, - * and bilinear interpolation is used to fill in colours over the entire unit square. - * - * Coordinates are mapped from the unit square into a four-sided patch whose sides are not necessarily linear. - * The mapping is continuous: the corners of the unit square map to corners of the patch - * and the sides of the unit square map to sides of the patch. - * - * For the format of data stream, that defines patches (see ISO-320001 Table 85). - * - * If the shading dictionary contains a Function entry, the colour data for each corner of a patch - * shall be specified by a single parametric value t rather than by n separate colour components c1...cn. - */ - public static class CoonsPatchMesh extends PdfShading { - - - /** - * Creates the new instance of the class from the existing {@link PdfStream}. - * - * @param pdfStream from which this {@link CoonsPatchMesh} will be created - */ - protected CoonsPatchMesh(PdfStream pdfStream) { - super(pdfStream); - } - - /** - * Creates the new instance of the class. - * - * @param cs the {@link PdfColorSpace} object in which colour values shall be expressed. - * The special Pattern space isn't excepted. - * @param bitsPerCoordinate the number of bits used to represent each vertex coordinate. - * The value shall be 1, 2, 4, 8, 12, 16, 24, or 32. - * @param bitsPerComponent the number of bits used to represent each colour component. - * The value shall be 1, 2, 4, 8, 12, or 16. - * @param bitsPerFlag the number of bits used to represent the edge flag for each vertex. - * The value of BitsPerFlag shall be 2, 4, or 8, - * but only the least significant 2 bits in each flag value shall be used. - * The value for the edge flag shall be 0, 1, 2 or 3. - * @param decode the {@code int[]} of numbers specifying how to map vertex coordinates and colour components - * into the appropriate ranges of values. The ranges shall be specified as follows: - * [x_min x_max y_min y_max c1_min c1_max … cn_min cn_max]. - * Only one pair of color values shall be specified if a Function entry is present. - */ - public CoonsPatchMesh(PdfColorSpace cs, int bitsPerCoordinate, int bitsPerComponent, int bitsPerFlag, float[] decode) { - this(cs, bitsPerCoordinate, bitsPerComponent, bitsPerFlag, new PdfArray(decode)); - } - - /** - * Creates the new instance of the class. - * - * @param cs the {@link PdfColorSpace} object in which colour values shall be expressed. - * The special Pattern space isn't excepted. - * @param bitsPerCoordinate the number of bits used to represent each vertex coordinate. - * The value shall be 1, 2, 4, 8, 12, 16, 24, or 32. - * @param bitsPerComponent the number of bits used to represent each colour component. - * The value shall be 1, 2, 4, 8, 12, or 16. - * @param bitsPerFlag the number of bits used to represent the edge flag for each vertex. - * The value of BitsPerFlag shall be 2, 4, or 8, - * but only the least significant 2 bits in each flag value shall be used. - * The value for the edge flag shall be 0, 1, 2 or 3. - * @param decode the {@link PdfArray} of numbers specifying how to map vertex coordinates and colour components - * into the appropriate ranges of values. The ranges shall be specified as follows: - * [x_min x_max y_min y_max c1_min c1_max … cn_min cn_max]. - * Only one pair of color values shall be specified if a Function entry is present. - */ - public CoonsPatchMesh(PdfColorSpace cs, int bitsPerCoordinate, int bitsPerComponent, int bitsPerFlag, PdfArray decode) { - super(new PdfStream(), ShadingType.COONS_PATCH_MESH, cs); - setBitsPerCoordinate(bitsPerCoordinate); - setBitsPerComponent(bitsPerComponent); - setBitsPerFlag(bitsPerFlag); - setDecode(decode); - } - - /** - * Gets the number of bits used to represent each vertex coordinate. - * - * @return the number of bits. Can be 1, 2, 4, 8, 12, 16, 24, or 32. - */ - public int getBitsPerCoordinate() { - return (int) getPdfObject().getAsInt(PdfName.BitsPerCoordinate); - } - - /** - * Sets the number of bits used to represent each vertex coordinate. - * - * @param bitsPerCoordinate the number of bits to be set. Shall be 1, 2, 4, 8, 12, 16, 24, or 32. - */ - public void setBitsPerCoordinate(int bitsPerCoordinate) { - getPdfObject().put(PdfName.BitsPerCoordinate, new PdfNumber(bitsPerCoordinate)); - setModified(); - } - - /** - * Gets the number of bits used to represent each colour component. - * - * @return the number of bits. Can be 1, 2, 4, 8, 12, or 16. - */ - public int getBitsPerComponent() { - return (int) getPdfObject().getAsInt(PdfName.BitsPerComponent); - } - - /** - * Sets the number of bits used to represent each colour component. - * - * @param bitsPerComponent the number of bits to be set. Shall be 1, 2, 4, 8, 12, or 16. - */ - public void setBitsPerComponent(int bitsPerComponent) { - getPdfObject().put(PdfName.BitsPerComponent, new PdfNumber(bitsPerComponent)); - setModified(); - } - - /** - * Gets the number of bits used to represent the edge flag for each vertex. - * But only the least significant 2 bits in each flag value shall be used. - * The valid flag values are 0, 1, 2 or 3. - * - * @return the number of bits. Can be 2, 4 or 8. - */ - public int getBitsPerFlag() { - return (int) getPdfObject().getAsInt(PdfName.BitsPerFlag); - } - - /** - * Sets the number of bits used to represent the edge flag for each vertex. - * But only the least significant 2 bits in each flag value shall be used. - * The valid flag values are 0, 1, 2 or 3. - * - * @param bitsPerFlag the number of bits to be set. Shall be 2, 4 or 8. - */ - public void setBitsPerFlag(int bitsPerFlag) { - getPdfObject().put(PdfName.BitsPerFlag, new PdfNumber(bitsPerFlag)); - setModified(); - } - - /** - * Gets the {@link PdfArray} of numbers specifying how to map vertex coordinates and colour components - * into the appropriate ranges of values. The ranges shall be specified as follows: - * [x_min x_max y_min y_max c1_min c1_max … cn_min cn_max]. - * Only one pair of color values shall be specified if a Function entry is present. - * - * @return the {@link PdfArray} Decode object. - */ - public PdfArray getDecode() { - return getPdfObject().getAsArray(PdfName.Decode); - } - - /** - * Sets the {@code float[]} of numbers specifying how to map vertex coordinates and colour components - * into the appropriate ranges of values. The ranges shall be specified as follows: - * [x_min x_max y_min y_max c1_min c1_max … cn_min cn_max]. - * Only one pair of color values shall be specified if a Function entry is present. - * - * @param decode the {@code float[]} of Decode object to set. - */ - public void setDecode(float[] decode) { - setDecode(new PdfArray(decode)); - } - - /** - * Sets the {@link PdfArray} of numbers specifying how to map vertex coordinates and colour components - * into the appropriate ranges of values. The ranges shall be specified as follows: - * [x_min x_max y_min y_max c1_min c1_max … cn_min cn_max]. - * Only one pair of color values shall be specified if a Function entry is present. - * - * @param decode the {@link PdfArray} Decode object to set. - */ - public void setDecode(PdfArray decode) { - getPdfObject().put(PdfName.Decode, decode); - setModified(); - } - } - - /** - * The class that extends {@link PdfShading} class and is in charge of Shading Dictionary with - * Tensor-Product Patch mesh type. - * - * This type of shading is identical to {@link CoonsPatchMesh}, except that it's based on a - * bicubic tensor-product patch defined by 16 control points. - * - * For the format of data stream, that defines patches, see ISO-320001 Table 86. - */ - public static class TensorProductPatchMesh extends PdfShading { - - - /** - * Creates the new instance of the class from the existing {@link PdfStream}. - * - * @param pdfStream from which this {@link TensorProductPatchMesh} will be created - */ - protected TensorProductPatchMesh(PdfStream pdfStream) { - super(pdfStream); - } - - /** - * Creates the new instance of the class. - * - * @param cs the {@link PdfColorSpace} object in which colour values shall be expressed. - * The special Pattern space isn't excepted. - * @param bitsPerCoordinate the number of bits used to represent each vertex coordinate. - * The value shall be 1, 2, 4, 8, 12, 16, 24, or 32. - * @param bitsPerComponent the number of bits used to represent each colour component. - * The value shall be 1, 2, 4, 8, 12, or 16. - * @param bitsPerFlag the number of bits used to represent the edge flag for each vertex. - * The value of BitsPerFlag shall be 2, 4, or 8, - * but only the least significant 2 bits in each flag value shall be used. - * The value for the edge flag shall be 0, 1, 2 or 3. - * @param decode the {@code int[]} of numbers specifying how to map vertex coordinates and colour components - * into the appropriate ranges of values. The ranges shall be specified as follows: - * [x_min x_max y_min y_max c1_min c1_max … cn_min cn_max]. - * Only one pair of color values shall be specified if a Function entry is present. - */ - public TensorProductPatchMesh(PdfColorSpace cs, int bitsPerCoordinate, int bitsPerComponent, int bitsPerFlag, float[] decode) { - this(cs, bitsPerCoordinate, bitsPerComponent, bitsPerFlag, new PdfArray(decode)); - } - - /** - * Creates the new instance of the class. - * - * @param cs the {@link PdfColorSpace} object in which colour values shall be expressed. - * The special Pattern space isn't excepted. - * @param bitsPerCoordinate the number of bits used to represent each vertex coordinate. - * The value shall be 1, 2, 4, 8, 12, 16, 24, or 32. - * @param bitsPerComponent the number of bits used to represent each colour component. - * The value shall be 1, 2, 4, 8, 12, or 16. - * @param bitsPerFlag the number of bits used to represent the edge flag for each vertex. - * The value of BitsPerFlag shall be 2, 4, or 8, - * but only the least significant 2 bits in each flag value shall be used. - * The value for the edge flag shall be 0, 1, 2 or 3. - * @param decode the {@link PdfArray} of numbers specifying how to map vertex coordinates and colour components - * into the appropriate ranges of values. The ranges shall be specified as follows: - * [x_min x_max y_min y_max c1_min c1_max … cn_min cn_max]. - * Only one pair of color values shall be specified if a Function entry is present. - */ - public TensorProductPatchMesh(PdfColorSpace cs, int bitsPerCoordinate, int bitsPerComponent, int bitsPerFlag, PdfArray decode) { - super(new PdfStream(), ShadingType.TENSOR_PRODUCT_PATCH_MESH, cs); - - setBitsPerCoordinate(bitsPerCoordinate); - setBitsPerComponent(bitsPerComponent); - setBitsPerFlag(bitsPerFlag); - setDecode(decode); - } - - /** - * Gets the number of bits used to represent each vertex coordinate. - * - * @return the number of bits. Can be 1, 2, 4, 8, 12, 16, 24, or 32. - */ - public int getBitsPerCoordinate() { - return (int) getPdfObject().getAsInt(PdfName.BitsPerCoordinate); - } - - /** - * Sets the number of bits used to represent each vertex coordinate. - * - * @param bitsPerCoordinate the number of bits to be set. Shall be 1, 2, 4, 8, 12, 16, 24, or 32. - */ - public void setBitsPerCoordinate(int bitsPerCoordinate) { - getPdfObject().put(PdfName.BitsPerCoordinate, new PdfNumber(bitsPerCoordinate)); - setModified(); - } - - /** - * Gets the number of bits used to represent each colour component. - * - * @return the number of bits. Can be 1, 2, 4, 8, 12, or 16. - */ - public int getBitsPerComponent() { - return (int) getPdfObject().getAsInt(PdfName.BitsPerComponent); - } - - /** - * Sets the number of bits used to represent each colour component. - * - * @param bitsPerComponent the number of bits to be set. Shall be 1, 2, 4, 8, 12, or 16. - */ - public void setBitsPerComponent(int bitsPerComponent) { - getPdfObject().put(PdfName.BitsPerComponent, new PdfNumber(bitsPerComponent)); - setModified(); - } - - /** - * Gets the number of bits used to represent the edge flag for each vertex. - * But only the least significant 2 bits in each flag value shall be used. - * The valid flag values are 0, 1, 2 or 3. - * - * @return the number of bits. Can be 2, 4 or 8. - */ - public int getBitsPerFlag() { - return (int) getPdfObject().getAsInt(PdfName.BitsPerFlag); - } - - /** - * Sets the number of bits used to represent the edge flag for each vertex. - * But only the least significant 2 bits in each flag value shall be used. - * The valid flag values are 0, 1, 2 or 3. - * - * @param bitsPerFlag the number of bits to be set. Shall be 2, 4 or 8. - */ - public void setBitsPerFlag(int bitsPerFlag) { - getPdfObject().put(PdfName.BitsPerFlag, new PdfNumber(bitsPerFlag)); - setModified(); - } - - /** - * Gets the {@link PdfArray} of numbers specifying how to map vertex coordinates and colour components - * into the appropriate ranges of values. The ranges shall be specified as follows: - * [x_min x_max y_min y_max c1_min c1_max … cn_min cn_max]. - * Only one pair of color values shall be specified if a Function entry is present. - * - * @return the {@link PdfArray} Decode object. - */ - public PdfArray getDecode() { - return getPdfObject().getAsArray(PdfName.Decode); - } - - /** - * Sets the {@code float[]} of numbers specifying how to map vertex coordinates and colour components - * into the appropriate ranges of values. The ranges shall be specified as follows: - * [x_min x_max y_min y_max c1_min c1_max … cn_min cn_max]. - * Only one pair of color values shall be specified if a Function entry is present. - * - * @param decode the {@code float[]} of Decode object to set. - */ - public void setDecode(float[] decode) { - setDecode(new PdfArray(decode)); - } - - /** - * Sets the {@link PdfArray} of numbers specifying how to map vertex coordinates and colour components - * into the appropriate ranges of values. The ranges shall be specified as follows: - * [x_min x_max y_min y_max c1_min c1_max … cn_min cn_max]. - * Only one pair of color values shall be specified if a Function entry is present. - * - * @param decode the {@link PdfArray} Decode object to set. - */ - public void setDecode(PdfArray decode) { - getPdfObject().put(PdfName.Decode, decode); - setModified(); - } - } -} diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/colorspace/shading/AbstractPdfShading.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/colorspace/shading/AbstractPdfShading.java new file mode 100644 index 0000000000..534132382c --- /dev/null +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/colorspace/shading/AbstractPdfShading.java @@ -0,0 +1,199 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.pdf.colorspace.shading; + +import com.itextpdf.kernel.exceptions.KernelExceptionMessageConstant; +import com.itextpdf.kernel.exceptions.PdfException; +import com.itextpdf.kernel.pdf.PdfArray; +import com.itextpdf.kernel.pdf.PdfDictionary; +import com.itextpdf.kernel.pdf.PdfDocument; +import com.itextpdf.kernel.pdf.PdfName; +import com.itextpdf.kernel.pdf.PdfNumber; +import com.itextpdf.kernel.pdf.PdfObject; +import com.itextpdf.kernel.pdf.PdfObjectWrapper; +import com.itextpdf.kernel.pdf.PdfStream; +import com.itextpdf.kernel.pdf.colorspace.PdfColorSpace; +import com.itextpdf.kernel.pdf.colorspace.PdfSpecialCs.Pattern; +import com.itextpdf.kernel.pdf.function.IPdfFunction; + +/** + * The PdfShading class that represents the Shading Dictionary PDF object. + */ +public abstract class AbstractPdfShading extends PdfObjectWrapper { + + /** + * Creates the {@link AbstractPdfShading} object from the existing {@link PdfDictionary} with corresponding type. + * + * @param shadingDictionary {@link PdfDictionary} from which the {@link AbstractPdfShading} object will be created + * + * @return Created {@link AbstractPdfShading} object + */ + public static AbstractPdfShading makeShading(PdfDictionary shadingDictionary) { + if (!shadingDictionary.containsKey(PdfName.ShadingType)) { + throw new PdfException(KernelExceptionMessageConstant.SHADING_TYPE_NOT_FOUND); + } + if (!shadingDictionary.containsKey(PdfName.ColorSpace)) { + throw new PdfException(KernelExceptionMessageConstant.COLOR_SPACE_NOT_FOUND); + } + + AbstractPdfShading shading; + switch (shadingDictionary.getAsNumber(PdfName.ShadingType).intValue()) { + case ShadingType.FUNCTION_BASED: + shading = new PdfFunctionBasedShading(shadingDictionary); + break; + case ShadingType.AXIAL: + shading = new PdfAxialShading(shadingDictionary); + break; + case ShadingType.RADIAL: + shading = new PdfRadialShading(shadingDictionary); + break; + case ShadingType.FREE_FORM_GOURAUD_SHADED_TRIANGLE_MESH: + if (!shadingDictionary.isStream()) { + throw new PdfException(KernelExceptionMessageConstant.UNEXPECTED_SHADING_TYPE); + } + shading = new PdfFreeFormGouraudShadedTriangleShading((PdfStream) shadingDictionary); + break; + case ShadingType.LATTICE_FORM_GOURAUD_SHADED_TRIANGLE_MESH: + if (!shadingDictionary.isStream()) { + throw new PdfException(KernelExceptionMessageConstant.UNEXPECTED_SHADING_TYPE); + } + shading = new PdfLatticeFormGouraudShadedTriangleShading((PdfStream) shadingDictionary); + break; + case ShadingType.COONS_PATCH_MESH: + if (!shadingDictionary.isStream()) { + throw new PdfException(KernelExceptionMessageConstant.UNEXPECTED_SHADING_TYPE); + } + shading = new PdfCoonsPatchShading((PdfStream) shadingDictionary); + break; + case ShadingType.TENSOR_PRODUCT_PATCH_MESH: + if (!shadingDictionary.isStream()) { + throw new PdfException(KernelExceptionMessageConstant.UNEXPECTED_SHADING_TYPE); + } + shading = new PdfTensorProductPatchShading((PdfStream) shadingDictionary); + break; + default: + throw new PdfException(KernelExceptionMessageConstant.UNEXPECTED_SHADING_TYPE); + } + return shading; + } + + /** + * Creates the {@link AbstractPdfShading} object from the existing {@link PdfDictionary}. + * + * @param pdfObject {@link PdfDictionary} from which the {@link AbstractPdfShading} object will be created + */ + protected AbstractPdfShading(PdfDictionary pdfObject) { + super(pdfObject); + } + + /** + * Creates the {@link AbstractPdfShading} object from the existing {@link PdfDictionary}, + * using provided type and colorspace. + * + * @param pdfObject {@link PdfDictionary} from which the {@link AbstractPdfShading} object will be created + * @param type type with which this {@link AbstractPdfShading} object will be created + * @param colorSpace {@link PdfColorSpace} with which this {@link AbstractPdfShading} object will be created + */ + protected AbstractPdfShading(PdfDictionary pdfObject, int type, PdfColorSpace colorSpace) { + super(pdfObject); + getPdfObject().put(PdfName.ShadingType, new PdfNumber(type)); + if (colorSpace instanceof Pattern) { + throw new IllegalArgumentException("colorSpace"); + } + getPdfObject().put(PdfName.ColorSpace, colorSpace.getPdfObject()); + } + + /** + * Gets the shading type. + * + * @return int value of {@link PdfName#ShadingType} + */ + public int getShadingType() { + return (int) getPdfObject().getAsInt(PdfName.ShadingType); + } + + /** + * Gets the color space in which colour values shall be expressed. + * + * @return {@link PdfObject} Color space + */ + public PdfObject getColorSpace() { + return getPdfObject().get(PdfName.ColorSpace); + } + + /** + * Gets the function PdfObject that represents color transitions + * across the shading geometry. + * + * @return {@link PdfObject} Function + */ + public PdfObject getFunction() { + return getPdfObject().get(PdfName.Function); + } + + /** + * Sets the function that represents color transitions + * across the shading geometry as one object. + * + * @param function The {@link IPdfFunction} to set + */ + public final void setFunction(IPdfFunction function) { + getPdfObject().put(PdfName.Function, function.getAsPdfObject()); + setModified(); + } + + /** + * Sets the function object that represents color transitions + * across the shading geometry as an array of functions. + * + * @param functions The array of {@link IPdfFunction} to be set + */ + public final void setFunction(IPdfFunction[] functions) { + PdfArray arr = new PdfArray(); + for (IPdfFunction func : functions) { + arr.add(func.getAsPdfObject()); + } + getPdfObject().put(PdfName.Function, arr); + setModified(); + } + + /** + * To manually flush a {@code PdfObject} behind this wrapper, you have to ensure + * that this object is added to the document, i.e. it has an indirect reference. + * Basically this means that before flushing you need to explicitly call {@link #makeIndirect(PdfDocument)}. + * For example: wrapperInstance.makeIndirect(document).flush(); + * Note that not every wrapper require this, only those that have such warning in documentation. + */ + @Override + public final void flush() { + super.flush(); + } + + /** + * {@inheritDoc} + */ + @Override + protected boolean isWrappedObjectMustBeIndirect() { + return true; + } +} diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/colorspace/shading/AbstractPdfShadingBlend.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/colorspace/shading/AbstractPdfShadingBlend.java new file mode 100644 index 0000000000..950278c382 --- /dev/null +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/colorspace/shading/AbstractPdfShadingBlend.java @@ -0,0 +1,150 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.pdf.colorspace.shading; + +import com.itextpdf.kernel.pdf.PdfArray; +import com.itextpdf.kernel.pdf.PdfDictionary; +import com.itextpdf.kernel.pdf.PdfName; +import com.itextpdf.kernel.pdf.colorspace.PdfColorSpace; + +/** + * The PdfShadingBlend class which extends {@link AbstractPdfShading} and represents shadings which are + * based on a blend, with Coords, Domain and Extend fields in the PDF object. + */ +public abstract class AbstractPdfShadingBlend extends AbstractPdfShading { + + /** + * Gets the coords {@link PdfArray} object. + * + * @return the {@link PdfArray} coords object + */ + public PdfArray getCoords() { + return getPdfObject().getAsArray(PdfName.Coords); + } + + /** + * Sets the Coords object with the {@link PdfArray}, + * that specified the starting and the endings coordinates of thew axis, + * expressed in the shading's target coordinate space. + * + * @param coords the Chords {@link PdfArray} to be set + */ + public final void setCoords(PdfArray coords) { + getPdfObject().put(PdfName.Coords, coords); + setModified(); + } + + /** + * Gets the {@link PdfArray} of two {@code float} [t0, t1] that represent the limiting values of a parametric + * variable t, that becomes an input of color function(s). + * + * @return the {@link PdfArray} of Domain object ([0.0 1.0] by default) + */ + public PdfArray getDomain() { + PdfArray domain = getPdfObject().getAsArray(PdfName.Domain); + if (domain == null) { + domain = new PdfArray(new float[]{0, 1}); + setDomain(domain); + } + return domain; + } + + /** + * Sets the Domain with the array of two {@code float} [t0, t1] that represent the limiting values + * of a parametric variable t, that becomes an input of color function(s). + * + * @param t0 first limit of variable t + * @param t1 second limit of variable t + */ + public final void setDomain(float t0, float t1) { + setDomain(new PdfArray(new float[] {t0, t1})); + } + + /** + * Sets the Domain with the {@link PdfArray} of two {@code float} [t0, t1] that represent the limiting values + * of a parametric variable t, that becomes an input of color function(s). + * + * @param domain the {@link PdfArray} that represents domain + */ + public final void setDomain(PdfArray domain) { + getPdfObject().put(PdfName.Domain, domain); + setModified(); + } + + /** + * Gets the {@link PdfArray} of two {@code boolean} that specified whether to extend the shading + * beyond the starting and ending points of the axis, respectively. + * + * @return the {@link PdfArray} of Extended object ([false false] by default) + */ + public PdfArray getExtend() { + PdfArray extend = getPdfObject().getAsArray(PdfName.Extend); + if (extend == null) { + extend = new PdfArray(new boolean[]{false, false}); + setExtend(extend); + } + return extend; + } + + /** + * Sets the Extend object with the two {@code boolean} value. + * + * @param extendStart if true will extend shading beyond the starting point of Coords + * @param extendEnd if true will extend shading beyond the ending point of Coords + */ + public final void setExtend(boolean extendStart, boolean extendEnd) { + setExtend(new PdfArray(new boolean[] {extendStart, extendEnd})); + } + + /** + * Sets the Extend object with the {@link PdfArray} of two {@code boolean}. + * If first is true shading will extend beyond the starting point of Coords. + * If second is true shading will extend beyond the ending point of Coords. + * + * @param extend the {@link PdfArray} representing Extend object + */ + public final void setExtend(PdfArray extend) { + getPdfObject().put(PdfName.Extend, extend); + setModified(); + } + + /** + * Constructor for PdfShadingBlend object using a PdfDictionary. + * + * @param pdfObject input PdfDictionary + */ + protected AbstractPdfShadingBlend(PdfDictionary pdfObject) { + super(pdfObject); + } + + /** + * Constructor for PdfShadingBlend object using PdfDictionary, shading type and colorspace value. + * + * @param pdfObject input PdfDictionary + * @param shadingType shading type + * @param cs color space + */ + protected AbstractPdfShadingBlend(PdfDictionary pdfObject, int shadingType, PdfColorSpace cs) { + super(pdfObject, shadingType, cs); + } +} diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/colorspace/shading/AbstractPdfShadingMesh.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/colorspace/shading/AbstractPdfShadingMesh.java new file mode 100644 index 0000000000..8b905f6e1f --- /dev/null +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/colorspace/shading/AbstractPdfShadingMesh.java @@ -0,0 +1,131 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.pdf.colorspace.shading; + +import com.itextpdf.kernel.pdf.PdfArray; +import com.itextpdf.kernel.pdf.PdfDictionary; +import com.itextpdf.kernel.pdf.PdfName; +import com.itextpdf.kernel.pdf.PdfNumber; +import com.itextpdf.kernel.pdf.colorspace.PdfColorSpace; + +/** + * The PdfShadingMesh class which extends {@link AbstractPdfShading} and represents shadings which are based on a mesh, + * with BitsPerCoordinate, BitsPerComponent and Decode fields in the PDF object. + */ +public abstract class AbstractPdfShadingMesh extends AbstractPdfShading { + + /** + * Gets the number of bits used to represent each vertex coordinate. + * + * @return the number of bits. Can be 1, 2, 4, 8, 12, 16, 24, or 32 + */ + public int getBitsPerCoordinate() { + return (int) getPdfObject().getAsInt(PdfName.BitsPerCoordinate); + } + + /** + * Sets the number of bits used to represent each vertex coordinate. + * + * @param bitsPerCoordinate the number of bits to be set. Shall be 1, 2, 4, 8, 12, 16, 24, or 32 + */ + public final void setBitsPerCoordinate(int bitsPerCoordinate) { + getPdfObject().put(PdfName.BitsPerCoordinate, new PdfNumber(bitsPerCoordinate)); + setModified(); + } + + /** + * Gets the number of bits used to represent each colour component. + * + * @return the number of bits. Can be 1, 2, 4, 8, 12, or 16 + */ + public int getBitsPerComponent() { + return (int) getPdfObject().getAsInt(PdfName.BitsPerComponent); + } + + /** + * Sets the number of bits used to represent each colour component. + * + * @param bitsPerComponent the number of bits to be set. Shall be 1, 2, 4, 8, 12, or 16 + */ + public final void setBitsPerComponent(int bitsPerComponent) { + getPdfObject().put(PdfName.BitsPerComponent, new PdfNumber(bitsPerComponent)); + setModified(); + } + + /** + * Gets the {@link PdfArray} of numbers specifying how to map vertex coordinates and colour components + * into the appropriate ranges of values. The ranges shall be specified as follows: + * [x_min x_max y_min y_max c1_min c1_max … cn_min cn_max]. + * Only one pair of color values shall be specified if a Function entry is present. + * + * @return the {@link PdfArray} Decode object + */ + public PdfArray getDecode() { + return getPdfObject().getAsArray(PdfName.Decode); + } + + /** + * Sets the {@code float[]} of numbers specifying how to map vertex coordinates and colour components + * into the appropriate ranges of values. The ranges shall be specified as follows: + * [x_min x_max y_min y_max c1_min c1_max … cn_min cn_max]. + * Only one pair of color values shall be specified if a Function entry is present. + * + * @param decode the {@code float[]} of Decode object to set + */ + public final void setDecode(float[] decode) { + setDecode(new PdfArray(decode)); + } + + /** + * Sets the {@link PdfArray} of numbers specifying how to map vertex coordinates and colour components + * into the appropriate ranges of values. The ranges shall be specified as follows: + * [x_min x_max y_min y_max c1_min c1_max … cn_min cn_max]. + * Only one pair of color values shall be specified if a Function entry is present. + * + * @param decode the {@link PdfArray} Decode object to set + */ + public final void setDecode(PdfArray decode) { + getPdfObject().put(PdfName.Decode, decode); + setModified(); + } + + /** + * Constructor for PdfShadingBlend object using a PdfDictionary. + * + * @param pdfObject input PdfDictionary + */ + protected AbstractPdfShadingMesh(PdfDictionary pdfObject) { + super(pdfObject); + } + + /** + * Constructor for PdfShadingBlend object using a PdfDictionary, shading type and color space. + * + * @param pdfObject input PdfDictionary + * @param type shading type + * @param colorSpace color space + */ + protected AbstractPdfShadingMesh(PdfDictionary pdfObject, int type, PdfColorSpace colorSpace) { + super(pdfObject, type, colorSpace); + } +} diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/colorspace/shading/AbstractPdfShadingMeshWithFlags.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/colorspace/shading/AbstractPdfShadingMeshWithFlags.java new file mode 100644 index 0000000000..efbc296552 --- /dev/null +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/colorspace/shading/AbstractPdfShadingMeshWithFlags.java @@ -0,0 +1,79 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.pdf.colorspace.shading; + +import com.itextpdf.kernel.pdf.PdfDictionary; +import com.itextpdf.kernel.pdf.PdfName; +import com.itextpdf.kernel.pdf.PdfNumber; +import com.itextpdf.kernel.pdf.colorspace.PdfColorSpace; + +/** + * The PdfShadingMeshFlags class which extends {@link AbstractPdfShading} and {@link AbstractPdfShadingMesh} + * and represents shadings which are based on a mesh, with all fields from {@link AbstractPdfShadingMesh} + * as well as BitsPerFlag in the PDF object. + */ +public abstract class AbstractPdfShadingMeshWithFlags extends AbstractPdfShadingMesh { + + /** + * Gets the number of bits used to represent the edge flag for each vertex. + * But only the least significant 2 bits in each flag value shall be used. + * The valid flag values are 0, 1, 2 or 3. + * + * @return the number of bits. Can be 2, 4 or 8 + */ + public int getBitsPerFlag() { + return (int) getPdfObject().getAsInt(PdfName.BitsPerFlag); + } + + /** + * Sets the number of bits used to represent the edge flag for each vertex. + * But only the least significant 2 bits in each flag value shall be used. + * The valid flag values are 0, 1, 2 or 3. + * + * @param bitsPerFlag the number of bits to be set. Shall be 2, 4 or 8 + */ + public final void setBitsPerFlag(int bitsPerFlag) { + getPdfObject().put(PdfName.BitsPerFlag, new PdfNumber(bitsPerFlag)); + setModified(); + } + + /** + * Constructor for PdfShadingBlend object using a PdfDictionary. + * + * @param pdfObject input PdfDictionary + */ + protected AbstractPdfShadingMeshWithFlags(PdfDictionary pdfObject) { + super(pdfObject); + } + + /** + * Constructor for PdfShadingBlend object using a PdfDictionary, shading type and color space. + * + * @param pdfObject input PdfDictionary + * @param type shading type + * @param colorSpace color space + */ + protected AbstractPdfShadingMeshWithFlags(PdfDictionary pdfObject, int type, PdfColorSpace colorSpace) { + super(pdfObject, type, colorSpace); + } +} diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/colorspace/shading/PdfAxialShading.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/colorspace/shading/PdfAxialShading.java new file mode 100644 index 0000000000..af800da662 --- /dev/null +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/colorspace/shading/PdfAxialShading.java @@ -0,0 +1,137 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.pdf.colorspace.shading; + +import com.itextpdf.kernel.pdf.PdfArray; +import com.itextpdf.kernel.pdf.PdfDictionary; +import com.itextpdf.kernel.pdf.colorspace.PdfColorSpace; +import com.itextpdf.kernel.pdf.function.IPdfFunction; +import com.itextpdf.kernel.pdf.function.PdfType2Function; + +/** + * The class that extends {@link AbstractPdfShading} and {@link AbstractPdfShadingBlend} classes + * and is in charge of Shading Dictionary with axial type, that define a colour blend that varies along + * a linear axis between two endpoints and extends indefinitely perpendicular to that axis. + */ +public class PdfAxialShading extends AbstractPdfShadingBlend { + + /** + * Creates the new instance of the class from the existing {@link PdfDictionary}. + * + * @param pdfDictionary from which this {@link PdfAxialShading} will be created + */ + public PdfAxialShading(PdfDictionary pdfDictionary) { + super(pdfDictionary); + } + + /** + * Creates the new instance of the class. + * + * @param cs the {@link PdfColorSpace} object in which colour values shall be expressed. + * The special Pattern space isn't excepted + * @param x0 the start coordinate of X axis expressed in the shading's target coordinate space + * @param y0 the start coordinate of Y axis expressed in the shading's target coordinate space + * @param color0 the {@code float[]} that represents the color in the start point + * @param x1 the end coordinate of X axis expressed in the shading's target coordinate space + * @param y1 the end coordinate of Y axis expressed in the shading's target coordinate space + * @param color1 the {@code float[]} that represents the color in the end point + */ + public PdfAxialShading(PdfColorSpace cs, float x0, float y0, float[] color0, float x1, float y1, float[] color1) { + super(new PdfDictionary(), ShadingType.AXIAL, cs); + + setCoords(x0, y0, x1, y1); + IPdfFunction func = new PdfType2Function(new float[] {0, 1}, null, color0, color1, 1); + setFunction(func); + } + + /** + * Creates the new instance of the class. + * + * @param cs the {@link PdfColorSpace} object in which colour values shall be expressed. + * The special Pattern space isn't excepted + * @param x0 the start coordinate of X axis expressed in the shading's target coordinate space + * @param y0 the start coordinate of Y axis expressed in the shading's target coordinate space + * @param color0 the {@code float[]} that represents the color in the start point + * @param x1 the end coordinate of X axis expressed in the shading's target coordinate space + * @param y1 the end coordinate of Y axis expressed in the shading's target coordinate space + * @param color1 the {@code float[]} that represents the color in the end point + * @param extend the array of two booleans that specified whether to extend the shading + * beyond the starting and ending points of the axis, respectively + */ + public PdfAxialShading(PdfColorSpace cs, float x0, float y0, float[] color0, float x1, float y1, + float[] color1, boolean[] extend) { + this(cs, x0, y0, color0, x1, y1, color1); + + if (extend == null || extend.length != 2) + throw new IllegalArgumentException("extend"); + + setExtend(extend[0], extend[1]); + } + + /** + * Creates the new instance of the class. + * + * @param cs the {@link PdfColorSpace} object in which colour values shall be expressed. + * The special Pattern space isn't excepted + * @param coords the {@link PdfArray} of four numbers [x0 y0 x1 y1] that specified the starting + * and the endings coordinates of thew axis, expressed in the shading's target coordinate space + * @param function the {@link IPdfFunction} object, that is used to calculate color transitions + */ + public PdfAxialShading(PdfColorSpace cs, PdfArray coords, IPdfFunction function) { + this(cs, coords, null, function); + } + + /** + * Creates the new instance of the class. + * + * @param cs the {@link PdfColorSpace} object in which colour values shall be expressed. + * The special Pattern space isn't excepted + * @param coords the {@link PdfArray} of four numbers [x0 y0 x1 y1] that specified + * the starting and the endings coordinates of thew axis, expressed + * in the shading's target coordinate space + * @param domain the {@link PdfArray} of two numbers [t0 t1] specifying the limiting values + * of a parametric variable t which is considered to vary linearly between + * these two values and becomes the input argument to the colour function + * @param function the {@link IPdfFunction} object, that is used to calculate color transitions + */ + public PdfAxialShading(PdfColorSpace cs, PdfArray coords, PdfArray domain, IPdfFunction function) { + super(new PdfDictionary(), ShadingType.AXIAL, cs); + setCoords(coords); + if (domain != null) { + setDomain(domain); + } + setFunction(function); + } + + /** + * Sets the Choords object with the four params expressed in the shading's target coordinate space. + * + * @param x0 the start coordinate of X axis to be set + * @param y0 the start coordinate of Y axis to be set + * @param x1 the end coordinate of X axis to be set + * @param y1 the end coordinate of Y axis to be set + */ + public final void setCoords(float x0, float y0, float x1, float y1) { + setCoords(new PdfArray(new float[] {x0, y0, x1, y1})); + } +} \ No newline at end of file diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/colorspace/shading/PdfCoonsPatchShading.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/colorspace/shading/PdfCoonsPatchShading.java new file mode 100644 index 0000000000..1e2dc40c6a --- /dev/null +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/colorspace/shading/PdfCoonsPatchShading.java @@ -0,0 +1,117 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.pdf.colorspace.shading; + +import com.itextpdf.kernel.pdf.PdfArray; +import com.itextpdf.kernel.pdf.PdfStream; +import com.itextpdf.kernel.pdf.colorspace.PdfColorSpace; + +/** + * The class that extends {@link AbstractPdfShading}, {@link AbstractPdfShadingMesh} and + * {@link AbstractPdfShadingMeshWithFlags} classes and is in charge of Shading Dictionary with Coons Patch mesh type. + * + *

+ * This type of shading is constructed from one or more colour patches, each bounded by four cubic Bézier curves. + * Degenerate Bézier curves are allowed and are useful for certain graphical effects. + * At least one complete patch shall be specified. + * + *

+ * The shape of patch is defined by 12 control points. + * + *

+ * Colours are specified for each corner of the unit square, + * and bilinear interpolation is used to fill in colours over the entire unit square. + * + *

+ * Coordinates are mapped from the unit square into a four-sided patch whose sides are not necessarily linear. + * The mapping is continuous: the corners of the unit square map to corners of the patch + * and the sides of the unit square map to sides of the patch. + * + *

+ * For the format of data stream, that defines patches (see ISO-320001 Table 85). + * + *

+ * If the shading dictionary contains a Function entry, the colour data for each corner of a patch + * shall be specified by a single parametric value t rather than by n separate colour components c1...cn. + */ +public class PdfCoonsPatchShading extends AbstractPdfShadingMeshWithFlags { + + /** + * Creates the new instance of the class from the existing {@link PdfStream}. + * + * @param pdfStream from which this {@link PdfCoonsPatchShading} will be created + */ + public PdfCoonsPatchShading(PdfStream pdfStream) { + super(pdfStream); + } + + /** + * Creates the new instance of the class. + * + * @param cs the {@link PdfColorSpace} object in which colour values shall be expressed. + * The special Pattern space isn't excepted + * @param bitsPerCoordinate the number of bits used to represent each vertex coordinate. + * The value shall be 1, 2, 4, 8, 12, 16, 24, or 32 + * @param bitsPerComponent the number of bits used to represent each colour component. + * The value shall be 1, 2, 4, 8, 12, or 16 + * @param bitsPerFlag the number of bits used to represent the edge flag for each vertex. + * The value of BitsPerFlag shall be 2, 4, or 8, + * but only the least significant 2 bits in each flag value shall be used. + * The value for the edge flag shall be 0, 1, 2 or 3 + * @param decode the {@code int[]} of numbers specifying how to map vertex coordinates and colour components + * into the appropriate ranges of values. The ranges shall be specified as follows: + * [x_min x_max y_min y_max c1_min c1_max … cn_min cn_max]. + * Only one pair of color values shall be specified if a Function entry is present + */ + public PdfCoonsPatchShading(PdfColorSpace cs, int bitsPerCoordinate, int bitsPerComponent, + int bitsPerFlag, float[] decode) { + this(cs, bitsPerCoordinate, bitsPerComponent, bitsPerFlag, new PdfArray(decode)); + } + + /** + * Creates the new instance of the class. + * + * @param cs the {@link PdfColorSpace} object in which colour values shall be expressed. + * The special Pattern space isn't excepted + * @param bitsPerCoordinate the number of bits used to represent each vertex coordinate. + * The value shall be 1, 2, 4, 8, 12, 16, 24, or 32 + * @param bitsPerComponent the number of bits used to represent each colour component. + * The value shall be 1, 2, 4, 8, 12, or 16 + * @param bitsPerFlag the number of bits used to represent the edge flag for each vertex. + * The value of BitsPerFlag shall be 2, 4, or 8, + * but only the least significant 2 bits in each flag value shall be used. + * The value for the edge flag shall be 0, 1, 2 or 3 + * @param decode the {@link PdfArray} of numbers specifying how to map vertex coordinates and colour components + * into the appropriate ranges of values. The ranges shall be specified as follows: + * [x_min x_max y_min y_max c1_min c1_max … cn_min cn_max]. + * Only one pair of color values shall be specified if a Function entry is present + */ + public PdfCoonsPatchShading(PdfColorSpace cs, int bitsPerCoordinate, int bitsPerComponent, + int bitsPerFlag, PdfArray decode) { + super(new PdfStream(), ShadingType.COONS_PATCH_MESH, cs); + setBitsPerCoordinate(bitsPerCoordinate); + setBitsPerComponent(bitsPerComponent); + setBitsPerFlag(bitsPerFlag); + setDecode(decode); + } +} \ No newline at end of file diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/colorspace/shading/PdfFreeFormGouraudShadedTriangleShading.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/colorspace/shading/PdfFreeFormGouraudShadedTriangleShading.java new file mode 100644 index 0000000000..68739d7db8 --- /dev/null +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/colorspace/shading/PdfFreeFormGouraudShadedTriangleShading.java @@ -0,0 +1,113 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.pdf.colorspace.shading; + +import com.itextpdf.kernel.pdf.PdfArray; +import com.itextpdf.kernel.pdf.PdfStream; +import com.itextpdf.kernel.pdf.colorspace.PdfColorSpace; + +/** + * The class that extends {@link AbstractPdfShading}, {@link AbstractPdfShadingMesh} and + * {@link AbstractPdfShadingMeshWithFlags} classes and is in charge of Shading Dictionary + * with free-form Gouraud-shaded triangle mesh type. + * + *

+ * The area to be shaded is defined by a path composed entirely of triangles. + * The colour at each vertex of the triangles is specified, + * and a technique known as Gouraud interpolation is used to colour the interiors. + * + *

+ * The object shall be represented as stream containing a sequence of vertex data. + * Each vertex is specified by the following values, in the order shown: + * f x y c1 ... cn where: + * f - the vertex's edge flag, that determines the vertex is connected to other vertices of the triangle mesh. + * For full description, see ISO-320001 Paragraph 8.7.4.5.5 + * x, y - vertex's horizontal and vertical coordinates, expressed in the shading's target coordinate space. + * c1...cn - vertex's colour components. + * + *

+ * If the shading dictionary includes a Function entry, only a single parametric value, t, + * shall be specified for each vertex in place of the colour components c1...cn. + */ +public class PdfFreeFormGouraudShadedTriangleShading extends AbstractPdfShadingMeshWithFlags { + + /** + * Creates the new instance of the class from the existing {@link PdfStream}. + * + * @param pdfStream from which this {@link PdfFreeFormGouraudShadedTriangleShading} will be created + */ + public PdfFreeFormGouraudShadedTriangleShading(PdfStream pdfStream) { + super(pdfStream); + } + + /** + * Creates the new instance of the class. + * + * @param cs the {@link PdfColorSpace} object in which colour values shall be expressed. + * The special Pattern space isn't excepted. + * @param bitsPerCoordinate the number of bits used to represent each vertex coordinate. + * The value shall be 1, 2, 4, 8, 12, 16, 24, or 32 + * @param bitsPerComponent the number of bits used to represent each colour component. + * The value shall be 1, 2, 4, 8, 12, or 16 + * @param bitsPerFlag the number of bits used to represent the edge flag for each vertex. + * The value of BitsPerFlag shall be 2, 4, or 8, + * but only the least significant 2 bits in each flag value shall be used. + * The value for the edge flag shall be 0, 1, or 2 + * @param decode the {@code int[]} of numbers specifying how to map vertex coordinates and colour components + * into the appropriate ranges of values. The ranges shall be specified as follows: + * [x_min x_max y_min y_max c1_min c1_max … cn_min cn_max]. + * Only one pair of color values shall be specified if a Function entry is present + */ + public PdfFreeFormGouraudShadedTriangleShading(PdfColorSpace cs, int bitsPerCoordinate, int bitsPerComponent, + int bitsPerFlag, float[] decode) { + this(cs, bitsPerCoordinate, bitsPerComponent, bitsPerFlag, new PdfArray(decode)); + } + + /** + * Creates the new instance of the class. + * + * @param cs the {@link PdfColorSpace} object in which colour values shall be expressed. + * The special Pattern space isn't excepted + * @param bitsPerCoordinate the number of bits used to represent each vertex coordinate. + * The value shall be 1, 2, 4, 8, 12, 16, 24, or 32 + * @param bitsPerComponent the number of bits used to represent each colour component. + * The value shall be 1, 2, 4, 8, 12, or 16 + * @param bitsPerFlag the number of bits used to represent the edge flag for each vertex. + * The value of BitsPerFlag shall be 2, 4, or 8, + * but only the least significant 2 bits in each flag value shall be used. + * The value for the edge flag shall be 0, 1, or 2 + * @param decode the {@link PdfArray} of numbers specifying how to map vertex coordinates and colour components + * into the appropriate ranges of values. The ranges shall be specified as follows: + * [x_min x_max y_min y_max c1_min c1_max … cn_min cn_max]. + * Only one pair of color values shall be specified if a Function entry is present + */ + public PdfFreeFormGouraudShadedTriangleShading(PdfColorSpace cs, int bitsPerCoordinate, int bitsPerComponent, + int bitsPerFlag, PdfArray decode) { + super(new PdfStream(), ShadingType.FREE_FORM_GOURAUD_SHADED_TRIANGLE_MESH, cs); + + setBitsPerCoordinate(bitsPerCoordinate); + setBitsPerComponent(bitsPerComponent); + setBitsPerFlag(bitsPerFlag); + setDecode(decode); + } +} \ No newline at end of file diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/colorspace/shading/PdfFunctionBasedShading.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/colorspace/shading/PdfFunctionBasedShading.java new file mode 100644 index 0000000000..886b3ad7e3 --- /dev/null +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/colorspace/shading/PdfFunctionBasedShading.java @@ -0,0 +1,138 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.pdf.colorspace.shading; + +import com.itextpdf.kernel.pdf.PdfArray; +import com.itextpdf.kernel.pdf.PdfDictionary; +import com.itextpdf.kernel.pdf.PdfName; +import com.itextpdf.kernel.pdf.PdfObject; +import com.itextpdf.kernel.pdf.colorspace.PdfColorSpace; +import com.itextpdf.kernel.pdf.function.IPdfFunction; + +/** + * The class that extends {@link AbstractPdfShading} class and is in charge of Shading Dictionary + * with function-based type, that defines color at every point in the domain by a specified mathematical function. + */ +public class PdfFunctionBasedShading extends AbstractPdfShading { + + /** + * Creates the new instance of the class from the existing {@link PdfDictionary}. + * + * @param pdfDictionary from which this {@link PdfFunctionBasedShading} will be created + */ + public PdfFunctionBasedShading(PdfDictionary pdfDictionary) { + super(pdfDictionary); + } + + /** + * Creates the new instance of the class. + * + * @param colorSpace the {@link PdfColorSpace} object in which colour values shall be expressed + * @param function the {@link IPdfFunction}, that is used to calculate color transitions + */ + public PdfFunctionBasedShading(PdfColorSpace colorSpace, IPdfFunction function) { + this(colorSpace.getPdfObject(), function); + } + + /** + * Creates the new instance of the class. + * + * @param colorSpace the {@link PdfObject}, that represents color space in which colour values shall be expressed + * @param function the {@link IPdfFunction}, that is used to calculate color transitions + */ + public PdfFunctionBasedShading(PdfObject colorSpace, IPdfFunction function) { + super(new PdfDictionary(), ShadingType.FUNCTION_BASED, PdfColorSpace.makeColorSpace(colorSpace)); + + setFunction(function); + } + + /** + * Gets the {@link PdfArray} domain rectangle object that establishes an internal coordinate space + * for the shading that is independent of the target coordinate space in which it shall be painted. + * + * @return {@link PdfArray} domain rectangle + */ + public PdfArray getDomain() { + return getPdfObject().getAsArray(PdfName.Domain); + } + + /** + * Sets the {@link PdfArray} domain rectangle object that establishes an internal coordinate space + * for the shading that is independent of the target coordinate space in which it shall be painted. + * + * @param xmin the Xmin coordinate of rectangle + * @param xmax the Xmax coordinate of rectangle + * @param ymin the Ymin coordinate of rectangle + * @param ymax the Ymax coordinate of rectangle + */ + public void setDomain(float xmin, float xmax, float ymin, float ymax) { + setDomain(new PdfArray(new float[] {xmin, xmax, ymin, ymax})); + } + + /** + * Sets the {@link PdfArray} domain rectangle object that establishes an internal coordinate space + * for the shading that is independent of the target coordinate space in which it shall be painted. + * + * @param domain the {@link PdfArray} domain rectangle object to be set + */ + public void setDomain(PdfArray domain) { + getPdfObject().put(PdfName.Domain, domain); + setModified(); + } + + /** + * Gets the {@link PdfArray} of floats that represents the transformation matrix that maps the domain rectangle + * into a corresponding figure in the target coordinate space. + * + * @return the {@link PdfArray} of transformation matrix (identical matrix by default) + */ + public PdfArray getMatrix() { + PdfArray matrix = getPdfObject().getAsArray(PdfName.Matrix); + if (matrix == null) { + matrix = new PdfArray(new float[]{1, 0, 0, 1, 0, 0}); + setMatrix(matrix); + } + return matrix; + } + + /** + * Sets the array of floats that represents the transformation matrix that maps the domain rectangle + * into a corresponding figure in the target coordinate space. + * + * @param matrix the {@code float[]} of transformation matrix to be set + */ + public void setMatrix(float[] matrix) { + setMatrix(new PdfArray(matrix)); + } + + /** + * Sets the array of floats that represents the transformation matrix that maps the domain rectangle + * into a corresponding figure in the target coordinate space. + * + * @param matrix the {@link PdfArray} transformation matrix object to be set + */ + public void setMatrix(PdfArray matrix) { + getPdfObject().put(PdfName.Matrix, matrix); + setModified(); + } +} diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/colorspace/shading/PdfLatticeFormGouraudShadedTriangleShading.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/colorspace/shading/PdfLatticeFormGouraudShadedTriangleShading.java new file mode 100644 index 0000000000..5d34a4c0ca --- /dev/null +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/colorspace/shading/PdfLatticeFormGouraudShadedTriangleShading.java @@ -0,0 +1,122 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.pdf.colorspace.shading; + +import com.itextpdf.kernel.pdf.PdfArray; +import com.itextpdf.kernel.pdf.PdfName; +import com.itextpdf.kernel.pdf.PdfNumber; +import com.itextpdf.kernel.pdf.PdfStream; +import com.itextpdf.kernel.pdf.colorspace.PdfColorSpace; + +/** + *The class that extends {@link AbstractPdfShading} and {@link AbstractPdfShadingMesh} classes + * and is in charge of Shading Dictionary with lattice-form Gouraud-shaded triangle mesh type. + * + *

+ * This type is similar to {@link PdfFreeFormGouraudShadedTriangleShading} but instead of using free-form geometry, + * the vertices are arranged in a pseudorectangular lattice, + * which is topologically equivalent to a rectangular grid. + * The vertices are organized into rows, which need not be geometrically linear. + * + *

+ * The verticals data in stream is similar to {@link PdfFreeFormGouraudShadedTriangleShading}, + * except there is no edge flag. + */ +public class PdfLatticeFormGouraudShadedTriangleShading extends AbstractPdfShadingMesh { + + /** + * Creates the new instance of the class from the existing {@link PdfStream}. + * + * @param pdfStream from which this {@link PdfLatticeFormGouraudShadedTriangleShading} will be created + */ + public PdfLatticeFormGouraudShadedTriangleShading(PdfStream pdfStream) { + super(pdfStream); + } + + /** + * Creates the new instance of the class. + * + * @param cs the {@link PdfColorSpace} object in which colour values shall be expressed. + * The special Pattern space isn't excepted + * @param bitsPerCoordinate the number of bits used to represent each vertex coordinate. + * The value shall be 1, 2, 4, 8, 12, 16, 24, or 32 + * @param bitsPerComponent the number of bits used to represent each colour component. + * The value shall be 1, 2, 4, 8, 12, or 16 + * @param verticesPerRow the number of vertices in each row of the lattice (shall be > 1). + * The number of rows need not be specified + * @param decode the {@code int[]} of numbers specifying how to map vertex coordinates and colour components + * into the appropriate ranges of values. The ranges shall be specified as follows: + * [x_min x_max y_min y_max c1_min c1_max … cn_min cn_max]. + * Only one pair of color values shall be specified if a Function entry is present + */ + public PdfLatticeFormGouraudShadedTriangleShading(PdfColorSpace cs, int bitsPerCoordinate, int bitsPerComponent, + int verticesPerRow, float[] decode) { + this(cs, bitsPerCoordinate, bitsPerComponent, verticesPerRow, new PdfArray(decode)); + } + + /** + * Creates the new instance of the class. + * + * @param cs the {@link PdfColorSpace} object in which colour values shall be expressed. + * The special Pattern space isn't excepted + * @param bitsPerCoordinate the number of bits used to represent each vertex coordinate. + * The value shall be 1, 2, 4, 8, 12, 16, 24, or 32 + * @param bitsPerComponent the number of bits used to represent each colour component. + * The value shall be 1, 2, 4, 8, 12, or 16 + * @param verticesPerRow the number of vertices in each row of the lattice (shall be > 1). + * The number of rows need not be specified + * @param decode the {@link PdfArray} of numbers specifying how to map vertex coordinates and colour components + * into the appropriate ranges of values. The ranges shall be specified as follows: + * [x_min x_max y_min y_max c1_min c1_max … cn_min cn_max]. + * Only one pair of color values shall be specified if a Function entry is present + */ + public PdfLatticeFormGouraudShadedTriangleShading(PdfColorSpace cs, int bitsPerCoordinate, int bitsPerComponent, + int verticesPerRow, PdfArray decode) { + super(new PdfStream(), ShadingType.LATTICE_FORM_GOURAUD_SHADED_TRIANGLE_MESH, cs); + + setBitsPerCoordinate(bitsPerCoordinate); + setBitsPerComponent(bitsPerComponent); + setVerticesPerRow(verticesPerRow); + setDecode(decode); + } + + /** + * Gets the number of vertices in each row of the lattice. + * + * @return the number of vertices. Can only be greater than 1 + */ + public int getVerticesPerRow() { + return (int) getPdfObject().getAsInt(PdfName.VerticesPerRow); + } + + /** + * Sets the number of vertices in each row of the lattice. + * The number of rows need not be specified. + * + * @param verticesPerRow the number of vertices to be set. Shall be greater than 1 + */ + public final void setVerticesPerRow(int verticesPerRow) { + getPdfObject().put(PdfName.VerticesPerRow, new PdfNumber(verticesPerRow)); + setModified(); + } +} \ No newline at end of file diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/colorspace/shading/PdfRadialShading.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/colorspace/shading/PdfRadialShading.java new file mode 100644 index 0000000000..f3b0e72af3 --- /dev/null +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/colorspace/shading/PdfRadialShading.java @@ -0,0 +1,143 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.pdf.colorspace.shading; + +import com.itextpdf.kernel.pdf.PdfArray; +import com.itextpdf.kernel.pdf.PdfDictionary; +import com.itextpdf.kernel.pdf.colorspace.PdfColorSpace; +import com.itextpdf.kernel.pdf.function.IPdfFunction; +import com.itextpdf.kernel.pdf.function.PdfType2Function; + +/** + * The class that extends {@link AbstractPdfShading} and {@link AbstractPdfShadingBlend} classes + * and is in charge of Shading Dictionary with radial type, that defines a colour blend that varies between two circles. + * + *

+ * This type of shading shall not be used with an Indexed colour space + */ +public class PdfRadialShading extends AbstractPdfShadingBlend { + + /** + * Creates the new instance of the class from the existing {@link PdfDictionary}. + * + * @param pdfDictionary from which this {@link PdfRadialShading} will be created + */ + public PdfRadialShading(PdfDictionary pdfDictionary) { + super(pdfDictionary); + } + + /** + * Creates the new instance of the class. + * + * @param cs the {@link PdfColorSpace} object in which colour values shall be expressed. + * The Indexed color space isn't excepted + * @param x0 the X coordinate of starting circle's centre, expressed in in the shading’s target coordinate space + * @param y0 the Y coordinate of starting circle's centre, expressed in in the shading’s target coordinate space + * @param r0 the radius of starting circle's centre, should be greater or equal to 0. + * If 0 then starting circle is treated as point. + * If both radii are 0, nothing shall be painted + * @param color0 the {@code float[]} that represents the color in the start circle + * @param x1 the X coordinate of ending circle's centre, expressed in in the shading’s target coordinate space + * @param y1 the Y coordinate of ending circle's centre, expressed in in the shading’s target coordinate space + * @param r1 the radius of ending circle's centre, should be greater or equal to 0. + * If 0 then ending circle is treated as point. + * If both radii are 0, nothing shall be painted + * @param color1 the {@code float[]} that represents the color in the end circle + */ + public PdfRadialShading(PdfColorSpace cs, float x0, float y0, float r0, float[] color0, float x1, float y1, + float r1, float[] color1) { + super(new PdfDictionary(), ShadingType.RADIAL, cs); + + setCoords(x0, y0, r0, x1, y1, r1); + IPdfFunction func = new PdfType2Function(new float[] {0, 1}, null, + color0, color1, 1); + setFunction(func); + } + + /** + * Creates the new instance of the class. + * + * @param cs the {@link PdfColorSpace} object in which colour values shall be expressed. + * The Indexed color space isn't excepted + * @param x0 the X coordinate of starting circle's centre, expressed in in the shading’s target coordinate space + * @param y0 the Y coordinate of starting circle's centre, expressed in in the shading’s target coordinate space + * @param r0 the radius of starting circle's centre, should be greater or equal to 0. + * If 0 then starting circle is treated as point. + * If both radii are 0, nothing shall be painted + * @param color0 the {@code float[]} that represents the color in the start circle + * @param x1 the X coordinate of ending circle's centre, expressed in in the shading’s target coordinate space + * @param y1 the Y coordinate of ending circle's centre, expressed in in the shading’s target coordinate space + * @param r1 the radius of ending circle's centre, should be greater or equal to 0. + * If 0 then ending circle is treated as point. + * If both radii are 0, nothing shall be painted + * @param color1 the {@code float[]} that represents the color in the end circle + * @param extend the array of two {@code boolean} that specified whether to extend the shading + * beyond the starting and ending points of the axis, respectively + */ + public PdfRadialShading(PdfColorSpace cs, float x0, float y0, float r0, float[] color0, float x1, float y1, float r1, + float[] color1, boolean[] extend) { + this(cs, x0, y0, r0, color0, x1, y1, r1, color1); + + if (extend == null || extend.length != 2) + throw new IllegalArgumentException("extend"); + + setExtend(extend[0], extend[1]); + } + + /** + * Creates the new instance of the class. + * + * @param cs the {@link PdfColorSpace} object in which colour values shall be expressed. + * The Indexed color space isn't excepted + * @param coords the {@link PdfArray} of of six numbers [x0 y0 r0 x1 y1 r1], + * specifying the centres and radii of the starting and ending circles, + * expressed in the shading’s target coordinate space. + * The radii r0 and r1 shall both be greater than or equal to 0. + * If one radius is 0, the corresponding circle shall be treated as a point; + * if both are 0, nothing shall be painted + * @param function the {@link IPdfFunction} object, that is used to calculate color transitions + */ + public PdfRadialShading(PdfColorSpace cs, PdfArray coords, IPdfFunction function) { + super(new PdfDictionary(), ShadingType.RADIAL, cs); + setCoords(coords); + setFunction(function); + } + + /** + * Sets the coords object. + * + * @param x0 the X coordinate of starting circle's centre, expressed in in the shading’s target coordinate space + * @param y0 the Y coordinate of starting circle's centre, expressed in in the shading’s target coordinate space + * @param r0 the radius of starting circle's centre, should be greater or equal to 0. + * If 0 then starting circle is treated as point. + * If both radii are 0, nothing shall be painted + * @param x1 the X coordinate of ending circle's centre, expressed in in the shading’s target coordinate space + * @param y1 the Y coordinate of ending circle's centre, expressed in in the shading’s target coordinate space + * @param r1 the radius of ending circle's centre, should be greater or equal to 0. + * If 0 then ending circle is treated as point. + * If both radii are 0, nothing shall be painted + */ + public final void setCoords(float x0, float y0, float r0, float x1, float y1, float r1) { + setCoords(new PdfArray(new float[] {x0, y0, r0, x1, y1, r1})); + } +} \ No newline at end of file diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/colorspace/shading/PdfTensorProductPatchShading.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/colorspace/shading/PdfTensorProductPatchShading.java new file mode 100644 index 0000000000..48f889daca --- /dev/null +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/colorspace/shading/PdfTensorProductPatchShading.java @@ -0,0 +1,102 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.pdf.colorspace.shading; + +import com.itextpdf.kernel.pdf.PdfArray; +import com.itextpdf.kernel.pdf.PdfStream; +import com.itextpdf.kernel.pdf.colorspace.PdfColorSpace; + +/** + * The class that extends {@link AbstractPdfShading}, {@link AbstractPdfShadingMesh} + * and {@link AbstractPdfShadingMeshWithFlags} classes and is in charge of Shading Dictionary + * with Tensor-Product Patch mesh type. + * + *

+ * This type of shading is identical to {@link PdfCoonsPatchShading}, except that it's based on a + * bicubic tensor-product patch defined by 16 control points. + * + *

+ * For the format of data stream, that defines patches, see ISO-320001 Table 86. + */ +public class PdfTensorProductPatchShading extends AbstractPdfShadingMeshWithFlags { + + /** + * Creates the new instance of the class from the existing {@link PdfStream}. + * + * @param pdfStream from which this {@link PdfTensorProductPatchShading} will be created + */ + public PdfTensorProductPatchShading(PdfStream pdfStream) { + super(pdfStream); + } + + /** + * Creates the new instance of the class. + * + * @param cs the {@link PdfColorSpace} object in which colour values shall be expressed. + * The special Pattern space isn't excepted + * @param bitsPerCoordinate the number of bits used to represent each vertex coordinate. + * The value shall be 1, 2, 4, 8, 12, 16, 24, or 32 + * @param bitsPerComponent the number of bits used to represent each colour component. + * The value shall be 1, 2, 4, 8, 12, or 16 + * @param bitsPerFlag the number of bits used to represent the edge flag for each vertex. + * The value of BitsPerFlag shall be 2, 4, or 8, + * but only the least significant 2 bits in each flag value shall be used. + * The value for the edge flag shall be 0, 1, 2 or 3 + * @param decode the {@code int[]} of numbers specifying how to map vertex coordinates and colour components + * into the appropriate ranges of values. The ranges shall be specified as follows: + * [x_min x_max y_min y_max c1_min c1_max … cn_min cn_max]. + * Only one pair of color values shall be specified if a Function entry is present + */ + public PdfTensorProductPatchShading(PdfColorSpace cs, int bitsPerCoordinate, int bitsPerComponent, + int bitsPerFlag, float[] decode) { + this(cs, bitsPerCoordinate, bitsPerComponent, bitsPerFlag, new PdfArray(decode)); + } + + /** + * Creates the new instance of the class. + * + * @param cs the {@link PdfColorSpace} object in which colour values shall be expressed. + * The special Pattern space isn't excepted + * @param bitsPerCoordinate the number of bits used to represent each vertex coordinate. + * The value shall be 1, 2, 4, 8, 12, 16, 24, or 32 + * @param bitsPerComponent the number of bits used to represent each colour component. + * The value shall be 1, 2, 4, 8, 12, or 16 + * @param bitsPerFlag the number of bits used to represent the edge flag for each vertex. + * The value of BitsPerFlag shall be 2, 4, or 8, + * but only the least significant 2 bits in each flag value shall be used. + * The value for the edge flag shall be 0, 1, 2 or 3 + * @param decode the {@link PdfArray} of numbers specifying how to map vertex coordinates and colour components + * into the appropriate ranges of values. The ranges shall be specified as follows: + * [x_min x_max y_min y_max c1_min c1_max … cn_min cn_max]. + * Only one pair of color values shall be specified if a Function entry is present + */ + public PdfTensorProductPatchShading(PdfColorSpace cs, int bitsPerCoordinate, int bitsPerComponent, + int bitsPerFlag, PdfArray decode) { + super(new PdfStream(), ShadingType.TENSOR_PRODUCT_PATCH_MESH, cs); + + setBitsPerCoordinate(bitsPerCoordinate); + setBitsPerComponent(bitsPerComponent); + setBitsPerFlag(bitsPerFlag); + setDecode(decode); + } +} \ No newline at end of file diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/colorspace/shading/ShadingType.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/colorspace/shading/ShadingType.java new file mode 100644 index 0000000000..57f728015e --- /dev/null +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/colorspace/shading/ShadingType.java @@ -0,0 +1,62 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.pdf.colorspace.shading; + +/** + * The constants of shading type (see ISO-320001 Table 78). + */ +public final class ShadingType { + + /** + * The int value of function-based shading type + */ + public static final int FUNCTION_BASED = 1; + /** + * The int value of axial shading type + */ + public static final int AXIAL = 2; + /** + * The int value of radial shading type + */ + public static final int RADIAL = 3; + /** + * The int value of free-form Gouraud-shaded triangle mesh shading type + */ + public static final int FREE_FORM_GOURAUD_SHADED_TRIANGLE_MESH = 4; + /** + * The int value of lattice-form Gouraud-shaded triangle mesh shading type + */ + public static final int LATTICE_FORM_GOURAUD_SHADED_TRIANGLE_MESH = 5; + /** + * The int value of coons patch meshes shading type + */ + public static final int COONS_PATCH_MESH = 6; + /** + * The int value of tensor-product patch meshes shading type + */ + public static final int TENSOR_PRODUCT_PATCH_MESH = 7; + + private ShadingType() { + } + +} \ No newline at end of file diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/event/AbstractPdfDocumentEvent.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/event/AbstractPdfDocumentEvent.java new file mode 100644 index 0000000000..29222f6740 --- /dev/null +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/event/AbstractPdfDocumentEvent.java @@ -0,0 +1,80 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.pdf.event; + +import com.itextpdf.commons.actions.IEvent; +import com.itextpdf.kernel.pdf.PdfDocument; + +/** + * Describes abstract PDF document event of the specified type. + * + *

+ * Use {@link PdfDocument#dispatchEvent(AbstractPdfDocumentEvent)} to fire an event + * and {@link PdfDocument#addEventHandler(String, AbstractPdfDocumentEventHandler)} + * to register {@link AbstractPdfDocumentEventHandler} handler for that type of event. + */ +public abstract class AbstractPdfDocumentEvent implements IEvent { + + /** A type of event. */ + protected String type; + private PdfDocument document; + + /** + * Creates an event of the specified type. + * + * @param type the type of event + */ + protected AbstractPdfDocumentEvent(String type) { + this.type = type; + } + + /** + * Returns the type of this event. + * + * @return type of this event + */ + public String getType() { + return type; + } + + /** + * Retrieves the document associated with this event. + * + * @return {@link PdfDocument} that triggered this event + */ + public PdfDocument getDocument() { + return document; + } + + /** + * Sets the document associated with this event. + * + * @param document {@link PdfDocument} that triggered this event + * + * @return this {@link AbstractPdfDocumentEvent} instance + */ + public AbstractPdfDocumentEvent setDocument(PdfDocument document) { + this.document = document; + return this; + } +} diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/event/AbstractPdfDocumentEventHandler.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/event/AbstractPdfDocumentEventHandler.java new file mode 100644 index 0000000000..42b2d021b5 --- /dev/null +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/event/AbstractPdfDocumentEventHandler.java @@ -0,0 +1,82 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.pdf.event; + +import com.itextpdf.commons.actions.IEvent; +import com.itextpdf.commons.actions.IEventHandler; +import com.itextpdf.kernel.pdf.PdfDocument; + +import java.util.HashSet; +import java.util.Set; + +/** + * Base class for PDF document events handling based on the event type. + * + *

+ * Handles {@link AbstractPdfDocumentEvent} event fired by {@link PdfDocument#dispatchEvent(AbstractPdfDocumentEvent)}. + * Use {@link PdfDocument#addEventHandler(String, AbstractPdfDocumentEventHandler)} to register this handler for + * specific type of event. + */ +public abstract class AbstractPdfDocumentEventHandler implements IEventHandler { + private final Set types = new HashSet<>(); + + /** + * Creates new {@link AbstractPdfDocumentEventHandler} instance. + * + *

+ * By default, this instance handles all types of the {@link AbstractPdfDocumentEvent} events. For specific types + * handling, use {@link #addType(String)} method. + */ + protected AbstractPdfDocumentEventHandler() { + } + + /** + * Adds new event type to handle by this {@link AbstractPdfDocumentEventHandler} instance. + * + * @param type the {@link AbstractPdfDocumentEvent} type to handle + * + * @return this {@link AbstractPdfDocumentEventHandler} instance + */ + public AbstractPdfDocumentEventHandler addType(String type) { + this.types.add(type); + return this; + } + + @Override + public void onEvent(IEvent event) { + if (!(event instanceof AbstractPdfDocumentEvent)) { + return; + } + final AbstractPdfDocumentEvent iTextEvent = (AbstractPdfDocumentEvent) event; + if (types.isEmpty() || types.contains(iTextEvent.getType())) { + onAcceptedEvent(iTextEvent); + } + } + + /** + * Handles the accepted event. + * + * @param event {@link AbstractPdfDocumentEvent} to handle + */ + protected abstract void onAcceptedEvent(AbstractPdfDocumentEvent event); +} diff --git a/kernel/src/main/java/com/itextpdf/kernel/events/PdfDocumentEvent.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/event/PdfDocumentEvent.java similarity index 80% rename from kernel/src/main/java/com/itextpdf/kernel/events/PdfDocumentEvent.java rename to kernel/src/main/java/com/itextpdf/kernel/pdf/event/PdfDocumentEvent.java index 91c67241ae..37c4578445 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/events/PdfDocumentEvent.java +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/event/PdfDocumentEvent.java @@ -20,15 +20,14 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.kernel.events; +package com.itextpdf.kernel.pdf.event; -import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfPage; /** * Event dispatched by PdfDocument. */ -public class PdfDocumentEvent extends Event { +public class PdfDocumentEvent extends AbstractPdfDocumentEvent { /** * Dispatched after page is created. @@ -53,24 +52,26 @@ public class PdfDocumentEvent extends Event { public static final String END_PAGE = "EndPdfPage"; /** - * The PdfPage associated with this event. + * Dispatched before writer is closed. */ - protected PdfPage page; + public static final String START_WRITER_CLOSING = "StartWriterClosing"; + /** + * Dispatched after writer is flushed to a document. + */ + public static final String START_DOCUMENT_CLOSING = "StartDocumentClosing"; /** - * The PdfDocument associated with this event. + * The PdfPage associated with this event. */ - private PdfDocument document; + protected PdfPage page; /** * Creates a PdfDocumentEvent. * * @param type type of the event that fired this event - * @param document document that fired this event */ - public PdfDocumentEvent(String type, PdfDocument document) { + public PdfDocumentEvent(String type) { super(type); - this.document = document; } /** @@ -82,16 +83,6 @@ public PdfDocumentEvent(String type, PdfDocument document) { public PdfDocumentEvent(String type, PdfPage page) { super(type); this.page = page; - this.document = page.getDocument(); - } - - /** - * Returns the PdfDocument associated with this event. - * - * @return the PdfDocument associated with this event - */ - public PdfDocument getDocument() { - return document; } /** diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/extgstate/PdfExtGState.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/extgstate/PdfExtGState.java index 8417c92e84..9d25e0f077 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/pdf/extgstate/PdfExtGState.java +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/extgstate/PdfExtGState.java @@ -43,68 +43,68 @@ public class PdfExtGState extends PdfObjectWrapper { /** * Standard separable blend mode. See ISO-320001, table 136 */ - public static PdfName BM_NORMAL = PdfName.Normal; + public static final PdfName BM_NORMAL = PdfName.Normal; /** * Standard separable blend mode. See ISO-320001, table 136 */ - public static PdfName BM_MULTIPLY = PdfName.Multiply; + public static final PdfName BM_MULTIPLY = PdfName.Multiply; /** * Standard separable blend mode. See ISO-320001, table 136 */ - public static PdfName BM_SCREEN = PdfName.Screen; + public static final PdfName BM_SCREEN = PdfName.Screen; /** * Standard separable blend mode. See ISO-320001, table 136 */ - public static PdfName BM_OVERLAY = PdfName.Overlay; + public static final PdfName BM_OVERLAY = PdfName.Overlay; /** * Standard separable blend mode. See ISO-320001, table 136 */ - public static PdfName BM_DARKEN = PdfName.Darken; + public static final PdfName BM_DARKEN = PdfName.Darken; /** * Standard separable blend mode. See ISO-320001, table 136 */ - public static PdfName BM_LIGHTEN = PdfName.Lighten; + public static final PdfName BM_LIGHTEN = PdfName.Lighten; /** * Standard separable blend mode. See ISO-320001, table 136 */ - public static PdfName BM_COLOR_DODGE = PdfName.ColorDodge; + public static final PdfName BM_COLOR_DODGE = PdfName.ColorDodge; /** * Standard separable blend mode. See ISO-320001, table 136 */ - public static PdfName BM_COLOR_BURN = PdfName.ColorBurn; + public static final PdfName BM_COLOR_BURN = PdfName.ColorBurn; /** * Standard separable blend mode. See ISO-320001, table 136 */ - public static PdfName BM_HARD_LIGHT = PdfName.HardLight; + public static final PdfName BM_HARD_LIGHT = PdfName.HardLight; /** * Standard separable blend mode. See ISO-320001, table 136 */ - public static PdfName BM_SOFT_LIGHT = PdfName.SoftLight; + public static final PdfName BM_SOFT_LIGHT = PdfName.SoftLight; /** * Standard separable blend mode. See ISO-320001, table 136 */ - public static PdfName BM_DIFFERENCE = PdfName.Difference; + public static final PdfName BM_DIFFERENCE = PdfName.Difference; /** * Standard separable blend mode. See ISO-320001, table 136 */ - public static PdfName BM_EXCLUSION = PdfName.Exclusion; + public static final PdfName BM_EXCLUSION = PdfName.Exclusion; /** * Standard nonseparable blend mode. See ISO-320001, table 137 */ - public static PdfName BM_HUE = PdfName.Hue; + public static final PdfName BM_HUE = PdfName.Hue; /** * Standard nonseparable blend mode. See ISO-320001, table 137 */ - public static PdfName BM_SATURATION = PdfName.Saturation; + public static final PdfName BM_SATURATION = PdfName.Saturation; /** * Standard nonseparable blend mode. See ISO-320001, table 137 */ - public static PdfName BM_COLOR = PdfName.Color; + public static final PdfName BM_COLOR = PdfName.Color; /** * Standard nonseparable blend mode. See ISO-320001, table 137 */ - public static PdfName BM_LUMINOSITY = PdfName.Luminosity; + public static final PdfName BM_LUMINOSITY = PdfName.Luminosity; /** * Create instance of graphics state parameter dictionary wrapper @@ -690,9 +690,9 @@ public PdfExtGState setUseBlackPointCompensation(boolean useBlackPointCompensati public Boolean isBlackPointCompensationUsed() { PdfName useBlackPointCompensation = getPdfObject().getAsName(PdfName.UseBlackPtComp); if (PdfName.ON.equals(useBlackPointCompensation)) { - return true; + return Boolean.TRUE; } else if (PdfName.OFF.equals(useBlackPointCompensation)) { - return false; + return Boolean.FALSE; } else { return null; } diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/filters/DoNothingFilter.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/filters/DoNothingFilter.java index 6c8fef1f1a..7c311cee64 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/pdf/filters/DoNothingFilter.java +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/filters/DoNothingFilter.java @@ -31,11 +31,9 @@ This file is part of the iText (R) project. * A filter that doesn't modify the stream at all */ public class DoNothingFilter implements IFilterHandler { - private PdfName lastFilterName; @Override public byte[] decode(byte[] b, PdfName filterName, PdfObject decodeParams, PdfDictionary streamDictionary) { - lastFilterName = filterName; return b; } } diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/layer/PdfLayer.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/layer/PdfLayer.java index 7f985706fd..18fa04c385 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/pdf/layer/PdfLayer.java +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/layer/PdfLayer.java @@ -22,7 +22,10 @@ This file is part of the iText (R) project. */ package com.itextpdf.kernel.pdf.layer; +import com.itextpdf.commons.utils.MessageFormatUtil; import com.itextpdf.io.font.PdfEncodings; +import com.itextpdf.kernel.exceptions.KernelExceptionMessageConstant; +import com.itextpdf.kernel.exceptions.PdfException; import com.itextpdf.kernel.pdf.PdfArray; import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.kernel.pdf.PdfDocument; @@ -118,11 +121,18 @@ public static void addOCGRadioGroup(PdfDocument document, List group) * @param childLayer the child layer */ public void addChild(PdfLayer childLayer) { - if (childLayer.parent != null) - throw new IllegalArgumentException("Illegal argument: childLayer"); + //TODO DEVSIX-8490 implement multiple parent support + if (childLayer.parent != null) { + PdfIndirectReference ref = childLayer.getIndirectReference(); + throw new PdfException(MessageFormatUtil.format( + KernelExceptionMessageConstant.UNABLE_TO_ADD_SECOND_PARENT_LAYER, ref.toString())); + } + childLayer.parent = this; - if (children == null) + if (children == null) { children = new ArrayList<>(); + } + children.add(childLayer); } diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/layer/PdfOCProperties.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/layer/PdfOCProperties.java index c62dfcdbde..5c53e5175b 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/pdf/layer/PdfOCProperties.java +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/layer/PdfOCProperties.java @@ -24,10 +24,17 @@ This file is part of the iText (R) project. import com.itextpdf.commons.utils.MessageFormatUtil; import com.itextpdf.io.font.PdfEncodings; +import com.itextpdf.kernel.exceptions.KernelExceptionMessageConstant; +import com.itextpdf.kernel.exceptions.PdfException; import com.itextpdf.kernel.logs.KernelLogMessageConstant; -import com.itextpdf.kernel.pdf.*; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import com.itextpdf.kernel.pdf.PdfArray; +import com.itextpdf.kernel.pdf.PdfDictionary; +import com.itextpdf.kernel.pdf.PdfDocument; +import com.itextpdf.kernel.pdf.PdfIndirectReference; +import com.itextpdf.kernel.pdf.PdfName; +import com.itextpdf.kernel.pdf.PdfObject; +import com.itextpdf.kernel.pdf.PdfObjectWrapper; +import com.itextpdf.kernel.pdf.PdfString; import java.util.ArrayList; import java.util.HashSet; @@ -35,6 +42,8 @@ This file is part of the iText (R) project. import java.util.Map; import java.util.Set; import java.util.TreeMap; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * This class represents /OCProperties entry if pdf catalog and manages @@ -49,6 +58,12 @@ public class PdfOCProperties extends PdfObjectWrapper { private List layers = new ArrayList<>(); + //TODO DEVSIX-8490 remove this field when implemented + private Set references; + + //TODO DEVSIX-8490 remove this field when implemented + private boolean isDuplicateRemoved; + /** * Creates a new PdfOCProperties instance. * @@ -395,8 +410,17 @@ private void readLayersFromDictionary() { } PdfArray orderArray = d.getAsArray(PdfName.Order); - if (orderArray != null && !orderArray.isEmpty()) + if (orderArray != null && !orderArray.isEmpty()) { + references = new HashSet<>(); + isDuplicateRemoved = false; readOrderFromDictionary(null, orderArray, layerMap); + //TODO DEVSIX-8490 remove this check when implemented + if (isDuplicateRemoved) { + Logger logger = LoggerFactory.getLogger(PdfOCProperties.class); + logger.warn(KernelLogMessageConstant.DUPLICATE_ENTRIES_IN_ORDER_ARRAY_REMOVED); + } + } + } // Add the layers which should not be displayed on the panel to the order list @@ -414,7 +438,27 @@ private void readOrderFromDictionary(PdfLayer parent, PdfArray orderArray, Map

0 && nextArray.get(0).getType() != PdfObject.STRING) { + PdfIndirectReference ref = layer.getIndirectReference(); + throw new PdfException(MessageFormatUtil.format( + KernelExceptionMessageConstant.UNABLE_TO_REMOVE_DUPLICATE_LAYER + , ref.toString())); + } + } + + isDuplicateRemoved = true; + } else { + references.add(layer.getIndirectReference()); layers.add(layer); layer.onPanel = true; if (parent != null) diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/tagging/McrCheckUtil.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/tagging/McrCheckUtil.java index 1d54b7a6ae..5f1ce3f7e7 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/pdf/tagging/McrCheckUtil.java +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/tagging/McrCheckUtil.java @@ -74,11 +74,13 @@ public McrTagHandler() { //empty constructor } - /** - * {@inheritDoc} - */ @Override - public void nextElement(IStructureNode elem) { + public boolean accept(IStructureNode node) { + return node != null; + } + + @Override + public void processElement(IStructureNode elem) { if ((elem instanceof PdfMcr)) { haveMcr = true; } diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/tagging/ParentTreeHandler.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/tagging/ParentTreeHandler.java index a5036d098d..175ee39a88 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/pdf/tagging/ParentTreeHandler.java +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/tagging/ParentTreeHandler.java @@ -26,7 +26,6 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.exceptions.KernelExceptionMessageConstant; import com.itextpdf.kernel.exceptions.PdfException; import com.itextpdf.kernel.logs.KernelLogMessageConstant; -import com.itextpdf.kernel.pdf.IsoKey; import com.itextpdf.kernel.pdf.PdfArray; import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.kernel.pdf.PdfIndirectReference; @@ -38,6 +37,7 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfPage; import com.itextpdf.kernel.pdf.PdfReader; import com.itextpdf.kernel.pdf.PdfStream; +import com.itextpdf.kernel.validation.context.TagStructElementValidationContext; import java.util.ArrayList; import java.util.Collection; @@ -375,7 +375,7 @@ private boolean updateStructParentTreeForContentStreamEntries(Map pdfDoc.checkIsoConformance(key, IsoKey.DUPLICATE_ID_ENTRY)); + super.addEntry(key, value, pdfDoc -> pdfDoc.checkIsoConformance(new DuplicateIdEntryValidationContext(key))); } } diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/tagging/PdfStructTreeRoot.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/tagging/PdfStructTreeRoot.java index f10a4d0484..e6eaf043c7 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/pdf/tagging/PdfStructTreeRoot.java +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/tagging/PdfStructTreeRoot.java @@ -47,7 +47,6 @@ This file is part of the iText (R) project. import java.util.concurrent.ConcurrentHashMap; import com.itextpdf.kernel.pdf.tagutils.TagTreeIterator; -import com.itextpdf.kernel.pdf.tagutils.TagTreeIteratorAvoidDuplicatesApprover; import com.itextpdf.kernel.pdf.tagutils.TagTreeIteratorFlusher; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -322,19 +321,6 @@ public PdfMcr findMcrByMcid(PdfDictionary pageDict, int mcid) { return getParentTreeHandler().findMcrByMcid(pageDict, mcid); } - - public PdfMcr findMcrByMcid(PdfDocument document, int mcid) { - int amountOfPages = document.getNumberOfPages(); - for (int i = 1; i <= amountOfPages; ++i) { - PdfPage page = document.getPage(i); - PdfMcr mcr = findMcrByMcid(page.getPdfObject(), mcid); - if (mcr != null) { - return mcr; - } - } - return null; - } - public PdfObjRef findObjRefByStructParentIndex(PdfDictionary pageDict, int structParentIndex) { return getParentTreeHandler().findObjRefByStructParentIndex(pageDict, structParentIndex); } @@ -526,8 +512,7 @@ protected boolean isWrappedObjectMustBeIndirect() { } private static void flushAllKids(PdfStructTreeRoot elem) { - TagTreeIterator iterator = new TagTreeIterator( - elem, new TagTreeIteratorAvoidDuplicatesApprover(), TagTreeIterator.TreeTraversalOrder.POST_ORDER); + TagTreeIterator iterator = new TagTreeIterator(elem, TagTreeIterator.TreeTraversalOrder.POST_ORDER); iterator.addHandler(new TagTreeIteratorFlusher()); iterator.traverse(); } diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/tagging/StructureTreeCopier.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/tagging/StructureTreeCopier.java index d0fab95326..4d4f618825 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/pdf/tagging/StructureTreeCopier.java +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/tagging/StructureTreeCopier.java @@ -43,6 +43,8 @@ This file is part of the iText (R) project. import java.util.List; import java.util.Map; import java.util.Set; + +import com.itextpdf.kernel.pdf.tagutils.TagTreeIterator; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -629,11 +631,14 @@ private static PdfDictionary getTopmostParent(PdfMcr mcr) { } private static List retrieveParents(PdfMcr mcr, boolean all) { - List parents = new ArrayList<>(); - IStructureNode firstParent = mcr.getParent(); + final Set parents = new LinkedHashSet<>(); + final IStructureNode firstParent = mcr.getParent(); PdfDictionary previous = null; PdfDictionary current = firstParent instanceof PdfStructElem ? ((PdfStructElem) firstParent).getPdfObject() : null; - while (current != null && !PdfName.StructTreeRoot.equals(current.getAsName(PdfName.Type))) { + + while (current != null + && !PdfName.StructTreeRoot.equals(current.getAsName(PdfName.Type)) + && !parents.contains(current)) { if (all) { parents.add(current); } @@ -643,7 +648,7 @@ private static List retrieveParents(PdfMcr mcr, boolean all) { if (!all) { parents.add(previous); } - return parents; + return new ArrayList<>(parents); } static class LastClonedAncestor { diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/tagutils/TagTreeIteratorAvoidDuplicatesApprover.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/tagutils/AbstractAvoidDuplicatesTagTreeIteratorHandler.java similarity index 64% rename from kernel/src/main/java/com/itextpdf/kernel/pdf/tagutils/TagTreeIteratorAvoidDuplicatesApprover.java rename to kernel/src/main/java/com/itextpdf/kernel/pdf/tagutils/AbstractAvoidDuplicatesTagTreeIteratorHandler.java index 533c0f15d2..236fab6954 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/pdf/tagutils/TagTreeIteratorAvoidDuplicatesApprover.java +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/tagutils/AbstractAvoidDuplicatesTagTreeIteratorHandler.java @@ -31,40 +31,28 @@ This file is part of the iText (R) project. import java.util.Set; /** - * Element checker for {@link TagTreeIterator}. + * Handler for {@link TagTreeIterator}. * It is used to check whether specific element should be traversed. - * It doesn't approve elements which have been traversed before. + * It doesn't accept elements which have been traversed before. */ -public class TagTreeIteratorAvoidDuplicatesApprover extends TagTreeIteratorElementApprover { +public abstract class AbstractAvoidDuplicatesTagTreeIteratorHandler implements ITagTreeIteratorHandler { private final Set processedObjects = new HashSet<>(); - /** - * Creates a new instance of {@link TagTreeIteratorAvoidDuplicatesApprover} - */ - public TagTreeIteratorAvoidDuplicatesApprover() { - super(); - } - - /** - * {@inheritDoc} - */ @Override - public boolean approve(IStructureNode elem) { - if (elem instanceof PdfStructTreeRoot) { + public boolean accept(IStructureNode node) { + if (node instanceof PdfStructTreeRoot) { return true; - } - - if (!super.approve(elem) || !(elem instanceof PdfStructElem)) { - return false; - } - - PdfObject obj = ((PdfStructElem) elem).getPdfObject(); - final boolean isProcessed = processedObjects.contains(obj); - if (isProcessed) { + } else if (!(node instanceof PdfStructElem)) { return false; } else { - processedObjects.add(obj); - return true; + PdfObject obj = ((PdfStructElem) node).getPdfObject(); + final boolean isProcessed = processedObjects.contains(obj); + if (isProcessed) { + return false; + } else { + processedObjects.add(obj); + return true; + } } } } diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/tagutils/ITagTreeIteratorHandler.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/tagutils/ITagTreeIteratorHandler.java index e407defeea..f14b2a0391 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/pdf/tagutils/ITagTreeIteratorHandler.java +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/tagutils/ITagTreeIteratorHandler.java @@ -31,9 +31,18 @@ This file is part of the iText (R) project. public interface ITagTreeIteratorHandler { /** - * Called when the next element is reached during the traversal. + * Checks whether the element should be traversed. * - * @param elem the next element + * @param node the element to check + * + * @return {@code true} if the iteration should be continued, {@code false} otherwise + */ + boolean accept(IStructureNode node); + + /** + * Called when the next element is reached during the traversal to process it. + * + * @param elem the element to process */ - void nextElement(IStructureNode elem); + void processElement(IStructureNode elem); } diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/tagutils/RootTagNormalizer.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/tagutils/RootTagNormalizer.java index aefb7cc2bb..e4103ef2f7 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/pdf/tagutils/RootTagNormalizer.java +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/tagutils/RootTagNormalizer.java @@ -110,8 +110,9 @@ private void addStructTreeRootKidsToTheRootTag(List rootKids) { // This boolean is used to "flatten" possible deep "stacking" of the tag structure in case of the multiple pages copying operations. // This could happen due to the wrapping of all the kids in the createNewRootTag or ensureExistingRootTagIsDocument methods. - // And therefore, we don't need here to resolve mappings, because we exactly know which role we set. - boolean kidIsDocument = PdfName.Document.equals(kid.getRole()); + IRoleMappingResolver mapping = kid.getRole() == null ? null + : context.resolveMappingToStandardOrDomainSpecificRole(kid.getRole().getValue(), rootTagElement.getNamespace()); + boolean kidIsDocument = mapping != null && mapping.currentRoleIsStandard() && StandardRoles.DOCUMENT.equals(mapping.getRole()); if (kidIsDocument && kid.getNamespace() != null && context.targetTagStructureVersionIs2()) { // we flatten only tags of document role in standard structure namespace String kidNamespaceName = kid.getNamespace().getNamespaceName(); diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/tagutils/TagTreeIterator.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/tagutils/TagTreeIterator.java index 7d14c2489e..80d32f3a41 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/pdf/tagutils/TagTreeIterator.java +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/tagutils/TagTreeIterator.java @@ -42,38 +42,28 @@ public class TagTreeIterator { private final Set handlerList; - private final TagTreeIteratorElementApprover approver; - private final TreeTraversalOrder traversalOrder; /** - * Creates a new instance of {@link TagTreeIterator}. It will use {@link TagTreeIteratorElementApprover} to filter - * elements and TreeTraversalOrder.PRE_ORDER for tree traversal. + * Creates a new instance of {@link TagTreeIterator}. It will use TreeTraversalOrder.PRE_ORDER for tree traversal. * * @param tagTreePointer the tag tree pointer. */ public TagTreeIterator(IStructureNode tagTreePointer) { - this(tagTreePointer, new TagTreeIteratorElementApprover(), TreeTraversalOrder.PRE_ORDER); + this(tagTreePointer, TreeTraversalOrder.PRE_ORDER); } /** * Creates a new instance of {@link TagTreeIterator}. * - * @param tagTreePointer the tag tree pointer. - * @param approver a filter that will be called to let iterator know whether some particular element - * should be traversed or not. + * @param tagTreePointer the tag tree pointer * @param traversalOrder an order in which the tree will be traversed. */ - public TagTreeIterator(IStructureNode tagTreePointer, TagTreeIteratorElementApprover approver, - TreeTraversalOrder traversalOrder) { + public TagTreeIterator(IStructureNode tagTreePointer, TreeTraversalOrder traversalOrder) { if (tagTreePointer == null) { throw new IllegalArgumentException( MessageFormatUtil.format(KernelExceptionMessageConstant.ARG_SHOULD_NOT_BE_NULL, "tagTreepointer")); } - if (approver == null) { - throw new IllegalArgumentException( - MessageFormatUtil.format(KernelExceptionMessageConstant.ARG_SHOULD_NOT_BE_NULL, "approver")); - } if (traversalOrder == null) { throw new IllegalArgumentException( MessageFormatUtil.format(KernelExceptionMessageConstant.ARG_SHOULD_NOT_BE_NULL, "traversalOrder")); @@ -81,7 +71,6 @@ public TagTreeIterator(IStructureNode tagTreePointer, TagTreeIteratorElementAppr this.pointer = tagTreePointer; this.traversalOrder = traversalOrder; handlerList = new HashSet<>(); - this.approver = approver; } /** @@ -111,13 +100,15 @@ public void traverse() { } private void traverse(IStructureNode elem) { - if (!approver.approve(elem)) { - return; + for (ITagTreeIteratorHandler handler : handlerList) { + if (!handler.accept(elem)) { + return; + } } if (traversalOrder == TreeTraversalOrder.PRE_ORDER) { for (ITagTreeIteratorHandler handler : handlerList) { - handler.nextElement(elem); + handler.processElement(elem); } } @@ -130,7 +121,7 @@ private void traverse(IStructureNode elem) { if (traversalOrder == TreeTraversalOrder.POST_ORDER) { for (ITagTreeIteratorHandler handler : handlerList) { - handler.nextElement(elem); + handler.processElement(elem); } } } diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/tagutils/TagTreeIteratorFlusher.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/tagutils/TagTreeIteratorFlusher.java index 4937d733ec..9bc09f76ce 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/pdf/tagutils/TagTreeIteratorFlusher.java +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/tagutils/TagTreeIteratorFlusher.java @@ -22,26 +22,51 @@ This file is part of the iText (R) project. */ package com.itextpdf.kernel.pdf.tagutils; +import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.kernel.pdf.tagging.IStructureNode; import com.itextpdf.kernel.pdf.tagging.PdfStructElem; +import java.util.Set; + /** * Class that flushes struct elements while iterating over struct tree root with {@link TagTreeIterator}. */ -public class TagTreeIteratorFlusher implements ITagTreeIteratorHandler { +public class TagTreeIteratorFlusher extends AbstractAvoidDuplicatesTagTreeIteratorHandler { + + private Set waitingTags; + private boolean waitingTagsUsed = false; /** - * Creates a new instance of {@link TagTreeIteratorFlusher} + * Creates a new instance of {@link TagTreeIteratorFlusher}. */ public TagTreeIteratorFlusher() { // Empty constructor } /** - * {@inheritDoc} + * Sets waiting tags for {@link TagTreeIteratorFlusher}. + * + * @param waitingTags waiting tags to set + * + * @return this same {@link TagTreeIteratorFlusher} instance */ + public ITagTreeIteratorHandler setWaitingTags(Set waitingTags) { + this.waitingTags = waitingTags; + this.waitingTagsUsed = true; + return this; + } + + @Override + public boolean accept(IStructureNode node) { + if (waitingTagsUsed) { + return super.accept(node) && node instanceof PdfStructElem && + (waitingTags == null || !waitingTags.contains(((PdfStructElem) node).getPdfObject())); + } + return super.accept(node); + } + @Override - public void nextElement(IStructureNode elem) { + public void processElement(IStructureNode elem) { if (elem instanceof PdfStructElem && !((PdfStructElem) elem).isFlushed()) { ((PdfStructElem) elem).flush(); } diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/tagutils/TagTreePointer.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/tagutils/TagTreePointer.java index e64c460062..d9f07119a9 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/pdf/tagutils/TagTreePointer.java +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/tagutils/TagTreePointer.java @@ -528,8 +528,7 @@ public TagTreePointer moveToKid(int n, String role) { } RoleFinderHandler handler = new RoleFinderHandler(n, role); - TagTreeIteratorApproverWithStop approver = new TagTreeIteratorApproverWithStop(handler); - TagTreeIterator iterator = new TagTreeIterator(getCurrentStructElem(), approver, + TagTreeIterator iterator = new TagTreeIterator(getCurrentStructElem(), TagTreeIterator.TreeTraversalOrder.PRE_ORDER); iterator.addHandler(handler); @@ -837,7 +836,7 @@ private void throwExceptionIfCurrentPageIsNotInited() { } } - private static class RoleFinderHandler implements ITagTreeIteratorHandler { + private static class RoleFinderHandler extends AbstractAvoidDuplicatesTagTreeIteratorHandler { private final int n; private final String role; private int foundIdx = 0; @@ -848,8 +847,17 @@ private static class RoleFinderHandler implements ITagTreeIteratorHandler { this.role = role; } + public PdfStructElem getFoundElement() { + return foundElem; + } + + @Override + public boolean accept(IStructureNode node) { + return getFoundElement() == null && super.accept(node); + } + @Override - public void nextElement(IStructureNode elem) { + public void processElement(IStructureNode elem) { if (foundElem != null) { return; } @@ -859,27 +867,5 @@ public void nextElement(IStructureNode elem) { foundElem = (PdfStructElem) elem; } } - - public PdfStructElem getFoundElement() { - return foundElem; - } - } - - /** - * @deprecated change ITagTreeIteratorHandler#nextElement to return boolean - * showing whether the iteration should be continued. It will allow to get rid of this ugly workaround. - */ - @Deprecated - private static class TagTreeIteratorApproverWithStop extends TagTreeIteratorAvoidDuplicatesApprover { - private final RoleFinderHandler handler; - public TagTreeIteratorApproverWithStop(RoleFinderHandler handler) { - super(); - this.handler = handler; - } - - @Override - public boolean approve(IStructureNode elem) { - return super.approve(elem) && handler.getFoundElement() == null; - } } } diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/tagutils/WaitingTagsManager.java b/kernel/src/main/java/com/itextpdf/kernel/pdf/tagutils/WaitingTagsManager.java index 100b844992..933aaf492a 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/pdf/tagutils/WaitingTagsManager.java +++ b/kernel/src/main/java/com/itextpdf/kernel/pdf/tagutils/WaitingTagsManager.java @@ -28,7 +28,6 @@ This file is part of the iText (R) project. import java.util.HashMap; import java.util.Map; -import java.util.Set; /** * This class is used to manage waiting tags state. @@ -42,8 +41,8 @@ This file is part of the iText (R) project. */ public class WaitingTagsManager { - private Map associatedObjToWaitingTag; - private Map waitingTagToAssociatedObj; + private final Map associatedObjToWaitingTag; + private final Map waitingTagToAssociatedObj; WaitingTagsManager() { associatedObjToWaitingTag = new HashMap<>(); @@ -170,10 +169,8 @@ private void flushStructElementAndItKids(PdfStructElem elem) { return; } - TagTreeIterator iterator = new TagTreeIterator(elem, - new WaitingTagsApprover(waitingTagToAssociatedObj.keySet()), - TagTreeIterator.TreeTraversalOrder.POST_ORDER); - iterator.addHandler(new TagTreeIteratorFlusher()); + TagTreeIterator iterator = new TagTreeIterator(elem, TagTreeIterator.TreeTraversalOrder.POST_ORDER); + iterator.addHandler(new TagTreeIteratorFlusher().setWaitingTags(waitingTagToAssociatedObj.keySet())); iterator.traverse(); } @@ -186,18 +183,4 @@ private void removeWaitingStateAndFlushIfParentFlushed(PdfStructElem structElem) } } } - - private static class WaitingTagsApprover extends TagTreeIteratorAvoidDuplicatesApprover { - private final Set waitingTags; - public WaitingTagsApprover(Set waitingTags) { - super(); - this.waitingTags = waitingTags; - } - - @Override - public boolean approve(IStructureNode elem) { - return super.approve(elem) && elem instanceof PdfStructElem && - (waitingTags == null || !waitingTags.contains(((PdfStructElem) elem).getPdfObject())); - } - } } diff --git a/kernel/src/main/java/com/itextpdf/kernel/utils/CompareTool.java b/kernel/src/main/java/com/itextpdf/kernel/utils/CompareTool.java index 44fd19ced5..6896d463b8 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/utils/CompareTool.java +++ b/kernel/src/main/java/com/itextpdf/kernel/utils/CompareTool.java @@ -74,6 +74,7 @@ This file is part of the iText (R) project. import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; +import java.util.HashSet; import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.LinkedList; @@ -138,6 +139,7 @@ public class CompareTool { private boolean generateCompareByContentXmlReport = false; private boolean encryptionCompareEnabled = false; + private boolean kdfSaltCompareEnabled = true; private boolean useCachedPagesForComparison = true; private IMetaInfo metaInfo; @@ -165,7 +167,7 @@ public CompareTool() { * rather than a regular file, does not exist but cannot * be created, or cannot be opened for any other reason. */ - public static PdfWriter createTestPdfWriter(String filename) throws FileNotFoundException { + public static PdfWriter createTestPdfWriter(String filename) throws IOException { return createTestPdfWriter(filename, new WriterProperties()); } @@ -179,7 +181,7 @@ public static PdfWriter createTestPdfWriter(String filename) throws FileNotFound * rather than a regular file, does not exist but cannot * be created, or cannot be opened for any other reason. */ - public static PdfWriter createTestPdfWriter(String filename, WriterProperties properties) throws FileNotFoundException { + public static PdfWriter createTestPdfWriter(String filename, WriterProperties properties) throws IOException { return new MemoryFirstPdfWriter(filename, properties); // Android-Conversion-Replace return new PdfWriter(filename, properties); } @@ -336,7 +338,24 @@ public void setEventCountingMetaInfo(IMetaInfo metaInfo) { * @return this CompareTool instance. */ public CompareTool enableEncryptionCompare() { + return enableEncryptionCompare(true); + } + + /** + * Enables the comparison of the encryption properties of the documents. Encryption properties comparison + * results are returned along with all other comparison results. + *

+ * IMPORTANT NOTE: this flag affects only the comparison performed by compareByContent methods! + * {@link #compareByCatalog(PdfDocument, PdfDocument)} doesn't compare encryption properties + * because encryption properties aren't part of the document's Catalog. + * + * @param kdfSaltCompareEnabled set to {@code true} if {@link PdfName#KDFSalt} entry must be compared, + * {code false} otherwise + * @return this CompareTool instance. + */ + public CompareTool enableEncryptionCompare(boolean kdfSaltCompareEnabled) { this.encryptionCompareEnabled = true; + this.kdfSaltCompareEnabled = kdfSaltCompareEnabled; return this; } @@ -777,7 +796,8 @@ public String compareXmp(String outPdf, String cmpPdf, boolean ignoreDateAndProd PdfReader readerOut = CompareTool.createOutputReader(this.outPdf); PdfDocument outDocument = new PdfDocument(readerOut, new DocumentProperties().setEventCountingMetaInfo(metaInfo))) { - byte[] cmpBytes = cmpDocument.getXmpMetadata(), outBytes = outDocument.getXmpMetadata(); + byte[] cmpBytes = cmpDocument.getXmpMetadataBytes(); + byte[] outBytes = outDocument.getXmpMetadataBytes(); if (ignoreDateAndProducerProperties) { XMPMeta xmpMeta = XMPMetaFactory.parseFromBuffer(cmpBytes, new ParseOptions().setOmitNormalization(true)); @@ -1270,6 +1290,7 @@ private String compareByContent(String outPath, String differenceImagePrefix, Ma if (encryptionCompareEnabled) { compareDocumentsEncryption(outDocument, cmpDocument, compareResult); + compareDocumentsMac(outDocument, cmpDocument, compareResult); } if (generateCompareByContentXmlReport) { String outPdfName = new File(outPdf).getName(); @@ -1370,6 +1391,27 @@ private void compareDocumentsEncryption(PdfDocument outDocument, PdfDocument cmp } } + private void compareDocumentsMac(PdfDocument outDocument, PdfDocument cmpDocument, CompareResult compareResult) { + PdfDictionary outAuthCode = outDocument.getTrailer().getAsDictionary(PdfName.AuthCode); + PdfDictionary cmpAuthCode = cmpDocument.getTrailer().getAsDictionary(PdfName.AuthCode); + if (outAuthCode == null && cmpAuthCode == null) { + return; + } + + ObjectPath trailerPath = new TrailerPath(cmpDocument, outDocument); + if (outAuthCode == null) { + compareResult.addError(trailerPath, "Output document does not contain MAC."); + return; + } + if (cmpAuthCode == null) { + compareResult.addError(trailerPath, "Output document contains MAC which is not expected."); + return; + } + + compareDictionariesExtended(outAuthCode, cmpAuthCode, trailerPath, compareResult, + new HashSet<>(Arrays.asList(PdfName.ByteRange, PdfName.MAC))); + } + private boolean compareStreams(InputStream is1, InputStream is2) throws IOException { byte[] buffer1 = new byte[64 * 1024]; byte[] buffer2 = new byte[64 * 1024]; @@ -1409,7 +1451,10 @@ private boolean compareDictionariesExtended(PdfDictionary outDict, PdfDictionary if (excludedKeys != null && excludedKeys.contains(key)) { continue; } - if (key.equals(PdfName.Parent) || key.equals(PdfName.P) || key.equals(PdfName.ModDate)) continue; + if (key.equals(PdfName.Parent) || key.equals(PdfName.P) || key.equals(PdfName.ModDate) || + (key.equals(PdfName.KDFSalt) && !kdfSaltCompareEnabled)) { + continue; + } if (outDict.isStream() && cmpDict.isStream() && (key.equals(PdfName.Filter) || key.equals(PdfName.Length))) continue; if (key.equals(PdfName.BaseFont) || key.equals(PdfName.FontName)) { diff --git a/kernel/src/main/java/com/itextpdf/kernel/utils/IValidationChecker.java b/kernel/src/main/java/com/itextpdf/kernel/utils/IValidationChecker.java deleted file mode 100644 index ae835e8239..0000000000 --- a/kernel/src/main/java/com/itextpdf/kernel/utils/IValidationChecker.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - This file is part of the iText (R) project. - Copyright (c) 1998-2024 Apryse Group NV - Authors: Apryse Software. - - This program is offered under a commercial and under the AGPL license. - For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. - - AGPL licensing: - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . - */ -package com.itextpdf.kernel.utils; - -import com.itextpdf.kernel.pdf.IsoKey; -import com.itextpdf.kernel.pdf.PdfDocument; -import com.itextpdf.kernel.pdf.PdfResources; -import com.itextpdf.kernel.pdf.PdfStream; - -/** - * Used to check if a PDF document is compliant to a specific validation profile. - */ -public interface IValidationChecker { - - /** - * Validate the provided {@link ValidationContext}. - *

- * - * This method is called by the {@link PdfDocument#close()} to check for additional conformance requirements. - * - * @param validationContext the {@link ValidationContext} to validate - */ - void validateDocument(ValidationContext validationContext); - - /** - * Check the provided object for conformance. - *

- * - * This method is called by the - * {@link PdfDocument#checkIsoConformance(Object, IsoKey, PdfResources, PdfStream, Object)} - * to check for additional conformance requirements. - * - * @param obj the object to check - * @param key the {@link IsoKey} of the object - * @param resources the {@link PdfResources} of the object - * @param contentStream the {@link PdfStream} of the object - * @param extra additional information - */ - void validateObject(Object obj, IsoKey key, PdfResources resources, PdfStream contentStream, - Object extra); -} diff --git a/kernel/src/main/java/com/itextpdf/kernel/utils/PdfMerger.java b/kernel/src/main/java/com/itextpdf/kernel/utils/PdfMerger.java index bf81aac9be..769ba212da 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/utils/PdfMerger.java +++ b/kernel/src/main/java/com/itextpdf/kernel/utils/PdfMerger.java @@ -43,27 +43,7 @@ public class PdfMerger { * @param pdfDocument the document into which source documents will be merged */ public PdfMerger(PdfDocument pdfDocument) { - this(pdfDocument, true, true); - } - - /** - * This class is used to merge a number of existing documents into one. - * - * @param pdfDocument the document into which source documents will be merged - * @param mergeTags if true, then tags from the source document are copied even if destination document is not set as - * tagged. Note, that if false, tag structure is still could be copied if the destination document - * is explicitly marked as tagged with {@link PdfDocument#setTagged()} - * @param mergeOutlines if true, then outlines from the source document are copied even if in destination document - * outlines are not initialized. Note, that if false, outlines are still could be copied if the - * destination document outlines were explicitly initialized with {@link PdfDocument#initializeOutlines()} - * - * @deprecated use PdfMerger(PdfDocument, PdfMergerProperties) constructor - */ - @Deprecated - public PdfMerger(PdfDocument pdfDocument, boolean mergeTags, boolean mergeOutlines) { - this.pdfDocument = pdfDocument; - this.properties = new PdfMergerProperties(); - this.properties.setMergeTags(mergeTags).setMergeOutlines(mergeOutlines); + this(pdfDocument, new PdfMergerProperties().setMergeTags(true).setMergeOutlines(true)); } /** diff --git a/kernel/src/main/java/com/itextpdf/kernel/utils/RegisterDefaultDiContainer.java b/kernel/src/main/java/com/itextpdf/kernel/utils/RegisterDefaultDiContainer.java new file mode 100644 index 0000000000..20c49a45cc --- /dev/null +++ b/kernel/src/main/java/com/itextpdf/kernel/utils/RegisterDefaultDiContainer.java @@ -0,0 +1,51 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.utils; + +import com.itextpdf.commons.utils.DIContainer; +import com.itextpdf.kernel.di.pagetree.IPageTreeListFactory; +import com.itextpdf.kernel.di.pagetree.DefaultPageTreeListFactory; +import com.itextpdf.kernel.mac.IMacContainerLocator; +import com.itextpdf.kernel.mac.StandaloneMacContainerLocator; + +/** + * Registers a default instance for a dependency injection container for the kernel module. + */ +public class RegisterDefaultDiContainer { + + private static final int DEFAULT_PAGE_TREE_LIST_FACTORY_MAX_SAFE_ENTRIES = 50_000; + + /** + * Creates an instance of {@link RegisterDefaultDiContainer}. + */ + public RegisterDefaultDiContainer() { + // Empty constructor but should be public as we need it for automatic class loading + // sharp + } + + static { + DIContainer.registerDefault(IPageTreeListFactory.class, + () -> new DefaultPageTreeListFactory(DEFAULT_PAGE_TREE_LIST_FACTORY_MAX_SAFE_ENTRIES)); + DIContainer.registerDefault(IMacContainerLocator.class, () -> new StandaloneMacContainerLocator()); + } +} diff --git a/kernel/src/main/java/com/itextpdf/kernel/utils/ValidationContext.java b/kernel/src/main/java/com/itextpdf/kernel/utils/ValidationContext.java deleted file mode 100644 index dca1919151..0000000000 --- a/kernel/src/main/java/com/itextpdf/kernel/utils/ValidationContext.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - This file is part of the iText (R) project. - Copyright (c) 1998-2024 Apryse Group NV - Authors: Apryse Software. - - This program is offered under a commercial and under the AGPL license. - For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. - - AGPL licensing: - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . - */ -package com.itextpdf.kernel.utils; - -import com.itextpdf.kernel.font.PdfFont; -import com.itextpdf.kernel.pdf.PdfDocument; - -import java.util.Collection; - -/** - * This class is used to pass additional information to the {@link IValidationChecker} implementations. - */ -public class ValidationContext { - - private PdfDocument PdfDocument = null; - private Collection fonts = null; - - /** - * Creates new {@link ValidationContext} instance. - */ - public ValidationContext() { - } - - /** - * Sets {@link PdfDocument} for this {@link ValidationContext} instance. - * - * @param pdfDocument document to validate. - * - * @return this {@link ValidationContext} instance. - */ - public ValidationContext withPdfDocument(PdfDocument pdfDocument) { - this.PdfDocument = pdfDocument; - return this; - } - - /** - * Sets fonts for this {@link ValidationContext} instance. - * - * @param fonts collection of the {@link PdfFont} fonts to validate. - * - * @return this {@link ValidationContext} instance. - */ - public ValidationContext withFonts(Collection fonts) { - this.fonts = fonts; - return this; - } - - /** - * Gets {@link PdfDocument} related to this {@link ValidationContext}. - * - * @return {@link PdfDocument} document to validate. - */ - public PdfDocument getPdfDocument() { - return PdfDocument; - } - - /** - * Gets fonts related to this {@link ValidationContext}. - * - * @return fonts to validate. - */ - public Collection getFonts() { - return fonts; - } -} diff --git a/kernel/src/main/java/com/itextpdf/kernel/validation/IValidationChecker.java b/kernel/src/main/java/com/itextpdf/kernel/validation/IValidationChecker.java new file mode 100644 index 0000000000..3c1c78cb23 --- /dev/null +++ b/kernel/src/main/java/com/itextpdf/kernel/validation/IValidationChecker.java @@ -0,0 +1,47 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.validation; + + +import com.itextpdf.kernel.pdf.PdfObject; + +/** + * Used to check if a PDF document is compliant to a specific validation profile. + */ +public interface IValidationChecker { + /** + * Validate the provided {@link IValidationContext}. + * + * @param validationContext the {@link IValidationContext} to validate + */ + void validate(IValidationContext validationContext); + + /** + * Is {@link PdfObject} ready to flush. + * + * @param object the pdf object to check + * + * @return {@code true} if the object is ready to flush, {@code false} otherwise + */ + boolean isPdfObjectReadyToFlush(PdfObject object); +} diff --git a/pdftest/src/main/java/com/itextpdf/test/annotations/type/SlowTest.java b/kernel/src/main/java/com/itextpdf/kernel/validation/IValidationContext.java similarity index 78% rename from pdftest/src/main/java/com/itextpdf/test/annotations/type/SlowTest.java rename to kernel/src/main/java/com/itextpdf/kernel/validation/IValidationContext.java index e1028d2794..d72f97b3ae 100644 --- a/pdftest/src/main/java/com/itextpdf/test/annotations/type/SlowTest.java +++ b/kernel/src/main/java/com/itextpdf/kernel/validation/IValidationContext.java @@ -20,12 +20,16 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.test.annotations.type; +package com.itextpdf.kernel.validation; /** - * Tests that can take longer than a couple of milliseconds to run. These tests - * can be excluded by a build tool that wants to a fast test of the code, for - * example only Unit Tests. + * Interface for classes that store some information which is required for validation. */ -public interface SlowTest { +public interface IValidationContext { + /** + * Gets type of the context. + * + * @return the type + */ + ValidationType getType(); } diff --git a/kernel/src/main/java/com/itextpdf/kernel/utils/ValidationContainer.java b/kernel/src/main/java/com/itextpdf/kernel/validation/ValidationContainer.java similarity index 70% rename from kernel/src/main/java/com/itextpdf/kernel/utils/ValidationContainer.java rename to kernel/src/main/java/com/itextpdf/kernel/validation/ValidationContainer.java index 4b134a1972..7818e21a4a 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/utils/ValidationContainer.java +++ b/kernel/src/main/java/com/itextpdf/kernel/validation/ValidationContainer.java @@ -20,11 +20,9 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.kernel.utils; +package com.itextpdf.kernel.validation; -import com.itextpdf.kernel.pdf.IsoKey; -import com.itextpdf.kernel.pdf.PdfResources; -import com.itextpdf.kernel.pdf.PdfStream; +import com.itextpdf.kernel.pdf.PdfObject; import java.util.ArrayList; import java.util.List; @@ -50,31 +48,13 @@ public ValidationContainer() { } /** - * Validate the provided {@link ValidationContext} with all the {@link IValidationChecker} implementations. - *

- * - * @param context the {@link ValidationContext} to validate - */ - public void validate(ValidationContext context) { - for (IValidationChecker checker : validationCheckers) { - checker.validateDocument(context); - } - } - - /** - * Check the provided object for conformance with all the {@link IValidationChecker} implementations. - *

+ * Validate the provided {@link IValidationContext} with all the {@link IValidationChecker} implementations. * - * @param obj the object to check - * @param key the {@link IsoKey} of the object - * @param resources the {@link PdfResources} of the object - * @param contentStream the {@link PdfStream} of the object - * @param extra additional information + * @param context the {@link IValidationContext} to validate */ - public void validate(Object obj, IsoKey key, PdfResources resources, PdfStream contentStream, - Object extra) { + public void validate(IValidationContext context) { for (IValidationChecker checker : validationCheckers) { - checker.validateObject(obj, key, resources, contentStream, extra); + checker.validate(context); } } @@ -99,4 +79,19 @@ public boolean containsChecker(IValidationChecker checker) { return validationCheckers.contains(checker); } + /** + * Is {@link PdfObject} ready to flush according to all added {@link IValidationChecker} implementations. + * + * @param pdfObject the pdf object to check + * + * @return {@code true} if the object is ready to flush, {@code false} otherwise + */ + public boolean isPdfObjectChecked(PdfObject pdfObject) { + for (IValidationChecker checker : validationCheckers) { + if (!checker.isPdfObjectReadyToFlush(pdfObject)) { + return false; + } + } + return true; + } } diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/IsoKey.java b/kernel/src/main/java/com/itextpdf/kernel/validation/ValidationType.java similarity index 91% rename from kernel/src/main/java/com/itextpdf/kernel/pdf/IsoKey.java rename to kernel/src/main/java/com/itextpdf/kernel/validation/ValidationType.java index c1b4c58a00..b39c15f920 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/pdf/IsoKey.java +++ b/kernel/src/main/java/com/itextpdf/kernel/validation/ValidationType.java @@ -20,18 +20,19 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.kernel.pdf; +package com.itextpdf.kernel.validation; /** - * Type of object to conform. + * Type of object to validate. */ -public enum IsoKey { +public enum ValidationType { + PDF_DOCUMENT, // PDF/A Enums CANVAS_STACK, FILL_COLOR, EXTENDED_GRAPHICS_STATE, INLINE_IMAGE, - PAGE, + PDF_PAGE, PDF_OBJECT, RENDERING_INTENT, STROKE_COLOR, diff --git a/kernel/src/main/java/com/itextpdf/kernel/validation/context/AbstractColorValidationContext.java b/kernel/src/main/java/com/itextpdf/kernel/validation/context/AbstractColorValidationContext.java new file mode 100644 index 0000000000..7186be3f4c --- /dev/null +++ b/kernel/src/main/java/com/itextpdf/kernel/validation/context/AbstractColorValidationContext.java @@ -0,0 +1,74 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.validation.context; + +import com.itextpdf.kernel.pdf.PdfDictionary; +import com.itextpdf.kernel.pdf.PdfName; +import com.itextpdf.kernel.pdf.PdfResources; +import com.itextpdf.kernel.pdf.PdfStream; +import com.itextpdf.kernel.pdf.canvas.CanvasGraphicsState; +import com.itextpdf.kernel.validation.IValidationContext; + +/** + * Abstract class for color validation context. + */ +public abstract class AbstractColorValidationContext implements IValidationContext, + IContentStreamValidationParameter, IGraphicStateValidationParameter { + + private final CanvasGraphicsState graphicsState; + private final PdfDictionary currentColorSpaces; + private final PdfStream contentStream; + + /** + * Instantiates a new {@link AbstractColorValidationContext} based on graphic state, resources and content stream. + * + * @param graphicsState the graphical state + * @param resources the resources + * @param contentStream the content stream + */ + protected AbstractColorValidationContext(CanvasGraphicsState graphicsState, PdfResources resources, + PdfStream contentStream) { + this.graphicsState = graphicsState; + currentColorSpaces = resources == null ? null : resources.getPdfObject().getAsDictionary(PdfName.ColorSpace); + this.contentStream = contentStream; + } + + /** + * Gets the current color space. + * + * @return the color space dictionary + */ + public PdfDictionary getCurrentColorSpaces() { + return currentColorSpaces; + } + + @Override + public CanvasGraphicsState getGraphicsState() { + return graphicsState; + } + + @Override + public PdfStream getContentStream() { + return contentStream; + } +} diff --git a/kernel/src/main/java/com/itextpdf/kernel/validation/context/CanvasBmcValidationContext.java b/kernel/src/main/java/com/itextpdf/kernel/validation/context/CanvasBmcValidationContext.java new file mode 100644 index 0000000000..9cb8dd772d --- /dev/null +++ b/kernel/src/main/java/com/itextpdf/kernel/validation/context/CanvasBmcValidationContext.java @@ -0,0 +1,74 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.validation.context; + +import com.itextpdf.commons.datastructures.Tuple2; +import com.itextpdf.kernel.pdf.PdfDictionary; +import com.itextpdf.kernel.pdf.PdfName; +import com.itextpdf.kernel.validation.IValidationContext; +import com.itextpdf.kernel.validation.ValidationType; + +import java.util.Stack; + +/** + * Class for canvas begin marked content validation. + */ +public class CanvasBmcValidationContext implements IValidationContext { + private final Stack> tagStructureStack; + private final Tuple2 currentBmc; + + /** + * Instantiates a new {@link CanvasBmcValidationContext} based on tag structure stack and current BMC. + * + * @param tagStructureStack the tag structure stack + * @param currentBmc the current BMC + */ + public CanvasBmcValidationContext(Stack> tagStructureStack, + Tuple2 currentBmc) { + this.tagStructureStack = tagStructureStack; + this.currentBmc = currentBmc; + } + + /** + * Gets tag structure stack. + * + * @return tag structure stack + */ + public Stack> getTagStructureStack() { + return tagStructureStack; + } + + /** + * Gets current BMC. + * + * @return the current BMC + */ + public Tuple2 getCurrentBmc() { + return currentBmc; + } + + @Override + public ValidationType getType() { + return ValidationType.CANVAS_BEGIN_MARKED_CONTENT; + } +} diff --git a/kernel/src/main/java/com/itextpdf/kernel/validation/context/CanvasStackValidationContext.java b/kernel/src/main/java/com/itextpdf/kernel/validation/context/CanvasStackValidationContext.java new file mode 100644 index 0000000000..b35f897dc2 --- /dev/null +++ b/kernel/src/main/java/com/itextpdf/kernel/validation/context/CanvasStackValidationContext.java @@ -0,0 +1,56 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.validation.context; + +import com.itextpdf.kernel.validation.IValidationContext; +import com.itextpdf.kernel.validation.ValidationType; + +/** + * Class for canvas stack validation. + */ +public class CanvasStackValidationContext implements IValidationContext { + private final char operator; + + /** + * Instantiates a new {@link CanvasStackValidationContext} based on operator. + * + * @param operator the operator + */ + public CanvasStackValidationContext(char operator) { + this.operator = operator; + } + + /** + * Gets the operator. + * + * @return the operator + */ + public char getOperator() { + return operator; + } + + @Override + public ValidationType getType() { + return ValidationType.CANVAS_STACK; + } +} diff --git a/kernel/src/main/java/com/itextpdf/kernel/validation/context/CanvasWritingContentValidationContext.java b/kernel/src/main/java/com/itextpdf/kernel/validation/context/CanvasWritingContentValidationContext.java new file mode 100644 index 0000000000..f80f5cdf97 --- /dev/null +++ b/kernel/src/main/java/com/itextpdf/kernel/validation/context/CanvasWritingContentValidationContext.java @@ -0,0 +1,61 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.validation.context; + +import com.itextpdf.commons.datastructures.Tuple2; +import com.itextpdf.kernel.pdf.PdfDictionary; +import com.itextpdf.kernel.pdf.PdfName; +import com.itextpdf.kernel.validation.IValidationContext; +import com.itextpdf.kernel.validation.ValidationType; + +import java.util.Stack; + +/** + * Class for canvas writing content validation. + */ +public class CanvasWritingContentValidationContext implements IValidationContext { + private final Stack> tagStructureStack; + + /** + * Instantiates a new {@link CanvasWritingContentValidationContext} based on tag structure stack. + * + * @param tagStructureStack the tag structure stack + */ + public CanvasWritingContentValidationContext(Stack> tagStructureStack) { + this.tagStructureStack = tagStructureStack; + } + + /** + * Gets the tag structure stack. + * + * @return the tag structure stack + */ + public Stack> getTagStructureStack() { + return tagStructureStack; + } + + @Override + public ValidationType getType() { + return ValidationType.CANVAS_WRITING_CONTENT; + } +} diff --git a/kernel/src/main/java/com/itextpdf/kernel/validation/context/CryptoValidationContext.java b/kernel/src/main/java/com/itextpdf/kernel/validation/context/CryptoValidationContext.java new file mode 100644 index 0000000000..0b8648ab8e --- /dev/null +++ b/kernel/src/main/java/com/itextpdf/kernel/validation/context/CryptoValidationContext.java @@ -0,0 +1,57 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.validation.context; + +import com.itextpdf.kernel.pdf.PdfObject; +import com.itextpdf.kernel.validation.IValidationContext; +import com.itextpdf.kernel.validation.ValidationType; + +/** + * Class for crypto validation. + */ +public class CryptoValidationContext implements IValidationContext { + private final PdfObject crypto; + + /** + * Instantiates a new {@link CryptoValidationContext} based on crypto object. + * + * @param crypto the crypto object + */ + public CryptoValidationContext(PdfObject crypto) { + this.crypto = crypto; + } + + /** + * Gets the crypto object. + * + * @return the crypto object + */ + public PdfObject getCrypto() { + return crypto; + } + + @Override + public ValidationType getType() { + return ValidationType.CRYPTO; + } +} diff --git a/kernel/src/main/java/com/itextpdf/kernel/validation/context/DuplicateIdEntryValidationContext.java b/kernel/src/main/java/com/itextpdf/kernel/validation/context/DuplicateIdEntryValidationContext.java new file mode 100644 index 0000000000..a7a42a0b39 --- /dev/null +++ b/kernel/src/main/java/com/itextpdf/kernel/validation/context/DuplicateIdEntryValidationContext.java @@ -0,0 +1,57 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.validation.context; + +import com.itextpdf.kernel.pdf.PdfString; +import com.itextpdf.kernel.validation.IValidationContext; +import com.itextpdf.kernel.validation.ValidationType; + +/** + * Class for duplicate ID entry in structure element tree validation. + */ +public class DuplicateIdEntryValidationContext implements IValidationContext { + private final PdfString id; + + /** + * Instantiates a new {@link DuplicateIdEntryValidationContext} based on ID string. + * + * @param id the ID of the entry + */ + public DuplicateIdEntryValidationContext(PdfString id) { + this.id = id; + } + + /** + * Gets the ID of the entry. + * + * @return the ID + */ + public PdfString getId() { + return id; + } + + @Override + public ValidationType getType() { + return ValidationType.DUPLICATE_ID_ENTRY; + } +} diff --git a/kernel/src/main/java/com/itextpdf/kernel/validation/context/ExtendedGStateValidationContext.java b/kernel/src/main/java/com/itextpdf/kernel/validation/context/ExtendedGStateValidationContext.java new file mode 100644 index 0000000000..39b4fc8a53 --- /dev/null +++ b/kernel/src/main/java/com/itextpdf/kernel/validation/context/ExtendedGStateValidationContext.java @@ -0,0 +1,64 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.validation.context; + +import com.itextpdf.kernel.pdf.PdfStream; +import com.itextpdf.kernel.pdf.canvas.CanvasGraphicsState; +import com.itextpdf.kernel.validation.IValidationContext; +import com.itextpdf.kernel.validation.ValidationType; + +/** + * Class for extended graphics state validation. + */ +public class ExtendedGStateValidationContext implements IValidationContext, + IGraphicStateValidationParameter, IContentStreamValidationParameter { + + private final CanvasGraphicsState graphicsState; + private final PdfStream contentStream; + + /** + * Instantiates a new {@link ExtendedGStateValidationContext} based on graphics state and content stream. + * + * @param graphicsState the graphics state + * @param contentStream the content stream + */ + public ExtendedGStateValidationContext(CanvasGraphicsState graphicsState, PdfStream contentStream) { + this.graphicsState = graphicsState; + this.contentStream = contentStream; + } + + @Override + public PdfStream getContentStream() { + return contentStream; + } + + @Override + public CanvasGraphicsState getGraphicsState() { + return graphicsState; + } + + @Override + public ValidationType getType() { + return ValidationType.EXTENDED_GRAPHICS_STATE; + } +} diff --git a/kernel/src/main/java/com/itextpdf/kernel/validation/context/FillColorValidationContext.java b/kernel/src/main/java/com/itextpdf/kernel/validation/context/FillColorValidationContext.java new file mode 100644 index 0000000000..407eb5f8c8 --- /dev/null +++ b/kernel/src/main/java/com/itextpdf/kernel/validation/context/FillColorValidationContext.java @@ -0,0 +1,50 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.validation.context; + +import com.itextpdf.kernel.pdf.PdfResources; +import com.itextpdf.kernel.pdf.PdfStream; +import com.itextpdf.kernel.pdf.canvas.CanvasGraphicsState; +import com.itextpdf.kernel.validation.ValidationType; + +/** + * Class for fill canvas color canvas tag validation. + */ +public class FillColorValidationContext extends AbstractColorValidationContext { + /** + * Instantiates a new {@link FillColorValidationContext} based on graphics state, resources and content stream. + * + * @param canvasGraphicsState the canvas graphics state + * @param resources the resources + * @param stream the content stream + */ + public FillColorValidationContext(CanvasGraphicsState canvasGraphicsState, PdfResources resources, + PdfStream stream) { + super(canvasGraphicsState, resources, stream); + } + + @Override + public ValidationType getType() { + return ValidationType.FILL_COLOR; + } +} diff --git a/kernel/src/main/java/com/itextpdf/kernel/validation/context/FontGlyphsGStateValidationContext.java b/kernel/src/main/java/com/itextpdf/kernel/validation/context/FontGlyphsGStateValidationContext.java new file mode 100644 index 0000000000..288af6b823 --- /dev/null +++ b/kernel/src/main/java/com/itextpdf/kernel/validation/context/FontGlyphsGStateValidationContext.java @@ -0,0 +1,63 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.validation.context; + +import com.itextpdf.kernel.pdf.PdfStream; +import com.itextpdf.kernel.pdf.canvas.CanvasGraphicsState; +import com.itextpdf.kernel.validation.IValidationContext; +import com.itextpdf.kernel.validation.ValidationType; + +/** + * Class for canvas font glyphs validation context. + */ +public class FontGlyphsGStateValidationContext implements IValidationContext, + IGraphicStateValidationParameter, IContentStreamValidationParameter { + private final CanvasGraphicsState graphicsState; + private final PdfStream contentStream; + + /** + * Instantiates a new {@link FontGlyphsGStateValidationContext} based on canvas graphics state and content stream. + * + * @param graphicsState the canvas graphics state + * @param contentStream the content stream + */ + public FontGlyphsGStateValidationContext(CanvasGraphicsState graphicsState, PdfStream contentStream) { + this.graphicsState = graphicsState; + this.contentStream = contentStream; + } + + @Override + public PdfStream getContentStream() { + return contentStream; + } + + @Override + public CanvasGraphicsState getGraphicsState() { + return graphicsState; + } + + @Override + public ValidationType getType() { + return ValidationType.FONT_GLYPHS; + } +} diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfUAConformanceLevel.java b/kernel/src/main/java/com/itextpdf/kernel/validation/context/FontValidationContext.java similarity index 54% rename from kernel/src/main/java/com/itextpdf/kernel/pdf/PdfUAConformanceLevel.java rename to kernel/src/main/java/com/itextpdf/kernel/validation/context/FontValidationContext.java index 0815cf32e3..ff73ca47b1 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/pdf/PdfUAConformanceLevel.java +++ b/kernel/src/main/java/com/itextpdf/kernel/validation/context/FontValidationContext.java @@ -20,40 +20,50 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.kernel.pdf; +package com.itextpdf.kernel.validation.context; + +import com.itextpdf.kernel.font.PdfFont; +import com.itextpdf.kernel.validation.IValidationContext; +import com.itextpdf.kernel.validation.ValidationType; /** - * Implementation of {@link IConformanceLevel} interface for PDF/UA conformance level. - *

- * - * PDF/UA is a conformance level for PDF files that ensures the files are accessible. - * It contains an enumeration of all the PDF/UA conformance levels currently supported by iText. + * Class for font validation context. */ -public class PdfUAConformanceLevel implements IConformanceLevel { +public class FontValidationContext implements IValidationContext { + private final String text; + private final PdfFont font; /** - * PDF/UA conformance level PDF/UA-1. + * Instantiates a new {@link FontValidationContext} based on text and font. + * + * @param text the text + * @param font the font */ - public static final PdfUAConformanceLevel PDFUA_1 = new PdfUAConformanceLevel(1); - - private final int version; - + public FontValidationContext(String text, PdfFont font) { + this.text = text; + this.font = font; + } /** - * Creates a new {@link PdfUAConformanceLevel} instance. + * Gets the text. * - * @param version the version of the PDF/UA conformance level + * @return the text */ - private PdfUAConformanceLevel(int version) { - this.version = version; + public String getText() { + return text; } /** - * Get the version of the PDF/UA conformance level. + * Gets the font. * - * @return the version of the PDF/UA conformance level + * @return the font */ - public int getVersion() { - return version; + public PdfFont getFont() { + return font; + } + + @Override + public ValidationType getType() { + return ValidationType.FONT; } } diff --git a/pdftest/src/main/java/com/itextpdf/test/annotations/type/PerformanceTest.java b/kernel/src/main/java/com/itextpdf/kernel/validation/context/IContentStreamValidationParameter.java similarity index 74% rename from pdftest/src/main/java/com/itextpdf/test/annotations/type/PerformanceTest.java rename to kernel/src/main/java/com/itextpdf/kernel/validation/context/IContentStreamValidationParameter.java index d7a2fad502..bd16cd84c1 100644 --- a/pdftest/src/main/java/com/itextpdf/test/annotations/type/PerformanceTest.java +++ b/kernel/src/main/java/com/itextpdf/kernel/validation/context/IContentStreamValidationParameter.java @@ -20,14 +20,18 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.test.annotations.type; +package com.itextpdf.kernel.validation.context; + +import com.itextpdf.kernel.pdf.PdfStream; /** - * Performance Tests generate performance metrics: speed, memory usage, disk - * space,... - *

- * A Performance Test may repeat the same (or similar) test cases a lot, and may - * compare the metrics with metrics of a previous version. + * Interface for validation context classes which store content stream. */ -public interface PerformanceTest extends SlowTest { +public interface IContentStreamValidationParameter { + /** + * Gets the content stream. + * + * @return the content stream + */ + PdfStream getContentStream(); } diff --git a/kernel/src/main/java/com/itextpdf/kernel/pdf/IConformanceLevel.java b/kernel/src/main/java/com/itextpdf/kernel/validation/context/IGraphicStateValidationParameter.java similarity index 73% rename from kernel/src/main/java/com/itextpdf/kernel/pdf/IConformanceLevel.java rename to kernel/src/main/java/com/itextpdf/kernel/validation/context/IGraphicStateValidationParameter.java index 3b5a94b423..90f12cd81d 100644 --- a/kernel/src/main/java/com/itextpdf/kernel/pdf/IConformanceLevel.java +++ b/kernel/src/main/java/com/itextpdf/kernel/validation/context/IGraphicStateValidationParameter.java @@ -20,16 +20,18 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.kernel.pdf; +package com.itextpdf.kernel.validation.context; +import com.itextpdf.kernel.pdf.canvas.CanvasGraphicsState; /** - * Interface for PDF conformance level. - *

- * - * Conformance levels are extended PDF specifications that define subsets of PDF - * functionality. An example of a conformance level is PDF/A, which is used for long-term archiving - * and PDF/UA, which is used for accessible documents. + * Interface for validation context classes which store graphics state. */ -public interface IConformanceLevel { +public interface IGraphicStateValidationParameter { + /** + * Gets the graphics state. + * + * @return the graphics state + */ + CanvasGraphicsState getGraphicsState(); } diff --git a/kernel/src/main/java/com/itextpdf/kernel/validation/context/InlineImageValidationContext.java b/kernel/src/main/java/com/itextpdf/kernel/validation/context/InlineImageValidationContext.java new file mode 100644 index 0000000000..30088c67c2 --- /dev/null +++ b/kernel/src/main/java/com/itextpdf/kernel/validation/context/InlineImageValidationContext.java @@ -0,0 +1,72 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.validation.context; + +import com.itextpdf.kernel.pdf.PdfDictionary; +import com.itextpdf.kernel.pdf.PdfName; +import com.itextpdf.kernel.pdf.PdfResources; +import com.itextpdf.kernel.pdf.PdfStream; +import com.itextpdf.kernel.validation.IValidationContext; +import com.itextpdf.kernel.validation.ValidationType; + +/** + * Class for inline image validation context. + */ +public class InlineImageValidationContext implements IValidationContext { + private final PdfStream image; + private final PdfDictionary currentColorSpaces; + + /** + * Instantiates a new {@link InlineImageValidationContext} based on image and resources. + * + * @param image the image + * @param resources the resources which are used to extract color space of the image + */ + public InlineImageValidationContext(PdfStream image, PdfResources resources) { + this.image = image; + currentColorSpaces = resources == null ? null : resources.getPdfObject().getAsDictionary(PdfName.ColorSpace); + } + + /** + * Gets the image. + * + * @return the image + */ + public PdfStream getImage() { + return image; + } + + /** + * Gets the current color space. + * + * @return the color space + */ + public PdfDictionary getCurrentColorSpaces() { + return currentColorSpaces; + } + + @Override + public ValidationType getType() { + return ValidationType.INLINE_IMAGE; + } +} diff --git a/kernel/src/main/java/com/itextpdf/kernel/validation/context/PdfDocumentValidationContext.java b/kernel/src/main/java/com/itextpdf/kernel/validation/context/PdfDocumentValidationContext.java new file mode 100644 index 0000000000..95d1cee2c9 --- /dev/null +++ b/kernel/src/main/java/com/itextpdf/kernel/validation/context/PdfDocumentValidationContext.java @@ -0,0 +1,72 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.validation.context; + +import com.itextpdf.kernel.font.PdfFont; +import com.itextpdf.kernel.pdf.PdfDocument; +import com.itextpdf.kernel.validation.IValidationContext; +import com.itextpdf.kernel.validation.ValidationType; + +import java.util.Collection; + +/** + * Class for {@link PdfDocument} validation context. + */ +public class PdfDocumentValidationContext implements IValidationContext { + private final PdfDocument pdfDocument; + private final Collection documentFonts; + + /** + * Instantiates a new {@link PdfDocumentValidationContext} based on document and document fonts. + * + * @param pdfDocument the pdf document + * @param documentFonts the document fonts + */ + public PdfDocumentValidationContext(PdfDocument pdfDocument, Collection documentFonts) { + this.pdfDocument = pdfDocument; + this.documentFonts = documentFonts; + } + + /** + * Gets the pdf document. + * + * @return the pdf document + */ + public PdfDocument getPdfDocument() { + return pdfDocument; + } + + /** + * Gets the document fonts. + * + * @return the document fonts + */ + public Collection getDocumentFonts() { + return documentFonts; + } + + @Override + public ValidationType getType() { + return ValidationType.PDF_DOCUMENT; + } +} diff --git a/kernel/src/main/java/com/itextpdf/kernel/validation/context/PdfObjectValidationContext.java b/kernel/src/main/java/com/itextpdf/kernel/validation/context/PdfObjectValidationContext.java new file mode 100644 index 0000000000..0f9ecbb89c --- /dev/null +++ b/kernel/src/main/java/com/itextpdf/kernel/validation/context/PdfObjectValidationContext.java @@ -0,0 +1,57 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.validation.context; + +import com.itextpdf.kernel.pdf.PdfObject; +import com.itextpdf.kernel.validation.IValidationContext; +import com.itextpdf.kernel.validation.ValidationType; + +/** + * Class for {@link PdfObject} validation context. + */ +public class PdfObjectValidationContext implements IValidationContext { + private final PdfObject object; + + /** + * Instantiates a new {@link PdfObjectValidationContext} based on pdf object. + * + * @param object the pdf object + */ + public PdfObjectValidationContext(PdfObject object) { + this.object = object; + } + + /** + * Gets the pdf object. + * + * @return the pdf object + */ + public PdfObject getObject() { + return object; + } + + @Override + public ValidationType getType() { + return ValidationType.PDF_OBJECT; + } +} diff --git a/kernel/src/main/java/com/itextpdf/kernel/validation/context/PdfPageValidationContext.java b/kernel/src/main/java/com/itextpdf/kernel/validation/context/PdfPageValidationContext.java new file mode 100644 index 0000000000..d396f67332 --- /dev/null +++ b/kernel/src/main/java/com/itextpdf/kernel/validation/context/PdfPageValidationContext.java @@ -0,0 +1,57 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.validation.context; + +import com.itextpdf.kernel.pdf.PdfPage; +import com.itextpdf.kernel.validation.IValidationContext; +import com.itextpdf.kernel.validation.ValidationType; + +/** + * Class for {@link PdfPage} validation context. + */ +public class PdfPageValidationContext implements IValidationContext { + private final PdfPage page; + + /** + * Instantiates a new {@link PdfPageValidationContext} based on pdf page. + * + * @param page the pdf page + */ + public PdfPageValidationContext(PdfPage page) { + this.page = page; + } + + /** + * Gets the pdf page. + * + * @return the pdf page + */ + public PdfPage getPage() { + return page; + } + + @Override + public ValidationType getType() { + return ValidationType.PDF_PAGE; + } +} diff --git a/pdfua/src/main/java/com/itextpdf/pdfua/checkers/utils/TagTreeHandlerUtil.java b/kernel/src/main/java/com/itextpdf/kernel/validation/context/RenderingIntentValidationContext.java similarity index 57% rename from pdfua/src/main/java/com/itextpdf/pdfua/checkers/utils/TagTreeHandlerUtil.java rename to kernel/src/main/java/com/itextpdf/kernel/validation/context/RenderingIntentValidationContext.java index 7b670c82eb..e9058893db 100644 --- a/pdfua/src/main/java/com/itextpdf/pdfua/checkers/utils/TagTreeHandlerUtil.java +++ b/kernel/src/main/java/com/itextpdf/kernel/validation/context/RenderingIntentValidationContext.java @@ -20,33 +20,38 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.pdfua.checkers.utils; +package com.itextpdf.kernel.validation.context; import com.itextpdf.kernel.pdf.PdfName; -import com.itextpdf.kernel.pdf.tagging.IStructureNode; -import com.itextpdf.kernel.pdf.tagging.PdfStructElem; +import com.itextpdf.kernel.validation.IValidationContext; +import com.itextpdf.kernel.validation.ValidationType; /** - * Utility class that contains utility methods used when working with the TagTreeHandler + * Class for rendering intent validation context. */ -@Deprecated -public final class TagTreeHandlerUtil { +public class RenderingIntentValidationContext implements IValidationContext { + private final PdfName intent; - private TagTreeHandlerUtil() { - //Empty constructor. + /** + * Instantiates a new {@link RenderingIntentValidationContext} based on pdf name. + * + * @param intent the intent pdf name + */ + public RenderingIntentValidationContext(PdfName intent) { + this.intent = intent; } /** - * Gets the {@link PdfStructElem} if the element matches the provided role and the structureNode is indeed an - * {@link PdfStructElem} + * Gets the intent pdf name. * - * @param role The role that needs to be matched. - * @param structureNode The structure node. - * - * @return The {@link PdfStructElem} if the structure matches the role. + * @return the intent pdf name */ - @Deprecated - public static PdfStructElem getElementIfRoleMatches(PdfName role, IStructureNode structureNode) { - return null; + public PdfName getIntent() { + return intent; + } + + @Override + public ValidationType getType() { + return ValidationType.RENDERING_INTENT; } } diff --git a/kernel/src/main/java/com/itextpdf/kernel/validation/context/SignTypeValidationContext.java b/kernel/src/main/java/com/itextpdf/kernel/validation/context/SignTypeValidationContext.java new file mode 100644 index 0000000000..bab4fecea2 --- /dev/null +++ b/kernel/src/main/java/com/itextpdf/kernel/validation/context/SignTypeValidationContext.java @@ -0,0 +1,56 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.validation.context; + +import com.itextpdf.kernel.validation.IValidationContext; +import com.itextpdf.kernel.validation.ValidationType; + +/** + * Class for sign type validation context. + */ +public class SignTypeValidationContext implements IValidationContext { + private final boolean isCAdES; + + /** + * Instantiates a new {@link SignTypeValidationContext} based on whether sign is CAdeS or not. + * + * @param isCAdES whether sign is CAdeS or not + */ + public SignTypeValidationContext(boolean isCAdES) { + this.isCAdES = isCAdES; + } + + /** + * Whether sign is CAdeS or not. + * + * @return whether sign is CAdeS or not + */ + public boolean isCAdES() { + return isCAdES; + } + + @Override + public ValidationType getType() { + return ValidationType.SIGNATURE_TYPE; + } +} diff --git a/kernel/src/main/java/com/itextpdf/kernel/validation/context/SignatureValidationContext.java b/kernel/src/main/java/com/itextpdf/kernel/validation/context/SignatureValidationContext.java new file mode 100644 index 0000000000..3c127b6df5 --- /dev/null +++ b/kernel/src/main/java/com/itextpdf/kernel/validation/context/SignatureValidationContext.java @@ -0,0 +1,57 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.validation.context; + +import com.itextpdf.kernel.pdf.PdfDictionary; +import com.itextpdf.kernel.validation.IValidationContext; +import com.itextpdf.kernel.validation.ValidationType; + +/** + * Class for signature validation context. + */ +public class SignatureValidationContext implements IValidationContext { + private final PdfDictionary sign; + + /** + * Instantiates a new {@link SignatureValidationContext} based on sign pdf dictionary. + * + * @param sign the sign pdf dictionary + */ + public SignatureValidationContext(PdfDictionary sign) { + this.sign = sign; + } + + /** + * Gets the sign pdf dictionary. + * + * @return the sign pdf dictionary + */ + public PdfDictionary getSignature() { + return sign; + } + + @Override + public ValidationType getType() { + return ValidationType.SIGNATURE; + } +} diff --git a/kernel/src/main/java/com/itextpdf/kernel/validation/context/StrokeColorValidationContext.java b/kernel/src/main/java/com/itextpdf/kernel/validation/context/StrokeColorValidationContext.java new file mode 100644 index 0000000000..c0c414b979 --- /dev/null +++ b/kernel/src/main/java/com/itextpdf/kernel/validation/context/StrokeColorValidationContext.java @@ -0,0 +1,50 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.validation.context; + +import com.itextpdf.kernel.pdf.PdfResources; +import com.itextpdf.kernel.pdf.PdfStream; +import com.itextpdf.kernel.pdf.canvas.CanvasGraphicsState; +import com.itextpdf.kernel.validation.ValidationType; + +/** + * Class for stroke canvas color validation context. + */ +public class StrokeColorValidationContext extends AbstractColorValidationContext { + /** + * Instantiates a new {@link StrokeColorValidationContext} based on graphics state, resources and content stream. + * + * @param canvasGraphicsState the canvas graphics state + * @param resources the resources + * @param stream the content stream + */ + public StrokeColorValidationContext(CanvasGraphicsState canvasGraphicsState, + PdfResources resources, PdfStream stream) { + super(canvasGraphicsState, resources, stream); + } + + @Override + public ValidationType getType() { + return ValidationType.STROKE_COLOR; + } +} diff --git a/kernel/src/main/java/com/itextpdf/kernel/validation/context/TagStructElementValidationContext.java b/kernel/src/main/java/com/itextpdf/kernel/validation/context/TagStructElementValidationContext.java new file mode 100644 index 0000000000..42ef3bbf2c --- /dev/null +++ b/kernel/src/main/java/com/itextpdf/kernel/validation/context/TagStructElementValidationContext.java @@ -0,0 +1,57 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.validation.context; + +import com.itextpdf.kernel.pdf.PdfObject; +import com.itextpdf.kernel.validation.IValidationContext; +import com.itextpdf.kernel.validation.ValidationType; + +/** + * Class for tag structure element validation context. + */ +public class TagStructElementValidationContext implements IValidationContext { + private final PdfObject object; + + /** + * Instantiates a new {@link TagStructElementValidationContext} based on pdf object. + * + * @param object the tag pdf object + */ + public TagStructElementValidationContext(PdfObject object) { + this.object = object; + } + + /** + * Gets the tag pdf object. + * + * @return the tag pdf object + */ + public PdfObject getObject() { + return object; + } + + @Override + public ValidationType getType() { + return ValidationType.TAG_STRUCTURE_ELEMENT; + } +} diff --git a/kernel/src/main/java/com/itextpdf/kernel/validation/context/XrefTableValidationContext.java b/kernel/src/main/java/com/itextpdf/kernel/validation/context/XrefTableValidationContext.java new file mode 100644 index 0000000000..6110f5f596 --- /dev/null +++ b/kernel/src/main/java/com/itextpdf/kernel/validation/context/XrefTableValidationContext.java @@ -0,0 +1,57 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.validation.context; + +import com.itextpdf.kernel.pdf.PdfXrefTable; +import com.itextpdf.kernel.validation.IValidationContext; +import com.itextpdf.kernel.validation.ValidationType; + +/** + * Class for {@link PdfXrefTable} validation context. + */ +public class XrefTableValidationContext implements IValidationContext { + private final PdfXrefTable xrefTable; + + /** + * Instantiates a new {@link XrefTableValidationContext} based on pdf xref table. + * + * @param xrefTable the pdf xref table + */ + public XrefTableValidationContext(PdfXrefTable xrefTable) { + this.xrefTable = xrefTable; + } + + /** + * Gets the pdf xref table. + * + * @return the pdf xref table + */ + public PdfXrefTable getXrefTable() { + return xrefTable; + } + + @Override + public ValidationType getType() { + return ValidationType.XREF_TABLE; + } +} diff --git a/kernel/src/main/resources/META-INF/native-image/com.itextpdf/kernel/reflect-config.json b/kernel/src/main/resources/META-INF/native-image/com.itextpdf/kernel/reflect-config.json index 2621b74cf5..4ed150ec3b 100644 --- a/kernel/src/main/resources/META-INF/native-image/com.itextpdf/kernel/reflect-config.json +++ b/kernel/src/main/resources/META-INF/native-image/com.itextpdf/kernel/reflect-config.json @@ -1,7 +1,15 @@ -[{ +[ + { "condition": { - "typeReachable": "com.itextpdf.kernel.pdf.PdfName" + "typeReachable": "com.itextpdf.kernel.pdf.PdfName" }, "name": "com.itextpdf.kernel.pdf.PdfName", - "allDeclaredFields":true -}] + "allDeclaredFields": true + }, + { + "condition": { + "typeReachable": "com.itextpdf.kernel.di.pagetree.IPageTreeListFactory" + }, + "name": "com.itextpdf.kernel.utils.RegisterDefaultDiContainer" + } +] diff --git a/kernel/src/test/java/com/itextpdf/kernel/PdfExceptionTest.java b/kernel/src/test/java/com/itextpdf/kernel/PdfExceptionTest.java index 4ad88d945f..71d1471d94 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/PdfExceptionTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/PdfExceptionTest.java @@ -25,19 +25,18 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.exceptions.KernelExceptionMessageConstant; import com.itextpdf.kernel.exceptions.PdfException; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfExceptionTest extends ExtendedITextTest { @Test public void whenCreatedPdfExceptionWrapsCauseWithUnknownExceptionMessageTest() { - Exception e = Assert.assertThrows(PdfException.class, + Exception e = Assertions.assertThrows(PdfException.class, () -> {throw new PdfException(new Exception("itext"));}); - Assert.assertEquals(KernelExceptionMessageConstant.UNKNOWN_PDF_EXCEPTION, e.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.UNKNOWN_PDF_EXCEPTION, e.getMessage()); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/actions/ProducerBuilderIntegrationTest.java b/kernel/src/test/java/com/itextpdf/kernel/actions/ProducerBuilderIntegrationTest.java index 2d6171779d..5179bedf7c 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/actions/ProducerBuilderIntegrationTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/actions/ProducerBuilderIntegrationTest.java @@ -25,23 +25,22 @@ This file is part of the iText (R) project. import com.itextpdf.io.source.ByteArrayOutputStream; import com.itextpdf.kernel.pdf.*; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import java.io.ByteArrayInputStream; import java.io.IOException; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class ProducerBuilderIntegrationTest extends ExtendedITextTest { private static String ITEXT_PRODUCER; private static final String MODIFIED_USING = "; modified using "; - @BeforeClass + @BeforeAll public static void beforeClass() throws IOException { byte[] docBytes; try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) { @@ -67,7 +66,7 @@ public void modifiedByItextTest() throws IOException { } try (PdfDocument docReopen = new PdfDocument(new PdfReader(new ByteArrayInputStream(docBytes)))) { - Assert.assertEquals("someProducer" + MODIFIED_USING + ITEXT_PRODUCER + Assertions.assertEquals("someProducer" + MODIFIED_USING + ITEXT_PRODUCER , docReopen.getDocumentInfo().getProducer()); } } @@ -83,7 +82,7 @@ public void modifiedSecondTimeModifiedByItextTest() throws IOException { } try (PdfDocument docReopen = new PdfDocument(new PdfReader(new ByteArrayInputStream(docBytes)))) { - Assert.assertEquals("someProducer; modified using anotherProducer" + MODIFIED_USING + ITEXT_PRODUCER + Assertions.assertEquals("someProducer; modified using anotherProducer" + MODIFIED_USING + ITEXT_PRODUCER , docReopen.getDocumentInfo().getProducer()); } } @@ -99,7 +98,7 @@ public void createdByItextModifiedByItextTest() throws IOException { } try (PdfDocument docReopen = new PdfDocument(new PdfReader(new ByteArrayInputStream(docBytes)))) { - Assert.assertEquals(ITEXT_PRODUCER, docReopen.getDocumentInfo().getProducer()); + Assertions.assertEquals(ITEXT_PRODUCER, docReopen.getDocumentInfo().getProducer()); } } @@ -114,7 +113,7 @@ public void modifiedByItextSecondTimeModifiedByItextTest() throws IOException { } try (PdfDocument docReopen = new PdfDocument(new PdfReader(new ByteArrayInputStream(docBytes)))) { - Assert.assertEquals("someProducer" + MODIFIED_USING + ITEXT_PRODUCER + Assertions.assertEquals("someProducer" + MODIFIED_USING + ITEXT_PRODUCER , docReopen.getDocumentInfo().getProducer()); } } @@ -131,7 +130,7 @@ public void modifiedByItextSecondTimeModifiedThirdTimeModifiedByItextTest() thro } try (PdfDocument docReopen = new PdfDocument(new PdfReader(new ByteArrayInputStream(docBytes)))) { - Assert.assertEquals("someProducer" + MODIFIED_USING + ITEXT_PRODUCER + MODIFIED_USING + Assertions.assertEquals("someProducer" + MODIFIED_USING + ITEXT_PRODUCER + MODIFIED_USING + "thirdProducer" + MODIFIED_USING + ITEXT_PRODUCER, docReopen.getDocumentInfo().getProducer()); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/actions/ProductEventHandlerTest.java b/kernel/src/test/java/com/itextpdf/kernel/actions/ProductEventHandlerTest.java index 1947532913..89fbaf5cde 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/actions/ProductEventHandlerTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/actions/ProductEventHandlerTest.java @@ -29,14 +29,13 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfReader; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.IOException; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class ProductEventHandlerTest extends ExtendedITextTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/kernel/actions/"; @@ -51,14 +50,14 @@ public void documentIdBasedEventTest() throws IOException { EventManager.getInstance().onEvent(new ITextTestEvent(document.getDocumentIdWrapper(), null, "test-event", ProductNameConstant.ITEXT_CORE)); - Assert.assertEquals(alreadyRegisteredEvents + 1, handler.publicGetEvents(document.getDocumentIdWrapper()).size()); + Assertions.assertEquals(alreadyRegisteredEvents + 1, handler.publicGetEvents(document.getDocumentIdWrapper()).size()); AbstractProductProcessITextEvent event = handler.publicGetEvents(document.getDocumentIdWrapper()).get(alreadyRegisteredEvents); - Assert.assertEquals(document.getDocumentIdWrapper(), event.getSequenceId()); - Assert.assertEquals("test-event", event.getEventType()); - Assert.assertEquals(ProductNameConstant.ITEXT_CORE, event.getProductName()); - Assert.assertNotNull(event.getProductData()); + Assertions.assertEquals(document.getDocumentIdWrapper(), event.getSequenceId()); + Assertions.assertEquals("test-event", event.getEventType()); + Assertions.assertEquals(ProductNameConstant.ITEXT_CORE, event.getProductName()); + Assertions.assertNotNull(event.getProductData()); } } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/actions/events/AddFingerPrintEventTest.java b/kernel/src/test/java/com/itextpdf/kernel/actions/events/AddFingerPrintEventTest.java new file mode 100644 index 0000000000..9a3decd2a9 --- /dev/null +++ b/kernel/src/test/java/com/itextpdf/kernel/actions/events/AddFingerPrintEventTest.java @@ -0,0 +1,80 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.actions.events; + +import com.itextpdf.commons.actions.data.ProductData; +import com.itextpdf.io.source.ByteArrayOutputStream; +import com.itextpdf.kernel.logs.KernelLogMessageConstant; +import com.itextpdf.kernel.pdf.PdfDocument; +import com.itextpdf.kernel.pdf.PdfWriter; +import com.itextpdf.test.AssertUtil; +import com.itextpdf.test.ExtendedITextTest; +import com.itextpdf.test.annotations.LogMessage; +import com.itextpdf.test.annotations.LogMessages; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +import java.io.IOException; + +@Tag("UnitTest") +public class AddFingerPrintEventTest extends ExtendedITextTest { + + @Test + public void nullDocumentTest() { + AddFingerPrintEvent addFingerPrintEvent = new AddFingerPrintEvent(null); + AssertUtil.doesNotThrow(() -> addFingerPrintEvent.doAction()); + } + + @Test + @LogMessages(messages = @LogMessage(messageTemplate = + KernelLogMessageConstant.FINGERPRINT_DISABLED_BUT_NO_REQUIRED_LICENCE)) + public void disableFingerPrintAGPLTest() throws IOException { + try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) { + try (PdfDocument doc = new PdfDocument(new PdfWriter(outputStream))) { + doc.getFingerPrint().disableFingerPrint(); + AssertUtil.doesNotThrow(() -> doc.close()); + } + } + } + + @Test + public void enabledFingerPrintAGPLTest() throws java.io.IOException { + try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) { + try (PdfDocument doc = new PdfDocument(new PdfWriter(outputStream))) { + AssertUtil.doesNotThrow(() -> doc.close()); + } + } + } + + @Test + public void disableFingerPrintNoProcessorForProductTest() throws IOException { + try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) { + try (PdfDocument doc = new PdfDocument(new PdfWriter(outputStream))) { + ProductData productData = new ProductData("public product name" + , "product name", "1", 2000, 2024); + doc.getFingerPrint().registerProduct(productData); + AssertUtil.doesNotThrow(() -> doc.close()); + } + } + } +} diff --git a/kernel/src/test/java/com/itextpdf/kernel/actions/events/FlushPdfDocumentEventTest.java b/kernel/src/test/java/com/itextpdf/kernel/actions/events/FlushPdfDocumentEventTest.java index 41a46a66e0..2a55c3d3d6 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/actions/events/FlushPdfDocumentEventTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/actions/events/FlushPdfDocumentEventTest.java @@ -42,15 +42,14 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.ByteArrayInputStream; import java.io.IOException; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(UnitTest.class) +@Tag("UnitTest") public class FlushPdfDocumentEventTest extends ExtendedITextTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/kernel/actions/"; @@ -67,9 +66,9 @@ public void onCloseReportingTest() throws IOException { new FlushPdfDocumentEvent(document).doAction(); AbstractProductProcessITextEvent reportedEvent = access.publicGetEvents(document.getDocumentIdWrapper()).get(initialLength); - Assert.assertTrue(reportedEvent instanceof ConfirmedEventWrapper); + Assertions.assertTrue(reportedEvent instanceof ConfirmedEventWrapper); ConfirmedEventWrapper wrappedEvent = (ConfirmedEventWrapper) reportedEvent; - Assert.assertEquals(event, wrappedEvent.getEvent()); + Assertions.assertEquals(event, wrappedEvent.getEvent()); } } @@ -91,7 +90,7 @@ public void onDemandReportingIgnoredTest() throws IOException { new FlushPdfDocumentEvent(document).doAction(); AbstractProductProcessITextEvent reportedEvent = access.publicGetEvents(document.getDocumentIdWrapper()).get(initialLength); - Assert.assertFalse(reportedEvent instanceof ConfirmedEventWrapper); + Assertions.assertFalse(reportedEvent instanceof ConfirmedEventWrapper); } } @@ -106,16 +105,16 @@ public void onDemandReportingConfirmedTest() throws IOException { EventManager.getInstance().onEvent(event); AbstractProductProcessITextEvent reportedEvent = access.publicGetEvents(document.getDocumentIdWrapper()).get(initialLength); - Assert.assertFalse(reportedEvent instanceof ConfirmedEventWrapper); - Assert.assertEquals(event, reportedEvent); + Assertions.assertFalse(reportedEvent instanceof ConfirmedEventWrapper); + Assertions.assertEquals(event, reportedEvent); EventManager.getInstance().onEvent(new ConfirmEvent(document.getDocumentIdWrapper(), event)); new FlushPdfDocumentEvent(document).doAction(); AbstractProductProcessITextEvent confirmedEvent = access.publicGetEvents(document.getDocumentIdWrapper()).get(initialLength); - Assert.assertTrue(confirmedEvent instanceof ConfirmedEventWrapper); + Assertions.assertTrue(confirmedEvent instanceof ConfirmedEventWrapper); ConfirmedEventWrapper wrappedEvent = (ConfirmedEventWrapper) confirmedEvent; - Assert.assertEquals(event, wrappedEvent.getEvent()); + Assertions.assertEquals(event, wrappedEvent.getEvent()); } } @@ -145,7 +144,7 @@ public void doActionNullDocumentTest() { public void doActionNullEventMapTest() throws IOException { try (PdfDocument document = new DummyPdfDocument(new PdfReader(SOURCE_FOLDER + "hello.pdf"))) { AssertUtil.doesNotThrow(() -> new FlushPdfDocumentEvent(document).doAction()); - Assert.assertTrue(document.getDocumentInfo().getProducer() + Assertions.assertTrue(document.getDocumentInfo().getProducer() .contains("Apryse Group NV (no registered products)")); } } @@ -162,7 +161,7 @@ public void flushEventAfterEachEventTest() throws IOException { try (PdfDocument pdf = new PdfDocument(new PdfReader(new ByteArrayInputStream(baos.toByteArray())))) { String producerLine = pdf.getDocumentInfo().getProducer(); String modifiedByItext = "modified using iText\u00ae Core"; - Assert.assertEquals(producerLine.indexOf(modifiedByItext), producerLine.lastIndexOf(modifiedByItext)); + Assertions.assertEquals(producerLine.indexOf(modifiedByItext), producerLine.lastIndexOf(modifiedByItext)); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/actions/events/ITextCoreProductEventTest.java b/kernel/src/test/java/com/itextpdf/kernel/actions/events/ITextCoreProductEventTest.java index d287454d49..2bab9de8eb 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/actions/events/ITextCoreProductEventTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/actions/events/ITextCoreProductEventTest.java @@ -28,28 +28,27 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.actions.data.ITextCoreProductData; import com.itextpdf.kernel.actions.ecosystem.TestMetaInfo; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class ITextCoreProductEventTest extends ExtendedITextTest { @Test public void openDocumentEventTest() { SequenceId sequenceId = new SequenceId(); ITextCoreProductEvent event = ITextCoreProductEvent.createProcessPdfEvent(sequenceId, new TestMetaInfo("meta data"), EventConfirmationType.ON_CLOSE); - Assert.assertEquals(ITextCoreProductEvent.PROCESS_PDF, event.getEventType()); - Assert.assertEquals(ProductNameConstant.ITEXT_CORE, event.getProductName()); - Assert.assertEquals(EventConfirmationType.ON_CLOSE, event.getConfirmationType()); - Assert.assertEquals(sequenceId, event.getSequenceId()); + Assertions.assertEquals(ITextCoreProductEvent.PROCESS_PDF, event.getEventType()); + Assertions.assertEquals(ProductNameConstant.ITEXT_CORE, event.getProductName()); + Assertions.assertEquals(EventConfirmationType.ON_CLOSE, event.getConfirmationType()); + Assertions.assertEquals(sequenceId, event.getSequenceId()); - Assert.assertEquals(ITextCoreProductData.getInstance().getPublicProductName(), event.getProductData().getPublicProductName()); - Assert.assertEquals(ITextCoreProductData.getInstance().getProductName(), event.getProductData().getProductName()); - Assert.assertEquals(ITextCoreProductData.getInstance().getVersion(), event.getProductData().getVersion()); - Assert.assertEquals(ITextCoreProductData.getInstance().getSinceCopyrightYear(), event.getProductData().getSinceCopyrightYear()); - Assert.assertEquals(ITextCoreProductData.getInstance().getToCopyrightYear(), event.getProductData().getToCopyrightYear()); + Assertions.assertEquals(ITextCoreProductData.getInstance().getPublicProductName(), event.getProductData().getPublicProductName()); + Assertions.assertEquals(ITextCoreProductData.getInstance().getProductName(), event.getProductData().getProductName()); + Assertions.assertEquals(ITextCoreProductData.getInstance().getVersion(), event.getProductData().getVersion()); + Assertions.assertEquals(ITextCoreProductData.getInstance().getSinceCopyrightYear(), event.getProductData().getSinceCopyrightYear()); + Assertions.assertEquals(ITextCoreProductData.getInstance().getToCopyrightYear(), event.getProductData().getToCopyrightYear()); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/actions/events/LinkDocumentIdEventTest.java b/kernel/src/test/java/com/itextpdf/kernel/actions/events/LinkDocumentIdEventTest.java index 15dafa2212..312aba6c76 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/actions/events/LinkDocumentIdEventTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/actions/events/LinkDocumentIdEventTest.java @@ -33,15 +33,14 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfReader; import com.itextpdf.test.AssertUtil; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.IOException; import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class LinkDocumentIdEventTest extends ExtendedITextTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/kernel/actions/"; @@ -69,16 +68,16 @@ public void doActionLinkModifiedDocumentBySequenceIdTest() throws IOException { new LinkDocumentIdEvent(document, sequenceId).doAction(); - Assert.assertEquals(initialSequenceEventsNumber, access.publicGetEvents(sequenceId).size()); + Assertions.assertEquals(initialSequenceEventsNumber, access.publicGetEvents(sequenceId).size()); List actualDocumentEvents = access.publicGetEvents(document.getDocumentIdWrapper()); - Assert.assertEquals(initialDocumentEventsNumber + 3, actualDocumentEvents.size()); + Assertions.assertEquals(initialDocumentEventsNumber + 3, actualDocumentEvents.size()); for (int i = initialDocumentEventsNumber; i < initialDocumentEventsNumber + 3; i++) { AbstractProductProcessITextEvent sequenceEvent = actualDocumentEvents.get(i); - Assert.assertEquals("sequenceId-testing", sequenceEvent.getEventType()); - Assert.assertEquals("test-product-" + (i - initialDocumentEventsNumber), sequenceEvent.getProductName()); - Assert.assertEquals(sequenceId, sequenceEvent.getSequenceId()); + Assertions.assertEquals("sequenceId-testing", sequenceEvent.getEventType()); + Assertions.assertEquals("test-product-" + (i - initialDocumentEventsNumber), sequenceEvent.getProductName()); + Assertions.assertEquals(sequenceId, sequenceEvent.getSequenceId()); } } } @@ -109,16 +108,16 @@ public void doActionLinkModifiedDocumentByIdentifiableElemTest() throws IOExcept SequenceIdManager.setSequenceId(identifiableElement, sequenceId); new LinkDocumentIdEvent(document, identifiableElement).doAction(); - Assert.assertEquals(initialSequenceEventsNumber, access.publicGetEvents(sequenceId).size()); + Assertions.assertEquals(initialSequenceEventsNumber, access.publicGetEvents(sequenceId).size()); List actualDocumentEvents = access.publicGetEvents(document.getDocumentIdWrapper()); - Assert.assertEquals(initialDocumentEventsNumber + 3, actualDocumentEvents.size()); + Assertions.assertEquals(initialDocumentEventsNumber + 3, actualDocumentEvents.size()); for (int i = initialDocumentEventsNumber; i < initialDocumentEventsNumber + 3; i++) { AbstractProductProcessITextEvent sequenceEvent = actualDocumentEvents.get(i); - Assert.assertEquals("sequenceId-testing", sequenceEvent.getEventType()); - Assert.assertEquals("test-product-" + (i - initialDocumentEventsNumber), sequenceEvent.getProductName()); - Assert.assertEquals(sequenceId, sequenceEvent.getSequenceId()); + Assertions.assertEquals("sequenceId-testing", sequenceEvent.getEventType()); + Assertions.assertEquals("test-product-" + (i - initialDocumentEventsNumber), sequenceEvent.getProductName()); + Assertions.assertEquals(sequenceId, sequenceEvent.getSequenceId()); } } } @@ -139,7 +138,7 @@ public void linkSimilarEventsButDifferentInstanceTest() throws IOException { // Check that first event will be linked to document but it was the // similar to stored second event, but they have different instance - Assert.assertEquals(3, access.publicGetEvents(document.getDocumentIdWrapper()).size()); + Assertions.assertEquals(3, access.publicGetEvents(document.getDocumentIdWrapper()).size()); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/colors/ColorTest.java b/kernel/src/test/java/com/itextpdf/kernel/colors/ColorTest.java index 80d89b5fa9..c32d62fd27 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/colors/ColorTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/colors/ColorTest.java @@ -33,13 +33,12 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.colorspace.PdfDeviceCs; import com.itextpdf.kernel.pdf.colorspace.PdfSpecialCs; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class ColorTest extends ExtendedITextTest { private static final float EPS = 1e-4f; @@ -49,7 +48,7 @@ public void convertCmykToRgbTest() { DeviceCmyk cmyk = new DeviceCmyk(0, 0, 0, 0); DeviceRgb rgb = new DeviceRgb(255, 255, 255); - Assert.assertArrayEquals(rgb.colorValue, Color.convertCmykToRgb(cmyk).colorValue, EPS); + Assertions.assertArrayEquals(rgb.colorValue, Color.convertCmykToRgb(cmyk).colorValue, EPS); } @Test @@ -57,7 +56,7 @@ public void convertRgbToCmykTest() { DeviceCmyk cmyk = new DeviceCmyk(0, 0, 0, 0); DeviceRgb rgb = new DeviceRgb(255, 255, 255); - Assert.assertArrayEquals(cmyk.colorValue, Color.convertRgbToCmyk(rgb).colorValue, EPS); + Assertions.assertArrayEquals(cmyk.colorValue, Color.convertRgbToCmyk(rgb).colorValue, EPS); } @Test @@ -65,10 +64,10 @@ public void setColorValueIncorrectComponentsNumberTest() { float[] colorValues = new float[] {0.0f, 0.5f, 0.1f}; Color color = Color.makeColor(PdfColorSpace.makeColorSpace(PdfName.DeviceRGB), colorValues); - Exception e = Assert.assertThrows(PdfException.class, + Exception e = Assertions.assertThrows(PdfException.class, () -> color.setColorValue(new float[] {0.1f, 0.2f}) ); - Assert.assertEquals(KernelExceptionMessageConstant.INCORRECT_NUMBER_OF_COMPONENTS, e.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.INCORRECT_NUMBER_OF_COMPONENTS, e.getMessage()); } @Test @@ -78,9 +77,9 @@ public void equalsAndHashCodeTest() { Color color2 = Color.makeColor(PdfColorSpace.makeColorSpace(PdfName.DeviceRGB), colorValues); boolean result = color1.equals(color2); - Assert.assertTrue(result); + Assertions.assertTrue(result); - Assert.assertEquals(color1.hashCode(), color2.hashCode()); + Assertions.assertEquals(color1.hashCode(), color2.hashCode()); } @Test @@ -90,9 +89,9 @@ public void equalsAndHashCodeNullColorSpacesTest() { Color color2 = new Color(null, colorValues); boolean result = color1.equals(color2); - Assert.assertTrue(result); + Assertions.assertTrue(result); - Assert.assertEquals(color1.hashCode(), color2.hashCode()); + Assertions.assertEquals(color1.hashCode(), color2.hashCode()); } @Test @@ -101,9 +100,9 @@ public void equalsAndHashCodeNullColorValuesTest() { Color color2 = new Color(PdfColorSpace.makeColorSpace(PdfName.DeviceRGB), null); boolean result = color1.equals(color2); - Assert.assertTrue(result); + Assertions.assertTrue(result); - Assert.assertEquals(color1.hashCode(), color2.hashCode()); + Assertions.assertEquals(color1.hashCode(), color2.hashCode()); } @Test @@ -113,9 +112,9 @@ public void notEqualsAndHashCodeDifferentColorSpacesTest() { Color color2 = Color.makeColor(PdfColorSpace.makeColorSpace(PdfName.DeviceGray), colorValues); boolean result = color1.equals(color2); - Assert.assertFalse(result); + Assertions.assertFalse(result); - Assert.assertNotEquals(color1.hashCode(), color2.hashCode()); + Assertions.assertNotEquals(color1.hashCode(), color2.hashCode()); } @Test @@ -124,7 +123,7 @@ public void notEqualsNullObjectTest() { Color color1 = Color.makeColor(PdfColorSpace.makeColorSpace(PdfName.DeviceRGB), colorValues); boolean result = color1.equals(null); - Assert.assertFalse(result); + Assertions.assertFalse(result); } @Test @@ -134,15 +133,15 @@ public void notEqualsDifferentClassesTest() { DeviceCmyk cmyk = new DeviceCmyk(0, 0, 0, 0); boolean result = color1.equals(cmyk); - Assert.assertFalse(result); + Assertions.assertFalse(result); } @Test public void nullColorSpaceTest() { float[] colorValues = new float[] {0.0f, 0.5f, 0.1f}; - Exception e = Assert.assertThrows(PdfException.class, () -> Color.makeColor(null, colorValues)); - Assert.assertEquals("Unknown color space.", e.getMessage()); + Exception e = Assertions.assertThrows(PdfException.class, () -> Color.makeColor(null, colorValues)); + Assertions.assertEquals("Unknown color space.", e.getMessage()); } @Test @@ -150,8 +149,8 @@ public void makeDeviceGrayNullColorValuesTest() { PdfColorSpace colorSpace = PdfColorSpace.makeColorSpace(PdfName.DeviceGray); Color color = Color.makeColor(colorSpace); - Assert.assertTrue(color instanceof DeviceGray); - Assert.assertArrayEquals(new float[] {0.0f}, color.getColorValue(), EPS); + Assertions.assertTrue(color instanceof DeviceGray); + Assertions.assertArrayEquals(new float[] {0.0f}, color.getColorValue(), EPS); } @Test @@ -160,8 +159,8 @@ public void makeDeviceGrayTest() { PdfColorSpace colorSpace = PdfColorSpace.makeColorSpace(PdfName.DeviceGray); Color color = Color.makeColor(colorSpace, colorValues); - Assert.assertTrue(color instanceof DeviceGray); - Assert.assertArrayEquals(new float[] {0.7f}, color.getColorValue(), EPS); + Assertions.assertTrue(color instanceof DeviceGray); + Assertions.assertArrayEquals(new float[] {0.7f}, color.getColorValue(), EPS); } @Test @@ -169,8 +168,8 @@ public void makeDeviceCmykNullColorValuesTest() { PdfColorSpace colorSpace = PdfColorSpace.makeColorSpace(PdfName.DeviceCMYK); Color color = Color.makeColor(colorSpace); - Assert.assertTrue(color instanceof DeviceCmyk); - Assert.assertArrayEquals(new float[] {0.0f, 0.0f, 0.0f, 1.0f}, color.getColorValue(), EPS); + Assertions.assertTrue(color instanceof DeviceCmyk); + Assertions.assertArrayEquals(new float[] {0.0f, 0.0f, 0.0f, 1.0f}, color.getColorValue(), EPS); } @Test @@ -179,14 +178,14 @@ public void makeDeviceCmykTest() { PdfColorSpace colorSpace = PdfColorSpace.makeColorSpace(PdfName.DeviceCMYK); Color color = Color.makeColor(colorSpace, colorValues); - Assert.assertTrue(color instanceof DeviceCmyk); - Assert.assertArrayEquals(colorValues, color.getColorValue(), EPS); + Assertions.assertTrue(color instanceof DeviceCmyk); + Assertions.assertArrayEquals(colorValues, color.getColorValue(), EPS); } @Test public void unknownDeviceCsTest() { - Exception e = Assert.assertThrows(PdfException.class, () -> Color.makeColor(new CustomDeviceCs(null))); - Assert.assertEquals("Unknown color space.", e.getMessage()); + Exception e = Assertions.assertThrows(PdfException.class, () -> Color.makeColor(new CustomDeviceCs(null))); + Assertions.assertEquals("Unknown color space.", e.getMessage()); } @Test @@ -200,8 +199,8 @@ public void makeCalGrayNullColorValuesTest() { Color color = Color.makeColor(colorSpace); - Assert.assertTrue(color instanceof CalGray); - Assert.assertArrayEquals(new float[] {0.0f}, color.getColorValue(), EPS); + Assertions.assertTrue(color instanceof CalGray); + Assertions.assertArrayEquals(new float[] {0.0f}, color.getColorValue(), EPS); } @Test @@ -216,8 +215,8 @@ public void makeCalGrayTest() { Color color = Color.makeColor(colorSpace, colorValues); - Assert.assertTrue(color instanceof CalGray); - Assert.assertArrayEquals(new float[] {0.7f}, color.getColorValue(), EPS); + Assertions.assertTrue(color instanceof CalGray); + Assertions.assertArrayEquals(new float[] {0.7f}, color.getColorValue(), EPS); } @Test @@ -231,8 +230,8 @@ public void makeCalRgbNullColorValuesTest() { Color color = Color.makeColor(colorSpace); - Assert.assertTrue(color instanceof CalRgb); - Assert.assertArrayEquals(new float[] {0.0f, 0.0f, 0.0f}, color.getColorValue(), EPS); + Assertions.assertTrue(color instanceof CalRgb); + Assertions.assertArrayEquals(new float[] {0.0f, 0.0f, 0.0f}, color.getColorValue(), EPS); } @Test @@ -247,8 +246,8 @@ public void makeCalRgbTest() { Color color = Color.makeColor(colorSpace, colorValues); - Assert.assertTrue(color instanceof CalRgb); - Assert.assertArrayEquals(colorValues, color.getColorValue(), EPS); + Assertions.assertTrue(color instanceof CalRgb); + Assertions.assertArrayEquals(colorValues, color.getColorValue(), EPS); } @Test @@ -262,8 +261,8 @@ public void makeLabNullColorValuesTest() { Color color = Color.makeColor(colorSpace); - Assert.assertTrue(color instanceof Lab); - Assert.assertArrayEquals(new float[] {0.0f, 0.0f, 0.0f}, color.getColorValue(), EPS); + Assertions.assertTrue(color instanceof Lab); + Assertions.assertArrayEquals(new float[] {0.0f, 0.0f, 0.0f}, color.getColorValue(), EPS); } @Test @@ -278,16 +277,16 @@ public void makeLabTest() { Color color = Color.makeColor(colorSpace, colorValues); - Assert.assertTrue(color instanceof Lab); - Assert.assertArrayEquals(colorValues, color.getColorValue(), EPS); + Assertions.assertTrue(color instanceof Lab); + Assertions.assertArrayEquals(colorValues, color.getColorValue(), EPS); } @Test public void unknownCieBasedCsTest() { - Exception e = Assert.assertThrows(PdfException.class, + Exception e = Assertions.assertThrows(PdfException.class, () -> Color.makeColor(new CustomPdfCieBasedCs(new PdfArray())) ); - Assert.assertEquals("Unknown color space.", e.getMessage()); + Assertions.assertEquals("Unknown color space.", e.getMessage()); } @Test @@ -301,8 +300,8 @@ public void makeDeviceNNullColorValuesTest() { Color color = Color.makeColor(colorSpace); - Assert.assertTrue(color instanceof DeviceN); - Assert.assertArrayEquals(new float[] {}, color.getColorValue(), EPS); + Assertions.assertTrue(color instanceof DeviceN); + Assertions.assertArrayEquals(new float[] {}, color.getColorValue(), EPS); } @Test @@ -317,8 +316,8 @@ public void makeDeviceNTest() { Color color = Color.makeColor(colorSpace, colorValues); - Assert.assertTrue(color instanceof DeviceN); - Assert.assertArrayEquals(colorValues, color.getColorValue(), EPS); + Assertions.assertTrue(color instanceof DeviceN); + Assertions.assertArrayEquals(colorValues, color.getColorValue(), EPS); } @Test @@ -332,8 +331,8 @@ public void makeIndexedNullColorValuesTest() { Color color = Color.makeColor(colorSpace); - Assert.assertTrue(color instanceof Indexed); - Assert.assertArrayEquals(new float[] {0.0f}, color.getColorValue(), EPS); + Assertions.assertTrue(color instanceof Indexed); + Assertions.assertArrayEquals(new float[] {0.0f}, color.getColorValue(), EPS); } @Test @@ -348,21 +347,21 @@ public void makeIndexedTest() { Color color = Color.makeColor(colorSpace, colorValues); - Assert.assertTrue(color instanceof Indexed); - Assert.assertArrayEquals(new float[] {1f}, color.getColorValue(), EPS); + Assertions.assertTrue(color instanceof Indexed); + Assertions.assertArrayEquals(new float[] {1f}, color.getColorValue(), EPS); } @Test public void unknownSpecialCsTest() { - Exception e = Assert.assertThrows(PdfException.class, + Exception e = Assertions.assertThrows(PdfException.class, () -> Color.makeColor(new CustomPdfSpecialCs(new PdfArray())) ); - Assert.assertEquals("Unknown color space.", e.getMessage()); + Assertions.assertEquals("Unknown color space.", e.getMessage()); } @Test public void createColorWithColorSpaceRgb() { - Assert.assertEquals(ColorConstants.BLACK, Color.createColorWithColorSpace(new float[] { + Assertions.assertEquals(ColorConstants.BLACK, Color.createColorWithColorSpace(new float[] { 0.0F, 0.0F, 0.0F })); } @@ -370,7 +369,7 @@ public void createColorWithColorSpaceRgb() { @Test public void createColorWithColorSpaceGraySpace() { - Assert.assertEquals(new DeviceGray(), Color.createColorWithColorSpace(new float[] { + Assertions.assertEquals(new DeviceGray(), Color.createColorWithColorSpace(new float[] { 0.0F })); } @@ -378,7 +377,7 @@ public void createColorWithColorSpaceGraySpace() { @Test public void createColorWithColorSpaceCmyk() { - Assert.assertEquals(new DeviceCmyk(), Color.createColorWithColorSpace(new float[] { + Assertions.assertEquals(new DeviceCmyk(), Color.createColorWithColorSpace(new float[] { 0.0F, 0.0F, 0.0F, 1F })); } @@ -386,17 +385,17 @@ public void createColorWithColorSpaceCmyk() { @Test public void createColorWithInvalidValueNull() { - Assert.assertNull(Color.createColorWithColorSpace(null)); + Assertions.assertNull(Color.createColorWithColorSpace(null)); } @Test public void createColorWithInvalidNoValues() { - Assert.assertNull(Color.createColorWithColorSpace(new float[] {})); + Assertions.assertNull(Color.createColorWithColorSpace(new float[] {})); } @Test public void createColorWithInvalidMoreThen4Values() { - Assert.assertNull(Color.createColorWithColorSpace(new float[] { + Assertions.assertNull(Color.createColorWithColorSpace(new float[] { 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, })); } diff --git a/kernel/src/test/java/com/itextpdf/kernel/colors/DeviceRgbTest.java b/kernel/src/test/java/com/itextpdf/kernel/colors/DeviceRgbTest.java index cb5cb49a19..c922bbbe7f 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/colors/DeviceRgbTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/colors/DeviceRgbTest.java @@ -26,12 +26,11 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class DeviceRgbTest extends ExtendedITextTest { @Test @@ -42,9 +41,9 @@ public void makeDarkerTest() { // check the resultant darkness of RGB items with using this multiplier float multiplier = Math.max(0f, (150f / 255 - 0.33f) / (150f / 255)); - Assert.assertEquals(multiplier * (50f / 255), darkerRgbColor.getColorValue()[0], 0.0001); - Assert.assertEquals(multiplier * (100f / 255), darkerRgbColor.getColorValue()[1], 0.0001); - Assert.assertEquals(multiplier * (150f / 255), darkerRgbColor.getColorValue()[2], 0.0001); + Assertions.assertEquals(multiplier * (50f / 255), darkerRgbColor.getColorValue()[0], 0.0001); + Assertions.assertEquals(multiplier * (100f / 255), darkerRgbColor.getColorValue()[1], 0.0001); + Assertions.assertEquals(multiplier * (150f / 255), darkerRgbColor.getColorValue()[2], 0.0001); } @Test @@ -55,9 +54,9 @@ public void makeLighterTest() { // check the resultant darkness of RGB items with using this multiplier float multiplier = Math.min(1f, 150f / 255 + 0.33f) / (150f / 255); - Assert.assertEquals(multiplier * (50f / 255), darkerRgbColor.getColorValue()[0], 0.0001); - Assert.assertEquals(multiplier * (100f / 255), darkerRgbColor.getColorValue()[1], 0.0001); - Assert.assertEquals(multiplier * (150f / 255), darkerRgbColor.getColorValue()[2], 0.0001); + Assertions.assertEquals(multiplier * (50f / 255), darkerRgbColor.getColorValue()[0], 0.0001); + Assertions.assertEquals(multiplier * (100f / 255), darkerRgbColor.getColorValue()[1], 0.0001); + Assertions.assertEquals(multiplier * (150f / 255), darkerRgbColor.getColorValue()[2], 0.0001); } // Android-Conversion-Skip-Block-Start (java.awt library isn't available on Android) @@ -67,25 +66,25 @@ public void colorByAWTColorConstantTest() { DeviceRgb rgbColor = new DeviceRgb(java.awt.Color.RED); float[] rgbColorValue = rgbColor.getColorValue(); - Assert.assertEquals(1, rgbColorValue[0], 0.0001); - Assert.assertEquals(0, rgbColorValue[1], 0.0001); - Assert.assertEquals(0, rgbColorValue[2], 0.0001); + Assertions.assertEquals(1, rgbColorValue[0], 0.0001); + Assertions.assertEquals(0, rgbColorValue[1], 0.0001); + Assertions.assertEquals(0, rgbColorValue[2], 0.0001); // GREEN rgbColor = new DeviceRgb(java.awt.Color.GREEN); rgbColorValue = rgbColor.getColorValue(); - Assert.assertEquals(0, rgbColorValue[0], 0.0001); - Assert.assertEquals(1, rgbColorValue[1], 0.0001); - Assert.assertEquals(0, rgbColorValue[2], 0.0001); + Assertions.assertEquals(0, rgbColorValue[0], 0.0001); + Assertions.assertEquals(1, rgbColorValue[1], 0.0001); + Assertions.assertEquals(0, rgbColorValue[2], 0.0001); // BLUE rgbColor = new DeviceRgb(java.awt.Color.BLUE); rgbColorValue = rgbColor.getColorValue(); - Assert.assertEquals(0, rgbColorValue[0], 0.0001); - Assert.assertEquals(0, rgbColorValue[1], 0.0001); - Assert.assertEquals(1, rgbColorValue[2], 0.0001); + Assertions.assertEquals(0, rgbColorValue[0], 0.0001); + Assertions.assertEquals(0, rgbColorValue[1], 0.0001); + Assertions.assertEquals(1, rgbColorValue[2], 0.0001); } @Test @@ -93,9 +92,9 @@ public void colorByAWTColorTest() { java.awt.Color color = new java.awt.Color(50, 100, 150); DeviceRgb rgbColor = new DeviceRgb(color); float[] rgbColorValue = rgbColor.getColorValue(); - Assert.assertEquals(50f / 255, rgbColorValue[0], 0.0001); - Assert.assertEquals(100f / 255, rgbColorValue[1], 0.0001); - Assert.assertEquals(150f / 255, rgbColorValue[2], 0.0001); + Assertions.assertEquals(50f / 255, rgbColorValue[0], 0.0001); + Assertions.assertEquals(100f / 255, rgbColorValue[1], 0.0001); + Assertions.assertEquals(150f / 255, rgbColorValue[2], 0.0001); } // Android-Conversion-Skip-Block-End @@ -104,24 +103,24 @@ public void colorByAWTColorTest() { @LogMessage(messageTemplate = IoLogMessageConstant.COLORANT_INTENSITIES_INVALID, count = 14) }) public void invalidConstructorArgumentsTest() { - Assert.assertEquals(0, getSumOfColorValues(new DeviceRgb(-2f, 0f, 0f)), 0.001f); - Assert.assertEquals(0, getSumOfColorValues(new DeviceRgb(0f, -2f, 0f)), 0.001f); - Assert.assertEquals(0, getSumOfColorValues(new DeviceRgb(0f, 0f, -2f)), 0.001f); + Assertions.assertEquals(0, getSumOfColorValues(new DeviceRgb(-2f, 0f, 0f)), 0.001f); + Assertions.assertEquals(0, getSumOfColorValues(new DeviceRgb(0f, -2f, 0f)), 0.001f); + Assertions.assertEquals(0, getSumOfColorValues(new DeviceRgb(0f, 0f, -2f)), 0.001f); - Assert.assertEquals(1, getSumOfColorValues(new DeviceRgb(2f, 0f, 0f)), 0.001f); - Assert.assertEquals(1, getSumOfColorValues(new DeviceRgb(0f, 2f, 0f)), 0.001f); - Assert.assertEquals(1, getSumOfColorValues(new DeviceRgb(0f, 0f, 2f)), 0.001f); + Assertions.assertEquals(1, getSumOfColorValues(new DeviceRgb(2f, 0f, 0f)), 0.001f); + Assertions.assertEquals(1, getSumOfColorValues(new DeviceRgb(0f, 2f, 0f)), 0.001f); + Assertions.assertEquals(1, getSumOfColorValues(new DeviceRgb(0f, 0f, 2f)), 0.001f); - Assert.assertEquals(0, getSumOfColorValues(new DeviceRgb(-2f, -2f, 0f)), 0.001f); - Assert.assertEquals(0, getSumOfColorValues(new DeviceRgb(-2f, 0f, -2f)), 0.001f); - Assert.assertEquals(0, getSumOfColorValues(new DeviceRgb(0f, -2f, -2f)), 0.001f); + Assertions.assertEquals(0, getSumOfColorValues(new DeviceRgb(-2f, -2f, 0f)), 0.001f); + Assertions.assertEquals(0, getSumOfColorValues(new DeviceRgb(-2f, 0f, -2f)), 0.001f); + Assertions.assertEquals(0, getSumOfColorValues(new DeviceRgb(0f, -2f, -2f)), 0.001f); - Assert.assertEquals(2, getSumOfColorValues(new DeviceRgb(2f, 2f, 0f)), 0.001f); - Assert.assertEquals(2, getSumOfColorValues(new DeviceRgb(2f, 0f, 2f)), 0.001f); - Assert.assertEquals(2, getSumOfColorValues(new DeviceRgb(0f, 2f, 2f)), 0.001f); + Assertions.assertEquals(2, getSumOfColorValues(new DeviceRgb(2f, 2f, 0f)), 0.001f); + Assertions.assertEquals(2, getSumOfColorValues(new DeviceRgb(2f, 0f, 2f)), 0.001f); + Assertions.assertEquals(2, getSumOfColorValues(new DeviceRgb(0f, 2f, 2f)), 0.001f); - Assert.assertEquals(0, getSumOfColorValues(new DeviceRgb(-2f, -2f, -2f)), 0.001f); - Assert.assertEquals(3, getSumOfColorValues(new DeviceRgb(2f, 2f, 2f)), 0.001f); + Assertions.assertEquals(0, getSumOfColorValues(new DeviceRgb(-2f, -2f, -2f)), 0.001f); + Assertions.assertEquals(3, getSumOfColorValues(new DeviceRgb(2f, 2f, 2f)), 0.001f); } private float getSumOfColorValues(DeviceRgb deviceRgb) { diff --git a/kernel/src/test/java/com/itextpdf/kernel/colors/WebColorsTest.java b/kernel/src/test/java/com/itextpdf/kernel/colors/WebColorsTest.java index d6fe23f3ad..f53c38db8b 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/colors/WebColorsTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/colors/WebColorsTest.java @@ -23,12 +23,11 @@ This file is part of the iText (R) project. package com.itextpdf.kernel.colors; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class WebColorsTest extends ExtendedITextTest { private static final double RGB_MAX_VAL = 255.0; @@ -41,7 +40,7 @@ public void getRGBColorBySupportedNameTest() { DeviceRgb resultRgb = WebColors.getRGBColor(colorName); - Assert.assertEquals(cmpRgb, resultRgb); + Assertions.assertEquals(cmpRgb, resultRgb); } @Test @@ -51,7 +50,7 @@ public void getRGBColorByUnsupportedNameTest() { DeviceRgb resultRgb = WebColors.getRGBColor(colorName); - Assert.assertEquals(cmpRgb, resultRgb); + Assertions.assertEquals(cmpRgb, resultRgb); } @Test @@ -62,7 +61,7 @@ public void getRGBAColorByNameTest() { float[] resultRgba = WebColors.getRGBAColor(colorName); - Assert.assertArrayEquals(cmpRgba, resultRgba, delta); + Assertions.assertArrayEquals(cmpRgba, resultRgba, delta); } @Test @@ -74,7 +73,7 @@ public void getRGBAColorByCodeWithHashTest() { float[] resultRgba = WebColors.getRGBAColor(hashHex); - Assert.assertArrayEquals(cmpRgba, resultRgba, delta); + Assertions.assertArrayEquals(cmpRgba, resultRgba, delta); } @Test @@ -86,7 +85,7 @@ public void getRGBAColorByCode6DigitsTest() { float[] resultRgba = WebColors.getRGBAColor(hexString); - Assert.assertArrayEquals(cmpRgba, resultRgba, delta); + Assertions.assertArrayEquals(cmpRgba, resultRgba, delta); } @Test @@ -98,7 +97,7 @@ public void getRGBAColorByCode3DigitsTest() { float[] resultRgba = WebColors.getRGBAColor(hexString); - Assert.assertArrayEquals(cmpRgba, resultRgba, delta); + Assertions.assertArrayEquals(cmpRgba, resultRgba, delta); } @Test @@ -107,7 +106,7 @@ public void getRGBAColorByCodeWrongDigitsNumberTest() { float[] resultRgba = WebColors.getRGBAColor(hexString); - Assert.assertNull(resultRgba); + Assertions.assertNull(resultRgba); } @Test @@ -119,7 +118,7 @@ public void getRGBAColorByRgbObjectTest() { float[] resultRgba = WebColors.getRGBAColor(rgbString); - Assert.assertArrayEquals(cmpRgba, resultRgba, delta); + Assertions.assertArrayEquals(cmpRgba, resultRgba, delta); } @@ -132,7 +131,7 @@ public void getRGBAColorByRgbaObjectTest() { float[] resultRgba = WebColors.getRGBAColor(rgbaString); - Assert.assertArrayEquals(cmpRgba, resultRgba, delta); + Assertions.assertArrayEquals(cmpRgba, resultRgba, delta); } @Test @@ -144,7 +143,7 @@ public void getCMYKColorByDeviceCmykTest() { float[] resultCmyk = WebColors.getCMYKArray(cmykString); - Assert.assertArrayEquals(cmpCmyk, resultCmyk, delta); + Assertions.assertArrayEquals(cmpCmyk, resultCmyk, delta); } @Test @@ -156,7 +155,7 @@ public void getCMYKColorByDeviceCmykWithOpacityTest() { float[] resultCmyk = WebColors.getCMYKArray(cmykString); - Assert.assertArrayEquals(cmpCmyk, resultCmyk, delta); + Assertions.assertArrayEquals(cmpCmyk, resultCmyk, delta); } @@ -169,7 +168,7 @@ public void getCMYKColorByDeviceCmykWithOpacityAndFallbackTest() { float[] resultCmyk = WebColors.getCMYKArray(cmykString); - Assert.assertArrayEquals(cmpCmyk, resultCmyk, delta); + Assertions.assertArrayEquals(cmpCmyk, resultCmyk, delta); } @Test @@ -180,7 +179,7 @@ public void getCMYKColorWithNoBlack() { float[] resultCmyk = WebColors.getCMYKArray(cmykString); - Assert.assertArrayEquals(cmpCmyk, resultCmyk, delta); + Assertions.assertArrayEquals(cmpCmyk, resultCmyk, delta); } @Test @@ -189,20 +188,20 @@ public void getCMYKColorWithInvalidDeviceCmykDefinition() { float[] resultCmyk = WebColors.getCMYKArray(cmykString); - Assert.assertNull(resultCmyk); + Assertions.assertNull(resultCmyk); } @Test public void getCMYKColorWithExceptionDuringParsing() { float[] resultCmyk = WebColors.getCMYKArray(null); - Assert.assertNull(resultCmyk); + Assertions.assertNull(resultCmyk); } @Test public void getRGBAColorWithExceptionDuringParsing() { float[] resultCmyk = WebColors.getRGBAColor(null); - Assert.assertNull(resultCmyk); + Assertions.assertNull(resultCmyk); } @@ -216,7 +215,7 @@ public void getCMYKColorTest() { DeviceCmyk resultCmyk = WebColors.getCMYKColor(cmykString); - Assert.assertArrayEquals(cmpCmyk, resultCmyk.colorValue, delta); + Assertions.assertArrayEquals(cmpCmyk, resultCmyk.colorValue, delta); } @Test @@ -227,7 +226,7 @@ public void getCMYKColorFloatTest() { DeviceCmyk resultCmyk = WebColors.getCMYKColor(cmykString); - Assert.assertArrayEquals(cmpCmyk, resultCmyk.colorValue, delta); + Assertions.assertArrayEquals(cmpCmyk, resultCmyk.colorValue, delta); } @Test @@ -238,6 +237,6 @@ public void getCMYKColorNullTest() { DeviceCmyk resultCmyk = WebColors.getCMYKColor(cmykString); - Assert.assertArrayEquals(cmpCmyk, resultCmyk.colorValue, delta); + Assertions.assertArrayEquals(cmpCmyk, resultCmyk.colorValue, delta); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/colors/gradients/GradientColorStopTest.java b/kernel/src/test/java/com/itextpdf/kernel/colors/gradients/GradientColorStopTest.java index 642d4e8d1d..edf478b61d 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/colors/gradients/GradientColorStopTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/colors/gradients/GradientColorStopTest.java @@ -25,32 +25,31 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.colors.gradients.GradientColorStop.HintOffsetType; import com.itextpdf.kernel.colors.gradients.GradientColorStop.OffsetType; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class GradientColorStopTest extends ExtendedITextTest { @Test public void normalizationTest() { GradientColorStop stopToTest = new GradientColorStop(new float[]{-0.5f, 1.5f, 0.5f, 0.5f}, 1.5, OffsetType.AUTO).setHint(1.5, HintOffsetType.NONE); - Assert.assertArrayEquals(new float[]{0f, 1f, 0.5f}, stopToTest.getRgbArray(), 1e-10f); - Assert.assertEquals(0, stopToTest.getOffset(), 1e-10); - Assert.assertEquals(OffsetType.AUTO, stopToTest.getOffsetType()); - Assert.assertEquals(0, stopToTest.getHintOffset(), 1e-10); - Assert.assertEquals(HintOffsetType.NONE, stopToTest.getHintOffsetType()); + Assertions.assertArrayEquals(new float[]{0f, 1f, 0.5f}, stopToTest.getRgbArray(), 1e-10f); + Assertions.assertEquals(0, stopToTest.getOffset(), 1e-10); + Assertions.assertEquals(OffsetType.AUTO, stopToTest.getOffsetType()); + Assertions.assertEquals(0, stopToTest.getHintOffset(), 1e-10); + Assertions.assertEquals(HintOffsetType.NONE, stopToTest.getHintOffsetType()); } @Test public void cornerCasesTest() { GradientColorStop stopToTest = new GradientColorStop((float[]) null, 1.5, OffsetType.AUTO).setHint(1.5, HintOffsetType.NONE); - Assert.assertArrayEquals(new float[]{0f, 0f, 0f}, stopToTest.getRgbArray(), 1e-10f); - Assert.assertEquals(0, stopToTest.getOffset(), 1e-10); - Assert.assertEquals(OffsetType.AUTO, stopToTest.getOffsetType()); - Assert.assertEquals(0, stopToTest.getHintOffset(), 1e-10); - Assert.assertEquals(HintOffsetType.NONE, stopToTest.getHintOffsetType()); + Assertions.assertArrayEquals(new float[]{0f, 0f, 0f}, stopToTest.getRgbArray(), 1e-10f); + Assertions.assertEquals(0, stopToTest.getOffset(), 1e-10); + Assertions.assertEquals(OffsetType.AUTO, stopToTest.getOffsetType()); + Assertions.assertEquals(0, stopToTest.getHintOffset(), 1e-10); + Assertions.assertEquals(HintOffsetType.NONE, stopToTest.getHintOffsetType()); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/colors/gradients/LinearGradientBuilderTest.java b/kernel/src/test/java/com/itextpdf/kernel/colors/gradients/LinearGradientBuilderTest.java index 60d2fce9a5..ca42f2faf5 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/colors/gradients/LinearGradientBuilderTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/colors/gradients/LinearGradientBuilderTest.java @@ -32,28 +32,27 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.canvas.PdfCanvas; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.File; import java.io.IOException; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class LinearGradientBuilderTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/kernel/colors/gradients/LinearGradientBuilderTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/kernel/colors/gradients/LinearGradientBuilderTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(destinationFolder); } @@ -63,7 +62,7 @@ public void buildWithNullArgumentsAndWithoutSettersTest() { Rectangle targetBoundingBox = new Rectangle(50f, 450f, 300f, 300f); AbstractLinearGradientBuilder gradientBuilder = new LinearGradientBuilder(); - Assert.assertNull(gradientBuilder.buildColor(targetBoundingBox, null, null)); + Assertions.assertNull(gradientBuilder.buildColor(targetBoundingBox, null, null)); } @Test @@ -241,7 +240,7 @@ public void buildWithNullArgumentsAndWithoutStopsTest() { targetBoundingBox.getRight() - 100f, targetBoundingBox.getTop() - 100f) .setSpreadMethod(GradientSpreadMethod.PAD); - Assert.assertNull(gradientBuilder.buildColor(null, null, null)); + Assertions.assertNull(gradientBuilder.buildColor(null, null, null)); } @Test @@ -711,7 +710,7 @@ public void buildWithTwoStopsBeforeTheBeginningAndNoneTest() { .addColorStop(new GradientColorStop(ColorConstants.RED.getColorValue(), -10d, OffsetType.RELATIVE)) .addColorStop(new GradientColorStop(ColorConstants.BLUE.getColorValue(), -5d, OffsetType.RELATIVE)); - Assert.assertNull(gradientBuilder.buildColor(targetBoundingBox, null, null)); + Assertions.assertNull(gradientBuilder.buildColor(targetBoundingBox, null, null)); } @Test @@ -724,7 +723,7 @@ public void buildWithTwoStopsAfterEndAndNoneTest() { .addColorStop(new GradientColorStop(ColorConstants.RED.getColorValue(), 5d, OffsetType.RELATIVE)) .addColorStop(new GradientColorStop(ColorConstants.BLUE.getColorValue(), 10d, OffsetType.RELATIVE)); - Assert.assertNull(gradientBuilder.buildColor(targetBoundingBox, null, null)); + Assertions.assertNull(gradientBuilder.buildColor(targetBoundingBox, null, null)); } @Test @@ -737,7 +736,7 @@ public void buildWithTwoEqualOffsetsStopsAndNoneTest() { .addColorStop(new GradientColorStop(ColorConstants.RED.getColorValue(), 0.5d, OffsetType.RELATIVE)) .addColorStop(new GradientColorStop(ColorConstants.BLUE.getColorValue(), 0.5d, OffsetType.RELATIVE)); - Assert.assertNull(gradientBuilder.buildColor(targetBoundingBox, null, null)); + Assertions.assertNull(gradientBuilder.buildColor(targetBoundingBox, null, null)); } @Test @@ -782,7 +781,7 @@ private void generateAndComparePdfs(String fileName, Rectangle toDraw, AffineTra .fillStroke(); } - Assert.assertNull(new CompareTool() + Assertions.assertNull(new CompareTool() .compareByContent(outPdfPath, sourceFolder + "cmp_" + fileName, destinationFolder, "diff")); } @@ -799,7 +798,7 @@ private void generateAndComparePdfsWithoutArgumentToBuild(String fileName, Recta .fillStroke(); } - Assert.assertNull(new CompareTool() + Assertions.assertNull(new CompareTool() .compareByContent(outPdfPath, sourceFolder + "cmp_" + fileName, destinationFolder, "diff")); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/colors/gradients/StrategyBasedLinearGradientBuilderTest.java b/kernel/src/test/java/com/itextpdf/kernel/colors/gradients/StrategyBasedLinearGradientBuilderTest.java index 90e666cbf4..f86d9664ad 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/colors/gradients/StrategyBasedLinearGradientBuilderTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/colors/gradients/StrategyBasedLinearGradientBuilderTest.java @@ -31,46 +31,45 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.canvas.PdfCanvas; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.File; import java.io.IOException; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; /** * This test class focuses on different types of linear gradient coordinates vector strategies. * Tests related to stop colors work omitted here as they would be equivalent to tests in * {@link LinearGradientBuilderTest} */ -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class StrategyBasedLinearGradientBuilderTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/kernel/colors/gradients/StrategyBasedLinearGradientBuilderTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/kernel/colors/gradients/StrategyBasedLinearGradientBuilderTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(destinationFolder); } @Test public void noSettersTest() { - Assert.assertNull(new StrategyBasedLinearGradientBuilder() + Assertions.assertNull(new StrategyBasedLinearGradientBuilder() .buildColor(new Rectangle(50f, 450f, 500f, 300f), null, null)); } @Test public void noRectangleTest() { - Assert.assertNull(new StrategyBasedLinearGradientBuilder() + Assertions.assertNull(new StrategyBasedLinearGradientBuilder() .addColorStop(new GradientColorStop(ColorConstants.RED.getColorValue(), 0d, OffsetType.RELATIVE)) .addColorStop(new GradientColorStop(ColorConstants.GREEN.getColorValue(), 0.5, OffsetType.RELATIVE)) .addColorStop(new GradientColorStop(ColorConstants.BLUE.getColorValue(), 1d, OffsetType.RELATIVE)) @@ -288,7 +287,7 @@ private void generateAndComparePdfs(String fileName, AffineTransform transform, .fillStroke(); } - Assert.assertNull(new CompareTool() + Assertions.assertNull(new CompareTool() .compareByContent(outPdfPath, sourceFolder + "cmp_" + fileName, destinationFolder, "diff")); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/crypto/CryptoUtilTest.java b/kernel/src/test/java/com/itextpdf/kernel/crypto/CryptoUtilTest.java index 69e69d67e7..652989e2d8 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/crypto/CryptoUtilTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/crypto/CryptoUtilTest.java @@ -29,13 +29,12 @@ This file is part of the iText (R) project. import com.itextpdf.io.source.ByteArrayOutputStream; import com.itextpdf.kernel.exceptions.KernelExceptionMessageConstant; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.BouncyCastleUnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(BouncyCastleUnitTest.class) +@Tag("BouncyCastleUnitTest") public class CryptoUtilTest extends ExtendedITextTest { private static final IBouncyCastleFactory FACTORY = BouncyCastleFactoryCreator.getFactory(); @@ -43,23 +42,23 @@ public class CryptoUtilTest extends ExtendedITextTest { public void createBerStreamTest() { ByteArrayOutputStream baos = new ByteArrayOutputStream(); IASN1OutputStream stream = CryptoUtil.createAsn1OutputStream(baos, FACTORY.createASN1Encoding().getBer()); - Assert.assertNotNull(stream); + Assertions.assertNotNull(stream); } @Test public void createDerStreamTest() { ByteArrayOutputStream baos = new ByteArrayOutputStream(); IASN1OutputStream stream = CryptoUtil.createAsn1OutputStream(baos, FACTORY.createASN1Encoding().getDer()); - Assert.assertNotNull(stream); + Assertions.assertNotNull(stream); } @Test public void createUnsupportedEncodingStreamTest() { ByteArrayOutputStream baos = new ByteArrayOutputStream(); - Exception e = Assert.assertThrows(UnsupportedOperationException.class, + Exception e = Assertions.assertThrows(UnsupportedOperationException.class, () -> CryptoUtil.createAsn1OutputStream(baos, "DL") ); - Assert.assertEquals(MessageFormatUtil.format(KernelExceptionMessageConstant.UNSUPPORTED_ASN1_ENCODING, "DL"), + Assertions.assertEquals(MessageFormatUtil.format(KernelExceptionMessageConstant.UNSUPPORTED_ASN1_ENCODING, "DL"), e.getMessage()); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/crypto/EncryptionInApprovedModeTest.java b/kernel/src/test/java/com/itextpdf/kernel/crypto/EncryptionInApprovedModeTest.java index b8b2ea84ac..46000b536a 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/crypto/EncryptionInApprovedModeTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/crypto/EncryptionInApprovedModeTest.java @@ -34,18 +34,17 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.BouncyCastleIntegrationTest; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.security.Security; -import org.junit.AfterClass; -import org.junit.Assume; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(BouncyCastleIntegrationTest.class) +@Tag("BouncyCastleIntegrationTest") public class EncryptionInApprovedModeTest extends ExtendedITextTest { private static final IBouncyCastleFactory FACTORY = BouncyCastleFactoryCreator.getFactory(); @@ -64,14 +63,14 @@ public class EncryptionInApprovedModeTest extends ExtendedITextTest { */ public static byte[] OWNER = "World".getBytes(StandardCharsets.ISO_8859_1); - @BeforeClass + @BeforeAll public static void beforeClass() { - Assume.assumeTrue(FACTORY.isInApprovedOnlyMode()); + Assumptions.assumeTrue(FACTORY.isInApprovedOnlyMode()); createOrClearDestinationFolder(destinationFolder); Security.addProvider(FACTORY.getProvider()); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(destinationFolder); } diff --git a/kernel/src/test/java/com/itextpdf/kernel/crypto/PdfDecryptingTest.java b/kernel/src/test/java/com/itextpdf/kernel/crypto/PdfDecryptingTest.java index 4ee4afe71f..46537d89ec 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/crypto/PdfDecryptingTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/crypto/PdfDecryptingTest.java @@ -34,7 +34,6 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.BouncyCastleIntegrationTest; import java.io.IOException; import java.io.InputStream; @@ -46,12 +45,12 @@ This file is part of the iText (R) project. import java.security.cert.Certificate; import java.security.cert.CertificateException; import java.security.spec.PKCS8EncodedKeySpec; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(BouncyCastleIntegrationTest.class) +@Tag("BouncyCastleIntegrationTest") public class PdfDecryptingTest extends ExtendedITextTest { private static final String CERTS_SRC = "./src/test/resources/com/itextpdf/kernel/crypto/PdfDecryptingTest/certs/"; @@ -59,7 +58,7 @@ public class PdfDecryptingTest extends ExtendedITextTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/kernel/crypto/PdfDecryptingTest/"; private static final String PROVIDER_NAME = BouncyCastleFactoryCreator.getFactory().getProviderName(); - @BeforeClass + @BeforeAll public static void setUpBeforeClass() { createOrClearDestinationFolder(DESTINATION_FOLDER); Security.addProvider(BouncyCastleFactoryCreator.getFactory().getProvider()); @@ -271,7 +270,7 @@ private void decryptWithPassword(String fileName, byte[] password) throws IOExce ReaderProperties readerProperties = new ReaderProperties().setPassword(password); try (PdfDocument pdfDocument = new PdfDocument(new PdfReader(SOURCE_FOLDER + fileName, readerProperties))) { - Assert.assertTrue( + Assertions.assertTrue( PdfTextExtractor.getTextFromPage(pdfDocument.getFirstPage()).startsWith("Content encrypted by ")); } } @@ -283,7 +282,7 @@ private void decryptWithCertificate(String fileName, String certificateName, Pri certificate, certificateKey, PROVIDER_NAME, null); try (PdfDocument pdfDocument = new PdfDocument(new PdfReader(SOURCE_FOLDER + fileName, readerProperties))) { - Assert.assertTrue( + Assertions.assertTrue( PdfTextExtractor.getTextFromPage(pdfDocument.getFirstPage()).startsWith("Content encrypted by ")); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/crypto/PdfEncryptingTest.java b/kernel/src/test/java/com/itextpdf/kernel/crypto/PdfEncryptingTest.java index 15c5d954a4..c943796723 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/crypto/PdfEncryptingTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/crypto/PdfEncryptingTest.java @@ -43,7 +43,6 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.BouncyCastleIntegrationTest; import java.io.IOException; import java.io.InputStream; @@ -54,13 +53,13 @@ This file is part of the iText (R) project. import java.security.Security; import java.security.cert.Certificate; import java.security.spec.PKCS8EncodedKeySpec; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(BouncyCastleIntegrationTest.class) +@Tag("BouncyCastleIntegrationTest") public class PdfEncryptingTest extends ExtendedITextTest { private static final String CERTS_SRC = "./src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptingTest/certs/"; private static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/kernel/crypto/PdfEncryptingTest/"; @@ -71,13 +70,13 @@ public class PdfEncryptingTest extends ExtendedITextTest { private static final String PROVIDER_NAME = BouncyCastleFactoryCreator.getFactory().getProviderName(); - @BeforeClass + @BeforeAll public static void setUpBeforeClass() { createOrClearDestinationFolder(DESTINATION_FOLDER); Security.addProvider(BouncyCastleFactoryCreator.getFactory().getProvider()); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(DESTINATION_FOLDER); } @@ -122,7 +121,7 @@ public void encryptWithPasswordAes256Pdf2() throws IOException, InterruptedExcep public void encryptWithCertificateAes256Rsa() throws GeneralSecurityException, IOException, InterruptedException { if (BouncyCastleFactoryCreator.getFactory().isInApprovedOnlyMode()) { // RSA PKCS1.5 encryption disallowed - Assert.assertThrows(AbstractFipsUnapprovedOperationError.class, + Assertions.assertThrows(AbstractFipsUnapprovedOperationError.class, () -> encryptWithCertificate("encryptWithCertificateAes256Rsa.pdf", "SHA256withRSA.crt")); } else { encryptWithCertificate("encryptWithCertificateAes256Rsa.pdf", "SHA256withRSA.crt"); @@ -132,21 +131,21 @@ public void encryptWithCertificateAes256Rsa() throws GeneralSecurityException, I @Test @LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT), ignore = true) public void encryptWithCertificateAes256EcdsaP256() { - String exceptionTest = Assert.assertThrows(PdfException.class, + String exceptionTest = Assertions.assertThrows(PdfException.class, () -> encryptWithCertificate("encryptWithCertificateAes256EcdsaP256.pdf", "SHA256withECDSA_P256.crt")) .getMessage(); - Assert.assertEquals(MessageFormatUtil.format( + Assertions.assertEquals(MessageFormatUtil.format( KernelExceptionMessageConstant.ALGORITHM_IS_NOT_SUPPORTED, "1.2.840.10045.2.1"), exceptionTest); } @Test @LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT), ignore = true) public void encryptWithCertificateAes256EcdsaBrainpoolP256R1() { - String exceptionTest = Assert.assertThrows(PdfException.class, + String exceptionTest = Assertions.assertThrows(PdfException.class, () -> encryptWithCertificate( "encryptWithCertificateAes256EcdsaBrainpoolP256R1.pdf", "SHA256withECDSA_brainpoolP256r1.crt")) .getMessage(); - Assert.assertEquals(MessageFormatUtil.format( + Assertions.assertEquals(MessageFormatUtil.format( KernelExceptionMessageConstant.ALGORITHM_IS_NOT_SUPPORTED, "1.2.840.10045.2.1"), exceptionTest); } @@ -162,7 +161,7 @@ private void encryptWithPassword(String fileName, int encryptionType, boolean pd PdfDocument document = new PdfDocument(writer)) { writeTextToDocument(document); } - Assert.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + fileName, + Assertions.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + fileName, SOURCE_FOLDER + "cmp_" + fileName, DESTINATION_FOLDER, "diff", USER_PASSWORD, USER_PASSWORD)); } @@ -179,7 +178,7 @@ private void encryptWithCertificate(String fileName, String certificatePath) PrivateKey privateKey = readPrivateKey("SHA256withRSA.key", "RSA"); compareTool.getCmpReaderProperties().setPublicKeySecurityParams(certificate, privateKey, PROVIDER_NAME, null); compareTool.getOutReaderProperties().setPublicKeySecurityParams(certificate, privateKey, PROVIDER_NAME, null); - Assert.assertNull(compareTool + Assertions.assertNull(compareTool .compareByContent(DESTINATION_FOLDER + fileName, SOURCE_FOLDER + "cmp_" + fileName, DESTINATION_FOLDER, "diff")); } diff --git a/kernel/src/test/java/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest.java b/kernel/src/test/java/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest.java index 3ba431a89a..68c71a0290 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest.java @@ -50,7 +50,6 @@ This file is part of the iText (R) project. import com.itextpdf.test.ITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.BouncyCastleIntegrationTest; import java.io.IOException; import java.io.InputStream; @@ -60,11 +59,11 @@ This file is part of the iText (R) project. import java.security.Security; import java.security.cert.Certificate; import java.security.cert.CertificateException; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; /** @@ -79,7 +78,7 @@ This file is part of the iText (R) project. * Extension (JCE) Unlimited Strength Jurisdiction Policy Files. These JARs * are available for download from http://java.oracle.com/ in eligible countries. */ -@Category(BouncyCastleIntegrationTest.class) +@Tag("BouncyCastleIntegrationTest") public class PdfEncryptionManuallyPortedTest extends ExtendedITextTest { private static final IBouncyCastleFactory FACTORY = BouncyCastleFactoryCreator.getFactory(); @@ -100,13 +99,13 @@ public class PdfEncryptionManuallyPortedTest extends ExtendedITextTest { private PrivateKey privateKey; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); Security.addProvider(FACTORY.getProvider()); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(destinationFolder); } @@ -120,7 +119,7 @@ public void encryptWithCertificateStandard128() throws IOException, InterruptedE int encryptionType = EncryptionConstants.STANDARD_ENCRYPTION_128; if (FACTORY.isInApprovedOnlyMode()) { // RSA PKCS1.5 encryption disallowed - Assert.assertThrows(AbstractFipsUnapprovedOperationError.class, + Assertions.assertThrows(AbstractFipsUnapprovedOperationError.class, () -> encryptWithCertificate(filename, encryptionType, CompressionConstants.DEFAULT_COMPRESSION)); } else { encryptWithCertificate(filename, encryptionType, CompressionConstants.DEFAULT_COMPRESSION); @@ -136,7 +135,7 @@ public void encryptWithCertificateStandard40() throws IOException, InterruptedEx int encryptionType = EncryptionConstants.STANDARD_ENCRYPTION_40; if (FACTORY.isInApprovedOnlyMode()) { // RSA PKCS1.5 encryption disallowed - Assert.assertThrows(AbstractFipsUnapprovedOperationError.class, + Assertions.assertThrows(AbstractFipsUnapprovedOperationError.class, () -> encryptWithCertificate(filename, encryptionType, CompressionConstants.DEFAULT_COMPRESSION)); } else { encryptWithCertificate(filename, encryptionType, CompressionConstants.DEFAULT_COMPRESSION); @@ -152,7 +151,7 @@ public void encryptWithCertificateStandard128NoCompression() throws IOException, int encryptionType = EncryptionConstants.STANDARD_ENCRYPTION_128; if (FACTORY.isInApprovedOnlyMode()) { // RSA PKCS1.5 encryption disallowed - Assert.assertThrows(AbstractFipsUnapprovedOperationError.class, + Assertions.assertThrows(AbstractFipsUnapprovedOperationError.class, () -> encryptWithCertificate(filename, encryptionType, CompressionConstants.NO_COMPRESSION)); } else { encryptWithCertificate(filename, encryptionType, CompressionConstants.NO_COMPRESSION); @@ -168,7 +167,7 @@ public void encryptWithCertificateStandard40NoCompression() throws IOException, int encryptionType = EncryptionConstants.STANDARD_ENCRYPTION_40; if (FACTORY.isInApprovedOnlyMode()) { // RSA PKCS1.5 encryption disallowed - Assert.assertThrows(AbstractFipsUnapprovedOperationError.class, + Assertions.assertThrows(AbstractFipsUnapprovedOperationError.class, () -> encryptWithCertificate(filename, encryptionType, CompressionConstants.NO_COMPRESSION)); } else { encryptWithCertificate(filename, encryptionType, CompressionConstants.NO_COMPRESSION); @@ -184,7 +183,7 @@ public void encryptWithCertificateAes128() throws IOException, InterruptedExcept int encryptionType = EncryptionConstants.ENCRYPTION_AES_128; if (FACTORY.isInApprovedOnlyMode()) { // RSA PKCS1.5 encryption disallowed - Assert.assertThrows(AbstractFipsUnapprovedOperationError.class, + Assertions.assertThrows(AbstractFipsUnapprovedOperationError.class, () -> encryptWithCertificate(filename, encryptionType, CompressionConstants.DEFAULT_COMPRESSION)); } else { encryptWithCertificate(filename, encryptionType, CompressionConstants.DEFAULT_COMPRESSION); @@ -200,7 +199,7 @@ public void encryptWithCertificateAes256() throws IOException, InterruptedExcept int encryptionType = EncryptionConstants.ENCRYPTION_AES_256; if (FACTORY.isInApprovedOnlyMode()) { // RSA PKCS1.5 encryption disallowed - Assert.assertThrows(AbstractFipsUnapprovedOperationError.class, + Assertions.assertThrows(AbstractFipsUnapprovedOperationError.class, () -> encryptWithCertificate(filename, encryptionType, CompressionConstants.DEFAULT_COMPRESSION)); } else { encryptWithCertificate(filename, encryptionType, CompressionConstants.DEFAULT_COMPRESSION); @@ -216,7 +215,7 @@ public void encryptWithCertificateAes128NoCompression() throws IOException, Inte int encryptionType = EncryptionConstants.ENCRYPTION_AES_128; if (FACTORY.isInApprovedOnlyMode()) { // RSA PKCS1.5 encryption disallowed - Assert.assertThrows(AbstractFipsUnapprovedOperationError.class, + Assertions.assertThrows(AbstractFipsUnapprovedOperationError.class, () -> encryptWithCertificate(filename, encryptionType, CompressionConstants.NO_COMPRESSION)); } else { encryptWithCertificate(filename, encryptionType, CompressionConstants.NO_COMPRESSION); @@ -232,7 +231,7 @@ public void encryptWithCertificateAes256NoCompression() throws IOException, Inte int encryptionType = EncryptionConstants.ENCRYPTION_AES_256; if (FACTORY.isInApprovedOnlyMode()) { // RSA PKCS1.5 encryption disallowed - Assert.assertThrows(AbstractFipsUnapprovedOperationError.class, + Assertions.assertThrows(AbstractFipsUnapprovedOperationError.class, () -> encryptWithCertificate(filename, encryptionType, CompressionConstants.NO_COMPRESSION)); } else { encryptWithCertificate(filename, encryptionType, CompressionConstants.NO_COMPRESSION); @@ -253,10 +252,10 @@ public void openEncryptedDocWithWrongPrivateKey() FACTORY.getProviderName(), null))) { - Exception e = Assert.assertThrows(PdfException.class, + Exception e = Assertions.assertThrows(PdfException.class, () -> new PdfDocument(reader) ); - Assert.assertEquals(KernelExceptionMessageConstant.PDF_DECRYPTION, e.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.PDF_DECRYPTION, e.getMessage()); } } @@ -271,7 +270,7 @@ public void openEncryptedWithCertificateDocWithDefaultKeyLength() throws IOExcep new ReaderProperties().setPublicKeySecurityParams(cert, getPrivateKey(), FACTORY.getProviderName(), null)); PdfDocument document = new PdfDocument(reader)) { - Assert.assertFalse(document.getTrailer().getAsDictionary(PdfName.Encrypt).containsKey(PdfName.Length)); + Assertions.assertFalse(document.getTrailer().getAsDictionary(PdfName.Encrypt).containsKey(PdfName.Length)); } } @@ -304,7 +303,7 @@ public void encryptWithCertificate(String filename, int encryptionType, int comp String compareResult = compareTool.compareByContent(outFileName, sourceFolder + "cmp_" + filename, destinationFolder, "diff_"); if (compareResult != null) { - Assert.fail(compareResult); + Assertions.fail(compareResult); } checkEncryptedWithCertificateDocumentStamping(filename, cert); @@ -334,10 +333,10 @@ public void checkDecryptedWithCertificateContent(String filename, Certificate ce PdfPage page = document.getPage(1); String s = new String(page.getStreamBytes(0)); - Assert.assertTrue("Expected content: \n" + pageContent, s.contains(pageContent)); - Assert.assertEquals("Encrypted custom", customInfoEntryValue, + Assertions.assertTrue(s.contains(pageContent), "Expected content: \n" + pageContent); + Assertions.assertEquals(customInfoEntryValue, document.getTrailer().getAsDictionary(PdfName.Info).getAsString(new PdfName(customInfoEntryKey)) - .toUnicodeString()); + .toUnicodeString(), "Encrypted custom"); document.close(); } @@ -360,7 +359,7 @@ public void checkEncryptedWithCertificateDocumentStamping(String filename, Certi destinationFolder, "diff_"); if (compareResult != null) { - Assert.fail(compareResult); + Assertions.fail(compareResult); } } @@ -385,7 +384,7 @@ public void checkEncryptedWithCertificateDocumentAppending(String filename, Cert PdfPage secondPage = appendedDoc.getPage(2); PdfString helloWorldPdfString = secondPage.getPdfObject().getAsString(PdfName.Default); String actualHelloWorldStringValue = helloWorldPdfString != null ? helloWorldPdfString.getValue() : null; - Assert.assertEquals(actualHelloWorldStringValue, helloWorldStringValue); + Assertions.assertEquals(actualHelloWorldStringValue, helloWorldStringValue); appendedDoc.close(); CompareTool compareTool = new CompareTool().enableEncryptionCompare(); @@ -398,7 +397,7 @@ public void checkEncryptedWithCertificateDocumentAppending(String filename, Cert destinationFolder, "diff_"); if (compareResult != null) { - Assert.fail(compareResult); + Assertions.fail(compareResult); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/crypto/PdfReaderCustomFilterTest.java b/kernel/src/test/java/com/itextpdf/kernel/crypto/PdfReaderCustomFilterTest.java index 30cbc09744..e85a2ecbb3 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/crypto/PdfReaderCustomFilterTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/crypto/PdfReaderCustomFilterTest.java @@ -28,22 +28,21 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfReader; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfReaderCustomFilterTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/kernel/crypto/PdfReaderCustomFilterTest/"; @Test public void encryptedDocumentCustomFilterStandartTest() throws IOException { try (PdfReader reader = new PdfReader(sourceFolder + "customSecurityHandler.pdf")) { - Exception e = Assert.assertThrows(UnsupportedSecurityHandlerException.class, () -> new PdfDocument(reader)); - Assert.assertEquals(MessageFormatUtil.format(KernelExceptionMessageConstant.UNSUPPORTED_SECURITY_HANDLER, + Exception e = Assertions.assertThrows(UnsupportedSecurityHandlerException.class, () -> new PdfDocument(reader)); + Assertions.assertEquals(MessageFormatUtil.format(KernelExceptionMessageConstant.UNSUPPORTED_SECURITY_HANDLER, "/Standart"), e.getMessage()); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/crypto/UnencryptedWrapperTest.java b/kernel/src/test/java/com/itextpdf/kernel/crypto/UnencryptedWrapperTest.java index 8bf0a9d432..e6c5b9c056 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/crypto/UnencryptedWrapperTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/crypto/UnencryptedWrapperTest.java @@ -42,30 +42,29 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.BouncyCastleIntegrationTest; import java.io.OutputStream; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.FileOutputStream; import java.io.IOException; import java.nio.charset.StandardCharsets; -@Category(BouncyCastleIntegrationTest.class) +@Tag("BouncyCastleIntegrationTest") public class UnencryptedWrapperTest extends ExtendedITextTest { public static final String destinationFolder = "./target/test/com/itextpdf/kernel/crypto/UnencryptedWrapperTest/"; public static final String sourceFolder = "./src/test/resources/com/itextpdf/kernel/crypto/UnencryptedWrapperTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(destinationFolder); } @@ -115,7 +114,7 @@ private void createWrapper(String encryptedName, String wrapperName, String cryp canvas.release(); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outPath, cmpPath, destinationFolder, diff)); + Assertions.assertNull(new CompareTool().compareByContent(outPath, cmpPath, destinationFolder, diff)); } private void extractEncrypted(String encryptedName, String wrapperName, byte[] password) throws IOException, InterruptedException { @@ -133,15 +132,15 @@ private void extractEncrypted(String encryptedName, String wrapperName, byte[] p document.close(); PdfEncryptedPayload ep = encryptedDocument.getEncryptedPayload(); - Assert.assertEquals(PdfEncryptedPayloadFileSpecFactory.generateFileDisplay(ep), encryptedDocument.getName()); + Assertions.assertEquals(PdfEncryptedPayloadFileSpecFactory.generateFileDisplay(ep), encryptedDocument.getName()); if (password != null) { - Assert.assertNull(new CompareTool().compareByContent(outPath, cmpPath, destinationFolder, diff, password, password)); + Assertions.assertNull(new CompareTool().compareByContent(outPath, cmpPath, destinationFolder, diff, password, password)); } else { RandomAccessFileOrArray raf = new RandomAccessFileOrArray(new RandomAccessSourceFactory().createBestSource(cmpPath)); byte[] cmpBytes = new byte[(int) raf.length()]; raf.readFully(cmpBytes); raf.close(); - Assert.assertArrayEquals(cmpBytes, encryptedDocumentBytes); + Assertions.assertArrayEquals(cmpBytes, encryptedDocumentBytes); } } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/crypto/pdfencryption/PdfEncryptionTest.java b/kernel/src/test/java/com/itextpdf/kernel/crypto/pdfencryption/PdfEncryptionTest.java index d9158bd82d..8a764afd39 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/crypto/pdfencryption/PdfEncryptionTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/crypto/pdfencryption/PdfEncryptionTest.java @@ -55,13 +55,11 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.xmp.XMPConst; import com.itextpdf.kernel.xmp.XMPException; import com.itextpdf.kernel.xmp.XMPMeta; -import com.itextpdf.kernel.xmp.XMPMetaFactory; import com.itextpdf.kernel.xmp.properties.XMPProperty; import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.ITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.BouncyCastleIntegrationTest; import java.io.IOException; import java.io.InputStream; @@ -72,12 +70,12 @@ This file is part of the iText (R) project. import java.security.Security; import java.security.cert.Certificate; import java.security.cert.CertificateException; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.Assume; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; @@ -93,7 +91,7 @@ This file is part of the iText (R) project. * Extension (JCE) Unlimited Strength Jurisdiction Policy Files. These JARs * are available for download from http://java.oracle.com/ in eligible countries. */ -@Category(BouncyCastleIntegrationTest.class) +@Tag("BouncyCastleIntegrationTest") public class PdfEncryptionTest extends ExtendedITextTest { private static final IBouncyCastleFactory FACTORY = BouncyCastleFactoryCreator.getFactory(); @@ -109,13 +107,13 @@ public class PdfEncryptionTest extends ExtendedITextTest { PdfEncryptionTestUtils encryptionUtil = new PdfEncryptionTestUtils(destinationFolder, sourceFolder); - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); Security.addProvider(FACTORY.getProvider()); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(destinationFolder); } @@ -197,8 +195,8 @@ public void encryptWithPasswordAes256NoCompression() throws IOException, Interru ignore = true)) public void openEncryptedDocWithoutPassword() throws IOException { try (PdfReader reader = new PdfReader(sourceFolder + "encryptedWithPasswordStandard40.pdf")) { - Exception e = Assert.assertThrows(BadPasswordException.class, () -> new PdfDocument(reader)); - Assert.assertEquals(KernelExceptionMessageConstant.BAD_USER_PASSWORD, e.getMessage()); + Exception e = Assertions.assertThrows(BadPasswordException.class, () -> new PdfDocument(reader)); + Assertions.assertEquals(KernelExceptionMessageConstant.BAD_USER_PASSWORD, e.getMessage()); } } @@ -209,8 +207,8 @@ public void openEncryptedDocWithWrongPassword() throws IOException { try (PdfReader reader = new PdfReader(sourceFolder + "encryptedWithPasswordStandard40.pdf", new ReaderProperties().setPassword("wrong_password".getBytes(StandardCharsets.ISO_8859_1)))) { - Exception e = Assert.assertThrows(BadPasswordException.class, () -> new PdfDocument(reader)); - Assert.assertEquals(KernelExceptionMessageConstant.BAD_USER_PASSWORD, e.getMessage()); + Exception e = Assertions.assertThrows(BadPasswordException.class, () -> new PdfDocument(reader)); + Assertions.assertEquals(KernelExceptionMessageConstant.BAD_USER_PASSWORD, e.getMessage()); } } @@ -218,8 +216,8 @@ public void openEncryptedDocWithWrongPassword() throws IOException { public void openEncryptedDocWithoutCertificate() throws IOException { try (PdfReader reader = new PdfReader(sourceFolder + "encryptedWithCertificateAes128.pdf")) { - Exception e = Assert.assertThrows(PdfException.class, () -> new PdfDocument(reader)); - Assert.assertEquals( + Exception e = Assertions.assertThrows(PdfException.class, () -> new PdfDocument(reader)); + Assertions.assertEquals( KernelExceptionMessageConstant.CERTIFICATE_IS_NOT_PROVIDED_DOCUMENT_IS_ENCRYPTED_WITH_PUBLIC_KEY_CERTIFICATE, e.getMessage()); } @@ -237,10 +235,10 @@ public void openEncryptedDocWithoutPrivateKey() throws IOException, CertificateE FACTORY.getProviderName(), null))) { - Exception e = Assert.assertThrows(PdfException.class, + Exception e = Assertions.assertThrows(PdfException.class, () -> new PdfDocument(reader) ); - Assert.assertEquals(KernelExceptionMessageConstant.BAD_CERTIFICATE_AND_KEY, e.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.BAD_CERTIFICATE_AND_KEY, e.getMessage()); } } @@ -257,10 +255,10 @@ public void openEncryptedDocWithWrongCertificate() FACTORY.getProviderName(), null))) { - Exception e = Assert.assertThrows(PdfException.class, + Exception e = Assertions.assertThrows(PdfException.class, () -> new PdfDocument(reader) ); - Assert.assertEquals(KernelExceptionMessageConstant.BAD_CERTIFICATE_AND_KEY, e.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.BAD_CERTIFICATE_AND_KEY, e.getMessage()); } } @@ -278,10 +276,10 @@ public void openEncryptedDocWithWrongCertificateAndPrivateKey() FACTORY.getProviderName(), null))) { - Exception e = Assert.assertThrows(PdfException.class, + Exception e = Assertions.assertThrows(PdfException.class, () -> new PdfDocument(reader) ); - Assert.assertEquals(KernelExceptionMessageConstant.BAD_CERTIFICATE_AND_KEY, e.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.BAD_CERTIFICATE_AND_KEY, e.getMessage()); } } @@ -292,11 +290,11 @@ public void metadataReadingInEncryptedDoc() throws IOException, XMPException { PdfReader reader = new PdfReader(sourceFolder + "encryptedWithPlainMetadata.pdf", new ReaderProperties().setPassword(PdfEncryptionTestUtils.OWNER)); PdfDocument doc = new PdfDocument(reader); - XMPMeta xmpMeta = XMPMetaFactory.parseFromBuffer(doc.getXmpMetadata()); + XMPMeta xmpMeta = doc.getXmpMetadata(); XMPProperty creatorToolXmp = xmpMeta.getProperty(XMPConst.NS_XMP, "CreatorTool"); doc.close(); - Assert.assertNotNull(creatorToolXmp); - Assert.assertEquals("iText", creatorToolXmp.getValue()); + Assertions.assertNotNull(creatorToolXmp); + Assertions.assertEquals("iText", creatorToolXmp.getValue()); } @Test @@ -328,7 +326,7 @@ public void copyEncryptedDocument() throws GeneralSecurityException, IOException srcDoc.close(); destDoc.close(); - Assert.assertNull(new CompareTool() + Assertions.assertNull(new CompareTool() .compareByContent(destinationFolder + fileName, sourceFolder + "cmp_" + fileName, destinationFolder, "diff_")); } @@ -354,8 +352,8 @@ public void stampDocNoUserPassword() throws IOException { try (PdfReader reader = new PdfReader(sourceFolder + "noUserPassword.pdf"); PdfWriter writer = CompareTool.createTestPdfWriter(destinationFolder + fileName)) { - Exception e = Assert.assertThrows(BadPasswordException.class, () -> new PdfDocument(reader, writer)); - Assert.assertEquals(BadPasswordException.PdfReaderNotOpenedWithOwnerPassword, e.getMessage()); + Exception e = Assertions.assertThrows(BadPasswordException.class, () -> new PdfDocument(reader, writer)); + Assertions.assertEquals(BadPasswordException.PdfReaderNotOpenedWithOwnerPassword, e.getMessage()); } } @@ -395,6 +393,42 @@ public void encryptWithPasswordAes128EmbeddedFilesOnly() throws IOException { textContent, ERROR_IS_EXPECTED); } + @Test + @LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT, + ignore = true)) + public void encryptWithPasswordAes256EmbeddedFilesOnly() throws IOException, InterruptedException { + String filename = "encryptWithPasswordAes256EmbeddedFilesOnly.pdf"; + int encryptionType = EncryptionConstants.ENCRYPTION_AES_256 | EncryptionConstants.EMBEDDED_FILES_ONLY; + + String outFileName = destinationFolder + filename; + int permissions = EncryptionConstants.ALLOW_SCREENREADERS; + PdfWriter writer = CompareTool.createTestPdfWriter(outFileName, + new WriterProperties().setStandardEncryption(PdfEncryptionTestUtils.USER, PdfEncryptionTestUtils.OWNER, permissions, + encryptionType).addXmpMetadata().setPdfVersion(PdfVersion.PDF_2_0) + ); + PdfDocument document = new PdfDocument(writer); + document.getDocumentInfo().setMoreInfo(PdfEncryptionTestUtils.CUSTOM_INFO_ENTRY_KEY, PdfEncryptionTestUtils.CUSTOM_INFO_ENTRY_VALUE); + PdfPage page = document.addNewPage(); + String textContent = "Hello world!"; + PdfEncryptionTestUtils.writeTextBytesOnPageContent(page, textContent); + + String descripton = "encryptedFile"; + String path = sourceFolder + "pageWithContent.pdf"; + document.addFileAttachment(descripton, + PdfFileSpec.createEmbeddedFileSpec(document, path, descripton, path, null, null)); + + page.flush(); + document.close(); + + //TODO DEVSIX-5355 Specific crypto filters for EFF StmF and StrF are not supported at the moment. + // However we can read embedded files only mode. + boolean ERROR_IS_EXPECTED = false; + encryptionUtil.checkDecryptedWithPasswordContent(destinationFolder + filename, PdfEncryptionTestUtils.OWNER, + textContent, ERROR_IS_EXPECTED); + encryptionUtil.checkDecryptedWithPasswordContent(destinationFolder + filename, PdfEncryptionTestUtils.USER, + textContent, ERROR_IS_EXPECTED); + } + @Test @LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT, ignore = true)) @@ -434,7 +468,7 @@ public void encryptAes256EncryptedStampingUpdate() throws InterruptedException, String compareResult = compareTool.compareByContent(out, sourceFolder + "cmp_" + filename, destinationFolder, "diff_", PdfEncryptionTestUtils.USER, PdfEncryptionTestUtils.USER); if (compareResult != null) { - Assert.fail(compareResult); + Assertions.fail(compareResult); } } @@ -459,7 +493,7 @@ public void encryptWithPasswordAes256Pdf2() throws InterruptedException, IOExcep @Test @LogMessages(messages = { @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT, ignore = true), - @LogMessage(messageTemplate = VersionConforming.DEPRECATED_ENCRYPTION_ALGORITHMS)}) + @LogMessage(messageTemplate = VersionConforming.DEPRECATED_ENCRYPTION_ALGORITHMS, count = 2)}) public void encryptWithPasswordAes128Pdf2() throws InterruptedException, IOException { String filename = "encryptWithPasswordAes128Pdf2.pdf"; int encryptionType = EncryptionConstants.ENCRYPTION_AES_128; @@ -524,12 +558,12 @@ public void encryptWithPasswordAes128NoMetadataCompression() throws Exception { compareTool.getCmpReaderProperties().setPassword("superowner".getBytes()); String outPdf = destinationFolder + outFilename; String cmpPdf = sourceFolder + "cmp_" + outFilename; - Assert.assertNull(compareTool.compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); + Assertions.assertNull(compareTool.compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); } @Test public void checkMD5LogAbsenceInUnapprovedMode() throws IOException { - Assume.assumeTrue(!FACTORY.isInApprovedOnlyMode()); + Assumptions.assumeTrue(!FACTORY.isInApprovedOnlyMode()); String fileName = "noUserPassword.pdf"; try (PdfDocument document = new PdfDocument(new PdfReader(sourceFolder + fileName))) { // this test checks log message absence @@ -556,9 +590,9 @@ public void decodeDictionaryWithInvalidOwnerHashAes256() { "\u0087J \u0013\"V\u008E\fT!\u0082\u0003\u009E£\u008Fc\u0004 ].\u008C\u009C\u009C\u0000" + "\u0000\u0000\u0000\u0013\u0000\u0013\u0013\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" + "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0013")); - Exception e = Assert.assertThrows(PdfException.class, + Exception e = Assertions.assertThrows(PdfException.class, () -> new StandardHandlerUsingAes256(dictionary, "owner".getBytes())); - Assert.assertEquals(KernelExceptionMessageConstant.BAD_PASSWORD_HASH, e.getCause().getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.BAD_PASSWORD_HASH, e.getCause().getMessage()); } @Test @@ -568,7 +602,7 @@ public void openEncryptedWithPasswordDocWithDefaultKeyLength() throws IOExceptio try (PdfReader reader = new PdfReader(sourceFolder + "encryptedWithPasswordWithDefaultKeyLength.pdf", new ReaderProperties().setPassword("user".getBytes(StandardCharsets.UTF_8))); PdfDocument document = new PdfDocument(reader)) { - Assert.assertFalse(document.getTrailer().getAsDictionary(PdfName.Encrypt).containsKey(PdfName.Length)); + Assertions.assertFalse(document.getTrailer().getAsDictionary(PdfName.Encrypt).containsKey(PdfName.Length)); } } @@ -656,7 +690,7 @@ public void checkEncryptedWithPasswordDocumentStamping(String filename, byte[] p destinationFolder, "diff_", PdfEncryptionTestUtils.USER, PdfEncryptionTestUtils.USER); if (compareResult != null) { - Assert.fail(compareResult); + Assertions.fail(compareResult); } } @@ -672,13 +706,13 @@ public void checkEncryptedWithPasswordDocumentAppending(String filename, byte[] PdfEncryptionTestUtils.writeTextBytesOnPageContent(newPage, "Hello world page_2!"); document.close(); - CompareTool compareTool = new CompareTool().enableEncryptionCompare(); + CompareTool compareTool = new CompareTool().enableEncryptionCompare(false); String compareResult = compareTool.compareByContent(outFileName, sourceFolder + "cmp_appended_" + filename, destinationFolder, "diff_", PdfEncryptionTestUtils.USER, PdfEncryptionTestUtils.USER); if (compareResult != null) { - Assert.fail(compareResult); + Assertions.fail(compareResult); } } @@ -686,7 +720,7 @@ private void decryptWithPassword(String fileName, byte[] password) throws IOExce ReaderProperties readerProperties = new ReaderProperties().setPassword(password); try (PdfReader reader = new PdfReader(fileName, readerProperties); PdfDocument pdfDocument = new PdfDocument(reader)) { - Assert.assertTrue(PdfTextExtractor.getTextFromPage(pdfDocument.getFirstPage()) + Assertions.assertTrue(PdfTextExtractor.getTextFromPage(pdfDocument.getFirstPage()) .startsWith("Content encrypted by ")); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/crypto/pdfencryption/PdfEncryptionTestUtils.java b/kernel/src/test/java/com/itextpdf/kernel/crypto/pdfencryption/PdfEncryptionTestUtils.java index d703c2ad21..709824db75 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/crypto/pdfencryption/PdfEncryptionTestUtils.java +++ b/kernel/src/test/java/com/itextpdf/kernel/crypto/pdfencryption/PdfEncryptionTestUtils.java @@ -26,7 +26,7 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.font.PdfFontFactory; import com.itextpdf.kernel.pdf.*; import com.itextpdf.kernel.utils.CompareTool; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import java.io.IOException; import java.nio.charset.StandardCharsets; @@ -63,11 +63,11 @@ public void compareEncryptedPdf(String filename) throws IOException, Interrupted checkDecryptedWithPasswordContent(destinationFolder + filename, OWNER, PAGE_TEXT_CONTENT); checkDecryptedWithPasswordContent(destinationFolder + filename, USER, PAGE_TEXT_CONTENT); - CompareTool compareTool = new CompareTool().enableEncryptionCompare(); + CompareTool compareTool = new CompareTool().enableEncryptionCompare(false); String compareResult = compareTool.compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_", USER, USER); if (compareResult != null) { - Assert.fail(compareResult); + Assertions.fail(compareResult); } } @@ -87,11 +87,11 @@ public void checkDecryptedWithPasswordContent(String src, byte[] password, Strin .getAsString(new PdfName(CUSTOM_INFO_ENTRY_KEY)).toUnicodeString(); if (!expectError) { - Assert.assertTrue("Expected content: \n" + pageContent, expectedContentFound); - Assert.assertEquals("Encrypted custom", CUSTOM_INFO_ENTRY_VALUE, actualCustomInfoEntry); + Assertions.assertTrue(expectedContentFound, "Expected content: \n" + pageContent); + Assertions.assertEquals( CUSTOM_INFO_ENTRY_VALUE, actualCustomInfoEntry, "Encrypted custom"); } else { - Assert.assertFalse("Expected content: \n" + pageContent, expectedContentFound); - Assert.assertNotEquals("Encrypted custom", CUSTOM_INFO_ENTRY_VALUE, actualCustomInfoEntry); + Assertions.assertFalse(expectedContentFound, "Expected content: \n" + pageContent); + Assertions.assertNotEquals(CUSTOM_INFO_ENTRY_VALUE, actualCustomInfoEntry, "Encrypted custom"); } document.close(); diff --git a/kernel/src/test/java/com/itextpdf/kernel/crypto/pdfencryption/PdfPreserveEncryptionTest.java b/kernel/src/test/java/com/itextpdf/kernel/crypto/pdfencryption/PdfPreserveEncryptionTest.java index d3819c5eb7..a036781915 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/crypto/pdfencryption/PdfPreserveEncryptionTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/crypto/pdfencryption/PdfPreserveEncryptionTest.java @@ -28,18 +28,17 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfPreserveEncryptionTest extends ExtendedITextTest { public static final String destinationFolder = "./target/test/com/itextpdf/kernel/crypto/pdfencryption/PdfPreserveEncryptionTest/"; @@ -48,12 +47,12 @@ public class PdfPreserveEncryptionTest extends ExtendedITextTest { public PdfEncryptionTestUtils encryptionUtil = new PdfEncryptionTestUtils(destinationFolder, sourceFolder); - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(destinationFolder); } @@ -110,7 +109,7 @@ public void encryptAes256EncryptedStampingPreserve() throws InterruptedException String compareResult = compareTool.compareByContent(out, sourceFolder + "cmp_" + filename, destinationFolder, "diff_", PdfEncryptionTestUtils.USER, PdfEncryptionTestUtils.USER); if (compareResult != null) { - Assert.fail(compareResult); + Assertions.fail(compareResult); } } @@ -130,7 +129,7 @@ public void preserveEncryptionShorterDocumentId() throws IOException, Interrupte String compareResult = compareTool.compareByContent(out, sourceFolder + "cmp_" + filename, destinationFolder, "diff_", null, null); if (compareResult != null) { - Assert.fail(compareResult); + Assertions.fail(compareResult); } } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest.java b/kernel/src/test/java/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest.java index be942a5876..83287f62c4 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest.java @@ -22,6 +22,7 @@ This file is part of the iText (R) project. */ package com.itextpdf.kernel.crypto.pdfencryption; +import com.itextpdf.bouncycastleconnector.BouncyCastleFactoryCreator; import com.itextpdf.kernel.logs.KernelLogMessageConstant; import com.itextpdf.kernel.pdf.EncryptionConstants; import com.itextpdf.kernel.pdf.PdfDocument; @@ -33,21 +34,21 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.BouncyCastleIntegrationTest; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; import java.nio.charset.StandardCharsets; +import java.security.Security; import java.util.LinkedHashMap; import java.util.Map; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; -@Category(BouncyCastleIntegrationTest.class) +@Tag("BouncyCastleIntegrationTest") public class UnicodeBasedPasswordEncryptionTest extends ExtendedITextTest { public static final String destinationFolder = "./target/test/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/"; @@ -171,12 +172,13 @@ private static class SaslPreparedString { } } - @BeforeClass + @BeforeAll public static void before() { + Security.addProvider(BouncyCastleFactoryCreator.getFactory().getProvider()); createOrClearDestinationFolder(destinationFolder); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(destinationFolder); } @@ -215,7 +217,7 @@ private void encryptAes256AndCheck(String filename, byte[] ownerPassword) throws encryptionUtil.checkDecryptedWithPasswordContent(destinationFolder + filename, ownerPassword, PdfEncryptionTestUtils.PAGE_TEXT_CONTENT); - CompareTool compareTool = new CompareTool().enableEncryptionCompare(); + CompareTool compareTool = new CompareTool().enableEncryptionCompare(false); String compareResult = compareTool.compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_", ownerPassword, ownerPassword); if (compareResult != null) { fail(compareResult); diff --git a/kernel/src/test/java/com/itextpdf/kernel/crypto/securityhandler/EncryptionUtilsTest.java b/kernel/src/test/java/com/itextpdf/kernel/crypto/securityhandler/EncryptionUtilsTest.java index f83edd9f31..03ea4d5faa 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/crypto/securityhandler/EncryptionUtilsTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/crypto/securityhandler/EncryptionUtilsTest.java @@ -24,18 +24,17 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.exceptions.PdfException; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class EncryptionUtilsTest extends ExtendedITextTest { @Test public void fetchEnvelopedDataThrows() { - Assert.assertThrows(Exception.class, () -> EncryptionUtils.fetchEnvelopedData(null, null, null, null, null)); + Assertions.assertThrows(Exception.class, () -> EncryptionUtils.fetchEnvelopedData(null, null, null, null, null)); } } \ No newline at end of file diff --git a/kernel/src/test/java/com/itextpdf/kernel/crypto/securityhandler/PubKeySecurityHandlerTest.java b/kernel/src/test/java/com/itextpdf/kernel/crypto/securityhandler/PubKeySecurityHandlerTest.java index bf783f209d..58881bec48 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/crypto/securityhandler/PubKeySecurityHandlerTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/crypto/securityhandler/PubKeySecurityHandlerTest.java @@ -29,14 +29,13 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.BouncyCastleUnitTest; import java.io.OutputStream; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(BouncyCastleUnitTest.class) +@Tag("BouncyCastleUnitTest") public class PubKeySecurityHandlerTest extends ExtendedITextTest { @Test @@ -44,7 +43,7 @@ public class PubKeySecurityHandlerTest extends ExtendedITextTest { ignore = true)) public void computeGlobalKeyDecryptTest() { PubKeySecurityHandler securityHandler = new TestSecurityHandler(); - Assert.assertEquals(20, securityHandler.computeGlobalKey("SHA1", false).length); + Assertions.assertEquals(20, securityHandler.computeGlobalKey("SHA1", false).length); } private static class TestSecurityHandler extends PubKeySecurityHandler { diff --git a/kernel/src/test/java/com/itextpdf/kernel/crypto/securityhandler/PubSecHandlerUsingAesGcmTest.java b/kernel/src/test/java/com/itextpdf/kernel/crypto/securityhandler/PubSecHandlerUsingAesGcmTest.java new file mode 100644 index 0000000000..6b747cc8f0 --- /dev/null +++ b/kernel/src/test/java/com/itextpdf/kernel/crypto/securityhandler/PubSecHandlerUsingAesGcmTest.java @@ -0,0 +1,233 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.crypto.securityhandler; + +import com.itextpdf.bouncycastleconnector.BouncyCastleFactoryCreator; +import com.itextpdf.commons.bouncycastle.IBouncyCastleFactory; +import com.itextpdf.commons.bouncycastle.crypto.fips.AbstractFipsUnapprovedOperationError; +import com.itextpdf.commons.utils.FileUtil; +import com.itextpdf.kernel.crypto.CryptoUtil; +import com.itextpdf.kernel.exceptions.KernelExceptionMessageConstant; +import com.itextpdf.kernel.exceptions.PdfException; +import com.itextpdf.kernel.logs.KernelLogMessageConstant; +import com.itextpdf.kernel.pdf.EncryptionConstants; +import com.itextpdf.kernel.pdf.PdfBoolean; +import com.itextpdf.kernel.pdf.PdfDictionary; +import com.itextpdf.kernel.pdf.PdfDocument; +import com.itextpdf.kernel.pdf.PdfEncryption; +import com.itextpdf.kernel.pdf.PdfName; +import com.itextpdf.kernel.pdf.PdfNumber; +import com.itextpdf.kernel.pdf.PdfObject; +import com.itextpdf.kernel.pdf.PdfReader; +import com.itextpdf.kernel.pdf.PdfVersion; +import com.itextpdf.kernel.pdf.PdfWriter; +import com.itextpdf.kernel.pdf.ReaderProperties; +import com.itextpdf.kernel.pdf.VersionConforming; +import com.itextpdf.kernel.pdf.WriterProperties; +import com.itextpdf.kernel.utils.CompareTool; +import com.itextpdf.kernel.utils.PemFileHelper; +import com.itextpdf.test.ExtendedITextTest; + +import java.io.IOException; +import java.security.PrivateKey; +import java.security.Security; +import java.security.cert.Certificate; +import java.security.cert.CertificateException; +import java.util.HashMap; + +import com.itextpdf.test.annotations.LogMessage; +import com.itextpdf.test.annotations.LogMessages; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +@Tag("BouncyCastleIntegrationTest") +public class PubSecHandlerUsingAesGcmTest extends ExtendedITextTest { + public static final String SOURCE_FOLDER = + "./src/test/resources/com/itextpdf/kernel/crypto/securityhandler/PubSecHandlerUsingAesGcmTest/"; + public static final String DESTINATION_FOLDER = + "./target/test/com/itextpdf/kernel/crypto/securityhandler/PubSecHandlerUsingAesGcmTest/"; + + private static final IBouncyCastleFactory FACTORY = BouncyCastleFactoryCreator.getFactory(); + private static final char[] PASSWORD = "testpassphrase".toCharArray(); + + @BeforeAll + public static void setUp() { + createOrClearDestinationFolder(DESTINATION_FOLDER); + Security.addProvider(FACTORY.getProvider()); + } + + @LogMessages(messages = {@LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT, + ignore = true)}) + @Test + public void testSimpleEncryptDecryptTest() throws Exception { + try { + BouncyCastleFactoryCreator.getFactory().isEncryptionFeatureSupported(0, true); + } catch (Exception ignored) { + Assumptions.assumeTrue(false); + } + Assumptions.assumeTrue(!BouncyCastleFactoryCreator.getFactory().isInApprovedOnlyMode()); + + String fileName = "simpleEncryptDecrypt.pdf"; + String srcFile = SOURCE_FOLDER + fileName; + String outFile = DESTINATION_FOLDER + fileName; + + doEncrypt(srcFile, outFile, true); + decryptWithCertificate(fileName, DESTINATION_FOLDER, "test.cer", "test.pem"); + } + + @LogMessages(messages = {@LogMessage(messageTemplate = VersionConforming.NOT_SUPPORTED_AES_GCM, ignore = true), + @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT, + ignore = true)}) + @Test + public void testSimpleEncryptDecryptPdf17Test() throws Exception { + try { + BouncyCastleFactoryCreator.getFactory().isEncryptionFeatureSupported(0, true); + } catch (Exception ignored) { + Assumptions.assumeTrue(false); + } + Assumptions.assumeTrue(!BouncyCastleFactoryCreator.getFactory().isInApprovedOnlyMode()); + + String fileName = "simpleEncryptDecrypt_1_7.pdf"; + String srcFile = SOURCE_FOLDER + fileName; + String outFile = DESTINATION_FOLDER + fileName; + + doEncrypt(srcFile, outFile, false); + decryptWithCertificate(fileName, DESTINATION_FOLDER, "test.cer", "test.pem"); + } + + @LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT, + ignore = true)) + @Test + public void decryptExternalFileTest() throws Exception { + try { + BouncyCastleFactoryCreator.getFactory().isEncryptionFeatureSupported(0, true); + } catch (Exception ignored) { + Assumptions.assumeTrue(false); + } + + decryptWithCertificate("externalFile.pdf", SOURCE_FOLDER, "decrypter.cert.pem", "signerkey.pem"); + } + + @LogMessages(messages = {@LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT, + ignore = true)}) + @Test + public void invalidCryptFilterTest() { + String fileName = "invalidCryptFilter.pdf"; + Exception e = Assertions.assertThrows(PdfException.class, + () -> decryptWithCertificate(fileName, SOURCE_FOLDER, "test.cer", "test.pem")); + Assertions.assertEquals(KernelExceptionMessageConstant.NO_COMPATIBLE_ENCRYPTION_FOUND, e.getMessage()); + } + + @Test + public void encryptPdfWithMissingCFTest() throws Exception { + PrivateKey certificateKey = PemFileHelper.readPrivateKeyFromPemFile( + FileUtil.getInputStreamForFile(SOURCE_FOLDER + "signerkey.pem"), PASSWORD); + Certificate certificate = CryptoUtil.readPublicCertificate( + FileUtil.getInputStreamForFile(SOURCE_FOLDER + "decrypter.cert.pem")); + HashMap encMap = new HashMap(); + encMap.put(PdfName.V, new PdfNumber(6)); + encMap.put(PdfName.EncryptMetadata, PdfBoolean.TRUE); + PdfDictionary dictionary = new PdfDictionary(encMap); + Exception e = Assertions.assertThrows(PdfException.class, () -> new PdfEncryption(dictionary, certificateKey, + certificate, FACTORY.getProviderName(), null)); + Assertions.assertEquals(KernelExceptionMessageConstant.CF_NOT_FOUND_ENCRYPTION, e.getMessage()); + } + + @Test + public void encryptPdfWithMissingDefaultCryptFilterTest() throws Exception { + PrivateKey certificateKey = PemFileHelper.readPrivateKeyFromPemFile( + FileUtil.getInputStreamForFile(SOURCE_FOLDER + "signerkey.pem"), PASSWORD); + Certificate certificate = CryptoUtil.readPublicCertificate( + FileUtil.getInputStreamForFile(SOURCE_FOLDER + "decrypter.cert.pem")); + HashMap encMap = new HashMap(); + encMap.put(PdfName.V, new PdfNumber(6)); + PdfDictionary embeddedFilesDict = new PdfDictionary(); + embeddedFilesDict.put(PdfName.FlateDecode, new PdfDictionary()); + encMap.put(PdfName.CF, embeddedFilesDict); + PdfDictionary dictionary = new PdfDictionary(encMap); + Exception e = Assertions.assertThrows(PdfException.class, () -> new PdfEncryption(dictionary, certificateKey, + certificate, FACTORY.getProviderName(), null)); + Assertions.assertEquals(KernelExceptionMessageConstant.DEFAULT_CRYPT_FILTER_NOT_FOUND_ENCRYPTION, + e.getMessage()); + } + + @Test + public void encryptPdfWithMissingCFMTest() throws Exception { + PrivateKey certificateKey = PemFileHelper.readPrivateKeyFromPemFile( + FileUtil.getInputStreamForFile(SOURCE_FOLDER + "signerkey.pem"), PASSWORD); + Certificate certificate = CryptoUtil.readPublicCertificate( + FileUtil.getInputStreamForFile(SOURCE_FOLDER + "decrypter.cert.pem")); + HashMap encMap = new HashMap(); + encMap.put(PdfName.V, new PdfNumber(6)); + PdfDictionary embeddedFilesDict = new PdfDictionary(); + embeddedFilesDict.put(PdfName.DefaultCryptFilter, new PdfDictionary()); + encMap.put(PdfName.CF, embeddedFilesDict); + PdfDictionary dictionary = new PdfDictionary(encMap); + Exception e = Assertions.assertThrows(PdfException.class, () -> new PdfEncryption(dictionary, certificateKey, + certificate, FACTORY.getProviderName(), null)); + Assertions.assertEquals(KernelExceptionMessageConstant.NO_COMPATIBLE_ENCRYPTION_FOUND, e.getMessage()); + } + + private void doEncrypt(String input, String output, boolean isPdf20) throws IOException, CertificateException { + Certificate certificate = CryptoUtil.readPublicCertificate( + FileUtil.getInputStreamForFile(SOURCE_FOLDER + "test.cer")); + WriterProperties writerProperties = new WriterProperties().setPublicKeyEncryption( + new Certificate[] {certificate}, new int[] {EncryptionConstants.ALLOW_PRINTING}, + EncryptionConstants.ENCRYPTION_AES_GCM); + if (isPdf20) { + writerProperties.setPdfVersion(PdfVersion.PDF_2_0); + } + // Instantiate input/output document. + try (PdfDocument docIn = new PdfDocument(new PdfReader(input)); PdfDocument docOut = new PdfDocument( + new PdfWriter(output, writerProperties))) { + // Copy one page from input to output. + docIn.copyPagesTo(1, 1, docOut); + } + } + + private void decryptWithCertificate(String fileName, String srcFileFolder, + String certificateName, String privateKeyName) throws Exception { + String srcFile = srcFileFolder + fileName; + String cmpFile = SOURCE_FOLDER + "cmp_" + fileName; + String outFile = DESTINATION_FOLDER + "decrypted_" + fileName; + + Certificate certificate = CryptoUtil.readPublicCertificate( + FileUtil.getInputStreamForFile(SOURCE_FOLDER + certificateName)); + PrivateKey privateKey = PemFileHelper.readPrivateKeyFromPemFile( + FileUtil.getInputStreamForFile(SOURCE_FOLDER + privateKeyName), PASSWORD); + ReaderProperties readerProperties = new ReaderProperties().setPublicKeySecurityParams( + certificate, privateKey, FACTORY.getProviderName(), null); + + PdfDocument ignored = new PdfDocument(new PdfReader(srcFile, readerProperties), new PdfWriter(outFile)); + ignored.close(); + + String errorMessage = new CompareTool().compareByContent(outFile, cmpFile, DESTINATION_FOLDER, "diff_"); + if (errorMessage != null) { + Assertions.fail(errorMessage); + } + } +} diff --git a/kernel/src/test/java/com/itextpdf/kernel/crypto/securityhandler/StandardHandlerUsingAesGcmTest.java b/kernel/src/test/java/com/itextpdf/kernel/crypto/securityhandler/StandardHandlerUsingAesGcmTest.java new file mode 100644 index 0000000000..b3f9ed8182 --- /dev/null +++ b/kernel/src/test/java/com/itextpdf/kernel/crypto/securityhandler/StandardHandlerUsingAesGcmTest.java @@ -0,0 +1,306 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.crypto.securityhandler; + +import com.itextpdf.bouncycastleconnector.BouncyCastleFactoryCreator; +import com.itextpdf.commons.bouncycastle.IBouncyCastleFactory; +import com.itextpdf.io.logs.IoLogMessageConstant; +import com.itextpdf.kernel.exceptions.KernelExceptionMessageConstant; +import com.itextpdf.kernel.exceptions.PdfException; +import com.itextpdf.kernel.logs.KernelLogMessageConstant; +import com.itextpdf.kernel.pdf.EncryptionConstants; +import com.itextpdf.kernel.pdf.PdfBoolean; +import com.itextpdf.kernel.pdf.PdfDictionary; +import com.itextpdf.kernel.pdf.PdfDocument; +import com.itextpdf.kernel.pdf.PdfEncryption; +import com.itextpdf.kernel.pdf.PdfName; +import com.itextpdf.kernel.pdf.PdfNumber; +import com.itextpdf.kernel.pdf.PdfObject; +import com.itextpdf.kernel.pdf.PdfReader; +import com.itextpdf.kernel.pdf.PdfStream; +import com.itextpdf.kernel.pdf.PdfString; +import com.itextpdf.kernel.pdf.PdfVersion; +import com.itextpdf.kernel.pdf.PdfWriter; +import com.itextpdf.kernel.pdf.ReaderProperties; +import com.itextpdf.kernel.pdf.VersionConforming; +import com.itextpdf.kernel.pdf.WriterProperties; +import com.itextpdf.kernel.utils.CompareTool; +import com.itextpdf.kernel.utils.objectpathitems.ObjectPath; +import com.itextpdf.test.ExtendedITextTest; +import com.itextpdf.test.annotations.LogMessage; +import com.itextpdf.test.annotations.LogMessages; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.security.Security; +import java.util.HashMap; + +@Tag("BouncyCastleIntegrationTest") +public class StandardHandlerUsingAesGcmTest extends ExtendedITextTest { + public static final String SRC = + "./src/test/resources/com/itextpdf/kernel/crypto/securityhandler/StandardHandlerUsingAesGcmTest/"; + public static final String DEST = + "./target/test/com/itextpdf/kernel/crypto/securityhandler/StandardHandlerUsingAesGcmTest/"; + + private static final IBouncyCastleFactory FACTORY = BouncyCastleFactoryCreator.getFactory(); + private static final byte[] OWNER_PASSWORD = "supersecret".getBytes(StandardCharsets.UTF_8); + private static final byte[] USER_PASSWORD = "secret".getBytes(StandardCharsets.UTF_8); + + @BeforeAll + public static void setUp() { + createOrClearDestinationFolder(DEST); + Security.addProvider(FACTORY.getProvider()); + } + + @Test + @LogMessages(messages = { + @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT, + ignore = true)}) + public void simpleEncryptDecryptTest() throws Exception { + String srcFile = SRC + "simpleDocument.pdf"; + String encryptedCmpFile = SRC + "cmp_encryptedSimpleDocument.pdf"; + String outFile = DEST + "simpleEncryptDecrypt.pdf"; + + // Set usage permissions. + int perms = EncryptionConstants.ALLOW_PRINTING | EncryptionConstants.ALLOW_DEGRADED_PRINTING; + WriterProperties wProps = new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0) + .setStandardEncryption(USER_PASSWORD, OWNER_PASSWORD, perms, EncryptionConstants.ENCRYPTION_AES_GCM); + // Instantiate input/output document. + try (PdfDocument docIn = new PdfDocument(new PdfReader(srcFile)); + PdfDocument docOut = new PdfDocument(new PdfWriter(outFile, wProps))) { + // Copy one page from input to output. + docIn.copyPagesTo(1, 1, docOut); + } + + new CToolNoDeveloperExtension().compareByContent(outFile, srcFile, DEST, "diff", USER_PASSWORD, null); + new CompareTool().compareByContent(outFile, encryptedCmpFile, DEST, "diff", USER_PASSWORD, USER_PASSWORD); + } + + @Test + @LogMessages(messages = {@LogMessage(messageTemplate = VersionConforming.NOT_SUPPORTED_AES_GCM), + @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT, ignore = true)}) + public void simpleEncryptDecryptPdf15Test() throws Exception { + String srcFile = SRC + "simpleDocument.pdf"; + String outFile = DEST + "notSupportedVersionDocument.pdf"; + + int perms = EncryptionConstants.ALLOW_PRINTING | EncryptionConstants.ALLOW_DEGRADED_PRINTING; + WriterProperties wProps = new WriterProperties() + .setStandardEncryption(USER_PASSWORD, OWNER_PASSWORD, perms, EncryptionConstants.ENCRYPTION_AES_GCM); + PdfDocument ignored = new PdfDocument(new PdfReader(srcFile), new PdfWriter(outFile, wProps)); + ignored.close(); + new CToolNoDeveloperExtension().compareByContent(outFile, srcFile, DEST, "diff", USER_PASSWORD, null); + } + + @Test + @LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT, + ignore = true)) + public void knownOutputTest() throws Exception { + String srcFile = SRC + "encryptedDocument.pdf"; + String outFile = DEST + "encryptedDocument.pdf"; + String cmpFile = SRC + "simpleDocument.pdf"; + try (PdfDocument ignored = new PdfDocument(new PdfReader(srcFile, + new ReaderProperties().setPassword(OWNER_PASSWORD)), new PdfWriter(outFile))) { + // We need to copy the source file to the destination folder to be able to compare pdf files in android. + } + new CompareTool().compareByContent(outFile, cmpFile, DEST, "diff", USER_PASSWORD, null); + } + + // In all these tampered files, the stream content of object 14 has been modified. + @LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT, + ignore = true)) + @Test + public void macTamperedTest() throws IOException { + String srcFile = SRC + "encryptedDocumentTamperedMac.pdf"; + assertTampered(srcFile); + } + + @LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT, + ignore = true)) + @Test + public void initVectorTamperedTest() throws IOException { + String srcFile = SRC + "encryptedDocumentTamperedIv.pdf"; + assertTampered(srcFile); + } + + @LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT, + ignore = true)) + @Test + public void ciphertextTamperedTest() throws IOException { + String srcFile = SRC + "encryptedDocumentTamperedCiphertext.pdf"; + assertTampered(srcFile); + } + + @Test + @LogMessages(messages = {@LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT, + ignore = true), + @LogMessage(messageTemplate = IoLogMessageConstant.ENCRYPTION_ENTRIES_P_AND_ENCRYPT_METADATA_NOT_CORRESPOND_PERMS_ENTRY)}) + public void pdfEncryptionWithEmbeddedFilesTest() { + byte[] documentId = new byte[]{(byte)88, (byte)189, (byte)192, (byte)48, (byte)240, (byte)200, (byte)87, + (byte)183, (byte)244, (byte)119, (byte)224, (byte)109, (byte)226, (byte)173, (byte)32, (byte)90}; + byte[] password = new byte[]{(byte)115, (byte)101, (byte)99, (byte)114, (byte)101, (byte)116}; + HashMap encMap = new HashMap(); + encMap.put(PdfName.R, new PdfNumber(7)); + encMap.put(PdfName.V, new PdfNumber(6)); + encMap.put(PdfName.P, new PdfNumber(-1852)); + encMap.put(PdfName.EFF, PdfName.FlateDecode); + encMap.put(PdfName.StmF, PdfName.Identity); + encMap.put(PdfName.StrF, PdfName.Identity); + PdfDictionary embeddedFilesDict = new PdfDictionary(); + embeddedFilesDict.put(PdfName.FlateDecode, new PdfDictionary()); + PdfDictionary cfmDict = new PdfDictionary(); + cfmDict.put(PdfName.CFM, PdfName.AESV4); + embeddedFilesDict.put(PdfName.StdCF, cfmDict); + encMap.put(PdfName.CF, embeddedFilesDict); + encMap.put(PdfName.EncryptMetadata, PdfBoolean.FALSE); + encMap.put(PdfName.O, new PdfString("\u0006¡Ê\u009A<@\u009DÔG\u0013&\u008C5r\u0096\u0081i!\u0091\u000Fªìh=±\u0091\u0006Að¨\u008D\"¼\u0018?õ\u001DNó»{y\u0091)\u0090vâý")); + encMap.put(PdfName.U, new PdfString("ôY\u009DÃ\u0017Ý·Ü\u0097vØ\fJ\u0099c\u0004áݹÔB\u0084·9÷\u008F\u009D-¿xnkþ\u0086Æ\u0088º\u0086ÜTÿëÕï\u0018\u009D\u0016-")); + encMap.put(PdfName.OE, new PdfString("5Ë\u009EUÔº\u0007 Nøß\u0094ä\u001DÄ_wnù\u001AKò-\u007F\u00ADQ²Ø \u001FSJ")); + encMap.put(PdfName.UE, new PdfString("\u000B:\rÆ\u0004\u0094Ûìkþ,ôBS9ü\u001E³\u0088\u001D(\u0098ºÀ\u0010½\u0082.'`kñ")); + encMap.put(PdfName.Perms, new PdfString("\u008F»\u0080.òç\u0011\u001Et\u0012\u00905\u001B\u0019\u0014«")); + PdfDictionary dictionary = new PdfDictionary(encMap); + PdfEncryption encryption = new PdfEncryption(dictionary, password, documentId); + Assertions.assertTrue(encryption.isEmbeddedFilesOnly()); + } + + @Test + @LogMessages(messages = {@LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT, + ignore = true)}) + public void pdfEncryptionWithMetadataTest() { + byte[] documentId = new byte[]{(byte)88, (byte)189, (byte)192, (byte)48, (byte)240, (byte)200, (byte)87, + (byte)183, (byte)244, (byte)119, (byte)224, (byte)109, (byte)226, (byte)173, (byte)32, (byte)90}; + byte[] password = new byte[]{(byte)115, (byte)101, (byte)99, (byte)114, (byte)101, (byte)116}; + HashMap encMap = new HashMap(); + encMap.put(PdfName.R, new PdfNumber(7)); + encMap.put(PdfName.V, new PdfNumber(6)); + encMap.put(PdfName.P, new PdfNumber(-1852)); + encMap.put(PdfName.StmF, PdfName.StdCF); + encMap.put(PdfName.StrF, PdfName.StdCF); + PdfDictionary embeddedFilesDict = new PdfDictionary(); + embeddedFilesDict.put(PdfName.FlateDecode, new PdfDictionary()); + PdfDictionary cfmDict = new PdfDictionary(); + cfmDict.put(PdfName.CFM, PdfName.AESV4); + embeddedFilesDict.put(PdfName.StdCF, cfmDict); + encMap.put(PdfName.CF, embeddedFilesDict); + encMap.put(PdfName.EncryptMetadata, PdfBoolean.TRUE); + encMap.put(PdfName.O, new PdfString("\u0006¡Ê\u009A<@\u009DÔG\u0013&\u008C5r\u0096\u0081i!\u0091\u000Fªìh=±\u0091\u0006Að¨\u008D\"¼\u0018?õ\u001DNó»{y\u0091)\u0090vâý")); + encMap.put(PdfName.U, new PdfString("ôY\u009DÃ\u0017Ý·Ü\u0097vØ\fJ\u0099c\u0004áݹÔB\u0084·9÷\u008F\u009D-¿xnkþ\u0086Æ\u0088º\u0086ÜTÿëÕï\u0018\u009D\u0016-")); + encMap.put(PdfName.OE, new PdfString("5Ë\u009EUÔº\u0007 Nøß\u0094ä\u001DÄ_wnù\u001AKò-\u007F\u00ADQ²Ø \u001FSJ")); + encMap.put(PdfName.UE, new PdfString("\u000B:\rÆ\u0004\u0094Ûìkþ,ôBS9ü\u001E³\u0088\u001D(\u0098ºÀ\u0010½\u0082.'`kñ")); + encMap.put(PdfName.Perms, new PdfString("\u008F»\u0080.òç\u0011\u001Et\u0012\u00905\u001B\u0019\u0014«")); + PdfDictionary dictionary = new PdfDictionary(encMap); + PdfEncryption encryption = new PdfEncryption(dictionary, password, documentId); + Assertions.assertTrue(encryption.isMetadataEncrypted()); + } + + @Test + @LogMessages(messages = {@LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT, + ignore = true)}) + public void encryptPdfWithMissingCFTest() { + byte[] documentId = new byte[]{(byte)88, (byte)189, (byte)192, (byte)48, (byte)240, (byte)200, (byte)87, + (byte)183, (byte)244, (byte)119, (byte)224, (byte)109, (byte)226, (byte)173, (byte)32, (byte)90}; + byte[] password = new byte[]{(byte)115, (byte)101, (byte)99, (byte)114, (byte)101, (byte)116}; + HashMap encMap = new HashMap(); + encMap.put(PdfName.R, new PdfNumber(7)); + encMap.put(PdfName.V, new PdfNumber(6)); + PdfDictionary dictionary = new PdfDictionary(encMap); + Exception e = Assertions.assertThrows(PdfException.class, () -> new PdfEncryption(dictionary, password, documentId)); + Assertions.assertEquals(KernelExceptionMessageConstant.CF_NOT_FOUND_ENCRYPTION, e.getMessage()); + } + + @Test + @LogMessages(messages = {@LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT, + ignore = true)}) + public void encryptPdfWithMissingStdCFTest() { + byte[] documentId = new byte[]{(byte)88, (byte)189, (byte)192, (byte)48, (byte)240, (byte)200, (byte)87, + (byte)183, (byte)244, (byte)119, (byte)224, (byte)109, (byte)226, (byte)173, (byte)32, (byte)90}; + byte[] password = new byte[]{(byte)115, (byte)101, (byte)99, (byte)114, (byte)101, (byte)116}; + HashMap encMap = new HashMap(); + encMap.put(PdfName.R, new PdfNumber(7)); + encMap.put(PdfName.V, new PdfNumber(6)); + PdfDictionary embeddedFilesDict = new PdfDictionary(); + embeddedFilesDict.put(PdfName.FlateDecode, new PdfDictionary()); + PdfDictionary cfmDict = new PdfDictionary(); + cfmDict.put(PdfName.CFM, PdfName.AESV4); + encMap.put(PdfName.CF, embeddedFilesDict); + PdfDictionary dictionary = new PdfDictionary(encMap); + Exception e = Assertions.assertThrows(PdfException.class, () -> new PdfEncryption(dictionary, password, documentId)); + Assertions.assertEquals(KernelExceptionMessageConstant.STDCF_NOT_FOUND_ENCRYPTION, e.getMessage()); + } + + @Test + @LogMessages(messages = {@LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT, + ignore = true)}) + public void encryptPdfWithMissingCFMTest() { + byte[] documentId = new byte[]{(byte)88, (byte)189, (byte)192, (byte)48, (byte)240, (byte)200, (byte)87, + (byte)183, (byte)244, (byte)119, (byte)224, (byte)109, (byte)226, (byte)173, (byte)32, (byte)90}; + byte[] password = new byte[]{(byte)115, (byte)101, (byte)99, (byte)114, (byte)101, (byte)116}; + HashMap encMap = new HashMap(); + encMap.put(PdfName.R, new PdfNumber(7)); + encMap.put(PdfName.V, new PdfNumber(6)); + encMap.put(PdfName.P, new PdfNumber(-1852)); + encMap.put(PdfName.StmF, PdfName.StdCF); + encMap.put(PdfName.StrF, PdfName.StdCF); + PdfDictionary embeddedFilesDict = new PdfDictionary(); + embeddedFilesDict.put(PdfName.FlateDecode, new PdfDictionary()); + PdfDictionary cfmDict = new PdfDictionary(); + embeddedFilesDict.put(PdfName.StdCF, cfmDict); + encMap.put(PdfName.CF, embeddedFilesDict); + PdfDictionary dictionary = new PdfDictionary(encMap); + Exception e = Assertions.assertThrows(PdfException.class, () -> new PdfEncryption(dictionary, password, documentId)); + Assertions.assertEquals(KernelExceptionMessageConstant.NO_COMPATIBLE_ENCRYPTION_FOUND, e.getMessage()); + } + + private void assertTampered(String outFile) throws IOException { + try (PdfDocument pdfDoc = + new PdfDocument(new PdfReader(outFile, new ReaderProperties().setPassword(USER_PASSWORD)))) { + PdfObject obj = pdfDoc.getPdfObject(14); + if (obj != null && obj.isStream()) { + // Get decoded stream bytes. + Assertions.assertThrows(Exception.class, () -> ((PdfStream) obj).getBytes()); + } + } + } +} + +// Outside test class for porting +class CToolNoDeveloperExtension extends CompareTool { + @Override + protected boolean compareObjects(PdfObject outObj, PdfObject cmpObj, ObjectPath currentPath, CompareResult compareResult) { + if (outObj != null && outObj.isDictionary()) { + if (((PdfDictionary) outObj).get(PdfName.ISO_) != null) { + return true; + } + } + if (cmpObj != null && cmpObj.isDictionary()) { + if (((PdfDictionary) cmpObj).get(PdfName.ISO_) != null) { + return true; + } + } + + return super.compareObjects(outObj, cmpObj, currentPath, compareResult); + } +} diff --git a/kernel/src/test/java/com/itextpdf/kernel/font/FontUtilTest.java b/kernel/src/test/java/com/itextpdf/kernel/font/FontUtilTest.java index 304adc0e6a..548b263218 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/font/FontUtilTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/font/FontUtilTest.java @@ -32,17 +32,16 @@ This file is part of the iText (R) project. import com.itextpdf.test.LogLevelConstants; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class FontUtilTest extends ExtendedITextTest { @Test public void parseUniversalNotExistedCMapTest() { - Assert.assertNull(FontUtil.parseUniversalToUnicodeCMap("NotExisted")); + Assertions.assertNull(FontUtil.parseUniversalToUnicodeCMap("NotExisted")); } @Test @@ -55,8 +54,8 @@ public void processInvalidToUnicodeTest() { toUnicode.makeIndirect(pdfDocument); toUnicode.flush(); final CMapToUnicode cmap = FontUtil.processToUnicode(toUnicode); - Assert.assertNotNull(cmap); - Assert.assertFalse(cmap.hasByteMappings()); + Assertions.assertNotNull(cmap); + Assertions.assertFalse(cmap.hasByteMappings()); } } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/font/PdfFontFactoryTest.java b/kernel/src/test/java/com/itextpdf/kernel/font/PdfFontFactoryTest.java index 9de56b8fd2..387f5b3fd2 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/font/PdfFontFactoryTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/font/PdfFontFactoryTest.java @@ -35,14 +35,13 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.IOException; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfFontFactoryTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/kernel/font/"; @@ -51,10 +50,10 @@ public class PdfFontFactoryTest extends ExtendedITextTest { public void standardFontForceEmbeddedTest() throws IOException { Type1Font fontProgram = (Type1Font) FontProgramFactory.createFont(StandardFonts.HELVETICA); - Exception e = Assert.assertThrows(PdfException.class, + Exception e = Assertions.assertThrows(PdfException.class, () -> PdfFontFactory.createFont(fontProgram, PdfEncodings.UTF8, EmbeddingStrategy.FORCE_EMBEDDED) ); - Assert.assertEquals(KernelExceptionMessageConstant.CANNOT_EMBED_STANDARD_FONT, e.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.CANNOT_EMBED_STANDARD_FONT, e.getMessage()); } @Test @@ -63,8 +62,8 @@ public void standardFontPreferEmbeddedTest() throws IOException { PdfType1Font font = (PdfType1Font) PdfFontFactory.createFont( fontProgram, PdfEncodings.UTF8, EmbeddingStrategy.PREFER_EMBEDDED); - Assert.assertNotNull(font); - Assert.assertFalse(font.isEmbedded()); + Assertions.assertNotNull(font); + Assertions.assertFalse(font.isEmbedded()); } @Test @@ -73,8 +72,8 @@ public void standardFontPreferNotEmbeddedTest() throws IOException { PdfType1Font font = (PdfType1Font) PdfFontFactory.createFont( fontProgram, PdfEncodings.UTF8, EmbeddingStrategy.PREFER_NOT_EMBEDDED); - Assert.assertNotNull(font); - Assert.assertFalse(font.isEmbedded()); + Assertions.assertNotNull(font); + Assertions.assertFalse(font.isEmbedded()); } @Test @@ -83,8 +82,8 @@ public void standardFontForceNotEmbeddedTest() throws IOException { PdfType1Font font = (PdfType1Font) PdfFontFactory.createFont( fontProgram, PdfEncodings.UTF8, EmbeddingStrategy.FORCE_NOT_EMBEDDED); - Assert.assertNotNull(font); - Assert.assertFalse(font.isEmbedded()); + Assertions.assertNotNull(font); + Assertions.assertFalse(font.isEmbedded()); } @Test @@ -93,8 +92,8 @@ public void customType1FontForceEmbeddedTest() throws IOException { PdfType1Font font = (PdfType1Font) PdfFontFactory.createFont( fontProgram, PdfEncodings.UTF8, EmbeddingStrategy.FORCE_EMBEDDED); - Assert.assertNotNull(font); - Assert.assertTrue(font.isEmbedded()); + Assertions.assertNotNull(font); + Assertions.assertTrue(font.isEmbedded()); } @Test @@ -103,8 +102,8 @@ public void customType1FontPreferEmbeddedTest() throws IOException { PdfType1Font font = (PdfType1Font) PdfFontFactory.createFont( fontProgram, PdfEncodings.UTF8, EmbeddingStrategy.PREFER_EMBEDDED); - Assert.assertNotNull(font); - Assert.assertTrue(font.isEmbedded()); + Assertions.assertNotNull(font); + Assertions.assertTrue(font.isEmbedded()); } @Test @@ -113,8 +112,8 @@ public void customType1FontPreferNotEmbeddedTest() throws IOException { PdfType1Font font = (PdfType1Font) PdfFontFactory.createFont( fontProgram, PdfEncodings.UTF8, EmbeddingStrategy.PREFER_NOT_EMBEDDED); - Assert.assertNotNull(font); - Assert.assertFalse(font.isEmbedded()); + Assertions.assertNotNull(font); + Assertions.assertFalse(font.isEmbedded()); } @Test @@ -123,8 +122,8 @@ public void customType1FontForceNotEmbeddedTest() throws IOException { PdfType1Font font = (PdfType1Font) PdfFontFactory.createFont( fontProgram, PdfEncodings.UTF8, EmbeddingStrategy.FORCE_NOT_EMBEDDED); - Assert.assertNotNull(font); - Assert.assertFalse(font.isEmbedded()); + Assertions.assertNotNull(font); + Assertions.assertFalse(font.isEmbedded()); } @Test @@ -133,8 +132,8 @@ public void trueTypeFontProgramUTF8AllowEmbeddingEncodingForceEmbeddedTest() { PdfTrueTypeFont font = (PdfTrueTypeFont) PdfFontFactory.createFont( fontProgram, PdfEncodings.UTF8, EmbeddingStrategy.FORCE_EMBEDDED); - Assert.assertNotNull(font); - Assert.assertTrue(font.isEmbedded()); + Assertions.assertNotNull(font); + Assertions.assertTrue(font.isEmbedded()); } @Test @@ -143,8 +142,8 @@ public void trueTypeFontProgramUTF8AllowEmbeddingEncodingPreferEmbeddedTest() { PdfTrueTypeFont font = (PdfTrueTypeFont) PdfFontFactory.createFont( fontProgram, PdfEncodings.UTF8, EmbeddingStrategy.PREFER_EMBEDDED); - Assert.assertNotNull(font); - Assert.assertTrue(font.isEmbedded()); + Assertions.assertNotNull(font); + Assertions.assertTrue(font.isEmbedded()); } @Test @@ -153,8 +152,8 @@ public void trueTypeFontProgramUTF8AllowEmbeddingEncodingPreferNotEmbeddedTest() PdfTrueTypeFont font = (PdfTrueTypeFont) PdfFontFactory.createFont( fontProgram, PdfEncodings.UTF8, EmbeddingStrategy.PREFER_NOT_EMBEDDED); - Assert.assertNotNull(font); - Assert.assertFalse(font.isEmbedded()); + Assertions.assertNotNull(font); + Assertions.assertFalse(font.isEmbedded()); } @Test @@ -163,18 +162,18 @@ public void trueTypeFontProgramUTF8AllowEmbeddingEncodingForceNotEmbeddedTest() PdfTrueTypeFont font = (PdfTrueTypeFont) PdfFontFactory.createFont( fontProgram, PdfEncodings.UTF8, EmbeddingStrategy.FORCE_NOT_EMBEDDED); - Assert.assertNotNull(font); - Assert.assertFalse(font.isEmbedded()); + Assertions.assertNotNull(font); + Assertions.assertFalse(font.isEmbedded()); } @Test public void trueTypeFontProgramUTF8NotAllowEmbeddingEncodingForceEmbeddedTest() { TrueTypeFont fontProgram = new CustomTrueTypeFontProgram(false); - Exception e = Assert.assertThrows(PdfException.class, + Exception e = Assertions.assertThrows(PdfException.class, () -> PdfFontFactory.createFont(fontProgram, PdfEncodings.UTF8, EmbeddingStrategy.FORCE_EMBEDDED) ); - Assert.assertEquals(MessageFormatUtil.format(KernelExceptionMessageConstant.CANNOT_BE_EMBEDDED_DUE_TO_LICENSING_RESTRICTIONS, "CustomNameCustomStyle"), + Assertions.assertEquals(MessageFormatUtil.format(KernelExceptionMessageConstant.CANNOT_BE_EMBEDDED_DUE_TO_LICENSING_RESTRICTIONS, "CustomNameCustomStyle"), e.getMessage()); } @@ -184,8 +183,8 @@ public void trueTypeFontProgramUTF8NotAllowEmbeddingEncodingPreferEmbeddedTest() PdfTrueTypeFont font = (PdfTrueTypeFont) PdfFontFactory.createFont( fontProgram, PdfEncodings.UTF8, EmbeddingStrategy.PREFER_EMBEDDED); - Assert.assertNotNull(font); - Assert.assertFalse(font.isEmbedded()); + Assertions.assertNotNull(font); + Assertions.assertFalse(font.isEmbedded()); } @Test @@ -194,8 +193,8 @@ public void trueTypeFontProgramUTF8NotAllowEmbeddingEncodingPreferNotEmbeddedTes PdfTrueTypeFont font = (PdfTrueTypeFont) PdfFontFactory.createFont( fontProgram, PdfEncodings.UTF8, EmbeddingStrategy.PREFER_NOT_EMBEDDED); - Assert.assertNotNull(font); - Assert.assertFalse(font.isEmbedded()); + Assertions.assertNotNull(font); + Assertions.assertFalse(font.isEmbedded()); } @Test @@ -204,8 +203,8 @@ public void trueTypeFontProgramUTF8NotAllowEmbeddingEncodingForceNotEmbeddedTest PdfTrueTypeFont font = (PdfTrueTypeFont) PdfFontFactory.createFont( fontProgram, PdfEncodings.UTF8, EmbeddingStrategy.FORCE_NOT_EMBEDDED); - Assert.assertNotNull(font); - Assert.assertFalse(font.isEmbedded()); + Assertions.assertNotNull(font); + Assertions.assertFalse(font.isEmbedded()); } @Test @@ -214,8 +213,8 @@ public void trueTypeFontProgramIdentityHAllowEmbeddingEncodingForceEmbeddedTest( PdfType0Font font = (PdfType0Font) PdfFontFactory.createFont( fontProgram, PdfEncodings.IDENTITY_H, EmbeddingStrategy.FORCE_EMBEDDED); - Assert.assertNotNull(font); - Assert.assertTrue(font.isEmbedded()); + Assertions.assertNotNull(font); + Assertions.assertTrue(font.isEmbedded()); } @Test @@ -224,8 +223,8 @@ public void trueTypeFontProgramIdentityHAllowEmbeddingEncodingPreferEmbeddedTest PdfType0Font font = (PdfType0Font) PdfFontFactory.createFont( fontProgram, PdfEncodings.IDENTITY_H, EmbeddingStrategy.PREFER_EMBEDDED); - Assert.assertNotNull(font); - Assert.assertTrue(font.isEmbedded()); + Assertions.assertNotNull(font); + Assertions.assertTrue(font.isEmbedded()); } @Test @@ -234,28 +233,28 @@ public void trueTypeFontProgramIdentityHAllowEmbeddingEncodingPreferNotEmbeddedT PdfType0Font font = (PdfType0Font) PdfFontFactory.createFont( fontProgram, PdfEncodings.IDENTITY_H, EmbeddingStrategy.PREFER_NOT_EMBEDDED); - Assert.assertNotNull(font); - Assert.assertTrue(font.isEmbedded()); + Assertions.assertNotNull(font); + Assertions.assertTrue(font.isEmbedded()); } @Test public void trueTypeFontProgramIdentityHAllowEmbeddingEncodingForceNotEmbeddedTest() { TrueTypeFont fontProgram = new CustomTrueTypeFontProgram(true); - Exception e = Assert.assertThrows(PdfException.class, + Exception e = Assertions.assertThrows(PdfException.class, () -> PdfFontFactory.createFont(fontProgram, PdfEncodings.IDENTITY_H, EmbeddingStrategy.FORCE_NOT_EMBEDDED) ); - Assert.assertEquals(KernelExceptionMessageConstant.CANNOT_CREATE_TYPE_0_FONT_WITH_TRUE_TYPE_FONT_PROGRAM_WITHOUT_EMBEDDING_IT, e.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.CANNOT_CREATE_TYPE_0_FONT_WITH_TRUE_TYPE_FONT_PROGRAM_WITHOUT_EMBEDDING_IT, e.getMessage()); } @Test public void trueTypeFontProgramIdentityHNotAllowEmbeddingEncodingForceEmbeddedTest() { TrueTypeFont fontProgram = new CustomTrueTypeFontProgram(false); - Exception e = Assert.assertThrows(PdfException.class, + Exception e = Assertions.assertThrows(PdfException.class, () -> PdfFontFactory.createFont(fontProgram, PdfEncodings.IDENTITY_H, EmbeddingStrategy.FORCE_EMBEDDED) ); - Assert.assertEquals(MessageFormatUtil.format(KernelExceptionMessageConstant.CANNOT_BE_EMBEDDED_DUE_TO_LICENSING_RESTRICTIONS, + Assertions.assertEquals(MessageFormatUtil.format(KernelExceptionMessageConstant.CANNOT_BE_EMBEDDED_DUE_TO_LICENSING_RESTRICTIONS, "CustomNameCustomStyle"), e.getMessage()); } @@ -263,10 +262,10 @@ public void trueTypeFontProgramIdentityHNotAllowEmbeddingEncodingForceEmbeddedTe public void trueTypeFontProgramIdentityHNotAllowEmbeddingEncodingPreferEmbeddedTest() { TrueTypeFont fontProgram = new CustomTrueTypeFontProgram(false); - Exception e = Assert.assertThrows(PdfException.class, + Exception e = Assertions.assertThrows(PdfException.class, () -> PdfFontFactory.createFont(fontProgram, PdfEncodings.IDENTITY_H, EmbeddingStrategy.PREFER_EMBEDDED) ); - Assert.assertEquals(MessageFormatUtil.format(KernelExceptionMessageConstant.CANNOT_BE_EMBEDDED_DUE_TO_LICENSING_RESTRICTIONS, + Assertions.assertEquals(MessageFormatUtil.format(KernelExceptionMessageConstant.CANNOT_BE_EMBEDDED_DUE_TO_LICENSING_RESTRICTIONS, "CustomNameCustomStyle"), e.getMessage()); } @@ -274,10 +273,10 @@ public void trueTypeFontProgramIdentityHNotAllowEmbeddingEncodingPreferEmbeddedT public void trueTypeFontProgramIdentityHNotAllowEmbeddingEncodingPreferNotEmbeddedTest() { TrueTypeFont fontProgram = new CustomTrueTypeFontProgram(false); - Exception e = Assert.assertThrows(PdfException.class, + Exception e = Assertions.assertThrows(PdfException.class, () -> PdfFontFactory.createFont(fontProgram, PdfEncodings.IDENTITY_H, EmbeddingStrategy.PREFER_NOT_EMBEDDED) ); - Assert.assertEquals(MessageFormatUtil.format(KernelExceptionMessageConstant.CANNOT_BE_EMBEDDED_DUE_TO_LICENSING_RESTRICTIONS, + Assertions.assertEquals(MessageFormatUtil.format(KernelExceptionMessageConstant.CANNOT_BE_EMBEDDED_DUE_TO_LICENSING_RESTRICTIONS, "CustomNameCustomStyle"), e.getMessage()); } @@ -285,10 +284,10 @@ public void trueTypeFontProgramIdentityHNotAllowEmbeddingEncodingPreferNotEmbedd public void trueTypeFontProgramIdentityHNotAllowEmbeddingEncodingForceNotEmbeddedTest() { TrueTypeFont fontProgram = new CustomTrueTypeFontProgram(false); - Exception e = Assert.assertThrows(PdfException.class, + Exception e = Assertions.assertThrows(PdfException.class, () -> PdfFontFactory.createFont(fontProgram, PdfEncodings.IDENTITY_H, EmbeddingStrategy.FORCE_NOT_EMBEDDED) ); - Assert.assertEquals(MessageFormatUtil.format(KernelExceptionMessageConstant.CANNOT_BE_EMBEDDED_DUE_TO_LICENSING_RESTRICTIONS, + Assertions.assertEquals(MessageFormatUtil.format(KernelExceptionMessageConstant.CANNOT_BE_EMBEDDED_DUE_TO_LICENSING_RESTRICTIONS, "CustomNameCustomStyle"), e.getMessage()); } @@ -299,24 +298,24 @@ public void standardFontCachedWithoutDocumentTest() throws IOException { PdfDocument cacheTo = null; PdfType1Font font = (PdfType1Font) PdfFontFactory.createFont( StandardFonts.HELVETICA, PdfEncodings.UTF8, cacheTo); - Assert.assertNotNull(font); - Assert.assertFalse(font.isEmbedded()); + Assertions.assertNotNull(font); + Assertions.assertFalse(font.isEmbedded()); } @Test public void createFontFromNullDictionaryTest() { PdfDictionary dictionary = null; - Exception e = Assert.assertThrows(PdfException.class, () -> PdfFontFactory.createFont(dictionary)); - Assert.assertEquals(KernelExceptionMessageConstant.CANNOT_CREATE_FONT_FROM_NULL_PDF_DICTIONARY, e.getMessage()); + Exception e = Assertions.assertThrows(PdfException.class, () -> PdfFontFactory.createFont(dictionary)); + Assertions.assertEquals(KernelExceptionMessageConstant.CANNOT_CREATE_FONT_FROM_NULL_PDF_DICTIONARY, e.getMessage()); } @Test public void createFontFromEmptyDictionaryTest() { PdfDictionary dictionary = new PdfDictionary(); - Exception e = Assert.assertThrows(PdfException.class, () -> PdfFontFactory.createFont(dictionary)); - Assert.assertEquals(KernelExceptionMessageConstant.DICTIONARY_DOES_NOT_HAVE_SUPPORTED_FONT_DATA, e.getMessage()); + Exception e = Assertions.assertThrows(PdfException.class, () -> PdfFontFactory.createFont(dictionary)); + Assertions.assertEquals(KernelExceptionMessageConstant.DICTIONARY_DOES_NOT_HAVE_SUPPORTED_FONT_DATA, e.getMessage()); } private static class CustomType1FontProgram extends Type1Font { diff --git a/kernel/src/test/java/com/itextpdf/kernel/font/PdfFontUnitTest.java b/kernel/src/test/java/com/itextpdf/kernel/font/PdfFontUnitTest.java index aeac67e7a4..02c82d52f2 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/font/PdfFontUnitTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/font/PdfFontUnitTest.java @@ -36,17 +36,16 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfString; import com.itextpdf.kernel.pdf.PdfWriter; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.List; import java.util.regex.Pattern; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfFontUnitTest extends ExtendedITextTest { public static final int FONT_METRICS_DESCENT = -40; public static final int FONT_METRICS_ASCENT = 700; @@ -189,7 +188,7 @@ public TestFontMetrics() { public void constructorWithoutParamsTest() { TestFont font = new TestFont(); - Assert.assertEquals(PdfName.Font, font.getPdfObject().get(PdfName.Type)); + Assertions.assertEquals(PdfName.Font, font.getPdfObject().get(PdfName.Type)); } @Test @@ -199,42 +198,42 @@ public void constructorWithDictionaryTest() { TestFont font = new TestFont(dictionary); - Assert.assertEquals(PdfName.Font, font.getPdfObject().get(PdfName.Type)); - Assert.assertEquals(PdfName.B, font.getPdfObject().get(PdfName.A)); + Assertions.assertEquals(PdfName.Font, font.getPdfObject().get(PdfName.Type)); + Assertions.assertEquals(PdfName.B, font.getPdfObject().get(PdfName.A)); } @Test public void containsGlyphTest() { TestFont font = new TestFont(); - Assert.assertTrue(font.containsGlyph(TestFont.SIMPLE_GLYPH)); - Assert.assertFalse(font.containsGlyph(111)); + Assertions.assertTrue(font.containsGlyph(TestFont.SIMPLE_GLYPH)); + Assertions.assertFalse(font.containsGlyph(111)); } @Test public void zeroGlyphIsAllowedOnlyIfFontIsSymbolicTest() { TestFont font = new TestFont(); - Assert.assertFalse(font.containsGlyph(TestFont.ZERO_CODE_GLYPH)); + Assertions.assertFalse(font.containsGlyph(TestFont.ZERO_CODE_GLYPH)); font.setFontProgram(new TestFontProgram()); - Assert.assertTrue(font.containsGlyph(TestFont.ZERO_CODE_GLYPH)); + Assertions.assertTrue(font.containsGlyph(TestFont.ZERO_CODE_GLYPH)); } @Test public void getWidthUnicodeTest() { TestFont font = new TestFont(); - Assert.assertEquals(TestFont.SIMPLE_GLYPH_WIDTH, font.getWidth(TestFont.SIMPLE_GLYPH)); - Assert.assertEquals(0, font.getWidth(111)); + Assertions.assertEquals(TestFont.SIMPLE_GLYPH_WIDTH, font.getWidth(TestFont.SIMPLE_GLYPH)); + Assertions.assertEquals(0, font.getWidth(111)); } @Test public void getWidthFontSizeTest() { TestFont font = new TestFont(); double expectedValue = TestFont.SIMPLE_GLYPH_WIDTH * FONT_SIZE / (double) FontProgram.UNITS_NORMALIZATION; - Assert.assertEquals(expectedValue, font.getWidth(TestFont.SIMPLE_GLYPH, FONT_SIZE), 0.1); - Assert.assertEquals(0, font.getWidth(111)); + Assertions.assertEquals(expectedValue, font.getWidth(TestFont.SIMPLE_GLYPH, FONT_SIZE), 0.1); + Assertions.assertEquals(0, font.getWidth(111)); } @Test @@ -242,7 +241,7 @@ public void getWidthOfStringTest() { TestFont font = new TestFont(); char[] text = getSentence(3); String textAsString = new String(text); - Assert.assertEquals(3 * TestFont.SIMPLE_GLYPH_WIDTH, font.getWidth(textAsString)); + Assertions.assertEquals(3 * TestFont.SIMPLE_GLYPH_WIDTH, font.getWidth(textAsString)); } @Test @@ -254,7 +253,7 @@ public void getWidthOfSurrogatePairTest() { (char) TestFont.SIMPLE_GLYPH, }; String textAsString = new String(text); - Assert.assertEquals(TestFont.COMPLEX_GLYPH_WIDTH + TestFont.SIMPLE_GLYPH_WIDTH, + Assertions.assertEquals(TestFont.COMPLEX_GLYPH_WIDTH + TestFont.SIMPLE_GLYPH_WIDTH, font.getWidth(textAsString)); } @@ -267,7 +266,7 @@ public void getWidthOfUnknownGlyphsTest() { (char) 333, }; String textAsString = new String(text); - Assert.assertEquals(0, font.getWidth(textAsString)); + Assertions.assertEquals(0, font.getWidth(textAsString)); } @Test @@ -276,7 +275,7 @@ public void getWidthOfStringWithFontSizeTest() { char[] text = getSentence(3); String textAsString = new String(text); double expectedValue = 3 * TestFont.SIMPLE_GLYPH_WIDTH * FONT_SIZE / (double) FontProgram.UNITS_NORMALIZATION; - Assert.assertEquals(expectedValue, font.getWidth(textAsString, FONT_SIZE), 0.1); + Assertions.assertEquals(expectedValue, font.getWidth(textAsString, FONT_SIZE), 0.1); } @Test @@ -285,21 +284,21 @@ public void getDescentOfGlyphTest() { int expectedDescent = font.getGlyph(TestFont.SIMPLE_GLYPH).getBbox()[1]; float expectedValue = (float) (expectedDescent * FONT_SIZE / (float) FontProgram.UNITS_NORMALIZATION); - Assert.assertEquals(expectedValue, font.getDescent(TestFont.SIMPLE_GLYPH, FONT_SIZE), 0.1); + Assertions.assertEquals(expectedValue, font.getDescent(TestFont.SIMPLE_GLYPH, FONT_SIZE), 0.1); } @Test public void descentCannotBePositiveTest() { TestFont font = new TestFont(); - Assert.assertEquals(0, font.getDescent(TestFont.SIMPLE_GLYPH_WITH_POSITIVE_DESCENT, 50), 0.1); + Assertions.assertEquals(0, font.getDescent(TestFont.SIMPLE_GLYPH_WITH_POSITIVE_DESCENT, 50), 0.1); } @Test public void getDescentOfUnknownGlyphTest() { TestFont font = new TestFont(); - Assert.assertEquals(0, font.getDescent(111, 50), 0.1); + Assertions.assertEquals(0, font.getDescent(111, 50), 0.1); } @Test @@ -308,7 +307,7 @@ public void getDescentOfGlyphWithoutBBoxTest() { font.setFontProgram(new TestFontProgram()); float expectedValue = (float) (FONT_METRICS_DESCENT * FONT_SIZE / (double) FontProgram.UNITS_NORMALIZATION); - Assert.assertEquals(expectedValue, font.getDescent(TestFont.SIMPLE_GLYPH_WITHOUT_BBOX, FONT_SIZE), 0.1); + Assertions.assertEquals(expectedValue, font.getDescent(TestFont.SIMPLE_GLYPH_WITHOUT_BBOX, FONT_SIZE), 0.1); } @Test @@ -323,7 +322,7 @@ public void getDescentOfTextTest() { int expectedMinDescent = Math.min(font.getGlyph(TestFont.SIMPLE_GLYPH).getBbox()[1], font.getGlyph(TestFont.COMPLEX_GLYPH).getBbox()[1]); float expectedValue = (float) (expectedMinDescent * FONT_SIZE / (double) FontProgram.UNITS_NORMALIZATION); - Assert.assertEquals(expectedValue, font.getDescent(textAsString, FONT_SIZE), 0.1); + Assertions.assertEquals(expectedValue, font.getDescent(textAsString, FONT_SIZE), 0.1); } @Test @@ -338,7 +337,7 @@ public void getDescentOfTextWithGlyphWithoutBBoxTest() { int expectedMinDescent = Math.min(font.getGlyph(TestFont.SIMPLE_GLYPH).getBbox()[1], FONT_METRICS_DESCENT); float expectedValue = (float) (expectedMinDescent * FONT_SIZE / (double) FontProgram.UNITS_NORMALIZATION); - Assert.assertEquals(expectedValue, font.getDescent(textAsString, FONT_SIZE), 0.1); + Assertions.assertEquals(expectedValue, font.getDescent(textAsString, FONT_SIZE), 0.1); } @Test @@ -347,7 +346,7 @@ public void getAscentOfGlyphTest() { int expectedAscent = font.getGlyph(TestFont.SIMPLE_GLYPH).getBbox()[3]; float expectedValue = (float) (expectedAscent * FONT_SIZE / (double) FontProgram.UNITS_NORMALIZATION); - Assert.assertEquals(expectedValue, font.getAscent(TestFont.SIMPLE_GLYPH, FONT_SIZE), 0.1); + Assertions.assertEquals(expectedValue, font.getAscent(TestFont.SIMPLE_GLYPH, FONT_SIZE), 0.1); } @Test @@ -356,7 +355,7 @@ public void getAscentOfGlyphWithoutBBoxTest() { font.setFontProgram(new TestFontProgram()); float expectedValue = (float) (FONT_METRICS_ASCENT * FONT_SIZE / (double) FontProgram.UNITS_NORMALIZATION); - Assert.assertEquals(expectedValue, font.getAscent(TestFont.SIMPLE_GLYPH_WITHOUT_BBOX, FONT_SIZE), 0.1); + Assertions.assertEquals(expectedValue, font.getAscent(TestFont.SIMPLE_GLYPH_WITHOUT_BBOX, FONT_SIZE), 0.1); } @Test @@ -372,7 +371,7 @@ public void getAscentOfTextTest() { font.getGlyph(TestFont.SIMPLE_GLYPH).getBbox()[3], font.getGlyph(TestFont.COMPLEX_GLYPH).getBbox()[3]); float expectedValue = (float) (expectedMaxAscent * FONT_SIZE / (double) FontProgram.UNITS_NORMALIZATION); - Assert.assertEquals(expectedValue, font.getAscent(textAsString, FONT_SIZE), 0.1); + Assertions.assertEquals(expectedValue, font.getAscent(textAsString, FONT_SIZE), 0.1); } @Test @@ -388,25 +387,25 @@ public void getAscentOfTextWithGlyphWithoutBBoxTest() { font.getGlyph(TestFont.SIMPLE_GLYPH).getBbox()[3], FONT_METRICS_ASCENT); float expectedValue = (float) (expectedMaxAscent * FONT_SIZE / (double) FontProgram.UNITS_NORMALIZATION); - Assert.assertEquals(expectedValue, font.getAscent(textAsString, FONT_SIZE), 0.1); + Assertions.assertEquals(expectedValue, font.getAscent(textAsString, FONT_SIZE), 0.1); } @Test public void isEmbeddedTest() { TestFont font = new TestFont(); - Assert.assertFalse(font.isEmbedded()); + Assertions.assertFalse(font.isEmbedded()); font.embedded = true; - Assert.assertTrue(font.isEmbedded()); + Assertions.assertTrue(font.isEmbedded()); } @Test public void isSubsetTest() { TestFont font = new TestFont(); - Assert.assertTrue(font.isSubset()); + Assertions.assertTrue(font.isSubset()); font.setSubset(false); - Assert.assertFalse(font.isSubset()); + Assertions.assertFalse(font.isSubset()); } @Test @@ -420,10 +419,10 @@ public void addSubsetRangeTest() { font.addSubsetRange(range1); font.addSubsetRange(range2); - Assert.assertTrue(font.isSubset()); - Assert.assertEquals(2, font.subsetRanges.size()); - Assert.assertArrayEquals(range1, font.subsetRanges.get(0)); - Assert.assertArrayEquals(range2, font.subsetRanges.get(1)); + Assertions.assertTrue(font.isSubset()); + Assertions.assertEquals(2, font.subsetRanges.size()); + Assertions.assertArrayEquals(range1, font.subsetRanges.get(0)); + Assertions.assertArrayEquals(range2, font.subsetRanges.get(1)); } @Test @@ -433,8 +432,8 @@ public void splitSentenceFitMaxWidthTest() { String wordsAsString = new String(words); double width = 6 * font.getWidth(TestFont.SIMPLE_GLYPH, FONT_SIZE); List result = font.splitString(wordsAsString, FONT_SIZE, (float) width + 0.01f); - Assert.assertEquals(1, result.size()); - Assert.assertEquals(wordsAsString, result.get(0)); + Assertions.assertEquals(1, result.size()); + Assertions.assertEquals(wordsAsString, result.get(0)); } @Test @@ -444,10 +443,10 @@ public void splitSentenceWordFitMaxWidthTest() { String wordsAsString = new String(words); double width = 4 * font.getWidth(TestFont.SIMPLE_GLYPH, FONT_SIZE); List result = font.splitString(wordsAsString, FONT_SIZE, (float) width + 0.01f); - Assert.assertEquals(3, result.size()); - Assert.assertEquals(new String(getSentence(3)), result.get(0)); - Assert.assertEquals(new String(getSentence(4)), result.get(1)); - Assert.assertEquals(new String(getSentence(2)), result.get(2)); + Assertions.assertEquals(3, result.size()); + Assertions.assertEquals(new String(getSentence(3)), result.get(0)); + Assertions.assertEquals(new String(getSentence(4)), result.get(1)); + Assertions.assertEquals(new String(getSentence(2)), result.get(2)); } @Test @@ -457,10 +456,10 @@ public void splitSentenceWordDoesNotFitMaxWidthCase_PartIsCombinedWithTheFollowi String wordsAsString = new String(words); double width = 3 * font.getWidth(TestFont.SIMPLE_GLYPH, FONT_SIZE); List result = font.splitString(wordsAsString, FONT_SIZE, (float) width + 0.01f); - Assert.assertEquals(3, result.size()); - Assert.assertEquals(new String(getSentence(3)), result.get(0)); - Assert.assertEquals(new String(getSentence(3)), result.get(1)); - Assert.assertEquals(new String(getSentence(1, 2)), result.get(2)); + Assertions.assertEquals(3, result.size()); + Assertions.assertEquals(new String(getSentence(3)), result.get(0)); + Assertions.assertEquals(new String(getSentence(3)), result.get(1)); + Assertions.assertEquals(new String(getSentence(1, 2)), result.get(2)); } @Test @@ -470,11 +469,11 @@ public void splitSentenceWordDoesNotFitMaxWidthCase_PartIsOnTheSeparateLineTest( String wordsAsString = new String(words); double width = 3 * font.getWidth(TestFont.SIMPLE_GLYPH, FONT_SIZE); List result = font.splitString(wordsAsString, FONT_SIZE, (float) width + 0.01f); - Assert.assertEquals(4, result.size()); - Assert.assertEquals(new String(getSentence(2)), result.get(0)); - Assert.assertEquals(new String(getSentence(3)), result.get(1)); - Assert.assertEquals(new String(getSentence(1)), result.get(2)); - Assert.assertEquals(new String(getSentence(3)), result.get(3)); + Assertions.assertEquals(4, result.size()); + Assertions.assertEquals(new String(getSentence(2)), result.get(0)); + Assertions.assertEquals(new String(getSentence(3)), result.get(1)); + Assertions.assertEquals(new String(getSentence(1)), result.get(2)); + Assertions.assertEquals(new String(getSentence(3)), result.get(3)); } @Test @@ -484,11 +483,11 @@ public void splitSentenceSymbolDoesNotFitLineTest() { String wordsAsString = new String(words); double width = font.getWidth(TestFont.SIMPLE_GLYPH, FONT_SIZE) / 2.; List result = font.splitString(wordsAsString, FONT_SIZE, (float) width + 0.01f); - Assert.assertEquals(4, result.size()); - Assert.assertEquals(new String(getSentence(1)), result.get(0)); - Assert.assertEquals(new String(getSentence(1)), result.get(1)); - Assert.assertEquals(new String(getSentence(1)), result.get(2)); - Assert.assertEquals(new String(getSentence(0)), result.get(3)); + Assertions.assertEquals(4, result.size()); + Assertions.assertEquals(new String(getSentence(1)), result.get(0)); + Assertions.assertEquals(new String(getSentence(1)), result.get(1)); + Assertions.assertEquals(new String(getSentence(1)), result.get(2)); + Assertions.assertEquals(new String(getSentence(0)), result.get(3)); } @@ -503,21 +502,21 @@ public void splitSentenceWithLineBreakTest() { String wordsAsString = new String(words); double width = 10 * font.getWidth(TestFont.SIMPLE_GLYPH, FONT_SIZE); List result = font.splitString(wordsAsString, FONT_SIZE, (float) width + 0.01f); - Assert.assertEquals(2, result.size()); - Assert.assertEquals(new String(getSentence(1)), result.get(0)); - Assert.assertEquals(new String(getSentence(1)), result.get(1)); + Assertions.assertEquals(2, result.size()); + Assertions.assertEquals(new String(getSentence(1)), result.get(0)); + Assertions.assertEquals(new String(getSentence(1)), result.get(1)); } @Test public void isBuiltWithTest() { TestFont font = new TestFont(); - Assert.assertFalse(font.isBuiltWith("Any String Here", "Any Encoding")); + Assertions.assertFalse(font.isBuiltWith("Any String Here", "Any Encoding")); } @Test public void isWrappedObjectMustBeIndirectTest() { TestFont font = new TestFont(); - Assert.assertTrue(font.isWrappedObjectMustBeIndirect()); + Assertions.assertTrue(font.isWrappedObjectMustBeIndirect()); } @Test @@ -528,22 +527,22 @@ public void updateEmbeddedSubsetPrefixTest() { String onlyEmbeddedFontName = TestFont.updateSubsetPrefix(fontName, false, true); String justFontName = TestFont.updateSubsetPrefix(fontName, false, false); - Assert.assertEquals(fontName, onlySubsetFontName); - Assert.assertEquals(fontName, onlyEmbeddedFontName); - Assert.assertEquals(fontName, justFontName); + Assertions.assertEquals(fontName, onlySubsetFontName); + Assertions.assertEquals(fontName, onlyEmbeddedFontName); + Assertions.assertEquals(fontName, justFontName); Pattern prefixPattern = Pattern.compile("^[A-Z]{6}\\+FontTest$"); - Assert.assertTrue(prefixPattern.matcher(embeddedSubsetFontName).matches()); + Assertions.assertTrue(prefixPattern.matcher(embeddedSubsetFontName).matches()); } @Test public void getEmptyPdfStreamTest() { TestFont font = new TestFont(); - Exception e = Assert.assertThrows(PdfException.class, + Exception e = Assertions.assertThrows(PdfException.class, () -> font.getPdfFontStream(null, null) ); - Assert.assertEquals(KernelExceptionMessageConstant.FONT_EMBEDDING_ISSUE, e.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.FONT_EMBEDDING_ISSUE, e.getMessage()); } @Test @@ -555,10 +554,10 @@ public void getPdfStreamTest() { } int[] fontStreamLength = new int[] {10, 20, 30}; PdfStream stream = font.getPdfFontStream(data, fontStreamLength); - Assert.assertArrayEquals(data, stream.getBytes()); - Assert.assertEquals(10, stream.getAsNumber(new PdfName("Length1")).intValue()); - Assert.assertEquals(20, stream.getAsNumber(new PdfName("Length2")).intValue()); - Assert.assertEquals(30, stream.getAsNumber(new PdfName("Length3")).intValue()); + Assertions.assertArrayEquals(data, stream.getBytes()); + Assertions.assertEquals(10, stream.getAsNumber(new PdfName("Length1")).intValue()); + Assertions.assertEquals(20, stream.getAsNumber(new PdfName("Length2")).intValue()); + Assertions.assertEquals(30, stream.getAsNumber(new PdfName("Length3")).intValue()); } @Test @@ -566,15 +565,15 @@ public void getFontProgramTest() { TestFont font = new TestFont(); TestFontProgram program = new TestFontProgram(); - Assert.assertNull(font.getFontProgram()); + Assertions.assertNull(font.getFontProgram()); font.setFontProgram(program); - Assert.assertEquals(program, font.getFontProgram()); + Assertions.assertEquals(program, font.getFontProgram()); } @Test public void toStringTest() { TestFont font = new TestFont(); - Assert.assertEquals("PdfFont{fontProgram=" + font.fontProgram + "}", font.toString()); + Assertions.assertEquals("PdfFont{fontProgram=" + font.fontProgram + "}", font.toString()); } @Test @@ -587,9 +586,9 @@ public void makeObjectIndirectWhileFontIsIndirectTest() { font.getPdfObject().makeIndirect(document); PdfDictionary dictionary = new PdfDictionary(); - Assert.assertTrue(font.makeObjectIndirect(dictionary)); - Assert.assertNotNull(dictionary.getIndirectReference()); - Assert.assertEquals(document, dictionary.getIndirectReference().getDocument()); + Assertions.assertTrue(font.makeObjectIndirect(dictionary)); + Assertions.assertNotNull(dictionary.getIndirectReference()); + Assertions.assertEquals(document, dictionary.getIndirectReference().getDocument()); } } @@ -598,8 +597,8 @@ public void makeObjectIndirectWhileFontIsDirectTest() { TestFont font = new TestFont(); PdfDictionary dictionary = new PdfDictionary(); - Assert.assertFalse(font.makeObjectIndirect(dictionary)); - Assert.assertNull(dictionary.getIndirectReference()); + Assertions.assertFalse(font.makeObjectIndirect(dictionary)); + Assertions.assertNull(dictionary.getIndirectReference()); } private char[] getSentence(int... lengthsOfWords) { @@ -629,24 +628,24 @@ private char[] getSentence(int... lengthsOfWords) { @Test public void cannotGetFontStreamForNullBytesTest() throws IOException { PdfFont pdfFont = PdfFontFactory.createFont(); - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> pdfFont.getPdfFontStream(null, new int[] {1})); - Assert.assertEquals(KernelExceptionMessageConstant.FONT_EMBEDDING_ISSUE, exception.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.FONT_EMBEDDING_ISSUE, exception.getMessage()); } @Test public void cannotGetFontStreamForNullLengthsTest() throws IOException { PdfFont pdfFont = PdfFontFactory.createFont(); - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> pdfFont.getPdfFontStream(new byte[] {1}, null)); - Assert.assertEquals(KernelExceptionMessageConstant.FONT_EMBEDDING_ISSUE, exception.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.FONT_EMBEDDING_ISSUE, exception.getMessage()); } @Test public void cannotGetFontStreamForNullBytesAndLengthsTest() throws IOException { PdfFont pdfFont = PdfFontFactory.createFont(); - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> pdfFont.getPdfFontStream(null, null)); - Assert.assertEquals(KernelExceptionMessageConstant.FONT_EMBEDDING_ISSUE, exception.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.FONT_EMBEDDING_ISSUE, exception.getMessage()); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/font/PdfSimpleFontTest.java b/kernel/src/test/java/com/itextpdf/kernel/font/PdfSimpleFontTest.java index 7405a52826..40f4c4faed 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/font/PdfSimpleFontTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/font/PdfSimpleFontTest.java @@ -31,18 +31,17 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.kernel.pdf.PdfOutputStream; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.ArrayList; import java.util.List; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfSimpleFontTest extends ExtendedITextTest { private static final byte T_CODE = 116; @@ -55,7 +54,7 @@ public class PdfSimpleFontTest extends ExtendedITextTest { private static Glyph T_GLYPH_FONT_SPECIFIC; private static Glyph E_GLYPH_CUSTOM_MAPPED; - @BeforeClass + @BeforeAll public static void init() { T_GLYPH_FONT_SPECIFIC = new Glyph(T_CODE, 278, 116, new int[]{14, -7, 257, 669}); T_GLYPH_FONT_SPECIFIC.setChars(new char[]{'t'}); @@ -77,7 +76,7 @@ public void createGlyphLineWithSpecificEncodingTest() throws IOException { glyphs.add(E_GLYPH_FONT_SPECIFIC); GlyphLine expected = new GlyphLine(glyphs, 0, 2); - Assert.assertEquals(expected, glyphLine); + Assertions.assertEquals(expected, glyphLine); } @Test @@ -89,7 +88,7 @@ public void createGlyphLineWithEmptyEncodingTest() throws IOException { glyphs.add(E_GLYPH_CUSTOM_MAPPED); GlyphLine expected = new GlyphLine(glyphs, 0, 1); - Assert.assertEquals(expected, glyphLine); + Assertions.assertEquals(expected, glyphLine); } @Test @@ -97,13 +96,13 @@ public void appendGlyphsWithSpecificEncodingTest() throws IOException { PdfSimpleFont fontToTest = new TestSimpleFont(FontEncoding.createFontSpecificEncoding()); List toAppend = new ArrayList<>(); int processed = fontToTest.appendGlyphs("te", 0, 1, toAppend); - Assert.assertEquals(2, processed); + Assertions.assertEquals(2, processed); List glyphs = new ArrayList<>(); glyphs.add(T_GLYPH_FONT_SPECIFIC); glyphs.add(E_GLYPH_FONT_SPECIFIC); - Assert.assertEquals(glyphs, toAppend); + Assertions.assertEquals(glyphs, toAppend); } @Test @@ -111,13 +110,13 @@ public void appendGlyphsWithEmptyEncodingTest() throws IOException { PdfSimpleFont fontToTest = new TestSimpleFont(FontEncoding.createEmptyFontEncoding()); List toAppend = new ArrayList<>(); int processed = fontToTest.appendGlyphs("e ete", 0, 4, toAppend); - Assert.assertEquals(3, processed); + Assertions.assertEquals(3, processed); List glyphs = new ArrayList<>(); glyphs.add(E_GLYPH_CUSTOM_MAPPED); glyphs.add(E_GLYPH_CUSTOM_MAPPED); - Assert.assertEquals(glyphs, toAppend); + Assertions.assertEquals(glyphs, toAppend); } @Test @@ -125,12 +124,12 @@ public void appendAnyGlyphWithSpecificEncodingTest() throws IOException { PdfSimpleFont fontToTest = new TestSimpleFont(FontEncoding.createFontSpecificEncoding()); List toAppend = new ArrayList<>(); int processed = fontToTest.appendAnyGlyph("te", 0, toAppend); - Assert.assertEquals(1, processed); + Assertions.assertEquals(1, processed); List glyphs = new ArrayList<>(); glyphs.add(T_GLYPH_FONT_SPECIFIC); - Assert.assertEquals(glyphs, toAppend); + Assertions.assertEquals(glyphs, toAppend); } @Test @@ -138,12 +137,12 @@ public void appendAnyGlyphWithEmptyEncodingTest() throws IOException { PdfSimpleFont fontToTest = new TestSimpleFont(FontEncoding.createEmptyFontEncoding()); List toAppend = new ArrayList<>(); int processed = fontToTest.appendAnyGlyph("e ete", 0, toAppend); - Assert.assertEquals(1, processed); + Assertions.assertEquals(1, processed); List glyphs = new ArrayList<>(); glyphs.add(E_GLYPH_CUSTOM_MAPPED); - Assert.assertEquals(glyphs, toAppend); + Assertions.assertEquals(glyphs, toAppend); } @Test @@ -157,7 +156,7 @@ public void convertGlyphLineToBytesWithSpecificEncodingTest() throws IOException byte[] bytes = fontToTest.convertToBytes(glyphLine); - Assert.assertArrayEquals(new byte[]{T_CODE, E_CODE}, bytes); + Assertions.assertArrayEquals(new byte[]{T_CODE, E_CODE}, bytes); } @Test @@ -171,7 +170,7 @@ public void convertGlyphLineToBytesWithEmptyEncodingTest() throws IOException { byte[] bytes = fontToTest.convertToBytes(glyphLine); - Assert.assertArrayEquals(new byte[0], bytes); + Assertions.assertArrayEquals(new byte[0], bytes); } @Test @@ -180,7 +179,7 @@ public void convertToBytesWithNullEntry() throws IOException { byte[] bytes = fontToTest.convertToBytes((GlyphLine) null); - Assert.assertArrayEquals(new byte[0], bytes); + Assertions.assertArrayEquals(new byte[0], bytes); } @Test @@ -189,7 +188,7 @@ public void convertGlyphToBytesWithSpecificEncodingTest() throws IOException { byte[] bytes = fontToTest.convertToBytes(E_GLYPH_FONT_SPECIFIC); - Assert.assertArrayEquals(new byte[]{E_CODE}, bytes); + Assertions.assertArrayEquals(new byte[]{E_CODE}, bytes); } @Test @@ -200,7 +199,7 @@ public void convertGlyphToBytesWithCustomEncodingTest() throws IOException { byte[] bytes = fontToTest.convertToBytes(E_GLYPH_FONT_SPECIFIC); - Assert.assertArrayEquals(new byte[]{E_CUSTOM_CODE}, bytes); + Assertions.assertArrayEquals(new byte[]{E_CUSTOM_CODE}, bytes); } @Test @@ -209,7 +208,7 @@ public void convertGlyphToBytesWithEmptyEncodingTest() throws IOException { byte[] bytes = fontToTest.convertToBytes(E_GLYPH_FONT_SPECIFIC); - Assert.assertArrayEquals(new byte[0], bytes); + Assertions.assertArrayEquals(new byte[0], bytes); } @Test @@ -226,7 +225,7 @@ public void writeTextGlyphLineWithSpecificEncodingTest() throws IOException { fontToTest.writeText(glyphLine, 0, 1, pos); } - Assert.assertArrayEquals(new byte[]{OPEN_BRACKET_CODE, T_CODE, E_CODE, CLOSE_BRACKET_CODE}, bos.toByteArray()); + Assertions.assertArrayEquals(new byte[]{OPEN_BRACKET_CODE, T_CODE, E_CODE, CLOSE_BRACKET_CODE}, bos.toByteArray()); } @Test @@ -245,7 +244,7 @@ public void writeTextGlyphLineWithCustomEncodingTest() throws IOException { fontToTest.writeText(glyphLine, 0, 1, pos); } - Assert.assertArrayEquals(new byte[]{OPEN_BRACKET_CODE, E_CUSTOM_CODE, CLOSE_BRACKET_CODE}, bos.toByteArray()); + Assertions.assertArrayEquals(new byte[]{OPEN_BRACKET_CODE, E_CUSTOM_CODE, CLOSE_BRACKET_CODE}, bos.toByteArray()); } @Test @@ -262,7 +261,7 @@ public void writeTextGlyphLineWithEmptyEncodingTest() throws IOException { fontToTest.writeText(glyphLine, 0, 1, pos); } - Assert.assertArrayEquals(new byte[]{OPEN_BRACKET_CODE, CLOSE_BRACKET_CODE}, bos.toByteArray()); + Assertions.assertArrayEquals(new byte[]{OPEN_BRACKET_CODE, CLOSE_BRACKET_CODE}, bos.toByteArray()); } private static class TestSimpleFont extends PdfSimpleFont { diff --git a/kernel/src/test/java/com/itextpdf/kernel/font/PdfTrueTypeFontTest.java b/kernel/src/test/java/com/itextpdf/kernel/font/PdfTrueTypeFontTest.java index 11a441013f..588108ec36 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/font/PdfTrueTypeFontTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/font/PdfTrueTypeFontTest.java @@ -29,14 +29,13 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfName; import com.itextpdf.kernel.pdf.PdfReader; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.IOException; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfTrueTypeFontTest extends ExtendedITextTest { public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/kernel/font/PdfTrueTypeFontTest/"; @@ -51,15 +50,15 @@ public void testReadingPdfTrueTypeFontWithType1StandardFontProgram() throws IOEx PdfDictionary fontDict = pdfDocument.getPage(1).getResources().getResource(PdfName.Font).getAsDictionary(new PdfName("F1")); PdfFont pdfFont = PdfFontFactory.createFont(fontDict); - Assert.assertEquals(542, pdfFont.getFontProgram().getAvgWidth()); - Assert.assertEquals(556, pdfFont.getGlyph('a').getWidth()); + Assertions.assertEquals(542, pdfFont.getFontProgram().getAvgWidth()); + Assertions.assertEquals(556, pdfFont.getGlyph('a').getWidth()); } @Test public void isBuiltInTest() { PdfFont font = PdfFontFactory.createFont(createTrueTypeFontDictionaryWithStandardHelveticaFont()); - Assert.assertTrue(font instanceof PdfTrueTypeFont); - Assert.assertTrue(((PdfTrueTypeFont) font).isBuiltInFont()); + Assertions.assertTrue(font instanceof PdfTrueTypeFont); + Assertions.assertTrue(((PdfTrueTypeFont) font).isBuiltInFont()); } @Test @@ -67,8 +66,8 @@ public void isNotBuiltInTest() throws IOException { PdfFont font = PdfFontFactory.createFont( SOURCE_FOLDER + "NotoSans-Regular.ttf", PdfEncodings.WINANSI); - Assert.assertTrue(font instanceof PdfTrueTypeFont); - Assert.assertFalse(((PdfTrueTypeFont) font).isBuiltInFont()); + Assertions.assertTrue(font instanceof PdfTrueTypeFont); + Assertions.assertFalse(((PdfTrueTypeFont) font).isBuiltInFont()); } private static PdfDictionary createTrueTypeFontDictionaryWithStandardHelveticaFont() { diff --git a/kernel/src/test/java/com/itextpdf/kernel/font/PdfType0FontTest.java b/kernel/src/test/java/com/itextpdf/kernel/font/PdfType0FontTest.java index e443f6706b..09efb07160 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/font/PdfType0FontTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/font/PdfType0FontTest.java @@ -31,18 +31,17 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.exceptions.PdfException; import com.itextpdf.kernel.pdf.*; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.File; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfType0FontTest extends ExtendedITextTest { public static final String DESTINATION_FOLDER = "./target/test/resources/com/itextpdf/kernel/font/PdfType0FontTest/"; @@ -56,24 +55,24 @@ public void trueTypeFontAndCmapConstructorTest() throws IOException { CMapEncoding cmap = type0Font.getCmap(); - Assert.assertNotNull(cmap); - Assert.assertTrue(cmap.isDirect()); - Assert.assertFalse(cmap.hasUniMap()); - Assert.assertNull(cmap.getUniMapName()); - Assert.assertEquals("Adobe", cmap.getRegistry()); - Assert.assertEquals("Identity", cmap.getOrdering()); - Assert.assertEquals(0, cmap.getSupplement()); - Assert.assertEquals(PdfEncodings.IDENTITY_H, cmap.getCmapName()); + Assertions.assertNotNull(cmap); + Assertions.assertTrue(cmap.isDirect()); + Assertions.assertFalse(cmap.hasUniMap()); + Assertions.assertNull(cmap.getUniMapName()); + Assertions.assertEquals("Adobe", cmap.getRegistry()); + Assertions.assertEquals("Identity", cmap.getOrdering()); + Assertions.assertEquals(0, cmap.getSupplement()); + Assertions.assertEquals(PdfEncodings.IDENTITY_H, cmap.getCmapName()); } @Test public void unsupportedCmapTest() throws IOException { TrueTypeFont ttf = new TrueTypeFont(SOURCE_FOLDER + "NotoSerif-Regular_v1.7.ttf"); - Exception e = Assert.assertThrows(PdfException.class, + Exception e = Assertions.assertThrows(PdfException.class, () -> new PdfType0Font(ttf, PdfEncodings.WINANSI) ); - Assert.assertEquals(KernelExceptionMessageConstant.ONLY_IDENTITY_CMAPS_SUPPORTS_WITH_TRUETYPE, e.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.ONLY_IDENTITY_CMAPS_SUPPORTS_WITH_TRUETYPE, e.getMessage()); } @Test @@ -89,14 +88,14 @@ public void dictionaryConstructorTest() throws IOException { CMapEncoding cmap = type0Font.getCmap(); - Assert.assertNotNull(cmap); - Assert.assertTrue(cmap.isDirect()); - Assert.assertFalse(cmap.hasUniMap()); - Assert.assertNull(cmap.getUniMapName()); - Assert.assertEquals("Adobe", cmap.getRegistry()); - Assert.assertEquals("Identity", cmap.getOrdering()); - Assert.assertEquals(0, cmap.getSupplement()); - Assert.assertEquals(PdfEncodings.IDENTITY_H, cmap.getCmapName()); + Assertions.assertNotNull(cmap); + Assertions.assertTrue(cmap.isDirect()); + Assertions.assertFalse(cmap.hasUniMap()); + Assertions.assertNull(cmap.getUniMapName()); + Assertions.assertEquals("Adobe", cmap.getRegistry()); + Assertions.assertEquals("Identity", cmap.getOrdering()); + Assertions.assertEquals(0, cmap.getSupplement()); + Assertions.assertEquals(PdfEncodings.IDENTITY_H, cmap.getCmapName()); } @Test @@ -108,25 +107,25 @@ public void appendThreeSurrogatePairsTest() throws IOException { List glyphs = new ArrayList<>(); type0Font.appendGlyphs(textWithThreeSurrogatePairs, 0, textWithThreeSurrogatePairs.length() - 1, glyphs); - Assert.assertEquals(3, glyphs.size()); + Assertions.assertEquals(3, glyphs.size()); } @Test public void getUniMapFromOrderingTest() { - Assert.assertEquals("UniCNS-UTF16-H", PdfType0Font.getUniMapFromOrdering("CNS1", true)); - Assert.assertEquals("UniCNS-UTF16-V", PdfType0Font.getUniMapFromOrdering("CNS1", false)); + Assertions.assertEquals("UniCNS-UTF16-H", PdfType0Font.getUniMapFromOrdering("CNS1", true)); + Assertions.assertEquals("UniCNS-UTF16-V", PdfType0Font.getUniMapFromOrdering("CNS1", false)); - Assert.assertEquals("UniJIS-UTF16-H", PdfType0Font.getUniMapFromOrdering("Japan1", true)); - Assert.assertEquals("UniJIS-UTF16-V", PdfType0Font.getUniMapFromOrdering("Japan1", false)); + Assertions.assertEquals("UniJIS-UTF16-H", PdfType0Font.getUniMapFromOrdering("Japan1", true)); + Assertions.assertEquals("UniJIS-UTF16-V", PdfType0Font.getUniMapFromOrdering("Japan1", false)); - Assert.assertEquals("UniKS-UTF16-H", PdfType0Font.getUniMapFromOrdering("Korea1", true)); - Assert.assertEquals("UniKS-UTF16-V", PdfType0Font.getUniMapFromOrdering("Korea1", false)); + Assertions.assertEquals("UniKS-UTF16-H", PdfType0Font.getUniMapFromOrdering("Korea1", true)); + Assertions.assertEquals("UniKS-UTF16-V", PdfType0Font.getUniMapFromOrdering("Korea1", false)); - Assert.assertEquals("UniGB-UTF16-H", PdfType0Font.getUniMapFromOrdering("GB1", true)); - Assert.assertEquals("UniGB-UTF16-V", PdfType0Font.getUniMapFromOrdering("GB1", false)); + Assertions.assertEquals("UniGB-UTF16-H", PdfType0Font.getUniMapFromOrdering("GB1", true)); + Assertions.assertEquals("UniGB-UTF16-V", PdfType0Font.getUniMapFromOrdering("GB1", false)); - Assert.assertEquals("Identity-H", PdfType0Font.getUniMapFromOrdering("Identity", true)); - Assert.assertEquals("Identity-V", PdfType0Font.getUniMapFromOrdering("Identity", false)); + Assertions.assertEquals("Identity-H", PdfType0Font.getUniMapFromOrdering("Identity", true)); + Assertions.assertEquals("Identity-V", PdfType0Font.getUniMapFromOrdering("Identity", false)); } @Test @@ -139,8 +138,8 @@ public void descendantCidFontWithoutOrderingTest() { fontDict.put(PdfName.DescendantFonts, descendantFonts); - Exception e = Assert.assertThrows(PdfException.class, () -> new PdfType0Font(fontDict)); - Assert.assertEquals(KernelExceptionMessageConstant.ORDERING_SHOULD_BE_DETERMINED, e.getMessage()); + Exception e = Assertions.assertThrows(PdfException.class, () -> new PdfType0Font(fontDict)); + Assertions.assertEquals(KernelExceptionMessageConstant.ORDERING_SHOULD_BE_DETERMINED, e.getMessage()); } @@ -160,7 +159,7 @@ public void convertToBytesNoEncoderTest() throws IOException { PdfFont font = PdfFontFactory.createFont("STSong-Light", "UniGB-UCS2-H", PdfFontFactory.EmbeddingStrategy.PREFER_NOT_EMBEDDED); GlyphLine line = new GlyphLine(constructGlyphListFromString("\u5341\u950a\u57cb\u4f0f", font)); byte[] result = font.convertToBytes(line); - Assert.assertArrayEquals(expected, result); + Assertions.assertArrayEquals(expected, result); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/font/PdfType3FontTest.java b/kernel/src/test/java/com/itextpdf/kernel/font/PdfType3FontTest.java index e0df949a19..9b8a4b7c33 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/font/PdfType3FontTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/font/PdfType3FontTest.java @@ -37,13 +37,12 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfType3FontTest extends ExtendedITextTest { private static final float EPS = 1e-4f; @@ -65,14 +64,14 @@ protected PdfDocument getDocument() { return null; } }; - Assert.assertNotNull(type3Font.getFontProgram()); + Assertions.assertNotNull(type3Font.getFontProgram()); int spaceGlyphCode = 32; Glyph glyph = type3Font.getFontProgram().getGlyph(spaceGlyphCode); - Assert.assertEquals(new Glyph(spaceGlyphCode, 0, new char[]{' '}), glyph); + Assertions.assertEquals(new Glyph(spaceGlyphCode, 0, new char[]{' '}), glyph); int AGlyphCode = 65; glyph = type3Font.getFontProgram().getGlyph(AGlyphCode); - Assert.assertEquals(new Glyph(AGlyphCode, 0, new char[] {'A'}), glyph); + Assertions.assertEquals(new Glyph(AGlyphCode, 0, new char[] {'A'}), glyph); } @Test @@ -92,11 +91,11 @@ protected PdfDocument getDocument() { }; Type3Glyph type3Glyph = type3Font.addGlyph('A', 1, 2, 3, 5, 8); - Assert.assertEquals(0, type3Glyph.getWx(), EPS); - Assert.assertEquals(0, type3Glyph.getLlx(), EPS); - Assert.assertEquals(0, type3Glyph.getLly(), EPS); - Assert.assertEquals(0, type3Glyph.getUrx(), EPS); - Assert.assertEquals(0, type3Glyph.getUry(), EPS); + Assertions.assertEquals(0, type3Glyph.getWx(), EPS); + Assertions.assertEquals(0, type3Glyph.getLlx(), EPS); + Assertions.assertEquals(0, type3Glyph.getLly(), EPS); + Assertions.assertEquals(0, type3Glyph.getUrx(), EPS); + Assertions.assertEquals(0, type3Glyph.getUry(), EPS); } @Test @@ -111,9 +110,9 @@ public void setFontStretchTest() { String fontStretch = "test"; type3Font.setFontStretch(fontStretch); - Assert.assertNotNull(type3Font.fontProgram); - Assert.assertNotNull(type3Font.fontProgram.getFontNames()); - Assert.assertEquals(fontStretch, type3Font.fontProgram.getFontNames().getFontStretch()); + Assertions.assertNotNull(type3Font.fontProgram); + Assertions.assertNotNull(type3Font.fontProgram.getFontNames()); + Assertions.assertEquals(fontStretch, type3Font.fontProgram.getFontNames().getFontStretch()); } @Test @@ -128,8 +127,8 @@ public void setPdfFontFlagsTest() { int randomTestFontFlagsValue = 5; type3Font.setPdfFontFlags(randomTestFontFlagsValue); - Assert.assertNotNull(type3Font.fontProgram); - Assert.assertEquals(randomTestFontFlagsValue, type3Font.fontProgram.getPdfFontFlags()); + Assertions.assertNotNull(type3Font.fontProgram); + Assertions.assertEquals(randomTestFontFlagsValue, type3Font.fontProgram.getPdfFontFlags()); } @Test @@ -143,7 +142,7 @@ public void glyphWithUnicodeBiggerThan32CannotBeEncodedTest() { PdfType3Font type3Font = new PdfType3Font(dictionary); int cannotEncodeAndAUnicodeBiggerThan32TestValue = 333; - Assert.assertNull(type3Font.getGlyph(cannotEncodeAndAUnicodeBiggerThan32TestValue)); + Assertions.assertNull(type3Font.getGlyph(cannotEncodeAndAUnicodeBiggerThan32TestValue)); } @Test @@ -161,13 +160,13 @@ protected PdfDocument getDocument() { } }; - Assert.assertFalse(type3Font.containsGlyph(333)); - Assert.assertFalse(type3Font.containsGlyph(-5)); - Assert.assertFalse(type3Font.containsGlyph(32)); + Assertions.assertFalse(type3Font.containsGlyph(333)); + Assertions.assertFalse(type3Font.containsGlyph(-5)); + Assertions.assertFalse(type3Font.containsGlyph(32)); type3Font.addGlyph(' ', 0, 0, 0, 1, 1); - Assert.assertTrue(type3Font.containsGlyph(32)); + Assertions.assertTrue(type3Font.containsGlyph(32)); type3Font.addGlyph('A', 0, 0, 0, 0, 0); - Assert.assertTrue(type3Font.containsGlyph(65)); + Assertions.assertTrue(type3Font.containsGlyph(65)); } @Test @@ -180,10 +179,10 @@ public void flushExceptionTest() { dictionary.put(PdfName.Widths, new PdfArray()); PdfType3Font type3Font = new DisableEnsureUnderlyingObjectHasIndirectReference(dictionary); - Exception e = Assert.assertThrows(PdfException.class, + Exception e = Assertions.assertThrows(PdfException.class, () -> type3Font.flush() ); - Assert.assertEquals(KernelExceptionMessageConstant.NO_GLYPHS_DEFINED_FOR_TYPE_3_FONT, e.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.NO_GLYPHS_DEFINED_FOR_TYPE_3_FONT, e.getMessage()); } @Test @@ -204,9 +203,9 @@ protected PdfDocument getDocument() { return null; } }; - Assert.assertNotNull(type3Font.fontProgram); - Assert.assertNotNull(type3Font.fontProgram.getFontNames()); - Assert.assertEquals(fontStretch, type3Font.fontProgram.getFontNames().getFontStretch()); + Assertions.assertNotNull(type3Font.fontProgram); + Assertions.assertNotNull(type3Font.fontProgram.getFontNames()); + Assertions.assertEquals(fontStretch, type3Font.fontProgram.getFontNames().getFontStretch()); } @Test @@ -252,10 +251,10 @@ public void missingFontMatrixTest() { dictionary.put(PdfName.ToUnicode, PdfName.IdentityH); dictionary.put(PdfName.Encoding, new PdfName("zapfdingbatsencoding")); - Exception e = Assert.assertThrows(PdfException.class, + Exception e = Assertions.assertThrows(PdfException.class, () -> new PdfType3Font(dictionary) ); - Assert.assertEquals(MessageFormatUtil.format(KernelExceptionMessageConstant.MISSING_REQUIRED_FIELD_IN_FONT_DICTIONARY, PdfName.FontMatrix), e.getMessage()); + Assertions.assertEquals(MessageFormatUtil.format(KernelExceptionMessageConstant.MISSING_REQUIRED_FIELD_IN_FONT_DICTIONARY, PdfName.FontMatrix), e.getMessage()); } @Test @@ -265,10 +264,10 @@ public void missingWidthsTest() { dictionary.put(PdfName.ToUnicode, PdfName.IdentityH); dictionary.put(PdfName.Encoding, new PdfName("zapfdingbatsencoding")); - Exception e = Assert.assertThrows(PdfException.class, + Exception e = Assertions.assertThrows(PdfException.class, () -> new PdfType3Font(dictionary) ); - Assert.assertEquals(MessageFormatUtil.format( + Assertions.assertEquals(MessageFormatUtil.format( KernelExceptionMessageConstant.MISSING_REQUIRED_FIELD_IN_FONT_DICTIONARY, PdfName.Widths), e.getMessage()); } diff --git a/kernel/src/test/java/com/itextpdf/kernel/font/Type3FontTest.java b/kernel/src/test/java/com/itextpdf/kernel/font/Type3FontTest.java index d49d2d89a5..491f9926dc 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/font/Type3FontTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/font/Type3FontTest.java @@ -23,13 +23,12 @@ This file is part of the iText (R) project. package com.itextpdf.kernel.font; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class Type3FontTest extends ExtendedITextTest { @Test @@ -38,7 +37,7 @@ public void addGlyphTest() { font.addGlyph(1, 1, 600, null, null); - Assert.assertEquals(1, font.getNumberOfGlyphs()); + Assertions.assertEquals(1, font.getNumberOfGlyphs()); } @Test @@ -48,9 +47,9 @@ public void addGlyphsWithDifferentUnicodeTest() { font.addGlyph(1, 1, 600, null, null); font.addGlyph(2, 2, 600, null, null); - Assert.assertEquals(2, font.getNumberOfGlyphs()); - Assert.assertEquals(1, font.getGlyphByCode(1).getUnicode()); - Assert.assertEquals(2, font.getGlyphByCode(2).getUnicode()); + Assertions.assertEquals(2, font.getNumberOfGlyphs()); + Assertions.assertEquals(1, font.getGlyphByCode(1).getUnicode()); + Assertions.assertEquals(2, font.getGlyphByCode(2).getUnicode()); } @Test @@ -60,9 +59,9 @@ public void addGlyphsWithDifferentCodesTest() { font.addGlyph(1, -1, 600, null, null); font.addGlyph(2, -1, 700, null, null); - Assert.assertEquals(2, font.getNumberOfGlyphs()); - Assert.assertEquals(600, font.getGlyphByCode(1).getWidth()); - Assert.assertEquals(700, font.getGlyphByCode(2).getWidth()); + Assertions.assertEquals(2, font.getNumberOfGlyphs()); + Assertions.assertEquals(600, font.getGlyphByCode(1).getWidth()); + Assertions.assertEquals(700, font.getGlyphByCode(2).getWidth()); } @Test @@ -72,8 +71,8 @@ public void replaceGlyphsWithSameUnicodeTest() { font.addGlyph(1, 1, 600, null, null); font.addGlyph(2, 1, 600, null, null); - Assert.assertEquals(1, font.getNumberOfGlyphs()); - Assert.assertEquals(2, font.getGlyph(1).getCode()); + Assertions.assertEquals(1, font.getNumberOfGlyphs()); + Assertions.assertEquals(2, font.getGlyph(1).getCode()); } @Test @@ -83,8 +82,8 @@ public void replaceGlyphWithSameCodeTest() { font.addGlyph(1, -1, 600, null, null); font.addGlyph(1, -1, 700, null, null); - Assert.assertEquals(1, font.getNumberOfGlyphs()); - Assert.assertEquals(700, font.getGlyphByCode(1).getWidth()); + Assertions.assertEquals(1, font.getNumberOfGlyphs()); + Assertions.assertEquals(700, font.getGlyphByCode(1).getWidth()); } @Test @@ -94,9 +93,9 @@ public void notAddGlyphWithSameCodeEmptyUnicodeFirstTest() { font.addGlyph(1, -1, 600, null, null); font.addGlyph(1, 100, 600, null, null); - Assert.assertEquals(1, font.getNumberOfGlyphs()); - Assert.assertEquals(1, font.getGlyph(100).getCode()); - Assert.assertEquals(100, font.getGlyphByCode(1).getUnicode()); + Assertions.assertEquals(1, font.getNumberOfGlyphs()); + Assertions.assertEquals(1, font.getGlyph(100).getCode()); + Assertions.assertEquals(100, font.getGlyphByCode(1).getUnicode()); } @Test @@ -106,9 +105,9 @@ public void replaceGlyphWithSameCodeEmptyUnicodeLastTest() { font.addGlyph(1, 100, 600, null, null); font.addGlyph(1, -1, 600, null, null); - Assert.assertNull(font.getGlyph(-1)); - Assert.assertNull(font.getGlyph(100)); - Assert.assertEquals(1, font.getNumberOfGlyphs()); - Assert.assertEquals(-1, font.getGlyphByCode(1).getUnicode()); + Assertions.assertNull(font.getGlyph(-1)); + Assertions.assertNull(font.getGlyph(100)); + Assertions.assertEquals(1, font.getNumberOfGlyphs()); + Assertions.assertEquals(-1, font.getGlyphByCode(1).getUnicode()); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/font/Type3GlyphUnitTest.java b/kernel/src/test/java/com/itextpdf/kernel/font/Type3GlyphUnitTest.java index 2263dfe03b..39dba0d4c7 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/font/Type3GlyphUnitTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/font/Type3GlyphUnitTest.java @@ -29,15 +29,14 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfStream; import com.itextpdf.kernel.pdf.PdfWriter; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.ByteArrayOutputStream; import java.net.MalformedURLException; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class Type3GlyphUnitTest extends ExtendedITextTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/kernel/font/Type3GlyphUnitTest/"; @@ -47,9 +46,9 @@ public void addImageWithoutMaskTest() throws MalformedURLException { PdfDocument pdfDoc = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); Type3Glyph glyph = new Type3Glyph(new PdfStream(), pdfDoc); ImageData img = ImageDataFactory.create(SOURCE_FOLDER + "imageTest.png"); - Exception e = Assert.assertThrows(PdfException.class, + Exception e = Assertions.assertThrows(PdfException.class, () -> glyph.addImageWithTransformationMatrix(img, 100, 0, 0, 100, 0, 0, false)); - Assert.assertEquals("Not colorized type3 fonts accept only mask images.", e.getMessage()); + Assertions.assertEquals("Not colorized type3 fonts accept only mask images.", e.getMessage()); } @Test @@ -58,7 +57,7 @@ public void addInlineImageMaskTest() throws MalformedURLException { Type3Glyph glyph = new Type3Glyph(new PdfStream(), pdfDoc); ImageData img = ImageDataFactory.create(SOURCE_FOLDER + "imageTest.png"); img.makeMask(); - Assert.assertNull(glyph.addImageWithTransformationMatrix(img, 100, 0, 0, 100, 0, 0, true)); + Assertions.assertNull(glyph.addImageWithTransformationMatrix(img, 100, 0, 0, 100, 0, 0, true)); } @Test @@ -68,7 +67,7 @@ public void addImageMaskAsNotInlineTest() throws MalformedURLException { Type3Glyph glyph = new Type3Glyph(new PdfStream(), pdfDoc); ImageData img = ImageDataFactory.create(SOURCE_FOLDER + "imageTest.png"); img.makeMask(); - Assert.assertThrows(NullPointerException.class, + Assertions.assertThrows(NullPointerException.class, () -> glyph.addImageWithTransformationMatrix(img, 100, 0, 0, 100, 0, 0, false)); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/geom/AffineTransformTest.java b/kernel/src/test/java/com/itextpdf/kernel/geom/AffineTransformTest.java index 698d7bf460..27d6b2d081 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/geom/AffineTransformTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/geom/AffineTransformTest.java @@ -23,27 +23,26 @@ This file is part of the iText (R) project. package com.itextpdf.kernel.geom; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class AffineTransformTest extends ExtendedITextTest { @Test public void selfTest() { AffineTransform affineTransform = new AffineTransform(); - Assert.assertTrue(affineTransform.equals(affineTransform)); + Assertions.assertTrue(affineTransform.equals(affineTransform)); } @Test public void nullTest() { AffineTransform affineTransform = new AffineTransform(); - Assert.assertFalse(affineTransform.equals(null)); + Assertions.assertFalse(affineTransform.equals(null)); } @Test @@ -51,7 +50,7 @@ public void otherClassTest() { AffineTransform affineTransform = new AffineTransform(); String string = "Test"; - Assert.assertFalse(affineTransform.equals(string)); + Assertions.assertFalse(affineTransform.equals(string)); } @Test @@ -61,9 +60,9 @@ public void sameValuesTest() { int hash1 = affineTransform1.hashCode(); int hash2 = affineTransform2.hashCode(); - Assert.assertFalse(affineTransform1 == affineTransform2); - Assert.assertEquals(hash1, hash2); - Assert.assertTrue(affineTransform1.equals(affineTransform2)); + Assertions.assertFalse(affineTransform1 == affineTransform2); + Assertions.assertEquals(hash1, hash2); + Assertions.assertTrue(affineTransform1.equals(affineTransform2)); } @Test @@ -73,9 +72,9 @@ public void differentValuesTest() { int hash1 = affineTransform1.hashCode(); int hash2 = affineTransform2.hashCode(); - Assert.assertFalse(affineTransform1 == affineTransform2); - Assert.assertNotEquals(hash1, hash2); - Assert.assertFalse(affineTransform1.equals(affineTransform2)); + Assertions.assertFalse(affineTransform1 == affineTransform2); + Assertions.assertNotEquals(hash1, hash2); + Assertions.assertFalse(affineTransform1.equals(affineTransform2)); } @Test @@ -83,7 +82,7 @@ public void getRotateInstanceTest() { AffineTransform rotateOne = AffineTransform.getRotateInstance(Math.PI / 2); AffineTransform expected = new AffineTransform(0, 1, -1, 0, 0, 0); - Assert.assertEquals(rotateOne, expected); + Assertions.assertEquals(rotateOne, expected); } @Test @@ -91,7 +90,7 @@ public void getRotateInstanceTranslateTest() { AffineTransform rotateTranslate = AffineTransform.getRotateInstance(Math.PI / 2, 10, 5); AffineTransform expected = new AffineTransform(0, 1, -1, 0, 15, -5); - Assert.assertEquals(rotateTranslate, expected); + Assertions.assertEquals(rotateTranslate, expected); } @Test @@ -99,8 +98,8 @@ public void cloneTest() throws CloneNotSupportedException { AffineTransform original = new AffineTransform(); AffineTransform clone = original.clone(); - Assert.assertTrue(original != clone); - Assert.assertTrue(original.equals(clone)); + Assertions.assertTrue(original != clone); + Assertions.assertTrue(original.equals(clone)); } @Test @@ -108,13 +107,13 @@ public void getTransformValuesTest() { float[] matrix = new float[]{0f, 1f, 2f, 3f, 4f, 5f}; AffineTransform affineTransform = new AffineTransform(matrix); - Assert.assertEquals(matrix[0], affineTransform.getScaleX(), 0.0); - Assert.assertEquals(matrix[3], affineTransform.getScaleY(), 0.0); - Assert.assertEquals(matrix[2], affineTransform.getShearX(), 0.0); - Assert.assertEquals(matrix[1], affineTransform.getShearY(), 0.0); - Assert.assertEquals(matrix[4], affineTransform.getTranslateX(), 0.0); - Assert.assertEquals(matrix[5], affineTransform.getTranslateY(), 0.0); - Assert.assertEquals(32, affineTransform.getType(), 0.0); + Assertions.assertEquals(matrix[0], affineTransform.getScaleX(), 0.0); + Assertions.assertEquals(matrix[3], affineTransform.getScaleY(), 0.0); + Assertions.assertEquals(matrix[2], affineTransform.getShearX(), 0.0); + Assertions.assertEquals(matrix[1], affineTransform.getShearY(), 0.0); + Assertions.assertEquals(matrix[4], affineTransform.getTranslateX(), 0.0); + Assertions.assertEquals(matrix[5], affineTransform.getTranslateY(), 0.0); + Assertions.assertEquals(32, affineTransform.getType(), 0.0); } @Test @@ -122,8 +121,8 @@ public void createAffineTransformFromOtherATTest() { AffineTransform template = new AffineTransform(0, 1, 2, 3, 4, 5); AffineTransform result = new AffineTransform(template); - Assert.assertNotSame(template, result); - Assert.assertEquals(template, result); + Assertions.assertNotSame(template, result); + Assertions.assertEquals(template, result); } @Test @@ -132,7 +131,7 @@ public void createAffineTransformFromFloatArrayTest() { AffineTransform expected = new AffineTransform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); AffineTransform result = new AffineTransform(matrix); - Assert.assertEquals(expected, result); + Assertions.assertEquals(expected, result); } @Test @@ -141,7 +140,7 @@ public void createAffineTransformFromDoubleArrayTest() { AffineTransform expected = new AffineTransform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); AffineTransform result = new AffineTransform(matrix); - Assert.assertEquals(expected, result); + Assertions.assertEquals(expected, result); } @Test @@ -152,7 +151,7 @@ public void setTransformTest() { result.setTransform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); - Assert.assertEquals(expected, result); + Assertions.assertEquals(expected, result); } @Test @@ -162,7 +161,7 @@ public void setToIdentityTest() { result.setToIdentity(); - Assert.assertEquals(expected, result); + Assertions.assertEquals(expected, result); } @Test @@ -174,7 +173,7 @@ public void setToShearTypeIdentityTest() { result.setToShear(shx, shy); - Assert.assertEquals(expected, result); + Assertions.assertEquals(expected, result); } @Test @@ -186,7 +185,7 @@ public void setToShearTypeUnknownTest() { result.setToShear(shx, shy); - Assert.assertEquals(expected, result); + Assertions.assertEquals(expected, result); } @Test @@ -196,7 +195,7 @@ public void getShearInstanceTest() { AffineTransform expected = new AffineTransform(1, shx, shy, 1, 0, 0); AffineTransform result = AffineTransform.getShearInstance(shx, shy); - Assert.assertEquals(expected, result); + Assertions.assertEquals(expected, result); } @Test @@ -208,7 +207,7 @@ public void shearTest() { result.shear(shx, shy); - Assert.assertEquals(expected, result); + Assertions.assertEquals(expected, result); } @Test @@ -219,7 +218,7 @@ public void rotateTest() { result.rotate(angle); - Assert.assertEquals(expected, result); + Assertions.assertEquals(expected, result); } @Test @@ -230,7 +229,7 @@ public void preConcatenateTest() { result.preConcatenate(template); - Assert.assertEquals(expected, result); + Assertions.assertEquals(expected, result); } @Test @@ -242,7 +241,7 @@ public void transformDoubleArrayTest() { affineTransform.transform(src, 1, dest, 1, 2); - Assert.assertArrayEquals(expected, dest, 0); + Assertions.assertArrayEquals(expected, dest, 0); } @Test @@ -253,7 +252,7 @@ public void transformDoubleArraySourceDestEqualsTest() { affineTransform.transform(src, 1, src, 2, 2); - Assert.assertArrayEquals(expected, src, 0); + Assertions.assertArrayEquals(expected, src, 0); } @Test @@ -265,7 +264,7 @@ public void transformFloatArrayTest() { affineTransform.transform(src, 1, dest, 1, 2); - Assert.assertArrayEquals(expected, dest, 0); + Assertions.assertArrayEquals(expected, dest, 0); } @Test @@ -276,7 +275,7 @@ public void transformFloatArraySourceDestEqualsTest() { affineTransform.transform(src, 1, src, 2, 2); - Assert.assertArrayEquals(expected, src, 0); + Assertions.assertArrayEquals(expected, src, 0); } @Test @@ -288,7 +287,7 @@ public void transformFloatToDoubleTest() { affineTransform.transform(src, 1, dest, 1, 2); - Assert.assertArrayEquals(expected, dest, 0); + Assertions.assertArrayEquals(expected, dest, 0); } @Test @@ -300,7 +299,7 @@ public void transformDoubleToFloatTest() { affineTransform.transform(src, 1, dest, 1, 2); - Assert.assertArrayEquals(expected, dest, 0); + Assertions.assertArrayEquals(expected, dest, 0); } @Test @@ -312,7 +311,7 @@ public void deltaTransformPointTest() { affineTransform.deltaTransform(src, dest); - Assert.assertEquals(expected, dest); + Assertions.assertEquals(expected, dest); } @Test @@ -323,7 +322,7 @@ public void deltaTransformPointNullDestTest() { Point dest = affineTransform.deltaTransform(src, null); - Assert.assertEquals(expected, dest); + Assertions.assertEquals(expected, dest); } @Test @@ -335,7 +334,7 @@ public void deltaTransformDoubleArrayTest() { affineTransform.deltaTransform(src, 1, dest, 1, 2); - Assert.assertArrayEquals(expected, dest, 0); + Assertions.assertArrayEquals(expected, dest, 0); } @Test @@ -347,7 +346,7 @@ public void inverseTransformPointTest() throws NoninvertibleTransformException { affineTransform.inverseTransform(src, dest); - Assert.assertEquals(expected, dest); + Assertions.assertEquals(expected, dest); } @Test @@ -358,7 +357,7 @@ public void inverseTransformPointNullTest() throws NoninvertibleTransformExcepti Point dest = affineTransform.inverseTransform(src, null); - Assert.assertEquals(expected, dest); + Assertions.assertEquals(expected, dest); } @Test @@ -370,7 +369,7 @@ public void inverseTransformDoubleArrayTest() throws NoninvertibleTransformExcep affineTransform.inverseTransform(src, 1, dest, 1, 2); - Assert.assertArrayEquals(expected, dest, 0); + Assertions.assertArrayEquals(expected, dest, 0); } @Test @@ -382,6 +381,6 @@ public void inverseTransformFloatArrayTest() throws NoninvertibleTransformExcept affineTransform.inverseTransform(src, 1, dest, 1, 2); - Assert.assertArrayEquals(expected, dest, 0); + Assertions.assertArrayEquals(expected, dest, 0); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/geom/BezierCurveTest.java b/kernel/src/test/java/com/itextpdf/kernel/geom/BezierCurveTest.java index 05c9a09e9d..4145b1062b 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/geom/BezierCurveTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/geom/BezierCurveTest.java @@ -23,15 +23,14 @@ This file is part of the iText (R) project. package com.itextpdf.kernel.geom; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.util.Arrays; import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class BezierCurveTest extends ExtendedITextTest { @Test @@ -54,11 +53,11 @@ public void approximationTest() { new Point(16.979065f, 1.267128f), new Point(18.180115f, 2.538719f), new Point(19.391418f, 4.102364f), new Point(20f, 5f)); - Assert.assertEquals(expectedApproximation.size(), approximation.size()); + Assertions.assertEquals(expectedApproximation.size(), approximation.size()); for (int i = 0; i < expectedApproximation.size(); ++i) { - Assert.assertEquals(expectedApproximation.get(i).getX(), approximation.get(i).getX(), 0.001f); - Assert.assertEquals(expectedApproximation.get(i).getY(), approximation.get(i).getY(), 0.001f); + Assertions.assertEquals(expectedApproximation.get(i).getX(), approximation.get(i).getX(), 0.001f); + Assertions.assertEquals(expectedApproximation.get(i).getY(), approximation.get(i).getY(), 0.001f); } } @@ -78,11 +77,11 @@ public void approximationWithEqualStartAndEndTest() { new Point(2.026978f, -3.769684f), new Point(1.497437f, -2.986908f), new Point(0.601685f, -1.262970f), new Point(0f, 0f)); - Assert.assertEquals(expectedApproximation.size(), approximation.size()); + Assertions.assertEquals(expectedApproximation.size(), approximation.size()); for (int i = 0; i < expectedApproximation.size(); ++i) { - Assert.assertEquals(expectedApproximation.get(i).getX(), approximation.get(i).getX(), 0.001f); - Assert.assertEquals(expectedApproximation.get(i).getY(), approximation.get(i).getY(), 0.001f); + Assertions.assertEquals(expectedApproximation.get(i).getX(), approximation.get(i).getX(), 0.001f); + Assertions.assertEquals(expectedApproximation.get(i).getY(), approximation.get(i).getY(), 0.001f); } } @@ -102,11 +101,11 @@ public void approximationWithEqualSecondAndEndTest() { new Point(13.888580f, -3.828888f), new Point(15.040771f, -2.459717f), new Point(17.852783f, 1.702881f), new Point(20f, 5f)); - Assert.assertEquals(expectedApproximation.size(), approximation.size()); + Assertions.assertEquals(expectedApproximation.size(), approximation.size()); for (int i = 0; i < expectedApproximation.size(); ++i) { - Assert.assertEquals(expectedApproximation.get(i).getX(), approximation.get(i).getX(), 0.001f); - Assert.assertEquals(expectedApproximation.get(i).getY(), approximation.get(i).getY(), 0.001f); + Assertions.assertEquals(expectedApproximation.get(i).getX(), approximation.get(i).getX(), 0.001f); + Assertions.assertEquals(expectedApproximation.get(i).getY(), approximation.get(i).getY(), 0.001f); } } @@ -124,11 +123,11 @@ public void approximationWithEqualStartAndEndAndHugeDistanceToleranceManhattanTe List expectedApproximation = Arrays.asList(new Point(0.000000f, 0.000000f), new Point(0.75f, 1.875f), new Point(0.000000f, 0.000000f)); - Assert.assertEquals(expectedApproximation.size(), approximation.size()); + Assertions.assertEquals(expectedApproximation.size(), approximation.size()); for (int i = 0; i < expectedApproximation.size(); ++i) { - Assert.assertEquals(expectedApproximation.get(i).getX(), approximation.get(i).getX(), 0.001f); - Assert.assertEquals(expectedApproximation.get(i).getY(), approximation.get(i).getY(), 0.001f); + Assertions.assertEquals(expectedApproximation.get(i).getX(), approximation.get(i).getX(), 0.001f); + Assertions.assertEquals(expectedApproximation.get(i).getY(), approximation.get(i).getY(), 0.001f); } } finally { BezierCurve.distanceToleranceManhattan = oldDistanceToleranceManhattan; diff --git a/kernel/src/test/java/com/itextpdf/kernel/geom/LineSegmentTest.java b/kernel/src/test/java/com/itextpdf/kernel/geom/LineSegmentTest.java index ae5a2bef8c..b1de14387c 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/geom/LineSegmentTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/geom/LineSegmentTest.java @@ -23,19 +23,18 @@ This file is part of the iText (R) project. package com.itextpdf.kernel.geom; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class LineSegmentTest extends ExtendedITextTest { @Test public void containsPointNullTest() { LineSegment lineSegment = new LineSegment(new Vector(20.3246f, 769.4974f, 1.0f), new Vector(151.22923f, 769.4974f, 1.0f)); - Assert.assertFalse(lineSegment.containsPoint(null)); + Assertions.assertFalse(lineSegment.containsPoint(null)); } @Test @@ -44,7 +43,7 @@ public void containsPointTest() { LineSegment lineSegment = new LineSegment(pointToCheck, new Vector(151.22923f, 769.4974f, 1.0f)); - Assert.assertTrue(lineSegment.containsPoint(pointToCheck)); + Assertions.assertTrue(lineSegment.containsPoint(pointToCheck)); } @Test @@ -53,7 +52,7 @@ public void notContainsPointLeftTest() { LineSegment lineSegment = new LineSegment(new Vector(120.3246f, 769.4974f, 1.0f), new Vector(151.22923f, 769.4974f, 1.0f)); - Assert.assertFalse(lineSegment.containsPoint(pointToCheck)); + Assertions.assertFalse(lineSegment.containsPoint(pointToCheck)); } @Test @@ -62,7 +61,7 @@ public void notContainsPointRightTest() { LineSegment lineSegment = new LineSegment(new Vector(120.3246f, 769.4974f, 1.0f), new Vector(151.22923f, 769.4974f, 1.0f)); - Assert.assertFalse(lineSegment.containsPoint(pointToCheck)); + Assertions.assertFalse(lineSegment.containsPoint(pointToCheck)); } @Test @@ -70,7 +69,7 @@ public void containsSegmentNullTest() { LineSegment lineSegment = new LineSegment(new Vector(100.3246f, 769.4974f, 1.0f), new Vector(151.22923f, 769.4974f, 1.0f)); - Assert.assertFalse(lineSegment.containsSegment(null)); + Assertions.assertFalse(lineSegment.containsSegment(null)); } @Test @@ -81,7 +80,7 @@ public void containsSegmentTest() { LineSegment segmentToCheck = new LineSegment(new Vector(110.3246f, 769.4974f, 1.0f), new Vector(140.22923f, 769.4974f, 1.0f)); - Assert.assertTrue(lineSegment.containsSegment(segmentToCheck)); + Assertions.assertTrue(lineSegment.containsSegment(segmentToCheck)); } @Test @@ -92,6 +91,6 @@ public void notContainsSegmentTest() { LineSegment segmentToCheck = new LineSegment(new Vector(110.3246f, 769.4974f, 1.0f), new Vector(115.22923f, 769.4974f, 1.0f)); - Assert.assertFalse(lineSegment.containsSegment(segmentToCheck)); + Assertions.assertFalse(lineSegment.containsSegment(segmentToCheck)); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/geom/MatrixTest.java b/kernel/src/test/java/com/itextpdf/kernel/geom/MatrixTest.java index d026368615..8c91072c60 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/geom/MatrixTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/geom/MatrixTest.java @@ -23,13 +23,12 @@ This file is part of the iText (R) project. package com.itextpdf.kernel.geom; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class MatrixTest extends ExtendedITextTest { @Test @@ -39,13 +38,13 @@ public void testMultiply() { Matrix shouldBe = new Matrix(46, 51, 82, 91, 130, 144); Matrix rslt = m1.multiply(m2); - Assert.assertEquals(shouldBe, rslt); + Assertions.assertEquals(shouldBe, rslt); } @Test public void testDeterminant(){ Matrix m = new Matrix(2, 3, 4, 5, 6, 7); - Assert.assertEquals(-2f, m.getDeterminant(), .001f); + Assertions.assertEquals(-2f, m.getDeterminant(), .001f); } @Test @@ -55,7 +54,7 @@ public void testSubtract() { Matrix shouldBe = new Matrix(-5, -3,0, -1, 1,0, 3, 5,0); Matrix rslt = m1.subtract(m2); - Assert.assertEquals(shouldBe, rslt); + Assertions.assertEquals(shouldBe, rslt); } @Test @@ -65,7 +64,7 @@ public void testAdd() { Matrix shouldBe = new Matrix(7, 7,0, 7, 7,0, 7, 7,2); Matrix rslt = m1.add(m2); - Assert.assertEquals(shouldBe, rslt); + Assertions.assertEquals(shouldBe, rslt); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/geom/PageSizeTest.java b/kernel/src/test/java/com/itextpdf/kernel/geom/PageSizeTest.java index 49a9f6c90f..667e74a981 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/geom/PageSizeTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/geom/PageSizeTest.java @@ -29,28 +29,27 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.annot.PdfFreeTextAnnotation; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import java.io.IOException; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PageSizeTest extends ExtendedITextTest { public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/kernel/geom/PageSizeTest/"; public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/kernel/geom/PageSizeTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(DESTINATION_FOLDER); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(DESTINATION_FOLDER); } @@ -64,7 +63,7 @@ public void emptyA9PageTest() throws IOException, InterruptedException { doc.addNewPage(PageSize.A9); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER, "diff")); } @Test @@ -79,7 +78,7 @@ public void notEmptyA9PageTest() throws IOException, InterruptedException { page.addAnnotation(annotation); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER, "diff")); } @Test @@ -95,6 +94,6 @@ public void allATypePageSizesTest() throws IOException, InterruptedException { } doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER, "diff")); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/geom/PageSizeUnitTest.java b/kernel/src/test/java/com/itextpdf/kernel/geom/PageSizeUnitTest.java index 46720f68c3..66fe02f6a8 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/geom/PageSizeUnitTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/geom/PageSizeUnitTest.java @@ -23,28 +23,27 @@ This file is part of the iText (R) project. package com.itextpdf.kernel.geom; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PageSizeUnitTest extends ExtendedITextTest { @Test public void constructFromRectangleTest() { Rectangle rectangle = new Rectangle(0, 0, 100, 200); PageSize pageSize = new PageSize(rectangle); - Assert.assertEquals(rectangle.x, pageSize.x, 1e-5); - Assert.assertEquals(rectangle.y, pageSize.y, 1e-5); - Assert.assertEquals(rectangle.width, pageSize.width, 1e-5); - Assert.assertEquals(rectangle.height, pageSize.height, 1e-5); + Assertions.assertEquals(rectangle.x, pageSize.x, 1e-5); + Assertions.assertEquals(rectangle.y, pageSize.y, 1e-5); + Assertions.assertEquals(rectangle.width, pageSize.width, 1e-5); + Assertions.assertEquals(rectangle.height, pageSize.height, 1e-5); } @Test public void A9pageSizeTest() { PageSize size = new PageSize(PageSize.A9); - Assert.assertEquals(148, size.height, 1e-5); - Assert.assertEquals(105, size.width, 1e-5); + Assertions.assertEquals(148, size.height, 1e-5); + Assertions.assertEquals(105, size.width, 1e-5); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/geom/PointTest.java b/kernel/src/test/java/com/itextpdf/kernel/geom/PointTest.java index d12b34bac0..ed428be39a 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/geom/PointTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/geom/PointTest.java @@ -23,50 +23,42 @@ This file is part of the iText (R) project. package com.itextpdf.kernel.geom; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(UnitTest.class) +@Tag("UnitTest") public class PointTest extends ExtendedITextTest { private static double EPSILON_COMPARISON = 1E-12; @Test public void defaultConstructorTest() { Point first = new Point(); - Assert.assertEquals(0, first.x, EPSILON_COMPARISON); - Assert.assertEquals(0, first.y, EPSILON_COMPARISON); + Assertions.assertEquals(0, first.getX(), EPSILON_COMPARISON); + Assertions.assertEquals(0, first.getY(), EPSILON_COMPARISON); } @Test public void doubleParamConstructorTest() { Point first = new Point(0.13, 1.1); - Assert.assertEquals(0.13, first.getX(), EPSILON_COMPARISON); - Assert.assertEquals(1.1, first.getY(), EPSILON_COMPARISON); + Assertions.assertEquals(0.13, first.getX(), EPSILON_COMPARISON); + Assertions.assertEquals(1.1, first.getY(), EPSILON_COMPARISON); } @Test public void intParamConstructorTest() { Point first = new Point(2, 3); - Assert.assertEquals(2, first.x, EPSILON_COMPARISON); - Assert.assertEquals(3, first.y, EPSILON_COMPARISON); - } - - @Test - public void copyConstructorTest() { - Point second = new Point(new Point(0.13, 1.1)); - Assert.assertEquals(0.13, second.getX(), EPSILON_COMPARISON); - Assert.assertEquals(1.1, second.getY(), EPSILON_COMPARISON); + Assertions.assertEquals(2, first.getX(), EPSILON_COMPARISON); + Assertions.assertEquals(3, first.getY(), EPSILON_COMPARISON); } @Test public void equalsItselfTest() { Point first = new Point(1.23, 1.1); - Assert.assertTrue(first.equals(first)); - Assert.assertEquals(first.hashCode(), first.hashCode()); + Assertions.assertTrue(first.equals(first)); + Assertions.assertEquals(first.hashCode(), first.hashCode()); } @Test @@ -74,9 +66,9 @@ public void equalsToAnotherPointTest() { Point first = new Point(1.23, 1.1); Point second = new Point(1.23, 1.1); - Assert.assertTrue(first.equals(second)); - Assert.assertTrue(second.equals(first)); - Assert.assertEquals(first.hashCode(), second.hashCode()); + Assertions.assertTrue(first.equals(second)); + Assertions.assertTrue(second.equals(first)); + Assertions.assertEquals(first.hashCode(), second.hashCode()); } @Test @@ -84,57 +76,15 @@ public void notEqualsToAnotherPointTest() { Point first = new Point(1.23, 1.1); Point second = new Point(1.23, 1.2); - Assert.assertFalse(first.equals(second)); - Assert.assertFalse(second.equals(first)); - Assert.assertNotEquals(first.hashCode(), second.hashCode()); + Assertions.assertFalse(first.equals(second)); + Assertions.assertFalse(second.equals(first)); + Assertions.assertNotEquals(first.hashCode(), second.hashCode()); } @Test public void notEqualsToNullTest() { Point first = new Point(1.23, 1.1); - Assert.assertFalse(first.equals(null)); - } - - @Test - public void distanceSquareBetweenCoordinatesTest() { - Point first = new Point(1, 1); - Point second = new Point(1.1, 1.1); - - double expected = 0.02; - Assert.assertEquals(expected, Point.distanceSq(first.x, first.y, second.x, second.y), EPSILON_COMPARISON); - } - - @Test - public void distanceSquareByCoordinatesTest() { - Point first = new Point(1, 1); - Point second = new Point(1.1, 1.1); - - double expected = 0.02; - Assert.assertEquals(expected, first.distanceSq(second.x, second.y), EPSILON_COMPARISON); - } - - @Test - public void distanceSquareByPointTest() { - Point first = new Point(1, 1); - Point second = new Point(1.1, 1.1); - - double expected = 0.02; - Assert.assertEquals(expected, first.distanceSq(second), EPSILON_COMPARISON); - } - - @Test - public void distanceItselfSquareTest() { - Point first = new Point(1, 1); - Assert.assertEquals(0, first.distanceSq(first), EPSILON_COMPARISON); - } - - @Test - public void distanceBetweenCoordinatesTest() { - Point first = new Point(1, 1); - Point second = new Point(1.1, 1.1); - - double expected = Math.sqrt(0.02); - Assert.assertEquals(expected, Point.distance(first.x, first.y, second.x, second.y), EPSILON_COMPARISON); + Assertions.assertFalse(first.equals(null)); } @Test @@ -143,7 +93,7 @@ public void distanceByCoordinatesTest() { Point second = new Point(1.1, 1.1); double expected = Math.sqrt(0.02); - Assert.assertEquals(expected, first.distance(second.x, second.y), EPSILON_COMPARISON); + Assertions.assertEquals(expected, first.distance(second.getX(), second.getY()), EPSILON_COMPARISON); } @Test @@ -152,31 +102,31 @@ public void distanceByPointTest() { Point second = new Point(1.1, 1.1); double expected = Math.sqrt(0.02); - Assert.assertEquals(expected, first.distance(second), EPSILON_COMPARISON); + Assertions.assertEquals(expected, first.distance(second), EPSILON_COMPARISON); } @Test public void distanceItselfTest() { Point first = new Point(1, 1); - Assert.assertEquals(0, first.distance(first), EPSILON_COMPARISON); + Assertions.assertEquals(0, first.distance(first), EPSILON_COMPARISON); } @Test public void toStringTest() { Point first = new Point(1.23, 1.1); - Assert.assertEquals("Point: [x=1.23,y=1.1]", first.toString()); + Assertions.assertEquals("Point: [x=1.23,y=1.1]", first.toString()); } @Test public void cloneTest() { Point first = new Point(1.23, 1.1); Point clone = (Point) first.clone(); - Assert.assertEquals(first, clone); - Assert.assertEquals(first.hashCode(), clone.hashCode()); + Assertions.assertEquals(first, clone); + Assertions.assertEquals(first.hashCode(), clone.hashCode()); } @Test - public void translateTest() { + public void moveTest() { float w = 3.73f; float h = 5.23f; Rectangle rectangle = new Rectangle(0, 0, w, h); @@ -184,14 +134,14 @@ public void translateTest() { Point point = new Point(0, 0); - point.translate(w, 0); - Assert.assertEquals(expectedPoints[1], point); - point.translate(0, h); - Assert.assertEquals(expectedPoints[2], point); - point.translate(-w, 0); - Assert.assertEquals(expectedPoints[3], point); - point.translate(0, -h); - Assert.assertEquals(expectedPoints[0], point); + point.move(w, 0); + Assertions.assertEquals(expectedPoints[1], point); + point.move(0, h); + Assertions.assertEquals(expectedPoints[2], point); + point.move(-w, 0); + Assertions.assertEquals(expectedPoints[3], point); + point.move(0, -h); + Assertions.assertEquals(expectedPoints[0], point); } @Test @@ -199,17 +149,7 @@ public void pointVsItLocationTest() { Point first = new Point(1.23, 1.1); Point location = first.getLocation(); - Assert.assertTrue(first != location && first.equals(location)); - } - - @Test - public void setLocationByPointTest() { - Point first = new Point(1.23, 1.1); - Point second = new Point(3.59, 0.87); - - Assert.assertNotEquals(first, second); - first.setLocation(second); - Assert.assertEquals(first, second); + Assertions.assertTrue(first != location && first.equals(location)); } @Test @@ -217,28 +157,8 @@ public void setLocationByDoubleParamTest() { Point first = new Point(1.23, 1.1); Point second = new Point(3.59, 0.87); - Assert.assertNotEquals(first, second); - first.setLocation(second.x, second.y); - Assert.assertEquals(first, second); - } - - @Test - public void setLocationByIntParamTest() { - Point first = new Point(1.23, 1.1); - Point second = new Point(3.59, 0.87); - - Assert.assertNotEquals(first, second); - first.setLocation((int) second.x, (int) second.y); - Assert.assertEquals(first, new Point(3, 0)); - } - - @Test - public void movePointTest() { - Point first = new Point(1.23, 1.1); - Point second = new Point(3.59, 0.87); - - Assert.assertNotEquals(first, second); - first.move(second.x, second.y); - Assert.assertEquals(first, second); + Assertions.assertNotEquals(first, second); + first.setLocation(second.getX(), second.getY()); + Assertions.assertEquals(first, second); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/geom/RectangleTest.java b/kernel/src/test/java/com/itextpdf/kernel/geom/RectangleTest.java index a155d66714..63fa6cea67 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/geom/RectangleTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/geom/RectangleTest.java @@ -28,7 +28,6 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfPage; import com.itextpdf.kernel.pdf.PdfWriter; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.ByteArrayOutputStream; @@ -36,11 +35,11 @@ This file is part of the iText (R) project. import java.util.Arrays; import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class RectangleTest extends ExtendedITextTest { private static final float OVERLAP_EPSILON = 0.1f; @@ -49,24 +48,24 @@ public void overlapWithEpsilon() { Rectangle first = new Rectangle(0, 0, 10, 10); Rectangle second = new Rectangle(-10, 0, 10.09f, 5); - Assert.assertFalse(first.overlaps(second, OVERLAP_EPSILON)); + Assertions.assertFalse(first.overlaps(second, OVERLAP_EPSILON)); second.setWidth(10.11f); - Assert.assertTrue(first.overlaps(second, OVERLAP_EPSILON)); + Assertions.assertTrue(first.overlaps(second, OVERLAP_EPSILON)); second = new Rectangle(5, 9.91f, 5, 5); - Assert.assertFalse(first.overlaps(second, OVERLAP_EPSILON)); + Assertions.assertFalse(first.overlaps(second, OVERLAP_EPSILON)); second.setY(9.89f); - Assert.assertTrue(first.overlaps(second, OVERLAP_EPSILON)); + Assertions.assertTrue(first.overlaps(second, OVERLAP_EPSILON)); second = new Rectangle(9.91f, 0, 5, 5); - Assert.assertFalse(first.overlaps(second, OVERLAP_EPSILON)); + Assertions.assertFalse(first.overlaps(second, OVERLAP_EPSILON)); second.setX(9.89f); - Assert.assertTrue(first.overlaps(second, OVERLAP_EPSILON)); + Assertions.assertTrue(first.overlaps(second, OVERLAP_EPSILON)); second = new Rectangle(5, -10, 5, 10.09f); - Assert.assertFalse(first.overlaps(second, OVERLAP_EPSILON)); + Assertions.assertFalse(first.overlaps(second, OVERLAP_EPSILON)); second.setHeight(10.11f); - Assert.assertTrue(first.overlaps(second, OVERLAP_EPSILON)); + Assertions.assertTrue(first.overlaps(second, OVERLAP_EPSILON)); } @Test @@ -74,24 +73,24 @@ public void overlapWithNegativeEpsilon() { Rectangle first = new Rectangle(0, 0, 10, 10); Rectangle second = new Rectangle(-10, 0, 9.89f, 5); - Assert.assertFalse(first.overlaps(second, -OVERLAP_EPSILON)); + Assertions.assertFalse(first.overlaps(second, -OVERLAP_EPSILON)); second.setWidth(9.91f); - Assert.assertTrue(first.overlaps(second, -OVERLAP_EPSILON)); + Assertions.assertTrue(first.overlaps(second, -OVERLAP_EPSILON)); second = new Rectangle(5, 10.11f, 5, 5); - Assert.assertFalse(first.overlaps(second, -OVERLAP_EPSILON)); + Assertions.assertFalse(first.overlaps(second, -OVERLAP_EPSILON)); second.setY(10.09f); - Assert.assertTrue(first.overlaps(second, -OVERLAP_EPSILON)); + Assertions.assertTrue(first.overlaps(second, -OVERLAP_EPSILON)); second = new Rectangle(10.11f, 0, 5, 5); - Assert.assertFalse(first.overlaps(second, -OVERLAP_EPSILON)); + Assertions.assertFalse(first.overlaps(second, -OVERLAP_EPSILON)); second.setX(10.09f); - Assert.assertTrue(first.overlaps(second, -OVERLAP_EPSILON)); + Assertions.assertTrue(first.overlaps(second, -OVERLAP_EPSILON)); second = new Rectangle(5, -10, 5, 9.89f); - Assert.assertFalse(first.overlaps(second, -OVERLAP_EPSILON)); + Assertions.assertFalse(first.overlaps(second, -OVERLAP_EPSILON)); second.setHeight(9.91f); - Assert.assertTrue(first.overlaps(second, -OVERLAP_EPSILON)); + Assertions.assertTrue(first.overlaps(second, -OVERLAP_EPSILON)); } @Test @@ -100,19 +99,19 @@ public void rectangleOverlapTest01() { Rectangle one = new Rectangle(0, 0, 10, 10); Rectangle two = new Rectangle(5, 5, 5, 5); boolean result = one.overlaps(two); - Assert.assertTrue(result); + Assertions.assertTrue(result); //envelopment one = new Rectangle(0, 0, 10, 10); two = new Rectangle(2, 2, 5, 5); result = one.overlaps(two); - Assert.assertTrue(result); + Assertions.assertTrue(result); //identical one = new Rectangle(0, 0, 10, 10); two = new Rectangle(0, 0, 10, 10); result = one.overlaps(two); - Assert.assertTrue(result); + Assertions.assertTrue(result); } @@ -123,53 +122,53 @@ public void rectangleOverlapTest02() { Rectangle one = new Rectangle(0, 0, 10, 10); Rectangle two = new Rectangle(15, 15, 10, 10); boolean result = one.overlaps(two); - Assert.assertFalse(result); + Assertions.assertFalse(result); //Middle left one = new Rectangle(0, 0, 10, 10); two = new Rectangle(15, 5, 10, 10); result = one.overlaps(two); - Assert.assertFalse(result); + Assertions.assertFalse(result); //Lower left one = new Rectangle(0, 0, 10, 10); two = new Rectangle(15, -5, 10, 10); result = one.overlaps(two); - Assert.assertFalse(result); + Assertions.assertFalse(result); //Bottom //Bottom left one = new Rectangle(0, 0, 10, 10); two = new Rectangle(5, -15, 10, 10); result = one.overlaps(two); - Assert.assertFalse(result); + Assertions.assertFalse(result); //Bottom right one = new Rectangle(0, 0, 10, 10); two = new Rectangle(-5, -15, 10, 10); result = one.overlaps(two); - Assert.assertFalse(result); + Assertions.assertFalse(result); //Right //Lower right one = new Rectangle(0, 0, 10, 10); two = new Rectangle(-15, -5, 10, 10); result = one.overlaps(two); - Assert.assertFalse(result); + Assertions.assertFalse(result); //Upper right one = new Rectangle(0, 0, 10, 10); two = new Rectangle(-15, 5, 10, 10); result = one.overlaps(two); - Assert.assertFalse(result); + Assertions.assertFalse(result); //Top //Top right one = new Rectangle(0, 0, 10, 10); two = new Rectangle(-5, 15, 10, 10); result = one.overlaps(two); - Assert.assertFalse(result); + Assertions.assertFalse(result); //Top left one = new Rectangle(0, 0, 10, 10); two = new Rectangle(5, 15, 10, 10); result = one.overlaps(two); - Assert.assertFalse(result); + Assertions.assertFalse(result); } @@ -180,7 +179,7 @@ public void envelopTest01() { Rectangle one = new Rectangle(0, 0, 10, 10); Rectangle two = new Rectangle(5, 5, 5, 5); boolean result = one.contains(two); - Assert.assertTrue(result); + Assertions.assertTrue(result); } @Test @@ -189,7 +188,7 @@ public void envelopsTest02() { Rectangle one = new Rectangle(0, 0, 10, 10); Rectangle two = new Rectangle(0, 0, 10, 10); boolean result = one.contains(two); - Assert.assertTrue(result); + Assertions.assertTrue(result); } @@ -199,7 +198,7 @@ public void envelopsTest03() { Rectangle one = new Rectangle(0, 0, 10, 10); Rectangle two = new Rectangle(5, 5, 10, 10); boolean result = one.contains(two); - Assert.assertFalse(result); + Assertions.assertFalse(result); } @Test @@ -208,7 +207,7 @@ public void envelopsTest04() { Rectangle one = new Rectangle(0, 0, 10, 10); Rectangle two = new Rectangle(-15, -15, 10, 10); boolean result = one.contains(two); - Assert.assertFalse(result); + Assertions.assertFalse(result); } @Test @@ -292,7 +291,7 @@ public void getIntersectionTest01() { areEqual = areEqual && (expected.equalsWithEpsilon(actual)); //Check if any have failed - Assert.assertTrue(areEqual); + Assertions.assertTrue(areEqual); } @Test @@ -318,7 +317,7 @@ public void getIntersectionTest02() { actual = main.getIntersection(second); noIntersection = noIntersection && ((actual) == null); - Assert.assertTrue(noIntersection); + Assertions.assertTrue(noIntersection); } @Test @@ -345,7 +344,7 @@ public void getIntersectionTest03() { actual = main.getIntersection(second); areEqual = areEqual && (expected.equalsWithEpsilon(actual)); - Assert.assertTrue(areEqual); + Assertions.assertTrue(areEqual); } @Test @@ -395,7 +394,7 @@ public void getIntersectionTest04() { expected = new Rectangle(2, 2, 0, 0); actual = main.getIntersection(second); areEqual = areEqual && (expected.equalsWithEpsilon(actual)); - Assert.assertTrue(areEqual); + Assertions.assertTrue(areEqual); } @Test @@ -407,7 +406,7 @@ public void createBoundingRectangleFromQuadPointsTest01() { expected = new Rectangle(-2, 0, 4, 2); actual = Rectangle.createBoundingRectangleFromQuadPoint(quadpoints); Boolean areEqual = expected.equalsWithEpsilon(actual); - Assert.assertTrue(areEqual); + Assertions.assertTrue(areEqual); } @@ -423,7 +422,7 @@ public void createBoundingRectangleFromQuadPointsTest02() { exception = true; } - Assert.assertTrue(exception); + Assertions.assertTrue(exception); } @Test @@ -440,7 +439,7 @@ public void createBoundingRectanglesFromQuadPointsTest01() { for (int i = 0; i < expected.size(); i++) { areEqual = areEqual && expected.get(i).equalsWithEpsilon(actual.get(i)); } - Assert.assertTrue(areEqual); + Assertions.assertTrue(areEqual); } @Test @@ -456,7 +455,7 @@ public void createBoundingRectanglesFromQuadPointsTest02() { exception = true; } - Assert.assertTrue(exception); + Assertions.assertTrue(exception); } @Test @@ -465,29 +464,29 @@ public void translateOnRotatedPageTest01() { PdfDocument pdfDocument = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); PdfPage page = pdfDocument.addNewPage(); - Assert.assertTrue(PageSize.A4.equalsWithEpsilon(page.getPageSize())); + Assertions.assertTrue(PageSize.A4.equalsWithEpsilon(page.getPageSize())); // Test rectangle Rectangle testRectangle = new Rectangle(200, 200, 100, 200); - Assert.assertEquals(0, page.getRotation()); - Assert.assertTrue(new Rectangle(200, 200, 100, 200).equalsWithEpsilon(Rectangle.getRectangleOnRotatedPage(testRectangle, page))); + Assertions.assertEquals(0, page.getRotation()); + Assertions.assertTrue(new Rectangle(200, 200, 100, 200).equalsWithEpsilon(Rectangle.getRectangleOnRotatedPage(testRectangle, page))); page.setRotation(90); - Assert.assertEquals(90, page.getRotation()); - Assert.assertTrue(new Rectangle(195, 200, 200, 100).equalsWithEpsilon(Rectangle.getRectangleOnRotatedPage(testRectangle, page))); + Assertions.assertEquals(90, page.getRotation()); + Assertions.assertTrue(new Rectangle(195, 200, 200, 100).equalsWithEpsilon(Rectangle.getRectangleOnRotatedPage(testRectangle, page))); page.setRotation(180); - Assert.assertEquals(180, page.getRotation()); - Assert.assertTrue(new Rectangle(295, 442, 100, 200).equalsWithEpsilon(Rectangle.getRectangleOnRotatedPage(testRectangle, page))); + Assertions.assertEquals(180, page.getRotation()); + Assertions.assertTrue(new Rectangle(295, 442, 100, 200).equalsWithEpsilon(Rectangle.getRectangleOnRotatedPage(testRectangle, page))); page.setRotation(270); - Assert.assertEquals(270, page.getRotation()); - Assert.assertTrue(new Rectangle(200, 542, 200, 100).equalsWithEpsilon(Rectangle.getRectangleOnRotatedPage(testRectangle, page))); + Assertions.assertEquals(270, page.getRotation()); + Assertions.assertTrue(new Rectangle(200, 542, 200, 100).equalsWithEpsilon(Rectangle.getRectangleOnRotatedPage(testRectangle, page))); page.setRotation(360); - Assert.assertEquals(0, page.getRotation()); - Assert.assertTrue(new Rectangle(200, 200, 100, 200).equalsWithEpsilon(Rectangle.getRectangleOnRotatedPage(testRectangle, page))); + Assertions.assertEquals(0, page.getRotation()); + Assertions.assertTrue(new Rectangle(200, 200, 100, 200).equalsWithEpsilon(Rectangle.getRectangleOnRotatedPage(testRectangle, page))); } @Test @@ -500,7 +499,7 @@ public void calculateBBoxTest() { // Zero rotation Rectangle.calculateBBox(Arrays.asList(a, b, c, d)); - Assert.assertTrue(new Rectangle(100, 100, 100, 100).equalsWithEpsilon(Rectangle.calculateBBox(Arrays.asList(a, b, c, d)))); + Assertions.assertTrue(new Rectangle(100, 100, 100, 100).equalsWithEpsilon(Rectangle.calculateBBox(Arrays.asList(a, b, c, d)))); // 270 degree rotation a = new Point(200, 100); @@ -508,7 +507,7 @@ public void calculateBBoxTest() { c = new Point(100, 200); d = new Point(100, 100); - Assert.assertTrue(new Rectangle(100, 100, 100, 100).equalsWithEpsilon(Rectangle.calculateBBox(Arrays.asList(a, b, c, d)))); + Assertions.assertTrue(new Rectangle(100, 100, 100, 100).equalsWithEpsilon(Rectangle.calculateBBox(Arrays.asList(a, b, c, d)))); // it looks as follows: // dxxxxxx @@ -521,142 +520,142 @@ public void calculateBBoxTest() { c = new Point(0, 100); d = new Point(0, 200); - Assert.assertTrue(new Rectangle(0, 0, 200, 200).equalsWithEpsilon(Rectangle.calculateBBox(Arrays.asList(a, b, c, d)))); + Assertions.assertTrue(new Rectangle(0, 0, 200, 200).equalsWithEpsilon(Rectangle.calculateBBox(Arrays.asList(a, b, c, d)))); } @Test public void setBBoxWithoutNormalizationTest() { Rectangle rectangle = new Rectangle(0, 0, 100, 200); - Assert.assertEquals(0, rectangle.getX(), 1e-5); - Assert.assertEquals(0, rectangle.getY(), 1e-5); - Assert.assertEquals(100, rectangle.getWidth(), 1e-5); - Assert.assertEquals(200, rectangle.getHeight(), 1e-5); + Assertions.assertEquals(0, rectangle.getX(), 1e-5); + Assertions.assertEquals(0, rectangle.getY(), 1e-5); + Assertions.assertEquals(100, rectangle.getWidth(), 1e-5); + Assertions.assertEquals(200, rectangle.getHeight(), 1e-5); //set bBox without any normalization needed rectangle.setBbox(10, 10, 90, 190); - Assert.assertEquals(10, rectangle.getX(), 1e-5); - Assert.assertEquals(10, rectangle.getY(), 1e-5); - Assert.assertEquals(80, rectangle.getWidth(), 1e-5); - Assert.assertEquals(180, rectangle.getHeight(), 1e-5); + Assertions.assertEquals(10, rectangle.getX(), 1e-5); + Assertions.assertEquals(10, rectangle.getY(), 1e-5); + Assertions.assertEquals(80, rectangle.getWidth(), 1e-5); + Assertions.assertEquals(180, rectangle.getHeight(), 1e-5); } @Test public void setBBoxNormalizeXTest() { Rectangle rectangle = new Rectangle(0, 0, 100, 200); - Assert.assertEquals(0, rectangle.getX(), 1e-5); - Assert.assertEquals(0, rectangle.getY(), 1e-5); - Assert.assertEquals(100, rectangle.getWidth(), 1e-5); - Assert.assertEquals(200, rectangle.getHeight(), 1e-5); + Assertions.assertEquals(0, rectangle.getX(), 1e-5); + Assertions.assertEquals(0, rectangle.getY(), 1e-5); + Assertions.assertEquals(100, rectangle.getWidth(), 1e-5); + Assertions.assertEquals(200, rectangle.getHeight(), 1e-5); //set bBox where llx > urx rectangle.setBbox(90, 10, 10, 190); - Assert.assertEquals(10, rectangle.getX(), 1e-5); - Assert.assertEquals(10, rectangle.getY(), 1e-5); - Assert.assertEquals(80, rectangle.getWidth(), 1e-5); - Assert.assertEquals(180, rectangle.getHeight(), 1e-5); + Assertions.assertEquals(10, rectangle.getX(), 1e-5); + Assertions.assertEquals(10, rectangle.getY(), 1e-5); + Assertions.assertEquals(80, rectangle.getWidth(), 1e-5); + Assertions.assertEquals(180, rectangle.getHeight(), 1e-5); } @Test public void setBBoxNormalizeYTest() { Rectangle rectangle = new Rectangle(0, 0, 100, 200); - Assert.assertEquals(0, rectangle.getX(), 1e-5); - Assert.assertEquals(0, rectangle.getY(), 1e-5); - Assert.assertEquals(100, rectangle.getWidth(), 1e-5); - Assert.assertEquals(200, rectangle.getHeight(), 1e-5); + Assertions.assertEquals(0, rectangle.getX(), 1e-5); + Assertions.assertEquals(0, rectangle.getY(), 1e-5); + Assertions.assertEquals(100, rectangle.getWidth(), 1e-5); + Assertions.assertEquals(200, rectangle.getHeight(), 1e-5); //set bBox where lly > ury rectangle.setBbox(10, 190, 90, 10); - Assert.assertEquals(10, rectangle.getX(), 1e-5); - Assert.assertEquals(10, rectangle.getY(), 1e-5); - Assert.assertEquals(80, rectangle.getWidth(), 1e-5); - Assert.assertEquals(180, rectangle.getHeight(), 1e-5); + Assertions.assertEquals(10, rectangle.getX(), 1e-5); + Assertions.assertEquals(10, rectangle.getY(), 1e-5); + Assertions.assertEquals(80, rectangle.getWidth(), 1e-5); + Assertions.assertEquals(180, rectangle.getHeight(), 1e-5); } @Test public void setXTest() { Rectangle rectangle = new Rectangle(0,0,100,200); - Assert.assertEquals(0, rectangle.getX(), 1e-5); + Assertions.assertEquals(0, rectangle.getX(), 1e-5); rectangle.setX(50); - Assert.assertEquals(50, rectangle.getX(), 1e-5); + Assertions.assertEquals(50, rectangle.getX(), 1e-5); } @Test public void setYTest() { Rectangle rectangle = new Rectangle(0,0,100,200); - Assert.assertEquals(0, rectangle.getY(), 1e-5); + Assertions.assertEquals(0, rectangle.getY(), 1e-5); rectangle.setY(50); - Assert.assertEquals(50, rectangle.getY(), 1e-5); + Assertions.assertEquals(50, rectangle.getY(), 1e-5); } @Test public void setWidthTest() { Rectangle rectangle = new Rectangle(0,0,100,200); - Assert.assertEquals(100, rectangle.getWidth(), 1e-5); + Assertions.assertEquals(100, rectangle.getWidth(), 1e-5); rectangle.setWidth(50); - Assert.assertEquals(50, rectangle.getWidth(), 1e-5); + Assertions.assertEquals(50, rectangle.getWidth(), 1e-5); } @Test public void setHeightTest() { Rectangle rectangle = new Rectangle(0,0,100,200); - Assert.assertEquals(200, rectangle.getHeight(), 1e-5); + Assertions.assertEquals(200, rectangle.getHeight(), 1e-5); rectangle.setHeight(50); - Assert.assertEquals(50, rectangle.getHeight(), 1e-5); + Assertions.assertEquals(50, rectangle.getHeight(), 1e-5); } @Test public void increaseHeightTest() { Rectangle rectangle = new Rectangle(0,0,100,200); - Assert.assertEquals(200, rectangle.getHeight(), 1e-5); + Assertions.assertEquals(200, rectangle.getHeight(), 1e-5); rectangle.increaseHeight(50); - Assert.assertEquals(250, rectangle.getHeight(), 1e-5); + Assertions.assertEquals(250, rectangle.getHeight(), 1e-5); } @Test public void decreaseHeightTest() { Rectangle rectangle = new Rectangle(0,0,100,200); - Assert.assertEquals(200, rectangle.getHeight(), 1e-5); + Assertions.assertEquals(200, rectangle.getHeight(), 1e-5); rectangle.decreaseHeight(50); - Assert.assertEquals(150, rectangle.getHeight(), 1e-5); + Assertions.assertEquals(150, rectangle.getHeight(), 1e-5); } @Test public void applyMarginsShrinkTest() { Rectangle rectangle = new Rectangle(0,0,100,200); - Assert.assertEquals(0, rectangle.getX(), 1e-5); - Assert.assertEquals(0, rectangle.getY(), 1e-5); - Assert.assertEquals(100, rectangle.getWidth(), 1e-5); - Assert.assertEquals(200, rectangle.getHeight(), 1e-5); + Assertions.assertEquals(0, rectangle.getX(), 1e-5); + Assertions.assertEquals(0, rectangle.getY(), 1e-5); + Assertions.assertEquals(100, rectangle.getWidth(), 1e-5); + Assertions.assertEquals(200, rectangle.getHeight(), 1e-5); //shrink the rectangle rectangle.applyMargins(20,20,20,20, false); - Assert.assertEquals(20, rectangle.getX(), 1e-5); - Assert.assertEquals(20, rectangle.getY(), 1e-5); - Assert.assertEquals(60, rectangle.getWidth(), 1e-5); - Assert.assertEquals(160, rectangle.getHeight(), 1e-5); + Assertions.assertEquals(20, rectangle.getX(), 1e-5); + Assertions.assertEquals(20, rectangle.getY(), 1e-5); + Assertions.assertEquals(60, rectangle.getWidth(), 1e-5); + Assertions.assertEquals(160, rectangle.getHeight(), 1e-5); } @Test public void applyMarginsExpandTest() { Rectangle rectangle = new Rectangle(20,20,100,200); - Assert.assertEquals(20, rectangle.getX(), 1e-5); - Assert.assertEquals(20, rectangle.getY(), 1e-5); - Assert.assertEquals(100, rectangle.getWidth(), 1e-5); - Assert.assertEquals(200, rectangle.getHeight(), 1e-5); + Assertions.assertEquals(20, rectangle.getX(), 1e-5); + Assertions.assertEquals(20, rectangle.getY(), 1e-5); + Assertions.assertEquals(100, rectangle.getWidth(), 1e-5); + Assertions.assertEquals(200, rectangle.getHeight(), 1e-5); //expand the rectangle rectangle.applyMargins(10,10,10,10, true); - Assert.assertEquals(10, rectangle.getX(), 1e-5); - Assert.assertEquals(10, rectangle.getY(), 1e-5); - Assert.assertEquals(120, rectangle.getWidth(), 1e-5); - Assert.assertEquals(220, rectangle.getHeight(), 1e-5); + Assertions.assertEquals(10, rectangle.getX(), 1e-5); + Assertions.assertEquals(10, rectangle.getY(), 1e-5); + Assertions.assertEquals(120, rectangle.getWidth(), 1e-5); + Assertions.assertEquals(220, rectangle.getHeight(), 1e-5); } @Test @@ -665,8 +664,8 @@ public void toStringTest() { String rectangleString = rectangle.toString(); //Using contains() to check for value instead of equals() on the whole string due to the //differences between decimal numbers formatting in java and .NET. - Assert.assertTrue(rectangleString.contains("100")); - Assert.assertTrue(rectangleString.contains("200")); + Assertions.assertTrue(rectangleString.contains("100")); + Assertions.assertTrue(rectangleString.contains("200")); } @Test @@ -674,21 +673,21 @@ public void cloneTest() { PageSize originalPageSize = new PageSize(15, 20); PageSize copyAsPageSize = (PageSize) originalPageSize.clone(); Rectangle copyAsRectangle = ((Rectangle) originalPageSize).clone(); - Assert.assertEquals(PageSize.class, copyAsPageSize.getClass()); - Assert.assertEquals(PageSize.class, copyAsRectangle.getClass()); + Assertions.assertEquals(PageSize.class, copyAsPageSize.getClass()); + Assertions.assertEquals(PageSize.class, copyAsRectangle.getClass()); } @Test public void decreaseWidthTest() { Rectangle rectangle = new Rectangle(100, 200); rectangle.decreaseWidth(10); - Assert.assertEquals(90, rectangle.getWidth(), Rectangle.EPS); + Assertions.assertEquals(90, rectangle.getWidth(), Rectangle.EPS); } @Test public void increaseWidthTest() { Rectangle rectangle = new Rectangle(100, 200); rectangle.increaseWidth(10); - Assert.assertEquals(110, rectangle.getWidth(), Rectangle.EPS); + Assertions.assertEquals(110, rectangle.getWidth(), Rectangle.EPS); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/geom/ShapeTransformUtilTest.java b/kernel/src/test/java/com/itextpdf/kernel/geom/ShapeTransformUtilTest.java index 3f4a3816b6..2f03c25995 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/geom/ShapeTransformUtilTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/geom/ShapeTransformUtilTest.java @@ -23,15 +23,14 @@ This file is part of the iText (R) project. package com.itextpdf.kernel.geom; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.util.Arrays; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class ShapeTransformUtilTest extends ExtendedITextTest { @Test public void transformBezierCurveTest() { @@ -41,7 +40,7 @@ public void transformBezierCurveTest() { BezierCurve cmpBezierCurve = new BezierCurve(Arrays.asList(new Point(-5, -5), new Point(-5, 0), new Point(0, 0), new Point(0, -5))); - Assert.assertArrayEquals(cmpBezierCurve.getBasePoints().toArray(), outBezierCurve.getBasePoints().toArray()); + Assertions.assertArrayEquals(cmpBezierCurve.getBasePoints().toArray(), outBezierCurve.getBasePoints().toArray()); } @Test @@ -52,7 +51,7 @@ public void transformLineTest() { Line cmpLine = new Line(new Point(-2.5, -5), new Point(2.5, 5)); - Assert.assertArrayEquals(cmpLine.getBasePoints().toArray(), outLine.getBasePoints().toArray()); + Assertions.assertArrayEquals(cmpLine.getBasePoints().toArray(), outLine.getBasePoints().toArray()); } @Test @@ -78,7 +77,7 @@ public void transformPathTest() { for (int j = 0; j < subpath.getSegments().size(); j++) { IShape cmpShape = subpath.getSegments().get(j); IShape outShape = outPath.getSubpaths().get(i).getSegments().get(j); - Assert.assertArrayEquals(cmpShape.getBasePoints().toArray(), outShape.getBasePoints().toArray()); + Assertions.assertArrayEquals(cmpShape.getBasePoints().toArray(), outShape.getBasePoints().toArray()); } } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/geom/VectorTest.java b/kernel/src/test/java/com/itextpdf/kernel/geom/VectorTest.java index 5a88b5ee1f..29b251f994 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/geom/VectorTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/geom/VectorTest.java @@ -23,13 +23,12 @@ This file is part of the iText (R) project. package com.itextpdf.kernel.geom; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class VectorTest extends ExtendedITextTest { @Test @@ -39,7 +38,7 @@ public void testCrossVector() { Vector shouldBe = new Vector(67, 76, 4); Vector rslt = v.cross(m); - Assert.assertEquals(shouldBe, rslt); + Assertions.assertEquals(shouldBe, rslt); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest.java b/kernel/src/test/java/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest.java new file mode 100644 index 0000000000..fca6e82ed7 --- /dev/null +++ b/kernel/src/test/java/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest.java @@ -0,0 +1,393 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.mac; + +import com.itextpdf.bouncycastleconnector.BouncyCastleFactoryCreator; +import com.itextpdf.commons.bouncycastle.operator.AbstractOperatorCreationException; +import com.itextpdf.commons.bouncycastle.pkcs.AbstractPKCSException; +import com.itextpdf.commons.utils.FileUtil; +import com.itextpdf.io.logs.IoLogMessageConstant; +import com.itextpdf.io.util.EnumUtil; +import com.itextpdf.kernel.crypto.CryptoUtil; +import com.itextpdf.kernel.exceptions.KernelExceptionMessageConstant; +import com.itextpdf.kernel.exceptions.PdfException; +import com.itextpdf.kernel.geom.Rectangle; +import com.itextpdf.kernel.logs.KernelLogMessageConstant; +import com.itextpdf.kernel.pdf.EncryptionConstants; +import com.itextpdf.kernel.pdf.PdfDocument; +import com.itextpdf.kernel.pdf.PdfReader; +import com.itextpdf.kernel.pdf.PdfVersion; +import com.itextpdf.kernel.pdf.PdfWriter; +import com.itextpdf.kernel.pdf.ReaderProperties; +import com.itextpdf.kernel.pdf.StampingProperties; +import com.itextpdf.kernel.pdf.VersionConforming; +import com.itextpdf.kernel.pdf.WriterProperties; +import com.itextpdf.kernel.mac.MacProperties.KeyWrappingAlgorithm; +import com.itextpdf.kernel.mac.MacProperties.MacAlgorithm; +import com.itextpdf.kernel.mac.MacProperties.MacDigestAlgorithm; +import com.itextpdf.kernel.pdf.annot.PdfTextAnnotation; +import com.itextpdf.kernel.utils.CompareTool; +import com.itextpdf.kernel.utils.PemFileHelper; +import com.itextpdf.test.ExtendedITextTest; +import com.itextpdf.test.annotations.LogMessage; +import com.itextpdf.test.annotations.LogMessages; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.security.PrivateKey; +import java.security.Security; +import java.security.cert.Certificate; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +@Tag("BouncyCastleIntegrationTest") +public class MacIntegrityProtectorCreationTest extends ExtendedITextTest { + private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/"; + private static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/"; + private static final String CERTS_SRC = "./src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/certs/"; + private static final byte[] PASSWORD = "123".getBytes(); + private static final String PROVIDER_NAME = BouncyCastleFactoryCreator.getFactory().getProviderName(); + + @BeforeAll + public static void beforeClass() { + createOrClearDestinationFolder(DESTINATION_FOLDER); + Security.addProvider(BouncyCastleFactoryCreator.getFactory().getProvider()); + } + + @AfterAll + public static void afterClass() { + CompareTool.cleanup(DESTINATION_FOLDER); + } + + @Test + @LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT, + ignore = true)) + public void standaloneMacStandardEncryptionTest() throws IOException, InterruptedException { + String fileName = "standaloneMacStandardEncryptionTest.pdf"; + String outputFileName = DESTINATION_FOLDER + fileName; + String cmpFileName = SOURCE_FOLDER + "cmp_" + fileName; + + WriterProperties writerProperties = new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0) + .setStandardEncryption(PASSWORD, PASSWORD, 0, EncryptionConstants.ENCRYPTION_AES_256, + new MacProperties(MacDigestAlgorithm.SHA_256)); + + try (PdfDocument pdfDoc = new PdfDocument(CompareTool.createTestPdfWriter(outputFileName, writerProperties))) { + pdfDoc.addNewPage().addAnnotation(new PdfTextAnnotation(new Rectangle(100, 100, 100, 100))); + } + Assertions.assertNull(new CompareTool().enableEncryptionCompare(false).compareByContent( + outputFileName, cmpFileName, DESTINATION_FOLDER, "diff", PASSWORD, PASSWORD)); + } + + @Test + @LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT, + ignore = true)) + public void noMacProtectionTest() throws IOException, InterruptedException { + String fileName = "noMacProtectionTest.pdf"; + String outputFileName = DESTINATION_FOLDER + fileName; + String cmpFileName = SOURCE_FOLDER + "cmp_" + fileName; + + WriterProperties writerProperties = new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0) + .setStandardEncryption(PASSWORD, PASSWORD, 0, EncryptionConstants.ENCRYPTION_AES_256, null); + + try (PdfDocument pdfDoc = new PdfDocument(CompareTool.createTestPdfWriter(outputFileName, writerProperties))) { + pdfDoc.addNewPage().addAnnotation(new PdfTextAnnotation(new Rectangle(100, 100, 100, 100))); + } + Assertions.assertNull(new CompareTool().enableEncryptionCompare().compareByContent( + outputFileName, cmpFileName, DESTINATION_FOLDER, "diff", PASSWORD, PASSWORD)); + } + + @Test + @LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT, + ignore = true)) + public void macEncryptionWithAesGcmTest() throws IOException, InterruptedException { + String fileName = "macEncryptionWithAesGsmTest.pdf"; + String outputFileName = DESTINATION_FOLDER + fileName; + String cmpFileName = SOURCE_FOLDER + "cmp_" + fileName; + + WriterProperties writerProperties = new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0) + .setStandardEncryption(PASSWORD, PASSWORD, 0, EncryptionConstants.ENCRYPTION_AES_GCM, + new MacProperties(MacDigestAlgorithm.SHA_256)); + + try (PdfDocument pdfDoc = new PdfDocument(CompareTool.createTestPdfWriter(outputFileName, writerProperties))) { + pdfDoc.addNewPage().addAnnotation(new PdfTextAnnotation(new Rectangle(100, 100, 100, 100))); + } + Assertions.assertNull(new CompareTool().enableEncryptionCompare(false).compareByContent( + outputFileName, cmpFileName, DESTINATION_FOLDER, "diff", PASSWORD, PASSWORD)); + } + + @Test + @LogMessages(messages = { + @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT, ignore = true), + @LogMessage(messageTemplate = IoLogMessageConstant.PDF_WRITER_CLOSING_FAILED) + }) + public void standaloneMacUnwritableStreamTest() throws IOException { + WriterProperties writerProperties = new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0) + .setStandardEncryption(PASSWORD, PASSWORD, 0, EncryptionConstants.ENCRYPTION_AES_256, + new MacProperties(MacDigestAlgorithm.SHA_256)); + ByteArrayOutputStream unwritableStream = new ByteArrayOutputStream() { + @Override + public void write(byte[] b, int off, int len) { + throw new RuntimeException("expected"); + } + }; + + try (PdfDocument pdfDoc = new PdfDocument(new PdfWriter(unwritableStream, writerProperties))) { + pdfDoc.addNewPage().addAnnotation(new PdfTextAnnotation(new Rectangle(100, 100, 100, 100))); + } + + unwritableStream.close(); + } + + @Test + @LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT, + ignore = true)) + public void standaloneMacWithAllHashAlgorithmsTest() throws IOException, InterruptedException { + for (int i = 0; i < EnumUtil.getAllValuesOfEnum(MacDigestAlgorithm.class).size(); i++) { + String fileName = "standaloneMacWithAllHashAlgorithmsTest" + (i + 1) + ".pdf"; + String outputFileName = DESTINATION_FOLDER + fileName; + String cmpFileName = SOURCE_FOLDER + "cmp_" + fileName; + + MacProperties macProperties = new MacProperties(EnumUtil.getAllValuesOfEnum(MacDigestAlgorithm.class).get(i), + MacAlgorithm.HMAC_WITH_SHA_256, KeyWrappingAlgorithm.AES_256_NO_PADD); + WriterProperties writerProperties = new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0) + .setStandardEncryption(PASSWORD, PASSWORD, 0, EncryptionConstants.ENCRYPTION_AES_256, + macProperties); + + try (PdfDocument pdfDoc = new PdfDocument(CompareTool.createTestPdfWriter(outputFileName, writerProperties))) { + pdfDoc.addNewPage().addAnnotation(new PdfTextAnnotation(new Rectangle(100, 100, 100, 100))); + } + Assertions.assertNull(new CompareTool().enableEncryptionCompare(false).compareByContent( + outputFileName, cmpFileName, DESTINATION_FOLDER, "diff", PASSWORD, PASSWORD)); + } + } + + @Test + @LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT, + ignore = true)) + public void standaloneMacPdfVersionNotSetTest() { + String fileName = "standaloneMacPdfVersionNotSetTest.pdf"; + String outputFileName = DESTINATION_FOLDER + fileName; + + MacProperties macProperties = new MacProperties(MacDigestAlgorithm.SHA_256, MacAlgorithm.HMAC_WITH_SHA_256, + KeyWrappingAlgorithm.AES_256_NO_PADD); + WriterProperties writerProperties = new WriterProperties() + .setStandardEncryption(PASSWORD, PASSWORD, 0, EncryptionConstants.ENCRYPTION_AES_256, macProperties); + + String exceptionMessage = Assertions.assertThrows(PdfException.class, () -> { + try (PdfDocument pdfDoc = new PdfDocument(CompareTool.createTestPdfWriter(outputFileName, writerProperties))) { + pdfDoc.addNewPage().addAnnotation(new PdfTextAnnotation(new Rectangle(100, 100, 100, 100))); + } + }).getMessage(); + Assertions.assertEquals(KernelExceptionMessageConstant.MAC_FOR_PDF_2, exceptionMessage); + } + + @Test + @LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT, + ignore = true)) + public void addMacOnPreserveEncryptionTest() throws IOException, InterruptedException { + String fileName = "addMacOnPreserveEncryptionTest.pdf"; + String outputFileName = DESTINATION_FOLDER + fileName; + String cmpFileName = SOURCE_FOLDER + "cmp_" + fileName; + + try (PdfDocument pdfDoc = new PdfDocument(new PdfReader(SOURCE_FOLDER + "noMacProtectionDocument.pdf", + new ReaderProperties().setPassword(PASSWORD)), + CompareTool.createTestPdfWriter(outputFileName, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)), + new StampingProperties().preserveEncryption())) { + pdfDoc.addNewPage().addAnnotation(new PdfTextAnnotation(new Rectangle(100, 100, 100, 100))); + } + Assertions.assertNull(new CompareTool().enableEncryptionCompare(false).compareByContent( + outputFileName, cmpFileName, DESTINATION_FOLDER, "diff", PASSWORD, PASSWORD)); + } + + @Test + @LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT, + ignore = true)) + public void addMacOnAppendModeTest() throws IOException, InterruptedException { + // MAC should not be added in append mode + String fileName = "addMacOnAppendModeTest.pdf"; + String outputFileName = DESTINATION_FOLDER + fileName; + String cmpFileName = SOURCE_FOLDER + "cmp_" + fileName; + + try (PdfDocument pdfDoc = new PdfDocument(new PdfReader(SOURCE_FOLDER + "noMacProtectionDocument.pdf", + new ReaderProperties().setPassword(PASSWORD)), + CompareTool.createTestPdfWriter(outputFileName, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)), + new StampingProperties().useAppendMode())) { + pdfDoc.addNewPage().addAnnotation(new PdfTextAnnotation(new Rectangle(100, 100, 100, 100))); + } + Assertions.assertNull(new CompareTool().enableEncryptionCompare().compareByContent( + outputFileName, cmpFileName, DESTINATION_FOLDER, "diff", PASSWORD, PASSWORD)); + } + + @Test + @LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT, + ignore = true)) + public void addMacWithDisableMacPropertyTest() throws IOException, InterruptedException { + // MAC should not be added in disable MAC mode even if it was provided with writer properties + String fileName = "addMacWithDisableMacPropertyTest.pdf"; + String outputFileName = DESTINATION_FOLDER + fileName; + String cmpFileName = SOURCE_FOLDER + "cmp_" + fileName; + + MacProperties macProperties = new MacProperties(MacDigestAlgorithm.SHA_384); + WriterProperties writerProperties = new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0) + .setStandardEncryption(PASSWORD, PASSWORD, 0, EncryptionConstants.ENCRYPTION_AES_256, macProperties); + try (PdfDocument pdfDoc = new PdfDocument( + new PdfReader(SOURCE_FOLDER + "noMacProtectionDocument.pdf", new ReaderProperties().setPassword(PASSWORD)), + new PdfWriter(outputFileName, writerProperties), new StampingProperties().disableMac())) { + pdfDoc.addNewPage().addAnnotation(new PdfTextAnnotation(new Rectangle(100, 100, 100, 100))); + } + Assertions.assertNull(new CompareTool().enableEncryptionCompare().compareByContent( + outputFileName, cmpFileName, DESTINATION_FOLDER, "diff", PASSWORD, PASSWORD)); + } + + @Test + @LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT, + ignore = true)) + public void addMacOnPreserveEncryptionWhileDowngradingTest() throws IOException, InterruptedException { + String fileName = "addMacOnPreserveEncryptionWhileDowngradingTest.pdf"; + String outputFileName = DESTINATION_FOLDER + fileName; + String cmpFileName = SOURCE_FOLDER + "cmp_" + fileName; + + try (PdfDocument pdfDoc = new PdfDocument(new PdfReader(SOURCE_FOLDER + "noMacProtectionDocument.pdf", + new ReaderProperties().setPassword(PASSWORD)), + CompareTool.createTestPdfWriter(outputFileName, new WriterProperties().setPdfVersion(PdfVersion.PDF_1_7)), + new StampingProperties().preserveEncryption())) { + pdfDoc.addNewPage().addAnnotation(new PdfTextAnnotation(new Rectangle(100, 100, 100, 100))); + } + Assertions.assertNull(new CompareTool().enableEncryptionCompare().compareByContent( + outputFileName, cmpFileName, DESTINATION_FOLDER, "diff", PASSWORD, PASSWORD)); + } + + @Test + @LogMessages(messages = { + @LogMessage(messageTemplate = VersionConforming.DEPRECATED_AES256_REVISION), + @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT, ignore = true)}) + public void addMacOnPreserveEncryptionFor17DocTest() throws IOException, InterruptedException { + // We can't embed MAC into encrypted documents during the conversion from earlier PDF version + // because their encryption does not support this. So WriterProperties should be used iso preserveEncryption + String fileName = "addMacOnPreserveEncryptionFor17DocTest.pdf"; + String outputFileName = DESTINATION_FOLDER + fileName; + String cmpFileName = SOURCE_FOLDER + "cmp_" + fileName; + + try (PdfDocument pdfDoc = new PdfDocument(new PdfReader(SOURCE_FOLDER + "noMacProtectionDocument_1_7.pdf", + new ReaderProperties().setPassword(PASSWORD)), + CompareTool.createTestPdfWriter(outputFileName, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)), + new StampingProperties().preserveEncryption())) { + pdfDoc.addNewPage().addAnnotation(new PdfTextAnnotation(new Rectangle(100, 100, 100, 100))); + } + Assertions.assertNull(new CompareTool().enableEncryptionCompare().compareByContent( + outputFileName, cmpFileName, DESTINATION_FOLDER, "diff", PASSWORD, PASSWORD)); + } + + @Test + @LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT, + ignore = true)) + public void standaloneMacOldEncryptionAlgorithmTest() { + String fileName = "standaloneMacOldEncryptionAlgorithmTest.pdf"; + String outputFileName = DESTINATION_FOLDER + fileName; + + MacProperties macProperties = new MacProperties(MacDigestAlgorithm.SHA_256, MacAlgorithm.HMAC_WITH_SHA_256, + KeyWrappingAlgorithm.AES_256_NO_PADD); + WriterProperties writerProperties = new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0) + .setStandardEncryption(PASSWORD, PASSWORD, 0, EncryptionConstants.ENCRYPTION_AES_128, macProperties); + + String exceptionMessage = Assertions.assertThrows(PdfException.class, () -> { + try (PdfDocument pdfDoc = new PdfDocument(CompareTool.createTestPdfWriter(outputFileName, writerProperties))) { + pdfDoc.addNewPage().addAnnotation(new PdfTextAnnotation(new Rectangle(100, 100, 100, 100))); + } + }).getMessage(); + Assertions.assertEquals(KernelExceptionMessageConstant.MAC_FOR_ENCRYPTION_5, exceptionMessage); + } + + @Test + @LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT, + ignore = true)) + public void standaloneMacPublicKeyEncryptionTest() throws Exception { + try { + BouncyCastleFactoryCreator.getFactory().isEncryptionFeatureSupported(0, true); + } catch (Exception ignored) { + Assumptions.assumeTrue(false); + } + Assumptions.assumeTrue(!BouncyCastleFactoryCreator.getFactory().isInApprovedOnlyMode()); + String fileName = "standaloneMacPublicKeyEncryptionTest.pdf"; + String outputFileName = DESTINATION_FOLDER + fileName; + String cmpFileName = SOURCE_FOLDER + "cmp_" + fileName; + + Certificate certificate = CryptoUtil.readPublicCertificate(FileUtil.getInputStreamForFile(CERTS_SRC + "SHA256withRSA.cer")); + + WriterProperties writerProperties = new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0) + .setPublicKeyEncryption(new Certificate[] {certificate}, new int[] {-1}, EncryptionConstants.ENCRYPTION_AES_256, + new MacProperties(MacDigestAlgorithm.SHA_256)); + try (PdfDocument pdfDoc = new PdfDocument(CompareTool.createTestPdfWriter(outputFileName, writerProperties))) { + pdfDoc.addNewPage().addAnnotation(new PdfTextAnnotation(new Rectangle(100, 100, 100, 100))); + } + PrivateKey privateKey = getPrivateKey(CERTS_SRC + "SHA256withRSA.key"); + CompareTool compareTool = new CompareTool(); + compareTool.getCmpReaderProperties().setPublicKeySecurityParams(certificate, privateKey, PROVIDER_NAME, null); + compareTool.getOutReaderProperties().setPublicKeySecurityParams(certificate, privateKey, PROVIDER_NAME, null); + + Assertions.assertNull(compareTool.compareByContent(outputFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + } + + @Test + @LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT, + ignore = true)) + // TODO DEVSIX-8635 - Verify MAC permission and embed MAC in stamping mode for public key encryption + public void addMacOnPreservePublicKeyEncryptionTest() throws Exception { + try { + BouncyCastleFactoryCreator.getFactory().isEncryptionFeatureSupported(0, true); + } catch (Exception ignored) { + Assumptions.assumeTrue(false); + } + + String fileName = "addMacOnPreservePublicKeyEncryptionTest.pdf"; + String outputFileName = DESTINATION_FOLDER + fileName; + String cmpFileName = SOURCE_FOLDER + "cmp_" + fileName; + + Certificate certificate = CryptoUtil.readPublicCertificate( + FileUtil.getInputStreamForFile(CERTS_SRC + "SHA256withRSA.cer")); + PrivateKey privateKey = getPrivateKey(CERTS_SRC + "SHA256withRSA.key"); + ReaderProperties readerProperties = new ReaderProperties(); + readerProperties.setPublicKeySecurityParams(certificate, privateKey, PROVIDER_NAME, null); + try (PdfDocument pdfDoc = new PdfDocument( + new PdfReader(SOURCE_FOLDER + "noMacProtectionPublicKeyEncryptionDocument.pdf", readerProperties), + CompareTool.createTestPdfWriter(outputFileName), new StampingProperties().preserveEncryption())) { + pdfDoc.addNewPage().addAnnotation(new PdfTextAnnotation(new Rectangle(100, 100, 100, 100))); + } + + CompareTool compareTool = new CompareTool(); + compareTool.getCmpReaderProperties().setPublicKeySecurityParams(certificate, privateKey, PROVIDER_NAME, null); + compareTool.getOutReaderProperties().setPublicKeySecurityParams(certificate, privateKey, PROVIDER_NAME, null); + + Assertions.assertNull(compareTool.compareByContent(outputFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + } + + public static PrivateKey getPrivateKey(String keyName) throws IOException, AbstractPKCSException, AbstractOperatorCreationException { + return PemFileHelper.readPrivateKeyFromPemFile( + FileUtil.getInputStreamForFile(keyName), "testpassphrase".toCharArray()); + } +} diff --git a/kernel/src/test/java/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest.java b/kernel/src/test/java/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest.java new file mode 100644 index 0000000000..91e466e10c --- /dev/null +++ b/kernel/src/test/java/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest.java @@ -0,0 +1,398 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.mac; + +import com.itextpdf.bouncycastleconnector.BouncyCastleFactoryCreator; +import com.itextpdf.commons.utils.FileUtil; +import com.itextpdf.kernel.crypto.CryptoUtil; +import com.itextpdf.kernel.exceptions.KernelExceptionMessageConstant; +import com.itextpdf.kernel.exceptions.PdfException; +import com.itextpdf.kernel.geom.Rectangle; +import com.itextpdf.kernel.logs.KernelLogMessageConstant; +import com.itextpdf.kernel.mac.MacProperties.MacDigestAlgorithm; +import com.itextpdf.kernel.pdf.DocumentProperties; +import com.itextpdf.kernel.pdf.EncryptionConstants; +import com.itextpdf.kernel.pdf.PdfDocument; +import com.itextpdf.kernel.pdf.PdfReader; +import com.itextpdf.kernel.pdf.PdfVersion; +import com.itextpdf.kernel.pdf.ReaderProperties; +import com.itextpdf.kernel.pdf.StampingProperties; +import com.itextpdf.kernel.pdf.WriterProperties; +import com.itextpdf.kernel.pdf.annot.PdfTextAnnotation; +import com.itextpdf.kernel.utils.CompareTool; +import com.itextpdf.test.AssertUtil; +import com.itextpdf.test.ExtendedITextTest; +import com.itextpdf.test.annotations.LogMessage; +import com.itextpdf.test.annotations.LogMessages; + +import java.io.IOException; +import java.security.PrivateKey; +import java.security.Security; +import java.security.cert.Certificate; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +@Tag("BouncyCastleIntegrationTest") +public class MacIntegrityProtectorReadingAndRewritingTest extends ExtendedITextTest { + private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/"; + private static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/"; + private static final String CERTS_SRC = "./src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/certs/"; + private static final byte[] PASSWORD = "123".getBytes(); + private static final String PROVIDER_NAME = BouncyCastleFactoryCreator.getFactory().getProviderName(); + + @BeforeAll + public static void beforeClass() { + createOrClearDestinationFolder(DESTINATION_FOLDER); + Security.addProvider(BouncyCastleFactoryCreator.getFactory().getProvider()); + } + + @AfterAll + public static void afterClass() { + CompareTool.cleanup(DESTINATION_FOLDER); + } + + @Test + @LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT, + ignore = true)) + public void appendModeTest() throws IOException, InterruptedException { + String fileName = "appendModeTest.pdf"; + String outputFileName = DESTINATION_FOLDER + fileName; + String cmpFileName = SOURCE_FOLDER + "cmp_" + fileName; + + try (PdfDocument pdfDoc = new PdfDocument(new PdfReader(SOURCE_FOLDER + "macProtectedDocument.pdf", + new ReaderProperties().setPassword(PASSWORD)), CompareTool.createTestPdfWriter(outputFileName), + new StampingProperties().useAppendMode())) { + pdfDoc.addNewPage().addAnnotation(new PdfTextAnnotation(new Rectangle(100, 100, 100, 100))); + } + Assertions.assertNull(new CompareTool().enableEncryptionCompare().compareByContent( + outputFileName, cmpFileName, DESTINATION_FOLDER, "diff", PASSWORD, PASSWORD)); + } + + @Test + @LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT, + ignore = true)) + public void preserveEncryptionTest() throws IOException, InterruptedException { + String fileName = "preserveEncryptionTest.pdf"; + String outputFileName = DESTINATION_FOLDER + fileName; + String cmpFileName = SOURCE_FOLDER + "cmp_" + fileName; + + try (PdfDocument pdfDoc = new PdfDocument( + new PdfReader(SOURCE_FOLDER + "macProtectedDocument.pdf", new ReaderProperties().setPassword(PASSWORD)), + CompareTool.createTestPdfWriter(outputFileName), + new StampingProperties().preserveEncryption())) { + pdfDoc.addNewPage().addAnnotation(new PdfTextAnnotation(new Rectangle(100, 100, 100, 100))); + } + Assertions.assertNull(new CompareTool().enableEncryptionCompare().compareByContent( + outputFileName, cmpFileName, DESTINATION_FOLDER, "diff", PASSWORD, PASSWORD)); + } + + @Test + @LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT, + ignore = true)) + public void disableMacTest() throws IOException, InterruptedException { + String fileName = "disableMacTest.pdf"; + String outputFileName = DESTINATION_FOLDER + fileName; + String cmpFileName = SOURCE_FOLDER + "cmp_" + fileName; + + try (PdfDocument pdfDoc = new PdfDocument( + new PdfReader(SOURCE_FOLDER + "macProtectedDocument.pdf", new ReaderProperties().setPassword(PASSWORD)), + CompareTool.createTestPdfWriter(outputFileName), + new StampingProperties().preserveEncryption().disableMac())) { + pdfDoc.addNewPage().addAnnotation(new PdfTextAnnotation(new Rectangle(100, 100, 100, 100))); + } + Assertions.assertNull(new CompareTool().enableEncryptionCompare().compareByContent( + outputFileName, cmpFileName, DESTINATION_FOLDER, "diff", PASSWORD, PASSWORD)); + } + + @Test + @LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT, + ignore = true)) + public void disableMacInAppendModeTest() throws IOException, InterruptedException { + // We do not disable MAC in append mode if it was there + String fileName = "disableMacInAppendModeTest.pdf"; + String outputFileName = DESTINATION_FOLDER + fileName; + String cmpFileName = SOURCE_FOLDER + "cmp_" + fileName; + + try (PdfDocument pdfDoc = new PdfDocument( + new PdfReader(SOURCE_FOLDER + "macProtectedDocument.pdf", new ReaderProperties().setPassword(PASSWORD)), + CompareTool.createTestPdfWriter(outputFileName), + new StampingProperties().useAppendMode().disableMac())) { + pdfDoc.addNewPage().addAnnotation(new PdfTextAnnotation(new Rectangle(100, 100, 100, 100))); + } + Assertions.assertNull(new CompareTool().enableEncryptionCompare().compareByContent( + outputFileName, cmpFileName, DESTINATION_FOLDER, "diff", PASSWORD, PASSWORD)); + } + + @Test + @LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT, + ignore = true)) + public void writerPropertiesTest() throws IOException, InterruptedException { + String fileName = "writerPropertiesTest.pdf"; + String outputFileName = DESTINATION_FOLDER + fileName; + String cmpFileName = SOURCE_FOLDER + "cmp_" + fileName; + + MacProperties macProperties = new MacProperties(MacDigestAlgorithm.SHA_512); + WriterProperties writerProperties = new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0) + .setStandardEncryption(PASSWORD, PASSWORD, 0, EncryptionConstants.ENCRYPTION_AES_256, macProperties); + + try (PdfDocument pdfDoc = new PdfDocument( + new PdfReader(SOURCE_FOLDER + "macProtectedDocument.pdf", new ReaderProperties().setPassword(PASSWORD)), + CompareTool.createTestPdfWriter(outputFileName, writerProperties))) { + pdfDoc.addNewPage().addAnnotation(new PdfTextAnnotation(new Rectangle(100, 100, 100, 100))); + } + Assertions.assertNull(new CompareTool().compareByContent( + outputFileName, cmpFileName, DESTINATION_FOLDER, "diff", PASSWORD, PASSWORD)); + } + + @Test + @LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT, + ignore = true)) + public void macShouldNotBePreservedWithEncryptionTest() throws IOException, InterruptedException { + String fileName = "macShouldNotBePreservedWithEncryptionTest.pdf"; + String outputFileName = DESTINATION_FOLDER + fileName; + String cmpFileName = SOURCE_FOLDER + "cmp_" + fileName; + + WriterProperties writerProperties = new WriterProperties().setPdfVersion(PdfVersion.PDF_1_7) + .setStandardEncryption(PASSWORD, PASSWORD, 0, EncryptionConstants.ENCRYPTION_AES_128); + try (PdfDocument pdfDoc = new PdfDocument(new PdfReader(SOURCE_FOLDER + "macProtectedDocument.pdf", + new ReaderProperties().setPassword(PASSWORD)), CompareTool.createTestPdfWriter(outputFileName, writerProperties))) { + pdfDoc.addNewPage().addAnnotation(new PdfTextAnnotation(new Rectangle(100, 100, 100, 100))); + } + Assertions.assertNull(new CompareTool().enableEncryptionCompare().compareByContent( + outputFileName, cmpFileName, DESTINATION_FOLDER, "diff", PASSWORD, PASSWORD)); + } + + @Test + @LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT, + ignore = true)) + public void macShouldNotBePreservedTest() throws IOException, InterruptedException { + String fileName = "macShouldNotBePreservedTest.pdf"; + String outputFileName = DESTINATION_FOLDER + fileName; + String cmpFileName = SOURCE_FOLDER + "cmp_" + fileName; + + try (PdfDocument pdfDoc = new PdfDocument( + new PdfReader(SOURCE_FOLDER + "macProtectedDocument.pdf", new ReaderProperties().setPassword(PASSWORD)), + CompareTool.createTestPdfWriter(outputFileName))) { + pdfDoc.addNewPage().addAnnotation(new PdfTextAnnotation(new Rectangle(100, 100, 100, 100))); + } + Assertions.assertNull(new CompareTool().compareByContent( + outputFileName, cmpFileName, DESTINATION_FOLDER, "diff", PASSWORD, PASSWORD)); + } + + @Test + @LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT, + ignore = true)) + public void invalidMacTokenTest() { + String fileName = "invalidMacTokenTest.pdf"; + String outputFileName = DESTINATION_FOLDER + fileName; + + String exceptionMessage = Assertions.assertThrows(PdfException.class, () -> { + try (PdfDocument pdfDoc = new PdfDocument(new PdfReader(SOURCE_FOLDER + "invalidMacProtectedDocument.pdf", + new ReaderProperties().setPassword(PASSWORD)), CompareTool.createTestPdfWriter(outputFileName))) { + pdfDoc.addNewPage().addAnnotation(new PdfTextAnnotation(new Rectangle(100, 100, 100, 100))); + } + }).getMessage(); + Assertions.assertEquals(KernelExceptionMessageConstant.MAC_VALIDATION_FAILED, exceptionMessage); + } + + @Test + @LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT, + ignore = true)) + public void invalidPublicKeyMacProtectedDocumentTest() throws Exception { + try { + BouncyCastleFactoryCreator.getFactory().isEncryptionFeatureSupported(0, true); + } catch (Exception ignored) { + Assumptions.assumeTrue(false); + } + String fileName = "invalidPublicKeyMacProtectedDocumentTest.pdf"; + String outputFileName = DESTINATION_FOLDER + fileName; + + Certificate certificate = CryptoUtil.readPublicCertificate( + FileUtil.getInputStreamForFile(CERTS_SRC + "SHA256withRSA.cer")); + PrivateKey privateKey = MacIntegrityProtectorCreationTest.getPrivateKey(CERTS_SRC + "SHA256withRSA.key"); + String exceptionMessage = Assertions.assertThrows(PdfException.class, () -> { + try (PdfDocument pdfDoc = new PdfDocument( + new PdfReader(SOURCE_FOLDER + "invalidPublicKeyMacProtectedDocument.pdf", + new ReaderProperties().setPublicKeySecurityParams(certificate, privateKey, PROVIDER_NAME, + null)), CompareTool.createTestPdfWriter(outputFileName))) { + pdfDoc.addNewPage().addAnnotation(new PdfTextAnnotation(new Rectangle(100, 100, 100, 100))); + } + }).getMessage(); + Assertions.assertEquals(KernelExceptionMessageConstant.MAC_VALIDATION_FAILED, + exceptionMessage); + } + + @Test + @LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT, + ignore = true)) + public void readSignedMacProtectedDocumentWithoutAttributeTest() { + String message = Assertions.assertThrows(PdfException.class, () -> { + try (PdfDocument ignored = new PdfDocument(new PdfReader(SOURCE_FOLDER + "signedMacProtectedDocWithoutAttribute.pdf", + new ReaderProperties().setPassword(PASSWORD)))) { + } + }).getMessage(); + Assertions.assertEquals(KernelExceptionMessageConstant.MAC_ATTRIBUTE_NOT_SPECIFIED, message); + } + + @Test + @LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT, + ignore = true)) + public void macProtectionStrippedTest() { + String message = Assertions.assertThrows(PdfException.class, () -> { + try (PdfDocument ignored = new PdfDocument(new PdfReader(SOURCE_FOLDER + "macProtectionStrippedTest.pdf", + new ReaderProperties().setPassword(PASSWORD)))) { + } + }).getMessage(); + Assertions.assertEquals(KernelExceptionMessageConstant.MAC_PERMS_WITHOUT_MAC, message); + } + + @Test + @LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT, + ignore = true)) + public void readSignedMacProtectedDocumentTest() { + AssertUtil.doesNotThrow(() -> { + try (PdfDocument ignored = new PdfDocument(new PdfReader(SOURCE_FOLDER + "signedMacProtectedDocument.pdf", + new ReaderProperties().setPassword(PASSWORD)))) { + } + }); + } + + @Test + @LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT, + ignore = true)) + public void readThirdPartyMacProtectedDocumentTest() { + AssertUtil.doesNotThrow(() -> { + try (PdfDocument ignored = new PdfDocument(new PdfReader(SOURCE_FOLDER + "thirdPartyMacProtectedDocument.pdf", + new ReaderProperties().setPassword(PASSWORD)))) { + } + }); + } + + @Test + @LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT, + ignore = true)) + public void readThirdPartyPublicKeyMacProtectedDocumentTest() throws Exception { + try { + BouncyCastleFactoryCreator.getFactory().isEncryptionFeatureSupported(0, true); + } catch (Exception ignored) { + Assumptions.assumeTrue(false); + } + PrivateKey privateKey = MacIntegrityProtectorCreationTest.getPrivateKey(CERTS_SRC + "keyForEncryption.pem"); + Certificate certificate = CryptoUtil.readPublicCertificate( + FileUtil.getInputStreamForFile(CERTS_SRC + "certForEncryption.crt")); + AssertUtil.doesNotThrow(() -> { + try (PdfDocument ignored = new PdfDocument(new PdfReader(SOURCE_FOLDER + "thirdPartyPublicKeyMacProtectedDocument.pdf", + new ReaderProperties().setPublicKeySecurityParams(certificate, privateKey, PROVIDER_NAME, null)))) { + } + }); + } + + @Test + @LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT, + ignore = true)) + public void readMacProtectedPdf1_7() { + AssertUtil.doesNotThrow(() -> { + try (PdfDocument ignored = new PdfDocument(new PdfReader(SOURCE_FOLDER + "macProtectedDocumentPdf1_7.pdf", + new ReaderProperties().setPassword(PASSWORD)))) { + } + }); + } + + @Test + @LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT, + ignore = true)) + public void noSaltTest() { + String message = Assertions.assertThrows(PdfException.class, () -> { + try (PdfDocument pdfDoc = new PdfDocument(new PdfReader(SOURCE_FOLDER + "noSaltTest.pdf", + new ReaderProperties().setPassword(PASSWORD)))) { + } + }).getMessage(); + Assertions.assertEquals(KernelExceptionMessageConstant.MAC_VALIDATION_NO_SALT, message); + } + + @Test + @LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT, + ignore = true)) + public void readTamperedMacProtectedDocumentTest() { + String message = Assertions.assertThrows(PdfException.class, () -> { + try (PdfDocument ignored = new PdfDocument( + new PdfReader(SOURCE_FOLDER + "thirdPartyMacProtectedDocumentTampered.pdf", + new ReaderProperties().setPassword(PASSWORD)))) { + } + }).getMessage(); + Assertions.assertEquals(KernelExceptionMessageConstant.MAC_VALIDATION_FAILED, message); + } + + @Test + @LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT, + ignore = true)) + public void doNotThrowOnValidationTest1() throws IOException, InterruptedException { + String fileName = "doNotThrowOnValidationTest1.pdf"; + String outputFileName = DESTINATION_FOLDER + fileName; + String cmpFileName = SOURCE_FOLDER + "cmp_" + fileName; + + StampingProperties stampingProperties = new StampingProperties(); + stampingProperties.registerDependency(IMacContainerLocator.class, + new StandaloneMacContainerLocator() { + @Override + public void handleMacValidationError(MacValidationException exception) { + // do nothing + } + }); + try (PdfDocument pdfDoc = new PdfDocument(new PdfReader(SOURCE_FOLDER + "macProtectionStrippedTest.pdf", + new ReaderProperties().setPassword(PASSWORD)), + CompareTool.createTestPdfWriter(outputFileName), stampingProperties)) { + } + + new CompareTool().compareByContent(outputFileName, cmpFileName, DESTINATION_FOLDER, "diff"); + } + + @Test + @LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT, + ignore = true)) + public void doNotThrowOnValidationTest2() throws IOException, InterruptedException { + String fileName = "doNotThrowOnValidationTest2.pdf"; + String outputFileName = DESTINATION_FOLDER + fileName; + String cmpFileName = SOURCE_FOLDER + "cmp_" + fileName; + + StampingProperties stampingProperties = new StampingProperties(); + stampingProperties.registerDependency(IMacContainerLocator.class, + new StandaloneMacContainerLocator() { + @Override + public void handleMacValidationError(MacValidationException exception) { + // do nothing + } + }); + try (PdfDocument pdfDoc = new PdfDocument( + new PdfReader(SOURCE_FOLDER + "thirdPartyMacProtectedDocumentTampered.pdf", + new ReaderProperties().setPassword(PASSWORD)), + CompareTool.createTestPdfWriter(outputFileName), stampingProperties)) { + } + + new CompareTool().compareByContent(outputFileName, cmpFileName, DESTINATION_FOLDER, "diff"); + } +} diff --git a/kernel/src/test/java/com/itextpdf/kernel/numbering/ArmenianNumberingTest.java b/kernel/src/test/java/com/itextpdf/kernel/numbering/ArmenianNumberingTest.java index 5856ab7dc2..52c690c3f7 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/numbering/ArmenianNumberingTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/numbering/ArmenianNumberingTest.java @@ -23,32 +23,31 @@ This file is part of the iText (R) project. package com.itextpdf.kernel.numbering; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class ArmenianNumberingTest extends ExtendedITextTest { @Test public void negativeToArmenianTest() { - Assert.assertEquals("", ArmenianNumbering.toArmenian(-10)); + Assertions.assertEquals("", ArmenianNumbering.toArmenian(-10)); } @Test public void zeroToArmenianTest() { - Assert.assertEquals("", ArmenianNumbering.toArmenian(0)); + Assertions.assertEquals("", ArmenianNumbering.toArmenian(0)); } @Test public void toArmenianTest() { - Assert.assertEquals("\u0554\u054B\u0542\u0539", ArmenianNumbering.toArmenian(9999)); - Assert.assertEquals("\u0552\u054A\u0540\u0534", ArmenianNumbering.toArmenian(7874)); + Assertions.assertEquals("\u0554\u054B\u0542\u0539", ArmenianNumbering.toArmenian(9999)); + Assertions.assertEquals("\u0552\u054A\u0540\u0534", ArmenianNumbering.toArmenian(7874)); } @Test public void numberGreaterThan9999toArmenianTest() { - Assert.assertEquals("\u0554\u0554\u0554\u0554\u0554\u0554\u0554\u0532", ArmenianNumbering.toArmenian(63002)); + Assertions.assertEquals("\u0554\u0554\u0554\u0554\u0554\u0554\u0554\u0532", ArmenianNumbering.toArmenian(63002)); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/numbering/GeorgianNumberingTest.java b/kernel/src/test/java/com/itextpdf/kernel/numbering/GeorgianNumberingTest.java index 2594f5da45..59ed2e5bc2 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/numbering/GeorgianNumberingTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/numbering/GeorgianNumberingTest.java @@ -23,32 +23,31 @@ This file is part of the iText (R) project. package com.itextpdf.kernel.numbering; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class GeorgianNumberingTest extends ExtendedITextTest { @Test public void negativeToGeorgianTest() { - Assert.assertEquals("", GeorgianNumbering.toGeorgian(-10)); + Assertions.assertEquals("", GeorgianNumbering.toGeorgian(-10)); } @Test public void zeroToGeorgianTest() { - Assert.assertEquals("", GeorgianNumbering.toGeorgian(0)); + Assertions.assertEquals("", GeorgianNumbering.toGeorgian(0)); } @Test public void toGeorgianTest() { - Assert.assertEquals("\u10F5", GeorgianNumbering.toGeorgian(10000)); - Assert.assertEquals("\u10F4\u10E8\u10F2\u10D6", GeorgianNumbering.toGeorgian(7967)); + Assertions.assertEquals("\u10F5", GeorgianNumbering.toGeorgian(10000)); + Assertions.assertEquals("\u10F4\u10E8\u10F2\u10D6", GeorgianNumbering.toGeorgian(7967)); } @Test public void numberGreaterThan10000toGeorgianTest() { - Assert.assertEquals("\u10F5\u10F5\u10F5\u10F5\u10F5\u10F5\u10D2", GeorgianNumbering.toGeorgian(60003));; + Assertions.assertEquals("\u10F5\u10F5\u10F5\u10F5\u10F5\u10F5\u10D2", GeorgianNumbering.toGeorgian(60003));; } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/numbering/GreekAlphabetNumberingTest.java b/kernel/src/test/java/com/itextpdf/kernel/numbering/GreekAlphabetNumberingTest.java index 382287a62a..7042335166 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/numbering/GreekAlphabetNumberingTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/numbering/GreekAlphabetNumberingTest.java @@ -23,12 +23,11 @@ This file is part of the iText (R) project. package com.itextpdf.kernel.numbering; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class GreekAlphabetNumberingTest extends ExtendedITextTest { @Test @@ -38,7 +37,7 @@ public void testUpperCase() { builder.append(GreekAlphabetNumbering.toGreekAlphabetNumber(i, true)); } // 25th symbol is `AA`, i.e. alphabet has 24 letters. - Assert.assertEquals("ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩΑΑ", builder.toString()); + Assertions.assertEquals("ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩΑΑ", builder.toString()); } @Test @@ -48,7 +47,7 @@ public void testLowerCase() { builder.append(GreekAlphabetNumbering.toGreekAlphabetNumber(i, false)); } // 25th symbol is `αα`, i.e. alphabet has 24 letters. - Assert.assertEquals("αβγδεζηθικλμνξοπρστυφχψωαα", builder.toString()); + Assertions.assertEquals("αβγδεζηθικλμνξοπρστυφχψωαα", builder.toString()); } @Test @@ -58,7 +57,7 @@ public void testUpperCaseSymbol() { builder.append(GreekAlphabetNumbering.toGreekAlphabetNumber(i, true, true)); } // Symbol font use regular WinAnsi codes for greek letters. - Assert.assertEquals("ABGDEZHQIKLMNXOPRSTUFCYWAA", builder.toString()); + Assertions.assertEquals("ABGDEZHQIKLMNXOPRSTUFCYWAA", builder.toString()); } @Test @@ -68,11 +67,11 @@ public void testLowerCaseSymbol() { builder.append(GreekAlphabetNumbering.toGreekAlphabetNumber(i, false, true)); } // Symbol font use regular WinAnsi codes for greek letters. - Assert.assertEquals("abgdezhqiklmnxoprstufcywaa", builder.toString()); + Assertions.assertEquals("abgdezhqiklmnxoprstufcywaa", builder.toString()); } @Test public void intIsNotEnoughForInternalCalculationsTest() { - Assert.assertEquals("ζλαββωσ", GreekAlphabetNumbering.toGreekAlphabetNumberLowerCase(1234567890)); + Assertions.assertEquals("ζλαββωσ", GreekAlphabetNumbering.toGreekAlphabetNumberLowerCase(1234567890)); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/numbering/RomanNumberingTest.java b/kernel/src/test/java/com/itextpdf/kernel/numbering/RomanNumberingTest.java index 4cde678c5e..c330a921a9 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/numbering/RomanNumberingTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/numbering/RomanNumberingTest.java @@ -23,47 +23,46 @@ This file is part of the iText (R) project. package com.itextpdf.kernel.numbering; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class RomanNumberingTest extends ExtendedITextTest { @Test public void negativeConvertTest() { - Assert.assertEquals("-vi", RomanNumbering.convert(-6)); + Assertions.assertEquals("-vi", RomanNumbering.convert(-6)); } @Test public void zeroConvertTest() { - Assert.assertEquals("", RomanNumbering.convert(0)); + Assertions.assertEquals("", RomanNumbering.convert(0)); } @Test public void convertTest() { - Assert.assertEquals("mdclxvi", RomanNumbering.convert(1666)); - Assert.assertEquals("mcmlxxxiii", RomanNumbering.convert(1983)); - Assert.assertEquals("mmm", RomanNumbering.convert(3000)); - Assert.assertEquals("|vi|", RomanNumbering.convert(6000)); - Assert.assertEquals("|vi|dccxxxiii", RomanNumbering.convert(6733)); + Assertions.assertEquals("mdclxvi", RomanNumbering.convert(1666)); + Assertions.assertEquals("mcmlxxxiii", RomanNumbering.convert(1983)); + Assertions.assertEquals("mmm", RomanNumbering.convert(3000)); + Assertions.assertEquals("|vi|", RomanNumbering.convert(6000)); + Assertions.assertEquals("|vi|dccxxxiii", RomanNumbering.convert(6733)); } @Test public void toRomanTest() { String expected = "dcclvi"; - Assert.assertEquals(expected.toUpperCase(), RomanNumbering.toRoman(756, true)); - Assert.assertEquals(expected.toLowerCase(), RomanNumbering.toRoman(756, false)); + Assertions.assertEquals(expected.toUpperCase(), RomanNumbering.toRoman(756, true)); + Assertions.assertEquals(expected.toLowerCase(), RomanNumbering.toRoman(756, false)); } @Test public void toRomanUpperCaseTest() { - Assert.assertEquals("CCCLXXXVI", RomanNumbering.toRomanUpperCase(386)); + Assertions.assertEquals("CCCLXXXVI", RomanNumbering.toRomanUpperCase(386)); } @Test public void toRomanLowerCaseTest() { - Assert.assertEquals("xxvi", RomanNumbering.toRomanLowerCase(26)); + Assertions.assertEquals("xxvi", RomanNumbering.toRomanLowerCase(26)); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/DocumentPropertiesUnitTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/DocumentPropertiesUnitTest.java index 5abec5124b..43175d5757 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/DocumentPropertiesUnitTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/DocumentPropertiesUnitTest.java @@ -24,25 +24,24 @@ This file is part of the iText (R) project. import com.itextpdf.commons.actions.contexts.IMetaInfo; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class DocumentPropertiesUnitTest extends ExtendedITextTest { @Test public void setEventCountingMetaInfoTest() { DocumentProperties documentProperties = new DocumentProperties(); documentProperties.setEventCountingMetaInfo(new TestMetaInfo()); - Assert.assertTrue(documentProperties.isEventCountingMetaInfoSet()); + Assertions.assertTrue(documentProperties.isEventCountingMetaInfoSet()); } @Test public void metaInfoIsNotSetTest() { DocumentProperties documentProperties = new DocumentProperties(); - Assert.assertFalse(documentProperties.isEventCountingMetaInfoSet()); + Assertions.assertFalse(documentProperties.isEventCountingMetaInfoSet()); } private static class TestMetaInfo implements IMetaInfo { diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/EncodingTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/EncodingTest.java index e22286d700..1c9b559649 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/EncodingTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/EncodingTest.java @@ -31,28 +31,27 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.canvas.parser.PdfTextExtractor; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.ByteArrayOutputStream; import java.io.IOException; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class EncodingTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/kernel/pdf/EncodingTest/"; public static final String outputFolder = "./target/test/com/itextpdf/kernel/pdf/EncodingTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(outputFolder); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(outputFolder); } @@ -77,7 +76,7 @@ public void surrogatePairTest() throws IOException, InterruptedException { canvas.release(); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outputFolder + fileName, sourceFolder + "cmp_" + fileName, outputFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outputFolder + fileName, sourceFolder + "cmp_" + fileName, outputFolder, "diff_")); } @Test @@ -101,7 +100,7 @@ public void customSimpleEncodingTimesRomanTest() throws IOException, Interrupted restoreState(); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outputFolder + fileName, sourceFolder + "cmp_" + fileName, outputFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outputFolder + fileName, sourceFolder + "cmp_" + fileName, outputFolder, "diff_")); } @Test @@ -123,7 +122,7 @@ public void customFullEncodingTimesRomanTest() throws IOException, InterruptedEx restoreState(); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outputFolder + fileName, sourceFolder + "cmp_" + fileName, outputFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outputFolder + fileName, sourceFolder + "cmp_" + fileName, outputFolder, "diff_")); } @Test @@ -157,7 +156,7 @@ public void notdefInStandardFontTest() throws IOException, InterruptedException doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outputFolder + fileName, sourceFolder + "cmp_" + fileName, outputFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outputFolder + fileName, sourceFolder + "cmp_" + fileName, outputFolder, "diff_")); } @Test @@ -189,7 +188,7 @@ public void notdefInTrueTypeFontTest() throws IOException, InterruptedException doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outputFolder + fileName, sourceFolder + "cmp_" + fileName, outputFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outputFolder + fileName, sourceFolder + "cmp_" + fileName, outputFolder, "diff_")); } @Test @@ -211,7 +210,7 @@ public void notdefInType0Test() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outputFolder + fileName, sourceFolder + "cmp_" + fileName, outputFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outputFolder + fileName, sourceFolder + "cmp_" + fileName, outputFolder, "diff_")); } @Test @@ -227,7 +226,7 @@ public void symbolDefaultFontTest() throws IOException, InterruptedException { fillSymbolDefaultPage(font, doc.addNewPage()); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outputFolder + fileName, sourceFolder + "cmp_" + fileName, outputFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outputFolder + fileName, sourceFolder + "cmp_" + fileName, outputFolder, "diff_")); } private void fillSymbolDefaultPage(PdfFont font, PdfPage page) { @@ -312,7 +311,7 @@ public void symbolTrueTypeFontWinAnsiTest() throws IOException, InterruptedExcep restoreState(); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outputFolder + fileName, sourceFolder + "cmp_" + fileName, outputFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outputFolder + fileName, sourceFolder + "cmp_" + fileName, outputFolder, "diff_")); } @Test @@ -363,7 +362,7 @@ public void symbolTrueTypeFontIdentityTest() throws IOException, InterruptedExce restoreState(); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outputFolder + fileName, sourceFolder + "cmp_" + fileName, outputFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outputFolder + fileName, sourceFolder + "cmp_" + fileName, outputFolder, "diff_")); } @Test @@ -385,7 +384,7 @@ public void symbolTrueTypeFontSameCharsIdentityTest() throws IOException, Interr restoreState(); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outputFolder + fileName, sourceFolder + "cmp_" + fileName, outputFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outputFolder + fileName, sourceFolder + "cmp_" + fileName, outputFolder, "diff_")); } @Test @@ -393,7 +392,7 @@ public void encodingStreamExtractionTest() throws IOException { String fileName = sourceFolder + "encodingStream01.pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfReader(fileName)); String extractedText = PdfTextExtractor.getTextFromPage(pdfDocument.getPage(1)); - Assert.assertEquals("abc", extractedText); + Assertions.assertEquals("abc", extractedText); } @Test @@ -401,6 +400,6 @@ public void differentCodeSpaceRangeLengthsExtractionTest() throws IOException { String fileName = sourceFolder + "differentCodeSpaceRangeLengths01.pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfReader(fileName)); String extractedText = PdfTextExtractor.getTextFromPage(pdfDocument.getPage(1)); - Assert.assertEquals("Hello\u7121\u540dworld\u6b98\u528d", extractedText); + Assertions.assertEquals("Hello\u7121\u540dworld\u6b98\u528d", extractedText); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/EncryptedEmbeddedStreamsHandlerTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/EncryptedEmbeddedStreamsHandlerTest.java index 8428f08d06..879da4b9ca 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/EncryptedEmbeddedStreamsHandlerTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/EncryptedEmbeddedStreamsHandlerTest.java @@ -30,28 +30,27 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.BouncyCastleIntegrationTest; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; -@Category(BouncyCastleIntegrationTest.class) +@Tag("BouncyCastleIntegrationTest") public class EncryptedEmbeddedStreamsHandlerTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/kernel/pdf/EncryptedEmbeddedStreamsHandlerTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/kernel/pdf/EncryptedEmbeddedStreamsHandlerTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(destinationFolder); } @@ -71,7 +70,7 @@ public void noReaderStandardEncryptionAddFileAttachment() throws IOException, In pdfDocument.addNewPage(); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff", "password".getBytes(), "password".getBytes())); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff", "password".getBytes(), "password".getBytes())); } @Test @@ -89,7 +88,7 @@ public void noReaderAesEncryptionAddFileAttachment() throws IOException, Interru pdfDocument.addNewPage(); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff", "password".getBytes(), "password".getBytes())); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff", "password".getBytes(), "password".getBytes())); } @Test @@ -110,7 +109,7 @@ public void withReaderStandardEncryptionAddFileAttachment() throws IOException, pdfDocument.addNewPage(); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -128,7 +127,7 @@ public void noReaderStandardEncryptionAddAnnotation() throws IOException, Interr pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff", "password".getBytes(), "password".getBytes())); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff", "password".getBytes(), "password".getBytes())); } @Test @@ -149,7 +148,7 @@ public void withReaderStandardEncryptionAddAnnotation() throws IOException, Inte pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -167,7 +166,7 @@ public void readerWithoutEncryptionWriterStandardEncryption() throws IOException pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff", "password".getBytes(), "password".getBytes())); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff", "password".getBytes(), "password".getBytes())); } private PdfDocument createEncryptedDocument(int encryptionAlgorithm, String outFileName) throws IOException { diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/FingerPrintTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/FingerPrintTest.java index 120be987d3..aede78eb63 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/FingerPrintTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/FingerPrintTest.java @@ -25,20 +25,19 @@ This file is part of the iText (R) project. import com.itextpdf.commons.actions.data.ProductData; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class FingerPrintTest extends ExtendedITextTest { private ProductData productData; private ProductData productData2; private ProductData duplicateProductData; - @Before + @BeforeEach public void beforeTest() { this.productData = new ProductData("pdfProduct", "pdfProduct", "7.0.0", 1900, 2000); this.productData2 = new ProductData("pdfProduct2", "pdfProduct2", "7.0.0", 1900, 2000); @@ -48,16 +47,23 @@ public void beforeTest() { @Test public void normalAddTest() { FingerPrint fingerPrint = new FingerPrint(); - Assert.assertTrue(fingerPrint.registerProduct(productData)); - Assert.assertTrue(fingerPrint.registerProduct(productData2)); - Assert.assertEquals(2, fingerPrint.getProducts().size()); + Assertions.assertTrue(fingerPrint.registerProduct(productData)); + Assertions.assertTrue(fingerPrint.registerProduct(productData2)); + Assertions.assertEquals(2, fingerPrint.getProducts().size()); } @Test public void duplicateTest() { FingerPrint fingerPrint = new FingerPrint(); fingerPrint.registerProduct(productData); - Assert.assertFalse(fingerPrint.registerProduct(duplicateProductData)); + Assertions.assertFalse(fingerPrint.registerProduct(duplicateProductData)); + } + + @Test + public void disableFingerPrintTest() { + FingerPrint fingerPrint = new FingerPrint(); + fingerPrint.disableFingerPrint(); + Assertions.assertFalse(fingerPrint.isFingerPrintEnabled()); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/FontToUnicodeTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/FontToUnicodeTest.java index fc59d55a71..f765bdb23e 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/FontToUnicodeTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/FontToUnicodeTest.java @@ -31,35 +31,34 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.canvas.parser.PdfTextExtractor; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; import java.util.Collections; import java.util.List; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class FontToUnicodeTest extends ExtendedITextTest { public static final String fontsFolder = "./src/test/resources/com/itextpdf/kernel/pdf/fonts/"; public static final String destinationFolder = "./target/test/com/itextpdf/kernel/pdf/FontToUnicodeTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(destinationFolder); } @Test // TODO DEVSIX-3634. In the output now we don't expect the \u2F46 unicode range. - // TODO DEVSIX-3634. SUBSTITUTE "Assert.assertEquals("\u2F46"..." to "Assert.assertEquals("\u65E0"..." after the fix + // TODO DEVSIX-3634. SUBSTITUTE "Assertions.assertEquals("\u2F46"..." to "Assertions.assertEquals("\u65E0"..." after the fix public void severalUnicodesWithinOneGlyphTest() throws IOException { String outFileName = destinationFolder + "severalUnicodesWithinOneGlyphTest.pdf"; @@ -85,6 +84,6 @@ public void severalUnicodesWithinOneGlyphTest() throws IOException { PdfDocument resultantPdfAsFile = new PdfDocument(CompareTool.createOutputReader(outFileName)); String actualUnicode = PdfTextExtractor.getTextFromPage(resultantPdfAsFile.getFirstPage()); - Assert.assertEquals("\u2F46", actualUnicode); + Assertions.assertEquals("\u2F46", actualUnicode); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/FreeReferencesTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/FreeReferencesTest.java index 10d8e990ce..0c079cc28a 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/FreeReferencesTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/FreeReferencesTest.java @@ -27,30 +27,29 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class FreeReferencesTest extends ExtendedITextTest { public static final String destinationFolder = "./target/test/com/itextpdf/kernel/pdf/FreeReferencesTest/"; public static final String sourceFolder = "./src/test/resources/com/itextpdf/kernel/pdf/FreeReferencesTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(destinationFolder); } @@ -174,12 +173,12 @@ public void freeReferencesTest04() throws IOException { PdfDocument pdfDocument = new PdfDocument(new PdfReader(sourceFolder + src), new PdfWriter(destinationFolder + out)); PdfObject contentsObj = pdfDocument.getPage(1).getPdfObject().remove(PdfName.Contents); - Assert.assertTrue(contentsObj instanceof PdfIndirectReference); + Assertions.assertTrue(contentsObj instanceof PdfIndirectReference); PdfIndirectReference contentsRef = (PdfIndirectReference) contentsObj; contentsRef.setFree(); PdfObject freedContentsRefRefersTo = contentsRef.getRefersTo(); - Assert.assertNull(freedContentsRefRefersTo); + Assertions.assertNull(freedContentsRefRefersTo); pdfDocument.close(); String[] xrefString = extractXrefTableAsStrings(out); @@ -289,12 +288,12 @@ public void freeReferencesTest08() throws IOException { new StampingProperties().useAppendMode()); PdfObject contentsObj = pdfDocument.getPage(1).getPdfObject().remove(PdfName.Contents); pdfDocument.getPage(1).setModified(); - Assert.assertTrue(contentsObj instanceof PdfIndirectReference); + Assertions.assertTrue(contentsObj instanceof PdfIndirectReference); PdfIndirectReference contentsRef = (PdfIndirectReference) contentsObj; contentsRef.setFree(); PdfObject freedContentsRefRefersTo = contentsRef.getRefersTo(); - Assert.assertNull(freedContentsRefRefersTo); + Assertions.assertNull(freedContentsRefRefersTo); pdfDocument.close(); String[] xrefString = extractXrefTableAsStrings(out); @@ -392,8 +391,8 @@ public void freeARefInWrongWayTest02() throws IOException { .makeIndirect(pdfDocument) .flush(); - Assert.assertTrue(a1.get(1, false) instanceof PdfIndirectReference); - Assert.assertTrue(((PdfIndirectReference)a1.get(1, false)).isFree()); + Assertions.assertTrue(a1.get(1, false) instanceof PdfIndirectReference); + Assertions.assertTrue(((PdfIndirectReference)a1.get(1, false)).isFree()); a1.flush(); pdfDocument.close(); @@ -440,7 +439,7 @@ public void freeARefInWrongWayTest03() throws IOException { a1.flush(); a2.getIndirectReference().setFree(); - Assert.assertFalse(a2.getIndirectReference().isFree()); + Assertions.assertFalse(a2.getIndirectReference().isFree()); List objects = Arrays.asList(new PdfObject[]{new PdfString("The answer to life is "), new PdfNumber(42)}); new PdfArray(objects) @@ -492,7 +491,7 @@ public void freeARefInWrongWayTest04() throws IOException { a2.flush(); a2.getIndirectReference().setFree(); - Assert.assertFalse(a2.getIndirectReference().isFree()); + Assertions.assertFalse(a2.getIndirectReference().isFree()); List objects = Arrays.asList(new PdfObject[]{new PdfString("The answer to life is "), new PdfNumber(42)}); new PdfArray(objects) @@ -873,7 +872,7 @@ public void corruptedDocIndRefToFree01() throws IOException { pdfDocument = new PdfDocument(CompareTool.createOutputReader(destinationFolder + out)); PdfObject contentsObj = pdfDocument.getPage(1).getPdfObject().get(PdfName.Contents); - Assert.assertEquals(PdfNull.PDF_NULL, contentsObj); + Assertions.assertEquals(PdfNull.PDF_NULL, contentsObj); pdfDocument.close(); String[] xrefString = extractXrefTableAsStrings(out); @@ -1486,7 +1485,7 @@ public void freeRefsReusingTest06() throws IOException { PdfDocument pdfDocument = new PdfDocument(new PdfReader(sourceFolder + src), new PdfWriter(destinationFolder + out)); PdfObject contentsObj = pdfDocument.getPage(1).getPdfObject().remove(PdfName.Contents); - Assert.assertTrue(contentsObj instanceof PdfIndirectReference); + Assertions.assertTrue(contentsObj instanceof PdfIndirectReference); PdfIndirectReference contentsRef = (PdfIndirectReference) contentsObj; contentsRef.setFree(); @@ -1524,8 +1523,8 @@ public void readingXrefWithLotsOfFreeObjTest() throws IOException { int actualNumberOfObj = doc.getNumberOfPdfObjects(); - Assert.assertEquals(68, actualNumberOfObj); - Assert.assertNull(doc.getPdfObject(7)); + Assertions.assertEquals(68, actualNumberOfObj); + Assertions.assertNull(doc.getPdfObject(7)); PdfXrefTable xref = doc.getXref(); @@ -1537,17 +1536,17 @@ public void readingXrefWithLotsOfFreeObjTest() throws IOException { } } - Assert.assertEquals(31, freeRefsCount); + Assertions.assertEquals(31, freeRefsCount); doc.close(); } private void compareXrefTables(String[] xrefString, String[] expected) { - Assert.assertEquals(expected.length, xrefString.length); + Assertions.assertEquals(expected.length, xrefString.length); for (int i = 0; i < xrefString.length; ++i) { if (!compareXrefSection(xrefString[i], expected[i])) { // XrefTables are different. Use Assert method in order to show differences gracefully. - Assert.assertArrayEquals(expected, xrefString); + Assertions.assertArrayEquals(expected, xrefString); } } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/ImageFormatsTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/ImageFormatsTest.java index a70e787568..54d7cf3ac9 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/ImageFormatsTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/ImageFormatsTest.java @@ -32,27 +32,26 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.canvas.PdfCanvas; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class ImageFormatsTest extends ExtendedITextTest { public static final String destinationFolder = "./target/test/com/itextpdf/kernel/pdf/ImageFormatsTest/"; public static final String sourceFolder = "./src/test/resources/com/itextpdf/kernel/pdf/ImageFormatsTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(destinationFolder); } @@ -133,7 +132,7 @@ public void imagesWithDifferentDepth() throws IOException, InterruptedException canvas.release(); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff_")); } @Test @@ -164,7 +163,7 @@ public void png_imageTransparency_8bitDepthImage() throws IOException, Interrupt canvas.release(); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff_")); } @Test @@ -207,6 +206,6 @@ public void png_imageTransparency_24bitDepthImage() throws IOException, Interrup canvas.release(); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff_")); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/InheritedPageEntriesTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/InheritedPageEntriesTest.java index 8dfa1d3d23..43fc7601d1 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/InheritedPageEntriesTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/InheritedPageEntriesTest.java @@ -28,26 +28,25 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.canvas.PdfCanvas; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class InheritedPageEntriesTest extends ExtendedITextTest { public static final String destinationFolder = "./target/test/com/itextpdf/kernel/pdf/InheritedPageEntriesTest/"; public static final String sourceFolder = "./src/test/resources/com/itextpdf/kernel/pdf/InheritedPageEntriesTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(destinationFolder); } @@ -73,7 +72,7 @@ public void addNewPageToDocumentWithInheritedPageRotationTest() throws Interrupt outFile.close(); - Assert.assertNull(new CompareTool().compareByContent(outputFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outputFileName, cmpFileName, destinationFolder)); } @Test @@ -89,7 +88,7 @@ public void setRotationToPageTest() throws InterruptedException, IOException { pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(outputFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outputFileName, cmpFileName, destinationFolder)); } @Test @@ -109,7 +108,7 @@ public void copySeveralPagesToDocumentWithInheritedPageRotationTest() throws Int pdfDoc2.close(); - Assert.assertNull(new CompareTool().compareByContent(outputFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outputFileName, cmpFileName, destinationFolder)); } @Test @@ -120,7 +119,7 @@ public void mediaBoxInheritance() throws IOException { PdfObject mediaBox = outFile.getPage(1).getPdfObject().get(PdfName.MediaBox); //Check if MediaBox in Page is absent - Assert.assertNull(mediaBox); + Assertions.assertNull(mediaBox); PdfArray array = outFile.getCatalog().getPdfObject().getAsDictionary(PdfName.Pages).getAsArray(PdfName.MediaBox); Rectangle rectangle = array.toRectangle(); @@ -129,7 +128,7 @@ public void mediaBoxInheritance() throws IOException { outFile.close(); - Assert.assertTrue(rectangle.equalsWithEpsilon(pageRect)); + Assertions.assertTrue(rectangle.equalsWithEpsilon(pageRect)); } @Test @@ -140,7 +139,7 @@ public void cropBoxInheritance() throws IOException { PdfObject cropBox = outFile.getPage(1).getPdfObject().get(PdfName.CropBox); //Check if CropBox in Page is absent - Assert.assertNull(cropBox); + Assertions.assertNull(cropBox); PdfArray array = outFile.getCatalog().getPdfObject().getAsDictionary(PdfName.Pages).getAsArray(PdfName.CropBox); Rectangle rectangle = array.toRectangle(); @@ -149,6 +148,6 @@ public void cropBoxInheritance() throws IOException { outFile.close(); - Assert.assertTrue(rectangle.equalsWithEpsilon(pageRect)); + Assertions.assertTrue(rectangle.equalsWithEpsilon(pageRect)); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/MemoryLimitsAwareHandlerTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/MemoryLimitsAwareHandlerTest.java index 8a3c97e31c..20de8a43a8 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/MemoryLimitsAwareHandlerTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/MemoryLimitsAwareHandlerTest.java @@ -25,32 +25,37 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.exceptions.KernelExceptionMessageConstant; import com.itextpdf.kernel.exceptions.MemoryLimitsAwareException; +import com.itextpdf.kernel.logs.KernelLogMessageConstant; import com.itextpdf.test.AssertUtil; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import com.itextpdf.test.annotations.LogMessage; +import com.itextpdf.test.annotations.LogMessages; -@Category(UnitTest.class) +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@Tag("UnitTest") public class MemoryLimitsAwareHandlerTest extends ExtendedITextTest { @Test public void defaultMemoryHandler() { MemoryLimitsAwareHandler handler = new MemoryLimitsAwareHandler(); - Assert.assertEquals(Integer.MAX_VALUE / 100, handler.getMaxSizeOfSingleDecompressedPdfStream()); - Assert.assertEquals(Integer.MAX_VALUE / 20, handler.getMaxSizeOfDecompressedPdfStreamsSum()); - Assert.assertEquals(50000000, handler.getMaxNumberOfElementsInXrefStructure()); - Assert.assertEquals(1024L*1024L*1024L*3L, handler.getMaxXObjectsSizePerPage()); + Assertions.assertEquals(Integer.MAX_VALUE / 100, handler.getMaxSizeOfSingleDecompressedPdfStream()); + Assertions.assertEquals(Integer.MAX_VALUE / 20, handler.getMaxSizeOfDecompressedPdfStreamsSum()); + Assertions.assertEquals(50000000, handler.getMaxNumberOfElementsInXrefStructure()); + Assertions.assertEquals(1024L*1024L*1024L*3L, handler.getMaxXObjectsSizePerPage()); } @Test public void customMemoryHandler() { MemoryLimitsAwareHandler handler = new MemoryLimitsAwareHandler(1000000); - Assert.assertEquals(100000000, handler.getMaxSizeOfSingleDecompressedPdfStream()); - Assert.assertEquals(500000000, handler.getMaxSizeOfDecompressedPdfStreamsSum()); + Assertions.assertEquals(100000000, handler.getMaxSizeOfSingleDecompressedPdfStream()); + Assertions.assertEquals(500000000, handler.getMaxSizeOfDecompressedPdfStreamsSum()); } @Test @@ -66,9 +71,8 @@ public boolean isMemoryLimitsAwarenessRequiredOnDecompression(PdfArray filters) PdfArray filters = new PdfArray(); filters.add(PdfName.FlateDecode); - Assert.assertFalse(defaultHandler.isMemoryLimitsAwarenessRequiredOnDecompression(filters)); - Assert.assertTrue(customHandler.isMemoryLimitsAwarenessRequiredOnDecompression(filters)); - + Assertions.assertFalse(defaultHandler.isMemoryLimitsAwarenessRequiredOnDecompression(filters)); + Assertions.assertTrue(customHandler.isMemoryLimitsAwarenessRequiredOnDecompression(filters)); } @Test @@ -94,52 +98,52 @@ public void considerBytesTest() { handler.considerBytesOccupiedByDecompressedPdfStream(100); long state2 = handler.getAllMemoryUsedForDecompression(); - Assert.assertEquals(state1, state2); + Assertions.assertEquals(state1, state2); handler.beginDecompressedPdfStreamProcessing(); handler.considerBytesOccupiedByDecompressedPdfStream(100); long state3 = handler.getAllMemoryUsedForDecompression(); - Assert.assertEquals(state1, state3); + Assertions.assertEquals(state1, state3); handler.considerBytesOccupiedByDecompressedPdfStream(80); long state4 = handler.getAllMemoryUsedForDecompression(); - Assert.assertEquals(state1, state4); + Assertions.assertEquals(state1, state4); handler.endDecompressedPdfStreamProcessing(); long state5 = handler.getAllMemoryUsedForDecompression(); - Assert.assertEquals(state1 + 100, state5); + Assertions.assertEquals(state1 + 100, state5); } @Test public void customXrefCapacityHandlerTest() { final MemoryLimitsAwareHandler memoryLimitsAwareHandler = new MemoryLimitsAwareHandler(); - Assert.assertEquals(50000000, memoryLimitsAwareHandler.getMaxNumberOfElementsInXrefStructure()); + Assertions.assertEquals(50000000, memoryLimitsAwareHandler.getMaxNumberOfElementsInXrefStructure()); memoryLimitsAwareHandler.setMaxNumberOfElementsInXrefStructure(20); - Assert.assertEquals(20, memoryLimitsAwareHandler.getMaxNumberOfElementsInXrefStructure()); + Assertions.assertEquals(20, memoryLimitsAwareHandler.getMaxNumberOfElementsInXrefStructure()); } @Test public void customMaxXObjectSizePerPageHandlerTest() { final MemoryLimitsAwareHandler memoryLimitsAwareHandler = new MemoryLimitsAwareHandler(); - Assert.assertEquals(1024L*1024L*1024L*3L, memoryLimitsAwareHandler.getMaxXObjectsSizePerPage()); + Assertions.assertEquals(1024L*1024L*1024L*3L, memoryLimitsAwareHandler.getMaxXObjectsSizePerPage()); memoryLimitsAwareHandler.setMaxXObjectsSizePerPage(1024L); - Assert.assertEquals(1024L, memoryLimitsAwareHandler.getMaxXObjectsSizePerPage()); + Assertions.assertEquals(1024L, memoryLimitsAwareHandler.getMaxXObjectsSizePerPage()); } @Test public void minSizeBasedXrefCapacityHandlerTest() { final MemoryLimitsAwareHandler memoryLimitsAwareHandler = new MemoryLimitsAwareHandler(1024*1024); - Assert.assertEquals(500000, memoryLimitsAwareHandler.getMaxNumberOfElementsInXrefStructure()); + Assertions.assertEquals(500000, memoryLimitsAwareHandler.getMaxNumberOfElementsInXrefStructure()); } @Test public void sizeBasedXrefCapacityHandlerTest() { final MemoryLimitsAwareHandler memoryLimitsAwareHandler = new MemoryLimitsAwareHandler(1024*1024*80); - Assert.assertEquals(40000000, memoryLimitsAwareHandler.getMaxNumberOfElementsInXrefStructure()); + Assertions.assertEquals(40000000, memoryLimitsAwareHandler.getMaxNumberOfElementsInXrefStructure()); } @Test @@ -149,9 +153,9 @@ public void checkCapacityExceedsLimitTest() { // before check. final int capacityExceededTheLimit = memoryLimitsAwareHandler.getMaxNumberOfElementsInXrefStructure() + 2; - Exception ex = Assert.assertThrows(MemoryLimitsAwareException.class, + Exception ex = Assertions.assertThrows(MemoryLimitsAwareException.class, () -> memoryLimitsAwareHandler.checkIfXrefStructureExceedsTheLimit(capacityExceededTheLimit)); - Assert.assertEquals(KernelExceptionMessageConstant.XREF_STRUCTURE_SIZE_EXCEEDED_THE_LIMIT, ex.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.XREF_STRUCTURE_SIZE_EXCEEDED_THE_LIMIT, ex.getMessage()); } @Test @@ -162,6 +166,53 @@ public void checkCapacityTest() { AssertUtil.doesNotThrow(() -> memoryLimitsAwareHandler.checkIfXrefStructureExceedsTheLimit(capacityToSet)); } + @Test + @LogMessages(messages = {@LogMessage(messageTemplate = + KernelLogMessageConstant.MEMORYLIMITAWAREHANDLER_OVERRIDE_CREATENEWINSTANCE_METHOD)}) + public void createCopyMemoryHandlerWarningTest() { + MemoryLimitsAwareHandler customHandler = new MemoryLimitsAwareHandler() {}; + + customHandler.setMaxNumberOfElementsInXrefStructure(1); + customHandler.setMaxXObjectsSizePerPage(2); + customHandler.setMaxSizeOfDecompressedPdfStreamsSum(3); + customHandler.setMaxSizeOfSingleDecompressedPdfStream(4); + + MemoryLimitsAwareHandler copy = customHandler.createNewInstance(); + + Assertions.assertEquals(1, copy.getMaxNumberOfElementsInXrefStructure()); + Assertions.assertEquals(2, copy.getMaxXObjectsSizePerPage()); + Assertions.assertEquals(3, copy.getMaxSizeOfDecompressedPdfStreamsSum()); + Assertions.assertEquals(4, copy.getMaxSizeOfSingleDecompressedPdfStream()); + } + + @Test + public void createCopyMemoryHandlerNoWarningTest() { + MemoryLimitsAwareHandler customHandler = new MemoryLimitsAwareHandler() { + @Override + public MemoryLimitsAwareHandler createNewInstance() { + MemoryLimitsAwareHandler to = new MemoryLimitsAwareHandler(); + to.setMaxSizeOfSingleDecompressedPdfStream(this.getMaxSizeOfSingleDecompressedPdfStream()); + to.setMaxSizeOfDecompressedPdfStreamsSum(this.getMaxSizeOfDecompressedPdfStreamsSum()); + to.setMaxNumberOfElementsInXrefStructure(this.getMaxNumberOfElementsInXrefStructure()); + to.setMaxXObjectsSizePerPage(this.getMaxXObjectsSizePerPage()); + + return to; + } + }; + + customHandler.setMaxNumberOfElementsInXrefStructure(1); + customHandler.setMaxXObjectsSizePerPage(2); + customHandler.setMaxSizeOfDecompressedPdfStreamsSum(3); + customHandler.setMaxSizeOfSingleDecompressedPdfStream(4); + + MemoryLimitsAwareHandler copy = customHandler.createNewInstance(); + + Assertions.assertEquals(1, copy.getMaxNumberOfElementsInXrefStructure()); + Assertions.assertEquals(2, copy.getMaxXObjectsSizePerPage()); + Assertions.assertEquals(3, copy.getMaxSizeOfDecompressedPdfStreamsSum()); + Assertions.assertEquals(4, copy.getMaxSizeOfSingleDecompressedPdfStream()); + } + private static void testSingleStream(MemoryLimitsAwareHandler handler) { String expectedExceptionMessage = KernelExceptionMessageConstant.DURING_DECOMPRESSION_SINGLE_STREAM_OCCUPIED_MORE_MEMORY_THAN_ALLOWED; int expectedFailureIndex = 10; @@ -181,8 +232,8 @@ private static void testSingleStream(MemoryLimitsAwareHandler handler) { } catch (MemoryLimitsAwareException e) { occuredExceptionMessage = e.getMessage(); } - Assert.assertEquals(expectedFailureIndex, i); - Assert.assertEquals(expectedExceptionMessage, occuredExceptionMessage); + Assertions.assertEquals(expectedFailureIndex, i); + Assertions.assertEquals(expectedExceptionMessage, occuredExceptionMessage); } private static void testMultipleStreams(MemoryLimitsAwareHandler handler) { @@ -203,8 +254,8 @@ private static void testMultipleStreams(MemoryLimitsAwareHandler handler) { } catch (MemoryLimitsAwareException e) { occuredExceptionMessage = e.getMessage(); } - Assert.assertEquals(expectedFailureIndex, i); - Assert.assertEquals(expectedExceptionMessage, occuredExceptionMessage); + Assertions.assertEquals(expectedFailureIndex, i); + Assertions.assertEquals(expectedExceptionMessage, occuredExceptionMessage); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/MemoryLimitsAwareOutputStreamTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/MemoryLimitsAwareOutputStreamTest.java index 2a3d7646c0..f23526af87 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/MemoryLimitsAwareOutputStreamTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/MemoryLimitsAwareOutputStreamTest.java @@ -24,12 +24,11 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.exceptions.MemoryLimitsAwareException; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class MemoryLimitsAwareOutputStreamTest extends ExtendedITextTest { @Test @@ -40,12 +39,12 @@ public void testMaxSize() { MemoryLimitsAwareOutputStream stream = new MemoryLimitsAwareOutputStream(); stream.setMaxStreamSize(100); - Assert.assertEquals(100, stream.getMaxStreamSize()); + Assertions.assertEquals(100, stream.getMaxStreamSize()); stream.write(bigArray, 0, bigArray.length); - Assert.assertEquals(bigArray.length, stream.size()); - Assert.assertThrows(MemoryLimitsAwareException.class, () -> stream.write(smallArray, 0, smallArray.length)); + Assertions.assertEquals(bigArray.length, stream.size()); + Assertions.assertThrows(MemoryLimitsAwareException.class, () -> stream.write(smallArray, 0, smallArray.length)); } @Test @@ -56,14 +55,14 @@ public void testNegativeSize() { stream.setMaxStreamSize(-100); - Assert.assertEquals(-100, stream.getMaxStreamSize()); - Assert.assertThrows(MemoryLimitsAwareException.class, () -> stream.write(zeroArray, 0, zeroArray.length)); + Assertions.assertEquals(-100, stream.getMaxStreamSize()); + Assertions.assertThrows(MemoryLimitsAwareException.class, () -> stream.write(zeroArray, 0, zeroArray.length)); } @Test public void testIncorrectLength() { MemoryLimitsAwareOutputStream stream = new MemoryLimitsAwareOutputStream(); - Assert.assertThrows(IndexOutOfBoundsException.class, () -> stream.write(new byte[1],0, -1)); + Assertions.assertThrows(IndexOutOfBoundsException.class, () -> stream.write(new byte[1],0, -1)); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/OcgPropertiesCopierTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/OcgPropertiesCopierTest.java index 9b9fb7c7c4..1494ce10a0 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/OcgPropertiesCopierTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/OcgPropertiesCopierTest.java @@ -39,7 +39,6 @@ This file is part of the iText (R) project. import com.itextpdf.test.LogLevelConstants; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.ByteArrayInputStream; import java.io.IOException; @@ -49,11 +48,11 @@ This file is part of the iText (R) project. import java.util.List; import java.util.Set; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class OcgPropertiesCopierTest extends ExtendedITextTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/kernel/pdf/OcgPropertiesCopierTest/"; @@ -195,7 +194,7 @@ public void copyOcgWithEmptyOCGsInOCPropertiesTest() throws IOException { try (PdfDocument fromDocument = new PdfDocument(new PdfReader(new ByteArrayInputStream(fromDocBytes)))) { // This test verifies that if the PDF is invalid, i.e. if OCProperties.OCGs is empty in the document, // but there are OCGs that are used on the page, then OCGs will be copied - Assert.assertTrue(fromDocument.getCatalog().getPdfObject().getAsDictionary(PdfName.OCProperties).getAsArray(PdfName.OCGs).isEmpty()); + Assertions.assertTrue(fromDocument.getCatalog().getPdfObject().getAsDictionary(PdfName.OCProperties).getAsArray(PdfName.OCGs).isEmpty()); fromDocument.copyPagesTo(1, 1, toDocument); @@ -238,7 +237,7 @@ public void notCopyConfigsTest() throws IOException { PdfOCProperties ocProperties = toDocument.getCatalog().getOCProperties(false); // Check that the Configs field has not been copied - Assert.assertFalse(ocProperties.getPdfObject().containsKey(PdfName.Configs)); + Assertions.assertFalse(ocProperties.getPdfObject().containsKey(PdfName.Configs)); } } } @@ -367,15 +366,15 @@ public void copySameRBGroupFromDifferentPages() throws IOException { PdfArray rbGroups = dDict.getAsArray(PdfName.RBGroups); - Assert.assertEquals(2, rbGroups.size()); + Assertions.assertEquals(2, rbGroups.size()); - Assert.assertEquals(3, rbGroups.getAsArray(0).size()); - Assert.assertEquals("Radio1", rbGroups.getAsArray(0).getAsDictionary(0).getAsString(PdfName.Name).toUnicodeString()); - Assert.assertEquals("Radio2", rbGroups.getAsArray(0).getAsDictionary(1).getAsString(PdfName.Name).toUnicodeString()); - Assert.assertEquals("Radio3", rbGroups.getAsArray(0).getAsDictionary(2).getAsString(PdfName.Name).toUnicodeString()); + Assertions.assertEquals(3, rbGroups.getAsArray(0).size()); + Assertions.assertEquals("Radio1", rbGroups.getAsArray(0).getAsDictionary(0).getAsString(PdfName.Name).toUnicodeString()); + Assertions.assertEquals("Radio2", rbGroups.getAsArray(0).getAsDictionary(1).getAsString(PdfName.Name).toUnicodeString()); + Assertions.assertEquals("Radio3", rbGroups.getAsArray(0).getAsDictionary(2).getAsString(PdfName.Name).toUnicodeString()); - Assert.assertEquals(1, rbGroups.getAsArray(1).size()); - Assert.assertEquals("Radio3", rbGroups.getAsArray(1).getAsDictionary(0).getAsString(PdfName.Name).toUnicodeString()); + Assertions.assertEquals(1, rbGroups.getAsArray(1).size()); + Assertions.assertEquals("Radio3", rbGroups.getAsArray(1).getAsDictionary(0).getAsString(PdfName.Name).toUnicodeString()); } @Test @@ -491,31 +490,31 @@ public void copySameOrderGroupFromDifferentPages() throws IOException { PdfArray order = dDict.getAsArray(PdfName.Order); - Assert.assertEquals(8, order.size()); + Assertions.assertEquals(8, order.size()); - Assert.assertEquals("parent1", order.getAsDictionary(0).getAsString(PdfName.Name).toUnicodeString()); + Assertions.assertEquals("parent1", order.getAsDictionary(0).getAsString(PdfName.Name).toUnicodeString()); - Assert.assertEquals(2, order.getAsArray(1).size()); - Assert.assertEquals("child1", order.getAsArray(1).getAsDictionary(0).getAsString(PdfName.Name).toUnicodeString()); - Assert.assertEquals("child2", order.getAsArray(1).getAsDictionary(1).getAsString(PdfName.Name).toUnicodeString()); + Assertions.assertEquals(2, order.getAsArray(1).size()); + Assertions.assertEquals("child1", order.getAsArray(1).getAsDictionary(0).getAsString(PdfName.Name).toUnicodeString()); + Assertions.assertEquals("child2", order.getAsArray(1).getAsDictionary(1).getAsString(PdfName.Name).toUnicodeString()); - Assert.assertEquals("parent2", order.getAsDictionary(2).getAsString(PdfName.Name).toUnicodeString()); + Assertions.assertEquals("parent2", order.getAsDictionary(2).getAsString(PdfName.Name).toUnicodeString()); - Assert.assertEquals("parent3", order.getAsDictionary(3).getAsString(PdfName.Name).toUnicodeString()); + Assertions.assertEquals("parent3", order.getAsDictionary(3).getAsString(PdfName.Name).toUnicodeString()); - Assert.assertEquals(1, order.getAsArray(4).size()); - Assert.assertEquals("child5", order.getAsArray(4).getAsDictionary(0).getAsString(PdfName.Name).toUnicodeString()); + Assertions.assertEquals(1, order.getAsArray(4).size()); + Assertions.assertEquals("child5", order.getAsArray(4).getAsDictionary(0).getAsString(PdfName.Name).toUnicodeString()); - Assert.assertEquals(2, order.getAsArray(5).size()); - Assert.assertEquals("parent4", order.getAsArray(5).getAsString(0).toUnicodeString()); - Assert.assertEquals("child6", order.getAsArray(5).getAsDictionary(1).getAsString(PdfName.Name).toUnicodeString()); + Assertions.assertEquals(2, order.getAsArray(5).size()); + Assertions.assertEquals("parent4", order.getAsArray(5).getAsString(0).toUnicodeString()); + Assertions.assertEquals("child6", order.getAsArray(5).getAsDictionary(1).getAsString(PdfName.Name).toUnicodeString()); - Assert.assertEquals("grandpa1", order.getAsDictionary(6).getAsString(PdfName.Name).toUnicodeString()); + Assertions.assertEquals("grandpa1", order.getAsDictionary(6).getAsString(PdfName.Name).toUnicodeString()); - Assert.assertEquals(2, order.getAsArray(7).size()); - Assert.assertEquals("parent6", order.getAsArray(7).getAsDictionary(0).getAsString(PdfName.Name).toUnicodeString()); - Assert.assertEquals(1, order.getAsArray(7).getAsArray(1).size()); - Assert.assertEquals("child8", order.getAsArray(7).getAsArray(1).getAsDictionary(0).getAsString(PdfName.Name).toUnicodeString()); + Assertions.assertEquals(2, order.getAsArray(7).size()); + Assertions.assertEquals("parent6", order.getAsArray(7).getAsDictionary(0).getAsString(PdfName.Name).toUnicodeString()); + Assertions.assertEquals(1, order.getAsArray(7).getAsArray(1).size()); + Assertions.assertEquals("child8", order.getAsArray(7).getAsArray(1).getAsDictionary(0).getAsString(PdfName.Name).toUnicodeString()); } @Test @@ -581,24 +580,24 @@ public void copyOrderToEmptyDocumentTest() throws IOException { namesOrTitles.add("Parent2"); namesOrTitles.add("Child5"); PdfArray order = OcgPropertiesCopierTest.copyPagesAndAssertLayersNameAndGetDDict(namesOrTitles, fromDocBytes, null).getAsArray(PdfName.Order); - Assert.assertEquals(4, order.size()); - Assert.assertEquals("Layer1", order.getAsDictionary(0).getAsString(PdfName.Name).toUnicodeString()); + Assertions.assertEquals(4, order.size()); + Assertions.assertEquals("Layer1", order.getAsDictionary(0).getAsString(PdfName.Name).toUnicodeString()); PdfArray subArray = order.getAsArray(1); - Assert.assertEquals(3, subArray.size()); - Assert.assertEquals("Grandpa1", subArray.getAsString(0).toUnicodeString()); + Assertions.assertEquals(3, subArray.size()); + Assertions.assertEquals("Grandpa1", subArray.getAsString(0).toUnicodeString()); - Assert.assertEquals(2, subArray.getAsArray(1).size()); - Assert.assertEquals("Parent1", subArray.getAsArray(1).getAsString(0).toUnicodeString()); - Assert.assertEquals("Child2", subArray.getAsArray(1).getAsDictionary(1).getAsString(PdfName.Name).toUnicodeString()); + Assertions.assertEquals(2, subArray.getAsArray(1).size()); + Assertions.assertEquals("Parent1", subArray.getAsArray(1).getAsString(0).toUnicodeString()); + Assertions.assertEquals("Child2", subArray.getAsArray(1).getAsDictionary(1).getAsString(PdfName.Name).toUnicodeString()); - Assert.assertEquals("Child4", subArray.getAsDictionary(2).getAsString(PdfName.Name).toUnicodeString()); + Assertions.assertEquals("Child4", subArray.getAsDictionary(2).getAsString(PdfName.Name).toUnicodeString()); - Assert.assertEquals("Parent2", order.getAsDictionary(2).getAsString(PdfName.Name).toUnicodeString()); + Assertions.assertEquals("Parent2", order.getAsDictionary(2).getAsString(PdfName.Name).toUnicodeString()); - Assert.assertEquals(1, order.getAsArray(3).size()); - Assert.assertEquals("Child5", order.getAsArray(3).getAsDictionary(0).getAsString(PdfName.Name).toUnicodeString()); + Assertions.assertEquals(1, order.getAsArray(3).size()); + Assertions.assertEquals("Child5", order.getAsArray(3).getAsDictionary(0).getAsString(PdfName.Name).toUnicodeString()); } @Test @@ -619,38 +618,38 @@ public void copyDFieldsToEmptyDocumentTest() throws IOException { PdfDictionary dDict = OcgPropertiesCopierTest.copyPagesAndAssertLayersNameAndGetDDict(namesOrTitles, fromDocBytes, null); PdfArray locked = dDict.getAsArray(PdfName.Locked); - Assert.assertEquals(1, locked.size()); - Assert.assertEquals("Locked1", locked.getAsDictionary(0).getAsString(PdfName.Name).toUnicodeString()); + Assertions.assertEquals(1, locked.size()); + Assertions.assertEquals("Locked1", locked.getAsDictionary(0).getAsString(PdfName.Name).toUnicodeString()); PdfArray rbGroups = dDict.getAsArray(PdfName.RBGroups); - Assert.assertEquals(2, rbGroups.size()); - Assert.assertEquals(2, rbGroups.getAsArray(0).size()); - Assert.assertEquals("Radio1", rbGroups.getAsArray(0).getAsDictionary(0).getAsString(PdfName.Name).toUnicodeString()); - Assert.assertEquals("Radio3", rbGroups.getAsArray(0).getAsDictionary(1).getAsString(PdfName.Name).toUnicodeString()); - Assert.assertEquals(1, rbGroups.getAsArray(1).size()); - Assert.assertEquals("Radio4", rbGroups.getAsArray(1).getAsDictionary(0).getAsString(PdfName.Name).toUnicodeString()); + Assertions.assertEquals(2, rbGroups.size()); + Assertions.assertEquals(2, rbGroups.getAsArray(0).size()); + Assertions.assertEquals("Radio1", rbGroups.getAsArray(0).getAsDictionary(0).getAsString(PdfName.Name).toUnicodeString()); + Assertions.assertEquals("Radio3", rbGroups.getAsArray(0).getAsDictionary(1).getAsString(PdfName.Name).toUnicodeString()); + Assertions.assertEquals(1, rbGroups.getAsArray(1).size()); + Assertions.assertEquals("Radio4", rbGroups.getAsArray(1).getAsDictionary(0).getAsString(PdfName.Name).toUnicodeString()); - Assert.assertNull(dDict.getAsArray(PdfName.ON)); + Assertions.assertNull(dDict.getAsArray(PdfName.ON)); PdfArray off = dDict.getAsArray(PdfName.OFF); - Assert.assertEquals(1, off.size()); - Assert.assertEquals("Off1", off.getAsDictionary(0).getAsString(PdfName.Name).toUnicodeString()); + Assertions.assertEquals(1, off.size()); + Assertions.assertEquals("Off1", off.getAsDictionary(0).getAsString(PdfName.Name).toUnicodeString()); - Assert.assertNull(dDict.getAsArray(PdfName.Creator)); + Assertions.assertNull(dDict.getAsArray(PdfName.Creator)); - Assert.assertEquals("Name", dDict.getAsString(PdfName.Name).toUnicodeString()); + Assertions.assertEquals("Name", dDict.getAsString(PdfName.Name).toUnicodeString()); - Assert.assertEquals(PdfName.ON, dDict.getAsName(PdfName.BaseState)); + Assertions.assertEquals(PdfName.ON, dDict.getAsName(PdfName.BaseState)); PdfArray asArray = dDict.getAsArray(PdfName.AS); - Assert.assertEquals(1, asArray.size()); - Assert.assertEquals(1, asArray.getAsDictionary(0).getAsArray(PdfName.Category).size()); - Assert.assertEquals(PdfName.Print, asArray.getAsDictionary(0).getAsArray(PdfName.Category).getAsName(0)); - Assert.assertEquals("noPrint1", asArray.getAsDictionary(0).getAsArray(PdfName.OCGs).getAsDictionary(0).getAsString(PdfName.Name).toUnicodeString()); + Assertions.assertEquals(1, asArray.size()); + Assertions.assertEquals(1, asArray.getAsDictionary(0).getAsArray(PdfName.Category).size()); + Assertions.assertEquals(PdfName.Print, asArray.getAsDictionary(0).getAsArray(PdfName.Category).getAsName(0)); + Assertions.assertEquals("noPrint1", asArray.getAsDictionary(0).getAsArray(PdfName.OCGs).getAsDictionary(0).getAsString(PdfName.Name).toUnicodeString()); - Assert.assertEquals(PdfName.View, dDict.getAsName(PdfName.Intent)); + Assertions.assertEquals(PdfName.View, dDict.getAsName(PdfName.Intent)); - Assert.assertEquals(PdfName.VisiblePages, dDict.getAsName(PdfName.ListMode)); + Assertions.assertEquals(PdfName.VisiblePages, dDict.getAsName(PdfName.ListMode)); } @Test @@ -738,47 +737,47 @@ public void copyDFieldsToDocumentWithDDictTest() throws IOException { PdfDictionary dDict = OcgPropertiesCopierTest.copyPagesAndAssertLayersNameAndGetDDict(namesOrTitles, fromDocBytes, toDocBytes); PdfArray locked = dDict.getAsArray(PdfName.Locked); - Assert.assertEquals(3, locked.size()); - Assert.assertEquals("Locked1", locked.getAsDictionary(0).getAsString(PdfName.Name).toUnicodeString()); - Assert.assertEquals("Locked2", locked.getAsDictionary(1).getAsString(PdfName.Name).toUnicodeString()); - Assert.assertEquals("from_Locked1", locked.getAsDictionary(2).getAsString(PdfName.Name).toUnicodeString()); + Assertions.assertEquals(3, locked.size()); + Assertions.assertEquals("Locked1", locked.getAsDictionary(0).getAsString(PdfName.Name).toUnicodeString()); + Assertions.assertEquals("Locked2", locked.getAsDictionary(1).getAsString(PdfName.Name).toUnicodeString()); + Assertions.assertEquals("from_Locked1", locked.getAsDictionary(2).getAsString(PdfName.Name).toUnicodeString()); PdfArray rbGroups = dDict.getAsArray(PdfName.RBGroups); - Assert.assertEquals(3, rbGroups.size()); - Assert.assertEquals(3, rbGroups.getAsArray(0).size()); - Assert.assertEquals("Radio1", rbGroups.getAsArray(0).getAsDictionary(0).getAsString(PdfName.Name).toUnicodeString()); - Assert.assertEquals("Radio2", rbGroups.getAsArray(0).getAsDictionary(1).getAsString(PdfName.Name).toUnicodeString()); - Assert.assertEquals("Radio3", rbGroups.getAsArray(0).getAsDictionary(2).getAsString(PdfName.Name).toUnicodeString()); - Assert.assertEquals(1, rbGroups.getAsArray(1).size()); - Assert.assertEquals("Radio4", rbGroups.getAsArray(1).getAsDictionary(0).getAsString(PdfName.Name).toUnicodeString()); - Assert.assertEquals(1, rbGroups.getAsArray(2).size()); - Assert.assertEquals("from_Radio1", rbGroups.getAsArray(2).getAsDictionary(0).getAsString(PdfName.Name).toUnicodeString()); - - Assert.assertNull(dDict.getAsArray(PdfName.ON)); + Assertions.assertEquals(3, rbGroups.size()); + Assertions.assertEquals(3, rbGroups.getAsArray(0).size()); + Assertions.assertEquals("Radio1", rbGroups.getAsArray(0).getAsDictionary(0).getAsString(PdfName.Name).toUnicodeString()); + Assertions.assertEquals("Radio2", rbGroups.getAsArray(0).getAsDictionary(1).getAsString(PdfName.Name).toUnicodeString()); + Assertions.assertEquals("Radio3", rbGroups.getAsArray(0).getAsDictionary(2).getAsString(PdfName.Name).toUnicodeString()); + Assertions.assertEquals(1, rbGroups.getAsArray(1).size()); + Assertions.assertEquals("Radio4", rbGroups.getAsArray(1).getAsDictionary(0).getAsString(PdfName.Name).toUnicodeString()); + Assertions.assertEquals(1, rbGroups.getAsArray(2).size()); + Assertions.assertEquals("from_Radio1", rbGroups.getAsArray(2).getAsDictionary(0).getAsString(PdfName.Name).toUnicodeString()); + + Assertions.assertNull(dDict.getAsArray(PdfName.ON)); PdfArray off = dDict.getAsArray(PdfName.OFF); - Assert.assertEquals(3, off.size()); - Assert.assertEquals("Off1", off.getAsDictionary(0).getAsString(PdfName.Name).toUnicodeString()); - Assert.assertEquals("Off2", off.getAsDictionary(1).getAsString(PdfName.Name).toUnicodeString()); - Assert.assertEquals("from_Off1", off.getAsDictionary(2).getAsString(PdfName.Name).toUnicodeString()); + Assertions.assertEquals(3, off.size()); + Assertions.assertEquals("Off1", off.getAsDictionary(0).getAsString(PdfName.Name).toUnicodeString()); + Assertions.assertEquals("Off2", off.getAsDictionary(1).getAsString(PdfName.Name).toUnicodeString()); + Assertions.assertEquals("from_Off1", off.getAsDictionary(2).getAsString(PdfName.Name).toUnicodeString()); - Assert.assertNull(dDict.getAsArray(PdfName.Creator)); + Assertions.assertNull(dDict.getAsArray(PdfName.Creator)); - Assert.assertEquals("Name", dDict.getAsString(PdfName.Name).toUnicodeString()); + Assertions.assertEquals("Name", dDict.getAsString(PdfName.Name).toUnicodeString()); - Assert.assertEquals(PdfName.ON, dDict.getAsName(PdfName.BaseState)); + Assertions.assertEquals(PdfName.ON, dDict.getAsName(PdfName.BaseState)); PdfArray asArray = dDict.getAsArray(PdfName.AS); - Assert.assertEquals(1, asArray.size()); - Assert.assertEquals(1, asArray.getAsDictionary(0).getAsArray(PdfName.Category).size()); - Assert.assertEquals(PdfName.Print, asArray.getAsDictionary(0).getAsArray(PdfName.Category).getAsName(0)); - Assert.assertEquals(2, asArray.getAsDictionary(0).getAsArray(PdfName.OCGs).size()); - Assert.assertEquals("noPrint1", asArray.getAsDictionary(0).getAsArray(PdfName.OCGs).getAsDictionary(0).getAsString(PdfName.Name).toUnicodeString()); - Assert.assertEquals("from_noPrint1", asArray.getAsDictionary(0).getAsArray(PdfName.OCGs).getAsDictionary(1).getAsString(PdfName.Name).toUnicodeString()); + Assertions.assertEquals(1, asArray.size()); + Assertions.assertEquals(1, asArray.getAsDictionary(0).getAsArray(PdfName.Category).size()); + Assertions.assertEquals(PdfName.Print, asArray.getAsDictionary(0).getAsArray(PdfName.Category).getAsName(0)); + Assertions.assertEquals(2, asArray.getAsDictionary(0).getAsArray(PdfName.OCGs).size()); + Assertions.assertEquals("noPrint1", asArray.getAsDictionary(0).getAsArray(PdfName.OCGs).getAsDictionary(0).getAsString(PdfName.Name).toUnicodeString()); + Assertions.assertEquals("from_noPrint1", asArray.getAsDictionary(0).getAsArray(PdfName.OCGs).getAsDictionary(1).getAsString(PdfName.Name).toUnicodeString()); - Assert.assertEquals(PdfName.View, dDict.getAsName(PdfName.Intent)); + Assertions.assertEquals(PdfName.View, dDict.getAsName(PdfName.Intent)); - Assert.assertEquals(PdfName.VisiblePages, dDict.getAsName(PdfName.ListMode)); + Assertions.assertEquals(PdfName.VisiblePages, dDict.getAsName(PdfName.ListMode)); } // Copy OCGs from different locations (OCMDs, annotations, content streams, xObjects) test block @@ -1083,7 +1082,7 @@ public void copyEmptyOcgTest() throws IOException { try (PdfDocument fromDocument = new PdfDocument(new PdfReader(new ByteArrayInputStream(fromDocBytes)))) { fromDocument.copyPagesTo(1, 1, toDocument); - Assert.assertNull(toDocument.getCatalog().getOCProperties(false)); + Assertions.assertNull(toDocument.getCatalog().getOCProperties(false)); } } } @@ -1224,37 +1223,37 @@ private static void copyPagesAndAssertLayersName(List names, byte[] from } private static void checkLayersOrTitleNameInToDocument(PdfDocument toDocument, Set namesOrTitles) { - Assert.assertNotNull(toDocument.getCatalog()); + Assertions.assertNotNull(toDocument.getCatalog()); PdfOCProperties ocProperties = toDocument.getCatalog().getOCProperties(false); ocProperties.fillDictionary(); - Assert.assertNotNull(ocProperties); - Assert.assertEquals(namesOrTitles.size(), ocProperties.getLayers().size()); + Assertions.assertNotNull(ocProperties); + Assertions.assertEquals(namesOrTitles.size(), ocProperties.getLayers().size()); for (PdfLayer layer : ocProperties.getLayers()) { - Assert.assertNotNull(layer); + Assertions.assertNotNull(layer); String layerTitle = layer.getTitle(); if (namesOrTitles.contains(layerTitle)) { - Assert.assertTrue(namesOrTitles.remove(layerTitle)); + Assertions.assertTrue(namesOrTitles.remove(layerTitle)); } else { PdfDictionary layerDictionary = layer.getPdfObject(); - Assert.assertNotNull(layerDictionary.get(PdfName.Name)); + Assertions.assertNotNull(layerDictionary.get(PdfName.Name)); String layerName = layerDictionary.get(PdfName.Name).toString(); - Assert.assertTrue(namesOrTitles.remove(layerName)); + Assertions.assertTrue(namesOrTitles.remove(layerName)); } } } private static void checkLayersNameInToDocument(PdfDocument toDocument, List names) { - Assert.assertNotNull(toDocument.getCatalog()); + Assertions.assertNotNull(toDocument.getCatalog()); PdfOCProperties ocProperties = toDocument.getCatalog().getOCProperties(false); - Assert.assertNotNull(ocProperties); - Assert.assertEquals(names.size(), ocProperties.getLayers().size()); + Assertions.assertNotNull(ocProperties); + Assertions.assertEquals(names.size(), ocProperties.getLayers().size()); for (PdfLayer layer : ocProperties.getLayers()) { - Assert.assertNotNull(layer); + Assertions.assertNotNull(layer); PdfDictionary layerDictionary = layer.getPdfObject(); - Assert.assertNotNull(layerDictionary.get(PdfName.Name)); + Assertions.assertNotNull(layerDictionary.get(PdfName.Name)); String layerNameString = layerDictionary.get(PdfName.Name).toString(); - Assert.assertTrue(names.contains(layerNameString)); + Assertions.assertTrue(names.contains(layerNameString)); names.remove(layerNameString); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/PageFlushingHelperUnitTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/PageFlushingHelperUnitTest.java index 1e338781c4..3f8ed72473 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/PageFlushingHelperUnitTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/PageFlushingHelperUnitTest.java @@ -24,16 +24,15 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.exceptions.KernelExceptionMessageConstant; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PageFlushingHelperUnitTest extends ExtendedITextTest { @Test @@ -45,9 +44,9 @@ public void flushingInUnsafeModeTest() throws IOException { pdfDocument.close(); pdfDocument = new PdfDocument(new PdfReader(new ByteArrayInputStream(outputStream.toByteArray()))); PageFlushingHelper pageFlushingHelper = new PageFlushingHelper(pdfDocument); - Exception exception = Assert.assertThrows(IllegalArgumentException.class, + Exception exception = Assertions.assertThrows(IllegalArgumentException.class, () -> pageFlushingHelper.unsafeFlushDeep(pageToFlush)); - Assert.assertEquals(KernelExceptionMessageConstant.FLUSHING_HELPER_FLUSHING_MODE_IS_NOT_FOR_DOC_READING_MODE, + Assertions.assertEquals(KernelExceptionMessageConstant.FLUSHING_HELPER_FLUSHING_MODE_IS_NOT_FOR_DOC_READING_MODE, exception.getMessage()); } @@ -60,9 +59,9 @@ public void flushingInAppendModeTest() throws IOException { pdfDocument.close(); pdfDocument = new PdfDocument(new PdfReader(new ByteArrayInputStream(outputStream.toByteArray()))); PageFlushingHelper pageFlushingHelper = new PageFlushingHelper(pdfDocument); - Exception exception = Assert.assertThrows(IllegalArgumentException.class, + Exception exception = Assertions.assertThrows(IllegalArgumentException.class, () -> pageFlushingHelper.appendModeFlush(pageToFlush)); - Assert.assertEquals(KernelExceptionMessageConstant.FLUSHING_HELPER_FLUSHING_MODE_IS_NOT_FOR_DOC_READING_MODE, + Assertions.assertEquals(KernelExceptionMessageConstant.FLUSHING_HELPER_FLUSHING_MODE_IS_NOT_FOR_DOC_READING_MODE, exception.getMessage()); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/PageFlushingTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/PageFlushingTest.java index e08d824130..57516a970f 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/PageFlushingTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/PageFlushingTest.java @@ -22,9 +22,9 @@ This file is part of the iText (R) project. */ package com.itextpdf.kernel.pdf; +import com.itextpdf.commons.utils.MessageFormatUtil; import com.itextpdf.io.font.constants.StandardFonts; import com.itextpdf.io.image.ImageDataFactory; -import com.itextpdf.commons.utils.MessageFormatUtil; import com.itextpdf.kernel.colors.ColorConstants; import com.itextpdf.kernel.font.PdfFont; import com.itextpdf.kernel.font.PdfFontFactory; @@ -39,30 +39,33 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.navigation.PdfExplicitDestination; import com.itextpdf.kernel.pdf.xobject.PdfImageXObject; import com.itextpdf.kernel.utils.CompareTool; +import com.itextpdf.kernel.validation.IValidationChecker; +import com.itextpdf.kernel.validation.IValidationContext; +import com.itextpdf.kernel.validation.ValidationContainer; +import com.itextpdf.kernel.validation.ValidationType; +import com.itextpdf.kernel.validation.context.PdfPageValidationContext; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.Map; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PageFlushingTest extends ExtendedITextTest { private static final String sourceFolder = "./src/test/resources/com/itextpdf/kernel/pdf/PageFlushingTest/"; private static final String destinationFolder = "./target/test/com/itextpdf/kernel/pdf/PageFlushingTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(destinationFolder); } @@ -306,11 +309,11 @@ public void modifyAnnotationOnlyAppendMode() throws IOException { flushingHelper.appendModeFlush(1); // annotation is flushed - Assert.assertTrue(annotObj.isFlushed()); + Assertions.assertTrue(annotObj.isFlushed()); // page is not flushed - Assert.assertFalse(pageIndRef.checkState(PdfObject.FLUSHED)); + Assertions.assertFalse(pageIndRef.checkState(PdfObject.FLUSHED)); // page is released - Assert.assertNull(pageIndRef.refersTo); + Assertions.assertNull(pageIndRef.refersTo); // exception is not thrown @@ -338,15 +341,15 @@ public void setLinkDestinationToPageAppendMode() throws IOException { flushingHelper.unsafeFlushDeep(1); // annotation is flushed - Assert.assertTrue(aDict.isFlushed()); + Assertions.assertTrue(aDict.isFlushed()); // page is not flushed - Assert.assertFalse(page1IndRef.checkState(PdfObject.FLUSHED)); + Assertions.assertFalse(page1IndRef.checkState(PdfObject.FLUSHED)); // page is released - Assert.assertNull(page1IndRef.refersTo); + Assertions.assertNull(page1IndRef.refersTo); // page is not flushed - Assert.assertFalse(page2IndRef.checkState(PdfObject.FLUSHED)); + Assertions.assertFalse(page2IndRef.checkState(PdfObject.FLUSHED)); // page is released - Assert.assertNull(page2IndRef.refersTo); + Assertions.assertNull(page2IndRef.refersTo); // exception is not thrown @@ -374,8 +377,8 @@ public void flushSelfContainingObjectsWritingMode() { PageFlushingHelper flushingHelper = new PageFlushingHelper(pdfDoc); flushingHelper.unsafeFlushDeep(1); - Assert.assertTrue(dict1.isFlushed()); - Assert.assertTrue(arr1.isFlushed()); + Assertions.assertTrue(dict1.isFlushed()); + Assertions.assertTrue(arr1.isFlushed()); pdfDoc.close(); @@ -419,14 +422,44 @@ public void flushingPageResourcesMadeIndependent() throws IOException { PdfDocument result = new PdfDocument(CompareTool.createOutputReader(outputFile)); PdfObject page15Res = result.getPage(15).getPdfObject().get(PdfName.Resources, false); PdfObject page34Res = result.getPage(34).getPdfObject().get(PdfName.Resources, false); - Assert.assertTrue(page15Res.isDictionary()); - Assert.assertEquals(numOfAddedXObjectsPerPage, ((PdfDictionary)page15Res).getAsDictionary(PdfName.XObject).size()); - Assert.assertTrue(page34Res.isDictionary()); - Assert.assertNotEquals(page15Res, page34Res); + Assertions.assertTrue(page15Res.isDictionary()); + Assertions.assertEquals(numOfAddedXObjectsPerPage, ((PdfDictionary)page15Res).getAsDictionary(PdfName.XObject).size()); + Assertions.assertTrue(page34Res.isDictionary()); + Assertions.assertNotEquals(page15Res, page34Res); result.close(); } + @Test + public void pageValidationTest() { + try (PdfDocument doc = new PdfDocument(new PdfWriter(new ByteArrayOutputStream()))) { + ValidationContainer container = new ValidationContainer(); + CustomValidationChecker checker = new CustomValidationChecker(); + container.addChecker(checker); + doc.getDiContainer().register(ValidationContainer.class, container); + Assertions.assertNull(checker.page); + final PdfPage pdfPage = doc.addNewPage(); + pdfPage.flush(true); + Assertions.assertSame(pdfPage, checker.page); + } + } + + private static class CustomValidationChecker implements IValidationChecker { + public PdfPage page; + + @Override + public void validate(IValidationContext validationContext) { + if (validationContext.getType() == ValidationType.PDF_PAGE) { + page = ((PdfPageValidationContext) validationContext).getPage(); + } + } + + @Override + public boolean isPdfObjectReadyToFlush(PdfObject object) { + return true; + } + } + private static void test(String filename, DocMode docMode, FlushMode flushMode, PagesOp pagesOp, int total, int flushedExpected, int notReadExpected) throws IOException { String input = sourceFolder + "100pages.pdf"; @@ -522,14 +555,14 @@ private static void verifyFlushedObjectsNum(PdfDocument pdfDoc, int total, int f } if (pdfDoc.getXref().size() != total || flushedActual != flushedExpected || notReadActual != notReadExpected) { - Assert.fail(MessageFormatUtil.format("\nExpected total: {0}, flushed: {1}, not read: {2};" + + Assertions.fail(MessageFormatUtil.format("\nExpected total: {0}, flushed: {1}, not read: {2};" + "\nbut actual was: {3}, flushed: {4}, not read: {5}.", total, flushedExpected, notReadExpected, pdfDoc.getXref().size(), flushedActual, notReadActual )); } - Assert.assertEquals("wrong num of total objects", total, pdfDoc.getXref().size()); - Assert.assertEquals("wrong num of flushed objects", flushedExpected, flushedActual); - Assert.assertEquals("wrong num of not read objects", notReadExpected, notReadActual); + Assertions.assertEquals(total, pdfDoc.getXref().size(), "wrong num of total objects"); + Assertions.assertEquals(flushedExpected, flushedActual, "wrong num of flushed objects"); + Assertions.assertEquals(notReadExpected, notReadActual, "wrong num of not read objects"); } private static void addContentToPage(PdfPage pdfPage, PdfFont font, PdfImageXObject xObject) throws IOException { diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/ParentTreeTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/ParentTreeTest.java index c5f27268c6..c2f12d5f31 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/ParentTreeTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/ParentTreeTest.java @@ -42,29 +42,28 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.ByteArrayOutputStream; import java.io.IOException; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class ParentTreeTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/kernel/pdf/ParentTreeTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/kernel/pdf/ParentTreeTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(destinationFolder); } @@ -109,7 +108,7 @@ public void stampingFormXObjectInnerContentTaggedTest() throws IOException, Inte PdfDocument taggedPdf = new PdfDocument(new PdfReader(pdf), CompareTool.createTestPdfWriter(outPdf)); taggedPdf.setTagged(); taggedPdf.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff")); } @Test @@ -121,7 +120,7 @@ public void severalXObjectsOnOnePageTest() throws IOException, InterruptedExcept PdfDocument taggedPdf = new PdfDocument(new PdfReader(pdf), CompareTool.createTestPdfWriter(outPdf)); taggedPdf.setTagged(); taggedPdf.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff")); } @Test @@ -135,7 +134,7 @@ public void earlyFlushXObjectTaggedTest() throws IOException, InterruptedExcepti resource.get(new PdfName("Fm1")).flush(); taggedPdf.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff")); } @Test @@ -147,7 +146,7 @@ public void identicalMcidIdInOneStreamTest() throws IOException, InterruptedExce PdfDocument taggedPdf = new PdfDocument(new PdfReader(pdf), CompareTool.createTestPdfWriter(outPdf)); taggedPdf.setTagged(); taggedPdf.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff")); } @Test @@ -163,7 +162,7 @@ public void copyPageWithFormXObjectTaggedTest() throws IOException, InterruptedE srcPdf.close(); outPdf.close(); - Assert.assertNull(new CompareTool().compareByContent(outDoc, cmpPdf, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outDoc, cmpPdf, destinationFolder)); } @Test @@ -178,7 +177,7 @@ public void removePageWithFormXObjectTaggedTest() throws IOException, Interrupte outPdf.close(); - Assert.assertNull(new CompareTool().compareByContent(outDoc, cmpPdf, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outDoc, cmpPdf, destinationFolder)); } @Test @@ -367,7 +366,7 @@ public void objRefAsStreamTest() throws IOException, InterruptedException { PdfDocument taggedPdf = new PdfDocument(new PdfReader(pdf), CompareTool.createTestPdfWriter(outPdf)); taggedPdf.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff")); } @Test @@ -377,7 +376,7 @@ public void objRefAsStreamTest() throws IOException, InterruptedException { public void objRefAsInvalidType() throws IOException { String pdf = sourceFolder + "objRefAsInvalidType.pdf"; PdfDocument doc = new PdfDocument(new PdfReader(pdf)); - Assert.assertNull(doc.getStructTreeRoot()); + Assertions.assertNull(doc.getStructTreeRoot()); } @Test @@ -392,7 +391,7 @@ public void unregisterObjRefAsStreamTest() throws IOException, InterruptedExcept elem.removeKid(0); taggedPdf.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff")); } @@ -407,7 +406,7 @@ public void allObjRefDontHaveStructParentTest() throws IOException, InterruptedE PdfDocument taggedPdf = new PdfDocument(new PdfReader(pdf), new PdfWriter(outPdf)); taggedPdf.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff")); } @Test @@ -421,7 +420,7 @@ public void xObjDoesntHaveStructParentTest() throws IOException, InterruptedExce PdfDocument taggedPdf = new PdfDocument(new PdfReader(pdf), new PdfWriter(outPdf)); taggedPdf.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff")); } @Test @@ -456,7 +455,7 @@ public void objRefNoStructParentModificationTest() throws IOException, Interrupt PdfDocument doc = new PdfDocument(new PdfReader(pdf), CompareTool.createTestPdfWriter(outPdf)); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff")); } @Test @@ -489,7 +488,7 @@ public void xObjNoStructParentModificationTest() throws IOException, Interrupted PdfDocument doc = new PdfDocument(new PdfReader(pdf), CompareTool.createTestPdfWriter(outPdf)); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff")); } @Test @@ -521,7 +520,7 @@ public void objRefNoStructParentNoReaderTest() throws IOException, InterruptedEx pdfDoc.getStructTreeRoot().addKid(elem); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff")); } @Test diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfAConformanceLevelTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfAConformanceLevelTest.java deleted file mode 100644 index b99f9cb012..0000000000 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfAConformanceLevelTest.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - This file is part of the iText (R) project. - Copyright (c) 1998-2024 Apryse Group NV - Authors: Apryse Software. - - This program is offered under a commercial and under the AGPL license. - For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. - - AGPL licensing: - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . - */ -package com.itextpdf.kernel.pdf; - -import com.itextpdf.io.source.ByteArrayOutputStream; -import com.itextpdf.kernel.xmp.XMPConst; -import com.itextpdf.kernel.xmp.XMPException; -import com.itextpdf.kernel.xmp.XMPMeta; -import com.itextpdf.kernel.xmp.impl.XMPMetaImpl; -import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; - -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -@Category(UnitTest.class) -public class PdfAConformanceLevelTest extends ExtendedITextTest { - @Test - public void getConformanceTest() { - Assert.assertEquals(PdfAConformanceLevel.PDF_A_4, PdfAConformanceLevel.getConformanceLevel("4", null)); - Assert.assertEquals(PdfAConformanceLevel.PDF_A_4E, PdfAConformanceLevel.getConformanceLevel("4", "E")); - Assert.assertEquals(PdfAConformanceLevel.PDF_A_4F, PdfAConformanceLevel.getConformanceLevel("4", "F")); - } - - @Test - public void getXmpConformanceNullTest() throws XMPException { - XMPMeta meta = new XMPMetaImpl(); - meta.setProperty(XMPConst.NS_PDFA_ID, XMPConst.PART, "4"); - PdfAConformanceLevel level = PdfAConformanceLevel.getConformanceLevel(meta); - Assert.assertEquals(PdfAConformanceLevel.PDF_A_4, level); - } - - @Test - public void getXmpConformanceBTest() throws XMPException { - XMPMeta meta = new XMPMetaImpl(); - meta.setProperty(XMPConst.NS_PDFA_ID, XMPConst.PART, "2"); - meta.setProperty(XMPConst.NS_PDFA_ID, XMPConst.CONFORMANCE, "B"); - PdfAConformanceLevel level = PdfAConformanceLevel.getConformanceLevel(meta); - Assert.assertEquals(PdfAConformanceLevel.PDF_A_2B, level); - } - - @Test - public void getPdfAConformanceLevel01Test() { - Assert.assertNull(PdfAConformanceLevel.getPDFAConformance(null, null)); - } - - @Test - public void getPdfAConformanceLevel02Test() { - Assert.assertEquals(PdfAConformanceLevel.PDF_A_1A, - PdfAConformanceLevel.getPDFAConformance(PdfAConformanceLevel.PDF_A_1A, null)); - } - - - @Test - public void getPdfAConformanceLevel03Test() { - try(PdfDocument pdfDocument = new PdfDocument(new PdfWriter(new ByteArrayOutputStream()))){ - Assert.assertEquals(PdfAConformanceLevel.PDF_A_1A, - PdfAConformanceLevel.getPDFAConformance(PdfAConformanceLevel.PDF_A_1A, pdfDocument)); - } - } - - @Test - public void getPdfAConformanceLevel04Test() { - try(PdfDocument pdfDocument = new PdfDocument(new PdfWriter(new ByteArrayOutputStream()))){ - Assert.assertNull(PdfAConformanceLevel.getPDFAConformance(null, pdfDocument)); - } - } -} diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfAConformanceTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfAConformanceTest.java new file mode 100644 index 0000000000..be3ba1033f --- /dev/null +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfAConformanceTest.java @@ -0,0 +1,62 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.pdf; + +import com.itextpdf.kernel.xmp.XMPConst; +import com.itextpdf.kernel.xmp.XMPException; +import com.itextpdf.kernel.xmp.XMPMeta; +import com.itextpdf.kernel.xmp.impl.XMPMetaImpl; +import com.itextpdf.test.ExtendedITextTest; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +@Tag("UnitTest") +public class PdfAConformanceTest extends ExtendedITextTest { + @Test + public void getConformanceTest() { + Assertions.assertEquals(PdfAConformance.PDF_A_4, PdfConformance.getAConformance("4", null)); + Assertions.assertEquals(PdfAConformance.PDF_A_4E, PdfConformance.getAConformance("4", "E")); + Assertions.assertEquals(PdfAConformance.PDF_A_4F, PdfConformance.getAConformance("4", "F")); + } + + @Test + public void getXmpConformanceNullTest() throws XMPException { + XMPMeta meta = new XMPMetaImpl(); + meta.setProperty(XMPConst.NS_PDFA_ID, XMPConst.PART, "4"); + PdfConformance level = PdfConformance.getConformance(meta); + Assertions.assertEquals(PdfAConformance.PDF_A_4, level.getAConformance()); + Assertions.assertEquals(PdfConformance.PDF_A_4, level); + } + + @Test + public void getXmpConformanceBTest() throws XMPException { + XMPMeta meta = new XMPMetaImpl(); + meta.setProperty(XMPConst.NS_PDFA_ID, XMPConst.PART, "2"); + meta.setProperty(XMPConst.NS_PDFA_ID, XMPConst.CONFORMANCE, "B"); + PdfConformance level = PdfConformance.getConformance(meta); + Assertions.assertEquals(PdfAConformance.PDF_A_2B, level.getAConformance()); + Assertions.assertEquals(PdfConformance.PDF_A_2B, level); + } +} diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfActionTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfActionTest.java index b7765339d9..790d368913 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfActionTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfActionTest.java @@ -32,31 +32,30 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.filespec.PdfStringFS; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.ByteArrayOutputStream; import java.io.InputStream; import java.net.URI; import java.util.ArrayList; import java.util.List; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfActionTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/kernel/pdf/PdfActionTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/kernel/pdf/PdfActionTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(destinationFolder); } @@ -89,7 +88,7 @@ public void actionTest03() throws Exception { String uri = "http://itextpdf.com/"; document.getCatalog().setOpenAction(PdfAction.createURI(new URI(uri))); - Assert.assertEquals(new PdfString(uri), + Assertions.assertEquals(new PdfString(uri), document.getCatalog().getPdfObject().getAsDictionary(PdfName.OpenAction).get(PdfName.URI)); document.close(); @@ -111,7 +110,7 @@ public void soundActionTest() throws Exception { document.getPage(2).setAdditionalAction(PdfName.O, PdfAction.createSound(sound1)); document.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + fileName, + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + fileName, sourceFolder + "cmp_" + fileName, destinationFolder, "diff_")); } @@ -131,7 +130,7 @@ public void soundActionWithRepeatFlagTest() throws Exception { .setAdditionalAction(PdfName.O, PdfAction.createSound(sound1,1f, false, true, false)); document.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + fileName, + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + fileName, sourceFolder + "cmp_" + fileName, destinationFolder, "diff_")); } @@ -149,9 +148,9 @@ public void soundActionWithToBigVolumeTest() throws Exception { try { document.getPage(2) .setAdditionalAction(PdfName.O, PdfAction.createSound(sound1, 1.1f, false, false, false)); - Assert.fail("Exception not thrown"); + Assertions.fail("Exception not thrown"); } catch (Exception e) { - Assert.assertEquals("volume", e.getMessage()); + Assertions.assertEquals("volume", e.getMessage()); } document.close(); } @@ -170,9 +169,9 @@ public void soundActionWithToLowVolumeTest() throws Exception { try { document.getPage(2) .setAdditionalAction(PdfName.O, PdfAction.createSound(sound1, -1.1f, false, false, false)); - Assert.fail("Exception not thrown"); + Assertions.fail("Exception not thrown"); } catch (Exception e) { - Assert.assertEquals("volume", e.getMessage()); + Assertions.assertEquals("volume", e.getMessage()); } document.close(); } @@ -201,7 +200,7 @@ public void ocgStateTest() throws Exception { document.getPage(1).setAdditionalAction(PdfName.O, PdfAction.createSetOcgState(ocgStates)); document.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + fileName, + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + fileName, sourceFolder + "cmp_" + fileName, destinationFolder, "diff_")); } @@ -213,7 +212,7 @@ public void launchActionTest() throws Exception { document.getPage(1).setAdditionalAction(PdfName.O, PdfAction.createLaunch(new PdfStringFS("launch.sh"))); document.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + fileName, + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + fileName, sourceFolder + "cmp_" + fileName, destinationFolder, "diff_")); } @@ -226,7 +225,7 @@ public void launchActionOnNewWindowTest() throws Exception { PdfAction.createLaunch(new PdfStringFS("launch.sh"), true)); document.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + fileName, + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + fileName, sourceFolder + "cmp_" + fileName, destinationFolder, "diff_")); } @@ -240,7 +239,7 @@ public void createHiddenAnnotationTest() throws Exception { document.getPage(1).setAdditionalAction(PdfName.O, PdfAction.createHide(annotation, true)); document.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + fileName, + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + fileName, sourceFolder + "cmp_" + fileName, destinationFolder, "diff_")); } @@ -256,7 +255,7 @@ public void createHiddenAnnotationsTest() throws Exception { document.getPage(1).setAdditionalAction(PdfName.O, PdfAction.createHide(annotations, true)); document.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + fileName, + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + fileName, sourceFolder + "cmp_" + fileName, destinationFolder, "diff_")); } @@ -268,7 +267,7 @@ public void createHiddenByFieldNameTest() throws Exception { document.getPage(1).setAdditionalAction(PdfName.O, PdfAction.createHide("name", true)); document.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + fileName, + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + fileName, sourceFolder + "cmp_" + fileName, destinationFolder, "diff_")); } @@ -280,7 +279,7 @@ public void createHiddenByFieldNamesTest() throws Exception { document.getPage(1).setAdditionalAction(PdfName.O, PdfAction.createHide(new String[] {"name1", "name2"}, true)); document.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + fileName, + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + fileName, sourceFolder + "cmp_" + fileName, destinationFolder, "diff_")); } @@ -292,7 +291,7 @@ public void createNamedTest() throws Exception { document.getPage(1).setAdditionalAction(PdfName.O, PdfAction.createNamed(PdfName.LastPage)); document.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + fileName, + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + fileName, sourceFolder + "cmp_" + fileName, destinationFolder, "diff_")); } @@ -305,7 +304,7 @@ public void createJavaScriptTest() throws Exception { document.getPage(1).setAdditionalAction(PdfName.O, PdfAction.createJavaScript(javaScriptRotatePages)); document.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + fileName, + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + fileName, sourceFolder + "cmp_" + fileName, destinationFolder, "diff_")); } @@ -326,7 +325,7 @@ public void soundAndNextJavaScriptActionTest() throws Exception { document.getPage(2).setAdditionalAction(PdfName.O, action); document.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + fileName, + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + fileName, sourceFolder + "cmp_" + fileName, destinationFolder, "diff_")); } @@ -348,7 +347,7 @@ public void soundAndTwoNextJavaScriptActionTest() throws Exception { document.getPage(2).setAdditionalAction(PdfName.O, action); document.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + fileName, + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + fileName, sourceFolder + "cmp_" + fileName, destinationFolder, "diff_")); } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfArrayTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfArrayTest.java index c824a88620..3cdb7f6012 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfArrayTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfArrayTest.java @@ -31,14 +31,13 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.colorspace.PdfColorSpace; import com.itextpdf.kernel.pdf.colorspace.PdfSpecialCs; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.util.Set; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfArrayTest extends ExtendedITextTest { @Test @@ -53,12 +52,12 @@ public void testValuesIndirectContains() { array.add(new PdfNumber(4)); array.add(new PdfNumber(5)); - Assert.assertTrue(array.contains(array.get(0, false))); - Assert.assertTrue(array.contains(array.get(1, false))); - Assert.assertTrue(array.contains(array.get(2).getIndirectReference())); - Assert.assertTrue(array.contains(array.get(3).getIndirectReference())); - Assert.assertTrue(array.contains(array.get(4))); - Assert.assertTrue(array.contains(array.get(5))); + Assertions.assertTrue(array.contains(array.get(0, false))); + Assertions.assertTrue(array.contains(array.get(1, false))); + Assertions.assertTrue(array.contains(array.get(2).getIndirectReference())); + Assertions.assertTrue(array.contains(array.get(3).getIndirectReference())); + Assertions.assertTrue(array.contains(array.get(4))); + Assertions.assertTrue(array.contains(array.get(5))); } @Test @@ -80,7 +79,7 @@ public void testValuesIndirectRemove() { array.remove(array.get(0)); array.remove(array.get(0)); - Assert.assertEquals(0, array.size()); + Assertions.assertEquals(0, array.size()); } @Test @@ -104,11 +103,11 @@ public void testContains() { array2.add(new PdfNumber(6)); for (PdfObject obj : array2) { - Assert.assertTrue(array.contains(obj)); + Assertions.assertTrue(array.contains(obj)); } for (int i = 0; i < array2.size(); i++) { - Assert.assertTrue(array.contains(array2.get(i))); + Assertions.assertTrue(array.contains(array2.get(i))); } } @@ -136,7 +135,7 @@ public void testRemove() { array.remove(obj); } - Assert.assertEquals(0, array.size()); + Assertions.assertEquals(0, array.size()); } @Test @@ -163,7 +162,7 @@ public void testRemove2() { array.remove(array2.get(i)); } - Assert.assertEquals(0, array.size()); + Assertions.assertEquals(0, array.size()); } @Test public void testIndexOf() { @@ -187,7 +186,7 @@ public void testIndexOf() { int i = 0; for (PdfObject obj : array2) { - Assert.assertEquals(i++, array.indexOf(obj)); + Assertions.assertEquals(i++, array.indexOf(obj)); } } @@ -212,7 +211,7 @@ public void testIndexOf2() { array2.add(new PdfNumber(6)); for (int i = 0; i < array2.size(); i++) { - Assert.assertEquals(i, array.indexOf(array2.get(i))); + Assertions.assertEquals(i, array.indexOf(array2.get(i))); } } @@ -240,7 +239,7 @@ public void pdfUncoloredPatternColorSize1Test() { processor.processPageContent(page); // Check if we reach the end of the test without failings together with verifying expected color space instance - Assert.assertTrue(processor.getGraphicsState().getFillColor().getColorSpace() instanceof PdfSpecialCs.Pattern); + Assertions.assertTrue(processor.getGraphicsState().getFillColor().getColorSpace() instanceof PdfSpecialCs.Pattern); } private static class NoOpListener implements IEventListener { diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfArrayUnitTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfArrayUnitTest.java index f3b840d0b3..5d8541bf9a 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfArrayUnitTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfArrayUnitTest.java @@ -25,66 +25,65 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.exceptions.KernelExceptionMessageConstant; import com.itextpdf.kernel.exceptions.PdfException; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfArrayUnitTest extends ExtendedITextTest { @Test public void cannotConvertArrayOfPdfStringsToArrayOfBooleansTest() { PdfArray pdfArray = new PdfArray(new PdfString("")); - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> pdfArray.toBooleanArray()); - Assert.assertEquals(KernelExceptionMessageConstant.CANNOT_CONVERT_PDF_ARRAY_TO_AN_ARRAY_OF_BOOLEANS, + Assertions.assertEquals(KernelExceptionMessageConstant.CANNOT_CONVERT_PDF_ARRAY_TO_AN_ARRAY_OF_BOOLEANS, exception.getMessage()); } @Test public void cannotConvertArrayOfPdfStringsToDoubleArrayTest() { PdfArray pdfArray = new PdfArray(new PdfString("")); - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> pdfArray.toDoubleArray()); - Assert.assertEquals(KernelExceptionMessageConstant.CANNOT_CONVERT_PDF_ARRAY_TO_DOUBLE_ARRAY, + Assertions.assertEquals(KernelExceptionMessageConstant.CANNOT_CONVERT_PDF_ARRAY_TO_DOUBLE_ARRAY, exception.getMessage()); } @Test public void cannotConvertArrayOfPdfStringsToIntArrayTest() { PdfArray pdfArray = new PdfArray(new PdfString("")); - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> pdfArray.toIntArray()); - Assert.assertEquals(KernelExceptionMessageConstant.CANNOT_CONVERT_PDF_ARRAY_TO_INT_ARRAY, + Assertions.assertEquals(KernelExceptionMessageConstant.CANNOT_CONVERT_PDF_ARRAY_TO_INT_ARRAY, exception.getMessage()); } @Test public void cannotConvertArrayOfPdfStringsToFloatArrayTest() { PdfArray pdfArray = new PdfArray(new PdfString("")); - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> pdfArray.toFloatArray()); - Assert.assertEquals(KernelExceptionMessageConstant.CANNOT_CONVERT_PDF_ARRAY_TO_FLOAT_ARRAY, + Assertions.assertEquals(KernelExceptionMessageConstant.CANNOT_CONVERT_PDF_ARRAY_TO_FLOAT_ARRAY, exception.getMessage()); } @Test public void cannotConvertArrayOfPdfStringsToLongArrayTest() { PdfArray pdfArray = new PdfArray(new PdfString("")); - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> pdfArray.toLongArray()); - Assert.assertEquals(KernelExceptionMessageConstant.CANNOT_CONVERT_PDF_ARRAY_TO_LONG_ARRAY, + Assertions.assertEquals(KernelExceptionMessageConstant.CANNOT_CONVERT_PDF_ARRAY_TO_LONG_ARRAY, exception.getMessage()); } @Test public void cannotConvertArrayOfPdfStringsToRectangleTest() { PdfArray pdfArray = new PdfArray(new PdfString("")); - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> pdfArray.toRectangle()); - Assert.assertEquals(KernelExceptionMessageConstant.CANNOT_CONVERT_PDF_ARRAY_TO_RECTANGLE, + Assertions.assertEquals(KernelExceptionMessageConstant.CANNOT_CONVERT_PDF_ARRAY_TO_RECTANGLE, exception.getMessage()); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfCopyTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfCopyTest.java index 1615250e48..6ae060992b 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfCopyTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfCopyTest.java @@ -30,33 +30,33 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.ByteArrayInputStream; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; - -@Category(IntegrationTest.class) +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; + +@Tag("IntegrationTest") public class PdfCopyTest extends ExtendedITextTest { public static final String destinationFolder = "./target/test/com/itextpdf/kernel/pdf/PdfCopyTest/"; public static final String sourceFolder = "./src/test/resources/com/itextpdf/kernel/pdf/PdfCopyTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(destinationFolder); } @@ -78,8 +78,8 @@ public void copySignedDocuments() throws IOException { PdfDictionary sig = (PdfDictionary) pdfDocument.getPdfObject(13); PdfDictionary sigRef = sig.getAsArray(PdfName.Reference).getAsDictionary(0); - Assert.assertTrue(PdfName.SigRef.equals(sigRef.getAsName(PdfName.Type))); - Assert.assertTrue(sigRef.get(PdfName.Data).isNull()); + Assertions.assertTrue(PdfName.SigRef.equals(sigRef.getAsName(PdfName.Type))); + Assertions.assertTrue(sigRef.get(PdfName.Data).isNull()); } @Test @@ -104,7 +104,7 @@ public void copying1() throws IOException { PdfReader reader = CompareTool.createOutputReader(destinationFolder + "copying1_2.pdf"); PdfDocument pdfDocument = new PdfDocument(reader); - assertEquals("Rebuilt", false, reader.hasRebuiltXref()); + assertFalse(reader.hasRebuiltXref(), "Rebuilt"); PdfDictionary trailer = pdfDocument.getTrailer(); PdfDictionary info = trailer.getAsDictionary(PdfName.Info); PdfName b = info.getAsName(new PdfName("a")); @@ -136,7 +136,7 @@ public void copying2() throws IOException { PdfReader reader = CompareTool.createOutputReader(destinationFolder + "copying2_2.pdf"); PdfDocument pdfDocument = new PdfDocument(reader); - assertEquals("Rebuilt", false, reader.hasRebuiltXref()); + assertFalse(reader.hasRebuiltXref(), "Rebuilt"); for (int i = 0; i < 5; i++) { byte[] bytes = pdfDocument.getPage(i + 1).getContentBytes(); assertEquals("%page " + String.valueOf(i * 2 + 1) + "\n", new String(bytes)); @@ -162,7 +162,7 @@ public void copying3() throws IOException { PdfReader reader = CompareTool.createOutputReader(destinationFolder + "copying3_1.pdf"); pdfDoc = new PdfDocument(reader); - assertEquals("Rebuilt", false, reader.hasRebuiltXref()); + assertFalse(reader.hasRebuiltXref(), "Rebuilt"); PdfDictionary dic0 = pdfDoc.getPage(1).getPdfObject().getAsDictionary(new PdfName("HelloWorld")); assertEquals(4, dic0.getIndirectReference().getObjNumber()); @@ -325,9 +325,9 @@ public void copySelfContainedObject() throws IOException { PdfDictionary destSelfContainedDictR = destSelfContainedDict.getAsDictionary(randEntry1); PdfDictionary destSelfContainedDictS = destSelfContainedDict.getAsDictionary(randEntry2); - Assert.assertEquals(destSelfContainedDict.getIndirectReference(), + Assertions.assertEquals(destSelfContainedDict.getIndirectReference(), destSelfContainedDictR.getIndirectReference()); - Assert.assertEquals(destSelfContainedDict.getIndirectReference(), + Assertions.assertEquals(destSelfContainedDict.getIndirectReference(), destSelfContainedDictS.getIndirectReference()); destDoc.close(); @@ -352,12 +352,12 @@ public void copyDifferentRangesOfPagesWithBookmarksTest() throws IOException, In int targetOutlines = targetPdf.getOutlines(false).getAllChildren().size(); - Assert.assertEquals(sourcePdfOutlines, targetOutlines); + Assertions.assertEquals(sourcePdfOutlines, targetOutlines); sourcePdf.close(); targetPdf.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } @Test @@ -375,12 +375,12 @@ public void copyPagesLinkAnnotationTest() throws IOException, InterruptedExcepti linkAnotPdf.copyPagesTo(1, 2, targetPdf); List annotations = getPdfAnnotations(targetPdf); - Assert.assertEquals("The number of merged annotations are not the same.", 0, annotations.size()); + Assertions.assertEquals(0, annotations.size(), "The number of merged annotations are not the same."); linkAnotPdf.close(); targetPdf.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } @Test @@ -397,7 +397,7 @@ public void objRefAsStreamCopyTest() throws IOException, InterruptedException { pdfFile.close(); copiedFile.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff")); } @Test @@ -413,7 +413,7 @@ public void copyDocWithFullDDictionary() throws IOException, InterruptedExceptio inPdf.close(); outPdf.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } private List getPdfAnnotations(PdfDocument pdfDoc) { diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfDashPatternTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfDashPatternTest.java index 3c665a8f2b..cfca30cc9a 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfDashPatternTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfDashPatternTest.java @@ -23,43 +23,42 @@ This file is part of the iText (R) project. package com.itextpdf.kernel.pdf; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfDashPatternTest extends ExtendedITextTest { @Test public void constructorNoParamTest() { PdfDashPattern dashPattern = new PdfDashPattern(); - Assert.assertEquals(-1, dashPattern.getDash(), 0.0001); - Assert.assertEquals(-1, dashPattern.getGap(), 0.0001); - Assert.assertEquals(-1, dashPattern.getPhase(), 0.0001); + Assertions.assertEquals(-1, dashPattern.getDash(), 0.0001); + Assertions.assertEquals(-1, dashPattern.getGap(), 0.0001); + Assertions.assertEquals(-1, dashPattern.getPhase(), 0.0001); } @Test public void constructorOneParamTest() { PdfDashPattern dashPattern = new PdfDashPattern(10); - Assert.assertEquals(10, dashPattern.getDash(), 0.0001); - Assert.assertEquals(-1, dashPattern.getGap(), 0.0001); - Assert.assertEquals(-1, dashPattern.getPhase(), 0.0001); + Assertions.assertEquals(10, dashPattern.getDash(), 0.0001); + Assertions.assertEquals(-1, dashPattern.getGap(), 0.0001); + Assertions.assertEquals(-1, dashPattern.getPhase(), 0.0001); } @Test public void constructorTwoParamsTest() { PdfDashPattern dashPattern = new PdfDashPattern(10, 20); - Assert.assertEquals(10, dashPattern.getDash(), 0.0001); - Assert.assertEquals(20, dashPattern.getGap(), 0.0001); - Assert.assertEquals(-1, dashPattern.getPhase(), 0.0001); + Assertions.assertEquals(10, dashPattern.getDash(), 0.0001); + Assertions.assertEquals(20, dashPattern.getGap(), 0.0001); + Assertions.assertEquals(-1, dashPattern.getPhase(), 0.0001); } @Test public void constructorThreeParamsTest() { PdfDashPattern dashPattern = new PdfDashPattern(10, 20, 30); - Assert.assertEquals(10, dashPattern.getDash(), 0.0001); - Assert.assertEquals(20, dashPattern.getGap(), 0.0001); - Assert.assertEquals(30, dashPattern.getPhase(), 0.0001); + Assertions.assertEquals(10, dashPattern.getDash(), 0.0001); + Assertions.assertEquals(20, dashPattern.getGap(), 0.0001); + Assertions.assertEquals(30, dashPattern.getPhase(), 0.0001); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfDestinationTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfDestinationTest.java index db410b0697..a5e42c5dca 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfDestinationTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfDestinationTest.java @@ -37,35 +37,34 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.ByteArrayOutputStream; import java.util.HashMap; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertNull; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfDestinationTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/kernel/pdf/PdfDestinationTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/kernel/pdf/PdfDestinationTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(destinationFolder); } @@ -215,9 +214,9 @@ public void structureDestinationWithoutRemoteIdTest() throws IOException { try { PdfAction.createGoToR(new PdfStringFS("Some fake destination"), PdfStructureDestination.createFit(imgElement)); - Assert.fail("Exception not thrown"); + Assertions.fail("Exception not thrown"); } catch (IllegalArgumentException e) { - Assert.assertEquals("Structure destinations shall specify structure element ID in remote go-to actions. Structure element that has no ID is specified instead", e.getMessage()); + Assertions.assertEquals("Structure destinations shall specify structure element ID in remote go-to actions. Structure element that has no ID is specified instead", e.getMessage()); } document.close(); @@ -274,7 +273,7 @@ public void makeDestination01Test() throws IOException { PdfDocument pdfDocument = new PdfDocument(new PdfReader(srcFile)); PdfObject destObj = ((PdfLinkAnnotation) pdfDocument.getPage(2).getAnnotations().get(0)).getAction().get(PdfName.D); PdfDestination destWrapper = PdfDestination.makeDestination(destObj); - Assert.assertEquals(PdfStructureDestination.class, destWrapper.getClass()); + Assertions.assertEquals(PdfStructureDestination.class, destWrapper.getClass()); } @Test @@ -336,9 +335,9 @@ public void remoteGoToRIllegalDestinationTest() throws IOException { try { PdfAction.createGoToR(new PdfStringFS("Some fake destination"), PdfExplicitDestination.createFitB(document.getPage(1))); - Assert.fail("Exception not thrown"); + Assertions.fail("Exception not thrown"); } catch (IllegalArgumentException e) { - Assert.assertEquals("Explicit destinations shall specify page number in remote go-to actions instead of page dictionary", e.getMessage()); + Assertions.assertEquals("Explicit destinations shall specify page number in remote go-to actions instead of page dictionary", e.getMessage()); } document.close(); } @@ -406,7 +405,7 @@ public void copyNullDestination() throws IOException { .copyDestination(null, new HashMap(), pdfDocument); // We expect null to be returned if the destination to be copied is null - Assert.assertNull(copiedDestination); + Assertions.assertNull(copiedDestination); } } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfDeveloperExtensionTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfDeveloperExtensionTest.java index 30ce20a516..c504beffe4 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfDeveloperExtensionTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfDeveloperExtensionTest.java @@ -24,9 +24,8 @@ This file is part of the iText (R) project. import com.itextpdf.io.source.ByteArrayOutputStream; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.ByteArrayInputStream; import java.io.IOException; @@ -36,11 +35,9 @@ This file is part of the iText (R) project. import java.util.HashSet; import java.util.Set; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Assertions; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfDeveloperExtensionTest extends ExtendedITextTest { @@ -151,13 +148,53 @@ public void addMultivaluedExtensionNoOverrideTest() throws IOException { ); } + @Test + public void removeSingleValuedExtensionTest() throws IOException { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + + try (PdfDocument pdfDoc = new PdfDocument(new PdfWriter(baos))) { + pdfDoc.getCatalog().addDeveloperExtension(SIMPLE_EXTENSION_L5); + pdfDoc.getCatalog().removeDeveloperExtension(SIMPLE_EXTENSION_L5); + } + + assertNoExtensionWithPrefix( + baos.toByteArray(), + SIMPLE_EXTENSION_L5.getPrefix() + ); + } + + @Test + public void removeMultivaluedExtensionTest() throws IOException { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + + try (PdfDocument pdfDoc = new PdfDocument(new PdfWriter(baos))) { + pdfDoc.getCatalog().addDeveloperExtension(MULTI_EXTENSION_1); + pdfDoc.getCatalog().addDeveloperExtension(MULTI_EXTENSION_2); + pdfDoc.getCatalog().removeDeveloperExtension(MULTI_EXTENSION_2); + } + + assertMultiExtension( + baos.toByteArray(), + MULTI_EXTENSION_1.getPrefix(), + Arrays.asList(MULTI_EXTENSION_1.getExtensionLevel()) + ); + } + private void assertSimpleExtension(byte[] docData, PdfName prefix, int expectedLevel) throws IOException { + try (PdfDocument pdfDoc = new PdfDocument(new PdfReader(new ByteArrayInputStream(docData)))) { + PdfDictionary extDict = pdfDoc.getCatalog().getPdfObject() + .getAsDictionary(PdfName.Extensions) + .getAsDictionary(prefix); + Assertions.assertEquals(expectedLevel, extDict.getAsNumber(PdfName.ExtensionLevel).intValue()); + } + } + private void assertNoExtensionWithPrefix(byte[] docData, PdfName prefix) throws IOException { try (PdfDocument pdfDoc = new PdfDocument(new PdfReader(new ByteArrayInputStream(docData)))) { PdfDictionary extDict = pdfDoc.getCatalog().getPdfObject() .getAsDictionary(PdfName.Extensions) .getAsDictionary(prefix); - assertEquals(expectedLevel, extDict.getAsNumber(PdfName.ExtensionLevel).intValue()); + Assertions.assertNull(extDict); } } @@ -172,8 +209,8 @@ private void assertMultiExtension(byte[] docData, PdfName prefix, Collection nums = new ArrayList<>(Arrays.asList(1, 2, 3, 4, 5, 6)); for (Map.Entry e: dict.entrySet()) { - Assert.assertEquals(e.getKey().toString(), "/"+e.getValue()); + Assertions.assertEquals(e.getKey().toString(), "/"+e.getValue()); if (!nums.remove(Integer.valueOf(((PdfNumber)e.getValue()).intValue()))) { - Assert.fail("Element not found"); + Assertions.fail("Element not found"); } } } @@ -71,7 +70,7 @@ public void testEntrySetContains() { dict.put(new PdfName("6"), new PdfNumber(6)); for (Map.Entry e: dict.entrySet()) { - Assert.assertTrue(dict.entrySet().contains(e)); + Assertions.assertTrue(dict.entrySet().contains(e)); } } @@ -92,11 +91,11 @@ public void testEntrySetRemove() { toRemove.add(e); } for (Map.Entry e: toRemove) { - Assert.assertTrue(dict.entrySet().remove(e)); + Assertions.assertTrue(dict.entrySet().remove(e)); } - Assert.assertEquals(0, dict.entrySet().size()); - Assert.assertEquals(0, dict.values().size()); - Assert.assertEquals(0, dict.size()); + Assertions.assertEquals(0, dict.entrySet().size()); + Assertions.assertEquals(0, dict.values().size()); + Assertions.assertEquals(0, dict.size()); } @Test @@ -120,12 +119,12 @@ public void testEntrySetRemove2() { dict2.put(new PdfName("6"), new PdfNumber(6)); for (Map.Entry e: dict2.entrySet()) { - Assert.assertTrue(dict.entrySet().remove(e)); + Assertions.assertTrue(dict.entrySet().remove(e)); } - Assert.assertEquals(0, dict.entrySet().size()); - Assert.assertEquals(0, dict.values().size()); - Assert.assertEquals(0, dict.size()); + Assertions.assertEquals(0, dict.entrySet().size()); + Assertions.assertEquals(0, dict.values().size()); + Assertions.assertEquals(0, dict.size()); } @Test @@ -146,9 +145,9 @@ public void testEntrySetRemoveAll() { } dict.entrySet().removeAll(toRemove); - Assert.assertEquals(0, dict.entrySet().size()); - Assert.assertEquals(0, dict.values().size()); - Assert.assertEquals(0, dict.size()); + Assertions.assertEquals(0, dict.entrySet().size()); + Assertions.assertEquals(0, dict.values().size()); + Assertions.assertEquals(0, dict.size()); } @Test @@ -172,9 +171,9 @@ public void testEntrySetRemoveAll2() { dict2.put(new PdfName("6"), new PdfNumber(6)); dict.entrySet().removeAll(dict2.entrySet()); - Assert.assertEquals(0, dict.entrySet().size()); - Assert.assertEquals(0, dict.values().size()); - Assert.assertEquals(0, dict.size()); + Assertions.assertEquals(0, dict.entrySet().size()); + Assertions.assertEquals(0, dict.values().size()); + Assertions.assertEquals(0, dict.size()); } @Test @@ -197,9 +196,9 @@ public void testEntrySetRetainAll() { } dict.entrySet().retainAll(toRemove); - Assert.assertEquals(4, dict.entrySet().size()); - Assert.assertEquals(4, dict.values().size()); - Assert.assertEquals(4, dict.size()); + Assertions.assertEquals(4, dict.entrySet().size()); + Assertions.assertEquals(4, dict.values().size()); + Assertions.assertEquals(4, dict.size()); } @Test @@ -215,9 +214,9 @@ public void testEntrySetClear() { dict.put(new PdfName("6"), new PdfNumber(6)); dict.entrySet().clear(); - Assert.assertEquals(0, dict.entrySet().size()); - Assert.assertEquals(0, dict.values().size()); - Assert.assertEquals(0, dict.size()); + Assertions.assertEquals(0, dict.entrySet().size()); + Assertions.assertEquals(0, dict.values().size()); + Assertions.assertEquals(0, dict.size()); } @Test @@ -234,9 +233,9 @@ public void testValues() { List nums = new ArrayList<>(Arrays.asList(1, 2, 3, 4, 5, 6)); for (Map.Entry e: dict.entrySet()) { - Assert.assertEquals(e.getKey().toString(), "/"+e.getValue()); + Assertions.assertEquals(e.getKey().toString(), "/"+e.getValue()); if (!nums.remove(Integer.valueOf(((PdfNumber)e.getValue()).intValue()))) { - Assert.fail("Element not found"); + Assertions.fail("Element not found"); } } } @@ -254,7 +253,7 @@ public void testValuesContains() { dict.put(new PdfName("6"), new PdfNumber(6)); for (PdfObject v: dict.values()) { - Assert.assertTrue(dict.values().contains(v)); + Assertions.assertTrue(dict.values().contains(v)); } } @@ -270,10 +269,10 @@ public void testValuesIndirectContains() { dict.put(new PdfName("5"), new PdfNumber(5)); dict.put(new PdfName("6"), new PdfNumber(6)); - Assert.assertTrue(dict.values().contains(dict.get(new PdfName("1"), false))); - Assert.assertTrue(dict.values().contains(dict.get(new PdfName("2"), false))); - Assert.assertTrue(dict.values().contains(dict.get(new PdfName("3")).getIndirectReference())); - Assert.assertTrue(dict.values().contains(dict.get(new PdfName("4")).getIndirectReference())); + Assertions.assertTrue(dict.values().contains(dict.get(new PdfName("1"), false))); + Assertions.assertTrue(dict.values().contains(dict.get(new PdfName("2"), false))); + Assertions.assertTrue(dict.values().contains(dict.get(new PdfName("3")).getIndirectReference())); + Assertions.assertTrue(dict.values().contains(dict.get(new PdfName("4")).getIndirectReference())); } @Test @@ -340,7 +339,7 @@ public void testPdfNamesFetching() { break; } } - Assert.assertTrue(found); - Assert.assertTrue(dict.containsKey(expectedToContain)); + Assertions.assertTrue(found); + Assertions.assertTrue(dict.containsKey(expectedToContain)); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfDictionaryTokenizerTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfDictionaryTokenizerTest.java index 006583c13b..e32eb9361d 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfDictionaryTokenizerTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfDictionaryTokenizerTest.java @@ -23,21 +23,20 @@ This file is part of the iText (R) project. package com.itextpdf.kernel.pdf; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfDictionaryTokenizerTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/kernel/pdf/PdfDictionaryTokenizerTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/kernel/pdf/PdfDictionaryTokenizerTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } @@ -68,7 +67,7 @@ public void readerTurnsCorrectlyNotWellFormattedValueInDictionary_01() throws IO // ItalicAngle -12.-23 turns into -12. String result = getItalicAngleValue(inPath); - Assert.assertEquals(EXPECTED, result); + Assertions.assertEquals(EXPECTED, result); } @Test @@ -96,7 +95,7 @@ public void readerTurnsCorrectlyNotWellFormattedValueInDictionary_02() throws IO // ItalicAngle -12.-23 turns into -12. String result = getItalicAngleValue(inPath); - Assert.assertEquals(EXPECTED, result); + Assertions.assertEquals(EXPECTED, result); } private String getItalicAngleValue(String inPath) throws IOException { diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfDocumentAppendModeTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfDocumentAppendModeTest.java index 4705a1e704..fffde16ec3 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfDocumentAppendModeTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfDocumentAppendModeTest.java @@ -27,27 +27,26 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfDocumentAppendModeTest extends ExtendedITextTest { public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/kernel/pdf/PdfDocumentAppendModeTest/"; public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/kernel/pdf/PdfDocumentAppendModeTest/"; - @BeforeClass + @BeforeAll public static void setUp() { createDestinationFolder(DESTINATION_FOLDER); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(DESTINATION_FOLDER); } @@ -64,7 +63,7 @@ public void testAppendModeWithFullCompressionRequestedWhenOriginalDocumentHasXre new StampingProperties().useAppendMode()); pdfDocument.addNewPage(); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFile, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFile, DESTINATION_FOLDER)); } @Test @@ -79,7 +78,7 @@ public void testAppendModeWithFullCompressionSetToFalseWhenOriginalDocumentHasXr new StampingProperties().useAppendMode()); pdfDocument.addNewPage(); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFile, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFile, DESTINATION_FOLDER)); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfDocumentIdTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfDocumentIdTest.java index e73cac197d..b91c9c1e4b 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfDocumentIdTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfDocumentIdTest.java @@ -35,18 +35,17 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfDocumentIdTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/kernel/pdf/PdfDocumentTestID/"; public static final String destinationFolder = "./target/test/com/itextpdf/kernel/pdf/PdfDocumentTestID/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } @@ -69,11 +68,11 @@ public void changeIdTest() throws IOException { PdfReader reader = new PdfReader(new ByteArrayInputStream(documentBytes)); pdfDocument = new PdfDocument(reader); PdfArray idArray = pdfDocument.getTrailer().getAsArray(PdfName.ID); - Assert.assertNotNull(idArray); + Assertions.assertNotNull(idArray); String extractedValue = idArray.getAsString(1).getValue(); pdfDocument.close(); - Assert.assertEquals(value, extractedValue); + Assertions.assertEquals(value, extractedValue); } @Test @@ -99,11 +98,11 @@ public void changeIdTest02() throws IOException { PdfReader reader = new PdfReader(new ByteArrayInputStream(documentBytes)); pdfDocument = new PdfDocument(reader); PdfArray idArray = pdfDocument.getTrailer().getAsArray(PdfName.ID); - Assert.assertNotNull(idArray); + Assertions.assertNotNull(idArray); PdfString extractedString = idArray.getAsString(1); pdfDocument.close(); - Assert.assertEquals(initialId, extractedString); + Assertions.assertEquals(initialId, extractedString); } @Test @@ -130,11 +129,11 @@ public void changeIdTest03() throws IOException { pdfDocument = new PdfDocument(reader); PdfArray idArray = pdfDocument.getTrailer().getAsArray(PdfName.ID); pdfDocument.close(); - Assert.assertNotNull(idArray); + Assertions.assertNotNull(idArray); PdfString extractedInitialValue = idArray.getAsString(0); - Assert.assertEquals(initialId, extractedInitialValue); + Assertions.assertEquals(initialId, extractedInitialValue); PdfString extractedModifiedValue = idArray.getAsString(1); - Assert.assertEquals(modifiedId, extractedModifiedValue); + Assertions.assertEquals(modifiedId, extractedModifiedValue); pdfDocument = new PdfDocument(new PdfReader(new RandomAccessSourceFactory().createSource(baosInitial.toByteArray()), new ReaderProperties()), @@ -151,11 +150,11 @@ public void changeIdTest03() throws IOException { pdfDocument = new PdfDocument(reader); idArray = pdfDocument.getTrailer().getAsArray(PdfName.ID); pdfDocument.close(); - Assert.assertNotNull(idArray); + Assertions.assertNotNull(idArray); extractedInitialValue = idArray.getAsString(0); - Assert.assertEquals(initialId, extractedInitialValue); + Assertions.assertEquals(initialId, extractedInitialValue); extractedModifiedValue = idArray.getAsString(1); - Assert.assertNotEquals(modifiedId, extractedModifiedValue); + Assertions.assertNotEquals(modifiedId, extractedModifiedValue); } @Test @@ -185,8 +184,8 @@ public void fetchReaderIdTest() throws IOException{ String firstModifiedId = new String(reader.getModifiedFileId()); String secondModifiedId = new String(reader.getModifiedFileId()); - Assert.assertEquals(firstOriginalId, secondOriginalId); - Assert.assertEquals(firstModifiedId, secondModifiedId); + Assertions.assertEquals(firstOriginalId, secondOriginalId); + Assertions.assertEquals(firstModifiedId, secondModifiedId); } @Test @@ -224,8 +223,8 @@ public void writerPropertiesPriorityTest() throws IOException { pdfDocument.close(); - Assert.assertEquals(extractedOriginalId, newOriginalId.getValue()); - Assert.assertEquals(extractedModifiedId, newModifiedId.getValue()); + Assertions.assertEquals(extractedOriginalId, newOriginalId.getValue()); + Assertions.assertEquals(extractedModifiedId, newModifiedId.getValue()); } @Test @@ -241,8 +240,8 @@ public void readPdfWithTwoStringIdsTest() throws IOException{ } pdfDocument.close(); - Assert.assertNotNull(originalId); - Assert.assertNotNull(modifiedId); + Assertions.assertNotNull(originalId); + Assertions.assertNotNull(modifiedId); } @@ -263,8 +262,8 @@ public void readPdfWithTwoNumberIdsTest() throws IOException{ pdfDocument.close(); - Assert.assertNull(originalId); - Assert.assertNull(modifiedId); + Assertions.assertNull(originalId); + Assertions.assertNull(modifiedId); } @@ -284,8 +283,8 @@ public void readPdfWithOneNumberOneStringIdsTest() throws IOException{ } pdfDocument.close(); - Assert.assertNull(originalId); - Assert.assertNotNull(modifiedId); + Assertions.assertNull(originalId); + Assertions.assertNotNull(modifiedId); } @Test @@ -304,8 +303,8 @@ public void readPdfWithOneStringIdValueTest() throws IOException{ } pdfDocument.close(); - Assert.assertNull(originalId); - Assert.assertNull(modifiedId); + Assertions.assertNull(originalId); + Assertions.assertNull(modifiedId); } @Test @@ -324,8 +323,8 @@ public void readPdfWithOneNumberIdValueTest() throws IOException{ } pdfDocument.close(); - Assert.assertNull(originalId); - Assert.assertNull(modifiedId); + Assertions.assertNull(originalId); + Assertions.assertNull(modifiedId); } @Test @@ -346,11 +345,11 @@ public void readPdfWithNoIdTest() throws IOException{ } pdfDocument.close(); - Assert.assertNull(originalId); - Assert.assertNull(modifiedId); + Assertions.assertNull(originalId); + Assertions.assertNull(modifiedId); - Assert.assertEquals(0, reader.getOriginalFileId().length); - Assert.assertEquals(0, reader.getModifiedFileId().length); + Assertions.assertEquals(0, reader.getOriginalFileId().length); + Assertions.assertEquals(0, reader.getModifiedFileId().length); } @Test @@ -358,8 +357,8 @@ public void readPdfWithNoIdAndConservativeReadingTest() throws IOException{ try (PdfReader reader = new PdfReader(sourceFolder + "pdfWithNoId.pdf") .setStrictnessLevel(StrictnessLevel.CONSERVATIVE)) { - Exception e = Assert.assertThrows(PdfException.class, () -> new PdfDocument(reader)); - Assert.assertEquals(IoLogMessageConstant.DOCUMENT_IDS_ARE_CORRUPTED, e.getMessage()); + Exception e = Assertions.assertThrows(PdfException.class, () -> new PdfDocument(reader)); + Assertions.assertEquals(IoLogMessageConstant.DOCUMENT_IDS_ARE_CORRUPTED, e.getMessage()); } } @@ -383,8 +382,8 @@ public void readPdfWithNoIdAndConservativeReadingTest() throws IOException{ // PdfString originalId = new PdfString("Original ID 56789"); // PdfWriter initialWriter = CompareTool.createTestPdfWriter(baos, new WriterProperties().setInitialDocumentId(originalId)); // -// Assert.assertNotEquals(); -// Assert.assertEquals(); +// Assertions.assertNotEquals(); +// Assertions.assertEquals(); // // } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfDocumentInfoTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfDocumentInfoTest.java index c8a8b49bd3..3954d16e1f 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfDocumentInfoTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfDocumentInfoTest.java @@ -24,27 +24,26 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfDocumentInfoTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/kernel/pdf/PdfDocumentInfoTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/kernel/pdf/PdfDocumentInfoTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(destinationFolder); } @@ -60,9 +59,9 @@ public void documentInfoCreatePdf20() throws IOException, InterruptedException { document.close(); CompareTool ct = new CompareTool(); - Assert.assertNull(ct.compareByContent(outFile, cmpFile, destinationFolder, "diff_")); - Assert.assertNull(ct.compareDocumentInfo(outFile, cmpFile)); - Assert.assertNull(ct.compareXmp(outFile, cmpFile, true)); + Assertions.assertNull(ct.compareByContent(outFile, cmpFile, destinationFolder, "diff_")); + Assertions.assertNull(ct.compareDocumentInfo(outFile, cmpFile)); + Assertions.assertNull(ct.compareXmp(outFile, cmpFile, true)); } @Test @@ -75,9 +74,9 @@ public void documentInfoTransformPdf17ToPdf20() throws IOException, InterruptedE document.close(); CompareTool ct = new CompareTool(); - Assert.assertNull(ct.compareByContent(outFile, cmpFile, destinationFolder, "diff_")); - Assert.assertNull(ct.compareDocumentInfo(outFile, cmpFile)); - Assert.assertNull(ct.compareXmp(outFile, cmpFile, true)); + Assertions.assertNull(ct.compareByContent(outFile, cmpFile, destinationFolder, "diff_")); + Assertions.assertNull(ct.compareDocumentInfo(outFile, cmpFile)); + Assertions.assertNull(ct.compareXmp(outFile, cmpFile, true)); } @Test @@ -93,9 +92,9 @@ public void changeDocumentVersionAndInfoInAppendMode() throws IOException, Inter document.close(); CompareTool ct = new CompareTool(); - Assert.assertNull(ct.compareByContent(outFile, cmpFile, destinationFolder, "diff_")); - Assert.assertNull(ct.compareDocumentInfo(outFile, cmpFile)); - Assert.assertNull(ct.compareXmp(outFile, cmpFile, true)); + Assertions.assertNull(ct.compareByContent(outFile, cmpFile, destinationFolder, "diff_")); + Assertions.assertNull(ct.compareDocumentInfo(outFile, cmpFile)); + Assertions.assertNull(ct.compareXmp(outFile, cmpFile, true)); } @Test @@ -109,9 +108,9 @@ public void readInfoFromMetadata() throws IOException { document.close(); - Assert.assertEquals("Author", "Bruno Lowagie", author); - Assert.assertEquals("Title", "Hello World example", title); - Assert.assertEquals("Subject", "This example shows how to add metadata", subject); + Assertions.assertEquals("Bruno Lowagie", author, "Author"); + Assertions.assertEquals("Hello World example", title, "Title"); + Assertions.assertEquals("This example shows how to add metadata", subject, "Subject"); } @Test @@ -125,9 +124,9 @@ public void changeMetadataInAppendMode() throws IOException, InterruptedExceptio document.close(); CompareTool ct = new CompareTool(); - Assert.assertNull(ct.compareByContent(outFile, cmpFile, destinationFolder, "diff_")); - Assert.assertNull(ct.compareDocumentInfo(outFile, cmpFile)); - Assert.assertNull(ct.compareXmp(outFile, cmpFile, true)); + Assertions.assertNull(ct.compareByContent(outFile, cmpFile, destinationFolder, "diff_")); + Assertions.assertNull(ct.compareDocumentInfo(outFile, cmpFile)); + Assertions.assertNull(ct.compareXmp(outFile, cmpFile, true)); } @Test @@ -140,12 +139,12 @@ public void simpleStampingMetadataLeaveUnchanged() throws IOException, Interrupt String author = document.getDocumentInfo().getAuthor(); document.close(); - Assert.assertEquals("Author", "Bruno Lowagie; Alexey Subach", author); + Assertions.assertEquals("Bruno Lowagie; Alexey Subach", author, "Author"); CompareTool ct = new CompareTool(); - Assert.assertNull(ct.compareByContent(outFile, cmpFile, destinationFolder, "diff_")); - Assert.assertNull(ct.compareDocumentInfo(outFile, cmpFile)); - Assert.assertNull(ct.compareXmp(outFile, cmpFile, true)); + Assertions.assertNull(ct.compareByContent(outFile, cmpFile, destinationFolder, "diff_")); + Assertions.assertNull(ct.compareDocumentInfo(outFile, cmpFile)); + Assertions.assertNull(ct.compareXmp(outFile, cmpFile, true)); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfDocumentTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfDocumentTest.java index 3c31db1bbc..02e69f54e1 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfDocumentTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfDocumentTest.java @@ -23,6 +23,7 @@ This file is part of the iText (R) project. package com.itextpdf.kernel.pdf; import com.itextpdf.commons.utils.FileUtil; +import com.itextpdf.commons.utils.MessageFormatUtil; import com.itextpdf.io.image.ImageDataFactory; import com.itextpdf.io.logs.IoLogMessageConstant; import com.itextpdf.io.source.DeflaterOutputStream; @@ -45,30 +46,29 @@ This file is part of the iText (R) project. import com.itextpdf.test.LogLevelConstants; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.BouncyCastleIntegrationTest; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.nio.charset.StandardCharsets; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(BouncyCastleIntegrationTest.class) +@Tag("BouncyCastleIntegrationTest") public class PdfDocumentTest extends ExtendedITextTest { public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/kernel/pdf/PdfDocumentTest/"; public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/kernel/pdf/PdfDocumentTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(DESTINATION_FOLDER); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(DESTINATION_FOLDER); } @@ -80,8 +80,8 @@ public void missingProducerTest() throws IOException { try (PdfDocument document = new PdfDocument(new PdfReader(inputFile), new PdfWriter(outputStream))) { PdfDocumentInfo documentInfo = document.getDocumentInfo(); - Assert.assertNull(documentInfo.getPdfObject().get(PdfName.Producer)); - Assert.assertNull(documentInfo.getProducer()); + Assertions.assertNull(documentInfo.getPdfObject().get(PdfName.Producer)); + Assertions.assertNull(documentInfo.getProducer()); } ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray()); @@ -89,8 +89,8 @@ public void missingProducerTest() throws IOException { try (PdfDocument document = new PdfDocument(new PdfReader(inputStream), new PdfWriter(new ByteArrayOutputStream()))) { PdfDocumentInfo documentInfo = document.getDocumentInfo(); - Assert.assertNotNull(documentInfo.getPdfObject().get(PdfName.Producer)); - Assert.assertNotNull(document.getDocumentInfo().getProducer()); + Assertions.assertNotNull(documentInfo.getPdfObject().get(PdfName.Producer)); + Assertions.assertNotNull(document.getDocumentInfo().getProducer()); } } @@ -101,16 +101,16 @@ public void nullProducerTest() throws IOException { try (PdfDocument document = new PdfDocument(new PdfReader(inputFile), new PdfWriter(outputStream))) { PdfDocumentInfo documentInfo = document.getDocumentInfo(); - Assert.assertEquals(PdfNull.PDF_NULL, documentInfo.getPdfObject().get(PdfName.Producer)); - Assert.assertNull(documentInfo.getProducer()); + Assertions.assertEquals(PdfNull.PDF_NULL, documentInfo.getPdfObject().get(PdfName.Producer)); + Assertions.assertNull(documentInfo.getProducer()); } ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray()); try (PdfDocument document = new PdfDocument(new PdfReader(inputStream), new PdfWriter(new ByteArrayOutputStream()))) { PdfDocumentInfo documentInfo = document.getDocumentInfo(); - Assert.assertNotNull(documentInfo.getPdfObject().get(PdfName.Producer)); - Assert.assertNotNull(document.getDocumentInfo().getProducer()); + Assertions.assertNotNull(documentInfo.getPdfObject().get(PdfName.Producer)); + Assertions.assertNotNull(document.getDocumentInfo().getProducer()); } } @@ -121,16 +121,16 @@ public void nameProducerTest() throws IOException { try (PdfDocument document = new PdfDocument(new PdfReader(inputFile), new PdfWriter(outputStream))) { PdfDocumentInfo documentInfo = document.getDocumentInfo(); - Assert.assertEquals(new PdfName("producerAsName"), documentInfo.getPdfObject().get(PdfName.Producer)); - Assert.assertNull(documentInfo.getProducer()); + Assertions.assertEquals(new PdfName("producerAsName"), documentInfo.getPdfObject().get(PdfName.Producer)); + Assertions.assertNull(documentInfo.getProducer()); } ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray()); try (PdfDocument document = new PdfDocument(new PdfReader(inputStream), new PdfWriter(new ByteArrayOutputStream()))) { PdfDocumentInfo documentInfo = document.getDocumentInfo(); - Assert.assertNotNull(documentInfo.getPdfObject().get(PdfName.Producer)); - Assert.assertNotNull(document.getDocumentInfo().getProducer()); + Assertions.assertNotNull(documentInfo.getPdfObject().get(PdfName.Producer)); + Assertions.assertNotNull(document.getDocumentInfo().getProducer()); } } @@ -142,13 +142,13 @@ public void writingVersionTest01() throws IOException { PdfDocument pdfDoc = new PdfDocument( CompareTool.createTestPdfWriter(out, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0))); - Assert.assertEquals(PdfVersion.PDF_2_0, pdfDoc.getPdfVersion()); + Assertions.assertEquals(PdfVersion.PDF_2_0, pdfDoc.getPdfVersion()); pdfDoc.addNewPage(); pdfDoc.close(); PdfDocument assertPdfDoc = new PdfDocument(CompareTool.createOutputReader(out)); - Assert.assertEquals(PdfVersion.PDF_2_0, assertPdfDoc.getPdfVersion()); + Assertions.assertEquals(PdfVersion.PDF_2_0, assertPdfDoc.getPdfVersion()); assertPdfDoc.close(); } @@ -195,7 +195,7 @@ public void addOutlinesWithNamedDestinations01() throws IOException, Interrupted thirdOutline.addDestination(PdfDestination.makeDestination(new PdfString("test3"))); pdfDoc.close(); - Assert.assertNull(new CompareTool() + Assertions.assertNull(new CompareTool() .compareByContent(filename, SOURCE_FOLDER + "cmp_outlinesWithNamedDestinations01.pdf", DESTINATION_FOLDER, "diff_")); @@ -208,7 +208,7 @@ public void freeReferencesInObjectStream() throws IOException { PdfDocument document = new PdfDocument(reader, writer, new StampingProperties().useAppendMode()); PdfDictionary dict = new PdfDictionary(); dict.makeIndirect(document); - Assert.assertTrue(dict.getIndirectReference().getObjNumber() > 0); + Assertions.assertTrue(dict.getIndirectReference().getObjNumber() > 0); } @Test @@ -226,12 +226,12 @@ public void removeUnusedObjectsInWriterModeTest() throws IOException { unusedDictionary.makeIndirect(pdfDocument); - Assert.assertEquals(pdfDocument.getXref().size(), 8); + Assertions.assertEquals(pdfDocument.getXref().size(), 8); //on closing, all unused objects shall not be written to resultant document pdfDocument.close(); PdfDocument testerDocument = new PdfDocument(CompareTool.createOutputReader(DESTINATION_FOLDER + filename)); - Assert.assertEquals(testerDocument.getXref().size(), 6); + Assertions.assertEquals(testerDocument.getXref().size(), 6); testerDocument.close(); } @@ -254,12 +254,12 @@ public void removeUnusedObjectsInStampingModeTest() throws IOException { PdfDocument doc = new PdfDocument(CompareTool.createOutputReader(DESTINATION_FOLDER + filenameIn), CompareTool.createTestPdfWriter(DESTINATION_FOLDER + filenameOut)); - Assert.assertEquals(doc.getXref().size(), 8); + Assertions.assertEquals(doc.getXref().size(), 8); //on closing, all unused objects shall not be written to resultant document doc.close(); PdfDocument testerDocument = new PdfDocument(CompareTool.createOutputReader(DESTINATION_FOLDER + filenameOut)); - Assert.assertEquals(testerDocument.getXref().size(), 6); + Assertions.assertEquals(testerDocument.getXref().size(), 6); testerDocument.close(); } @@ -279,12 +279,12 @@ public void addUnusedObjectsInWriterModeTest() throws IOException { unusedDictionary.makeIndirect(pdfDocument); - Assert.assertEquals(pdfDocument.getXref().size(), 8); + Assertions.assertEquals(pdfDocument.getXref().size(), 8); pdfDocument.setFlushUnusedObjects(true); pdfDocument.close(); PdfDocument testerDocument = new PdfDocument(CompareTool.createOutputReader(DESTINATION_FOLDER + filename)); - Assert.assertEquals(testerDocument.getXref().size(), 8); + Assertions.assertEquals(testerDocument.getXref().size(), 8); testerDocument.close(); } @@ -307,12 +307,12 @@ public void addUnusedObjectsInStampingModeTest() throws IOException { PdfDocument doc = new PdfDocument(CompareTool.createOutputReader(DESTINATION_FOLDER + filenameIn), CompareTool.createTestPdfWriter(DESTINATION_FOLDER + filenameOut)); - Assert.assertEquals(doc.getXref().size(), 8); + Assertions.assertEquals(doc.getXref().size(), 8); doc.setFlushUnusedObjects(true); doc.close(); PdfDocument testerDocument = new PdfDocument(CompareTool.createOutputReader(DESTINATION_FOLDER + filenameOut)); - Assert.assertEquals(testerDocument.getXref().size(), 8); + Assertions.assertEquals(testerDocument.getXref().size(), 8); testerDocument.close(); } @@ -335,7 +335,7 @@ public void addUnusedStreamObjectsTest() throws IOException { pdfDocument.close(); PdfDocument testerDocument = new PdfDocument(CompareTool.createOutputReader(DESTINATION_FOLDER + filenameIn)); - Assert.assertEquals(testerDocument.getXref().size(), 9); + Assertions.assertEquals(testerDocument.getXref().size(), 9); testerDocument.close(); } @@ -353,7 +353,7 @@ public void testImageCompressLevel() throws IOException { DeflaterOutputStream zip2 = new DeflaterOutputStream(byteArrayStream2, -1); image.writeTo(zip2); - Assert.assertTrue(byteArrayStream1.size() == byteArrayStream2.size()); + Assertions.assertTrue(byteArrayStream1.size() == byteArrayStream2.size()); zip.close(); zip2.close(); } @@ -371,7 +371,7 @@ public void testFreeReference() throws IOException, InterruptedException { pdfStream.makeIndirect(pdfDocument); pdfDocument.getPage(1).getResources().getPdfObject().getAsArray(new PdfName("d")).add(pdfStream); pdfDocument.close(); - Assert.assertNull(new CompareTool() + Assertions.assertNull(new CompareTool() .compareByContent(DESTINATION_FOLDER + "freeReference.pdf", SOURCE_FOLDER + "cmp_freeReference.pdf", DESTINATION_FOLDER, "diff_")); } @@ -395,12 +395,12 @@ public void fullCompressionAppendMode() throws IOException, InterruptedException pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + "fullCompressionAppendMode.pdf", + Assertions.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + "fullCompressionAppendMode.pdf", SOURCE_FOLDER + "cmp_fullCompressionAppendMode.pdf", DESTINATION_FOLDER, "diff_")); PdfDocument assertDoc = new PdfDocument(CompareTool.createOutputReader(DESTINATION_FOLDER + "fullCompressionAppendMode.pdf")); - Assert.assertTrue(assertDoc.getPdfObject(9).isStream()); - Assert.assertEquals(1, ((PdfDictionary) assertDoc.getPdfObject(9)).getAsNumber(PdfName.N).intValue()); + Assertions.assertTrue(assertDoc.getPdfObject(9).isStream()); + Assertions.assertEquals(1, ((PdfDictionary) assertDoc.getPdfObject(9)).getAsNumber(PdfName.N).intValue()); } @Test @@ -410,7 +410,7 @@ public void checkAndResolveCircularReferences() throws IOException, InterruptedE PdfDictionary pdfObject = (PdfDictionary) pdfDocument.getPdfObject(53); pdfDocument.getPage(1).getResources().addForm((PdfStream) pdfObject); pdfDocument.close(); - Assert.assertNull(new CompareTool() + Assertions.assertNull(new CompareTool() .compareByContent(DESTINATION_FOLDER + "datasheet_mode.pdf", SOURCE_FOLDER + "cmp_datasheet_mode.pdf", DESTINATION_FOLDER, "diff_")); } @@ -427,10 +427,10 @@ public void readEncryptedDocumentWithFullCompression() throws IOException { PdfDictionary field = form.getAsArray(PdfName.Fields).getAsDictionary(0); - Assert.assertEquals("ch", field.getAsString(PdfName.T).toUnicodeString()); - Assert.assertEquals("SomeStringValueInDictionary", + Assertions.assertEquals("ch", field.getAsString(PdfName.T).toUnicodeString()); + Assertions.assertEquals("SomeStringValueInDictionary", field.getAsDictionary(new PdfName("TestDic")).getAsString(new PdfName("TestString")).toUnicodeString()); - Assert.assertEquals("SomeStringValueInArray", + Assertions.assertEquals("SomeStringValueInArray", field.getAsArray(new PdfName("TestArray")).getAsString(0).toUnicodeString()); pdfDocument.close(); } @@ -458,7 +458,7 @@ public void addAssociatedFilesTest01() throws IOException, InterruptedException pdfDocument.getFirstPage().addAnnotation(textannot); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + "add_associated_files01.pdf", + Assertions.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + "add_associated_files01.pdf", SOURCE_FOLDER + "cmp_add_associated_files01.pdf", DESTINATION_FOLDER, "diff_")); } @@ -490,7 +490,7 @@ public void addAssociatedFilesTest02() throws IOException, InterruptedException pageCanvas.addXObjectAt(formXObject, 40, 100); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + "add_associated_files02.pdf", + Assertions.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + "add_associated_files02.pdf", SOURCE_FOLDER + "cmp_add_associated_files02.pdf", DESTINATION_FOLDER, "diff_")); } @@ -500,8 +500,8 @@ public void ignoreTagStructureTest() throws IOException { PdfDocument doNotIgnoreTagStructureDocument = new PdfDocument(new PdfReader(srcFile)); IgnoreTagStructurePdfDocument ignoreTagStructureDocument = new IgnoreTagStructurePdfDocument( new PdfReader(srcFile)); - Assert.assertTrue(doNotIgnoreTagStructureDocument.isTagged()); - Assert.assertFalse(ignoreTagStructureDocument.isTagged()); + Assertions.assertTrue(doNotIgnoreTagStructureDocument.isTagged()); + Assertions.assertFalse(ignoreTagStructureDocument.isTagged()); doNotIgnoreTagStructureDocument.close(); ignoreTagStructureDocument.close(); @@ -522,7 +522,7 @@ public void removePageWithInvalidOutlineTest() throws IOException, InterruptedEx document.removePage(4); document.close(); - Assert.assertNull(new CompareTool().compareByContent(destination, cmp, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destination, cmp, DESTINATION_FOLDER, "diff_")); } @Test @@ -533,7 +533,7 @@ public void removePageWithInvalidOutlineTest() throws IOException, InterruptedEx public void openDocumentWithInvalidCatalogVersionTest() throws IOException { try (PdfReader reader = new PdfReader(SOURCE_FOLDER + "sample-with-invalid-catalog-version.pdf"); PdfDocument pdfDocument = new PdfDocument(reader)) { - Assert.assertNotNull(pdfDocument); + Assertions.assertNotNull(pdfDocument); } } @@ -542,10 +542,10 @@ public void openDocumentWithInvalidCatalogVersionAndConservativeStrictnessReadin try (PdfReader reader = new PdfReader(SOURCE_FOLDER + "sample-with-invalid-catalog-version.pdf") .setStrictnessLevel(StrictnessLevel.CONSERVATIVE)) { - Exception e = Assert.assertThrows(PdfException.class, + Exception e = Assertions.assertThrows(PdfException.class, () -> new PdfDocument(reader) ); - Assert.assertEquals(IoLogMessageConstant.DOCUMENT_VERSION_IN_CATALOG_CORRUPTED, e.getMessage()); + Assertions.assertEquals(IoLogMessageConstant.DOCUMENT_VERSION_IN_CATALOG_CORRUPTED, e.getMessage()); } } @@ -557,7 +557,7 @@ public void widgetDaEntryRemovePageTest() throws IOException, InterruptedExcepti new PdfReader(SOURCE_FOLDER + "widgetWithDaEntry.pdf"), CompareTool.createTestPdfWriter(outPdf))) { pdfDocument.removePage(3); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, SOURCE_FOLDER + "cmp_" + testName, + Assertions.assertNull(new CompareTool().compareByContent(outPdf, SOURCE_FOLDER + "cmp_" + testName, DESTINATION_FOLDER)); } @@ -569,7 +569,7 @@ public void mergedAndSimpleWidgetsRemovePageTest() throws IOException, Interrupt new PdfReader(SOURCE_FOLDER + "mergedAndSimpleWidgets.pdf"), CompareTool.createTestPdfWriter(outPdf))) { pdfDocument.removePage(1); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, SOURCE_FOLDER + "cmp_" + testName, + Assertions.assertNull(new CompareTool().compareByContent(outPdf, SOURCE_FOLDER + "cmp_" + testName, DESTINATION_FOLDER)); } @@ -581,18 +581,18 @@ public void mergedSiblingWidgetsRemovePageTest() throws IOException, Interrupted new PdfReader(SOURCE_FOLDER + "mergedSiblingWidgets.pdf"), CompareTool.createTestPdfWriter(outPdf))) { pdfDocument.removePage(2); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, SOURCE_FOLDER + "cmp_" + testName, + Assertions.assertNull(new CompareTool().compareByContent(outPdf, SOURCE_FOLDER + "cmp_" + testName, DESTINATION_FOLDER)); } @Test @LogMessages(messages = @LogMessage(messageTemplate = - IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT)) + IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT_WITH_CAUSE)) public void rootCannotBeReferenceFromTrailerTest() throws IOException { String filename = SOURCE_FOLDER + "rootCannotBeReferenceFromTrailerTest.pdf"; PdfReader corruptedReader = new PdfReader(filename); - Exception e = Assert.assertThrows(PdfException.class, () -> new PdfDocument(corruptedReader)); - Assert.assertEquals(KernelExceptionMessageConstant.CORRUPTED_ROOT_ENTRY_IN_TRAILER, e.getMessage()); + Exception e = Assertions.assertThrows(PdfException.class, () -> new PdfDocument(corruptedReader)); + Assertions.assertEquals(KernelExceptionMessageConstant.CORRUPTED_ROOT_ENTRY_IN_TRAILER, e.getMessage()); } @Test @@ -600,21 +600,94 @@ public void setSerializeOptionsTest() { PdfDocument document = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); SerializeOptions options = new SerializeOptions().setUseCanonicalFormat(true); document.setSerializeOptions(options); - Assert.assertEquals(options, document.getSerializeOptions()); + Assertions.assertEquals(options, document.getSerializeOptions()); } @Test public void getDiContainer() { PdfDocument document = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); - Assert.assertNotNull(document.getDiContainer()); + Assertions.assertNotNull(document.getDiContainer()); } @Test public void getDefaultConformanceLevelTest() { PdfDocument document = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); - Assert.assertNull(document.getConformanceLevel()); + Assertions.assertNotNull(document.getConformance()); + Assertions.assertFalse(document.getConformance().isPdfAOrUa()); } + //TODO DEVSIX-8490 remove this test when implemented + @Test + @LogMessages(messages = @LogMessage(messageTemplate = + KernelLogMessageConstant.DUPLICATE_ENTRIES_IN_ORDER_ARRAY_REMOVED)) + public void removeDuplicatesInOrderArrayTest() throws IOException, InterruptedException { + String inputPdf = "removeDuplicatesInOrderArray.pdf"; + String outputPdf = "removedDuplicateInOrderArray.pdf"; + PdfDocument doc = new PdfDocument(new PdfReader(SOURCE_FOLDER + inputPdf) + , CompareTool.createTestPdfWriter(DESTINATION_FOLDER + outputPdf)); + //Need to update OCProperties + doc.getCatalog().getOCProperties(false); + doc.close(); + + Assertions.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + outputPdf, SOURCE_FOLDER + "cmp_" + outputPdf, + DESTINATION_FOLDER)); + } + + //TODO DEVSIX-8490 remove this test when implemented + @Test + @LogMessages(messages = @LogMessage(messageTemplate = + KernelLogMessageConstant.DUPLICATE_ENTRIES_IN_ORDER_ARRAY_REMOVED)) + public void removeNestedDuplicatesInOrderArrayTest() throws IOException, InterruptedException { + String inputPdf = "removeNestedDuplicatesInOrderArray.pdf"; + String outputPdf = "removedNestedDuplicatesInOrderArray.pdf"; + PdfDocument doc = new PdfDocument(new PdfReader(SOURCE_FOLDER + inputPdf) + , new PdfWriter(DESTINATION_FOLDER + outputPdf)); + //Need to update OCProperties + doc.getCatalog().getOCProperties(false); + doc.close(); + + Assertions.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + outputPdf, SOURCE_FOLDER + "cmp_" + outputPdf, + DESTINATION_FOLDER)); + } + + //TODO DEVSIX-8490 remove this test when implemented + @Test + public void removeDuplicatesHasChildInOrderArrayTest() throws IOException, InterruptedException { + String inputPdf = "removeDuplicatesHasChildInOrderArray.pdf"; + String outputPdf = "removedDuplicatesHasChildInOrderArray.pdf"; + PdfDocument doc = new PdfDocument(new PdfReader(SOURCE_FOLDER + inputPdf) + , CompareTool.createTestPdfWriter(DESTINATION_FOLDER + outputPdf)); + PdfCatalog catalog = doc.getCatalog(); + Exception e = Assertions.assertThrows(PdfException.class, () -> catalog.getOCProperties(false)); + Assertions.assertEquals(MessageFormatUtil.format( + KernelExceptionMessageConstant.UNABLE_TO_REMOVE_DUPLICATE_LAYER, "4 0 R"), e.getMessage()); + } + + //TODO DEVSIX-8490 remove this test when implemented + @Test + public void removeNestedDuplicatesHasChildInOrderArrayTest() throws IOException, InterruptedException { + String inputPdf = "removeNestedDuplicatesHasChildInOrderArray.pdf"; + String outputPdf = "removedNestedDuplicatesHasChildInOrderArray.pdf"; + PdfDocument doc = new PdfDocument(new PdfReader(SOURCE_FOLDER + inputPdf) + , CompareTool.createTestPdfWriter(DESTINATION_FOLDER + outputPdf)); + PdfCatalog catalog = doc.getCatalog(); + Exception e = Assertions.assertThrows(PdfException.class, () -> catalog.getOCProperties(false)); + Assertions.assertEquals(MessageFormatUtil.format( + KernelExceptionMessageConstant.UNABLE_TO_REMOVE_DUPLICATE_LAYER, "27 0 R"), e.getMessage()); + } + + @Test + public void createPdfDocumentWithAAndUaMetadataTest() throws IOException, InterruptedException { + String outputPdf = "pdfDocWithAAndUaMetadata.pdf"; + final WriterProperties writerProperties = new WriterProperties().addPdfAXmpMetadata(PdfAConformance.PDF_A_3A) + .addPdfUaXmpMetadata(PdfUAConformance.PDF_UA_1); + PdfDocument doc = new PdfDocument(new PdfWriter(DESTINATION_FOLDER + outputPdf, writerProperties)); + doc.addNewPage(); + doc.close(); + + Assertions.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + outputPdf, + SOURCE_FOLDER + "cmp_" + outputPdf, DESTINATION_FOLDER)); + } private static class IgnoreTagStructurePdfDocument extends PdfDocument { diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfDocumentUnitTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfDocumentUnitTest.java index 7d88d42ed6..fb03374315 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfDocumentUnitTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfDocumentUnitTest.java @@ -33,25 +33,26 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.filespec.PdfFileSpec; import com.itextpdf.kernel.pdf.layer.PdfLayer; import com.itextpdf.kernel.pdf.layer.PdfOCProperties; -import com.itextpdf.kernel.utils.IValidationChecker; -import com.itextpdf.kernel.utils.ValidationContainer; -import com.itextpdf.kernel.utils.ValidationContext; +import com.itextpdf.kernel.validation.IValidationChecker; +import com.itextpdf.kernel.validation.IValidationContext; +import com.itextpdf.kernel.validation.ValidationContainer; +import com.itextpdf.kernel.validation.ValidationType; +import com.itextpdf.kernel.validation.context.PdfDocumentValidationContext; import com.itextpdf.test.AssertUtil; import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.LogLevelConstants; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.BouncyCastleUnitTest; import java.io.ByteArrayInputStream; import java.io.IOException; import java.util.ArrayList; import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(BouncyCastleUnitTest.class) +@Tag("BouncyCastleUnitTest") public class PdfDocumentUnitTest extends ExtendedITextTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/kernel/pdf/PdfDocumentUnitTest/"; @@ -73,13 +74,13 @@ public void getFontWithDirectFontDictionaryTest() { encoding.put(PdfName.Differences, differences); - Assert.assertNull(initialFontDict.getIndirectReference()); + Assertions.assertNull(initialFontDict.getIndirectReference()); try (PdfDocument doc = new PdfDocument(new PdfWriter(new ByteArrayOutputStream()))) { // prevent no pages exception on close doc.addNewPage(); PdfType3Font font1 = (PdfType3Font) doc.getFont(initialFontDict); - Assert.assertNotNull(font1); + Assertions.assertNotNull(font1); // prevent no glyphs for type3 font on close font1.addGlyph('a', 0, 0, 0, 0, 0); @@ -209,112 +210,46 @@ public void copyPagesFlushedResources() throws IOException { outDocument.flushCopiedObjects(fromDocument); fromDocument.copyPagesTo(2, 2, outDocument); - Assert.assertNotNull(outDocument.getCatalog()); + Assertions.assertNotNull(outDocument.getCatalog()); PdfOCProperties ocProperties = outDocument.getCatalog().getOCProperties(false); - Assert.assertNotNull(ocProperties); - Assert.assertEquals(1, ocProperties.getLayers().size()); + Assertions.assertNotNull(ocProperties); + Assertions.assertEquals(1, ocProperties.getLayers().size()); PdfLayer layer = ocProperties.getLayers().get(0); - Assert.assertTrue(layer.getPdfObject().isFlushed()); + Assertions.assertTrue(layer.getPdfObject().isFlushed()); } } } - @Test - public void pdfDocumentInstanceNoWriterInfoAndConformanceLevelInitialization() throws IOException { - PdfDocument pdfDocument = new PdfDocument(new PdfReader(SOURCE_FOLDER + "pdfWithMetadata.pdf")); - - Assert.assertNull(pdfDocument.info); - Assert.assertNull(pdfDocument.reader.pdfAConformanceLevel); - - pdfDocument.close(); - - Assert.assertNull(pdfDocument.info); - Assert.assertNull(pdfDocument.reader.pdfAConformanceLevel); - } - - @Test - public void pdfDocumentInstanceWriterInfoAndConformanceLevelInitialization() throws IOException { - PdfDocument pdfDocument = new PdfDocument( - new PdfReader(SOURCE_FOLDER + "pdfWithMetadata.pdf"), new PdfWriter(new ByteArrayOutputStream())); - - Assert.assertNotNull(pdfDocument.info); - Assert.assertNull(pdfDocument.reader.pdfAConformanceLevel); - - pdfDocument.close(); - - Assert.assertNotNull(pdfDocument.info); - Assert.assertNull(pdfDocument.reader.pdfAConformanceLevel); - } - - @Test - public void extendedPdfDocumentNoWriterInfoAndConformanceLevelInitialization() throws IOException { - PdfDocument pdfDocument = new PdfDocument(new PdfReader(SOURCE_FOLDER + "pdfWithMetadata.pdf")) { - // This class instance extends pdfDocument - }; - - // TODO DEVSIX-5292 These fields shouldn't be initialized during the document's opening - Assert.assertNotNull(pdfDocument.info); - Assert.assertNotNull(pdfDocument.reader.pdfAConformanceLevel); - - pdfDocument.close(); - - Assert.assertNotNull(pdfDocument.info); - Assert.assertNotNull(pdfDocument.reader.pdfAConformanceLevel); - } - - @Test - public void extendedPdfDocumentWriterInfoAndConformanceLevelInitialization() throws IOException { - PdfDocument pdfDocument = new PdfDocument( - new PdfReader(SOURCE_FOLDER + "pdfWithMetadata.pdf"), new PdfWriter(new ByteArrayOutputStream())) { - // This class instance extends pdfDocument - }; - - Assert.assertNotNull(pdfDocument.info); - // TODO DEVSIX-5292 pdfAConformanceLevel shouldn't be initialized during the document's opening - Assert.assertNotNull(pdfDocument.reader.pdfAConformanceLevel); - - pdfDocument.close(); - - Assert.assertNotNull(pdfDocument.info); - Assert.assertNotNull(pdfDocument.reader.pdfAConformanceLevel); - } - @Test public void getDocumentInfoAlreadyClosedTest() throws IOException { PdfDocument pdfDocument = new PdfDocument(new PdfReader(SOURCE_FOLDER + "pdfWithMetadata.pdf")); pdfDocument.close(); - Assert.assertThrows(PdfException.class, () -> pdfDocument.getDocumentInfo()); + Assertions.assertThrows(PdfException.class, () -> pdfDocument.getDocumentInfo()); } @Test - public void getDocumentInfoNotInitializedTest() throws IOException { + public void getDocumentInfoInitializationTest() throws IOException { PdfDocument pdfDocument = new PdfDocument(new PdfReader(SOURCE_FOLDER + "pdfWithMetadata.pdf")); - - Assert.assertNull(pdfDocument.info); - Assert.assertNotNull(pdfDocument.getDocumentInfo()); - + Assertions.assertNotNull(pdfDocument.getDocumentInfo()); pdfDocument.close(); } @Test - public void getPdfAConformanceLevelNotInitializedTest() throws IOException { + public void getPdfAConformanceLevelInitializationTest() throws IOException { PdfDocument pdfDocument = new PdfDocument(new PdfReader(SOURCE_FOLDER + "pdfWithMetadata.pdf")); - - Assert.assertNull(pdfDocument.reader.pdfAConformanceLevel); - Assert.assertNotNull(pdfDocument.reader.getPdfAConformanceLevel()); - + Assertions.assertTrue(pdfDocument.reader.getPdfConformance().isPdfAOrUa()); pdfDocument.close(); } private static void assertLayerNames(PdfDocument outDocument, List layerNames) { - Assert.assertNotNull(outDocument.getCatalog()); + Assertions.assertNotNull(outDocument.getCatalog()); PdfOCProperties ocProperties = outDocument.getCatalog().getOCProperties(true); - Assert.assertNotNull(ocProperties); - Assert.assertEquals(layerNames.size(), ocProperties.getLayers().size()); + Assertions.assertNotNull(ocProperties); + Assertions.assertEquals(layerNames.size(), ocProperties.getLayers().size()); for (int i = 0; i < layerNames.size(); i++) { PdfLayer layer = ocProperties.getLayers().get(i); - Assert.assertNotNull(layer); + Assertions.assertNotNull(layer); PdfDocumentUnitTest.assertLayerNameEqual(layerNames.get(i), layer); } } @@ -348,18 +283,18 @@ private static byte[] initDocument(List names) throws IOException { private static void assertLayerNameEqual(String name, PdfLayer layer) { PdfDictionary layerDictionary = layer.getPdfObject(); - Assert.assertNotNull(layerDictionary); - Assert.assertNotNull(layerDictionary.get(PdfName.Name)); + Assertions.assertNotNull(layerDictionary); + Assertions.assertNotNull(layerDictionary.get(PdfName.Name)); String layerNameString = layerDictionary.get(PdfName.Name).toString(); - Assert.assertEquals(name, layerNameString); + Assertions.assertEquals(name, layerNameString); } @Test public void cannotGetTagStructureForUntaggedDocumentTest() { PdfDocument pdfDoc = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> pdfDoc.getTagStructureContext()); - Assert.assertEquals(KernelExceptionMessageConstant.MUST_BE_A_TAGGED_DOCUMENT, exception.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.MUST_BE_A_TAGGED_DOCUMENT, exception.getMessage()); } @Test @@ -367,9 +302,9 @@ public void cannotAddPageAfterDocumentIsClosedTest() { PdfDocument pdfDoc = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); pdfDoc.addNewPage(1); pdfDoc.close(); - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> pdfDoc.addNewPage(2)); - Assert.assertEquals(KernelExceptionMessageConstant.DOCUMENT_CLOSED_IT_IS_IMPOSSIBLE_TO_EXECUTE_ACTION, + Assertions.assertEquals(KernelExceptionMessageConstant.DOCUMENT_CLOSED_IT_IS_IMPOSSIBLE_TO_EXECUTE_ACTION, exception.getMessage()); } @@ -377,9 +312,9 @@ public void cannotAddPageAfterDocumentIsClosedTest() { public void cannotMovePageToZeroPositionTest() { PdfDocument pdfDoc = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); pdfDoc.addNewPage(); - Exception exception = Assert.assertThrows(IndexOutOfBoundsException.class, + Exception exception = Assertions.assertThrows(IndexOutOfBoundsException.class, () -> pdfDoc.movePage(1, 0)); - Assert.assertEquals( + Assertions.assertEquals( MessageFormatUtil.format(KernelExceptionMessageConstant.REQUESTED_PAGE_NUMBER_IS_OUT_OF_BOUNDS, 0), exception.getMessage()); } @@ -388,9 +323,9 @@ public void cannotMovePageToZeroPositionTest() { public void cannotMovePageToNegativePosition() { PdfDocument pdfDoc = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); pdfDoc.addNewPage(); - Exception exception = Assert.assertThrows(IndexOutOfBoundsException.class, + Exception exception = Assertions.assertThrows(IndexOutOfBoundsException.class, () -> pdfDoc.movePage(1, -1)); - Assert.assertEquals( + Assertions.assertEquals( MessageFormatUtil.format(KernelExceptionMessageConstant.REQUESTED_PAGE_NUMBER_IS_OUT_OF_BOUNDS, -1), exception.getMessage()); } @@ -399,9 +334,9 @@ public void cannotMovePageToNegativePosition() { public void cannotMovePageToOneMorePositionThanPagesNumberTest() { PdfDocument pdfDoc = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); pdfDoc.addNewPage(); - Exception exception = Assert.assertThrows(IndexOutOfBoundsException.class, + Exception exception = Assertions.assertThrows(IndexOutOfBoundsException.class, () -> pdfDoc.movePage(1, 3)); - Assert.assertEquals( + Assertions.assertEquals( MessageFormatUtil.format(KernelExceptionMessageConstant.REQUESTED_PAGE_NUMBER_IS_OUT_OF_BOUNDS, 3), exception.getMessage()); } @@ -411,9 +346,9 @@ public void cannotAddPageToAnotherDocumentTest() { PdfDocument pdfDoc1 = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); PdfDocument pdfDoc2 = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); pdfDoc1.addNewPage(1); - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> pdfDoc2.checkAndAddPage(1, pdfDoc1.getPage(1))); - Assert.assertEquals(MessageFormatUtil.format( + Assertions.assertEquals(MessageFormatUtil.format( KernelExceptionMessageConstant.PAGE_CANNOT_BE_ADDED_TO_DOCUMENT_BECAUSE_IT_BELONGS_TO_ANOTHER_DOCUMENT, pdfDoc1, 1, pdfDoc2), exception.getMessage()); } @@ -423,9 +358,9 @@ public void cannotAddPageToAnotherDocTest() { PdfDocument pdfDoc1 = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); PdfDocument pdfDoc2 = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); pdfDoc1.addNewPage(1); - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> pdfDoc2.checkAndAddPage(pdfDoc1.getPage(1))); - Assert.assertEquals(MessageFormatUtil.format( + Assertions.assertEquals(MessageFormatUtil.format( KernelExceptionMessageConstant.PAGE_CANNOT_BE_ADDED_TO_DOCUMENT_BECAUSE_IT_BELONGS_TO_ANOTHER_DOCUMENT, pdfDoc1, 1, pdfDoc2), exception.getMessage()); } @@ -433,9 +368,9 @@ public void cannotAddPageToAnotherDocTest() { @Test public void cannotSetEncryptedPayloadInReadingModeTest() throws IOException { PdfDocument pdfDoc = new PdfDocument(new PdfReader(SOURCE_FOLDER + "setEncryptedPayloadInReadingModeTest.pdf")); - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> pdfDoc.setEncryptedPayload(null)); - Assert.assertEquals( + Assertions.assertEquals( KernelExceptionMessageConstant.CANNOT_SET_ENCRYPTED_PAYLOAD_TO_DOCUMENT_OPENED_IN_READING_MODE, exception.getMessage()); } @@ -449,16 +384,17 @@ public void cannotSetEncryptedPayloadToEncryptedDocTest() { PdfDocument pdfDoc = new PdfDocument(new PdfWriter(new ByteArrayOutputStream(), writerProperties)); PdfFileSpec fs = PdfFileSpec .createExternalFileSpec(pdfDoc, SOURCE_FOLDER + "testPath"); - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> pdfDoc.setEncryptedPayload(fs)); - Assert.assertEquals(KernelExceptionMessageConstant.CANNOT_SET_ENCRYPTED_PAYLOAD_TO_ENCRYPTED_DOCUMENT, + Assertions.assertEquals(KernelExceptionMessageConstant.CANNOT_SET_ENCRYPTED_PAYLOAD_TO_ENCRYPTED_DOCUMENT, exception.getMessage()); } @Test public void checkEmptyIsoConformanceTest() { try (PdfDocument doc = new PdfDocument(new PdfWriter(new ByteArrayOutputStream()))) { - AssertUtil.doesNotThrow(() -> doc.checkIsoConformance()); + IValidationContext validationContext = new PdfDocumentValidationContext(doc, doc.getDocumentFonts()); + AssertUtil.doesNotThrow(() -> doc.checkIsoConformance(validationContext)); } } @@ -469,25 +405,26 @@ public void checkIsoConformanceTest() { final CustomValidationChecker checker = new CustomValidationChecker(); container.addChecker(checker); doc.getDiContainer().register(ValidationContainer.class, container); - Assert.assertFalse(checker.documentValidationPerformed); - doc.checkIsoConformance(); - Assert.assertTrue(checker.documentValidationPerformed); + Assertions.assertFalse(checker.documentValidationPerformed); + IValidationContext validationContext = new PdfDocumentValidationContext(doc, doc.getDocumentFonts()); + doc.checkIsoConformance(validationContext); + Assertions.assertTrue(checker.documentValidationPerformed); } } private static class CustomValidationChecker implements IValidationChecker { public boolean documentValidationPerformed = false; - public boolean objectValidationPerformed = false; @Override - public void validateDocument(ValidationContext validationContext) { - documentValidationPerformed = true; + public void validate(IValidationContext validationContext) { + if (validationContext.getType() == ValidationType.PDF_DOCUMENT) { + documentValidationPerformed = true; + } } @Override - public void validateObject(Object obj, IsoKey key, PdfResources resources, PdfStream contentStream, - Object extra) { - objectValidationPerformed = true; + public boolean isPdfObjectReadyToFlush(PdfObject object) { + return true; } } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfEncryptionUnitTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfEncryptionUnitTest.java index 39c2c81ae1..e27593cacf 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfEncryptionUnitTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfEncryptionUnitTest.java @@ -23,12 +23,11 @@ This file is part of the iText (R) project. package com.itextpdf.kernel.pdf; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfEncryptionUnitTest extends ExtendedITextTest { @Test public void readEncryptEmbeddedFilesOnlyFromPdfDocumentCorrectEntryTest() { @@ -40,7 +39,7 @@ public void readEncryptEmbeddedFilesOnlyFromPdfDocumentCorrectEntryTest() { cfDictionary.put(PdfName.StdCF, new PdfDictionary()); cryptDictionary.put(PdfName.CF, cfDictionary); - Assert.assertTrue(PdfEncryption.readEmbeddedFilesOnlyFromEncryptDictionary(cryptDictionary)); + Assertions.assertTrue(PdfEncryption.readEmbeddedFilesOnlyFromEncryptDictionary(cryptDictionary)); } @Test @@ -53,7 +52,7 @@ public void readEncryptEmbeddedFilesOnlyFromPdfDocumentIncorrectEffTest() { cfDictionary.put(PdfName.StdCF, new PdfDictionary()); cryptDictionary.put(PdfName.CF, cfDictionary); - Assert.assertFalse(PdfEncryption.readEmbeddedFilesOnlyFromEncryptDictionary(cryptDictionary)); + Assertions.assertFalse(PdfEncryption.readEmbeddedFilesOnlyFromEncryptDictionary(cryptDictionary)); } @Test @@ -66,7 +65,7 @@ public void readEncryptEmbeddedFilesOnlyFromPdfDocumentIncorrectStmFTest() { cfDictionary.put(PdfName.StdCF, new PdfDictionary()); cryptDictionary.put(PdfName.CF, cfDictionary); - Assert.assertFalse(PdfEncryption.readEmbeddedFilesOnlyFromEncryptDictionary(cryptDictionary)); + Assertions.assertFalse(PdfEncryption.readEmbeddedFilesOnlyFromEncryptDictionary(cryptDictionary)); } @Test @@ -79,7 +78,7 @@ public void readEncryptEmbeddedFilesOnlyFromPdfDocumentIncorrectStrFTest() { cfDictionary.put(PdfName.StdCF, new PdfDictionary()); cryptDictionary.put(PdfName.CF, cfDictionary); - Assert.assertFalse(PdfEncryption.readEmbeddedFilesOnlyFromEncryptDictionary(cryptDictionary)); + Assertions.assertFalse(PdfEncryption.readEmbeddedFilesOnlyFromEncryptDictionary(cryptDictionary)); } @Test @@ -92,11 +91,11 @@ public void readEncryptEmbeddedFilesOnlyFromPdfDocumentIncorrectCfTest() { cfDictionary.put(PdfName.DefaultCryptFilter, new PdfDictionary()); cryptDictionary.put(PdfName.CF, cfDictionary); - Assert.assertFalse(PdfEncryption.readEmbeddedFilesOnlyFromEncryptDictionary(cryptDictionary)); + Assertions.assertFalse(PdfEncryption.readEmbeddedFilesOnlyFromEncryptDictionary(cryptDictionary)); } @Test - public void createIdNormalLength(){ + public void createIdNormalLength() { byte[] originalId = new byte[]{0x33, 0x39, 0x62, 0x38, 0x65, 0x61, 0x30, 0x33, 0x65, 0x32, 0x39, 0x31, 0x38, 0x32, 0x66, 0x31, 0x39, 0x63, 0x62, 0x65, 0x64, 0x32, 0x33, 0x37, 0x37, 0x33, 0x61, 0x63, 0x39, 0x65, 0x34, 0x39}; @@ -105,12 +104,12 @@ public void createIdNormalLength(){ 0x76, 0x30, (byte) 0x83, 0x49, 0x2F, 0x07, 0x61, (byte) 0xBC, (byte) 0xBA, 0x04, 0x37, 0x1B, 0x0E, (byte) 0x80, 0x34, 0x30, 0x4A, 0x3B, 0x0E, 0x27, 0x4F, 0x01, 0x1D, 0x36, 0x71, 0x7A, 0x42, 0x2B, 0x2C, 0x14, 0x6A, 0x52, 0x07, 0x1E, 0x4C}; - PdfObject fileId = PdfEncryption.createInfoId(originalId,modifiedId); + PdfObject fileId = PdfEncryption.createInfoId(originalId, modifiedId, false); PdfObject expectedFileId = new PdfLiteral("[<3339623865613033653239313832663139636265643233373733616" + "339653439><082704302042226a5f405657444a6e1c187671803780715c687e3541763083492f0761bcba04371b0e80343" + "04a3b0e274f011d36717a422b2c146a52071e4c>]"); - Assert.assertEquals(expectedFileId,fileId); + Assertions.assertEquals(expectedFileId, fileId); } @Test @@ -134,7 +133,7 @@ public void createIdNormalLengthWithoutPreserveEncryption(){ "62aab38fe1bb4a00caf3fed9903889d055fe15c99c430345cea6883d2ec147752bea504470701>]"); - Assert.assertEquals(expectedFileId,fileId); + Assertions.assertEquals(expectedFileId,fileId); } @Test @@ -159,7 +158,7 @@ public void createINormalLengthWithPreserveEncryption(){ "ffe638b782848af59cddf679381aada88823c0a38c1b43283b3a2a272019a85ed3d6f504fa5e14c1f9de77c8936db3e9df" + "805d210d>]"); - Assert.assertEquals(expectedFileId,fileId); + Assertions.assertEquals(expectedFileId,fileId); } @Test @@ -171,7 +170,7 @@ public void createIdShortLengthWithoutPreserveEncryption(){ PdfObject expectedFileId = new PdfLiteral("[]"); - Assert.assertEquals(expectedFileId,fileId); + Assertions.assertEquals(expectedFileId,fileId); } @Test @@ -183,6 +182,6 @@ public void createIdShortLengthWithPreserveEncryption(){ PdfObject fileId = PdfEncryption.createInfoId(originalId,modifiedId,true); PdfObject expectedFileId = new PdfLiteral("[<3b0d7aede4a34ba612240c65><4e844fc286503a6c82dfab7d168075>]"); - Assert.assertEquals(expectedFileId,fileId); + Assertions.assertEquals(expectedFileId,fileId); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfEncryptorTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfEncryptorTest.java index a52fa471a5..b1c38cd961 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfEncryptorTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfEncryptorTest.java @@ -27,24 +27,23 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.BouncyCastleIntegrationTest; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(BouncyCastleIntegrationTest.class) +@Tag("BouncyCastleIntegrationTest") public class PdfEncryptorTest extends ExtendedITextTest { public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/kernel/pdf/PdfEncryptorTest/"; public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/kernel/pdf/PdfEncryptorTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(DESTINATION_FOLDER); } @@ -70,6 +69,6 @@ public void encryptFileTest() throws IOException { PdfReader outFile = new PdfReader(outFileName, readerProperties); PdfDocument doc = new PdfDocument(outFile); doc.close(); - Assert.assertTrue(outFile.isEncrypted()); + Assertions.assertTrue(outFile.isEncrypted()); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfExtGStateTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfExtGStateTest.java index f97c442cdc..cfb2fdd06b 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfExtGStateTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfExtGStateTest.java @@ -29,26 +29,25 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.extgstate.PdfExtGState; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfExtGStateTest extends ExtendedITextTest{ public static final String sourceFolder = "./src/test/resources/com/itextpdf/kernel/pdf/PdfExtGStateTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/kernel/PdfExtGStateTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(destinationFolder); } @@ -97,7 +96,59 @@ public void egsTest1() throws Exception { page.flush(); document.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationDocument, sourceFolder + "cmp_egsTest1.pdf", destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destinationDocument, sourceFolder + "cmp_egsTest1.pdf", destinationFolder, "diff_")); } + @Test + public void blackPointCompensationTest1() { + PdfExtGState pdfExtGState = new PdfExtGState(); + pdfExtGState.setUseBlackPointCompensation(true); + Assertions.assertTrue(pdfExtGState.isBlackPointCompensationUsed()); + } + + @Test + public void blackPointCompensationTest2() { + PdfExtGState pdfExtGState = new PdfExtGState(); + pdfExtGState.setUseBlackPointCompensation(false); + Assertions.assertFalse(pdfExtGState.isBlackPointCompensationUsed()); + } + + @Test + public void blackPointCompensationTest3() { + PdfExtGState pdfExtGState = new PdfExtGState(); + PdfObject useBlackPoint = pdfExtGState.getPdfObject().getAsName(PdfName.UseBlackPtComp); + Assertions.assertNull(useBlackPoint); + } + + @Test + public void blackPointCompensationTest4() { + PdfExtGState pdfExtGState = new PdfExtGState(); + PdfDictionary pdfExtGStateObj = pdfExtGState.getPdfObject(); + pdfExtGStateObj.put(PdfName.UseBlackPtComp, PdfName.ON); + Assertions.assertTrue(pdfExtGState.isBlackPointCompensationUsed()); + } + + @Test + public void blackPointCompensationTest5() { + PdfExtGState pdfExtGState = new PdfExtGState(); + PdfDictionary pdfExtGStateObj = pdfExtGState.getPdfObject(); + pdfExtGStateObj.put(PdfName.UseBlackPtComp, PdfName.OFF); + Assertions.assertFalse(pdfExtGState.isBlackPointCompensationUsed()); + } + + @Test + public void blackPointCompensationTest6() { + PdfExtGState pdfExtGState = new PdfExtGState(); + pdfExtGState.setUseBlackPointCompensation(true); + PdfName useBlackPtComp = pdfExtGState.getPdfObject().getAsName(PdfName.UseBlackPtComp); + Assertions.assertEquals(PdfName.ON, useBlackPtComp, "PdfName is different from expected."); + } + + @Test + public void blackPointCompensationTest7() { + PdfExtGState pdfExtGState = new PdfExtGState(); + pdfExtGState.setUseBlackPointCompensation(false); + PdfName useBlackPtComp = pdfExtGState.getPdfObject().getAsName(PdfName.UseBlackPtComp); + Assertions.assertEquals(PdfName.OFF, useBlackPtComp, "PdfName is different from expected."); + } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfFontCacheTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfFontCacheTest.java index bdb8c5f35d..945aff663f 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfFontCacheTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfFontCacheTest.java @@ -32,20 +32,19 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.canvas.PdfCanvas; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.FileNotFoundException; import java.io.IOException; import java.util.HashSet; import java.util.Set; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfFontCacheTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/kernel/pdf/PdfFontCacheTest/"; private static final String fontsFolder = "./src/test/resources/com/itextpdf/kernel/pdf/fonts/"; @@ -55,12 +54,12 @@ public class PdfFontCacheTest extends ExtendedITextTest { static final String pangramme = "Amazingly few discotheques provide jukeboxes " + "but it now while sayingly ABEFGHJKNOPQRSTUWYZ?"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(destinationFolder); } @@ -81,8 +80,8 @@ public void createDocumentWithKozmin() throws IOException, InterruptedException addPagesWithFonts(pdfDoc, "KozMinPro-Regular", "Adobe-Japan1-0", TextSetChinese); pdfDoc.close(); - Assert.assertEquals(2, countPdfFonts(filename)); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertEquals(2, countPdfFonts(filename)); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @Test @@ -100,8 +99,8 @@ public void createDocumentWithHelveticaMixEncodings() throws IOException, Interr addPagesWithFonts(pdfDoc, font, "MacRoman", TextSetWithABC); pdfDoc.close(); - Assert.assertEquals(2, countPdfFonts(filename)); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertEquals(2, countPdfFonts(filename)); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @Test @@ -120,8 +119,8 @@ public void createDocumentWithHelvetica() throws IOException, InterruptedExcepti addPagesWithFonts(pdfDoc, font, encoding, TextSetWithABC); pdfDoc.close(); - Assert.assertEquals(1, countPdfFonts(filename)); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertEquals(1, countPdfFonts(filename)); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @Test @@ -143,8 +142,8 @@ public void createDocumentWithHelveticaFlushed() throws IOException, Interrupted pdfDoc.close(); //Flushed fonts cannot be reused. - Assert.assertEquals(3, countPdfFonts(filename)); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertEquals(3, countPdfFonts(filename)); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @Test @@ -165,8 +164,8 @@ public void createDocumentWithTimesAndCustomEncoding() throws IOException, Inter pdfDoc.close(); - Assert.assertEquals(1, countPdfFonts(filename)); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertEquals(1, countPdfFonts(filename)); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @Test @@ -188,8 +187,8 @@ public void createDocumentWithCourierAndWinAnsiEncodings() throws IOException, I pdfDoc.close(); - Assert.assertEquals(1, countPdfFonts(filename)); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertEquals(1, countPdfFonts(filename)); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @Test @@ -209,8 +208,8 @@ public void createDocumentWithAbserifAndIdentityHEncodings() throws IOException, pdfDoc.close(); - Assert.assertEquals(1, countPdfFonts(filename)); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertEquals(1, countPdfFonts(filename)); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @Test @@ -227,8 +226,8 @@ public void createDocumentWithEmbeddedAbserifFirstWinAnsiThenIdentityHEncodings( addPagesWithFonts(pdfDoc, font, "", TextSetWithABC); pdfDoc.close(); - Assert.assertEquals(2, countPdfFonts(filename)); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertEquals(2, countPdfFonts(filename)); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @Test @@ -245,8 +244,8 @@ public void createDocumentWithEmbeddedAbserifFirstIdentityHThenWinAnsiEncodings( addPagesWithFonts(pdfDoc, font, PdfEncodings.WINANSI, TextSetWithABC); pdfDoc.close(); - Assert.assertEquals(2, countPdfFonts(filename)); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertEquals(2, countPdfFonts(filename)); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @Test @@ -264,8 +263,8 @@ public void createDocumentWithNotEmbeddedAbserifFirstWinAnsiThenIdentityHEncodin addPagesWithFonts(pdfDoc, font, "", embeddingStrategy, TextSetWithABC); pdfDoc.close(); - Assert.assertEquals(2, countPdfFonts(filename)); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertEquals(2, countPdfFonts(filename)); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @Test @@ -283,8 +282,8 @@ public void createDocumentWithNotEmbeddedAbserifFirstIdentityHThenWinAnsiEncodin addPagesWithFonts(pdfDoc, font, PdfEncodings.WINANSI, embeddingStrategy, TextSetWithABC); pdfDoc.close(); - Assert.assertEquals(2, countPdfFonts(filename)); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertEquals(2, countPdfFonts(filename)); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @Test @@ -303,8 +302,8 @@ public void createDocumentWithTimesBoldAndMacRomanEncodings() throws IOException pdfDoc.close(); - Assert.assertEquals(1, countPdfFonts(filename)); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertEquals(1, countPdfFonts(filename)); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @Test @@ -323,8 +322,8 @@ public void createDocumentWithTrueTypeAsType0DefaultEncoding() throws IOExceptio addPagesWithFonts(pdfDoc, font, encoding, TextSetWithABC); pdfDoc.close(); - Assert.assertEquals(1, countPdfFonts(filename)); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertEquals(1, countPdfFonts(filename)); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @Test @@ -343,8 +342,8 @@ public void createDocumentWithTrueTypeAsTrueType() throws IOException, Interrupt addPagesWithFonts(pdfDoc, font, encoding, TextSetWithABC); pdfDoc.close(); - Assert.assertEquals(1, countPdfFonts(filename)); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertEquals(1, countPdfFonts(filename)); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @Test @@ -368,8 +367,8 @@ public void createDocumentWithTrueTypeFlushed() throws IOException, InterruptedE //Flushed fonts cannot be reused. //For some reason Acrobat shows only one font in Properties. //RUPS shows 3 instances of the same font. - Assert.assertEquals(3, countPdfFonts(filename)); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertEquals(3, countPdfFonts(filename)); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @Test @@ -388,8 +387,8 @@ public void createDocumentWithTrueTypeAsType0() throws IOException, InterruptedE addPagesWithFonts(pdfDoc, font, encoding, TextSetWithABC); pdfDoc.close(); - Assert.assertEquals(1, countPdfFonts(filename)); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertEquals(1, countPdfFonts(filename)); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @Test @@ -411,8 +410,8 @@ public void createDocumentWithTrueTypeAsType0Flushed() throws IOException, Inter pdfDoc.close(); //Flushed fonts cannot be reused. - Assert.assertEquals(3, countPdfFonts(filename)); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertEquals(3, countPdfFonts(filename)); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @Test @@ -431,8 +430,8 @@ public void createDocumentWithOpenTypeAsType0() throws IOException, InterruptedE addPagesWithFonts(pdfDoc, font, encoding, TextSetInternational); pdfDoc.close(); - Assert.assertEquals(1, countPdfFonts(filename)); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertEquals(1, countPdfFonts(filename)); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @Test @@ -454,8 +453,8 @@ public void createDocumentWithOpenTypeAsType0Flushed() throws IOException, Inter pdfDoc.close(); //Flushed fonts cannot be reused. - Assert.assertEquals(3, countPdfFonts(filename)); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertEquals(3, countPdfFonts(filename)); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @Test @@ -474,8 +473,8 @@ public void createDocumentWithHelveticaFromDocument() throws IOException, Interr String encoding = "WinAnsiEncoding"; PdfDictionary fontDict = (PdfDictionary) pdfDoc.getPdfObject(6); - Assert.assertEquals(font, fontDict.getAsName(PdfName.BaseFont).getValue()); - Assert.assertEquals(encoding, fontDict.getAsName(PdfName.Encoding).getValue()); + Assertions.assertEquals(font, fontDict.getAsName(PdfName.BaseFont).getValue()); + Assertions.assertEquals(encoding, fontDict.getAsName(PdfName.Encoding).getValue()); PdfFont documentFont = PdfFontFactory.createFont(fontDict); @@ -495,7 +494,7 @@ public void createDocumentWithHelveticaFromDocument() throws IOException, Interr .release(); //There is only one just loaded and used document font. - Assert.assertEquals(1, pdfDoc.getDocumentFonts().size()); + Assertions.assertEquals(1, pdfDoc.getDocumentFonts().size()); addPagesWithFonts(pdfDoc, font, "WinAnsi", TextSetWithABC); addPagesWithFonts(pdfDoc, font, null, TextSetWithABC); @@ -503,8 +502,8 @@ public void createDocumentWithHelveticaFromDocument() throws IOException, Interr //We cannot rely on font name for a document font, so we treat them as two different fonts. //However we're trying to detect standard fonts in this case, so it will work. - Assert.assertEquals(1, countPdfFonts(filename)); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertEquals(1, countPdfFonts(filename)); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @Test @@ -523,8 +522,8 @@ public void createDocumentWithHelveticaFromDocumentWithWrongEncoding() throws IO String encoding = "WinAnsiEncoding"; PdfDictionary fontDict = (PdfDictionary) pdfDoc.getPdfObject(6); - Assert.assertEquals(font, fontDict.getAsName(PdfName.BaseFont).getValue()); - Assert.assertEquals(encoding, fontDict.getAsName(PdfName.Encoding).getValue()); + Assertions.assertEquals(font, fontDict.getAsName(PdfName.BaseFont).getValue()); + Assertions.assertEquals(encoding, fontDict.getAsName(PdfName.Encoding).getValue()); PdfFont documentFont = PdfFontFactory.createFont(fontDict); @@ -544,15 +543,15 @@ public void createDocumentWithHelveticaFromDocumentWithWrongEncoding() throws IO .release(); //There is only one just loaded and used document font. - Assert.assertEquals(1, pdfDoc.getDocumentFonts().size()); + Assertions.assertEquals(1, pdfDoc.getDocumentFonts().size()); addPagesWithFonts(pdfDoc, font, null, TextSetWithABC); addPagesWithFonts(pdfDoc, font, "MacRoman", TextSetWithABC); pdfDoc.close(); //Two different encodings were used -> two fonts are expected. - Assert.assertEquals(2, countPdfFonts(filename)); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertEquals(2, countPdfFonts(filename)); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @Test public void createDocumentWithTrueTypeAboriginalFromDocument() throws IOException, InterruptedException { @@ -570,8 +569,8 @@ public void createDocumentWithTrueTypeAboriginalFromDocument() throws IOExceptio String encoding = "WinAnsiEncoding"; PdfDictionary fontDict = (PdfDictionary) pdfDoc.getPdfObject(6); - Assert.assertEquals(font, fontDict.getAsName(PdfName.BaseFont).getValue()); - Assert.assertEquals(encoding, fontDict.getAsName(PdfName.Encoding).getValue()); + Assertions.assertEquals(font, fontDict.getAsName(PdfName.BaseFont).getValue()); + Assertions.assertEquals(encoding, fontDict.getAsName(PdfName.Encoding).getValue()); PdfFont documentFont = PdfFontFactory.createFont(fontDict); @@ -590,14 +589,14 @@ public void createDocumentWithTrueTypeAboriginalFromDocument() throws IOExceptio .release(); //There is only one just loaded and used document font. - Assert.assertEquals(1, pdfDoc.getDocumentFonts().size()); + Assertions.assertEquals(1, pdfDoc.getDocumentFonts().size()); addPagesWithFonts(pdfDoc, fontsFolder + "abserif4_5.ttf", "WinAnsi", TextSetWithABC); pdfDoc.close(); //We cannot rely on font name for a document font, so we treat them as two different fonts. - Assert.assertEquals(2, countPdfFonts(filename)); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertEquals(2, countPdfFonts(filename)); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @Test @@ -616,8 +615,8 @@ public void createDocumentWithType1NotoFromDocument() throws IOException, Interr String encoding = "WinAnsiEncoding"; PdfDictionary fontDict = (PdfDictionary) pdfDoc.getPdfObject(6); - Assert.assertEquals(font, fontDict.getAsName(PdfName.BaseFont).getValue()); - Assert.assertEquals(encoding, fontDict.getAsName(PdfName.Encoding).getValue()); + Assertions.assertEquals(font, fontDict.getAsName(PdfName.BaseFont).getValue()); + Assertions.assertEquals(encoding, fontDict.getAsName(PdfName.Encoding).getValue()); PdfFont documentFont = PdfFontFactory.createFont(fontDict); @@ -636,15 +635,15 @@ public void createDocumentWithType1NotoFromDocument() throws IOException, Interr .release(); //There is only one just loaded and used document font. - Assert.assertEquals(1, pdfDoc.getDocumentFonts().size()); + Assertions.assertEquals(1, pdfDoc.getDocumentFonts().size()); addPagesWithFonts(pdfDoc, fontsFolder + "NotoSansCJKjp-Bold.otf", encoding, EmbeddingStrategy.FORCE_NOT_EMBEDDED, TextSetWithABC); pdfDoc.close(); //We cannot rely on font name for a document font, so we treat them as two different fonts. - Assert.assertEquals(2, countPdfFonts(filename)); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertEquals(2, countPdfFonts(filename)); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @Test @@ -663,8 +662,8 @@ public void createDocumentWithType0AboriginalFromDocument1() throws IOException, String encoding = "Identity-H"; PdfDictionary fontDict = (PdfDictionary) pdfDoc.getPdfObject(6); - Assert.assertEquals(font, fontDict.getAsName(PdfName.BaseFont).getValue()); - Assert.assertEquals(encoding, fontDict.getAsName(PdfName.Encoding).getValue()); + Assertions.assertEquals(font, fontDict.getAsName(PdfName.BaseFont).getValue()); + Assertions.assertEquals(encoding, fontDict.getAsName(PdfName.Encoding).getValue()); PdfFont documentFont = PdfFontFactory.createFont(fontDict); @@ -683,14 +682,14 @@ public void createDocumentWithType0AboriginalFromDocument1() throws IOException, .release(); //There is only one just loaded and used document font. - Assert.assertEquals(1, pdfDoc.getDocumentFonts().size()); + Assertions.assertEquals(1, pdfDoc.getDocumentFonts().size()); addPagesWithFonts(pdfDoc, fontsFolder + "abserif4_5.ttf", encoding, TextSetWithABC); pdfDoc.close(); //We cannot rely on font name for a document font, so we treat them as two different fonts. - Assert.assertEquals(2, countPdfFonts(filename)); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertEquals(2, countPdfFonts(filename)); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @Test @@ -709,8 +708,8 @@ public void createDocumentWithType0NotoFromDocument1() throws IOException, Inter String font = "NotoSansCJKjp-Bold-" + encoding; PdfDictionary fontDict = (PdfDictionary) pdfDoc.getPdfObject(6); - Assert.assertEquals(font, fontDict.getAsName(PdfName.BaseFont).getValue()); - Assert.assertEquals(encoding, fontDict.getAsName(PdfName.Encoding).getValue()); + Assertions.assertEquals(font, fontDict.getAsName(PdfName.BaseFont).getValue()); + Assertions.assertEquals(encoding, fontDict.getAsName(PdfName.Encoding).getValue()); PdfFont documentFont = PdfFontFactory.createFont(fontDict); @@ -729,15 +728,15 @@ public void createDocumentWithType0NotoFromDocument1() throws IOException, Inter .release(); //There is only one just loaded and used document font. - Assert.assertEquals(1, pdfDoc.getDocumentFonts().size()); + Assertions.assertEquals(1, pdfDoc.getDocumentFonts().size()); addPagesWithFonts(pdfDoc, fontsFolder + "NotoSansCJKjp-Bold.otf", PdfEncodings.WINANSI, EmbeddingStrategy.PREFER_NOT_EMBEDDED, TextSetWithABC); pdfDoc.close(); //We cannot rely on font name for a document font, so we treat them as two different fonts. - Assert.assertEquals(2, countPdfFonts(filename)); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertEquals(2, countPdfFonts(filename)); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @Test @@ -786,10 +785,10 @@ public void createDocumentWithType3Font() throws IOException, InterruptedExcepti pdfDoc.close(); //PdfType3Font comparing returns false; - Assert.assertEquals(2, countPdfFonts(filename)); + Assertions.assertEquals(2, countPdfFonts(filename)); // reading and comparing text - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } private void addPagesWithFonts(PdfDocument pdfDoc, String fontProgram, String fontEncoding, String[] text) throws IOException { @@ -829,7 +828,7 @@ private int countPdfFonts(String filename) throws IOException { return fonts.size(); } - private PdfDocument createDocument(String filename) throws FileNotFoundException { + private PdfDocument createDocument(String filename) throws IOException { PdfWriter writer = CompareTool.createTestPdfWriter(filename).setCompressionLevel(CompressionConstants.NO_COMPRESSION); return new PdfDocument(writer); } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfFontTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfFontTest.java index 7046f84ff8..d3bcff8673 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfFontTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfFontTest.java @@ -56,18 +56,17 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.FileInputStream; import java.io.IOException; import java.util.List; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfFontTest extends ExtendedITextTest { public static final int PageCount = 1; public static final String sourceFolder = "./src/test/resources/com/itextpdf/kernel/pdf/PdfFontTest/"; @@ -77,12 +76,12 @@ public class PdfFontTest extends ExtendedITextTest { static final String author = "Alexander Chingarev"; static final String creator = "iText"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(destinationFolder); } @@ -101,8 +100,8 @@ public void createDocumentWithKozmin() throws IOException, InterruptedException setCreator(creator). setTitle(title); PdfFont type0Font = PdfFontFactory.createFont("KozMinPro-Regular", "UniJIS-UCS2-H"); - Assert.assertTrue("Type0Font expected", type0Font instanceof PdfType0Font); - Assert.assertTrue("CidFont expected", type0Font.getFontProgram() instanceof CidFont); + Assertions.assertTrue(type0Font instanceof PdfType0Font, "Type0Font expected"); + Assertions.assertTrue(type0Font.getFontProgram() instanceof CidFont, "CidFont expected"); PdfPage page = pdfDoc.addNewPage(); PdfCanvas canvas = new PdfCanvas(page); canvas.saveState() @@ -116,7 +115,7 @@ public void createDocumentWithKozmin() throws IOException, InterruptedException canvas.release(); page.flush(); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @Test @@ -134,8 +133,8 @@ public void createDocumentWithKozminAndDifferentCodespaceRanges() throws IOExcep setTitle(title); PdfFont type0Font = PdfFontFactory.createFont("KozMinPro-Regular", "83pv-RKSJ-H", EmbeddingStrategy.PREFER_EMBEDDED); - Assert.assertTrue("Type0Font expected", type0Font instanceof PdfType0Font); - Assert.assertTrue("CidFont expected", type0Font.getFontProgram() instanceof CidFont); + Assertions.assertTrue(type0Font instanceof PdfType0Font, "Type0Font expected"); + Assertions.assertTrue(type0Font.getFontProgram() instanceof CidFont, "CidFont expected"); PdfPage page = pdfDoc.addNewPage(); PdfCanvas canvas = new PdfCanvas(page); canvas.saveState() @@ -148,7 +147,7 @@ public void createDocumentWithKozminAndDifferentCodespaceRanges() throws IOExcep canvas.release(); page.flush(); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @Test @@ -163,8 +162,8 @@ public void createDocumentWithStSongUni() throws IOException, InterruptedExcepti setCreator(creator). setTitle(title); PdfFont type0Font = PdfFontFactory.createFont("STSong-Light", "UniGB-UTF16-H"); - Assert.assertTrue("Type0Font expected", type0Font instanceof PdfType0Font); - Assert.assertTrue("CidFont expected", type0Font.getFontProgram() instanceof CidFont); + Assertions.assertTrue(type0Font instanceof PdfType0Font, "Type0Font expected"); + Assertions.assertTrue(type0Font.getFontProgram() instanceof CidFont, "CidFont expected"); PdfPage page = pdfDoc.addNewPage(); PdfCanvas canvas = new PdfCanvas(page); canvas.saveState() @@ -178,7 +177,7 @@ public void createDocumentWithStSongUni() throws IOException, InterruptedExcepti canvas.release(); page.flush(); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @@ -194,8 +193,8 @@ public void createDocumentWithStSong() throws IOException, InterruptedException setCreator(creator). setTitle(title); PdfFont type0Font = PdfFontFactory.createFont("STSong-Light", "Adobe-GB1-4"); - Assert.assertTrue("Type0Font expected", type0Font instanceof PdfType0Font); - Assert.assertTrue("CidFont expected", type0Font.getFontProgram() instanceof CidFont); + Assertions.assertTrue(type0Font instanceof PdfType0Font, "Type0Font expected"); + Assertions.assertTrue(type0Font.getFontProgram() instanceof CidFont, "CidFont expected"); PdfPage page = pdfDoc.addNewPage(); PdfCanvas canvas = new PdfCanvas(page); canvas.saveState() @@ -209,7 +208,7 @@ public void createDocumentWithStSong() throws IOException, InterruptedException canvas.release(); page.flush(); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @Test @@ -228,8 +227,8 @@ public void createDocumentWithTrueTypeAsType0() throws IOException, InterruptedE String font = fontsFolder + "abserif4_5.ttf"; PdfFont type0Font = PdfFontFactory.createFont(font, "Identity-H"); // type0Font.setSubset(false); - Assert.assertTrue("PdfType0Font expected", type0Font instanceof PdfType0Font); - Assert.assertTrue("TrueType expected", type0Font.getFontProgram() instanceof TrueTypeFont); + Assertions.assertTrue(type0Font instanceof PdfType0Font, "PdfType0Font expected"); + Assertions.assertTrue(type0Font.getFontProgram() instanceof TrueTypeFont, "TrueType expected"); PdfPage page = pdfDoc.addNewPage(); new PdfCanvas(page) .saveState() @@ -255,8 +254,8 @@ public void createDocumentWithTrueTypeAsType0() throws IOException, InterruptedE byte[] ttf = StreamUtil.inputStreamToArray(FileUtil.getInputStreamForFile(font)); type0Font = PdfFontFactory.createFont(ttf, "Identity-H"); - Assert.assertTrue("PdfType0Font expected", type0Font instanceof PdfType0Font); - Assert.assertTrue("TrueType expected", type0Font.getFontProgram() instanceof TrueTypeFont); + Assertions.assertTrue(type0Font instanceof PdfType0Font, "PdfType0Font expected"); + Assertions.assertTrue(type0Font.getFontProgram() instanceof TrueTypeFont, "TrueType expected"); page = pdfDoc.addNewPage(); new PdfCanvas(page) .saveState() @@ -271,7 +270,7 @@ public void createDocumentWithTrueTypeAsType0() throws IOException, InterruptedE page.flush(); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @Test @@ -296,13 +295,13 @@ public void createDocumentWithType3Font() throws IOException, InterruptedExcepti a.lineTo(595, 5); a.closePathFillStroke(); - Assert.assertEquals(600.0, getContentWidth(type3, 'A'), 1e-5); + Assertions.assertEquals(600.0, getContentWidth(type3, 'A'), 1e-5); Type3Glyph space = type3.addGlyph(' ', 600, 0, 0, 600, 700); space.setLineWidth(10); space.closePathFillStroke(); - Assert.assertEquals(600.0, getContentWidth(type3, ' '), 1e-5); + Assertions.assertEquals(600.0, getContentWidth(type3, ' '), 1e-5); Type3Glyph e = type3.addGlyph('E', 600, 0, 0, 600, 700); e.setLineWidth(100); @@ -313,7 +312,7 @@ public void createDocumentWithType3Font() throws IOException, InterruptedExcepti e.lineTo(595, 695); e.stroke(); - Assert.assertEquals(600.0, getContentWidth(type3, 'E'), 1e-5); + Assertions.assertEquals(600.0, getContentWidth(type3, 'E'), 1e-5); Type3Glyph tilde = type3.addGlyph('~', 600, 0, 0, 600, 700); tilde.setLineWidth(100); @@ -321,7 +320,7 @@ public void createDocumentWithType3Font() throws IOException, InterruptedExcepti tilde.lineTo(5, 5); tilde.stroke(); - Assert.assertEquals(600.0, getContentWidth(type3, '~'), 1e-5); + Assertions.assertEquals(600.0, getContentWidth(type3, '~'), 1e-5); Type3Glyph symbol233 = type3.addGlyph('\u00E9', 600, 0, 0, 600, 700); symbol233.setLineWidth(100); @@ -329,7 +328,7 @@ public void createDocumentWithType3Font() throws IOException, InterruptedExcepti symbol233.lineTo(5, 340); symbol233.stroke(); - Assert.assertEquals(600.0, getContentWidth(type3, '\u00E9'), 1e-5); + Assertions.assertEquals(600.0, getContentWidth(type3, '\u00E9'), 1e-5); pdfDoc.getDocumentInfo().setAuthor(author). setCreator(creator). @@ -349,7 +348,7 @@ public void createDocumentWithType3Font() throws IOException, InterruptedExcepti pdfDoc.close(); // reading and comparing text - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @Test @@ -363,7 +362,7 @@ public void notReplaceToUnicodeMappingTest() throws IOException { //should be another glyph defined in ToUnicode mapping Glyph glyph = pdfType3Font.getGlyph(32); - Assert.assertEquals(0, glyph.getWidth()); + Assertions.assertEquals(0, glyph.getWidth()); } } @@ -433,7 +432,7 @@ public void createTaggedDocumentWithType3Font() throws IOException, InterruptedE pdfDoc.close(); // reading and comparing text - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @Test @@ -453,7 +452,7 @@ public void createDocumentWithHelvetica() throws IOException, InterruptedExcepti PdfPage page = pdfDoc.addNewPage(); PdfCanvas canvas = new PdfCanvas(page); PdfFont pdfFont = PdfFontFactory.createFont(StandardFonts.HELVETICA); - Assert.assertTrue("PdfType1Font expected", pdfFont instanceof PdfType1Font); + Assertions.assertTrue(pdfFont instanceof PdfType1Font, "PdfType1Font expected"); canvas.saveState() .beginText() .moveText(36, 700) @@ -466,7 +465,7 @@ public void createDocumentWithHelvetica() throws IOException, InterruptedExcepti page.flush(); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @Test @@ -483,7 +482,7 @@ public void createDocumentWithHelveticaOblique() throws IOException, Interrupted setTitle(title); PdfFont pdfFont = PdfFontFactory.createFont(StandardFonts.HELVETICA_OBLIQUE); - Assert.assertTrue("PdfType1Font expected", pdfFont instanceof PdfType1Font); + Assertions.assertTrue(pdfFont instanceof PdfType1Font, "PdfType1Font expected"); PdfPage page = pdfDoc.addNewPage(); PdfCanvas canvas = new PdfCanvas(page); @@ -500,7 +499,7 @@ public void createDocumentWithHelveticaOblique() throws IOException, Interrupted page.flush(); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @Test @@ -518,7 +517,7 @@ public void createDocumentWithHelveticaBoldOblique() throws IOException, Interru setTitle(title); PdfFont pdfFont = PdfFontFactory.createFont(StandardFonts.HELVETICA_BOLDOBLIQUE); - Assert.assertTrue("PdfType1Font expected", pdfFont instanceof PdfType1Font); + Assertions.assertTrue(pdfFont instanceof PdfType1Font, "PdfType1Font expected"); PdfPage page = pdfDoc.addNewPage(); PdfCanvas canvas = new PdfCanvas(page); @@ -535,7 +534,7 @@ public void createDocumentWithHelveticaBoldOblique() throws IOException, Interru page.flush(); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @Test @@ -552,7 +551,7 @@ public void createDocumentWithCourierBold() throws IOException, InterruptedExcep setTitle(title); PdfFont pdfFont = PdfFontFactory.createFont(StandardFonts.COURIER_BOLD); - Assert.assertTrue("PdfType1Font expected", pdfFont instanceof PdfType1Font); + Assertions.assertTrue(pdfFont instanceof PdfType1Font, "PdfType1Font expected"); PdfPage page = pdfDoc.addNewPage(); PdfCanvas canvas = new PdfCanvas(page); @@ -569,7 +568,7 @@ public void createDocumentWithCourierBold() throws IOException, InterruptedExcep page.flush(); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @Test @@ -587,7 +586,7 @@ public void createDocumentWithType1FontAfm() throws IOException, InterruptedExce PdfFont pdfType1Font = PdfFontFactory.createFont(FontProgramFactory.createType1Font( fontsFolder + "cmr10.afm", fontsFolder + "cmr10.pfb"), FontEncoding.FONT_SPECIFIC, EmbeddingStrategy.PREFER_EMBEDDED); - Assert.assertTrue("PdfType1Font expected", pdfType1Font instanceof PdfType1Font); + Assertions.assertTrue(pdfType1Font instanceof PdfType1Font, "PdfType1Font expected"); new PdfCanvas(pdfDoc.addNewPage()) .saveState() @@ -603,7 +602,7 @@ public void createDocumentWithType1FontAfm() throws IOException, InterruptedExce byte[] pfb = StreamUtil.inputStreamToArray(FileUtil.getInputStreamForFile(fontsFolder + "cmr10.pfb")); pdfType1Font = PdfFontFactory.createFont(FontProgramFactory.createType1Font(afm, pfb), FontEncoding.FONT_SPECIFIC, EmbeddingStrategy.PREFER_EMBEDDED); - Assert.assertTrue("PdfType1Font expected", pdfType1Font instanceof PdfType1Font); + Assertions.assertTrue(pdfType1Font instanceof PdfType1Font, "PdfType1Font expected"); new PdfCanvas(pdfDoc.addNewPage()) .saveState() @@ -617,7 +616,7 @@ public void createDocumentWithType1FontAfm() throws IOException, InterruptedExce pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @Test @@ -650,7 +649,7 @@ public void createDocumentWithType1FontPfm() throws IOException, InterruptedExce page.flush(); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @@ -668,7 +667,7 @@ public void createDocumentWithTrueTypeFont1() throws IOException, InterruptedExc String font = fontsFolder + "abserif4_5.ttf"; PdfFont pdfTrueTypeFont = PdfFontFactory.createFont(font, PdfEncodings.WINANSI, EmbeddingStrategy.FORCE_EMBEDDED); - Assert.assertTrue("PdfTrueTypeFont expected", pdfTrueTypeFont instanceof PdfTrueTypeFont); + Assertions.assertTrue(pdfTrueTypeFont instanceof PdfTrueTypeFont, "PdfTrueTypeFont expected"); pdfTrueTypeFont.setSubset(true); PdfPage page = pdfDoc.addNewPage(); new PdfCanvas(page) @@ -686,7 +685,7 @@ public void createDocumentWithTrueTypeFont1() throws IOException, InterruptedExc byte[] ttf = StreamUtil.inputStreamToArray(FileUtil.getInputStreamForFile(font)); pdfTrueTypeFont = PdfFontFactory.createFont(ttf, PdfEncodings.WINANSI, EmbeddingStrategy.FORCE_EMBEDDED); - Assert.assertTrue("PdfTrueTypeFont expected", pdfTrueTypeFont instanceof PdfTrueTypeFont); + Assertions.assertTrue(pdfTrueTypeFont instanceof PdfTrueTypeFont, "PdfTrueTypeFont expected"); pdfTrueTypeFont.setSubset(true); page = pdfDoc.addNewPage(); new PdfCanvas(page) @@ -702,7 +701,7 @@ public void createDocumentWithTrueTypeFont1() throws IOException, InterruptedExc pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @Test @@ -719,7 +718,7 @@ public void createDocumentWithTrueTypeFont1NotEmbedded() throws IOException, Int String font = fontsFolder + "abserif4_5.ttf"; PdfFont pdfTrueTypeFont = PdfFontFactory.createFont(font, PdfEncodings.WINANSI, EmbeddingStrategy.FORCE_NOT_EMBEDDED); - Assert.assertTrue("PdfTrueTypeFont expected", pdfTrueTypeFont instanceof PdfTrueTypeFont); + Assertions.assertTrue(pdfTrueTypeFont instanceof PdfTrueTypeFont, "PdfTrueTypeFont expected"); pdfTrueTypeFont.setSubset(true); PdfPage page = pdfDoc.addNewPage(); new PdfCanvas(page) @@ -737,7 +736,7 @@ public void createDocumentWithTrueTypeFont1NotEmbedded() throws IOException, Int byte[] ttf = StreamUtil.inputStreamToArray(FileUtil.getInputStreamForFile(font)); pdfTrueTypeFont = PdfFontFactory.createFont(ttf, PdfEncodings.WINANSI, EmbeddingStrategy.FORCE_NOT_EMBEDDED); - Assert.assertTrue("PdfTrueTypeFont expected", pdfTrueTypeFont instanceof PdfTrueTypeFont); + Assertions.assertTrue(pdfTrueTypeFont instanceof PdfTrueTypeFont, "PdfTrueTypeFont expected"); pdfTrueTypeFont.setSubset(true); page = pdfDoc.addNewPage(); new PdfCanvas(page) @@ -753,7 +752,7 @@ public void createDocumentWithTrueTypeFont1NotEmbedded() throws IOException, Int pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @Test @@ -773,7 +772,7 @@ public void createDocumentWithTrueTypeOtfFont() throws IOException, InterruptedE PdfFont pdfTrueTypeFont = PdfFontFactory.createFont(font, PdfEncodings.WINANSI, EmbeddingStrategy.FORCE_EMBEDDED); - Assert.assertTrue("PdfTrueTypeFont expected", pdfTrueTypeFont instanceof PdfTrueTypeFont); + Assertions.assertTrue(pdfTrueTypeFont instanceof PdfTrueTypeFont, "PdfTrueTypeFont expected"); pdfTrueTypeFont.setSubset(true); PdfPage page = pdfDoc.addNewPage(); PdfCanvas canvas = new PdfCanvas(page); @@ -792,7 +791,7 @@ public void createDocumentWithTrueTypeOtfFont() throws IOException, InterruptedE byte[] ttf = StreamUtil.inputStreamToArray(FileUtil.getInputStreamForFile(font)); pdfTrueTypeFont = PdfFontFactory.createFont(ttf, PdfEncodings.WINANSI, EmbeddingStrategy.FORCE_EMBEDDED); - Assert.assertTrue("PdfTrueTypeFont expected", pdfTrueTypeFont instanceof PdfTrueTypeFont); + Assertions.assertTrue(pdfTrueTypeFont instanceof PdfTrueTypeFont, "PdfTrueTypeFont expected"); pdfTrueTypeFont.setSubset(true); page = pdfDoc.addNewPage(); canvas = new PdfCanvas(page); @@ -809,7 +808,7 @@ public void createDocumentWithTrueTypeOtfFont() throws IOException, InterruptedE pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @Test @@ -843,10 +842,10 @@ public void createDocumentWithTrueTypeOtfFontPdf20() throws IOException, Interru PdfDocument generatedDoc = new PdfDocument(CompareTool.createOutputReader(filename)); PdfFont pdfFont = PdfFontFactory.createFont(generatedDoc.getPage(1).getResources().getResource(PdfName.Font).getAsDictionary(new PdfName("F1"))); PdfDictionary descriptor = pdfFont.getPdfObject().getAsArray(PdfName.DescendantFonts).getAsDictionary(0).getAsDictionary(PdfName.FontDescriptor); - Assert.assertFalse("CIDSet is deprecated in PDF 2.0 and should not be written", descriptor.containsKey(PdfName.CIDSet)); + Assertions.assertFalse(descriptor.containsKey(PdfName.CIDSet), "CIDSet is deprecated in PDF 2.0 and should not be written"); generatedDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @Test @@ -865,7 +864,7 @@ public void createDocumentWithType0OtfFont() throws IOException, InterruptedExce String font = fontsFolder + "Puritan2.otf"; PdfFont pdfFont = PdfFontFactory.createFont(font, "Identity-H"); - Assert.assertTrue("PdfType0Font expected", pdfFont instanceof PdfType0Font); + Assertions.assertTrue(pdfFont instanceof PdfType0Font, "PdfType0Font expected"); pdfFont.setSubset(true); PdfPage page = pdfDoc.addNewPage(); PdfCanvas canvas = new PdfCanvas(page); @@ -883,7 +882,7 @@ public void createDocumentWithType0OtfFont() throws IOException, InterruptedExce byte[] ttf = StreamUtil.inputStreamToArray(FileUtil.getInputStreamForFile(font)); pdfFont = PdfFontFactory.createFont(ttf, "Identity-H"); - Assert.assertTrue("PdfTrueTypeFont expected", pdfFont instanceof PdfType0Font); + Assertions.assertTrue(pdfFont instanceof PdfType0Font, "PdfTrueTypeFont expected"); pdfFont.setSubset(true); page = pdfDoc.addNewPage(); canvas = new PdfCanvas(page); @@ -900,7 +899,7 @@ public void createDocumentWithType0OtfFont() throws IOException, InterruptedExce pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @Test @@ -940,8 +939,8 @@ public void testUpdateType3FontBasedExistingFont() throws IOException, Interrupt page.flush(); numberOfGlyphs = pdfType3Font.getNumberOfGlyphs(); } - Assert.assertEquals(6, numberOfGlyphs); - Assert.assertNull(new CompareTool().compareByContent(outputFileName, cmpOutputFileName, destinationFolder, "diff_")); + Assertions.assertEquals(6, numberOfGlyphs); + Assertions.assertNull(new CompareTool().compareByContent(outputFileName, cmpOutputFileName, destinationFolder, "diff_")); } @Test @@ -983,8 +982,8 @@ public void testNewType3FontBasedExistingFont() throws IOException, InterruptedE numberOfGlyphs = pdfType3Font.getNumberOfGlyphs(); } - Assert.assertEquals(6, numberOfGlyphs); - Assert.assertNull(new CompareTool().compareByContent(outputFileName, cmpOutputFileName, destinationFolder, "diff_")); + Assertions.assertEquals(6, numberOfGlyphs); + Assertions.assertNull(new CompareTool().compareByContent(outputFileName, cmpOutputFileName, destinationFolder, "diff_")); } @Test @@ -1018,7 +1017,7 @@ public void testAddGlyphToType3FontWithCustomNames() throws IOException { finalGlyphsNumber = pdfType3Font.getNumberOfGlyphs(); } - Assert.assertEquals(initialGlyphsNumber + 1, finalGlyphsNumber); + Assertions.assertEquals(initialGlyphsNumber + 1, finalGlyphsNumber); } @Test @@ -1055,7 +1054,7 @@ public void testNewType1FontBasedExistingFont() throws IOException, InterruptedE page.flush(); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @Test @@ -1090,7 +1089,7 @@ public void testNewTrueTypeFont1BasedExistingFont() throws IOException, Interrup canvas.release(); page.flush(); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @Test @@ -1127,7 +1126,7 @@ public void testNewTrueTypeFont2BasedExistingFont() throws IOException, Interrup page.flush(); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @Test @@ -1158,7 +1157,7 @@ public void testTrueTypeFont1BasedExistingFont() throws IOException, Interrupted page.flush(); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @Test @@ -1193,7 +1192,7 @@ public void testUpdateCjkFontBasedExistingFont() throws IOException, Interrupted page.flush(); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @Test @@ -1230,7 +1229,7 @@ public void testNewCjkFontBasedExistingFont() throws IOException, InterruptedExc page.flush(); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @Test @@ -1267,7 +1266,7 @@ public void createDocumentWithTrueTypeAsType0BasedExistingFont() throws IOExcept page.flush(); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @Test @@ -1301,7 +1300,7 @@ public void createUpdatedDocumentWithTrueTypeAsType0BasedExistingFont() throws I page.flush(); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @Test @@ -1337,7 +1336,7 @@ public void createDocumentWithType1WithToUnicodeBasedExistingFont() throws IOExc page.flush(); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @Test @@ -1367,7 +1366,7 @@ public void testType1FontUpdateContent() throws IOException, InterruptedExceptio page.flush(); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @Test @@ -1393,7 +1392,7 @@ public void testType1FontUpdateContent2() throws IOException, InterruptedExcepti .endText() .restoreState(); PdfFont pdfType1Font2 = pdfDoc.getFont(pdfDictionary); - Assert.assertEquals(pdfType1Font, pdfType1Font2); + Assertions.assertEquals(pdfType1Font, pdfType1Font2); canvas .saveState() .beginText() @@ -1407,7 +1406,7 @@ public void testType1FontUpdateContent2() throws IOException, InterruptedExcepti page.flush(); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @Test @@ -1419,7 +1418,7 @@ public void createWrongAfm1() throws IOException { } catch (com.itextpdf.io.exceptions.IOException e) { message = e.getMessage(); } - Assert.assertEquals("Invalid afm or pfm font file.", message); + Assertions.assertEquals("Invalid afm or pfm font file.", message); } @Test @@ -1431,7 +1430,7 @@ public void createWrongAfm2() throws IOException { } catch (com.itextpdf.io.exceptions.IOException e) { message = e.getMessage(); } - Assert.assertEquals(MessageFormatUtil.format(IoExceptionMessageConstant.IS_NOT_AN_AFM_OR_PFM_FONT_FILE, font), message); + Assertions.assertEquals(MessageFormatUtil.format(IoExceptionMessageConstant.IS_NOT_AN_AFM_OR_PFM_FONT_FILE, font), message); } @@ -1443,14 +1442,14 @@ public void createWrongPfb() throws IOException { byte[] afm = StreamUtil.inputStreamToArray(FileUtil.getInputStreamForFile(fontsFolder + "cmr10.afm")); PdfFont font = PdfFontFactory.createFont(FontProgramFactory.createType1Font(afm, afm, false), null); byte[] streamContent = ((Type1Font) ((PdfType1Font) font).getFontProgram()).getFontStreamBytes(); - Assert.assertTrue("Empty stream content expected", streamContent == null); + Assertions.assertTrue(streamContent == null, "Empty stream content expected"); } @Test public void autoDetect1() throws IOException { byte[] afm = StreamUtil.inputStreamToArray(FileUtil.getInputStreamForFile(fontsFolder + "cmr10.afm")); - Assert.assertTrue("Type1 font expected", FontProgramFactory.createFont(afm, false) instanceof Type1Font); + Assertions.assertTrue(FontProgramFactory.createFont(afm, false) instanceof Type1Font, "Type1 font expected"); } @Test @@ -1458,25 +1457,25 @@ public void autoDetect2() throws IOException { byte[] afm = StreamUtil.inputStreamToArray(FileUtil.getInputStreamForFile(fontsFolder + "cmr10.afm")); byte[] pfb = StreamUtil.inputStreamToArray(FileUtil.getInputStreamForFile(fontsFolder + "cmr10.pfb")); - Assert.assertTrue("Type1 font expected", FontProgramFactory.createType1Font(afm, pfb) instanceof Type1Font); + Assertions.assertTrue(FontProgramFactory.createType1Font(afm, pfb) instanceof Type1Font, "Type1 font expected"); } @Test public void autoDetect3() throws IOException { byte[] otf = StreamUtil.inputStreamToArray(FileUtil.getInputStreamForFile(fontsFolder + "Puritan2.otf")); - Assert.assertTrue("TrueType (OTF) font expected", FontProgramFactory.createFont(otf) instanceof TrueTypeFont); + Assertions.assertTrue(FontProgramFactory.createFont(otf) instanceof TrueTypeFont, "TrueType (OTF) font expected"); } @Test public void autoDetect4() throws IOException { byte[] ttf = StreamUtil.inputStreamToArray(FileUtil.getInputStreamForFile(fontsFolder + "abserif4_5.ttf")); - Assert.assertTrue("TrueType (TTF) expected", FontProgramFactory.createFont(ttf) instanceof TrueTypeFont); + Assertions.assertTrue(FontProgramFactory.createFont(ttf) instanceof TrueTypeFont, "TrueType (TTF) expected"); } @Test public void autoDetect5() throws IOException { byte[] ttf = StreamUtil.inputStreamToArray(FileUtil.getInputStreamForFile(fontsFolder + "abserif4_5.ttf")); - Assert.assertTrue("TrueType (TTF) expected", FontProgramFactory.createFont(ttf) instanceof TrueTypeFont); + Assertions.assertTrue(FontProgramFactory.createFont(ttf) instanceof TrueTypeFont, "TrueType (TTF) expected"); } @Test @@ -1501,7 +1500,7 @@ public void testPdfFontFactoryTtc() throws IOException, InterruptedException { .restoreState(); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @Test @@ -1556,7 +1555,7 @@ public void testWriteTTC() throws IOException, InterruptedException { pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @Test @@ -1611,7 +1610,7 @@ public void testWriteTTCNotEmbedded() throws IOException, InterruptedException { pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @Test @@ -1637,7 +1636,7 @@ public void testNotoFont() throws IOException, InterruptedException { .restoreState(); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @Test @@ -1663,7 +1662,7 @@ public void woffFontTest() throws IOException, InterruptedException { .restoreState(); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @@ -1688,7 +1687,7 @@ public void NotoSansCJKjpTest() throws IOException, InterruptedException { .restoreState(); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @Test @@ -1712,7 +1711,7 @@ public void NotoSansCJKjpTest02() throws IOException, InterruptedException { .restoreState(); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @Test @@ -1740,7 +1739,7 @@ public void NotoSansCJKjpTest03() throws IOException, InterruptedException { .restoreState(); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @Test @@ -1764,7 +1763,7 @@ public void SourceHanSansHWTest() throws IOException, InterruptedException { .restoreState(); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @Test @@ -1787,7 +1786,7 @@ public void sourceHanSerifKRRegularTest() throws IOException, InterruptedExcepti .restoreState(); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder)); } @Test @@ -1811,7 +1810,7 @@ public void sourceHanSerifKRRegularFullTest() throws IOException, InterruptedExc .restoreState(); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder)); } @Test @@ -1821,8 +1820,8 @@ public void mmType1ReadTest() throws IOException { PdfDocument doc = new PdfDocument(new PdfReader(src)); PdfFont font = PdfFontFactory.createFont((PdfDictionary) doc.getPdfObject(335)); doc.close(); - Assert.assertEquals(PdfName.MMType1, font.getPdfObject().getAsName(PdfName.Subtype)); - Assert.assertEquals(PdfType1Font.class, font.getClass()); + Assertions.assertEquals(PdfName.MMType1, font.getPdfObject().getAsName(PdfName.Subtype)); + Assertions.assertEquals(PdfType1Font.class, font.getClass()); } @@ -1846,7 +1845,7 @@ public void mmType1WriteTest() throws IOException, InterruptedException { .restoreState(); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @@ -1897,13 +1896,13 @@ public void testFontStyleProcessing() throws IOException, InterruptedException { canvas.release(); page.flush(); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder, "diff_")); } @Test public void testCheckTTCSize() throws IOException { TrueTypeCollection collection = new TrueTypeCollection(fontsFolder + "uming.ttc"); - Assert.assertTrue(collection.getTTCSize() == 4); + Assertions.assertTrue(collection.getTTCSize() == 4); } @Test @@ -1915,7 +1914,7 @@ public void testFontDirectoryRegister() throws IOException { for (String name : PdfFontFactory.getRegisteredFonts()) { PdfFont pdfFont = PdfFontFactory.createRegisteredFont(name); if (pdfFont == null) - Assert.assertTrue("Font {" + name + "} can't be empty", false); + Assertions.assertTrue(false, "Font {" + name + "} can't be empty"); } pdfDoc.addNewPage(); @@ -1932,7 +1931,7 @@ public void fontRegisterTest() throws IOException { PdfFont pdfFont = PdfFontFactory.createRegisteredFont("notoSerifRegular"); //clear font cache for other tests FontProgramFactory.clearRegisteredFonts(); - Assert.assertTrue(pdfFont instanceof PdfType0Font); + Assertions.assertTrue(pdfFont instanceof PdfType0Font); pdfDoc.addNewPage(); pdfDoc.close(); } @@ -1941,51 +1940,51 @@ public void fontRegisterTest() throws IOException { public void testSplitString() throws IOException { PdfFont font = PdfFontFactory.createFont(); List list1 = font.splitString("Hello", 12f, 10); - Assert.assertTrue(list1.size() == 3); + Assertions.assertTrue(list1.size() == 3); List list2 = font.splitString("Digitally signed by Dmitry Trusevich\nDate: 2015.10.25 14:43:56 MSK\nReason: Test 1\nLocation: Ghent", 12f, 176); - Assert.assertTrue(list2.size() == 5); + Assertions.assertTrue(list2.size() == 5); } @Test public void otfByStringNames() { FontProgramDescriptor descriptor = FontProgramDescriptorFactory.fetchDescriptor(fontsFolder + "Puritan2.otf"); - Assert.assertEquals(descriptor.getFontName(), "Puritan2"); - Assert.assertEquals(descriptor.getFullNameLowerCase(), "Puritan 2.0 Regular".toLowerCase()); - Assert.assertEquals(descriptor.getFamilyNameLowerCase(), "Puritan 2.0".toLowerCase()); - Assert.assertEquals(descriptor.getStyle(), "Normal"); - Assert.assertEquals(descriptor.getFontWeight(), 400); + Assertions.assertEquals(descriptor.getFontName(), "Puritan2"); + Assertions.assertEquals(descriptor.getFullNameLowerCase(), "Puritan 2.0 Regular".toLowerCase()); + Assertions.assertEquals(descriptor.getFamilyNameLowerCase(), "Puritan 2.0".toLowerCase()); + Assertions.assertEquals(descriptor.getStyle(), "Normal"); + Assertions.assertEquals(descriptor.getFontWeight(), 400); } @Test public void otfByStreamNames() throws Exception { FontProgramDescriptor descriptor = FontProgramDescriptorFactory.fetchDescriptor(StreamUtil.inputStreamToArray(FileUtil.getInputStreamForFile(fontsFolder + "Puritan2.otf"))); - Assert.assertEquals(descriptor.getFontName(), "Puritan2"); - Assert.assertEquals(descriptor.getFullNameLowerCase(), "Puritan 2.0 Regular".toLowerCase()); - Assert.assertEquals(descriptor.getFamilyNameLowerCase(), "Puritan 2.0".toLowerCase()); - Assert.assertEquals(descriptor.getStyle(), "Normal"); - Assert.assertEquals(descriptor.getFontWeight(), 400); + Assertions.assertEquals(descriptor.getFontName(), "Puritan2"); + Assertions.assertEquals(descriptor.getFullNameLowerCase(), "Puritan 2.0 Regular".toLowerCase()); + Assertions.assertEquals(descriptor.getFamilyNameLowerCase(), "Puritan 2.0".toLowerCase()); + Assertions.assertEquals(descriptor.getStyle(), "Normal"); + Assertions.assertEquals(descriptor.getFontWeight(), 400); } @Test public void ttfByStringNames() { FontProgramDescriptor descriptor = FontProgramDescriptorFactory.fetchDescriptor(fontsFolder + "abserif4_5.ttf"); - Assert.assertEquals(descriptor.getFontName(), "AboriginalSerif"); - Assert.assertEquals(descriptor.getFullNameLowerCase(), "Aboriginal Serif".toLowerCase()); - Assert.assertEquals(descriptor.getFamilyNameLowerCase(), "Aboriginal Serif".toLowerCase()); - Assert.assertEquals(descriptor.getStyle(), "Regular"); - Assert.assertEquals(descriptor.getFontWeight(), 400); + Assertions.assertEquals(descriptor.getFontName(), "AboriginalSerif"); + Assertions.assertEquals(descriptor.getFullNameLowerCase(), "Aboriginal Serif".toLowerCase()); + Assertions.assertEquals(descriptor.getFamilyNameLowerCase(), "Aboriginal Serif".toLowerCase()); + Assertions.assertEquals(descriptor.getStyle(), "Regular"); + Assertions.assertEquals(descriptor.getFontWeight(), 400); } @Test public void ttfByStreamNames() throws Exception { FontProgramDescriptor descriptor = FontProgramDescriptorFactory.fetchDescriptor(StreamUtil.inputStreamToArray(FileUtil.getInputStreamForFile(fontsFolder + "abserif4_5.ttf"))); - Assert.assertEquals(descriptor.getFontName(), "AboriginalSerif"); - Assert.assertEquals(descriptor.getFullNameLowerCase(), "Aboriginal Serif".toLowerCase()); - Assert.assertEquals(descriptor.getFamilyNameLowerCase(), "Aboriginal Serif".toLowerCase()); - Assert.assertEquals(descriptor.getStyle(), "Regular"); - Assert.assertEquals(descriptor.getFontWeight(), 400); + Assertions.assertEquals(descriptor.getFontName(), "AboriginalSerif"); + Assertions.assertEquals(descriptor.getFullNameLowerCase(), "Aboriginal Serif".toLowerCase()); + Assertions.assertEquals(descriptor.getFamilyNameLowerCase(), "Aboriginal Serif".toLowerCase()); + Assertions.assertEquals(descriptor.getStyle(), "Regular"); + Assertions.assertEquals(descriptor.getFontWeight(), 400); } @Test @@ -1993,8 +1992,8 @@ public void testDefaultFontWithReader() throws IOException { String inputFileName = sourceFolder + "type3Font.pdf"; try(PdfDocument pdfDoc = new PdfDocument(new PdfReader(inputFileName))) { - Assert.assertNotNull(pdfDoc.getDefaultFont()); - Assert.assertNull(pdfDoc.getDefaultFont().getPdfObject().getIndirectReference()); + Assertions.assertNotNull(pdfDoc.getDefaultFont()); + Assertions.assertNull(pdfDoc.getDefaultFont().getPdfObject().getIndirectReference()); } } @@ -2020,7 +2019,7 @@ public void mSungLightFontRanges() throws IOException, InterruptedException { .restoreState(); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, destinationFolder)); } @Test @@ -2054,7 +2053,7 @@ public void halfWidthFontTest() throws IOException, InterruptedException { } } - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff_")); } @Test @@ -2072,8 +2071,8 @@ public void utf16ToUcs2HWFontTest() throws IOException { .moveText(36, 700) .setFontAndSize(PdfFontFactory.createFont("KozMinPro-Regular", "UniJIS-UCS2-HW-H", EmbeddingStrategy.PREFER_EMBEDDED, true), 12); - Exception e = Assert.assertThrows(ITextException.class, () -> canvas.showText(msg)); - Assert.assertEquals(IoExceptionMessageConstant.ONLY_BMP_ENCODING, e.getMessage()); + Exception e = Assertions.assertThrows(ITextException.class, () -> canvas.showText(msg)); + Assertions.assertEquals(IoExceptionMessageConstant.ONLY_BMP_ENCODING, e.getMessage()); } } @@ -2098,7 +2097,7 @@ public void uniJIS2004UTF16FontTest() throws IOException, InterruptedException { .restoreState(); } - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff_")); } private float getContentWidth(PdfType3Font type3, char glyph) { diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfIndirectReferenceTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfIndirectReferenceTest.java index 9c9375b6a5..bc2dcf11a0 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfIndirectReferenceTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfIndirectReferenceTest.java @@ -23,24 +23,23 @@ This file is part of the iText (R) project. package com.itextpdf.kernel.pdf; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.ByteArrayOutputStream; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfIndirectReferenceTest extends ExtendedITextTest { @Test public void baseEqualsTest() { PdfIndirectReference reference = new PdfIndirectReference(null, 41, 0); - Assert.assertTrue(reference.equals(reference)); - Assert.assertFalse(reference.equals(null)); + Assertions.assertTrue(reference.equals(reference)); + Assertions.assertFalse(reference.equals(null)); TestIndirectReference testIndirectReference = new TestIndirectReference(null, 41, 0); - Assert.assertFalse(reference.equals(testIndirectReference)); - Assert.assertFalse(testIndirectReference.equals(reference)); + Assertions.assertFalse(reference.equals(testIndirectReference)); + Assertions.assertFalse(testIndirectReference.equals(reference)); } @@ -54,11 +53,11 @@ public void equalsWithDocTest() { PdfIndirectReference obj41Gen0 = new PdfIndirectReference(firstDoc, 41, 0); - Assert.assertTrue(obj41Gen0.equals(new PdfIndirectReference(firstDoc, 41, 0))); - Assert.assertFalse(obj41Gen0.equals(new PdfIndirectReference(firstDoc, 42, 0))); - Assert.assertFalse(obj41Gen0.equals(new PdfIndirectReference(firstDoc, 41, 1))); - Assert.assertFalse(obj41Gen0.equals(new PdfIndirectReference(null, 41, 0))); - Assert.assertFalse(obj41Gen0.equals(new PdfIndirectReference(secondDoc, 41, 0))); + Assertions.assertTrue(obj41Gen0.equals(new PdfIndirectReference(firstDoc, 41, 0))); + Assertions.assertFalse(obj41Gen0.equals(new PdfIndirectReference(firstDoc, 42, 0))); + Assertions.assertFalse(obj41Gen0.equals(new PdfIndirectReference(firstDoc, 41, 1))); + Assertions.assertFalse(obj41Gen0.equals(new PdfIndirectReference(null, 41, 0))); + Assertions.assertFalse(obj41Gen0.equals(new PdfIndirectReference(secondDoc, 41, 0))); } } @@ -66,15 +65,15 @@ public void equalsWithDocTest() { public void equalsWithNullDocsTest() { PdfIndirectReference obj41Gen0 = new PdfIndirectReference(null, 41, 0); - Assert.assertTrue(obj41Gen0.equals(new PdfIndirectReference(null, 41, 0))); - Assert.assertFalse(obj41Gen0.equals(new PdfIndirectReference(null, 42, 0))); - Assert.assertFalse(obj41Gen0.equals(new PdfIndirectReference(null, 41, 1))); + Assertions.assertTrue(obj41Gen0.equals(new PdfIndirectReference(null, 41, 0))); + Assertions.assertFalse(obj41Gen0.equals(new PdfIndirectReference(null, 42, 0))); + Assertions.assertFalse(obj41Gen0.equals(new PdfIndirectReference(null, 41, 1))); try (PdfDocument doc = new PdfDocument(new PdfWriter(new ByteArrayOutputStream()))) { // add a page to avoid exception throwing on close doc.addNewPage(); - Assert.assertFalse(obj41Gen0.equals(new PdfIndirectReference(doc, 41, 0))); + Assertions.assertFalse(obj41Gen0.equals(new PdfIndirectReference(doc, 41, 0))); } } @@ -82,10 +81,10 @@ public void equalsWithNullDocsTest() { public void hashCodeTest() { PdfIndirectReference firstReference = new PdfIndirectReference(null, 41, 7); PdfIndirectReference secondReference = new PdfIndirectReference(null, 41, 7); - Assert.assertNotSame(firstReference, secondReference); - Assert.assertEquals(firstReference.hashCode(), secondReference.hashCode()); - Assert.assertNotEquals(firstReference.hashCode(), new PdfIndirectReference(null, 42, 7).hashCode()); - Assert.assertNotEquals(firstReference.hashCode(), new PdfIndirectReference(null, 41, 5).hashCode()); + Assertions.assertNotSame(firstReference, secondReference); + Assertions.assertEquals(firstReference.hashCode(), secondReference.hashCode()); + Assertions.assertNotEquals(firstReference.hashCode(), new PdfIndirectReference(null, 42, 7).hashCode()); + Assertions.assertNotEquals(firstReference.hashCode(), new PdfIndirectReference(null, 41, 5).hashCode()); try (PdfDocument firstDoc = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); PdfDocument secondDoc = new PdfDocument(new PdfWriter(new ByteArrayOutputStream()))) { @@ -95,9 +94,9 @@ public void hashCodeTest() { PdfIndirectReference obj41Gen0 = new PdfIndirectReference(firstDoc, 41, 0); - Assert.assertEquals(obj41Gen0.hashCode(), new PdfIndirectReference(firstDoc, 41, 0).hashCode()); - Assert.assertNotEquals(obj41Gen0.hashCode(), new PdfIndirectReference(secondDoc, 41, 0).hashCode()); - Assert.assertNotEquals(obj41Gen0.hashCode(), new PdfIndirectReference(null, 41, 0).hashCode()); + Assertions.assertEquals(obj41Gen0.hashCode(), new PdfIndirectReference(firstDoc, 41, 0).hashCode()); + Assertions.assertNotEquals(obj41Gen0.hashCode(), new PdfIndirectReference(secondDoc, 41, 0).hashCode()); + Assertions.assertNotEquals(obj41Gen0.hashCode(), new PdfIndirectReference(null, 41, 0).hashCode()); } } @@ -111,20 +110,20 @@ public void compareToWithDocTest() { PdfIndirectReference obj41Gen7 = new PdfIndirectReference(firstDoc, 41, 7); - Assert.assertEquals(0, obj41Gen7.compareTo(new PdfIndirectReference(firstDoc, 41, 7))); + Assertions.assertEquals(0, obj41Gen7.compareTo(new PdfIndirectReference(firstDoc, 41, 7))); - Assert.assertEquals(1, obj41Gen7.compareTo(new PdfIndirectReference(firstDoc, 11, 17))); - Assert.assertEquals(-1, obj41Gen7.compareTo(new PdfIndirectReference(firstDoc, 51, 0))); + Assertions.assertEquals(1, obj41Gen7.compareTo(new PdfIndirectReference(firstDoc, 11, 17))); + Assertions.assertEquals(-1, obj41Gen7.compareTo(new PdfIndirectReference(firstDoc, 51, 0))); - Assert.assertEquals(-1, obj41Gen7.compareTo(new PdfIndirectReference(firstDoc, 41, 17))); - Assert.assertEquals(1, obj41Gen7.compareTo(new PdfIndirectReference(firstDoc, 41, 0))); + Assertions.assertEquals(-1, obj41Gen7.compareTo(new PdfIndirectReference(firstDoc, 41, 17))); + Assertions.assertEquals(1, obj41Gen7.compareTo(new PdfIndirectReference(firstDoc, 41, 0))); - Assert.assertEquals(1, obj41Gen7.compareTo(new PdfIndirectReference(null, 41, 7))); + Assertions.assertEquals(1, obj41Gen7.compareTo(new PdfIndirectReference(null, 41, 7))); // we do not expect that ids could be equal int docIdsCompareResult = firstDoc.getDocumentId() > secondDoc.getDocumentId() ? 1 : -1; - Assert.assertEquals(docIdsCompareResult, + Assertions.assertEquals(docIdsCompareResult, obj41Gen7.compareTo(new PdfIndirectReference(secondDoc, 41, 7))); - Assert.assertEquals(-docIdsCompareResult, + Assertions.assertEquals(-docIdsCompareResult, new PdfIndirectReference(secondDoc, 41, 7).compareTo(obj41Gen7)); } } @@ -133,19 +132,19 @@ public void compareToWithDocTest() { public void compareToWithNullDocsTest() { PdfIndirectReference obj41Gen7 = new PdfIndirectReference(null, 41, 7); - Assert.assertEquals(0, obj41Gen7.compareTo(new PdfIndirectReference(null, 41, 7))); - Assert.assertEquals(1, obj41Gen7.compareTo(new PdfIndirectReference(null, 11, 17))); - Assert.assertEquals(-1, obj41Gen7.compareTo(new PdfIndirectReference(null, 51, 0))); - Assert.assertEquals(-1, obj41Gen7.compareTo(new PdfIndirectReference(null, 41, 17))); - Assert.assertEquals(1, obj41Gen7.compareTo(new PdfIndirectReference(null, 41, 0))); + Assertions.assertEquals(0, obj41Gen7.compareTo(new PdfIndirectReference(null, 41, 7))); + Assertions.assertEquals(1, obj41Gen7.compareTo(new PdfIndirectReference(null, 11, 17))); + Assertions.assertEquals(-1, obj41Gen7.compareTo(new PdfIndirectReference(null, 51, 0))); + Assertions.assertEquals(-1, obj41Gen7.compareTo(new PdfIndirectReference(null, 41, 17))); + Assertions.assertEquals(1, obj41Gen7.compareTo(new PdfIndirectReference(null, 41, 0))); try (PdfDocument doc = new PdfDocument(new PdfWriter(new ByteArrayOutputStream()))) { // add a page to avoid exception throwing on close doc.addNewPage(); - Assert.assertEquals(-1, obj41Gen7.compareTo(new PdfIndirectReference(doc, 41, 7))); - Assert.assertEquals(1, obj41Gen7.compareTo(new PdfIndirectReference(doc, 11, 17))); - Assert.assertEquals(1, obj41Gen7.compareTo(new PdfIndirectReference(doc, 41, 0))); + Assertions.assertEquals(-1, obj41Gen7.compareTo(new PdfIndirectReference(doc, 41, 7))); + Assertions.assertEquals(1, obj41Gen7.compareTo(new PdfIndirectReference(doc, 11, 17))); + Assertions.assertEquals(1, obj41Gen7.compareTo(new PdfIndirectReference(doc, 41, 0))); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfNameTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfNameTest.java index 100686bf88..9ecf46765c 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfNameTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfNameTest.java @@ -24,13 +24,12 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.ITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfNameTest extends ExtendedITextTest { @Test @@ -38,9 +37,9 @@ public void specialCharactersTest(){ String str1 = " %()<>"; String str2 = "[]{}/#"; PdfName name1 = new PdfName(str1); - Assert.assertEquals(str1, createStringByEscaped(name1.getInternalContent())); + Assertions.assertEquals(str1, createStringByEscaped(name1.getInternalContent())); PdfName name2 = new PdfName(str2); - Assert.assertEquals(str2, createStringByEscaped(name2.getInternalContent())); + Assertions.assertEquals(str2, createStringByEscaped(name2.getInternalContent())); } @Test @@ -72,13 +71,13 @@ public void basicCompareToTest(){ int oneContentToTwo = name1ContentOnly.compareTo(name2); double delta = 1e-8; - Assert.assertEquals(Math.signum(oneToTwo), -Math.signum(twoToOne), delta); + Assertions.assertEquals(Math.signum(oneToTwo), -Math.signum(twoToOne), delta); - Assert.assertEquals(Math.signum(oneToTwo), Math.signum(twoToThree), delta); - Assert.assertEquals(Math.signum(oneToTwo), Math.signum(oneToThree), delta); + Assertions.assertEquals(Math.signum(oneToTwo), Math.signum(twoToThree), delta); + Assertions.assertEquals(Math.signum(oneToTwo), Math.signum(oneToThree), delta); - Assert.assertEquals(oneToOneContent, 0); - Assert.assertEquals(Math.signum(oneToTwo), Math.signum(oneContentToTwo), delta); + Assertions.assertEquals(oneToOneContent, 0); + Assertions.assertEquals(Math.signum(oneToTwo), Math.signum(oneContentToTwo), delta); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfNameTreeTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfNameTreeTest.java index 6f0bfb9308..fcdc0ad9f8 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfNameTreeTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfNameTreeTest.java @@ -32,15 +32,14 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.xobject.PdfFormXObject; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.util.ArrayList; import java.util.List; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -48,18 +47,18 @@ This file is part of the iText (R) project. import java.util.Set; import java.util.Map; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfNameTreeTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/kernel/pdf/PdfNameTreeTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/kernel/pdf/PdfNameTreeTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(destinationFolder); } @@ -72,8 +71,8 @@ public void embeddedFileAndJavascriptTest() throws IOException { PdfNameTree javascript = pdfDocument.getCatalog().getNameTree(PdfName.JavaScript); Map objs2 = javascript.getNames(); pdfDocument.close(); - Assert.assertEquals(1, objs.size()); - Assert.assertEquals(1, objs2.size()); + Assertions.assertEquals(1, objs.size()); + Assertions.assertEquals(1, objs2.size()); } @Test @@ -112,8 +111,8 @@ public void embeddedFileAddedInAppendModeTest() throws IOException{ PdfNameTree embeddedFilesNameTree = finalDoc.getCatalog().getNameTree(PdfName.EmbeddedFiles); Map embeddedFilesMap = embeddedFilesNameTree.getNames(); - Assert.assertTrue(embeddedFilesMap.size()>0); - Assert.assertTrue(embeddedFilesMap.containsKey(new PdfString("Test File"))); + Assertions.assertTrue(embeddedFilesMap.size()>0); + Assertions.assertTrue(embeddedFilesMap.containsKey(new PdfString("Test File"))); } @Test @@ -136,7 +135,7 @@ public void annotationAppearanceTest() throws IOException { PdfNameTree appearance = pdfDocument.getCatalog().getNameTree(PdfName.AP); Map objs = appearance.getNames(); pdfDocument.close(); - Assert.assertEquals(1, objs.size()); + Assertions.assertEquals(1, objs.size()); } @Test @@ -170,7 +169,7 @@ public void checkNamesOrder() throws IOException { System.out.println("Actual names: " + actualNames); - Assert.assertEquals(expectedNames, actualNames); + Assertions.assertEquals(expectedNames, actualNames); } doc.close(); @@ -207,7 +206,7 @@ private static void testSetModified(boolean isAppendMode) throws IOException { nameTree = pdfDoc.getCatalog().getNameTree(PdfName.Dests); Set actualKeys = nameTree.getNames().keySet(); - Assert.assertArrayEquals(expectedKeys, actualKeys.toArray()); + Assertions.assertArrayEquals(expectedKeys, actualKeys.toArray()); } private static ByteArrayOutputStream createDocumentInMemory() { diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfNumberTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfNumberTest.java index 1e1757d582..900ab7001a 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfNumberTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfNumberTest.java @@ -26,12 +26,11 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfNumberTest extends ExtendedITextTest { private static final double DELTA = 0.0001; @@ -42,7 +41,7 @@ public void testNaN() { PdfNumber number = new PdfNumber(Double.NaN); // code for "0" byte[] expected = {48}; - Assert.assertArrayEquals(expected, number.getInternalContent()); + Assertions.assertArrayEquals(expected, number.getInternalContent()); } @Test @@ -50,12 +49,12 @@ public void intValueInPdfNumberTest() { double valueToSet = 3000000000d; final PdfNumber number = new PdfNumber(valueToSet); - Assert.assertEquals(valueToSet, number.getValue(), DELTA); - Assert.assertEquals(valueToSet, number.doubleValue(), DELTA); - Assert.assertEquals(Integer.MAX_VALUE, number.intValue()); + Assertions.assertEquals(valueToSet, number.getValue(), DELTA); + Assertions.assertEquals(valueToSet, number.doubleValue(), DELTA); + Assertions.assertEquals(Integer.MAX_VALUE, number.intValue()); valueToSet = 50d; number.setValue(valueToSet + DELTA); - Assert.assertEquals(50, number.intValue()); + Assertions.assertEquals(50, number.intValue()); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfObjectReleaseTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfObjectReleaseTest.java index 7eaad7a220..36727abb09 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfObjectReleaseTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfObjectReleaseTest.java @@ -30,27 +30,26 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfObjectReleaseTest extends ExtendedITextTest { public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/kernel/pdf/PdfObjectReleaseTest/"; public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/kernel/pdf/PdfObjectReleaseTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(DESTINATION_FOLDER); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(DESTINATION_FOLDER); } @@ -89,7 +88,7 @@ public void releaseCatalogTest() throws IOException, InterruptedException { doc.getCatalog().getPdfObject().release(); } - Assert.assertNull(new CompareTool().compareByContent(release, srcFile, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(release, srcFile, DESTINATION_FOLDER)); } @Test @@ -102,7 +101,7 @@ public void releasePagesTest() throws IOException, InterruptedException { doc.getCatalog().getPdfObject().getAsDictionary(PdfName.Pages).release(); } - Assert.assertNull(new CompareTool().compareByContent(release, srcFile, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(release, srcFile, DESTINATION_FOLDER)); } @Test @@ -115,7 +114,7 @@ public void releaseStructTreeRootTest() throws IOException, InterruptedException doc.getStructTreeRoot().getPdfObject().release(); } - Assert.assertNull(new CompareTool().compareByContent(release, srcFile, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(release, srcFile, DESTINATION_FOLDER)); } @Test @@ -133,7 +132,7 @@ public void releaseModifiedObjectTest() throws IOException, InterruptedException annots.getPdfObject().release(); } - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFile, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFile, DESTINATION_FOLDER)); } @Test @@ -148,10 +147,10 @@ public void addingReleasedObjectToDocumentTest() throws IOException { doc.getCatalog().put(PdfName.Outlines, releasedObj); } finally { - Exception e = Assert.assertThrows(PdfException.class, + Exception e = Assertions.assertThrows(PdfException.class, () -> doc.close() ); - Assert.assertEquals("Cannot write object after it was released." + Assertions.assertEquals("Cannot write object after it was released." + " In normal situation the object must be read once again before being written.", e.getMessage()); } } @@ -176,6 +175,6 @@ private void singlePdfObjectReleaseTest(String inputFilename, String outStamping stamperRelease.close(); - Assert.assertNull(new CompareTool().compareByContent(outStampingRelease, outPureStamping, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outStampingRelease, outPureStamping, DESTINATION_FOLDER)); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfObjectStreamUnitTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfObjectStreamUnitTest.java index 278c0502a0..5d09e4405a 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfObjectStreamUnitTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfObjectStreamUnitTest.java @@ -26,13 +26,12 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.exceptions.KernelExceptionMessageConstant; import com.itextpdf.kernel.exceptions.PdfException; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfObjectStreamUnitTest extends ExtendedITextTest { @Test @@ -45,9 +44,9 @@ public void cannotAddMoreObjectsThanMaxStreamSizeTest() { for (int i = 0; i < PdfObjectStream.MAX_OBJ_STREAM_SIZE; i++) { pdfObjectStream.addObject(number); } - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> pdfObjectStream.addObject(number)); - Assert.assertEquals(KernelExceptionMessageConstant.PDF_OBJECT_STREAM_REACH_MAX_SIZE, + Assertions.assertEquals(KernelExceptionMessageConstant.PDF_OBJECT_STREAM_REACH_MAX_SIZE, exception.getMessage()); } @@ -60,6 +59,6 @@ public void objectCanBeAddedToObjectStreamWithSizeLessThenMaxStreamSizeTest() { for (int i = 0; i <= PdfObjectStream.MAX_OBJ_STREAM_SIZE - 1; i++) { pdfObjectStream.addObject(number); } - Assert.assertTrue("We don't expect to reach this line, since no exception should have been thrown", true); + Assertions.assertTrue(true, "We don't expect to reach this line, since no exception should have been thrown"); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfObjectTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfObjectTest.java index e8bbed5b50..c131bf24f5 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfObjectTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfObjectTest.java @@ -26,17 +26,16 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.HashMap; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfObjectTest extends ExtendedITextTest { @Test @@ -47,7 +46,7 @@ public void indirectsChain1() { catalog.put(new PdfName("a"), getTestPdfDictionary() .makeIndirect(document).getIndirectReference().makeIndirect(document).getIndirectReference().makeIndirect(document)); PdfObject object = ((PdfIndirectReference)catalog.get(new PdfName("a"), false)).getRefersTo(true); - Assert.assertTrue(object instanceof PdfDictionary); + Assertions.assertTrue(object instanceof PdfDictionary); document.close(); } @@ -63,7 +62,7 @@ public void indirectsChain2() { } catalog.put(new PdfName("a"), object); ((PdfIndirectReference)catalog.get(new PdfName("a"))).getRefersTo(true); - Assert.assertNotNull(((PdfIndirectReference) catalog.get(new PdfName("a"))).getRefersTo(true)); + Assertions.assertNotNull(((PdfIndirectReference) catalog.get(new PdfName("a"))).getRefersTo(true)); document.close(); } @@ -79,8 +78,8 @@ public void indirectsChain3() { } catalog.put(new PdfName("a"), object); object = catalog.get(new PdfName("a"), true); - Assert.assertTrue(object instanceof PdfDictionary); - Assert.assertEquals(new PdfName("c").toString(), ((PdfDictionary) object).get(new PdfName("b")).toString()); + Assertions.assertTrue(object instanceof PdfDictionary); + Assertions.assertEquals(new PdfName("c").toString(), ((PdfDictionary) object).get(new PdfName("b")).toString()); document.close(); } @@ -98,8 +97,8 @@ public void indirectsChain4() { array.add(object); catalog.put(new PdfName("a"), array); object = ((PdfArray)catalog.get(new PdfName("a"))).get(0, true); - Assert.assertTrue(object instanceof PdfDictionary); - Assert.assertEquals(new PdfName("c").toString(), ((PdfDictionary)object).get(new PdfName("b")).toString()); + Assertions.assertTrue(object instanceof PdfDictionary); + Assertions.assertEquals(new PdfName("c").toString(), ((PdfDictionary)object).get(new PdfName("b")).toString()); document.close(); } @@ -110,42 +109,44 @@ public void pdfIndirectReferenceFlags(){ reference.setState(PdfObject.READING); reference.setState(PdfObject.MODIFIED); - Assert.assertEquals("Free", true, reference.checkState(PdfObject.FREE)); - Assert.assertEquals("Reading", true, reference.checkState(PdfObject.READING)); - Assert.assertEquals("Modified", true, reference.checkState(PdfObject.MODIFIED)); - Assert.assertEquals("Free|Reading|Modified", true, - reference.checkState((byte)(PdfObject.FREE |PdfObject.MODIFIED |PdfObject.READING))); + Assertions.assertEquals(Boolean.TRUE, reference.checkState(PdfObject.FREE), "Free"); + Assertions.assertEquals(Boolean.TRUE, reference.checkState(PdfObject.READING), "Reading"); + Assertions.assertEquals(Boolean.TRUE, reference.checkState(PdfObject.MODIFIED), "Modified"); + Assertions.assertEquals(Boolean.TRUE, + reference.checkState((byte) (PdfObject.FREE | PdfObject.MODIFIED | PdfObject.READING)), + "Free|Reading|Modified"); reference.clearState(PdfObject.FREE); - Assert.assertEquals("Free", false, reference.checkState(PdfObject.FREE)); - Assert.assertEquals("Reading", true, reference.checkState(PdfObject.READING)); - Assert.assertEquals("Modified", true, reference.checkState(PdfObject.MODIFIED)); - Assert.assertEquals("Reading|Modified", true, - reference.checkState((byte)(PdfObject.READING |PdfObject.MODIFIED))); - Assert.assertEquals("Free|Reading|Modified", false, - reference.checkState((byte)(PdfObject.FREE |PdfObject.READING |PdfObject.MODIFIED))); + Assertions.assertEquals(Boolean.FALSE, reference.checkState(PdfObject.FREE), "Free"); + Assertions.assertEquals(Boolean.TRUE, reference.checkState(PdfObject.READING), "Reading"); + Assertions.assertEquals(Boolean.TRUE, reference.checkState(PdfObject.MODIFIED), "Modified"); + Assertions.assertEquals(Boolean.TRUE, + reference.checkState((byte)(PdfObject.READING |PdfObject.MODIFIED)), "Reading|Modified"); + Assertions.assertEquals(Boolean.FALSE, + reference.checkState((byte) (PdfObject.FREE | PdfObject.READING | PdfObject.MODIFIED)), + "Free|Reading|Modified"); reference.clearState(PdfObject.READING); - Assert.assertEquals("Free", false, reference.checkState(PdfObject.FREE)); - Assert.assertEquals("Reading", false, reference.checkState(PdfObject.READING)); - Assert.assertEquals("Modified", true, reference.checkState(PdfObject.MODIFIED)); - Assert.assertEquals("Free|Reading", false, - reference.checkState((byte) (PdfObject.FREE | PdfObject.READING))); + Assertions.assertEquals(Boolean.FALSE, reference.checkState(PdfObject.FREE), "Free"); + Assertions.assertEquals(Boolean.FALSE, reference.checkState(PdfObject.READING), "Reading"); + Assertions.assertEquals(Boolean.TRUE, reference.checkState(PdfObject.MODIFIED), "Modified"); + Assertions.assertEquals(Boolean.FALSE, + reference.checkState((byte) (PdfObject.FREE | PdfObject.READING)), "Free|Reading"); reference.clearState(PdfObject.MODIFIED); - Assert.assertEquals("Free", false, reference.checkState(PdfObject.FREE)); - Assert.assertEquals("Reading", false, reference.checkState(PdfObject.READING)); - Assert.assertEquals("Modified", false, reference.checkState(PdfObject.MODIFIED)); + Assertions.assertEquals(Boolean.FALSE, reference.checkState(PdfObject.FREE), "Free"); + Assertions.assertEquals(Boolean.FALSE, reference.checkState(PdfObject.READING), "Reading"); + Assertions.assertEquals(Boolean.FALSE, reference.checkState(PdfObject.MODIFIED), "Modified"); - Assert.assertEquals("Is InUse", true, !reference.isFree()); + Assertions.assertEquals(Boolean.TRUE, !reference.isFree(), "Is InUse"); reference.setState(PdfObject.FREE); - Assert.assertEquals("Not IsInUse", false, !reference.isFree()); + Assertions.assertEquals(Boolean.FALSE, !reference.isFree(), "Not IsInUse"); } @Test @@ -170,10 +171,10 @@ public void pdtIndirectReferenceLateInitializing1() throws IOException { document = new PdfDocument(new PdfReader(bais)); PdfObject object = document.getCatalog().getPdfObject().get(new PdfName("Smth")); - Assert.assertTrue(object instanceof PdfDictionary); + Assertions.assertTrue(object instanceof PdfDictionary); dictionary = (PdfDictionary) object; PdfString a = (PdfString) dictionary.get(new PdfName("A")); - Assert.assertTrue(a.getValue().equals("a")); + Assertions.assertTrue(a.getValue().equals("a")); document.close(); } @@ -182,7 +183,7 @@ public void pdtIndirectReferenceLateInitializing1() throws IOException { @LogMessages(messages = { @LogMessage(messageTemplate = IoLogMessageConstant.FLUSHED_OBJECT_CONTAINS_REFERENCE_WHICH_NOT_REFER_TO_ANY_OBJECT), @LogMessage(messageTemplate = IoLogMessageConstant.INDIRECT_REFERENCE_USED_IN_FLUSHED_OBJECT_MADE_FREE), - @LogMessage(messageTemplate = IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT) + @LogMessage(messageTemplate = IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT_WITH_CAUSE) }) public void pdtIndirectReferenceLateInitializing2() throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); @@ -209,8 +210,8 @@ public void pdtIndirectReferenceLateInitializing2() throws IOException { PdfDictionary catalogDict = document.getCatalog().getPdfObject(); PdfObject object1 = catalogDict.get(new PdfName("Smth1")); PdfObject object2 = catalogDict.get(new PdfName("Smth2")); - Assert.assertTrue(object1 instanceof PdfNull); - Assert.assertTrue(object2 instanceof PdfArray); + Assertions.assertTrue(object1 instanceof PdfNull); + Assertions.assertTrue(object2 instanceof PdfArray); } @Test @@ -243,18 +244,18 @@ public void pdtIndirectReferenceLateInitializing3() { PdfObject object1 = arrayClone.get(1, false); PdfObject object2 = arrayClone.get(2, false); - Assert.assertTrue(object0 instanceof PdfString); - Assert.assertTrue(object1 instanceof PdfDictionary); - Assert.assertTrue(object2 instanceof PdfNull); + Assertions.assertTrue(object0 instanceof PdfString); + Assertions.assertTrue(object1 instanceof PdfDictionary); + Assertions.assertTrue(object2 instanceof PdfNull); PdfString string1 = (PdfString)object0; - Assert.assertTrue(string != string1); - Assert.assertTrue(string.getValue().equals(string1.getValue())); + Assertions.assertTrue(string != string1); + Assertions.assertTrue(string.getValue().equals(string1.getValue())); PdfDictionary dict1 = (PdfDictionary) object1; - Assert.assertTrue(dict1.getIndirectReference().getObjNumber() == dict.getIndirectReference().getObjNumber()); - Assert.assertTrue(dict1.getIndirectReference().getGenNumber() == dict.getIndirectReference().getGenNumber()); - Assert.assertTrue(dict1 == dict); + Assertions.assertTrue(dict1.getIndirectReference().getObjNumber() == dict.getIndirectReference().getObjNumber()); + Assertions.assertTrue(dict1.getIndirectReference().getGenNumber() == dict.getIndirectReference().getGenNumber()); + Assertions.assertTrue(dict1 == dict); document.close(); } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfObjectUnitTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfObjectUnitTest.java index d4b6c1db0d..e33f999e1f 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfObjectUnitTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfObjectUnitTest.java @@ -26,14 +26,13 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.exceptions.KernelExceptionMessageConstant; import com.itextpdf.kernel.exceptions.PdfException; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.IOException; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfObjectUnitTest extends ExtendedITextTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/kernel/pdf/PdfObjectUnitTest/"; @@ -42,9 +41,9 @@ public class PdfObjectUnitTest extends ExtendedITextTest { public void noWriterForMakingIndirectTest() throws IOException { PdfDocument pdfDocument = new PdfDocument(new PdfReader(SOURCE_FOLDER + "noWriterForMakingIndirect.pdf")); PdfDictionary pdfDictionary = new PdfDictionary(); - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> pdfDictionary.makeIndirect(pdfDocument)); - Assert.assertEquals(KernelExceptionMessageConstant.THERE_IS_NO_ASSOCIATE_PDF_WRITER_FOR_MAKING_INDIRECTS, + Assertions.assertEquals(KernelExceptionMessageConstant.THERE_IS_NO_ASSOCIATE_PDF_WRITER_FOR_MAKING_INDIRECTS, exception.getMessage()); } @@ -52,9 +51,9 @@ public void noWriterForMakingIndirectTest() throws IOException { public void copyDocInReadingModeTest() throws IOException { PdfDocument pdfDocument = new PdfDocument(new PdfReader(SOURCE_FOLDER + "copyDocInReadingMode.pdf")); PdfDictionary pdfDictionary = new PdfDictionary(); - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> pdfDictionary.processCopying(pdfDocument, true)); - Assert.assertEquals(KernelExceptionMessageConstant.CANNOT_COPY_TO_DOCUMENT_OPENED_IN_READING_MODE, + Assertions.assertEquals(KernelExceptionMessageConstant.CANNOT_COPY_TO_DOCUMENT_OPENED_IN_READING_MODE, exception.getMessage()); } @@ -62,9 +61,9 @@ public void copyDocInReadingModeTest() throws IOException { public void copyIndirectObjectTest() { PdfDocument pdfDocument = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); PdfObject pdfObject = pdfDocument.getPdfObject(1); - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> pdfObject.copyTo(pdfDocument, true)); - Assert.assertEquals( + Assertions.assertEquals( KernelExceptionMessageConstant.CANNOT_COPY_INDIRECT_OBJECT_FROM_THE_DOCUMENT_THAT_IS_BEING_WRITTEN, exception.getMessage()); } @@ -74,8 +73,8 @@ public void copyFlushedObjectTest() { PdfDocument pdfDocument = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); PdfObject pdfObject = pdfDocument.getPdfObject(1); pdfObject.flush(); - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> pdfObject.copyContent(pdfObject, pdfDocument)); - Assert.assertEquals(KernelExceptionMessageConstant.CANNOT_COPY_FLUSHED_OBJECT, exception.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.CANNOT_COPY_FLUSHED_OBJECT, exception.getMessage()); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfObjectWrapperUnitTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfObjectWrapperUnitTest.java index e48601ccd6..b20250e404 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfObjectWrapperUnitTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfObjectWrapperUnitTest.java @@ -25,23 +25,22 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.exceptions.KernelExceptionMessageConstant; import com.itextpdf.kernel.exceptions.PdfException; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfObjectWrapperUnitTest extends ExtendedITextTest { @Test public void directObjectsCouldNotBeWrappedTest01() { PdfDictionary pdfDictionary = new PdfDictionary(); - Assert.assertNull(pdfDictionary.getIndirectReference()); + Assertions.assertNull(pdfDictionary.getIndirectReference()); // PdfCatalog is one of PdfObjectWrapper implementations. The issue could be reproduced on any of them, not only on this one - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> new PdfCatalog(pdfDictionary)); - Assert.assertEquals(KernelExceptionMessageConstant.OBJECT_MUST_BE_INDIRECT_TO_WORK_WITH_THIS_WRAPPER, + Assertions.assertEquals(KernelExceptionMessageConstant.OBJECT_MUST_BE_INDIRECT_TO_WORK_WITH_THIS_WRAPPER, exception.getMessage()); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfOutlineTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfOutlineTest.java index 59f25df334..e1dfaf8869 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfOutlineTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfOutlineTest.java @@ -39,7 +39,6 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -48,26 +47,26 @@ This file is part of the iText (R) project. import java.util.List; import java.util.Set; import javax.xml.parsers.ParserConfigurationException; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import org.xml.sax.SAXException; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfOutlineTest extends ExtendedITextTest { public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/kernel/pdf/PdfOutlineTest/"; public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/kernel/pdf/PdfOutlineTest/"; - @BeforeClass + @BeforeAll public static void before() { createOrClearDestinationFolder(DESTINATION_FOLDER); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(DESTINATION_FOLDER); } @@ -89,7 +88,7 @@ public void createSimpleDocWithOutlines() throws IOException, InterruptedExcepti pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + filename, SOURCE_FOLDER + "cmp_" + filename, + Assertions.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + filename, SOURCE_FOLDER + "cmp_" + filename, DESTINATION_FOLDER, "diff_")); } @@ -99,9 +98,9 @@ public void outlinesTest() throws IOException { PdfOutline outlines = pdfDoc.getOutlines(false); List children = outlines.getAllChildren().get(0).getAllChildren(); - Assert.assertEquals(outlines.getTitle(), "Outlines"); - Assert.assertEquals(children.size(), 13); - Assert.assertTrue(children.get(0).getDestination() instanceof PdfStringDestination); + Assertions.assertEquals(outlines.getTitle(), "Outlines"); + Assertions.assertEquals(children.size(), 13); + Assertions.assertTrue(children.get(0).getDestination() instanceof PdfStringDestination); } @Test @@ -110,9 +109,9 @@ public void outlinesWithPagesTest() throws IOException { PdfPage page = pdfDoc.getPage(52); List pageOutlines = page.getOutlines(true); try { - Assert.assertEquals(3, pageOutlines.size()); - Assert.assertTrue(pageOutlines.get(0).getTitle().equals("Safari")); - Assert.assertEquals(pageOutlines.get(0).getAllChildren().size(), 4); + Assertions.assertEquals(3, pageOutlines.size()); + Assertions.assertTrue(pageOutlines.get(0).getTitle().equals("Safari")); + Assertions.assertEquals(pageOutlines.get(0).getAllChildren().size(), 4); } finally { pdfDoc.close(); } @@ -140,7 +139,7 @@ public void addOutlinesToDocumentTest() throws IOException, InterruptedException pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + filename, SOURCE_FOLDER + "cmp_" + filename, + Assertions.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + filename, SOURCE_FOLDER + "cmp_" + filename, DESTINATION_FOLDER, "diff_")); } @@ -151,8 +150,8 @@ public void readOutlinesFromDocumentTest() throws IOException { PdfDocument pdfDoc = new PdfDocument(new PdfReader(filename)); PdfOutline outlines = pdfDoc.getOutlines(false); try { - Assert.assertEquals(3, outlines.getAllChildren().size()); - Assert.assertEquals("firstPageChild", outlines.getAllChildren().get(1).getAllChildren().get(0).getTitle()); + Assertions.assertEquals(3, outlines.getAllChildren().size()); + Assertions.assertEquals("firstPageChild", outlines.getAllChildren().get(1).getAllChildren().get(0).getTitle()); } finally { pdfDoc.close(); } @@ -176,7 +175,7 @@ public void removePageWithOutlinesTest() throws IOException, InterruptedExceptio if (diffContent != null || diffTags != null) { diffContent = diffContent != null ? diffContent : ""; diffTags = diffTags != null ? diffTags : ""; - Assert.fail(diffContent + diffTags); + Assertions.fail(diffContent + diffTags); } } @@ -190,7 +189,7 @@ public void readRemovedPageWithOutlinesTest() throws IOException { PdfPage page = pdfDoc.getPage(102); List pageOutlines = page.getOutlines(false); try { - Assert.assertEquals(4, pageOutlines.size()); + Assertions.assertEquals(4, pageOutlines.size()); } finally { pdfDoc.close(); } @@ -208,7 +207,7 @@ public void updateOutlineTitle() throws IOException, InterruptedException { pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + filename, SOURCE_FOLDER + "cmp_" + filename, + Assertions.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + filename, SOURCE_FOLDER + "cmp_" + filename, DESTINATION_FOLDER, "diff_")); } @@ -222,11 +221,11 @@ public void getOutlinesInvalidParentLink() throws IOException { PdfOutline firstOutline = outlines.getAllChildren().get(0); PdfOutline secondOutline = outlines.getAllChildren().get(1); try { - Assert.assertEquals(2, outlines.getAllChildren().size()); - Assert.assertEquals("First Page", firstOutline.getTitle()); - Assert.assertEquals(outlines, firstOutline.getParent()); - Assert.assertEquals("Second Page", secondOutline.getTitle()); - Assert.assertEquals(outlines, secondOutline.getParent()); + Assertions.assertEquals(2, outlines.getAllChildren().size()); + Assertions.assertEquals("First Page", firstOutline.getTitle()); + Assertions.assertEquals(outlines, firstOutline.getParent()); + Assertions.assertEquals("Second Page", secondOutline.getTitle()); + Assertions.assertEquals(outlines, secondOutline.getParent()); } finally { pdfDoc.close(); } @@ -240,7 +239,7 @@ public void readOutlineTitle() throws IOException { PdfOutline outlines = pdfDoc.getOutlines(false); PdfOutline outline = outlines.getAllChildren().get(0).getAllChildren().get(1); try { - Assert.assertEquals("New Title", outline.getTitle()); + Assertions.assertEquals("New Title", outline.getTitle()); } finally { pdfDoc.close(); } @@ -266,7 +265,7 @@ public void addOutlineInNotOutlineMode() throws IOException, InterruptedExceptio pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + filename, SOURCE_FOLDER + "cmp_" + filename, + Assertions.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + filename, SOURCE_FOLDER + "cmp_" + filename, DESTINATION_FOLDER, "diff_")); } @@ -277,7 +276,7 @@ public void readOutlineAddedInNotOutlineMode() throws IOException { List pageOutlines = pdfDoc.getPage(102).getOutlines(true); try { - Assert.assertEquals(5, pageOutlines.size()); + Assertions.assertEquals(5, pageOutlines.size()); } finally { pdfDoc.close(); } @@ -291,8 +290,8 @@ public void createDocWithOutlines() throws IOException { PdfOutline outlines = pdfDoc.getOutlines(false); try { - Assert.assertEquals(2, outlines.getAllChildren().size()); - Assert.assertEquals("First Page", outlines.getAllChildren().get(0).getTitle()); + Assertions.assertEquals(2, outlines.getAllChildren().size()); + Assertions.assertEquals("First Page", outlines.getAllChildren().get(0).getTitle()); } finally { pdfDoc.close(); } @@ -321,8 +320,8 @@ public void copyPagesWithOutlines() throws IOException { pdfDoc.copyPagesTo(pages, pdfDoc1); pdfDoc.close(); - Assert.assertEquals(6, pdfDoc1.getNumberOfPages()); - Assert.assertEquals(4, pdfDoc1.getOutlines(false).getAllChildren().get(0).getAllChildren().size()); + Assertions.assertEquals(6, pdfDoc1.getNumberOfPages()); + Assertions.assertEquals(4, pdfDoc1.getOutlines(false).getAllChildren().get(0).getAllChildren().size()); pdfDoc1.close(); } @@ -369,7 +368,7 @@ public void addOutlinesWithNamedDestinations01() throws IOException, Interrupted thirdOutline.addDestination(PdfDestination.makeDestination(new PdfString("test3"))); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(filename, SOURCE_FOLDER + "cmp_outlinesWithNamedDestinations01.pdf", + Assertions.assertNull(new CompareTool().compareByContent(filename, SOURCE_FOLDER + "cmp_outlinesWithNamedDestinations01.pdf", DESTINATION_FOLDER, "diff_")); } @@ -412,7 +411,7 @@ public void addOutlinesWithNamedDestinations02() throws IOException, Interrupted thirdOutline.addDestination(PdfDestination.makeDestination(new PdfString("page3"))); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(filename, SOURCE_FOLDER + "cmp_outlinesWithNamedDestinations02.pdf", + Assertions.assertNull(new CompareTool().compareByContent(filename, SOURCE_FOLDER + "cmp_outlinesWithNamedDestinations02.pdf", DESTINATION_FOLDER, "diff_")); } @@ -424,7 +423,7 @@ public void outlineStackOverflowTest01() throws IOException { try { pdfDoc.getOutlines(true); } catch (StackOverflowError e) { - Assert.fail("StackOverflow thrown when reading document with a large number of outlines."); + Assertions.fail("StackOverflow thrown when reading document with a large number of outlines."); } } @@ -437,7 +436,7 @@ public void outlineTypeNull() throws IOException, InterruptedException { PdfDocument pdfDoc = new PdfDocument(reader, writer); pdfDoc.removePage(3); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(outputFile, SOURCE_FOLDER + "cmp_" + filename + ".pdf", + Assertions.assertNull(new CompareTool().compareByContent(outputFile, SOURCE_FOLDER + "cmp_" + filename + ".pdf", DESTINATION_FOLDER, "diff_")); } @@ -453,7 +452,7 @@ public void removeAllOutlinesTest() throws IOException, InterruptedException { pdfDocument.getOutlines(true).removeOutline(); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(output, cmp, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(output, cmp, DESTINATION_FOLDER, "diff_")); } @Test @@ -470,7 +469,7 @@ public void removeOneOutlineTest() throws IOException, InterruptedException { toRemove.removeOutline(); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(output, cmp, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(output, cmp, DESTINATION_FOLDER, "diff_")); } @Test @@ -478,10 +477,10 @@ public void testReinitializingOutlines() throws IOException { String input = SOURCE_FOLDER + "outlineTree.pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfReader(input)); PdfOutline root = pdfDocument.getOutlines(false); - Assert.assertEquals(4, root.getAllChildren().size()); + Assertions.assertEquals(4, root.getAllChildren().size()); pdfDocument.getCatalog().getPdfObject().remove(PdfName.Outlines); root = pdfDocument.getOutlines(true); - Assert.assertNull(root); + Assertions.assertNull(root); pdfDocument.close(); } @@ -493,11 +492,11 @@ public void removePageInDocWithSimpleOutlineTreeStructTest() throws IOException, PdfDocument pdfDocument = new PdfDocument(new PdfReader(input), CompareTool.createTestPdfWriter(output)); pdfDocument.removePage(2); - Assert.assertEquals(2, pdfDocument.getNumberOfPages()); + Assertions.assertEquals(2, pdfDocument.getNumberOfPages()); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(output, cmp, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(output, cmp, DESTINATION_FOLDER, "diff_")); } @Test @@ -508,11 +507,11 @@ public void removePageInDocWithComplexOutlineTreeStructTest() throws IOException PdfDocument pdfDocument = new PdfDocument(new PdfReader(input), CompareTool.createTestPdfWriter(output)); pdfDocument.removePage(2); - Assert.assertEquals(2, pdfDocument.getNumberOfPages()); + Assertions.assertEquals(2, pdfDocument.getNumberOfPages()); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(output, cmp, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(output, cmp, DESTINATION_FOLDER, "diff_")); } @Test @@ -551,12 +550,12 @@ public void constructOutlinesNoTitleTest() throws IOException { outlineDictionary.put(PdfName.First, first); first.put(PdfName.Parent, outlineDictionary); - Exception exception = Assert.assertThrows( + Exception exception = Assertions.assertThrows( PdfException.class, () -> pdfDocument.getCatalog() .constructOutlines(outlineDictionary, new EmptyNameTree()) ); - Assert.assertEquals( + Assertions.assertEquals( MessageFormatUtil.format(KernelExceptionMessageConstant.CORRUPTED_OUTLINE_NO_TITLE_ENTRY, first.indirectReference), exception.getMessage()); @@ -580,14 +579,14 @@ public void checkParentOfOutlinesTest() throws IOException { firstOutline.addDestination(PdfExplicitDestination.createFit(firstPage)); PdfOutline resultedRoot = pdfDocument.getOutlines(true); - Assert.assertEquals(2, resultedRoot.getAllChildren().size()); - Assert.assertEquals(resultedRoot, resultedRoot.getAllChildren().get(0).getParent()); - Assert.assertEquals(resultedRoot, resultedRoot.getAllChildren().get(1).getParent()); + Assertions.assertEquals(2, resultedRoot.getAllChildren().size()); + Assertions.assertEquals(resultedRoot, resultedRoot.getAllChildren().get(0).getParent()); + Assertions.assertEquals(resultedRoot, resultedRoot.getAllChildren().get(1).getParent()); PdfOutline resultedFirstOutline = resultedRoot.getAllChildren().get(0); - Assert.assertEquals(2, resultedFirstOutline.getAllChildren().size()); - Assert.assertEquals(resultedFirstOutline, resultedFirstOutline.getAllChildren().get(0).getParent()); - Assert.assertEquals(resultedFirstOutline, resultedFirstOutline.getAllChildren().get(1).getParent()); + Assertions.assertEquals(2, resultedFirstOutline.getAllChildren().size()); + Assertions.assertEquals(resultedFirstOutline, resultedFirstOutline.getAllChildren().get(0).getParent()); + Assertions.assertEquals(resultedFirstOutline, resultedFirstOutline.getAllChildren().get(1).getParent()); } } @@ -606,16 +605,16 @@ public void checkNestedOutlinesParentTest() throws IOException { firstOutline.addDestination(PdfExplicitDestination.createFit(firstPage)); PdfOutline resultedRoot = pdfDocument.getOutlines(true); - Assert.assertEquals(1, resultedRoot.getAllChildren().size()); - Assert.assertEquals(resultedRoot, resultedRoot.getAllChildren().get(0).getParent()); + Assertions.assertEquals(1, resultedRoot.getAllChildren().size()); + Assertions.assertEquals(resultedRoot, resultedRoot.getAllChildren().get(0).getParent()); PdfOutline resultedFirstOutline = resultedRoot.getAllChildren().get(0); - Assert.assertEquals(1, resultedFirstOutline.getAllChildren().size()); - Assert.assertEquals(resultedFirstOutline, resultedFirstOutline.getAllChildren().get(0).getParent()); + Assertions.assertEquals(1, resultedFirstOutline.getAllChildren().size()); + Assertions.assertEquals(resultedFirstOutline, resultedFirstOutline.getAllChildren().get(0).getParent()); PdfOutline resultedSecondOutline = resultedFirstOutline.getAllChildren().get(0); - Assert.assertEquals(1, resultedSecondOutline.getAllChildren().size()); - Assert.assertEquals(resultedSecondOutline, resultedSecondOutline.getAllChildren().get(0).getParent()); + Assertions.assertEquals(1, resultedSecondOutline.getAllChildren().size()); + Assertions.assertEquals(resultedSecondOutline, resultedSecondOutline.getAllChildren().get(0).getParent()); } } @@ -629,23 +628,23 @@ public void setOutlinePropertiesTest() throws IOException { PdfOutline rootOutline = pdfDocument.getOutlines(true); PdfOutline outline = rootOutline.addOutline("Outline"); - Assert.assertTrue(outline.isOpen()); - Assert.assertNull(outline.getStyle()); - Assert.assertNull(outline.getColor()); + Assertions.assertTrue(outline.isOpen()); + Assertions.assertNull(outline.getStyle()); + Assertions.assertNull(outline.getColor()); outline.getContent().put(PdfName.C, new PdfArray(ColorConstants.BLACK.getColorValue())); outline.getContent().put(PdfName.F, new PdfNumber(2)); outline.getContent().put(PdfName.Count, new PdfNumber(4)); - Assert.assertTrue(outline.isOpen()); - Assert.assertEquals(new Integer(2), outline.getStyle()); - Assert.assertEquals(ColorConstants.BLACK, outline.getColor()); + Assertions.assertTrue(outline.isOpen()); + Assertions.assertEquals(new Integer(2), outline.getStyle()); + Assertions.assertEquals(ColorConstants.BLACK, outline.getColor()); outline.getContent().put(PdfName.Count, new PdfNumber(0)); - Assert.assertTrue(outline.isOpen()); + Assertions.assertTrue(outline.isOpen()); outline.getContent().put(PdfName.Count, new PdfNumber(-5)); - Assert.assertFalse(outline.isOpen()); + Assertions.assertFalse(outline.isOpen()); } } @@ -681,8 +680,8 @@ public void checkPossibleInfiniteLoopWithSameNextAndPrevLinkTest() throws IOExce AssertUtil.doesNotThrow(() -> pdfDocument.getCatalog() .constructOutlines(outlineDictionary, new EmptyNameTree())); PdfOutline resultedOutline = pdfDocument.getOutlines(false); - Assert.assertEquals(2, resultedOutline.getAllChildren().size()); - Assert.assertEquals(resultedOutline.getAllChildren().get(1).getParent(), + Assertions.assertEquals(2, resultedOutline.getAllChildren().size()); + Assertions.assertEquals(resultedOutline.getAllChildren().get(1).getParent(), resultedOutline.getAllChildren().get(0).getParent()); } } @@ -712,8 +711,8 @@ public void checkPossibleInfiniteLoopWithSameFirstAndLastLinkTest() throws IOExc AssertUtil.doesNotThrow(() -> pdfDocument.getCatalog() .constructOutlines(outlineDictionary, new EmptyNameTree())); PdfOutline resultedOutline = pdfDocument.getOutlines(false); - Assert.assertEquals(1, resultedOutline.getAllChildren().size()); - Assert.assertEquals(resultedOutline, + Assertions.assertEquals(1, resultedOutline.getAllChildren().size()); + Assertions.assertEquals(resultedOutline, resultedOutline.getAllChildren().get(0).getParent()); } } @@ -724,11 +723,11 @@ public void outlineNoParentLinkInConservativeModeTest() throws IOException { PdfDocument pdfDocument = new PdfDocument( new PdfReader(SOURCE_FOLDER + "outlinesNoParentLink.pdf"))) { pdfDocument.getReader().setStrictnessLevel(StrictnessLevel.CONSERVATIVE); - Exception exception = Assert.assertThrows(PdfException.class, () -> pdfDocument.getOutlines(true)); + Exception exception = Assertions.assertThrows(PdfException.class, () -> pdfDocument.getOutlines(true)); //Hardcode indirectReference, cause there is no option to get this outline due to #getOutlines method // will be thrown an exception. - Assert.assertEquals( + Assertions.assertEquals( MessageFormatUtil.format(KernelExceptionMessageConstant.CORRUPTED_OUTLINE_NO_PARENT_ENTRY, "9 0 R"), exception.getMessage()); } @@ -740,11 +739,11 @@ public void outlineHasInfiniteLoopInConservativeModeTest() throws IOException { PdfDocument pdfDocument = new PdfDocument( new PdfReader(SOURCE_FOLDER + "outlinesHaveInfiniteLoop.pdf"))) { pdfDocument.getReader().setStrictnessLevel(StrictnessLevel.CONSERVATIVE); - Exception exception = Assert.assertThrows(PdfException.class, () -> pdfDocument.getOutlines(true)); + Exception exception = Assertions.assertThrows(PdfException.class, () -> pdfDocument.getOutlines(true)); //Hardcode indirectReference, cause there is no option to get this outline due to #getOutlines method // will be thrown an exception. - Assert.assertEquals( + Assertions.assertEquals( MessageFormatUtil.format( KernelExceptionMessageConstant.CORRUPTED_OUTLINE_DICTIONARY_HAS_INFINITE_LOOP, "<> /Prev 10 0 R /Title First Page >>"), @@ -774,30 +773,30 @@ public void createOutlinesWithDifferentVariantsOfChildrenTest() throws IOExcepti PdfOutline resultedA = pdfDocument.getOutlines(true); // Asserting children of root outline. - Assert.assertEquals(2, resultedA.getAllChildren().size()); - Assert.assertEquals(resultedA, resultedA.getAllChildren().get(0).getParent()); - Assert.assertEquals(resultedA, resultedA.getAllChildren().get(1).getParent()); - Assert.assertTrue(resultedA.getAllChildren().get(1).getAllChildren().isEmpty()); - Assert.assertEquals(2, resultedA.getAllChildren().get(0).getAllChildren().size()); + Assertions.assertEquals(2, resultedA.getAllChildren().size()); + Assertions.assertEquals(resultedA, resultedA.getAllChildren().get(0).getParent()); + Assertions.assertEquals(resultedA, resultedA.getAllChildren().get(1).getParent()); + Assertions.assertTrue(resultedA.getAllChildren().get(1).getAllChildren().isEmpty()); + Assertions.assertEquals(2, resultedA.getAllChildren().get(0).getAllChildren().size()); //Asserting children of B outline after reconstructing. PdfOutline resultedB = resultedA.getAllChildren().get(0); - Assert.assertEquals(resultedB, resultedB.getAllChildren().get(0).getParent()); - Assert.assertEquals(resultedB, resultedB.getAllChildren().get(1).getParent()); - Assert.assertTrue(resultedB.getAllChildren().get(1).getAllChildren().isEmpty()); - Assert.assertEquals(1, resultedB.getAllChildren().get(0).getAllChildren().size()); + Assertions.assertEquals(resultedB, resultedB.getAllChildren().get(0).getParent()); + Assertions.assertEquals(resultedB, resultedB.getAllChildren().get(1).getParent()); + Assertions.assertTrue(resultedB.getAllChildren().get(1).getAllChildren().isEmpty()); + Assertions.assertEquals(1, resultedB.getAllChildren().get(0).getAllChildren().size()); //Asserting children of E outline after reconstructing. PdfOutline resultedE = resultedB.getAllChildren().get(0); - Assert.assertEquals(resultedE, resultedE.getAllChildren().get(0).getParent()); - Assert.assertEquals(2, resultedE.getAllChildren().get(0).getAllChildren().size()); + Assertions.assertEquals(resultedE, resultedE.getAllChildren().get(0).getParent()); + Assertions.assertEquals(2, resultedE.getAllChildren().get(0).getAllChildren().size()); //Asserting children of F outline after reconstructing. PdfOutline resultedF = resultedE.getAllChildren().get(0); - Assert.assertEquals(resultedF, resultedF.getAllChildren().get(0).getParent()); - Assert.assertEquals(resultedF, resultedF.getAllChildren().get(1).getParent()); - Assert.assertTrue(resultedF.getAllChildren().get(0).getAllChildren().isEmpty()); - Assert.assertTrue(resultedF.getAllChildren().get(1).getAllChildren().isEmpty()); + Assertions.assertEquals(resultedF, resultedF.getAllChildren().get(0).getParent()); + Assertions.assertEquals(resultedF, resultedF.getAllChildren().get(1).getParent()); + Assertions.assertTrue(resultedF.getAllChildren().get(0).getAllChildren().isEmpty()); + Assertions.assertTrue(resultedF.getAllChildren().get(1).getAllChildren().isEmpty()); } } @@ -817,13 +816,13 @@ public void createOutlinesWithActionsTest() throws IOException, InterruptedExcep PdfDestination page1Dest = PdfExplicitDestination.createFit(firstPage); PdfAction page1Action = PdfAction.createGoTo(page1Dest); firstOutline.addAction(page1Action); - Assert.assertEquals(page1Dest.getPdfObject(), firstOutline.getDestination().getPdfObject()); + Assertions.assertEquals(page1Dest.getPdfObject(), firstOutline.getDestination().getPdfObject()); PdfAction page2Action = PdfAction.createGoTo(PdfExplicitDestination.createFit(secondPage)); secondOutline.addAction(page2Action); } - Assert.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + filename, SOURCE_FOLDER + "cmp_" + filename, + Assertions.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + filename, SOURCE_FOLDER + "cmp_" + filename, DESTINATION_FOLDER, "diff_")); } @@ -840,10 +839,10 @@ public void createOutlinesWithURIActionTest() throws IOException, InterruptedExc // Apparently it works! PdfAction action1 = PdfAction.createURI("https://example.com"); firstOutline.addAction(action1); - Assert.assertNull(firstOutline.getDestination()); + Assertions.assertNull(firstOutline.getDestination()); } - Assert.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + filename, SOURCE_FOLDER + "cmp_" + filename, + Assertions.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + filename, SOURCE_FOLDER + "cmp_" + filename, DESTINATION_FOLDER, "diff_")); } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfPageTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfPageTest.java index 493d666821..33f651cd7f 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfPageTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfPageTest.java @@ -27,28 +27,27 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.annot.PdfAnnotation; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.IOException; import java.util.Arrays; import java.util.Collections; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfPageTest extends ExtendedITextTest { private PdfDocument dummyDoc; - @Before + @BeforeEach public void before() { dummyDoc = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); dummyDoc.addNewPage(); } - @After + @AfterEach public void after() { dummyDoc.close(); } @@ -59,7 +58,7 @@ public void pageConstructorModifiedStateTest() { simulateIndirectState(pageDictionary); PdfPage pdfPage = new PdfPage(pageDictionary); - Assert.assertFalse(pageDictionary.isModified()); + Assertions.assertFalse(pageDictionary.isModified()); } @Test @@ -69,14 +68,14 @@ public void removeLastAnnotationTest() { PdfDictionary annotDictionary = new PdfDictionary(); pageDictionary.put(PdfName.Annots, new PdfArray(Collections.singletonList((PdfObject) annotDictionary))); - Assert.assertFalse(pageDictionary.isModified()); + Assertions.assertFalse(pageDictionary.isModified()); PdfPage pdfPage = new PdfPage(pageDictionary); pdfPage.removeAnnotation(PdfAnnotation.makeAnnotation(annotDictionary)); - Assert.assertTrue(pdfPage.getAnnotations().isEmpty()); - Assert.assertFalse(pageDictionary.containsKey(PdfName.Annots)); - Assert.assertTrue(pageDictionary.isModified()); + Assertions.assertTrue(pdfPage.getAnnotations().isEmpty()); + Assertions.assertFalse(pageDictionary.containsKey(PdfName.Annots)); + Assertions.assertTrue(pageDictionary.isModified()); } @Test @@ -89,14 +88,14 @@ public void removeAnnotationTest() { Arrays.asList(annotDictionary1, (PdfObject) annotDictionary2)) ); - Assert.assertFalse(pageDictionary.isModified()); + Assertions.assertFalse(pageDictionary.isModified()); PdfPage pdfPage = new PdfPage(pageDictionary); pdfPage.removeAnnotation(PdfAnnotation.makeAnnotation(annotDictionary1)); - Assert.assertEquals(1, pdfPage.getAnnotations().size()); - Assert.assertEquals(annotDictionary2, pdfPage.getAnnotations().get(0).getPdfObject()); - Assert.assertTrue(pageDictionary.isModified()); + Assertions.assertEquals(1, pdfPage.getAnnotations().size()); + Assertions.assertEquals(annotDictionary2, pdfPage.getAnnotations().get(0).getPdfObject()); + Assertions.assertTrue(pageDictionary.isModified()); } @Test @@ -112,15 +111,15 @@ public void removeAnnotationWithIndirectAnnotsArrayTest() { pageDictionary.put(PdfName.Annots, annotsArray); - Assert.assertFalse(annotsArray.isModified()); + Assertions.assertFalse(annotsArray.isModified()); PdfPage pdfPage = new PdfPage(pageDictionary); pdfPage.removeAnnotation(PdfAnnotation.makeAnnotation(annotDictionary1)); - Assert.assertEquals(1, pdfPage.getAnnotations().size()); - Assert.assertEquals(annotDictionary2, pdfPage.getAnnotations().get(0).getPdfObject()); - Assert.assertFalse(pageDictionary.isModified()); - Assert.assertTrue(annotsArray.isModified()); + Assertions.assertEquals(1, pdfPage.getAnnotations().size()); + Assertions.assertEquals(annotDictionary2, pdfPage.getAnnotations().get(0).getPdfObject()); + Assertions.assertFalse(pageDictionary.isModified()); + Assertions.assertTrue(annotsArray.isModified()); } @Test @@ -130,7 +129,7 @@ public void setArtBoxTest() { pageDictionary.put(PdfName.TrimBox, preExistingTrimBoxArr); simulateIndirectState(pageDictionary); - Assert.assertFalse(pageDictionary.isModified()); + Assertions.assertFalse(pageDictionary.isModified()); PdfPage pdfPage = new PdfPage(pageDictionary); pdfPage.setArtBox(new Rectangle(25, 40)); @@ -138,12 +137,12 @@ public void setArtBoxTest() { PdfArray expectedArtBoxArr = new PdfArray( Arrays.asList(new PdfNumber(0), new PdfNumber(0), new PdfNumber(25), (PdfObject) new PdfNumber(40)) ); - Assert.assertTrue( + Assertions.assertTrue( new CompareTool().compareArrays(pageDictionary.getAsArray(PdfName.ArtBox), expectedArtBoxArr)); // trimbox not removed - Assert.assertTrue( + Assertions.assertTrue( new CompareTool().compareArrays(pageDictionary.getAsArray(PdfName.TrimBox), preExistingTrimBoxArr)); - Assert.assertTrue(pageDictionary.isModified()); + Assertions.assertTrue(pageDictionary.isModified()); } @Test @@ -153,7 +152,7 @@ public void setTrimBoxTest() { pageDictionary.put(PdfName.ArtBox, preExistingArtBoxArr); simulateIndirectState(pageDictionary); - Assert.assertFalse(pageDictionary.isModified()); + Assertions.assertFalse(pageDictionary.isModified()); PdfPage pdfPage = new PdfPage(pageDictionary); pdfPage.setTrimBox(new Rectangle(25, 40)); @@ -161,12 +160,12 @@ public void setTrimBoxTest() { PdfArray expectedTrimBoxArr = new PdfArray( Arrays.asList(new PdfNumber(0), new PdfNumber(0), new PdfNumber(25), (PdfObject) new PdfNumber(40)) ); - Assert.assertTrue( + Assertions.assertTrue( new CompareTool().compareArrays(pageDictionary.getAsArray(PdfName.TrimBox), expectedTrimBoxArr)); // artbox not removed - Assert.assertTrue( + Assertions.assertTrue( new CompareTool().compareArrays(pageDictionary.getAsArray(PdfName.ArtBox), preExistingArtBoxArr)); - Assert.assertTrue(pageDictionary.isModified()); + Assertions.assertTrue(pageDictionary.isModified()); } /** diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfPageUnitTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfPageUnitTest.java index d8a9e209e9..21e3367728 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfPageUnitTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfPageUnitTest.java @@ -26,15 +26,14 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.exceptions.KernelExceptionMessageConstant; import com.itextpdf.kernel.exceptions.PdfException; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.IOException; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import static com.itextpdf.kernel.pdf.PageLabelNumberingStyle.DECIMAL_ARABIC_NUMERALS; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfPageUnitTest extends ExtendedITextTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/kernel/pdf/PdfPageUnitTest/"; @@ -43,18 +42,18 @@ public class PdfPageUnitTest extends ExtendedITextTest { public void cannotGetMcidIfDocIsNotTagged() { PdfDocument pdfDoc = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); PdfPage pdfPage = pdfDoc.addNewPage(); - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> pdfPage.getNextMcid()); - Assert.assertEquals(KernelExceptionMessageConstant.MUST_BE_A_TAGGED_DOCUMENT, exception.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.MUST_BE_A_TAGGED_DOCUMENT, exception.getMessage()); } @Test public void cannotSetPageLabelIfFirstPageLessThanOneTest() { PdfDocument pdfDoc = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); PdfPage pdfPage = pdfDoc.addNewPage(); - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> pdfPage.setPageLabel(DECIMAL_ARABIC_NUMERALS, "test_prefix", 0)); - Assert.assertEquals( + Assertions.assertEquals( KernelExceptionMessageConstant.IN_A_PAGE_LABEL_THE_PAGE_NUMBERS_MUST_BE_GREATER_OR_EQUAL_TO_1, exception.getMessage()); } @@ -63,9 +62,9 @@ public void cannotSetPageLabelIfFirstPageLessThanOneTest() { public void cannotFlushTagsIfNoTagStructureIsPresentTest() { PdfDocument pdfDoc = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); PdfPage pdfPage = pdfDoc.addNewPage(); - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> pdfPage.tryFlushPageTags()); - Assert.assertEquals(KernelExceptionMessageConstant.TAG_STRUCTURE_FLUSHING_FAILED_IT_MIGHT_BE_CORRUPTED, + Assertions.assertEquals(KernelExceptionMessageConstant.TAG_STRUCTURE_FLUSHING_FAILED_IT_MIGHT_BE_CORRUPTED, exception.getMessage()); } @@ -73,10 +72,10 @@ public void cannotFlushTagsIfNoTagStructureIsPresentTest() { public void mediaBoxAttributeIsNotPresentTest() throws IOException { PdfDocument pdfDoc = new PdfDocument(new PdfReader(SOURCE_FOLDER + "mediaBoxAttributeIsNotPresentTest.pdf")); PdfObject mediaBox = pdfDoc.getPage(1).getPdfObject().get(PdfName.MediaBox); - Assert.assertNull(mediaBox); + Assertions.assertNull(mediaBox); PdfPage page = pdfDoc.getPage(1); - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> page.getMediaBox()); - Assert.assertEquals(KernelExceptionMessageConstant.CANNOT_RETRIEVE_MEDIA_BOX_ATTRIBUTE, exception.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.CANNOT_RETRIEVE_MEDIA_BOX_ATTRIBUTE, exception.getMessage()); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfPagesTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfPagesTest.java index 68d623bed7..49cbdbb235 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfPagesTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfPagesTest.java @@ -41,7 +41,6 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -51,24 +50,24 @@ This file is part of the iText (R) project. import java.util.List; import java.util.Random; import java.util.Set; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfPagesTest extends ExtendedITextTest { public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/kernel/pdf/PdfPagesTest/"; public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/kernel/pdf/PdfPagesTest/"; private static final PdfName PageNum = new PdfName("PageNum"); - @BeforeClass + @BeforeAll public static void setup() { createDestinationFolder(DESTINATION_FOLDER); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(DESTINATION_FOLDER); } @@ -89,7 +88,7 @@ public void countDontCorrespondToRealTest() throws IOException { AssertUtil.doesNotThrow(() -> pdfDoc.addPage(1, page)); // we don't expect that Count will be different from real number of pages - Assert.assertThrows(NullPointerException.class, () -> pdfDoc.close()); + Assertions.assertThrows(NullPointerException.class, () -> pdfDoc.close()); } @Test @@ -136,7 +135,7 @@ public void reversePagesTest2() throws Exception { pdfDoc.movePage(i, n + 1); } pdfDoc.close(); - Assert.assertNull(new CompareTool() + Assertions.assertNull(new CompareTool() .compareByContent(DESTINATION_FOLDER + filename, SOURCE_FOLDER + "cmp_" + filename, DESTINATION_FOLDER, "diff")); } @@ -170,10 +169,10 @@ public void randomObjectPagesTest() throws IOException { int testPageXref = document.getPage(1000).getPdfObject().getIndirectReference().getObjNumber(); document.movePage(1000, 1000); - Assert.assertEquals(testPageXref, document.getPage(1000).getPdfObject().getIndirectReference().getObjNumber()); + Assertions.assertEquals(testPageXref, document.getPage(1000).getPdfObject().getIndirectReference().getObjNumber()); for (int i = 0; i < pages.length; i++) { - Assert.assertTrue("Move page", document.movePage(pages[i], i + 1)); + Assertions.assertTrue(document.movePage(pages[i], i + 1), "Move page"); } document.close(); @@ -214,7 +213,7 @@ public void randomNumberPagesTest() throws IOException { pdfDoc.movePage(j, i); } } - Assert.assertTrue(verifyIntegrity(pdfDoc.getCatalog().getPageTree()) == -1); + Assertions.assertTrue(verifyIntegrity(pdfDoc.getCatalog().getPageTree()) == -1); } pdfDoc.close(); @@ -232,10 +231,10 @@ public void insertFlushedPageTest() { page.flush(); pdfDoc.removePage(page); - Exception e = Assert.assertThrows(PdfException.class, + Exception e = Assertions.assertThrows(PdfException.class, () -> pdfDoc.addPage(1, page) ); - Assert.assertEquals(KernelExceptionMessageConstant.FLUSHED_PAGE_CANNOT_BE_ADDED_OR_INSERTED, e.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.FLUSHED_PAGE_CANNOT_BE_ADDED_OR_INSERTED, e.getMessage()); } @Test @@ -249,10 +248,10 @@ public void addFlushedPageTest() { page.flush(); pdfDoc.removePage(page); - Exception e = Assert.assertThrows(PdfException.class, + Exception e = Assertions.assertThrows(PdfException.class, () -> pdfDoc.addPage(page) ); - Assert.assertEquals(KernelExceptionMessageConstant.FLUSHED_PAGE_CANNOT_BE_ADDED_OR_INSERTED, e.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.FLUSHED_PAGE_CANNOT_BE_ADDED_OR_INSERTED, e.getMessage()); } @Test @@ -276,8 +275,8 @@ public void removeFlushedPage() throws IOException { page.flush(); } - Assert.assertTrue("Remove last page", pdfDoc.removePage(pdfDoc.getPage(pageCount))); - Assert.assertFalse("Free reference", pdfDoc.getXref().get(removedPageObjectNumber).checkState(PdfObject.FREE)); + Assertions.assertTrue(pdfDoc.removePage(pdfDoc.getPage(pageCount)), "Remove last page"); + Assertions.assertFalse(pdfDoc.getXref().get(removedPageObjectNumber).checkState(PdfObject.FREE), "Free reference"); pdfDoc.close(); verifyPagesOrder(DESTINATION_FOLDER + filename, pageCount - 1); @@ -290,10 +289,10 @@ public void removeFlushedPageFromTaggedDocument() { pdfDocument.addNewPage(); pdfDocument.getPage(1).flush(); - Exception e = Assert.assertThrows(PdfException.class, + Exception e = Assertions.assertThrows(PdfException.class, () -> pdfDocument.removePage(1) ); - Assert.assertEquals(KernelExceptionMessageConstant.FLUSHED_PAGE_CANNOT_BE_REMOVED, e.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.FLUSHED_PAGE_CANNOT_BE_REMOVED, e.getMessage()); } } @@ -304,10 +303,10 @@ public void removeFlushedPageFromDocumentWithAcroForm() { pdfDocument.addNewPage(); pdfDocument.getPage(1).flush(); - Exception e = Assert.assertThrows(PdfException.class, + Exception e = Assertions.assertThrows(PdfException.class, () -> pdfDocument.removePage(1) ); - Assert.assertEquals(KernelExceptionMessageConstant.FLUSHED_PAGE_CANNOT_BE_REMOVED, e.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.FLUSHED_PAGE_CANNOT_BE_REMOVED, e.getMessage()); } } @@ -316,9 +315,9 @@ public void testInheritedResources() throws IOException { PdfDocument pdfDocument = new PdfDocument(new PdfReader(SOURCE_FOLDER + "simpleInheritedResources.pdf")); PdfPage page = pdfDocument.getPage(1); PdfDictionary dict = page.getResources().getResource(PdfName.ExtGState); - Assert.assertEquals(2, dict.size()); + Assertions.assertEquals(2, dict.size()); PdfExtGState gState = new PdfExtGState((PdfDictionary) dict.get(new PdfName("Gs1"))); - Assert.assertEquals(10, gState.getLineWidth().intValue()); + Assertions.assertEquals(10, gState.getLineWidth().intValue()); } @Test @@ -345,7 +344,7 @@ public void readFormXObjectsWithCircularReferencesInResources() throws IOExcepti } // ensure resources XObject entry is read correctly - Assert.assertEquals(2, formXObjects.size()); + Assertions.assertEquals(2, formXObjects.size()); } @Test @@ -362,9 +361,9 @@ public void testInheritedResourcesUpdate() throws IOException, InterruptedExcept SOURCE_FOLDER + "cmp_" + "updateInheritedResources.pdf", DESTINATION_FOLDER, "diff"); - Assert.assertEquals(3, gsCount); - Assert.assertEquals("Gs3", newGsName.getValue()); - Assert.assertNull(compareResult); + Assertions.assertEquals(3, gsCount); + Assertions.assertEquals("Gs3", newGsName.getValue()); + Assertions.assertNull(compareResult); } @Test @@ -381,7 +380,7 @@ public void reorderInheritedResourcesTest() throws IOException, InterruptedExcep DESTINATION_FOLDER + "reorderInheritedFontResources.pdf", SOURCE_FOLDER + "cmp_reorderInheritedFontResources.pdf", DESTINATION_FOLDER, "diff_reorderInheritedFontResources_"); - Assert.assertNull(compareResult); + Assertions.assertNull(compareResult); } @Test @@ -400,9 +399,9 @@ public void getPageByDictionary() throws IOException { for (PdfObject pageObject : pageDictionaries) { PdfDictionary pageDictionary = (PdfDictionary) pageObject; - Assert.assertEquals(PdfName.Page, pageDictionary.get(PdfName.Type)); + Assertions.assertEquals(PdfName.Page, pageDictionary.get(PdfName.Type)); PdfPage page = pdfDoc.getPage(pageDictionary); - Assert.assertEquals(pageDictionary, page.getPdfObject()); + Assertions.assertEquals(pageDictionary, page.getPdfObject()); } pdfDoc.close(); } @@ -417,7 +416,7 @@ public void removePageWithFormFieldsTest() throws IOException, InterruptedExcept pdfDoc.removePage(1); } - Assert.assertNull( + Assertions.assertNull( new CompareTool().compareByContent(outPdf, SOURCE_FOLDER + "cmp_" + testName, DESTINATION_FOLDER)); } @@ -428,10 +427,10 @@ public void getPageSizeWithInheritedMediaBox() throws IOException { PdfDocument pdfDoc = new PdfDocument(new PdfReader(filename)); - Assert.assertEquals(0, pdfDoc.getPage(1).getPageSize().getLeft(), eps); - Assert.assertEquals(0, pdfDoc.getPage(1).getPageSize().getBottom(), eps); - Assert.assertEquals(595, pdfDoc.getPage(1).getPageSize().getRight(), eps); - Assert.assertEquals(842, pdfDoc.getPage(1).getPageSize().getTop(), eps); + Assertions.assertEquals(0, pdfDoc.getPage(1).getPageSize().getLeft(), eps); + Assertions.assertEquals(0, pdfDoc.getPage(1).getPageSize().getBottom(), eps); + Assertions.assertEquals(595, pdfDoc.getPage(1).getPageSize().getRight(), eps); + Assertions.assertEquals(842, pdfDoc.getPage(1).getPageSize().getTop(), eps); pdfDoc.close(); } @@ -446,7 +445,7 @@ public void pageThumbnailTest() throws Exception { .setThumbnailImage(new PdfImageXObject(ImageDataFactory.create(SOURCE_FOLDER + imageSrc))); new PdfCanvas(page).setFillColor(ColorConstants.RED).rectangle(100, 100, 400, 400).fill(); pdfDoc.close(); - Assert.assertNull(new CompareTool() + Assertions.assertNull(new CompareTool() .compareByContent(DESTINATION_FOLDER + filename, SOURCE_FOLDER + "cmp_" + filename, DESTINATION_FOLDER, "diff")); } @@ -456,7 +455,7 @@ public void rotationPagesRotationTest() throws IOException { String filename = "singlePageDocumentWithRotation.pdf"; PdfDocument pdfDoc = new PdfDocument(new PdfReader(SOURCE_FOLDER + filename)); PdfPage page = pdfDoc.getPage(1); - Assert.assertEquals("Inherited value is invalid", 90, page.getRotation()); + Assertions.assertEquals(90, page.getRotation(), "Inherited value is invalid"); } @Test @@ -468,7 +467,7 @@ public void pageTreeCleanupParentRefTest() throws IOException { PdfDocument pdfDoc = new PdfDocument(reader, writer); pdfDoc.close(); - Assert.assertTrue(testPageTreeParentsValid(src) && testPageTreeParentsValid(dest)); + Assertions.assertTrue(testPageTreeParentsValid(src) && testPageTreeParentsValid(dest)); } @Test @@ -483,13 +482,13 @@ public void pdfNumberInPageContentArrayTest() throws IOException { pdfDoc = new PdfDocument(CompareTool.createOutputReader(dest)); PdfObject pageDictWithInvalidContents = pdfDoc.getPdfObject(10); PdfArray invalidContentsArray = ((PdfDictionary) pageDictWithInvalidContents).getAsArray(PdfName.Contents); - Assert.assertEquals(5, invalidContentsArray.size()); + Assertions.assertEquals(5, invalidContentsArray.size()); - Assert.assertFalse(invalidContentsArray.get(0).isStream()); - Assert.assertFalse(invalidContentsArray.get(1).isStream()); - Assert.assertFalse(invalidContentsArray.get(2).isStream()); - Assert.assertFalse(invalidContentsArray.get(3).isStream()); - Assert.assertTrue(invalidContentsArray.get(4).isStream()); + Assertions.assertFalse(invalidContentsArray.get(0).isStream()); + Assertions.assertFalse(invalidContentsArray.get(1).isStream()); + Assertions.assertFalse(invalidContentsArray.get(2).isStream()); + Assertions.assertFalse(invalidContentsArray.get(3).isStream()); + Assertions.assertTrue(invalidContentsArray.get(4).isStream()); } private boolean testPageTreeParentsValid(String src) throws com.itextpdf.io.exceptions.IOException, java.io.IOException { @@ -533,8 +532,8 @@ public void testExcessiveXrefEntriesForCopyXObject() throws IOException { outputPdf.close(); inputPdf.close(); - Assert.assertNotNull(outputPdf.getXref()); - Assert.assertEquals(500, outputPdf.getXref().size() - inputPdf.getXref().size()); + Assertions.assertNotNull(outputPdf.getXref()); + Assertions.assertEquals(500, outputPdf.getXref().size() - inputPdf.getXref().size()); } @Test @@ -549,7 +548,7 @@ public void pageGetMediaBoxTooManyArgumentsTest() throws IOException { PdfPage pageOne = pdfDoc.getPage(1); Rectangle actual = pageOne.getPageSize(); - Assert.assertTrue(expected.equalsWithEpsilon(actual)); + Assertions.assertTrue(expected.equalsWithEpsilon(actual)); } @@ -559,8 +558,8 @@ public void closeDocumentWithRecursivePagesNodeReferencesThrowsExTest() throws I PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); ) { PdfDocument pdfDocument = new PdfDocument(reader, writer); - Exception e = Assert.assertThrows(PdfException.class, () -> pdfDocument.close()); - Assert.assertEquals(MessageFormatUtil.format(KernelExceptionMessageConstant.INVALID_PAGE_STRUCTURE, 2), e.getMessage()); + Exception e = Assertions.assertThrows(PdfException.class, () -> pdfDocument.close()); + Assertions.assertEquals(MessageFormatUtil.format(KernelExceptionMessageConstant.INVALID_PAGE_STRUCTURE, 2), e.getMessage()); } } @@ -570,10 +569,10 @@ public void getPageWithRecursivePagesNodeReferenceInAppendModeThrowExTest() thro PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); PdfDocument pdfDocument = new PdfDocument(reader, writer, new StampingProperties().useAppendMode()); ) { - Assert.assertEquals(2, pdfDocument.getNumberOfPages()); - Assert.assertNotNull(pdfDocument.getPage(1)); - Exception e = Assert.assertThrows(PdfException.class, () -> pdfDocument.getPage(2)); - Assert.assertEquals(MessageFormatUtil.format(KernelExceptionMessageConstant.INVALID_PAGE_STRUCTURE, 2), e.getMessage()); + Assertions.assertEquals(2, pdfDocument.getNumberOfPages()); + Assertions.assertNotNull(pdfDocument.getPage(1)); + Exception e = Assertions.assertThrows(PdfException.class, () -> pdfDocument.getPage(2)); + Assertions.assertEquals(MessageFormatUtil.format(KernelExceptionMessageConstant.INVALID_PAGE_STRUCTURE, 2), e.getMessage()); } } @@ -594,8 +593,8 @@ public void pageGetMediaBoxNotEnoughArgumentsTest() throws IOException { PdfDocument pdfDoc = new PdfDocument(reader); PdfPage pageOne = pdfDoc.getPage(1); - Exception e = Assert.assertThrows(PdfException.class, () -> pageOne.getPageSize()); - Assert.assertEquals(MessageFormatUtil.format(KernelExceptionMessageConstant.WRONG_MEDIA_BOX_SIZE_TOO_FEW_ARGUMENTS, 3), e.getMessage()); + Exception e = Assertions.assertThrows(PdfException.class, () -> pageOne.getPageSize()); + Assertions.assertEquals(MessageFormatUtil.format(KernelExceptionMessageConstant.WRONG_MEDIA_BOX_SIZE_TOO_FEW_ARGUMENTS, 3), e.getMessage()); } @Test @@ -614,7 +613,7 @@ public void insertIntermediateParentTest() throws IOException { pdfDoc.close(); - Assert.assertTrue(page.getPdfObject().isModified()); + Assertions.assertTrue(page.getPdfObject().isModified()); } @Test @@ -623,7 +622,7 @@ public void verifyPagesAreNotReadOnOpenTest() throws IOException { CustomPdfReader reader = new CustomPdfReader(srcFile); PdfDocument document = new PdfDocument(reader); document.close(); - Assert.assertFalse(reader.pagesAreRead); + Assertions.assertFalse(reader.pagesAreRead); } @Test @@ -639,8 +638,8 @@ public void copyAnnotationWithoutSubtypeTest() throws IOException { // We do expect that the following line will not throw any NPE PdfPage copiedPage = documentToMerge.getPage(1).copyTo(resultantDocument); - Assert.assertEquals(1, copiedPage.getAnnotations().size()); - Assert.assertNull(copiedPage.getAnnotations().get(0).getSubtype()); + Assertions.assertEquals(1, copiedPage.getAnnotations().size()); + Assertions.assertNull(copiedPage.getAnnotations().get(0).getSubtype()); resultantDocument.addPage(copiedPage); } @@ -660,8 +659,8 @@ public void readPagesInBlocksTest() throws IOException { reader.numOfPagesRead = 0; } - Assert.assertEquals(111, document.getNumberOfPages()); - Assert.assertEquals(10, maxAmountOfPagesReadAtATime); + Assertions.assertEquals(111, document.getNumberOfPages()); + Assertions.assertEquals(10, maxAmountOfPagesReadAtATime); document.close(); } @@ -678,13 +677,13 @@ public void readSinglePageTest() throws IOException { PdfArray pageIndRefArray = ((PdfDictionary) pdfPages.getPdfObject()).getAsArray(PdfName.Kids); document.getPage(amountOfPages); - Assert.assertEquals(1, getAmountOfReadPages(pageIndRefArray)); + Assertions.assertEquals(1, getAmountOfReadPages(pageIndRefArray)); document.getPage(amountOfPages / 2); - Assert.assertEquals(2, getAmountOfReadPages(pageIndRefArray)); + Assertions.assertEquals(2, getAmountOfReadPages(pageIndRefArray)); document.getPage(1); - Assert.assertEquals(3, getAmountOfReadPages(pageIndRefArray)); + Assertions.assertEquals(3, getAmountOfReadPages(pageIndRefArray)); document.close(); } @@ -696,7 +695,7 @@ public void implicitPagesTreeRebuildingTest() throws IOException, InterruptedExc String cmpFileName = SOURCE_FOLDER + "cmp_implicitPagesTreeRebuilding.pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfReader(inFileName), CompareTool.createTestPdfWriter(outFileName)); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName,cmpFileName, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName,cmpFileName, DESTINATION_FOLDER)); } @Test @@ -759,27 +758,27 @@ public void testPageTreeGenerationWhenFirstPdfPagesHasOnePageOnly() { for (int i = 0; i < totalPageCount; i++) { pdfDocument.addNewPage(); } - Assert.assertEquals(2, pdfDocument.getCatalog().getPageTree().getParents().size()); - Assert.assertEquals(PdfPagesTree.DEFAULT_LEAF_SIZE, + Assertions.assertEquals(2, pdfDocument.getCatalog().getPageTree().getParents().size()); + Assertions.assertEquals(PdfPagesTree.DEFAULT_LEAF_SIZE, pdfDocument.getCatalog().getPageTree().getParents().get(0).getCount()); // Leave only one page in the first pages tree for (int i = PdfPagesTree.DEFAULT_LEAF_SIZE - 1; i >= 1; i--) { pdfDocument.removePage(i); } - Assert.assertEquals(2, pdfDocument.getCatalog().getPageTree().getParents().size()); - Assert.assertEquals(1, + Assertions.assertEquals(2, pdfDocument.getCatalog().getPageTree().getParents().size()); + Assertions.assertEquals(1, pdfDocument.getCatalog().getPageTree().getParents().get(0).getCount()); // TODO DEVSIX-5575 remove expected exception and add proper assertions - Assert.assertThrows(NullPointerException.class, () -> pdfDocument.close()); + Assertions.assertThrows(NullPointerException.class, () -> pdfDocument.close()); } private static void findAndAssertNullPages(PdfDocument pdfDocument, Set nullPages) { for (Integer nullPage : nullPages) { int pageNum = (int)nullPage; - Exception exception = Assert.assertThrows(PdfException.class,()-> pdfDocument.getPage(pageNum)); - Assert.assertEquals(exception.getMessage() , MessageFormatUtil.format( + Exception exception = Assertions.assertThrows(PdfException.class,()-> pdfDocument.getPage(pageNum)); + Assertions.assertEquals(exception.getMessage() , MessageFormatUtil.format( IoLogMessageConstant.PAGE_TREE_IS_BROKEN_FAILED_TO_RETRIEVE_PAGE, pageNum)); } } @@ -797,16 +796,16 @@ private static int getAmountOfReadPages(PdfArray pageIndRefArray) { private static void verifyPagesOrder(String filename, int numOfPages) throws IOException { PdfReader reader = CompareTool.createOutputReader(filename); PdfDocument pdfDocument = new PdfDocument(reader); - Assert.assertEquals("Rebuilt", false, reader.hasRebuiltXref()); + Assertions.assertEquals(Boolean.FALSE, reader.hasRebuiltXref(), "Rebuilt"); for (int i = 1; i <= pdfDocument.getNumberOfPages(); i++) { PdfDictionary page = pdfDocument.getPage(i).getPdfObject(); - Assert.assertNotNull(page); + Assertions.assertNotNull(page); PdfNumber number = page.getAsNumber(PageNum); - Assert.assertEquals("Page number", i, number.intValue()); + Assertions.assertEquals(i, number.intValue(), "Page number"); } - Assert.assertEquals("Number of pages", numOfPages, pdfDocument.getNumberOfPages()); + Assertions.assertEquals(numOfPages, pdfDocument.getNumberOfPages(), "Number of pages"); pdfDocument.close(); } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfPagesTreeTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfPagesTreeTest.java index 8878447cd0..0f7ca05c1d 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfPagesTreeTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfPagesTreeTest.java @@ -22,17 +22,19 @@ This file is part of the iText (R) project. */ package com.itextpdf.kernel.pdf; +import com.itextpdf.commons.datastructures.NullUnlimitedList; +import com.itextpdf.commons.datastructures.SimpleArrayList; import com.itextpdf.io.source.ByteArrayOutputStream; -import com.itextpdf.kernel.pdf.PdfPagesTree.NullUnlimitedList; +import com.itextpdf.kernel.di.pagetree.DefaultPageTreeListFactory; +import com.itextpdf.kernel.di.pagetree.IPageTreeListFactory; import com.itextpdf.test.AssertUtil; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfPagesTreeTest extends ExtendedITextTest { @Test public void generateTreeDocHasNoPagesTest() { @@ -41,35 +43,57 @@ public void generateTreeDocHasNoPagesTest() { } @Test - public void nullUnlimitedListAddTest() { - NullUnlimitedList list = new NullUnlimitedList<>(); - list.add("hey"); - list.add("bye"); - Assert.assertEquals(2, list.size()); - list.add(-1, "hello"); - list.add(3, "goodbye"); - Assert.assertEquals(2, list.size()); + public void defaultImplementationIsExpectedInstance() { + PdfDocument pdfDoc = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); + pdfDoc.getCatalog().put(PdfName.Count, new PdfNumber(10)); + IPageTreeListFactory factory = pdfDoc.getDiContainer().getInstance(IPageTreeListFactory.class); + Assertions.assertTrue(factory instanceof DefaultPageTreeListFactory); + } + + + @Test + public void defaultImplementationWritingOnlyReturnArrayList() { + PdfDocument pdfDoc = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); + IPageTreeListFactory factory = pdfDoc.getDiContainer().getInstance(IPageTreeListFactory.class); + Assertions.assertTrue(factory.createList(null) instanceof SimpleArrayList); } @Test - public void nullUnlimitedListIndexOfTest() { - NullUnlimitedList list = new NullUnlimitedList<>(); - list.add("hey"); - list.add(null); - list.add("bye"); - list.add(null); - Assert.assertEquals(4, list.size()); - Assert.assertEquals(1, list.indexOf(null)); + public void defaultImplementationReadingAndModifyingNullUnlimitedList() { + PdfDocument pdfDoc = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); + IPageTreeListFactory factory = pdfDoc.getDiContainer().getInstance(IPageTreeListFactory.class); + PdfDictionary dict = new PdfDictionary(); + dict.put(PdfName.Count, new PdfNumber(Integer.MAX_VALUE)); + Assertions.assertTrue(factory.createList(dict) instanceof NullUnlimitedList); } + @Test - public void nullUnlimitedListRemoveTest() { - NullUnlimitedList list = new NullUnlimitedList<>(); - list.add("hey"); - list.add("bye"); - Assert.assertEquals(2, list.size()); - list.remove(-1); - list.remove(2); - Assert.assertEquals(2, list.size()); + public void defaultImplementationReadingAndModifyingArrayList() { + PdfDocument pdfDoc = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); + IPageTreeListFactory factory = pdfDoc.getDiContainer().getInstance(IPageTreeListFactory.class); + PdfDictionary dict = new PdfDictionary(); + dict.put(PdfName.Count, new PdfNumber(10)); + Assertions.assertTrue(factory.createList(dict) instanceof SimpleArrayList); + } + + + @Test + public void defaultImplementationReadingAndModifyingArrayListNegative() { + PdfDocument pdfDoc = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); + IPageTreeListFactory factory = pdfDoc.getDiContainer().getInstance(IPageTreeListFactory.class); + PdfDictionary dict = new PdfDictionary(); + dict.put(PdfName.Count, new PdfNumber(-10)); + Assertions.assertTrue(factory.createList(dict) instanceof NullUnlimitedList); + } + + + @Test + public void defaultImplementationReadingAndModifyingArrayListNull() { + PdfDocument pdfDoc = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); + IPageTreeListFactory factory = pdfDoc.getDiContainer().getInstance(IPageTreeListFactory.class); + PdfDictionary dict = new PdfDictionary(); + dict.put(PdfName.Count, new PdfNull()); + Assertions.assertTrue(factory.createList(dict) instanceof NullUnlimitedList); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfPrimitivesTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfPrimitivesTest.java index 6763f1ad30..b48f23b6b5 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfPrimitivesTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfPrimitivesTest.java @@ -28,20 +28,18 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.util.Random; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfPrimitivesTest extends ExtendedITextTest{ static final String destinationFolder = "./target/test/com/itextpdf/kernel/pdf/PdfPrimitivesTest/"; @@ -79,12 +77,12 @@ public String nextString() { } } - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(destinationFolder); } @@ -239,10 +237,10 @@ public void makeIndirectDirectOnlyPdfBoolean() { public void equalStrings() { PdfString a = (PdfString) new PdfString("abcd").makeIndirect(new PdfDocument(new PdfWriter(new ByteArrayOutputStream()))); PdfString b = new PdfString("abcd".getBytes(StandardCharsets.US_ASCII)); - Assert.assertTrue(a.equals(b)); + Assertions.assertTrue(a.equals(b)); PdfString c = new PdfString("abcd", "UTF-8"); - Assert.assertFalse(c.equals(a)); + Assertions.assertFalse(c.equals(a)); } @Test @@ -254,13 +252,13 @@ public void equalNumbers() { PdfNumber num1 = (PdfNumber) new PdfNumber(1).makeIndirect(document); PdfNumber num2 = new PdfNumber(2); - Assert.assertFalse(num1.equals(num2)); + Assertions.assertFalse(num1.equals(num2)); int hashCode = num1.hashCode(); num1.increment(); - Assert.assertTrue(num1.equals(num2)); - Assert.assertNotEquals(hashCode, num1.hashCode()); + Assertions.assertTrue(num1.equals(num2)); + Assertions.assertNotEquals(hashCode, num1.hashCode()); } PdfNumber a = new PdfNumber(1); @@ -268,48 +266,48 @@ public void equalNumbers() { PdfNumber b = new PdfNumber(2); PdfNumber bContent = new PdfNumber(b.getInternalContent()); - Assert.assertTrue(a.equals(aContent)); - Assert.assertEquals(a.hashCode(), aContent.hashCode()); - Assert.assertTrue(b.equals(bContent)); - Assert.assertEquals(b.hashCode(), bContent.hashCode()); - Assert.assertFalse(aContent.equals(bContent)); - Assert.assertNotEquals(aContent.hashCode(), bContent.hashCode()); + Assertions.assertTrue(a.equals(aContent)); + Assertions.assertEquals(a.hashCode(), aContent.hashCode()); + Assertions.assertTrue(b.equals(bContent)); + Assertions.assertEquals(b.hashCode(), bContent.hashCode()); + Assertions.assertFalse(aContent.equals(bContent)); + Assertions.assertNotEquals(aContent.hashCode(), bContent.hashCode()); aContent.increment(); - Assert.assertFalse(a.equals(aContent)); - Assert.assertNotEquals(a.hashCode(), aContent.hashCode()); - Assert.assertTrue(aContent.equals(bContent)); - Assert.assertEquals(aContent.hashCode(), bContent.hashCode()); + Assertions.assertFalse(a.equals(aContent)); + Assertions.assertNotEquals(a.hashCode(), aContent.hashCode()); + Assertions.assertTrue(aContent.equals(bContent)); + Assertions.assertEquals(aContent.hashCode(), bContent.hashCode()); } @Test public void equalNames() { PdfName a = (PdfName) new PdfName("abcd").makeIndirect(new PdfDocument(new PdfWriter(new ByteArrayOutputStream()))); PdfName b = new PdfName("abcd"); - Assert.assertTrue(a.equals(b)); + Assertions.assertTrue(a.equals(b)); } @Test public void equalBoolean() { PdfBoolean f = (PdfBoolean) new PdfBoolean(false).makeIndirect(new PdfDocument(new PdfWriter(new ByteArrayOutputStream()))); PdfBoolean t = new PdfBoolean(true); - Assert.assertFalse(f.equals(t)); - Assert.assertTrue(f.equals(PdfBoolean.FALSE)); - Assert.assertTrue(t.equals(PdfBoolean.TRUE)); + Assertions.assertFalse(f.equals(t)); + Assertions.assertTrue(f.equals(PdfBoolean.FALSE)); + Assertions.assertTrue(t.equals(PdfBoolean.TRUE)); } @Test public void equalNulls() { PdfNull a = (PdfNull) new PdfNull().makeIndirect(new PdfDocument(new PdfWriter(new ByteArrayOutputStream())));; - Assert.assertTrue(a.equals(PdfNull.PDF_NULL)); + Assertions.assertTrue(a.equals(PdfNull.PDF_NULL)); } @Test public void equalLiterals() { PdfLiteral a = new PdfLiteral("abcd"); PdfLiteral b = new PdfLiteral("abcd".getBytes(StandardCharsets.US_ASCII)); - Assert.assertTrue(a.equals(b)); + Assertions.assertTrue(a.equals(b)); } private PdfArray generatePdfArrayWithFloatNumbers(PdfDocument doc, boolean indirects) { diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfReaderDecodeTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfReaderDecodeTest.java index c48e795f01..7ec267e0ab 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfReaderDecodeTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfReaderDecodeTest.java @@ -29,16 +29,15 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfReaderDecodeTest extends ExtendedITextTest { public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/kernel/pdf/PdfReaderDecodeTest/"; @@ -56,16 +55,16 @@ public void noMemoryHandlerTest() throws IOException { stream.put(PdfName.Filter, array); stream.makeIndirect(pdfDocument); - Assert.assertEquals(51, PdfReader.decodeBytes(b, stream).length); + Assertions.assertEquals(51, PdfReader.decodeBytes(b, stream).length); array.add(PdfName.Fl); - Assert.assertEquals(40, PdfReader.decodeBytes(b, stream).length); + Assertions.assertEquals(40, PdfReader.decodeBytes(b, stream).length); array.add(PdfName.Fl); - Assert.assertEquals(992, PdfReader.decodeBytes(b, stream).length); + Assertions.assertEquals(992, PdfReader.decodeBytes(b, stream).length); array.add(PdfName.Fl); - Assert.assertEquals(1000000, PdfReader.decodeBytes(b, stream).length); + Assertions.assertEquals(1000000, PdfReader.decodeBytes(b, stream).length); // needed to close the document pdfDocument.addNewPage(); @@ -75,7 +74,7 @@ public void noMemoryHandlerTest() throws IOException { @Test @LogMessages(messages = { @LogMessage(messageTemplate = IoLogMessageConstant.INVALID_INDIRECT_REFERENCE), - @LogMessage(messageTemplate = IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT) + @LogMessage(messageTemplate = IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT_WITH_CAUSE) }) public void defaultMemoryHandlerTest() throws IOException { try (PdfDocument pdfDocument = new PdfDocument( @@ -87,23 +86,23 @@ public void defaultMemoryHandlerTest() throws IOException { PdfArray array = new PdfArray(); stream.put(PdfName.Filter, array); - Assert.assertEquals(51, PdfReader.decodeBytes(b, stream).length); + Assertions.assertEquals(51, PdfReader.decodeBytes(b, stream).length); array.add(PdfName.Fl); - Assert.assertEquals(40, PdfReader.decodeBytes(b, stream).length); + Assertions.assertEquals(40, PdfReader.decodeBytes(b, stream).length); array.add(PdfName.Fl); - Assert.assertEquals(992, PdfReader.decodeBytes(b, stream).length); + Assertions.assertEquals(992, PdfReader.decodeBytes(b, stream).length); array.add(PdfName.Fl); - Assert.assertEquals(1000000, PdfReader.decodeBytes(b, stream).length); + Assertions.assertEquals(1000000, PdfReader.decodeBytes(b, stream).length); } } @Test @LogMessages(messages = { @LogMessage(messageTemplate = IoLogMessageConstant.INVALID_INDIRECT_REFERENCE), - @LogMessage(messageTemplate = IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT) + @LogMessage(messageTemplate = IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT_WITH_CAUSE) }) public void customMemoryHandlerSingleTest() throws IOException { MemoryLimitsAwareHandler handler = new MemoryLimitsAwareHandler(); @@ -120,27 +119,27 @@ public void customMemoryHandlerSingleTest() throws IOException { PdfArray array = new PdfArray(); stream.put(PdfName.Filter, array); - Assert.assertEquals(51, PdfReader.decodeBytes(b, stream).length); + Assertions.assertEquals(51, PdfReader.decodeBytes(b, stream).length); array.add(PdfName.Fl); - Assert.assertEquals(40, PdfReader.decodeBytes(b, stream).length); + Assertions.assertEquals(40, PdfReader.decodeBytes(b, stream).length); array.add(PdfName.Fl); - Assert.assertEquals(992, PdfReader.decodeBytes(b, stream).length); + Assertions.assertEquals(992, PdfReader.decodeBytes(b, stream).length); array.add(PdfName.Fl); - Exception e = Assert.assertThrows(MemoryLimitsAwareException.class, + Exception e = Assertions.assertThrows(MemoryLimitsAwareException.class, () -> PdfReader.decodeBytes(b, stream) ); - Assert.assertEquals(KernelExceptionMessageConstant.DURING_DECOMPRESSION_SINGLE_STREAM_OCCUPIED_MORE_MEMORY_THAN_ALLOWED, e.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.DURING_DECOMPRESSION_SINGLE_STREAM_OCCUPIED_MORE_MEMORY_THAN_ALLOWED, e.getMessage()); } } @Test @LogMessages(messages = { @LogMessage(messageTemplate = IoLogMessageConstant.INVALID_INDIRECT_REFERENCE), - @LogMessage(messageTemplate = IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT) + @LogMessage(messageTemplate = IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT_WITH_CAUSE) }) public void oneFilterCustomMemoryHandlerSingleTest() throws IOException { MemoryLimitsAwareHandler handler = new MemoryLimitsAwareHandler(); @@ -158,18 +157,18 @@ public void oneFilterCustomMemoryHandlerSingleTest() throws IOException { stream.put(PdfName.Filter, array); // Limit is reached, but the stream has no filters. Therefore, we don't consider it to be suspicious. - Assert.assertEquals(51, PdfReader.decodeBytes(b, stream).length); + Assertions.assertEquals(51, PdfReader.decodeBytes(b, stream).length); // Limit is reached, but the stream has only one filter. Therefore, we don't consider it to be suspicious. array.add(PdfName.Fl); - Assert.assertEquals(40, PdfReader.decodeBytes(b, stream).length); + Assertions.assertEquals(40, PdfReader.decodeBytes(b, stream).length); } } @Test @LogMessages(messages = { @LogMessage(messageTemplate = IoLogMessageConstant.INVALID_INDIRECT_REFERENCE), - @LogMessage(messageTemplate = IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT) + @LogMessage(messageTemplate = IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT_WITH_CAUSE) }) public void overriddenMemoryHandlerAllStreamsAreSuspiciousTest() throws IOException { MemoryLimitsAwareHandler handler = new MemoryLimitsAwareHandler() { @@ -193,17 +192,17 @@ public boolean isMemoryLimitsAwarenessRequiredOnDecompression(PdfArray filters) array.add(PdfName.Fl); // Limit is reached, and the stream with one filter is considered to be suspicious. - Exception e = Assert.assertThrows(MemoryLimitsAwareException.class, + Exception e = Assertions.assertThrows(MemoryLimitsAwareException.class, () -> PdfReader.decodeBytes(b, stream) ); - Assert.assertEquals(KernelExceptionMessageConstant.DURING_DECOMPRESSION_SINGLE_STREAM_OCCUPIED_MORE_MEMORY_THAN_ALLOWED, e.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.DURING_DECOMPRESSION_SINGLE_STREAM_OCCUPIED_MORE_MEMORY_THAN_ALLOWED, e.getMessage()); } } @Test @LogMessages(messages = { @LogMessage(messageTemplate = IoLogMessageConstant.INVALID_INDIRECT_REFERENCE), - @LogMessage(messageTemplate = IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT) + @LogMessage(messageTemplate = IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT_WITH_CAUSE) }) public void overriddenMemoryHandlerNoStreamsAreSuspiciousTest() throws IOException { @@ -246,13 +245,13 @@ public void differentFiltersEmptyTest() { PdfStream stream = new PdfStream(b); stream.put(PdfName.Filter, array); - Assert.assertEquals(0, PdfReader.decodeBytes(b, stream).length); + Assertions.assertEquals(0, PdfReader.decodeBytes(b, stream).length); } @Test @LogMessages(messages = { @LogMessage(messageTemplate = IoLogMessageConstant.INVALID_INDIRECT_REFERENCE), - @LogMessage(messageTemplate = IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT) + @LogMessage(messageTemplate = IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT_WITH_CAUSE) }) public void customMemoryHandlerSumTest() throws IOException { MemoryLimitsAwareHandler handler = new MemoryLimitsAwareHandler(); @@ -266,17 +265,17 @@ public void customMemoryHandlerSumTest() throws IOException { PdfStream stream = pdfDocument.getFirstPage().getContentStream(0); byte[] b = stream.getBytes(false); - Exception e = Assert.assertThrows(MemoryLimitsAwareException.class, + Exception e = Assertions.assertThrows(MemoryLimitsAwareException.class, () -> PdfReader.decodeBytes(b, stream) ); - Assert.assertEquals(KernelExceptionMessageConstant.DURING_DECOMPRESSION_MULTIPLE_STREAMS_IN_SUM_OCCUPIED_MORE_MEMORY_THAN_ALLOWED, e.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.DURING_DECOMPRESSION_MULTIPLE_STREAMS_IN_SUM_OCCUPIED_MORE_MEMORY_THAN_ALLOWED, e.getMessage()); } } @Test @LogMessages(messages = { @LogMessage(messageTemplate = IoLogMessageConstant.INVALID_INDIRECT_REFERENCE), - @LogMessage(messageTemplate = IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT) + @LogMessage(messageTemplate = IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT_WITH_CAUSE) }) public void pageSumTest() throws IOException { MemoryLimitsAwareHandler handler = new MemoryLimitsAwareHandler(); @@ -287,17 +286,17 @@ public void pageSumTest() throws IOException { new ReaderProperties().setMemoryLimitsAwareHandler(handler)), new PdfWriter(new ByteArrayOutputStream()))) { - Exception e = Assert.assertThrows(MemoryLimitsAwareException.class, + Exception e = Assertions.assertThrows(MemoryLimitsAwareException.class, () -> pdfDocument.getFirstPage().getContentBytes() ); - Assert.assertEquals(KernelExceptionMessageConstant.DURING_DECOMPRESSION_MULTIPLE_STREAMS_IN_SUM_OCCUPIED_MORE_MEMORY_THAN_ALLOWED, e.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.DURING_DECOMPRESSION_MULTIPLE_STREAMS_IN_SUM_OCCUPIED_MORE_MEMORY_THAN_ALLOWED, e.getMessage()); } } @Test @LogMessages(messages = { @LogMessage(messageTemplate = IoLogMessageConstant.INVALID_INDIRECT_REFERENCE), - @LogMessage(messageTemplate = IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT) + @LogMessage(messageTemplate = IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT_WITH_CAUSE) }) public void pageAsSingleStreamTest() throws IOException { MemoryLimitsAwareHandler handler = new MemoryLimitsAwareHandler(); @@ -308,10 +307,10 @@ public void pageAsSingleStreamTest() throws IOException { new ReaderProperties().setMemoryLimitsAwareHandler(handler)), new PdfWriter(new ByteArrayOutputStream()))) { - Exception e = Assert.assertThrows(MemoryLimitsAwareException.class, + Exception e = Assertions.assertThrows(MemoryLimitsAwareException.class, () -> pdfDocument.getFirstPage().getContentBytes() ); - Assert.assertEquals(KernelExceptionMessageConstant.DURING_DECOMPRESSION_SINGLE_STREAM_OCCUPIED_MORE_MEMORY_THAN_ALLOWED, e.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.DURING_DECOMPRESSION_SINGLE_STREAM_OCCUPIED_MORE_MEMORY_THAN_ALLOWED, e.getMessage()); } } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfReaderTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfReaderTest.java index 3a154e318b..06305bd537 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfReaderTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfReaderTest.java @@ -50,7 +50,6 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.ByteArrayInputStream; import java.io.File; @@ -64,14 +63,16 @@ This file is part of the iText (R) project. import java.util.HashMap; import java.util.List; import java.util.Random; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -@Category(IntegrationTest.class) +import java.util.concurrent.TimeUnit; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Timeout; + +@Tag("IntegrationTest") public class PdfReaderTest extends ExtendedITextTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/kernel/pdf/PdfReaderTest/"; @@ -83,12 +84,12 @@ public class PdfReaderTest extends ExtendedITextTest { static final byte[] USER_PASSWORD = "Hello".getBytes(StandardCharsets.ISO_8859_1); - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(DESTINATION_FOLDER); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(DESTINATION_FOLDER); } @@ -106,27 +107,27 @@ public void openSimpleDoc() throws IOException { PdfReader reader = CompareTool.createOutputReader(filename); pdfDoc = new PdfDocument(reader); - Assert.assertEquals(author, pdfDoc.getDocumentInfo().getAuthor()); - Assert.assertEquals(creator, pdfDoc.getDocumentInfo().getCreator()); - Assert.assertEquals(title, pdfDoc.getDocumentInfo().getTitle()); + Assertions.assertEquals(author, pdfDoc.getDocumentInfo().getAuthor()); + Assertions.assertEquals(creator, pdfDoc.getDocumentInfo().getCreator()); + Assertions.assertEquals(title, pdfDoc.getDocumentInfo().getTitle()); PdfObject object = pdfDoc.getPdfObject(1); - Assert.assertEquals(PdfObject.DICTIONARY, object.getType()); - Assert.assertTrue(objectTypeEqualTo(object, PdfName.Catalog)); + Assertions.assertEquals(PdfObject.DICTIONARY, object.getType()); + Assertions.assertTrue(objectTypeEqualTo(object, PdfName.Catalog)); object = pdfDoc.getPdfObject(2); - Assert.assertEquals(PdfObject.DICTIONARY, object.getType()); - Assert.assertTrue(objectTypeEqualTo(object, PdfName.Pages)); + Assertions.assertEquals(PdfObject.DICTIONARY, object.getType()); + Assertions.assertTrue(objectTypeEqualTo(object, PdfName.Pages)); object = pdfDoc.getPdfObject(3); - Assert.assertEquals(PdfObject.DICTIONARY, object.getType()); + Assertions.assertEquals(PdfObject.DICTIONARY, object.getType()); object = pdfDoc.getPdfObject(4); - Assert.assertEquals(PdfObject.DICTIONARY, object.getType()); - Assert.assertTrue(objectTypeEqualTo(object, PdfName.Page)); + Assertions.assertEquals(PdfObject.DICTIONARY, object.getType()); + Assertions.assertTrue(objectTypeEqualTo(object, PdfName.Page)); - Assert.assertEquals(PdfObject.STREAM, pdfDoc.getPdfObject(5).getType()); + Assertions.assertEquals(PdfObject.STREAM, pdfDoc.getPdfObject(5).getType()); - Assert.assertFalse("No need in rebuildXref()", reader.hasRebuiltXref()); + Assertions.assertFalse(reader.hasRebuiltXref(), "No need in rebuildXref()"); pdfDoc.close(); } @@ -137,26 +138,26 @@ public void openSimpleDocWithFullCompression() throws IOException { PdfDocument pdfDoc = new PdfDocument(reader); PdfObject object = pdfDoc.getPdfObject(1); - Assert.assertEquals(PdfObject.DICTIONARY, object.getType()); - Assert.assertTrue(objectTypeEqualTo(object, PdfName.Catalog)); + Assertions.assertEquals(PdfObject.DICTIONARY, object.getType()); + Assertions.assertTrue(objectTypeEqualTo(object, PdfName.Catalog)); object = pdfDoc.getPdfObject(2); - Assert.assertEquals(PdfObject.DICTIONARY, object.getType()); - Assert.assertTrue(objectTypeEqualTo(object, PdfName.Pages)); + Assertions.assertEquals(PdfObject.DICTIONARY, object.getType()); + Assertions.assertTrue(objectTypeEqualTo(object, PdfName.Pages)); object = pdfDoc.getPdfObject(3); - Assert.assertEquals(PdfObject.DICTIONARY, object.getType()); + Assertions.assertEquals(PdfObject.DICTIONARY, object.getType()); object = pdfDoc.getPdfObject(4); - Assert.assertEquals(PdfObject.DICTIONARY, object.getType()); - Assert.assertTrue(objectTypeEqualTo(object, PdfName.Page)); + Assertions.assertEquals(PdfObject.DICTIONARY, object.getType()); + Assertions.assertTrue(objectTypeEqualTo(object, PdfName.Page)); object = pdfDoc.getPdfObject(5); - Assert.assertEquals(PdfObject.STREAM, object.getType()); + Assertions.assertEquals(PdfObject.STREAM, object.getType()); String content = "100 100 100 100 re\nf\n"; - Assert.assertArrayEquals(ByteUtils.getIsoBytes(content), ((PdfStream) object).getBytes()); + Assertions.assertArrayEquals(ByteUtils.getIsoBytes(content), ((PdfStream) object).getBytes()); - Assert.assertFalse("No need in rebuildXref()", reader.hasRebuiltXref()); + Assertions.assertFalse(reader.hasRebuiltXref(), "No need in rebuildXref()"); reader.close(); pdfDoc.close(); } @@ -181,14 +182,14 @@ public void objectStreamIncrementalUpdateReading() throws IOException { PdfDictionary customDict1 = catalogDict.getAsDictionary(new PdfName("CustomDict1")); PdfDictionary customDict2 = catalogDict.getAsDictionary(new PdfName("CustomDict2")); - Assert.assertEquals(1, customDict1.size()); - Assert.assertEquals(1, customDict2.size()); + Assertions.assertEquals(1, customDict1.size()); + Assertions.assertEquals(1, customDict2.size()); - Assert.assertEquals("Hello world updated.", customDict1.getAsString(new PdfName("Key1")).getValue()); - Assert.assertEquals("Hello world for second dictionary.", + Assertions.assertEquals("Hello world updated.", customDict1.getAsString(new PdfName("Key1")).getValue()); + Assertions.assertEquals("Hello world for second dictionary.", customDict2.getAsString(new PdfName("Key1")).getValue()); - Assert.assertFalse("No need in rebuildXref()", reader.hasRebuiltXref()); + Assertions.assertFalse(reader.hasRebuiltXref(), "No need in rebuildXref()"); pdfDoc.close(); } @@ -202,8 +203,8 @@ public void rereadReleasedObjectFromObjectStream() throws IOException { PdfDictionary customDict1 = catalogDict.getAsDictionary(new PdfName("CustomDict1")); PdfDictionary customDict2 = catalogDict.getAsDictionary(new PdfName("CustomDict2")); - Assert.assertTrue(customDict1.containsKey(new PdfName("CustomDict1Key1"))); - Assert.assertTrue(customDict2.containsKey(new PdfName("CustomDict2Key1"))); + Assertions.assertTrue(customDict1.containsKey(new PdfName("CustomDict1Key1"))); + Assertions.assertTrue(customDict2.containsKey(new PdfName("CustomDict2Key1"))); customDict2.clear(); customDict1.release(); @@ -212,10 +213,10 @@ public void rereadReleasedObjectFromObjectStream() throws IOException { customDict1 = catalogDict.getAsDictionary(new PdfName("CustomDict1")); customDict2 = catalogDict.getAsDictionary(new PdfName("CustomDict2")); - Assert.assertTrue(customDict1.containsKey(new PdfName("CustomDict1Key1"))); - Assert.assertFalse(customDict2.containsKey(new PdfName("CustomDict2Key1"))); + Assertions.assertTrue(customDict1.containsKey(new PdfName("CustomDict1Key1"))); + Assertions.assertFalse(customDict2.containsKey(new PdfName("CustomDict2Key1"))); - Assert.assertFalse("No need in rebuildXref()", reader.hasRebuiltXref()); + Assertions.assertFalse(reader.hasRebuiltXref(), "No need in rebuildXref()"); pdfDoc.close(); } @@ -225,7 +226,7 @@ public void openDocWithFlateFilter() throws IOException { PdfReader reader = new PdfReader(filename); PdfDocument document = new PdfDocument(reader); - Assert.assertEquals("Page count", 100, document.getNumberOfPages()); + Assertions.assertEquals(100, document.getNumberOfPages(), "Page count"); String contentTemplate = "q\n" + "BT\n" + @@ -240,11 +241,11 @@ public void openDocWithFlateFilter() throws IOException { for (int i = 1; i <= document.getNumberOfPages(); i++) { PdfPage page = document.getPage(i); byte[] content = page.getFirstContentStream().getBytes(); - Assert.assertEquals("Page content " + i, MessageFormatUtil.format(contentTemplate, i), new String(content)); + Assertions.assertEquals(MessageFormatUtil.format(contentTemplate, i), new String(content), "Page content " + i); } - Assert.assertFalse("No need in rebuildXref()", reader.hasRebuiltXref()); - Assert.assertFalse("No need in fixXref()", reader.hasFixedXref()); + Assertions.assertFalse(reader.hasRebuiltXref(), "No need in rebuildXref()"); + Assertions.assertFalse(reader.hasFixedXref(), "No need in fixXref()"); document.close(); } @@ -261,27 +262,27 @@ public void primitivesRead() throws IOException { document = new PdfDocument(reader); PdfObject object = document.getXref().get(1).getRefersTo(); - Assert.assertEquals(PdfObject.DICTIONARY, object.getType()); - Assert.assertTrue(objectTypeEqualTo(object, PdfName.Catalog)); + Assertions.assertEquals(PdfObject.DICTIONARY, object.getType()); + Assertions.assertTrue(objectTypeEqualTo(object, PdfName.Catalog)); object = document.getXref().get(2).getRefersTo(); - Assert.assertEquals(PdfObject.DICTIONARY, object.getType()); - Assert.assertTrue(objectTypeEqualTo(object, PdfName.Pages)); + Assertions.assertEquals(PdfObject.DICTIONARY, object.getType()); + Assertions.assertTrue(objectTypeEqualTo(object, PdfName.Pages)); object = document.getXref().get(3).getRefersTo(); - Assert.assertEquals(PdfObject.DICTIONARY, object.getType()); + Assertions.assertEquals(PdfObject.DICTIONARY, object.getType()); object = document.getXref().get(4).getRefersTo(); - Assert.assertEquals(PdfObject.DICTIONARY, object.getType()); - Assert.assertTrue(objectTypeEqualTo(object, PdfName.Page)); + Assertions.assertEquals(PdfObject.DICTIONARY, object.getType()); + Assertions.assertTrue(objectTypeEqualTo(object, PdfName.Page)); - Assert.assertEquals(PdfObject.STREAM, document.getXref().get(5).getRefersTo().getType()); + Assertions.assertEquals(PdfObject.STREAM, document.getXref().get(5).getRefersTo().getType()); object = document.getXref().get(6).getRefersTo(); - Assert.assertEquals(PdfObject.BOOLEAN, object.getType()); - Assert.assertNotNull(object.getIndirectReference()); + Assertions.assertEquals(PdfObject.BOOLEAN, object.getType()); + Assertions.assertNotNull(object.getIndirectReference()); - Assert.assertFalse("No need in rebuildXref()", reader.hasRebuiltXref()); + Assertions.assertFalse(reader.hasRebuiltXref(), "No need in rebuildXref()"); document.close(); } @@ -302,27 +303,27 @@ public void indirectsChain1() throws IOException { document = new PdfDocument(reader); pdfObject = document.getXref().get(1).getRefersTo(); - Assert.assertEquals(PdfObject.DICTIONARY, pdfObject.getType()); - Assert.assertTrue(objectTypeEqualTo(pdfObject, PdfName.Catalog)); + Assertions.assertEquals(PdfObject.DICTIONARY, pdfObject.getType()); + Assertions.assertTrue(objectTypeEqualTo(pdfObject, PdfName.Catalog)); pdfObject = document.getXref().get(2).getRefersTo(); - Assert.assertEquals(PdfObject.DICTIONARY, pdfObject.getType()); - Assert.assertTrue(objectTypeEqualTo(pdfObject, PdfName.Pages)); + Assertions.assertEquals(PdfObject.DICTIONARY, pdfObject.getType()); + Assertions.assertTrue(objectTypeEqualTo(pdfObject, PdfName.Pages)); pdfObject = document.getXref().get(3).getRefersTo(); - Assert.assertEquals(PdfObject.DICTIONARY, pdfObject.getType()); + Assertions.assertEquals(PdfObject.DICTIONARY, pdfObject.getType()); pdfObject = document.getXref().get(4).getRefersTo(); - Assert.assertEquals(PdfObject.DICTIONARY, pdfObject.getType()); - Assert.assertTrue(objectTypeEqualTo(pdfObject, PdfName.Page)); + Assertions.assertEquals(PdfObject.DICTIONARY, pdfObject.getType()); + Assertions.assertTrue(objectTypeEqualTo(pdfObject, PdfName.Page)); - Assert.assertEquals(PdfObject.STREAM, document.getXref().get(5).getRefersTo().getType()); + Assertions.assertEquals(PdfObject.STREAM, document.getXref().get(5).getRefersTo().getType()); for (int i = 6; i < document.getXref().size(); i++) { - Assert.assertEquals(PdfObject.DICTIONARY, document.getXref().get(i).getRefersTo().getType()); + Assertions.assertEquals(PdfObject.DICTIONARY, document.getXref().get(i).getRefersTo().getType()); } - Assert.assertFalse("No need in rebuildXref()", reader.hasRebuiltXref()); + Assertions.assertFalse(reader.hasRebuiltXref(), "No need in rebuildXref()"); document.close(); } @@ -334,9 +335,9 @@ public void exponentialXObjectLoopTest() throws IOException { memoryLimitsAwareHandler.setMaxXObjectsSizePerPage(1024L*1024L*256L); PdfReader pdfReader = new PdfReader(fileName, new ReaderProperties().setMemoryLimitsAwareHandler(memoryLimitsAwareHandler)); PdfDocument document = new PdfDocument(pdfReader); - Exception exception = Assert.assertThrows(MemoryLimitsAwareException.class, + Exception exception = Assertions.assertThrows(MemoryLimitsAwareException.class, () -> PdfTextExtractor.getTextFromPage(document.getPage(1))); - Assert.assertEquals(KernelExceptionMessageConstant.TOTAL_XOBJECT_SIZE_ONE_PAGE_EXCEEDED_THE_LIMIT, + Assertions.assertEquals(KernelExceptionMessageConstant.TOTAL_XOBJECT_SIZE_ONE_PAGE_EXCEEDED_THE_LIMIT, exception.getMessage()); } @@ -357,31 +358,31 @@ public void indirectsChain2() throws IOException { document = new PdfDocument(reader); pdfObject = document.getXref().get(1).getRefersTo(); - Assert.assertEquals(PdfObject.DICTIONARY, pdfObject.getType()); - Assert.assertTrue(objectTypeEqualTo(pdfObject, PdfName.Catalog)); + Assertions.assertEquals(PdfObject.DICTIONARY, pdfObject.getType()); + Assertions.assertTrue(objectTypeEqualTo(pdfObject, PdfName.Catalog)); pdfObject = document.getXref().get(2).getRefersTo(); - Assert.assertEquals(PdfObject.DICTIONARY, pdfObject.getType()); - Assert.assertTrue(objectTypeEqualTo(pdfObject, PdfName.Pages)); + Assertions.assertEquals(PdfObject.DICTIONARY, pdfObject.getType()); + Assertions.assertTrue(objectTypeEqualTo(pdfObject, PdfName.Pages)); pdfObject = document.getXref().get(3).getRefersTo(); - Assert.assertEquals(PdfObject.DICTIONARY, pdfObject.getType()); + Assertions.assertEquals(PdfObject.DICTIONARY, pdfObject.getType()); pdfObject = document.getXref().get(4).getRefersTo(); - Assert.assertEquals(PdfObject.DICTIONARY, pdfObject.getType()); - Assert.assertTrue(objectTypeEqualTo(pdfObject, PdfName.Page)); + Assertions.assertEquals(PdfObject.DICTIONARY, pdfObject.getType()); + Assertions.assertTrue(objectTypeEqualTo(pdfObject, PdfName.Page)); - Assert.assertEquals(PdfObject.STREAM, document.getXref().get(5).getRefersTo().getType()); + Assertions.assertEquals(PdfObject.STREAM, document.getXref().get(5).getRefersTo().getType()); for (int i = 6; i < 6 + 32; i++) { - Assert.assertEquals(PdfObject.DICTIONARY, document.getXref().get(6).getRefersTo().getType()); + Assertions.assertEquals(PdfObject.DICTIONARY, document.getXref().get(6).getRefersTo().getType()); } for (int i = 6 + 32; i < document.getXref().size(); i++) { - Assert.assertEquals(PdfObject.INDIRECT_REFERENCE, document.getXref().get(i).getRefersTo().getType()); + Assertions.assertEquals(PdfObject.INDIRECT_REFERENCE, document.getXref().get(i).getRefersTo().getType()); } - Assert.assertFalse("No need in rebuildXref()", reader.hasRebuiltXref()); + Assertions.assertFalse(reader.hasRebuiltXref(), "No need in rebuildXref()"); document.close(); } @@ -393,28 +394,28 @@ public void indirectsChain3() throws IOException { PdfDocument document = new PdfDocument(reader); PdfObject object = document.getXref().get(1).getRefersTo(); - Assert.assertEquals(PdfObject.DICTIONARY, object.getType()); - Assert.assertTrue(objectTypeEqualTo(object, PdfName.Catalog)); + Assertions.assertEquals(PdfObject.DICTIONARY, object.getType()); + Assertions.assertTrue(objectTypeEqualTo(object, PdfName.Catalog)); object = document.getXref().get(2).getRefersTo(); - Assert.assertEquals(PdfObject.DICTIONARY, object.getType()); - Assert.assertTrue(objectTypeEqualTo(object, PdfName.Pages)); + Assertions.assertEquals(PdfObject.DICTIONARY, object.getType()); + Assertions.assertTrue(objectTypeEqualTo(object, PdfName.Pages)); object = document.getXref().get(3).getRefersTo(); - Assert.assertTrue(object.getType() == PdfObject.DICTIONARY); + Assertions.assertTrue(object.getType() == PdfObject.DICTIONARY); object = document.getXref().get(4).getRefersTo(); - Assert.assertEquals(PdfObject.DICTIONARY, object.getType()); - Assert.assertTrue(objectTypeEqualTo(object, PdfName.Page)); + Assertions.assertEquals(PdfObject.DICTIONARY, object.getType()); + Assertions.assertTrue(objectTypeEqualTo(object, PdfName.Page)); - Assert.assertEquals(PdfObject.STREAM, document.getXref().get(5).getRefersTo().getType()); + Assertions.assertEquals(PdfObject.STREAM, document.getXref().get(5).getRefersTo().getType()); - Assert.assertEquals(PdfObject.DICTIONARY, document.getXref().get(6).getRefersTo().getType()); + Assertions.assertEquals(PdfObject.DICTIONARY, document.getXref().get(6).getRefersTo().getType()); for (int i = 7; i < document.getXref().size(); i++) { - Assert.assertEquals(PdfObject.INDIRECT_REFERENCE, document.getXref().get(i).getRefersTo().getType()); + Assertions.assertEquals(PdfObject.INDIRECT_REFERENCE, document.getXref().get(i).getRefersTo().getType()); } - Assert.assertFalse("No need in rebuildXref()", reader.hasRebuiltXref()); + Assertions.assertFalse(reader.hasRebuiltXref(), "No need in rebuildXref()"); document.close(); } @@ -427,27 +428,27 @@ public void invalidIndirect() throws IOException { PdfDocument document = new PdfDocument(reader); PdfObject object = document.getXref().get(1).getRefersTo(); - Assert.assertEquals(PdfObject.DICTIONARY, object.getType()); - Assert.assertTrue(objectTypeEqualTo(object, PdfName.Catalog)); + Assertions.assertEquals(PdfObject.DICTIONARY, object.getType()); + Assertions.assertTrue(objectTypeEqualTo(object, PdfName.Catalog)); object = document.getXref().get(2).getRefersTo(); - Assert.assertEquals(PdfObject.DICTIONARY, object.getType()); - Assert.assertTrue(objectTypeEqualTo(object, PdfName.Pages)); + Assertions.assertEquals(PdfObject.DICTIONARY, object.getType()); + Assertions.assertTrue(objectTypeEqualTo(object, PdfName.Pages)); object = document.getXref().get(3).getRefersTo(); - Assert.assertEquals(PdfObject.DICTIONARY, object.getType()); + Assertions.assertEquals(PdfObject.DICTIONARY, object.getType()); object = document.getXref().get(4).getRefersTo(); - Assert.assertEquals(PdfObject.DICTIONARY, object.getType()); - Assert.assertTrue(objectTypeEqualTo(object, PdfName.Page)); + Assertions.assertEquals(PdfObject.DICTIONARY, object.getType()); + Assertions.assertTrue(objectTypeEqualTo(object, PdfName.Page)); - Assert.assertEquals(PdfObject.STREAM, document.getXref().get(5).getRefersTo().getType()); - Assert.assertEquals(PdfObject.DICTIONARY, document.getXref().get(6).getRefersTo().getType()); + Assertions.assertEquals(PdfObject.STREAM, document.getXref().get(5).getRefersTo().getType()); + Assertions.assertEquals(PdfObject.DICTIONARY, document.getXref().get(6).getRefersTo().getType()); for (int i = 7; i < document.getXref().size(); i++) { - Assert.assertNull(document.getXref().get(i).getRefersTo()); + Assertions.assertNull(document.getXref().get(i).getRefersTo()); } - Assert.assertFalse("No need in rebuildXref()", reader.hasRebuiltXref()); + Assertions.assertFalse(reader.hasRebuiltXref(), "No need in rebuildXref()"); document.close(); } @@ -459,24 +460,24 @@ public void pagesTest01() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); PdfDocument document = new PdfDocument(reader, writer); int pageCount = document.getNumberOfPages(); - Assert.assertEquals(1000, pageCount); + Assertions.assertEquals(1000, pageCount); PdfPage testPage = document.getPage(1000); int testXref = testPage.getPdfObject().getIndirectReference().getObjNumber(); document.movePage(1000, 1000); - Assert.assertEquals(testXref, testPage.getPdfObject().getIndirectReference().getObjNumber()); + Assertions.assertEquals(testXref, testPage.getPdfObject().getIndirectReference().getObjNumber()); for (int i = 1; i < document.getNumberOfPages() + 1; i++) { PdfPage page = document.getPage(i); String content = new String(page.getContentStream(0).getBytes()); - Assert.assertTrue(content.contains("(" + i + ")")); + Assertions.assertTrue(content.contains("(" + i + ")")); } for (int i = 1; i < pageCount + 1; i++) { PdfPage page = document.getPage(1); document.removePage(page); String content = new String(page.getContentStream(0).getBytes()); - Assert.assertTrue(content.contains("(" + i + ")")); + Assertions.assertTrue(content.contains("(" + i + ")")); } reader.close(); @@ -487,10 +488,10 @@ public void pagesTest01() throws IOException { PdfPage page = document.getPage(pageNum); document.removePage(pageNum); String content = new String(page.getContentStream(0).getBytes()); - Assert.assertTrue(content.contains("(" + pageNum + ")")); + Assertions.assertTrue(content.contains("(" + pageNum + ")")); } - Assert.assertFalse("No need in rebuildXref()", reader.hasRebuiltXref()); + Assertions.assertFalse(reader.hasRebuiltXref(), "No need in rebuildXref()"); document.close(); } @@ -501,22 +502,22 @@ public void pagesTest02() throws IOException { PdfReader reader = new PdfReader(filename); PdfDocument document = new PdfDocument(reader); int pageCount = document.getNumberOfPages(); - Assert.assertEquals(1000, pageCount); + Assertions.assertEquals(1000, pageCount); for (int i = 1; i < document.getNumberOfPages() + 1; i++) { PdfPage page = document.getPage(i); String content = new String(page.getContentStream(0).getBytes()); - Assert.assertTrue(content.contains("(" + i + ")")); + Assertions.assertTrue(content.contains("(" + i + ")")); } for (int i = 1; i < pageCount + 1; i++) { PdfPage page = document.getPage(1); document.removePage(page); String content = new String(page.getContentStream(0).getBytes()); - Assert.assertTrue(content.contains("(" + i + ")")); + Assertions.assertTrue(content.contains("(" + i + ")")); } - Assert.assertFalse("No need in rebuildXref()", reader.hasRebuiltXref()); + Assertions.assertFalse(reader.hasRebuiltXref(), "No need in rebuildXref()"); document.close(); reader = new PdfReader(filename); @@ -526,7 +527,7 @@ public void pagesTest02() throws IOException { PdfPage page = document.getPage(pageNum); document.removePage(pageNum); String content = new String(page.getContentStream(0).getBytes()); - Assert.assertTrue(content.contains("(" + pageNum + ")")); + Assertions.assertTrue(content.contains("(" + pageNum + ")")); } document.close(); } @@ -538,22 +539,22 @@ public void pagesTest03() throws IOException { PdfReader reader = new PdfReader(filename); PdfDocument document = new PdfDocument(reader); int pageCount = document.getNumberOfPages(); - Assert.assertEquals(10, pageCount); + Assertions.assertEquals(10, pageCount); for (int i = 1; i < document.getNumberOfPages() + 1; i++) { PdfPage page = document.getPage(i); String content = new String(page.getContentStream(0).getBytes()); - Assert.assertTrue(content.contains("(" + i + ")")); + Assertions.assertTrue(content.contains("(" + i + ")")); } for (int i = 1; i < pageCount + 1; i++) { PdfPage page = document.getPage(1); document.removePage(page); String content = new String(page.getContentStream(0).getBytes()); - Assert.assertTrue(content.contains("(" + i + ")")); + Assertions.assertTrue(content.contains("(" + i + ")")); } - Assert.assertFalse("No need in rebuildXref()", reader.hasRebuiltXref()); + Assertions.assertFalse(reader.hasRebuiltXref(), "No need in rebuildXref()"); document.close(); reader = new PdfReader(filename); @@ -563,9 +564,9 @@ public void pagesTest03() throws IOException { PdfPage page = document.getPage(pageNum); document.removePage(pageNum); String content = new String(page.getContentStream(0).getBytes()); - Assert.assertTrue(content.contains("(" + pageNum + ")")); + Assertions.assertTrue(content.contains("(" + pageNum + ")")); } - Assert.assertFalse("No need in rebuildXref()", reader.hasRebuiltXref()); + Assertions.assertFalse(reader.hasRebuiltXref(), "No need in rebuildXref()"); document.close(); } @@ -576,22 +577,22 @@ public void pagesTest04() throws IOException { PdfReader reader = new PdfReader(filename); PdfDocument document = new PdfDocument(reader); int pageCount = document.getNumberOfPages(); - Assert.assertEquals(3, pageCount); + Assertions.assertEquals(3, pageCount); for (int i = 1; i < document.getNumberOfPages() + 1; i++) { PdfPage page = document.getPage(i); String content = new String(page.getContentStream(0).getBytes()); - Assert.assertTrue(content.startsWith(i + "00")); + Assertions.assertTrue(content.startsWith(i + "00")); } for (int i = 1; i < pageCount + 1; i++) { PdfPage page = document.getPage(1); document.removePage(page); String content = new String(page.getContentStream(0).getBytes()); - Assert.assertTrue(content.startsWith(i + "00")); + Assertions.assertTrue(content.startsWith(i + "00")); } - Assert.assertFalse("No need in rebuildXref()", reader.hasRebuiltXref()); + Assertions.assertFalse(reader.hasRebuiltXref(), "No need in rebuildXref()"); document.close(); reader = new PdfReader(filename); @@ -601,9 +602,9 @@ public void pagesTest04() throws IOException { PdfPage page = document.getPage(pageNum); document.removePage(pageNum); String content = new String(page.getContentStream(0).getBytes()); - Assert.assertTrue(content.startsWith(pageNum + "00")); + Assertions.assertTrue(content.startsWith(pageNum + "00")); } - Assert.assertFalse("No need in rebuildXref()", reader.hasRebuiltXref()); + Assertions.assertFalse(reader.hasRebuiltXref(), "No need in rebuildXref()"); document.close(); } @@ -614,22 +615,22 @@ public void pagesTest05() throws IOException { PdfReader reader = new PdfReader(filename); PdfDocument document = new PdfDocument(reader); int pageCount = document.getNumberOfPages(); - Assert.assertEquals(3, pageCount); + Assertions.assertEquals(3, pageCount); for (int i = 1; i < document.getNumberOfPages() + 1; i++) { PdfPage page = document.getPage(i); String content = new String(page.getContentStream(0).getBytes()); - Assert.assertTrue(content.startsWith(i + "00")); + Assertions.assertTrue(content.startsWith(i + "00")); } for (int i = 1; i < pageCount + 1; i++) { PdfPage page = document.getPage(1); document.removePage(page); String content = new String(page.getContentStream(0).getBytes()); - Assert.assertTrue(content.startsWith(i + "00")); + Assertions.assertTrue(content.startsWith(i + "00")); } - Assert.assertFalse("No need in rebuildXref()", reader.hasRebuiltXref()); + Assertions.assertFalse(reader.hasRebuiltXref(), "No need in rebuildXref()"); document.close(); reader = new PdfReader(filename); @@ -639,10 +640,10 @@ public void pagesTest05() throws IOException { PdfPage page = document.getPage(pageNum); document.removePage(pageNum); String content = new String(page.getContentStream(0).getBytes()); - Assert.assertTrue(content.startsWith(pageNum + "00")); + Assertions.assertTrue(content.startsWith(pageNum + "00")); } - Assert.assertFalse("No need in rebuildXref()", reader.hasRebuiltXref()); + Assertions.assertFalse(reader.hasRebuiltXref(), "No need in rebuildXref()"); document.close(); } @@ -653,15 +654,15 @@ public void pagesTest06() throws IOException { PdfReader reader = new PdfReader(filename); PdfDocument document = new PdfDocument(reader); int pageCount = document.getNumberOfPages(); - Assert.assertEquals(2, pageCount); + Assertions.assertEquals(2, pageCount); PdfPage page = document.getPage(1); String content = new String(page.getContentStream(0).getBytes()); - Assert.assertTrue(content.startsWith("100")); + Assertions.assertTrue(content.startsWith("100")); page = document.getPage(2); content = new String(page.getContentStream(0).getBytes()); - Assert.assertTrue(content.startsWith("300")); - Assert.assertFalse("No need in rebuildXref()", reader.hasRebuiltXref()); + Assertions.assertTrue(content.startsWith("300")); + Assertions.assertFalse(reader.hasRebuiltXref(), "No need in rebuildXref()"); document.close(); reader = new PdfReader(filename); @@ -670,13 +671,13 @@ public void pagesTest06() throws IOException { page = document.getPage(2); document.removePage(page); content = new String(page.getContentStream(0).getBytes()); - Assert.assertTrue(content.startsWith("300")); + Assertions.assertTrue(content.startsWith("300")); page = document.getPage(1); document.removePage(1); content = new String(page.getContentStream(0).getBytes()); - Assert.assertTrue(content.startsWith("100")); + Assertions.assertTrue(content.startsWith("100")); - Assert.assertFalse("No need in rebuildXref()", reader.hasRebuiltXref()); + Assertions.assertFalse(reader.hasRebuiltXref(), "No need in rebuildXref()"); document.close(); } @@ -687,15 +688,15 @@ public void pagesTest07() throws IOException { PdfReader reader = new PdfReader(filename); PdfDocument document = new PdfDocument(reader); int pageCount = document.getNumberOfPages(); - Assert.assertEquals(2, pageCount); + Assertions.assertEquals(2, pageCount); boolean exception = false; try { document.getPage(1); } catch (PdfException e) { exception = true; } - Assert.assertTrue(exception); - Assert.assertFalse("No need in rebuildXref()", reader.hasRebuiltXref()); + Assertions.assertTrue(exception); + Assertions.assertFalse(reader.hasRebuiltXref(), "No need in rebuildXref()"); document.close(); } @@ -706,15 +707,15 @@ public void pagesTest08() throws IOException { PdfReader reader = new PdfReader(filename); PdfDocument document = new PdfDocument(reader); int pageCount = document.getNumberOfPages(); - Assert.assertEquals(1, pageCount); + Assertions.assertEquals(1, pageCount); boolean exception = false; try { document.getPage(1); } catch (PdfException e) { exception = true; } - Assert.assertTrue(exception); - Assert.assertFalse("No need in rebuildXref()", reader.hasRebuiltXref()); + Assertions.assertTrue(exception); + Assertions.assertFalse(reader.hasRebuiltXref(), "No need in rebuildXref()"); document.close(); } @@ -725,16 +726,16 @@ public void pagesTest09() throws IOException { PdfReader reader = new PdfReader(filename); PdfDocument document = new PdfDocument(reader); int pageCount = document.getNumberOfPages(); - Assert.assertEquals(1, pageCount); + Assertions.assertEquals(1, pageCount); PdfPage page = document.getPage(1); String content = new String(page.getContentStream(0).getBytes()); - Assert.assertTrue(content.startsWith("100")); + Assertions.assertTrue(content.startsWith("100")); page = document.getPage(1); document.removePage(1); content = new String(page.getContentStream(0).getBytes()); - Assert.assertTrue(content.startsWith("100")); - Assert.assertFalse("No need in rebuildXref()", reader.hasRebuiltXref()); + Assertions.assertTrue(content.startsWith("100")); + Assertions.assertFalse(reader.hasRebuiltXref(), "No need in rebuildXref()"); document.close(); } @@ -745,14 +746,14 @@ public void pagesTest10() throws IOException { PdfReader reader = new PdfReader(filename); PdfDocument document = new PdfDocument(reader); int pageCount = document.getNumberOfPages(); - Assert.assertEquals(1000, pageCount); + Assertions.assertEquals(1000, pageCount); Random rnd = new Random(); for (int i = 1; i < document.getNumberOfPages() + 1; i++) { int pageNum = rnd.nextInt(document.getNumberOfPages()) + 1; PdfPage page = document.getPage(pageNum); String content = new String(page.getContentStream(0).getBytes()); - Assert.assertTrue(content.contains("(" + pageNum + ")")); + Assertions.assertTrue(content.contains("(" + pageNum + ")")); } List pageNums = new ArrayList<>(1000); @@ -766,9 +767,9 @@ public void pagesTest10() throws IOException { PdfPage page = document.getPage(index); document.removePage(index); String content = new String(page.getContentStream(0).getBytes()); - Assert.assertTrue(content.contains("(" + pageNum + ")")); + Assertions.assertTrue(content.contains("(" + pageNum + ")")); } - Assert.assertFalse("No need in rebuildXref()", reader.hasRebuiltXref()); + Assertions.assertFalse(reader.hasRebuiltXref(), "No need in rebuildXref()"); document.close(); } @@ -781,14 +782,14 @@ public void pagesTest11() throws IOException { try { document.getPage(-30); } catch (IndexOutOfBoundsException e) { - Assert.assertEquals( + Assertions.assertEquals( MessageFormatUtil.format(KernelExceptionMessageConstant.REQUESTED_PAGE_NUMBER_IS_OUT_OF_BOUNDS, -30), e.getMessage()); } try { document.getPage(0); } catch (IndexOutOfBoundsException e) { - Assert.assertEquals( + Assertions.assertEquals( MessageFormatUtil.format(KernelExceptionMessageConstant.REQUESTED_PAGE_NUMBER_IS_OUT_OF_BOUNDS, 0), e.getMessage()); } @@ -796,7 +797,7 @@ public void pagesTest11() throws IOException { try { document.getPage(25); } catch (IndexOutOfBoundsException e) { - Assert.assertEquals( + Assertions.assertEquals( MessageFormatUtil.format(KernelExceptionMessageConstant.REQUESTED_PAGE_NUMBER_IS_OUT_OF_BOUNDS, 25), e.getMessage()); } @@ -804,20 +805,20 @@ public void pagesTest11() throws IOException { } @Test - @LogMessages(messages = @LogMessage(messageTemplate = - IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT, count = 1)) + @LogMessages(messages = @LogMessage( + messageTemplate = IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT_WITH_CAUSE, count = 1)) public void correctSimpleDoc1() throws IOException { String filename = SOURCE_FOLDER + "correctSimpleDoc1.pdf"; PdfReader reader = new PdfReader(filename); PdfDocument document = new PdfDocument(reader); - Assert.assertTrue("Need rebuildXref()", reader.hasRebuiltXref()); + Assertions.assertTrue(reader.hasRebuiltXref(), "Need rebuildXref()"); int pageCount = document.getNumberOfPages(); - Assert.assertEquals(1, pageCount); + Assertions.assertEquals(1, pageCount); PdfPage page = document.getPage(1); - Assert.assertNotNull(page.getContentStream(0).getBytes()); + Assertions.assertNotNull(page.getContentStream(0).getBytes()); document.close(); } @@ -828,39 +829,39 @@ public void correctSimpleDoc2() throws IOException { PdfReader reader = new PdfReader(filename); PdfDocument document = new PdfDocument(reader); - Assert.assertTrue("Need fixXref()", reader.hasFixedXref()); + Assertions.assertTrue(reader.hasFixedXref(), "Need fixXref()"); int pageCount = document.getNumberOfPages(); - Assert.assertEquals(1, pageCount); + Assertions.assertEquals(1, pageCount); PdfPage page = document.getPage(1); - Assert.assertNotNull(page.getContentStream(0).getBytes()); + Assertions.assertNotNull(page.getContentStream(0).getBytes()); document.close(); } @Test @LogMessages(messages = @LogMessage(messageTemplate = - IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT, count = 1)) + IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT_WITH_CAUSE, count = 1)) public void correctSimpleDoc3() throws IOException { String filename = SOURCE_FOLDER + "correctSimpleDoc3.pdf"; PdfReader reader = new PdfReader(filename); PdfDocument document = new PdfDocument(reader); - Assert.assertTrue("Need rebuildXref()", reader.hasRebuiltXref()); + Assertions.assertTrue(reader.hasRebuiltXref(), "Need rebuildXref()"); int pageCount = document.getNumberOfPages(); - Assert.assertEquals(1, pageCount); + Assertions.assertEquals(1, pageCount); PdfPage page = document.getPage(1); - Assert.assertNotNull(page.getContentStream(0).getBytes()); + Assertions.assertNotNull(page.getContentStream(0).getBytes()); document.close(); } @Test @LogMessages(messages = { - @LogMessage(messageTemplate = IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT), + @LogMessage(messageTemplate = IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT_WITH_CAUSE), @LogMessage(messageTemplate = IoLogMessageConstant.INVALID_INDIRECT_REFERENCE), }) public void correctSimpleDoc4() throws IOException { @@ -870,9 +871,9 @@ public void correctSimpleDoc4() throws IOException { try { //NOTE test with abnormal object declaration that iText can't resolve. PdfDocument document = new PdfDocument(reader); - Assert.fail("Expect exception"); + Assertions.fail("Expect exception"); } catch (PdfException e) { - Assert.assertEquals(KernelExceptionMessageConstant.INVALID_PAGE_STRUCTURE_PAGES_MUST_BE_PDF_DICTIONARY, + Assertions.assertEquals(KernelExceptionMessageConstant.INVALID_PAGE_STRUCTURE_PAGES_MUST_BE_PDF_DICTIONARY, e.getMessage()); } finally { reader.close(); @@ -881,21 +882,21 @@ public void correctSimpleDoc4() throws IOException { @Test @LogMessages(messages = @LogMessage(messageTemplate = - IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT)) + IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT_WITH_CAUSE)) public void fixPdfTest01() throws IOException { String filename = SOURCE_FOLDER + "OnlyTrailer.pdf"; PdfReader reader = new PdfReader(filename); PdfDocument document = new PdfDocument(reader); - Assert.assertTrue("Need rebuildXref()", reader.hasRebuiltXref()); + Assertions.assertTrue(reader.hasRebuiltXref(), "Need rebuildXref()"); int pageCount = document.getNumberOfPages(); - Assert.assertEquals(10, pageCount); + Assertions.assertEquals(10, pageCount); for (int i = 1; i < document.getNumberOfPages() + 1; i++) { PdfPage page = document.getPage(i); String content = new String(page.getContentStream(0).getBytes()); - Assert.assertTrue(content.contains("(" + i + ")")); + Assertions.assertTrue(content.contains("(" + i + ")")); } document.close(); @@ -907,16 +908,16 @@ public void fixPdfTest02() throws IOException { PdfReader reader = new PdfReader(filename); PdfDocument document = new PdfDocument(reader); - Assert.assertFalse("No need in fixXref()", reader.hasFixedXref()); - Assert.assertFalse("No need in rebuildXref()", reader.hasRebuiltXref()); + Assertions.assertFalse(reader.hasFixedXref(), "No need in fixXref()"); + Assertions.assertFalse(reader.hasRebuiltXref(), "No need in rebuildXref()"); int pageCount = document.getNumberOfPages(); - Assert.assertEquals(10, pageCount); + Assertions.assertEquals(10, pageCount); for (int i = 1; i < document.getNumberOfPages() + 1; i++) { PdfPage page = document.getPage(i); String content = new String(page.getContentStream(0).getBytes()); - Assert.assertTrue(content.contains("(" + i + ")")); + Assertions.assertTrue(content.contains("(" + i + ")")); } document.close(); @@ -928,16 +929,16 @@ public void fixPdfTest03() throws IOException { PdfReader reader = new PdfReader(filename); PdfDocument document = new PdfDocument(reader); - Assert.assertFalse("No need in fixXref()", reader.hasFixedXref()); - Assert.assertFalse("No need in rebuildXref()", reader.hasRebuiltXref()); + Assertions.assertFalse(reader.hasFixedXref(), "No need in fixXref()"); + Assertions.assertFalse(reader.hasRebuiltXref(), "No need in rebuildXref()"); int pageCount = document.getNumberOfPages(); - Assert.assertEquals(10, pageCount); + Assertions.assertEquals(10, pageCount); for (int i = 1; i < document.getNumberOfPages() + 1; i++) { PdfPage page = document.getPage(i); String content = new String(page.getContentStream(0).getBytes()); - Assert.assertTrue(content.contains("(" + i + ")")); + Assertions.assertTrue(content.contains("(" + i + ")")); } document.close(); @@ -955,13 +956,13 @@ public void fixPdfTest04() throws IOException { exception = true; } - Assert.assertTrue(exception); + Assertions.assertTrue(exception); reader.close(); } @Test @LogMessages(messages = @LogMessage(messageTemplate = - IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT)) + IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT_WITH_CAUSE)) public void fixPdfTest05() throws IOException { String filename = SOURCE_FOLDER + "CompressionWrongShift.pdf"; @@ -973,7 +974,7 @@ public void fixPdfTest05() throws IOException { exception = true; } - Assert.assertTrue(exception); + Assertions.assertTrue(exception); reader.close(); } @@ -983,15 +984,15 @@ public void fixPdfTest06() throws IOException { PdfReader reader = new PdfReader(filename); PdfDocument document = new PdfDocument(reader); - Assert.assertTrue("Need fixXref()", reader.hasFixedXref()); + Assertions.assertTrue(reader.hasFixedXref(), "Need fixXref()"); int pageCount = document.getNumberOfPages(); - Assert.assertEquals(10, pageCount); + Assertions.assertEquals(10, pageCount); for (int i = 1; i < document.getNumberOfPages() + 1; i++) { PdfPage page = document.getPage(i); String content = new String(page.getContentStream(0).getBytes()); - Assert.assertTrue(content.contains("(" + i + ")")); + Assertions.assertTrue(content.contains("(" + i + ")")); } document.close(); @@ -1010,31 +1011,31 @@ public void fixPdfTest07() throws IOException { exception = true; } - Assert.assertTrue(exception); + Assertions.assertTrue(exception); reader.close(); } @Test @LogMessages(messages = @LogMessage(messageTemplate = - IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT)) + IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT_WITH_CAUSE)) public void fixPdfTest08() throws IOException { String filename = SOURCE_FOLDER + "XRefSectionWithFreeReferences2.pdf"; PdfReader reader = new PdfReader(filename); PdfDocument document = new PdfDocument(reader); - Assert.assertTrue("Need rebuildXref()", reader.hasRebuiltXref()); + Assertions.assertTrue(reader.hasRebuiltXref(), "Need rebuildXref()"); - Assert.assertEquals(author, document.getDocumentInfo().getAuthor()); - Assert.assertEquals(creator, document.getDocumentInfo().getCreator()); - Assert.assertEquals(title, document.getDocumentInfo().getTitle()); + Assertions.assertEquals(author, document.getDocumentInfo().getAuthor()); + Assertions.assertEquals(creator, document.getDocumentInfo().getCreator()); + Assertions.assertEquals(title, document.getDocumentInfo().getTitle()); int pageCount = document.getNumberOfPages(); - Assert.assertEquals(10, pageCount); + Assertions.assertEquals(10, pageCount); for (int i = 1; i < document.getNumberOfPages() + 1; i++) { PdfPage page = document.getPage(i); String content = new String(page.getContentStream(0).getBytes()); - Assert.assertTrue(content.contains("(" + i + ")")); + Assertions.assertTrue(content.contains("(" + i + ")")); } document.close(); @@ -1042,25 +1043,25 @@ public void fixPdfTest08() throws IOException { @Test @LogMessages(messages = @LogMessage(messageTemplate = - IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT)) + IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT_WITH_CAUSE)) public void fixPdfTest09() throws IOException { String filename = SOURCE_FOLDER + "XRefSectionWithFreeReferences3.pdf"; PdfReader reader = new PdfReader(filename); PdfDocument document = new PdfDocument(reader); - Assert.assertTrue("Need rebuildXref()", reader.hasRebuiltXref()); + Assertions.assertTrue(reader.hasRebuiltXref(), "Need rebuildXref()"); - Assert.assertEquals(author, document.getDocumentInfo().getAuthor()); - Assert.assertEquals(creator, document.getDocumentInfo().getCreator()); - Assert.assertEquals(title, document.getDocumentInfo().getTitle()); + Assertions.assertEquals(author, document.getDocumentInfo().getAuthor()); + Assertions.assertEquals(creator, document.getDocumentInfo().getCreator()); + Assertions.assertEquals(title, document.getDocumentInfo().getTitle()); int pageCount = document.getNumberOfPages(); - Assert.assertEquals(10, pageCount); + Assertions.assertEquals(10, pageCount); for (int i = 1; i < document.getNumberOfPages() + 1; i++) { PdfPage page = document.getPage(i); String content = new String(page.getContentStream(0).getBytes()); - Assert.assertTrue(content.contains("(" + i + ")")); + Assertions.assertTrue(content.contains("(" + i + ")")); } document.close(); @@ -1074,20 +1075,20 @@ public void fixPdfTest10() throws IOException { PdfReader reader = new PdfReader(filename); PdfDocument document = new PdfDocument(reader); - Assert.assertFalse("No need in fixXref()", reader.hasFixedXref()); - Assert.assertFalse("No need in rebuildXref()", reader.hasRebuiltXref()); + Assertions.assertFalse(reader.hasFixedXref(), "No need in fixXref()"); + Assertions.assertFalse(reader.hasRebuiltXref(), "No need in rebuildXref()"); - Assert.assertEquals(null, document.getDocumentInfo().getAuthor()); - Assert.assertEquals(null, document.getDocumentInfo().getCreator()); - Assert.assertEquals(null, document.getDocumentInfo().getTitle()); + Assertions.assertEquals(null, document.getDocumentInfo().getAuthor()); + Assertions.assertEquals(null, document.getDocumentInfo().getCreator()); + Assertions.assertEquals(null, document.getDocumentInfo().getTitle()); int pageCount = document.getNumberOfPages(); - Assert.assertEquals(10, pageCount); + Assertions.assertEquals(10, pageCount); for (int i = 1; i < document.getNumberOfPages() + 1; i++) { PdfPage page = document.getPage(i); String content = new String(page.getContentStream(0).getBytes()); - Assert.assertTrue(content.contains("(" + i + ")")); + Assertions.assertTrue(content.contains("(" + i + ")")); } document.close(); @@ -1095,21 +1096,21 @@ public void fixPdfTest10() throws IOException { @Test @LogMessages(messages = @LogMessage(messageTemplate = - IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT)) + IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT_WITH_CAUSE)) public void fixPdfTest11() throws IOException { String filename = SOURCE_FOLDER + "XRefSectionWithoutSize.pdf"; PdfReader reader = new PdfReader(filename); PdfDocument document = new PdfDocument(reader); - Assert.assertTrue("Need rebuildXref()", reader.hasRebuiltXref()); + Assertions.assertTrue(reader.hasRebuiltXref(), "Need rebuildXref()"); int pageCount = document.getNumberOfPages(); - Assert.assertEquals(10, pageCount); + Assertions.assertEquals(10, pageCount); for (int i = 1; i < document.getNumberOfPages() + 1; i++) { PdfPage page = document.getPage(i); String content = new String(page.getContentStream(0).getBytes()); - Assert.assertTrue(content.contains("(" + i + ")")); + Assertions.assertTrue(content.contains("(" + i + ")")); } document.close(); @@ -1117,21 +1118,21 @@ public void fixPdfTest11() throws IOException { @Test @LogMessages(messages = @LogMessage(messageTemplate = - IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT)) + IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT_WITH_CAUSE)) public void fixPdfTest12() throws IOException { String filename = SOURCE_FOLDER + "XRefWithBreaks.pdf"; PdfReader reader = new PdfReader(filename); PdfDocument document = new PdfDocument(reader); - Assert.assertTrue("Need rebuildXref()", reader.hasRebuiltXref()); + Assertions.assertTrue(reader.hasRebuiltXref(), "Need rebuildXref()"); int pageCount = document.getNumberOfPages(); - Assert.assertEquals(10, pageCount); + Assertions.assertEquals(10, pageCount); for (int i = 1; i < document.getNumberOfPages() + 1; i++) { PdfPage page = document.getPage(i); String content = new String(page.getContentStream(0).getBytes()); - Assert.assertTrue(content.contains("(" + i + ")")); + Assertions.assertTrue(content.contains("(" + i + ")")); } document.close(); @@ -1146,16 +1147,16 @@ public void fixPdfTest13() throws IOException { PdfReader reader = new PdfReader(filename); PdfDocument document = new PdfDocument(reader); - Assert.assertFalse("No need in fixXref()", reader.hasFixedXref()); - Assert.assertFalse("No need in rebuildXref()", reader.hasRebuiltXref()); + Assertions.assertFalse(reader.hasFixedXref(), "No need in fixXref()"); + Assertions.assertFalse(reader.hasRebuiltXref(), "No need in rebuildXref()"); int pageCount = document.getNumberOfPages(); - Assert.assertEquals(1000, pageCount); + Assertions.assertEquals(1000, pageCount); for (int i = 1; i < 10; i++) { PdfPage page = document.getPage(i); String content = new String(page.getContentStream(0).getBytes()); - Assert.assertTrue(content.contains("(" + i + ")")); + Assertions.assertTrue(content.contains("(" + i + ")")); } @@ -1164,7 +1165,7 @@ public void fixPdfTest13() throws IOException { int i; PdfObject fontF1 = document.getPage(997).getPdfObject().getAsDictionary(PdfName.Resources) .getAsDictionary(PdfName.Font).get(new PdfName("F1")); - Assert.assertTrue(fontF1 instanceof PdfNull); + Assertions.assertTrue(fontF1 instanceof PdfNull); //There is a generation number mismatch in xref table and object for 3093 try { @@ -1172,7 +1173,7 @@ public void fixPdfTest13() throws IOException { } catch (com.itextpdf.io.exceptions.IOException ex) { exception = true; } - Assert.assertTrue(exception); + Assertions.assertTrue(exception); exception = false; try { @@ -1183,7 +1184,7 @@ public void fixPdfTest13() throws IOException { } catch (PdfException ex) { exception = true; } - Assert.assertFalse(exception); + Assertions.assertFalse(exception); document.close(); } @@ -1202,27 +1203,27 @@ public void fixPdfTest14() throws IOException { exception = true; } - Assert.assertTrue(exception); + Assertions.assertTrue(exception); reader.close(); } @Test @LogMessages(messages = @LogMessage(messageTemplate = - IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT)) + IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT_WITH_CAUSE)) public void fixPdfTest15() throws IOException { String filename = SOURCE_FOLDER + "XRefWithInvalidGenerations3.pdf"; PdfReader reader = new PdfReader(filename); PdfDocument document = new PdfDocument(reader); - Assert.assertTrue("Need rebuildXref()", reader.hasRebuiltXref()); + Assertions.assertTrue(reader.hasRebuiltXref(), "Need rebuildXref()"); int pageCount = document.getNumberOfPages(); - Assert.assertEquals(10, pageCount); + Assertions.assertEquals(10, pageCount); for (int i = 1; i < document.getNumberOfPages() + 1; i++) { PdfPage page = document.getPage(i); String content = new String(page.getContentStream(0).getBytes()); - Assert.assertTrue(content.contains("(" + i + ")")); + Assertions.assertTrue(content.contains("(" + i + ")")); } document.close(); @@ -1234,39 +1235,39 @@ public void fixPdfTest16() throws IOException { PdfReader reader = new PdfReader(filename); PdfDocument document = new PdfDocument(reader); - Assert.assertFalse("No need in fixXref()", reader.hasFixedXref()); + Assertions.assertFalse(reader.hasFixedXref(), "No need in fixXref()"); int pageCount = document.getNumberOfPages(); - Assert.assertEquals(10, pageCount); + Assertions.assertEquals(10, pageCount); for (int i = 1; i < document.getNumberOfPages() + 1; i++) { PdfPage page = document.getPage(i); String content = new String(page.getContentStream(0).getBytes()); - Assert.assertTrue(content.contains("(" + i + ")")); + Assertions.assertTrue(content.contains("(" + i + ")")); } - Assert.assertTrue("Need live fixXref()", reader.hasFixedXref()); + Assertions.assertTrue(reader.hasFixedXref(), "Need live fixXref()"); document.close(); } @Test @LogMessages(messages = @LogMessage(messageTemplate = - IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT)) + IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT_WITH_CAUSE)) public void fixPdfTest17() throws IOException { String filename = SOURCE_FOLDER + "XrefWithNullOffsets.pdf"; PdfReader reader = new PdfReader(filename); PdfDocument document = new PdfDocument(reader); - Assert.assertTrue("Need rebuildXref()", reader.hasRebuiltXref()); + Assertions.assertTrue(reader.hasRebuiltXref(), "Need rebuildXref()"); int pageCount = document.getNumberOfPages(); - Assert.assertEquals(10, pageCount); + Assertions.assertEquals(10, pageCount); for (int i = 1; i < document.getNumberOfPages() + 1; i++) { PdfPage page = document.getPage(i); String content = new String(page.getContentStream(0).getBytes()); - Assert.assertTrue(content.contains("(" + i + ")")); + Assertions.assertTrue(content.contains("(" + i + ")")); } document.close(); @@ -1274,18 +1275,18 @@ public void fixPdfTest17() throws IOException { @Test @LogMessages(messages = @LogMessage(messageTemplate = - IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT)) + IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT_WITH_CAUSE)) public void fixPdfTest18() throws IOException { String filename = SOURCE_FOLDER + "noXrefAndTrailerWithInfo.pdf"; PdfReader reader = new PdfReader(filename); PdfDocument document = new PdfDocument(reader); - Assert.assertTrue("Need rebuildXref()", reader.hasRebuiltXref()); + Assertions.assertTrue(reader.hasRebuiltXref(), "Need rebuildXref()"); int pageCount = document.getNumberOfPages(); - Assert.assertEquals(1, pageCount); + Assertions.assertEquals(1, pageCount); - Assert.assertTrue(document.getDocumentInfo().getProducer().contains("iText Group NV (AGPL-version)")); + Assertions.assertTrue(document.getDocumentInfo().getProducer().contains("iText Group NV (AGPL-version)")); document.close(); } @@ -1297,19 +1298,19 @@ public void appendModeWith1000Pages() throws IOException { PdfReader reader = new PdfReader(filename); PdfDocument document = new PdfDocument(reader); int pageCount = document.getNumberOfPages(); - Assert.assertEquals(1000, pageCount); + Assertions.assertEquals(1000, pageCount); for (int i = 1; i < document.getNumberOfPages() + 1; i++) { PdfPage page = document.getPage(i); String content = new String(page.getContentStream(0).getBytes()); - Assert.assertFalse(content.length() == 0); + Assertions.assertFalse(content.length() == 0); content = new String(page.getContentStream(1).getBytes()); - Assert.assertTrue(content.contains("(" + i + ")")); + Assertions.assertTrue(content.contains("(" + i + ")")); content = new String(page.getContentStream(2).getBytes()); - Assert.assertTrue(content.contains("Append mode")); + Assertions.assertTrue(content.contains("Append mode")); } - Assert.assertFalse("No need in rebuildXref()", reader.hasRebuiltXref()); + Assertions.assertFalse(reader.hasRebuiltXref(), "No need in rebuildXref()"); document.close(); } @@ -1321,19 +1322,19 @@ public void appendModeWith1000PagesWithCompression() throws IOException { PdfReader reader = new PdfReader(filename); PdfDocument document = new PdfDocument(reader); int pageCount = document.getNumberOfPages(); - Assert.assertEquals(1000, pageCount); + Assertions.assertEquals(1000, pageCount); for (int i = 1; i < document.getNumberOfPages() + 1; i++) { PdfPage page = document.getPage(i); String content = new String(page.getContentStream(0).getBytes()); - Assert.assertFalse(content.length() == 0); + Assertions.assertFalse(content.length() == 0); content = new String(page.getContentStream(1).getBytes()); - Assert.assertTrue(content.contains("(" + i + ")")); + Assertions.assertTrue(content.contains("(" + i + ")")); content = new String(page.getContentStream(2).getBytes()); - Assert.assertTrue(content.contains("Append mode")); + Assertions.assertTrue(content.contains("Append mode")); } - Assert.assertFalse("No need in rebuildXref()", reader.hasRebuiltXref()); + Assertions.assertFalse(reader.hasRebuiltXref(), "No need in rebuildXref()"); document.close(); } @@ -1345,19 +1346,19 @@ public void appendModeWith10Pages() throws IOException { PdfReader reader = new PdfReader(filename); PdfDocument document = new PdfDocument(reader); int pageCount = document.getNumberOfPages(); - Assert.assertEquals(10, pageCount); + Assertions.assertEquals(10, pageCount); for (int i = 1; i < document.getNumberOfPages() + 1; i++) { PdfPage page = document.getPage(i); String content = new String(page.getContentStream(0).getBytes()); - Assert.assertFalse(content.length() == 0); + Assertions.assertFalse(content.length() == 0); content = new String(page.getContentStream(1).getBytes()); - Assert.assertTrue(content.contains("(" + i + ")")); + Assertions.assertTrue(content.contains("(" + i + ")")); content = new String(page.getContentStream(2).getBytes()); - Assert.assertTrue(content.contains("Append mode")); + Assertions.assertTrue(content.contains("Append mode")); } - Assert.assertFalse("No need in rebuildXref()", reader.hasRebuiltXref()); + Assertions.assertFalse(reader.hasRebuiltXref(), "No need in rebuildXref()"); document.close(); } @@ -1369,53 +1370,53 @@ public void appendModeWith10PagesWithCompression() throws IOException { PdfReader reader = new PdfReader(filename); PdfDocument document = new PdfDocument(reader); int pageCount = document.getNumberOfPages(); - Assert.assertEquals(10, pageCount); + Assertions.assertEquals(10, pageCount); for (int i = 1; i < document.getNumberOfPages() + 1; i++) { PdfPage page = document.getPage(i); String content = new String(page.getContentStream(0).getBytes()); - Assert.assertFalse(content.length() == 0); + Assertions.assertFalse(content.length() == 0); content = new String(page.getContentStream(1).getBytes()); - Assert.assertTrue(content.contains("(" + i + ")")); + Assertions.assertTrue(content.contains("(" + i + ")")); content = new String(page.getContentStream(2).getBytes()); - Assert.assertTrue(content.contains("Append mode")); + Assertions.assertTrue(content.contains("Append mode")); } - Assert.assertFalse("No need in rebuildXref()", reader.hasRebuiltXref()); + Assertions.assertFalse(reader.hasRebuiltXref(), "No need in rebuildXref()"); document.close(); } @Test @LogMessages(messages = @LogMessage(messageTemplate = - IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT)) + IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT_WITH_CAUSE)) public void appendModeWith10PagesFix1() throws IOException { String filename = SOURCE_FOLDER + "10PagesDocumentAppendedFix1.pdf"; PdfReader reader = new PdfReader(filename); PdfDocument document = new PdfDocument(reader); int pageCount = document.getNumberOfPages(); - Assert.assertEquals(10, pageCount); + Assertions.assertEquals(10, pageCount); for (int i = 1; i < document.getNumberOfPages() + 1; i++) { PdfPage page = document.getPage(i); String content = new String(page.getContentStream(0).getBytes()); - Assert.assertFalse(content.length() == 0); + Assertions.assertFalse(content.length() == 0); content = new String(page.getContentStream(1).getBytes()); - Assert.assertTrue(content.contains("(" + i + ")")); + Assertions.assertTrue(content.contains("(" + i + ")")); content = new String(page.getContentStream(2).getBytes()); - Assert.assertTrue(content.contains("Append mode")); + Assertions.assertTrue(content.contains("Append mode")); } - Assert.assertTrue("Need rebuildXref()", reader.hasRebuiltXref()); - Assert.assertNotNull("Invalid trailer", document.getTrailer().get(PdfName.ID)); + Assertions.assertTrue(reader.hasRebuiltXref(), "Need rebuildXref()"); + Assertions.assertNotNull(document.getTrailer().get(PdfName.ID), "Invalid trailer"); document.close(); } @Test @LogMessages(messages = @LogMessage(messageTemplate = - IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT)) + IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT_WITH_CAUSE)) public void appendModeWith10PagesFix2() throws IOException { String filename = SOURCE_FOLDER + "10PagesDocumentAppendedFix2.pdf"; @@ -1423,20 +1424,20 @@ public void appendModeWith10PagesFix2() throws IOException { PdfDocument document = new PdfDocument(reader); int pageCount = document.getNumberOfPages(); - Assert.assertEquals(10, pageCount); + Assertions.assertEquals(10, pageCount); for (int i = 1; i < document.getNumberOfPages() + 1; i++) { PdfPage page = document.getPage(i); String content = new String(page.getContentStream(0).getBytes()); - Assert.assertFalse(content.length() == 0); + Assertions.assertFalse(content.length() == 0); content = new String(page.getContentStream(1).getBytes()); - Assert.assertTrue(content.contains("(" + i + ")")); + Assertions.assertTrue(content.contains("(" + i + ")")); content = new String(page.getContentStream(2).getBytes()); - Assert.assertTrue(content.contains("Append mode")); + Assertions.assertTrue(content.contains("Append mode")); } - Assert.assertTrue("Need rebuildXref()", reader.hasRebuiltXref()); - Assert.assertNotNull("Invalid trailer", document.getTrailer().get(PdfName.ID)); + Assertions.assertTrue(reader.hasRebuiltXref(), "Need rebuildXref()"); + Assertions.assertNotNull(document.getTrailer().get(PdfName.ID), "Invalid trailer"); document.close(); } @@ -1448,8 +1449,8 @@ public void incorrectXrefSizeInTrailer() throws IOException { PdfReader reader = new PdfReader(filename); PdfDocument document = new PdfDocument(reader); - Assert.assertFalse("Need rebuildXref()", reader.hasRebuiltXref()); - Assert.assertNotNull("Invalid trailer", document.getTrailer().get(PdfName.ID)); + Assertions.assertFalse(reader.hasRebuiltXref(), "Need rebuildXref()"); + Assertions.assertNotNull(document.getTrailer().get(PdfName.ID), "Invalid trailer"); document.close(); } @@ -1461,14 +1462,15 @@ public void incorrectXrefSizeInTrailerAppend() throws IOException { PdfReader reader = new PdfReader(filename); PdfDocument document = new PdfDocument(reader); - Assert.assertFalse("Need rebuildXref()", reader.hasRebuiltXref()); - Assert.assertNotNull("Invalid trailer", document.getTrailer().get(PdfName.ID)); + Assertions.assertFalse(reader.hasRebuiltXref(), "Need rebuildXref()"); + Assertions.assertNotNull(document.getTrailer().get(PdfName.ID), "Invalid trailer"); document.close(); } - @Test(timeout = 1000) + @Test + @Timeout(unit = TimeUnit.MILLISECONDS, value = 1000) public void streamLengthCorrection1() throws IOException { synchronized (this) { String filename = SOURCE_FOLDER + "10PagesDocumentWithInvalidStreamLength.pdf"; @@ -1480,13 +1482,14 @@ public void streamLengthCorrection1() throws IOException { PdfPage page = pdfDoc.getPage(k); page.getPdfObject().get(PdfName.MediaBox); byte[] content = page.getFirstContentStream().getBytes(); - Assert.assertEquals(57, content.length); + Assertions.assertEquals(57, content.length); } pdfDoc.close(); } } - @Test(timeout = 1000) + @Test + @Timeout(unit = TimeUnit.MILLISECONDS, value = 1000) public void streamLengthCorrection2() throws IOException { synchronized (this) { String filename = SOURCE_FOLDER + "simpleCanvasWithDrawingLength1.pdf"; @@ -1496,12 +1499,13 @@ public void streamLengthCorrection2() throws IOException { PdfPage page = pdfDoc.getPage(1); page.getPdfObject().get(PdfName.MediaBox); byte[] content = page.getFirstContentStream().getBytes(); - Assert.assertEquals(696, content.length); + Assertions.assertEquals(696, content.length); pdfDoc.close(); } } - @Test(timeout = 1000) + @Test + @Timeout(unit = TimeUnit.MILLISECONDS, value = 1000) public void streamLengthCorrection3() throws IOException { synchronized (this) { String filename = SOURCE_FOLDER + "simpleCanvasWithDrawingLength2.pdf"; @@ -1511,12 +1515,13 @@ public void streamLengthCorrection3() throws IOException { PdfPage page = pdfDoc.getPage(1); page.getPdfObject().get(PdfName.MediaBox); byte[] content = page.getFirstContentStream().getBytes(); - Assert.assertEquals(697, content.length); + Assertions.assertEquals(697, content.length); pdfDoc.close(); } } - @Test(timeout = 1000) + @Test + @Timeout(unit = TimeUnit.MILLISECONDS, value = 1000) public void streamLengthCorrection4() throws IOException { synchronized (this) { String filename = SOURCE_FOLDER + "simpleCanvasWithDrawingLength3.pdf"; @@ -1526,12 +1531,13 @@ public void streamLengthCorrection4() throws IOException { PdfPage page = pdfDoc.getPage(1); page.getPdfObject().get(PdfName.MediaBox); byte[] content = page.getFirstContentStream().getBytes(); - Assert.assertEquals(696, content.length); + Assertions.assertEquals(696, content.length); pdfDoc.close(); } } - @Test(timeout = 1000) + @Test + @Timeout(unit = TimeUnit.MILLISECONDS, value = 1000) public void streamLengthCorrection5() throws IOException { synchronized (this) { String filename = SOURCE_FOLDER + "simpleCanvasWithDrawingLength4.pdf"; @@ -1541,12 +1547,13 @@ public void streamLengthCorrection5() throws IOException { PdfPage page = pdfDoc.getPage(1); page.getPdfObject().get(PdfName.MediaBox); byte[] content = page.getFirstContentStream().getBytes(); - Assert.assertEquals(696, content.length); + Assertions.assertEquals(696, content.length); pdfDoc.close(); } } - @Test(timeout = 1000) + @Test + @Timeout(unit = TimeUnit.MILLISECONDS, value = 1000) public void streamLengthCorrection6() throws IOException { synchronized (this) { String filename = SOURCE_FOLDER + "simpleCanvasWithDrawingWithInvalidStreamLength1.pdf"; @@ -1556,12 +1563,13 @@ public void streamLengthCorrection6() throws IOException { PdfPage page = pdfDoc.getPage(1); page.getPdfObject().get(PdfName.MediaBox); byte[] content = page.getFirstContentStream().getBytes(); - Assert.assertEquals(696, content.length); + Assertions.assertEquals(696, content.length); pdfDoc.close(); } } - @Test(timeout = 1000) + @Test + @Timeout(unit = TimeUnit.MILLISECONDS, value = 1000) public void streamLengthCorrection7() throws IOException { synchronized (this) { String filename = SOURCE_FOLDER + "simpleCanvasWithDrawingWithInvalidStreamLength2.pdf"; @@ -1571,12 +1579,13 @@ public void streamLengthCorrection7() throws IOException { PdfPage page = pdfDoc.getPage(1); page.getPdfObject().get(PdfName.MediaBox); byte[] content = page.getFirstContentStream().getBytes(); - Assert.assertEquals(696, content.length); + Assertions.assertEquals(696, content.length); pdfDoc.close(); } } - @Test(timeout = 1000) + @Test + @Timeout(unit = TimeUnit.MILLISECONDS, value = 1000) public void streamLengthCorrection8() throws IOException { synchronized (this) { String filename = SOURCE_FOLDER + "simpleCanvasWithDrawingWithInvalidStreamLength3.pdf"; @@ -1586,12 +1595,13 @@ public void streamLengthCorrection8() throws IOException { PdfPage page = pdfDoc.getPage(1); page.getPdfObject().get(PdfName.MediaBox); byte[] content = page.getFirstContentStream().getBytes(); - Assert.assertEquals(697, content.length); + Assertions.assertEquals(697, content.length); pdfDoc.close(); } } - @Test(timeout = 1000) + @Test + @Timeout(unit = TimeUnit.MILLISECONDS, value = 1000) public void streamLengthCorrection9() throws IOException { synchronized (this) { String filename = SOURCE_FOLDER + "10PagesDocumentWithInvalidStreamLength2.pdf"; @@ -1603,7 +1613,7 @@ public void streamLengthCorrection9() throws IOException { PdfPage page = pdfDoc.getPage(k); page.getPdfObject().get(PdfName.MediaBox); byte[] content = page.getFirstContentStream().getBytes(); - Assert.assertEquals(20, content.length); + Assertions.assertEquals(20, content.length); } pdfDoc.close(); PdfReader.correctStreamLength = true; @@ -1617,9 +1627,9 @@ public void freeReferencesTest() throws IOException { PdfDocument pdfDoc = new PdfDocument(new PdfReader(filename)); - Assert.assertNull(pdfDoc.getPdfObject(8)); - //Assert.assertFalse(pdfDoc.getReader().fixedXref); - Assert.assertFalse(pdfDoc.getReader().rebuiltXref); + Assertions.assertNull(pdfDoc.getPdfObject(8)); + //Assertions.assertFalse(pdfDoc.getReader().fixedXref); + Assertions.assertFalse(pdfDoc.getReader().rebuiltXref); pdfDoc.close(); } @@ -1643,7 +1653,7 @@ public void freeReferencesTest02() throws IOException, InterruptedException { inputPdfDocument.close(); outputPdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(outputFile, cmpFile, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outputFile, cmpFile, DESTINATION_FOLDER, "diff_")); } @Test @@ -1652,7 +1662,7 @@ public void pdfVersionTest() throws IOException { PdfDocument pdfDoc = new PdfDocument(new PdfReader(filename)); - Assert.assertEquals(PdfVersion.PDF_1_4, pdfDoc.getPdfVersion()); + Assertions.assertEquals(PdfVersion.PDF_1_4, pdfDoc.getPdfVersion()); pdfDoc.close(); } @@ -1670,9 +1680,9 @@ public void zeroUpdateTest() throws IOException { // trailer // <> // startxref - Assert.assertFalse(reader.hasFixedXref()); - Assert.assertFalse(reader.hasRebuiltXref()); - Assert.assertTrue(((PdfDictionary) pdfDoc.getPdfObject(1)).containsKey(PdfName.AcroForm)); + Assertions.assertFalse(reader.hasFixedXref()); + Assertions.assertFalse(reader.hasRebuiltXref()); + Assertions.assertTrue(((PdfDictionary) pdfDoc.getPdfObject(1)).containsKey(PdfName.AcroForm)); pdfDoc.close(); } @@ -1683,17 +1693,17 @@ public void incrementalUpdateWithOnlyZeroObjectUpdate() throws IOException { PdfReader reader = new PdfReader(filename); PdfDocument pdfDoc = new PdfDocument(reader); - Assert.assertFalse(reader.hasFixedXref()); - Assert.assertFalse(reader.hasRebuiltXref()); + Assertions.assertFalse(reader.hasFixedXref()); + Assertions.assertFalse(reader.hasRebuiltXref()); // problem that is tested here originally was found because the StructTreeRoot dictionary wasn't read - Assert.assertTrue(pdfDoc.isTagged()); + Assertions.assertTrue(pdfDoc.isTagged()); pdfDoc.close(); } @Test @LogMessages(messages = {@LogMessage(messageTemplate = IoLogMessageConstant.INVALID_INDIRECT_REFERENCE, count = 1), - @LogMessage(messageTemplate = IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT), + @LogMessage(messageTemplate = IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT_WITH_CAUSE), @LogMessage(messageTemplate = IoLogMessageConstant.ENCOUNTERED_INVALID_MCR)}) public void wrongTagStructureFlushingTest() throws IOException { //wrong /Pg number @@ -1701,7 +1711,7 @@ public void wrongTagStructureFlushingTest() throws IOException { String dest = DESTINATION_FOLDER + "wrongTagStructureFlushingTest.pdf"; PdfDocument pdfDoc = new PdfDocument(new PdfReader(source), CompareTool.createTestPdfWriter(dest)); pdfDoc.setTagged(); - Assert.assertEquals(PdfNull.PDF_NULL, ((PdfDictionary) pdfDoc.getPdfObject(12)).get(PdfName.Pg)); + Assertions.assertEquals(PdfNull.PDF_NULL, ((PdfDictionary) pdfDoc.getPdfObject(12)).get(PdfName.Pg)); pdfDoc.close(); } @@ -1712,10 +1722,10 @@ public void readerReuseTest() throws IOException { PdfReader reader = new PdfReader(filename); PdfDocument pdfDoc1 = new PdfDocument(reader); - Exception e = Assert.assertThrows(PdfException.class, + Exception e = Assertions.assertThrows(PdfException.class, () -> new PdfDocument(reader) ); - Assert.assertEquals(KernelExceptionMessageConstant.PDF_READER_HAS_BEEN_ALREADY_UTILIZED, e.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.PDF_READER_HAS_BEEN_ALREADY_UTILIZED, e.getMessage()); } @Test @@ -1726,17 +1736,17 @@ public void hugeInvalidIndRefObjNumberTest() throws IOException { PdfReader reader = new PdfReader(filename); PdfDocument pdfDoc = new PdfDocument(reader); PdfObject pdfObject = pdfDoc.getPdfObject(4); - Assert.assertTrue(pdfObject.isDictionary()); - Assert.assertEquals(PdfNull.PDF_NULL, ((PdfDictionary) pdfObject).get(PdfName.Pg)); + Assertions.assertTrue(pdfObject.isDictionary()); + Assertions.assertEquals(PdfNull.PDF_NULL, ((PdfDictionary) pdfObject).get(PdfName.Pg)); pdfDoc.close(); } @Test - @Ignore("DEVSIX-2133") + @Disabled("DEVSIX-2133") public void testFileIsNotLockedOnException() throws IOException { File nonPdfFileName = new File(SOURCE_FOLDER + "text_file.txt"); - Assert.assertTrue(nonPdfFileName.exists()); + Assertions.assertTrue(nonPdfFileName.exists()); boolean exceptionThrown = false; try { PdfReader reader = new PdfReader(nonPdfFileName); @@ -1747,7 +1757,7 @@ public void testFileIsNotLockedOnException() throws IOException { OutputStream stream = FileUtil.getFileOutputStream(nonPdfFileName); stream.write(new byte[] {0}); } - Assert.assertTrue(exceptionThrown); + Assertions.assertTrue(exceptionThrown); } @@ -1768,8 +1778,8 @@ private boolean objectTypeEqualTo(PdfObject object, PdfName type) { public void hasRebuiltXrefPdfDocumentNotReadTest() throws IOException { PdfReader hasRebuiltXrefReader = pdfDocumentNotReadTestInit(); - Exception e = Assert.assertThrows(PdfException.class, () -> hasRebuiltXrefReader.hasRebuiltXref()); - Assert.assertEquals(KernelExceptionMessageConstant.DOCUMENT_HAS_NOT_BEEN_READ_YET, e.getMessage()); + Exception e = Assertions.assertThrows(PdfException.class, () -> hasRebuiltXrefReader.hasRebuiltXref()); + Assertions.assertEquals(KernelExceptionMessageConstant.DOCUMENT_HAS_NOT_BEEN_READ_YET, e.getMessage()); } @Test @@ -1791,8 +1801,8 @@ protected void readPdf() throws IOException { public void hasHybridXrefPdfDocumentNotReadTest() throws IOException { PdfReader hasHybridXrefPdfReader = pdfDocumentNotReadTestInit(); - Exception e = Assert.assertThrows(PdfException.class, () -> hasHybridXrefPdfReader.hasHybridXref()); - Assert.assertEquals(KernelExceptionMessageConstant.DOCUMENT_HAS_NOT_BEEN_READ_YET, e.getMessage()); + Exception e = Assertions.assertThrows(PdfException.class, () -> hasHybridXrefPdfReader.hasHybridXref()); + Assertions.assertEquals(KernelExceptionMessageConstant.DOCUMENT_HAS_NOT_BEEN_READ_YET, e.getMessage()); } @Test @@ -1814,8 +1824,8 @@ protected void readPdf() throws IOException { public void hasXrefStmPdfDocumentNotReadTest() throws IOException { PdfReader hasXrefStmReader = pdfDocumentNotReadTestInit(); - Exception e = Assert.assertThrows(PdfException.class, () -> hasXrefStmReader.hasXrefStm()); - Assert.assertEquals(KernelExceptionMessageConstant.DOCUMENT_HAS_NOT_BEEN_READ_YET, e.getMessage()); + Exception e = Assertions.assertThrows(PdfException.class, () -> hasXrefStmReader.hasXrefStm()); + Assertions.assertEquals(KernelExceptionMessageConstant.DOCUMENT_HAS_NOT_BEEN_READ_YET, e.getMessage()); } @Test @@ -1837,8 +1847,8 @@ protected void readPdf() throws IOException { public void hasFixedXrefPdfDocumentNotReadTest() throws IOException { PdfReader hasFixedXrefReader = pdfDocumentNotReadTestInit(); - Exception e = Assert.assertThrows(PdfException.class, () -> hasFixedXrefReader.hasFixedXref()); - Assert.assertEquals(KernelExceptionMessageConstant.DOCUMENT_HAS_NOT_BEEN_READ_YET, e.getMessage()); + Exception e = Assertions.assertThrows(PdfException.class, () -> hasFixedXrefReader.hasFixedXref()); + Assertions.assertEquals(KernelExceptionMessageConstant.DOCUMENT_HAS_NOT_BEEN_READ_YET, e.getMessage()); } @Test @@ -1860,8 +1870,8 @@ protected void readPdf() throws IOException { public void getLastXrefPdfDocumentNotReadTest() throws IOException { PdfReader getLastXrefReader = pdfDocumentNotReadTestInit(); - Exception e = Assert.assertThrows(PdfException.class, () -> getLastXrefReader.getLastXref()); - Assert.assertEquals(KernelExceptionMessageConstant.DOCUMENT_HAS_NOT_BEEN_READ_YET, e.getMessage()); + Exception e = Assertions.assertThrows(PdfException.class, () -> getLastXrefReader.getLastXref()); + Assertions.assertEquals(KernelExceptionMessageConstant.DOCUMENT_HAS_NOT_BEEN_READ_YET, e.getMessage()); } @Test @@ -1883,8 +1893,8 @@ protected void readPdf() throws IOException { public void getPermissionsPdfDocumentNotReadTest() throws IOException { PdfReader getPermissionsReader = pdfDocumentNotReadTestInit(); - Exception e = Assert.assertThrows(PdfException.class, () -> getPermissionsReader.getPermissions()); - Assert.assertEquals(KernelExceptionMessageConstant.DOCUMENT_HAS_NOT_BEEN_READ_YET, e.getMessage()); + Exception e = Assertions.assertThrows(PdfException.class, () -> getPermissionsReader.getPermissions()); + Assertions.assertEquals(KernelExceptionMessageConstant.DOCUMENT_HAS_NOT_BEEN_READ_YET, e.getMessage()); } @Test @@ -1906,10 +1916,10 @@ protected void readPdf() throws IOException { public void isOpenedWithFullPPdfDocumentNotReadTest() throws IOException { PdfReader isOpenedWithFullPReader = pdfDocumentNotReadTestInit(); - Exception e = Assert.assertThrows(PdfException.class, + Exception e = Assertions.assertThrows(PdfException.class, () -> isOpenedWithFullPReader.isOpenedWithFullPermission() ); - Assert.assertEquals(KernelExceptionMessageConstant.DOCUMENT_HAS_NOT_BEEN_READ_YET, e.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.DOCUMENT_HAS_NOT_BEEN_READ_YET, e.getMessage()); } @Test @@ -1931,8 +1941,8 @@ protected void readPdf() throws IOException { public void getCryptoModePdfDocumentNotReadTest() throws IOException { PdfReader getCryptoModeReader = pdfDocumentNotReadTestInit(); - Exception e = Assert.assertThrows(PdfException.class, () -> getCryptoModeReader.getCryptoMode()); - Assert.assertEquals(KernelExceptionMessageConstant.DOCUMENT_HAS_NOT_BEEN_READ_YET, e.getMessage()); + Exception e = Assertions.assertThrows(PdfException.class, () -> getCryptoModeReader.getCryptoMode()); + Assertions.assertEquals(KernelExceptionMessageConstant.DOCUMENT_HAS_NOT_BEEN_READ_YET, e.getMessage()); } @Test @@ -1954,10 +1964,10 @@ protected void readPdf() throws IOException { public void computeUserPasswordPdfDocumentNotReadTest() throws IOException { PdfReader computeUserPasswordReader = pdfDocumentNotReadTestInit(); - Exception e = Assert.assertThrows(PdfException.class, + Exception e = Assertions.assertThrows(PdfException.class, () -> computeUserPasswordReader.computeUserPassword() ); - Assert.assertEquals(KernelExceptionMessageConstant.DOCUMENT_HAS_NOT_BEEN_READ_YET, e.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.DOCUMENT_HAS_NOT_BEEN_READ_YET, e.getMessage()); } @Test @@ -1979,8 +1989,8 @@ protected void readPdf() throws IOException { public void getOriginalFileIdPdfDocumentNotReadTest() throws IOException { PdfReader getOriginalFileIdReader = pdfDocumentNotReadTestInit(); - Exception e = Assert.assertThrows(PdfException.class, () -> getOriginalFileIdReader.getOriginalFileId()); - Assert.assertEquals(KernelExceptionMessageConstant.DOCUMENT_HAS_NOT_BEEN_READ_YET, e.getMessage()); + Exception e = Assertions.assertThrows(PdfException.class, () -> getOriginalFileIdReader.getOriginalFileId()); + Assertions.assertEquals(KernelExceptionMessageConstant.DOCUMENT_HAS_NOT_BEEN_READ_YET, e.getMessage()); } @Test @@ -2002,8 +2012,8 @@ protected void readPdf() throws IOException { public void getModifiedFileIdPdfDocumentNotReadTest() throws IOException { PdfReader getModifiedFileIdReader = pdfDocumentNotReadTestInit(); - Exception e = Assert.assertThrows(PdfException.class, () -> getModifiedFileIdReader.getModifiedFileId()); - Assert.assertEquals(KernelExceptionMessageConstant.DOCUMENT_HAS_NOT_BEEN_READ_YET, e.getMessage()); + Exception e = Assertions.assertThrows(PdfException.class, () -> getModifiedFileIdReader.getModifiedFileId()); + Assertions.assertEquals(KernelExceptionMessageConstant.DOCUMENT_HAS_NOT_BEEN_READ_YET, e.getMessage()); } @Test @@ -2025,8 +2035,8 @@ protected void readPdf() throws IOException { public void isEncryptedPdfDocumentNotReadTest() throws IOException { PdfReader isEncryptedReader = pdfDocumentNotReadTestInit(); - Exception e = Assert.assertThrows(PdfException.class, () -> isEncryptedReader.isEncrypted()); - Assert.assertEquals(KernelExceptionMessageConstant.DOCUMENT_HAS_NOT_BEEN_READ_YET, e.getMessage()); + Exception e = Assertions.assertThrows(PdfException.class, () -> isEncryptedReader.isEncrypted()); + Assertions.assertEquals(KernelExceptionMessageConstant.DOCUMENT_HAS_NOT_BEEN_READ_YET, e.getMessage()); } @Test @@ -2053,26 +2063,26 @@ public void pdf11VersionValidTest() throws IOException { @Test public void noPdfVersionTest() throws IOException { PdfReader pdfReader = new PdfReader(SOURCE_FOLDER + "noPdfVersion.pdf"); - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> pdfReader.readPdf()); - Assert.assertEquals(KernelExceptionMessageConstant.PDF_VERSION_IS_NOT_VALID, exception.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.PDF_VERSION_IS_NOT_VALID, exception.getMessage()); } @Test public void startxrefIsNotFollowedByANumberTest() throws IOException { PdfReader pdfReader = new PdfReader(SOURCE_FOLDER + "startxrefIsNotFollowedByANumber.pdf"); - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> pdfReader.readXref()); - Assert.assertEquals(KernelExceptionMessageConstant.PDF_STARTXREF_IS_NOT_FOLLOWED_BY_A_NUMBER, + Assertions.assertEquals(KernelExceptionMessageConstant.PDF_STARTXREF_IS_NOT_FOLLOWED_BY_A_NUMBER, exception.getMessage()); } @Test public void startxrefNotFoundTest() throws IOException { PdfReader pdfReader = new PdfReader(SOURCE_FOLDER + "startxrefNotFound.pdf"); - Exception exception = Assert.assertThrows(com.itextpdf.io.exceptions.IOException.class, + Exception exception = Assertions.assertThrows(com.itextpdf.io.exceptions.IOException.class, () -> pdfReader.readXref()); - Assert.assertEquals(KernelExceptionMessageConstant.PDF_STARTXREF_NOT_FOUND, exception.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.PDF_STARTXREF_NOT_FOUND, exception.getMessage()); } @Test @@ -2082,11 +2092,11 @@ public void closeStreamCreatedByITextTest() throws IOException { //Later in the test we will need to delete a file. Since we do not want to delete it from sources, we will // copy it to destination folder. File copiedFile = copyFileForTest(fileName, copiedFileName); - Exception e = Assert.assertThrows(com.itextpdf.io.exceptions.IOException.class, () -> new PdfReader(fileName)); - Assert.assertEquals(IoExceptionMessageConstant.PDF_HEADER_NOT_FOUND, e.getMessage()); + Exception e = Assertions.assertThrows(com.itextpdf.io.exceptions.IOException.class, () -> new PdfReader(fileName)); + Assertions.assertEquals(IoExceptionMessageConstant.PDF_HEADER_NOT_FOUND, e.getMessage()); //This check is meaningfull only on Windows, since on other OS the fact of a stream being open doesn't // prevent the stream from being deleted. - Assert.assertTrue(FileUtil.deleteFile(copiedFile)); + Assertions.assertTrue(FileUtil.deleteFile(copiedFile)); } @Test @@ -2095,10 +2105,10 @@ public void notCloseUserStreamTest() throws IOException { try (InputStream pdfStream = FileUtil.getInputStreamForFile(fileName)) { IRandomAccessSource randomAccessSource = new RandomAccessSourceFactory() .createSource(pdfStream); - Exception e = Assert.assertThrows(com.itextpdf.io.exceptions.IOException.class, + Exception e = Assertions.assertThrows(com.itextpdf.io.exceptions.IOException.class, () -> new PdfReader(randomAccessSource, new ReaderProperties())); //An exception would be thrown, if stream is closed. - Assert.assertEquals(-1, pdfStream.read()); + Assertions.assertEquals(-1, pdfStream.read()); } } @@ -2112,25 +2122,25 @@ public void endDicInsteadOfArrayClosingBracketTest() throws IOException { PdfArray actual = (PdfArray) document.getPdfObject(4); PdfArray expected = new PdfArray(new float[] {5, 10, 15, 20}); for (int i = 0; i < expected.size(); i++) { - Assert.assertEquals(expected.get(i), actual.get(i)); + Assertions.assertEquals(expected.get(i), actual.get(i)); } } @Test public void endArrayClosingBracketInsteadOfEndDicTest() { String fileName = SOURCE_FOLDER + "endArrayClosingBracketInsteadOfEndDic.pdf"; - Exception exception = Assert.assertThrows(com.itextpdf.io.exceptions.IOException.class, + Exception exception = Assertions.assertThrows(com.itextpdf.io.exceptions.IOException.class, () -> new PdfDocument(new PdfReader(fileName))); - Assert.assertEquals(MessageFormatUtil.format(KernelExceptionMessageConstant.UNEXPECTED_TOKEN, "]"), + Assertions.assertEquals(MessageFormatUtil.format(KernelExceptionMessageConstant.UNEXPECTED_TOKEN, "]"), exception.getCause().getMessage()); } @Test public void endDicClosingBracketInsideTheDicTest() { String fileName = SOURCE_FOLDER + "endDicClosingBracketInsideTheDic.pdf"; - Exception exception = Assert.assertThrows(com.itextpdf.io.exceptions.IOException.class, + Exception exception = Assertions.assertThrows(com.itextpdf.io.exceptions.IOException.class, () -> new PdfDocument(new PdfReader(fileName))); - Assert.assertEquals(MessageFormatUtil.format(KernelExceptionMessageConstant.UNEXPECTED_TOKEN, ">>"), + Assertions.assertEquals(MessageFormatUtil.format(KernelExceptionMessageConstant.UNEXPECTED_TOKEN, ">>"), exception.getCause().getMessage()); } @@ -2144,7 +2154,7 @@ public void eofInsteadOfArrayClosingBracketTest() throws IOException { PdfArray actual = (PdfArray) document.getPdfObject(4); PdfArray expected = new PdfArray(new float[] {5, 10, 15, 20}); for (int i = 0; i < expected.size(); i++) { - Assert.assertEquals(expected.get(i), actual.get(i)); + Assertions.assertEquals(expected.get(i), actual.get(i)); } } @@ -2158,14 +2168,14 @@ public void endObjInsteadOfArrayClosingBracketTest() throws IOException { PdfArray actual = (PdfArray) document.getPdfObject(4); PdfArray expected = new PdfArray(new float[] {5, 10, 15, 20}); for (int i = 0; i < expected.size(); i++) { - Assert.assertEquals(expected.get(i), actual.get(i)); + Assertions.assertEquals(expected.get(i), actual.get(i)); } } @Test @LogMessages(messages = { @LogMessage(messageTemplate = KernelExceptionMessageConstant.UNEXPECTED_TOKEN), - @LogMessage(messageTemplate = IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT) + @LogMessage(messageTemplate = IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT_WITH_CAUSE) }) public void nameInsteadOfArrayClosingBracketTest() throws IOException { String fileName = SOURCE_FOLDER + "invalidArrayNameToken.pdf"; @@ -2173,7 +2183,7 @@ public void nameInsteadOfArrayClosingBracketTest() throws IOException { PdfArray actual = (PdfArray) document.getPdfObject(4); PdfArray expected = new PdfArray(new float[] {5, 10, 15, 20}); for (int i = 0; i < expected.size(); i++) { - Assert.assertEquals(expected.get(i), actual.get(i)); + Assertions.assertEquals(expected.get(i), actual.get(i)); } } @@ -2187,7 +2197,7 @@ public void objInsteadOfArrayClosingBracketTest() throws IOException { PdfArray actual = (PdfArray) document.getPdfObject(4); PdfArray expected = new PdfArray(new float[] {5, 10, 15, 20}); for (int i = 0; i < expected.size(); i++) { - Assert.assertEquals(expected.get(i), actual.get(i)); + Assertions.assertEquals(expected.get(i), actual.get(i)); } } @@ -2201,7 +2211,7 @@ public void refInsteadOfArrayClosingBracketTest() throws IOException { PdfArray actual = (PdfArray) document.getPdfObject(4); PdfArray expected = new PdfArray(new float[] {5, 10, 15, 20}); for (int i = 0; i < expected.size(); i++) { - Assert.assertEquals(expected.get(i), actual.get(i)); + Assertions.assertEquals(expected.get(i), actual.get(i)); } } @@ -2215,14 +2225,14 @@ public void startArrayInsteadOfArrayClosingBracketTest() throws IOException { PdfArray actual = (PdfArray) document.getPdfObject(4); PdfArray expected = new PdfArray(new float[] {5, 10, 15, 20}); for (int i = 0; i < expected.size(); i++) { - Assert.assertEquals(expected.get(i), actual.get(i)); + Assertions.assertEquals(expected.get(i), actual.get(i)); } } @Test @LogMessages(messages = { @LogMessage(messageTemplate = KernelExceptionMessageConstant.UNEXPECTED_TOKEN), - @LogMessage(messageTemplate = IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT) + @LogMessage(messageTemplate = IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT_WITH_CAUSE) }) public void stringInsteadOfArrayClosingBracketTest() throws IOException { String fileName = SOURCE_FOLDER + "invalidArrayStringToken.pdf"; @@ -2230,7 +2240,7 @@ public void stringInsteadOfArrayClosingBracketTest() throws IOException { PdfArray actual = (PdfArray) document.getPdfObject(4); PdfArray expected = new PdfArray(new float[] {5, 10, 15, 20}); for (int i = 0; i < expected.size(); i++) { - Assert.assertEquals(expected.get(i), actual.get(i)); + Assertions.assertEquals(expected.get(i), actual.get(i)); } } @@ -2240,9 +2250,9 @@ public void closingArrayBracketMissingConservativeTest() throws IOException { PdfReader reader = new PdfReader(fileName); reader.setStrictnessLevel(StrictnessLevel.CONSERVATIVE); PdfDocument document = new PdfDocument(reader); - Exception exception = Assert.assertThrows(com.itextpdf.io.exceptions.IOException.class, + Exception exception = Assertions.assertThrows(com.itextpdf.io.exceptions.IOException.class, () -> document.getPdfObject(4)); - Assert.assertEquals(MessageFormatUtil.format(KernelExceptionMessageConstant.UNEXPECTED_TOKEN, "obj"), + Assertions.assertEquals(MessageFormatUtil.format(KernelExceptionMessageConstant.UNEXPECTED_TOKEN, "obj"), exception.getCause().getMessage()); } @@ -2257,9 +2267,9 @@ public void readRASInputStreamClosedTest() throws IOException { randomAccessSource.close(); - Exception e = Assert.assertThrows(IllegalStateException.class, + Exception e = Assertions.assertThrows(IllegalStateException.class, () -> new PdfReader(rasInputStream)); - Assert.assertEquals(IoExceptionMessageConstant.ALREADY_CLOSED, e.getMessage()); + Assertions.assertEquals(IoExceptionMessageConstant.ALREADY_CLOSED, e.getMessage()); } } @@ -2273,8 +2283,8 @@ public void readRASInputStreamTest() throws IOException { try (PdfReader reader = new PdfReader(rasInputStream)) { randomAccessSource.close(); - Exception e = Assert.assertThrows(IllegalStateException.class, () -> new PdfDocument(reader)); - Assert.assertEquals(IoExceptionMessageConstant.ALREADY_CLOSED, e.getMessage()); + Exception e = Assertions.assertThrows(IllegalStateException.class, () -> new PdfDocument(reader)); + Assertions.assertEquals(IoExceptionMessageConstant.ALREADY_CLOSED, e.getMessage()); } } } @@ -2306,22 +2316,22 @@ private PdfReader pdfDocumentNotReadTestInit() throws IOException { } private void readingNotCompletedTest(PdfReader reader) { - Exception e = Assert.assertThrows(PdfException.class, () -> new PdfDocument(reader)); - Assert.assertEquals(KernelExceptionMessageConstant.DOCUMENT_HAS_NOT_BEEN_READ_YET, e.getMessage()); + Exception e = Assertions.assertThrows(PdfException.class, () -> new PdfDocument(reader)); + Assertions.assertEquals(KernelExceptionMessageConstant.DOCUMENT_HAS_NOT_BEEN_READ_YET, e.getMessage()); } @Test - public void getPdfAConformanceLevelPdfDocumentNotReadTest() throws IOException { + public void getPdfAConformancePdfDocumentNotReadTest() throws IOException { PdfReader getModifiedFileIdReader = pdfDocumentNotReadTestInit(); - Exception e = Assert.assertThrows(PdfException.class, () -> getModifiedFileIdReader.getPdfAConformanceLevel()); - Assert.assertEquals(KernelExceptionMessageConstant.DOCUMENT_HAS_NOT_BEEN_READ_YET, e.getMessage()); + Exception e = Assertions.assertThrows(PdfException.class, () -> getModifiedFileIdReader.getPdfConformance()); + Assertions.assertEquals(KernelExceptionMessageConstant.DOCUMENT_HAS_NOT_BEEN_READ_YET, e.getMessage()); } @Test - public void getPdfAConformanceLevelNoMetadataTest() throws IOException { + public void getPdfConformanceNoMetadataTest() throws IOException { PdfDocument pdfDoc = new PdfDocument(new PdfReader(new ByteArrayInputStream(createPdfDocumentForTest()))); - Assert.assertNull(pdfDoc.getReader().getPdfAConformanceLevel()); + Assertions.assertFalse(pdfDoc.getReader().getPdfConformance().isPdfAOrUa()); } @Test @@ -2329,11 +2339,11 @@ public void xrefStreamPointsItselfTest() throws IOException { String fileName = SOURCE_FOLDER + "xrefStreamPointsItself.pdf"; try (PdfReader pdfReader = new PdfReader(fileName)) { - Exception exception = Assert.assertThrows(XrefCycledReferencesException.class, + Exception exception = Assertions.assertThrows(XrefCycledReferencesException.class, () -> new PdfDocument(pdfReader)); - Assert.assertEquals(StrictnessLevel.LENIENT, pdfReader.getStrictnessLevel()); - Assert.assertEquals(KernelExceptionMessageConstant.XREF_STREAM_HAS_CYCLED_REFERENCES, + Assertions.assertEquals(StrictnessLevel.LENIENT, pdfReader.getStrictnessLevel()); + Assertions.assertEquals(KernelExceptionMessageConstant.XREF_STREAM_HAS_CYCLED_REFERENCES, exception.getMessage()); } } @@ -2344,32 +2354,32 @@ public void xrefStreamPointsItselfConservativeModeTest() throws IOException { try (PdfReader pdfReader = new PdfReader(fileName)) { pdfReader.setStrictnessLevel(StrictnessLevel.CONSERVATIVE); - Exception exception = Assert.assertThrows(XrefCycledReferencesException.class, + Exception exception = Assertions.assertThrows(XrefCycledReferencesException.class, () -> new PdfDocument(pdfReader)); - Assert.assertEquals(StrictnessLevel.CONSERVATIVE, pdfReader.getStrictnessLevel()); - Assert.assertEquals(KernelExceptionMessageConstant.XREF_STREAM_HAS_CYCLED_REFERENCES, + Assertions.assertEquals(StrictnessLevel.CONSERVATIVE, pdfReader.getStrictnessLevel()); + Assertions.assertEquals(KernelExceptionMessageConstant.XREF_STREAM_HAS_CYCLED_REFERENCES, exception.getMessage()); } } @LogMessages(messages = @LogMessage(messageTemplate = - IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT)) + IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT_WITH_CAUSE)) @Test public void exactLimitOfObjectNrSizeTest() throws IOException { String fileName = SOURCE_FOLDER + "exactLimitOfObjectNr.pdf"; try (PdfReader pdfReader = new PdfReader(fileName)) { - Exception exception = Assert.assertThrows(MemoryLimitsAwareException.class, + Exception exception = Assertions.assertThrows(MemoryLimitsAwareException.class, () -> new PdfDocument(pdfReader)); - Assert.assertEquals(KernelExceptionMessageConstant.XREF_STRUCTURE_SIZE_EXCEEDED_THE_LIMIT, + Assertions.assertEquals(KernelExceptionMessageConstant.XREF_STRUCTURE_SIZE_EXCEEDED_THE_LIMIT, exception.getMessage()); } } @LogMessages(messages = @LogMessage(messageTemplate = - IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT)) + IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT_WITH_CAUSE)) @Test public void justBeforeLimitOfObjectNrSizeTest() throws IOException, InterruptedException { String inputFile = SOURCE_FOLDER + "justBeforeLimitOfObjectNr.pdf"; @@ -2377,7 +2387,7 @@ public void justBeforeLimitOfObjectNrSizeTest() throws IOException, InterruptedE //trying to open the document to see that no error is thrown PdfReader pdfReader = new PdfReader(inputFile); PdfDocument document = new PdfDocument(pdfReader); - Assert.assertEquals(500000, document.getXref().getCapacity()); + Assertions.assertEquals(500000, document.getXref().getCapacity()); document.close(); } @@ -2386,11 +2396,11 @@ public void xrefStreamsHaveCycledReferencesTest() throws IOException { String fileName = SOURCE_FOLDER + "cycledReferencesInXrefStreams.pdf"; try (PdfReader pdfReader = new PdfReader(fileName)) { - Exception exception = Assert.assertThrows(XrefCycledReferencesException.class, + Exception exception = Assertions.assertThrows(XrefCycledReferencesException.class, () -> new PdfDocument(pdfReader)); - Assert.assertEquals(StrictnessLevel.LENIENT, pdfReader.getStrictnessLevel()); - Assert.assertEquals(KernelExceptionMessageConstant.XREF_STREAM_HAS_CYCLED_REFERENCES, + Assertions.assertEquals(StrictnessLevel.LENIENT, pdfReader.getStrictnessLevel()); + Assertions.assertEquals(KernelExceptionMessageConstant.XREF_STREAM_HAS_CYCLED_REFERENCES, exception.getMessage()); } } @@ -2401,40 +2411,40 @@ public void xrefStreamsHaveCycledReferencesConservativeModeTest() throws IOExcep try (PdfReader pdfReader = new PdfReader(fileName)) { pdfReader.setStrictnessLevel(StrictnessLevel.CONSERVATIVE); - Exception exception = Assert.assertThrows(XrefCycledReferencesException.class, + Exception exception = Assertions.assertThrows(XrefCycledReferencesException.class, () -> new PdfDocument(pdfReader)); - Assert.assertEquals(StrictnessLevel.CONSERVATIVE, pdfReader.getStrictnessLevel()); - Assert.assertEquals(KernelExceptionMessageConstant.XREF_STREAM_HAS_CYCLED_REFERENCES, + Assertions.assertEquals(StrictnessLevel.CONSERVATIVE, pdfReader.getStrictnessLevel()); + Assertions.assertEquals(KernelExceptionMessageConstant.XREF_STREAM_HAS_CYCLED_REFERENCES, exception.getMessage()); } } @Test @LogMessages(messages = @LogMessage(messageTemplate = - IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT, count = 1)) + IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT_WITH_CAUSE, count = 1)) public void xrefTablesHaveCycledReferencesTest() throws IOException { String fileName = SOURCE_FOLDER + "cycledReferencesInXrefTables.pdf"; try (PdfReader pdfReader = new PdfReader(fileName)) { AssertUtil.doesNotThrow(() -> new PdfDocument(pdfReader)); - Assert.assertEquals(StrictnessLevel.LENIENT, pdfReader.getStrictnessLevel()); - Assert.assertTrue(pdfReader.hasRebuiltXref()); + Assertions.assertEquals(StrictnessLevel.LENIENT, pdfReader.getStrictnessLevel()); + Assertions.assertTrue(pdfReader.hasRebuiltXref()); } } @Test @LogMessages(messages = @LogMessage(messageTemplate = - IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT, count = 1)) + IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT_WITH_CAUSE, count = 1)) public void xrefTablePointsItselfTest() throws IOException { String fileName = SOURCE_FOLDER + "xrefTablePointsItself.pdf"; try (PdfReader pdfReader = new PdfReader(fileName)) { AssertUtil.doesNotThrow(() -> new PdfDocument(pdfReader)); - Assert.assertEquals(StrictnessLevel.LENIENT, pdfReader.getStrictnessLevel()); - Assert.assertTrue(pdfReader.hasRebuiltXref()); + Assertions.assertEquals(StrictnessLevel.LENIENT, pdfReader.getStrictnessLevel()); + Assertions.assertTrue(pdfReader.hasRebuiltXref()); } } @@ -2444,11 +2454,11 @@ public void xrefTablePointsItselfConservativeModeTest() throws IOException { try (PdfReader pdfReader = new PdfReader(fileName)) { pdfReader.setStrictnessLevel(StrictnessLevel.CONSERVATIVE); - Exception exception = Assert.assertThrows(XrefCycledReferencesException.class, + Exception exception = Assertions.assertThrows(XrefCycledReferencesException.class, () -> new PdfDocument(pdfReader)); - Assert.assertEquals(StrictnessLevel.CONSERVATIVE, pdfReader.getStrictnessLevel()); - Assert.assertEquals(KernelExceptionMessageConstant.XREF_TABLE_HAS_CYCLED_REFERENCES, + Assertions.assertEquals(StrictnessLevel.CONSERVATIVE, pdfReader.getStrictnessLevel()); + Assertions.assertEquals(KernelExceptionMessageConstant.XREF_TABLE_HAS_CYCLED_REFERENCES, exception.getMessage()); } } @@ -2459,11 +2469,11 @@ public void xrefTablesHaveCycledReferencesConservativeModeTest() throws IOExcept try (PdfReader pdfReader = new PdfReader(fileName)) { pdfReader.setStrictnessLevel(StrictnessLevel.CONSERVATIVE); - Exception exception = Assert.assertThrows(XrefCycledReferencesException.class, + Exception exception = Assertions.assertThrows(XrefCycledReferencesException.class, () -> new PdfDocument(pdfReader)); - Assert.assertEquals(StrictnessLevel.CONSERVATIVE, pdfReader.getStrictnessLevel()); - Assert.assertEquals(KernelExceptionMessageConstant.XREF_TABLE_HAS_CYCLED_REFERENCES, + Assertions.assertEquals(StrictnessLevel.CONSERVATIVE, pdfReader.getStrictnessLevel()); + Assertions.assertEquals(KernelExceptionMessageConstant.XREF_TABLE_HAS_CYCLED_REFERENCES, exception.getMessage()); } } @@ -2473,8 +2483,8 @@ public void checkXrefStreamInvalidSize() throws IOException { final String fileName = SOURCE_FOLDER + "xrefStreamInvalidSize.pdf"; try (PdfReader reader = new PdfReader(fileName)) { - Exception ex = Assert.assertThrows(MemoryLimitsAwareException.class, () -> new PdfDocument(reader)); - Assert.assertEquals(KernelExceptionMessageConstant.XREF_STRUCTURE_SIZE_EXCEEDED_THE_LIMIT, ex.getMessage()); + Exception ex = Assertions.assertThrows(MemoryLimitsAwareException.class, () -> new PdfDocument(reader)); + Assertions.assertEquals(KernelExceptionMessageConstant.XREF_STRUCTURE_SIZE_EXCEEDED_THE_LIMIT, ex.getMessage()); } } @@ -2495,15 +2505,15 @@ public void checkXrefPrevWithDifferentTypesTest() throws IOException { AssertUtil.doesNotThrow(() -> reader.getXrefPrev(indirectReferenceXrefPrev)); // Check string xref prev with StrictnessLevel#LENIENT. - Exception exception = Assert.assertThrows(InvalidXRefPrevException.class, + Exception exception = Assertions.assertThrows(InvalidXRefPrevException.class, () -> reader.getXrefPrev(stringXrefPrev)); - Assert.assertEquals(KernelExceptionMessageConstant.XREF_PREV_SHALL_BE_DIRECT_NUMBER_OBJECT, + Assertions.assertEquals(KernelExceptionMessageConstant.XREF_PREV_SHALL_BE_DIRECT_NUMBER_OBJECT, exception.getMessage()); // Check indirect reference to string xref prev with StrictnessLevel#LENIENT. - exception = Assert.assertThrows(InvalidXRefPrevException.class, + exception = Assertions.assertThrows(InvalidXRefPrevException.class, () -> reader.getXrefPrev(indirectReferenceToString)); - Assert.assertEquals(KernelExceptionMessageConstant.XREF_PREV_SHALL_BE_DIRECT_NUMBER_OBJECT, + Assertions.assertEquals(KernelExceptionMessageConstant.XREF_PREV_SHALL_BE_DIRECT_NUMBER_OBJECT, exception.getMessage()); } } @@ -2523,21 +2533,21 @@ public void checkXrefPrevWithDifferentTypesConservativeModeTest() throws IOExcep AssertUtil.doesNotThrow(() -> reader.getXrefPrev(numberXrefPrev)); // Check indirect reference to number xref prev with StrictnessLevel#CONSERVATIVE. - Exception exception = Assert.assertThrows(InvalidXRefPrevException.class, + Exception exception = Assertions.assertThrows(InvalidXRefPrevException.class, () -> reader.getXrefPrev(indirectReferenceXrefPrev)); - Assert.assertEquals(KernelExceptionMessageConstant.XREF_PREV_SHALL_BE_DIRECT_NUMBER_OBJECT, + Assertions.assertEquals(KernelExceptionMessageConstant.XREF_PREV_SHALL_BE_DIRECT_NUMBER_OBJECT, exception.getMessage()); // Check string xref prev with StrictnessLevel#CONSERVATIVE. - exception = Assert.assertThrows(InvalidXRefPrevException.class, + exception = Assertions.assertThrows(InvalidXRefPrevException.class, () -> reader.getXrefPrev(stringXrefPrev)); - Assert.assertEquals(KernelExceptionMessageConstant.XREF_PREV_SHALL_BE_DIRECT_NUMBER_OBJECT, + Assertions.assertEquals(KernelExceptionMessageConstant.XREF_PREV_SHALL_BE_DIRECT_NUMBER_OBJECT, exception.getMessage()); // Check indirect reference to string xref prev with StrictnessLevel#CONSERVATIVE. - exception = Assert.assertThrows(InvalidXRefPrevException.class, + exception = Assertions.assertThrows(InvalidXRefPrevException.class, () -> reader.getXrefPrev(indirectReferenceToString)); - Assert.assertEquals(KernelExceptionMessageConstant.XREF_PREV_SHALL_BE_DIRECT_NUMBER_OBJECT, + Assertions.assertEquals(KernelExceptionMessageConstant.XREF_PREV_SHALL_BE_DIRECT_NUMBER_OBJECT, exception.getMessage()); } } @@ -2551,7 +2561,7 @@ public void readDocumentWithIndirectPrevTest() throws IOException { try (PdfReader reader = new PdfReader(fileName); PdfDocument document = new PdfDocument(reader)) { final PdfDictionary documentTrailer = document.getTrailer(); - Assert.assertTrue(documentTrailer.get(PdfName.Prev, false).isIndirectReference()); + Assertions.assertTrue(documentTrailer.get(PdfName.Prev, false).isIndirectReference()); } // Read/write pdf document to rewrite xref structure. @@ -2564,7 +2574,7 @@ public void readDocumentWithIndirectPrevTest() throws IOException { try (PdfReader reader = CompareTool.createOutputReader(outputName); PdfDocument document = new PdfDocument(reader)) { PdfDictionary trailer = document.getTrailer(); - Assert.assertNull(trailer.get(PdfName.Prev, false)); + Assertions.assertNull(trailer.get(PdfName.Prev, false)); } } @@ -2577,7 +2587,7 @@ public void notChangeInvalidPrevInAppendModeTest() throws IOException { try (PdfReader reader = new PdfReader(fileName); PdfDocument document = new PdfDocument(reader)) { final PdfDictionary documentTrailer = document.getTrailer(); - Assert.assertTrue(documentTrailer.get(PdfName.Prev, false).isIndirectReference()); + Assertions.assertTrue(documentTrailer.get(PdfName.Prev, false).isIndirectReference()); } // Read and write document in append mode to not change previous xref prev. @@ -2592,11 +2602,11 @@ public void notChangeInvalidPrevInAppendModeTest() throws IOException { try (PdfReader reader = CompareTool.createOutputReader(outputName); PdfDocument document = new PdfDocument(reader)) { final PdfDictionary trailer = document.getTrailer(); - Assert.assertFalse(trailer.get(PdfName.Prev, false).isIndirectReference()); + Assertions.assertFalse(trailer.get(PdfName.Prev, false).isIndirectReference()); PdfNumber prevPointer = (PdfNumber) trailer.get(PdfName.Prev); reader.tokens.seek(prevPointer.longValue()); final PdfDictionary previousTrailer = reader.readXrefSection(); - Assert.assertTrue(previousTrailer.get(PdfName.Prev, false).isIndirectReference()); + Assertions.assertTrue(previousTrailer.get(PdfName.Prev, false).isIndirectReference()); } } @@ -2607,9 +2617,9 @@ public void readPdfInvalidPrevConservativeModeTest() throws IOException { // Simply open document with StrictnessLevel#CONSERVATIVE. try (PdfReader reader = new PdfReader(fileName)) { reader.setStrictnessLevel(StrictnessLevel.CONSERVATIVE); - Exception exception = Assert.assertThrows(InvalidXRefPrevException.class, () -> new PdfDocument(reader)); + Exception exception = Assertions.assertThrows(InvalidXRefPrevException.class, () -> new PdfDocument(reader)); - Assert.assertEquals(KernelExceptionMessageConstant.XREF_PREV_SHALL_BE_DIRECT_NUMBER_OBJECT, + Assertions.assertEquals(KernelExceptionMessageConstant.XREF_PREV_SHALL_BE_DIRECT_NUMBER_OBJECT, exception.getMessage()); } @@ -2618,10 +2628,10 @@ public void readPdfInvalidPrevConservativeModeTest() throws IOException { try (PdfReader reader = new PdfReader(fileName); PdfWriter writer = new PdfWriter(new ByteArrayOutputStream())) { reader.setStrictnessLevel(StrictnessLevel.CONSERVATIVE); - Exception exception = Assert.assertThrows(InvalidXRefPrevException.class, + Exception exception = Assertions.assertThrows(InvalidXRefPrevException.class, () -> new PdfDocument(reader, writer, properties)); - Assert.assertEquals(KernelExceptionMessageConstant.XREF_PREV_SHALL_BE_DIRECT_NUMBER_OBJECT, + Assertions.assertEquals(KernelExceptionMessageConstant.XREF_PREV_SHALL_BE_DIRECT_NUMBER_OBJECT, exception.getMessage()); } @@ -2629,50 +2639,60 @@ public void readPdfInvalidPrevConservativeModeTest() throws IOException { try (PdfReader reader = new PdfReader(fileName); PdfWriter writer = new PdfWriter(new ByteArrayOutputStream())) { reader.setStrictnessLevel(StrictnessLevel.CONSERVATIVE); - Exception exception = Assert.assertThrows(InvalidXRefPrevException.class, + Exception exception = Assertions.assertThrows(InvalidXRefPrevException.class, () -> new PdfDocument(reader, writer)); - Assert.assertEquals(KernelExceptionMessageConstant.XREF_PREV_SHALL_BE_DIRECT_NUMBER_OBJECT, + Assertions.assertEquals(KernelExceptionMessageConstant.XREF_PREV_SHALL_BE_DIRECT_NUMBER_OBJECT, exception.getMessage()); } } @Test - public void streamWithoutEndstreamKeywordTest() throws IOException, XMPException { + public void streamWithoutEndstreamKeywordTest() throws IOException { final String fileName = SOURCE_FOLDER + "NoEndstreamKeyword.pdf"; try (PdfReader reader = new PdfReader(fileName)) { reader.setStrictnessLevel(StrictnessLevel.LENIENT); try (PdfDocument document = new PdfDocument(reader)) { - final PdfCatalog catalog = new PdfCatalog((PdfDictionary) reader.trailer - .get(PdfName.Root, true)); + // Initialize xmp metadata, because we in reader mode in which xmp will be initialized only during closing + byte[] metadataBytes = document.getXmpMetadataBytes(); + final PdfCatalog catalog = new PdfCatalog((PdfDictionary) reader.trailer.get(PdfName.Root, true)); final PdfStream xmpMetadataStream = catalog.getPdfObject().getAsStream(PdfName.Metadata); final int xmpMetadataStreamLength = ((PdfNumber) xmpMetadataStream.get(PdfName.Length)).intValue(); - // 27600 is actual invalid length of stream. In reader StrictnessLevel#LENIENT we expect, that this - // length will be fixed. - Assert.assertNotEquals(27600, xmpMetadataStreamLength); - - // 3090 is expected length of the stream after fix. - Assert.assertEquals(3090, xmpMetadataStreamLength); + // Initial length was 27600. 3090 is expected length of the stream after the fix + Assertions.assertEquals(3090, xmpMetadataStreamLength); + Assertions.assertEquals(3090, metadataBytes.length); } } } @Test - public void streamWithoutEndstreamKeywordConservativeModeTest() throws IOException, XMPException { + public void streamWithoutEndstreamKeywordConservativeModeTest() throws IOException { final String fileName = SOURCE_FOLDER + "NoEndstreamKeyword.pdf"; try (PdfReader reader = new PdfReader(fileName)) { reader.setStrictnessLevel(StrictnessLevel.CONSERVATIVE); - Exception exception = Assert.assertThrows(PdfException.class, () -> new PdfDocument(reader)); - Assert.assertEquals(KernelExceptionMessageConstant.STREAM_SHALL_END_WITH_ENDSTREAM, exception.getMessage()); + Exception exception = Assertions.assertThrows(PdfException.class, () -> new PdfDocument(reader)); + Assertions.assertEquals(KernelExceptionMessageConstant.STREAM_SHALL_END_WITH_ENDSTREAM, exception.getMessage()); PdfCatalog catalog = new PdfCatalog((PdfDictionary) reader.trailer.get(PdfName.Root, true)); PdfStream xmpMetadataStream = catalog.getPdfObject().getAsStream(PdfName.Metadata); // 27600 is actual invalid length of stream. In reader StrictnessLevel#CONSERVATIVE we expect, that // exception would be thrown and length wouldn't be fixed. - Assert.assertEquals(27600, ((PdfNumber) xmpMetadataStream.get(PdfName.Length)).intValue()); + Assertions.assertEquals(27600, ((PdfNumber) xmpMetadataStream.get(PdfName.Length)).intValue()); + } + } + + @Test + public void streamWithoutEndKeyConservativeModeWithWriterTest() throws IOException { + final String fileName = SOURCE_FOLDER + "NoEndstreamKeyword.pdf"; + try (PdfReader reader = new PdfReader(fileName)) { + reader.setStrictnessLevel(StrictnessLevel.CONSERVATIVE); + + Exception exception = Assertions.assertThrows(PdfException.class, () -> + new PdfDocument(reader, new PdfWriter(new ByteArrayOutputStream()))); + Assertions.assertEquals(KernelExceptionMessageConstant.STREAM_SHALL_END_WITH_ENDSTREAM, exception.getMessage()); } } @@ -2688,7 +2708,7 @@ public void tokensPositionIsNotUpdatedWhileReadingLengthTest() throws IOExceptio PdfStream pageContentStream = (PdfStream) pdfDoc.getPdfObject(5); // tokenizer's position after reading object should point to the end of the object's stream - Assert.assertEquals(pageContentStream.getOffset() + pageContentStream.getLength(), tokenizer.getPosition()); + Assertions.assertEquals(pageContentStream.getOffset() + pageContentStream.getLength(), tokenizer.getPosition()); // let's read next valid token and check that it means ending stream tokenizer.nextValidToken(); @@ -2697,7 +2717,7 @@ public void tokensPositionIsNotUpdatedWhileReadingLengthTest() throws IOExceptio } @Test - public void conformanceLevelCacheTest() throws IOException, XMPException { + public void conformanceCacheTest() throws IOException, XMPException { String filename = DESTINATION_FOLDER + "simpleDoc.pdf"; PdfDocument pdfDoc = new PdfDocument(CompareTool.createTestPdfWriter(filename)); @@ -2711,14 +2731,14 @@ public void conformanceLevelCacheTest() throws IOException, XMPException { TestPdfDocumentCache pdfTestDoc = new TestPdfDocumentCache(CompareTool.createOutputReader(filename)); for (int i = 0; i < 1000; ++i) { - pdfTestDoc.getReader().getPdfAConformanceLevel(); + pdfTestDoc.getReader().getPdfConformance(); } - Assert.assertEquals(2, pdfTestDoc.getCounter()); + Assertions.assertEquals(1, pdfTestDoc.getCounter()); } @Test @LogMessages(messages = @LogMessage(messageTemplate = - IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT, count = 1)) + IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT_WITH_CAUSE, count = 1)) public void invalidXrefTableRebuildsCorrectlyWhenTrailerIsBeforeObjects() throws IOException { // when a pdf is Linearized the following can occur: // xref table @@ -2741,9 +2761,9 @@ public void invalidXrefTableRebuildsCorrectlyWhenTrailerIsBeforeObjects() throws PdfDocument linearizedWithGoodXrefTable = new PdfDocument( new PdfReader(SOURCE_FOLDER + goodFilePath))) { - Assert.assertEquals(linearizedWithGoodXrefTable.getNumberOfPages(), + Assertions.assertEquals(linearizedWithGoodXrefTable.getNumberOfPages(), linearizedWithBadXrefTable.getNumberOfPages()); - Assert.assertEquals(linearizedWithGoodXrefTable.getOriginalDocumentId(), + Assertions.assertEquals(linearizedWithGoodXrefTable.getOriginalDocumentId(), linearizedWithBadXrefTable.getOriginalDocumentId()); PdfDictionary goodTrailer = linearizedWithGoodXrefTable.getTrailer(); @@ -2752,10 +2772,10 @@ public void invalidXrefTableRebuildsCorrectlyWhenTrailerIsBeforeObjects() throws // offsets // and there we take the last trailer but the good document takes the fist trailer because its // linearized - Assert.assertEquals(goodTrailer.size(), badTrailer.size()); - Assert.assertEquals(goodTrailer.get(PdfName.ID).toString(), badTrailer.get(PdfName.ID).toString()); - Assert.assertEquals(goodTrailer.get(PdfName.Info).toString(), badTrailer.get(PdfName.Info).toString()); - Assert.assertEquals(goodTrailer.get(PdfName.Root).toString(), badTrailer.get(PdfName.Root).toString()); + Assertions.assertEquals(goodTrailer.size(), badTrailer.size()); + Assertions.assertEquals(goodTrailer.get(PdfName.ID).toString(), badTrailer.get(PdfName.ID).toString()); + Assertions.assertEquals(goodTrailer.get(PdfName.Info).toString(), badTrailer.get(PdfName.Info).toString()); + Assertions.assertEquals(goodTrailer.get(PdfName.Root).toString(), badTrailer.get(PdfName.Root).toString()); } } @@ -2765,25 +2785,25 @@ public void newPdfReaderConstructorTest() throws IOException { PdfReader reader = new PdfReader(new File(filename), new ReaderProperties()); PdfDocument pdfDoc = new PdfDocument(reader); - Assert.assertEquals(author, pdfDoc.getDocumentInfo().getAuthor()); - Assert.assertEquals(creator, pdfDoc.getDocumentInfo().getCreator()); - Assert.assertEquals(title, pdfDoc.getDocumentInfo().getTitle()); + Assertions.assertEquals(author, pdfDoc.getDocumentInfo().getAuthor()); + Assertions.assertEquals(creator, pdfDoc.getDocumentInfo().getCreator()); + Assertions.assertEquals(title, pdfDoc.getDocumentInfo().getTitle()); PdfObject object = pdfDoc.getPdfObject(1); - Assert.assertEquals(PdfObject.DICTIONARY, object.getType()); - Assert.assertTrue(objectTypeEqualTo(object, PdfName.Catalog)); + Assertions.assertEquals(PdfObject.DICTIONARY, object.getType()); + Assertions.assertTrue(objectTypeEqualTo(object, PdfName.Catalog)); object = pdfDoc.getPdfObject(2); - Assert.assertEquals(PdfObject.DICTIONARY, object.getType()); - Assert.assertTrue(objectTypeEqualTo(object, PdfName.Pages)); + Assertions.assertEquals(PdfObject.DICTIONARY, object.getType()); + Assertions.assertTrue(objectTypeEqualTo(object, PdfName.Pages)); object = pdfDoc.getPdfObject(3); - Assert.assertEquals(PdfObject.DICTIONARY, object.getType()); + Assertions.assertEquals(PdfObject.DICTIONARY, object.getType()); object = pdfDoc.getPdfObject(4); - Assert.assertEquals(PdfObject.DICTIONARY, object.getType()); - Assert.assertTrue(objectTypeEqualTo(object, PdfName.Page)); + Assertions.assertEquals(PdfObject.DICTIONARY, object.getType()); + Assertions.assertTrue(objectTypeEqualTo(object, PdfName.Page)); - Assert.assertEquals(PdfObject.STREAM, pdfDoc.getPdfObject(5).getType()); + Assertions.assertEquals(PdfObject.STREAM, pdfDoc.getPdfObject(5).getType()); } @Test @@ -2793,25 +2813,25 @@ public void newPdfReaderConstructorPropertiesTest() throws IOException { .setPassword(USER_PASSWORD)); PdfDocument pdfDoc = new PdfDocument(reader); - Assert.assertEquals(author, pdfDoc.getDocumentInfo().getAuthor()); - Assert.assertEquals(creator, pdfDoc.getDocumentInfo().getCreator()); - Assert.assertEquals(title, pdfDoc.getDocumentInfo().getTitle()); + Assertions.assertEquals(author, pdfDoc.getDocumentInfo().getAuthor()); + Assertions.assertEquals(creator, pdfDoc.getDocumentInfo().getCreator()); + Assertions.assertEquals(title, pdfDoc.getDocumentInfo().getTitle()); PdfObject object = pdfDoc.getPdfObject(1); - Assert.assertEquals(PdfObject.DICTIONARY, object.getType()); - Assert.assertTrue(objectTypeEqualTo(object, PdfName.Catalog)); + Assertions.assertEquals(PdfObject.DICTIONARY, object.getType()); + Assertions.assertTrue(objectTypeEqualTo(object, PdfName.Catalog)); object = pdfDoc.getPdfObject(2); - Assert.assertEquals(PdfObject.DICTIONARY, object.getType()); - Assert.assertTrue(objectTypeEqualTo(object, PdfName.Pages)); + Assertions.assertEquals(PdfObject.DICTIONARY, object.getType()); + Assertions.assertTrue(objectTypeEqualTo(object, PdfName.Pages)); object = pdfDoc.getPdfObject(3); - Assert.assertEquals(PdfObject.DICTIONARY, object.getType()); + Assertions.assertEquals(PdfObject.DICTIONARY, object.getType()); object = pdfDoc.getPdfObject(4); - Assert.assertEquals(PdfObject.DICTIONARY, object.getType()); - Assert.assertTrue(objectTypeEqualTo(object, PdfName.Page)); + Assertions.assertEquals(PdfObject.DICTIONARY, object.getType()); + Assertions.assertTrue(objectTypeEqualTo(object, PdfName.Page)); - Assert.assertEquals(PdfObject.STREAM, pdfDoc.getPdfObject(5).getType()); + Assertions.assertEquals(PdfObject.STREAM, pdfDoc.getPdfObject(5).getType()); } @Test @@ -2839,8 +2859,8 @@ protected PdfObject readObject(PdfIndirectReference reference) { } }; - Exception e = Assert.assertThrows(PdfException.class, () -> new PdfDocument(pdfReader)); - Assert.assertEquals(MessageFormatUtil.format( + Exception e = Assertions.assertThrows(PdfException.class, () -> new PdfDocument(pdfReader)); + Assertions.assertEquals(MessageFormatUtil.format( KernelExceptionMessageConstant.INVALID_OBJECT_STREAM_NUMBER, 5, 4, 492), e.getMessage()); } @@ -2855,7 +2875,7 @@ public boolean isMemoryLimitsAwarenessRequiredOnDecompression(PdfArray filters) }; memoryLimitsAwareHandler.setMaxSizeOfDecompressedPdfStreamsSum(100000); - Assert.assertThrows(MemoryLimitsAwareException.class, () -> { + Assertions.assertThrows(MemoryLimitsAwareException.class, () -> { try (final PdfReader reader = new PdfReader(file, new ReaderProperties().setMemoryLimitsAwareHandler(memoryLimitsAwareHandler)); final PdfDocument document = new PdfDocument(reader);) { @@ -2863,6 +2883,50 @@ public boolean isMemoryLimitsAwarenessRequiredOnDecompression(PdfArray filters) }); } + @LogMessages(messages = @LogMessage(messageTemplate = + IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT_WITH_CAUSE)) + @Test + public void incorrectFilePositionInSubsectionCauseTest() throws IOException { + PdfReader pdfReader = new PdfReader(SOURCE_FOLDER + "incorrectFilePositionInSubsection.pdf").setStrictnessLevel(StrictnessLevel.LENIENT); + new PdfDocument(pdfReader); + Assertions.assertTrue(pdfReader.hasRebuiltXref(), "Need rebuildXref()"); + } + + @LogMessages(messages = @LogMessage(messageTemplate = + IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT_WITH_CAUSE)) + @Test + public void noSubsectionCauseTest() throws IOException { + PdfReader pdfReader = new PdfReader(SOURCE_FOLDER + "noSubsection.pdf").setStrictnessLevel(StrictnessLevel.LENIENT); + new PdfDocument(pdfReader); + Assertions.assertTrue(pdfReader.hasRebuiltXref(), "Need rebuildXref()"); + } + + @LogMessages(messages = @LogMessage(messageTemplate = + IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT_WITH_CAUSE)) + @Test + public void invalidRefCauseXrefRebuildTest() throws IOException { + PdfReader pdfReader = new PdfReader(SOURCE_FOLDER + "invalidRefCauseXrefRebuild.pdf").setStrictnessLevel(StrictnessLevel.LENIENT); + new PdfDocument(pdfReader); + Assertions.assertTrue(pdfReader.hasRebuiltXref(), "Need rebuildXref()"); + } + + @LogMessages(messages = @LogMessage(messageTemplate = + IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT_WITH_CAUSE)) + @Test + public void startxrefNotFoundCauseTest() throws IOException { + PdfReader pdfReader = new PdfReader(SOURCE_FOLDER + "startxrefNotFound.pdf").setStrictnessLevel(StrictnessLevel.LENIENT); + new PdfDocument(pdfReader); + Assertions.assertTrue(pdfReader.hasRebuiltXref(), "Need rebuildXref()"); + } + + @Test + public void readAandUaDocumentTest() throws IOException { + try (PdfDocument pdfDoc = new PdfDocument(new PdfReader(SOURCE_FOLDER + "bothAandUa.pdf"))) { + Assertions.assertEquals(PdfAConformance.PDF_A_2B, pdfDoc.getConformance().getAConformance()); + Assertions.assertEquals(PdfUAConformance.PDF_UA_1, pdfDoc.getConformance().getUAConformance()); + } + } + private static PdfDictionary getTestPdfDictionary() { HashMap tmpMap = new HashMap(); tmpMap.put(new PdfName("b"), new PdfName("c")); @@ -2886,9 +2950,9 @@ public TestPdfDocumentCache(PdfReader pdfReader) { } @Override - public byte[] getXmpMetadata(boolean createNew) { + public byte[] getXmpMetadataBytes(boolean createdNew) { ++getXmpMetadataCounter; - return super.getXmpMetadata(createNew); + return super.getXmpMetadataBytes(createdNew); } public int getCounter() { diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfReaderUnitTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfReaderUnitTest.java index 2032476e5e..c64805888b 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfReaderUnitTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfReaderUnitTest.java @@ -26,12 +26,11 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.exceptions.KernelExceptionMessageConstant; import com.itextpdf.kernel.exceptions.PdfException; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfReaderUnitTest extends ExtendedITextTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/kernel/pdf/PdfReaderUnitTest/"; @@ -39,15 +38,15 @@ public class PdfReaderUnitTest extends ExtendedITextTest { @Test public void readStreamBytesRawNullStreamTest() throws java.io.IOException { PdfReader reader = new PdfReader(SOURCE_FOLDER + "testFile.pdf"); - Exception e = Assert.assertThrows(PdfException.class, () -> reader.readStreamBytesRaw(null)); - Assert.assertEquals(KernelExceptionMessageConstant.UNABLE_TO_READ_STREAM_BYTES, e.getMessage()); + Exception e = Assertions.assertThrows(PdfException.class, () -> reader.readStreamBytesRaw(null)); + Assertions.assertEquals(KernelExceptionMessageConstant.UNABLE_TO_READ_STREAM_BYTES, e.getMessage()); } @Test public void readObjectStreamNullStreamTest() throws java.io.IOException { PdfReader reader = new PdfReader(SOURCE_FOLDER + "testFile.pdf"); - Exception e = Assert.assertThrows(PdfException.class, () -> reader.readObjectStream(null)); - Assert.assertEquals(KernelExceptionMessageConstant.UNABLE_TO_READ_OBJECT_STREAM, e.getMessage()); + Exception e = Assertions.assertThrows(PdfException.class, () -> reader.readObjectStream(null)); + Assertions.assertEquals(KernelExceptionMessageConstant.UNABLE_TO_READ_OBJECT_STREAM, e.getMessage()); } @Test @@ -66,8 +65,8 @@ public void readObjectInvalidObjectStreamNumberTest() throws java.io.IOException doc.getXref().add(ref2); doc.getCatalog().getPdfObject().put(PdfName.StructTreeRoot, ref); - Exception e = Assert.assertThrows(PdfException.class, () -> reader.readObject(ref)); - Assert.assertEquals(MessageFormatUtil.format( + Exception e = Assertions.assertThrows(PdfException.class, () -> reader.readObject(ref)); + Assertions.assertEquals(MessageFormatUtil.format( KernelExceptionMessageConstant.INVALID_OBJECT_STREAM_NUMBER, 20, 5, 0), e.getMessage()); } } \ No newline at end of file diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfResourcesTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfResourcesTest.java index 568bd368d4..2f8eaf898f 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfResourcesTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfResourcesTest.java @@ -24,18 +24,17 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.extgstate.PdfExtGState; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.util.Set; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfResourcesTest extends ExtendedITextTest { @Test public void resourcesTest1() { @@ -46,11 +45,11 @@ public void resourcesTest1() { PdfExtGState egs2 = new PdfExtGState(); PdfResources resources = page.getResources(); PdfName n1 = resources.addExtGState(egs1); - Assert.assertEquals("Gs1", n1.getValue()); + Assertions.assertEquals("Gs1", n1.getValue()); PdfName n2 = resources.addExtGState(egs2); - Assert.assertEquals("Gs2", n2.getValue()); + Assertions.assertEquals("Gs2", n2.getValue()); n1 = resources.addExtGState(egs1); - Assert.assertEquals("Gs1", n1.getValue()); + Assertions.assertEquals("Gs1", n1.getValue()); document.close(); } @@ -72,27 +71,27 @@ public void resourcesTest2() throws Exception { page = document.getPage(1); resources = page.getResources(); Set names = resources.getResourceNames(); - Assert.assertEquals(2, names.size()); + Assertions.assertEquals(2, names.size()); String[] expectedNames = { "Gs1", "Gs2"}; int i = 0; for (PdfName name : names) { - Assert.assertEquals(expectedNames[i++], name.getValue()); + Assertions.assertEquals(expectedNames[i++], name.getValue()); } PdfExtGState egs3 = new PdfExtGState(); PdfName n3 = resources.addExtGState(egs3); - Assert.assertEquals("Gs3", n3.getValue()); + Assertions.assertEquals("Gs3", n3.getValue()); PdfDictionary egsResources = page.getPdfObject().getAsDictionary(PdfName.Resources).getAsDictionary(PdfName.ExtGState); PdfDictionary e1 = egsResources.getAsDictionary(new PdfName("Gs1")); PdfName n1 = resources.addExtGState(e1); - Assert.assertEquals("Gs1", n1.getValue()); + Assertions.assertEquals("Gs1", n1.getValue()); PdfDictionary e2 = egsResources.getAsDictionary(new PdfName("Gs2")); PdfName n2 = resources.addExtGState(e2); - Assert.assertEquals("Gs2", n2.getValue()); + Assertions.assertEquals("Gs2", n2.getValue()); PdfDictionary e4 = (PdfDictionary) e2.clone(); PdfName n4 = resources.addExtGState(e4); - Assert.assertEquals("Gs4", n4.getValue()); + Assertions.assertEquals("Gs4", n4.getValue()); document.close(); } @@ -103,9 +102,9 @@ public void getNonExistentResourcesCategory() { // Assert returned value is properly functioning PdfName randomResName = new PdfName("NonExistentResourceName"); - Assert.assertFalse(unknownResCategory.contains(randomResName)); - Assert.assertFalse(unknownResCategory.remove(randomResName)); - Assert.assertTrue(unknownResCategory.isEmpty()); + Assertions.assertFalse(unknownResCategory.contains(randomResName)); + Assertions.assertFalse(unknownResCategory.remove(randomResName)); + Assertions.assertTrue(unknownResCategory.isEmpty()); } @Test @@ -117,9 +116,9 @@ public void resourcesCategoryDictionarySetModifiedTest() { PdfObject resourceCategoryDict = resources.getPdfObject().get(PdfName.ExtGState); resourceCategoryDict.setIndirectReference(new PdfIndirectReference(null, 1)); - Assert.assertFalse(resourceCategoryDict.isModified()); + Assertions.assertFalse(resourceCategoryDict.isModified()); resources.addExtGState(new PdfExtGState()); // Check that when changing an existing resource category dictionary, the flag PdfObject.MODIFIED will be set for it - Assert.assertTrue(resourceCategoryDict.isModified()); + Assertions.assertTrue(resourceCategoryDict.isModified()); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfRevisionsReaderTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfRevisionsReaderTest.java index 97e92450b7..722969df92 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfRevisionsReaderTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfRevisionsReaderTest.java @@ -23,15 +23,14 @@ This file is part of the iText (R) project. package com.itextpdf.kernel.pdf; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.IOException; import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfRevisionsReaderTest extends ExtendedITextTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/kernel/pdf/PdfRevisionsReaderTest/"; @@ -43,11 +42,11 @@ public void singleRevisionDocumentTest() throws IOException { PdfRevisionsReader revisionsReader = new PdfRevisionsReader(reader); List documentRevisions = revisionsReader.getAllRevisions(); - Assert.assertEquals(1, documentRevisions.size()); + Assertions.assertEquals(1, documentRevisions.size()); DocumentRevision firstRevision = documentRevisions.get(0); assertResultingRevision(firstRevision, 1, 2, 3, 4, 5, 6); - Assert.assertEquals(929, firstRevision.getEofOffset()); + Assertions.assertEquals(929, firstRevision.getEofOffset()); } } @@ -59,11 +58,11 @@ public void singleRevisionWithXrefStreamTest() throws IOException { PdfRevisionsReader revisionsReader = new PdfRevisionsReader(reader); List documentRevisions = revisionsReader.getAllRevisions(); - Assert.assertEquals(1, documentRevisions.size()); + Assertions.assertEquals(1, documentRevisions.size()); DocumentRevision firstRevision = documentRevisions.get(0); assertResultingRevision(firstRevision, 1, 2, 3, 4, 5, 6, 7, 8); - Assert.assertEquals(1085, firstRevision.getEofOffset()); + Assertions.assertEquals(1085, firstRevision.getEofOffset()); } } @@ -75,19 +74,19 @@ public void multipleRevisionsDocument() throws IOException { PdfRevisionsReader revisionsReader = new PdfRevisionsReader(reader); List documentRevisions = revisionsReader.getAllRevisions(); - Assert.assertEquals(3, documentRevisions.size()); + Assertions.assertEquals(3, documentRevisions.size()); DocumentRevision firstRevision = documentRevisions.get(0); assertResultingRevision(firstRevision, 1, 2, 3, 4, 5, 6); - Assert.assertEquals(929, firstRevision.getEofOffset()); + Assertions.assertEquals(930, firstRevision.getEofOffset()); DocumentRevision secondRevision = documentRevisions.get(1); assertResultingRevision(secondRevision, 1, 3, 4, 7, 8, 9, 10, 11, 12, 13, 14, 15); - Assert.assertEquals(28119, secondRevision.getEofOffset()); + Assertions.assertEquals(28120, secondRevision.getEofOffset()); DocumentRevision thirdRevision = documentRevisions.get(2); assertResultingRevision(thirdRevision, 1, 3, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28); - Assert.assertEquals(36207, thirdRevision.getEofOffset()); + Assertions.assertEquals(36207, thirdRevision.getEofOffset()); } } @@ -99,28 +98,28 @@ public void freeReferencesDocument() throws IOException { PdfRevisionsReader revisionsReader = new PdfRevisionsReader(reader); List documentRevisions = revisionsReader.getAllRevisions(); - Assert.assertEquals(5, documentRevisions.size()); + Assertions.assertEquals(5, documentRevisions.size()); DocumentRevision firstRevision = documentRevisions.get(0); assertResultingRevision(firstRevision, 1, 2, 3, 4, 5, 6); - Assert.assertEquals(929, firstRevision.getEofOffset()); + Assertions.assertEquals(930, firstRevision.getEofOffset()); DocumentRevision secondRevision = documentRevisions.get(1); assertResultingRevision(secondRevision, 1, 3, 4, 7, 8, 9, 10, 11, 12, 13, 14, 15); - Assert.assertEquals(28119, secondRevision.getEofOffset()); + Assertions.assertEquals(28120, secondRevision.getEofOffset()); DocumentRevision thirdRevision = documentRevisions.get(2); assertResultingRevision(thirdRevision, 1, 3, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28); - Assert.assertEquals(36207, thirdRevision.getEofOffset()); + Assertions.assertEquals(36208, thirdRevision.getEofOffset()); DocumentRevision fourthRevision = documentRevisions.get(3); assertResultingRevision(fourthRevision, new int[] {1, 3, 23, 24}, new int[] {0, 0, 1, 1}); - Assert.assertEquals(37006, fourthRevision.getEofOffset()); + Assertions.assertEquals(37007, fourthRevision.getEofOffset()); DocumentRevision fifthRevision = documentRevisions.get(4); assertResultingRevision(fifthRevision, new int[] {1, 3, 19, 20, 21, 22, 23, 25}, new int[] {0, 0, 1, 1, 1, 1, 1, 1}); - Assert.assertEquals(38094, fifthRevision.getEofOffset()); + Assertions.assertEquals(38094, fifthRevision.getEofOffset()); } } @@ -132,19 +131,19 @@ public void multipleRevisionsWithXrefStreamTest() throws IOException { PdfRevisionsReader revisionsReader = new PdfRevisionsReader(reader); List documentRevisions = revisionsReader.getAllRevisions(); - Assert.assertEquals(3, documentRevisions.size()); + Assertions.assertEquals(3, documentRevisions.size()); DocumentRevision firstRevision = documentRevisions.get(0); assertResultingRevision(firstRevision, 1, 2, 3, 4, 5, 6, 7, 8); - Assert.assertEquals(1085, firstRevision.getEofOffset()); + Assertions.assertEquals(1086, firstRevision.getEofOffset()); DocumentRevision secondRevision = documentRevisions.get(1); assertResultingRevision(secondRevision, 1, 3, 4, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19); - Assert.assertEquals(28137, secondRevision.getEofOffset()); + Assertions.assertEquals(28138, secondRevision.getEofOffset()); DocumentRevision thirdRevision = documentRevisions.get(2); assertResultingRevision(thirdRevision, 1, 3, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34); - Assert.assertEquals(36059, thirdRevision.getEofOffset()); + Assertions.assertEquals(36059, thirdRevision.getEofOffset()); } } @@ -156,28 +155,28 @@ public void freeReferencesWithXrefStream() throws IOException { PdfRevisionsReader revisionsReader = new PdfRevisionsReader(reader); List documentRevisions = revisionsReader.getAllRevisions(); - Assert.assertEquals(5, documentRevisions.size()); + Assertions.assertEquals(5, documentRevisions.size()); DocumentRevision firstRevision = documentRevisions.get(0); assertResultingRevision(firstRevision, 1, 2, 3, 4, 5, 6, 7, 8); - Assert.assertEquals(1085, firstRevision.getEofOffset()); + Assertions.assertEquals(1086, firstRevision.getEofOffset()); DocumentRevision secondRevision = documentRevisions.get(1); assertResultingRevision(secondRevision, 1, 3, 4, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19); - Assert.assertEquals(28137, secondRevision.getEofOffset()); + Assertions.assertEquals(28138, secondRevision.getEofOffset()); DocumentRevision thirdRevision = documentRevisions.get(2); assertResultingRevision(thirdRevision, 1, 3, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34); - Assert.assertEquals(36059, thirdRevision.getEofOffset()); + Assertions.assertEquals(36060, thirdRevision.getEofOffset()); DocumentRevision fourthRevision = documentRevisions.get(3); assertResultingRevision(fourthRevision, new int[] {1, 3, 27, 28, 35}, new int[] {0, 0, 1, 1, 0}); - Assert.assertEquals(36975, fourthRevision.getEofOffset()); + Assertions.assertEquals(36976, fourthRevision.getEofOffset()); DocumentRevision fifthRevision = documentRevisions.get(4); assertResultingRevision(fifthRevision, new int[] {1, 3, 23, 24, 25, 26, 27, 29, 36}, new int[] {0, 0, 1, 1, 1, 1, 1, 1, 0}); - Assert.assertEquals(38111, fifthRevision.getEofOffset()); + Assertions.assertEquals(38111, fifthRevision.getEofOffset()); } } @@ -189,21 +188,21 @@ public void documentWithStreamAndTableXref() throws IOException { PdfRevisionsReader revisionsReader = new PdfRevisionsReader(reader); List documentRevisions = revisionsReader.getAllRevisions(); - Assert.assertEquals(3, documentRevisions.size()); + Assertions.assertEquals(3, documentRevisions.size()); DocumentRevision thirdRevision = revisionsReader.getAllRevisions().get(0); // xref was broken in this revision and fixed in the next one assertResultingRevision(thirdRevision, new int[] {1, 2, 3, 4, 5, 6, 7, 8, 9}, new int[] {0, 0, 0, 0, 0, 0, 65535, 0, 0}); - Assert.assertEquals(1381, thirdRevision.getEofOffset()); + Assertions.assertEquals(1381, thirdRevision.getEofOffset()); DocumentRevision secondRevision = revisionsReader.getAllRevisions().get(1); assertResultingRevision(secondRevision, 1, 2, 3, 4, 5, 6, 7, 8); - Assert.assertEquals(1381, secondRevision.getEofOffset()); + Assertions.assertEquals(1381, secondRevision.getEofOffset()); DocumentRevision firstRevision = revisionsReader.getAllRevisions().get(2); assertResultingRevision(firstRevision); - Assert.assertEquals(1550, firstRevision.getEofOffset()); + Assertions.assertEquals(1550, firstRevision.getEofOffset()); } } @@ -212,15 +211,15 @@ private void assertResultingRevision(DocumentRevision documentRevision, int... o } private void assertResultingRevision(DocumentRevision documentRevision, int[] objNumbers, int[] objGens) { - Assert.assertEquals(objNumbers.length, objGens.length); - Assert.assertEquals(objNumbers.length + 1, documentRevision.getModifiedObjects().size()); + Assertions.assertEquals(objNumbers.length, objGens.length); + Assertions.assertEquals(objNumbers.length + 1, documentRevision.getModifiedObjects().size()); for (int i = 0; i < objNumbers.length; ++i) { int objNumber = objNumbers[i]; int objGen = objGens[i]; - Assert.assertTrue(documentRevision.getModifiedObjects().stream().anyMatch( + Assertions.assertTrue(documentRevision.getModifiedObjects().stream().anyMatch( reference -> reference.getObjNumber() == objNumber && reference.getGenNumber() == objGen)); } - Assert.assertTrue(documentRevision.getModifiedObjects().stream().anyMatch( + Assertions.assertTrue(documentRevision.getModifiedObjects().stream().anyMatch( reference -> reference.getObjNumber() == 0 && reference.getGenNumber() == 65535 && reference.isFree())); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfStampingTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfStampingTest.java index 7de3bcdf3c..ca90c1ef91 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfStampingTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfStampingTest.java @@ -25,9 +25,9 @@ This file is part of the iText (R) project. import com.itextpdf.commons.utils.DateTimeUtil; import com.itextpdf.io.source.ByteArrayOutputStream; import com.itextpdf.io.source.ByteUtils; -import com.itextpdf.kernel.events.Event; -import com.itextpdf.kernel.events.IEventHandler; -import com.itextpdf.kernel.events.PdfDocumentEvent; +import com.itextpdf.kernel.pdf.event.AbstractPdfDocumentEventHandler; +import com.itextpdf.kernel.pdf.event.AbstractPdfDocumentEvent; +import com.itextpdf.kernel.pdf.event.PdfDocumentEvent; import com.itextpdf.kernel.font.PdfFont; import com.itextpdf.kernel.font.PdfFontFactory; import com.itextpdf.kernel.logs.KernelLogMessageConstant; @@ -36,39 +36,38 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.canvas.parser.listener.LocationTextExtractionStrategy; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.kernel.xmp.XMPException; -import com.itextpdf.kernel.xmp.XMPMetaFactory; import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.ByteArrayInputStream; import java.io.File; import java.io.IOException; import java.util.Calendar; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -@Category(IntegrationTest.class) + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +@Tag("IntegrationTest") public class PdfStampingTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/kernel/pdf/PdfStampingTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/kernel/pdf/PdfStampingTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(destinationFolder); } @@ -98,14 +97,14 @@ public void stamping1() throws IOException { for (int i = 0; i < pdfDoc3.getNumberOfPages(); i++) { pdfDoc3.getPage(i + 1); } - assertEquals("Rebuilt", false, reader3.hasRebuiltXref()); - assertEquals("Fixed", false, reader3.hasFixedXref()); + assertFalse(reader3.hasRebuiltXref(), "Rebuilt"); + assertFalse(reader3.hasFixedXref(), "Fixed"); verifyPdfPagesCount(pdfDoc3.getCatalog().getPageTree().getRoot().getPdfObject()); pdfDoc3.close(); PdfReader reader = CompareTool.createOutputReader(destinationFolder + "stamping1_2.pdf"); PdfDocument document = new PdfDocument(reader); - assertEquals("Rebuilt", false, reader.hasRebuiltXref()); + assertFalse(reader.hasRebuiltXref(), "Rebuilt"); PdfDictionary trailer = document.getTrailer(); PdfDictionary info = trailer.getAsDictionary(PdfName.Info); PdfString creator = info.getAsString(PdfName.Creator); @@ -116,7 +115,7 @@ public void stamping1() throws IOException { Calendar cl = PdfDate.decode(date); double diff = DateTimeUtil.getUtcMillisFromEpoch(null) - DateTimeUtil.getUtcMillisFromEpoch(cl); String message = "Unexpected creation date. Different from now is " + (float) diff / 1000 + "s"; - assertTrue(message, diff < 5000); + assertTrue(diff < 5000, message); document.close(); } @@ -144,14 +143,14 @@ public void stamping2() throws IOException { for (int i = 0; i < pdfDoc3.getNumberOfPages(); i++) { pdfDoc3.getPage(i + 1); } - assertEquals("Rebuilt", false, reader3.hasRebuiltXref()); - assertEquals("Fixed", false, reader3.hasFixedXref()); + assertFalse(reader3.hasRebuiltXref(), "Rebuilt"); + assertFalse(reader3.hasFixedXref(), "Fixed"); verifyPdfPagesCount(pdfDoc3.getCatalog().getPageTree().getRoot().getPdfObject()); pdfDoc3.close(); PdfReader reader = CompareTool.createOutputReader(destinationFolder + "stamping2_2.pdf"); PdfDocument pdfDocument = new PdfDocument(reader); - assertEquals("Rebuilt", false, reader.hasRebuiltXref()); + assertFalse(reader.hasRebuiltXref(), "Rebuilt"); byte[] bytes = pdfDocument.getPage(1).getContentBytes(); assertEquals("%page 1\n", new String(bytes)); bytes = pdfDocument.getPage(2).getContentBytes(); @@ -184,14 +183,14 @@ public void stamping3() throws IOException { for (int i = 0; i < pdfDoc3.getNumberOfPages(); i++) { pdfDoc3.getPage(i + 1); } - assertEquals("Rebuilt", false, reader3.hasRebuiltXref()); - assertEquals("Fixed", false, reader3.hasFixedXref()); + assertFalse(reader3.hasRebuiltXref(), "Rebuilt"); + assertFalse(reader3.hasFixedXref(), "Fixed"); verifyPdfPagesCount(pdfDoc3.getCatalog().getPageTree().getRoot().getPdfObject()); pdfDoc3.close(); PdfReader reader = CompareTool.createOutputReader(filename2); PdfDocument pdfDocument = new PdfDocument(reader); - assertEquals("Rebuilt", false, reader.hasRebuiltXref()); + assertFalse(reader.hasRebuiltXref(), "Rebuilt"); byte[] bytes = pdfDocument.getPage(1).getContentBytes(); assertEquals("%page 1\n", new String(bytes)); bytes = pdfDocument.getPage(2).getContentBytes(); @@ -224,15 +223,15 @@ public void stamping4() throws IOException { for (int i = 0; i < pdfDoc3.getNumberOfPages(); i++) { pdfDoc3.getPage(i + 1); } - assertEquals("Rebuilt", false, reader3.hasRebuiltXref()); - assertEquals("Fixed", false, reader3.hasFixedXref()); + assertFalse(reader3.hasRebuiltXref(), "Rebuilt"); + assertFalse(reader3.hasFixedXref(), "Fixed"); verifyPdfPagesCount(pdfDoc3.getCatalog().getPageTree().getRoot().getPdfObject()); pdfDoc3.close(); PdfReader reader = CompareTool.createOutputReader(filename2); PdfDocument pdfDocument = new PdfDocument(reader); - assertEquals("Rebuilt", false, reader.hasRebuiltXref()); - assertEquals("Page count", pageCount, pdfDocument.getNumberOfPages()); + assertFalse(reader.hasRebuiltXref(), "Rebuilt"); + assertEquals(pageCount, pdfDocument.getNumberOfPages(), "Page count"); for (int i = 1; i < pdfDocument.getNumberOfPages(); i++) { byte[] bytes = pdfDocument.getPage(i).getContentBytes(); assertEquals("%page " + i + "\n", new String(bytes)); @@ -267,15 +266,15 @@ public void stamping5() throws IOException { for (int i = 0; i < pdfDoc3.getNumberOfPages(); i++) { pdfDoc3.getPage(i + 1); } - assertEquals("Rebuilt", false, reader3.hasRebuiltXref()); - assertEquals("Fixed", false, reader3.hasFixedXref()); + assertFalse(reader3.hasRebuiltXref(), "Rebuilt"); + assertFalse(reader3.hasFixedXref(), "Fixed"); verifyPdfPagesCount(pdfDoc3.getCatalog().getPageTree().getRoot().getPdfObject()); pdfDoc3.close(); PdfReader reader = CompareTool.createOutputReader(filename2); PdfDocument pdfDocument = new PdfDocument(reader); - assertEquals("Rebuilt", false, reader.hasRebuiltXref()); - assertEquals("Page count", pageCount, pdfDocument.getNumberOfPages()); + assertFalse(reader.hasRebuiltXref(), "Rebuilt"); + assertEquals(pageCount, pdfDocument.getNumberOfPages(), "Page count"); for (int i = 1; i < pdfDocument.getNumberOfPages(); i++) { byte[] bytes = pdfDocument.getPage(i).getContentBytes(); assertEquals("%page " + i + "\n", new String(bytes)); @@ -305,14 +304,14 @@ public void stamping6() throws IOException { for (int i = 0; i < pdfDoc3.getNumberOfPages(); i++) { pdfDoc3.getPage(i + 1); } - assertEquals("Rebuilt", false, reader3.hasRebuiltXref()); - assertEquals("Fixed", false, reader3.hasFixedXref()); + assertFalse(reader3.hasRebuiltXref(), "Rebuilt"); + assertFalse(reader3.hasFixedXref(), "Fixed"); verifyPdfPagesCount(pdfDoc3.getCatalog().getPageTree().getRoot().getPdfObject()); pdfDoc3.close(); PdfReader reader = CompareTool.createOutputReader(filename2); PdfDocument pdfDocument = new PdfDocument(reader); - assertEquals("Rebuilt", false, reader.hasRebuiltXref()); + assertFalse(reader.hasRebuiltXref(), "Rebuilt"); byte[] bytes = pdfDocument.getPage(1).getContentBytes(); assertEquals("%page 1\n", new String(bytes)); bytes = pdfDocument.getPage(2).getContentBytes(); @@ -344,14 +343,14 @@ public void stamping7() throws IOException { for (int i = 0; i < pdfDoc3.getNumberOfPages(); i++) { pdfDoc3.getPage(i + 1); } - assertEquals("Rebuilt", false, reader3.hasRebuiltXref()); - assertEquals("Fixed", false, reader3.hasFixedXref()); + assertFalse(reader3.hasRebuiltXref(), "Rebuilt"); + assertFalse(reader3.hasFixedXref(), "Fixed"); verifyPdfPagesCount(pdfDoc3.getCatalog().getPageTree().getRoot().getPdfObject()); pdfDoc3.close(); PdfReader reader = CompareTool.createOutputReader(filename2); PdfDocument pdfDocument = new PdfDocument(reader); - assertEquals("Rebuilt", false, reader.hasRebuiltXref()); + assertFalse(reader.hasRebuiltXref(), "Rebuilt"); byte[] bytes = pdfDocument.getPage(1).getContentBytes(); assertEquals("%page 1\n", new String(bytes)); bytes = pdfDocument.getPage(2).getContentBytes(); @@ -384,18 +383,18 @@ public void stamping8() throws IOException { for (int i = 0; i < pdfDoc3.getNumberOfPages(); i++) { pdfDoc3.getPage(i + 1); } - assertEquals("Number of pages", pageCount, pdfDoc3.getNumberOfPages()); - assertEquals("Rebuilt", false, reader3.hasRebuiltXref()); - assertEquals("Fixed", false, reader3.hasFixedXref()); + assertEquals(pageCount, pdfDoc3.getNumberOfPages(), "Number of pages"); + assertFalse(reader3.hasRebuiltXref(), "Rebuilt"); + assertFalse(reader3.hasFixedXref(), "Fixed"); verifyPdfPagesCount(pdfDoc3.getCatalog().getPageTree().getRoot().getPdfObject()); pdfDoc3.close(); PdfReader reader = CompareTool.createOutputReader(filename2); PdfDocument pdfDocument = new PdfDocument(reader); - assertEquals("Rebuilt", false, reader.hasRebuiltXref()); + assertFalse(reader.hasRebuiltXref(), "Rebuilt"); for (int i = 1; i <= pageCount; i++) { byte[] bytes = pdfDocument.getPage(i).getContentBytes(); - assertEquals("Page content at page " + i, "%page " + i + "\n", new String(bytes)); + assertEquals("%page " + i + "\n", new String(bytes), "Page content at page " + i); } pdfDocument.close(); } @@ -425,18 +424,18 @@ public void stamping9() throws IOException { for (int i = 0; i < pdfDoc3.getNumberOfPages(); i++) { pdfDoc3.getPage(i + 1); } - assertEquals("Number of pages", pageCount, pdfDoc3.getNumberOfPages()); - assertEquals("Rebuilt", false, reader3.hasRebuiltXref()); - assertEquals("Fixed", false, reader3.hasFixedXref()); + assertEquals(pageCount, pdfDoc3.getNumberOfPages(), "Number of pages"); + assertFalse(reader3.hasRebuiltXref(), "Rebuilt"); + assertFalse(reader3.hasFixedXref(), "Fixed"); verifyPdfPagesCount(pdfDoc3.getCatalog().getPageTree().getRoot().getPdfObject()); pdfDoc3.close(); PdfReader reader = CompareTool.createOutputReader(filename2); PdfDocument pdfDocument = new PdfDocument(reader); - assertEquals("Rebuilt", false, reader.hasRebuiltXref()); + assertFalse(reader.hasRebuiltXref(), "Rebuilt"); for (int i = 1; i <= pageCount; i++) { byte[] bytes = pdfDocument.getPage(i).getContentBytes(); - assertEquals("Page content at page " + i, "%page " + i + "\n", new String(bytes)); + assertEquals("%page " + i + "\n", new String(bytes), "Page content at page " + i); } pdfDocument.close(); } @@ -466,18 +465,18 @@ public void stamping10() throws IOException { for (int i = 0; i < pdfDoc3.getNumberOfPages(); i++) { pdfDoc3.getPage(i + 1); } - assertEquals("Number of pages", pageCount, pdfDoc3.getNumberOfPages()); - assertEquals("Rebuilt", false, reader3.hasRebuiltXref()); - assertEquals("Fixed", false, reader3.hasFixedXref()); + assertEquals(pageCount, pdfDoc3.getNumberOfPages(), "Number of pages"); + assertFalse(reader3.hasRebuiltXref(), "Rebuilt"); + assertFalse(reader3.hasFixedXref(), "Fixed"); verifyPdfPagesCount(pdfDoc3.getCatalog().getPageTree().getRoot().getPdfObject()); pdfDoc3.close(); PdfReader reader = CompareTool.createOutputReader(filename2); PdfDocument pdfDocument = new PdfDocument(reader); - assertEquals("Rebuilt", false, reader.hasRebuiltXref()); + assertFalse(reader.hasRebuiltXref(), "Rebuilt"); for (int i = 1; i <= pageCount; i++) { byte[] bytes = pdfDocument.getPage(i).getContentBytes(); - assertEquals("Page content at page " + i, "%page " + i + "\n", new String(bytes)); + assertEquals("%page " + i + "\n", new String(bytes), "Page content at page " + i); } pdfDocument.close(); } @@ -507,18 +506,18 @@ public void stamping11() throws IOException { for (int i = 0; i < pdfDoc3.getNumberOfPages(); i++) { pdfDoc3.getPage(i + 1); } - assertEquals("Number of pages", pageCount, pdfDoc3.getNumberOfPages()); - assertEquals("Rebuilt", false, reader3.hasRebuiltXref()); - assertEquals("Fixed", false, reader3.hasFixedXref()); + assertEquals(pageCount, pdfDoc3.getNumberOfPages(), "Number of pages"); + assertFalse(reader3.hasRebuiltXref(), "Rebuilt"); + assertFalse(reader3.hasFixedXref(), "Fixed"); verifyPdfPagesCount(pdfDoc3.getCatalog().getPageTree().getRoot().getPdfObject()); pdfDoc3.close(); PdfReader reader = CompareTool.createOutputReader(filename2); PdfDocument pdfDocument = new PdfDocument(reader); - assertEquals("Rebuilt", false, reader.hasRebuiltXref()); + assertFalse(reader.hasRebuiltXref(), "Rebuilt"); for (int i = 1; i <= pageCount; i++) { byte[] bytes = pdfDocument.getPage(i).getContentBytes(); - assertEquals("Page content at page " + i, "%page " + i + "\n", new String(bytes)); + assertEquals("%page " + i + "\n", new String(bytes), "Page content at page " + i); } pdfDocument.close(); } @@ -552,19 +551,19 @@ public void stamping12() throws IOException { } PdfPage pdfPage = pdfDoc3.getPage(1); PdfDictionary root = pdfPage.getPdfObject().getAsDictionary(PdfName.Parent); - assertEquals("PdfPages kids count", newPageCount, root.getAsArray(PdfName.Kids).size()); - assertEquals("Number of pages", newPageCount, pdfDoc3.getNumberOfPages()); - assertEquals("Rebuilt", false, reader3.hasRebuiltXref()); - assertEquals("Fixed", false, reader3.hasFixedXref()); + assertEquals(newPageCount, root.getAsArray(PdfName.Kids).size(), "PdfPages kids count"); + assertEquals(newPageCount, pdfDoc3.getNumberOfPages(), "Number of pages"); + assertFalse(reader3.hasRebuiltXref(), "Rebuilt"); + assertFalse(reader3.hasFixedXref(), "Fixed"); verifyPdfPagesCount(pdfDoc3.getCatalog().getPageTree().getRoot().getPdfObject()); pdfDoc3.close(); PdfReader reader = CompareTool.createOutputReader(filename2); PdfDocument pdfDocument = new PdfDocument(reader); - assertEquals("Rebuilt", false, reader.hasRebuiltXref()); + assertFalse(reader.hasRebuiltXref(), "Rebuilt"); for (int i = 1; i <= pdfDocument.getNumberOfPages(); i++) { byte[] bytes = pdfDocument.getPage(i).getContentBytes(); - assertEquals("Page content at page " + i, "%page " + i + "\n", new String(bytes)); + assertEquals("%page " + i + "\n", new String(bytes), "Page content at page " + i); } pdfDocument.close(); } @@ -602,19 +601,19 @@ public void stamping13() throws IOException { pdfDoc3.getPage(i); } PdfArray rootKids = pdfDoc3.getCatalog().getPageTree().getRoot().getPdfObject().getAsArray(PdfName.Kids); - assertEquals("Page root kids count", 2, rootKids.size()); - assertEquals("Number of pages", pageCount, pdfDoc3.getNumberOfPages()); - assertEquals("Rebuilt", false, reader3.hasRebuiltXref()); - assertEquals("Fixed", false, reader3.hasFixedXref()); + assertEquals(2, rootKids.size(), "Page root kids count"); + assertEquals(pageCount, pdfDoc3.getNumberOfPages(), "Number of pages"); + assertFalse(reader3.hasRebuiltXref(), "Rebuilt"); + assertFalse(reader3.hasFixedXref(), "Fixed"); verifyPdfPagesCount(pdfDoc3.getCatalog().getPageTree().getRoot().getPdfObject()); pdfDoc3.close(); PdfReader reader = CompareTool.createOutputReader(filename2); PdfDocument pdfDocument = new PdfDocument(reader); - assertEquals("Rebuilt", false, reader.hasRebuiltXref()); + assertFalse(reader.hasRebuiltXref(), "Rebuilt"); for (int i = 1; i <= pageCount; i++) { byte[] bytes = pdfDocument.getPage(i).getContentBytes(); - assertEquals("Page content at page " + i, "%page " + i + "\n", new String(bytes)); + assertEquals("%page " + i + "\n", new String(bytes), "Page content at page " + i); } pdfDocument.close(); } @@ -638,19 +637,19 @@ public void stamping14() throws IOException { pdfDoc3.getPage(i); } //NOTE: during page removing iText don't flatten page structure (we can end up with a lot of embedded pages dictionaries) - assertEquals("Xref size", 42226, pdfDoc3.getXref().size()); - assertEquals("Number of pages", 3, pdfDoc3.getNumberOfPages()); - assertFalse("Rebuilt", reader3.hasRebuiltXref()); - assertFalse("Fixed", reader3.hasFixedXref()); + assertEquals(42226, pdfDoc3.getXref().size(), "Xref size"); + assertEquals(3, pdfDoc3.getNumberOfPages(), "Number of pages"); + assertFalse(reader3.hasRebuiltXref(), "Rebuilt"); + assertFalse(reader3.hasFixedXref(), "Fixed"); verifyPdfPagesCount(pdfDoc3.getCatalog().getPageTree().getRoot().getPdfObject()); pdfDoc3.close(); PdfReader reader = CompareTool.createOutputReader(filename2); PdfDocument pdfDocument = new PdfDocument(reader); - assertEquals("Rebuilt", false, reader.hasRebuiltXref()); + assertFalse(reader.hasRebuiltXref(), "Rebuilt"); for (int i = 1; i <= pdfDocument.getNumberOfPages(); i++) { byte[] bytes = pdfDocument.getPage(i).getContentBytes(); - assertEquals("Page content at page " + i, "%page " + i + "\n", new String(bytes)); + assertEquals("%page " + i + "\n", new String(bytes), "Page content at page " + i); } pdfDocument.close(); } @@ -755,19 +754,19 @@ public void stampingXmp1() throws IOException, XMPException { for (int i = 0; i < pdfDoc3.getNumberOfPages(); i++) { pdfDoc3.getPage(i + 1); } - assertNotNull("XmpMetadata not found", XMPMetaFactory.parseFromBuffer(pdfDoc3.getXmpMetadata())); - assertEquals("Number of pages", pageCount, pdfDoc3.getNumberOfPages()); - assertEquals("Rebuilt", false, reader3.hasRebuiltXref()); - assertEquals("Fixed", false, reader3.hasFixedXref()); + assertNotNull(pdfDoc3.getXmpMetadata(), "XmpMetadata not found"); + assertEquals(pageCount, pdfDoc3.getNumberOfPages(), "Number of pages"); + assertFalse(reader3.hasRebuiltXref(), "Rebuilt"); + assertFalse(reader3.hasFixedXref(), "Fixed"); verifyPdfPagesCount(pdfDoc3.getCatalog().getPageTree().getRoot().getPdfObject()); pdfDoc3.close(); PdfReader reader = CompareTool.createOutputReader(filename2); PdfDocument pdfDocument = new PdfDocument(reader); - assertEquals("Rebuilt", false, reader.hasRebuiltXref()); + assertFalse(reader.hasRebuiltXref(), "Rebuilt"); for (int i = 1; i <= pageCount; i++) { byte[] bytes = pdfDocument.getPage(i).getContentBytes(); - assertEquals("Page content at page " + i, "%page " + i + "\n", new String(bytes)); + assertEquals("%page " + i + "\n", new String(bytes), "Page content at page " + i); } pdfDocument.close(); } @@ -799,19 +798,19 @@ public void stampingXmp2() throws IOException, XMPException { for (int i = 0; i < pdfDoc3.getNumberOfPages(); i++) { pdfDoc3.getPage(i + 1); } - assertNotNull("XmpMetadata not found", XMPMetaFactory.parseFromBuffer(pdfDoc3.getXmpMetadata())); - assertEquals("Number of pages", pageCount, pdfDoc3.getNumberOfPages()); - assertEquals("Rebuilt", false, reader3.hasRebuiltXref()); - assertEquals("Fixed", false, reader3.hasFixedXref()); + assertNotNull(pdfDoc3.getXmpMetadata(), "XmpMetadata not found"); + assertEquals(pageCount, pdfDoc3.getNumberOfPages(), "Number of pages"); + assertFalse(reader3.hasRebuiltXref(), "Rebuilt"); + assertFalse(reader3.hasFixedXref(), "Fixed"); verifyPdfPagesCount(pdfDoc3.getCatalog().getPageTree().getRoot().getPdfObject()); pdfDoc3.close(); PdfReader reader = CompareTool.createOutputReader(filename2); PdfDocument pdfDocument = new PdfDocument(reader); - assertEquals("Rebuilt", false, reader.hasRebuiltXref()); + assertFalse(reader.hasRebuiltXref(), "Rebuilt"); for (int i = 1; i <= pageCount; i++) { byte[] bytes = pdfDocument.getPage(i).getContentBytes(); - assertEquals("Page content at page " + i, "%page " + i + "\n", new String(bytes)); + assertEquals("%page " + i + "\n", new String(bytes), "Page content at page " + i); } pdfDocument.close(); } @@ -839,14 +838,14 @@ public void stampingAppend1() throws IOException { for (int i = 0; i < pdfDoc3.getNumberOfPages(); i++) { pdfDoc3.getPage(i + 1); } - assertEquals("Rebuilt", false, reader3.hasRebuiltXref()); - assertEquals("Fixed", false, reader3.hasFixedXref()); + assertFalse(reader3.hasRebuiltXref(), "Rebuilt"); + assertFalse(reader3.hasFixedXref(), "Fixed"); verifyPdfPagesCount(pdfDoc3.getCatalog().getPageTree().getRoot().getPdfObject()); pdfDoc3.close(); PdfReader reader = CompareTool.createOutputReader(filename2); PdfDocument pdfDocument = new PdfDocument(reader); - assertEquals("Rebuilt", false, reader.hasRebuiltXref()); + assertFalse(reader.hasRebuiltXref(), "Rebuilt"); PdfDictionary trailer = pdfDocument.getTrailer(); PdfDictionary info = trailer.getAsDictionary(PdfName.Info); PdfString creator = info.getAsString(PdfName.Creator); @@ -857,7 +856,7 @@ public void stampingAppend1() throws IOException { Calendar cl = PdfDate.decode(date); double diff = DateTimeUtil.getUtcMillisFromEpoch(null) - DateTimeUtil.getUtcMillisFromEpoch(cl); String message = "Unexpected creation date. Different from now is " + (float) diff / 1000 + "s"; - assertTrue(message, diff < 5000); + assertTrue(diff < 5000, message); pdfDocument.close(); } @@ -884,14 +883,14 @@ public void stampingAppend2() throws IOException { for (int i = 0; i < pdfDoc3.getNumberOfPages(); i++) { pdfDoc3.getPage(i + 1); } - assertEquals("Rebuilt", false, reader3.hasRebuiltXref()); - assertEquals("Fixed", false, reader3.hasFixedXref()); + assertFalse(reader3.hasRebuiltXref(), "Rebuilt"); + assertFalse(reader3.hasFixedXref(), "Fixed"); verifyPdfPagesCount(pdfDoc3.getCatalog().getPageTree().getRoot().getPdfObject()); pdfDoc3.close(); PdfReader reader = CompareTool.createOutputReader(filename2); PdfDocument pdfDocument = new PdfDocument(reader); - assertEquals("Rebuilt", false, reader.hasRebuiltXref()); + assertFalse(reader.hasRebuiltXref(), "Rebuilt"); byte[] bytes = pdfDocument.getPage(1).getContentBytes(); assertEquals("%page 1\n", new String(bytes)); bytes = pdfDocument.getPage(2).getContentBytes(); @@ -923,14 +922,14 @@ public void stampingAppend3() throws IOException { for (int i = 0; i < pdfDoc3.getNumberOfPages(); i++) { pdfDoc3.getPage(i + 1); } - assertEquals("Rebuilt", false, reader3.hasRebuiltXref()); - assertEquals("Fixed", false, reader3.hasFixedXref()); + assertFalse(reader3.hasRebuiltXref(), "Rebuilt"); + assertFalse(reader3.hasFixedXref(), "Fixed"); verifyPdfPagesCount(pdfDoc3.getCatalog().getPageTree().getRoot().getPdfObject()); pdfDoc3.close(); PdfReader reader = CompareTool.createOutputReader(filename2); PdfDocument pdfDocument = new PdfDocument(reader); - assertEquals("Rebuilt", false, reader.hasRebuiltXref()); + assertFalse(reader.hasRebuiltXref(), "Rebuilt"); byte[] bytes = pdfDocument.getPage(1).getContentBytes(); assertEquals("%page 1\n", new String(bytes)); bytes = pdfDocument.getPage(2).getContentBytes(); @@ -964,15 +963,15 @@ public void stampingAppend4() throws IOException { for (int i = 0; i < pdfDoc3.getNumberOfPages(); i++) { pdfDoc3.getPage(i + 1); } - assertEquals("Rebuilt", false, reader3.hasRebuiltXref()); - assertEquals("Fixed", false, reader3.hasFixedXref()); + assertFalse(reader3.hasRebuiltXref(), "Rebuilt"); + assertFalse(reader3.hasFixedXref(), "Fixed"); verifyPdfPagesCount(pdfDoc3.getCatalog().getPageTree().getRoot().getPdfObject()); pdfDoc3.close(); PdfReader reader = CompareTool.createOutputReader(filename2); PdfDocument pdfDocument = new PdfDocument(reader); - assertEquals("Rebuilt", false, reader.hasRebuiltXref()); - assertEquals("Page count", pageCount, pdfDocument.getNumberOfPages()); + assertFalse(reader.hasRebuiltXref(), "Rebuilt"); + assertEquals(pageCount, pdfDocument.getNumberOfPages(), "Page count"); for (int i = 1; i < pdfDocument.getNumberOfPages(); i++) { byte[] bytes = pdfDocument.getPage(i).getContentBytes(); assertEquals("%page " + i + "\n", new String(bytes)); @@ -1008,15 +1007,15 @@ public void stampingAppend5() throws IOException { for (int i = 0; i < pdfDoc3.getNumberOfPages(); i++) { pdfDoc3.getPage(i + 1); } - assertEquals("Rebuilt", false, reader3.hasRebuiltXref()); - assertEquals("Fixed", false, reader3.hasFixedXref()); + assertFalse(reader3.hasRebuiltXref(), "Rebuilt"); + assertFalse(reader3.hasFixedXref(), "Fixed"); verifyPdfPagesCount(pdfDoc3.getCatalog().getPageTree().getRoot().getPdfObject()); pdfDoc3.close(); PdfReader reader = CompareTool.createOutputReader(filename2); PdfDocument pdfDocument = new PdfDocument(reader); - assertEquals("Rebuilt", false, reader.hasRebuiltXref()); - assertEquals("Page count", pageCount, pdfDocument.getNumberOfPages()); + assertFalse(reader.hasRebuiltXref(), "Rebuilt"); + assertEquals(pageCount, pdfDocument.getNumberOfPages(), "Page count"); for (int i = 1; i < pdfDocument.getNumberOfPages(); i++) { byte[] bytes = pdfDocument.getPage(i).getContentBytes(); assertEquals("%page " + i + "\n", new String(bytes)); @@ -1047,18 +1046,18 @@ public void stampingAppend8() throws IOException { for (int i = 0; i < pdfDoc3.getNumberOfPages(); i++) { pdfDoc3.getPage(i + 1); } - assertEquals("Number of pages", pageCount, pdfDoc3.getNumberOfPages()); - assertEquals("Rebuilt", false, reader3.hasRebuiltXref()); - assertEquals("Fixed", false, reader3.hasFixedXref()); + assertEquals(pageCount, pdfDoc3.getNumberOfPages(), "Number of pages"); + assertFalse(reader3.hasRebuiltXref(), "Rebuilt"); + assertFalse(reader3.hasFixedXref(), "Fixed"); verifyPdfPagesCount(pdfDoc3.getCatalog().getPageTree().getRoot().getPdfObject()); pdfDoc3.close(); PdfReader reader = CompareTool.createOutputReader(filename2); PdfDocument pdfDocument = new PdfDocument(reader); - assertEquals("Rebuilt", false, reader.hasRebuiltXref()); + assertFalse(reader.hasRebuiltXref(), "Rebuilt"); for (int i = 1; i <= pageCount; i++) { byte[] bytes = pdfDocument.getPage(i).getContentBytes(); - assertEquals("Page content at page " + i, "%page " + i + "\n", new String(bytes)); + assertEquals("%page " + i + "\n", new String(bytes), "Page content at page " + i); } pdfDocument.close(); } @@ -1089,18 +1088,18 @@ public void stampingAppend9() throws IOException { for (int i = 0; i < pdfDoc3.getNumberOfPages(); i++) { pdfDoc3.getPage(i + 1); } - assertEquals("Number of pages", pageCount, pdfDoc3.getNumberOfPages()); - assertEquals("Rebuilt", false, reader3.hasRebuiltXref()); - assertEquals("Fixed", false, reader3.hasFixedXref()); + assertEquals(pageCount, pdfDoc3.getNumberOfPages(), "Number of pages"); + assertFalse(reader3.hasRebuiltXref(), "Rebuilt"); + assertFalse(reader3.hasFixedXref(), "Fixed"); verifyPdfPagesCount(pdfDoc3.getCatalog().getPageTree().getRoot().getPdfObject()); pdfDoc3.close(); PdfReader reader = CompareTool.createOutputReader(filename2); PdfDocument pdfDocument = new PdfDocument(reader); - assertEquals("Rebuilt", false, reader.hasRebuiltXref()); + assertFalse(reader.hasRebuiltXref(), "Rebuilt"); for (int i = 1; i <= pageCount; i++) { byte[] bytes = pdfDocument.getPage(i).getContentBytes(); - assertEquals("Page content at page " + i, "%page " + i + "\n", new String(bytes)); + assertEquals("%page " + i + "\n", new String(bytes), "Page content at page " + i); } pdfDocument.close(); } @@ -1131,18 +1130,18 @@ public void stampingAppend10() throws IOException { for (int i = 0; i < pdfDoc3.getNumberOfPages(); i++) { pdfDoc3.getPage(i + 1); } - assertEquals("Number of pages", pageCount, pdfDoc3.getNumberOfPages()); - assertEquals("Rebuilt", false, reader3.hasRebuiltXref()); - assertEquals("Fixed", false, reader3.hasFixedXref()); + assertEquals(pageCount, pdfDoc3.getNumberOfPages(), "Number of pages"); + assertFalse(reader3.hasRebuiltXref(), "Rebuilt"); + assertFalse(reader3.hasFixedXref(), "Fixed"); verifyPdfPagesCount(pdfDoc3.getCatalog().getPageTree().getRoot().getPdfObject()); pdfDoc3.close(); PdfReader reader = CompareTool.createOutputReader(filename2); PdfDocument pdfDocument = new PdfDocument(reader); - assertEquals("Rebuilt", false, reader.hasRebuiltXref()); + assertFalse(reader.hasRebuiltXref(), "Rebuilt"); for (int i = 1; i <= pageCount; i++) { byte[] bytes = pdfDocument.getPage(i).getContentBytes(); - assertEquals("Page content at page " + i, "%page " + i + "\n", new String(bytes)); + assertEquals("%page " + i + "\n", new String(bytes), "Page content at page " + i); } pdfDocument.close(); } @@ -1172,18 +1171,18 @@ public void stampingAppend11() throws IOException { for (int i = 0; i < pdfDoc3.getNumberOfPages(); i++) { pdfDoc3.getPage(i + 1); } - assertEquals("Number of pages", pageCount, pdfDoc3.getNumberOfPages()); - assertEquals("Rebuilt", false, reader3.hasRebuiltXref()); - assertEquals("Fixed", false, reader3.hasFixedXref()); + assertEquals(pageCount, pdfDoc3.getNumberOfPages(), "Number of pages"); + assertFalse(reader3.hasRebuiltXref(), "Rebuilt"); + assertFalse(reader3.hasFixedXref(), "Fixed"); verifyPdfPagesCount(pdfDoc3.getCatalog().getPageTree().getRoot().getPdfObject()); pdfDoc3.close(); PdfReader reader = CompareTool.createOutputReader(filename2); PdfDocument pdfDocument = new PdfDocument(reader); - assertEquals("Rebuilt", false, reader.hasRebuiltXref()); + assertFalse(reader.hasRebuiltXref(), "Rebuilt"); for (int i = 1; i <= pageCount; i++) { byte[] bytes = pdfDocument.getPage(i).getContentBytes(); - assertEquals("Page content at page " + i, "%page " + i + "\n", new String(bytes)); + assertEquals("%page " + i + "\n", new String(bytes), "Page content at page " + i); } pdfDocument.close(); } @@ -1283,7 +1282,7 @@ public void stampingStreamNoEndingWhitespace01() throws IOException, Interrupted pdfDocInput.close(); pdfDocOutput.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "stampingStreamNoEndingWhitespace01.pdf", sourceFolder + "cmp_stampingStreamNoEndingWhitespace01.pdf", destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "stampingStreamNoEndingWhitespace01.pdf", sourceFolder + "cmp_stampingStreamNoEndingWhitespace01.pdf", destinationFolder, "diff_")); } @Test @@ -1313,7 +1312,7 @@ public void stampingInAppendModeCreatesNewResourceDictionary() throws Exception PdfCanvasProcessor processor = new PdfCanvasProcessor(strat); // this fails with an NPE b/c the /F1 font isn't in the fonts dictionary processor.processPageContent(pdfDoc.getPage(1)); - Assert.assertTrue(strat.getResultantText().contains("TEXT TO STAMP")); + Assertions.assertTrue(strat.getResultantText().contains("TEXT TO STAMP")); } @@ -1325,7 +1324,7 @@ static void verifyPdfPagesCount(PdfObject root) { if (!pages.containsKey(PdfName.Kids)) return; PdfNumber count = pages.getAsNumber(PdfName.Count); if (count != null) { - assertTrue("PdfPages with zero count", count.intValue() > 0); + assertTrue(count.intValue() > 0, "PdfPages with zero count"); } PdfObject kids = pages.get(PdfName.Kids); if (kids.getType() == PdfObject.ARRAY) { @@ -1337,10 +1336,10 @@ static void verifyPdfPagesCount(PdfObject root) { } } - static class WatermarkEventHandler implements IEventHandler { + static class WatermarkEventHandler extends AbstractPdfDocumentEventHandler { @Override - public void handleEvent(Event event) { + public void onAcceptedEvent(AbstractPdfDocumentEvent event) { PdfDocumentEvent pdfEvent = (PdfDocumentEvent) event; PdfPage page = pdfEvent.getPage(); PdfCanvas pdfCanvas = new PdfCanvas(page); diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfStreamDecodeTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfStreamDecodeTest.java index f9d7c2004e..ddc48af7a2 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfStreamDecodeTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfStreamDecodeTest.java @@ -30,14 +30,13 @@ This file is part of the iText (R) project. import com.itextpdf.test.LogLevelConstants; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.UnitTest; import java.util.Arrays; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfStreamDecodeTest extends ExtendedITextTest { private static final byte[] BYTES = new byte[] { @@ -74,7 +73,7 @@ public void testDCTDecodeFilter() { PdfStream pdfStream = new PdfStream(FLATE_DECODED_BYTES); pdfStream.put(PdfName.Filter, new PdfArray(Arrays.asList((PdfObject) PdfName.FlateDecode, (PdfObject) PdfName.DCTDecode))); - Assert.assertArrayEquals(BYTES, pdfStream.getBytes()); + Assertions.assertArrayEquals(BYTES, pdfStream.getBytes()); } @Test @@ -82,10 +81,10 @@ public void testJBIG2DecodeFilter() { PdfStream pdfStream = new PdfStream(FLATE_DECODED_BYTES); pdfStream.put(PdfName.Filter, new PdfArray(Arrays.asList((PdfObject) PdfName.FlateDecode, (PdfObject) PdfName.JBIG2Decode))); - Exception e = Assert.assertThrows(PdfException.class, + Exception e = Assertions.assertThrows(PdfException.class, () -> pdfStream.getBytes(true) ); - Assert.assertEquals(MessageFormatUtil.format(KernelExceptionMessageConstant.THIS_FILTER_IS_NOT_SUPPORTED, PdfName.JBIG2Decode), e.getMessage()); + Assertions.assertEquals(MessageFormatUtil.format(KernelExceptionMessageConstant.THIS_FILTER_IS_NOT_SUPPORTED, PdfName.JBIG2Decode), e.getMessage()); } @Test @@ -96,6 +95,6 @@ public void testJPXDecodeFilter() { PdfStream pdfStream = new PdfStream(FLATE_DECODED_BYTES); pdfStream.put(PdfName.Filter, new PdfArray(Arrays.asList((PdfObject) PdfName.FlateDecode, (PdfObject) PdfName.JPXDecode))); - Assert.assertArrayEquals(BYTES, pdfStream.getBytes()); + Assertions.assertArrayEquals(BYTES, pdfStream.getBytes()); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfStreamTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfStreamTest.java index 633e1cd9f1..2e197154b9 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfStreamTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfStreamTest.java @@ -37,28 +37,27 @@ This file is part of the iText (R) project. import com.itextpdf.test.LogLevelConstants; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.BouncyCastleIntegrationTest; import java.util.Collections; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import static org.junit.Assert.fail; - -@Category(BouncyCastleIntegrationTest.class) +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; +import static org.junit.jupiter.api.Assertions.fail; + +@Tag("BouncyCastleIntegrationTest") public class PdfStreamTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/kernel/pdf/PdfStreamTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/kernel/pdf/PdfStreamTest/"; - @BeforeClass + @BeforeAll public static void before() { createOrClearDestinationFolder(destinationFolder); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(destinationFolder); } @@ -83,7 +82,7 @@ public void streamAppendDataOnJustCopiedWithCompression() throws IOException, In document.getPage(1).getLastContentStream().setData(newContent, true); document.close(); - Assert.assertNull(new CompareTool().compareByContent(destFile, cmpFile, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destFile, cmpFile, destinationFolder, "diff_")); } @Test @@ -104,8 +103,8 @@ public void runLengthEncodingTest01() throws IOException { byte[] cmpImgBytes1 = readFile(sourceFolder + "cmp_img1.jpg"); byte[] cmpImgBytes2 = readFile(sourceFolder + "cmp_img2.jpg"); - Assert.assertArrayEquals(imgBytes1, cmpImgBytes1); - Assert.assertArrayEquals(imgBytes2, cmpImgBytes2); + Assertions.assertArrayEquals(imgBytes1, cmpImgBytes1); + Assertions.assertArrayEquals(imgBytes2, cmpImgBytes2); } @Test @@ -129,8 +128,8 @@ public void indirectRefInFilterAndNoTaggedPdfTest() throws IOException { PdfStream cmpStreamIm2 = srcDoc.getFirstPage().getResources().getResource(PdfName.XObject) .getAsStream(new PdfName("Im2")); - Assert.assertNull(new CompareTool().compareStreamsStructure(outStreamIm1, cmpStreamIm1)); - Assert.assertNull(new CompareTool().compareStreamsStructure(outStreamIm2, cmpStreamIm2)); + Assertions.assertNull(new CompareTool().compareStreamsStructure(outStreamIm1, cmpStreamIm1)); + Assertions.assertNull(new CompareTool().compareStreamsStructure(outStreamIm2, cmpStreamIm2)); srcDoc.close(); outDoc.close(); @@ -156,8 +155,8 @@ public void cryptFilterFlushedBeforeReadStreamTest() throws IOException { ((PdfStream)doc.getPdfObject(5)).getBytes(); //Simulating that this flush happened automatically before normal stream flushing in close method ((PdfStream)doc.getPdfObject(5)).get(PdfName.Filter).flush(); - Exception exception = Assert.assertThrows(PdfException.class, () -> doc.close()); - Assert.assertEquals( + Exception exception = Assertions.assertThrows(PdfException.class, () -> doc.close()); + Assertions.assertEquals( MessageFormatUtil.format(KernelExceptionMessageConstant.FLUSHED_STREAM_FILTER_EXCEPTION, "5", "0"), exception.getMessage()); } @@ -181,8 +180,8 @@ public void cryptFilterFlushedBeforeStreamTest() throws IOException { PdfDocument doc = new PdfDocument(reader, writer); //Simulating that this flush happened automatically before normal stream flushing in close method ((PdfStream)doc.getPdfObject(5)).get(PdfName.Filter).flush(); - Exception exception = Assert.assertThrows(PdfException.class, () -> doc.close()); - Assert.assertEquals( + Exception exception = Assertions.assertThrows(PdfException.class, () -> doc.close()); + Assertions.assertEquals( MessageFormatUtil.format(KernelExceptionMessageConstant.FLUSHED_STREAM_FILTER_EXCEPTION, "5", "0"), exception.getMessage()); } @@ -231,7 +230,7 @@ public void indirectFilterInCatalogTest() throws IOException, InterruptedExcepti PdfDocument doc = new PdfDocument(new PdfReader(file), CompareTool.createTestPdfWriter(destFile)); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(destFile, cmpFile, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(destFile, cmpFile, destinationFolder)); } @LogMessages(messages = { @@ -248,7 +247,7 @@ public void userDefinedCompressionWithIndirectFilterInCatalogTest() throws IOExc PdfStream stream = (PdfStream) doc.getPdfObject(5); stream.setCompressionLevel(CompressionConstants.BEST_COMPRESSION); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(destFile, cmpFile, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(destFile, cmpFile, destinationFolder)); } @LogMessages(messages = { @@ -269,7 +268,7 @@ public void indirectFilterFlushedBeforeStreamTest() throws IOException, Interrup //Simulating that this flush happened automatically before normal stream flushing in close method filterObject.flush(); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(destFile, cmpFile, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(destFile, cmpFile, destinationFolder)); } @LogMessages(messages = { @@ -296,7 +295,7 @@ public void indirectFilterMarkedToBeFlushedBeforeStreamTest() throws IOException writer.flushWaitingObjects(Collections.emptySet()); // There also was a NPE because FlateFilter was already flushed. pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(destFile, cmpFile, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(destFile, cmpFile, destinationFolder)); } @LogMessages(messages = { @@ -315,7 +314,7 @@ public void decodeParamsFlushedBeforeStreamTest() throws IOException, Interrupte //Simulating that this flush happened automatically before normal stream flushing in close method stream.get(PdfName.DecodeParms).makeIndirect(stream.getIndirectReference().getDocument()).flush(); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(destFile, cmpFile, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(destFile, cmpFile, destinationFolder)); } @LogMessages(messages = { @@ -335,7 +334,7 @@ public void decodeParamsPredictorFlushedBeforeStreamTest() throws IOException, I ((PdfDictionary)stream.get(PdfName.DecodeParms)).get(PdfName.Predictor).makeIndirect(stream.getIndirectReference() .getDocument()).flush(); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(destFile, cmpFile, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(destFile, cmpFile, destinationFolder)); } @LogMessages(messages = { @@ -355,7 +354,7 @@ public void decodeParamsColumnsFlushedBeforeStreamTest() throws IOException, Int ((PdfDictionary)stream.get(PdfName.DecodeParms)).get(PdfName.Columns).makeIndirect(stream.getIndirectReference() .getDocument()).flush(); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(destFile, cmpFile, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(destFile, cmpFile, destinationFolder)); } @LogMessages(messages = { @@ -375,7 +374,7 @@ public void decodeParamsColorsFlushedBeforeStreamTest() throws IOException, Inte ((PdfDictionary)stream.get(PdfName.DecodeParms)).get(PdfName.Colors).makeIndirect(stream.getIndirectReference() .getDocument()).flush(); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(destFile, cmpFile, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(destFile, cmpFile, destinationFolder)); } @LogMessages(messages = { @@ -395,7 +394,7 @@ public void decodeParamsBitsPerComponentFlushedBeforeStreamTest() throws IOExcep ((PdfDictionary)stream.get(PdfName.DecodeParms)).get(PdfName.BitsPerComponent).makeIndirect(stream.getIndirectReference() .getDocument()).flush(); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(destFile, cmpFile, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(destFile, cmpFile, destinationFolder)); } @LogMessages(messages = { @@ -416,7 +415,7 @@ public void flateFilterFlushedWhileDecodeTest() throws IOException, InterruptedE //Simulating that this flush happened automatically before normal stream flushing in close method stream.get(PdfName.Filter).makeIndirect(stream.getIndirectReference().getDocument()).flush(); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(destFile, cmpFile, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(destFile, cmpFile, destinationFolder)); } @LogMessages(messages = { @@ -437,6 +436,6 @@ public void arrayFlateFilterFlushedWhileDecodeTest() throws IOException, Interru //Simulating that this flush happened automatically before normal stream flushing in close method stream.get(PdfName.Filter).makeIndirect(stream.getIndirectReference().getDocument()).flush(); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(destFile, cmpFile, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(destFile, cmpFile, destinationFolder)); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfStreamUnitTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfStreamUnitTest.java index 78e9e028db..d9e7cad851 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfStreamUnitTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfStreamUnitTest.java @@ -26,22 +26,21 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.exceptions.KernelExceptionMessageConstant; import com.itextpdf.kernel.exceptions.PdfException; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.ByteArrayInputStream; import java.io.InputStream; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfStreamUnitTest extends ExtendedITextTest { @Test public void cannotCreatePdfStreamWithoutDocumentTest() { - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> new PdfStream(null, null, 1)); - Assert.assertEquals(KernelExceptionMessageConstant.CANNOT_CREATE_PDFSTREAM_BY_INPUT_STREAM_WITHOUT_PDF_DOCUMENT, + Assertions.assertEquals(KernelExceptionMessageConstant.CANNOT_CREATE_PDFSTREAM_BY_INPUT_STREAM_WITHOUT_PDF_DOCUMENT, exception.getMessage()); } @@ -50,9 +49,9 @@ public void setDataToPdfStreamWithInputStreamTest() { InputStream inputStream = new ByteArrayInputStream(new byte[] {}); PdfDocument pdfDocument = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); PdfStream pdfStream = new PdfStream(pdfDocument, inputStream, 1); - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> pdfStream.setData(new byte[] {}, true)); - Assert.assertEquals( + Assertions.assertEquals( KernelExceptionMessageConstant.CANNOT_SET_DATA_TO_PDF_STREAM_WHICH_WAS_CREATED_BY_INPUT_STREAM, exception.getMessage()); } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfStringTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfStringTest.java index b25ac8cb0a..8331302126 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfStringTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfStringTest.java @@ -39,32 +39,30 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; import java.util.ArrayList; import java.util.List; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfStringTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/kernel/pdf/PdfStringTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/kernel/pdf/PdfStringTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(destinationFolder); } @@ -91,20 +89,20 @@ public void testPdfDocumentInfoStringEncoding01() throws IOException, Interrupte pdfDocument.close(); PdfDocument readDoc = new PdfDocument(CompareTool.createOutputReader(destinationFolder + fileName)); - Assert.assertEquals(author, readDoc.getDocumentInfo().getAuthor()); - Assert.assertEquals(title, readDoc.getDocumentInfo().getTitle()); - Assert.assertEquals(subject, readDoc.getDocumentInfo().getSubject()); - Assert.assertEquals(keywords, readDoc.getDocumentInfo().getKeywords()); - Assert.assertEquals(creator, readDoc.getDocumentInfo().getCreator()); + Assertions.assertEquals(author, readDoc.getDocumentInfo().getAuthor()); + Assertions.assertEquals(title, readDoc.getDocumentInfo().getTitle()); + Assertions.assertEquals(subject, readDoc.getDocumentInfo().getSubject()); + Assertions.assertEquals(keywords, readDoc.getDocumentInfo().getKeywords()); + Assertions.assertEquals(creator, readDoc.getDocumentInfo().getCreator()); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + fileName, sourceFolder + "cmp_" + fileName, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + fileName, sourceFolder + "cmp_" + fileName, destinationFolder, "diff_")); } @Test public void testUnicodeString() { String unicode = "Привет!"; PdfString string = new PdfString(unicode); - Assert.assertNotEquals(unicode, string.toUnicodeString()); + Assertions.assertNotEquals(unicode, string.toUnicodeString()); } @Test @@ -114,7 +112,7 @@ public void readUtf8ActualText() throws java.io.IOException { String text = PdfTextExtractor.getTextFromPage(pdfDoc.getPage(1), new LocationTextExtractionStrategy().setUseActualText(true)); pdfDoc.close(); // शांति देवनागरी - Assert.assertEquals("\u0936\u093e\u0902\u0924\u093f \u0926\u0947\u0935\u0928\u093E\u0917\u0930\u0940", text); + Assertions.assertEquals("\u0936\u093e\u0902\u0924\u093f \u0926\u0947\u0935\u0928\u093E\u0917\u0930\u0940", text); } @Test @@ -128,7 +126,7 @@ public void readUtf8AltText() throws java.io.IOException { String alternateDescription = tagTreePointer.moveToKid(0).moveToKid(0).moveToKid(0).getProperties().getAlternateDescription(); pdfDoc.close(); // 2001: A Space Odyssey (Космическая одиссея) - Assert.assertEquals("2001: A Space Odyssey (\u041A\u043E\u0441\u043C\u0438\u0447\u0435\u0441\u043A\u0430\u044F " + + Assertions.assertEquals("2001: A Space Odyssey (\u041A\u043E\u0441\u043C\u0438\u0447\u0435\u0441\u043A\u0430\u044F " + "\u043E\u0434\u0438\u0441\u0441\u0435\u044F)", alternateDescription); } @@ -154,7 +152,7 @@ public void readUtf8Bookmarks() throws java.io.IOException { expected.add("\u4E2D\u56FD bookmark 2-1"); expected.add("\u4E2D\u56FD bookmark 2-2"); for (int i = 0; i < 6; i++) - Assert.assertEquals(expected.get(i), children.get(i)); + Assertions.assertEquals(expected.get(i), children.get(i)); } @Test @@ -166,7 +164,7 @@ public void readUtf8PageLabelPrefix() throws java.io.IOException { "Movies-9", "Movies-10", "Movies-11", "Movies-12"}; pdfDoc.close(); for (int i = 0; i < labels.length; i++) - Assert.assertEquals(expected[i], labels[i]); + Assertions.assertEquals(expected[i], labels[i]); } @Test @@ -193,7 +191,7 @@ public void writeUtf8AltText() throws java.io.IOException, InterruptedException canvas.closeTag(); canvas.endText(); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "writeUtf8AltText.pdf", sourceFolder + "cmp_writeUtf8AltText.pdf", destinationFolder, "diffAltText_")); + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "writeUtf8AltText.pdf", sourceFolder + "cmp_writeUtf8AltText.pdf", destinationFolder, "diffAltText_")); } @Test @@ -224,7 +222,7 @@ public void writeUtf8Bookmarks() throws java.io.IOException, InterruptedExceptio second.addOutline("").getContent().put(PdfName.Title, new PdfString("\u4E2D\u56FD bookmark 2-2", PdfEncodings.UTF8)); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "writeUtf8Bookmarks.pdf", sourceFolder + "cmp_writeUtf8Bookmarks.pdf", destinationFolder, "diffBookmarks_")); + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "writeUtf8Bookmarks.pdf", sourceFolder + "cmp_writeUtf8Bookmarks.pdf", destinationFolder, "diffBookmarks_")); } @Test @@ -248,7 +246,7 @@ public void writeUtf8PageLabelPrefix() throws java.io.IOException, InterruptedEx canvas.endText(); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "writeUtf8PageLabelPrefix.pdf", sourceFolder + "cmp_writeUtf8PageLabelPrefix.pdf", destinationFolder, "diffPageLabelPrefix_")); + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "writeUtf8PageLabelPrefix.pdf", sourceFolder + "cmp_writeUtf8PageLabelPrefix.pdf", destinationFolder, "diffPageLabelPrefix_")); } @Test @@ -271,6 +269,6 @@ public void writeUtf8ActualText() throws java.io.IOException, InterruptedExcepti canvas.endText(); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "writeUtf8ActualText.pdf", sourceFolder + "cmp_writeUtf8ActualText.pdf", destinationFolder, "diffActualText_")); + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "writeUtf8ActualText.pdf", sourceFolder + "cmp_writeUtf8ActualText.pdf", destinationFolder, "diffActualText_")); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfStructElemTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfStructElemTest.java index a762da484f..25ad8ec40d 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfStructElemTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfStructElemTest.java @@ -42,34 +42,33 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.ArrayList; import javax.xml.parsers.ParserConfigurationException; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import org.xml.sax.SAXException; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfStructElemTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/kernel/pdf/PdfStructElemTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/kernel/pdf/PdfStructElemTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(destinationFolder); } @@ -204,10 +203,10 @@ public void structElemTest03() throws Exception { document.close(); document = new PdfDocument(CompareTool.createOutputReader(destinationFolder + "structElemTest03.pdf")); - Assert.assertEquals(2, (int) document.getNextStructParentIndex()); + Assertions.assertEquals(2, (int) document.getNextStructParentIndex()); PdfPage page = document.getPage(1); - Assert.assertEquals(0, page.getStructParentIndex()); - Assert.assertEquals(2, page.getNextMcid()); + Assertions.assertEquals(0, page.getStructParentIndex()); + Assertions.assertEquals(2, page.getNextMcid()); document.close(); } @@ -501,7 +500,7 @@ public void structTreeCopyingTest03() throws Exception { source.close(); // we don't compare tag structures, because resultant document is not tagged - Assert.assertNull(new CompareTool() + Assertions.assertNull(new CompareTool() .compareByContent(destinationFolder + "structTreeCopyingTest03.pdf", sourceFolder + "cmp_structTreeCopyingTest03.pdf", destinationFolder, "diff_copying_03_")); @@ -685,11 +684,11 @@ public void structTreeCopyingToPartiallyFlushedDocumentTest() throws Exception { document1.close(); PdfDocument document2 = new PdfDocument(new PdfReader(sourceFolder + "quick-brown-fox.pdf")); - Exception e = Assert.assertThrows(PdfException.class, () -> { + Exception e = Assertions.assertThrows(PdfException.class, () -> { document2.copyPagesTo(1, 1, resultDoc); }); // TODO DEVSIX-7005 after exception is gone add assertion for the resulting document - Assert.assertEquals( + Assertions.assertEquals( KernelExceptionMessageConstant.TAG_STRUCTURE_COPYING_FAILED_IT_MIGHT_BE_CORRUPTED_IN_ONE_OF_THE_DOCUMENTS, e.getMessage() ); @@ -742,7 +741,7 @@ public void corruptedTagStructureTest04() throws IOException { docToCopyTo.close(); document = new PdfDocument(new PdfReader(new ByteArrayInputStream(baos.toByteArray()))); - Assert.assertTrue(document.isTagged()); + Assertions.assertTrue(document.isTagged()); document.close(); } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfStructTreeRootTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfStructTreeRootTest.java index d38a2d85f0..295f97811c 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfStructTreeRootTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfStructTreeRootTest.java @@ -27,7 +27,6 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.tagging.PdfStructTreeRoot; import com.itextpdf.test.AssertUtil; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -35,18 +34,18 @@ This file is part of the iText (R) project. import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; +import static org.junit.jupiter.api.Assertions.assertTrue; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfStructTreeRootTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/kernel/pdf/PdfStructTreeRootTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/kernel/pdf/PdfStructTreeRootTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } @@ -86,7 +85,7 @@ public void severalSameElementsInStructTreeRootTest() throws IOException { structTreeRoot.flush(); for (PdfStructElem kidsOfStructTreeRootKid : kidsOfStructTreeRootKids) { - Assert.assertTrue(kidsOfStructTreeRootKid.isFlushed()); + Assertions.assertTrue(kidsOfStructTreeRootKid.isFlushed()); } } @@ -105,7 +104,7 @@ public void idTreeIsLazyTest() throws IOException { // we've retrieved the ID tree but not used it -> it should be left out in the resulting file PdfReader r = new PdfReader(new ByteArrayInputStream(os.toByteArray())); PdfDocument readPdfDoc = new PdfDocument(r); - Assert.assertFalse(readPdfDoc.getStructTreeRoot().getPdfObject().containsKey(PdfName.IDTree)); + Assertions.assertFalse(readPdfDoc.getStructTreeRoot().getPdfObject().containsKey(PdfName.IDTree)); } @Test diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfStructTreeRootUnitTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfStructTreeRootUnitTest.java index ce5523d72e..0bb13a8c28 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfStructTreeRootUnitTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfStructTreeRootUnitTest.java @@ -28,13 +28,12 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.exceptions.PdfException; import com.itextpdf.kernel.pdf.tagging.PdfStructTreeRoot; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfStructTreeRootUnitTest extends ExtendedITextTest { @Test @@ -43,9 +42,9 @@ public void cannotMovePageInPartlyFlushedDocTest() { PdfPage pdfPage = pdfDocument.addNewPage(1); pdfPage.flush(); PdfStructTreeRoot pdfStructTreeRoot = new PdfStructTreeRoot(pdfDocument); - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> pdfStructTreeRoot.move(pdfPage, -1)); - Assert.assertEquals(MessageFormatUtil + Assertions.assertEquals(MessageFormatUtil .format(KernelExceptionMessageConstant.CANNOT_MOVE_PAGES_IN_PARTLY_FLUSHED_DOCUMENT, 1), exception.getMessage()); } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfTextArrayTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfTextArrayTest.java index 116863be22..fdefec4bfe 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfTextArrayTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfTextArrayTest.java @@ -24,22 +24,21 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.font.PdfFontFactory; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfTextArrayTest extends ExtendedITextTest { @Test public void addNZeroTest() { PdfTextArray textArray = new PdfTextArray(); - Assert.assertFalse(textArray.add(0.0f)); - Assert.assertTrue(textArray.isEmpty()); + Assertions.assertFalse(textArray.add(0.0f)); + Assertions.assertTrue(textArray.isEmpty()); } @Test @@ -48,22 +47,22 @@ public void additiveInverseTest() { float number = 10; textArray.add(number); textArray.add(number * -1); - Assert.assertTrue(textArray.isEmpty()); + Assertions.assertTrue(textArray.isEmpty()); } @Test public void addEmptyStringTest() { PdfTextArray textArray = new PdfTextArray(); - Assert.assertFalse(textArray.add("")); - Assert.assertTrue(textArray.isEmpty()); + Assertions.assertFalse(textArray.add("")); + Assertions.assertTrue(textArray.isEmpty()); } @Test public void addNewStringTest() { PdfTextArray textArray = new PdfTextArray(); String content = "content"; - Assert.assertTrue(textArray.add(content)); - Assert.assertEquals(new PdfString(content), textArray.get(0)); + Assertions.assertTrue(textArray.add(content)); + Assertions.assertEquals(new PdfString(content), textArray.get(0)); } @Test @@ -73,7 +72,7 @@ public void appendStringTest() { for (String string : stringArray) textArray.add(string); PdfString expected = new PdfString(stringArray[0] + stringArray[1]); - Assert.assertEquals(expected, textArray.get(0)); + Assertions.assertEquals(expected, textArray.get(0)); } @Test @@ -81,14 +80,14 @@ public void addStringWithFontTest() throws IOException { PdfTextArray textArray = new PdfTextArray(); String string = "font"; textArray.add(string, PdfFontFactory.createFont()); - Assert.assertEquals(new PdfString(string), textArray.get(0)); + Assertions.assertEquals(new PdfString(string), textArray.get(0)); } @Test public void addAllNullTest() { PdfTextArray textArray = new PdfTextArray(); textArray.addAll((PdfArray) null); - Assert.assertTrue(textArray.isEmpty()); + Assertions.assertTrue(textArray.isEmpty()); } @Test @@ -98,7 +97,7 @@ public void addNumbersTest() { float b = 10f; textArray.add(new PdfNumber(a)); textArray.add(new PdfNumber(b)); - Assert.assertEquals(a + b, textArray.getAsNumber(0).floatValue(), 0.0001); + Assertions.assertEquals(a + b, textArray.getAsNumber(0).floatValue(), 0.0001); } @Test @@ -109,7 +108,7 @@ public void addCollectionTest() { PdfTextArray textArray = new PdfTextArray(); textArray.addAll(collection); - Assert.assertEquals(collection.list, textArray.list); + Assertions.assertEquals(collection.list, textArray.list); } @Test @@ -126,7 +125,7 @@ public void addZeroSumTest() { PdfArray expected = new PdfArray(); expected.add(new PdfString("test")); expected.add(new PdfString("test")); - Assert.assertEquals(expected.list, textArray.list); + Assertions.assertEquals(expected.list, textArray.list); } @Test @@ -140,7 +139,7 @@ public void addZeroSumAtTheBeginningTest() { PdfArray expected = new PdfArray(); expected.add(new PdfNumber(13)); expected.add(new PdfString("test")); - Assert.assertEquals(expected.list, textArray.list); + Assertions.assertEquals(expected.list, textArray.list); } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfTokenizerTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfTokenizerTest.java index f209555c38..4ccab5e545 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfTokenizerTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfTokenizerTest.java @@ -27,18 +27,18 @@ This file is part of the iText (R) project. import com.itextpdf.io.source.PdfTokenizer; import com.itextpdf.io.source.RandomAccessFileOrArray; import com.itextpdf.io.source.RandomAccessSourceFactory; +import com.itextpdf.kernel.exceptions.KernelExceptionMessageConstant; import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; import java.nio.charset.StandardCharsets; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfTokenizerTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/kernel/pdf/PdfTokeniserTest/"; @@ -55,51 +55,52 @@ public void encodingTest() throws IOException { tok = new PdfTokenizer(new RandomAccessFileOrArray(factory.createSource(testHexString.getBytes(StandardCharsets.ISO_8859_1)))); tok.nextToken(); pdfString = new PdfString(tok.getByteContent(), tok.isHexString()); - Assert.assertEquals("\r\n\tUser\u0090s Guide", pdfString.getValue()); + Assertions.assertEquals("\r\n\tUser\u0090s Guide", pdfString.getValue()); String testUnicodeString = "ΑΒΓΗ€•♣⋅"; pdfString = new PdfString(PdfEncodings.convertToBytes(testUnicodeString, PdfEncodings.UNICODE_BIG), false); - Assert.assertEquals(testUnicodeString, pdfString.toUnicodeString()); + Assertions.assertEquals(testUnicodeString, pdfString.toUnicodeString()); pdfString = new PdfString("FEFF041F04400438043204350442".getBytes(StandardCharsets.ISO_8859_1), true); - Assert.assertEquals("\u041F\u0440\u0438\u0432\u0435\u0442", pdfString.toUnicodeString()); + Assertions.assertEquals("\u041F\u0440\u0438\u0432\u0435\u0442", pdfString.toUnicodeString()); pdfString = new PdfString("FEFF041F04400438043204350442".getBytes(StandardCharsets.ISO_8859_1), false); - Assert.assertEquals("FEFF041F04400438043204350442", pdfString.toUnicodeString()); + Assertions.assertEquals("FEFF041F04400438043204350442", pdfString.toUnicodeString()); String specialCharacter = "\r\n\t\\n\\r\\t\\f"; pdfString = new PdfString(specialCharacter.getBytes(StandardCharsets.ISO_8859_1), false); - Assert.assertEquals("\n\t\n\r\t\f", pdfString.toUnicodeString()); + Assertions.assertEquals("\n\t\n\r\t\f", pdfString.toUnicodeString()); String symbol = "\u0001\u0004\u0006\u000E\u001F"; pdfString = new PdfString(symbol.getBytes(StandardCharsets.ISO_8859_1), false); - Assert.assertEquals(symbol, pdfString.toUnicodeString()); + Assertions.assertEquals(symbol, pdfString.toUnicodeString()); String testString1 ="These\\\n two\\\r strings\\\n are the same"; pdfString = new PdfString(testString1.getBytes(StandardCharsets.ISO_8859_1), false); - Assert.assertEquals("These two strings are the same", pdfString.getValue()); + Assertions.assertEquals("These two strings are the same", pdfString.getValue()); String testString2 ="This string contains \\245two octal characters\\307"; pdfString = new PdfString(testString2.getBytes(StandardCharsets.ISO_8859_1), false); - Assert.assertEquals("This string contains \u00A5two octal characters\u00C7", pdfString.getValue()); + Assertions.assertEquals("This string contains \u00A5two octal characters\u00C7", pdfString.getValue()); String testString3 ="\\0053"; pdfString = new PdfString(testString3.getBytes(StandardCharsets.ISO_8859_1), false); - Assert.assertEquals("\u00053", pdfString.getValue()); + Assertions.assertEquals("\u00053", pdfString.getValue()); String testString4 ="\\053"; pdfString = new PdfString(testString4.getBytes(StandardCharsets.ISO_8859_1), false); - Assert.assertEquals("+", pdfString.getValue()); + Assertions.assertEquals("+", pdfString.getValue()); byte[] b = new byte[]{(byte)46,(byte)56,(byte)40}; pdfString = new PdfString(b,false); - Assert.assertEquals(new String(b),pdfString.getValue()); + Assertions.assertEquals(new String(b),pdfString.getValue()); } @Test - @LogMessages(messages = {@LogMessage(messageTemplate = IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT)}) + @LogMessages(messages = @LogMessage(messageTemplate = + IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT_WITH_CAUSE)) public void readPdfStringTest() throws IOException { final String author = "This string9078 contains \u00A5two octal characters\u00C7"; final String creator = "iText\r 6\n"; @@ -110,13 +111,13 @@ public void readPdfStringTest() throws IOException { PdfReader reader = new PdfReader(filename); PdfDocument d = new PdfDocument(reader); // text in pdf: int array ( 223,227, 235,240) - Assert.assertEquals(d.getDocumentInfo().getTitle(), title); + Assertions.assertEquals(d.getDocumentInfo().getTitle(), title); // text in pdf: This string\9078 contains \245two octal characters\307 - Assert.assertEquals(d.getDocumentInfo().getAuthor(), author); + Assertions.assertEquals(d.getDocumentInfo().getAuthor(), author); // text in pdf: iText\r 6\n - Assert.assertEquals(d.getDocumentInfo().getCreator(), creator); + Assertions.assertEquals(d.getDocumentInfo().getCreator(), creator); // text in pdf: \053 - Assert.assertEquals(d.getDocumentInfo().getSubject(), subject); + Assertions.assertEquals(d.getDocumentInfo().getSubject(), subject); } @@ -133,105 +134,105 @@ public void primitivesTest() throws Exception { PdfTokenizer tok = new PdfTokenizer(new RandomAccessFileOrArray(factory.createSource(data.getBytes(StandardCharsets.ISO_8859_1)))); tok.nextValidToken(); - Assert.assertEquals(tok.getTokenType(), PdfTokenizer.TokenType.StartDic); + Assertions.assertEquals(tok.getTokenType(), PdfTokenizer.TokenType.StartDic); tok.nextValidToken(); - Assert.assertEquals(tok.getTokenType(), PdfTokenizer.TokenType.Name); + Assertions.assertEquals(tok.getTokenType(), PdfTokenizer.TokenType.Name); PdfName name = new PdfName(tok.getByteContent()); - Assert.assertEquals("Size", name.getValue()); + Assertions.assertEquals("Size", name.getValue()); tok.nextValidToken(); - Assert.assertEquals(tok.getTokenType(), PdfTokenizer.TokenType.Number); + Assertions.assertEquals(tok.getTokenType(), PdfTokenizer.TokenType.Number); PdfNumber num = new PdfNumber(tok.getByteContent()); - Assert.assertEquals("70.", num.toString()); + Assertions.assertEquals("70.", num.toString()); tok.nextValidToken(); - Assert.assertEquals(tok.getTokenType(), PdfTokenizer.TokenType.Name); + Assertions.assertEquals(tok.getTokenType(), PdfTokenizer.TokenType.Name); name = new PdfName(tok.getByteContent()); - Assert.assertEquals("Value ", name.getValue()); + Assertions.assertEquals("Value ", name.getValue()); tok.nextValidToken(); - Assert.assertEquals(tok.getTokenType(), PdfTokenizer.TokenType.Number); + Assertions.assertEquals(tok.getTokenType(), PdfTokenizer.TokenType.Number); num = new PdfNumber(tok.getByteContent()); - Assert.assertNotSame("0.1", num.toString()); + Assertions.assertNotSame("0.1", num.toString()); tok.nextValidToken(); - Assert.assertEquals(tok.getTokenType(), PdfTokenizer.TokenType.Name); + Assertions.assertEquals(tok.getTokenType(), PdfTokenizer.TokenType.Name); name = new PdfName(tok.getByteContent()); - Assert.assertEquals("Root", name.getValue()); + Assertions.assertEquals("Root", name.getValue()); tok.nextValidToken(); - Assert.assertEquals(tok.getTokenType(), PdfTokenizer.TokenType.Ref); + Assertions.assertEquals(tok.getTokenType(), PdfTokenizer.TokenType.Ref); PdfIndirectReference ref = new PdfIndirectReference(null, tok.getObjNr(), tok.getGenNr()); - Assert.assertEquals("46 0 R", ref.toString()); + Assertions.assertEquals("46 0 R", ref.toString()); tok.nextValidToken(); - Assert.assertEquals(tok.getTokenType(), PdfTokenizer.TokenType.Name); + Assertions.assertEquals(tok.getTokenType(), PdfTokenizer.TokenType.Name); name = new PdfName(tok.getByteContent()); - Assert.assertEquals("Info", name.getValue()); + Assertions.assertEquals("Info", name.getValue()); tok.nextValidToken(); - Assert.assertEquals(tok.getTokenType(), PdfTokenizer.TokenType.Ref); + Assertions.assertEquals(tok.getTokenType(), PdfTokenizer.TokenType.Ref); ref = new PdfIndirectReference(null, tok.getObjNr(), tok.getGenNr()); - Assert.assertEquals("44 0 R", ref.toString()); + Assertions.assertEquals("44 0 R", ref.toString()); tok.nextValidToken(); - Assert.assertEquals(tok.getTokenType(), PdfTokenizer.TokenType.Name); + Assertions.assertEquals(tok.getTokenType(), PdfTokenizer.TokenType.Name); name = new PdfName(tok.getByteContent()); - Assert.assertEquals("ID", name.getValue()); + Assertions.assertEquals("ID", name.getValue()); tok.nextValidToken(); - Assert.assertEquals(tok.getTokenType(), PdfTokenizer.TokenType.StartArray); + Assertions.assertEquals(tok.getTokenType(), PdfTokenizer.TokenType.StartArray); tok.nextValidToken(); - Assert.assertEquals(tok.getTokenType(), PdfTokenizer.TokenType.String); - Assert.assertTrue(tok.isHexString()); + Assertions.assertEquals(tok.getTokenType(), PdfTokenizer.TokenType.String); + Assertions.assertTrue(tok.isHexString()); PdfString str = new PdfString(tok.getByteContent(), tok.isHexString()); - Assert.assertEquals("some hex string ", str.getValue()); + Assertions.assertEquals("some hex string ", str.getValue()); tok.nextValidToken(); - Assert.assertEquals(tok.getTokenType(), PdfTokenizer.TokenType.String); - Assert.assertFalse(tok.isHexString()); + Assertions.assertEquals(tok.getTokenType(), PdfTokenizer.TokenType.String); + Assertions.assertFalse(tok.isHexString()); str = new PdfString(tok.getByteContent(), tok.isHexString()); - Assert.assertEquals("some simple string ", str.getValue()); + Assertions.assertEquals("some simple string ", str.getValue()); tok.nextValidToken(); - Assert.assertEquals(tok.getTokenType(), PdfTokenizer.TokenType.String); - Assert.assertTrue(tok.isHexString()); + Assertions.assertEquals(tok.getTokenType(), PdfTokenizer.TokenType.String); + Assertions.assertTrue(tok.isHexString()); str = new PdfString(tok.getByteContent(), tok.isHexString()); - Assert.assertEquals("\u008C%G\u00D5\u008DK\u00D2\u00C6\u00F3\u00D3+\u0083\u000B\u00E3%\u009D ", str.getValue()); + Assertions.assertEquals("\u008C%G\u00D5\u008DK\u00D2\u00C6\u00F3\u00D3+\u0083\u000B\u00E3%\u009D ", str.getValue()); tok.nextValidToken(); - Assert.assertEquals(tok.getTokenType(), PdfTokenizer.TokenType.Number); + Assertions.assertEquals(tok.getTokenType(), PdfTokenizer.TokenType.Number); num = new PdfNumber(tok.getByteContent()); - Assert.assertEquals("-70.1", num.toString()); + Assertions.assertEquals("-70.1", num.toString()); tok.nextValidToken(); - Assert.assertEquals(tok.getTokenType(), PdfTokenizer.TokenType.Number); + Assertions.assertEquals(tok.getTokenType(), PdfTokenizer.TokenType.Number); num = new PdfNumber(tok.getByteContent()); - Assert.assertEquals("-0.2", num.toString()); + Assertions.assertEquals("-0.2", num.toString()); tok.nextValidToken(); - Assert.assertEquals(tok.getTokenType(), PdfTokenizer.TokenType.EndArray); + Assertions.assertEquals(tok.getTokenType(), PdfTokenizer.TokenType.EndArray); tok.nextValidToken(); - Assert.assertEquals(tok.getTokenType(), PdfTokenizer.TokenType.Name); + Assertions.assertEquals(tok.getTokenType(), PdfTokenizer.TokenType.Name); name = new PdfName(tok.getByteContent()); - Assert.assertEquals("Name1", name.getValue()); + Assertions.assertEquals("Name1", name.getValue()); tok.nextValidToken(); - Assert.assertEquals(tok.getTokenType(), PdfTokenizer.TokenType.Number); + Assertions.assertEquals(tok.getTokenType(), PdfTokenizer.TokenType.Number); num = new PdfNumber(tok.getByteContent()); - Assert.assertEquals("0", num.toString()); + Assertions.assertEquals("0", num.toString()); tok.nextValidToken(); - Assert.assertEquals(tok.getTokenType(), PdfTokenizer.TokenType.Name); + Assertions.assertEquals(tok.getTokenType(), PdfTokenizer.TokenType.Name); name = new PdfName(tok.getByteContent()); - Assert.assertEquals("Prev", name.getValue()); + Assertions.assertEquals("Prev", name.getValue()); tok.nextValidToken(); - Assert.assertEquals(tok.getTokenType(), PdfTokenizer.TokenType.Number); + Assertions.assertEquals(tok.getTokenType(), PdfTokenizer.TokenType.Number); num = new PdfNumber(tok.getByteContent()); - Assert.assertEquals("-116.23", num.toString()); + Assertions.assertEquals("-116.23", num.toString()); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfType0FontIntegrationTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfType0FontIntegrationTest.java index 5eacda4454..ee9fcbda0d 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfType0FontIntegrationTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfType0FontIntegrationTest.java @@ -27,19 +27,15 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.canvas.PdfCanvas; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; -import java.util.Arrays; -import java.util.HashSet; -import java.util.stream.Collectors; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -@Category(IntegrationTest.class) +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; + +@Tag("IntegrationTest") public class PdfType0FontIntegrationTest extends ExtendedITextTest { private static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/kernel/pdf/PdfType0FontIntegrationTest/"; private static final String FONTS_FOLDER = "./src/test/resources/com/itextpdf/kernel/pdf/fonts/"; @@ -53,12 +49,12 @@ public class PdfType0FontIntegrationTest extends ExtendedITextTest { private static final String JAPANESE = "5た うぞせツそぇBぁデぢつっず信えいすてナおドぅだトヅでぉミ(:テかちぜ)じぃあづ"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(DESTINATION_FOLDER); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(DESTINATION_FOLDER); } @@ -86,7 +82,7 @@ public void notoSansJpFontTest() throws IOException, InterruptedException { canvas.release(); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, DESTINATION_FOLDER)); } @Test @@ -115,7 +111,7 @@ public void notoSansScFontTest() throws IOException, InterruptedException { canvas.release(); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, DESTINATION_FOLDER)); } @Test @@ -144,6 +140,58 @@ public void notoSansTcFontTest() throws IOException, InterruptedException { canvas.release(); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFilename, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, DESTINATION_FOLDER)); + } + + @Test + public void cmapPlatform0PlatEnc3Format4FontTest() throws IOException, InterruptedException { + String filename = DESTINATION_FOLDER + "cmapPlatform0PlatEnc3Format4FontTest.pdf"; + String cmpFilename = SOURCE_FOLDER + "cmp_cmapPlatform0PlatEnc3Format4FontTest.pdf"; + + PdfWriter writer = CompareTool.createTestPdfWriter(filename); + writer.setCompressionLevel(CompressionConstants.NO_COMPRESSION); + PdfDocument pdfDoc = new PdfDocument(writer); + + PdfFont font = PdfFontFactory.createFont(FONTS_FOLDER + "glyphs.ttf"); + + PdfCanvas canvas = new PdfCanvas(pdfDoc.addNewPage()); + canvas.saveState() + .beginText() + .setFontAndSize(font, 20) + .moveText(36, 700) + .showText("===fff===iii===fi") + .endText() + .restoreState(); + canvas.rectangle(100, 500, 100, 100).fill(); + canvas.release(); + + pdfDoc.close(); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, DESTINATION_FOLDER)); + } + + @Test + public void cmapPlatform0PlatEnc3Format6FontTest() throws IOException, InterruptedException { + String filename = DESTINATION_FOLDER + "cmapPlatform0PlatEnc3Format6FontTest.pdf"; + String cmpFilename = SOURCE_FOLDER + "cmp_cmapPlatform0PlatEnc3Format6FontTest.pdf"; + + PdfWriter writer = CompareTool.createTestPdfWriter(filename); + writer.setCompressionLevel(CompressionConstants.NO_COMPRESSION); + PdfDocument pdfDoc = new PdfDocument(writer); + + PdfFont font = PdfFontFactory.createFont(FONTS_FOLDER + "glyphs-fmt-6.ttf"); + + PdfCanvas canvas = new PdfCanvas(pdfDoc.addNewPage()); + canvas.saveState() + .beginText() + .setFontAndSize(font, 20) + .moveText(36, 700) + .showText("===fff===iii===") + .endText() + .restoreState(); + canvas.rectangle(100, 500, 100, 100).fill(); + canvas.release(); + + pdfDoc.close(); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFilename, DESTINATION_FOLDER)); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfViewerPreferencesTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfViewerPreferencesTest.java index e682596858..05536b6d82 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfViewerPreferencesTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfViewerPreferencesTest.java @@ -23,223 +23,222 @@ This file is part of the iText (R) project. package com.itextpdf.kernel.pdf; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfViewerPreferencesTest extends ExtendedITextTest { @Test public void printScalingTest() { PdfViewerPreferences preferences = new PdfViewerPreferences(); PdfDictionary dictionary = preferences.getPdfObject(); - Assert.assertEquals(0, dictionary.size()); + Assertions.assertEquals(0, dictionary.size()); // Set non-appropriate value preferences.setPrintScaling(PdfViewerPreferences.PdfViewerPreferencesConstants.PRINT_AREA); - Assert.assertEquals(0, dictionary.size()); + Assertions.assertEquals(0, dictionary.size()); preferences.setPrintScaling(PdfViewerPreferences.PdfViewerPreferencesConstants.NONE); - Assert.assertEquals(1, dictionary.size()); - Assert.assertEquals(PdfName.None, dictionary.get(PdfName.PrintScaling)); + Assertions.assertEquals(1, dictionary.size()); + Assertions.assertEquals(PdfName.None, dictionary.get(PdfName.PrintScaling)); preferences.setPrintScaling(PdfViewerPreferences.PdfViewerPreferencesConstants.APP_DEFAULT); - Assert.assertEquals(1, dictionary.size()); - Assert.assertEquals(PdfName.AppDefault, dictionary.get(PdfName.PrintScaling)); + Assertions.assertEquals(1, dictionary.size()); + Assertions.assertEquals(PdfName.AppDefault, dictionary.get(PdfName.PrintScaling)); } @Test public void duplexTest() { PdfViewerPreferences preferences = new PdfViewerPreferences(); PdfDictionary dictionary = preferences.getPdfObject(); - Assert.assertEquals(0, dictionary.size()); + Assertions.assertEquals(0, dictionary.size()); // Set non-appropriate value preferences.setDuplex(PdfViewerPreferences.PdfViewerPreferencesConstants.PRINT_AREA); - Assert.assertEquals(0, dictionary.size()); + Assertions.assertEquals(0, dictionary.size()); preferences.setDuplex(PdfViewerPreferences.PdfViewerPreferencesConstants.SIMPLEX); - Assert.assertEquals(1, dictionary.size()); - Assert.assertEquals(PdfName.Simplex, dictionary.get(PdfName.Duplex)); + Assertions.assertEquals(1, dictionary.size()); + Assertions.assertEquals(PdfName.Simplex, dictionary.get(PdfName.Duplex)); preferences.setDuplex(PdfViewerPreferences.PdfViewerPreferencesConstants.DUPLEX_FLIP_LONG_EDGE); - Assert.assertEquals(1, dictionary.size()); - Assert.assertEquals(PdfName.DuplexFlipLongEdge, dictionary.get(PdfName.Duplex)); + Assertions.assertEquals(1, dictionary.size()); + Assertions.assertEquals(PdfName.DuplexFlipLongEdge, dictionary.get(PdfName.Duplex)); preferences.setDuplex(PdfViewerPreferences.PdfViewerPreferencesConstants.DUPLEX_FLIP_SHORT_EDGE); - Assert.assertEquals(1, dictionary.size()); - Assert.assertEquals(PdfName.DuplexFlipShortEdge, dictionary.get(PdfName.Duplex)); + Assertions.assertEquals(1, dictionary.size()); + Assertions.assertEquals(PdfName.DuplexFlipShortEdge, dictionary.get(PdfName.Duplex)); } @Test public void nonFullScreenPageModeTest() { PdfViewerPreferences preferences = new PdfViewerPreferences(); PdfDictionary dictionary = preferences.getPdfObject(); - Assert.assertEquals(0, dictionary.size()); + Assertions.assertEquals(0, dictionary.size()); // Set non-appropriate value preferences.setNonFullScreenPageMode(PdfViewerPreferences.PdfViewerPreferencesConstants.PRINT_AREA); - Assert.assertEquals(0, dictionary.size()); + Assertions.assertEquals(0, dictionary.size()); preferences.setNonFullScreenPageMode(PdfViewerPreferences.PdfViewerPreferencesConstants.USE_THUMBS); - Assert.assertEquals(1, dictionary.size()); - Assert.assertEquals(PdfName.UseThumbs, dictionary.get(PdfName.NonFullScreenPageMode)); + Assertions.assertEquals(1, dictionary.size()); + Assertions.assertEquals(PdfName.UseThumbs, dictionary.get(PdfName.NonFullScreenPageMode)); preferences.setNonFullScreenPageMode(PdfViewerPreferences.PdfViewerPreferencesConstants.USE_NONE); - Assert.assertEquals(1, dictionary.size()); - Assert.assertEquals(PdfName.UseNone, dictionary.get(PdfName.NonFullScreenPageMode)); + Assertions.assertEquals(1, dictionary.size()); + Assertions.assertEquals(PdfName.UseNone, dictionary.get(PdfName.NonFullScreenPageMode)); preferences.setNonFullScreenPageMode(PdfViewerPreferences.PdfViewerPreferencesConstants.USE_OC); - Assert.assertEquals(1, dictionary.size()); - Assert.assertEquals(PdfName.UseOC, dictionary.get(PdfName.NonFullScreenPageMode)); + Assertions.assertEquals(1, dictionary.size()); + Assertions.assertEquals(PdfName.UseOC, dictionary.get(PdfName.NonFullScreenPageMode)); preferences.setNonFullScreenPageMode(PdfViewerPreferences.PdfViewerPreferencesConstants.USE_OUTLINES); - Assert.assertEquals(1, dictionary.size()); - Assert.assertEquals(PdfName.UseOutlines, dictionary.get(PdfName.NonFullScreenPageMode)); + Assertions.assertEquals(1, dictionary.size()); + Assertions.assertEquals(PdfName.UseOutlines, dictionary.get(PdfName.NonFullScreenPageMode)); } @Test public void directionTest() { PdfViewerPreferences preferences = new PdfViewerPreferences(); PdfDictionary dictionary = preferences.getPdfObject(); - Assert.assertEquals(0, dictionary.size()); + Assertions.assertEquals(0, dictionary.size()); // Set non-appropriate value preferences.setDirection(PdfViewerPreferences.PdfViewerPreferencesConstants.PRINT_AREA); - Assert.assertEquals(0, dictionary.size()); + Assertions.assertEquals(0, dictionary.size()); preferences.setDirection(PdfViewerPreferences.PdfViewerPreferencesConstants.LEFT_TO_RIGHT); - Assert.assertEquals(1, dictionary.size()); - Assert.assertEquals(PdfName.L2R, dictionary.get(PdfName.Direction)); + Assertions.assertEquals(1, dictionary.size()); + Assertions.assertEquals(PdfName.L2R, dictionary.get(PdfName.Direction)); preferences.setDirection(PdfViewerPreferences.PdfViewerPreferencesConstants.RIGHT_TO_LEFT); - Assert.assertEquals(1, dictionary.size()); - Assert.assertEquals(PdfName.R2L, dictionary.get(PdfName.Direction)); + Assertions.assertEquals(1, dictionary.size()); + Assertions.assertEquals(PdfName.R2L, dictionary.get(PdfName.Direction)); } @Test public void viewAreaTest() { PdfViewerPreferences preferences = new PdfViewerPreferences(); PdfDictionary dictionary = preferences.getPdfObject(); - Assert.assertEquals(0, dictionary.size()); + Assertions.assertEquals(0, dictionary.size()); // Set non-appropriate value preferences.setViewArea(PdfViewerPreferences.PdfViewerPreferencesConstants.PRINT_AREA); - Assert.assertEquals(0, dictionary.size()); + Assertions.assertEquals(0, dictionary.size()); preferences.setViewArea(PdfViewerPreferences.PdfViewerPreferencesConstants.CROP_BOX); - Assert.assertEquals(1, dictionary.size()); - Assert.assertEquals(PdfName.CropBox, dictionary.get(PdfName.ViewArea)); + Assertions.assertEquals(1, dictionary.size()); + Assertions.assertEquals(PdfName.CropBox, dictionary.get(PdfName.ViewArea)); preferences.setViewArea(PdfViewerPreferences.PdfViewerPreferencesConstants.ART_BOX); - Assert.assertEquals(1, dictionary.size()); - Assert.assertEquals(PdfName.ArtBox, dictionary.get(PdfName.ViewArea)); + Assertions.assertEquals(1, dictionary.size()); + Assertions.assertEquals(PdfName.ArtBox, dictionary.get(PdfName.ViewArea)); preferences.setViewArea(PdfViewerPreferences.PdfViewerPreferencesConstants.BLEED_BOX); - Assert.assertEquals(1, dictionary.size()); - Assert.assertEquals(PdfName.BleedBox, dictionary.get(PdfName.ViewArea)); + Assertions.assertEquals(1, dictionary.size()); + Assertions.assertEquals(PdfName.BleedBox, dictionary.get(PdfName.ViewArea)); preferences.setViewArea(PdfViewerPreferences.PdfViewerPreferencesConstants.MEDIA_BOX); - Assert.assertEquals(1, dictionary.size()); - Assert.assertEquals(PdfName.MediaBox, dictionary.get(PdfName.ViewArea)); + Assertions.assertEquals(1, dictionary.size()); + Assertions.assertEquals(PdfName.MediaBox, dictionary.get(PdfName.ViewArea)); preferences.setViewArea(PdfViewerPreferences.PdfViewerPreferencesConstants.TRIM_BOX); - Assert.assertEquals(1, dictionary.size()); - Assert.assertEquals(PdfName.TrimBox, dictionary.get(PdfName.ViewArea)); + Assertions.assertEquals(1, dictionary.size()); + Assertions.assertEquals(PdfName.TrimBox, dictionary.get(PdfName.ViewArea)); } @Test public void viewClipTest() { PdfViewerPreferences preferences = new PdfViewerPreferences(); PdfDictionary dictionary = preferences.getPdfObject(); - Assert.assertEquals(0, dictionary.size()); + Assertions.assertEquals(0, dictionary.size()); // Set non-appropriate value preferences.setViewClip(PdfViewerPreferences.PdfViewerPreferencesConstants.PRINT_AREA); - Assert.assertEquals(0, dictionary.size()); + Assertions.assertEquals(0, dictionary.size()); preferences.setViewClip(PdfViewerPreferences.PdfViewerPreferencesConstants.CROP_BOX); - Assert.assertEquals(1, dictionary.size()); - Assert.assertEquals(PdfName.CropBox, dictionary.get(PdfName.ViewClip)); + Assertions.assertEquals(1, dictionary.size()); + Assertions.assertEquals(PdfName.CropBox, dictionary.get(PdfName.ViewClip)); preferences.setViewClip(PdfViewerPreferences.PdfViewerPreferencesConstants.ART_BOX); - Assert.assertEquals(1, dictionary.size()); - Assert.assertEquals(PdfName.ArtBox, dictionary.get(PdfName.ViewClip)); + Assertions.assertEquals(1, dictionary.size()); + Assertions.assertEquals(PdfName.ArtBox, dictionary.get(PdfName.ViewClip)); preferences.setViewClip(PdfViewerPreferences.PdfViewerPreferencesConstants.BLEED_BOX); - Assert.assertEquals(1, dictionary.size()); - Assert.assertEquals(PdfName.BleedBox, dictionary.get(PdfName.ViewClip)); + Assertions.assertEquals(1, dictionary.size()); + Assertions.assertEquals(PdfName.BleedBox, dictionary.get(PdfName.ViewClip)); preferences.setViewClip(PdfViewerPreferences.PdfViewerPreferencesConstants.MEDIA_BOX); - Assert.assertEquals(1, dictionary.size()); - Assert.assertEquals(PdfName.MediaBox, dictionary.get(PdfName.ViewClip)); + Assertions.assertEquals(1, dictionary.size()); + Assertions.assertEquals(PdfName.MediaBox, dictionary.get(PdfName.ViewClip)); preferences.setViewClip(PdfViewerPreferences.PdfViewerPreferencesConstants.TRIM_BOX); - Assert.assertEquals(1, dictionary.size()); - Assert.assertEquals(PdfName.TrimBox, dictionary.get(PdfName.ViewClip)); + Assertions.assertEquals(1, dictionary.size()); + Assertions.assertEquals(PdfName.TrimBox, dictionary.get(PdfName.ViewClip)); } @Test public void printAreaTest() { PdfViewerPreferences preferences = new PdfViewerPreferences(); PdfDictionary dictionary = preferences.getPdfObject(); - Assert.assertEquals(0, dictionary.size()); + Assertions.assertEquals(0, dictionary.size()); // Set non-appropriate value preferences.setPrintArea(PdfViewerPreferences.PdfViewerPreferencesConstants.PRINT_AREA); - Assert.assertEquals(0, dictionary.size()); + Assertions.assertEquals(0, dictionary.size()); preferences.setPrintArea(PdfViewerPreferences.PdfViewerPreferencesConstants.CROP_BOX); - Assert.assertEquals(1, dictionary.size()); - Assert.assertEquals(PdfName.CropBox, dictionary.get(PdfName.PrintArea)); + Assertions.assertEquals(1, dictionary.size()); + Assertions.assertEquals(PdfName.CropBox, dictionary.get(PdfName.PrintArea)); preferences.setPrintArea(PdfViewerPreferences.PdfViewerPreferencesConstants.ART_BOX); - Assert.assertEquals(1, dictionary.size()); - Assert.assertEquals(PdfName.ArtBox, dictionary.get(PdfName.PrintArea)); + Assertions.assertEquals(1, dictionary.size()); + Assertions.assertEquals(PdfName.ArtBox, dictionary.get(PdfName.PrintArea)); preferences.setPrintArea(PdfViewerPreferences.PdfViewerPreferencesConstants.BLEED_BOX); - Assert.assertEquals(1, dictionary.size()); - Assert.assertEquals(PdfName.BleedBox, dictionary.get(PdfName.PrintArea)); + Assertions.assertEquals(1, dictionary.size()); + Assertions.assertEquals(PdfName.BleedBox, dictionary.get(PdfName.PrintArea)); preferences.setPrintArea(PdfViewerPreferences.PdfViewerPreferencesConstants.MEDIA_BOX); - Assert.assertEquals(1, dictionary.size()); - Assert.assertEquals(PdfName.MediaBox, dictionary.get(PdfName.PrintArea)); + Assertions.assertEquals(1, dictionary.size()); + Assertions.assertEquals(PdfName.MediaBox, dictionary.get(PdfName.PrintArea)); preferences.setPrintArea(PdfViewerPreferences.PdfViewerPreferencesConstants.TRIM_BOX); - Assert.assertEquals(1, dictionary.size()); - Assert.assertEquals(PdfName.TrimBox, dictionary.get(PdfName.PrintArea)); + Assertions.assertEquals(1, dictionary.size()); + Assertions.assertEquals(PdfName.TrimBox, dictionary.get(PdfName.PrintArea)); } @Test public void printClipTest() { PdfViewerPreferences preferences = new PdfViewerPreferences(); PdfDictionary dictionary = preferences.getPdfObject(); - Assert.assertEquals(0, dictionary.size()); + Assertions.assertEquals(0, dictionary.size()); // Set non-appropriate value preferences.setPrintClip(PdfViewerPreferences.PdfViewerPreferencesConstants.PRINT_AREA); - Assert.assertEquals(0, dictionary.size()); + Assertions.assertEquals(0, dictionary.size()); preferences.setPrintClip(PdfViewerPreferences.PdfViewerPreferencesConstants.CROP_BOX); - Assert.assertEquals(1, dictionary.size()); - Assert.assertEquals(PdfName.CropBox, dictionary.get(PdfName.PrintClip)); + Assertions.assertEquals(1, dictionary.size()); + Assertions.assertEquals(PdfName.CropBox, dictionary.get(PdfName.PrintClip)); preferences.setPrintClip(PdfViewerPreferences.PdfViewerPreferencesConstants.ART_BOX); - Assert.assertEquals(1, dictionary.size()); - Assert.assertEquals(PdfName.ArtBox, dictionary.get(PdfName.PrintClip)); + Assertions.assertEquals(1, dictionary.size()); + Assertions.assertEquals(PdfName.ArtBox, dictionary.get(PdfName.PrintClip)); preferences.setPrintClip(PdfViewerPreferences.PdfViewerPreferencesConstants.BLEED_BOX); - Assert.assertEquals(1, dictionary.size()); - Assert.assertEquals(PdfName.BleedBox, dictionary.get(PdfName.PrintClip)); + Assertions.assertEquals(1, dictionary.size()); + Assertions.assertEquals(PdfName.BleedBox, dictionary.get(PdfName.PrintClip)); preferences.setPrintClip(PdfViewerPreferences.PdfViewerPreferencesConstants.MEDIA_BOX); - Assert.assertEquals(1, dictionary.size()); - Assert.assertEquals(PdfName.MediaBox, dictionary.get(PdfName.PrintClip)); + Assertions.assertEquals(1, dictionary.size()); + Assertions.assertEquals(PdfName.MediaBox, dictionary.get(PdfName.PrintClip)); preferences.setPrintClip(PdfViewerPreferences.PdfViewerPreferencesConstants.TRIM_BOX); - Assert.assertEquals(1, dictionary.size()); - Assert.assertEquals(PdfName.TrimBox, dictionary.get(PdfName.PrintClip)); + Assertions.assertEquals(1, dictionary.size()); + Assertions.assertEquals(PdfName.TrimBox, dictionary.get(PdfName.PrintClip)); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfViewerPreferencesUnitTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfViewerPreferencesUnitTest.java index fc4459aff3..535c943927 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfViewerPreferencesUnitTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfViewerPreferencesUnitTest.java @@ -25,13 +25,12 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.exceptions.KernelExceptionMessageConstant; import com.itextpdf.kernel.exceptions.PdfException; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfViewerPreferencesUnitTest extends ExtendedITextTest { @Test @@ -39,9 +38,9 @@ public void printScalingIsNullTest() { PdfViewerPreferences preferences = new PdfViewerPreferences(); PdfName pdfName = PdfName.PrintScaling; PdfArray pdfArray = new PdfArray(pdfName); - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> preferences.setEnforce(pdfArray)); - Assert.assertEquals(KernelExceptionMessageConstant.PRINT_SCALING_ENFORCE_ENTRY_INVALID, + Assertions.assertEquals(KernelExceptionMessageConstant.PRINT_SCALING_ENFORCE_ENTRY_INVALID, exception.getMessage()); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfWriterTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfWriterTest.java index e51bbb446b..b6d150fb8a 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfWriterTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfWriterTest.java @@ -29,14 +29,13 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.exceptions.KernelExceptionMessageConstant; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.OutputStream; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.ByteArrayInputStream; import java.io.FileOutputStream; @@ -45,17 +44,17 @@ This file is part of the iText (R) project. import java.util.Calendar; import java.util.TreeMap; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfWriterTest extends ExtendedITextTest { public static final String destinationFolder = "./target/test/com/itextpdf/kernel/pdf/PdfWriterTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(destinationFolder); } @@ -72,13 +71,13 @@ public void createEmptyDocument() throws IOException { PdfReader reader = CompareTool.createOutputReader(destinationFolder + "emptyDocument.pdf"); PdfDocument pdfDocument = new PdfDocument(reader); - Assert.assertEquals("Rebuilt", false, reader.hasRebuiltXref()); - Assert.assertNotNull(pdfDocument.getPage(1)); + Assertions.assertEquals(false, reader.hasRebuiltXref(), "Rebuilt"); + Assertions.assertNotNull(pdfDocument.getPage(1)); String date = pdfDocument.getDocumentInfo().getPdfObject().getAsString(PdfName.CreationDate).getValue(); Calendar cl = PdfDate.decode(date); double diff = DateTimeUtil.getUtcMillisFromEpoch(null) - DateTimeUtil.getUtcMillisFromEpoch(cl); String message = "Unexpected creation date. Different from now is " + (float) diff / 1000 + "s"; - Assert.assertTrue(message, diff < 5000); + Assertions.assertTrue(diff < 5000, message); pdfDocument.close(); } @@ -149,17 +148,17 @@ public void useObjectForMultipleTimes4() throws IOException { private void validateUseObjectForMultipleTimesTest(String filename) throws IOException { PdfReader reader = CompareTool.createOutputReader(filename); PdfDocument pdfDoc = new PdfDocument(reader); - Assert.assertEquals("Rebuilt", false, reader.hasRebuiltXref()); + Assertions.assertEquals(false, reader.hasRebuiltXref(), "Rebuilt"); PdfDictionary page = pdfDoc.getPage(1).getPdfObject(); - Assert.assertNotNull(page); + Assertions.assertNotNull(page); PdfDictionary helloWorld = page.getAsDictionary(new PdfName("HelloWorld")); - Assert.assertNotNull(helloWorld); + Assertions.assertNotNull(helloWorld); PdfString world = helloWorld.getAsString(new PdfName("Hello")); - Assert.assertEquals("World", world.toString()); + Assertions.assertEquals("World", world.toString()); helloWorld = pdfDoc.getCatalog().getPdfObject().getAsDictionary(new PdfName("HelloWorld")); - Assert.assertNotNull(helloWorld); + Assertions.assertNotNull(helloWorld); world = helloWorld.getAsString(new PdfName("Hello")); - Assert.assertEquals("World", world.toString()); + Assertions.assertEquals("World", world.toString()); pdfDoc.close(); } @@ -201,19 +200,19 @@ public void copyObject1() throws IOException { PdfReader reader = CompareTool.createOutputReader(destinationFolder + "copyObject1_2.pdf"); PdfDocument pdfDocument = new PdfDocument(reader); - Assert.assertEquals("Rebuilt", false, reader.hasRebuiltXref()); + Assertions.assertEquals(false, reader.hasRebuiltXref(), "Rebuilt"); PdfDictionary catalog = pdfDocument.getCatalog().getPdfObject(); PdfArray a = (PdfArray) catalog.get(new PdfName("aDirect")); - Assert.assertNotNull(a); - Assert.assertEquals(1, ((PdfNumber) ((PdfArray) a.get(0)).get(0)).intValue()); - Assert.assertEquals(2, ((PdfNumber) ((PdfArray) a.get(0)).get(1)).intValue()); - Assert.assertEquals(true, ((PdfBoolean) a.get(1)).getValue()); - Assert.assertEquals(1, ((PdfNumber) ((PdfDictionary) a.get(2)).get(new PdfName("one"))).intValue()); - Assert.assertEquals(2, ((PdfNumber) ((PdfDictionary) a.get(2)).get(new PdfName("two"))).intValue()); - Assert.assertEquals(new PdfName("name"), a.get(3)); - Assert.assertTrue(a.get(4).isNull()); - Assert.assertEquals(100, ((PdfNumber) a.get(5)).intValue()); - Assert.assertEquals("string", ((PdfString) a.get(6)).toUnicodeString()); + Assertions.assertNotNull(a); + Assertions.assertEquals(1, ((PdfNumber) ((PdfArray) a.get(0)).get(0)).intValue()); + Assertions.assertEquals(2, ((PdfNumber) ((PdfArray) a.get(0)).get(1)).intValue()); + Assertions.assertEquals(true, ((PdfBoolean) a.get(1)).getValue()); + Assertions.assertEquals(1, ((PdfNumber) ((PdfDictionary) a.get(2)).get(new PdfName("one"))).intValue()); + Assertions.assertEquals(2, ((PdfNumber) ((PdfDictionary) a.get(2)).get(new PdfName("two"))).intValue()); + Assertions.assertEquals(new PdfName("name"), a.get(3)); + Assertions.assertTrue(a.get(4).isNull()); + Assertions.assertEquals(100, ((PdfNumber) a.get(5)).intValue()); + Assertions.assertEquals("string", ((PdfString) a.get(6)).toUnicodeString()); pdfDocument.close(); } @@ -261,20 +260,20 @@ public void copyObject2() throws IOException { PdfReader reader = CompareTool.createOutputReader(destinationFolder + "copyObject2_2.pdf"); PdfDocument pdfDocument = new PdfDocument(reader); - Assert.assertEquals("Rebuilt", false, reader.hasRebuiltXref()); + Assertions.assertEquals(false, reader.hasRebuiltXref(), "Rebuilt"); PdfDictionary catalog = pdfDocument.getCatalog().getPdfObject(); PdfArray a = catalog.getAsArray(new PdfName("aDirect")); - Assert.assertNotNull(a); - Assert.assertEquals(1, ((PdfNumber) ((PdfArray) a.get(0)).get(0)).intValue()); - Assert.assertEquals(2, ((PdfArray) a.get(0)).getAsNumber(1).intValue()); - Assert.assertEquals(true, ((PdfBoolean) a.get(1)).getValue()); - Assert.assertEquals(1, ((PdfNumber) ((PdfDictionary) a.get(2)).get(new PdfName("one"))).intValue()); - Assert.assertEquals(2, ((PdfDictionary) a.get(2)).getAsNumber(new PdfName("two")).intValue()); - Assert.assertEquals(new PdfName("name"), a.get(3)); - - Assert.assertTrue(a.get(4).isNull()); - Assert.assertEquals(100, ((PdfNumber) a.get(5)).intValue()); - Assert.assertEquals("string", ((PdfString) a.get(6)).toUnicodeString()); + Assertions.assertNotNull(a); + Assertions.assertEquals(1, ((PdfNumber) ((PdfArray) a.get(0)).get(0)).intValue()); + Assertions.assertEquals(2, ((PdfArray) a.get(0)).getAsNumber(1).intValue()); + Assertions.assertEquals(true, ((PdfBoolean) a.get(1)).getValue()); + Assertions.assertEquals(1, ((PdfNumber) ((PdfDictionary) a.get(2)).get(new PdfName("one"))).intValue()); + Assertions.assertEquals(2, ((PdfDictionary) a.get(2)).getAsNumber(new PdfName("two")).intValue()); + Assertions.assertEquals(new PdfName("name"), a.get(3)); + + Assertions.assertTrue(a.get(4).isNull()); + Assertions.assertEquals(100, ((PdfNumber) a.get(5)).intValue()); + Assertions.assertEquals("string", ((PdfString) a.get(6)).toUnicodeString()); pdfDocument.close(); } @@ -318,13 +317,13 @@ public void copyObject3() throws IOException { { PdfReader reader = CompareTool.createOutputReader(destinationFolder + "copyObject3_2.pdf"); PdfDocument pdfDocument = new PdfDocument(reader); - Assert.assertEquals("Rebuilt", false, reader.hasRebuiltXref()); + Assertions.assertEquals(false, reader.hasRebuiltXref(), "Rebuilt"); PdfDictionary catalog = pdfDocument.getCatalog().getPdfObject(); PdfArray arr1 = catalog.getAsArray(new PdfName("arr1")); PdfArray arr2 = arr1.getAsArray(0); PdfDictionary dic1 = arr2.getAsDictionary(0); PdfDictionary dic2 = dic1.getAsDictionary(new PdfName("dic2")); - Assert.assertEquals(arr1, dic2.getAsArray(new PdfName("arr1"))); + Assertions.assertEquals(arr1, dic2.getAsArray(new PdfName("arr1"))); pdfDocument.close(); } } @@ -363,11 +362,11 @@ public void copyObject4() throws IOException { PdfReader reader = CompareTool.createOutputReader(destinationFolder + "copyObject4_2.pdf"); PdfDocument pdfDocument = new PdfDocument(reader); - Assert.assertEquals("Rebuilt", false, reader.hasRebuiltXref()); + Assertions.assertEquals(false, reader.hasRebuiltXref(), "Rebuilt"); PdfDictionary catalog = pdfDocument.getCatalog().getPdfObject(); PdfStream stream = (PdfStream) catalog.getAsStream(new PdfName("stream")); byte[] bytes = stream.getBytes(); - Assert.assertArrayEquals(ByteUtils.getIsoBytes("[1 2 3]"), bytes); + Assertions.assertArrayEquals(ByteUtils.getIsoBytes("[1 2 3]"), bytes); pdfDocument.close(); } @@ -400,14 +399,14 @@ public void copyObject5() throws IOException { PdfReader reader = CompareTool.createOutputReader(destinationFolder + "copyObject5_2.pdf"); PdfDocument pdfDocument = new PdfDocument(reader); - Assert.assertEquals("Rebuilt", false, reader.hasRebuiltXref()); - Assert.assertEquals(8, reader.trailer.getAsNumber(PdfName.Size).intValue()); + Assertions.assertEquals(false, reader.hasRebuiltXref(), "Rebuilt"); + Assertions.assertEquals(8, reader.trailer.getAsNumber(PdfName.Size).intValue()); byte[] bytes = pdfDocument.getPage(1).getContentBytes(); // getting content bytes results in adding '\n' for each content stream // so we should compare String with '\n' at the end - Assert.assertArrayEquals(ByteUtils.getIsoBytes("%Page_1\n"), bytes); + Assertions.assertArrayEquals(ByteUtils.getIsoBytes("%Page_1\n"), bytes); bytes = pdfDocument.getPage(2).getContentBytes(); - Assert.assertArrayEquals(ByteUtils.getIsoBytes("%Page_2\n"), bytes); + Assertions.assertArrayEquals(ByteUtils.getIsoBytes("%Page_2\n"), bytes); pdfDocument.close(); } @@ -442,25 +441,25 @@ public void copyObject6() throws IOException { PdfReader reader = CompareTool.createOutputReader(destinationFolder + "copyObject6_2.pdf"); PdfDocument pdfDocument = new PdfDocument(reader); - Assert.assertEquals("Rebuilt", false, reader.hasRebuiltXref()); + Assertions.assertEquals(false, reader.hasRebuiltXref(), "Rebuilt"); PdfObject obj1 = pdfDocument.getPage(1).getPdfObject().get(new PdfName("HelloWorldCopy1")); PdfIndirectReference ref1 = obj1.getIndirectReference(); - Assert.assertEquals(6, ref1.objNr); - Assert.assertEquals(0, ref1.genNr); + Assertions.assertEquals(6, ref1.objNr); + Assertions.assertEquals(0, ref1.genNr); PdfObject obj2 = pdfDocument.getPage(1).getPdfObject().get(new PdfName("HelloWorldCopy2")); PdfIndirectReference ref2 = obj2.getIndirectReference(); - Assert.assertEquals(7, ref2.getObjNumber()); - Assert.assertEquals(0, ref2.getGenNumber()); + Assertions.assertEquals(7, ref2.getObjNumber()); + Assertions.assertEquals(0, ref2.getGenNumber()); PdfObject obj3 = pdfDocument.getPage(1).getPdfObject().get(new PdfName("HelloWorldCopy3")); PdfIndirectReference ref3 = obj3.getIndirectReference(); - Assert.assertEquals(7, ref3.getObjNumber()); - Assert.assertEquals(0, ref3.getGenNumber()); + Assertions.assertEquals(7, ref3.getObjNumber()); + Assertions.assertEquals(0, ref3.getGenNumber()); pdfDocument.close(); } @@ -494,7 +493,7 @@ public void copyObject7() throws IOException { pdfDoc2.close(); } - Assert.assertEquals( + Assertions.assertEquals( KernelExceptionMessageConstant.CANNOT_COPY_INDIRECT_OBJECT_FROM_THE_DOCUMENT_THAT_IS_BEING_WRITTEN, exceptionMessage); } @@ -523,7 +522,7 @@ public void copyObject8() throws IOException { pdfDoc.close(); } - Assert.assertEquals( + Assertions.assertEquals( KernelExceptionMessageConstant.DOCUMENT_FOR_COPY_TO_CANNOT_BE_NULL, exceptionMessage); } @@ -536,7 +535,7 @@ public void closeStream1() throws IOException { pdfDoc.close(); try { fos.write(1); - Assert.fail("Exception expected"); + Assertions.fail("Exception expected"); } catch (Exception e) { //ignored } @@ -578,10 +577,10 @@ public void directInIndirectChain() throws IOException { PdfReader reader = CompareTool.createOutputReader(filename); PdfDocument pdfDocument = new PdfDocument(reader); - Assert.assertEquals("Rebuilt", false, reader.hasRebuiltXref()); - Assert.assertEquals("Page count", 1, pdfDocument.getNumberOfPages()); + Assertions.assertEquals(false, reader.hasRebuiltXref(), "Rebuilt"); + Assertions.assertEquals(1, pdfDocument.getNumberOfPages(), "Page count"); PdfDictionary page = pdfDocument.getPage(1).getPdfObject(); - Assert.assertEquals(PdfName.Page, page.get(PdfName.Type)); + Assertions.assertEquals(PdfName.Page, page.get(PdfName.Type)); pdfDocument.close(); } @@ -603,21 +602,21 @@ public void createPdfStreamByInputStream() throws IOException { document.close(); // com.itextpdf.text.pdf.PdfReader reader = new PdfReader(filename); -// Assert.assertEquals("Rebuilt", false, reader.isRebuilt()); -// Assert.assertNotNull(reader.getPageN(1)); +// Assertions.assertEquals("Rebuilt", false, reader.isRebuilt()); +// Assertions.assertNotNull(reader.getPageN(1)); // String date = reader.getDocumentInfo().get("CreationDate"); // Calendar cl = com.itextpdf.text.pdf.PdfDate.decode(date); // long diff = new GregorianCalendar().getTimeInMillis() - cl.getTimeInMillis(); // String message = "Unexpected creation date. Different from now is " + (float)diff/1000 + "s"; -// Assert.assertTrue(message, diff < 5000); +// Assertions.assertTrue(diff < 5000, message); // reader.close(); PdfReader reader6 = CompareTool.createOutputReader(filename); document = new PdfDocument(reader6); - Assert.assertEquals("Rebuilt", false, reader6.hasRebuiltXref()); - Assert.assertEquals("Fixed", false, reader6.hasFixedXref()); + Assertions.assertEquals(false, reader6.hasRebuiltXref(), "Rebuilt"); + Assertions.assertEquals(false, reader6.hasFixedXref(), "Fixed"); PdfStream pdfStream = (PdfStream) document.getXref().get(streamIndirectNumber).getRefersTo(); - Assert.assertArrayEquals("Stream by InputStream", streamContent.getBytes(), pdfStream.getBytes()); + Assertions.assertArrayEquals(streamContent.getBytes(), pdfStream.getBytes(), "Stream by InputStream"); document.close(); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfXObjectTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfXObjectTest.java index 98aa1d18f8..276a82d864 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfXObjectTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfXObjectTest.java @@ -36,14 +36,12 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.File; import java.io.FileOutputStream; @@ -53,7 +51,7 @@ This file is part of the iText (R) project. import java.util.HashMap; import java.util.List; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfXObjectTest extends ExtendedITextTest{ public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/kernel/pdf/PdfXObjectTest/"; public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/kernel/pdf/PdfXObjectTest/"; @@ -64,12 +62,12 @@ public class PdfXObjectTest extends ExtendedITextTest{ SOURCE_FOLDER + "WP_20140410_001.tif"}; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(DESTINATION_FOLDER); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(DESTINATION_FOLDER); } @@ -102,8 +100,8 @@ public void createDocumentFromImages1() throws IOException, InterruptedExceptio page.flush(); document.close(); - Assert.assertTrue(new File(destinationDocument).length() < 20 * 1024 * 1024); - Assert.assertNull(new CompareTool().compareByContent(destinationDocument, SOURCE_FOLDER + "cmp_documentFromImages1.pdf", + Assertions.assertTrue(new File(destinationDocument).length() < 20 * 1024 * 1024); + Assertions.assertNull(new CompareTool().compareByContent(destinationDocument, SOURCE_FOLDER + "cmp_documentFromImages1.pdf", DESTINATION_FOLDER, "diff_")); } @@ -126,7 +124,7 @@ public void createDocumentFromImages2() throws IOException, InterruptedExceptio document.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationDocument, SOURCE_FOLDER + "cmp_documentFromImages2.pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationDocument, SOURCE_FOLDER + "cmp_documentFromImages2.pdf", DESTINATION_FOLDER, "diff_")); } @@ -169,7 +167,7 @@ public void createDocumentWithForms() throws IOException, InterruptedException document.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationDocument, SOURCE_FOLDER + "cmp_documentWithForms1.pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationDocument, SOURCE_FOLDER + "cmp_documentWithForms1.pdf", DESTINATION_FOLDER, "diff_")); } @@ -237,13 +235,13 @@ public void xObjectIterativeReference() throws IOException { String case1 = "<> /Subtype /Form /Type /XObject >>"; Integer countOut1 = mapOut.get(case1); Integer countIn1 = mapIn.get(case1); - Assert.assertTrue(countOut1.equals(1) && countIn1.equals(6)); + Assertions.assertTrue(countOut1.equals(1) && countIn1.equals(6)); //the following object appears 1 time in the original pdf file and just once in the output file String case2 = "<>"; Integer countOut2 = mapOut.get(case2); Integer countIn2 = mapIn.get(case2); - Assert.assertTrue(countOut2.equals(countIn2) && countOut2.equals(1)); + Assertions.assertTrue(countOut2.equals(countIn2) && countOut2.equals(1)); //from the original pdf the object "<> >> /Subtype /Form /Type /XObject >>"; //is going to be found changed in the output pdf referencing the referenced object with another id which is retrieved through the hashmap @@ -251,7 +249,7 @@ public void xObjectIterativeReference() throws IOException { Integer countIdIn = mapOutId.get(case3).get(0); //EXPECTED to be as the original but with different referenced object and marked as modified String expected = "<> >> /Subtype /Form /Type /XObject >>"; - Assert.assertTrue(mapOut.get(expected).equals(1)); + Assertions.assertTrue(mapOut.get(expected).equals(1)); } @Test @@ -280,18 +278,18 @@ public void calculateProportionallyFitRectangleWithWidthTest() throws IOExceptio document.close(); - Assert.assertNull(new CompareTool().compareByContent(destPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); } @Test - @Category(UnitTest.class) + @Tag("UnitTest") public void calculateProportionallyFitRectangleWithWidthForCustomXObjectTest() { PdfXObject pdfXObject = new CustomPdfXObject(new PdfStream()); - Exception e = Assert.assertThrows(IllegalArgumentException.class, + Exception e = Assertions.assertThrows(IllegalArgumentException.class, () -> PdfXObject.calculateProportionallyFitRectangleWithWidth(pdfXObject, 0, 0, 20) ); - Assert.assertEquals("PdfFormXObject or PdfImageXObject expected.", e.getMessage()); + Assertions.assertEquals("PdfFormXObject or PdfImageXObject expected.", e.getMessage()); } @Test @@ -320,18 +318,18 @@ public void calculateProportionallyFitRectangleWithHeightTest() throws IOExcepti document.close(); - Assert.assertNull(new CompareTool().compareByContent(destPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); } @Test - @Category(UnitTest.class) + @Tag("UnitTest") public void calculateProportionallyFitRectangleWithHeightForCustomXObjectTest() { PdfXObject pdfXObject = new CustomPdfXObject(new PdfStream()); - Exception e = Assert.assertThrows(IllegalArgumentException.class, + Exception e = Assertions.assertThrows(IllegalArgumentException.class, () -> PdfXObject.calculateProportionallyFitRectangleWithHeight(pdfXObject, 0, 0, 20) ); - Assert.assertEquals("PdfFormXObject or PdfImageXObject expected.", e.getMessage()); + Assertions.assertEquals("PdfFormXObject or PdfImageXObject expected.", e.getMessage()); } private static class CustomPdfXObject extends PdfXObject { diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfXrefTableTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfXrefTableTest.java index e6333e43af..8f481242d2 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfXrefTableTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfXrefTableTest.java @@ -27,40 +27,41 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.exceptions.MemoryLimitsAwareException; import com.itextpdf.kernel.exceptions.PdfException; import com.itextpdf.kernel.utils.CompareTool; +import com.itextpdf.kernel.xmp.XMPException; import com.itextpdf.test.AssertUtil; import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.LogLevelConstants; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.ByteArrayOutputStream; import java.io.IOException; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfXrefTableTest extends ExtendedITextTest { public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/kernel/pdf/PdfXrefTableTest/"; public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/kernel/pdf/PdfXrefTableTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(DESTINATION_FOLDER); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(DESTINATION_FOLDER); } @Test @LogMessages(messages = { - @LogMessage(messageTemplate = IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT, logLevel = LogLevelConstants.ERROR) + @LogMessage(messageTemplate = IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT_WITH_CAUSE + , logLevel = LogLevelConstants.ERROR) }) public void openInvalidDocWithHugeRefTest() { String inputFile = SOURCE_FOLDER + "invalidDocWithHugeRef.pdf"; @@ -74,29 +75,31 @@ public void checkIfXrefStructureExceedsTheLimit(int requestedCapacity) { @Test @LogMessages(messages = { - @LogMessage(messageTemplate = IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT, logLevel = LogLevelConstants.ERROR) + @LogMessage(messageTemplate = IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT_WITH_CAUSE + , logLevel = LogLevelConstants.ERROR) }) public void openInvalidDocWithHugeRefTestDefaultMemoryLimitAwareHandler() { String inputFile = SOURCE_FOLDER + "invalidDocWithHugeRef.pdf"; - Assert.assertThrows(MemoryLimitsAwareException.class,() -> + Assertions.assertThrows(MemoryLimitsAwareException.class,() -> new PdfDocument(new PdfReader(inputFile))); } @Test @LogMessages(messages = { - @LogMessage(messageTemplate = IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT, logLevel = LogLevelConstants.ERROR) + @LogMessage(messageTemplate = IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT_WITH_CAUSE + , logLevel = LogLevelConstants.ERROR) }) public void openWithWriterInvalidDocWithHugeRefTest() { String inputFile = SOURCE_FOLDER + "invalidDocWithHugeRef.pdf"; ByteArrayOutputStream outputStream = new com.itextpdf.io.source.ByteArrayOutputStream(); - Exception e = Assert.assertThrows(PdfException.class, () -> + Exception e = Assertions.assertThrows(PdfException.class, () -> new PdfDocument(new PdfReader(inputFile), new PdfWriter(outputStream))); - Assert.assertEquals(KernelExceptionMessageConstant.XREF_STRUCTURE_SIZE_EXCEEDED_THE_LIMIT, e.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.XREF_STRUCTURE_SIZE_EXCEEDED_THE_LIMIT, e.getMessage()); } @Test - public void testCreateAndUpdateXMP() throws IOException { + public void testCreateAndUpdateXMP() throws IOException, XMPException { String created = DESTINATION_FOLDER + "testCreateAndUpdateXMP_create.pdf"; String updated = DESTINATION_FOLDER + "testCreateAndUpdateXMP_update.pdf"; PdfDocument pdfDocument = new PdfDocument(CompareTool.createTestPdfWriter(created)); @@ -131,13 +134,13 @@ public void testCreateAndUpdateXMP() throws IOException { 0000000561 00000 n */ - Assert.assertTrue(freeRef.isFree()); - Assert.assertEquals(ref0.offsetOrIndex, freeRef.objNr); - Assert.assertEquals(1, freeRef.genNr); + Assertions.assertTrue(freeRef.isFree()); + Assertions.assertEquals(ref0.offsetOrIndex, freeRef.objNr); + Assertions.assertEquals(1, freeRef.genNr); } @Test - public void testCreateAndUpdateTwiceXMP() throws IOException { + public void testCreateAndUpdateTwiceXMP() throws IOException, XMPException { String created = DESTINATION_FOLDER + "testCreateAndUpdateTwiceXMP_create.pdf"; String updated = DESTINATION_FOLDER + "testCreateAndUpdateTwiceXMP_update.pdf"; String updatedAgain = DESTINATION_FOLDER + "testCreateAndUpdateTwiceXMP_updatedAgain.pdf"; @@ -184,12 +187,12 @@ public void testCreateAndUpdateTwiceXMP() throws IOException { 0000000561 00000 n */ - Assert.assertTrue(freeRef1.isFree()); - Assert.assertEquals(ref0.offsetOrIndex, freeRef1.objNr); - Assert.assertEquals(1, freeRef1.genNr); - Assert.assertTrue(freeRef2.isFree()); - Assert.assertEquals(freeRef1.offsetOrIndex, freeRef2.objNr); - Assert.assertEquals(1, freeRef2.genNr); + Assertions.assertTrue(freeRef1.isFree()); + Assertions.assertEquals(ref0.offsetOrIndex, freeRef1.objNr); + Assertions.assertEquals(1, freeRef1.genNr); + Assertions.assertTrue(freeRef2.isFree()); + Assertions.assertEquals(freeRef1.offsetOrIndex, freeRef2.objNr); + Assertions.assertEquals(1, freeRef2.genNr); pdfDocument.close(); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfXrefTableUnitTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfXrefTableUnitTest.java index 18428ea819..070b846126 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfXrefTableUnitTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/PdfXrefTableUnitTest.java @@ -29,18 +29,17 @@ This file is part of the iText (R) project. import com.itextpdf.test.AssertUtil; import com.itextpdf.test.ExceptionTestUtil; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfXrefTableUnitTest extends ExtendedITextTest { @Test public void checkNumberOfIndirectObjectsTest() { PdfXrefTable table = new PdfXrefTable(); - Assert.assertEquals(0, table.getCountOfIndirectObjects()); + Assertions.assertEquals(0, table.getCountOfIndirectObjects()); int numberOfReferences = 10; @@ -48,7 +47,7 @@ public void checkNumberOfIndirectObjectsTest() { table.add(new PdfIndirectReference(null, i + 1)); } - Assert.assertEquals(numberOfReferences, table.getCountOfIndirectObjects()); + Assertions.assertEquals(numberOfReferences, table.getCountOfIndirectObjects()); } @Test @@ -66,8 +65,8 @@ public void checkNumberOfIndirectObjectsWithFreeReferencesTest() { int freeReferenceNumber = 5; table.freeReference(table.get(freeReferenceNumber)); - Assert.assertEquals(numberOfReferences - 1, table.getCountOfIndirectObjects()); - Assert.assertTrue(table.get(freeReferenceNumber).isFree()); + Assertions.assertEquals(numberOfReferences - 1, table.getCountOfIndirectObjects()); + Assertions.assertTrue(table.get(freeReferenceNumber).isFree()); } @Test @@ -80,8 +79,8 @@ public void checkNumberOfIndirectObjectsWithRandomNumbersTest() { table.add(new PdfIndirectReference(null, i * 25)); } - Assert.assertEquals(numberOfReferences, table.getCountOfIndirectObjects()); - Assert.assertEquals(226, table.size()); + Assertions.assertEquals(numberOfReferences, table.getCountOfIndirectObjects()); + Assertions.assertEquals(226, table.size()); } @Test @@ -95,9 +94,9 @@ public void checkExceedTheNumberOfElementsInXrefTest() { xrefTable.add(new PdfIndirectReference(null, i)); } - Exception exception = Assert.assertThrows(MemoryLimitsAwareException.class, + Exception exception = Assertions.assertThrows(MemoryLimitsAwareException.class, () -> xrefTable.add(new PdfIndirectReference(null, numberOfReferences))); - Assert.assertEquals(KernelExceptionMessageConstant.XREF_STRUCTURE_SIZE_EXCEEDED_THE_LIMIT, + Assertions.assertEquals(KernelExceptionMessageConstant.XREF_STRUCTURE_SIZE_EXCEEDED_THE_LIMIT, exception.getMessage()); } @@ -109,9 +108,9 @@ public void ensureCapacityExceedTheLimitTest() { // There we add 2 instead of 1 since xref structures used 1-based indexes, so we decrement the capacity // before check. - Exception ex = Assert.assertThrows(MemoryLimitsAwareException.class, + Exception ex = Assertions.assertThrows(MemoryLimitsAwareException.class, () -> xrefTable.setCapacity(newCapacityExceededTheLimit)); - Assert.assertEquals(KernelExceptionMessageConstant.XREF_STRUCTURE_SIZE_EXCEEDED_THE_LIMIT, ex.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.XREF_STRUCTURE_SIZE_EXCEEDED_THE_LIMIT, ex.getMessage()); } @Test @@ -119,9 +118,9 @@ public void passCapacityGreaterThanLimitInConstructorTest() { final MemoryLimitsAwareHandler memoryLimitsAwareHandler = new MemoryLimitsAwareHandler(); memoryLimitsAwareHandler.setMaxNumberOfElementsInXrefStructure(20); - Exception ex = Assert.assertThrows(MemoryLimitsAwareException.class, + Exception ex = Assertions.assertThrows(MemoryLimitsAwareException.class, () -> new PdfXrefTable(30, memoryLimitsAwareHandler)); - Assert.assertEquals(KernelExceptionMessageConstant.XREF_STRUCTURE_SIZE_EXCEEDED_THE_LIMIT, ex.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.XREF_STRUCTURE_SIZE_EXCEEDED_THE_LIMIT, ex.getMessage()); } @Test @@ -130,7 +129,7 @@ public void zeroCapacityInConstructorWithHandlerTest() { memoryLimitsAwareHandler.setMaxNumberOfElementsInXrefStructure(20); final PdfXrefTable xrefTable = new PdfXrefTable(0, memoryLimitsAwareHandler); - Assert.assertEquals(20, xrefTable.getCapacity()); + Assertions.assertEquals(20, xrefTable.getCapacity()); } @Test @@ -138,10 +137,10 @@ public void xRefMaxValueLong() { PdfDocument document = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); document.xref.add(new PdfIndirectReferenceProxy(document, 11, Long.MAX_VALUE)); - Exception e = Assert.assertThrows(PdfException.class, () -> { + Exception e = Assertions.assertThrows(PdfException.class, () -> { document.close(); }); - Assert.assertEquals(KernelExceptionMessageConstant.XREF_HAS_AN_ENTRY_WITH_TOO_BIG_OFFSET, e.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.XREF_HAS_AN_ENTRY_WITH_TOO_BIG_OFFSET, e.getMessage()); } @@ -151,10 +150,10 @@ public void maxCrossReferenceOffSetReached() { PdfDocument document = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); document.xref.add(new PdfIndirectReferenceProxy(document, 11, justOver10gbLogical)); - Exception e = Assert.assertThrows(PdfException.class, () -> { + Exception e = Assertions.assertThrows(PdfException.class, () -> { document.close(); }); - Assert.assertEquals(KernelExceptionMessageConstant.XREF_HAS_AN_ENTRY_WITH_TOO_BIG_OFFSET, e.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.XREF_HAS_AN_ENTRY_WITH_TOO_BIG_OFFSET, e.getMessage()); } @Test @@ -163,10 +162,10 @@ public void maxCrossReference() { PdfDocument document = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); document.xref.add(new PdfIndirectReferenceProxy(document, 11, justOver10gbLogical)); - Exception e = Assert.assertThrows(PdfException.class, () -> { + Exception e = Assertions.assertThrows(PdfException.class, () -> { document.close(); }); - Assert.assertEquals(KernelExceptionMessageConstant.XREF_HAS_AN_ENTRY_WITH_TOO_BIG_OFFSET, e.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.XREF_HAS_AN_ENTRY_WITH_TOO_BIG_OFFSET, e.getMessage()); } @Test diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/ReaderPropertiesTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/ReaderPropertiesTest.java new file mode 100644 index 0000000000..a817ad458f --- /dev/null +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/ReaderPropertiesTest.java @@ -0,0 +1,51 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.pdf; + +import com.itextpdf.test.ExtendedITextTest; + +import java.nio.charset.StandardCharsets; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +@Tag("UnitTest") +public class ReaderPropertiesTest extends ExtendedITextTest { + + @Test + public void copyConstructorTest() { + MemoryLimitsAwareHandler handler = new MemoryLimitsAwareHandler(); + handler.setMaxXObjectsSizePerPage(10); + ReaderProperties properties = new ReaderProperties().setPassword("123".getBytes(StandardCharsets.ISO_8859_1)) + .setMemoryLimitsAwareHandler(handler); + + ReaderProperties copy = new ReaderProperties(properties); + + Assertions.assertArrayEquals(copy.password, properties.password); + + Assertions.assertNotEquals(copy.memoryLimitsAwareHandler, properties.memoryLimitsAwareHandler); + Assertions.assertEquals(copy.memoryLimitsAwareHandler.getMaxXObjectsSizePerPage(), + properties.memoryLimitsAwareHandler.getMaxXObjectsSizePerPage()); + Assertions.assertEquals(10, copy.memoryLimitsAwareHandler.getMaxXObjectsSizePerPage()); + } +} diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/ReorderPagesTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/ReorderPagesTest.java index a240f57d6e..1ff55c1f8c 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/ReorderPagesTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/ReorderPagesTest.java @@ -24,32 +24,31 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import org.xml.sax.SAXException; import javax.xml.parsers.ParserConfigurationException; import java.io.IOException; import java.util.Arrays; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class ReorderPagesTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/kernel/pdf/ReorderPagesTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/kernel/pdf/ReorderPagesTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(destinationFolder); } @@ -124,7 +123,7 @@ private void compare(String outPath, String cmpPath, String destinationFolder, S if (contentErrors != null) { resultMessage += contentErrors + "\n"; } - assertTrue(resultMessage, tagStructureErrors == null && contentErrors == null); + assertTrue(tagStructureErrors == null && contentErrors == null, resultMessage); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/SmartModePdfObjectsSerializerTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/SmartModePdfObjectsSerializerTest.java index f60cd829f5..a17737294b 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/SmartModePdfObjectsSerializerTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/SmartModePdfObjectsSerializerTest.java @@ -23,15 +23,14 @@ This file is part of the iText (R) project. package com.itextpdf.kernel.pdf; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.ByteArrayOutputStream; import java.nio.charset.StandardCharsets; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class SmartModePdfObjectsSerializerTest extends ExtendedITextTest { @Test @@ -66,6 +65,6 @@ public void smartModeObjectSelfReferencingTest() { SerializedObjectContent expected = new SerializedObjectContent( stringBytes.toString().getBytes(StandardCharsets.UTF_8)); - Assert.assertEquals(expected, serializedObject); + Assertions.assertEquals(expected, serializedObject); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/SmartModeTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/SmartModeTest.java index 1af703bfc4..fbf9ce292d 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/SmartModeTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/SmartModeTest.java @@ -30,26 +30,25 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.xobject.PdfFormXObject; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class SmartModeTest extends ExtendedITextTest { public static final String destinationFolder = "./target/test/com/itextpdf/kernel/pdf/SmartModeTest/"; public static final String sourceFolder = "./src/test/resources/com/itextpdf/kernel/pdf/SmartModeTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(destinationFolder); } @@ -83,11 +82,11 @@ public void smartModeSameResourcesCopyingAndFlushing() throws IOException, Inter PdfIndirectReference page3ResFontObj = assertDoc.getPage(3).getPdfObject().getAsDictionary(PdfName.Resources) .getAsDictionary(PdfName.Font).getIndirectReference(); - Assert.assertTrue(page1ResFontObj.equals(page2ResFontObj)); - Assert.assertTrue(page1ResFontObj.equals(page3ResFontObj)); + Assertions.assertTrue(page1ResFontObj.equals(page2ResFontObj)); + Assertions.assertTrue(page1ResFontObj.equals(page3ResFontObj)); assertDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFile, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFile, destinationFolder)); } @Test @@ -116,7 +115,7 @@ public void smartModeSameResourcesCopyingModifyingAndFlushing() throws IOExcepti } catch (NullPointerException expected) { // Smart mode makes it possible to share objects coming from different source documents. // Flushing one object documents might make it impossible to modify further copied objects. - Assert.assertEquals(2, i); + Assertions.assertEquals(2, i); exceptionCaught = true; break; } @@ -132,7 +131,7 @@ public void smartModeSameResourcesCopyingModifyingAndFlushing() throws IOExcepti } if (!exceptionCaught) { - Assert.fail(); + Assertions.fail(); } } @@ -193,12 +192,12 @@ public void smartModeSameResourcesCopyingModifyingAndFlushing_ensureObjectFresh( PdfIndirectReference page3ResFontObj = assertDoc.getPage(3).getPdfObject().getAsDictionary(PdfName.Resources) .getAsDictionary(PdfName.Font).getIndirectReference(); - Assert.assertFalse(page1ResFontObj.equals(page2ResFontObj)); - Assert.assertFalse(page1ResFontObj.equals(page3ResFontObj)); - Assert.assertFalse(page2ResFontObj.equals(page3ResFontObj)); + Assertions.assertFalse(page1ResFontObj.equals(page2ResFontObj)); + Assertions.assertFalse(page1ResFontObj.equals(page3ResFontObj)); + Assertions.assertFalse(page2ResFontObj.equals(page3ResFontObj)); assertDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFile, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFile, destinationFolder)); } @Test @@ -224,7 +223,7 @@ public void pageCopyAsFormXObjectWithInheritedResourcesTest() throws IOException copyPdfX.close(); origPdf.close(); - Assert.assertNull(new CompareTool().compareByContent(destFile, cmpFile, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(destFile, cmpFile, destinationFolder)); } @Test @@ -249,10 +248,10 @@ public void smartModeSameImageResourcesTest() throws IOException, InterruptedExc .getAsDictionary(PdfName.XObject) .getAsStream(new PdfName("Im0")).getIndirectReference(); - Assert.assertEquals(page1ImgRes, page2ImgRes); + Assertions.assertEquals(page1ImgRes, page2ImgRes); } - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFile, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFile, destinationFolder)); } @Test @@ -283,7 +282,7 @@ public void smartModeSameColorSpaceResourcesTest() throws IOException, Interrupt // It's expected that indirect arrays are not processed by smart mode. // Smart mode only merges duplicate dictionaries and streams. - Assert.assertEquals(page1CsRes, page2CsRes); + Assertions.assertEquals(page1CsRes, page2CsRes); PdfIndirectReference page1CsStm = newDoc.getPage(1).getPdfObject() .getAsDictionary(PdfName.Resources) @@ -295,10 +294,10 @@ public void smartModeSameColorSpaceResourcesTest() throws IOException, Interrupt .getAsDictionary(PdfName.ColorSpace).getAsArray(new PdfName("CS0")) .getAsStream(1).getIndirectReference(); - Assert.assertEquals(page1CsStm, page2CsStm); + Assertions.assertEquals(page1CsStm, page2CsStm); } - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFile, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFile, destinationFolder)); } @Test @@ -325,10 +324,10 @@ public void smartModeSameExtGStateResourcesTest() throws IOException, Interrupte .getAsDictionary(PdfName.ExtGState) .getAsDictionary(new PdfName("Gs1")).getIndirectReference(); - Assert.assertEquals(page1GsRes, page2GsRes); + Assertions.assertEquals(page1GsRes, page2GsRes); } - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFile, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFile, destinationFolder)); } @Test @@ -344,12 +343,12 @@ public void smartModeCopyingInTaggedPdfTest() throws IOException, InterruptedExc pdfSrc.copyPagesTo(1, pdfSrc.getNumberOfPages(), pdfDest); } - Assert.assertNotNull(pdfDest.getStructTreeRoot() + Assertions.assertNotNull(pdfDest.getStructTreeRoot() .getKidsObject().getAsDictionary(0).getAsArray(PdfName.K) .getAsDictionary(0).get(PdfName.K)); } - Assert.assertNull(new CompareTool().compareByContent(dstFile, cmpFile, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(dstFile, cmpFile, destinationFolder)); } @Test @@ -372,12 +371,12 @@ public void smartModeCopyingInPdfWithIdenticalPagesTaggedTest() throws IOExcepti for (int i = 2; i <= 10; i++) { PdfIndirectReference pageObj = pdfDest.getPage(i).getPdfObject().getIndirectReference(); - Assert.assertNotEquals(expectedPageObj, pageObj); + Assertions.assertNotEquals(expectedPageObj, pageObj); PdfIndirectReference pageContentStm = pdfDest.getPage(i).getPdfObject() .getAsStream(PdfName.Contents).getIndirectReference(); - Assert.assertEquals(expectedContStm, pageContentStm); + Assertions.assertEquals(expectedContStm, pageContentStm); } } } @@ -401,12 +400,12 @@ public void smartModeCopyingInPdfWithIdenticalPagesTest() throws IOException { for (int i = 2; i <= 10; i++) { PdfIndirectReference pageObj = pdfDest.getPage(i).getPdfObject().getIndirectReference(); - Assert.assertNotEquals(expectedPageObj, pageObj); + Assertions.assertNotEquals(expectedPageObj, pageObj); PdfIndirectReference pageContentStm = pdfDest.getPage(i).getPdfObject() .getAsStream(PdfName.Contents).getIndirectReference(); - Assert.assertEquals(expectedContStm, pageContentStm); + Assertions.assertEquals(expectedContStm, pageContentStm); } } } @@ -433,7 +432,7 @@ public void smartModeCopyingInPdfSamePagesDifferentXObjectsTest() throws IOExcep .getAsDictionary(PdfName.XObject) .getAsStream(new PdfName("Im1")).getIndirectReference(); - Assert.assertEquals(expectedImgRes, pagesImgRes); + Assertions.assertEquals(expectedImgRes, pagesImgRes); } } } @@ -456,7 +455,7 @@ public void smartCopyingOfArrayWithStringsTest() throws IOException { .getAsDictionary(new PdfName("Key2")).getIndirectReference(); // Currently smart mode copying doesn't affect any other objects except streams and dictionaries - Assert.assertNotEquals(key1Ref, key2Ref); + Assertions.assertNotEquals(key1Ref, key2Ref); } } @@ -496,9 +495,9 @@ public void smartCopyingOfNestedIndirectDictionariesTest() throws IOException { .getAsArray(new PdfName("Key3")).getIndirectReference(); // Currently smart mode copying doesn't affect any other objects except streams and dictionaries - Assert.assertEquals(key1Page1Ref, key1Page2Ref); - Assert.assertEquals(key2Page1Ref, key2Page2Ref); - Assert.assertEquals(key3Page1Ref, key3Page2Ref); + Assertions.assertEquals(key1Page1Ref, key1Page2Ref); + Assertions.assertEquals(key2Page1Ref, key2Page2Ref); + Assertions.assertEquals(key3Page1Ref, key3Page2Ref); } } @@ -521,7 +520,7 @@ public void smartModeSeparatedOutlinesCopyingTest() throws IOException, Interrup } } - Assert.assertNull(new CompareTool().compareByContent(dstFile, cmpFile, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(dstFile, cmpFile, destinationFolder)); } @Test @@ -546,7 +545,7 @@ public void smartModeCopyingInPdfWithLinksOnOnePageTest() throws IOException { .getAsDictionary(PdfName.XObject) .getAsStream(new PdfName("Im1")).getIndirectReference(); - Assert.assertEquals(expectedImgRes, pagesImgRes); + Assertions.assertEquals(expectedImgRes, pagesImgRes); } } } @@ -573,7 +572,7 @@ public void smartModeCopyingInPdfWithDiffImagesTest() throws IOException { .getAsDictionary(PdfName.XObject) .getAsStream(new PdfName("Im1")).getIndirectReference(); - Assert.assertNotEquals(expectedImgRes, pagesImgRes); + Assertions.assertNotEquals(expectedImgRes, pagesImgRes); } } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/TagTreePointerTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/TagTreePointerTest.java index fd2ecb3fbd..ca8249cc0e 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/TagTreePointerTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/TagTreePointerTest.java @@ -45,7 +45,6 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import com.itextpdf.test.ExtendedITextTest; import java.io.ByteArrayInputStream; @@ -55,27 +54,27 @@ This file is part of the iText (R) project. import java.nio.charset.StandardCharsets; import java.util.List; import javax.xml.parsers.ParserConfigurationException; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import org.xml.sax.SAXException; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class TagTreePointerTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/kernel/pdf/TagTreePointerTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/kernel/pdf/TagTreePointerTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(destinationFolder); } @@ -355,12 +354,12 @@ public void tagTreePointerTest08() throws Exception { TagTreePointer pointer = new TagTreePointer(document); AccessibilityProperties properties = pointer.moveToKid(StandardRoles.DIV).getProperties(); String language = properties.getLanguage(); - Assert.assertEquals("en-Us", language); + Assertions.assertEquals("en-Us", language); properties.setLanguage("EN-GB"); pointer.moveToRoot().moveToKid(2, StandardRoles.P).getProperties().setRole(StandardRoles.H6); String role = pointer.getProperties().getRole(); - Assert.assertEquals("H6", role); + Assertions.assertEquals("H6", role); document.close(); compareResult("tagTreePointerTest08.pdf", "cmp_tagTreePointerTest08.pdf", "diff08_"); @@ -377,18 +376,18 @@ public void changeExistedBackedAccessibilityPropertiesTest() throws Exception { AccessibilityProperties properties = pointer.moveToKid(StandardRoles.DIV).getProperties(); String altDescription = "Alternate Description"; properties.setAlternateDescription(altDescription); - Assert.assertEquals(altDescription, properties.getAlternateDescription()); + Assertions.assertEquals(altDescription, properties.getAlternateDescription()); String expansion = "expansion"; properties.setExpansion(expansion); - Assert.assertEquals(expansion, properties.getExpansion()); + Assertions.assertEquals(expansion, properties.getExpansion()); properties.setNamespace(new PdfNamespace(StandardNamespaces.PDF_2_0)); - Assert.assertEquals(StandardNamespaces.PDF_2_0, properties.getNamespace().getNamespaceName()); + Assertions.assertEquals(StandardNamespaces.PDF_2_0, properties.getNamespace().getNamespaceName()); String phoneme = "phoneme"; properties.setPhoneme(phoneme); - Assert.assertEquals(phoneme, properties.getPhoneme()); + Assertions.assertEquals(phoneme, properties.getPhoneme()); String phoneticAlphabet = "Phonetic Alphabet"; properties.setPhoneticAlphabet(phoneticAlphabet); - Assert.assertEquals(phoneticAlphabet, properties.getPhoneticAlphabet()); + Assertions.assertEquals(phoneticAlphabet, properties.getPhoneticAlphabet()); document.close(); @@ -405,14 +404,14 @@ public void removeExistedBackedAccessibilityPropertiesTest() throws Exception { TagTreePointer pointer = new TagTreePointer(document); AccessibilityProperties properties = pointer.moveToKid(StandardRoles.DIV).getProperties(); - Assert.assertNotNull(properties.getAttributesList()); - Assert.assertNotNull(properties.addAttributes(0, null)); + Assertions.assertNotNull(properties.getAttributesList()); + Assertions.assertNotNull(properties.addAttributes(0, null)); properties.clearAttributes(); - Assert.assertTrue(properties.getAttributesList().isEmpty()); + Assertions.assertTrue(properties.getAttributesList().isEmpty()); properties.addRef(pointer); - Assert.assertFalse(properties.getRefsList().isEmpty()); + Assertions.assertFalse(properties.getRefsList().isEmpty()); properties.clearRefs(); - Assert.assertTrue(properties.getRefsList().isEmpty()); + Assertions.assertTrue(properties.getRefsList().isEmpty()); document.close(); @@ -430,29 +429,29 @@ public void setDefaultAccessibilityPropertiesTest() throws Exception { TagTreePointer pointer = new TagTreePointer(document); AccessibilityProperties properties = new DefaultAccessibilityProperties(StandardRoles.DIV); properties.setRole(StandardRoles.H6); - Assert.assertEquals(StandardRoles.H6, properties.getRole()); + Assertions.assertEquals(StandardRoles.H6, properties.getRole()); String actualText = "Test text"; properties.setActualText(actualText); - Assert.assertEquals(actualText, properties.getActualText()); + Assertions.assertEquals(actualText, properties.getActualText()); String language = "EN-GB"; properties.setLanguage(language); - Assert.assertEquals(language, properties.getLanguage()); + Assertions.assertEquals(language, properties.getLanguage()); String alternateDescription = "Alternate Description"; properties.setAlternateDescription(alternateDescription); - Assert.assertEquals(alternateDescription, properties.getAlternateDescription()); + Assertions.assertEquals(alternateDescription, properties.getAlternateDescription()); String expansion = "expansion"; properties.setExpansion(expansion); - Assert.assertEquals(expansion, properties.getExpansion()); + Assertions.assertEquals(expansion, properties.getExpansion()); properties.setNamespace(new PdfNamespace(StandardNamespaces.PDF_2_0)); - Assert.assertEquals(StandardNamespaces.PDF_2_0, properties.getNamespace().getNamespaceName()); + Assertions.assertEquals(StandardNamespaces.PDF_2_0, properties.getNamespace().getNamespaceName()); String phoneme = "phoneme"; properties.setPhoneme(phoneme); - Assert.assertEquals(phoneme, properties.getPhoneme()); + Assertions.assertEquals(phoneme, properties.getPhoneme()); String phoneticAlphabet = "phoneticAlphabet"; properties.setPhoneticAlphabet(phoneticAlphabet); - Assert.assertEquals(phoneticAlphabet, properties.getPhoneticAlphabet()); + Assertions.assertEquals(phoneticAlphabet, properties.getPhoneticAlphabet()); properties.addRef(pointer); - Assert.assertFalse(properties.getRefsList().isEmpty()); + Assertions.assertFalse(properties.getRefsList().isEmpty()); pointer.addTag(properties); document.close(); @@ -476,11 +475,11 @@ public void removeDefaultAccessibilityPropertiesTest() throws Exception { properties.addAttributes(1, testAttr); properties.getAttributesList(); properties.clearAttributes(); - Assert.assertTrue(properties.getAttributesList().isEmpty()); + Assertions.assertTrue(properties.getAttributesList().isEmpty()); properties.addRef(pointer); - Assert.assertFalse(properties.getRefsList().isEmpty()); + Assertions.assertFalse(properties.getRefsList().isEmpty()); properties.clearRefs(); - Assert.assertTrue(properties.getRefsList().isEmpty()); + Assertions.assertTrue(properties.getRefsList().isEmpty()); pointer.addTag(properties); document.close(); @@ -1194,9 +1193,9 @@ public void accessibleAttributesInsertionTest01() throws IOException, Interrupte try { properties.addAttributes(10, testAttr); - Assert.fail(); + Assertions.fail(); } catch (Exception e) { - Assert.assertTrue(ExceptionUtil.isOutOfRange(e)); + Assertions.assertTrue(ExceptionUtil.isOutOfRange(e)); } document.close(); @@ -1301,35 +1300,35 @@ public void accessibleAttributesInsertionTest05() throws IOException, Interrupte try { // 1 attribute array pointer.moveToKid(1).getProperties().addAttributes(5, new PdfStructureAttributes(testAttrDict)); - Assert.fail(); + Assertions.fail(); } catch (Exception e) { - Assert.assertTrue(ExceptionUtil.isOutOfRange(e)); + Assertions.assertTrue(ExceptionUtil.isOutOfRange(e)); } pointer.moveToRoot(); try { // 3 attributes pointer.moveToKid(2).getProperties().addAttributes(5, new PdfStructureAttributes(testAttrDict)); - Assert.fail(); + Assertions.fail(); } catch (Exception e) { - Assert.assertTrue(ExceptionUtil.isOutOfRange(e)); + Assertions.assertTrue(ExceptionUtil.isOutOfRange(e)); } pointer.moveToRoot(); try { // 1 attribute dictionary pointer.moveToKid(0).moveToKid(StandardRoles.LI).moveToKid(StandardRoles.LBODY).getProperties().addAttributes(5, new PdfStructureAttributes(testAttrDict)); - Assert.fail(); + Assertions.fail(); } catch (Exception e) { - Assert.assertTrue(ExceptionUtil.isOutOfRange(e)); + Assertions.assertTrue(ExceptionUtil.isOutOfRange(e)); } try { // no attributes pointer.moveToKid(StandardRoles.P).moveToKid(StandardRoles.SPAN).getProperties().addAttributes(5, new PdfStructureAttributes(testAttrDict)); - Assert.fail(); + Assertions.fail(); } catch (Exception e) { - Assert.assertTrue(ExceptionUtil.isOutOfRange(e)); + Assertions.assertTrue(ExceptionUtil.isOutOfRange(e)); } document.close(); diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/TrailerTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/TrailerTest.java index 482f36369b..ddcb00688d 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/TrailerTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/TrailerTest.java @@ -27,26 +27,27 @@ This file is part of the iText (R) project. import com.itextpdf.commons.utils.MessageFormatUtil; import com.itextpdf.kernel.actions.data.ITextCoreProductData; import com.itextpdf.kernel.font.PdfFontFactory; +import com.itextpdf.kernel.logs.KernelLogMessageConstant; import com.itextpdf.kernel.pdf.canvas.PdfCanvas; -import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; -import java.io.FileOutputStream; import java.io.IOException; import java.io.RandomAccessFile; import java.util.HashMap; import java.util.Map.Entry; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; -@Category(IntegrationTest.class) +import com.itextpdf.test.annotations.LogMessage; +import com.itextpdf.test.annotations.LogMessages; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; + +@Tag("IntegrationTest") public class TrailerTest extends ExtendedITextTest { private ProductData productData; @@ -54,12 +55,12 @@ public class TrailerTest extends ExtendedITextTest { private static final byte[] USERPASS = "user".getBytes(); private static final byte[] OWNERPASS = "owner".getBytes(); - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } - @Before + @BeforeEach public void beforeTest() { this.productData = new ProductData("pdfProduct", "pdfProduct", "1.0.0", 1900, 2000); } @@ -77,7 +78,7 @@ public void trailerFingerprintTest() throws IOException { pdf.close(); - Assert.assertTrue(doesTrailerContainFingerprint(new File(destinationFolder + "output.pdf"), MessageFormatUtil + Assertions.assertTrue(doesTrailerContainFingerprint(new File(destinationFolder + "output.pdf"), MessageFormatUtil .format("%iText-{0}-{1}\n", productData.getProductName(), productData.getVersion()))); } @@ -101,8 +102,8 @@ public void existingTrailerValuesTest() throws IOException { boolean keyPresent = trailer.containsKey(expectedKey); PdfName actualValue = trailer.getAsName(expectedKey); stampingDocument.close(); - Assert.assertTrue(keyPresent); - Assert.assertEquals(expectedValue, actualValue); + Assertions.assertTrue(keyPresent); + Assertions.assertEquals(expectedValue, actualValue); } } @@ -133,8 +134,8 @@ public void existingTrailerValuesTestWithEncryption() throws IOException { stampingDocument.close(); - Assert.assertTrue(keyPresent); - Assert.assertEquals(expectedValue, actualValue); + Assertions.assertTrue(keyPresent); + Assertions.assertEquals(expectedValue, actualValue); } } @@ -164,13 +165,53 @@ public void existingTrailerValuesWithStandardizedNameTest() throws IOException { PdfName pdfName2 = entry.getValue(); boolean keyPresent = trailer.containsKey(pdfName); PdfName actualValue = trailer.getAsName(pdfName); - Assert.assertTrue(keyPresent); - Assert.assertEquals(pdfName2, actualValue); + Assertions.assertTrue(keyPresent); + Assertions.assertEquals(pdfName2, actualValue); } stampingDocument.close(); } } + @Test + public void enableFingerprintInAGPLModeTest() throws IOException { + PdfDocument pdf = new PdfDocument(new PdfWriter( + destinationFolder + "enableFingerprintInAGPLMode.pdf")); + pdf.registerProduct(this.productData); + PdfPage page = pdf.addNewPage(); + PdfCanvas canvas = new PdfCanvas(page); + canvas.beginText() + .setFontAndSize(PdfFontFactory.createFont(), 12f) + .showText("Hello World") + .endText(); + pdf.close(); + + Assertions.assertTrue(doesTrailerContainFingerprint(new File( + destinationFolder + "enableFingerprintInAGPLMode.pdf"), MessageFormatUtil.format( + "%iText-{0}-{1}\n", productData.getProductName(), productData.getVersion()))); + } + + @Test + @LogMessages(messages = @LogMessage(messageTemplate = + KernelLogMessageConstant.FINGERPRINT_DISABLED_BUT_NO_REQUIRED_LICENCE)) + public void tryDisablingFingerprintInAGPLModeTest() throws IOException { + PdfDocument pdf = new PdfDocument(new PdfWriter( + destinationFolder + "tryDisablingFingerprintInAGPLMode.pdf")); + pdf.registerProduct(this.productData); + PdfPage page = pdf.addNewPage(); + PdfCanvas canvas = new PdfCanvas(page); + canvas.beginText() + .setFontAndSize(PdfFontFactory.createFont(), 12f) + .showText("Hello World") + .endText(); + pdf.getFingerPrint().disableFingerPrint(); + pdf.close(); + + + Assertions.assertTrue(doesTrailerContainFingerprint(new File( + destinationFolder + "tryDisablingFingerprintInAGPLMode.pdf"), MessageFormatUtil.format( + "%iText-{0}-{1}\n", productData.getProductName(), productData.getVersion()))); + } + private boolean doesTrailerContainFingerprint(File file, String fingerPrint) throws IOException { try (RandomAccessFile raf = FileUtil.getRandomAccessFile(file)) { @@ -182,6 +223,10 @@ private boolean doesTrailerContainFingerprint(File file, String fingerPrint) thr String templine = ""; while (!templine.contains(coreProductData)) { + if (raf.getFilePointer() <= 2) { + return false; + } + templine = (char) raf.read() + templine; raf.seek(raf.getFilePointer() - 2); } @@ -191,6 +236,10 @@ private boolean doesTrailerContainFingerprint(File file, String fingerPrint) thr templine = ""; while (read != '%') { + if (raf.getFilePointer() <= 2) { + return false; + } + read = (char) raf.read(); templine = read + templine; raf.seek(raf.getFilePointer() - 2); diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/XMPMetadataTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/XMPMetadataTest.java index 3d9bfb4dfc..d8358503e9 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/XMPMetadataTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/XMPMetadataTest.java @@ -34,39 +34,38 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.nio.charset.StandardCharsets; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -@Category(IntegrationTest.class) +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +@Tag("IntegrationTest") public class XMPMetadataTest extends ExtendedITextTest{ - public static final String sourceFolder = "./src/test/resources/com/itextpdf/kernel/pdf/XmpWriterTest/"; - public static final String destinationFolder = "./target/test/com/itextpdf/kernel/pdf/XmpWriterTest/"; + public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/kernel/pdf/XmpWriterTest/"; + public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/kernel/pdf/XmpWriterTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { - createOrClearDestinationFolder(destinationFolder); + createOrClearDestinationFolder(DESTINATION_FOLDER); } - @AfterClass + @AfterAll public static void afterClass() { - CompareTool.cleanup(destinationFolder); + CompareTool.cleanup(DESTINATION_FOLDER); } @Test public void createEmptyDocumentWithXmp() throws Exception { String filename = "emptyDocumentWithXmp.pdf"; - PdfWriter writer = CompareTool.createTestPdfWriter(destinationFolder + filename, new WriterProperties().addXmpMetadata()); + PdfWriter writer = CompareTool.createTestPdfWriter(DESTINATION_FOLDER + filename, new WriterProperties().addXmpMetadata()); PdfDocument pdfDoc = new PdfDocument(writer); pdfDoc.getDocumentInfo().setAuthor("Alexander Chingarev"). setCreator("iText"). @@ -76,25 +75,25 @@ public void createEmptyDocumentWithXmp() throws Exception { PdfPage page = pdfDoc.addNewPage(); page.flush(); pdfDoc.close(); - PdfReader reader = CompareTool.createOutputReader(destinationFolder + filename); + PdfReader reader = CompareTool.createOutputReader(DESTINATION_FOLDER + filename); PdfDocument pdfDocument = new PdfDocument(reader); - Assert.assertEquals("Rebuilt", false, reader.hasRebuiltXref()); - byte[] outBytes = pdfDocument.getXmpMetadata(); + Assertions.assertEquals(false, reader.hasRebuiltXref(), "Rebuilt"); + byte[] outBytes = pdfDocument.getXmpMetadataBytes(); pdfDocument.close(); - byte[] cmpBytes = readFile(sourceFolder + "emptyDocumentWithXmp.xml"); + byte[] cmpBytes = readFile(SOURCE_FOLDER + "emptyDocumentWithXmp.xml"); cmpBytes = removeAlwaysDifferentEntries(cmpBytes); outBytes = removeAlwaysDifferentEntries(outBytes); - Assert.assertTrue(new CompareTool().compareXmls(outBytes, cmpBytes)); + Assertions.assertTrue(new CompareTool().compareXmls(outBytes, cmpBytes)); } @Test public void emptyDocumentWithXmpAppendMode01() throws Exception { - String created = destinationFolder + "emptyDocumentWithXmpAppendMode01.pdf"; - String updated = destinationFolder + "emptyDocumentWithXmpAppendMode01_updated.pdf"; - String updatedAgain = destinationFolder + "emptyDocumentWithXmpAppendMode01_updatedAgain.pdf"; + String created = DESTINATION_FOLDER + "emptyDocumentWithXmpAppendMode01.pdf"; + String updated = DESTINATION_FOLDER + "emptyDocumentWithXmpAppendMode01_updated.pdf"; + String updatedAgain = DESTINATION_FOLDER + "emptyDocumentWithXmpAppendMode01_updatedAgain.pdf"; PdfDocument pdfDocument = new PdfDocument(CompareTool.createTestPdfWriter(created)); pdfDocument.addNewPage(); @@ -110,30 +109,30 @@ public void emptyDocumentWithXmpAppendMode01() throws Exception { PdfReader reader = CompareTool.createOutputReader(updatedAgain); pdfDocument = new PdfDocument(reader); - Assert.assertEquals("Rebuilt", false, reader.hasRebuiltXref()); - Assert.assertNotNull(pdfDocument.getCatalog().getPdfObject().getAsStream(PdfName.Metadata)); + Assertions.assertEquals(false, reader.hasRebuiltXref(), "Rebuilt"); + Assertions.assertNotNull(pdfDocument.getCatalog().getPdfObject().getAsStream(PdfName.Metadata)); PdfIndirectReference metadataRef = pdfDocument.getCatalog().getPdfObject().getAsStream(PdfName.Metadata).getIndirectReference(); - Assert.assertEquals(6, metadataRef.getObjNumber()); - Assert.assertEquals(0, metadataRef.getGenNumber()); + Assertions.assertEquals(6, metadataRef.getObjNumber()); + Assertions.assertEquals(0, metadataRef.getGenNumber()); - byte[] outBytes = pdfDocument.getXmpMetadata(); + byte[] outBytes = pdfDocument.getXmpMetadataBytes(); pdfDocument.close(); - byte[] cmpBytes = readFile(sourceFolder + "emptyDocumentWithXmpAppendMode01.xml"); + byte[] cmpBytes = readFile(SOURCE_FOLDER + "emptyDocumentWithXmpAppendMode01.xml"); cmpBytes = removeAlwaysDifferentEntries(cmpBytes); outBytes = removeAlwaysDifferentEntries(outBytes); - Assert.assertTrue(new CompareTool().compareXmls(outBytes, cmpBytes)); + Assertions.assertTrue(new CompareTool().compareXmls(outBytes, cmpBytes)); } @Test public void emptyDocumentWithXmpAppendMode02() throws Exception { - String created = destinationFolder + "emptyDocumentWithXmpAppendMode02.pdf"; - String updated = destinationFolder + "emptyDocumentWithXmpAppendMode02_updated.pdf"; - String updatedAgain = destinationFolder + "emptyDocumentWithXmpAppendMode02_updatedAgain.pdf"; + String created = DESTINATION_FOLDER + "emptyDocumentWithXmpAppendMode02.pdf"; + String updated = DESTINATION_FOLDER + "emptyDocumentWithXmpAppendMode02_updated.pdf"; + String updatedAgain = DESTINATION_FOLDER + "emptyDocumentWithXmpAppendMode02_updatedAgain.pdf"; PdfDocument pdfDocument = new PdfDocument(CompareTool.createTestPdfWriter(created)); pdfDocument.addNewPage(); pdfDocument.close(); @@ -149,29 +148,29 @@ public void emptyDocumentWithXmpAppendMode02() throws Exception { PdfReader reader = CompareTool.createOutputReader(updatedAgain); pdfDocument = new PdfDocument(reader); - Assert.assertEquals("Rebuilt", false, reader.hasRebuiltXref()); - Assert.assertNotNull(pdfDocument.getCatalog().getPdfObject().getAsStream(PdfName.Metadata)); + Assertions.assertEquals(false, reader.hasRebuiltXref(), "Rebuilt"); + Assertions.assertNotNull(pdfDocument.getCatalog().getPdfObject().getAsStream(PdfName.Metadata)); PdfIndirectReference metadataRef = pdfDocument.getCatalog().getPdfObject().getAsStream(PdfName.Metadata).getIndirectReference(); - Assert.assertEquals(6, metadataRef.getObjNumber()); - Assert.assertEquals(0, metadataRef.getGenNumber()); + Assertions.assertEquals(6, metadataRef.getObjNumber()); + Assertions.assertEquals(0, metadataRef.getGenNumber()); - byte[] outBytes = pdfDocument.getXmpMetadata(); + byte[] outBytes = pdfDocument.getXmpMetadataBytes(); pdfDocument.close(); - byte[] cmpBytes = readFile(sourceFolder + "emptyDocumentWithXmpAppendMode02.xml"); + byte[] cmpBytes = readFile(SOURCE_FOLDER + "emptyDocumentWithXmpAppendMode02.xml"); cmpBytes = removeAlwaysDifferentEntries(cmpBytes); outBytes = removeAlwaysDifferentEntries(outBytes); - Assert.assertTrue(new CompareTool().compareXmls(outBytes, cmpBytes)); + Assertions.assertTrue(new CompareTool().compareXmls(outBytes, cmpBytes)); } @Test @LogMessages(messages = { - @LogMessage(messageTemplate = IoLogMessageConstant.EXCEPTION_WHILE_UPDATING_XMPMETADATA) + @LogMessage(messageTemplate = IoLogMessageConstant.EXCEPTION_WHILE_UPDATING_XMPMETADATA, count = 2) }) public void createEmptyDocumentWithAbcXmp() throws IOException { ByteArrayOutputStream fos = new ByteArrayOutputStream(); @@ -189,15 +188,15 @@ public void createEmptyDocumentWithAbcXmp() throws IOException { PdfReader reader = new PdfReader(new ByteArrayInputStream(fos.toByteArray())); PdfDocument pdfDocument = new PdfDocument(reader); - Assert.assertEquals("Rebuilt", false, reader.hasRebuiltXref()); - Assert.assertArrayEquals("abc".getBytes(StandardCharsets.ISO_8859_1), pdfDocument.getXmpMetadata()); - Assert.assertNotNull(pdfDocument.getPage(1)); + Assertions.assertFalse(reader.hasRebuiltXref(), "Rebuilt"); + Assertions.assertArrayEquals("abc".getBytes(StandardCharsets.ISO_8859_1), pdfDocument.getXmpMetadataBytes()); + Assertions.assertNotNull(pdfDocument.getPage(1)); reader.close(); } @Test - @Ignore("DEVSIX-1899: fails in .NET passes in Java") - public void customXmpTest() throws IOException, InterruptedException { + @Disabled("DEVSIX-1899: fails in .NET passes in Java") + public void customXmpTest() throws IOException, InterruptedException, XMPException { runCustomXmpTest("customXmp", "\n" + "\n" + @@ -224,8 +223,8 @@ public void customXmpTest() throws IOException, InterruptedException { } @Test - @Ignore("DEVSIX-1899: fails in .NET passes in Java") - public void customXmpTest02() throws IOException, InterruptedException { + @Disabled("DEVSIX-1899: fails in .NET passes in Java") + public void customXmpTest02() throws IOException, InterruptedException, XMPException { runCustomXmpTest("customXmp02", "\n" + "Rasant_ACE.indd\n" + @@ -234,8 +233,8 @@ public void customXmpTest02() throws IOException, InterruptedException { } private void runCustomXmpTest(String name, String xmp) throws IOException, InterruptedException { - String outPath = destinationFolder + name + ".pdf"; - String cmpPath = sourceFolder + "cmp_" + name + ".pdf"; + String outPath = DESTINATION_FOLDER + name + ".pdf"; + String cmpPath = SOURCE_FOLDER + "cmp_" + name + ".pdf"; PdfDocument pdfDoc = new PdfDocument(CompareTool.createTestPdfWriter(outPath)); PdfPage page = pdfDoc.addNewPage(); @@ -244,8 +243,8 @@ private void runCustomXmpTest(String name, String xmp) throws IOException, Inter pdfDoc.close(); CompareTool compareTool = new CompareTool(); - Assert.assertNull(compareTool.compareByContent(outPath, cmpPath, destinationFolder, "diff_" + name + "_")); - Assert.assertNull(compareTool.compareDocumentInfo(outPath, cmpPath)); + Assertions.assertNull(compareTool.compareByContent(outPath, cmpPath, DESTINATION_FOLDER, "diff_" + name + "_")); + Assertions.assertNull(compareTool.compareDocumentInfo(outPath, cmpPath)); } private byte[] removeAlwaysDifferentEntries(byte[] cmpBytes) throws XMPException { diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/XrefStreamDocumentUpdatesTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/XrefStreamDocumentUpdatesTest.java index c2d067bcbd..5528e2a54e 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/XrefStreamDocumentUpdatesTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/XrefStreamDocumentUpdatesTest.java @@ -29,26 +29,25 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.BouncyCastleIntegrationTest; import java.io.IOException; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(BouncyCastleIntegrationTest.class) +@Tag("BouncyCastleIntegrationTest") public class XrefStreamDocumentUpdatesTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/kernel/pdf/XrefStreamDocumentUpdatesTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/kernel/pdf/XrefStreamDocumentUpdatesTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(destinationFolder); } @@ -61,8 +60,8 @@ public void readFreeRefReusingInIncrementTest() throws IOException { PdfArray array = (PdfArray) document.getCatalog().getPdfObject() .get(new PdfName("CustomKey")); - Assert.assertTrue(array instanceof PdfArray); - Assert.assertEquals(0, array.size()); + Assertions.assertTrue(array instanceof PdfArray); + Assertions.assertEquals(0, array.size()); } @Test @@ -87,8 +86,8 @@ public void notReuseIndirectRefForObjectStreamTest() throws IOException { int expectNumberOfObjects = pdfDoc.getNumberOfPdfObjects(); //output pdf document should be openable - Assert.assertEquals(10, expectNumberOfObjects); - Assert.assertEquals(PdfName.ObjStm, pageDict.get(PdfName.Type)); + Assertions.assertEquals(10, expectNumberOfObjects); + Assertions.assertEquals(PdfName.ObjStm, pageDict.get(PdfName.Type)); } @Test @@ -111,8 +110,8 @@ public void notReuseIndRefForObjStreamInIncrementTest() throws IOException { int expectNumberOfObjects = doc.getNumberOfPdfObjects(); //output pdf document should be openable - Assert.assertEquals(9, expectNumberOfObjects); - Assert.assertEquals(PdfName.ObjStm, objStmDict.get(PdfName.Type)); + Assertions.assertEquals(9, expectNumberOfObjects); + Assertions.assertEquals(PdfName.ObjStm, objStmDict.get(PdfName.Type)); doc.close(); } @@ -134,9 +133,9 @@ public void freeRefReuseWhenAddNewObjTest() throws IOException { PdfXrefTable xref = pdfDoc1.getXref(); - Assert.assertEquals(8, expectObjNumber); - Assert.assertEquals(0, expectGenNumber); - Assert.assertTrue(xref.get(5).isFree()); + Assertions.assertEquals(8, expectObjNumber); + Assertions.assertEquals(0, expectGenNumber); + Assertions.assertTrue(xref.get(5).isFree()); pdfDoc1.close(); } @@ -157,8 +156,8 @@ public void checkEncryptionInXrefStmInIncrementsTest() throws IOException, Inter pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, inFileName, destinationFolder)); - Assert.assertEquals(PdfName.XRef, xrefStm.get(PdfName.Type)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, inFileName, destinationFolder)); + Assertions.assertEquals(PdfName.XRef, xrefStm.get(PdfName.Type)); } @Test @@ -173,7 +172,7 @@ public void hybridReferenceInIncrementsTest() throws IOException, InterruptedExc pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, inFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, inFileName, destinationFolder)); } @Test @@ -209,9 +208,9 @@ public void xrefStmInWriteModeTest() throws IOException { } } - Assert.assertEquals(((PdfNumber) doc.getTrailer().get(PdfName.Size)).intValue(), doc.getNumberOfPdfObjects()); + Assertions.assertEquals(((PdfNumber) doc.getTrailer().get(PdfName.Size)).intValue(), doc.getNumberOfPdfObjects()); doc.close(); - Assert.assertEquals(1, xrefTableCounter); + Assertions.assertEquals(1, xrefTableCounter); } @Test @@ -240,9 +239,9 @@ public void xrefStmInAppendModeTest() throws IOException { } } - Assert.assertEquals(((PdfNumber) doc.getTrailer().get(PdfName.Size)).intValue(), doc.getNumberOfPdfObjects()); + Assertions.assertEquals(((PdfNumber) doc.getTrailer().get(PdfName.Size)).intValue(), doc.getNumberOfPdfObjects()); doc.close(); - Assert.assertEquals(2, xrefTableCounter); + Assertions.assertEquals(2, xrefTableCounter); } @Test @@ -274,9 +273,9 @@ public void closeDocumentWithoutModificationsTest() throws IOException { } } - Assert.assertEquals(((PdfNumber) doc.getTrailer().get(PdfName.Size)).intValue(), doc.getNumberOfPdfObjects()); + Assertions.assertEquals(((PdfNumber) doc.getTrailer().get(PdfName.Size)).intValue(), doc.getNumberOfPdfObjects()); doc.close(); - Assert.assertEquals(1, xrefTableCounter); + Assertions.assertEquals(1, xrefTableCounter); } @Test @@ -299,6 +298,6 @@ public void hybridReferenceIncrementTwiceTest() throws IOException, InterruptedE pdfDoc2.close(); //if document processed correctly, no errors should occur - Assert.assertNull(new CompareTool().compareByContent(outFileName, inFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, inFileName, destinationFolder)); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/action/PdfActionOcgStateTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/action/PdfActionOcgStateTest.java index 52fa90fd06..29f228978d 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/action/PdfActionOcgStateTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/action/PdfActionOcgStateTest.java @@ -26,15 +26,14 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfName; import com.itextpdf.kernel.pdf.PdfObject; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.util.ArrayList; import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfActionOcgStateTest extends ExtendedITextTest { @Test public void pdfActionOcgStateUsageTest() { @@ -54,13 +53,13 @@ public void pdfActionOcgStateUsageTest() { PdfActionOcgState ocgState = new PdfActionOcgState(stateName, dicts); - Assert.assertEquals(stateName, ocgState.getState()); - Assert.assertEquals(dicts, ocgState.getOcgs()); + Assertions.assertEquals(stateName, ocgState.getState()); + Assertions.assertEquals(dicts, ocgState.getOcgs()); List states = ocgState.getObjectList(); - Assert.assertEquals(3, states.size()); - Assert.assertEquals(stateName, states.get(0)); - Assert.assertEquals(ocgDict1, states.get(1)); - Assert.assertEquals(ocgDict2, states.get(2)); + Assertions.assertEquals(3, states.size()); + Assertions.assertEquals(stateName, states.get(0)); + Assertions.assertEquals(ocgDict1, states.get(1)); + Assertions.assertEquals(ocgDict2, states.get(2)); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/action/PdfAnnotationAdditionalActionsTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/action/PdfAnnotationAdditionalActionsTest.java index ef3e0f23e6..6c66f949c3 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/action/PdfAnnotationAdditionalActionsTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/action/PdfAnnotationAdditionalActionsTest.java @@ -25,14 +25,13 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.kernel.pdf.PdfName; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfAnnotationAdditionalActionsTest extends ExtendedITextTest { @Test @@ -41,7 +40,7 @@ public void onEnterTest() { PdfAction action = PdfAction.createHide("test", false); aa.setOnEnter(action); - Assert.assertEquals(action.getPdfObject().getAsString(PdfName.T), aa.getOnEnter().getPdfObject().getAsString(PdfName.T)); + Assertions.assertEquals(action.getPdfObject().getAsString(PdfName.T), aa.getOnEnter().getPdfObject().getAsString(PdfName.T)); } @Test @@ -50,7 +49,7 @@ public void onExitTest() { PdfAction action = PdfAction.createHide("test", false); aa.setOnExit(action); - Assert.assertEquals(action.getPdfObject().getAsString(PdfName.T), aa.getOnExit().getPdfObject().getAsString(PdfName.T)); + Assertions.assertEquals(action.getPdfObject().getAsString(PdfName.T), aa.getOnExit().getPdfObject().getAsString(PdfName.T)); } @Test @@ -59,7 +58,7 @@ public void onFocusTest() { PdfAction action = PdfAction.createHide("test", false); aa.setOnFocus(action); - Assert.assertEquals(action.getPdfObject().getAsString(PdfName.T), aa.getOnFocus().getPdfObject().getAsString(PdfName.T)); + Assertions.assertEquals(action.getPdfObject().getAsString(PdfName.T), aa.getOnFocus().getPdfObject().getAsString(PdfName.T)); } @Test @@ -68,7 +67,7 @@ public void onLostFocusTest() { PdfAction action = PdfAction.createHide("test", false); aa.setOnLostFocus(action); - Assert.assertEquals(action.getPdfObject().getAsString(PdfName.T), aa.getOnLostFocus().getPdfObject().getAsString(PdfName.T)); + Assertions.assertEquals(action.getPdfObject().getAsString(PdfName.T), aa.getOnLostFocus().getPdfObject().getAsString(PdfName.T)); } @Test @@ -77,7 +76,7 @@ public void onMouseDownTest() { PdfAction action = PdfAction.createHide("test", false); aa.setOnMouseDown(action); - Assert.assertEquals(action.getPdfObject().getAsString(PdfName.T), aa.getOnMouseDown().getPdfObject().getAsString(PdfName.T)); + Assertions.assertEquals(action.getPdfObject().getAsString(PdfName.T), aa.getOnMouseDown().getPdfObject().getAsString(PdfName.T)); } @Test @@ -86,7 +85,7 @@ public void onMouseUpTest() { PdfAction action = PdfAction.createHide("test", false); aa.setOnMouseUp(action); - Assert.assertEquals(action.getPdfObject().getAsString(PdfName.T), aa.getOnMouseUp().getPdfObject().getAsString(PdfName.T)); + Assertions.assertEquals(action.getPdfObject().getAsString(PdfName.T), aa.getOnMouseUp().getPdfObject().getAsString(PdfName.T)); } @@ -96,7 +95,7 @@ public void onPageClosedTest() { PdfAction action = PdfAction.createHide("test", false); aa.setOnPageClosed(action); - Assert.assertEquals(action.getPdfObject().getAsString(PdfName.T), aa.getOnPageClosed().getPdfObject().getAsString(PdfName.T)); + Assertions.assertEquals(action.getPdfObject().getAsString(PdfName.T), aa.getOnPageClosed().getPdfObject().getAsString(PdfName.T)); } @Test @@ -105,7 +104,7 @@ public void onPageLostViewTest() { PdfAction action = PdfAction.createHide("test", false); aa.setOnPageLostView(action); - Assert.assertEquals(action.getPdfObject().getAsString(PdfName.T), aa.getOnPageLostView().getPdfObject().getAsString(PdfName.T)); + Assertions.assertEquals(action.getPdfObject().getAsString(PdfName.T), aa.getOnPageLostView().getPdfObject().getAsString(PdfName.T)); } @Test @@ -114,7 +113,7 @@ public void onPageOpenedTest() { PdfAction action = PdfAction.createHide("test", false); aa.setOnPageOpened(action); - Assert.assertEquals(action.getPdfObject().getAsString(PdfName.T), aa.getOnPageOpened().getPdfObject().getAsString(PdfName.T)); + Assertions.assertEquals(action.getPdfObject().getAsString(PdfName.T), aa.getOnPageOpened().getPdfObject().getAsString(PdfName.T)); } @Test @@ -123,7 +122,7 @@ public void onPageVisibleTest() { PdfAction action = PdfAction.createHide("test", false); aa.setOnPageVisible(action); - Assert.assertEquals(action.getPdfObject().getAsString(PdfName.T), aa.getOnPageVisible().getPdfObject().getAsString(PdfName.T)); + Assertions.assertEquals(action.getPdfObject().getAsString(PdfName.T), aa.getOnPageVisible().getPdfObject().getAsString(PdfName.T)); } @Test @@ -152,27 +151,27 @@ public void getAllKnownActions() { aa.setOnLostFocus(actionLostFocus); List result = aa.getAllKnownActions(); - Assert.assertEquals(10, result.size()); + Assertions.assertEquals(10, result.size()); - Assert.assertTrue(result.stream(). + Assertions.assertTrue(result.stream(). anyMatch((PdfAction a) -> a.getPdfObject().getAsString(PdfName.T).getValue() == "PageVisible")); - Assert.assertTrue(result.stream(). + Assertions.assertTrue(result.stream(). anyMatch((PdfAction a) -> a.getPdfObject().getAsString(PdfName.T).getValue() == "PageClosed")); - Assert.assertTrue(result.stream(). + Assertions.assertTrue(result.stream(). anyMatch((PdfAction a) -> a.getPdfObject().getAsString(PdfName.T).getValue() == "PageOpened")); - Assert.assertTrue(result.stream(). + Assertions.assertTrue(result.stream(). anyMatch((PdfAction a) -> a.getPdfObject().getAsString(PdfName.T).getValue() == "PageLostView")); - Assert.assertTrue(result.stream(). + Assertions.assertTrue(result.stream(). anyMatch((PdfAction a) -> a.getPdfObject().getAsString(PdfName.T).getValue() == "Exit")); - Assert.assertTrue(result.stream(). + Assertions.assertTrue(result.stream(). anyMatch((PdfAction a) -> a.getPdfObject().getAsString(PdfName.T).getValue() == "Enter")); - Assert.assertTrue(result.stream(). + Assertions.assertTrue(result.stream(). anyMatch((PdfAction a) -> a.getPdfObject().getAsString(PdfName.T).getValue() == "MouseUp")); - Assert.assertTrue(result.stream(). + Assertions.assertTrue(result.stream(). anyMatch((PdfAction a) -> a.getPdfObject().getAsString(PdfName.T).getValue() == "MouseDown")); - Assert.assertTrue(result.stream(). + Assertions.assertTrue(result.stream(). anyMatch((PdfAction a) -> a.getPdfObject().getAsString(PdfName.T).getValue() == "Focus")); - Assert.assertTrue(result.stream(). + Assertions.assertTrue(result.stream(). anyMatch((PdfAction a) -> a.getPdfObject().getAsString(PdfName.T).getValue() == "LostFocus")); } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/action/PdfTargetTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/action/PdfTargetTest.java index bd27f289ea..9b186ce601 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/action/PdfTargetTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/action/PdfTargetTest.java @@ -38,14 +38,13 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.ByteArrayOutputStream; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfTargetTest extends ExtendedITextTest { @Test @@ -53,21 +52,21 @@ public void createInstanceTest() { PdfDictionary dictionary = new PdfDictionary(); PdfTarget target = PdfTarget.create(dictionary); - Assert.assertEquals(dictionary, target.getPdfObject()); + Assertions.assertEquals(dictionary, target.getPdfObject()); } @Test public void createParentInstanceTest() { PdfTarget target = PdfTarget.createParentTarget(); PdfDictionary dictionary = target.getPdfObject(); - Assert.assertEquals(PdfName.P, dictionary.get(PdfName.R)); + Assertions.assertEquals(PdfName.P, dictionary.get(PdfName.R)); } @Test public void createChildInstanceTest() { PdfTarget target = PdfTarget.createChildTarget(); PdfDictionary dictionary = target.getPdfObject(); - Assert.assertEquals(PdfName.C, dictionary.get(PdfName.R)); + Assertions.assertEquals(PdfName.C, dictionary.get(PdfName.R)); } @Test @@ -76,8 +75,8 @@ public void createChildInstanceWithEmbeddedFileTest() { PdfTarget target = PdfTarget.createChildTarget(embeddedFileName); PdfDictionary dictionary = target.getPdfObject(); - Assert.assertEquals(PdfName.C, dictionary.get(PdfName.R)); - Assert.assertEquals(new PdfString(embeddedFileName), dictionary.get(PdfName.N)); + Assertions.assertEquals(PdfName.C, dictionary.get(PdfName.R)); + Assertions.assertEquals(new PdfString(embeddedFileName), dictionary.get(PdfName.N)); } @Test @@ -88,9 +87,9 @@ public void createChildInstanceWithNamedDestinationTest() { PdfTarget target = PdfTarget.createChildTarget(namedDestination, annotationIdentifier); PdfDictionary dictionary = target.getPdfObject(); - Assert.assertEquals(PdfName.C, dictionary.get(PdfName.R)); - Assert.assertEquals(new PdfString(namedDestination), dictionary.get(PdfName.P)); - Assert.assertEquals(new PdfString(annotationIdentifier), dictionary.get(PdfName.A)); + Assertions.assertEquals(PdfName.C, dictionary.get(PdfName.R)); + Assertions.assertEquals(new PdfString(namedDestination), dictionary.get(PdfName.P)); + Assertions.assertEquals(new PdfString(annotationIdentifier), dictionary.get(PdfName.A)); } @Test @@ -101,9 +100,9 @@ public void createChildInstanceWithPageNumberTest() { PdfTarget target = PdfTarget.createChildTarget(pageNumber, annotationIndex); PdfDictionary dictionary = target.getPdfObject(); - Assert.assertEquals(PdfName.C, dictionary.get(PdfName.R)); - Assert.assertEquals(new PdfNumber(pageNumber - 1), dictionary.get(PdfName.P)); - Assert.assertEquals(new PdfNumber(annotationIndex), dictionary.get(PdfName.A)); + Assertions.assertEquals(PdfName.C, dictionary.get(PdfName.R)); + Assertions.assertEquals(new PdfNumber(pageNumber - 1), dictionary.get(PdfName.P)); + Assertions.assertEquals(new PdfNumber(annotationIndex), dictionary.get(PdfName.A)); } @Test @@ -113,8 +112,8 @@ public void namePropertyTest() { PdfTarget target = PdfTarget.create(new PdfDictionary()); target.setName(name); - Assert.assertEquals(name, target.getName()); - Assert.assertEquals(new PdfString(name), target.getPdfObject().get(PdfName.N)); + Assertions.assertEquals(name, target.getName()); + Assertions.assertEquals(new PdfString(name), target.getPdfObject().get(PdfName.N)); } @@ -130,8 +129,8 @@ public void targetPropertyTest() { PdfTarget target = PdfTarget.create(oldDictionary); target.setTarget(PdfTarget.create(newDictionary)); - Assert.assertEquals(newDictionary, target.getTarget().getPdfObject()); - Assert.assertEquals(newDictionary, target.getPdfObject().get(PdfName.T)); + Assertions.assertEquals(newDictionary, target.getTarget().getPdfObject()); + Assertions.assertEquals(newDictionary, target.getPdfObject().get(PdfName.T)); } @Test @@ -153,8 +152,8 @@ public void setAnnotationTest() { target.setAnnotation(annotation2, document); PdfDictionary dictionary = target.getPdfObject(); - Assert.assertEquals(0, dictionary.getAsNumber(PdfName.P).intValue()); - Assert.assertEquals(2, dictionary.getAsNumber(PdfName.A).intValue()); + Assertions.assertEquals(0, dictionary.getAsNumber(PdfName.P).intValue()); + Assertions.assertEquals(2, dictionary.getAsNumber(PdfName.A).intValue()); } } @@ -178,8 +177,8 @@ public void setAnnotationWhichIsMissedOnThePageTest() { target.setAnnotation(annotation2, document); PdfDictionary dictionary = target.getPdfObject(); - Assert.assertEquals(0, dictionary.getAsNumber(PdfName.P).intValue()); - Assert.assertEquals(-1, dictionary.getAsNumber(PdfName.A).intValue()); + Assertions.assertEquals(0, dictionary.getAsNumber(PdfName.P).intValue()); + Assertions.assertEquals(-1, dictionary.getAsNumber(PdfName.A).intValue()); } } @@ -193,10 +192,10 @@ public void setAnnotationWithoutPageTest() { PdfTarget target = PdfTarget.create(new PdfDictionary()); - Exception e = Assert.assertThrows(PdfException.class, + Exception e = Assertions.assertThrows(PdfException.class, () -> target.setAnnotation(annotation, document) ); - Assert.assertEquals(KernelExceptionMessageConstant.ANNOTATION_SHALL_HAVE_REFERENCE_TO_PAGE, e.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.ANNOTATION_SHALL_HAVE_REFERENCE_TO_PAGE, e.getMessage()); } } @@ -215,7 +214,7 @@ public void getAnnotationSetAsAnnotationTest() { PdfTarget target = PdfTarget.create(new PdfDictionary()); target.setAnnotation(annotation, document); - Assert.assertEquals(annotation.getPdfObject(), target.getAnnotation(document).getPdfObject()); + Assertions.assertEquals(annotation.getPdfObject(), target.getAnnotation(document).getPdfObject()); } } @@ -232,7 +231,7 @@ public void getAnnotationSetAsIntsTest() { document.addNewPage(); document.getPage(1).addAnnotation(annotation); - Assert.assertEquals(annotation.getPdfObject(), target.getAnnotation(document).getPdfObject()); + Assertions.assertEquals(annotation.getPdfObject(), target.getAnnotation(document).getPdfObject()); } } @@ -255,7 +254,7 @@ public void getAnnotationSetAsStringTest() { PdfAnnotation retrievedAnnotation = target.getAnnotation(document); - Assert.assertEquals(annotation.getPdfObject(), retrievedAnnotation.getPdfObject()); + Assertions.assertEquals(annotation.getPdfObject(), retrievedAnnotation.getPdfObject()); } } @@ -275,7 +274,7 @@ public void getAnnotationSetAsStringNotAvailableTest() { new PdfArray(new PdfNumber(1))); PdfAnnotation annotation = target.getAnnotation(document); - Assert.assertNull(annotation); + Assertions.assertNull(annotation); } } @@ -288,8 +287,8 @@ public void putTest() { PdfTarget target = PdfTarget.create(dictionary); target.put(key1, new PdfNumber(23)) .put(key2, new PdfString("Hello, world!")); - Assert.assertEquals(23, dictionary.getAsNumber(key1).intValue()); - Assert.assertEquals("Hello, world!", dictionary.getAsString(key2).getValue()); + Assertions.assertEquals(23, dictionary.getAsNumber(key1).intValue()); + Assertions.assertEquals("Hello, world!", dictionary.getAsString(key2).getValue()); } @@ -298,16 +297,16 @@ public void isWrappedObjectMustBeIndirectTest() { PdfDictionary pdfObject = new PdfDictionary(); PdfTarget target = PdfTarget.create(pdfObject); - Assert.assertFalse(target.isWrappedObjectMustBeIndirect()); + Assertions.assertFalse(target.isWrappedObjectMustBeIndirect()); } @Test public void noAnnotationPageReferenceTest() { PdfFileAttachmentAnnotation pdfAnnotation = new PdfFileAttachmentAnnotation(new Rectangle(100, 100)); PdfTarget pdfTarget = PdfTarget.create(new PdfDictionary()); - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> pdfTarget.setAnnotation(pdfAnnotation, null)); - Assert.assertEquals(KernelExceptionMessageConstant.ANNOTATION_SHALL_HAVE_REFERENCE_TO_PAGE, + Assertions.assertEquals(KernelExceptionMessageConstant.ANNOTATION_SHALL_HAVE_REFERENCE_TO_PAGE, exception.getMessage()); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/action/PdfWinTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/action/PdfWinTest.java index 5c5e591994..2203d05cb2 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/action/PdfWinTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/action/PdfWinTest.java @@ -26,13 +26,12 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfName; import com.itextpdf.kernel.pdf.PdfString; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfWinTest extends ExtendedITextTest { @Test @@ -44,8 +43,8 @@ public void checkDictionaryConstructorTest() { PdfWin win = new PdfWin(dict); PdfDictionary pdfWinObj = win.getPdfObject(); - Assert.assertEquals(1, pdfWinObj.size()); - Assert.assertEquals(somePath, pdfWinObj.getAsString(PdfName.F).toString()); + Assertions.assertEquals(1, pdfWinObj.size()); + Assertions.assertEquals(somePath, pdfWinObj.getAsString(PdfName.F).toString()); } @Test @@ -55,8 +54,8 @@ public void checkSingleParamConstructorTest() { PdfWin win = new PdfWin(new PdfString(somePath)); PdfDictionary pdfWinObj = win.getPdfObject(); - Assert.assertEquals(1, pdfWinObj.size()); - Assert.assertEquals(somePath, pdfWinObj.getAsString(PdfName.F).toString()); + Assertions.assertEquals(1, pdfWinObj.size()); + Assertions.assertEquals(somePath, pdfWinObj.getAsString(PdfName.F).toString()); } @Test @@ -71,11 +70,11 @@ public void checkMultipleParamConstructorTest() { PdfDictionary pdfWinObj = win.getPdfObject(); - Assert.assertEquals(4, pdfWinObj.size()); - Assert.assertEquals(somePath, pdfWinObj.getAsString(PdfName.F).toString()); - Assert.assertEquals(defaultDirectory, pdfWinObj.getAsString(PdfName.D).toString()); - Assert.assertEquals(operation, pdfWinObj.getAsString(PdfName.O).toString()); - Assert.assertEquals(parameter, pdfWinObj.getAsString(PdfName.P).toString()); + Assertions.assertEquals(4, pdfWinObj.size()); + Assertions.assertEquals(somePath, pdfWinObj.getAsString(PdfName.F).toString()); + Assertions.assertEquals(defaultDirectory, pdfWinObj.getAsString(PdfName.D).toString()); + Assertions.assertEquals(operation, pdfWinObj.getAsString(PdfName.O).toString()); + Assertions.assertEquals(parameter, pdfWinObj.getAsString(PdfName.P).toString()); } @Test @@ -84,6 +83,6 @@ public void isWrappedObjectMustBeIndirectTest() { PdfWin win = new PdfWin(new PdfString(somePath)); - Assert.assertFalse(win.isWrappedObjectMustBeIndirect()); + Assertions.assertFalse(win.isWrappedObjectMustBeIndirect()); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/annot/AddLinkAnnotationTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/annot/AddLinkAnnotationTest.java index ca5f7bcea0..dcd696eab9 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/annot/AddLinkAnnotationTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/annot/AddLinkAnnotationTest.java @@ -44,29 +44,28 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.FileOutputStream; import java.io.IOException; import java.util.List; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class AddLinkAnnotationTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/kernel/pdf/annot/AddLinkAnnotationTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/kernel/pdf/annot/AddLinkAnnotationTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(destinationFolder); } @@ -102,7 +101,7 @@ public void addLinkAnnotation01() throws Exception { document.close(); - Assert.assertNull(new CompareTool() + Assertions.assertNull(new CompareTool() .compareByContent(destinationFolder + "linkAnnotation01.pdf", sourceFolder + "cmp_linkAnnotation01.pdf", destinationFolder, "diff_")); @@ -130,7 +129,7 @@ public void addLinkAnnotation02() throws Exception { document.close(); - Assert.assertNull(new CompareTool() + Assertions.assertNull(new CompareTool() .compareByContent(destinationFolder + "linkAnnotation02.pdf", sourceFolder + "cmp_linkAnnotation02.pdf", destinationFolder, "diff_")); @@ -170,17 +169,17 @@ public void addAndGetLinkAnnotations() throws Exception { document.close(); - Assert.assertNull(new CompareTool() + Assertions.assertNull(new CompareTool() .compareByContent(destinationFolder + "linkAnnotation03.pdf", sourceFolder + "cmp_linkAnnotation03.pdf", destinationFolder, "diff_")); document = new PdfDocument(CompareTool.createOutputReader(destinationFolder + "linkAnnotation03.pdf")); page = document.getPage(1); - Assert.assertEquals(3, page.getAnnotsSize()); + Assertions.assertEquals(3, page.getAnnotsSize()); List annotations = page.getAnnotations(); - Assert.assertEquals(3, annotations.size()); + Assertions.assertEquals(3, annotations.size()); PdfLinkAnnotation link = (PdfLinkAnnotation) annotations.get(0); - Assert.assertEquals(page, link.getPage()); + Assertions.assertEquals(page, link.getPage()); document.close(); } @@ -207,7 +206,7 @@ public void linkAnnotationActionDestinationTest() throws IOException, Interrupte pdfDocument.close(); - Assert.assertNull(new CompareTool() + Assertions.assertNull(new CompareTool() .compareByContent(destinationFolder + fileName, sourceFolder + "cmp_" + fileName, destinationFolder)); } @@ -221,7 +220,7 @@ public void removeLinkAnnotationTaggedAsLinkTest() throws IOException, Interrupt page.removeAnnotation(page.getAnnotations().get(0)); } - Assert.assertNull(new CompareTool().compareByContent(output, cmp, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(output, cmp, destinationFolder)); } @Test @@ -234,7 +233,7 @@ public void removeLinkAnnotationTaggedAsAnnotTest() throws IOException, Interrup page.removeAnnotation(page.getAnnotations().get(0)); } - Assert.assertNull(new CompareTool().compareByContent(output, cmp, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(output, cmp, destinationFolder)); } @Test @@ -247,7 +246,7 @@ public void removeLinkAnnotationTagWithContentTest() throws IOException, Interru page.removeAnnotation(page.getAnnotations().get(0)); } - Assert.assertNull(new CompareTool().compareByContent(output, cmp, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(output, cmp, destinationFolder)); } @Test @@ -260,7 +259,7 @@ public void removeLinkAnnotationWithNoTagTest() throws IOException, InterruptedE page.removeAnnotation(page.getAnnotations().get(0)); } - Assert.assertNull(new CompareTool().compareByContent(output, cmp, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(output, cmp, destinationFolder)); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/annot/AddMiscTypesAnnotationsTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/annot/AddMiscTypesAnnotationsTest.java index 85acca8e06..6983cb1f49 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/annot/AddMiscTypesAnnotationsTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/annot/AddMiscTypesAnnotationsTest.java @@ -61,19 +61,18 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.List; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class AddMiscTypesAnnotationsTest extends ExtendedITextTest { public static final String SOURCE_FOLDER = @@ -81,12 +80,12 @@ public class AddMiscTypesAnnotationsTest extends ExtendedITextTest { public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/kernel/pdf/annot/AddMiscTypesAnnotationsTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(DESTINATION_FOLDER); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(DESTINATION_FOLDER); } @@ -109,7 +108,7 @@ public void addTextAnnotation01() throws Exception { document.close(); - Assert.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + "textAnnotation01.pdf", SOURCE_FOLDER + Assertions.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + "textAnnotation01.pdf", SOURCE_FOLDER + "cmp_textAnnotation01.pdf", DESTINATION_FOLDER, "diff_")); } @@ -130,7 +129,7 @@ outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_1_4)))) { page.addAnnotation(annot); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); } @Test @@ -178,7 +177,7 @@ public void caretTest() throws IOException, InterruptedException { String errorMessage = compareTool.compareByContent(filename, SOURCE_FOLDER + "cmp_CaretAnnotation.pdf", DESTINATION_FOLDER, "diff_"); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -200,7 +199,7 @@ public void addFreeTextAnnotation01() throws Exception { document.close(); - Assert.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + "freeTextAnnotation01.pdf", SOURCE_FOLDER + Assertions.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + "freeTextAnnotation01.pdf", SOURCE_FOLDER + "cmp_freeTextAnnotation01.pdf", DESTINATION_FOLDER, "diff_")); } @@ -221,7 +220,7 @@ public void addSquareAndCircleAnnotations01() throws Exception { document.close(); - Assert.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + "squareAndCircleAnnotations01.pdf", SOURCE_FOLDER + Assertions.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + "squareAndCircleAnnotations01.pdf", SOURCE_FOLDER + "cmp_squareAndCircleAnnotations01.pdf", DESTINATION_FOLDER, "diff_")); } @@ -249,7 +248,7 @@ public void fileAttachmentTest() throws IOException, InterruptedException { String errorMessage = compareTool.compareByContent(filename, SOURCE_FOLDER + "cmp_fileAttachmentAnnotation.pdf", DESTINATION_FOLDER, "diff_"); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -290,7 +289,7 @@ public void fileAttachmentTargetTest() throws IOException, InterruptedException String errorMessage = compareTool.compareByContent(filename, SOURCE_FOLDER + "cmp_fileAttachmentTargetTest.pdf", DESTINATION_FOLDER, "diff_"); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -311,7 +310,7 @@ public void noFileAttachmentTargetTest() throws IOException, InterruptedExceptio String errorMessage = compareTool.compareByContent(DESTINATION_FOLDER + fileName, SOURCE_FOLDER + "cmp_" + fileName, DESTINATION_FOLDER, "diff_"); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -341,7 +340,7 @@ public void fileAttachmentAppendModeTest() throws IOException, InterruptedExcept finalDoc.addFileAttachment("some_test", spec); finalDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(fileName, SOURCE_FOLDER + "cmp_fileAttachmentAppendModeTest.pdf", + Assertions.assertNull(new CompareTool().compareByContent(fileName, SOURCE_FOLDER + "cmp_fileAttachmentAppendModeTest.pdf", DESTINATION_FOLDER, "diff_")); } @@ -403,7 +402,7 @@ public void rubberStampTest() throws IOException, InterruptedException { String errorMessage = compareTool.compareByContent(filename, SOURCE_FOLDER + "cmp_rubberStampAnnotation01.pdf", DESTINATION_FOLDER, "diff_"); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -427,7 +426,7 @@ public void rubberStampWrongStampTest() throws IOException, InterruptedException String errorMessage = compareTool.compareByContent(filename, SOURCE_FOLDER + "cmp_rubberStampAnnotation02.pdf", DESTINATION_FOLDER, "diff_"); if (errorMessage != null) { - Assert.assertNull(errorMessage); + Assertions.assertNull(errorMessage); } } @@ -463,7 +462,7 @@ public void inkTest() throws IOException, InterruptedException { String errorMessage = compareTool.compareByContent(filename, SOURCE_FOLDER + "cmp_inkAnnotation01.pdf", DESTINATION_FOLDER, "diff_"); if (errorMessage != null) { - Assert.assertNull(errorMessage); + Assertions.assertNull(errorMessage); } } @@ -504,7 +503,7 @@ public void printerMarkText() throws IOException, InterruptedException { String errorMessage = compareTool.compareByContent(filename, SOURCE_FOLDER + "cmp_printerMarkAnnotation01.pdf", DESTINATION_FOLDER, "diff_"); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -548,7 +547,7 @@ public void trapNetworkText() throws IOException, InterruptedException { String errorMessage = compareTool.compareByContent(filename, SOURCE_FOLDER + "cmp_trapNetworkAnnotation01.pdf", DESTINATION_FOLDER, "diff_"); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -593,7 +592,7 @@ public void waterMarkTest() throws IOException, InterruptedException { String errorMessage = compareTool.compareByContent(filename, SOURCE_FOLDER + "cmp_watermarkAnnotation01.pdf", DESTINATION_FOLDER, "diff_"); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -662,7 +661,7 @@ public void redactionTest() throws IOException, InterruptedException { String errorMessage = compareTool.compareByContent(filename, SOURCE_FOLDER + "cmp_redactionAnnotation01.pdf", DESTINATION_FOLDER, "diff_"); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -729,7 +728,7 @@ public void defaultAppearanceTest() throws IOException, InterruptedException { ); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(outPath, cmpPath, DESTINATION_FOLDER, diff)); + Assertions.assertNull(new CompareTool().compareByContent(outPath, cmpPath, DESTINATION_FOLDER, diff)); } @Test @@ -741,7 +740,7 @@ public void make3dAnnotationTest() throws IOException { PdfPage page1 = pdfDoc.getPage(1); List annots = page1.getAnnotations(); - Assert.assertTrue(annots.get(0) instanceof Pdf3DAnnotation); + Assertions.assertTrue(annots.get(0) instanceof Pdf3DAnnotation); } @Test @@ -771,7 +770,7 @@ public void add3dAnnotationTest() throws IOException, InterruptedException { pdfDoc.addNewPage().addAnnotation(annot); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + "add3DAnnotation01.pdf", + Assertions.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + "add3DAnnotation01.pdf", SOURCE_FOLDER + "cmp_add3DAnnotation01.pdf", DESTINATION_FOLDER, "diff_")); } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/annot/AddScreenAnnotationTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/annot/AddScreenAnnotationTest.java index b1210db1d1..4c876b8dae 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/annot/AddScreenAnnotationTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/annot/AddScreenAnnotationTest.java @@ -34,30 +34,29 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.filespec.PdfFileSpec; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; import java.nio.file.Paths; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class AddScreenAnnotationTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/kernel/pdf/annot/AddScreenAnnotationTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/kernel/pdf/annot/AddScreenAnnotationTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(destinationFolder); } @@ -77,7 +76,7 @@ public void screenEmbeddedWavFromPathTest() throws IOException, InterruptedExcep String errorMessage = new CompareTool().compareByContent(filename, cmp, destinationFolder); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -98,7 +97,7 @@ public void screenEmbeddedWavFromStreamTest() throws IOException, InterruptedExc String errorMessage = new CompareTool().compareByContent(filename, cmp, destinationFolder); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -118,7 +117,7 @@ public void screenEmbeddedWavFromBytesTest() throws IOException, InterruptedExce String errorMessage = new CompareTool().compareByContent(filename, cmp, destinationFolder); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -136,7 +135,7 @@ public void screenExternalWavTest() throws IOException, InterruptedException { String errorMessage = new CompareTool().compareByContent(filename, cmp, destinationFolder); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/annot/AddSoundAnnotationTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/annot/AddSoundAnnotationTest.java index 1981b3123e..e7645dfe83 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/annot/AddSoundAnnotationTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/annot/AddSoundAnnotationTest.java @@ -30,17 +30,16 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfStream; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; import java.io.InputStream; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class AddSoundAnnotationTest extends ExtendedITextTest { public static final String sourceFolder = @@ -50,12 +49,12 @@ public class AddSoundAnnotationTest extends ExtendedITextTest { private static final String RIFF_TAG = "RIFF"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(destinationFolder); } @@ -80,7 +79,7 @@ public void soundTestAif() throws IOException, InterruptedException { String errorMessage = new CompareTool().compareByContent(filename, cmp, destinationFolder); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -105,7 +104,7 @@ public void soundTestAiff() throws IOException, InterruptedException { String errorMessage = new CompareTool().compareByContent(filename, cmpPdf, destinationFolder); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -133,7 +132,7 @@ public void soundTestWav01() throws IOException, InterruptedException { String errorMessage = new CompareTool().compareByContent(filename, cmpPdf, destinationFolder); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -155,7 +154,7 @@ public void soundTestSnd() throws IOException, InterruptedException { String errorMessage = new CompareTool().compareByContent(filename, cmpPdf, destinationFolder); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -177,7 +176,7 @@ public void soundTestWav() throws IOException, InterruptedException { String errorMessage = new CompareTool().compareByContent(filename, cmpPdf, destinationFolder); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/annot/AddTextMarkupAnnotationTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/annot/AddTextMarkupAnnotationTest.java index 4811b4b128..3b6778f9f3 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/annot/AddTextMarkupAnnotationTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/annot/AddTextMarkupAnnotationTest.java @@ -33,16 +33,15 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.canvas.PdfCanvas; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class AddTextMarkupAnnotationTest extends ExtendedITextTest { public static final String sourceFolder = @@ -50,12 +49,12 @@ public class AddTextMarkupAnnotationTest extends ExtendedITextTest { public static final String destinationFolder = "./target/test/com/itextpdf/kernel/pdf/annot/AddTextMarkupAnnotationTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(destinationFolder); } @@ -94,7 +93,7 @@ public void textMarkupTest01() throws IOException, InterruptedException { .compareByContent(filename, sourceFolder + "cmp_textMarkupAnnotation01.pdf", destinationFolder, "diff_"); if (errorMessage != null) { - Assert.assertNull(errorMessage); + Assertions.assertNull(errorMessage); } } @@ -132,7 +131,7 @@ public void textMarkupTest02() throws IOException, InterruptedException { .compareByContent(filename, sourceFolder + "cmp_textMarkupAnnotation02.pdf", destinationFolder, "diff_"); if (errorMessage != null) { - Assert.assertNull(errorMessage); + Assertions.assertNull(errorMessage); } } @@ -170,7 +169,7 @@ public void textMarkupTest03() throws IOException, InterruptedException { .compareByContent(filename, sourceFolder + "cmp_textMarkupAnnotation03.pdf", destinationFolder, "diff_"); if (errorMessage != null) { - Assert.assertNull(errorMessage); + Assertions.assertNull(errorMessage); } } @@ -208,7 +207,7 @@ public void textMarkupTest04() throws IOException, InterruptedException { .compareByContent(filename, sourceFolder + "cmp_textMarkupAnnotation04.pdf", destinationFolder, "diff_"); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/annot/CopyAnnotationsTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/annot/CopyAnnotationsTest.java index c4e3b6cbdc..bc6c43c51e 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/annot/CopyAnnotationsTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/annot/CopyAnnotationsTest.java @@ -29,31 +29,30 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfWriter; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; import java.util.List; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class CopyAnnotationsTest extends ExtendedITextTest { public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/kernel/pdf/annot" + "/CopyAnnotationsTest/"; public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/kernel/pdf/annot/CopyAnnotationsTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(DESTINATION_FOLDER); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(DESTINATION_FOLDER); } @@ -67,7 +66,7 @@ public void copyGoToRDestinationTest() throws IOException { } } List annotations = getAnnotationsFromPdf(outFile, 1); - Assert.assertEquals("Destination is not copied", 1, annotations.size()); + Assertions.assertEquals(1, annotations.size(), "Destination is not copied"); } @Test @@ -79,7 +78,7 @@ public void copyMultipleGoToRDestinationTest() throws IOException { } } List annotations = getAnnotationsFromPdf(outFile, 1); - Assert.assertEquals("Not all destinations are copied", 2, annotations.size()); + Assertions.assertEquals(2, annotations.size(), "Not all destinations are copied"); } @Test @@ -91,7 +90,7 @@ public void copyGoToRWithoutTargetTest() throws IOException { } } List annotations = getAnnotationsFromPdf(outFile, 5); - Assert.assertTrue("Destinations are copied but should not", annotations.isEmpty()); + Assertions.assertTrue(annotations.isEmpty(), "Destinations are copied but should not"); } @Test @@ -103,9 +102,9 @@ public void copyGoToRNamedDestinationTest() throws IOException { } } List annotations = getAnnotationsFromPdf(outFile, 6); - Assert.assertFalse("Annotation is copied", annotations.isEmpty()); + Assertions.assertFalse(annotations.isEmpty(), "Annotation is copied"); String destination = (annotations.get(0)).getPdfObject().get(PdfName.Dest).toString(); - Assert.assertEquals("Destination is different from expected", "Destination_1", destination); + Assertions.assertEquals("Destination_1", destination, "Destination is different from expected"); } @Test @@ -117,9 +116,9 @@ public void fileAttachmentTargetTest() throws IOException { } } List annotations = getAnnotationsFromPdf(outFile, 2); - Assert.assertFalse("Annotation is not copied", annotations.isEmpty()); + Assertions.assertFalse(annotations.isEmpty(), "Annotation is not copied"); String nm = annotations.get(0).getPdfObject().getAsString(PdfName.NM).toString(); - Assert.assertEquals("File attachment name is different from expected", "FileAttachmentAnnotation1", nm); + Assertions.assertEquals("FileAttachmentAnnotation1", nm, "File attachment name is different from expected"); } @Test @@ -132,8 +131,8 @@ public void copyLinkWidgetTest() throws IOException { } } List annotations = getAnnotationsFromPdf(outFile, 1); - Assert.assertFalse("Annotation is not copied", annotations.isEmpty()); - Assert.assertEquals("Annotation is of a different subtype", PdfName.Widget, annotations.get(0).getSubtype()); + Assertions.assertFalse(annotations.isEmpty(), "Annotation is not copied"); + Assertions.assertEquals(PdfName.Widget, annotations.get(0).getSubtype(), "Annotation is of a different subtype"); } @Test @@ -147,7 +146,7 @@ public void noPdfNameATest() throws IOException { } } List annotations = getAnnotationsFromPdf(outFile, 1); - Assert.assertFalse("Annotation is not copied", annotations.isEmpty()); + Assertions.assertFalse(annotations.isEmpty(), "Annotation is not copied"); } @Test @@ -162,7 +161,7 @@ public void noPdfNameDTest() throws IOException { } } List annotations = getAnnotationsFromPdf(outFile, 1); - Assert.assertFalse("Annotation is not copied", annotations.isEmpty()); + Assertions.assertFalse(annotations.isEmpty(), "Annotation is not copied"); } @Test @@ -176,7 +175,7 @@ public void noPdfNameSTest() throws IOException { } } List annotations = getAnnotationsFromPdf(outFile, 1); - Assert.assertTrue("Annotation is copied", annotations.isEmpty()); + Assertions.assertTrue(annotations.isEmpty(), "Annotation is copied"); } @Test @@ -193,7 +192,7 @@ public void noPdfNameDWithGoToRTest() throws IOException { } } List annotations = getAnnotationsFromPdf(outFile, 1); - Assert.assertFalse("Annotation is not copied", annotations.isEmpty()); + Assertions.assertFalse(annotations.isEmpty(), "Annotation is not copied"); } @Test @@ -205,7 +204,7 @@ public void linkInsideArray() throws IOException { } } List annotations = getAnnotationsFromPdf(outFile, 1); - Assert.assertTrue("Annotation is copied", annotations.isEmpty()); + Assertions.assertTrue(annotations.isEmpty(), "Annotation is copied"); } private List getAnnotationsFromPdf(String outFilePath, int pageNumber) throws IOException { diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/annot/Pdf3DAnnotationTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/annot/Pdf3DAnnotationTest.java index 8a0bb88bfe..ac31fabc76 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/annot/Pdf3DAnnotationTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/annot/Pdf3DAnnotationTest.java @@ -26,12 +26,11 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.kernel.pdf.PdfName; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class Pdf3DAnnotationTest extends ExtendedITextTest { @Test @@ -42,7 +41,7 @@ public void setAndGetDefaultInitialViewTest() { pdf3DAnnotation.setDefaultInitialView(dict); - Assert.assertEquals(dict, pdf3DAnnotation.getDefaultInitialView()); + Assertions.assertEquals(dict, pdf3DAnnotation.getDefaultInitialView()); } @Test @@ -53,7 +52,7 @@ public void setAndGetActivationDictionaryTest() { pdf3DAnnotation.setActivationDictionary(dict); - Assert.assertEquals(dict, pdf3DAnnotation.getActivationDictionary()); + Assertions.assertEquals(dict, pdf3DAnnotation.getActivationDictionary()); } @Test @@ -63,7 +62,7 @@ public void setAndIsInteractiveTest() { pdf3DAnnotation.setInteractive(flag); - Assert.assertEquals(flag, pdf3DAnnotation.isInteractive().getValue()); + Assertions.assertEquals(flag, pdf3DAnnotation.isInteractive().getValue()); } @Test @@ -74,6 +73,6 @@ public void setAndGetViewBoxTest() { pdf3DAnnotation.setViewBox(rect); boolean result = rect.equalsWithEpsilon(pdf3DAnnotation.getViewBox()); - Assert.assertTrue("Rectangles are different", result); + Assertions.assertTrue(result, "Rectangles are different"); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/annot/PdfAnnotationMakeTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/annot/PdfAnnotationMakeTest.java index 9f12632129..6c34ba5f96 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/annot/PdfAnnotationMakeTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/annot/PdfAnnotationMakeTest.java @@ -28,21 +28,20 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfObject; import com.itextpdf.kernel.pdf.PdfWriter; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.ByteArrayOutputStream; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfAnnotationMakeTest extends ExtendedITextTest { @Test public void makePdfAnnotationTest() { PdfDictionary object = new PdfDictionary(); PdfAnnotation result = PdfAnnotation.makeAnnotation(object); - Assert.assertNull(result.getSubtype()); + Assertions.assertNull(result.getSubtype()); } @Test @@ -50,7 +49,7 @@ public void makePdfTextAnnotationTest() { PdfDictionary object = new PdfDictionary(); object.put(PdfName.Subtype, PdfName.Text); PdfAnnotation result = PdfAnnotation.makeAnnotation(object); - Assert.assertTrue(result instanceof PdfTextAnnotation); + Assertions.assertTrue(result instanceof PdfTextAnnotation); } @Test @@ -61,7 +60,7 @@ public void makeIndirectPdfAnnotationTest() { PdfObject indirect = object.makeIndirect(doc); object.put(PdfName.Subtype, PdfName.Text); PdfAnnotation result = PdfAnnotation.makeAnnotation(indirect); - Assert.assertTrue(result instanceof PdfTextAnnotation); + Assertions.assertTrue(result instanceof PdfTextAnnotation); } } @@ -70,7 +69,7 @@ public void makePdfPolyAnnotationTest() { PdfDictionary object = new PdfDictionary(); object.put(PdfName.Subtype, PdfName.Polygon); PdfAnnotation result = PdfAnnotation.makeAnnotation(object); - Assert.assertTrue(result instanceof PdfPolyGeomAnnotation); + Assertions.assertTrue(result instanceof PdfPolyGeomAnnotation); } @Test @@ -79,6 +78,6 @@ public void makePdfUnknownAnnotationTest() { // from DEVSIX-2661 object.put(PdfName.Subtype, new PdfName("BatesN")); PdfAnnotation result = PdfAnnotation.makeAnnotation(object); - Assert.assertTrue(result instanceof PdfAnnotation.PdfUnknownAnnotation); + Assertions.assertTrue(result instanceof PdfAnnotation.PdfUnknownAnnotation); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/annot/PdfFreeTextAnnotationTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/annot/PdfFreeTextAnnotationTest.java index 3efe7a4443..cf721b7f7b 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/annot/PdfFreeTextAnnotationTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/annot/PdfFreeTextAnnotationTest.java @@ -25,12 +25,11 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.geom.Rectangle; import com.itextpdf.kernel.pdf.PdfString; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfFreeTextAnnotationTest extends ExtendedITextTest { @Test @@ -38,14 +37,14 @@ public void setAndGetRotationTest() { PdfFreeTextAnnotation freeTextAnnotation = new PdfFreeTextAnnotation(new Rectangle(0, 0, 100, 50), new PdfString("content")); freeTextAnnotation.setRotation(135); - Assert.assertEquals(135, freeTextAnnotation.getRotation().intValue()); + Assertions.assertEquals(135, freeTextAnnotation.getRotation().intValue()); } @Test public void setAndGetJustificationTest() { PdfFreeTextAnnotation freeTextAnnotation = new PdfFreeTextAnnotation(new Rectangle(0, 0, 100, 50), null); - Assert.assertEquals(PdfFreeTextAnnotation.LEFT_JUSTIFIED, freeTextAnnotation.getJustification()); + Assertions.assertEquals(PdfFreeTextAnnotation.LEFT_JUSTIFIED, freeTextAnnotation.getJustification()); freeTextAnnotation.setJustification(PdfFreeTextAnnotation.CENTERED); - Assert.assertEquals(PdfFreeTextAnnotation.CENTERED, freeTextAnnotation.getJustification()); + Assertions.assertEquals(PdfFreeTextAnnotation.CENTERED, freeTextAnnotation.getJustification()); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/annot/PdfLineAnnotationTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/annot/PdfLineAnnotationTest.java index 74750ad329..11c3d4a9b6 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/annot/PdfLineAnnotationTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/annot/PdfLineAnnotationTest.java @@ -31,12 +31,11 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfString; import com.itextpdf.kernel.pdf.colorspace.PdfColorSpace; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfLineAnnotationTest extends ExtendedITextTest { private static final float FLOAT_EPSILON_COMPARISON = 1E-6f; @@ -45,7 +44,7 @@ public void getLineTest() { float[] lineArray = new float[] {1f, 1f, 1f, 1f}; PdfLineAnnotation pdfLineAnnotation = new PdfLineAnnotation(new Rectangle(10, 10), lineArray); - Assert.assertArrayEquals(lineArray, pdfLineAnnotation.getLine().toFloatArray(), FLOAT_EPSILON_COMPARISON); + Assertions.assertArrayEquals(lineArray, pdfLineAnnotation.getLine().toFloatArray(), FLOAT_EPSILON_COMPARISON); } @Test @@ -56,7 +55,7 @@ public void setAndGetBorderStylePdfDictTest() { dict.put(PdfName.Width, new PdfNumber(1)); pdfLineAnnotation.setBorderStyle(dict); - Assert.assertEquals(dict, pdfLineAnnotation.getBorderStyle()); + Assertions.assertEquals(dict, pdfLineAnnotation.getBorderStyle()); } @Test @@ -65,7 +64,7 @@ public void setAndGetBorderStylePdfNameTest() { pdfLineAnnotation.setBorderStyle(PdfName.D); - Assert.assertEquals(PdfName.D, pdfLineAnnotation.getBorderStyle().getAsName(PdfName.S)); + Assertions.assertEquals(PdfName.D, pdfLineAnnotation.getBorderStyle().getAsName(PdfName.S)); } @Test @@ -75,7 +74,7 @@ public void setDashPatternTest() { PdfArray array = new PdfArray(new float[]{1, 2}); pdfLineAnnotation.setDashPattern(array); - Assert.assertArrayEquals(array.toFloatArray(), + Assertions.assertArrayEquals(array.toFloatArray(), pdfLineAnnotation.getBorderStyle().getAsArray(PdfName.D).toFloatArray(), FLOAT_EPSILON_COMPARISON); } @@ -86,7 +85,7 @@ public void setAndGetLineEndingStylesTest() { PdfArray lineEndingStyles = new PdfArray(new float[]{1, 2}); pdfLineAnnotation.setLineEndingStyles(lineEndingStyles); - Assert.assertArrayEquals(lineEndingStyles.toFloatArray(), + Assertions.assertArrayEquals(lineEndingStyles.toFloatArray(), pdfLineAnnotation.getLineEndingStyles().toFloatArray(), FLOAT_EPSILON_COMPARISON); } @@ -99,7 +98,7 @@ public void setAndGetInteriorColorPdfArrayTest() { pdfLineAnnotation.setInteriorColor(array); Color expectedColor = Color.makeColor(PdfColorSpace.makeColorSpace(PdfName.DeviceRGB), colorValues); - Assert.assertEquals(expectedColor, pdfLineAnnotation.getInteriorColor()); + Assertions.assertEquals(expectedColor, pdfLineAnnotation.getInteriorColor()); } @Test @@ -110,7 +109,7 @@ public void setAndGetInteriorColorFloatArrayTest() { pdfLineAnnotation.setInteriorColor(colorValues); Color expectedColor = Color.makeColor(PdfColorSpace.makeColorSpace(PdfName.DeviceRGB), colorValues); - Assert.assertEquals(expectedColor, pdfLineAnnotation.getInteriorColor()); + Assertions.assertEquals(expectedColor, pdfLineAnnotation.getInteriorColor()); } @Test @@ -120,14 +119,14 @@ public void setAndGetLeaderLineLengthTest() { pdfLineAnnotation.setLeaderLineLength(length); - Assert.assertEquals(length, pdfLineAnnotation.getLeaderLineLength(), FLOAT_EPSILON_COMPARISON); + Assertions.assertEquals(length, pdfLineAnnotation.getLeaderLineLength(), FLOAT_EPSILON_COMPARISON); } @Test public void getLeaderLineLengthNullTest() { PdfLineAnnotation pdfLineAnnotation = new PdfLineAnnotation(new PdfDictionary()); - Assert.assertEquals(0, pdfLineAnnotation.getLeaderLineLength(), FLOAT_EPSILON_COMPARISON); + Assertions.assertEquals(0, pdfLineAnnotation.getLeaderLineLength(), FLOAT_EPSILON_COMPARISON); } @Test @@ -137,14 +136,14 @@ public void setAndGetLeaderLineExtensionTest() { pdfLineAnnotation.setLeaderLineExtension(length); - Assert.assertEquals(length, pdfLineAnnotation.getLeaderLineExtension(), FLOAT_EPSILON_COMPARISON); + Assertions.assertEquals(length, pdfLineAnnotation.getLeaderLineExtension(), FLOAT_EPSILON_COMPARISON); } @Test public void setAndGetLeaderLineExtensionNullTest() { PdfLineAnnotation pdfLineAnnotation = new PdfLineAnnotation(new PdfDictionary()); - Assert.assertEquals(0, pdfLineAnnotation.getLeaderLineExtension(), FLOAT_EPSILON_COMPARISON); + Assertions.assertEquals(0, pdfLineAnnotation.getLeaderLineExtension(), FLOAT_EPSILON_COMPARISON); } @Test @@ -154,14 +153,14 @@ public void setAndGetLeaderLineOffsetTest() { pdfLineAnnotation.setLeaderLineOffset(length); - Assert.assertEquals(length, pdfLineAnnotation.getLeaderLineOffset(), FLOAT_EPSILON_COMPARISON); + Assertions.assertEquals(length, pdfLineAnnotation.getLeaderLineOffset(), FLOAT_EPSILON_COMPARISON); } @Test public void getLeaderLineOffsetNullTest() { PdfLineAnnotation pdfLineAnnotation = new PdfLineAnnotation(new PdfDictionary()); - Assert.assertEquals(0, pdfLineAnnotation.getLeaderLineOffset(), FLOAT_EPSILON_COMPARISON); + Assertions.assertEquals(0, pdfLineAnnotation.getLeaderLineOffset(), FLOAT_EPSILON_COMPARISON); } @Test @@ -171,14 +170,14 @@ public void setAndGetContentsAsCaptionTest() { pdfLineAnnotation.setContentsAsCaption(contentsAsCaption); - Assert.assertEquals(contentsAsCaption, pdfLineAnnotation.getContentsAsCaption()); + Assertions.assertEquals(contentsAsCaption, pdfLineAnnotation.getContentsAsCaption()); } @Test public void getContentsAsCaptionNullTest() { PdfLineAnnotation pdfLineAnnotation = new PdfLineAnnotation(new PdfDictionary()); - Assert.assertFalse(pdfLineAnnotation.getContentsAsCaption()); + Assertions.assertFalse(pdfLineAnnotation.getContentsAsCaption()); } @Test @@ -187,7 +186,7 @@ public void setAndGetCaptionPositionTest() { pdfLineAnnotation.setCaptionPosition(PdfName.Inline); - Assert.assertEquals(PdfName.Inline, pdfLineAnnotation.getCaptionPosition()); + Assertions.assertEquals(PdfName.Inline, pdfLineAnnotation.getCaptionPosition()); } @Test @@ -198,7 +197,7 @@ public void setAndGetMeasureTest() { measure.put(PdfName.Subtype, new PdfString("")); pdfLineAnnotation.setMeasure(measure); - Assert.assertEquals(measure, pdfLineAnnotation.getMeasure()); + Assertions.assertEquals(measure, pdfLineAnnotation.getMeasure()); } @Test @@ -208,7 +207,7 @@ public void setAndGetCaptionOffsetPdfArrayTest() { pdfLineAnnotation.setCaptionOffset(offset); - Assert.assertArrayEquals(offset.toFloatArray(), pdfLineAnnotation.getCaptionOffset().toFloatArray(), + Assertions.assertArrayEquals(offset.toFloatArray(), pdfLineAnnotation.getCaptionOffset().toFloatArray(), FLOAT_EPSILON_COMPARISON); } @@ -219,6 +218,6 @@ public void setAndGetCaptionOffsetFloatArrayTest() { pdfLineAnnotation.setCaptionOffset(offset); - Assert.assertArrayEquals(offset, pdfLineAnnotation.getCaptionOffset().toFloatArray(), FLOAT_EPSILON_COMPARISON); + Assertions.assertArrayEquals(offset, pdfLineAnnotation.getCaptionOffset().toFloatArray(), FLOAT_EPSILON_COMPARISON); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/annot/PdfMarkupAnnotationTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/annot/PdfMarkupAnnotationTest.java index e61264faaf..1cb079c96f 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/annot/PdfMarkupAnnotationTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/annot/PdfMarkupAnnotationTest.java @@ -26,18 +26,17 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.kernel.pdf.PdfObject; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfMarkupAnnotationTest extends ExtendedITextTest { @Test public void externalDataTest() { PdfMarkupAnnotation annotation = new PdfCircleAnnotation(new Rectangle(0, 0, 10, 10)); annotation.setExternalData(new PdfDictionary()); - Assert.assertEquals(PdfObject.DICTIONARY, annotation.getExternalData().getType()); + Assertions.assertEquals(PdfObject.DICTIONARY, annotation.getExternalData().getType()); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/annot/PdfPolyGeomAnnotationTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/annot/PdfPolyGeomAnnotationTest.java index 8f29dbb451..00fae8d0d2 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/annot/PdfPolyGeomAnnotationTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/annot/PdfPolyGeomAnnotationTest.java @@ -35,15 +35,14 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.util.ArrayList; import java.util.List; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfPolyGeomAnnotationTest extends ExtendedITextTest { private static final float FLOAT_EPSILON_COMPARISON = 1E-6f; @@ -53,9 +52,9 @@ public void createPolygonTest() { float[] vertices = new float[]{1, 1, 1, 1}; PdfPolyGeomAnnotation pdfPolyGeomAnnotation = PdfPolyGeomAnnotation.createPolygon(rect, vertices); - Assert.assertTrue("Rectangles are not equal", - pdfPolyGeomAnnotation.getRectangle().toRectangle().equalsWithEpsilon(rect)); - Assert.assertArrayEquals(vertices, pdfPolyGeomAnnotation.getVertices().toFloatArray(), FLOAT_EPSILON_COMPARISON); + Assertions.assertTrue(pdfPolyGeomAnnotation.getRectangle().toRectangle().equalsWithEpsilon(rect), + "Rectangles are not equal"); + Assertions.assertArrayEquals(vertices, pdfPolyGeomAnnotation.getVertices().toFloatArray(), FLOAT_EPSILON_COMPARISON); } @Test @@ -64,9 +63,8 @@ public void createPolylineTest() { float[] vertices = new float[]{1, 1, 1, 1}; PdfPolyGeomAnnotation pdfPolyGeomAnnotation = PdfPolyGeomAnnotation.createPolyLine(rect, vertices); - Assert.assertTrue("Rectangles are not equal", - pdfPolyGeomAnnotation.getRectangle().toRectangle().equalsWithEpsilon(rect)); - Assert.assertArrayEquals(vertices, pdfPolyGeomAnnotation.getVertices().toFloatArray(), FLOAT_EPSILON_COMPARISON); + Assertions.assertTrue(pdfPolyGeomAnnotation.getRectangle().toRectangle().equalsWithEpsilon(rect), "Rectangles are not equal"); + Assertions.assertArrayEquals(vertices, pdfPolyGeomAnnotation.getVertices().toFloatArray(), FLOAT_EPSILON_COMPARISON); } @Test @@ -76,7 +74,7 @@ public void setAndGetVerticesFloatArrayTest() { float[] vertices = new float[]{1, 1, 1, 1}; pdfPolyGeomAnnotation.setVertices(vertices); - Assert.assertArrayEquals(vertices, pdfPolyGeomAnnotation.getVertices().toFloatArray(), FLOAT_EPSILON_COMPARISON); + Assertions.assertArrayEquals(vertices, pdfPolyGeomAnnotation.getVertices().toFloatArray(), FLOAT_EPSILON_COMPARISON); } @Test @@ -89,7 +87,7 @@ public void setAndGetVerticesFloatArrayLogMessageTest() { float[] vertices = new float[]{1, 1, 1, 1}; pdfPolyGeomAnnotation.setVertices(vertices); - Assert.assertArrayEquals(vertices, pdfPolyGeomAnnotation.getVertices().toFloatArray(), FLOAT_EPSILON_COMPARISON); + Assertions.assertArrayEquals(vertices, pdfPolyGeomAnnotation.getVertices().toFloatArray(), FLOAT_EPSILON_COMPARISON); } @Test @@ -99,7 +97,7 @@ public void setAndGetVerticesPdfArrayTest() { PdfArray vertices = new PdfArray(new float[]{1, 1, 1, 1}); pdfPolyGeomAnnotation.setVertices(vertices); - Assert.assertArrayEquals(vertices.toFloatArray(), pdfPolyGeomAnnotation.getVertices().toFloatArray(), FLOAT_EPSILON_COMPARISON); + Assertions.assertArrayEquals(vertices.toFloatArray(), pdfPolyGeomAnnotation.getVertices().toFloatArray(), FLOAT_EPSILON_COMPARISON); } @Test @@ -112,7 +110,7 @@ public void setAndGetVerticesPdfArrayLogMessageTest() { PdfArray vertices = new PdfArray(new float[]{1, 1, 1, 1}); pdfPolyGeomAnnotation.setVertices(vertices); - Assert.assertArrayEquals(vertices.toFloatArray(), pdfPolyGeomAnnotation.getVertices().toFloatArray(), FLOAT_EPSILON_COMPARISON); + Assertions.assertArrayEquals(vertices.toFloatArray(), pdfPolyGeomAnnotation.getVertices().toFloatArray(), FLOAT_EPSILON_COMPARISON); } @Test @@ -124,7 +122,7 @@ public void setAndGetLineEndingStylesTest() { PdfArray lineEndingStyles = new PdfArray(new float[]{1, 2}); pdfPolyGeomAnnotation.setLineEndingStyles(lineEndingStyles); - Assert.assertArrayEquals(lineEndingStyles.toFloatArray(), + Assertions.assertArrayEquals(lineEndingStyles.toFloatArray(), pdfPolyGeomAnnotation.getLineEndingStyles().toFloatArray(), FLOAT_EPSILON_COMPARISON); } @@ -138,7 +136,7 @@ public void setAndGetMeasureTest() { measure.put(PdfName.Subtype, new PdfString("")); pdfPolyGeomAnnotation.setMeasure(measure); - Assert.assertEquals(measure, pdfPolyGeomAnnotation.getMeasure()); + Assertions.assertEquals(measure, pdfPolyGeomAnnotation.getMeasure()); } @Test @@ -150,7 +148,7 @@ public void setAndGetPathTest() { PdfArray path = new PdfArray(arrays); pdfPolyGeomAnnotation.setPath(path); - Assert.assertEquals(path.toString(), pdfPolyGeomAnnotation.getPath().toString()); + Assertions.assertEquals(path.toString(), pdfPolyGeomAnnotation.getPath().toString()); } @Test @@ -164,7 +162,7 @@ public void setAndGetPathLogMessageTest() { PdfArray path = new PdfArray(arrays); pdfPolyGeomAnnotation.setPath(path); - Assert.assertEquals(path, pdfPolyGeomAnnotation.getPath()); + Assertions.assertEquals(path, pdfPolyGeomAnnotation.getPath()); } @Test @@ -175,7 +173,7 @@ public void setAndGetBorderStylePdfDictTest() { style.put(PdfName.Width, new PdfNumber(1)); pdfPolyGeomAnnotation.setBorderStyle(style); - Assert.assertEquals(style, pdfPolyGeomAnnotation.getBorderStyle()); + Assertions.assertEquals(style, pdfPolyGeomAnnotation.getBorderStyle()); } @Test @@ -184,7 +182,7 @@ public void setAndGetBorderStylePdfNameTest() { pdfPolyGeomAnnotation.setBorderStyle(PdfName.D); - Assert.assertEquals(PdfName.D, pdfPolyGeomAnnotation.getBorderStyle().getAsName(PdfName.S)); + Assertions.assertEquals(PdfName.D, pdfPolyGeomAnnotation.getBorderStyle().getAsName(PdfName.S)); } @Test @@ -194,7 +192,7 @@ public void setAndGetDashPatternTest() { PdfArray array = new PdfArray(new float[]{1, 2}); pdfPolyGeomAnnotation.setDashPattern(array); - Assert.assertEquals(array, pdfPolyGeomAnnotation.getBorderStyle().getAsArray(PdfName.D)); + Assertions.assertEquals(array, pdfPolyGeomAnnotation.getBorderStyle().getAsArray(PdfName.D)); } @Test @@ -204,7 +202,7 @@ public void setAndGetBorderEffectTest() { PdfDictionary dict = new PdfDictionary(); pdfPolyGeomAnnotation.setBorderEffect(dict); - Assert.assertEquals(dict, pdfPolyGeomAnnotation.getBorderEffect()); + Assertions.assertEquals(dict, pdfPolyGeomAnnotation.getBorderEffect()); } @Test @@ -216,7 +214,7 @@ public void setAndGetInteriorColorPdfArrayTest() { pdfPolyGeomAnnotation.setInteriorColor(array); Color expectedColor = Color.makeColor(PdfColorSpace.makeColorSpace(PdfName.DeviceRGB), colorValues); - Assert.assertEquals(expectedColor, pdfPolyGeomAnnotation.getInteriorColor()); + Assertions.assertEquals(expectedColor, pdfPolyGeomAnnotation.getInteriorColor()); } @Test @@ -227,6 +225,6 @@ public void setAndGetInteriorColorFloatArrayTest() { pdfPolyGeomAnnotation.setInteriorColor(colorValues); Color expectedColor = Color.makeColor(PdfColorSpace.makeColorSpace(PdfName.DeviceRGB), colorValues); - Assert.assertEquals(expectedColor, pdfPolyGeomAnnotation.getInteriorColor()); + Assertions.assertEquals(expectedColor, pdfPolyGeomAnnotation.getInteriorColor()); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/annot/PdfStampAnnotationTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/annot/PdfStampAnnotationTest.java index b92e36bf7f..764cbec7f4 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/annot/PdfStampAnnotationTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/annot/PdfStampAnnotationTest.java @@ -25,32 +25,31 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.geom.Rectangle; import com.itextpdf.kernel.pdf.PdfName; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfStampAnnotationTest extends ExtendedITextTest { @Test public void setAndGetRotationTest() { PdfStampAnnotation stamp = new PdfStampAnnotation(new Rectangle(0, 0, 100, 50)); stamp.setRotation(45); - Assert.assertEquals(45, stamp.getRotation().intValue()); + Assertions.assertEquals(45, stamp.getRotation().intValue()); } @Test public void setAndGetIconNameTest() { PdfStampAnnotation stamp = new PdfStampAnnotation(new Rectangle(0, 0, 100, 50)); stamp.setIconName(new PdfName("SBApproved")); - Assert.assertEquals("SBApproved", stamp.getIconName().getValue()); + Assertions.assertEquals("SBApproved", stamp.getIconName().getValue()); } @Test public void setAndGetStampNameTest() { PdfStampAnnotation stamp = new PdfStampAnnotation(new Rectangle(0, 0, 100, 50)); stamp.setStampName(new PdfName("SBApproved")); - Assert.assertEquals("SBApproved", stamp.getIconName().getValue()); + Assertions.assertEquals("SBApproved", stamp.getIconName().getValue()); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/CanvasTagTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/CanvasTagTest.java index c9fb1d3894..8e2f8b179d 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/CanvasTagTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/CanvasTagTest.java @@ -24,17 +24,16 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfName; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class CanvasTagTest extends ExtendedITextTest { @Test public void testGetActualTextReturnsNullIfNotExists() { CanvasTag tag = new CanvasTag(PdfName.Span); - Assert.assertNull(tag.getActualText()); + Assertions.assertNull(tag.getActualText()); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/CharacterRenderInfoTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/CharacterRenderInfoTest.java index 4079071e31..751a626d96 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/CharacterRenderInfoTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/CharacterRenderInfoTest.java @@ -30,15 +30,14 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.canvas.parser.data.TextRenderInfo; import com.itextpdf.kernel.pdf.canvas.parser.listener.CharacterRenderInfo; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; import java.util.Stack; -@Category(UnitTest.class) +@Tag("UnitTest") public class CharacterRenderInfoTest extends ExtendedITextTest { @Test @@ -47,7 +46,7 @@ public void boundingBoxForRotatedText() throws IOException { CharacterRenderInfo characterRenderInfo = new CharacterRenderInfo(tri); - Assert.assertTrue(characterRenderInfo.getBoundingBox().equalsWithEpsilon(new Rectangle(-8.616f, 0f, 11.1f, 19.344f))); + Assertions.assertTrue(characterRenderInfo.getBoundingBox().equalsWithEpsilon(new Rectangle(-8.616f, 0f, 11.1f, 19.344f))); } private static TextRenderInfo initTRI(String text, double angle) throws IOException { diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/ImageMasksTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/ImageMasksTest.java index ef0f5ed847..1953fcc34d 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/ImageMasksTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/ImageMasksTest.java @@ -34,26 +34,25 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.xobject.PdfImageXObject; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class ImageMasksTest extends ExtendedITextTest { private static final String sourceFolder = "./src/test/resources/com/itextpdf/kernel/pdf/canvas/ImageMasksTest/"; private static final String destinationFolder = "./target/test/com/itextpdf/kernel/pdf/canvas/ImageMasksTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(destinationFolder); } @@ -80,7 +79,7 @@ public void imageResizedParentWithHardMaskTest() throws IOException, Interrupted pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } @Test @@ -109,7 +108,7 @@ public void diffMasksOnSameImageXObjectTest() throws IOException, InterruptedExc pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } @Test @@ -134,7 +133,7 @@ public void imageResizedParentWithSoftMaskTest() throws IOException, Interrupted pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } @Test @@ -159,7 +158,7 @@ public void imageWithSoftMaskMatteTest() throws IOException, InterruptedExceptio pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } @Test @@ -185,16 +184,16 @@ public void sMaskMatteDifferentSizeOfImgTest() throws IOException, InterruptedEx pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } @Test public void imageWithInvalidMaskTest() throws IOException { ImageData mask = ImageDataFactory.create(sourceFolder + "mask.png"); - Exception e = Assert.assertThrows(com.itextpdf.io.exceptions.IOException.class, + Exception e = Assertions.assertThrows(com.itextpdf.io.exceptions.IOException.class, () -> mask.makeMask() ); - Assert.assertEquals(MessageFormatUtil.format(IoExceptionMessageConstant.THIS_IMAGE_CAN_NOT_BE_AN_IMAGE_MASK), e.getMessage()); + Assertions.assertEquals(MessageFormatUtil.format(IoExceptionMessageConstant.THIS_IMAGE_CAN_NOT_BE_AN_IMAGE_MASK), e.getMessage()); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/PdfCanvasColorTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/PdfCanvasColorTest.java index 944be5da8d..84233fbc59 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/PdfCanvasColorTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/PdfCanvasColorTest.java @@ -49,35 +49,36 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.colorspace.PdfColorSpace; import com.itextpdf.kernel.pdf.colorspace.PdfDeviceCs; import com.itextpdf.kernel.pdf.colorspace.PdfPattern; -import com.itextpdf.kernel.pdf.colorspace.PdfShading; +import com.itextpdf.kernel.pdf.colorspace.shading.AbstractPdfShading; import com.itextpdf.kernel.pdf.colorspace.PdfSpecialCs; +import com.itextpdf.kernel.pdf.colorspace.shading.PdfAxialShading; +import com.itextpdf.kernel.pdf.colorspace.shading.PdfRadialShading; import com.itextpdf.kernel.pdf.function.PdfType4Function; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.nio.charset.StandardCharsets; import java.util.ArrayList; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfCanvasColorTest extends ExtendedITextTest { public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/kernel/pdf/canvas/PdfCanvasColorTest/"; public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/kernel/pdf/canvas/PdfCanvasColorTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(DESTINATION_FOLDER); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(DESTINATION_FOLDER); } @@ -100,7 +101,7 @@ public void colorTest01() throws Exception { canvas.release(); document.close(); - Assert.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + "colorTest01.pdf", + Assertions.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + "colorTest01.pdf", SOURCE_FOLDER + "cmp_colorTest01.pdf", DESTINATION_FOLDER, "diff_")); } @@ -134,7 +135,7 @@ public void colorTest02() throws Exception { canvas.release(); document.close(); - Assert.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + "colorTest02.pdf", + Assertions.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + "colorTest02.pdf", SOURCE_FOLDER + "cmp_colorTest02.pdf", DESTINATION_FOLDER, "diff_")); } @@ -167,7 +168,7 @@ public void colorTest03() throws Exception { canvas.release(); document.close(); - Assert.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + "colorTest03.pdf", + Assertions.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + "colorTest03.pdf", SOURCE_FOLDER + "cmp_colorTest03.pdf", DESTINATION_FOLDER, "diff_")); } @@ -203,7 +204,7 @@ public void colorTest04() throws Exception { newDocument.close(); document.close(); - Assert.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + "colorTest04.pdf", + Assertions.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + "colorTest04.pdf", SOURCE_FOLDER + "cmp_colorTest04.pdf", DESTINATION_FOLDER, "diff_")); } @@ -228,7 +229,7 @@ public void colorTest05() throws Exception { canvas.release(); document.close(); - Assert.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + "colorTest05.pdf", + Assertions.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + "colorTest05.pdf", SOURCE_FOLDER + "cmp_colorTest05.pdf", DESTINATION_FOLDER, "diff_")); } @@ -256,7 +257,7 @@ public void colorTest06() throws Exception { canvas.release(); document.close(); - Assert.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + "colorTest06.pdf", + Assertions.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + "colorTest06.pdf", SOURCE_FOLDER + "cmp_colorTest06.pdf", DESTINATION_FOLDER, "diff_")); } @@ -278,7 +279,7 @@ public void colorTest07Depr() throws Exception { canvas.release(); document.close(); - Assert.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + "colorTest07.pdf", + Assertions.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + "colorTest07.pdf", SOURCE_FOLDER + "cmp_colorTest07.pdf", DESTINATION_FOLDER, "diff_")); } @@ -300,7 +301,7 @@ public void colorTest07() throws Exception { canvas.release(); document.close(); - Assert.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + "colorTest07.pdf", + Assertions.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + "colorTest07.pdf", SOURCE_FOLDER + "cmp_colorTest07.pdf", DESTINATION_FOLDER, "diff_")); } @@ -326,7 +327,7 @@ public void colorTest08Depr() throws Exception { canvas.release(); document.close(); - Assert.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + "colorTest08.pdf", + Assertions.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + "colorTest08.pdf", SOURCE_FOLDER + "cmp_colorTest08.pdf", DESTINATION_FOLDER, "diff_")); } @@ -351,7 +352,7 @@ public void colorTest08() throws Exception { canvas.release(); document.close(); - Assert.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + "colorTest08.pdf", + Assertions.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + "colorTest08.pdf", SOURCE_FOLDER + "cmp_colorTest08.pdf", DESTINATION_FOLDER, "diff_")); } @@ -384,7 +385,7 @@ public void makePatternColorTest() throws IOException, InterruptedException { canvas.release(); document.close(); - Assert.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + "makePatternColorTest.pdf", + Assertions.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + "makePatternColorTest.pdf", SOURCE_FOLDER + "cmp_makePatternColorTest.pdf", DESTINATION_FOLDER, "diff_")); } @@ -398,7 +399,7 @@ public void patternColorColoredAxialPatternTest() throws Exception { PdfCanvas canvas = new PdfCanvas(page); - PdfShading axial = new PdfShading.Axial( + AbstractPdfShading axial = new PdfAxialShading( new PdfDeviceCs.Rgb(), 36, 716, new float[]{1, .784f, 0}, 396, 788, new float[]{0, 0, 1}, @@ -411,7 +412,7 @@ public void patternColorColoredAxialPatternTest() throws Exception { canvas.release(); document.close(); - Assert.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + name, + Assertions.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + name, SOURCE_FOLDER + "cmp_" + name, DESTINATION_FOLDER)); } @@ -425,7 +426,7 @@ public void patternColorColoredRadialPatternTest() throws Exception { PdfCanvas canvas = new PdfCanvas(page); - PdfShading radial = new PdfShading.Radial( + AbstractPdfShading radial = new PdfRadialShading( new PdfDeviceCs.Rgb(), 200, 700, 50, new float[] {1, 0.968f, 0.58f}, 300, 700, 100, new float[] {0.968f, 0.541f, 0.42f} @@ -437,7 +438,7 @@ public void patternColorColoredRadialPatternTest() throws Exception { canvas.release(); document.close(); - Assert.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + name, + Assertions.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + name, SOURCE_FOLDER + "cmp_" + name, DESTINATION_FOLDER)); } @@ -465,7 +466,7 @@ public void patternColorUncoloredCircleRgbTest() throws Exception { canvas.release(); document.close(); - Assert.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + name, + Assertions.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + name, SOURCE_FOLDER + "cmp_" + name, DESTINATION_FOLDER)); } @@ -488,7 +489,7 @@ public void patternColorUncoloredLineGrayTest() throws Exception { canvas.release(); document.close(); - Assert.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + name, + Assertions.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + name, SOURCE_FOLDER + "cmp_" + name, DESTINATION_FOLDER)); } @@ -534,9 +535,9 @@ public void patternColorColoredSetTwiceTest() throws Exception { String contentStreamString = new String(pageContentStreamBytes, StandardCharsets.US_ASCII); int p1Count = countSubstringOccurrences(contentStreamString, "/P1 scn"); int p2Count = countSubstringOccurrences(contentStreamString, "/P2 scn"); - Assert.assertEquals(1, p1Count); - Assert.assertEquals(1, p2Count); - Assert.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + name, + Assertions.assertEquals(1, p1Count); + Assertions.assertEquals(1, p2Count); + Assertions.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + name, SOURCE_FOLDER + "cmp_" + name, DESTINATION_FOLDER)); } @@ -583,9 +584,9 @@ public void patternColorUncoloredSetTwiceTest() throws Exception { String contentStreamString = new String(pageContentStreamBytes, StandardCharsets.US_ASCII); int p1Count = countSubstringOccurrences(contentStreamString, "/P1 scn"); int p2Count = countSubstringOccurrences(contentStreamString, "/P2 scn"); - Assert.assertEquals(2, p1Count); - Assert.assertEquals(2, p2Count); - Assert.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + name, + Assertions.assertEquals(2, p1Count); + Assertions.assertEquals(2, p2Count); + Assertions.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + name, SOURCE_FOLDER + "cmp_" + name, DESTINATION_FOLDER)); } @@ -596,7 +597,7 @@ public void patternColorUncoloredPatternCsUnitTest() { PdfPattern.Tiling circle = new PdfPattern.Tiling(15, 15, 10, 20, false); new PdfPatternCanvas(circle, doc).circle(7.5f, 7.5f, 2.5f).fill().release(); - Assert.assertThrows(IllegalArgumentException.class, + Assertions.assertThrows(IllegalArgumentException.class, () -> new PatternColor(circle, new PdfSpecialCs.Pattern(), new float[0]) ); } @@ -610,7 +611,7 @@ public void patternColorUncoloredPatternColorUnitTest() { PatternColor redCirclePattern = new PatternColor(circle, ColorConstants.RED); - Assert.assertThrows(IllegalArgumentException.class, () -> new PatternColor(circle, redCirclePattern)); + Assertions.assertThrows(IllegalArgumentException.class, () -> new PatternColor(circle, redCirclePattern)); } private void setColorSameColorSpacesTest(String pdfName, boolean pattern) throws IOException, InterruptedException { @@ -626,9 +627,9 @@ private void setColorSameColorSpacesTest(String pdfName, boolean pattern) throws float[] colorValue1 = pattern ? null : new float[]{1.0f, 0.6f, 0.7f}; float[] colorValue2 = pattern ? null : new float[]{0.1f, 0.9f, 0.9f}; - PdfPattern pattern1 = pattern? new PdfPattern.Shading(new PdfShading.Axial(new PdfDeviceCs.Rgb(), 45, 750, ColorConstants.PINK.getColorValue(), + PdfPattern pattern1 = pattern? new PdfPattern.Shading(new PdfAxialShading(new PdfDeviceCs.Rgb(), 45, 750, ColorConstants.PINK.getColorValue(), 100, 760, ColorConstants.MAGENTA.getColorValue())) : null; - PdfPattern pattern2 = pattern ? new PdfPattern.Shading(new PdfShading.Axial(new PdfDeviceCs.Rgb(), 45, 690, ColorConstants.BLUE.getColorValue(), + PdfPattern pattern2 = pattern ? new PdfPattern.Shading(new PdfAxialShading(new PdfDeviceCs.Rgb(), 45, 690, ColorConstants.BLUE.getColorValue(), 100, 710, ColorConstants.CYAN.getColorValue())) : null; canvas.setColor(space, colorValue1, pattern1, true); @@ -660,7 +661,7 @@ private void setColorSameColorSpacesTest(String pdfName, boolean pattern) throws document.close(); - Assert.assertNull(new CompareTool().compareByContent(destFile, cmpFile, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destFile, cmpFile, DESTINATION_FOLDER, "diff_")); } private static int countSubstringOccurrences(String str, String findStr) { diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/PdfCanvasGlyphlineShowTextTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/PdfCanvasGlyphlineShowTextTest.java index 4bfe4e48e0..41bc6d4434 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/PdfCanvasGlyphlineShowTextTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/PdfCanvasGlyphlineShowTextTest.java @@ -32,29 +32,28 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfWriter; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; import java.util.Arrays; import java.util.List; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfCanvasGlyphlineShowTextTest extends ExtendedITextTest { public static final String destinationFolder = "./target/test/com/itextpdf/kernel/pdf/canvas/PdfCanvasGlyphlineShowTextTest/"; public static final String sourceFolder = "./src/test/resources/com/itextpdf/kernel/pdf/canvas/PdfCanvasGlyphlineShowTextTest/"; public static final String fontsFolder = "./src/test/resources/com/itextpdf/kernel/pdf/fonts/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(destinationFolder); } @@ -95,7 +94,7 @@ public void notoSerifWithInvalidXYPlacementAnchorDeltaTest() throws IOException, pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder)); } private Glyph applyGlyphParameters(char glyphUni, int anchorDelta, int xPlacement, int yPlacement, PdfFont font) { diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/PdfCanvasInlineImagesTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/PdfCanvasInlineImagesTest.java index d68f0ea8b6..c776e420fb 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/PdfCanvasInlineImagesTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/PdfCanvasInlineImagesTest.java @@ -38,27 +38,26 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; import java.io.InputStream; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfCanvasInlineImagesTest extends ExtendedITextTest { public static final String destinationFolder = "./target/test/com/itextpdf/kernel/pdf/canvas/PdfCanvasInlineImagesTest/"; public static final String sourceFolder = "./src/test/resources/com/itextpdf/kernel/pdf/canvas/PdfCanvasInlineImagesTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(destinationFolder); } @@ -87,7 +86,7 @@ public void inlineImagesTest01() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool() + Assertions.assertNull(new CompareTool() .compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder)); } @@ -142,7 +141,7 @@ public void inlineImagesTest02() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool() + Assertions.assertNull(new CompareTool() .compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder)); } @@ -160,12 +159,11 @@ public void inlineImagesTest03() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool() + Assertions.assertNull(new CompareTool() .compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder)); } @Test - //TODO update cmp-files after DEVSIX-3564 will be fixed public void inlineImagesPngTest() throws IOException, InterruptedException { String filename = "inlineImagePng.pdf"; PdfDocument document = new PdfDocument(CompareTool.createTestPdfWriter(destinationFolder + filename)); @@ -176,12 +174,11 @@ public void inlineImagesPngTest() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool() + Assertions.assertNull(new CompareTool() .compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder)); } @Test - //TODO update cmp-files after DEVSIX-3564 will be fixed public void inlineImagesPngErrorWhileOpenTest() throws IOException, InterruptedException { String filename = "inlineImagePngErrorWhileOpen.pdf"; PdfDocument document = new PdfDocument(CompareTool.createTestPdfWriter(destinationFolder + filename)); @@ -192,7 +189,7 @@ public void inlineImagesPngErrorWhileOpenTest() throws IOException, InterruptedE document.close(); - Assert.assertNull(new CompareTool() + Assertions.assertNull(new CompareTool() .compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder)); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/PdfCanvasTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/PdfCanvasTest.java index 376e8c1359..808cc4e153 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/PdfCanvasTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/PdfCanvasTest.java @@ -24,7 +24,11 @@ This file is part of the iText (R) project. import com.itextpdf.commons.utils.FileUtil; import com.itextpdf.commons.utils.MessageFormatUtil; +import com.itextpdf.io.font.PdfEncodings; import com.itextpdf.io.font.constants.StandardFonts; +import com.itextpdf.io.font.otf.ActualTextIterator; +import com.itextpdf.io.font.otf.Glyph; +import com.itextpdf.io.font.otf.GlyphLine; import com.itextpdf.io.image.ImageData; import com.itextpdf.io.image.ImageDataFactory; import com.itextpdf.io.source.ByteArrayOutputStream; @@ -34,6 +38,7 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.exceptions.KernelExceptionMessageConstant; import com.itextpdf.kernel.exceptions.MemoryLimitsAwareException; import com.itextpdf.kernel.exceptions.PdfException; +import com.itextpdf.kernel.font.PdfFont; import com.itextpdf.kernel.font.PdfFontFactory; import com.itextpdf.kernel.geom.Rectangle; import com.itextpdf.kernel.pdf.*; @@ -42,21 +47,21 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.AssertUtil; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; import java.util.List; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfCanvasTest extends ExtendedITextTest { /** @@ -71,6 +76,9 @@ public class PdfCanvasTest extends ExtendedITextTest { private static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/kernel/pdf/canvas/PdfCanvasTest/"; private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/kernel/pdf/canvas/PdfCanvasTest/"; + private static final String FONTS_FOLDER = "./src/test/resources/com/itextpdf/kernel/pdf/fonts/"; + + private static final String AUTHOR = "iText Software"; private static final String CREATOR = "iText"; private static final String TITLE = "Empty iText Document"; @@ -91,12 +99,12 @@ public void drawOnCanvas(PdfCanvas canvas, int pageNumber) throws IOException { }; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(DESTINATION_FOLDER); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(DESTINATION_FOLDER); } @@ -146,7 +154,7 @@ public void canvasDrawArcsTest() throws IOException, InterruptedException { canvas.release(); } - Assert.assertNull(new CompareTool().compareByContent(output, cmp, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(output, cmp, DESTINATION_FOLDER, "diff_")); } @Test @@ -501,14 +509,14 @@ public void copyPagesTest1() throws IOException, InterruptedException { for (int i = 1; i <= pdfDocument.getNumberOfPages(); i++) { PdfDictionary page = pdfDocument.getPage(i).getPdfObject(); - Assert.assertEquals(PdfName.Page, page.get(PdfName.Type)); + Assertions.assertEquals(PdfName.Page, page.get(PdfName.Type)); } reader.close(); - Assert.assertEquals("Rebuilt", false, reader.hasRebuiltXref()); + Assertions.assertEquals(false, reader.hasRebuiltXref(), "Rebuilt"); PdfDictionary page = pdfDocument.getPage(1).getPdfObject(); - Assert.assertNotNull(page.get(PdfName.Parent)); + Assertions.assertNotNull(page.get(PdfName.Parent)); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(file1, file2, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(file1, file2, DESTINATION_FOLDER, "diff_")); } @Test @@ -548,9 +556,9 @@ public void copyPagesTest2() throws IOException { PdfReader reader = CompareTool.createOutputReader(file2); PdfDocument pdfDocument = new PdfDocument(reader); - Assert.assertEquals("Rebuilt", false, reader.hasRebuiltXref()); + Assertions.assertEquals(false, reader.hasRebuiltXref(), "Rebuilt"); PdfDictionary page = pdfDocument.getPage(1).getPdfObject(); - Assert.assertNotNull(page.get(PdfName.Parent)); + Assertions.assertNotNull(page.get(PdfName.Parent)); pdfDocument.close(); CompareTool cmpTool = new CompareTool(); @@ -560,7 +568,7 @@ public void copyPagesTest2() throws IOException { for (int i = 0; i < 10; i++) { PdfDictionary page1 = doc1.getPage(i + 1).getPdfObject(); PdfDictionary page2 = doc2.getPage(10 - i).getPdfObject(); - Assert.assertTrue(cmpTool.compareDictionaries(page1, page2)); + Assertions.assertTrue(cmpTool.compareDictionaries(page1, page2)); } doc1.close(); @@ -606,14 +614,14 @@ public void copyPagesTest3() throws IOException { CompareTool cmpTool = new CompareTool(); PdfReader reader1 = CompareTool.createOutputReader(file1); PdfDocument doc1 = new PdfDocument(reader1); - Assert.assertEquals("Rebuilt", false, reader1.hasRebuiltXref()); + Assertions.assertEquals(false, reader1.hasRebuiltXref(), "Rebuilt"); PdfDictionary p1 = doc1.getPage(1).getPdfObject(); PdfReader reader2 = CompareTool.createOutputReader(file2); PdfDocument doc2 = new PdfDocument(reader2); - Assert.assertEquals("Rebuilt", false, reader2.hasRebuiltXref()); + Assertions.assertEquals(false, reader2.hasRebuiltXref(), "Rebuilt"); for (int i = 0; i < 10; i++) { PdfDictionary p2 = doc2.getPage(i + 1).getPdfObject(); - Assert.assertTrue(cmpTool.compareDictionaries(p1, p2)); + Assertions.assertTrue(cmpTool.compareDictionaries(p1, p2)); } doc1.close(); doc2.close(); @@ -654,14 +662,14 @@ public void copyPagesTest4() throws IOException { CompareTool cmpTool = new CompareTool(); PdfReader reader1 = CompareTool.createOutputReader(file1); PdfDocument doc1 = new PdfDocument(reader1); - Assert.assertEquals("Rebuilt", false, reader1.hasRebuiltXref()); + Assertions.assertEquals(false, reader1.hasRebuiltXref(), "Rebuilt"); for (int i = 0; i < 5; i++) { PdfDictionary page1 = doc1.getPage(i + 1).getPdfObject(); PdfDocument doc2 = new PdfDocument(CompareTool.createOutputReader( DESTINATION_FOLDER + MessageFormatUtil.format("copyPages4_{0}.pdf", i + 2))); PdfDictionary page = doc2.getPage(1).getPdfObject(); - Assert.assertTrue(cmpTool.compareDictionaries(page1, page)); + Assertions.assertTrue(cmpTool.compareDictionaries(page1, page)); doc2.close(); } @@ -710,13 +718,13 @@ public void copyPagesTest5() throws IOException { for (int i = 0; i < 3; i++) { PdfReader reader1 = CompareTool.createOutputReader(DESTINATION_FOLDER + MessageFormatUtil.format("copyPages5_{0}.pdf", i + 1)); PdfDocument doc1 = new PdfDocument(reader1); - Assert.assertEquals("Rebuilt", false, reader1.hasRebuiltXref()); + Assertions.assertEquals(false, reader1.hasRebuiltXref(), "Rebuilt"); PdfReader reader2 = CompareTool.createOutputReader(DESTINATION_FOLDER + "copyPages5_4.pdf"); PdfDocument doc2 = new PdfDocument(reader2); - Assert.assertEquals("Rebuilt", false, reader2.hasRebuiltXref()); + Assertions.assertEquals(false, reader2.hasRebuiltXref(), "Rebuilt"); PdfDictionary page1 = doc1.getPage(1).getPdfObject(); PdfDictionary page2 = doc2.getPage(i + 1).getPdfObject(); - Assert.assertTrue(cmpTool.compareDictionaries(page1, page2)); + Assertions.assertTrue(cmpTool.compareDictionaries(page1, page2)); doc1.close(); doc2.close(); } @@ -774,19 +782,19 @@ public void copyPagesTest6() throws IOException { for (int i = 0; i < 3; i++) { PdfReader reader1 = CompareTool.createOutputReader(file1); PdfDocument doc1 = new PdfDocument(reader1); - Assert.assertEquals("Rebuilt", false, reader1.hasRebuiltXref()); + Assertions.assertEquals(false, reader1.hasRebuiltXref(), "Rebuilt"); PdfReader reader2 = CompareTool.createOutputReader(file2); PdfDocument doc2 = new PdfDocument(reader2); - Assert.assertEquals("Rebuilt", false, reader2.hasRebuiltXref()); + Assertions.assertEquals(false, reader2.hasRebuiltXref(), "Rebuilt"); PdfReader reader3 = CompareTool.createOutputReader(file3); PdfDocument doc3 = new PdfDocument(reader3); - Assert.assertEquals("Rebuilt", false, reader3.hasRebuiltXref()); + Assertions.assertEquals(false, reader3.hasRebuiltXref(), "Rebuilt"); PdfReader reader4 = CompareTool.createOutputReader(file1_upd); PdfDocument doc4 = new PdfDocument(reader4); - Assert.assertEquals("Rebuilt", false, reader4.hasRebuiltXref()); - Assert.assertTrue(cmpTool.compareDictionaries(doc1.getPage(1).getPdfObject(), doc4.getPage(2).getPdfObject())); - Assert.assertTrue(cmpTool.compareDictionaries(doc4.getPage(2).getPdfObject(), doc2.getPage(1).getPdfObject())); - Assert.assertTrue(cmpTool.compareDictionaries(doc2.getPage(1).getPdfObject(), doc4.getPage(1).getPdfObject())); + Assertions.assertEquals(false, reader4.hasRebuiltXref(), "Rebuilt"); + Assertions.assertTrue(cmpTool.compareDictionaries(doc1.getPage(1).getPdfObject(), doc4.getPage(2).getPdfObject())); + Assertions.assertTrue(cmpTool.compareDictionaries(doc4.getPage(2).getPdfObject(), doc2.getPage(1).getPdfObject())); + Assertions.assertTrue(cmpTool.compareDictionaries(doc2.getPage(1).getPdfObject(), doc4.getPage(1).getPdfObject())); doc1.close(); doc2.close(); doc3.close(); @@ -810,7 +818,7 @@ public void markedContentTest1() { } canvas.release(); document.close(); - Assert.assertEquals(KernelExceptionMessageConstant.UNBALANCED_BEGIN_END_MARKED_CONTENT_OPERATORS, message); + Assertions.assertEquals(KernelExceptionMessageConstant.UNBALANCED_BEGIN_END_MARKED_CONTENT_OPERATORS, message); } @Test @@ -833,7 +841,7 @@ public void markedContentTest2() throws Exception { canvas.release(); document.close(); - Assert.assertNull(new CompareTool().compareByContent( + Assertions.assertNull(new CompareTool().compareByContent( DESTINATION_FOLDER + "markedContentTest2.pdf", SOURCE_FOLDER + "cmp_markedContentTest2.pdf", DESTINATION_FOLDER, "diff_")); } @@ -846,13 +854,13 @@ public void graphicsStateTest1() { canvas.setLineWidth(3); canvas.saveState(); canvas.setLineWidth(5); - Assert.assertEquals(5, canvas.getGraphicsState().getLineWidth(), 0); + Assertions.assertEquals(5, canvas.getGraphicsState().getLineWidth(), 0); canvas.restoreState(); - Assert.assertEquals(3, canvas.getGraphicsState().getLineWidth(), 0); + Assertions.assertEquals(3, canvas.getGraphicsState().getLineWidth(), 0); PdfExtGState egs = new PdfExtGState(); egs.getPdfObject().put(com.itextpdf.kernel.pdf.PdfName.LW, new PdfNumber(2)); canvas.setExtGState(egs); - Assert.assertEquals(2, canvas.getGraphicsState().getLineWidth(), 0); + Assertions.assertEquals(2, canvas.getGraphicsState().getLineWidth(), 0); canvas.release(); document.close(); } @@ -868,7 +876,7 @@ public void wmfImageTest01() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + "wmfImageTest01.pdf", SOURCE_FOLDER + "cmp_wmfImageTest01.pdf", + Assertions.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + "wmfImageTest01.pdf", SOURCE_FOLDER + "cmp_wmfImageTest01.pdf", DESTINATION_FOLDER, "diff_")); } @@ -883,7 +891,7 @@ public void wmfImageTest02() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + "wmfImageTest02.pdf", SOURCE_FOLDER + "cmp_wmfImageTest02.pdf", + Assertions.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + "wmfImageTest02.pdf", SOURCE_FOLDER + "cmp_wmfImageTest02.pdf", DESTINATION_FOLDER, "diff_")); } @@ -899,7 +907,7 @@ public void wmfImageTest03() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + "wmfImageTest03.pdf", SOURCE_FOLDER + "cmp_wmfImageTest03.pdf", + Assertions.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + "wmfImageTest03.pdf", SOURCE_FOLDER + "cmp_wmfImageTest03.pdf", DESTINATION_FOLDER, "diff_")); } @@ -914,7 +922,7 @@ public void wmfImageTest04() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + "wmfImageTest04.pdf", SOURCE_FOLDER + "cmp_wmfImageTest04.pdf", + Assertions.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + "wmfImageTest04.pdf", SOURCE_FOLDER + "cmp_wmfImageTest04.pdf", DESTINATION_FOLDER, "diff_")); } @@ -932,7 +940,7 @@ public void wmfImageTest05() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + "wmfImageTest05.pdf", SOURCE_FOLDER + "cmp_wmfImageTest05.pdf", + Assertions.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + "wmfImageTest05.pdf", SOURCE_FOLDER + "cmp_wmfImageTest05.pdf", DESTINATION_FOLDER, "diff_")); } @@ -947,7 +955,7 @@ public void gifImageTest01() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + "gifImageTest01.pdf", SOURCE_FOLDER + "cmp_gifImageTest01.pdf", + Assertions.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + "gifImageTest01.pdf", SOURCE_FOLDER + "cmp_gifImageTest01.pdf", DESTINATION_FOLDER, "diff_")); } @@ -970,7 +978,7 @@ public void gifImageTest02() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + "gifImageTest02.pdf", SOURCE_FOLDER + "cmp_gifImageTest02.pdf", + Assertions.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + "gifImageTest02.pdf", SOURCE_FOLDER + "cmp_gifImageTest02.pdf", DESTINATION_FOLDER, "diff_")); } @@ -993,7 +1001,7 @@ public void gifImageTest03() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + "gifImageTest03.pdf", SOURCE_FOLDER + "cmp_gifImageTest03.pdf", + Assertions.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + "gifImageTest03.pdf", SOURCE_FOLDER + "cmp_gifImageTest03.pdf", DESTINATION_FOLDER, "diff_")); } @@ -1013,7 +1021,7 @@ public void gifImageTest04() throws IOException { PdfCanvas canvas = new PdfCanvas(page); try { ImageDataFactory.createGifFrame(baos.toByteArray(), 3); - Assert.fail("IOException expected"); + Assertions.fail("IOException expected"); } catch (com.itextpdf.io.exceptions.IOException ignored) { } @@ -1042,7 +1050,7 @@ public void gifImageTest05() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + "gifImageTest05.pdf", SOURCE_FOLDER + "cmp_gifImageTest05.pdf", + Assertions.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + "gifImageTest05.pdf", SOURCE_FOLDER + "cmp_gifImageTest05.pdf", DESTINATION_FOLDER, "diff_")); } @@ -1067,7 +1075,7 @@ public void awtImagesTest01() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + filename, SOURCE_FOLDER + "cmp_" + filename, + Assertions.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + filename, SOURCE_FOLDER + "cmp_" + filename, DESTINATION_FOLDER, "diff_")); } // Android-Conversion-Skip-Block-End @@ -1086,7 +1094,7 @@ public void canvasInitializationPageNoContentsKey() throws IOException, Interrup document.close(); - Assert.assertNull(new CompareTool().compareByContent(destFile, cmpFile, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destFile, cmpFile, DESTINATION_FOLDER, "diff_")); } @Test @@ -1104,7 +1112,7 @@ public void canvasInitializationStampingExistingStream() throws IOException, Int document.close(); - Assert.assertNull(new CompareTool().compareByContent(destFile, cmpFile, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destFile, cmpFile, DESTINATION_FOLDER, "diff_")); } @Test @@ -1145,7 +1153,7 @@ public boolean isMemoryLimitsAwarenessRequiredOnDecompression(PdfArray filters) PdfDocument document = new PdfDocument(new PdfReader(srcFile, properties)); PdfPage page = document.getPage(1); - Assert.assertThrows(MemoryLimitsAwareException.class, () ->{ + Assertions.assertThrows(MemoryLimitsAwareException.class, () ->{ new PdfCanvas(page.getLastContentStream(), page.getResources(), page.getDocument()); }); } @@ -1168,7 +1176,7 @@ public void canvasStampingJustCopiedStreamWithCompression() throws IOException, document.close(); - Assert.assertNull(new CompareTool().compareByContent(destFile, cmpFile, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destFile, cmpFile, DESTINATION_FOLDER, "diff_")); } @Test @@ -1224,7 +1232,7 @@ public void canvasSmallFontSize01() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(destFile, cmpFile, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destFile, cmpFile, DESTINATION_FOLDER, "diff_")); } @Test @@ -1238,7 +1246,7 @@ public void addWmfImageTest() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + "addWmfImage.pdf", + Assertions.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + "addWmfImage.pdf", SOURCE_FOLDER + "cmp_addWmfImage.pdf", DESTINATION_FOLDER, "diff_")); } @@ -1276,7 +1284,7 @@ public void setLeadingPositiveTest() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -1313,7 +1321,7 @@ public void setLeadingNegativeTest() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -1339,7 +1347,7 @@ public void wrongLengthOfTransMatrixTest() throws IOException, PdfException, Int document.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -1364,7 +1372,7 @@ public void concatMatrixPdfArrayTest() throws IOException, PdfException, Interru document.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -1402,7 +1410,7 @@ public void setMoveTextWithLeadingTest() throws IOException, InterruptedExceptio document.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -1436,7 +1444,7 @@ public void setNewLineTextTest() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -1469,7 +1477,7 @@ public void setPositiveTextRiseValueTest() throws IOException, InterruptedExcept document.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -1502,7 +1510,7 @@ public void setNegativeTextRiseValueTest() throws IOException, InterruptedExcept document.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -1535,7 +1543,7 @@ public void setPositiveWordSpacingValueTest() throws IOException, InterruptedExc document.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -1568,7 +1576,7 @@ public void setNegativeWordSpacingValueTest() throws IOException, InterruptedExc document.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -1601,7 +1609,7 @@ public void setPositiveCharSpacingValueTest() throws IOException, InterruptedExc document.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -1633,7 +1641,7 @@ public void setNegativeCharSpacingValueTest() throws IOException, InterruptedExc document.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -1665,7 +1673,7 @@ public void setNegativeHorizontalScalingValueTest() throws IOException, Interrup document.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -1697,7 +1705,7 @@ public void setPositiveHorizontalScalingValueTest() throws IOException, Interrup document.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -1727,7 +1735,127 @@ public void createSimpleCanvasWithPdfArrayText() throws IOException, Interrupted canvas.release(); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); + } + + @Test + public void ignorePageRotationForContentTest() throws IOException, InterruptedException { + final String outPdf = DESTINATION_FOLDER + "ignorePageRotationForContent.pdf"; + final String cmpPdf = SOURCE_FOLDER + "cmp_ignorePageRotationForContent.pdf"; + + try (PdfDocument pdfDoc = new PdfDocument(CompareTool.createTestPdfWriter(outPdf))) { + pdfDoc.getDocumentInfo().setAuthor(AUTHOR).setCreator(CREATOR).setTitle(TITLE); + + PdfPage page = pdfDoc.addNewPage().setRotation(270); + + // When "true": in case the page has a rotation, then new content will be automatically rotated in the + // opposite direction. On the rotated page this would look as if new content ignores page rotation. + page.setIgnorePageRotationForContent(true); + + PdfCanvas canvas = new PdfCanvas(page, false); + canvas + .saveState() + .beginText() + .moveText(180, 350) + .setFontAndSize(PdfFontFactory.createFont(StandardFonts.HELVETICA), 30) + .showText("Page rotation is set to 270 degrees,") + .endText() + .restoreState(); + PdfCanvas canvas2 = new PdfCanvas(page, false); + canvas2 + .saveState() + .beginText() + .moveText(180, 250) + .setFontAndSize(PdfFontFactory.createFont(StandardFonts.HELVETICA), 30) + .showText("but new content ignores page rotation") + .endText() + .restoreState(); + page.flush(); + } + + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); + } + + @Test + public void getResourcesTest() throws IOException { + final String outPdf = DESTINATION_FOLDER + "getResourcesDoc.pdf"; + + PdfDocument pdfDoc = new PdfDocument(CompareTool.createTestPdfWriter(outPdf)); + PdfPage page1 = pdfDoc.addNewPage(); + PdfCanvas canvas = new PdfCanvas(page1); + + canvas.saveState() + .beginText() + .moveText(150, 400) + .setFontAndSize(PdfFontFactory.createFont(), 8) + .showText("test text") + .endText() + .restoreState(); + + PdfResources resources = canvas.getResources(); + + pdfDoc.close(); + + Assertions.assertEquals(1, resources.getResourceNames().size()); + } + + @Test + public void attachContentStreamTest() throws IOException { + final String outPdf = DESTINATION_FOLDER + "attachContentStreamDoc.pdf"; + + PdfDocument pdfDoc = new PdfDocument(CompareTool.createTestPdfWriter(outPdf)); + PdfPage page1 = pdfDoc.addNewPage(); + PdfCanvas canvas = new PdfCanvas(page1); + + canvas.attachContentStream(new PdfStream("test".getBytes(StandardCharsets.UTF_8))); + String contentFromStream = new String(canvas.getContentStream().getBytes(), StandardCharsets.UTF_8); + pdfDoc.close(); + + Assertions.assertEquals("test", contentFromStream); + } + + @Test + public void graphicStateFontNullTest() throws IOException { + final String outPdf = DESTINATION_FOLDER + "showTextDoc.pdf"; + + try(PdfDocument pdfDoc = new PdfDocument(CompareTool.createTestPdfWriter(outPdf))) { + PdfPage page1 = pdfDoc.addNewPage(); + PdfCanvas canvas = new PdfCanvas(page1); + GlyphLine glyphLine = new GlyphLine(); + canvas.getGraphicsState().setFont(null); + ActualTextIterator actualTextIterator = new ActualTextIterator(glyphLine); + Assertions.assertThrows(PdfException.class, () -> + canvas.showText(glyphLine, actualTextIterator)); + } + } + + + + @Test + public void glyphlineActualTextTest() throws IOException { + String outFileName = DESTINATION_FOLDER + "glyphlineActualText.pdf"; + + try (PdfDocument pdfDocument = new PdfDocument(CompareTool.createTestPdfWriter(outFileName))) { + PdfFont font = PdfFontFactory.createFont(FONTS_FOLDER + "NotoSansCJKjp-Bold.otf", + PdfEncodings.IDENTITY_H); + + List glyphs = Collections.singletonList(font.getGlyph((int) '\u65E0')); + GlyphLine glyphLine = new GlyphLine(glyphs); + glyphLine.setActualText(0, 1, "TEST"); + PdfCanvas canvas = new PdfCanvas(pdfDocument.addNewPage()); + canvas + .saveState() + .beginText() + .setFontAndSize(font, 7) + .showText(glyphLine) + .endText() + .restoreState(); + + String contentstream = new String(canvas.getContentStream().getBytes(), StandardCharsets.UTF_8); + canvas.release(); + + Assertions.assertTrue(contentstream.contains("/ActualText")); + } } private void createStandardDocument(PdfWriter writer, int pageCount, ContentProvider contentProvider) throws IOException { @@ -1750,15 +1878,15 @@ private void createStandardDocument(PdfWriter writer, int pageCount, ContentProv private void assertStandardDocument(String filename, int pageCount) throws IOException { PdfReader reader = CompareTool.createOutputReader(filename); PdfDocument pdfDocument = new PdfDocument(reader); - Assert.assertEquals("Rebuilt", false, reader.hasRebuiltXref()); + Assertions.assertFalse(reader.hasRebuiltXref(), "Rebuilt"); PdfDictionary info = pdfDocument.getTrailer().getAsDictionary(PdfName.Info); - Assert.assertEquals("Author", AUTHOR, info.get(PdfName.Author).toString()); - Assert.assertEquals("Creator", CREATOR, info.get(PdfName.Creator).toString()); - Assert.assertEquals("Title", TITLE, info.get(PdfName.Title).toString()); - Assert.assertEquals("Page count", pageCount, pdfDocument.getNumberOfPages()); + Assertions.assertEquals(AUTHOR, info.get(PdfName.Author).toString(), "Author"); + Assertions.assertEquals(CREATOR, info.get(PdfName.Creator).toString(), "Creator"); + Assertions.assertEquals(TITLE, info.get(PdfName.Title).toString(), "Title"); + Assertions.assertEquals(pageCount, pdfDocument.getNumberOfPages(), "Page count"); for (int i = 1; i <= pageCount; i++) { PdfDictionary page = pdfDocument.getPage(i).getPdfObject(); - Assert.assertEquals(PdfName.Page, page.get(PdfName.Type)); + Assertions.assertEquals(PdfName.Page, page.get(PdfName.Type)); } pdfDocument.close(); } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/PdfCanvasUnitTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/PdfCanvasUnitTest.java index e7995d81f0..57d640d59b 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/PdfCanvasUnitTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/PdfCanvasUnitTest.java @@ -22,23 +22,39 @@ This file is part of the iText (R) project. */ package com.itextpdf.kernel.pdf.canvas; +import com.itextpdf.commons.datastructures.Tuple2; +import com.itextpdf.io.font.constants.StandardFonts; import com.itextpdf.io.source.ByteArrayOutputStream; import com.itextpdf.kernel.exceptions.KernelExceptionMessageConstant; import com.itextpdf.kernel.exceptions.PdfException; +import com.itextpdf.kernel.font.PdfFontFactory; import com.itextpdf.kernel.pdf.PdfArray; +import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.kernel.pdf.PdfDocument; +import com.itextpdf.kernel.pdf.PdfName; +import com.itextpdf.kernel.pdf.PdfObject; import com.itextpdf.kernel.pdf.PdfPage; import com.itextpdf.kernel.pdf.PdfResources; import com.itextpdf.kernel.pdf.PdfStream; import com.itextpdf.kernel.pdf.PdfWriter; +import com.itextpdf.kernel.pdf.extgstate.PdfExtGState; +import com.itextpdf.kernel.validation.IValidationChecker; +import com.itextpdf.kernel.validation.IValidationContext; +import com.itextpdf.kernel.validation.ValidationContainer; +import com.itextpdf.kernel.validation.ValidationType; +import com.itextpdf.kernel.validation.context.CanvasBmcValidationContext; +import com.itextpdf.kernel.validation.context.ExtendedGStateValidationContext; +import com.itextpdf.kernel.validation.context.FontGlyphsGStateValidationContext; +import com.itextpdf.kernel.validation.context.RenderingIntentValidationContext; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import java.io.IOException; +import java.util.Stack; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfCanvasUnitTest extends ExtendedITextTest { @Test @@ -47,10 +63,10 @@ public void unbalancedSaveRestoreStateOperatorsUnexpectedRestoreTest() { PdfStream pdfStream = new PdfStream(); PdfResources pdfResources = new PdfResources(); PdfCanvas pdfCanvas = new PdfCanvas(pdfStream, pdfResources, pdfDocument); - Assert.assertTrue(pdfCanvas.gsStack.isEmpty()); - Exception exception = Assert.assertThrows(PdfException.class, + Assertions.assertTrue(pdfCanvas.gsStack.isEmpty()); + Exception exception = Assertions.assertThrows(PdfException.class, () -> pdfCanvas.restoreState()); - Assert.assertEquals(KernelExceptionMessageConstant.UNBALANCED_SAVE_RESTORE_STATE_OPERATORS, + Assertions.assertEquals(KernelExceptionMessageConstant.UNBALANCED_SAVE_RESTORE_STATE_OPERATORS, exception.getMessage()); } @@ -60,9 +76,9 @@ public void unbalancedLayerOperatorUnexpectedEndTest() { PdfStream pdfStream = new PdfStream(); PdfResources pdfResources = new PdfResources(); PdfCanvas pdfCanvas = new PdfCanvas(pdfStream, pdfResources, pdfDocument); - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> pdfCanvas.endLayer()); - Assert.assertEquals(KernelExceptionMessageConstant.UNBALANCED_LAYER_OPERATORS, exception.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.UNBALANCED_LAYER_OPERATORS, exception.getMessage()); } @Test @@ -71,9 +87,9 @@ public void unbalancedBeginAndMarkedOperatorsUnexpectedEndTest() { PdfStream pdfStream = new PdfStream(); PdfResources pdfResources = new PdfResources(); PdfCanvas pdfCanvas = new PdfCanvas(pdfStream, pdfResources, pdfDocument); - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> pdfCanvas.endMarkedContent()); - Assert.assertEquals(KernelExceptionMessageConstant.UNBALANCED_BEGIN_END_MARKED_CONTENT_OPERATORS, + Assertions.assertEquals(KernelExceptionMessageConstant.UNBALANCED_BEGIN_END_MARKED_CONTENT_OPERATORS, exception.getMessage()); } @@ -82,9 +98,9 @@ public void fontAndSizeShouldBeSetBeforeShowTextTest01() { PdfDocument pdfDocument = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); PdfPage pdfPage = pdfDocument.addNewPage(); PdfCanvas pdfCanvas = new PdfCanvas(pdfPage); - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> pdfCanvas.showText("text")); - Assert.assertEquals(KernelExceptionMessageConstant.FONT_AND_SIZE_MUST_BE_SET_BEFORE_WRITING_ANY_TEXT, + Assertions.assertEquals(KernelExceptionMessageConstant.FONT_AND_SIZE_MUST_BE_SET_BEFORE_WRITING_ANY_TEXT, exception.getMessage()); } @@ -94,9 +110,114 @@ public void fontAndSizeShouldBeSetBeforeShowTextTest02() { PdfPage pdfPage = pdfDocument.addNewPage(); PdfCanvas pdfCanvas = new PdfCanvas(pdfPage); PdfArray pdfArray = new PdfArray(); - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> pdfCanvas.showText(pdfArray)); - Assert.assertEquals(KernelExceptionMessageConstant.FONT_AND_SIZE_MUST_BE_SET_BEFORE_WRITING_ANY_TEXT, + Assertions.assertEquals(KernelExceptionMessageConstant.FONT_AND_SIZE_MUST_BE_SET_BEFORE_WRITING_ANY_TEXT, exception.getMessage()); } + + @Test + public void renderingIntentValidationTest() { + try (PdfDocument doc = new PdfDocument(new PdfWriter(new ByteArrayOutputStream()))) { + ValidationContainer container = new ValidationContainer(); + CustomValidationChecker checker = new CustomValidationChecker(); + container.addChecker(checker); + doc.getDiContainer().register(ValidationContainer.class, container); + Assertions.assertNull(checker.intent); + final PdfPage pdfPage = doc.addNewPage(); + PdfCanvas pdfCanvas = new PdfCanvas(pdfPage); + final PdfName intent = new PdfName("Test"); + pdfCanvas.setRenderingIntent(intent); + Assertions.assertSame(intent, checker.intent); + } + } + + @Test + public void bmcValidationTest() { + try (PdfDocument doc = new PdfDocument(new PdfWriter(new ByteArrayOutputStream()))) { + ValidationContainer container = new ValidationContainer(); + CustomValidationChecker checker = new CustomValidationChecker(); + container.addChecker(checker); + doc.getDiContainer().register(ValidationContainer.class, container); + Assertions.assertNull(checker.intent); + final PdfPage pdfPage = doc.addNewPage(); + PdfCanvas pdfCanvas = new PdfCanvas(pdfPage); + final PdfName tag = new PdfName("Test"); + pdfCanvas.beginMarkedContent(tag); + Assertions.assertSame(tag, checker.currentBmc.getFirst()); + Assertions.assertNull(checker.currentBmc.getSecond()); + Assertions.assertEquals(1, checker.tagStructureStack.size()); + } + } + + @Test + public void fontGlyphsValidationTest() throws IOException { + try (PdfDocument doc = new PdfDocument(new PdfWriter(new ByteArrayOutputStream()))) { + ValidationContainer container = new ValidationContainer(); + CustomValidationChecker checker = new CustomValidationChecker(); + container.addChecker(checker); + doc.getDiContainer().register(ValidationContainer.class, container); + Assertions.assertNull(checker.intent); + final PdfPage pdfPage = doc.addNewPage(); + PdfCanvas pdfCanvas = new PdfCanvas(pdfPage); + pdfCanvas.beginText(); + pdfCanvas.setFontAndSize(PdfFontFactory.createFont(StandardFonts.COURIER), 24); + pdfCanvas.showText("Test"); + pdfCanvas.endText(); + Assertions.assertNotNull(checker.gState); + Assertions.assertNotNull(checker.contentStream); + } + } + + @Test + public void extendedGStateValidationTest() { + try (PdfDocument doc = new PdfDocument(new PdfWriter(new ByteArrayOutputStream()))) { + ValidationContainer container = new ValidationContainer(); + CustomValidationChecker checker = new CustomValidationChecker(); + container.addChecker(checker); + doc.getDiContainer().register(ValidationContainer.class, container); + Assertions.assertNull(checker.intent); + final PdfPage pdfPage = doc.addNewPage(); + PdfCanvas pdfCanvas = new PdfCanvas(pdfPage); + + pdfCanvas.setExtGState(new PdfExtGState()); + Assertions.assertNotNull(checker.gState); + Assertions.assertNotNull(checker.contentStream); + } + } + + private static class CustomValidationChecker implements IValidationChecker { + public PdfName intent; + public Stack> tagStructureStack; + public Tuple2 currentBmc; + public PdfStream contentStream; + public CanvasGraphicsState gState; + + @Override + public void validate(IValidationContext validationContext) { + if (validationContext.getType() == ValidationType.RENDERING_INTENT) { + intent = ((RenderingIntentValidationContext) validationContext).getIntent(); + } + if (validationContext.getType() == ValidationType.CANVAS_BEGIN_MARKED_CONTENT) { + CanvasBmcValidationContext bmcContext = (CanvasBmcValidationContext) validationContext; + tagStructureStack = bmcContext.getTagStructureStack(); + currentBmc = bmcContext.getCurrentBmc(); + } + if (validationContext.getType() == ValidationType.EXTENDED_GRAPHICS_STATE) { + ExtendedGStateValidationContext gContext = (ExtendedGStateValidationContext) validationContext; + contentStream = gContext.getContentStream(); + gState = gContext.getGraphicsState(); + } + if (validationContext.getType() == ValidationType.FONT_GLYPHS) { + FontGlyphsGStateValidationContext glyphsContext = (FontGlyphsGStateValidationContext) validationContext; + contentStream = glyphsContext.getContentStream(); + gState = glyphsContext.getGraphicsState(); + } + } + + @Override + public boolean isPdfObjectReadyToFlush(PdfObject object) { + return true; + } + } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/PdfCanvasXObjectTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/PdfCanvasXObjectTest.java index 5e8d3e6bbf..5219e03ddf 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/PdfCanvasXObjectTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/PdfCanvasXObjectTest.java @@ -35,30 +35,28 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.xobject.PdfXObject; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.ByteArrayOutputStream; import java.io.FileOutputStream; import java.io.IOException; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfCanvasXObjectTest extends ExtendedITextTest { public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/kernel/pdf/canvas/PdfCanvasXObjectTest/"; public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/kernel/pdf/canvas/PdfCanvasXObjectTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(DESTINATION_FOLDER); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(DESTINATION_FOLDER); } @@ -83,7 +81,7 @@ public void addFormXObjectXYWithoutMatrixTest() throws IOException, Interrupted document.close(); - Assert.assertNull(new CompareTool().compareByContent(destPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); } @Test @@ -105,7 +103,7 @@ public void addFormXObjectXYWithMatrixTest() throws IOException, InterruptedExc document.close(); - Assert.assertNull(new CompareTool().compareByContent(destPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); } @Test @@ -125,20 +123,20 @@ public void addImageXObjectAtTest() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(destPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); } @Test - @Category(UnitTest.class) + @Tag("UnitTest") public void addCustomXObjectAtTest() { PdfXObject pdfXObject = new CustomPdfXObject(new PdfStream()); PdfDocument document = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); PdfCanvas canvas = new PdfCanvas(document.addNewPage()); - Exception e = Assert.assertThrows(IllegalArgumentException.class, + Exception e = Assertions.assertThrows(IllegalArgumentException.class, () -> canvas.addXObjectAt(pdfXObject, 0, 0) ); - Assert.assertEquals("PdfFormXObject or PdfImageXObject expected.", e.getMessage()); + Assertions.assertEquals("PdfFormXObject or PdfImageXObject expected.", e.getMessage()); } // addXObjectFittedIntoRectangle(PdfXObject, Rectangle) test block (use PdfXObject#calculateProportionallyFitRectangleWithWidth) @@ -162,7 +160,7 @@ public void addFormXObjectXYWidthLessOneWithoutMatrixTest() throws IOException, document.close(); - Assert.assertNull(new CompareTool().compareByContent(destPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); } @Test @@ -184,7 +182,7 @@ public void addFormXObjectXYWidthLargerOneWithoutMatrixTest() throws IOException document.close(); - Assert.assertNull(new CompareTool().compareByContent(destPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); } @Test @@ -207,7 +205,7 @@ public void addFormXObjectXYWidthLessOneWithMatrixTest() throws IOException, In document.close(); - Assert.assertNull(new CompareTool().compareByContent(destPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); } @Test @@ -230,7 +228,7 @@ public void addFormXObjectXYWidthLargerOneWithMatrixTest() throws IOException, document.close(); - Assert.assertNull(new CompareTool().compareByContent(destPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); } // addXObjectFittedIntoRectangle(PdfXObject, Rectangle) test block (use PdfXObject#calculateProportionallyFitRectangleWithHeight) @@ -254,7 +252,7 @@ public void addFormXObjectXYHeightLessOneWithoutMatrixTest() throws IOException, document.close(); - Assert.assertNull(new CompareTool().compareByContent(destPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); } @Test @@ -276,7 +274,7 @@ public void addFormXObjectXYHeightLargerOneWithoutMatrixTest() throws IOExceptio document.close(); - Assert.assertNull(new CompareTool().compareByContent(destPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); } @Test @@ -299,7 +297,7 @@ public void addFormXObjectXYHeightLessOneWithMatrixTest() throws IOException, I document.close(); - Assert.assertNull(new CompareTool().compareByContent(destPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); } @Test @@ -322,7 +320,7 @@ public void addFormXObjectXYHeightLargerOneWithMatrixTest() throws IOException, document.close(); - Assert.assertNull(new CompareTool().compareByContent(destPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); } // addXObjectFittedIntoRectangle(PdfXObject, Rectangle) test block @@ -345,7 +343,7 @@ public void addFormXObjectRectangleLessWithoutMatrixTest() throws IOException, document.close(); - Assert.assertNull(new CompareTool().compareByContent(destPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); } @Test @@ -366,7 +364,7 @@ public void addFormXObjectRectangleLargerWithoutMatrixTest() throws IOException, document.close(); - Assert.assertNull(new CompareTool().compareByContent(destPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); } @Test @@ -388,7 +386,7 @@ public void addFormXObjectRectangleLessWithMatrixTest() throws IOException, Int document.close(); - Assert.assertNull(new CompareTool().compareByContent(destPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); } @Test @@ -410,20 +408,20 @@ public void addFormXObjectRectangleLargerWithMatrixTest() throws IOException, I document.close(); - Assert.assertNull(new CompareTool().compareByContent(destPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); } @Test - @Category(UnitTest.class) + @Tag("UnitTest") public void addCustomXObjectFittedIntoRectangleTest() { PdfXObject pdfXObject = new CustomPdfXObject(new PdfStream()); PdfDocument document = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); PdfCanvas pdfCanvas = new PdfCanvas(document.addNewPage()); - Exception e = Assert.assertThrows(IllegalArgumentException.class, + Exception e = Assertions.assertThrows(IllegalArgumentException.class, () -> pdfCanvas.addXObjectFittedIntoRectangle(pdfXObject, new Rectangle(0, 0, 0, 0)) ); - Assert.assertEquals("PdfFormXObject or PdfImageXObject expected.", e.getMessage()); + Assertions.assertEquals("PdfFormXObject or PdfImageXObject expected.", e.getMessage()); } // addXObject(PdfXObject) test block @@ -446,7 +444,7 @@ public void addFormXObjectWithoutMatrixTest() throws IOException, InterruptedEx document.close(); - Assert.assertNull(new CompareTool().compareByContent(destPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); } @Test @@ -468,7 +466,7 @@ public void addFormXObjectWithMatrixTest() throws IOException, InterruptedExcep document.close(); - Assert.assertNull(new CompareTool().compareByContent(destPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); } @Test @@ -488,7 +486,7 @@ public void addImageXObjectTest() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(destPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); } // addXObjectWithTransformationMatrix(PdfXObject, float, float, float, float, float, float) test block @@ -511,7 +509,7 @@ public void addFormXObjectWithTransformationMatrixTest() throws IOException, In document.close(); - Assert.assertNull(new CompareTool().compareByContent(destPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); } @Test @@ -531,20 +529,20 @@ public void addImageXObjectWithTransformationMatrixTest() throws IOException, I document.close(); - Assert.assertNull(new CompareTool().compareByContent(destPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); } @Test - @Category(UnitTest.class) + @Tag("UnitTest") public void addCustomXObjectTest() { PdfXObject pdfXObject = new CustomPdfXObject(new PdfStream()); PdfDocument document = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); PdfCanvas canvas = new PdfCanvas(document.addNewPage()); - Exception e = Assert.assertThrows(IllegalArgumentException.class, + Exception e = Assertions.assertThrows(IllegalArgumentException.class, () -> canvas.addXObject(pdfXObject) ); - Assert.assertEquals("PdfFormXObject or PdfImageXObject expected.", e.getMessage()); + Assertions.assertEquals("PdfFormXObject or PdfImageXObject expected.", e.getMessage()); } private static class CustomPdfXObject extends PdfXObject { @@ -583,7 +581,7 @@ public void addFormXObjectWithUserIdentityMatrixTest() throws IOException, Inte document.close(); - Assert.assertNull(new CompareTool().compareByContent(destPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); } @Test @@ -613,6 +611,6 @@ public void addFormXObjectWithIdentityMatrixTest() throws IOException, Interrup document.close(); - Assert.assertNull(new CompareTool().compareByContent(destPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/TextRenderInfoUnitTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/TextRenderInfoUnitTest.java index 358119475f..fc79fce85c 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/TextRenderInfoUnitTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/TextRenderInfoUnitTest.java @@ -32,14 +32,13 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfString; import com.itextpdf.kernel.pdf.canvas.parser.data.TextRenderInfo; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.util.Arrays; import java.util.Stack; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class TextRenderInfoUnitTest extends ExtendedITextTest { @Test @@ -55,8 +54,8 @@ public void textExtractGlyphAverageWidth() { float singleSpaceWidth = testTRI.getSingleSpaceWidth(); float iWidth = testTRI.getUnscaledWidth(); - Assert.assertTrue(iWidth < singleSpaceWidth); - Assert.assertEquals(6.671999931335449, singleSpaceWidth, 0); + Assertions.assertTrue(iWidth < singleSpaceWidth); + Assertions.assertEquals(6.671999931335449, singleSpaceWidth, 0); } private static PdfDictionary initFontDictWithNotSpecifiedWidthOfSpaceChar() { diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/draw/DashedLineTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/draw/DashedLineTest.java index feaba9f007..18600a3f94 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/draw/DashedLineTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/draw/DashedLineTest.java @@ -34,24 +34,23 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.canvas.parser.data.TextRenderInfo; import com.itextpdf.kernel.pdf.canvas.parser.listener.CharacterRenderInfo; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.Stack; -@Category(UnitTest.class) +@Tag("UnitTest") public class DashedLineTest extends ExtendedITextTest { @Test public void defaultDashedLineTest01() { DashedLine dashedLine = new DashedLine(); - Assert.assertEquals(ColorConstants.BLACK, dashedLine.getColor()); - Assert.assertEquals(1, dashedLine.getLineWidth(), 0.0001); + Assertions.assertEquals(ColorConstants.BLACK, dashedLine.getColor()); + Assertions.assertEquals(1, dashedLine.getLineWidth(), 0.0001); } @@ -59,21 +58,21 @@ public void defaultDashedLineTest01() { public void dashedLineWithSetWidthTest01() { DashedLine dashedLine = new DashedLine(20); - Assert.assertEquals(ColorConstants.BLACK, dashedLine.getColor()); - Assert.assertEquals(20, dashedLine.getLineWidth(), 0.0001); + Assertions.assertEquals(ColorConstants.BLACK, dashedLine.getColor()); + Assertions.assertEquals(20, dashedLine.getLineWidth(), 0.0001); } @Test public void dashedLineSettersTest01() { DashedLine dashedLine = new DashedLine(15); - Assert.assertEquals(ColorConstants.BLACK, dashedLine.getColor()); - Assert.assertEquals(15, dashedLine.getLineWidth(), 0.0001); + Assertions.assertEquals(ColorConstants.BLACK, dashedLine.getColor()); + Assertions.assertEquals(15, dashedLine.getLineWidth(), 0.0001); dashedLine.setColor(ColorConstants.RED); - Assert.assertEquals(ColorConstants.RED, dashedLine.getColor()); + Assertions.assertEquals(ColorConstants.RED, dashedLine.getColor()); dashedLine.setLineWidth(10); - Assert.assertEquals(10, dashedLine.getLineWidth(), 0.0001); + Assertions.assertEquals(10, dashedLine.getLineWidth(), 0.0001); } @Test @@ -95,6 +94,6 @@ public void dashedLineDrawTest01() { byte[] writtenContentBytes = canvas.getContentStream().getBytes(); - Assert.assertArrayEquals(expectedContent.getBytes(), writtenContentBytes); + Assertions.assertArrayEquals(expectedContent.getBytes(), writtenContentBytes); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/draw/DottedLineTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/draw/DottedLineTest.java index 04592f7b58..4d02cbcc74 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/draw/DottedLineTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/draw/DottedLineTest.java @@ -34,25 +34,24 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.canvas.parser.data.TextRenderInfo; import com.itextpdf.kernel.pdf.canvas.parser.listener.CharacterRenderInfo; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.Stack; -@Category(UnitTest.class) +@Tag("UnitTest") public class DottedLineTest extends ExtendedITextTest { @Test public void defaultDottedLineTest01() { DottedLine dottedLine = new DottedLine(); - Assert.assertEquals(ColorConstants.BLACK, dottedLine.getColor()); - Assert.assertEquals(1, dottedLine.getLineWidth(), 0.0001); - Assert.assertEquals(4, dottedLine.getGap(), 0.0001); + Assertions.assertEquals(ColorConstants.BLACK, dottedLine.getColor()); + Assertions.assertEquals(1, dottedLine.getLineWidth(), 0.0001); + Assertions.assertEquals(4, dottedLine.getGap(), 0.0001); } @@ -60,18 +59,18 @@ public void defaultDottedLineTest01() { public void dottedLineWithSetWidthTest01() { DottedLine dottedLine = new DottedLine(20); - Assert.assertEquals(ColorConstants.BLACK, dottedLine.getColor()); - Assert.assertEquals(4, dottedLine.getGap(), 0.0001); - Assert.assertEquals(20, dottedLine.getLineWidth(), 0.0001); + Assertions.assertEquals(ColorConstants.BLACK, dottedLine.getColor()); + Assertions.assertEquals(4, dottedLine.getGap(), 0.0001); + Assertions.assertEquals(20, dottedLine.getLineWidth(), 0.0001); } @Test public void dottedLineWithSetWidthAndGapTest01() { DottedLine dottedLine = new DottedLine(10, 15); - Assert.assertEquals(ColorConstants.BLACK, dottedLine.getColor()); - Assert.assertEquals(10, dottedLine.getLineWidth(), 0.0001); - Assert.assertEquals(15, dottedLine.getGap(), 0.0001); + Assertions.assertEquals(ColorConstants.BLACK, dottedLine.getColor()); + Assertions.assertEquals(10, dottedLine.getLineWidth(), 0.0001); + Assertions.assertEquals(15, dottedLine.getGap(), 0.0001); } @@ -79,19 +78,19 @@ public void dottedLineWithSetWidthAndGapTest01() { @Test public void dottedLineSettersTest01() { DottedLine dottedLine = new DottedLine(15); - Assert.assertEquals(ColorConstants.BLACK, dottedLine.getColor()); - Assert.assertEquals(15, dottedLine.getLineWidth(), 0.0001); - Assert.assertEquals(4, dottedLine.getGap(), 0.0001); + Assertions.assertEquals(ColorConstants.BLACK, dottedLine.getColor()); + Assertions.assertEquals(15, dottedLine.getLineWidth(), 0.0001); + Assertions.assertEquals(4, dottedLine.getGap(), 0.0001); dottedLine.setColor(ColorConstants.RED); - Assert.assertEquals(ColorConstants.RED, dottedLine.getColor()); + Assertions.assertEquals(ColorConstants.RED, dottedLine.getColor()); dottedLine.setLineWidth(10); - Assert.assertEquals(10, dottedLine.getLineWidth(), 0.0001); + Assertions.assertEquals(10, dottedLine.getLineWidth(), 0.0001); dottedLine.setGap(5); - Assert.assertEquals(5, dottedLine.getGap(), 0.0001); + Assertions.assertEquals(5, dottedLine.getGap(), 0.0001); } @@ -115,6 +114,6 @@ public void dottedLineDrawTest01() { byte[] writtenContentBytes = canvas.getContentStream().getBytes(); - Assert.assertArrayEquals(expectedContent.getBytes(), writtenContentBytes); + Assertions.assertArrayEquals(expectedContent.getBytes(), writtenContentBytes); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/draw/SolidLineTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/draw/SolidLineTest.java index 0ac82f6ed3..844e4946a6 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/draw/SolidLineTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/draw/SolidLineTest.java @@ -34,24 +34,23 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.canvas.parser.data.TextRenderInfo; import com.itextpdf.kernel.pdf.canvas.parser.listener.CharacterRenderInfo; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.Stack; -@Category(UnitTest.class) +@Tag("UnitTest") public class SolidLineTest extends ExtendedITextTest { @Test public void defaultSolidLineTest01() { SolidLine solidLine = new SolidLine(); - Assert.assertEquals(ColorConstants.BLACK, solidLine.getColor()); - Assert.assertEquals(1, solidLine.getLineWidth(), 0.0001); + Assertions.assertEquals(ColorConstants.BLACK, solidLine.getColor()); + Assertions.assertEquals(1, solidLine.getLineWidth(), 0.0001); } @@ -59,22 +58,22 @@ public void defaultSolidLineTest01() { public void solidLineWithSetWidthTest01() { SolidLine solidLine = new SolidLine(20); - Assert.assertEquals(ColorConstants.BLACK, solidLine.getColor()); - Assert.assertEquals(20, solidLine.getLineWidth(), 0.0001); + Assertions.assertEquals(ColorConstants.BLACK, solidLine.getColor()); + Assertions.assertEquals(20, solidLine.getLineWidth(), 0.0001); } @Test public void solidLineSettersTest01() { SolidLine solidLine = new SolidLine(15); - Assert.assertEquals(ColorConstants.BLACK, solidLine.getColor()); - Assert.assertEquals(15, solidLine.getLineWidth(), 0.0001); + Assertions.assertEquals(ColorConstants.BLACK, solidLine.getColor()); + Assertions.assertEquals(15, solidLine.getLineWidth(), 0.0001); solidLine.setColor(ColorConstants.RED); - Assert.assertEquals(ColorConstants.RED, solidLine.getColor()); + Assertions.assertEquals(ColorConstants.RED, solidLine.getColor()); solidLine.setLineWidth(10); - Assert.assertEquals(10, solidLine.getLineWidth(), 0.0001); + Assertions.assertEquals(10, solidLine.getLineWidth(), 0.0001); } @Test @@ -95,6 +94,6 @@ public void solidLineDrawTest01() { byte[] writtenContentBytes = canvas.getContentStream().getBytes(); - Assert.assertArrayEquals(expectedContent.getBytes(), writtenContentBytes); + Assertions.assertArrayEquals(expectedContent.getBytes(), writtenContentBytes); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/BidiTextExtractionTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/BidiTextExtractionTest.java index 9ac9e467c6..146c2fe9fa 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/BidiTextExtractionTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/BidiTextExtractionTest.java @@ -29,16 +29,15 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.canvas.parser.listener.FilteredEventListener; import com.itextpdf.kernel.pdf.canvas.parser.listener.LocationTextExtractionStrategy; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; -import org.junit.Assert; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class BidiTextExtractionTest extends ExtendedITextTest { private static final String sourceFolder = "./src/test/resources/com/itextpdf/kernel/parser/BidiTextExtractionTest/"; @@ -53,7 +52,7 @@ public void test01() throws IOException { String actualText = PdfTextExtractor.getTextFromPage(pdfDocument.getPage(1), new LocationTextExtractionStrategy().setRightToLeftRunDirection(true)); - Assert.assertEquals(expected, actualText); + Assertions.assertEquals(expected, actualText); } @Test @@ -86,7 +85,7 @@ public void test02() throws IOException { for (int i = 0; i < regions.length; i++) { String actualText = extractionStrategies[i].getResultantText(); - Assert.assertEquals(expectedText[i], actualText); + Assertions.assertEquals(expectedText[i], actualText); } } @@ -102,7 +101,7 @@ public void test03() throws IOException { String actualText = PdfTextExtractor.getTextFromPage(pdfDocument.getPage(1), new LocationTextExtractionStrategy()); - Assert.assertEquals(expectedText, actualText); + Assertions.assertEquals(expectedText, actualText); } @Test @@ -115,11 +114,11 @@ public void test04() throws IOException { String actualText = PdfTextExtractor.getTextFromPage(pdfDocument.getPage(1), new LocationTextExtractionStrategy().setRightToLeftRunDirection(true)); - Assert.assertEquals(expectedText, actualText); + Assertions.assertEquals(expectedText, actualText); } @Test - @Ignore("see DEVSIX-854") + @Disabled("see DEVSIX-854") // Not correct since iText cannot detect reordering automatically when no /ReversedChars is present. public void test05() throws IOException { PdfDocument pdfDocument = new PdfDocument(new PdfReader(sourceFolder + "in05.pdf")); @@ -128,7 +127,7 @@ public void test05() throws IOException { String actualText = PdfTextExtractor.getTextFromPage(pdfDocument.getPage(1), new LocationTextExtractionStrategy().setRightToLeftRunDirection(true)); - Assert.assertEquals(expectedText, actualText); + Assertions.assertEquals(expectedText, actualText); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/FilteredEventListenerTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/FilteredEventListenerTest.java index ac051200c3..cbf447f21d 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/FilteredEventListenerTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/FilteredEventListenerTest.java @@ -30,15 +30,14 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.canvas.parser.listener.FilteredTextEventListener; import com.itextpdf.kernel.pdf.canvas.parser.listener.LocationTextExtractionStrategy; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class FilteredEventListenerTest extends ExtendedITextTest { private static final String sourceFolder = "./src/test/resources/com/itextpdf/kernel/parser/FilteredEventListenerTest/"; @@ -76,7 +75,7 @@ public void test() throws IOException { for (int i = 0; i < regions.length; i++) { String actualText = extractionStrategies[i].getResultantText(); - Assert.assertEquals(expectedText[i], actualText); + Assertions.assertEquals(expectedText[i], actualText); } } @@ -100,6 +99,6 @@ public void multipleFiltersForOneRegionTest() throws IOException { String expectedText = PdfTextExtractor.getTextFromPage(pdfDocument.getPage(1), new FilteredTextEventListener(new LocationTextExtractionStrategy(), regionFilters)); - Assert.assertEquals(expectedText, actualText); + Assertions.assertEquals(expectedText, actualText); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/FilteredTextEventListenerTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/FilteredTextEventListenerTest.java index da085532f1..935ad65899 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/FilteredTextEventListenerTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/FilteredTextEventListenerTest.java @@ -28,14 +28,13 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.canvas.parser.listener.LocationTextExtractionStrategy; import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfReader; -import com.itextpdf.test.annotations.type.IntegrationTest; import com.itextpdf.test.ExtendedITextTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class FilteredTextEventListenerTest extends ExtendedITextTest { private static final String sourceFolder = "./src/test/resources/com/itextpdf/kernel/parser/FilteredTextEventListenerTest/"; @@ -46,8 +45,8 @@ public void testRegion() throws Exception { float pageHeight = doc.getPage(1).getPageSize().getHeight(); Rectangle upperLeft = new Rectangle(0, (int) pageHeight - 30, 250, (int) pageHeight); - Assert.assertTrue(textIsInRectangle(doc, "Upper Left", upperLeft)); - Assert.assertFalse(textIsInRectangle(doc, "Upper Right", upperLeft)); + Assertions.assertTrue(textIsInRectangle(doc, "Upper Left", upperLeft)); + Assertions.assertFalse(textIsInRectangle(doc, "Upper Right", upperLeft)); } private boolean textIsInRectangle(PdfDocument doc, String text, Rectangle rect) { diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/GlyphBboxCalculationTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/GlyphBboxCalculationTest.java index 7bc1b9a32e..2f977a9565 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/GlyphBboxCalculationTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/GlyphBboxCalculationTest.java @@ -36,14 +36,13 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.canvas.parser.listener.ITextExtractionStrategy; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.util.ArrayList; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; import java.util.Collections; @@ -51,18 +50,18 @@ This file is part of the iText (R) project. import java.util.List; import java.util.Set; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class GlyphBboxCalculationTest extends ExtendedITextTest { private static final String sourceFolder = "./src/test/resources/com/itextpdf/kernel/pdf/canvas/parser/GlyphBboxCalculationTest/"; private static final String destinationFolder = "./target/test/com/itextpdf/kernel/pdf/canvas/parser/GlyphBboxCalculationTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(destinationFolder); } @@ -75,7 +74,7 @@ public void checkBboxCalculationForType3FontsWithFontMatrix01() throws IOExcepti PdfCanvasProcessor processor = new PdfCanvasProcessor(listener); processor.processPageContent(pdfDocument.getPage(1)); // font size (36) * |fontMatrix| (0.001) * glyph width (600) = 21.6 - Assert.assertEquals(21.6, listener.glyphWidth, 1e-5); + Assertions.assertEquals(21.6, listener.glyphWidth, 1e-5); } @Test @@ -86,7 +85,7 @@ public void checkBboxCalculationForType3FontsWithFontMatrix02() throws IOExcepti PdfCanvasProcessor processor = new PdfCanvasProcessor(listener); processor.processPageContent(pdfDocument.getPage(1)); // font size (36) * |fontMatrix| (1) * glyph width (0.6) = 21.6 - Assert.assertEquals(21.6, listener.glyphWidth, 1e-5); + Assertions.assertEquals(21.6, listener.glyphWidth, 1e-5); } @Test @@ -96,7 +95,7 @@ public void checkAverageBboxCalculationForType3FontsWithFontMatrix01Test() throw CharacterPositionEventListener listener = new CharacterPositionEventListener(); PdfCanvasProcessor processor = new PdfCanvasProcessor(listener); processor.processPageContent(pdfDocument.getPage(1)); - Assert.assertEquals(600, listener.firstTextRenderInfo.getFont().getFontProgram().getAvgWidth(), 0.01f); + Assertions.assertEquals(600, listener.firstTextRenderInfo.getFont().getFontProgram().getAvgWidth(), 0.01f); } @Test @@ -118,7 +117,7 @@ public void type3FontsWithIdentityFontMatrixAndMultiplier() throws IOException, .endText(); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(outputPdf, sourceFolder + "cmp_type3FontsWithIdentityFontMatrixAndMultiplier.pdf", destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outputPdf, sourceFolder + "cmp_type3FontsWithIdentityFontMatrixAndMultiplier.pdf", destinationFolder, "diff_")); } @Test @@ -139,8 +138,8 @@ public void type3FontCustomFontMatrixAndFontBBoxTest() throws IOException { actualRectangles = eventListener.getRectangles(); } - Assert.assertEquals(1, actualRectangles.size()); - Assert.assertTrue(expectedRectangle.equalsWithEpsilon(actualRectangles.get(0))); + Assertions.assertEquals(1, actualRectangles.size()); + Assertions.assertTrue(expectedRectangle.equalsWithEpsilon(actualRectangles.get(0))); } private static class CharacterPositionEventListener implements ITextExtractionStrategy { diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/GlyphTextEventListenerTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/GlyphTextEventListenerTest.java index 186aac55b7..1d3eb973a3 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/GlyphTextEventListenerTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/GlyphTextEventListenerTest.java @@ -33,15 +33,14 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfReader; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class GlyphTextEventListenerTest extends ExtendedITextTest { private static final String sourceFolder = "./src/test/resources/com/itextpdf/kernel/parser/GlyphTextEventListenerTest/"; @@ -58,7 +57,7 @@ public void test01() throws IOException { String extractedText = PdfTextExtractor.getTextFromPage(pdfDocument.getPage(1), new GlyphTextEventListener(new FilteredTextEventListener(new LocationTextExtractionStrategy(), new TextRegionEventFilter(new Rectangle(x1, y1, x2, y2))))); - Assert.assertEquals("1234\nt5678", extractedText); + Assertions.assertEquals("1234\nt5678", extractedText); } @Test @@ -68,7 +67,7 @@ public void test02() throws IOException { String extractedText = PdfTextExtractor.getTextFromPage(pdfDocument.getPage(1), new GlyphTextEventListener(new FilteredTextEventListener(new LocationTextExtractionStrategy(), new TextRegionEventFilter(new Rectangle(111, 855, 25, 12))))); - Assert.assertEquals("Your ", extractedText); + Assertions.assertEquals("Your ", extractedText); } @Test @@ -95,8 +94,8 @@ public void testWithMultiFilteredRenderListener() throws IOException { PdfCanvasProcessor parser = new PdfCanvasProcessor(new GlyphEventListener(listener)); parser.processPageContent(pdfDocument.getPage(1)); - Assert.assertEquals("Your", region1Listener.getResultantText()); - Assert.assertEquals("dju", region2Listener.getResultantText()); + Assertions.assertEquals("Your", region1Listener.getResultantText()); + Assertions.assertEquals("dju", region2Listener.getResultantText()); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/HighlightItemsTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/HighlightItemsTest.java index f11e4529d7..d2891f8a68 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/HighlightItemsTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/HighlightItemsTest.java @@ -34,7 +34,6 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.canvas.parser.listener.IEventListener; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; import java.util.ArrayList; @@ -43,25 +42,25 @@ This file is part of the iText (R) project. import java.util.List; import java.util.Set; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class HighlightItemsTest extends ExtendedITextTest { private static final String sourceFolder = "./src/test/resources/com/itextpdf/kernel/pdf/canvas/parser/HighlightItemsTest/"; private static final String outputPath = "./target/test/com/itextpdf/kernel/parser/HighlightItemsTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(outputPath); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(outputPath); } @@ -73,7 +72,7 @@ public void highlightPage229() throws IOException, InterruptedException { String cmp = sourceFolder + "cmp_page229.pdf"; PdfWriter writer = CompareTool.createTestPdfWriter(output); parseAndHighlight(input, writer, false); - Assert.assertEquals(null, new CompareTool().compareByContent(output, cmp, outputPath, "diff")); + Assertions.assertEquals(null, new CompareTool().compareByContent(output, cmp, outputPath, "diff")); } @Test @@ -83,7 +82,7 @@ public void highlightCharactersPage229() throws IOException, InterruptedExceptio String cmp = sourceFolder + "cmp_page229_characters.pdf"; PdfWriter writer = CompareTool.createTestPdfWriter(output); parseAndHighlight(input, writer, true); - Assert.assertEquals(null, new CompareTool().compareByContent(output, cmp, outputPath, "diff")); + Assertions.assertEquals(null, new CompareTool().compareByContent(output, cmp, outputPath, "diff")); } @Test @@ -93,7 +92,7 @@ public void highlightIsoTc171() throws IOException, InterruptedException { String cmp = sourceFolder + "cmp_ISO-TC171-SC2_N0896_SC2WG5_Edinburgh_Agenda.pdf"; PdfWriter writer = CompareTool.createTestPdfWriter(output); parseAndHighlight(input, writer, false); - Assert.assertEquals(null, new CompareTool().compareByContent(output, cmp, outputPath, "diff")); + Assertions.assertEquals(null, new CompareTool().compareByContent(output, cmp, outputPath, "diff")); } @Test @@ -103,7 +102,7 @@ public void highlightCharactersIsoTc171() throws IOException, InterruptedExcepti String cmp = sourceFolder + "cmp_ISO-TC171-SC2_N0896_SC2WG5_Edinburgh_Agenda_characters.pdf"; PdfWriter writer = CompareTool.createTestPdfWriter(output); parseAndHighlight(input, writer, true); - Assert.assertEquals(null, new CompareTool().compareByContent(output, cmp, outputPath, "diff")); + Assertions.assertEquals(null, new CompareTool().compareByContent(output, cmp, outputPath, "diff")); } @Test @@ -113,7 +112,7 @@ public void highlightHeaderFooter() throws IOException, InterruptedException { String cmp = sourceFolder + "cmp_HeaderFooter.pdf"; PdfWriter writer = CompareTool.createTestPdfWriter(output); parseAndHighlight(input, writer, false); - Assert.assertEquals(null, new CompareTool().compareByContent(output, cmp, outputPath, "diff")); + Assertions.assertEquals(null, new CompareTool().compareByContent(output, cmp, outputPath, "diff")); } @Test @@ -123,7 +122,7 @@ public void highlightCharactersHeaderFooter() throws IOException, InterruptedExc String cmp = sourceFolder + "cmp_HeaderFooter_characters.pdf"; PdfWriter writer = CompareTool.createTestPdfWriter(output); parseAndHighlight(input, writer, true); - Assert.assertEquals(null, new CompareTool().compareByContent(output, cmp, outputPath, "diff")); + Assertions.assertEquals(null, new CompareTool().compareByContent(output, cmp, outputPath, "diff")); } @Test @@ -133,7 +132,7 @@ public void highlightReferencePage2Test() throws IOException, InterruptedExcepti String cmp = sourceFolder + "cmp_reference_page2_characters.pdf"; PdfWriter writer = CompareTool.createTestPdfWriter(output); parseAndHighlight(input, writer, true); - Assert.assertEquals(null, new CompareTool().compareByContent(output, cmp, outputPath, "diff")); + Assertions.assertEquals(null, new CompareTool().compareByContent(output, cmp, outputPath, "diff")); } @Test @@ -143,7 +142,7 @@ public void highlightReferencePage832Test() throws IOException, InterruptedExcep String cmp = sourceFolder + "cmp_reference_page832_characters.pdf"; PdfWriter writer = CompareTool.createTestPdfWriter(output); parseAndHighlight(input, writer, true); - Assert.assertEquals(null, new CompareTool().compareByContent(output, cmp, outputPath, "diff")); + Assertions.assertEquals(null, new CompareTool().compareByContent(output, cmp, outputPath, "diff")); } @Test @@ -153,7 +152,7 @@ public void highlightReferencePage604Test() throws IOException, InterruptedExcep String cmp = sourceFolder + "cmp_reference_page604_characters.pdf"; PdfWriter writer = CompareTool.createTestPdfWriter(output); parseAndHighlight(input, writer, true); - Assert.assertEquals(null, new CompareTool().compareByContent(output, cmp, outputPath, "diff")); + Assertions.assertEquals(null, new CompareTool().compareByContent(output, cmp, outputPath, "diff")); } @Test @@ -163,7 +162,7 @@ public void highlightNotDefTest() throws IOException, InterruptedException { String cmp = sourceFolder + "cmp_notdefWidth.pdf"; PdfWriter writer = CompareTool.createTestPdfWriter(output); parseAndHighlight(input, writer, false); - Assert.assertEquals(null, new CompareTool().compareByContent(output, cmp, outputPath, "diff")); + Assertions.assertEquals(null, new CompareTool().compareByContent(output, cmp, outputPath, "diff")); } @Test @@ -173,7 +172,7 @@ public void fillStandardEncodingType1NoDescriptorTest() throws IOException, Inte String cmp = sourceFolder + "cmp_fillStandardEncodingType1NoDescriptorTest.pdf"; PdfWriter writer = CompareTool.createTestPdfWriter(output); parseAndHighlight(input, writer, true); - Assert.assertNull(new CompareTool().compareByContent(output, cmp, outputPath)); + Assertions.assertNull(new CompareTool().compareByContent(output, cmp, outputPath)); } @Test @@ -183,7 +182,7 @@ public void fillStandardEncodingTrueTypeFontDescriptorTest() throws IOException, String cmp = sourceFolder + "cmp_fillStandardEncodingTrueTypeFontDescriptorTest.pdf"; PdfWriter writer = CompareTool.createTestPdfWriter(output); parseAndHighlight(input, writer, true); - Assert.assertNull(new CompareTool().compareByContent(output, cmp, outputPath)); + Assertions.assertNull(new CompareTool().compareByContent(output, cmp, outputPath)); } @Test @@ -193,7 +192,7 @@ public void fillStandardEncodingType1FontDescriptorTest() throws IOException, In String cmp = sourceFolder + "cmp_fillStandardEncodingType1FontDescriptorTest.pdf"; PdfWriter writer = CompareTool.createTestPdfWriter(output); parseAndHighlight(input, writer, true); - Assert.assertNull(new CompareTool().compareByContent(output, cmp, outputPath)); + Assertions.assertNull(new CompareTool().compareByContent(output, cmp, outputPath)); } @Test @@ -205,7 +204,7 @@ public void incorrectAscentFontDescriptorTest() throws IOException, InterruptedE String cmp = sourceFolder + "cmp_incorrectAscentFontDescriptorTest.pdf"; PdfWriter writer = CompareTool.createTestPdfWriter(output); parseAndHighlight(input, writer, true); - Assert.assertNull(new CompareTool().compareByContent(output, cmp, outputPath)); + Assertions.assertNull(new CompareTool().compareByContent(output, cmp, outputPath)); } @Test @@ -215,7 +214,7 @@ public void incorrectDescentFontDescriptorTest() throws IOException, Interrupted String cmp = sourceFolder + "cmp_incorrectDescentFontDescriptorTest.pdf"; PdfWriter writer = CompareTool.createTestPdfWriter(output); parseAndHighlight(input, writer, true); - Assert.assertNull(new CompareTool().compareByContent(output, cmp, outputPath)); + Assertions.assertNull(new CompareTool().compareByContent(output, cmp, outputPath)); } @Test @@ -225,7 +224,7 @@ public void fontDictWidthArrayMissingWidthTest() throws IOException, Interrupted String cmp = sourceFolder + "cmp_fontDictWidthArrayMissingWidthTest.pdf"; PdfWriter writer = CompareTool.createTestPdfWriter(output); parseAndHighlight(input, writer, true); - Assert.assertNull(new CompareTool().compareByContent(output, cmp, outputPath)); + Assertions.assertNull(new CompareTool().compareByContent(output, cmp, outputPath)); } @Test @@ -235,7 +234,7 @@ public void trueTypeCIDFontWithDWWithoutProperWidthGlyphTest() throws IOExceptio String cmp = sourceFolder + "cmp_trueTypeCIDFontWithDWWithoutProperWidthGlyphTest.pdf"; PdfWriter writer = CompareTool.createTestPdfWriter(output); parseAndHighlight(input, writer, true); - Assert.assertNull(new CompareTool().compareByContent(output, cmp, outputPath)); + Assertions.assertNull(new CompareTool().compareByContent(output, cmp, outputPath)); } @Test @@ -245,7 +244,7 @@ public void doubleMappingSimpleFontTest() throws IOException, InterruptedExcepti String cmp = sourceFolder + "cmp_doubleMappingSimpleFont.pdf"; PdfWriter writer = CompareTool.createTestPdfWriter(output); parseAndHighlight(input, writer, false); - Assert.assertNull(new CompareTool().compareByContent(output, cmp, outputPath)); + Assertions.assertNull(new CompareTool().compareByContent(output, cmp, outputPath)); } @Test @@ -255,7 +254,7 @@ public void doubleMappingSimpleFontTest2() throws IOException, InterruptedExcept String cmp = sourceFolder + "cmp_doubleMappingSimpleFont2.pdf"; PdfWriter writer = CompareTool.createTestPdfWriter(output); parseAndHighlight(input, writer, true); - Assert.assertNull(new CompareTool().compareByContent(output, cmp, outputPath)); + Assertions.assertNull(new CompareTool().compareByContent(output, cmp, outputPath)); } private void parseAndHighlight(String input, PdfWriter writer, boolean singleCharacters) throws IOException { diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/IndicTextExtractionTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/IndicTextExtractionTest.java index 78c656e8c0..fc6c484c60 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/IndicTextExtractionTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/IndicTextExtractionTest.java @@ -29,15 +29,14 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfReader; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class IndicTextExtractionTest extends ExtendedITextTest { private static final String sourceFolder = "./src/test/resources/com/itextpdf/kernel/parser/IndicTextExtractionTest/"; @@ -79,7 +78,7 @@ public void test01() throws IOException { for (int i = 0; i < regions.length; i++) { String actualText = extractionStrategies[i].getResultantText(); - Assert.assertEquals(expectedText[i], actualText); + Assertions.assertEquals(expectedText[i], actualText); } } @@ -97,7 +96,7 @@ public void test02() throws IOException { PdfDocument pdfDocument = new PdfDocument(new PdfReader(sourceFolder + "test02.pdf")); String extractedText = PdfTextExtractor.getTextFromPage(pdfDocument.getPage(1), new LocationTextExtractionStrategy().setUseActualText(true)); - Assert.assertEquals(expectedText, extractedText); + Assertions.assertEquals(expectedText, extractedText); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/InlineImageExtractionTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/InlineImageExtractionTest.java index ff8477209c..7d6607bd32 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/InlineImageExtractionTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/InlineImageExtractionTest.java @@ -22,6 +22,7 @@ This file is part of the iText (R) project. */ package com.itextpdf.kernel.pdf.canvas.parser; +import com.itextpdf.kernel.pdf.PdfArray; import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfName; @@ -32,11 +33,12 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.canvas.parser.data.IEventData; import com.itextpdf.kernel.pdf.canvas.parser.data.ImageRenderInfo; import com.itextpdf.kernel.pdf.canvas.parser.listener.IEventListener; +import com.itextpdf.kernel.pdf.canvas.parser.listener.SimpleTextExtractionStrategy; +import com.itextpdf.kernel.pdf.colorspace.PdfColorSpace; import com.itextpdf.kernel.pdf.colorspace.PdfSpecialCs.Indexed; import com.itextpdf.kernel.pdf.xobject.PdfImageXObject; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; import java.nio.file.Files; @@ -46,17 +48,17 @@ This file is part of the iText (R) project. import java.util.LinkedHashSet; import java.util.List; import java.util.Set; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class InlineImageExtractionTest extends ExtendedITextTest { public static final String destinationFolder = "./target/test/com/itextpdf/kernel/pdf/canvas/parser/InlineImageExtractionTest/"; public static final String sourceFolder = "./src/test/resources/com/itextpdf/kernel/pdf/canvas/parser/InlineImageExtractionTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } @@ -72,11 +74,11 @@ public void extractSingleInlineImageWithIndexedColorSpaceTest() throws IOExcepti List inlineImages = eventListener.getInlineImages(); - Assert.assertEquals(1, inlineImages.size()); + Assertions.assertEquals(1, inlineImages.size()); byte[] imgBytes = inlineImages.get(0).getBytes(); byte[] cmpImgBytes = Files.readAllBytes(Paths.get(sourceFolder, "imgtest.dat")); - Assert.assertArrayEquals(cmpImgBytes, imgBytes); + Assertions.assertArrayEquals(cmpImgBytes, imgBytes); PdfDictionary expectedDict = new PdfDictionary(); expectedDict.put(PdfName.BitsPerComponent, new PdfNumber(8)); @@ -102,7 +104,7 @@ public void extractSingleInlineImageWithIndexedColorSpaceTest() throws IOExcepti Indexed expectedIndexedCs = new Indexed(PdfName.DeviceRGB, 255, new PdfString(indexedCsLookupData)); expectedDict.put(PdfName.ColorSpace, expectedIndexedCs.getPdfObject()); - Assert.assertTrue(new CompareTool().compareDictionaries(inlineImages.get(0), expectedDict)); + Assertions.assertTrue(new CompareTool().compareDictionaries(inlineImages.get(0), expectedDict)); } @Test @@ -117,24 +119,173 @@ public void parseInlineImageTest() throws IOException { byte[] cmpImgBytes = Files.readAllBytes(Paths.get(sourceFolder, "docWithInlineImageBytes.dat")); - Assert.assertArrayEquals(cmpImgBytes, data); + Assertions.assertArrayEquals(cmpImgBytes, data); + } + + @Test + public void parseInlineImageCalRGBColorSpaceTest() throws IOException { + try(PdfDocument pdf = new PdfDocument(new PdfReader(sourceFolder + "inlineImageCalRGBColorSpace.pdf"))){ + PdfCanvasProcessor pdfCanvasProcessor = new PdfCanvasProcessor(new SimpleTextExtractionStrategy()); + pdfCanvasProcessor.processPageContent(pdf.getPage(1)); + + PdfName name = new PdfName("Cs1"); + PdfColorSpace colorSpace = pdf.getPage(1).getResources().getColorSpace(name); + + PdfArray pdfArray = (PdfArray) colorSpace.getPdfObject(); + PdfName actualName = (PdfName) pdfArray.get(0); + + Assertions.assertEquals(PdfName.CalRGB, actualName); + } + } + + @Test + public void parseInlineImageCalGrayColorSpaceTest() throws IOException { + try(PdfDocument pdf = new PdfDocument(new PdfReader(sourceFolder + "inlineImageCalGrayColorSpace.pdf"))){ + PdfCanvasProcessor pdfCanvasProcessor = new PdfCanvasProcessor(new SimpleTextExtractionStrategy()); + pdfCanvasProcessor.processPageContent(pdf.getPage(1)); + + PdfName name = new PdfName("Cs1"); + PdfColorSpace colorSpace = pdf.getPage(1).getResources().getColorSpace(name); + + PdfArray pdfArray = (PdfArray) colorSpace.getPdfObject(); + PdfName actualName = (PdfName) pdfArray.get(0); + + Assertions.assertEquals(PdfName.CalGray, actualName); + } + } + + @Test + public void parseInlineImageLabColorSpaceTest() throws IOException { + try(PdfDocument pdf = new PdfDocument(new PdfReader(sourceFolder + "inlineImageLabColorSpace.pdf"))){ + PdfCanvasProcessor pdfCanvasProcessor = new PdfCanvasProcessor(new SimpleTextExtractionStrategy()); + pdfCanvasProcessor.processPageContent(pdf.getPage(1)); + + PdfName name = new PdfName("Cs1"); + PdfColorSpace colorSpace = pdf.getPage(1).getResources().getColorSpace(name); + + PdfArray pdfArray = (PdfArray) colorSpace.getPdfObject(); + PdfName actualName = (PdfName) pdfArray.get(0); + + Assertions.assertEquals(PdfName.Lab, actualName); + } + } + + @Test + public void parseInlineImageICCBasedColorSpaceTest() throws IOException { + try(PdfDocument pdf = new PdfDocument(new PdfReader(sourceFolder + "inlineImageICCBasedColorSpace.pdf"))){ + PdfCanvasProcessor pdfCanvasProcessor = new PdfCanvasProcessor(new SimpleTextExtractionStrategy()); + pdfCanvasProcessor.processPageContent(pdf.getPage(1)); + + PdfName name = new PdfName("Cs1"); + PdfColorSpace colorSpace = pdf.getPage(1).getResources().getColorSpace(name); + + PdfArray pdfArray = (PdfArray) colorSpace.getPdfObject(); + PdfName actualName = (PdfName) pdfArray.get(0); + + Assertions.assertEquals(PdfName.ICCBased, actualName); + } + } + + @Test + public void parseInlineImageDeviceRGBColorSpaceTest() throws IOException { + try(PdfDocument pdf = new PdfDocument(new PdfReader(sourceFolder + "inlineImageDeviceRGBColorSpace.pdf"))){ + PdfCanvasProcessor pdfCanvasProcessor = new PdfCanvasProcessor(new SimpleTextExtractionStrategy()); + pdfCanvasProcessor.processPageContent(pdf.getPage(1)); + + PdfStream stream = pdf.getPage(1).getContentStream(0); + String firstPageData = new String(stream.getBytes()); + + Assertions.assertTrue(firstPageData.contains(PdfName.DeviceRGB.getValue())); + } + } + + @Test + public void parseInlineImageDeviceCMYKColorSpaceTest() throws IOException { + try(PdfDocument pdf = new PdfDocument(new PdfReader(sourceFolder + "inlineImageDeviceCMYKColorSpace.pdf"))){ + PdfCanvasProcessor pdfCanvasProcessor = new PdfCanvasProcessor(new SimpleTextExtractionStrategy()); + pdfCanvasProcessor.processPageContent(pdf.getPage(1)); + + PdfStream stream = pdf.getPage(1).getContentStream(0); + String firstPageData = new String(stream.getBytes()); + + Assertions.assertTrue(firstPageData.contains(PdfName.DeviceCMYK.getValue())); + } + } + + @Test + public void parseInlineImageDeviceGrayColorSpaceTest() throws IOException { + try(PdfDocument pdf = new PdfDocument(new PdfReader(sourceFolder + "inlineImageDeviceGrayColorSpace.pdf"))){ + PdfCanvasProcessor pdfCanvasProcessor = new PdfCanvasProcessor(new SimpleTextExtractionStrategy()); + pdfCanvasProcessor.processPageContent(pdf.getPage(1)); + + PdfStream stream = pdf.getPage(1).getContentStream(0); + String firstPageData = new String(stream.getBytes()); + + Assertions.assertTrue(firstPageData.contains(PdfName.DeviceGray.getValue())); + } + } + + @Test + public void parseInlineImageSeparationColorSpaceTest() throws IOException { + try(PdfDocument pdf = new PdfDocument(new PdfReader(sourceFolder + "inlineImageSeparationColorSpace.pdf"))){ + PdfCanvasProcessor pdfCanvasProcessor = new PdfCanvasProcessor(new SimpleTextExtractionStrategy()); + pdfCanvasProcessor.processPageContent(pdf.getPage(1)); + + PdfName name = new PdfName("Cs1"); + PdfColorSpace colorSpace = pdf.getPage(1).getResources().getColorSpace(name); + + PdfArray pdfArray = (PdfArray) colorSpace.getPdfObject(); + PdfName actualName = (PdfName) pdfArray.get(0); + + Assertions.assertEquals(PdfName.Separation, actualName); + } + } + + @Test + public void parseInlineImageDeviceNColorSpaceTest() throws IOException { + try(PdfDocument pdf = new PdfDocument(new PdfReader(sourceFolder + "inlineImageDeviceNColorSpace.pdf"))){ + PdfCanvasProcessor pdfCanvasProcessor = new PdfCanvasProcessor(new SimpleTextExtractionStrategy()); + pdfCanvasProcessor.processPageContent(pdf.getPage(1)); + + PdfName name = new PdfName("Cs1"); + PdfColorSpace colorSpace = pdf.getPage(1).getResources().getColorSpace(name); + + PdfArray pdfArray = (PdfArray) colorSpace.getPdfObject(); + PdfName actualName = (PdfName) pdfArray.get(0); + + Assertions.assertEquals(PdfName.DeviceN, actualName); + } + } + + @Test + public void parseInlineImageIndexedColorSpaceTest() throws IOException { + try(PdfDocument pdf = new PdfDocument(new PdfReader(sourceFolder + "inlineImageIndexedColorSpace.pdf"))){ + PdfCanvasProcessor pdfCanvasProcessor = new PdfCanvasProcessor(new SimpleTextExtractionStrategy()); + pdfCanvasProcessor.processPageContent(pdf.getPage(1)); + + PdfName name = new PdfName("Cs1"); + PdfColorSpace colorSpace = pdf.getPage(1).getResources().getColorSpace(name); + + PdfArray pdfArray = (PdfArray) colorSpace.getPdfObject(); + PdfName actualName = (PdfName) pdfArray.get(0); + + Assertions.assertEquals(PdfName.Indexed, actualName); + } } private static class InlineImageEventListener implements IEventListener { - private List inlineImages = new ArrayList<>(); + private final List inlineImages = new ArrayList<>(); public List getInlineImages() { return inlineImages; } public void eventOccurred(IEventData data, EventType type) { - switch (type) { - case RENDER_IMAGE: - ImageRenderInfo imageEventData = (ImageRenderInfo) data; - if (((ImageRenderInfo) data).isInline()) { - inlineImages.add(imageEventData.getImage().getPdfObject()); - } - break; + if (type == EventType.RENDER_IMAGE) { + ImageRenderInfo imageEventData = (ImageRenderInfo) data; + if (((ImageRenderInfo) data).isInline()) { + inlineImages.add(imageEventData.getImage().getPdfObject()); + } } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/LocationExtractTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/LocationExtractTest.java index 4df6c74711..d7bd47b692 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/LocationExtractTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/LocationExtractTest.java @@ -30,10 +30,9 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.canvas.parser.listener.IPdfTextLocation; import com.itextpdf.kernel.pdf.canvas.parser.listener.RegexBasedLocationExtractionStrategy; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; import java.util.ArrayList; @@ -48,7 +47,7 @@ This file is part of the iText (R) project. * It uses RegexBasedLocationExtractionStrategy, and searches for the word "Alice" in the book * "Alice in Wonderland" by Lewis Caroll on page 1. */ -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class LocationExtractTest extends ExtendedITextTest { private static final String sourceFolder = "./src/test/resources/com/itextpdf/kernel/parser/LocationExtractionTest/"; @@ -77,8 +76,8 @@ public void testLocationExtraction() throws IOException { expectedRectangles.add(new Rectangle(510.3833f, 618.4366f, 29.380737f, 14.982483f)); expectedRectangles.add(new Rectangle(84.0f, 649.3966f, 29.297523f, 14.982483f)); - Assert.assertTrue(expectedRectangles.size() == rectangleCollection.size()); - Assert.assertTrue(fuzzyContainsAll(rectangleCollection, expectedRectangles)); + Assertions.assertTrue(expectedRectangles.size() == rectangleCollection.size()); + Assertions.assertTrue(fuzzyContainsAll(rectangleCollection, expectedRectangles)); } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/PdfCanvasProcessorIntegrationTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/PdfCanvasProcessorIntegrationTest.java index a8924db0c8..134e62efa2 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/PdfCanvasProcessorIntegrationTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/PdfCanvasProcessorIntegrationTest.java @@ -45,7 +45,6 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.nio.charset.StandardCharsets; import java.nio.file.Files; @@ -54,22 +53,22 @@ This file is part of the iText (R) project. import java.util.List; import java.util.Map; import java.util.HashMap; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; import java.util.Set; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfCanvasProcessorIntegrationTest extends ExtendedITextTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/kernel/parser/PdfCanvasProcessorTest/"; private static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/kernel/parser/PdfCanvasProcessorTest/"; - @BeforeClass + @BeforeAll public static void setUp() { createDestinationFolder(DESTINATION_FOLDER); } @@ -92,7 +91,7 @@ public void contentStreamProcessorTest() throws IOException { byte[] logBytes = Files.readAllBytes(Paths.get(SOURCE_FOLDER + "contentStreamProcessorTest_events_log.dat")); String expectedPageEventsLog = new String(logBytes, StandardCharsets.UTF_8); - Assert.assertEquals(expectedPageEventsLog, pageEventsLog.toString()); + Assertions.assertEquals(expectedPageEventsLog, pageEventsLog.toString()); } @Test @@ -106,7 +105,7 @@ public void processGraphicsStateResourceOperatorFillOpacityTest() throws IOExcep PdfCanvasProcessor processor = new PdfCanvasProcessor(new RecordEveryTextRenderEvent(textRenderInfo)); processor.processPageContent(page); } - Assert.assertEquals("Expected fill opacity not found", expOpacity, textRenderInfo.get("FillOpacity")); + Assertions.assertEquals(expOpacity, textRenderInfo.get("FillOpacity"), "Expected fill opacity not found"); } @Test @@ -120,7 +119,7 @@ public void processGraphicsStateResourceOperatorStrokeOpacityTest() throws IOExc PdfCanvasProcessor processor = new PdfCanvasProcessor(new RecordEveryTextRenderEvent(textRenderInfo)); processor.processPageContent(page); } - Assert.assertEquals("Expected stroke opacity not found", expOpacity, textRenderInfo.get("StrokeOpacity")); + Assertions.assertEquals(expOpacity, textRenderInfo.get("StrokeOpacity"), "Expected stroke opacity not found"); } @Test @@ -146,11 +145,11 @@ public void testNoninvertibleMatrix() throws IOException { String resultantText = strategy.getResultantText(); pdfDocument.close(); - Assert.assertEquals("Hello World!\nHello World!\nHello World!\nHello World! Hello World! Hello World!", resultantText); + Assertions.assertEquals("Hello World!\nHello World!\nHello World!\nHello World! Hello World! Hello World!", resultantText); } @Test - @Ignore("DEVSIX-3608: this test currently throws StackOverflowError, which cannot be caught in .NET") + @Disabled("DEVSIX-3608: this test currently throws StackOverflowError, which cannot be caught in .NET") public void parseCircularReferencesInResourcesTest() throws IOException { String fileName = "circularReferencesInResources.pdf"; try (PdfDocument pdfDocument = new PdfDocument(new PdfReader(SOURCE_FOLDER + fileName))) { @@ -158,7 +157,7 @@ public void parseCircularReferencesInResourcesTest() throws IOException { PdfCanvasProcessor processor = new PdfCanvasProcessor(new NoOpEventListener()); PdfPage page = pdfDocument.getFirstPage(); - Assert.assertThrows(StackOverflowError.class, () -> processor.processPageContent(page)); + Assertions.assertThrows(StackOverflowError.class, () -> processor.processPageContent(page)); } } @@ -178,7 +177,7 @@ public void patternColorParsingNotValidPdfTest() throws IOException { Color renderInfo = colorParsingEventListener.getEncounteredPath().getFillColor(); - Assert.assertNull(renderInfo); + Assertions.assertNull(renderInfo); } } @@ -198,7 +197,7 @@ public void patternColorParsingValidPdfTest() throws IOException { PathRenderInfo renderInfo = colorParsingEventListener.getEncounteredPath(); PdfColorSpace colorSpace = renderInfo.getGraphicsState().getFillColor().getColorSpace(); - Assert.assertTrue(colorSpace instanceof PdfSpecialCs.Pattern); + Assertions.assertTrue(colorSpace instanceof PdfSpecialCs.Pattern); } } @@ -215,21 +214,21 @@ public void checkImageRenderInfoProcessorTest() throws IOException { // Check caught image's ImageRenderInfo ImageRenderInfo imageRenderInfo = eventListener.getImageRenderInfo(); final float EPS = 0.001f; - Assert.assertFalse(imageRenderInfo.isInline()); - Assert.assertEquals(1024, imageRenderInfo.getImage().getWidth(), EPS); - Assert.assertEquals(768, imageRenderInfo.getImage().getHeight(), EPS); - Assert.assertEquals("/Im1", imageRenderInfo.getImageResourceName().toString()); - Assert.assertEquals(new com.itextpdf.kernel.geom.Vector(212.67f, 676.25f, 1), + Assertions.assertFalse(imageRenderInfo.isInline()); + Assertions.assertEquals(1024, imageRenderInfo.getImage().getWidth(), EPS); + Assertions.assertEquals(768, imageRenderInfo.getImage().getHeight(), EPS); + Assertions.assertEquals("/Im1", imageRenderInfo.getImageResourceName().toString()); + Assertions.assertEquals(new com.itextpdf.kernel.geom.Vector(212.67f, 676.25f, 1), imageRenderInfo.getStartPoint()); - Assert.assertEquals(new Matrix(169.67f, 0, 0, 0, 127.25f, 0, 212.67f, 676.25f, 1), + Assertions.assertEquals(new Matrix(169.67f, 0, 0, 0, 127.25f, 0, 212.67f, 676.25f, 1), imageRenderInfo.getImageCtm()); - Assert.assertEquals(21590.508, imageRenderInfo.getArea(), EPS); - Assert.assertNull(imageRenderInfo.getColorSpaceDictionary()); - Assert.assertEquals(1, imageRenderInfo.getCanvasTagHierarchy().size()); - Assert.assertTrue(imageRenderInfo.hasMcid(5, true)); - Assert.assertTrue(imageRenderInfo.hasMcid(5)); - Assert.assertFalse(imageRenderInfo.hasMcid(1)); - Assert.assertEquals(5, imageRenderInfo.getMcid()); + Assertions.assertEquals(21590.508, imageRenderInfo.getArea(), EPS); + Assertions.assertNull(imageRenderInfo.getColorSpaceDictionary()); + Assertions.assertEquals(1, imageRenderInfo.getCanvasTagHierarchy().size()); + Assertions.assertTrue(imageRenderInfo.hasMcid(5, true)); + Assertions.assertTrue(imageRenderInfo.hasMcid(5)); + Assertions.assertFalse(imageRenderInfo.hasMcid(1)); + Assertions.assertEquals(5, imageRenderInfo.getMcid()); } private static class ColorParsingEventListener implements IEventListener { diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/PdfCanvasProcessorUnitTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/PdfCanvasProcessorUnitTest.java index 85fbcce7d2..e8ea4416ba 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/PdfCanvasProcessorUnitTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/PdfCanvasProcessorUnitTest.java @@ -27,14 +27,13 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfObject; import com.itextpdf.kernel.pdf.canvas.parser.listener.FilteredEventListener; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.util.Collections; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfCanvasProcessorUnitTest extends ExtendedITextTest { @Test @@ -42,7 +41,7 @@ public void beginMarkerContentOperatorTest() { PdfCanvasProcessor processor = new PdfCanvasProcessor(new FilteredEventListener()) { @Override protected void beginMarkedContent(PdfName tag, PdfDictionary dict) { - Assert.assertNull(dict); + Assertions.assertNull(dict); } }; IContentOperator contentOperator = processor.registerContentOperator("BMC", null); diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/PdfContentExtractionTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/PdfContentExtractionTest.java index 226abfbb42..1b3ee9796b 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/PdfContentExtractionTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/PdfContentExtractionTest.java @@ -24,37 +24,52 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfReader; +import com.itextpdf.kernel.pdf.canvas.parser.clipper.ClipperBridge; import com.itextpdf.kernel.pdf.canvas.parser.clipper.ClipperException; import com.itextpdf.kernel.pdf.canvas.parser.clipper.ClipperExceptionConstant; import com.itextpdf.kernel.pdf.canvas.parser.listener.LocationTextExtractionStrategy; +import com.itextpdf.test.AssertUtil; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import java.io.IOException; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfContentExtractionTest extends ExtendedITextTest { - - private static final String sourceFolder = "./src/test/resources/com/itextpdf/kernel/parser/PdfContentExtractionTest/"; + + private static final String SOURCE_FOLDER = + "./src/test/resources/com/itextpdf/kernel/parser/PdfContentExtractionTest/"; @Test - //TODO: remove the expected exception construct once the issue is fixed (DEVSIX-1279) public void contentExtractionInDocWithBigCoordinatesTest() throws IOException { - String inputFileName = sourceFolder + "docWithBigCoordinates.pdf"; - //In this document the CTM shrinks coordinates and this coordinates are large numbers. + String inputFileName = SOURCE_FOLDER + "docWithBigCoordinates.pdf"; + // In this document the CTM shrinks coordinates and these coordinates are large numbers. // At the moment creation of this test clipper has a problem with handling large numbers // since internally it deals with integers and has to multiply large numbers even more // for internal purposes + try (PdfDocument pdfDocument = new PdfDocument(new PdfReader(inputFileName))) { + PdfDocumentContentParser contentParser = new PdfDocumentContentParser(pdfDocument); + AssertUtil.doesNotThrow(() -> contentParser.processContent(1, new LocationTextExtractionStrategy())); + } + } - PdfDocument pdfDocument = new PdfDocument(new PdfReader(inputFileName)); - PdfDocumentContentParser contentParser = new PdfDocumentContentParser(pdfDocument); - - Exception e = Assert.assertThrows(ClipperException.class, - () -> contentParser.processContent(1, new LocationTextExtractionStrategy()) - ); - Assert.assertEquals(ClipperExceptionConstant.COORDINATE_OUTSIDE_ALLOWED_RANGE, e.getMessage()); + @Test + public void contentExtractionInDocWithStaticFloatMultiplierTest() throws IOException { + String inputFileName = SOURCE_FOLDER + "docWithBigCoordinates.pdf"; + // In this document the CTM shrinks coordinates and these coordinates are large numbers. + // At the moment creation of this test clipper has a problem with handling large numbers + // since internally it deals with integers and has to multiply large numbers even more + // for internal purposes + try (PdfDocument pdfDocument = new PdfDocument(new PdfReader(inputFileName))) { + PdfDocumentContentParser contentParser = new PdfDocumentContentParser(pdfDocument); + ClipperBridge.floatMultiplier = Math.pow(10, 14); + Exception e = Assertions.assertThrows(ClipperException.class, + () -> contentParser.processContent(1, new LocationTextExtractionStrategy()) + ); + Assertions.assertEquals(ClipperExceptionConstant.COORDINATE_OUTSIDE_ALLOWED_RANGE, e.getMessage()); + ClipperBridge.floatMultiplier = null; + } } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/PdfTextExtractorTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/PdfTextExtractorTest.java index eded667d25..8e0523f154 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/PdfTextExtractorTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/PdfTextExtractorTest.java @@ -28,14 +28,13 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfTextExtractorTest extends ExtendedITextTest { private static final String sourceFolder = "./src/test/resources/com/itextpdf/kernel/parser/PdfTextExtractorTest/"; @@ -47,7 +46,7 @@ public void noSpecifiedDictionaryInPropertiesTest() throws IOException { try (PdfDocument pdfDocument = new PdfDocument(new PdfReader(inFile))) { String text = PdfTextExtractor.getTextFromPage(pdfDocument.getPage(1)); // Here we check that no NPE wasn't thrown. There is no text on the page so the extracted string should be empty. - Assert.assertEquals("", text); + Assertions.assertEquals("", text); } } @@ -58,7 +57,7 @@ public void noPropertiesInResourcesTest() throws IOException { try (PdfDocument pdfDocument = new PdfDocument(new PdfReader(inFile))) { String text = PdfTextExtractor.getTextFromPage(pdfDocument.getPage(1)); // Here we check that no NPE wasn't thrown. There is no text on the page so the extracted string should be empty. - Assert.assertEquals("", text); + Assertions.assertEquals("", text); } } @@ -66,7 +65,7 @@ public void noPropertiesInResourcesTest() throws IOException { public void type3FontNoCMapTest() throws IOException { String inFile = sourceFolder + "type3NoCMap.pdf"; try (PdfDocument pdfDocument = new PdfDocument(new PdfReader(inFile))) { - Assert.assertEquals("*0*", PdfTextExtractor.getTextFromPage(pdfDocument.getPage(1))); + Assertions.assertEquals("*0*", PdfTextExtractor.getTextFromPage(pdfDocument.getPage(1))); } } @@ -74,7 +73,7 @@ public void type3FontNoCMapTest() throws IOException { public void noBaseEncodingTest() throws IOException { String inFile = sourceFolder + "noBaseEncoding.pdf"; try (PdfDocument pdfDocument = new PdfDocument(new PdfReader(inFile))) { - Assert.assertEquals("HELLO WORLD", PdfTextExtractor.getTextFromPage(pdfDocument.getPage(1))); + Assertions.assertEquals("HELLO WORLD", PdfTextExtractor.getTextFromPage(pdfDocument.getPage(1))); } } @@ -82,7 +81,7 @@ public void noBaseEncodingTest() throws IOException { public void simpleFontWithoutEncodingToUnicodeTest() throws IOException { String inFile = sourceFolder + "simpleFontWithoutEncodingToUnicode.pdf"; try (PdfDocument pdfDocument = new PdfDocument(new PdfReader(inFile))) { - Assert.assertEquals("MyriadPro-Bold font.", PdfTextExtractor.getTextFromPage(pdfDocument.getPage(1))); + Assertions.assertEquals("MyriadPro-Bold font.", PdfTextExtractor.getTextFromPage(pdfDocument.getPage(1))); } } @@ -90,7 +89,7 @@ public void simpleFontWithoutEncodingToUnicodeTest() throws IOException { public void simpleFontWithPartialToUnicodeTest() throws IOException { String inFile = sourceFolder + "simpleFontWithPartialToUnicode.pdf"; try (PdfDocument pdfDocument = new PdfDocument(new PdfReader(inFile))) { - Assert.assertEquals("Registered", PdfTextExtractor.getTextFromPage(pdfDocument.getPage(1))); + Assertions.assertEquals("Registered", PdfTextExtractor.getTextFromPage(pdfDocument.getPage(1))); } } @@ -98,7 +97,7 @@ public void simpleFontWithPartialToUnicodeTest() throws IOException { public void type0FontToUnicodeTest() throws IOException { String inFile = sourceFolder + "type0FontToUnicode.pdf"; try (PdfDocument pdfDocument = new PdfDocument(new PdfReader(inFile))) { - Assert.assertEquals("€ 390", PdfTextExtractor.getTextFromPage(pdfDocument.getPage(1))); + Assertions.assertEquals("€ 390", PdfTextExtractor.getTextFromPage(pdfDocument.getPage(1))); } } @@ -109,7 +108,7 @@ public void parseTextDiacriticShiftedLessThanTwo() throws IOException { // संस्कृत म् String expected = "\u0938\u0902\u0938\u094d\u0915\u0943\u0924 \u092e\u094d"; try (PdfDocument pdfDocument = new PdfDocument(new PdfReader(inFile))) { - Assert.assertEquals(expected, PdfTextExtractor.getTextFromPage(pdfDocument.getPage(1))); + Assertions.assertEquals(expected, PdfTextExtractor.getTextFromPage(pdfDocument.getPage(1))); } } @@ -121,7 +120,7 @@ public void parseTextDiacriticShiftedMoreThanTwo() throws IOException { //संस्कृत म् String expected = "\u0943\n\u0938\u0902\u0938\u094d\u0915\u0943\u0924 \u092e\u094d"; try (PdfDocument pdfDocument = new PdfDocument(new PdfReader(inFile))) { - Assert.assertEquals(expected, PdfTextExtractor.getTextFromPage(pdfDocument.getPage(1))); + Assertions.assertEquals(expected, PdfTextExtractor.getTextFromPage(pdfDocument.getPage(1))); } } @@ -129,7 +128,7 @@ public void parseTextDiacriticShiftedMoreThanTwo() throws IOException { public void shortOctalDataAsTextTest() throws IOException { String inFile = sourceFolder + "shortOctalDataAsText.pdf"; try (PdfDocument pdfDocument = new PdfDocument(new PdfReader(inFile))) { - Assert.assertEquals("EC", PdfTextExtractor.getTextFromPage(pdfDocument.getPage(1))); + Assertions.assertEquals("EC", PdfTextExtractor.getTextFromPage(pdfDocument.getPage(1))); } } @@ -138,8 +137,8 @@ public void notDefaultCodespacesCyrillicTest() throws IOException { String inFile = sourceFolder + "notDefaultCodespacesCyrillic.pdf"; try (PdfDocument pdfDocument = new PdfDocument(new PdfReader(inFile))) { String extractedText = PdfTextExtractor.getTextFromPage(pdfDocument.getPage(1)); - Assert.assertTrue(extractedText.contains("бронирование")); - Assert.assertTrue(extractedText.contains("From")); + Assertions.assertTrue(extractedText.contains("бронирование")); + Assertions.assertTrue(extractedText.contains("From")); } } @@ -148,7 +147,7 @@ public void notDefaultCodespacesChineseTest() throws IOException { String inFile = sourceFolder + "notDefaultCodespacesChinese.pdf"; try (PdfDocument pdfDocument = new PdfDocument(new PdfReader(inFile))) { String extractedText = PdfTextExtractor.getTextFromPage(pdfDocument.getPage(1)); - Assert.assertTrue(extractedText.contains("L3B 廠: 新竹科學工業園區新竹市東區力行二路 1 號")); + Assertions.assertTrue(extractedText.contains("L3B 廠: 新竹科學工業園區新竹市東區力行二路 1 號")); } } @@ -157,8 +156,8 @@ public void mixedCharacterCodes() throws IOException { String inFile = sourceFolder + "SameCidForDifferentCodes.pdf"; try (PdfDocument pdfDocument = new PdfDocument(new PdfReader(inFile))) { String extractedText = PdfTextExtractor.getTextFromPage(pdfDocument.getPage(1)); - Assert.assertTrue(extractedText.contains("18个月")); - Assert.assertFalse(extractedText.contains("18个⽉")); + Assertions.assertTrue(extractedText.contains("18个月")); + Assertions.assertFalse(extractedText.contains("18个⽉")); } } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/PdfTextExtractorUnicodeIdentityTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/PdfTextExtractorUnicodeIdentityTest.java index fc68a331a6..e5270f6386 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/PdfTextExtractorUnicodeIdentityTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/PdfTextExtractorUnicodeIdentityTest.java @@ -30,15 +30,14 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfReader; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfTextExtractorUnicodeIdentityTest extends ExtendedITextTest { private static final String sourceFolder = "./src/test/resources/com/itextpdf/kernel/parser/PdfTextExtractorUnicodeIdentityTest/"; @@ -50,7 +49,7 @@ public void test() throws IOException { Rectangle rectangle = new Rectangle(71, 708, 154, 9); IEventFilter filter = new TextRegionEventFilter(rectangle); String txt = PdfTextExtractor.getTextFromPage(pdfDocument.getPage(1), new FilteredTextEventListener(new LocationTextExtractionStrategy(), filter)); - Assert.assertEquals("Pname Dname Email Address", txt); + Assertions.assertEquals("Pname Dname Email Address", txt); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/SimpleFontToUnicodeExtractionTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/SimpleFontToUnicodeExtractionTest.java index d0362f8177..d318fbb066 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/SimpleFontToUnicodeExtractionTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/SimpleFontToUnicodeExtractionTest.java @@ -26,14 +26,13 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfReader; import com.itextpdf.kernel.pdf.canvas.parser.listener.LocationTextExtractionStrategy; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class SimpleFontToUnicodeExtractionTest extends ExtendedITextTest { private static final String sourceFolder = "./src/test/resources/com/itextpdf/kernel/parser/SimpleFontToUnicodeExtractionTest/"; @@ -66,7 +65,7 @@ public void test01() throws IOException { String actualText = PdfTextExtractor.getTextFromPage(pdfDocument.getPage(1), new LocationTextExtractionStrategy()); - Assert.assertEquals(expected, actualText); + Assertions.assertEquals(expected, actualText); } @Test @@ -77,7 +76,7 @@ public void test02() throws IOException { String actualText = PdfTextExtractor.getTextFromPage(pdfDocument.getPage(1), new LocationTextExtractionStrategy()); - Assert.assertEquals(expected, actualText); + Assertions.assertEquals(expected, actualText); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/TextExtractIllegalDifferencesTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/TextExtractIllegalDifferencesTest.java index 46dfd18ea6..9277630b65 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/TextExtractIllegalDifferencesTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/TextExtractIllegalDifferencesTest.java @@ -29,14 +29,13 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class TextExtractIllegalDifferencesTest extends ExtendedITextTest { private static final String sourceFolder = "./src/test/resources/com/itextpdf/kernel/parser/TextExtractIllegalDifferencesTest/"; diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/TextMarginFinderTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/TextMarginFinderTest.java index 242a3aa24b..f53347ddd7 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/TextMarginFinderTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/TextMarginFinderTest.java @@ -27,13 +27,12 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfReader; import com.itextpdf.kernel.pdf.canvas.parser.listener.TextMarginFinder; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class TextMarginFinderTest extends ExtendedITextTest { private static final String sourceFolder = "./src/test/resources/com/itextpdf/kernel/parser/TextMarginFinderTest/"; @@ -45,9 +44,9 @@ public void test() throws Exception { new PdfCanvasProcessor(finder).processPageContent(pdfDocument.getPage(1)); Rectangle textRect = finder.getTextRectangle(); - Assert.assertEquals(1.42f * 72f, textRect.getX(), 0.01f); - Assert.assertEquals(7.42f * 72f, textRect.getX() + textRect.getWidth(), 0.01f); - Assert.assertEquals(2.42f * 72f, textRect.getY(), 0.01f); - Assert.assertEquals(10.42f * 72f, textRect.getY() + textRect.getHeight(), 0.01f); + Assertions.assertEquals(1.42f * 72f, textRect.getX(), 0.01f); + Assertions.assertEquals(7.42f * 72f, textRect.getX() + textRect.getWidth(), 0.01f); + Assertions.assertEquals(2.42f * 72f, textRect.getY(), 0.01f); + Assertions.assertEquals(10.42f * 72f, textRect.getY() + textRect.getHeight(), 0.01f); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/TextRenderInfoTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/TextRenderInfoTest.java index e240030561..1c8c5476e1 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/TextRenderInfoTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/TextRenderInfoTest.java @@ -32,7 +32,6 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.canvas.parser.listener.ITextExtractionStrategy; import com.itextpdf.kernel.pdf.canvas.parser.listener.SimpleTextExtractionStrategy; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; import java.util.ArrayList; @@ -40,11 +39,11 @@ This file is part of the iText (R) project. import java.util.LinkedHashSet; import java.util.List; import java.util.Set; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class TextRenderInfoTest extends ExtendedITextTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/kernel/parser/TextRenderInfoTest/"; @@ -78,7 +77,7 @@ public void testUnicodeEmptyString() throws Exception { + "\u914d\u5f53\u8cb4\u65cf\u6307\u6570\u306e\u30d1\u30d5" + "\u30a9\u30fc\u30de\u30f3\u30b9\u306f\u0053\uff06\u0050" + "\u0035\u0030\u0030\u6307\u6570\u3092\u4e0a\u56de\u308b"; - Assert.assertEquals(origText, result); + Assertions.assertEquals(origText, result); } @Test @@ -92,10 +91,10 @@ public void testType3FontWidth() throws Exception { processor.processPageContent(pdfDocument.getPage(FIRST_PAGE)); - Assert.assertEquals(renderListener.getLineSegments().get(FIRST_ELEMENT_INDEX).getStartPoint().get(FIRST_ELEMENT_INDEX), + Assertions.assertEquals(renderListener.getLineSegments().get(FIRST_ELEMENT_INDEX).getStartPoint().get(FIRST_ELEMENT_INDEX), origLineSegment.getStartPoint().get(FIRST_ELEMENT_INDEX), 1 / 2f); - Assert.assertEquals(renderListener.getLineSegments().get(FIRST_ELEMENT_INDEX).getEndPoint().get(FIRST_ELEMENT_INDEX), + Assertions.assertEquals(renderListener.getLineSegments().get(FIRST_ELEMENT_INDEX).getEndPoint().get(FIRST_ELEMENT_INDEX), origLineSegment.getEndPoint().get(FIRST_ELEMENT_INDEX), 1 / 2f); } @@ -110,7 +109,7 @@ public void testDoubleMappedCharacterExtraction() throws IOException { ITextExtractionStrategy strategy = new SimpleTextExtractionStrategy(); String result = PdfTextExtractor.getTextFromPage(pdfDocument.getPage(FIRST_PAGE), strategy).trim(); - Assert.assertEquals(expectedResult, result); + Assertions.assertEquals(expectedResult, result); } @Test @@ -123,7 +122,7 @@ public void testEmbeddedIdentityToUnicodeTest() throws IOException { ITextExtractionStrategy start = new SimpleTextExtractionStrategy(); String result = PdfTextExtractor.getTextFromPage(pdfDocument.getPage(FIRST_PAGE), start).trim(); - Assert.assertEquals(expectedResult, result); + Assertions.assertEquals(expectedResult, result); } private static class TextPositionEventListener implements IEventListener { @@ -171,8 +170,8 @@ public void eventOccurred(IEventData data, EventType type) { } private void assertVectorsEqual(String message, Vector v1, Vector v2) { - Assert.assertEquals(message, v1.get(0), v2.get(0), 1 / 72f); - Assert.assertEquals(message, v1.get(1), v2.get(1), 1 / 72f); + Assertions.assertEquals(v1.get(0), v2.get(0), 1 / 72f, message); + Assertions.assertEquals(v1.get(1), v2.get(1), 1 / 72f, message); } @Override diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/clipper/ClipperBridgeTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/clipper/ClipperBridgeTest.java index bf4a8997a5..14938726bb 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/clipper/ClipperBridgeTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/clipper/ClipperBridgeTest.java @@ -25,6 +25,7 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.geom.IShape; import com.itextpdf.kernel.geom.Line; import com.itextpdf.kernel.geom.Path; +import com.itextpdf.kernel.geom.Point; import com.itextpdf.kernel.geom.Subpath; import com.itextpdf.kernel.pdf.canvas.PdfCanvasConstants.LineCapStyle; import com.itextpdf.kernel.pdf.canvas.PdfCanvasConstants.LineJoinStyle; @@ -33,15 +34,15 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.canvas.parser.clipper.IClipper.JoinType; import com.itextpdf.kernel.pdf.canvas.parser.clipper.IClipper.PolyType; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; +import java.util.Arrays; import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class ClipperBridgeTest extends ExtendedITextTest { @Test @@ -65,58 +66,85 @@ public void squareClippingTest() { rectanglePath.addSubpath(rectangleSubpath); DefaultClipper clipper = new DefaultClipper(); - ClipperBridge.addPath(clipper, squarePath, PolyType.SUBJECT); - ClipperBridge.addPath(clipper, rectanglePath, PolyType.CLIP); + ClipperBridge clipperBridge = new ClipperBridge(squarePath, rectanglePath); + clipperBridge.addPath(clipper, squarePath, PolyType.SUBJECT); + clipperBridge.addPath(clipper, rectanglePath, PolyType.CLIP); PolyTree polyTree = new PolyTree(); clipper.execute(ClipType.UNION, polyTree); - Path result = ClipperBridge.convertToPath(polyTree); + Path result = clipperBridge.convertToPath(polyTree); - Assert.assertEquals(new com.itextpdf.kernel.geom.Point(20, 40), result.getCurrentPoint()); - Assert.assertEquals(2, result.getSubpaths().size()); + Assertions.assertEquals(new com.itextpdf.kernel.geom.Point(20, 40), result.getCurrentPoint()); + Assertions.assertEquals(2, result.getSubpaths().size()); Subpath closedPath = result.getSubpaths().get(0); - Assert.assertEquals(new com.itextpdf.kernel.geom.Point(20, 40), closedPath.getStartPoint()); + Assertions.assertEquals(new com.itextpdf.kernel.geom.Point(20, 40), closedPath.getStartPoint()); List closedPartSegments = closedPath.getSegments(); - Assert.assertEquals(5, closedPartSegments.size()); - Assert.assertTrue(areShapesEqual(new Line(20, 40, 20, 30), closedPartSegments.get(0))); - Assert.assertTrue(areShapesEqual(new Line(20, 30, 10, 30), closedPartSegments.get(1))); - Assert.assertTrue(areShapesEqual(new Line(10, 30, 10, 10), closedPartSegments.get(2))); - Assert.assertTrue(areShapesEqual(new Line(10, 10, 30, 10), closedPartSegments.get(3))); - Assert.assertTrue(areShapesEqual(new Line(30, 10, 30, 40), closedPartSegments.get(4))); - Assert.assertTrue(closedPath.isClosed()); + Assertions.assertEquals(5, closedPartSegments.size()); + Assertions.assertTrue(areShapesEqual(new Line(20, 40, 20, 30), closedPartSegments.get(0))); + Assertions.assertTrue(areShapesEqual(new Line(20, 30, 10, 30), closedPartSegments.get(1))); + Assertions.assertTrue(areShapesEqual(new Line(10, 30, 10, 10), closedPartSegments.get(2))); + Assertions.assertTrue(areShapesEqual(new Line(10, 10, 30, 10), closedPartSegments.get(3))); + Assertions.assertTrue(areShapesEqual(new Line(30, 10, 30, 40), closedPartSegments.get(4))); + Assertions.assertTrue(closedPath.isClosed()); Subpath openPart = result.getSubpaths().get(1); - Assert.assertEquals(new com.itextpdf.kernel.geom.Point(20, 40), openPart.getStartPoint()); - Assert.assertEquals(0, openPart.getSegments().size()); - Assert.assertFalse(openPart.isClosed()); + Assertions.assertEquals(new com.itextpdf.kernel.geom.Point(20, 40), openPart.getStartPoint()); + Assertions.assertEquals(0, openPart.getSegments().size()); + Assertions.assertFalse(openPart.isClosed()); } @Test public void getJoinTypeTest() { - Assert.assertEquals(JoinType.BEVEL, ClipperBridge.getJoinType(LineJoinStyle.BEVEL)); - Assert.assertEquals(JoinType.MITER, ClipperBridge.getJoinType(LineJoinStyle.MITER)); - Assert.assertEquals(JoinType.ROUND, ClipperBridge.getJoinType(LineJoinStyle.ROUND)); + Assertions.assertEquals(JoinType.BEVEL, ClipperBridge.getJoinType(LineJoinStyle.BEVEL)); + Assertions.assertEquals(JoinType.MITER, ClipperBridge.getJoinType(LineJoinStyle.MITER)); + Assertions.assertEquals(JoinType.ROUND, ClipperBridge.getJoinType(LineJoinStyle.ROUND)); } @Test public void getEndTypeTest() { - Assert.assertEquals(EndType.OPEN_BUTT, ClipperBridge.getEndType(LineCapStyle.BUTT)); - Assert.assertEquals(EndType.OPEN_SQUARE, ClipperBridge.getEndType(LineCapStyle.PROJECTING_SQUARE)); - Assert.assertEquals(EndType.OPEN_ROUND, ClipperBridge.getEndType(LineCapStyle.ROUND)); + Assertions.assertEquals(EndType.OPEN_BUTT, ClipperBridge.getEndType(LineCapStyle.BUTT)); + Assertions.assertEquals(EndType.OPEN_SQUARE, ClipperBridge.getEndType(LineCapStyle.PROJECTING_SQUARE)); + Assertions.assertEquals(EndType.OPEN_ROUND, ClipperBridge.getEndType(LineCapStyle.ROUND)); } @Test public void longRectWidthTest() { LongRect longRect = new LongRect(14900000000000000L, 21275000000000000L, 71065802001953128L, 71075000000000000L); - Assert.assertEquals(561.658, ClipperBridge.longRectCalculateWidth(longRect), 0.001f); + Assertions.assertEquals(561.658, new ClipperBridge().longRectCalculateWidth(longRect), 0.001f); } @Test public void longRectHeightTest() { LongRect longRect = new LongRect(14900000000000000L, 21275000000000000L, 71065802001953128L, 71075000000000000L); - Assert.assertEquals(498, ClipperBridge.longRectCalculateHeight(longRect), 0.001f); + Assertions.assertEquals(498, new ClipperBridge().longRectCalculateHeight(longRect), 0.001f); + } + + @Test + public void dynamicFloatMultiplierCalculationsSmallValuesTest() { + Point[] points = new Point[]{ + new Point(1e-10, 0), + new Point(0, 1e-13) + }; + Assertions.assertEquals(1.8014398509481984e26, new ClipperBridge(points).getFloatMultiplier(), 0e+10); + } + + @Test + public void dynamicFloatMultiplierCalculationsBigValuesTest() { + Point[] points = new Point[]{ + new Point(1e+11, 10), + new Point(10, 1e+10) + }; + Assertions.assertEquals(180143, new ClipperBridge(points).getFloatMultiplier(), 0.001f); + } + + @Test + public void smallFloatMultiplierCoefficientTest() { + Point[] points = new Point[]{new Point(1e-10, 1e+10)}; + Assertions.assertEquals( + new com.itextpdf.kernel.pdf.canvas.parser.clipper.Point.LongPoint(0, 18014390000000000L), + new ClipperBridge(points).convertToLongPoints(Arrays.asList(points)).get(0)); } private boolean areShapesEqual(IShape expected, IShape actual) { diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/clipper/LongRectTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/clipper/LongRectTest.java index f8bfaab74c..d85cfc5fdb 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/clipper/LongRectTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/clipper/LongRectTest.java @@ -23,33 +23,32 @@ This file is part of the iText (R) project. package com.itextpdf.kernel.pdf.canvas.parser.clipper; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class LongRectTest extends ExtendedITextTest { @Test public void defaultConstructorTest() { final LongRect rect = new LongRect(); - Assert.assertEquals(0, rect.right); - Assert.assertEquals(0, rect.bottom); - Assert.assertEquals(0, rect.left); - Assert.assertEquals(0, rect.top); + Assertions.assertEquals(0, rect.right); + Assertions.assertEquals(0, rect.bottom); + Assertions.assertEquals(0, rect.left); + Assertions.assertEquals(0, rect.top); } @Test public void longParamConstructorTest() { final LongRect rect = new LongRect(5, 15, 6, 10); - Assert.assertEquals(5, rect.left); - Assert.assertEquals(15, rect.top); - Assert.assertEquals(6, rect.right); - Assert.assertEquals(10, rect.bottom); + Assertions.assertEquals(5, rect.left); + Assertions.assertEquals(15, rect.top); + Assertions.assertEquals(6, rect.right); + Assertions.assertEquals(10, rect.bottom); } @Test @@ -58,9 +57,9 @@ public void copyConstructorTest() { final LongRect newRect = new LongRect(rect); - Assert.assertEquals(10, newRect.bottom); - Assert.assertEquals(6, newRect.right); - Assert.assertEquals(5, newRect.left); - Assert.assertEquals(15, newRect.top); + Assertions.assertEquals(10, newRect.bottom); + Assertions.assertEquals(6, newRect.right); + Assertions.assertEquals(5, newRect.left); + Assertions.assertEquals(15, newRect.top); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/clipper/PointTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/clipper/PointTest.java index 0b50c2253d..bae4d9df70 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/clipper/PointTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/clipper/PointTest.java @@ -25,13 +25,12 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.canvas.parser.clipper.Point.DoublePoint; import com.itextpdf.kernel.pdf.canvas.parser.clipper.Point.LongPoint; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PointTest extends ExtendedITextTest { private static final double DOUBLE_EPSILON_COMPARISON = 1E-6; @@ -66,8 +65,8 @@ public void doublePointCopyConstructorTest() { public void doublePointEqualsAndHashCodeItselfTest() { DoublePoint dp = new DoublePoint(1.23, 5.34, 234.23); - Assert.assertTrue(dp.equals(dp)); - Assert.assertEquals(dp.hashCode(), dp.hashCode()); + Assertions.assertTrue(dp.equals(dp)); + Assertions.assertEquals(dp.hashCode(), dp.hashCode()); } @Test @@ -75,9 +74,9 @@ public void doublePointEqualsAndHashCodeToAnotherEqualPointTest() { DoublePoint first = new DoublePoint(1.23, 5.34, 234.23); DoublePoint second = new DoublePoint(1.23, 5.34, 13); - Assert.assertTrue(first.equals(second)); - Assert.assertTrue(second.equals(first)); - Assert.assertNotEquals(first.hashCode(), second.hashCode()); + Assertions.assertTrue(first.equals(second)); + Assertions.assertTrue(second.equals(first)); + Assertions.assertNotEquals(first.hashCode(), second.hashCode()); } @Test @@ -85,28 +84,28 @@ public void doublePointEqualsAndHashCodeToAnotherNotEqualPointTest() { DoublePoint first = new DoublePoint(1.23, 5.34, 234.23); DoublePoint second = new DoublePoint(0, 5.34, 234.23); - Assert.assertFalse(first.equals(second)); - Assert.assertFalse(second.equals(first)); - Assert.assertNotEquals(first.hashCode(), second.hashCode()); + Assertions.assertFalse(first.equals(second)); + Assertions.assertFalse(second.equals(first)); + Assertions.assertNotEquals(first.hashCode(), second.hashCode()); second = new DoublePoint(1.23, 0, 234.23); - Assert.assertFalse(first.equals(second)); - Assert.assertFalse(second.equals(first)); - Assert.assertNotEquals(first.hashCode(), second.hashCode()); + Assertions.assertFalse(first.equals(second)); + Assertions.assertFalse(second.equals(first)); + Assertions.assertNotEquals(first.hashCode(), second.hashCode()); } @Test public void doublePointEqualsToNullTest() { DoublePoint dp = new DoublePoint(1.23, 5.34, 234.23); - Assert.assertFalse(dp.equals(null)); + Assertions.assertFalse(dp.equals(null)); } @Test public void doublePointEqualsToAnotherClassTest() { DoublePoint dp = new DoublePoint(1.23, 5.34, 234.23); - Assert.assertFalse(dp.equals(new String())); + Assertions.assertFalse(dp.equals(new String())); } @Test @@ -134,7 +133,7 @@ public void doublePointSetFieldsTest() { @Test public void doublePointToStringTest() { DoublePoint dp = new DoublePoint(1.23, 5.34, 234.23); - Assert.assertEquals("Point [x=1.23, y=5.34, z=234.23]", dp.toString()); + Assertions.assertEquals("Point [x=1.23, y=5.34, z=234.23]", dp.toString()); } // LongPoint tests block @@ -174,8 +173,8 @@ public void longPointCopyConstructorTest() { public void longPointEqualsAndHashCodeItselfTest() { LongPoint lp = new LongPoint(1, 5, 234); - Assert.assertTrue(lp.equals(lp)); - Assert.assertEquals(lp.hashCode(), lp.hashCode()); + Assertions.assertTrue(lp.equals(lp)); + Assertions.assertEquals(lp.hashCode(), lp.hashCode()); } @Test @@ -183,9 +182,9 @@ public void longPointEqualsAndHashCodeToAnotherEqualPointTest() { LongPoint first = new LongPoint(1, 5, 234); LongPoint second = new LongPoint(1, 5, 13); - Assert.assertTrue(first.equals(second)); - Assert.assertTrue(second.equals(first)); - Assert.assertNotEquals(first.hashCode(), second.hashCode()); + Assertions.assertTrue(first.equals(second)); + Assertions.assertTrue(second.equals(first)); + Assertions.assertNotEquals(first.hashCode(), second.hashCode()); } @Test @@ -193,28 +192,28 @@ public void longPointEqualsAndHashCodeToAnotherNotEqualPointTest() { LongPoint first = new LongPoint(1, 5, 234); LongPoint second = new LongPoint(0, 5, 234); - Assert.assertFalse(first.equals(second)); - Assert.assertFalse(second.equals(first)); - Assert.assertNotEquals(first.hashCode(), second.hashCode()); + Assertions.assertFalse(first.equals(second)); + Assertions.assertFalse(second.equals(first)); + Assertions.assertNotEquals(first.hashCode(), second.hashCode()); second = new LongPoint(1, 0, 234); - Assert.assertFalse(first.equals(second)); - Assert.assertFalse(second.equals(first)); - Assert.assertNotEquals(first.hashCode(), second.hashCode()); + Assertions.assertFalse(first.equals(second)); + Assertions.assertFalse(second.equals(first)); + Assertions.assertNotEquals(first.hashCode(), second.hashCode()); } @Test public void longPointEqualsToNullTest() { LongPoint lp = new LongPoint(1, 5, 234); - Assert.assertFalse(lp.equals(null)); + Assertions.assertFalse(lp.equals(null)); } @Test public void longPointEqualsToAnotherClassTest() { LongPoint lp = new LongPoint(1, 5, 234); - Assert.assertFalse(lp.equals(new String())); + Assertions.assertFalse(lp.equals(new String())); } @Test @@ -242,21 +241,21 @@ public void longPointSetFieldsTest() { @Test public void longPointToStringTest() { LongPoint lp = new LongPoint(1, 5, 234); - Assert.assertEquals("Point [x=1, y=5, z=234]", lp.toString()); + Assertions.assertEquals("Point [x=1, y=5, z=234]", lp.toString()); } @Test public void longPointGetDeltaXEqualsYTest() { LongPoint lp1 = new LongPoint(1, 5); LongPoint lp2 = new LongPoint(3, 5); - Assert.assertEquals(Edge.HORIZONTAL, LongPoint.getDeltaX(lp1, lp2), DOUBLE_EPSILON_COMPARISON); + Assertions.assertEquals(Edge.HORIZONTAL, LongPoint.getDeltaX(lp1, lp2), DOUBLE_EPSILON_COMPARISON); } @Test public void longPointGetDeltaXDifferentYTest() { LongPoint lp1 = new LongPoint(1, 5); LongPoint lp2 = new LongPoint(3, 6); - Assert.assertEquals(2, LongPoint.getDeltaX(lp1, lp2), DOUBLE_EPSILON_COMPARISON); + Assertions.assertEquals(2, LongPoint.getDeltaX(lp1, lp2), DOUBLE_EPSILON_COMPARISON); } // Point tests block @@ -266,25 +265,25 @@ public void isPt2BetweenPt1AndPt3Test() { LongPoint pt1 = new LongPoint(); LongPoint pt2 = new LongPoint(); LongPoint pt3 = new LongPoint(); - Assert.assertFalse(Point.isPt2BetweenPt1AndPt3(pt1, pt2, pt3)); + Assertions.assertFalse(Point.isPt2BetweenPt1AndPt3(pt1, pt2, pt3)); pt3.setX(10L); pt3.setY(10L); - Assert.assertFalse(Point.isPt2BetweenPt1AndPt3(pt1, pt2, pt3)); + Assertions.assertFalse(Point.isPt2BetweenPt1AndPt3(pt1, pt2, pt3)); pt2.setX(10L); pt2.setY(10L); - Assert.assertFalse(Point.isPt2BetweenPt1AndPt3(pt1, pt2, pt3)); + Assertions.assertFalse(Point.isPt2BetweenPt1AndPt3(pt1, pt2, pt3)); pt2.setX(5L); pt2.setY(10L); - Assert.assertTrue(Point.isPt2BetweenPt1AndPt3(pt1, pt2, pt3)); + Assertions.assertTrue(Point.isPt2BetweenPt1AndPt3(pt1, pt2, pt3)); pt1.setX(10L); pt1.setY(0L); pt2.setX(10L); pt2.setY(5L); - Assert.assertTrue(Point.isPt2BetweenPt1AndPt3(pt1, pt2, pt3)); + Assertions.assertTrue(Point.isPt2BetweenPt1AndPt3(pt1, pt2, pt3)); } @Test @@ -293,12 +292,12 @@ public void slopesEqualThreePointTest() { LongPoint pt2 = new LongPoint(3, 2); LongPoint pt3 = new LongPoint(0, 3); - Assert.assertTrue(Point.slopesEqual(pt1, pt2, pt3, false)); - Assert.assertTrue(Point.slopesEqual(pt1, pt2, pt3, true)); + Assertions.assertTrue(Point.slopesEqual(pt1, pt2, pt3, false)); + Assertions.assertTrue(Point.slopesEqual(pt1, pt2, pt3, true)); pt1.setX(10L); - Assert.assertFalse(Point.slopesEqual(pt1, pt2, pt3, false)); - Assert.assertFalse(Point.slopesEqual(pt1, pt2, pt3, true)); + Assertions.assertFalse(Point.slopesEqual(pt1, pt2, pt3, false)); + Assertions.assertFalse(Point.slopesEqual(pt1, pt2, pt3, true)); } @Test @@ -308,12 +307,12 @@ public void slopesEqualFourPointTest() { LongPoint pt3 = new LongPoint(3, 2); LongPoint pt4 = new LongPoint(0, 5); - Assert.assertTrue(Point.slopesEqual(pt1, pt2, pt3, pt4, false)); - Assert.assertTrue(Point.slopesEqual(pt1, pt2, pt3, pt4, true)); + Assertions.assertTrue(Point.slopesEqual(pt1, pt2, pt3, pt4, false)); + Assertions.assertTrue(Point.slopesEqual(pt1, pt2, pt3, pt4, true)); pt1.setX(10L); - Assert.assertFalse(Point.slopesEqual(pt1, pt2, pt3, pt4, false)); - Assert.assertFalse(Point.slopesEqual(pt1, pt2, pt3, pt4, true)); + Assertions.assertFalse(Point.slopesEqual(pt1, pt2, pt3, pt4, false)); + Assertions.assertFalse(Point.slopesEqual(pt1, pt2, pt3, pt4, true)); } @Test @@ -321,8 +320,8 @@ public void arePointsCloseTest() { LongPoint pt1 = new LongPoint(1, 2); LongPoint pt2 = new LongPoint(0, 0); - Assert.assertFalse(Point.arePointsClose(pt1, pt2, 4)); - Assert.assertTrue(Point.arePointsClose(pt1, pt2, 5)); + Assertions.assertFalse(Point.arePointsClose(pt1, pt2, 4)); + Assertions.assertTrue(Point.arePointsClose(pt1, pt2, 5)); } @Test @@ -332,7 +331,7 @@ public void distanceFromLineSqrdTest() { DoublePoint ln2 = new DoublePoint(0, 0); // 9.2342 * 9.2342 ~ 85.27044964 - Assert.assertEquals(85.27044964, Point.distanceFromLineSqrd(pt, ln1, ln2), DOUBLE_EPSILON_COMPARISON); + Assertions.assertEquals(85.27044964, Point.distanceFromLineSqrd(pt, ln1, ln2), DOUBLE_EPSILON_COMPARISON); } @Test @@ -340,15 +339,15 @@ public void getUnitNormalTest() { LongPoint pt1 = new LongPoint(1, 1); LongPoint pt2 = new LongPoint(1, 1); - Assert.assertEquals(new DoublePoint(), Point.getUnitNormal(pt1, pt2)); + Assertions.assertEquals(new DoublePoint(), Point.getUnitNormal(pt1, pt2)); pt2.setX(5L); - Assert.assertEquals(new DoublePoint(0, -1), Point.getUnitNormal(pt1, pt2)); + Assertions.assertEquals(new DoublePoint(0, -1), Point.getUnitNormal(pt1, pt2)); pt2.setY(4L); DoublePoint dp = Point.getUnitNormal(pt1, pt2); - Assert.assertEquals(0.6, dp.getX(), DOUBLE_EPSILON_COMPARISON); - Assert.assertEquals(-0.8, dp.getY(), DOUBLE_EPSILON_COMPARISON); + Assertions.assertEquals(0.6, dp.getX(), DOUBLE_EPSILON_COMPARISON); + Assertions.assertEquals(-0.8, dp.getY(), DOUBLE_EPSILON_COMPARISON); } @Test @@ -357,14 +356,14 @@ public void slopesNearCollinearTest01() { LongPoint pt2 = new LongPoint(1, 1); LongPoint pt3 = new LongPoint(6, 2); - Assert.assertTrue(Point.slopesNearCollinear(pt1, pt2, pt3, 0.04)); - Assert.assertFalse(Point.slopesNearCollinear(pt1, pt2, pt3, 0.03)); + Assertions.assertTrue(Point.slopesNearCollinear(pt1, pt2, pt3, 0.04)); + Assertions.assertFalse(Point.slopesNearCollinear(pt1, pt2, pt3, 0.03)); pt1 = new LongPoint(2, 5); pt2 = new LongPoint(1, 1); pt3 = new LongPoint(2, 6); - Assert.assertTrue(Point.slopesNearCollinear(pt1, pt2, pt3, 0.04)); - Assert.assertFalse(Point.slopesNearCollinear(pt1, pt2, pt3, 0.03)); + Assertions.assertTrue(Point.slopesNearCollinear(pt1, pt2, pt3, 0.04)); + Assertions.assertFalse(Point.slopesNearCollinear(pt1, pt2, pt3, 0.03)); } @Test @@ -373,14 +372,14 @@ public void slopesNearCollinearTest02() { LongPoint pt2 = new LongPoint(5, 2); LongPoint pt3 = new LongPoint(6, 2); - Assert.assertTrue(Point.slopesNearCollinear(pt1, pt2, pt3, 0.04)); - Assert.assertFalse(Point.slopesNearCollinear(pt1, pt2, pt3, 0.03)); + Assertions.assertTrue(Point.slopesNearCollinear(pt1, pt2, pt3, 0.04)); + Assertions.assertFalse(Point.slopesNearCollinear(pt1, pt2, pt3, 0.03)); pt1 = new LongPoint(1, 1); pt2 = new LongPoint(2, 5); pt3 = new LongPoint(2, 6); - Assert.assertTrue(Point.slopesNearCollinear(pt1, pt2, pt3, 0.04)); - Assert.assertFalse(Point.slopesNearCollinear(pt1, pt2, pt3, 0.03)); + Assertions.assertTrue(Point.slopesNearCollinear(pt1, pt2, pt3, 0.04)); + Assertions.assertFalse(Point.slopesNearCollinear(pt1, pt2, pt3, 0.03)); } @Test @@ -389,25 +388,25 @@ public void slopesNearCollinearTest03() { LongPoint pt2 = new LongPoint(6, 2); LongPoint pt3 = new LongPoint(5, 2); - Assert.assertTrue(Point.slopesNearCollinear(pt1, pt2, pt3, 0.04)); - Assert.assertFalse(Point.slopesNearCollinear(pt1, pt2, pt3, 0.03)); + Assertions.assertTrue(Point.slopesNearCollinear(pt1, pt2, pt3, 0.04)); + Assertions.assertFalse(Point.slopesNearCollinear(pt1, pt2, pt3, 0.03)); pt1 = new LongPoint(1, 1); pt2 = new LongPoint(2, 6); pt3 = new LongPoint(2, 5); - Assert.assertTrue(Point.slopesNearCollinear(pt1, pt2, pt3, 0.04)); - Assert.assertFalse(Point.slopesNearCollinear(pt1, pt2, pt3, 0.03)); + Assertions.assertTrue(Point.slopesNearCollinear(pt1, pt2, pt3, 0.04)); + Assertions.assertFalse(Point.slopesNearCollinear(pt1, pt2, pt3, 0.03)); } private static void assertLongPointFields(LongPoint lp, long x, long y, long z) { - Assert.assertEquals(x, lp.getX()); - Assert.assertEquals(y, lp.getY()); - Assert.assertEquals(z, lp.getZ()); + Assertions.assertEquals(x, lp.getX()); + Assertions.assertEquals(y, lp.getY()); + Assertions.assertEquals(z, lp.getZ()); } private static void assertDoublePointFields(DoublePoint dp, double x, double y, double z) { - Assert.assertEquals(x, dp.getX(), DOUBLE_EPSILON_COMPARISON); - Assert.assertEquals(y, dp.getY(), DOUBLE_EPSILON_COMPARISON); - Assert.assertEquals(z, dp.getZ(), DOUBLE_EPSILON_COMPARISON); + Assertions.assertEquals(x, dp.getX(), DOUBLE_EPSILON_COMPARISON); + Assertions.assertEquals(y, dp.getY(), DOUBLE_EPSILON_COMPARISON); + Assertions.assertEquals(z, dp.getZ(), DOUBLE_EPSILON_COMPARISON); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/clipper/PolyNodeTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/clipper/PolyNodeTest.java index ec580705e7..40941a3633 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/clipper/PolyNodeTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/clipper/PolyNodeTest.java @@ -25,14 +25,13 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.canvas.parser.clipper.IClipper.EndType; import com.itextpdf.kernel.pdf.canvas.parser.clipper.IClipper.JoinType; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PolyNodeTest extends ExtendedITextTest { @Test @@ -42,8 +41,8 @@ public void addAndGetChildTest() { PolyNode child = new PolyNode(); node.addChild(child); - Assert.assertSame(child, node.getChilds().get(0)); - Assert.assertEquals(1, node.getChilds().size()); + Assertions.assertSame(child, node.getChilds().get(0)); + Assertions.assertEquals(1, node.getChilds().size()); } @Test @@ -52,7 +51,7 @@ public void unmodifiableListOfChildsTest() { List childs = node.getChilds(); - Assert.assertThrows(UnsupportedOperationException.class, () -> childs.add(new PolyNode())); + Assertions.assertThrows(UnsupportedOperationException.class, () -> childs.add(new PolyNode())); } @Test @@ -60,15 +59,15 @@ public void getChildCountTest() { PolyNode node = new PolyNode(); node.addChild(new PolyNode()); - Assert.assertEquals(1, node.getChildCount()); + Assertions.assertEquals(1, node.getChildCount()); } @Test public void getContourAndPolygonTest() { PolyNode node = new PolyNode(); - Assert.assertTrue(node.getContour()instanceof Path); - Assert.assertSame(node.getContour(), node.getPolygon()); + Assertions.assertTrue(node.getContour()instanceof Path); + Assertions.assertSame(node.getContour(), node.getPolygon()); } @Test @@ -76,7 +75,7 @@ public void setAndGetEndTypeTest() { PolyNode node = new PolyNode(); node.setEndType(EndType.CLOSED_POLYGON); - Assert.assertEquals(EndType.CLOSED_POLYGON, node.getEndType()); + Assertions.assertEquals(EndType.CLOSED_POLYGON, node.getEndType()); } @Test @@ -84,7 +83,7 @@ public void setAndGetJoinTypeTest() { PolyNode node = new PolyNode(); node.setJoinType(JoinType.ROUND); - Assert.assertEquals(JoinType.ROUND, node.getJoinType()); + Assertions.assertEquals(JoinType.ROUND, node.getJoinType()); } @Test @@ -92,7 +91,7 @@ public void setAndIsOpenTest() { PolyNode node = new PolyNode(); node.setOpen(true); - Assert.assertTrue(node.isOpen()); + Assertions.assertTrue(node.isOpen()); } @Test @@ -102,7 +101,7 @@ public void setAndGetParentTest() { PolyNode child = new PolyNode(); child.setParent(parentNode); - Assert.assertSame(parentNode, child.getParent()); + Assertions.assertSame(parentNode, child.getParent()); } @Test @@ -111,14 +110,14 @@ public void getNextPolyNodeNotEmptyTest() { node.addChild(new PolyNode()); node.addChild(new PolyNode()); - Assert.assertSame(node.getChilds().get(0), node.getNext()); + Assertions.assertSame(node.getChilds().get(0), node.getNext()); } @Test public void getNextNoChildsTest() { PolyNode node = new PolyNode(); - Assert.assertNull(node.getNext()); + Assertions.assertNull(node.getNext()); } @Test @@ -132,14 +131,14 @@ public void getNextPolyNodeWithSiblingTest() { child1.setParent(node); child2.setParent(node); - Assert.assertSame(child2, child1.getNext()); + Assertions.assertSame(child2, child1.getNext()); } @Test public void isHoleTest() { PolyNode node = new PolyNode(); - Assert.assertTrue(node.isHole()); + Assertions.assertTrue(node.isHole()); } @Test @@ -149,6 +148,6 @@ public void isNotHoleTest() { node.addChild(child); - Assert.assertFalse(child.isHole()); + Assertions.assertFalse(child.isHole()); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/clipper/PolyTreeTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/clipper/PolyTreeTest.java index 12a532dcf0..3897554265 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/clipper/PolyTreeTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/clipper/PolyTreeTest.java @@ -23,14 +23,13 @@ This file is part of the iText (R) project. package com.itextpdf.kernel.pdf.canvas.parser.clipper; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PolyTreeTest extends ExtendedITextTest { @Test @@ -41,13 +40,13 @@ public void clearPolyTreeTest() { List allPolys = tree.getAllPolys(); allPolys.add(new PolyNode()); - Assert.assertFalse(allPolys.isEmpty()); - Assert.assertEquals(1, tree.getChildCount()); + Assertions.assertFalse(allPolys.isEmpty()); + Assertions.assertEquals(1, tree.getChildCount()); tree.Clear(); - Assert.assertTrue(allPolys.isEmpty()); - Assert.assertEquals(0, tree.getChildCount()); + Assertions.assertTrue(allPolys.isEmpty()); + Assertions.assertEquals(0, tree.getChildCount()); } @Test @@ -60,21 +59,21 @@ public void getFistChildInPolyTreeTest() { tree.addChild(firstChild); tree.addChild(secondChild); - Assert.assertSame(firstChild, tree.getFirst()); + Assertions.assertSame(firstChild, tree.getFirst()); } @Test public void getFistChildInEmptyPolyTreeTest() { PolyTree tree = new PolyTree(); - Assert.assertNull(tree.getFirst()); + Assertions.assertNull(tree.getFirst()); } @Test public void getTotalSizePolyTreeEmptyTest() { PolyTree tree = new PolyTree(); - Assert.assertEquals(0, tree.getTotalSize()); + Assertions.assertEquals(0, tree.getTotalSize()); } @Test @@ -87,7 +86,7 @@ public void getTotalSizeDifferentPolyNodeTest() { tree.addChild(new PolyNode()); - Assert.assertEquals(1, tree.getTotalSize()); + Assertions.assertEquals(1, tree.getTotalSize()); } @Test @@ -101,6 +100,6 @@ public void getTotalSizeSamePolyNodeTest() { tree.addChild(node); - Assert.assertEquals(2, tree.getTotalSize()); + Assertions.assertEquals(2, tree.getTotalSize()); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/data/ImageRenderInfoTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/data/ImageRenderInfoTest.java index bf796ede74..d776852293 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/data/ImageRenderInfoTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/data/ImageRenderInfoTest.java @@ -31,16 +31,15 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.canvas.CanvasTag; import com.itextpdf.kernel.pdf.xobject.PdfImageXObject; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.net.MalformedURLException; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.util.*; -@Category(UnitTest.class) +@Tag("UnitTest") public class ImageRenderInfoTest extends ExtendedITextTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/kernel/parser/data/" + "ImageRenderInfoTest/"; @@ -58,18 +57,18 @@ public void checkImageRenderInfoTest() throws MalformedURLException { ImageRenderInfo imageRenderInfo = new ImageRenderInfo(tagHierarchy, new TestGraphicsState(), matrix, imageStream, new PdfName("Im1"), new PdfDictionary(), true); - Assert.assertTrue(imageRenderInfo.isInline()); - Assert.assertEquals(image.getWidth(), imageRenderInfo.getImage().getWidth(), EPS); - Assert.assertEquals("/Im1", imageRenderInfo.getImageResourceName().toString()); - Assert.assertEquals(new com.itextpdf.kernel.geom.Vector(0.5f, 0, 1), imageRenderInfo.getStartPoint()); - Assert.assertEquals(matrix, imageRenderInfo.getImageCtm()); - Assert.assertEquals(4, imageRenderInfo.getArea(), EPS); - Assert.assertEquals(0, imageRenderInfo.getColorSpaceDictionary().size()); - Assert.assertEquals(1, imageRenderInfo.getCanvasTagHierarchy().size()); - Assert.assertTrue(imageRenderInfo.hasMcid(2, true)); - Assert.assertTrue(imageRenderInfo.hasMcid(2)); - Assert.assertFalse(imageRenderInfo.hasMcid(1)); - Assert.assertEquals(2, imageRenderInfo.getMcid()); + Assertions.assertTrue(imageRenderInfo.isInline()); + Assertions.assertEquals(image.getWidth(), imageRenderInfo.getImage().getWidth(), EPS); + Assertions.assertEquals("/Im1", imageRenderInfo.getImageResourceName().toString()); + Assertions.assertEquals(new com.itextpdf.kernel.geom.Vector(0.5f, 0, 1), imageRenderInfo.getStartPoint()); + Assertions.assertEquals(matrix, imageRenderInfo.getImageCtm()); + Assertions.assertEquals(4, imageRenderInfo.getArea(), EPS); + Assertions.assertEquals(0, imageRenderInfo.getColorSpaceDictionary().size()); + Assertions.assertEquals(1, imageRenderInfo.getCanvasTagHierarchy().size()); + Assertions.assertTrue(imageRenderInfo.hasMcid(2, true)); + Assertions.assertTrue(imageRenderInfo.hasMcid(2)); + Assertions.assertFalse(imageRenderInfo.hasMcid(1)); + Assertions.assertEquals(2, imageRenderInfo.getMcid()); } private class TestGraphicsState extends CanvasGraphicsState { diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/listener/RegexBasedLocationExtractionStrategyTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/listener/RegexBasedLocationExtractionStrategyTest.java index b2b58db3fc..dd76c5b126 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/listener/RegexBasedLocationExtractionStrategyTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/listener/RegexBasedLocationExtractionStrategyTest.java @@ -27,56 +27,79 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfReader; import com.itextpdf.kernel.pdf.canvas.parser.PdfCanvasProcessor; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.List; -import java.util.regex.Pattern; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class RegexBasedLocationExtractionStrategyTest extends ExtendedITextTest { private static final String sourceFolder = "./src/test/resources/com/itextpdf/kernel/parser/RegexBasedLocationExtractionStrategyTest/"; @Test - public void test01() throws IOException { - System.out.println(new File(sourceFolder).getAbsolutePath()); + public void test00() throws IOException { + PdfDocument document = new PdfDocument(new PdfReader(sourceFolder + "in00.pdf")); + // get locations + List locationList = new ArrayList<>(); + for (int i = 1; i <= document.getNumberOfPages(); ++i) { + RegexBasedLocationExtractionStrategy extractionStrategy = new RegexBasedLocationExtractionStrategy("cillum"); + PdfCanvasProcessor processor = new PdfCanvasProcessor(extractionStrategy); + processor.processPageContent(document.getPage(i)); + for (IPdfTextLocation location : extractionStrategy.getResultantLocations()) { + locationList.add(location); + } + } + // compare + Assertions.assertEquals(2, locationList.size()); - PdfDocument pdfDocument = new PdfDocument(new PdfReader(sourceFolder + "in01.pdf")); + IPdfTextLocation loc = locationList.get(0); + + Assertions.assertEquals("cillum", loc.getText()); + Assertions.assertEquals(64, (int) loc.getRectangle().getX()); + Assertions.assertEquals(732, (int) loc.getRectangle().getY()); + Assertions.assertEquals(30, (int) loc.getRectangle().getWidth()); + Assertions.assertEquals(11, (int) loc.getRectangle().getHeight()); + + IPdfTextLocation loc2 = locationList.get(1); + Assertions.assertEquals(64, (int) loc2.getRectangle().getX()); + Assertions.assertEquals(732, (int) loc2.getRectangle().getY()); + Assertions.assertEquals(30, (int) loc2.getRectangle().getWidth()); + Assertions.assertEquals(11, (int) loc2.getRectangle().getHeight()); - // build strategy - RegexBasedLocationExtractionStrategy extractionStrategy = new RegexBasedLocationExtractionStrategy(Pattern.compile("\\{\\{Signature\\}\\}")); + document.close(); + } + @Test + public void test02() throws IOException { + PdfDocument document = new PdfDocument(new PdfReader(sourceFolder + "in01.pdf")); // get locations List locationList = new ArrayList<>(); - for (int x = 1; x <= pdfDocument.getNumberOfPages(); x++) { - new PdfCanvasProcessor(extractionStrategy).processPageContent(pdfDocument.getPage(x)); - for(IPdfTextLocation location : extractionStrategy.getResultantLocations()) { - if(location != null) { - locationList.add(location); - } + for (int i = 1; i <= document.getNumberOfPages(); ++i) { + RegexBasedLocationExtractionStrategy extractionStrategy = new RegexBasedLocationExtractionStrategy("\\{\\{Signature\\}\\}"); + PdfCanvasProcessor processor = new PdfCanvasProcessor(extractionStrategy); + processor.processPageContent(document.getPage(i)); + for (IPdfTextLocation location : extractionStrategy.getResultantLocations()) { + locationList.add(location); } } - // compare - Assert.assertEquals(1, locationList.size()); + Assertions.assertEquals(1, locationList.size()); IPdfTextLocation loc = locationList.get(0); - Assert.assertEquals("{{Signature}}", loc.getText()); - Assert.assertEquals(23, (int) loc.getRectangle().getX()); - Assert.assertEquals(375, (int) loc.getRectangle().getY()); - Assert.assertEquals(55, (int) loc.getRectangle().getWidth()); - Assert.assertEquals(11, (int) loc.getRectangle().getHeight()); + Assertions.assertEquals("{{Signature}}", loc.getText()); + Assertions.assertEquals(23, (int) loc.getRectangle().getX()); + Assertions.assertEquals(375, (int) loc.getRectangle().getY()); + Assertions.assertEquals(55, (int) loc.getRectangle().getWidth()); + Assertions.assertEquals(11, (int) loc.getRectangle().getHeight()); - // close - pdfDocument.close(); + document.close(); } @@ -89,12 +112,11 @@ public void testLigatureBeforeLigature() throws IOException { PdfDocument pdfDocument = new PdfDocument(new PdfReader(sourceFolder + "ligature.pdf")); - // build strategy - RegexBasedLocationExtractionStrategy extractionStrategy = new RegexBasedLocationExtractionStrategy("ca"); - // get locations List locationList = new ArrayList<>(); for (int x = 1; x <= pdfDocument.getNumberOfPages(); x++) { + // build strategy + RegexBasedLocationExtractionStrategy extractionStrategy = new RegexBasedLocationExtractionStrategy("ca"); new PdfCanvasProcessor(extractionStrategy).processPageContent(pdfDocument.getPage(x)); for(IPdfTextLocation location : extractionStrategy.getResultantLocations()) { if(location != null) { @@ -104,16 +126,16 @@ public void testLigatureBeforeLigature() throws IOException { } // compare - Assert.assertEquals(1, locationList.size()); + Assertions.assertEquals(1, locationList.size()); IPdfTextLocation loc = locationList.get(0); - Assert.assertEquals("ca", loc.getText()); + Assertions.assertEquals("ca", loc.getText()); Rectangle rect = loc.getRectangle(); - Assert.assertEquals(36, rect.getX(), 0.0001); - Assert.assertEquals(655.4600, rect.getY(), 0.0001); - Assert.assertEquals(25.1000, rect.getWidth(), 0.0001); - Assert.assertEquals(20, rect.getHeight(), 0.0001); + Assertions.assertEquals(36, rect.getX(), 0.0001); + Assertions.assertEquals(655.4600, rect.getY(), 0.0001); + Assertions.assertEquals(25.1000, rect.getWidth(), 0.0001); + Assertions.assertEquals(20, rect.getHeight(), 0.0001); pdfDocument.close(); } @@ -124,12 +146,11 @@ public void testLigatureCrossLigature() throws IOException { PdfDocument pdfDocument = new PdfDocument(new PdfReader(sourceFolder + "ligature.pdf")); - // build strategy - RegexBasedLocationExtractionStrategy extractionStrategy = new RegexBasedLocationExtractionStrategy("al"); - // get locations List locationList = new ArrayList<>(); for (int x = 1; x <= pdfDocument.getNumberOfPages(); x++) { + // build strategy + RegexBasedLocationExtractionStrategy extractionStrategy = new RegexBasedLocationExtractionStrategy("al"); new PdfCanvasProcessor(extractionStrategy).processPageContent(pdfDocument.getPage(x)); for(IPdfTextLocation location : extractionStrategy.getResultantLocations()) { if(location != null) { @@ -139,16 +160,16 @@ public void testLigatureCrossLigature() throws IOException { } // compare - Assert.assertEquals(1, locationList.size()); + Assertions.assertEquals(1, locationList.size()); IPdfTextLocation loc = locationList.get(0); - Assert.assertEquals("al", loc.getText()); + Assertions.assertEquals("al", loc.getText()); Rectangle rect = loc.getRectangle(); - Assert.assertEquals(48.7600, rect.getX(), 0.0001); - Assert.assertEquals(655.4600, rect.getY(), 0.0001); - Assert.assertEquals(25.9799, rect.getWidth(), 0.0001); - Assert.assertEquals(20, rect.getHeight(), 0.0001); + Assertions.assertEquals(48.7600, rect.getX(), 0.0001); + Assertions.assertEquals(655.4600, rect.getY(), 0.0001); + Assertions.assertEquals(25.9799, rect.getWidth(), 0.0001); + Assertions.assertEquals(20, rect.getHeight(), 0.0001); pdfDocument.close(); } @@ -159,12 +180,11 @@ public void testLigatureInLigature() throws IOException { PdfDocument pdfDocument = new PdfDocument(new PdfReader(sourceFolder + "ligature.pdf")); - // build strategy - RegexBasedLocationExtractionStrategy extractionStrategy = new RegexBasedLocationExtractionStrategy("l"); - // get locations List locationList = new ArrayList<>(); for (int x = 1; x <= pdfDocument.getNumberOfPages(); x++) { + // build strategy + RegexBasedLocationExtractionStrategy extractionStrategy = new RegexBasedLocationExtractionStrategy("l"); new PdfCanvasProcessor(extractionStrategy).processPageContent(pdfDocument.getPage(x)); for(IPdfTextLocation location : extractionStrategy.getResultantLocations()) { if(location != null) { @@ -174,16 +194,16 @@ public void testLigatureInLigature() throws IOException { } // compare - Assert.assertEquals(1, locationList.size()); + Assertions.assertEquals(1, locationList.size()); IPdfTextLocation loc = locationList.get(0); - Assert.assertEquals("l", loc.getText()); + Assertions.assertEquals("l", loc.getText()); Rectangle rect = loc.getRectangle(); - Assert.assertEquals(61.0999, rect.getX(), 0.0001); - Assert.assertEquals(655.4600, rect.getY(), 0.0001); - Assert.assertEquals(13.6399, rect.getWidth(), 0.0001); - Assert.assertEquals(20, rect.getHeight(), 0.0001); + Assertions.assertEquals(61.0999, rect.getX(), 0.0001); + Assertions.assertEquals(655.4600, rect.getY(), 0.0001); + Assertions.assertEquals(13.6399, rect.getWidth(), 0.0001); + Assertions.assertEquals(20, rect.getHeight(), 0.0001); pdfDocument.close(); } @@ -192,12 +212,11 @@ public void testLigatureInLigature() throws IOException { public void testRotatedText() throws IOException { PdfDocument pdfDocument = new PdfDocument(new PdfReader(sourceFolder + "rotatedText.pdf")); - // build strategy - RegexBasedLocationExtractionStrategy extractionStrategy = new RegexBasedLocationExtractionStrategy("abc"); - // get locations List locationList = new ArrayList<>(); for (int x = 1; x <= pdfDocument.getNumberOfPages(); x++) { + // build strategy + RegexBasedLocationExtractionStrategy extractionStrategy = new RegexBasedLocationExtractionStrategy("abc"); new PdfCanvasProcessor(extractionStrategy).processPageContent(pdfDocument.getPage(x)); for(IPdfTextLocation location : extractionStrategy.getResultantLocations()) { if(location != null) { @@ -207,9 +226,9 @@ public void testRotatedText() throws IOException { } // compare - Assert.assertEquals(2, locationList.size()); - Assert.assertTrue(locationList.get(0).getRectangle().equalsWithEpsilon(new Rectangle(188.512f, 450f, 14.800003f, 25.791992f))); - Assert.assertTrue(locationList.get(1).getRectangle().equalsWithEpsilon(new Rectangle(36f, 746.688f, 25.792f, 14.799988f))); + Assertions.assertEquals(2, locationList.size()); + Assertions.assertTrue(locationList.get(0).getRectangle().equalsWithEpsilon(new Rectangle(188.512f, 450f, 14.800003f, 25.791992f))); + Assertions.assertTrue(locationList.get(1).getRectangle().equalsWithEpsilon(new Rectangle(36f, 746.688f, 25.792f, 14.799988f))); pdfDocument.close(); } @@ -222,9 +241,9 @@ public void regexStartedWithWhiteSpaceTest() throws IOException { List locations = new ArrayList<>(extractionStrategy.getResultantLocations()); pdfDocument.close(); - Assert.assertEquals(1, locations.size()); - Assert.assertEquals(" start", locations.get(0).getText()); - Assert.assertTrue( + Assertions.assertEquals(1, locations.size()); + Assertions.assertEquals(" start", locations.get(0).getText()); + Assertions.assertTrue( new Rectangle(92.3f, 743.3970f, 20.6159f, 13.2839f).equalsWithEpsilon(locations.get(0).getRectangle())); } @@ -236,9 +255,9 @@ public void regexStartedWithNewLineTest() throws IOException { List locations = new ArrayList<>(extractionStrategy.getResultantLocations()); pdfDocument.close(); - Assert.assertEquals(1, locations.size()); - Assert.assertEquals("\nstart", locations.get(0).getText()); - Assert.assertTrue( + Assertions.assertEquals(1, locations.size()); + Assertions.assertEquals("\nstart", locations.get(0).getText()); + Assertions.assertTrue( new Rectangle(56.8f, 729.5970f, 20.6159f, 13.2839f).equalsWithEpsilon(locations.get(0).getRectangle())); } @@ -251,9 +270,9 @@ public void regexWithWhiteSpacesTest() throws IOException { List locations = new ArrayList<>(extractionStrategy.getResultantLocations()); pdfDocument.close(); - Assert.assertEquals(1, locations.size()); - Assert.assertEquals(" start ", locations.get(0).getText()); - Assert.assertTrue( + Assertions.assertEquals(1, locations.size()); + Assertions.assertEquals(" start ", locations.get(0).getText()); + Assertions.assertTrue( new Rectangle(92.3f, 743.3970f, 20.6159f, 13.2839f).equalsWithEpsilon(locations.get(0).getRectangle())); } @@ -266,9 +285,9 @@ public void regexWithNewLinesTest() throws IOException { List locations = new ArrayList<>(extractionStrategy.getResultantLocations()); pdfDocument.close(); - Assert.assertEquals(1, locations.size()); - Assert.assertEquals("\nstart\n", locations.get(0).getText()); - Assert.assertTrue( + Assertions.assertEquals(1, locations.size()); + Assertions.assertEquals("\nstart\n", locations.get(0).getText()); + Assertions.assertTrue( new Rectangle(56.8f, 729.5970f, 20.6159f, 13.2839f).equalsWithEpsilon(locations.get(0).getRectangle())); } @@ -282,12 +301,12 @@ public void regexWithNewLineBetweenWordsTest() throws IOException { List locations = new ArrayList<>(extractionStrategy.getResultantLocations()); pdfDocument.close(); - Assert.assertEquals(2, locations.size()); - Assert.assertEquals("hello\nworld", locations.get(0).getText()); - Assert.assertEquals("hello\nworld", locations.get(1).getText()); - Assert.assertTrue( + Assertions.assertEquals(2, locations.size()); + Assertions.assertEquals("hello\nworld", locations.get(0).getText()); + Assertions.assertEquals("hello\nworld", locations.get(1).getText()); + Assertions.assertTrue( new Rectangle(56.8f, 729.5970f, 27.8999f, 13.2839f).equalsWithEpsilon(locations.get(0).getRectangle())); - Assert.assertTrue( + Assertions.assertTrue( new Rectangle(56.8f, 743.3970f, 23.9039f, 13.2839f).equalsWithEpsilon(locations.get(1).getRectangle())); } @@ -300,7 +319,7 @@ public void regexWithOnlyNewLine() throws IOException { List locations = new ArrayList<>(extractionStrategy.getResultantLocations()); pdfDocument.close(); - Assert.assertEquals(0, locations.size()); + Assertions.assertEquals(0, locations.size()); } @Test @@ -311,7 +330,7 @@ public void regexWithOnlyWhiteSpace() throws IOException { List locations = new ArrayList<>(extractionStrategy.getResultantLocations()); pdfDocument.close(); - Assert.assertEquals(0, locations.size()); + Assertions.assertEquals(0, locations.size()); } @Test @@ -322,7 +341,7 @@ public void sortCompareTest() throws IOException { pdfCanvasProcessor.processPageContent(pdfDocument.getPage(1)); pdfCanvasProcessor.processPageContent(pdfDocument.getPage(2)); List locations = new ArrayList<>(extractionStrategy.getResultantLocations()); - Assert.assertEquals(13, locations.size()); + Assertions.assertEquals(13, locations.size()); } } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/util/InlineImageParsingUtilsTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/util/InlineImageParsingUtilsTest.java index 6a66b6b413..f62d6337e4 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/util/InlineImageParsingUtilsTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/util/InlineImageParsingUtilsTest.java @@ -23,23 +23,37 @@ This file is part of the iText (R) project. package com.itextpdf.kernel.pdf.canvas.parser.util; import com.itextpdf.commons.utils.MessageFormatUtil; +import com.itextpdf.io.source.ByteArrayOutputStream; +import com.itextpdf.io.source.PdfTokenizer; +import com.itextpdf.io.source.RandomAccessFileOrArray; +import com.itextpdf.io.source.RandomAccessSourceFactory; import com.itextpdf.kernel.exceptions.KernelExceptionMessageConstant; import com.itextpdf.kernel.pdf.PdfArray; import com.itextpdf.kernel.pdf.PdfDictionary; +import com.itextpdf.kernel.pdf.PdfLiteral; import com.itextpdf.kernel.pdf.PdfName; import com.itextpdf.kernel.pdf.PdfNumber; +import com.itextpdf.kernel.pdf.PdfObject; +import com.itextpdf.kernel.pdf.PdfResources; import com.itextpdf.kernel.pdf.PdfStream; import com.itextpdf.kernel.pdf.canvas.parser.util.InlineImageParsingUtils.InlineImageParseException; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.List; + +@Tag("UnitTest") public class InlineImageParsingUtilsTest extends ExtendedITextTest { + private static final String RESOURCE_FOLDER = "./src/test/resources/com/itextpdf/kernel/pdf/canvas/parser/InlineImageParsingUtilsTest/"; + @Test public void iccBasedCsTest() { PdfName colorSpace = PdfName.ICCBased; @@ -52,7 +66,7 @@ public void iccBasedCsTest() { array.add(stream); dictionary.put(colorSpace, array); - Assert.assertEquals(4, InlineImageParsingUtils.getComponentsPerPixel(colorSpace, dictionary)); + Assertions.assertEquals(4, InlineImageParsingUtils.getComponentsPerPixel(colorSpace, dictionary)); } @Test @@ -64,7 +78,7 @@ public void indexedCsTest() { array.add(colorSpace); dictionary.put(colorSpace, array); - Assert.assertEquals(1, InlineImageParsingUtils.getComponentsPerPixel(colorSpace, dictionary)); + Assertions.assertEquals(1, InlineImageParsingUtils.getComponentsPerPixel(colorSpace, dictionary)); } @Test @@ -74,57 +88,108 @@ public void csInDictAsNameTest() { PdfDictionary dictionary = new PdfDictionary(); dictionary.put(colorSpace, PdfName.DeviceCMYK); - Assert.assertEquals(4, InlineImageParsingUtils.getComponentsPerPixel(colorSpace, dictionary)); + Assertions.assertEquals(4, InlineImageParsingUtils.getComponentsPerPixel(colorSpace, dictionary)); } @Test public void csInDictAsNameNullTest() { PdfName colorSpace = PdfName.ICCBased; PdfDictionary dictionary = new PdfDictionary(); - Exception exception = Assert.assertThrows(InlineImageParseException.class, - () -> InlineImageParsingUtils.getComponentsPerPixel(colorSpace, dictionary)); - Assert.assertEquals(MessageFormatUtil.format(KernelExceptionMessageConstant.UNEXPECTED_COLOR_SPACE, "/ICCBased"), - exception.getMessage()); - } - - @Test - public void notSupportedCsWithCsDictionaryTest() { - PdfName colorSpace = PdfName.ICCBased; - - PdfDictionary dictionary = new PdfDictionary(); - PdfArray array = new PdfArray(); - array.add(PdfName.Pattern); - PdfStream stream = new PdfStream(); - stream.put(PdfName.N, new PdfNumber(4)); - array.add(stream); - dictionary.put(colorSpace, array); - - Exception exception = Assert.assertThrows(InlineImageParseException.class, + Exception exception = Assertions.assertThrows(InlineImageParseException.class, () -> InlineImageParsingUtils.getComponentsPerPixel(colorSpace, dictionary)); - Assert.assertEquals(MessageFormatUtil.format(KernelExceptionMessageConstant.UNEXPECTED_COLOR_SPACE, "/ICCBased"), + Assertions.assertEquals(MessageFormatUtil.format(KernelExceptionMessageConstant.UNEXPECTED_COLOR_SPACE, "/ICCBased"), exception.getMessage()); } @Test public void nullCsTest() { - Assert.assertEquals(1, InlineImageParsingUtils.getComponentsPerPixel(null, null)); + Assertions.assertEquals(1, InlineImageParsingUtils.getComponentsPerPixel(null, null)); } @Test public void deviceGrayCsTest() { PdfName colorSpace = PdfName.DeviceGray; - Assert.assertEquals(1, InlineImageParsingUtils.getComponentsPerPixel(colorSpace, null)); + Assertions.assertEquals(1, InlineImageParsingUtils.getComponentsPerPixel(colorSpace, null)); } @Test public void deviceRGBCsTest() { PdfName colorSpace = PdfName.DeviceRGB; - Assert.assertEquals(3, InlineImageParsingUtils.getComponentsPerPixel(colorSpace, null)); + Assertions.assertEquals(3, InlineImageParsingUtils.getComponentsPerPixel(colorSpace, null)); } @Test public void deviceCMYKCsTest() { PdfName colorSpace = PdfName.DeviceCMYK; - Assert.assertEquals(4, InlineImageParsingUtils.getComponentsPerPixel(colorSpace, null)); + Assertions.assertEquals(4, InlineImageParsingUtils.getComponentsPerPixel(colorSpace, null)); + } + + @Test + public void parseLargeImageWithEndMarkerInDataTest() throws IOException { + PdfTokenizer tokenizer = new PdfTokenizer( + new RandomAccessFileOrArray( + new RandomAccessSourceFactory().createSource( + Files.readAllBytes(Paths.get(RESOURCE_FOLDER + "img.dat"))) + )); + PdfCanvasParser ps = new PdfCanvasParser(tokenizer, new PdfResources()); + List objects = ps.parse(null); + Assertions.assertEquals(2, objects.size()); + Assertions.assertTrue(objects.get(0) instanceof PdfStream); + Assertions.assertEquals(new PdfLiteral("EI"), objects.get(1)); + //Getting encoded bytes of an image, can't use PdfStream#getBytes() here because it decodes an image + byte[] image = ((ByteArrayOutputStream) ((PdfStream)objects.get(0)).getOutputStream().getOutputStream()).toByteArray(); + byte[] cmpImage = Files.readAllBytes(Paths.get(RESOURCE_FOLDER, "cmp_img.dat")); + Assertions.assertArrayEquals(cmpImage, image); + } + + @Test + public void binaryDataProbationTest() throws IOException { + testInlineImage("ID\nBl7a$DIjr)D..'g+Cno&@/EI Q", "inline image data"); + testInlineImage("ID\nBl7a$DIjr)D..'g+Cno&@/EI EMC", "inline image data"); + testInlineImage("ID\nBl7a$DIjr)D..'g+Cno&@/EI S", "inline image data"); + testInlineImage("ID\nBl7a$DIjr)D..'g+Cno&@/EI EMC", "inline image data"); + + testInlineImage("ID\nBl7a$DIjr)D..'g+Cno&@/EI \000Q", "inline image data"); + + testInlineImage("ID\nBl7a$DIjr)D..'g+Cno&@/EI Q ", "inline image data"); + testInlineImage("ID\nBl7a$DIjr)D..'g+Cno&@/EI EMC ", "inline image data"); + + testInlineImage("ID\nBl7a$DIjr)D..'g+Cno&@/EI ", "inline image data"); + + testInlineImage("ID\nBl7a$DIjr)D..'g+Cno&@/EI Q ", "inline image data"); + testInlineImage("ID\nBl7a$DIjr)D..'g+Cno&@/EI EMC ", "inline image data"); + + testInlineImage("ID\nBl7a$DIjr)D..'g+Cno&@/EI ", "inline image data"); + testInlineImage("ID\nBl7a$DIjr)D..'g+Cno&@/EI QEI", "inline image data"); + testInlineImage("ID\nBl7a$DIjr)D..'g+Cno&@/ EI ", "inline image data"); + // 2nd EI is taken into account + testInlineImage("ID\nBl7a$DIjr)D..'g+Cno&@/ EI DDDEI ", "inline image dat`ûGÔn"); + testInlineImage("ID\nBl7a$DIjr)D..'g+Cno&@/EI SEI Q", "inline image data"); + + testInlineImage("ID\nBl7a$DIjr)D..'g+Cno&@/EI \u0000", "inline image data"); + testInlineImage("ID\nBl7a$DIjr)D..'g+Cno&@/EI \u007f", "inline image data"); + testInlineImage("ID\nBl7a$DIjr)D..'g+Cno&@/EI \u0000pdf", "inline image data"); + testInlineImage("ID\nBl7a$DIjr)D..'g+Cno&@/EI \u0000pdf\u0000\u0000\u0000", "inline image data"); + } + + private void testInlineImage(String imgData, String cmpImgData) throws IOException { + String data = "BI\n" + + "/Width 10\n" + + "/Height 10\n" + + "/BitsPerComponent 8\n" + + "/ColorSpace /DeviceRGB\n" + + "/Filter [/ASCII85Decode]\n" + imgData; + PdfTokenizer tokenizer = new PdfTokenizer( + new RandomAccessFileOrArray( + new RandomAccessSourceFactory().createSource(data.getBytes(StandardCharsets.ISO_8859_1)) + ) + ); + PdfCanvasParser ps = new PdfCanvasParser(tokenizer, new PdfResources()); + List objects = ps.parse(null); + Assertions.assertEquals(2, objects.size()); + Assertions.assertTrue(objects.get(0) instanceof PdfStream); + Assertions.assertEquals(new PdfLiteral("EI"), objects.get(1)); + String image = new String(((PdfStream)objects.get(0)).getBytes(), StandardCharsets.ISO_8859_1); + Assertions.assertEquals(image, cmpImgData); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/util/PdfCanvasParserTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/util/PdfCanvasParserTest.java index cb7f90d6e0..5fb6f62a6f 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/util/PdfCanvasParserTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/parser/util/PdfCanvasParserTest.java @@ -37,16 +37,15 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfString; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; import java.util.ArrayList; import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfCanvasParserTest extends ExtendedITextTest { private static final String sourceFolder = "./src/test/resources/com/itextpdf/kernel/parser/PdfCanvasParserTest/"; @@ -77,7 +76,7 @@ public void innerArraysInContentStreamTest() throws IOException { PdfArray cmpArray = new PdfArray(expected); - Assert.assertTrue(new CompareTool().compareArrays(cmpArray, + Assertions.assertTrue(new CompareTool().compareArrays(cmpArray, (((PdfDictionary) actual.get(1)).getAsArray(new PdfName("ColorantsDef"))))); } @@ -95,9 +94,9 @@ public void parseArrayTest() throws IOException { PdfResources resources = pdfDocument.getPage(1).getResources(); PdfCanvasParser ps = new PdfCanvasParser(tokeniser, resources); - Exception exception = Assert.assertThrows(com.itextpdf.io.exceptions.IOException.class, + Exception exception = Assertions.assertThrows(com.itextpdf.io.exceptions.IOException.class, () -> ps.parse(null)); - Assert.assertEquals(MessageFormatUtil.format(KernelExceptionMessageConstant.UNEXPECTED_TOKEN, ">>"), + Assertions.assertEquals(MessageFormatUtil.format(KernelExceptionMessageConstant.UNEXPECTED_TOKEN, ">>"), exception.getCause().getMessage()); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/wmf/MetaDoUnitTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/wmf/MetaDoUnitTest.java index 42df319781..2536051bf9 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/wmf/MetaDoUnitTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/canvas/wmf/MetaDoUnitTest.java @@ -30,16 +30,15 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfWriter; import com.itextpdf.kernel.pdf.canvas.PdfCanvas; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class MetaDoUnitTest extends ExtendedITextTest { @Test @@ -50,8 +49,8 @@ public void inputStreamShallBeStartFromSpecificValueTest() throws IOException { // InputStream value shall be start with 0x9AC6CDD7 InputStream inputStream = new ByteArrayInputStream(new byte[] {}); MetaDo metaDo = new MetaDo(inputStream, pdfCanvas); - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> metaDo.readAll()); - Assert.assertEquals(KernelExceptionMessageConstant.NOT_A_PLACEABLE_WINDOWS_METAFILE, exception.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.NOT_A_PLACEABLE_WINDOWS_METAFILE, exception.getMessage()); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/collection/PdfCollectionFieldTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/collection/PdfCollectionFieldTest.java index e508804f9a..10beb72f81 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/collection/PdfCollectionFieldTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/collection/PdfCollectionFieldTest.java @@ -30,13 +30,12 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfNumber; import com.itextpdf.kernel.pdf.PdfString; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfCollectionFieldTest extends ExtendedITextTest { private static final PdfName[] ALLOWED_PDF_NAMES = { @@ -66,7 +65,7 @@ public void subTypeInConstructorTest() { PdfCollectionField field = new PdfCollectionField(pdfObject); - Assert.assertEquals(field.subType, EXPECTED_SUB_TYPES[i]); + Assertions.assertEquals(field.subType, EXPECTED_SUB_TYPES[i]); } } @@ -77,7 +76,7 @@ public void defaultSubTypeInConstructorTest() { PdfCollectionField field = new PdfCollectionField(pdfObject); - Assert.assertEquals(field.subType, PdfCollectionField.TEXT); + Assertions.assertEquals(field.subType, PdfCollectionField.TEXT); } @Test @@ -87,8 +86,8 @@ public void fieldCreationWithNameAndSubTypeTest() { for(int i = 0; i < ALLOWED_PDF_NAMES.length; i++) { PdfCollectionField field = new PdfCollectionField(fieldName, EXPECTED_SUB_TYPES[i]); - Assert.assertEquals(new PdfString(fieldName), field.getPdfObject().get(PdfName.N)); - Assert.assertEquals(ALLOWED_PDF_NAMES[i], field.getPdfObject().get(PdfName.Subtype)); + Assertions.assertEquals(new PdfString(fieldName), field.getPdfObject().get(PdfName.N)); + Assertions.assertEquals(ALLOWED_PDF_NAMES[i], field.getPdfObject().get(PdfName.Subtype)); } } @@ -100,7 +99,7 @@ public void fieldCreationWithDefaultSubTypeTest() { PdfCollectionField field = new PdfCollectionField(fieldName, unexpectedSubType); - Assert.assertEquals(defaultSubType, field.getPdfObject().get(PdfName.Subtype)); + Assertions.assertEquals(defaultSubType, field.getPdfObject().get(PdfName.Subtype)); } @Test @@ -111,11 +110,11 @@ public void orderPropertyTest() { pdfObject.put(PdfName.Subtype, PdfName.S); PdfCollectionField field = new PdfCollectionField(pdfObject); - Assert.assertNull(field.getOrder()); + Assertions.assertNull(field.getOrder()); field.setOrder(testOrder); - Assert.assertEquals(testOrder, field.getOrder().intValue()); + Assertions.assertEquals(testOrder, field.getOrder().intValue()); } @Test @@ -126,11 +125,11 @@ public void visibilityPropertyTest() { pdfObject.put(PdfName.Subtype, PdfName.S); PdfCollectionField field = new PdfCollectionField(pdfObject); - Assert.assertNull(field.getVisibility()); + Assertions.assertNull(field.getVisibility()); field.setVisibility(testVisibility); - Assert.assertEquals(testVisibility, field.getVisibility().getValue()); + Assertions.assertEquals(testVisibility, field.getVisibility().getValue()); } @Test @@ -141,11 +140,11 @@ public void editablePropertyTest() { pdfObject.put(PdfName.Subtype, PdfName.S); PdfCollectionField field = new PdfCollectionField(pdfObject); - Assert.assertNull(field.getEditable()); + Assertions.assertNull(field.getEditable()); field.setEditable(testEditable); - Assert.assertEquals(testEditable, field.getEditable().getValue()); + Assertions.assertEquals(testEditable, field.getEditable().getValue()); } @Test @@ -156,7 +155,7 @@ public void getTextValueTest() { pdfObject.put(PdfName.Subtype, PdfName.S); PdfCollectionField field = new PdfCollectionField(pdfObject); - Assert.assertEquals(new PdfString(textValue), field.getValue(textValue)); + Assertions.assertEquals(new PdfString(textValue), field.getValue(textValue)); } @Test @@ -168,7 +167,7 @@ public void getNumberValueTest() { pdfObject.put(PdfName.Subtype, PdfName.N); PdfCollectionField field = new PdfCollectionField(pdfObject); - Assert.assertEquals(numberValue, ((PdfNumber)field.getValue(numberValueAsString)).getValue(), 0.0001); + Assertions.assertEquals(numberValue, ((PdfNumber)field.getValue(numberValueAsString)).getValue(), 0.0001); } @Test @@ -179,7 +178,7 @@ public void getDateValueTest() { pdfObject.put(PdfName.Subtype, PdfName.D); PdfCollectionField field = new PdfCollectionField(pdfObject); - Assert.assertTrue(((PdfString)field.getValue(timeValueAsString)).getValue().startsWith("D:1986")); + Assertions.assertTrue(((PdfString)field.getValue(timeValueAsString)).getValue().startsWith("D:1986")); } @Test @@ -191,8 +190,8 @@ public void getUnsupportedTypeValueTest() { // this line will throw an exception as getValue() method is not // supported for subType which differs from S, N and D. - Exception e = Assert.assertThrows(PdfException.class, () -> field.getValue(stringValue)); - Assert.assertEquals(MessageFormatUtil.format(KernelExceptionMessageConstant.UNACCEPTABLE_FIELD_VALUE, + Exception e = Assertions.assertThrows(PdfException.class, () -> field.getValue(stringValue)); + Assertions.assertEquals(MessageFormatUtil.format(KernelExceptionMessageConstant.UNACCEPTABLE_FIELD_VALUE, stringValue, fieldName), e.getMessage()); } @@ -202,7 +201,7 @@ public void isWrappedObjectMustBeIndirectTest() { pdfObject.put(PdfName.Subtype, PdfName.S); PdfCollectionField field = new PdfCollectionField(pdfObject); - Assert.assertFalse(field.isWrappedObjectMustBeIndirect()); + Assertions.assertFalse(field.isWrappedObjectMustBeIndirect()); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/collection/PdfCollectionItemTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/collection/PdfCollectionItemTest.java index fd7c70de00..26ccad1cd2 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/collection/PdfCollectionItemTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/collection/PdfCollectionItemTest.java @@ -30,13 +30,12 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfNumber; import com.itextpdf.kernel.pdf.PdfString; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfCollectionItemTest extends ExtendedITextTest { @Test @@ -55,7 +54,7 @@ public void addItemTest() { PdfCollectionItem item = new PdfCollectionItem(schema); item.addItem(fieldName, fieldValue); - Assert.assertEquals(fieldValue, item.getPdfObject().getAsString(new PdfName(fieldName)).getValue()); + Assertions.assertEquals(fieldValue, item.getPdfObject().getAsString(new PdfName(fieldName)).getValue()); } @Test @@ -74,7 +73,7 @@ public void addDateItemTest() { PdfCollectionItem item = new PdfCollectionItem(schema); item.addItem(fieldName, new PdfDate(PdfDate.decode(timeValueAsString))); - Assert.assertTrue(((PdfString)field.getValue(timeValueAsString)).getValue().startsWith("D:1986")); + Assertions.assertTrue(((PdfString)field.getValue(timeValueAsString)).getValue().startsWith("D:1986")); } @Test @@ -93,7 +92,7 @@ public void dontAddDateItemToAnotherSubTypeFieldTest() { PdfCollectionItem item = new PdfCollectionItem(schema); item.addItem(fieldName, new PdfDate(PdfDate.decode(timeValueAsString))); - Assert.assertNull(item.getPdfObject().getAsString(new PdfName(fieldName))); + Assertions.assertNull(item.getPdfObject().getAsString(new PdfName(fieldName))); } @Test @@ -113,7 +112,7 @@ public void addNumberItemTest() { PdfCollectionItem item = new PdfCollectionItem(schema); item.addItem(fieldName, new PdfNumber(numberValue)); - Assert.assertEquals(numberValue, item.getPdfObject().getAsNumber(new PdfName(fieldName)).getValue(), 0.0001); + Assertions.assertEquals(numberValue, item.getPdfObject().getAsNumber(new PdfName(fieldName)).getValue(), 0.0001); } @Test @@ -133,7 +132,7 @@ public void dontAddNumberItemToAnotherSubTypeFieldTest() { PdfCollectionItem item = new PdfCollectionItem(schema); item.addItem(fieldName, new PdfNumber(numberValue)); - Assert.assertNull(item.getPdfObject().getAsString(new PdfName(fieldName))); + Assertions.assertNull(item.getPdfObject().getAsString(new PdfName(fieldName))); } @Test @@ -155,9 +154,9 @@ public void addPrefixTest() { item.addItem(fieldName, fieldValue); item.setPrefix(fieldName, fieldPrefix); - Assert.assertEquals(fieldValue, item.getPdfObject().getAsDictionary(new PdfName(fieldName)) + Assertions.assertEquals(fieldValue, item.getPdfObject().getAsDictionary(new PdfName(fieldName)) .getAsString(PdfName.D).getValue()); - Assert.assertEquals(fieldPrefix, item.getPdfObject().getAsDictionary(new PdfName(fieldName)) + Assertions.assertEquals(fieldPrefix, item.getPdfObject().getAsDictionary(new PdfName(fieldName)) .getAsString(PdfName.P).getValue()); } @@ -178,16 +177,16 @@ public void addPrefixToEmptyFieldTest() { // this line will throw an exception as setPrefix() method may be called // only if value was set previously - Exception e = Assert.assertThrows(PdfException.class, + Exception e = Assertions.assertThrows(PdfException.class, () -> item.setPrefix(fieldName, fieldPrefix) ); - Assert.assertEquals(KernelExceptionMessageConstant.YOU_MUST_SET_A_VALUE_BEFORE_ADDING_A_PREFIX, e.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.YOU_MUST_SET_A_VALUE_BEFORE_ADDING_A_PREFIX, e.getMessage()); } @Test public void isWrappedObjectMustBeIndirectTest() { PdfCollectionItem item = new PdfCollectionItem(new PdfCollectionSchema()); - Assert.assertFalse(item.isWrappedObjectMustBeIndirect()); + Assertions.assertFalse(item.isWrappedObjectMustBeIndirect()); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/collection/PdfCollectionSchemaTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/collection/PdfCollectionSchemaTest.java index fe642ae0dd..49da205427 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/collection/PdfCollectionSchemaTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/collection/PdfCollectionSchemaTest.java @@ -25,13 +25,12 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.kernel.pdf.PdfName; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfCollectionSchemaTest extends ExtendedITextTest { @Test public void fieldAddingTest() { @@ -45,11 +44,11 @@ public void fieldAddingTest() { schema.addField(fieldName, field); // should be the same instance - Assert.assertEquals(schema.getField(fieldName).getPdfObject(), pdfObject); + Assertions.assertEquals(schema.getField(fieldName).getPdfObject(), pdfObject); } @Test public void isWrappedObjectMustBeIndirectTest() { - Assert.assertFalse(new PdfCollectionSchema().isWrappedObjectMustBeIndirect()); + Assertions.assertFalse(new PdfCollectionSchema().isWrappedObjectMustBeIndirect()); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/collection/PdfCollectionSortTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/collection/PdfCollectionSortTest.java index 46c564dcd2..9789a95953 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/collection/PdfCollectionSortTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/collection/PdfCollectionSortTest.java @@ -26,13 +26,12 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.exceptions.KernelExceptionMessageConstant; import com.itextpdf.kernel.pdf.PdfName; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfCollectionSortTest extends ExtendedITextTest { @Test @@ -40,7 +39,7 @@ public void oneKeyConstructorTest() { final String key = "testKey"; PdfCollectionSort sort = new PdfCollectionSort(key); - Assert.assertEquals(key, sort.getPdfObject().getAsName(PdfName.S).getValue()); + Assertions.assertEquals(key, sort.getPdfObject().getAsName(PdfName.S).getValue()); } @Test @@ -49,7 +48,7 @@ public void multipleKeysConstructorTest() { PdfCollectionSort sort = new PdfCollectionSort(keys); for(int i = 0; i < keys.length; i++) { - Assert.assertEquals(keys[i], sort.getPdfObject().getAsArray(PdfName.S).getAsName(i).getValue()); + Assertions.assertEquals(keys[i], sort.getPdfObject().getAsArray(PdfName.S).getAsName(i).getValue()); } } @@ -59,11 +58,11 @@ public void sortOrderForOneKeyTest() { final boolean testAscending = true; PdfCollectionSort sort = new PdfCollectionSort(key); - Assert.assertNull(sort.getPdfObject().get(PdfName.A)); + Assertions.assertNull(sort.getPdfObject().get(PdfName.A)); sort.setSortOrder(testAscending); - Assert.assertTrue(sort.getPdfObject().getAsBool(PdfName.A)); + Assertions.assertTrue(sort.getPdfObject().getAsBool(PdfName.A)); } @Test @@ -75,10 +74,10 @@ public void incorrectSortOrderForOneKeyTest() { // this line will throw an exception as number of parameters of setSortOrder() // method should be exactly the same as number of keys of PdfCollectionSort // here we have one key but two params - Exception e = Assert.assertThrows(PdfException.class, + Exception e = Assertions.assertThrows(PdfException.class, () -> sort.setSortOrder(testAscendings) ); - Assert.assertEquals(KernelExceptionMessageConstant.YOU_NEED_A_SINGLE_BOOLEAN_FOR_THIS_COLLECTION_SORT_DICTIONARY, e.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.YOU_NEED_A_SINGLE_BOOLEAN_FOR_THIS_COLLECTION_SORT_DICTIONARY, e.getMessage()); } @Test @@ -91,7 +90,7 @@ public void sortOrderForMultipleKeysTest() { sort.setSortOrder(testAscendings); for(int i = 0; i < testAscendings.length; i++) { - Assert.assertEquals(testAscendings[i], sort.getPdfObject().getAsArray(PdfName.A).getAsBoolean(i).getValue()); + Assertions.assertEquals(testAscendings[i], sort.getPdfObject().getAsArray(PdfName.A).getAsBoolean(i).getValue()); } } @@ -105,10 +104,10 @@ public void singleSortOrderForMultipleKeysTest() { // this line will throw an exception as number of parameters of setSortOrder() // method should be exactly the same as number of keys of PdfCollectionSort // here we have three keys but one param - Exception e = Assert.assertThrows(PdfException.class, + Exception e = Assertions.assertThrows(PdfException.class, () -> sort.setSortOrder(testAscending) ); - Assert.assertEquals(KernelExceptionMessageConstant.YOU_HAVE_TO_DEFINE_A_BOOLEAN_ARRAY_FOR_THIS_COLLECTION_SORT_DICTIONARY, e.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.YOU_HAVE_TO_DEFINE_A_BOOLEAN_ARRAY_FOR_THIS_COLLECTION_SORT_DICTIONARY, e.getMessage()); } @Test @@ -122,15 +121,15 @@ public void incorrectMultipleSortOrderForMultipleKeysTest() { // this line will throw an exception as number of parameters of setSortOrder() // method should be exactly the same as number of keys of PdfCollectionSort // here we have three keys but two params - Exception e = Assert.assertThrows(PdfException.class, + Exception e = Assertions.assertThrows(PdfException.class, () -> sort.setSortOrder(testAscendings) ); - Assert.assertEquals(KernelExceptionMessageConstant.NUMBER_OF_BOOLEANS_IN_THE_ARRAY_DOES_NOT_CORRESPOND_WITH_THE_NUMBER_OF_FIELDS, e.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.NUMBER_OF_BOOLEANS_IN_THE_ARRAY_DOES_NOT_CORRESPOND_WITH_THE_NUMBER_OF_FIELDS, e.getMessage()); } @Test public void isWrappedObjectMustBeIndirectTest() { final String key = "testKey"; - Assert.assertFalse(new PdfCollectionSort(key).isWrappedObjectMustBeIndirect()); + Assertions.assertFalse(new PdfCollectionSort(key).isWrappedObjectMustBeIndirect()); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/colorspace/CreateShadingTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/colorspace/CreateShadingTest.java index fa7050d758..cea4b216fb 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/colorspace/CreateShadingTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/colorspace/CreateShadingTest.java @@ -29,42 +29,41 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfObject; import com.itextpdf.kernel.pdf.PdfReader; import com.itextpdf.kernel.pdf.PdfResources; -import com.itextpdf.kernel.pdf.PdfWriter; import com.itextpdf.kernel.pdf.StampingProperties; import com.itextpdf.kernel.pdf.canvas.PdfCanvas; import com.itextpdf.kernel.pdf.colorspace.PdfDeviceCs.Cmyk; import com.itextpdf.kernel.pdf.colorspace.PdfDeviceCs.Gray; -import com.itextpdf.kernel.pdf.colorspace.PdfShading.Axial; -import com.itextpdf.kernel.pdf.colorspace.PdfShading.Radial; -import com.itextpdf.kernel.pdf.colorspace.PdfShading.ShadingType; +import com.itextpdf.kernel.pdf.colorspace.shading.PdfAxialShading; +import com.itextpdf.kernel.pdf.colorspace.shading.AbstractPdfShading; +import com.itextpdf.kernel.pdf.colorspace.shading.PdfRadialShading; +import com.itextpdf.kernel.pdf.colorspace.shading.ShadingType; import com.itextpdf.kernel.pdf.function.AbstractPdfFunction; import com.itextpdf.kernel.pdf.function.PdfType2Function; import com.itextpdf.kernel.pdf.function.PdfType3Function; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.kernel.utils.CompareTool.CompareResult; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class CreateShadingTest extends ExtendedITextTest { public static final String destinationFolder = "./target/test/com/itextpdf/kernel/pdf/colorspace/CreateShadingTest/"; public static final String sourceFolder = "./src/test/resources/com/itextpdf/kernel/pdf/colorspace/CreateShadingTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(destinationFolder); } @@ -86,7 +85,7 @@ public void createAxialShadingWithStitchingFunctionTest() throws IOException { PdfType3Function stitchingFunction = createStitchingCmykShadingFunction(); - Axial axialShading = new Axial(new Cmyk(), shadingVector, stitchingFunction); + PdfAxialShading axialShading = new PdfAxialShading(new Cmyk(), shadingVector, stitchingFunction); pdfCanvas.paintShading(axialShading); pdfDocument.close(); @@ -107,9 +106,9 @@ public void modifyAxialShadingTest() throws IOException { PdfResources resources = pdfDocument.getPage(1).getResources(); for (PdfName resName : resources.getResourceNames()) { - PdfShading shading = resources.getShading(resName); + AbstractPdfShading shading = resources.getShading(resName); if (shading != null && shading.getShadingType() == ShadingType.AXIAL) { - Axial axialShading = (Axial) shading; + PdfAxialShading axialShading = (PdfAxialShading) shading; // "cut" shading and extend colors axialShading.setDomain(0.1f, 0.8f); @@ -138,7 +137,7 @@ public void createSimpleRadialShadingTest() throws IOException { int y1 = y0; int r1 = 50; - Radial radialShading = new Radial( + PdfRadialShading radialShading = new PdfRadialShading( new Gray(), x0, y0, r0, new float[] {0.9f}, x1, y1, r1, new float[] {0.2f}, @@ -170,7 +169,7 @@ public void createRadialShadingWithStitchingFunctionTest() throws IOException { PdfType3Function stitchingFunction = createStitchingCmykShadingFunction(); - Radial radialShading = new Radial(new Cmyk(), shadingVector, stitchingFunction); + PdfRadialShading radialShading = new PdfRadialShading(new Cmyk(), shadingVector, stitchingFunction); pdfCanvas.paintShading(radialShading); pdfDocument.close(); @@ -191,9 +190,9 @@ public void modifyRadialShadingTest() throws IOException { PdfResources resources = pdfDocument.getPage(1).getResources(); for (PdfName resName : resources.getResourceNames()) { - PdfShading shading = resources.getShading(resName); + AbstractPdfShading shading = resources.getShading(resName); if (shading != null && shading.getShadingType() == ShadingType.RADIAL) { - Radial radialShading = (Radial) shading; + PdfRadialShading radialShading = (PdfRadialShading) shading; // "cut" shading and extend colors radialShading.setDomain(0.1f, 0.8f); @@ -233,11 +232,11 @@ private static void assertShadingDictionaryResult(String outName, String cmpName PdfObject outShDictionary = outPdf.getPage(1).getResources().getResourceObject(PdfName.Shading, resName); PdfObject cmpShDictionary = cmpPdf.getPage(1).getResources().getResourceObject(PdfName.Shading, resName); - Assert.assertTrue(outShDictionary.isDictionary()); + Assertions.assertTrue(outShDictionary.isDictionary()); CompareResult compareResult = new CompareTool() .compareDictionariesStructure((PdfDictionary) outShDictionary, (PdfDictionary) cmpShDictionary); - Assert.assertNull(compareResult); + Assertions.assertNull(compareResult); outPdf.close(); cmpPdf.close(); diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/colorspace/PdfCieBasedCsUnitTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/colorspace/PdfCieBasedCsUnitTest.java index 5b90405db7..7217d1c867 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/colorspace/PdfCieBasedCsUnitTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/colorspace/PdfCieBasedCsUnitTest.java @@ -28,84 +28,83 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.colorspace.PdfCieBasedCs.CalRgb; import com.itextpdf.kernel.pdf.colorspace.PdfCieBasedCs.Lab; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfCieBasedCsUnitTest extends ExtendedITextTest { @Test public void whitePointOfCalGrayIsIncorrectEmptyTest() { - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> new CalGray(new float[] {})); - Assert.assertEquals(KernelExceptionMessageConstant.WHITE_POINT_IS_INCORRECTLY_SPECIFIED, + Assertions.assertEquals(KernelExceptionMessageConstant.WHITE_POINT_IS_INCORRECTLY_SPECIFIED, exception.getMessage()); } @Test public void whitePointOfCalRgbIsIncorrectEmptyTest() { - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> new CalRgb(new float[] {})); - Assert.assertEquals(KernelExceptionMessageConstant.WHITE_POINT_IS_INCORRECTLY_SPECIFIED, + Assertions.assertEquals(KernelExceptionMessageConstant.WHITE_POINT_IS_INCORRECTLY_SPECIFIED, exception.getMessage()); } @Test public void whitePointOfLabIsIncorrectEmptyTest() { - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> new Lab(new float[] {})); - Assert.assertEquals(KernelExceptionMessageConstant.WHITE_POINT_IS_INCORRECTLY_SPECIFIED, + Assertions.assertEquals(KernelExceptionMessageConstant.WHITE_POINT_IS_INCORRECTLY_SPECIFIED, exception.getMessage()); } @Test public void whitePointOfCalGrayIsIncorrectTooLittlePointsTest() { - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> new CalGray(new float[] {1, 2})); - Assert.assertEquals(KernelExceptionMessageConstant.WHITE_POINT_IS_INCORRECTLY_SPECIFIED, + Assertions.assertEquals(KernelExceptionMessageConstant.WHITE_POINT_IS_INCORRECTLY_SPECIFIED, exception.getMessage()); } @Test public void whitePointOfCalRgbIsIncorrectTooLittlePointsTest() { - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> new CalRgb(new float[] {1, 2})); - Assert.assertEquals(KernelExceptionMessageConstant.WHITE_POINT_IS_INCORRECTLY_SPECIFIED, + Assertions.assertEquals(KernelExceptionMessageConstant.WHITE_POINT_IS_INCORRECTLY_SPECIFIED, exception.getMessage()); } @Test public void whitePointOfLabIsIncorrectTooLittlePointsTest() { - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> new Lab(new float[] {1, 2})); - Assert.assertEquals(KernelExceptionMessageConstant.WHITE_POINT_IS_INCORRECTLY_SPECIFIED, + Assertions.assertEquals(KernelExceptionMessageConstant.WHITE_POINT_IS_INCORRECTLY_SPECIFIED, exception.getMessage()); } @Test public void whitePointOfCalGrayIsIncorrectTooMuchPointsTest() { - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> new CalGray(new float[] {1, 2, 3, 4})); - Assert.assertEquals(KernelExceptionMessageConstant.WHITE_POINT_IS_INCORRECTLY_SPECIFIED, + Assertions.assertEquals(KernelExceptionMessageConstant.WHITE_POINT_IS_INCORRECTLY_SPECIFIED, exception.getMessage()); } @Test public void whitePointOfCalRgbIsIncorrectTooMuchPointsTest() { - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> new CalRgb(new float[] {1, 2, 3, 4})); - Assert.assertEquals(KernelExceptionMessageConstant.WHITE_POINT_IS_INCORRECTLY_SPECIFIED, + Assertions.assertEquals(KernelExceptionMessageConstant.WHITE_POINT_IS_INCORRECTLY_SPECIFIED, exception.getMessage()); } @Test public void whitePointOfLabIsIncorrectTooMuchPointsTest() { - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> new Lab(new float[] {1, 2, 3, 4})); - Assert.assertEquals(KernelExceptionMessageConstant.WHITE_POINT_IS_INCORRECTLY_SPECIFIED, + Assertions.assertEquals(KernelExceptionMessageConstant.WHITE_POINT_IS_INCORRECTLY_SPECIFIED, exception.getMessage()); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/colorspace/PdfShadingDocumentTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/colorspace/PdfShadingDocumentTest.java new file mode 100644 index 0000000000..569186bee8 --- /dev/null +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/colorspace/PdfShadingDocumentTest.java @@ -0,0 +1,81 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.pdf.colorspace; + +import com.itextpdf.kernel.pdf.PdfDictionary; +import com.itextpdf.kernel.pdf.PdfDocument; +import com.itextpdf.kernel.pdf.PdfName; +import com.itextpdf.kernel.pdf.PdfPage; +import com.itextpdf.kernel.pdf.PdfWriter; +import com.itextpdf.kernel.pdf.canvas.PdfCanvas; +import com.itextpdf.kernel.pdf.colorspace.shading.PdfAxialShading; +import com.itextpdf.test.ExtendedITextTest; + +import java.io.IOException; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +@Tag("IntegrationTest") +public class PdfShadingDocumentTest extends ExtendedITextTest { + + public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/kernel/pdf/colorspace/PdfShadingDocumentTest/"; + + @BeforeAll + public static void beforeClass() { + createOrClearDestinationFolder(DESTINATION_FOLDER); + } + + @Test + public void axialDocumentTest() throws IOException { + String dest = DESTINATION_FOLDER + "axialDoc.pdf"; + + try (PdfDocument pdfDocument = new PdfDocument(new PdfWriter(dest))) { + PdfPage pdfPage = pdfDocument.addNewPage(); + + PdfCanvas canvas = new PdfCanvas(pdfPage); + + int x = 36; + int y = 400; + int side = 500; + + float[] green = new float[] {0, 255, 0}; + float[] blue = new float[] {0, 0, 255}; + + PdfAxialShading axial = new PdfAxialShading(new PdfDeviceCs.Rgb(), x, y, green, + x + side, y, blue); + PdfPattern.Shading shading = new PdfPattern.Shading(axial); + + canvas.setFillColorShading(shading); + canvas.moveTo(x, y); + canvas.lineTo(x + side, y); + canvas.lineTo(x + (side / 2), (float) (y + (side * Math.sin(Math.PI / 3)))); + canvas.closePathFillStroke(); + + PdfDictionary pdfObject = pdfDocument.getPage(1).getResources().getPdfObject(); + + Assertions.assertTrue(pdfObject.containsKey(PdfName.Pattern)); + } + } +} diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/colorspace/PdfShadingParameterizedTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/colorspace/PdfShadingParameterizedTest.java index e47ee11b93..96288d13e4 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/colorspace/PdfShadingParameterizedTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/colorspace/PdfShadingParameterizedTest.java @@ -27,29 +27,18 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.kernel.pdf.PdfName; import com.itextpdf.kernel.pdf.PdfNumber; +import com.itextpdf.kernel.pdf.colorspace.shading.AbstractPdfShading; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.util.Arrays; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; -@Category(UnitTest.class) -@RunWith(Parameterized.class) +@Tag("UnitTest") public class PdfShadingParameterizedTest extends ExtendedITextTest { - private final String shadingName; - private final int shadingType; - - public PdfShadingParameterizedTest(Object name, Object type) { - shadingName = (String) name; - shadingType = (int) type; - } - - @Parameterized.Parameters(name = "{0}") public static Iterable parameters() { return Arrays.asList(new Object[][] { {"FreeFormGouraudShadedTriangleMesh", 4}, @@ -60,14 +49,15 @@ public static Iterable parameters() { } - @Test - public void AllAboveType3FromDictionaryShouldFailTest() { + @ParameterizedTest(name = "{0}") + @MethodSource("parameters") + public void AllAboveType3FromDictionaryShouldFailTest(String shadingName, int shadingType) { PdfDictionary dict = new PdfDictionary(); dict.put(PdfName.ShadingType, new PdfNumber(shadingType)); dict.put(PdfName.ColorSpace, PdfName.DeviceRGB); - Exception e = Assert.assertThrows("Creating " + shadingName + " should throw PdfException.", PdfException.class, - () -> PdfShading.makeShading(dict)); + Exception e = Assertions.assertThrows(PdfException.class, () -> AbstractPdfShading.makeShading(dict), + "Creating " + shadingName + " should throw PdfException."); - Assert.assertEquals(KernelExceptionMessageConstant.UNEXPECTED_SHADING_TYPE, e.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.UNEXPECTED_SHADING_TYPE, e.getMessage()); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/colorspace/PdfShadingTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/colorspace/PdfShadingTest.java index 767125509e..7eb4051d70 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/colorspace/PdfShadingTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/colorspace/PdfShadingTest.java @@ -32,26 +32,26 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfObject; import com.itextpdf.kernel.pdf.PdfStream; import com.itextpdf.kernel.pdf.colorspace.PdfDeviceCs.Rgb; -import com.itextpdf.kernel.pdf.colorspace.PdfShading.Axial; -import com.itextpdf.kernel.pdf.colorspace.PdfShading.CoonsPatchMesh; -import com.itextpdf.kernel.pdf.colorspace.PdfShading.FreeFormGouraudShadedTriangleMesh; -import com.itextpdf.kernel.pdf.colorspace.PdfShading.FunctionBased; -import com.itextpdf.kernel.pdf.colorspace.PdfShading.LatticeFormGouraudShadedTriangleMesh; -import com.itextpdf.kernel.pdf.colorspace.PdfShading.Radial; -import com.itextpdf.kernel.pdf.colorspace.PdfShading.ShadingType; -import com.itextpdf.kernel.pdf.colorspace.PdfShading.TensorProductPatchMesh; +import com.itextpdf.kernel.pdf.colorspace.shading.PdfAxialShading; +import com.itextpdf.kernel.pdf.colorspace.shading.PdfCoonsPatchShading; +import com.itextpdf.kernel.pdf.colorspace.shading.PdfFreeFormGouraudShadedTriangleShading; +import com.itextpdf.kernel.pdf.colorspace.shading.PdfFunctionBasedShading; +import com.itextpdf.kernel.pdf.colorspace.shading.PdfLatticeFormGouraudShadedTriangleShading; +import com.itextpdf.kernel.pdf.colorspace.shading.AbstractPdfShading; +import com.itextpdf.kernel.pdf.colorspace.shading.PdfRadialShading; +import com.itextpdf.kernel.pdf.colorspace.shading.ShadingType; +import com.itextpdf.kernel.pdf.colorspace.shading.PdfTensorProductPatchShading; import com.itextpdf.kernel.pdf.colorspace.PdfSpecialCs.Pattern; import com.itextpdf.kernel.pdf.function.IPdfFunction; import com.itextpdf.kernel.pdf.function.PdfType4Function; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.nio.charset.StandardCharsets; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfShadingTest extends ExtendedITextTest { @Test @@ -59,10 +59,10 @@ public void axialShadingConstructorNullExtendArgumentTest() { boolean[] extendArray = null; Rgb color = new Rgb(); - Exception e = Assert.assertThrows(IllegalArgumentException.class, - () -> new Axial(color, 0f, 0f, new float[] {0f, 0f, 0f}, 0.5f, 0.5f, new float[] {0.5f, 0.5f, 0.5f}, + Exception e = Assertions.assertThrows(IllegalArgumentException.class, + () -> new PdfAxialShading(color, 0f, 0f, new float[] {0f, 0f, 0f}, 0.5f, 0.5f, new float[] {0.5f, 0.5f, 0.5f}, extendArray)); - Assert.assertEquals("extend", e.getMessage()); + Assertions.assertEquals("extend", e.getMessage()); } @Test @@ -70,10 +70,10 @@ public void axialShadingConstructorInvalidExtendArgumentTest() { boolean[] extendArray = new boolean[] {true}; Rgb color = new Rgb(); - Exception e = Assert.assertThrows(IllegalArgumentException.class, - () -> new Axial(color, 0f, 0f, new float[] {0f, 0f, 0f}, 0.5f, 0.5f, new float[] {0.5f, 0.5f, 0.5f}, + Exception e = Assertions.assertThrows(IllegalArgumentException.class, + () -> new PdfAxialShading(color, 0f, 0f, new float[] {0f, 0f, 0f}, 0.5f, 0.5f, new float[] {0.5f, 0.5f, 0.5f}, extendArray)); - Assert.assertEquals("extend", e.getMessage()); + Assertions.assertEquals("extend", e.getMessage()); } @Test @@ -81,10 +81,10 @@ public void radialShadingConstructorNullExtendArgumentTest() { boolean[] extendArray = null; Rgb color = new Rgb(); - Exception e = Assert.assertThrows(IllegalArgumentException.class, - () -> new Radial(color, 0f, 0f, 0f, new float[] {0f, 0f, 0f}, 0.5f, 0.5f, 10f, + Exception e = Assertions.assertThrows(IllegalArgumentException.class, + () -> new PdfRadialShading(color, 0f, 0f, 0f, new float[] {0f, 0f, 0f}, 0.5f, 0.5f, 10f, new float[] {0.5f, 0.5f, 0.5f}, extendArray)); - Assert.assertEquals("extend", e.getMessage()); + Assertions.assertEquals("extend", e.getMessage()); } @Test @@ -92,10 +92,10 @@ public void radialShadingConstructorInvalidExtendArgumentTest() { boolean[] extendArray = new boolean[] {true, false, false}; Rgb color = new Rgb(); - Exception e = Assert.assertThrows(IllegalArgumentException.class, - () -> new Radial(color, 0f, 0f, 0f, new float[] {0f, 0f, 0f}, 0.5f, 0.5f, 10f, + Exception e = Assertions.assertThrows(IllegalArgumentException.class, + () -> new PdfRadialShading(color, 0f, 0f, 0f, new float[] {0f, 0f, 0f}, 0.5f, 0.5f, 10f, new float[] {0.5f, 0.5f, 0.5f}, extendArray)); - Assert.assertEquals("extend", e.getMessage()); + Assertions.assertEquals("extend", e.getMessage()); } @Test @@ -107,12 +107,12 @@ public void axialShadingGettersTest() { PdfDictionary axialShadingDictionary = initShadingDictionary(coordsArray, domainArray, extendArray, ShadingType.AXIAL); - Axial axial = new Axial(axialShadingDictionary); - Assert.assertArrayEquals(coordsArray, axial.getCoords().toFloatArray(), 0f); - Assert.assertArrayEquals(domainArray, axial.getDomain().toFloatArray(), 0f); - Assert.assertArrayEquals(extendArray, axial.getExtend().toBooleanArray()); - Assert.assertEquals(ShadingType.AXIAL, axial.getShadingType()); - Assert.assertEquals(PdfName.DeviceRGB, axial.getColorSpace()); + PdfAxialShading axial = new PdfAxialShading(axialShadingDictionary); + Assertions.assertArrayEquals(coordsArray, axial.getCoords().toFloatArray(), 0f); + Assertions.assertArrayEquals(domainArray, axial.getDomain().toFloatArray(), 0f); + Assertions.assertArrayEquals(extendArray, axial.getExtend().toBooleanArray()); + Assertions.assertEquals(ShadingType.AXIAL, axial.getShadingType()); + Assertions.assertEquals(PdfName.DeviceRGB, axial.getColorSpace()); } @Test @@ -123,8 +123,8 @@ public void setFunctionsTest() { PdfDictionary axialShadingDictionary = initShadingDictionary(coordsArray, domainArray, extendArray, ShadingType.AXIAL); - Axial axial = new Axial(axialShadingDictionary); - Assert.assertTrue(axial.getFunction() instanceof PdfDictionary); + PdfAxialShading axial = new PdfAxialShading(axialShadingDictionary); + Assertions.assertTrue(axial.getFunction() instanceof PdfDictionary); byte[] ps = "{2 copy sin abs sin abs 3 index 10 mul sin 1 sub abs}".getBytes(StandardCharsets.ISO_8859_1); float[] domain = new float[] {0, 1000, 0, 1000}; @@ -133,9 +133,9 @@ public void setFunctionsTest() { axial.setFunction(functions); final PdfObject funcObj = axial.getFunction(); - Assert.assertTrue(funcObj instanceof PdfArray); - Assert.assertEquals(1, ((PdfArray) funcObj).size()); - Assert.assertEquals(functions[0].getAsPdfObject(), ((PdfArray) funcObj).get(0)); + Assertions.assertTrue(funcObj instanceof PdfArray); + Assertions.assertEquals(1, ((PdfArray) funcObj).size()); + Assertions.assertEquals(functions[0].getAsPdfObject(), ((PdfArray) funcObj).get(0)); } @Test @@ -147,12 +147,12 @@ public void axialShadingViaPdfObjectTest() { PdfDictionary axialShadingDictionary = initShadingDictionary(coordsArray, domainArray, extendArray, ShadingType.AXIAL); - Axial axial = (Axial) PdfShading.makeShading(axialShadingDictionary); + PdfAxialShading axial = (PdfAxialShading) AbstractPdfShading.makeShading(axialShadingDictionary); - Assert.assertArrayEquals(coordsArray, axial.getCoords().toFloatArray(), 0f); - Assert.assertArrayEquals(domainArray, axial.getDomain().toFloatArray(), 0f); - Assert.assertArrayEquals(extendArray, axial.getExtend().toBooleanArray()); - Assert.assertEquals(ShadingType.AXIAL, axial.getShadingType()); + Assertions.assertArrayEquals(coordsArray, axial.getCoords().toFloatArray(), 0f); + Assertions.assertArrayEquals(domainArray, axial.getDomain().toFloatArray(), 0f); + Assertions.assertArrayEquals(extendArray, axial.getExtend().toBooleanArray()); + Assertions.assertEquals(ShadingType.AXIAL, axial.getShadingType()); } @Test @@ -163,11 +163,11 @@ public void axialShadingGettersWithDomainExtendDefaultValuesTest() { PdfDictionary axialShadingDictionary = initShadingDictionary(coordsArray, null, null, ShadingType.AXIAL); - Axial axial = new Axial(axialShadingDictionary); - Assert.assertArrayEquals(coordsArray, axial.getCoords().toFloatArray(), 0f); - Assert.assertArrayEquals(defaultDomainArray, axial.getDomain().toFloatArray(), 0f); - Assert.assertArrayEquals(defaultExtendArray, axial.getExtend().toBooleanArray()); - Assert.assertEquals(ShadingType.AXIAL, axial.getShadingType()); + PdfAxialShading axial = new PdfAxialShading(axialShadingDictionary); + Assertions.assertArrayEquals(coordsArray, axial.getCoords().toFloatArray(), 0f); + Assertions.assertArrayEquals(defaultDomainArray, axial.getDomain().toFloatArray(), 0f); + Assertions.assertArrayEquals(defaultExtendArray, axial.getExtend().toBooleanArray()); + Assertions.assertEquals(ShadingType.AXIAL, axial.getShadingType()); } @Test @@ -179,11 +179,11 @@ public void radialShadingGettersTest() { PdfDictionary radialShadingDictionary = initShadingDictionary(coordsArray, domainArray, extendArray, ShadingType.RADIAL); - Radial radial = new Radial(radialShadingDictionary); - Assert.assertArrayEquals(coordsArray, radial.getCoords().toFloatArray(), 0f); - Assert.assertArrayEquals(domainArray, radial.getDomain().toFloatArray(), 0f); - Assert.assertArrayEquals(extendArray, radial.getExtend().toBooleanArray()); - Assert.assertEquals(ShadingType.RADIAL, radial.getShadingType()); + PdfRadialShading radial = new PdfRadialShading(radialShadingDictionary); + Assertions.assertArrayEquals(coordsArray, radial.getCoords().toFloatArray(), 0f); + Assertions.assertArrayEquals(domainArray, radial.getDomain().toFloatArray(), 0f); + Assertions.assertArrayEquals(extendArray, radial.getExtend().toBooleanArray()); + Assertions.assertEquals(ShadingType.RADIAL, radial.getShadingType()); } @Test @@ -195,11 +195,11 @@ public void radialShadingViaMakeShadingTest() { PdfDictionary radialShadingDictionary = initShadingDictionary(coordsArray, domainArray, extendArray, ShadingType.RADIAL); - Radial radial = (Radial) PdfShading.makeShading(radialShadingDictionary); - Assert.assertArrayEquals(coordsArray, radial.getCoords().toFloatArray(), 0f); - Assert.assertArrayEquals(domainArray, radial.getDomain().toFloatArray(), 0f); - Assert.assertArrayEquals(extendArray, radial.getExtend().toBooleanArray()); - Assert.assertEquals(ShadingType.RADIAL, radial.getShadingType()); + PdfRadialShading radial = (PdfRadialShading) AbstractPdfShading.makeShading(radialShadingDictionary); + Assertions.assertArrayEquals(coordsArray, radial.getCoords().toFloatArray(), 0f); + Assertions.assertArrayEquals(domainArray, radial.getDomain().toFloatArray(), 0f); + Assertions.assertArrayEquals(extendArray, radial.getExtend().toBooleanArray()); + Assertions.assertEquals(ShadingType.RADIAL, radial.getShadingType()); } @Test @@ -210,27 +210,27 @@ public void radialShadingGettersWithDomainExtendDefaultValuesTest() { PdfDictionary radialShadingDictionary = initShadingDictionary(coordsArray, null, null, ShadingType.RADIAL); - Radial radial = new Radial(radialShadingDictionary); - Assert.assertArrayEquals(coordsArray, radial.getCoords().toFloatArray(), 0f); - Assert.assertArrayEquals(defaultDomainArray, radial.getDomain().toFloatArray(), 0f); - Assert.assertArrayEquals(defaultExtendArray, radial.getExtend().toBooleanArray()); - Assert.assertEquals(ShadingType.RADIAL, radial.getShadingType()); + PdfRadialShading radial = new PdfRadialShading(radialShadingDictionary); + Assertions.assertArrayEquals(coordsArray, radial.getCoords().toFloatArray(), 0f); + Assertions.assertArrayEquals(defaultDomainArray, radial.getDomain().toFloatArray(), 0f); + Assertions.assertArrayEquals(defaultExtendArray, radial.getExtend().toBooleanArray()); + Assertions.assertEquals(ShadingType.RADIAL, radial.getShadingType()); } @Test public void makeShadingShouldFailOnMissingShadeType() { PdfDictionary shade = new PdfDictionary(); shade.put(PdfName.ColorSpace, new PdfArray()); - Exception error = Assert.assertThrows(PdfException.class, () -> PdfShading.makeShading(shade)); - Assert.assertEquals(KernelExceptionMessageConstant.SHADING_TYPE_NOT_FOUND, error.getMessage()); + Exception error = Assertions.assertThrows(PdfException.class, () -> AbstractPdfShading.makeShading(shade)); + Assertions.assertEquals(KernelExceptionMessageConstant.SHADING_TYPE_NOT_FOUND, error.getMessage()); } @Test public void makeShadingShouldFailOnMissingColorSpace() { PdfDictionary shade = new PdfDictionary(); shade.put(PdfName.ShadingType, new PdfArray()); - Exception error = Assert.assertThrows(PdfException.class, () -> PdfShading.makeShading(shade)); - Assert.assertEquals(KernelExceptionMessageConstant.COLOR_SPACE_NOT_FOUND, error.getMessage()); + Exception error = Assertions.assertThrows(PdfException.class, () -> AbstractPdfShading.makeShading(shade)); + Assertions.assertEquals(KernelExceptionMessageConstant.COLOR_SPACE_NOT_FOUND, error.getMessage()); } @Test @@ -240,10 +240,10 @@ public void usingPatternColorSpaceThrowsException() { new float[] {0, 1, 0, 1, 0, 1}, ps); Pattern colorSpace = new Pattern(); - Exception ex = Assert.assertThrows(IllegalArgumentException.class, - () -> new FunctionBased(colorSpace, function)); + Exception ex = Assertions.assertThrows(IllegalArgumentException.class, + () -> new PdfFunctionBasedShading(colorSpace, function)); - Assert.assertEquals("colorSpace", ex.getMessage()); + Assertions.assertEquals("colorSpace", ex.getMessage()); } @Test @@ -254,19 +254,19 @@ public void makeShadingFunctionBased1Test() { IPdfFunction function = new PdfType4Function(domain, range, ps); - FunctionBased shade = new FunctionBased(new PdfDeviceCs.Rgb(), function); + PdfFunctionBasedShading shade = new PdfFunctionBasedShading(new PdfDeviceCs.Rgb(), function); PdfDictionary object = shade.getPdfObject(); - Assert.assertEquals(1, object.getAsInt(PdfName.ShadingType).intValue()); - Assert.assertEquals(PdfName.DeviceRGB, object.getAsName(PdfName.ColorSpace)); + Assertions.assertEquals(1, object.getAsInt(PdfName.ShadingType).intValue()); + Assertions.assertEquals(PdfName.DeviceRGB, object.getAsName(PdfName.ColorSpace)); PdfStream functionStream = object.getAsStream(PdfName.Function); PdfArray functionDomain = functionStream.getAsArray(PdfName.Domain); - Assert.assertArrayEquals(domain, functionDomain.toFloatArray(), 0.0f); + Assertions.assertArrayEquals(domain, functionDomain.toFloatArray(), 0.0f); PdfArray functionRange = functionStream.getAsArray(PdfName.Range); - Assert.assertArrayEquals(range, functionRange.toFloatArray(), 0.0f); - Assert.assertEquals(4, functionStream.getAsInt(PdfName.FunctionType).intValue()); + Assertions.assertArrayEquals(range, functionRange.toFloatArray(), 0.0f); + Assertions.assertEquals(4, functionStream.getAsInt(PdfName.FunctionType).intValue()); } @Test @@ -287,22 +287,22 @@ public void makeShadingFunctionBased2Test() { shadingDict.put(PdfName.Function, stream); - PdfShading shade = PdfShading.makeShading(shadingDict); + AbstractPdfShading shade = AbstractPdfShading.makeShading(shadingDict); PdfDictionary object = shade.getPdfObject(); - Assert.assertEquals(1, object.getAsInt(PdfName.ShadingType).intValue()); - Assert.assertEquals(PdfName.DeviceRGB, object.getAsName(PdfName.ColorSpace)); + Assertions.assertEquals(1, object.getAsInt(PdfName.ShadingType).intValue()); + Assertions.assertEquals(PdfName.DeviceRGB, object.getAsName(PdfName.ColorSpace)); PdfStream functionStream = object.getAsStream(PdfName.Function); PdfArray functionDomain = functionStream.getAsArray(PdfName.Domain); - Assert.assertArrayEquals(domain.toDoubleArray(), functionDomain.toDoubleArray(), 0.0); + Assertions.assertArrayEquals(domain.toDoubleArray(), functionDomain.toDoubleArray(), 0.0); PdfArray functionRange = functionStream.getAsArray(PdfName.Range); - Assert.assertArrayEquals(range.toDoubleArray(), functionRange.toDoubleArray(), 0.0); + Assertions.assertArrayEquals(range.toDoubleArray(), functionRange.toDoubleArray(), 0.0); - Assert.assertEquals(4, functionStream.getAsInt(PdfName.FunctionType).intValue()); + Assertions.assertEquals(4, functionStream.getAsInt(PdfName.FunctionType).intValue()); - Assert.assertEquals(functionStream, shade.getFunction()); + Assertions.assertEquals(functionStream, shade.getFunction()); } @Test @@ -311,8 +311,8 @@ public void makeShadingWithInvalidShadeType() { PdfDictionary radialShadingDictionary = initShadingDictionary(coordsArray, null, null, 21); - Exception e = Assert.assertThrows(PdfException.class, () -> PdfShading.makeShading(radialShadingDictionary)); - Assert.assertEquals(KernelExceptionMessageConstant.UNEXPECTED_SHADING_TYPE, e.getMessage()); + Exception e = Assertions.assertThrows(PdfException.class, () -> AbstractPdfShading.makeShading(radialShadingDictionary)); + Assertions.assertEquals(KernelExceptionMessageConstant.UNEXPECTED_SHADING_TYPE, e.getMessage()); } @Test @@ -336,14 +336,14 @@ public void makeFreeFormGouraudShadedTriangleMeshTest() { new PdfArray(new float[] {x, x + side, y, y + (int) (side * Math.sin(Math.PI / 3)), 0, 1, 0, 1, 0, 1})); stream.put(PdfName.Matrix, new PdfArray(new float[] {1, 0, 0, -1, 0, 0})); - FreeFormGouraudShadedTriangleMesh shade = (FreeFormGouraudShadedTriangleMesh) PdfShading.makeShading(stream); + PdfFreeFormGouraudShadedTriangleShading shade = (PdfFreeFormGouraudShadedTriangleShading) AbstractPdfShading.makeShading(stream); - Assert.assertEquals(PdfName.DeviceRGB, shade.getColorSpace()); - Assert.assertEquals(4, shade.getShadingType()); - Assert.assertEquals(32, shade.getBitsPerCoordinate()); - Assert.assertEquals(8, shade.getBitsPerComponent()); - Assert.assertEquals(8, shade.getBitsPerFlag()); - Assert.assertEquals(y, shade.getDecode().getAsNumber(2).intValue()); + Assertions.assertEquals(PdfName.DeviceRGB, shade.getColorSpace()); + Assertions.assertEquals(4, shade.getShadingType()); + Assertions.assertEquals(32, shade.getBitsPerCoordinate()); + Assertions.assertEquals(8, shade.getBitsPerComponent()); + Assertions.assertEquals(8, shade.getBitsPerFlag()); + Assertions.assertEquals(y, shade.getDecode().getAsNumber(2).intValue()); } @Test @@ -366,15 +366,15 @@ public void makeLatticeFormGouraudShadedTriangleMeshTest() { new PdfArray(new float[] {x, x + side, y, y + (int) (side * Math.sin(Math.PI / 3)), 0, 1, 0, 1, 0, 1})); stream.put(PdfName.Matrix, new PdfArray(new float[] {1, 0, 0, -1, 0, 0})); - LatticeFormGouraudShadedTriangleMesh shade = (LatticeFormGouraudShadedTriangleMesh) PdfShading.makeShading( + PdfLatticeFormGouraudShadedTriangleShading shade = (PdfLatticeFormGouraudShadedTriangleShading) AbstractPdfShading.makeShading( stream); - Assert.assertEquals(PdfName.DeviceRGB, shade.getColorSpace()); - Assert.assertEquals(5, shade.getShadingType()); - Assert.assertEquals(32, shade.getBitsPerCoordinate()); - Assert.assertEquals(8, shade.getBitsPerComponent()); - Assert.assertEquals(2, shade.getVerticesPerRow()); - Assert.assertEquals(y, shade.getDecode().getAsNumber(2).intValue()); + Assertions.assertEquals(PdfName.DeviceRGB, shade.getColorSpace()); + Assertions.assertEquals(5, shade.getShadingType()); + Assertions.assertEquals(32, shade.getBitsPerCoordinate()); + Assertions.assertEquals(8, shade.getBitsPerComponent()); + Assertions.assertEquals(2, shade.getVerticesPerRow()); + Assertions.assertEquals(y, shade.getDecode().getAsNumber(2).intValue()); } @Test @@ -428,14 +428,14 @@ public void coonsPatchMeshGradientTest() { new PdfArray(new float[] {x, x + side, y, y + (int) (side * Math.sin(Math.PI / 3)), 0, 1, 0, 1, 0, 1})); stream.put(PdfName.Matrix, new PdfArray(new float[] {1, 0, 0, -1, 0, 0})); - CoonsPatchMesh shade = (CoonsPatchMesh) PdfShading.makeShading(stream); + PdfCoonsPatchShading shade = (PdfCoonsPatchShading) AbstractPdfShading.makeShading(stream); - Assert.assertEquals(PdfName.DeviceRGB, shade.getColorSpace()); - Assert.assertEquals(6, shade.getShadingType()); - Assert.assertEquals(32, shade.getBitsPerCoordinate()); - Assert.assertEquals(8, shade.getBitsPerComponent()); - Assert.assertEquals(8, shade.getBitsPerFlag()); - Assert.assertEquals(y, shade.getDecode().getAsNumber(2).intValue()); + Assertions.assertEquals(PdfName.DeviceRGB, shade.getColorSpace()); + Assertions.assertEquals(6, shade.getShadingType()); + Assertions.assertEquals(32, shade.getBitsPerCoordinate()); + Assertions.assertEquals(8, shade.getBitsPerComponent()); + Assertions.assertEquals(8, shade.getBitsPerFlag()); + Assertions.assertEquals(y, shade.getDecode().getAsNumber(2).intValue()); } @Test @@ -498,14 +498,14 @@ public void TensorProductPatchMeshShadingTest() { new PdfArray(new float[] {x, x + side, y, y + (int) (side * Math.sin(Math.PI / 3)), 0, 1, 0, 1, 0, 1})); stream.put(PdfName.Matrix, new PdfArray(new float[] {-1, 0, 0, 1, 0, 0})); - TensorProductPatchMesh shade = (TensorProductPatchMesh) PdfShading.makeShading(stream); + PdfTensorProductPatchShading shade = (PdfTensorProductPatchShading) AbstractPdfShading.makeShading(stream); - Assert.assertEquals(PdfName.DeviceRGB, shade.getColorSpace()); - Assert.assertEquals(7, shade.getShadingType()); - Assert.assertEquals(32, shade.getBitsPerCoordinate()); - Assert.assertEquals(8, shade.getBitsPerComponent()); - Assert.assertEquals(8, shade.getBitsPerFlag()); - Assert.assertEquals(y, shade.getDecode().getAsNumber(2).intValue()); + Assertions.assertEquals(PdfName.DeviceRGB, shade.getColorSpace()); + Assertions.assertEquals(7, shade.getShadingType()); + Assertions.assertEquals(32, shade.getBitsPerCoordinate()); + Assertions.assertEquals(8, shade.getBitsPerComponent()); + Assertions.assertEquals(8, shade.getBitsPerFlag()); + Assertions.assertEquals(y, shade.getDecode().getAsNumber(2).intValue()); } @Test @@ -513,11 +513,141 @@ public void invalidShadingTypeShouldFailTest() { PdfDictionary dict = new PdfDictionary(); dict.put(PdfName.ShadingType, new PdfNumber(8)); dict.put(PdfName.ColorSpace, PdfName.DeviceRGB); - Exception e = Assert.assertThrows(PdfException.class, () -> PdfShading.makeShading(dict)); + Exception e = Assertions.assertThrows(PdfException.class, () -> AbstractPdfShading.makeShading(dict)); - Assert.assertEquals(KernelExceptionMessageConstant.UNEXPECTED_SHADING_TYPE, e.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.UNEXPECTED_SHADING_TYPE, e.getMessage()); } + @Test + public void basicCoonsPathMeshTest() { + int x = 36; + int y = 400; + int side = 500; + PdfArray decode = new PdfArray( + new float[] {x, x + side, y, y + (int) (side * Math.sin(Math.PI / 3)), 0, 1, 0, 1, 0, 1}); + PdfColorSpace cs = PdfColorSpace.makeColorSpace(PdfName.DeviceRGB); + PdfCoonsPatchShading coonsPatchMesh = new PdfCoonsPatchShading(cs, 32, 16, 8, decode); + + Assertions.assertEquals(PdfName.DeviceRGB, coonsPatchMesh.getColorSpace()); + Assertions.assertEquals(6, coonsPatchMesh.getShadingType()); + Assertions.assertEquals(32, coonsPatchMesh.getBitsPerCoordinate()); + Assertions.assertEquals(16, coonsPatchMesh.getBitsPerComponent()); + Assertions.assertEquals(8, coonsPatchMesh.getBitsPerFlag()); + Assertions.assertEquals(y, coonsPatchMesh.getDecode().getAsNumber(2).intValue()); + } + + @Test + public void basicFreeFormGouraudShadedTriangleMeshTest() { + int x = 36; + int y = 400; + int side = 500; + PdfArray pdfArray = new PdfArray( + new float[] {x, x + side, y, y + (int) (side * Math.sin(Math.PI / 3)), 0, 1, 0, 1, 0, 1}); + PdfColorSpace cs = PdfColorSpace.makeColorSpace(PdfName.DeviceRGB); + PdfFreeFormGouraudShadedTriangleShading shade = new PdfFreeFormGouraudShadedTriangleShading(cs, 32, 8, 8, pdfArray); + + Assertions.assertEquals(PdfName.DeviceRGB, shade.getColorSpace()); + Assertions.assertEquals(4, shade.getShadingType()); + Assertions.assertEquals(32, shade.getBitsPerCoordinate()); + Assertions.assertEquals(8, shade.getBitsPerComponent()); + Assertions.assertEquals(8, shade.getBitsPerFlag()); + Assertions.assertEquals(y, shade.getDecode().getAsNumber(2).intValue()); + } + + @Test + public void basicTensorProductPatchMeshTest() { + int x = 36; + int y = 400; + int side = 500; + PdfArray pdfArray = new PdfArray( + new float[] {x, x + side, y, y + (int) (side * Math.sin(Math.PI / 3)), 0, 1, 0, 1, 0, 1}); + PdfColorSpace cs = PdfColorSpace.makeColorSpace(PdfName.DeviceRGB); + PdfTensorProductPatchShading shade = new PdfTensorProductPatchShading(cs, 32, 8, 8, pdfArray); + + Assertions.assertEquals(PdfName.DeviceRGB, shade.getColorSpace()); + Assertions.assertEquals(7, shade.getShadingType()); + Assertions.assertEquals(32, shade.getBitsPerCoordinate()); + Assertions.assertEquals(8, shade.getBitsPerComponent()); + Assertions.assertEquals(8, shade.getBitsPerFlag()); + Assertions.assertEquals(y, shade.getDecode().getAsNumber(2).intValue()); + } + + @Test + public void basicLatticeFormGouraudShadedTriangleMeshTest() { + int x = 36; + int y = 400; + int side = 500; + PdfArray pdfArray = new PdfArray( + new float[] {x, x + side, y, y + (int) (side * Math.sin(Math.PI / 3)), 0, 1, 0, 1, 0, 1}); + PdfColorSpace cs = PdfColorSpace.makeColorSpace(PdfName.DeviceRGB); + PdfLatticeFormGouraudShadedTriangleShading shade = new PdfLatticeFormGouraudShadedTriangleShading(cs, 32, 8, 2, pdfArray); + + Assertions.assertEquals(PdfName.DeviceRGB, shade.getColorSpace()); + Assertions.assertEquals(5, shade.getShadingType()); + Assertions.assertEquals(32, shade.getBitsPerCoordinate()); + Assertions.assertEquals(8, shade.getBitsPerComponent()); + Assertions.assertEquals(2, shade.getVerticesPerRow()); + Assertions.assertEquals(y, shade.getDecode().getAsNumber(2).intValue()); + } + + @Test + public void basicFunctionBasedShadingTest() { + byte[] ps = "{2 copy sin abs sin abs 3 index 10 mul sin 1 sub abs}".getBytes(StandardCharsets.ISO_8859_1); + float[] domain = new float[] {0, 1000, 0, 1000}; + float[] range = new float[] {0, 1, 0, 1, 0, 1}; + float[] transformMatrix = new float[] {1, 0, 0, 1, 0, 0}; + + IPdfFunction function = new PdfType4Function(domain, + range, ps); + PdfColorSpace cs = PdfColorSpace.makeColorSpace(PdfName.DeviceRGB); + PdfFunctionBasedShading shade = new PdfFunctionBasedShading(cs, function); + shade.setDomain(1, 4, 1, 4); + shade.setMatrix(transformMatrix); + + Assertions.assertEquals(PdfName.DeviceRGB, shade.getColorSpace()); + Assertions.assertEquals(1, shade.getShadingType()); + Assertions.assertArrayEquals(transformMatrix, shade.getMatrix().toFloatArray()); + Assertions.assertArrayEquals(new float[]{1, 4, 1, 4}, shade.getDomain().toFloatArray()); + } + + @Test + public void changeFreeFormGouraudShadedTriangleMeshTest() { + int x = 36; + int y = 400; + int side = 500; + float[] decode = + new float[] {x, x + side, y, y + (int) (side * Math.sin(Math.PI / 3)), 0, 1, 0, 1, 0, 1}; + PdfColorSpace cs = PdfColorSpace.makeColorSpace(PdfName.DeviceRGB); + PdfFreeFormGouraudShadedTriangleShading shade = new PdfFreeFormGouraudShadedTriangleShading(cs, 16, 8, 8, new PdfArray()); + + shade.setDecode(decode); + shade.setBitsPerComponent(16); + shade.setBitsPerCoordinate(32); + shade.setBitsPerFlag(4); + + Assertions.assertEquals(PdfName.DeviceRGB, shade.getColorSpace()); + Assertions.assertEquals(4, shade.getShadingType()); + Assertions.assertEquals(32, shade.getBitsPerCoordinate()); + Assertions.assertEquals(16, shade.getBitsPerComponent()); + Assertions.assertEquals(4, shade.getBitsPerFlag()); + Assertions.assertEquals(y, shade.getDecode().getAsNumber(2).intValue()); + } + + @Test + public void setDecodeCoonsPatchMeshTest() { + int x = 36; + int y = 400; + int side = 500; + PdfArray decode = new PdfArray( + new float[] {x, x + side, y, y + (int) (side * Math.sin(Math.PI / 3)), 0, 1, 0, 1, 0, 1}); + PdfColorSpace cs = PdfColorSpace.makeColorSpace(PdfName.DeviceRGB); + PdfCoonsPatchShading coonsPatchMesh = new PdfCoonsPatchShading(cs, 32, 16, 16, new PdfArray()); + coonsPatchMesh.setDecode(decode); + + Assertions.assertEquals(y, coonsPatchMesh.getDecode().getAsNumber(2).intValue()); + } + + private static PdfDictionary initShadingDictionary(float[] coordsArray, float[] domainArray, boolean[] extendArray, int radial2) { PdfDictionary axialShadingDictionary = new PdfDictionary(); diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/copy/PdfAnnotationCopyingTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/copy/PdfAnnotationCopyingTest.java index e95fac9ee5..47872907c9 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/copy/PdfAnnotationCopyingTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/copy/PdfAnnotationCopyingTest.java @@ -42,36 +42,35 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -@Category(IntegrationTest.class) +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; + +@Tag("IntegrationTest") public class PdfAnnotationCopyingTest extends ExtendedITextTest { public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/kernel/pdf/PdfAnnotationCopyingTest/"; public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/kernel/pdf/PdfAnnotationCopyingTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(DESTINATION_FOLDER); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(DESTINATION_FOLDER); } @Test - @Ignore("Unignore when DEVSIX-3585 would be implemented") + @Disabled("Unignore when DEVSIX-3585 would be implemented") public void testCopyingPageWithAnnotationContainingPopupKey() throws IOException { String inFilePath = SOURCE_FOLDER + "annotation-with-popup.pdf"; String outFilePath = DESTINATION_FOLDER + "copy-annotation-with-popup.pdf"; @@ -90,32 +89,31 @@ public void testCopyingPageWithAnnotationContainingPopupKey() throws IOException outDocument = new PdfDocument(new PdfReader(outFilePath)); for (int pageNum = 1; pageNum <= outDocument.getNumberOfPages(); pageNum++) { PdfPage page = outDocument.getPage(pageNum); - Assert.assertEquals(2, page.getAnnotsSize()); - Assert.assertEquals(2, page.getAnnotations().size()); + Assertions.assertEquals(2, page.getAnnotsSize()); + Assertions.assertEquals(2, page.getAnnotations().size()); boolean foundMarkupAnnotation = false; for (PdfAnnotation annotation : page.getAnnotations()) { PdfDictionary annotationPageDict = annotation.getPageObject(); if (annotationPageDict != null) { - Assert.assertSame(page.getPdfObject(), annotationPageDict); + Assertions.assertSame(page.getPdfObject(), annotationPageDict); } if (annotation instanceof PdfMarkupAnnotation) { foundMarkupAnnotation = true; PdfPopupAnnotation popup = ((PdfMarkupAnnotation) annotation).getPopup(); - Assert.assertTrue(MessageFormatUtil.format( - "Popup reference must point to annotation present on the same page (# {0})", pageNum), - page.containsAnnotation(popup)); + Assertions.assertTrue(page.containsAnnotation(popup), MessageFormatUtil.format( + "Popup reference must point to annotation present on the same page (# {0})", pageNum)); PdfDictionary parentAnnotation = popup.getParentObject(); - Assert.assertSame("Popup annotation parent must point to the annotation that specified it as Popup", - annotation.getPdfObject(), parentAnnotation); + Assertions.assertSame(annotation.getPdfObject(), parentAnnotation, + "Popup annotation parent must point to the annotation that specified it as Popup"); } } - Assert.assertTrue("Markup annotation expected to be present but not found", foundMarkupAnnotation); + Assertions.assertTrue(foundMarkupAnnotation, "Markup annotation expected to be present but not found"); } outDocument.close(); } @Test - @Ignore("Unignore when DEVSIX-3585 would be implemented") + @Disabled("Unignore when DEVSIX-3585 would be implemented") public void testCopyingPageWithAnnotationContainingIrtKey() throws IOException { String inFilePath = SOURCE_FOLDER + "annotation-with-irt.pdf"; String outFilePath = DESTINATION_FOLDER + "copy-annotation-with-irt.pdf"; @@ -134,22 +132,22 @@ public void testCopyingPageWithAnnotationContainingIrtKey() throws IOException { outDocument = new PdfDocument(new PdfReader(outFilePath)); for (int pageNum = 1; pageNum <= outDocument.getNumberOfPages(); pageNum++) { PdfPage page = outDocument.getPage(pageNum); - Assert.assertEquals(4, page.getAnnotsSize()); - Assert.assertEquals(4, page.getAnnotations().size()); + Assertions.assertEquals(4, page.getAnnotsSize()); + Assertions.assertEquals(4, page.getAnnotations().size()); boolean foundMarkupAnnotation = false; for (PdfAnnotation annotation : page.getAnnotations()) { PdfDictionary annotationPageDict = annotation.getPageObject(); if (annotationPageDict != null) { - Assert.assertSame(page.getPdfObject(), annotationPageDict); + Assertions.assertSame(page.getPdfObject(), annotationPageDict); } if (annotation instanceof PdfMarkupAnnotation) { foundMarkupAnnotation = true; PdfDictionary inReplyTo = ((PdfMarkupAnnotation) annotation).getInReplyToObject(); - Assert.assertTrue("IRT reference must point to annotation present on the same page", - page.containsAnnotation(PdfAnnotation.makeAnnotation(inReplyTo))); + Assertions.assertTrue(page.containsAnnotation(PdfAnnotation.makeAnnotation(inReplyTo)), + "IRT reference must point to annotation present on the same page"); } } - Assert.assertTrue("Markup annotation expected to be present but not found", foundMarkupAnnotation); + Assertions.assertTrue(foundMarkupAnnotation, "Markup annotation expected to be present but not found"); } outDocument.close(); } @@ -162,7 +160,7 @@ public void copySameLinksWithGoToSmartModeTest() throws IOException, Interrupted PdfWriter writer = CompareTool.createTestPdfWriter(outFilePath).setSmartMode(true); copyLinksGoToActionTest(writer, true, false); - Assert.assertNull(new CompareTool().compareByContent(outFilePath, cmpFilePath, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outFilePath, cmpFilePath, DESTINATION_FOLDER)); } @Test @@ -173,7 +171,7 @@ public void copyDiffDestLinksWithGoToSmartModeTest() throws IOException, Interru PdfWriter writer = CompareTool.createTestPdfWriter(outFilePath).setSmartMode(true); copyLinksGoToActionTest(writer, false, false); - Assert.assertNull(new CompareTool().compareByContent(outFilePath, cmpFilePath, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outFilePath, cmpFilePath, DESTINATION_FOLDER)); } @Test @@ -184,7 +182,7 @@ public void copyDiffDisplayLinksWithGoToSmartModeTest() throws IOException, Inte PdfWriter writer = CompareTool.createTestPdfWriter(outFilePath).setSmartMode(true); copyLinksGoToActionTest(writer, false, true); - Assert.assertNull(new CompareTool().compareByContent(outFilePath, cmpFilePath, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outFilePath, cmpFilePath, DESTINATION_FOLDER)); } @Test @@ -243,7 +241,7 @@ private void copyPages(String sourceFile, String outFilePath, String cmpFilePath } } - Assert.assertNull(new CompareTool().compareByContent(outFilePath, cmpFilePath, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outFilePath, cmpFilePath, DESTINATION_FOLDER)); } private ByteArrayOutputStream createPdfWithGoToAnnot(boolean isTheSameLink, boolean diffDisplayOptions) { diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/copy/PdfDestinationCopyingTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/copy/PdfDestinationCopyingTest.java index c1d28d2ecc..564e04d170 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/copy/PdfDestinationCopyingTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/copy/PdfDestinationCopyingTest.java @@ -31,17 +31,16 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.navigation.PdfDestination; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.IOException; import java.nio.file.Paths; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfDestinationCopyingTest extends ExtendedITextTest { public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/kernel/pdf/PdfDestinationCopyingTest/"; @@ -66,12 +65,12 @@ public class PdfDestinationCopyingTest extends ExtendedITextTest { SOURCE_FOLDER + "LinkAnnotationViaActionWithNextActionNamedDestination.pdf"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(DESTINATION_FOLDER); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(DESTINATION_FOLDER); } @@ -102,7 +101,7 @@ public void linkAnnotationExplicitDestinationMissingTest() throws IOException { } } - Assert.assertNull(annot); + Assertions.assertNull(annot); } @Test @@ -131,10 +130,10 @@ public void linkAnnotationExplicitDestinationTargetBecomesPage5Test() throws IOE } } - Assert.assertNotNull(annot); + Assertions.assertNotNull(annot); PdfDestination dest = PdfDestination.makeDestination(((PdfLinkAnnotation) annot).getDestinationObject()); - Assert.assertEquals(resultDoc.getPage(5).getPdfObject(), + Assertions.assertEquals(resultDoc.getPage(5).getPdfObject(), dest.getDestinationPage(resultDoc.getCatalog().getNameTree(PdfName.Dests))); } @@ -163,9 +162,9 @@ public void linkAnnotationNamedDestinationMissingTest() throws IOException { break; } } - Assert.assertNull(annot); + Assertions.assertNull(annot); // verify wether name is removed - Assert.assertTrue(resultDoc.getCatalog().getNameTree(PdfName.Dests).getNames().isEmpty()); + Assertions.assertTrue(resultDoc.getCatalog().getNameTree(PdfName.Dests).getNames().isEmpty()); } @Test @@ -194,10 +193,10 @@ public void linkAnnotationNamedDestinationTargetBecomesPage5Test() throws IOExce } } - Assert.assertNotNull(annot); + Assertions.assertNotNull(annot); PdfDestination dest = PdfDestination.makeDestination(((PdfLinkAnnotation) annot).getDestinationObject()); - Assert.assertEquals(resultDoc.getPage(5).getPdfObject(), + Assertions.assertEquals(resultDoc.getPage(5).getPdfObject(), dest.getDestinationPage(resultDoc.getCatalog().getNameTree(PdfName.Dests))); } @@ -227,7 +226,7 @@ public void linkAnnotationViaActionExplicitDestinationMissingTest() throws IOExc } } - Assert.assertNull(annot); + Assertions.assertNull(annot); } @Test @@ -256,10 +255,10 @@ public void linkAnnotationViaActionExplicitDestinationTargetBecomesPage5Test() t } } - Assert.assertNotNull(annot); PdfDestination dest = PdfDestination.makeDestination( + Assertions.assertNotNull(annot); PdfDestination dest = PdfDestination.makeDestination( ((PdfLinkAnnotation) annot).getAction().get(PdfName.D)); - Assert.assertEquals(resultDoc.getPage(5).getPdfObject(), + Assertions.assertEquals(resultDoc.getPage(5).getPdfObject(), dest.getDestinationPage(resultDoc.getCatalog().getNameTree(PdfName.Dests))); } @@ -289,10 +288,10 @@ public void linkAnnotationViaActionNamedDestinationMissingTest() throws IOExcept } } - Assert.assertNull(annot); + Assertions.assertNull(annot); // verify wether name is removed - Assert.assertTrue(resultDoc.getCatalog().getNameTree(PdfName.Dests).getNames().isEmpty()); + Assertions.assertTrue(resultDoc.getCatalog().getNameTree(PdfName.Dests).getNames().isEmpty()); } @Test @@ -321,10 +320,10 @@ public void linkAnnotationViaActionNamedDestinationTargetBecomesPage5Test() thro } } - Assert.assertNotNull(annot);PdfDestination dest = PdfDestination.makeDestination( + Assertions.assertNotNull(annot);PdfDestination dest = PdfDestination.makeDestination( ((PdfLinkAnnotation) annot).getAction().get(PdfName.D)); - Assert.assertEquals(resultDoc.getPage(5).getPdfObject(), + Assertions.assertEquals(resultDoc.getPage(5).getPdfObject(), dest.getDestinationPage(resultDoc.getCatalog().getNameTree(PdfName.Dests))); } @@ -355,8 +354,8 @@ public void linkAnnotationViaNextActionExplicitDestinationMissingTest() throws I } } - Assert.assertNotNull(annot); - Assert.assertNull(((PdfLinkAnnotation) annot).getAction().get(PdfName.Next)); + Assertions.assertNotNull(annot); + Assertions.assertNull(((PdfLinkAnnotation) annot).getAction().get(PdfName.Next)); } @Test @@ -385,11 +384,11 @@ public void linkAnnotationViaNextActionExplicitDestinationTargetBecomesPage5Test } } - Assert.assertNotNull(annot); + Assertions.assertNotNull(annot); PdfDestination dest = PdfDestination.makeDestination( ((PdfLinkAnnotation) annot).getAction().getAsDictionary(PdfName.Next).get(PdfName.D)); - Assert.assertEquals(resultDoc.getPage(5).getPdfObject(), + Assertions.assertEquals(resultDoc.getPage(5).getPdfObject(), dest.getDestinationPage(resultDoc.getCatalog().getNameTree(PdfName.Dests))); } @@ -419,10 +418,10 @@ public void linkAnnotationViaNextActionNamedDestinationMissingTest() throws IOEx } } - Assert.assertNotNull(annot); - Assert.assertNull(((PdfLinkAnnotation) annot).getAction().get(PdfName.Next)); + Assertions.assertNotNull(annot); + Assertions.assertNull(((PdfLinkAnnotation) annot).getAction().get(PdfName.Next)); // verify whether name is removed - Assert.assertTrue(resultDoc.getCatalog().getNameTree(PdfName.Dests).getNames().isEmpty()); + Assertions.assertTrue(resultDoc.getCatalog().getNameTree(PdfName.Dests).getNames().isEmpty()); } @Test @@ -451,10 +450,10 @@ public void linkAnnotationViaNextActionNamedDestinationTargetBecomesPage5Test() } } - Assert.assertNotNull(annot);PdfDestination dest = PdfDestination.makeDestination( + Assertions.assertNotNull(annot);PdfDestination dest = PdfDestination.makeDestination( ((PdfLinkAnnotation) annot).getAction().getAsDictionary(PdfName.Next).get(PdfName.D)); - Assert.assertEquals(resultDoc.getPage(5).getPdfObject(), + Assertions.assertEquals(resultDoc.getPage(5).getPdfObject(), dest.getDestinationPage(resultDoc.getCatalog().getNameTree(PdfName.Dests))); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/event/PdfDocumentEventHandlingTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/event/PdfDocumentEventHandlingTest.java new file mode 100644 index 0000000000..304b7f70ed --- /dev/null +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/event/PdfDocumentEventHandlingTest.java @@ -0,0 +1,104 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.pdf.event; + +import com.itextpdf.commons.actions.EventManager; +import com.itextpdf.kernel.pdf.PdfDocument; +import com.itextpdf.kernel.pdf.PdfWriter; +import com.itextpdf.test.ExtendedITextTest; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +import java.io.ByteArrayOutputStream; + +@Tag("UnitTest") +public class PdfDocumentEventHandlingTest extends ExtendedITextTest { + + @Test + public void simplePdfDocumentEventTest() { + try (PdfDocument document = new PdfDocument(new PdfWriter(new ByteArrayOutputStream()))) { + InsertPageHandler insertPageHandler = new InsertPageHandler(); + document.addEventHandler(PdfDocumentEvent.INSERT_PAGE, insertPageHandler); + document.addNewPage(); + document.addNewPage(); + Assertions.assertEquals(2, insertPageHandler.getInsertedPagesCounter()); + } + } + + @Test + public void globallyRegisteredAbstractPdfDocumentEventHandlerTest() { + InsertPageHandler insertPageHandler = new InsertPageHandler(); + insertPageHandler.addType(PdfDocumentEvent.INSERT_PAGE); + EventManager.getInstance().register(insertPageHandler); + try (PdfDocument document = new PdfDocument(new PdfWriter(new ByteArrayOutputStream()))) { + document.addNewPage(); + } + // Events with specified PDF document are ignored. + Assertions.assertEquals(0, insertPageHandler.getInsertedPagesCounter()); + EventManager.getInstance().unregister(insertPageHandler); + } + + @Test + public void eventHandlerPerSeveralDocumentsTest() { + try (PdfDocument document1 = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); + PdfDocument document2 = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); + PdfDocument document3 = new PdfDocument(new PdfWriter(new ByteArrayOutputStream()))) { + InsertPageHandler insertPageHandler = new InsertPageHandler(); + document1.addEventHandler(PdfDocumentEvent.INSERT_PAGE, insertPageHandler); + document2.addEventHandler(PdfDocumentEvent.INSERT_PAGE, insertPageHandler); + + document1.addNewPage(); + document2.addNewPage(); + document3.addNewPage(); + Assertions.assertEquals(2, insertPageHandler.getInsertedPagesCounter()); + + document2.removeEventHandler(insertPageHandler); + document2.addNewPage(); + Assertions.assertEquals(2, insertPageHandler.getInsertedPagesCounter()); + } + } + + @Test + public void noDocumentSpecifiedForEventButHandlerIsGloballyRegisteredTest() { + InsertPageHandler insertPageHandler = new InsertPageHandler(); + insertPageHandler.addType(PdfDocumentEvent.INSERT_PAGE); + EventManager.getInstance().register(insertPageHandler); + EventManager.getInstance().onEvent(new PdfDocumentEvent(PdfDocumentEvent.INSERT_PAGE)); + EventManager.getInstance().unregister(insertPageHandler); + Assertions.assertEquals(1, insertPageHandler.getInsertedPagesCounter()); + } + + private static class InsertPageHandler extends AbstractPdfDocumentEventHandler { + private int insertedPagesCounter = 0; + + public int getInsertedPagesCounter() { + return insertedPagesCounter; + } + + @Override + protected void onAcceptedEvent(AbstractPdfDocumentEvent event) { + insertedPagesCounter++; + } + } +} diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/filters/ASCII85DecodeFilterTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/filters/ASCII85DecodeFilterTest.java index 5256995496..f5e0165649 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/filters/ASCII85DecodeFilterTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/filters/ASCII85DecodeFilterTest.java @@ -24,16 +24,15 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.File; import java.io.IOException; import java.nio.file.Files; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class ASCII85DecodeFilterTest extends ExtendedITextTest { public static final String SOURCE_FILE = "./src/test/resources/com/itextpdf/kernel/pdf/filters/ASCII85.bin"; @@ -54,7 +53,7 @@ public void decodingTest() throws IOException { ASCII85DecodeFilter filter = new ASCII85DecodeFilter(); String decoded = new String(filter.decode(bytes, null, null, new PdfDictionary())); - Assert.assertEquals(expectedResult, decoded); + Assertions.assertEquals(expectedResult, decoded); } @Test @@ -66,6 +65,6 @@ public void decodingWithZeroBytesTest() { ASCII85DecodeFilter filter = new ASCII85DecodeFilter(); String decoded = new String(filter.decode(bytes, null, null, new PdfDictionary())); - Assert.assertEquals(expectedResult, decoded); + Assertions.assertEquals(expectedResult, decoded); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/filters/ASCIIHexDecodeFilterTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/filters/ASCIIHexDecodeFilterTest.java index ed00011738..8cafd8364a 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/filters/ASCIIHexDecodeFilterTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/filters/ASCIIHexDecodeFilterTest.java @@ -25,16 +25,15 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.exceptions.PdfException; import com.itextpdf.kernel.exceptions.KernelExceptionMessageConstant; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.File; import java.io.IOException; import java.nio.file.Files; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class ASCIIHexDecodeFilterTest extends ExtendedITextTest { public static final String SOURCE_FILE = "./src/test/resources/com/itextpdf/kernel/pdf/filters/ASCIIHex.bin"; @@ -53,17 +52,17 @@ public void decodingTest() throws IOException { + "Etiam hendrerit scelerisque sapien tristique varius."; String decoded = new String(ASCIIHexDecodeFilter.ASCIIHexDecode(bytes)); - Assert.assertEquals(expectedResult, decoded); + Assertions.assertEquals(expectedResult, decoded); } @Test public void decodingIllegalaCharacterTest() { byte[] bytes = "4c6f72656d20697073756d2eg>".getBytes(); - Exception e = Assert.assertThrows(PdfException.class, + Exception e = Assertions.assertThrows(PdfException.class, () -> ASCIIHexDecodeFilter.ASCIIHexDecode(bytes) ); - Assert.assertEquals(KernelExceptionMessageConstant.ILLEGAL_CHARACTER_IN_ASCIIHEXDECODE, e.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.ILLEGAL_CHARACTER_IN_ASCIIHEXDECODE, e.getMessage()); } @Test @@ -72,6 +71,6 @@ public void decodingSkipWhitespacesTest() { String expectedResult = "Lorem ipsum."; String decoded = new String(ASCIIHexDecodeFilter.ASCIIHexDecode(bytes)); - Assert.assertEquals(expectedResult, decoded); + Assertions.assertEquals(expectedResult, decoded); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/filters/LZWDecodeFilterTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/filters/LZWDecodeFilterTest.java index db3b5a1f84..b8b513ebbc 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/filters/LZWDecodeFilterTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/filters/LZWDecodeFilterTest.java @@ -24,13 +24,12 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class LZWDecodeFilterTest extends ExtendedITextTest { @Test @@ -39,7 +38,7 @@ public void decodingTestStatic() { String expectedResult = "-----A---B"; String decoded = new String(LZWDecodeFilter.LZWDecode(bytes)); - Assert.assertEquals(expectedResult, decoded); + Assertions.assertEquals(expectedResult, decoded); } @Test @@ -50,7 +49,7 @@ public void decodingTestNonStatic() { LZWDecodeFilter filter = new LZWDecodeFilter(); String decoded = new String(filter.decode(bytes,null, new PdfDictionary(), new PdfDictionary())); - Assert.assertEquals(expectedResult, decoded); + Assertions.assertEquals(expectedResult, decoded); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/function/AbstractPdfType0FunctionTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/function/AbstractPdfType0FunctionTest.java index 050525c315..ab1e7100ab 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/function/AbstractPdfType0FunctionTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/function/AbstractPdfType0FunctionTest.java @@ -27,17 +27,16 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfNumber; import com.itextpdf.kernel.pdf.PdfStream; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.util.Arrays; import java.util.List; import java.util.function.Function; import java.util.stream.Stream; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public abstract class AbstractPdfType0FunctionTest extends ExtendedITextTest { protected static final double DELTA = 1e-12; @@ -64,7 +63,7 @@ public void testConstantFunctions() { double[] actual = pdfFunction.calculate(new double[] {0, 10, -99}); - Assert.assertArrayEquals(expected, actual, DELTA); + Assertions.assertArrayEquals(expected, actual, DELTA); } @Test @@ -88,7 +87,7 @@ public void testLinearFunctions() { double[] expected = stream.mapToDouble(x -> x).toArray(); double[] actual = pdfFunction.calculate(new double[] {argument}); - Assert.assertArrayEquals(expected, actual, DELTA); + Assertions.assertArrayEquals(expected, actual, DELTA); } } @@ -112,7 +111,7 @@ public void testLinearFunctionsWithEncoding() { double[] expected = function.apply(argument).stream().mapToDouble(x -> x).toArray(); double[] actual = pdfFunction.calculate(new double[] {argument}); - Assert.assertArrayEquals(expected, actual, DELTA); + Assertions.assertArrayEquals(expected, actual, DELTA); } } @@ -144,7 +143,7 @@ public void testLinearFunctionsDim3() { double[] expected = function.apply(argument).stream().mapToDouble(d -> d).toArray(); double[] actual = pdfFunction.calculate(argument.stream().mapToDouble(d -> d).toArray()); - Assert.assertArrayEquals(expected, actual, DELTA); + Assertions.assertArrayEquals(expected, actual, DELTA); } } @@ -171,7 +170,7 @@ protected void testPolynomials(double[] expectedDelta) { double[] actual = pdfFunction.calculate(new double[] {argument}); for (int i = 0; i < expectedDelta.length; ++i) { - Assert.assertEquals(expected[i], actual[i], expectedDelta[i]); + Assertions.assertEquals(expected[i], actual[i], expectedDelta[i]); } } } @@ -206,7 +205,7 @@ protected void testPolynomialsWithEncoding(double[] expectedDelta) { double[] actual = pdfFunction.calculate(new double[] {argument}); for (int i = 0; i < expectedDelta.length; ++i) { - Assert.assertEquals(expected[i], actual[i], expectedDelta[i]); + Assertions.assertEquals(expected[i], actual[i], expectedDelta[i]); } } } @@ -240,7 +239,7 @@ protected void testPolynomialsDim2(double[] expectedDelta) { double[] actual = pdfFunction.calculate(argument.stream().mapToDouble(d -> d).toArray()); for (int i = 0; i < expectedDelta.length; ++i) { - Assert.assertEquals(expected[i], actual[i], expectedDelta[i]); + Assertions.assertEquals(expected[i], actual[i], expectedDelta[i]); } } } @@ -280,7 +279,7 @@ protected void testPolynomialsDim2WithEncoding(double[] expectedDelta) { double[] actual = pdfFunction.calculate(argument.stream().mapToDouble(d -> d).toArray()); for (int i = 0; i < expectedDelta.length; ++i) { - Assert.assertEquals(expected[i], actual[i], expectedDelta[i]); + Assertions.assertEquals(expected[i], actual[i], expectedDelta[i]); } } } @@ -302,7 +301,7 @@ protected void testSinus(double delta) { double expected = function.apply((double) i); double actual = pdfFunction.calculate(new double[] {i})[0]; - Assert.assertEquals(expected, actual, delta); + Assertions.assertEquals(expected, actual, delta); } } @@ -327,7 +326,7 @@ protected void testExponent(double delta) { for (double argument : arguments) { double expected = function.apply(argument); double actual = pdfFunction.calculate(new double[] {argument})[0]; - Assert.assertEquals(expected, actual, delta); + Assertions.assertEquals(expected, actual, delta); } } @@ -352,7 +351,7 @@ protected void testLogarithm(double delta) { for (double argument : arguments) { double expected = function.apply(argument); double actual = pdfFunction.calculate(new double[] {argument})[0]; - Assert.assertEquals(expected, actual, delta); + Assertions.assertEquals(expected, actual, delta); } } @@ -376,7 +375,7 @@ protected void testGeneralInterpolation(double delta) { double expected = function.apply(Arrays.asList(x, y)); double actual = pdfFunction.calculate(new double[] {x, y})[0]; - Assert.assertEquals(expected, actual, delta); + Assertions.assertEquals(expected, actual, delta); } } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/function/BaseInputOutPutConvertorsTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/function/BaseInputOutPutConvertorsTest.java index cadff16c1b..2ba7098440 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/function/BaseInputOutPutConvertorsTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/function/BaseInputOutPutConvertorsTest.java @@ -27,18 +27,17 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfName; import com.itextpdf.kernel.pdf.colorspace.PdfSpecialCs.Separation; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; -@Category(UnitTest.class) +@Tag("UnitTest") public class BaseInputOutPutConvertorsTest extends ExtendedITextTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/kernel/pdf/function/BaseInputOutPutConvertorsTest/"; @@ -90,7 +89,7 @@ public void testInvalidOffsetAndLength() throws IOException { Separation sep1 = new Separation(new PdfName("SEP_RGB"), PdfName.DeviceRGB, fnct1.getPdfObject()); IPdfFunction func = sep1.getTintTransformation(); - Exception ex = Assert.assertThrows(IllegalArgumentException.class, () -> + Exception ex = Assertions.assertThrows(IllegalArgumentException.class, () -> func.calculateFromByteArray(original, 10, original.length, 1, 1)); assertEquals(KernelExceptionMessageConstant.INVALID_LENGTH, ex.getMessage()); @@ -117,7 +116,7 @@ public void testInvalidLengthForWordSize() throws IOException { Separation sep1 = new Separation(new PdfName("SEP_RGB"), PdfName.DeviceRGB, fnct1.getPdfObject()); IPdfFunction func = sep1.getTintTransformation(); - Exception ex = Assert.assertThrows(IllegalArgumentException.class, () -> + Exception ex = Assertions.assertThrows(IllegalArgumentException.class, () -> func.calculateFromByteArray(original, 0, original.length, 11*8, 1)); assertEquals(MessageFormatUtil.format(KernelExceptionMessageConstant.INVALID_LENGTH_FOR_WORDSIZE, 11), ex.getMessage()); diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/function/PdfFunctionFactoryTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/function/PdfFunctionFactoryTest.java index 3adc60a2d8..3e13c715c9 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/function/PdfFunctionFactoryTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/function/PdfFunctionFactoryTest.java @@ -29,13 +29,12 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfNumber; import com.itextpdf.kernel.pdf.PdfStream; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfFunctionFactoryTest extends ExtendedITextTest { @Test @@ -49,7 +48,7 @@ public void testCreateFunctionType0() { stream.put(PdfName.BitsPerSample, new PdfNumber(1)); IPdfFunction function = PdfFunctionFactory.create(stream); - Assert.assertTrue(function instanceof PdfType0Function); + Assertions.assertTrue(function instanceof PdfType0Function); } @Test @@ -61,7 +60,7 @@ public void testCreateFunctionType2() { object.put(PdfName.N, new PdfNumber(2)); IPdfFunction function = PdfFunctionFactory.create(object); - Assert.assertTrue(function instanceof PdfType2Function); + Assertions.assertTrue(function instanceof PdfType2Function); } @Test @@ -79,7 +78,7 @@ public void testCreateFunctionType3() { object.put(PdfName.Encode, new PdfArray(new double[] {0, 1, 0, 1})); IPdfFunction function = PdfFunctionFactory.create(object); - Assert.assertTrue(function instanceof PdfType3Function); + Assertions.assertTrue(function instanceof PdfType3Function); } @@ -94,7 +93,7 @@ public void testCreateFunctionType4() { stream.put(PdfName.BitsPerSample, new PdfNumber(1)); IPdfFunction function = PdfFunctionFactory.create(stream); - Assert.assertTrue(function instanceof PdfType4Function); + Assertions.assertTrue(function instanceof PdfType4Function); } @@ -107,9 +106,9 @@ public void testInvalidFunctionTypeThrowsException() { stream.put(PdfName.Range, new PdfArray( new double[] {1,2,3,4,5,6})); stream.put(PdfName.BitsPerSample, new PdfNumber(1)); - Exception ex = Assert.assertThrows(PdfException.class, () -> PdfFunctionFactory.create(stream)); + Exception ex = Assertions.assertThrows(PdfException.class, () -> PdfFunctionFactory.create(stream)); - Assert.assertEquals("Invalid function type 1", ex.getMessage()); + Assertions.assertEquals("Invalid function type 1", ex.getMessage()); } @Test @@ -121,9 +120,9 @@ public void testDictionaryForType0Throws() { dict.put(PdfName.Range, new PdfArray( new double[] {1,2,3,4,5,6})); dict.put(PdfName.BitsPerSample, new PdfNumber(1)); - Exception ex = Assert.assertThrows(PdfException.class, () -> PdfFunctionFactory.create(dict)); + Exception ex = Assertions.assertThrows(PdfException.class, () -> PdfFunctionFactory.create(dict)); - Assert.assertEquals("Invalid object type, a function type 0 requires a stream object", ex.getMessage()); + Assertions.assertEquals("Invalid object type, a function type 0 requires a stream object", ex.getMessage()); } @Test @@ -135,16 +134,16 @@ public void testDictionaryForType4Throws() { dict.put(PdfName.Range, new PdfArray( new double[] {1,2,3,4,5,6})); dict.put(PdfName.BitsPerSample, new PdfNumber(1)); - Exception ex = Assert.assertThrows(PdfException.class, () -> PdfFunctionFactory.create(dict)); + Exception ex = Assertions.assertThrows(PdfException.class, () -> PdfFunctionFactory.create(dict)); - Assert.assertEquals("Invalid object type, a function type 4 requires a stream object", ex.getMessage()); + Assertions.assertEquals("Invalid object type, a function type 4 requires a stream object", ex.getMessage()); } @Test public void testArrayThrows() { PdfArray array = new PdfArray(); - Exception ex = Assert.assertThrows(PdfException.class, () -> PdfFunctionFactory.create(array)); + Exception ex = Assertions.assertThrows(PdfException.class, () -> PdfFunctionFactory.create(array)); - Assert.assertEquals("Invalid object type, a function must be either a Dictionary or a Stream", ex.getMessage()); + Assertions.assertEquals("Invalid object type, a function must be either a Dictionary or a Stream", ex.getMessage()); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/function/PdfType0FunctionTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/function/PdfType0FunctionTest.java index 9227b3c504..2b1d1631c9 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/function/PdfType0FunctionTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/function/PdfType0FunctionTest.java @@ -29,13 +29,12 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfStream; import com.itextpdf.test.AssertUtil; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfType0FunctionTest extends ExtendedITextTest { protected static final double DELTA = 1e-12; @@ -59,7 +58,7 @@ public void testEncoding() { for (int j = 0; j < x.length; ++j) { double actual = PdfType0Function.encode(x[j], encode[i][0], encode[i][1]); - Assert.assertEquals(expected[i][j], actual, DELTA); + Assertions.assertEquals(expected[i][j], actual, DELTA); } } } @@ -80,7 +79,7 @@ public void testFloor() { for (int i = 0; i < normals.length; ++i) { int[] actual = PdfType0Function.getFloor(normals[i], encode); - Assert.assertArrayEquals(expected[i], actual); + Assertions.assertArrayEquals(expected[i], actual); } } @@ -91,7 +90,7 @@ public void testSamplePositionDim1() { for (int sample = 0; sample < size; ++sample) { int position = PdfType0Function.getSamplePosition(new int[] {sample}, sizeArr); - Assert.assertEquals(sample, position); + Assertions.assertEquals(sample, position); } } } @@ -116,7 +115,7 @@ public void testSamplePositionDim3() { for (int i = 0; i < size.length; ++i) { for (int j = 0; j < samples[i].length; ++j) { int actual = PdfType0Function.getSamplePosition(samples[i][j], size[i]); - Assert.assertEquals(expected[i][j], actual); + Assertions.assertEquals(expected[i][j], actual); } } } @@ -138,7 +137,7 @@ public void testFloorWeights() { for (int i = 0; i < normals.length; ++i) { double[] actual = PdfType0Function.getFloorWeights(normals[i], encode); - Assert.assertArrayEquals(expected[i], actual, DELTA); + Assertions.assertArrayEquals(expected[i], actual, DELTA); } } @@ -151,7 +150,7 @@ public void testFloorWeight() { for (int i = 0; i < normals.length; ++i) { double actual = PdfType0Function.getFloorWeight(normals[i], encode[2 * i], encode[2 * i + 1]); - Assert.assertEquals(expected[i], actual, DELTA); + Assertions.assertEquals(expected[i], actual, DELTA); } } @@ -172,7 +171,7 @@ public void testSpecialSweepMethod() { for (int i = 0; i < rhsVectors.length; ++i) { double[] actual = PdfType0Function.specialSweepMethod(rhsVectors[i]); - Assert.assertArrayEquals(expected[i], actual, DELTA); + Assertions.assertArrayEquals(expected[i], actual, DELTA); } } @@ -180,9 +179,9 @@ public void testSpecialSweepMethod() { public void testNoInputException() { AbstractPdfFunction function = new PdfType0Function(new PdfStream()); - Exception e = Assert + Exception e = Assertions .assertThrows(IllegalArgumentException.class, () -> function.calculate(new double[] {0})); - Assert.assertEquals(KernelExceptionMessageConstant.PDF_TYPE0_FUNCTION_NOT_NULL_PARAMETERS, e.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.PDF_TYPE0_FUNCTION_NOT_NULL_PARAMETERS, e.getMessage()); } @Test @@ -196,9 +195,9 @@ public void testSimpleValidPdfFunction() { @Test public void testInvalidBitsPerSampleException() { PdfType0Function function = generateSimplePdfFunction(new byte[] {0}, 3); - Exception e = Assert + Exception e = Assertions .assertThrows(IllegalArgumentException.class, () -> function.calculate(new double[] {0})); - Assert.assertEquals(KernelExceptionMessageConstant.PDF_TYPE0_FUNCTION_BITS_PER_SAMPLE_INVALID_VALUE, e.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.PDF_TYPE0_FUNCTION_BITS_PER_SAMPLE_INVALID_VALUE, e.getMessage()); } @Test @@ -206,9 +205,9 @@ public void testInvalidOrderException() { PdfType0Function function = generateSimplePdfFunction(new byte[] {0}, 1); function.setOrder(2); - Exception e = Assert + Exception e = Assertions .assertThrows(IllegalArgumentException.class, () -> function.calculate(new double[] {0})); - Assert.assertEquals(KernelExceptionMessageConstant.PDF_TYPE0_FUNCTION_INVALID_ORDER, e.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.PDF_TYPE0_FUNCTION_INVALID_ORDER, e.getMessage()); } @Test @@ -216,9 +215,9 @@ public void testInvalidDomainException() { PdfType0Function function = generateSimplePdfFunction(new byte[] {0}, 1); function.setDomain(new double[] {0, 1, 1}); - Exception e = Assert + Exception e = Assertions .assertThrows(IllegalArgumentException.class, () -> function.calculate(new double[] {0})); - Assert.assertEquals(KernelExceptionMessageConstant.PDF_TYPE0_FUNCTION_INVALID_DOMAIN, e.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.PDF_TYPE0_FUNCTION_INVALID_DOMAIN, e.getMessage()); } @Test @@ -226,9 +225,9 @@ public void testInvalidRangeException() { PdfType0Function function = generateSimplePdfFunction(new byte[] {0}, 1); function.setRange(new double[] {0, 1, 1}); - Exception e = Assert + Exception e = Assertions .assertThrows(IllegalArgumentException.class, () -> function.calculate(new double[] {0})); - Assert.assertEquals(KernelExceptionMessageConstant.PDF_TYPE0_FUNCTION_INVALID_RANGE, e.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.PDF_TYPE0_FUNCTION_INVALID_RANGE, e.getMessage()); } @Test @@ -236,9 +235,9 @@ public void testInvalidSizeException() { PdfType0Function function = generateSimplePdfFunction(new byte[] {0}, 1); function.setSize(new int[] {2, 2}); - Exception e = Assert + Exception e = Assertions .assertThrows(IllegalArgumentException.class, () -> function.calculate(new double[] {0})); - Assert.assertEquals(KernelExceptionMessageConstant.PDF_TYPE0_FUNCTION_INVALID_SIZE, e.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.PDF_TYPE0_FUNCTION_INVALID_SIZE, e.getMessage()); } @Test @@ -246,9 +245,9 @@ public void testInvalidEncodeException() { PdfType0Function function = generateSimplePdfFunction(new byte[] {0}, 1); function.setEncode(new int[] {3, 4}); - Exception e = Assert + Exception e = Assertions .assertThrows(IllegalArgumentException.class, () -> function.calculate(new double[] {0})); - Assert.assertEquals(KernelExceptionMessageConstant.PDF_TYPE0_FUNCTION_INVALID_ENCODE, e.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.PDF_TYPE0_FUNCTION_INVALID_ENCODE, e.getMessage()); } @Test @@ -256,9 +255,9 @@ public void testInvalidDecodeException() { PdfType0Function function = generateSimplePdfFunction(new byte[] {0}, 1); function.setDecode(new double[] {0}); - Exception e = Assert + Exception e = Assertions .assertThrows(IllegalArgumentException.class, () -> function.calculate(new double[] {0})); - Assert.assertEquals(KernelExceptionMessageConstant.PDF_TYPE0_FUNCTION_INVALID_DECODE, e.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.PDF_TYPE0_FUNCTION_INVALID_DECODE, e.getMessage()); } @Test @@ -266,9 +265,9 @@ public void testInvalidSamplesException() { PdfType0Function function = generateSimplePdfFunction(new byte[] {0x0f, 0x0f}, 4); function.setSize(new int[] {5}); - Exception e = Assert + Exception e = Assertions .assertThrows(IllegalArgumentException.class, () -> function.calculate(new double[] {0})); - Assert.assertEquals(KernelExceptionMessageConstant.PDF_TYPE0_FUNCTION_INVALID_SAMPLES, e.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.PDF_TYPE0_FUNCTION_INVALID_SAMPLES, e.getMessage()); } private PdfType0Function generateSimplePdfFunction(byte[] samples, int bitsPerSample) { diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/function/PdfType0Order1FunctionTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/function/PdfType0Order1FunctionTest.java index 8a72913314..d7ce4a138a 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/function/PdfType0Order1FunctionTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/function/PdfType0Order1FunctionTest.java @@ -22,12 +22,11 @@ This file is part of the iText (R) project. */ package com.itextpdf.kernel.pdf.function; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfType0Order1FunctionTest extends AbstractPdfType0FunctionTest { private static final int LINEAR_INTERPOLATION_ORDER = 1; diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/function/PdfType0Order3FunctionTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/function/PdfType0Order3FunctionTest.java index 181fbfded7..583be9db86 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/function/PdfType0Order3FunctionTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/function/PdfType0Order3FunctionTest.java @@ -22,12 +22,11 @@ This file is part of the iText (R) project. */ package com.itextpdf.kernel.pdf.function; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfType0Order3FunctionTest extends AbstractPdfType0FunctionTest { private static final int CUBIC_INTERPOLATION_ORDER = 3; diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/function/PdfType2FunctionTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/function/PdfType2FunctionTest.java index 810083afcf..fbbe558179 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/function/PdfType2FunctionTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/function/PdfType2FunctionTest.java @@ -30,13 +30,12 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfNumber; import com.itextpdf.kernel.pdf.PdfString; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfType2FunctionTest extends ExtendedITextTest { private final static double EPSILON = 10e-6; @@ -44,16 +43,16 @@ public class PdfType2FunctionTest extends ExtendedITextTest { public void constructorInvalidObjWithoutNTest() { PdfDictionary type2Func = PdfFunctionUtil.createMinimalPdfType2FunctionDict(); type2Func.remove(PdfName.N); - Exception ex = Assert.assertThrows(PdfException.class, () -> new PdfType2Function(type2Func)); - Assert.assertEquals(KernelExceptionMessageConstant.INVALID_TYPE_2_FUNCTION_N, ex.getMessage()); + Exception ex = Assertions.assertThrows(PdfException.class, () -> new PdfType2Function(type2Func)); + Assertions.assertEquals(KernelExceptionMessageConstant.INVALID_TYPE_2_FUNCTION_N, ex.getMessage()); } @Test public void constructorInvalidObjNNotNumberTest() { PdfDictionary type2Func = PdfFunctionUtil.createMinimalPdfType2FunctionDict(); type2Func.put(PdfName.N, new PdfString("some text")); - Exception ex = Assert.assertThrows(PdfException.class, () -> new PdfType2Function(type2Func)); - Assert.assertEquals(KernelExceptionMessageConstant.INVALID_TYPE_2_FUNCTION_N, ex.getMessage()); + Exception ex = Assertions.assertThrows(PdfException.class, () -> new PdfType2Function(type2Func)); + Assertions.assertEquals(KernelExceptionMessageConstant.INVALID_TYPE_2_FUNCTION_N, ex.getMessage()); } @Test @@ -63,24 +62,24 @@ public void constructorInvalidObjWithNonIntegerNTest() { final PdfArray domain = type2Func.getAsArray(PdfName.Domain); domain.add(0, new PdfNumber(-1)); domain.remove(2); - Exception ex = Assert.assertThrows(PdfException.class, () -> new PdfType2Function(type2Func)); - Assert.assertEquals(KernelExceptionMessageConstant.INVALID_TYPE_2_FUNCTION_N_NOT_INTEGER, ex.getMessage()); + Exception ex = Assertions.assertThrows(PdfException.class, () -> new PdfType2Function(type2Func)); + Assertions.assertEquals(KernelExceptionMessageConstant.INVALID_TYPE_2_FUNCTION_N_NOT_INTEGER, ex.getMessage()); } @Test public void constructorInvalidObjWithNegativeNTest() { PdfDictionary type2Func = PdfFunctionUtil.createMinimalPdfType2FunctionDict(); type2Func.put(PdfName.N, new PdfNumber(-2)); - Exception ex = Assert.assertThrows(PdfException.class, () -> new PdfType2Function(type2Func)); - Assert.assertEquals(KernelExceptionMessageConstant.INVALID_TYPE_2_FUNCTION_N_NEGATIVE, ex.getMessage()); + Exception ex = Assertions.assertThrows(PdfException.class, () -> new PdfType2Function(type2Func)); + Assertions.assertEquals(KernelExceptionMessageConstant.INVALID_TYPE_2_FUNCTION_N_NEGATIVE, ex.getMessage()); } @Test public void constructorInvalidDomainTest() { PdfDictionary type2Func = PdfFunctionUtil.createMinimalPdfType2FunctionDict(); type2Func.put(PdfName.Domain, new PdfArray(new double[] {1})); - Exception ex = Assert.assertThrows(PdfException.class, () -> new PdfType2Function(type2Func)); - Assert.assertEquals(KernelExceptionMessageConstant.INVALID_TYPE_2_FUNCTION_DOMAIN, ex.getMessage()); + Exception ex = Assertions.assertThrows(PdfException.class, () -> new PdfType2Function(type2Func)); + Assertions.assertEquals(KernelExceptionMessageConstant.INVALID_TYPE_2_FUNCTION_DOMAIN, ex.getMessage()); } @Test @@ -88,7 +87,7 @@ public void constructorCorrectDomainTest() { PdfDictionary type2Func = PdfFunctionUtil.createMinimalPdfType2FunctionDict(); type2Func.put(PdfName.Domain, new PdfArray(new double[] {1, 2, 3, 4})); PdfType2Function type2Function = new PdfType2Function(type2Func); - Assert.assertEquals(2, type2Function.getInputSize()); + Assertions.assertEquals(2, type2Function.getInputSize()); } @Test @@ -96,8 +95,8 @@ public void constructorInvalidCDifferentSizeTest() { PdfDictionary type2Func = PdfFunctionUtil.createMinimalPdfType2FunctionDict(); type2Func.put(PdfName.C0, new PdfArray(new int[]{1, 2})); type2Func.put(PdfName.C1, new PdfArray(new int[]{3})); - Exception ex = Assert.assertThrows(PdfException.class, () -> new PdfType2Function(type2Func)); - Assert.assertEquals(KernelExceptionMessageConstant.INVALID_TYPE_2_FUNCTION_OUTPUT_SIZE, ex.getMessage()); + Exception ex = Assertions.assertThrows(PdfException.class, () -> new PdfType2Function(type2Func)); + Assertions.assertEquals(KernelExceptionMessageConstant.INVALID_TYPE_2_FUNCTION_OUTPUT_SIZE, ex.getMessage()); } @Test @@ -105,8 +104,8 @@ public void constructorInvalidCAndRangeDifferentSizeTest() { PdfDictionary type2Func = PdfFunctionUtil.createMinimalPdfType2FunctionDict(); type2Func.put(PdfName.C0, new PdfArray(new int[]{1, 2})); type2Func.put(PdfName.Range, new PdfArray(new int[] {1, 3})); - Exception ex = Assert.assertThrows(PdfException.class, () -> new PdfType2Function(type2Func)); - Assert.assertEquals(KernelExceptionMessageConstant.INVALID_TYPE_2_FUNCTION_OUTPUT_SIZE, ex.getMessage()); + Exception ex = Assertions.assertThrows(PdfException.class, () -> new PdfType2Function(type2Func)); + Assertions.assertEquals(KernelExceptionMessageConstant.INVALID_TYPE_2_FUNCTION_OUTPUT_SIZE, ex.getMessage()); } @Test @@ -114,18 +113,18 @@ public void constructorWithRangeTest() { PdfDictionary type2FuncDict = PdfFunctionUtil.createMinimalPdfType2FunctionDict(); type2FuncDict.put(PdfName.Range, new PdfArray(new int[] {1, 2, 3, 4, 5, 6})); PdfType2Function type2Func = new PdfType2Function(type2FuncDict); - Assert.assertArrayEquals(new double[] {0, 0, 0}, type2Func.getC0(), EPSILON); - Assert.assertArrayEquals(new double[] {1, 1, 1}, type2Func.getC1(), EPSILON); - Assert.assertEquals(2, type2Func.getN(), EPSILON); + Assertions.assertArrayEquals(new double[] {0, 0, 0}, type2Func.getC0(), EPSILON); + Assertions.assertArrayEquals(new double[] {1, 1, 1}, type2Func.getC1(), EPSILON); + Assertions.assertEquals(2, type2Func.getN(), EPSILON); } @Test public void constructorMinimalTest() { PdfDictionary type2FuncDict = PdfFunctionUtil.createMinimalPdfType2FunctionDict(); PdfType2Function type2Func = new PdfType2Function(type2FuncDict); - Assert.assertArrayEquals(new double[] {0}, type2Func.getC0(), EPSILON); - Assert.assertArrayEquals(new double[] {1}, type2Func.getC1(), EPSILON); - Assert.assertEquals(2, type2Func.getN(), EPSILON); + Assertions.assertArrayEquals(new double[] {0}, type2Func.getC0(), EPSILON); + Assertions.assertArrayEquals(new double[] {1}, type2Func.getC1(), EPSILON); + Assertions.assertEquals(2, type2Func.getN(), EPSILON); } @Test @@ -135,25 +134,25 @@ public void constructorFullTest() { type2FuncDict.put(PdfName.C1, new PdfArray(new int[] {1, 2})); PdfType2Function type2Func = new PdfType2Function(type2FuncDict); - Assert.assertEquals(2, type2Func.getN(), EPSILON); - Assert.assertArrayEquals(new double[] {0, 1}, type2Func.getC0(), EPSILON); - Assert.assertArrayEquals(new double[] {1, 2}, type2Func.getC1(), EPSILON); + Assertions.assertEquals(2, type2Func.getN(), EPSILON); + Assertions.assertArrayEquals(new double[] {0, 1}, type2Func.getC0(), EPSILON); + Assertions.assertArrayEquals(new double[] {1, 2}, type2Func.getC1(), EPSILON); } @Test public void calculateInvalid2NumberInputTest() { PdfType2Function type2Func = new PdfType2Function(PdfFunctionUtil.createMinimalPdfType2FunctionDict()); - Exception ex = Assert.assertThrows(PdfException.class, () -> type2Func.calculate(new double[] {0, 1})); - Assert.assertEquals(KernelExceptionMessageConstant.INVALID_INPUT_FOR_TYPE_2_FUNCTION, ex.getMessage()); + Exception ex = Assertions.assertThrows(PdfException.class, () -> type2Func.calculate(new double[] {0, 1})); + Assertions.assertEquals(KernelExceptionMessageConstant.INVALID_INPUT_FOR_TYPE_2_FUNCTION, ex.getMessage()); } @Test public void calculateInvalidNullInputTest() { PdfType2Function type2Func = new PdfType2Function(PdfFunctionUtil.createMinimalPdfType2FunctionDict()); - Exception ex = Assert.assertThrows(PdfException.class, () -> type2Func.calculate(null)); - Assert.assertEquals(KernelExceptionMessageConstant.INVALID_INPUT_FOR_TYPE_2_FUNCTION, ex.getMessage()); + Exception ex = Assertions.assertThrows(PdfException.class, () -> type2Func.calculate(null)); + Assertions.assertEquals(KernelExceptionMessageConstant.INVALID_INPUT_FOR_TYPE_2_FUNCTION, ex.getMessage()); } @Test @@ -164,7 +163,7 @@ public void calculateInputClipTest() { double[] output = type2Function.calculate(new double[] {8}); // input value was clipped to 3 from 8 - Assert.assertArrayEquals(new double[] {9}, output, EPSILON); + Assertions.assertArrayEquals(new double[] {9}, output, EPSILON); } @Test @@ -177,7 +176,7 @@ public void calculateTest() { PdfType2Function type2Function = new PdfType2Function(type2FuncDict); double[] output = type2Function.calculate(new double[] {2}); - Assert.assertArrayEquals(new double[] {0, -15}, output, EPSILON); + Assertions.assertArrayEquals(new double[] {0, -15}, output, EPSILON); } @Test @@ -189,7 +188,7 @@ public void calculateWithoutC0Test() { PdfType2Function type2Function = new PdfType2Function(type2FuncDict); double[] output = type2Function.calculate(new double[] {2}); - Assert.assertArrayEquals(new double[] {0, -12}, output, EPSILON); + Assertions.assertArrayEquals(new double[] {0, -12}, output, EPSILON); } @Test @@ -202,6 +201,6 @@ public void calculateClipOutputTest() { double[] output = type2Function.calculate(new double[] {2}); // output value was clipped to -2 from 4 - Assert.assertArrayEquals(new double[] {-2}, output, EPSILON); + Assertions.assertArrayEquals(new double[] {-2}, output, EPSILON); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/function/PdfType3FunctionTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/function/PdfType3FunctionTest.java index 5989f7c070..18e22b3ccc 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/function/PdfType3FunctionTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/function/PdfType3FunctionTest.java @@ -29,13 +29,12 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfName; import com.itextpdf.kernel.pdf.PdfNumber; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfType3FunctionTest extends ExtendedITextTest { private final static double EPSILON = 10e-6; @@ -43,40 +42,40 @@ public class PdfType3FunctionTest extends ExtendedITextTest { public void constructorNullFunctionsTest() { PdfDictionary type3Func = createMinimalPdfType3FunctionDict(); type3Func.remove(PdfName.Functions); - Exception ex = Assert.assertThrows(PdfException.class, () -> new PdfType3Function(type3Func)); - Assert.assertEquals(KernelExceptionMessageConstant.INVALID_TYPE_3_FUNCTION_NULL_FUNCTIONS, ex.getMessage()); + Exception ex = Assertions.assertThrows(PdfException.class, () -> new PdfType3Function(type3Func)); + Assertions.assertEquals(KernelExceptionMessageConstant.INVALID_TYPE_3_FUNCTION_NULL_FUNCTIONS, ex.getMessage()); } @Test public void constructorZeroSizeOfFunctionsTest() { PdfDictionary type3Func = createMinimalPdfType3FunctionDict(); type3Func.put(PdfName.Functions, new PdfArray()); - Exception ex = Assert.assertThrows(PdfException.class, () -> new PdfType3Function(type3Func)); - Assert.assertEquals(KernelExceptionMessageConstant.INVALID_TYPE_3_FUNCTION_NULL_FUNCTIONS, ex.getMessage()); + Exception ex = Assertions.assertThrows(PdfException.class, () -> new PdfType3Function(type3Func)); + Assertions.assertEquals(KernelExceptionMessageConstant.INVALID_TYPE_3_FUNCTION_NULL_FUNCTIONS, ex.getMessage()); } @Test public void constructorDifferentOutputSizeOfFunctionsTest() { PdfDictionary type3Func = createMinimalPdfType3FunctionDict(); type3Func.getAsArray(PdfName.Functions).getAsDictionary(0).put(PdfName.Range, new PdfArray(new double[] {-100, 100, -100, 100})); - Exception ex = Assert.assertThrows(PdfException.class, () -> new PdfType3Function(type3Func)); - Assert.assertEquals(KernelExceptionMessageConstant.INVALID_TYPE_3_FUNCTION_FUNCTIONS_OUTPUT, ex.getMessage()); + Exception ex = Assertions.assertThrows(PdfException.class, () -> new PdfType3Function(type3Func)); + Assertions.assertEquals(KernelExceptionMessageConstant.INVALID_TYPE_3_FUNCTION_FUNCTIONS_OUTPUT, ex.getMessage()); } @Test public void constructorDifferentOutputSizeFuncWithRangeTest() { PdfDictionary type3Func = createMinimalPdfType3FunctionDict(); type3Func.put(PdfName.Range, new PdfArray(new double[] {-100, 100, -100, 100})); - Exception ex = Assert.assertThrows(PdfException.class, () -> new PdfType3Function(type3Func)); - Assert.assertEquals(KernelExceptionMessageConstant.INVALID_TYPE_3_FUNCTION_FUNCTIONS_OUTPUT, ex.getMessage()); + Exception ex = Assertions.assertThrows(PdfException.class, () -> new PdfType3Function(type3Func)); + Assertions.assertEquals(KernelExceptionMessageConstant.INVALID_TYPE_3_FUNCTION_FUNCTIONS_OUTPUT, ex.getMessage()); } @Test public void constructorInvalidInputSizeOfFuncTest() { PdfDictionary type3Func = createMinimalPdfType3FunctionDict(); IPdfFunctionFactory customFactory = (dict) -> new CustomPdfFunction((PdfDictionary)dict, 2, 1); - Exception ex = Assert.assertThrows(PdfException.class, () -> new PdfType3Function(type3Func, customFactory)); - Assert.assertEquals(KernelExceptionMessageConstant.INVALID_TYPE_3_FUNCTION_FUNCTIONS_INPUT, ex.getMessage()); + Exception ex = Assertions.assertThrows(PdfException.class, () -> new PdfType3Function(type3Func, customFactory)); + Assertions.assertEquals(KernelExceptionMessageConstant.INVALID_TYPE_3_FUNCTION_FUNCTIONS_INPUT, ex.getMessage()); } @Test @@ -84,31 +83,31 @@ public void constructorIgnoreNotDictFunctionsTest() { PdfDictionary type3FuncDict = createMinimalPdfType3FunctionDict(); type3FuncDict.getAsArray(PdfName.Functions).add(new PdfNumber(1)); PdfType3Function type3Function = new PdfType3Function(type3FuncDict); - Assert.assertEquals(2, type3Function.getFunctions().size()); + Assertions.assertEquals(2, type3Function.getFunctions().size()); } @Test public void constructorInvalidFunctionTest() { PdfDictionary type3Func = createMinimalPdfType3FunctionDict(); type3Func.getAsArray(PdfName.Functions).getAsDictionary(0).remove(PdfName.N); - Exception ex = Assert.assertThrows(PdfException.class, () -> new PdfType3Function(type3Func)); - Assert.assertEquals(KernelExceptionMessageConstant.INVALID_TYPE_2_FUNCTION_N, ex.getMessage()); + Exception ex = Assertions.assertThrows(PdfException.class, () -> new PdfType3Function(type3Func)); + Assertions.assertEquals(KernelExceptionMessageConstant.INVALID_TYPE_2_FUNCTION_N, ex.getMessage()); } @Test public void constructorNullBoundsTest() { PdfDictionary type3Func = createMinimalPdfType3FunctionDict(); type3Func.remove(PdfName.Bounds); - Exception ex = Assert.assertThrows(PdfException.class, () -> new PdfType3Function(type3Func)); - Assert.assertEquals(KernelExceptionMessageConstant.INVALID_TYPE_3_FUNCTION_NULL_BOUNDS, ex.getMessage()); + Exception ex = Assertions.assertThrows(PdfException.class, () -> new PdfType3Function(type3Func)); + Assertions.assertEquals(KernelExceptionMessageConstant.INVALID_TYPE_3_FUNCTION_NULL_BOUNDS, ex.getMessage()); } @Test public void constructorInvalidSizeOfBoundsTest() { PdfDictionary type3Func = createMinimalPdfType3FunctionDict(); type3Func.put(PdfName.Bounds, new PdfArray()); - Exception ex = Assert.assertThrows(PdfException.class, () -> new PdfType3Function(type3Func)); - Assert.assertEquals(KernelExceptionMessageConstant.INVALID_TYPE_3_FUNCTION_NULL_BOUNDS, ex.getMessage()); + Exception ex = Assertions.assertThrows(PdfException.class, () -> new PdfType3Function(type3Func)); + Assertions.assertEquals(KernelExceptionMessageConstant.INVALID_TYPE_3_FUNCTION_NULL_BOUNDS, ex.getMessage()); } @Test @@ -116,8 +115,8 @@ public void constructorInvalidBoundsLessThanDomainTest() { PdfDictionary type3Func = createMinimalPdfType3FunctionDict(); type3Func.getAsArray(PdfName.Bounds).remove(0); type3Func.getAsArray(PdfName.Bounds).add(new PdfNumber(-1)); - Exception ex = Assert.assertThrows(PdfException.class, () -> new PdfType3Function(type3Func)); - Assert.assertEquals(KernelExceptionMessageConstant.INVALID_TYPE_3_FUNCTION_BOUNDS, ex.getMessage()); + Exception ex = Assertions.assertThrows(PdfException.class, () -> new PdfType3Function(type3Func)); + Assertions.assertEquals(KernelExceptionMessageConstant.INVALID_TYPE_3_FUNCTION_BOUNDS, ex.getMessage()); } @Test @@ -125,8 +124,8 @@ public void constructorInvalidBoundsMoreThanDomainTest() { PdfDictionary type3Func = createMinimalPdfType3FunctionDict(); type3Func.getAsArray(PdfName.Bounds).remove(0); type3Func.getAsArray(PdfName.Bounds).add(new PdfNumber(3)); - Exception ex = Assert.assertThrows(PdfException.class, () -> new PdfType3Function(type3Func)); - Assert.assertEquals(KernelExceptionMessageConstant.INVALID_TYPE_3_FUNCTION_BOUNDS, ex.getMessage()); + Exception ex = Assertions.assertThrows(PdfException.class, () -> new PdfType3Function(type3Func)); + Assertions.assertEquals(KernelExceptionMessageConstant.INVALID_TYPE_3_FUNCTION_BOUNDS, ex.getMessage()); } @Test @@ -146,32 +145,32 @@ public void constructorInvalidBoundsLessThanPreviousTest() { type3Func.put(PdfName.Encode, new PdfArray(new double[] {0, 1, 0, 1, 0, 1})); - Exception ex = Assert.assertThrows(PdfException.class, () -> new PdfType3Function(type3Func)); - Assert.assertEquals(KernelExceptionMessageConstant.INVALID_TYPE_3_FUNCTION_BOUNDS, ex.getMessage()); + Exception ex = Assertions.assertThrows(PdfException.class, () -> new PdfType3Function(type3Func)); + Assertions.assertEquals(KernelExceptionMessageConstant.INVALID_TYPE_3_FUNCTION_BOUNDS, ex.getMessage()); } @Test public void constructorNullEncodeTest() { PdfDictionary type3Func = createMinimalPdfType3FunctionDict(); type3Func.remove(PdfName.Encode); - Exception ex = Assert.assertThrows(PdfException.class, () -> new PdfType3Function(type3Func)); - Assert.assertEquals(KernelExceptionMessageConstant.INVALID_TYPE_3_FUNCTION_NULL_ENCODE, ex.getMessage()); + Exception ex = Assertions.assertThrows(PdfException.class, () -> new PdfType3Function(type3Func)); + Assertions.assertEquals(KernelExceptionMessageConstant.INVALID_TYPE_3_FUNCTION_NULL_ENCODE, ex.getMessage()); } @Test public void constructorInvalidSizeOfEncodeTest() { PdfDictionary type3Func = createMinimalPdfType3FunctionDict(); type3Func.put(PdfName.Encode, new PdfArray()); - Exception ex = Assert.assertThrows(PdfException.class, () -> new PdfType3Function(type3Func)); - Assert.assertEquals(KernelExceptionMessageConstant.INVALID_TYPE_3_FUNCTION_NULL_ENCODE, ex.getMessage()); + Exception ex = Assertions.assertThrows(PdfException.class, () -> new PdfType3Function(type3Func)); + Assertions.assertEquals(KernelExceptionMessageConstant.INVALID_TYPE_3_FUNCTION_NULL_ENCODE, ex.getMessage()); } @Test public void constructorInvalidDomainTest() { PdfDictionary type3Func = createMinimalPdfType3FunctionDict(); type3Func.put(PdfName.Domain, new PdfArray(new double[] {1})); - Exception ex = Assert.assertThrows(PdfException.class, () -> new PdfType3Function(type3Func)); - Assert.assertEquals(KernelExceptionMessageConstant.INVALID_TYPE_3_FUNCTION_DOMAIN, ex.getMessage()); + Exception ex = Assertions.assertThrows(PdfException.class, () -> new PdfType3Function(type3Func)); + Assertions.assertEquals(KernelExceptionMessageConstant.INVALID_TYPE_3_FUNCTION_DOMAIN, ex.getMessage()); } @Test @@ -179,7 +178,7 @@ public void getOutputSizeNullRangeTest() { PdfDictionary type3FuncDict = createMinimalPdfType3FunctionDict(); IPdfFunctionFactory customFactory = (dict) -> new CustomPdfFunction((PdfDictionary)dict, 1, 7); PdfType3Function type3Function = new PdfType3Function(type3FuncDict, customFactory); - Assert.assertEquals(7, type3Function.getOutputSize()); + Assertions.assertEquals(7, type3Function.getOutputSize()); } @Test @@ -188,7 +187,7 @@ public void getEncodeTest() { type3FuncDict.put(PdfName.Encode, new PdfArray(new double[] {0, 0.37, -1, 0})); PdfType3Function type3Function = new PdfType3Function(type3FuncDict); - Assert.assertArrayEquals(new double[] {0, 0.37, -1, 0}, type3Function.getEncode(), EPSILON); + Assertions.assertArrayEquals(new double[] {0, 0.37, -1, 0}, type3Function.getEncode(), EPSILON); } @Test @@ -197,23 +196,23 @@ public void getBoundsTest() { type3FuncDict.put(PdfName.Bounds, new PdfArray(new double[] {0.789})); PdfType3Function type3Function = new PdfType3Function(type3FuncDict); - Assert.assertArrayEquals(new double[] {0.789}, type3Function.getBounds(), EPSILON); + Assertions.assertArrayEquals(new double[] {0.789}, type3Function.getBounds(), EPSILON); } @Test public void calculateInvalid2NumberInputTest() { PdfType3Function type3Func = new PdfType3Function(createMinimalPdfType3FunctionDict()); - Exception ex = Assert.assertThrows(PdfException.class, () -> type3Func.calculate(new double[] {0, 1})); - Assert.assertEquals(KernelExceptionMessageConstant.INVALID_INPUT_FOR_TYPE_3_FUNCTION, ex.getMessage()); + Exception ex = Assertions.assertThrows(PdfException.class, () -> type3Func.calculate(new double[] {0, 1})); + Assertions.assertEquals(KernelExceptionMessageConstant.INVALID_INPUT_FOR_TYPE_3_FUNCTION, ex.getMessage()); } @Test public void calculateInvalidNullInputTest() { PdfType3Function type3Func = new PdfType3Function(createMinimalPdfType3FunctionDict()); - Exception ex = Assert.assertThrows(PdfException.class, () -> type3Func.calculate(null)); - Assert.assertEquals(KernelExceptionMessageConstant.INVALID_INPUT_FOR_TYPE_3_FUNCTION, ex.getMessage()); + Exception ex = Assertions.assertThrows(PdfException.class, () -> type3Func.calculate(null)); + Assertions.assertEquals(KernelExceptionMessageConstant.INVALID_INPUT_FOR_TYPE_3_FUNCTION, ex.getMessage()); } @Test @@ -223,7 +222,7 @@ public void calculateInputClipTest() { double[] output = type3Function.calculate(new double[] {-5}); // input value was clipped to 0 from -5 - Assert.assertArrayEquals(new double[] {0}, output, EPSILON); + Assertions.assertArrayEquals(new double[] {0}, output, EPSILON); } @Test @@ -235,7 +234,7 @@ public void calculateDomainOnePointIntervalTest() { PdfType3Function type3Function = new PdfType3Function(type3FuncDict); double[] output = type3Function.calculate(new double[] {7}); - Assert.assertArrayEquals(new double[] {0}, output, EPSILON); + Assertions.assertArrayEquals(new double[] {0}, output, EPSILON); } @Test @@ -246,7 +245,7 @@ public void calculateInputClipByFuncTest() { double[] output = type3Function.calculate(new double[] {0.1}); // input value 0.1 was passed to first function with domain [2, 3], so value was clipped to 2 from 0.1 - Assert.assertArrayEquals(new double[] {4}, output, EPSILON); + Assertions.assertArrayEquals(new double[] {4}, output, EPSILON); } @Test @@ -258,7 +257,7 @@ public void calculateInputValueEqualBoundsTest() { double[] output = type3Function.calculate(new double[] {0.5}); // Input value 0.5 was passed to second function. // Subdomain is [0.5, 1], encode is [0, 1], so value 0.5 was encoded to 0. - Assert.assertArrayEquals(new double[] {-3}, output, EPSILON); + Assertions.assertArrayEquals(new double[] {-3}, output, EPSILON); } @Test @@ -269,7 +268,7 @@ public void calculateInputValueNotEqualBoundsTest() { double[] output = type3Function.calculate(new double[] {0.53}); // Input value 0.53 was passed to second function. // Subdomain is [0.5, 1], encode is [0, 1], so value 0.53 was encoded to 0.06. - Assert.assertArrayEquals(new double[] {0.06}, output, EPSILON); + Assertions.assertArrayEquals(new double[] {0.06}, output, EPSILON); } @Test @@ -278,7 +277,7 @@ public void calculateInputValueEqualDomainTest() { PdfType3Function type3Function = new PdfType3Function(type3FuncDict); double[] output = type3Function.calculate(new double[] {1}); - Assert.assertArrayEquals(new double[] {1}, output, EPSILON); + Assertions.assertArrayEquals(new double[] {1}, output, EPSILON); } @Test @@ -295,7 +294,7 @@ public void calculateWith3FunctionsTest() { double[] output = type3Function.calculate(new double[] {0.52}); // Input value 0.52 was passed to second function. // Subdomain is [0.5, 0.7], encode is [0, 1], so value 0.52 was encoded to 0.1. - Assert.assertArrayEquals(new double[] {0.001}, output, EPSILON); + Assertions.assertArrayEquals(new double[] {0.001}, output, EPSILON); } @Test @@ -304,12 +303,12 @@ public void calculateReverseEncodingTest() { type3FuncDict.put(PdfName.Encode, new PdfArray(new double[] {0, 1, 1, 0})); PdfType3Function type3Function = new PdfType3Function(type3FuncDict); - Assert.assertArrayEquals(new double[] {0, 1, 1, 0}, type3Function.getEncode(), EPSILON); + Assertions.assertArrayEquals(new double[] {0, 1, 1, 0}, type3Function.getEncode(), EPSILON); double[] output = type3Function.calculate(new double[] {1}); // Input value 1 was passed to second function. // Subdomain is [0.5, 1], encode is [1, 0], so value 1 was encoded to 0. - Assert.assertArrayEquals(new double[] {0}, output, EPSILON); + Assertions.assertArrayEquals(new double[] {0}, output, EPSILON); } @Test @@ -320,7 +319,7 @@ public void calculateOneFunctionTest() { PdfType3Function type3Function = new PdfType3Function(type3FuncDict); double[] output = type3Function.calculate(new double[] {0.6}); - Assert.assertArrayEquals(new double[] {0.36}, output, EPSILON); + Assertions.assertArrayEquals(new double[] {0.36}, output, EPSILON); } @Test @@ -333,15 +332,15 @@ public void calculateBoundsEqualLeftDomainTest() { double[] output = type3Function.calculate(new double[] {0}); // first function was used - Assert.assertArrayEquals(new double[] {-3}, output, EPSILON); + Assertions.assertArrayEquals(new double[] {-3}, output, EPSILON); output = type3Function.calculate(new double[] {0.1}); // second function was used - Assert.assertArrayEquals(new double[] {0.5}, output, EPSILON); + Assertions.assertArrayEquals(new double[] {0.5}, output, EPSILON); output = type3Function.calculate(new double[] {1}); // second function was used - Assert.assertArrayEquals(new double[] {5}, output, EPSILON); + Assertions.assertArrayEquals(new double[] {5}, output, EPSILON); } @Test @@ -354,15 +353,15 @@ public void calculateBoundsEqualRightDomainTest() { double[] output = type3Function.calculate(new double[] {0}); // first function was used - Assert.assertArrayEquals(new double[] {0}, output, EPSILON); + Assertions.assertArrayEquals(new double[] {0}, output, EPSILON); output = type3Function.calculate(new double[] {0.1}); // first function was used - Assert.assertArrayEquals(new double[] {-0.03}, output, EPSILON); + Assertions.assertArrayEquals(new double[] {-0.03}, output, EPSILON); output = type3Function.calculate(new double[] {1}); // second function was used - Assert.assertArrayEquals(new double[] {5}, output, EPSILON); + Assertions.assertArrayEquals(new double[] {5}, output, EPSILON); } @Test @@ -380,19 +379,19 @@ public void calculateBoundsEqualLeftDomainWith3FuncTest() { double[] output = type3Function.calculate(new double[] {0}); // first function was used - Assert.assertArrayEquals(new double[] {-3}, output, EPSILON); + Assertions.assertArrayEquals(new double[] {-3}, output, EPSILON); output = type3Function.calculate(new double[] {0.1}); // second function was used - Assert.assertArrayEquals(new double[] {1}, output, EPSILON); + Assertions.assertArrayEquals(new double[] {1}, output, EPSILON); output = type3Function.calculate(new double[] {0.6}); // third function was used - Assert.assertArrayEquals(new double[] {-0.4}, output, EPSILON); + Assertions.assertArrayEquals(new double[] {-0.4}, output, EPSILON); output = type3Function.calculate(new double[] {1}); // third function was used - Assert.assertArrayEquals(new double[] {-2}, output, EPSILON); + Assertions.assertArrayEquals(new double[] {-2}, output, EPSILON); } private static PdfDictionary createMinimalPdfType3FunctionDict() { diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/function/utils/SampleExtractorTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/function/utils/SampleExtractorTest.java index 60dbe85ad2..3cd96ac009 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/function/utils/SampleExtractorTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/function/utils/SampleExtractorTest.java @@ -23,18 +23,15 @@ This file is part of the iText (R) project. package com.itextpdf.kernel.pdf.function.utils; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.util.Arrays; import java.util.Collection; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(Parameterized.class) -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class SampleExtractorTest extends ExtendedITextTest { private static final String PARAMETERS_NAME_PATTERN = "{0}bitsPerSample"; @@ -42,7 +39,6 @@ public class SampleExtractorTest extends ExtendedITextTest { private static final byte[] SAMPLES = {0x01, 0x23, 0x45, 0x67, (byte) 0x89, (byte) 0xab, (byte) 0xcd, (byte) 0xef}; - @Parameterized.Parameters(name = PARAMETERS_NAME_PATTERN) public static Collection samplesInfo() { return Arrays.asList(new Object[][] { {1, new long[] { @@ -92,25 +88,18 @@ public static Collection samplesInfo() { }); } - private final int bitsPerSample; - private final long[] expected; - - public SampleExtractorTest(Object bitsPerSample, Object expected) { - this.bitsPerSample = (int) bitsPerSample; - this.expected = (long[]) expected; - } - - @Test - public void testSamplesExtraction() { + @ParameterizedTest(name = PARAMETERS_NAME_PATTERN) + @MethodSource("samplesInfo") + public void testSamplesExtraction(int bitsPerSample, long[] expected) { long[] actual = new long[(SAMPLES.length << 3) / bitsPerSample]; - Assert.assertEquals(expected.length, actual.length); + Assertions.assertEquals(expected.length, actual.length); AbstractSampleExtractor extractor = AbstractSampleExtractor.createExtractor(bitsPerSample); for (int i = 0; i < actual.length; ++i) { actual[i] = extractor.extract(SAMPLES, i); } - Assert.assertArrayEquals(expected, actual); + Assertions.assertArrayEquals(expected, actual); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/layer/PdfLayerMembershipTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/layer/PdfLayerMembershipTest.java index d2aa5a804c..102a50a9b6 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/layer/PdfLayerMembershipTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/layer/PdfLayerMembershipTest.java @@ -33,29 +33,28 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.layer.PdfLayer; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; import java.util.List; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfLayerMembershipTest extends ExtendedITextTest{ public static final String sourceFolder = "./src/test/resources/com/itextpdf/kernel/pdf/layer/PdfLayerMembershipTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/kernel/pdf/layer/PdfLayerMembershipTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(destinationFolder); } @@ -83,7 +82,7 @@ public void enabledVisibilityPolicyAllOnTest() throws IOException, InterruptedEx pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + destPdf, + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + destPdf, sourceFolder + cmpPdf, destinationFolder)); } @@ -111,7 +110,7 @@ public void disabledVisibilityPolicyAllOnTest() throws IOException, InterruptedE pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + destPdf, + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + destPdf, sourceFolder + cmpPdf, destinationFolder)); } @@ -137,7 +136,7 @@ public void enabledVisibilityPolicyAllOffTest() throws IOException, InterruptedE PdfLayerTestUtils.addTextInsideLayer(layerMembershipAllOff, canvas, "visibilityPolicyAllOffTest", 200, 500); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + destPdf, + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + destPdf, sourceFolder + cmpPdf, destinationFolder)); } @@ -163,7 +162,7 @@ public void disabledVisibilityPolicyAllOffTest() throws IOException, Interrupted PdfLayerTestUtils.addTextInsideLayer(layerMembershipAllOff, canvas, "visibilityPolicyAllOffTest", 200, 500); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + destPdf, + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + destPdf, sourceFolder + cmpPdf, destinationFolder)); } @@ -190,7 +189,7 @@ public void enabledVisibilityPolicyAnyOnTest() throws IOException, InterruptedEx pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + destPdf, + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + destPdf, sourceFolder + cmpPdf, destinationFolder)); } @@ -218,7 +217,7 @@ public void disabledVisibilityPolicyAnyOnTest() throws IOException, InterruptedE pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + destPdf, + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + destPdf, sourceFolder + cmpPdf, destinationFolder)); } @@ -245,7 +244,7 @@ public void enabledVisibilityPolicyAnyOffTest() throws IOException, InterruptedE PdfLayerTestUtils.addTextInsideLayer(layerMembershipAnyOn, canvas, "visibilityPolicyAnyOffTest", 200, 500); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + destPdf, + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + destPdf, sourceFolder + cmpPdf, destinationFolder)); } @@ -271,7 +270,7 @@ public void disabledVisibilityPolicyAnyOffTest() throws IOException, Interrupted PdfLayerTestUtils.addTextInsideLayer(layerMembershipAnyOn, canvas, "visibilityPolicyAnyOffTest", 200, 500); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + destPdf, + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + destPdf, sourceFolder + cmpPdf, destinationFolder)); } @@ -310,7 +309,7 @@ public void enabledVisualExpressionTest01() throws IOException, InterruptedExcep PdfLayerTestUtils.addTextInsideLayer(layerMembershipAnyOn, canvas, "visualExpressionTest01", 200, 500); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + destPdf, + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + destPdf, sourceFolder + cmpPdf, destinationFolder)); } @@ -349,7 +348,7 @@ public void disabledVisualExpressionTest01() throws IOException, InterruptedExce PdfLayerTestUtils.addTextInsideLayer(layerMembershipAnyOn, canvas, "visualExpressionTest01", 200, 500); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + destPdf, + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + destPdf, sourceFolder + cmpPdf, destinationFolder)); } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/layer/PdfLayerTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/layer/PdfLayerTest.java index 7369976592..d9ebf8941d 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/layer/PdfLayerTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/layer/PdfLayerTest.java @@ -22,41 +22,57 @@ This file is part of the iText (R) project. */ package com.itextpdf.kernel.pdf.layer; +import com.itextpdf.commons.utils.MessageFormatUtil; import com.itextpdf.io.font.constants.StandardFonts; +import com.itextpdf.io.image.ImageData; +import com.itextpdf.io.image.ImageDataFactory; +import com.itextpdf.io.source.ByteArrayOutputStream; +import com.itextpdf.kernel.exceptions.KernelExceptionMessageConstant; +import com.itextpdf.kernel.exceptions.PdfException; import com.itextpdf.kernel.font.PdfFont; import com.itextpdf.kernel.font.PdfFontFactory; +import com.itextpdf.kernel.geom.Rectangle; +import com.itextpdf.kernel.pdf.OcgPropertiesCopierTest; import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfName; +import com.itextpdf.kernel.pdf.PdfPage; import com.itextpdf.kernel.pdf.PdfReader; +import com.itextpdf.kernel.pdf.PdfResources; import com.itextpdf.kernel.pdf.PdfWriter; +import com.itextpdf.kernel.pdf.annot.PdfAnnotation; +import com.itextpdf.kernel.pdf.annot.PdfTextAnnotation; import com.itextpdf.kernel.pdf.canvas.PdfCanvas; +import com.itextpdf.kernel.pdf.PdfIndirectReference; +import com.itextpdf.kernel.pdf.xobject.PdfFormXObject; +import com.itextpdf.kernel.pdf.xobject.PdfImageXObject; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import java.util.Set; -@Category(IntegrationTest.class) +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; + +@Tag("IntegrationTest") public class PdfLayerTest extends ExtendedITextTest { public static final String destinationFolder = "./target/test/com/itextpdf/kernel/pdf/layer/PdfLayerTest/"; public static final String sourceFolder = "./src/test/resources/com/itextpdf/kernel/pdf/layer/PdfLayerTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(destinationFolder); } @@ -67,7 +83,7 @@ public void layerDefaultIntents() { Collection defaultIntents = pdfLayer.getIntents(); - Assert.assertArrayEquals(new PdfName[] {PdfName.View}, defaultIntents.toArray(new PdfName[1])); + Assertions.assertArrayEquals(new PdfName[] {PdfName.View}, defaultIntents.toArray(new PdfName[1])); } @Test @@ -76,7 +92,7 @@ public void layerSetSingleIntent() { Collection defaultIntents = pdfLayer.getIntents(); - Assert.assertArrayEquals(new PdfName[] {PdfName.Design}, defaultIntents.toArray(new PdfName[1])); + Assertions.assertArrayEquals(new PdfName[] {PdfName.Design}, defaultIntents.toArray(new PdfName[1])); } @Test @@ -86,7 +102,7 @@ public void layerSetSeveralIntents() { Collection defaultIntents = pdfLayer.getIntents(); - Assert.assertArrayEquals(new PdfName[] {PdfName.Design, custom}, defaultIntents.toArray(new PdfName[2])); + Assertions.assertArrayEquals(new PdfName[] {PdfName.Design, custom}, defaultIntents.toArray(new PdfName[2])); } @Test @@ -97,7 +113,7 @@ public void layerSetIntentsNull() { pdfLayer.setIntents(null); Collection postNullIntents = pdfLayer.getIntents(); - Assert.assertArrayEquals(new PdfName[] {PdfName.View}, postNullIntents.toArray(new PdfName[1])); + Assertions.assertArrayEquals(new PdfName[] {PdfName.View}, postNullIntents.toArray(new PdfName[1])); } @Test @@ -108,7 +124,7 @@ public void layerSetIntentsEmpty() { pdfLayer.setIntents(Collections.emptyList()); Collection postNullIntents = pdfLayer.getIntents(); - Assert.assertArrayEquals(new PdfName[] {PdfName.View}, postNullIntents.toArray(new PdfName[1])); + Assertions.assertArrayEquals(new PdfName[] {PdfName.View}, postNullIntents.toArray(new PdfName[1])); } @@ -286,7 +302,7 @@ public void ocConfigUniqueName() throws IOException { // start of test assertion logic PdfDocument resPdf = new PdfDocument(CompareTool.createOutputReader(outPdf)); PdfDictionary d = resPdf.getCatalog().getPdfObject().getAsDictionary(PdfName.OCProperties).getAsDictionary(PdfName.D); - Assert.assertEquals(PdfOCProperties.OC_CONFIG_NAME_PATTERN + "2", d.getAsString(PdfName.Name).toUnicodeString()); + Assertions.assertEquals(PdfOCProperties.OC_CONFIG_NAME_PATTERN + "2", d.getAsString(PdfName.Name).toUnicodeString()); PdfLayerTestUtils.compareLayers(outPdf, cmpPdf); } @@ -409,7 +425,7 @@ public void testInStamperMode1() throws IOException, InterruptedException { PdfDocument pdfDoc = new PdfDocument(new PdfReader(sourceFolder + "input_layered.pdf"), CompareTool.createTestPdfWriter(destinationFolder + "output_copy_layered.pdf")); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "output_copy_layered.pdf", sourceFolder + "cmp_output_copy_layered.pdf", destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "output_copy_layered.pdf", sourceFolder + "cmp_output_copy_layered.pdf", destinationFolder, "diff")); } @Test @@ -433,7 +449,147 @@ public void testInStamperMode2() throws IOException, InterruptedException { } pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "output_layered.pdf", sourceFolder + "cmp_output_layered.pdf", destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "output_layered.pdf", sourceFolder + "cmp_output_layered.pdf", destinationFolder, "diff")); + } + + @Test + public void testReadAllLayersFromPage1() throws IOException, InterruptedException { + PdfDocument pdfDoc = new PdfDocument(new PdfReader(sourceFolder + "input_layered.pdf"), + CompareTool.createTestPdfWriter(destinationFolder + "output_layered_2.pdf")); + + PdfCanvas canvas = new PdfCanvas(pdfDoc, 1); + + //create layer on page + PdfLayer newLayer = new PdfLayer("appended", pdfDoc); + canvas.setFontAndSize(PdfFontFactory.createFont(StandardFonts.HELVETICA), 18); + PdfLayerTestUtils.addTextInsideLayer(newLayer, canvas, "APPENDED CONTENT", 200, 600); + + List layersFromCatalog = pdfDoc.getCatalog().getOCProperties(true).getLayers(); + Assertions.assertEquals(13, layersFromCatalog.size()); + PdfPage page = pdfDoc.getPage(1); + Set layersFromPage = page.getPdfLayers(); + Assertions.assertEquals(11, layersFromPage.size()); + + pdfDoc.close(); + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "output_layered_2.pdf", sourceFolder + "cmp_output_layered_2.pdf", destinationFolder, "diff")); + } + + @Test + public void testReadAllLayersFromDocumentWithComplexOCG() throws IOException, InterruptedException { + PdfDocument pdfDoc = new PdfDocument(new PdfReader(sourceFolder + "input_complex_layers.pdf"), + CompareTool.createTestPdfWriter(destinationFolder + "output_complex_layers.pdf")); + + List layersFromCatalog = pdfDoc.getCatalog().getOCProperties(true).getLayers(); + Assertions.assertEquals(12, layersFromCatalog.size()); + PdfPage page = pdfDoc.getPage(1); + Set layersFromPage = page.getPdfLayers(); + Assertions.assertEquals(10, layersFromPage.size()); + pdfDoc.close(); + } + + + //Read OCGs from different locations (annotations, content streams, xObjects) test block + + @Test + public void testReadOcgFromStreamProperties() throws IOException { + try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) { + try (PdfDocument document = new PdfDocument(new PdfWriter(outputStream))) { + PdfPage page = document.addNewPage(); + + PdfResources pdfResource = page.getResources(); + pdfResource.addProperties(new PdfLayer("name", document).getPdfObject()); + pdfResource.makeIndirect(document); + + Set layersFromPage = page.getPdfLayers(); + Assertions.assertEquals(1, layersFromPage.size()); + } + } + } + + @Test + public void testReadOcgFromAnnotation() throws IOException { + try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) { + try (PdfDocument fromDocument = new PdfDocument(new PdfWriter(outputStream))) { + PdfPage page = fromDocument.addNewPage(); + PdfAnnotation annotation = new PdfTextAnnotation(new Rectangle(50, 10)); + annotation.setLayer(new PdfLayer("name", fromDocument)); + page.addAnnotation(annotation); + + Set layersFromPage = page.getPdfLayers(); + Assertions.assertEquals(1, layersFromPage.size()); + } + } } + @Test + public void testReadOcgFromFlushedAnnotation() throws IOException { + try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) { + try (PdfDocument fromDocument = new PdfDocument(new PdfWriter(outputStream))) { + PdfPage page = fromDocument.addNewPage(); + PdfAnnotation annotation = new PdfTextAnnotation(new Rectangle(50, 10)); + annotation.setLayer(new PdfLayer("name", fromDocument)); + page.addAnnotation(annotation); + annotation.flush(); + + Set layersFromPage = page.getPdfLayers(); + Assertions.assertEquals(1, layersFromPage.size()); + } + } + } + + @Test + public void testReadOcgFromApAnnotation() throws IOException { + try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) { + try (PdfDocument fromDocument = new PdfDocument(new PdfWriter(outputStream))) { + PdfPage page = fromDocument.addNewPage(); + + PdfAnnotation annotation = new PdfTextAnnotation(new Rectangle(50, 10)); + + PdfFormXObject formXObject = new PdfFormXObject(new Rectangle(50, 10)); + formXObject.setLayer(new PdfLayer("someName1", fromDocument)); + formXObject.makeIndirect(fromDocument); + PdfDictionary nDict = new PdfDictionary(); + nDict.put(PdfName.ON, formXObject.getPdfObject()); + annotation.setAppearance(PdfName.N, nDict); + + formXObject = new PdfFormXObject(new Rectangle(50, 10)); + formXObject.setLayer(new PdfLayer("someName2", fromDocument)); + PdfResources formResources = formXObject.getResources(); + formResources.addProperties(new PdfLayer("someName3", fromDocument).getPdfObject()); + formXObject.makeIndirect(fromDocument); + PdfDictionary rDict = new PdfDictionary(); + rDict.put(PdfName.OFF, formXObject.getPdfObject()); + annotation.setAppearance(PdfName.R, rDict); + + formXObject = new PdfFormXObject(new Rectangle(50, 10)); + formXObject.setLayer(new PdfLayer("someName4", fromDocument)); + formXObject.makeIndirect(fromDocument); + annotation.setAppearance(PdfName.D, formXObject.getPdfObject()); + + page.addAnnotation(annotation); + + Set layersFromPage = page.getPdfLayers(); + Assertions.assertEquals(4, layersFromPage.size()); + } + } + } + + //TODO DEVSIX-8490 remove this test when implemented + @Test + public void addSecondParentlayerTest() throws IOException { + try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) { + try (PdfDocument doc = new PdfDocument(new PdfWriter(outputStream))) { + PdfLayer childLayer = new PdfLayer("childLayer", doc); + PdfLayer parentLayer1 = new PdfLayer("firstParentLayer", doc); + PdfLayer parentLayer2 = new PdfLayer("secondParentLayer", doc); + + parentLayer1.addChild(childLayer); + PdfIndirectReference ref = childLayer.getIndirectReference(); + Exception e = Assertions.assertThrows(PdfException.class, () -> parentLayer2.addChild(childLayer)); + Assertions.assertEquals(MessageFormatUtil.format( + KernelExceptionMessageConstant.UNABLE_TO_ADD_SECOND_PARENT_LAYER + , ref.toString()), e.getMessage()); + } + } + } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/layer/PdfLayerTestUtils.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/layer/PdfLayerTestUtils.java index 398527e802..eae58217fb 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/layer/PdfLayerTestUtils.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/layer/PdfLayerTestUtils.java @@ -34,7 +34,7 @@ This file is part of the iText (R) project. import java.io.IOException; import java.util.Arrays; import java.util.Collections; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; class PdfLayerTestUtils { @@ -77,7 +77,7 @@ static void compareLayers(String outPdf, String cmpPdf) throws IOException { try (PdfDocument cmpDoc = new PdfDocument(CompareTool.createOutputReader(cmpPdf))) { PdfDictionary outOCP = outDoc.getCatalog().getPdfObject().getAsDictionary(PdfName.OCProperties); PdfDictionary cmpOCP = cmpDoc.getCatalog().getPdfObject().getAsDictionary(PdfName.OCProperties); - Assert.assertNull(new CompareTool().compareDictionariesStructure(outOCP, cmpOCP)); + Assertions.assertNull(new CompareTool().compareDictionariesStructure(outOCP, cmpOCP)); } } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/layer/PdfOCPropertiesUnitTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/layer/PdfOCPropertiesUnitTest.java new file mode 100644 index 0000000000..a41d1ec837 --- /dev/null +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/layer/PdfOCPropertiesUnitTest.java @@ -0,0 +1,127 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.pdf.layer; + +import com.itextpdf.commons.utils.MessageFormatUtil; +import com.itextpdf.io.source.ByteArrayOutputStream; +import com.itextpdf.kernel.exceptions.KernelExceptionMessageConstant; +import com.itextpdf.kernel.exceptions.PdfException; +import com.itextpdf.kernel.pdf.*; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +import java.io.ByteArrayInputStream; +import java.io.IOException; + +@Tag("UnitTest") +public class PdfOCPropertiesUnitTest { + + //TODO DEVSIX-8490 remove this test when implemented + @Test + public void removeOrderDuplicatesTest() throws IOException { + byte[] docBytes; + try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) { + try (PdfDocument document = new PdfDocument(new PdfWriter(outputStream))) { + PdfDictionary ocgDic = new PdfDictionary(); + ocgDic.makeIndirect(document); + PdfArray orderArray = new PdfArray(); + for (int i = 0; i < 3; i++) { + orderArray.add(ocgDic); + } + + PdfDictionary ocgDic2 = new PdfDictionary(); + ocgDic.makeIndirect(document); + for (int i = 0; i < 3; i++) { + PdfArray layerArray = new PdfArray(); + layerArray.add(new PdfString("layerName" + i)); + layerArray.add(ocgDic2); + orderArray.add(layerArray); + } + + PdfDictionary DDictionary = new PdfDictionary(); + DDictionary.put(PdfName.Order, orderArray); + PdfArray OCGsArray = new PdfArray(); + OCGsArray.add(ocgDic); + OCGsArray.add(ocgDic2); + + PdfDictionary OCPropertiesDic = new PdfDictionary(); + OCPropertiesDic.put(PdfName.D, DDictionary); + OCPropertiesDic.put(PdfName.OCGs, OCGsArray); + document.getCatalog().getPdfObject().put(PdfName.OCProperties, OCPropertiesDic); + + document.getCatalog().getOCProperties(false); + + } + docBytes = outputStream.toByteArray(); + } + + try (PdfDocument docReopen = new PdfDocument(new PdfReader(new ByteArrayInputStream(docBytes)))) { + PdfArray resultArray = docReopen.getCatalog().getPdfObject().getAsDictionary(PdfName.OCProperties) + .getAsDictionary(PdfName.D).getAsArray(PdfName.Order); + Assertions.assertEquals(2, resultArray.size()); + } + } + + //TODO DEVSIX-8490 remove this test when implemented + @Test + public void removeOrderDuplicateHasChildTest() throws IOException { + try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) { + try (PdfDocument document = new PdfDocument(new PdfWriter(outputStream))) { + PdfDictionary ocgDic = new PdfDictionary(); + PdfDictionary ocgDicChild1 = new PdfDictionary(); + PdfDictionary ocgDicChild2 = new PdfDictionary(); + ocgDic.makeIndirect(document); + + PdfArray orderArray = new PdfArray(); + PdfArray childArray1 = new PdfArray(); + childArray1.add(ocgDicChild1); + PdfArray childArray2 = new PdfArray(); + childArray2.add(ocgDicChild2); + + orderArray.add(ocgDic); + orderArray.add(childArray1); + orderArray.add(ocgDic); + orderArray.add(childArray2); + + PdfDictionary DDictionary = new PdfDictionary(); + DDictionary.put(PdfName.Order, orderArray); + PdfArray OCGsArray = new PdfArray(); + OCGsArray.add(ocgDic); + OCGsArray.add(ocgDicChild1); + OCGsArray.add(ocgDicChild2); + + PdfDictionary OCPropertiesDic = new PdfDictionary(); + OCPropertiesDic.put(PdfName.D, DDictionary); + OCPropertiesDic.put(PdfName.OCGs, OCGsArray); + document.getCatalog().getPdfObject().put(PdfName.OCProperties, OCPropertiesDic); + + PdfIndirectReference ref = ocgDic.getIndirectReference(); + PdfCatalog catalog = document.getCatalog(); + Exception e = Assertions.assertThrows(PdfException.class, () -> catalog.getOCProperties(false)); + Assertions.assertEquals(MessageFormatUtil.format( + KernelExceptionMessageConstant.UNABLE_TO_REMOVE_DUPLICATE_LAYER, ref.toString()), e.getMessage()); + } + } + } +} diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/layer/PdfVisibilityExpressionTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/layer/PdfVisibilityExpressionTest.java index c4c20aa0dc..182621c373 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/layer/PdfVisibilityExpressionTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/layer/PdfVisibilityExpressionTest.java @@ -29,15 +29,14 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfObject; import com.itextpdf.kernel.pdf.PdfWriter; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.ByteArrayOutputStream; import java.io.IOException; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfVisibilityExpressionTest extends ExtendedITextTest { @Test @@ -57,9 +56,9 @@ public void expressionByArrayTest() { PdfVisibilityExpression expression = new PdfVisibilityExpression(array); PdfObject expressionObject = expression.getPdfObject(); - Assert.assertTrue(expressionObject instanceof PdfArray); - Assert.assertEquals(3, ((PdfArray) expressionObject).size()); - Assert.assertEquals(PdfName.And, ((PdfArray) expressionObject).getAsName(0)); + Assertions.assertTrue(expressionObject instanceof PdfArray); + Assertions.assertEquals(3, ((PdfArray) expressionObject).size()); + Assertions.assertEquals(PdfName.And, ((PdfArray) expressionObject).getAsName(0)); } @Test @@ -74,9 +73,9 @@ public void andExpressionTest() { expression.addOperand(new PdfLayer((PdfDictionary) new PdfDictionary().makeIndirect(tempDoc))); PdfObject expressionObject = expression.getPdfObject(); - Assert.assertTrue(expressionObject instanceof PdfArray); - Assert.assertEquals(3, ((PdfArray) expressionObject).size()); - Assert.assertEquals(PdfName.And, ((PdfArray) expressionObject).getAsName(0)); + Assertions.assertTrue(expressionObject instanceof PdfArray); + Assertions.assertEquals(3, ((PdfArray) expressionObject).size()); + Assertions.assertEquals(PdfName.And, ((PdfArray) expressionObject).getAsName(0)); } @Test @@ -98,14 +97,14 @@ public void nestedExpressionTest() { expression.addOperand(nestedExpression); PdfObject expressionObject = expression.getPdfObject(); - Assert.assertTrue(expressionObject instanceof PdfArray); - Assert.assertEquals(3, ((PdfArray) expressionObject).size()); - Assert.assertEquals(PdfName.Or, ((PdfArray) expressionObject).getAsName(0)); + Assertions.assertTrue(expressionObject instanceof PdfArray); + Assertions.assertEquals(3, ((PdfArray) expressionObject).size()); + Assertions.assertEquals(PdfName.Or, ((PdfArray) expressionObject).getAsName(0)); PdfObject child = ((PdfArray) expressionObject).get(2); - Assert.assertTrue(child instanceof PdfArray); - Assert.assertEquals(3, ((PdfArray) child).size()); - Assert.assertEquals(PdfName.And, ((PdfArray) child).get(0)); + Assertions.assertTrue(child instanceof PdfArray); + Assertions.assertEquals(3, ((PdfArray) child).size()); + Assertions.assertEquals(PdfName.And, ((PdfArray) child).get(0)); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/statistics/NumberOfPagesStatisticsTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/statistics/NumberOfPagesStatisticsTest.java index b7baaa36fd..7871fb6d67 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/statistics/NumberOfPagesStatisticsTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/statistics/NumberOfPagesStatisticsTest.java @@ -30,30 +30,29 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfReader; import com.itextpdf.kernel.pdf.PdfWriter; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; import java.util.ArrayList; import java.util.List; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class NumberOfPagesStatisticsTest extends ExtendedITextTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/kernel/pdf/statistics/NumberOfPagesStatisticsTest/"; private static NumberOfPagesStatisticsHandler handler = new NumberOfPagesStatisticsHandler(); - @Before + @BeforeEach public void registerHandler() { EventManager.getInstance().register(handler); } - @After + @AfterEach public void unregisterHandler() { EventManager.getInstance().unregister(handler); handler.clearNumberOfPagesEvents(); @@ -67,8 +66,8 @@ public void pdfDocumentWithWriterTest() { List numberOfPagesEvents = handler.getNumberOfPagesEvents(); - Assert.assertEquals(1, numberOfPagesEvents.size()); - Assert.assertEquals(1, numberOfPagesEvents.get(0).getNumberOfPages()); + Assertions.assertEquals(1, numberOfPagesEvents.size()); + Assertions.assertEquals(1, numberOfPagesEvents.get(0).getNumberOfPages()); } @Test @@ -80,19 +79,19 @@ public void pdfDocumentWithWriterAndReaderTest() throws IOException { List numberOfPagesEvents = handler.getNumberOfPagesEvents(); - Assert.assertEquals(1, numberOfPagesEvents.size()); - Assert.assertEquals(2, numberOfPagesEvents.get(0).getNumberOfPages()); + Assertions.assertEquals(1, numberOfPagesEvents.size()); + Assertions.assertEquals(2, numberOfPagesEvents.get(0).getNumberOfPages()); } @Test public void pdfDocumentWithReaderTest() throws IOException { try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "document.pdf"))) { - Assert.assertNotNull(document.getPage(1)); + Assertions.assertNotNull(document.getPage(1)); } List numberOfPagesEvents = handler.getNumberOfPagesEvents(); - Assert.assertTrue(numberOfPagesEvents.isEmpty()); + Assertions.assertTrue(numberOfPagesEvents.isEmpty()); } @Test @@ -113,10 +112,10 @@ public void severalPdfDocumentsTest() { List numberOfPagesEvents = handler.getNumberOfPagesEvents(); - Assert.assertEquals(3, numberOfPagesEvents.size()); - Assert.assertEquals(100, numberOfPagesEvents.get(0).getNumberOfPages()); - Assert.assertEquals(10, numberOfPagesEvents.get(1).getNumberOfPages()); - Assert.assertEquals(1, numberOfPagesEvents.get(2).getNumberOfPages()); + Assertions.assertEquals(3, numberOfPagesEvents.size()); + Assertions.assertEquals(100, numberOfPagesEvents.get(0).getNumberOfPages()); + Assertions.assertEquals(10, numberOfPagesEvents.get(1).getNumberOfPages()); + Assertions.assertEquals(1, numberOfPagesEvents.get(2).getNumberOfPages()); } private static class NumberOfPagesStatisticsHandler implements IEventHandler { diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/statistics/NumberOfPagesStatisticsUnitTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/statistics/NumberOfPagesStatisticsUnitTest.java index ebe7b7bcef..307d61c7ac 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/statistics/NumberOfPagesStatisticsUnitTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/statistics/NumberOfPagesStatisticsUnitTest.java @@ -29,33 +29,32 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.UnitTest; import java.util.Collections; import java.util.Map; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class NumberOfPagesStatisticsUnitTest extends ExtendedITextTest { @Test public void defaultEventTest() { NumberOfPagesStatisticsEvent event = new NumberOfPagesStatisticsEvent(1, ITextCoreProductData.getInstance()); - Assert.assertEquals(1, event.getNumberOfPages()); - Assert.assertEquals(Collections.singletonList("numberOfPages"), event.getStatisticsNames()); - Assert.assertEquals(NumberOfPagesStatisticsAggregator.class, event.createStatisticsAggregatorFromName("numberOfPages").getClass()); + Assertions.assertEquals(1, event.getNumberOfPages()); + Assertions.assertEquals(Collections.singletonList("numberOfPages"), event.getStatisticsNames()); + Assertions.assertEquals(NumberOfPagesStatisticsAggregator.class, event.createStatisticsAggregatorFromName("numberOfPages").getClass()); } @Test public void invalidArgumentEventTest() { Exception exception = - Assert.assertThrows( + Assertions.assertThrows( IllegalStateException.class, () -> new NumberOfPagesStatisticsEvent(-1, ITextCoreProductData.getInstance())); - Assert.assertEquals(KernelExceptionMessageConstant.NUMBER_OF_PAGES_CAN_NOT_BE_NEGATIVE, exception.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.NUMBER_OF_PAGES_CAN_NOT_BE_NEGATIVE, exception.getMessage()); } @Test @@ -71,17 +70,17 @@ public void aggregateZeroPageEventTest() { Object aggregation = aggregator.retrieveAggregation(); Map castedAggregation = (Map) aggregation; - Assert.assertEquals(1, castedAggregation.size()); + Assertions.assertEquals(1, castedAggregation.size()); Long numberOfPages = castedAggregation.get("1"); - Assert.assertEquals(new Long(1L), numberOfPages); + Assertions.assertEquals(new Long(1L), numberOfPages); } @Test @LogMessages(messages = @LogMessage(messageTemplate = CommonsLogMessageConstant.INVALID_STATISTICS_NAME)) public void invalidStatisticsNameEventTest() { NumberOfPagesStatisticsEvent event = new NumberOfPagesStatisticsEvent(5, ITextCoreProductData.getInstance()); - Assert.assertNull(event.createStatisticsAggregatorFromName("invalid name")); + Assertions.assertNull(event.createStatisticsAggregatorFromName("invalid name")); } @Test @@ -108,21 +107,21 @@ public void aggregateEventTest() { Object aggregation = aggregator.retrieveAggregation(); Map castedAggregation = (Map) aggregation; - Assert.assertEquals(4, castedAggregation.size()); + Assertions.assertEquals(4, castedAggregation.size()); Long numberOfPages = castedAggregation.get("1"); - Assert.assertEquals(new Long(1L), numberOfPages); + Assertions.assertEquals(new Long(1L), numberOfPages); numberOfPages = castedAggregation.get("2-10"); - Assert.assertEquals(new Long(4L), numberOfPages); + Assertions.assertEquals(new Long(4L), numberOfPages); - Assert.assertNull(castedAggregation.get("11-100")); + Assertions.assertNull(castedAggregation.get("11-100")); numberOfPages = castedAggregation.get("101-1000"); - Assert.assertEquals(new Long(2L), numberOfPages); + Assertions.assertEquals(new Long(2L), numberOfPages); numberOfPages = castedAggregation.get("1001+"); - Assert.assertEquals(new Long(1L), numberOfPages); + Assertions.assertEquals(new Long(1L), numberOfPages); } @Test @@ -131,7 +130,7 @@ public void nothingAggregatedTest() { Object aggregation = aggregator.retrieveAggregation(); Map castedAggregation = (Map) aggregation; - Assert.assertTrue(castedAggregation.isEmpty()); + Assertions.assertTrue(castedAggregation.isEmpty()); } @Test @@ -142,7 +141,7 @@ public void aggregateWrongEventTest() { Object aggregation = aggregator.retrieveAggregation(); Map castedAggregation = (Map) aggregation; - Assert.assertTrue(castedAggregation.isEmpty()); + Assertions.assertTrue(castedAggregation.isEmpty()); } @Test @@ -173,20 +172,20 @@ public void mergeTest() { Object aggregation = aggregator1.retrieveAggregation(); Map castedAggregation = (Map) aggregation; - Assert.assertEquals(4, castedAggregation.size()); + Assertions.assertEquals(4, castedAggregation.size()); Long numberOfPages = castedAggregation.get("1"); - Assert.assertEquals(new Long(1L), numberOfPages); + Assertions.assertEquals(new Long(1L), numberOfPages); numberOfPages = castedAggregation.get("2-10"); - Assert.assertEquals(new Long(4L), numberOfPages); + Assertions.assertEquals(new Long(4L), numberOfPages); - Assert.assertNull(castedAggregation.get("11-100")); + Assertions.assertNull(castedAggregation.get("11-100")); numberOfPages = castedAggregation.get("101-1000"); - Assert.assertEquals(new Long(2L), numberOfPages); + Assertions.assertEquals(new Long(2L), numberOfPages); numberOfPages = castedAggregation.get("1001+"); - Assert.assertEquals(new Long(1L), numberOfPages); + Assertions.assertEquals(new Long(1L), numberOfPages); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/statistics/SizeOfPdfStatisticsTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/statistics/SizeOfPdfStatisticsTest.java index a177571fc7..db9ac2d5c2 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/statistics/SizeOfPdfStatisticsTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/statistics/SizeOfPdfStatisticsTest.java @@ -31,30 +31,29 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfReader; import com.itextpdf.kernel.pdf.PdfWriter; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; import java.util.ArrayList; import java.util.List; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class SizeOfPdfStatisticsTest extends ExtendedITextTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/kernel/pdf/statistics/SizeOfPdfStatisticsTest/"; private static SizeOfPdfStatisticsHandler handler = new SizeOfPdfStatisticsHandler(); - @Before + @BeforeEach public void registerHandler() { EventManager.getInstance().register(handler); } - @After + @AfterEach public void unregisterHandler() { EventManager.getInstance().unregister(handler); handler.clearSizeOfPdfEvents(); @@ -69,8 +68,8 @@ public void pdfDocumentWithWriterTest() { List sizeOfPdfEvents = handler.getSizeOfPdfEvents(); - Assert.assertEquals(1, sizeOfPdfEvents.size()); - Assert.assertEquals(outputStream.getAmountOfWrittenBytes(), sizeOfPdfEvents.get(0).getAmountOfBytes()); + Assertions.assertEquals(1, sizeOfPdfEvents.size()); + Assertions.assertEquals(outputStream.getAmountOfWrittenBytes(), sizeOfPdfEvents.get(0).getAmountOfBytes()); } @Test @@ -83,19 +82,19 @@ public void pdfDocumentWithWriterAndReaderTest() throws IOException { List sizeOfPdfEvents = handler.getSizeOfPdfEvents(); - Assert.assertEquals(1, sizeOfPdfEvents.size()); - Assert.assertEquals(outputStream.getAmountOfWrittenBytes(), sizeOfPdfEvents.get(0).getAmountOfBytes()); + Assertions.assertEquals(1, sizeOfPdfEvents.size()); + Assertions.assertEquals(outputStream.getAmountOfWrittenBytes(), sizeOfPdfEvents.get(0).getAmountOfBytes()); } @Test public void pdfDocumentWithReaderTest() throws IOException { try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "document.pdf"))) { - Assert.assertNotNull(document.getPage(1)); + Assertions.assertNotNull(document.getPage(1)); } List sizeOfPdfEvents = handler.getSizeOfPdfEvents(); - Assert.assertTrue(sizeOfPdfEvents.isEmpty()); + Assertions.assertTrue(sizeOfPdfEvents.isEmpty()); } @Test @@ -120,10 +119,10 @@ public void severalPdfDocumentsTest() { List sizeOfPdfEvents = handler.getSizeOfPdfEvents(); - Assert.assertEquals(3, sizeOfPdfEvents.size()); - Assert.assertEquals(outputStream1.getAmountOfWrittenBytes(), sizeOfPdfEvents.get(0).getAmountOfBytes()); - Assert.assertEquals(outputStream2.getAmountOfWrittenBytes(), sizeOfPdfEvents.get(1).getAmountOfBytes()); - Assert.assertEquals(outputStream3.getAmountOfWrittenBytes(), sizeOfPdfEvents.get(2).getAmountOfBytes()); + Assertions.assertEquals(3, sizeOfPdfEvents.size()); + Assertions.assertEquals(outputStream1.getAmountOfWrittenBytes(), sizeOfPdfEvents.get(0).getAmountOfBytes()); + Assertions.assertEquals(outputStream2.getAmountOfWrittenBytes(), sizeOfPdfEvents.get(1).getAmountOfBytes()); + Assertions.assertEquals(outputStream3.getAmountOfWrittenBytes(), sizeOfPdfEvents.get(2).getAmountOfBytes()); } private static class SizeOfPdfStatisticsHandler implements IEventHandler { diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/statistics/SizeOfPdfStatisticsUnitTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/statistics/SizeOfPdfStatisticsUnitTest.java index 635c005fe8..224f861d98 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/statistics/SizeOfPdfStatisticsUnitTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/statistics/SizeOfPdfStatisticsUnitTest.java @@ -29,38 +29,37 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.UnitTest; import java.util.Collections; import java.util.Map; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class SizeOfPdfStatisticsUnitTest extends ExtendedITextTest { @Test public void defaultEventTest() { SizeOfPdfStatisticsEvent event = new SizeOfPdfStatisticsEvent(0, ITextCoreProductData.getInstance()); - Assert.assertEquals(0, event.getAmountOfBytes()); - Assert.assertEquals(Collections.singletonList("pdfSize"), event.getStatisticsNames()); - Assert.assertEquals(SizeOfPdfStatisticsAggregator.class, event.createStatisticsAggregatorFromName("pdfSize").getClass()); + Assertions.assertEquals(0, event.getAmountOfBytes()); + Assertions.assertEquals(Collections.singletonList("pdfSize"), event.getStatisticsNames()); + Assertions.assertEquals(SizeOfPdfStatisticsAggregator.class, event.createStatisticsAggregatorFromName("pdfSize").getClass()); } @Test public void invalidArgumentEventTest() { Exception exception = - Assert.assertThrows(IllegalArgumentException.class, + Assertions.assertThrows(IllegalArgumentException.class, () -> new SizeOfPdfStatisticsEvent(-1, ITextCoreProductData.getInstance())); - Assert.assertEquals(KernelExceptionMessageConstant.AMOUNT_OF_BYTES_LESS_THAN_ZERO, exception.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.AMOUNT_OF_BYTES_LESS_THAN_ZERO, exception.getMessage()); } @Test @LogMessages(messages = @LogMessage(messageTemplate = CommonsLogMessageConstant.INVALID_STATISTICS_NAME)) public void invalidStatisticsNameEventTest() { SizeOfPdfStatisticsEvent event = new SizeOfPdfStatisticsEvent(5, ITextCoreProductData.getInstance()); - Assert.assertNull(event.createStatisticsAggregatorFromName("invalid name")); + Assertions.assertNull(event.createStatisticsAggregatorFromName("invalid name")); } @Test @@ -85,21 +84,21 @@ public void aggregateEventTest() { Object aggregation = aggregator.retrieveAggregation(); Map castedAggregation = (Map) aggregation; - Assert.assertEquals(4, castedAggregation.size()); + Assertions.assertEquals(4, castedAggregation.size()); Long numberOfPages = castedAggregation.get("<128kb"); - Assert.assertEquals(new Long(2L), numberOfPages); + Assertions.assertEquals(new Long(2L), numberOfPages); numberOfPages = castedAggregation.get("128kb-1mb"); - Assert.assertEquals(new Long(2L), numberOfPages); + Assertions.assertEquals(new Long(2L), numberOfPages); - Assert.assertNull(castedAggregation.get("1mb-16mb")); + Assertions.assertNull(castedAggregation.get("1mb-16mb")); numberOfPages = castedAggregation.get("16mb-128mb"); - Assert.assertEquals(new Long(1L), numberOfPages); + Assertions.assertEquals(new Long(1L), numberOfPages); numberOfPages = castedAggregation.get("128mb+"); - Assert.assertEquals(new Long(2L), numberOfPages); + Assertions.assertEquals(new Long(2L), numberOfPages); } @Test @@ -108,7 +107,7 @@ public void nothingAggregatedTest() { Object aggregation = aggregator.retrieveAggregation(); Map castedAggregation = (Map) aggregation; - Assert.assertTrue(castedAggregation.isEmpty()); + Assertions.assertTrue(castedAggregation.isEmpty()); } @Test @@ -119,7 +118,7 @@ public void aggregateWrongEventTest() { Object aggregation = aggregator.retrieveAggregation(); Map castedAggregation = (Map) aggregation; - Assert.assertTrue(castedAggregation.isEmpty()); + Assertions.assertTrue(castedAggregation.isEmpty()); } @Test @@ -148,20 +147,20 @@ public void mergeTest() { Object aggregation = aggregator1.retrieveAggregation(); Map castedAggregation = (Map) aggregation; - Assert.assertEquals(4, castedAggregation.size()); + Assertions.assertEquals(4, castedAggregation.size()); Long numberOfPages = castedAggregation.get("<128kb"); - Assert.assertEquals(new Long(2L), numberOfPages); + Assertions.assertEquals(new Long(2L), numberOfPages); numberOfPages = castedAggregation.get("128kb-1mb"); - Assert.assertEquals(new Long(2L), numberOfPages); + Assertions.assertEquals(new Long(2L), numberOfPages); - Assert.assertNull(castedAggregation.get("1mb-16mb")); + Assertions.assertNull(castedAggregation.get("1mb-16mb")); numberOfPages = castedAggregation.get("16mb-128mb"); - Assert.assertEquals(new Long(1L), numberOfPages); + Assertions.assertEquals(new Long(1L), numberOfPages); numberOfPages = castedAggregation.get("128mb+"); - Assert.assertEquals(new Long(2L), numberOfPages); + Assertions.assertEquals(new Long(2L), numberOfPages); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/tagging/PdfObjRefUnitTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/tagging/PdfObjRefUnitTest.java index a419c74e59..774aeb12cd 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/tagging/PdfObjRefUnitTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/tagging/PdfObjRefUnitTest.java @@ -24,12 +24,11 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.*; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfObjRefUnitTest extends ExtendedITextTest { @Test @@ -42,8 +41,8 @@ public void refObjAsStreamTest() { PdfObjRef objRef = new PdfObjRef(obj, new PdfStructElem(new PdfDictionary())); - Assert.assertTrue(objRef.getReferencedObject() instanceof PdfStream); - Assert.assertTrue(objRef.getReferencedObject().containsKey(PdfName.Name)); + Assertions.assertTrue(objRef.getReferencedObject() instanceof PdfStream); + Assertions.assertTrue(objRef.getReferencedObject().containsKey(PdfName.Name)); } @Test @@ -53,6 +52,6 @@ public void refObjAsInvalidTypeTest() { PdfObjRef objRef = new PdfObjRef(obj, new PdfStructElem(new PdfDictionary())); - Assert.assertNull(objRef.getReferencedObject()); + Assertions.assertNull(objRef.getReferencedObject()); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/tagging/PdfStructElemUnitTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/tagging/PdfStructElemUnitTest.java index 3554171ed7..bd76e31a34 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/tagging/PdfStructElemUnitTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/tagging/PdfStructElemUnitTest.java @@ -34,22 +34,21 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.annot.Pdf3DAnnotation; import com.itextpdf.kernel.pdf.annot.PdfAnnotation; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfStructElemUnitTest extends ExtendedITextTest { @Test public void noParentObjectTest() { PdfDictionary parent = new PdfDictionary(); PdfArray kid = new PdfArray(); - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> PdfStructElem.addKidObject(parent, 1, kid)); - Assert.assertEquals(KernelExceptionMessageConstant.STRUCTURE_ELEMENT_SHALL_CONTAIN_PARENT_OBJECT, + Assertions.assertEquals(KernelExceptionMessageConstant.STRUCTURE_ELEMENT_SHALL_CONTAIN_PARENT_OBJECT, exception.getMessage()); } @@ -58,9 +57,9 @@ public void annotationHasNoReferenceToPageTest() { PdfDocument pdfDoc = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); PdfName pdfName = new PdfName("test"); PdfAnnotation annotation = new Pdf3DAnnotation(new Rectangle(100, 100), pdfName); - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> new PdfStructElem(pdfDoc, pdfName, annotation)); - Assert.assertEquals(KernelExceptionMessageConstant.ANNOTATION_SHALL_HAVE_REFERENCE_TO_PAGE, + Assertions.assertEquals(KernelExceptionMessageConstant.ANNOTATION_SHALL_HAVE_REFERENCE_TO_PAGE, exception.getMessage()); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/tagging/StandardNamespacesTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/tagging/StandardNamespacesTest.java index 60303be1e6..3fa535de22 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/tagging/StandardNamespacesTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/tagging/StandardNamespacesTest.java @@ -23,13 +23,12 @@ This file is part of the iText (R) project. package com.itextpdf.kernel.pdf.tagging; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import static org.junit.Assert.*; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; +import static org.junit.jupiter.api.Assertions.*; -@Category(UnitTest.class) +@Tag("UnitTest") public class StandardNamespacesTest extends ExtendedITextTest { @Test diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/tagging/StructureTreeCopierUnitTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/tagging/StructureTreeCopierUnitTest.java index 6c111356f8..3b7fe3b69d 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/tagging/StructureTreeCopierUnitTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/tagging/StructureTreeCopierUnitTest.java @@ -26,15 +26,14 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfName; import com.itextpdf.kernel.pdf.PdfObject; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.util.HashMap; import java.util.Map; -@Category(UnitTest.class) +@Tag("UnitTest") public class StructureTreeCopierUnitTest extends ExtendedITextTest { private static final Map td = new HashMap<>(); @@ -52,7 +51,7 @@ public void shouldTableElementBeCopiedTdTrTest() { PdfDictionary obj = new PdfDictionary(td); PdfDictionary parent = new PdfDictionary(tr); - Assert.assertTrue(StructureTreeCopier.shouldTableElementBeCopied(obj, parent)); + Assertions.assertTrue(StructureTreeCopier.shouldTableElementBeCopied(obj, parent)); } @Test @@ -60,7 +59,7 @@ public void shouldTableElementBeCopiedThTrTest() { PdfDictionary obj = new PdfDictionary(th); PdfDictionary parent = new PdfDictionary(tr); - Assert.assertTrue(StructureTreeCopier.shouldTableElementBeCopied(obj, parent)); + Assertions.assertTrue(StructureTreeCopier.shouldTableElementBeCopied(obj, parent)); } @Test @@ -68,7 +67,7 @@ public void shouldTableElementBeCopiedTdTdTest() { PdfDictionary obj = new PdfDictionary(td); PdfDictionary parent = new PdfDictionary(td); - Assert.assertFalse(StructureTreeCopier.shouldTableElementBeCopied(obj, parent)); + Assertions.assertFalse(StructureTreeCopier.shouldTableElementBeCopied(obj, parent)); } @Test @@ -76,7 +75,7 @@ public void shouldTableElementBeCopiedTrTdTest() { PdfDictionary obj = new PdfDictionary(tr); PdfDictionary parent = new PdfDictionary(td); - Assert.assertTrue(StructureTreeCopier.shouldTableElementBeCopied(obj, parent)); + Assertions.assertTrue(StructureTreeCopier.shouldTableElementBeCopied(obj, parent)); } @Test @@ -84,7 +83,7 @@ public void shouldTableElementBeCopiedTrTrTest() { PdfDictionary obj = new PdfDictionary(tr); PdfDictionary parent = new PdfDictionary(tr); - Assert.assertTrue(StructureTreeCopier.shouldTableElementBeCopied(obj, parent)); + Assertions.assertTrue(StructureTreeCopier.shouldTableElementBeCopied(obj, parent)); } @Test @@ -92,6 +91,6 @@ public void shouldTableElementBeCopiedThThTest() { PdfDictionary obj = new PdfDictionary(th); PdfDictionary parent = new PdfDictionary(th); - Assert.assertFalse(StructureTreeCopier.shouldTableElementBeCopied(obj, parent)); + Assertions.assertFalse(StructureTreeCopier.shouldTableElementBeCopied(obj, parent)); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/tagutils/AccessibilityPropertiesTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/tagutils/AccessibilityPropertiesTest.java index acf989c9b5..b01712846e 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/tagutils/AccessibilityPropertiesTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/tagutils/AccessibilityPropertiesTest.java @@ -29,48 +29,47 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.tagging.PdfStructureAttributes; import com.itextpdf.kernel.pdf.tagging.StandardRoles; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class AccessibilityPropertiesTest extends ExtendedITextTest { @Test public void setAccessibilityPropertiesTest() { AccessibilityProperties properties = new AccessibilityProperties() { }; - Assert.assertNotNull(properties.setRole(StandardRoles.DIV)); - Assert.assertNotNull(properties.setLanguage("EN-GB")); - Assert.assertNotNull(properties.setActualText("actualText")); - Assert.assertNotNull(properties.setAlternateDescription("Description")); - Assert.assertNotNull(properties.setExpansion("expansion")); - Assert.assertNotNull(properties.setPhoneme("phoneme")); - Assert.assertNotNull(properties.setPhoneticAlphabet("Phonetic Alphabet")); - Assert.assertNotNull(properties.setNamespace(new PdfNamespace("Namespace"))); - Assert.assertNotNull(properties.getRefsList()); - Assert.assertNotNull(properties.clearRefs()); - Assert.assertNotNull(properties.addAttributes(new PdfStructureAttributes("attributes"))); - Assert.assertNotNull(properties.addAttributes(0, new PdfStructureAttributes("attributes"))); - Assert.assertNotNull(properties.clearAttributes()); - Assert.assertNotNull(properties.getAttributesList()); - Assert.assertNotNull(properties.addRef(new TagTreePointer(createTestDocument()))); + Assertions.assertNotNull(properties.setRole(StandardRoles.DIV)); + Assertions.assertNotNull(properties.setLanguage("EN-GB")); + Assertions.assertNotNull(properties.setActualText("actualText")); + Assertions.assertNotNull(properties.setAlternateDescription("Description")); + Assertions.assertNotNull(properties.setExpansion("expansion")); + Assertions.assertNotNull(properties.setPhoneme("phoneme")); + Assertions.assertNotNull(properties.setPhoneticAlphabet("Phonetic Alphabet")); + Assertions.assertNotNull(properties.setNamespace(new PdfNamespace("Namespace"))); + Assertions.assertNotNull(properties.getRefsList()); + Assertions.assertNotNull(properties.clearRefs()); + Assertions.assertNotNull(properties.addAttributes(new PdfStructureAttributes("attributes"))); + Assertions.assertNotNull(properties.addAttributes(0, new PdfStructureAttributes("attributes"))); + Assertions.assertNotNull(properties.clearAttributes()); + Assertions.assertNotNull(properties.getAttributesList()); + Assertions.assertNotNull(properties.addRef(new TagTreePointer(createTestDocument()))); } @Test public void getAccessibilityPropertiesTest() { AccessibilityProperties properties = new AccessibilityProperties() { }; - Assert.assertNull(properties.getRole()); - Assert.assertNull(properties.getLanguage()); - Assert.assertNull(properties.getActualText()); - Assert.assertNull(properties.getAlternateDescription()); - Assert.assertNull(properties.getExpansion()); - Assert.assertNull(properties.getPhoneme()); - Assert.assertNull(properties.getPhoneticAlphabet()); - Assert.assertNull(properties.getNamespace()); + Assertions.assertNull(properties.getRole()); + Assertions.assertNull(properties.getLanguage()); + Assertions.assertNull(properties.getActualText()); + Assertions.assertNull(properties.getAlternateDescription()); + Assertions.assertNull(properties.getExpansion()); + Assertions.assertNull(properties.getPhoneme()); + Assertions.assertNull(properties.getPhoneticAlphabet()); + Assertions.assertNull(properties.getNamespace()); } private static PdfDocument createTestDocument() { diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/tagutils/TagStructureContextUnitTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/tagutils/TagStructureContextUnitTest.java index 0c6ff1d60b..025ec33765 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/tagutils/TagStructureContextUnitTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/tagutils/TagStructureContextUnitTest.java @@ -28,20 +28,19 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfWriter; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class TagStructureContextUnitTest extends ExtendedITextTest { @Test public void noTagStructureInNonTaggedDocumentTest() { PdfDocument pdfDocument = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> new TagStructureContext(pdfDocument)); - Assert.assertEquals(KernelExceptionMessageConstant.MUST_BE_A_TAGGED_DOCUMENT, exception.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.MUST_BE_A_TAGGED_DOCUMENT, exception.getMessage()); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/tagutils/TagTreeIteratorTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/tagutils/TagTreeIteratorTest.java index 61c383a3ca..4091a3e06d 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/tagutils/TagTreeIteratorTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/tagutils/TagTreeIteratorTest.java @@ -27,6 +27,7 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.exceptions.KernelExceptionMessageConstant; import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfName; +import com.itextpdf.kernel.pdf.PdfObject; import com.itextpdf.kernel.pdf.PdfWriter; import com.itextpdf.kernel.pdf.WriterProperties; import com.itextpdf.kernel.pdf.tagging.IStructureNode; @@ -34,35 +35,25 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.tagging.PdfStructTreeRoot; import com.itextpdf.kernel.pdf.tagging.StandardRoles; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import java.util.Set; -@Category(UnitTest.class) -public class TagTreeIteratorTest extends ExtendedITextTest { +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; +@Tag("UnitTest") +public class TagTreeIteratorTest extends ExtendedITextTest { @Test public void tagTreeIteratorTagPointerNull() { String errorMessage = MessageFormatUtil.format(KernelExceptionMessageConstant.ARG_SHOULD_NOT_BE_NULL, "tagTreepointer"); - Exception e = Assert.assertThrows(IllegalArgumentException.class, () -> new TagTreeIterator(null)); - Assert.assertEquals(e.getMessage(), errorMessage); - } - - @Test - public void tagTreeIteratorApproverNull() { - String errorMessage = - MessageFormatUtil.format(KernelExceptionMessageConstant.ARG_SHOULD_NOT_BE_NULL, "approver"); - PdfDocument doc = new PdfDocument(new PdfWriter(new ByteArrayOutputStream(), new WriterProperties())); - doc.setTagged(); - Exception e = Assert.assertThrows(IllegalArgumentException.class, - () -> new TagTreeIterator(doc.getStructTreeRoot(), null, TagTreeIterator.TreeTraversalOrder.PRE_ORDER)); - Assert.assertEquals(e.getMessage(), errorMessage); + Exception e = Assertions.assertThrows(IllegalArgumentException.class, () -> new TagTreeIterator(null)); + Assertions.assertEquals(e.getMessage(), errorMessage); } @Test @@ -72,9 +63,9 @@ public void tagTreeIteratorHandlerNull() { PdfDocument doc = new PdfDocument(new PdfWriter(new ByteArrayOutputStream(), new WriterProperties())); doc.setTagged(); TagTreeIterator it = new TagTreeIterator(doc.getStructTreeRoot()); - Exception e = Assert.assertThrows(IllegalArgumentException.class, + Exception e = Assertions.assertThrows(IllegalArgumentException.class, () -> it.addHandler(null)); - Assert.assertEquals(e.getMessage(), errorMessage); + Assertions.assertEquals(e.getMessage(), errorMessage); } @Test @@ -85,7 +76,7 @@ public void traversalWithoutElements() { TestHandler handler = new TestHandler(); iterator.addHandler(handler); iterator.traverse(); - Assert.assertEquals(1, handler.nodes.size()); + Assertions.assertEquals(1, handler.nodes.size()); } @Test @@ -106,14 +97,14 @@ public void traversalWithSomeElements() { iterator.addHandler(handler); iterator.traverse(); - Assert.assertEquals(7, handler.nodes.size()); - Assert.assertNull(handler.nodes.get(0).getRole()); - Assert.assertEquals(PdfName.Document, handler.nodes.get(1).getRole()); - Assert.assertEquals(PdfName.Div, handler.nodes.get(2).getRole()); - Assert.assertEquals(PdfName.P, handler.nodes.get(3).getRole()); - Assert.assertEquals(PdfName.Figure, handler.nodes.get(4).getRole()); - Assert.assertEquals(PdfName.Div, handler.nodes.get(5).getRole()); - Assert.assertEquals(PdfName.Code, handler.nodes.get(6).getRole()); + Assertions.assertEquals(7, handler.nodes.size()); + Assertions.assertNull(handler.nodes.get(0).getRole()); + Assertions.assertEquals(PdfName.Document, handler.nodes.get(1).getRole()); + Assertions.assertEquals(PdfName.Div, handler.nodes.get(2).getRole()); + Assertions.assertEquals(PdfName.P, handler.nodes.get(3).getRole()); + Assertions.assertEquals(PdfName.Figure, handler.nodes.get(4).getRole()); + Assertions.assertEquals(PdfName.Div, handler.nodes.get(5).getRole()); + Assertions.assertEquals(PdfName.Code, handler.nodes.get(6).getRole()); } @Test @@ -129,20 +120,20 @@ public void postOrderTraversal() { tp.addTag(StandardRoles.DIV); tp.addTag(StandardRoles.CODE); - TagTreeIterator iterator = new TagTreeIterator(doc.getStructTreeRoot(), new TagTreeIteratorElementApprover(), + TagTreeIterator iterator = new TagTreeIterator(doc.getStructTreeRoot(), TagTreeIterator.TreeTraversalOrder.POST_ORDER); TestHandler handler = new TestHandler(); iterator.addHandler(handler); iterator.traverse(); - Assert.assertEquals(7, handler.nodes.size()); - Assert.assertEquals(PdfName.Figure, handler.nodes.get(0).getRole()); - Assert.assertEquals(PdfName.Code, handler.nodes.get(1).getRole()); - Assert.assertEquals(PdfName.Div, handler.nodes.get(2).getRole()); - Assert.assertEquals(PdfName.P, handler.nodes.get(3).getRole()); - Assert.assertEquals(PdfName.Div, handler.nodes.get(4).getRole()); - Assert.assertEquals(PdfName.Document, handler.nodes.get(5).getRole()); - Assert.assertNull(handler.nodes.get(6).getRole()); + Assertions.assertEquals(7, handler.nodes.size()); + Assertions.assertEquals(PdfName.Figure, handler.nodes.get(0).getRole()); + Assertions.assertEquals(PdfName.Code, handler.nodes.get(1).getRole()); + Assertions.assertEquals(PdfName.Div, handler.nodes.get(2).getRole()); + Assertions.assertEquals(PdfName.P, handler.nodes.get(3).getRole()); + Assertions.assertEquals(PdfName.Div, handler.nodes.get(4).getRole()); + Assertions.assertEquals(PdfName.Document, handler.nodes.get(5).getRole()); + Assertions.assertNull(handler.nodes.get(6).getRole()); } @Test @@ -158,27 +149,39 @@ public void cyclicReferencesTraversal() { kid2.addKid(kid1); TagTreeIterator iterator = new TagTreeIterator(doc.getStructTreeRoot(), - new TagTreeIteratorAvoidDuplicatesApprover(), TagTreeIterator.TreeTraversalOrder.POST_ORDER); - TestHandler handler = new TestHandler(); + TestHandlerAvoidDuplicates handler = new TestHandlerAvoidDuplicates(); iterator.addHandler(handler); iterator.traverse(); - Assert.assertEquals(3, handler.nodes.size()); + Assertions.assertEquals(3, handler.nodes.size()); - Assert.assertEquals(PdfName.Div, handler.nodes.get(0).getRole()); - Assert.assertEquals(PdfName.P, handler.nodes.get(1).getRole()); - Assert.assertNull(handler.nodes.get(2).getRole()); + Assertions.assertEquals(PdfName.Div, handler.nodes.get(0).getRole()); + Assertions.assertEquals(PdfName.P, handler.nodes.get(1).getRole()); + Assertions.assertNull(handler.nodes.get(2).getRole()); } static class TestHandler implements ITagTreeIteratorHandler { + final List nodes = new ArrayList<>(); + + @Override + public boolean accept(IStructureNode node) { + return node != null; + } + + @Override + public void processElement(IStructureNode elem) { + nodes.add(elem); + } + } + static class TestHandlerAvoidDuplicates extends AbstractAvoidDuplicatesTagTreeIteratorHandler { final List nodes = new ArrayList<>(); @Override - public void nextElement(IStructureNode elem) { + public void processElement(IStructureNode elem) { nodes.add(elem); } } -} \ No newline at end of file +} diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/tagutils/TagTreePointerUnitTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/tagutils/TagTreePointerUnitTest.java index 575f5198db..1f69db3615 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/tagutils/TagTreePointerUnitTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/tagutils/TagTreePointerUnitTest.java @@ -39,22 +39,21 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class TagTreePointerUnitTest extends ExtendedITextTest { @Test public void rootTagCannotBeRemovedTest () { PdfDocument pdfDoc = createTestDocument(); TagTreePointer tagTreePointer = new TagTreePointer(pdfDoc); - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> tagTreePointer.removeTag()); - Assert.assertEquals(KernelExceptionMessageConstant.CANNOT_REMOVE_DOCUMENT_ROOT_TAG, + Assertions.assertEquals(KernelExceptionMessageConstant.CANNOT_REMOVE_DOCUMENT_ROOT_TAG, exception.getMessage()); } @@ -62,9 +61,9 @@ public void rootTagCannotBeRemovedTest () { public void cannotMoveToKidWithNonExistingRoleTest() { PdfDocument pdfDoc = createTestDocument(); TagTreePointer tagTreePointer = new TagTreePointer(pdfDoc); - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> tagTreePointer.moveToKid(1, "role")); - Assert.assertEquals(KernelExceptionMessageConstant.NO_KID_WITH_SUCH_ROLE, + Assertions.assertEquals(KernelExceptionMessageConstant.NO_KID_WITH_SUCH_ROLE, exception.getMessage()); } @@ -72,9 +71,9 @@ public void cannotMoveToKidWithNonExistingRoleTest() { public void cannotMoveToKidMcrTest01() { PdfDocument pdfDoc = createTestDocument(); TagTreePointer tagTreePointer = new TagTreePointer(pdfDoc); - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> tagTreePointer.moveToKid(1, "MCR")); - Assert.assertEquals(KernelExceptionMessageConstant.CANNOT_MOVE_TO_MARKED_CONTENT_REFERENCE, + Assertions.assertEquals(KernelExceptionMessageConstant.CANNOT_MOVE_TO_MARKED_CONTENT_REFERENCE, exception.getMessage()); } @@ -92,9 +91,9 @@ public void cannotMoveToKidMcrTest02() { parent.addKid(kid1); parent.addKid(kid2); tagTreePointer.setCurrentStructElem(parent); - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> tagTreePointer.moveToKid(1)); - Assert.assertEquals(KernelExceptionMessageConstant.CANNOT_MOVE_TO_MARKED_CONTENT_REFERENCE, + Assertions.assertEquals(KernelExceptionMessageConstant.CANNOT_MOVE_TO_MARKED_CONTENT_REFERENCE, exception.getMessage()); } @@ -103,9 +102,9 @@ public void noParentObjectInStructElemTest() { PdfDocument pdfDoc = createTestDocument(); TagTreePointer tagTreePointer = new TagTreePointer(pdfDoc); PdfStructElem pdfStructElem = new PdfStructElem(pdfDoc, PdfName.MCR); - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> tagTreePointer.setCurrentStructElem(pdfStructElem)); - Assert.assertEquals(KernelExceptionMessageConstant.STRUCTURE_ELEMENT_SHALL_CONTAIN_PARENT_OBJECT, + Assertions.assertEquals(KernelExceptionMessageConstant.STRUCTURE_ELEMENT_SHALL_CONTAIN_PARENT_OBJECT, exception.getMessage()); } @@ -114,9 +113,9 @@ public void pageMustBeInitializedBeforeNextMcidCreationTest() { PdfDocument pdfDoc = createTestDocument(); TagTreePointer tagTreePointer = new TagTreePointer(pdfDoc); PdfStructElem pdfStructElem = new PdfStructElem(pdfDoc, PdfName.MCR); - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> tagTreePointer.createNextMcidForStructElem(pdfStructElem, 1)); - Assert.assertEquals(KernelExceptionMessageConstant.PAGE_IS_NOT_SET_FOR_THE_PDF_TAG_STRUCTURE, + Assertions.assertEquals(KernelExceptionMessageConstant.PAGE_IS_NOT_SET_FOR_THE_PDF_TAG_STRUCTURE, exception.getMessage()); } @@ -124,9 +123,9 @@ public void pageMustBeInitializedBeforeNextMcidCreationTest() { public void cannotMoveRootToParentTest() { PdfDocument pdfDoc = createTestDocument(); TagTreePointer tagTreePointer = new TagTreePointer(pdfDoc); - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> tagTreePointer.moveToParent()); - Assert.assertEquals(KernelExceptionMessageConstant.CANNOT_MOVE_TO_PARENT_CURRENT_ELEMENT_IS_ROOT, + Assertions.assertEquals(KernelExceptionMessageConstant.CANNOT_MOVE_TO_PARENT_CURRENT_ELEMENT_IS_ROOT, exception.getMessage()); } @@ -134,9 +133,9 @@ public void cannotMoveRootToParentTest() { public void cannotRelocateRootTagTest() { PdfDocument pdfDoc = createTestDocument(); TagTreePointer tagTreePointer = new TagTreePointer(pdfDoc); - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> tagTreePointer.relocate(tagTreePointer)); - Assert.assertEquals(KernelExceptionMessageConstant.CANNOT_RELOCATE_ROOT_TAG, exception.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.CANNOT_RELOCATE_ROOT_TAG, exception.getMessage()); } @Test @@ -145,9 +144,9 @@ public void cannotFlushAlreadyFlushedPageTest() { TagTreePointer tagTreePointer = new TagTreePointer(pdfDoc); PdfPage pdfPage = pdfDoc.addNewPage(1); pdfPage.flush(); - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> tagTreePointer.setPageForTagging(pdfPage)); - Assert.assertEquals(KernelExceptionMessageConstant.PAGE_ALREADY_FLUSHED, exception.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.PAGE_ALREADY_FLUSHED, exception.getMessage()); } @Test @@ -162,9 +161,9 @@ public void cyclicReferencesWhileLookingForRoleTest() { kid2.addKid(kid1); TagTreePointer pointer = new TagTreePointer(doc); - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> pointer.moveToKid(StandardRoles.FIGURE)); - Assert.assertEquals(KernelExceptionMessageConstant.NO_KID_WITH_SUCH_ROLE, + Assertions.assertEquals(KernelExceptionMessageConstant.NO_KID_WITH_SUCH_ROLE, exception.getMessage()); } @@ -183,8 +182,8 @@ public void cyclicReferencesWhileFlushingTest() { pointer.moveToKid(StandardRoles.P); AssertUtil.doesNotThrow(() -> pointer.flushTag()); - Assert.assertTrue(kid1.isFlushed()); - Assert.assertTrue(kid2.isFlushed()); + Assertions.assertTrue(kid1.isFlushed()); + Assertions.assertTrue(kid2.isFlushed()); } @Test @@ -206,8 +205,8 @@ public void cyclicReferencesWithWaitingObjectsWhileFlushingTest() { pointer.moveToParent().moveToKid(StandardRoles.DIV); AssertUtil.doesNotThrow(() -> pointer.flushTag()); - Assert.assertFalse(kid1.isFlushed()); - Assert.assertTrue(kid2.isFlushed()); + Assertions.assertFalse(kid1.isFlushed()); + Assertions.assertTrue(kid2.isFlushed()); } private static PdfDocument createTestDocument() { diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/xobject/CreateImageStreamTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/xobject/CreateImageStreamTest.java index 5be9fb4d9a..155664b400 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/xobject/CreateImageStreamTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/xobject/CreateImageStreamTest.java @@ -32,27 +32,26 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.canvas.PdfCanvas; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class CreateImageStreamTest extends ExtendedITextTest { private static final String sourceFolder = "./src/test/resources/com/itextpdf/kernel/pdf/xobject/CreateImageStreamTest/"; private static final String destinationFolder = "./target/test/com/itextpdf/kernel/pdf/xobject/CreateImageStreamTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(destinationFolder); } @@ -88,7 +87,7 @@ public void compareColorspacesTest() throws IOException, InterruptedException { pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(out, cmp, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(out, cmp, destinationFolder, "diff_")); } @Test @@ -142,6 +141,6 @@ private void testSingleImage(String imgName) throws IOException, InterruptedExce .addXObjectFittedIntoRectangle(imageXObject, new Rectangle(0, 0, img.getWidth(), img.getHeight())); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(out, cmp, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(out, cmp, destinationFolder, "diff_")); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/xobject/GetImageBytesTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/xobject/GetImageBytesTest.java index a7a076a1b0..12092ef6c5 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/xobject/GetImageBytesTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/xobject/GetImageBytesTest.java @@ -43,7 +43,6 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.canvas.parser.data.ImageRenderInfo; import com.itextpdf.kernel.pdf.canvas.parser.listener.IEventListener; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.FileOutputStream; import java.io.IOException; @@ -54,20 +53,20 @@ This file is part of the iText (R) project. import java.util.ArrayList; import java.util.Arrays; import java.util.Set; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class GetImageBytesTest extends ExtendedITextTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/kernel/pdf/xobject" + "/GetImageBytesTest/"; private static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/kernel/pdf/xobject/GetImageBytesTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(DESTINATION_FOLDER); } @@ -157,7 +156,7 @@ public void testSeparationCSWithICCBasedAsAlternative() throws Exception { // TODO: DEVSIX-3538 (update test after fix) // Android-Conversion-Ignore-Test (TODO DEVSIX-6445 fix different DeflaterOutputStream behavior) public void testSeparationCSWithDeviceCMYKAsAlternative() throws Exception { - Assert.assertThrows(UnsupportedOperationException.class, () -> + Assertions.assertThrows(UnsupportedOperationException.class, () -> { testFile("separationCSWithDeviceCMYKAsAlternative.pdf", "Im1", "png"); }); @@ -236,7 +235,7 @@ public void extractByteAlignedG4TiffImageTest() throws IOException { processor.processPageContent(pdfDocument.getPage(1)); java.util.List images = listener.getImages(); - Assert.assertEquals(1, images.size()); + Assertions.assertEquals(1, images.size()); try (OutputStream fos = FileUtil.getFileOutputStream(outImageFileName)) { fos.write(images.get(0), 0, images.size()); @@ -247,11 +246,11 @@ public void extractByteAlignedG4TiffImageTest() throws IOException { byte[] buf = new byte[expectedLen]; try (InputStream is = FileUtil.getInputStreamForFile(cmpImageFileName)) { int read = is.read(buf, 0, buf.length); - Assert.assertEquals(expectedLen, read); + Assertions.assertEquals(expectedLen, read); read = is.read(buf, 0, buf.length); - Assert.assertTrue(read <= 0); + Assertions.assertTrue(read <= 0); } - Assert.assertArrayEquals(images.get(0), buf); + Assertions.assertArrayEquals(images.get(0), buf); } @Test @@ -264,10 +263,10 @@ public void expectedByteAlignedTiffImageExtractionTest() throws IOException { ImageExtractor listener = new ImageExtractor(); PdfCanvasProcessor processor = new PdfCanvasProcessor(listener); - Exception e = Assert.assertThrows(com.itextpdf.io.exceptions.IOException.class, + Exception e = Assertions.assertThrows(com.itextpdf.io.exceptions.IOException.class, () -> processor.processPageContent(pdfDocument.getPage(1)) ); - Assert.assertEquals(MessageFormatUtil + Assertions.assertEquals(MessageFormatUtil .format(IoExceptionMessageConstant.EXPECTED_TRAILING_ZERO_BITS_FOR_BYTE_ALIGNED_LINES), e.getMessage()); } @@ -290,7 +289,7 @@ private void testFile(String filename, String objectid, String expectedImageForm PdfImageXObject img = new PdfImageXObject((PdfStream) obj); - Assert.assertEquals(expectedImageFormat, img.identifyImageFileExtension()); + Assertions.assertEquals(expectedImageFormat, img.identifyImageFileExtension()); byte[] result = img.getImageBytes(true); if (saveResult) { @@ -304,7 +303,7 @@ private void testFile(String filename, String objectid, String expectedImageForm if (img.identifyImageFileExtension().equals("tif")) { compareTiffImages(cmpBytes, result); } else { - Assert.assertArrayEquals(cmpBytes, result); + Assertions.assertArrayEquals(cmpBytes, result); } } } @@ -315,7 +314,7 @@ private void compareTiffImages(byte[] cmpBytes, byte[] resultBytes) throws IOExc int resultNumDirectories = TIFFDirectory.getNumDirectories(new RandomAccessFileOrArray( new RandomAccessSourceFactory().createSource(resultBytes))); - Assert.assertEquals(cmpNumDirectories, resultNumDirectories); + Assertions.assertEquals(cmpNumDirectories, resultNumDirectories); for (int dirNum = 0; dirNum < cmpNumDirectories; ++dirNum) { TIFFDirectory cmpDir = new TIFFDirectory(new RandomAccessFileOrArray( @@ -323,13 +322,13 @@ private void compareTiffImages(byte[] cmpBytes, byte[] resultBytes) throws IOExc TIFFDirectory resultDir = new TIFFDirectory(new RandomAccessFileOrArray( new RandomAccessSourceFactory().createSource(resultBytes)), dirNum); - Assert.assertEquals(cmpDir.getNumEntries(), resultDir.getNumEntries()); - Assert.assertEquals(cmpDir.getIFDOffset(), resultDir.getIFDOffset()); - Assert.assertEquals(cmpDir.getNextIFDOffset(), resultDir.getNextIFDOffset()); - Assert.assertArrayEquals(cmpDir.getTags(), resultDir.getTags()); + Assertions.assertEquals(cmpDir.getNumEntries(), resultDir.getNumEntries()); + Assertions.assertEquals(cmpDir.getIFDOffset(), resultDir.getIFDOffset()); + Assertions.assertEquals(cmpDir.getNextIFDOffset(), resultDir.getNextIFDOffset()); + Assertions.assertArrayEquals(cmpDir.getTags(), resultDir.getTags()); for (int tag : cmpDir.getTags()) { - Assert.assertEquals(cmpDir.isTagPresent(tag), resultDir.isTagPresent(tag)); + Assertions.assertEquals(cmpDir.isTagPresent(tag), resultDir.isTagPresent(tag)); TIFFField cmpField = cmpDir.getField(tag); TIFFField resultField = resultDir.getField(tag); @@ -345,53 +344,53 @@ private void compareTiffImages(byte[] cmpBytes, byte[] resultBytes) throws IOExc private void compareFields(TIFFField cmpField, TIFFField resultField) { if (cmpField.getType() == TIFFField.TIFF_LONG) { - Assert.assertArrayEquals(cmpField.getAsLongs(), resultField.getAsLongs()); + Assertions.assertArrayEquals(cmpField.getAsLongs(), resultField.getAsLongs()); } else if (cmpField.getType() == TIFFField.TIFF_BYTE) { - Assert.assertArrayEquals(cmpField.getAsBytes(), resultField.getAsBytes()); + Assertions.assertArrayEquals(cmpField.getAsBytes(), resultField.getAsBytes()); } else if (cmpField.getType() == TIFFField.TIFF_SBYTE) { - Assert.assertArrayEquals(cmpField.getAsBytes(), resultField.getAsBytes()); + Assertions.assertArrayEquals(cmpField.getAsBytes(), resultField.getAsBytes()); } else if (cmpField.getType() == TIFFField.TIFF_SHORT) { - Assert.assertArrayEquals(cmpField.getAsChars(), resultField.getAsChars()); + Assertions.assertArrayEquals(cmpField.getAsChars(), resultField.getAsChars()); } else if (cmpField.getType() == TIFFField.TIFF_SLONG) { - Assert.assertArrayEquals(cmpField.getAsInts(), resultField.getAsInts()); + Assertions.assertArrayEquals(cmpField.getAsInts(), resultField.getAsInts()); } else if (cmpField.getType() == TIFFField.TIFF_SSHORT) { - Assert.assertArrayEquals(cmpField.getAsChars(), resultField.getAsChars()); + Assertions.assertArrayEquals(cmpField.getAsChars(), resultField.getAsChars()); } else if (cmpField.getType() == TIFFField.TIFF_UNDEFINED) { - Assert.assertArrayEquals(cmpField.getAsBytes(), resultField.getAsBytes()); + Assertions.assertArrayEquals(cmpField.getAsBytes(), resultField.getAsBytes()); } else if (cmpField.getType() == TIFFField.TIFF_DOUBLE) { - Assert.assertArrayEquals(cmpField.getAsDoubles(), resultField.getAsDoubles(), 0); + Assertions.assertArrayEquals(cmpField.getAsDoubles(), resultField.getAsDoubles(), 0); } else if (cmpField.getType() == TIFFField.TIFF_FLOAT) { - Assert.assertArrayEquals(cmpField.getAsFloats(), resultField.getAsFloats(), 0); + Assertions.assertArrayEquals(cmpField.getAsFloats(), resultField.getAsFloats(), 0); } else if (cmpField.getType() == TIFFField.TIFF_RATIONAL) { - Assert.assertArrayEquals(cmpField.getAsRationals(), resultField.getAsRationals()); + Assertions.assertArrayEquals(cmpField.getAsRationals(), resultField.getAsRationals()); } else if (cmpField.getType() == TIFFField.TIFF_SRATIONAL) { - Assert.assertArrayEquals(cmpField.getAsSRationals(), resultField.getAsSRationals()); + Assertions.assertArrayEquals(cmpField.getAsSRationals(), resultField.getAsSRationals()); } else if (cmpField.getType() == TIFFField.TIFF_ASCII) { - Assert.assertArrayEquals(cmpField.getAsStrings(), resultField.getAsStrings()); + Assertions.assertArrayEquals(cmpField.getAsStrings(), resultField.getAsStrings()); } else { - Assert.assertArrayEquals(cmpField.getAsBytes(), resultField.getAsBytes()); + Assertions.assertArrayEquals(cmpField.getAsBytes(), resultField.getAsBytes()); } } private void compareImageData(TIFFDirectory cmpDir, TIFFDirectory resultDir, byte[] cmpBytes, byte[] resultBytes) { - Assert.assertTrue(cmpDir.isTagPresent(TIFFConstants.TIFFTAG_STRIPOFFSETS)); - Assert.assertTrue(cmpDir.isTagPresent(TIFFConstants.TIFFTAG_STRIPBYTECOUNTS)); - Assert.assertTrue(resultDir.isTagPresent(TIFFConstants.TIFFTAG_STRIPOFFSETS)); - Assert.assertTrue(resultDir.isTagPresent(TIFFConstants.TIFFTAG_STRIPBYTECOUNTS)); + Assertions.assertTrue(cmpDir.isTagPresent(TIFFConstants.TIFFTAG_STRIPOFFSETS)); + Assertions.assertTrue(cmpDir.isTagPresent(TIFFConstants.TIFFTAG_STRIPBYTECOUNTS)); + Assertions.assertTrue(resultDir.isTagPresent(TIFFConstants.TIFFTAG_STRIPOFFSETS)); + Assertions.assertTrue(resultDir.isTagPresent(TIFFConstants.TIFFTAG_STRIPBYTECOUNTS)); long[] cmpImageOffsets = cmpDir.getField(TIFFConstants.TIFFTAG_STRIPOFFSETS).getAsLongs(); long[] cmpStripByteCountsArray = cmpDir.getField(TIFFConstants.TIFFTAG_STRIPOFFSETS).getAsLongs(); long[] resultImageOffsets = resultDir.getField(TIFFConstants.TIFFTAG_STRIPOFFSETS).getAsLongs(); long[] resultStripByteCountsArray = resultDir.getField(TIFFConstants.TIFFTAG_STRIPOFFSETS).getAsLongs(); - Assert.assertEquals(cmpImageOffsets.length, resultImageOffsets.length); - Assert.assertEquals(cmpStripByteCountsArray.length, resultStripByteCountsArray.length); + Assertions.assertEquals(cmpImageOffsets.length, resultImageOffsets.length); + Assertions.assertEquals(cmpStripByteCountsArray.length, resultStripByteCountsArray.length); for (int i = 0; i < cmpImageOffsets.length; ++i) { int cmpOffset = (int) cmpImageOffsets[i], cmpCounts = (int) cmpStripByteCountsArray[i]; int resultOffset = (int) resultImageOffsets[i], resultCounts = (int) resultStripByteCountsArray[i]; - Assert.assertArrayEquals(subArray(cmpBytes, cmpOffset, (cmpOffset + cmpCounts - 1)), + Assertions.assertArrayEquals(subArray(cmpBytes, cmpOffset, (cmpOffset + cmpCounts - 1)), subArray(resultBytes, resultOffset, (resultOffset + resultCounts - 1))); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/xobject/ImageFromLanguageStandardLibraryTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/xobject/ImageFromLanguageStandardLibraryTest.java index 70b2d4056b..3cf9344137 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/xobject/ImageFromLanguageStandardLibraryTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/xobject/ImageFromLanguageStandardLibraryTest.java @@ -34,26 +34,25 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.canvas.PdfCanvas; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") // Android-Conversion-Skip-File (java.awt library isn't available on Android) public class ImageFromLanguageStandardLibraryTest extends ExtendedITextTest { public static final String destinationFolder = "./target/test/com/itextpdf/kernel/pdf/xobject/ImageFromLanguageStandardLibraryTest/"; public static final String sourceFolder = "./src/test/resources/com/itextpdf/kernel/pdf/xobject/ImageFromLanguageStandardLibraryTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(destinationFolder); } @@ -87,7 +86,7 @@ public void imageBinaryTransparencySameColorTest() throws java.io.IOException { PdfStream outStream = firstPage.getResources().getResource(PdfName.XObject).getAsStream(new PdfName("Im1")); PdfStream cmpStream = cmpDoc.getFirstPage().getResources().getResource(PdfName.XObject).getAsStream(new PdfName("Im1")); - Assert.assertNull(new CompareTool().compareStreamsStructure(outStream, cmpStream)); + Assertions.assertNull(new CompareTool().compareStreamsStructure(outStream, cmpStream)); cmpDoc.close(); pdfDocument.close(); @@ -124,7 +123,7 @@ public void imageBinaryTransparencyDifferentColorsTest() throws java.io.IOExcept PdfStream outStream = firstPage.getResources().getResource(PdfName.XObject).getAsStream(new PdfName("Im1")); PdfStream cmpStream = cmpDoc.getFirstPage().getResources().getResource(PdfName.XObject).getAsStream(new PdfName("Im1")); - Assert.assertNull(new CompareTool().compareStreamsStructure(outStream, cmpStream)); + Assertions.assertNull(new CompareTool().compareStreamsStructure(outStream, cmpStream)); cmpDoc.close(); pdfDocument.close(); diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/xobject/PdfImageXObjectTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/xobject/PdfImageXObjectTest.java index e360f8d377..5d19b5bf9b 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/xobject/PdfImageXObjectTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/xobject/PdfImageXObjectTest.java @@ -34,28 +34,27 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.canvas.PdfCanvas; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.FileOutputStream; import java.io.IOException; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfImageXObjectTest extends ExtendedITextTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/kernel/pdf/xobject/PdfImageXObjectTest/"; private static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/kernel/pdf/xobject/PdfImageXObjectTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(DESTINATION_FOLDER); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(DESTINATION_FOLDER); } @@ -77,7 +76,7 @@ public void addFlushedImageXObjectToCanvas() throws IOException, InterruptedExce canvas.addXObjectFittedIntoRectangle(imageXObject, new Rectangle(50, 500, 200, 200)); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(filename, cmpfile, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpfile, DESTINATION_FOLDER)); } @Test @@ -175,7 +174,7 @@ public void group3CompTiffImgRecoverErrorAndDirectTest() throws IOException, Int canvas.addXObjectFittedIntoRectangle(imageXObject, new Rectangle(50, 500, 200, 200)); } - Assert.assertNull(new CompareTool().compareByContent(filename, cmpFile, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpFile, DESTINATION_FOLDER)); } @Test @@ -199,7 +198,7 @@ public void redundantDecodeParmsTest() throws IOException, InterruptedException new StampingProperties())) { } - Assert.assertNull(new CompareTool().compareByContent(destFilename, cmpFilename, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(destFilename, cmpFilename, DESTINATION_FOLDER)); } private void convertAndCompare(String outFilename, String cmpFilename, String imageFilename) @@ -224,7 +223,7 @@ private void convertAndCompare(String outFilename, String cmpFilename, String im PdfStream cmpStream = cmpDoc.getFirstPage().getResources().getResource(PdfName.XObject).getAsStream(new PdfName("Im1")); - Assert.assertNull(new CompareTool().compareStreamsStructure(outStream, cmpStream)); + Assertions.assertNull(new CompareTool().compareStreamsStructure(outStream, cmpStream)); cmpDoc.close(); outDoc.close(); @@ -251,7 +250,7 @@ private void convertAndCompare(String outFilename, String cmpFilename,PdfImageXO PdfStream cmpStream = cmpDoc.getFirstPage().getResources().getResource(PdfName.XObject).getAsStream(new PdfName("Im1")); - Assert.assertNull(new CompareTool().compareStreamsStructure(outStream, cmpStream)); + Assertions.assertNull(new CompareTool().compareStreamsStructure(outStream, cmpStream)); cmpDoc.close(); outDoc.close(); diff --git a/kernel/src/test/java/com/itextpdf/kernel/pdf/xobject/PdfXObjectUnitTest.java b/kernel/src/test/java/com/itextpdf/kernel/pdf/xobject/PdfXObjectUnitTest.java index de23591969..b60e8d0c7a 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/pdf/xobject/PdfXObjectUnitTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/pdf/xobject/PdfXObjectUnitTest.java @@ -26,29 +26,28 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfName; import com.itextpdf.kernel.pdf.PdfStream; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfXObjectUnitTest extends ExtendedITextTest { @Test public void noSubTypeProvidedTest() { PdfStream pdfStream = new PdfStream(); - Exception exception = Assert.assertThrows(UnsupportedOperationException.class, + Exception exception = Assertions.assertThrows(UnsupportedOperationException.class, () -> PdfXObject.makeXObject(pdfStream)); - Assert.assertEquals(KernelExceptionMessageConstant.UNSUPPORTED_XOBJECT_TYPE, exception.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.UNSUPPORTED_XOBJECT_TYPE, exception.getMessage()); } @Test public void unsupportedSubTypeIsSet() { PdfStream pdfStream = new PdfStream(); pdfStream.put(PdfName.Subtype, new PdfName("Unsupported SubType")); - Exception exception = Assert.assertThrows(UnsupportedOperationException.class, + Exception exception = Assertions.assertThrows(UnsupportedOperationException.class, () -> PdfXObject.makeXObject(pdfStream)); - Assert.assertEquals(KernelExceptionMessageConstant.UNSUPPORTED_XOBJECT_TYPE, exception.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.UNSUPPORTED_XOBJECT_TYPE, exception.getMessage()); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/utils/CompareToolObjectPathTest.java b/kernel/src/test/java/com/itextpdf/kernel/utils/CompareToolObjectPathTest.java index 4c5b86db9a..8cb5a65b1f 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/utils/CompareToolObjectPathTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/utils/CompareToolObjectPathTest.java @@ -27,14 +27,13 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfWriter; import com.itextpdf.kernel.utils.objectpathitems.ObjectPath; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.ByteArrayOutputStream; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class CompareToolObjectPathTest extends ExtendedITextTest { @Test @@ -42,21 +41,21 @@ public void baseEqualsTest() { PdfIndirectReference firstReference = createIndirectReference(null, 41, 0); PdfIndirectReference secondReference = createIndirectReference(null, 42, 0); ObjectPath path = new ObjectPath(firstReference, secondReference); - Assert.assertTrue(path.equals(path)); - Assert.assertFalse(path.equals(null)); + Assertions.assertTrue(path.equals(path)); + Assertions.assertFalse(path.equals(null)); - Assert.assertFalse(new ObjectPath(firstReference, secondReference).equals( + Assertions.assertFalse(new ObjectPath(firstReference, secondReference).equals( new ObjectPath(null, secondReference))); - Assert.assertFalse(new ObjectPath(null, secondReference).equals( + Assertions.assertFalse(new ObjectPath(null, secondReference).equals( new ObjectPath(firstReference, secondReference))); - Assert.assertFalse(new ObjectPath(firstReference, secondReference).equals( + Assertions.assertFalse(new ObjectPath(firstReference, secondReference).equals( new ObjectPath(firstReference, null))); - Assert.assertFalse(new ObjectPath(firstReference, secondReference).equals( + Assertions.assertFalse(new ObjectPath(firstReference, secondReference).equals( new ObjectPath(null, secondReference))); - Assert.assertFalse(new ObjectPath(firstReference, secondReference).equals( + Assertions.assertFalse(new ObjectPath(firstReference, secondReference).equals( new ObjectPath(new TestIndirectReference(null, 41, 0), secondReference))); - Assert.assertFalse(new ObjectPath(firstReference, secondReference).equals( + Assertions.assertFalse(new ObjectPath(firstReference, secondReference).equals( new ObjectPath(firstReference, new TestIndirectReference(null, 42, 0)))); } @@ -72,33 +71,33 @@ public void equalsWithDocTest() { PdfIndirectReference obj41Gen0 = createIndirectReference(firstDoc, 41, 0); PdfIndirectReference obj42Gen0 = createIndirectReference(firstDoc, 42, 0); - Assert.assertTrue(new ObjectPath(obj41Gen0, obj42Gen0).equals( + Assertions.assertTrue(new ObjectPath(obj41Gen0, obj42Gen0).equals( new ObjectPath(createIndirectReference(firstDoc, 41, 0), obj42Gen0))); - Assert.assertTrue(new ObjectPath(obj41Gen0, obj42Gen0).equals( + Assertions.assertTrue(new ObjectPath(obj41Gen0, obj42Gen0).equals( new ObjectPath(obj41Gen0, createIndirectReference(firstDoc, 42, 0)))); - Assert.assertFalse(new ObjectPath(obj41Gen0, obj42Gen0).equals( + Assertions.assertFalse(new ObjectPath(obj41Gen0, obj42Gen0).equals( new ObjectPath(createIndirectReference(firstDoc, 42, 0), obj42Gen0))); - Assert.assertFalse(new ObjectPath(obj41Gen0, obj42Gen0).equals( + Assertions.assertFalse(new ObjectPath(obj41Gen0, obj42Gen0).equals( new ObjectPath(obj41Gen0, createIndirectReference(firstDoc, 41, 0)))); - Assert.assertFalse(new ObjectPath(obj41Gen0, obj42Gen0).equals( + Assertions.assertFalse(new ObjectPath(obj41Gen0, obj42Gen0).equals( new ObjectPath(createIndirectReference(firstDoc, 41, 1), obj42Gen0))); - Assert.assertFalse(new ObjectPath(obj41Gen0, obj42Gen0).equals( + Assertions.assertFalse(new ObjectPath(obj41Gen0, obj42Gen0).equals( new ObjectPath(obj41Gen0, createIndirectReference(firstDoc, 42, 1)))); // TODO: DEVSIX-4756 start asserting false - Assert.assertTrue(new ObjectPath(obj41Gen0, obj42Gen0).equals( + Assertions.assertTrue(new ObjectPath(obj41Gen0, obj42Gen0).equals( new ObjectPath(createIndirectReference(null, 41, 0), obj42Gen0))); // TODO: DEVSIX-4756 start asserting false - Assert.assertTrue(new ObjectPath(obj41Gen0, obj42Gen0).equals( + Assertions.assertTrue(new ObjectPath(obj41Gen0, obj42Gen0).equals( new ObjectPath(obj41Gen0, createIndirectReference(null, 42, 0)))); // TODO: DEVSIX-4756 start asserting false - Assert.assertTrue(new ObjectPath(obj41Gen0, obj42Gen0).equals( + Assertions.assertTrue(new ObjectPath(obj41Gen0, obj42Gen0).equals( new ObjectPath(createIndirectReference(secondDoc, 41, 0), obj42Gen0))); // TODO: DEVSIX-4756 start asserting false - Assert.assertTrue(new ObjectPath(obj41Gen0, obj42Gen0).equals( + Assertions.assertTrue(new ObjectPath(obj41Gen0, obj42Gen0).equals( new ObjectPath(obj41Gen0, createIndirectReference(secondDoc, 42, 0)))); } @@ -116,44 +115,44 @@ public void hashCodeTest() { PdfIndirectReference obj41Gen0 = createIndirectReference(firstDoc, 41, 0); PdfIndirectReference obj42Gen0 = createIndirectReference(firstDoc, 42, 0); - Assert.assertEquals(new ObjectPath(obj41Gen0, obj42Gen0).hashCode(), + Assertions.assertEquals(new ObjectPath(obj41Gen0, obj42Gen0).hashCode(), new ObjectPath( createIndirectReference(firstDoc, 41, 0), createIndirectReference(firstDoc, 42, 0) ).hashCode()); - Assert.assertNotEquals(new ObjectPath(obj41Gen0, obj42Gen0).hashCode(), + Assertions.assertNotEquals(new ObjectPath(obj41Gen0, obj42Gen0).hashCode(), new ObjectPath( createIndirectReference(firstDoc, 42, 0), obj42Gen0 ).hashCode()); - Assert.assertNotEquals(new ObjectPath(obj41Gen0, obj42Gen0).hashCode(), + Assertions.assertNotEquals(new ObjectPath(obj41Gen0, obj42Gen0).hashCode(), new ObjectPath( obj41Gen0, createIndirectReference(firstDoc, 41, 0) ).hashCode()); // TODO: DEVSIX-4756 start asserting not equals - Assert.assertEquals(new ObjectPath(obj41Gen0, obj42Gen0).hashCode(), + Assertions.assertEquals(new ObjectPath(obj41Gen0, obj42Gen0).hashCode(), new ObjectPath( createIndirectReference(null, 41, 0), createIndirectReference(firstDoc, 42, 0) ).hashCode()); // TODO: DEVSIX-4756 start asserting not equals - Assert.assertEquals(new ObjectPath(obj41Gen0, obj42Gen0).hashCode(), + Assertions.assertEquals(new ObjectPath(obj41Gen0, obj42Gen0).hashCode(), new ObjectPath( createIndirectReference(firstDoc, 41, 0), createIndirectReference(null, 42, 0) ).hashCode()); // TODO: DEVSIX-4756 start asserting not equals - Assert.assertEquals(new ObjectPath(obj41Gen0, obj42Gen0).hashCode(), + Assertions.assertEquals(new ObjectPath(obj41Gen0, obj42Gen0).hashCode(), new ObjectPath( createIndirectReference(secondDoc, 41, 0), createIndirectReference(firstDoc, 42, 0) ).hashCode()); // TODO: DEVSIX-4756 start asserting not equals - Assert.assertEquals(new ObjectPath(obj41Gen0, obj42Gen0).hashCode(), + Assertions.assertEquals(new ObjectPath(obj41Gen0, obj42Gen0).hashCode(), new ObjectPath( createIndirectReference(firstDoc, 41, 0), createIndirectReference(secondDoc, 42, 0) diff --git a/kernel/src/test/java/com/itextpdf/kernel/utils/CompareToolTest.java b/kernel/src/test/java/com/itextpdf/kernel/utils/CompareToolTest.java index 4ec1fc47d7..0968384baf 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/utils/CompareToolTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/utils/CompareToolTest.java @@ -40,32 +40,31 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import javax.xml.parsers.ParserConfigurationException; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import org.xml.sax.SAXException; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") // Android-Conversion-Skip-File (during Android conversion the class will be replaced by DeferredCompareTool) public class CompareToolTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/kernel/utils/CompareToolTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/kernel/utils/CompareToolTest/"; - @BeforeClass + @BeforeAll public static void setUp() { createOrClearDestinationFolder(destinationFolder); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(destinationFolder); } @@ -80,11 +79,12 @@ public void compareToolErrorReportTest01() String cmpPdf = sourceFolder + "cmp_simple_pdf.pdf"; String result = compareTool.compareByContent(outPdf, cmpPdf, destinationFolder); System.out.println("\nRESULT:\n" + result); - Assert.assertNotNull("CompareTool must return differences found between the files", result); - Assert.assertTrue(result.contains("differs on page [1, 2].")); + Assertions.assertNotNull("CompareTool must return differences found between the files", result); + Assertions.assertTrue(result.contains("differs on page [1, 2].")); // Comparing the report to the reference one. - Assert.assertTrue("CompareTool report differs from the reference one", compareTool - .compareXmls(destinationFolder + "simple_pdf.report.xml", sourceFolder + "cmp_report01.xml")); + Assertions.assertTrue( + compareTool.compareXmls(destinationFolder + "simple_pdf.report.xml", sourceFolder + "cmp_report01.xml"), + "CompareTool report differs from the reference one"); } @Test @@ -97,11 +97,12 @@ public void compareToolErrorReportTest02() String cmpPdf = sourceFolder + "cmp_tagged_pdf.pdf"; String result = compareTool.compareByContent(outPdf, cmpPdf, destinationFolder); System.out.println("\nRESULT:\n" + result); - Assert.assertNotNull("CompareTool must return differences found between the files", result); - Assert.assertTrue(result.contains("Compare by content fails. No visual differences")); + Assertions.assertNotNull("CompareTool must return differences found between the files", result); + Assertions.assertTrue(result.contains("Compare by content fails. No visual differences")); // Comparing the report to the reference one. - Assert.assertTrue("CompareTool report differs from the reference one", compareTool - .compareXmls(destinationFolder + "tagged_pdf.report.xml", sourceFolder + "cmp_report02.xml")); + Assertions.assertTrue( + compareTool.compareXmls(destinationFolder + "tagged_pdf.report.xml", sourceFolder + "cmp_report02.xml"), + "CompareTool report differs from the reference one"); } @Test @@ -114,11 +115,11 @@ public void compareToolErrorReportTest03() String cmpPdf = sourceFolder + "cmp_screenAnnotation.pdf"; String result = compareTool.compareByContent(outPdf, cmpPdf, destinationFolder); System.out.println("\nRESULT:\n" + result); - Assert.assertNotNull("CompareTool must return differences found between the files", result); - Assert.assertTrue(result.contains("Compare by content fails. No visual differences")); + Assertions.assertNotNull("CompareTool must return differences found between the files", result); + Assertions.assertTrue(result.contains("Compare by content fails. No visual differences")); // Comparing the report to the reference one. - Assert.assertTrue("CompareTool report differs from the reference one", compareTool - .compareXmls(destinationFolder + "screenAnnotation.report.xml", sourceFolder + "cmp_report03.xml")); + Assertions.assertTrue(compareTool.compareXmls(destinationFolder + "screenAnnotation.report.xml", + sourceFolder + "cmp_report03.xml"), "CompareTool report differs from the reference one"); } @@ -133,11 +134,12 @@ public void compareToolErrorReportTest04() String cmpPdf = sourceFolder + "cmp_simple_pdf_with_space .pdf"; String result = compareTool.compareByContent(outPdf, cmpPdf, destinationFolder); System.out.println("\nRESULT:\n" + result); - Assert.assertNotNull("CompareTool must return differences found between the files", result); - Assert.assertTrue(result.contains("differs on page [1, 2].")); + Assertions.assertNotNull("CompareTool must return differences found between the files", result); + Assertions.assertTrue(result.contains("differs on page [1, 2].")); // Comparing the report to the reference one. - Assert.assertTrue("CompareTool report differs from the reference one", compareTool - .compareXmls(destinationFolder + "simple_pdf.report.xml", sourceFolder + "cmp_report01.xml")); + Assertions.assertTrue( + compareTool.compareXmls(destinationFolder + "simple_pdf.report.xml", sourceFolder + "cmp_report01.xml"), + "CompareTool report differs from the reference one"); } @@ -146,14 +148,14 @@ public void differentProducerTest() throws IOException { String expectedMessage = "Document info fail. Expected: \"iText\u00ae \u00a9 Apryse Group NV (iText Software; licensed version)\", actual: \"iText\u00ae \u00a9 Apryse Group NV (AGPL-version)\""; String licensed = sourceFolder + "producerLicensed.pdf"; String agpl = sourceFolder + "producerAGPL.pdf"; - Assert.assertEquals(expectedMessage, new CompareTool().compareDocumentInfo(agpl, licensed)); + Assertions.assertEquals(expectedMessage, new CompareTool().compareDocumentInfo(agpl, licensed)); } @Test public void versionReplaceTest() { String initial = "iText® 1.10.10-SNAPSHOT (licensed to iText) ©2000-2018 Apryse Group NV"; String replacedExpected = "iText® (licensed to iText) © Apryse Group NV"; - Assert.assertEquals(replacedExpected, new CompareTool().convertProducerLine(initial)); + Assertions.assertEquals(replacedExpected, new CompareTool().convertProducerLine(initial)); } @Test @@ -161,7 +163,7 @@ public void gsEnvironmentVariableIsNotSpecifiedExceptionTest() throws IOExceptio String outPdf = sourceFolder + "simple_pdf.pdf"; String cmpPdf = sourceFolder + "cmp_simple_pdf.pdf"; new CompareTool(null, null).compareVisually(outPdf, cmpPdf, destinationFolder, "diff_"); - Assert.assertTrue(new File(destinationFolder + "diff_1.png").exists()); + Assertions.assertTrue(new File(destinationFolder + "diff_1.png").exists()); } @Test @@ -169,7 +171,7 @@ public void compareXmpThrows(){ CompareTool compareTool = new CompareTool(); String outPdf = sourceFolder + "simple_pdf.pdf"; String cmpPdf = sourceFolder + "cmp_simple_pdf.pdf"; - Assert.assertEquals("XMP parsing failure!", compareTool.compareXmp(outPdf, cmpPdf)); + Assertions.assertEquals("XMP parsing failure!", compareTool.compareXmp(outPdf, cmpPdf)); } @Test @@ -177,10 +179,10 @@ public void gsEnvironmentVariableSpecifiedIncorrectlyTest() throws IOException, String outPdf = sourceFolder + "simple_pdf.pdf"; String cmpPdf = sourceFolder + "cmp_simple_pdf.pdf"; - Exception e = Assert.assertThrows(CompareTool.CompareToolExecutionException.class, + Exception e = Assertions.assertThrows(CompareTool.CompareToolExecutionException.class, () -> new CompareTool("unspecified", null).compareVisually(outPdf, cmpPdf, destinationFolder, "diff_") ); - Assert.assertEquals(IoExceptionMessageConstant.GS_ENVIRONMENT_VARIABLE_IS_NOT_SPECIFIED, e.getMessage()); + Assertions.assertEquals(IoExceptionMessageConstant.GS_ENVIRONMENT_VARIABLE_IS_NOT_SPECIFIED, e.getMessage()); } @Test @@ -193,8 +195,8 @@ public void compareCommandIsNotSpecifiedTest() throws IOException, InterruptedEx } String result = new CompareTool(gsExec, null) .compareVisually(outPdf, cmpPdf, destinationFolder, "diff_"); - Assert.assertFalse(result.contains(IoExceptionMessageConstant.COMPARE_COMMAND_IS_NOT_SPECIFIED)); - Assert.assertTrue(new File(destinationFolder + "diff_1.png").exists()); + Assertions.assertFalse(result.contains(IoExceptionMessageConstant.COMPARE_COMMAND_IS_NOT_SPECIFIED)); + Assertions.assertTrue(new File(destinationFolder + "diff_1.png").exists()); } @Test @@ -209,7 +211,7 @@ public void compareCommandSpecifiedIncorrectlyTest() throws IOException, Interru } String result = new CompareTool(gsExec, "unspecified") .compareVisually(outPdf, cmpPdf, destinationFolder, "diff_"); - Assert.assertTrue(result.contains(IoExceptionMessageConstant.COMPARE_COMMAND_SPECIFIED_INCORRECTLY)); + Assertions.assertTrue(result.contains(IoExceptionMessageConstant.COMPARE_COMMAND_SPECIFIED_INCORRECTLY)); } @Test @@ -218,9 +220,9 @@ public void compareVisuallyDiffTestTest() throws IOException, InterruptedExcepti String cmpPdf = sourceFolder + "compareVisuallyDiffTestTest2.pdf"; String result = new CompareTool().compareVisually(outPdf, cmpPdf, destinationFolder, "diff_"); System.out.println("\nRESULT:\n" + result); - Assert.assertTrue(result.contains("differs on page [1, 2].")); - Assert.assertTrue(new File(destinationFolder + "diff_1.png").exists()); - Assert.assertTrue(new File(destinationFolder + "diff_2.png").exists()); + Assertions.assertTrue(result.contains("differs on page [1, 2].")); + Assertions.assertTrue(new File(destinationFolder + "diff_1.png").exists()); + Assertions.assertTrue(new File(destinationFolder + "diff_2.png").exists()); } @Test @@ -260,7 +262,7 @@ public void compareDiffFilesWithSameLinkAnnotationTest() throws IOException { page1secondDocument.flush(); secondDocument.close(); - Assert.assertNull(new CompareTool().compareLinkAnnotations(firstPdf, secondPdf)); + Assertions.assertNull(new CompareTool().compareLinkAnnotations(firstPdf, secondPdf)); } @Test @@ -282,7 +284,7 @@ public void compareFilesWithDiffLinkAnnotationTest() throws IOException { page1SecondDocument.flush(); secondDocument.close(); - Assert.assertNotNull(new CompareTool().compareLinkAnnotations(firstPdf, secondPdf)); + Assertions.assertNotNull(new CompareTool().compareLinkAnnotations(firstPdf, secondPdf)); } @Test @@ -300,11 +302,11 @@ protected String[] convertDocInfoToStrings(PdfDocumentInfo info) { try (PdfReader reader = new PdfReader(inPdf, compareTool.getOutReaderProperties()); PdfDocument doc = new PdfDocument(reader)) { String[] docInfo = compareTool.convertDocInfoToStrings(doc.getDocumentInfo()); - Assert.assertEquals("very long title to compare later on", docInfo[0]); - Assert.assertEquals("itextcore", docInfo[1]); - Assert.assertEquals("test file", docInfo[2]); - Assert.assertEquals("new job", docInfo[3]); - Assert.assertEquals("Adobe Acrobat Pro DC (64-bit) ", docInfo[4]); + Assertions.assertEquals("very long title to compare later on", docInfo[0]); + Assertions.assertEquals("itextcore", docInfo[1]); + Assertions.assertEquals("test file", docInfo[2]); + Assertions.assertEquals("new job", docInfo[3]); + Assertions.assertEquals("Adobe Acrobat Pro DC (64-bit) ", docInfo[4]); } } @@ -327,9 +329,9 @@ public void memoryFirstWriterNoFileTest() throws InterruptedException, IOExcepti page1SecondDocument.flush(); secondDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(firstPdf, secondPdf, destinationFolder)); - Assert.assertFalse(new File(firstPdf).exists()); - Assert.assertFalse(new File(secondPdf).exists()); + Assertions.assertNull(new CompareTool().compareByContent(firstPdf, secondPdf, destinationFolder)); + Assertions.assertFalse(new File(firstPdf).exists()); + Assertions.assertFalse(new File(secondPdf).exists()); } @Test @@ -351,19 +353,19 @@ public void dumpMemoryFirstWriterOnDiskTest() throws InterruptedException, IOExc page1SecondDocument.flush(); secondDocument.close(); - Assert.assertNotNull(new CompareTool().compareByContent(firstPdf, secondPdf, destinationFolder)); - Assert.assertTrue(new File(firstPdf).exists()); - Assert.assertTrue(new File(secondPdf).exists()); + Assertions.assertNotNull(new CompareTool().compareByContent(firstPdf, secondPdf, destinationFolder)); + Assertions.assertTrue(new File(firstPdf).exists()); + Assertions.assertTrue(new File(secondPdf).exists()); } @Test - public void cleanupTest() throws FileNotFoundException { + public void cleanupTest() throws IOException { CompareTool.createTestPdfWriter(destinationFolder + "cleanupTest/cleanupTest.pdf"); - Assert.assertNotNull(MemoryFirstPdfWriter.get(destinationFolder + "cleanupTest/cleanupTest.pdf")); + Assertions.assertNotNull(MemoryFirstPdfWriter.get(destinationFolder + "cleanupTest/cleanupTest.pdf")); - Assert.assertThrows(IllegalArgumentException.class, () -> CompareTool.cleanup(null)); + Assertions.assertThrows(IllegalArgumentException.class, () -> CompareTool.cleanup(null)); CompareTool.cleanup(destinationFolder + "cleanupTest"); - Assert.assertNull(MemoryFirstPdfWriter.get(destinationFolder + "cleanupTest/cleanupTest.pdf")); + Assertions.assertNull(MemoryFirstPdfWriter.get(destinationFolder + "cleanupTest/cleanupTest.pdf")); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/utils/PageRangeTest.java b/kernel/src/test/java/com/itextpdf/kernel/utils/PageRangeTest.java index d9e3c3fb5c..a9d8d901ca 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/utils/PageRangeTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/utils/PageRangeTest.java @@ -23,16 +23,15 @@ This file is part of the iText (R) project. package com.itextpdf.kernel.utils; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.util.ArrayList; import java.util.Arrays; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PageRangeTest extends ExtendedITextTest { @Test @@ -40,7 +39,7 @@ public void addSingleTest() { PageRange range = new PageRange(); range.addSinglePage(5); - Assert.assertEquals(Arrays.asList(5), range.getQualifyingPageNums(10)); + Assertions.assertEquals(Arrays.asList(5), range.getQualifyingPageNums(10)); } @Test @@ -49,7 +48,7 @@ public void addSinglesTest() { range.addSinglePage(5); range.addSinglePage(1); - Assert.assertEquals(Arrays.asList(5, 1), range.getQualifyingPageNums(7)); + Assertions.assertEquals(Arrays.asList(5, 1), range.getQualifyingPageNums(7)); } @Test @@ -57,7 +56,7 @@ public void addSequenceTest() { PageRange range = new PageRange(); range.addPageSequence(11, 19); - Assert.assertEquals(Arrays.asList(11, 12, 13, 14, 15, 16), range.getQualifyingPageNums(16)); + Assertions.assertEquals(Arrays.asList(11, 12, 13, 14, 15, 16), range.getQualifyingPageNums(16)); } @Test @@ -66,7 +65,7 @@ public void addSequenceAndSingleTest() { range.addPageSequence(22, 27); range.addSinglePage(25); - Assert.assertEquals(Arrays.asList(22, 23, 24, 25, 26, 27, 25), range.getQualifyingPageNums(30)); + Assertions.assertEquals(Arrays.asList(22, 23, 24, 25, 26, 27, 25), range.getQualifyingPageNums(30)); } @Test @@ -75,7 +74,7 @@ public void addSingleAndSequenceTest() { range.addSinglePage(5); range.addPageSequence(3, 8); - Assert.assertEquals(Arrays.asList(5, 3, 4, 5, 6, 7, 8), range.getQualifyingPageNums(10)); + Assertions.assertEquals(Arrays.asList(5, 3, 4, 5, 6, 7, 8), range.getQualifyingPageNums(10)); } @Test @@ -83,7 +82,7 @@ public void addCustomAfterTest() { PageRange range = new PageRange(); range.addPageRangePart(new PageRange.PageRangePartAfter(3)); - Assert.assertEquals(Arrays.asList(3, 4, 5), range.getQualifyingPageNums(5)); + Assertions.assertEquals(Arrays.asList(3, 4, 5), range.getQualifyingPageNums(5)); } @Test @@ -91,7 +90,7 @@ public void addCustomEvenTest() { PageRange range = new PageRange(); range.addPageRangePart(PageRange.PageRangePartOddEven.EVEN); - Assert.assertEquals(Arrays.asList(2, 4), range.getQualifyingPageNums(5)); + Assertions.assertEquals(Arrays.asList(2, 4), range.getQualifyingPageNums(5)); } @Test @@ -102,49 +101,49 @@ public void addCustomAndTest() { PageRange.IPageRangePart and = new PageRange.PageRangePartAnd(odd, seq); range.addPageRangePart(and); - Assert.assertEquals(Arrays.asList(3, 5, 7, 9, 11, 13), range.getQualifyingPageNums(15)); + Assertions.assertEquals(Arrays.asList(3, 5, 7, 9, 11, 13), range.getQualifyingPageNums(15)); } @Test public void addSingleConstructorTest() { PageRange range = new PageRange("5"); - Assert.assertEquals(Arrays.asList(5), range.getQualifyingPageNums(7)); + Assertions.assertEquals(Arrays.asList(5), range.getQualifyingPageNums(7)); } @Test public void addSinglesConstructorTest() { PageRange range = new PageRange("5, 1"); - Assert.assertEquals(Arrays.asList(5, 1), range.getQualifyingPageNums(10)); + Assertions.assertEquals(Arrays.asList(5, 1), range.getQualifyingPageNums(10)); } @Test public void addSinglesConstructorWithNegativeNumbersTest() { PageRange range = new PageRange("-5, -1"); - Assert.assertNotEquals(Arrays.asList(5, 1), range.getQualifyingPageNums(10)); + Assertions.assertNotEquals(Arrays.asList(5, 1), range.getQualifyingPageNums(10)); } @Test public void addSinglesConstructorWithWhitespacesTest() { PageRange range = new PageRange(" 5 , 1 "); - Assert.assertEquals(Arrays.asList(5, 1), range.getQualifyingPageNums(10)); + Assertions.assertEquals(Arrays.asList(5, 1), range.getQualifyingPageNums(10)); } @Test public void addSinglesConstructorWithLetterTest() { PageRange range = new PageRange("5, A, 1"); - Assert.assertEquals(Arrays.asList(5, 1), range.getQualifyingPageNums(10)); + Assertions.assertEquals(Arrays.asList(5, 1), range.getQualifyingPageNums(10)); } @Test public void addSequenceConstructorTest() { PageRange range = new PageRange("11-19"); - Assert.assertEquals(Arrays.asList(11, 12, 13, 14, 15, 16), range.getQualifyingPageNums(16)); + Assertions.assertEquals(Arrays.asList(11, 12, 13, 14, 15, 16), range.getQualifyingPageNums(16)); } @Test @@ -153,79 +152,79 @@ public void addSequenceConstructorWithWhitespacesTest() { PageRange range2 = new PageRange(" 11 -19"); PageRange range3 = new PageRange(" 11 - 19"); - Assert.assertEquals(Arrays.asList(11, 12, 13, 14, 15, 16), range1.getQualifyingPageNums(16)); - Assert.assertEquals(Arrays.asList(11, 12, 13, 14, 15, 16), range2.getQualifyingPageNums(16)); - Assert.assertEquals(Arrays.asList(11, 12, 13, 14, 15, 16), range3.getQualifyingPageNums(16)); + Assertions.assertEquals(Arrays.asList(11, 12, 13, 14, 15, 16), range1.getQualifyingPageNums(16)); + Assertions.assertEquals(Arrays.asList(11, 12, 13, 14, 15, 16), range2.getQualifyingPageNums(16)); + Assertions.assertEquals(Arrays.asList(11, 12, 13, 14, 15, 16), range3.getQualifyingPageNums(16)); } @Test public void addSequenceAndSingleConstructorTest() { PageRange range = new PageRange("22-27,25"); - Assert.assertEquals(Arrays.asList(22, 23, 24, 25, 26, 27, 25), range.getQualifyingPageNums(30)); + Assertions.assertEquals(Arrays.asList(22, 23, 24, 25, 26, 27, 25), range.getQualifyingPageNums(30)); } @Test public void addSingleAndSequenceConstructorTest() { PageRange range = new PageRange("5, 3-8"); - Assert.assertEquals(Arrays.asList(5, 3, 4, 5, 6, 7, 8), range.getQualifyingPageNums(10)); + Assertions.assertEquals(Arrays.asList(5, 3, 4, 5, 6, 7, 8), range.getQualifyingPageNums(10)); } @Test public void addCustomAfterConstructorTest() { PageRange range = new PageRange("3-"); - Assert.assertEquals(Arrays.asList(3, 4, 5), range.getQualifyingPageNums(5)); + Assertions.assertEquals(Arrays.asList(3, 4, 5), range.getQualifyingPageNums(5)); } @Test public void addCustomEvenConstructorTest() { PageRange range = new PageRange("even"); - Assert.assertEquals(Arrays.asList(2, 4), range.getQualifyingPageNums(5)); + Assertions.assertEquals(Arrays.asList(2, 4), range.getQualifyingPageNums(5)); } @Test public void addCustomAndConstructorTest() { PageRange range = new PageRange("odd & 2-14"); - Assert.assertEquals(Arrays.asList(3, 5, 7, 9, 11, 13), range.getQualifyingPageNums(15)); + Assertions.assertEquals(Arrays.asList(3, 5, 7, 9, 11, 13), range.getQualifyingPageNums(15)); } @Test public void addIncorrectCustomAndConstructorTest() { PageRange range = new PageRange("&"); - Assert.assertEquals(new ArrayList<>(), range.getQualifyingPageNums(0)); + Assertions.assertEquals(new ArrayList<>(), range.getQualifyingPageNums(0)); } @Test public void addIncorrectConstructorTest() { PageRange range = new PageRange(""); - Assert.assertEquals(new ArrayList<>(), range.getQualifyingPageNums(0)); + Assertions.assertEquals(new ArrayList<>(), range.getQualifyingPageNums(0)); } @Test public void isPageInRangeTrueTest() { PageRange range = new PageRange("3-8"); - Assert.assertTrue(range.isPageInRange(6)); + Assertions.assertTrue(range.isPageInRange(6)); } @Test public void isPageInRangeFalseTest() { PageRange range = new PageRange("3-8"); - Assert.assertFalse(range.isPageInRange(2)); + Assertions.assertFalse(range.isPageInRange(2)); } @Test public void addSequenceConstructorWithNegativeNumberTest() { PageRange range = new PageRange("-3-8"); - Assert.assertEquals(new ArrayList<>(), range.getQualifyingPageNums(3)); + Assertions.assertEquals(new ArrayList<>(), range.getQualifyingPageNums(3)); } @Test @@ -233,15 +232,15 @@ public void addSequenceConstructorWithLetterTest() { PageRange range1 = new PageRange("3-F"); PageRange range2 = new PageRange("3-8F"); - Assert.assertEquals(new ArrayList<>(), range1.getQualifyingPageNums(3)); - Assert.assertEquals(new ArrayList<>(), range2.getQualifyingPageNums(3)); + Assertions.assertEquals(new ArrayList<>(), range1.getQualifyingPageNums(3)); + Assertions.assertEquals(new ArrayList<>(), range2.getQualifyingPageNums(3)); } @Test public void checkPageRangeEqualsNullTest() { PageRange range1 = new PageRange("3-8"); - Assert.assertFalse(range1.equals(null)); + Assertions.assertFalse(range1.equals(null)); } @Test @@ -250,8 +249,8 @@ public void checkPageRangeEqualsAndHashCodeTest() { PageRange range2 = new PageRange("3-8"); boolean result = range1.equals(range2); - Assert.assertTrue(result); - Assert.assertEquals(range1.hashCode(), range2.hashCode()); + Assertions.assertTrue(result); + Assertions.assertEquals(range1.hashCode(), range2.hashCode()); } @Test @@ -260,36 +259,36 @@ public void checkPageRangeNotEqualsAndHashCodeTest() { PageRange range2 = new PageRange("1-2"); boolean result = range1.equals(range2); - Assert.assertFalse(result); - Assert.assertNotEquals(range1.hashCode(), range2.hashCode()); + Assertions.assertFalse(result); + Assertions.assertNotEquals(range1.hashCode(), range2.hashCode()); } @Test public void getAllPagesInRangeEmptyTest() { PageRange.PageRangePartSingle pageRangePartSingle = new PageRange.PageRangePartSingle(10); - Assert.assertEquals(new ArrayList<>(), pageRangePartSingle.getAllPagesInRange(4)); + Assertions.assertEquals(new ArrayList<>(), pageRangePartSingle.getAllPagesInRange(4)); } @Test public void isRangePartSingleInRangeTrueTest() { PageRange.PageRangePartSingle pageRangePartSingle = new PageRange.PageRangePartSingle(10); - Assert.assertTrue(pageRangePartSingle.isPageInRange(10)); + Assertions.assertTrue(pageRangePartSingle.isPageInRange(10)); } @Test public void isRangePartSingleInRangeFalseTest() { PageRange.PageRangePartSingle pageRangePartSingle = new PageRange.PageRangePartSingle(10); - Assert.assertFalse(pageRangePartSingle.isPageInRange(1)); + Assertions.assertFalse(pageRangePartSingle.isPageInRange(1)); } @Test public void checkRangePartSingleEqualsNullTest() { PageRange.PageRangePartSingle pageRangePartSingle = new PageRange.PageRangePartSingle(10); - Assert.assertFalse(pageRangePartSingle.equals(null)); + Assertions.assertFalse(pageRangePartSingle.equals(null)); } @Test @@ -298,8 +297,8 @@ public void checkRangePartSingleEqualsAndHashCodeTest() { PageRange.PageRangePartSingle pageRangePartSingle2 = new PageRange.PageRangePartSingle(10); boolean result = pageRangePartSingle1.equals(pageRangePartSingle2); - Assert.assertTrue(result); - Assert.assertEquals(pageRangePartSingle1.hashCode(), pageRangePartSingle2.hashCode()); + Assertions.assertTrue(result); + Assertions.assertEquals(pageRangePartSingle1.hashCode(), pageRangePartSingle2.hashCode()); } @Test @@ -308,15 +307,15 @@ public void checkRangePartSingleNotEqualsAndHashCodeTest() { PageRange.PageRangePartSingle pageRangePartSingle2 = new PageRange.PageRangePartSingle(1); boolean result = pageRangePartSingle1.equals(pageRangePartSingle2); - Assert.assertFalse(result); - Assert.assertNotEquals(pageRangePartSingle1.hashCode(), pageRangePartSingle2.hashCode()); + Assertions.assertFalse(result); + Assertions.assertNotEquals(pageRangePartSingle1.hashCode(), pageRangePartSingle2.hashCode()); } @Test public void checkRangePartSequenceEqualsNullTest() { PageRange.PageRangePartSequence pageRangePartSequence = new PageRange.PageRangePartSequence(1, 2); - Assert.assertFalse(pageRangePartSequence.equals(null)); + Assertions.assertFalse(pageRangePartSequence.equals(null)); } @Test @@ -325,8 +324,8 @@ public void checkRangePartSequenceEqualsAndHashCodeTest() { PageRange.PageRangePartSequence pageRangePartSequence2 = new PageRange.PageRangePartSequence(1, 2); boolean result = pageRangePartSequence.equals(pageRangePartSequence2); - Assert.assertTrue(result); - Assert.assertEquals(pageRangePartSequence.hashCode(), pageRangePartSequence2.hashCode()); + Assertions.assertTrue(result); + Assertions.assertEquals(pageRangePartSequence.hashCode(), pageRangePartSequence2.hashCode()); } @Test @@ -335,29 +334,29 @@ public void checkRangePartSequenceNotEqualsAndHashCodeTest() { PageRange.PageRangePartSequence pageRangePartSequence2 = new PageRange.PageRangePartSequence(3, 4); boolean result = pageRangePartSequence.equals(pageRangePartSequence2); - Assert.assertFalse(result); - Assert.assertNotEquals(pageRangePartSequence.hashCode(), pageRangePartSequence2.hashCode()); + Assertions.assertFalse(result); + Assertions.assertNotEquals(pageRangePartSequence.hashCode(), pageRangePartSequence2.hashCode()); } @Test public void isRangePartAfterInRangeTrueTest() { PageRange.PageRangePartAfter pageRangePartAfter = new PageRange.PageRangePartAfter(10); - Assert.assertTrue(pageRangePartAfter.isPageInRange(11)); + Assertions.assertTrue(pageRangePartAfter.isPageInRange(11)); } @Test public void isRangePartAfterInRangeFalseTest() { PageRange.PageRangePartAfter pageRangePartAfter = new PageRange.PageRangePartAfter(10); - Assert.assertFalse(pageRangePartAfter.isPageInRange(1)); + Assertions.assertFalse(pageRangePartAfter.isPageInRange(1)); } @Test public void checkRangePartAfterEqualsNullTest() { PageRange.PageRangePartAfter pageRangePartAfter = new PageRange.PageRangePartAfter(10); - Assert.assertFalse(pageRangePartAfter.equals(null)); + Assertions.assertFalse(pageRangePartAfter.equals(null)); } @Test @@ -366,8 +365,8 @@ public void checkRangePartAfterEqualsAndHashCodeTest() { PageRange.PageRangePartAfter pageRangePartAfter2 = new PageRange.PageRangePartAfter(10); boolean result = pageRangePartAfter.equals(pageRangePartAfter2); - Assert.assertTrue(result); - Assert.assertEquals(pageRangePartAfter.hashCode(), pageRangePartAfter2.hashCode()); + Assertions.assertTrue(result); + Assertions.assertEquals(pageRangePartAfter.hashCode(), pageRangePartAfter2.hashCode()); } @Test @@ -376,44 +375,44 @@ public void checkRangePartAfterNotEqualsAndHashCodeTest() { PageRange.PageRangePartAfter pageRangePartAfter2 = new PageRange.PageRangePartAfter(1); boolean result = pageRangePartAfter.equals(pageRangePartAfter2); - Assert.assertFalse(result); - Assert.assertNotEquals(pageRangePartAfter.hashCode(), pageRangePartAfter2.hashCode()); + Assertions.assertFalse(result); + Assertions.assertNotEquals(pageRangePartAfter.hashCode(), pageRangePartAfter2.hashCode()); } @Test public void isRangePartOddEvenInRangeTrueTest() { - Assert.assertTrue(PageRange.PageRangePartOddEven.ODD.isPageInRange(11)); - Assert.assertTrue(PageRange.PageRangePartOddEven.EVEN.isPageInRange(10)); + Assertions.assertTrue(PageRange.PageRangePartOddEven.ODD.isPageInRange(11)); + Assertions.assertTrue(PageRange.PageRangePartOddEven.EVEN.isPageInRange(10)); } @Test public void isRangePartOddEvenInRangeFalseTest() { - Assert.assertFalse(PageRange.PageRangePartOddEven.ODD.isPageInRange(10)); - Assert.assertFalse(PageRange.PageRangePartOddEven.EVEN.isPageInRange(11)); + Assertions.assertFalse(PageRange.PageRangePartOddEven.ODD.isPageInRange(10)); + Assertions.assertFalse(PageRange.PageRangePartOddEven.EVEN.isPageInRange(11)); } @Test public void checkRangePartOddEvenEqualsNullTest() { - Assert.assertFalse(PageRange.PageRangePartOddEven.EVEN.equals(null)); - Assert.assertFalse(PageRange.PageRangePartOddEven.ODD.equals(null)); + Assertions.assertFalse(PageRange.PageRangePartOddEven.EVEN.equals(null)); + Assertions.assertFalse(PageRange.PageRangePartOddEven.ODD.equals(null)); } @Test public void checkRangePartOddEvenEqualsAndHashCodeTest() { - Assert.assertTrue(PageRange.PageRangePartOddEven.EVEN.equals(PageRange.PageRangePartOddEven.EVEN)); - Assert.assertTrue(PageRange.PageRangePartOddEven.ODD.equals(PageRange.PageRangePartOddEven.ODD)); + Assertions.assertTrue(PageRange.PageRangePartOddEven.EVEN.equals(PageRange.PageRangePartOddEven.EVEN)); + Assertions.assertTrue(PageRange.PageRangePartOddEven.ODD.equals(PageRange.PageRangePartOddEven.ODD)); - Assert.assertEquals(PageRange.PageRangePartOddEven.EVEN.hashCode(), + Assertions.assertEquals(PageRange.PageRangePartOddEven.EVEN.hashCode(), PageRange.PageRangePartOddEven.EVEN.hashCode()); - Assert.assertEquals(PageRange.PageRangePartOddEven.ODD.hashCode(), + Assertions.assertEquals(PageRange.PageRangePartOddEven.ODD.hashCode(), PageRange.PageRangePartOddEven.ODD.hashCode()); } @Test public void checkRangePartOddEvenNotEqualsAndHashCodeTest() { - Assert.assertFalse(PageRange.PageRangePartOddEven.EVEN.equals(PageRange.PageRangePartOddEven.ODD)); + Assertions.assertFalse(PageRange.PageRangePartOddEven.EVEN.equals(PageRange.PageRangePartOddEven.ODD)); - Assert.assertNotEquals(PageRange.PageRangePartOddEven.EVEN.hashCode(), + Assertions.assertNotEquals(PageRange.PageRangePartOddEven.EVEN.hashCode(), PageRange.PageRangePartOddEven.ODD.hashCode()); } @@ -423,7 +422,7 @@ public void isRangePartAndInRangeTrueTest() { PageRange.IPageRangePart seq = new PageRange.PageRangePartSequence(2, 14); PageRange.PageRangePartAnd pageRangePartAnd = new PageRange.PageRangePartAnd(odd, seq); - Assert.assertTrue(pageRangePartAnd.isPageInRange(5)); + Assertions.assertTrue(pageRangePartAnd.isPageInRange(5)); } @Test @@ -432,7 +431,7 @@ public void isRangePartAndInRangeFalseTest() { PageRange.IPageRangePart seq = new PageRange.PageRangePartSequence(2, 14); PageRange.PageRangePartAnd pageRangePartAnd = new PageRange.PageRangePartAnd(odd, seq); - Assert.assertFalse(pageRangePartAnd.isPageInRange(1)); + Assertions.assertFalse(pageRangePartAnd.isPageInRange(1)); } @Test @@ -441,7 +440,7 @@ public void checkRangePartAndEqualsNullTest() { PageRange.IPageRangePart seq = new PageRange.PageRangePartSequence(2, 14); PageRange.PageRangePartAnd pageRangePartAnd = new PageRange.PageRangePartAnd(odd, seq); - Assert.assertFalse(pageRangePartAnd.equals(null)); + Assertions.assertFalse(pageRangePartAnd.equals(null)); } @Test @@ -452,8 +451,8 @@ public void checkRangePartAndEqualsAndHashCodeTest() { PageRange.PageRangePartAnd pageRangePartAnd2 = new PageRange.PageRangePartAnd(odd, seq); boolean result = pageRangePartAnd.equals(pageRangePartAnd2); - Assert.assertTrue(result); - Assert.assertEquals(pageRangePartAnd.hashCode(), pageRangePartAnd2.hashCode()); + Assertions.assertTrue(result); + Assertions.assertEquals(pageRangePartAnd.hashCode(), pageRangePartAnd2.hashCode()); } @Test @@ -464,7 +463,7 @@ public void checkRangePartAndNotEqualsAndHashCodeTest() { PageRange.PageRangePartAnd pageRangePartAnd2 = new PageRange.PageRangePartAnd(); boolean result = pageRangePartAnd.equals(pageRangePartAnd2); - Assert.assertFalse(result); - Assert.assertNotEquals(pageRangePartAnd.hashCode(), pageRangePartAnd2.hashCode()); + Assertions.assertFalse(result); + Assertions.assertNotEquals(pageRangePartAnd.hashCode(), pageRangePartAnd2.hashCode()); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/utils/PdfAnnotationFlattenerTest.java b/kernel/src/test/java/com/itextpdf/kernel/utils/PdfAnnotationFlattenerTest.java index fb93eb2a96..5c87539693 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/utils/PdfAnnotationFlattenerTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/utils/PdfAnnotationFlattenerTest.java @@ -56,30 +56,29 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.List; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfAnnotationFlattenerTest extends ExtendedITextTest { public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/kernel/utils/flatteningTest/"; public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/kernel/utils/flatteningTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(DESTINATION_FOLDER); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(DESTINATION_FOLDER); } @@ -90,7 +89,7 @@ public void testNullAnnotations() { pdfDoc.addNewPage(); PdfAnnotationFlattener flattener = new PdfAnnotationFlattener(); List annotations = null; - Assert.assertThrows(PdfException.class, () -> { + Assertions.assertThrows(PdfException.class, () -> { flattener.flatten(annotations); }); } @@ -101,7 +100,7 @@ public void testNullAnnotations() { public void testNullDocument() { PdfDocument pdfDoc = null; PdfAnnotationFlattener flattener = new PdfAnnotationFlattener(); - Assert.assertThrows(PdfException.class, () -> { + Assertions.assertThrows(PdfException.class, () -> { flattener.flatten(pdfDoc); }); } @@ -112,7 +111,7 @@ public void testNullPageDrawAppearanceWorker() { pdfDoc.addNewPage(); IAnnotationFlattener flattener = new DefaultAnnotationFlattener(); PdfPage page = pdfDoc.getFirstPage(); - Assert.assertThrows(PdfException.class, () -> { + Assertions.assertThrows(PdfException.class, () -> { flattener.flatten(null, page); }); } @@ -123,7 +122,7 @@ public void testNullAnnotationDrawAppearanceWorker() { try (PdfDocument pdfDoc = new PdfDocument(new PdfWriter(new ByteArrayOutputStream()))) { pdfDoc.addNewPage(); IAnnotationFlattener flattener = new DefaultAnnotationFlattener(); - Assert.assertThrows(PdfException.class, () -> { + Assertions.assertThrows(PdfException.class, () -> { flattener.flatten(new PdfLinkAnnotation(new Rectangle(20, 20)), null); }); } @@ -135,7 +134,7 @@ public void testEmptyAnnotations() { pdfDoc.addNewPage(); PdfAnnotationFlattener flattener = new PdfAnnotationFlattener(); flattener.flatten(new ArrayList<>()); - Assert.assertEquals(0, pdfDoc.getFirstPage().getAnnotsSize()); + Assertions.assertEquals(0, pdfDoc.getFirstPage().getAnnotsSize()); } } @@ -171,7 +170,7 @@ public void defaultAppearanceGetsRendered() throws IOException, InterruptedExcep worker.flatten(annotation, pdfDoc.getFirstPage()); } - Assert.assertNull( + Assertions.assertNull( new CompareTool().compareByContent(resultFile, SOURCE_FOLDER + "cmp_default_annotations_app.pdf", DESTINATION_FOLDER, "diff_")); @@ -190,7 +189,7 @@ public void unknownAnnotationsDefaultImplementation() { PdfAnnotationFlattener flattener = new PdfAnnotationFlattener(); flattener.flatten(Collections.singletonList(unknownAnnotation)); //Annotation is not removed in default implementation - Assert.assertEquals(1, pdfDoc.getFirstPage().getAnnotsSize()); + Assertions.assertEquals(1, pdfDoc.getFirstPage().getAnnotsSize()); } } @@ -206,7 +205,7 @@ public void nullTypeAnnotationsDefaultImplementation() { PdfAnnotationFlattener flattener = new PdfAnnotationFlattener(); flattener.flatten(Collections.singletonList(unknownAnnotation)); //Annotation is not removed in default implementation - Assert.assertEquals(1, pdfDoc.getFirstPage().getAnnotsSize()); + Assertions.assertEquals(1, pdfDoc.getFirstPage().getAnnotsSize()); } } @@ -220,7 +219,7 @@ public void overwriteDefaultImplementation() { setBorder(new PdfArray(borders))); PdfAnnotationFlattener flattener = new PdfAnnotationFlattener(new CustomPdfAnnotationFlattenFactory()); flattener.flatten(pdfDoc.getFirstPage().getAnnotations()); - Assert.assertEquals(0, pdfDoc.getFirstPage().getAnnotsSize()); + Assertions.assertEquals(0, pdfDoc.getFirstPage().getAnnotsSize()); } } @@ -247,7 +246,7 @@ public void removeQuadPoints() throws IOException, InterruptedException { } //it is expected that the line is the middle of the page because the annotation whole rectangle is the // size of the page, it's also expected that underline will not show up as it is at the bottom of the page - Assert.assertNull( + Assertions.assertNull( new CompareTool().compareByContent(resultFile, SOURCE_FOLDER + "cmp_text_quadpoints.pdf", DESTINATION_FOLDER, "diff_")); } @@ -276,7 +275,7 @@ public void invalidQuadPoints() throws IOException, InterruptedException { } //it is expected that the line is the middle of the page because the annotation whole rectangle is the // size of the page, it's also expected that underline will not show up as it is at the bottom of the page - Assert.assertNull( + Assertions.assertNull( new CompareTool().compareByContent(resultFile, SOURCE_FOLDER + "cmp_invalid_quadpoints.pdf", DESTINATION_FOLDER, "diff_")); } @@ -291,7 +290,7 @@ public void testEmptyParamListDoesntDeleteAnyAnnots() { setBorder(new PdfArray(borders))); PdfAnnotationFlattener flattener = new PdfAnnotationFlattener(); flattener.flatten(new ArrayList<>()); - Assert.assertEquals(1, pdfDoc.getFirstPage().getAnnotsSize()); + Assertions.assertEquals(1, pdfDoc.getFirstPage().getAnnotsSize()); } } @@ -310,8 +309,8 @@ public void testListFromDifferentPageDoesntDeleteAnyAnnotsButWarnsUser() { setBorder(new PdfArray(borders))); PdfAnnotationFlattener flattener = new PdfAnnotationFlattener(); flattener.flatten(pdfDoc.getPage(2).getAnnotations()); - Assert.assertEquals(1, pdfDoc.getFirstPage().getAnnotsSize()); - Assert.assertEquals(1, pdfDoc.getPage(2).getAnnotsSize()); + Assertions.assertEquals(1, pdfDoc.getFirstPage().getAnnotsSize()); + Assertions.assertEquals(1, pdfDoc.getPage(2).getAnnotsSize()); } } @@ -323,7 +322,7 @@ public void flattenPdfLink() throws IOException, InterruptedException { CompareTool.createTestPdfWriter(resultFile))) { new PdfAnnotationFlattener().flatten(pdfDoc); } - Assert.assertNull( + Assertions.assertNull( new CompareTool().compareByContent(resultFile, SOURCE_FOLDER + "cmp_flattened_pdf_link.pdf", DESTINATION_FOLDER, "diff_")); } @@ -347,7 +346,7 @@ public void flattenPdfLinkWithDefaultAppearance() throws IOException, Interrupte annot.setNormalAppearance(formN.getPdfObject()); new PdfAnnotationFlattener().flatten(pdfDoc); } - Assert.assertNull( + Assertions.assertNull( new CompareTool().compareByContent(resultFile, SOURCE_FOLDER + "cmp_flattened_DA_pdf_link.pdf", DESTINATION_FOLDER, "diff_")); } @@ -380,7 +379,7 @@ public void flattenTextMarkupAnnotations() new PdfAnnotationFlattener() .flatten(pdfDoc.getFirstPage().getAnnotations()); } - Assert.assertNull( + Assertions.assertNull( new CompareTool().compareByContent(resultFile, SOURCE_FOLDER + "cmp_text_markup_flatten.pdf", DESTINATION_FOLDER, "diff_")); } @@ -393,9 +392,9 @@ public void flattenLinkAnnotationTest() throws IOException, InterruptedException try (PdfDocument document = new PdfDocument(new PdfReader(sourceFile), CompareTool.createTestPdfWriter(resultFile))) { PdfAnnotationFlattener flattener = new PdfAnnotationFlattener(); flattener.flatten(document); - Assert.assertEquals(1, document.getFirstPage().getAnnotations().size()); + Assertions.assertEquals(1, document.getFirstPage().getAnnotations().size()); } - Assert.assertNull( + Assertions.assertNull( new CompareTool().compareByContent(resultFile, SOURCE_FOLDER + "cmp_flattenLinkAnnotationTest.pdf", DESTINATION_FOLDER, "diff_")); } @@ -409,10 +408,10 @@ public void flattenWidgetAnnotationTest() throws IOException, InterruptedExcepti try (PdfDocument document = new PdfDocument(new PdfReader(sourceFile), CompareTool.createTestPdfWriter(resultFile))) { PdfAnnotationFlattener flattener = new PdfAnnotationFlattener(); List annot = flattener.flatten(document); - Assert.assertEquals(1, annot.size()); - Assert.assertEquals(1, document.getFirstPage().getAnnotations().size()); + Assertions.assertEquals(1, annot.size()); + Assertions.assertEquals(1, document.getFirstPage().getAnnotations().size()); } - Assert.assertNull( + Assertions.assertNull( new CompareTool().compareByContent(resultFile, SOURCE_FOLDER + "cmp_flattenWidgetAnnotationTest.pdf", DESTINATION_FOLDER, "diff_")); } @@ -424,9 +423,9 @@ public void flattenScreenAnnotationTest() throws IOException, InterruptedExcepti try (PdfDocument document = new PdfDocument(new PdfReader(sourceFile), CompareTool.createTestPdfWriter(resultFile))) { PdfAnnotationFlattener flattener = new PdfAnnotationFlattener(); flattener.flatten(document); - Assert.assertEquals(0, document.getFirstPage().getAnnotations().size()); + Assertions.assertEquals(0, document.getFirstPage().getAnnotations().size()); } - Assert.assertNull( + Assertions.assertNull( new CompareTool().compareByContent(resultFile, SOURCE_FOLDER + "cmp_flattenScreenAnnotationTest.pdf", DESTINATION_FOLDER, "diff_")); } @@ -438,9 +437,9 @@ public void flatten3DAnnotationTest() throws IOException, InterruptedException { try (PdfDocument document = new PdfDocument(new PdfReader(sourceFile), CompareTool.createTestPdfWriter(resultFile))) { PdfAnnotationFlattener flattener = new PdfAnnotationFlattener(); flattener.flatten(document); - Assert.assertEquals(0, document.getFirstPage().getAnnotations().size()); + Assertions.assertEquals(0, document.getFirstPage().getAnnotations().size()); } - Assert.assertNull( + Assertions.assertNull( new CompareTool().compareByContent(resultFile, SOURCE_FOLDER + "cmp_flatten3DAnnotationTest.pdf", DESTINATION_FOLDER, "diff_")); } @@ -453,9 +452,9 @@ public void flattenHighlightAnnotationTest() throws IOException, InterruptedExce PdfAnnotationFlattener flattener = new PdfAnnotationFlattener(); flattener.flatten(document); - Assert.assertEquals(0, document.getFirstPage().getAnnotations().size()); + Assertions.assertEquals(0, document.getFirstPage().getAnnotations().size()); } - Assert.assertNull( + Assertions.assertNull( new CompareTool().compareByContent(resultFile, SOURCE_FOLDER + "cmp_flattenHighlightAnnotationTest.pdf", DESTINATION_FOLDER, "diff_")); } @@ -468,10 +467,10 @@ public void flattenUnderlineAnnotationTest() throws IOException, InterruptedExce PdfAnnotationFlattener flattener = new PdfAnnotationFlattener(); flattener.flatten(document); - Assert.assertEquals(0, document.getFirstPage().getAnnotations().size()); + Assertions.assertEquals(0, document.getFirstPage().getAnnotations().size()); } - Assert.assertNull( + Assertions.assertNull( new CompareTool().compareByContent(resultFile, SOURCE_FOLDER + "cmp_flattenUnderlineAnnotationTest.pdf", DESTINATION_FOLDER, "diff_")); } @@ -484,10 +483,10 @@ public void flattenSquigglyAnnotationTest() throws IOException, InterruptedExcep PdfAnnotationFlattener flattener = new PdfAnnotationFlattener(); flattener.flatten(document); - Assert.assertEquals(0, document.getFirstPage().getAnnotations().size()); + Assertions.assertEquals(0, document.getFirstPage().getAnnotations().size()); } - Assert.assertNull( + Assertions.assertNull( new CompareTool().compareByContent(resultFile, SOURCE_FOLDER + "cmp_flattenSquigglyAnnotationTest.pdf", DESTINATION_FOLDER, "diff_")); } @@ -500,10 +499,10 @@ public void flattenStrikeOutAnnotationTest() throws IOException, InterruptedExce PdfAnnotationFlattener flattener = new PdfAnnotationFlattener(); flattener.flatten(document); - Assert.assertEquals(0, document.getFirstPage().getAnnotations().size()); + Assertions.assertEquals(0, document.getFirstPage().getAnnotations().size()); } - Assert.assertNull( + Assertions.assertNull( new CompareTool().compareByContent(resultFile, SOURCE_FOLDER + "cmp_flattenStrikeOutAnnotationTest.pdf", DESTINATION_FOLDER, "diff_")); } @@ -516,10 +515,10 @@ public void flattenCaretAnnotationTest() throws IOException, InterruptedExceptio PdfAnnotationFlattener flattener = new PdfAnnotationFlattener(); flattener.flatten(document); - Assert.assertEquals(0, document.getFirstPage().getAnnotations().size()); + Assertions.assertEquals(0, document.getFirstPage().getAnnotations().size()); } - Assert.assertNull( + Assertions.assertNull( new CompareTool().compareByContent(resultFile, SOURCE_FOLDER + "cmp_flattenCaretAnnotationTest.pdf", DESTINATION_FOLDER, "diff_")); } @@ -532,10 +531,10 @@ public void flattenTextAnnotationTest() throws IOException, InterruptedException PdfAnnotationFlattener flattener = new PdfAnnotationFlattener(); flattener.flatten(document); - Assert.assertEquals(0, document.getFirstPage().getAnnotations().size()); + Assertions.assertEquals(0, document.getFirstPage().getAnnotations().size()); } - Assert.assertNull( + Assertions.assertNull( new CompareTool().compareByContent(resultFile, SOURCE_FOLDER + "cmp_flattenTextAnnotationTest.pdf", DESTINATION_FOLDER, "diff_")); } @@ -548,10 +547,10 @@ public void flattenSoundAnnotationTest() throws IOException, InterruptedExceptio PdfAnnotationFlattener flattener = new PdfAnnotationFlattener(); flattener.flatten(document); - Assert.assertEquals(0, document.getFirstPage().getAnnotations().size()); + Assertions.assertEquals(0, document.getFirstPage().getAnnotations().size()); } - Assert.assertNull( + Assertions.assertNull( new CompareTool().compareByContent(resultFile, SOURCE_FOLDER + "cmp_flattenSoundAnnotationTest.pdf", DESTINATION_FOLDER, "diff_")); } @@ -562,11 +561,11 @@ public void flattenStampAnnotationTest() throws IOException, InterruptedExceptio String resultFile = DESTINATION_FOLDER + "flattenStampAnnotationTest.pdf"; try (PdfDocument document = new PdfDocument(new PdfReader(sourceFile), CompareTool.createTestPdfWriter(resultFile))) { PdfAnnotationFlattener flattener = new PdfAnnotationFlattener(); - Assert.assertEquals(0, flattener.flatten(document).size()); - Assert.assertEquals(0, document.getFirstPage().getAnnotations().size()); + Assertions.assertEquals(0, flattener.flatten(document).size()); + Assertions.assertEquals(0, document.getFirstPage().getAnnotations().size()); } - Assert.assertNull( + Assertions.assertNull( new CompareTool().compareByContent(resultFile, SOURCE_FOLDER + "cmp_flattenStampAnnotationTest.pdf", DESTINATION_FOLDER, "diff_")); } @@ -579,10 +578,10 @@ public void flattenFileAttachmentAnnotationTest() throws IOException, Interrupte PdfAnnotationFlattener flattener = new PdfAnnotationFlattener(); flattener.flatten(document); - Assert.assertEquals(0, document.getFirstPage().getAnnotations().size()); + Assertions.assertEquals(0, document.getFirstPage().getAnnotations().size()); } - Assert.assertNull( + Assertions.assertNull( new CompareTool().compareByContent(resultFile, SOURCE_FOLDER + "cmp_flattenFileAttachmentAnnotationTest.pdf", DESTINATION_FOLDER, "diff_")); @@ -596,10 +595,10 @@ public void flattenInkAnnotationTest() throws IOException, InterruptedException PdfAnnotationFlattener flattener = new PdfAnnotationFlattener(); flattener.flatten(document); - Assert.assertEquals(0, document.getFirstPage().getAnnotations().size()); + Assertions.assertEquals(0, document.getFirstPage().getAnnotations().size()); } - Assert.assertNull( + Assertions.assertNull( new CompareTool().compareByContent(resultFile, SOURCE_FOLDER + "cmp_flattenInkAnnotationTest.pdf", DESTINATION_FOLDER, "diff_")); } @@ -612,10 +611,10 @@ public void flattenPrinterMarkAnnotationTest() throws IOException, InterruptedEx PdfAnnotationFlattener flattener = new PdfAnnotationFlattener(); flattener.flatten(document); - Assert.assertEquals(0, document.getFirstPage().getAnnotations().size()); + Assertions.assertEquals(0, document.getFirstPage().getAnnotations().size()); } - Assert.assertNull( + Assertions.assertNull( new CompareTool().compareByContent(resultFile, SOURCE_FOLDER + "cmp_flattenPrinterMarkAnnotationTest.pdf", DESTINATION_FOLDER, "diff_")); @@ -629,10 +628,10 @@ public void flattenTrapNetAnnotationTest() throws IOException, InterruptedExcept PdfAnnotationFlattener flattener = new PdfAnnotationFlattener(); flattener.flatten(document); - Assert.assertEquals(0, document.getFirstPage().getAnnotations().size()); + Assertions.assertEquals(0, document.getFirstPage().getAnnotations().size()); } - Assert.assertNull( + Assertions.assertNull( new CompareTool().compareByContent(resultFile, SOURCE_FOLDER + "cmp_flattenTrapNetAnnotationTest.pdf", DESTINATION_FOLDER, "diff_")); } @@ -641,7 +640,7 @@ public void flattenTrapNetAnnotationTest() throws IOException, InterruptedExcept public void testWarnAnnotationFlattenerAnnotNull() { WarnFormfieldFlattener warnFormfieldFlattener = new WarnFormfieldFlattener(); PdfPage page = null; - Assert.assertThrows(PdfException.class, () -> { + Assertions.assertThrows(PdfException.class, () -> { warnFormfieldFlattener.flatten(null, page); }); } @@ -650,7 +649,7 @@ public void testWarnAnnotationFlattenerAnnotNull() { public void testWarnAnnotationFlattenerPageNull() { WarnFormfieldFlattener warnFormfieldFlattener = new WarnFormfieldFlattener(); PdfAnnotation annot = new PdfCircleAnnotation(new Rectangle(100, 100, 100, 100)); - Assert.assertThrows(PdfException.class, () -> { + Assertions.assertThrows(PdfException.class, () -> { warnFormfieldFlattener.flatten(annot, null); }); } @@ -659,7 +658,7 @@ public void testWarnAnnotationFlattenerPageNull() { public void removeWithoutDrawingFormfieldFlattenerNull() { RemoveWithoutDrawingFlattener flattener = new RemoveWithoutDrawingFlattener(); PdfPage page = null; - Assert.assertThrows(PdfException.class, () -> { + Assertions.assertThrows(PdfException.class, () -> { flattener.flatten(null, page); }); } @@ -668,7 +667,7 @@ public void removeWithoutDrawingFormfieldFlattenerNull() { public void removeWithoutDrawingAnnotationFlattenerPageNull() { RemoveWithoutDrawingFlattener warnFormfieldFlattener = new RemoveWithoutDrawingFlattener(); PdfAnnotation annot = new PdfCircleAnnotation(new Rectangle(100, 100, 100, 100)); - Assert.assertThrows(PdfException.class, () -> { + Assertions.assertThrows(PdfException.class, () -> { warnFormfieldFlattener.flatten(annot, null); }); } @@ -682,10 +681,10 @@ public void flattenFreeTextAnnotationTest() throws IOException, InterruptedExcep PdfAnnotationFlattener flattener = new PdfAnnotationFlattener(); flattener.flatten(document); - Assert.assertEquals(0, document.getFirstPage().getAnnotations().size()); + Assertions.assertEquals(0, document.getFirstPage().getAnnotations().size()); } - Assert.assertNull( + Assertions.assertNull( new CompareTool().compareByContent(resultFile, SOURCE_FOLDER + "cmp_flattenFreeTextAnnotationTest.pdf", DESTINATION_FOLDER, "diff_")); } @@ -698,10 +697,10 @@ public void flattenSquareAnnotationTest() throws IOException, InterruptedExcepti PdfAnnotationFlattener flattener = new PdfAnnotationFlattener(); flattener.flatten(document); - Assert.assertEquals(0, document.getFirstPage().getAnnotations().size()); + Assertions.assertEquals(0, document.getFirstPage().getAnnotations().size()); } - Assert.assertNull( + Assertions.assertNull( new CompareTool().compareByContent(resultFile, SOURCE_FOLDER + "cmp_flattenSquareAnnotationTest.pdf", DESTINATION_FOLDER, "diff_")); } @@ -714,10 +713,10 @@ public void flattenCircleAnnotationTest() throws IOException, InterruptedExcepti PdfAnnotationFlattener flattener = new PdfAnnotationFlattener(); flattener.flatten(document); - Assert.assertEquals(0, document.getFirstPage().getAnnotations().size()); + Assertions.assertEquals(0, document.getFirstPage().getAnnotations().size()); } - Assert.assertNull( + Assertions.assertNull( new CompareTool().compareByContent(resultFile, SOURCE_FOLDER + "cmp_flattenCircleAnnotationTest.pdf", DESTINATION_FOLDER, "diff_")); } @@ -732,7 +731,7 @@ public void flatteningOfAnnotationListWithNullAnnotationContinues() { annots.add(null); flattener.flatten(annots); - Assert.assertEquals(0, document.getFirstPage().getAnnotations().size()); + Assertions.assertEquals(0, document.getFirstPage().getAnnotations().size()); } } @@ -745,7 +744,7 @@ public void flatteningOfAnnotationListWithNoPageAttachedAnnotationContinues() { annots.add(new PdfCircleAnnotation(new Rectangle(100, 100, 100, 100))); flattener.flatten(annots); - Assert.assertEquals(0, document.getFirstPage().getAnnotations().size()); + Assertions.assertEquals(0, document.getFirstPage().getAnnotations().size()); } } @@ -757,10 +756,10 @@ public void flattenLineAnnotationTest() throws IOException, InterruptedException PdfAnnotationFlattener flattener = new PdfAnnotationFlattener(); flattener.flatten(document); - Assert.assertEquals(0, document.getFirstPage().getAnnotations().size()); + Assertions.assertEquals(0, document.getFirstPage().getAnnotations().size()); } - Assert.assertNull( + Assertions.assertNull( new CompareTool().compareByContent(resultFile, SOURCE_FOLDER + "cmp_flattenLineAnnotationTest.pdf", DESTINATION_FOLDER, "diff_")); } @@ -773,10 +772,10 @@ public void flattenPolygonAnnotationTest() throws IOException, InterruptedExcept PdfAnnotationFlattener flattener = new PdfAnnotationFlattener(); flattener.flatten(document); - Assert.assertEquals(0, document.getFirstPage().getAnnotations().size()); + Assertions.assertEquals(0, document.getFirstPage().getAnnotations().size()); } - Assert.assertNull( + Assertions.assertNull( new CompareTool().compareByContent(resultFile, SOURCE_FOLDER + "cmp_flattenPolygonAnnotationTest.pdf", DESTINATION_FOLDER, "diff_")); } @@ -789,10 +788,10 @@ public void flattenPolyLineAnnotationTest() throws IOException, InterruptedExcep PdfAnnotationFlattener flattener = new PdfAnnotationFlattener(); flattener.flatten(document); - Assert.assertEquals(0, document.getFirstPage().getAnnotations().size()); + Assertions.assertEquals(0, document.getFirstPage().getAnnotations().size()); } - Assert.assertNull( + Assertions.assertNull( new CompareTool().compareByContent(resultFile, SOURCE_FOLDER + "cmp_flattenPolyLineAnnotationTest.pdf", DESTINATION_FOLDER, "diff_")); } @@ -805,10 +804,10 @@ public void flattenRedactAnnotationTest() throws IOException, InterruptedExcepti PdfAnnotationFlattener flattener = new PdfAnnotationFlattener(); flattener.flatten(document); - Assert.assertEquals(0, document.getFirstPage().getAnnotations().size()); + Assertions.assertEquals(0, document.getFirstPage().getAnnotations().size()); } - Assert.assertNull( + Assertions.assertNull( new CompareTool().compareByContent(resultFile, SOURCE_FOLDER + "cmp_flattenRedactAnnotationTest.pdf", DESTINATION_FOLDER, "diff_")); } @@ -821,10 +820,10 @@ public void flattenWatermarkAnnotationTest() throws IOException, InterruptedExce PdfAnnotationFlattener flattener = new PdfAnnotationFlattener(); flattener.flatten(document); - Assert.assertEquals(0, document.getFirstPage().getAnnotations().size()); + Assertions.assertEquals(0, document.getFirstPage().getAnnotations().size()); } - Assert.assertNull( + Assertions.assertNull( new CompareTool().compareByContent(resultFile, SOURCE_FOLDER + "cmp_flattenWatermarkAnnotationTest.pdf", DESTINATION_FOLDER, "diff_")); } diff --git a/kernel/src/test/java/com/itextpdf/kernel/utils/PdfMergerTest.java b/kernel/src/test/java/com/itextpdf/kernel/utils/PdfMergerTest.java index b2ce4abfb4..82c4177396 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/utils/PdfMergerTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/utils/PdfMergerTest.java @@ -32,32 +32,31 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.List; import javax.xml.parsers.ParserConfigurationException; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import org.xml.sax.SAXException; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfMergerTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/kernel/utils/PdfMergerTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/kernel/utils/PdfMergerTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(destinationFolder); } @@ -87,7 +86,7 @@ public void mergeDocumentTest01() throws IOException, InterruptedException { pdfDoc3.close(); - Assert.assertNull(new CompareTool().compareByContent(resultFile, sourceFolder + "cmp_mergedResult01.pdf", destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(resultFile, sourceFolder + "cmp_mergedResult01.pdf", destinationFolder, "diff_")); } @Test @@ -104,7 +103,7 @@ public void mergeDocumentOutlinesWithNullDestinationTest01() throws IOException, resultDocument.close(); sourceDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(resultFile, sourceFolder + "cmp_mergeDocumentOutlinesWithNullDestinationTest01.pdf", destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(resultFile, sourceFolder + "cmp_mergeDocumentOutlinesWithNullDestinationTest01.pdf", destinationFolder, "diff_")); } @Test @@ -118,7 +117,7 @@ public void mergeDocumentWithCycleRefInAcroFormTest() throws IOException, Interr PdfMerger merger = new PdfMerger(pdfDocument2); merger.merge(pdfDocument1, 1, pdfDocument1.getNumberOfPages()); } - Assert.assertNull( + Assertions.assertNull( new CompareTool().compareByContent(resultFile, sourceFolder + "cmp_resultFileWithoutStackOverflow.pdf", destinationFolder, "diff_")); } @@ -137,7 +136,7 @@ public void mergeDocumentWithLinkAnnotationTest() throws IOException, Interrupte merger.merge(pdfDoc, 1, 1).close(); - Assert.assertNull(new CompareTool().compareByContent(resultFile, sourceFolder + "cmp_mergedDocumentWithLinkAnnotation.pdf", destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(resultFile, sourceFolder + "cmp_mergedDocumentWithLinkAnnotation.pdf", destinationFolder, "diff_")); } @Test @@ -160,7 +159,23 @@ public void mergeDocumentTest02() throws IOException, InterruptedException { merger.merge(pdfDoc, 1, 1).merge(pdfDoc1, 1, 1).merge(pdfDoc2, 1, 1).close(); - Assert.assertNull(new CompareTool().compareByContent(resultFile, sourceFolder + "cmp_mergedResult02.pdf", destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(resultFile, sourceFolder + "cmp_mergedResult02.pdf", destinationFolder, "diff_")); + } + + @Test + public void mergeDocumentWithCycleTagReferenceTest() throws IOException, InterruptedException { + String filename1 = sourceFolder + "doc1.pdf"; + String filename2 = sourceFolder + "pdfWithCycleRefInParentTag.pdf"; + String resultFile = destinationFolder + "pdfWithCycleRefInParentTag.pdf"; + try (PdfDocument pdfDocument1 = new PdfDocument(new PdfReader(filename2)); + PdfDocument pdfDocument2 = new PdfDocument(new PdfReader(filename1), + CompareTool.createTestPdfWriter(resultFile).setSmartMode(true));) { + PdfMerger merger = new PdfMerger(pdfDocument2); + merger.merge(pdfDocument1, 1, pdfDocument1.getNumberOfPages()); + } + Assertions.assertNull( + new CompareTool().compareByContent(resultFile, sourceFolder + "cmp_pdfWithCycleRefInParentTag.pdf", + destinationFolder, "diff_")); } @Test @@ -197,7 +212,7 @@ public void mergeDocumentTest03() throws IOException, InterruptedException, Pars errorMessage += tagStructErrorMessage == null ? "" : tagStructErrorMessage + "\n"; errorMessage += contentErrorMessage == null ? "" : contentErrorMessage; if (!errorMessage.isEmpty()) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -244,7 +259,7 @@ public void mergeDocumentTest04() throws IOException, InterruptedException, Pars errorMessage += tagStructErrorMessage == null ? "" : tagStructErrorMessage + "\n"; errorMessage += contentErrorMessage == null ? "" : contentErrorMessage; if (!errorMessage.isEmpty()) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -344,7 +359,7 @@ public void splitAndMergeEmptyTrTableTest() throws ParserConfigurationException, sources.add(new File(secondPageFilename)); mergePdfs(sources, resultFilename, new PdfMergerProperties(), false); - Assert.assertNull(new CompareTool().compareTagStructures(resultFilename, cmpFilename)); + Assertions.assertNull(new CompareTool().compareTagStructures(resultFilename, cmpFilename)); } @Test @@ -368,7 +383,7 @@ public void mergeOutlinesNamedDestinations() throws IOException, InterruptedExce CompareTool compareTool = new CompareTool(); String errorMessage = compareTool.compareByContent(resultFile, sourceFolder + "cmp_mergeOutlinesNamedDestinations.pdf", destinationFolder, "diff_"); if (errorMessage != null) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } @@ -388,7 +403,7 @@ public void mergeWithAcroFormsTest() throws IOException, InterruptedException { sources.add(new File(pdfAcro2)); mergePdfs(sources, outFileName, false); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } @Test @@ -408,7 +423,7 @@ public void mergePdfWithOCGTest() throws IOException, InterruptedException { sources.add(new File(pdfWithOCG2)); mergePdfs(sources, outPdf, false); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder)); } @Test @@ -426,7 +441,7 @@ public void mergePdfWithComplexOCGTest() throws IOException, InterruptedExceptio sources.add(new File(pdfWithOCG2)); mergePdfs(sources, outPdf, false); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder)); } @Test @@ -454,7 +469,7 @@ public void mergeTwoPagePdfWithComplexOCGTest() throws IOException, InterruptedE merger.close(); mergedDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder)); } @Test @@ -473,7 +488,7 @@ public void mergePdfWithComplexOCGTwiceTest() throws IOException, InterruptedExc merger.close(); mergedDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder)); } @Test @@ -489,7 +504,7 @@ public void stackOverflowErrorCycleReferenceOcgMergeTest() throws IOException, I merger.merge(pdfWithOCGToMerge, 1, pdfWithOCGToMerge.getNumberOfPages()); pdfWithOCGToMerge.close(); pdfWithOCG.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder)); } @Test @@ -503,13 +518,13 @@ public void mergeOutlinesWithWrongStructureTest() throws IOException, Interrupte PdfDocument outputDoc = new PdfDocument(CompareTool.createTestPdfWriter( destinationFolder + "infiniteLoopInOutlineStructure.pdf")); - PdfMerger merger = new PdfMerger(outputDoc, false, true); + PdfMerger merger = new PdfMerger(outputDoc, new PdfMergerProperties().setMergeTags(false).setMergeOutlines(true)); System.out.println("Doing merge"); merger.merge(inputDoc, 1, 2); merger.close(); System.out.println("Merge done"); - Assert.assertNull(new CompareTool().compareByContent( + Assertions.assertNull(new CompareTool().compareByContent( destinationFolder + "infiniteLoopInOutlineStructure.pdf", sourceFolder + "cmp_infiniteLoopInOutlineStructure.pdf", destinationFolder)); } @@ -532,7 +547,7 @@ private static void mergeAndCompareTagStructures(String testName, int fromPage, merger.close(); output.close(); - Assert.assertNull(new CompareTool().compareTagStructures(dest, cmp)); + Assertions.assertNull(new CompareTool().compareTagStructures(dest, cmp)); } @Test @@ -544,7 +559,7 @@ public void mergeDocumentWithColorPropertyInOutlineTest() throws IOException, In try (PdfDocument merged = new PdfDocument(CompareTool.createTestPdfWriter(mergedPdf)); PdfDocument fileA = new PdfDocument(new PdfReader(firstDocument)); PdfDocument fileB = new PdfDocument(new PdfReader(secondDocument))) { - PdfMerger merger = new PdfMerger(merged, false, true); + PdfMerger merger = new PdfMerger(merged, new PdfMergerProperties().setMergeTags(false).setMergeOutlines(true)); merger.merge(fileA, 1, fileA.getNumberOfPages()); merger.merge(fileB, 1, fileB.getNumberOfPages()); @@ -552,7 +567,7 @@ public void mergeDocumentWithColorPropertyInOutlineTest() throws IOException, In merger.close(); } - Assert.assertNull(new CompareTool().compareByContent(mergedPdf, cmpDocument, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(mergedPdf, cmpDocument, destinationFolder)); } @Test @@ -565,14 +580,14 @@ public void mergeDocumentWithStylePropertyInOutlineTest() throws IOException, In try (PdfDocument documentA = new PdfDocument(new PdfReader(firstDocument)); PdfDocument documentB = new PdfDocument(new PdfReader(secondDocument)); PdfDocument merged = new PdfDocument(CompareTool.createTestPdfWriter(mergedPdf))) { - PdfMerger merger = new PdfMerger(merged, false, true); + PdfMerger merger = new PdfMerger(merged, new PdfMergerProperties().setMergeTags(false).setMergeOutlines(true)); merger.merge(documentA, 1, documentA.getNumberOfPages()); merger.merge(documentB, 1, documentB.getNumberOfPages()); merger.close(); } - Assert.assertNull(new CompareTool().compareByContent(mergedPdf, cmpPdf, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(mergedPdf, cmpPdf, destinationFolder)); } @Test @@ -585,14 +600,14 @@ public void mergePdfDocumentsWithCopingOutlinesTest() throws IOException, Interr try (PdfDocument documentA = new PdfDocument(new PdfReader(firstPdfDocument)); PdfDocument documentB = new PdfDocument(new PdfReader(secondPdfDocument)); PdfDocument mergedPdf = new PdfDocument(CompareTool.createTestPdfWriter(mergedDocument))) { - PdfMerger merger = new PdfMerger(mergedPdf, false, true); + PdfMerger merger = new PdfMerger(mergedPdf, new PdfMergerProperties().setMergeTags(false).setMergeOutlines(true)); merger.merge(documentA, 1, documentA.getNumberOfPages()); merger.merge(documentB, 1, documentB.getNumberOfPages()); merger.close(); } - Assert.assertNull(new CompareTool().compareByContent(mergedDocument, cmpDocument, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(mergedDocument, cmpDocument, destinationFolder)); } @Test @@ -607,9 +622,9 @@ public void MergeWithSameNamedOcgTest() throws IOException, InterruptedException sources.add(new File(secondPdfDocument)); mergePdfs(sources, mergedDocument, true); - Assert.assertNull(new CompareTool().compareByContent(mergedDocument, cmpDocument, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(mergedDocument, cmpDocument, destinationFolder)); // We have to compare visually also because compareByContent doesn't catch the differences in OCGs with the same names - Assert.assertNull(new CompareTool().compareVisually(mergedDocument, cmpDocument, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareVisually(mergedDocument, cmpDocument, destinationFolder, "diff_")); } @Test @@ -628,7 +643,7 @@ public void MergeWithSameNamedOcgOcmdDTest() throws IOException, InterruptedExce sources.add(new File(secondPdfDocument)); mergePdfs(sources, mergedDocument, true); - Assert.assertNull(new CompareTool().compareByContent(mergedDocument, cmpDocument, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(mergedDocument, cmpDocument, destinationFolder)); } @Test @@ -637,8 +652,8 @@ public void MergeWithSameNamedOcgOcmdDTest() throws IOException, InterruptedExce }) public void mergePdfWithMissingStructElemBeginningOfTreeTest() throws IOException, InterruptedException { String name = "structParentMissingFirstElement.pdf"; - Assert.assertNotNull(mergeSinglePdfAndGetResultingStructTreeRoot(name)); - Assert.assertNull(new CompareTool().compareByContent( + Assertions.assertNotNull(mergeSinglePdfAndGetResultingStructTreeRoot(name)); + Assertions.assertNull(new CompareTool().compareByContent( destinationFolder + name, sourceFolder + "cmp_" + name, destinationFolder)); } @@ -650,8 +665,8 @@ public void mergePdfWithMissingStructElemBeginningOfTreeTest() throws IOExceptio }) public void mergePdfWithMissingStructElemEndOfTreeTest() throws IOException, InterruptedException { String name = "structParentMissingLastElement.pdf"; - Assert.assertNotNull(mergeSinglePdfAndGetResultingStructTreeRoot(name)); - Assert.assertNull(new CompareTool().compareByContent( + Assertions.assertNotNull(mergeSinglePdfAndGetResultingStructTreeRoot(name)); + Assertions.assertNull(new CompareTool().compareByContent( destinationFolder + name, sourceFolder + "cmp_" + name, destinationFolder)); } @@ -663,8 +678,8 @@ public void mergePdfWithMissingStructElemEndOfTreeTest() throws IOException, Int }) public void mergePdfAllObjectsMissingStructParentTest() throws IOException, InterruptedException { String name = "allObjectsHaveStructParent.pdf"; - Assert.assertNotNull(mergeSinglePdfAndGetResultingStructTreeRoot(name)); - Assert.assertNull(new CompareTool().compareByContent( + Assertions.assertNotNull(mergeSinglePdfAndGetResultingStructTreeRoot(name)); + Assertions.assertNull(new CompareTool().compareByContent( destinationFolder + name, sourceFolder + "cmp_" + name, destinationFolder)); } @@ -675,8 +690,8 @@ public void mergePdfAllObjectsMissingStructParentTest() throws IOException, Inte }) public void mergePdfChildObjectsOfSameStructElemMissingStructParentTest() throws IOException, InterruptedException { String name = "SameStructElemNoParent.pdf"; - Assert.assertNotNull(mergeSinglePdfAndGetResultingStructTreeRoot(name)); - Assert.assertNull(new CompareTool().compareByContent( + Assertions.assertNotNull(mergeSinglePdfAndGetResultingStructTreeRoot(name)); + Assertions.assertNull(new CompareTool().compareByContent( destinationFolder + name, sourceFolder + "cmp_" + name, destinationFolder)); } @@ -693,7 +708,7 @@ public void mergeDocumentsWithStringAdditionalActions() throws IOException, Inte sources.add(new File(secondPdfDocument)); mergePdfs(sources, mergedDocument, new PdfMergerProperties().setMergeScripts(true), true); - Assert.assertNull(new CompareTool().compareByContent(mergedDocument, cmpDocument, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(mergedDocument, cmpDocument, destinationFolder)); } @Test @@ -708,7 +723,7 @@ public void mergeDocumentsWithAdditionalActionsInDestination() throws IOExceptio sources.add(new File(firstPdfDocument)); sources.add(new File(secondPdfDocument)); mergePdfs(sources, mergedDocument, new PdfMergerProperties().setMergeScripts(true), true); - Assert.assertNull(new CompareTool().compareByContent(mergedDocument, cmpDocument, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(mergedDocument, cmpDocument, destinationFolder)); } @Test @@ -723,7 +738,7 @@ public void mergeDocumentsWithUnexpectedKeyAdditionalActions() throws IOExceptio sources.add(new File(secondPdfDocument)); mergePdfs(sources, mergedDocument, new PdfMergerProperties().setMergeScripts(true), true); - Assert.assertNull(new CompareTool().compareByContent(mergedDocument, cmpDocument, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(mergedDocument, cmpDocument, destinationFolder)); } @Test @@ -738,7 +753,7 @@ public void mergeDocumentsWithStreamAdditionalActions() throws IOException, Inte sources.add(new File(secondPdfDocument)); mergePdfs(sources, mergedDocument, new PdfMergerProperties().setMergeScripts(true), true); - Assert.assertNull(new CompareTool().compareByContent(mergedDocument, cmpDocument, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(mergedDocument, cmpDocument, destinationFolder)); } @Test @@ -753,7 +768,7 @@ public void mergeDocumentsWithStringOpenActions() throws IOException, Interrupte sources.add(new File(secondPdfDocument)); mergePdfs(sources, mergedDocument, new PdfMergerProperties().setMergeScripts(true), true); - Assert.assertNull(new CompareTool().compareByContent(mergedDocument, cmpDocument, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(mergedDocument, cmpDocument, destinationFolder)); } @Test @@ -768,7 +783,7 @@ public void mergeDocumentsWithOpenActionInDestination() throws IOException, Inte sources.add(new File(firstPdfDocument)); sources.add(new File(secondPdfDocument)); mergePdfs(sources, mergedDocument, new PdfMergerProperties().setMergeScripts(true), true); - Assert.assertNull(new CompareTool().compareByContent(mergedDocument, cmpDocument, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(mergedDocument, cmpDocument, destinationFolder)); } @Test @@ -783,7 +798,7 @@ public void mergeDocumentsWithStreamOpenActions() throws IOException, Interrupte sources.add(new File(secondPdfDocument)); mergePdfs(sources, mergedDocument, new PdfMergerProperties().setMergeScripts(true), true); - Assert.assertNull(new CompareTool().compareByContent(mergedDocument, cmpDocument, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(mergedDocument, cmpDocument, destinationFolder)); } @@ -799,7 +814,7 @@ public void mergeDocumentsWithJSInTree() throws IOException, InterruptedExceptio sources.add(new File(secondPdfDocument)); mergePdfs(sources, mergedDocument, new PdfMergerProperties().setMergeScripts(true), true); - Assert.assertNull(new CompareTool().compareByContent(mergedDocument, cmpDocument, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(mergedDocument, cmpDocument, destinationFolder)); } @Test @@ -814,7 +829,7 @@ public void mergeDocumentsWithNullDestination() throws IOException, InterruptedE sources.add(new File(secondPdfDocument)); mergePdfs(sources, mergedDocument, new PdfMergerProperties().setMergeScripts(true), true); - Assert.assertNull(new CompareTool().compareByContent(mergedDocument, cmpDocument, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(mergedDocument, cmpDocument, destinationFolder)); } @Test @@ -829,7 +844,7 @@ public void mergeDocumentsWithNullDestinationInGoTo() throws IOException, Interr sources.add(new File(secondPdfDocument)); mergePdfs(sources, mergedDocument, new PdfMergerProperties().setMergeScripts(true), true); - Assert.assertNull(new CompareTool().compareByContent(mergedDocument, cmpDocument, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(mergedDocument, cmpDocument, destinationFolder)); } @Test @@ -844,7 +859,7 @@ public void mergeDocumentsWithPdfNullDestinationInGoTo() throws IOException, Int sources.add(new File(secondPdfDocument)); mergePdfs(sources, mergedDocument, new PdfMergerProperties().setMergeScripts(true), true); - Assert.assertNull(new CompareTool().compareByContent(mergedDocument, cmpDocument, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(mergedDocument, cmpDocument, destinationFolder)); } @Test @@ -859,7 +874,7 @@ public void mergeDocumentsWithNamesJSInDestination() throws IOException, Interru sources.add(new File(firstPdfDocument)); sources.add(new File(secondPdfDocument)); mergePdfs(sources, mergedDocument, new PdfMergerProperties().setMergeScripts(true), true); - Assert.assertNull(new CompareTool().compareByContent(mergedDocument, cmpDocument, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(mergedDocument, cmpDocument, destinationFolder)); } @Test @@ -874,7 +889,7 @@ public void copyEmptyOcPropertiesTest() throws IOException, InterruptedException merger.merge(pdfDoc, 1, 1).close(); - Assert.assertNull(new CompareTool().compareByContent(resultFile, sourceFolder + "cmp_mergedEmptyOcPropertiesDoc.pdf", destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(resultFile, sourceFolder + "cmp_mergedEmptyOcPropertiesDoc.pdf", destinationFolder, "diff_")); } @Test @@ -889,7 +904,35 @@ public void copyOnlyEmptyOcPropertiesTest() throws IOException, InterruptedExcep merger.merge(pdfDoc, 1, 1).close(); - Assert.assertNull(new CompareTool().compareByContent(resultFile, sourceFolder + "cmp_mergedOcPropertiesDoc.pdf", destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(resultFile, sourceFolder + "cmp_mergedOcPropertiesDoc.pdf", destinationFolder, "diff_")); + } + + @LogMessages(messages = { + @LogMessage(messageTemplate = IoLogMessageConstant.SOURCE_DOCUMENT_HAS_ACROFORM_DICTIONARY) + }) + @Test + public void combineTagRootKidsTest() throws IOException, InterruptedException { + String filename1 = sourceFolder + "tagRootKidsDoc1.pdf"; + String filename2 = sourceFolder + "tagRootKidsDoc2.pdf"; + String resultFile = destinationFolder + "mergedTags.pdf"; + + PdfDocument result = new PdfDocument(CompareTool.createTestPdfWriter(resultFile)); + + PdfMerger merger = new PdfMerger(result, new PdfMergerProperties().setMergeTags(true).setMergeOutlines(true)) + .setCloseSourceDocuments(true); + + PdfDocument input1 = new PdfDocument(new PdfReader(filename1)); + merger.merge(input1, 1, 1); + input1.close(); + + PdfDocument input2 = new PdfDocument(new PdfReader(filename2)); + merger.merge(input2, 1, 1); + input2.close(); + + merger.close(); + + Assertions.assertNull(new CompareTool() + .compareByContent(resultFile, sourceFolder + "cmp_mergedTags.pdf", destinationFolder, "diff_")); } private PdfDictionary mergeSinglePdfAndGetResultingStructTreeRoot(String pathToMerge) diff --git a/kernel/src/test/java/com/itextpdf/kernel/utils/PdfSplitterTest.java b/kernel/src/test/java/com/itextpdf/kernel/utils/PdfSplitterTest.java index 80dacdfef3..c0f47a8573 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/utils/PdfSplitterTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/utils/PdfSplitterTest.java @@ -29,13 +29,12 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.FileNotFoundException; import java.io.IOException; @@ -43,18 +42,18 @@ This file is part of the iText (R) project. import java.util.Arrays; import java.util.List; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfSplitterTest extends ExtendedITextTest{ public static final String sourceFolder = "./src/test/resources/com/itextpdf/kernel/utils/PdfSplitterTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/kernel/utils/PdfSplitterTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } - @AfterClass + @AfterAll public static void afterClass() { CompareTool.cleanup(destinationFolder); } @@ -76,7 +75,7 @@ public void splitDocumentTest01() throws IOException, InterruptedException { protected PdfWriter getNextPdfWriter(PageRange documentPageRange) { try { return CompareTool.createTestPdfWriter(destinationFolder + "splitDocument1_" + String.valueOf(partNumber++) + ".pdf"); - } catch (FileNotFoundException e) { + } catch (IOException e) { throw new RuntimeException(); } } @@ -86,7 +85,7 @@ protected PdfWriter getNextPdfWriter(PageRange documentPageRange) { doc.close(); for (int i = 1; i <= 3; i++) { - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "splitDocument1_" + String.valueOf(i) + ".pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "splitDocument1_" + String.valueOf(i) + ".pdf", sourceFolder + "cmp/" + "cmp_splitDocument1_" + String.valueOf(i) + ".pdf", destinationFolder, "diff_")); } } @@ -107,7 +106,7 @@ protected PdfWriter getNextPdfWriter(PageRange documentPageRange) { try { PdfWriter writer = CompareTool.createTestPdfWriter(destinationFolder + "splitDocument2_" + String.valueOf(partNumber++) + ".pdf"); return writer; - } catch (FileNotFoundException e) { + } catch (IOException e) { throw new RuntimeException(); } } @@ -124,7 +123,7 @@ public void documentReady(PdfDocument pdfDocument, PageRange pageRange) { }); for (int i = 1; i <= 3; i++) { - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "splitDocument2_" + String.valueOf(i) + ".pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "splitDocument2_" + String.valueOf(i) + ".pdf", sourceFolder + "cmp/" + "cmp_splitDocument2_" + String.valueOf(i) + ".pdf", destinationFolder, "diff_")); } } @@ -147,7 +146,7 @@ public void splitDocumentTest03() throws IOException, InterruptedException { protected PdfWriter getNextPdfWriter(PageRange documentPageRange) { try { return CompareTool.createTestPdfWriter(destinationFolder + "splitDocument3_" + String.valueOf(partNumber++) + ".pdf"); - } catch (FileNotFoundException e) { + } catch (IOException e) { throw new RuntimeException(); } } @@ -158,7 +157,7 @@ protected PdfWriter getNextPdfWriter(PageRange documentPageRange) { } for (int i = 1; i <= 2; i++) { - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "splitDocument3_" + i + ".pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "splitDocument3_" + i + ".pdf", sourceFolder + "cmp/" + "cmp_splitDocument3_" + String.valueOf(i) + ".pdf", destinationFolder, "diff_")); } } @@ -181,7 +180,7 @@ public void splitDocumentTest04() throws IOException, InterruptedException { protected PdfWriter getNextPdfWriter(PageRange documentPageRange) { try { return CompareTool.createTestPdfWriter(destinationFolder + "splitDocument4_" + String.valueOf(partNumber++) + ".pdf"); - } catch (FileNotFoundException e) { + } catch (IOException e) { throw new RuntimeException(); } } @@ -192,7 +191,7 @@ protected PdfWriter getNextPdfWriter(PageRange documentPageRange) { } for (int i = 1; i <= 2; i++) { - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "splitDocument4_" + i + ".pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "splitDocument4_" + i + ".pdf", sourceFolder + "cmp/" + "cmp_splitDocument4_" + String.valueOf(i) + ".pdf", destinationFolder, "diff_")); } } @@ -210,8 +209,8 @@ public void splitDocumentByOutlineTest() throws IOException { listTitles.add("Syncing iPod Content from Your iTunes Library"); listTitles.add("Restoring or Transferring Your iPhone Settings"); List list = splitter.splitByOutlines(listTitles); - Assert.assertEquals(1,list.get(0).getNumberOfPages()); - Assert.assertEquals(2,list.get(1).getNumberOfPages()); + Assertions.assertEquals(1,list.get(0).getNumberOfPages()); + Assertions.assertEquals(2,list.get(1).getNumberOfPages()); list.get(0).close(); list.get(1).close(); } @@ -228,7 +227,7 @@ public void splitDocumentBySize() throws IOException, InterruptedException { protected PdfWriter getNextPdfWriter(PageRange documentPageRange) { try { return CompareTool.createTestPdfWriter(destinationFolder + "splitBySize_part" + String.valueOf(partNumber++) + ".pdf"); - } catch (FileNotFoundException e) { + } catch (IOException e) { throw new RuntimeException(); } } @@ -241,7 +240,7 @@ protected PdfWriter getNextPdfWriter(PageRange documentPageRange) { } for (int i = 1; i <= 4; ++i) { - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "splitBySize_part" + i + ".pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "splitBySize_part" + i + ".pdf", sourceFolder + "cmp/" + "cmp_splitBySize_part" + i + ".pdf", destinationFolder, "diff_")); } } @@ -264,7 +263,7 @@ public void splitByPageCountTest() throws IOException { doc.close(); } - Assert.assertEquals(pagesCount / pagesCountInSplitDoc, splitDocuments.size()); + Assertions.assertEquals(pagesCount / pagesCountInSplitDoc, splitDocuments.size()); } } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/utils/PdfSplitterUnitTest.java b/kernel/src/test/java/com/itextpdf/kernel/utils/PdfSplitterUnitTest.java index 608fb9930b..7c68a30f75 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/utils/PdfSplitterUnitTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/utils/PdfSplitterUnitTest.java @@ -28,21 +28,20 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfWriter; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfSplitterUnitTest extends ExtendedITextTest { @Test public void splitDocumentThatIsBeingWrittenTest() { PdfDocument pdfDocument = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> new PdfSplitter(pdfDocument)); - Assert.assertEquals(KernelExceptionMessageConstant.CANNOT_SPLIT_DOCUMENT_THAT_IS_BEING_WRITTEN, + Assertions.assertEquals(KernelExceptionMessageConstant.CANNOT_SPLIT_DOCUMENT_THAT_IS_BEING_WRITTEN, exception.getMessage()); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/utils/PemFileHelper.java b/kernel/src/test/java/com/itextpdf/kernel/utils/PemFileHelper.java index 0c9911d737..e60d3c748d 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/utils/PemFileHelper.java +++ b/kernel/src/test/java/com/itextpdf/kernel/utils/PemFileHelper.java @@ -24,6 +24,8 @@ This file is part of the iText (R) project. import com.itextpdf.bouncycastleconnector.BouncyCastleFactoryCreator; import com.itextpdf.commons.bouncycastle.IBouncyCastleFactory; +import com.itextpdf.commons.bouncycastle.cert.IX509CertificateHolder; +import com.itextpdf.commons.bouncycastle.cert.jcajce.IJcaX509CertificateConverter; import com.itextpdf.commons.bouncycastle.openssl.IPEMParser; import com.itextpdf.commons.bouncycastle.openssl.jcajce.IJcaPEMKeyConverter; import com.itextpdf.commons.bouncycastle.operator.AbstractOperatorCreationException; @@ -31,10 +33,15 @@ This file is part of the iText (R) project. import com.itextpdf.commons.bouncycastle.pkcs.AbstractPKCSException; import com.itextpdf.commons.bouncycastle.pkcs.IPKCS8EncryptedPrivateKeyInfo; +import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.security.PrivateKey; +import java.security.cert.Certificate; +import java.security.cert.CertificateException; +import java.util.ArrayList; +import java.util.List; public final class PemFileHelper { @@ -57,6 +64,31 @@ public static PrivateKey readPrivateKeyFromPemFile(InputStream pemFile, char[] p return null; } + public static Certificate[] readFirstChain(String pemFileName) throws IOException, CertificateException { + List certificatesHolders = readCertificates(pemFileName); + IJcaX509CertificateConverter converter = + BOUNCY_CASTLE_FACTORY.createJcaX509CertificateConverter().setProvider(BOUNCY_CASTLE_FACTORY.getProvider()); + Certificate[] certificates = new Certificate[certificatesHolders.size()]; + for (int i = 0; i < certificatesHolders.size(); i++) { + certificates[i] = converter.getCertificate(certificatesHolders.get(i)); + } + return certificates; + } + + private static List readCertificates(String pemFileName) throws IOException { + try (IPEMParser parser = BOUNCY_CASTLE_FACTORY.createPEMParser(new FileReader(pemFileName))) { + Object readObject = parser.readObject(); + List certificateHolders = new ArrayList<>(); + while (readObject != null) { + if (readObject instanceof IX509CertificateHolder) { + certificateHolders.add((IX509CertificateHolder) readObject); + } + readObject = parser.readObject(); + } + return certificateHolders; + } + } + private static IPKCS8EncryptedPrivateKeyInfo readPrivateKey(InputStream pemFile) throws IOException { try (IPEMParser parser = BOUNCY_CASTLE_FACTORY.createPEMParser(new InputStreamReader(pemFile))) { Object readObject = parser.readObject(); diff --git a/kernel/src/test/java/com/itextpdf/kernel/utils/RegisterDefaultDiContainerTest.java b/kernel/src/test/java/com/itextpdf/kernel/utils/RegisterDefaultDiContainerTest.java new file mode 100644 index 0000000000..86e5afb33d --- /dev/null +++ b/kernel/src/test/java/com/itextpdf/kernel/utils/RegisterDefaultDiContainerTest.java @@ -0,0 +1,95 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.kernel.utils; + +import com.itextpdf.commons.datastructures.ISimpleList; +import com.itextpdf.io.source.ByteArrayOutputStream; +import com.itextpdf.kernel.di.pagetree.IPageTreeListFactory; +import com.itextpdf.kernel.pdf.DocumentProperties; +import com.itextpdf.kernel.pdf.PdfDictionary; +import com.itextpdf.kernel.pdf.PdfDocument; +import com.itextpdf.kernel.pdf.PdfWriter; +import com.itextpdf.test.ExtendedITextTest; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +@Tag("UnitTest") +public class RegisterDefaultDiContainerTest extends ExtendedITextTest { + + @Test + public void test() { + RegisterDefaultDiContainer registerDefaultDiContainer = new RegisterDefaultDiContainer(); + assertNotNull(registerDefaultDiContainer); + } + + @Test + public void testStaticBlock() { + PdfDocument pdfDocument = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); + assertTrue(pdfDocument.getDiContainer().getInstance(IPageTreeListFactory.class) instanceof IPageTreeListFactory); + } + + + @Test + public void testWithOverWriting() { + PdfDocument pdfDocument = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); + assertTrue(pdfDocument.getDiContainer().getInstance(IPageTreeListFactory.class) instanceof IPageTreeListFactory); + } + + @Test + public void testWithSettingDocumentProps() { + DocumentProperties documentProperties = new DocumentProperties(); + documentProperties.registerDependency(IPageTreeListFactory.class, new IPageTreeTestImpl()); + PdfDocument pdfDocument = new PdfDocument(new PdfWriter(new ByteArrayOutputStream()), documentProperties); + assertTrue(pdfDocument.getDiContainer().getInstance(IPageTreeListFactory.class) instanceof IPageTreeTestImpl); + } + + @Test + public void documentPropsSetWithNullInstance() { + DocumentProperties documentProperties = new DocumentProperties(); + Assertions.assertThrows(IllegalArgumentException.class, () -> { + documentProperties.registerDependency(IPageTreeListFactory.class, null); + }); + } + + @Test + public void documentPropsSetWithNullType() { + DocumentProperties documentProperties = new DocumentProperties(); + Object dummyObject = new Object(); + Assertions.assertThrows(IllegalArgumentException.class, () -> { + documentProperties.registerDependency(null, dummyObject); + }); + } + + static final class IPageTreeTestImpl implements IPageTreeListFactory { + + @Override + public ISimpleList createList(PdfDictionary pagesDictionary) { + return null; + } + } + + +} \ No newline at end of file diff --git a/kernel/src/test/java/com/itextpdf/kernel/utils/TaggedPdfReaderToolTest.java b/kernel/src/test/java/com/itextpdf/kernel/utils/TaggedPdfReaderToolTest.java index 85f84a930b..0361ba3991 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/utils/TaggedPdfReaderToolTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/utils/TaggedPdfReaderToolTest.java @@ -32,26 +32,25 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.tagging.PdfStructTreeRoot; import com.itextpdf.kernel.pdf.tagging.StandardRoles; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.ByteArrayOutputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; import javax.xml.parsers.ParserConfigurationException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import org.xml.sax.SAXException; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class TaggedPdfReaderToolTest extends ExtendedITextTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/kernel/utils/TaggedPdfReaderToolTest/"; private static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/kernel/utils/TaggedPdfReaderToolTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(DESTINATION_FOLDER); } @@ -75,7 +74,7 @@ public void taggedPdfReaderToolTest01() throws IOException, ParserConfigurationE CompareTool compareTool = new CompareTool(); if (!compareTool.compareXmls(outXmlPath, cmpXmlPath)) { - Assert.fail("Resultant xml is different."); + Assertions.fail("Resultant xml is different."); } } @@ -87,13 +86,13 @@ public void noStructTreeRootInDocTest() { PdfDocument pdfDocument = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); TaggedPdfReaderTool tool = new TaggedPdfReaderTool(pdfDocument); try (OutputStream outXml = FileUtil.getFileOutputStream(outXmlPath)) { - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> tool.convertToXml(outXml, "UTF-8")); - Assert.assertEquals(KernelExceptionMessageConstant.DOCUMENT_DOES_NOT_CONTAIN_STRUCT_TREE_ROOT, + Assertions.assertEquals(KernelExceptionMessageConstant.DOCUMENT_DOES_NOT_CONTAIN_STRUCT_TREE_ROOT, exception.getMessage()); } } catch (IOException e) { - Assert.fail("IOException is not expected to be triggered"); + Assertions.fail("IOException is not expected to be triggered"); } } @@ -118,7 +117,7 @@ public void cyclicReferencesTest() throws IOException, ParserConfigurationExcept CompareTool compareTool = new CompareTool(); if (!compareTool.compareXmls(outXmlPath, cmpXmlPath)) { - Assert.fail("Resultant xml is different."); + Assertions.fail("Resultant xml is different."); } } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/utils/ValidationContainerTest.java b/kernel/src/test/java/com/itextpdf/kernel/utils/ValidationContainerTest.java index 8737a7e189..5bae84b962 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/utils/ValidationContainerTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/utils/ValidationContainerTest.java @@ -22,42 +22,45 @@ This file is part of the iText (R) project. */ package com.itextpdf.kernel.utils; -import com.itextpdf.kernel.pdf.IsoKey; -import com.itextpdf.kernel.pdf.PdfResources; -import com.itextpdf.kernel.pdf.PdfStream; +import com.itextpdf.kernel.pdf.PdfObject; +import com.itextpdf.kernel.validation.IValidationChecker; +import com.itextpdf.kernel.validation.IValidationContext; +import com.itextpdf.kernel.validation.ValidationContainer; +import com.itextpdf.kernel.validation.ValidationType; +import com.itextpdf.kernel.validation.context.FontValidationContext; +import com.itextpdf.kernel.validation.context.PdfDocumentValidationContext; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(UnitTest.class) +@Tag("UnitTest") public class ValidationContainerTest extends ExtendedITextTest { @Test public void validateObjectTest() { ValidationContainer container = new ValidationContainer(); - container.validate(null, IsoKey.FONT, null, null, null); + container.validate(new FontValidationContext(null, null)); final CustomValidationChecker checker = new CustomValidationChecker(); container.addChecker(checker); - Assert.assertTrue(container.containsChecker(checker)); + Assertions.assertTrue(container.containsChecker(checker)); - Assert.assertFalse(checker.objectValidationPerformed); - container.validate(null, IsoKey.FONT, null, null, null); - Assert.assertTrue(checker.objectValidationPerformed); + Assertions.assertFalse(checker.objectValidationPerformed); + container.validate(new FontValidationContext(null, null)); + Assertions.assertTrue(checker.objectValidationPerformed); } @Test public void validateDocumentTest() { ValidationContainer container = new ValidationContainer(); - ValidationContext context = new ValidationContext().withPdfDocument(null); + PdfDocumentValidationContext context = new PdfDocumentValidationContext(null, null); container.validate(context); final CustomValidationChecker checker = new CustomValidationChecker(); container.addChecker(checker); - Assert.assertFalse(checker.documentValidationPerformed); + Assertions.assertFalse(checker.documentValidationPerformed); container.validate(context); - Assert.assertTrue(checker.documentValidationPerformed); + Assertions.assertTrue(checker.documentValidationPerformed); } private static class CustomValidationChecker implements IValidationChecker { @@ -65,14 +68,17 @@ private static class CustomValidationChecker implements IValidationChecker { public boolean objectValidationPerformed = false; @Override - public void validateDocument(ValidationContext validationContext) { - documentValidationPerformed = true; + public void validate(IValidationContext validationContext) { + if (validationContext.getType() == ValidationType.PDF_DOCUMENT) { + documentValidationPerformed = true; + } else { + objectValidationPerformed = true; + } } @Override - public void validateObject(Object obj, IsoKey key, PdfResources resources, PdfStream contentStream, - Object extra) { - objectValidationPerformed = true; + public boolean isPdfObjectReadyToFlush(PdfObject object) { + return true; } } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/utils/ValidationContextTest.java b/kernel/src/test/java/com/itextpdf/kernel/utils/ValidationContextTest.java deleted file mode 100644 index 30588a1917..0000000000 --- a/kernel/src/test/java/com/itextpdf/kernel/utils/ValidationContextTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - This file is part of the iText (R) project. - Copyright (c) 1998-2024 Apryse Group NV - Authors: Apryse Software. - - This program is offered under a commercial and under the AGPL license. - For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. - - AGPL licensing: - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . - */ -package com.itextpdf.kernel.utils; - -import com.itextpdf.io.source.ByteArrayOutputStream; -import com.itextpdf.kernel.font.PdfFont; -import com.itextpdf.kernel.pdf.PdfDocument; -import com.itextpdf.kernel.pdf.PdfWriter; -import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; - -import java.util.ArrayList; -import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -@Category(UnitTest.class) -public class ValidationContextTest extends ExtendedITextTest { - @Test - public void withDocumentsCheckTest() { - ValidationContext context = new ValidationContext(); - Assert.assertNull(context.getPdfDocument()); - context.withPdfDocument(new PdfDocument(new PdfWriter(new ByteArrayOutputStream()))); - Assert.assertNotNull(context.getPdfDocument()); - } - - @Test - public void withFontsCheckTest() { - ValidationContext context = new ValidationContext(); - Assert.assertNull(context.getFonts()); - List fonts = new ArrayList<>(); - context.withFonts(fonts); - Assert.assertNotNull(context.getFonts()); - } -} diff --git a/kernel/src/test/java/com/itextpdf/kernel/utils/XmlProcessorCreatorSecurityTest.java b/kernel/src/test/java/com/itextpdf/kernel/utils/XmlProcessorCreatorSecurityTest.java index c5c9d523bf..c43d93d336 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/utils/XmlProcessorCreatorSecurityTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/utils/XmlProcessorCreatorSecurityTest.java @@ -25,7 +25,6 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.exceptions.PdfException; import com.itextpdf.test.ExceptionTestUtil; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.ByteArrayInputStream; import java.io.IOException; @@ -33,17 +32,17 @@ This file is part of the iText (R) project. import java.nio.charset.StandardCharsets; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.ParserConfigurationException; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import org.w3c.dom.Document; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; import org.xml.sax.XMLReader; -@Category(UnitTest.class) +@Tag("UnitTest") public class XmlProcessorCreatorSecurityTest extends ExtendedITextTest { private static final String XML_WITHOUT_DTD = "\n" @@ -93,7 +92,7 @@ public class XmlProcessorCreatorSecurityTest extends ExtendedITextTest { private final static String DTD_EXCEPTION_MESSAGE = ExceptionTestUtil.getDoctypeIsDisallowedExceptionMessage(); - @Before + @BeforeEach public void resetXmlParserFactoryToDefault() { XmlProcessorCreator.setXmlParserFactory(null); } @@ -105,7 +104,7 @@ public void xmlWithoutDtd() throws ParserConfigurationException, IOException, SA try (InputStream inputStream = new ByteArrayInputStream(XML_WITHOUT_DTD.getBytes(StandardCharsets.UTF_8))) { document = documentBuilder.parse(inputStream); } - Assert.assertNotNull(document); + Assertions.assertNotNull(document); } @Test @@ -113,10 +112,10 @@ public void xmlWithXXECustomFactory() throws ParserConfigurationException, IOExc XmlProcessorCreator.setXmlParserFactory(new SecurityTestXmlParserFactory()); DocumentBuilder documentBuilder = XmlProcessorCreator.createSafeDocumentBuilder(false, false); try (InputStream inputStream = new ByteArrayInputStream(XML_WITH_XXE.getBytes(StandardCharsets.UTF_8))) { - Exception e = Assert.assertThrows(PdfException.class, + Exception e = Assertions.assertThrows(PdfException.class, () -> documentBuilder.parse(inputStream) ); - Assert.assertEquals("Test message", e.getMessage()); + Assertions.assertEquals("Test message", e.getMessage()); } } @@ -187,10 +186,10 @@ private void createSafeXMLReaderTest(boolean nameSpace, boolean validating) try (InputStream inputStream = new ByteArrayInputStream( XmlProcessorCreatorSecurityTest.XML_WITH_XXE.getBytes(StandardCharsets.UTF_8))) { InputSource inputSource = new InputSource(inputStream); - Exception e = Assert.assertThrows(SAXParseException.class, + Exception e = Assertions.assertThrows(SAXParseException.class, () -> reader.parse(inputSource) ); - Assert.assertEquals(XmlProcessorCreatorSecurityTest.DTD_EXCEPTION_MESSAGE, e.getMessage()); + Assertions.assertEquals(XmlProcessorCreatorSecurityTest.DTD_EXCEPTION_MESSAGE, e.getMessage()); } } @@ -198,10 +197,10 @@ private void createSafeDocumentBuilderTest(String xml, boolean nameSpace, boolea throws IOException, SAXException { DocumentBuilder documentBuilder = XmlProcessorCreator.createSafeDocumentBuilder(nameSpace, comments); try (InputStream inputStream = new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8))) { - Exception e = Assert.assertThrows(SAXParseException.class, + Exception e = Assertions.assertThrows(SAXParseException.class, () -> documentBuilder.parse(inputStream) ); - Assert.assertEquals(XmlProcessorCreatorSecurityTest.DTD_EXCEPTION_MESSAGE, e.getMessage()); + Assertions.assertEquals(XmlProcessorCreatorSecurityTest.DTD_EXCEPTION_MESSAGE, e.getMessage()); } } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/utils/checkers/FontCheckUtilTest.java b/kernel/src/test/java/com/itextpdf/kernel/utils/checkers/FontCheckUtilTest.java index 4c81db4df5..c33b64c0e6 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/utils/checkers/FontCheckUtilTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/utils/checkers/FontCheckUtilTest.java @@ -30,22 +30,21 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.font.PdfFontFactory.EmbeddingStrategy; import com.itextpdf.kernel.utils.checkers.FontCheckUtil.CharacterChecker; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.IOException; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class FontCheckUtilTest extends ExtendedITextTest { private static final String FONTS_FOLDER = "./src/test/resources/com/itextpdf/kernel/pdf/fonts/"; @Test public void checkFontAvailable() throws IOException { PdfFont font = PdfFontFactory.createFont(StandardFonts.HELVETICA); - Assert.assertEquals(-1, FontCheckUtil.checkGlyphsOfText("123", font, new CharacterChecker() { + Assertions.assertEquals(-1, FontCheckUtil.checkGlyphsOfText("123", font, new CharacterChecker() { @Override public boolean check(int ch, PdfFont fontToCheck) { return !fontToCheck.containsGlyph(ch); @@ -57,7 +56,7 @@ public boolean check(int ch, PdfFont fontToCheck) { @Test public void checkFontNotAvailable() throws IOException { PdfFont font = PdfFontFactory.createFont(StandardFonts.HELVETICA); - Assert.assertEquals(2, FontCheckUtil.checkGlyphsOfText("hi⫊", font, new CharacterChecker() { + Assertions.assertEquals(2, FontCheckUtil.checkGlyphsOfText("hi⫊", font, new CharacterChecker() { @Override public boolean check(int ch, PdfFont fontToCheck) { return !fontToCheck.containsGlyph(ch); @@ -80,7 +79,7 @@ public boolean check(int ch, PdfFont fontToCheck) { } } }); - Assert.assertEquals(1, index); + Assertions.assertEquals(1, index); } @Test @@ -98,6 +97,6 @@ public boolean check(int ch, PdfFont fontToCheck) { } } }); - Assert.assertEquals(-1, index); + Assertions.assertEquals(-1, index); } } \ No newline at end of file diff --git a/kernel/src/test/java/com/itextpdf/kernel/utils/objectpathitems/ArrayPathItemTest.java b/kernel/src/test/java/com/itextpdf/kernel/utils/objectpathitems/ArrayPathItemTest.java index 775bfcec3a..3f8ecc7e53 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/utils/objectpathitems/ArrayPathItemTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/utils/objectpathitems/ArrayPathItemTest.java @@ -23,12 +23,11 @@ This file is part of the iText (R) project. package com.itextpdf.kernel.utils.objectpathitems; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class ArrayPathItemTest extends ExtendedITextTest { @Test @@ -38,8 +37,8 @@ public void equalsAndHashCodeTest() { ArrayPathItem arrayPathItem2 = new ArrayPathItem(index); boolean result = arrayPathItem1.equals(arrayPathItem2); - Assert.assertTrue(result); - Assert.assertEquals(arrayPathItem1.hashCode(), arrayPathItem2.hashCode()); + Assertions.assertTrue(result); + Assertions.assertEquals(arrayPathItem1.hashCode(), arrayPathItem2.hashCode()); } @Test @@ -48,8 +47,8 @@ public void notEqualsAndHashCodeTest() { ArrayPathItem arrayPathItem2 = new ArrayPathItem(2); boolean result = arrayPathItem1.equals(arrayPathItem2); - Assert.assertFalse(result); - Assert.assertNotEquals(arrayPathItem1.hashCode(), arrayPathItem2.hashCode()); + Assertions.assertFalse(result); + Assertions.assertNotEquals(arrayPathItem1.hashCode(), arrayPathItem2.hashCode()); } @Test @@ -57,6 +56,6 @@ public void getIndexTest() { int index = 1; ArrayPathItem arrayPathItem = new ArrayPathItem(index); - Assert.assertEquals(index, arrayPathItem.getIndex()); + Assertions.assertEquals(index, arrayPathItem.getIndex()); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/utils/objectpathitems/DictPathItemTest.java b/kernel/src/test/java/com/itextpdf/kernel/utils/objectpathitems/DictPathItemTest.java index 1481a2d210..c0196b8bc7 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/utils/objectpathitems/DictPathItemTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/utils/objectpathitems/DictPathItemTest.java @@ -24,12 +24,11 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfName; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class DictPathItemTest extends ExtendedITextTest { @Test @@ -39,8 +38,8 @@ public void equalsAndHashCodeTest() { DictPathItem dictPathItem2 = new DictPathItem(name); boolean result = dictPathItem1.equals(dictPathItem2); - Assert.assertTrue(result); - Assert.assertEquals(dictPathItem1.hashCode(), dictPathItem2.hashCode()); + Assertions.assertTrue(result); + Assertions.assertEquals(dictPathItem1.hashCode(), dictPathItem2.hashCode()); } @Test @@ -49,8 +48,8 @@ public void notEqualsAndHashCodeTest() { DictPathItem dictPathItem2 = new DictPathItem(new PdfName("test2")); boolean result = dictPathItem1.equals(dictPathItem2); - Assert.assertFalse(result); - Assert.assertNotEquals(dictPathItem1.hashCode(), dictPathItem2.hashCode()); + Assertions.assertFalse(result); + Assertions.assertNotEquals(dictPathItem1.hashCode(), dictPathItem2.hashCode()); } @Test @@ -58,6 +57,6 @@ public void getKeyTest() { PdfName name = new PdfName("test"); DictPathItem dictPathItem = new DictPathItem(name); - Assert.assertEquals(name, dictPathItem.getKey()); + Assertions.assertEquals(name, dictPathItem.getKey()); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/utils/objectpathitems/IndirectPathItemTest.java b/kernel/src/test/java/com/itextpdf/kernel/utils/objectpathitems/IndirectPathItemTest.java index 2122d45652..0dd0064f91 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/utils/objectpathitems/IndirectPathItemTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/utils/objectpathitems/IndirectPathItemTest.java @@ -27,20 +27,19 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfIndirectReference; import com.itextpdf.kernel.pdf.PdfWriter; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -@Category(IntegrationTest.class) +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; + +@Tag("IntegrationTest") public class IndirectPathItemTest extends ExtendedITextTest { private PdfDocument testCmp; private PdfDocument testOut; - @Before + @BeforeEach public void setUpPdfDocuments() { testCmp = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); testCmp.addNewPage(); @@ -51,7 +50,7 @@ public void setUpPdfDocuments() { testOut.addNewPage(); } - @After + @AfterEach public void closePdfDocuments() { testCmp.close(); testOut.close(); @@ -64,8 +63,8 @@ public void getIndirectObjectsTest() { IndirectPathItem indirectPathItem = new IndirectPathItem(cmpIndirect, outIndirect); - Assert.assertEquals(cmpIndirect, indirectPathItem.getCmpObject()); - Assert.assertEquals(outIndirect, indirectPathItem.getOutObject()); + Assertions.assertEquals(cmpIndirect, indirectPathItem.getCmpObject()); + Assertions.assertEquals(outIndirect, indirectPathItem.getOutObject()); } @Test @@ -77,8 +76,8 @@ public void equalsAndHashCodeTest() { IndirectPathItem indirectPathItem2 = new IndirectPathItem(cmpIndirect, outIndirect); boolean result = indirectPathItem1.equals(indirectPathItem2); - Assert.assertTrue(result); - Assert.assertEquals(indirectPathItem1.hashCode(), indirectPathItem2.hashCode()); + Assertions.assertTrue(result); + Assertions.assertEquals(indirectPathItem1.hashCode(), indirectPathItem2.hashCode()); } @Test @@ -92,8 +91,8 @@ public void notEqualsCmpObjAndHashCodeTest() { IndirectPathItem indirectPathItem2 = new IndirectPathItem(cmpIndirect2, outIndirect2); boolean result = indirectPathItem1.equals(indirectPathItem2); - Assert.assertFalse(result); - Assert.assertNotEquals(indirectPathItem1.hashCode(), indirectPathItem2.hashCode()); + Assertions.assertFalse(result); + Assertions.assertNotEquals(indirectPathItem1.hashCode(), indirectPathItem2.hashCode()); } @Test @@ -107,7 +106,7 @@ public void notEqualsOutObjAndHashCodeTest() { IndirectPathItem indirectPathItem2 = new IndirectPathItem(cmpIndirect2, outIndirect2); boolean result = indirectPathItem1.equals(indirectPathItem2); - Assert.assertFalse(result); - Assert.assertNotEquals(indirectPathItem1.hashCode(), indirectPathItem2.hashCode()); + Assertions.assertFalse(result); + Assertions.assertNotEquals(indirectPathItem1.hashCode(), indirectPathItem2.hashCode()); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/utils/objectpathitems/ObjectPathTest.java b/kernel/src/test/java/com/itextpdf/kernel/utils/objectpathitems/ObjectPathTest.java index 62b8c30086..c8eb29e209 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/utils/objectpathitems/ObjectPathTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/utils/objectpathitems/ObjectPathTest.java @@ -27,22 +27,21 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfIndirectReference; import com.itextpdf.kernel.pdf.PdfWriter; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.util.Stack; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class ObjectPathTest extends ExtendedITextTest { private PdfDocument testCmp; private PdfDocument testOut; - @Before + @BeforeEach public void setUpPdfDocuments() { testCmp = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); testCmp.addNewPage(); @@ -53,7 +52,7 @@ public void setUpPdfDocuments() { testOut.addNewPage(); } - @After + @AfterEach public void closePdfDocuments() { testCmp.close(); testOut.close(); @@ -70,10 +69,10 @@ public void getIndirectObjectsTest() { ObjectPath objectPath = new ObjectPath(cmpIndirect, outIndirect, localPath, indirectPathItems); - Assert.assertEquals(cmpIndirect, objectPath.getBaseCmpObject()); - Assert.assertEquals(outIndirect, objectPath.getBaseOutObject()); - Assert.assertEquals(localPath, objectPath.getLocalPath()); - Assert.assertEquals(indirectPathItems, objectPath.getIndirectPath()); + Assertions.assertEquals(cmpIndirect, objectPath.getBaseCmpObject()); + Assertions.assertEquals(outIndirect, objectPath.getBaseOutObject()); + Assertions.assertEquals(localPath, objectPath.getLocalPath()); + Assertions.assertEquals(indirectPathItems, objectPath.getIndirectPath()); } @Test @@ -88,8 +87,8 @@ public void hashCodeWithoutNullParametersTest() { ObjectPath objectPath1 = new ObjectPath(cmpIndirect, outIndirect, localPath, indirectPathItems); ObjectPath objectPath2 = new ObjectPath(cmpIndirect, outIndirect, localPath, indirectPathItems); - Assert.assertNotEquals(0, objectPath1.hashCode()); - Assert.assertEquals(objectPath1.hashCode(), objectPath2.hashCode()); + Assertions.assertNotEquals(0, objectPath1.hashCode()); + Assertions.assertEquals(objectPath1.hashCode(), objectPath2.hashCode()); } @Test @@ -100,8 +99,8 @@ public void hashCodeWithNullParametersTest() { ObjectPath objectPath1 = new ObjectPath(null, null, localPath, indirectPathItems); ObjectPath objectPath2 = new ObjectPath(null, null, localPath, indirectPathItems); - Assert.assertEquals(0, objectPath1.hashCode()); - Assert.assertEquals(objectPath1.hashCode(), objectPath2.hashCode()); + Assertions.assertEquals(0, objectPath1.hashCode()); + Assertions.assertEquals(objectPath1.hashCode(), objectPath2.hashCode()); } @Test @@ -119,8 +118,8 @@ public void equalsAndHashCodeTest() { ObjectPath objectPath2 = new ObjectPath(cmpIndirect, outIndirect, localPath, indirectPathItems); boolean result = objectPath1.equals(objectPath2); - Assert.assertTrue(result); - Assert.assertEquals(objectPath1.hashCode(), objectPath2.hashCode()); + Assertions.assertTrue(result); + Assertions.assertEquals(objectPath1.hashCode(), objectPath2.hashCode()); } @Test @@ -139,8 +138,8 @@ public void notEqualsAndHashCodeTest() { ObjectPath objectPath2 = new ObjectPath(cmpIndirect, outIndirect, localPath, indirectPathItems); boolean result = objectPath1.equals(objectPath2); - Assert.assertFalse(result); - Assert.assertNotEquals(objectPath1.hashCode(), objectPath2.hashCode()); + Assertions.assertFalse(result); + Assertions.assertNotEquals(objectPath1.hashCode(), objectPath2.hashCode()); } @Test @@ -157,7 +156,7 @@ public void cloneConstructorTest() { ObjectPath objectPath2 = new ObjectPath(objectPath1); boolean result = objectPath1.equals(objectPath2); - Assert.assertTrue(result); - Assert.assertEquals(objectPath1.hashCode(), objectPath2.hashCode()); + Assertions.assertTrue(result); + Assertions.assertEquals(objectPath1.hashCode(), objectPath2.hashCode()); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/utils/objectpathitems/OffsetPathItemTest.java b/kernel/src/test/java/com/itextpdf/kernel/utils/objectpathitems/OffsetPathItemTest.java index d37461c07f..93ae57f6b0 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/utils/objectpathitems/OffsetPathItemTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/utils/objectpathitems/OffsetPathItemTest.java @@ -23,12 +23,11 @@ This file is part of the iText (R) project. package com.itextpdf.kernel.utils.objectpathitems; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class OffsetPathItemTest extends ExtendedITextTest { @Test @@ -38,8 +37,8 @@ public void equalsAndHashCodeTest() { OffsetPathItem offsetPathItem2 = new OffsetPathItem(offset); boolean result = offsetPathItem1.equals(offsetPathItem2); - Assert.assertTrue(result); - Assert.assertEquals(offsetPathItem1.hashCode(), offsetPathItem2.hashCode()); + Assertions.assertTrue(result); + Assertions.assertEquals(offsetPathItem1.hashCode(), offsetPathItem2.hashCode()); } @Test @@ -48,8 +47,8 @@ public void notEqualsAndHashCodeTest() { OffsetPathItem offsetPathItem2 = new OffsetPathItem(2); boolean result = offsetPathItem1.equals(offsetPathItem2); - Assert.assertFalse(result); - Assert.assertNotEquals(offsetPathItem1.hashCode(), offsetPathItem2.hashCode()); + Assertions.assertFalse(result); + Assertions.assertNotEquals(offsetPathItem1.hashCode(), offsetPathItem2.hashCode()); } @Test @@ -57,6 +56,6 @@ public void getIndexTest() { int offset = 1; OffsetPathItem offsetPathItem = new OffsetPathItem(offset); - Assert.assertEquals(offset, offsetPathItem.getOffset()); + Assertions.assertEquals(offset, offsetPathItem.getOffset()); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/utils/objectpathitems/TrailerPathTest.java b/kernel/src/test/java/com/itextpdf/kernel/utils/objectpathitems/TrailerPathTest.java index 923576110a..4e6fb80e67 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/utils/objectpathitems/TrailerPathTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/utils/objectpathitems/TrailerPathTest.java @@ -27,15 +27,14 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfWriter; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import org.w3c.dom.Document; import java.util.Stack; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class TrailerPathTest extends ExtendedITextTest { @Test @@ -49,8 +48,8 @@ public void equalsAndHashCodeTest() { TrailerPath path2 = new TrailerPath(src, dest, stack); boolean result = path1.equals(path2); - Assert.assertTrue(result); - Assert.assertEquals(path1.hashCode(), path2.hashCode()); + Assertions.assertTrue(result); + Assertions.assertEquals(path1.hashCode(), path2.hashCode()); } @Test @@ -66,8 +65,8 @@ public void notEqualsAndHashCodeTest() { TrailerPath path2 = new TrailerPath(src, dest, stack); boolean result = path1.equals(path2); - Assert.assertFalse(result); - Assert.assertNotEquals(path1.hashCode(), path2.hashCode()); + Assertions.assertFalse(result); + Assertions.assertNotEquals(path1.hashCode(), path2.hashCode()); } @Test @@ -82,8 +81,8 @@ public void cloneConstructorTest() { TrailerPath path2 = new TrailerPath(path1); boolean result = path1.equals(path2); - Assert.assertTrue(result); - Assert.assertEquals(path1.hashCode(), path2.hashCode()); + Assertions.assertTrue(result); + Assertions.assertEquals(path1.hashCode(), path2.hashCode()); } @Test @@ -95,7 +94,7 @@ public void toStringTest() { stack.push(new ArrayPathItem(1)); TrailerPath path1 = new TrailerPath(src, dest, stack); - Assert.assertEquals("Base cmp object: trailer. Base out object: trailer\nArray index: 1", + Assertions.assertEquals("Base cmp object: trailer. Base out object: trailer\nArray index: 1", path1.toString()); } @@ -107,8 +106,8 @@ public void getPdfDocumentsTest() { TrailerPath path = new TrailerPath(cmp, out, stack); - Assert.assertEquals(cmp, path.getCmpDocument()); - Assert.assertEquals(out, path.getOutDocument()); + Assertions.assertEquals(cmp, path.getCmpDocument()); + Assertions.assertEquals(out, path.getOutDocument()); } @Test @@ -121,7 +120,7 @@ public void toXmlNodeTest() throws Exception { TrailerPath path1 = new TrailerPath(src, dest, stack); Document doc = XmlUtil.initNewXmlDocument(); - Assert.assertNotNull(path1.toXmlNode(doc)); + Assertions.assertNotNull(path1.toXmlNode(doc)); } private static PdfDocument createDocument() { diff --git a/kernel/src/test/java/com/itextpdf/kernel/xmp/impl/XMPMetaParserSecurityTest.java b/kernel/src/test/java/com/itextpdf/kernel/xmp/impl/XMPMetaParserSecurityTest.java index 96f3bba117..930795fe0e 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/xmp/impl/XMPMetaParserSecurityTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/xmp/impl/XMPMetaParserSecurityTest.java @@ -28,18 +28,17 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.xmp.XMPException; import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.ExceptionTestUtil; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.nio.charset.StandardCharsets; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class XMPMetaParserSecurityTest extends ExtendedITextTest { private static final String XMP_WITH_XXE = "\n" @@ -56,41 +55,41 @@ public class XMPMetaParserSecurityTest extends ExtendedITextTest { private static final String DTD_EXCEPTION_MESSAGE = ExceptionTestUtil.getDoctypeIsDisallowedExceptionMessage(); - @Before + @BeforeEach public void resetXmlParserFactoryToDefault() { XmlProcessorCreator.setXmlParserFactory(null); } @Test public void xxeTestFromString() throws XMPException { - Exception e = Assert.assertThrows(XMPException.class, () -> XMPMetaParser.parse(XMP_WITH_XXE, null)); - Assert.assertEquals(DTD_EXCEPTION_MESSAGE, e.getMessage()); + Exception e = Assertions.assertThrows(XMPException.class, () -> XMPMetaParser.parse(XMP_WITH_XXE, null)); + Assertions.assertEquals(DTD_EXCEPTION_MESSAGE, e.getMessage()); } @Test public void xxeTestFromByteBuffer() throws XMPException { - Exception e = Assert.assertThrows(XMPException.class, + Exception e = Assertions.assertThrows(XMPException.class, () -> XMPMetaParser.parse(XMP_WITH_XXE.getBytes(StandardCharsets.UTF_8), null) ); - Assert.assertEquals(DTD_EXCEPTION_MESSAGE, e.getMessage()); + Assertions.assertEquals(DTD_EXCEPTION_MESSAGE, e.getMessage()); } @Test public void xxeTestFromInputStream() throws XMPException, IOException { try (InputStream inputStream = new ByteArrayInputStream(XMP_WITH_XXE.getBytes(StandardCharsets.UTF_8))) { - Exception e = Assert.assertThrows(XMPException.class, + Exception e = Assertions.assertThrows(XMPException.class, () -> XMPMetaParser.parse(inputStream, null) ); - Assert.assertEquals(DTD_EXCEPTION_MESSAGE, e.getMessage()); + Assertions.assertEquals(DTD_EXCEPTION_MESSAGE, e.getMessage()); } } @Test public void xxeTestFromStringCustomXmlParser() throws XMPException { XmlProcessorCreator.setXmlParserFactory(new SecurityTestXmlParserFactory()); - Exception e = Assert.assertThrows(PdfException.class, + Exception e = Assertions.assertThrows(PdfException.class, () -> XMPMetaParser.parse(XMP_WITH_XXE, null) ); - Assert.assertEquals("Test message", e.getMessage()); + Assertions.assertEquals("Test message", e.getMessage()); } } diff --git a/kernel/src/test/java/com/itextpdf/kernel/xmp/impl/XMPNodeTest.java b/kernel/src/test/java/com/itextpdf/kernel/xmp/impl/XMPNodeTest.java index c5f1f1ae47..c01136a11f 100644 --- a/kernel/src/test/java/com/itextpdf/kernel/xmp/impl/XMPNodeTest.java +++ b/kernel/src/test/java/com/itextpdf/kernel/xmp/impl/XMPNodeTest.java @@ -26,11 +26,10 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.xmp.options.PropertyOptions; import com.itextpdf.test.AssertUtil; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class XMPNodeTest extends ExtendedITextTest { @Test public void test() throws XMPException { diff --git a/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptingTest/cmp_encryptWithPasswordAes256Pdf2.pdf b/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptingTest/cmp_encryptWithPasswordAes256Pdf2.pdf index 092fe20533..8f724a26d6 100644 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptingTest/cmp_encryptWithPasswordAes256Pdf2.pdf and b/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptingTest/cmp_encryptWithPasswordAes256Pdf2.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest/cmp_appended_encryptWithCertificateAes128.pdf b/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest/cmp_appended_encryptWithCertificateAes128.pdf index e173bf5a6c..b13b030ef5 100644 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest/cmp_appended_encryptWithCertificateAes128.pdf and b/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest/cmp_appended_encryptWithCertificateAes128.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest/cmp_appended_encryptWithCertificateAes128NoCompression.pdf b/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest/cmp_appended_encryptWithCertificateAes128NoCompression.pdf index 5f692a7297..995e6259b6 100644 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest/cmp_appended_encryptWithCertificateAes128NoCompression.pdf and b/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest/cmp_appended_encryptWithCertificateAes128NoCompression.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest/cmp_appended_encryptWithCertificateAes256.pdf b/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest/cmp_appended_encryptWithCertificateAes256.pdf index d0c35c7959..138ba14ec9 100644 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest/cmp_appended_encryptWithCertificateAes256.pdf and b/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest/cmp_appended_encryptWithCertificateAes256.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest/cmp_appended_encryptWithCertificateAes256NoCompression.pdf b/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest/cmp_appended_encryptWithCertificateAes256NoCompression.pdf index 3beb48e7a5..8513c348de 100644 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest/cmp_appended_encryptWithCertificateAes256NoCompression.pdf and b/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest/cmp_appended_encryptWithCertificateAes256NoCompression.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest/cmp_appended_encryptWithCertificateStandard128.pdf b/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest/cmp_appended_encryptWithCertificateStandard128.pdf index 3292cd3cb2..d8467daf59 100644 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest/cmp_appended_encryptWithCertificateStandard128.pdf and b/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest/cmp_appended_encryptWithCertificateStandard128.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest/cmp_appended_encryptWithCertificateStandard128NoCompression.pdf b/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest/cmp_appended_encryptWithCertificateStandard128NoCompression.pdf index 8f00163772..09c0245272 100644 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest/cmp_appended_encryptWithCertificateStandard128NoCompression.pdf and b/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest/cmp_appended_encryptWithCertificateStandard128NoCompression.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest/cmp_appended_encryptWithCertificateStandard40.pdf b/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest/cmp_appended_encryptWithCertificateStandard40.pdf index 45d5c2a2d4..f48d6885ce 100644 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest/cmp_appended_encryptWithCertificateStandard40.pdf and b/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest/cmp_appended_encryptWithCertificateStandard40.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest/cmp_appended_encryptWithCertificateStandard40NoCompression.pdf b/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest/cmp_appended_encryptWithCertificateStandard40NoCompression.pdf index 0769bbd00c..782c17518a 100644 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest/cmp_appended_encryptWithCertificateStandard40NoCompression.pdf and b/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest/cmp_appended_encryptWithCertificateStandard40NoCompression.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest/cmp_encryptWithCertificateAes128.pdf b/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest/cmp_encryptWithCertificateAes128.pdf index 5fc210b229..7cd4e5a752 100644 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest/cmp_encryptWithCertificateAes128.pdf and b/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest/cmp_encryptWithCertificateAes128.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest/cmp_encryptWithCertificateAes128NoCompression.pdf b/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest/cmp_encryptWithCertificateAes128NoCompression.pdf index ddcbd32f63..1e00eb29c3 100644 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest/cmp_encryptWithCertificateAes128NoCompression.pdf and b/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest/cmp_encryptWithCertificateAes128NoCompression.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest/cmp_encryptWithCertificateAes256.pdf b/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest/cmp_encryptWithCertificateAes256.pdf index cd9f13666c..c2cdee2e07 100644 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest/cmp_encryptWithCertificateAes256.pdf and b/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest/cmp_encryptWithCertificateAes256.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest/cmp_encryptWithCertificateAes256NoCompression.pdf b/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest/cmp_encryptWithCertificateAes256NoCompression.pdf index 7acb873318..5f364a5d3a 100644 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest/cmp_encryptWithCertificateAes256NoCompression.pdf and b/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest/cmp_encryptWithCertificateAes256NoCompression.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest/cmp_encryptWithCertificateStandard128.pdf b/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest/cmp_encryptWithCertificateStandard128.pdf index c64bad3632..7df42b6d3a 100644 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest/cmp_encryptWithCertificateStandard128.pdf and b/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest/cmp_encryptWithCertificateStandard128.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest/cmp_encryptWithCertificateStandard128NoCompression.pdf b/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest/cmp_encryptWithCertificateStandard128NoCompression.pdf index 3088393a43..f695c44f81 100644 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest/cmp_encryptWithCertificateStandard128NoCompression.pdf and b/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest/cmp_encryptWithCertificateStandard128NoCompression.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest/cmp_encryptWithCertificateStandard40.pdf b/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest/cmp_encryptWithCertificateStandard40.pdf index ebfbe0697b..708d88a008 100644 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest/cmp_encryptWithCertificateStandard40.pdf and b/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest/cmp_encryptWithCertificateStandard40.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest/cmp_encryptWithCertificateStandard40NoCompression.pdf b/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest/cmp_encryptWithCertificateStandard40NoCompression.pdf index ea318f14df..07548fe6de 100644 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest/cmp_encryptWithCertificateStandard40NoCompression.pdf and b/kernel/src/test/resources/com/itextpdf/kernel/crypto/PdfEncryptionManuallyPortedTest/cmp_encryptWithCertificateStandard40NoCompression.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/PdfEncryptionTest/cmp_appended_encryptAes256FullCompression.pdf b/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/PdfEncryptionTest/cmp_appended_encryptAes256FullCompression.pdf index 533b80e956..d1a6fe05dd 100644 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/PdfEncryptionTest/cmp_appended_encryptAes256FullCompression.pdf and b/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/PdfEncryptionTest/cmp_appended_encryptAes256FullCompression.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/PdfEncryptionTest/cmp_appended_encryptWithPasswordAes256Pdf2.pdf b/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/PdfEncryptionTest/cmp_appended_encryptWithPasswordAes256Pdf2.pdf index 5b492a02f4..103cab5001 100644 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/PdfEncryptionTest/cmp_appended_encryptWithPasswordAes256Pdf2.pdf and b/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/PdfEncryptionTest/cmp_appended_encryptWithPasswordAes256Pdf2.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/PdfEncryptionTest/cmp_encryptAes256FullCompression.pdf b/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/PdfEncryptionTest/cmp_encryptAes256FullCompression.pdf index 36f8d33df7..67169d5a14 100644 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/PdfEncryptionTest/cmp_encryptAes256FullCompression.pdf and b/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/PdfEncryptionTest/cmp_encryptAes256FullCompression.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/PdfEncryptionTest/cmp_encryptAes256Pdf2Permissions.pdf b/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/PdfEncryptionTest/cmp_encryptAes256Pdf2Permissions.pdf index fc84e5a3c6..24f164693c 100644 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/PdfEncryptionTest/cmp_encryptAes256Pdf2Permissions.pdf and b/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/PdfEncryptionTest/cmp_encryptAes256Pdf2Permissions.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/PdfEncryptionTest/cmp_encryptWithPasswordAes256Pdf2.pdf b/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/PdfEncryptionTest/cmp_encryptWithPasswordAes256Pdf2.pdf index ad124a4201..0342ff69f2 100644 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/PdfEncryptionTest/cmp_encryptWithPasswordAes256Pdf2.pdf and b/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/PdfEncryptionTest/cmp_encryptWithPasswordAes256Pdf2.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/PdfEncryptionTest/cmp_stampAndUpdateVersionNewAes256.pdf b/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/PdfEncryptionTest/cmp_stampAndUpdateVersionNewAes256.pdf index 4e4e2c245b..81221803b7 100644 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/PdfEncryptionTest/cmp_stampAndUpdateVersionNewAes256.pdf and b/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/PdfEncryptionTest/cmp_stampAndUpdateVersionNewAes256.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_arabic01.pdf b/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_arabic01.pdf index fdbf27e6ce..9bf3c10bef 100644 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_arabic01.pdf and b/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_arabic01.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_arabic02.pdf b/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_arabic02.pdf index 594d85820e..c5a942b289 100644 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_arabic02.pdf and b/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_arabic02.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_arabic03.pdf b/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_arabic03.pdf index 22a95ed46c..1fef9fd751 100644 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_arabic03.pdf and b/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_arabic03.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_arabic04.pdf b/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_arabic04.pdf index 84f2984d92..908976c468 100644 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_arabic04.pdf and b/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_arabic04.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_arabic05.pdf b/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_arabic05.pdf index 0072a341ea..9651572068 100644 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_arabic05.pdf and b/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_arabic05.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_devanagari01.pdf b/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_devanagari01.pdf index 309fdcf2ef..c41d3c8123 100644 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_devanagari01.pdf and b/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_devanagari01.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_devanagari02.pdf b/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_devanagari02.pdf index 6481b11782..f23b6fbaa5 100644 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_devanagari02.pdf and b/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_devanagari02.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_emoji01.pdf b/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_emoji01.pdf index 0c3803b0d1..bcb49fb02e 100644 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_emoji01.pdf and b/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_emoji01.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_gurmukhi01.pdf b/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_gurmukhi01.pdf index c090428637..e88847346f 100644 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_gurmukhi01.pdf and b/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_gurmukhi01.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_khmer01.pdf b/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_khmer01.pdf index 79672d615d..a4182c6804 100644 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_khmer01.pdf and b/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_khmer01.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_nfkcNormalization01.pdf b/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_nfkcNormalization01.pdf index 994a3cf184..700818f509 100644 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_nfkcNormalization01.pdf and b/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_nfkcNormalization01.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_nfkcNormalization02.pdf b/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_nfkcNormalization02.pdf index d12efd75e3..5e53b3b77c 100644 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_nfkcNormalization02.pdf and b/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_nfkcNormalization02.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_nfkcNormalization03.pdf b/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_nfkcNormalization03.pdf index ac6400b63d..74608901bd 100644 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_nfkcNormalization03.pdf and b/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_nfkcNormalization03.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_nfkcNormalization04.pdf b/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_nfkcNormalization04.pdf index b26f7154ad..b4f60b0dd5 100644 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_nfkcNormalization04.pdf and b/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_nfkcNormalization04.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_nfkcNormalization05.pdf b/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_nfkcNormalization05.pdf index 20ad57efbc..41b2f7c667 100644 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_nfkcNormalization05.pdf and b/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_nfkcNormalization05.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_nonAsciiSpace01.pdf b/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_nonAsciiSpace01.pdf index 25866b1594..b3b13fe202 100644 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_nonAsciiSpace01.pdf and b/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_nonAsciiSpace01.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_rfc4013Example01.pdf b/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_rfc4013Example01.pdf index 0f5dcc5def..1bb32c6a41 100644 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_rfc4013Example01.pdf and b/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_rfc4013Example01.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_rfc4013Example02.pdf b/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_rfc4013Example02.pdf index 68fbdbdc47..54866c9766 100644 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_rfc4013Example02.pdf and b/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_rfc4013Example02.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_rfc4013Example03.pdf b/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_rfc4013Example03.pdf index d7d11aac6d..2de9ec3f40 100644 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_rfc4013Example03.pdf and b/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_rfc4013Example03.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_rfc4013Example04.pdf b/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_rfc4013Example04.pdf index c7fbaa9399..bd72132b51 100644 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_rfc4013Example04.pdf and b/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_rfc4013Example04.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_tamil01.pdf b/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_tamil01.pdf index 23e1032373..8a0132e81b 100644 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_tamil01.pdf and b/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_tamil01.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_thai01.pdf b/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_thai01.pdf index ec9ba63c25..d9344d4983 100644 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_thai01.pdf and b/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_thai01.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_unicodeBom01.pdf b/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_unicodeBom01.pdf index a87947fbad..b13c9602c0 100644 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_unicodeBom01.pdf and b/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/UnicodeBasedPasswordEncryptionTest/cmp_unicodePassword_unicodeBom01.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/crypto/securityhandler/PubSecHandlerUsingAesGcmTest/cmp_externalFile.pdf b/kernel/src/test/resources/com/itextpdf/kernel/crypto/securityhandler/PubSecHandlerUsingAesGcmTest/cmp_externalFile.pdf new file mode 100644 index 0000000000..cb26c71843 Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/crypto/securityhandler/PubSecHandlerUsingAesGcmTest/cmp_externalFile.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/crypto/securityhandler/PubSecHandlerUsingAesGcmTest/cmp_simpleEncryptDecrypt.pdf b/kernel/src/test/resources/com/itextpdf/kernel/crypto/securityhandler/PubSecHandlerUsingAesGcmTest/cmp_simpleEncryptDecrypt.pdf new file mode 100644 index 0000000000..04af4ab69a Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/crypto/securityhandler/PubSecHandlerUsingAesGcmTest/cmp_simpleEncryptDecrypt.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/crypto/securityhandler/PubSecHandlerUsingAesGcmTest/cmp_simpleEncryptDecrypt_1_7.pdf b/kernel/src/test/resources/com/itextpdf/kernel/crypto/securityhandler/PubSecHandlerUsingAesGcmTest/cmp_simpleEncryptDecrypt_1_7.pdf new file mode 100644 index 0000000000..bfae56843b Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/crypto/securityhandler/PubSecHandlerUsingAesGcmTest/cmp_simpleEncryptDecrypt_1_7.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/crypto/securityhandler/PubSecHandlerUsingAesGcmTest/decrypter.cert.pem b/kernel/src/test/resources/com/itextpdf/kernel/crypto/securityhandler/PubSecHandlerUsingAesGcmTest/decrypter.cert.pem new file mode 100644 index 0000000000..b389cc324c --- /dev/null +++ b/kernel/src/test/resources/com/itextpdf/kernel/crypto/securityhandler/PubSecHandlerUsingAesGcmTest/decrypter.cert.pem @@ -0,0 +1,25 @@ +-----BEGIN CERTIFICATE----- +MIIEMDCCAxigAwIBAgICEAIwDQYJKoZIhvcNAQELBQAwWTELMAkGA1UEBhMCQkUx +FDASBgNVBAoMC0V4YW1wbGUgSW5jMRowGAYDVQQLDBFUZXN0aW5nIEF1dGhvcml0 +eTEYMBYGA1UEAwwPSW50ZXJtZWRpYXRlIENBMCIYDzIwMjAwMTAxMDAwMDAwWhgP +MjAyMjAxMDEwMDAwMDBaMHExCzAJBgNVBAYTAkJFMRQwEgYDVQQKDAtFeGFtcGxl +IEluYzEaMBgGA1UECwwRVGVzdGluZyBBdXRob3JpdHkxDjAMBgNVBAMMBUFsaWNl +MSAwHgYJKoZIhvcNAQkBFhFhbGljZUBleGFtcGxlLmNvbTCCASIwDQYJKoZIhvcN +AQEBBQADggEPADCCAQoCggEBAOFzgm4eL34uvUYrX4akyEBi+sn0gCYo8UOthApf +luxF4ccaGhCHdjZa1PwRpV3bDGFQpUbhNu0juCBkYbRGxasQOn1CUDF7DCCjztNE +d779WwRlA5dnqWMFU5IjtoavSYl+CA1Ase2edxq7UjEZr4kIm7ADlUVpdKxLItJF +EP4QOjqv5sENuiGCKpMqb/JGmvnLxRevxDZQ8hIDV2s07krCog8hRChie39mDNmZ +/RH/JbgME6mGY99bDAnhu8xH41iBo8GemEmmFesx8YPrMivcXHk3QNt2LsKCAGZl +G51fsrtiC31732W0+dc09PoITS0NMvP8/38dQmod3ktJBusCAwEAAaOB5TCB4jAd +BgNVHQ4EFgQUXsenutQKZ62drno9rRRqOLVzCrgwHwYDVR0jBBgwFoAU7796UYsu +pC5KXdLO52F4zmo2SU8wDgYDVR0PAQH/BAQDAgUgMEcGA1UdHwRAMD4wPKA6oDiG +Nmh0dHA6Ly9weWhhbmtvLnRlc3RzL3Rlc3RpbmctY2EvY3Jscy9pbnRlcm0vbGF0 +ZXN0LmNybDBHBggrBgEFBQcBAQQ7MDkwNwYIKwYBBQUHMAGGK2h0dHA6Ly9weWhh +bmtvLnRlc3RzL3Rlc3RpbmctY2Evb2NzcC9pbnRlcm0wDQYJKoZIhvcNAQELBQAD +ggEBAJemwKDaHB+cRZHHGZbQ26E+xR1XgBw/IPqEanGfm37ANyJk1BCBXFUJBNLF +3b9pdvRnu+wuF0h9rGBkIAKNuuzyJIJhAj5FgRVTLRTIDxYZMPgBuxdrKx3rocYm +CVCu/OmlK6k8kHQubMCuQgVucd2emqg2tG1QOjt+yHXLLpPoOnYjKZlixzA0mW75 +DHj2hPFnan8fZ18orLGuWKRjMIatEdQYNIcPkmDEbQT9mh2v+ucXChg01TdvVzbc +fz43Jgu8Idv4PUiwbr4x8qCOahH1eUHQ1PCsCuF6RH5vjqAS8urthuR56BJOw7TX +Yl0L7vBpz0oA4j+uP6n1a8Uu43k= +-----END CERTIFICATE----- diff --git a/kernel/src/test/resources/com/itextpdf/kernel/crypto/securityhandler/PubSecHandlerUsingAesGcmTest/externalFile.pdf b/kernel/src/test/resources/com/itextpdf/kernel/crypto/securityhandler/PubSecHandlerUsingAesGcmTest/externalFile.pdf new file mode 100644 index 0000000000..e2253473ab Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/crypto/securityhandler/PubSecHandlerUsingAesGcmTest/externalFile.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/crypto/securityhandler/PubSecHandlerUsingAesGcmTest/invalidCryptFilter.pdf b/kernel/src/test/resources/com/itextpdf/kernel/crypto/securityhandler/PubSecHandlerUsingAesGcmTest/invalidCryptFilter.pdf new file mode 100644 index 0000000000..086d385149 Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/crypto/securityhandler/PubSecHandlerUsingAesGcmTest/invalidCryptFilter.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/crypto/securityhandler/PubSecHandlerUsingAesGcmTest/signerkey.pem b/kernel/src/test/resources/com/itextpdf/kernel/crypto/securityhandler/PubSecHandlerUsingAesGcmTest/signerkey.pem new file mode 100644 index 0000000000..cc30330c20 --- /dev/null +++ b/kernel/src/test/resources/com/itextpdf/kernel/crypto/securityhandler/PubSecHandlerUsingAesGcmTest/signerkey.pem @@ -0,0 +1,30 @@ +-----BEGIN ENCRYPTED PRIVATE KEY----- +MIIFNTBfBgkqhkiG9w0BBQ0wUjAxBgkqhkiG9w0BBQwwJAQQxtGpvXqM8ggXE+LE +qX9lZwICCAAwDAYIKoZIhvcNAgkFADAdBglghkgBZQMEASoEEKK3IjaIwyNfaYFC +I8eHbZgEggTQS/qyyqLzljwQRKFPb6la2EAF1SKsWwP5hsrZ6TaGC4Rwdgm2wpH/ +HYp7DcdigKoYFCb4avatNRNdjY9YDEObrULn3YKemQNxcDRnceDppNWfN7eR0Ug4 +Y6OHPQfWzBsxWTyxrPJsa7v+rEczqLcIR77HNIGvH9oFYE58hTHLiEiFe5GM1lY3 +n+D7xyFrDT1IhO0BqVsIQUNXYonF5sThbUur2/g6YVpjHASnkILxZNoKEm0akfLV +99ACy6ABe9NwR0pHeCkOqkhVRT68/iktriK2Cpsp5xc8Hs6PT7jKMtF803k35vH7 +joMFYKzrqpNkv6goJ1MK0twpsvBVQD6zoK8dIXfuduTSNfhYobZ8ACjppLSZ0zTo +oXWBQPaOPADpH+/sC/MpZGH1DvUwV9XPsOQWcpmbrzb9rp83/KyBZ/sPSY3j9XqY +2WKT2nfi0DUPepolhBFG3Z/rBQZsK4IxCmMA2Dy8yJwct7Dk2CH/dRy0XDi0hV/3 +sSug2XjnTg4z+fBEEd/S55+DJNUbModH9Z5bfcDSKoXWwa7tmF+EYiAVjgRDPJIK +2eDJ6Esaw2HPKhe5sI/NJ2kxzmd0k8/ITH428kQS8VrC6k/MTtIxDjOx+0xbwvgI +Vuh+oDGjpNb7UVYLZt8ckdGhzWSOeZahHpygA9aG2zwhu0uL2Mu6uUqZH3WHv3Nl +UnrLanQ9EiLREiKaNBuLRWCX0/RI1UgAiKVI+bsyNYVGb1EKCX5f7WAJUX0C2Qzv +AWDohtBbDcpSFKgbwZy0JvR899i01xkJwWy8wwNwrcZ4XVfU7H34TcF/qklt90HU +epSKShHbTAejgZURCAK3OQaLaxEDMMAXNxoMk2LYq/8syB7dt73iU4b4iJJospiv +aSI9CTvMj7EQ4iE3m0LSxFWF4cXgMqXe6X51VSvf68oq2Ge9yZr29UW2sdrNfdJC +oV76SoRdcTiYd1BLbOKiUbpDmP2bzX9eCCdJkBfpAePVzf6LCajBJnr7A1FHpja6 +TbC1vWyPvqLKI+B4sVFJwoGXW/a91Iuqxtqo5fsT0FTyy4z8gMXyi/XWIPq93KWx +ZHDSNUDNc38Jb00nR/spap8btt9MNf5SFgwCGt0+RQxxp0FVKvSYtTa6Gu1/0Odc +bYbjAZRuJz6TxningKMFoNHAUo+/0SGV/S7ebjF618nPhAnmTXSlHzJ3OA3jmASl +eIpwyFpBCq8h0icyGNMJU8j5YMsXgWVlw2s0YGwpNwDVMsaFgLzByMStONdhRM6l +EOCmgAS8H+TgRuTIvqNppYs/1Q/SfOt6Gw/0qv0HBQtDuwbuQzbIt/YuAyUjXTni +CSvz5/3GCtGuCG4wQLw+ZRYadfLSwNv/c6yX8fdkOxpxdWrl/ixnZVy8+9b3q0Zx +J645eDywxWEtFGFBwNxsOkJVKXFuvG6S2MQhG22jH6tPFsGl4n7bgNEJmFch8EyX +bbkacEqJmpF1TW3F7d4lhg54fC6ex8mPtMYCtCAbTdmVBwv6Q1AmR2SpuWwwLlFv +sTe1ogJAvtvWkiHbG0tfVgNi3R3I6JfyAagwzJQcz3qsVKgfB5KHZCJqrDDDb1b6 +QA93ii2B/a+xQUDE/31NlraIuPKbQa8BWMoUxf/5JTuCSvM3jSPVh4Q= +-----END ENCRYPTED PRIVATE KEY----- diff --git a/kernel/src/test/resources/com/itextpdf/kernel/crypto/securityhandler/PubSecHandlerUsingAesGcmTest/simpleEncryptDecrypt.pdf b/kernel/src/test/resources/com/itextpdf/kernel/crypto/securityhandler/PubSecHandlerUsingAesGcmTest/simpleEncryptDecrypt.pdf new file mode 100644 index 0000000000..7f24d3a4fc Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/crypto/securityhandler/PubSecHandlerUsingAesGcmTest/simpleEncryptDecrypt.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/crypto/securityhandler/PubSecHandlerUsingAesGcmTest/simpleEncryptDecrypt_1_7.pdf b/kernel/src/test/resources/com/itextpdf/kernel/crypto/securityhandler/PubSecHandlerUsingAesGcmTest/simpleEncryptDecrypt_1_7.pdf new file mode 100644 index 0000000000..7f24d3a4fc Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/crypto/securityhandler/PubSecHandlerUsingAesGcmTest/simpleEncryptDecrypt_1_7.pdf differ diff --git a/sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/test.cer b/kernel/src/test/resources/com/itextpdf/kernel/crypto/securityhandler/PubSecHandlerUsingAesGcmTest/test.cer similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/test.cer rename to kernel/src/test/resources/com/itextpdf/kernel/crypto/securityhandler/PubSecHandlerUsingAesGcmTest/test.cer diff --git a/kernel/src/test/resources/com/itextpdf/kernel/crypto/securityhandler/PubSecHandlerUsingAesGcmTest/test.pem b/kernel/src/test/resources/com/itextpdf/kernel/crypto/securityhandler/PubSecHandlerUsingAesGcmTest/test.pem new file mode 100644 index 0000000000..9a9aba7c6a --- /dev/null +++ b/kernel/src/test/resources/com/itextpdf/kernel/crypto/securityhandler/PubSecHandlerUsingAesGcmTest/test.pem @@ -0,0 +1,51 @@ +-----BEGIN ENCRYPTED PRIVATE KEY----- +MIIFNTBfBgkqhkiG9w0BBQ0wUjAxBgkqhkiG9w0BBQwwJAQQdOaEUfD0sZWtUR11 +xwgn0gICCAAwDAYIKoZIhvcNAgkFADAdBglghkgBZQMEASoEEBaNXSfwUjF5SS7n +ce1JFoUEggTQ6eV+IsckiVP7I9VTldLkpP5OKB8brmw5t20fO11HyCnqkkhooR2b +t2fBj4fWv0IRUe266L+fVs7AOngjkWfezEvGR6nte4pNXEFrOwt/U8A6IYZXBdA5 +dvqs6VMPHbjQ8CufVLGvksuYFQVRcGy0rk1DH2Of44GU4X0GtROlFFJnkmfZhVPS +Hx2MXXGQ02Ko1i1eKoEGgvmSAsDcPijiX96DKlQZJ4YMtI/8rRsdvNJsJ2beyZDa +T3aJMmSSBF92mS2dtS21DwjzEu8utquguYA0KYzjZM9onOuBEEUifam8Fjnvlui6 +beQJya4zldoA6QZPSd2PUAP6l1U/d8UXqcisjzArDZDmRu58dPxn4rs0NgTOIO8h +fEUIvfS+wuknff1b/wdGnwXkXoeSrrjS9dhP9KVU1SJ/FWKc6BY+P+JmE5vLjAtn +AmbyZhXY0jX7ZHFh0z0y1y1fTIXL1aj4iB+cUwhJ1ZdlGkT5HdG4ts/oTGCnpB6O +F1GvGyhprmtjp/dspLH5ha0I+4aTn46yFpnBNyg8w9c2+xj8Jiqy9J/ppVtPdhxt +wrE1/ThUGIWUTsbGbLW87WIrZq6IlSGtztbxAMYxXoe4solYueE3pI3eYFzgnBcq +T6Byktr71gt9AGD/N/p+Kk5RM4JT8XpQjLjz9TlmsGpJzUoBGeG6KFLsqqLLSD+0 +c5lAGWsFhec3uCu4fCyBqxpQc0y5j2bgUiTRGYn1NOdyZg+ERO/aWGfkDOAtlL1i +B79NGIBxIXgt508g83UeaQC6KjuG/8hPY6UHmU5mlgRT9H5jvkSX3mEtl1Gdk2y0 +M5pZTTrhbG4p66GhBi8vM5tQfiBoLUKEM/kgiGXPC6Kob42nb3ufP0rmnKklcDGC ++898hW5ge+VNmOkHpVuV5ZD9aWUSVEU4+8QNZj8pcyL0GXFyEL/HxNxUESdz3k0S +bInuxO49mgGPjBqtx5ZvaxyWFnzOp6rmHZUHymejxxdnlnTnSnXKkJFjcm7n0sKO +575ofHtk0OdqIK6YiPgfeF6nZkIg3C0PbReZ05kTplrW182ZWuQQyJgv+RPzF4+9 +5rCe67nJhJrt7hXFRsUScHXNj+HF9Av8WR2RnHTRbpQBJszijM+Xgl+VeYcY5ckB +fk+AfcR9r0Jud4O9795OOWVxWqGVu/b1RGonfjMkGW+JdnZL0vkOYYcHt4iMZmzW +M0ZowZPGO5dFBV7/ZkVzb0fexw+f+E0lUBEK1cx0gxnzjmcGJO+C9if1uIEfwpon +3wBOTDsU7XKDx9v6ibcDMOXrZa+rcJWxgNkXt5nRpozZkddYctBkehGu+snV2g4n +SdOwr0eIVv/L+v4IywZmeWWEVnbSAvB0p7nB89bgLMr9tV0ly7MWxPH+gPnNJ1gE +7Mp3AgN5BxEmLfW3+ou3QLoqnOS2MCw/xcgLP0nJACSPI7/nWy95iKXKgkCkAgF9 +4Ztk7uBG4tiK14KcKq8ToCW2YNliT3g0CWjBLtVPUS6qboudMiuedxTxE8WEirpT +A77nfDNg4MVjl4kP9jhV0Phpn9rDMJ2jw0BqFc1Vou4aNDXYandAFJea44Wce9H+ +qAowcrfsWehD01HBQ2KwWVg3sLnwwBHw0nvbATS41hdxsP2OmCnxWkc= +-----END ENCRYPTED PRIVATE KEY----- +-----BEGIN CERTIFICATE----- +MIIDfzCCAmegAwIBAgIEUFic9zANBgkqhkiG9w0BAQsFADBvMQswCQYDVQQGEwJU +UzETMBEGA1UECBMKVGVzdCBTdGF0ZTESMBAGA1UEBxMJVGVzdCBUb3duMREwDwYD +VQQKEwhUZXN0IG9yZzEQMA4GA1UECxMHVGVzdCBPVTESMBAGA1UEAxMJVGVzdCBV +c2VyMCAXDTE0MDkyMjA5MTExMVoYDzIxMTQwODI5MDkxMTExWjBvMQswCQYDVQQG +EwJUUzETMBEGA1UECBMKVGVzdCBTdGF0ZTESMBAGA1UEBxMJVGVzdCBUb3duMREw +DwYDVQQKEwhUZXN0IG9yZzEQMA4GA1UECxMHVGVzdCBPVTESMBAGA1UEAxMJVGVz +dCBVc2VyMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA+6g5sYzXiNOA +hR7C8wc8buxU/JgcbdHpHIR44iuXjpepBYAE7hRsWM7H4cuXrKiRxS9UMOadqkGF +Qqb5sG6lo2UUhcj4qlN6hKDc/+AMZMIW1mvQldiygCAkqgM8iso+kw56dpVuerG/ +k1nd8f+X9rjXN6/DIMznZcMy2d9ByIFuixFKElPvOWx9q9N4aiueOd5FM5eHxp+3 +F4uCTrpM5zkS7Rmf5GVtCofc8KgaTLLp4D0Ge5VUJm7yW8fuU3eIpin4ivjk+Gye +Q3t0BsrmNyQy3CmKGOBP/vX0+wEMvGN2xqNgAFP9dxA+AbJMiAfsmoWvxXaPktqC +DOspTCFqbwIDAQABoyEwHzAdBgNVHQ4EFgQUILviRCmSrhuLDmF0nus4pv2uu7gw +DQYJKoZIhvcNAQELBQADggEBAGnfGYL7nDm5taDPRxuGGMqUPwRnH2bXwef6S2Xb +/nIEFtNheVFQFtKNn5Ikq68DTFMP06yXLnI7F40+ZiQezRBB1EPPmDL2fYKc9fL1 +SHntu6HLgP/Y5nnCVegtL8l9745gQZnnXlMtkTs2HFwffznIHW/3STO0Bcj0+KMa +p8vebMjmvV7bZEGvrcrVXL55QPZXJwRuQMXJB3f5XhAEH1VqAhTW6DrvBUnuESwo +9fxxA5gmblt80SQYdKr2I08OTk0qmyF8zNuffTOiSS8/V6Cf7CntuPWjSuVf1EVP +MH6KkSjceLZ99Y7bvl7KKvQ4Kj5Bp27PwlRvtYbfCUmQEG8= +-----END CERTIFICATE----- diff --git a/kernel/src/test/resources/com/itextpdf/kernel/crypto/securityhandler/StandardHandlerUsingAesGcmTest/cmp_encryptedSimpleDocument.pdf b/kernel/src/test/resources/com/itextpdf/kernel/crypto/securityhandler/StandardHandlerUsingAesGcmTest/cmp_encryptedSimpleDocument.pdf new file mode 100644 index 0000000000..51981cdead Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/crypto/securityhandler/StandardHandlerUsingAesGcmTest/cmp_encryptedSimpleDocument.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/crypto/securityhandler/StandardHandlerUsingAesGcmTest/encryptedDocument.pdf b/kernel/src/test/resources/com/itextpdf/kernel/crypto/securityhandler/StandardHandlerUsingAesGcmTest/encryptedDocument.pdf new file mode 100644 index 0000000000..07df73faa8 Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/crypto/securityhandler/StandardHandlerUsingAesGcmTest/encryptedDocument.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/crypto/securityhandler/StandardHandlerUsingAesGcmTest/encryptedDocumentTamperedCiphertext.pdf b/kernel/src/test/resources/com/itextpdf/kernel/crypto/securityhandler/StandardHandlerUsingAesGcmTest/encryptedDocumentTamperedCiphertext.pdf new file mode 100644 index 0000000000..9bd2097f6d Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/crypto/securityhandler/StandardHandlerUsingAesGcmTest/encryptedDocumentTamperedCiphertext.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/crypto/securityhandler/StandardHandlerUsingAesGcmTest/encryptedDocumentTamperedIv.pdf b/kernel/src/test/resources/com/itextpdf/kernel/crypto/securityhandler/StandardHandlerUsingAesGcmTest/encryptedDocumentTamperedIv.pdf new file mode 100644 index 0000000000..fc50c51615 Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/crypto/securityhandler/StandardHandlerUsingAesGcmTest/encryptedDocumentTamperedIv.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/crypto/securityhandler/StandardHandlerUsingAesGcmTest/encryptedDocumentTamperedMac.pdf b/kernel/src/test/resources/com/itextpdf/kernel/crypto/securityhandler/StandardHandlerUsingAesGcmTest/encryptedDocumentTamperedMac.pdf new file mode 100644 index 0000000000..93d25ec16d Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/crypto/securityhandler/StandardHandlerUsingAesGcmTest/encryptedDocumentTamperedMac.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/crypto/securityhandler/StandardHandlerUsingAesGcmTest/simpleDocument.pdf b/kernel/src/test/resources/com/itextpdf/kernel/crypto/securityhandler/StandardHandlerUsingAesGcmTest/simpleDocument.pdf new file mode 100644 index 0000000000..7f24d3a4fc Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/crypto/securityhandler/StandardHandlerUsingAesGcmTest/simpleDocument.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/font/PdfType3FontTest/type3FontMultipleCodesToOneGlyph.pdf b/kernel/src/test/resources/com/itextpdf/kernel/font/PdfType3FontTest/type3FontMultipleCodesToOneGlyph.pdf deleted file mode 100644 index 80b78eebcd..0000000000 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/font/PdfType3FontTest/type3FontMultipleCodesToOneGlyph.pdf and /dev/null differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/font/PdfType3FontTest/type3FontWithCustomNames.pdf b/kernel/src/test/resources/com/itextpdf/kernel/font/PdfType3FontTest/type3FontWithCustomNames.pdf deleted file mode 100644 index 9c85f4294b..0000000000 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/font/PdfType3FontTest/type3FontWithCustomNames.pdf and /dev/null differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/certs/SHA256withRSA.cer b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/certs/SHA256withRSA.cer new file mode 100644 index 0000000000..fbaad2b382 Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/certs/SHA256withRSA.cer differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/certs/SHA256withRSA.key b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/certs/SHA256withRSA.key new file mode 100644 index 0000000000..d7e9b5e825 --- /dev/null +++ b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/certs/SHA256withRSA.key @@ -0,0 +1,51 @@ +-----BEGIN ENCRYPTED PRIVATE KEY----- +MIIFNTBfBgkqhkiG9w0BBQ0wUjAxBgkqhkiG9w0BBQwwJAQQdOaEUfD0sZWtUR11 +xwgn0gICCAAwDAYIKoZIhvcNAgkFADAdBglghkgBZQMEASoEEBaNXSfwUjF5SS7n +ce1JFoUEggTQ6eV+IsckiVP7I9VTldLkpP5OKB8brmw5t20fO11HyCnqkkhooR2b +t2fBj4fWv0IRUe266L+fVs7AOngjkWfezEvGR6nte4pNXEFrOwt/U8A6IYZXBdA5 +dvqs6VMPHbjQ8CufVLGvksuYFQVRcGy0rk1DH2Of44GU4X0GtROlFFJnkmfZhVPS +Hx2MXXGQ02Ko1i1eKoEGgvmSAsDcPijiX96DKlQZJ4YMtI/8rRsdvNJsJ2beyZDa +T3aJMmSSBF92mS2dtS21DwjzEu8utquguYA0KYzjZM9onOuBEEUifam8Fjnvlui6 +beQJya4zldoA6QZPSd2PUAP6l1U/d8UXqcisjzArDZDmRu58dPxn4rs0NgTOIO8h +fEUIvfS+wuknff1b/wdGnwXkXoeSrrjS9dhP9KVU1SJ/FWKc6BY+P+JmE5vLjAtn +AmbyZhXY0jX7ZHFh0z0y1y1fTIXL1aj4iB+cUwhJ1ZdlGkT5HdG4ts/oTGCnpB6O +F1GvGyhprmtjp/dspLH5ha0I+4aTn46yFpnBNyg8w9c2+xj8Jiqy9J/ppVtPdhxt +wrE1/ThUGIWUTsbGbLW87WIrZq6IlSGtztbxAMYxXoe4solYueE3pI3eYFzgnBcq +T6Byktr71gt9AGD/N/p+Kk5RM4JT8XpQjLjz9TlmsGpJzUoBGeG6KFLsqqLLSD+0 +c5lAGWsFhec3uCu4fCyBqxpQc0y5j2bgUiTRGYn1NOdyZg+ERO/aWGfkDOAtlL1i +B79NGIBxIXgt508g83UeaQC6KjuG/8hPY6UHmU5mlgRT9H5jvkSX3mEtl1Gdk2y0 +M5pZTTrhbG4p66GhBi8vM5tQfiBoLUKEM/kgiGXPC6Kob42nb3ufP0rmnKklcDGC ++898hW5ge+VNmOkHpVuV5ZD9aWUSVEU4+8QNZj8pcyL0GXFyEL/HxNxUESdz3k0S +bInuxO49mgGPjBqtx5ZvaxyWFnzOp6rmHZUHymejxxdnlnTnSnXKkJFjcm7n0sKO +575ofHtk0OdqIK6YiPgfeF6nZkIg3C0PbReZ05kTplrW182ZWuQQyJgv+RPzF4+9 +5rCe67nJhJrt7hXFRsUScHXNj+HF9Av8WR2RnHTRbpQBJszijM+Xgl+VeYcY5ckB +fk+AfcR9r0Jud4O9795OOWVxWqGVu/b1RGonfjMkGW+JdnZL0vkOYYcHt4iMZmzW +M0ZowZPGO5dFBV7/ZkVzb0fexw+f+E0lUBEK1cx0gxnzjmcGJO+C9if1uIEfwpon +3wBOTDsU7XKDx9v6ibcDMOXrZa+rcJWxgNkXt5nRpozZkddYctBkehGu+snV2g4n +SdOwr0eIVv/L+v4IywZmeWWEVnbSAvB0p7nB89bgLMr9tV0ly7MWxPH+gPnNJ1gE +7Mp3AgN5BxEmLfW3+ou3QLoqnOS2MCw/xcgLP0nJACSPI7/nWy95iKXKgkCkAgF9 +4Ztk7uBG4tiK14KcKq8ToCW2YNliT3g0CWjBLtVPUS6qboudMiuedxTxE8WEirpT +A77nfDNg4MVjl4kP9jhV0Phpn9rDMJ2jw0BqFc1Vou4aNDXYandAFJea44Wce9H+ +qAowcrfsWehD01HBQ2KwWVg3sLnwwBHw0nvbATS41hdxsP2OmCnxWkc= +-----END ENCRYPTED PRIVATE KEY----- +-----BEGIN CERTIFICATE----- +MIIDfzCCAmegAwIBAgIEUFic9zANBgkqhkiG9w0BAQsFADBvMQswCQYDVQQGEwJU +UzETMBEGA1UECBMKVGVzdCBTdGF0ZTESMBAGA1UEBxMJVGVzdCBUb3duMREwDwYD +VQQKEwhUZXN0IG9yZzEQMA4GA1UECxMHVGVzdCBPVTESMBAGA1UEAxMJVGVzdCBV +c2VyMCAXDTE0MDkyMjA5MTExMVoYDzIxMTQwODI5MDkxMTExWjBvMQswCQYDVQQG +EwJUUzETMBEGA1UECBMKVGVzdCBTdGF0ZTESMBAGA1UEBxMJVGVzdCBUb3duMREw +DwYDVQQKEwhUZXN0IG9yZzEQMA4GA1UECxMHVGVzdCBPVTESMBAGA1UEAxMJVGVz +dCBVc2VyMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA+6g5sYzXiNOA +hR7C8wc8buxU/JgcbdHpHIR44iuXjpepBYAE7hRsWM7H4cuXrKiRxS9UMOadqkGF +Qqb5sG6lo2UUhcj4qlN6hKDc/+AMZMIW1mvQldiygCAkqgM8iso+kw56dpVuerG/ +k1nd8f+X9rjXN6/DIMznZcMy2d9ByIFuixFKElPvOWx9q9N4aiueOd5FM5eHxp+3 +F4uCTrpM5zkS7Rmf5GVtCofc8KgaTLLp4D0Ge5VUJm7yW8fuU3eIpin4ivjk+Gye +Q3t0BsrmNyQy3CmKGOBP/vX0+wEMvGN2xqNgAFP9dxA+AbJMiAfsmoWvxXaPktqC +DOspTCFqbwIDAQABoyEwHzAdBgNVHQ4EFgQUILviRCmSrhuLDmF0nus4pv2uu7gw +DQYJKoZIhvcNAQELBQADggEBAGnfGYL7nDm5taDPRxuGGMqUPwRnH2bXwef6S2Xb +/nIEFtNheVFQFtKNn5Ikq68DTFMP06yXLnI7F40+ZiQezRBB1EPPmDL2fYKc9fL1 +SHntu6HLgP/Y5nnCVegtL8l9745gQZnnXlMtkTs2HFwffznIHW/3STO0Bcj0+KMa +p8vebMjmvV7bZEGvrcrVXL55QPZXJwRuQMXJB3f5XhAEH1VqAhTW6DrvBUnuESwo +9fxxA5gmblt80SQYdKr2I08OTk0qmyF8zNuffTOiSS8/V6Cf7CntuPWjSuVf1EVP +MH6KkSjceLZ99Y7bvl7KKvQ4Kj5Bp27PwlRvtYbfCUmQEG8= +-----END CERTIFICATE----- diff --git a/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/cmp_addMacOnAppendModeTest.pdf b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/cmp_addMacOnAppendModeTest.pdf new file mode 100644 index 0000000000..792884c274 Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/cmp_addMacOnAppendModeTest.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/cmp_addMacOnPreserveEncryptionFor17DocTest.pdf b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/cmp_addMacOnPreserveEncryptionFor17DocTest.pdf new file mode 100644 index 0000000000..2a95592bc0 Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/cmp_addMacOnPreserveEncryptionFor17DocTest.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/cmp_addMacOnPreserveEncryptionTest.pdf b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/cmp_addMacOnPreserveEncryptionTest.pdf new file mode 100644 index 0000000000..86eb20d0c6 Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/cmp_addMacOnPreserveEncryptionTest.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/cmp_addMacOnPreserveEncryptionWhileDowngradingTest.pdf b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/cmp_addMacOnPreserveEncryptionWhileDowngradingTest.pdf new file mode 100644 index 0000000000..31820a46c0 Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/cmp_addMacOnPreserveEncryptionWhileDowngradingTest.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/cmp_addMacOnPreservePublicKeyEncryptionTest.pdf b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/cmp_addMacOnPreservePublicKeyEncryptionTest.pdf new file mode 100644 index 0000000000..ea6b7c705d Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/cmp_addMacOnPreservePublicKeyEncryptionTest.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/cmp_addMacWithDisableMacPropertyTest.pdf b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/cmp_addMacWithDisableMacPropertyTest.pdf new file mode 100644 index 0000000000..0bca6b434c Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/cmp_addMacWithDisableMacPropertyTest.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/cmp_macEncryptionWithAesGsmTest.pdf b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/cmp_macEncryptionWithAesGsmTest.pdf new file mode 100644 index 0000000000..995f5df2fb Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/cmp_macEncryptionWithAesGsmTest.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/cmp_noMacProtectionTest.pdf b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/cmp_noMacProtectionTest.pdf new file mode 100644 index 0000000000..963d5074ab Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/cmp_noMacProtectionTest.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/cmp_standaloneMacPublicKeyEncryptionTest.pdf b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/cmp_standaloneMacPublicKeyEncryptionTest.pdf new file mode 100644 index 0000000000..3eb997bda3 Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/cmp_standaloneMacPublicKeyEncryptionTest.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/cmp_standaloneMacStandardEncryptionTest.pdf b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/cmp_standaloneMacStandardEncryptionTest.pdf new file mode 100644 index 0000000000..f8bffedbdc Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/cmp_standaloneMacStandardEncryptionTest.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/cmp_standaloneMacWithAllHashAlgorithmsTest1.pdf b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/cmp_standaloneMacWithAllHashAlgorithmsTest1.pdf new file mode 100644 index 0000000000..0c296530e4 Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/cmp_standaloneMacWithAllHashAlgorithmsTest1.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/cmp_standaloneMacWithAllHashAlgorithmsTest2.pdf b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/cmp_standaloneMacWithAllHashAlgorithmsTest2.pdf new file mode 100644 index 0000000000..396ef5bb01 Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/cmp_standaloneMacWithAllHashAlgorithmsTest2.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/cmp_standaloneMacWithAllHashAlgorithmsTest3.pdf b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/cmp_standaloneMacWithAllHashAlgorithmsTest3.pdf new file mode 100644 index 0000000000..b2b994a544 Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/cmp_standaloneMacWithAllHashAlgorithmsTest3.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/cmp_standaloneMacWithAllHashAlgorithmsTest4.pdf b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/cmp_standaloneMacWithAllHashAlgorithmsTest4.pdf new file mode 100644 index 0000000000..54aac71803 Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/cmp_standaloneMacWithAllHashAlgorithmsTest4.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/cmp_standaloneMacWithAllHashAlgorithmsTest5.pdf b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/cmp_standaloneMacWithAllHashAlgorithmsTest5.pdf new file mode 100644 index 0000000000..e4dfce5bbe Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/cmp_standaloneMacWithAllHashAlgorithmsTest5.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/cmp_standaloneMacWithAllHashAlgorithmsTest6.pdf b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/cmp_standaloneMacWithAllHashAlgorithmsTest6.pdf new file mode 100644 index 0000000000..9b6fe69a20 Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/cmp_standaloneMacWithAllHashAlgorithmsTest6.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/noMacProtectionDocument.pdf b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/noMacProtectionDocument.pdf new file mode 100644 index 0000000000..318f529543 Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/noMacProtectionDocument.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/noMacProtectionDocument_1_7.pdf b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/noMacProtectionDocument_1_7.pdf new file mode 100644 index 0000000000..db862c7069 Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/noMacProtectionDocument_1_7.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/noMacProtectionPublicKeyEncryptionDocument.pdf b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/noMacProtectionPublicKeyEncryptionDocument.pdf new file mode 100644 index 0000000000..4b5a106e64 Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest/noMacProtectionPublicKeyEncryptionDocument.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/certs/SHA256withRSA.cer b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/certs/SHA256withRSA.cer new file mode 100644 index 0000000000..fbaad2b382 Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/certs/SHA256withRSA.cer differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/certs/SHA256withRSA.key b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/certs/SHA256withRSA.key new file mode 100644 index 0000000000..d7e9b5e825 --- /dev/null +++ b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/certs/SHA256withRSA.key @@ -0,0 +1,51 @@ +-----BEGIN ENCRYPTED PRIVATE KEY----- +MIIFNTBfBgkqhkiG9w0BBQ0wUjAxBgkqhkiG9w0BBQwwJAQQdOaEUfD0sZWtUR11 +xwgn0gICCAAwDAYIKoZIhvcNAgkFADAdBglghkgBZQMEASoEEBaNXSfwUjF5SS7n +ce1JFoUEggTQ6eV+IsckiVP7I9VTldLkpP5OKB8brmw5t20fO11HyCnqkkhooR2b +t2fBj4fWv0IRUe266L+fVs7AOngjkWfezEvGR6nte4pNXEFrOwt/U8A6IYZXBdA5 +dvqs6VMPHbjQ8CufVLGvksuYFQVRcGy0rk1DH2Of44GU4X0GtROlFFJnkmfZhVPS +Hx2MXXGQ02Ko1i1eKoEGgvmSAsDcPijiX96DKlQZJ4YMtI/8rRsdvNJsJ2beyZDa +T3aJMmSSBF92mS2dtS21DwjzEu8utquguYA0KYzjZM9onOuBEEUifam8Fjnvlui6 +beQJya4zldoA6QZPSd2PUAP6l1U/d8UXqcisjzArDZDmRu58dPxn4rs0NgTOIO8h +fEUIvfS+wuknff1b/wdGnwXkXoeSrrjS9dhP9KVU1SJ/FWKc6BY+P+JmE5vLjAtn +AmbyZhXY0jX7ZHFh0z0y1y1fTIXL1aj4iB+cUwhJ1ZdlGkT5HdG4ts/oTGCnpB6O +F1GvGyhprmtjp/dspLH5ha0I+4aTn46yFpnBNyg8w9c2+xj8Jiqy9J/ppVtPdhxt +wrE1/ThUGIWUTsbGbLW87WIrZq6IlSGtztbxAMYxXoe4solYueE3pI3eYFzgnBcq +T6Byktr71gt9AGD/N/p+Kk5RM4JT8XpQjLjz9TlmsGpJzUoBGeG6KFLsqqLLSD+0 +c5lAGWsFhec3uCu4fCyBqxpQc0y5j2bgUiTRGYn1NOdyZg+ERO/aWGfkDOAtlL1i +B79NGIBxIXgt508g83UeaQC6KjuG/8hPY6UHmU5mlgRT9H5jvkSX3mEtl1Gdk2y0 +M5pZTTrhbG4p66GhBi8vM5tQfiBoLUKEM/kgiGXPC6Kob42nb3ufP0rmnKklcDGC ++898hW5ge+VNmOkHpVuV5ZD9aWUSVEU4+8QNZj8pcyL0GXFyEL/HxNxUESdz3k0S +bInuxO49mgGPjBqtx5ZvaxyWFnzOp6rmHZUHymejxxdnlnTnSnXKkJFjcm7n0sKO +575ofHtk0OdqIK6YiPgfeF6nZkIg3C0PbReZ05kTplrW182ZWuQQyJgv+RPzF4+9 +5rCe67nJhJrt7hXFRsUScHXNj+HF9Av8WR2RnHTRbpQBJszijM+Xgl+VeYcY5ckB +fk+AfcR9r0Jud4O9795OOWVxWqGVu/b1RGonfjMkGW+JdnZL0vkOYYcHt4iMZmzW +M0ZowZPGO5dFBV7/ZkVzb0fexw+f+E0lUBEK1cx0gxnzjmcGJO+C9if1uIEfwpon +3wBOTDsU7XKDx9v6ibcDMOXrZa+rcJWxgNkXt5nRpozZkddYctBkehGu+snV2g4n +SdOwr0eIVv/L+v4IywZmeWWEVnbSAvB0p7nB89bgLMr9tV0ly7MWxPH+gPnNJ1gE +7Mp3AgN5BxEmLfW3+ou3QLoqnOS2MCw/xcgLP0nJACSPI7/nWy95iKXKgkCkAgF9 +4Ztk7uBG4tiK14KcKq8ToCW2YNliT3g0CWjBLtVPUS6qboudMiuedxTxE8WEirpT +A77nfDNg4MVjl4kP9jhV0Phpn9rDMJ2jw0BqFc1Vou4aNDXYandAFJea44Wce9H+ +qAowcrfsWehD01HBQ2KwWVg3sLnwwBHw0nvbATS41hdxsP2OmCnxWkc= +-----END ENCRYPTED PRIVATE KEY----- +-----BEGIN CERTIFICATE----- +MIIDfzCCAmegAwIBAgIEUFic9zANBgkqhkiG9w0BAQsFADBvMQswCQYDVQQGEwJU +UzETMBEGA1UECBMKVGVzdCBTdGF0ZTESMBAGA1UEBxMJVGVzdCBUb3duMREwDwYD +VQQKEwhUZXN0IG9yZzEQMA4GA1UECxMHVGVzdCBPVTESMBAGA1UEAxMJVGVzdCBV +c2VyMCAXDTE0MDkyMjA5MTExMVoYDzIxMTQwODI5MDkxMTExWjBvMQswCQYDVQQG +EwJUUzETMBEGA1UECBMKVGVzdCBTdGF0ZTESMBAGA1UEBxMJVGVzdCBUb3duMREw +DwYDVQQKEwhUZXN0IG9yZzEQMA4GA1UECxMHVGVzdCBPVTESMBAGA1UEAxMJVGVz +dCBVc2VyMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA+6g5sYzXiNOA +hR7C8wc8buxU/JgcbdHpHIR44iuXjpepBYAE7hRsWM7H4cuXrKiRxS9UMOadqkGF +Qqb5sG6lo2UUhcj4qlN6hKDc/+AMZMIW1mvQldiygCAkqgM8iso+kw56dpVuerG/ +k1nd8f+X9rjXN6/DIMznZcMy2d9ByIFuixFKElPvOWx9q9N4aiueOd5FM5eHxp+3 +F4uCTrpM5zkS7Rmf5GVtCofc8KgaTLLp4D0Ge5VUJm7yW8fuU3eIpin4ivjk+Gye +Q3t0BsrmNyQy3CmKGOBP/vX0+wEMvGN2xqNgAFP9dxA+AbJMiAfsmoWvxXaPktqC +DOspTCFqbwIDAQABoyEwHzAdBgNVHQ4EFgQUILviRCmSrhuLDmF0nus4pv2uu7gw +DQYJKoZIhvcNAQELBQADggEBAGnfGYL7nDm5taDPRxuGGMqUPwRnH2bXwef6S2Xb +/nIEFtNheVFQFtKNn5Ikq68DTFMP06yXLnI7F40+ZiQezRBB1EPPmDL2fYKc9fL1 +SHntu6HLgP/Y5nnCVegtL8l9745gQZnnXlMtkTs2HFwffznIHW/3STO0Bcj0+KMa +p8vebMjmvV7bZEGvrcrVXL55QPZXJwRuQMXJB3f5XhAEH1VqAhTW6DrvBUnuESwo +9fxxA5gmblt80SQYdKr2I08OTk0qmyF8zNuffTOiSS8/V6Cf7CntuPWjSuVf1EVP +MH6KkSjceLZ99Y7bvl7KKvQ4Kj5Bp27PwlRvtYbfCUmQEG8= +-----END CERTIFICATE----- diff --git a/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/certs/certForEncryption.crt b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/certs/certForEncryption.crt new file mode 100644 index 0000000000..9b472214d4 Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/certs/certForEncryption.crt differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/certs/keyForEncryption.pem b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/certs/keyForEncryption.pem new file mode 100644 index 0000000000..068689ceaa --- /dev/null +++ b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/certs/keyForEncryption.pem @@ -0,0 +1,30 @@ +-----BEGIN ENCRYPTED PRIVATE KEY----- +MIIFNTBfBgkqhkiG9w0BBQ0wUjAxBgkqhkiG9w0BBQwwJAQQw74LmQhymYGN8QhZ +NXA6/QICCAAwDAYIKoZIhvcNAgkFADAdBglghkgBZQMEAQIEEAw8/Oa2xvlCpECW +RKztuKUEggTQiWBW4ih3uPsyF3rmJbCU+ipcKTe6NcDEIowHxY1BH0MjvlO7KBaB +Qxg+9mz9yf05lz9CkrPvd8HCjpLa0+v4tzsBq55me6flqYTq8udtVkzCSigPkWkb +35QjCG1FHNUN4Fxc+YlZfbMvCCW2e7uGvANXtAeUNq8oo7bGOJUizdcs8V8CJ0t2 +UtXIYWV72WHznn4qZNcQBtAwFtL8tO/mpan+J0TLbydWu+oK8aDvTwkVs4DQPBp/ +ztEBMPuyJXSoChxzh4IpWlKBJoWkTXZpBZds9zjQ21JV3QeCxqBvAqlY0YBChOMh +HSxGhIuCQlj+44BjFUVYfGYTCulW/qLd+fS/fZGe7PKEoXxA71+uC47oCQMQKZda +XBOqYEGhoXg3XRidPK0yGSkRsSpyhVGgffy5c+ckDW2b9CO3IRAFIqI06QgW9tBt +Wfk30KfhbRADQ08p9zEaEchKUyEZLcAp0b+UHl0ocL1Up/tfygv5atqwvoR/aL3p +lX4yAfDPDIXSY7wF13WPwx8FbebPSd3T2OZQB9q07gjLgkczbRSvq+7muFCFCNPH +mBtyZl8WQqE85yz/jrvkSQG+6TCLgXEJvNxOvw4tmDDvWxW2bKKnij3fUDKHlop5 +6ypojj8jcfFJVUVGbxEdD19mTvnBTSY1Kv1h6D2CEBLzMuYyZaomwWfUD0oGIdfA +ImuI+WhFXcY5GIo0yWPbu1L0HWH9xJObEM9MhNdLm1LIY3rQ0OoNipDAFrLv9jfc +W9Ef9VPklv5lO6HhfAhEQgRvdP9NAY8U66287lioRUuTU9O1MULZETg7Or08JIMP +qIeKYWxrmXEuaS0S6i1Q65WF9ayP5mEragIBiEQpTm5C6BVk3cxv2GVN84HyEdRQ +ekAQyRbZQitzkRGv8Nf30GXlhEz1vgiG2tylfvLmAhL5y4BE51YrrBtoljeLTm59 +2kGSXYUqN5bTlvjk/v/kflRpMNCPzJAMP59dkY0ithoiQJn3VHbRiqB0NwxuRtpM +EpYTkBiItKhlpVA48pX/kfNbk8t7cp5Xo/FFo5gupygYZOJI1LnEQyoGoqR8n8wO +XzyAqzQFyhtAyOkTQMn10x6s2g3mjnYnfify/9oJQstX4Q2UNChwLresxpv/fcDF +rJjG5Qq5kvbZjGsdYcT6O89DGWWTHVPZdKe9MApaw1hb/q8OhueCrVgudZES/A9t +jx0F7TSoEPcm5yTAWCZfdsukI4Vtfj0x653uhFlu4DpRIxw06yLjH+6Sb6abvDoS +LpDs1l/doQI6CJOcPw0uESEAXkj7tWmyCSXxFnG0hor7w5Oaz82hpQcc/mZ09p4O +PqP0QBU/dUzHgSQdhZHDBXY5NT6laEQMMzdnyYdFanxdoinWMY4RvgmjwRFU9rQg +N72sYdZZ8GD0mG3k8ZhSt3rs4+sraDo38BqOFtNGBGE9LMyP8AqQtfbABPl8VAb6 +MrI4tVuUpo/vD68tFfDk2flH36jvmZoAUUgGINn1GFgTJXXC+embg6lHAu3GgeQC +9TOrtNzKjIj7jX3sECgmPEBS+9HymrGhSue9klq0/iptRLIrXWuuB5TtBD5PGG15 +Afn2MfHM5IR8Bls+5khYRtoM5M+TdfkAjvsFUpD1YXehn/aTO2BzquE= +-----END ENCRYPTED PRIVATE KEY----- diff --git a/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/cmp_appendModeTest.pdf b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/cmp_appendModeTest.pdf new file mode 100644 index 0000000000..31dafb6472 Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/cmp_appendModeTest.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/cmp_disableMacInAppendModeTest.pdf b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/cmp_disableMacInAppendModeTest.pdf new file mode 100644 index 0000000000..acd6ea98f1 Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/cmp_disableMacInAppendModeTest.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/cmp_disableMacTest.pdf b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/cmp_disableMacTest.pdf new file mode 100644 index 0000000000..833985f2e5 Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/cmp_disableMacTest.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/cmp_doNotThrowOnValidationTest1.pdf b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/cmp_doNotThrowOnValidationTest1.pdf new file mode 100644 index 0000000000..b1117bb947 Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/cmp_doNotThrowOnValidationTest1.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/cmp_doNotThrowOnValidationTest2.pdf b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/cmp_doNotThrowOnValidationTest2.pdf new file mode 100644 index 0000000000..593d11e8fd Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/cmp_doNotThrowOnValidationTest2.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/cmp_macShouldNotBePreservedTest.pdf b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/cmp_macShouldNotBePreservedTest.pdf new file mode 100644 index 0000000000..079ab91ce5 Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/cmp_macShouldNotBePreservedTest.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/cmp_macShouldNotBePreservedWithEncryptionTest.pdf b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/cmp_macShouldNotBePreservedWithEncryptionTest.pdf new file mode 100644 index 0000000000..c74d7239e3 Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/cmp_macShouldNotBePreservedWithEncryptionTest.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/cmp_preserveEncryptionTest.pdf b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/cmp_preserveEncryptionTest.pdf new file mode 100644 index 0000000000..abefee33ed Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/cmp_preserveEncryptionTest.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/cmp_writerPropertiesTest.pdf b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/cmp_writerPropertiesTest.pdf new file mode 100644 index 0000000000..00f32869cb Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/cmp_writerPropertiesTest.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/invalidMacProtectedDocument.pdf b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/invalidMacProtectedDocument.pdf new file mode 100644 index 0000000000..e88e53f82d Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/invalidMacProtectedDocument.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/invalidPublicKeyMacProtectedDocument.pdf b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/invalidPublicKeyMacProtectedDocument.pdf new file mode 100644 index 0000000000..728bd49ad9 Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/invalidPublicKeyMacProtectedDocument.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/macProtectedDocument.pdf b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/macProtectedDocument.pdf new file mode 100644 index 0000000000..7e180dbf47 Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/macProtectedDocument.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/macProtectedDocumentPdf1_7.pdf b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/macProtectedDocumentPdf1_7.pdf new file mode 100644 index 0000000000..e3410f2fc7 Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/macProtectedDocumentPdf1_7.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/macProtectionStrippedTest.pdf b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/macProtectionStrippedTest.pdf new file mode 100644 index 0000000000..f772dea961 Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/macProtectionStrippedTest.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/noSaltTest.pdf b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/noSaltTest.pdf new file mode 100644 index 0000000000..dcf9bc7117 Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/noSaltTest.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/signedMacProtectedDocWithoutAttribute.pdf b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/signedMacProtectedDocWithoutAttribute.pdf new file mode 100644 index 0000000000..27038d63b0 Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/signedMacProtectedDocWithoutAttribute.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/signedMacProtectedDocument.pdf b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/signedMacProtectedDocument.pdf new file mode 100644 index 0000000000..0f8a456338 Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/signedMacProtectedDocument.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/thirdPartyMacProtectedDocument.pdf b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/thirdPartyMacProtectedDocument.pdf new file mode 100644 index 0000000000..1850292a1a Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/thirdPartyMacProtectedDocument.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/thirdPartyMacProtectedDocumentTampered.pdf b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/thirdPartyMacProtectedDocumentTampered.pdf new file mode 100644 index 0000000000..026b98534e Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/thirdPartyMacProtectedDocumentTampered.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/thirdPartyPublicKeyMacProtectedDocument.pdf b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/thirdPartyPublicKeyMacProtectedDocument.pdf new file mode 100644 index 0000000000..766820a649 Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest/thirdPartyPublicKeyMacProtectedDocument.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/parser/GlyphTextEventListenerTest/test_dec.pdf b/kernel/src/test/resources/com/itextpdf/kernel/parser/GlyphTextEventListenerTest/test_dec.pdf deleted file mode 100644 index 0778c3ccd8..0000000000 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/parser/GlyphTextEventListenerTest/test_dec.pdf and /dev/null differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/parser/LocationExtractionTest/AliceInWonderlandMarked.pdf b/kernel/src/test/resources/com/itextpdf/kernel/parser/LocationExtractionTest/AliceInWonderlandMarked.pdf deleted file mode 100644 index d9d1b7faf2..0000000000 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/parser/LocationExtractionTest/AliceInWonderlandMarked.pdf and /dev/null differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/parser/RegexBasedLocationExtractionStrategyTest/in00.pdf b/kernel/src/test/resources/com/itextpdf/kernel/parser/RegexBasedLocationExtractionStrategyTest/in00.pdf new file mode 100644 index 0000000000..1526edb58c Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/parser/RegexBasedLocationExtractionStrategyTest/in00.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/pdf/PdfActionTest/placeholderTest05.pdf b/kernel/src/test/resources/com/itextpdf/kernel/pdf/PdfActionTest/placeholderTest05.pdf deleted file mode 100644 index da43b2a6d5..0000000000 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/pdf/PdfActionTest/placeholderTest05.pdf and /dev/null differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/pdf/PdfDocumentTest/20000PagesDocument.pdf b/kernel/src/test/resources/com/itextpdf/kernel/pdf/PdfDocumentTest/20000PagesDocument.pdf deleted file mode 100644 index 60261cc670..0000000000 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/pdf/PdfDocumentTest/20000PagesDocument.pdf and /dev/null differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/pdf/PdfDocumentTest/cmp_pdfDocWithAAndUaMetadata.pdf b/kernel/src/test/resources/com/itextpdf/kernel/pdf/PdfDocumentTest/cmp_pdfDocWithAAndUaMetadata.pdf new file mode 100644 index 0000000000..0a3149d4f2 Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/pdf/PdfDocumentTest/cmp_pdfDocWithAAndUaMetadata.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/pdf/PdfDocumentTest/cmp_removedDuplicateInOrderArray.pdf b/kernel/src/test/resources/com/itextpdf/kernel/pdf/PdfDocumentTest/cmp_removedDuplicateInOrderArray.pdf new file mode 100644 index 0000000000..602e3a4c81 Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/pdf/PdfDocumentTest/cmp_removedDuplicateInOrderArray.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/pdf/PdfDocumentTest/cmp_removedNestedDuplicatesInOrderArray.pdf b/kernel/src/test/resources/com/itextpdf/kernel/pdf/PdfDocumentTest/cmp_removedNestedDuplicatesInOrderArray.pdf new file mode 100644 index 0000000000..9da2248dfa Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/pdf/PdfDocumentTest/cmp_removedNestedDuplicatesInOrderArray.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/pdf/PdfDocumentTest/encryptWithPassword.pdf b/kernel/src/test/resources/com/itextpdf/kernel/pdf/PdfDocumentTest/encryptWithPassword.pdf deleted file mode 100644 index bf26b2e4b3..0000000000 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/pdf/PdfDocumentTest/encryptWithPassword.pdf and /dev/null differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/pdf/PdfDocumentTest/removeDuplicatesHasChildInOrderArray.pdf b/kernel/src/test/resources/com/itextpdf/kernel/pdf/PdfDocumentTest/removeDuplicatesHasChildInOrderArray.pdf new file mode 100644 index 0000000000..2fa10d0386 Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/pdf/PdfDocumentTest/removeDuplicatesHasChildInOrderArray.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/pdf/PdfDocumentTest/removeDuplicatesInOrderArray.pdf b/kernel/src/test/resources/com/itextpdf/kernel/pdf/PdfDocumentTest/removeDuplicatesInOrderArray.pdf new file mode 100644 index 0000000000..5afded545d Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/pdf/PdfDocumentTest/removeDuplicatesInOrderArray.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/pdf/PdfDocumentTest/removeNestedDuplicatesHasChildInOrderArray.pdf b/kernel/src/test/resources/com/itextpdf/kernel/pdf/PdfDocumentTest/removeNestedDuplicatesHasChildInOrderArray.pdf new file mode 100644 index 0000000000..754950dda9 Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/pdf/PdfDocumentTest/removeNestedDuplicatesHasChildInOrderArray.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/pdf/PdfDocumentTest/removeNestedDuplicatesInOrderArray.pdf b/kernel/src/test/resources/com/itextpdf/kernel/pdf/PdfDocumentTest/removeNestedDuplicatesInOrderArray.pdf new file mode 100644 index 0000000000..1f43c432c2 Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/pdf/PdfDocumentTest/removeNestedDuplicatesInOrderArray.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/pdf/PdfOutlineTest/pdf_open_parameters.pdf b/kernel/src/test/resources/com/itextpdf/kernel/pdf/PdfOutlineTest/pdf_open_parameters.pdf deleted file mode 100644 index 4a547d99e8..0000000000 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/pdf/PdfOutlineTest/pdf_open_parameters.pdf and /dev/null differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/pdf/PdfPagesTest/veraPDF-A003-a-pass.pdf b/kernel/src/test/resources/com/itextpdf/kernel/pdf/PdfPagesTest/veraPDF-A003-a-pass.pdf deleted file mode 100644 index dd81bde4b6..0000000000 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/pdf/PdfPagesTest/veraPDF-A003-a-pass.pdf and /dev/null differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/pdf/PdfReaderTest/StreamLengthCorrection1.pdf b/kernel/src/test/resources/com/itextpdf/kernel/pdf/PdfReaderTest/StreamLengthCorrection1.pdf deleted file mode 100644 index 8eec21c1fd..0000000000 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/pdf/PdfReaderTest/StreamLengthCorrection1.pdf and /dev/null differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/pdf/PdfReaderTest/StreamLengthCorrection2.pdf b/kernel/src/test/resources/com/itextpdf/kernel/pdf/PdfReaderTest/StreamLengthCorrection2.pdf deleted file mode 100644 index 57a4388c24..0000000000 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/pdf/PdfReaderTest/StreamLengthCorrection2.pdf and /dev/null differ diff --git a/pdfua/src/test/resources/com/itextpdf/pdfua/PdfUATest/cmp_pdfuaOCGPropertiesCheck.pdf b/kernel/src/test/resources/com/itextpdf/kernel/pdf/PdfReaderTest/bothAandUa.pdf similarity index 67% rename from pdfua/src/test/resources/com/itextpdf/pdfua/PdfUATest/cmp_pdfuaOCGPropertiesCheck.pdf rename to kernel/src/test/resources/com/itextpdf/kernel/pdf/PdfReaderTest/bothAandUa.pdf index e90526e6fd..a5703e8d40 100644 Binary files a/pdfua/src/test/resources/com/itextpdf/pdfua/PdfUATest/cmp_pdfuaOCGPropertiesCheck.pdf and b/kernel/src/test/resources/com/itextpdf/kernel/pdf/PdfReaderTest/bothAandUa.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/pdf/PdfReaderTest/incorrectFilePositionInSubsection.pdf b/kernel/src/test/resources/com/itextpdf/kernel/pdf/PdfReaderTest/incorrectFilePositionInSubsection.pdf new file mode 100644 index 0000000000..3e9731b7bb Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/pdf/PdfReaderTest/incorrectFilePositionInSubsection.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/pdf/PdfReaderTest/invalidRefCauseXrefRebuild.pdf b/kernel/src/test/resources/com/itextpdf/kernel/pdf/PdfReaderTest/invalidRefCauseXrefRebuild.pdf new file mode 100644 index 0000000000..c4fed73c02 Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/pdf/PdfReaderTest/invalidRefCauseXrefRebuild.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/pdf/PdfReaderTest/noSubsection.pdf b/kernel/src/test/resources/com/itextpdf/kernel/pdf/PdfReaderTest/noSubsection.pdf new file mode 100644 index 0000000000..c146b9abe2 Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/pdf/PdfReaderTest/noSubsection.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/pdf/PdfType0FontIntegrationTest/cmp_cmapPlatform0PlatEnc3Format4FontTest.pdf b/kernel/src/test/resources/com/itextpdf/kernel/pdf/PdfType0FontIntegrationTest/cmp_cmapPlatform0PlatEnc3Format4FontTest.pdf new file mode 100644 index 0000000000..d6b47d7f6a Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/pdf/PdfType0FontIntegrationTest/cmp_cmapPlatform0PlatEnc3Format4FontTest.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/pdf/PdfType0FontIntegrationTest/cmp_cmapPlatform0PlatEnc3Format6FontTest.pdf b/kernel/src/test/resources/com/itextpdf/kernel/pdf/PdfType0FontIntegrationTest/cmp_cmapPlatform0PlatEnc3Format6FontTest.pdf new file mode 100644 index 0000000000..25f9ffb1a4 Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/pdf/PdfType0FontIntegrationTest/cmp_cmapPlatform0PlatEnc3Format6FontTest.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/ImageMasksTest/Mask.jpg b/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/ImageMasksTest/Mask.jpg deleted file mode 100644 index 2db7edb5f6..0000000000 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/ImageMasksTest/Mask.jpg and /dev/null differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/ImageMasksTest/MatteImage50Percent.jpg b/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/ImageMasksTest/MatteImage50Percent.jpg deleted file mode 100644 index eea6e285a4..0000000000 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/ImageMasksTest/MatteImage50Percent.jpg and /dev/null differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/PdfCanvasInlineImagesTest/cmp_inlineImagePng.pdf b/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/PdfCanvasInlineImagesTest/cmp_inlineImagePng.pdf index 402b81c912..650e266b1b 100644 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/PdfCanvasInlineImagesTest/cmp_inlineImagePng.pdf and b/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/PdfCanvasInlineImagesTest/cmp_inlineImagePng.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/PdfCanvasInlineImagesTest/cmp_inlineImagePngErrorWhileOpen.pdf b/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/PdfCanvasInlineImagesTest/cmp_inlineImagePngErrorWhileOpen.pdf index 42e92c46ad..e61658af19 100644 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/PdfCanvasInlineImagesTest/cmp_inlineImagePngErrorWhileOpen.pdf and b/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/PdfCanvasInlineImagesTest/cmp_inlineImagePngErrorWhileOpen.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/PdfCanvasInlineImagesTest/cmp_inlineImages01.pdf b/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/PdfCanvasInlineImagesTest/cmp_inlineImages01.pdf index 81f42a9149..f7c5bf4899 100644 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/PdfCanvasInlineImagesTest/cmp_inlineImages01.pdf and b/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/PdfCanvasInlineImagesTest/cmp_inlineImages01.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/PdfCanvasInlineImagesTest/cmp_inlineImages02.pdf b/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/PdfCanvasInlineImagesTest/cmp_inlineImages02.pdf index 896fe09ec6..ef51a01173 100644 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/PdfCanvasInlineImagesTest/cmp_inlineImages02.pdf and b/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/PdfCanvasInlineImagesTest/cmp_inlineImages02.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/PdfCanvasInlineImagesTest/cmp_inlineImages03.pdf b/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/PdfCanvasInlineImagesTest/cmp_inlineImages03.pdf index 5d88b57d0d..b00d239486 100644 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/PdfCanvasInlineImagesTest/cmp_inlineImages03.pdf and b/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/PdfCanvasInlineImagesTest/cmp_inlineImages03.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/PdfCanvasTest/cmp_ccittImage01.pdf b/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/PdfCanvasTest/cmp_ccittImage01.pdf deleted file mode 100644 index fb0e1aae56..0000000000 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/PdfCanvasTest/cmp_ccittImage01.pdf and /dev/null differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/PdfCanvasTest/cmp_colorTest03.pdf b/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/PdfCanvasTest/cmp_colorTest03.pdf deleted file mode 100644 index dd276830d9..0000000000 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/PdfCanvasTest/cmp_colorTest03.pdf and /dev/null differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/PdfCanvasTest/cmp_colorTest07.pdf b/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/PdfCanvasTest/cmp_colorTest07.pdf deleted file mode 100644 index f3e15694b2..0000000000 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/PdfCanvasTest/cmp_colorTest07.pdf and /dev/null differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/PdfCanvasTest/cmp_colorTest08.pdf b/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/PdfCanvasTest/cmp_colorTest08.pdf deleted file mode 100644 index 244cde8c04..0000000000 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/PdfCanvasTest/cmp_colorTest08.pdf and /dev/null differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/PdfCanvasTest/cmp_ignorePageRotationForContent.pdf b/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/PdfCanvasTest/cmp_ignorePageRotationForContent.pdf new file mode 100644 index 0000000000..dbad67e477 Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/PdfCanvasTest/cmp_ignorePageRotationForContent.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/PdfCanvasXObjectTest/cmp_addXObjectWithXAndYCoordinateWithMatrixTest.pdf b/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/PdfCanvasXObjectTest/cmp_addXObjectWithXAndYCoordinateWithMatrixTest.pdf deleted file mode 100644 index df1cf5a831..0000000000 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/PdfCanvasXObjectTest/cmp_addXObjectWithXAndYCoordinateWithMatrixTest.pdf and /dev/null differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/parser/InlineImageExtractionTest/inlineImageCalGrayColorSpace.pdf b/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/parser/InlineImageExtractionTest/inlineImageCalGrayColorSpace.pdf new file mode 100644 index 0000000000..9d39eb6b65 Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/parser/InlineImageExtractionTest/inlineImageCalGrayColorSpace.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/parser/InlineImageExtractionTest/inlineImageCalRGBColorSpace.pdf b/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/parser/InlineImageExtractionTest/inlineImageCalRGBColorSpace.pdf new file mode 100644 index 0000000000..053e1b16b8 Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/parser/InlineImageExtractionTest/inlineImageCalRGBColorSpace.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/parser/InlineImageExtractionTest/inlineImageDeviceCMYKColorSpace.pdf b/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/parser/InlineImageExtractionTest/inlineImageDeviceCMYKColorSpace.pdf new file mode 100644 index 0000000000..044dd4ef7e Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/parser/InlineImageExtractionTest/inlineImageDeviceCMYKColorSpace.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/parser/InlineImageExtractionTest/inlineImageDeviceGrayColorSpace.pdf b/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/parser/InlineImageExtractionTest/inlineImageDeviceGrayColorSpace.pdf new file mode 100644 index 0000000000..2e72ec99cf Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/parser/InlineImageExtractionTest/inlineImageDeviceGrayColorSpace.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/parser/InlineImageExtractionTest/inlineImageDeviceNColorSpace.pdf b/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/parser/InlineImageExtractionTest/inlineImageDeviceNColorSpace.pdf new file mode 100644 index 0000000000..a959089193 Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/parser/InlineImageExtractionTest/inlineImageDeviceNColorSpace.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/parser/InlineImageExtractionTest/inlineImageDeviceRGBColorSpace.pdf b/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/parser/InlineImageExtractionTest/inlineImageDeviceRGBColorSpace.pdf new file mode 100644 index 0000000000..a82ab683d9 Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/parser/InlineImageExtractionTest/inlineImageDeviceRGBColorSpace.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/parser/InlineImageExtractionTest/inlineImageICCBasedColorSpace.pdf b/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/parser/InlineImageExtractionTest/inlineImageICCBasedColorSpace.pdf new file mode 100644 index 0000000000..cc8527d711 Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/parser/InlineImageExtractionTest/inlineImageICCBasedColorSpace.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/parser/InlineImageExtractionTest/inlineImageIndexedColorSpace.pdf b/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/parser/InlineImageExtractionTest/inlineImageIndexedColorSpace.pdf new file mode 100644 index 0000000000..308b89da0e Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/parser/InlineImageExtractionTest/inlineImageIndexedColorSpace.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/parser/InlineImageExtractionTest/inlineImageLabColorSpace.pdf b/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/parser/InlineImageExtractionTest/inlineImageLabColorSpace.pdf new file mode 100644 index 0000000000..9f0f4dfb9f Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/parser/InlineImageExtractionTest/inlineImageLabColorSpace.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/parser/InlineImageExtractionTest/inlineImageSeparationColorSpace.pdf b/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/parser/InlineImageExtractionTest/inlineImageSeparationColorSpace.pdf new file mode 100644 index 0000000000..954af2fefe Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/parser/InlineImageExtractionTest/inlineImageSeparationColorSpace.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/parser/InlineImageParsingUtilsTest/cmp_img.dat b/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/parser/InlineImageParsingUtilsTest/cmp_img.dat new file mode 100644 index 0000000000..eed4ff54a0 --- /dev/null +++ b/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/parser/InlineImageParsingUtilsTest/cmp_img.dat @@ -0,0 +1,234 @@ +J3Vsg3$]7K#D>EP:q1$o$N>iL@So+\<\5,G^LL-NjE<[*IE5[a2RJa3-XFkqZF,@n9eVk^VFc'/enm@9:1mM9jS"!dTMEqb2!l#N8#0#toX2(aMbe':>ZE_:<^TriioWjnAY&^gM+`4=1jRLW!YA=M/6)*KS9P +E`kN%="Tc_Aoh+fk'&t\ctIN)4XQLiVpoI(>.nOW?*DmIDOWebB%lA%.Q9k7iBquDi!)/,DC66[a5h8d>eXi0S^6MAH1IXb_>kP+oS^^pnX!PjdJ%0OEX9GI`IODGoc^+5,t$):"t/5eh:9Jl%POR,+@ +`"_L`O_e;>`Y"/@)9.H\bcnd!<%/i[Y`*t?_=A"g+ioftN?cOX9U-pGP&-[:aqBZ0.E[gS=!,Tp[!7W\AU%]<`,c@+1!Gh4biOO78m5==1Mkl+c4c.P3R3haDQ_#7bdP"(1[=9V:_X?B6-tiJ%7AMW9bg+EP\hF2dM.T+5>m:/p3KX>AMl9mPjLV0e.-I+ +;9h$MiB#L(9O0`\PKVQ@^%AEW8QM+YD-PU,c#m=DQ0j!,fG4pM7TNISG>'';n=`\3Q>N1*`,=fY;cL/)X]3i.h-D%%#lTZR=Eb4nESQm4c#_\W:"=CBQYkO)>Oo\eZ9)OOTmPZ5c1L%JpZ[0Wg66Z_J^/G][;ET8mCdbf2gud&iY[\%M;jo*/W8X+c8<7DOn7@"A/F)kOlVc9 +^)3Ge9rW_UOd6EWi=ABl\7;fC2k/tJc?5]@RI5KqkSaqa_.Km.go6f/p6Cg*RVnZ.P.HZTQKjTM?E@`h?=o5]Z1`sVll-GRZ0[r4c*QdV94+j1X)Q\"l2-M&\[hfjm0auaQE.^=g:P\4]pdY6[Q[ns%E%]U:DLk=S8TFgf6efTNuX[jXpsfhcS`t!`K*0qDjmR%^[MUq"i9b( +V]jU`SSqfcp)T3*g%L@P;VEAG)%4`6SaN"$GR)9CiV7X.NR2c*^IGJMX!^]GG3b3)l2%!TXm>j*caE/eQ7nhYXH?a[(jFjjc$Y/Y8_n5u[J@\l>l1/30nrI5r@g2*s$u,,K$Xi86eHe2?pm50OD'3`.#ehkC?13`/g`hCM%ekW9o;e+&1]-B=Tc<>Kb82T.F?BWiFFU#:Vn!h=76T);l"]Cl3bGMV]4Wc;2u&?-q?8a'&]:(O&>p4,e6EJR58t$Dg@nPFUfd3[gC4%QZZ/2mn@M!L*=8E0+>M6rbo!?HAt;Pg@F!Pa +-RLtXUI7F[c\\2^kS0tk'TOHc$;Af\,k7Oc)6K0C92"JS0qh);(/Xd56t7e^::+$::?`!QBh]Y?P\Q9/)Su+\9M.S#P# +nRLp>Og7M]Y.o;!=6gReVmKd&=3Ea3%.0[o;)lnU4&&mbql$mqY#O,<2/=>rCUOq_f/:0QCQ?/sV)R3o#s(Uj'5Tc(JAFje.r],,@">?eX^ia(ER&/Nr*1?WLZ($;Xljp4-Ea)CF"M$FjBia5n'ENVb+Z54tdgrGCqTu8t&24!oC +=[-S=2@6ut-O*(f`Ii,_"i9t'=KXb77P@3=_Xrl^5kbE009.3Od0I7JqCsq1.B/E@1&?)ob]u"CjNsK(690K%Nj>A(t^VEV!M/Gj>dE4G.cM?+OWWZR0-4SJMq,-+L6F'P1NKnSr$8`RdHY.;PcBo)o'5\VAMlN6.LBAj"/D/Tlkb6Z^DVeBoV-+dgP_ql;U +AT'[K]l_iL_OEPKmqCmkTJHok>RtZl+`kKdD[GB'2\Lgn*PkLE.2R>^9PuH&A+qV<:&/[9A__jO[%?aI'5Ml64WhBu2;mR7>CBp#pm1_L<3O\Q&Lu`Cc1lk:*.7*uF5D>kq>g'L>n?E_q`k?MT3H-u=LlgqdL>P-fKl=eM=hHOpGmU'>hIGX4KoQL?5 +hb386?d,SK[tO]DTCr25h>>AKSc&35pO5=7-b1dIrnfs9qEN4'O5U'lb4Q6VOKV\J.iJMO'_`i8$]lA%E$4>iI-=2.)\!ooLW&CCP5,6P*'"Rt4U_jDn3M[b]#"7SY\0M)d/9X:m!f+:nhcs5uN!t)n*$aC-Kd0Mn=[dqf^&MY:50>Q2!9bHC>&Fh==:n#Rh>5aL('(J*k&N]rq-PTE+__@rDaZU?=d0gOV$5$JUnR,AD^<&!@FQ@HT&TJ9_O;:]=%8\2X +J`?E3UDH:^A-!tn&FBtrLCZ(1%r/]eXjI[@ZOh#t)Nb[K0sFG.<+_)=&WguOEPVJ!,2J2@*$R6Z1!oI<6O;&%`UV\'1#R0$hZe&.qN9"N.0TZ!h]D<)'T`h3dH_i.i>,o<$no[b5dMUgLcE5_+gHFgOQ[4<,p?c[T]!F"%XT'imhq3W)9Qq;#h'\\=W5T',`o,N;GdU[mh)`8 +-'A!Lmctj/2&rmG,r0;P;:cKo2]\'&-LqB_E/>\mK-h4Co.a)5Eemr)=HLp9.?])u1'fTi$ta"t7;?-3Z5*VL[3>%k%YJj<&h#a()?j"m*`=j+&ifZl4JFSrP7g;0E`DO+9aWYJ*AR@9cNPs7P:pdD-;\t7Oi&fVitF%,-ZX=uZNV`IHQLUgoWn8;On/p9q(^s>.<5ABO^Bgt +4XqZg.V9AX.]=8K_?.NX1pXY.nE:ch;.D6K^DkS416[\3d!HC"V]PG\.M@9RkjT7$^3P(o0"NicmYSL1iA@2nf\HoWZD./5-n?NMZOR@@3[R=petkl'%WTdg6bf\7e;#Q +F:SU4b7aE#33laJF2($raN7C/&oqbRF#Q/)F[JpW3]&PtEsX78SKJUm&Q9o&n>es^.j*6Z4#BGpn:s-d%51X0/7QE(JB]o]],2$G"*Ar]oRTNjSOdhi!l38UoRf[jk=:U\if$RRN\7UBhW%?i2`(k(Ec"G@[7bVP9<-#[dg[T[]hE@67?]qVdU)n%a\?m19si_NkF53d+gY'&k>HFO;R>OX2).V=GRi5\#1Yk81kSA\I6Y(:8ee"Y/SM]Ek>,sC>BLQnl?-,Toi:SA,m$"u2/-,K[jKU2qUA]('m)RgAQX)27Z^VMl4*O^?'p+KVX@:KnS>F$44p5`HZ;/%lE>jo!r +U::q=V)2SXC:3):odO6iJf2#-?K6iq5uV-5qY%>rlEs>ciU(#f,@tuJ4Yu6SU.--rG>]Tj28Q")p@&oBol"8YDkUl`iFd*g"_p>&.5qYa!C:]LHkA:T%2U%)i;msX+*)QB&L)X0TgNen%efW#F125/iGsU&K5Yr'FJ5=6+h/KC40W)Utj\5Fa&%T +GIN!EQ@4!:Km7fuGdiZWpQ9\InTKt]@PrWr!o,>ZE#c+DDrG@V!c)h^,S,k6Hag\8i:[Zt`)BaY%=l3@ngk-7e-Ym&IC+_8^k$qnjaMF;#<1uR=7Lc!om[UW"IK(:p\rn/PQTP=J@40Cp^r'-jp)^eJ[abJQm$megM3CZ!Pl5i`nuCkf6fjQ%p1uIpd'Ql]5h%Tn.!b7/PZ_h`>#Bc(/afKVp9*Hn^ko'*+-ahN]mV2BMsMR]dGpp#`#0ISokMkYWB#.&!n_0,k4GUFs\Q?FOIX;Vr.)0jtZ=%.Ge4`d;mNjglb_)[Q#LQ?]TC*>*\Qq.b`"cs;B&Xa%T)#,Lp%?BG29=X/(:'MM971NBlNIddG +\M85lef5OKN/JUA2!8SnE:m\O%XCc*@/Z?KZ'AbVCK,k03!W!^2f)O7l'BLNG0a.]e=@B-q1ROhTrKFW;@gRbR%TM-o!ARn6^`10F#X)G@$-m#_jYg6'D\^I3O)*(nTgC(3k'!2D7t89Fdc^T#arm?g!Q*:6?;j="P=N=[#PSME"WsQ5'aZ9P3kAc>^bRfT=O-4i4]H-"FVCS +RAn/U@"Y.41QPt4TsP#!es2'N]7r?UU816]H81#&#GY^]USqj@g*<(uZ\^L,M.U100-6RG<#S\*HJ$,G`i*#Wg_k1c%m"PO^k\g5dKM<["8XQ_UP&^crW\gJJcM/H\ri(>r[AXVPP-#%cjHdU81U,3#I?p\Thgr>Z'Eh&R,F#r\oJ(%BpPoYQL:SW/S18_J!Zu!)g^9d\1+>e +I_ID;TceuT@=buFJ#Ls=)#K;'[+U[6-`UX\N/b"t@\Oce[;,QK82tu,[X))\J#&e6JOe\H'`J,AgSL?o*=p?0A([8E]n@ZS>&,X`sE[5M$t_onj>=es'BV%au>)egia>\5t67:FT^pe2;CCW1ZJk;VrCr*a1/]t$Jo>p?Qir,FQ6YI]!\]!R$L+ZY9DRMOYi]?Z2E%\^!6$+u,D +_ZI41);^r5b-net])/\['J/3ibFh/Er2)M&06!2?^_3RsGCo&V^'#Fn55CC]S)oI\5V%1Mc+NC'qgRbp)FjSU/0$N(Ho[f2d>?Uj21.j$ge"@Dou,h:VSMbCr9k'K[="N#;>$UL=DK]SmmoOSG<`ir#1<>b!&u$(V'%dQ*bSi6Tf: +8%sSqFLs-U_k!_b"]mh1@6n,MqKLR1$spHi_:X[Q4@g+KMB^hC,*@*c?>r@-;8%EkL0CSqrh+#>jX,of7;egI'#H(ot&+rrYPCbnsPssqDoHmWTnPcJ[!U48CRahnZpftT^u).Pr3,V)[\n5gBb``7hnQDp!H_[(b+4K4WV>bS7rP%8ps#E:C4nD`f:9tEQ&(hR+ +#mGrI+4-BS/f>+Q_;Z%DPX2&Z$Us(fR+-"6*KN_O&fDCD8K1f(hbokAY$!?C9BHkbbg'o[Rk3_'\^Zpj4eGO6'H.\rM++1:kX"K4(7@(Y;s'/;Ptn;VLK3XTRakjOr3'2g()n!G<0":_/JagTA3k'Vg[5jsQ-SW4G?sYRS(6rrRD2qp(`Pe#$$a&?nJ;Fj0,]biA+B"MPLCtG +b@U8_=0?E-S^1s@)BAA+8Pml7gH(HdY6D&[C\A\fQH1eg?>]>`*S0\)^#*c'*$*a3M6l5^q%H"XS'I)[A[uHH-=YCAK:c+R7`;KYm6>3f9@[/4,:@ +jcgPF3Q:>_SHEjG>8K`s\4[\s-Hl=7Wj0D?%7bEt\:Hu0!m$Ua&gUl_M,HXu,r%/aikA"TJV,CBd:g!>0[adC\$?Y-]#HKqRklcmCt\+$9_1VBHcF1$eMd^HKW-t,F/*(6KZ>A/pdETlq`d,-[0&J:D3-VB*4/,dRnrZdUBj`dH;u-s'I>8&;X*D%9es(U3deDTO\&5GFX9YO +"I2C1F]6G9!ehR(;9RoBNV4el^Z63XDb4jhEQ@,#\d]3`Q-V4VJ0_l_*.*YQtj-s^W9d'9acc>faKfk-qTDR=7KUq2<9V5P??tb,WB$)Mfd9>E&U?i' +)cR?>9p]GZ2.r1ODOk.%./B-4NjkD\HO*jH%>bHsLj"KI+EfY\TijD0>,O-_d#"T6HD4!$]sc(_U2+Mo]q@]<:9's$4!i4"Ynq$#]SG6R`1e-=LG:(2?e`E]J7)UD#lbW%#2R+7BeiGPBtQqKQB"(?$!;sFL,Hq[RIqV=o'0%7a)cR)13)p]S(j6.>j"c#7R8N_d+-Jb +9T\Q7G:*T8]qoqV_Kn6fXs&5=NNi*2/5+YFeXqEQ@98+qkA)Q>GNU-bT]pSEEBDi0*XFn5\#F='Ga^K/A+6;?K5ZUkG<((jYV1@QX>$di=c4 +7Yn2R_Y"*O@?\l[M!=*?GG>F9q9'2N.2A2)[.t>Uh/+]N84*A.)5:(s0!C[k5)7RRT3LYUn$qNdaKZ@%dXr;IFq2L`qCH+j>=JY91I*q8T:l#5HNPlU7eDXs`r'n/m-'h:(uZN7P7.h\>j4%X,mMJmBoR'M*>U%s6".]g6c<.-_P\)B,#Dm4;H3OEGqcQo\Yb+cg)H+;)'R/m +eckW1"U$8N\`+#k*Tc4&b5#HsAX'Ne!p3]TJ7gK9[&f,-jsWY4`t]\+pm@6\@NFF[s.m$F5(QaI7ohO"SkYY#fBYG>Vl8._K\7Nl8,&+Ug+!+'tKF(?Ak +eErI*/e_'E]c>&i'+Ip*\\ptd/La[MQ32`*7RUr@$\YOWPh)=&601jUeN9[np7A,ab>;pg6`=UWF](F]PP=QP<[)m9?QFQs3SeVc[^LA#bULM(.FpWsM[L*0@b7f(/kL/!6*at;,5Sd*fi5Z*)4UJ)CDNl"p4A=NY!JnGWe;L20Nl".2eF!)?)G`X@keM8`KhVVQ6I;j'=3iEc+j'6>Y=Cj`aZo9h9M*%DClBR@?QW;".]:>!W.ns\'+\+%nS?PJ9-2'+MiG!M31WB/;eQTDk#X_Tc2+kl1tCAB(P\k?G->tm>.pZr;8(\UmB_72Qa5qK)J^N1S1M%$Xtd;l>G4NNRBscJ.N9O)CXBo'eRIgqAQ1d=SN(H,.a!eRjun]]p(P`Q(o/@=,%n4mAbd[4I^J=0G(]8\b$)0&TjTJoFnM_9B)/"8sSA +2F0^Jq7`tF]*KbWieiW65C;P#MiMf/6qUS3Y4!1Foo6+O@!P]b5C%n%GlJqS4,9$jSla)n:F#"Lf:/rs((!T0?d(EP14adB^@Q4ec;']fkJ"B%SQd\Th[`)c=0o(>?OM6#JBU_n4l,cJF)#QLLM],eWP\AtrLN,N"b<]V.*k4E#PjkTDO*2HfR +mh@r7l0=mjn-:n5VSLm_Im)K%hC!s*I),sYO%&paO8BA"h4U5CJK)ui]4\f-RQWa%]hq9F1Y4m:YIXG5\d?tOUVn=dJ#oe)]>5A9dUGoK&"-:0K7"U$;> +pj4Z8Q(V@[XR$o]X=F_g!2,Iu^af%C3X%Z',f!QNV[;(mKJu/XYs>#35dJA4@Z:K^.4aI9#J8k3j5:jO1:?r^#2DO/4;3Kl'WG%HLLP_*R]V,(FMs(L.@_9T]Gdpe)oCg`W]3>`lo_?$,=MtuZ[3i^'#qe-R?jco7/3CSEQbd@R^T4\(t&,0>ZNA&:4t)G_YDHlapCDg_8Od_ +3C;c$C*Z7-]#-9&_qZMm]NIU)5.tD:`f]LQJ?ZqRd_hfu046EPls$LR3(F8#2cTa@[JP:5"A438i7E:@48!nG>X10As?Ur;@[*^0Gkf>4$?l/C-K62\fQo2rE431*L86gm?CkkQ/Le*%X8=YQ.XG]W^N(D-m!qHYKCl_*nIuN0E%)cGT]EKWb&#"gWg5Xi`IhA8;(%"*Rt\BClh.SRtkOeeD/ +/B\\@ZV:^NL"t*A'*uancV48"[UcKe1Z8HNS-fC!8bC?N%*kjmR]L1B:#+C$A:ao*d7t!%8dqDX7,^a!T2$*!9O+Jj<9F[SWM#KUaaDg$`2pD;Xig;'$#Hh='XC1BiC0aM5TJiNWA%*tSkaW2"Hj)'[(M^KElU!J#N8r&RL+W-r(J*I-%s1^m!-`I=IdMZ'V*5nPfZUd`ltOL +WZ5#4f[S0UHHrJ4c?uG4+C1^0e4CA)6-E_/WAQ!C)9qB_[f*)Xs$;;E9jm2i(M(K(SH[j;AS1u]XBU.u-h.GZ2ir8o/V-I*=hTNpa'FU8J`la=ClcJ:)XeJ97&Z%[S2c3s4cV".Df:X;0\#F+m=3XJ5SpQ<\pbMbsJ;IptK +h$#A.:Y9j:ofjck`6:fOU-Ul;KLsCHIaC@":fQ/K)"7RV#6rEY;RjltN1SD'k*$4(btQ;T>0b6hM2!l"$67[F2$MAoTZtW[eI!QUZD#^[92M@R!JO]"RhSk]Us_:-dS/%e>rG^$QVr,Gec_r"RKZTh?dP&h`>_ku4YG%90;"dhdi>`t8dD2%'*V&QJ9+gTOAtbj<,GSJ/QF:)?s(ZSO\Jp(Q%@@]SCO8Lf@fJoQqK;>eZ&pU]u82:PYsp0=TpWbCo5X7a3!_:+.\j"eOiuV+PG#1-l&:"ue/-4KncJ)?_>A=K!ICRX`IGFu`\sQ`,d%__#^KtbV>RGo7*Q$Sog>'oMgg-&tD3EdV>p*-R9atuBrKeXloh"8iT+0*#"fSo*6.R7KIB$-*<2?1m+(mGQ2WGH55&,"8>766TZ87:'MlWZC8q +Pg3K-JDQgEfJS=]h76Wns0<#Q?LX]#3HNW^MV,5drh*A#`s(h,!\k4mLEP%&)d\nLKV\!atb6j,"LR9>8;Obc6+SP(8+tMhMrH-Af9?H)Q![l +@9j?ul\u:(HN=m'$928O/k=n1ngE!4Tme5d%OC&XT&4+B!oC\OW8iS@@_)_SJM:Qdj5TIPfPKna%PcleYb1nN_8\=Z[KY].-=Crf@"p]"ONL@U+!E@0;/fJY7D8sI5L\a[i:o$>.P`B-;7)N&7&3GA4u`tj8>&s%c@+:)@=8=1Hm1pIk(RYMN@T]`J7TS)"%IlA?7O6K +RgeYOYd,Ne^g/Q>Bhp@.$sn+ZrK/4lMuqQEBULK+rf81ic\ER!koQ!RQt,AA,\X?@/G]Z0XNF]e-Kn18`ca&QAt'9LB5,Kl2oo%`iI(p=TN8Z@k?als/0^aPOUPi<$G&\@K+=QDV1?`kk7)TI*NRD)118[UC+bZ_2"KDpGb=t\c?3K.p51<5LM,"&6*@D!I3R+O'PJ&RAI2@L +jJ1I1Koo,bkJEd*0R2h7^a[!UTU(Q'$<7nnNs,HD*<*ilDT?HNA"]5)kq5G>@Kl"8a(t(IBS?e)5#5c@S/#Q-Bt7"'aCcVo56YZ>/c4;R^7oIh`+h#c+J,Bf?DX)?7$N3BmFhlR80/^6%cI&];tujdRPFp3jD*Oom%puLSXPM7Yb.etc;q7:1>ck>(h_UglYbm%m*FF66#2RW +/RH%W^:ZoNL*;;,Ct>4q?GgRt"mdk^CdsJYQB:QYr+N7SC)3u,(<[h$bYUp%jCZ\N72+bL:[J1BD'%+=B%(Ta5B"]5m;=ecNnA<\\a>P)l:"lk?S1Q.&4;DSCMdcF*)sk1td\9X:IIl1qfH'QQbq:_COK7e4Bu +o>K5PTml\(*p[d2Omdl*DjJE3VT!J^`cB*S0n0(oP`Gi`(t;UdTDnoVpB!2V\*uPl9kBh]=\j!L#*8K`TDm@3)'s6r"i)2gF;j$#-DR5?g4t_"nHNhAEj(2&,Y;V^A-WfP]c_lH1+^`flK45sj@ee@#p>QS>brb:hR%:f([fbXo^q3YN6d**=P!AOE3]37n<3CEHJ=+K"$1R,l@c-:$u?enX!;HV]-]g;:Y%kp'R8Va&MU/f +2>On7H-,ROhY(AR3.&pj0R'40?_[BU4aKV=qH#EG63$QnVsT7_qOae^O*Qc4b3oZ5FLgs[&$XO\*X+;S44CmB?Pn#0MH"em<7q]$;om:o]?\c[sa8145bqI,,p&"83^!5cu!5EIkmRY.>r"0(@ca4Po_8iW##f9E.-sjd;,V\gSY1(,q_opMM&B%EaSq4d6 +4'jL-;'\R@Sg=5B'Lkci`u;pZ]Q"pn`]SMaa31_T+NI*%>o+!V4F\Wu;I#U2+i@QXLX"R/h'9_+p;d@u188F&*1X8S_o"D8K]^W`ZPMGstcdVgk`h-3N#Y*1iSIhBRe61TsdFO9U/"/0e.;rDHtcCCulS*EReK(f?[rQq*"p-M-NR/m?!SR;&N;Ef[&3,BZB`C>m3;CS/lF;NKJL!bKoQdWn*LTfb7T<<)bGSP@6Orh""=[GhmS7kd),8^#(*'GMVR_8E6iDJDaNJGRWNIp(1Ng8%'7]iRiT&LuMO..>QlL^+kP6R,/,X9GK-(OO=ZUV2iL^:.:E/=^<+q +AXQsKR,lW:#,fd-^2ZDN=krg=:m;g#T]U5[9;:PD'e,s,FN0`GZslLuTuLQEWDVQ^,u88;XpnO55BA-fVeZ)I`EO->oIt9%<@qdaD9hWf\Esc.V7Op>FOp/RIrJUXR5?()D9+b\>p!5#]ResJ +=S>kB0oG\WO(mD.R+[nZ178#3cI'0MI+Ghh;`WfI5#7H>Gnd,b8,00c#-m>4]^MG=DOpFJj+l=W[K/&?9c\'M.5p[#*k8G&ba-)Lri=GQ5I2clLD+Jt:(=\#!Jpf7S'b3/)@/UFLp7(-J8caM"=sT7iK&nQJjn@32CJM1b?L'\j`/DZ6H%uZ3F3Vc +]t?]LAIQT^229K7*(-*9%:PbiLX=HiT@d=JQp=t_ME01t\;(^U4&cQ^H71LlD\U7(\p#dt-5;esRpK%3M^9h4]_BLBhIL,TO.=Q[(qrn>WFC2d]YH\?jIY&oqAKt&23jh!*mG[7N=R3*8/"`FA0cFQB^fNH85s2.]5N0H.ROn_qRC'>["'o"Ud.HZOPn;c%aof"'HrYgeL;aT +0ru>:Qn70+l+C+PE9b:(6;_.sn<1*4YsN/::Z4tsKp(k352f3ii]F)DDQ#Ti)3iA&J0f$Z;;9'&Bbi%#>B=]i02/Zs(g]UBI&:e"7X4oF@oV/0OgK>Q$.N<,S8sXcQq^=bIfog0iLFa35u3\68d5^p."YKM8?$Q3,\q:[oD2%Z.L)@f]`%u\Bi6kB>,hrI/>CSr("&;f_M-d- +JOQjPPj)B1AV&9q;u0\E\JHlq<5!sJreFDf"pufPkbcfDcV/SK9W@$.Da7_RMA`)*k*$[OP:C>p\@R-%Ph]tOg2Ke)^HKfrjdaeoFj?u?p>`)^X453LrVJ9PB(PJFlP[Mi.`sK/J?fL5eq0(tK_oAK[d*N`XY49Pg\n +.BbE(Q:r3&#jI%ZZc[Y`g),p]m2E@"(4Oa\0h6!D)]#BRBoYncR-EDmfpbu%Ut.T'<9g;\RoNq!`qm.;USofTeAt9fR`AP>ok(bMlKD9c#@&gnF'=j[F'!I=A^&C.T@NTm;(DX%aUi3V6AkCg5dPds>o5(6Hm?YgbMZ5&\QcG$!SD%t9SBQDqYa;XLdG!!(.orNbkHs2EE +)mna8b9m&S9rUgV3%"mfg`M2gSe]-;B+6IT,+32&/#nX%7@QU/N)P>P6_da/j4)_'5?tMKU(oD!c8U%>PoHqR%I4BaWKt(ph6_I$P?fibQu`\nc$A:/QsuHjF<6*g=4k]c6E?nPkg>-^:`S`:4/d9CV:6QISB;>.>9S'//[WH'talr[IW^m_smeqXK2?(QaVk2*$bV*U)lRK=KJ!Jd$n'-.9\*-l;+9h:9p$V4#meHLp\iOR^dA.Tq/6R-jlf8GUT#b'a8[qi=4K5mmZ[7XWN]dZ7K?DuTi)[#fhop1&pPYAP(NEd^`,)DDs0!kA"+h"X[$m&u@D_/0\qSi=0iq3+E1BrGeqo:bq!haG(UmjWC#K"LYlr9nHf'nB8;D00i#6sa5r;L0HriVLBcg[%Bo^f9]oIt%4 +TQ:K,I1),bXNsr?Yd"U'H;:0nbA\YnDNP!7me9M&$uk&Nn2CHR4P_\V:S@e"$J69dpB9ta&&UF=Yl_<5pCNEm?Edl[0P:k,Ym0AO#;5*DBpS$57$`6#qmS'0.=&#/ICU)o-+=0d&?@DXT-Z`ZbU,f$31^7W#[ET!6ejP&R>fRCDW)XP].oV`gm1YFUeuD +:CuaVOR,bnP8T6g"OWhSN<^!aVDE/=Zf$l`&If$M_YY_R(m)cMVN1s*,ohd>)%k150VDu"ruHq@#B;e1E=c4@QC^pB*AL0-O\Q)m;S@">'p64u9]cL/$4P9L(<>M(&T5N!F!)#L$kaWucYX+EE=J![%FQ1"Oc3'*OUeT\67a/[C1IYA7iq-d)NasL90X[&bpA<6qXM)a0teeC +1E7`K#:\l+5ZK1/8KC8h*f.,(6+87:QD-)trW.,<;=#i2nJ'=<'a`t::>[/aAq?#?SrJgEEj?P1[SmeO\^8.n18t625qJ(-Q4VE2:t6C0Ri$1b!HL"NE]Dkdm"%d]Z%29gYb1"(;oO$$;PBeRRQ*.]CaMZ"k65q*?+'Q<4b +LH?STp^8hSA5E(VkY;9P_9fqP:FDQnm29Vpd6(FSF5AgsY7<;!_#p)Qf,\0/Fh+EN'lWNjTC^&G$&:o*H!b%60DS0d]rQ_$rLur"Kgf1'a:(7RCc2Y*(6u1Fp@);d5j"ZiX7pq!3&$l[c3Da6S<(7k#BsJECPf`-pb=)nsXh<%$kia#:+48l*Ui#@77#c$:saqN@ZnbdS\Ij7I"=e[%fNJF>Ph>!0_C21nO/DUJ$O13jX4$'7bJpof.'#kEIkY'KRsY*DMdQ9o$JFM9R:LPsf_:8?bqlX&(f3 +&>&LMQNF!PeBH2]^JKacjorhJ.JsF9(/djTC!EfBciao^k.?UI84s(`1p&:Q/P,*Vjj^AG_)G=n"K/85"UgJ+d:du/=&kMii!3W=_c!N/'L?_GD(T+qSR:TK +?oA-cp'G@]f_PSOF>b:Bp)e)c?Xd'EfV_)Gd^N]e:Lf^FD:UjdbQhZ'$"RNRACaC.^rid8*AeA)A[D4Re`aCT$"f0c]9UE`XQQMReQF'ULG'f@o!Q"m7aCA+kh2RRNsGpbjW!nPD#_aS_aaPHSkbj\dNf$d^BQWP$VD:a8>p>L2< +4`4a)DRSqMoq?%+fdT5E&%;Kf72kg!;/6jlB!XZqIq,WpX;]r`H.p&1Y4lhpI*lfX`ULsFSATgpJlPi@l:]%Cj*d@F]WCgp9c@.G?3=?(_^$S=b)ip+@R:\G"6g7fYpK[L=TF$f:_!>*7Fp(^i1lt'!E!6MJe=&gpa.`IHEEO^"le!Vpb^EQ*8^d/^i;;d/N\W0&t;\n +r:i(2=[SEM;1#'U'tI):`8b?^F9?1\HW@f8@%9<-YXE1'DM2)h8d:*I,;dAM]_*@oO:lI]/VG=eh"6Q$9b,Rb72!Fg`,aBq(O&Ram=aF^(@.M4?KAQa"5fB?>`_SWQ8X%QWCJPLks+5EpHA*R<`]@,%;V1;A%;Sln2hU"\9^l_'[SE4C3PoE_)> +9mpmCLku6MqBD5FScmGSn+gUEpmir2EF7@oRolY[iRs+QQH=YGOEs^!$PK=7Z4_G>Mj_JN$'go]_eU-\UWMR.H?5NhK:9?kGT!`R=gaa1L)i='=BWgIHAl!1O]AtZT2"U0H.Pbng+eW;Xc_6Hq<)\M%8WfCU;0m=&@;[&q/H-fT@s;kg'=[If<'[>PbQa2(egRE]F9NtI#7G@ +J]s0_5*g.[(&BPd2^"JFop41*UR%mVl'8%^c_P9>)nR2B2R06JB3K%ZSsin)RZXHrK;Np\VQ4kkH(Kk=EY*P?Ql:=N<]R)bK;_t1S"!:r>:(A;@CB=,WQ3Ph):^_*q\_rgH_u;&"U>g$;0T9:Xf9>>Zr4\WjP0@UCmK%(&,V4rDmoPD]%WdLR6G.RJu2bJH2Fa$oK\W`_n;6% +S1L\;=s=aSY'h8*])+mJmTm9/@AWX$AI7Gc=;APsB=0YM@ChH5GNHOE=qFpWAX*phThi)O-_$,^_V?f^"Lb13>Jcml_qL$W*(..rpTf/$;Yh;CP2c8KHB,Uh:m#uhTn;d9WPWQi6TIDIp]*PB%;r#-,O*a]m3_u!`W*.Qn-Mt +>csRNdE>]QC2)6"X;8T?;,>pZtRq8L#uC&j?tM$3-H"fU%h1UaCLnWV5id#n(-f*I&A_En; +g$+jIf7D0cqoq\$VkB=<*OF$+Cn=qGS,L/=r_e8Pb%5rDR[&H\&S^'LfI)(T>CMe$*TbS;l(#I6dKW_/>ppeC/0@6-,RW2W*XCVZ`:EKr/;m@N$IGdLS8 +TWO..k?<;gM.c#)XlpZ^gf\`khM>`LNMiA1l5l;=?.tq,hs)3]l3U52ktE,OrOL[i;[Ak!Bu9[\dBZ4WgPn55ot9J=&'&nK!D.5"kFUp=R37i.@!NeP/hCO@53_bk*&rThJRq94/\:qo^Ri*S5AF6=u8B<8T`DFPhL7Cd8?lBlBN]=?B86kjofg3#Yume[>;`"u-FI%EQIt!$iGlD5mP=NQrpb9*^TX!Ylh:DW_-lc">W*JoM1&k'R)ET#\WP!Ei[bME^G2/#cYhFk +p4#B%d:i0@>lEtcWRMnFR8%k>,_aocF^&(qCN6o@DY#&8p;;HtMPiG&D'dYn.(aMFSDJHSU!`(D\t*-(gJ`:F,!2;IpO4/YnTD1O.84g--uJgtrndsp\4QLA5*GobV/c>+IeX;#o@!\)/p^tD5EIZF/AWiY(3R:S.5_Arn<1(p6EY/4OWK[/6ceoY/*_X?=NY0Pj>S`m#^7f-X4jQn^Q?Z]fXZ5-qWalV"S4H;)YkFT./T<"lGu[4UJN6oV7H!@BdZjR@?9Bmd<\;REd*85h)L$D5M"aELHXPPGki:='*j!=0E?71$Z# +\YiP.9cZ3c5:+9O2S[5E04$mu[;d0P,0[:!6-1Ap9ir"G.W.kE,#'Q,$ZnmM:^-Nq&u5/X#8GmsA6j&FscO'f;O"F*nSVdD0[X;)>=cN)CCcmU5(bPhH]0-lYU7Y>e7lh;T:L%nBM6/d7VS +1p/WnA>aQ4Ss^JI#.&.&$)B9)XU7-9Im93Z)V4a!0-/k+*a48'EiO''LEOfH+gAY#njfBpOk_tr^H=7%off7)Jd42#T<3t?rE7]D^1n6JafHb;6QIIsCCE]ra&]@Y((`#Uo](4kn$G,43^'@aqBEk#1'_+cIpT?_DZi4mW&qH$/WB$I="e4p"a4Th("EpJ=!fs>sh +FcCB"gh"hJl,\(^nlFkf=f5fCk_%c/huqn7;Y!;*j31^'5!lUtqRn1<4',aX?`82Jp8RG[>/)&cCS(sEYJpMh)6ka*iLf_O1)Cd[D;U5WqL9q'/+A#Q3.ZS`d@Uh;r)#m>#B3Kd"VkLO!D:f](b<_HY7dT/Qg<^K/Bpm>7k4gC':<3'BZ<5L*+X^b-Zi-j'cKSuD*cB!KVlCQ +6T8CYiG0BUMCoa0LN"TsF'*e:"lHs,!t*j6SL+g&*L&h,'3YGcj+@K'&k6=cqGB??EGr4G^A->X`?]YZ`#sb(;DOI]bArCAU,'d+.f]\\!b]pmMSO4+!p"CnE0;W.5mSb>b&L=?lY\P`#W/Ddj;r?'Je5dBoGJr3Os^=J +EcV6i+G$ITp!)/)Fslp$\r$=Pe/LtuW^`\.DaAP:H-%q9j_/ahtbKfQ+g#[i%L&T"%%PPm@pUg[0+NZcD'XVrJ>>=(,jLW8C6*#fl<,SAII&Ts3XhmDtuEV`A*B`^@D,jLK>+p(Ps)'e?"A'C7b"uu%'"Bm@khrg7I#Rd'Vs`8nLB5fC*lFq>kjkG??\\X[/6B\66[)o4O8L\)ATTP)g4DSIog.e9/$Hom^c35UG4+IG6T,rHfU=O)'-ir:=&=X)qtXf?Cb)k<)&D.')a$M/FP+ebqs=o8r&'Jh1n<%A1pClM[+cDXH0:-bShuqhgFQikhik=!cn?eDXJAhdT]sVQ]kM&B)17XUoTU5D_mug]%^U\Xg)6eSif*4=2R[QJN)1JV9^HV8ApSY>20%gXaM@;@7G;?s.=qHNA3f#?:.(@:kK8pBaP``K'I[)P[:N\F^jP:_1i7=s&^PO/\otSBE8hnY\U&8>[:`.'QY>e90@3GZ$Hj6-_:R&Rd]T-,Qa(VV.i322u^b[ACfc+ORahD?R_To.QjI!pb"AX96S<=WmRVf^GpF"pRh(!LXAG.%N>:)5nC]+*I>J&NheV;p)_9-HTu63ICH]ZT"!O&^No9>crg&`"GV(Bb9=Rna7Xp$h2S%oTaSXbq@q96"cmZr6jM?@+(sth^UNlbpYYljL[fgXamKk6FU59ft!Mgp9KP7e7E+,fYniU@aL:e/#Mphc15J^;6_.4=tF;McH'u&`H_5&!cZl?j"*5U,D^FUG>aIP$,4h_UR_BIYGlfSTP%72TlT+M3aMglp2NJ@'S[s/@cd3h/Bq2%@" +6K3\&/2+cjqNeWu/;u1`dN6:o1rE9M_dR(CF>q*j308eO6_lc:l/_q$R=f$5^c7Q';KSl@"uV$fQf/FD1K;/YlbKNJ5e6P-F_CO<*t^=5=Q>NLL`W88sR=, +[D6i'Mei[;5YX53'e*:A7\je=Ztm\"CrXtA`oM$W_ltXV:Ic*k5m$Sp]M'-/E^s):7prGeoMA%oGfPp7`@4rJcm2-"H,n9j`F-2BJNT>K---_t*<7a\Ub)mGG_#.7Vc5._Qu>$J4@XF@aIo;]P`*O,@k!pY\Qc\cA-bRar=j?eaK1P^dgX8B91M;P^Vl=-E/)DY4\:$hae4O3 +WKIY;>6=GcaY\I'Ck%JE=t1Y17fpsO7"`QGPlco@W)QlP`/'Vhjp'&$8t_#pA?3en#K-[t8E7k6o2K5npdEPH4h%e&DO%&%pRiZrG5icj`65c/dWu9Y^s>_'VHC5H#[-dMIJVdS*c-L,A%k;--@,kEV:m:%X<0W2WJ5F@JAXbj*&7>d-p13"3$!9f2.W0Gi&$"i1&$9lYH2I.trD:sG[":Q5.]%,@:R]UE[66KbhNNq2Md%;<""i_a4aXEDdLFdH^[+n?EOXK>j%UhDV+!X<1B<&uI'\@V">+-76_/eiJ>cGW!NQ1JW$']dHic0ZVA3iJ9/mUK9\.=7+f4C(I0l#BpKn!2$C!t'b4F)sdl(hI&>$-c=S].8'LhbX4M3e[/g+kuhi(M_DOBC4Z=RD.W)k:)H +*SD`B>0X44rKN>iQJJEBq?I#^`3:8\eNg<<:o.@#I#j@7gc=cUfp#aDb`@1V%PVI!p!"MbZV/`6"$P)=KUiQ@\$h_Sgdho'<Yg>TIZS2;KF5TEuWXgi[Vl +KufF@WnmcjgprX*?0@+,c46rc!sRm,FjX.A>_bK0JJIUZJRi%\eMg#I?QtoW^fi2R`!3'N?EpNJ`70P?gfc<'Te%\)p"n>tD;V&<-6in&h2TFrL!QGPYMBiE1,REl4nh`h/3I`XmAj+=>.je?WHUQ'1'iWQ%MOk?suH4*[?JQ#`c7;@R37e`?6JO'JkAY%B^5MSE>P]R@&]qLH;#^%POdM(?0$mYM^e?=l/+T0q,51;-L55OVcuR2&'I#;@mhVaL#=nCLAb:$A6EW>$5?t-=SDkj:2l5;!Nl!1?9l'id+[sONcaep+S!OW?l(924Q+/'e,MLAE*W\Lg&4R +7?B29jX'q]P<\)&;&?Rb.$`\$;.UJ`I>*L]M`s8#Aj,26^uOp+aEj`bQ<01Q6&k#7?`!!%Uo@i6@LqF+2YD525#e`8dU^'^k&tM%XkBZR0':U_N@fTk;"-fRo=es);-!h=.NY6m[q`d;@6Nf,ksl/kQOJB6pYB5.=ekTSD8`35/@^`U[#l%P6o@2.kOe/cD37oK7RFKs%l*e4bk.L$,OOatMcTi<6Ga[n%Y&4-$Ca'gUQ(@2piJe,B+b5DID5aCl,JN;?82+DOK2GY0,`2aFoT`mb5Scii`oJhWHUp!uDTOn@3Yphsnrn%QDPcJ.a&`_@QoE[M%[($BSEDK%Bn0[B+g0&c;5]P=UjKHm/Y +pBp8b$gOlID$#f>G7MT=onR4[>('4W;2?\&,h/+LD)W_sR9)p1[16geO&$\cE/*QjO(lYK[a/8h@;Cp!70K#j&li]g9)&aD`&:?:480Yf;f5LX[l.(o"57>QKr,W?BsLH5r)4)n\*!SO8LOQU]V>49=H +Dq:GWLoCPZAA;e.l1UbA:*XnH>BFcjioXB22[%?rF*+(IBWK(XL/W3G$ZtONKO8c$NIH!d%s&Rm*+C_;I;&1KagcN[86)jDHHOW6gsc3q&h;82j=&-PkeCGq.H#hD%q8N +R/*):q59\W\!Vd!SGCd-q<+@FpRh9eTGA?;qBr$62l$4>V#"/hqIc]%GGk:mW;;j[qPU@i\#]AGX*YT=joKhR\%DOX]_gC@;ur?,*>^eg84@#f?B5j?$^_;rU91Rp[A+enG>l<>pqMH1r@!e;076]=qA:GEkqg[H%\(uP3r;YC+H-??+5_'oK8N7p.%*O;biD/$92B<G%6DV:Of*]O#MX]B/SSJ&#H2=?IP[%/.VKEEKkc-0pV!44!9rHKUF]uIj[p?2iCj'#GVUaM3ghq=?^#o';^Yj'THWP[VM9"[kpfn7=0:gGI`M2/uVcSl"lum_]]oIBsamXJ%?9]cd\``U2F?X&E\)$NDB0KZeVpjW!omVBrD>u!Ys1f0Rpu]@g/.D]Pcm/bm6',n'#IZOS@&S,LF7kq;b*lns$-OE*Me%GO`CUB=T0=#Da]WdQXUqe\)],N9D%!h-]99STpH-$St]ct[a/BoupYuK6330(Yuo>!%Zf'#NNS#\Ko'?aB1\IZ=24\uXDrB\ekAA^d^%.+DmcnoQq$;T*0.lgL,X9R$:e87';bk-7C92\W?>^"#J'hqWW'hbH$-"D/"(M;fM(*pi>odGSl='aiL\'K6EP36jC@iqT*.MU]/sF'ZhS&_g[Rd>gbfAMp!-QK2/.++.2A +eWXQIRE>,7kDT;6C$6>7YG']0lJHl!H;9_]A'dZd$0c\f!D6cZAj**Y%5s=%?hai39l%?KbG/m4f#7%Cm`oBbl+!=a[agjoXgIM\#1j.K(pmXIj>htn^ZsRugQ5nb"A>$3R5Rp[6sN4uO`C;1A%U^J5&Hdlq:1n)kF)=#BkUZjXeP0nhWrY`%;uDl@TP2Henr&0("DM31M*od +PCCj6k.<9oGkW6%B?E+1?44;gf,bOTG[>17i\fRe?+nf$D[X[6*m,Yj>[/NRm6j'[=iFtP"?l8qS+e0!83Varb?4\_1X/Mhje'k?o"RQ>9:[ENm@JD#Fmj;72"p5$)JcWe0F(l&SJu(TW/+8^3ZIj+F]du\L_:/Ua4/]_cD6+;E8D\A\9/qQlS+Il.1sV.bn1XX7Yq^(,paCr'22A$M?Zg)0A+;dAO:X'`qh8F +Qk7-JFab*fdtCLBP^PFd^CTE*8r_nQ"X>_9K5Hp*b<$FZR-.?:hMt2P/dbR8lV$gtcqMJ-R/OemB)5C/KN`"L0)Q8?54gZ,j +7;+$\jk4LH8eC[!qFaK>`6"kjbk+O$h$If%;bour8Od]-;G*1!VD=fYP5bGG'K=6g#u9GE)Delp=$lU>MM7tP(qWmm^-@euq'Kt>k3b5^;b&mr$^IMV5E53qlkYI3Z4=B"BjVr_Bm<\DBogDsejKorZA3lG,.%&,8Wm]J-b +]">o^Aks^oZkK0g=.:jWkuFUFerJp5s2u9HAc7orto) +^@`7\AK/#GMC3hIda,M\@@Qq>^MTRY%B,nf0^;k"!`81*#6=-cPg:e!5<:K%`\.GRTE/dNDs2._)Np^fSeKk1-P!FR4c21/7Fb5L/G\Zmj9r.rh!tABu"q:!or$>JhjHS_2BBXAm?L4YiQ#)WLF:XPi7A'G&`h0;\.sTVhhT),fJ5#'OmPuMXbQ1\l[bRk%tR$lW-)E +GinR1Xpaj:R3ookLFj!]X>b6" +ep',nn6/2^2ACDfBp2lmQqP?,LCDh'f&'pQjg&sQbEKOsB2;Gkfdch\]0V7R_V/'LLfbZ0=/E2e(TaF+76O%\)0s@kC*Vjm^mt6jaLFX3IZn,rV#i%*c$qO'u'1LS(MthXl;Gi9W\MPB)U+MpVai*&g*2*IUC@qs$u>P?a'0PhoI+Y +J=Z[+X835hloDi$&o8oQUCn0A5M-j/ri!miY(+ADrGNru'V"6$'Z/B%-538A"1):21o0N8T[=:B.R#r#`l0Ot>`BEW9j"0cbI0QdV>Glo0V#OlO4?s#iO5>+Vb<%kS6Ck$18;\",I`^W"'B?#S=3C&@Dan1CKjc +$fJQ(+[lfKCo-*q%,hF#+H[+P2?_BO"*!3)?s3nVkRk&d$/r6WO%;,0&/enB&+E[45f""Ned2mu#9ZqW0S9T13sW#2#Co5U0S0JU-jT8o#iM?bEAS8i3=2qZ[_ci!O[L!?8/2_2!$[X?O3S@-=TK+?!9&DC,?,D_Bbg/T(@cA\0m*KU0H)0>)3KIdDo`nqLdCAi5!d"&+UoTW#CoAa0KKL0Q4UmC)X96?a"[4(Pau:[W_pSP0uY,Hi:eZcM9K4rjLDs=o_NR`*V&(=/'=R1h",==*lSX,m[deUi_]#8*KgFG.fR1\"X()[+R1Mln^Se')'Q:++n=(%&cV8HaW7,61a+.i0]`o;3?tgm,P",G1.;9F0dNEI,iKOc+i>U93;(6%rrL=SP%>*.7jbNY-Lu.( ++d"-gM'33')=i:`P(b8;G71'"-:%>_146:r.\A6L*-.](@5ofg:F`Z,.e9hH0YR`8U^XJr*E']qAb;\X#T3-W$NP`.0Q[M^fbP`[?S]^1bRckRE=ah^"*2pEnrYI(e:&$8Y`Y(g!AuQ?aX32$0_0#aEtf&s(_r5T09:]K!Rif5O;25p%WY;MEpk^r3@?N/&7\ZjP<1UB8Mmac +0u6sf_*'Ys3#^7O+/7bhTf4lKZih#F&V2Gk.iTY*q_tj02o=euMhrCiqCiN'3:i7+$0^c;G4!^#g26('F/:#jY,kR"3qKU<1(>F+[6!^,40uaH1TJqTIlqJ\3V/o`'@AsW8AmM9nm4>.Q6nc18i]0_%=8E(R21Us&rq^]!37MMO$E7uF"oG_nR?]lt^Z`Y+/\HTdh5np(f0JF'&a?Ggn9N9D61-ZP*=u2$3'D16>JZhgi^sjM(:@nf(2"WQ0p.J>6:\02u +:D5R[*SPgriUYU#qW*Gs`0!o4%\P?4$/-PS6P2*emN.ONLj#8CJW25O@(Q6'o%-"4[t+OgJc\QJNK0(eQBZM:]2ZS-i;>kDA@d*?$kT?+&EiG%#!+BX5$'B!Rh'[W,'MWkT9;7+PVbokRFtDcJVQ]s*2R@4A01.XDZ=>?qp=2bl&HP22+h#\2FF4j3;/Wha=S*jCdWQK9'g"3P'@bA9pB>2E.:)4!'LA]1PbT,Eq"h$8+MhD=f'c[JGB0s=)3$d.asS;F-645bF8%%O((Xgr[<+?%.lJBqp*!0e&Pcc(QiD)UES3dH]fOd=2en*aaCO\Ha4`?lgPQHflZs_,9\@KeZ>M;]m\J:=Z=O_Ep_.A14_)idWJb=15@=L=Vt6#hR$*l"%"\'nS#f.%#M5=1]+5'5,)\7H9H;DV;0 +Fd!>Yf3l=XSH>%NG(;Ci(klJoFs".]GKYtj!qBgqKfM)K*7rMMPGnU24eBXLi#pVgiJbDiruME&j(GLXA%08=WX)B_U$!QQ=+^7rDEO8/*EfC=e-*\pSp&bU?6&n)tD#@8!&O>X^(pdQ&7.lpTb=*JNiGU[rrM[pYU=*>g@C;^[o +8WjgL&XXk&2`46#rriFo#(T^d,L3RL!8bZ[P-[#0L^7bFl20XZrFblB.M"m*h=I-KWRo&mPMADnC=-JQj$].37h2Uh4:nDNZ$'*H-j9uNLm\!@'udC3;J#;r@aT-9j%^k$Q(t@?_FffOSKbtW]^[!s'+.GLJtG` +TRBma\,u?TH!%YP_#pHTO.SF#X2.B'3ZD2pl3.m')f+%S\N:,f-jAd+Y+)^6"2WI9n?$H2Br2ZiXX^K%Y1IC'[R/UBqm1/U/d71qD"1k2DdI!UU?qnpCVs5UF=br/%\(G!A.bB9ejIi\bf8=gIVB#;A!=$]&9?q0bOXHdC'rlK^(HS&qgOVaf_*N]_g$-UZk03 +ah8YL^%_I[)[jA!l+Gt`^A(-56g0V>ruZ9#_rr$=NFh6PbXN4+kN'cX9&=EF>n`2?,DlgJ*:@5EH&`qMP63;]=`)DjAb\Pb@CH7L[!4d)f=FjioTd!L2]jdOs\W]b^\*IlZ3cc-mC +PYou^>0g6?NH[:G4a^Jf,dF>*5MASZ`Dc$SVME0SeYJtRTej`M;(MtD8/An_au.d,S?^!iQc*eUfa7,!;Ur"FHeu7R$o6?h4gg_N`Ckc-6@a4:3Ji[sEMttZ1pYaUgqdbgNJt(:1LR]NRnFK4+`0Q7-/P>BMumi24#]"Q!XDZ1Fk7?bddOTZll$pNc^FTugl6Ij +3RIaBW4ll=Zl?c$%paFq*57!"]hQN?QTk2&eL6FA4]dJ"Q.=\t*5/?*]rWs%Z0K'*lMe'S5.0^$f>83_NOG$O5.L!o^$C-Fm/GBrg`A0kf6j0bmJ<7mhV7H>UVX\3mf)_r?C\#ZoC'5\m[i065,CI6[k1R>$/X*p2.m%8V3CK^r1:W+HNu8+&b%t^RUMgj8QKlJ-;qA*fkN:P4hlY+:kCb%LE;k6(]iu<%]$tL;"iBGa(rP +'oPN?:MA6q3?=/Nj:W='':IA<:E,lgA5jEdnqBE&dH$MV7,EhrVc2jq)O4'O(op*cFaDP4W?JCqlkUMaL,!2D=mZ`EKs'*G[p/8:)jS_5DhhWe&?Dr$q0]R,lrD^"Es3L"iPO6;<\G>M`g604>V.TO>K:=H(t5p2BgQZLo/[l.:J"3D +A@3>H<-J?VC?rb6*>Zs6dG%*K)kEkP.tOk^1/bR$%sQ"4)0lj#?S7r2k70NmDCJM`3h[)]*A#&T\Jm9tqcJs;O.>9lFgVm)GH\oB?2N]rJcE1uUe/nmbqI\tBP[VhO981P]d\NO!sW^3prnZ#A-A)9n:S^i_+_Y4$QW'^*=YATj-7A*YbN%%`,(m!&#A:q;\63H6s?KQ$>GD9 +2B]XH_hKKpEYc]8=RdIWC[0W&aDrPa+eOocP9ie@A=.eenq4\LUJA`@o\g]1trokjdTZ\(4jYC.>eMp'u%cEA7EACNOn_Z/P9^W*eD#Ip=Or]:aY"A]1We^KGENU0gZoGG[C&B#alQ3j<\5$7pZ9&;l%t+`.jXI+EPhQAfDAS[M21tiU91P'Lc"a>'*4-H9uo;iXSb*f,B-qbGp +&OsrZ>pPB^1u91FBR2"`UF*=5.raOKSrWoDg)bgEC2.k`67ilEIB+Srg$Pn;QUY8*8DZ"_aS./'!6spA6(_\p"KXVilO`Xb@&,mEas&GAgPY9I0HR3>1!e`Nea/mg)Td/qJi@/7L*E,&tPlLG'(36G)lp" +jb4Tj^')L.VM"&ibSEB1*$ffW_0b?ZhLmbAi\;a-V.mHM6XaJ,kB*A[hZR![%;>>`P`HF\':28CQeNm"hh7hrrb*(j/T!>230*i"kPP9Dns7^*!NSr@@ACU`i;TBJ;JWCW[Pjrdf+R[VJd$_46$CQPMp*#Sn5]g_-RMh4H5(6KaJFj::p>nZH6b*4;n(qd!o]9C0C&WRK4o3q +9%]noLo_-)p(UMlj)&7YOarJ"r2IR*9870?,D$c*Y_.=%F@:i2+[poOKTo\,6OGJ3Lfj>,J7sms[0[mP:rks1m69jLBb"*UY`:t[9[=-8\3\@M_"to(@G%E]V4\#9;36;@('1s9W5R^0Y*!Com4ji1;d_$o*"l:#!Yc=TUss=1VEsgfPn**4[Cq?A,a\nMX`%=;qCf>TPIN:pNc/LfL,/b>D0A]?J:41.s_?2)(!n6<:$_`cTss@;[c]pfs`UJe".:bd7lucjH[K.h]1qYg.gZ$>5MP&TcMH3@K_.`Ou(h%$4gk<:1`>'#InHhC=ZoY(E%'*f]\8m63OT9Ok=Y*Agd6!TVlMkg:oS-h;8uEFDCC^r)t1eU8*M +fh,9WngS%jQT9l70VtU%-*L$Ad('rYb)n*7cYc:<=`Qua,st+1MPCe#b_T-fk[e\4;'^EZqkZ]YPt^=Q&F!Gm+e:HjQ$0>X8g6sj_b?tF3j@0B!ErqOCP#QjeP.KR>>sp0Xp&QR=*"+:dcG^N("BH^6W#_%jOe3Y/T!$]\RK1H*h4siI+G1s=t/_["BJPJQA7SY6"QOW"Br4\ +27b&6'^>ipNlW3^r9oW$m'W-1NmZ>?:'ge:$g4r]7!Gfq$$-586JC'b*4OsVBobB-<,R\+qi9!Si*d#,\_lVb?<>,l^@W\mDJ^C%!d/("d+.K6I*X9!ij'bYD.''7;_EmUjK_R0(pVp$(8"7,JYR2,_4 +@59KC0[XmTA1nCjHn\U&")]h&^rX"eQ7d/T_@>/+f+H1FE3+KuJXBPd3e2I4_nJ2d#T.PXj:j$u'qV$(mZWf!eWNrK8I\eKjj+5cY_GVG`T1ph*nt3qXmibb6?b(eS%),CW'`_@^G@V7kAUs'10s'j0rui-*,\eI-DS17/C6A\L44IsiEnf#.[P\NjYg'5AclWHThcNEjJVAK +MQC7D5u:Gl5=7u8<0Sh0jT:4:og8M])t/5/b#cKWkq9`=@A(#/X2%ggQrZ5\!m<^UmrkfouPt,XZ,Ht)D+J0s'_&l;Ue;@P*=B?>,j\dsp:o,6jg>/D;)pg4&\Zn,(@6FgCd#-/8^+,5"=V"T"&f),`gW$@>N^8()]a`p'$Q;f%Jfe9[H[;>i6YFR;\(nF'PqI<2JkY-6IS(Lufs@BoN4dFq,h=kMOYJp!+0gj>B/m[_tAGCJl54-s(1 +7u"s9cILiCc[T%`j26"j\`-X(m1Qhe_0GtOr6Cs77==/J1SOE=`a>3;6N>AUDU8g*'#J"./'*$Z)BSiT_ED?gSX7VO&.r7"94ARh+JGLsC;4*LHPF*4e.el[hm&`9\#`@J;R!O3W;2//=,/FFnXm9sbmn.P[UJ^WrV+S'Ie2t=XfHHTn(H@?A;'EJKSB_5OArdL"Tr,j4;lu@ +$-921s*j.X5M&:&M%cVk"/D9Z]K!l#"._u'f[#_bK2-'6$c!j"m(=C+CQ%6pWb5Jt#re"AqkrkJ8r5R[ZZ4/Kju0#1Fa74_@aA-P<+$q(dk6Ln/GA*uDe;+6mB5h&t$A.LB\'fol%7I4AMr*ViYVT%;"6"&qCFBaQ?DoPm"`bAj$ +GWEAT`.m=9]P>'u9BMYc(5$TAZ,1cGZ(8$upu8'r.4u`1[aW\3.OM9KD`> +5NGQPCek\>@&6hc8$l4;4JYSA]Y?!%`E\TjS>Vi-=?^P(8h=Ml[&Z8V>d)q)7F\$Rr3/g&Ttq.6_-7P6Uj`AkD9H1m95M(1I(2h.\P%i0L-Sa3]I8E2&51\b,eG-fPT,kb7foVV9J"(T4N'oe`CsKO9PhaCI)o!?a\85Gb?OFu\qZ7`'nl5)2'`[C:lVt%(D0k2b3NOB*7P`8 +kQ/W']#2dI=^_B%fh*s/8&5*od4L&/h%3PtKiF($(l#pN-kBu(:+GIqgss+e9"JDIc=p],?m/6[V^si,`^Hdifu/T53=\H>:'Bf3g^V@nK#f1@4$8f4+^mJAFU)V$JS>9XC,a87ou*r%`4VXroU`W6T:^M(P)QXY`:'O=V,/06:b8Qd*3;CVWQsl$cQho$XT64T"ON*9T<#E4 +g_A*5%8bjj:rNdRMnVhEbY]An()2Ha6tt%#'iA)t2q6$6ZeGU+(!$17bk'&jO@R^?'nGZm(fRn**9N"/@0/S9:nnNJ8Q3_;7_OJ0OJLYEdmsK[.1^)?d]D?QBSAdoj$%bu7PNjnHW&$i@8a$PdPCcUV)/r%[*lH`dqV&Th$-GF!74s":D?mW4K'257*0.A]EgZ!q%^4):9a)S +&>Ygfe=Fq/Thj>fcft7%laP>!VpI:n<3-8GA5tn.3_:n.;p5]tKh57no2Q3*:p^b[ohs:nue!C52_&@J.pK?'nca".^[O6M2bBj%Zsj^B"]RV]<)#e7V+)>n7iB!@'`ohe]5H,+Qc=]tVog:^3N@S-;7di^Pl0iM +E@nN$G?2V=f$Lp-i:b:0%0fP8-rCT./N\a'NQ@L\Jb?W)]ibg#G;%Y%L&k]b28EDs7b5+Kf$/c$bJm#R\5L!I=rY:['^O99\C`BcO^#)HSK\+q"T[)u4ih:tAVgrZME?docc(g='o^eqNJH=jf_(?^IFq$&JlNct>]g'PQ,VE.Q!>!b=`*".h3]\*R9gVt?7k2+m@7A9=P%,Z +hIt`D]/\LM;VMblDccq#qi?93]Bt%rK"\e\8=n,i`R'[BdCXPLh*'7n8:FiJ<7pS9?&fk4^#)c6 +*5+NE]/AAA?'@C):gdeKiSGaaA`0G.iSmktibg,*`T45ISR0Sk%GZH^+ALk<,N7pgg+Fl7pu:/be-I!FQ4[t@*ND3.i=T477h)H/`NG>/YMqNrhhW-,R($G$m9dG**M?"VlJGt9#.u)JOHG6)-(W,#$F&q$Prg=&TSDBE(#XcM@$sg7i(mbC9hMiH4"_!%"s;W[b#@DT3cTjD +q&9`))S1'ZEI +"QkI&]2?KnG@$D?5T5l>@25]m>JVY3N])49h9tO_Q">\Q)1Gb'IMh3_UZf^dBs(oIjUUCY]4o0nl.&==k*o!ZT0'c\l0]Dp*gnLJ!U<Xs30=W'C84W2dd*$#_J%Y+iP-@0B'JCC[!'*f^ss]2#%,ClB%naPH)D7ql;`D6B23p8H+4cQA1hmI&k7[\-IJd(>=rm(Ls"g^?faWlL*G'C::sg(%9e7mboX/R8_R"C2N+sjh:7#4Q10T.p&ji\?jC,juQQp +[3%!kf"ppi'Cu._=PfV:J:2I1%!i"4.@=)q%]2#3YI'915QR:QoFL^2!-o3LAI0qa"[i3>a>s0!bVb$^Bfgk$&CXALf6)1GkTBh%(gPIgMfLMl2"Q_&Su6ok?1aRDcDM> +i!+$U8*8hTi),dT)"F4Yo4Kj@`uKb%qp=JqD+P'[$b<^>&;8)E7JBoD(F;Za-MLb=Edp'PY<$i&H$>kBn`LkcY8_Z!SF[8;DPo=7[7>HErp!!&l=bnl/XN:6`Qst@(IO_?Q"$m(pn"b+-q=YC3nJf'fd/"bb*;3-LCPOMTH-c^t@6T0UF)QVQhU*'%dWX4_m6;&'nHE(m[p"YP&5XSJGd[9),S0'[`:nG%]UiuTKm6r^GON:nq4.:\@.PT?r"8dQ,bb,p^a3(#Eqb'qQD+3EIrfPAr3+:h-\gte(9C;fp^=[DTi9C$&Vupg +Gf^;;hO=6*UpPoS&>AXl_'p*M2@u\%H!^X7Z#Q(TBF*KGaAe,-8"5nYcbV?S\iO[W1CHgW6'cc0BJdpgTm'o^S.+eFHAki:rB3miTkB;KZ8pL:EDQ\W%_+8L6PCu'85?C:NSg13WfcOQZuIbsB,,Y8VQIt%I)A3E+i,?u?Un-ZaV5u:f(#/SZ6+U+LBS1+f^d(D!46VuL$oW+&n5nLt3*(^d;8gI*T/WX,eogLJ&pD:hC'*t,I +B[gf46cp*[*N7?GJKW$3*/LK4dQEVS/-1\.[#9iIDNB_hS,T\,`@CGlb+Q'>91EbC2MiLh(hGJ;iagF^_o:]i/V:qMi8_jdXQ_YZ1VCI7$o?\o8PdT?(BVA3>mT.4jZO1FPI+S&M$S3MQMiT%RuWB@:]$TJKll,*>uT4r6HG'@EALM)ki'uic-=Tu0qT!se=adbqHZ$D&!U]& +^@/u3LRpC$ar*#[2CdcdE!K +`Yn4^kFeYb`c1ZN.<(cPc,r4drD@geel8(La^Sc[p,g%rH(rPp$*ObODk'b=N%]OnH:A.L?Z;'S%eF*me>T6%I9M`!Pn20*Fil(S2s4OnHe:e`USO_MoN0D%hS8kW +@!q`Th=OKfdrBHiUcc9l2ePH$VqeM7eepCt7aJ>ejpuFam\Oq@l0u>tO3-L`UVG1GY3'PEU:bA[L6<#GSDBut^63[`Rc!#(Z$)mi_EVSd-QjXf?OfZe'd>u6KM2hG#&SaaG0Y,"\CZ>JD@@R?[g(cB*-B6Z4i.nfh-hQTKZH=&_O+=1TM-qkd(U>a(hF,uZIO\fiYt7-XU\dh +4bqCe+>#R#;IU%sL2dtS7$s5Piabc?d68s;[IFLJF/TJNZ6>o-E>I#F+V/?ks1<=_&DY3$6N\Mh-K-0fb%t[2`EAZf?qc'eP]_iE2<,#(g]c`rjH%]NbFI);#:(P2+#)6Y";qo'hWScoK/uOE0_$FJ0hrdq?2#7fI4!+,6'EZfpb.1I.+<,PPf'M#8-^9RKS"(tTRl\[8'i:* +Eh\br:/rPVP7LKc%"ZdB-5hikVE9_UB)#=a\Hr[hYXU5=096>fG>`O^e`&PV]9]:F,WN:\q.5PWh"OH*gSi"VjbL:5hjZQo/R;r;t1g7F6^>pV5P5FV_qF[(VNa?7e\8O:.O>b.]lgL.hRlj>qd*_Xg7A#DTjlt-Z4CYJS'fh@ri4p:s"0.qZWdMNO(aHW6\_muk[;H=TSek@P<\Kr7*rrliU7q_<=;g!*jm$'$[<>qG\V.-O'ZDMR[es>p<-Z_;5EOEqa.DSN$L<]UR^Ouh?-F%8n72j0'I*k.XP@Y\X^d^.pGD!UJtP$mU#QPa?:7`H2c&&\)[gb6OBoh1%s'$0^FVKif9^6.Js]edHb8m7\t6&!euaO4C0(B9u*TL$YVPRfImaSYpirlUmsAp]8E[Uk0)oA?!p/mJS/iBK5S9!YrgH.($BVt_n9bDqj@KPWT/&H +Hs[K_=#]O4cR7_9"SFY[cQA'(K=Y4N,`[FK;(c9-:[b`WcmEqt5+UB=5RLa0n_^Lg*mfW*4Ud/3b?]s/D= +hJdEujr]&c;1Iaqr@b>@7(QCC-G_*D]rh"RaB[%!kka>*Fhq7NWBS\4.':fK!t+,^Y-a;kK"PfV[$)EmtBI0;TU-d]EZ!47egR,>iFO0pK&(r]+@%KgY25X#Jr6[$6P4'"B;m(!kfQUDb=&A?WNm/B9-Pn-nKb[`103iEi2cA&)lfD<11p&s,#s33-P7IN&!nIh??`'( +Ak(:7@4<)"M^ZNI+#2-rTt(Af_c#AE;WfZqlRlrh0%0>E;YMi-q^umK.['rg6HT]-$K861s+*.Sk@9"lc/fphD\?a7"EX2tm1'5PY1QssY'8JB:N28q/1t*^1ZK;S%RlAff0i7g#aHC7LR4l[`\H,bj_&YV$Y!Nc,2$gjt1;c5!8/!1WBam5S^bbT#XqT&O;p.\\Rn;,%8ee$Re)O&"X%Lgh54l$O<4>MZ%-hqQ9E6Y'P[s@W-VQ>t8#.4]oZp6q'1**8-5%CpZ_9@a>:jnt6^(di`MVR5&KjiH/TaZZF)rp(//mha +:33#O;f+1)@`[(5+B3D6P]f[+dm%kl*&Af^iJg$CN&#L:Xn7rZ;SPl492sG;<>9jRPuC\J>!^ZEcnl=O^(Z'&=lH!Ei;'bLIIlcA=or^43O:/TiI+omo>jCFXkr?5)j-_\H,W +X]0H3/6-=i$%&X5((:7@]iR-2/CoMJ#a%0S)bK#7F:QgsmDoB*mMIbSFG'U.$)qZ>nSB"KFr+XAG-c?nCL&G*G1UeZ6nT$U:!9!)e=*]7a*"d[G?>N0=;J]]Bn;Wmd5JUg(ai\0VZrjB%4*&$?pfR4JQF)g#+.ak96q00_AZ>M]@S/1=BBTGRP)(96$Q[K(S<93#.qn)bu`RaLu_N, +=]9K44dWN6(V'&!4OtY$M$')sJ4!t&04hPt:j-81KdNH'dKqn:LK"bl/A-sN,8#Nm8uP^te:8@/)iVdJ2iih#kiI,TDgsOgIq-N9e=(%&XpH>=]U+9Yorgs^$V<;g<*1T2=U0MF*KZ[!DO;`4)&H8_'p4n+433VIA13MTaL=HiXKkG2YBl,J]d@.H%Cnij=\"^:'9f@]U^.5> +O^u">*l4WS"@3N005Z'\tM_7V5,$/?eVW_>.:1DYq;ETT,PDE1]mFgRrl=/\9c8]&Bb0je:Dm<]]WO>5'QdnLV9IXP3WW<2Hf; +qlk.rYe(RR>8OQ58[.d3Z+;ftoA?i7A$U5OZF_omgFi'o2*@?gZkM]14$u*a4g`s>[2W$q4%TN9@4rI9t,JM]+W`*)mcUBVn:]u]GducLekZEhn49q]XrI%oBX(OgRanc=o5D: +)s6-A\%\$I^"`.n>PF3umV\NiYWMe7gY9MJ&\o@sO?URCY/&L'p_]1JM>W9Qj42]i<`#M._>Xu`&9>oU]`>hgq>Z\n7>K,B)`Z/L.>\D'HCW>.J`uK0@>^+5YHcOoka;fiR>_gCjMoa\7aW-Md>aNR&S&sHXarI2!>c5`7X305$b8dk3>dqnH]?B!E +bT+OE>fY'YbKSbfboG3W>h@5jgWeO2c5bli>j'D&ld";ScQ)Q&>kcR7qp4'tclE58>mJ`I$dd]?d2`nJ>o1nZ)q!I`dN'R\>pn'k/(36,diC6n>rU6'44E"Me/^p+>tLhP:efA8O?"_`ZCY%<[f,\qa?$FnkHe7)'fH#Us?&.('MqHjHfc?:0?'j68 +S(ZVig)ZsB?)QDIX4lC5gE!WT?+8RZ]A)/Vg`=;f?,t`kbM:q"h&Xu#?.[o'gYL]ChAtY5?0C(8le^Idh];=G?2*6Iqqp60i#W!Y?3fD[$fKkPi>rZk?5MRl)r]WqiZ9?(?74a(/)oD=iuU#:?8po946,0^j;p\L?:X(J9B=r*jW7@^?NO^KjrS$p?>&DlCZaJlk8n^- +??bS(Hfs78kT5B??AIa9Ms0#YkoQ&Q?C0oJS*Ae%l5l_c?Dm([X6SQFlQ3Cu?FT6l]Be=gllO(2?H;E(bO"*3m2jaD?J"S9g[3kTmN1EV?K^aJlgEWumiM)h?MEo[qsWDAn/hc%?O-(m$h3$anK/G7?Pi7))tDf-nfK+I?RPE:/+VRNo,fd[?T7SK47h>ooH-Hm?Usa\9D%+; +ocI-*?WZom>P6l\p)df7Kg\p$erZC2"?g%E\li,f1ru^k4?haSmqu=M5s+*GnOB==\&IF.XiK2]64s:Mp7,j>2ZsGI)NCMrj +f^sVY+d#=VP$'W5;(7c&jc\;=^0raa9]hOA[,,d_SPJ@3g%>8p6(q-=PZfpcO\)BIl'0nE5+tiQ<9f`P[9g+@X]FbQg@]p2@Bir$QX(B>jdq_[GLG!]jC/og\(RIJ\ba`Qs;Nk&W+J9nX/*T59Z02AFc-n[U1bWc"?R8h"H4`U![QGRU%hD;5r)\opX][ +^L=D#D"a?([bl)8h/;tVh=gl"_;TA.S6e,rOic^*q4-;c5G?KhFS_P7[pQDnm<8AthY2N9iUM0jSmOFKdHU=MrLVnj^Z"_YI/]aF\)6`OrI4d=ht-jJ5VNlW!^NtH%g50P<#5a)Y]Lrm684WO$::u(0+:3%e2Ik)Yk1-k6noBG&k&u]:D?5P<*'i(Z#j=i7PU-?)Fh!=D]D8% +e9;s(Z1NMg82:m7,"T!rO!I:P<0nq'Z?2]e8huX/.S@"PL4Fd~> diff --git a/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/parser/InlineImageParsingUtilsTest/img.dat b/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/parser/InlineImageParsingUtilsTest/img.dat new file mode 100644 index 0000000000..93875155ad --- /dev/null +++ b/kernel/src/test/resources/com/itextpdf/kernel/pdf/canvas/parser/InlineImageParsingUtilsTest/img.dat @@ -0,0 +1,243 @@ +BI +/Width 1030 +/Height 325 +/BitsPerComponent 8 +/ColorSpace /DeviceRGB +/Filter [/ASCII85Decode /LZWDecode] +ID +J3Vsg3$]7K#D>EP:q1$o$N>iL@So+\<\5,G^LL-NjE<[*IE5[a2RJa3-XFkqZF,@n9eVk^VFc'/enm@9:1mM9jS"!dTMEqb2!l#N8#0#toX2(aMbe':>ZE_:<^TriioWjnAY&^gM+`4=1jRLW!YA=M/6)*KS9P +E`kN%="Tc_Aoh+fk'&t\ctIN)4XQLiVpoI(>.nOW?*DmIDOWebB%lA%.Q9k7iBquDi!)/,DC66[a5h8d>eXi0S^6MAH1IXb_>kP+oS^^pnX!PjdJ%0OEX9GI`IODGoc^+5,t$):"t/5eh:9Jl%POR,+@ +`"_L`O_e;>`Y"/@)9.H\bcnd!<%/i[Y`*t?_=A"g+ioftN?cOX9U-pGP&-[:aqBZ0.E[gS=!,Tp[!7W\AU%]<`,c@+1!Gh4biOO78m5==1Mkl+c4c.P3R3haDQ_#7bdP"(1[=9V:_X?B6-tiJ%7AMW9bg+EP\hF2dM.T+5>m:/p3KX>AMl9mPjLV0e.-I+ +;9h$MiB#L(9O0`\PKVQ@^%AEW8QM+YD-PU,c#m=DQ0j!,fG4pM7TNISG>'';n=`\3Q>N1*`,=fY;cL/)X]3i.h-D%%#lTZR=Eb4nESQm4c#_\W:"=CBQYkO)>Oo\eZ9)OOTmPZ5c1L%JpZ[0Wg66Z_J^/G][;ET8mCdbf2gud&iY[\%M;jo*/W8X+c8<7DOn7@"A/F)kOlVc9 +^)3Ge9rW_UOd6EWi=ABl\7;fC2k/tJc?5]@RI5KqkSaqa_.Km.go6f/p6Cg*RVnZ.P.HZTQKjTM?E@`h?=o5]Z1`sVll-GRZ0[r4c*QdV94+j1X)Q\"l2-M&\[hfjm0auaQE.^=g:P\4]pdY6[Q[ns%E%]U:DLk=S8TFgf6efTNuX[jXpsfhcS`t!`K*0qDjmR%^[MUq"i9b( +V]jU`SSqfcp)T3*g%L@P;VEAG)%4`6SaN"$GR)9CiV7X.NR2c*^IGJMX!^]GG3b3)l2%!TXm>j*caE/eQ7nhYXH?a[(jFjjc$Y/Y8_n5u[J@\l>l1/30nrI5r@g2*s$u,,K$Xi86eHe2?pm50OD'3`.#ehkC?13`/g`hCM%ekW9o;e+&1]-B=Tc<>Kb82T.F?BWiFFU#:Vn!h=76T);l"]Cl3bGMV]4Wc;2u&?-q?8a'&]:(O&>p4,e6EJR58t$Dg@nPFUfd3[gC4%QZZ/2mn@M!L*=8E0+>M6rbo!?HAt;Pg@F!Pa +-RLtXUI7F[c\\2^kS0tk'TOHc$;Af\,k7Oc)6K0C92"JS0qh);(/Xd56t7e^::+$::?`!QBh]Y?P\Q9/)Su+\9M.S#P# +nRLp>Og7M]Y.o;!=6gReVmKd&=3Ea3%.0[o;)lnU4&&mbql$mqY#O,<2/=>rCUOq_f/:0QCQ?/sV)R3o#s(Uj'5Tc(JAFje.r],,@">?eX^ia(ER&/Nr*1?WLZ($;Xljp4-Ea)CF"M$FjBia5n'ENVb+Z54tdgrGCqTu8t&24!oC +=[-S=2@6ut-O*(f`Ii,_"i9t'=KXb77P@3=_Xrl^5kbE009.3Od0I7JqCsq1.B/E@1&?)ob]u"CjNsK(690K%Nj>A(t^VEV!M/Gj>dE4G.cM?+OWWZR0-4SJMq,-+L6F'P1NKnSr$8`RdHY.;PcBo)o'5\VAMlN6.LBAj"/D/Tlkb6Z^DVeBoV-+dgP_ql;U +AT'[K]l_iL_OEPKmqCmkTJHok>RtZl+`kKdD[GB'2\Lgn*PkLE.2R>^9PuH&A+qV<:&/[9A__jO[%?aI'5Ml64WhBu2;mR7>CBp#pm1_L<3O\Q&Lu`Cc1lk:*.7*uF5D>kq>g'L>n?E_q`k?MT3H-u=LlgqdL>P-fKl=eM=hHOpGmU'>hIGX4KoQL?5 +hb386?d,SK[tO]DTCr25h>>AKSc&35pO5=7-b1dIrnfs9qEN4'O5U'lb4Q6VOKV\J.iJMO'_`i8$]lA%E$4>iI-=2.)\!ooLW&CCP5,6P*'"Rt4U_jDn3M[b]#"7SY\0M)d/9X:m!f+:nhcs5uN!t)n*$aC-Kd0Mn=[dqf^&MY:50>Q2!9bHC>&Fh==:n#Rh>5aL('(J*k&N]rq-PTE+__@rDaZU?=d0gOV$5$JUnR,AD^<&!@FQ@HT&TJ9_O;:]=%8\2X +J`?E3UDH:^A-!tn&FBtrLCZ(1%r/]eXjI[@ZOh#t)Nb[K0sFG.<+_)=&WguOEPVJ!,2J2@*$R6Z1!oI<6O;&%`UV\'1#R0$hZe&.qN9"N.0TZ!h]D<)'T`h3dH_i.i>,o<$no[b5dMUgLcE5_+gHFgOQ[4<,p?c[T]!F"%XT'imhq3W)9Qq;#h'\\=W5T',`o,N;GdU[mh)`8 +-'A!Lmctj/2&rmG,r0;P;:cKo2]\'&-LqB_E/>\mK-h4Co.a)5Eemr)=HLp9.?])u1'fTi$ta"t7;?-3Z5*VL[3>%k%YJj<&h#a()?j"m*`=j+&ifZl4JFSrP7g;0E`DO+9aWYJ*AR@9cNPs7P:pdD-;\t7Oi&fVitF%,-ZX=uZNV`IHQLUgoWn8;On/p9q(^s>.<5ABO^Bgt +4XqZg.V9AX.]=8K_?.NX1pXY.nE:ch;.D6K^DkS416[\3d!HC"V]PG\.M@9RkjT7$^3P(o0"NicmYSL1iA@2nf\HoWZD./5-n?NMZOR@@3[R=petkl'%WTdg6bf\7e;#Q +F:SU4b7aE#33laJF2($raN7C/&oqbRF#Q/)F[JpW3]&PtEsX78SKJUm&Q9o&n>es^.j*6Z4#BGpn:s-d%51X0/7QE(JB]o]],2$G"*Ar]oRTNjSOdhi!l38UoRf[jk=:U\if$RRN\7UBhW%?i2`(k(Ec"G@[7bVP9<-#[dg[T[]hE@67?]qVdU)n%a\?m19si_NkF53d+gY'&k>HFO;R>OX2).V=GRi5\#1Yk81kSA\I6Y(:8ee"Y/SM]Ek>,sC>BLQnl?-,Toi:SA,m$"u2/-,K[jKU2qUA]('m)RgAQX)27Z^VMl4*O^?'p+KVX@:KnS>F$44p5`HZ;/%lE>jo!r +U::q=V)2SXC:3):odO6iJf2#-?K6iq5uV-5qY%>rlEs>ciU(#f,@tuJ4Yu6SU.--rG>]Tj28Q")p@&oBol"8YDkUl`iFd*g"_p>&.5qYa!C:]LHkA:T%2U%)i;msX+*)QB&L)X0TgNen%efW#F125/iGsU&K5Yr'FJ5=6+h/KC40W)Utj\5Fa&%T +GIN!EQ@4!:Km7fuGdiZWpQ9\InTKt]@PrWr!o,>ZE#c+DDrG@V!c)h^,S,k6Hag\8i:[Zt`)BaY%=l3@ngk-7e-Ym&IC+_8^k$qnjaMF;#<1uR=7Lc!om[UW"IK(:p\rn/PQTP=J@40Cp^r'-jp)^eJ[abJQm$megM3CZ!Pl5i`nuCkf6fjQ%p1uIpd'Ql]5h%Tn.!b7/PZ_h`>#Bc(/afKVp9*Hn^ko'*+-ahN]mV2BMsMR]dGpp#`#0ISokMkYWB#.&!n_0,k4GUFs\Q?FOIX;Vr.)0jtZ=%.Ge4`d;mNjglb_)[Q#LQ?]TC*>*\Qq.b`"cs;B&Xa%T)#,Lp%?BG29=X/(:'MM971NBlNIddG +\M85lef5OKN/JUA2!8SnE:m\O%XCc*@/Z?KZ'AbVCK,k03!W!^2f)O7l'BLNG0a.]e=@B-q1ROhTrKFW;@gRbR%TM-o!ARn6^`10F#X)G@$-m#_jYg6'D\^I3O)*(nTgC(3k'!2D7t89Fdc^T#arm?g!Q*:6?;j="P=N=[#PSME"WsQ5'aZ9P3kAc>^bRfT=O-4i4]H-"FVCS +RAn/U@"Y.41QPt4TsP#!es2'N]7r?UU816]H81#&#GY^]USqj@g*<(uZ\^L,M.U100-6RG<#S\*HJ$,G`i*#Wg_k1c%m"PO^k\g5dKM<["8XQ_UP&^crW\gJJcM/H\ri(>r[AXVPP-#%cjHdU81U,3#I?p\Thgr>Z'Eh&R,F#r\oJ(%BpPoYQL:SW/S18_J!Zu!)g^9d\1+>e +I_ID;TceuT@=buFJ#Ls=)#K;'[+U[6-`UX\N/b"t@\Oce[;,QK82tu,[X))\J#&e6JOe\H'`J,AgSL?o*=p?0A([8E]n@ZS>&,X`sE[5M$t_onj>=es'BV%au>)egia>\5t67:FT^pe2;CCW1ZJk;VrCr*a1/]t$Jo>p?Qir,FQ6YI]!\]!R$L+ZY9DRMOYi]?Z2E%\^!6$+u,D +_ZI41);^r5b-net])/\['J/3ibFh/Er2)M&06!2?^_3RsGCo&V^'#Fn55CC]S)oI\5V%1Mc+NC'qgRbp)FjSU/0$N(Ho[f2d>?Uj21.j$ge"@Dou,h:VSMbCr9k'K[="N#;>$UL=DK]SmmoOSG<`ir#1<>b!&u$(V'%dQ*bSi6Tf: +8%sSqFLs-U_k!_b"]mh1@6n,MqKLR1$spHi_:X[Q4@g+KMB^hC,*@*c?>r@-;8%EkL0CSqrh+#>jX,of7;egI'#H(ot&+rrYPCbnsPssqDoHmWTnPcJ[!U48CRahnZpftT^u).Pr3,V)[\n5gBb``7hnQDp!H_[(b+4K4WV>bS7rP%8ps#E:C4nD`f:9tEQ&(hR+ +#mGrI+4-BS/f>+Q_;Z%DPX2&Z$Us(fR+-"6*KN_O&fDCD8K1f(hbokAY$!?C9BHkbbg'o[Rk3_'\^Zpj4eGO6'H.\rM++1:kX"K4(7@(Y;s'/;Ptn;VLK3XTRakjOr3'2g()n!G<0":_/JagTA3k'Vg[5jsQ-SW4G?sYRS(6rrRD2qp(`Pe#$$a&?nJ;Fj0,]biA+B"MPLCtG +b@U8_=0?E-S^1s@)BAA+8Pml7gH(HdY6D&[C\A\fQH1eg?>]>`*S0\)^#*c'*$*a3M6l5^q%H"XS'I)[A[uHH-=YCAK:c+R7`;KYm6>3f9@[/4,:@ +jcgPF3Q:>_SHEjG>8K`s\4[\s-Hl=7Wj0D?%7bEt\:Hu0!m$Ua&gUl_M,HXu,r%/aikA"TJV,CBd:g!>0[adC\$?Y-]#HKqRklcmCt\+$9_1VBHcF1$eMd^HKW-t,F/*(6KZ>A/pdETlq`d,-[0&J:D3-VB*4/,dRnrZdUBj`dH;u-s'I>8&;X*D%9es(U3deDTO\&5GFX9YO +"I2C1F]6G9!ehR(;9RoBNV4el^Z63XDb4jhEQ@,#\d]3`Q-V4VJ0_l_*.*YQtj-s^W9d'9acc>faKfk-qTDR=7KUq2<9V5P??tb,WB$)Mfd9>E&U?i' +)cR?>9p]GZ2.r1ODOk.%./B-4NjkD\HO*jH%>bHsLj"KI+EfY\TijD0>,O-_d#"T6HD4!$]sc(_U2+Mo]q@]<:9's$4!i4"Ynq$#]SG6R`1e-=LG:(2?e`E]J7)UD#lbW%#2R+7BeiGPBtQqKQB"(?$!;sFL,Hq[RIqV=o'0%7a)cR)13)p]S(j6.>j"c#7R8N_d+-Jb +9T\Q7G:*T8]qoqV_Kn6fXs&5=NNi*2/5+YFeXqEQ@98+qkA)Q>GNU-bT]pSEEBDi0*XFn5\#F='Ga^K/A+6;?K5ZUkG<((jYV1@QX>$di=c4 +7Yn2R_Y"*O@?\l[M!=*?GG>F9q9'2N.2A2)[.t>Uh/+]N84*A.)5:(s0!C[k5)7RRT3LYUn$qNdaKZ@%dXr;IFq2L`qCH+j>=JY91I*q8T:l#5HNPlU7eDXs`r'n/m-'h:(uZN7P7.h\>j4%X,mMJmBoR'M*>U%s6".]g6c<.-_P\)B,#Dm4;H3OEGqcQo\Yb+cg)H+;)'R/m +eckW1"U$8N\`+#k*Tc4&b5#HsAX'Ne!p3]TJ7gK9[&f,-jsWY4`t]\+pm@6\@NFF[s.m$F5(QaI7ohO"SkYY#fBYG>Vl8._K\7Nl8,&+Ug+!+'tKF(?Ak +eErI*/e_'E]c>&i'+Ip*\\ptd/La[MQ32`*7RUr@$\YOWPh)=&601jUeN9[np7A,ab>;pg6`=UWF](F]PP=QP<[)m9?QFQs3SeVc[^LA#bULM(.FpWsM[L*0@b7f(/kL/!6*at;,5Sd*fi5Z*)4UJ)CDNl"p4A=NY!JnGWe;L20Nl".2eF!)?)G`X@keM8`KhVVQ6I;j'=3iEc+j'6>Y=Cj`aZo9h9M*%DClBR@?QW;".]:>!W.ns\'+\+%nS?PJ9-2'+MiG!M31WB/;eQTDk#X_Tc2+kl1tCAB(P\k?G->tm>.pZr;8(\UmB_72Qa5qK)J^N1S1M%$Xtd;l>G4NNRBscJ.N9O)CXBo'eRIgqAQ1d=SN(H,.a!eRjun]]p(P`Q(o/@=,%n4mAbd[4I^J=0G(]8\b$)0&TjTJoFnM_9B)/"8sSA +2F0^Jq7`tF]*KbWieiW65C;P#MiMf/6qUS3Y4!1Foo6+O@!P]b5C%n%GlJqS4,9$jSla)n:F#"Lf:/rs((!T0?d(EP14adB^@Q4ec;']fkJ"B%SQd\Th[`)c=0o(>?OM6#JBU_n4l,cJF)#QLLM],eWP\AtrLN,N"b<]V.*k4E#PjkTDO*2HfR +mh@r7l0=mjn-:n5VSLm_Im)K%hC!s*I),sYO%&paO8BA"h4U5CJK)ui]4\f-RQWa%]hq9F1Y4m:YIXG5\d?tOUVn=dJ#oe)]>5A9dUGoK&"-:0K7"U$;> +pj4Z8Q(V@[XR$o]X=F_g!2,Iu^af%C3X%Z',f!QNV[;(mKJu/XYs>#35dJA4@Z:K^.4aI9#J8k3j5:jO1:?r^#2DO/4;3Kl'WG%HLLP_*R]V,(FMs(L.@_9T]Gdpe)oCg`W]3>`lo_?$,=MtuZ[3i^'#qe-R?jco7/3CSEQbd@R^T4\(t&,0>ZNA&:4t)G_YDHlapCDg_8Od_ +3C;c$C*Z7-]#-9&_qZMm]NIU)5.tD:`f]LQJ?ZqRd_hfu046EPls$LR3(F8#2cTa@[JP:5"A438i7E:@48!nG>X10As?Ur;@[*^0Gkf>4$?l/C-K62\fQo2rE431*L86gm?CkkQ/Le*%X8=YQ.XG]W^N(D-m!qHYKCl_*nIuN0E%)cGT]EKWb&#"gWg5Xi`IhA8;(%"*Rt\BClh.SRtkOeeD/ +/B\\@ZV:^NL"t*A'*uancV48"[UcKe1Z8HNS-fC!8bC?N%*kjmR]L1B:#+C$A:ao*d7t!%8dqDX7,^a!T2$*!9O+Jj<9F[SWM#KUaaDg$`2pD;Xig;'$#Hh='XC1BiC0aM5TJiNWA%*tSkaW2"Hj)'[(M^KElU!J#N8r&RL+W-r(J*I-%s1^m!-`I=IdMZ'V*5nPfZUd`ltOL +WZ5#4f[S0UHHrJ4c?uG4+C1^0e4CA)6-E_/WAQ!C)9qB_[f*)Xs$;;E9jm2i(M(K(SH[j;AS1u]XBU.u-h.GZ2ir8o/V-I*=hTNpa'FU8J`la=ClcJ:)XeJ97&Z%[S2c3s4cV".Df:X;0\#F+m=3XJ5SpQ<\pbMbsJ;IptK +h$#A.:Y9j:ofjck`6:fOU-Ul;KLsCHIaC@":fQ/K)"7RV#6rEY;RjltN1SD'k*$4(btQ;T>0b6hM2!l"$67[F2$MAoTZtW[eI!QUZD#^[92M@R!JO]"RhSk]Us_:-dS/%e>rG^$QVr,Gec_r"RKZTh?dP&h`>_ku4YG%90;"dhdi>`t8dD2%'*V&QJ9+gTOAtbj<,GSJ/QF:)?s(ZSO\Jp(Q%@@]SCO8Lf@fJoQqK;>eZ&pU]u82:PYsp0=TpWbCo5X7a3!_:+.\j"eOiuV+PG#1-l&:"ue/-4KncJ)?_>A=K!ICRX`IGFu`\sQ`,d%__#^KtbV>RGo7*Q$Sog>'oMgg-&tD3EdV>p*-R9atuBrKeXloh"8iT+0*#"fSo*6.R7KIB$-*<2?1m+(mGQ2WGH55&,"8>766TZ87:'MlWZC8q +Pg3K-JDQgEfJS=]h76Wns0<#Q?LX]#3HNW^MV,5drh*A#`s(h,!\k4mLEP%&)d\nLKV\!atb6j,"LR9>8;Obc6+SP(8+tMhMrH-Af9?H)Q![l +@9j?ul\u:(HN=m'$928O/k=n1ngE!4Tme5d%OC&XT&4+B!oC\OW8iS@@_)_SJM:Qdj5TIPfPKna%PcleYb1nN_8\=Z[KY].-=Crf@"p]"ONL@U+!E@0;/fJY7D8sI5L\a[i:o$>.P`B-;7)N&7&3GA4u`tj8>&s%c@+:)@=8=1Hm1pIk(RYMN@T]`J7TS)"%IlA?7O6K +RgeYOYd,Ne^g/Q>Bhp@.$sn+ZrK/4lMuqQEBULK+rf81ic\ER!koQ!RQt,AA,\X?@/G]Z0XNF]e-Kn18`ca&QAt'9LB5,Kl2oo%`iI(p=TN8Z@k?als/0^aPOUPi<$G&\@K+=QDV1?`kk7)TI*NRD)118[UC+bZ_2"KDpGb=t\c?3K.p51<5LM,"&6*@D!I3R+O'PJ&RAI2@L +jJ1I1Koo,bkJEd*0R2h7^a[!UTU(Q'$<7nnNs,HD*<*ilDT?HNA"]5)kq5G>@Kl"8a(t(IBS?e)5#5c@S/#Q-Bt7"'aCcVo56YZ>/c4;R^7oIh`+h#c+J,Bf?DX)?7$N3BmFhlR80/^6%cI&];tujdRPFp3jD*Oom%puLSXPM7Yb.etc;q7:1>ck>(h_UglYbm%m*FF66#2RW +/RH%W^:ZoNL*;;,Ct>4q?GgRt"mdk^CdsJYQB:QYr+N7SC)3u,(<[h$bYUp%jCZ\N72+bL:[J1BD'%+=B%(Ta5B"]5m;=ecNnA<\\a>P)l:"lk?S1Q.&4;DSCMdcF*)sk1td\9X:IIl1qfH'QQbq:_COK7e4Bu +o>K5PTml\(*p[d2Omdl*DjJE3VT!J^`cB*S0n0(oP`Gi`(t;UdTDnoVpB!2V\*uPl9kBh]=\j!L#*8K`TDm@3)'s6r"i)2gF;j$#-DR5?g4t_"nHNhAEj(2&,Y;V^A-WfP]c_lH1+^`flK45sj@ee@#p>QS>brb:hR%:f([fbXo^q3YN6d**=P!AOE3]37n<3CEHJ=+K"$1R,l@c-:$u?enX!;HV]-]g;:Y%kp'R8Va&MU/f +2>On7H-,ROhY(AR3.&pj0R'40?_[BU4aKV=qH#EG63$QnVsT7_qOae^O*Qc4b3oZ5FLgs[&$XO\*X+;S44CmB?Pn#0MH"em<7q]$;om:o]?\c[sa8145bqI,,p&"83^!5cu!5EIkmRY.>r"0(@ca4Po_8iW##f9E.-sjd;,V\gSY1(,q_opMM&B%EaSq4d6 +4'jL-;'\R@Sg=5B'Lkci`u;pZ]Q"pn`]SMaa31_T+NI*%>o+!V4F\Wu;I#U2+i@QXLX"R/h'9_+p;d@u188F&*1X8S_o"D8K]^W`ZPMGstcdVgk`h-3N#Y*1iSIhBRe61TsdFO9U/"/0e.;rDHtcCCulS*EReK(f?[rQq*"p-M-NR/m?!SR;&N;Ef[&3,BZB`C>m3;CS/lF;NKJL!bKoQdWn*LTfb7T<<)bGSP@6Orh""=[GhmS7kd),8^#(*'GMVR_8E6iDJDaNJGRWNIp(1Ng8%'7]iRiT&LuMO..>QlL^+kP6R,/,X9GK-(OO=ZUV2iL^:.:E/=^<+q +AXQsKR,lW:#,fd-^2ZDN=krg=:m;g#T]U5[9;:PD'e,s,FN0`GZslLuTuLQEWDVQ^,u88;XpnO55BA-fVeZ)I`EO->oIt9%<@qdaD9hWf\Esc.V7Op>FOp/RIrJUXR5?()D9+b\>p!5#]ResJ +=S>kB0oG\WO(mD.R+[nZ178#3cI'0MI+Ghh;`WfI5#7H>Gnd,b8,00c#-m>4]^MG=DOpFJj+l=W[K/&?9c\'M.5p[#*k8G&ba-)Lri=GQ5I2clLD+Jt:(=\#!Jpf7S'b3/)@/UFLp7(-J8caM"=sT7iK&nQJjn@32CJM1b?L'\j`/DZ6H%uZ3F3Vc +]t?]LAIQT^229K7*(-*9%:PbiLX=HiT@d=JQp=t_ME01t\;(^U4&cQ^H71LlD\U7(\p#dt-5;esRpK%3M^9h4]_BLBhIL,TO.=Q[(qrn>WFC2d]YH\?jIY&oqAKt&23jh!*mG[7N=R3*8/"`FA0cFQB^fNH85s2.]5N0H.ROn_qRC'>["'o"Ud.HZOPn;c%aof"'HrYgeL;aT +0ru>:Qn70+l+C+PE9b:(6;_.sn<1*4YsN/::Z4tsKp(k352f3ii]F)DDQ#Ti)3iA&J0f$Z;;9'&Bbi%#>B=]i02/Zs(g]UBI&:e"7X4oF@oV/0OgK>Q$.N<,S8sXcQq^=bIfog0iLFa35u3\68d5^p."YKM8?$Q3,\q:[oD2%Z.L)@f]`%u\Bi6kB>,hrI/>CSr("&;f_M-d- +JOQjPPj)B1AV&9q;u0\E\JHlq<5!sJreFDf"pufPkbcfDcV/SK9W@$.Da7_RMA`)*k*$[OP:C>p\@R-%Ph]tOg2Ke)^HKfrjdaeoFj?u?p>`)^X453LrVJ9PB(PJFlP[Mi.`sK/J?fL5eq0(tK_oAK[d*N`XY49Pg\n +.BbE(Q:r3&#jI%ZZc[Y`g),p]m2E@"(4Oa\0h6!D)]#BRBoYncR-EDmfpbu%Ut.T'<9g;\RoNq!`qm.;USofTeAt9fR`AP>ok(bMlKD9c#@&gnF'=j[F'!I=A^&C.T@NTm;(DX%aUi3V6AkCg5dPds>o5(6Hm?YgbMZ5&\QcG$!SD%t9SBQDqYa;XLdG!!(.orNbkHs2EE +)mna8b9m&S9rUgV3%"mfg`M2gSe]-;B+6IT,+32&/#nX%7@QU/N)P>P6_da/j4)_'5?tMKU(oD!c8U%>PoHqR%I4BaWKt(ph6_I$P?fibQu`\nc$A:/QsuHjF<6*g=4k]c6E?nPkg>-^:`S`:4/d9CV:6QISB;>.>9S'//[WH'talr[IW^m_smeqXK2?(QaVk2*$bV*U)lRK=KJ!Jd$n'-.9\*-l;+9h:9p$V4#meHLp\iOR^dA.Tq/6R-jlf8GUT#b'a8[qi=4K5mmZ[7XWN]dZ7K?DuTi)[#fhop1&pPYAP(NEd^`,)DDs0!kA"+h"X[$m&u@D_/0\qSi=0iq3+E1BrGeqo:bq!haG(UmjWC#K"LYlr9nHf'nB8;D00i#6sa5r;L0HriVLBcg[%Bo^f9]oIt%4 +TQ:K,I1),bXNsr?Yd"U'H;:0nbA\YnDNP!7me9M&$uk&Nn2CHR4P_\V:S@e"$J69dpB9ta&&UF=Yl_<5pCNEm?Edl[0P:k,Ym0AO#;5*DBpS$57$`6#qmS'0.=&#/ICU)o-+=0d&?@DXT-Z`ZbU,f$31^7W#[ET!6ejP&R>fRCDW)XP].oV`gm1YFUeuD +:CuaVOR,bnP8T6g"OWhSN<^!aVDE/=Zf$l`&If$M_YY_R(m)cMVN1s*,ohd>)%k150VDu"ruHq@#B;e1E=c4@QC^pB*AL0-O\Q)m;S@">'p64u9]cL/$4P9L(<>M(&T5N!F!)#L$kaWucYX+EE=J![%FQ1"Oc3'*OUeT\67a/[C1IYA7iq-d)NasL90X[&bpA<6qXM)a0teeC +1E7`K#:\l+5ZK1/8KC8h*f.,(6+87:QD-)trW.,<;=#i2nJ'=<'a`t::>[/aAq?#?SrJgEEj?P1[SmeO\^8.n18t625qJ(-Q4VE2:t6C0Ri$1b!HL"NE]Dkdm"%d]Z%29gYb1"(;oO$$;PBeRRQ*.]CaMZ"k65q*?+'Q<4b +LH?STp^8hSA5E(VkY;9P_9fqP:FDQnm29Vpd6(FSF5AgsY7<;!_#p)Qf,\0/Fh+EN'lWNjTC^&G$&:o*H!b%60DS0d]rQ_$rLur"Kgf1'a:(7RCc2Y*(6u1Fp@);d5j"ZiX7pq!3&$l[c3Da6S<(7k#BsJECPf`-pb=)nsXh<%$kia#:+48l*Ui#@77#c$:saqN@ZnbdS\Ij7I"=e[%fNJF>Ph>!0_C21nO/DUJ$O13jX4$'7bJpof.'#kEIkY'KRsY*DMdQ9o$JFM9R:LPsf_:8?bqlX&(f3 +&>&LMQNF!PeBH2]^JKacjorhJ.JsF9(/djTC!EfBciao^k.?UI84s(`1p&:Q/P,*Vjj^AG_)G=n"K/85"UgJ+d:du/=&kMii!3W=_c!N/'L?_GD(T+qSR:TK +?oA-cp'G@]f_PSOF>b:Bp)e)c?Xd'EfV_)Gd^N]e:Lf^FD:UjdbQhZ'$"RNRACaC.^rid8*AeA)A[D4Re`aCT$"f0c]9UE`XQQMReQF'ULG'f@o!Q"m7aCA+kh2RRNsGpbjW!nPD#_aS_aaPHSkbj\dNf$d^BQWP$VD:a8>p>L2< +4`4a)DRSqMoq?%+fdT5E&%;Kf72kg!;/6jlB!XZqIq,WpX;]r`H.p&1Y4lhpI*lfX`ULsFSATgpJlPi@l:]%Cj*d@F]WCgp9c@.G?3=?(_^$S=b)ip+@R:\G"6g7fYpK[L=TF$f:_!>*7Fp(^i1lt'!E!6MJe=&gpa.`IHEEO^"le!Vpb^EQ*8^d/^i;;d/N\W0&t;\n +r:i(2=[SEM;1#'U'tI):`8b?^F9?1\HW@f8@%9<-YXE1'DM2)h8d:*I,;dAM]_*@oO:lI]/VG=eh"6Q$9b,Rb72!Fg`,aBq(O&Ram=aF^(@.M4?KAQa"5fB?>`_SWQ8X%QWCJPLks+5EpHA*R<`]@,%;V1;A%;Sln2hU"\9^l_'[SE4C3PoE_)> +9mpmCLku6MqBD5FScmGSn+gUEpmir2EF7@oRolY[iRs+QQH=YGOEs^!$PK=7Z4_G>Mj_JN$'go]_eU-\UWMR.H?5NhK:9?kGT!`R=gaa1L)i='=BWgIHAl!1O]AtZT2"U0H.Pbng+eW;Xc_6Hq<)\M%8WfCU;0m=&@;[&q/H-fT@s;kg'=[If<'[>PbQa2(egRE]F9NtI#7G@ +J]s0_5*g.[(&BPd2^"JFop41*UR%mVl'8%^c_P9>)nR2B2R06JB3K%ZSsin)RZXHrK;Np\VQ4kkH(Kk=EY*P?Ql:=N<]R)bK;_t1S"!:r>:(A;@CB=,WQ3Ph):^_*q\_rgH_u;&"U>g$;0T9:Xf9>>Zr4\WjP0@UCmK%(&,V4rDmoPD]%WdLR6G.RJu2bJH2Fa$oK\W`_n;6% +S1L\;=s=aSY'h8*])+mJmTm9/@AWX$AI7Gc=;APsB=0YM@ChH5GNHOE=qFpWAX*phThi)O-_$,^_V?f^"Lb13>Jcml_qL$W*(..rpTf/$;Yh;CP2c8KHB,Uh:m#uhTn;d9WPWQi6TIDIp]*PB%;r#-,O*a]m3_u!`W*.Qn-Mt +>csRNdE>]QC2)6"X;8T?;,>pZtRq8L#uC&j?tM$3-H"fU%h1UaCLnWV5id#n(-f*I&A_En; +g$+jIf7D0cqoq\$VkB=<*OF$+Cn=qGS,L/=r_e8Pb%5rDR[&H\&S^'LfI)(T>CMe$*TbS;l(#I6dKW_/>ppeC/0@6-,RW2W*XCVZ`:EKr/;m@N$IGdLS8 +TWO..k?<;gM.c#)XlpZ^gf\`khM>`LNMiA1l5l;=?.tq,hs)3]l3U52ktE,OrOL[i;[Ak!Bu9[\dBZ4WgPn55ot9J=&'&nK!D.5"kFUp=R37i.@!NeP/hCO@53_bk*&rThJRq94/\:qo^Ri*S5AF6=u8B<8T`DFPhL7Cd8?lBlBN]=?B86kjofg3#Yume[>;`"u-FI%EQIt!$iGlD5mP=NQrpb9*^TX!Ylh:DW_-lc">W*JoM1&k'R)ET#\WP!Ei[bME^G2/#cYhFk +p4#B%d:i0@>lEtcWRMnFR8%k>,_aocF^&(qCN6o@DY#&8p;;HtMPiG&D'dYn.(aMFSDJHSU!`(D\t*-(gJ`:F,!2;IpO4/YnTD1O.84g--uJgtrndsp\4QLA5*GobV/c>+IeX;#o@!\)/p^tD5EIZF/AWiY(3R:S.5_Arn<1(p6EY/4OWK[/6ceoY/*_X?=NY0Pj>S`m#^7f-X4jQn^Q?Z]fXZ5-qWalV"S4H;)YkFT./T<"lGu[4UJN6oV7H!@BdZjR@?9Bmd<\;REd*85h)L$D5M"aELHXPPGki:='*j!=0E?71$Z# +\YiP.9cZ3c5:+9O2S[5E04$mu[;d0P,0[:!6-1Ap9ir"G.W.kE,#'Q,$ZnmM:^-Nq&u5/X#8GmsA6j&FscO'f;O"F*nSVdD0[X;)>=cN)CCcmU5(bPhH]0-lYU7Y>e7lh;T:L%nBM6/d7VS +1p/WnA>aQ4Ss^JI#.&.&$)B9)XU7-9Im93Z)V4a!0-/k+*a48'EiO''LEOfH+gAY#njfBpOk_tr^H=7%off7)Jd42#T<3t?rE7]D^1n6JafHb;6QIIsCCE]ra&]@Y((`#Uo](4kn$G,43^'@aqBEk#1'_+cIpT?_DZi4mW&qH$/WB$I="e4p"a4Th("EpJ=!fs>sh +FcCB"gh"hJl,\(^nlFkf=f5fCk_%c/huqn7;Y!;*j31^'5!lUtqRn1<4',aX?`82Jp8RG[>/)&cCS(sEYJpMh)6ka*iLf_O1)Cd[D;U5WqL9q'/+A#Q3.ZS`d@Uh;r)#m>#B3Kd"VkLO!D:f](b<_HY7dT/Qg<^K/Bpm>7k4gC':<3'BZ<5L*+X^b-Zi-j'cKSuD*cB!KVlCQ +6T8CYiG0BUMCoa0LN"TsF'*e:"lHs,!t*j6SL+g&*L&h,'3YGcj+@K'&k6=cqGB??EGr4G^A->X`?]YZ`#sb(;DOI]bArCAU,'d+.f]\\!b]pmMSO4+!p"CnE0;W.5mSb>b&L=?lY\P`#W/Ddj;r?'Je5dBoGJr3Os^=J +EcV6i+G$ITp!)/)Fslp$\r$=Pe/LtuW^`\.DaAP:H-%q9j_/ahtbKfQ+g#[i%L&T"%%PPm@pUg[0+NZcD'XVrJ>>=(,jLW8C6*#fl<,SAII&Ts3XhmDtuEV`A*B`^@D,jLK>+p(Ps)'e?"A'C7b"uu%'"Bm@khrg7I#Rd'Vs`8nLB5fC*lFq>kjkG??\\X[/6B\66[)o4O8L\)ATTP)g4DSIog.e9/$Hom^c35UG4+IG6T,rHfU=O)'-ir:=&=X)qtXf?Cb)k<)&D.')a$M/FP+ebqs=o8r&'Jh1n<%A1pClM[+cDXH0:-bShuqhgFQikhik=!cn?eDXJAhdT]sVQ]kM&B)17XUoTU5D_mug]%^U\Xg)6eSif*4=2R[QJN)1JV9^HV8ApSY>20%gXaM@;@7G;?s.=qHNA3f#?:.(@:kK8pBaP``K'I[)P[:N\F^jP:_1i7=s&^PO/\otSBE8hnY\U&8>[:`.'QY>e90@3GZ$Hj6-_:R&Rd]T-,Qa(VV.i322u^b[ACfc+ORahD?R_To.QjI!pb"AX96S<=WmRVf^GpF"pRh(!LXAG.%N>:)5nC]+*I>J&NheV;p)_9-HTu63ICH]ZT"!O&^No9>crg&`"GV(Bb9=Rna7Xp$h2S%oTaSXbq@q96"cmZr6jM?@+(sth^UNlbpYYljL[fgXamKk6FU59ft!Mgp9KP7e7E+,fYniU@aL:e/#Mphc15J^;6_.4=tF;McH'u&`H_5&!cZl?j"*5U,D^FUG>aIP$,4h_UR_BIYGlfSTP%72TlT+M3aMglp2NJ@'S[s/@cd3h/Bq2%@" +6K3\&/2+cjqNeWu/;u1`dN6:o1rE9M_dR(CF>q*j308eO6_lc:l/_q$R=f$5^c7Q';KSl@"uV$fQf/FD1K;/YlbKNJ5e6P-F_CO<*t^=5=Q>NLL`W88sR=, +[D6i'Mei[;5YX53'e*:A7\je=Ztm\"CrXtA`oM$W_ltXV:Ic*k5m$Sp]M'-/E^s):7prGeoMA%oGfPp7`@4rJcm2-"H,n9j`F-2BJNT>K---_t*<7a\Ub)mGG_#.7Vc5._Qu>$J4@XF@aIo;]P`*O,@k!pY\Qc\cA-bRar=j?eaK1P^dgX8B91M;P^Vl=-E/)DY4\:$hae4O3 +WKIY;>6=GcaY\I'Ck%JE=t1Y17fpsO7"`QGPlco@W)QlP`/'Vhjp'&$8t_#pA?3en#K-[t8E7k6o2K5npdEPH4h%e&DO%&%pRiZrG5icj`65c/dWu9Y^s>_'VHC5H#[-dMIJVdS*c-L,A%k;--@,kEV:m:%X<0W2WJ5F@JAXbj*&7>d-p13"3$!9f2.W0Gi&$"i1&$9lYH2I.trD:sG[":Q5.]%,@:R]UE[66KbhNNq2Md%;<""i_a4aXEDdLFdH^[+n?EOXK>j%UhDV+!X<1B<&uI'\@V">+-76_/eiJ>cGW!NQ1JW$']dHic0ZVA3iJ9/mUK9\.=7+f4C(I0l#BpKn!2$C!t'b4F)sdl(hI&>$-c=S].8'LhbX4M3e[/g+kuhi(M_DOBC4Z=RD.W)k:)H +*SD`B>0X44rKN>iQJJEBq?I#^`3:8\eNg<<:o.@#I#j@7gc=cUfp#aDb`@1V%PVI!p!"MbZV/`6"$P)=KUiQ@\$h_Sgdho'<Yg>TIZS2;KF5TEuWXgi[Vl +KufF@WnmcjgprX*?0@+,c46rc!sRm,FjX.A>_bK0JJIUZJRi%\eMg#I?QtoW^fi2R`!3'N?EpNJ`70P?gfc<'Te%\)p"n>tD;V&<-6in&h2TFrL!QGPYMBiE1,REl4nh`h/3I`XmAj+=>.je?WHUQ'1'iWQ%MOk?suH4*[?JQ#`c7;@R37e`?6JO'JkAY%B^5MSE>P]R@&]qLH;#^%POdM(?0$mYM^e?=l/+T0q,51;-L55OVcuR2&'I#;@mhVaL#=nCLAb:$A6EW>$5?t-=SDkj:2l5;!Nl!1?9l'id+[sONcaep+S!OW?l(924Q+/'e,MLAE*W\Lg&4R +7?B29jX'q]P<\)&;&?Rb.$`\$;.UJ`I>*L]M`s8#Aj,26^uOp+aEj`bQ<01Q6&k#7?`!!%Uo@i6@LqF+2YD525#e`8dU^'^k&tM%XkBZR0':U_N@fTk;"-fRo=es);-!h=.NY6m[q`d;@6Nf,ksl/kQOJB6pYB5.=ekTSD8`35/@^`U[#l%P6o@2.kOe/cD37oK7RFKs%l*e4bk.L$,OOatMcTi<6Ga[n%Y&4-$Ca'gUQ(@2piJe,B+b5DID5aCl,JN;?82+DOK2GY0,`2aFoT`mb5Scii`oJhWHUp!uDTOn@3Yphsnrn%QDPcJ.a&`_@QoE[M%[($BSEDK%Bn0[B+g0&c;5]P=UjKHm/Y +pBp8b$gOlID$#f>G7MT=onR4[>('4W;2?\&,h/+LD)W_sR9)p1[16geO&$\cE/*QjO(lYK[a/8h@;Cp!70K#j&li]g9)&aD`&:?:480Yf;f5LX[l.(o"57>QKr,W?BsLH5r)4)n\*!SO8LOQU]V>49=H +Dq:GWLoCPZAA;e.l1UbA:*XnH>BFcjioXB22[%?rF*+(IBWK(XL/W3G$ZtONKO8c$NIH!d%s&Rm*+C_;I;&1KagcN[86)jDHHOW6gsc3q&h;82j=&-PkeCGq.H#hD%q8N +R/*):q59\W\!Vd!SGCd-q<+@FpRh9eTGA?;qBr$62l$4>V#"/hqIc]%GGk:mW;;j[qPU@i\#]AGX*YT=joKhR\%DOX]_gC@;ur?,*>^eg84@#f?B5j?$^_;rU91Rp[A+enG>l<>pqMH1r@!e;076]=qA:GEkqg[H%\(uP3r;YC+H-??+5_'oK8N7p.%*O;biD/$92B<G%6DV:Of*]O#MX]B/SSJ&#H2=?IP[%/.VKEEKkc-0pV!44!9rHKUF]uIj[p?2iCj'#GVUaM3ghq=?^#o';^Yj'THWP[VM9"[kpfn7=0:gGI`M2/uVcSl"lum_]]oIBsamXJ%?9]cd\``U2F?X&E\)$NDB0KZeVpjW!omVBrD>u!Ys1f0Rpu]@g/.D]Pcm/bm6',n'#IZOS@&S,LF7kq;b*lns$-OE*Me%GO`CUB=T0=#Da]WdQXUqe\)],N9D%!h-]99STpH-$St]ct[a/BoupYuK6330(Yuo>!%Zf'#NNS#\Ko'?aB1\IZ=24\uXDrB\ekAA^d^%.+DmcnoQq$;T*0.lgL,X9R$:e87';bk-7C92\W?>^"#J'hqWW'hbH$-"D/"(M;fM(*pi>odGSl='aiL\'K6EP36jC@iqT*.MU]/sF'ZhS&_g[Rd>gbfAMp!-QK2/.++.2A +eWXQIRE>,7kDT;6C$6>7YG']0lJHl!H;9_]A'dZd$0c\f!D6cZAj**Y%5s=%?hai39l%?KbG/m4f#7%Cm`oBbl+!=a[agjoXgIM\#1j.K(pmXIj>htn^ZsRugQ5nb"A>$3R5Rp[6sN4uO`C;1A%U^J5&Hdlq:1n)kF)=#BkUZjXeP0nhWrY`%;uDl@TP2Henr&0("DM31M*od +PCCj6k.<9oGkW6%B?E+1?44;gf,bOTG[>17i\fRe?+nf$D[X[6*m,Yj>[/NRm6j'[=iFtP"?l8qS+e0!83Varb?4\_1X/Mhje'k?o"RQ>9:[ENm@JD#Fmj;72"p5$)JcWe0F(l&SJu(TW/+8^3ZIj+F]du\L_:/Ua4/]_cD6+;E8D\A\9/qQlS+Il.1sV.bn1XX7Yq^(,paCr'22A$M?Zg)0A+;dAO:X'`qh8F +Qk7-JFab*fdtCLBP^PFd^CTE*8r_nQ"X>_9K5Hp*b<$FZR-.?:hMt2P/dbR8lV$gtcqMJ-R/OemB)5C/KN`"L0)Q8?54gZ,j +7;+$\jk4LH8eC[!qFaK>`6"kjbk+O$h$If%;bour8Od]-;G*1!VD=fYP5bGG'K=6g#u9GE)Delp=$lU>MM7tP(qWmm^-@euq'Kt>k3b5^;b&mr$^IMV5E53qlkYI3Z4=B"BjVr_Bm<\DBogDsejKorZA3lG,.%&,8Wm]J-b +]">o^Aks^oZkK0g=.:jWkuFUFerJp5s2u9HAc7orto) +^@`7\AK/#GMC3hIda,M\@@Qq>^MTRY%B,nf0^;k"!`81*#6=-cPg:e!5<:K%`\.GRTE/dNDs2._)Np^fSeKk1-P!FR4c21/7Fb5L/G\Zmj9r.rh!tABu"q:!or$>JhjHS_2BBXAm?L4YiQ#)WLF:XPi7A'G&`h0;\.sTVhhT),fJ5#'OmPuMXbQ1\l[bRk%tR$lW-)E +GinR1Xpaj:R3ookLFj!]X>b6" +ep',nn6/2^2ACDfBp2lmQqP?,LCDh'f&'pQjg&sQbEKOsB2;Gkfdch\]0V7R_V/'LLfbZ0=/E2e(TaF+76O%\)0s@kC*Vjm^mt6jaLFX3IZn,rV#i%*c$qO'u'1LS(MthXl;Gi9W\MPB)U+MpVai*&g*2*IUC@qs$u>P?a'0PhoI+Y +J=Z[+X835hloDi$&o8oQUCn0A5M-j/ri!miY(+ADrGNru'V"6$'Z/B%-538A"1):21o0N8T[=:B.R#r#`l0Ot>`BEW9j"0cbI0QdV>Glo0V#OlO4?s#iO5>+Vb<%kS6Ck$18;\",I`^W"'B?#S=3C&@Dan1CKjc +$fJQ(+[lfKCo-*q%,hF#+H[+P2?_BO"*!3)?s3nVkRk&d$/r6WO%;,0&/enB&+E[45f""Ned2mu#9ZqW0S9T13sW#2#Co5U0S0JU-jT8o#iM?bEAS8i3=2qZ[_ci!O[L!?8/2_2!$[X?O3S@-=TK+?!9&DC,?,D_Bbg/T(@cA\0m*KU0H)0>)3KIdDo`nqLdCAi5!d"&+UoTW#CoAa0KKL0Q4UmC)X96?a"[4(Pau:[W_pSP0uY,Hi:eZcM9K4rjLDs=o_NR`*V&(=/'=R1h",==*lSX,m[deUi_]#8*KgFG.fR1\"X()[+R1Mln^Se')'Q:++n=(%&cV8HaW7,61a+.i0]`o;3?tgm,P",G1.;9F0dNEI,iKOc+i>U93;(6%rrL=SP%>*.7jbNY-Lu.( ++d"-gM'33')=i:`P(b8;G71'"-:%>_146:r.\A6L*-.](@5ofg:F`Z,.e9hH0YR`8U^XJr*E']qAb;\X#T3-W$NP`.0Q[M^fbP`[?S]^1bRckRE=ah^"*2pEnrYI(e:&$8Y`Y(g!AuQ?aX32$0_0#aEtf&s(_r5T09:]K!Rif5O;25p%WY;MEpk^r3@?N/&7\ZjP<1UB8Mmac +0u6sf_*'Ys3#^7O+/7bhTf4lKZih#F&V2Gk.iTY*q_tj02o=euMhrCiqCiN'3:i7+$0^c;G4!^#g26('F/:#jY,kR"3qKU<1(>F+[6!^,40uaH1TJqTIlqJ\3V/o`'@AsW8AmM9nm4>.Q6nc18i]0_%=8E(R21Us&rq^]!37MMO$E7uF"oG_nR?]lt^Z`Y+/\HTdh5np(f0JF'&a?Ggn9N9D61-ZP*=u2$3'D16>JZhgi^sjM(:@nf(2"WQ0p.J>6:\02u +:D5R[*SPgriUYU#qW*Gs`0!o4%\P?4$/-PS6P2*emN.ONLj#8CJW25O@(Q6'o%-"4[t+OgJc\QJNK0(eQBZM:]2ZS-i;>kDA@d*?$kT?+&EiG%#!+BX5$'B!Rh'[W,'MWkT9;7+PVbokRFtDcJVQ]s*2R@4A01.XDZ=>?qp=2bl&HP22+h#\2FF4j3;/Wha=S*jCdWQK9'g"3P'@bA9pB>2E.:)4!'LA]1PbT,Eq"h$8+MhD=f'c[JGB0s=)3$d.asS;F-645bF8%%O((Xgr[<+?%.lJBqp*!0e&Pcc(QiD)UES3dH]fOd=2en*aaCO\Ha4`?lgPQHflZs_,9\@KeZ>M;]m\J:=Z=O_Ep_.A14_)idWJb=15@=L=Vt6#hR$*l"%"\'nS#f.%#M5=1]+5'5,)\7H9H;DV;0 +Fd!>Yf3l=XSH>%NG(;Ci(klJoFs".]GKYtj!qBgqKfM)K*7rMMPGnU24eBXLi#pVgiJbDiruME&j(GLXA%08=WX)B_U$!QQ=+^7rDEO8/*EfC=e-*\pSp&bU?6&n)tD#@8!&O>X^(pdQ&7.lpTb=*JNiGU[rrM[pYU=*>g@C;^[o +8WjgL&XXk&2`46#rriFo#(T^d,L3RL!8bZ[P-[#0L^7bFl20XZrFblB.M"m*h=I-KWRo&mPMADnC=-JQj$].37h2Uh4:nDNZ$'*H-j9uNLm\!@'udC3;J#;r@aT-9j%^k$Q(t@?_FffOSKbtW]^[!s'+.GLJtG` +TRBma\,u?TH!%YP_#pHTO.SF#X2.B'3ZD2pl3.m')f+%S\N:,f-jAd+Y+)^6"2WI9n?$H2Br2ZiXX^K%Y1IC'[R/UBqm1/U/d71qD"1k2DdI!UU?qnpCVs5UF=br/%\(G!A.bB9ejIi\bf8=gIVB#;A!=$]&9?q0bOXHdC'rlK^(HS&qgOVaf_*N]_g$-UZk03 +ah8YL^%_I[)[jA!l+Gt`^A(-56g0V>ruZ9#_rr$=NFh6PbXN4+kN'cX9&=EF>n`2?,DlgJ*:@5EH&`qMP63;]=`)DjAb\Pb@CH7L[!4d)f=FjioTd!L2]jdOs\W]b^\*IlZ3cc-mC +PYou^>0g6?NH[:G4a^Jf,dF>*5MASZ`Dc$SVME0SeYJtRTej`M;(MtD8/An_au.d,S?^!iQc*eUfa7,!;Ur"FHeu7R$o6?h4gg_N`Ckc-6@a4:3Ji[sEMttZ1pYaUgqdbgNJt(:1LR]NRnFK4+`0Q7-/P>BMumi24#]"Q!XDZ1Fk7?bddOTZll$pNc^FTugl6Ij +3RIaBW4ll=Zl?c$%paFq*57!"]hQN?QTk2&eL6FA4]dJ"Q.=\t*5/?*]rWs%Z0K'*lMe'S5.0^$f>83_NOG$O5.L!o^$C-Fm/GBrg`A0kf6j0bmJ<7mhV7H>UVX\3mf)_r?C\#ZoC'5\m[i065,CI6[k1R>$/X*p2.m%8V3CK^r1:W+HNu8+&b%t^RUMgj8QKlJ-;qA*fkN:P4hlY+:kCb%LE;k6(]iu<%]$tL;"iBGa(rP +'oPN?:MA6q3?=/Nj:W='':IA<:E,lgA5jEdnqBE&dH$MV7,EhrVc2jq)O4'O(op*cFaDP4W?JCqlkUMaL,!2D=mZ`EKs'*G[p/8:)jS_5DhhWe&?Dr$q0]R,lrD^"Es3L"iPO6;<\G>M`g604>V.TO>K:=H(t5p2BgQZLo/[l.:J"3D +A@3>H<-J?VC?rb6*>Zs6dG%*K)kEkP.tOk^1/bR$%sQ"4)0lj#?S7r2k70NmDCJM`3h[)]*A#&T\Jm9tqcJs;O.>9lFgVm)GH\oB?2N]rJcE1uUe/nmbqI\tBP[VhO981P]d\NO!sW^3prnZ#A-A)9n:S^i_+_Y4$QW'^*=YATj-7A*YbN%%`,(m!&#A:q;\63H6s?KQ$>GD9 +2B]XH_hKKpEYc]8=RdIWC[0W&aDrPa+eOocP9ie@A=.eenq4\LUJA`@o\g]1trokjdTZ\(4jYC.>eMp'u%cEA7EACNOn_Z/P9^W*eD#Ip=Or]:aY"A]1We^KGENU0gZoGG[C&B#alQ3j<\5$7pZ9&;l%t+`.jXI+EPhQAfDAS[M21tiU91P'Lc"a>'*4-H9uo;iXSb*f,B-qbGp +&OsrZ>pPB^1u91FBR2"`UF*=5.raOKSrWoDg)bgEC2.k`67ilEIB+Srg$Pn;QUY8*8DZ"_aS./'!6spA6(_\p"KXVilO`Xb@&,mEas&GAgPY9I0HR3>1!e`Nea/mg)Td/qJi@/7L*E,&tPlLG'(36G)lp" +jb4Tj^')L.VM"&ibSEB1*$ffW_0b?ZhLmbAi\;a-V.mHM6XaJ,kB*A[hZR![%;>>`P`HF\':28CQeNm"hh7hrrb*(j/T!>230*i"kPP9Dns7^*!NSr@@ACU`i;TBJ;JWCW[Pjrdf+R[VJd$_46$CQPMp*#Sn5]g_-RMh4H5(6KaJFj::p>nZH6b*4;n(qd!o]9C0C&WRK4o3q +9%]noLo_-)p(UMlj)&7YOarJ"r2IR*9870?,D$c*Y_.=%F@:i2+[poOKTo\,6OGJ3Lfj>,J7sms[0[mP:rks1m69jLBb"*UY`:t[9[=-8\3\@M_"to(@G%E]V4\#9;36;@('1s9W5R^0Y*!Com4ji1;d_$o*"l:#!Yc=TUss=1VEsgfPn**4[Cq?A,a\nMX`%=;qCf>TPIN:pNc/LfL,/b>D0A]?J:41.s_?2)(!n6<:$_`cTss@;[c]pfs`UJe".:bd7lucjH[K.h]1qYg.gZ$>5MP&TcMH3@K_.`Ou(h%$4gk<:1`>'#InHhC=ZoY(E%'*f]\8m63OT9Ok=Y*Agd6!TVlMkg:oS-h;8uEFDCC^r)t1eU8*M +fh,9WngS%jQT9l70VtU%-*L$Ad('rYb)n*7cYc:<=`Qua,st+1MPCe#b_T-fk[e\4;'^EZqkZ]YPt^=Q&F!Gm+e:HjQ$0>X8g6sj_b?tF3j@0B!ErqOCP#QjeP.KR>>sp0Xp&QR=*"+:dcG^N("BH^6W#_%jOe3Y/T!$]\RK1H*h4siI+G1s=t/_["BJPJQA7SY6"QOW"Br4\ +27b&6'^>ipNlW3^r9oW$m'W-1NmZ>?:'ge:$g4r]7!Gfq$$-586JC'b*4OsVBobB-<,R\+qi9!Si*d#,\_lVb?<>,l^@W\mDJ^C%!d/("d+.K6I*X9!ij'bYD.''7;_EmUjK_R0(pVp$(8"7,JYR2,_4 +@59KC0[XmTA1nCjHn\U&")]h&^rX"eQ7d/T_@>/+f+H1FE3+KuJXBPd3e2I4_nJ2d#T.PXj:j$u'qV$(mZWf!eWNrK8I\eKjj+5cY_GVG`T1ph*nt3qXmibb6?b(eS%),CW'`_@^G@V7kAUs'10s'j0rui-*,\eI-DS17/C6A\L44IsiEnf#.[P\NjYg'5AclWHThcNEjJVAK +MQC7D5u:Gl5=7u8<0Sh0jT:4:og8M])t/5/b#cKWkq9`=@A(#/X2%ggQrZ5\!m<^UmrkfouPt,XZ,Ht)D+J0s'_&l;Ue;@P*=B?>,j\dsp:o,6jg>/D;)pg4&\Zn,(@6FgCd#-/8^+,5"=V"T"&f),`gW$@>N^8()]a`p'$Q;f%Jfe9[H[;>i6YFR;\(nF'PqI<2JkY-6IS(Lufs@BoN4dFq,h=kMOYJp!+0gj>B/m[_tAGCJl54-s(1 +7u"s9cILiCc[T%`j26"j\`-X(m1Qhe_0GtOr6Cs77==/J1SOE=`a>3;6N>AUDU8g*'#J"./'*$Z)BSiT_ED?gSX7VO&.r7"94ARh+JGLsC;4*LHPF*4e.el[hm&`9\#`@J;R!O3W;2//=,/FFnXm9sbmn.P[UJ^WrV+S'Ie2t=XfHHTn(H@?A;'EJKSB_5OArdL"Tr,j4;lu@ +$-921s*j.X5M&:&M%cVk"/D9Z]K!l#"._u'f[#_bK2-'6$c!j"m(=C+CQ%6pWb5Jt#re"AqkrkJ8r5R[ZZ4/Kju0#1Fa74_@aA-P<+$q(dk6Ln/GA*uDe;+6mB5h&t$A.LB\'fol%7I4AMr*ViYVT%;"6"&qCFBaQ?DoPm"`bAj$ +GWEAT`.m=9]P>'u9BMYc(5$TAZ,1cGZ(8$upu8'r.4u`1[aW\3.OM9KD`> +5NGQPCek\>@&6hc8$l4;4JYSA]Y?!%`E\TjS>Vi-=?^P(8h=Ml[&Z8V>d)q)7F\$Rr3/g&Ttq.6_-7P6Uj`AkD9H1m95M(1I(2h.\P%i0L-Sa3]I8E2&51\b,eG-fPT,kb7foVV9J"(T4N'oe`CsKO9PhaCI)o!?a\85Gb?OFu\qZ7`'nl5)2'`[C:lVt%(D0k2b3NOB*7P`8 +kQ/W']#2dI=^_B%fh*s/8&5*od4L&/h%3PtKiF($(l#pN-kBu(:+GIqgss+e9"JDIc=p],?m/6[V^si,`^Hdifu/T53=\H>:'Bf3g^V@nK#f1@4$8f4+^mJAFU)V$JS>9XC,a87ou*r%`4VXroU`W6T:^M(P)QXY`:'O=V,/06:b8Qd*3;CVWQsl$cQho$XT64T"ON*9T<#E4 +g_A*5%8bjj:rNdRMnVhEbY]An()2Ha6tt%#'iA)t2q6$6ZeGU+(!$17bk'&jO@R^?'nGZm(fRn**9N"/@0/S9:nnNJ8Q3_;7_OJ0OJLYEdmsK[.1^)?d]D?QBSAdoj$%bu7PNjnHW&$i@8a$PdPCcUV)/r%[*lH`dqV&Th$-GF!74s":D?mW4K'257*0.A]EgZ!q%^4):9a)S +&>Ygfe=Fq/Thj>fcft7%laP>!VpI:n<3-8GA5tn.3_:n.;p5]tKh57no2Q3*:p^b[ohs:nue!C52_&@J.pK?'nca".^[O6M2bBj%Zsj^B"]RV]<)#e7V+)>n7iB!@'`ohe]5H,+Qc=]tVog:^3N@S-;7di^Pl0iM +E@nN$G?2V=f$Lp-i:b:0%0fP8-rCT./N\a'NQ@L\Jb?W)]ibg#G;%Y%L&k]b28EDs7b5+Kf$/c$bJm#R\5L!I=rY:['^O99\C`BcO^#)HSK\+q"T[)u4ih:tAVgrZME?docc(g='o^eqNJH=jf_(?^IFq$&JlNct>]g'PQ,VE.Q!>!b=`*".h3]\*R9gVt?7k2+m@7A9=P%,Z +hIt`D]/\LM;VMblDccq#qi?93]Bt%rK"\e\8=n,i`R'[BdCXPLh*'7n8:FiJ<7pS9?&fk4^#)c6 +*5+NE]/AAA?'@C):gdeKiSGaaA`0G.iSmktibg,*`T45ISR0Sk%GZH^+ALk<,N7pgg+Fl7pu:/be-I!FQ4[t@*ND3.i=T477h)H/`NG>/YMqNrhhW-,R($G$m9dG**M?"VlJGt9#.u)JOHG6)-(W,#$F&q$Prg=&TSDBE(#XcM@$sg7i(mbC9hMiH4"_!%"s;W[b#@DT3cTjD +q&9`))S1'ZEI +"QkI&]2?KnG@$D?5T5l>@25]m>JVY3N])49h9tO_Q">\Q)1Gb'IMh3_UZf^dBs(oIjUUCY]4o0nl.&==k*o!ZT0'c\l0]Dp*gnLJ!U<Xs30=W'C84W2dd*$#_J%Y+iP-@0B'JCC[!'*f^ss]2#%,ClB%naPH)D7ql;`D6B23p8H+4cQA1hmI&k7[\-IJd(>=rm(Ls"g^?faWlL*G'C::sg(%9e7mboX/R8_R"C2N+sjh:7#4Q10T.p&ji\?jC,juQQp +[3%!kf"ppi'Cu._=PfV:J:2I1%!i"4.@=)q%]2#3YI'915QR:QoFL^2!-o3LAI0qa"[i3>a>s0!bVb$^Bfgk$&CXALf6)1GkTBh%(gPIgMfLMl2"Q_&Su6ok?1aRDcDM> +i!+$U8*8hTi),dT)"F4Yo4Kj@`uKb%qp=JqD+P'[$b<^>&;8)E7JBoD(F;Za-MLb=Edp'PY<$i&H$>kBn`LkcY8_Z!SF[8;DPo=7[7>HErp!!&l=bnl/XN:6`Qst@(IO_?Q"$m(pn"b+-q=YC3nJf'fd/"bb*;3-LCPOMTH-c^t@6T0UF)QVQhU*'%dWX4_m6;&'nHE(m[p"YP&5XSJGd[9),S0'[`:nG%]UiuTKm6r^GON:nq4.:\@.PT?r"8dQ,bb,p^a3(#Eqb'qQD+3EIrfPAr3+:h-\gte(9C;fp^=[DTi9C$&Vupg +Gf^;;hO=6*UpPoS&>AXl_'p*M2@u\%H!^X7Z#Q(TBF*KGaAe,-8"5nYcbV?S\iO[W1CHgW6'cc0BJdpgTm'o^S.+eFHAki:rB3miTkB;KZ8pL:EDQ\W%_+8L6PCu'85?C:NSg13WfcOQZuIbsB,,Y8VQIt%I)A3E+i,?u?Un-ZaV5u:f(#/SZ6+U+LBS1+f^d(D!46VuL$oW+&n5nLt3*(^d;8gI*T/WX,eogLJ&pD:hC'*t,I +B[gf46cp*[*N7?GJKW$3*/LK4dQEVS/-1\.[#9iIDNB_hS,T\,`@CGlb+Q'>91EbC2MiLh(hGJ;iagF^_o:]i/V:qMi8_jdXQ_YZ1VCI7$o?\o8PdT?(BVA3>mT.4jZO1FPI+S&M$S3MQMiT%RuWB@:]$TJKll,*>uT4r6HG'@EALM)ki'uic-=Tu0qT!se=adbqHZ$D&!U]& +^@/u3LRpC$ar*#[2CdcdE!K +`Yn4^kFeYb`c1ZN.<(cPc,r4drD@geel8(La^Sc[p,g%rH(rPp$*ObODk'b=N%]OnH:A.L?Z;'S%eF*me>T6%I9M`!Pn20*Fil(S2s4OnHe:e`USO_MoN0D%hS8kW +@!q`Th=OKfdrBHiUcc9l2ePH$VqeM7eepCt7aJ>ejpuFam\Oq@l0u>tO3-L`UVG1GY3'PEU:bA[L6<#GSDBut^63[`Rc!#(Z$)mi_EVSd-QjXf?OfZe'd>u6KM2hG#&SaaG0Y,"\CZ>JD@@R?[g(cB*-B6Z4i.nfh-hQTKZH=&_O+=1TM-qkd(U>a(hF,uZIO\fiYt7-XU\dh +4bqCe+>#R#;IU%sL2dtS7$s5Piabc?d68s;[IFLJF/TJNZ6>o-E>I#F+V/?ks1<=_&DY3$6N\Mh-K-0fb%t[2`EAZf?qc'eP]_iE2<,#(g]c`rjH%]NbFI);#:(P2+#)6Y";qo'hWScoK/uOE0_$FJ0hrdq?2#7fI4!+,6'EZfpb.1I.+<,PPf'M#8-^9RKS"(tTRl\[8'i:* +Eh\br:/rPVP7LKc%"ZdB-5hikVE9_UB)#=a\Hr[hYXU5=096>fG>`O^e`&PV]9]:F,WN:\q.5PWh"OH*gSi"VjbL:5hjZQo/R;r;t1g7F6^>pV5P5FV_qF[(VNa?7e\8O:.O>b.]lgL.hRlj>qd*_Xg7A#DTjlt-Z4CYJS'fh@ri4p:s"0.qZWdMNO(aHW6\_muk[;H=TSek@P<\Kr7*rrliU7q_<=;g!*jm$'$[<>qG\V.-O'ZDMR[es>p<-Z_;5EOEqa.DSN$L<]UR^Ouh?-F%8n72j0'I*k.XP@Y\X^d^.pGD!UJtP$mU#QPa?:7`H2c&&\)[gb6OBoh1%s'$0^FVKif9^6.Js]edHb8m7\t6&!euaO4C0(B9u*TL$YVPRfImaSYpirlUmsAp]8E[Uk0)oA?!p/mJS/iBK5S9!YrgH.($BVt_n9bDqj@KPWT/&H +Hs[K_=#]O4cR7_9"SFY[cQA'(K=Y4N,`[FK;(c9-:[b`WcmEqt5+UB=5RLa0n_^Lg*mfW*4Ud/3b?]s/D= +hJdEujr]&c;1Iaqr@b>@7(QCC-G_*D]rh"RaB[%!kka>*Fhq7NWBS\4.':fK!t+,^Y-a;kK"PfV[$)EmtBI0;TU-d]EZ!47egR,>iFO0pK&(r]+@%KgY25X#Jr6[$6P4'"B;m(!kfQUDb=&A?WNm/B9-Pn-nKb[`103iEi2cA&)lfD<11p&s,#s33-P7IN&!nIh??`'( +Ak(:7@4<)"M^ZNI+#2-rTt(Af_c#AE;WfZqlRlrh0%0>E;YMi-q^umK.['rg6HT]-$K861s+*.Sk@9"lc/fphD\?a7"EX2tm1'5PY1QssY'8JB:N28q/1t*^1ZK;S%RlAff0i7g#aHC7LR4l[`\H,bj_&YV$Y!Nc,2$gjt1;c5!8/!1WBam5S^bbT#XqT&O;p.\\Rn;,%8ee$Re)O&"X%Lgh54l$O<4>MZ%-hqQ9E6Y'P[s@W-VQ>t8#.4]oZp6q'1**8-5%CpZ_9@a>:jnt6^(di`MVR5&KjiH/TaZZF)rp(//mha +:33#O;f+1)@`[(5+B3D6P]f[+dm%kl*&Af^iJg$CN&#L:Xn7rZ;SPl492sG;<>9jRPuC\J>!^ZEcnl=O^(Z'&=lH!Ei;'bLIIlcA=or^43O:/TiI+omo>jCFXkr?5)j-_\H,W +X]0H3/6-=i$%&X5((:7@]iR-2/CoMJ#a%0S)bK#7F:QgsmDoB*mMIbSFG'U.$)qZ>nSB"KFr+XAG-c?nCL&G*G1UeZ6nT$U:!9!)e=*]7a*"d[G?>N0=;J]]Bn;Wmd5JUg(ai\0VZrjB%4*&$?pfR4JQF)g#+.ak96q00_AZ>M]@S/1=BBTGRP)(96$Q[K(S<93#.qn)bu`RaLu_N, +=]9K44dWN6(V'&!4OtY$M$')sJ4!t&04hPt:j-81KdNH'dKqn:LK"bl/A-sN,8#Nm8uP^te:8@/)iVdJ2iih#kiI,TDgsOgIq-N9e=(%&XpH>=]U+9Yorgs^$V<;g<*1T2=U0MF*KZ[!DO;`4)&H8_'p4n+433VIA13MTaL=HiXKkG2YBl,J]d@.H%Cnij=\"^:'9f@]U^.5> +O^u">*l4WS"@3N005Z'\tM_7V5,$/?eVW_>.:1DYq;ETT,PDE1]mFgRrl=/\9c8]&Bb0je:Dm<]]WO>5'QdnLV9IXP3WW<2Hf; +qlk.rYe(RR>8OQ58[.d3Z+;ftoA?i7A$U5OZF_omgFi'o2*@?gZkM]14$u*a4g`s>[2W$q4%TN9@4rI9t,JM]+W`*)mcUBVn:]u]GducLekZEhn49q]XrI%oBX(OgRanc=o5D: +)s6-A\%\$I^"`.n>PF3umV\NiYWMe7gY9MJ&\o@sO?URCY/&L'p_]1JM>W9Qj42]i<`#M._>Xu`&9>oU]`>hgq>Z\n7>K,B)`Z/L.>\D'HCW>.J`uK0@>^+5YHcOoka;fiR>_gCjMoa\7aW-Md>aNR&S&sHXarI2!>c5`7X305$b8dk3>dqnH]?B!E +bT+OE>fY'YbKSbfboG3W>h@5jgWeO2c5bli>j'D&ld";ScQ)Q&>kcR7qp4'tclE58>mJ`I$dd]?d2`nJ>o1nZ)q!I`dN'R\>pn'k/(36,diC6n>rU6'44E"Me/^p+>tLhP:efA8O?"_`ZCY%<[f,\qa?$FnkHe7)'fH#Us?&.('MqHjHfc?:0?'j68 +S(ZVig)ZsB?)QDIX4lC5gE!WT?+8RZ]A)/Vg`=;f?,t`kbM:q"h&Xu#?.[o'gYL]ChAtY5?0C(8le^Idh];=G?2*6Iqqp60i#W!Y?3fD[$fKkPi>rZk?5MRl)r]WqiZ9?(?74a(/)oD=iuU#:?8po946,0^j;p\L?:X(J9B=r*jW7@^?NO^KjrS$p?>&DlCZaJlk8n^- +??bS(Hfs78kT5B??AIa9Ms0#YkoQ&Q?C0oJS*Ae%l5l_c?Dm([X6SQFlQ3Cu?FT6l]Be=gllO(2?H;E(bO"*3m2jaD?J"S9g[3kTmN1EV?K^aJlgEWumiM)h?MEo[qsWDAn/hc%?O-(m$h3$anK/G7?Pi7))tDf-nfK+I?RPE:/+VRNo,fd[?T7SK47h>ooH-Hm?Usa\9D%+; +ocI-*?WZom>P6l\p)df7Kg\p$erZC2"?g%E\li,f1ru^k4?haSmqu=M5s+*GnOB==\&IF.XiK2]64s:Mp7,j>2ZsGI)NCMrj +f^sVY+d#=VP$'W5;(7c&jc\;=^0raa9]hOA[,,d_SPJ@3g%>8p6(q-=PZfpcO\)BIl'0nE5+tiQ<9f`P[9g+@X]FbQg@]p2@Bir$QX(B>jdq_[GLG!]jC/og\(RIJ\ba`Qs;Nk&W+J9nX/*T59Z02AFc-n[U1bWc"?R8h"H4`U![QGRU%hD;5r)\opX][ +^L=D#D"a?([bl)8h/;tVh=gl"_;TA.S6e,rOic^*q4-;c5G?KhFS_P7[pQDnm<8AthY2N9iUM0jSmOFKdHU=MrLVnj^Z"_YI/]aF\)6`OrI4d=ht-jJ5VNlW!^NtH%g50P<#5a)Y]Lrm684WO$::u(0+:3%e2Ik)Yk1-k6noBG&k&u]:D?5P<*'i(Z#j=i7PU-?)Fh!=D]D8% +e9;s(Z1NMg82:m7,"T!rO!I:P<0nq'Z?2]e8huX/.S@"PL4Fd~> +EI + \ No newline at end of file diff --git a/kernel/src/test/resources/com/itextpdf/kernel/pdf/fonts/NOTICE.txt b/kernel/src/test/resources/com/itextpdf/kernel/pdf/fonts/NOTICE.txt index 1bd55b66cb..adbfd10344 100644 --- a/kernel/src/test/resources/com/itextpdf/kernel/pdf/fonts/NOTICE.txt +++ b/kernel/src/test/resources/com/itextpdf/kernel/pdf/fonts/NOTICE.txt @@ -10,3 +10,4 @@ This software uses the following test resources under the following licenses: | cmr10.pfb | SIL OFL-1.1 | LICENSE-SIL-1.1.txt | https://www.ams.org/arc/resources/amsfonts-about.html (13.09.2023) | cmr10.pfm | SIL OFL-1.1 | LICENSE-SIL-1.1.txt | https://www.ams.org/arc/resources/amsfonts-about.html (13.09.2023) | SourceHanSansHW-Regular.otf | LICENCE-SIL-1.1.txt | https://github.com/adobe-fonts/source-han-sans/releases/tag/2.004R (File: Static Language Specific OTFs, path in zip folder:OTF/japanesHW) (07.09.2023) +| glyphs.ttf, glyphs-fmt-6.ttf | MIT | Derived from https://github.com/RazrFalcon/ttf-parser/tree/337e7d1c08b06478a84c4345f4f289fc2cb9210c/tests/fonts-src diff --git a/kernel/src/test/resources/com/itextpdf/kernel/pdf/fonts/glyphs-fmt-6.ttf b/kernel/src/test/resources/com/itextpdf/kernel/pdf/fonts/glyphs-fmt-6.ttf new file mode 100644 index 0000000000..941a4cd173 Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/pdf/fonts/glyphs-fmt-6.ttf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/pdf/fonts/glyphs.ttf b/kernel/src/test/resources/com/itextpdf/kernel/pdf/fonts/glyphs.ttf new file mode 100644 index 0000000000..60436aeb3c Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/pdf/fonts/glyphs.ttf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/pdf/layer/PdfLayerTest/cmp_output_layered_2.pdf b/kernel/src/test/resources/com/itextpdf/kernel/pdf/layer/PdfLayerTest/cmp_output_layered_2.pdf new file mode 100644 index 0000000000..92af7c8e89 Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/pdf/layer/PdfLayerTest/cmp_output_layered_2.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/pdf/layer/PdfLayerTest/input_complex_layers.pdf b/kernel/src/test/resources/com/itextpdf/kernel/pdf/layer/PdfLayerTest/input_complex_layers.pdf new file mode 100644 index 0000000000..4dbe49cf99 Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/pdf/layer/PdfLayerTest/input_complex_layers.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/pdf/xobject/GetImageBytesTest/SUP4582.pdf b/kernel/src/test/resources/com/itextpdf/kernel/pdf/xobject/GetImageBytesTest/SUP4582.pdf deleted file mode 100644 index 630fd83910..0000000000 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/pdf/xobject/GetImageBytesTest/SUP4582.pdf and /dev/null differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/pdf/xobject/GetImageBytesTest/separationCSWithDeviceCMYKAsAlternative.png b/kernel/src/test/resources/com/itextpdf/kernel/pdf/xobject/GetImageBytesTest/separationCSWithDeviceCMYKAsAlternative.png deleted file mode 100644 index 56403e86cf..0000000000 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/pdf/xobject/GetImageBytesTest/separationCSWithDeviceCMYKAsAlternative.png and /dev/null differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/pdf/xobject/GetImageBytesTest/separationCSWithDeviceRgbAsAlternative-clean.pdf b/kernel/src/test/resources/com/itextpdf/kernel/pdf/xobject/GetImageBytesTest/separationCSWithDeviceRgbAsAlternative-clean.pdf deleted file mode 100644 index 2421f078ab..0000000000 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/pdf/xobject/GetImageBytesTest/separationCSWithDeviceRgbAsAlternative-clean.pdf and /dev/null differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/pdf/xobject/GetImageBytesTest/testSeparationRemovedCSWithDeviceRGBAsAlternative.png b/kernel/src/test/resources/com/itextpdf/kernel/pdf/xobject/GetImageBytesTest/testSeparationRemovedCSWithDeviceRGBAsAlternative.png deleted file mode 100644 index dd87c48276..0000000000 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/pdf/xobject/GetImageBytesTest/testSeparationRemovedCSWithDeviceRGBAsAlternative.png and /dev/null differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/pdf/xobject/PdfImageXObjectTest/indexed1BpcImage.png b/kernel/src/test/resources/com/itextpdf/kernel/pdf/xobject/PdfImageXObjectTest/indexed1BpcImage.png deleted file mode 100644 index 570cfc97e5..0000000000 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/pdf/xobject/PdfImageXObjectTest/indexed1BpcImage.png and /dev/null differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/pdf/xobject/PdfImageXObjectTest/rgbWithoutSaveColorProfile.png b/kernel/src/test/resources/com/itextpdf/kernel/pdf/xobject/PdfImageXObjectTest/rgbWithoutSaveColorProfile.png deleted file mode 100644 index 8fdd680eb6..0000000000 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/pdf/xobject/PdfImageXObjectTest/rgbWithoutSaveColorProfile.png and /dev/null differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/utils/PdfMergerTest/cmp_mergedResult04.pdf b/kernel/src/test/resources/com/itextpdf/kernel/utils/PdfMergerTest/cmp_mergedResult04.pdf index f362958bff..6bbe3fdc55 100644 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/utils/PdfMergerTest/cmp_mergedResult04.pdf and b/kernel/src/test/resources/com/itextpdf/kernel/utils/PdfMergerTest/cmp_mergedResult04.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/utils/PdfMergerTest/cmp_mergedTags.pdf b/kernel/src/test/resources/com/itextpdf/kernel/utils/PdfMergerTest/cmp_mergedTags.pdf new file mode 100644 index 0000000000..e0c63b3f78 Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/utils/PdfMergerTest/cmp_mergedTags.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/utils/PdfMergerTest/cmp_pdfWithCycleRefInParentTag.pdf b/kernel/src/test/resources/com/itextpdf/kernel/utils/PdfMergerTest/cmp_pdfWithCycleRefInParentTag.pdf new file mode 100644 index 0000000000..666750776c Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/utils/PdfMergerTest/cmp_pdfWithCycleRefInParentTag.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/utils/PdfMergerTest/pdfWithCycleRefInParentTag.pdf b/kernel/src/test/resources/com/itextpdf/kernel/utils/PdfMergerTest/pdfWithCycleRefInParentTag.pdf new file mode 100644 index 0000000000..4f08885bc3 Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/utils/PdfMergerTest/pdfWithCycleRefInParentTag.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/utils/PdfMergerTest/tagRootKidsDoc1.pdf b/kernel/src/test/resources/com/itextpdf/kernel/utils/PdfMergerTest/tagRootKidsDoc1.pdf new file mode 100644 index 0000000000..102a320161 Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/utils/PdfMergerTest/tagRootKidsDoc1.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/utils/PdfMergerTest/tagRootKidsDoc2.pdf b/kernel/src/test/resources/com/itextpdf/kernel/utils/PdfMergerTest/tagRootKidsDoc2.pdf new file mode 100644 index 0000000000..a07b23bd54 Binary files /dev/null and b/kernel/src/test/resources/com/itextpdf/kernel/utils/PdfMergerTest/tagRootKidsDoc2.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/utils/flatteningTest/remove_quadPoints.pdf b/kernel/src/test/resources/com/itextpdf/kernel/utils/flatteningTest/remove_quadPoints.pdf deleted file mode 100644 index cbd8c63cdf..0000000000 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/utils/flatteningTest/remove_quadPoints.pdf and /dev/null differ diff --git a/layout/pom.xml b/layout/pom.xml index 28d0d9b7ac..3fab729316 100644 --- a/layout/pom.xml +++ b/layout/pom.xml @@ -5,7 +5,7 @@ com.itextpdf root - 8.0.5 + 9.0.0 layout diff --git a/layout/src/main/java/com/itextpdf/layout/Document.java b/layout/src/main/java/com/itextpdf/layout/Document.java index f6a674ebf6..c57c1d279a 100644 --- a/layout/src/main/java/com/itextpdf/layout/Document.java +++ b/layout/src/main/java/com/itextpdf/layout/Document.java @@ -297,7 +297,7 @@ public Rectangle getPageEffectiveArea(PageSize pageSize) { public T1 getDefaultProperty(int property) { switch (property) { case Property.FONT: - if (getPdfDocument().getConformanceLevel() != null) { + if (getPdfDocument().getConformance().isPdfAOrUa()) { return (T1) (Object) getPdfDocument().getDefaultFont(); } return super.getDefaultProperty(property); diff --git a/layout/src/main/java/com/itextpdf/layout/ElementPropertyContainer.java b/layout/src/main/java/com/itextpdf/layout/ElementPropertyContainer.java index 545f170fc5..4d69e2da30 100644 --- a/layout/src/main/java/com/itextpdf/layout/ElementPropertyContainer.java +++ b/layout/src/main/java/com/itextpdf/layout/ElementPropertyContainer.java @@ -22,8 +22,8 @@ This file is part of the iText (R) project. */ package com.itextpdf.layout; -import com.itextpdf.kernel.colors.Color; import com.itextpdf.commons.actions.sequence.AbstractIdentifiableElement; +import com.itextpdf.kernel.colors.Color; import com.itextpdf.kernel.font.PdfFont; import com.itextpdf.kernel.pdf.canvas.PdfCanvasConstants; import com.itextpdf.layout.borders.Border; @@ -443,7 +443,10 @@ public T setBackgroundImage(List imagesList) { * @return this Element. */ public T setBorder(Border border) { - setProperty(Property.BORDER, border); + setProperty(Property.BORDER_TOP, border); + setProperty(Property.BORDER_RIGHT, border); + setProperty(Property.BORDER_BOTTOM, border); + setProperty(Property.BORDER_LEFT, border); return (T) (Object) this; } @@ -498,7 +501,10 @@ public T setBorderLeft(Border border) { * @return this Element. */ public T setBorderRadius(BorderRadius borderRadius) { - setProperty(Property.BORDER_RADIUS, borderRadius); + setProperty(Property.BORDER_BOTTOM_LEFT_RADIUS, borderRadius); + setProperty(Property.BORDER_BOTTOM_RIGHT_RADIUS, borderRadius); + setProperty(Property.BORDER_TOP_LEFT_RADIUS, borderRadius); + setProperty(Property.BORDER_TOP_RIGHT_RADIUS, borderRadius); return (T) (Object) this; } @@ -638,23 +644,23 @@ public T setStrokeWidth(float strokeWidth) { } /** - * Switch on the simulation of bold style for a font. + * Simulates bold style for a font. * Be aware that using correct bold font is highly preferred over this option. * * @return this element */ - public T setBold() { + public T simulateBold() { setProperty(Property.BOLD_SIMULATION, true); return (T) (Object) this; } /** - * Switch on the simulation of italic style for a font. + * Simulates italic style for a font. * Be aware that using correct italic (oblique) font is highly preferred over this option. * * @return this element */ - public T setItalic() { + public T simulateItalic() { setProperty(Property.ITALIC_SIMULATION, true); return (T) (Object) this; } diff --git a/layout/src/main/java/com/itextpdf/layout/RootElement.java b/layout/src/main/java/com/itextpdf/layout/RootElement.java index c3c4b5d63e..e0db090d04 100644 --- a/layout/src/main/java/com/itextpdf/layout/RootElement.java +++ b/layout/src/main/java/com/itextpdf/layout/RootElement.java @@ -24,7 +24,6 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.font.PdfFont; import com.itextpdf.kernel.font.PdfFontFactory; -import com.itextpdf.kernel.pdf.IsoKey; import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.canvas.PdfCanvasConstants; import com.itextpdf.kernel.pdf.tagging.StandardRoles; @@ -47,6 +46,7 @@ This file is part of the iText (R) project. import com.itextpdf.layout.splitting.DefaultSplitCharacters; import com.itextpdf.layout.splitting.ISplitCharacters; import com.itextpdf.layout.tagging.LayoutTaggingHelper; +import com.itextpdf.layout.validation.context.LayoutValidationContext; import java.io.Closeable; import java.io.IOException; @@ -365,7 +365,7 @@ private static void traverseAndCallIso(PdfDocument pdfDocument, IRenderer render if (renderer == null) { return; } - pdfDocument.checkIsoConformance(renderer, IsoKey.LAYOUT); + pdfDocument.checkIsoConformance(new LayoutValidationContext(renderer)); List renderers = renderer.getChildRenderers(); if (renderers == null) { return; diff --git a/layout/src/main/java/com/itextpdf/layout/borders/Border.java b/layout/src/main/java/com/itextpdf/layout/borders/Border.java index 96f9af3519..66e44f1880 100644 --- a/layout/src/main/java/com/itextpdf/layout/borders/Border.java +++ b/layout/src/main/java/com/itextpdf/layout/borders/Border.java @@ -22,14 +22,15 @@ This file is part of the iText (R) project. */ package com.itextpdf.layout.borders; -import com.itextpdf.io.logs.IoLogMessageConstant; import com.itextpdf.commons.utils.MessageFormatUtil; +import com.itextpdf.io.logs.IoLogMessageConstant; import com.itextpdf.kernel.colors.Color; import com.itextpdf.kernel.colors.ColorConstants; import com.itextpdf.kernel.geom.Point; import com.itextpdf.kernel.geom.Rectangle; import com.itextpdf.kernel.pdf.canvas.PdfCanvas; import com.itextpdf.layout.properties.TransparentColor; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -524,11 +525,18 @@ protected void drawDiscontinuousBorders(PdfCanvas canvas, Rectangle boundingRect clipPoint1 = getIntersectionPoint(new Point(x1 - borderWidthBefore, y1 + width), new Point(x1, y1), new Point(x0, y0), new Point(x0 + 10, y0)); clipPoint2 = getIntersectionPoint(new Point(x2 + borderWidthAfter, y2 + width), new Point(x2, y2), new Point(x3, y3), new Point(x3 - 10, y3)); - if (clipPoint1.x > clipPoint2.x) { + if (clipPoint1.getX() > clipPoint2.getX()) { clipPoint = getIntersectionPoint(new Point(x1 - borderWidthBefore, y1 + width), clipPoint1, clipPoint2, new Point(x2 + borderWidthAfter, y2 + width)); - canvas.moveTo(x1 - borderWidthBefore, y1 + width).lineTo(clipPoint.x, clipPoint.y).lineTo(x2 + borderWidthAfter, y2 + width).lineTo(x1 - borderWidthBefore, y1 + width); + canvas.moveTo(x1 - borderWidthBefore, y1 + width) + .lineTo(clipPoint.getX(), clipPoint.getY()) + .lineTo(x2 + borderWidthAfter, y2 + width) + .lineTo(x1 - borderWidthBefore, y1 + width); } else { - canvas.moveTo(x1 - borderWidthBefore, y1 + width).lineTo(clipPoint1.x, clipPoint1.y).lineTo(clipPoint2.x, clipPoint2.y).lineTo(x2 + borderWidthAfter, y2 + width).lineTo(x1 - borderWidthBefore, y1 + width); + canvas.moveTo(x1 - borderWidthBefore, y1 + width) + .lineTo(clipPoint1.getX(), clipPoint1.getY()) + .lineTo(clipPoint2.getX(), clipPoint2.getY()) + .lineTo(x2 + borderWidthAfter, y2 + width) + .lineTo(x1 - borderWidthBefore, y1 + width); } canvas.clip().endPath(); @@ -560,11 +568,22 @@ protected void drawDiscontinuousBorders(PdfCanvas canvas, Rectangle boundingRect clipPoint1 = getIntersectionPoint(new Point(x1 + width, y1 + borderWidthBefore), new Point(x1, y1), new Point(x0, y0), new Point(x0, y0 - 10)); clipPoint2 = getIntersectionPoint(new Point(x2 + width, y2 - borderWidthAfter), new Point(x2, y2), new Point(x3, y3), new Point(x3, y3 - 10)); - if (clipPoint1.y < clipPoint2.y) { + if (clipPoint1.getY() < clipPoint2.getY()) { clipPoint = getIntersectionPoint(new Point(x1 + width, y1 + borderWidthBefore), clipPoint1, clipPoint2, new Point(x2 + width, y2 - borderWidthAfter)); - canvas.moveTo(x1 + width, y1 + borderWidthBefore).lineTo(clipPoint.x, clipPoint.y).lineTo(x2 + width, y2 - borderWidthAfter).lineTo(x1 + width, y1 + borderWidthBefore).clip().endPath(); + canvas.moveTo(x1 + width, y1 + borderWidthBefore) + .lineTo(clipPoint.getX(), clipPoint.getY()) + .lineTo(x2 + width, y2 - borderWidthAfter) + .lineTo(x1 + width, y1 + borderWidthBefore) + .clip() + .endPath(); } else { - canvas.moveTo(x1 + width, y1 + borderWidthBefore).lineTo(clipPoint1.x, clipPoint1.y).lineTo(clipPoint2.x, clipPoint2.y).lineTo(x2 + width, y2 - borderWidthAfter).lineTo(x1 + width, y1 + borderWidthBefore).clip().endPath(); + canvas.moveTo(x1 + width, y1 + borderWidthBefore) + .lineTo(clipPoint1.getX(), clipPoint1.getY()) + .lineTo(clipPoint2.getX(), clipPoint2.getY()) + .lineTo(x2 + width, y2 - borderWidthAfter) + .lineTo(x1 + width, y1 + borderWidthBefore) + .clip() + .endPath(); } canvas.clip().endPath(); @@ -596,11 +615,18 @@ protected void drawDiscontinuousBorders(PdfCanvas canvas, Rectangle boundingRect clipPoint1 = getIntersectionPoint(new Point(x1 + borderWidthBefore, y1 - width), new Point(x1, y1), new Point(x0, y0), new Point(x0 - 10, y0)); clipPoint2 = getIntersectionPoint(new Point(x2 - borderWidthAfter, y2 - width), new Point(x2, y2), new Point(x3, y3), new Point(x3 + 10, y3)); - if (clipPoint1.x < clipPoint2.x) { + if (clipPoint1.getX() < clipPoint2.getX()) { clipPoint = getIntersectionPoint(new Point(x1 + borderWidthBefore, y1 - width), clipPoint1, clipPoint2, new Point(x2 - borderWidthAfter, y2 - width)); - canvas.moveTo(x1 + borderWidthBefore, y1 - width).lineTo(clipPoint.x, clipPoint.y).lineTo(x2 - borderWidthAfter, y2 - width).lineTo(x1 + borderWidthBefore, y1 - width); + canvas.moveTo(x1 + borderWidthBefore, y1 - width) + .lineTo(clipPoint.getX(), clipPoint.getY()) + .lineTo(x2 - borderWidthAfter, y2 - width) + .lineTo(x1 + borderWidthBefore, y1 - width); } else { - canvas.moveTo(x1 + borderWidthBefore, y1 - width).lineTo(clipPoint1.x, clipPoint1.y).lineTo(clipPoint2.x, clipPoint2.y).lineTo(x2 - borderWidthAfter, y2 - width).lineTo(x1 + borderWidthBefore, y1 - width); + canvas.moveTo(x1 + borderWidthBefore, y1 - width) + .lineTo(clipPoint1.getX(), clipPoint1.getY()) + .lineTo(clipPoint2.getX(), clipPoint2.getY()) + .lineTo(x2 - borderWidthAfter, y2 - width) + .lineTo(x1 + borderWidthBefore, y1 - width); } canvas.clip().endPath(); @@ -632,11 +658,18 @@ protected void drawDiscontinuousBorders(PdfCanvas canvas, Rectangle boundingRect clipPoint1 = getIntersectionPoint(new Point(x1 - width, y1 - borderWidthBefore), new Point(x1, y1), new Point(x0, y0), new Point(x0, y0 + 10)); clipPoint2 = getIntersectionPoint(new Point(x2 - width, y2 + borderWidthAfter), new Point(x2, y2), new Point(x3, y3), new Point(x3, y3 + 10)); - if (clipPoint1.y > clipPoint2.y) { + if (clipPoint1.getY() > clipPoint2.getY()) { clipPoint = getIntersectionPoint(new Point(x1 - width, y1 - borderWidthBefore), clipPoint1, clipPoint2, new Point(x2 - width, y2 + borderWidthAfter)); - canvas.moveTo(x1 - width, y1 - borderWidthBefore).lineTo(clipPoint.x, clipPoint.y).lineTo(x2 - width, y2 + borderWidthAfter).lineTo(x1 - width, y1 - borderWidthBefore); + canvas.moveTo(x1 - width, y1 - borderWidthBefore) + .lineTo(clipPoint.getX(), clipPoint.getY()) + .lineTo(x2 - width, y2 + borderWidthAfter) + .lineTo(x1 - width, y1 - borderWidthBefore); } else { - canvas.moveTo(x1 - width, y1 - borderWidthBefore).lineTo(clipPoint1.x, clipPoint1.y).lineTo(clipPoint2.x, clipPoint2.y).lineTo(x2 - width, y2 + borderWidthAfter).lineTo(x1 - width, y1 - borderWidthBefore); + canvas.moveTo(x1 - width, y1 - borderWidthBefore) + .lineTo(clipPoint1.getX(), clipPoint1.getY()) + .lineTo(clipPoint2.getX(), clipPoint2.getY()) + .lineTo(x2 - width, y2 + borderWidthAfter) + .lineTo(x1 - width, y1 - borderWidthBefore); } canvas.clip().endPath(); diff --git a/layout/src/main/java/com/itextpdf/layout/element/Cell.java b/layout/src/main/java/com/itextpdf/layout/element/Cell.java index 357c83aff9..9119a9cc63 100644 --- a/layout/src/main/java/com/itextpdf/layout/element/Cell.java +++ b/layout/src/main/java/com/itextpdf/layout/element/Cell.java @@ -177,7 +177,10 @@ public Cell clone(boolean includeContent) { @Override public T1 getDefaultProperty(int property) { switch (property) { - case Property.BORDER: + case Property.BORDER_TOP: + case Property.BORDER_RIGHT: + case Property.BORDER_BOTTOM: + case Property.BORDER_LEFT: return (T1) (Object) DEFAULT_BORDER; case Property.PADDING_BOTTOM: case Property.PADDING_LEFT: diff --git a/layout/src/main/java/com/itextpdf/layout/element/ILargeElement.java b/layout/src/main/java/com/itextpdf/layout/element/ILargeElement.java index f377b93c7f..e3d1a59e19 100644 --- a/layout/src/main/java/com/itextpdf/layout/element/ILargeElement.java +++ b/layout/src/main/java/com/itextpdf/layout/element/ILargeElement.java @@ -50,8 +50,11 @@ public interface ILargeElement extends IElement { void flush(); /** - * Flushes the content which has just been added to the document. - * This is a method for internal usage and is called automatically by the document. + * Writes to the output document the content which has just been added to it. + * + *

+ * This method is called automatically for the newly added {@link ILargeElement} to be immediately placed + * in the page contents after it is added to the {@link Document}, so it shouldn't be used in any other places. */ void flushContent(); diff --git a/layout/src/main/java/com/itextpdf/layout/element/Table.java b/layout/src/main/java/com/itextpdf/layout/element/Table.java index 772b068288..6144246f8e 100644 --- a/layout/src/main/java/com/itextpdf/layout/element/Table.java +++ b/layout/src/main/java/com/itextpdf/layout/element/Table.java @@ -746,10 +746,6 @@ public void flush() { } } - /** - * Flushes the content which has just been added to the document. - * This is a method for internal usage and is called automatically by the document. - */ @Override public void flushContent() { if (lastAddedRowGroups == null || lastAddedRowGroups.isEmpty()) @@ -787,16 +783,13 @@ public void setDocument(Document document) { public List getLastRowBottomBorder() { List horizontalBorder = new ArrayList<>(); if (lastAddedRow != null) { - for (int i = 0; i < lastAddedRow.length; i++) { - Cell cell = lastAddedRow[i]; + for (Cell cell : lastAddedRow) { Border border = null; if (cell != null) { if (cell.hasProperty(Property.BORDER_BOTTOM)) { border = cell.getProperty(Property.BORDER_BOTTOM); - } else if (cell.hasProperty(Property.BORDER)) { - border = cell.getProperty(Property.BORDER); } else { - border = cell.getDefaultProperty(Property.BORDER); + border = cell.getDefaultProperty(Property.BORDER_BOTTOM); } } horizontalBorder.add(border); diff --git a/layout/src/main/java/com/itextpdf/layout/element/Text.java b/layout/src/main/java/com/itextpdf/layout/element/Text.java index ed70315844..f02b7337d5 100644 --- a/layout/src/main/java/com/itextpdf/layout/element/Text.java +++ b/layout/src/main/java/com/itextpdf/layout/element/Text.java @@ -25,6 +25,7 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.tagging.StandardRoles; import com.itextpdf.kernel.pdf.tagutils.DefaultAccessibilityProperties; import com.itextpdf.kernel.pdf.tagutils.AccessibilityProperties; +import com.itextpdf.layout.exceptions.LayoutExceptionMessageConstant; import com.itextpdf.layout.tagging.IAccessibleElement; import com.itextpdf.layout.properties.Property; import com.itextpdf.layout.renderer.IRenderer; @@ -45,7 +46,7 @@ public class Text extends AbstractElement implements ILeafElement, IAccess */ public Text(String text) { if (null == text) { - throw new IllegalArgumentException(); + throw new IllegalArgumentException(LayoutExceptionMessageConstant.TEXT_CONTENT_CANNOT_BE_NULL); } this.text = text; } diff --git a/layout/src/main/java/com/itextpdf/layout/exceptions/LayoutExceptionMessageConstant.java b/layout/src/main/java/com/itextpdf/layout/exceptions/LayoutExceptionMessageConstant.java index 832e6df070..777297ba14 100644 --- a/layout/src/main/java/com/itextpdf/layout/exceptions/LayoutExceptionMessageConstant.java +++ b/layout/src/main/java/com/itextpdf/layout/exceptions/LayoutExceptionMessageConstant.java @@ -61,6 +61,7 @@ public final class LayoutExceptionMessageConstant { = "Automatic repetitions in the grid template cannot be combined with intrinsic or flexible sizes."; public static final String FLEXIBLE_ARENT_ALLOWED_AS_MINIMUM_IN_MINMAX = "Flexible values aren't allowed as minimum in minmax grid function."; + public static final String TEXT_CONTENT_CANNOT_BE_NULL = "Text content cannot be null."; private LayoutExceptionMessageConstant(){} } diff --git a/layout/src/main/java/com/itextpdf/layout/font/ComplexFontSelectorStrategy.java b/layout/src/main/java/com/itextpdf/layout/font/ComplexFontSelectorStrategy.java deleted file mode 100644 index 8419b2a13e..0000000000 --- a/layout/src/main/java/com/itextpdf/layout/font/ComplexFontSelectorStrategy.java +++ /dev/null @@ -1,152 +0,0 @@ -/* - This file is part of the iText (R) project. - Copyright (c) 1998-2024 Apryse Group NV - Authors: Apryse Software. - - This program is offered under a commercial and under the AGPL license. - For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. - - AGPL licensing: - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . - */ -package com.itextpdf.layout.font; - -import com.itextpdf.io.font.otf.Glyph; -import com.itextpdf.io.util.TextUtil; -import com.itextpdf.kernel.font.PdfFont; -import com.itextpdf.layout.font.selectorstrategy.FirstMatchFontSelectorStrategy; - -import java.util.ArrayList; -import java.util.List; - -/** - * Complex FontSelectorStrategy split text based on {@link java.lang.Character.UnicodeScript}. - * If unicode script changes, a new font will be found. - * If there is no suitable font, only one notdef glyph from {@link FontSelector#bestMatch()} will be added. - * @deprecated was replaced by {@link FirstMatchFontSelectorStrategy}. - */ -@Deprecated -public class ComplexFontSelectorStrategy extends FontSelectorStrategy { - - private PdfFont font; - private FontSelector selector; - - - public ComplexFontSelectorStrategy(String text, FontSelector selector, FontProvider provider, FontSet additionalFonts) { - super(text, provider, additionalFonts); - this.font = null; - this.selector = selector; - } - - public ComplexFontSelectorStrategy(String text, FontSelector selector, FontProvider provider) { - super(text, provider, null); - this.font = null; - this.selector = selector; - } - - @Override - public PdfFont getCurrentFont() { - return font; - } - - @Override - public List nextGlyphs() { - font = null; - int nextUnignorable = nextSignificantIndex(); - if (nextUnignorable < text.length()) { - for (FontInfo f : selector.getFonts()) { - int codePoint = isSurrogatePair(text, nextUnignorable) - ? TextUtil.convertToUtf32(text, nextUnignorable) - : (int) text.charAt(nextUnignorable); - - if (f.getFontUnicodeRange().contains(codePoint)) { - PdfFont currentFont = getPdfFont(f); - Glyph glyph = currentFont.getGlyph(codePoint); - if (null != glyph && 0 != glyph.getCode()) { - font = currentFont; - break; - } - } - } - } - List glyphs = new ArrayList<>(); - boolean anyGlyphsAppended = false; - if (font != null) { - Character.UnicodeScript unicodeScript = nextSignificantUnicodeScript(nextUnignorable); - int to = nextUnignorable; - for (int i = nextUnignorable; i < text.length(); i++) { - int codePoint = isSurrogatePair(text, i) ? TextUtil.convertToUtf32(text, i) : (int) text.charAt(i); - Character.UnicodeScript currScript = Character.UnicodeScript.of(codePoint); - if (isSignificantUnicodeScript(currScript) && currScript != unicodeScript) { - break; - } - if (codePoint > 0xFFFF) i++; - to = i; - } - - int numOfAppendedGlyphs = font.appendGlyphs(text, index, to, glyphs); - anyGlyphsAppended = numOfAppendedGlyphs > 0; - assert anyGlyphsAppended; - index += numOfAppendedGlyphs; - } - if (!anyGlyphsAppended) { - font = getPdfFont(selector.bestMatch()); - if (index != nextUnignorable) { - index += font.appendGlyphs(text, index, nextUnignorable - 1, glyphs); - } - while (index <= nextUnignorable && index < text.length()) { - index += font.appendAnyGlyph(text, index, glyphs); - } - } - return glyphs; - } - - private int nextSignificantIndex() { - int nextValidChar = index; - for (; nextValidChar < text.length(); nextValidChar++) { - if (!TextUtil.isWhitespaceOrNonPrintable(text.charAt(nextValidChar))) { - break; - } - } - return nextValidChar; - } - - private Character.UnicodeScript nextSignificantUnicodeScript(int from) { - for (int i = from; i < text.length(); i++) { - int codePoint; - if (isSurrogatePair(text, i)) { - codePoint = TextUtil.convertToUtf32(text, i); - i++; - } else { - codePoint = (int) text.charAt(i); - } - Character.UnicodeScript unicodeScript = Character.UnicodeScript.of(codePoint); - if (isSignificantUnicodeScript(unicodeScript)) { - return unicodeScript; - } - } - return Character.UnicodeScript.COMMON; - } - - private static boolean isSignificantUnicodeScript(Character.UnicodeScript unicodeScript) { - // Character.UnicodeScript.UNKNOWN will be handled as significant unicode script - return unicodeScript != Character.UnicodeScript.COMMON && unicodeScript != Character.UnicodeScript.INHERITED; - } - - //This method doesn't perform additional checks if compare with TextUtil#isSurrogatePair() - private static boolean isSurrogatePair(String text, int idx) { - return TextUtil.isSurrogateHigh(text.charAt(idx)) && idx < text.length() - 1 - && TextUtil.isSurrogateLow(text.charAt(idx + 1)); - } -} diff --git a/layout/src/main/java/com/itextpdf/layout/font/FontProvider.java b/layout/src/main/java/com/itextpdf/layout/font/FontProvider.java index b70b3a65f2..282f7dc3cc 100644 --- a/layout/src/main/java/com/itextpdf/layout/font/FontProvider.java +++ b/layout/src/main/java/com/itextpdf/layout/font/FontProvider.java @@ -35,7 +35,7 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.font.PdfFontFactory.EmbeddingStrategy; import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.layout.exceptions.LayoutExceptionMessageConstant; -import com.itextpdf.layout.font.selectorstrategy.FirstMatchFontSelectorStrategy.FirstMathFontSelectorStrategyFactory; +import com.itextpdf.layout.font.selectorstrategy.BestMatchFontSelectorStrategy.BestMatchFontSelectorStrategyFactory; import com.itextpdf.layout.font.selectorstrategy.IFontSelectorStrategy; import com.itextpdf.layout.font.selectorstrategy.IFontSelectorStrategyFactory; @@ -110,7 +110,7 @@ public FontProvider(FontSet fontSet, String defaultFontFamily) { pdfFonts = new HashMap<>(); fontSelectorCache = new FontSelectorCache(this.fontSet); this.defaultFontFamily = defaultFontFamily; - this.fontSelectorStrategyFactory = new FirstMathFontSelectorStrategyFactory(); + this.fontSelectorStrategyFactory = new BestMatchFontSelectorStrategyFactory(); } /** @@ -356,60 +356,6 @@ public boolean getDefaultEmbeddingFlag() { return true; } - /** - * Gets the {@link FontSelectorStrategy} to split specified text into sequences of glyphs, already tied - * to the fonts which contain them. The fonts can be taken from the added fonts to the font provider and - * are chosen based on font-families list and desired font characteristics. - * - * @param text for splitting into sequences of glyphs. - * @param fontFamilies target font families to create {@link FontSelector} for sequences of glyphs. - * @param fc instance of {@link FontCharacteristics} to create {@link FontSelector} for sequences of glyphs. - * @param additionalFonts set which provides fonts additionally to the fonts added to font provider. - * Combined set of font provider fonts and additional fonts is used when choosing - * a single font for a sequence of glyphs. Additional fonts will only be used for the given - * font selector strategy instance and will not be otherwise preserved in font provider. - * - * @return {@link FontSelectorStrategy} instance. - * @deprecated use {@link #createFontSelectorStrategy(List, FontCharacteristics, FontSet)} - */ - @Deprecated - public FontSelectorStrategy getStrategy(String text, List fontFamilies, FontCharacteristics fc, FontSet additionalFonts) { - return new ComplexFontSelectorStrategy(text, getFontSelector(fontFamilies, fc, additionalFonts), this, additionalFonts); - } - - /** - * Gets the {@link FontSelectorStrategy} to split specified text into sequences of glyphs, already tied - * to the fonts which contain them. The fonts can be taken from the added fonts to the font provider and - * are chosen based on font-families list and desired font characteristics. - * - * @param text for splitting into sequences of glyphs. - * @param fontFamilies target font families to create {@link FontSelector} for sequences of glyphs. - * @param fc instance of {@link FontCharacteristics} to create {@link FontSelector} for sequences of glyphs. - * - * @return {@link FontSelectorStrategy} instance. - * @deprecated use {@link #createFontSelectorStrategy(List, FontCharacteristics, FontSet)} - */ - @Deprecated - public FontSelectorStrategy getStrategy(String text, List fontFamilies, FontCharacteristics fc) { - return getStrategy(text, fontFamilies, fc, null); - } - - /** - * Gets the {@link FontSelectorStrategy} to split specified text into sequences of glyphs, already tied - * to the fonts which contain them. The fonts can be taken from the added fonts to the font provider and - * are chosen based on font-families list and desired font characteristics. - * - * @param text for splitting into sequences of glyphs. - * @param fontFamilies target font families to create {@link FontSelector} for sequences of glyphs. - * - * @return {@link FontSelectorStrategy} instance. - * @deprecated use {@link #createFontSelectorStrategy(List, FontCharacteristics, FontSet)} - */ - @Deprecated - public FontSelectorStrategy getStrategy(String text, List fontFamilies) { - return getStrategy(text, fontFamilies, null); - } - /** * Sets factory which will be used in {@link #createFontSelectorStrategy(List, FontCharacteristics, FontSet)} * method. diff --git a/layout/src/main/java/com/itextpdf/layout/font/FontSelectorStrategy.java b/layout/src/main/java/com/itextpdf/layout/font/FontSelectorStrategy.java deleted file mode 100644 index 795e84f5a7..0000000000 --- a/layout/src/main/java/com/itextpdf/layout/font/FontSelectorStrategy.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - This file is part of the iText (R) project. - Copyright (c) 1998-2024 Apryse Group NV - Authors: Apryse Software. - - This program is offered under a commercial and under the AGPL license. - For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. - - AGPL licensing: - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . - */ -package com.itextpdf.layout.font; - -import com.itextpdf.io.font.otf.Glyph; -import com.itextpdf.kernel.font.PdfFont; -import com.itextpdf.layout.font.selectorstrategy.IFontSelectorStrategy; - -import java.util.List; - -/** - * {@link FontSelectorStrategy} is responsible for splitting text into sub texts with one particular font. - * {@link #nextGlyphs()} will create next sub text and set current font. - * @deprecated replaced by {@link IFontSelectorStrategy}. - */ -@Deprecated -public abstract class FontSelectorStrategy { - - protected String text; - protected int index; - protected final FontProvider provider; - protected final FontSet additionalFonts; - - protected FontSelectorStrategy(String text, FontProvider provider, FontSet additionalFonts) { - this.text = text; - this.index = 0; - this.provider = provider; - this.additionalFonts = additionalFonts; - } - - public boolean endOfText() { - return text == null || index >= text.length(); - } - - public abstract PdfFont getCurrentFont(); - - public abstract List nextGlyphs(); - - /** - * Utility method to create PdfFont. - * - * @param fontInfo instance of FontInfo. - * @return cached or just created PdfFont on success, otherwise null. - * @see FontProvider#getPdfFont(FontInfo, FontSet) - */ - protected PdfFont getPdfFont(FontInfo fontInfo) { - return provider.getPdfFont(fontInfo, additionalFonts); - } -} diff --git a/layout/src/main/java/com/itextpdf/layout/hyphenation/HyphenationTree.java b/layout/src/main/java/com/itextpdf/layout/hyphenation/HyphenationTree.java index 45178d390d..407148140d 100644 --- a/layout/src/main/java/com/itextpdf/layout/hyphenation/HyphenationTree.java +++ b/layout/src/main/java/com/itextpdf/layout/hyphenation/HyphenationTree.java @@ -17,8 +17,11 @@ package com.itextpdf.layout.hyphenation; +import com.itextpdf.commons.utils.FileUtil; + import java.io.FileInputStream; import java.io.FileNotFoundException; +import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.Collections; @@ -125,8 +128,8 @@ protected String unpackValues(int k) { * @throws HyphenationException In case the parsing fails * @throws FileNotFoundException When the specified file is not found */ - public void loadPatterns(String filename) throws HyphenationException, FileNotFoundException { - loadPatterns(new FileInputStream(filename), filename); + public void loadPatterns(String filename) throws HyphenationException, IOException { + loadPatterns(FileUtil.getInputStreamForFile(filename), filename); } /** diff --git a/layout/src/main/java/com/itextpdf/layout/hyphenation/PatternParser.java b/layout/src/main/java/com/itextpdf/layout/hyphenation/PatternParser.java index c111d886af..c3d745e539 100644 --- a/layout/src/main/java/com/itextpdf/layout/hyphenation/PatternParser.java +++ b/layout/src/main/java/com/itextpdf/layout/hyphenation/PatternParser.java @@ -17,6 +17,7 @@ package com.itextpdf.layout.hyphenation; +import com.itextpdf.commons.utils.FileUtil; import com.itextpdf.io.util.ResourceUtil; import com.itextpdf.kernel.utils.XmlProcessorCreator; @@ -82,8 +83,8 @@ public PatternParser(IPatternConsumer consumer) { * @throws HyphenationException In case of an exception while parsing * @throws FileNotFoundException If the specified file is not found */ - public void parse(String filename) throws HyphenationException, FileNotFoundException { - parse(new FileInputStream(filename), filename); + public void parse(String filename) throws HyphenationException, IOException { + parse(FileUtil.getInputStreamForFile(filename), filename); } /** diff --git a/layout/src/main/java/com/itextpdf/layout/margincollapse/MarginsCollapseHandler.java b/layout/src/main/java/com/itextpdf/layout/margincollapse/MarginsCollapseHandler.java index 7a2b57c649..9f622c7f0c 100644 --- a/layout/src/main/java/com/itextpdf/layout/margincollapse/MarginsCollapseHandler.java +++ b/layout/src/main/java/com/itextpdf/layout/margincollapse/MarginsCollapseHandler.java @@ -25,7 +25,6 @@ This file is part of the iText (R) project. import com.itextpdf.commons.utils.MessageFormatUtil; import com.itextpdf.io.logs.IoLogMessageConstant; import com.itextpdf.kernel.geom.Rectangle; -import com.itextpdf.layout.IPropertyContainer; import com.itextpdf.layout.properties.ContinuousContainer; import com.itextpdf.layout.properties.FloatPropertyValue; import com.itextpdf.layout.properties.Property; @@ -539,11 +538,11 @@ private static boolean hasBottomPadding(IRenderer renderer) { } private static boolean hasTopBorders(IRenderer renderer) { - return MarginsCollapseHandler.hasBorders(renderer, Property.BORDER_TOP); + return renderer.getModelElement().hasProperty(Property.BORDER_TOP); } private static boolean hasBottomBorders(IRenderer renderer) { - return MarginsCollapseHandler.hasBorders(renderer, Property.BORDER_BOTTOM); + return renderer.getModelElement().hasProperty(Property.BORDER_BOTTOM); } private static boolean rendererIsFloated(IRenderer renderer) { @@ -605,9 +604,4 @@ private static boolean hasPadding(IRenderer renderer, int property) { } return padding != null && padding.getValue() > 0; } - - private static boolean hasBorders(IRenderer renderer, int property) { - IPropertyContainer modelElement = renderer.getModelElement(); - return modelElement.hasProperty(property) || modelElement.hasProperty(Property.BORDER); - } } diff --git a/layout/src/main/java/com/itextpdf/layout/minmaxwidth/MinMaxWidthUtils.java b/layout/src/main/java/com/itextpdf/layout/minmaxwidth/MinMaxWidthUtils.java index 0cf321de06..36055e0429 100644 --- a/layout/src/main/java/com/itextpdf/layout/minmaxwidth/MinMaxWidthUtils.java +++ b/layout/src/main/java/com/itextpdf/layout/minmaxwidth/MinMaxWidthUtils.java @@ -62,17 +62,9 @@ public static MinMaxWidth countDefaultMinMaxWidth(IRenderer renderer) { } public static float getBorderWidth(IPropertyContainer element) { - Border border = element.getProperty(Property.BORDER); Border rightBorder = element.getProperty(Property.BORDER_RIGHT); Border leftBorder = element.getProperty(Property.BORDER_LEFT); - - if (!element.hasOwnProperty(Property.BORDER_RIGHT)) { - rightBorder = border; - } - if (!element.hasOwnProperty(Property.BORDER_LEFT)) { - leftBorder = border; - } - + float rightBorderWidth = rightBorder != null ? rightBorder.getWidth() : 0; float leftBorderWidth = leftBorder != null ? leftBorder.getWidth() : 0; return rightBorderWidth + leftBorderWidth; diff --git a/layout/src/main/java/com/itextpdf/layout/properties/ContinuousContainer.java b/layout/src/main/java/com/itextpdf/layout/properties/ContinuousContainer.java index 768739c36b..e687cf6534 100644 --- a/layout/src/main/java/com/itextpdf/layout/properties/ContinuousContainer.java +++ b/layout/src/main/java/com/itextpdf/layout/properties/ContinuousContainer.java @@ -23,7 +23,6 @@ This file is part of the iText (R) project. package com.itextpdf.layout.properties; import com.itextpdf.layout.IPropertyContainer; -import com.itextpdf.layout.borders.Border; import com.itextpdf.layout.renderer.AbstractRenderer; import com.itextpdf.layout.renderer.IRenderer; @@ -43,7 +42,7 @@ public final class ContinuousContainer { */ private static final int[] PROPERTIES_NEEDED_FOR_CONTINUOUS_CONTAINER = {Property.MARGIN_BOTTOM, Property.BORDER_BOTTOM, - Property.PADDING_BOTTOM, Property.BORDER}; + Property.PADDING_BOTTOM}; private final HashMap properties = new HashMap<>(); @@ -109,11 +108,6 @@ public void reApplyProperties(AbstractRenderer blockRenderer) { for (int property : PROPERTIES_NEEDED_FOR_CONTINUOUS_CONTAINER) { blockRenderer.setProperty(property, properties.get(property)); } - final Border allBorders = (Border) properties.get(Property.BORDER); - final Border bottomBorder = (Border) properties.get(Property.BORDER_BOTTOM); - if (allBorders != null && bottomBorder == null) { - blockRenderer.setProperty(Property.BORDER_BOTTOM, allBorders); - } } /** diff --git a/layout/src/main/java/com/itextpdf/layout/properties/Property.java b/layout/src/main/java/com/itextpdf/layout/properties/Property.java index 0ba4f58f73..e150d0c363 100644 --- a/layout/src/main/java/com/itextpdf/layout/properties/Property.java +++ b/layout/src/main/java/com/itextpdf/layout/properties/Property.java @@ -49,13 +49,11 @@ public final class Property { public static final int BACKGROUND_IMAGE = 90; public static final int BASE_DIRECTION = 7; public static final int BOLD_SIMULATION = 8; - public static final int BORDER = 9; public static final int BORDER_BOTTOM = 10; public static final int BORDER_BOTTOM_LEFT_RADIUS = 113; public static final int BORDER_BOTTOM_RIGHT_RADIUS = 112; public static final int BORDER_COLLAPSE = 114; public static final int BORDER_LEFT = 11; - public static final int BORDER_RADIUS = 101; public static final int BORDER_RIGHT = 12; public static final int BORDER_TOP = 13; public static final int BORDER_TOP_LEFT_RADIUS = 110; @@ -121,10 +119,10 @@ public final class Property { public static final int FULL = 25; public static final int GRID_COLUMN_END = 147; public static final int GRID_COLUMN_START = 148; - public static final int GRID_COLUMN_SPAN = 155; + public static final int GRID_COLUMN_SPAN = 9; public static final int GRID_ROW_END = 149; public static final int GRID_ROW_START = 150; - public static final int GRID_ROW_SPAN = 156; + public static final int GRID_ROW_SPAN = 101; public static final int GRID_TEMPLATE_COLUMNS = 145; public static final int GRID_TEMPLATE_ROWS = 146; public static final int GRID_AUTO_ROWS = 151; @@ -236,7 +234,7 @@ public final class Property { * related to textual operations. Indicates whether or not this type of property is inheritable. */ private static final boolean[] INHERITED_PROPERTIES; - private static final int MAX_INHERITED_PROPERTY_ID = 156; + private static final int MAX_INHERITED_PROPERTY_ID = 154; static { INHERITED_PROPERTIES = new boolean[MAX_INHERITED_PROPERTY_ID + 1]; diff --git a/layout/src/main/java/com/itextpdf/layout/renderer/AbstractRenderer.java b/layout/src/main/java/com/itextpdf/layout/renderer/AbstractRenderer.java index 820786e70c..7c432fa3cb 100644 --- a/layout/src/main/java/com/itextpdf/layout/renderer/AbstractRenderer.java +++ b/layout/src/main/java/com/itextpdf/layout/renderer/AbstractRenderer.java @@ -1069,11 +1069,11 @@ public void drawChildren(DrawContext drawContext) { } /** - * Performs the drawing operation for the border of this renderer, if - * defined by any of the {@link Property#BORDER} values in either the layout - * element or this {@link IRenderer} itself. + * Performs the drawing operation for the border of this renderer, if defined by the {@link Property#BORDER_TOP}, + * {@link Property#BORDER_RIGHT}, {@link Property#BORDER_BOTTOM} and {@link Property#BORDER_LEFT} values in either + * the layout element or this {@link IRenderer} itself. * - * @param drawContext the context (canvas, document, etc) of this drawing operation. + * @param drawContext the context (canvas, document, etc.) of this drawing operation */ public void drawBorder(DrawContext drawContext) { Border[] borders = getBorders(); @@ -1393,8 +1393,8 @@ static void processWaitingDrawing(IRenderer child, Transform transformProp, List Div outlines = new Div().setNeutralRole(); if (transformProp != null) outlines.setProperty(Property.TRANSFORM, transformProp); - outlines.setProperty(Property.BORDER, outlineProp); - float offset = outlines.getProperty(Property.BORDER).getWidth(); + outlines.setBorder(outlineProp); + float offset = outlineProp.getWidth(); if (abstractChild.getPropertyAsFloat(Property.OUTLINE_OFFSET) != null) offset += (float) abstractChild.getPropertyAsFloat(Property.OUTLINE_OFFSET); DivRenderer div = new DivRenderer(outlines); @@ -1402,8 +1402,12 @@ static void processWaitingDrawing(IRenderer child, Transform transformProp, List Rectangle divOccupiedArea = abstractChild.applyMargins(abstractChild.occupiedArea.clone().getBBox(), false).moveLeft(offset).moveDown(offset); divOccupiedArea.setWidth(divOccupiedArea.getWidth() + 2 * offset).setHeight(divOccupiedArea.getHeight() + 2 * offset); div.occupiedArea = new LayoutArea(abstractChild.getOccupiedArea().getPageNumber(), divOccupiedArea); - float outlineWidth = div.getProperty(Property.BORDER).getWidth(); - if (divOccupiedArea.getWidth() >= outlineWidth * 2 && divOccupiedArea.getHeight() >= outlineWidth * 2) { + float outlineWidthTop = div.getProperty(Property.BORDER_TOP).getWidth(); + float outlineWidthBottom = div.getProperty(Property.BORDER_BOTTOM).getWidth(); + float outlineWidthLeft = div.getProperty(Property.BORDER_LEFT).getWidth(); + float outlineWidthRight = div.getProperty(Property.BORDER_RIGHT).getWidth(); + if (divOccupiedArea.getWidth() >= (outlineWidthLeft + outlineWidthRight) && + divOccupiedArea.getHeight() >= (outlineWidthTop + outlineWidthBottom)) { waitingDrawing.add(div); } if (abstractChild.isRelativePosition()) @@ -1997,7 +2001,8 @@ protected void applyAction(PdfDocument document) { PdfLinkAnnotation link = this.getProperty(Property.LINK_ANNOTATION); if (link == null) { link = (PdfLinkAnnotation) new PdfLinkAnnotation(new Rectangle(0, 0, 0, 0)).setFlags(PdfAnnotation.PRINT); - Border border = this.getProperty(Property.BORDER); + // For now, we set left border to an annotation, but appropriate borders for an element will be drawn. + Border border = this.getProperty(Property.BORDER_LEFT); if (border != null) { link.setBorder(new PdfArray(new float[]{0, 0, border.getWidth()})); } else { @@ -2556,28 +2561,11 @@ PdfFont resolveFirstPdfFont(String[] font, FontProvider provider, FontCharacteri } static Border[] getBorders(IRenderer renderer) { - Border border = renderer.getProperty(Property.BORDER); Border topBorder = renderer.getProperty(Property.BORDER_TOP); Border rightBorder = renderer.getProperty(Property.BORDER_RIGHT); Border bottomBorder = renderer.getProperty(Property.BORDER_BOTTOM); Border leftBorder = renderer.getProperty(Property.BORDER_LEFT); - - Border[] borders = {topBorder, rightBorder, bottomBorder, leftBorder}; - - if (!hasOwnOrModelProperty(renderer, Property.BORDER_TOP)) { - borders[0] = border; - } - if (!hasOwnOrModelProperty(renderer, Property.BORDER_RIGHT)) { - borders[1] = border; - } - if (!hasOwnOrModelProperty(renderer, Property.BORDER_BOTTOM)) { - borders[2] = border; - } - if (!hasOwnOrModelProperty(renderer, Property.BORDER_LEFT)) { - borders[3] = border; - } - - return borders; + return new Border[]{topBorder, rightBorder, bottomBorder, leftBorder}; } void applyAbsolutePositionIfNeeded(LayoutContext layoutContext) { @@ -2828,28 +2816,12 @@ private static UnitValue[] getMargins(IRenderer renderer) { } private static BorderRadius[] getBorderRadii(IRenderer renderer) { - BorderRadius radius = renderer.getProperty(Property.BORDER_RADIUS); BorderRadius topLeftRadius = renderer.getProperty(Property.BORDER_TOP_LEFT_RADIUS); BorderRadius topRightRadius = renderer.getProperty(Property.BORDER_TOP_RIGHT_RADIUS); BorderRadius bottomRightRadius = renderer.getProperty(Property.BORDER_BOTTOM_RIGHT_RADIUS); BorderRadius bottomLeftRadius = renderer.getProperty(Property.BORDER_BOTTOM_LEFT_RADIUS); - BorderRadius[] borderRadii = {topLeftRadius, topRightRadius, bottomRightRadius, bottomLeftRadius}; - - if (!hasOwnOrModelProperty(renderer, Property.BORDER_TOP_LEFT_RADIUS)) { - borderRadii[0] = radius; - } - if (!hasOwnOrModelProperty(renderer, Property.BORDER_TOP_RIGHT_RADIUS)) { - borderRadii[1] = radius; - } - if (!hasOwnOrModelProperty(renderer, Property.BORDER_BOTTOM_RIGHT_RADIUS)) { - borderRadii[2] = radius; - } - if (!hasOwnOrModelProperty(renderer, Property.BORDER_BOTTOM_LEFT_RADIUS)) { - borderRadii[3] = radius; - } - - return borderRadii; + return new BorderRadius[]{topLeftRadius, topRightRadius, bottomRightRadius, bottomLeftRadius}; } private static UnitValue[] getPaddings(IRenderer renderer) { diff --git a/layout/src/main/java/com/itextpdf/layout/renderer/AccessibleAttributesApplier.java b/layout/src/main/java/com/itextpdf/layout/renderer/AccessibleAttributesApplier.java index 13c21674ac..af3f612a8e 100644 --- a/layout/src/main/java/com/itextpdf/layout/renderer/AccessibleAttributesApplier.java +++ b/layout/src/main/java/com/itextpdf/layout/renderer/AccessibleAttributesApplier.java @@ -24,7 +24,6 @@ This file is part of the iText (R) project. import com.itextpdf.io.logs.IoLogMessageConstant; import com.itextpdf.commons.utils.MessageFormatUtil; -import com.itextpdf.kernel.colors.Color; import com.itextpdf.kernel.colors.DeviceRgb; import com.itextpdf.kernel.geom.Rectangle; import com.itextpdf.kernel.pdf.PdfArray; @@ -374,27 +373,12 @@ private static void applyPaddingAttribute(AbstractRenderer renderer, PdfDictiona } private static void applyBorderAttributes(AbstractRenderer renderer, PdfDictionary attributes) { - boolean specificBorderProperties = renderer.getProperty(Property.BORDER_TOP) != null + boolean borderPropertiesSet = renderer.getProperty(Property.BORDER_TOP) != null || renderer.getProperty(Property.BORDER_RIGHT) != null || renderer.getProperty(Property.BORDER_BOTTOM) != null || renderer.getProperty(Property.BORDER_LEFT) != null; - boolean generalBorderProperties = !specificBorderProperties && renderer.getProperty(Property.BORDER) != null; - - if (generalBorderProperties) { - Border generalBorder = renderer.getProperty(Property.BORDER); - Color generalBorderColor = generalBorder.getColor(); - int borderType = generalBorder.getType(); - float borderWidth = generalBorder.getWidth(); - - if (generalBorderColor instanceof DeviceRgb) { - attributes.put(PdfName.BorderColor, new PdfArray(generalBorderColor.getColorValue())); - attributes.put(PdfName.BorderStyle, transformBorderTypeToName(borderType)); - attributes.put(PdfName.BorderThickness, new PdfNumber(borderWidth)); - } - } - - if (specificBorderProperties) { + if (borderPropertiesSet) { PdfArray borderColors = new PdfArray(); PdfArray borderTypes = new PdfArray(); PdfArray borderWidths = new PdfArray(); diff --git a/layout/src/main/java/com/itextpdf/layout/renderer/CollapsedTableBorders.java b/layout/src/main/java/com/itextpdf/layout/renderer/CollapsedTableBorders.java index 67ef1e5b8a..d8c9d785f3 100644 --- a/layout/src/main/java/com/itextpdf/layout/renderer/CollapsedTableBorders.java +++ b/layout/src/main/java/com/itextpdf/layout/renderer/CollapsedTableBorders.java @@ -239,7 +239,8 @@ public CollapsedTableBorders setBottomBorderCollapseWith(List bottomBord } //endregion - protected void buildBordersArrays(CellRenderer cell, int row, int col, int[] rowspansToDeduct) { + @Override + protected void buildBordersArrays(CellRenderer cell, int row, int col) { // We should check if the row number is less than horizontal borders array size. It can happen if the cell with // big rowspan doesn't fit current area and is going to be placed partial. if (row > horizontalBorders.size()) { @@ -266,7 +267,7 @@ protected void buildBordersArrays(CellRenderer cell, int row, int col, int[] row // process only valid cells which hasn't been processed yet if (j >= 0 && nextCellRow != rows.size() && nextCellRow > row) { CellRenderer nextCell = rows.get(nextCellRow)[j]; - buildBordersArrays(nextCell, nextCellRow, true); + buildBordersArrays(nextCell, nextCellRow); } } @@ -283,7 +284,7 @@ protected void buildBordersArrays(CellRenderer cell, int row, int col, int[] row CellRenderer nextCell = rows.get(nextCellRow)[col + j]; // otherwise the border was considered previously if (row == nextCellRow - (int) nextCell.getPropertyAsInteger(Property.ROWSPAN)) { - buildBordersArrays(nextCell, nextCellRow, true); + buildBordersArrays(nextCell, nextCellRow); } j += (int) nextCell.getPropertyAsInteger(Property.COLSPAN); } @@ -296,15 +297,15 @@ protected void buildBordersArrays(CellRenderer cell, int row, int col, int[] row } if (nextCellRow != rows.size()) { CellRenderer nextCell = rows.get(nextCellRow)[col + currCellColspan]; - buildBordersArrays(nextCell, nextCellRow, true); + buildBordersArrays(nextCell, nextCellRow); } } // consider current cell - buildBordersArrays(cell, row, false); + buildBordersArrays(cell, row); } - protected void buildBordersArrays(CellRenderer cell, int row, boolean isNeighbourCell) { + protected void buildBordersArrays(CellRenderer cell, int row) { int colspan = (int) cell.getPropertyAsInteger(Property.COLSPAN); int rowspan = (int) cell.getPropertyAsInteger(Property.ROWSPAN); int colN = ((Cell) cell.getModelElement()).getCol(); diff --git a/layout/src/main/java/com/itextpdf/layout/renderer/FlexContainerRenderer.java b/layout/src/main/java/com/itextpdf/layout/renderer/FlexContainerRenderer.java index 8d2ce99bc5..db2d1593bd 100644 --- a/layout/src/main/java/com/itextpdf/layout/renderer/FlexContainerRenderer.java +++ b/layout/src/main/java/com/itextpdf/layout/renderer/FlexContainerRenderer.java @@ -22,6 +22,7 @@ This file is part of the iText (R) project. */ package com.itextpdf.layout.renderer; +import com.itextpdf.commons.datastructures.Tuple2; import com.itextpdf.kernel.geom.Rectangle; import com.itextpdf.layout.borders.Border; import com.itextpdf.layout.element.Div; @@ -49,7 +50,8 @@ This file is part of the iText (R) project. public class FlexContainerRenderer extends DivRenderer { - /* Used for caching purposes in FlexUtil + /** + * Used for caching purposes in FlexUtil * We couldn't find the real use case when this map contains more than 1 entry * but let it still be a map to be on a safe(r) side * Map mainSize (always width in our case) - hypotheticalCrossSize @@ -60,6 +62,11 @@ public class FlexContainerRenderer extends DivRenderer { private IFlexItemMainDirector flexItemMainDirector = null; + /** + * Child renderers and their heights and min heights before the layout. + */ + private final Map> heights = new HashMap<>(); + /** * Creates a FlexContainerRenderer from its corresponding layout object. * @@ -103,8 +110,6 @@ public LayoutResult layout(LayoutContext layoutContext) { List renderersToOverflow = retrieveRenderersToOverflow(layoutContextRectangle); final List previousWidths = new ArrayList<>(); - final List previousHeights = new ArrayList<>(); - final List previousMinHeights = new ArrayList<>(); for (final List line : lines) { for (final FlexItemInfo itemInfo : line) { final Rectangle rectangleWithoutBordersMarginsPaddings; @@ -116,9 +121,10 @@ public LayoutResult layout(LayoutContext layoutContext) { itemInfo.getRenderer().applyMarginsBordersPaddings(itemInfo.getRectangle().clone(), false); } + heights.put(itemInfo.getRenderer(), new Tuple2( + itemInfo.getRenderer().getProperty(Property.HEIGHT), + itemInfo.getRenderer().getProperty(Property.MIN_HEIGHT))); previousWidths.add(itemInfo.getRenderer().getProperty(Property.WIDTH)); - previousHeights.add(itemInfo.getRenderer().getProperty(Property.HEIGHT)); - previousMinHeights.add(itemInfo.getRenderer().getProperty(Property.MIN_HEIGHT)); itemInfo.getRenderer().setProperty(Property.WIDTH, UnitValue.createPointValue(rectangleWithoutBordersMarginsPaddings.getWidth())); @@ -148,8 +154,9 @@ public LayoutResult layout(LayoutContext layoutContext) { for (final List line : lines) { for (final FlexItemInfo itemInfo : line) { itemInfo.getRenderer().setProperty(Property.WIDTH, previousWidths.get(counter)); - itemInfo.getRenderer().setProperty(Property.HEIGHT, previousHeights.get(counter)); - itemInfo.getRenderer().setProperty(Property.MIN_HEIGHT, previousMinHeights.get(counter)); + Tuple2 curHeights = heights.get(itemInfo.getRenderer()); + itemInfo.getRenderer().setProperty(Property.HEIGHT, curHeights.getFirst()); + itemInfo.getRenderer().setProperty(Property.MIN_HEIGHT, curHeights.getSecond()); ++counter; } } @@ -511,6 +518,8 @@ private static void addSimulateDiv(AbstractRenderer overflowRenderer, float widt private void fillSplitOverflowRenderersForPartialResult(AbstractRenderer splitRenderer, AbstractRenderer overflowRenderer, List line, IRenderer childRenderer, LayoutResult childResult) { + restoreHeightForOverflowRenderer(childRenderer, childResult.getOverflowRenderer()); + float occupiedSpace = 0; float maxHeightInLine = 0; boolean metChildRendererInLine = false; @@ -526,7 +535,7 @@ private void fillSplitOverflowRenderersForPartialResult(AbstractRenderer splitRe // Get rid of vertical alignment for item with partial result. For column direction, justify-content // is applied to the entire line, not the single item, so there is no point in getting rid of it if (!FlexUtil.isColumnDirection(this)) { - childResult.getOverflowRenderer().setProperty(Property.ALIGN_SELF, AlignmentPropertyValue.START); + setAlignSelfIfNotStretch(childResult.getOverflowRenderer()); } overflowRenderer.addChildRenderer(childResult.getOverflowRenderer()); } @@ -551,6 +560,8 @@ private void fillSplitOverflowRenderersForPartialResult(AbstractRenderer splitRe maxHeightInLine - itemInfo.getRectangle().getY()); final LayoutResult neighbourLayoutResult = itemInfo.getRenderer().layout(new LayoutContext( new LayoutArea(childResult.getOccupiedArea().getPageNumber(), neighbourBbox))); + restoreHeightForOverflowRenderer(itemInfo.getRenderer(), neighbourLayoutResult.getOverflowRenderer()); + // Handle result if (neighbourLayoutResult.getStatus() == LayoutResult.PARTIAL && neighbourLayoutResult.getSplitRenderer() != null) { @@ -564,8 +575,7 @@ private void fillSplitOverflowRenderersForPartialResult(AbstractRenderer splitRe if (neighbourLayoutResult.getOverflowRenderer() != null) { if (neighbourLayoutResult.getStatus() == LayoutResult.PARTIAL) { // Get rid of cross alignment for item with partial result - neighbourLayoutResult.getOverflowRenderer() - .setProperty(Property.ALIGN_SELF, AlignmentPropertyValue.START); + setAlignSelfIfNotStretch(neighbourLayoutResult.getOverflowRenderer()); } overflowRenderer.addChildRenderer(neighbourLayoutResult.getOverflowRenderer()); } else { @@ -590,6 +600,34 @@ private void fillSplitOverflowRenderersForPartialResult(AbstractRenderer splitRe } } + private void setAlignSelfIfNotStretch(IRenderer overflowRenderer) { + AlignmentPropertyValue alignItems = + (AlignmentPropertyValue) this.getProperty( + Property.ALIGN_ITEMS, AlignmentPropertyValue.STRETCH); + AlignmentPropertyValue alignSelf = + (AlignmentPropertyValue) overflowRenderer.getProperty( + Property.ALIGN_SELF, alignItems); + if (alignSelf != AlignmentPropertyValue.STRETCH) { + overflowRenderer.setProperty(Property.ALIGN_SELF, AlignmentPropertyValue.START); + } + } + + private void restoreHeightForOverflowRenderer(IRenderer childRenderer, IRenderer overflowRenderer) { + if (overflowRenderer == null) { + return; + } + + // childRenderer is the original renderer we set the height for before the layout + // And we need to remove the height from the corresponding overflow renderer + Tuple2 curHeights = heights.get(childRenderer); + if (curHeights.getFirst() == null) { + overflowRenderer.deleteOwnProperty(Property.HEIGHT); + } + if (curHeights.getSecond() == null) { + overflowRenderer.deleteOwnProperty(Property.MIN_HEIGHT); + } + } + private void findMinMaxWidthIfCorrespondingPropertiesAreNotSet(MinMaxWidth minMaxWidth, AbstractWidthHandler minMaxWidthHandler) { float initialMinWidth = minMaxWidth.getChildrenMinWidth(); diff --git a/layout/src/main/java/com/itextpdf/layout/renderer/GridContainerRenderer.java b/layout/src/main/java/com/itextpdf/layout/renderer/GridContainerRenderer.java index 454aaa23a7..78006af8e0 100644 --- a/layout/src/main/java/com/itextpdf/layout/renderer/GridContainerRenderer.java +++ b/layout/src/main/java/com/itextpdf/layout/renderer/GridContainerRenderer.java @@ -178,10 +178,10 @@ private GridLayoutResult layoutGrid(LayoutContext layoutContext, Rectangle actua // Adjust cell BBox to the remaining part of the layout bbox // This way we can lay out elements partially - cellBBox.setHeight(cellBBox.getTop() - actualBBox.getBottom()) - .setY(actualBBox.getY()); + cellBBox.setHeight(cellBBox.getTop() - layoutContext.getArea().getBBox().getBottom()) + .setY(layoutContext.getArea().getBBox().getY()); - cellToRender.setProperty(Property.FILL_AVAILABLE_AREA, Boolean.TRUE); + cellToRender.setProperty(Property.FILL_AVAILABLE_AREA_ON_SPLIT, Boolean.TRUE); LayoutResult cellResult = cellToRender.layout(cellContext); notLayoutedRow = Math.min(notLayoutedRow, processLayoutResult(layoutResult, cell, cellResult)); } @@ -267,13 +267,13 @@ private LayoutArea calculateContainerOccupiedArea(LayoutContext layoutContext, b LayoutArea area = layoutContext.getArea().clone(); final Rectangle areaBBox = area.getBBox(); - final float totalContainerHeight = GridMulticolUtil.updateOccupiedHeight(containerHeight, isFull, isFirstLayout, this); + final float totalContainerHeight = GridMulticolUtil.updateOccupiedHeight(containerHeight, isFull, this); if (totalContainerHeight < areaBBox.getHeight() || isFull) { Float height = retrieveHeight(); if (height == null) { areaBBox.setHeight(totalContainerHeight); } else { - height = GridMulticolUtil.updateOccupiedHeight((float) height, isFull, isFirstLayout, this); + height = GridMulticolUtil.updateOccupiedHeight((float) height, isFull, this); areaBBox.setHeight((float) height); } } diff --git a/layout/src/main/java/com/itextpdf/layout/renderer/GridItemRenderer.java b/layout/src/main/java/com/itextpdf/layout/renderer/GridItemRenderer.java index 3a31929721..1f69124d5f 100644 --- a/layout/src/main/java/com/itextpdf/layout/renderer/GridItemRenderer.java +++ b/layout/src/main/java/com/itextpdf/layout/renderer/GridItemRenderer.java @@ -108,7 +108,7 @@ public void setProperty(int property, Object value) { } break; - case Property.FILL_AVAILABLE_AREA: + case Property.FILL_AVAILABLE_AREA_ON_SPLIT: renderer.setProperty(property, value); break; @@ -166,7 +166,9 @@ float calculateHeight(float initialHeight) { rectangle.decreaseHeight(paddingBottom.getValue()); } Border borderBottom = renderer.getBorders()[AbstractRenderer.BOTTOM_SIDE]; - rectangle.decreaseHeight(borderBottom.getWidth()); + if (borderBottom != null) { + rectangle.decreaseHeight(borderBottom.getWidth()); + } } else { renderer.applyMarginsBordersPaddings(rectangle, false); } diff --git a/layout/src/main/java/com/itextpdf/layout/renderer/GridMulticolUtil.java b/layout/src/main/java/com/itextpdf/layout/renderer/GridMulticolUtil.java index 0fd31f554f..2e623ebe0d 100644 --- a/layout/src/main/java/com/itextpdf/layout/renderer/GridMulticolUtil.java +++ b/layout/src/main/java/com/itextpdf/layout/renderer/GridMulticolUtil.java @@ -65,44 +65,23 @@ static float updateOccupiedWidth(float initialWidth, AbstractRenderer renderer) result += safelyRetrieveFloatProperty(Property.MARGIN_LEFT, renderer); result += safelyRetrieveFloatProperty(Property.MARGIN_RIGHT, renderer); - if (!renderer.hasOwnProperty(Property.BORDER) || renderer.getProperty(Property.BORDER) == null) { - result += safelyRetrieveFloatProperty(Property.BORDER_LEFT, renderer); - } - if (!renderer.hasOwnProperty(Property.BORDER) || renderer.getProperty(Property.BORDER) == null) { - result += safelyRetrieveFloatProperty(Property.BORDER_RIGHT, renderer); - } - result += safelyRetrieveFloatProperty(Property.BORDER, renderer) * 2; + result += safelyRetrieveFloatProperty(Property.BORDER_LEFT, renderer); + result += safelyRetrieveFloatProperty(Property.BORDER_RIGHT, renderer); return result; } - static float updateOccupiedHeight(float initialHeight, boolean isFull, boolean isFirstLayout, - AbstractRenderer renderer) { - + static float updateOccupiedHeight(float initialHeight, boolean isFull, AbstractRenderer renderer) { float result = initialHeight; if (isFull) { result += safelyRetrieveFloatProperty(Property.PADDING_BOTTOM, renderer); result += safelyRetrieveFloatProperty(Property.MARGIN_BOTTOM, renderer); - if (!renderer.hasOwnProperty(Property.BORDER) || renderer.getProperty(Property.BORDER) == null) { - result += safelyRetrieveFloatProperty(Property.BORDER_BOTTOM, renderer); - } + result += safelyRetrieveFloatProperty(Property.BORDER_BOTTOM, renderer); } result += safelyRetrieveFloatProperty(Property.PADDING_TOP, renderer); - result += safelyRetrieveFloatProperty(Property.MARGIN_TOP, renderer); + result += safelyRetrieveFloatProperty(Property.BORDER_TOP, renderer); - if (!renderer.hasOwnProperty(Property.BORDER) || renderer.getProperty(Property.BORDER) == null) { - result += safelyRetrieveFloatProperty(Property.BORDER_TOP, renderer); - } - - // isFirstLayout is necessary to handle the case when multicol container layouted in more - // than 2 pages, and on the last page layout result is full, but there is no bottom border - float TOP_AND_BOTTOM = isFull && isFirstLayout ? 2 : 1; - // Multicol container layouted in more than 3 pages, and there is a page where there are no bottom and top borders - if (!isFull && !isFirstLayout) { - TOP_AND_BOTTOM = 0; - } - result += safelyRetrieveFloatProperty(Property.BORDER, renderer) * TOP_AND_BOTTOM; return result; } diff --git a/layout/src/main/java/com/itextpdf/layout/renderer/GridTrackSizer.java b/layout/src/main/java/com/itextpdf/layout/renderer/GridTrackSizer.java index 16fd262b53..b99bee97bf 100644 --- a/layout/src/main/java/com/itextpdf/layout/renderer/GridTrackSizer.java +++ b/layout/src/main/java/com/itextpdf/layout/renderer/GridTrackSizer.java @@ -928,7 +928,6 @@ private float calculateMinMaxContribution(GridCell cell, boolean minTypeContribu // https://drafts.csswg.org/css-sizing-3/#auto-box-sizes: // min-content block size - For block containers, tables, and // inline boxes, this is equivalent to the max-content block size. - cell.getValue().setProperty(Property.FILL_AVAILABLE_AREA, Boolean.FALSE); final LayoutContext layoutContext = new LayoutContext( new LayoutArea(1, new Rectangle(cell.getLayoutArea().getWidth(), AbstractRenderer.INF))); LayoutResult inifiniteHeighLayoutResult = cell.getValue().layout(layoutContext); diff --git a/layout/src/main/java/com/itextpdf/layout/renderer/LineRenderer.java b/layout/src/main/java/com/itextpdf/layout/renderer/LineRenderer.java index 549509a023..5352387931 100644 --- a/layout/src/main/java/com/itextpdf/layout/renderer/LineRenderer.java +++ b/layout/src/main/java/com/itextpdf/layout/renderer/LineRenderer.java @@ -1058,7 +1058,7 @@ static LineSplitIntoGlyphsData splitLineIntoGlyphs(LineRenderer toSplit) { } if (child instanceof TextRenderer) { GlyphLine childLine = ((TextRenderer) child).line; - for (int i = childLine.start; i < childLine.end; i++) { + for (int i = childLine.getStart(); i < childLine.getEnd(); i++) { if (TextUtil.isNewLine(childLine.get(i))) { newLineFound = true; break; @@ -1080,7 +1080,7 @@ static void reorder(LineRenderer toProcess, LineSplitIntoGlyphsData splitLineInt final List lineGlyphs = splitLineIntoGlyphsResult.getLineGlyphs(); int initialPos = 0; for (int offset = initialPos; offset < lineGlyphs.size(); offset = initialPos) { - final TextRenderer renderer = lineGlyphs.get(offset).renderer; + final TextRenderer renderer = lineGlyphs.get(offset).getRenderer(); final TextRenderer newRenderer = new TextRenderer(renderer).removeReversedRanges(); toProcess.addChildRenderer(newRenderer); @@ -1090,13 +1090,13 @@ static void reorder(LineRenderer toProcess, LineSplitIntoGlyphsData splitLineInt newRenderer.line = new GlyphLine(newRenderer.line); List replacementGlyphs = new ArrayList<>(); boolean reversed = false; - for (int pos = offset; pos < lineGlyphs.size() && lineGlyphs.get(pos).renderer == renderer; ++pos) { - replacementGlyphs.add(lineGlyphs.get(pos).glyph); + for (int pos = offset; pos < lineGlyphs.size() && lineGlyphs.get(pos).getRenderer() == renderer; ++pos) { + replacementGlyphs.add(lineGlyphs.get(pos).getGlyph()); if (pos + 1 < lineGlyphs.size() - && lineGlyphs.get(pos + 1).renderer == renderer + && lineGlyphs.get(pos + 1).getRenderer() == renderer && newOrder[pos] == newOrder[pos + 1] + 1 - && !TextUtil.isSpaceOrWhitespace(lineGlyphs.get(pos + 1).glyph) - && !TextUtil.isSpaceOrWhitespace(lineGlyphs.get(pos).glyph)) { + && !TextUtil.isSpaceOrWhitespace(lineGlyphs.get(pos + 1).getGlyph()) + && !TextUtil.isSpaceOrWhitespace(lineGlyphs.get(pos).getGlyph())) { reversed = true; continue; } @@ -1329,9 +1329,9 @@ int trimFirst() { TextRenderer textRenderer = (TextRenderer) renderer; GlyphLine currentText = textRenderer.getText(); if (currentText != null) { - int prevTextStart = currentText.start; + int prevTextStart = currentText.getStart(); textRenderer.trimFirst(); - int numOfTrimmedGlyphs = textRenderer.getText().start - prevTextStart; + int numOfTrimmedGlyphs = textRenderer.getText().getStart() - prevTextStart; totalNumberOfTrimmedGlyphs += numOfTrimmedGlyphs; } trimFinished = textRenderer.length() > 0; @@ -1527,7 +1527,7 @@ private void updateBidiLevels(int totalNumberOfTrimmedGlyphs, BaseDirection base } if (child instanceof TextRenderer) { GlyphLine text = ((TextRenderer) child).getText(); - for (int i = text.start; i < text.end; i++) { + for (int i = text.getStart(); i < text.getEnd(); i++) { Glyph glyph = text.get(i); if (TextUtil.isNewLine(glyph)) { newLineFound = true; @@ -1621,13 +1621,49 @@ private boolean hasInlineBlocksWithVerticalAlignment() { } public static class RendererGlyph { - public Glyph glyph; - public TextRenderer renderer; + private Glyph glyph; + private TextRenderer renderer; public RendererGlyph(Glyph glyph, TextRenderer textRenderer) { this.glyph = glyph; this.renderer = textRenderer; } + + /** + * Sets the glyph of the object. + * + * @param glyph glyph + */ + public void setGlyph(Glyph glyph) { + this.glyph = glyph; + } + + /** + * Retrieves the glyph of the object. + * + * @return glyph + */ + public Glyph getGlyph() { + return glyph; + } + + /** + * Sets the renderer of the object. + * + * @param renderer renderer + */ + public void setRenderer(TextRenderer renderer) { + this.renderer = renderer; + } + + /** + * Retrieves the renderer of the object. + * + * @return renderer + */ + public TextRenderer getRenderer() { + return renderer; + } } static class LineAscentDescentState { diff --git a/layout/src/main/java/com/itextpdf/layout/renderer/MulticolRenderer.java b/layout/src/main/java/com/itextpdf/layout/renderer/MulticolRenderer.java index adecef42b5..6b10f9500a 100644 --- a/layout/src/main/java/com/itextpdf/layout/renderer/MulticolRenderer.java +++ b/layout/src/main/java/com/itextpdf/layout/renderer/MulticolRenderer.java @@ -125,7 +125,7 @@ public LayoutResult layout(LayoutContext layoutContext) { } else { this.occupiedArea = calculateContainerOccupiedArea(layoutContext, false); return new LayoutResult(LayoutResult.PARTIAL, this.occupiedArea, - createSplitRenderer(layoutResult.getSplitRenderers()), + GridMulticolUtil.createSplitRenderer(layoutResult.getSplitRenderers(), this), createOverflowRenderer(layoutResult.getOverflowRenderer())); } } @@ -140,9 +140,9 @@ public IRenderer getNextRenderer() { } /** - * Performs the drawing operation for the border of this renderer, if - * defined by any of the {@link Property#BORDER} values in either the layout - * element or this {@link IRenderer} itself. + * Performs the drawing operation for the border of this renderer, if defined by the {@link Property#BORDER_TOP}, + * {@link Property#BORDER_RIGHT}, {@link Property#BORDER_BOTTOM} and {@link Property#BORDER_LEFT} values in either + * the layout element or this {@link IRenderer} itself. * * @param drawContext the context (canvas, document, etc) of this drawing operation. */ @@ -194,19 +194,6 @@ protected MulticolLayoutResult layoutInColumns(LayoutContext layoutContext, Rect return balanceContentAndLayoutColumns(layoutContext, actualBBox); } - /** - * Creates a split renderer. - * - * @param children children of the split renderer - * - * @return a new {@link AbstractRenderer} instance - * @deprecated use {@link GridMulticolUtil#createSplitRenderer(List, AbstractRenderer)} - */ - @Deprecated - protected AbstractRenderer createSplitRenderer(List children) { - return GridMulticolUtil.createSplitRenderer(children, this); - } - /** * Creates an overflow renderer. * @@ -358,12 +345,12 @@ private LayoutArea calculateContainerOccupiedArea(LayoutContext layoutContext, b LayoutArea area = layoutContext.getArea().clone(); final Rectangle areaBBox = area.getBBox(); - final float totalContainerHeight = GridMulticolUtil.updateOccupiedHeight(approximateHeight, isFull, isFirstLayout, this); + final float totalContainerHeight = GridMulticolUtil.updateOccupiedHeight(approximateHeight, isFull, this); if (totalContainerHeight < areaBBox.getHeight() || isFull) { areaBBox.setHeight(totalContainerHeight); Float height = determineHeight(areaBBox); if (height != null) { - height = GridMulticolUtil.updateOccupiedHeight((float) height, isFull, isFirstLayout, this); + height = GridMulticolUtil.updateOccupiedHeight((float) height, isFull, this); areaBBox.setHeight((float) height); } } diff --git a/layout/src/main/java/com/itextpdf/layout/renderer/SeparatedTableBorders.java b/layout/src/main/java/com/itextpdf/layout/renderer/SeparatedTableBorders.java index 64aa3245e1..49504dc794 100644 --- a/layout/src/main/java/com/itextpdf/layout/renderer/SeparatedTableBorders.java +++ b/layout/src/main/java/com/itextpdf/layout/renderer/SeparatedTableBorders.java @@ -172,7 +172,8 @@ public float[] getCellBorderIndents(int row, int col, int rowspan, int colspan) return new float[] {0, 0, 0, 0}; } - protected void buildBordersArrays(CellRenderer cell, int row, int col, int[] rowspansToDeduct) { + @Override + protected void buildBordersArrays(CellRenderer cell, int row, int col) { int colspan = (int) cell.getPropertyAsInteger(Property.COLSPAN); int rowspan = (int) cell.getPropertyAsInteger(Property.ROWSPAN); int colN = ((Cell) cell.getModelElement()).getCol(); diff --git a/layout/src/main/java/com/itextpdf/layout/renderer/TableBorderUtil.java b/layout/src/main/java/com/itextpdf/layout/renderer/TableBorderUtil.java index 2fd4fa3858..1e8e24829b 100644 --- a/layout/src/main/java/com/itextpdf/layout/renderer/TableBorderUtil.java +++ b/layout/src/main/java/com/itextpdf/layout/renderer/TableBorderUtil.java @@ -36,10 +36,7 @@ private TableBorderUtil() { public static Border getCellSideBorder(Cell cellModel, int borderType) { Border cellModelSideBorder = cellModel.getProperty(borderType); if (null == cellModelSideBorder && !cellModel.hasProperty(borderType)) { - cellModelSideBorder = cellModel.getProperty(Property.BORDER); - if (null == cellModelSideBorder && !cellModel.hasProperty(Property.BORDER)) { - cellModelSideBorder = cellModel.getDefaultProperty(Property.BORDER); - } + cellModelSideBorder = cellModel.getDefaultProperty(borderType); } return cellModelSideBorder; } diff --git a/layout/src/main/java/com/itextpdf/layout/renderer/TableBorders.java b/layout/src/main/java/com/itextpdf/layout/renderer/TableBorders.java index a6e3c725aa..3d86c19a3f 100644 --- a/layout/src/main/java/com/itextpdf/layout/renderer/TableBorders.java +++ b/layout/src/main/java/com/itextpdf/layout/renderer/TableBorders.java @@ -155,11 +155,7 @@ public TableBorders(List rows, int numberOfColumns, Border[] tab protected abstract float getCellVerticalAddition(float[] indents); // endregion - /** - * @deprecated Remove rowspansToDeduct parameter which is not used anymore. - */ - @Deprecated - protected abstract void buildBordersArrays(CellRenderer cell, int row, int col, int[] rowspansToDeduct); + protected abstract void buildBordersArrays(CellRenderer cell, int row, int col); protected abstract TableBorders updateBordersOnNewPage(boolean isOriginalNonSplitRenderer, boolean isFooterOrHeader, TableRenderer currentRenderer, TableRenderer headerRenderer, TableRenderer footerRenderer); // endregion @@ -183,7 +179,7 @@ protected TableBorders processAllBordersAndEmptyRows() { numOfRowsToRemove = 0; } - buildBordersArrays(currentRow[col], row, col, null); + buildBordersArrays(currentRow[col], row, col); hasCells = true; int colspan = (int) currentRow[col].getPropertyAsInteger(Property.COLSPAN); col += colspan - 1; diff --git a/layout/src/main/java/com/itextpdf/layout/renderer/TableRenderer.java b/layout/src/main/java/com/itextpdf/layout/renderer/TableRenderer.java index 781850e4b9..449339ba38 100644 --- a/layout/src/main/java/com/itextpdf/layout/renderer/TableRenderer.java +++ b/layout/src/main/java/com/itextpdf/layout/renderer/TableRenderer.java @@ -484,16 +484,16 @@ public LayoutResult layout(LayoutContext layoutContext) { // if cell is in the last row on the page, its borders shouldn't collapse with the next row borders while (cellProcessingQueue.size() > 0) { CellRendererInfo currentCellInfo = cellProcessingQueue.pop(); - col = currentCellInfo.column; - CellRenderer cell = currentCellInfo.cellRenderer; + col = currentCellInfo.getColumn(); + CellRenderer cell = currentCellInfo.getCellRenderer(); int colspan = (int) cell.getPropertyAsInteger(Property.COLSPAN); int rowspan = (int) cell.getPropertyAsInteger(Property.ROWSPAN); if (1 != rowspan) { cellWithBigRowspanAdded = true; } - targetOverflowRowIndex[col] = currentCellInfo.finishRowInd; + targetOverflowRowIndex[col] = currentCellInfo.getFinishRowInd(); // This cell came from the future (split occurred and we need to place cell with big rowpsan into the current area) - boolean currentCellHasBigRowspan = (row != currentCellInfo.finishRowInd); + boolean currentCellHasBigRowspan = (row != currentCellInfo.getFinishRowInd()); if (cell.hasOwnOrModelProperty(Property.HEIGHT)) { rowHasCellWithSetHeight = true; } @@ -505,7 +505,7 @@ public LayoutResult layout(LayoutContext layoutContext) { colOffset += countedColumnWidth[l]; } float rowspanOffset = 0; - for (int m = row - 1; m > currentCellInfo.finishRowInd - rowspan && m >= 0; m--) { + for (int m = row - 1; m > currentCellInfo.getFinishRowInd() - rowspan && m >= 0; m--) { rowspanOffset += (float) heights.get(m); } float cellLayoutBoxHeight = rowspanOffset + (!currentCellHasBigRowspan || hasContent ? layoutBox.getHeight() : 0); @@ -519,7 +519,7 @@ public LayoutResult layout(LayoutContext layoutContext) { cell.setProperty(Property.WIDTH, UnitValue.createPointValue(cellWidth)); } // Apply cell borders - float[] cellIndents = bordersHandler.getCellBorderIndents(currentCellInfo.finishRowInd, col, + float[] cellIndents = bordersHandler.getCellBorderIndents(currentCellInfo.getFinishRowInd(), col, rowspan, colspan); if (!(bordersHandler instanceof SeparatedTableBorders)) { // Bottom indent to be applied consists of two parts which should be summed up: @@ -595,9 +595,9 @@ public LayoutResult layout(LayoutContext layoutContext) { if (cellResult.getStatus() == LayoutResult.PARTIAL) { currentRow[col] = (CellRenderer) cellResult.getSplitRenderer(); } else { - rows.get(currentCellInfo.finishRowInd)[col] = null; + rows.get(currentCellInfo.getFinishRowInd())[col] = null; currentRow[col] = cell; - rowMoves.put(col, currentCellInfo.finishRowInd); + rowMoves.put(col, currentCellInfo.getFinishRowInd()); } } else { if (cellResult.getStatus() != LayoutResult.FULL) { @@ -1795,7 +1795,6 @@ private void ensureFooterOrHeaderHasTheSamePropertiesAsParentTableRenderer(Table if (bordersHandler instanceof SeparatedTableBorders) { headerOrFooterRenderer.setProperty(Property.HORIZONTAL_BORDER_SPACING, this.getPropertyAsFloat(Property.HORIZONTAL_BORDER_SPACING)); headerOrFooterRenderer.setProperty(Property.VERTICAL_BORDER_SPACING, this.getPropertyAsFloat(Property.VERTICAL_BORDER_SPACING)); - headerOrFooterRenderer.setProperty(Property.BORDER, Border.NO_BORDER); headerOrFooterRenderer.setProperty(Property.BORDER_LEFT, Border.NO_BORDER); headerOrFooterRenderer.setProperty(Property.BORDER_TOP, Border.NO_BORDER); headerOrFooterRenderer.setProperty(Property.BORDER_RIGHT, Border.NO_BORDER); @@ -1864,9 +1863,9 @@ private float getTableWidth() { * This are a structs used for convenience in layout. */ private static class CellRendererInfo { - public CellRenderer cellRenderer; - public int column; - public int finishRowInd; + private final CellRenderer cellRenderer; + private final int column; + private final int finishRowInd; public CellRendererInfo(CellRenderer cellRenderer, int column, int finishRow) { this.cellRenderer = cellRenderer; @@ -1875,6 +1874,33 @@ public CellRendererInfo(CellRenderer cellRenderer, int column, int finishRow) { // Otherwise, this is simply the index of the row of the cell in the {@link #rows} array. this.finishRowInd = finishRow; } + + /** + * Retrieves the cell renderer. + * + * @return cell renderer + */ + public CellRenderer getCellRenderer() { + return cellRenderer; + } + + /** + * Retrieves the column. + * + * @return column + */ + public int getColumn() { + return column; + } + + /** + * Retrieves the finish row index. + * + * @return finish row index + */ + public int getFinishRowInd() { + return finishRowInd; + } } /** diff --git a/layout/src/main/java/com/itextpdf/layout/renderer/TextRenderer.java b/layout/src/main/java/com/itextpdf/layout/renderer/TextRenderer.java index 89ae4b24b4..d1bb5cbfc1 100644 --- a/layout/src/main/java/com/itextpdf/layout/renderer/TextRenderer.java +++ b/layout/src/main/java/com/itextpdf/layout/renderer/TextRenderer.java @@ -210,7 +210,7 @@ public LayoutResult layout(LayoutContext layoutContext) { boolean anythingPlaced = false; - int currentTextPos = text.start; + int currentTextPos = text.getStart(); UnitValue fontSize = (UnitValue) this.getPropertyAsUnitValue(Property.FONT_SIZE); if (!fontSize.isPointValue()) { Logger logger = LoggerFactory.getLogger(TextRenderer.class); @@ -226,7 +226,8 @@ public LayoutResult layout(LayoutContext layoutContext) { float boldSimulationAddition = Boolean.TRUE.equals(getPropertyAsBoolean(Property.BOLD_SIMULATION)) ? BOLD_SIMULATION_STROKE_COEFF * fontSize.getValue() : 0; line = new GlyphLine(text); - line.start = line.end = -1; + line.setStart(-1); + line.setEnd(-1); float ascender = 0; float descender = 0; @@ -275,21 +276,21 @@ public LayoutResult layout(LayoutContext layoutContext) { // For example, if a first character is a RTL mark (U+200F), and the second is a newline, we need to break anyway int firstPrintPos = currentTextPos; - while (firstPrintPos < text.end && noPrint(text.get(firstPrintPos))) { + while (firstPrintPos < text.getEnd() && noPrint(text.get(firstPrintPos))) { firstPrintPos++; } - while (currentTextPos < text.end) { + while (currentTextPos < text.getEnd()) { if (noPrint(text.get(currentTextPos))) { - if (line.start == -1) { - line.start = currentTextPos; + if (line.getStart() == -1) { + line.setStart(currentTextPos); } - line.end = Math.max(line.end, currentTextPos + 1); + line.setEnd(Math.max(line.getEnd(), currentTextPos + 1)); currentTextPos++; continue; } - int nonBreakablePartEnd = text.end - 1; + int nonBreakablePartEnd = text.getEnd() - 1; float nonBreakablePartFullWidth = 0; float nonBreakablePartWidthWhichDoesNotExceedAllowedWidth = 0; float nonBreakablePartMaxAscender = 0; @@ -301,7 +302,7 @@ public LayoutResult layout(LayoutContext layoutContext) { float beforeNonBreakingHyphenRelatedChunkMaxAscender = 0; float beforeNonBreakingHyphenRelatedChunkMaxDescender = 0; - for (int ind = currentTextPos; ind < text.end; ind++) { + for (int ind = currentTextPos; ind < text.getEnd(); ind++) { if (TextUtil.isNewLine(text.get(ind))) { containsPossibleBreak = true; wordBreakGlyphAtLineEnding = text.get(ind); @@ -314,8 +315,8 @@ public LayoutResult layout(LayoutContext layoutContext) { forcePartialSplitOnFirstChar = true; } - if (line.start == -1) { - line.start = currentTextPos; + if (line.getStart() == -1) { + line.setStart(currentTextPos); } crlf = TextUtil.isCarriageReturnFollowedByLineFeed(text, currentTextPos); @@ -324,19 +325,19 @@ public LayoutResult layout(LayoutContext layoutContext) { currentTextPos++; } - line.end = Math.max(line.end, firstCharacterWhichExceedsAllowedWidth - 1); + line.setEnd(Math.max(line.getEnd(), firstCharacterWhichExceedsAllowedWidth - 1)); break; } Glyph currentGlyph = text.get(ind); if (noPrint(currentGlyph)) { - boolean nextGlyphIsSpaceOrWhiteSpace = ind + 1 < text.end + boolean nextGlyphIsSpaceOrWhiteSpace = ind + 1 < text.getEnd() && (splitCharacters.isSplitCharacter(text, ind + 1) && TextUtil.isSpaceOrWhitespace(text.get(ind + 1))); if (nextGlyphIsSpaceOrWhiteSpace && firstCharacterWhichExceedsAllowedWidth == -1) { containsPossibleBreak = true; } - if (ind + 1 == text.end || nextGlyphIsSpaceOrWhiteSpace + if (ind + 1 == text.getEnd() || nextGlyphIsSpaceOrWhiteSpace || (ind + 1 >= indexOfFirstCharacterToBeForcedToOverflow)) { if (ind + 1 >= indexOfFirstCharacterToBeForcedToOverflow) { firstCharacterWhichExceedsAllowedWidth = currentTextPos; @@ -408,7 +409,8 @@ public LayoutResult layout(LayoutContext layoutContext) { previousCharPos = ind; if (!noSoftWrap && symbolNotFitOnLine - && (0 == nonBreakingHyphenRelatedChunkWidth || ind + 1 == text.end || !glyphBelongsToNonBreakingHyphenRelatedChunk(text, ind + 1))) { + && (0 == nonBreakingHyphenRelatedChunkWidth || ind + 1 == text.getEnd() || + !glyphBelongsToNonBreakingHyphenRelatedChunk(text, ind + 1))) { if (isOverflowFit(overflowX)) { // we have extracted all the information we wanted and we do not want to continue. // we will have to split the word anyway. @@ -432,13 +434,13 @@ public LayoutResult layout(LayoutContext layoutContext) { && findPossibleBreaksSplitPosition(specialScriptsWordBreakPoints, ind + 1, true) >= 0; boolean endOfNonBreakablePartCausedBySplitCharacter = splitCharacters.isSplitCharacter(text, ind) - || (ind + 1 < text.end + || (ind + 1 < text.getEnd() && (splitCharacters.isSplitCharacter(text, ind + 1) && TextUtil.isSpaceOrWhitespace(text.get(ind + 1)))); if (endOfNonBreakablePartCausedBySplitCharacter && firstCharacterWhichExceedsAllowedWidth == -1) { containsPossibleBreak = true; } - if (ind + 1 == text.end + if (ind + 1 == text.getEnd() || endOfNonBreakablePartCausedBySplitCharacter || endOfWordBelongingToSpecialScripts || (ind + 1 >= indexOfFirstCharacterToBeForcedToOverflow)) { @@ -453,10 +455,10 @@ && findPossibleBreaksSplitPosition(specialScriptsWordBreakPoints, if (firstCharacterWhichExceedsAllowedWidth == -1) { // can fit the whole word in a line - if (line.start == -1) { - line.start = currentTextPos; + if (line.getStart() == -1) { + line.setStart(currentTextPos); } - line.end = Math.max(line.end, nonBreakablePartEnd + 1); + line.setEnd(Math.max(line.getEnd(), nonBreakablePartEnd + 1)); currentLineAscender = Math.max(currentLineAscender, nonBreakablePartMaxAscender); currentLineDescender = Math.min(currentLineDescender, nonBreakablePartMaxDescender); currentLineHeight = Math.max(currentLineHeight, nonBreakablePartMaxHeight); @@ -484,10 +486,10 @@ && findPossibleBreaksSplitPosition(specialScriptsWordBreakPoints, applyBorderBox(occupiedArea.getBBox(), borders, true); applyMargins(occupiedArea.getBBox(), margins, true); // Force to place what we can - if (line.start == -1) { - line.start = currentTextPos; + if (line.getStart() == -1) { + line.setStart(currentTextPos); } - line.end = Math.max(line.end, firstCharacterWhichExceedsAllowedWidth); + line.setEnd(Math.max(line.getEnd(), firstCharacterWhichExceedsAllowedWidth)); // the line does not fit because of height - full overflow TextRenderer[] splitResult = split(initialLineTextPos); @@ -505,7 +507,8 @@ && findPossibleBreaksSplitPosition(specialScriptsWordBreakPoints, if (hyphenationConfig != null && indexOfFirstCharacterToBeForcedToOverflow == UNDEFINED_FIRST_CHAR_TO_FORCE_OVERFLOW) { if (-1 == nonBreakingHyphenRelatedChunkStart) { - int[] wordBounds = getWordBoundsForHyphenation(text, currentTextPos, text.end, Math.max(currentTextPos, firstCharacterWhichExceedsAllowedWidth - 1)); + int[] wordBounds = getWordBoundsForHyphenation(text, currentTextPos, text.getEnd(), + Math.max(currentTextPos, firstCharacterWhichExceedsAllowedWidth - 1)); if (wordBounds != null) { String word = text.toUnicodeString(wordBounds[0], wordBounds[1]); Hyphenation hyph = hyphenationConfig.hyphenate(word); @@ -518,13 +521,13 @@ && findPossibleBreaksSplitPosition(specialScriptsWordBreakPoints, if (currentLineWidth + currentHyphenationChoicePreTextWidth + italicSkewAddition + boldSimulationAddition <= layoutBox.getWidth()) { hyphenationApplied = true; - if (line.start == -1) { - line.start = currentTextPos; + if (line.getStart() == -1) { + line.setStart(currentTextPos); } - line.end = Math.max(line.end, wordBounds[0] + pre.length()); - GlyphLine lineCopy = line.copy(line.start, line.end); + line.setEnd(Math.max(line.getEnd(), wordBounds[0] + pre.length())); + GlyphLine lineCopy = line.copy(line.getStart(), line.getEnd()); lineCopy.add(font.getGlyph(hyphenationConfig.getHyphenSymbol())); - lineCopy.end++; + lineCopy.setEnd(lineCopy.getEnd() +1); line = lineCopy; // TODO DEVSIX-7010 recalculate line properties in case of word hyphenation. @@ -554,7 +557,7 @@ && findPossibleBreaksSplitPosition(specialScriptsWordBreakPoints, } } } else { - if (text.start == nonBreakingHyphenRelatedChunkStart) { + if (text.getStart() == nonBreakingHyphenRelatedChunkStart) { nonBreakingHyphenRelatedChunkWidth = 0; firstCharacterWhichExceedsAllowedWidth = previousCharPos + 1; } else { @@ -575,14 +578,14 @@ && findPossibleBreaksSplitPosition(specialScriptsWordBreakPoints, // if the word is too long for a single line we will have to split it // we also need to split the word here if text contains glyphs from scripts // which require word wrapping for further processing in LineRenderer - if (line.start == -1) { - line.start = currentTextPos; + if (line.getStart() == -1) { + line.setStart(currentTextPos); } if (!crlf) { currentTextPos = (forcePartialSplitOnFirstChar || isOverflowFit(overflowX) || specialScriptWordSplit) ? firstCharacterWhichExceedsAllowedWidth : nonBreakablePartEnd + 1; } - line.end = Math.max(line.end, currentTextPos); - wordSplit = !forcePartialSplitOnFirstChar && (text.end != currentTextPos); + line.setEnd(Math.max(line.getEnd(), currentTextPos)); + wordSplit = !forcePartialSplitOnFirstChar && (text.getEnd() != currentTextPos); if (wordSplit || !(forcePartialSplitOnFirstChar || isOverflowFit(overflowX))) { currentLineAscender = Math.max(currentLineAscender, nonBreakablePartMaxAscender); currentLineDescender = Math.min(currentLineDescender, nonBreakablePartMaxDescender); @@ -610,11 +613,11 @@ && findPossibleBreaksSplitPosition(specialScriptsWordBreakPoints, currentLineHeight = FontProgram.convertTextSpaceToGlyphSpace( (currentLineAscender - currentLineDescender) * fontSize.getValue()) + textRise; currentLineWidth += FontProgram.convertTextSpaceToGlyphSpace( - getCharWidth(line.get(line.start), fontSize.getValue(), hScale, characterSpacing, - wordSpacing)); + getCharWidth(line.get(line.getStart()), fontSize.getValue(), hScale, + characterSpacing, wordSpacing)); } } - if (line.end <= line.start) { + if (line.getEnd() <= line.getStart()) { boolean[] startsEnds = isStartsWithSplitCharWhiteSpaceAndEndsWithSplitChar(splitCharacters); return new TextLayoutResult( LayoutResult.NOTHING, occupiedArea, null, this, this) @@ -685,7 +688,7 @@ && findPossibleBreaksSplitPosition(specialScriptsWordBreakPoints, } // no sense to process empty renderer - if (split[1].text.start != split[1].text.end) { + if (split[1].text.getStart() != split[1].text.getEnd()) { result.setOverflowRenderer(split[1]); } else { // LayoutResult with partial status should have non-null overflow renderer @@ -736,7 +739,7 @@ private void increaseYLineOffset(UnitValue[] paddings, Border[] borders, UnitVal public void applyOtf() { updateFontAndText(); Character.UnicodeScript script = this.getProperty(Property.FONT_SCRIPT); - if (!otfFeaturesApplied && TypographyUtils.isPdfCalligraphAvailable() && text.start < text.end) { + if (!otfFeaturesApplied && TypographyUtils.isPdfCalligraphAvailable() && text.getStart() < text.getEnd()) { final PdfDocument pdfDocument = getPdfDocument(); final SequenceId sequenceId = pdfDocument == null ? null : pdfDocument.getDocumentIdWrapper(); final MetaInfoContainer metaInfoContainer = this.getProperty(Property.META_INFO); @@ -752,12 +755,12 @@ public void applyOtf() { } List scriptsRanges = new ArrayList<>(); if (script != null) { - scriptsRanges.add(new ScriptRange(script, text.end)); + scriptsRanges.add(new ScriptRange(script, text.getEnd())); } else { // Try to autodetect script. - ScriptRange currRange = new ScriptRange(null, text.end); + ScriptRange currRange = new ScriptRange(null, text.getEnd()); scriptsRanges.add(currRange); - for (int i = text.start; i < text.end; i++) { + for (int i = text.getStart(); i < text.getEnd(); i++) { int unicode = text.get(i).getUnicode(); if (unicode > -1) { Character.UnicodeScript glyphScript = Character.UnicodeScript.of(unicode); @@ -770,7 +773,7 @@ public void applyOtf() { currRange.script = glyphScript; } else { currRange.rangeEnd = i; - currRange = new ScriptRange(glyphScript, text.end); + currRange = new ScriptRange(glyphScript, text.getEnd()); scriptsRanges.add(currRange); } } @@ -779,16 +782,16 @@ public void applyOtf() { } int delta = 0; - int origTextStart = text.start; - int origTextEnd = text.end; - int shapingRangeStart = text.start; + int origTextStart = text.getStart(); + int origTextEnd = text.getEnd(); + int shapingRangeStart = text.getStart(); for (ScriptRange scriptsRange : scriptsRanges) { if (scriptsRange.script == null || !supportedScripts.contains(EnumUtil.throwIfNull(scriptsRange.script))) { continue; } scriptsRange.rangeEnd += delta; - text.start = shapingRangeStart; - text.end = scriptsRange.rangeEnd; + text.setStart(shapingRangeStart); + text.setEnd(scriptsRange.rangeEnd); if ((scriptsRange.script == Character.UnicodeScript.ARABIC || scriptsRange.script == Character.UnicodeScript.HEBREW) && parent instanceof LineRenderer) { // It's safe to set here BASE_DIRECTION to TextRenderer without additional checks, because @@ -801,11 +804,11 @@ public void applyOtf() { TypographyUtils.applyOtfScript( font.getFontProgram(), text, scriptsRange.script, typographyConfig, sequenceId, metaInfo); - delta += text.end - scriptsRange.rangeEnd; - scriptsRange.rangeEnd = shapingRangeStart = text.end; + delta += text.getEnd() - scriptsRange.rangeEnd; + scriptsRange.rangeEnd = shapingRangeStart = text.getEnd(); } - text.start = origTextStart; - text.end = origTextEnd + delta; + text.setStart(origTextStart); + text.setEnd(origTextEnd + delta); } FontKerning fontKerning = (FontKerning) this.getProperty(Property.FONT_KERNING, FontKerning.NO); @@ -855,7 +858,7 @@ public void draw(DrawContext drawContext) { float leftBBoxX = getInnerAreaBBox().getX(); - if (line.end > line.start || savedWordBreakAtLineEnding != null) { + if (line.getEnd() > line.getStart() || savedWordBreakAtLineEnding != null) { UnitValue fontSize = this.getPropertyAsUnitValue(Property.FONT_SIZE); if (!fontSize.isPointValue()) { Logger logger = LoggerFactory.getLogger(TextRenderer.class); @@ -932,7 +935,7 @@ public void draw(DrawContext drawContext) { // It does not apply to occurrences of the byte value 32 in multiple-byte codes. // // For PdfType0Font we must add word manually with glyph offsets - for (int gInd = line.start; gInd < line.end; gInd++) { + for (int gInd = line.getStart(); gInd < line.getEnd(); gInd++) { if (TextUtil.isUni0020(line.get(gInd))) { final short advance = (short) (FontProgram.convertGlyphSpaceToTextSpace((float) wordSpacing) / fontSize.getValue()); @@ -956,7 +959,7 @@ public void draw(DrawContext drawContext) { if (getReversedRanges() != null) { boolean writeReversedChars = !appearanceStreamLayout; ArrayList removedIds = new ArrayList<>(); - for (int i = line.start; i < line.end; i++) { + for (int i = line.getStart(); i < line.getEnd(); i++) { if (!filter.accept(line.get(i))) { removedIds.add(i); } @@ -973,7 +976,7 @@ public void draw(DrawContext drawContext) { } } else { if (appearanceStreamLayout) { - line.setActualText(line.start, line.end, null); + line.setActualText(line.getStart(), line.getEnd(), null); } canvas.showText(line.filter(filter)); } @@ -1021,9 +1024,9 @@ public void trimFirst() { if (text != null) { Glyph glyph; - while (text.start < text.end - && TextUtil.isWhitespace(glyph = text.get(text.start)) && !TextUtil.isNewLine(glyph)) { - text.start++; + while (text.getStart() < text.getEnd() + && TextUtil.isWhitespace(glyph = text.get(text.getStart())) && !TextUtil.isNewLine(glyph)) { + text.setStart(text.getStart() +1); } } @@ -1036,7 +1039,7 @@ public void trimFirst() { in case if the removed break point was the only possible break point). */ if (textContainsSpecialScriptGlyphs(true) - && specialScriptsWordBreakPoints.get(0) == text.start) { + && specialScriptsWordBreakPoints.get(0) == text.getStart()) { if (specialScriptsWordBreakPoints.size() == 1) { specialScriptsWordBreakPoints.set(0, -1); } else { @@ -1048,7 +1051,7 @@ public void trimFirst() { float trimLast() { float trimmedSpace = 0; - if (line.end <= 0) + if (line.getEnd() <= 0) return trimmedSpace; UnitValue fontSize = (UnitValue) this.getPropertyAsUnitValue(Property.FONT_SIZE); @@ -1061,8 +1064,8 @@ float trimLast() { Float wordSpacing = this.getPropertyAsFloat(Property.WORD_SPACING); float hScale = (float) this.getPropertyAsFloat(Property.HORIZONTAL_SCALING, 1f); - int firstNonSpaceCharIndex = line.end - 1; - while (firstNonSpaceCharIndex >= line.start) { + int firstNonSpaceCharIndex = line.getEnd() - 1; + while (firstNonSpaceCharIndex >= line.getStart()) { Glyph currentGlyph = line.get(firstNonSpaceCharIndex); if (!TextUtil.isWhitespace(currentGlyph)) { break; @@ -1071,7 +1074,7 @@ float trimLast() { final float currentCharWidth = FontProgram.convertTextSpaceToGlyphSpace( getCharWidth(currentGlyph, fontSize.getValue(), hScale, characterSpacing, wordSpacing)); - final float xAdvance = firstNonSpaceCharIndex > line.start ? FontProgram.convertTextSpaceToGlyphSpace( + final float xAdvance = firstNonSpaceCharIndex > line.getStart() ? FontProgram.convertTextSpaceToGlyphSpace( scaleXAdvance(line.get(firstNonSpaceCharIndex - 1).getXAdvance(), fontSize.getValue(), hScale)) : 0; trimmedSpace += currentCharWidth - xAdvance; occupiedArea.getBBox().setWidth(occupiedArea.getBBox().getWidth() - currentCharWidth); @@ -1079,7 +1082,7 @@ float trimLast() { firstNonSpaceCharIndex--; } - line.end = firstNonSpaceCharIndex + 1; + line.setEnd(firstNonSpaceCharIndex + 1); return trimmedSpace; } @@ -1160,7 +1163,7 @@ public GlyphLine getText() { * @return the text length */ public int length() { - return text == null ? 0 : text.end - text.start; + return text == null ? 0 : text.getEnd() - text.getStart(); } @Override @@ -1175,7 +1178,7 @@ public String toString() { * @return Unicode char code */ public int charAt(int pos) { - return text.get(pos + text.start).getUnicode(); + return text.get(pos + text.getStart()).getUnicode(); } public float getTabAnchorCharacterPosition() { @@ -1304,7 +1307,7 @@ boolean textContainsSpecialScriptGlyphs(boolean analyzeSpecialScriptsWordBreakPo specialScriptsWordBreakPoints = new ArrayList<>(); } - for (int i = text.start; i < text.end; i++) { + for (int i = text.getStart(); i < text.getEnd(); i++) { int unicode = text.get(i).getUnicode(); if (unicode > -1) { if (codePointIsOfSpecialScript(unicode)) { @@ -1371,12 +1374,12 @@ protected Float getLastYLineRecursively() { * @return the length of the line */ protected int lineLength() { - return line.end > 0 ? line.end - line.start : 0; + return line.getEnd() > 0 ? line.getEnd() - line.getStart() : 0; } protected int baseCharactersCount() { int count = 0; - for (int i = line.start; i < line.end; i++) { + for (int i = line.getStart(); i < line.getEnd(); i++) { Glyph glyph = line.get(i); if (!glyph.hasPlacement()) { count++; @@ -1392,10 +1395,10 @@ public MinMaxWidth getMinMaxWidth() { } protected int getNumberOfSpaces() { - if (line.end <= 0) + if (line.getEnd() <= 0) return 0; int spaces = 0; - for (int i = line.start; i < line.end; i++) { + for (int i = line.getStart(); i < line.getEnd(); i++) { Glyph currentGlyph = line.get(i); if (currentGlyph.getUnicode() == ' ') { spaces++; @@ -1415,8 +1418,8 @@ protected TextRenderer createOverflowRenderer() { protected TextRenderer[] split(int initialOverflowTextPos) { TextRenderer splitRenderer = createSplitRenderer(); GlyphLine newText = new GlyphLine(text); - newText.start = text.start; - newText.end = initialOverflowTextPos; + newText.setStart(text.getStart()); + newText.setEnd(initialOverflowTextPos); splitRenderer.setProcessedGlyphLineAndFont(newText, font); splitRenderer.line = line; splitRenderer.occupiedArea = occupiedArea.clone(); @@ -1428,8 +1431,8 @@ protected TextRenderer[] split(int initialOverflowTextPos) { TextRenderer overflowRenderer = createOverflowRenderer(); newText = new GlyphLine(text); - newText.start = initialOverflowTextPos; - newText.end = text.end; + newText.setStart(initialOverflowTextPos); + newText.setEnd(text.getEnd()); overflowRenderer.setProcessedGlyphLineAndFont(newText, font); overflowRenderer.otfFeaturesApplied = otfFeaturesApplied; overflowRenderer.parent = parent; @@ -1643,16 +1646,16 @@ PdfFont resolveFirstPdfFont(String[] font, FontProvider provider, FontCharacteri * break possibility. */ boolean[] isStartsWithSplitCharWhiteSpaceAndEndsWithSplitChar(ISplitCharacters splitCharacters) { - boolean startsWithBreak = line.start < line.end - && splitCharacters.isSplitCharacter(text, line.start) - && TextUtil.isSpaceOrWhitespace(text.get(line.start)); - boolean endsWithBreak = line.start < line.end - && splitCharacters.isSplitCharacter(text, line.end - 1); + boolean startsWithBreak = line.getStart() < line.getEnd() + && splitCharacters.isSplitCharacter(text, line.getStart()) + && TextUtil.isSpaceOrWhitespace(text.get(line.getStart())); + boolean endsWithBreak = line.getStart() < line.getEnd() + && splitCharacters.isSplitCharacter(text, line.getEnd() - 1); if (specialScriptsWordBreakPoints == null || specialScriptsWordBreakPoints.isEmpty()) { return new boolean[]{startsWithBreak, endsWithBreak}; } else { if (!endsWithBreak) { - endsWithBreak = specialScriptsWordBreakPoints.contains(line.end); + endsWithBreak = specialScriptsWordBreakPoints.contains(line.getEnd()); } return new boolean[]{startsWithBreak, endsWithBreak}; } @@ -1690,11 +1693,12 @@ private float scaleXAdvance(float xAdvance, float fontSize, Float hScale) { private float getGlyphLineWidth(GlyphLine glyphLine, float fontSize, float hScale, Float characterSpacing, Float wordSpacing) { float width = 0; - for (int i = glyphLine.start; i < glyphLine.end; i++) { + for (int i = glyphLine.getStart(); i < glyphLine.getEnd(); i++) { if (!noPrint(glyphLine.get(i))) { float charWidth = getCharWidth(glyphLine.get(i), fontSize, hScale, characterSpacing, wordSpacing); width += charWidth; - float xAdvance = (i != glyphLine.start) ? scaleXAdvance(glyphLine.get(i - 1).getXAdvance(), fontSize, hScale) : 0; + float xAdvance = (i != glyphLine.getStart()) ? scaleXAdvance(glyphLine.get(i - 1).getXAdvance(), + fontSize, hScale) : 0; width += xAdvance; } } @@ -1785,7 +1789,9 @@ private static boolean noPrint(Glyph g) { } private static boolean glyphBelongsToNonBreakingHyphenRelatedChunk(GlyphLine text, int ind) { - return TextUtil.isNonBreakingHyphen(text.get(ind)) || (ind + 1 < text.end && TextUtil.isNonBreakingHyphen(text.get(ind + 1))) || ind - 1 >= text.start && TextUtil.isNonBreakingHyphen(text.get(ind - 1)); + return TextUtil.isNonBreakingHyphen(text.get(ind)) || (ind + 1 < text.getEnd() && + TextUtil.isNonBreakingHyphen(text.get(ind + 1))) || ind - 1 >= text.getStart() && + TextUtil.isNonBreakingHyphen(text.get(ind - 1)); } private static class ReversedCharsIterator implements Iterator { @@ -1823,8 +1829,8 @@ public ReversedCharsIterator(List reversedRange, GlyphLine line) { reversed.add(false); } } else { - outStart.add(line.start); - outEnd.add(line.end); + outStart.add(line.getStart()); + outEnd.add(line.getEnd()); reversed.add(false); } } diff --git a/layout/src/main/java/com/itextpdf/layout/renderer/TextSequenceWordWrapping.java b/layout/src/main/java/com/itextpdf/layout/renderer/TextSequenceWordWrapping.java index 738aec1155..7473494bdc 100644 --- a/layout/src/main/java/com/itextpdf/layout/renderer/TextSequenceWordWrapping.java +++ b/layout/src/main/java/com/itextpdf/layout/renderer/TextSequenceWordWrapping.java @@ -211,7 +211,7 @@ public static LastFittingChildRendererData getIndexAndLayoutResultOfTheLastTextR } if (textLayoutResult.isContainsPossibleBreak() && textLayoutResult.getStatus() != LayoutResult.NOTHING) { - textRenderer.setIndexOfFirstCharacterToBeForcedToOverflow(textRenderer.line.end); + textRenderer.setIndexOfFirstCharacterToBeForcedToOverflow(textRenderer.line.getEnd()); LayoutArea layoutArea = textRenderer.getOccupiedArea().clone(); layoutArea.getBBox() .increaseHeight(OCCUPIED_AREA_RELAYOUT_EPS) @@ -299,8 +299,9 @@ public static LastFittingChildRendererData getIndexAndLayoutResultOfTheLastTextR GlyphLine splitText = splitTextRenderer.text; if (splitTextRenderer.length() > 0) { fittingLengthWithTrailingRightSideSpaces = splitTextRenderer.length(); - while (splitText.end + amountOfTrailingRightSideSpaces < splitText.size() - && TextUtil.isWhitespace(splitText.get(splitText.end + amountOfTrailingRightSideSpaces))) { + while (splitText.getEnd() + amountOfTrailingRightSideSpaces < splitText.size() + && TextUtil.isWhitespace(splitText.get(splitText.getEnd() + + amountOfTrailingRightSideSpaces))) { fittingLengthWithTrailingRightSideSpaces++; amountOfTrailingRightSideSpaces++; } @@ -313,10 +314,10 @@ public static LastFittingChildRendererData getIndexAndLayoutResultOfTheLastTextR if (breakPoints != null && breakPoints.size() > 0 && breakPoints.get(0) != -1) { int possibleBreakPointPosition = TextRenderer.findPossibleBreaksSplitPosition( textRenderer.getSpecialScriptsWordBreakPoints(), - fittingLengthWithTrailingRightSideSpaces + textRenderer.text.start, false); + fittingLengthWithTrailingRightSideSpaces + textRenderer.text.getStart(), false); if (possibleBreakPointPosition > -1) { splitPosition = breakPoints.get(possibleBreakPointPosition) - amountOfTrailingRightSideSpaces; - needToSplitRendererContainingLastFullyFittingWord = splitPosition != textRenderer.text.end; + needToSplitRendererContainingLastFullyFittingWord = splitPosition != textRenderer.text.getEnd(); if (!needToSplitRendererContainingLastFullyFittingWord) { analyzedTextRendererIndex++; } @@ -370,7 +371,7 @@ public static LastFittingChildRendererData getIndexAndLayoutResultOfTheLastTextR if (needToSplitRendererContainingLastFullyFittingWord) { int amountOfFitOnTheFirstLayout = fittingLengthWithTrailingRightSideSpaces - amountOfTrailingRightSideSpaces - + childRenderer.text.start; + + childRenderer.text.getStart(); if (amountOfFitOnTheFirstLayout != splitPosition) { LayoutArea layoutArea = childRenderer.getOccupiedArea().clone(); layoutArea.getBBox() @@ -682,15 +683,15 @@ private static void fillActualTextChunkRelatedLists( while (actualTextIterator.hasNext()) { GlyphLine.GlyphLinePart part = actualTextIterator.next(); int amountOfCharsWithinCurrentActualTextOrGlyph = 0; - if (part.actualText != null) { - amountOfCharsWithinCurrentActualTextOrGlyph = part.actualText.length(); + if (part.getActualText() != null) { + amountOfCharsWithinCurrentActualTextOrGlyph = part.getActualText().length(); int nextAmountOfChars = amountOfCharsWithinCurrentActualTextOrGlyph + amountOfCharsBetweenTextStartAndCurrentActualTextStartOrGlyph; amountOfCharsBetweenTextStartAndActualTextChunk.add(nextAmountOfChars); - glyphLineBasedIndicesOfActualTextChunkEnds.add(part.end); + glyphLineBasedIndicesOfActualTextChunkEnds.add(part.getEnd()); amountOfCharsBetweenTextStartAndCurrentActualTextStartOrGlyph = nextAmountOfChars; } else { - for (int j = part.start; j < part.end; j++) { + for (int j = part.getStart(); j < part.getEnd(); j++) { char[] chars = glyphLine.get(j).getChars(); amountOfCharsWithinCurrentActualTextOrGlyph = chars != null ? chars.length : 0; int nextAmountOfChars = amountOfCharsWithinCurrentActualTextOrGlyph diff --git a/layout/src/main/java/com/itextpdf/layout/validation/context/LayoutValidationContext.java b/layout/src/main/java/com/itextpdf/layout/validation/context/LayoutValidationContext.java new file mode 100644 index 0000000000..e41e582342 --- /dev/null +++ b/layout/src/main/java/com/itextpdf/layout/validation/context/LayoutValidationContext.java @@ -0,0 +1,57 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.layout.validation.context; + +import com.itextpdf.kernel.validation.ValidationType; +import com.itextpdf.kernel.validation.IValidationContext; +import com.itextpdf.layout.renderer.IRenderer; + +/** + * Class for {@link IRenderer} validation context. + */ +public class LayoutValidationContext implements IValidationContext { + private final IRenderer renderer; + + /** + * Instantiates a new {@link LayoutValidationContext} based on renderer. + * + * @param renderer the renderer + */ + public LayoutValidationContext(IRenderer renderer) { + this.renderer = renderer; + } + + /** + * Gets the renderer. + * + * @return the renderer + */ + public IRenderer getRenderer() { + return renderer; + } + + @Override + public ValidationType getType() { + return ValidationType.LAYOUT; + } +} diff --git a/layout/src/test/java/com/itextpdf/layout/AbstractTableTest.java b/layout/src/test/java/com/itextpdf/layout/AbstractTableTest.java index 212df75f79..ec4ff5c86b 100644 --- a/layout/src/test/java/com/itextpdf/layout/AbstractTableTest.java +++ b/layout/src/test/java/com/itextpdf/layout/AbstractTableTest.java @@ -27,11 +27,10 @@ This file is part of the iText (R) project. import com.itextpdf.layout.element.Table; import com.itextpdf.layout.properties.UnitValue; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class AbstractTableTest extends ExtendedITextTest { static Document addTableBelowToCheckThatOccupiedAreaIsCorrect(Document doc) { doc.add(new Table(UnitValue.createPercentArray(1)) diff --git a/layout/src/test/java/com/itextpdf/layout/AlignmentTest.java b/layout/src/test/java/com/itextpdf/layout/AlignmentTest.java index 5c23dbe220..1a73801eff 100644 --- a/layout/src/test/java/com/itextpdf/layout/AlignmentTest.java +++ b/layout/src/test/java/com/itextpdf/layout/AlignmentTest.java @@ -41,23 +41,22 @@ This file is part of the iText (R) project. import com.itextpdf.layout.renderer.DocumentRenderer; import com.itextpdf.layout.renderer.FlexContainerRenderer; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.net.MalformedURLException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class AlignmentTest extends ExtendedITextTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/layout/AlignmentTest/"; private static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/layout/AlignmentTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(DESTINATION_FOLDER); } @@ -80,7 +79,7 @@ public void justifyAlignmentTest01() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -97,7 +96,7 @@ public void justifyAlignmentTest02() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -117,7 +116,7 @@ public void justifyAlignmentTest03() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -137,7 +136,7 @@ public void justifyAlignmentTest04() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -158,7 +157,7 @@ public void justifyAlignmentForcedNewlinesTest01() throws IOException, Interrupt document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -179,7 +178,7 @@ public void justifyAllTest01() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -202,7 +201,7 @@ public void justifyAllTest02() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -228,7 +227,7 @@ public void blockAlignmentTest01() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -251,7 +250,7 @@ public void blockAlignmentTest02() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -273,7 +272,7 @@ public void imageAlignmentTest01() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -292,7 +291,7 @@ public void emptyLineJustification01() throws IOException, InterruptedException doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -318,7 +317,7 @@ public void floatAlignmentTest01() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } private static void addFloatAndText(Document doc, FloatPropertyValue floatPropertyValue) { @@ -363,7 +362,7 @@ public void floatAlignmentTest02() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -511,7 +510,7 @@ public void inlineVerticalAlignmentmixedTest() throws IOException, InterruptedEx doc.add(p); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @@ -582,7 +581,7 @@ public void floatAlignmentTest03() throws IOException, InterruptedException { doc.close(); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -600,7 +599,7 @@ public void flexItemHorizontalAlignmentTest() throws IOException, InterruptedExc div.setNextRenderer(flexContainerRenderer); Div innerDiv = new Div(); - innerDiv.setProperty(Property.BORDER, new SolidBorder(1)); + innerDiv.setBorder(new SolidBorder(1)); innerDiv.setProperty(Property.WIDTH, UnitValue.createPointValue(50)); innerDiv.setProperty(Property.HEIGHT, UnitValue.createPointValue(100)); innerDiv.setProperty(Property.BACKGROUND, new Background(ColorConstants.GREEN)); @@ -610,7 +609,7 @@ public void flexItemHorizontalAlignmentTest() throws IOException, InterruptedExc doc.add(div); } - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } private static void createDocumentWithInlineAlignment(String outPdf, String cmpPdf, @@ -655,7 +654,7 @@ private static void createDocumentWithInlineAlignment(String outPdf, String cmpP doc.add(p); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @@ -673,7 +672,7 @@ private static void createDocumentWithAlignment(String outPdf, String cmpPdf, Ve pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } private void addInlineBlockFloatAndText(Document doc, Div div) { diff --git a/layout/src/test/java/com/itextpdf/layout/AreaBreakTest.java b/layout/src/test/java/com/itextpdf/layout/AreaBreakTest.java index daa9aad9d5..619b8de8ae 100644 --- a/layout/src/test/java/com/itextpdf/layout/AreaBreakTest.java +++ b/layout/src/test/java/com/itextpdf/layout/AreaBreakTest.java @@ -36,23 +36,22 @@ This file is part of the iText (R) project. import com.itextpdf.layout.renderer.DivRenderer; import com.itextpdf.layout.renderer.IRenderer; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; import java.util.Arrays; import java.util.List; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class AreaBreakTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/layout/AreaBreakTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/layout/AreaBreakTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } @@ -68,7 +67,7 @@ public void pageBreakTest1() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -82,7 +81,7 @@ public void pageBreakTest2() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -99,7 +98,7 @@ public void pageBreakTest03() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -116,7 +115,7 @@ public void lastPageAreaBreakTest01() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -134,7 +133,7 @@ public void lastPageAreaBreakTest02() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -153,7 +152,7 @@ public void lastPageAreaBreakTest03() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -172,7 +171,7 @@ public void lastPageAreaBreakTest04() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -187,7 +186,7 @@ public void areaBreakInsideDiv01Test() throws IOException, InterruptedException document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -202,7 +201,7 @@ public void areaBreakInsideDiv02Test() throws IOException, InterruptedException document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -220,7 +219,7 @@ public void areaBreakInsideDiv03Test() throws IOException, InterruptedException document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -236,7 +235,7 @@ public void areaBreakInsideDiv04Test() throws IOException, InterruptedException document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } private static class DivRendererWithAreas extends DivRenderer { diff --git a/layout/src/test/java/com/itextpdf/layout/BackgroundColorTest.java b/layout/src/test/java/com/itextpdf/layout/BackgroundColorTest.java index d0f8684859..9bcd6e9c2c 100644 --- a/layout/src/test/java/com/itextpdf/layout/BackgroundColorTest.java +++ b/layout/src/test/java/com/itextpdf/layout/BackgroundColorTest.java @@ -34,14 +34,13 @@ This file is part of the iText (R) project. import com.itextpdf.layout.element.Text; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class BackgroundColorTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/layout/BackgroundColorTest/"; @@ -52,7 +51,7 @@ public class BackgroundColorTest extends ExtendedITextTest { String outFileName; String cmpFileName; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } @@ -78,7 +77,7 @@ private void closeDocumentAndCompareOutputs(Document document) throws IOExceptio document.close(); String compareResult = new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff"); if (compareResult != null) { - Assert.fail(compareResult); + Assertions.fail(compareResult); } } } diff --git a/layout/src/test/java/com/itextpdf/layout/BackgroundPositionUnitTest.java b/layout/src/test/java/com/itextpdf/layout/BackgroundPositionUnitTest.java index 55cd7cab9d..ad89eac99a 100644 --- a/layout/src/test/java/com/itextpdf/layout/BackgroundPositionUnitTest.java +++ b/layout/src/test/java/com/itextpdf/layout/BackgroundPositionUnitTest.java @@ -25,19 +25,18 @@ This file is part of the iText (R) project. import com.itextpdf.layout.properties.BackgroundPosition; import com.itextpdf.layout.properties.UnitValue; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class BackgroundPositionUnitTest extends ExtendedITextTest { @Test public void defaultConstructorTest() { BackgroundPosition position = new BackgroundPosition(); - Assert.assertEquals(new BackgroundPosition().setPositionX(BackgroundPosition.PositionX.LEFT).setPositionY(BackgroundPosition.PositionY.TOP) + Assertions.assertEquals(new BackgroundPosition().setPositionX(BackgroundPosition.PositionX.LEFT).setPositionY(BackgroundPosition.PositionY.TOP) .setXShift(new UnitValue(UnitValue.POINT, 0)).setYShift(new UnitValue(UnitValue.POINT, 0)), position); } @@ -50,8 +49,8 @@ public void processPercentageTest() { UnitValue yPosition = UnitValue.createPointValue(0); position.calculatePositionValues(1000, 300, xPosition, yPosition); - Assert.assertEquals(new UnitValue(UnitValue.POINT, 970), xPosition); - Assert.assertEquals(new UnitValue(UnitValue.POINT, 30), yPosition); + Assertions.assertEquals(new UnitValue(UnitValue.POINT, 970), xPosition); + Assertions.assertEquals(new UnitValue(UnitValue.POINT, 30), yPosition); position = new BackgroundPosition().setPositionX(BackgroundPosition.PositionX.CENTER).setPositionY(BackgroundPosition.PositionY.BOTTOM) .setXShift(new UnitValue(UnitValue.POINT, 30)).setYShift(new UnitValue(UnitValue.PERCENT, 10)); @@ -60,8 +59,8 @@ public void processPercentageTest() { yPosition = UnitValue.createPointValue(0); position.calculatePositionValues(1000, 300, xPosition, yPosition); - Assert.assertEquals(new UnitValue(UnitValue.POINT, 0), xPosition); - Assert.assertEquals(new UnitValue(UnitValue.POINT, 270), yPosition); + Assertions.assertEquals(new UnitValue(UnitValue.POINT, 0), xPosition); + Assertions.assertEquals(new UnitValue(UnitValue.POINT, 270), yPosition); } @Test @@ -70,8 +69,8 @@ public void processValidPositionTest() { final UnitValue valueX = new UnitValue(UnitValue.PERCENT, 0); final UnitValue valueY = new UnitValue(UnitValue.PERCENT, 0); position.calculatePositionValues(1000, 1000, valueX, valueY); - Assert.assertEquals(new UnitValue(UnitValue.POINT, 170), valueX); - Assert.assertEquals(new UnitValue(UnitValue.POINT, 0), valueY); + Assertions.assertEquals(new UnitValue(UnitValue.POINT, 170), valueX); + Assertions.assertEquals(new UnitValue(UnitValue.POINT, 0), valueY); } @Test @@ -82,8 +81,8 @@ public void processInvalidPositionTest() { final UnitValue valueX = new UnitValue(UnitValue.PERCENT, 0); final UnitValue valueY = new UnitValue(UnitValue.PERCENT, 0); position.calculatePositionValues(1000, 1000, valueX, valueY); - Assert.assertEquals(new UnitValue(UnitValue.POINT, 0), valueX); - Assert.assertEquals(new UnitValue(UnitValue.POINT, 0), valueY); + Assertions.assertEquals(new UnitValue(UnitValue.POINT, 0), valueX); + Assertions.assertEquals(new UnitValue(UnitValue.POINT, 0), valueY); } @Test @@ -94,8 +93,8 @@ public void processCenterWithoutShiftPositionTest() { final UnitValue valueX = new UnitValue(UnitValue.PERCENT, 0); final UnitValue valueY = new UnitValue(UnitValue.PERCENT, 0); position.calculatePositionValues(1000, 1000, valueX, valueY); - Assert.assertEquals(new UnitValue(UnitValue.POINT, 500), valueX); - Assert.assertEquals(new UnitValue(UnitValue.POINT, 500), valueY); + Assertions.assertEquals(new UnitValue(UnitValue.POINT, 500), valueX); + Assertions.assertEquals(new UnitValue(UnitValue.POINT, 500), valueY); } @Test @@ -106,8 +105,8 @@ public void processCenterWithZeroShiftPositionTest() { final UnitValue valueX = new UnitValue(UnitValue.PERCENT, 0); final UnitValue valueY = new UnitValue(UnitValue.PERCENT, 0); position.calculatePositionValues(1000, 1000, valueX, valueY); - Assert.assertEquals(new UnitValue(UnitValue.POINT, 500), valueX); - Assert.assertEquals(new UnitValue(UnitValue.POINT, 500), valueY); + Assertions.assertEquals(new UnitValue(UnitValue.POINT, 500), valueX); + Assertions.assertEquals(new UnitValue(UnitValue.POINT, 500), valueY); } @Test @@ -118,8 +117,8 @@ public void processCenterWithAlmostZeroShiftPositionTest() { final UnitValue valueX = new UnitValue(UnitValue.PERCENT, 0); final UnitValue valueY = new UnitValue(UnitValue.PERCENT, 0); position.calculatePositionValues(1000, 1000, valueX, valueY); - Assert.assertEquals(new UnitValue(UnitValue.POINT, 0), valueX); - Assert.assertEquals(new UnitValue(UnitValue.POINT, 0), valueY); + Assertions.assertEquals(new UnitValue(UnitValue.POINT, 0), valueX); + Assertions.assertEquals(new UnitValue(UnitValue.POINT, 0), valueY); } @Test @@ -127,10 +126,10 @@ public void gettersTest() { BackgroundPosition position = new BackgroundPosition().setPositionX(BackgroundPosition.PositionX.RIGHT).setPositionY(BackgroundPosition.PositionY.BOTTOM) .setXShift(new UnitValue(UnitValue.POINT, 30)).setYShift(new UnitValue(UnitValue.PERCENT, 10)); - Assert.assertEquals(BackgroundPosition.PositionX.RIGHT, position.getPositionX()); - Assert.assertEquals(BackgroundPosition.PositionY.BOTTOM, position.getPositionY()); - Assert.assertEquals(new UnitValue(UnitValue.POINT, 30), position.getXShift()); - Assert.assertEquals(new UnitValue(UnitValue.PERCENT, 10), position.getYShift()); + Assertions.assertEquals(BackgroundPosition.PositionX.RIGHT, position.getPositionX()); + Assertions.assertEquals(BackgroundPosition.PositionY.BOTTOM, position.getPositionY()); + Assertions.assertEquals(new UnitValue(UnitValue.POINT, 30), position.getXShift()); + Assertions.assertEquals(new UnitValue(UnitValue.PERCENT, 10), position.getYShift()); } @Test @@ -142,10 +141,10 @@ public void settersTest() { position.setXShift(new UnitValue(UnitValue.POINT, 30)); position.setYShift(new UnitValue(UnitValue.PERCENT, 10)); - Assert.assertEquals(BackgroundPosition.PositionX.RIGHT, position.getPositionX()); - Assert.assertEquals(BackgroundPosition.PositionY.BOTTOM, position.getPositionY()); - Assert.assertEquals(new UnitValue(UnitValue.POINT, 30), position.getXShift()); - Assert.assertEquals(new UnitValue(UnitValue.PERCENT, 10), position.getYShift()); + Assertions.assertEquals(BackgroundPosition.PositionX.RIGHT, position.getPositionX()); + Assertions.assertEquals(BackgroundPosition.PositionY.BOTTOM, position.getPositionY()); + Assertions.assertEquals(new UnitValue(UnitValue.POINT, 30), position.getXShift()); + Assertions.assertEquals(new UnitValue(UnitValue.PERCENT, 10), position.getYShift()); } @Test @@ -156,7 +155,7 @@ public void equalsTest() { BackgroundPosition position2 = new BackgroundPosition().setPositionX(BackgroundPosition.PositionX.RIGHT).setPositionY(BackgroundPosition.PositionY.BOTTOM) .setXShift(new UnitValue(UnitValue.POINT, 30)).setYShift(new UnitValue(UnitValue.PERCENT, 10)); - Assert.assertEquals(position1, position2); + Assertions.assertEquals(position1, position2); } @Test @@ -164,7 +163,7 @@ public void equalsSameObjectTest() { BackgroundPosition position1 = new BackgroundPosition().setPositionX(BackgroundPosition.PositionX.RIGHT).setPositionY(BackgroundPosition.PositionY.BOTTOM) .setXShift(new UnitValue(UnitValue.POINT, 30)).setYShift(new UnitValue(UnitValue.PERCENT, 10)); - Assert.assertEquals(position1, position1); + Assertions.assertEquals(position1, position1); } @Test @@ -172,7 +171,7 @@ public void equalsNullTest() { BackgroundPosition position1 = new BackgroundPosition().setPositionX(BackgroundPosition.PositionX.RIGHT).setPositionY(BackgroundPosition.PositionY.BOTTOM) .setXShift(new UnitValue(UnitValue.POINT, 30)).setYShift(new UnitValue(UnitValue.PERCENT, 10)); - Assert.assertNotEquals(position1, null); + Assertions.assertNotEquals(position1, null); } @Test @@ -180,7 +179,7 @@ public void equalsWrongTypeTest() { BackgroundPosition position1 = new BackgroundPosition().setPositionX(BackgroundPosition.PositionX.RIGHT).setPositionY(BackgroundPosition.PositionY.BOTTOM) .setXShift(new UnitValue(UnitValue.POINT, 30)).setYShift(new UnitValue(UnitValue.PERCENT, 10)); - Assert.assertNotEquals(position1, 5); + Assertions.assertNotEquals(position1, 5); } @Test @@ -188,10 +187,10 @@ public void hashCodeTest() { BackgroundPosition position = new BackgroundPosition().setPositionX(BackgroundPosition.PositionX.RIGHT).setPositionY(BackgroundPosition.PositionY.BOTTOM) .setXShift(new UnitValue(UnitValue.POINT, 30)).setYShift(new UnitValue(UnitValue.PERCENT, 10)); - Assert.assertEquals(1028641704, position.hashCode()); + Assertions.assertEquals(1028641704, position.hashCode()); position.setXShift(new UnitValue(UnitValue.POINT, 37)); - Assert.assertEquals(1101779880, position.hashCode()); + Assertions.assertEquals(1101779880, position.hashCode()); } } diff --git a/layout/src/test/java/com/itextpdf/layout/BlockTest.java b/layout/src/test/java/com/itextpdf/layout/BlockTest.java index b4006e40b0..686e7a0876 100644 --- a/layout/src/test/java/com/itextpdf/layout/BlockTest.java +++ b/layout/src/test/java/com/itextpdf/layout/BlockTest.java @@ -52,16 +52,15 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class BlockTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/layout/BlockTest/"; @@ -89,7 +88,7 @@ public class BlockTest extends ExtendedITextTest { "Then battle for Freedom wherever you can,\n" + " And, if not shot or hanged, you'll get knighted."; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } @@ -151,7 +150,7 @@ public void blockWithSetHeightProperties01() throws IOException, InterruptedExce doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @@ -216,7 +215,7 @@ public void blockWithSetHeightProperties02() throws IOException, InterruptedExce doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @LogMessages(messages = { @@ -315,7 +314,7 @@ public void blockWithSetHeightProperties03() throws IOException, InterruptedExce doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @@ -415,7 +414,7 @@ public void blockWithSetHeightProperties04() throws IOException, InterruptedExce doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @@ -447,7 +446,7 @@ public void overflowTest01() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -475,7 +474,7 @@ public void overflowTest02() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -503,11 +502,11 @@ public void overflowTest03() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } - @Ignore("DEVSIX-1375") + @Disabled("DEVSIX-1375") @Test public void overflowTest04() throws IOException, InterruptedException { String outFileName = destinationFolder + "overflowTest04.pdf"; @@ -535,10 +534,10 @@ public void overflowTest04() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } - @Ignore("DEVSIX-1373") + @Disabled("DEVSIX-1373") @Test public void overflowTest05() throws IOException, InterruptedException { String outFileName = destinationFolder + "overflowTest05.pdf"; @@ -569,10 +568,10 @@ public void overflowTest05() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } - @Ignore("DEVSIX-1373") + @Disabled("DEVSIX-1373") @Test public void overflowTest06() throws IOException, InterruptedException { String outFileName = destinationFolder + "overflowTest06.pdf"; @@ -595,7 +594,7 @@ public void overflowTest06() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -680,7 +679,7 @@ public void blockFillAvailableArea01() throws IOException, InterruptedException doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -702,7 +701,7 @@ public void marginsBordersPaddingOverflow01() throws IOException, InterruptedExc doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -726,7 +725,7 @@ public void marginsBordersPaddingOverflow02() throws IOException, InterruptedExc doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -768,7 +767,7 @@ public void marginsBordersPaddingOverflow03() throws IOException, InterruptedExc doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -823,7 +822,7 @@ public void borderRadiusTest01() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -860,7 +859,7 @@ public void borderRadiusTest02() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -923,7 +922,7 @@ public void borderRadiusTest03() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -987,7 +986,7 @@ public void borderRadiusTest04() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -1046,7 +1045,7 @@ public void borderRadiusTest05() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -1105,7 +1104,7 @@ public void borderRadiusTest06() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -1123,11 +1122,11 @@ public void heightShouldBeIncreasedUpToSetHeightTest01() throws IOException, Int doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test - @Ignore("DEVSIX-1897") + @Disabled("DEVSIX-1897") public void paragraphVerticalAlignmentTest01() throws IOException, InterruptedException { String outFileName = destinationFolder + "paragraphVerticalAlignmentTest01.pdf"; String cmpFileName = sourceFolder + "paragraphVerticalAlignmentTest01.pdf"; @@ -1143,7 +1142,7 @@ public void paragraphVerticalAlignmentTest01() throws IOException, InterruptedEx doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } private Div createDiv(Div innerOverflowDiv, String text, DeviceRgb backgroundColor, boolean keepTogether, boolean fillAlways, boolean fillOnSplit) { diff --git a/layout/src/test/java/com/itextpdf/layout/BorderTest.java b/layout/src/test/java/com/itextpdf/layout/BorderTest.java index d6ccad8f30..177209a75e 100644 --- a/layout/src/test/java/com/itextpdf/layout/BorderTest.java +++ b/layout/src/test/java/com/itextpdf/layout/BorderTest.java @@ -51,16 +51,15 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.FileNotFoundException; import java.io.IOException; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class BorderTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/layout/BorderTest/"; @@ -71,7 +70,7 @@ public class BorderTest extends ExtendedITextTest { String outFileName; String cmpFileName; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } @@ -133,7 +132,7 @@ public void drawBordersByRectangleTest() throws IOException, InterruptedExceptio new RoundDotsBorder(DeviceRgb.GREEN, 5).draw(canvas, new Rectangle(350, 400, 100, 100)); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff")); } @Test @@ -283,8 +282,8 @@ public void borderBoxTest() throws IOException, InterruptedException { Paragraph p = new Paragraph(text).setBackgroundColor(ColorConstants.GRAY); p.setMargins(25, 60, 70, 80); - p.setBorderLeft(new DoubleBorder(ColorConstants.RED, 25)); p.setBorder(new DoubleBorder(ColorConstants.BLACK, 6)); + p.setBorderLeft(new DoubleBorder(ColorConstants.RED, 25)); doc.add(p); doc.add(new Paragraph(textAfter).setBorder(new DottedBorder(ColorConstants.BLACK, 3)).setBorderRight(new DottedBorder(ColorConstants.BLACK, 12))); @@ -347,7 +346,7 @@ public void rotatedBordersTest() throws IOException, InterruptedException { closeDocumentAndCompareOutputs(doc); } - private Document createDocument() throws FileNotFoundException { + private Document createDocument() throws IOException { outFileName = destinationFolder + fileName; cmpFileName = sourceFolder + cmpPrefix + fileName; @@ -360,7 +359,7 @@ private void closeDocumentAndCompareOutputs(Document document) throws IOExceptio document.close(); String compareResult = new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff"); if (compareResult != null) { - Assert.fail(compareResult); + Assertions.fail(compareResult); } } @@ -382,6 +381,6 @@ public void getDotsGapTest() { TestBorder border = new TestBorder(1f); float actual = border.publicGetDotsGap(distance, initialGap); - Assert.assertEquals(expected, actual, 0.0001f); + Assertions.assertEquals(expected, actual, 0.0001f); } } diff --git a/layout/src/test/java/com/itextpdf/layout/CanvasTest.java b/layout/src/test/java/com/itextpdf/layout/CanvasTest.java index 95eab4717d..7ec6c61e0a 100644 --- a/layout/src/test/java/com/itextpdf/layout/CanvasTest.java +++ b/layout/src/test/java/com/itextpdf/layout/CanvasTest.java @@ -53,24 +53,23 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.List; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class CanvasTest extends ExtendedITextTest { private static final TestConfigurationEvent CONFIGURATION_ACCESS = new TestConfigurationEvent(); private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/layout/CanvasTest/"; private static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/layout/CanvasTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(DESTINATION_FOLDER); } @@ -100,7 +99,7 @@ public void canvasNoPageLinkTest() throws IOException, InterruptedException { canvas.close(); pdf.close(); - Assert.assertNull(new CompareTool().compareByContent(out, cmp, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(out, cmp, DESTINATION_FOLDER)); } @Test @@ -126,7 +125,7 @@ public void canvasWithPageLinkTest() throws IOException, InterruptedException { canvas.close(); pdf.close(); - Assert.assertNull(new CompareTool().compareByContent(out, cmp, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(out, cmp, DESTINATION_FOLDER)); } @Test @@ -147,7 +146,7 @@ public void listItemWithoutMarginsInCanvasTest() throws IOException, Interrupted canvas.close(); pdf.close(); - Assert.assertNull(new CompareTool().compareByContent(out, cmp, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(out, cmp, DESTINATION_FOLDER)); } @Test @@ -165,7 +164,7 @@ public void notApplyingMarginsInCanvasTest() throws IOException, InterruptedExce canvas.close(); pdf.close(); - Assert.assertNull(new CompareTool().compareByContent(out, cmp, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(out, cmp, DESTINATION_FOLDER)); } @Test @@ -183,7 +182,7 @@ public void nullableMarginsInCanvasRendererTest() throws IOException, Interrupte canvas.close(); pdf.close(); - Assert.assertNull(new CompareTool().compareByContent(out, cmp, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(out, cmp, DESTINATION_FOLDER)); } @Test @@ -212,7 +211,7 @@ public void canvasWithPageEnableTaggingTest01() throws IOException, InterruptedE canvas.close(); pdf.close(); - Assert.assertNull(new CompareTool().compareByContent(out, cmp, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(out, cmp, DESTINATION_FOLDER)); } @Test @@ -247,7 +246,7 @@ public void canvasWithPageEnableTaggingTest02() throws IOException, InterruptedE canvas.close(); pdf.close(); - Assert.assertNull(new CompareTool().compareByContent(out, cmp, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(out, cmp, DESTINATION_FOLDER)); } @Test @@ -272,7 +271,7 @@ public void elementWithAbsolutePositioningInCanvasTest() throws IOException, Int canvas.close(); } - Assert.assertNull(new CompareTool().compareByContent(out, cmp, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(out, cmp, DESTINATION_FOLDER)); } @Test @@ -299,7 +298,7 @@ public void parentElemWithAbsolPositionKidNotSuitCanvasTest() throws IOException canvas.close(); } - Assert.assertNull(new CompareTool().compareByContent(out, cmp, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(out, cmp, DESTINATION_FOLDER)); } @Test @@ -322,11 +321,11 @@ public void nestedElementWithAbsolutePositioningInCanvasTest() throws IOExceptio notFittingDiv.add(divWithPosition); - Assert.assertThrows(NullPointerException.class, () -> canvas.add(notFittingDiv)); + Assertions.assertThrows(NullPointerException.class, () -> canvas.add(notFittingDiv)); canvas.close(); } - Assert.assertNull(new CompareTool().compareByContent(out, cmp, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(out, cmp, DESTINATION_FOLDER)); } @Test @@ -347,10 +346,10 @@ public void addBlockElemMethodLinkingTest() { } // Second event was linked by adding block element method - Assert.assertEquals(2, events.size()); + Assertions.assertEquals(2, events.size()); - Assert.assertTrue(events.get(0) instanceof ITextCoreProductEvent); - Assert.assertTrue(events.get(1) instanceof TestProductEvent); + Assertions.assertTrue(events.get(0) instanceof ITextCoreProductEvent); + Assertions.assertTrue(events.get(1) instanceof TestProductEvent); } } @@ -372,10 +371,10 @@ public void addImageElemMethodLinkingTest() { } // Second event was linked by adding block element method - Assert.assertEquals(2, events.size()); + Assertions.assertEquals(2, events.size()); - Assert.assertTrue(events.get(0) instanceof ITextCoreProductEvent); - Assert.assertTrue(events.get(1) instanceof TestProductEvent); + Assertions.assertTrue(events.get(0) instanceof ITextCoreProductEvent); + Assertions.assertTrue(events.get(1) instanceof TestProductEvent); } } @@ -383,9 +382,9 @@ public void addImageElemMethodLinkingTest() { public void drawingOnPageReuseCanvas() { try (PdfDocument pdfDocument = new PdfDocument(new PdfWriter(new ByteArrayOutputStream()))) { ExposedPdfCanvas canvas = new ExposedPdfCanvas(pdfDocument.addNewPage()); - Assert.assertTrue(canvas.getDrawingOnPage()); + Assertions.assertTrue(canvas.getDrawingOnPage()); try (Canvas canvas1 = new Canvas(canvas, new Rectangle(200, 200, 200, 200))) { - Assert.assertTrue(((ExposedPdfCanvas) canvas1.pdfCanvas).getDrawingOnPage()); + Assertions.assertTrue(((ExposedPdfCanvas) canvas1.pdfCanvas).getDrawingOnPage()); } } } @@ -395,9 +394,9 @@ public void notDrawingOnPageReuseCanvas() { try (PdfDocument pdfDocument = new PdfDocument(new PdfWriter(new ByteArrayOutputStream()))) { PdfStream stream = new PdfStream(); ExposedPdfCanvas canvas = new ExposedPdfCanvas(stream, new PdfResources(), pdfDocument); - Assert.assertFalse(canvas.getDrawingOnPage()); + Assertions.assertFalse(canvas.getDrawingOnPage()); try (Canvas canvas1 = new Canvas(canvas, new Rectangle(200, 200, 200, 200))) { - Assert.assertFalse(((ExposedPdfCanvas) canvas1.pdfCanvas).getDrawingOnPage()); + Assertions.assertFalse(((ExposedPdfCanvas) canvas1.pdfCanvas).getDrawingOnPage()); } } } diff --git a/layout/src/test/java/com/itextpdf/layout/CanvasUnitTest.java b/layout/src/test/java/com/itextpdf/layout/CanvasUnitTest.java index f6abfef98d..0f9e125ccc 100644 --- a/layout/src/test/java/com/itextpdf/layout/CanvasUnitTest.java +++ b/layout/src/test/java/com/itextpdf/layout/CanvasUnitTest.java @@ -29,13 +29,12 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfWriter; import com.itextpdf.kernel.pdf.canvas.PdfCanvas; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class CanvasUnitTest extends ExtendedITextTest { @Test @@ -46,7 +45,7 @@ public void canvasImmediateFlushConstructorTest() { Rectangle rectangle = new Rectangle(0, 0); Canvas canvas = new Canvas(pdfCanvas, rectangle, false); - Assert.assertEquals(pdfCanvas.getDocument(), canvas.getPdfDocument()); - Assert.assertFalse(canvas.immediateFlush); + Assertions.assertEquals(pdfCanvas.getDocument(), canvas.getPdfDocument()); + Assertions.assertFalse(canvas.immediateFlush); } } diff --git a/layout/src/test/java/com/itextpdf/layout/CollapsingMarginsTest.java b/layout/src/test/java/com/itextpdf/layout/CollapsingMarginsTest.java index d03be174e1..7c5af52d62 100644 --- a/layout/src/test/java/com/itextpdf/layout/CollapsingMarginsTest.java +++ b/layout/src/test/java/com/itextpdf/layout/CollapsingMarginsTest.java @@ -39,17 +39,16 @@ This file is part of the iText (R) project. import com.itextpdf.layout.renderer.DivRenderer; import com.itextpdf.layout.renderer.IRenderer; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; import java.util.ArrayList; import java.util.List; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class CollapsingMarginsTest extends ExtendedITextTest { private static final String sourceFolder = "./src/test/resources/com/itextpdf/layout/CollapsingMarginsTest/"; private static final String destinationFolder = "./target/test/com/itextpdf/layout/CollapsingMarginsTest/"; @@ -64,7 +63,7 @@ public class CollapsingMarginsTest extends ExtendedITextTest { "Then battle for Freedom wherever you can,\n" + " And, if not shot or hanged, you'll get knighted."; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } @@ -104,7 +103,7 @@ public void collapsingMarginsTest01() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -148,7 +147,7 @@ public void collapsingMarginsTest02() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -189,7 +188,7 @@ public void collapsingMarginsTest03() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -235,7 +234,7 @@ public void collapsingMarginsTest04() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -264,7 +263,7 @@ public void collapsingMarginsTest05() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -294,7 +293,7 @@ public void elementCollapsingMarginsTest01() throws IOException, InterruptedExce doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } private void drawPageBorders(PdfDocument pdfDocument, int pageNum) { @@ -336,10 +335,10 @@ public void columnRendererTest() throws IOException, InterruptedException { areas.add(new Rectangle(370, 30, 150, 600)); div.setNextRenderer(new CustomColumnDocumentRenderer(div, areas)); - Assert.assertThrows(Exception.class, () -> doc.add(div)); + Assertions.assertThrows(Exception.class, () -> doc.add(div)); } - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } private static class CustomColumnDocumentRenderer extends DivRenderer { diff --git a/layout/src/test/java/com/itextpdf/layout/CustomCurrentAreaTest.java b/layout/src/test/java/com/itextpdf/layout/CustomCurrentAreaTest.java index 37566cac7f..d7f78dc159 100644 --- a/layout/src/test/java/com/itextpdf/layout/CustomCurrentAreaTest.java +++ b/layout/src/test/java/com/itextpdf/layout/CustomCurrentAreaTest.java @@ -34,20 +34,19 @@ This file is part of the iText (R) project. import com.itextpdf.layout.layout.RootLayoutArea; import com.itextpdf.layout.renderer.DocumentRenderer; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class CustomCurrentAreaTest extends ExtendedITextTest { public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/layout/CustomCurrentAreaTest/"; public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/layout/CustomCurrentAreaTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(DESTINATION_FOLDER); } @@ -68,7 +67,7 @@ public void longListItemTest() throws IOException, InterruptedException { + " when looking at its layout.")); document.add(new Table(1).addCell(new Cell().add(list))); } - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } private static class ClauseRenderer extends DocumentRenderer { diff --git a/layout/src/test/java/com/itextpdf/layout/DefaultLayoutTest.java b/layout/src/test/java/com/itextpdf/layout/DefaultLayoutTest.java index d00798e3b2..28c7d7b6c9 100644 --- a/layout/src/test/java/com/itextpdf/layout/DefaultLayoutTest.java +++ b/layout/src/test/java/com/itextpdf/layout/DefaultLayoutTest.java @@ -24,9 +24,9 @@ This file is part of the iText (R) project. import com.itextpdf.io.logs.IoLogMessageConstant; import com.itextpdf.kernel.colors.ColorConstants; -import com.itextpdf.kernel.events.Event; -import com.itextpdf.kernel.events.IEventHandler; -import com.itextpdf.kernel.events.PdfDocumentEvent; +import com.itextpdf.kernel.pdf.event.AbstractPdfDocumentEventHandler; +import com.itextpdf.kernel.pdf.event.AbstractPdfDocumentEvent; +import com.itextpdf.kernel.pdf.event.PdfDocumentEvent; import com.itextpdf.kernel.font.PdfFontFactory; import com.itextpdf.kernel.geom.PageSize; import com.itextpdf.kernel.geom.Rectangle; @@ -47,20 +47,20 @@ This file is part of the iText (R) project. import com.itextpdf.test.LogLevelConstants; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.util.ArrayList; import java.util.List; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class DefaultLayoutTest extends ExtendedITextTest { public static float EPS = 0.001f; @@ -68,7 +68,7 @@ public class DefaultLayoutTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/layout/DefaultLayoutTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/layout/DefaultLayoutTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } @@ -87,7 +87,7 @@ public void multipleAdditionsOfSameModelElementTest() throws IOException, Interr document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -106,7 +106,7 @@ public void rendererTest01() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -128,7 +128,7 @@ public void emptyParagraphsTest01() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -144,7 +144,7 @@ public void emptyParagraphsTest02() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -163,7 +163,7 @@ public void textWithWhitespacesTest01() throws IOException, InterruptedException doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @@ -189,7 +189,7 @@ public void addParagraphOnShortPage1() throws IOException, InterruptedException doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -210,7 +210,7 @@ public void addParagraphOnShortPage2() throws IOException, InterruptedException doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -240,7 +240,7 @@ public void addWordOnShortPageTest01() throws IOException, InterruptedException doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -252,7 +252,7 @@ public void closeEmptyDocumentTest() throws IOException, InterruptedException { Document document = new Document(pdfDocument); AssertUtil.doesNotThrow(() -> document.close()); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -267,7 +267,7 @@ public void closeEmptyDocumentWithEventOnAddingPageTest() throws IOException, In pdfDocument.addEventHandler(PdfDocumentEvent.START_PAGE, handler); AssertUtil.doesNotThrow(() -> pdfDocument.close()); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -279,7 +279,7 @@ public void checkPageSizeOfClosedEmptyDocumentTest() throws IOException { baos.close(); PdfDocument newDoc = new PdfDocument(new PdfReader(new ByteArrayInputStream(bytes))); - Assert.assertTrue(PageSize.DEFAULT.equalsWithEpsilon(newDoc.getPage(1).getPageSize())); + Assertions.assertTrue(PageSize.DEFAULT.equalsWithEpsilon(newDoc.getPage(1).getPageSize())); newDoc.close(); } @@ -297,12 +297,12 @@ public void closeEmptyDocumentWithRemovingPageEventOnAddingPageTest() throws IOE pdfDocument.addEventHandler(PdfDocumentEvent.START_PAGE, handler); AssertUtil.doesNotThrow(() -> pdfDocument.close()); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } - private static class ParagraphAdderHandler implements IEventHandler { + private static class ParagraphAdderHandler extends AbstractPdfDocumentEventHandler { @Override - public void handleEvent(Event event) { + public void onAcceptedEvent(AbstractPdfDocumentEvent event) { PdfDocumentEvent docEvent = (PdfDocumentEvent) event; PdfPage page = docEvent.getPage(); PdfDocument pdfDoc = ((PdfDocumentEvent) event).getDocument(); @@ -318,13 +318,13 @@ public void handleEvent(Event event) { } } - private static class PageRemoverHandler implements IEventHandler { + private static class PageRemoverHandler extends AbstractPdfDocumentEventHandler { @Override - public void handleEvent(Event event) { + public void onAcceptedEvent(AbstractPdfDocumentEvent event) { PdfDocumentEvent docEvent = (PdfDocumentEvent) event; PdfPage page = docEvent.getPage(); - PdfDocument pdfDoc = ((PdfDocumentEvent) event).getDocument(); - pdfDoc.removePage(1); + PdfDocument pdfDoc = event.getDocument(); + pdfDoc.removePage(page); } } } diff --git a/layout/src/test/java/com/itextpdf/layout/DestinationTest.java b/layout/src/test/java/com/itextpdf/layout/DestinationTest.java index 9190c44f8e..6c67446f7c 100644 --- a/layout/src/test/java/com/itextpdf/layout/DestinationTest.java +++ b/layout/src/test/java/com/itextpdf/layout/DestinationTest.java @@ -29,22 +29,21 @@ This file is part of the iText (R) project. import com.itextpdf.layout.element.Text; import com.itextpdf.layout.properties.Property; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; import com.itextpdf.commons.utils.MessageFormatUtil; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class DestinationTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/layout/DestinationTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/layout/DestinationTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } @@ -61,7 +60,7 @@ public void destinationTest01() throws IOException, InterruptedException { doc.add(new Paragraph(text).setFixedPosition(1, 549, 742, 40).setMargin(0)); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } } diff --git a/layout/src/test/java/com/itextpdf/layout/DocumentTest.java b/layout/src/test/java/com/itextpdf/layout/DocumentTest.java index 31ae67bbc4..a11ef5d65a 100644 --- a/layout/src/test/java/com/itextpdf/layout/DocumentTest.java +++ b/layout/src/test/java/com/itextpdf/layout/DocumentTest.java @@ -42,14 +42,13 @@ This file is part of the iText (R) project. import com.itextpdf.layout.testutil.TestConfigurationEvent; import com.itextpdf.layout.testutil.TestProductEvent; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class DocumentTest extends ExtendedITextTest { private static final TestConfigurationEvent CONFIGURATION_ACCESS = new TestConfigurationEvent(); @@ -61,9 +60,9 @@ public void executeActionInClosedDocTest() { Paragraph paragraph = new Paragraph("test"); document.add(paragraph); document.close(); - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> document.checkClosingStatus()); - Assert.assertEquals(LayoutExceptionMessageConstant.DOCUMENT_CLOSED_IT_IS_IMPOSSIBLE_TO_EXECUTE_ACTION, + Assertions.assertEquals(LayoutExceptionMessageConstant.DOCUMENT_CLOSED_IT_IS_IMPOSSIBLE_TO_EXECUTE_ACTION, exception.getMessage()); } @@ -80,10 +79,10 @@ public void addBlockElemMethodLinkingTest() { List events = CONFIGURATION_ACCESS.getPublicEvents( doc.getPdfDocument().getDocumentIdWrapper()); // Second event was linked by adding block element method - Assert.assertEquals(2, events.size()); + Assertions.assertEquals(2, events.size()); - Assert.assertTrue(events.get(0) instanceof ITextCoreProductEvent); - Assert.assertTrue(events.get(1) instanceof TestProductEvent); + Assertions.assertTrue(events.get(0) instanceof ITextCoreProductEvent); + Assertions.assertTrue(events.get(1) instanceof TestProductEvent); } } @@ -99,9 +98,9 @@ public void addAreaBreakElemMethodLinkingTest() { List events = CONFIGURATION_ACCESS.getPublicEvents( doc.getPdfDocument().getDocumentIdWrapper()); - Assert.assertEquals(1, events.size()); + Assertions.assertEquals(1, events.size()); - Assert.assertTrue(events.get(0) instanceof ITextCoreProductEvent); + Assertions.assertTrue(events.get(0) instanceof ITextCoreProductEvent); } } @@ -118,10 +117,10 @@ public void addImageElemMethodLinkingTest() { List events = CONFIGURATION_ACCESS.getPublicEvents( doc.getPdfDocument().getDocumentIdWrapper()); // Second event was linked by adding block element - Assert.assertEquals(2, events.size()); + Assertions.assertEquals(2, events.size()); - Assert.assertTrue(events.get(0) instanceof ITextCoreProductEvent); - Assert.assertTrue(events.get(1) instanceof TestProductEvent); + Assertions.assertTrue(events.get(0) instanceof ITextCoreProductEvent); + Assertions.assertTrue(events.get(1) instanceof TestProductEvent); } } } diff --git a/layout/src/test/java/com/itextpdf/layout/FixedHeightTest.java b/layout/src/test/java/com/itextpdf/layout/FixedHeightTest.java index 8a45e0ff9c..b9e8a01637 100644 --- a/layout/src/test/java/com/itextpdf/layout/FixedHeightTest.java +++ b/layout/src/test/java/com/itextpdf/layout/FixedHeightTest.java @@ -35,19 +35,18 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class FixedHeightTest extends ExtendedITextTest { - private static final String sourceFolder = "./src/test/resources/com/itextpdf/layout/FloatAndAlignmentTest/"; - private static final String destinationFolder = "./target/test/com/itextpdf/layout/FloatAndAlignmentTest/"; + private static final String sourceFolder = "./src/test/resources/com/itextpdf/layout/FixedHeightTest/"; + private static final String destinationFolder = "./target/test/com/itextpdf/layout/FixedHeightTest/"; private static final String textByron = "When a man hath no freedom to fight for at home,\n" + @@ -60,7 +59,7 @@ public class FixedHeightTest extends ExtendedITextTest { "Then battle for Freedom wherever you can,\n" + " And, if not shot or hanged, you'll get knighted."; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } @@ -93,7 +92,7 @@ public void divWithParagraphsAndFixedPositionTest() throws IOException, Interrup doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } @LogMessages(messages = { @@ -121,6 +120,6 @@ public void listWithFixedPositionTest() throws IOException, InterruptedException doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } } diff --git a/layout/src/test/java/com/itextpdf/layout/FloatAndAlignmentTest.java b/layout/src/test/java/com/itextpdf/layout/FloatAndAlignmentTest.java index ab710f0dc5..806b4c746d 100644 --- a/layout/src/test/java/com/itextpdf/layout/FloatAndAlignmentTest.java +++ b/layout/src/test/java/com/itextpdf/layout/FloatAndAlignmentTest.java @@ -43,16 +43,15 @@ This file is part of the iText (R) project. import com.itextpdf.layout.properties.UnitValue; import com.itextpdf.layout.renderer.FlexContainerRenderer; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.FileNotFoundException; import java.io.IOException; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class FloatAndAlignmentTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/layout/FloatAndAlignmentTest/"; @@ -65,7 +64,7 @@ public class FloatAndAlignmentTest extends ExtendedITextTest { "qui officia deserunt mollit anim id est laborum."; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } @@ -106,7 +105,7 @@ public void blocksInsideDiv() throws IOException, InterruptedException { document.add( divParent3 ); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff01_")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff01_")); } @Test @@ -144,7 +143,7 @@ public void blocksInsideDivFloat() throws IOException, InterruptedException { document.add( divParent3 ); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff01_")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff01_")); } @Test @@ -181,7 +180,7 @@ public void blocksInsideEachOther() throws IOException, InterruptedException { document.add( divParent3 ); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff02_")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff02_")); } @Test @@ -219,7 +218,7 @@ public void blocksInsideEachOther_sameFixedWidthsNesting() throws IOException, I document.add( divParent3 ); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff02_sameFixedWidth_")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff02_sameFixedWidth_")); } @@ -232,7 +231,7 @@ public void blocksNotInDivCenter() throws IOException, InterruptedException { String outFileName = destinationFolder + testName + ".pdf"; String cmpFileName = sourceFolder + "cmp_" + testName + ".pdf"; createDocumentWithBlocks( outFileName, HorizontalAlignment.CENTER ); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff03_")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff03_")); } @Test @@ -244,7 +243,7 @@ public void blocksNotInDivLeft() throws IOException, InterruptedException { String outFileName = destinationFolder + testName + ".pdf"; String cmpFileName = sourceFolder + "cmp_" + testName + ".pdf"; createDocumentWithBlocks( outFileName, HorizontalAlignment.LEFT ); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff04_")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff04_")); } @Test @@ -261,10 +260,11 @@ public void blocksNotInDivRight() throws IOException, InterruptedException { * So, only FloatPropertyValue defines the position of element in such cases */ createDocumentWithBlocks( outFileName, HorizontalAlignment.RIGHT ); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff05_")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff05_")); } - private void createDocumentWithBlocks(String outFileName, HorizontalAlignment horizontalAlignment) throws FileNotFoundException { + private void createDocumentWithBlocks(String outFileName, HorizontalAlignment horizontalAlignment) + throws IOException { PdfDocument pdfDocument = new PdfDocument( new PdfWriter( outFileName ) ); pdfDocument.setTagged(); Document document = new Document( pdfDocument ); @@ -317,7 +317,7 @@ public void inlineBlocksAndFloatsWithTextAlignmentTest01() throws IOException, I document.add(parentPara); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diffTextAlign01_")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diffTextAlign01_")); } @Test @@ -343,7 +343,7 @@ public void inlineBlocksAndFloatsWithTextAlignmentTest02() throws IOException, I document.add(parentPara.setBorder(new DashedBorder(2))); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diffTextAlign02_")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diffTextAlign02_")); } @Test @@ -372,7 +372,7 @@ public void inlineBlocksAndFloatsWithTextAlignmentTest03() throws IOException, I document.add(parentPara.setBorder(new DashedBorder(2))); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diffTextAlign03_")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diffTextAlign03_")); } @Test @@ -410,7 +410,7 @@ public void inlineBlocksAndFloatsWithTextAlignmentTest04() throws IOException, I } } } catch(Exception ex){} - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diffTextAlign04_")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diffTextAlign04_")); } @Test @@ -432,7 +432,7 @@ public void floatsOnlyJustificationTest01() throws IOException, InterruptedExcep document.add(parentPara.setBorder(new DashedBorder(2))); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff_")); } @Test @@ -469,7 +469,7 @@ public void tableWithAlignmentNextToRightFloatTest() throws IOException, Interru document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } @Test @@ -506,7 +506,7 @@ public void tableWithAlignmentNextToLeftFloatTest() throws IOException, Interrup document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } @Test @@ -549,7 +549,7 @@ public void tableWithAlignmentBetweenFloatsTest() throws IOException, Interrupte document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } @Test @@ -589,7 +589,7 @@ public void tableWithBigLeftMarginAfterFloatTest() throws IOException, Interrupt document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } @Test @@ -629,7 +629,7 @@ public void tableWithBigRightMarginAfterFloatTest() throws IOException, Interrup document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } @Test @@ -675,7 +675,7 @@ public void tableWithSideMarginsBetweenFloatTest() throws IOException, Interrupt document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } @Test @@ -733,7 +733,7 @@ public void floatPositioningOutsideBlocksTest() throws IOException, InterruptedE document.add(wideDivWithBfc); document.add(new Paragraph("Plain text after wide div")); } - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff01_")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff01_")); } @Test @@ -778,7 +778,7 @@ public void floatPositioningOutsideFlexContainerTest() throws IOException, Inter document.add(flexContainer2); document.add(new Paragraph("Plain text after wide flex container")); } - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff01_")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff01_")); } private Div createParentDiv(HorizontalAlignment horizontalAlignment, ClearPropertyValue clearPropertyValue, UnitValue width) { diff --git a/layout/src/test/java/com/itextpdf/layout/FloatBlockTest.java b/layout/src/test/java/com/itextpdf/layout/FloatBlockTest.java index 35f29109c7..93070bb30a 100644 --- a/layout/src/test/java/com/itextpdf/layout/FloatBlockTest.java +++ b/layout/src/test/java/com/itextpdf/layout/FloatBlockTest.java @@ -39,25 +39,24 @@ This file is part of the iText (R) project. import com.itextpdf.layout.properties.Property; import com.itextpdf.layout.properties.UnitValue; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; import java.net.MalformedURLException; import java.util.ArrayList; import java.util.List; import javax.xml.parsers.ParserConfigurationException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import org.xml.sax.SAXException; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class FloatBlockTest extends ExtendedITextTest { private static final String sourceFolder = "./src/test/resources/com/itextpdf/layout/FloatBlockTest/"; private static final String destinationFolder = "./target/test/com/itextpdf/layout/FloatBlockTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } @@ -75,9 +74,9 @@ public void floatImageInDivClearNoneTest() throws IOException, InterruptedExcept document.close(); - Assert.assertNull(new CompareTool() + Assertions.assertNull(new CompareTool() .compareByContent(dest, sourceFolder + "cmp_floatImageInDivClearNone.pdf", destinationFolder)); - Assert.assertNull( + Assertions.assertNull( new CompareTool().compareTagStructures(dest, sourceFolder + "cmp_floatImageInDivClearNone.pdf")); } @@ -94,9 +93,9 @@ public void floatImageInDivClearBothTest() throws IOException, InterruptedExcept document.close(); - Assert.assertNull(new CompareTool() + Assertions.assertNull(new CompareTool() .compareByContent(dest, sourceFolder + "cmp_floatImageInDivClearBoth.pdf", destinationFolder)); - Assert.assertNull( + Assertions.assertNull( new CompareTool().compareTagStructures(dest, sourceFolder + "cmp_floatImageInDivClearBoth.pdf")); } @@ -142,8 +141,8 @@ public void floatImageDifferentSizeInDivTest() doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder)); - Assert.assertNull(new CompareTool().compareTagStructures(outFile, cmpFileName)); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareTagStructures(outFile, cmpFileName)); } private static void addFloatingImagesInDivs(Document document, UnitValue width, ClearPropertyValue clearValue) diff --git a/layout/src/test/java/com/itextpdf/layout/FloatImageTest.java b/layout/src/test/java/com/itextpdf/layout/FloatImageTest.java index 4004a7f9b3..9ed3318e92 100644 --- a/layout/src/test/java/com/itextpdf/layout/FloatImageTest.java +++ b/layout/src/test/java/com/itextpdf/layout/FloatImageTest.java @@ -36,24 +36,23 @@ This file is part of the iText (R) project. import com.itextpdf.layout.properties.Property; import com.itextpdf.layout.properties.UnitValue; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; import java.util.ArrayList; import java.util.List; import javax.xml.parsers.ParserConfigurationException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import org.xml.sax.SAXException; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class FloatImageTest extends ExtendedITextTest { private static final String sourceFolder = "./src/test/resources/com/itextpdf/layout/FloatImageTest/"; private static final String destinationFolder = "./target/test/com/itextpdf/layout/FloatImageTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } @@ -82,9 +81,9 @@ public void floatAllClearNoneImageTest() throws IOException, InterruptedExceptio document.close(); - Assert.assertNull(new CompareTool() + Assertions.assertNull(new CompareTool() .compareByContent(dest, sourceFolder + "cmp_floatAllClearNoneImage.pdf", destinationFolder)); - Assert.assertNull( + Assertions.assertNull( new CompareTool().compareTagStructures(dest, sourceFolder + "cmp_floatAllClearNoneImage.pdf")); } @@ -112,9 +111,9 @@ public void floatAllClearBothImageTest() throws IOException, InterruptedExceptio document.close(); - Assert.assertNull(new CompareTool() + Assertions.assertNull(new CompareTool() .compareByContent(dest, sourceFolder + "cmp_floatAllClearBothImage.pdf", destinationFolder)); - Assert.assertNull( + Assertions.assertNull( new CompareTool().compareTagStructures(dest, sourceFolder + "cmp_floatAllClearBothImage.pdf")); } @@ -141,9 +140,9 @@ public void floatNoneRightClearBothImageTest() throws IOException, InterruptedEx document.close(); - Assert.assertNull(new CompareTool() + Assertions.assertNull(new CompareTool() .compareByContent(dest, sourceFolder + "cmp_floatNoneRightClearBothImage.pdf", destinationFolder)); - Assert.assertNull( + Assertions.assertNull( new CompareTool().compareTagStructures(dest, sourceFolder + "cmp_floatNoneRightClearBothImage.pdf")); } @@ -169,9 +168,9 @@ public void floatNoneRightClearNoneImageTest() throws IOException, InterruptedEx document.close(); - Assert.assertNull(new CompareTool() + Assertions.assertNull(new CompareTool() .compareByContent(dest, sourceFolder + "cmp_floatNoneRightClearNoneImage.pdf", destinationFolder)); - Assert.assertNull( + Assertions.assertNull( new CompareTool().compareTagStructures(dest, sourceFolder + "cmp_floatNoneRightClearNoneImage.pdf")); } diff --git a/layout/src/test/java/com/itextpdf/layout/FloatTest.java b/layout/src/test/java/com/itextpdf/layout/FloatTest.java index 8d94ce640e..ad30e0aa80 100644 --- a/layout/src/test/java/com/itextpdf/layout/FloatTest.java +++ b/layout/src/test/java/com/itextpdf/layout/FloatTest.java @@ -53,16 +53,15 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class FloatTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/layout/FloatTest/"; @@ -78,7 +77,7 @@ public class FloatTest extends ExtendedITextTest { "Save time in Word with new buttons that show up where you need them. To change the way a picture fits in your document, click it and a button for layout options appears next to it. When you work on a table, click where you want to add a row or a column, and then click the plus sign. " + "Reading is easier, too, in the new Reading view. You can collapse parts of the document and focus on the text you want. If you need to stop reading before you reach the end, Word remembers where you left off - even on another device. "; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } @@ -113,7 +112,7 @@ public void floatParagraphTest01() throws IOException, InterruptedException { doc.add(p2); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff01_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff01_")); } @Test @@ -146,7 +145,7 @@ public void floatParagraphTest02() throws IOException, InterruptedException { p3.setBorder(new SolidBorder(1)); doc.add(p3); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff02_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff02_")); } @Test @@ -171,7 +170,7 @@ public void floatDivTest01() throws IOException, InterruptedException { doc.add(new Paragraph("div2")); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff03_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff03_")); } @Test @@ -209,7 +208,7 @@ public void floatDivTest02() throws IOException, InterruptedException { doc.add(coloredDiv); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff04_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff04_")); } @Test @@ -244,7 +243,7 @@ public void floatDivTest03() throws IOException, InterruptedException { doc.add(div); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff05_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff05_")); } @Test @@ -271,7 +270,7 @@ public void floatingImageInCell() throws IOException, InterruptedException { document.add(table); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff06_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff06_")); } @Test @@ -296,7 +295,7 @@ public void floatingImageToNextPage() throws IOException, InterruptedException { document.add(new Paragraph(text)); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff07_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff07_")); } @Test @@ -322,7 +321,7 @@ public void inlineFloatingImageToNextPage() throws IOException, InterruptedExcep document.add(p); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff08_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff08_")); } @Test @@ -345,7 +344,7 @@ public void floatingTwoImages() throws IOException, InterruptedException { document.add(new Paragraph(text)); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff09_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff09_")); } @Test @@ -368,7 +367,7 @@ public void floatingTwoImagesLR() throws IOException, InterruptedException { document.add(new Paragraph(text)); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff10_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff10_")); } @Test @@ -426,7 +425,7 @@ public void floatingImageInParagraph() throws IOException, InterruptedException document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff11_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff11_")); } @Test @@ -465,7 +464,7 @@ public void floatsOnCanvas() throws IOException, InterruptedException { canvas.close(); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff12_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff12_")); } @Test @@ -492,7 +491,7 @@ public void floatsFixedWidthTest01_floatRight() throws IOException, InterruptedE document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff_width01_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff_width01_")); } @Test @@ -518,7 +517,7 @@ public void floatsFixedWidth01_noFloat() throws IOException, InterruptedExceptio document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff_width01_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff_width01_")); } @Test @@ -545,7 +544,7 @@ public void floatsFixedWidth01_floatLeft() throws IOException, InterruptedExcept document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff_width01_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff_width01_")); } @Test @@ -578,7 +577,7 @@ public void floatFixedHeightContentNotFit() throws IOException, InterruptedExcep document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff13_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff13_")); } @Test @@ -604,7 +603,7 @@ public void clearanceFixedHeightPageSplitInRoot01() throws IOException, Interrup document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff13_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff13_")); } @Test @@ -632,7 +631,7 @@ public void clearancePageSplitFloatPartialInRoot01() throws IOException, Interru document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff14_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff14_")); } @Test @@ -659,7 +658,7 @@ public void clearancePageSplitFloatPartialInRoot02() throws IOException, Interru document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff15_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff15_")); } @Test @@ -692,7 +691,7 @@ public void clearancePageSplitFloatPartialInRoot03() throws IOException, Interru document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff14_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff14_")); } @Test @@ -729,7 +728,7 @@ public void clearancePageSplitFloatPartialInBlock01() throws IOException, Interr document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff23_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff23_")); } @Test @@ -759,7 +758,7 @@ public void clearancePageSplitFloatPartialInBlock02() throws IOException, Interr document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff24_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff24_")); } @Test @@ -800,7 +799,7 @@ public void clearancePageSplitFloatPartialInBlock03() throws IOException, Interr document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff23_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff23_")); } @Test @@ -830,7 +829,7 @@ public void clearancePageSplitFloatNothingInRoot01() throws IOException, Interru document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff16_01_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff16_01_")); } @Test @@ -859,7 +858,7 @@ public void clearancePageSplitFloatNothingInRoot02() throws IOException, Interru document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff16_02_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff16_02_")); } @Test @@ -889,7 +888,7 @@ public void clearancePageSplitFloatNothingInRoot03() throws IOException, Interru document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff16_02_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff16_02_")); } @Test @@ -922,7 +921,7 @@ public void clearancePageSplitFloatNothingInBlock01() throws IOException, Interr document.add(containerDiv); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff25_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff25_")); } @Test @@ -954,7 +953,7 @@ public void clearancePageSplitFloatNothingInBlock02() throws IOException, Interr document.add(containerDiv); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff25_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff25_")); } @Test @@ -987,7 +986,7 @@ public void clearancePageSplitFloatNothingInBlock03() throws IOException, Interr document.add(containerDiv); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff25_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff25_")); } @Test @@ -1019,7 +1018,7 @@ public void clearanceNoContentPageSplitFloatPartialInRoot01() throws IOException document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff15_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff15_")); } @Test @@ -1050,7 +1049,7 @@ public void clearanceNoContentPageSplitFloatPartialInBlock01() throws IOExceptio document.add(containerDiv); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff26_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff26_")); } @Test @@ -1073,7 +1072,7 @@ public void floatsOnPageSplit01() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff17_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff17_")); } @Test @@ -1095,7 +1094,7 @@ public void floatsOnPageSplit02() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff18_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff18_")); } @Test @@ -1117,7 +1116,7 @@ public void floatsOnPageSplit03() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff19_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff19_")); } @Test @@ -1138,7 +1137,7 @@ public void floatsOnPageSplit04() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff20_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff20_")); } @Test @@ -1167,7 +1166,7 @@ public void floatsOnPageSplit05() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff21_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff21_")); } @Test @@ -1195,7 +1194,7 @@ public void floatsOnPageSplit06_01() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff22_01_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff22_01_")); } @Test @@ -1223,7 +1222,7 @@ public void floatsOnPageSplit06_02() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff22_02")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff22_02")); } @Test @@ -1251,7 +1250,7 @@ public void floatsOnPageSplit06_03() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff22_03")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff22_03")); } @Test @@ -1280,7 +1279,7 @@ public void floatsOnPageSplit07() throws IOException, InterruptedException { document.add(containerDiv); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff27_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff27_")); } @Test @@ -1308,7 +1307,7 @@ public void floatsOnPageSplit08_01() throws IOException, InterruptedException { document.add(containerDiv); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff28_01_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff28_01_")); } @Test @@ -1337,7 +1336,7 @@ public void floatsOnPageSplit08_02() throws IOException, InterruptedException { document.add(containerDiv); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff28_02_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff28_02_")); } @Test @@ -1363,7 +1362,7 @@ public void floatsOnPageSplit08_03() throws IOException, InterruptedException { document.add(containerDiv); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff28_03_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff28_03_")); } @Test @@ -1392,7 +1391,7 @@ public void floatsOnPageSplit09() throws IOException, InterruptedException { document.add(containerDiv); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff29_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff29_")); } @Test @@ -1416,7 +1415,7 @@ public void floatsOnPageSplit10() throws IOException, InterruptedException { document.add(containerDiv); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff30_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff30_")); } @Test @@ -1449,7 +1448,7 @@ public void floatsOnPageSplit11() throws IOException, InterruptedException { document.add(containerDiv); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff31_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff31_")); } @Test @@ -1469,7 +1468,7 @@ public void floatsOnPageSplit12_01() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff32_01_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff32_01_")); } @Test @@ -1489,7 +1488,7 @@ public void floatsOnPageSplit12_02() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff32_02_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff32_02_")); } @Test @@ -1515,7 +1514,7 @@ public void floatsOnPageSplit14() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff33_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff33_")); } @Test @@ -1548,7 +1547,7 @@ public void floatsOnPageSplit15() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff34_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff34_")); } @Test @@ -1580,7 +1579,7 @@ public void floatsOnPageSplit16() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff34_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff34_")); } @Test @@ -1605,7 +1604,7 @@ public void floatsOnPageSplit17() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff35_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff35_")); } @Test @@ -1634,7 +1633,7 @@ public void floatsOnPageSplit18() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff36_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff36_")); } @Test @@ -1663,7 +1662,7 @@ public void floatsOnPageSplit19() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff37_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff37_")); } @Test @@ -1684,7 +1683,7 @@ public void floatsKeepTogetherOnPageSplit01() throws IOException, InterruptedExc document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff38_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff38_")); } @Test @@ -1708,7 +1707,7 @@ public void floatsKeepTogetherOnPageSplit02() throws IOException, InterruptedExc document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff39_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff39_")); } @Test @@ -1736,7 +1735,7 @@ public void floatsKeepTogetherOnPageSplit03() throws IOException, InterruptedExc document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff39_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff39_")); } @@ -1761,7 +1760,7 @@ public void floatsInParagraphPartialSplit01() throws IOException, InterruptedExc document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff40_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff40_")); } @Test @@ -1789,7 +1788,7 @@ public void floatsInParagraphPartialSplit02() throws IOException, InterruptedExc document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff41_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff41_")); } @Test @@ -1817,7 +1816,7 @@ public void floatsInParagraphPartialSplit03() throws IOException, InterruptedExc document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff42_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff42_")); } @Test @@ -1845,7 +1844,7 @@ public void floatsInParagraphPartialSplit04() throws IOException, InterruptedExc document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff43_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff43_")); } @Test @@ -1868,7 +1867,7 @@ public void floatsInParagraphPartialSplit05() throws IOException, InterruptedExc document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff44_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff44_")); } @Test @@ -1900,7 +1899,7 @@ public void floatsInParagraphPartialSplit06() throws IOException, InterruptedExc document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff45_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff45_")); } @Test @@ -1932,7 +1931,7 @@ public void floatsInParagraphPartialSplit07() throws IOException, InterruptedExc document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff46_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff46_")); } @Test @@ -1963,7 +1962,7 @@ public void floatsInParagraphPartialSplit08() throws IOException, InterruptedExc document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff47_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff47_")); } @Test @@ -1984,7 +1983,7 @@ public void floatingTextInParagraphPartialSplit01() throws IOException, Interrup document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff51_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff51_")); } @Test @@ -2025,7 +2024,7 @@ public void floatingTextInParagraphPartialSplit02() throws IOException, Interrup document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff52_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff52_")); } @Test @@ -2056,7 +2055,7 @@ public void floatingTextInParagraphPartialSplit03() throws IOException, Interrup document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff53")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff53")); } @Test @@ -2083,7 +2082,7 @@ public void floatsFirstOnPageNotFit01() throws IOException, InterruptedException document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff48_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff48_")); } @Test @@ -2110,7 +2109,7 @@ public void floatsFirstOnPageNotFit02() throws IOException, InterruptedException document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff49_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff49_")); } @Test @@ -2134,7 +2133,7 @@ public void floatsFirstOnPageNotFit03() throws IOException, InterruptedException document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff50_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff50_")); } @Test @@ -2160,7 +2159,7 @@ public void floatPartialSplitBigGapAtPageEnd01() throws IOException, Interrupted document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff54_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff54_")); } @Test @@ -2195,7 +2194,7 @@ public void floatPartialSplitBigGapAtPageEnd02() throws IOException, Interrupted document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff55_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff55_")); } @Test @@ -2221,7 +2220,7 @@ public void floatInParagraphLastLineLeadingOverflow01() throws IOException, Inte document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff56_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff56_")); } @Test @@ -2258,7 +2257,7 @@ public void floatOverflowNothingInParagraph01() throws IOException, InterruptedE document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff57_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff57_")); } @Test @@ -2281,7 +2280,7 @@ public void floatOverflowNothingInParagraph02() throws IOException, InterruptedE document.add(p); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff58_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff58_")); } @Test @@ -2303,7 +2302,7 @@ public void floatInlineBlockTest01() throws IOException, InterruptedException { doc.add(p); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff14_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff14_")); } @Test @@ -2324,7 +2323,7 @@ public void floatsHeightFixedInBlock01() throws IOException, InterruptedExceptio document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff_height_01_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff_height_01_")); } @Test @@ -2349,7 +2348,7 @@ public void floatsHeightFixedInBlock02() throws IOException, InterruptedExceptio document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff_height_02_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff_height_02_")); } @Test @@ -2373,7 +2372,7 @@ public void floatsHeightFixedInParagraph01() throws IOException, InterruptedExce document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff_height_03_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff_height_03_")); } @Test @@ -2399,7 +2398,7 @@ public void floatsHeightFixedInParagraph02() throws IOException, InterruptedExce document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff_height_04_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff_height_04_")); } @Test @@ -2420,7 +2419,7 @@ public void floatsMaxHeightFixedInBlock01() throws IOException, InterruptedExcep document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff_maxheight_01_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff_maxheight_01_")); } @Test @@ -2445,7 +2444,7 @@ public void floatsMaxHeightFixedInBlock02() throws IOException, InterruptedExcep document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff_maxheight_02_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff_maxheight_02_")); } @Test @@ -2469,7 +2468,7 @@ public void floatsMaxHeightFixedInParagraph01() throws IOException, InterruptedE document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff_maxheight_03_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff_maxheight_03_")); } @Test @@ -2495,7 +2494,7 @@ public void floatsMaxHeightFixedInParagraph02() throws IOException, InterruptedE document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff_maxheight_04_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff_maxheight_04_")); } @Test @@ -2515,7 +2514,7 @@ public void floatsMinHeightFixedInBlock01() throws IOException, InterruptedExcep document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff_minheight_01_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff_minheight_01_")); } @Test @@ -2539,7 +2538,7 @@ public void floatsMinHeightFixedInBlock02() throws IOException, InterruptedExcep document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff_minheight_02_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff_minheight_02_")); } @Test @@ -2562,7 +2561,7 @@ public void floatsMinHeightFixedInParagraph01() throws IOException, InterruptedE document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff_minheight_03_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff_minheight_03_")); } @Test @@ -2587,7 +2586,7 @@ public void floatsMinHeightFixedInParagraph02() throws IOException, InterruptedE document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff_minheight_04_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff_minheight_04_")); } @Test @@ -2612,7 +2611,7 @@ public void floatsMinHeightApplyingOnSplitTest01() throws IOException, Interrupt document.add(mainDiv); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff_minheightapplying_01_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff_minheightapplying_01_")); } @Test @@ -2643,7 +2642,7 @@ public void floatsMinHeightApplyingOnSplitTest02() throws IOException, Interrupt document.add(mainDiv); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff_minheightapplying_02_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff_minheightapplying_02_")); } @Test @@ -2673,7 +2672,7 @@ public void floatsMinHeightApplyingOnSplitTest03() throws IOException, Interrupt document.add(mainDiv); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff_minheightapplying_03_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff_minheightapplying_03_")); } @Test @@ -2711,7 +2710,7 @@ public void floatsMinHeightApplyingOnSplitTest04() throws IOException, Interrupt document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff_minheightapplying_04_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff_minheightapplying_04_")); } @Test @@ -2761,7 +2760,7 @@ public void floatsMinHeightApplyingOnSplitTest05() throws IOException, Interrupt document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff_minheightapplying_05_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff_minheightapplying_05_")); } @Test @@ -2796,7 +2795,7 @@ public void floatsFixedMaxHeightAndOverflowHidden01() throws IOException, Interr // TODO DEVSIX-1818: overflow value HIDDEN doesn't clip floats because they are drawn later in different part of content stream. - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff_maxheighthidden_01_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff_maxheighthidden_01_")); } @Test @@ -2827,7 +2826,7 @@ public void floatsOverflowToNextLineAtPageEndInParagraph01() throws IOException, document.add(mainP); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff_overflowNextLineAtPageEnd_01_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff_overflowNextLineAtPageEnd_01_")); } @Test @@ -2854,7 +2853,7 @@ public void floatsOverflowToNextLineAtPageEndInParagraph02() throws IOException, document.add(mainP); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff_overflowNextLineAtPageEnd_02_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff_overflowNextLineAtPageEnd_02_")); } @Test @@ -2883,7 +2882,7 @@ public void floatsOverflowToNextLineAtPageEndInParagraph03() throws IOException, document.add(mainP); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff_overflowNextLineAtPageEnd_03_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff_overflowNextLineAtPageEnd_03_")); } private void addFloatingElements(Div mainDiv) { @@ -2954,7 +2953,7 @@ public void floatRootElementNotFitPage01() throws IOException, InterruptedExcept .add("Some text\nSome text")); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff15_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff15_")); } /** @@ -3007,7 +3006,7 @@ public void floatRootElementNotFitPage02() throws IOException, InterruptedExcept document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff16_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff16_")); } @Test @@ -3031,7 +3030,7 @@ public void floatOverflowAlongWithNewContent01() throws IOException, Interrupted document.add(new Paragraph(text + text)); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff_overflowNewContent01_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff_overflowNewContent01_")); } @Test @@ -3055,7 +3054,7 @@ public void floatOverflowAlongWithNewContent02() throws IOException, Interrupted document.add(new Paragraph(text + text + text)); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff_overflowNewContent02_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff_overflowNewContent02_")); } @Test @@ -3086,7 +3085,7 @@ public void floatTableTest01() throws IOException, InterruptedException { doc.add(div); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff03_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff03_")); } @Test @@ -3101,7 +3100,7 @@ public void keepTogetherEnoughSpaceOnNewPageWithFloatTest() throws IOException, document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff50_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff50_")); } @Test @@ -3117,7 +3116,7 @@ public void keepTogetherNotEnoughSpaceOnNewPageWithFloatEnoughOnEmptyTest() document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff50_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff50_")); } @Test @@ -3132,7 +3131,7 @@ public void keepTogetherNotEnoughSpaceOnNewEmptyPageTest() throws IOException, I document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff50_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff50_")); } @Test @@ -3147,7 +3146,7 @@ public void keepTogetherNotEnoughSpaceOnNewEmptyPageShortFloatTest() throws IOEx document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff50_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff50_")); } @@ -3163,7 +3162,7 @@ public void innerKeepTogetherEnoughSpaceOnNewPageWithFloatTest() throws IOExcept document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff50_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff50_")); } @Test @@ -3180,7 +3179,7 @@ public void innerKeepTogetherNotEnoughSpaceOnNewPageWithFloatEnoughOnEmptyTest() document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff50_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff50_")); } @Test @@ -3195,7 +3194,7 @@ public void innerKeepTogetherNotEnoughSpaceOnNewEmptyPageTest() throws IOExcepti document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff50_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff50_")); } @Test @@ -3218,7 +3217,7 @@ public void indentInParagraphAndFloatInInnerDivTest() throws IOException, Interr document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder)); } @Test @@ -3240,7 +3239,7 @@ public void floatAndIndentInFirstParagraphInDivTest() throws IOException, Interr document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder)); } @Test @@ -3262,7 +3261,7 @@ public void shortFloatRightAndIndentInSecondParagraphInDivTest() throws IOExcept document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder)); } @Test @@ -3284,7 +3283,7 @@ public void shortFloatLeftAndIndentInSecondParagraphInDivTest() throws IOExcepti document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder)); } @Test @@ -3306,7 +3305,7 @@ public void longFloatAndIndentInSecondParagraphInDivTest() throws IOException, I document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder)); } @Test @@ -3329,7 +3328,7 @@ public void indentInParentParagraphShortFirstFloatTest() throws IOException, Int document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder)); } @Test @@ -3352,7 +3351,7 @@ public void indentInParentParagraphLongFirstFloatTest() throws IOException, Inte document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder)); } diff --git a/layout/src/test/java/com/itextpdf/layout/FontProviderTest.java b/layout/src/test/java/com/itextpdf/layout/FontProviderTest.java index b3b15e269d..1cf1f11cf5 100644 --- a/layout/src/test/java/com/itextpdf/layout/FontProviderTest.java +++ b/layout/src/test/java/com/itextpdf/layout/FontProviderTest.java @@ -42,11 +42,10 @@ This file is part of the iText (R) project. import com.itextpdf.layout.font.FontSelector; import com.itextpdf.layout.properties.Property; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.FileInputStream; import java.io.FileOutputStream; @@ -54,7 +53,7 @@ This file is part of the iText (R) project. import java.util.Collection; import java.util.List; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class FontProviderTest extends ExtendedITextTest { private static class PdfFontProvider extends FontProvider { @@ -81,7 +80,7 @@ protected FontSelector createFontSelector(Collection fonts, List doc.add(paragraph)); - Assert.assertEquals(LayoutExceptionMessageConstant.FONT_PROVIDER_NOT_SET_FONT_FAMILY_NOT_RESOLVED, e.getMessage()); + Exception e = Assertions.assertThrows(IllegalStateException.class, () -> doc.add(paragraph)); + Assertions.assertEquals(LayoutExceptionMessageConstant.FONT_PROVIDER_NOT_SET_FONT_FAMILY_NOT_RESOLVED, e.getMessage()); } } } diff --git a/layout/src/test/java/com/itextpdf/layout/FontSelectorTest.java b/layout/src/test/java/com/itextpdf/layout/FontSelectorTest.java index c13e874944..743394e4f5 100644 --- a/layout/src/test/java/com/itextpdf/layout/FontSelectorTest.java +++ b/layout/src/test/java/com/itextpdf/layout/FontSelectorTest.java @@ -43,7 +43,6 @@ This file is part of the iText (R) project. import com.itextpdf.layout.font.selectorstrategy.BestMatchFontSelectorStrategy.BestMatchFontSelectorStrategyFactory; import com.itextpdf.layout.properties.Property; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; import java.util.ArrayList; @@ -55,19 +54,19 @@ This file is part of the iText (R) project. import java.util.List; import java.util.Map; import java.util.Set; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class FontSelectorTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/layout/FontSelectorTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/layout/FontSelectorTest/"; public static final String fontsFolder = "./src/test/resources/com/itextpdf/layout/fonts/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } @@ -79,9 +78,9 @@ public void cyrillicAndLatinGroup() throws Exception { String cmpFileName = sourceFolder + "cmp_" + fileName + ".pdf"; FontProvider sel = new FontProvider(); - Assert.assertTrue(sel.addFont(fontsFolder + "NotoSans-Regular.ttf")); - Assert.assertTrue(sel.addFont(fontsFolder + "FreeSans.ttf")); - Assert.assertTrue(sel.getFontSet().addFont(fontsFolder + "Puritan2.otf", PdfEncodings.IDENTITY_H, "Puritan42")); + Assertions.assertTrue(sel.addFont(fontsFolder + "NotoSans-Regular.ttf")); + Assertions.assertTrue(sel.addFont(fontsFolder + "FreeSans.ttf")); + Assertions.assertTrue(sel.getFontSet().addFont(fontsFolder + "Puritan2.otf", PdfEncodings.IDENTITY_H, "Puritan42")); String s = "Hello world! Здравствуй мир! Hello world! Здравствуй мир!"; @@ -95,7 +94,7 @@ public void cyrillicAndLatinGroup() throws Exception { doc.add(paragraph); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff" + fileName)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff" + fileName)); } @Test @@ -105,9 +104,9 @@ public void cyrillicAndLatinGroup2() throws Exception { String cmpFileName = sourceFolder + "cmp_" + fileName + ".pdf"; FontProvider sel = new FontProvider(); - Assert.assertTrue(sel.addFont(fontsFolder + "Puritan2.otf")); - Assert.assertTrue(sel.addFont(fontsFolder + "NotoSans-Regular.ttf")); - Assert.assertTrue(sel.addFont(fontsFolder + "FreeSans.ttf")); + Assertions.assertTrue(sel.addFont(fontsFolder + "Puritan2.otf")); + Assertions.assertTrue(sel.addFont(fontsFolder + "NotoSans-Regular.ttf")); + Assertions.assertTrue(sel.addFont(fontsFolder + "FreeSans.ttf")); String s = "Hello world! Здравствуй мир! Hello world! Здравствуй мир!"; @@ -121,7 +120,7 @@ public void cyrillicAndLatinGroup2() throws Exception { doc.add(paragraph); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff" + fileName)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff" + fileName)); } @Test @@ -132,9 +131,9 @@ public void cyrillicAndLatinGroup3() throws Exception { FontProvider sel = new FontProvider(); - Assert.assertTrue(sel.addFont(fontsFolder + "FreeSans.ttf")); - Assert.assertTrue(sel.addFont(fontsFolder + "NotoSans-Regular.ttf")); - Assert.assertTrue(sel.addFont(fontsFolder + "Puritan2.otf")); + Assertions.assertTrue(sel.addFont(fontsFolder + "FreeSans.ttf")); + Assertions.assertTrue(sel.addFont(fontsFolder + "NotoSans-Regular.ttf")); + Assertions.assertTrue(sel.addFont(fontsFolder + "Puritan2.otf")); String s = "Hello world! Здравствуй мир! Hello world! Здравствуй мир!"; @@ -148,7 +147,7 @@ public void cyrillicAndLatinGroup3() throws Exception { doc.add(paragraph); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff" + fileName)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff" + fileName)); } @Test @@ -159,9 +158,9 @@ public void cyrillicAndLatinGroupFontAsStringValue() throws Exception { FontProvider sel = new FontProvider(); - Assert.assertTrue(sel.addFont(fontsFolder + "FreeSans.ttf")); - Assert.assertTrue(sel.addFont(fontsFolder + "NotoSans-Regular.ttf")); - Assert.assertTrue(sel.addFont(fontsFolder + "Puritan2.otf")); + Assertions.assertTrue(sel.addFont(fontsFolder + "FreeSans.ttf")); + Assertions.assertTrue(sel.addFont(fontsFolder + "NotoSans-Regular.ttf")); + Assertions.assertTrue(sel.addFont(fontsFolder + "Puritan2.otf")); String s = "Hello world! Здравствуй мир! Hello world! Здравствуй мир!"; @@ -172,13 +171,13 @@ public void cyrillicAndLatinGroupFontAsStringValue() throws Exception { doc.setProperty(Property.FONT, "'Puritan', \"FreeSans\""); Text text = new Text(s).setBackgroundColor(ColorConstants.LIGHT_GRAY); Paragraph paragraph = new Paragraph(text); - Exception exception = Assert.assertThrows(IllegalStateException.class, () -> { + Exception exception = Assertions.assertThrows(IllegalStateException.class, () -> { doc.add(paragraph); doc.close(); - Assert.assertNull( + Assertions.assertNull( new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff" + fileName)); }); - Assert.assertEquals("Invalid FONT property value type.", exception.getMessage()); + Assertions.assertEquals("Invalid FONT property value type.", exception.getMessage()); } @Test @@ -188,7 +187,7 @@ public void latinAndNotdefGroup() throws Exception { String cmpFileName = sourceFolder + "cmp_" + fileName + ".pdf"; FontProvider sel = new FontProvider(); - Assert.assertTrue(sel.addFont(fontsFolder + "Puritan2.otf")); + Assertions.assertTrue(sel.addFont(fontsFolder + "Puritan2.otf")); String s = "Hello мир!"; PdfDocument pdfDoc = new PdfDocument(new PdfWriter(FileUtil.getFileOutputStream(outFileName))); @@ -201,7 +200,7 @@ public void latinAndNotdefGroup() throws Exception { doc.add(paragraph); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff" + fileName)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff" + fileName)); } @Test @@ -231,7 +230,7 @@ public void customFontWeight() throws Exception { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff" + fileName)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff" + fileName)); } @Test @@ -258,7 +257,7 @@ public void customFontWeight2() throws Exception { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff" + fileName)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff" + fileName)); } @Test @@ -286,7 +285,7 @@ public void customFontWeight3() throws Exception { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff" + fileName)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff" + fileName)); } @Test @@ -312,71 +311,71 @@ public void standardPdfFonts() throws Exception { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff" + fileName)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff" + fileName)); } @Test public void searchNames() { FontProvider sel = new FontProvider(); - Assert.assertTrue(sel.addFont(fontsFolder + "NotoSans-Regular.ttf")); - Assert.assertTrue(sel.addFont(fontsFolder + "FreeSans.ttf")); - Assert.assertTrue(sel.getFontSet().addFont(fontsFolder + "Puritan2.otf", PdfEncodings.IDENTITY_H, "Puritan42")); + Assertions.assertTrue(sel.addFont(fontsFolder + "NotoSans-Regular.ttf")); + Assertions.assertTrue(sel.addFont(fontsFolder + "FreeSans.ttf")); + Assertions.assertTrue(sel.getFontSet().addFont(fontsFolder + "Puritan2.otf", PdfEncodings.IDENTITY_H, "Puritan42")); Collection fonts = sel.getFontSet().get("puritan2"); - Assert.assertTrue("Puritan not found!", fonts.size() != 0); + Assertions.assertTrue(fonts.size() != 0, "Puritan not found!"); FontInfo puritan = getFirst(fonts); - Assert.assertFalse("Replace existed font", sel.getFontSet().addFont(puritan, "Puritan42")); - Assert.assertFalse("Replace existed font", sel.getFontSet().addFont(puritan)); + Assertions.assertFalse(sel.getFontSet().addFont(puritan, "Puritan42"), "Replace existed font"); + Assertions.assertFalse(sel.getFontSet().addFont(puritan), "Replace existed font"); - Assert.assertTrue("NotoSans not found!", sel.getFontSet().contains("NotoSans")); - Assert.assertTrue("NotoSans not found!", sel.getFontSet().contains("Noto Sans")); - Assert.assertTrue("FreeSans not found!", sel.getFontSet().contains("FreeSans")); - Assert.assertTrue("FreeSans not found!", sel.getFontSet().contains("Free Sans")); - Assert.assertTrue("Puritan 2.0 not found!", sel.getFontSet().contains("puritan 2.0 regular")); - Assert.assertTrue("Puritan 2.0 not found!", sel.getFontSet().contains("puritan2")); - Assert.assertFalse("Puritan42 found!", sel.getFontSet().contains("puritan42")); + Assertions.assertTrue(sel.getFontSet().contains("NotoSans"), "NotoSans not found!"); + Assertions.assertTrue(sel.getFontSet().contains("Noto Sans"), "NotoSans not found!"); + Assertions.assertTrue(sel.getFontSet().contains("FreeSans"), "FreeSans not found!"); + Assertions.assertTrue(sel.getFontSet().contains("Free Sans"), "FreeSans not found!"); + Assertions.assertTrue(sel.getFontSet().contains("puritan 2.0 regular"), "Puritan 2.0 not found!"); + Assertions.assertTrue(sel.getFontSet().contains("puritan2"), "Puritan 2.0 not found!"); + Assertions.assertFalse(sel.getFontSet().contains("puritan42"), "Puritan42 found!"); - Assert.assertEquals("Puritan 2.0 not found!", puritan, getFirst(sel.getFontSet().get("puritan 2.0 regular"))); - Assert.assertEquals("Puritan 2.0 not found!", puritan, getFirst(sel.getFontSet().get("puritan2"))); - Assert.assertTrue("Puritan42 found!", getFirst(sel.getFontSet().get("puritan42")) == null); + Assertions.assertEquals(puritan, getFirst(sel.getFontSet().get("puritan 2.0 regular")), "Puritan 2.0 not found!"); + Assertions.assertEquals(puritan, getFirst(sel.getFontSet().get("puritan2")), "Puritan 2.0 not found!"); + Assertions.assertTrue(getFirst(sel.getFontSet().get("puritan42")) == null, "Puritan42 found!"); } @Test public void searchNames2() { FontProvider sel = new FontProvider(); - Assert.assertTrue(sel.getFontSet().addFont(fontsFolder + "NotoSans-Regular.ttf")); - Assert.assertTrue(sel.getFontSet().addFont(fontsFolder + "FreeSans.ttf")); - Assert.assertTrue(sel.getFontSet().addFont(fontsFolder + "Puritan2.otf", PdfEncodings.IDENTITY_H, "Puritan42")); + Assertions.assertTrue(sel.getFontSet().addFont(fontsFolder + "NotoSans-Regular.ttf")); + Assertions.assertTrue(sel.getFontSet().addFont(fontsFolder + "FreeSans.ttf")); + Assertions.assertTrue(sel.getFontSet().addFont(fontsFolder + "Puritan2.otf", PdfEncodings.IDENTITY_H, "Puritan42")); Collection fonts = sel.getFontSet().get("puritan2"); - Assert.assertTrue("Puritan not found!", fonts.size() != 0); + Assertions.assertTrue(fonts.size() != 0, "Puritan not found!"); FontInfo puritan = getFirst(fonts); fonts = sel.getFontSet().get("NotoSans"); - Assert.assertTrue("NotoSans not found!", fonts.size() != 0); + Assertions.assertTrue(fonts.size() != 0, "NotoSans not found!"); FontInfo notoSans = getFirst(fonts); fonts = sel.getFontSet().get("FreeSans"); - Assert.assertTrue("FreeSans not found!", fonts.size() != 0); + Assertions.assertTrue(fonts.size() != 0, "FreeSans not found!"); FontInfo freeSans = getFirst(fonts); - Assert.assertTrue("NotoSans not found!", sel.getFontSet().contains("NotoSans")); - Assert.assertTrue("NotoSans not found!", sel.getFontSet().contains("Noto Sans")); - Assert.assertTrue("FreeSans not found!", sel.getFontSet().contains("FreeSans")); - Assert.assertTrue("FreeSans not found!", sel.getFontSet().contains("Free Sans")); - Assert.assertTrue("Puritan 2.0 not found!", sel.getFontSet().contains("puritan 2.0 regular")); - Assert.assertTrue("Puritan 2.0 not found!", sel.getFontSet().contains("puritan2")); - Assert.assertFalse("Puritan42 found!", sel.getFontSet().contains("puritan42")); - - Assert.assertEquals("NotoSans not found!", notoSans, getFirst(sel.getFontSet().get("NotoSans"))); - Assert.assertEquals("NotoSans not found!", notoSans, getFirst(sel.getFontSet().get("Noto Sans"))); - Assert.assertEquals("FreeSans not found!", freeSans, getFirst(sel.getFontSet().get("FreeSans"))); - Assert.assertEquals("FreeSans not found!", freeSans, getFirst(sel.getFontSet().get("Free Sans"))); - Assert.assertEquals("Puritan 2.0 not found!", puritan, getFirst(sel.getFontSet().get("puritan 2.0 regular"))); - Assert.assertEquals("Puritan 2.0 not found!", puritan, getFirst(sel.getFontSet().get("puritan2"))); - Assert.assertTrue("Puritan42 found!", getFirst(sel.getFontSet().get("puritan42")) == null); + Assertions.assertTrue(sel.getFontSet().contains("NotoSans"), "NotoSans not found!"); + Assertions.assertTrue(sel.getFontSet().contains("Noto Sans"), "NotoSans not found!"); + Assertions.assertTrue(sel.getFontSet().contains("FreeSans"), "FreeSans not found!"); + Assertions.assertTrue(sel.getFontSet().contains("Free Sans"), "FreeSans not found!"); + Assertions.assertTrue(sel.getFontSet().contains("puritan 2.0 regular"), "Puritan 2.0 not found!"); + Assertions.assertTrue(sel.getFontSet().contains("puritan2"), "Puritan 2.0 not found!"); + Assertions.assertFalse(sel.getFontSet().contains("puritan42"), "Puritan42 found!"); + + Assertions.assertEquals(notoSans, getFirst(sel.getFontSet().get("NotoSans")), "NotoSans not found!"); + Assertions.assertEquals(notoSans, getFirst(sel.getFontSet().get("Noto Sans")), "NotoSans not found!"); + Assertions.assertEquals(freeSans, getFirst(sel.getFontSet().get("FreeSans")), "FreeSans not found!"); + Assertions.assertEquals(freeSans, getFirst(sel.getFontSet().get("Free Sans")), "FreeSans not found!"); + Assertions.assertEquals(puritan, getFirst(sel.getFontSet().get("puritan 2.0 regular")), "Puritan 2.0 not found!"); + Assertions.assertEquals(puritan, getFirst(sel.getFontSet().get("puritan2")), "Puritan 2.0 not found!"); + Assertions.assertTrue(getFirst(sel.getFontSet().get("puritan42")) == null, "Puritan42 found!"); } @Test @@ -406,12 +405,12 @@ public void searchFontAliasWithUnicodeChars() { actualAliases.add(fontInfo.getAlias()); } Set expectedAliases = aliasToFontName.keySet(); - Assert.assertTrue(actualAliases.containsAll(expectedAliases) && expectedAliases.containsAll(actualAliases)); + Assertions.assertTrue(actualAliases.containsAll(expectedAliases) && expectedAliases.containsAll(actualAliases)); for (String fontAlias : expectedAliases) { PdfFont pdfFont = provider.getPdfFont(provider.getFontSelector(Collections.singletonList(fontAlias), new FontCharacteristics()).bestMatch()); String fontName = pdfFont.getFontProgram().getFontNames().getFontName(); - Assert.assertTrue(aliasToFontName.get(fontAlias).contains(fontName)); + Assertions.assertTrue(aliasToFontName.get(fontAlias).contains(fontName)); } } @@ -439,7 +438,7 @@ public void writeTextInFontWhichAliasWithUnicodeChars() throws IOException, Inte doc.close(); // Text shall be written in Puritan 2.0 - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } @@ -450,9 +449,9 @@ public void cyrillicAndLatinWithUnicodeRange() throws Exception { String cmpFileName = sourceFolder + "cmp_" + fileName + ".pdf"; FontProvider sel = new FontProvider(); - Assert.assertTrue(sel.getFontSet().addFont(fontsFolder + "NotoSans-Regular.ttf", null, "FontAlias", new RangeBuilder(0, 255).create())); - Assert.assertTrue(sel.getFontSet().addFont(fontsFolder + "FreeSans.ttf", null, "FontAlias", new RangeBuilder(1024, 1279).create())); - Assert.assertTrue(sel.getFontSet().size() == 2); + Assertions.assertTrue(sel.getFontSet().addFont(fontsFolder + "NotoSans-Regular.ttf", null, "FontAlias", new RangeBuilder(0, 255).create())); + Assertions.assertTrue(sel.getFontSet().addFont(fontsFolder + "FreeSans.ttf", null, "FontAlias", new RangeBuilder(1024, 1279).create())); + Assertions.assertTrue(sel.getFontSet().size() == 2); String s = "Hello world! Здравствуй мир! Hello world! Здравствуй мир!"; PdfDocument pdfDoc = new PdfDocument(new PdfWriter(FileUtil.getFileOutputStream(outFileName))); @@ -465,7 +464,7 @@ public void cyrillicAndLatinWithUnicodeRange() throws Exception { doc.add(paragraph); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff" + fileName)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff" + fileName)); } @Test @@ -475,8 +474,8 @@ public void notSignificantCharacterOfTheFontWithUnicodeRange() throws Exception FontProvider sel = new FontProvider(); sel.setFontSelectorStrategyFactory(new BestMatchFontSelectorStrategyFactory()); - Assert.assertTrue(sel.getFontSet().addFont(fontsFolder + "NotoSansCJKjp-Bold.otf", null, "FontAlias", new RangeBuilder(117, 117).create())); // just 'u' letter - Assert.assertTrue(sel.getFontSet().addFont(fontsFolder + "FreeSans.ttf", null, "FontAlias", new RangeBuilder(106, 113).create()));// 'j', 'm' and 'p' are in that interval + Assertions.assertTrue(sel.getFontSet().addFont(fontsFolder + "NotoSansCJKjp-Bold.otf", null, "FontAlias", new RangeBuilder(117, 117).create())); // just 'u' letter + Assertions.assertTrue(sel.getFontSet().addFont(fontsFolder + "FreeSans.ttf", null, "FontAlias", new RangeBuilder(106, 113).create()));// 'j', 'm' and 'p' are in that interval PdfDocument pdfDoc = new PdfDocument(new PdfWriter(outFileName)); Document doc = new Document(pdfDoc); @@ -488,7 +487,7 @@ public void notSignificantCharacterOfTheFontWithUnicodeRange() throws Exception doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -499,11 +498,11 @@ public void checkThreeFontsInOneLineWithUnicodeRange() throws Exception { FontProvider sel = new FontProvider(); sel.setFontSelectorStrategyFactory(new BestMatchFontSelectorStrategyFactory()); // 'a', 'b' and 'c' are in that interval - Assert.assertTrue(sel.getFontSet().addFont(fontsFolder + "NotoSansCJKjp-Bold.otf", null, "FontAlias", new RangeBuilder(97, 99).create())); + Assertions.assertTrue(sel.getFontSet().addFont(fontsFolder + "NotoSansCJKjp-Bold.otf", null, "FontAlias", new RangeBuilder(97, 99).create())); // 'd', 'e' and 'f' are in that interval - Assert.assertTrue(sel.getFontSet().addFont(fontsFolder + "FreeSans.ttf", null, "FontAlias", new RangeBuilder(100, 102).create())); + Assertions.assertTrue(sel.getFontSet().addFont(fontsFolder + "FreeSans.ttf", null, "FontAlias", new RangeBuilder(100, 102).create())); // 'x', 'y' and 'z' are in that interval - Assert.assertTrue(sel.getFontSet().addFont(fontsFolder + "Puritan2.otf", null, "FontAlias", new RangeBuilder(120, 122).create())); + Assertions.assertTrue(sel.getFontSet().addFont(fontsFolder + "Puritan2.otf", null, "FontAlias", new RangeBuilder(120, 122).create())); PdfDocument pdfDoc = new PdfDocument(new PdfWriter(outFileName)); Document doc = new Document(pdfDoc); @@ -515,7 +514,7 @@ public void checkThreeFontsInOneLineWithUnicodeRange() throws Exception { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -526,9 +525,9 @@ public void duplicateFontWithUnicodeRange() throws Exception { String cmpFileName = sourceFolder + "cmp_" + fileName + ".pdf"; FontProvider sel = new FontProvider(); - Assert.assertTrue(sel.getFontSet().addFont(fontsFolder + "NotoSans-Regular.ttf", null, "FontAlias", new RangeBuilder(0, 255).create())); - Assert.assertTrue(sel.getFontSet().addFont(fontsFolder + "NotoSans-Regular.ttf", null, "FontAlias", new RangeBuilder(1024, 1279).create())); - Assert.assertTrue(sel.getFontSet().size() == 2); + Assertions.assertTrue(sel.getFontSet().addFont(fontsFolder + "NotoSans-Regular.ttf", null, "FontAlias", new RangeBuilder(0, 255).create())); + Assertions.assertTrue(sel.getFontSet().addFont(fontsFolder + "NotoSans-Regular.ttf", null, "FontAlias", new RangeBuilder(1024, 1279).create())); + Assertions.assertTrue(sel.getFontSet().size() == 2); String s = "Hello world! Здравствуй мир! Hello world! Здравствуй мир!"; PdfDocument pdfDoc = new PdfDocument(new PdfWriter(FileUtil.getFileOutputStream(outFileName))); @@ -541,7 +540,7 @@ public void duplicateFontWithUnicodeRange() throws Exception { doc.add(paragraph); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff" + fileName)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff" + fileName)); } @Test @@ -552,9 +551,9 @@ public void singleFontWithUnicodeRange() throws Exception { String cmpFileName = sourceFolder + "cmp_" + fileName + ".pdf"; FontProvider sel = new FontProvider(); - Assert.assertTrue(sel.getFontSet().addFont(fontsFolder + "NotoSans-Regular.ttf", null, "FontAlias")); - Assert.assertFalse(sel.getFontSet().addFont(fontsFolder + "NotoSans-Regular.ttf", null, "FontAlias")); - Assert.assertTrue(sel.getFontSet().size() == 1); + Assertions.assertTrue(sel.getFontSet().addFont(fontsFolder + "NotoSans-Regular.ttf", null, "FontAlias")); + Assertions.assertFalse(sel.getFontSet().addFont(fontsFolder + "NotoSans-Regular.ttf", null, "FontAlias")); + Assertions.assertTrue(sel.getFontSet().size() == 1); String s = "Hello world! Здравствуй мир! Hello world! Здравствуй мир!"; PdfDocument pdfDoc = new PdfDocument(new PdfWriter(FileUtil.getFileOutputStream(outFileName))); @@ -567,7 +566,7 @@ public void singleFontWithUnicodeRange() throws Exception { doc.add(paragraph); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff" + fileName)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff" + fileName)); } @Test @@ -1013,7 +1012,7 @@ public void openSansFontWeightBoldRenderingTest() throws Exception { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } @Test @@ -1044,7 +1043,7 @@ public void openSansFontWeightNotBoldRenderingTest() throws Exception { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } @Test @@ -1061,7 +1060,7 @@ public void openSansOutOfBoldFontWeightTest() { FontCharacteristics fc = new FontCharacteristics(); fc.setFontWeight((short) 400); - Assert.assertEquals("OpenSans-Bold", new FontSelector(set.getFonts(), fontFamilies, fc).bestMatch().getDescriptor().getFontName()); + Assertions.assertEquals("OpenSans-Bold", new FontSelector(set.getFonts(), fontFamilies, fc).bestMatch().getDescriptor().getFontName()); } @Test @@ -1078,13 +1077,13 @@ public void openSansOutOfMixedFontWeightTest() { FontCharacteristics fc = new FontCharacteristics(); fc.setFontWeight((short) 100); - Assert.assertEquals("OpenSans-Light", + Assertions.assertEquals("OpenSans-Light", new FontSelector(set.getFonts(), fontFamilies, fc).bestMatch().getDescriptor().getFontName()); fc = new FontCharacteristics(); fc.setFontWeight((short) 600); - Assert.assertEquals("OpenSans-SemiBold", + Assertions.assertEquals("OpenSans-SemiBold", new FontSelector(set.getFonts(), fontFamilies, fc).bestMatch().getDescriptor().getFontName()); } @@ -1103,7 +1102,7 @@ public void openSansOutOfNotBoldFontWeightTest() { FontCharacteristics fc = new FontCharacteristics(); fc.setFontWeight((short) 700); - Assert.assertEquals("OpenSans-Light", + Assertions.assertEquals("OpenSans-Light", new FontSelector(set.getFonts(), fontFamilies, fc).bestMatch().getDescriptor().getFontName()); } @@ -1121,7 +1120,7 @@ public void monospaceFontIsNotSelectedInPreferenceToTestFamilyTest() { FontCharacteristics fc = new FontCharacteristics(); //Expected font is Courier - Assert.assertEquals("Helvetica", + Assertions.assertEquals("Helvetica", new FontSelector(set.getFonts(), fontFamilies, fc).bestMatch().getDescriptor().getFontName()); } @@ -1139,7 +1138,7 @@ public void family2UsedToSortFontsTest() { FontCharacteristics fc = new FontCharacteristics(); fc.setFontWeight((short) 300); // Between hairline (200) and regular (400) - Assert.assertEquals("Lato-Hairline", + Assertions.assertEquals("Lato-Hairline", new FontSelector(set.getFonts(), fontFamilies, fc).bestMatch().getDescriptor().getFontName()); } @@ -1155,7 +1154,7 @@ public void monospaceFontsTest() { FontSelector fontSelector = new FontSelector(set.getFonts(), fontFamilies, fc); - Assert.assertTrue("Font is not recognized as monospace.", fontSelector.bestMatch().getDescriptor().isMonospace()); + Assertions.assertTrue(fontSelector.bestMatch().getDescriptor().isMonospace(), "Font is not recognized as monospace."); } private void checkSelector(Collection fontInfoCollection, String fontFamily, @@ -1255,7 +1254,7 @@ private void checkSelector(Collection fontInfoCollection, String fontF private void assertSelectedFont(Collection fontInfoCollection, List fontFamilies, FontCharacteristics fc, String expectedFontName) { - Assert.assertEquals(expectedFontName, new FontSelector(fontInfoCollection, fontFamilies, fc).bestMatch().getDescriptor().getFontName()); + Assertions.assertEquals(expectedFontName, new FontSelector(fontInfoCollection, fontFamilies, fc).bestMatch().getDescriptor().getFontName()); } private static FontSet getStandardFontSet() { diff --git a/layout/src/test/java/com/itextpdf/layout/HyphenateLayoutTest.java b/layout/src/test/java/com/itextpdf/layout/HyphenateLayoutTest.java index dff28d08cc..54c5130d93 100644 --- a/layout/src/test/java/com/itextpdf/layout/HyphenateLayoutTest.java +++ b/layout/src/test/java/com/itextpdf/layout/HyphenateLayoutTest.java @@ -39,20 +39,19 @@ This file is part of the iText (R) project. import com.itextpdf.layout.hyphenation.Hyphenator; import com.itextpdf.layout.properties.TextAlignment; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class HyphenateLayoutTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/layout/HyphenateLayoutTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/layout/HyphenateLayoutTest/"; public static final String fontsFolder = "./src/test/resources/com/itextpdf/layout/fonts/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } @@ -79,7 +78,7 @@ public void parenthesisTest01() throws Exception { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -115,7 +114,7 @@ public void uriTest01() throws Exception { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -136,7 +135,7 @@ public void widthTest01() throws Exception { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @@ -158,7 +157,7 @@ public void widthTest02() throws Exception { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -192,7 +191,7 @@ public void widthTest03() throws Exception { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -216,7 +215,7 @@ public void nonBreakingHyphenTest01() throws Exception { document.close(); pdf.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -244,7 +243,7 @@ public void nonBreakingHyphenTest02() throws Exception { document.close(); pdf.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -285,6 +284,6 @@ public void hyphenSymbolTest01() throws Exception { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } } diff --git a/layout/src/test/java/com/itextpdf/layout/HyphenateResultTest.java b/layout/src/test/java/com/itextpdf/layout/HyphenateResultTest.java index 51e2c5b4b2..ceb41e17b4 100644 --- a/layout/src/test/java/com/itextpdf/layout/HyphenateResultTest.java +++ b/layout/src/test/java/com/itextpdf/layout/HyphenateResultTest.java @@ -25,12 +25,11 @@ This file is part of the iText (R) project. import com.itextpdf.layout.hyphenation.Hyphenation; import com.itextpdf.layout.hyphenation.HyphenationConfig; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class HyphenateResultTest extends ExtendedITextTest { @Test @@ -111,9 +110,9 @@ private void testHyphenateResult(String lang, String testWorld, int[] expectedHy HyphenationConfig config = new HyphenationConfig(lang, country, 3, 3); Hyphenation result = config.hyphenate(testWorld); if (result != null) { - Assert.assertArrayEquals(expectedHyphenatePoints, result.getHyphenationPoints()); + Assertions.assertArrayEquals(expectedHyphenatePoints, result.getHyphenationPoints()); } else { - Assert.assertNull(expectedHyphenatePoints); + Assertions.assertNull(expectedHyphenatePoints); } } } diff --git a/layout/src/test/java/com/itextpdf/layout/HyphenateTest.java b/layout/src/test/java/com/itextpdf/layout/HyphenateTest.java index 40047832f1..bf713b6e36 100644 --- a/layout/src/test/java/com/itextpdf/layout/HyphenateTest.java +++ b/layout/src/test/java/com/itextpdf/layout/HyphenateTest.java @@ -26,32 +26,20 @@ This file is part of the iText (R) project. import com.itextpdf.layout.hyphenation.Hyphenation; import com.itextpdf.layout.hyphenation.HyphenationConfig; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(Parameterized.class) -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class HyphenateTest extends ExtendedITextTest { - private final String lang; - private final String testWord; - private List errors = new ArrayList<>(); - public HyphenateTest(String testName, String lang, String testWord) { - this.lang = lang; - this.testWord = testWord; - } - - @Parameterized.Parameters(name = "{0}") public static Iterable hyphenationProperties() { return Arrays.asList(new Object[][]{ {"African", "af", "country"}, @@ -127,11 +115,12 @@ public static Iterable hyphenationProperties() { }); } - @Test - public void runTest() { + @ParameterizedTest(name = "{0}") + @MethodSource("hyphenationProperties") + public void runTest(String name, String lang, String testWord) { errors.clear(); tryHyphenate(lang, testWord); - Assert.assertTrue(buildReport(), errors.isEmpty()); + Assertions.assertTrue(errors.isEmpty(), buildReport()); } private void tryHyphenate(String lang, String testWorld) { diff --git a/layout/src/test/java/com/itextpdf/layout/ImageColorProfileTest.java b/layout/src/test/java/com/itextpdf/layout/ImageColorProfileTest.java index f870ed262e..005e7ab3cb 100644 --- a/layout/src/test/java/com/itextpdf/layout/ImageColorProfileTest.java +++ b/layout/src/test/java/com/itextpdf/layout/ImageColorProfileTest.java @@ -34,23 +34,22 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; import java.util.HashMap; import java.util.Map; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class ImageColorProfileTest extends ExtendedITextTest { public static final String destinationFolder = "./target/test/com/itextpdf/layout/ImageColorProfileTest/"; public static final String sourceFolder = "./src/test/resources/com/itextpdf/layout/ImageColorProfileTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } @@ -59,7 +58,7 @@ public static void beforeClass() { @LogMessages(messages = {@LogMessage(messageTemplate = IoLogMessageConstant.PNG_IMAGE_HAS_ICC_PROFILE_WITH_INCOMPATIBLE_NUMBER_OF_COLOR_COMPONENTS)}) public void extractIncompatibleColorProfileTest() throws IOException { ImageData imageData = ImageDataFactory.create(sourceFolder + "png-incorrect-embedded-color-profile.png"); - Assert.assertNotNull(imageData.getProfile()); + Assertions.assertNotNull(imageData.getProfile()); } @Test @@ -148,6 +147,6 @@ private void runTest(String pdfName, String imageName, String colorProfileName, document.add(png); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, diff)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, diff)); } } diff --git a/layout/src/test/java/com/itextpdf/layout/ImageTest.java b/layout/src/test/java/com/itextpdf/layout/ImageTest.java index 817e399064..3965a1c6b1 100644 --- a/layout/src/test/java/com/itextpdf/layout/ImageTest.java +++ b/layout/src/test/java/com/itextpdf/layout/ImageTest.java @@ -54,21 +54,20 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class ImageTest extends ExtendedITextTest { public static final String destinationFolder = "./target/test/com/itextpdf/layout/ImageTest/"; public static final String sourceFolder = "./src/test/resources/com/itextpdf/layout/ImageTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } @@ -96,7 +95,7 @@ public void imageTest01() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -122,7 +121,7 @@ public void imageTest02() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -149,7 +148,7 @@ public void imageTest03() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -176,7 +175,7 @@ public void imageTest04() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -203,7 +202,7 @@ public void imageTest05() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -229,7 +228,7 @@ public void imageTest06() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -252,7 +251,7 @@ public void imageTest07() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -277,7 +276,7 @@ public void imageTest08() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -298,7 +297,7 @@ public void imageTest09() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -316,7 +315,7 @@ public void imageTest10() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -334,7 +333,7 @@ public void imageTest11() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -353,7 +352,7 @@ public void imageTest12_HorizontalAlignment_CENTER() throws IOException, Interru doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -372,7 +371,7 @@ public void imageTest13_HorizontalAlignment_RIGHT() throws IOException, Interrup doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -391,7 +390,7 @@ public void imageTest14_HorizontalAlignment_LEFT() throws IOException, Interrupt doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -413,7 +412,7 @@ public void imageTest15() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test() @@ -434,7 +433,7 @@ public void imageTest16() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test() @@ -462,7 +461,7 @@ public void imageTest17() throws IOException, InterruptedException { } doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -486,7 +485,7 @@ public void imageTest18() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } //TODO(DEVSIX-1659) @@ -511,7 +510,7 @@ public void imageTest19() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -535,7 +534,7 @@ public void imageTest20() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } //TODO(DEVSIX-1659) @@ -569,7 +568,7 @@ public void imageTest21() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -590,7 +589,7 @@ public void imageTest22() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff_")); } @Test @@ -608,7 +607,7 @@ public void imageTest23() throws IOException, InterruptedException { doc.add(image); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } /** @@ -635,7 +634,7 @@ public void flushOnDrawTest() throws IOException, InterruptedException { document.add(table); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } /** @@ -677,7 +676,7 @@ public void flushOnDrawCheckCircularReferencesTest() throws IOException, Interru document.add(table); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -704,7 +703,7 @@ public void imageWithBordersSurroundedByTextTest() throws IOException, Interrupt doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -729,7 +728,7 @@ public void imageInParagraphBorderTest() throws IOException, InterruptedExceptio doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } //TODO(DEVSIX-1022) @@ -755,7 +754,7 @@ public void imageRelativePositionTest() throws IOException, InterruptedException doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -785,7 +784,7 @@ public void imageInTableTest01() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -816,7 +815,7 @@ public void imageInTableTest02() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } //TODO(DEVSIX-1045) @@ -833,7 +832,7 @@ public void fixedPositionImageTest01() throws IOException, InterruptedException document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -870,7 +869,7 @@ public void imageWithMinMaxHeightTest01() throws IOException, InterruptedExcepti doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -901,7 +900,7 @@ public void precisionTest01() throws IOException, InterruptedException { pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -923,7 +922,7 @@ public void imageBorderRadiusTest01() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -950,7 +949,7 @@ public void createTiffImageTest() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } @Test @@ -967,6 +966,6 @@ public void tiffImageWithoutCompressionTest() throws IOException, InterruptedExc document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff02_")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff02_")); } } diff --git a/layout/src/test/java/com/itextpdf/layout/InlineBlockTest.java b/layout/src/test/java/com/itextpdf/layout/InlineBlockTest.java index 68e3e91745..faa618b2da 100644 --- a/layout/src/test/java/com/itextpdf/layout/InlineBlockTest.java +++ b/layout/src/test/java/com/itextpdf/layout/InlineBlockTest.java @@ -40,22 +40,21 @@ This file is part of the iText (R) project. import com.itextpdf.layout.properties.Property; import com.itextpdf.layout.properties.UnitValue; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.FileNotFoundException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class InlineBlockTest extends ExtendedITextTest { public static final String destinationFolder = "./target/test/com/itextpdf/layout/InlineBlockTest/"; public static final String sourceFolder = "./src/test/resources/com/itextpdf/layout/InlineBlockTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } @@ -99,7 +98,7 @@ public void inlineTableTest01() throws IOException, InterruptedException { doc.add(p4); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -140,7 +139,7 @@ public void deepNestingInlineBlocksTest01() throws IOException, InterruptedExcep System.out.println(SystemUtil.getRelativeTimeMillis() - start); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -173,6 +172,6 @@ public void wrappingAfter100PercentWidthFloatTest() throws IOException, Interrup ); } - Assert.assertNull(new CompareTool().compareByContent(output, cmp, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(output, cmp, destinationFolder)); } } diff --git a/layout/src/test/java/com/itextpdf/layout/KeepTogetherTest.java b/layout/src/test/java/com/itextpdf/layout/KeepTogetherTest.java index 4c95d7704d..35ee829144 100644 --- a/layout/src/test/java/com/itextpdf/layout/KeepTogetherTest.java +++ b/layout/src/test/java/com/itextpdf/layout/KeepTogetherTest.java @@ -54,17 +54,16 @@ This file is part of the iText (R) project. import com.itextpdf.test.LogLevelConstants; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.ByteArrayOutputStream; import java.io.IOException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class KeepTogetherTest extends ExtendedITextTest { public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/layout/KeepTogetherTest/"; @@ -85,7 +84,7 @@ public class KeepTogetherTest extends ExtendedITextTest { private static final String SMALL_TEXT = "Short text"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(DESTINATION_FOLDER); } @@ -111,7 +110,7 @@ public void keepTogetherParagraphTest01() throws IOException, InterruptedExcepti p1.setKeepTogether(true); doc.add(p1); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -128,7 +127,7 @@ public void skipKeepTogetherInCaseOfAreaBreak() throws IOException, InterruptedE doc.add(keptTogetherDiv); // If this line is not triggered, then an NPE occurred - Assert.assertTrue(true); + Assertions.assertTrue(true); doc.close(); } @@ -161,7 +160,7 @@ public void keepTogetherParagraphTest02() throws IOException, InterruptedExcepti doc.add(p1); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -180,7 +179,7 @@ public void keepTogetherListTest01() throws IOException, InterruptedException { list.add("firstItem").add("secondItem").add("thirdItem").setKeepTogether(true).setListSymbol(ListNumberingType.DECIMAL); doc.add(list); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -207,7 +206,7 @@ public void keepTogetherDivTest01() throws IOException, InterruptedException { doc.add(div); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -234,7 +233,7 @@ public void keepTogetherMinHeightTest() throws IOException, InterruptedException doc.add(div); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -259,7 +258,7 @@ public void keepTogetherDivTest02() throws IOException, InterruptedException { doc.add(div); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -324,7 +323,7 @@ public void keepTogetherDivWithInnerClearDiv() throws IOException, InterruptedEx // as the first add doc.add(keepTogetherDiv); } - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -346,11 +345,11 @@ public void keepTogetherDefaultTest01() throws IOException, InterruptedException doc.add(div); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test - @Ignore("DEVSIX-1837: NPE") + @Disabled("DEVSIX-1837: NPE") public void keepTogetherInlineDiv01() throws IOException, InterruptedException { String cmpFileName = SOURCE_FOLDER + "cmp_keepTogetherInlineDiv01.pdf"; String outFile = DESTINATION_FOLDER + "keepTogetherInlineDiv01.pdf"; @@ -369,7 +368,7 @@ public void keepTogetherInlineDiv01() throws IOException, InterruptedException { doc.add(new Paragraph().add(div)); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -396,7 +395,7 @@ public void keepTogetherInlineDiv02() throws IOException, InterruptedException { doc.add(new Paragraph().add(div)); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -431,7 +430,7 @@ public void narrowPageTest01() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, testName + "_diff")); } @Test @@ -472,7 +471,7 @@ public void narrowPageTest02() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, testName + "_diff")); } @Test @@ -508,7 +507,7 @@ public void narrowPageTest02A() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, testName + "_diff")); } @Test @@ -538,7 +537,7 @@ public void updateHeightTest01() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, testName + "_diff")); } @Test @@ -570,7 +569,7 @@ public void partialTest01() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, testName + "_diff")); } @Test @@ -597,7 +596,7 @@ public void fixedHeightOverflowTest01() throws IOException, InterruptedException doc.add(div); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER, "diff")); } @@ -630,7 +629,7 @@ public void marginCollapseKeptTogetherDivGoesBackTest01() throws IOException, In doc.add(div2); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -662,7 +661,7 @@ public void marginCollapseKeptTogetherDivGoesBackTest02() throws IOException, In doc.add(div2); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -693,7 +692,7 @@ public void keepTogetherNotEmptyPageTest() throws IOException, InterruptedExcept doc.add(innerDiv); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -727,7 +726,7 @@ public void keepTogetherOnFirstInnerElementNotEmptyPageTest() throws IOException doc.add(outerDiv); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -756,7 +755,7 @@ public void marginCollapseKeptTogetherGoesOnNextAreaTest01() throws IOException, doc.add(div2); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -785,7 +784,7 @@ public void marginCollapseKeptTogetherGoesOnNextAreaTest02() throws IOException, doc.add(div2); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -820,7 +819,7 @@ public void keepTogetherOnSecondInnerElementNotEmptyPageTest() throws IOExceptio doc.add(outerDiv); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -839,7 +838,7 @@ public void smallFloatInsideKeptTogetherDivTest01() throws IOException, Interrup doc.add(createKeptTogetherDivWithSmallFloat(divHeight)); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -861,7 +860,7 @@ public void smallFloatInsideKeptTogetherDivTest02() throws IOException, Interrup doc.add(createKeptTogetherDivWithSmallFloat(divHeight)); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -880,7 +879,7 @@ public void smallFloatInsideKeptTogetherParagraphTest01() throws IOException, In doc.add(createKeptTogetherParagraphWithSmallFloat(paragraphHeight)); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -902,7 +901,7 @@ public void smallFloatInsideKeptTogetherParagraphTest02() throws IOException, In doc.add(createKeptTogetherParagraphWithSmallFloat(paragraphHeight)); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -927,7 +926,7 @@ public void keepTogetherOnInnerElementTestEmptyPageTest() throws IOException, In addDivs(doc, innerDivHeight, new Style(), new Style(), first); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -955,7 +954,7 @@ public void keepTogetherOnInnerElementMargin01EmptyPageTest() throws IOException addDivs(doc, innerDivHeight, inner, predefined, first); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -983,7 +982,7 @@ public void keepTogetherOnInnerElementMargin02EmptyPageTest() throws IOException addDivs(doc, innerDivHeight, inner, predefined, first); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -1002,7 +1001,7 @@ public void smallFloatInsideKeptTogetherTableTest01() throws IOException, Interr doc.add(createKeptTogetherTableWithSmallFloat(numOfRows)); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER, "diff")); } @@ -1025,7 +1024,7 @@ public void smallFloatInsideKeptTogetherTableTest02() throws IOException, Interr doc.add(createKeptTogetherTableWithSmallFloat(numOfRows)); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -1057,7 +1056,7 @@ public void keepTogetherTreeWithParentNotFitOnDocumentTest() throws IOException, doc.add(main); } - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER)); } @Test @@ -1091,7 +1090,7 @@ public void keepTogetherSubTreeWithParentNotFitOnDocumentTest() throws IOExcepti doc.add(main); } - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER)); } @Test @@ -1126,7 +1125,7 @@ public void keepTogetherSubTreeWithChildKeepTogetherFalseAndParentNotFitOnDocume doc.add(main); } - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER)); } @Test @@ -1163,7 +1162,7 @@ public void keepTogetherTreeWithParentNotFitOnPageCanvasTest() throws IOExceptio } } - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER)); } @Test @@ -1200,7 +1199,7 @@ public void keepTogetherInDivWithKidsFloatTest() throws IOException, Interrupted doc.add(main); } - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER)); } @Test @@ -1240,7 +1239,7 @@ public void floatingElementsInDivAndKeepTogetherElemTest() throws IOException, I .setKeepTogether(true).setFontSize(24)); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER)); } @Test @@ -1283,7 +1282,7 @@ public void floatingEmptyElementsInDivAndKeepTogetherElemTest() throws IOExcepti doc.add(ktp); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER)); } @Test @@ -1318,7 +1317,7 @@ public void floatingEmptyElementsAndKeepTogetherElemTest() throws IOException, I doc.add(ktp); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER)); } @Test @@ -1338,7 +1337,7 @@ public void pWithKeepTogetherPlusHugeImgChildTest() throws IOException, Interrup p.add(new Image(ImageDataFactory.create(SOURCE_FOLDER + "huge.png"))); doc.add(p); } - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -1375,7 +1374,7 @@ private void generateCmpWithKeepTogetherAndCheckResult(boolean doRelayout) throw } doc.close(); } - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER, "diff")); } private Div createChildDivWithText(Div parent, String text) { diff --git a/layout/src/test/java/com/itextpdf/layout/KeepWithNextTest.java b/layout/src/test/java/com/itextpdf/layout/KeepWithNextTest.java index 384c00cbde..2a258e4ce4 100644 --- a/layout/src/test/java/com/itextpdf/layout/KeepWithNextTest.java +++ b/layout/src/test/java/com/itextpdf/layout/KeepWithNextTest.java @@ -36,16 +36,15 @@ This file is part of the iText (R) project. import com.itextpdf.layout.properties.Property; import com.itextpdf.layout.properties.UnitValue; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class KeepWithNextTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/layout/KeepWithNextTest/"; @@ -68,7 +67,7 @@ public class KeepWithNextTest extends ExtendedITextTest { "Click Insert and then choose the elements you want from the different galleries. Themes and styles also help keep your document coordinated. When you click Design and choose a new Theme, the pictures, charts, and SmartArt graphics change to match your new theme. When you apply styles, your headings change to match the new theme. Save time in Word with new buttons that show up where you need them. To change the way a picture fits in your document, click it and a button for layout options appears next to it. When you work on a table, click where you want to add a row or a column, and then click the plus sign. Reading is easier, too, in the new Reading view. You can collapse parts of the document and focus on the text you want. If you need to stop reading before you reach the end, Word remembers where you left off - even on another device.\n" + "Video provides a powerful way to help you prove your point. When you click Online Video, you can paste in the embed code for the video you want to add. You can also type a keyword to search online for the video that best fits your document. To make your document look professionally produced, Word provides header, footer, cover page, and text box designs that complement each other. For example, you can add a matching cover page, header, and sidebar. Click Insert and then choose the elements you want from the different galleries. Themes and styles also help keep your document coordinated. When you click Design and choose a new Theme, the pictures, charts, and SmartArt graphics change to match your new theme. When you apply styles, your headings change to match the new theme. Save time in Word with new buttons that show up where you need them.\n"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } @@ -92,7 +91,7 @@ public void keepWithNextTest01() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -112,7 +111,7 @@ public void keepWithNextTest02() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -132,7 +131,7 @@ public void keepWithNextTest03() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -153,7 +152,7 @@ public void keepWithNextTest04() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -175,7 +174,7 @@ public void keepWithNextTest05() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -189,7 +188,7 @@ public void keepWithNextTest06() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -205,7 +204,7 @@ public void keepWithNextTest07() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -228,7 +227,7 @@ public void keepWithNextTest08() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -250,7 +249,7 @@ public void keepWithNextTest09() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -272,7 +271,7 @@ public void keepWithNextTest10() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -295,7 +294,7 @@ public void keepWithNextTest11() throws IOException, InterruptedException { document.add(table); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } } diff --git a/layout/src/test/java/com/itextpdf/layout/LargeElementTest.java b/layout/src/test/java/com/itextpdf/layout/LargeElementTest.java index 84a58af7f3..f4583c4709 100644 --- a/layout/src/test/java/com/itextpdf/layout/LargeElementTest.java +++ b/layout/src/test/java/com/itextpdf/layout/LargeElementTest.java @@ -48,23 +48,22 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class LargeElementTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/layout/LargeElementTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/layout/LargeElementTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } @@ -98,7 +97,7 @@ public void largeTableTest01() throws IOException, InterruptedException { doc.add(new Table(UnitValue.createPercentArray(1)).useAllAvailableWidth().setBorder(new SolidBorder(ColorConstants.ORANGE, 2)).addCell("Is my occupied area correct?")); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -126,7 +125,7 @@ public void largeTableTest02() throws IOException, InterruptedException { doc.add(new Table(UnitValue.createPercentArray(1)).useAllAvailableWidth().setBorder(new SolidBorder(ColorConstants.ORANGE, 2)).addCell("Is my occupied area correct?")); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -157,7 +156,7 @@ public void largeTableWithEmptyLastRowTest() throws IOException, InterruptedExce doc.add(new Table(UnitValue.createPercentArray(1)).useAllAvailableWidth().setBorder(new SolidBorder(ColorConstants.ORANGE, 2)).addCell("Is my occupied area correct?")); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -180,10 +179,10 @@ public void flushingLargeTableAfterStartingNewRowTest() throws IOException, Inte table.addCell(new Cell().add(new Paragraph("Hello"))); table.addCell(new Cell().add(new Paragraph("World"))); table.startNewRow(); - Assert.assertThrows(NullPointerException.class, () -> table.flush()); + Assertions.assertThrows(NullPointerException.class, () -> table.flush()); table.complete(); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -215,7 +214,7 @@ public void largeTableWithCollapsedFooterTest() throws IOException, InterruptedE table.complete(); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -247,7 +246,7 @@ public void largeTableWithHeaderFooterTest01A() throws IOException, InterruptedE doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -282,7 +281,7 @@ public void largeTableWithHeaderFooterTest01ASeparated() throws IOException, Int doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @@ -318,7 +317,7 @@ public void largeTableWithHeaderFooterTest01B() throws IOException, InterruptedE doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -342,11 +341,11 @@ public void largeTableWithHeaderFooterTest01C() throws IOException, InterruptedE table.complete(); doc.add(new Table(UnitValue.createPercentArray(1)).useAllAvailableWidth().setBorder(new SolidBorder(ColorConstants.ORANGE, 2)).addCell("Is my occupied area correct?")); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test - @Ignore("DEVSIX-1778") + @Disabled("DEVSIX-1778") public void largeTableWithHeaderFooterTest01CForcedPlacement() throws IOException, InterruptedException { String testName = "largeTableWithHeaderFooterTest01CForcedPlacement.pdf"; String outFileName = destinationFolder + testName; @@ -389,7 +388,7 @@ public void largeTableWithHeaderFooterTest01CForcedPlacement() throws IOExceptio doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -414,7 +413,7 @@ public void largeTableWithHeaderFooterTest01D() throws IOException, InterruptedE table.complete(); doc.add(new Table(UnitValue.createPercentArray(1)).useAllAvailableWidth().setBorder(new SolidBorder(ColorConstants.ORANGE, 2)).addCell("Is my occupied area correct?")); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -440,7 +439,7 @@ public void largeTableWithHeaderFooterTest01DSeparated() throws IOException, Int table.complete(); doc.add(new Table(UnitValue.createPercentArray(1)).useAllAvailableWidth().setBorder(new SolidBorder(ColorConstants.ORANGE, 2)).addCell("Is my occupied area correct?")); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -476,7 +475,7 @@ public void largeTableWithHeaderFooterTest01E() throws IOException, InterruptedE doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -515,7 +514,7 @@ public void largeTableWithHeaderFooterTest01ESeparated() throws IOException, Int doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -549,7 +548,7 @@ public void largeTableWithHeaderFooterTest02() throws IOException, InterruptedEx doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -583,7 +582,7 @@ public void largeTableWithHeaderFooterTest03() throws IOException, InterruptedEx doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -614,7 +613,7 @@ public void largeTableWithHeaderFooterTest04() throws IOException, InterruptedEx doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -651,7 +650,7 @@ public void largeTableWithLayoutResultNothingTest01() throws IOException, Interr table.complete(); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -686,7 +685,7 @@ public void tableWithLayoutResultNothingTest01() throws IOException, Interrupted doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @@ -719,7 +718,7 @@ public void largeTableWithLayoutResultNothingTest02() throws IOException, Interr table.complete(); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -750,7 +749,7 @@ public void largeTableWithLayoutResultNothingTest03() throws IOException, Interr table.complete(); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } private static class DifferentPagesDocumentRenderer extends DocumentRenderer { @@ -793,7 +792,7 @@ public void largeTableSplitTest01() throws IOException, InterruptedException { String outFileName = destinationFolder + testName; String cmpFileName = sourceFolder + "cmp_" + testName; largeTableSplitTest(outFileName, 100, 1, false, false); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -802,7 +801,7 @@ public void largeTableSplitSeparateTest() throws IOException, InterruptedExcepti String outFileName = destinationFolder + testName; String cmpFileName = sourceFolder + "cmp_" + testName; largeTableSplitTest(outFileName, 100, 1, false, true); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -811,7 +810,7 @@ public void largeTableSplitFooterTest() throws IOException, InterruptedException String outFileName = destinationFolder + testName; String cmpFileName = sourceFolder + "cmp_" + testName; largeTableSplitTest(outFileName, 280, 6, true, false); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } private void largeTableSplitTest(String outFileName, float pageHeight, float rowsNumber, boolean addFooter, boolean separate) throws IOException { @@ -876,7 +875,7 @@ public void largeTableWithTableBorderSplitTest() throws IOException, Interrupted table.complete(); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } @Test @@ -901,7 +900,7 @@ public void largeTableWithTableBorderSplitTest02() throws IOException, Interrupt table.complete(); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } @Test @@ -936,7 +935,7 @@ public void largeTableWithCellBordersSplitTest1() throws IOException, Interrupte table.complete(); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } @Test @@ -968,7 +967,7 @@ public void largeTableWithCellBordersSplitTest() throws IOException, Interrupted table.complete(); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } @Test @@ -995,7 +994,7 @@ public void largeTableWithCellBordersSplitTest02() throws IOException, Interrupt table.flush(); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } @Test @@ -1021,7 +1020,7 @@ public void simpleLargeTableDifferentCellBottomBorderTest() throws IOException, table.complete(); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } @Test @@ -1049,7 +1048,7 @@ public void largeTableSplitFooter2Test() throws IOException, InterruptedExceptio table.complete(); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } @Test @@ -1078,7 +1077,7 @@ public void largeTableSplitFooter2ATest() throws IOException, InterruptedExcepti table.complete(); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } @Test @@ -1104,7 +1103,7 @@ public void largeTableSplitFooter2BTest() throws IOException, InterruptedExcepti doc.add(new AreaBreak()); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } @Test @@ -1128,7 +1127,7 @@ public void largeTableCollapsingSplitTest() throws IOException, InterruptedExcep table.complete(); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } @Test @@ -1161,7 +1160,7 @@ public void largeTableOnDifferentPages01() throws IOException, InterruptedExcept table.complete(); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -1191,7 +1190,7 @@ public void tableOnDifferentPages01() throws IOException, InterruptedException { doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -1223,7 +1222,7 @@ public void largeTableOnDifferentPages01A() throws IOException, InterruptedExcep table.complete(); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -1253,7 +1252,7 @@ public void tableOnDifferentPages02() throws IOException, InterruptedException { doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -1294,7 +1293,7 @@ public void reuseLargeTableTest01() throws IOException, InterruptedException { try { for (int i = 0; i < 25; i++) { table.addCell(new Cell().add(new Paragraph("Cell#" + (i * 4 + 0)))); - Assert.assertTrue("The line above should have thrown an exception.", false); + Assertions.assertTrue(false, "The line above should have thrown an exception."); table.addCell(new Cell().add(new Paragraph("Cell#" + (i * 4 + 1)))); table.addCell(new Cell().add(new Paragraph("Cell#" + (i * 4 + 2)))); table.addCell(new Cell().add(new Paragraph("Cell#" + (i * 4 + 3)))); @@ -1307,7 +1306,7 @@ public void reuseLargeTableTest01() throws IOException, InterruptedException { } doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -1323,7 +1322,7 @@ public void largeEmptyTableTest() throws IOException, InterruptedException { table.complete(); doc.add(new Table(UnitValue.createPercentArray(1)).useAllAvailableWidth().setBorder(new SolidBorder(ColorConstants.ORANGE, 2)).addCell("Is my occupied area correct?")); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -1397,7 +1396,7 @@ public void largeEmptyTableTest02() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -1472,7 +1471,7 @@ public void largeEmptyTableTest02Separated() throws IOException, InterruptedExce doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -1499,7 +1498,7 @@ public void largeTableFooterNotFitTest() throws IOException, InterruptedExceptio table.complete(); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } private static void addSpecificTableConsideringFlushes(Document doc, boolean flushFirst, boolean flushSecond) { diff --git a/layout/src/test/java/com/itextpdf/layout/LayoutTaggingPdf2Test.java b/layout/src/test/java/com/itextpdf/layout/LayoutTaggingPdf2Test.java index dc1f38d751..fc2ce4abe6 100644 --- a/layout/src/test/java/com/itextpdf/layout/LayoutTaggingPdf2Test.java +++ b/layout/src/test/java/com/itextpdf/layout/LayoutTaggingPdf2Test.java @@ -52,26 +52,25 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; import java.net.MalformedURLException; import java.text.MessageFormat; import javax.xml.parsers.ParserConfigurationException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import org.xml.sax.SAXException; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class LayoutTaggingPdf2Test extends ExtendedITextTest { public static final String destinationFolder = "./target/test/com/itextpdf/layout/LayoutTaggingPdf2Test/"; public static final String imageName = "Desert.jpg"; public static final String sourceFolder = "./src/test/resources/com/itextpdf/layout/LayoutTaggingPdf2Test/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } @@ -319,10 +318,10 @@ public void docWithInvalidMapping01() throws IOException { customRolePara.getAccessibilityProperties().setRole(HtmlRoles.p); customRolePara.getAccessibilityProperties().setNamespace(explicitDefaultNs); - Exception e = Assert.assertThrows(PdfException.class, + Exception e = Assertions.assertThrows(PdfException.class, () -> document.add(customRolePara) ); - Assert.assertEquals(MessageFormat.format(LayoutExceptionMessageConstant.ROLE_IN_NAMESPACE_IS_NOT_MAPPED_TO_ANY_STANDARD_ROLE, + Assertions.assertEquals(MessageFormat.format(LayoutExceptionMessageConstant.ROLE_IN_NAMESPACE_IS_NOT_MAPPED_TO_ANY_STANDARD_ROLE, "p", "http://iso.org/pdf/ssn"), e.getMessage()); } } @@ -343,10 +342,10 @@ public void docWithInvalidMapping02() throws IOException { Paragraph customRolePara = new Paragraph("Hello world text."); customRolePara.getAccessibilityProperties().setRole(HtmlRoles.p); - Exception e = Assert.assertThrows(PdfException.class, + Exception e = Assertions.assertThrows(PdfException.class, () -> document.add(customRolePara) ); - Assert.assertEquals(MessageFormat.format(LayoutExceptionMessageConstant.ROLE_IS_NOT_MAPPED_TO_ANY_STANDARD_ROLE, "p"), + Assertions.assertEquals(MessageFormat.format(LayoutExceptionMessageConstant.ROLE_IS_NOT_MAPPED_TO_ANY_STANDARD_ROLE, "p"), e.getMessage()); } } @@ -362,8 +361,8 @@ public void docWithInvalidMapping03() throws IOException { Paragraph customRolePara = new Paragraph("Hello world text."); customRolePara.getAccessibilityProperties().setRole(HtmlRoles.p); - Exception e = Assert.assertThrows(PdfException.class, () -> document.add(customRolePara)); - Assert.assertEquals(MessageFormat.format(LayoutExceptionMessageConstant.ROLE_IN_NAMESPACE_IS_NOT_MAPPED_TO_ANY_STANDARD_ROLE, + Exception e = Assertions.assertThrows(PdfException.class, () -> document.add(customRolePara)); + Assertions.assertEquals(MessageFormat.format(LayoutExceptionMessageConstant.ROLE_IN_NAMESPACE_IS_NOT_MAPPED_TO_ANY_STANDARD_ROLE, "p", "http://iso.org/pdf2/ssn"), e.getMessage()); } } @@ -415,8 +414,8 @@ public void docWithInvalidMapping05() throws IOException { customRolePara2.getAccessibilityProperties().setRole(HtmlRoles.p); // not explicitly setting namespace that we've manually created. This will lead to the situation, when // /Namespaces entry in StructTreeRoot would have two different namespace dictionaries with the same name. - Exception e = Assert.assertThrows(PdfException.class, () -> document.add(customRolePara2)); - Assert.assertEquals(MessageFormat.format(LayoutExceptionMessageConstant.ROLE_IN_NAMESPACE_IS_NOT_MAPPED_TO_ANY_STANDARD_ROLE, + Exception e = Assertions.assertThrows(PdfException.class, () -> document.add(customRolePara2)); + Assertions.assertEquals(MessageFormat.format(LayoutExceptionMessageConstant.ROLE_IN_NAMESPACE_IS_NOT_MAPPED_TO_ANY_STANDARD_ROLE, "p", "http://iso.org/pdf2/ssn"), e.getMessage()); } } @@ -478,8 +477,8 @@ public void docWithInvalidMapping07() throws IOException { customRolePText1.getAccessibilityProperties().setRole(HtmlRoles.span); customRolePText1.getAccessibilityProperties().setNamespace(stdNs2); - Exception e = Assert.assertThrows(PdfException.class, () -> document.add(new Paragraph(customRolePText1))); - Assert.assertEquals(MessageFormat.format(LayoutExceptionMessageConstant.ROLE_IN_NAMESPACE_IS_NOT_MAPPED_TO_ANY_STANDARD_ROLE, + Exception e = Assertions.assertThrows(PdfException.class, () -> document.add(new Paragraph(customRolePText1))); + Assertions.assertEquals(MessageFormat.format(LayoutExceptionMessageConstant.ROLE_IN_NAMESPACE_IS_NOT_MAPPED_TO_ANY_STANDARD_ROLE, "span", "http://iso.org/pdf2/ssn"), e.getMessage()); } } @@ -495,8 +494,8 @@ public void docWithInvalidMapping08() throws IOException { Paragraph h9Para = new Paragraph("Header level 9"); h9Para.getAccessibilityProperties().setRole("H9"); - Exception e = Assert.assertThrows(PdfException.class, () -> document.add(h9Para)); - Assert.assertEquals(MessageFormat.format(LayoutExceptionMessageConstant.ROLE_IS_NOT_MAPPED_TO_ANY_STANDARD_ROLE, "H9"), e.getMessage()); + Exception e = Assertions.assertThrows(PdfException.class, () -> document.add(h9Para)); + Assertions.assertEquals(MessageFormat.format(LayoutExceptionMessageConstant.ROLE_IS_NOT_MAPPED_TO_ANY_STANDARD_ROLE, "H9"), e.getMessage()); } } @@ -750,7 +749,7 @@ private void addContentToDocInCustomNs(PdfDocument pdfDocument, PdfNamespace def if (defaultNamespace == null) { Text i = new Text("italic text"); i.getAccessibilityProperties().setRole("I"); - Paragraph pi = new Paragraph(i.setItalic()); + Paragraph pi = new Paragraph(i.simulateItalic()); document.add(pi); } } @@ -772,7 +771,7 @@ private void compareResult(String testName) errorMessage += taggedStructureDifferences == null ? "" : taggedStructureDifferences + "\n"; errorMessage += contentDifferences == null ? "" : contentDifferences; if (!errorMessage.isEmpty()) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } } diff --git a/layout/src/test/java/com/itextpdf/layout/LayoutTaggingTest.java b/layout/src/test/java/com/itextpdf/layout/LayoutTaggingTest.java index c0cdbb0117..a6cf9567a3 100644 --- a/layout/src/test/java/com/itextpdf/layout/LayoutTaggingTest.java +++ b/layout/src/test/java/com/itextpdf/layout/LayoutTaggingTest.java @@ -74,19 +74,18 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; import java.nio.charset.StandardCharsets; import javax.xml.parsers.ParserConfigurationException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import org.xml.sax.SAXException; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class LayoutTaggingTest extends ExtendedITextTest { public static final String destinationFolder = "./target/test/com/itextpdf/layout/LayoutTaggingTest/"; @@ -94,7 +93,7 @@ public class LayoutTaggingTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/layout/LayoutTaggingTest/"; public static final String fontsFolder = "./src/test/resources/com/itextpdf/layout/fonts/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } @@ -1044,7 +1043,7 @@ public void checkParentTreeIfFormXObjectTaggedTest() throws IOException, Interru pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpPdf, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpPdf, destinationFolder, "diff")); } @Test @@ -1291,7 +1290,7 @@ private IBlockElement createTable(boolean useCaption) { Div div = new Div(); div.getAccessibilityProperties().setRole(StandardRoles.TABLE); Paragraph p = new Paragraph("Caption").setNeutralRole(); - p.setTextAlignment(TextAlignment.CENTER).setBold(); + p.setTextAlignment(TextAlignment.CENTER).simulateBold(); Div caption = new Div().add(p); caption.getAccessibilityProperties().setRole(StandardRoles.CAPTION); div.add(caption); @@ -1316,7 +1315,7 @@ private void compareResult(String outFileName, String cmpFileName) errorMessage += taggedStructureDifferences == null ? "" : taggedStructureDifferences + "\n"; errorMessage += contentDifferences == null ? "" : contentDifferences; if (!errorMessage.isEmpty()) { - Assert.fail(errorMessage); + Assertions.fail(errorMessage); } } } diff --git a/layout/src/test/java/com/itextpdf/layout/LeadingHeightTest.java b/layout/src/test/java/com/itextpdf/layout/LeadingHeightTest.java index 8b4bb36cc9..f29ce7c286 100644 --- a/layout/src/test/java/com/itextpdf/layout/LeadingHeightTest.java +++ b/layout/src/test/java/com/itextpdf/layout/LeadingHeightTest.java @@ -44,15 +44,14 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class LeadingHeightTest extends ExtendedITextTest { public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/layout/LeadingHeightTest/"; @@ -63,7 +62,7 @@ public class LeadingHeightTest extends ExtendedITextTest { private static final int HEIGHT_EXACT_THAT_REQUIRED = 0; private static final int HEIGHT_MORE_THAN_REQUIRED = 100; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(DESTINATION_FOLDER); } @@ -87,7 +86,7 @@ public void clippedHeightParagraphTest() throws IOException, InterruptedExceptio addTable(doc, 50, "RETIREMENT PLANNING: BECAUSE YOU CAN’T BE A FINANCIAL PLANNER FOREVER.", HEIGHT_LESS_THAN_REQUIRED); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -110,7 +109,7 @@ public void paragraphTest() throws IOException, InterruptedException { doc.close(); //Partial text expected to be present in the document //There should be only "RETIREMENT PLANNING: BECAUSE YOU CAN’T BE A FINANCIAL" - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -139,7 +138,7 @@ public void pageHeightDivWithNestedParagraphTest() throws IOException, Interrupt doc.add(ph2); doc.close(); //Full text expected to be present on the first page - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } private void addTable(Document doc, int y, String text, int heightParam) diff --git a/layout/src/test/java/com/itextpdf/layout/LineSeparatorTest.java b/layout/src/test/java/com/itextpdf/layout/LineSeparatorTest.java index 7134b2e78a..386da36d7f 100644 --- a/layout/src/test/java/com/itextpdf/layout/LineSeparatorTest.java +++ b/layout/src/test/java/com/itextpdf/layout/LineSeparatorTest.java @@ -34,22 +34,21 @@ This file is part of the iText (R) project. import com.itextpdf.layout.properties.HorizontalAlignment; import com.itextpdf.layout.properties.UnitValue; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class LineSeparatorTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/layout/LineSeparatorTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/layout/LineSeparatorTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } @@ -69,7 +68,7 @@ public void lineSeparatorWidthPercentageTest01() throws IOException, Interrupted document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -88,7 +87,7 @@ public void lineSeparatorBackgroundTest01() throws IOException, InterruptedExcep document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @@ -103,7 +102,7 @@ public void rotatedLineSeparatorTest01() throws IOException, InterruptedExceptio document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -120,7 +119,7 @@ public void rotatedLineSeparatorTest02() throws IOException, InterruptedExceptio document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } } diff --git a/layout/src/test/java/com/itextpdf/layout/LinkTest.java b/layout/src/test/java/com/itextpdf/layout/LinkTest.java index 8b22d2fb6a..ce0c275bc2 100644 --- a/layout/src/test/java/com/itextpdf/layout/LinkTest.java +++ b/layout/src/test/java/com/itextpdf/layout/LinkTest.java @@ -53,16 +53,15 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.FileOutputStream; import java.io.IOException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class LinkTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/layout/LinkTest/"; @@ -75,7 +74,7 @@ public class LinkTest extends ExtendedITextTest { + "Donec fringilla sapien sed neque finibus, non luctus justo lobortis. Praesent commodo pellentesque ligula, vel fringilla odio commodo id. Nam ultrices justo a dignissim congue. Nullam imperdiet sem eget placerat aliquam. Suspendisse non faucibus libero. Aenean purus arcu, auctor vitae tincidunt in, tincidunt at ante. Pellentesque euismod, velit vel vulputate faucibus, dolor erat consectetur sapien, ut elementum dui turpis nec lacus. In hac habitasse platea dictumst. Aenean vel elit ultrices, varius mi quis, congue erat." + "Curabitur sit amet nunc porttitor, congue elit vestibulum, vestibulum sapien. Fusce ut arcu consequat, scelerisque sapien vitae, dignissim ligula. Duis gravida mollis volutpat. Maecenas condimentum pulvinar urna in cursus. Nulla ornare est non tellus elementum auctor. Mauris ornare, elit non ornare lobortis, risus augue consectetur orci, ac efficitur ex nunc nec leo. Aenean dictum mattis magna vitae bibendum."; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } @@ -95,7 +94,7 @@ public void linkTest01() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -115,7 +114,7 @@ public void linkTest02() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -142,7 +141,7 @@ public void linkTest03() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -159,7 +158,7 @@ public void borderedLinkTest() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } /** @@ -187,7 +186,7 @@ public void testCreateLocalLinkInRotatedCell() throws IOException, InterruptedEx document.add(table); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -204,7 +203,7 @@ public void rotatedLinkAtFixedPosition() throws IOException, InterruptedExceptio doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -224,7 +223,7 @@ public void rotatedLinkInnerRotation() throws IOException, InterruptedException doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @@ -245,7 +244,7 @@ public void simpleMarginsTest01() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -267,7 +266,7 @@ public void multiLineLinkTest01() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -297,7 +296,7 @@ public void tableHeaderLinkTest01() throws IOException, InterruptedException { doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -326,7 +325,7 @@ public void linkWithCustomRectangleTest01() throws IOException, InterruptedExcep doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } @Test @@ -349,7 +348,7 @@ public void splitLinkTest01() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } @Test @@ -372,7 +371,7 @@ public void linkAnnotationOnDivSplitTest01() throws IOException, InterruptedExce doc.add(div); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } @Test @@ -394,7 +393,7 @@ public void linkActionOnDivSplitTest01() throws IOException, InterruptedExceptio doc.add(div); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } @Test @@ -426,7 +425,7 @@ public void intraForwardLinkTest() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -460,6 +459,6 @@ public void intraBackwardLinkTest() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } } diff --git a/layout/src/test/java/com/itextpdf/layout/ListAlignmentDirectionTest.java b/layout/src/test/java/com/itextpdf/layout/ListAlignmentDirectionTest.java index ced9f877cf..0d8e1baebf 100644 --- a/layout/src/test/java/com/itextpdf/layout/ListAlignmentDirectionTest.java +++ b/layout/src/test/java/com/itextpdf/layout/ListAlignmentDirectionTest.java @@ -38,21 +38,18 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; import java.io.OutputStream; import java.nio.charset.StandardCharsets; import java.util.ArrayList; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; - -@RunWith(Parameterized.class) -@Category(IntegrationTest.class) +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +@Tag("IntegrationTest") public class ListAlignmentDirectionTest extends ExtendedITextTest { public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/layout/ListAlignmentDirectionTest/"; public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/layout/ListAlignmentDirectionTest/"; @@ -68,25 +65,11 @@ public class ListAlignmentDirectionTest extends ExtendedITextTest { + "
  • Specific line
  • " + ""; - private TextAlignment itemTextAlignment; - private BaseDirection itemBaseDirection; - private TextAlignment listTextAlignment; - private BaseDirection listBaseDirection; - - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(DESTINATION_FOLDER); } - public ListAlignmentDirectionTest(Object itemTextAlignment, Object itemBaseDirection, - Object listTextAlignment, Object listBaseDirection) throws IOException { - this.itemTextAlignment = (TextAlignment) itemTextAlignment; - this.itemBaseDirection = (BaseDirection) itemBaseDirection; - this.listTextAlignment = (TextAlignment) listTextAlignment; - this.listBaseDirection = (BaseDirection) listBaseDirection; - } - - @Parameterized.Parameters(name = PARAMETERS_NAME_PATTERN) public static Iterable alignItemsAndJustifyContentProperties() { TextAlignment[] alignmentTestValues = new TextAlignment[] {TextAlignment.LEFT, TextAlignment.CENTER, TextAlignment.RIGHT, TextAlignment.JUSTIFIED, TextAlignment.JUSTIFIED_ALL}; @@ -105,13 +88,15 @@ public static Iterable alignItemsAndJustifyContentProperties() { return objectList; } - @Test + @ParameterizedTest(name = PARAMETERS_NAME_PATTERN) + @MethodSource("alignItemsAndJustifyContentProperties") @LogMessages(messages = @LogMessage(messageTemplate = IoLogMessageConstant.TYPOGRAPHY_NOT_FOUND, count = 8)) // TODO DEVSIX-5727 direction of the first list-item should define the symbol indent's side. Once the issue // is fixed, the corresponding cmps should be updated. - public void alignmentDirectionTest() throws Exception { + public void alignmentDirectionTest(TextAlignment itemTextAlignment, BaseDirection itemBaseDirection, TextAlignment listTextAlignment, + BaseDirection listBaseDirection) throws Exception { // Create an HTML for this test - createHtml(); + createHtml(itemTextAlignment, itemBaseDirection, listTextAlignment, listBaseDirection); String fileName = MessageFormatUtil.format( RESULTANT_FILE_NAME_PATTERN, formatTextAlignment(itemTextAlignment), @@ -135,7 +120,7 @@ public void alignmentDirectionTest() throws Exception { document.close(); System.out.println("HTML: " + UrlUtil.getNormalizedFileUriString(DESTINATION_FOLDER + fileName + ".html") + "\n"); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff_")); } private static List createTestList(Style secondItemStyle) { @@ -160,7 +145,8 @@ private static List createTestList(Style secondItemStyle) { return list; } - private void createHtml() throws IOException { + private void createHtml(TextAlignment itemTextAlignment, BaseDirection itemBaseDirection, TextAlignment listTextAlignment, + BaseDirection listBaseDirection) throws IOException { String fileName = MessageFormatUtil.format( RESULTANT_FILE_NAME_PATTERN, formatTextAlignment(itemTextAlignment), @@ -198,7 +184,7 @@ private static String formatTextAlignment(TextAlignment alignment, boolean isHtm case JUSTIFIED_ALL: return isHtml ? "justify" : "justify-all"; default: - Assert.fail("Unexpected text alignment"); + Assertions.fail("Unexpected text alignment"); return null; } } @@ -210,7 +196,7 @@ private static String formatBaseDirection(BaseDirection direction) { case RIGHT_TO_LEFT: return "rtl"; default: - Assert.fail("Unexpected base direction"); + Assertions.fail("Unexpected base direction"); return null; } } diff --git a/layout/src/test/java/com/itextpdf/layout/ListItemPositionAlignmentTest.java b/layout/src/test/java/com/itextpdf/layout/ListItemPositionAlignmentTest.java index bd86156e7b..6174d5e2f9 100644 --- a/layout/src/test/java/com/itextpdf/layout/ListItemPositionAlignmentTest.java +++ b/layout/src/test/java/com/itextpdf/layout/ListItemPositionAlignmentTest.java @@ -40,21 +40,18 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; import java.io.OutputStream; import java.nio.charset.StandardCharsets; import java.util.ArrayList; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; - -@RunWith(Parameterized.class) -@Category(IntegrationTest.class) +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +@Tag("IntegrationTest") public class ListItemPositionAlignmentTest extends ExtendedITextTest { public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/layout/ListItemPositionAlignmentTest/"; @@ -71,27 +68,11 @@ public class ListItemPositionAlignmentTest extends ExtendedITextTest { + "
  • Specific item
  • " + ""; - private BaseDirection listBaseDirection; - private BaseDirection listItemBaseDirection; - private ListSymbolAlignment listSymbolAlignment; - private ListSymbolPosition listSymbolPosition; - private Integer comparisonPdfId; - - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(DESTINATION_FOLDER); } - public ListItemPositionAlignmentTest(Object listBaseDirection, Object listItemBaseDirection, - Object listSymbolAlignment, Object listSymbolPosition, Object comparisonPdfId) throws IOException { - this.listBaseDirection = (BaseDirection) listBaseDirection; - this.listItemBaseDirection = (BaseDirection) listItemBaseDirection; - this.listSymbolAlignment = (ListSymbolAlignment) listSymbolAlignment; - this.listSymbolPosition = (ListSymbolPosition) listSymbolPosition; - this.comparisonPdfId = (Integer) comparisonPdfId; - } - - @Parameterized.Parameters(name = PARAMETERS_NAME_PATTERN) public static Iterable baseDirectionAndSymbolAlignmentProperties() { BaseDirection[] directionTestValues = new BaseDirection[]{BaseDirection.LEFT_TO_RIGHT, BaseDirection.RIGHT_TO_LEFT}; @@ -114,11 +95,14 @@ public static Iterable baseDirectionAndSymbolAlignmentProperties() { return objectList; } - @Test + @ParameterizedTest(name = PARAMETERS_NAME_PATTERN) + @MethodSource("baseDirectionAndSymbolAlignmentProperties") @LogMessages(messages = {@LogMessage(messageTemplate = IoLogMessageConstant.TYPOGRAPHY_NOT_FOUND, count = 8)}) - public void defaultListIemPositionAlignmentTest() throws IOException, InterruptedException { + public void defaultListIemPositionAlignmentTest(BaseDirection listBaseDirection, BaseDirection listItemBaseDirection, + ListSymbolAlignment listSymbolAlignment, ListSymbolPosition listSymbolPosition, Integer comparisonPdfId) + throws IOException, InterruptedException { // Create an HTML for this test - createHtml(); + createHtml(listBaseDirection, listItemBaseDirection, listSymbolAlignment, listSymbolPosition); String fileName = MessageFormatUtil.format( RESULTANT_FILE_NAME_PATTERN, formatSymbolPosition(listSymbolPosition), @@ -131,16 +115,17 @@ public void defaultListIemPositionAlignmentTest() throws IOException, Interrupte PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); Document document = new Document(pdfDocument); - List list = createTestList(); + List list = createTestList(listBaseDirection, listItemBaseDirection, listSymbolAlignment, listSymbolPosition); document.add(list); document.close(); System.out.println("HTML: " + UrlUtil.getNormalizedFileUriString(DESTINATION_FOLDER + fileName + ".html") + "\n"); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } - private List createTestList() { + private List createTestList(BaseDirection listBaseDirection, BaseDirection listItemBaseDirection, + ListSymbolAlignment listSymbolAlignment, ListSymbolPosition listSymbolPosition) { List list = new List(); list.setSymbolIndent(20); list.setListSymbol("\u2022"); @@ -163,7 +148,8 @@ private List createTestList() { return list; } - private void createHtml() throws IOException { + private void createHtml(BaseDirection listBaseDirection, BaseDirection listItemBaseDirection, + ListSymbolAlignment listSymbolAlignment, ListSymbolPosition listSymbolPosition) throws IOException { String fileName = MessageFormatUtil.format( RESULTANT_FILE_NAME_PATTERN, formatSymbolPosition(listSymbolPosition), @@ -191,7 +177,7 @@ private static String formatBaseDirection(BaseDirection direction) { case RIGHT_TO_LEFT: return "rtl"; default: - Assert.fail("Unexpected base direction"); + Assertions.fail("Unexpected base direction"); return null; } } @@ -203,7 +189,7 @@ private static String formatSymbolAlignment(ListSymbolAlignment alignment) { case RIGHT: return "right"; default: - Assert.fail("Unexpected symbol alignment"); + Assertions.fail("Unexpected symbol alignment"); return null; } } @@ -215,7 +201,7 @@ private static String formatSymbolPosition(ListSymbolPosition position) { case INSIDE: return "inside"; default: - Assert.fail("Unexpected symbol position"); + Assertions.fail("Unexpected symbol position"); return null; } } diff --git a/layout/src/test/java/com/itextpdf/layout/ListTest.java b/layout/src/test/java/com/itextpdf/layout/ListTest.java index 9e6332e66f..26b1309506 100644 --- a/layout/src/test/java/com/itextpdf/layout/ListTest.java +++ b/layout/src/test/java/com/itextpdf/layout/ListTest.java @@ -53,22 +53,21 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; import java.util.ArrayList; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class ListTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/layout/ListTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/layout/ListTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } @@ -96,7 +95,7 @@ public void nestedListTest01() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -117,7 +116,7 @@ public void nestedListTest02() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -140,7 +139,7 @@ public void listNestedInTableTest01() throws IOException, InterruptedException { document.add(table); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -172,7 +171,7 @@ public void listNumberingTest01() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -208,7 +207,7 @@ public void addListOnShortPage1() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -245,7 +244,7 @@ public void addListOnShortPage2() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -261,7 +260,7 @@ public void divInListItemTest01() throws IOException, InterruptedException { document.add(new List().add(item)); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -287,7 +286,7 @@ public void listOverflowTest01() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -313,7 +312,7 @@ public void listOverflowTest02() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -340,7 +339,7 @@ public void listOverflowTest03() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -358,7 +357,7 @@ public void listEmptyItemTest01() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -378,7 +377,7 @@ public void imageInListTest01() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -399,7 +398,7 @@ public void listItemAlignmentTest01() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -416,7 +415,7 @@ public void listItemTest01() throws IOException, InterruptedException { document.add(list); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -439,7 +438,7 @@ public void listItemTest02() throws IOException, InterruptedException { document.add(list); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -458,7 +457,7 @@ public void listItemWithoutMarginsTest() throws IOException, InterruptedExceptio document.add(list); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -478,7 +477,7 @@ public void listItemBigMarginsTest() throws IOException, InterruptedException { document.add(list); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -498,7 +497,7 @@ public void maxMarginWidthWhereTheBulletIsNotDrawnTest() throws IOException, Int list.setFixedPosition((float) marginLeft, 780, 200); document.add(list); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -519,7 +518,7 @@ public void initialMarginWidthWhereTheBulletIsDrawnTest() throws IOException, In document.add(list); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @LogMessages(messages = { @@ -610,21 +609,21 @@ public void listWithSetHeightProperties01() throws IOException, InterruptedExcep doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test public void listSetSymbol() { List list = new List(); - Assert.assertNull(list.getProperty(Property.LIST_SYMBOL)); + Assertions.assertNull(list.getProperty(Property.LIST_SYMBOL)); list.setListSymbol("* "); - Assert.assertEquals("* ", ((Text) list.getProperty(Property.LIST_SYMBOL)).getText()); + Assertions.assertEquals("* ", ((Text) list.getProperty(Property.LIST_SYMBOL)).getText()); list = new List(); Style style = new Style(); style.setProperty(Property.LIST_SYMBOL, new Text("* ")); list.addStyle(style); - Assert.assertEquals("* ", ((Text) list.getProperty(Property.LIST_SYMBOL)).getText()); + Assertions.assertEquals("* ", ((Text) list.getProperty(Property.LIST_SYMBOL)).getText()); } @Test @@ -650,7 +649,7 @@ public void listItemNullSymbol() throws Exception { doc.add(list); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff_")); } @Test @@ -675,7 +674,7 @@ public void listSymbolForcedPlacement01() throws Exception { document.close(); // TODO DEVSIX-1655: partially not fitting list symbol not shown at all, however this might be improved - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff_")); } @Test @@ -699,7 +698,7 @@ public void bothSymbolIndentAndMarginAreSetTest() throws Exception { document.add(l); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff_")); } @Test @@ -720,7 +719,7 @@ public void listItemMarginInPercentTest() throws Exception { document.add(l); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff_")); } @Test @@ -748,7 +747,7 @@ public void listItemWithImageSymbolPositionTest() throws IOException, Interrupte document.add(l); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff_")); } // TODO DEVSIX-6877 wrapping list item content in a div causes the bullet to be misaligned @@ -772,7 +771,7 @@ public void listItemWrappedDivSymbolInside() throws IOException, InterruptedExce document.add(l); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff_")); } private static List createTestList() { diff --git a/layout/src/test/java/com/itextpdf/layout/LocationTextExtractionStrategyTest.java b/layout/src/test/java/com/itextpdf/layout/LocationTextExtractionStrategyTest.java index 463c894d41..e5434845be 100644 --- a/layout/src/test/java/com/itextpdf/layout/LocationTextExtractionStrategyTest.java +++ b/layout/src/test/java/com/itextpdf/layout/LocationTextExtractionStrategyTest.java @@ -48,19 +48,18 @@ This file is part of the iText (R) project. import com.itextpdf.layout.element.Paragraph; import com.itextpdf.layout.element.Text; import com.itextpdf.layout.properties.TextAlignment; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.nio.file.Files; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.nio.charset.StandardCharsets; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class LocationTextExtractionStrategyTest extends SimpleTextExtractionStrategyTest { private static final String sourceFolder = "./src/test/resources/com/itextpdf/layout/LocationTextExtractionStrategyTest/"; @@ -76,7 +75,7 @@ public void testYPosition() throws Exception { String text = PdfTextExtractor.getTextFromPage(doc.getPage(1), createRenderListenerForTest()); - Assert.assertEquals("A\nAA\nB\nBB\nC\nCC\nD\nDD", text); + Assertions.assertEquals("A\nAA\nB\nBB\nC\nCC\nD\nDD", text); } @Test @@ -88,8 +87,8 @@ public void testXPosition() throws Exception { String text = PdfTextExtractor.getTextFromPage(pdfDocument.getPage(1), createRenderListenerForTest()); - Assert.assertEquals("A AA B BB C CC D DD", text); -// Assert.assertEquals("A\tAA\tB\tBB\tC\tCC\tD\tDD", text); + Assertions.assertEquals("A AA B BB C CC D DD", text); +// Assertions.assertEquals("A\tAA\tB\tBB\tC\tCC\tD\tDD", text); } @Test @@ -100,7 +99,7 @@ public void testRotatedPage() throws Exception { String text = PdfTextExtractor.getTextFromPage(pdfDocument.getPage(1), createRenderListenerForTest()); - Assert.assertEquals("A \nB \nC \nD", text); + Assertions.assertEquals("A \nB \nC \nD", text); } @Test @@ -112,7 +111,7 @@ public void testRotatedPage2() throws Exception { String text = PdfTextExtractor.getTextFromPage(pdfDocument.getPage(1), createRenderListenerForTest()); - Assert.assertEquals("A \nB \nC \nD", text); + Assertions.assertEquals("A \nB \nC \nD", text); } @Test @@ -124,7 +123,7 @@ public void testRotatedPage3() throws Exception { String text = PdfTextExtractor.getTextFromPage(pdfDocument.getPage(1), createRenderListenerForTest()); - Assert.assertEquals("A \nB \nC \nD", text); + Assertions.assertEquals("A \nB \nC \nD", text); } @Test @@ -136,7 +135,7 @@ public void testExtractXObjectTextWithRotation() throws Exception { PdfDocument pdfDocument = new PdfDocument(new PdfReader(new ByteArrayInputStream(content))); String text = PdfTextExtractor.getTextFromPage(pdfDocument.getPage(1), createRenderListenerForTest()); - Assert.assertEquals("A\nB\nX\nC", text); + Assertions.assertEquals("A\nB\nX\nC", text); } @Test @@ -145,7 +144,7 @@ public void testNegativeCharacterSpacing() throws Exception { //TestResourceUtils.openBytesAsPdf(content); PdfDocument pdfDocument = new PdfDocument(new PdfReader(new ByteArrayInputStream(content))); String text = PdfTextExtractor.getTextFromPage(pdfDocument.getPage(1), createRenderListenerForTest()); - Assert.assertEquals("WA", text); + Assertions.assertEquals("WA", text); } @Test @@ -156,10 +155,10 @@ public void testSanityCheckOnVectorMath() { Vector parallelStart = new Vector(1.1f, 0, 1); float rsltAntiParallel = antiparallelStart.subtract(end).dot(end.subtract(start).normalize()); - Assert.assertEquals(-0.1f, rsltAntiParallel, 0.0001); + Assertions.assertEquals(-0.1f, rsltAntiParallel, 0.0001); float rsltParallel = parallelStart.subtract(end).dot(end.subtract(start).normalize()); - Assert.assertEquals(0.1f, rsltParallel, 0.0001); + Assertions.assertEquals(0.1f, rsltParallel, 0.0001); } @@ -169,7 +168,7 @@ public void testSuperscript() throws Exception { //TestResourceUtils.openBytesAsPdf(content); PdfDocument pdfDocument = new PdfDocument(new PdfReader(new ByteArrayInputStream(content))); String text = PdfTextExtractor.getTextFromPage(pdfDocument.getPage(1), createRenderListenerForTest()); - Assert.assertEquals("Hello", text); + Assertions.assertEquals("Hello", text); } @Test @@ -183,7 +182,7 @@ public void test01() throws IOException { "Great Place to Work Institute of San Francisco to evaluate \n" + "trust in management, pride in work/company, and \n" + "camaraderie. Responses were returned directly to us. "; - Assert.assertEquals(expectedText, text); + Assertions.assertEquals(expectedText, text); } @Test @@ -192,7 +191,7 @@ public void testFontSpacingEqualsCharSpacing() throws Exception { PdfDocument pdfDocument = new PdfDocument(new PdfReader(new ByteArrayInputStream(content))); String text = PdfTextExtractor.getTextFromPage(pdfDocument.getPage(1), createRenderListenerForTest()); - Assert.assertEquals("Preface", text); + Assertions.assertEquals("Preface", text); } @Test @@ -201,7 +200,7 @@ public void testLittleFontSize() throws Exception { PdfDocument pdfDocument = new PdfDocument(new PdfReader(new ByteArrayInputStream(content))); String text = PdfTextExtractor.getTextFromPage(pdfDocument.getPage(1), createRenderListenerForTest()); - Assert.assertEquals("Preface", text); + Assertions.assertEquals("Preface", text); } @Test @@ -218,14 +217,14 @@ public void testType3FontWithDifferences() throws IOException { byte[] bytes = Files.readAllBytes(java.nio.file.Paths.get(comparedTextFile)); - Assert.assertEquals(new String(bytes, StandardCharsets.UTF_8), result); - Assert.assertEquals(177, pdfType3Font.getNumberOfGlyphs()); + Assertions.assertEquals(new String(bytes, StandardCharsets.UTF_8), result); + Assertions.assertEquals(177, pdfType3Font.getNumberOfGlyphs()); - Assert.assertEquals("gA", pdfType3Font.getFontEncoding().getDifference(10)); - Assert.assertEquals(41, pdfType3Font.getFontProgram().getGlyphByCode(10).getUnicode()); + Assertions.assertEquals("gA", pdfType3Font.getFontEncoding().getDifference(10)); + Assertions.assertEquals(41, pdfType3Font.getFontProgram().getGlyphByCode(10).getUnicode()); - Assert.assertEquals(".notdef", pdfType3Font.getFontEncoding().getDifference(210)); - Assert.assertEquals(928, pdfType3Font.getFontProgram().getGlyphByCode(210).getUnicode()); + Assertions.assertEquals(".notdef", pdfType3Font.getFontEncoding().getDifference(210)); + Assertions.assertEquals(928, pdfType3Font.getFontProgram().getGlyphByCode(210).getUnicode()); } } diff --git a/layout/src/test/java/com/itextpdf/layout/NewLineTest.java b/layout/src/test/java/com/itextpdf/layout/NewLineTest.java index a45cfe7453..c913a43b03 100644 --- a/layout/src/test/java/com/itextpdf/layout/NewLineTest.java +++ b/layout/src/test/java/com/itextpdf/layout/NewLineTest.java @@ -29,21 +29,20 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.layout.element.Paragraph; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class NewLineTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/layout/NewLineTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/layout/NewLineTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } @@ -98,6 +97,6 @@ private void test(String newlineCharacters, String fileName) throws IOException, document.add(paragraph); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, diffPrefix)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, diffPrefix)); } } diff --git a/layout/src/test/java/com/itextpdf/layout/NonBreakableSpaceTest.java b/layout/src/test/java/com/itextpdf/layout/NonBreakableSpaceTest.java index 13a544b763..bc7f8f830b 100644 --- a/layout/src/test/java/com/itextpdf/layout/NonBreakableSpaceTest.java +++ b/layout/src/test/java/com/itextpdf/layout/NonBreakableSpaceTest.java @@ -29,21 +29,20 @@ This file is part of the iText (R) project. import com.itextpdf.layout.borders.SolidBorder; import com.itextpdf.layout.element.Paragraph; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class NonBreakableSpaceTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/layout/NonBreakableSpaceTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/layout/NonBreakableSpaceTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } @@ -60,7 +59,7 @@ public void simpleParagraphTest() throws IOException, InterruptedException { document.add(new Paragraph("aaaaaaa\u00a0bbbbbbbbbbb").setWidth(100).setBorder(new SolidBorder(ColorConstants.BLUE, 10))); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, diffPrefix)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, diffPrefix)); } @Test @@ -79,6 +78,6 @@ public void consecutiveSpacesTest() throws IOException, InterruptedException { document.add(p); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, diffPrefix)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, diffPrefix)); } } diff --git a/layout/src/test/java/com/itextpdf/layout/ObjectFitTest.java b/layout/src/test/java/com/itextpdf/layout/ObjectFitTest.java index 685dd48236..cc8119128c 100644 --- a/layout/src/test/java/com/itextpdf/layout/ObjectFitTest.java +++ b/layout/src/test/java/com/itextpdf/layout/ObjectFitTest.java @@ -37,21 +37,20 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class ObjectFitTest extends ExtendedITextTest { public static final String destinationFolder = "./target/test/com/itextpdf/layout/ObjectFitTest/"; public static final String sourceFolder = "./src/test/resources/com/itextpdf/layout/ObjectFitTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } @@ -64,7 +63,7 @@ public void fillObjectFitTest() throws IOException, InterruptedException { generateDocumentWithObjectFit(ObjectFit.FILL, outFileName); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -75,7 +74,7 @@ public void coverObjectFitTest() throws IOException, InterruptedException { generateDocumentWithObjectFit(ObjectFit.COVER, outFileName); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -86,7 +85,7 @@ public void containObjectFitTest() throws IOException, InterruptedException { generateDocumentWithObjectFit(ObjectFit.CONTAIN, outFileName); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -97,7 +96,7 @@ public void scaleDownObjectFitTest() throws IOException, InterruptedException { generateDocumentWithObjectFit(ObjectFit.SCALE_DOWN, outFileName); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -108,7 +107,7 @@ public void noneObjectFitTest() throws IOException, InterruptedException { generateDocumentWithObjectFit(ObjectFit.NONE, outFileName); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -132,7 +131,7 @@ public void scaleDownSmallImageObjectFitTest() throws IOException, InterruptedEx doc.add(p); } - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -163,7 +162,7 @@ public void twoCoverObjectsFitTest() throws IOException, InterruptedException { doc.add(p); } - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -190,7 +189,7 @@ public void containWithEffectsObjectsFitTest() throws IOException, InterruptedEx doc.add(p); } - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -221,7 +220,7 @@ public void containWithRotationObjectsFitTest() throws IOException, InterruptedE doc.add(p); } - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } private void generateDocumentWithObjectFit(ObjectFit objectFit, String outFileName) throws IOException { diff --git a/layout/src/test/java/com/itextpdf/layout/OpacityTest.java b/layout/src/test/java/com/itextpdf/layout/OpacityTest.java index b2505ae0c4..7f3c5b1f12 100644 --- a/layout/src/test/java/com/itextpdf/layout/OpacityTest.java +++ b/layout/src/test/java/com/itextpdf/layout/OpacityTest.java @@ -41,22 +41,21 @@ This file is part of the iText (R) project. import com.itextpdf.layout.element.Text; import com.itextpdf.layout.properties.UnitValue; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class OpacityTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/layout/OpacityTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/layout/OpacityTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } @@ -81,7 +80,7 @@ public void backgroundOpacityTest01() throws IOException, InterruptedException { document.add(div); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -113,7 +112,7 @@ public void backgroundOpacityTest02() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -136,7 +135,7 @@ public void borderOpacityTest01() throws IOException, InterruptedException { document.add(div); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -159,7 +158,7 @@ public void textOpacityTest01() throws IOException, InterruptedException { document.add(div); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -182,7 +181,7 @@ public void underlineOpacityTest01() throws IOException, InterruptedException { document.add(div); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -291,6 +290,6 @@ private void elementOpacityTest(String elem) throws IOException, InterruptedExce document.add(div); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } } diff --git a/layout/src/test/java/com/itextpdf/layout/OrphansWidowsTest.java b/layout/src/test/java/com/itextpdf/layout/OrphansWidowsTest.java index 8246b41043..b00d96dcda 100644 --- a/layout/src/test/java/com/itextpdf/layout/OrphansWidowsTest.java +++ b/layout/src/test/java/com/itextpdf/layout/OrphansWidowsTest.java @@ -41,23 +41,22 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.List; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class OrphansWidowsTest extends ExtendedITextTest { public static final String destinationFolder = "./target/test/com/itextpdf/layout/OrphansWidowsTest/"; public static final String sourceFolder = "./src/test/resources/com/itextpdf/layout/OrphansWidowsTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } @@ -150,23 +149,23 @@ public void multipleLayoutCallsProduceSameLayoutResult() { LayoutResult secondLayoutResult = paragraphRenderer.layout(layoutContext); // toString() comparison is used since it contains report on status, areaBreak and occupiedArea - Assert.assertEquals(firstLayoutResult.toString(), secondLayoutResult.toString()); + Assertions.assertEquals(firstLayoutResult.toString(), secondLayoutResult.toString()); ParagraphRenderer firstSplitRenderer = (ParagraphRenderer) firstLayoutResult.getSplitRenderer(); ParagraphRenderer secondSplitRenderer = (ParagraphRenderer) secondLayoutResult.getSplitRenderer(); - Assert.assertNotNull(firstSplitRenderer); - Assert.assertNotNull(secondSplitRenderer); - Assert.assertEquals(firstSplitRenderer.toString(), secondSplitRenderer.toString()); + Assertions.assertNotNull(firstSplitRenderer); + Assertions.assertNotNull(secondSplitRenderer); + Assertions.assertEquals(firstSplitRenderer.toString(), secondSplitRenderer.toString()); ParagraphRenderer firstOverflowRenderer = (ParagraphRenderer) firstLayoutResult.getOverflowRenderer(); ParagraphRenderer secondOverflowRenderer = (ParagraphRenderer) secondLayoutResult.getOverflowRenderer(); - Assert.assertNotNull(firstOverflowRenderer); - Assert.assertNotNull(secondOverflowRenderer); + Assertions.assertNotNull(firstOverflowRenderer); + Assertions.assertNotNull(secondOverflowRenderer); List firstOverflowRendererChildren = firstOverflowRenderer.getChildRenderers(); List secondOverflowRendererChildren = secondOverflowRenderer.getChildRenderers(); - Assert.assertNotNull(firstOverflowRendererChildren); - Assert.assertNotNull(secondOverflowRendererChildren); - Assert.assertEquals(firstOverflowRendererChildren.size(), secondOverflowRendererChildren.size()); + Assertions.assertNotNull(firstOverflowRendererChildren); + Assertions.assertNotNull(secondOverflowRendererChildren); + Assertions.assertEquals(firstOverflowRendererChildren.size(), secondOverflowRendererChildren.size()); } @Test @@ -191,14 +190,14 @@ public void orphansWidowsAwareAndDirectLayoutProduceSameResult() { LayoutResult widowsControlLayoutResult = paragraphRenderer.layout(layoutContext); // toString() comparison is used since it contains report on status, areaBreak and occupiedArea - Assert.assertEquals(noWidowsControlLayoutResult.toString(), widowsControlLayoutResult.toString()); + Assertions.assertEquals(noWidowsControlLayoutResult.toString(), widowsControlLayoutResult.toString()); ParagraphRenderer firstSplitRenderer = (ParagraphRenderer) noWidowsControlLayoutResult.getSplitRenderer(); ParagraphRenderer secondSplitRenderer = (ParagraphRenderer) widowsControlLayoutResult.getSplitRenderer(); - Assert.assertNotNull(firstSplitRenderer); - Assert.assertNotNull(secondSplitRenderer); - Assert.assertEquals(firstSplitRenderer.toString(), secondSplitRenderer.toString()); - Assert.assertNotNull(noWidowsControlLayoutResult.getOverflowRenderer()); - Assert.assertNotNull(widowsControlLayoutResult.getOverflowRenderer()); + Assertions.assertNotNull(firstSplitRenderer); + Assertions.assertNotNull(secondSplitRenderer); + Assertions.assertEquals(firstSplitRenderer.toString(), secondSplitRenderer.toString()); + Assertions.assertNotNull(noWidowsControlLayoutResult.getOverflowRenderer()); + Assertions.assertNotNull(widowsControlLayoutResult.getOverflowRenderer()); } @Test @@ -390,21 +389,21 @@ private static void runMaxHeightLimit(String fileName, boolean orphans) throws I String outPdf = destinationFolder + fileName + ".pdf"; String cmpPdf = sourceFolder + "cmp_" + fileName + ".pdf"; OrphansWidowsTestUtil.produceOrphansWidowsAndMaxHeightLimitTestCase(outPdf, orphans); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); } private static void runCanvasSize(String fileName, boolean orphans) throws IOException, InterruptedException { String outPdf = destinationFolder + fileName + ".pdf"; String cmpPdf = sourceFolder + "cmp_" + fileName + ".pdf"; OrphansWidowsTestUtil.produceOrphansWidowsOnCanvasOfLimitedSizeTestCase(outPdf, orphans); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); } private static void runDivSize(String fileName, boolean orphans) throws IOException, InterruptedException { String outPdf = destinationFolder + fileName + ".pdf"; String cmpPdf = sourceFolder + "cmp_" + fileName + ".pdf"; OrphansWidowsTestUtil.produceOrphansWidowsWithinDivOfLimitedSizeTestCase(outPdf, orphans); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); } private static void runKeepTogether(String fileName, boolean orphans, boolean large) @@ -412,7 +411,7 @@ private static void runKeepTogether(String fileName, boolean orphans, boolean la String outPdf = destinationFolder + fileName + ".pdf"; String cmpPdf = sourceFolder + "cmp_" + fileName + ".pdf"; OrphansWidowsTestUtil.produceOrphansWidowsKeepTogetherTestCase(outPdf, orphans, large); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); } private static void runInlineImage(String fileName, boolean orphans) throws IOException, InterruptedException { @@ -420,7 +419,7 @@ private static void runInlineImage(String fileName, boolean orphans) throws IOEx String cmpPdf = sourceFolder + "cmp_" + fileName + ".pdf"; String imagePath = sourceFolder + "bulb.gif"; OrphansWidowsTestUtil.produceOrphansWidowsInlineImageTestCase(outPdf, imagePath, orphans); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); } private static void runHugeInlineImage(String fileName, boolean orphans) throws IOException, InterruptedException { @@ -428,7 +427,7 @@ private static void runHugeInlineImage(String fileName, boolean orphans) throws String cmpPdf = sourceFolder + "cmp_" + fileName + ".pdf"; String imagePath = sourceFolder + "imageA4.png"; OrphansWidowsTestUtil.produceOrphansWidowsHugeInlineImageTestCase(outPdf, imagePath, orphans); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); } private static void runCustomParagraphAndRendererTest(String fileName, boolean orphans) @@ -442,7 +441,7 @@ private static void runCustomParagraphAndRendererTest(String fileName, boolean o customParagraph.setWidowsControl(new ParagraphWidowsControl(3, 1, false)); } OrphansWidowsTestUtil.produceOrphansWidowsTestCase(outPdf, 2, orphans, customParagraph, false); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); } private static void runUnexpectedWidthOfNextAreaTest(String fileName, boolean wide) @@ -450,7 +449,7 @@ private static void runUnexpectedWidthOfNextAreaTest(String fileName, boolean wi String outPdf = destinationFolder + fileName + ".pdf"; String cmpPdf = sourceFolder + "cmp_" + fileName + ".pdf"; OrphansWidowsTestUtil.produceOrphansWidowsUnexpectedWidthOfNextAreaTestCase(outPdf, wide); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); } private static void runInlineBlockTest(String fileName, boolean orphans) @@ -458,7 +457,7 @@ private static void runInlineBlockTest(String fileName, boolean orphans) String outPdf = destinationFolder + fileName + ".pdf"; String cmpPdf = sourceFolder + "cmp_" + fileName + ".pdf"; OrphansWidowsTestUtil.produceOrphansWidowsInlineBlockTestCase(outPdf, orphans); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); } private static void runInlineFloatTest(String fileName, boolean orphans) @@ -466,7 +465,7 @@ private static void runInlineFloatTest(String fileName, boolean orphans) String outPdf = destinationFolder + fileName + ".pdf"; String cmpPdf = sourceFolder + "cmp_" + fileName + ".pdf"; OrphansWidowsTestUtil.produceOrphansWidowsInlineFloatTestCase(outPdf, orphans); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); } private static void runFloatingDiv(String fileName, boolean orphans) @@ -474,7 +473,7 @@ private static void runFloatingDiv(String fileName, boolean orphans) String outPdf = destinationFolder + fileName + ".pdf"; String cmpPdf = sourceFolder + "cmp_" + fileName + ".pdf"; OrphansWidowsTestUtil.produceOrphansWidowsFloatingDivTestCase(outPdf, orphans); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); } private static void runOrphansWidowsBiggerThanLinesCount(String fileName, boolean orphans, boolean singleLine) @@ -482,7 +481,7 @@ private static void runOrphansWidowsBiggerThanLinesCount(String fileName, boolea String outPdf = destinationFolder + fileName + ".pdf"; String cmpPdf = sourceFolder + "cmp_" + fileName + ".pdf"; OrphansWidowsTestUtil.produceOrphansWidowsBiggerThanLinesCountTestCase(outPdf, orphans, singleLine); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); } private static void runMinThreeOrphansTest(String testName, int linesLeft) @@ -529,7 +528,7 @@ private static void runOrphansAndWidows(String testName) OrphansWidowsTestUtil.produceOrphansAndWidowsTestCase(outPdf, testPara); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); } private static void runTestOnPage(String testName, Paragraph testPara, boolean orphans) @@ -541,7 +540,7 @@ private static void runTestOnPage(String testName, Paragraph testPara, boolean o OrphansWidowsTestUtil.produceOrphansOrWidowsTestCase(outPdf, linesLeft, orphans, testPara); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); } private static void runTest(String testName, int linesLeft, boolean orphans, Paragraph testPara) @@ -557,7 +556,7 @@ private static void runTest(String testName, int linesLeft, boolean orphans, Par OrphansWidowsTestUtil .produceOrphansWidowsTestCase(outPdf, linesLeft, orphans, testPara, marginCollapseTestCase); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); } private static class CustomParagraphRenderer extends ParagraphRenderer { diff --git a/layout/src/test/java/com/itextpdf/layout/OverflowTest.java b/layout/src/test/java/com/itextpdf/layout/OverflowTest.java index 46cf9f3d57..d1d858adae 100644 --- a/layout/src/test/java/com/itextpdf/layout/OverflowTest.java +++ b/layout/src/test/java/com/itextpdf/layout/OverflowTest.java @@ -43,21 +43,20 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; import java.net.MalformedURLException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class OverflowTest extends ExtendedITextTest { public static final String destinationFolder = "./target/test/com/itextpdf/layout/OverflowTest/"; public static final String sourceFolder = "./src/test/resources/com/itextpdf/layout/OverflowTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } @@ -80,7 +79,7 @@ public void textOverflowTest01() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -99,7 +98,7 @@ public void textOverflowTest02() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -118,7 +117,7 @@ public void textOverflowTest03() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -133,7 +132,7 @@ public void textOverflowTest04() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -162,7 +161,7 @@ public void alignedInlineContentOverflowHiddenTest01() throws IOException, Inter document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -187,7 +186,7 @@ public void alignedInlineContentOverflowHiddenTest02() throws IOException, Inter document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -204,7 +203,7 @@ public void overflowHiddenOnCanvasTest01() throws IOException, InterruptedExcept canvas.close(); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -221,7 +220,7 @@ public void overflowHiddenOnCanvasTest02() throws IOException, InterruptedExcept canvas.close(); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -238,7 +237,7 @@ public void overflowVisibleOnCanvasTest01() throws IOException, InterruptedExcep canvas.close(); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -255,7 +254,7 @@ public void overflowVisibleOnCanvasTest02() throws IOException, InterruptedExcep canvas.close(); pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } private static void addParaWithImgSetOverflowX(Canvas canvas, OverflowPropertyValue overflowX) throws MalformedURLException { @@ -300,7 +299,7 @@ public void forcedPlacementTest01() throws IOException, InterruptedException { // This test is really artificial in fact, since FORCED_PLACEMENT is set explicitly. Even though at the moment // of test creation such situation in fact really happens during elements layout. - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -332,6 +331,6 @@ public void forcedPlacementTest02() throws IOException, InterruptedException { // This test is really artificial in fact, since FORCED_PLACEMENT is set explicitly. Even though at the moment // of test creation such situation in fact really happens during elements layout - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } } diff --git a/layout/src/test/java/com/itextpdf/layout/ParagraphTest.java b/layout/src/test/java/com/itextpdf/layout/ParagraphTest.java index e67bacd9ab..0c31e13bd1 100644 --- a/layout/src/test/java/com/itextpdf/layout/ParagraphTest.java +++ b/layout/src/test/java/com/itextpdf/layout/ParagraphTest.java @@ -35,21 +35,20 @@ This file is part of the iText (R) project. import com.itextpdf.test.LogLevelConstants; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class ParagraphTest extends ExtendedITextTest { public static final String destinationFolder = "./target/test/com/itextpdf/layout/ParagraphTest/"; public static final String sourceFolder = "./src/test/resources/com/itextpdf/layout/ParagraphTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } @@ -70,7 +69,7 @@ public void cannotPlaceABigChunkOnALineTest01() throws IOException, InterruptedE doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -89,7 +88,7 @@ public void cannotPlaceABigChunkOnALineTest02() throws IOException, InterruptedE doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -109,7 +108,7 @@ public void forceOverflowForTextRendererPartialResult01() throws IOException, In doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -135,6 +134,6 @@ public void wordWasSplitAndItWillFitOntoNextLineTest02() throws IOException, Int document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } } diff --git a/layout/src/test/java/com/itextpdf/layout/PdfTextExtractorEncodingsTest.java b/layout/src/test/java/com/itextpdf/layout/PdfTextExtractorEncodingsTest.java index c303390dd2..4400c8bfdb 100644 --- a/layout/src/test/java/com/itextpdf/layout/PdfTextExtractorEncodingsTest.java +++ b/layout/src/test/java/com/itextpdf/layout/PdfTextExtractorEncodingsTest.java @@ -34,16 +34,15 @@ This file is part of the iText (R) project. import com.itextpdf.layout.element.AreaBreak; import com.itextpdf.layout.element.Paragraph; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfTextExtractorEncodingsTest extends ExtendedITextTest { private static final String sourceFolder = "./src/test/resources/com/itextpdf/layout/PdfTextExtractorEncodingsTest/"; @@ -98,9 +97,9 @@ public void testUnicodeFont() throws Exception { private void checkPdf(byte[] pdfBytes) throws Exception { PdfDocument pdfDocument = new PdfDocument(new PdfReader(new ByteArrayInputStream(pdfBytes))); // Characters from http://unicode.org/charts/PDF/U0000.pdf - Assert.assertEquals(TEXT1, PdfTextExtractor.getTextFromPage(pdfDocument.getPage(1))); + Assertions.assertEquals(TEXT1, PdfTextExtractor.getTextFromPage(pdfDocument.getPage(1))); // Characters from http://unicode.org/charts/PDF/U0080.pdf - Assert.assertEquals(TEXT2, PdfTextExtractor.getTextFromPage(pdfDocument.getPage(2))); + Assertions.assertEquals(TEXT2, PdfTextExtractor.getTextFromPage(pdfDocument.getPage(2))); } protected static PdfFont getTTFont(String encoding, EmbeddingStrategy embeddingStrategy) throws IOException { diff --git a/layout/src/test/java/com/itextpdf/layout/PdfUA2AnnotationsTest.java b/layout/src/test/java/com/itextpdf/layout/PdfUA2AnnotationsTest.java index 3e6b3ca76c..6e26904f04 100644 --- a/layout/src/test/java/com/itextpdf/layout/PdfUA2AnnotationsTest.java +++ b/layout/src/test/java/com/itextpdf/layout/PdfUA2AnnotationsTest.java @@ -69,7 +69,6 @@ This file is part of the iText (R) project. import com.itextpdf.layout.element.Link; import com.itextpdf.layout.element.Paragraph; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import com.itextpdf.test.pdfa.VeraPdfValidator; // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) import java.io.ByteArrayInputStream; @@ -77,19 +76,19 @@ This file is part of the iText (R) project. import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Paths; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; +import static org.junit.jupiter.api.Assertions.fail; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfUA2AnnotationsTest extends ExtendedITextTest { public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/layout/PdfUA2AnnotationsTest/"; public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/layout/PdfUA2AnnotationsTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(DESTINATION_FOLDER); } @@ -130,7 +129,7 @@ public void pdfUA2LinkAnnotNoAltTest() throws IOException, XMPException { paragraph.add(link); new Document(pdfDocument).add(paragraph); } - Assert.assertNotNull(new VeraPdfValidator().validate(outFile));// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNotNull(new VeraPdfValidator().validate(outFile));// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) } @Test @@ -174,7 +173,7 @@ public void pdfUA2FileAttachmentAnnotNoAFRelTest() throws IOException, XMPExcept annot.setContents("Hello world"); pdfPage.addAnnotation(annot); } - Assert.assertNotNull(new VeraPdfValidator().validate(outFile));// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNotNull(new VeraPdfValidator().validate(outFile));// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) } @@ -200,7 +199,7 @@ public void pdfUA2RubberStampAnnotationsTest() throws IOException, XMPException, @Test public void pdfUA2RubberStampNoContentsAnnotationsTest() throws IOException, XMPException { - String outFile = DESTINATION_FOLDER + "pdfuaRubberstampAnnotationTest.pdf"; + String outFile = DESTINATION_FOLDER + "pdfuaRubberstampNoContentAnnotationTest.pdf"; try (PdfDocument pdfDocument = new PdfDocument( new PdfWriter(outFile, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)))) { @@ -211,7 +210,7 @@ public void pdfUA2RubberStampNoContentsAnnotationsTest() throws IOException, XMP pdfPage.addAnnotation(stamp); pdfPage.flush(); } - Assert.assertNotNull(new VeraPdfValidator().validate(outFile));// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNotNull(new VeraPdfValidator().validate(outFile));// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) } @Test @@ -227,7 +226,7 @@ public void pdfUA2ScreenAnnotationsTest() throws IOException, XMPException { pdfPage.addAnnotation(screen); pdfPage.flush(); } - Assert.assertNull(new VeraPdfValidator().validate(outFile));// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNull(new VeraPdfValidator().validate(outFile));// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) } @Test @@ -242,7 +241,7 @@ public void pdfUA2ScreenNoContentsAnnotationsTest() throws IOException, XMPExcep pdfPage.addAnnotation(screen); pdfPage.flush(); } - Assert.assertNotNull(new VeraPdfValidator().validate(outFile));// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNotNull(new VeraPdfValidator().validate(outFile));// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) } @Test @@ -276,7 +275,7 @@ public void pdfUA2InkAnnotationsNoContentTest() throws IOException, XMPException pdfPage.flush(); } - Assert.assertNotNull(new VeraPdfValidator().validate(outFile));// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNotNull(new VeraPdfValidator().validate(outFile));// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) } @Test @@ -311,7 +310,7 @@ public void pdfUA2RedactionNoContentsAnnotationsTest() throws IOException, XMPEx pdfPage.flush(); } - Assert.assertNotNull(new VeraPdfValidator().validate(outFile));// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNotNull(new VeraPdfValidator().validate(outFile));// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) } @Test @@ -345,7 +344,7 @@ public void pdfUA23DNoContentsAnnotationsTest() throws IOException, XMPException pdfPage.flush(); } - Assert.assertNotNull(new VeraPdfValidator().validate(outFile));// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNotNull(new VeraPdfValidator().validate(outFile));// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) } @Test @@ -379,7 +378,7 @@ public void pdfUA2RichMediaNoContentsAnnotationsTest() throws IOException, XMPEx pdfPage.flush(); } - Assert.assertNotNull(new VeraPdfValidator().validate(outFile));// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNotNull(new VeraPdfValidator().validate(outFile));// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) } @Test @@ -421,7 +420,7 @@ public void pdfUA2NotAllowedTrapNetAnnotationTest() throws IOException, XMPExcep PdfTrapNetworkAnnotation annot = new PdfTrapNetworkAnnotation(PageSize.A4, form); pdfPage.addAnnotation(annot); } - Assert.assertNotNull(new VeraPdfValidator().validate(outFile));// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNotNull(new VeraPdfValidator().validate(outFile));// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) } @Test @@ -435,7 +434,7 @@ public void pdfUA2NotAllowedSoundAnnotationTest() throws IOException, XMPExcepti PdfAnnotation annot = new PdfSoundAnnotation(new Rectangle(100, 100, 100, 100), new PdfStream()); pdfPage.addAnnotation(annot); } - Assert.assertNotNull(new VeraPdfValidator().validate(outFile));// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNotNull(new VeraPdfValidator().validate(outFile));// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) } @Test @@ -456,7 +455,7 @@ public void pdfUA2AltContentDiffAnnotationTest() new Document(pdfDocument).add(paragraph); } - Assert.assertNotNull(new VeraPdfValidator().validate(outFile));// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNotNull(new VeraPdfValidator().validate(outFile));// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) } @Test @@ -475,9 +474,9 @@ public void pdfUA2TabAnnotationsTest() throws IOException, XMPException, Interru for (int i = 0; i < pdfDocument.getNumberOfPages(); i++) { PdfDictionary pageObject = pdfDocument.getPage(i+1).getPdfObject(); - Assert.assertTrue(pageObject.containsKey(PdfName.Tabs)); + Assertions.assertTrue(pageObject.containsKey(PdfName.Tabs)); PdfObject pageT = pageObject.get(PdfName.Tabs); - Assert.assertEquals(PdfName.S, pageT); + Assertions.assertEquals(PdfName.S, pageT); } } compareAndValidate(outFile, cmpFile); @@ -497,7 +496,7 @@ public void annotationInvisibleButNoArtifactTest() throws IOException, XMPExcept pdfPage.flush(); } - Assert.assertNotNull(new VeraPdfValidator().validate(outFile));// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNotNull(new VeraPdfValidator().validate(outFile));// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) } @Test @@ -514,7 +513,7 @@ public void annotationNoViewButNoArtifactTest() throws IOException, XMPException pdfPage.flush(); } - Assert.assertNotNull(new VeraPdfValidator().validate(outFile));// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNotNull(new VeraPdfValidator().validate(outFile));// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) } private void createSimplePdfUA2Document(PdfDocument pdfDocument) throws IOException, XMPException { @@ -529,7 +528,7 @@ private void createSimplePdfUA2Document(PdfDocument pdfDocument) throws IOExcept } private void compareAndValidate(String outPdf, String cmpPdf) throws IOException, InterruptedException { - Assert.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) String result = new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_"); if (result != null) { fail(result); diff --git a/layout/src/test/java/com/itextpdf/layout/PdfUA2FontTest.java b/layout/src/test/java/com/itextpdf/layout/PdfUA2FontTest.java index 5ed4e4d93d..b5cca0be96 100644 --- a/layout/src/test/java/com/itextpdf/layout/PdfUA2FontTest.java +++ b/layout/src/test/java/com/itextpdf/layout/PdfUA2FontTest.java @@ -39,26 +39,25 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.xmp.XMPMetaFactory; import com.itextpdf.layout.element.Paragraph; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import com.itextpdf.test.pdfa.VeraPdfValidator; // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) import java.io.ByteArrayInputStream; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; +import static org.junit.jupiter.api.Assertions.fail; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfUA2FontTest extends ExtendedITextTest { public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/layout/PdfUA2FontTest/"; public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/layout/PdfUA2FontTest/"; public static final String FONT_FOLDER = "./src/test/resources/com/itextpdf/layout/fonts/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(DESTINATION_FOLDER); } @@ -170,7 +169,7 @@ private void createSimplePdfUA2Document(PdfDocument pdfDocument) throws IOExcept } private void compareAndValidate(String outPdf, String cmpPdf) throws IOException, InterruptedException { - Assert.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) String result = new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_"); if (result != null) { fail(result); diff --git a/layout/src/test/java/com/itextpdf/layout/PdfUA2Test.java b/layout/src/test/java/com/itextpdf/layout/PdfUA2Test.java index 3103ed2c0a..82974a5b1e 100644 --- a/layout/src/test/java/com/itextpdf/layout/PdfUA2Test.java +++ b/layout/src/test/java/com/itextpdf/layout/PdfUA2Test.java @@ -73,27 +73,26 @@ This file is part of the iText (R) project. import com.itextpdf.layout.properties.ListNumberingType; import com.itextpdf.layout.properties.Property; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import com.itextpdf.test.pdfa.VeraPdfValidator; // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) import java.io.ByteArrayInputStream; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.fail; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfUA2Test extends ExtendedITextTest { public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/layout/PdfUA2Test/"; public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/layout/PdfUA2Test/"; public static final String FONT_FOLDER = "./src/test/resources/com/itextpdf/layout/fonts/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(DESTINATION_FOLDER); } @@ -111,14 +110,14 @@ public void checkXmpMetadataTest() throws IOException, XMPException, Interrupted "WinAnsi", EmbeddingStrategy.FORCE_EMBEDDED); Paragraph paragraph = new Paragraph("Hello PdfUA2").setFont(font); - byte[] byteMetaData = pdfDocument.getXmpMetadata(); + byte[] byteMetaData = pdfDocument.getXmpMetadataBytes(); documentMetaData = new String(byteMetaData); document.add(paragraph); } // There is a typo in the specification and the Schema namespace must contain http - Assert.assertTrue(documentMetaData.contains("http://www.aiim.org/pdfua/ns/id/")); - Assert.assertTrue(documentMetaData.contains("pdfuaid:part=\"2\"")); - Assert.assertTrue(documentMetaData.contains("pdfuaid:rev=\"2024\"")); + Assertions.assertTrue(documentMetaData.contains("http://www.aiim.org/pdfua/ns/id/")); + Assertions.assertTrue(documentMetaData.contains("pdfuaid:part=\"2\"")); + Assertions.assertTrue(documentMetaData.contains("pdfuaid:rev=\"2024\"")); compareAndValidate(outFile, cmpFile); } @@ -140,7 +139,7 @@ public void checkRealContentTest() throws IOException, XMPException, Interrupted PdfStructTreeRoot structTreeRoot = pdfDocument.getStructTreeRoot(); // We check that the paragraph remains one in the structure when it spans two pages. - Assert.assertEquals(1, structTreeRoot.getKids().get(0).getKids().size()); + Assertions.assertEquals(1, structTreeRoot.getKids().get(0).getKids().size()); } compareAndValidate(outFile, cmpFile); } @@ -164,7 +163,7 @@ public void checkArtifactTest() throws IOException, XMPException, InterruptedExc PdfStructTreeRoot structTreeRoot = pdfDocument.getStructTreeRoot(); // We check that there are no children because the paragraph has the Artifact role, and it is not real content. - Assert.assertEquals(0, structTreeRoot.getKids().get(0).getKids().size()); + Assertions.assertEquals(0, structTreeRoot.getKids().get(0).getKids().size()); } compareAndValidate(outFile, cmpFile); } @@ -183,8 +182,8 @@ public void checkStructureTypeNamespaceTest() throws IOException, XMPException, Paragraph paragraph = new Paragraph("Hello PdfUA2").setFont(font); paragraph.getAccessibilityProperties().setRole("Custom Role"); - Exception e = Assert.assertThrows(PdfException.class, ()-> document.add(paragraph)); - Assert.assertEquals(MessageFormatUtil.format( + Exception e = Assertions.assertThrows(PdfException.class, ()-> document.add(paragraph)); + Assertions.assertEquals(MessageFormatUtil.format( KernelExceptionMessageConstant.ROLE_IN_NAMESPACE_IS_NOT_MAPPED_TO_ANY_STANDARD_ROLE, "Custom Role", "http://iso.org/pdf2/ssn"), e.getMessage()); } @@ -237,9 +236,9 @@ public void checkArticleTest() throws IOException, XMPException, InterruptedExce PdfStructTreeRoot structTreeRoot = pdfDocument.getStructTreeRoot(); IStructureNode articleNode = structTreeRoot.getKids().get(0).getKids().get(0); - Assert.assertEquals(1, articleNode.getKids().size()); + Assertions.assertEquals(1, articleNode.getKids().size()); String childElementSection = articleNode.getKids().get(0).getRole().toString(); - Assert.assertEquals("/Title", childElementSection); + Assertions.assertEquals("/Title", childElementSection); } compareAndValidate(outFile, cmpFile); } @@ -268,9 +267,9 @@ public void checkSectionTest() throws IOException, XMPException, InterruptedExce PdfStructTreeRoot structTreeRoot = pdfDocument.getStructTreeRoot(); IStructureNode sectionNode = structTreeRoot.getKids().get(0).getKids().get(0); - Assert.assertEquals(1, sectionNode.getKids().size()); + Assertions.assertEquals(1, sectionNode.getKids().size()); String childElementSection = sectionNode.getKids().get(0).getRole().toString(); - Assert.assertEquals("/H2", childElementSection); + Assertions.assertEquals("/H2", childElementSection); } compareAndValidate(outFile, cmpFile); } @@ -301,8 +300,8 @@ public void checkTableOfContentsTest() throws IOException, XMPException, Interru pointer.moveToParent().moveToKid(StandardRoles.TOCI); // We check that TOCI contains the previously added Paragraph ref - Assert.assertEquals(1, pointer.getProperties().getRefsList().size()); - Assert.assertEquals(StandardRoles.P, pointer.getProperties().getRefsList().get(0).getRole()); + Assertions.assertEquals(1, pointer.getProperties().getRefsList().size()); + Assertions.assertEquals(StandardRoles.P, pointer.getProperties().getRefsList().get(0).getRole()); } compareAndValidate(outFile, cmpFile); } @@ -359,8 +358,8 @@ public void checkParagraphTest() throws IOException, XMPException, InterruptedEx document.add(p2); PdfStructTreeRoot structTreeRoot = pdfDocument.getStructTreeRoot(); - Assert.assertEquals("/P", structTreeRoot.getKids().get(0).getKids().get(0).getRole().toString()); - Assert.assertEquals("/P", structTreeRoot.getKids().get(0).getKids().get(1).getRole().toString()); + Assertions.assertEquals("/P", structTreeRoot.getKids().get(0).getKids().get(0).getRole().toString()); + Assertions.assertEquals("/P", structTreeRoot.getKids().get(0).getKids().get(1).getRole().toString()); } compareAndValidate(outFile, cmpFile); } @@ -391,9 +390,9 @@ public void checkHeadingTest() throws IOException, XMPException, InterruptedExce document.add(h6); PdfStructTreeRoot structTreeRoot = pdfDocument.getStructTreeRoot(); - Assert.assertEquals("/H1", structTreeRoot.getKids().get(0).getKids().get(0).getRole().toString()); - Assert.assertEquals("/H3", structTreeRoot.getKids().get(0).getKids().get(1).getRole().toString()); - Assert.assertEquals("/H6", structTreeRoot.getKids().get(0).getKids().get(2).getRole().toString()); + Assertions.assertEquals("/H1", structTreeRoot.getKids().get(0).getKids().get(0).getRole().toString()); + Assertions.assertEquals("/H3", structTreeRoot.getKids().get(0).getKids().get(1).getRole().toString()); + Assertions.assertEquals("/H6", structTreeRoot.getKids().get(0).getKids().get(2).getRole().toString()); } compareAndValidate(outFile, cmpFile); } @@ -533,7 +532,7 @@ public void checkCaptionTest() throws IOException, XMPException, InterruptedExce IStructureNode tableNode = structTreeRoot.getKids().get(0).getKids().get(0); String tableChildRole = tableNode.getKids().get(0).getRole().toString(); - Assert.assertEquals("/Caption" , tableChildRole); + Assertions.assertEquals("/Caption" , tableChildRole); } compareAndValidate(outFile, cmpFile); } @@ -672,7 +671,7 @@ public void checkMetadataNoTitleTest() throws IOException, XMPException { pdfDocument.getCatalog().setViewerPreferences(new PdfViewerPreferences().setDisplayDocTitle(true)); pdfDocument.getCatalog().setLang(new PdfString("en-US")); } - Assert.assertNotNull(new VeraPdfValidator().validate(outFile));// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNotNull(new VeraPdfValidator().validate(outFile));// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) } @Test @@ -688,7 +687,7 @@ public void checkMetadataDisplayDocTitleFalseTest() throws IOException, XMPExcep PdfDocumentInfo info = pdfDocument.getDocumentInfo(); info.setTitle("PdfUA2 Title"); } - Assert.assertNotNull(new VeraPdfValidator().validate(outFile));// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNotNull(new VeraPdfValidator().validate(outFile));// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) } @Test @@ -703,7 +702,7 @@ public void checkMetadataNoViewerPrefTest() throws IOException, XMPException { PdfDocumentInfo info = pdfDocument.getDocumentInfo(); info.setTitle("PdfUA2 Title"); } - Assert.assertNotNull(new VeraPdfValidator().validate(outFile));// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNotNull(new VeraPdfValidator().validate(outFile));// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) } @Test @@ -732,7 +731,7 @@ public void checkEmbeddedFileNoDescTest() throws IOException, XMPException { ((PdfDictionary) spec.getPdfObject()).remove(PdfName.Desc); pdfDocument.addFileAttachment("specificname", spec); } - Assert.assertNotNull(new VeraPdfValidator().validate(outFile));// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNotNull(new VeraPdfValidator().validate(outFile));// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) } @Test @@ -848,9 +847,9 @@ public void checkOutlinesAsStructureDestinationsTest() throws IOException, XMPEx try (PdfDocument pdfDocument = new PdfDocument(new PdfReader(outFile))) { PdfOutline outline = pdfDocument.getOutlines(false); - Assert.assertEquals("header1", outline.getAllChildren().get(0) + Assertions.assertEquals("header1", outline.getAllChildren().get(0) .getDestination().getPdfObject().toString()); - Assert.assertEquals("header1.1", outline.getAllChildren().get(0).getAllChildren().get(0) + Assertions.assertEquals("header1.1", outline.getAllChildren().get(0).getAllChildren().get(0) .getDestination().getPdfObject().toString()); } } @@ -867,7 +866,7 @@ private void createSimplePdfUA2Document(PdfDocument pdfDocument) throws IOExcept } private void compareAndValidate(String outPdf, String cmpPdf) throws IOException, InterruptedException { - Assert.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) String result = new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_"); if (result != null) { fail(result); diff --git a/layout/src/test/java/com/itextpdf/layout/PositioningTest.java b/layout/src/test/java/com/itextpdf/layout/PositioningTest.java index 9c51743df8..31d80f8116 100644 --- a/layout/src/test/java/com/itextpdf/layout/PositioningTest.java +++ b/layout/src/test/java/com/itextpdf/layout/PositioningTest.java @@ -49,22 +49,21 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PositioningTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/layout/PositioningTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/layout/PositioningTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } @@ -89,7 +88,7 @@ public void relativePositioningTest01() throws IOException, InterruptedException document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -113,7 +112,7 @@ public void relativePositioningTest02() throws IOException, InterruptedException document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -133,7 +132,7 @@ public void relativePositioningTable01Test() throws IOException, InterruptedExce document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -155,7 +154,7 @@ public void fixedPositioningTest01() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -176,7 +175,7 @@ public void fixedPositioningTest02() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -202,7 +201,7 @@ public void fixedPositioningTest03() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -229,7 +228,7 @@ public void fixedPositioningTest04() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -289,7 +288,7 @@ public void showTextAlignedTest01() throws IOException, InterruptedException { document.showTextAligned(text, x, y, TextAlignment.RIGHT, VerticalAlignment.TOP, (float) (Math.PI/6 * 6)); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @@ -313,7 +312,7 @@ public void showTextAlignedTest02() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @@ -339,7 +338,7 @@ public void showTextAlignedTest03() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -358,11 +357,11 @@ public void showTextAlignedOnFlushedPageTest01() throws IOException { // First page will be flushed by now, because immediateFlush is set to false by default. int pageNumberToDrawTextOn = 1; - Exception e = Assert.assertThrows(PdfException.class, + Exception e = Assertions.assertThrows(PdfException.class, () -> doc.showTextAligned(new Paragraph("Hello Bruno on page 1!"), 36, 36, pageNumberToDrawTextOn, TextAlignment.LEFT, VerticalAlignment.TOP, 0) ); - Assert.assertEquals(LayoutExceptionMessageConstant.CANNOT_DRAW_ELEMENTS_ON_ALREADY_FLUSHED_PAGES, e.getMessage()); + Assertions.assertEquals(LayoutExceptionMessageConstant.CANNOT_DRAW_ELEMENTS_ON_ALREADY_FLUSHED_PAGES, e.getMessage()); } } diff --git a/layout/src/test/java/com/itextpdf/layout/PreLayoutTest.java b/layout/src/test/java/com/itextpdf/layout/PreLayoutTest.java index 29f1223e0e..7801d7aeda 100644 --- a/layout/src/test/java/com/itextpdf/layout/PreLayoutTest.java +++ b/layout/src/test/java/com/itextpdf/layout/PreLayoutTest.java @@ -37,23 +37,22 @@ This file is part of the iText (R) project. import com.itextpdf.layout.renderer.ParagraphRenderer; import com.itextpdf.layout.renderer.TextRenderer; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; import java.util.ArrayList; import java.util.List; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PreLayoutTest extends ExtendedITextTest{ public static final String sourceFolder = "./src/test/resources/com/itextpdf/layout/PreLayoutTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/layout/PreLayoutTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } @@ -95,7 +94,7 @@ public void preLayoutTest01() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -135,7 +134,7 @@ public void preLayoutTest02() throws IOException, InterruptedException { //Close document. Drawing of content is happened on close document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -160,7 +159,7 @@ public void columnDocumentRendererRelayoutTest() throws IOException, Interrupted document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } static class TwoColumnParagraphRenderer extends ParagraphRenderer { diff --git a/layout/src/test/java/com/itextpdf/layout/RotationTest.java b/layout/src/test/java/com/itextpdf/layout/RotationTest.java index a49f43ab22..f937d6c735 100644 --- a/layout/src/test/java/com/itextpdf/layout/RotationTest.java +++ b/layout/src/test/java/com/itextpdf/layout/RotationTest.java @@ -22,13 +22,20 @@ This file is part of the iText (R) project. */ package com.itextpdf.layout; +import com.itextpdf.io.font.constants.StandardFonts; import com.itextpdf.io.logs.IoLogMessageConstant; import com.itextpdf.io.image.ImageDataFactory; import com.itextpdf.kernel.colors.ColorConstants; +import com.itextpdf.kernel.font.PdfFont; +import com.itextpdf.kernel.font.PdfFontFactory; import com.itextpdf.kernel.geom.PageSize; +import com.itextpdf.kernel.geom.Rectangle; import com.itextpdf.kernel.pdf.PdfDocument; +import com.itextpdf.kernel.pdf.PdfPage; +import com.itextpdf.kernel.pdf.PdfReader; import com.itextpdf.kernel.pdf.PdfWriter; import com.itextpdf.kernel.pdf.canvas.PdfCanvas; +import com.itextpdf.kernel.pdf.extgstate.PdfExtGState; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.layout.borders.SolidBorder; import com.itextpdf.layout.element.AreaBreak; @@ -46,21 +53,21 @@ This file is part of the iText (R) project. import com.itextpdf.layout.properties.Property; import com.itextpdf.layout.properties.TextAlignment; import com.itextpdf.layout.properties.UnitValue; +import com.itextpdf.layout.properties.VerticalAlignment; import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class RotationTest extends ExtendedITextTest { - public static final String sourceFolder = "./src/test/resources/com/itextpdf/layout/RotationTest/"; - public static final String destinationFolder = "./target/test/com/itextpdf/layout/RotationTest/"; + public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/layout/RotationTest/"; + public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/layout/RotationTest/"; public static final String cmpPrefix = "cmp_"; private static final String para1Text = "The first published account of what would evolve into the Mafia in the United States came in the spring of 1869. " + @@ -75,15 +82,15 @@ public class RotationTest extends ExtendedITextTest { private static final String para3Text = "From the 1890s to the 1900s (decade) in New York City, the Sicilian Mafia developed into the Five Points Gang and were very powerful in the" + " Little Italy of the Lower East Side. They were often in conflict with the Jewish Eastmans of the same area."; - @BeforeClass + @BeforeAll public static void beforeClass() { - createOrClearDestinationFolder(destinationFolder); + createOrClearDestinationFolder(DESTINATION_FOLDER); } @Test public void fixedTextRotationTest01() throws IOException, InterruptedException { - String outFileName = destinationFolder + "fixedTextRotationTest01.pdf"; - String cmpFileName = sourceFolder + cmpPrefix + "fixedTextRotationTest01.pdf"; + String outFileName = DESTINATION_FOLDER + "fixedTextRotationTest01.pdf"; + String cmpFileName = SOURCE_FOLDER + cmpPrefix + "fixedTextRotationTest01.pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); Document document = new Document(pdfDocument); @@ -107,13 +114,13 @@ public void fixedTextRotationTest01() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test public void fixedTextRotationTest02() throws IOException, InterruptedException { - String outFileName = destinationFolder + "fixedTextRotationTest02.pdf"; - String cmpFileName = sourceFolder + cmpPrefix + "fixedTextRotationTest02.pdf"; + String outFileName = DESTINATION_FOLDER + "fixedTextRotationTest02.pdf"; + String cmpFileName = SOURCE_FOLDER + cmpPrefix + "fixedTextRotationTest02.pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); Document document = new Document(pdfDocument); @@ -125,13 +132,13 @@ public void fixedTextRotationTest02() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test public void fixedTextRotationTest03() throws IOException, InterruptedException { - String outFileName = destinationFolder + "fixedTextRotationTest03.pdf"; - String cmpFileName = sourceFolder + cmpPrefix + "fixedTextRotationTest03.pdf"; + String outFileName = DESTINATION_FOLDER + "fixedTextRotationTest03.pdf"; + String cmpFileName = SOURCE_FOLDER + cmpPrefix + "fixedTextRotationTest03.pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); Document document = new Document(pdfDocument); @@ -148,13 +155,13 @@ public void fixedTextRotationTest03() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test public void fixedTextRotationTest04() throws IOException, InterruptedException { - String outFileName = destinationFolder + "fixedTextRotationTest04.pdf"; - String cmpFileName = sourceFolder + cmpPrefix + "fixedTextRotationTest04.pdf"; + String outFileName = DESTINATION_FOLDER + "fixedTextRotationTest04.pdf"; + String cmpFileName = SOURCE_FOLDER + cmpPrefix + "fixedTextRotationTest04.pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); Document document = new Document(pdfDocument); @@ -170,7 +177,7 @@ public void fixedTextRotationTest04() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @LogMessages(messages = { @@ -178,8 +185,8 @@ public void fixedTextRotationTest04() throws IOException, InterruptedException { }) @Test public void staticTextRotationTest01() throws IOException, InterruptedException { - String outFileName = destinationFolder + "staticTextRotationTest01.pdf"; - String cmpFileName = sourceFolder + cmpPrefix + "staticTextRotationTest01.pdf"; + String outFileName = DESTINATION_FOLDER + "staticTextRotationTest01.pdf"; + String cmpFileName = SOURCE_FOLDER + cmpPrefix + "staticTextRotationTest01.pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); Document document = new Document(pdfDocument); @@ -192,7 +199,7 @@ public void staticTextRotationTest01() throws IOException, InterruptedException document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @LogMessages(messages = { @@ -200,8 +207,8 @@ public void staticTextRotationTest01() throws IOException, InterruptedException }) @Test public void staticTextRotationTest02() throws IOException, InterruptedException { - String outFileName = destinationFolder + "staticTextRotationTest02.pdf"; - String cmpFileName = sourceFolder + cmpPrefix + "staticTextRotationTest02.pdf"; + String outFileName = DESTINATION_FOLDER + "staticTextRotationTest02.pdf"; + String cmpFileName = SOURCE_FOLDER + cmpPrefix + "staticTextRotationTest02.pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); Document document = new Document(pdfDocument); @@ -214,7 +221,7 @@ public void staticTextRotationTest02() throws IOException, InterruptedException document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @LogMessages(messages = { @@ -222,8 +229,8 @@ public void staticTextRotationTest02() throws IOException, InterruptedException }) @Test public void staticTextRotationTest03() throws IOException, InterruptedException { - String outFileName = destinationFolder + "staticTextRotationTest03.pdf"; - String cmpFileName = sourceFolder + cmpPrefix + "staticTextRotationTest03.pdf"; + String outFileName = DESTINATION_FOLDER + "staticTextRotationTest03.pdf"; + String cmpFileName = SOURCE_FOLDER + cmpPrefix + "staticTextRotationTest03.pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); Document document = new Document(pdfDocument); @@ -235,13 +242,13 @@ public void staticTextRotationTest03() throws IOException, InterruptedException document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test public void staticTextRotationTest04() throws IOException, InterruptedException { - String outFileName = destinationFolder + "staticTextRotationTest04.pdf"; - String cmpFileName = sourceFolder + cmpPrefix + "staticTextRotationTest04.pdf"; + String outFileName = DESTINATION_FOLDER + "staticTextRotationTest04.pdf"; + String cmpFileName = SOURCE_FOLDER + cmpPrefix + "staticTextRotationTest04.pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); Document document = new Document(pdfDocument); @@ -252,13 +259,13 @@ public void staticTextRotationTest04() throws IOException, InterruptedException document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test public void splitTextRotationTest01() throws IOException, InterruptedException { - String outFileName = destinationFolder + "splitTextRotationTest01.pdf"; - String cmpFileName = sourceFolder + cmpPrefix + "splitTextRotationTest01.pdf"; + String outFileName = DESTINATION_FOLDER + "splitTextRotationTest01.pdf"; + String cmpFileName = SOURCE_FOLDER + cmpPrefix + "splitTextRotationTest01.pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); Document document = new Document(pdfDocument); @@ -271,7 +278,7 @@ public void splitTextRotationTest01() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @LogMessages(messages = { @@ -279,8 +286,8 @@ public void splitTextRotationTest01() throws IOException, InterruptedException { }) @Test public void splitTextRotationTest02() throws IOException, InterruptedException { - String outFileName = destinationFolder + "splitTextRotationTest02.pdf"; - String cmpFileName = sourceFolder + cmpPrefix + "splitTextRotationTest02.pdf"; + String outFileName = DESTINATION_FOLDER + "splitTextRotationTest02.pdf"; + String cmpFileName = SOURCE_FOLDER + cmpPrefix + "splitTextRotationTest02.pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); Document document = new Document(pdfDocument); @@ -299,14 +306,14 @@ public void splitTextRotationTest02() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test public void rotationInfiniteLoopTest01() throws IOException, InterruptedException { String fileName = "rotationInfiniteLoopTest01.pdf"; - String outFileName = destinationFolder + fileName; - String cmpFileName = sourceFolder + cmpPrefix + fileName; + String outFileName = DESTINATION_FOLDER + fileName; + String cmpFileName = SOURCE_FOLDER + cmpPrefix + fileName; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); pdfDocument.setDefaultPageSize(PageSize.A5.rotate()); @@ -316,7 +323,7 @@ public void rotationInfiniteLoopTest01() throws IOException, InterruptedExceptio document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @LogMessages(messages = { @@ -325,8 +332,8 @@ public void rotationInfiniteLoopTest01() throws IOException, InterruptedExceptio @Test public void rotationInfiniteLoopTest02() throws IOException, InterruptedException { String fileName = "rotationInfiniteLoopTest02.pdf"; - String outFileName = destinationFolder + fileName; - String cmpFileName = sourceFolder + cmpPrefix + fileName; + String outFileName = DESTINATION_FOLDER + fileName; + String cmpFileName = SOURCE_FOLDER + cmpPrefix + fileName; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); pdfDocument.setDefaultPageSize(PageSize.A5.rotate()); @@ -336,7 +343,7 @@ public void rotationInfiniteLoopTest02() throws IOException, InterruptedExceptio document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @LogMessages(messages = { @@ -344,8 +351,8 @@ public void rotationInfiniteLoopTest02() throws IOException, InterruptedExceptio }) @Test public void tableRotationTest02() throws IOException, InterruptedException { - String outFileName = destinationFolder + "tableRotationTest02.pdf"; - String cmpFileName = sourceFolder + cmpPrefix + "tableRotationTest02.pdf"; + String outFileName = DESTINATION_FOLDER + "tableRotationTest02.pdf"; + String cmpFileName = SOURCE_FOLDER + cmpPrefix + "tableRotationTest02.pdf"; PdfDocument pdfDoc = new PdfDocument(new PdfWriter(outFileName)); Document doc = new Document(pdfDoc); @@ -360,7 +367,7 @@ public void tableRotationTest02() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @LogMessages(messages = { @@ -368,8 +375,8 @@ public void tableRotationTest02() throws IOException, InterruptedException { }) @Test public void tableRotationTest03() throws IOException, InterruptedException { - String outFileName = destinationFolder + "tableRotationTest03.pdf"; - String cmpFileName = sourceFolder + cmpPrefix + "tableRotationTest03.pdf"; + String outFileName = DESTINATION_FOLDER + "tableRotationTest03.pdf"; + String cmpFileName = SOURCE_FOLDER + cmpPrefix + "tableRotationTest03.pdf"; PdfDocument pdfDoc = new PdfDocument(new PdfWriter(outFileName)); Document doc = new Document(pdfDoc); @@ -386,13 +393,13 @@ public void tableRotationTest03() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test public void cellRotationTest01() throws IOException, InterruptedException { - String outFileName = destinationFolder + "cellRotationTest01.pdf"; - String cmpFileName = sourceFolder + cmpPrefix + "cellRotationTest01.pdf"; + String outFileName = DESTINATION_FOLDER + "cellRotationTest01.pdf"; + String cmpFileName = SOURCE_FOLDER + cmpPrefix + "cellRotationTest01.pdf"; PdfDocument pdfDoc = new PdfDocument(new PdfWriter(outFileName)); Document doc = new Document(pdfDoc); @@ -407,13 +414,13 @@ public void cellRotationTest01() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test public void cellRotationTest02() throws IOException, InterruptedException { - String outFileName = destinationFolder + "cellRotationTest02.pdf"; - String cmpFileName = sourceFolder + cmpPrefix + "cellRotationTest02.pdf"; + String outFileName = DESTINATION_FOLDER + "cellRotationTest02.pdf"; + String cmpFileName = SOURCE_FOLDER + cmpPrefix + "cellRotationTest02.pdf"; PdfDocument pdfDoc = new PdfDocument(new PdfWriter(outFileName)); Document doc = new Document(pdfDoc); @@ -427,13 +434,13 @@ public void cellRotationTest02() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test public void cellRotationTest03() throws IOException, InterruptedException { - String outFileName = destinationFolder + "cellRotationTest03.pdf"; - String cmpFileName = sourceFolder + cmpPrefix + "cellRotationTest03.pdf"; + String outFileName = DESTINATION_FOLDER + "cellRotationTest03.pdf"; + String cmpFileName = SOURCE_FOLDER + cmpPrefix + "cellRotationTest03.pdf"; PdfDocument pdfDoc = new PdfDocument(new PdfWriter(outFileName)); Document doc = new Document(pdfDoc); @@ -447,13 +454,13 @@ public void cellRotationTest03() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test public void cellRotationDependsOnNeighbourCell() throws IOException, InterruptedException { - String outFileName = destinationFolder + "cellRotationDependsOnNeighbourCell.pdf"; - String cmpFileName = sourceFolder + cmpPrefix + "cellRotationDependsOnNeighbourCell.pdf"; + String outFileName = DESTINATION_FOLDER + "cellRotationDependsOnNeighbourCell.pdf"; + String cmpFileName = SOURCE_FOLDER + cmpPrefix + "cellRotationDependsOnNeighbourCell.pdf"; PdfDocument pdfDoc = new PdfDocument(new PdfWriter(outFileName)); Document doc = new Document(pdfDoc, new PageSize(300, 180)); @@ -467,15 +474,15 @@ public void cellRotationDependsOnNeighbourCell() throws IOException, Interrupted doc.add(createTable(100)); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test // TODO DEVSIX-5029 Content of the first cell is missing public void cellRotationParagraphIsGone() throws IOException, InterruptedException { String testName = "cellRotationParagraphIsGone.pdf"; - String outFileName = destinationFolder + testName; - String cmpFileName = sourceFolder + cmpPrefix + testName; + String outFileName = DESTINATION_FOLDER + testName; + String cmpFileName = SOURCE_FOLDER + cmpPrefix + testName; PdfDocument pdf = new PdfDocument(new PdfWriter(outFileName)); Document doc = new Document(pdf); @@ -495,7 +502,7 @@ public void cellRotationParagraphIsGone() throws IOException, InterruptedExcepti doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @@ -516,8 +523,8 @@ private Table createTable(float height) { @Test public void divRotationTest01() throws IOException, InterruptedException { - String outFileName = destinationFolder + "divRotationTest01.pdf"; - String cmpFileName = sourceFolder + cmpPrefix + "divRotationTest01.pdf"; + String outFileName = DESTINATION_FOLDER + "divRotationTest01.pdf"; + String cmpFileName = SOURCE_FOLDER + cmpPrefix + "divRotationTest01.pdf"; PdfDocument pdfDoc = new PdfDocument(new PdfWriter(outFileName)); Document doc = new Document(pdfDoc); @@ -532,7 +539,7 @@ public void divRotationTest01() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @LogMessages(messages = { @@ -540,8 +547,8 @@ public void divRotationTest01() throws IOException, InterruptedException { }) @Test public void divRotationTest02() throws IOException, InterruptedException { - String outFileName = destinationFolder + "divRotationTest02.pdf"; - String cmpFileName = sourceFolder + cmpPrefix + "divRotationTest02.pdf"; + String outFileName = DESTINATION_FOLDER + "divRotationTest02.pdf"; + String cmpFileName = SOURCE_FOLDER + cmpPrefix + "divRotationTest02.pdf"; PdfDocument pdfDoc = new PdfDocument(new PdfWriter(outFileName)); Document doc = new Document(pdfDoc); @@ -559,13 +566,13 @@ public void divRotationTest02() throws IOException, InterruptedException { doc.add(new Div().add(new Paragraph(extremelyLongText)).setRotationAngle(Math.PI / 4)); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test public void listRotationTest01() throws IOException, InterruptedException { - String outFileName = destinationFolder + "listRotationTest01.pdf"; - String cmpFileName = sourceFolder + cmpPrefix + "listRotationTest01.pdf"; + String outFileName = DESTINATION_FOLDER + "listRotationTest01.pdf"; + String cmpFileName = SOURCE_FOLDER + cmpPrefix + "listRotationTest01.pdf"; PdfDocument pdfDoc = new PdfDocument(new PdfWriter(outFileName)); Document doc = new Document(pdfDoc); @@ -582,7 +589,7 @@ public void listRotationTest01() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @@ -591,8 +598,8 @@ public void listRotationTest01() throws IOException, InterruptedException { }) @Test public void listRotationTest02() throws IOException, InterruptedException { - String outFileName = destinationFolder + "listRotationTest02.pdf"; - String cmpFileName = sourceFolder + cmpPrefix + "listRotationTest02.pdf"; + String outFileName = DESTINATION_FOLDER + "listRotationTest02.pdf"; + String cmpFileName = SOURCE_FOLDER + cmpPrefix + "listRotationTest02.pdf"; PdfDocument pdfDoc = new PdfDocument(new PdfWriter(outFileName)); Document doc = new Document(pdfDoc); @@ -612,13 +619,13 @@ public void listRotationTest02() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test public void alignedTextRotationTest01() throws IOException, InterruptedException { - String outFileName = destinationFolder + "alignedTextRotationTest01.pdf"; - String cmpFileName = sourceFolder + cmpPrefix + "alignedTextRotationTest01.pdf"; + String outFileName = DESTINATION_FOLDER + "alignedTextRotationTest01.pdf"; + String cmpFileName = SOURCE_FOLDER + cmpPrefix + "alignedTextRotationTest01.pdf"; PdfDocument pdfDoc = new PdfDocument(new PdfWriter(outFileName)); Document doc = new Document(pdfDoc); @@ -634,13 +641,13 @@ public void alignedTextRotationTest01() throws IOException, InterruptedException doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test public void innerRotationTest01() throws IOException, InterruptedException { - String outFileName = destinationFolder + "innerRotationTest01.pdf"; - String cmpFileName = sourceFolder + cmpPrefix + "innerRotationTest01.pdf"; + String outFileName = DESTINATION_FOLDER + "innerRotationTest01.pdf"; + String cmpFileName = SOURCE_FOLDER + cmpPrefix + "innerRotationTest01.pdf"; PdfDocument pdfDoc = new PdfDocument(new PdfWriter(outFileName)); Document doc = new Document(pdfDoc); @@ -658,7 +665,7 @@ public void innerRotationTest01() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @LogMessages(messages = { @@ -666,8 +673,8 @@ public void innerRotationTest01() throws IOException, InterruptedException { }) @Test public void innerRotationTest02() throws IOException, InterruptedException { - String outFileName = destinationFolder + "innerRotationTest02.pdf"; - String cmpFileName = sourceFolder + cmpPrefix + "innerRotationTest02.pdf"; + String outFileName = DESTINATION_FOLDER + "innerRotationTest02.pdf"; + String cmpFileName = SOURCE_FOLDER + cmpPrefix + "innerRotationTest02.pdf"; PdfDocument pdfDoc = new PdfDocument(new PdfWriter(outFileName)); Document doc = new Document(pdfDoc, new PageSize(6400, 6400)); @@ -689,13 +696,13 @@ public void innerRotationTest02() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test public void fixedWidthRotationTest01() throws IOException, InterruptedException { - String outFileName = destinationFolder + "fixedWidthRotationTest01.pdf"; - String cmpFileName = sourceFolder + cmpPrefix + "fixedWidthRotationTest01.pdf"; + String outFileName = DESTINATION_FOLDER + "fixedWidthRotationTest01.pdf"; + String cmpFileName = SOURCE_FOLDER + cmpPrefix + "fixedWidthRotationTest01.pdf"; Document doc = new Document(new PdfDocument(new PdfWriter(outFileName))); Text text = new Text("Hello. I am a fairly long paragraph. I really want you to process me correctly. You heard that? Correctly!!! Even if you will have to wrap me."); @@ -710,13 +717,13 @@ public void fixedWidthRotationTest01() throws IOException, InterruptedException doc.add(d.add(p)); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test public void fixedWidthRotationTest02() throws IOException, InterruptedException { - String outFileName = destinationFolder + "fixedWidthRotationTest02.pdf"; - String cmpFileName = sourceFolder + cmpPrefix + "fixedWidthRotationTest02.pdf"; + String outFileName = DESTINATION_FOLDER + "fixedWidthRotationTest02.pdf"; + String cmpFileName = SOURCE_FOLDER + cmpPrefix + "fixedWidthRotationTest02.pdf"; Document doc = new Document(new PdfDocument(new PdfWriter(outFileName))); Text text = new Text("Hello. I am a fairly long paragraph. I really want you to process me correctly. You heard that? Correctly!!! Even if you will have to wrap me."); @@ -731,13 +738,13 @@ public void fixedWidthRotationTest02() throws IOException, InterruptedException doc.add(d.add(p)); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test public void fixedWidthRotationTest03() throws IOException, InterruptedException { - String outFileName = destinationFolder + "fixedWidthRotationTest03.pdf"; - String cmpFileName = sourceFolder + cmpPrefix + "fixedWidthRotationTest03.pdf"; + String outFileName = DESTINATION_FOLDER + "fixedWidthRotationTest03.pdf"; + String cmpFileName = SOURCE_FOLDER + cmpPrefix + "fixedWidthRotationTest03.pdf"; Document doc = new Document(new PdfDocument(new PdfWriter(outFileName))); Text text = new Text("Hello. I am a fairly long paragraph. I really want you to process me correctly. You heard that? Correctly!!! Even if you will have to wrap me."); @@ -752,17 +759,17 @@ public void fixedWidthRotationTest03() throws IOException, InterruptedException doc.add(d.add(d1)); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test - public void ImageInRotatedBlockTest01() throws IOException, InterruptedException { - String outFileName = destinationFolder + "imageInRotatedBlockTest01.pdf"; - String cmpFileName = sourceFolder + "cmp_imageInRotatedBlockTest01.pdf"; + public void imageInRotatedBlockTest01() throws IOException, InterruptedException { + String outFileName = DESTINATION_FOLDER + "imageInRotatedBlockTest01.pdf"; + String cmpFileName = SOURCE_FOLDER + "cmp_imageInRotatedBlockTest01.pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); Document doc = new Document(pdfDocument); - Image image = new Image(ImageDataFactory.create(sourceFolder + "Desert.jpg")); + Image image = new Image(ImageDataFactory.create(SOURCE_FOLDER + "Desert.jpg")); image.setWidth(200); Div div = new Div(); @@ -774,7 +781,7 @@ public void ImageInRotatedBlockTest01() throws IOException, InterruptedException doc.add(new Paragraph("Hello!!!").setBackgroundColor(ColorConstants.RED)); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -782,13 +789,13 @@ public void ImageInRotatedBlockTest01() throws IOException, InterruptedException @LogMessage(messageTemplate = IoLogMessageConstant.CLIP_ELEMENT), @LogMessage(messageTemplate = IoLogMessageConstant.ROTATION_WAS_NOT_CORRECTLY_PROCESSED_FOR_RENDERER, count = 2) }) - public void ImageInRotatedBlockTest02() throws IOException, InterruptedException { - String outFileName = destinationFolder + "imageInRotatedBlockTest02.pdf"; - String cmpFileName = sourceFolder + "cmp_imageInRotatedBlockTest02.pdf"; + public void imageInRotatedBlockTest02() throws IOException, InterruptedException { + String outFileName = DESTINATION_FOLDER + "imageInRotatedBlockTest02.pdf"; + String cmpFileName = SOURCE_FOLDER + "cmp_imageInRotatedBlockTest02.pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); Document doc = new Document(pdfDocument); - Image image = new Image(ImageDataFactory.create(sourceFolder + "Desert.jpg")); + Image image = new Image(ImageDataFactory.create(SOURCE_FOLDER + "Desert.jpg")); image.setWidth(200); Div div = new Div(); @@ -801,13 +808,13 @@ public void ImageInRotatedBlockTest02() throws IOException, InterruptedException doc.add(new Paragraph("Hello!!!").setBackgroundColor(ColorConstants.RED)); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test public void blockWithBorderBoxSizingTest01() throws IOException, InterruptedException { - String outFileName = destinationFolder + "blockWithBorderBoxSizingTest01.pdf"; - String cmpFileName = sourceFolder + "cmp_blockWithBorderBoxSizingTest01.pdf"; + String outFileName = DESTINATION_FOLDER + "blockWithBorderBoxSizingTest01.pdf"; + String cmpFileName = SOURCE_FOLDER + "cmp_blockWithBorderBoxSizingTest01.pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); Document doc = new Document(pdfDocument); @@ -823,14 +830,14 @@ public void blockWithBorderBoxSizingTest01() throws IOException, InterruptedExce doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test //TODO: currently is incorrect. See DEVSIX-989 public void marginsRotatedTest01() throws IOException, InterruptedException { - String outFileName = destinationFolder + "marginsRotatedTest01.pdf"; - String cmpFileName = sourceFolder + cmpPrefix + "marginsRotatedTest01.pdf"; + String outFileName = DESTINATION_FOLDER + "marginsRotatedTest01.pdf"; + String cmpFileName = SOURCE_FOLDER + cmpPrefix + "marginsRotatedTest01.pdf"; Document doc = new Document(new PdfDocument(new PdfWriter(outFileName))); Text text = new Text("Hello. I am a fairly long paragraph. I really want you to process me correctly. You heard that? Correctly!!! Even if you will have to wrap me."); @@ -845,14 +852,14 @@ public void marginsRotatedTest01() throws IOException, InterruptedException { doc.add(d.add(d1)); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test //TODO: currently is incorrect. See DEVSIX-989 public void marginsRotatedTest02() throws IOException, InterruptedException { - String outFileName = destinationFolder + "marginsRotatedTest02.pdf"; - String cmpFileName = sourceFolder + cmpPrefix + "marginsRotatedTest02.pdf"; + String outFileName = DESTINATION_FOLDER + "marginsRotatedTest02.pdf"; + String cmpFileName = SOURCE_FOLDER + cmpPrefix + "marginsRotatedTest02.pdf"; Document doc = new Document(new PdfDocument(new PdfWriter(outFileName))); doc.setProperty(Property.COLLAPSING_MARGINS, true); @@ -868,14 +875,14 @@ public void marginsRotatedTest02() throws IOException, InterruptedException { doc.add(d.add(d1).add(new Paragraph("Hello").setMargin(50).setBorder(new SolidBorder(ColorConstants.GREEN, 5)))); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test //TODO: update cmp file after fixing DEVSIX-4458 public void zeroDegreeRotatedWithAlignmentParagraphInDivTest() throws IOException, InterruptedException { - String outFileName = destinationFolder + "zeroDegreeRotatedWithAlignmentParagraphInDiv.pdf"; - String cmpFileName = sourceFolder + "cmp_zeroDegreeRotatedWithAlignmentParagraphInDiv.pdf"; + String outFileName = DESTINATION_FOLDER + "zeroDegreeRotatedWithAlignmentParagraphInDiv.pdf"; + String cmpFileName = SOURCE_FOLDER + "cmp_zeroDegreeRotatedWithAlignmentParagraphInDiv.pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); @@ -897,14 +904,14 @@ public void zeroDegreeRotatedWithAlignmentParagraphInDivTest() throws IOExceptio doc.add(div); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER)); } @Test //TODO: update cmp file after fixing DEVSIX-4458 public void rotated180DegreesWithAlignmentParagraphInDivTest() throws IOException, InterruptedException { - String outFileName = destinationFolder + "rotated180DegreesWithAlignmentParagraphInDiv.pdf"; - String cmpFileName = sourceFolder + "cmp_rotated180DegreesWithAlignmentParagraphInDiv.pdf"; + String outFileName = DESTINATION_FOLDER + "rotated180DegreesWithAlignmentParagraphInDiv.pdf"; + String cmpFileName = SOURCE_FOLDER + "cmp_rotated180DegreesWithAlignmentParagraphInDiv.pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); @@ -926,14 +933,14 @@ public void rotated180DegreesWithAlignmentParagraphInDivTest() throws IOExceptio doc.add(div); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER)); } @Test //TODO: update cmp file after fixing DEVSIX-4458 public void rotated90DegreesWithAlignmentParagraphInDivTest() throws IOException, InterruptedException { - String outFileName = destinationFolder + "rotated90DegreesWithAlignmentParagraphInDiv.pdf"; - String cmpFileName = sourceFolder + "cmp_rotated90DegreesWithAlignmentParagraphInDiv.pdf"; + String outFileName = DESTINATION_FOLDER + "rotated90DegreesWithAlignmentParagraphInDiv.pdf"; + String cmpFileName = SOURCE_FOLDER + "cmp_rotated90DegreesWithAlignmentParagraphInDiv.pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); @@ -955,14 +962,14 @@ public void rotated90DegreesWithAlignmentParagraphInDivTest() throws IOException doc.add(div); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER)); } @Test //TODO: update cmp file after fixing DEVSIX-4458 public void rotatedWithAlignmentCellInTableTest() throws IOException, InterruptedException { - String outFileName = destinationFolder + "rotatedWithAlignmentCellInTable.pdf"; - String cmpFileName = sourceFolder + "cmp_rotatedWithAlignmentCellInTable.pdf"; + String outFileName = DESTINATION_FOLDER + "rotatedWithAlignmentCellInTable.pdf"; + String cmpFileName = SOURCE_FOLDER + "cmp_rotatedWithAlignmentCellInTable.pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); @@ -984,7 +991,44 @@ public void rotatedWithAlignmentCellInTableTest() throws IOException, Interrupte doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER)); + } + + @Test + public void ignorePageRotationForContentTest() throws IOException, InterruptedException { + String inputFile = SOURCE_FOLDER + "rotated.pdf"; + String compareFile = SOURCE_FOLDER + "cmp_ignorePageRotationForContent.pdf"; + String outputFile = DESTINATION_FOLDER + "ignorePageRotationForContent.pdf"; + + try (PdfDocument pdfDoc = new PdfDocument(new PdfReader(inputFile), new PdfWriter(outputFile)); + Document doc = new Document(pdfDoc)) { + + PdfExtGState gs1 = new PdfExtGState().setFillOpacity(0.5f); + PdfFont font = PdfFontFactory.createFont(StandardFonts.HELVETICA); + Paragraph paragraph = new Paragraph("My watermark (text)") + .setFont(font) + .setFontSize(30); + + PdfPage pdfPage = pdfDoc.getPage(1); + Rectangle pageSize = pdfPage.getPageSizeWithRotation(); + + // When "true": in case the page has a rotation, then new content will be automatically rotated in the + // opposite direction. On the rotated page this would look as if new content ignores page rotation. + pdfPage.setIgnorePageRotationForContent(true); + + float x = (pageSize.getLeft() + pageSize.getRight()) / 2; + float y = (pageSize.getTop() + pageSize.getBottom()) / 2; + PdfCanvas over = new PdfCanvas(pdfPage); + over.saveState(); + over.setExtGState(gs1); + // Each showTextAligned call creates new PdfCanvas instance for the same page. + doc.showTextAligned(paragraph, x, y + 100, 1, TextAlignment.CENTER, VerticalAlignment.TOP, 0); + doc.showTextAligned(paragraph, x, y, 1, TextAlignment.CENTER, VerticalAlignment.TOP, 0); + doc.showTextAligned(paragraph, x, y - 100, 1, TextAlignment.CENTER, VerticalAlignment.TOP, 0); + over.restoreState(); + } + Assertions.assertNull(new CompareTool().compareByContent(outputFile, compareFile, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareVisually(outputFile, compareFile, DESTINATION_FOLDER, "diff_")); } private void drawCross(PdfCanvas canvas, float x, float y) { diff --git a/layout/src/test/java/com/itextpdf/layout/SimpleTextExtractionStrategyTest.java b/layout/src/test/java/com/itextpdf/layout/SimpleTextExtractionStrategyTest.java index 0bc7c42695..f73f1ed197 100644 --- a/layout/src/test/java/com/itextpdf/layout/SimpleTextExtractionStrategyTest.java +++ b/layout/src/test/java/com/itextpdf/layout/SimpleTextExtractionStrategyTest.java @@ -42,17 +42,16 @@ This file is part of the iText (R) project. import com.itextpdf.layout.element.Image; import com.itextpdf.layout.element.Paragraph; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class SimpleTextExtractionStrategyTest extends ExtendedITextTest { private static final String sourceFolder = "./src/test/resources/com/itextpdf/layout/SimpleTextExtractionStrategyTest/"; @@ -68,7 +67,7 @@ public ITextExtractionStrategy createRenderListenerForTest() { public void testCoLinnearText() throws Exception { byte[] bytes = createPdfWithRotatedText(TEXT1, TEXT2, 0, false, 0); - Assert.assertEquals(TEXT1 + TEXT2, PdfTextExtractor.getTextFromPage(new PdfDocument(new PdfReader(new ByteArrayInputStream(bytes))).getPage(1), + Assertions.assertEquals(TEXT1 + TEXT2, PdfTextExtractor.getTextFromPage(new PdfDocument(new PdfReader(new ByteArrayInputStream(bytes))).getPage(1), createRenderListenerForTest())); } @@ -77,7 +76,7 @@ public void testCoLinnearTextWithSpace() throws Exception { byte[] bytes = createPdfWithRotatedText(TEXT1, TEXT2, 0, false, 2); //saveBytesToFile(bytes, new File("c:/temp/test.pdf")); - Assert.assertEquals(TEXT1 + " " + TEXT2, PdfTextExtractor.getTextFromPage(new PdfDocument(new PdfReader(new ByteArrayInputStream(bytes))).getPage(1), + Assertions.assertEquals(TEXT1 + " " + TEXT2, PdfTextExtractor.getTextFromPage(new PdfDocument(new PdfReader(new ByteArrayInputStream(bytes))).getPage(1), createRenderListenerForTest())); } @@ -88,7 +87,7 @@ public void testCoLinnearTextEndingWithSpaceCharacter() throws Exception { //TestResourceUtils.openBytesAsPdf(bytes); - Assert.assertEquals(TEXT1 + " " + TEXT2, PdfTextExtractor.getTextFromPage(new PdfDocument(new PdfReader(new ByteArrayInputStream(bytes))).getPage(1), + Assertions.assertEquals(TEXT1 + " " + TEXT2, PdfTextExtractor.getTextFromPage(new PdfDocument(new PdfReader(new ByteArrayInputStream(bytes))).getPage(1), createRenderListenerForTest())); } @@ -97,7 +96,7 @@ public void testCoLinnearTextEndingWithSpaceCharacter() throws Exception { public void testUnRotatedText() throws Exception { byte[] bytes = createPdfWithRotatedText(TEXT1, TEXT2, 0, true, -20); - Assert.assertEquals(TEXT1 + "\n" + TEXT2, PdfTextExtractor.getTextFromPage(new PdfDocument(new PdfReader(new ByteArrayInputStream(bytes))).getPage(1), + Assertions.assertEquals(TEXT1 + "\n" + TEXT2, PdfTextExtractor.getTextFromPage(new PdfDocument(new PdfReader(new ByteArrayInputStream(bytes))).getPage(1), createRenderListenerForTest())); } @@ -106,7 +105,7 @@ public void testUnRotatedText() throws Exception { public void testRotatedText() throws Exception { byte[] bytes = createPdfWithRotatedText(TEXT1, TEXT2, -90, true, -20); - Assert.assertEquals(TEXT1 + "\n" + TEXT2, PdfTextExtractor.getTextFromPage(new PdfDocument(new PdfReader(new ByteArrayInputStream(bytes))).getPage(1), + Assertions.assertEquals(TEXT1 + "\n" + TEXT2, PdfTextExtractor.getTextFromPage(new PdfDocument(new PdfReader(new ByteArrayInputStream(bytes))).getPage(1), createRenderListenerForTest())); } @@ -116,7 +115,7 @@ public void testRotatedText2() throws Exception { byte[] bytes = createPdfWithRotatedText(TEXT1, TEXT2, 90, true, -20); //TestResourceUtils.saveBytesToFile(bytes, new File("C:/temp/out.pdf")); - Assert.assertEquals(TEXT1 + "\n" + TEXT2, PdfTextExtractor.getTextFromPage(new PdfDocument(new PdfReader(new ByteArrayInputStream(bytes))).getPage(1), + Assertions.assertEquals(TEXT1 + "\n" + TEXT2, PdfTextExtractor.getTextFromPage(new PdfDocument(new PdfReader(new ByteArrayInputStream(bytes))).getPage(1), createRenderListenerForTest())); } @@ -125,7 +124,7 @@ public void testRotatedText2() throws Exception { public void testPartiallyRotatedText() throws Exception { byte[] bytes = createPdfWithRotatedText(TEXT1, TEXT2, 33, true, -20); - Assert.assertEquals(TEXT1 + "\n" + TEXT2, PdfTextExtractor.getTextFromPage(new PdfDocument(new PdfReader(new ByteArrayInputStream(bytes))).getPage(1), + Assertions.assertEquals(TEXT1 + "\n" + TEXT2, PdfTextExtractor.getTextFromPage(new PdfDocument(new PdfReader(new ByteArrayInputStream(bytes))).getPage(1), createRenderListenerForTest())); } @@ -134,7 +133,7 @@ public void testPartiallyRotatedText() throws Exception { public void testWordSpacingCausedByExplicitGlyphPositioning() throws Exception { byte[] bytes = createPdfWithArrayText(TEXT1, TEXT2, 250); - Assert.assertEquals(TEXT1 + " " + TEXT2, PdfTextExtractor.getTextFromPage(new PdfDocument(new PdfReader(new ByteArrayInputStream(bytes))).getPage(1), + Assertions.assertEquals(TEXT1 + " " + TEXT2, PdfTextExtractor.getTextFromPage(new PdfDocument(new PdfReader(new ByteArrayInputStream(bytes))).getPage(1), createRenderListenerForTest())); } @@ -168,7 +167,7 @@ public void testWordSpacingCausedByExplicitGlyphPositioning2() throws Exception byte[] bytes = createPdfWithArrayText(textArray); - Assert.assertEquals("San Diego Chapter", PdfTextExtractor.getTextFromPage(new PdfDocument(new PdfReader(new ByteArrayInputStream(bytes))).getPage(1), + Assertions.assertEquals("San Diego Chapter", PdfTextExtractor.getTextFromPage(new PdfDocument(new PdfReader(new ByteArrayInputStream(bytes))).getPage(1), createRenderListenerForTest())); } @@ -177,7 +176,7 @@ public void testWordSpacingCausedByExplicitGlyphPositioning2() throws Exception public void testTrailingSpace() throws Exception { byte[] bytes = createPdfWithRotatedText(TEXT1 + " ", TEXT2, 0, false, 6); - Assert.assertEquals(TEXT1 + " " + TEXT2, PdfTextExtractor.getTextFromPage(new PdfDocument(new PdfReader(new ByteArrayInputStream(bytes))).getPage(1), + Assertions.assertEquals(TEXT1 + " " + TEXT2, PdfTextExtractor.getTextFromPage(new PdfDocument(new PdfReader(new ByteArrayInputStream(bytes))).getPage(1), createRenderListenerForTest())); } @@ -185,7 +184,7 @@ public void testTrailingSpace() throws Exception { public void testLeadingSpace() throws Exception { byte[] bytes = createPdfWithRotatedText(TEXT1, " " + TEXT2, 0, false, 6); - Assert.assertEquals(TEXT1 + " " + TEXT2, PdfTextExtractor.getTextFromPage(new PdfDocument(new PdfReader(new ByteArrayInputStream(bytes))).getPage(1), + Assertions.assertEquals(TEXT1 + " " + TEXT2, PdfTextExtractor.getTextFromPage(new PdfDocument(new PdfReader(new ByteArrayInputStream(bytes))).getPage(1), createRenderListenerForTest())); } @@ -195,7 +194,7 @@ public void testExtractXObjectText() throws Exception { byte[] bytes = createPdfWithXObject(text1); String text = PdfTextExtractor.getTextFromPage(new PdfDocument(new PdfReader(new ByteArrayInputStream(bytes))).getPage(1), createRenderListenerForTest()); - Assert.assertTrue("extracted text (" + text + ") must contain '" + text1 + "'", text.contains(text1)); + Assertions.assertTrue(text.contains(text1), "extracted text (" + text + ") must contain '" + text1 + "'"); } @Test @@ -206,7 +205,7 @@ public void extractFromPage229() throws IOException { String text1 = PdfTextExtractor.getTextFromPage(pdfDocument.getPage(1), new SimpleTextExtractionStrategy()); String text2 = PdfTextExtractor.getTextFromPage(pdfDocument.getPage(1), new GlyphTextEventListener(new SimpleTextExtractionStrategy())); pdfDocument.close(); - Assert.assertEquals(text1, text2); + Assertions.assertEquals(text1, text2); } @Test @@ -221,7 +220,7 @@ public void extractFromIsoTc171() throws IOException { "\n" + PdfTextExtractor.getTextFromPage(pdfDocument.getPage(2), new GlyphTextEventListener(new SimpleTextExtractionStrategy())); pdfDocument.close(); - Assert.assertEquals(text1, text2); + Assertions.assertEquals(text1, text2); } diff --git a/layout/src/test/java/com/itextpdf/layout/StyleUnitTest.java b/layout/src/test/java/com/itextpdf/layout/StyleUnitTest.java index 2d0d030180..787c11c518 100644 --- a/layout/src/test/java/com/itextpdf/layout/StyleUnitTest.java +++ b/layout/src/test/java/com/itextpdf/layout/StyleUnitTest.java @@ -26,13 +26,12 @@ This file is part of the iText (R) project. import com.itextpdf.layout.properties.UnitValue; import com.itextpdf.layout.properties.VerticalAlignment; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class StyleUnitTest extends ExtendedITextTest { public static float EPS = 0.0001f; @@ -46,20 +45,20 @@ public void setAndGetMarginsTest() { Style style = new Style(); - Assert.assertNull(style.getMarginTop()); - Assert.assertNull(style.getMarginRight()); - Assert.assertNull(style.getMarginBottom()); - Assert.assertNull(style.getMarginLeft()); + Assertions.assertNull(style.getMarginTop()); + Assertions.assertNull(style.getMarginRight()); + Assertions.assertNull(style.getMarginBottom()); + Assertions.assertNull(style.getMarginLeft()); style.setMargins(expectedMarginTop, expectedMarginRight, expectedMarginBottom, expectedMarginLeft); - Assert.assertEquals(UnitValue.createPointValue(expectedMarginTop), + Assertions.assertEquals(UnitValue.createPointValue(expectedMarginTop), style.getMarginTop()); - Assert.assertEquals(UnitValue.createPointValue(expectedMarginRight), + Assertions.assertEquals(UnitValue.createPointValue(expectedMarginRight), style.getMarginRight()); - Assert.assertEquals(UnitValue.createPointValue(expectedMarginBottom), + Assertions.assertEquals(UnitValue.createPointValue(expectedMarginBottom), style.getMarginBottom()); - Assert.assertEquals(UnitValue.createPointValue(expectedMarginLeft), + Assertions.assertEquals(UnitValue.createPointValue(expectedMarginLeft), style.getMarginLeft()); } @@ -69,17 +68,17 @@ public void setMarginTest() { Style style = new Style(); - Assert.assertNull(style.getMarginTop()); - Assert.assertNull(style.getMarginRight()); - Assert.assertNull(style.getMarginBottom()); - Assert.assertNull(style.getMarginLeft()); + Assertions.assertNull(style.getMarginTop()); + Assertions.assertNull(style.getMarginRight()); + Assertions.assertNull(style.getMarginBottom()); + Assertions.assertNull(style.getMarginLeft()); style.setMargin(expectedMargin); - Assert.assertEquals(UnitValue.createPointValue(expectedMargin), style.getMarginTop()); - Assert.assertEquals(UnitValue.createPointValue(expectedMargin), style.getMarginRight()); - Assert.assertEquals(UnitValue.createPointValue(expectedMargin), style.getMarginBottom()); - Assert.assertEquals(UnitValue.createPointValue(expectedMargin), style.getMarginLeft()); + Assertions.assertEquals(UnitValue.createPointValue(expectedMargin), style.getMarginTop()); + Assertions.assertEquals(UnitValue.createPointValue(expectedMargin), style.getMarginRight()); + Assertions.assertEquals(UnitValue.createPointValue(expectedMargin), style.getMarginBottom()); + Assertions.assertEquals(UnitValue.createPointValue(expectedMargin), style.getMarginLeft()); } @Test @@ -88,11 +87,11 @@ public void getMarginLeftTest() { Style style = new Style(); - Assert.assertNull(style.getMarginLeft()); + Assertions.assertNull(style.getMarginLeft()); style.setMarginLeft(expLeftMargin); - Assert.assertEquals(UnitValue.createPointValue(expLeftMargin), style.getMarginLeft()); + Assertions.assertEquals(UnitValue.createPointValue(expLeftMargin), style.getMarginLeft()); } @Test @@ -101,11 +100,11 @@ public void getMarginRightTest() { Style style = new Style(); - Assert.assertNull(style.getMarginRight()); + Assertions.assertNull(style.getMarginRight()); style.setMarginRight(expRightMargin); - Assert.assertEquals(UnitValue.createPointValue(expRightMargin), style.getMarginRight()); + Assertions.assertEquals(UnitValue.createPointValue(expRightMargin), style.getMarginRight()); } @Test @@ -114,11 +113,11 @@ public void getMarginTopTest() { Style style = new Style(); - Assert.assertNull(style.getMarginTop()); + Assertions.assertNull(style.getMarginTop()); style.setMarginTop(expTopMargin); - Assert.assertEquals(UnitValue.createPointValue(expTopMargin), style.getMarginTop()); + Assertions.assertEquals(UnitValue.createPointValue(expTopMargin), style.getMarginTop()); } @Test @@ -127,11 +126,11 @@ public void getMarginBottomTest() { Style style = new Style(); - Assert.assertNull(style.getMarginTop()); + Assertions.assertNull(style.getMarginTop()); style.setMarginBottom(expBottomMargin); - Assert.assertEquals(UnitValue.createPointValue(expBottomMargin), style.getMarginBottom()); + Assertions.assertEquals(UnitValue.createPointValue(expBottomMargin), style.getMarginBottom()); } @Test @@ -140,11 +139,11 @@ public void getPaddingLeftTest() { Style style = new Style(); - Assert.assertNull(style.getPaddingLeft()); + Assertions.assertNull(style.getPaddingLeft()); style.setPaddingLeft(expLeftPadding); - Assert.assertEquals(UnitValue.createPointValue(expLeftPadding), style.getPaddingLeft()); + Assertions.assertEquals(UnitValue.createPointValue(expLeftPadding), style.getPaddingLeft()); } @Test @@ -153,11 +152,11 @@ public void getPaddingRightTest() { Style style = new Style(); - Assert.assertNull(style.getPaddingRight()); + Assertions.assertNull(style.getPaddingRight()); style.setPaddingRight(expRightPadding); - Assert.assertEquals(UnitValue.createPointValue(expRightPadding), style.getPaddingRight()); + Assertions.assertEquals(UnitValue.createPointValue(expRightPadding), style.getPaddingRight()); } @Test @@ -166,11 +165,11 @@ public void getPaddingTopTest() { Style style = new Style(); - Assert.assertNull(style.getPaddingTop()); + Assertions.assertNull(style.getPaddingTop()); style.setPaddingTop(expTopPadding); - Assert.assertEquals(UnitValue.createPointValue(expTopPadding), style.getPaddingTop()); + Assertions.assertEquals(UnitValue.createPointValue(expTopPadding), style.getPaddingTop()); } @Test @@ -179,11 +178,11 @@ public void getPaddingBottomTest() { Style style = new Style(); - Assert.assertNull(style.getPaddingBottom()); + Assertions.assertNull(style.getPaddingBottom()); style.setPaddingBottom(expBottomPadding); - Assert.assertEquals(UnitValue.createPointValue(expBottomPadding), style.getPaddingBottom()); + Assertions.assertEquals(UnitValue.createPointValue(expBottomPadding), style.getPaddingBottom()); } @Test @@ -191,17 +190,17 @@ public void setPaddingTest() { float expPadding = 10; Style style = new Style(); - Assert.assertNull(style.getPaddingTop()); - Assert.assertNull(style.getPaddingRight()); - Assert.assertNull(style.getPaddingBottom()); - Assert.assertNull(style.getPaddingLeft()); + Assertions.assertNull(style.getPaddingTop()); + Assertions.assertNull(style.getPaddingRight()); + Assertions.assertNull(style.getPaddingBottom()); + Assertions.assertNull(style.getPaddingLeft()); style.setPadding(expPadding); - Assert.assertEquals(UnitValue.createPointValue(expPadding), style.getPaddingTop()); - Assert.assertEquals(UnitValue.createPointValue(expPadding), style.getPaddingRight()); - Assert.assertEquals(UnitValue.createPointValue(expPadding), style.getPaddingBottom()); - Assert.assertEquals(UnitValue.createPointValue(expPadding), style.getPaddingLeft()); + Assertions.assertEquals(UnitValue.createPointValue(expPadding), style.getPaddingTop()); + Assertions.assertEquals(UnitValue.createPointValue(expPadding), style.getPaddingRight()); + Assertions.assertEquals(UnitValue.createPointValue(expPadding), style.getPaddingBottom()); + Assertions.assertEquals(UnitValue.createPointValue(expPadding), style.getPaddingLeft()); } @Test @@ -213,17 +212,17 @@ public void setPaddingsTest() { Style style = new Style(); - Assert.assertNull(style.getPaddingTop()); - Assert.assertNull(style.getPaddingRight()); - Assert.assertNull(style.getPaddingBottom()); - Assert.assertNull(style.getPaddingLeft()); + Assertions.assertNull(style.getPaddingTop()); + Assertions.assertNull(style.getPaddingRight()); + Assertions.assertNull(style.getPaddingBottom()); + Assertions.assertNull(style.getPaddingLeft()); style.setPaddings(expPaddingTop, expPaddingRight, expPaddingBottom, expPaddingLeft); - Assert.assertEquals(UnitValue.createPointValue(expPaddingLeft), style.getPaddingLeft()); - Assert.assertEquals(UnitValue.createPointValue(expPaddingBottom), style.getPaddingBottom()); - Assert.assertEquals(UnitValue.createPointValue(expPaddingTop), style.getPaddingTop()); - Assert.assertEquals(UnitValue.createPointValue(expPaddingRight), style.getPaddingRight()); + Assertions.assertEquals(UnitValue.createPointValue(expPaddingLeft), style.getPaddingLeft()); + Assertions.assertEquals(UnitValue.createPointValue(expPaddingBottom), style.getPaddingBottom()); + Assertions.assertEquals(UnitValue.createPointValue(expPaddingTop), style.getPaddingTop()); + Assertions.assertEquals(UnitValue.createPointValue(expPaddingRight), style.getPaddingRight()); } @Test @@ -232,11 +231,11 @@ public void setVerticalAlignmentMiddleTest() { Style style = new Style(); - Assert.assertNull(style.getProperty(Property.VERTICAL_ALIGNMENT)); + Assertions.assertNull(style.getProperty(Property.VERTICAL_ALIGNMENT)); style.setVerticalAlignment(expectedAlignment); - Assert.assertEquals(expectedAlignment, style.getProperty(Property.VERTICAL_ALIGNMENT)); + Assertions.assertEquals(expectedAlignment, style.getProperty(Property.VERTICAL_ALIGNMENT)); } @Test @@ -245,11 +244,11 @@ public void setVerticalAlignmentTopTest() { Style style = new Style(); - Assert.assertNull(style.getProperty(Property.VERTICAL_ALIGNMENT)); + Assertions.assertNull(style.getProperty(Property.VERTICAL_ALIGNMENT)); style.setVerticalAlignment(expectedAlignment); - Assert.assertEquals(expectedAlignment, style.getProperty(Property.VERTICAL_ALIGNMENT)); + Assertions.assertEquals(expectedAlignment, style.getProperty(Property.VERTICAL_ALIGNMENT)); } @Test @@ -258,11 +257,11 @@ public void setVerticalAlignmentBottomTest() { Style style = new Style(); - Assert.assertNull(style.getProperty(Property.VERTICAL_ALIGNMENT)); + Assertions.assertNull(style.getProperty(Property.VERTICAL_ALIGNMENT)); style.setVerticalAlignment(expectedAlignment); - Assert.assertEquals(expectedAlignment, style.getProperty(Property.VERTICAL_ALIGNMENT)); + Assertions.assertEquals(expectedAlignment, style.getProperty(Property.VERTICAL_ALIGNMENT)); } @Test @@ -271,44 +270,44 @@ public void setSpacingRatioTest() { Style style = new Style(); - Assert.assertNull(style.getProperty(Property.SPACING_RATIO)); + Assertions.assertNull(style.getProperty(Property.SPACING_RATIO)); style.setSpacingRatio(expectedSpacingRatio); - Assert.assertEquals(expectedSpacingRatio, (float)style.getProperty(Property.SPACING_RATIO), EPS); + Assertions.assertEquals(expectedSpacingRatio, (float)style.getProperty(Property.SPACING_RATIO), EPS); } @Test public void setKeepTogetherTrueTest() { Style style = new Style(); - Assert.assertNull(style.getProperty(Property.KEEP_TOGETHER)); + Assertions.assertNull(style.getProperty(Property.KEEP_TOGETHER)); style.setKeepTogether(true); - Assert.assertEquals(true, style.getProperty(Property.KEEP_TOGETHER)); + Assertions.assertEquals(true, style.getProperty(Property.KEEP_TOGETHER)); } @Test public void setKeepTogetherFalseTest() { Style style = new Style(); - Assert.assertNull(style.getProperty(Property.KEEP_TOGETHER)); + Assertions.assertNull(style.getProperty(Property.KEEP_TOGETHER)); style.setKeepTogether(false); - Assert.assertEquals(false, style.getProperty(Property.KEEP_TOGETHER)); + Assertions.assertEquals(false, style.getProperty(Property.KEEP_TOGETHER)); } @Test public void isKeepTogetherTest() { Style style = new Style(); - Assert.assertNull(style.getProperty(Property.KEEP_TOGETHER)); + Assertions.assertNull(style.getProperty(Property.KEEP_TOGETHER)); style.setKeepTogether(true); - Assert.assertEquals(true, style.isKeepTogether()); + Assertions.assertEquals(true, style.isKeepTogether()); } @Test @@ -317,11 +316,11 @@ public void setRotationAngleFloatTest() { Style style = new Style(); - Assert.assertNull(style.getProperty(Property.ROTATION_ANGLE)); + Assertions.assertNull(style.getProperty(Property.ROTATION_ANGLE)); style.setRotationAngle(expectedRotationAngle); - Assert.assertEquals(expectedRotationAngle, (float)style.getProperty(Property.ROTATION_ANGLE), EPS); + Assertions.assertEquals(expectedRotationAngle, (float)style.getProperty(Property.ROTATION_ANGLE), EPS); } @Test @@ -330,11 +329,11 @@ public void setRotationAngleDoubleTest() { Style style = new Style(); - Assert.assertNull(style.getProperty(Property.ROTATION_ANGLE)); + Assertions.assertNull(style.getProperty(Property.ROTATION_ANGLE)); style.setRotationAngle(expectedRotationAngle); - Assert.assertEquals(expectedRotationAngle, (float)style.getProperty(Property.ROTATION_ANGLE), EPS); + Assertions.assertEquals(expectedRotationAngle, (float)style.getProperty(Property.ROTATION_ANGLE), EPS); } @Test @@ -343,11 +342,11 @@ public void setAndGetWidthTest() { Style style = new Style(); - Assert.assertNull(style.getWidth()); + Assertions.assertNull(style.getWidth()); style.setWidth(expectedWidth); - Assert.assertEquals(UnitValue.createPointValue(expectedWidth), style.getWidth()); + Assertions.assertEquals(UnitValue.createPointValue(expectedWidth), style.getWidth()); } @Test @@ -356,11 +355,11 @@ public void setAndGetWidthUnitValueTest() { Style style = new Style(); - Assert.assertNull(style.getWidth()); + Assertions.assertNull(style.getWidth()); style.setWidth(UnitValue.createPointValue(expectedWidth)); - Assert.assertEquals(UnitValue.createPointValue(expectedWidth), style.getWidth()); + Assertions.assertEquals(UnitValue.createPointValue(expectedWidth), style.getWidth()); } @Test @@ -369,11 +368,11 @@ public void setAndGetHeightTest() { Style style = new Style(); - Assert.assertNull(style.getHeight()); + Assertions.assertNull(style.getHeight()); style.setHeight(expectedHeight); - Assert.assertEquals(UnitValue.createPointValue(expectedHeight), style.getHeight()); + Assertions.assertEquals(UnitValue.createPointValue(expectedHeight), style.getHeight()); } @Test @@ -382,11 +381,11 @@ public void setAndGetHeightUnitValueTest() { Style style = new Style(); - Assert.assertNull(style.getHeight()); + Assertions.assertNull(style.getHeight()); style.setHeight(UnitValue.createPointValue(expectedHeight)); - Assert.assertEquals(UnitValue.createPointValue(expectedHeight), style.getHeight()); + Assertions.assertEquals(UnitValue.createPointValue(expectedHeight), style.getHeight()); } @Test @@ -395,11 +394,11 @@ public void setMaxHeightTest() { Style style = new Style(); - Assert.assertNull(style.getProperty(Property.MAX_HEIGHT)); + Assertions.assertNull(style.getProperty(Property.MAX_HEIGHT)); style.setMaxHeight(expectedMaxHeight); - Assert.assertEquals(UnitValue.createPointValue(expectedMaxHeight), style.getProperty(Property.MAX_HEIGHT)); + Assertions.assertEquals(UnitValue.createPointValue(expectedMaxHeight), style.getProperty(Property.MAX_HEIGHT)); } @Test @@ -408,11 +407,11 @@ public void setMaxHeightUnitValueTest() { Style style = new Style(); - Assert.assertNull(style.getProperty(Property.MAX_HEIGHT)); + Assertions.assertNull(style.getProperty(Property.MAX_HEIGHT)); style.setMaxHeight(UnitValue.createPointValue(expectedMaxHeight)); - Assert.assertEquals(UnitValue.createPointValue(expectedMaxHeight), style.getProperty(Property.MAX_HEIGHT)); + Assertions.assertEquals(UnitValue.createPointValue(expectedMaxHeight), style.getProperty(Property.MAX_HEIGHT)); } @Test @@ -421,11 +420,11 @@ public void setMinHeightTest() { Style style = new Style(); - Assert.assertNull(style.getProperty(Property.MIN_HEIGHT)); + Assertions.assertNull(style.getProperty(Property.MIN_HEIGHT)); style.setMinHeight(expectedMinHeight); - Assert.assertEquals(UnitValue.createPointValue(expectedMinHeight), style.getProperty(Property.MIN_HEIGHT)); + Assertions.assertEquals(UnitValue.createPointValue(expectedMinHeight), style.getProperty(Property.MIN_HEIGHT)); } @Test @@ -434,11 +433,11 @@ public void setMinHeightUnitValueTest() { Style style = new Style(); - Assert.assertNull(style.getProperty(Property.MIN_HEIGHT)); + Assertions.assertNull(style.getProperty(Property.MIN_HEIGHT)); style.setMinHeight(UnitValue.createPointValue(expectedMinHeight)); - Assert.assertEquals(UnitValue.createPointValue(expectedMinHeight), style.getProperty(Property.MIN_HEIGHT)); + Assertions.assertEquals(UnitValue.createPointValue(expectedMinHeight), style.getProperty(Property.MIN_HEIGHT)); } @Test @@ -447,11 +446,11 @@ public void setMaxWidthTest() { Style style = new Style(); - Assert.assertNull(style.getProperty(Property.MAX_WIDTH)); + Assertions.assertNull(style.getProperty(Property.MAX_WIDTH)); style.setMaxWidth(expectedMaxWidth); - Assert.assertEquals(UnitValue.createPointValue(expectedMaxWidth), style.getProperty(Property.MAX_WIDTH)); + Assertions.assertEquals(UnitValue.createPointValue(expectedMaxWidth), style.getProperty(Property.MAX_WIDTH)); } @Test @@ -460,11 +459,11 @@ public void setMaxWidthUnitValueTest() { Style style = new Style(); - Assert.assertNull(style.getProperty(Property.MAX_WIDTH)); + Assertions.assertNull(style.getProperty(Property.MAX_WIDTH)); style.setMaxWidth(UnitValue.createPointValue(expectedMaxWidth)); - Assert.assertEquals(UnitValue.createPointValue(expectedMaxWidth), style.getProperty(Property.MAX_WIDTH)); + Assertions.assertEquals(UnitValue.createPointValue(expectedMaxWidth), style.getProperty(Property.MAX_WIDTH)); } @Test @@ -473,11 +472,11 @@ public void setMinWidthTest() { Style style = new Style(); - Assert.assertNull(style.getProperty(Property.MIN_WIDTH)); + Assertions.assertNull(style.getProperty(Property.MIN_WIDTH)); style.setMinWidth(expectedMinWidth); - Assert.assertEquals(UnitValue.createPointValue(expectedMinWidth), style.getProperty(Property.MIN_WIDTH)); + Assertions.assertEquals(UnitValue.createPointValue(expectedMinWidth), style.getProperty(Property.MIN_WIDTH)); } @Test @@ -486,10 +485,10 @@ public void setMinWidthUnitValueTest() { Style style = new Style(); - Assert.assertNull(style.getProperty(Property.MIN_WIDTH)); + Assertions.assertNull(style.getProperty(Property.MIN_WIDTH)); style.setMinWidth(UnitValue.createPointValue(expectedMinWidth)); - Assert.assertEquals(UnitValue.createPointValue(expectedMinWidth), style.getProperty(Property.MIN_WIDTH)); + Assertions.assertEquals(UnitValue.createPointValue(expectedMinWidth), style.getProperty(Property.MIN_WIDTH)); } } diff --git a/layout/src/test/java/com/itextpdf/layout/StylesTest.java b/layout/src/test/java/com/itextpdf/layout/StylesTest.java index d3d4336382..36fc7554fd 100644 --- a/layout/src/test/java/com/itextpdf/layout/StylesTest.java +++ b/layout/src/test/java/com/itextpdf/layout/StylesTest.java @@ -29,13 +29,12 @@ This file is part of the iText (R) project. import com.itextpdf.layout.properties.UnitValue; import com.itextpdf.layout.properties.VerticalAlignment; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class StylesTest extends ExtendedITextTest { public static float EPS = 0.0001f; @@ -46,7 +45,7 @@ public void copyConstructorTest() { myStyle.setFontColor(ColorConstants.RED); Style copiedStyle = new Style(myStyle); - Assert.assertEquals(ColorConstants.RED, + Assertions.assertEquals(ColorConstants.RED, copiedStyle.getProperty(Property.FONT_COLOR).getColor()); } @@ -59,7 +58,7 @@ public void addingStyleBeforeSettingPropertyTest() { .addStyle(myStyle) .setFontColor(ColorConstants.GREEN); - Assert.assertEquals(ColorConstants.GREEN, + Assertions.assertEquals(ColorConstants.GREEN, p.getRenderer().getProperty(Property.FONT_COLOR).getColor()); } @@ -72,7 +71,7 @@ public void addingStyleAfterSettingPropertyTest() { .setFontColor(ColorConstants.GREEN) .addStyle(myStyle); - Assert.assertEquals(ColorConstants.GREEN, + Assertions.assertEquals(ColorConstants.GREEN, p.getRenderer().getProperty(Property.FONT_COLOR).getColor()); } @@ -83,7 +82,7 @@ public void addingStyleTest() { Paragraph p = new Paragraph("text").addStyle(myStyle); - Assert.assertEquals(ColorConstants.RED, + Assertions.assertEquals(ColorConstants.RED, p.getRenderer().getProperty(Property.FONT_COLOR).getColor()); } @@ -94,7 +93,7 @@ public void addingSeveralStyleTest() { Paragraph p = new Paragraph("text").addStyle(myStyle); - Assert.assertEquals(ColorConstants.RED, + Assertions.assertEquals(ColorConstants.RED, p.getRenderer().getProperty(Property.FONT_COLOR).getColor()); Style myStyle2 = new Style(); @@ -102,7 +101,7 @@ public void addingSeveralStyleTest() { p.addStyle(myStyle2); - Assert.assertEquals(ColorConstants.GREEN, + Assertions.assertEquals(ColorConstants.GREEN, p.getRenderer().getProperty(Property.FONT_COLOR).getColor()); } @@ -110,7 +109,7 @@ public void addingSeveralStyleTest() { public void addNullAsStyleTest() { Paragraph p = new Paragraph("text"); - Assert.assertThrows(IllegalArgumentException.class, () -> p.addStyle(null)); + Assertions.assertThrows(IllegalArgumentException.class, () -> p.addStyle(null)); } @Test @@ -126,13 +125,13 @@ public void setMarginsViaStyleTest() { Paragraph p = new Paragraph("Hello, iText!"); p.addStyle(style); - Assert.assertEquals(UnitValue.createPointValue(expectedMarginTop), + Assertions.assertEquals(UnitValue.createPointValue(expectedMarginTop), p.getProperty(Property.MARGIN_TOP)); - Assert.assertEquals(UnitValue.createPointValue(expectedMarginRight), + Assertions.assertEquals(UnitValue.createPointValue(expectedMarginRight), p.getProperty(Property.MARGIN_RIGHT)); - Assert.assertEquals(UnitValue.createPointValue(expectedMarginBottom), + Assertions.assertEquals(UnitValue.createPointValue(expectedMarginBottom), p.getProperty(Property.MARGIN_BOTTOM)); - Assert.assertEquals(UnitValue.createPointValue(expectedMarginLeft), + Assertions.assertEquals(UnitValue.createPointValue(expectedMarginLeft), p.getProperty(Property.MARGIN_LEFT)); } @@ -146,7 +145,7 @@ public void setMarginTopViaStyleTest() { Paragraph p = new Paragraph("Hello, iText!"); p.addStyle(style); - Assert.assertEquals(UnitValue.createPointValue(expectedMarginTop), + Assertions.assertEquals(UnitValue.createPointValue(expectedMarginTop), p.getProperty(Property.MARGIN_TOP)); } @@ -160,7 +159,7 @@ public void setVerticalAlignmentViaStyleTest() { Paragraph p = new Paragraph(); p.addStyle(style); - Assert.assertEquals(expectedAlignment, p.getProperty(Property.VERTICAL_ALIGNMENT)); + Assertions.assertEquals(expectedAlignment, p.getProperty(Property.VERTICAL_ALIGNMENT)); } @Test @@ -173,7 +172,7 @@ public void setSpacingRatioViaStyleTest() { Paragraph p = new Paragraph(); p.addStyle(style); - Assert.assertEquals(expectedSpacingRatio, (float) p.getProperty(Property.SPACING_RATIO), EPS); + Assertions.assertEquals(expectedSpacingRatio, (float) p.getProperty(Property.SPACING_RATIO), EPS); } @Test @@ -184,7 +183,7 @@ public void setKeepTogetherTrueViaStyleTest() { Paragraph p1 = new Paragraph(); p1.addStyle(trueStyle); - Assert.assertEquals(true, p1.isKeepTogether()); + Assertions.assertEquals(true, p1.isKeepTogether()); } @Test @@ -195,7 +194,7 @@ public void setKeepTogetherFalseViaStyleTest() { Paragraph p = new Paragraph(); p.addStyle(falseStyle); - Assert.assertEquals(false, p.isKeepTogether()); + Assertions.assertEquals(false, p.isKeepTogether()); } @Test @@ -208,7 +207,7 @@ public void setRotationAngleViaStyleTest() { Paragraph p = new Paragraph(); p.addStyle(style); - Assert.assertEquals(expectedRotationAngle, (float) p.getProperty(Property.ROTATION_ANGLE), EPS); + Assertions.assertEquals(expectedRotationAngle, (float) p.getProperty(Property.ROTATION_ANGLE), EPS); } @Test @@ -221,7 +220,7 @@ public void setWidthViaStyleTest() { Paragraph p = new Paragraph(); p.addStyle(style); - Assert.assertEquals(UnitValue.createPointValue(expectedWidth), p.getProperty(Property.WIDTH)); + Assertions.assertEquals(UnitValue.createPointValue(expectedWidth), p.getProperty(Property.WIDTH)); } @Test @@ -234,7 +233,7 @@ public void setWidthInUnitValueViaStyleTest() { Paragraph p = new Paragraph(); p.addStyle(style); - Assert.assertEquals(UnitValue.createPointValue(expectedWidth), p.getProperty(Property.WIDTH)); + Assertions.assertEquals(UnitValue.createPointValue(expectedWidth), p.getProperty(Property.WIDTH)); } @Test @@ -247,7 +246,7 @@ public void setHeightViaStyleTest() { Paragraph p = new Paragraph(); p.addStyle(style); - Assert.assertEquals(UnitValue.createPointValue(expectedHeight), p.getProperty(Property.HEIGHT)); + Assertions.assertEquals(UnitValue.createPointValue(expectedHeight), p.getProperty(Property.HEIGHT)); } @Test @@ -260,7 +259,7 @@ public void setHeightInUnitValueViaStyleTest() { Paragraph p = new Paragraph(); p.addStyle(style); - Assert.assertEquals(UnitValue.createPointValue(expectedHeight), p.getProperty(Property.HEIGHT)); + Assertions.assertEquals(UnitValue.createPointValue(expectedHeight), p.getProperty(Property.HEIGHT)); } @Test @@ -273,7 +272,7 @@ public void setMaxHeightViaStyleTest() { Paragraph p = new Paragraph(); p.addStyle(style); - Assert.assertEquals(UnitValue.createPointValue(expectedMaxHeight), + Assertions.assertEquals(UnitValue.createPointValue(expectedMaxHeight), p.getProperty(Property.MAX_HEIGHT)); } @@ -287,7 +286,7 @@ public void setMinHeightViaStyleTest() { Paragraph p = new Paragraph(); p.addStyle(style); - Assert.assertEquals(UnitValue.createPointValue(expectedMinHeight), + Assertions.assertEquals(UnitValue.createPointValue(expectedMinHeight), p.getProperty(Property.MIN_HEIGHT)); } @@ -301,7 +300,7 @@ public void setMaxWidthViaStyleTest() { Paragraph p = new Paragraph(); p.addStyle(style); - Assert.assertEquals(UnitValue.createPointValue(expectedMaxWidth), p.getProperty(Property.MAX_WIDTH)); + Assertions.assertEquals(UnitValue.createPointValue(expectedMaxWidth), p.getProperty(Property.MAX_WIDTH)); } @Test @@ -314,6 +313,6 @@ public void setMinWidthViaStyleTest() { Paragraph p = new Paragraph(); p.addStyle(style); - Assert.assertEquals(UnitValue.createPointValue(expectedMinWidth), p.getProperty(Property.MIN_WIDTH)); + Assertions.assertEquals(UnitValue.createPointValue(expectedMinWidth), p.getProperty(Property.MIN_WIDTH)); } } diff --git a/layout/src/test/java/com/itextpdf/layout/SurrPairTest.java b/layout/src/test/java/com/itextpdf/layout/SurrPairTest.java index 87b0b5a75b..450927c3b2 100644 --- a/layout/src/test/java/com/itextpdf/layout/SurrPairTest.java +++ b/layout/src/test/java/com/itextpdf/layout/SurrPairTest.java @@ -33,22 +33,21 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class SurrPairTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/layout/SurrPairTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/layout/SurrPairTest/"; public static final String fontsFolder = "./src/test/resources/com/itextpdf/layout/fonts/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } @@ -72,7 +71,7 @@ public void surrogatePairFrom2Chars() throws IOException, InterruptedException { document.add(paragraph); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } @Test @@ -94,7 +93,7 @@ public void surrogatePair2Pairs() throws IOException, InterruptedException { document.add(paragraph); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } @Test @@ -116,7 +115,7 @@ public void surrogatePairFullCharacter() throws IOException, InterruptedExceptio document.add(paragraph); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } @Test @@ -147,7 +146,7 @@ public void surrogatePairCombingFullSurrs() throws IOException, InterruptedExcep document.add(paragraph); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } @Test @@ -179,6 +178,6 @@ public void surrogatePairCombingFullSurrsWithNoSurrs() throws IOException, Inter document.add(paragraph); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } } diff --git a/layout/src/test/java/com/itextpdf/layout/TableBorderTest.java b/layout/src/test/java/com/itextpdf/layout/TableBorderTest.java index 8c770322c3..4668cb609b 100644 --- a/layout/src/test/java/com/itextpdf/layout/TableBorderTest.java +++ b/layout/src/test/java/com/itextpdf/layout/TableBorderTest.java @@ -44,17 +44,16 @@ This file is part of the iText (R) project. import com.itextpdf.layout.properties.UnitValue; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.FileNotFoundException; import java.io.IOException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class TableBorderTest extends AbstractTableTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/layout/TableBorderTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/layout/TableBorderTest/"; @@ -64,7 +63,7 @@ public class TableBorderTest extends AbstractTableTest { String outFileName; String cmpFileName; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } @@ -845,7 +844,10 @@ public void splitCellsTest02() throws IOException, InterruptedException { doc.add(table); doc.add(new AreaBreak()); - table.deleteOwnProperty(Property.BORDER); + table.deleteOwnProperty(Property.BORDER_LEFT); + table.deleteOwnProperty(Property.BORDER_BOTTOM); + table.deleteOwnProperty(Property.BORDER_RIGHT); + table.deleteOwnProperty(Property.BORDER_TOP); table.setBorderCollapse(BorderCollapsePropertyValue.SEPARATE); table.setHorizontalBorderSpacing(20); table.setVerticalBorderSpacing(20); @@ -924,7 +926,7 @@ public void splitCellsTest04() throws IOException, InterruptedException { } @Test - @Ignore("DEVSIX-1734") + @Disabled("DEVSIX-1734") public void splitCellsTest04A() throws IOException, InterruptedException { fileName = "splitCellsTest04A.pdf"; Document doc = createDocument(); @@ -1161,7 +1163,7 @@ public void splitCellsTest10A() throws IOException, InterruptedException { } @Test - @Ignore("DEVSIX-1736") + @Disabled("DEVSIX-1736") public void splitCellsTest10B() throws IOException, InterruptedException { fileName = "splitCellsTest10B.pdf"; Document doc = createDocument(); @@ -1402,7 +1404,10 @@ public void tableWithHeaderFooterTest05() throws IOException, InterruptedExcepti doc.add(table); doc.add(new Table(UnitValue.createPercentArray(1)).useAllAvailableWidth().addCell("Hello").setBorder(new SolidBorder(ColorConstants.ORANGE, 5))); - table.deleteOwnProperty(Property.BORDER); + table.deleteOwnProperty(Property.BORDER_LEFT); + table.deleteOwnProperty(Property.BORDER_BOTTOM); + table.deleteOwnProperty(Property.BORDER_RIGHT); + table.deleteOwnProperty(Property.BORDER_TOP); doc.add(table); doc.add(new Table(UnitValue.createPercentArray(1)).useAllAvailableWidth().addCell("Hello").setBorder(new SolidBorder(ColorConstants.ORANGE, 5))); @@ -1414,7 +1419,10 @@ public void tableWithHeaderFooterTest05() throws IOException, InterruptedExcepti doc.add(table); doc.add(new Table(UnitValue.createPercentArray(1)).useAllAvailableWidth().addCell("Hello").setBorder(new SolidBorder(ColorConstants.ORANGE, 5))); - table.deleteOwnProperty(Property.BORDER); + table.deleteOwnProperty(Property.BORDER_LEFT); + table.deleteOwnProperty(Property.BORDER_BOTTOM); + table.deleteOwnProperty(Property.BORDER_RIGHT); + table.deleteOwnProperty(Property.BORDER_TOP); doc.add(table); doc.add(new Table(UnitValue.createPercentArray(1)).useAllAvailableWidth().addCell("Hello").setBorder(new SolidBorder(ColorConstants.ORANGE, 5))); @@ -1779,7 +1787,7 @@ public void tableWithHeaderFooterTest11A() throws IOException, InterruptedExcept addTableBelowToCheckThatOccupiedAreaIsCorrect(doc); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -1807,7 +1815,7 @@ public void tableWithHeaderFooterTest12() throws IOException, InterruptedExcepti closeDocumentAndCompareOutputs(doc); } - @Ignore("DEVSIX-1219") + @Disabled("DEVSIX-1219") @Test public void tableWithHeaderFooterTest13() throws IOException, InterruptedException { fileName = "tableWithHeaderFooterTest13.pdf"; @@ -1868,7 +1876,7 @@ public void tableWithHeaderFooterTest14() throws IOException, InterruptedExcepti .setBorderTop(new SolidBorder(2)) .setBorderBottom(new SolidBorder(1)); table.getFooter() - .setBold() + .simulateBold() .setBorderTop(new SolidBorder(10)) .setBorderBottom(new SolidBorder(1)) .setBackgroundColor(ColorConstants.LIGHT_GRAY); @@ -2411,10 +2419,10 @@ public void verticalMiddleBorderTest() throws IOException, InterruptedException doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } - private Document createDocument() throws FileNotFoundException { + private Document createDocument() throws IOException { outFileName = destinationFolder + fileName; cmpFileName = sourceFolder + cmpPrefix + fileName; @@ -2427,7 +2435,7 @@ private void closeDocumentAndCompareOutputs(Document document) throws IOExceptio document.close(); String compareResult = new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff"); if (compareResult != null) { - Assert.fail(compareResult); + Assertions.fail(compareResult); } } } diff --git a/layout/src/test/java/com/itextpdf/layout/TableTest.java b/layout/src/test/java/com/itextpdf/layout/TableTest.java index 67877297d8..c023646154 100644 --- a/layout/src/test/java/com/itextpdf/layout/TableTest.java +++ b/layout/src/test/java/com/itextpdf/layout/TableTest.java @@ -61,16 +61,15 @@ This file is part of the iText (R) project. import com.itextpdf.test.LogLevelConstants; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.ByteArrayOutputStream; import java.io.IOException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class TableTest extends AbstractTableTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/layout/TableTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/layout/TableTest/"; @@ -82,7 +81,7 @@ public class TableTest extends AbstractTableTest { private static final String MIDDLE_TEXT_CONTENT = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas porttitor congue massa. Fusce posuere, magna sed pulvinar ultricies, purus lectus malesuada libero, sit amet commodo magna eros quis urna.\n" + "Nunc viverra imperdiet enim. Fusce est. Vivamus a tellus."; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } @@ -101,8 +100,8 @@ public void simpleTableTest01() throws IOException, InterruptedException { .addCell(new Cell().add(new Paragraph("cell 1, 2"))); doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); - Assert.assertEquals("Cell[row=0, col=0, rowspan=1, colspan=1]", table.getCell(0, 0).toString()); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertEquals("Cell[row=0, col=0, rowspan=1, colspan=1]", table.getCell(0, 0).toString()); } @Test @@ -123,7 +122,7 @@ public void simpleTableTest02() throws IOException, InterruptedException { .addCell(new Cell()); doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -149,7 +148,7 @@ public void simpleTableTest03() throws IOException, InterruptedException { .addCell(new Cell().add(new Paragraph("cell 2, 2\n" + textContent2))); doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -168,7 +167,7 @@ public void simpleTableTest04() throws IOException, InterruptedException { table.addCell(new Cell().add(new Paragraph("cell 3, 1\n" + TEXT_CONTENT))); doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -187,7 +186,7 @@ public void simpleTableTest05() throws IOException, InterruptedException { .addCell(new Cell().add(new Paragraph("cell 3, 2\n" + TEXT_CONTENT))); doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -206,7 +205,7 @@ public void simpleTableTest06() throws IOException, InterruptedException { .addCell(new Cell().add(new Paragraph("cell 3, 1\n" + TEXT_CONTENT))); doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -225,7 +224,7 @@ public void simpleTableTest07() throws IOException, InterruptedException { .addCell(new Cell().add(new Paragraph("cell 3, 2\n" + TEXT_CONTENT))); doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -251,7 +250,7 @@ public void simpleTableTest08() throws IOException, InterruptedException { .addCell(new Cell().add(new Paragraph("cell 4, 3\n" + middleTextContent))); doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -280,7 +279,7 @@ public void simpleTableTest09() throws IOException, InterruptedException { .addCell(new Cell().add(new Paragraph("cell 5, 3\n" + middleTextContent))); doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -321,7 +320,7 @@ public void simpleTableTest10() throws IOException, InterruptedException { .addCell(new Cell().add(new Paragraph("2, 2"))); doc.add(table3); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -354,7 +353,7 @@ public void simpleTableTest11() throws IOException, InterruptedException { .addCell(new Cell().setKeepTogether(true).add(new Paragraph("cell 7, 2\n" + middleTextContent))); doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -395,7 +394,7 @@ public void simpleTableTest12() throws IOException, InterruptedException { .addCell(new Cell().add(new Paragraph("cell 11, 2\n" + shortTextContent))); doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -426,7 +425,7 @@ public void simpleTableTest13() throws IOException, InterruptedException { .addCell(new Cell().add(new Paragraph("cell 7, 2\n" + middleTextContent))); doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -458,7 +457,7 @@ public void simpleTableTest14() throws IOException, InterruptedException { .addCell(new Cell().add(new Paragraph("cell 6, 3\n" + middleTextContent))); doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -493,7 +492,7 @@ public void simpleTableTest15() throws IOException, InterruptedException { .addCell(new Cell().add(new Paragraph("cell 7, 3\n" + middleTextContent))); doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -518,7 +517,7 @@ public void simpleTableTest16() throws IOException, InterruptedException { .addCell(new Cell().add(new Paragraph("cell 2, 2\n" + longTextContent))); doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -549,7 +548,7 @@ public void wideFirstCellBorderDoesntAffectSecondCellTest() throws IOException, .addCell(new Cell().add(new Paragraph("cell 2, 2\n" + longTextContent))); doc.add(table); doc.close(); - Assert.assertNull( + Assertions.assertNull( new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @@ -580,7 +579,7 @@ public void simpleTableTest17() throws IOException, InterruptedException { doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -612,7 +611,7 @@ public void simpleTableTest18() throws IOException, InterruptedException { doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -643,7 +642,7 @@ public void simpleTableTest19() throws IOException, InterruptedException { .addCell(new Cell().add(new Paragraph("cell 6, 3\n" + MIDDLE_TEXT_CONTENT))); doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -670,7 +669,7 @@ public void simpleTableTest20() throws IOException, InterruptedException { .addCell(new Cell().add(new Paragraph("cell 6, 3\n" + MIDDLE_TEXT_CONTENT))); doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -703,7 +702,7 @@ public void simpleTableTest21() throws IOException, InterruptedException { .addCell(new Cell().add(new Paragraph("cell 6, 3\n" + middleTextContent))); doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -722,7 +721,7 @@ public void simpleTableTest22() throws IOException, InterruptedException { .addCell(new Cell().add(new Paragraph("cell 1, 4"))); doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -769,7 +768,7 @@ public void simpleTableTest23() throws IOException, InterruptedException { table.complete(); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -791,7 +790,7 @@ public void widthInPercentShouldBeResetAfterOverflow() throws IOException, Inter // will be added on the second page doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -818,7 +817,7 @@ public void bigRowspanTest01() throws IOException, InterruptedException { .addCell(new Cell().add(new Paragraph("cell 5, 1\n" + middleTextContent))); doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -845,7 +844,7 @@ public void bigRowspanTest02() throws IOException, InterruptedException { .addCell(new Cell().add(new Paragraph("cell 5, 1\n" + TEXT_CONTENT))); doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -869,7 +868,7 @@ public void bigRowspanTest03() throws IOException, InterruptedException { .addCell(new Cell().add(new Paragraph("cell 5, 1\n" + TEXT_CONTENT))); doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -896,7 +895,7 @@ public void bigRowspanTest04() throws IOException, InterruptedException { .addCell(new Cell().add(new Paragraph("cell 5, 1\n" + TEXT_CONTENT))); doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -920,7 +919,7 @@ public void bigRowspanTest05() throws IOException, InterruptedException { doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -941,7 +940,7 @@ public void bigRowspanTest06() throws IOException, InterruptedException { table.setBorderTop(new SolidBorder(ColorConstants.GREEN, 50)).setBorderBottom(new SolidBorder(ColorConstants.ORANGE, 40)); doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -972,7 +971,7 @@ public void bigRowspanTest07() throws IOException, InterruptedException { doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -1005,7 +1004,7 @@ public void differentPageOrientationTest01() throws IOException, InterruptedExce doc.setRenderer(new RotatedDocumentRenderer(doc, pdfDoc)); doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -1032,7 +1031,7 @@ public void extendLastRowTest01() throws IOException, InterruptedException { doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @LogMessages(messages = { @@ -1062,7 +1061,7 @@ public void toLargeElementWithKeepTogetherPropertyInTableTest01() throws IOExcep doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @LogMessages(messages = { @@ -1086,7 +1085,7 @@ public void toLargeElementInTableTest01() throws IOException, InterruptedExcepti doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -1138,7 +1137,7 @@ public void nestedTablesCollapseTest01() throws IOException, InterruptedExceptio doc.add(outertable); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -1170,7 +1169,7 @@ public void nestedTableSkipHeaderFooterTest() throws IOException, InterruptedExc doc.add(t); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -1192,7 +1191,7 @@ public void nestedTablesWithMarginsTest01() throws IOException, InterruptedExcep outerTable.setMarginTop(10); doc.add(outerTable); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @LogMessages(messages = { @@ -1232,7 +1231,7 @@ public void splitTableOnShortPage() throws IOException, InterruptedException { doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -1263,7 +1262,7 @@ public void splitCellWithStyles() throws IOException, InterruptedException { doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -1291,7 +1290,7 @@ public void imageInTableTest_HA() throws IOException, InterruptedException { doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -1310,7 +1309,7 @@ public void cellAlignmentAndSplittingTest01() throws IOException, InterruptedExc doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -1329,7 +1328,7 @@ public void cellAlignmentAndKeepTogetherTest01() throws IOException, Interrupted doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @LogMessages(messages = { @@ -1405,7 +1404,7 @@ public void tableWithSetHeightProperties01() throws IOException, InterruptedExce doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @LogMessages(messages = { @@ -1508,7 +1507,7 @@ public void tableWithSetHeightProperties02() throws IOException, InterruptedExce doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -1593,7 +1592,7 @@ public void tableWithSetHeightProperties03() throws IOException, InterruptedExce doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -1619,7 +1618,7 @@ public void tableWithHeaderInTheBottomOfPageTest() throws IOException, Interrupt doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -1639,7 +1638,7 @@ public void bigFooterTest01() throws IOException, InterruptedException { doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -1660,7 +1659,7 @@ public void bigFooterTest02() throws IOException, InterruptedException { doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -1681,7 +1680,7 @@ public void tableWithDocumentRelayoutTest() throws IOException, InterruptedExcep doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -1701,7 +1700,7 @@ public void tableWithKeepTogetherOnCells() throws IOException, InterruptedExcept document.add(table); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -1735,7 +1734,7 @@ public void emptyTableTest01() throws IOException, InterruptedException { addTableBelowToCheckThatOccupiedAreaIsCorrect(doc); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -1756,7 +1755,7 @@ public void emptyTableTest02() throws IOException, InterruptedException { addTableBelowToCheckThatOccupiedAreaIsCorrect(doc); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @@ -1780,7 +1779,7 @@ public void tableWithIncompleteFooter() throws IOException, InterruptedException doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -1806,7 +1805,7 @@ public void tableWithCustomRendererTest01() throws IOException, InterruptedExcep doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -1833,7 +1832,7 @@ public void skipLastRowTest() throws IOException, InterruptedException { doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -1855,7 +1854,7 @@ public void skipFooterTest01() throws IOException, InterruptedException { doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -1884,7 +1883,7 @@ public void skipHeaderTest01() throws IOException, InterruptedException { doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -1907,7 +1906,7 @@ public void tableSplitTest01() throws IOException, InterruptedException { doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -1939,7 +1938,7 @@ public void tableSplitTest02() throws IOException, InterruptedException { doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -1965,7 +1964,7 @@ public void tableSplitTest03() throws IOException, InterruptedException { doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -1995,7 +1994,7 @@ public void tableSplitTest04() throws IOException, InterruptedException { doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -2022,7 +2021,7 @@ public void tableNothingResultTest() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -2044,7 +2043,7 @@ public void tableWithEmptyLastRowTest() throws IOException, InterruptedException doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -2065,7 +2064,7 @@ public void tableWithEmptyRowsBetweenFullRowsTest() throws IOException, Interrup doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -2090,7 +2089,7 @@ public void tableWithEmptyRowAfterJustOneCellTest() throws IOException, Interrup doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -2114,7 +2113,7 @@ public void tableWithAlternatingRowsTest() throws IOException, InterruptedExcept doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -2137,7 +2136,7 @@ public void coloredTableWithColoredCellsTest() throws IOException, InterruptedEx doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -2161,7 +2160,7 @@ public void tableWithEmptyRowsAndSpansTest() throws IOException, InterruptedExce doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -2183,7 +2182,7 @@ public void tableWithEmptyRowsAndSeparatedBordersTest() throws IOException, Inte doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -2204,7 +2203,7 @@ public void tableWithCollapsedBordersTest() throws IOException, InterruptedExcep doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -2228,7 +2227,7 @@ public void tableWithCollapsedBordersAndFooterTest() throws IOException, Interru doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -2251,18 +2250,18 @@ public void autoLayoutTest01() throws IOException, InterruptedException { doc.add(new Paragraph("A cell with bold text:")); table = new Table(new float[1]); - table.addCell("A cell").setBold(); + table.addCell("A cell").simulateBold(); doc.add(table); doc.add(new Paragraph("A cell with italic text:")); table = new Table(new float[1]); - table.addCell("A cell").setItalic(); + table.addCell("A cell").simulateItalic(); doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -2282,7 +2281,7 @@ public void autoLayoutTest02() throws IOException, InterruptedException { .add(new Paragraph("Long long long Long long long Long long long Long long long text"))); doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -2302,7 +2301,7 @@ public void autoLayoutTest03() throws IOException, InterruptedException { doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -2324,7 +2323,7 @@ public void fixedLayoutTest01() throws IOException, InterruptedException { doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -2346,7 +2345,7 @@ public void fixedLayoutTest02() throws IOException, InterruptedException { doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -2380,7 +2379,7 @@ public void fixedPositionTest01() throws IOException, InterruptedException { doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -2407,7 +2406,7 @@ public void nestedTableLostContent() throws IOException, InterruptedException { doc.add(outerTable); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -2435,7 +2434,7 @@ public void nestedTableMinMaxWidthException() throws IOException, InterruptedExc doc.add(outerTable); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -2453,7 +2452,7 @@ public void tableMinMaxWidthTest01() throws IOException, InterruptedException { table.addCell(cell); doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -2471,7 +2470,7 @@ public void tableMinMaxWidthTest02() throws IOException, InterruptedException { table.addCell(cell); doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -2489,7 +2488,7 @@ public void tableMinMaxWidthTest03() throws IOException, InterruptedException { table.addCell(cell); doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -2507,7 +2506,7 @@ public void tableMinMaxWidthTest04() throws IOException, InterruptedException { table.addCell(cell); doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -2530,7 +2529,7 @@ public void tableMinMaxWidthTest05() throws IOException, InterruptedException { doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -2602,7 +2601,7 @@ public void cellsWithEdgeCaseLeadingTest01() throws IOException, InterruptedExce document.add(table); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -2625,7 +2624,7 @@ public void tableMinMaxWidthTest06() throws IOException, InterruptedException { doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -2651,8 +2650,8 @@ public void splitTableMinMaxWidthTest01() { MinMaxWidth minMaxWidth = overflowRenderer.getMinMaxWidth(); - Assert.assertEquals(result.getOccupiedArea().getBBox().getWidth(), minMaxWidth.getMaxWidth(), 0.0001); - Assert.assertEquals(minMaxWidth.getMaxWidth(), minMaxWidth.getMinWidth(), 0.0001); + Assertions.assertEquals(result.getOccupiedArea().getBBox().getWidth(), minMaxWidth.getMaxWidth(), 0.0001); + Assertions.assertEquals(minMaxWidth.getMaxWidth(), minMaxWidth.getMinWidth(), 0.0001); // not enough to place using max-width approach, but more than required for min-width approach areaWidth = 70; @@ -2663,8 +2662,8 @@ public void splitTableMinMaxWidthTest01() { minMaxWidth = overflowRenderer.getMinMaxWidth(); - Assert.assertEquals(result.getOccupiedArea().getBBox().getWidth(), minMaxWidth.getMaxWidth(), 0.0001); - Assert.assertEquals(minMaxWidth.getMaxWidth(), minMaxWidth.getMinWidth(), 0.0001); + Assertions.assertEquals(result.getOccupiedArea().getBBox().getWidth(), minMaxWidth.getMaxWidth(), 0.0001); + Assertions.assertEquals(minMaxWidth.getMaxWidth(), minMaxWidth.getMinWidth(), 0.0001); // enough to place using max-width approach @@ -2676,8 +2675,8 @@ public void splitTableMinMaxWidthTest01() { minMaxWidth = overflowRenderer.getMinMaxWidth(); - Assert.assertEquals(result.getOccupiedArea().getBBox().getWidth(), minMaxWidth.getMaxWidth(), 0.0001); - Assert.assertEquals(minMaxWidth.getMaxWidth(), minMaxWidth.getMinWidth(), 0.0001); + Assertions.assertEquals(result.getOccupiedArea().getBBox().getWidth(), minMaxWidth.getMaxWidth(), 0.0001); + Assertions.assertEquals(minMaxWidth.getMaxWidth(), minMaxWidth.getMinWidth(), 0.0001); } @@ -2710,7 +2709,7 @@ public void marginPaddingTest01() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -2744,7 +2743,7 @@ public void spacingTest01() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -2767,7 +2766,7 @@ public void taggedTableWithCaptionTest01() throws IOException, InterruptedExcept doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -2809,7 +2808,7 @@ public void wideCaptionTest01() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -2841,7 +2840,7 @@ public void splitTableWithCaptionTest01() throws IOException, InterruptedExcepti doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -2885,7 +2884,7 @@ public void captionedTableOfOnePageWithCollapsedBordersTest01() throws IOExcepti doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -2907,7 +2906,7 @@ public void tableWithDifferentStylesOfCollapsedBordersTest() throws IOException, doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @@ -2950,7 +2949,7 @@ public void captionedTableOfOnePageWithSeparatedBordersTest01() throws IOExcepti doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } private void addTable(Table table, boolean addParagraphBefore, boolean addParagraphAfter, Document doc) { @@ -3015,7 +3014,7 @@ public void skipLastFooterAndProcessBigRowspanTest01() throws IOException, Inter doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -3045,7 +3044,7 @@ public void skipLastFooterAndProcessBigRowspanTest02() throws IOException, Inter } doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -3070,7 +3069,7 @@ public void skipLastFooterOnShortPageTest01() throws IOException, InterruptedExc doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -3102,7 +3101,7 @@ public void firstRowPartiallyFitWideBottomBorderTest() throws IOException, Inter addTableBelowToCheckThatOccupiedAreaIsCorrect(doc); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -3135,7 +3134,7 @@ public void collapseWithNextRowWiderThanWithTableBorderTest() throws IOException addTableBelowToCheckThatOccupiedAreaIsCorrect(doc); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -3159,7 +3158,7 @@ public void tableBottomBorderWideTest() throws IOException, InterruptedException addTableBelowToCheckThatOccupiedAreaIsCorrect(doc); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -3198,7 +3197,7 @@ public void cellWithBigRowspanCompletedRowTooTest() throws IOException, Interrup doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -3238,7 +3237,7 @@ public void cellWithBigRowspanCompletedRowNotTest() throws IOException, Interrup doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -3261,12 +3260,12 @@ public void inheritHeaderPropsWhileMinMaxWidthCalculationsTest() throws IOExcept // If this property is not inherited while calculating min/max widths, // then while layouting header will request more space than the layout box's width - table.getHeader().setBold(); + table.getHeader().simulateBold(); document.add(table); document.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + filename, + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff")); } @@ -3301,7 +3300,7 @@ public void infiniteLoopOnUnfitCellAndBigRowspanTest() throws IOException, Inter doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -3335,7 +3334,7 @@ public void firstRowNotFitBigRowspanTest() throws IOException, InterruptedExcept doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -3368,7 +3367,7 @@ public void bigRowSpanTooFarFullTest() throws IOException, InterruptedException document.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + filename, + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder)); } @@ -3403,7 +3402,7 @@ public void bigRowSpanTooFarPartialTest() throws IOException, InterruptedExcepti document.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + filename, + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder)); } @@ -3442,7 +3441,7 @@ public void bigRowSpanTooFarNothingTest() throws IOException, InterruptedExcepti document.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + filename, + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder)); } @@ -3471,7 +3470,7 @@ public void setWidthShouldBeRespectedTest() throws IOException, InterruptedExcep doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + fileName, + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + fileName, sourceFolder + "cmp_" + fileName, destinationFolder)); } @@ -3495,13 +3494,13 @@ public void preciseFittingBoldSimulatedTextInCellsTest() throws IOException, Int table.setFixedLayout(); for (int i = 0; i < numberOfColumns; i++) { - table.addCell(new Cell().add(new Paragraph("Description").setBold())); + table.addCell(new Cell().add(new Paragraph("Description").simulateBold())); } doc.add(table); } - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + fileName, + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + fileName, sourceFolder + "cmp_" + fileName, destinationFolder)); } @@ -3531,7 +3530,7 @@ public void tableRelayoutTest() { Rectangle tableRectRelayout = result.getOccupiedArea().getBBox(); - Assert.assertTrue(tableRect.equalsWithEpsilon(tableRectRelayout)); + Assertions.assertTrue(tableRect.equalsWithEpsilon(tableRectRelayout)); } } @@ -3566,7 +3565,7 @@ public void infiniteLoopKeepTogetherTest() throws IOException, InterruptedExcept doc.add(table); } - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + fileName, + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + fileName, sourceFolder + "cmp_" + fileName, destinationFolder)); } @@ -3585,7 +3584,7 @@ public void negativeLayoutAreaTest() throws IOException, InterruptedException { doc.add(new Table(new float[]{1, 1}).addCell(new Cell().setHeight(10.0f))); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -3611,7 +3610,7 @@ public void keepTogetherCaptionAndHugeCellTest() throws IOException, Interrupted document.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + fileName, + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + fileName, sourceFolder + "cmp_" + fileName, destinationFolder)); } @@ -3641,7 +3640,7 @@ public void keepTogetherCaptionDoesntFitPageTest() throws IOException, Interrupt document.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + fileName, + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + fileName, sourceFolder + "cmp_" + fileName, destinationFolder)); } @@ -3668,7 +3667,7 @@ public void keepTogetherCaptionAndSplitCellTest() throws IOException, Interrupte document.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + fileName, + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + fileName, sourceFolder + "cmp_" + fileName, destinationFolder)); } diff --git a/layout/src/test/java/com/itextpdf/layout/TabsTest.java b/layout/src/test/java/com/itextpdf/layout/TabsTest.java index 672181a72e..52a6292ed8 100644 --- a/layout/src/test/java/com/itextpdf/layout/TabsTest.java +++ b/layout/src/test/java/com/itextpdf/layout/TabsTest.java @@ -44,18 +44,17 @@ This file is part of the iText (R) project. import com.itextpdf.layout.properties.Property; import com.itextpdf.layout.properties.TabAlignment; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.FileNotFoundException; import java.io.IOException; import java.util.ArrayList; import java.util.List; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class TabsTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/layout/TabsTest/"; @@ -84,7 +83,7 @@ public class TabsTest extends ExtendedITextTest { // private static final String text3 = "\t0\n\t11#2.35\n\t813.2134#558914423\n\t3.37761#098\n\t#.715\n\t972#5844.18167\n\t"; private static final String text3 = "\t0\n\t11#2.35\n\t813.2134#558914423\n\t3.37761#098\n\t#.715\n\t972#5844.18167\n\t65#1094.6177##1128\n\t65.7#463\n\t68750.25121\n\t393#19.6#418#31\n\t7#811"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } @@ -115,7 +114,7 @@ public void chunkEndsAfterOrBeforeTabPosition() throws IOException, InterruptedE doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -138,7 +137,7 @@ public void defaultTabsTest() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -195,7 +194,7 @@ public void simpleTabStopsTest() throws IOException, InterruptedException { drawTabStopsPositions(positions3, doc, 1, 235, 95); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -223,7 +222,7 @@ public void anchorTabStopsTest01() throws IOException, InterruptedException { drawTabStopsPositions(positions1, doc, 1, 0, 120); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff" + outFileName)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff" + outFileName)); } @Test @@ -251,7 +250,7 @@ public void anchorTabStopsTest02() throws IOException, InterruptedException { drawTabStopsPositions(positions1, doc, 1, 0, 200); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff" + outFileName)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff" + outFileName)); } @Test @@ -294,7 +293,7 @@ public void tablesAndTabInsideOfParagraph() throws IOException, InterruptedExcep doc.add(p); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, testName + "_diff")); } @Test @@ -326,7 +325,7 @@ public void tabPositionAbsoluteValueTest() throws IOException, InterruptedExcept doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } @Test @@ -363,7 +362,7 @@ public void severalTabsInRowTest() throws IOException, InterruptedException { drawTabStopsPositions(positions, doc, 1, 0, 120); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff" + outFileName)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff" + outFileName)); } @Test @@ -425,7 +424,7 @@ public void outOfPageBoundsTest() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -482,7 +481,7 @@ public void tabsInParagraphTest01() throws IOException, InterruptedException { doc.add(p); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -507,7 +506,7 @@ public void tabsAnchorSemicolonTest01() throws IOException, InterruptedException document.add(p); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -533,7 +532,7 @@ public void tabsAnchorSemicolonTest02() throws IOException, InterruptedException document.add(p); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -558,7 +557,7 @@ public void tabsAnchorSemicolonTest03() throws IOException, InterruptedException document.add(p); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -575,14 +574,14 @@ public void fillParagraphWithTabsDifferently() throws IOException, InterruptedEx doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } - private Document initDocument(String outFileName) throws FileNotFoundException { + private Document initDocument(String outFileName) throws IOException { return initDocument(outFileName, false); } - private Document initDocument(String outFileName, boolean tagged) throws FileNotFoundException { + private Document initDocument(String outFileName, boolean tagged) throws IOException { PdfDocument pdfDoc = new PdfDocument(new PdfWriter(outFileName)); if (tagged) { pdfDoc.setTagged(); diff --git a/layout/src/test/java/com/itextpdf/layout/TextWritingTest.java b/layout/src/test/java/com/itextpdf/layout/TextWritingTest.java index b21bbdf110..0c99db10d4 100644 --- a/layout/src/test/java/com/itextpdf/layout/TextWritingTest.java +++ b/layout/src/test/java/com/itextpdf/layout/TextWritingTest.java @@ -35,27 +35,27 @@ This file is part of the iText (R) project. import com.itextpdf.layout.element.AreaBreak; import com.itextpdf.layout.element.Paragraph; import com.itextpdf.layout.element.Text; +import com.itextpdf.layout.exceptions.LayoutExceptionMessageConstant; import com.itextpdf.layout.properties.FloatPropertyValue; import com.itextpdf.layout.properties.OverflowPropertyValue; import com.itextpdf.layout.properties.Property; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; - -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; import java.io.IOException; -@Category(IntegrationTest.class) +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +@Tag("IntegrationTest") public class TextWritingTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/layout/TextWritingTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/layout/TextWritingTest/"; public static final String fontsFolder = "./src/test/resources/com/itextpdf/layout/fonts/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } @@ -84,7 +84,7 @@ public void textRiseTest01() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -117,7 +117,7 @@ public void textRenderingModeTest01() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -143,7 +143,7 @@ public void leadingTest01() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -160,7 +160,7 @@ public void leadingTest02() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -206,7 +206,7 @@ public void firstLineIndentTest01() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -229,7 +229,7 @@ public void charSpacingTest01() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -253,7 +253,7 @@ public void wordSpacingTest01() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -266,15 +266,15 @@ public void fontStyleSimulationTest01() throws IOException, InterruptedException document.add(new Paragraph("I'm underlined").setUnderline()); document.add(new Paragraph("I'm strikethrough").setLineThrough()); - document.add(new Paragraph(new Text("I'm a bold simulation font").setBackgroundColor(ColorConstants.GREEN)).setBold()); - document.add(new Paragraph(new Text("I'm an italic simulation font").setBackgroundColor(ColorConstants.GREEN)).setItalic()); + document.add(new Paragraph(new Text("I'm a bold simulation font").setBackgroundColor(ColorConstants.GREEN)).simulateBold()); + document.add(new Paragraph(new Text("I'm an italic simulation font").setBackgroundColor(ColorConstants.GREEN)).simulateItalic()); document.add(new Paragraph(new Text("I'm a super bold italic underlined linethrough piece of text and no one can be better than me, even if " + "such a long description will cause me to occupy two lines").setBackgroundColor(ColorConstants.GREEN)) - .setItalic().setBold().setUnderline().setLineThrough()); + .simulateItalic().simulateBold().setUnderline().setLineThrough()); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @@ -317,7 +317,7 @@ public void bigWordTest01() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -337,7 +337,7 @@ public void underlineTest() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -354,12 +354,18 @@ public void lineThroughTest() throws IOException, InterruptedException { Text textDown = new Text("textRise-10f_with_lineThrough"); textDown.setTextRise(-10f); textDown.setLineThrough(); - Paragraph n= new Paragraph("baseline"); + Paragraph n = new Paragraph("baseline"); n.add(textUp).add(textDown); document.add(n); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff_")); + } + + @Test + public void textInitializationWithNullValueThrowsException() { + Exception e = Assertions.assertThrows(IllegalArgumentException.class, () -> new Text(null)); + Assertions.assertEquals(LayoutExceptionMessageConstant.TEXT_CONTENT_CANNOT_BE_NULL, e.getMessage()); } @Test @@ -383,7 +389,7 @@ public void leadingAndFloatInTextTest() throws IOException, InterruptedException document.add(p); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } @Test @@ -420,6 +426,6 @@ public void textWrappingEpsilonTest() throws IOException, InterruptedException { document.close(); writer.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } } diff --git a/layout/src/test/java/com/itextpdf/layout/XMPWriterTest.java b/layout/src/test/java/com/itextpdf/layout/XMPWriterTest.java index 518ac9cfe9..54cfd6f9f2 100644 --- a/layout/src/test/java/com/itextpdf/layout/XMPWriterTest.java +++ b/layout/src/test/java/com/itextpdf/layout/XMPWriterTest.java @@ -30,8 +30,9 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.font.PdfFontFactory.EmbeddingStrategy; import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfDocumentInfo; -import com.itextpdf.kernel.pdf.PdfViewerPreferences; import com.itextpdf.kernel.pdf.PdfString; +import com.itextpdf.kernel.pdf.PdfUAConformance; +import com.itextpdf.kernel.pdf.PdfViewerPreferences; import com.itextpdf.kernel.pdf.PdfWriter; import com.itextpdf.kernel.pdf.WriterProperties; import com.itextpdf.kernel.utils.CompareTool; @@ -44,15 +45,14 @@ This file is part of the iText (R) project. import com.itextpdf.layout.element.Paragraph; import com.itextpdf.layout.element.Text; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; import java.io.IOException; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class XMPWriterTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/layout/XMPWriterTest/"; @@ -61,7 +61,7 @@ public class XMPWriterTest extends ExtendedITextTest { public static final String FONT = "./src/test/resources/com/itextpdf/layout/fonts/FreeSans.ttf"; public static final String FOX = "./src/test/resources/com/itextpdf/layout/XMPWriterTest/fox.bmp"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } @@ -88,23 +88,25 @@ public void createPdfTest() throws IOException, XMPException { document.close(); CompareTool ct = new CompareTool(); - Assert.assertNull(ct.compareXmp(destinationFolder + fileName, sourceFolder + "cmp_" + fileName, true)); + Assertions.assertNull(ct.compareXmp(destinationFolder + fileName, sourceFolder + "cmp_" + fileName, true)); } @Test public void addUAXMPMetaDataNotTaggedTest() throws IOException { String fileName = "addUAXMPMetaDataNotTaggedTest.pdf"; - PdfDocument pdf = new PdfDocument(new PdfWriter(destinationFolder + fileName, new WriterProperties().addUAXmpMetadata())); + WriterProperties writerProperties = new WriterProperties().addPdfUaXmpMetadata(PdfUAConformance.PDF_UA_1); + PdfDocument pdf = new PdfDocument(new PdfWriter(destinationFolder + fileName, writerProperties)); manipulatePdf(pdf, false); - Assert.assertNull(new CompareTool().compareXmp(destinationFolder + fileName, sourceFolder + "cmp_" + fileName, true)); + Assertions.assertNull(new CompareTool().compareXmp(destinationFolder + fileName, sourceFolder + "cmp_" + fileName, true)); } @Test public void addUAXMPMetaDataTaggedTest() throws IOException { String fileName = "addUAXMPMetaDataTaggedTest.pdf"; - PdfDocument pdf = new PdfDocument(new PdfWriter(destinationFolder + fileName, new WriterProperties().addUAXmpMetadata())); + WriterProperties writerProperties = new WriterProperties().addPdfUaXmpMetadata(PdfUAConformance.PDF_UA_1); + PdfDocument pdf = new PdfDocument(new PdfWriter(destinationFolder + fileName, writerProperties)); manipulatePdf(pdf, true); - Assert.assertNull(new CompareTool().compareXmp(destinationFolder + fileName, sourceFolder + "cmp_" + fileName, true)); + Assertions.assertNull(new CompareTool().compareXmp(destinationFolder + fileName, sourceFolder + "cmp_" + fileName, true)); } @Test @@ -112,7 +114,7 @@ public void doNotAddUAXMPMetaDataTaggedTest() throws IOException { String fileName = "doNotAddUAXMPMetaDataTaggedTest.pdf"; PdfDocument pdf = new PdfDocument(new PdfWriter(destinationFolder + fileName, new WriterProperties().addXmpMetadata())); manipulatePdf(pdf, true); - Assert.assertNull(new CompareTool().compareXmp(destinationFolder + fileName, sourceFolder + "cmp_" + fileName, true)); + Assertions.assertNull(new CompareTool().compareXmp(destinationFolder + fileName, sourceFolder + "cmp_" + fileName, true)); } private void manipulatePdf(PdfDocument pdfDocument, boolean setTagged) throws IOException { diff --git a/layout/src/test/java/com/itextpdf/layout/element/FlexContainerColumnTest.java b/layout/src/test/java/com/itextpdf/layout/element/FlexContainerColumnTest.java index 18ee32635b..0e80ef1721 100644 --- a/layout/src/test/java/com/itextpdf/layout/element/FlexContainerColumnTest.java +++ b/layout/src/test/java/com/itextpdf/layout/element/FlexContainerColumnTest.java @@ -35,44 +35,25 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; import java.util.Arrays; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; - -@RunWith(Parameterized.class) -@Category(IntegrationTest.class) +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +@Tag("IntegrationTest") public class FlexContainerColumnTest extends ExtendedITextTest { public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/layout/FlexContainerColumnTest/"; public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/layout/FlexContainerColumnTest/"; - private AlignmentPropertyValue alignItemsValue; - private JustifyContent justifyContentValue; - private FlexWrapPropertyValue wrapValue; - private FlexDirectionPropertyValue directionValue; - private Integer comparisonPdfId; - - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(DESTINATION_FOLDER); } - public FlexContainerColumnTest(Object alignItemsValue, Object justifyContentValue, Object wrapValue, - Object directionValue, Object comparisonPdfId) { - this.alignItemsValue = (AlignmentPropertyValue) alignItemsValue; - this.justifyContentValue = (JustifyContent) justifyContentValue; - this.wrapValue = (FlexWrapPropertyValue) wrapValue; - this.directionValue = (FlexDirectionPropertyValue) directionValue; - this.comparisonPdfId = (Integer) comparisonPdfId; - } - - @Parameterized.Parameters(name = "{index}: align-items: {0}; justify-content: {1}; flex-wrap: {2}; flex-direction: {3}") public static Iterable alignItemsAndJustifyContentProperties() { return Arrays.asList(new Object[][]{ {AlignmentPropertyValue.FLEX_END, JustifyContent.FLEX_END, FlexWrapPropertyValue.NOWRAP, @@ -92,17 +73,20 @@ public static Iterable alignItemsAndJustifyContentProperties() { }); } - @Test - public void defaultFlexContainerTest() throws IOException, InterruptedException { + @ParameterizedTest(name = "{index}: align-items: {0}; justify-content: {1}; flex-wrap: {2}; flex-direction: {3}") + @MethodSource("alignItemsAndJustifyContentProperties") + public void defaultFlexContainerTest(AlignmentPropertyValue alignItemsValue, JustifyContent justifyContentValue, + FlexWrapPropertyValue wrapValue, FlexDirectionPropertyValue directionValue, Integer comparisonPdfId) + throws IOException, InterruptedException { String outFileName = DESTINATION_FOLDER + "defaultFlexContainerTest" + comparisonPdfId + ".pdf"; String cmpFileName = SOURCE_FOLDER + "cmp_defaultFlexContainerTest" + comparisonPdfId + ".pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); Document document = new Document(pdfDocument); - Div flexContainer = createFlexContainer(); + Div flexContainer = createFlexContainer(alignItemsValue, justifyContentValue, wrapValue, directionValue); flexContainer.setProperty(Property.MARGIN_TOP, UnitValue.createPointValue(50)); - flexContainer.setProperty(Property.BORDER, new SolidBorder(2)); + flexContainer.setBorder(new SolidBorder(2)); flexContainer.setProperty(Property.PADDING_LEFT, UnitValue.createPointValue(40)); flexContainer.setProperty(Property.BACKGROUND, new Background(ColorConstants.LIGHT_GRAY)); @@ -117,20 +101,22 @@ public void defaultFlexContainerTest() throws IOException, InterruptedException document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } - @Test - public void flexContainerFixedHeightWidthTest() throws IOException, InterruptedException { + @ParameterizedTest(name = "{index}: align-items: {0}; justify-content: {1}; flex-wrap: {2}; flex-direction: {3}") + @MethodSource("alignItemsAndJustifyContentProperties") + public void flexContainerFixedHeightWidthTest(AlignmentPropertyValue alignItemsValue, JustifyContent justifyContentValue, + FlexWrapPropertyValue wrapValue, FlexDirectionPropertyValue directionValue, Integer comparisonPdfId) throws IOException, InterruptedException { String outFileName = DESTINATION_FOLDER + "flexContainerFixedHeightWidthTest" + comparisonPdfId + ".pdf"; String cmpFileName = SOURCE_FOLDER + "cmp_flexContainerFixedHeightWidthTest" + comparisonPdfId + ".pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); Document document = new Document(pdfDocument); - Div flexContainer = createFlexContainer(); + Div flexContainer = createFlexContainer(alignItemsValue, justifyContentValue, wrapValue, directionValue); flexContainer.setProperty(Property.MARGIN_TOP, UnitValue.createPointValue(50)); - flexContainer.setProperty(Property.BORDER, new SolidBorder(2)); + flexContainer.setBorder(new SolidBorder(2)); flexContainer.setProperty(Property.PADDING_LEFT, UnitValue.createPointValue(40)); flexContainer.setProperty(Property.BACKGROUND, new Background(ColorConstants.LIGHT_GRAY)); flexContainer.setProperty(Property.WIDTH, UnitValue.createPointValue(450)); @@ -147,19 +133,21 @@ public void flexContainerFixedHeightWidthTest() throws IOException, InterruptedE document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } - @Test - public void flexContainerDifferentChildrenTest() throws IOException, InterruptedException { + @ParameterizedTest(name = "{index}: align-items: {0}; justify-content: {1}; flex-wrap: {2}; flex-direction: {3}") + @MethodSource("alignItemsAndJustifyContentProperties") + public void flexContainerDifferentChildrenTest(AlignmentPropertyValue alignItemsValue, JustifyContent justifyContentValue, + FlexWrapPropertyValue wrapValue, FlexDirectionPropertyValue directionValue, Integer comparisonPdfId) throws IOException, InterruptedException { String outFileName = DESTINATION_FOLDER + "flexContainerDifferentChildrenTest" + comparisonPdfId + ".pdf"; String cmpFileName = SOURCE_FOLDER + "cmp_flexContainerDifferentChildrenTest" + comparisonPdfId + ".pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); Document document = new Document(pdfDocument); - Div flexContainer = createFlexContainer(); - flexContainer.setProperty(Property.BORDER, new SolidBorder(2)); + Div flexContainer = createFlexContainer(alignItemsValue, justifyContentValue, wrapValue, directionValue); + flexContainer.setBorder(new SolidBorder(2)); flexContainer.setProperty(Property.BACKGROUND, new Background(ColorConstants.LIGHT_GRAY)); Div innerDiv = new Div(); @@ -181,20 +169,22 @@ public void flexContainerDifferentChildrenTest() throws IOException, Interrupted document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } - @Test + @ParameterizedTest(name = "{index}: align-items: {0}; justify-content: {1}; flex-wrap: {2}; flex-direction: {3}") + @MethodSource("alignItemsAndJustifyContentProperties") @LogMessages(messages = @LogMessage(messageTemplate = LayoutLogMessageConstant.ELEMENT_DOES_NOT_FIT_AREA), ignore = true) - public void flexContainerDifferentChildrenDontFitVerticallyTest() throws IOException, InterruptedException { + public void flexContainerDifferentChildrenDontFitVerticallyTest(AlignmentPropertyValue alignItemsValue, JustifyContent justifyContentValue, + FlexWrapPropertyValue wrapValue, FlexDirectionPropertyValue directionValue, Integer comparisonPdfId) throws IOException, InterruptedException { String outFileName = DESTINATION_FOLDER + "flexContainerDifferentChildrenDontFitHorizontallyTest" + comparisonPdfId + ".pdf"; String cmpFileName = SOURCE_FOLDER + "cmp_flexContainerDifferentChildrenDontFitHorizontallyTest" + comparisonPdfId + ".pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); Document document = new Document(pdfDocument); - Div flexContainer = createFlexContainer(); - flexContainer.setProperty(Property.BORDER, new SolidBorder(2)); + Div flexContainer = createFlexContainer(alignItemsValue, justifyContentValue, wrapValue, directionValue); + flexContainer.setBorder(new SolidBorder(2)); flexContainer.setProperty(Property.BACKGROUND, new Background(ColorConstants.LIGHT_GRAY)); flexContainer.setProperty(Property.HEIGHT, UnitValue.createPointValue(300)); @@ -216,19 +206,21 @@ public void flexContainerDifferentChildrenDontFitVerticallyTest() throws IOExcep document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } - @Test - public void flexContainerDifferentChildrenWithGrowTest() throws IOException, InterruptedException { + @ParameterizedTest(name = "{index}: align-items: {0}; justify-content: {1}; flex-wrap: {2}; flex-direction: {3}") + @MethodSource("alignItemsAndJustifyContentProperties") + public void flexContainerDifferentChildrenWithGrowTest(AlignmentPropertyValue alignItemsValue, JustifyContent justifyContentValue, + FlexWrapPropertyValue wrapValue, FlexDirectionPropertyValue directionValue, Integer comparisonPdfId) throws IOException, InterruptedException { String outFileName = DESTINATION_FOLDER + "flexContainerDifferentChildrenWithGrowTest" + comparisonPdfId + ".pdf"; String cmpFileName = SOURCE_FOLDER + "cmp_flexContainerDifferentChildrenWithGrowTest" + comparisonPdfId + ".pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); Document document = new Document(pdfDocument); - Div flexContainer = createFlexContainer(); - flexContainer.setProperty(Property.BORDER, new SolidBorder(2)); + Div flexContainer = createFlexContainer(alignItemsValue, justifyContentValue, wrapValue, directionValue); + flexContainer.setBorder(new SolidBorder(2)); flexContainer.setProperty(Property.BACKGROUND, new Background(ColorConstants.LIGHT_GRAY)); Div innerDiv = new Div(); @@ -256,19 +248,21 @@ public void flexContainerDifferentChildrenWithGrowTest() throws IOException, Int document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } - @Test - public void flexContainerDifferentChildrenWithFlexBasisTest() throws IOException, InterruptedException { + @ParameterizedTest(name = "{index}: align-items: {0}; justify-content: {1}; flex-wrap: {2}; flex-direction: {3}") + @MethodSource("alignItemsAndJustifyContentProperties") + public void flexContainerDifferentChildrenWithFlexBasisTest(AlignmentPropertyValue alignItemsValue, JustifyContent justifyContentValue, + FlexWrapPropertyValue wrapValue, FlexDirectionPropertyValue directionValue, Integer comparisonPdfId) throws IOException, InterruptedException { String outFileName = DESTINATION_FOLDER + "flexContainerDifferentChildrenWithFlexBasisTest" + comparisonPdfId + ".pdf"; String cmpFileName = SOURCE_FOLDER + "cmp_flexContainerDifferentChildrenWithFlexBasisTest" + comparisonPdfId + ".pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); Document document = new Document(pdfDocument); - Div flexContainer = createFlexContainer(); - flexContainer.setProperty(Property.BORDER, new SolidBorder(2)); + Div flexContainer = createFlexContainer(alignItemsValue, justifyContentValue, wrapValue, directionValue); + flexContainer.setBorder(new SolidBorder(2)); flexContainer.setProperty(Property.BACKGROUND, new Background(ColorConstants.LIGHT_GRAY)); Table table = new Table(UnitValue.createPercentArray(new float[] {50, 50})); @@ -291,20 +285,22 @@ public void flexContainerDifferentChildrenWithFlexBasisTest() throws IOException document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } - @Test - public void flexContainerDifferentChildrenWithFlexShrinkTest() throws IOException, InterruptedException { + @ParameterizedTest(name = "{index}: align-items: {0}; justify-content: {1}; flex-wrap: {2}; flex-direction: {3}") + @MethodSource("alignItemsAndJustifyContentProperties") + public void flexContainerDifferentChildrenWithFlexShrinkTest(AlignmentPropertyValue alignItemsValue, JustifyContent justifyContentValue, + FlexWrapPropertyValue wrapValue, FlexDirectionPropertyValue directionValue, Integer comparisonPdfId) throws IOException, InterruptedException { String outFileName = DESTINATION_FOLDER + "flexContainerDifferentChildrenWithFlexShrinkTest" + comparisonPdfId + ".pdf"; String cmpFileName = SOURCE_FOLDER + "cmp_flexContainerDifferentChildrenWithFlexShrinkTest" + comparisonPdfId + ".pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); Document document = new Document(pdfDocument); - Div flexContainer = createFlexContainer(); + Div flexContainer = createFlexContainer(alignItemsValue, justifyContentValue, wrapValue, directionValue); flexContainer.setHeight(450); - flexContainer.setProperty(Property.BORDER, new SolidBorder(2)); + flexContainer.setBorder(new SolidBorder(2)); flexContainer.setProperty(Property.BACKGROUND, new Background(ColorConstants.LIGHT_GRAY)); Table table = new Table(UnitValue.createPercentArray(new float[] {50, 50})); @@ -330,19 +326,21 @@ public void flexContainerDifferentChildrenWithFlexShrinkTest() throws IOExceptio document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } - @Test - public void flexContainerInsideFlexContainerTest() throws IOException, InterruptedException { + @ParameterizedTest(name = "{index}: align-items: {0}; justify-content: {1}; flex-wrap: {2}; flex-direction: {3}") + @MethodSource("alignItemsAndJustifyContentProperties") + public void flexContainerInsideFlexContainerTest(AlignmentPropertyValue alignItemsValue, JustifyContent justifyContentValue, + FlexWrapPropertyValue wrapValue, FlexDirectionPropertyValue directionValue, Integer comparisonPdfId) throws IOException, InterruptedException { String outFileName = DESTINATION_FOLDER + "flexContainerInsideFlexContainerTest" + comparisonPdfId + ".pdf"; String cmpFileName = SOURCE_FOLDER + "cmp_flexContainerInsideFlexContainerTest" + comparisonPdfId + ".pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); Document document = new Document(pdfDocument); - Div flexContainer = createFlexContainer(); - flexContainer.setProperty(Property.BORDER, new SolidBorder(2)); + Div flexContainer = createFlexContainer(alignItemsValue, justifyContentValue, wrapValue, directionValue); + flexContainer.setBorder(new SolidBorder(2)); flexContainer.setProperty(Property.BACKGROUND, new Background(ColorConstants.LIGHT_GRAY)); Div innerFlex = new FlexContainer(); @@ -359,19 +357,21 @@ public void flexContainerInsideFlexContainerTest() throws IOException, Interrupt document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } - @Test - public void multipleFlexContainersInsideFlexContainerTest() throws IOException, InterruptedException { + @ParameterizedTest(name = "{index}: align-items: {0}; justify-content: {1}; flex-wrap: {2}; flex-direction: {3}") + @MethodSource("alignItemsAndJustifyContentProperties") + public void multipleFlexContainersInsideFlexContainerTest(AlignmentPropertyValue alignItemsValue, JustifyContent justifyContentValue, + FlexWrapPropertyValue wrapValue, FlexDirectionPropertyValue directionValue, Integer comparisonPdfId) throws IOException, InterruptedException { String outFileName = DESTINATION_FOLDER + "multipleFlexContainersInsideFlexContainerTest" + comparisonPdfId + ".pdf"; String cmpFileName = SOURCE_FOLDER + "cmp_multipleFlexContainersInsideFlexContainerTest" + comparisonPdfId + ".pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); Document document = new Document(pdfDocument); - Div flexContainer = createFlexContainer(); - flexContainer.setProperty(Property.BORDER, new SolidBorder(2)); + Div flexContainer = createFlexContainer(alignItemsValue, justifyContentValue, wrapValue, directionValue); + flexContainer.setBorder(new SolidBorder(2)); flexContainer.setProperty(Property.BACKGROUND, new Background(ColorConstants.LIGHT_GRAY)); Div innerFlex1 = new FlexContainer(); @@ -397,19 +397,21 @@ public void multipleFlexContainersInsideFlexContainerTest() throws IOException, document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } - @Test - public void flexContainerRotationAngleTest() throws IOException, InterruptedException { + @ParameterizedTest(name = "{index}: align-items: {0}; justify-content: {1}; flex-wrap: {2}; flex-direction: {3}") + @MethodSource("alignItemsAndJustifyContentProperties") + public void flexContainerRotationAngleTest(AlignmentPropertyValue alignItemsValue, JustifyContent justifyContentValue, + FlexWrapPropertyValue wrapValue, FlexDirectionPropertyValue directionValue, Integer comparisonPdfId) throws IOException, InterruptedException { String outFileName = DESTINATION_FOLDER + "flexContainerRotationAngleTest" + comparisonPdfId + ".pdf"; String cmpFileName = SOURCE_FOLDER + "cmp_flexContainerRotationAngleTest" + comparisonPdfId + ".pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); Document document = new Document(pdfDocument); - Div flexContainer = createFlexContainer(); - flexContainer.setProperty(Property.BORDER, new SolidBorder(2)); + Div flexContainer = createFlexContainer(alignItemsValue, justifyContentValue, wrapValue, directionValue); + flexContainer.setBorder(new SolidBorder(2)); flexContainer.setProperty(Property.BACKGROUND, new Background(ColorConstants.LIGHT_GRAY)); flexContainer.setProperty(Property.ROTATION_ANGLE, 20f); @@ -428,19 +430,21 @@ public void flexContainerRotationAngleTest() throws IOException, InterruptedExce document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } - @Test - public void flexItemBoxSizingTest() throws IOException, InterruptedException { + @ParameterizedTest(name = "{index}: align-items: {0}; justify-content: {1}; flex-wrap: {2}; flex-direction: {3}") + @MethodSource("alignItemsAndJustifyContentProperties") + public void flexItemBoxSizingTest(AlignmentPropertyValue alignItemsValue, JustifyContent justifyContentValue, + FlexWrapPropertyValue wrapValue, FlexDirectionPropertyValue directionValue, Integer comparisonPdfId) throws IOException, InterruptedException { String outFileName = DESTINATION_FOLDER + "flexItemBoxSizingTest" + comparisonPdfId + ".pdf"; String cmpFileName = SOURCE_FOLDER + "cmp_flexItemBoxSizingTest" + comparisonPdfId + ".pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); Document document = new Document(pdfDocument); - Div flexContainer = createFlexContainer(); - flexContainer.setProperty(Property.BORDER, new SolidBorder(ColorConstants.BLUE, 30)); + Div flexContainer = createFlexContainer(alignItemsValue, justifyContentValue, wrapValue, directionValue); + flexContainer.setBorder(new SolidBorder(ColorConstants.BLUE, 30)); flexContainer.setProperty(Property.BACKGROUND, new Background(ColorConstants.LIGHT_GRAY)); flexContainer.setWidth(250); flexContainer.setHeight(400); @@ -476,19 +480,21 @@ public void flexItemBoxSizingTest() throws IOException, InterruptedException { document.add(flexContainer); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } - @Test - public void flexContainerBoxSizingTest() throws IOException, InterruptedException { + @ParameterizedTest(name = "{index}: align-items: {0}; justify-content: {1}; flex-wrap: {2}; flex-direction: {3}") + @MethodSource("alignItemsAndJustifyContentProperties") + public void flexContainerBoxSizingTest(AlignmentPropertyValue alignItemsValue, JustifyContent justifyContentValue, + FlexWrapPropertyValue wrapValue, FlexDirectionPropertyValue directionValue, Integer comparisonPdfId) throws IOException, InterruptedException { String outFileName = DESTINATION_FOLDER + "flexContainerBoxSizingTest" + comparisonPdfId + ".pdf"; String cmpFileName = SOURCE_FOLDER + "cmp_flexContainerBoxSizingTest" + comparisonPdfId + ".pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); Document document = new Document(pdfDocument); - Div flexContainer = createFlexContainer(); - flexContainer.setProperty(Property.BORDER, new SolidBorder(ColorConstants.BLUE, 30)); + Div flexContainer = createFlexContainer(alignItemsValue, justifyContentValue, wrapValue, directionValue); + flexContainer.setBorder(new SolidBorder(ColorConstants.BLUE, 30)); flexContainer.setProperty(Property.BACKGROUND, new Background(ColorConstants.LIGHT_GRAY)); flexContainer.setWidth(450); flexContainer.setProperty(Property.BOX_SIZING, BoxSizingPropertyValue.BORDER_BOX); @@ -505,17 +511,19 @@ public void flexContainerBoxSizingTest() throws IOException, InterruptedExceptio document.add(flexContainer); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } - @Test + @ParameterizedTest(name = "{index}: align-items: {0}; justify-content: {1}; flex-wrap: {2}; flex-direction: {3}") + @MethodSource("alignItemsAndJustifyContentProperties") @LogMessages(messages = @LogMessage(messageTemplate = LayoutLogMessageConstant.ELEMENT_DOES_NOT_FIT_AREA), ignore = true) - public void flexContainerPaginationTest() throws IOException, InterruptedException { + public void flexContainerPaginationTest(AlignmentPropertyValue alignItemsValue, JustifyContent justifyContentValue, + FlexWrapPropertyValue wrapValue, FlexDirectionPropertyValue directionValue, Integer comparisonPdfId) throws IOException, InterruptedException { String outFileName = DESTINATION_FOLDER + "flexContainerPaginationTest" + comparisonPdfId + ".pdf"; String cmpFileName = SOURCE_FOLDER + "cmp_flexContainerPaginationTest" + comparisonPdfId + ".pdf"; try (Document document = new Document(new PdfDocument(new PdfWriter(outFileName)))) { - Div flexContainer = createFlexContainer(); + Div flexContainer = createFlexContainer(alignItemsValue, justifyContentValue, wrapValue, directionValue); flexContainer.deleteOwnProperty(Property.HEIGHT); flexContainer.setBorder(new SolidBorder(ColorConstants.BLUE, 10)); @@ -537,16 +545,18 @@ public void flexContainerPaginationTest() throws IOException, InterruptedExcepti document.add(flexContainer); } - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } - @Test - public void flexContainerWithFixedHeightPaginationTest() throws IOException, InterruptedException { + @ParameterizedTest(name = "{index}: align-items: {0}; justify-content: {1}; flex-wrap: {2}; flex-direction: {3}") + @MethodSource("alignItemsAndJustifyContentProperties") + public void flexContainerWithFixedHeightPaginationTest(AlignmentPropertyValue alignItemsValue, JustifyContent justifyContentValue, + FlexWrapPropertyValue wrapValue, FlexDirectionPropertyValue directionValue, Integer comparisonPdfId) throws IOException, InterruptedException { String outFileName = DESTINATION_FOLDER + "flexContainerWithFixedHeightPagination" + comparisonPdfId + ".pdf"; String cmpFileName = SOURCE_FOLDER + "cmp_flexContainerWithFixedHeightPagination" + comparisonPdfId + ".pdf"; try (Document document = new Document(new PdfDocument(new PdfWriter(outFileName)))) { - Div flexContainer = createFlexContainer(); + Div flexContainer = createFlexContainer(alignItemsValue, justifyContentValue, wrapValue, directionValue); flexContainer.setHeight(1000); flexContainer.setBorder(new SolidBorder(ColorConstants.PINK, 10)); @@ -568,18 +578,20 @@ public void flexContainerWithFixedHeightPaginationTest() throws IOException, Int document.add(flexContainer); } - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } - @Test + @ParameterizedTest(name = "{index}: align-items: {0}; justify-content: {1}; flex-wrap: {2}; flex-direction: {3}") + @MethodSource("alignItemsAndJustifyContentProperties") @LogMessages(messages = @LogMessage(messageTemplate = IoLogMessageConstant.CLIP_ELEMENT), ignore = true) - public void flexContainerInsideDivPaginationTest() throws IOException, InterruptedException { + public void flexContainerInsideDivPaginationTest(AlignmentPropertyValue alignItemsValue, JustifyContent justifyContentValue, + FlexWrapPropertyValue wrapValue, FlexDirectionPropertyValue directionValue, Integer comparisonPdfId) throws IOException, InterruptedException { String outFileName = DESTINATION_FOLDER + "flexContainerInsideDivPaginationTest" + comparisonPdfId + ".pdf"; String cmpFileName = SOURCE_FOLDER + "cmp_flexContainerInsideDivPaginationTest" + comparisonPdfId + ".pdf"; try (Document document = new Document(new PdfDocument(new PdfWriter(outFileName)))) { Div div = new Div().setHeight(1800).setWidth(350).setBorder(new SolidBorder(ColorConstants.RED, 20)); - Div flexContainer = createFlexContainer(); + Div flexContainer = createFlexContainer(alignItemsValue, justifyContentValue, wrapValue, directionValue); flexContainer.deleteOwnProperty(Property.HEIGHT); flexContainer.setBorder(new SolidBorder(ColorConstants.BLUE, 10)); @@ -602,18 +614,20 @@ public void flexContainerInsideDivPaginationTest() throws IOException, Interrupt document.add(div); } - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } - @Test + @ParameterizedTest(name = "{index}: align-items: {0}; justify-content: {1}; flex-wrap: {2}; flex-direction: {3}") + @MethodSource("alignItemsAndJustifyContentProperties") @LogMessages(messages = @LogMessage(messageTemplate = IoLogMessageConstant.CLIP_ELEMENT), ignore = true) - public void flexContainerInsideDivTest() throws IOException, InterruptedException { + public void flexContainerInsideDivTest(AlignmentPropertyValue alignItemsValue, JustifyContent justifyContentValue, + FlexWrapPropertyValue wrapValue, FlexDirectionPropertyValue directionValue, Integer comparisonPdfId) throws IOException, InterruptedException { String outFileName = DESTINATION_FOLDER + "flexContainerInsideDivTest" + comparisonPdfId + ".pdf"; String cmpFileName = SOURCE_FOLDER + "cmp_flexContainerInsideDivTest" + comparisonPdfId + ".pdf"; try (Document document = new Document(new PdfDocument(new PdfWriter(outFileName)))) { Div div = new Div().setHeight(400).setWidth(140).setBorder(new SolidBorder(ColorConstants.PINK, 10)); - Div flexContainer = createFlexContainer(); + Div flexContainer = createFlexContainer(alignItemsValue, justifyContentValue, wrapValue, directionValue); flexContainer.deleteOwnProperty(Property.HEIGHT); flexContainer.setBorder(new SolidBorder(ColorConstants.YELLOW, 5)); @@ -631,10 +645,11 @@ public void flexContainerInsideDivTest() throws IOException, InterruptedExceptio document.add(div); } - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } - private FlexContainer createFlexContainer() { + private FlexContainer createFlexContainer(AlignmentPropertyValue alignItemsValue, JustifyContent justifyContentValue, + FlexWrapPropertyValue wrapValue, FlexDirectionPropertyValue directionValue) { FlexContainer flexContainer = new FlexContainer(); flexContainer.setProperty(Property.ALIGN_ITEMS, alignItemsValue); flexContainer.setProperty(Property.JUSTIFY_CONTENT, justifyContentValue); @@ -648,7 +663,7 @@ private FlexContainer createFlexContainer() { private static Div createNewDiv() { Div newDiv = new Div(); - newDiv.setProperty(Property.BORDER, new SolidBorder(1)); + newDiv.setBorder(new SolidBorder(1)); newDiv.setProperty(Property.WIDTH, UnitValue.createPointValue(50)); newDiv.setProperty(Property.HEIGHT, UnitValue.createPointValue(100)); return newDiv; diff --git a/layout/src/test/java/com/itextpdf/layout/element/FlexContainerSplitTest.java b/layout/src/test/java/com/itextpdf/layout/element/FlexContainerSplitTest.java index 2c5cdab947..b9c29b4e7d 100644 --- a/layout/src/test/java/com/itextpdf/layout/element/FlexContainerSplitTest.java +++ b/layout/src/test/java/com/itextpdf/layout/element/FlexContainerSplitTest.java @@ -35,15 +35,14 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class FlexContainerSplitTest extends ExtendedITextTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/layout/FlexContainerSplitTest/"; @@ -56,7 +55,7 @@ public class FlexContainerSplitTest extends ExtendedITextTest { + "cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. "; private static final String SHORT_TEXT = "Lorem ipsum dolor sit amet, consectetur adipiscing elit,?"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(DESTINATION_FOLDER); } @@ -73,7 +72,7 @@ public void simpleTest() throws IOException, InterruptedException { document.add(flexContainer); } - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -90,7 +89,7 @@ public void heightPropertyTest() throws IOException, InterruptedException { document.add(flexContainer); } - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -112,7 +111,7 @@ public void smallTrailingElementTest() throws IOException, InterruptedException document.add(flexContainer); } - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -128,7 +127,7 @@ public void splitOverSeveralPagesTest() throws IOException, InterruptedException document.add(flexContainer); } - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -148,7 +147,7 @@ public void keepTogetherIgnoredTest() throws IOException, InterruptedException { document.add(flexContainer); } - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -164,7 +163,7 @@ public void simpleWrapTest() throws IOException, InterruptedException { document.add(flexContainer); } - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -182,7 +181,7 @@ public void simpleWrapStartTest() throws IOException, InterruptedException { document.add(flexContainer); } - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -200,7 +199,7 @@ public void simpleWrapEndTest() throws IOException, InterruptedException { document.add(flexContainer); } - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -218,12 +217,12 @@ public void reverseWrapStartTest() throws IOException, InterruptedException { document.add(flexContainer); } - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @LogMessages(messages = { - @LogMessage(messageTemplate = IoLogMessageConstant.TYPOGRAPHY_NOT_FOUND, count = 556) + @LogMessage(messageTemplate = IoLogMessageConstant.TYPOGRAPHY_NOT_FOUND, count = 553) }) public void rowWrapRtlStartTest() throws IOException, InterruptedException { String outFileName = DESTINATION_FOLDER + "rowWrapRtlStartTest.pdf"; @@ -240,12 +239,12 @@ public void rowWrapRtlStartTest() throws IOException, InterruptedException { document.add(flexContainer); } - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @LogMessages(messages = { - @LogMessage(messageTemplate = IoLogMessageConstant.TYPOGRAPHY_NOT_FOUND, count = 556) + @LogMessage(messageTemplate = IoLogMessageConstant.TYPOGRAPHY_NOT_FOUND, count = 553) }) public void reverseRowWrapRtlStartTest() throws IOException, InterruptedException { String outFileName = DESTINATION_FOLDER + "reverseRowWrapRtlStartTest.pdf"; @@ -263,7 +262,7 @@ public void reverseRowWrapRtlStartTest() throws IOException, InterruptedExceptio document.add(flexContainer); } - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -281,7 +280,7 @@ public void reverseWrapEndTest() throws IOException, InterruptedException { document.add(flexContainer); } - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -300,7 +299,7 @@ public void reverseWrapStartHeightTest() throws IOException, InterruptedExceptio document.add(flexContainer); } - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -319,7 +318,7 @@ public void reverseWrapEndHeightTest() throws IOException, InterruptedException document.add(flexContainer); } - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -337,12 +336,38 @@ public void simpleWrapCenterTest() throws IOException, InterruptedException { document.add(flexContainer); } - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + } + + @Test + public void tableInFlexOnSplitTest() throws IOException, InterruptedException { + String outFileName = DESTINATION_FOLDER + "tableInFlexOnSplitTest.pdf"; + String cmpFileName = SOURCE_FOLDER + "tableInFlexOnSplitTest.pdf"; + try (PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName))) { + Document document = new Document(pdfDocument); + pdfDocument.setDefaultPageSize(PageSize.A5); + + Div flexContainer = new FlexContainer(); + flexContainer.setBackgroundColor(ColorConstants.LIGHT_GRAY); + flexContainer.setBorder(new SolidBorder(2)); + Table table = new Table(UnitValue.createPercentArray(new float[] {10, 10, 10})); + for (int i = 1; i <= 3; i++) { + table.addHeaderCell("Header" + i); + } + for (int i = 1; i <= 150; i++) { + table.addCell("Cell" + i); + } + + flexContainer.add(table); + document.add(flexContainer); + } + + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } private Div createDefaultFlexContainer() { Div flexContainer = new FlexContainer(); - flexContainer.setProperty(Property.BORDER, new SolidBorder(2)); + flexContainer.setBorder(new SolidBorder(2)); flexContainer.setProperty(Property.BACKGROUND, new Background(ColorConstants.LIGHT_GRAY)); Paragraph p1 = new Paragraph(SHORT_TEXT) .setWidth(UnitValue.createPercentValue(25)) @@ -363,7 +388,7 @@ private Div createDefaultFlexContainer() { private Div createDefaultFlexContainerForWrap() { Div flexContainer = new FlexContainer(); - flexContainer.setProperty(Property.BORDER, new SolidBorder(2)); + flexContainer.setBorder(new SolidBorder(2)); flexContainer.setProperty(Property.BACKGROUND, new Background(ColorConstants.LIGHT_GRAY)); Paragraph p1 = new Paragraph(SHORT_TEXT) .setWidth(UnitValue.createPercentValue(20)) diff --git a/layout/src/test/java/com/itextpdf/layout/element/FlexContainerTest.java b/layout/src/test/java/com/itextpdf/layout/element/FlexContainerTest.java index 51575f116a..e5e7451eae 100644 --- a/layout/src/test/java/com/itextpdf/layout/element/FlexContainerTest.java +++ b/layout/src/test/java/com/itextpdf/layout/element/FlexContainerTest.java @@ -36,44 +36,25 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; import java.util.Arrays; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; - -@RunWith(Parameterized.class) -@Category(IntegrationTest.class) +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +@Tag("IntegrationTest") public class FlexContainerTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/layout/FlexContainerTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/layout/FlexContainerTest/"; - private AlignmentPropertyValue alignItemsValue; - private JustifyContent justifyContentValue; - private FlexWrapPropertyValue wrapValue; - private FlexDirectionPropertyValue directionValue; - private Integer comparisonPdfId; - - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } - public FlexContainerTest(Object alignItemsValue, Object justifyContentValue, Object wrapValue, - Object directionValue, Object comparisonPdfId) { - this.alignItemsValue = (AlignmentPropertyValue) alignItemsValue; - this.justifyContentValue = (JustifyContent) justifyContentValue; - this.wrapValue = (FlexWrapPropertyValue) wrapValue; - this.directionValue = (FlexDirectionPropertyValue) directionValue; - this.comparisonPdfId = (Integer) comparisonPdfId; - } - - @Parameterized.Parameters(name = "{index}: align-items: {0}; justify-content: {1}; flex-wrap: {2}; flex-direction: {3}") public static Iterable alignItemsAndJustifyContentProperties() { return Arrays.asList(new Object[][]{ {AlignmentPropertyValue.FLEX_START, JustifyContent.FLEX_START, FlexWrapPropertyValue.NOWRAP, @@ -103,17 +84,20 @@ public static Iterable alignItemsAndJustifyContentProperties() { }); } - @Test - public void defaultFlexContainerTest() throws IOException, InterruptedException { + @ParameterizedTest(name = "{index}: align-items: {0}; justify-content: {1}; flex-wrap: {2}; flex-direction: {3}") + @MethodSource("alignItemsAndJustifyContentProperties") + public void defaultFlexContainerTest(AlignmentPropertyValue alignItemsValue, JustifyContent justifyContentValue, + FlexWrapPropertyValue wrapValue, FlexDirectionPropertyValue directionValue, Integer comparisonPdfId) + throws IOException, InterruptedException { String outFileName = destinationFolder + "defaultFlexContainerTest" + comparisonPdfId + ".pdf"; String cmpFileName = sourceFolder + "cmp_defaultFlexContainerTest" + comparisonPdfId + ".pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); Document document = new Document(pdfDocument); - Div flexContainer = createFlexContainer(); + Div flexContainer = createFlexContainer(alignItemsValue, justifyContentValue, wrapValue, directionValue); flexContainer.setProperty(Property.MARGIN_TOP, UnitValue.createPointValue(50)); - flexContainer.setProperty(Property.BORDER, new SolidBorder(2)); + flexContainer.setBorder(new SolidBorder(2)); flexContainer.setProperty(Property.PADDING_LEFT, UnitValue.createPointValue(40)); flexContainer.setProperty(Property.BACKGROUND, new Background(ColorConstants.LIGHT_GRAY)); @@ -126,20 +110,23 @@ public void defaultFlexContainerTest() throws IOException, InterruptedException document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } - @Test - public void flexContainerFixedHeightWidthTest() throws IOException, InterruptedException { + @ParameterizedTest(name = "{index}: align-items: {0}; justify-content: {1}; flex-wrap: {2}; flex-direction: {3}") + @MethodSource("alignItemsAndJustifyContentProperties") + public void flexContainerFixedHeightWidthTest(AlignmentPropertyValue alignItemsValue, JustifyContent justifyContentValue, + FlexWrapPropertyValue wrapValue, FlexDirectionPropertyValue directionValue, Integer comparisonPdfId) + throws IOException, InterruptedException { String outFileName = destinationFolder + "flexContainerFixedHeightWidthTest" + comparisonPdfId + ".pdf"; String cmpFileName = sourceFolder + "cmp_flexContainerFixedHeightWidthTest" + comparisonPdfId + ".pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); Document document = new Document(pdfDocument); - Div flexContainer = createFlexContainer(); + Div flexContainer = createFlexContainer(alignItemsValue, justifyContentValue, wrapValue, directionValue); flexContainer.setProperty(Property.MARGIN_TOP, UnitValue.createPointValue(50)); - flexContainer.setProperty(Property.BORDER, new SolidBorder(2)); + flexContainer.setBorder(new SolidBorder(2)); flexContainer.setProperty(Property.PADDING_LEFT, UnitValue.createPointValue(40)); flexContainer.setProperty(Property.BACKGROUND, new Background(ColorConstants.LIGHT_GRAY)); flexContainer.setProperty(Property.WIDTH, UnitValue.createPointValue(450)); @@ -154,19 +141,22 @@ public void flexContainerFixedHeightWidthTest() throws IOException, InterruptedE document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } - @Test - public void flexContainerDifferentChildrenTest() throws IOException, InterruptedException { + @ParameterizedTest(name = "{index}: align-items: {0}; justify-content: {1}; flex-wrap: {2}; flex-direction: {3}") + @MethodSource("alignItemsAndJustifyContentProperties") + public void flexContainerDifferentChildrenTest(AlignmentPropertyValue alignItemsValue, JustifyContent justifyContentValue, + FlexWrapPropertyValue wrapValue, FlexDirectionPropertyValue directionValue, Integer comparisonPdfId) + throws IOException, InterruptedException { String outFileName = destinationFolder + "flexContainerDifferentChildrenTest" + comparisonPdfId + ".pdf"; String cmpFileName = sourceFolder + "cmp_flexContainerDifferentChildrenTest" + comparisonPdfId + ".pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); Document document = new Document(pdfDocument); - Div flexContainer = createFlexContainer(); - flexContainer.setProperty(Property.BORDER, new SolidBorder(2)); + Div flexContainer = createFlexContainer(alignItemsValue, justifyContentValue, wrapValue, directionValue); + flexContainer.setBorder(new SolidBorder(2)); flexContainer.setProperty(Property.BACKGROUND, new Background(ColorConstants.LIGHT_GRAY)); Div innerDiv = new Div(); @@ -188,21 +178,24 @@ public void flexContainerDifferentChildrenTest() throws IOException, Interrupted document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } - @Test + @ParameterizedTest(name = "{index}: align-items: {0}; justify-content: {1}; flex-wrap: {2}; flex-direction: {3}") + @MethodSource("alignItemsAndJustifyContentProperties") // If height is clipped the behavior strongly depends on the child renderers // and the results are not expected sometimes - public void flexContainerHeightClippedTest() throws IOException, InterruptedException { + public void flexContainerHeightClippedTest(AlignmentPropertyValue alignItemsValue, JustifyContent justifyContentValue, + FlexWrapPropertyValue wrapValue, FlexDirectionPropertyValue directionValue, Integer comparisonPdfId) + throws IOException, InterruptedException { String outFileName = destinationFolder + "flexContainerHeightClippedTest" + comparisonPdfId + ".pdf"; String cmpFileName = sourceFolder + "cmp_flexContainerHeightClippedTest" + comparisonPdfId + ".pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); Document document = new Document(pdfDocument); - Div flexContainer = createFlexContainer(); - flexContainer.setProperty(Property.BORDER, new SolidBorder(2)); + Div flexContainer = createFlexContainer(alignItemsValue, justifyContentValue, wrapValue, directionValue); + flexContainer.setBorder(new SolidBorder(2)); flexContainer.setProperty(Property.BACKGROUND, new Background(ColorConstants.LIGHT_GRAY)); flexContainer.setHeight(250); @@ -225,21 +218,23 @@ public void flexContainerHeightClippedTest() throws IOException, InterruptedExce document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } - @Test + @ParameterizedTest(name = "{index}: align-items: {0}; justify-content: {1}; flex-wrap: {2}; flex-direction: {3}") + @MethodSource("alignItemsAndJustifyContentProperties") @LogMessages(messages = @LogMessage(messageTemplate = LayoutLogMessageConstant.ELEMENT_DOES_NOT_FIT_AREA), ignore = true) // TODO DEVSIX-5042 HEIGHT property is ignored when FORCED_PLACEMENT is true - public void flexContainerDifferentChildrenDontFitHorizontallyTest() throws IOException, InterruptedException { + public void flexContainerDifferentChildrenDontFitHorizontallyTest(AlignmentPropertyValue alignItemsValue, JustifyContent justifyContentValue, + FlexWrapPropertyValue wrapValue, FlexDirectionPropertyValue directionValue, Integer comparisonPdfId) throws IOException, InterruptedException { String outFileName = destinationFolder + "flexContainerDifferentChildrenDontFitHorizontallyTest" + comparisonPdfId + ".pdf"; String cmpFileName = sourceFolder + "cmp_flexContainerDifferentChildrenDontFitHorizontallyTest" + comparisonPdfId + ".pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); Document document = new Document(pdfDocument); - Div flexContainer = createFlexContainer(); - flexContainer.setProperty(Property.BORDER, new SolidBorder(2)); + Div flexContainer = createFlexContainer(alignItemsValue, justifyContentValue, wrapValue, directionValue); + flexContainer.setBorder(new SolidBorder(2)); flexContainer.setProperty(Property.BACKGROUND, new Background(ColorConstants.LIGHT_GRAY)); flexContainer.setProperty(Property.WIDTH, UnitValue.createPointValue(300)); @@ -261,20 +256,22 @@ public void flexContainerDifferentChildrenDontFitHorizontallyTest() throws IOExc document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } - @Test + @ParameterizedTest(name = "{index}: align-items: {0}; justify-content: {1}; flex-wrap: {2}; flex-direction: {3}") + @MethodSource("alignItemsAndJustifyContentProperties") // TODO DEVSIX-5042 HEIGHT property is ignored when FORCED_PLACEMENT is true - public void flexContainerDifferentChildrenDontFitHorizontallyForcedPlacementTest() throws IOException, InterruptedException { + public void flexContainerDifferentChildrenDontFitHorizontallyForcedPlacementTest(AlignmentPropertyValue alignItemsValue, JustifyContent justifyContentValue, + FlexWrapPropertyValue wrapValue, FlexDirectionPropertyValue directionValue, Integer comparisonPdfId) throws IOException, InterruptedException { String outFileName = destinationFolder + "flexContainerDifferentChildrenDontFitHorizontallyForcedPlacementTest" + comparisonPdfId + ".pdf"; String cmpFileName = sourceFolder + "cmp_flexContainerDifferentChildrenDontFitHorizontallyForcedPlacementTest" + comparisonPdfId + ".pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); Document document = new Document(pdfDocument); - Div flexContainer = createFlexContainer(); - flexContainer.setProperty(Property.BORDER, new SolidBorder(2)); + Div flexContainer = createFlexContainer(alignItemsValue, justifyContentValue, wrapValue, directionValue); + flexContainer.setBorder(new SolidBorder(2)); flexContainer.setProperty(Property.BACKGROUND, new Background(ColorConstants.LIGHT_GRAY)); flexContainer.setProperty(Property.FORCED_PLACEMENT, true); @@ -296,20 +293,22 @@ public void flexContainerDifferentChildrenDontFitHorizontallyForcedPlacementTest document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } - @Test + @ParameterizedTest(name = "{index}: align-items: {0}; justify-content: {1}; flex-wrap: {2}; flex-direction: {3}") + @MethodSource("alignItemsAndJustifyContentProperties") @LogMessages(messages = @LogMessage(messageTemplate = IoLogMessageConstant.CLIP_ELEMENT), ignore = true) - public void flexContainerDifferentChildrenDontFitVerticallyTest() throws IOException, InterruptedException { + public void flexContainerDifferentChildrenDontFitVerticallyTest(AlignmentPropertyValue alignItemsValue, JustifyContent justifyContentValue, + FlexWrapPropertyValue wrapValue, FlexDirectionPropertyValue directionValue, Integer comparisonPdfId) throws IOException, InterruptedException { String outFileName = destinationFolder + "flexContainerDifferentChildrenDontFitVerticallyTest" + comparisonPdfId + ".pdf"; String cmpFileName = sourceFolder + "cmp_flexContainerDifferentChildrenDontFitVerticallyTest" + comparisonPdfId + ".pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); Document document = new Document(pdfDocument); - Div flexContainer = createFlexContainer(); - flexContainer.setProperty(Property.BORDER, new SolidBorder(2)); + Div flexContainer = createFlexContainer(alignItemsValue, justifyContentValue, wrapValue, directionValue); + flexContainer.setBorder(new SolidBorder(2)); flexContainer.setProperty(Property.BACKGROUND, new Background(ColorConstants.LIGHT_GRAY)); flexContainer.setHeight(500); Div innerDiv = new Div(); @@ -334,20 +333,22 @@ public void flexContainerDifferentChildrenDontFitVerticallyTest() throws IOExcep document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } - @Test + @ParameterizedTest(name = "{index}: align-items: {0}; justify-content: {1}; flex-wrap: {2}; flex-direction: {3}") + @MethodSource("alignItemsAndJustifyContentProperties") @LogMessages(messages = @LogMessage(messageTemplate = IoLogMessageConstant.CLIP_ELEMENT), ignore = true) - public void flexContainerDifferentChildrenFitContainerDoesNotFitVerticallyTest() throws IOException, InterruptedException { + public void flexContainerDifferentChildrenFitContainerDoesNotFitVerticallyTest(AlignmentPropertyValue alignItemsValue, JustifyContent justifyContentValue, + FlexWrapPropertyValue wrapValue, FlexDirectionPropertyValue directionValue, Integer comparisonPdfId) throws IOException, InterruptedException { String outFileName = destinationFolder + "flexContainerDifferentChildrenFitContainerDoesNotFitVerticallyTest" + comparisonPdfId + ".pdf"; String cmpFileName = sourceFolder + "cmp_flexContainerDifferentChildrenFitContainerDoesNotFitVerticallyTest" + comparisonPdfId + ".pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); Document document = new Document(pdfDocument); - Div flexContainer = createFlexContainer(); - flexContainer.setProperty(Property.BORDER, new SolidBorder(2)); + Div flexContainer = createFlexContainer(alignItemsValue, justifyContentValue, wrapValue, directionValue); + flexContainer.setBorder(new SolidBorder(2)); flexContainer.setProperty(Property.BACKGROUND, new Background(ColorConstants.LIGHT_GRAY)); flexContainer.setHeight(600); @@ -373,19 +374,22 @@ public void flexContainerDifferentChildrenFitContainerDoesNotFitVerticallyTest() document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } - @Test - public void flexContainerDifferentChildrenWithGrowTest() throws IOException, InterruptedException { + @ParameterizedTest(name = "{index}: align-items: {0}; justify-content: {1}; flex-wrap: {2}; flex-direction: {3}") + @MethodSource("alignItemsAndJustifyContentProperties") + public void flexContainerDifferentChildrenWithGrowTest(AlignmentPropertyValue alignItemsValue, JustifyContent justifyContentValue, + FlexWrapPropertyValue wrapValue, FlexDirectionPropertyValue directionValue, Integer comparisonPdfId) + throws IOException, InterruptedException { String outFileName = destinationFolder + "flexContainerDifferentChildrenWithGrowTest" + comparisonPdfId + ".pdf"; String cmpFileName = sourceFolder + "cmp_flexContainerDifferentChildrenWithGrowTest" + comparisonPdfId + ".pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); Document document = new Document(pdfDocument); - Div flexContainer = createFlexContainer(); - flexContainer.setProperty(Property.BORDER, new SolidBorder(2)); + Div flexContainer = createFlexContainer(alignItemsValue, justifyContentValue, wrapValue, directionValue); + flexContainer.setBorder(new SolidBorder(2)); flexContainer.setProperty(Property.BACKGROUND, new Background(ColorConstants.LIGHT_GRAY)); Div innerDiv = new Div(); @@ -413,19 +417,21 @@ public void flexContainerDifferentChildrenWithGrowTest() throws IOException, Int document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } - @Test - public void flexContainerDifferentChildrenWithFlexBasisTest() throws IOException, InterruptedException { + @ParameterizedTest(name = "{index}: align-items: {0}; justify-content: {1}; flex-wrap: {2}; flex-direction: {3}") + @MethodSource("alignItemsAndJustifyContentProperties") + public void flexContainerDifferentChildrenWithFlexBasisTest(AlignmentPropertyValue alignItemsValue, JustifyContent justifyContentValue, + FlexWrapPropertyValue wrapValue, FlexDirectionPropertyValue directionValue, Integer comparisonPdfId) throws IOException, InterruptedException { String outFileName = destinationFolder + "flexContainerDifferentChildrenWithFlexBasisTest" + comparisonPdfId + ".pdf"; String cmpFileName = sourceFolder + "cmp_flexContainerDifferentChildrenWithFlexBasisTest" + comparisonPdfId + ".pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); Document document = new Document(pdfDocument); - Div flexContainer = createFlexContainer(); - flexContainer.setProperty(Property.BORDER, new SolidBorder(2)); + Div flexContainer = createFlexContainer(alignItemsValue, justifyContentValue, wrapValue, directionValue); + flexContainer.setBorder(new SolidBorder(2)); flexContainer.setProperty(Property.BACKGROUND, new Background(ColorConstants.LIGHT_GRAY)); Table table = new Table(UnitValue.createPercentArray(new float[] {50, 50})); @@ -448,19 +454,21 @@ public void flexContainerDifferentChildrenWithFlexBasisTest() throws IOException document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } - @Test - public void flexContainerDifferentChildrenWithFlexShrinkTest() throws IOException, InterruptedException { + @ParameterizedTest(name = "{index}: align-items: {0}; justify-content: {1}; flex-wrap: {2}; flex-direction: {3}") + @MethodSource("alignItemsAndJustifyContentProperties") + public void flexContainerDifferentChildrenWithFlexShrinkTest(AlignmentPropertyValue alignItemsValue, JustifyContent justifyContentValue, + FlexWrapPropertyValue wrapValue, FlexDirectionPropertyValue directionValue, Integer comparisonPdfId) throws IOException, InterruptedException { String outFileName = destinationFolder + "flexContainerDifferentChildrenWithFlexShrinkTest" + comparisonPdfId + ".pdf"; String cmpFileName = sourceFolder + "cmp_flexContainerDifferentChildrenWithFlexShrinkTest" + comparisonPdfId + ".pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); Document document = new Document(pdfDocument); - Div flexContainer = createFlexContainer(); - flexContainer.setProperty(Property.BORDER, new SolidBorder(2)); + Div flexContainer = createFlexContainer(alignItemsValue, justifyContentValue, wrapValue, directionValue); + flexContainer.setBorder(new SolidBorder(2)); flexContainer.setProperty(Property.BACKGROUND, new Background(ColorConstants.LIGHT_GRAY)); Table table = new Table(UnitValue.createPercentArray(new float[] {50, 50})); @@ -486,19 +494,21 @@ public void flexContainerDifferentChildrenWithFlexShrinkTest() throws IOExceptio document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } - @Test - public void flexContainerInsideFlexContainerTest() throws IOException, InterruptedException { + @ParameterizedTest(name = "{index}: align-items: {0}; justify-content: {1}; flex-wrap: {2}; flex-direction: {3}") + @MethodSource("alignItemsAndJustifyContentProperties") + public void flexContainerInsideFlexContainerTest(AlignmentPropertyValue alignItemsValue, JustifyContent justifyContentValue, + FlexWrapPropertyValue wrapValue, FlexDirectionPropertyValue directionValue, Integer comparisonPdfId) throws IOException, InterruptedException { String outFileName = destinationFolder + "flexContainerInsideFlexContainerTest" + comparisonPdfId + ".pdf"; String cmpFileName = sourceFolder + "cmp_flexContainerInsideFlexContainerTest" + comparisonPdfId + ".pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); Document document = new Document(pdfDocument); - Div flexContainer = createFlexContainer(); - flexContainer.setProperty(Property.BORDER, new SolidBorder(2)); + Div flexContainer = createFlexContainer(alignItemsValue, justifyContentValue, wrapValue, directionValue); + flexContainer.setBorder(new SolidBorder(2)); flexContainer.setProperty(Property.BACKGROUND, new Background(ColorConstants.LIGHT_GRAY)); Div innerFlex = new FlexContainer(); @@ -514,49 +524,57 @@ public void flexContainerInsideFlexContainerTest() throws IOException, Interrupt document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } - @Test - public void flexContainerInsideFlexContainerWithHugeBordersTest() throws IOException, InterruptedException { + @ParameterizedTest(name = "{index}: align-items: {0}; justify-content: {1}; flex-wrap: {2}; flex-direction: {3}") + @MethodSource("alignItemsAndJustifyContentProperties") + public void flexContainerInsideFlexContainerWithHugeBordersTest(AlignmentPropertyValue alignItemsValue, JustifyContent justifyContentValue, + FlexWrapPropertyValue wrapValue, FlexDirectionPropertyValue directionValue, Integer comparisonPdfId) throws IOException, InterruptedException { String outFileName = destinationFolder + "flexContainerInsideFlexContainerWithHugeBordersTest" + comparisonPdfId + ".pdf"; String cmpFileName = sourceFolder + "cmp_flexContainerInsideFlexContainerWithHugeBordersTest" + comparisonPdfId + ".pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); Document document = new Document(pdfDocument); - Div flexContainer = createFlexContainer(); - flexContainer.setProperty(Property.BORDER, new SolidBorder(ColorConstants.BLUE,20)); + Div flexContainer = createFlexContainer(alignItemsValue, justifyContentValue, wrapValue, directionValue); + flexContainer.setBorder(new SolidBorder(ColorConstants.BLUE,20)); flexContainer.setProperty(Property.BACKGROUND, new Background(ColorConstants.LIGHT_GRAY)); Div innerFlex = new FlexContainer(); innerFlex.add(createNewDiv()).add(createNewDiv()).add(createNewDiv()); for (IElement children : innerFlex.getChildren()) { children.setProperty(Property.FLEX_GROW, 1f); - children.setProperty(Property.BORDER, new SolidBorder(ColorConstants.YELLOW,10)); + SolidBorder border = new SolidBorder(ColorConstants.YELLOW, 10); + children.setProperty(Property.BORDER_TOP, border); + children.setProperty(Property.BORDER_RIGHT, border); + children.setProperty(Property.BORDER_BOTTOM, border); + children.setProperty(Property.BORDER_LEFT, border); } innerFlex.setProperty(Property.BACKGROUND, new Background(ColorConstants.RED)); innerFlex.setProperty(Property.FLEX_GROW, 1f); - innerFlex.setProperty(Property.BORDER, new SolidBorder(ColorConstants.RED,15)); + innerFlex.setBorder(new SolidBorder(ColorConstants.RED, 15)); - flexContainer.add(innerFlex).add(createNewDiv().setBorder(new SolidBorder(ColorConstants.GREEN,10))); + flexContainer.add(innerFlex).add(createNewDiv().setBorder(new SolidBorder(ColorConstants.GREEN, 10))); document.add(flexContainer); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } - @Test - public void multipleFlexContainersInsideFlexContainerTest() throws IOException, InterruptedException { + @ParameterizedTest(name = "{index}: align-items: {0}; justify-content: {1}; flex-wrap: {2}; flex-direction: {3}") + @MethodSource("alignItemsAndJustifyContentProperties") + public void multipleFlexContainersInsideFlexContainerTest(AlignmentPropertyValue alignItemsValue, JustifyContent justifyContentValue, + FlexWrapPropertyValue wrapValue, FlexDirectionPropertyValue directionValue, Integer comparisonPdfId) throws IOException, InterruptedException { String outFileName = destinationFolder + "multipleFlexContainersInsideFlexContainerTest" + comparisonPdfId + ".pdf"; String cmpFileName = sourceFolder + "cmp_multipleFlexContainersInsideFlexContainerTest" + comparisonPdfId + ".pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); Document document = new Document(pdfDocument); - Div flexContainer = createFlexContainer(); - flexContainer.setProperty(Property.BORDER, new SolidBorder(2)); + Div flexContainer = createFlexContainer(alignItemsValue, justifyContentValue, wrapValue, directionValue); + flexContainer.setBorder(new SolidBorder(2)); flexContainer.setProperty(Property.BACKGROUND, new Background(ColorConstants.LIGHT_GRAY)); Div innerFlex1 = new FlexContainer(); @@ -580,19 +598,21 @@ public void multipleFlexContainersInsideFlexContainerTest() throws IOException, document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } - @Test - public void multipleFlexContainersWithPredefinedPointWidthsInsideFlexContainerTest() throws IOException, InterruptedException { + @ParameterizedTest(name = "{index}: align-items: {0}; justify-content: {1}; flex-wrap: {2}; flex-direction: {3}") + @MethodSource("alignItemsAndJustifyContentProperties") + public void multipleFlexContainersWithPredefinedPointWidthsInsideFlexContainerTest(AlignmentPropertyValue alignItemsValue, JustifyContent justifyContentValue, + FlexWrapPropertyValue wrapValue, FlexDirectionPropertyValue directionValue, Integer comparisonPdfId) throws IOException, InterruptedException { String outFileName = destinationFolder + "multipleFlexContainersWithPredefinedPointWidthsInsideFlexContainerTest" + comparisonPdfId + ".pdf"; String cmpFileName = sourceFolder + "cmp_multipleFlexContainersWithPredefinedPointWidthsInsideFlexContainerTest" + comparisonPdfId + ".pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); Document document = new Document(pdfDocument); - Div flexContainer = createFlexContainer(); - flexContainer.setProperty(Property.BORDER, new SolidBorder(2)); + Div flexContainer = createFlexContainer(alignItemsValue, justifyContentValue, wrapValue, directionValue); + flexContainer.setBorder(new SolidBorder(2)); flexContainer.setProperty(Property.BACKGROUND, new Background(ColorConstants.LIGHT_GRAY)); Div innerFlex1 = new FlexContainer(); @@ -618,19 +638,21 @@ public void multipleFlexContainersWithPredefinedPointWidthsInsideFlexContainerTe document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } - @Test - public void multipleFlexContainersWithPredefinedPercentWidthsInsideFlexContainerTest() throws IOException, InterruptedException { + @ParameterizedTest(name = "{index}: align-items: {0}; justify-content: {1}; flex-wrap: {2}; flex-direction: {3}") + @MethodSource("alignItemsAndJustifyContentProperties") + public void multipleFlexContainersWithPredefinedPercentWidthsInsideFlexContainerTest(AlignmentPropertyValue alignItemsValue, JustifyContent justifyContentValue, + FlexWrapPropertyValue wrapValue, FlexDirectionPropertyValue directionValue, Integer comparisonPdfId) throws IOException, InterruptedException { String outFileName = destinationFolder + "multipleFlexContainersWithPredefinedPercentWidthsInsideFlexContainerTest" + comparisonPdfId + ".pdf"; String cmpFileName = sourceFolder + "cmp_multipleFlexContainersWithPredefinedPercentWidthsInsideFlexContainerTest" + comparisonPdfId + ".pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); Document document = new Document(pdfDocument); - Div flexContainer = createFlexContainer(); - flexContainer.setProperty(Property.BORDER, new SolidBorder(2)); + Div flexContainer = createFlexContainer(alignItemsValue, justifyContentValue, wrapValue, directionValue); + flexContainer.setBorder(new SolidBorder(2)); flexContainer.setProperty(Property.BACKGROUND, new Background(ColorConstants.LIGHT_GRAY)); Div innerFlex1 = new FlexContainer(); @@ -656,20 +678,22 @@ public void multipleFlexContainersWithPredefinedPercentWidthsInsideFlexContainer document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } - @Test + @ParameterizedTest(name = "{index}: align-items: {0}; justify-content: {1}; flex-wrap: {2}; flex-direction: {3}") + @MethodSource("alignItemsAndJustifyContentProperties") // TODO DEVSIX-5087 Content should not overflow container by default - public void multipleFlexContainersWithPredefinedMinWidthsInsideFlexContainerTest() throws IOException, InterruptedException { + public void multipleFlexContainersWithPredefinedMinWidthsInsideFlexContainerTest(AlignmentPropertyValue alignItemsValue, JustifyContent justifyContentValue, + FlexWrapPropertyValue wrapValue, FlexDirectionPropertyValue directionValue, Integer comparisonPdfId) throws IOException, InterruptedException { String outFileName = destinationFolder + "multipleFlexContainersWithPredefinedMinWidthsInsideFlexContainerTest" + comparisonPdfId + ".pdf"; String cmpFileName = sourceFolder + "cmp_multipleFlexContainersWithPredefinedMinWidthsInsideFlexContainerTest" + comparisonPdfId + ".pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); Document document = new Document(pdfDocument); - Div flexContainer = createFlexContainer(); - flexContainer.setProperty(Property.BORDER, new SolidBorder(2)); + Div flexContainer = createFlexContainer(alignItemsValue, justifyContentValue, wrapValue, directionValue); + flexContainer.setBorder(new SolidBorder(2)); flexContainer.setProperty(Property.BACKGROUND, new Background(ColorConstants.LIGHT_GRAY)); Div innerFlex1 = new FlexContainer(); @@ -695,19 +719,21 @@ public void multipleFlexContainersWithPredefinedMinWidthsInsideFlexContainerTest document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } - @Test - public void multipleFlexContainersWithPredefinedMaxWidthsInsideFlexContainerTest() throws IOException, InterruptedException { + @ParameterizedTest(name = "{index}: align-items: {0}; justify-content: {1}; flex-wrap: {2}; flex-direction: {3}") + @MethodSource("alignItemsAndJustifyContentProperties") + public void multipleFlexContainersWithPredefinedMaxWidthsInsideFlexContainerTest(AlignmentPropertyValue alignItemsValue, JustifyContent justifyContentValue, + FlexWrapPropertyValue wrapValue, FlexDirectionPropertyValue directionValue, Integer comparisonPdfId) throws IOException, InterruptedException { String outFileName = destinationFolder + "multipleFlexContainersWithPredefinedMaxWidthsInsideFlexContainerTest" + comparisonPdfId + ".pdf"; String cmpFileName = sourceFolder + "cmp_multipleFlexContainersWithPredefinedMaxWidthsInsideFlexContainerTest" + comparisonPdfId + ".pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); Document document = new Document(pdfDocument); - Div flexContainer = createFlexContainer(); - flexContainer.setProperty(Property.BORDER, new SolidBorder(2)); + Div flexContainer = createFlexContainer(alignItemsValue, justifyContentValue, wrapValue, directionValue); + flexContainer.setBorder(new SolidBorder(2)); flexContainer.setProperty(Property.BACKGROUND, new Background(ColorConstants.LIGHT_GRAY)); Div innerFlex1 = new FlexContainer(); @@ -733,19 +759,21 @@ public void multipleFlexContainersWithPredefinedMaxWidthsInsideFlexContainerTest document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } - @Test - public void flexContainerFillAvailableAreaTest() throws IOException, InterruptedException { + @ParameterizedTest(name = "{index}: align-items: {0}; justify-content: {1}; flex-wrap: {2}; flex-direction: {3}") + @MethodSource("alignItemsAndJustifyContentProperties") + public void flexContainerFillAvailableAreaTest(AlignmentPropertyValue alignItemsValue, JustifyContent justifyContentValue, + FlexWrapPropertyValue wrapValue, FlexDirectionPropertyValue directionValue, Integer comparisonPdfId) throws IOException, InterruptedException { String outFileName = destinationFolder + "flexContainerFillAvailableAreaTest" + comparisonPdfId + ".pdf"; String cmpFileName = sourceFolder + "cmp_flexContainerFillAvailableAreaTest" + comparisonPdfId + ".pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); Document document = new Document(pdfDocument); - Div flexContainer = createFlexContainer(); - flexContainer.setProperty(Property.BORDER, new SolidBorder(2)); + Div flexContainer = createFlexContainer(alignItemsValue, justifyContentValue, wrapValue, directionValue); + flexContainer.setBorder(new SolidBorder(2)); flexContainer.setProperty(Property.BACKGROUND, new Background(ColorConstants.LIGHT_GRAY)); flexContainer.setProperty(Property.FILL_AVAILABLE_AREA, true); @@ -768,19 +796,21 @@ public void flexContainerFillAvailableAreaTest() throws IOException, Interrupted document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } - @Test - public void flexContainerRotationAngleTest() throws IOException, InterruptedException { + @ParameterizedTest(name = "{index}: align-items: {0}; justify-content: {1}; flex-wrap: {2}; flex-direction: {3}") + @MethodSource("alignItemsAndJustifyContentProperties") + public void flexContainerRotationAngleTest(AlignmentPropertyValue alignItemsValue, JustifyContent justifyContentValue, + FlexWrapPropertyValue wrapValue, FlexDirectionPropertyValue directionValue, Integer comparisonPdfId) throws IOException, InterruptedException { String outFileName = destinationFolder + "flexContainerRotationAngleTest" + comparisonPdfId + ".pdf"; String cmpFileName = sourceFolder + "cmp_flexContainerRotationAngleTest" + comparisonPdfId + ".pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); Document document = new Document(pdfDocument); - Div flexContainer = createFlexContainer(); - flexContainer.setProperty(Property.BORDER, new SolidBorder(2)); + Div flexContainer = createFlexContainer(alignItemsValue, justifyContentValue, wrapValue, directionValue); + flexContainer.setBorder(new SolidBorder(2)); flexContainer.setProperty(Property.BACKGROUND, new Background(ColorConstants.LIGHT_GRAY)); flexContainer.setProperty(Property.ROTATION_ANGLE, 20f); @@ -799,12 +829,14 @@ public void flexContainerRotationAngleTest() throws IOException, InterruptedExce document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } - @Test + @ParameterizedTest(name = "{index}: align-items: {0}; justify-content: {1}; flex-wrap: {2}; flex-direction: {3}") + @MethodSource("alignItemsAndJustifyContentProperties") // TODO DEVSIX-5174 content should overflow bottom - public void respectFlexContainersHeightTest() throws IOException, InterruptedException { + public void respectFlexContainersHeightTest(AlignmentPropertyValue alignItemsValue, JustifyContent justifyContentValue, + FlexWrapPropertyValue wrapValue, FlexDirectionPropertyValue directionValue, Integer comparisonPdfId) throws IOException, InterruptedException { String outFileName = destinationFolder + "respectFlexContainersHeightTest" + comparisonPdfId + ".pdf"; String cmpFileName = sourceFolder + "cmp_respectFlexContainersHeightTest" + comparisonPdfId + ".pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); @@ -814,7 +846,7 @@ public void respectFlexContainersHeightTest() throws IOException, InterruptedExc .setWidth(60) .setHeight(50); - Div flexContainer = getFlexContainer(null, containerStyle); + Div flexContainer = getFlexContainer(null, containerStyle, alignItemsValue, justifyContentValue, wrapValue, directionValue); Div flexItem = new Div() .setBackgroundColor(ColorConstants.BLUE) .add(new Paragraph("h")) @@ -834,11 +866,13 @@ public void respectFlexContainersHeightTest() throws IOException, InterruptedExc document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } - @Test - public void respectFlexContainersWidthTest() throws IOException, InterruptedException { + @ParameterizedTest(name = "{index}: align-items: {0}; justify-content: {1}; flex-wrap: {2}; flex-direction: {3}") + @MethodSource("alignItemsAndJustifyContentProperties") + public void respectFlexContainersWidthTest(AlignmentPropertyValue alignItemsValue, JustifyContent justifyContentValue, + FlexWrapPropertyValue wrapValue, FlexDirectionPropertyValue directionValue, Integer comparisonPdfId) throws IOException, InterruptedException { String outFileName = destinationFolder + "respectFlexContainersWidthTest" + comparisonPdfId + ".pdf"; String cmpFileName = sourceFolder + "cmp_respectFlexContainersWidthTest" + comparisonPdfId + ".pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); @@ -855,7 +889,7 @@ public void respectFlexContainersWidthTest() throws IOException, InterruptedExce .setWidth(60f) .setHeight(100f); - Div flexContainer = getFlexContainer(overflowX, containerStyle); + Div flexContainer = getFlexContainer(overflowX, containerStyle, alignItemsValue, justifyContentValue, wrapValue, directionValue); flexContainer .add(getFlexItem(overflowX, itemStyle)) .add(getFlexItem(overflowX, itemStyle)); @@ -865,7 +899,7 @@ public void respectFlexContainersWidthTest() throws IOException, InterruptedExce // default (overflow visible) overflowX = OverflowPropertyValue.VISIBLE; - flexContainer = getFlexContainer(overflowX, containerStyle); + flexContainer = getFlexContainer(overflowX, containerStyle, alignItemsValue, justifyContentValue, wrapValue, directionValue); flexContainer .add(getFlexItem(overflowX, itemStyle)) .add(getFlexItem(overflowX, itemStyle)); @@ -873,18 +907,20 @@ public void respectFlexContainersWidthTest() throws IOException, InterruptedExce document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } - @Test - public void flexItemsMinHeightShouldBeOverriddenTest() throws IOException, InterruptedException { + @ParameterizedTest(name = "{index}: align-items: {0}; justify-content: {1}; flex-wrap: {2}; flex-direction: {3}") + @MethodSource("alignItemsAndJustifyContentProperties") + public void flexItemsMinHeightShouldBeOverriddenTest(AlignmentPropertyValue alignItemsValue, JustifyContent justifyContentValue, + FlexWrapPropertyValue wrapValue, FlexDirectionPropertyValue directionValue, Integer comparisonPdfId) throws IOException, InterruptedException { String outFileName = destinationFolder + "flexItemsMinHeightShouldBeOverriddenTest" + comparisonPdfId + ".pdf"; String cmpFileName = sourceFolder + "cmp_flexItemsMinHeightShouldBeOverriddenTest" + comparisonPdfId + ".pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); Document document = new Document(pdfDocument); - Div flexContainer = createFlexContainer(); + Div flexContainer = createFlexContainer(alignItemsValue, justifyContentValue, wrapValue, directionValue); flexContainer.add(new Div().setWidth(110).setBackgroundColor(ColorConstants.BLUE).setHeight(100)); flexContainer.add(new Div().setWidth(110).setBackgroundColor(ColorConstants.YELLOW).setMinHeight(20)); @@ -892,18 +928,20 @@ public void flexItemsMinHeightShouldBeOverriddenTest() throws IOException, Inter document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } - @Test - public void linesMinHeightShouldBeRespectedTest() throws IOException, InterruptedException { + @ParameterizedTest(name = "{index}: align-items: {0}; justify-content: {1}; flex-wrap: {2}; flex-direction: {3}") + @MethodSource("alignItemsAndJustifyContentProperties") + public void linesMinHeightShouldBeRespectedTest(AlignmentPropertyValue alignItemsValue, JustifyContent justifyContentValue, + FlexWrapPropertyValue wrapValue, FlexDirectionPropertyValue directionValue, Integer comparisonPdfId) throws IOException, InterruptedException { String outFileName = destinationFolder + "linesMinHeightShouldBeRespectedTest" + comparisonPdfId + ".pdf"; String cmpFileName = sourceFolder + "cmp_linesMinHeightShouldBeRespectedTest" + comparisonPdfId + ".pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); Document document = new Document(pdfDocument); - Div flexContainer = createFlexContainer(); + Div flexContainer = createFlexContainer(alignItemsValue, justifyContentValue, wrapValue, directionValue); flexContainer.setMinHeight(100); Div child = new Div().setWidth(110).setBackgroundColor(ColorConstants.BLUE); @@ -914,18 +952,20 @@ public void linesMinHeightShouldBeRespectedTest() throws IOException, Interrupte document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } - @Test - public void linesMaxHeightShouldBeRespectedTest() throws IOException, InterruptedException { + @ParameterizedTest(name = "{index}: align-items: {0}; justify-content: {1}; flex-wrap: {2}; flex-direction: {3}") + @MethodSource("alignItemsAndJustifyContentProperties") + public void linesMaxHeightShouldBeRespectedTest(AlignmentPropertyValue alignItemsValue, JustifyContent justifyContentValue, + FlexWrapPropertyValue wrapValue, FlexDirectionPropertyValue directionValue, Integer comparisonPdfId) throws IOException, InterruptedException { String outFileName = destinationFolder + "linesMaxHeightShouldBeRespectedTest" + comparisonPdfId + ".pdf"; String cmpFileName = sourceFolder + "cmp_linesMaxHeightShouldBeRespectedTest" + comparisonPdfId + ".pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); Document document = new Document(pdfDocument); - Div flexContainer = createFlexContainer(); + Div flexContainer = createFlexContainer(alignItemsValue, justifyContentValue, wrapValue, directionValue); flexContainer.setMaxHeight(100); Div child = new Div().setWidth(100).setBackgroundColor(ColorConstants.BLUE).setHeight(150); @@ -936,11 +976,13 @@ public void linesMaxHeightShouldBeRespectedTest() throws IOException, Interrupte document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } - @Test - public void collapsingMarginsFlexContainerTest() throws IOException, InterruptedException { + @ParameterizedTest(name = "{index}: align-items: {0}; justify-content: {1}; flex-wrap: {2}; flex-direction: {3}") + @MethodSource("alignItemsAndJustifyContentProperties") + public void collapsingMarginsFlexContainerTest(AlignmentPropertyValue alignItemsValue, JustifyContent justifyContentValue, + FlexWrapPropertyValue wrapValue, FlexDirectionPropertyValue directionValue, Integer comparisonPdfId) throws IOException, InterruptedException { String outFileName = destinationFolder + "collapsingMarginsFlexContainerTest" + comparisonPdfId + ".pdf"; String cmpFileName = sourceFolder + "cmp_collapsingMarginsFlexContainerTest" + comparisonPdfId + ".pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); @@ -948,9 +990,9 @@ public void collapsingMarginsFlexContainerTest() throws IOException, Interrupted Document document = new Document(pdfDocument); document.setProperty(Property.COLLAPSING_MARGINS, true); - Div flexContainer = createFlexContainer(); + Div flexContainer = createFlexContainer(alignItemsValue, justifyContentValue, wrapValue, directionValue); flexContainer.setProperty(Property.MARGIN_TOP, UnitValue.createPointValue(50)); - flexContainer.setProperty(Property.BORDER, new SolidBorder(2)); + flexContainer.setBorder(new SolidBorder(2)); flexContainer.setProperty(Property.BACKGROUND, new Background(ColorConstants.LIGHT_GRAY)); Div child1 = createNewDiv(); @@ -970,19 +1012,21 @@ public void collapsingMarginsFlexContainerTest() throws IOException, Interrupted document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } - @Test - public void flexItemBoxSizingTest() throws IOException, InterruptedException { + @ParameterizedTest(name = "{index}: align-items: {0}; justify-content: {1}; flex-wrap: {2}; flex-direction: {3}") + @MethodSource("alignItemsAndJustifyContentProperties") + public void flexItemBoxSizingTest(AlignmentPropertyValue alignItemsValue, JustifyContent justifyContentValue, + FlexWrapPropertyValue wrapValue, FlexDirectionPropertyValue directionValue, Integer comparisonPdfId) throws IOException, InterruptedException { String outFileName = destinationFolder + "flexItemBoxSizingTest" + comparisonPdfId + ".pdf"; String cmpFileName = sourceFolder + "cmp_flexItemBoxSizingTest" + comparisonPdfId + ".pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); Document document = new Document(pdfDocument); - Div flexContainer = createFlexContainer(); - flexContainer.setProperty(Property.BORDER, new SolidBorder(ColorConstants.BLUE, 30)); + Div flexContainer = createFlexContainer(alignItemsValue, justifyContentValue, wrapValue, directionValue); + flexContainer.setBorder(new SolidBorder(ColorConstants.BLUE, 30)); flexContainer.setProperty(Property.BACKGROUND, new Background(ColorConstants.LIGHT_GRAY)); flexContainer.setWidth(450); flexContainer.setHeight(200); @@ -1020,19 +1064,21 @@ public void flexItemBoxSizingTest() throws IOException, InterruptedException { document.add(flexContainer).add(divToCompare); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } - @Test - public void flexContainerBoxSizingTest() throws IOException, InterruptedException { + @ParameterizedTest(name = "{index}: align-items: {0}; justify-content: {1}; flex-wrap: {2}; flex-direction: {3}") + @MethodSource("alignItemsAndJustifyContentProperties") + public void flexContainerBoxSizingTest(AlignmentPropertyValue alignItemsValue, JustifyContent justifyContentValue, + FlexWrapPropertyValue wrapValue, FlexDirectionPropertyValue directionValue, Integer comparisonPdfId) throws IOException, InterruptedException { String outFileName = destinationFolder + "flexContainerBoxSizingTest" + comparisonPdfId + ".pdf"; String cmpFileName = sourceFolder + "cmp_flexContainerBoxSizingTest" + comparisonPdfId + ".pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); Document document = new Document(pdfDocument); - Div flexContainer = createFlexContainer(); - flexContainer.setProperty(Property.BORDER, new SolidBorder(ColorConstants.BLUE, 30)); + Div flexContainer = createFlexContainer(alignItemsValue, justifyContentValue, wrapValue, directionValue); + flexContainer.setBorder(new SolidBorder(ColorConstants.BLUE, 30)); flexContainer.setProperty(Property.BACKGROUND, new Background(ColorConstants.LIGHT_GRAY)); flexContainer.setWidth(450); flexContainer.setProperty(Property.BOX_SIZING, BoxSizingPropertyValue.BORDER_BOX); @@ -1051,11 +1097,12 @@ public void flexContainerBoxSizingTest() throws IOException, InterruptedExceptio document.add(flexContainer).add(divToCompare); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } - private Div getFlexContainer(OverflowPropertyValue overflowX, Style style) { - FlexContainer flexContainer = createFlexContainer(); + private Div getFlexContainer(OverflowPropertyValue overflowX, Style style, AlignmentPropertyValue alignItemsValue, JustifyContent justifyContentValue, + FlexWrapPropertyValue wrapValue, FlexDirectionPropertyValue directionValue) { + FlexContainer flexContainer = createFlexContainer(alignItemsValue, justifyContentValue, wrapValue, directionValue); flexContainer .setBackgroundColor(ColorConstants.GREEN) .setBorderRight(new SolidBorder(60)); @@ -1082,7 +1129,8 @@ private static Div getFlexItem(OverflowPropertyValue overflowX, Style style) { return flexItem; } - private FlexContainer createFlexContainer() { + private FlexContainer createFlexContainer(AlignmentPropertyValue alignItemsValue, JustifyContent justifyContentValue, + FlexWrapPropertyValue wrapValue, FlexDirectionPropertyValue directionValue) { FlexContainer flexContainer = new FlexContainer(); flexContainer.setProperty(Property.ALIGN_ITEMS, alignItemsValue); flexContainer.setProperty(Property.JUSTIFY_CONTENT, justifyContentValue); @@ -1096,7 +1144,7 @@ private FlexContainer createFlexContainer() { private static Div createNewDiv() { Div newDiv = new Div(); - newDiv.setProperty(Property.BORDER, new SolidBorder(1)); + newDiv.setBorder(new SolidBorder(1)); newDiv.setProperty(Property.WIDTH, UnitValue.createPointValue(50)); newDiv.setProperty(Property.HEIGHT, UnitValue.createPointValue(100)); return newDiv; diff --git a/layout/src/test/java/com/itextpdf/layout/element/GridContainerTest.java b/layout/src/test/java/com/itextpdf/layout/element/GridContainerTest.java index 5f89f9b652..834653ca2a 100644 --- a/layout/src/test/java/com/itextpdf/layout/element/GridContainerTest.java +++ b/layout/src/test/java/com/itextpdf/layout/element/GridContainerTest.java @@ -44,23 +44,22 @@ This file is part of the iText (R) project. import com.itextpdf.layout.properties.grid.PointValue; import com.itextpdf.layout.properties.grid.TemplateValue; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class GridContainerTest extends ExtendedITextTest { public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/layout/GridContainerTest/"; public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/layout/GridContainerTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(DESTINATION_FOLDER); } @@ -84,13 +83,33 @@ public void basicThreeColumnsTest() throws IOException, InterruptedException { } document.add(grid); } - Assert.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); + } + + @Test + public void borderBoxWithNoBordersTest() throws IOException, InterruptedException { + String filename = DESTINATION_FOLDER + "borderBoxWithNoBordersTest.pdf"; + String cmpName = SOURCE_FOLDER + "cmp_borderBoxWithNoBordersTest.pdf"; + + java.util.List templateColumns = new ArrayList<>(); + templateColumns.add(new PointValue(150.0f)); + templateColumns.add(new PointValue(150.0f)); + + try (Document document = new Document(new PdfDocument(new PdfWriter(filename)))) { + GridContainer grid = new GridContainer(); + grid.setProperty(Property.GRID_TEMPLATE_COLUMNS, templateColumns); + Paragraph child = new Paragraph("First"); + child.setProperty(Property.BOX_SIZING, BoxSizingPropertyValue.BORDER_BOX); + grid.add(child); + document.add(grid); + } + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); } @Test public void basicTwoColumnsTest() throws IOException, InterruptedException { - String filename = DESTINATION_FOLDER + "basicTwoColumnsTest.pdf"; - String cmpName = SOURCE_FOLDER + "cmp_basicTwoColumnsTest.pdf"; + String filename = DESTINATION_FOLDER + "borderBoxChild.pdf"; + String cmpName = SOURCE_FOLDER + "cmp_borderBoxChild.pdf"; java.util.List templateColumns = new ArrayList<>(); templateColumns.add(new PointValue(150.0f)); @@ -107,7 +126,7 @@ public void basicTwoColumnsTest() throws IOException, InterruptedException { grid.add(paragraph3); document.add(grid); } - Assert.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); } @Test @@ -131,7 +150,7 @@ public void basicTwoRowsTest() throws IOException, InterruptedException { grid.add(paragraph3); document.add(grid); } - Assert.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); } @Test @@ -148,7 +167,7 @@ public void basicAutoColumnsTest() throws IOException, InterruptedException { } document.add(grid); } - Assert.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); } @Test @@ -169,7 +188,7 @@ public void basicAutoRowsTest() throws IOException, InterruptedException { grid.add(new Paragraph("test").setBorder(border)); document.add(grid); } - Assert.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); } @Test @@ -198,7 +217,7 @@ public void basicThreeColumnsWithCustomColumnIndexesTest() throws IOException, I grid.add(new Paragraph("Four").setBorder(border)); document.add(grid); } - Assert.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); } @Test @@ -227,7 +246,7 @@ public void basicThreeColumnsOutOfBoundsWithNoCellsTest() throws IOException, In grid.add(new Paragraph("Four").setBorder(border)); document.add(grid); } - Assert.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); } @Test @@ -260,7 +279,7 @@ public void basicThreeColumnsWithNegativeCustomColumnIndexesTest() throws IOExce grid.add(new Paragraph("Eight").setBorder(border)); document.add(grid); } - Assert.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); } @Test @@ -297,7 +316,7 @@ public void threeColumnsWithAdjacentWideCellsTest() throws IOException, Interrup grid.add(new Paragraph("Five").setBorder(border)); document.add(grid); } - Assert.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); } @Test @@ -326,7 +345,7 @@ public void basicThreeColumnsWithCustomRowIndexesTest() throws IOException, Inte grid.add(new Paragraph("Four").setBorder(border)); document.add(grid); } - Assert.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); } @Test @@ -356,7 +375,7 @@ public void basicThreeColumnsWithCustomColumnAndRowIndexesTest() throws IOExcept grid.add(new Paragraph("Five").setBorder(border)); document.add(grid); } - Assert.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); } @Test @@ -394,7 +413,7 @@ public void basicThreeColumnsWithReversedIndexesTest() throws IOException, Inter grid.add(new Paragraph("Five").setBorder(border)); document.add(grid); } - Assert.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); } @Test @@ -430,7 +449,7 @@ public void basicThreeColumnsWithoutColumnEndTest() throws IOException, Interrup grid.add(new Paragraph("Five").setBorder(border)); document.add(grid); } - Assert.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); } @Test @@ -479,7 +498,7 @@ public void fixedColumnRowGoesFirstTest() throws IOException, InterruptedExcepti document.add(grid); } - Assert.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); } @Test @@ -516,7 +535,7 @@ public void overlapWithExistingItemTest() throws IOException, InterruptedExcepti document.add(grid); } - Assert.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); } @Test @@ -553,7 +572,7 @@ public void coverExistingItemTest() throws IOException, InterruptedException { document.add(grid); } - Assert.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); } @Test @@ -574,7 +593,7 @@ public void basicThreeColumnsWithPtAndPercentTest() throws IOException, Interrup } document.add(grid); } - Assert.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); } @Test @@ -596,7 +615,7 @@ public void thirdColumnNotLayoutedTest() throws IOException, InterruptedExceptio } document.add(grid); } - Assert.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); } @Test @@ -631,7 +650,7 @@ public void threeColumnsWithSquareAndVerticalCellsTest() throws IOException, Int grid.add(new Paragraph("Six").setBorder(border)); document.add(grid); } - Assert.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); } @Test @@ -662,7 +681,7 @@ public void threeColumnsWithSquareCellAndCellWithExplicitHeightTest() throws IOE grid.add(new Paragraph("Five").setBorder(border).setBackgroundColor(ColorConstants.RED)); document.add(grid); } - Assert.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); } @Test @@ -696,7 +715,7 @@ public void threeColumnsWithVerticalCellWithSeveralNeighboursToTheLeftTest() thr grid.add(new Paragraph("Five").setBorder(border).setBackgroundColor(ColorConstants.RED)); document.add(grid); } - Assert.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); } @Test @@ -715,7 +734,7 @@ public void bigCellMinContentTest() throws IOException, InterruptedException { grid.add(new Paragraph("test").setBorder(border)); document.add(grid); } - Assert.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); } @Test @@ -742,7 +761,7 @@ public void columnRowGapTest() throws IOException, InterruptedException { grid.add(new Paragraph("Seven").setBackgroundColor(ColorConstants.CYAN)); document.add(grid); } - Assert.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); } @Test @@ -775,7 +794,7 @@ public void autoRepeatTestWithRowGapTest() throws IOException, InterruptedExcept grid.add(new Paragraph("Nine").setBackgroundColor(ColorConstants.CYAN)); document.add(grid); } - Assert.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); } @Test @@ -798,7 +817,7 @@ public void autoRepeatWithShrinkTest() throws IOException, InterruptedException grid.add(new Paragraph("One").setBackgroundColor(ColorConstants.CYAN)); document.add(grid); } - Assert.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); } @Test @@ -818,7 +837,7 @@ public void autoRepeatOnEmptyGridTest() throws IOException, InterruptedException grid.setProperty(Property.GRID_TEMPLATE_ROWS, rowsTemplate); document.add(grid); } - Assert.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); } @Test @@ -857,7 +876,7 @@ public void fewBigCellsWithGapTest() throws IOException, InterruptedException { grid.add(new Paragraph("Nine").setBackgroundColor(ColorConstants.CYAN)); document.add(grid); } - Assert.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); } @Test @@ -898,7 +917,7 @@ public void columnFlowWithBigCellsTest() throws IOException, InterruptedExceptio grid.add(new Paragraph("Nine").setBackgroundColor(ColorConstants.CYAN)); document.add(grid); } - Assert.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); } @Test @@ -918,7 +937,7 @@ public void frInRowsTest() throws IOException, InterruptedException { grid.add(new Paragraph("Tree").setBackgroundColor(ColorConstants.CYAN)); document.add(grid); } - Assert.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); } @Test @@ -945,7 +964,7 @@ public void frColumnsTest() throws IOException, InterruptedException { grid.add(new Paragraph("Test5").setBorder(border)); document.add(grid); } - Assert.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); } @Test @@ -972,7 +991,7 @@ public void fitContentColumnsTest() throws IOException, InterruptedException { grid.add(new Paragraph("Test5").setBorder(border)); document.add(grid); } - Assert.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); } @Test @@ -998,7 +1017,7 @@ public void columnSpanTest() throws IOException, InterruptedException { grid.add(new Paragraph("Four").setBorder(border)); document.add(grid); } - Assert.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); } @Test @@ -1025,7 +1044,7 @@ public void rowSpanTest() throws IOException, InterruptedException { grid.add(new Paragraph("Four").setBorder(border)); document.add(grid); } - Assert.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); } @Test @@ -1054,7 +1073,7 @@ public void autoRepeatPaddingsBordersMarginsTest() throws IOException, Interrupt grid.add(new Paragraph("Nine").setBackgroundColor(ColorConstants.CYAN)); document.add(grid); } - Assert.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); } @Test @@ -1073,7 +1092,7 @@ public void marginsCollapsingIssueTest() throws IOException, InterruptedExceptio document.add(div); } - Assert.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); } @Test @@ -1107,7 +1126,7 @@ public void splitPageTest() throws IOException, InterruptedException { document.add(emptyDiv); document.add(grid); } - Assert.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); } @Test @@ -1144,7 +1163,7 @@ public void borderBoxSizingTest() throws IOException, InterruptedException { document.add(grid); } - Assert.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); } @Test @@ -1179,6 +1198,6 @@ public void marginCollapsingTest() throws IOException, InterruptedException { document.add(grid); } - Assert.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); } } diff --git a/layout/src/test/java/com/itextpdf/layout/element/MulticolContainerTest.java b/layout/src/test/java/com/itextpdf/layout/element/MulticolContainerTest.java index d8e7212a6c..6cded2d95d 100644 --- a/layout/src/test/java/com/itextpdf/layout/element/MulticolContainerTest.java +++ b/layout/src/test/java/com/itextpdf/layout/element/MulticolContainerTest.java @@ -46,18 +46,17 @@ This file is part of the iText (R) project. import com.itextpdf.test.LogLevelConstants; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; import java.net.MalformedURLException; import java.util.function.Consumer; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class MulticolContainerTest extends ExtendedITextTest { public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/layout/MulticolContainerTest/"; public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/layout/MulticolContainerTest/"; @@ -67,7 +66,7 @@ public class MulticolContainerTest extends ExtendedITextTest { private static final Color DEFAULT_BACKGROUND_COLOR = ColorConstants.CYAN; private static final Border DEFAULT_BORDER = new SolidBorder(ColorConstants.RED, 5F); - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(DESTINATION_FOLDER); } @@ -92,7 +91,7 @@ public void divColumnContainerTest() throws IOException, InterruptedException { ctx.setProperty(Property.COLUMN_COUNT, 2); Div div = new Div(); div.setProperty(Property.MARGIN_TOP, UnitValue.createPointValue(50)); - div.setProperty(Property.BORDER, new SolidBorder(2)); + div.setBorder(new SolidBorder(2)); div.setProperty(Property.PADDING_LEFT, UnitValue.createPointValue(40)); div.setProperty(Property.BACKGROUND, new Background(ColorConstants.LIGHT_GRAY)); div.setProperty(Property.WIDTH, UnitValue.createPointValue(450)); @@ -121,7 +120,7 @@ public void columnedDivInsideTableTest() throws IOException, InterruptedExceptio table.addCell(new Cell()); document.add(table); } - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -475,7 +474,7 @@ public void singleParagraphMultiPageTest() throws IOException, InterruptedExcept document.add(columnContainer); } - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -501,7 +500,7 @@ public void singleParagraphWithBorderMultiPageTest() throws IOException, Interru document.add(columnContainer); } - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -533,7 +532,7 @@ public void paragraphWithImagesMultiPageTest() throws IOException, InterruptedEx document.add(columnContainer); } - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -660,7 +659,7 @@ public void overflowingDivWithParagraphMultipageTest() throws IOException, Inter "sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, "); paragraph.setBorder(new SolidBorder(2)); Div columnDiv = new Div(); - columnDiv.setProperty(Property.BORDER, new SolidBorder(1)); + columnDiv.setBorder(new SolidBorder(1)); columnDiv.setProperty(Property.BACKGROUND, new Background(ColorConstants.BLUE)); columnDiv.setProperty(Property.KEEP_TOGETHER, Boolean.TRUE); columnDiv.setProperty(Property.WIDTH, UnitValue.createPointValue(50)); @@ -674,7 +673,7 @@ public void overflowingDivWithParagraphMultipageTest() throws IOException, Inter document.add(columnContainer); } - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -691,7 +690,7 @@ public void marginCantFitCurrentPageTest() throws IOException, InterruptedExcept "sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, "); paragraph.setBorder(new SolidBorder(2)); Div columnDiv = new Div(); - columnDiv.setProperty(Property.BORDER, new SolidBorder(1)); + columnDiv.setBorder(new SolidBorder(1)); columnDiv.setProperty(Property.BACKGROUND, new Background(ColorConstants.BLUE)); columnDiv.setProperty(Property.KEEP_TOGETHER, Boolean.TRUE); columnDiv.setProperty(Property.MARGIN_BOTTOM, UnitValue.createPointValue(40)); @@ -706,7 +705,7 @@ public void marginCantFitCurrentPageTest() throws IOException, InterruptedExcept document.add(columnContainer); } - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -723,7 +722,7 @@ public void paddingCantFitCurrentPageTest() throws IOException, InterruptedExcep "sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, "); paragraph.setBorder(new SolidBorder(2)); Div columnDiv = new Div(); - columnDiv.setProperty(Property.BORDER, new SolidBorder(1)); + columnDiv.setBorder(new SolidBorder(1)); columnDiv.setProperty(Property.BACKGROUND, new Background(ColorConstants.BLUE)); columnDiv.setProperty(Property.KEEP_TOGETHER, Boolean.TRUE); columnDiv.setProperty(Property.PADDING_BOTTOM, UnitValue.createPointValue(40)); @@ -738,7 +737,7 @@ public void paddingCantFitCurrentPageTest() throws IOException, InterruptedExcep document.add(columnContainer); } - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -769,7 +768,7 @@ public void keepTogetherBlockingLayoutTest() throws IOException, InterruptedExce document.add(columnContainer); } - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -966,11 +965,11 @@ public void widthMultiPage() throws IOException, InterruptedException { doc.add(new Paragraph("ELEMENT BELOW").setBackgroundColor(ColorConstants.YELLOW)); } CompareTool compareTool = new CompareTool(); - Assert.assertNull(compareTool.compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(compareTool.compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); } @Test - @Ignore("DEVSIX-7630") + @Disabled("DEVSIX-7630") public void heightMultiPage() throws IOException, InterruptedException { String testName = "heightMultiPage"; String filename = DESTINATION_FOLDER + testName + ".pdf"; @@ -989,7 +988,7 @@ public void heightMultiPage() throws IOException, InterruptedException { doc.add(new Paragraph("ELEMENT BELOW").setBackgroundColor(ColorConstants.YELLOW)); } CompareTool compareTool = new CompareTool(); - Assert.assertNull(compareTool.compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(compareTool.compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); } @Test @@ -1017,7 +1016,7 @@ public void paragraphWithColumnWidthTest() throws IOException, InterruptedExcept document.add(columnContainer); } //expecting 2 columns with ~260px width each - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -1034,7 +1033,7 @@ public void paragraphWithColumnWidthAndColumnCountTest() throws IOException, Int columnContainer.add(paragraph); document.add(columnContainer); } - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -1048,8 +1047,8 @@ public void paragraphWithInvalidColumnValuesTest() { columnContainer.setProperty(Property.COLUMN_GAP, -20.0f); Paragraph paragraph = createDummyParagraph(); columnContainer.add(paragraph); - Throwable exception = Assert.assertThrows(IllegalStateException.class, () -> document.add(columnContainer)); - Assert.assertEquals(LayoutExceptionMessageConstant.INVALID_COLUMN_PROPERTIES, exception.getMessage()); + Throwable exception = Assertions.assertThrows(IllegalStateException.class, () -> document.add(columnContainer)); + Assertions.assertEquals(LayoutExceptionMessageConstant.INVALID_COLUMN_PROPERTIES, exception.getMessage()); } } @@ -1066,7 +1065,7 @@ public void paragraphWithColumnWidthAndGapTest() throws IOException, Interrupted columnContainer.add(paragraph); document.add(columnContainer); } - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -1082,7 +1081,7 @@ public void paragraphWithColumnCountAndGapTest() throws IOException, Interrupted columnContainer.add(paragraph); document.add(columnContainer); } - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -1099,7 +1098,7 @@ public void paragraphWithSimpleSolidColumnGapTest() throws IOException, Interrup columnContainer.add(paragraph); document.add(columnContainer); } - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @@ -1121,7 +1120,7 @@ public void divWithSimpleSolidColumnGapTest() throws IOException, InterruptedExc columnContainer.add(div); document.add(columnContainer); } - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -1137,7 +1136,7 @@ public void paragraphWithNegativeValueSolidColumnGapTest() throws IOException, I columnContainer.add(paragraph); document.add(columnContainer); } - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -1153,7 +1152,7 @@ public void paragraphWithBiggerValueSolidColumnGapTest() throws IOException, Int columnContainer.add(paragraph); document.add(columnContainer); } - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @@ -1170,7 +1169,7 @@ public void paragraphWithNullValueSolidColumnGapTest() throws IOException, Inter columnContainer.add(paragraph); document.add(columnContainer); } - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } private void executeTest(String testName, Consumer executor, boolean wrapByP) throws IOException, InterruptedException { @@ -1191,7 +1190,7 @@ private void executeTest(String testName, Consumer executor, } } CompareTool compareTool = new CompareTool(); - Assert.assertNull(compareTool.compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(compareTool.compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); } private void executeTest(String testName, Consumer executor) throws IOException, InterruptedException { @@ -1220,7 +1219,7 @@ private static Paragraph createDummyParagraph() { private static Div createFirstPageFiller() { Div firstPageFiller = new Div(); firstPageFiller.setProperty(Property.MARGIN_TOP, UnitValue.createPointValue(50)); - firstPageFiller.setProperty(Property.BORDER, new SolidBorder(1)); + firstPageFiller.setBorder(new SolidBorder(1)); firstPageFiller.setProperty(Property.PADDING_LEFT, UnitValue.createPointValue(20)); firstPageFiller.setProperty(Property.BACKGROUND, new Background(ColorConstants.LIGHT_GRAY)); firstPageFiller.setProperty(Property.WIDTH, UnitValue.createPointValue(450)); diff --git a/layout/src/test/java/com/itextpdf/layout/element/gridcontainer/GridContainerLayoutTest.java b/layout/src/test/java/com/itextpdf/layout/element/gridcontainer/GridContainerLayoutTest.java index 244fac8df3..120e6103df 100644 --- a/layout/src/test/java/com/itextpdf/layout/element/gridcontainer/GridContainerLayoutTest.java +++ b/layout/src/test/java/com/itextpdf/layout/element/gridcontainer/GridContainerLayoutTest.java @@ -50,23 +50,22 @@ This file is part of the iText (R) project. import com.itextpdf.test.LogLevelConstants; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; import java.util.Arrays; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class GridContainerLayoutTest extends ExtendedITextTest { public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/layout/GridContainerTest/"; public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/layout/GridContainerTest/"; - @Before + @BeforeEach public void setup() { createDestinationFolder(DESTINATION_FOLDER); } @@ -91,7 +90,7 @@ public void simpleBorderBoxSizingTestTest() throws IOException, InterruptedExcep document.add(gridcontainer1); document.close(); - Assert.assertNull(new CompareTool().compareByContent(fileName, SOURCE_FOLDER + "cmp_border.pdf", + Assertions.assertNull(new CompareTool().compareByContent(fileName, SOURCE_FOLDER + "cmp_border.pdf", DESTINATION_FOLDER, "diff")); } @@ -111,7 +110,7 @@ public void simpleMarginTest() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(fileName, SOURCE_FOLDER + "cmp_margin.pdf", + Assertions.assertNull(new CompareTool().compareByContent(fileName, SOURCE_FOLDER + "cmp_margin.pdf", DESTINATION_FOLDER, "diff")); } @@ -132,7 +131,7 @@ public void simplePaddingTest() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(fileName, SOURCE_FOLDER + "cmp_padding.pdf", + Assertions.assertNull(new CompareTool().compareByContent(fileName, SOURCE_FOLDER + "cmp_padding.pdf", DESTINATION_FOLDER, "diff")); } @@ -150,7 +149,7 @@ public void simpleBackGroundTest() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(fileName, SOURCE_FOLDER + "cmp_background.pdf", + Assertions.assertNull(new CompareTool().compareByContent(fileName, SOURCE_FOLDER + "cmp_background.pdf", DESTINATION_FOLDER, "diff")); } @@ -175,7 +174,7 @@ public void backgroundWithImageTest() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(fileName, SOURCE_FOLDER + "cmp_backgroundWithImage.pdf", + Assertions.assertNull(new CompareTool().compareByContent(fileName, SOURCE_FOLDER + "cmp_backgroundWithImage.pdf", DESTINATION_FOLDER, "diff")); } @@ -199,7 +198,7 @@ public void emptyGridContainerTest() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(fileName, SOURCE_FOLDER + "cmp_emptyGridContainer.pdf", + Assertions.assertNull(new CompareTool().compareByContent(fileName, SOURCE_FOLDER + "cmp_emptyGridContainer.pdf", DESTINATION_FOLDER, "diff")); } @@ -223,7 +222,7 @@ public void overflowGridContainerTest() throws IOException, InterruptedException document.close(); - Assert.assertNull(new CompareTool().compareByContent(fileName, SOURCE_FOLDER + "cmp_overflowGridContainer.pdf", + Assertions.assertNull(new CompareTool().compareByContent(fileName, SOURCE_FOLDER + "cmp_overflowGridContainer.pdf", DESTINATION_FOLDER, "diff")); } @@ -242,7 +241,7 @@ public void nothingResultTest() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(fileName, SOURCE_FOLDER + "cmp_nothingResult.pdf", + Assertions.assertNull(new CompareTool().compareByContent(fileName, SOURCE_FOLDER + "cmp_nothingResult.pdf", DESTINATION_FOLDER, "diff")); } diff --git a/layout/src/test/java/com/itextpdf/layout/font/FontCharacteristicsTest.java b/layout/src/test/java/com/itextpdf/layout/font/FontCharacteristicsTest.java index 5e708bfa66..b1a4647057 100644 --- a/layout/src/test/java/com/itextpdf/layout/font/FontCharacteristicsTest.java +++ b/layout/src/test/java/com/itextpdf/layout/font/FontCharacteristicsTest.java @@ -23,22 +23,21 @@ This file is part of the iText (R) project. package com.itextpdf.layout.font; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class FontCharacteristicsTest extends ExtendedITextTest { @Test public void testDefaultFontCharacteristics() { FontCharacteristics fontCharacteristics = new FontCharacteristics(); - Assert.assertFalse(fontCharacteristics.isItalic()); - Assert.assertFalse(fontCharacteristics.isBold()); - Assert.assertFalse(fontCharacteristics.isMonospace()); - Assert.assertTrue(fontCharacteristics.isUndefined()); - Assert.assertEquals(400, fontCharacteristics.getFontWeight()); + Assertions.assertFalse(fontCharacteristics.isItalic()); + Assertions.assertFalse(fontCharacteristics.isBold()); + Assertions.assertFalse(fontCharacteristics.isMonospace()); + Assertions.assertTrue(fontCharacteristics.isUndefined()); + Assertions.assertEquals(400, fontCharacteristics.getFontWeight()); } @Test @@ -46,28 +45,28 @@ public void testPositiveFontWeight() { FontCharacteristics fontCharacteristics = new FontCharacteristics(); fontCharacteristics.setFontWeight((short) 50); - Assert.assertEquals(100, fontCharacteristics.getFontWeight()); - Assert.assertFalse(fontCharacteristics.isUndefined()); + Assertions.assertEquals(100, fontCharacteristics.getFontWeight()); + Assertions.assertFalse(fontCharacteristics.isUndefined()); fontCharacteristics.setFontWeight((short) 120); - Assert.assertEquals(100, fontCharacteristics.getFontWeight()); - Assert.assertFalse(fontCharacteristics.isUndefined()); + Assertions.assertEquals(100, fontCharacteristics.getFontWeight()); + Assertions.assertFalse(fontCharacteristics.isUndefined()); fontCharacteristics.setFontWeight((short) 340); - Assert.assertEquals(300, fontCharacteristics.getFontWeight()); - Assert.assertFalse(fontCharacteristics.isUndefined()); + Assertions.assertEquals(300, fontCharacteristics.getFontWeight()); + Assertions.assertFalse(fontCharacteristics.isUndefined()); fontCharacteristics.setFontWeight((short) 550); - Assert.assertEquals(500, fontCharacteristics.getFontWeight()); - Assert.assertFalse(fontCharacteristics.isUndefined()); + Assertions.assertEquals(500, fontCharacteristics.getFontWeight()); + Assertions.assertFalse(fontCharacteristics.isUndefined()); fontCharacteristics.setFontWeight((short) 885); - Assert.assertEquals(800, fontCharacteristics.getFontWeight()); - Assert.assertFalse(fontCharacteristics.isUndefined()); + Assertions.assertEquals(800, fontCharacteristics.getFontWeight()); + Assertions.assertFalse(fontCharacteristics.isUndefined()); fontCharacteristics.setFontWeight((short) 20000); - Assert.assertEquals(900, fontCharacteristics.getFontWeight()); - Assert.assertFalse(fontCharacteristics.isUndefined()); + Assertions.assertEquals(900, fontCharacteristics.getFontWeight()); + Assertions.assertFalse(fontCharacteristics.isUndefined()); } @Test @@ -75,113 +74,113 @@ public void testIncorrectFontWeight() { FontCharacteristics fontCharacteristics = new FontCharacteristics(); fontCharacteristics.setFontWeight((short) 0); - Assert.assertEquals(400, fontCharacteristics.getFontWeight()); - Assert.assertTrue(fontCharacteristics.isUndefined()); + Assertions.assertEquals(400, fontCharacteristics.getFontWeight()); + Assertions.assertTrue(fontCharacteristics.isUndefined()); fontCharacteristics.setFontWeight((short) -500); - Assert.assertEquals(400, fontCharacteristics.getFontWeight()); - Assert.assertTrue(fontCharacteristics.isUndefined()); + Assertions.assertEquals(400, fontCharacteristics.getFontWeight()); + Assertions.assertTrue(fontCharacteristics.isUndefined()); } @Test public void testBoldFlag() { FontCharacteristics fontCharacteristics = new FontCharacteristics(); - Assert.assertFalse(fontCharacteristics.isBold()); - Assert.assertTrue(fontCharacteristics.isUndefined()); + Assertions.assertFalse(fontCharacteristics.isBold()); + Assertions.assertTrue(fontCharacteristics.isUndefined()); fontCharacteristics.setBoldFlag(true); - Assert.assertTrue(fontCharacteristics.isBold()); - Assert.assertFalse(fontCharacteristics.isUndefined()); + Assertions.assertTrue(fontCharacteristics.isBold()); + Assertions.assertFalse(fontCharacteristics.isUndefined()); fontCharacteristics = new FontCharacteristics(); fontCharacteristics.setBoldFlag(false); - Assert.assertFalse(fontCharacteristics.isBold()); - Assert.assertTrue(fontCharacteristics.isUndefined()); + Assertions.assertFalse(fontCharacteristics.isBold()); + Assertions.assertTrue(fontCharacteristics.isUndefined()); } @Test public void testItalicFlag() { FontCharacteristics fontCharacteristics = new FontCharacteristics(); - Assert.assertFalse(fontCharacteristics.isItalic()); - Assert.assertTrue(fontCharacteristics.isUndefined()); + Assertions.assertFalse(fontCharacteristics.isItalic()); + Assertions.assertTrue(fontCharacteristics.isUndefined()); fontCharacteristics.setItalicFlag(true); - Assert.assertTrue(fontCharacteristics.isItalic()); - Assert.assertFalse(fontCharacteristics.isUndefined()); + Assertions.assertTrue(fontCharacteristics.isItalic()); + Assertions.assertFalse(fontCharacteristics.isUndefined()); fontCharacteristics = new FontCharacteristics(); fontCharacteristics.setItalicFlag(false); - Assert.assertFalse(fontCharacteristics.isItalic()); - Assert.assertTrue(fontCharacteristics.isUndefined()); + Assertions.assertFalse(fontCharacteristics.isItalic()); + Assertions.assertTrue(fontCharacteristics.isUndefined()); } @Test public void testMonospaceFlag() { FontCharacteristics fontCharacteristics = new FontCharacteristics(); - Assert.assertFalse(fontCharacteristics.isMonospace()); - Assert.assertTrue(fontCharacteristics.isUndefined()); + Assertions.assertFalse(fontCharacteristics.isMonospace()); + Assertions.assertTrue(fontCharacteristics.isUndefined()); fontCharacteristics.setMonospaceFlag(true); - Assert.assertTrue(fontCharacteristics.isMonospace()); - Assert.assertFalse(fontCharacteristics.isUndefined()); + Assertions.assertTrue(fontCharacteristics.isMonospace()); + Assertions.assertFalse(fontCharacteristics.isUndefined()); fontCharacteristics = new FontCharacteristics(); fontCharacteristics.setMonospaceFlag(false); - Assert.assertFalse(fontCharacteristics.isMonospace()); - Assert.assertTrue(fontCharacteristics.isUndefined()); + Assertions.assertFalse(fontCharacteristics.isMonospace()); + Assertions.assertTrue(fontCharacteristics.isUndefined()); } @Test public void testIncorrectFontStyle() { FontCharacteristics fontCharacteristics = new FontCharacteristics(); fontCharacteristics.setFontStyle(null); - Assert.assertFalse(fontCharacteristics.isItalic()); - Assert.assertTrue(fontCharacteristics.isUndefined()); + Assertions.assertFalse(fontCharacteristics.isItalic()); + Assertions.assertTrue(fontCharacteristics.isUndefined()); fontCharacteristics.setFontStyle("dsodkodkopsdkod"); - Assert.assertFalse(fontCharacteristics.isItalic()); - Assert.assertTrue(fontCharacteristics.isUndefined()); + Assertions.assertFalse(fontCharacteristics.isItalic()); + Assertions.assertTrue(fontCharacteristics.isUndefined()); fontCharacteristics.setFontStyle(""); - Assert.assertFalse(fontCharacteristics.isItalic()); - Assert.assertTrue(fontCharacteristics.isUndefined()); + Assertions.assertFalse(fontCharacteristics.isItalic()); + Assertions.assertTrue(fontCharacteristics.isUndefined()); fontCharacteristics.setFontStyle("-1"); - Assert.assertFalse(fontCharacteristics.isItalic()); - Assert.assertTrue(fontCharacteristics.isUndefined()); + Assertions.assertFalse(fontCharacteristics.isItalic()); + Assertions.assertTrue(fontCharacteristics.isUndefined()); fontCharacteristics.setFontStyle("bold"); - Assert.assertFalse(fontCharacteristics.isItalic()); - Assert.assertTrue(fontCharacteristics.isUndefined()); + Assertions.assertFalse(fontCharacteristics.isItalic()); + Assertions.assertTrue(fontCharacteristics.isUndefined()); } @Test public void testAllowedFontStyle() { FontCharacteristics fontCharacteristics = new FontCharacteristics(); - Assert.assertFalse(fontCharacteristics.isItalic()); - Assert.assertTrue(fontCharacteristics.isUndefined()); + Assertions.assertFalse(fontCharacteristics.isItalic()); + Assertions.assertTrue(fontCharacteristics.isUndefined()); fontCharacteristics = new FontCharacteristics(); fontCharacteristics.setFontStyle("normal"); - Assert.assertFalse(fontCharacteristics.isItalic()); - Assert.assertTrue(fontCharacteristics.isUndefined()); + Assertions.assertFalse(fontCharacteristics.isItalic()); + Assertions.assertTrue(fontCharacteristics.isUndefined()); fontCharacteristics = new FontCharacteristics(); fontCharacteristics.setFontStyle("oblique"); - Assert.assertTrue(fontCharacteristics.isItalic()); - Assert.assertFalse(fontCharacteristics.isUndefined()); + Assertions.assertTrue(fontCharacteristics.isItalic()); + Assertions.assertFalse(fontCharacteristics.isUndefined()); fontCharacteristics = new FontCharacteristics(); fontCharacteristics.setFontStyle("italic"); - Assert.assertTrue(fontCharacteristics.isItalic()); - Assert.assertFalse(fontCharacteristics.isUndefined()); + Assertions.assertTrue(fontCharacteristics.isItalic()); + Assertions.assertFalse(fontCharacteristics.isUndefined()); } @Test @@ -193,15 +192,15 @@ public void testEquals() { FontCharacteristics sameFontCharacteristics = new FontCharacteristics(); sameFontCharacteristics.setFontStyle("italic"); sameFontCharacteristics.setFontWeight((short) 300); - Assert.assertTrue(fontCharacteristics.equals(sameFontCharacteristics)); + Assertions.assertTrue(fontCharacteristics.equals(sameFontCharacteristics)); FontCharacteristics copyFontCharacteristics = new FontCharacteristics(fontCharacteristics); - Assert.assertTrue(fontCharacteristics.equals(copyFontCharacteristics)); + Assertions.assertTrue(fontCharacteristics.equals(copyFontCharacteristics)); FontCharacteristics diffFontCharacteristics = new FontCharacteristics(); fontCharacteristics.setBoldFlag(true); fontCharacteristics.setFontWeight((short) 800); - Assert.assertFalse(fontCharacteristics.equals(diffFontCharacteristics)); + Assertions.assertFalse(fontCharacteristics.equals(diffFontCharacteristics)); } @Test @@ -213,14 +212,14 @@ public void testHashCode() { FontCharacteristics sameFontCharacteristics = new FontCharacteristics(); sameFontCharacteristics.setFontStyle("italic"); sameFontCharacteristics.setFontWeight((short) 300); - Assert.assertEquals(fontCharacteristics.hashCode(), sameFontCharacteristics.hashCode()); + Assertions.assertEquals(fontCharacteristics.hashCode(), sameFontCharacteristics.hashCode()); FontCharacteristics copyFontCharacteristics = new FontCharacteristics(fontCharacteristics); - Assert.assertEquals(fontCharacteristics.hashCode(), copyFontCharacteristics.hashCode()); + Assertions.assertEquals(fontCharacteristics.hashCode(), copyFontCharacteristics.hashCode()); FontCharacteristics diffFontCharacteristics = new FontCharacteristics(); fontCharacteristics.setBoldFlag(true); fontCharacteristics.setFontWeight((short) 800); - Assert.assertNotEquals(fontCharacteristics.hashCode(), diffFontCharacteristics.hashCode()); + Assertions.assertNotEquals(fontCharacteristics.hashCode(), diffFontCharacteristics.hashCode()); } } diff --git a/layout/src/test/java/com/itextpdf/layout/font/FontCharacteristicsUtilsTest.java b/layout/src/test/java/com/itextpdf/layout/font/FontCharacteristicsUtilsTest.java index 5800d201cd..6dbcbfe5c0 100644 --- a/layout/src/test/java/com/itextpdf/layout/font/FontCharacteristicsUtilsTest.java +++ b/layout/src/test/java/com/itextpdf/layout/font/FontCharacteristicsUtilsTest.java @@ -23,74 +23,73 @@ This file is part of the iText (R) project. package com.itextpdf.layout.font; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class FontCharacteristicsUtilsTest extends ExtendedITextTest { @Test public void testNormalizingThinFontWeight() { - Assert.assertEquals(100, FontCharacteristicsUtils.normalizeFontWeight((short) -10000)); + Assertions.assertEquals(100, FontCharacteristicsUtils.normalizeFontWeight((short) -10000)); - Assert.assertEquals(100, FontCharacteristicsUtils.normalizeFontWeight((short) 0)); + Assertions.assertEquals(100, FontCharacteristicsUtils.normalizeFontWeight((short) 0)); - Assert.assertEquals(100, FontCharacteristicsUtils.normalizeFontWeight((short) 50)); + Assertions.assertEquals(100, FontCharacteristicsUtils.normalizeFontWeight((short) 50)); - Assert.assertEquals(100, FontCharacteristicsUtils.normalizeFontWeight((short) 100)); + Assertions.assertEquals(100, FontCharacteristicsUtils.normalizeFontWeight((short) 100)); } @Test public void testNormalizingHeavyFontWeight() { - Assert.assertEquals(900, FontCharacteristicsUtils.normalizeFontWeight((short) 900)); + Assertions.assertEquals(900, FontCharacteristicsUtils.normalizeFontWeight((short) 900)); - Assert.assertEquals(900, FontCharacteristicsUtils.normalizeFontWeight((short) 1600)); + Assertions.assertEquals(900, FontCharacteristicsUtils.normalizeFontWeight((short) 1600)); - Assert.assertEquals(900, FontCharacteristicsUtils.normalizeFontWeight((short) 23000)); + Assertions.assertEquals(900, FontCharacteristicsUtils.normalizeFontWeight((short) 23000)); } @Test public void testNormalizingNormalFontWeight() { - Assert.assertEquals(200, FontCharacteristicsUtils.normalizeFontWeight((short) 220)); + Assertions.assertEquals(200, FontCharacteristicsUtils.normalizeFontWeight((short) 220)); - Assert.assertEquals(400, FontCharacteristicsUtils.normalizeFontWeight((short) 456)); + Assertions.assertEquals(400, FontCharacteristicsUtils.normalizeFontWeight((short) 456)); - Assert.assertEquals(500, FontCharacteristicsUtils.normalizeFontWeight((short) 550)); + Assertions.assertEquals(500, FontCharacteristicsUtils.normalizeFontWeight((short) 550)); - Assert.assertEquals(600, FontCharacteristicsUtils.normalizeFontWeight((short) 620)); + Assertions.assertEquals(600, FontCharacteristicsUtils.normalizeFontWeight((short) 620)); - Assert.assertEquals(700, FontCharacteristicsUtils.normalizeFontWeight((short) 780)); + Assertions.assertEquals(700, FontCharacteristicsUtils.normalizeFontWeight((short) 780)); } @Test public void testParsingIncorrectFontWeight() { - Assert.assertEquals((short) -1, FontCharacteristicsUtils.parseFontWeight("")); + Assertions.assertEquals((short) -1, FontCharacteristicsUtils.parseFontWeight("")); - Assert.assertEquals((short) -1, FontCharacteristicsUtils.parseFontWeight(null)); + Assertions.assertEquals((short) -1, FontCharacteristicsUtils.parseFontWeight(null)); - Assert.assertEquals((short) -1, FontCharacteristicsUtils.parseFontWeight("dfgdgdfgdfgdf")); + Assertions.assertEquals((short) -1, FontCharacteristicsUtils.parseFontWeight("dfgdgdfgdfgdf")); - Assert.assertEquals((short) -1, FontCharacteristicsUtils.parseFontWeight("italic")); + Assertions.assertEquals((short) -1, FontCharacteristicsUtils.parseFontWeight("italic")); } @Test public void testParsingNumberFontWeight() { - Assert.assertEquals((short) 100, FontCharacteristicsUtils.parseFontWeight("-1")); + Assertions.assertEquals((short) 100, FontCharacteristicsUtils.parseFontWeight("-1")); - Assert.assertEquals((short) 100, FontCharacteristicsUtils.parseFontWeight("50")); + Assertions.assertEquals((short) 100, FontCharacteristicsUtils.parseFontWeight("50")); - Assert.assertEquals((short) 300, FontCharacteristicsUtils.parseFontWeight("360")); + Assertions.assertEquals((short) 300, FontCharacteristicsUtils.parseFontWeight("360")); - Assert.assertEquals((short) 900, FontCharacteristicsUtils.parseFontWeight("25000")); + Assertions.assertEquals((short) 900, FontCharacteristicsUtils.parseFontWeight("25000")); } @Test public void testParseAllowedFontWeight() { - Assert.assertEquals((short) 400, FontCharacteristicsUtils.parseFontWeight("normal")); + Assertions.assertEquals((short) 400, FontCharacteristicsUtils.parseFontWeight("normal")); - Assert.assertEquals((short) 700, FontCharacteristicsUtils.parseFontWeight("bold")); + Assertions.assertEquals((short) 700, FontCharacteristicsUtils.parseFontWeight("bold")); } } diff --git a/layout/src/test/java/com/itextpdf/layout/font/FontSelectorLayoutTest.java b/layout/src/test/java/com/itextpdf/layout/font/FontSelectorLayoutTest.java index 10ba59954b..420ab874ce 100644 --- a/layout/src/test/java/com/itextpdf/layout/font/FontSelectorLayoutTest.java +++ b/layout/src/test/java/com/itextpdf/layout/font/FontSelectorLayoutTest.java @@ -33,22 +33,21 @@ This file is part of the iText (R) project. import com.itextpdf.layout.font.selectorstrategy.BestMatchFontSelectorStrategy.BestMatchFontSelectorStrategyFactory; import com.itextpdf.test.AssertUtil; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.ByteArrayOutputStream; import java.io.IOException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class FontSelectorLayoutTest extends ExtendedITextTest { private static final String sourceFolder = "./src/test/resources/com/itextpdf/layout/NonBreakingHyphenTest/"; private static final String destinationFolder = "./target/test/com/itextpdf/layout/NonBreakingHyphenTest/"; private static final String fontsFolder = "./src/test/resources/com/itextpdf/layout/fonts/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } @@ -77,7 +76,7 @@ public void nonBreakingHyphenDifferentFonts() throws IOException, InterruptedExc document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diffPrefix")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diffPrefix")); } private static Paragraph createParagraph(String textParagraph, String font) { diff --git a/layout/src/test/java/com/itextpdf/layout/font/RangeTest.java b/layout/src/test/java/com/itextpdf/layout/font/RangeTest.java index b921ab9201..281c2238f9 100644 --- a/layout/src/test/java/com/itextpdf/layout/font/RangeTest.java +++ b/layout/src/test/java/com/itextpdf/layout/font/RangeTest.java @@ -23,35 +23,34 @@ This file is part of the iText (R) project. package com.itextpdf.layout.font; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.util.Random; -@Category(UnitTest.class) +@Tag("UnitTest") public class RangeTest extends ExtendedITextTest { @Test public void testWrongRange() { - Assert.assertThrows(IllegalArgumentException.class, () -> new RangeBuilder().addRange(11, 10)); + Assertions.assertThrows(IllegalArgumentException.class, () -> new RangeBuilder().addRange(11, 10)); } @Test public void testWrongRangeSize() { - Assert.assertThrows(IllegalArgumentException.class, () -> new RangeBuilder().create()); + Assertions.assertThrows(IllegalArgumentException.class, () -> new RangeBuilder().create()); } @Test public void testFullRange() { - Assert.assertTrue(RangeBuilder.getFullRange().contains(new Random().nextInt())); + Assertions.assertTrue(RangeBuilder.getFullRange().contains(new Random().nextInt())); - Assert.assertTrue(RangeBuilder.getFullRange().equals(RangeBuilder.getFullRange())); + Assertions.assertTrue(RangeBuilder.getFullRange().equals(RangeBuilder.getFullRange())); - Assert.assertTrue(RangeBuilder.getFullRange() == RangeBuilder.getFullRange()); + Assertions.assertTrue(RangeBuilder.getFullRange() == RangeBuilder.getFullRange()); - Assert.assertFalse(RangeBuilder.getFullRange().equals(new RangeBuilder().addRange(1).create())); + Assertions.assertFalse(RangeBuilder.getFullRange().equals(new RangeBuilder().addRange(1).create())); } @Test @@ -67,18 +66,18 @@ public void testHashCodeAndEquals() { .create(); - Assert.assertTrue(range.hashCode() == range2.hashCode()); - Assert.assertTrue(range.equals(range2)); - Assert.assertEquals(range.toString(), range2.toString()); + Assertions.assertTrue(range.hashCode() == range2.hashCode()); + Assertions.assertTrue(range.equals(range2)); + Assertions.assertEquals(range.toString(), range2.toString()); Range range3 = new RangeBuilder(25) .addRange((char) 26) .addRange((char) 1, (char) 7) .create(); - Assert.assertFalse(range2.hashCode() == range3.hashCode()); - Assert.assertFalse(range2.equals(range3)); - Assert.assertNotEquals(range2.toString(), range3.toString()); + Assertions.assertFalse(range2.hashCode() == range3.hashCode()); + Assertions.assertFalse(range2.equals(range3)); + Assertions.assertNotEquals(range2.toString(), range3.toString()); Range range4 = new RangeBuilder(26) .addRange((char) 25) @@ -86,9 +85,9 @@ public void testHashCodeAndEquals() { .addRange((char) 3, (char) 7) .create(); - Assert.assertTrue(range3.hashCode() == range4.hashCode()); - Assert.assertTrue(range3.equals(range4)); - Assert.assertEquals(range3.toString(), range4.toString()); + Assertions.assertTrue(range3.hashCode() == range4.hashCode()); + Assertions.assertTrue(range3.equals(range4)); + Assertions.assertEquals(range3.toString(), range4.toString()); } @Test @@ -103,23 +102,23 @@ public void testUnionAndContains() { .addRange(8, 15) .addRange(25, 30) .create(); - Assert.assertEquals("[(0; 22), (25; 30), (33; 40)]", range.toString()); - - Assert.assertTrue(range.contains(0)); - Assert.assertTrue(range.contains(10)); - Assert.assertTrue(range.contains(22)); - Assert.assertTrue(range.contains(25)); - Assert.assertTrue(range.contains(27)); - Assert.assertTrue(range.contains(30)); - Assert.assertTrue(range.contains(33)); - Assert.assertTrue(range.contains(34)); - Assert.assertTrue(range.contains(40)); - - Assert.assertFalse(range.contains(-1)); - Assert.assertFalse(range.contains(23)); - Assert.assertFalse(range.contains(31)); - Assert.assertFalse(range.contains(32)); - Assert.assertFalse(range.contains(41)); + Assertions.assertEquals("[(0; 22), (25; 30), (33; 40)]", range.toString()); + + Assertions.assertTrue(range.contains(0)); + Assertions.assertTrue(range.contains(10)); + Assertions.assertTrue(range.contains(22)); + Assertions.assertTrue(range.contains(25)); + Assertions.assertTrue(range.contains(27)); + Assertions.assertTrue(range.contains(30)); + Assertions.assertTrue(range.contains(33)); + Assertions.assertTrue(range.contains(34)); + Assertions.assertTrue(range.contains(40)); + + Assertions.assertFalse(range.contains(-1)); + Assertions.assertFalse(range.contains(23)); + Assertions.assertFalse(range.contains(31)); + Assertions.assertFalse(range.contains(32)); + Assertions.assertFalse(range.contains(41)); } @Test @@ -129,15 +128,15 @@ public void testSingles() { .addRange(3) .addRange(6) .create(); - Assert.assertEquals("[(1; 1), (2; 2), (3; 3), (6; 6)]", range.toString()); + Assertions.assertEquals("[(1; 1), (2; 2), (3; 3), (6; 6)]", range.toString()); - Assert.assertTrue(range.contains(1)); - Assert.assertTrue(range.contains(2)); - Assert.assertTrue(range.contains(3)); - Assert.assertTrue(range.contains(6)); + Assertions.assertTrue(range.contains(1)); + Assertions.assertTrue(range.contains(2)); + Assertions.assertTrue(range.contains(3)); + Assertions.assertTrue(range.contains(6)); - Assert.assertFalse(range.contains(0)); - Assert.assertFalse(range.contains(5)); - Assert.assertFalse(range.contains(7)); + Assertions.assertFalse(range.contains(0)); + Assertions.assertFalse(range.contains(5)); + Assertions.assertFalse(range.contains(7)); } } diff --git a/layout/src/test/java/com/itextpdf/layout/font/selectorstrategy/BestMatchFontSelectorStrategyTest.java b/layout/src/test/java/com/itextpdf/layout/font/selectorstrategy/BestMatchFontSelectorStrategyTest.java index a89dbcfe7e..92a6137bfa 100644 --- a/layout/src/test/java/com/itextpdf/layout/font/selectorstrategy/BestMatchFontSelectorStrategyTest.java +++ b/layout/src/test/java/com/itextpdf/layout/font/selectorstrategy/BestMatchFontSelectorStrategyTest.java @@ -27,14 +27,13 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.font.PdfFont; import com.itextpdf.layout.font.selectorstrategy.BestMatchFontSelectorStrategy.BestMatchFontSelectorStrategyFactory; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class BestMatchFontSelectorStrategyTest extends ExtendedITextTest { @Test public void twoDiacriticsInRowTest() { @@ -42,12 +41,12 @@ public void twoDiacriticsInRowTest() { final List> result = strategy.getGlyphLines( "L with accent: \u004f\u0301\u0302 abc"); - Assert.assertEquals(3, result.size()); - Assert.assertEquals("L with accent: ", result.get(0).getFirst().toString()); - Assert.assertEquals("\u004f\u0301\u0302", result.get(1).getFirst().toString()); - Assert.assertEquals(" abc", result.get(2).getFirst().toString()); + Assertions.assertEquals(3, result.size()); + Assertions.assertEquals("L with accent: ", result.get(0).getFirst().toString()); + Assertions.assertEquals("\u004f\u0301\u0302", result.get(1).getFirst().toString()); + Assertions.assertEquals(" abc", result.get(2).getFirst().toString()); // Diacritics and symbol were separated, but the font is the same - Assert.assertEquals(result.get(0).getSecond(), result.get(2).getSecond()); + Assertions.assertEquals(result.get(0).getSecond(), result.get(2).getSecond()); } @Test @@ -56,11 +55,11 @@ public void oneDiacriticTest() { final List> result = strategy.getGlyphLines( "L with accent: \u004f\u0302 abc"); - Assert.assertEquals(3, result.size()); - Assert.assertEquals("L with accent: ", result.get(0).getFirst().toString()); - Assert.assertEquals("\u004f\u0302", result.get(1).getFirst().toString()); - Assert.assertEquals(" abc", result.get(2).getFirst().toString()); - Assert.assertNotEquals(result.get(0).getSecond(), result.get(1).getSecond()); + Assertions.assertEquals(3, result.size()); + Assertions.assertEquals("L with accent: ", result.get(0).getFirst().toString()); + Assertions.assertEquals("\u004f\u0302", result.get(1).getFirst().toString()); + Assertions.assertEquals(" abc", result.get(2).getFirst().toString()); + Assertions.assertNotEquals(result.get(0).getSecond(), result.get(1).getSecond()); } @Test @@ -69,12 +68,12 @@ public void oneDiacriticWithUnsupportedFontTest() { final List> result = strategy.getGlyphLines( "L with accent: \u004f\u0302 abc"); - Assert.assertEquals(3, result.size()); - Assert.assertEquals("L with accent: \u004f", result.get(0).getFirst().toString()); - Assert.assertEquals("", result.get(1).getFirst().toString()); - Assert.assertEquals(" abc", result.get(2).getFirst().toString()); - Assert.assertEquals(result.get(0).getSecond(), result.get(2).getSecond()); - Assert.assertEquals(result.get(0).getSecond(), result.get(1).getSecond()); + Assertions.assertEquals(3, result.size()); + Assertions.assertEquals("L with accent: \u004f", result.get(0).getFirst().toString()); + Assertions.assertEquals("", result.get(1).getFirst().toString()); + Assertions.assertEquals(" abc", result.get(2).getFirst().toString()); + Assertions.assertEquals(result.get(0).getSecond(), result.get(2).getSecond()); + Assertions.assertEquals(result.get(0).getSecond(), result.get(1).getSecond()); } @Test @@ -83,15 +82,15 @@ public void diacriticFontDoesnotContainPreviousSymbolTest() { final List> result = strategy.getGlyphLines( "Ми\u0301ръ (mírə)"); - Assert.assertEquals(6, result.size()); - Assert.assertEquals("Ми", result.get(0).getFirst().toString()); - Assert.assertEquals("\u0301", result.get(1).getFirst().toString()); - Assert.assertEquals("ръ", result.get(2).getFirst().toString()); - Assert.assertEquals(" (mír", result.get(3).getFirst().toString()); - Assert.assertEquals("ə", result.get(4).getFirst().toString()); - Assert.assertEquals(")", result.get(5).getFirst().toString()); - Assert.assertEquals(result.get(0).getSecond(), result.get(2).getSecond()); - Assert.assertEquals(result.get(2).getSecond(), result.get(3).getSecond()); + Assertions.assertEquals(6, result.size()); + Assertions.assertEquals("Ми", result.get(0).getFirst().toString()); + Assertions.assertEquals("\u0301", result.get(1).getFirst().toString()); + Assertions.assertEquals("ръ", result.get(2).getFirst().toString()); + Assertions.assertEquals(" (mír", result.get(3).getFirst().toString()); + Assertions.assertEquals("ə", result.get(4).getFirst().toString()); + Assertions.assertEquals(")", result.get(5).getFirst().toString()); + Assertions.assertEquals(result.get(0).getSecond(), result.get(2).getSecond()); + Assertions.assertEquals(result.get(2).getSecond(), result.get(3).getSecond()); } @@ -101,8 +100,8 @@ public void oneDiacriticWithOneSupportedFontTest() { final List> result = strategy.getGlyphLines( "L with accent: \u004f\u0302 abc"); - Assert.assertEquals(1, result.size()); - Assert.assertEquals("L with accent: \u004f\u0302 abc", result.get(0).getFirst().toString()); + Assertions.assertEquals(1, result.size()); + Assertions.assertEquals("L with accent: \u004f\u0302 abc", result.get(0).getFirst().toString()); } @Test @@ -112,11 +111,11 @@ public void surrogatePairsTest() { // this text contains three successive surrogate pairs final List> result = strategy.getGlyphLines( "text \uD800\uDF10\uD800\uDF00\uD800\uDF11 text"); - Assert.assertEquals(3, result.size()); - Assert.assertEquals("text", result.get(0).getFirst().toString()); - Assert.assertEquals(" \uD800\uDF10\uD800\uDF00\uD800\uDF11 ", result.get(1).getFirst().toString()); - Assert.assertEquals("text", result.get(2).getFirst().toString()); - Assert.assertEquals(result.get(0).getSecond(), result.get(2).getSecond()); + Assertions.assertEquals(3, result.size()); + Assertions.assertEquals("text", result.get(0).getFirst().toString()); + Assertions.assertEquals(" \uD800\uDF10\uD800\uDF00\uD800\uDF11 ", result.get(1).getFirst().toString()); + Assertions.assertEquals("text", result.get(2).getFirst().toString()); + Assertions.assertEquals(result.get(0).getSecond(), result.get(2).getSecond()); } @Test @@ -124,10 +123,10 @@ public void simpleThreeFontTest() { IFontSelectorStrategy strategy = FontSelectorTestsUtil.createStrategyWithLimitedThreeFonts(new BestMatchFontSelectorStrategyFactory()); final List> result = strategy.getGlyphLines("abcdefxyz"); - Assert.assertEquals(3, result.size()); - Assert.assertEquals("abc", result.get(0).getFirst().toString()); - Assert.assertEquals("def", result.get(1).getFirst().toString()); - Assert.assertEquals("xyz", result.get(2).getFirst().toString()); + Assertions.assertEquals(3, result.size()); + Assertions.assertEquals("abc", result.get(0).getFirst().toString()); + Assertions.assertEquals("def", result.get(1).getFirst().toString()); + Assertions.assertEquals("xyz", result.get(2).getFirst().toString()); } @Test @@ -135,12 +134,12 @@ public void threeFontWithSpacesTest() { IFontSelectorStrategy strategy = FontSelectorTestsUtil.createStrategyWithLimitedThreeFonts(new BestMatchFontSelectorStrategyFactory()); final List> result = strategy.getGlyphLines(" axadefa "); - Assert.assertEquals(6, result.size()); - Assert.assertEquals(" a", result.get(0).getFirst().toString()); - Assert.assertEquals("x", result.get(1).getFirst().toString()); - Assert.assertEquals("a", result.get(2).getFirst().toString()); - Assert.assertEquals("def", result.get(3).getFirst().toString()); - Assert.assertEquals("a", result.get(4).getFirst().toString()); - Assert.assertEquals(" ", result.get(5).getFirst().toString()); + Assertions.assertEquals(6, result.size()); + Assertions.assertEquals(" a", result.get(0).getFirst().toString()); + Assertions.assertEquals("x", result.get(1).getFirst().toString()); + Assertions.assertEquals("a", result.get(2).getFirst().toString()); + Assertions.assertEquals("def", result.get(3).getFirst().toString()); + Assertions.assertEquals("a", result.get(4).getFirst().toString()); + Assertions.assertEquals(" ", result.get(5).getFirst().toString()); } } diff --git a/layout/src/test/java/com/itextpdf/layout/font/selectorstrategy/FirstMatchFontSelectorStrategyTest.java b/layout/src/test/java/com/itextpdf/layout/font/selectorstrategy/FirstMatchFontSelectorStrategyTest.java index 6a29545b41..650e12d4b8 100644 --- a/layout/src/test/java/com/itextpdf/layout/font/selectorstrategy/FirstMatchFontSelectorStrategyTest.java +++ b/layout/src/test/java/com/itextpdf/layout/font/selectorstrategy/FirstMatchFontSelectorStrategyTest.java @@ -27,14 +27,13 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.font.PdfFont; import com.itextpdf.layout.font.selectorstrategy.FirstMatchFontSelectorStrategy.FirstMathFontSelectorStrategyFactory; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class FirstMatchFontSelectorStrategyTest extends ExtendedITextTest { @Test public void twoDiacriticsInRowTest() { @@ -42,9 +41,9 @@ public void twoDiacriticsInRowTest() { final List> result = strategy.getGlyphLines( "L with accent: \u004f\u0301\u0302 abc"); - Assert.assertEquals(2, result.size()); - Assert.assertEquals("L with accent: ", result.get(0).getFirst().toString()); - Assert.assertEquals("\u004f\u0301\u0302 abc", result.get(1).getFirst().toString()); + Assertions.assertEquals(2, result.size()); + Assertions.assertEquals("L with accent: ", result.get(0).getFirst().toString()); + Assertions.assertEquals("\u004f\u0301\u0302 abc", result.get(1).getFirst().toString()); } @Test @@ -53,10 +52,10 @@ public void oneDiacriticTest() { final List> result = strategy.getGlyphLines( "L with accent: \u004f\u0302 abc"); - Assert.assertEquals(2, result.size()); - Assert.assertEquals("L with accent: ", result.get(0).getFirst().toString()); - Assert.assertEquals("\u004f\u0302 abc", result.get(1).getFirst().toString()); - Assert.assertNotEquals(result.get(0).getSecond(), result.get(1).getSecond()); + Assertions.assertEquals(2, result.size()); + Assertions.assertEquals("L with accent: ", result.get(0).getFirst().toString()); + Assertions.assertEquals("\u004f\u0302 abc", result.get(1).getFirst().toString()); + Assertions.assertNotEquals(result.get(0).getSecond(), result.get(1).getSecond()); } @Test @@ -65,15 +64,15 @@ public void diacriticFontDoesnotContainPreviousSymbolTest() { final List> result = strategy.getGlyphLines( "Ми\u0301ръ (mírə)"); - Assert.assertEquals(6, result.size()); - Assert.assertEquals("Ми", result.get(0).getFirst().toString()); - Assert.assertEquals("\u0301", result.get(1).getFirst().toString()); - Assert.assertEquals("ръ (", result.get(2).getFirst().toString()); - Assert.assertEquals("mír", result.get(3).getFirst().toString()); - Assert.assertEquals("ə", result.get(4).getFirst().toString()); - Assert.assertEquals(")", result.get(5).getFirst().toString()); - Assert.assertEquals(result.get(0).getSecond(), result.get(2).getSecond()); - Assert.assertEquals(result.get(2).getSecond(), result.get(3).getSecond()); + Assertions.assertEquals(6, result.size()); + Assertions.assertEquals("Ми", result.get(0).getFirst().toString()); + Assertions.assertEquals("\u0301", result.get(1).getFirst().toString()); + Assertions.assertEquals("ръ (", result.get(2).getFirst().toString()); + Assertions.assertEquals("mír", result.get(3).getFirst().toString()); + Assertions.assertEquals("ə", result.get(4).getFirst().toString()); + Assertions.assertEquals(")", result.get(5).getFirst().toString()); + Assertions.assertEquals(result.get(0).getSecond(), result.get(2).getSecond()); + Assertions.assertEquals(result.get(2).getSecond(), result.get(3).getSecond()); } @Test @@ -82,12 +81,12 @@ public void oneDiacriticWithUnsupportedFontTest() { final List> result = strategy.getGlyphLines( "L with accent: \u004f\u0302 abc"); - Assert.assertEquals(3, result.size()); - Assert.assertEquals("L with accent: \u004f", result.get(0).getFirst().toString()); - Assert.assertEquals("", result.get(1).getFirst().toString()); - Assert.assertEquals(" abc", result.get(2).getFirst().toString()); - Assert.assertEquals(result.get(0).getSecond(), result.get(2).getSecond()); - Assert.assertEquals(result.get(0).getSecond(), result.get(1).getSecond()); + Assertions.assertEquals(3, result.size()); + Assertions.assertEquals("L with accent: \u004f", result.get(0).getFirst().toString()); + Assertions.assertEquals("", result.get(1).getFirst().toString()); + Assertions.assertEquals(" abc", result.get(2).getFirst().toString()); + Assertions.assertEquals(result.get(0).getSecond(), result.get(2).getSecond()); + Assertions.assertEquals(result.get(0).getSecond(), result.get(1).getSecond()); } @Test @@ -96,8 +95,8 @@ public void oneDiacriticWithOneSupportedFontTest() { final List> result = strategy.getGlyphLines( "L with accent: \u004f\u0302 abc"); - Assert.assertEquals(1, result.size()); - Assert.assertEquals("L with accent: \u004f\u0302 abc", result.get(0).getFirst().toString()); + Assertions.assertEquals(1, result.size()); + Assertions.assertEquals("L with accent: \u004f\u0302 abc", result.get(0).getFirst().toString()); } @Test @@ -107,11 +106,11 @@ public void surrogatePairsTest() { // this text contains three successive surrogate pairs final List> result = strategy.getGlyphLines( "text \uD800\uDF10\uD800\uDF00\uD800\uDF11 text"); - Assert.assertEquals(3, result.size()); - Assert.assertEquals("text ", result.get(0).getFirst().toString()); - Assert.assertEquals("\uD800\uDF10\uD800\uDF00\uD800\uDF11 ", result.get(1).getFirst().toString()); - Assert.assertEquals("text", result.get(2).getFirst().toString()); - Assert.assertEquals(result.get(0).getSecond(), result.get(2).getSecond()); + Assertions.assertEquals(3, result.size()); + Assertions.assertEquals("text ", result.get(0).getFirst().toString()); + Assertions.assertEquals("\uD800\uDF10\uD800\uDF00\uD800\uDF11 ", result.get(1).getFirst().toString()); + Assertions.assertEquals("text", result.get(2).getFirst().toString()); + Assertions.assertEquals(result.get(0).getSecond(), result.get(2).getSecond()); } @Test @@ -119,8 +118,8 @@ public void simpleThreeFontTest() { IFontSelectorStrategy strategy = FontSelectorTestsUtil.createStrategyWithLimitedThreeFonts(new FirstMathFontSelectorStrategyFactory()); final List> result = strategy.getGlyphLines("abcdefxyz"); - Assert.assertEquals(1, result.size()); - Assert.assertEquals("abcdefxyz", result.get(0).getFirst().toString()); + Assertions.assertEquals(1, result.size()); + Assertions.assertEquals("abcdefxyz", result.get(0).getFirst().toString()); } @Test @@ -128,7 +127,7 @@ public void threeFontWithSpacesTest() { IFontSelectorStrategy strategy = FontSelectorTestsUtil.createStrategyWithLimitedThreeFonts(new FirstMathFontSelectorStrategyFactory()); final List> result = strategy.getGlyphLines(" axadefa "); - Assert.assertEquals(1, result.size()); - Assert.assertEquals(" axadefa ", result.get(0).getFirst().toString()); + Assertions.assertEquals(1, result.size()); + Assertions.assertEquals(" axadefa ", result.get(0).getFirst().toString()); } } diff --git a/layout/src/test/java/com/itextpdf/layout/hyphenation/HyphenationTreeTest.java b/layout/src/test/java/com/itextpdf/layout/hyphenation/HyphenationTreeTest.java new file mode 100644 index 0000000000..0243c9aaf7 --- /dev/null +++ b/layout/src/test/java/com/itextpdf/layout/hyphenation/HyphenationTreeTest.java @@ -0,0 +1,59 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.layout.hyphenation; + +import com.itextpdf.test.ExtendedITextTest; + +import java.io.IOException; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; +import org.xml.sax.SAXException; + +@Tag("UnitTest") +public class HyphenationTreeTest extends ExtendedITextTest { + + private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/layout/HyphenationTreeTest/"; + + @Test + public void loadPatternXmlTest() throws HyphenationException, IOException { + String sourceFilePath = SOURCE_FOLDER + "hyphen_pattern.xml"; + HyphenationTree hyphenationTree = new HyphenationTree(); + hyphenationTree.loadPatterns(sourceFilePath); + Assertions.assertEquals(3, hyphenationTree.length); + } + + @Test + public void directlyParsePatternClassesTest() throws HyphenationException, IOException, SAXException { + String sourceFilePath = SOURCE_FOLDER + "only_classes.xml"; + String classPatterns = "\u0000a\u0000Ab\u0000B\u0000c\u0000C\u0000d\u0000D"; + + HyphenationTree hyphenationTree = new HyphenationTree(); + PatternParser patternParser = new PatternParser(hyphenationTree); + patternParser.parse(sourceFilePath); + + char[] sc = hyphenationTree.classmap.sc; + String resultClassmapSc = new String(sc); + Assertions.assertTrue(resultClassmapSc.contains(classPatterns)); + } +} diff --git a/layout/src/test/java/com/itextpdf/layout/layout/LayoutAreaTest.java b/layout/src/test/java/com/itextpdf/layout/layout/LayoutAreaTest.java index 319ea88193..be62a9e47d 100644 --- a/layout/src/test/java/com/itextpdf/layout/layout/LayoutAreaTest.java +++ b/layout/src/test/java/com/itextpdf/layout/layout/LayoutAreaTest.java @@ -24,12 +24,11 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.geom.Rectangle; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class LayoutAreaTest extends ExtendedITextTest { @Test @@ -39,12 +38,12 @@ public void cloneTest() { LayoutArea cloneAsLayoutArea = ((LayoutArea) originalRootLayoutArea).clone(); RootLayoutArea cloneAsRootLayoutArea = (RootLayoutArea) originalRootLayoutArea.clone(); - Assert.assertTrue((originalRootLayoutArea).getBBox() != cloneAsLayoutArea.getBBox()); + Assertions.assertTrue((originalRootLayoutArea).getBBox() != cloneAsLayoutArea.getBBox()); - Assert.assertEquals(RootLayoutArea.class, cloneAsRootLayoutArea.getClass()); + Assertions.assertEquals(RootLayoutArea.class, cloneAsRootLayoutArea.getClass()); - Assert.assertEquals(RootLayoutArea.class, cloneAsLayoutArea.getClass()); - Assert.assertFalse(((RootLayoutArea) cloneAsLayoutArea).isEmptyArea()); + Assertions.assertEquals(RootLayoutArea.class, cloneAsLayoutArea.getClass()); + Assertions.assertFalse(((RootLayoutArea) cloneAsLayoutArea).isEmptyArea()); } diff --git a/layout/src/test/java/com/itextpdf/layout/margincollapse/MarginsCollapseHandlerTest.java b/layout/src/test/java/com/itextpdf/layout/margincollapse/MarginsCollapseHandlerTest.java index 6817fe5932..26a4adb217 100644 --- a/layout/src/test/java/com/itextpdf/layout/margincollapse/MarginsCollapseHandlerTest.java +++ b/layout/src/test/java/com/itextpdf/layout/margincollapse/MarginsCollapseHandlerTest.java @@ -32,12 +32,11 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class MarginsCollapseHandlerTest extends ExtendedITextTest { @Test diff --git a/layout/src/test/java/com/itextpdf/layout/properties/BackgroundImageTest.java b/layout/src/test/java/com/itextpdf/layout/properties/BackgroundImageTest.java index 183751433c..efc46bb71a 100644 --- a/layout/src/test/java/com/itextpdf/layout/properties/BackgroundImageTest.java +++ b/layout/src/test/java/com/itextpdf/layout/properties/BackgroundImageTest.java @@ -49,24 +49,23 @@ This file is part of the iText (R) project. import com.itextpdf.test.LogLevelConstants; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; import java.lang.reflect.Field; import java.net.MalformedURLException; import java.util.Arrays; import java.util.List; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class BackgroundImageTest extends ExtendedITextTest { public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/layout/BackgroundImageTest/"; public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/layout/BackgroundImageTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(DESTINATION_FOLDER); } @@ -76,8 +75,8 @@ public void backgroundImage() throws IOException, InterruptedException { PdfImageXObject xObject = new PdfImageXObject(ImageDataFactory.create(SOURCE_FOLDER + "itis.jpg")); BackgroundImage backgroundImage = new BackgroundImage.Builder().setImage(xObject).build(); - Assert.assertEquals(BackgroundRepeatValue.REPEAT, backgroundImage.getRepeat().getXAxisRepeat()); - Assert.assertEquals(BackgroundRepeatValue.REPEAT, backgroundImage.getRepeat().getYAxisRepeat()); + Assertions.assertEquals(BackgroundRepeatValue.REPEAT, backgroundImage.getRepeat().getXAxisRepeat()); + Assertions.assertEquals(BackgroundRepeatValue.REPEAT, backgroundImage.getRepeat().getYAxisRepeat()); backgroundImageGenericTest("backgroundImage", backgroundImage); } @@ -89,11 +88,11 @@ public void copyConstructorTest() throws MalformedURLException { Field[] imageFields = image.getClass().getDeclaredFields(); BackgroundImage copyImage = new BackgroundImage(image); Field[] copyImageFields = copyImage.getClass().getDeclaredFields(); - Assert.assertEquals(imageFields.length, copyImageFields.length); + Assertions.assertEquals(imageFields.length, copyImageFields.length); for (int i = 0; i < imageFields.length; i++) { Field imageField = imageFields[i]; Field copyImageField = copyImageFields[i]; - Assert.assertEquals(imageField, copyImageField); + Assertions.assertEquals(imageField, copyImageField); } } @@ -102,8 +101,8 @@ public void backgroundImageClipOriginDefaultsTest() throws IOException, Interrup PdfImageXObject xObject = new PdfImageXObject(ImageDataFactory.create(SOURCE_FOLDER + "itis.jpg")); BackgroundImage backgroundImage = new BackgroundImage.Builder().setImage(xObject).build(); - Assert.assertEquals(BackgroundBox.BORDER_BOX, backgroundImage.getBackgroundClip()); - Assert.assertEquals(BackgroundBox.PADDING_BOX, backgroundImage.getBackgroundOrigin()); + Assertions.assertEquals(BackgroundBox.BORDER_BOX, backgroundImage.getBackgroundClip()); + Assertions.assertEquals(BackgroundBox.PADDING_BOX, backgroundImage.getBackgroundOrigin()); backgroundImageGenericTest("backgroundImage", backgroundImage); } @@ -114,8 +113,8 @@ public void backgroundImageClipOriginTest() throws IOException, InterruptedExcep BackgroundImage backgroundImage = new BackgroundImage.Builder().setImage(xObject) .setBackgroundClip(BackgroundBox.CONTENT_BOX).setBackgroundOrigin(BackgroundBox.CONTENT_BOX).build(); - Assert.assertEquals(BackgroundBox.CONTENT_BOX, backgroundImage.getBackgroundClip()); - Assert.assertEquals(BackgroundBox.CONTENT_BOX, backgroundImage.getBackgroundOrigin()); + Assertions.assertEquals(BackgroundBox.CONTENT_BOX, backgroundImage.getBackgroundClip()); + Assertions.assertEquals(BackgroundBox.CONTENT_BOX, backgroundImage.getBackgroundOrigin()); backgroundImageGenericTest("backgroundImage", backgroundImage); } @@ -191,10 +190,10 @@ public void backgroundImageForText() throws IOException, InterruptedException { PdfImageXObject xObject = new PdfImageXObject(ImageDataFactory.create(SOURCE_FOLDER + "itis.jpg")); BackgroundImage backgroundImage = new BackgroundImage.Builder().setImage(xObject).build(); - Assert.assertEquals(BackgroundRepeatValue.REPEAT, backgroundImage.getRepeat().getXAxisRepeat()); - Assert.assertEquals(BackgroundRepeatValue.REPEAT, backgroundImage.getRepeat().getYAxisRepeat()); + Assertions.assertEquals(BackgroundRepeatValue.REPEAT, backgroundImage.getRepeat().getXAxisRepeat()); + Assertions.assertEquals(BackgroundRepeatValue.REPEAT, backgroundImage.getRepeat().getYAxisRepeat()); - Assert.assertTrue(backgroundImage.isBackgroundSpecified()); + Assertions.assertTrue(backgroundImage.isBackgroundSpecified()); String outFileName = DESTINATION_FOLDER + "backgroundImageForText.pdf"; String cmpFileName = SOURCE_FOLDER + "cmp_backgroundImageForText.pdf"; @@ -211,7 +210,7 @@ public void backgroundImageForText() throws IOException, InterruptedException { } - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -232,7 +231,7 @@ public void backgroundImageWithPercentWidth() throws IOException, InterruptedExc doc.add(new Paragraph(textElement)); } - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -253,7 +252,7 @@ public void backgroundImageWithPercentHeight() throws IOException, InterruptedEx doc.add(new Paragraph(textElement)); } - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -275,7 +274,7 @@ public void backgroundImageWithPercentHeightAndWidth() throws IOException, Inter doc.add(new Paragraph(textElement)); } - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -296,7 +295,7 @@ public void backgroundImageWithPointWidth() throws IOException, InterruptedExcep doc.add(new Paragraph(textElement)); } - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -317,7 +316,7 @@ public void backgroundImageWithPointHeight() throws IOException, InterruptedExce doc.add(new Paragraph(textElement)); } - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -339,7 +338,7 @@ public void backgroundImageWithPointHeightAndWidth() throws IOException, Interru doc.add(new Paragraph(textElement)); } - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -361,7 +360,7 @@ public void backgroundImageWithLowWidthAndHeight() throws IOException, Interrupt doc.add(new Paragraph(textElement)); } - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -370,8 +369,8 @@ public void backgroundImageWithoutRepeatXTest() throws IOException, InterruptedE BackgroundImage backgroundImage = new BackgroundImage .Builder().setImage(xObject).setBackgroundRepeat(new BackgroundRepeat(BackgroundRepeatValue.NO_REPEAT, BackgroundRepeatValue.REPEAT)).build(); - Assert.assertEquals(BackgroundRepeatValue.NO_REPEAT, backgroundImage.getRepeat().getXAxisRepeat()); - Assert.assertEquals(BackgroundRepeatValue.REPEAT, backgroundImage.getRepeat().getYAxisRepeat()); + Assertions.assertEquals(BackgroundRepeatValue.NO_REPEAT, backgroundImage.getRepeat().getXAxisRepeat()); + Assertions.assertEquals(BackgroundRepeatValue.REPEAT, backgroundImage.getRepeat().getYAxisRepeat()); backgroundImageGenericTest("backgroundImageWithoutRepeatX", backgroundImage); } @@ -382,8 +381,8 @@ public void backgroundImageWithoutRepeatYTest() throws IOException, InterruptedE BackgroundImage backgroundImage = new BackgroundImage .Builder().setImage(xObject).setBackgroundRepeat(new BackgroundRepeat(BackgroundRepeatValue.REPEAT, BackgroundRepeatValue.NO_REPEAT)).build(); - Assert.assertEquals(BackgroundRepeatValue.REPEAT, backgroundImage.getRepeat().getXAxisRepeat()); - Assert.assertEquals(BackgroundRepeatValue.NO_REPEAT, backgroundImage.getRepeat().getYAxisRepeat()); + Assertions.assertEquals(BackgroundRepeatValue.REPEAT, backgroundImage.getRepeat().getXAxisRepeat()); + Assertions.assertEquals(BackgroundRepeatValue.NO_REPEAT, backgroundImage.getRepeat().getYAxisRepeat()); backgroundImageGenericTest("backgroundImageWithoutRepeatY", backgroundImage); } @@ -394,8 +393,8 @@ public void backgroundImageWithoutRepeatXYTest() throws IOException, Interrupted BackgroundImage backgroundImage = new BackgroundImage .Builder().setImage(xObject).setBackgroundRepeat(new BackgroundRepeat(BackgroundRepeatValue.NO_REPEAT)).build(); - Assert.assertEquals(BackgroundRepeatValue.NO_REPEAT, backgroundImage.getRepeat().getXAxisRepeat()); - Assert.assertEquals(BackgroundRepeatValue.NO_REPEAT, backgroundImage.getRepeat().getYAxisRepeat()); + Assertions.assertEquals(BackgroundRepeatValue.NO_REPEAT, backgroundImage.getRepeat().getXAxisRepeat()); + Assertions.assertEquals(BackgroundRepeatValue.NO_REPEAT, backgroundImage.getRepeat().getYAxisRepeat()); backgroundImageGenericTest("backgroundImageWithoutRepeatXY", backgroundImage); } @@ -431,8 +430,8 @@ public void backgroundXObject() throws IOException, InterruptedException { try (PdfDocument pdfDocument = new PdfDocument(new PdfWriter(FileUtil.getFileOutputStream(outFileName)))) { BackgroundImage backgroundImage = new BackgroundImage.Builder().setImage(createFormXObject(pdfDocument, "itis.jpg")).build(); - Assert.assertEquals(BackgroundRepeatValue.REPEAT, backgroundImage.getRepeat().getXAxisRepeat()); - Assert.assertEquals(BackgroundRepeatValue.REPEAT, backgroundImage.getRepeat().getYAxisRepeat()); + Assertions.assertEquals(BackgroundRepeatValue.REPEAT, backgroundImage.getRepeat().getXAxisRepeat()); + Assertions.assertEquals(BackgroundRepeatValue.REPEAT, backgroundImage.getRepeat().getYAxisRepeat()); backgroundXObjectGenericTest(filename, backgroundImage, pdfDocument); } @@ -450,8 +449,8 @@ public void backgroundXObjectWithoutRepeatX() throws IOException, InterruptedExc .setImage(createFormXObject(pdfDocument, "itis.jpg")) .setBackgroundRepeat(new BackgroundRepeat(BackgroundRepeatValue.NO_REPEAT, BackgroundRepeatValue.REPEAT)).build(); - Assert.assertEquals(BackgroundRepeatValue.NO_REPEAT, backgroundImage.getRepeat().getXAxisRepeat()); - Assert.assertEquals(BackgroundRepeatValue.REPEAT, backgroundImage.getRepeat().getYAxisRepeat()); + Assertions.assertEquals(BackgroundRepeatValue.NO_REPEAT, backgroundImage.getRepeat().getXAxisRepeat()); + Assertions.assertEquals(BackgroundRepeatValue.REPEAT, backgroundImage.getRepeat().getYAxisRepeat()); backgroundXObjectGenericTest(filename, backgroundImage, pdfDocument); } @@ -469,8 +468,8 @@ public void backgroundXObjectWithoutRepeatY() throws IOException, InterruptedExc .Builder().setImage(createFormXObject(pdfDocument, "itis.jpg")) .setBackgroundRepeat(new BackgroundRepeat(BackgroundRepeatValue.REPEAT, BackgroundRepeatValue.NO_REPEAT)).build(); - Assert.assertEquals(BackgroundRepeatValue.REPEAT, backgroundImage.getRepeat().getXAxisRepeat()); - Assert.assertEquals(BackgroundRepeatValue.NO_REPEAT, backgroundImage.getRepeat().getYAxisRepeat()); + Assertions.assertEquals(BackgroundRepeatValue.REPEAT, backgroundImage.getRepeat().getXAxisRepeat()); + Assertions.assertEquals(BackgroundRepeatValue.NO_REPEAT, backgroundImage.getRepeat().getYAxisRepeat()); backgroundXObjectGenericTest(filename, backgroundImage, pdfDocument); } @@ -488,8 +487,8 @@ public void backgroundXObjectWithoutRepeatXY() throws IOException, InterruptedEx .Builder().setImage(createFormXObject(pdfDocument, "itis.jpg")) .setBackgroundRepeat(new BackgroundRepeat(BackgroundRepeatValue.NO_REPEAT)).build(); - Assert.assertEquals(BackgroundRepeatValue.NO_REPEAT, backgroundImage.getRepeat().getXAxisRepeat()); - Assert.assertEquals(BackgroundRepeatValue.NO_REPEAT, backgroundImage.getRepeat().getYAxisRepeat()); + Assertions.assertEquals(BackgroundRepeatValue.NO_REPEAT, backgroundImage.getRepeat().getXAxisRepeat()); + Assertions.assertEquals(BackgroundRepeatValue.NO_REPEAT, backgroundImage.getRepeat().getYAxisRepeat()); backgroundXObjectGenericTest(filename, backgroundImage, pdfDocument); } @@ -531,7 +530,7 @@ public void backgroundXObjectAndImageTest() throws IOException, InterruptedExcep pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } } @@ -566,7 +565,7 @@ public void backgroundXFormObjectWithBboxTest() throws IOException, InterruptedE pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } } @@ -695,10 +694,10 @@ private void backgroundImageGenericTest(String filename, Object backgroundImage) private void backgroundImageGenericTest(String filename, Object backgroundImage, Double angle) throws IOException, InterruptedException { if (backgroundImage instanceof BackgroundImage) { - Assert.assertTrue(((BackgroundImage) backgroundImage).isBackgroundSpecified()); + Assertions.assertTrue(((BackgroundImage) backgroundImage).isBackgroundSpecified()); } else { for (BackgroundImage image : (List) backgroundImage) { - Assert.assertTrue((image).isBackgroundSpecified()); + Assertions.assertTrue((image).isBackgroundSpecified()); } } @@ -731,11 +730,11 @@ private void backgroundImageGenericTest(String filename, Object backgroundImage, pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } private void backgroundXObjectGenericTest(String filename, BackgroundImage backgroundImage, PdfDocument pdfDocument) throws IOException, InterruptedException { - Assert.assertTrue(backgroundImage.isBackgroundSpecified()); + Assertions.assertTrue(backgroundImage.isBackgroundSpecified()); String outFileName = DESTINATION_FOLDER + filename + ".pdf"; String cmpFileName = SOURCE_FOLDER + "cmp_" + filename + ".pdf"; @@ -756,7 +755,7 @@ private void backgroundXObjectGenericTest(String filename, BackgroundImage backg pdfDocument.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } } diff --git a/layout/src/test/java/com/itextpdf/layout/properties/BackgroundRepeatUnitTest.java b/layout/src/test/java/com/itextpdf/layout/properties/BackgroundRepeatUnitTest.java index f4f28d6dc7..296b9e434b 100644 --- a/layout/src/test/java/com/itextpdf/layout/properties/BackgroundRepeatUnitTest.java +++ b/layout/src/test/java/com/itextpdf/layout/properties/BackgroundRepeatUnitTest.java @@ -26,50 +26,49 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.geom.Rectangle; import com.itextpdf.layout.properties.BackgroundRepeat.BackgroundRepeatValue; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class BackgroundRepeatUnitTest extends ExtendedITextTest { private static final double EPSILON = 0.000001; @Test public void defaultConstructorTest() { final BackgroundRepeat backgroundRepeat = new BackgroundRepeat(); - Assert.assertEquals(BackgroundRepeatValue.REPEAT, backgroundRepeat.getXAxisRepeat()); - Assert.assertEquals(BackgroundRepeatValue.REPEAT, backgroundRepeat.getYAxisRepeat()); + Assertions.assertEquals(BackgroundRepeatValue.REPEAT, backgroundRepeat.getXAxisRepeat()); + Assertions.assertEquals(BackgroundRepeatValue.REPEAT, backgroundRepeat.getYAxisRepeat()); } @Test public void oneBackgroundRepeatValueConstructorTest() { final BackgroundRepeat backgroundRepeat = new BackgroundRepeat(BackgroundRepeatValue.ROUND); - Assert.assertEquals(BackgroundRepeatValue.ROUND, backgroundRepeat.getXAxisRepeat()); - Assert.assertEquals(BackgroundRepeatValue.ROUND, backgroundRepeat.getYAxisRepeat()); + Assertions.assertEquals(BackgroundRepeatValue.ROUND, backgroundRepeat.getXAxisRepeat()); + Assertions.assertEquals(BackgroundRepeatValue.ROUND, backgroundRepeat.getYAxisRepeat()); } @Test public void twoBackgroundRepeatValueConstructorTest() { final BackgroundRepeat backgroundRepeat = new BackgroundRepeat(BackgroundRepeatValue.SPACE, BackgroundRepeatValue.ROUND); - Assert.assertEquals(BackgroundRepeatValue.SPACE, backgroundRepeat.getXAxisRepeat()); - Assert.assertEquals(BackgroundRepeatValue.ROUND, backgroundRepeat.getYAxisRepeat()); + Assertions.assertEquals(BackgroundRepeatValue.SPACE, backgroundRepeat.getXAxisRepeat()); + Assertions.assertEquals(BackgroundRepeatValue.ROUND, backgroundRepeat.getYAxisRepeat()); } @Test public void isNoRepeatOnAxis() { BackgroundRepeat backgroundRepeat = new BackgroundRepeat(BackgroundRepeatValue.SPACE, BackgroundRepeatValue.REPEAT); - Assert.assertFalse(backgroundRepeat.isNoRepeatOnXAxis()); - Assert.assertFalse(backgroundRepeat.isNoRepeatOnYAxis()); + Assertions.assertFalse(backgroundRepeat.isNoRepeatOnXAxis()); + Assertions.assertFalse(backgroundRepeat.isNoRepeatOnYAxis()); backgroundRepeat = new BackgroundRepeat(BackgroundRepeatValue.NO_REPEAT, BackgroundRepeatValue.ROUND); - Assert.assertTrue(backgroundRepeat.isNoRepeatOnXAxis()); - Assert.assertFalse(backgroundRepeat.isNoRepeatOnYAxis()); + Assertions.assertTrue(backgroundRepeat.isNoRepeatOnXAxis()); + Assertions.assertFalse(backgroundRepeat.isNoRepeatOnYAxis()); backgroundRepeat = new BackgroundRepeat(BackgroundRepeatValue.NO_REPEAT); - Assert.assertTrue(backgroundRepeat.isNoRepeatOnXAxis()); - Assert.assertTrue(backgroundRepeat.isNoRepeatOnYAxis()); + Assertions.assertTrue(backgroundRepeat.isNoRepeatOnXAxis()); + Assertions.assertTrue(backgroundRepeat.isNoRepeatOnYAxis()); } @Test @@ -80,9 +79,9 @@ public void prepareRectangleRepeatNoRepeatTest() { Rectangle availableArea = new Rectangle(0, 0, 160, 123); Point whitespace = repeat.prepareRectangleToDrawingAndGetWhitespace(imageRect, availableArea, new BackgroundSize()); - Assert.assertEquals(0, whitespace.getX(), EPSILON); - Assert.assertEquals(0, whitespace.getY(), EPSILON); - Assert.assertTrue(originalRect.equalsWithEpsilon(imageRect)); + Assertions.assertEquals(0, whitespace.getX(), EPSILON); + Assertions.assertEquals(0, whitespace.getY(), EPSILON); + Assertions.assertTrue(originalRect.equalsWithEpsilon(imageRect)); } @Test @@ -93,9 +92,9 @@ public void prepareRectangleSpaceRepeatTest() { Rectangle availableArea = new Rectangle(0, 0, 160, 123); Point whitespace = repeat.prepareRectangleToDrawingAndGetWhitespace(imageRect, availableArea, new BackgroundSize()); - Assert.assertEquals(5, whitespace.getX(), EPSILON); - Assert.assertEquals(0, whitespace.getY(), EPSILON); - Assert.assertTrue(originalRect.equalsWithEpsilon(imageRect)); + Assertions.assertEquals(5, whitespace.getX(), EPSILON); + Assertions.assertEquals(0, whitespace.getY(), EPSILON); + Assertions.assertTrue(originalRect.equalsWithEpsilon(imageRect)); } @Test @@ -106,9 +105,9 @@ public void prepareRectangleNoRepeatSpaceTest() { Rectangle availableArea = new Rectangle(0, 0, 160, 123); Point whitespace = repeat.prepareRectangleToDrawingAndGetWhitespace(imageRect, availableArea, new BackgroundSize()); - Assert.assertEquals(0, whitespace.getX(), EPSILON); - Assert.assertEquals(3, whitespace.getY(), EPSILON); - Assert.assertTrue(originalRect.equalsWithEpsilon(imageRect)); + Assertions.assertEquals(0, whitespace.getX(), EPSILON); + Assertions.assertEquals(3, whitespace.getY(), EPSILON); + Assertions.assertTrue(originalRect.equalsWithEpsilon(imageRect)); } @Test @@ -119,9 +118,9 @@ public void prepareRectangleSpaceSpaceTest() { Rectangle availableArea = new Rectangle(0, 0, 160, 123); Point whitespace = repeat.prepareRectangleToDrawingAndGetWhitespace(imageRect, availableArea, new BackgroundSize()); - Assert.assertEquals(5, whitespace.getX(), EPSILON); - Assert.assertEquals(3, whitespace.getY(), EPSILON); - Assert.assertTrue(originalRect.equalsWithEpsilon(imageRect)); + Assertions.assertEquals(5, whitespace.getX(), EPSILON); + Assertions.assertEquals(3, whitespace.getY(), EPSILON); + Assertions.assertTrue(originalRect.equalsWithEpsilon(imageRect)); } @Test @@ -132,9 +131,9 @@ public void prepareRectangleSpaceSpaceNoAvailableSpaceTest() { Rectangle availableArea = new Rectangle(0, 0, 45, 55); Point whitespace = repeat.prepareRectangleToDrawingAndGetWhitespace(imageRect, availableArea, new BackgroundSize()); - Assert.assertEquals(0, whitespace.getX(), EPSILON); - Assert.assertEquals(0, whitespace.getY(), EPSILON); - Assert.assertTrue(originalRect.equalsWithEpsilon(imageRect)); + Assertions.assertEquals(0, whitespace.getX(), EPSILON); + Assertions.assertEquals(0, whitespace.getY(), EPSILON); + Assertions.assertTrue(originalRect.equalsWithEpsilon(imageRect)); } @Test @@ -144,12 +143,12 @@ public void prepareRectangleRoundNoRepeatLessAndMoreHalfImageSizeTest() { Rectangle availableArea = new Rectangle(0, 0, 120, 180); Point whitespace = repeat.prepareRectangleToDrawingAndGetWhitespace(imageRect, availableArea, new BackgroundSize()); - Assert.assertEquals(0, whitespace.getX(), EPSILON); - Assert.assertEquals(0, whitespace.getY(), EPSILON); - Assert.assertEquals(0, imageRect.getX(), EPSILON); - Assert.assertEquals(-14, imageRect.getY(), EPSILON); - Assert.assertEquals(60, imageRect.getWidth(), EPSILON); - Assert.assertEquals(84, imageRect.getHeight(), EPSILON); + Assertions.assertEquals(0, whitespace.getX(), EPSILON); + Assertions.assertEquals(0, whitespace.getY(), EPSILON); + Assertions.assertEquals(0, imageRect.getX(), EPSILON); + Assertions.assertEquals(-14, imageRect.getY(), EPSILON); + Assertions.assertEquals(60, imageRect.getWidth(), EPSILON); + Assertions.assertEquals(84, imageRect.getHeight(), EPSILON); } @Test @@ -159,12 +158,12 @@ public void prepareRectangleRepeatRoundLessHalfImageSizeTest() { Rectangle availableArea = new Rectangle(0, 0, 120, 180); Point whitespace = repeat.prepareRectangleToDrawingAndGetWhitespace(imageRect, availableArea, new BackgroundSize()); - Assert.assertEquals(0, whitespace.getX(), EPSILON); - Assert.assertEquals(0, whitespace.getY(), EPSILON); - Assert.assertEquals(0, imageRect.getX(), EPSILON); - Assert.assertEquals(-15, imageRect.getY(), EPSILON); - Assert.assertEquals(60, imageRect.getWidth(), EPSILON); - Assert.assertEquals(90, imageRect.getHeight(), EPSILON); + Assertions.assertEquals(0, whitespace.getX(), EPSILON); + Assertions.assertEquals(0, whitespace.getY(), EPSILON); + Assertions.assertEquals(0, imageRect.getX(), EPSILON); + Assertions.assertEquals(-15, imageRect.getY(), EPSILON); + Assertions.assertEquals(60, imageRect.getWidth(), EPSILON); + Assertions.assertEquals(90, imageRect.getHeight(), EPSILON); } @Test @@ -174,12 +173,12 @@ public void prepareRectangleRoundRoundLessAndMoreHalfImageSizeTest() { Rectangle availableArea = new Rectangle(0, 0, 120, 180); Point whitespace = repeat.prepareRectangleToDrawingAndGetWhitespace(imageRect, availableArea, new BackgroundSize()); - Assert.assertEquals(0, whitespace.getX(), EPSILON); - Assert.assertEquals(0, whitespace.getY(), EPSILON); - Assert.assertEquals(0, imageRect.getX(), EPSILON); - Assert.assertEquals(10, imageRect.getY(), EPSILON); - Assert.assertEquals(60, imageRect.getWidth(), EPSILON); - Assert.assertEquals(60, imageRect.getHeight(), EPSILON); + Assertions.assertEquals(0, whitespace.getX(), EPSILON); + Assertions.assertEquals(0, whitespace.getY(), EPSILON); + Assertions.assertEquals(0, imageRect.getX(), EPSILON); + Assertions.assertEquals(10, imageRect.getY(), EPSILON); + Assertions.assertEquals(60, imageRect.getWidth(), EPSILON); + Assertions.assertEquals(60, imageRect.getHeight(), EPSILON); } @Test @@ -189,12 +188,12 @@ public void prepareRectangleRoundRoundMoreAndLessHalfImageSizeTest() { Rectangle availableArea = new Rectangle(0, 0, 144, 160); Point whitespace = repeat.prepareRectangleToDrawingAndGetWhitespace(imageRect, availableArea, new BackgroundSize()); - Assert.assertEquals(0, whitespace.getX(), EPSILON); - Assert.assertEquals(0, whitespace.getY(), EPSILON); - Assert.assertEquals(0, imageRect.getX(), EPSILON); - Assert.assertEquals(-10, imageRect.getY(), EPSILON); - Assert.assertEquals(48, imageRect.getWidth(), EPSILON); - Assert.assertEquals(80, imageRect.getHeight(), EPSILON); + Assertions.assertEquals(0, whitespace.getX(), EPSILON); + Assertions.assertEquals(0, whitespace.getY(), EPSILON); + Assertions.assertEquals(0, imageRect.getX(), EPSILON); + Assertions.assertEquals(-10, imageRect.getY(), EPSILON); + Assertions.assertEquals(48, imageRect.getWidth(), EPSILON); + Assertions.assertEquals(80, imageRect.getHeight(), EPSILON); } @Test @@ -204,12 +203,12 @@ public void prepareRectangleRoundRoundMoreHalfImageSizeTest() { Rectangle availableArea = new Rectangle(0, 0, 144, 180); Point whitespace = repeat.prepareRectangleToDrawingAndGetWhitespace(imageRect, availableArea, new BackgroundSize()); - Assert.assertEquals(0, whitespace.getX(), EPSILON); - Assert.assertEquals(0, whitespace.getY(), EPSILON); - Assert.assertEquals(0, imageRect.getX(), EPSILON); - Assert.assertEquals(10, imageRect.getY(), EPSILON); - Assert.assertEquals(48, imageRect.getWidth(), EPSILON); - Assert.assertEquals(60, imageRect.getHeight(), EPSILON); + Assertions.assertEquals(0, whitespace.getX(), EPSILON); + Assertions.assertEquals(0, whitespace.getY(), EPSILON); + Assertions.assertEquals(0, imageRect.getX(), EPSILON); + Assertions.assertEquals(10, imageRect.getY(), EPSILON); + Assertions.assertEquals(48, imageRect.getWidth(), EPSILON); + Assertions.assertEquals(60, imageRect.getHeight(), EPSILON); } @Test @@ -219,12 +218,12 @@ public void prepareRectangleRoundRoundLessHalfImageSizeTest() { Rectangle availableArea = new Rectangle(0, 0, 120, 160); Point whitespace = repeat.prepareRectangleToDrawingAndGetWhitespace(imageRect, availableArea, new BackgroundSize()); - Assert.assertEquals(0, whitespace.getX(), EPSILON); - Assert.assertEquals(0, whitespace.getY(), EPSILON); - Assert.assertEquals(0, imageRect.getX(), EPSILON); - Assert.assertEquals(-10, imageRect.getY(), EPSILON); - Assert.assertEquals(60, imageRect.getWidth(), EPSILON); - Assert.assertEquals(80, imageRect.getHeight(), EPSILON); + Assertions.assertEquals(0, whitespace.getX(), EPSILON); + Assertions.assertEquals(0, whitespace.getY(), EPSILON); + Assertions.assertEquals(0, imageRect.getX(), EPSILON); + Assertions.assertEquals(-10, imageRect.getY(), EPSILON); + Assertions.assertEquals(60, imageRect.getWidth(), EPSILON); + Assertions.assertEquals(80, imageRect.getHeight(), EPSILON); } @Test @@ -234,12 +233,12 @@ public void prepareRectangleSpaceRoundMoreHalfImageSizeTest() { Rectangle availableArea = new Rectangle(0, 0, 130, 180); Point whitespace = repeat.prepareRectangleToDrawingAndGetWhitespace(imageRect, availableArea, new BackgroundSize()); - Assert.assertEquals(10, whitespace.getX(), EPSILON); - Assert.assertEquals(0, whitespace.getY(), EPSILON); - Assert.assertEquals(0, imageRect.getX(), EPSILON); - Assert.assertEquals(-15, imageRect.getY(), EPSILON); - Assert.assertEquals(60, imageRect.getWidth(), EPSILON); - Assert.assertEquals(90, imageRect.getHeight(), EPSILON); + Assertions.assertEquals(10, whitespace.getX(), EPSILON); + Assertions.assertEquals(0, whitespace.getY(), EPSILON); + Assertions.assertEquals(0, imageRect.getX(), EPSILON); + Assertions.assertEquals(-15, imageRect.getY(), EPSILON); + Assertions.assertEquals(60, imageRect.getWidth(), EPSILON); + Assertions.assertEquals(90, imageRect.getHeight(), EPSILON); } @Test @@ -249,11 +248,11 @@ public void prepareRectangleRoundSpaceLessHalfImageSizeTest() { Rectangle availableArea = new Rectangle(0, 0, 120, 369); Point whitespace = repeat.prepareRectangleToDrawingAndGetWhitespace(imageRect, availableArea, new BackgroundSize()); - Assert.assertEquals(0, whitespace.getX(), EPSILON); - Assert.assertEquals(3, whitespace.getY(), EPSILON); - Assert.assertEquals(0, imageRect.getX(), EPSILON); - Assert.assertEquals(279, imageRect.getY(), EPSILON); - Assert.assertEquals(60, imageRect.getWidth(), EPSILON); - Assert.assertEquals(90, imageRect.getHeight(), EPSILON); + Assertions.assertEquals(0, whitespace.getX(), EPSILON); + Assertions.assertEquals(3, whitespace.getY(), EPSILON); + Assertions.assertEquals(0, imageRect.getX(), EPSILON); + Assertions.assertEquals(279, imageRect.getY(), EPSILON); + Assertions.assertEquals(60, imageRect.getWidth(), EPSILON); + Assertions.assertEquals(90, imageRect.getHeight(), EPSILON); } } diff --git a/layout/src/test/java/com/itextpdf/layout/properties/BackgroundSizeTest.java b/layout/src/test/java/com/itextpdf/layout/properties/BackgroundSizeTest.java index d9a14aedde..0d973fdfa8 100644 --- a/layout/src/test/java/com/itextpdf/layout/properties/BackgroundSizeTest.java +++ b/layout/src/test/java/com/itextpdf/layout/properties/BackgroundSizeTest.java @@ -23,23 +23,22 @@ This file is part of the iText (R) project. package com.itextpdf.layout.properties; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class BackgroundSizeTest extends ExtendedITextTest { @Test public void constructorTest() { final BackgroundSize size = new BackgroundSize(); - Assert.assertFalse(size.isContain()); - Assert.assertFalse(size.isCover()); - Assert.assertNull(size.getBackgroundWidthSize()); - Assert.assertNull(size.getBackgroundHeightSize()); + Assertions.assertFalse(size.isContain()); + Assertions.assertFalse(size.isCover()); + Assertions.assertNull(size.getBackgroundWidthSize()); + Assertions.assertNull(size.getBackgroundHeightSize()); } @Test @@ -49,10 +48,10 @@ public void clearAndSetToCoverTest() { size.setBackgroundSizeToValues(UnitValue.createPointValue(10), UnitValue.createPointValue(10)); size.setBackgroundSizeToCover(); - Assert.assertFalse(size.isContain()); - Assert.assertTrue(size.isCover()); - Assert.assertNull(size.getBackgroundWidthSize()); - Assert.assertNull(size.getBackgroundHeightSize()); + Assertions.assertFalse(size.isContain()); + Assertions.assertTrue(size.isCover()); + Assertions.assertNull(size.getBackgroundWidthSize()); + Assertions.assertNull(size.getBackgroundHeightSize()); } @Test @@ -62,9 +61,9 @@ public void clearAndSetToContainTest() { size.setBackgroundSizeToValues(UnitValue.createPointValue(10), UnitValue.createPointValue(10)); size.setBackgroundSizeToContain(); - Assert.assertTrue(size.isContain()); - Assert.assertFalse(size.isCover()); - Assert.assertNull(size.getBackgroundWidthSize()); - Assert.assertNull(size.getBackgroundHeightSize()); + Assertions.assertTrue(size.isContain()); + Assertions.assertFalse(size.isCover()); + Assertions.assertNull(size.getBackgroundWidthSize()); + Assertions.assertNull(size.getBackgroundHeightSize()); } } diff --git a/layout/src/test/java/com/itextpdf/layout/properties/BackgroundUnitTest.java b/layout/src/test/java/com/itextpdf/layout/properties/BackgroundUnitTest.java index 9ecc101bae..b26b6080e5 100644 --- a/layout/src/test/java/com/itextpdf/layout/properties/BackgroundUnitTest.java +++ b/layout/src/test/java/com/itextpdf/layout/properties/BackgroundUnitTest.java @@ -24,13 +24,12 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.colors.DeviceRgb; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class BackgroundUnitTest extends ExtendedITextTest { final static float EPS = 0.00001f; @@ -41,8 +40,8 @@ public void backgroundConstructorWithClipTest() { final float opacity = 10f; final BackgroundBox backgroundClip = BackgroundBox.BORDER_BOX; final Background background = new Background(deviceRgbColor, opacity, backgroundClip); - Assert.assertEquals(deviceRgbColor, background.getColor()); - Assert.assertEquals(opacity, background.getOpacity(), EPS); - Assert.assertEquals(backgroundClip, background.getBackgroundClip()); + Assertions.assertEquals(deviceRgbColor, background.getColor()); + Assertions.assertEquals(opacity, background.getOpacity(), EPS); + Assertions.assertEquals(backgroundClip, background.getBackgroundClip()); } } diff --git a/layout/src/test/java/com/itextpdf/layout/properties/ContinuousContainerTest.java b/layout/src/test/java/com/itextpdf/layout/properties/ContinuousContainerTest.java index 21f9c1b092..98711bf60b 100644 --- a/layout/src/test/java/com/itextpdf/layout/properties/ContinuousContainerTest.java +++ b/layout/src/test/java/com/itextpdf/layout/properties/ContinuousContainerTest.java @@ -39,16 +39,15 @@ This file is part of the iText (R) project. import com.itextpdf.layout.element.Paragraph; import com.itextpdf.layout.element.Table; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; import java.util.function.Consumer; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class ContinuousContainerTest extends ExtendedITextTest { @@ -60,7 +59,7 @@ public class ContinuousContainerTest extends ExtendedITextTest { private static final Color DEFAULT_BACKGROUND_COLOR = ColorConstants.CYAN; private static final Border DEFAULT_BORDER = new SolidBorder(ColorConstants.RED, 5F); - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(DESTINATION_FOLDER); } @@ -420,7 +419,7 @@ private void executeTest(String testName, T container, doc.add(new Paragraph("ELEMENT BELOW").setBackgroundColor(ColorConstants.YELLOW)); } CompareTool compareTool = new CompareTool(); - Assert.assertNull(compareTool.compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(compareTool.compareByContent(filename, cmpName, DESTINATION_FOLDER, "diff_")); } } diff --git a/layout/src/test/java/com/itextpdf/layout/properties/GridValueTest.java b/layout/src/test/java/com/itextpdf/layout/properties/GridValueTest.java index 4f885fd105..68e64f6bf9 100644 --- a/layout/src/test/java/com/itextpdf/layout/properties/GridValueTest.java +++ b/layout/src/test/java/com/itextpdf/layout/properties/GridValueTest.java @@ -33,61 +33,60 @@ This file is part of the iText (R) project. import com.itextpdf.layout.properties.grid.PercentValue; import com.itextpdf.layout.properties.grid.PointValue; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class GridValueTest extends ExtendedITextTest { @Test public void unitValueTest() { LengthValue value = new PointValue(3.2f); - Assert.assertEquals(value.getType(), GridValue.ValueType.POINT); - Assert.assertEquals(3.2f, (float) value.getValue(), 0.00001); + Assertions.assertEquals(value.getType(), GridValue.ValueType.POINT); + Assertions.assertEquals(3.2f, (float) value.getValue(), 0.00001); value = new PercentValue(30f); - Assert.assertEquals(value.getType(), GridValue.ValueType.PERCENT); - Assert.assertEquals(30, (float) value.getValue(), 0.00001); + Assertions.assertEquals(value.getType(), GridValue.ValueType.PERCENT); + Assertions.assertEquals(30, (float) value.getValue(), 0.00001); } @Test public void minMaxContentTest() { GridValue value = MinContentValue.VALUE; - Assert.assertEquals(value.getType(), GridValue.ValueType.MIN_CONTENT); + Assertions.assertEquals(value.getType(), GridValue.ValueType.MIN_CONTENT); value = MaxContentValue.VALUE; - Assert.assertEquals(value.getType(), GridValue.ValueType.MAX_CONTENT); + Assertions.assertEquals(value.getType(), GridValue.ValueType.MAX_CONTENT); } @Test public void autoTest() { GridValue value = AutoValue.VALUE; - Assert.assertEquals(value.getType(), GridValue.ValueType.AUTO); + Assertions.assertEquals(value.getType(), GridValue.ValueType.AUTO); } @Test public void flexValueTest() { FlexValue value = new FlexValue(1.5f); - Assert.assertEquals(value.getType(), GridValue.ValueType.FLEX); - Assert.assertEquals(1.5f, (float) value.getFlex(), 0.00001); + Assertions.assertEquals(value.getType(), GridValue.ValueType.FLEX); + Assertions.assertEquals(1.5f, (float) value.getFlex(), 0.00001); } @Test public void fitContentTest() { FitContentValue value = new FitContentValue(new PointValue(50.0f)); - Assert.assertEquals(value.getType(), GridValue.ValueType.FIT_CONTENT); - Assert.assertEquals(new PointValue(50.0f).getValue(), value.getLength().getValue(), 0.00001); + Assertions.assertEquals(value.getType(), GridValue.ValueType.FIT_CONTENT); + Assertions.assertEquals(new PointValue(50.0f).getValue(), value.getLength().getValue(), 0.00001); value = new FitContentValue(UnitValue.createPercentValue(20.0f)); - Assert.assertEquals(new PercentValue(20.0f).getValue(), value.getLength().getValue(), 0.00001); + Assertions.assertEquals(new PercentValue(20.0f).getValue(), value.getLength().getValue(), 0.00001); } @Test public void minMaxTest() { MinMaxValue value = new MinMaxValue(new PointValue(50.0f), new FlexValue(2.0f)); - Assert.assertEquals(value.getType(), GridValue.ValueType.MINMAX); - Assert.assertEquals(new PointValue(50.0f).getValue(), ((PointValue)value.getMin()).getValue(), 0.00001); - Assert.assertEquals(new FlexValue(2.0f).getFlex(), ((FlexValue)value.getMax()).getFlex(), 0.00001); + Assertions.assertEquals(value.getType(), GridValue.ValueType.MINMAX); + Assertions.assertEquals(new PointValue(50.0f).getValue(), ((PointValue)value.getMin()).getValue(), 0.00001); + Assertions.assertEquals(new FlexValue(2.0f).getFlex(), ((FlexValue)value.getMax()).getFlex(), 0.00001); } } diff --git a/layout/src/test/java/com/itextpdf/layout/properties/PropertyTest.java b/layout/src/test/java/com/itextpdf/layout/properties/PropertyTest.java index 07f79d6e80..9970236017 100644 --- a/layout/src/test/java/com/itextpdf/layout/properties/PropertyTest.java +++ b/layout/src/test/java/com/itextpdf/layout/properties/PropertyTest.java @@ -23,18 +23,17 @@ This file is part of the iText (R) project. package com.itextpdf.layout.properties; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.lang.reflect.Field; import com.itextpdf.commons.utils.MessageFormatUtil; import java.util.HashSet; import java.util.Set; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PropertyTest extends ExtendedITextTest { @Test @@ -46,7 +45,7 @@ public void propertyUniquenessTest() throws IllegalAccessException { int value = (int) field.get(null); maxFieldValue = Math.max(maxFieldValue, value); if (fieldValues.contains(value)) { - Assert.fail(MessageFormatUtil.format("Multiple fields with same value: {0}", value)); + Assertions.fail(MessageFormatUtil.format("Multiple fields with same value: {0}", value)); } fieldValues.add(value); } @@ -54,7 +53,7 @@ public void propertyUniquenessTest() throws IllegalAccessException { for (int i = 1; i <= maxFieldValue; i++) { if (!fieldValues.contains(i)) { - Assert.fail(MessageFormatUtil.format("Missing value: {0}", i)); + Assertions.fail(MessageFormatUtil.format("Missing value: {0}", i)); } } diff --git a/layout/src/test/java/com/itextpdf/layout/properties/TransformTest.java b/layout/src/test/java/com/itextpdf/layout/properties/TransformTest.java index 56802bb5d8..81a0b804aa 100644 --- a/layout/src/test/java/com/itextpdf/layout/properties/TransformTest.java +++ b/layout/src/test/java/com/itextpdf/layout/properties/TransformTest.java @@ -25,12 +25,11 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.geom.AffineTransform; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class TransformTest extends ExtendedITextTest { // AffineTransform.TYPE_UNKNOWN private static final float type = -1; @@ -39,33 +38,33 @@ public class TransformTest extends ExtendedITextTest { public void createDefaultSingleTransformTest() { Transform.SingleTransform defaultSingleTransform = new Transform.SingleTransform(); UnitValue[] defaultUnitValues = defaultSingleTransform.getUnitValues(); - Assert.assertArrayEquals(new float[] {1f, 0f, 0f, 1f}, defaultSingleTransform.getFloats(), 0); - Assert.assertEquals(2, defaultUnitValues.length); - Assert.assertEquals(UnitValue.createPointValue(0), defaultUnitValues[0]); - Assert.assertEquals(UnitValue.createPointValue(0), defaultUnitValues[1]); + Assertions.assertArrayEquals(new float[] {1f, 0f, 0f, 1f}, defaultSingleTransform.getFloats(), 0); + Assertions.assertEquals(2, defaultUnitValues.length); + Assertions.assertEquals(UnitValue.createPointValue(0), defaultUnitValues[0]); + Assertions.assertEquals(UnitValue.createPointValue(0), defaultUnitValues[1]); } @Test public void getAffineTransformPercentPointUnitValuesTest() { - Assert.assertEquals(new AffineTransform(new float[] {-2f, 3f, -4f, -5f, 12f, 30f, type}), + Assertions.assertEquals(new AffineTransform(new float[] {-2f, 3f, -4f, -5f, 12f, 30f, type}), getAffineTransform(UnitValue.PERCENT, UnitValue.POINT)); } @Test public void getAffineTransformPointPercentUnitValuesTest() { - Assert.assertEquals(new AffineTransform(new float[] {-2f, 3f, -4f, -5f, 20f, 24f, type}), + Assertions.assertEquals(new AffineTransform(new float[] {-2f, 3f, -4f, -5f, 20f, 24f, type}), getAffineTransform(UnitValue.POINT, UnitValue.PERCENT)); } @Test public void getAffineTransformPercentPercentUnitValuesTest() { - Assert.assertEquals(new AffineTransform(new float[] {-2f, 3f, -4f, -5f, 12f, 24f, type}), + Assertions.assertEquals(new AffineTransform(new float[] {-2f, 3f, -4f, -5f, 12f, 24f, type}), getAffineTransform(UnitValue.PERCENT, UnitValue.PERCENT)); } @Test public void getAffineTransformPointPointUnitValuesTest() { - Assert.assertEquals(new AffineTransform(new float[] {-2f, 3f, -4f, -5f, 20f, 30f, type}), + Assertions.assertEquals(new AffineTransform(new float[] {-2f, 3f, -4f, -5f, 20f, 30f, type}), getAffineTransform(UnitValue.POINT, UnitValue.POINT)); } @@ -83,7 +82,7 @@ public void getAffineTransformDiffSingleTransformTest() { UnitValue.createPercentValue(tyUnitValue2))); transform.addSingleTransform(createSingleTransform(UnitValue.createPointValue(txUnitValue), UnitValue.createPointValue(tyUnitValue2))); - Assert.assertEquals(new AffineTransform(new float[] {-524f, -105f, 140f, -419f, -788f, 2220f, type}), + Assertions.assertEquals(new AffineTransform(new float[] {-524f, -105f, 140f, -419f, -788f, 2220f, type}), Transform.getAffineTransform(transform, 60f, 80f)); } @@ -96,7 +95,7 @@ public void getAffineTransformOneSingleTransformFewTimesTest() { transform.addSingleTransform(singleTransform); transform.addSingleTransform(singleTransform); transform.addSingleTransform(singleTransform); - Assert.assertEquals(new AffineTransform(new float[] {-524f, -105f, 140f, -419f, -700f, 2100f, type}), + Assertions.assertEquals(new AffineTransform(new float[] {-524f, -105f, 140f, -419f, -700f, 2100f, type}), Transform.getAffineTransform(transform, 60f, 60f)); } @@ -105,13 +104,13 @@ public void getAffineTransformDifferentWidthHeightTest() { Transform transform = new Transform(1); transform.addSingleTransform(createSingleTransform(UnitValue.createPercentValue(20f), UnitValue.createPercentValue(30f))); - Assert.assertEquals(new AffineTransform(new float[] {-2f, 3f, -4f, -5f, -10f, -6f, type}), + Assertions.assertEquals(new AffineTransform(new float[] {-2f, 3f, -4f, -5f, -10f, -6f, type}), Transform.getAffineTransform(transform, -50f, -20f)); - Assert.assertEquals(new AffineTransform(new float[] {-2f, 3f, -4f, -5f, 10f, -6f, type}), + Assertions.assertEquals(new AffineTransform(new float[] {-2f, 3f, -4f, -5f, 10f, -6f, type}), Transform.getAffineTransform(transform, 50f, -20f)); - Assert.assertEquals(new AffineTransform(new float[] {-2f, 3f, -4f, -5f, -10f, 6f, type}), + Assertions.assertEquals(new AffineTransform(new float[] {-2f, 3f, -4f, -5f, -10f, 6f, type}), Transform.getAffineTransform(transform, -50f, 20f)); - Assert.assertEquals(new AffineTransform(new float[] {-2f, 3f, -4f, -5f, 10f, 6f, type}), + Assertions.assertEquals(new AffineTransform(new float[] {-2f, 3f, -4f, -5f, 10f, 6f, type}), Transform.getAffineTransform(transform, 50f, 20f)); } diff --git a/layout/src/test/java/com/itextpdf/layout/renderer/AbstractRendererUnitTest.java b/layout/src/test/java/com/itextpdf/layout/renderer/AbstractRendererUnitTest.java index dc1ad4f7e5..1ddb11c64b 100644 --- a/layout/src/test/java/com/itextpdf/layout/renderer/AbstractRendererUnitTest.java +++ b/layout/src/test/java/com/itextpdf/layout/renderer/AbstractRendererUnitTest.java @@ -59,16 +59,15 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.UnitTest; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class AbstractRendererUnitTest extends ExtendedITextTest { @Test @@ -80,14 +79,14 @@ public void createXObjectTest() { PdfDocument pdfDocument = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); PdfXObject pdfXObject = AbstractRenderer.createXObject(gradientBuilder, new Rectangle(0, 0, 20, 20), pdfDocument); - Assert.assertNotNull(pdfXObject.getPdfObject().get(PdfName.Resources)); + Assertions.assertNotNull(pdfXObject.getPdfObject().get(PdfName.Resources)); } @Test public void createXObjectWithNullLinearGradientTest() { PdfDocument pdfDocument = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); PdfXObject pdfXObject = AbstractRenderer.createXObject(null, new Rectangle(0, 0, 20, 20), pdfDocument); - Assert.assertNull(pdfXObject.getPdfObject().get(PdfName.Resources)); + Assertions.assertNull(pdfXObject.getPdfObject().get(PdfName.Resources)); } @Test @@ -96,7 +95,7 @@ public void createXObjectWithInvalidColorTest() { PdfDocument pdfDocument = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); PdfXObject pdfXObject = AbstractRenderer.createXObject(gradientBuilder, new Rectangle(0, 0, 20, 20), pdfDocument); - Assert.assertNull(pdfXObject.getPdfObject().get(PdfName.Resources)); + Assertions.assertNull(pdfXObject.getPdfObject().get(PdfName.Resources)); } @Test @@ -121,8 +120,8 @@ public PdfCanvas addXObjectFittedIntoRectangle(PdfXObject xObject, Rectangle rec return null; } object = xObject; - Assert.assertTrue(xObject instanceof PdfImageXObject); - Assert.assertEquals(Arrays.toString(((PdfImageXObject) xObject).getImageBytes(false)), + Assertions.assertTrue(xObject instanceof PdfImageXObject); + Assertions.assertEquals(Arrays.toString(((PdfImageXObject) xObject).getImageBytes(false)), Arrays.toString(bytes)); return null; } @@ -142,7 +141,7 @@ public float getHeight() { }).build()); renderer.setProperty(Property.BACKGROUND_IMAGE, images); renderer.drawBackground(context); - Assert.assertEquals(50, counter[0]); + Assertions.assertEquals(50, counter[0]); } @Test @@ -167,8 +166,8 @@ public PdfCanvas addXObjectFittedIntoRectangle(PdfXObject xObject, Rectangle rec return null; } object = xObject; - Assert.assertTrue(xObject instanceof PdfImageXObject); - Assert.assertEquals(Arrays.toString(((PdfImageXObject) xObject).getImageBytes(false)), + Assertions.assertTrue(xObject instanceof PdfImageXObject); + Assertions.assertEquals(Arrays.toString(((PdfImageXObject) xObject).getImageBytes(false)), Arrays.toString(bytes)); return null; } @@ -189,7 +188,7 @@ public float getHeight() { .build()); renderer.setProperty(Property.BACKGROUND_IMAGE, images); renderer.drawBackground(context); - Assert.assertEquals(5, counter[0]); + Assertions.assertEquals(5, counter[0]); } @Test @@ -214,8 +213,8 @@ public PdfCanvas addXObjectFittedIntoRectangle(PdfXObject xObject, Rectangle rec return null; } object = xObject; - Assert.assertTrue(xObject instanceof PdfImageXObject); - Assert.assertEquals(Arrays.toString(((PdfImageXObject) xObject).getImageBytes(false)), + Assertions.assertTrue(xObject instanceof PdfImageXObject); + Assertions.assertEquals(Arrays.toString(((PdfImageXObject) xObject).getImageBytes(false)), Arrays.toString(bytes)); return null; } @@ -236,7 +235,7 @@ public float getHeight() { .build()); renderer.setProperty(Property.BACKGROUND_IMAGE, images); renderer.drawBackground(context); - Assert.assertEquals(10, counter[0]); + Assertions.assertEquals(10, counter[0]); } @Test @@ -261,8 +260,8 @@ public PdfCanvas addXObjectFittedIntoRectangle(PdfXObject xObject, Rectangle rec return null; } object = xObject; - Assert.assertTrue(xObject instanceof PdfImageXObject); - Assert.assertEquals(Arrays.toString(((PdfImageXObject) xObject).getImageBytes(false)), + Assertions.assertTrue(xObject instanceof PdfImageXObject); + Assertions.assertEquals(Arrays.toString(((PdfImageXObject) xObject).getImageBytes(false)), Arrays.toString(bytes)); return null; } @@ -284,7 +283,7 @@ public float getHeight() { .build()); renderer.setProperty(Property.BACKGROUND_IMAGE, images); renderer.drawBackground(context); - Assert.assertEquals(1, counter[0]); + Assertions.assertEquals(1, counter[0]); } @Test @@ -307,11 +306,11 @@ public PdfCanvas addXObjectFittedIntoRectangle(PdfXObject xObject, Rectangle rec return null; } object = xObject; - Assert.assertTrue(xObject instanceof PdfImageXObject); - Assert.assertEquals(Arrays.toString(((PdfImageXObject) xObject).getImageBytes(false)), + Assertions.assertTrue(xObject instanceof PdfImageXObject); + Assertions.assertEquals(Arrays.toString(((PdfImageXObject) xObject).getImageBytes(false)), Arrays.toString(bytes)); - Assert.assertEquals(27, (int) rect.getX()); - Assert.assertEquals(40, (int) rect.getY()); + Assertions.assertEquals(27, (int) rect.getX()); + Assertions.assertEquals(40, (int) rect.getY()); return null; } }); @@ -352,9 +351,9 @@ public PdfCanvas addXObjectFittedIntoRectangle(PdfXObject xObject, Rectangle rec return null; } object = xObject; - Assert.assertTrue(xObject instanceof PdfFormXObject); - Assert.assertEquals(-30, (int) rect.getX()); - Assert.assertEquals(100, (int) rect.getY()); + Assertions.assertTrue(xObject instanceof PdfFormXObject); + Assertions.assertEquals(-30, (int) rect.getX()); + Assertions.assertEquals(100, (int) rect.getY()); return null; } }); @@ -389,9 +388,9 @@ public PdfCanvas addXObjectFittedIntoRectangle(PdfXObject xObject, Rectangle rec return null; } object = xObject; - Assert.assertTrue(xObject instanceof PdfFormXObject); - Assert.assertEquals(0, (int) rect.getX()); - Assert.assertEquals(0, (int) rect.getY()); + Assertions.assertTrue(xObject instanceof PdfFormXObject); + Assertions.assertEquals(0, (int) rect.getX()); + Assertions.assertEquals(0, (int) rect.getY()); return null; } }); @@ -430,8 +429,8 @@ public PdfCanvas addXObjectFittedIntoRectangle(PdfXObject xObject, Rectangle rec return null; } object = xObject; - Assert.assertTrue(xObject instanceof PdfImageXObject); - Assert.assertEquals(Arrays.toString(((PdfImageXObject) xObject).getImageBytes(false)), + Assertions.assertTrue(xObject instanceof PdfImageXObject); + Assertions.assertEquals(Arrays.toString(((PdfImageXObject) xObject).getImageBytes(false)), Arrays.toString(listBytes.get(counter[0]++))); return null; } @@ -460,7 +459,7 @@ public float getHeight() { } }).build())); renderer.drawBackground(context); - Assert.assertEquals(listBytes.size(), counter[0]); + Assertions.assertEquals(listBytes.size(), counter[0]); } @Test @@ -491,11 +490,11 @@ public PdfCanvas addXObjectFittedIntoRectangle(PdfXObject xObject, Rectangle rec return null; } object = xObject; - Assert.assertTrue(xObject instanceof PdfImageXObject); - Assert.assertEquals(Arrays.toString(((PdfImageXObject) xObject).getImageBytes(false)), + Assertions.assertTrue(xObject instanceof PdfImageXObject); + Assertions.assertEquals(Arrays.toString(((PdfImageXObject) xObject).getImageBytes(false)), Arrays.toString(listBytes.get(counter[0]))); - Assert.assertEquals((int) listRectangles.get(counter[0]).getX(), (int) rect.getX()); - Assert.assertEquals((int) listRectangles.get(counter[0]++).getY(), (int) rect.getY()); + Assertions.assertEquals((int) listRectangles.get(counter[0]).getX(), (int) rect.getX()); + Assertions.assertEquals((int) listRectangles.get(counter[0]++).getY(), (int) rect.getY()); return null; } }); @@ -524,7 +523,7 @@ public float getHeight() { }).setBackgroundPosition(new BackgroundPosition().setPositionX(BackgroundPosition.PositionX.RIGHT) .setPositionY(BackgroundPosition.PositionY.CENTER).setXShift(new UnitValue(UnitValue.PERCENT, 10))).build())); renderer.drawBackground(context); - Assert.assertEquals(listBytes.size(), counter[0]); + Assertions.assertEquals(listBytes.size(), counter[0]); } @Test @@ -533,10 +532,10 @@ public void backgroundColorClipTest() { final PdfCanvas pdfCanvas = new PdfCanvas(pdfDocument.addNewPage()) { @Override public PdfCanvas rectangle(double x, double y, double width, double height) { - Assert.assertEquals(130.0, x, 0); - Assert.assertEquals(230.0, y, 0); - Assert.assertEquals(240.0, width, 0); - Assert.assertEquals(340.0, height, 0); + Assertions.assertEquals(130.0, x, 0); + Assertions.assertEquals(230.0, y, 0); + Assertions.assertEquals(240.0, width, 0); + Assertions.assertEquals(340.0, height, 0); return this; } }; @@ -565,20 +564,20 @@ public float getHeight() { final PdfCanvas pdfCanvas = new PdfCanvas(pdfDocument.addNewPage()) { @Override public PdfCanvas rectangle(double x, double y, double width, double height) { - Assert.assertEquals(130.0, x, 0); - Assert.assertEquals(230.0, y, 0); - Assert.assertEquals(240.0, width, 0); - Assert.assertEquals(340.0, height, 0); + Assertions.assertEquals(130.0, x, 0); + Assertions.assertEquals(230.0, y, 0); + Assertions.assertEquals(240.0, width, 0); + Assertions.assertEquals(340.0, height, 0); return this; } @Override public PdfCanvas addXObjectFittedIntoRectangle(PdfXObject xObject, Rectangle rect) { - Assert.assertEquals(rawImage, xObject); - Assert.assertEquals(100f, rect.getX(), 0); - Assert.assertEquals(550f, rect.getY(), 0); - Assert.assertEquals(50f, rect.getWidth(), 0); - Assert.assertEquals(50f, rect.getHeight(), 0); + Assertions.assertEquals(rawImage, xObject); + Assertions.assertEquals(100f, rect.getX(), 0); + Assertions.assertEquals(550f, rect.getY(), 0); + Assertions.assertEquals(50f, rect.getWidth(), 0); + Assertions.assertEquals(50f, rect.getHeight(), 0); return this; } }; @@ -602,19 +601,19 @@ public void backgroundLinearGradientClipOriginNoRepeatTest() { final PdfCanvas pdfCanvas = new PdfCanvas(pdfDocument.addNewPage()) { @Override public PdfCanvas rectangle(double x, double y, double width, double height) { - Assert.assertEquals(130.0, x, 0); - Assert.assertEquals(230.0, y, 0); - Assert.assertEquals(240.0, width, 0); - Assert.assertEquals(340.0, height, 0); + Assertions.assertEquals(130.0, x, 0); + Assertions.assertEquals(230.0, y, 0); + Assertions.assertEquals(240.0, width, 0); + Assertions.assertEquals(340.0, height, 0); return this; } @Override public PdfCanvas addXObjectFittedIntoRectangle(PdfXObject xObject, Rectangle rect) { - Assert.assertEquals(100f, rect.getX(), 0); - Assert.assertEquals(200f, rect.getY(), 0); - Assert.assertEquals(300f, rect.getWidth(), 0); - Assert.assertEquals(400f, rect.getHeight(), 0); + Assertions.assertEquals(100f, rect.getX(), 0); + Assertions.assertEquals(200f, rect.getY(), 0); + Assertions.assertEquals(300f, rect.getWidth(), 0); + Assertions.assertEquals(400f, rect.getHeight(), 0); return this; } }; @@ -652,7 +651,7 @@ public void applyLinkAnnotationFlushedPageTest() { abstractRenderer.applyLinkAnnotation(pdfDocument); // This test checks that there is log message and there is no NPE so assertions are not required - Assert.assertTrue(true); + Assertions.assertTrue(true); } @Test @@ -675,6 +674,6 @@ public void obtainingMarginsErrorTest() { Document document = new Document(doc); RootRenderer renderer = document.getRenderer(); Rectangle rect = new Rectangle(0, 0); - Assert.assertThrows(ClassCastException.class, () -> renderer.applyMargins(rect, false)); + Assertions.assertThrows(ClassCastException.class, () -> renderer.applyMargins(rect, false)); } } diff --git a/layout/src/test/java/com/itextpdf/layout/renderer/AreaBreakRendererUnitTest.java b/layout/src/test/java/com/itextpdf/layout/renderer/AreaBreakRendererUnitTest.java index c39964ac7c..283573c15b 100644 --- a/layout/src/test/java/com/itextpdf/layout/renderer/AreaBreakRendererUnitTest.java +++ b/layout/src/test/java/com/itextpdf/layout/renderer/AreaBreakRendererUnitTest.java @@ -32,28 +32,27 @@ This file is part of the iText (R) project. import com.itextpdf.layout.properties.Property; import com.itextpdf.test.AssertUtil; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class AreaBreakRendererUnitTest extends ExtendedITextTest { @Test public void addChildTestUnsupported() { AreaBreakRenderer areaBreakRenderer = new AreaBreakRenderer(new AreaBreak()); - Assert.assertNull(areaBreakRenderer.getChildRenderers()); - Assert.assertThrows(Exception.class, () -> areaBreakRenderer.addChild(new TextRenderer(new Text("Test")))); + Assertions.assertNull(areaBreakRenderer.getChildRenderers()); + Assertions.assertThrows(Exception.class, () -> areaBreakRenderer.addChild(new TextRenderer(new Text("Test")))); } @Test public void drawTestUnsupported() { AreaBreakRenderer areaBreakRenderer = new AreaBreakRenderer(new AreaBreak()); - Assert.assertThrows(UnsupportedOperationException.class, + Assertions.assertThrows(UnsupportedOperationException.class, () -> areaBreakRenderer.draw(new DrawContext(new PdfDocument(new PdfWriter(new ByteArrayOutputStream())), null)) ); } @@ -62,121 +61,123 @@ public void drawTestUnsupported() { public void getOccupiedAreaTestUnsupported() { AreaBreakRenderer areaBreakRenderer = new AreaBreakRenderer(new AreaBreak()); - Assert.assertThrows(UnsupportedOperationException.class, () -> areaBreakRenderer.getOccupiedArea()); + Assertions.assertThrows(UnsupportedOperationException.class, () -> areaBreakRenderer.getOccupiedArea()); } @Test //Properties are not supported for AbstractRenderer, and it's expected that the result is false for all the properties. - //The BORDER property is chosen without any specific intention. It could be replaced with any other property. + //The AREA_BREAK_TYPE property is chosen without any specific intention. It could be replaced with any other property. public void hasPropertyTest() { AreaBreakRenderer areaBreakRenderer = new AreaBreakRenderer(new AreaBreak()); - Assert.assertFalse(areaBreakRenderer.hasProperty(Property.BORDER)); + Assertions.assertFalse(areaBreakRenderer.hasProperty(Property.AREA_BREAK_TYPE)); } @Test //Properties are not supported for AbstractRenderer, and it's expected that the result is false for all the properties. - //The BORDER property is chosen without any specific intention. It could be replaced with any other property. + //The AREA_BREAK_TYPE property is chosen without any specific intention. It could be replaced with any other property. public void hasOwnPropertyTest() { AreaBreakRenderer areaBreakRenderer = new AreaBreakRenderer(new AreaBreak()); - Assert.assertFalse(areaBreakRenderer.hasProperty(Property.BORDER)); + Assertions.assertFalse(areaBreakRenderer.hasOwnProperty(Property.AREA_BREAK_TYPE)); } @Test //Properties are not supported for AbstractRenderer, and it's expected that the result is null for all the properties. - //The BORDER property is chosen without any specific intention. It could be replaced with any other property. + //The AREA_BREAK_TYPE property is chosen without any specific intention. It could be replaced with any other property. public void getPropertyTest() { AreaBreakRenderer areaBreakRenderer = new AreaBreakRenderer(new AreaBreak()); - Assert.assertNull(areaBreakRenderer.getProperty(Property.BORDER)); + Assertions.assertNull(areaBreakRenderer.getProperty(Property.AREA_BREAK_TYPE)); } @Test //Properties are not supported for AbstractRenderer, and it's expected that the result is null for all the properties. - //The BORDER property is chosen without any specific intention. It could be replaced with any other property. + //The AREA_BREAK_TYPE property is chosen without any specific intention. It could be replaced with any other property. public void getOwnPropertyTest() { AreaBreakRenderer areaBreakRenderer = new AreaBreakRenderer(new AreaBreak()); - Assert.assertNull(areaBreakRenderer.getOwnProperty(Property.BORDER)); + Assertions.assertNull(areaBreakRenderer.getOwnProperty(Property.AREA_BREAK_TYPE)); } @Test //Properties are not supported for AbstractRenderer, and it's expected that the result is null for all the properties. - //The BORDER property is chosen without any specific intention. It could be replaced with any other property. + //The AREA_BREAK_TYPE property is chosen without any specific intention. It could be replaced with any other property. public void getDefaultPropertyTest() { AreaBreakRenderer areaBreakRenderer = new AreaBreakRenderer(new AreaBreak()); - Assert.assertNull(areaBreakRenderer.getDefaultProperty(Property.BORDER)); + Assertions.assertNull(areaBreakRenderer.getDefaultProperty(Property.AREA_BREAK_TYPE)); } @Test - //The BORDER_RADIUS property is chosen without any specific intention. It could be replaced with any other property. + //The BORDER_BOTTOM_LEFT_RADIUS property is chosen without any specific intention. It could be replaced with any other property. public void getPropertyWithDefaultValueTestUnsupported() { AreaBreakRenderer areaBreakRenderer = new AreaBreakRenderer(new AreaBreak()); - Assert.assertThrows(UnsupportedOperationException.class, () -> areaBreakRenderer.getProperty(Property.BORDER_RADIUS, 3)); + Assertions.assertThrows(UnsupportedOperationException.class, + () -> areaBreakRenderer.getProperty(Property.BORDER_BOTTOM_LEFT_RADIUS, 3)); } @Test - //The BORDER_RADIUS property is chosen without any specific intention. It could be replaced with any other property. + //The BORDER_BOTTOM_LEFT_RADIUS property is chosen without any specific intention. It could be replaced with any other property. public void setPropertyTestUnsupported() { AreaBreakRenderer areaBreakRenderer = new AreaBreakRenderer(new AreaBreak()); - Assert.assertThrows(UnsupportedOperationException.class, () -> areaBreakRenderer.setProperty(Property.BORDER_RADIUS, 5)); + Assertions.assertThrows(UnsupportedOperationException.class, + () -> areaBreakRenderer.setProperty(Property.BORDER_BOTTOM_LEFT_RADIUS, 5)); } @Test - //The BORDER property is chosen without any specific intention. It could be replaced with any other property. + //The AREA_BREAK_TYPE property is chosen without any specific intention. It could be replaced with any other property. //Here we just check that no exception has been thrown. public void deleteOwnProperty() { AreaBreakRenderer areaBreakRenderer = new AreaBreakRenderer(new AreaBreak()); - AssertUtil.doesNotThrow(() -> areaBreakRenderer.deleteOwnProperty(Property.BORDER)); + AssertUtil.doesNotThrow(() -> areaBreakRenderer.deleteOwnProperty(Property.AREA_BREAK_TYPE)); } @Test public void getModelElementTest() { AreaBreak areaBreak = new AreaBreak(); AreaBreakRenderer areaBreakRenderer = new AreaBreakRenderer(areaBreak); - Assert.assertNull(areaBreakRenderer.getModelElement()); + Assertions.assertNull(areaBreakRenderer.getModelElement()); } @Test public void getParentTest() { AreaBreakRenderer areaBreakRenderer = new AreaBreakRenderer(new AreaBreak()); - Assert.assertNull(areaBreakRenderer.getParent()); + Assertions.assertNull(areaBreakRenderer.getParent()); } @Test public void setParentTest() { AreaBreakRenderer areaBreakRenderer = new AreaBreakRenderer(new AreaBreak()); - Assert.assertEquals(areaBreakRenderer, areaBreakRenderer.setParent(new AreaBreakRenderer(new AreaBreak()))); + Assertions.assertEquals(areaBreakRenderer, areaBreakRenderer.setParent(new AreaBreakRenderer(new AreaBreak()))); } @Test public void isFlushedTest() { AreaBreakRenderer areaBreakRenderer = new AreaBreakRenderer(new AreaBreak()); - Assert.assertFalse(areaBreakRenderer.isFlushed()); + Assertions.assertFalse(areaBreakRenderer.isFlushed()); } @Test public void moveTestUnsupported() { AreaBreakRenderer areaBreakRenderer = new AreaBreakRenderer(new AreaBreak()); - Assert.assertThrows(UnsupportedOperationException.class, () -> areaBreakRenderer.move(2.0f, 2.0f)); + Assertions.assertThrows(UnsupportedOperationException.class, () -> areaBreakRenderer.move(2.0f, 2.0f)); } @Test public void getNextRendererTest() { AreaBreakRenderer areaBreakRenderer = new AreaBreakRenderer(new AreaBreak()); - Assert.assertNull(areaBreakRenderer.getNextRenderer()); + Assertions.assertNull(areaBreakRenderer.getNextRenderer()); } @Test public void layoutTest() { AreaBreakRenderer areaBreakRenderer = new AreaBreakRenderer(new AreaBreak()); LayoutResult layoutResult = areaBreakRenderer.layout(new LayoutContext(null)); - Assert.assertEquals(LayoutResult.NOTHING, layoutResult.getStatus()); - Assert.assertNull(layoutResult.getOccupiedArea()); - Assert.assertNull(layoutResult.getSplitRenderer()); - Assert.assertNull(layoutResult.getOverflowRenderer()); - Assert.assertEquals(areaBreakRenderer, layoutResult.getCauseOfNothing()); - Assert.assertEquals(areaBreakRenderer.areaBreak, layoutResult.getAreaBreak()); + Assertions.assertEquals(LayoutResult.NOTHING, layoutResult.getStatus()); + Assertions.assertNull(layoutResult.getOccupiedArea()); + Assertions.assertNull(layoutResult.getSplitRenderer()); + Assertions.assertNull(layoutResult.getOverflowRenderer()); + Assertions.assertEquals(areaBreakRenderer, layoutResult.getCauseOfNothing()); + Assertions.assertEquals(areaBreakRenderer.areaBreak, layoutResult.getAreaBreak()); } } diff --git a/layout/src/test/java/com/itextpdf/layout/renderer/BackgroundSizeCalculationUtilUnitTest.java b/layout/src/test/java/com/itextpdf/layout/renderer/BackgroundSizeCalculationUtilUnitTest.java index 81e1f4b50a..dc40fb52d3 100644 --- a/layout/src/test/java/com/itextpdf/layout/renderer/BackgroundSizeCalculationUtilUnitTest.java +++ b/layout/src/test/java/com/itextpdf/layout/renderer/BackgroundSizeCalculationUtilUnitTest.java @@ -26,14 +26,13 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.xobject.PdfImageXObject; import com.itextpdf.layout.properties.BackgroundImage; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.net.MalformedURLException; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class BackgroundSizeCalculationUtilUnitTest extends ExtendedITextTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/layout/BackgroundImageTest/"; @@ -46,7 +45,7 @@ public void calculateImageSizeTest() throws MalformedURLException { float[] widthAndHeight = BackgroundSizeCalculationUtil.calculateBackgroundImageSize(backgroundImage, 200f, 300f); - Assert.assertArrayEquals(new float[] {45f, 45f}, widthAndHeight, delta); + Assertions.assertArrayEquals(new float[] {45f, 45f}, widthAndHeight, delta); } @Test @@ -57,7 +56,7 @@ public void calculateImageSizeWithCoverPropertyTest() throws MalformedURLExcepti float[] widthAndHeight = BackgroundSizeCalculationUtil.calculateBackgroundImageSize(backgroundImage, 200f, 300f); - Assert.assertArrayEquals(new float[] {300f, 300f}, widthAndHeight, delta); + Assertions.assertArrayEquals(new float[] {300f, 300f}, widthAndHeight, delta); } @Test @@ -68,7 +67,7 @@ public void calculateSizeWithContainPropertyTest() throws MalformedURLException float[] widthAndHeight = BackgroundSizeCalculationUtil.calculateBackgroundImageSize(backgroundImage, 200f, 300f); - Assert.assertArrayEquals(new float[] {200f, 200.000015f}, widthAndHeight, delta); + Assertions.assertArrayEquals(new float[] {200f, 200.000015f}, widthAndHeight, delta); } @Test @@ -79,7 +78,7 @@ public void calculateSizeWithContainAndImageWeightMoreThatHeightTest() throws Ma float[] widthAndHeight = BackgroundSizeCalculationUtil.calculateBackgroundImageSize(backgroundImage, 200f, 300f); - Assert.assertArrayEquals(new float[] {200f, 112.5f}, widthAndHeight, delta); + Assertions.assertArrayEquals(new float[] {200f, 112.5f}, widthAndHeight, delta); } @Test @@ -90,6 +89,6 @@ public void calculateSizeWithCoverAndImageWeightMoreThatHeightTest() throws Malf float[] widthAndHeight = BackgroundSizeCalculationUtil.calculateBackgroundImageSize(backgroundImage, 200f, 300f); - Assert.assertArrayEquals(new float[] {533.3333f, 300f}, widthAndHeight, delta); + Assertions.assertArrayEquals(new float[] {533.3333f, 300f}, widthAndHeight, delta); } } diff --git a/layout/src/test/java/com/itextpdf/layout/renderer/BlockRendererTest.java b/layout/src/test/java/com/itextpdf/layout/renderer/BlockRendererTest.java index fe293bef41..cf6d431aea 100644 --- a/layout/src/test/java/com/itextpdf/layout/renderer/BlockRendererTest.java +++ b/layout/src/test/java/com/itextpdf/layout/renderer/BlockRendererTest.java @@ -45,21 +45,20 @@ This file is part of the iText (R) project. import com.itextpdf.test.LogLevelConstants; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class BlockRendererTest extends ExtendedITextTest { public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/layout/BlockRendererTest/"; public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/layout/BlockRendererTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(DESTINATION_FOLDER); } @@ -74,13 +73,13 @@ public void applyMinHeightForSpecificDimensionsCausingFloatPrecisionErrorTest() float occupiedHeight = 17.981995f; float leftHeight = 24.567993f; - Assert.assertTrue(occupiedHeight + leftHeight < divHeight); + Assertions.assertTrue(occupiedHeight + leftHeight < divHeight); BlockRenderer blockRenderer = (BlockRenderer) div.createRendererSubTree(); blockRenderer.occupiedArea = new LayoutArea(1, new Rectangle(0, 267.9681f, 0, occupiedHeight)); AbstractRenderer renderer = blockRenderer.applyMinHeight(OverflowPropertyValue.FIT, new Rectangle(0, 243.40012f, 0, leftHeight)); - Assert.assertNull(renderer); + Assertions.assertNull(renderer); } @Test @@ -116,7 +115,7 @@ public void parentBoxWrapAroundChildBoxesTest() throws IOException, InterruptedE document.add(div); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER)); + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, DESTINATION_FOLDER)); } @Test @@ -126,7 +125,7 @@ public void resolveFontTest() throws IOException { div.setProperty(Property.FONT, PdfFontFactory.createFont(StandardFonts.TIMES_ROMAN)); DivRenderer renderer = (DivRenderer) div.getRenderer(); PdfFont font = renderer.getResolvedFont(pdfDocument); - Assert.assertEquals("Times-Roman", font.getFontProgram().getFontNames().getFontName()); + Assertions.assertEquals("Times-Roman", font.getFontProgram().getFontNames().getFontName()); } @@ -135,7 +134,7 @@ public void resolveFontWithPdfDocumentNullTest() { Div div = new Div(); DivRenderer renderer = (DivRenderer) div.getRenderer(); PdfFont font = renderer.getResolvedFont(null); - Assert.assertNull(font); + Assertions.assertNull(font); } @@ -150,7 +149,7 @@ public void resolveFontFromFontProviderTest() { div.setProperty(Property.FONT, new String[] {"courier"}); DivRenderer renderer = (DivRenderer) div.getRenderer(); PdfFont font = renderer.getResolvedFont(pdfDocument); - Assert.assertEquals("Courier", font.getFontProgram().getFontNames().getFontName()); + Assertions.assertEquals("Courier", font.getFontProgram().getFontNames().getFontName()); } @@ -163,7 +162,7 @@ public void resolveFontFromFontProviderNullTest() { div.setProperty(Property.FONT, new String[] {"courier"}); DivRenderer renderer = (DivRenderer) div.getRenderer(); PdfFont font = renderer.getResolvedFont(pdfDocument); - Assert.assertEquals("Helvetica", font.getFontProgram().getFontNames().getFontName()); + Assertions.assertEquals("Helvetica", font.getFontProgram().getFontNames().getFontName()); } @Test @@ -174,7 +173,7 @@ public void resolveFontFromFontProviderNullAndDocNullTest() { div.setProperty(Property.FONT, new String[] {"courier"}); DivRenderer renderer = (DivRenderer) div.getRenderer(); PdfFont font = renderer.getResolvedFont(null); - Assert.assertNull(font); + Assertions.assertNull(font); } } diff --git a/layout/src/test/java/com/itextpdf/layout/renderer/BlockRendererUnitTest.java b/layout/src/test/java/com/itextpdf/layout/renderer/BlockRendererUnitTest.java index 41e48ccc96..7d105b9c84 100644 --- a/layout/src/test/java/com/itextpdf/layout/renderer/BlockRendererUnitTest.java +++ b/layout/src/test/java/com/itextpdf/layout/renderer/BlockRendererUnitTest.java @@ -35,12 +35,11 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class BlockRendererUnitTest extends ExtendedITextTest { @Test @@ -60,6 +59,6 @@ public void clippedAreaFlushedPageTest() { blockRenderer.draw(context); // This test checks that there is log message and there is no NPE so assertions are not required - Assert.assertTrue(true); + Assertions.assertTrue(true); } } diff --git a/layout/src/test/java/com/itextpdf/layout/renderer/CellRendererUnitTest.java b/layout/src/test/java/com/itextpdf/layout/renderer/CellRendererUnitTest.java index dc6a161311..98ae2613f4 100644 --- a/layout/src/test/java/com/itextpdf/layout/renderer/CellRendererUnitTest.java +++ b/layout/src/test/java/com/itextpdf/layout/renderer/CellRendererUnitTest.java @@ -27,13 +27,12 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class CellRendererUnitTest extends ExtendedITextTest { @Test @@ -45,6 +44,6 @@ public void getNextRendererShouldBeOverriddenTest() { // Nothing is overridden }; - Assert.assertEquals(CellRenderer.class, cellRenderer.getNextRenderer().getClass()); + Assertions.assertEquals(CellRenderer.class, cellRenderer.getNextRenderer().getClass()); } } diff --git a/layout/src/test/java/com/itextpdf/layout/renderer/DivRendererUnitTest.java b/layout/src/test/java/com/itextpdf/layout/renderer/DivRendererUnitTest.java index 8380781d34..f35e73c20c 100644 --- a/layout/src/test/java/com/itextpdf/layout/renderer/DivRendererUnitTest.java +++ b/layout/src/test/java/com/itextpdf/layout/renderer/DivRendererUnitTest.java @@ -27,13 +27,12 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class DivRendererUnitTest extends ExtendedITextTest { @Test @@ -45,6 +44,6 @@ public void getNextRendererShouldBeOverriddenTest() { // Nothing is overridden }; - Assert.assertEquals(DivRenderer.class, divRenderer.getNextRenderer().getClass()); + Assertions.assertEquals(DivRenderer.class, divRenderer.getNextRenderer().getClass()); } } diff --git a/layout/src/test/java/com/itextpdf/layout/renderer/EmptyNestedTableTest.java b/layout/src/test/java/com/itextpdf/layout/renderer/EmptyNestedTableTest.java index a72c455a54..e3c801db36 100644 --- a/layout/src/test/java/com/itextpdf/layout/renderer/EmptyNestedTableTest.java +++ b/layout/src/test/java/com/itextpdf/layout/renderer/EmptyNestedTableTest.java @@ -29,23 +29,22 @@ This file is part of the iText (R) project. import com.itextpdf.layout.element.Cell; import com.itextpdf.layout.element.Table; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; /** */ -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class EmptyNestedTableTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/layout/EmptyNestedTableTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/layout/EmptyNestedTableTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } @@ -70,7 +69,7 @@ public void buildEmptyTable() throws IOException, InterruptedException { layoutDocument.close(); // compare - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } } diff --git a/layout/src/test/java/com/itextpdf/layout/renderer/FlexContainerRendererTest.java b/layout/src/test/java/com/itextpdf/layout/renderer/FlexContainerRendererTest.java index d729f9d8f7..8bb7c5c03f 100644 --- a/layout/src/test/java/com/itextpdf/layout/renderer/FlexContainerRendererTest.java +++ b/layout/src/test/java/com/itextpdf/layout/renderer/FlexContainerRendererTest.java @@ -36,15 +36,14 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class FlexContainerRendererTest extends ExtendedITextTest { - private static float EPS = 0.0001F; + private static final float EPS = 0.0001F; @Test public void widthNotSetTest() { @@ -53,8 +52,8 @@ public void widthNotSetTest() { flexRenderer.addChild(divRenderer); - Assert.assertEquals(0F, flexRenderer.getMinMaxWidth().getMinWidth(), EPS); - Assert.assertEquals(0F, flexRenderer.getMinMaxWidth().getMaxWidth(), EPS); + Assertions.assertEquals(0F, flexRenderer.getMinMaxWidth().getMinWidth(), EPS); + Assertions.assertEquals(0F, flexRenderer.getMinMaxWidth().getMaxWidth(), EPS); } @Test @@ -65,8 +64,8 @@ public void widthSetToChildOneChildTest() { flexRenderer.addChild(divRenderer); - Assert.assertEquals(50F, flexRenderer.getMinMaxWidth().getMinWidth(), EPS); - Assert.assertEquals(50F, flexRenderer.getMinMaxWidth().getMaxWidth(), EPS); + Assertions.assertEquals(50F, flexRenderer.getMinMaxWidth().getMinWidth(), EPS); + Assertions.assertEquals(50F, flexRenderer.getMinMaxWidth().getMaxWidth(), EPS); } @Test @@ -86,8 +85,8 @@ public void widthSetToChildManyChildrenTest() { flexRenderer.addChild(divRenderer3); flexRenderer.addChild(divRenderer4); - Assert.assertEquals(125F, flexRenderer.getMinMaxWidth().getMinWidth(), EPS); - Assert.assertEquals(125F, flexRenderer.getMinMaxWidth().getMaxWidth(), EPS); + Assertions.assertEquals(125F, flexRenderer.getMinMaxWidth().getMinWidth(), EPS); + Assertions.assertEquals(125F, flexRenderer.getMinMaxWidth().getMaxWidth(), EPS); } @Test @@ -95,7 +94,11 @@ public void widthSetToChildManyChildrenWithBordersMarginsPaddingsTest() { FlexContainerRenderer flexRenderer = new FlexContainerRenderer(new Div()); DivRenderer divRenderer1 = new DivRenderer(new Div()); divRenderer1.setProperty(Property.WIDTH, UnitValue.createPointValue(50)); - divRenderer1.setProperty(Property.BORDER, new SolidBorder(5)); + SolidBorder border = new SolidBorder(5); + divRenderer1.setProperty(Property.BORDER_TOP, border); + divRenderer1.setProperty(Property.BORDER_RIGHT, border); + divRenderer1.setProperty(Property.BORDER_BOTTOM, border); + divRenderer1.setProperty(Property.BORDER_LEFT, border); DivRenderer divRenderer2 = new DivRenderer(new Div()); divRenderer2.setProperty(Property.WIDTH, UnitValue.createPointValue(40)); divRenderer2.setProperty(Property.MARGIN_LEFT, UnitValue.createPointValue(10)); @@ -110,8 +113,8 @@ public void widthSetToChildManyChildrenWithBordersMarginsPaddingsTest() { flexRenderer.addChild(divRenderer3); flexRenderer.addChild(divRenderer4); - Assert.assertEquals(165F, flexRenderer.getMinMaxWidth().getMinWidth(), EPS); - Assert.assertEquals(165F, flexRenderer.getMinMaxWidth().getMaxWidth(), EPS); + Assertions.assertEquals(165F, flexRenderer.getMinMaxWidth().getMinWidth(), EPS); + Assertions.assertEquals(165F, flexRenderer.getMinMaxWidth().getMaxWidth(), EPS); } @Test @@ -121,7 +124,11 @@ public void widthSetToFlexRendererAndToChildManyChildrenWithBordersMarginsPaddin DivRenderer divRenderer1 = new DivRenderer(new Div()); divRenderer1.setProperty(Property.WIDTH, UnitValue.createPointValue(50)); - divRenderer1.setProperty(Property.BORDER, new SolidBorder(5)); + SolidBorder border = new SolidBorder(5); + divRenderer1.setProperty(Property.BORDER_TOP, border); + divRenderer1.setProperty(Property.BORDER_RIGHT, border); + divRenderer1.setProperty(Property.BORDER_BOTTOM, border); + divRenderer1.setProperty(Property.BORDER_LEFT, border); DivRenderer divRenderer2 = new DivRenderer(new Div()); divRenderer2.setProperty(Property.WIDTH, UnitValue.createPointValue(40)); divRenderer2.setProperty(Property.MARGIN_LEFT, UnitValue.createPointValue(10)); @@ -136,8 +143,8 @@ public void widthSetToFlexRendererAndToChildManyChildrenWithBordersMarginsPaddin flexRenderer.addChild(divRenderer3); flexRenderer.addChild(divRenderer4); - Assert.assertEquals(50F, flexRenderer.getMinMaxWidth().getMinWidth(), EPS); - Assert.assertEquals(50F, flexRenderer.getMinMaxWidth().getMaxWidth(), EPS); + Assertions.assertEquals(50F, flexRenderer.getMinMaxWidth().getMinWidth(), EPS); + Assertions.assertEquals(50F, flexRenderer.getMinMaxWidth().getMaxWidth(), EPS); } @Test @@ -159,8 +166,8 @@ public void widthSetToChildManyChildrenFlexRendererWithRotationAngleTest() { flexRenderer.addChild(divRenderer3); flexRenderer.addChild(divRenderer4); - Assert.assertEquals(104.892334F, flexRenderer.getMinMaxWidth().getMinWidth(), EPS); - Assert.assertEquals(104.892334F, flexRenderer.getMinMaxWidth().getMaxWidth(), EPS); + Assertions.assertEquals(104.892334F, flexRenderer.getMinMaxWidth().getMinWidth(), EPS); + Assertions.assertEquals(104.892334F, flexRenderer.getMinMaxWidth().getMaxWidth(), EPS); } @Test @@ -182,8 +189,8 @@ public void widthSetToChildManyChildrenFlexRendererWithMinWidthTest() { flexRenderer.addChild(divRenderer3); flexRenderer.addChild(divRenderer4); - Assert.assertEquals(71F, flexRenderer.getMinMaxWidth().getMinWidth(), EPS); - Assert.assertEquals(125F, flexRenderer.getMinMaxWidth().getMaxWidth(), EPS); + Assertions.assertEquals(71F, flexRenderer.getMinMaxWidth().getMinWidth(), EPS); + Assertions.assertEquals(125F, flexRenderer.getMinMaxWidth().getMaxWidth(), EPS); } @@ -193,7 +200,7 @@ public void decreaseLayoutBoxAfterChildPlacementResultsOccupiedAreaNull() { splitRenderer.occupiedArea = new LayoutArea(0, new Rectangle(0, 0)); LayoutResult nothing = new LayoutResult(LayoutResult.NOTHING, null, splitRenderer, null); - Assert.assertNotNull(new FlexContainerRenderer(new Div()) + Assertions.assertNotNull(new FlexContainerRenderer(new Div()) .getOccupiedAreaInCaseNothingWasWrappedWithFull(nothing, splitRenderer)); } @@ -216,8 +223,8 @@ public void widthSetToChildManyChildrenFlexRendererWithMinWidthBiggerThanMaxWidt flexRenderer.addChild(divRenderer3); flexRenderer.addChild(divRenderer4); - Assert.assertEquals(150F, flexRenderer.getMinMaxWidth().getMinWidth(), EPS); - Assert.assertEquals(150F, flexRenderer.getMinMaxWidth().getMaxWidth(), EPS); + Assertions.assertEquals(150F, flexRenderer.getMinMaxWidth().getMinWidth(), EPS); + Assertions.assertEquals(150F, flexRenderer.getMinMaxWidth().getMaxWidth(), EPS); } @Test @@ -239,8 +246,8 @@ public void widthSetToChildManyChildrenFlexRendererWithMaxWidthTest() { flexRenderer.addChild(divRenderer3); flexRenderer.addChild(divRenderer4); - Assert.assertEquals(125F, flexRenderer.getMinMaxWidth().getMinWidth(), EPS); - Assert.assertEquals(150F, flexRenderer.getMinMaxWidth().getMaxWidth(), EPS); + Assertions.assertEquals(125F, flexRenderer.getMinMaxWidth().getMinWidth(), EPS); + Assertions.assertEquals(150F, flexRenderer.getMinMaxWidth().getMaxWidth(), EPS); } @Test @@ -262,8 +269,8 @@ public void widthSetToChildManyChildrenFlexRendererWithMaxWidthLowerThanMinWidth flexRenderer.addChild(divRenderer3); flexRenderer.addChild(divRenderer4); - Assert.assertEquals(100F, flexRenderer.getMinMaxWidth().getMinWidth(), EPS); - Assert.assertEquals(100F, flexRenderer.getMinMaxWidth().getMaxWidth(), EPS); + Assertions.assertEquals(100F, flexRenderer.getMinMaxWidth().getMinWidth(), EPS); + Assertions.assertEquals(100F, flexRenderer.getMinMaxWidth().getMaxWidth(), EPS); } @Test @@ -275,7 +282,7 @@ public void getNextRendererShouldBeOverriddenTest() { // Nothing is overridden }; - Assert.assertEquals(FlexContainerRenderer.class, flexContainerRenderer.getNextRenderer().getClass()); + Assertions.assertEquals(FlexContainerRenderer.class, flexContainerRenderer.getNextRenderer().getClass()); } @Test @@ -300,8 +307,8 @@ public void hypotheticalCrossSizeCacheTest() { new LayoutArea(0, new Rectangle(200, 0)))); // Test that hypotheticalCrossSizes can contain more than 1 value - Assert.assertNotNull(flexRendererChild.getHypotheticalCrossSize(125F)); - Assert.assertNotNull(flexRendererChild.getHypotheticalCrossSize(150F)); + Assertions.assertNotNull(flexRendererChild.getHypotheticalCrossSize(125F)); + Assertions.assertNotNull(flexRendererChild.getHypotheticalCrossSize(150F)); } @Test @@ -309,7 +316,11 @@ public void minMaxWidthForFlexRendererWithWrapTest() { FlexContainerRenderer flexRenderer = new FlexContainerRenderer(new Div()); flexRenderer.setProperty(Property.FLEX_WRAP, FlexWrapPropertyValue.WRAP); flexRenderer.setProperty(Property.MAX_WIDTH, UnitValue.createPointValue(100)); - flexRenderer.setProperty(Property.BORDER, new SolidBorder(5)); + SolidBorder border = new SolidBorder(5); + flexRenderer.setProperty(Property.BORDER_TOP, border); + flexRenderer.setProperty(Property.BORDER_RIGHT, border); + flexRenderer.setProperty(Property.BORDER_BOTTOM, border); + flexRenderer.setProperty(Property.BORDER_LEFT, border); // line 1 DivRenderer divRenderer1 = new DivRenderer(new Div()); @@ -335,14 +346,14 @@ public void minMaxWidthForFlexRendererWithWrapTest() { flexRenderer.layout(new LayoutContext(new LayoutArea(0, new Rectangle(100, 100)))); MinMaxWidth minMaxWidth = flexRenderer.getMinMaxWidth(); - Assert.assertEquals(75F, minMaxWidth.getChildrenMinWidth(), EPS); - Assert.assertEquals(85F, minMaxWidth.getMinWidth(), EPS); - Assert.assertEquals(100F, minMaxWidth.getChildrenMaxWidth(), EPS); - Assert.assertEquals(110F, minMaxWidth.getMaxWidth(), EPS); + Assertions.assertEquals(75F, minMaxWidth.getChildrenMinWidth(), EPS); + Assertions.assertEquals(85F, minMaxWidth.getMinWidth(), EPS); + Assertions.assertEquals(100F, minMaxWidth.getChildrenMaxWidth(), EPS); + Assertions.assertEquals(110F, minMaxWidth.getMaxWidth(), EPS); flexRenderer.deleteOwnProperty(Property.MAX_WIDTH); minMaxWidth = flexRenderer.getMinMaxWidth(); - Assert.assertEquals(90F, minMaxWidth.getChildrenMaxWidth(), EPS); - Assert.assertEquals(100F, minMaxWidth.getMaxWidth(), EPS); + Assertions.assertEquals(90F, minMaxWidth.getChildrenMaxWidth(), EPS); + Assertions.assertEquals(100F, minMaxWidth.getMaxWidth(), EPS); } } diff --git a/layout/src/test/java/com/itextpdf/layout/renderer/FlexUtilTest.java b/layout/src/test/java/com/itextpdf/layout/renderer/FlexUtilTest.java index 864a5be054..239cc59400 100644 --- a/layout/src/test/java/com/itextpdf/layout/renderer/FlexUtilTest.java +++ b/layout/src/test/java/com/itextpdf/layout/renderer/FlexUtilTest.java @@ -46,7 +46,6 @@ This file is part of the iText (R) project. import com.itextpdf.layout.properties.Property; import com.itextpdf.layout.properties.UnitValue; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.ByteArrayOutputStream; import java.net.MalformedURLException; @@ -54,11 +53,11 @@ This file is part of the iText (R) project. import java.util.Arrays; import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class FlexUtilTest extends ExtendedITextTest { /* To see integration tests for flex algorithm go to FlexAlgoTest in html2pdf module. @@ -99,11 +98,11 @@ public void defaultTest01() { ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(400f / 3, flexItemInfo.getRectangle().getWidth(), EPS); - Assert.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(400f / 3, flexItemInfo.getRectangle().getWidth(), EPS); + Assertions.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); } } } @@ -138,8 +137,8 @@ public void item1BasisGtWidthGrow0Shrink01Test01() { List> rectangleTable = FlexUtil.calculateChildrenRectangles(bBox, (FlexContainerRenderer) div.getRenderer()); - Assert.assertEquals(135f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(45f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); + Assertions.assertEquals(135f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(45f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); } @Test @@ -159,11 +158,11 @@ public void differentBasisGrow1Shrink0MarginBorderPaddingOnContainerTest01() { ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); - Assert.assertEquals(23.333334f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(33.333336f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); - Assert.assertEquals(43.333336f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); + Assertions.assertEquals(23.333334f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(33.333336f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); + Assertions.assertEquals(43.333336f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); } @Test @@ -181,11 +180,11 @@ public void differentBasisGrow1Shrink0MarginBorderPaddingOnContainerNoWidthTest0 ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); - Assert.assertEquals(104.333336f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(154.33334f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); - Assert.assertEquals(204.33334f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); + Assertions.assertEquals(104.333336f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(154.33334f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); + Assertions.assertEquals(204.33334f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); } @Test @@ -200,11 +199,11 @@ public void simpleStretchTest01() { ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(100f, flexItemInfo.getRectangle().getWidth(), EPS); - Assert.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(100f, flexItemInfo.getRectangle().getWidth(), EPS); + Assertions.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); } } } @@ -219,11 +218,11 @@ public void basis100Grow0Shrink0ColumnTest() { ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(100.0f, flexItemInfo.getRectangle().getWidth(), EPS); - Assert.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(100.0f, flexItemInfo.getRectangle().getWidth(), EPS); + Assertions.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); } } } @@ -238,11 +237,11 @@ public void basis100Grow1Shrink0ColumnTest() { ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(100.0f, flexItemInfo.getRectangle().getWidth(), EPS); - Assert.assertEquals(133.3333f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(100.0f, flexItemInfo.getRectangle().getWidth(), EPS); + Assertions.assertEquals(133.3333f, flexItemInfo.getRectangle().getHeight(), EPS); } } } @@ -257,11 +256,11 @@ public void basis100Grow01Shrink0ColumnTest() { ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(100.0f, flexItemInfo.getRectangle().getWidth(), EPS); - Assert.assertEquals(110.0f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(100.0f, flexItemInfo.getRectangle().getWidth(), EPS); + Assertions.assertEquals(110.0f, flexItemInfo.getRectangle().getHeight(), EPS); } } } @@ -276,11 +275,11 @@ public void basis200Grow0Shrink1ColumnTest() { ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(100.0f, flexItemInfo.getRectangle().getWidth(), EPS); - Assert.assertEquals(133.33333f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(100.0f, flexItemInfo.getRectangle().getWidth(), EPS); + Assertions.assertEquals(133.33333f, flexItemInfo.getRectangle().getHeight(), EPS); } } } @@ -295,16 +294,16 @@ public void basis100Grow0CustomShrinkContainerHeight50ColumnTest() { ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(100.0f, flexItemInfo.getRectangle().getWidth(), EPS); + Assertions.assertEquals(100.0f, flexItemInfo.getRectangle().getWidth(), EPS); } } // Expected because content of the element cannot be less than this value - Assert.assertEquals(25.9375f, rectangleTable.get(0).get(0).getRectangle().getHeight(), EPS); - Assert.assertEquals(25.9375f, rectangleTable.get(0).get(1).getRectangle().getHeight(), EPS); + Assertions.assertEquals(25.9375f, rectangleTable.get(0).get(0).getRectangle().getHeight(), EPS); + Assertions.assertEquals(25.9375f, rectangleTable.get(0).get(1).getRectangle().getHeight(), EPS); } @Test @@ -317,16 +316,16 @@ public void basis200Grow0CustomShrinkColumnTest1() { ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(100.0f, flexItemInfo.getRectangle().getWidth(), EPS); + Assertions.assertEquals(100.0f, flexItemInfo.getRectangle().getWidth(), EPS); } } - Assert.assertEquals(200f, rectangleTable.get(0).get(0).getRectangle().getHeight(), EPS); - Assert.assertEquals(150f, rectangleTable.get(0).get(1).getRectangle().getHeight(), EPS); - Assert.assertEquals(50f, rectangleTable.get(0).get(2).getRectangle().getHeight(), EPS); + Assertions.assertEquals(200f, rectangleTable.get(0).get(0).getRectangle().getHeight(), EPS); + Assertions.assertEquals(150f, rectangleTable.get(0).get(1).getRectangle().getHeight(), EPS); + Assertions.assertEquals(50f, rectangleTable.get(0).get(2).getRectangle().getHeight(), EPS); } @Test @@ -339,11 +338,11 @@ public void basis200Grow0Shrink01ColumnTest() { ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(100.0f, flexItemInfo.getRectangle().getWidth(), EPS); - Assert.assertEquals(180f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(100.0f, flexItemInfo.getRectangle().getWidth(), EPS); + Assertions.assertEquals(180f, flexItemInfo.getRectangle().getHeight(), EPS); } } } @@ -359,11 +358,11 @@ public void basis200Height150Grow0Shrink1ColumnTest() { ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(100.0f, flexItemInfo.getRectangle().getWidth(), EPS); - Assert.assertEquals(133.3333f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(100.0f, flexItemInfo.getRectangle().getWidth(), EPS); + Assertions.assertEquals(133.3333f, flexItemInfo.getRectangle().getHeight(), EPS); } } } @@ -379,11 +378,11 @@ public void basis100Height150Grow1Shrink0ColumnTest() { ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(100.0f, flexItemInfo.getRectangle().getWidth(), EPS); - Assert.assertEquals(133.3333f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(100.0f, flexItemInfo.getRectangle().getWidth(), EPS); + Assertions.assertEquals(133.3333f, flexItemInfo.getRectangle().getHeight(), EPS); } } } @@ -399,11 +398,11 @@ public void basis100Height50Grow1Shrink0ColumnTest() { ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(100.0f, flexItemInfo.getRectangle().getWidth(), EPS); - Assert.assertEquals(133.3333f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(100.0f, flexItemInfo.getRectangle().getWidth(), EPS); + Assertions.assertEquals(133.3333f, flexItemInfo.getRectangle().getHeight(), EPS); } } } @@ -419,11 +418,11 @@ public void basis100MaxHeight100Grow1Shrink0ColumnTest() { ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(100.0f, flexItemInfo.getRectangle().getWidth(), EPS); - Assert.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(100.0f, flexItemInfo.getRectangle().getWidth(), EPS); + Assertions.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); } } } @@ -439,11 +438,11 @@ public void basis200MinHeight150Grow0Shrink1ColumnTest() { ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(100f, flexItemInfo.getRectangle().getWidth(), EPS); - Assert.assertEquals(150f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(100f, flexItemInfo.getRectangle().getWidth(), EPS); + Assertions.assertEquals(150f, flexItemInfo.getRectangle().getHeight(), EPS); } } } @@ -459,11 +458,11 @@ public void usualDirectionColumnWithDefiniteWidthTest() { ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(50.0f, flexItemInfo.getRectangle().getWidth(), EPS); - Assert.assertEquals(133.3333f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(50.0f, flexItemInfo.getRectangle().getWidth(), EPS); + Assertions.assertEquals(133.3333f, flexItemInfo.getRectangle().getHeight(), EPS); } } } @@ -479,11 +478,11 @@ public void usualDirectionColumnWithDefiniteMaxWidthTest() { ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(50.0f, flexItemInfo.getRectangle().getWidth(), EPS); - Assert.assertEquals(133.3333f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(50.0f, flexItemInfo.getRectangle().getWidth(), EPS); + Assertions.assertEquals(133.3333f, flexItemInfo.getRectangle().getHeight(), EPS); } } } @@ -499,11 +498,11 @@ public void usualDirectionColumnWithDefiniteMinWidthTest() { ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(150.0f, flexItemInfo.getRectangle().getWidth(), EPS); - Assert.assertEquals(133.3333f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(150.0f, flexItemInfo.getRectangle().getWidth(), EPS); + Assertions.assertEquals(133.3333f, flexItemInfo.getRectangle().getHeight(), EPS); } } } @@ -519,11 +518,11 @@ public void directionColumnWithoutBasisWithDefiniteHeightTest() { ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(100.0f, flexItemInfo.getRectangle().getWidth(), EPS); - Assert.assertEquals(133.33333f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(100.0f, flexItemInfo.getRectangle().getWidth(), EPS); + Assertions.assertEquals(133.33333f, flexItemInfo.getRectangle().getHeight(), EPS); } } } @@ -540,12 +539,12 @@ public void directionColumnWithWrapElementsToGrowTest() { ); // after checks - Assert.assertEquals(3, rectangleTable.size()); + Assertions.assertEquals(3, rectangleTable.size()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(133.33333f, flexItemInfo.getRectangle().getWidth(), EPS); - Assert.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(133.33333f, flexItemInfo.getRectangle().getWidth(), EPS); + Assertions.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); } } } @@ -562,12 +561,12 @@ public void directionColumnWithWrapElementsNotToGrowTest() { ); // after checks - Assert.assertEquals(3, rectangleTable.size()); + Assertions.assertEquals(3, rectangleTable.size()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(133.33333f, flexItemInfo.getRectangle().getWidth(), EPS); - Assert.assertEquals(75.0f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(133.33333f, flexItemInfo.getRectangle().getWidth(), EPS); + Assertions.assertEquals(75.0f, flexItemInfo.getRectangle().getHeight(), EPS); } } } @@ -584,12 +583,12 @@ public void directionColumnWithWrapElementsToShrinkTest() { ); // after checks - Assert.assertEquals(3, rectangleTable.size()); + Assertions.assertEquals(3, rectangleTable.size()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(133.33333f, flexItemInfo.getRectangle().getWidth(), EPS); - Assert.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(133.33333f, flexItemInfo.getRectangle().getWidth(), EPS); + Assertions.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); } } } @@ -606,12 +605,12 @@ public void directionColumnWithWrapElementsNotToShrinkTest() { ); // after checks - Assert.assertEquals(3, rectangleTable.size()); + Assertions.assertEquals(3, rectangleTable.size()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(133.33333f, flexItemInfo.getRectangle().getWidth(), EPS); - Assert.assertEquals(120.0f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(133.33333f, flexItemInfo.getRectangle().getWidth(), EPS); + Assertions.assertEquals(120.0f, flexItemInfo.getRectangle().getHeight(), EPS); } } } @@ -629,12 +628,12 @@ public void directionColumnWithWrapDefiniteWidthAndHeightTest() { ); // after checks - Assert.assertEquals(3, rectangleTable.size()); + Assertions.assertEquals(3, rectangleTable.size()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(100.0f, flexItemInfo.getRectangle().getWidth(), EPS); - Assert.assertEquals(75.0f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(100.0f, flexItemInfo.getRectangle().getWidth(), EPS); + Assertions.assertEquals(75.0f, flexItemInfo.getRectangle().getHeight(), EPS); } } } @@ -653,15 +652,15 @@ public void directionColumnWithWrapWithAlignItemsAndJustifyContentTest() { ); // after checks - Assert.assertEquals(3, rectangleTable.size()); + Assertions.assertEquals(3, rectangleTable.size()); for (int i = 0; i < rectangleTable.size(); ++i) { List line = rectangleTable.get(i); for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(6.0f, flexItemInfo.getRectangle().getWidth(), EPS); - Assert.assertEquals(75.0f, flexItemInfo.getRectangle().getHeight(), EPS); - Assert.assertEquals(i == 0 ? 0.0f : 127.33334, flexItemInfo.getRectangle().getX(), EPS); - Assert.assertEquals(25.0f, flexItemInfo.getRectangle().getY(), EPS); + Assertions.assertEquals(6.0f, flexItemInfo.getRectangle().getWidth(), EPS); + Assertions.assertEquals(75.0f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(i == 0 ? 0.0f : 127.33334, flexItemInfo.getRectangle().getX(), EPS); + Assertions.assertEquals(25.0f, flexItemInfo.getRectangle().getY(), EPS); } } } @@ -679,14 +678,14 @@ public void directionColumnWithAlignItemsAndJustifyContentTest1() { ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(6.0f, flexItemInfo.getRectangle().getWidth(), EPS); - Assert.assertEquals(75.0f, flexItemInfo.getRectangle().getHeight(), EPS); - Assert.assertEquals(0.0f, flexItemInfo.getRectangle().getX(), EPS); + Assertions.assertEquals(6.0f, flexItemInfo.getRectangle().getWidth(), EPS); + Assertions.assertEquals(75.0f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(0.0f, flexItemInfo.getRectangle().getX(), EPS); } - Assert.assertEquals(175.0f, line.get(0).getRectangle().getY(), EPS); + Assertions.assertEquals(175.0f, line.get(0).getRectangle().getY(), EPS); } } @@ -703,13 +702,13 @@ public void directionColumnWithAlignItemsAndJustifyContentTest2() { ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(6.0f, flexItemInfo.getRectangle().getWidth(), EPS); - Assert.assertEquals(75.0f, flexItemInfo.getRectangle().getHeight(), EPS); - Assert.assertEquals(47.0f, flexItemInfo.getRectangle().getX(), EPS); - Assert.assertEquals(0.0f, flexItemInfo.getRectangle().getY(), EPS); + Assertions.assertEquals(6.0f, flexItemInfo.getRectangle().getWidth(), EPS); + Assertions.assertEquals(75.0f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(47.0f, flexItemInfo.getRectangle().getX(), EPS); + Assertions.assertEquals(0.0f, flexItemInfo.getRectangle().getY(), EPS); } } } @@ -727,14 +726,14 @@ public void directionColumnWithAlignItemsAndJustifyContentTest3() { ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(6.0f, flexItemInfo.getRectangle().getWidth(), EPS); - Assert.assertEquals(75.0f, flexItemInfo.getRectangle().getHeight(), EPS); - Assert.assertEquals(94.0f, flexItemInfo.getRectangle().getX(), EPS); + Assertions.assertEquals(6.0f, flexItemInfo.getRectangle().getWidth(), EPS); + Assertions.assertEquals(75.0f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(94.0f, flexItemInfo.getRectangle().getX(), EPS); } - Assert.assertEquals(87.5f, line.get(0).getRectangle().getY(), EPS); + Assertions.assertEquals(87.5f, line.get(0).getRectangle().getY(), EPS); } } @@ -777,10 +776,10 @@ public void imgAsFlexItemTest01() throws MalformedURLException { List> rectangleTable = FlexUtil.calculateChildrenRectangles(bBox, (FlexContainerRenderer) div.getRenderer()); - Assert.assertEquals(100f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(100f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); - Assert.assertEquals(40f, rectangleTable.get(0).get(0).getRectangle().getHeight(), EPS); - Assert.assertEquals(30f, rectangleTable.get(0).get(1).getRectangle().getHeight(), EPS); + Assertions.assertEquals(100f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(100f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); + Assertions.assertEquals(40f, rectangleTable.get(0).get(0).getRectangle().getHeight(), EPS); + Assertions.assertEquals(30f, rectangleTable.get(0).get(1).getRectangle().getHeight(), EPS); } @Test @@ -793,11 +792,11 @@ public void basisGtWidthGrow0Shrink0Test01() { ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(500f, flexItemInfo.getRectangle().getWidth(), EPS); - Assert.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(500f, flexItemInfo.getRectangle().getWidth(), EPS); + Assertions.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); } } } @@ -812,11 +811,11 @@ public void basisGtWidthGrow0Shrink1Test01() { ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(400f, flexItemInfo.getRectangle().getWidth(), EPS); - Assert.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(400f, flexItemInfo.getRectangle().getWidth(), EPS); + Assertions.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); } } } @@ -829,11 +828,11 @@ public void basisMinGrow0Shrink1Item2Grow05Test01() { Arrays.asList(1f, 1f, 1f)); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (int i = 0; i < rectangleTable.size(); i++) { FlexItemInfo flexItemInfo = rectangleTable.get(0).get(i); - Assert.assertEquals(i == 1 ? 197 : 6f, flexItemInfo.getRectangle().getWidth(), EPS); - Assert.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(i == 1 ? 197 : 6f, flexItemInfo.getRectangle().getWidth(), EPS); + Assertions.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); } } @@ -845,11 +844,11 @@ public void basisMinGrow0Shrink1Item2Grow2Test01() { Arrays.asList(1f, 1f, 1f)); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (int i = 0; i < rectangleTable.size(); i++) { FlexItemInfo flexItemInfo = rectangleTable.get(0).get(i); - Assert.assertEquals(i == 1 ? 388f : 6f, flexItemInfo.getRectangle().getWidth(), EPS); - Assert.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(i == 1 ? 388f : 6f, flexItemInfo.getRectangle().getWidth(), EPS); + Assertions.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); } } @@ -861,11 +860,11 @@ public void basisMinGrow2Shrink1Test01() { Arrays.asList(1f, 1f, 1f)); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(400f / 3, flexItemInfo.getRectangle().getWidth(), EPS); - Assert.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(400f / 3, flexItemInfo.getRectangle().getWidth(), EPS); + Assertions.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); } } } @@ -878,11 +877,11 @@ public void basisMinGrow05SumGt1Shrink1Test01() { Arrays.asList(1f, 1f, 1f)); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(400f / 3, flexItemInfo.getRectangle().getWidth(), EPS); - Assert.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(400f / 3, flexItemInfo.getRectangle().getWidth(), EPS); + Assertions.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); } } } @@ -895,11 +894,11 @@ public void basisMinGrow01SumLt1Shrink1Test01() { Arrays.asList(1f, 1f, 1f)); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(44.2f, flexItemInfo.getRectangle().getWidth(), EPS); - Assert.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(44.2f, flexItemInfo.getRectangle().getWidth(), EPS); + Assertions.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); } } } @@ -912,11 +911,11 @@ public void basisMinGrow0Shrink05SumGt1Test01() { Arrays.asList(0.5f, 0.5f, 0.5f)); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(6f, flexItemInfo.getRectangle().getWidth(), EPS); - Assert.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(6f, flexItemInfo.getRectangle().getWidth(), EPS); + Assertions.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); } } } @@ -929,11 +928,11 @@ public void basisMinGrow0Shrink01SumLt1Test01() { Arrays.asList(0.1f, 0.1f, 0.1f)); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(6f, flexItemInfo.getRectangle().getWidth(), EPS); - Assert.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(6f, flexItemInfo.getRectangle().getWidth(), EPS); + Assertions.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); } } } @@ -950,11 +949,11 @@ public void basis50SumLtWidthGrow0Shrink1Test01() { ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(50f, flexItemInfo.getRectangle().getWidth(), EPS); - Assert.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(50f, flexItemInfo.getRectangle().getWidth(), EPS); + Assertions.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); } } } @@ -971,11 +970,11 @@ public void basis250SumGtWidthGrow0Shrink1Test01() { ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(400f / 3, flexItemInfo.getRectangle().getWidth(), EPS); - Assert.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(400f / 3, flexItemInfo.getRectangle().getWidth(), EPS); + Assertions.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); } } } @@ -992,15 +991,15 @@ public void differentBasisSumLtWidthGrow0Shrink1Test01() { ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); } } - Assert.assertEquals(50f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(80f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); - Assert.assertEquals(100f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); + Assertions.assertEquals(50f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(80f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); + Assertions.assertEquals(100f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); } @Test @@ -1015,15 +1014,15 @@ public void differentBasisSumLtWidthGrow1Shrink1Test01() { ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); } } - Assert.assertEquals(106.66667f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(136.66667f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); - Assert.assertEquals(156.66667f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); + Assertions.assertEquals(106.66667f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(136.66667f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); + Assertions.assertEquals(156.66667f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); } @Test @@ -1061,9 +1060,9 @@ public void differentBasisSumLtWidthGrow1Shrink0Item2MarginBorderPadding30Test01 List> rectangleTable = FlexUtil.calculateChildrenRectangles(bBox, (FlexContainerRenderer) div.getRenderer()); - Assert.assertEquals(86.66667f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(176.66667f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); - Assert.assertEquals(136.66667f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); + Assertions.assertEquals(86.66667f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(176.66667f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); + Assertions.assertEquals(136.66667f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); } @Test @@ -1100,9 +1099,9 @@ public void differentBasisSumLtWidthGrow1Shrink1Item2MarginBorderPadding30Test01 List> rectangleTable = FlexUtil.calculateChildrenRectangles(bBox, (FlexContainerRenderer) div.getRenderer()); - Assert.assertEquals(30.434784f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(108.69565f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); - Assert.assertEquals(60.869568f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); + Assertions.assertEquals(30.434784f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(108.69565f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); + Assertions.assertEquals(60.869568f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); } @Test @@ -1141,13 +1140,13 @@ public void ltWidthGrow0Shrink1Item2MarginBorderPadding30Test01() { List> rectangleTable = FlexUtil.calculateChildrenRectangles(bBox, (FlexContainerRenderer) div.getRenderer()); - Assert.assertEquals(192.03125f, rectangleTable.get(0).get(0).getRectangle().getHeight(), EPS); - Assert.assertEquals(110.0f, rectangleTable.get(0).get(1).getRectangle().getHeight(), EPS); - Assert.assertEquals(107.96875f, rectangleTable.get(1).get(0).getRectangle().getHeight(), EPS); + Assertions.assertEquals(192.03125f, rectangleTable.get(0).get(0).getRectangle().getHeight(), EPS); + Assertions.assertEquals(110.0f, rectangleTable.get(0).get(1).getRectangle().getHeight(), EPS); + Assertions.assertEquals(107.96875f, rectangleTable.get(1).get(0).getRectangle().getHeight(), EPS); - Assert.assertEquals(50.0f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(110.0f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); - Assert.assertEquals(50.0f, rectangleTable.get(1).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(50.0f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(110.0f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); + Assertions.assertEquals(50.0f, rectangleTable.get(1).get(0).getRectangle().getWidth(), EPS); } @Test @@ -1188,21 +1187,21 @@ public void ltWidthGrow0Shrink1Item2MBP30JustifyContentCenterTest() { List> rectangleTable = FlexUtil.calculateChildrenRectangles(bBox, (FlexContainerRenderer) div.getRenderer()); - Assert.assertEquals(25.9375f, rectangleTable.get(0).get(0).getRectangle().getHeight(), EPS); - Assert.assertEquals(110.0f, rectangleTable.get(0).get(1).getRectangle().getHeight(), EPS); - Assert.assertEquals(25.9375f, rectangleTable.get(1).get(0).getRectangle().getHeight(), EPS); + Assertions.assertEquals(25.9375f, rectangleTable.get(0).get(0).getRectangle().getHeight(), EPS); + Assertions.assertEquals(110.0f, rectangleTable.get(0).get(1).getRectangle().getHeight(), EPS); + Assertions.assertEquals(25.9375f, rectangleTable.get(1).get(0).getRectangle().getHeight(), EPS); - Assert.assertEquals(50.0f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(110.0f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); - Assert.assertEquals(50.0f, rectangleTable.get(1).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(50.0f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(110.0f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); + Assertions.assertEquals(50.0f, rectangleTable.get(1).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(20.0f, rectangleTable.get(0).get(0).getRectangle().getX(), EPS); - Assert.assertEquals(0f, rectangleTable.get(0).get(1).getRectangle().getX(), EPS); - Assert.assertEquals(75.0f, rectangleTable.get(1).get(0).getRectangle().getX(), EPS); + Assertions.assertEquals(20.0f, rectangleTable.get(0).get(0).getRectangle().getX(), EPS); + Assertions.assertEquals(0f, rectangleTable.get(0).get(1).getRectangle().getX(), EPS); + Assertions.assertEquals(75.0f, rectangleTable.get(1).get(0).getRectangle().getX(), EPS); - Assert.assertEquals(83.046875f, rectangleTable.get(0).get(0).getRectangle().getY(), EPS); - Assert.assertEquals(41.015625f, rectangleTable.get(0).get(1).getRectangle().getY(), EPS); - Assert.assertEquals(82.03125f, rectangleTable.get(1).get(0).getRectangle().getY(), EPS); + Assertions.assertEquals(83.046875f, rectangleTable.get(0).get(0).getRectangle().getY(), EPS); + Assertions.assertEquals(41.015625f, rectangleTable.get(0).get(1).getRectangle().getY(), EPS); + Assertions.assertEquals(82.03125f, rectangleTable.get(1).get(0).getRectangle().getY(), EPS); } @Test @@ -1260,21 +1259,21 @@ public void ltWidthGrow0Shrink1Item2MBP30JustifyContentFlexStartTest() { List> rectangleTable = FlexUtil.calculateChildrenRectangles(bBox, (FlexContainerRenderer) div.getRenderer()); - Assert.assertEquals(25.9375f, rectangleTable.get(0).get(0).getRectangle().getHeight(), EPS); - Assert.assertEquals(110.0f, rectangleTable.get(0).get(1).getRectangle().getHeight(), EPS); - Assert.assertEquals(25.9375f, rectangleTable.get(1).get(0).getRectangle().getHeight(), EPS); + Assertions.assertEquals(25.9375f, rectangleTable.get(0).get(0).getRectangle().getHeight(), EPS); + Assertions.assertEquals(110.0f, rectangleTable.get(0).get(1).getRectangle().getHeight(), EPS); + Assertions.assertEquals(25.9375f, rectangleTable.get(1).get(0).getRectangle().getHeight(), EPS); - Assert.assertEquals(50.0f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(110.0f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); - Assert.assertEquals(50.0f, rectangleTable.get(1).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(50.0f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(110.0f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); + Assertions.assertEquals(50.0f, rectangleTable.get(1).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(0f, rectangleTable.get(0).get(0).getRectangle().getX(), EPS); - Assert.assertEquals(0f, rectangleTable.get(0).get(1).getRectangle().getX(), EPS); - Assert.assertEquals(0f, rectangleTable.get(1).get(0).getRectangle().getX(), EPS); + Assertions.assertEquals(0f, rectangleTable.get(0).get(0).getRectangle().getX(), EPS); + Assertions.assertEquals(0f, rectangleTable.get(0).get(1).getRectangle().getX(), EPS); + Assertions.assertEquals(0f, rectangleTable.get(1).get(0).getRectangle().getX(), EPS); - Assert.assertEquals(0f, rectangleTable.get(0).get(0).getRectangle().getY(), EPS); - Assert.assertEquals(0f, rectangleTable.get(0).get(1).getRectangle().getY(), EPS); - Assert.assertEquals(82.03125f, rectangleTable.get(1).get(0).getRectangle().getY(), EPS); + Assertions.assertEquals(0f, rectangleTable.get(0).get(0).getRectangle().getY(), EPS); + Assertions.assertEquals(0f, rectangleTable.get(0).get(1).getRectangle().getY(), EPS); + Assertions.assertEquals(82.03125f, rectangleTable.get(1).get(0).getRectangle().getY(), EPS); } } @@ -1329,21 +1328,21 @@ public void ltWidthGrow0Shrink1Item2MBP30JustifyContentFlexEndTest() { List> rectangleTable = FlexUtil.calculateChildrenRectangles(bBox, (FlexContainerRenderer) div.getRenderer()); - Assert.assertEquals(25.9375f, rectangleTable.get(0).get(0).getRectangle().getHeight(), EPS); - Assert.assertEquals(110.0f, rectangleTable.get(0).get(1).getRectangle().getHeight(), EPS); - Assert.assertEquals(25.9375f, rectangleTable.get(1).get(0).getRectangle().getHeight(), EPS); + Assertions.assertEquals(25.9375f, rectangleTable.get(0).get(0).getRectangle().getHeight(), EPS); + Assertions.assertEquals(110.0f, rectangleTable.get(0).get(1).getRectangle().getHeight(), EPS); + Assertions.assertEquals(25.9375f, rectangleTable.get(1).get(0).getRectangle().getHeight(), EPS); - Assert.assertEquals(50.0f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(110.0f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); - Assert.assertEquals(50.0f, rectangleTable.get(1).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(50.0f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(110.0f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); + Assertions.assertEquals(50.0f, rectangleTable.get(1).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(40.0f, rectangleTable.get(0).get(0).getRectangle().getX(), EPS); - Assert.assertEquals(0f, rectangleTable.get(0).get(1).getRectangle().getX(), EPS); - Assert.assertEquals(150.0f, rectangleTable.get(1).get(0).getRectangle().getX(), EPS); + Assertions.assertEquals(40.0f, rectangleTable.get(0).get(0).getRectangle().getX(), EPS); + Assertions.assertEquals(0f, rectangleTable.get(0).get(1).getRectangle().getX(), EPS); + Assertions.assertEquals(150.0f, rectangleTable.get(1).get(0).getRectangle().getX(), EPS); - Assert.assertEquals(166.09375f, rectangleTable.get(0).get(0).getRectangle().getY(), EPS); - Assert.assertEquals(82.03125f, rectangleTable.get(0).get(1).getRectangle().getY(), EPS); - Assert.assertEquals(82.03125f, rectangleTable.get(1).get(0).getRectangle().getY(), EPS); + Assertions.assertEquals(166.09375f, rectangleTable.get(0).get(0).getRectangle().getY(), EPS); + Assertions.assertEquals(82.03125f, rectangleTable.get(0).get(1).getRectangle().getY(), EPS); + Assertions.assertEquals(82.03125f, rectangleTable.get(1).get(0).getRectangle().getY(), EPS); } } @@ -1389,21 +1388,21 @@ public void ltWidthGrow0Shrink1Item2MBP30AlignItemsStretchTest() { List> rectangleTable = FlexUtil.calculateChildrenRectangles(bBox, (FlexContainerRenderer) div.getRenderer()); - Assert.assertEquals(192.03125f, rectangleTable.get(0).get(0).getRectangle().getHeight(), EPS); - Assert.assertEquals(110.0f, rectangleTable.get(0).get(1).getRectangle().getHeight(), EPS); - Assert.assertEquals(107.96875f, rectangleTable.get(1).get(0).getRectangle().getHeight(), EPS); + Assertions.assertEquals(192.03125f, rectangleTable.get(0).get(0).getRectangle().getHeight(), EPS); + Assertions.assertEquals(110.0f, rectangleTable.get(0).get(1).getRectangle().getHeight(), EPS); + Assertions.assertEquals(107.96875f, rectangleTable.get(1).get(0).getRectangle().getHeight(), EPS); - Assert.assertEquals(50.0f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(110.0f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); - Assert.assertEquals(50.0f, rectangleTable.get(1).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(50.0f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(110.0f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); + Assertions.assertEquals(50.0f, rectangleTable.get(1).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(0f, rectangleTable.get(0).get(0).getRectangle().getX(), EPS); - Assert.assertEquals(0f, rectangleTable.get(0).get(1).getRectangle().getX(), EPS); - Assert.assertEquals(0f, rectangleTable.get(1).get(0).getRectangle().getX(), EPS); + Assertions.assertEquals(0f, rectangleTable.get(0).get(0).getRectangle().getX(), EPS); + Assertions.assertEquals(0f, rectangleTable.get(0).get(1).getRectangle().getX(), EPS); + Assertions.assertEquals(0f, rectangleTable.get(1).get(0).getRectangle().getX(), EPS); - Assert.assertEquals(0f, rectangleTable.get(0).get(0).getRectangle().getY(), EPS); - Assert.assertEquals(0f, rectangleTable.get(0).get(1).getRectangle().getY(), EPS); - Assert.assertEquals(0f, rectangleTable.get(1).get(0).getRectangle().getY(), EPS); + Assertions.assertEquals(0f, rectangleTable.get(0).get(0).getRectangle().getY(), EPS); + Assertions.assertEquals(0f, rectangleTable.get(0).get(1).getRectangle().getY(), EPS); + Assertions.assertEquals(0f, rectangleTable.get(1).get(0).getRectangle().getY(), EPS); } } @@ -1444,21 +1443,21 @@ public void ltWidthGrow0Shrink1Item2MBP30JustifyContentCenterDontFitTest() { List> rectangleTable = FlexUtil.calculateChildrenRectangles(bBox, (FlexContainerRenderer) div.getRenderer()); - Assert.assertEquals(25.9375f, rectangleTable.get(0).get(0).getRectangle().getHeight(), EPS); - Assert.assertEquals(280.0f, rectangleTable.get(0).get(1).getRectangle().getHeight(), EPS); - Assert.assertEquals(25.9375f, rectangleTable.get(0).get(2).getRectangle().getHeight(), EPS); + Assertions.assertEquals(25.9375f, rectangleTable.get(0).get(0).getRectangle().getHeight(), EPS); + Assertions.assertEquals(280.0f, rectangleTable.get(0).get(1).getRectangle().getHeight(), EPS); + Assertions.assertEquals(25.9375f, rectangleTable.get(0).get(2).getRectangle().getHeight(), EPS); - Assert.assertEquals(100.0f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(160.0f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); - Assert.assertEquals(100.0f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); + Assertions.assertEquals(100.0f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(160.0f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); + Assertions.assertEquals(100.0f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); - Assert.assertEquals(-80.0f, rectangleTable.get(0).get(0).getRectangle().getX(), EPS); - Assert.assertEquals(0f, rectangleTable.get(0).get(1).getRectangle().getX(), EPS); - Assert.assertEquals(0f, rectangleTable.get(0).get(2).getRectangle().getX(), EPS); + Assertions.assertEquals(-80.0f, rectangleTable.get(0).get(0).getRectangle().getX(), EPS); + Assertions.assertEquals(0f, rectangleTable.get(0).get(1).getRectangle().getX(), EPS); + Assertions.assertEquals(0f, rectangleTable.get(0).get(2).getRectangle().getX(), EPS); - Assert.assertEquals(87.03125f, rectangleTable.get(0).get(0).getRectangle().getY(), EPS); - Assert.assertEquals(-40.0f, rectangleTable.get(0).get(1).getRectangle().getY(), EPS); - Assert.assertEquals(87.03125f, rectangleTable.get(0).get(2).getRectangle().getY(), EPS); + Assertions.assertEquals(87.03125f, rectangleTable.get(0).get(0).getRectangle().getY(), EPS); + Assertions.assertEquals(-40.0f, rectangleTable.get(0).get(1).getRectangle().getY(), EPS); + Assertions.assertEquals(87.03125f, rectangleTable.get(0).get(2).getRectangle().getY(), EPS); } @Test @@ -1501,9 +1500,9 @@ public void differentBasisSumLtWidthGrow1Shrink1Item2MuchContentTest01() { List> rectangleTable = FlexUtil.calculateChildrenRectangles(bBox, (FlexContainerRenderer) div.getRenderer()); - Assert.assertEquals(41.250023f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(179.99995f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); - Assert.assertEquals(78.75002f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); + Assertions.assertEquals(41.250023f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(179.99995f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); + Assertions.assertEquals(78.75002f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); } @Test @@ -1548,9 +1547,9 @@ public void differentBasisSumLtWidthGrow1Shrink1Item2MuchContentSetMinWidthLtBas List> rectangleTable = FlexUtil.calculateChildrenRectangles(bBox, (FlexContainerRenderer) div.getRenderer()); - Assert.assertEquals(80f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(102.5f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); - Assert.assertEquals(117.5f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); + Assertions.assertEquals(80f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(102.5f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); + Assertions.assertEquals(117.5f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); } @Test @@ -1588,9 +1587,9 @@ public void differentBasisSumLtWidthGrow1Shrink1Item2MaxWidthLtBasisTest01() { List> rectangleTable = FlexUtil.calculateChildrenRectangles(bBox, (FlexContainerRenderer) div.getRenderer()); - Assert.assertEquals(150f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(50f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); - Assert.assertEquals(200f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); + Assertions.assertEquals(150f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(50f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); + Assertions.assertEquals(200f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); } @Test @@ -1628,9 +1627,9 @@ public void differentBasisSumLtWidthGrow1Shrink1Item2MaxWidthLtBasisTest02() { List> rectangleTable = FlexUtil.calculateChildrenRectangles(bBox, (FlexContainerRenderer) div.getRenderer()); - Assert.assertEquals(23.333332f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(30f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); - Assert.assertEquals(46.666664f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); + Assertions.assertEquals(23.333332f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(30f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); + Assertions.assertEquals(46.666664f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); } @Test @@ -1667,9 +1666,9 @@ public void differentBasisSumLtWidthGrow1Shrink1Item2MaxWidthLtBasisTest03() { List> rectangleTable = FlexUtil.calculateChildrenRectangles(bBox, (FlexContainerRenderer) div.getRenderer()); - Assert.assertEquals(35f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(30f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); - Assert.assertEquals(35f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); + Assertions.assertEquals(35f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(30f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); + Assertions.assertEquals(35f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); } @Test @@ -1707,9 +1706,9 @@ public void differentBasisSumGtWidthGrow1Shrink1Item1MinWidthGtBasisTest01() { List> rectangleTable = FlexUtil.calculateChildrenRectangles(bBox, (FlexContainerRenderer) div.getRenderer()); - Assert.assertEquals(150f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(107.14285f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); - Assert.assertEquals(142.85715f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); + Assertions.assertEquals(150f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(107.14285f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); + Assertions.assertEquals(142.85715f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); } @Test @@ -1750,8 +1749,8 @@ public void imgGtUsedWidthTest01() throws MalformedURLException { List> rectangleTable = FlexUtil.calculateChildrenRectangles(bBox, (FlexContainerRenderer) div.getRenderer()); - Assert.assertEquals(50f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(30f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); + Assertions.assertEquals(50f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(30f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); } @Test @@ -1796,9 +1795,9 @@ public void differentBasisSumLtWidthGrow1Shrink1Item2MuchContentSetMinWidthGtBas List> rectangleTable = FlexUtil.calculateChildrenRectangles(bBox, (FlexContainerRenderer) div.getRenderer()); - Assert.assertEquals(80f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(102.5f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); - Assert.assertEquals(117.5f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); + Assertions.assertEquals(80f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(102.5f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); + Assertions.assertEquals(117.5f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); } @Test @@ -1842,8 +1841,8 @@ public void basis1Grow0Test01() { List> rectangleTable = FlexUtil.calculateChildrenRectangles(bBox, (FlexContainerRenderer) div.getRenderer()); - Assert.assertEquals(60f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(30f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); + Assertions.assertEquals(60f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(30f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); } @Test @@ -1888,9 +1887,9 @@ public void differentBasisSumLtWidthGrow1Shrink1Item2MuchContentSetMinWidthGtBas List> rectangleTable = FlexUtil.calculateChildrenRectangles(bBox, (FlexContainerRenderer) div.getRenderer()); - Assert.assertEquals(56.25f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(150f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); - Assert.assertEquals(93.75f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); + Assertions.assertEquals(56.25f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(150f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); + Assertions.assertEquals(93.75f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); } @Test @@ -1935,9 +1934,9 @@ public void differentBasisSumLtWidthGrow1Shrink1Item2MuchContentSetMinWidthGtBas List> rectangleTable = FlexUtil.calculateChildrenRectangles(bBox, (FlexContainerRenderer) div.getRenderer()); - Assert.assertEquals(56.25f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(150f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); - Assert.assertEquals(93.75f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); + Assertions.assertEquals(56.25f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(150f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); + Assertions.assertEquals(93.75f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); } @Test @@ -1953,20 +1952,20 @@ public void differentBasisSumEqWidthGrow1Shrink1Item2Basis0Test01() { ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); - Assert.assertEquals(1, rectangleTable.get(0).size()); - Assert.assertEquals(2, rectangleTable.get(1).size()); + Assertions.assertEquals(1, rectangleTable.get(0).size()); + Assertions.assertEquals(2, rectangleTable.get(1).size()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(50.0f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(50.0f, flexItemInfo.getRectangle().getHeight(), EPS); } } - Assert.assertEquals(400f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(150f, rectangleTable.get(1).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(250f, rectangleTable.get(1).get(1).getRectangle().getWidth(), EPS); + Assertions.assertEquals(400f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(150f, rectangleTable.get(1).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(250f, rectangleTable.get(1).get(1).getRectangle().getWidth(), EPS); } @Test @@ -2004,12 +2003,12 @@ public void differentBasisSumEqWidthGrow1Shrink1Item2Basis0NoContentTest02() { List> rectangleTable = FlexUtil.calculateChildrenRectangles(bBox, (FlexContainerRenderer) div.getRenderer()); - Assert.assertEquals(2, rectangleTable.get(0).size()); - Assert.assertEquals(1, rectangleTable.get(1).size()); + Assertions.assertEquals(2, rectangleTable.get(0).size()); + Assertions.assertEquals(1, rectangleTable.get(1).size()); - Assert.assertEquals(400f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(0f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); - Assert.assertEquals(400f, rectangleTable.get(1).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(400f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(0f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); + Assertions.assertEquals(400f, rectangleTable.get(1).get(0).getRectangle().getWidth(), EPS); } @Test @@ -2024,15 +2023,15 @@ public void differentBasisSumLtWidthGrow0Shrink0Test01() { ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); } } - Assert.assertEquals(50f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(80f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); - Assert.assertEquals(100f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); + Assertions.assertEquals(50f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(80f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); + Assertions.assertEquals(100f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); } @Test @@ -2047,15 +2046,15 @@ public void differentBasisSumLtWidthGrow0Shrink0Item2Grow2Test01() { ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); } } - Assert.assertEquals(50f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(250f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); - Assert.assertEquals(100f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); + Assertions.assertEquals(50f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(250f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); + Assertions.assertEquals(100f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); } @Test @@ -2070,15 +2069,15 @@ public void differentBasisSumLtWidthGrow1Shrink0Test01() { ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); } } - Assert.assertEquals(106.66667f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(136.66667f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); - Assert.assertEquals(156.66667f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); + Assertions.assertEquals(106.66667f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(136.66667f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); + Assertions.assertEquals(156.66667f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); } @Test @@ -2093,15 +2092,15 @@ public void differentBasisSumGtWidthGrow0Shrink1Test01() { ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); } } - Assert.assertEquals(200f / 3, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(400f / 3, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); - Assert.assertEquals(600f / 3, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); + Assertions.assertEquals(200f / 3, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(400f / 3, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); + Assertions.assertEquals(600f / 3, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); } @Test @@ -2116,15 +2115,15 @@ public void differentBasisSumGtWidthGrow0Shrink05Test01() { ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); } } - Assert.assertEquals(200f / 3, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(400f / 3, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); - Assert.assertEquals(600f / 3, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); + Assertions.assertEquals(200f / 3, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(400f / 3, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); + Assertions.assertEquals(600f / 3, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); } @Test @@ -2139,15 +2138,15 @@ public void differentBasisSumGtWidthGrow0Shrink01Test01() { ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); } } - Assert.assertEquals(90f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(180f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); - Assert.assertEquals(270f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); + Assertions.assertEquals(90f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(180f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); + Assertions.assertEquals(270f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); } @Test @@ -2162,15 +2161,15 @@ public void differentBasisSumGtWidthGrow0Shrink5Test01() { ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); } } - Assert.assertEquals(200f / 3, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(400f / 3, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); - Assert.assertEquals(600f / 3, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); + Assertions.assertEquals(200f / 3, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(400f / 3, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); + Assertions.assertEquals(600f / 3, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); } @Test @@ -2185,15 +2184,15 @@ public void differentBasisSumGtWidthGrow1Shrink1Test01() { ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); } } - Assert.assertEquals(200f / 3, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(400f / 3, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); - Assert.assertEquals(600f / 3, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); + Assertions.assertEquals(200f / 3, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(400f / 3, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); + Assertions.assertEquals(600f / 3, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); } @Test @@ -2208,15 +2207,15 @@ public void differentBasisSumGtWidthGrow1Shrink1Item3Shrink50Test01() { ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); } } - Assert.assertEquals(98.69281f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(197.38562f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); - Assert.assertEquals(103.92157f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); + Assertions.assertEquals(98.69281f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(197.38562f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); + Assertions.assertEquals(103.92157f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); } @Test @@ -2231,15 +2230,15 @@ public void differentBasisSumGtWidthGrow1Shrink1Item3Shrink5Test01() { ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); } } - Assert.assertEquals(88.888885f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(177.77777f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); - Assert.assertEquals(133.33334f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); + Assertions.assertEquals(88.888885f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(177.77777f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); + Assertions.assertEquals(133.33334f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); } @Test @@ -2254,15 +2253,15 @@ public void differentBasisSumGtWidthGrow0Shrink0Test01() { ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); } } - Assert.assertEquals(100f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(200f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); - Assert.assertEquals(300f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); + Assertions.assertEquals(100f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(200f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); + Assertions.assertEquals(300f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); } @Test @@ -2277,15 +2276,15 @@ public void differentBasisSumGtWidthGrow1Shrink0Test01() { ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); } } - Assert.assertEquals(100f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(200f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); - Assert.assertEquals(300f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); + Assertions.assertEquals(100f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(200f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); + Assertions.assertEquals(300f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); } @Test @@ -2301,11 +2300,11 @@ public void basis250SumGtWidthGrow0Shrink1WrapTest01() { ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(250f, flexItemInfo.getRectangle().getWidth(), EPS); - Assert.assertEquals(33.333332f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(250f, flexItemInfo.getRectangle().getWidth(), EPS); + Assertions.assertEquals(33.333332f, flexItemInfo.getRectangle().getHeight(), EPS); } } } @@ -2323,15 +2322,15 @@ public void differentBasisSumGtWidthGrow0Shrink1WrapTest01() { ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(50.0f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(50.0f, flexItemInfo.getRectangle().getHeight(), EPS); } } - Assert.assertEquals(100f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(200f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); - Assert.assertEquals(300f, rectangleTable.get(1).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(100f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(200f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); + Assertions.assertEquals(300f, rectangleTable.get(1).get(0).getRectangle().getWidth(), EPS); } @Test @@ -2347,15 +2346,15 @@ public void differentBasisSumGtWidthGrow0Shrink05WrapTest01() { ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(50.0f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(50.0f, flexItemInfo.getRectangle().getHeight(), EPS); } } - Assert.assertEquals(100f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(200f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); - Assert.assertEquals(300f, rectangleTable.get(1).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(100f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(200f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); + Assertions.assertEquals(300f, rectangleTable.get(1).get(0).getRectangle().getWidth(), EPS); } @Test @@ -2371,15 +2370,15 @@ public void differentBasisSumGtWidthGrow0Shrink01WrapTest01() { ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(50.0f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(50.0f, flexItemInfo.getRectangle().getHeight(), EPS); } } - Assert.assertEquals(100f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(200f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); - Assert.assertEquals(300f, rectangleTable.get(1).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(100f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(200f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); + Assertions.assertEquals(300f, rectangleTable.get(1).get(0).getRectangle().getWidth(), EPS); } @Test @@ -2395,15 +2394,15 @@ public void differentBasisSumGtWidthGrow0Shrink5WrapTest01() { ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(50.0f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(50.0f, flexItemInfo.getRectangle().getHeight(), EPS); } } - Assert.assertEquals(100f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(200f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); - Assert.assertEquals(300f, rectangleTable.get(1).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(100f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(200f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); + Assertions.assertEquals(300f, rectangleTable.get(1).get(0).getRectangle().getWidth(), EPS); } @Test @@ -2419,15 +2418,15 @@ public void differentBasisSumGtWidthGrow1Shrink1WrapTest01() { ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(50.0f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(50.0f, flexItemInfo.getRectangle().getHeight(), EPS); } } - Assert.assertEquals(150f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(250f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); - Assert.assertEquals(400f, rectangleTable.get(1).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(150f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(250f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); + Assertions.assertEquals(400f, rectangleTable.get(1).get(0).getRectangle().getWidth(), EPS); } @Test @@ -2443,15 +2442,15 @@ public void differentBasisSumGtWidthGrow1Shrink1Item3Shrink50WrapTest01() { ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(50.0f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(50.0f, flexItemInfo.getRectangle().getHeight(), EPS); } } - Assert.assertEquals(150f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(250f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); - Assert.assertEquals(400f, rectangleTable.get(1).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(150f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(250f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); + Assertions.assertEquals(400f, rectangleTable.get(1).get(0).getRectangle().getWidth(), EPS); } @Test @@ -2467,15 +2466,15 @@ public void differentBasisSumGtWidthGrow1Shrink1Item3Shrink5WrapTest01() { ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(50.0f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(50.0f, flexItemInfo.getRectangle().getHeight(), EPS); } } - Assert.assertEquals(150f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(250f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); - Assert.assertEquals(400f, rectangleTable.get(1).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(150f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(250f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); + Assertions.assertEquals(400f, rectangleTable.get(1).get(0).getRectangle().getWidth(), EPS); } @Test @@ -2491,15 +2490,15 @@ public void differentBasisSumGtWidthGrow0Shrink0WrapTest01() { ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(50.0f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(50.0f, flexItemInfo.getRectangle().getHeight(), EPS); } } - Assert.assertEquals(100f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(200f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); - Assert.assertEquals(300f, rectangleTable.get(1).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(100f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(200f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); + Assertions.assertEquals(300f, rectangleTable.get(1).get(0).getRectangle().getWidth(), EPS); } @Test @@ -2515,15 +2514,15 @@ public void differentBasisSumGtWidthGrow1Shrink0WrapTest01() { ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(50.0f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(50.0f, flexItemInfo.getRectangle().getHeight(), EPS); } } - Assert.assertEquals(150f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(250f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); - Assert.assertEquals(400f, rectangleTable.get(1).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(150f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(250f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); + Assertions.assertEquals(400f, rectangleTable.get(1).get(0).getRectangle().getWidth(), EPS); } @Test @@ -2538,15 +2537,15 @@ public void differentBasisPercentSumLtWidthGrow0Shrink1Test01() { ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); } } - Assert.assertEquals(40f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(80f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); - Assert.assertEquals(120f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); + Assertions.assertEquals(40f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(80f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); + Assertions.assertEquals(120f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); } @Test @@ -2561,15 +2560,15 @@ public void differentBasisPercentSumLtWidthGrow1Shrink1Test01() { ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); } } - Assert.assertEquals(93.333336f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(133.33333f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); - Assert.assertEquals(173.33333f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); + Assertions.assertEquals(93.333336f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(133.33333f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); + Assertions.assertEquals(173.33333f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); } @Test @@ -2584,15 +2583,15 @@ public void differentBasisPercentSumLtWidthGrow0Shrink0Test01() { ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); } } - Assert.assertEquals(40f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(80f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); - Assert.assertEquals(120f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); + Assertions.assertEquals(40f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(80f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); + Assertions.assertEquals(120f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); } @Test @@ -2607,15 +2606,15 @@ public void differentBasisPercentSumLtWidthGrow0Shrink0Item2Grow2Test01() { ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); } } - Assert.assertEquals(40f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(240f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); - Assert.assertEquals(120f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); + Assertions.assertEquals(40f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(240f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); + Assertions.assertEquals(120f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); } @Test @@ -2630,15 +2629,15 @@ public void differentBasisPercentSumLtWidthGrow1Shrink0Test01() { ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); } } - Assert.assertEquals(93.333336f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(133.33333f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); - Assert.assertEquals(173.33333f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); + Assertions.assertEquals(93.333336f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(133.33333f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); + Assertions.assertEquals(173.33333f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); } @Test @@ -2653,15 +2652,15 @@ public void differentBasisPercentSumGtWidthGrow0Shrink1Test01() { ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); } } - Assert.assertEquals(300f / 3, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(400f / 3, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); - Assert.assertEquals(500f / 3, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); + Assertions.assertEquals(300f / 3, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(400f / 3, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); + Assertions.assertEquals(500f / 3, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); } @Test @@ -2676,15 +2675,15 @@ public void differentBasisPercentSumGtWidthGrow0Shrink05Test01() { ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); } } - Assert.assertEquals(100f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(400f / 3, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); - Assert.assertEquals(500f / 3, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); + Assertions.assertEquals(100f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(400f / 3, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); + Assertions.assertEquals(500f / 3, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); } @Test @@ -2699,15 +2698,15 @@ public void differentBasisPercentSumGtWidthGrow0Shrink01Test01() { ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); } } - Assert.assertEquals(114f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(152f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); - Assert.assertEquals(190f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); + Assertions.assertEquals(114f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(152f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); + Assertions.assertEquals(190f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); } @Test @@ -2722,15 +2721,15 @@ public void differentBasisPercentSumGtWidthGrow0Shrink5Test01() { ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); } } - Assert.assertEquals(300f / 3, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(400f / 3, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); - Assert.assertEquals(500f / 3, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); + Assertions.assertEquals(300f / 3, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(400f / 3, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); + Assertions.assertEquals(500f / 3, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); } @Test @@ -2745,15 +2744,15 @@ public void differentBasisPercentSumGtWidthGrow1Shrink1Test01() { ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); } } - Assert.assertEquals(300f / 3, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(400f / 3, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); - Assert.assertEquals(500f / 3, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); + Assertions.assertEquals(300f / 3, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(400f / 3, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); + Assertions.assertEquals(500f / 3, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); } @Test @@ -2768,15 +2767,15 @@ public void differentBasisPercentSumGtWidthGrow1Shrink1Item3Shrink50Test01() { ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); } } - Assert.assertEquals(119.06615f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(158.75487f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); - Assert.assertEquals(122.178986f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); + Assertions.assertEquals(119.06615f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(158.75487f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); + Assertions.assertEquals(122.178986f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); } @Test @@ -2791,15 +2790,15 @@ public void differentBasisPercentSumGtWidthGrow1Shrink1Item3Shrink5Test01() { ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); } } - Assert.assertEquals(112.5f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(150f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); - Assert.assertEquals(137.5f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); + Assertions.assertEquals(112.5f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(150f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); + Assertions.assertEquals(137.5f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); } @Test @@ -2814,15 +2813,15 @@ public void differentBasisPercentSumGtWidthGrow0Shrink0Test01() { ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); } } - Assert.assertEquals(120f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(160f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); - Assert.assertEquals(200f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); + Assertions.assertEquals(120f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(160f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); + Assertions.assertEquals(200f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); } @Test @@ -2837,16 +2836,16 @@ public void differentBasisPercentSumGtWidthGrow1Shrink0Test01() { ); // after checks - Assert.assertFalse(rectangleTable.isEmpty()); + Assertions.assertFalse(rectangleTable.isEmpty()); for (List line : rectangleTable) { for (FlexItemInfo flexItemInfo : line) { - Assert.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); + Assertions.assertEquals(100.0f, flexItemInfo.getRectangle().getHeight(), EPS); } } - Assert.assertEquals(120f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); - Assert.assertEquals(160f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); - Assert.assertEquals(200f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); + Assertions.assertEquals(120f, rectangleTable.get(0).get(0).getRectangle().getWidth(), EPS); + Assertions.assertEquals(160f, rectangleTable.get(0).get(1).getRectangle().getWidth(), EPS); + Assertions.assertEquals(200f, rectangleTable.get(0).get(2).getRectangle().getWidth(), EPS); } @Test @@ -2856,13 +2855,13 @@ public void calculateMinContentWithMinWidthTest() { divRenderer.setProperty(Property.MIN_WIDTH, UnitValue.createPointValue(30)); FlexUtil.FlexItemCalculationInfo info = createFlexItemCalculationInfo(divRenderer); - Assert.assertEquals(30f, info.minContent, EPS); + Assertions.assertEquals(30f, info.minContent, EPS); divRenderer.setProperty(Property.WIDTH, UnitValue.createPointValue(30)); divRenderer.setProperty(Property.MIN_WIDTH, UnitValue.createPointValue(100)); info = createFlexItemCalculationInfo(divRenderer); - Assert.assertEquals(100f, info.minContent, EPS); + Assertions.assertEquals(100f, info.minContent, EPS); } @Test @@ -2872,7 +2871,7 @@ public void calculateMinContentForDivWithContentTest() { IRenderer divRenderer = div.createRendererSubTree(); FlexUtil.FlexItemCalculationInfo info = createFlexItemCalculationInfo((AbstractRenderer) divRenderer); - Assert.assertEquals(50.0f, info.minContent, EPS); + Assertions.assertEquals(50.0f, info.minContent, EPS); } @Test @@ -2881,7 +2880,7 @@ public void calculateMinContentForDivWithWidthTest() { divRenderer.setProperty(Property.WIDTH, UnitValue.createPointValue(100)); FlexUtil.FlexItemCalculationInfo info = createFlexItemCalculationInfo(divRenderer); - Assert.assertEquals(0.0f, info.minContent, EPS); + Assertions.assertEquals(0.0f, info.minContent, EPS); } @Test @@ -2892,7 +2891,7 @@ public void calculateMinContentForDivWithWidthAndContentTest() { divRenderer.setProperty(Property.WIDTH, UnitValue.createPointValue(100)); FlexUtil.FlexItemCalculationInfo info = createFlexItemCalculationInfo((AbstractRenderer) divRenderer); - Assert.assertEquals(50.0f, info.minContent, EPS); + Assertions.assertEquals(50.0f, info.minContent, EPS); div = new Div(); div.add(new Div().setWidth(150)); @@ -2900,7 +2899,7 @@ public void calculateMinContentForDivWithWidthAndContentTest() { divRenderer.setProperty(Property.WIDTH, UnitValue.createPointValue(100)); info = createFlexItemCalculationInfo((AbstractRenderer) divRenderer); - Assert.assertEquals(100.0f, info.minContent, EPS); + Assertions.assertEquals(100.0f, info.minContent, EPS); } @Test @@ -2912,7 +2911,7 @@ public void calculateMinContentForDivWithWidthMaxWidthAndContentTest() { divRenderer.setProperty(Property.WIDTH, UnitValue.createPointValue(100)); FlexUtil.FlexItemCalculationInfo info = createFlexItemCalculationInfo((AbstractRenderer) divRenderer); - Assert.assertEquals(45.0f, info.minContent, EPS); + Assertions.assertEquals(45.0f, info.minContent, EPS); div = new Div(); div.add(new Div().setWidth(150)); @@ -2921,7 +2920,7 @@ public void calculateMinContentForDivWithWidthMaxWidthAndContentTest() { divRenderer.setProperty(Property.WIDTH, UnitValue.createPointValue(100)); info = createFlexItemCalculationInfo((AbstractRenderer) divRenderer); - Assert.assertEquals(100.0f, info.minContent, EPS); + Assertions.assertEquals(100.0f, info.minContent, EPS); } @Test @@ -2930,7 +2929,7 @@ public void calculateMinContentForImageTest() { IRenderer imageRenderer = image.createRendererSubTree(); FlexUtil.FlexItemCalculationInfo info = createFlexItemCalculationInfo((AbstractRenderer) imageRenderer); - Assert.assertEquals(60.0f, info.minContent, EPS); + Assertions.assertEquals(60.0f, info.minContent, EPS); } @Test @@ -2940,14 +2939,14 @@ public void calculateMinContentForImageWithHeightTest() { IRenderer imageRenderer = image.createRendererSubTree(); FlexUtil.FlexItemCalculationInfo info = createFlexItemCalculationInfo((AbstractRenderer) imageRenderer); - Assert.assertEquals(60.0f, info.minContent, EPS); + Assertions.assertEquals(60.0f, info.minContent, EPS); image = new Image(new PdfFormXObject(new Rectangle(60, 150))); image.setHeight(100); imageRenderer = image.createRendererSubTree(); info = createFlexItemCalculationInfo((AbstractRenderer) imageRenderer); - Assert.assertEquals(40.0f, info.minContent, EPS); + Assertions.assertEquals(40.0f, info.minContent, EPS); } @Test @@ -2959,7 +2958,7 @@ public void calculateMinContentForImageWithHeightAndMinMaxHeightsTest() { IRenderer imageRenderer = image.createRendererSubTree(); FlexUtil.FlexItemCalculationInfo info = createFlexItemCalculationInfo((AbstractRenderer) imageRenderer); - Assert.assertEquals(40.0f, info.minContent, EPS); + Assertions.assertEquals(40.0f, info.minContent, EPS); image = new Image(new PdfFormXObject(new Rectangle(60, 150))); image.setHeight(100); @@ -2968,7 +2967,7 @@ public void calculateMinContentForImageWithHeightAndMinMaxHeightsTest() { imageRenderer = image.createRendererSubTree(); info = createFlexItemCalculationInfo((AbstractRenderer) imageRenderer); - Assert.assertEquals(30.0f, info.minContent, EPS); + Assertions.assertEquals(30.0f, info.minContent, EPS); } @Test @@ -2979,7 +2978,7 @@ public void calculateMinContentForImageWithHeightAndWidthTest() { IRenderer imageRenderer = image.createRendererSubTree(); FlexUtil.FlexItemCalculationInfo info = createFlexItemCalculationInfo((AbstractRenderer) imageRenderer); - Assert.assertEquals(60.0f, info.minContent, EPS); + Assertions.assertEquals(60.0f, info.minContent, EPS); image = new Image(new PdfFormXObject(new Rectangle(60, 150))); image.setHeight(50); @@ -2987,7 +2986,7 @@ public void calculateMinContentForImageWithHeightAndWidthTest() { imageRenderer = image.createRendererSubTree(); info = createFlexItemCalculationInfo((AbstractRenderer) imageRenderer); - Assert.assertEquals(50.0f, info.minContent, EPS); + Assertions.assertEquals(50.0f, info.minContent, EPS); } private static FlexUtil.FlexItemCalculationInfo createFlexItemCalculationInfo(AbstractRenderer renderer) { diff --git a/layout/src/test/java/com/itextpdf/layout/renderer/FloatExampleTest.java b/layout/src/test/java/com/itextpdf/layout/renderer/FloatExampleTest.java index 1c223be65c..e40a25853b 100644 --- a/layout/src/test/java/com/itextpdf/layout/renderer/FloatExampleTest.java +++ b/layout/src/test/java/com/itextpdf/layout/renderer/FloatExampleTest.java @@ -43,16 +43,15 @@ This file is part of the iText (R) project. import com.itextpdf.layout.properties.TextAlignment; import com.itextpdf.layout.properties.UnitValue; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; import java.io.IOException; import java.net.MalformedURLException; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class FloatExampleTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/layout/FloatExampleTest/"; @@ -63,7 +62,7 @@ public class FloatExampleTest extends ExtendedITextTest { private static final float DIV_BORDER_WIDTH = 1f; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } @@ -142,7 +141,7 @@ public void floatMaxWidthTest01() throws IOException, InterruptedException { Property.MAX_WIDTH, new UnitValue(UnitValue.PERCENT, 60f), ClearPropertyValue.BOTH, firstImage, lastImage); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff01_")); } @@ -176,7 +175,7 @@ public void floatMaxWidthTest02() throws IOException, InterruptedException { ClearPropertyValue.BOTH, firstImage, lastImage); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, + Assertions.assertNull(new CompareTool().compareByContent(outFile, cmpFileName, destinationFolder, "diff01_")); } @@ -228,7 +227,7 @@ private void addContent(Document document, boolean wrapImages, int imageWidthPro image.setProperty(imageWidthProperty, imageWidth); div.add(image); div.add(new Paragraph("Figure for Div" + i + ": This is longer text that wraps This is longer text that wraps") - .setTextAlignment(TextAlignment.CENTER)).setBold(); + .setTextAlignment(TextAlignment.CENTER)).simulateBold(); document.add(div); } else { image.setMargins(BORDER_MARGIN, 0, BORDER_MARGIN, BORDER_MARGIN); diff --git a/layout/src/test/java/com/itextpdf/layout/renderer/GridUnitTest.java b/layout/src/test/java/com/itextpdf/layout/renderer/GridUnitTest.java index 6e89ca7250..69b29693bf 100644 --- a/layout/src/test/java/com/itextpdf/layout/renderer/GridUnitTest.java +++ b/layout/src/test/java/com/itextpdf/layout/renderer/GridUnitTest.java @@ -25,18 +25,15 @@ This file is part of the iText (R) project. import com.itextpdf.layout.element.Text; import com.itextpdf.layout.properties.grid.GridFlow; import com.itextpdf.layout.properties.Property; -import com.itextpdf.layout.renderer.Grid.GridOrder; -import com.itextpdf.test.AssertUtil; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import java.util.Arrays; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class GridUnitTest extends ExtendedITextTest { @Test @@ -50,7 +47,7 @@ public void getUniqueCellsTest() { new TextRenderer(new Text("Three")), new TextRenderer(new Text("Four")) )).columns(3).rows(3).flow(GridFlow.ROW).build(); - Assert.assertEquals(4, grid.getUniqueGridCells(Grid.GridOrder.ROW).size()); + Assertions.assertEquals(4, grid.getUniqueGridCells(Grid.GridOrder.ROW).size()); } @Test @@ -72,13 +69,13 @@ public void sparsePackingTest() { cell5, cell6 )).columns(3).rows(3).flow(GridFlow.ROW).build(); - Assert.assertEquals(cell1, grid.getRows()[0][0].getValue()); - Assert.assertEquals(wideCell, grid.getRows()[0][1].getValue()); - Assert.assertEquals(wideCell, grid.getRows()[0][2].getValue()); - Assert.assertEquals(cell3, grid.getRows()[1][0].getValue()); - Assert.assertEquals(cell4, grid.getRows()[1][1].getValue()); - Assert.assertEquals(cell5, grid.getRows()[1][2].getValue()); - Assert.assertEquals(cell6, grid.getRows()[2][0].getValue()); + Assertions.assertEquals(cell1, grid.getRows()[0][0].getValue()); + Assertions.assertEquals(wideCell, grid.getRows()[0][1].getValue()); + Assertions.assertEquals(wideCell, grid.getRows()[0][2].getValue()); + Assertions.assertEquals(cell3, grid.getRows()[1][0].getValue()); + Assertions.assertEquals(cell4, grid.getRows()[1][1].getValue()); + Assertions.assertEquals(cell5, grid.getRows()[1][2].getValue()); + Assertions.assertEquals(cell6, grid.getRows()[2][0].getValue()); } @Test @@ -100,13 +97,13 @@ public void densePackingTest() { cell5, cell6 )).columns(3).rows(3).flow(GridFlow.ROW_DENSE).build(); - Assert.assertEquals(cell1, grid.getRows()[0][0].getValue()); - Assert.assertEquals(wideCell, grid.getRows()[0][1].getValue()); - Assert.assertEquals(wideCell, grid.getRows()[0][2].getValue()); - Assert.assertEquals(cell3, grid.getRows()[1][0].getValue()); - Assert.assertEquals(cell4, grid.getRows()[1][1].getValue()); - Assert.assertEquals(cell5, grid.getRows()[1][2].getValue()); - Assert.assertEquals(cell6, grid.getRows()[2][0].getValue()); + Assertions.assertEquals(cell1, grid.getRows()[0][0].getValue()); + Assertions.assertEquals(wideCell, grid.getRows()[0][1].getValue()); + Assertions.assertEquals(wideCell, grid.getRows()[0][2].getValue()); + Assertions.assertEquals(cell3, grid.getRows()[1][0].getValue()); + Assertions.assertEquals(cell4, grid.getRows()[1][1].getValue()); + Assertions.assertEquals(cell5, grid.getRows()[1][2].getValue()); + Assertions.assertEquals(cell6, grid.getRows()[2][0].getValue()); } @Test @@ -125,12 +122,12 @@ public void columnPackingTest() { cell5, cell6 )).columns(3).rows(3).flow(GridFlow.COLUMN).build(); - Assert.assertEquals(cell1, grid.getRows()[0][0].getValue()); - Assert.assertEquals(cell2, grid.getRows()[1][0].getValue()); - Assert.assertEquals(cell3, grid.getRows()[2][0].getValue()); - Assert.assertEquals(cell4, grid.getRows()[0][1].getValue()); - Assert.assertEquals(cell5, grid.getRows()[1][1].getValue()); - Assert.assertEquals(cell6, grid.getRows()[2][1].getValue()); + Assertions.assertEquals(cell1, grid.getRows()[0][0].getValue()); + Assertions.assertEquals(cell2, grid.getRows()[1][0].getValue()); + Assertions.assertEquals(cell3, grid.getRows()[2][0].getValue()); + Assertions.assertEquals(cell4, grid.getRows()[0][1].getValue()); + Assertions.assertEquals(cell5, grid.getRows()[1][1].getValue()); + Assertions.assertEquals(cell6, grid.getRows()[2][1].getValue()); } @Test @@ -152,13 +149,13 @@ public void columnWithFixedWideCellPackingTest() { cell5, cell6 )).columns(3).rows(3).flow(GridFlow.COLUMN).build(); - Assert.assertEquals(wideCell, grid.getRows()[0][0].getValue()); - Assert.assertEquals(cell1, grid.getRows()[1][0].getValue()); - Assert.assertEquals(cell4, grid.getRows()[1][1].getValue()); - Assert.assertEquals(cell3, grid.getRows()[2][0].getValue()); - Assert.assertEquals(wideCell, grid.getRows()[0][1].getValue()); - Assert.assertEquals(cell5, grid.getRows()[2][1].getValue()); - Assert.assertEquals(cell6, grid.getRows()[0][2].getValue()); + Assertions.assertEquals(wideCell, grid.getRows()[0][0].getValue()); + Assertions.assertEquals(cell1, grid.getRows()[1][0].getValue()); + Assertions.assertEquals(cell4, grid.getRows()[1][1].getValue()); + Assertions.assertEquals(cell3, grid.getRows()[2][0].getValue()); + Assertions.assertEquals(wideCell, grid.getRows()[0][1].getValue()); + Assertions.assertEquals(cell5, grid.getRows()[2][1].getValue()); + Assertions.assertEquals(cell6, grid.getRows()[0][2].getValue()); } @Test @@ -180,12 +177,12 @@ public void columnWithFixedTallCellPackingTest() { cell5, cell6 )).columns(3).rows(3).flow(GridFlow.COLUMN).build(); - Assert.assertEquals(cell1, grid.getRows()[0][0].getValue()); - Assert.assertEquals(tallCell, grid.getRows()[1][0].getValue()); - Assert.assertEquals(tallCell, grid.getRows()[2][0].getValue()); - Assert.assertEquals(cell3, grid.getRows()[0][1].getValue()); - Assert.assertEquals(cell4, grid.getRows()[1][1].getValue()); - Assert.assertEquals(cell5, grid.getRows()[2][1].getValue()); - Assert.assertEquals(cell6, grid.getRows()[0][2].getValue()); + Assertions.assertEquals(cell1, grid.getRows()[0][0].getValue()); + Assertions.assertEquals(tallCell, grid.getRows()[1][0].getValue()); + Assertions.assertEquals(tallCell, grid.getRows()[2][0].getValue()); + Assertions.assertEquals(cell3, grid.getRows()[0][1].getValue()); + Assertions.assertEquals(cell4, grid.getRows()[1][1].getValue()); + Assertions.assertEquals(cell5, grid.getRows()[2][1].getValue()); + Assertions.assertEquals(cell6, grid.getRows()[0][2].getValue()); } } diff --git a/layout/src/test/java/com/itextpdf/layout/renderer/ImageWidthTest.java b/layout/src/test/java/com/itextpdf/layout/renderer/ImageWidthTest.java index d301ead42a..883732adc4 100644 --- a/layout/src/test/java/com/itextpdf/layout/renderer/ImageWidthTest.java +++ b/layout/src/test/java/com/itextpdf/layout/renderer/ImageWidthTest.java @@ -35,15 +35,14 @@ This file is part of the iText (R) project. import com.itextpdf.layout.properties.Property; import com.itextpdf.layout.properties.UnitValue; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class ImageWidthTest extends ExtendedITextTest { private static final double EPSILON = 0.01; @@ -52,7 +51,7 @@ public class ImageWidthTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/layout/ImageWidthTest/"; public static final String imageFolder = "./src/test/resources/com/itextpdf/layout/ImageTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } @@ -105,7 +104,7 @@ public void imageWidthTest01() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -117,27 +116,27 @@ public void imageWidthTest02() throws IOException { image.setProperty(Property.MAX_WIDTH, UnitValue.createPointValue(50)); MinMaxWidth minMaxWidth = renderer.getMinMaxWidth(); - Assert.assertEquals(50.0, minMaxWidth.getMaxWidth(), EPSILON); - Assert.assertEquals(0.0, minMaxWidth.getMaxWidth()-minMaxWidth.getMinWidth(), EPSILON); + Assertions.assertEquals(50.0, minMaxWidth.getMaxWidth(), EPSILON); + Assertions.assertEquals(0.0, minMaxWidth.getMaxWidth()-minMaxWidth.getMinWidth(), EPSILON); image.setProperty(Property.MAX_WIDTH, UnitValue.createPercentValue(50)); minMaxWidth = renderer.getMinMaxWidth(); - Assert.assertEquals(1024.0, minMaxWidth.getMaxWidth(), EPSILON); + Assertions.assertEquals(1024.0, minMaxWidth.getMaxWidth(), EPSILON); image.setProperty(Property.MAX_HEIGHT, UnitValue.createPointValue(100f)); minMaxWidth = renderer.getMinMaxWidth(); - Assert.assertEquals( 100.0 * 1024.0 / 768.0, minMaxWidth.getMaxWidth(), EPSILON); + Assertions.assertEquals( 100.0 * 1024.0 / 768.0, minMaxWidth.getMaxWidth(), EPSILON); image = new Image(xObject); renderer = new ImageRenderer(image); image.setProperty(Property.MIN_WIDTH, UnitValue.createPointValue(2000)); image.setProperty(Property.MAX_WIDTH, UnitValue.createPointValue(3000)); minMaxWidth = renderer.getMinMaxWidth(); - Assert.assertEquals(2000.0, minMaxWidth.getMaxWidth(), EPSILON); - Assert.assertEquals(0.0, minMaxWidth.getMaxWidth() - minMaxWidth.getMinWidth(), EPSILON); + Assertions.assertEquals(2000.0, minMaxWidth.getMaxWidth(), EPSILON); + Assertions.assertEquals(0.0, minMaxWidth.getMaxWidth() - minMaxWidth.getMinWidth(), EPSILON); image.setProperty(Property.MIN_HEIGHT, UnitValue.createPointValue(100f)); image.setProperty(Property.HEIGHT, UnitValue.createPointValue(100f)); minMaxWidth = renderer.getMinMaxWidth(); - Assert.assertEquals( 100.0 * 1024.0 / 768.0, minMaxWidth.getMaxWidth(), EPSILON); + Assertions.assertEquals( 100.0 * 1024.0 / 768.0, minMaxWidth.getMaxWidth(), EPSILON); } } diff --git a/layout/src/test/java/com/itextpdf/layout/renderer/LineHeightHelperIntegrationTest.java b/layout/src/test/java/com/itextpdf/layout/renderer/LineHeightHelperIntegrationTest.java index bd60f4eaf0..ce3fa72830 100644 --- a/layout/src/test/java/com/itextpdf/layout/renderer/LineHeightHelperIntegrationTest.java +++ b/layout/src/test/java/com/itextpdf/layout/renderer/LineHeightHelperIntegrationTest.java @@ -33,17 +33,16 @@ This file is part of the iText (R) project. import com.itextpdf.layout.properties.Property; import com.itextpdf.layout.properties.RenderingMode; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.FileNotFoundException; import java.io.IOException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class LineHeightHelperIntegrationTest extends ExtendedITextTest { private static final String CMP = "./src/test/resources/com/itextpdf/layout/LineHeightHelperIntegrationTest/"; @@ -54,7 +53,7 @@ public class LineHeightHelperIntegrationTest extends ExtendedITextTest { + "Remember mistaken opinions it pleasure of debating. " + "Court front maids forty if aware their at. Chicken use are pressed removed."; - @BeforeClass + @BeforeAll public static void createDestFolder() { createDestinationFolder(DESTINATION); } @@ -65,7 +64,7 @@ public void courierTest() throws IOException, InterruptedException { String cmpPdf = CMP + "cmp_" + name; String outPdf = DESTINATION + name; testFont(PdfFontFactory.createFont(StandardFonts.COURIER), outPdf); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION)); } @Test @@ -74,7 +73,7 @@ public void helveticaTest() throws IOException, InterruptedException { String cmpPdf = CMP + "cmp_" + name; String outPdf = DESTINATION + name; testFont(PdfFontFactory.createFont(StandardFonts.HELVETICA), outPdf); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION)); } @Test @@ -83,10 +82,10 @@ public void timesRomanTest() throws IOException, InterruptedException { String cmpPdf = CMP + "cmp_" + name; String outPdf = DESTINATION + name; testFont(PdfFontFactory.createFont(StandardFonts.TIMES_ROMAN), outPdf); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION)); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION)); } - private void testFont(PdfFont font, String outPdf) throws FileNotFoundException { + private void testFont(PdfFont font, String outPdf) throws IOException { Document document = new Document(new PdfDocument(new PdfWriter(outPdf))); document.setFont(font); Paragraph paragraph = new Paragraph(TEXT_SAMPLE); diff --git a/layout/src/test/java/com/itextpdf/layout/renderer/LineHeightHelperUnitTest.java b/layout/src/test/java/com/itextpdf/layout/renderer/LineHeightHelperUnitTest.java index 326e96eb6f..b3215985c0 100644 --- a/layout/src/test/java/com/itextpdf/layout/renderer/LineHeightHelperUnitTest.java +++ b/layout/src/test/java/com/itextpdf/layout/renderer/LineHeightHelperUnitTest.java @@ -34,14 +34,13 @@ This file is part of the iText (R) project. import com.itextpdf.layout.properties.Property; import com.itextpdf.layout.properties.RenderingMode; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.IOException; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class LineHeightHelperUnitTest extends ExtendedITextTest { private static final double EPS = 1e-5; @@ -52,24 +51,24 @@ public class LineHeightHelperUnitTest extends ExtendedITextTest { public void calculateFontAscenderDescenderFromFontMetricsCourierTest() throws IOException { PdfFont font = PdfFontFactory.createFont(StandardFonts.COURIER); float[] fontAscenderDescender = TextRenderer.calculateAscenderDescender(font, RenderingMode.HTML_MODE); - Assert.assertEquals(629.0f * TextRenderer.TYPO_ASCENDER_SCALE_COEFF, fontAscenderDescender[0], EPS); - Assert.assertEquals(-157.0f * TextRenderer.TYPO_ASCENDER_SCALE_COEFF, fontAscenderDescender[1], EPS); + Assertions.assertEquals(629.0f * TextRenderer.TYPO_ASCENDER_SCALE_COEFF, fontAscenderDescender[0], EPS); + Assertions.assertEquals(-157.0f * TextRenderer.TYPO_ASCENDER_SCALE_COEFF, fontAscenderDescender[1], EPS); } @Test public void calculateFontAscenderDescenderFromFontMetricsTimesTest() throws IOException { PdfFont font = PdfFontFactory.createFont(StandardFonts.TIMES_ROMAN); float[] fontAscenderDescender = TextRenderer.calculateAscenderDescender(font, RenderingMode.HTML_MODE); - Assert.assertEquals(683.0f * TextRenderer.TYPO_ASCENDER_SCALE_COEFF, fontAscenderDescender[0], EPS); - Assert.assertEquals(-217.0f * TextRenderer.TYPO_ASCENDER_SCALE_COEFF, fontAscenderDescender[1], EPS); + Assertions.assertEquals(683.0f * TextRenderer.TYPO_ASCENDER_SCALE_COEFF, fontAscenderDescender[0], EPS); + Assertions.assertEquals(-217.0f * TextRenderer.TYPO_ASCENDER_SCALE_COEFF, fontAscenderDescender[1], EPS); } @Test public void calculateFontAscenderDescenderFromFontMetricsHelveticaTest() throws IOException { PdfFont font = PdfFontFactory.createFont(StandardFonts.HELVETICA); float[] fontAscenderDescender = TextRenderer.calculateAscenderDescender(font, RenderingMode.HTML_MODE); - Assert.assertEquals(718.0f * TextRenderer.TYPO_ASCENDER_SCALE_COEFF, fontAscenderDescender[0], EPS); - Assert.assertEquals(-207.0f * TextRenderer.TYPO_ASCENDER_SCALE_COEFF, fontAscenderDescender[1], EPS); + Assertions.assertEquals(718.0f * TextRenderer.TYPO_ASCENDER_SCALE_COEFF, fontAscenderDescender[0], EPS); + Assertions.assertEquals(-207.0f * TextRenderer.TYPO_ASCENDER_SCALE_COEFF, fontAscenderDescender[1], EPS); } @Test @@ -78,8 +77,8 @@ public void getFontAscenderDescenderNormalizedTextRendererTest() { TextRenderer textRenderer = new TextRenderer(new Text("Hello")); textRenderer.setParent(document.getRenderer()); float[] ascenderDescender = LineHeightHelper.getFontAscenderDescenderNormalized(textRenderer); - Assert.assertEquals(10.33920f, ascenderDescender[0], EPS); - Assert.assertEquals(-2.9808f, ascenderDescender[1], EPS); + Assertions.assertEquals(10.33920f, ascenderDescender[0], EPS); + Assertions.assertEquals(-2.9808f, ascenderDescender[1], EPS); } @Test @@ -88,7 +87,7 @@ public void calculateLineHeightTextRendererNullTest() { TextRenderer textRenderer = new TextRenderer(new Text("Hello")); textRenderer.setParent(document.getRenderer()); float lineHeight = LineHeightHelper.calculateLineHeight(textRenderer); - Assert.assertEquals(13.79999f, lineHeight, EPS); + Assertions.assertEquals(13.79999f, lineHeight, EPS); } @Test @@ -98,7 +97,7 @@ public void calculateLineHeightTextRendererNormalTest() { textRenderer.setProperty(Property.LINE_HEIGHT, LineHeight.createNormalValue()); textRenderer.setParent(document.getRenderer()); float lineHeight = LineHeightHelper.calculateLineHeight(textRenderer); - Assert.assertEquals(13.79999f, lineHeight, EPS); + Assertions.assertEquals(13.79999f, lineHeight, EPS); } @Test @@ -108,7 +107,7 @@ public void calculateLineHeightTextRendererPointNegativeTest() { textRenderer.setProperty(Property.LINE_HEIGHT, LineHeight.createFixedValue(-10)); textRenderer.setParent(document.getRenderer()); float lineHeight = LineHeightHelper.calculateLineHeight(textRenderer); - Assert.assertEquals(13.79999f, lineHeight, EPS); + Assertions.assertEquals(13.79999f, lineHeight, EPS); } @Test @@ -118,7 +117,7 @@ public void calculateLineHeightTextRendererNormalNegativeTest() { textRenderer.setProperty(Property.LINE_HEIGHT, LineHeight.createNormalValue()); textRenderer.setParent(document.getRenderer()); float lineHeight = LineHeightHelper.calculateLineHeight(textRenderer); - Assert.assertEquals(13.79999f, lineHeight, EPS); + Assertions.assertEquals(13.79999f, lineHeight, EPS); } @Test @@ -128,7 +127,7 @@ public void calculateLineHeighttTextRendererPointZeroTest() { textRenderer.setProperty(Property.LINE_HEIGHT, LineHeight.createFixedValue(0)); textRenderer.setParent(document.getRenderer()); float lineHeight = LineHeightHelper.calculateLineHeight(textRenderer); - Assert.assertEquals(0f, lineHeight, EPS); + Assertions.assertEquals(0f, lineHeight, EPS); } @@ -139,7 +138,7 @@ public void calculateLineHeighttTextRendererNormalZeroTest() { textRenderer.setProperty(Property.LINE_HEIGHT, LineHeight.createNormalValue()); textRenderer.setParent(document.getRenderer()); float lineHeight = LineHeightHelper.calculateLineHeight(textRenderer); - Assert.assertEquals(13.79999f, lineHeight, EPS); + Assertions.assertEquals(13.79999f, lineHeight, EPS); } @Test @@ -149,7 +148,7 @@ public void calculateLineHeighttTextRendererPointTest() { textRenderer.setProperty(Property.LINE_HEIGHT, LineHeight.createFixedValue(200)); textRenderer.setParent(document.getRenderer()); float lineHeight = LineHeightHelper.calculateLineHeight(textRenderer); - Assert.assertEquals(200, lineHeight, EPS); + Assertions.assertEquals(200, lineHeight, EPS); } @Test @@ -161,7 +160,7 @@ public void calculateLineHeightTextRendererNormalAscenderDescenderSumForNotoSans textRenderer.setProperty(Property.LINE_HEIGHT, LineHeight.createNormalValue()); textRenderer.setParent(document.getRenderer()); float lineHeight = LineHeightHelper.calculateLineHeight(textRenderer); - Assert.assertEquals(16.31999f, lineHeight, EPS); + Assertions.assertEquals(16.31999f, lineHeight, EPS); } @Test @@ -170,24 +169,24 @@ public void getActualAscenderDescenderTextRenderer() { TextRenderer textRenderer = new TextRenderer(new Text("Hello")); textRenderer.setParent(document.getRenderer()); float[] ascenderDescender = LineHeightHelper.getActualAscenderDescender(textRenderer); - Assert.assertEquals(10.57919f, ascenderDescender[0], EPS); - Assert.assertEquals(-3.22079f, ascenderDescender[1], EPS); + Assertions.assertEquals(10.57919f, ascenderDescender[0], EPS); + Assertions.assertEquals(-3.22079f, ascenderDescender[1], EPS); } @Test public void calculateFontAscenderDescenderFromFontMetricsNotoEmojiFontTest() throws IOException { PdfFont font = PdfFontFactory.createFont(FONTS + "NotoEmoji-Regular.ttf"); float[] ascenderDescenderFromFontMetrics = TextRenderer.calculateAscenderDescender(font, RenderingMode.HTML_MODE); - Assert.assertEquals(1068.0f, ascenderDescenderFromFontMetrics[0], EPS); - Assert.assertEquals(-292.0f, ascenderDescenderFromFontMetrics[1], EPS); + Assertions.assertEquals(1068.0f, ascenderDescenderFromFontMetrics[0], EPS); + Assertions.assertEquals(-292.0f, ascenderDescenderFromFontMetrics[1], EPS); } @Test public void calculateFontAscenderDescenderFromFontMetricsNotoSansFontTest() throws IOException { PdfFont font = PdfFontFactory.createFont(FONTS + "NotoSans-Regular.ttf"); float[] ascenderDescenderFromFontMetrics = TextRenderer.calculateAscenderDescender(font, RenderingMode.HTML_MODE); - Assert.assertEquals(1068.0f, ascenderDescenderFromFontMetrics[0], EPS); - Assert.assertEquals(-292.0f, ascenderDescenderFromFontMetrics[1], EPS); + Assertions.assertEquals(1068.0f, ascenderDescenderFromFontMetrics[0], EPS); + Assertions.assertEquals(-292.0f, ascenderDescenderFromFontMetrics[1], EPS); } @Test @@ -202,40 +201,40 @@ public void calculateFontAscenderDescenderFromFontMetricsNotoColorEmojiFontTest( public void calculateFontAscenderDescenderFromFontMetricsNotoSansCJKscRegularFontTest() throws IOException { PdfFont font = PdfFontFactory.createFont(FONTS + "NotoSansCJKsc-Regular.otf"); float[] ascenderDescenderFromFontMetrics = TextRenderer.calculateAscenderDescender(font, RenderingMode.HTML_MODE); - Assert.assertEquals(1160.0f, ascenderDescenderFromFontMetrics[0], EPS); - Assert.assertEquals(-320.0f, ascenderDescenderFromFontMetrics[1], EPS); + Assertions.assertEquals(1160.0f, ascenderDescenderFromFontMetrics[0], EPS); + Assertions.assertEquals(-320.0f, ascenderDescenderFromFontMetrics[1], EPS); } @Test public void calculateFontAscenderDescenderFromFontMetricsPuritan2FontTest() throws IOException { PdfFont font = PdfFontFactory.createFont(FONTS + "Puritan2.otf"); float[] ascenderDescenderFromFontMetrics = TextRenderer.calculateAscenderDescender(font, RenderingMode.HTML_MODE); - Assert.assertEquals(860.0f, ascenderDescenderFromFontMetrics[0], EPS); - Assert.assertEquals(-232.0f, ascenderDescenderFromFontMetrics[1], EPS); + Assertions.assertEquals(860.0f, ascenderDescenderFromFontMetrics[0], EPS); + Assertions.assertEquals(-232.0f, ascenderDescenderFromFontMetrics[1], EPS); } @Test public void calculateFontAscenderDescenderFromFontMetricsNotoSansCJKjpBoldFontTest() throws IOException { PdfFont font = PdfFontFactory.createFont(FONTS + "NotoSansCJKjp-Bold.otf"); float[] ascenderDescenderFromFontMetrics = TextRenderer.calculateAscenderDescender(font, RenderingMode.HTML_MODE); - Assert.assertEquals(1160.0f, ascenderDescenderFromFontMetrics[0], EPS); - Assert.assertEquals(-320.0f, ascenderDescenderFromFontMetrics[1], EPS); + Assertions.assertEquals(1160.0f, ascenderDescenderFromFontMetrics[0], EPS); + Assertions.assertEquals(-320.0f, ascenderDescenderFromFontMetrics[1], EPS); } @Test public void calculateFontAscenderDescenderFromFontMetricsFreeSansFontTest() throws IOException { PdfFont font = PdfFontFactory.createFont(FONTS + "FreeSans.ttf"); float[] ascenderDescenderFromFontMetrics = TextRenderer.calculateAscenderDescender(font, RenderingMode.HTML_MODE); - Assert.assertEquals(800.0f, ascenderDescenderFromFontMetrics[0], EPS); - Assert.assertEquals(-200.0f, ascenderDescenderFromFontMetrics[1], EPS); + Assertions.assertEquals(800.0f, ascenderDescenderFromFontMetrics[0], EPS); + Assertions.assertEquals(-200.0f, ascenderDescenderFromFontMetrics[1], EPS); } @Test public void calculateFontAscenderDescenderFromFontMetricsOpenSansRegularFontTest() throws IOException { PdfFont font = PdfFontFactory.createFont(OPEN_SANS_FONTS + "OpenSans-Regular.ttf"); float[] ascenderDescenderFromFontMetrics = TextRenderer.calculateAscenderDescender(font, RenderingMode.HTML_MODE); - Assert.assertEquals(1068.0f, ascenderDescenderFromFontMetrics[0], EPS); - Assert.assertEquals(-292.0f, ascenderDescenderFromFontMetrics[1], EPS); + Assertions.assertEquals(1068.0f, ascenderDescenderFromFontMetrics[0], EPS); + Assertions.assertEquals(-292.0f, ascenderDescenderFromFontMetrics[1], EPS); } } diff --git a/layout/src/test/java/com/itextpdf/layout/renderer/LineRendererUnitTest.java b/layout/src/test/java/com/itextpdf/layout/renderer/LineRendererUnitTest.java index 97ebd0d8af..70e61a5b96 100644 --- a/layout/src/test/java/com/itextpdf/layout/renderer/LineRendererUnitTest.java +++ b/layout/src/test/java/com/itextpdf/layout/renderer/LineRendererUnitTest.java @@ -37,23 +37,24 @@ This file is part of the iText (R) project. import com.itextpdf.layout.layout.LayoutContext; import com.itextpdf.layout.layout.LayoutResult; import com.itextpdf.layout.properties.FloatPropertyValue; +import com.itextpdf.layout.properties.Leading; import com.itextpdf.layout.properties.LineHeight; import com.itextpdf.layout.properties.Property; import com.itextpdf.layout.properties.RenderingMode; import com.itextpdf.layout.properties.UnitValue; import com.itextpdf.layout.renderer.LineRenderer.LineSplitIntoGlyphsData; +import com.itextpdf.layout.renderer.LineRenderer.RendererGlyph; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.IOException; import java.util.Arrays; import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class LineRendererUnitTest extends RendererUnitTest { private static final double EPS = 1e-5; @@ -64,13 +65,13 @@ public void adjustChildPositionsAfterReorderingSimpleTest01() { IRenderer dummy1 = createLayoutedTextRenderer("Hello", dummyDocument); IRenderer dummy2 = createLayoutedTextRenderer("world", dummyDocument); IRenderer dummyImage = createLayoutedImageRenderer(100, 100, dummyDocument); - Assert.assertEquals(0, dummy1.getOccupiedArea().getBBox().getX(), EPS); - Assert.assertEquals(0, dummy2.getOccupiedArea().getBBox().getX(), EPS); - Assert.assertEquals(0, dummyImage.getOccupiedArea().getBBox().getX(), EPS); + Assertions.assertEquals(0, dummy1.getOccupiedArea().getBBox().getX(), EPS); + Assertions.assertEquals(0, dummy2.getOccupiedArea().getBBox().getX(), EPS); + Assertions.assertEquals(0, dummyImage.getOccupiedArea().getBBox().getX(), EPS); LineRenderer.adjustChildPositionsAfterReordering(Arrays.asList(dummy1, dummyImage, dummy2), 10); - Assert.assertEquals(10, dummy1.getOccupiedArea().getBBox().getX(), EPS); - Assert.assertEquals(37.3359985, dummyImage.getOccupiedArea().getBBox().getX(), EPS); - Assert.assertEquals(137.3359985, dummy2.getOccupiedArea().getBBox().getX(), EPS); + Assertions.assertEquals(10, dummy1.getOccupiedArea().getBBox().getX(), EPS); + Assertions.assertEquals(37.3359985, dummyImage.getOccupiedArea().getBBox().getX(), EPS); + Assertions.assertEquals(137.3359985, dummy2.getOccupiedArea().getBBox().getX(), EPS); } @Test @@ -84,12 +85,12 @@ public void adjustChildPositionsAfterReorderingTestWithPercentMargins01() { dummy1.setProperty(Property.PADDING_LEFT, UnitValue.createPercentValue(10)); dummy1.setProperty(Property.PADDING_RIGHT, UnitValue.createPercentValue(10)); IRenderer dummy2 = createLayoutedTextRenderer("world", dummyDocument); - Assert.assertEquals(0, dummy1.getOccupiedArea().getBBox().getX(), EPS); - Assert.assertEquals(0, dummy2.getOccupiedArea().getBBox().getX(), EPS); + Assertions.assertEquals(0, dummy1.getOccupiedArea().getBBox().getX(), EPS); + Assertions.assertEquals(0, dummy2.getOccupiedArea().getBBox().getX(), EPS); LineRenderer.adjustChildPositionsAfterReordering(Arrays.asList(dummy1, dummy2), 10); - Assert.assertEquals(10, dummy1.getOccupiedArea().getBBox().getX(), EPS); + Assertions.assertEquals(10, dummy1.getOccupiedArea().getBBox().getX(), EPS); // If margins and paddings are specified in percents, we treat them as point values for now - Assert.assertEquals(77.3359985, dummy2.getOccupiedArea().getBBox().getX(), EPS); + Assertions.assertEquals(77.3359985, dummy2.getOccupiedArea().getBBox().getX(), EPS); } @Test @@ -99,14 +100,14 @@ public void adjustChildPositionsAfterReorderingTestWithFloats01() { IRenderer dummy2 = createLayoutedTextRenderer("world", dummyDocument); IRenderer dummyImage = createLayoutedImageRenderer(100, 100, dummyDocument); dummyImage.setProperty(Property.FLOAT, FloatPropertyValue.LEFT); - Assert.assertEquals(0, dummy1.getOccupiedArea().getBBox().getX(), EPS); - Assert.assertEquals(0, dummy2.getOccupiedArea().getBBox().getX(), EPS); - Assert.assertEquals(0, dummyImage.getOccupiedArea().getBBox().getX(), EPS); + Assertions.assertEquals(0, dummy1.getOccupiedArea().getBBox().getX(), EPS); + Assertions.assertEquals(0, dummy2.getOccupiedArea().getBBox().getX(), EPS); + Assertions.assertEquals(0, dummyImage.getOccupiedArea().getBBox().getX(), EPS); LineRenderer.adjustChildPositionsAfterReordering(Arrays.asList(dummy1, dummyImage, dummy2), 10); - Assert.assertEquals(10, dummy1.getOccupiedArea().getBBox().getX(), EPS); + Assertions.assertEquals(10, dummy1.getOccupiedArea().getBBox().getX(), EPS); // Floating renderer is not repositioned - Assert.assertEquals(0, dummyImage.getOccupiedArea().getBBox().getX(), EPS); - Assert.assertEquals(37.3359985, dummy2.getOccupiedArea().getBBox().getX(), EPS); + Assertions.assertEquals(0, dummyImage.getOccupiedArea().getBBox().getX(), EPS); + Assertions.assertEquals(37.3359985, dummy2.getOccupiedArea().getBBox().getX(), EPS); } @Test @@ -119,9 +120,9 @@ public void inlineBlockWithBigMinWidth01() { lineRenderer.addChild(inlineBlockRenderer); LayoutResult result = lineRenderer.layout(new LayoutContext(createLayoutArea(1000, 1000))); // In case there is an inline block child with large min-width, the inline block child will be force placed (not layouted properly) - Assert.assertEquals(LayoutResult.FULL, result.getStatus()); - Assert.assertEquals(0, result.getOccupiedArea().getBBox().getHeight(), EPS); - Assert.assertEquals(true, inlineBlockRenderer.getPropertyAsBoolean(Property.FORCED_PLACEMENT)); + Assertions.assertEquals(LayoutResult.FULL, result.getStatus()); + Assertions.assertEquals(0, result.getOccupiedArea().getBBox().getHeight(), EPS); + Assertions.assertEquals(true, inlineBlockRenderer.getPropertyAsBoolean(Property.FORCED_PLACEMENT)); } @Test @@ -144,8 +145,8 @@ public void adjustChildrenYLineTextChildHtmlModeTest() { lineRenderer.addChild(childTextRenderer); lineRenderer.adjustChildrenYLine(); - Assert.assertEquals(100f, lineRenderer.getOccupiedAreaBBox().getBottom(), EPS); - Assert.assertEquals(100f, childTextRenderer.getOccupiedAreaBBox().getBottom(), EPS); + Assertions.assertEquals(100f, lineRenderer.getOccupiedAreaBBox().getBottom(), EPS); + Assertions.assertEquals(100f, childTextRenderer.getOccupiedAreaBBox().getBottom(), EPS); } @Test @@ -168,9 +169,9 @@ public void adjustChildrenYLineImageChildHtmlModeTest() { lineRenderer.adjustChildrenYLine(); - Assert.assertEquals(50f, lineRenderer.getOccupiedAreaBBox().getBottom(), EPS); + Assertions.assertEquals(50f, lineRenderer.getOccupiedAreaBBox().getBottom(), EPS); //image should be on the baseline top 250 - maxAscent 150 = 100 - Assert.assertEquals(100.0, childImageRenderer.getOccupiedAreaBBox().getBottom(), EPS); + Assertions.assertEquals(100.0, childImageRenderer.getOccupiedAreaBBox().getBottom(), EPS); } @Test @@ -185,7 +186,7 @@ public void hasChildRendererInHtmlModeTest() { lineRenderer.addChild(textRenderer1); lineRenderer.addChild(textRenderer2); - Assert.assertTrue(lineRenderer.hasChildRendererInHtmlMode()); + Assertions.assertTrue(lineRenderer.hasChildRendererInHtmlMode()); } @Test @@ -200,13 +201,13 @@ public void childRendererInDefaultModeTest() { lineRenderer.addChild(textRenderer1); lineRenderer.addChild(textRenderer2); - Assert.assertFalse(lineRenderer.hasChildRendererInHtmlMode()); + Assertions.assertFalse(lineRenderer.hasChildRendererInHtmlMode()); } @Test public void hasChildRendererInHtmlModeNoChildrenTest() { LineRenderer lineRenderer = new LineRenderer(); - Assert.assertFalse(lineRenderer.hasChildRendererInHtmlMode()); + Assertions.assertFalse(lineRenderer.hasChildRendererInHtmlMode()); } @Test @@ -220,8 +221,8 @@ public void lineRendererLayoutInHtmlModeWithLineHeightAndNoChildrenTest() { lineRenderer.layout(new LayoutContext(createLayoutArea(1000, 1000))); - Assert.assertEquals(0f, lineRenderer.maxAscent, 0f); - Assert.assertEquals(0f, lineRenderer.maxDescent, 0f); + Assertions.assertEquals(0f, lineRenderer.maxAscent, 0f); + Assertions.assertEquals(0f, lineRenderer.maxDescent, 0f); } @Test @@ -244,8 +245,8 @@ public void lineRendererLayoutInHtmlModeWithLineHeightAndChildrenInDefaultModeTe lineRenderer.layout(new LayoutContext(createLayoutArea(1000, 1000))); - Assert.assertEquals(10.3392f, lineRenderer.maxAscent, EPS); - Assert.assertEquals(-2.98079f, lineRenderer.maxDescent, EPS); + Assertions.assertEquals(10.3392f, lineRenderer.maxAscent, EPS); + Assertions.assertEquals(-2.98079f, lineRenderer.maxDescent, EPS); } @Test @@ -267,8 +268,8 @@ public void lineRendererLayoutInHtmlModeWithLineHeightAndChildInHtmlModeTest() { lineRenderer.layout(new LayoutContext(createLayoutArea(1000, 1000))); - Assert.assertEquals(28.67920f, lineRenderer.maxAscent, EPS); - Assert.assertEquals(-21.32080f, lineRenderer.maxDescent, EPS); + Assertions.assertEquals(28.67920f, lineRenderer.maxAscent, EPS); + Assertions.assertEquals(-21.32080f, lineRenderer.maxDescent, EPS); } @Test @@ -291,7 +292,7 @@ public void lineRendererLayoutInHtmlModeWithLineHeightPropertyNotSet() throws IO Rectangle bboxLineHeightNotSet = layoutResLineHeightNotSet.getOccupiedArea().getBBox(); Rectangle bboxLineHeightNormal = layoutResLineHeightNormal.getOccupiedArea().getBBox(); - Assert.assertTrue(bboxLineHeightNotSet.equalsWithEpsilon(bboxLineHeightNormal)); + Assertions.assertTrue(bboxLineHeightNotSet.equalsWithEpsilon(bboxLineHeightNormal)); } @Test @@ -325,7 +326,7 @@ public void minMaxWidthEqualsActualMarginsBordersPaddings() { float countedMinWidth = lineRenderer.getMinMaxWidth().getMinWidth(); LayoutResult result = lineRenderer.layout(new LayoutContext(layoutArea)); - Assert.assertEquals(result.getOccupiedArea().getBBox().getWidth(), countedMinWidth, 0.0001); + Assertions.assertEquals(result.getOccupiedArea().getBBox().getWidth(), countedMinWidth, 0.0001); } @Test @@ -352,13 +353,13 @@ public void splitLineIntoGlyphsSimpleTest() { LineSplitIntoGlyphsData splitIntoGlyphsData = LineRenderer.splitLineIntoGlyphs(toSplit); - Assert.assertEquals(Arrays.asList(dummyImage1, dummyImage2), splitIntoGlyphsData.getStarterNonTextRenderers()); - Assert.assertEquals(Arrays.asList(dummyImage3), splitIntoGlyphsData.getInsertAfterAndRemove(dummy1)); - Assert.assertNull(splitIntoGlyphsData.getInsertAfterAndRemove(dummy1)); - Assert.assertNull(splitIntoGlyphsData.getInsertAfterAndRemove(dummy2)); - Assert.assertEquals(Arrays.asList(dummyImage4, dummyImage5), splitIntoGlyphsData.getInsertAfterAndRemove(dummy3)); - Assert.assertNull(splitIntoGlyphsData.getInsertAfterAndRemove(dummy3)); - Assert.assertEquals(13, splitIntoGlyphsData.getLineGlyphs().size()); + Assertions.assertEquals(Arrays.asList(dummyImage1, dummyImage2), splitIntoGlyphsData.getStarterNonTextRenderers()); + Assertions.assertEquals(Arrays.asList(dummyImage3), splitIntoGlyphsData.getInsertAfterAndRemove(dummy1)); + Assertions.assertNull(splitIntoGlyphsData.getInsertAfterAndRemove(dummy1)); + Assertions.assertNull(splitIntoGlyphsData.getInsertAfterAndRemove(dummy2)); + Assertions.assertEquals(Arrays.asList(dummyImage4, dummyImage5), splitIntoGlyphsData.getInsertAfterAndRemove(dummy3)); + Assertions.assertNull(splitIntoGlyphsData.getInsertAfterAndRemove(dummy3)); + Assertions.assertEquals(13, splitIntoGlyphsData.getLineGlyphs().size()); } @Test @@ -386,12 +387,12 @@ public void splitLineIntoGlyphsWithLineBreakTest() { LineSplitIntoGlyphsData splitIntoGlyphsData = LineRenderer.splitLineIntoGlyphs(toSplit); - Assert.assertEquals(Arrays.asList(dummyImage1, dummyImage2), splitIntoGlyphsData.getStarterNonTextRenderers()); - Assert.assertEquals(Arrays.asList(dummyImage3), splitIntoGlyphsData.getInsertAfterAndRemove(dummy1)); - Assert.assertNull(splitIntoGlyphsData.getInsertAfterAndRemove(dummy1)); - Assert.assertNull(splitIntoGlyphsData.getInsertAfterAndRemove(dummy2)); - Assert.assertNull(splitIntoGlyphsData.getInsertAfterAndRemove(dummy3)); - Assert.assertEquals(7, splitIntoGlyphsData.getLineGlyphs().size()); + Assertions.assertEquals(Arrays.asList(dummyImage1, dummyImage2), splitIntoGlyphsData.getStarterNonTextRenderers()); + Assertions.assertEquals(Arrays.asList(dummyImage3), splitIntoGlyphsData.getInsertAfterAndRemove(dummy1)); + Assertions.assertNull(splitIntoGlyphsData.getInsertAfterAndRemove(dummy1)); + Assertions.assertNull(splitIntoGlyphsData.getInsertAfterAndRemove(dummy2)); + Assertions.assertNull(splitIntoGlyphsData.getInsertAfterAndRemove(dummy3)); + Assertions.assertEquals(7, splitIntoGlyphsData.getLineGlyphs().size()); } @Test @@ -423,20 +424,73 @@ public void reorderSimpleTest() { // validate that all non text renderers are in place and all text renderers contains // the right revers ranges List childRenderers = toSplit.getChildRenderers(); - Assert.assertEquals(8, childRenderers.size()); - Assert.assertSame(dummyImage1, childRenderers.get(0)); - Assert.assertSame(dummyImage2, childRenderers.get(1)); + Assertions.assertEquals(8, childRenderers.size()); + Assertions.assertSame(dummyImage1, childRenderers.get(0)); + Assertions.assertSame(dummyImage2, childRenderers.get(1)); List firstReverseRanges = ((TextRenderer) childRenderers.get(2)).getReversedRanges(); - Assert.assertEquals(1, firstReverseRanges.size()); - Assert.assertArrayEquals(new int[]{2, 4}, firstReverseRanges.get(0)); - Assert.assertSame(dummyImage3, childRenderers.get(3)); + Assertions.assertEquals(1, firstReverseRanges.size()); + Assertions.assertArrayEquals(new int[]{2, 4}, firstReverseRanges.get(0)); + Assertions.assertSame(dummyImage3, childRenderers.get(3)); List secondReverseRanges = ((TextRenderer) childRenderers.get(4)).getReversedRanges(); - Assert.assertEquals(2, secondReverseRanges.size()); - Assert.assertArrayEquals(new int[]{0, 1}, secondReverseRanges.get(0)); - Assert.assertArrayEquals(new int[]{2, 3}, secondReverseRanges.get(1)); + Assertions.assertEquals(2, secondReverseRanges.size()); + Assertions.assertArrayEquals(new int[]{0, 1}, secondReverseRanges.get(0)); + Assertions.assertArrayEquals(new int[]{2, 3}, secondReverseRanges.get(1)); List thirdReverseRanges = ((TextRenderer) childRenderers.get(5)).getReversedRanges(); - Assert.assertNull(thirdReverseRanges); - Assert.assertSame(dummyImage4, childRenderers.get(6)); - Assert.assertSame(dummyImage5, childRenderers.get(7)); + Assertions.assertNull(thirdReverseRanges); + Assertions.assertSame(dummyImage4, childRenderers.get(6)); + Assertions.assertSame(dummyImage5, childRenderers.get(7)); + } + + @Test + @LogMessages(messages = { + @LogMessage(messageTemplate = IoLogMessageConstant.PROPERTY_IN_PERCENTS_NOT_SUPPORTED, count = 2)}) + public void percentFontSizeNotSupportedTest() { + LineRenderer lineRenderer = new LineRenderer(); + Leading leading = new Leading(Leading.MULTIPLIED, 1); + lineRenderer.setProperty(Property.FONT_SIZE, UnitValue.createPercentValue(35)); + float topLeadingIndent = lineRenderer.getTopLeadingIndent(leading); + float bottomLeadingIndent = lineRenderer.getBottomLeadingIndent(leading); + Assertions.assertEquals(0.0, topLeadingIndent); + Assertions.assertEquals(7.0, bottomLeadingIndent); + } + + @Test + public void leadingTypeUnsupportedTest() { + LineRenderer lineRenderer = new LineRenderer(); + Leading leading = new Leading(new Leading(3, 3).getType(), 1); + Assertions.assertThrows(IllegalStateException.class, () -> lineRenderer.getTopLeadingIndent(leading)); + Assertions.assertThrows(IllegalStateException.class, () -> lineRenderer.getBottomLeadingIndent(leading)); + } + + @Test + public void getGlyphTest() { + Document dummyDocument = createDummyDocument(); + TextRenderer textRenderer = createLayoutedTextRenderer("hello", dummyDocument); + RendererGlyph rendererGlyph = new RendererGlyph(null, textRenderer); + + rendererGlyph.setGlyph(new Glyph('\n', 0, '\n')); + Glyph glyph = rendererGlyph.getGlyph(); + + Assertions.assertEquals(1, glyph.getChars().length); + Assertions.assertEquals(0, glyph.getWidth()); + Assertions.assertEquals(10, glyph.getUnicode()); + Assertions.assertEquals(10, glyph.getCode()); + Assertions.assertFalse(glyph.isMark()); + } + + @Test + public void getRendererTest() { + Document dummyDocument = createDummyDocument(); + RendererGlyph rendererGlyph = new RendererGlyph(new Glyph('\n', 0, '\n'), null); + + TextRenderer textRenderer = createLayoutedTextRenderer("hello", dummyDocument); + rendererGlyph.setRenderer(textRenderer); + + TextRenderer renderer = rendererGlyph.getRenderer(); + + Assertions.assertEquals("hello", renderer.getText().toString()); + Assertions.assertEquals(0, renderer.getText().getStart()); + Assertions.assertEquals(5, renderer.getText().getEnd()); + Assertions.assertEquals(0, renderer.getText().getIdx()); } } diff --git a/layout/src/test/java/com/itextpdf/layout/renderer/LinkRendererUnitTest.java b/layout/src/test/java/com/itextpdf/layout/renderer/LinkRendererUnitTest.java index a0df34e36b..ffd60102a9 100644 --- a/layout/src/test/java/com/itextpdf/layout/renderer/LinkRendererUnitTest.java +++ b/layout/src/test/java/com/itextpdf/layout/renderer/LinkRendererUnitTest.java @@ -29,13 +29,12 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class LinkRendererUnitTest extends ExtendedITextTest { @Test @@ -48,6 +47,6 @@ public void getNextRendererShouldBeOverriddenTest() { // Nothing is overridden }; - Assert.assertEquals(LinkRenderer.class, linkRenderer.getNextRenderer().getClass()); + Assertions.assertEquals(LinkRenderer.class, linkRenderer.getNextRenderer().getClass()); } } diff --git a/layout/src/test/java/com/itextpdf/layout/renderer/ListRendererUnitTest.java b/layout/src/test/java/com/itextpdf/layout/renderer/ListRendererUnitTest.java index 9c0ca1685e..e265bf142c 100644 --- a/layout/src/test/java/com/itextpdf/layout/renderer/ListRendererUnitTest.java +++ b/layout/src/test/java/com/itextpdf/layout/renderer/ListRendererUnitTest.java @@ -36,17 +36,16 @@ This file is part of the iText (R) project. import com.itextpdf.layout.properties.Property; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; -@Category(UnitTest.class) +@Tag("UnitTest") public class ListRendererUnitTest extends RendererUnitTest { @Test @@ -58,7 +57,7 @@ public void getNextRendererShouldBeOverriddenTest() { // Nothing is overridden }; - Assert.assertEquals(ListRenderer.class, listRenderer.getNextRenderer().getClass()); + Assertions.assertEquals(ListRenderer.class, listRenderer.getNextRenderer().getClass()); } @Test @@ -91,7 +90,7 @@ public void symbolPositioningInsideDrawnOnceTest() { result.getSplitRenderer().draw(new DrawContext(document.getPdfDocument(), new PdfCanvas(pdfPage))); // only split part is drawn, list symbol is expected to be drawn only once. - Assert.assertEquals(1, invocationsCounter.getInvocationsCount()); + Assertions.assertEquals(1, invocationsCounter.getInvocationsCount()); } @Test @@ -120,7 +119,7 @@ public void symbolPositioningInsideAfterPageBreakTest() { Pattern regex = Pattern.compile("^.-.*?-.*$"); java.util.List childRenderers = listRenderer.getChildRenderers(); - Assert.assertEquals(0, childRenderers.stream() + Assertions.assertEquals(0, childRenderers.stream() .filter(listitem -> regex.matcher(listitem.toString()).matches()).count()); } diff --git a/layout/src/test/java/com/itextpdf/layout/renderer/MetaInfoContainerUnitTest.java b/layout/src/test/java/com/itextpdf/layout/renderer/MetaInfoContainerUnitTest.java index 5abaa3818b..c1a1ad0c4c 100644 --- a/layout/src/test/java/com/itextpdf/layout/renderer/MetaInfoContainerUnitTest.java +++ b/layout/src/test/java/com/itextpdf/layout/renderer/MetaInfoContainerUnitTest.java @@ -24,13 +24,12 @@ This file is part of the iText (R) project. import com.itextpdf.commons.actions.contexts.IMetaInfo; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class MetaInfoContainerUnitTest extends ExtendedITextTest { @Test @@ -38,14 +37,14 @@ public void createAndGetMetaInfoTest() { TestMetaInfo metaInfo = new TestMetaInfo(); MetaInfoContainer metaInfoContainer = new MetaInfoContainer(metaInfo); - Assert.assertSame(metaInfo, metaInfoContainer.getMetaInfo()); + Assertions.assertSame(metaInfo, metaInfoContainer.getMetaInfo()); } @Test public void getNullMetaInfoTest() { MetaInfoContainer metaInfoContainer = new MetaInfoContainer(null); - Assert.assertNull(metaInfoContainer.getMetaInfo()); + Assertions.assertNull(metaInfoContainer.getMetaInfo()); } private static class TestMetaInfo implements IMetaInfo { diff --git a/layout/src/test/java/com/itextpdf/layout/renderer/MinWidthTest.java b/layout/src/test/java/com/itextpdf/layout/renderer/MinWidthTest.java index 5cb74d613d..8a5bc3b168 100644 --- a/layout/src/test/java/com/itextpdf/layout/renderer/MinWidthTest.java +++ b/layout/src/test/java/com/itextpdf/layout/renderer/MinWidthTest.java @@ -46,22 +46,21 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class MinWidthTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/layout/MinWidthTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/layout/MinWidthTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } @@ -81,7 +80,7 @@ public void paragraphTest() throws IOException, InterruptedException { doc.add(p); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -101,7 +100,7 @@ public void divTest() throws IOException, InterruptedException { doc.add(d); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -122,7 +121,7 @@ public void divWithSmallRotatedParagraph() throws IOException, InterruptedExcept doc.add(d); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @@ -145,7 +144,7 @@ public void divWithBigRotatedParagraph() throws IOException, InterruptedExceptio doc.add(d); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -167,7 +166,7 @@ public void divWithSmallRotatedDiv() throws IOException, InterruptedException { doc.add(d); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @@ -189,7 +188,7 @@ public void divWithBigRotatedDiv() throws IOException, InterruptedException { doc.add(d); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -216,7 +215,7 @@ public void divWithPercentImage() throws IOException, InterruptedException { doc.add(dPercent); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -243,7 +242,7 @@ public void divWithRotatedPercentImage() throws IOException, InterruptedExceptio doc.add(dPercent); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -271,7 +270,7 @@ public void multipleDivTest() throws IOException, InterruptedException { doc.add(externalDiv); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -312,7 +311,7 @@ public void simpleTableTest() throws IOException, InterruptedException { doc.add(maxTable); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -353,7 +352,7 @@ public void colspanTableTest() throws IOException, InterruptedException { doc.add(maxTable); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -399,7 +398,7 @@ public void colspanRowspanTableTest() throws IOException, InterruptedException { doc.add(maxTable); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } @Test @@ -452,7 +451,7 @@ public void headerFooterTableTest() throws IOException, InterruptedException { doc.add(maxTable); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff")); } private static float toEffectiveWidth(IBlockElement b, float fullWidth) { diff --git a/layout/src/test/java/com/itextpdf/layout/renderer/MulticolRendererUnitTest.java b/layout/src/test/java/com/itextpdf/layout/renderer/MulticolRendererUnitTest.java index cd37ab5f4c..afaf4b8a8a 100644 --- a/layout/src/test/java/com/itextpdf/layout/renderer/MulticolRendererUnitTest.java +++ b/layout/src/test/java/com/itextpdf/layout/renderer/MulticolRendererUnitTest.java @@ -36,14 +36,13 @@ This file is part of the iText (R) project. import com.itextpdf.layout.properties.UnitValue; import com.itextpdf.layout.splitting.DefaultSplitCharacters; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; -@Category(UnitTest.class) +@Tag("UnitTest") public class MulticolRendererUnitTest extends ExtendedITextTest { @Test @@ -60,9 +59,9 @@ public void simpleTest() throws IOException { MulticolRenderer renderer = (MulticolRenderer) columnContainer.createRendererSubTree(); LayoutResult result = renderer.layout(new LayoutContext(new LayoutArea(1, new Rectangle(600f, 200.0f)))); - Assert.assertTrue(result.getSplitRenderer() instanceof MulticolRenderer); - Assert.assertEquals(3, result.getSplitRenderer().getChildRenderers().size()); - Assert.assertEquals(9, result.getSplitRenderer().getChildRenderers().get(0).getChildRenderers().size()); + Assertions.assertTrue(result.getSplitRenderer() instanceof MulticolRenderer); + Assertions.assertEquals(3, result.getSplitRenderer().getChildRenderers().size()); + Assertions.assertEquals(9, result.getSplitRenderer().getChildRenderers().get(0).getChildRenderers().size()); } @Test @@ -80,7 +79,7 @@ public void keepTogetherParagraphTest() throws IOException { MulticolRenderer renderer = (MulticolRenderer) columnContainer.createRendererSubTree(); LayoutResult result = renderer.layout(new LayoutContext(new LayoutArea(1, new Rectangle(200f, 20f)))); - Assert.assertEquals(1, result.getOverflowRenderer().getChildRenderers().size()); + Assertions.assertEquals(1, result.getOverflowRenderer().getChildRenderers().size()); } @Test @@ -97,7 +96,7 @@ public void divWithNoHeightTest() throws IOException { MulticolRenderer renderer = (MulticolRenderer) div.createRendererSubTree(); LayoutResult result = renderer.layout(new LayoutContext(new LayoutArea(1, new Rectangle(20.0f, 20.0f)))); - Assert.assertEquals(LayoutResult.NOTHING, result.getStatus()); + Assertions.assertEquals(LayoutResult.NOTHING, result.getStatus()); } @Test @@ -116,10 +115,10 @@ public void multipleParagraphsTest() throws IOException { MulticolRenderer renderer = (MulticolRenderer) div.createRendererSubTree(); LayoutResult result = renderer.layout(new LayoutContext(new LayoutArea(1, new Rectangle(600f, 30.0f)))); - Assert.assertTrue(result.getSplitRenderer() instanceof MulticolRenderer); - Assert.assertEquals(3, result.getSplitRenderer().getChildRenderers().size()); - Assert.assertEquals(1, result.getSplitRenderer().getChildRenderers().get(0).getChildRenderers().size()); - Assert.assertEquals(1, ((ParagraphRenderer)result.getSplitRenderer().getChildRenderers().get(0) + Assertions.assertTrue(result.getSplitRenderer() instanceof MulticolRenderer); + Assertions.assertEquals(3, result.getSplitRenderer().getChildRenderers().size()); + Assertions.assertEquals(1, result.getSplitRenderer().getChildRenderers().get(0).getChildRenderers().size()); + Assertions.assertEquals(1, ((ParagraphRenderer)result.getSplitRenderer().getChildRenderers().get(0) .getChildRenderers().get(0)).getLines().size()); } diff --git a/layout/src/test/java/com/itextpdf/layout/renderer/ParagraphRendererUnitTest.java b/layout/src/test/java/com/itextpdf/layout/renderer/ParagraphRendererUnitTest.java index aa20e3fc8b..8c638ab883 100644 --- a/layout/src/test/java/com/itextpdf/layout/renderer/ParagraphRendererUnitTest.java +++ b/layout/src/test/java/com/itextpdf/layout/renderer/ParagraphRendererUnitTest.java @@ -27,13 +27,12 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class ParagraphRendererUnitTest extends ExtendedITextTest { @Test @@ -45,6 +44,6 @@ public void getNextRendererShouldBeOverriddenTest() { // Nothing is overridden }; - Assert.assertEquals(ParagraphRenderer.class, paragraphRenderer.getNextRenderer().getClass()); + Assertions.assertEquals(ParagraphRenderer.class, paragraphRenderer.getNextRenderer().getClass()); } } diff --git a/layout/src/test/java/com/itextpdf/layout/renderer/TabRendererUnitTest.java b/layout/src/test/java/com/itextpdf/layout/renderer/TabRendererUnitTest.java index 02f51985a7..73d14ad176 100644 --- a/layout/src/test/java/com/itextpdf/layout/renderer/TabRendererUnitTest.java +++ b/layout/src/test/java/com/itextpdf/layout/renderer/TabRendererUnitTest.java @@ -27,13 +27,12 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class TabRendererUnitTest extends ExtendedITextTest { @Test @@ -45,6 +44,6 @@ public void getNextRendererShouldBeOverriddenTest() { // Nothing is overridden }; - Assert.assertEquals(TabRenderer.class, tabRenderer.getNextRenderer().getClass()); + Assertions.assertEquals(TabRenderer.class, tabRenderer.getNextRenderer().getClass()); } } diff --git a/layout/src/test/java/com/itextpdf/layout/renderer/TableRendererTest.java b/layout/src/test/java/com/itextpdf/layout/renderer/TableRendererTest.java index 3312db7ab6..c47d6fd6b8 100644 --- a/layout/src/test/java/com/itextpdf/layout/renderer/TableRendererTest.java +++ b/layout/src/test/java/com/itextpdf/layout/renderer/TableRendererTest.java @@ -36,13 +36,12 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class TableRendererTest extends ExtendedITextTest { @Test @@ -79,8 +78,8 @@ public void calculateColumnWidthsNotPointValue() { MinMaxWidth minMaxWidth = tableRenderer.getMinMaxWidth(); // TODO DEVSIX-3676: currently margins and paddings are still applied as if they are in points. After the mentioned ticket is fixed, the expected values should be updated. - Assert.assertEquals(327.46f, minMaxWidth.getMaxWidth(), 0.001); - Assert.assertEquals(327.46f, minMaxWidth.getMinWidth(), 0.001); + Assertions.assertEquals(327.46f, minMaxWidth.getMaxWidth(), 0.001); + Assertions.assertEquals(327.46f, minMaxWidth.getMinWidth(), 0.001); } @Test @@ -95,6 +94,6 @@ public void testIsOriginalNonSplitRenderer() { TableRenderer[] grandChildren = children[1].split(1); - Assert.assertFalse(grandChildren[0].isOriginalNonSplitRenderer); + Assertions.assertFalse(grandChildren[0].isOriginalNonSplitRenderer); } } diff --git a/layout/src/test/java/com/itextpdf/layout/renderer/TableRendererUnitTest.java b/layout/src/test/java/com/itextpdf/layout/renderer/TableRendererUnitTest.java index f27da797e2..2fd242bc0a 100644 --- a/layout/src/test/java/com/itextpdf/layout/renderer/TableRendererUnitTest.java +++ b/layout/src/test/java/com/itextpdf/layout/renderer/TableRendererUnitTest.java @@ -27,13 +27,12 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class TableRendererUnitTest extends ExtendedITextTest { @Test @@ -45,6 +44,6 @@ public void getNextRendererShouldBeOverriddenTest() { // Nothing is overridden }; - Assert.assertEquals(TableRenderer.class, tableRenderer.getNextRenderer().getClass()); + Assertions.assertEquals(TableRenderer.class, tableRenderer.getNextRenderer().getClass()); } } diff --git a/layout/src/test/java/com/itextpdf/layout/renderer/TableWidthsTest.java b/layout/src/test/java/com/itextpdf/layout/renderer/TableWidthsTest.java index 67a1720b46..44e362b70f 100644 --- a/layout/src/test/java/com/itextpdf/layout/renderer/TableWidthsTest.java +++ b/layout/src/test/java/com/itextpdf/layout/renderer/TableWidthsTest.java @@ -37,14 +37,13 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.ByteArrayOutputStream; import java.util.List; -@Category(UnitTest.class) +@Tag("UnitTest") public class TableWidthsTest extends ExtendedITextTest { @Test diff --git a/layout/src/test/java/com/itextpdf/layout/renderer/TargetCounterHandlerTest.java b/layout/src/test/java/com/itextpdf/layout/renderer/TargetCounterHandlerTest.java index c613c75f85..0b68ca61a9 100644 --- a/layout/src/test/java/com/itextpdf/layout/renderer/TargetCounterHandlerTest.java +++ b/layout/src/test/java/com/itextpdf/layout/renderer/TargetCounterHandlerTest.java @@ -44,21 +44,20 @@ This file is part of the iText (R) project. import com.itextpdf.layout.layout.LayoutResult; import com.itextpdf.layout.splitting.DefaultSplitCharacters; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class TargetCounterHandlerTest extends ExtendedITextTest { public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/layout/renderer/TargetCounterHandlerTest/"; public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/layout/renderer/TargetCounterHandlerTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(DESTINATION_FOLDER); } @@ -74,7 +73,7 @@ public void blockRendererAddByIDTest() { divRenderer.layout(layoutContext); documentRenderer.getTargetCounterHandler().prepareHandlerToRelayout(); - Assert.assertEquals((Integer) 4, TargetCounterHandler.getPageByID(divRenderer, id)); + Assertions.assertEquals((Integer) 4, TargetCounterHandler.getPageByID(divRenderer, id)); } @Test @@ -96,7 +95,7 @@ public void textRendererAddByIDTest() throws IOException { textRenderer.layout(layoutContext); documentRenderer.getTargetCounterHandler().prepareHandlerToRelayout(); - Assert.assertEquals((Integer) 4, TargetCounterHandler.getPageByID(textRenderer, id)); + Assertions.assertEquals((Integer) 4, TargetCounterHandler.getPageByID(textRenderer, id)); } @Test @@ -110,7 +109,7 @@ public void tableRendererAddByIDTest() { tableRenderer.layout(layoutContext); documentRenderer.getTargetCounterHandler().prepareHandlerToRelayout(); - Assert.assertEquals((Integer) 4, TargetCounterHandler.getPageByID(tableRenderer, id)); + Assertions.assertEquals((Integer) 4, TargetCounterHandler.getPageByID(tableRenderer, id)); } @Test @@ -124,7 +123,7 @@ public void paragraphRendererAddByIDTest() { paragraphRenderer.layout(layoutContext); documentRenderer.getTargetCounterHandler().prepareHandlerToRelayout(); - Assert.assertEquals((Integer) 4, TargetCounterHandler.getPageByID(paragraphRenderer, id)); + Assertions.assertEquals((Integer) 4, TargetCounterHandler.getPageByID(paragraphRenderer, id)); } @Test @@ -138,7 +137,7 @@ public void imageRendererAddByIDTest() { imageRenderer.layout(layoutContext); documentRenderer.getTargetCounterHandler().prepareHandlerToRelayout(); - Assert.assertEquals((Integer) 4, TargetCounterHandler.getPageByID(imageRenderer, id)); + Assertions.assertEquals((Integer) 4, TargetCounterHandler.getPageByID(imageRenderer, id)); } @Test @@ -152,7 +151,7 @@ public void lineRendererAddByIDTest() { lineRenderer.layout(layoutContext); documentRenderer.getTargetCounterHandler().prepareHandlerToRelayout(); - Assert.assertEquals((Integer) 4, TargetCounterHandler.getPageByID(lineRenderer, id)); + Assertions.assertEquals((Integer) 4, TargetCounterHandler.getPageByID(lineRenderer, id)); } @Test @@ -179,7 +178,7 @@ public void targetCounterHandlerEndToEndLayoutTest() throws IOException, Interru document.close(); - Assert.assertNull(new CompareTool().compareByContent(targetPdf, cmpPdf, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(targetPdf, cmpPdf, DESTINATION_FOLDER, "diff")); } private static class TargetCounterAwareTextRenderer extends TextRenderer { diff --git a/layout/src/test/java/com/itextpdf/layout/renderer/TargetCounterHandlerUnitTest.java b/layout/src/test/java/com/itextpdf/layout/renderer/TargetCounterHandlerUnitTest.java index 0c53b0d2dd..5728d723f1 100644 --- a/layout/src/test/java/com/itextpdf/layout/renderer/TargetCounterHandlerUnitTest.java +++ b/layout/src/test/java/com/itextpdf/layout/renderer/TargetCounterHandlerUnitTest.java @@ -28,12 +28,11 @@ This file is part of the iText (R) project. import com.itextpdf.layout.layout.LayoutResult; import com.itextpdf.layout.properties.Property; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class TargetCounterHandlerUnitTest extends ExtendedITextTest { @Test @@ -68,7 +67,7 @@ public LayoutArea getOccupiedArea() { TargetCounterHandler.addPageByID(renderer); Integer page = TargetCounterHandler.getPageByID(renderer, id); - Assert.assertNull(page); + Assertions.assertNull(page); } @Test @@ -100,7 +99,7 @@ public LayoutArea getOccupiedArea() { renderer.setParent(documentRenderer); renderer.setProperty(Property.ID, id); - Assert.assertFalse(TargetCounterHandler.isValueDefinedForThisId(renderer, id)); + Assertions.assertFalse(TargetCounterHandler.isValueDefinedForThisId(renderer, id)); } @Test @@ -119,7 +118,7 @@ public LayoutArea getOccupiedArea() { TargetCounterHandler.addPageByID(renderer); Integer page = TargetCounterHandler.getPageByID(renderer, id); - Assert.assertNull(page); + Assertions.assertNull(page); } @Test @@ -141,7 +140,7 @@ public LayoutArea getOccupiedArea() { documentRenderer.getTargetCounterHandler().prepareHandlerToRelayout(); Integer page = TargetCounterHandler.getPageByID(renderer, id); - Assert.assertEquals((Integer) 8, page); + Assertions.assertEquals((Integer) 8, page); } @Test @@ -163,7 +162,7 @@ public LayoutArea getOccupiedArea() { documentRenderer.getTargetCounterHandler().prepareHandlerToRelayout(); Integer page = TargetCounterHandler.getPageByID(renderer, id); - Assert.assertEquals((Integer) 2, page); + Assertions.assertEquals((Integer) 2, page); } @Test @@ -184,12 +183,12 @@ public LayoutArea getOccupiedArea() { documentRenderer.getTargetCounterHandler().prepareHandlerToRelayout(); Integer page = TargetCounterHandler.getPageByID(renderer, id); - Assert.assertEquals((Integer) expectedPage, page); + Assertions.assertEquals((Integer) expectedPage, page); IRenderer anotherRenderer = new TextRenderer(new Text("another_renderer")); anotherRenderer.setParent(documentRenderer); page = TargetCounterHandler.getPageByID(anotherRenderer, id); - Assert.assertEquals((Integer) expectedPage, page); + Assertions.assertEquals((Integer) expectedPage, page); } @Test @@ -207,11 +206,11 @@ public LayoutArea getOccupiedArea() { }; renderer.setParent(documentRenderer); renderer.setProperty(Property.ID, id); - Assert.assertFalse(documentRenderer.isRelayoutRequired()); + Assertions.assertFalse(documentRenderer.isRelayoutRequired()); TargetCounterHandler.addPageByID(renderer); - Assert.assertTrue(documentRenderer.isRelayoutRequired()); + Assertions.assertTrue(documentRenderer.isRelayoutRequired()); documentRenderer.getTargetCounterHandler().prepareHandlerToRelayout(); - Assert.assertFalse(documentRenderer.isRelayoutRequired()); + Assertions.assertFalse(documentRenderer.isRelayoutRequired()); } @Test @@ -231,7 +230,7 @@ public LayoutArea getOccupiedArea() { renderer.setProperty(Property.ID, id); TargetCounterHandler.addPageByID(renderer); TargetCounterHandler copy = new TargetCounterHandler(documentRenderer.getTargetCounterHandler()); - Assert.assertTrue(copy.isRelayoutRequired()); + Assertions.assertTrue(copy.isRelayoutRequired()); } @Test @@ -251,7 +250,7 @@ public LayoutArea getOccupiedArea() { renderer.setParent(documentRenderer); renderer.setProperty(Property.ID, id); TargetCounterHandler.addPageByID(renderer); - Assert.assertTrue(TargetCounterHandler.isValueDefinedForThisId(renderer, id)); - Assert.assertFalse(TargetCounterHandler.isValueDefinedForThisId(renderer, notAddedId)); + Assertions.assertTrue(TargetCounterHandler.isValueDefinedForThisId(renderer, id)); + Assertions.assertFalse(TargetCounterHandler.isValueDefinedForThisId(renderer, notAddedId)); } } diff --git a/layout/src/test/java/com/itextpdf/layout/renderer/TextFilteringReversedRangesTest.java b/layout/src/test/java/com/itextpdf/layout/renderer/TextFilteringReversedRangesTest.java index 5a6459c119..7b973018c4 100644 --- a/layout/src/test/java/com/itextpdf/layout/renderer/TextFilteringReversedRangesTest.java +++ b/layout/src/test/java/com/itextpdf/layout/renderer/TextFilteringReversedRangesTest.java @@ -23,14 +23,13 @@ This file is part of the iText (R) project. package com.itextpdf.layout.renderer; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.util.ArrayList; -@Category(UnitTest.class) +@Tag("UnitTest") public class TextFilteringReversedRangesTest extends ExtendedITextTest { @Test @@ -40,7 +39,7 @@ public void test01() { int[] range = new int[] {0, 1}; TextRenderer.updateRangeBasedOnRemovedCharacters(removedIds, range); - Assert.assertArrayEquals(new int[] {0, 0}, range); + Assertions.assertArrayEquals(new int[] {0, 0}, range); } @Test @@ -50,7 +49,7 @@ public void test02() { int[] range = new int[] {0, 5}; TextRenderer.updateRangeBasedOnRemovedCharacters(removedIds, range); - Assert.assertArrayEquals(new int[] {0, 5}, range); + Assertions.assertArrayEquals(new int[] {0, 5}, range); } @Test @@ -62,7 +61,7 @@ public void test03() { int[] range = new int[] {0, 5}; TextRenderer.updateRangeBasedOnRemovedCharacters(removedIds, range); - Assert.assertArrayEquals(new int[] {0, 3}, range); + Assertions.assertArrayEquals(new int[] {0, 3}, range); } @Test @@ -72,7 +71,7 @@ public void test04() { int[] range = new int[] {0, 1}; TextRenderer.updateRangeBasedOnRemovedCharacters(removedIds, range); - Assert.assertArrayEquals(new int[] {0, 0}, range); + Assertions.assertArrayEquals(new int[] {0, 0}, range); } } diff --git a/layout/src/test/java/com/itextpdf/layout/renderer/TextPreprocessingUtilTest.java b/layout/src/test/java/com/itextpdf/layout/renderer/TextPreprocessingUtilTest.java index c1065806b6..e5b15f8de8 100644 --- a/layout/src/test/java/com/itextpdf/layout/renderer/TextPreprocessingUtilTest.java +++ b/layout/src/test/java/com/itextpdf/layout/renderer/TextPreprocessingUtilTest.java @@ -28,20 +28,19 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.font.PdfFont; import com.itextpdf.kernel.font.PdfFontFactory; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.IOException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class TextPreprocessingUtilTest extends ExtendedITextTest { private static PdfFont pdfFont; - @BeforeClass + @BeforeAll public static void initializeFont() throws IOException { pdfFont = PdfFontFactory.createFont(); } @@ -75,7 +74,7 @@ public void regularSymbolTest() { TextPreprocessingUtil.replaceSpecialWhitespaceGlyphs(glyphLine, pdfFont); Glyph glyph = glyphLine.get(0); - Assert.assertEquals(regularGlyph, glyph); + Assertions.assertEquals(regularGlyph, glyph); } private void specialWhitespaceGlyphTest(int unicode) { @@ -87,9 +86,9 @@ private void specialWhitespaceGlyphTest(int unicode) { Glyph glyph = glyphLine.get(0); Glyph space = pdfFont.getGlyph('\u0020'); - Assert.assertEquals(space.getCode(), glyph.getCode()); - Assert.assertEquals(space.getWidth(), glyph.getWidth()); - Assert.assertEquals(space.getUnicode(), glyph.getUnicode()); - Assert.assertArrayEquals(TextUtil.convertFromUtf32(unicode), glyph.getChars()); + Assertions.assertEquals(space.getCode(), glyph.getCode()); + Assertions.assertEquals(space.getWidth(), glyph.getWidth()); + Assertions.assertEquals(space.getUnicode(), glyph.getUnicode()); + Assertions.assertArrayEquals(TextUtil.convertFromUtf32(unicode), glyph.getChars()); } } diff --git a/layout/src/test/java/com/itextpdf/layout/renderer/TextRendererIntegrationTest.java b/layout/src/test/java/com/itextpdf/layout/renderer/TextRendererIntegrationTest.java index 4de956085d..012f953e35 100644 --- a/layout/src/test/java/com/itextpdf/layout/renderer/TextRendererIntegrationTest.java +++ b/layout/src/test/java/com/itextpdf/layout/renderer/TextRendererIntegrationTest.java @@ -33,6 +33,7 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.geom.Rectangle; import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfWriter; +import com.itextpdf.kernel.pdf.canvas.PdfCanvasConstants.TextRenderingMode; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.layout.ColumnDocumentRenderer; import com.itextpdf.layout.Document; @@ -51,26 +52,28 @@ This file is part of the iText (R) project. import com.itextpdf.layout.properties.Property; import com.itextpdf.layout.properties.RenderingMode; import com.itextpdf.layout.properties.TextAlignment; +import com.itextpdf.layout.properties.TransparentColor; import com.itextpdf.layout.properties.UnitValue; import com.itextpdf.layout.font.FontProvider; import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; +import java.io.ByteArrayOutputStream; import java.io.IOException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import java.nio.charset.StandardCharsets; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class TextRendererIntegrationTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/layout/TextRendererIntegrationTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/layout/TextRendererIntegrationTest/"; public static final String fontsFolder = "./src/test/resources/com/itextpdf/layout/fonts/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } @@ -96,7 +99,7 @@ public void trimFirstJapaneseCharactersTest() throws IOException, InterruptedExc doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } @Test @@ -134,7 +137,7 @@ public void wordSplitAcrossTwoTextRenderers() throws IOException, InterruptedExc doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } @Test @@ -180,7 +183,7 @@ public void wordSplitAcrossMultipleRenderers() throws IOException, InterruptedEx doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } @Test @@ -214,7 +217,7 @@ public void wordEndsAndFollowingTextRendererStartsWithWhitespaces01() throws IOE doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } @Test @@ -244,7 +247,7 @@ public void wordEndsAndFollowingTextRendererStartsWithWhitespaces02() throws IOE doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } @Test @@ -280,7 +283,7 @@ public void forcedWordSplit() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } @Test @@ -325,7 +328,7 @@ public void wordSplitAcrossMultipleRenderersOverflowXVisibleWithPrecedingPlaceho doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } @Test @@ -363,7 +366,7 @@ public void wordSplitAcrossMultipleRenderersOverflowXVisible() throws IOExceptio doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } @Test @@ -404,7 +407,7 @@ public void wordSplitRenderersWithFittingFloatingElementInBetween() throws IOExc doc.add(p); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } @Test @@ -441,7 +444,7 @@ public void wordSplitRenderersWithNotFittingFloatingElementInBetween() throws IO doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } @Test @@ -485,7 +488,7 @@ public void wordSplitRenderersWithFittingFloatingInBetweenInSecondWord() throws doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } @Test @@ -526,7 +529,7 @@ public void wordSplitRenderersWithOverflowedFloatingElementInBetween() throws IO doc.add(p); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } @Test @@ -574,7 +577,7 @@ public void wordSplitAcrossMutipleTextRenderersWithinFloatingContainer() throws doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } @Test @@ -617,7 +620,7 @@ public void wordSplitAcrossRenderersWithPrecedingImageRenderer() throws IOExcept doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } @Test @@ -661,7 +664,7 @@ public void minMaxWidthWordSplitAcrossMultipleTextRenderers() throws IOException doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } @Test @@ -699,7 +702,7 @@ public void minWidthForWordInMultipleTextRenderersFollowedByFloatTest() throws I narrowDivWithTable.add(table); doc.add(narrowDivWithTable); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } @Test @@ -720,7 +723,7 @@ public void overflowWrapBreakWordWithOverflowXTest() throws IOException, Interru paragraph.setProperty(Property.RENDERING_MODE, RenderingMode.HTML_MODE); doc.add(paragraph); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } @Test @@ -772,7 +775,7 @@ public IRenderer getNextRenderer() { doc.add(new Paragraph(text)); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } @Test @@ -792,7 +795,7 @@ public void nbspCannotBeFitAndIsTheOnlySymbolTest() throws IOException, Interrup doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } @Test @@ -816,7 +819,7 @@ public void nbspCannotBeFitAndMakesTheFirstChunkTest() throws IOException, Inter doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } @Test @@ -839,7 +842,7 @@ public void nbspCannotBeFitAndIsTheFirstSymbolOfChunkTest() throws IOException, doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } @Test @@ -860,7 +863,7 @@ public void nbspCannotBeFitAndIsTheLastSymbolOfFirstChunkTest() throws IOExcepti doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); } @Test @@ -875,7 +878,7 @@ public void customTextRendererShouldOverrideCreateCopyTest() throws IOException, Document doc = new Document(pdfDoc); FontProvider fontProvider = new FontProvider(); - Assert.assertTrue(fontProvider.addFont(fontsFolder + "NotoSans-Regular.ttf")); + Assertions.assertTrue(fontProvider.addFont(fontsFolder + "NotoSans-Regular.ttf")); doc.setFontProvider(fontProvider); // To trigger font selector related logic one need to apply some font on a document @@ -910,7 +913,115 @@ public IRenderer getNextRenderer() { doc.add(new Paragraph(text)); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder)); + } + + @Test + @LogMessages(messages = { + @LogMessage(messageTemplate = IoLogMessageConstant.OCCUPIED_AREA_HAS_NOT_BEEN_INITIALIZED, count = 1) + }) + public void drawWithSkewAndHorizontalScalingTest() { + try (PdfDocument pdfDocument = new PdfDocument(new PdfWriter(new ByteArrayOutputStream()))) { + Document doc = new Document(pdfDocument); + Text text = new Text("test string") + .setTextRise(0) + .setWordSpacing(0) + .setSkew(10, 10) + .setHorizontalScaling(2); + Paragraph paragraph = new Paragraph().add(text); + paragraph.setNextRenderer(new TextRenderer(text) { + @Override + public void draw(DrawContext drawContext) { + drawContext.getCanvas() + .saveState() + .rectangle(occupiedArea.getBBox()) + .fill() + .restoreState(); + super.draw(drawContext); + } + + @Override + public IRenderer getNextRenderer() { + return new TextRendererWithOverriddenGetNextRenderer((Text) modelElement); + } + }); + doc.add(paragraph); + String contentstream = new String(doc.getPdfDocument().getPage(1).getContentBytes(), + StandardCharsets.UTF_8); + Assertions.assertTrue(contentstream.contains("test string")); + } + } + + @Test + @LogMessages(messages = { + @LogMessage(messageTemplate = IoLogMessageConstant.OCCUPIED_AREA_HAS_NOT_BEEN_INITIALIZED, count = 1) + }) + public void drawTextRenderingModeFillStrokeTest() { + try (PdfDocument pdfDocument = new PdfDocument(new PdfWriter(new ByteArrayOutputStream()))) { + Document doc = new Document(pdfDocument); + Text text = new Text("test string") + .setTextRenderingMode(TextRenderingMode.FILL_STROKE); + Paragraph paragraph = new Paragraph().add(text) + .setBackgroundColor(ColorConstants.YELLOW) + .setWidth(10) + .setStrokeWidth(1f) + .setStrokeColor(null) + .setBorder(new SolidBorder(1)); + paragraph.setNextRenderer(new TextRenderer(text) { + @Override + public void draw(DrawContext drawContext) { + drawContext.getCanvas() + .saveState() + .rectangle(occupiedArea.getBBox()) + .fill() + .restoreState(); + super.draw(drawContext); + } + + @Override + public IRenderer getNextRenderer() { + return new TextRendererWithOverriddenGetNextRenderer((Text) modelElement); + } + }); + doc.add(paragraph); + String contentstream = new String(doc.getPdfDocument().getPage(1).getContentBytes(), + StandardCharsets.UTF_8); + Assertions.assertTrue(contentstream.contains("test string")); + } + } + + @Test + @LogMessages(messages = { + @LogMessage(messageTemplate = IoLogMessageConstant.OCCUPIED_AREA_HAS_NOT_BEEN_INITIALIZED, count = 1) + }) + public void fontColorNullTest() { + try (PdfDocument pdfDocument = new PdfDocument(new PdfWriter(new ByteArrayOutputStream()))) { + Document doc = new Document(pdfDocument); + Text text = new Text("test string") + .setTextRenderingMode(TextRenderingMode.FILL_STROKE); + Paragraph paragraph = new Paragraph().add(text); + paragraph.setNextRenderer(new TextRenderer(text) { + @Override + public void draw(DrawContext drawContext) { + drawContext.getCanvas() + .saveState() + .rectangle(occupiedArea.getBBox()) + .fill() + .restoreState(); + this.setProperty(Property.FONT_COLOR, new TransparentColor(ColorConstants.RED)); + super.draw(drawContext); + } + + @Override + public IRenderer getNextRenderer() { + return new TextRendererWithOverriddenGetNextRenderer((Text) modelElement); + } + }); + doc.add(paragraph); + String contentstream = new String(doc.getPdfDocument().getPage(1).getContentBytes(), + StandardCharsets.UTF_8); + Assertions.assertTrue(contentstream.contains("test string")); + } } private static class TextRendererWithOverriddenGetNextRenderer extends TextRenderer { diff --git a/layout/src/test/java/com/itextpdf/layout/renderer/TextRendererPositioningTest.java b/layout/src/test/java/com/itextpdf/layout/renderer/TextRendererPositioningTest.java index 81f9bb527c..800151f572 100644 --- a/layout/src/test/java/com/itextpdf/layout/renderer/TextRendererPositioningTest.java +++ b/layout/src/test/java/com/itextpdf/layout/renderer/TextRendererPositioningTest.java @@ -33,20 +33,19 @@ This file is part of the iText (R) project. import com.itextpdf.layout.properties.Property; import com.itextpdf.layout.properties.UnitValue; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class TextRendererPositioningTest extends ExtendedITextTest { public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/layout/TextRendererPositioningTest/"; public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/layout/TextRendererPositioningTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(DESTINATION_FOLDER); } @@ -72,7 +71,7 @@ public void marginTopTest() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -96,7 +95,7 @@ public void marginBottomTest() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -121,7 +120,7 @@ public void marginTopBottomTest() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -146,7 +145,7 @@ public void diffFontSizeTest() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -173,6 +172,6 @@ public void marginAndPaddingTest() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } } diff --git a/layout/src/test/java/com/itextpdf/layout/renderer/TextRendererTest.java b/layout/src/test/java/com/itextpdf/layout/renderer/TextRendererTest.java index c02b90d2b6..3d2fc7d591 100644 --- a/layout/src/test/java/com/itextpdf/layout/renderer/TextRendererTest.java +++ b/layout/src/test/java/com/itextpdf/layout/renderer/TextRendererTest.java @@ -22,9 +22,9 @@ This file is part of the iText (R) project. */ package com.itextpdf.layout.renderer; -import com.itextpdf.io.logs.IoLogMessageConstant; import com.itextpdf.io.font.otf.Glyph; import com.itextpdf.io.font.otf.GlyphLine; +import com.itextpdf.io.logs.IoLogMessageConstant; import com.itextpdf.io.util.TextUtil; import com.itextpdf.kernel.font.PdfFont; import com.itextpdf.kernel.font.PdfFontFactory; @@ -41,26 +41,24 @@ This file is part of the iText (R) project. import com.itextpdf.layout.layout.LayoutResult; import com.itextpdf.layout.layout.TextLayoutResult; import com.itextpdf.layout.minmaxwidth.MinMaxWidth; +import com.itextpdf.layout.properties.FloatPropertyValue; import com.itextpdf.layout.properties.OverflowPropertyValue; import com.itextpdf.layout.properties.OverflowWrapPropertyValue; import com.itextpdf.layout.properties.Property; import com.itextpdf.layout.properties.RenderingMode; import com.itextpdf.layout.properties.UnitValue; -import com.itextpdf.layout.properties.FloatPropertyValue; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.ByteArrayOutputStream; import java.io.IOException; - +import java.nio.charset.StandardCharsets; import java.util.Arrays; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -@Category(UnitTest.class) +@Tag("UnitTest") public class TextRendererTest extends RendererUnitTest { private static final String FONTS_FOLDER = "./src/test/resources/com/itextpdf/layout/fonts/"; @@ -87,7 +85,7 @@ public void nextRendererTest() { LayoutResult result1 = textRenderer1.layout(layoutContext); LayoutResult result2 = textRenderer2.layout(layoutContext); - Assert.assertEquals(result1.getOccupiedArea(), result2.getOccupiedArea()); + Assertions.assertEquals(result1.getOccupiedArea(), result2.getOccupiedArea()); } @Test @@ -103,7 +101,7 @@ public void setTextException() { rend.setProperty(Property.FONT_PROVIDER, fp); rend.setProperty(Property.FONT, new String[] {fontName}); rend.setText(val); - Assert.assertEquals(val, rend.getText().toString()); + Assertions.assertEquals(val, rend.getText().toString()); } @Test @@ -123,12 +121,12 @@ public void setTextGlyphLineAndFontParamTest() throws IOException { renderer.setText(glyphLine, pdfFont); GlyphLine actualLine = renderer.getText(); - Assert.assertFalse(actualLine == glyphLine); + Assertions.assertFalse(actualLine == glyphLine); Glyph glyph = actualLine.get(0); Glyph space = pdfFont.getGlyph('\u0020'); // Check that the glyph line has been processed using the replaceSpecialWhitespaceGlyphs method - Assert.assertEquals(space.getCode(), glyph.getCode()); - Assert.assertEquals(space.getWidth(), glyph.getWidth()); + Assertions.assertEquals(space.getCode(), glyph.getCode()); + Assertions.assertEquals(space.getWidth(), glyph.getWidth()); } @Test @@ -146,19 +144,19 @@ public void setTextGlyphLineAndPositionsParamTest() throws IOException { } renderer.setText(new GlyphLine(), pdfFont); - glyphLine.start = 1; - glyphLine.end = 2; + glyphLine.setStart(1); + glyphLine.setEnd(2); renderer.setText(glyphLine, pdfFont); GlyphLine actualLine = renderer.getText(); - Assert.assertFalse(actualLine == glyphLine); + Assertions.assertFalse(actualLine == glyphLine); Glyph glyph = actualLine.get(0); Glyph space = pdfFont.getGlyph('\u0020'); // Check that the glyph line has been processed using the replaceSpecialWhitespaceGlyphs method - Assert.assertEquals(space.getCode(), glyph.getCode()); - Assert.assertEquals(space.getWidth(), glyph.getWidth()); - Assert.assertEquals(1, actualLine.start); - Assert.assertEquals(2, actualLine.end); + Assertions.assertEquals(space.getCode(), glyph.getCode()); + Assertions.assertEquals(space.getWidth(), glyph.getWidth()); + Assertions.assertEquals(1, actualLine.getStart()); + Assertions.assertEquals(2, actualLine.getEnd()); } /** @@ -190,7 +188,7 @@ public void getDescentTest() { TextRenderer textRenderer = createLayoutedTextRenderer("hello", doc); textRenderer.setProperty(Property.PADDING_TOP, UnitValue.createPointValue(20f)); textRenderer.setProperty(Property.MARGIN_TOP, UnitValue.createPointValue(20f)); - Assert.assertEquals(-2.980799674987793f, textRenderer.getDescent(), EPS); + Assertions.assertEquals(-2.980799674987793f, textRenderer.getDescent(), EPS); } @Test @@ -201,7 +199,7 @@ public void getOccupiedAreaBBoxTest() { textRenderer.setProperty(Property.MARGIN_TOP, UnitValue.createPointValue(20f)); textRenderer.setProperty(Property.PADDING_RIGHT, UnitValue.createPointValue(20f)); textRenderer.setProperty(Property.RENDERING_MODE, RenderingMode.HTML_MODE); - Assert.assertTrue( + Assertions.assertTrue( new Rectangle(0, 986.68f, 25.343998f, 13.32f).equalsWithEpsilon(textRenderer.getOccupiedAreaBBox())); } @@ -213,7 +211,7 @@ public void getInnerAreaBBoxTest() { textRenderer.setProperty(Property.MARGIN_TOP, UnitValue.createPointValue(20f)); textRenderer.setProperty(Property.PADDING_RIGHT, UnitValue.createPointValue(20f)); textRenderer.setProperty(Property.RENDERING_MODE, RenderingMode.HTML_MODE); - Assert.assertTrue(new Rectangle(0, 986.68f, 5.343998f, -26.68f) + Assertions.assertTrue(new Rectangle(0, 986.68f, 5.343998f, -26.68f) .equalsWithEpsilon(textRenderer.getInnerAreaBBox())); } @@ -235,37 +233,37 @@ public void resolveFirstPdfFontWithGlyphsAvailableOnlyInSecondaryFont() { TextRenderer renderer = (TextRenderer) new TextRenderer(text); PdfFont pdfFont = renderer.resolveFirstPdfFont(); - Assert.assertEquals("NotoSans", pdfFont.getFontProgram().getFontNames().getFontName()); + Assertions.assertEquals("NotoSans", pdfFont.getFontProgram().getFontNames().getFontName()); } @Test public void myanmarCharacterBelongsToSpecificScripts() { // u1042 MYANMAR DIGIT TWO - Assert.assertTrue(TextRenderer.codePointIsOfSpecialScript(4162)); + Assertions.assertTrue(TextRenderer.codePointIsOfSpecialScript(4162)); } @Test public void thaiCharacterBelongsToSpecificScripts() { // u0E19 THAI CHARACTER NO NU - Assert.assertTrue(TextRenderer.codePointIsOfSpecialScript(3609)); + Assertions.assertTrue(TextRenderer.codePointIsOfSpecialScript(3609)); } @Test public void laoCharacterBelongsToSpecificScripts() { // u0EC8 LAO TONE MAI EK - Assert.assertTrue(TextRenderer.codePointIsOfSpecialScript(3784)); + Assertions.assertTrue(TextRenderer.codePointIsOfSpecialScript(3784)); } @Test public void khmerCharacterBelongsToSpecificScripts() { // u1789 KHMER LETTER NYO - Assert.assertTrue(TextRenderer.codePointIsOfSpecialScript(6025)); + Assertions.assertTrue(TextRenderer.codePointIsOfSpecialScript(6025)); } @Test public void cyrillicCharacterDoesntBelongToSpecificScripts() { // u0433 Cyrillic Small Letter U - Assert.assertFalse(TextRenderer.codePointIsOfSpecialScript(1091)); + Assertions.assertFalse(TextRenderer.codePointIsOfSpecialScript(1091)); } @Test @@ -278,7 +276,7 @@ public void overflowWrapAnywhereProperty() { MinMaxWidth minMaxWidth = textRenderer.getMinMaxWidth(); - Assert.assertTrue(minMaxWidth.getMinWidth() < minMaxWidth.getMaxWidth()); + Assertions.assertTrue(minMaxWidth.getMinWidth() < minMaxWidth.getMaxWidth()); } @Test @@ -297,17 +295,16 @@ public void overflowWrapBreakWordProperty() { new Rectangle(fullWordWidth / 2, AbstractRenderer.INF)); TextLayoutResult result = (TextLayoutResult) textRenderer.layout(new LayoutContext(layoutArea)); - Assert.assertFalse(result.isWordHasBeenSplit()); + Assertions.assertFalse(result.isWordHasBeenSplit()); textRenderer.setProperty(Property.OVERFLOW_WRAP, OverflowWrapPropertyValue.BREAK_WORD); result = (TextLayoutResult) textRenderer.layout(new LayoutContext(layoutArea)); - Assert.assertTrue(result.isWordHasBeenSplit()); + Assertions.assertTrue(result.isWordHasBeenSplit()); } @Test public void overflowWrapAnywhereBoldSimulationMaxWidth() { Text text = new Text("wow"); - text.setBold(); TextRenderer textRenderer = (TextRenderer) text.getRenderer(); textRenderer.setParent(createDummyDocument().getRenderer()); @@ -317,13 +314,13 @@ public void overflowWrapAnywhereBoldSimulationMaxWidth() { text.setProperty(Property.OVERFLOW_WRAP, OverflowWrapPropertyValue.ANYWHERE); float maxWidthAndOverflowWrap = textRenderer.getMinMaxWidth().getMaxWidth(); - Assert.assertEquals(maxWidthAndOverflowWrap, maxWidthNoOverflowWrap, 0.0001); + Assertions.assertEquals(maxWidthAndOverflowWrap, maxWidthNoOverflowWrap, 0.0001); } @Test public void overflowWrapAnywhereItalicSimulationMaxWidth() { Text text = new Text("wow"); - text.setItalic(); + text.simulateItalic(); TextRenderer textRenderer = (TextRenderer) text.getRenderer(); textRenderer.setParent(createDummyDocument().getRenderer()); @@ -333,7 +330,7 @@ public void overflowWrapAnywhereItalicSimulationMaxWidth() { text.setProperty(Property.OVERFLOW_WRAP, OverflowWrapPropertyValue.ANYWHERE); float maxWidthAndOverflowWrap = textRenderer.getMinMaxWidth().getMaxWidth(); - Assert.assertEquals(maxWidthAndOverflowWrap, maxWidthNoOverflowWrap, 0.0001); + Assertions.assertEquals(maxWidthAndOverflowWrap, maxWidthNoOverflowWrap, 0.0001); } @Test @@ -346,10 +343,10 @@ public void overflowWrapAnywhereBoldSimulationMinWidth() { float minWidthNoBoldSimulation = textRenderer.getMinMaxWidth().getMinWidth(); - text.setBold(); + text.simulateBold(); float minWidthAndBoldSimulation = textRenderer.getMinMaxWidth().getMinWidth(); - Assert.assertTrue(minWidthAndBoldSimulation > minWidthNoBoldSimulation); + Assertions.assertTrue(minWidthAndBoldSimulation > minWidthNoBoldSimulation); } @Test @@ -362,10 +359,10 @@ public void overflowWrapAnywhereItalicSimulationMinWidth() { float minWidthNoItalicSimulation = textRenderer.getMinMaxWidth().getMinWidth(); - text.setItalic(); + text.simulateItalic(); float minWidthAndItalicSimulation = textRenderer.getMinMaxWidth().getMinWidth(); - Assert.assertTrue(minWidthAndItalicSimulation > minWidthNoItalicSimulation); + Assertions.assertTrue(minWidthAndItalicSimulation > minWidthNoItalicSimulation); } @Test @@ -386,7 +383,7 @@ public void floatingRightMinMaxWidth() throws IOException { float expectedMinWidth = font.getWidth(longestWord, fontSize); MinMaxWidth minMaxWidth = textRenderer.getMinMaxWidth(); - Assert.assertEquals(expectedMinWidth, minMaxWidth.getMinWidth(), 0.01f); - Assert.assertEquals(expectedMaxWidth, minMaxWidth.getMaxWidth(), 0.01f); + Assertions.assertEquals(expectedMinWidth, minMaxWidth.getMinWidth(), 0.01f); + Assertions.assertEquals(expectedMaxWidth, minMaxWidth.getMaxWidth(), 0.01f); } } diff --git a/layout/src/test/java/com/itextpdf/layout/renderer/TextRendererUnitTest.java b/layout/src/test/java/com/itextpdf/layout/renderer/TextRendererUnitTest.java index 55e84c6eef..ee1a34c266 100644 --- a/layout/src/test/java/com/itextpdf/layout/renderer/TextRendererUnitTest.java +++ b/layout/src/test/java/com/itextpdf/layout/renderer/TextRendererUnitTest.java @@ -27,13 +27,12 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class TextRendererUnitTest extends ExtendedITextTest { @Test @@ -45,6 +44,6 @@ public void getNextRendererShouldBeOverriddenTest() { // Nothing is overridden }; - Assert.assertEquals(TextRenderer.class, textRenderer.getNextRenderer().getClass()); + Assertions.assertEquals(TextRenderer.class, textRenderer.getNextRenderer().getClass()); } } diff --git a/layout/src/test/java/com/itextpdf/layout/renderer/TypographyUtilsTest.java b/layout/src/test/java/com/itextpdf/layout/renderer/TypographyUtilsTest.java index f4684c1b02..3c563cc2ba 100644 --- a/layout/src/test/java/com/itextpdf/layout/renderer/TypographyUtilsTest.java +++ b/layout/src/test/java/com/itextpdf/layout/renderer/TypographyUtilsTest.java @@ -23,18 +23,17 @@ This file is part of the iText (R) project. package com.itextpdf.layout.renderer; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class TypographyUtilsTest extends ExtendedITextTest { @Test public void verifyPdfCalligraphIsNotAvailable() { - Assert.assertFalse(TypographyUtils.isPdfCalligraphAvailable()); + Assertions.assertFalse(TypographyUtils.isPdfCalligraphAvailable()); } } diff --git a/layout/src/test/java/com/itextpdf/layout/renderer/WordWrapUnitTest.java b/layout/src/test/java/com/itextpdf/layout/renderer/WordWrapUnitTest.java index 4888b68d92..8d7a2d44a3 100644 --- a/layout/src/test/java/com/itextpdf/layout/renderer/WordWrapUnitTest.java +++ b/layout/src/test/java/com/itextpdf/layout/renderer/WordWrapUnitTest.java @@ -48,7 +48,6 @@ This file is part of the iText (R) project. import com.itextpdf.layout.renderer.TextSequenceWordWrapping.SpecialScriptsContainingSequenceStatus; import com.itextpdf.layout.renderer.TextSequenceWordWrapping.SpecialScriptsContainingTextRendererSequenceInfo; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -58,11 +57,11 @@ This file is part of the iText (R) project. import java.util.HashMap; import java.util.List; import java.util.Map; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class WordWrapUnitTest extends ExtendedITextTest { public static final String THAI_FONT = "./src/test/resources/com/itextpdf/layout/fonts/NotoSansThai-Regular.ttf"; @@ -82,7 +81,7 @@ public void isTextRendererAndRequiresSpecialScriptPreLayoutProcessingTest() thro TextRenderer textRenderer = new TextRenderer(new Text(THAI_TEXT)); textRenderer.setProperty(Property.FONT, PdfFontFactory.createFont(THAI_FONT, PdfEncodings.IDENTITY_H)); textRenderer.setText(THAI_TEXT); - Assert.assertTrue(TextSequenceWordWrapping.isTextRendererAndRequiresSpecialScriptPreLayoutProcessing(textRenderer)); + Assertions.assertTrue(TextSequenceWordWrapping.isTextRendererAndRequiresSpecialScriptPreLayoutProcessing(textRenderer)); } @Test @@ -91,13 +90,13 @@ public void isTextRendererAndDoesNotRequireSpecialScriptPreLayoutProcessingTest( textRenderer.setProperty(Property.FONT, PdfFontFactory.createFont(THAI_FONT, PdfEncodings.IDENTITY_H)); textRenderer.setText(THAI_TEXT); textRenderer.setSpecialScriptsWordBreakPoints(new ArrayList()); - Assert.assertFalse(TextSequenceWordWrapping.isTextRendererAndRequiresSpecialScriptPreLayoutProcessing(textRenderer)); + Assertions.assertFalse(TextSequenceWordWrapping.isTextRendererAndRequiresSpecialScriptPreLayoutProcessing(textRenderer)); } @Test public void isNotTextRenderer() { TabRenderer tabRenderer = new TabRenderer(new Tab()); - Assert.assertFalse(TextSequenceWordWrapping.isTextRendererAndRequiresSpecialScriptPreLayoutProcessing(tabRenderer)); + Assertions.assertFalse(TextSequenceWordWrapping.isTextRendererAndRequiresSpecialScriptPreLayoutProcessing(tabRenderer)); } @Test @@ -106,10 +105,10 @@ public void splitAndOverflowInheritSpecialScriptsWordBreakPoints() throws IOExce TextRenderer textRenderer = new TextRenderer(new Text(nonSpecialScriptText)); textRenderer.setProperty(Property.FONT, PdfFontFactory.createFont(REGULAR_FONT, PdfEncodings.IDENTITY_H)); textRenderer.setText(nonSpecialScriptText); - Assert.assertNull(textRenderer.getSpecialScriptsWordBreakPoints()); + Assertions.assertNull(textRenderer.getSpecialScriptsWordBreakPoints()); TextSequenceWordWrapping.isTextRendererAndRequiresSpecialScriptPreLayoutProcessing(textRenderer); - Assert.assertNotNull(textRenderer.getSpecialScriptsWordBreakPoints()); - Assert.assertTrue(textRenderer.getSpecialScriptsWordBreakPoints().isEmpty()); + Assertions.assertNotNull(textRenderer.getSpecialScriptsWordBreakPoints()); + Assertions.assertTrue(textRenderer.getSpecialScriptsWordBreakPoints().isEmpty()); // layout is needed prior to calling #split() in order to fill TextRenderer fields required to be non-null PdfDocument pdfDocument = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); @@ -120,8 +119,8 @@ public void splitAndOverflowInheritSpecialScriptsWordBreakPoints() throws IOExce TextRenderer[] splitRenderers = textRenderer.split(nonSpecialScriptText.length() / 2); for (TextRenderer split : splitRenderers) { - Assert.assertNotNull(split.getSpecialScriptsWordBreakPoints()); - Assert.assertTrue(split.getSpecialScriptsWordBreakPoints().isEmpty()); + Assertions.assertNotNull(split.getSpecialScriptsWordBreakPoints()); + Assertions.assertTrue(split.getSpecialScriptsWordBreakPoints().isEmpty()); } } @@ -138,7 +137,7 @@ public void noNeedToSplitTextRendererOnLineSplit() throws IOException { TextRenderer textRendererFirst = new TextRenderer(new Text("")); textRendererFirst.setProperty(Property.FONT, pdfFont); textRendererFirst.setText(thai.substring(0, 8)); - textRendererFirst.text.start = 3; + textRendererFirst.text.setStart(3); textRendererFirst.setSpecialScriptsWordBreakPoints(new ArrayList(Arrays.asList(3, 8))); textRendererFirst.setParent(document.getRenderer()); float longestWordLength = textRendererFirst.getMinMaxWidth().getMaxWidth(); @@ -156,23 +155,23 @@ public void noNeedToSplitTextRendererOnLineSplit() throws IOException { lineRenderer.addChild(textRendererSecond); LayoutResult result = lineRenderer.layout(new LayoutContext(layoutArea)); - Assert.assertEquals(LayoutResult.PARTIAL, result.getStatus()); + Assertions.assertEquals(LayoutResult.PARTIAL, result.getStatus()); IRenderer splitRenderer = result.getSplitRenderer(); - Assert.assertNotNull(splitRenderer); + Assertions.assertNotNull(splitRenderer); List splitChildren = splitRenderer.getChildRenderers(); - Assert.assertNotNull(splitChildren); - Assert.assertEquals(1, splitChildren.size()); + Assertions.assertNotNull(splitChildren); + Assertions.assertEquals(1, splitChildren.size()); IRenderer overflowRenderer = result.getOverflowRenderer(); - Assert.assertNotNull(overflowRenderer); + Assertions.assertNotNull(overflowRenderer); List overflowChildren = overflowRenderer.getChildRenderers(); - Assert.assertNotNull(overflowChildren); - Assert.assertEquals(1, overflowChildren.size()); + Assertions.assertNotNull(overflowChildren); + Assertions.assertEquals(1, overflowChildren.size()); TextRenderer splitChild = (TextRenderer) splitChildren.get(0); TextRenderer overflowChild = (TextRenderer) overflowChildren.get(0); - Assert.assertEquals(splitChild.text, overflowChild.text); + Assertions.assertEquals(splitChild.text, overflowChild.text); } @@ -210,19 +209,19 @@ public void specialScriptPreLayoutProcessing() throws IOException { String sequentialTextContent = info.sequentialTextContent; List indicesOfFloating = info.indicesOfFloating; - Assert.assertEquals(3, numberOfSequentialTextRenderers); - Assert.assertEquals(THAI_TEXT, sequentialTextContent); - Assert.assertEquals(1, indicesOfFloating.size()); - Assert.assertEquals(1, (int) indicesOfFloating.get(0)); + Assertions.assertEquals(3, numberOfSequentialTextRenderers); + Assertions.assertEquals(THAI_TEXT, sequentialTextContent); + Assertions.assertEquals(1, indicesOfFloating.size()); + Assertions.assertEquals(1, (int) indicesOfFloating.get(0)); List possibleBreaks = new ArrayList(Arrays.asList(3, 8, 10, 12, 15, 20, 23, 26, 28, 30, 36)); TextSequenceWordWrapping.distributePossibleBreakPointsOverSequentialTextRenderers( lineRenderer, 0, numberOfSequentialTextRenderers, possibleBreaks, indicesOfFloating); List possibleBreaksFirstPart = textRendererFirstPart.getSpecialScriptsWordBreakPoints(); - Assert.assertNotNull(possibleBreaksFirstPart); + Assertions.assertNotNull(possibleBreaksFirstPart); List possibleBreaksSecondPart = textRendererSecondPart.getSpecialScriptsWordBreakPoints(); - Assert.assertNotNull(possibleBreaksSecondPart); + Assertions.assertNotNull(possibleBreaksSecondPart); int indexOfLastPossibleBreakInTheFirstRenderer = 4; @@ -231,13 +230,13 @@ public void specialScriptPreLayoutProcessing() throws IOException { List expectedPossibleBreaksSecondPart = possibleBreaks .subList(indexOfLastPossibleBreakInTheFirstRenderer + 1, possibleBreaks.size()); - Assert.assertEquals(expectedPossibleBreaksFirstPart, possibleBreaksFirstPart); + Assertions.assertEquals(expectedPossibleBreaksFirstPart, possibleBreaksFirstPart); for (int i = 0; i < expectedPossibleBreaksSecondPart.size(); i++) { expectedPossibleBreaksSecondPart.set(i, expectedPossibleBreaksSecondPart.get(i) - thaiTextSplitPosition); } - Assert.assertEquals(expectedPossibleBreaksSecondPart, possibleBreaksSecondPart); + Assertions.assertEquals(expectedPossibleBreaksSecondPart, possibleBreaksSecondPart); } @Test @@ -260,9 +259,9 @@ public void specialScriptRendererFollowedByRegularTextRendererGetSequenceInfo() SpecialScriptsContainingTextRendererSequenceInfo info = TextSequenceWordWrapping .getSpecialScriptsContainingTextRendererSequenceInfo(lineRenderer, 0); - Assert.assertEquals(1, info.numberOfSequentialTextRenderers); - Assert.assertEquals(THAI_TEXT, info.sequentialTextContent); - Assert.assertTrue(info.indicesOfFloating.isEmpty()); + Assertions.assertEquals(1, info.numberOfSequentialTextRenderers); + Assertions.assertEquals(THAI_TEXT, info.sequentialTextContent); + Assertions.assertTrue(info.indicesOfFloating.isEmpty()); } @Test @@ -293,13 +292,13 @@ public void oneThaiWordSplitAcrossMultipleRenderersDistributePossibleBreakPoints for (int i = 0; i < THAI_WORD.length(); i++) { List possibleBreaksPerRenderer = ((TextRenderer) childRenderers.get(i)) .getSpecialScriptsWordBreakPoints(); - Assert.assertNotNull(possibleBreaksPerRenderer); - Assert.assertEquals(1, possibleBreaksPerRenderer.size()); + Assertions.assertNotNull(possibleBreaksPerRenderer); + Assertions.assertEquals(1, possibleBreaksPerRenderer.size()); int breakPoint = possibleBreaksPerRenderer.get(0); if (i != THAI_WORD.length() - 1) { - Assert.assertEquals(-1, breakPoint); + Assertions.assertEquals(-1, breakPoint); } else { - Assert.assertEquals(((TextRenderer) childRenderers.get(i)).length(), breakPoint); + Assertions.assertEquals(((TextRenderer) childRenderers.get(i)).length(), breakPoint); } } } @@ -339,9 +338,9 @@ public void oneThaiWordSplitAcrossMultipleRenderersGetIndexAndLayoutResult() thr .getIndexAndLayoutResultOfTheLastTextRendererContainingSpecialScripts(lineRenderer, THAI_WORD.length() + 1, specialScriptLayoutResults, false, true); - Assert.assertEquals(5, lastFittingChildRendererData.childIndex); - Assert.assertEquals(LayoutResult.NOTHING, lastFittingChildRendererData.childLayoutResult.getStatus()); - Assert.assertNull(lastFittingChildRendererData.childLayoutResult.getOccupiedArea()); + Assertions.assertEquals(5, lastFittingChildRendererData.childIndex); + Assertions.assertEquals(LayoutResult.NOTHING, lastFittingChildRendererData.childLayoutResult.getStatus()); + Assertions.assertNull(lastFittingChildRendererData.childLayoutResult.getOccupiedArea()); } @Test @@ -374,8 +373,8 @@ public void multipleFloatsFollowedByUnfittingThaiRenderer() throws IOException { .getIndexAndLayoutResultOfTheLastTextRendererContainingSpecialScripts(lineRenderer, indexOfThaiRenderer, specialScriptLayoutResults, false, true); - Assert.assertEquals(indexOfThaiRenderer, lastFittingChildRendererData.childIndex); - Assert.assertEquals(LayoutResult.NOTHING, lastFittingChildRendererData.childLayoutResult.getStatus()); + Assertions.assertEquals(indexOfThaiRenderer, lastFittingChildRendererData.childIndex); + Assertions.assertEquals(LayoutResult.NOTHING, lastFittingChildRendererData.childLayoutResult.getStatus()); } @Test @@ -414,8 +413,8 @@ public void trailingRightSideSpacesGetIndexAndLayoutResult() throws IOException .getIndexAndLayoutResultOfTheLastTextRendererContainingSpecialScripts(lineRenderer, THAI_WORD.length() - 1, specialScriptLayoutResults, false, true); - Assert.assertEquals(THAI_WORD.length() - 1, lastFittingChildRendererData.childIndex); - Assert.assertEquals(specialScriptLayoutResults.get(THAI_WORD.length() - 1), lastFittingChildRendererData.childLayoutResult); + Assertions.assertEquals(THAI_WORD.length() - 1, lastFittingChildRendererData.childIndex); + Assertions.assertEquals(specialScriptLayoutResults.get(THAI_WORD.length() - 1), lastFittingChildRendererData.childLayoutResult); } @Test @@ -431,7 +430,7 @@ public void minMaxWidthWithOneRenderer() throws IOException { MinMaxWidth minMaxWidth = textRenderer.getMinMaxWidth(); - Assert.assertTrue(minMaxWidth.getMinWidth() < minMaxWidth.getMaxWidth()); + Assertions.assertTrue(minMaxWidth.getMinWidth() < minMaxWidth.getMaxWidth()); } @Test @@ -455,26 +454,26 @@ public void specialScriptsWordBreakPointsSplit() throws IOException { .layout(new LayoutContext(new LayoutArea(1, new Rectangle(width, 500)))); IRenderer lineSplitRenderer = layoutResult.getSplitRenderer(); - Assert.assertNotNull(lineSplitRenderer); - Assert.assertNotNull(lineSplitRenderer.getChildRenderers()); - Assert.assertTrue(lineSplitRenderer.getChildRenderers().get(0) instanceof TextRenderer); + Assertions.assertNotNull(lineSplitRenderer); + Assertions.assertNotNull(lineSplitRenderer.getChildRenderers()); + Assertions.assertTrue(lineSplitRenderer.getChildRenderers().get(0) instanceof TextRenderer); TextRenderer textSplitRenderer = (TextRenderer) lineSplitRenderer.getChildRenderers().get(0); - Assert.assertNotNull(textSplitRenderer.getSpecialScriptsWordBreakPoints()); + Assertions.assertNotNull(textSplitRenderer.getSpecialScriptsWordBreakPoints()); IRenderer lineOverflowRenderer = layoutResult.getOverflowRenderer(); - Assert.assertNotNull(lineOverflowRenderer); - Assert.assertNotNull(lineOverflowRenderer.getChildRenderers()); - Assert.assertTrue(lineOverflowRenderer.getChildRenderers().get(0) instanceof TextRenderer); + Assertions.assertNotNull(lineOverflowRenderer); + Assertions.assertNotNull(lineOverflowRenderer.getChildRenderers()); + Assertions.assertTrue(lineOverflowRenderer.getChildRenderers().get(0) instanceof TextRenderer); TextRenderer textOverflowRenderer = (TextRenderer) lineOverflowRenderer.getChildRenderers().get(0); - Assert.assertNotNull(textOverflowRenderer.getSpecialScriptsWordBreakPoints()); + Assertions.assertNotNull(textOverflowRenderer.getSpecialScriptsWordBreakPoints()); int textSplitRendererTextLength = textSplitRenderer.text.toString().length(); for (int specialScriptsWordBreakPoint : textSplitRenderer.getSpecialScriptsWordBreakPoints()) { - Assert.assertTrue(specialScriptsWordBreakPoint <= textSplitRendererTextLength); + Assertions.assertTrue(specialScriptsWordBreakPoint <= textSplitRendererTextLength); } for (int specialScriptsWordBreakPoint : textOverflowRenderer.getSpecialScriptsWordBreakPoints()) { - Assert.assertTrue(specialScriptsWordBreakPoint > textSplitRendererTextLength + Assertions.assertTrue(specialScriptsWordBreakPoint > textSplitRendererTextLength && specialScriptsWordBreakPoint <= textOverflowRenderer.text.size()); } } @@ -497,7 +496,7 @@ public void forcedSplitOnTooNarrowArea() throws IOException { LayoutArea layoutArea = new LayoutArea(1, new Rectangle(minWidth / 2, 100)); LayoutResult layoutResult = lineRenderer.layout(new LayoutContext(layoutArea)); - Assert.assertEquals(LayoutResult.PARTIAL, layoutResult.getStatus()); + Assertions.assertEquals(LayoutResult.PARTIAL, layoutResult.getStatus()); } @Test @@ -520,7 +519,7 @@ public void midWordSplitPartialLayoutResult() throws IOException { LayoutArea layoutArea = new LayoutArea(1, new Rectangle(minWidth / 2, 100)); LayoutResult layoutResult = lineRenderer.layout(new LayoutContext(layoutArea)); - Assert.assertEquals(LayoutResult.PARTIAL, layoutResult.getStatus()); + Assertions.assertEquals(LayoutResult.PARTIAL, layoutResult.getStatus()); } @Test @@ -544,13 +543,13 @@ public void multipleRenderers() throws IOException { LayoutResult layoutResultSingleTextRenderer = lineRendererWithOneChild.layout(new LayoutContext(layoutArea)); IRenderer splitRendererOneChild = layoutResultSingleTextRenderer.getSplitRenderer(); - Assert.assertNotNull(splitRendererOneChild); - Assert.assertEquals(1, splitRendererOneChild.getChildRenderers().size()); + Assertions.assertNotNull(splitRendererOneChild); + Assertions.assertEquals(1, splitRendererOneChild.getChildRenderers().size()); String splitTextOneChild = ((TextRenderer) splitRendererOneChild.getChildRenderers().get(0)).text.toString(); IRenderer overflowRendererOneChild = layoutResultSingleTextRenderer.getOverflowRenderer(); - Assert.assertNotNull(overflowRendererOneChild); - Assert.assertEquals(1, overflowRendererOneChild.getChildRenderers().size()); + Assertions.assertNotNull(overflowRendererOneChild); + Assertions.assertEquals(1, overflowRendererOneChild.getChildRenderers().size()); String overflowTextOneChild = ((TextRenderer) overflowRendererOneChild.getChildRenderers().get(0)).text.toString(); LineRenderer lineRendererMultipleChildren = new LineRenderer(); @@ -568,8 +567,8 @@ public void multipleRenderers() throws IOException { LayoutResult layoutResultMultipleTextRenderers = lineRendererMultipleChildren.layout(new LayoutContext(layoutArea)); IRenderer splitRendererMultipleChildren = layoutResultMultipleTextRenderers.getSplitRenderer(); - Assert.assertNotNull(splitRendererMultipleChildren); - Assert.assertTrue(splitRendererMultipleChildren.getChildRenderers().size() > 0); + Assertions.assertNotNull(splitRendererMultipleChildren); + Assertions.assertTrue(splitRendererMultipleChildren.getChildRenderers().size() > 0); StringBuilder stringBuilder = new StringBuilder(); for (IRenderer childRenderer : splitRendererMultipleChildren.getChildRenderers()) { stringBuilder.append(((TextRenderer) childRenderer).text.toString()); @@ -577,16 +576,16 @@ public void multipleRenderers() throws IOException { String splitTextMultipleChildren = stringBuilder.toString(); IRenderer overflowRendererMultipleChildren = layoutResultMultipleTextRenderers.getOverflowRenderer(); - Assert.assertNotNull(overflowRendererMultipleChildren); - Assert.assertTrue(overflowRendererMultipleChildren.getChildRenderers().size() > 0); + Assertions.assertNotNull(overflowRendererMultipleChildren); + Assertions.assertTrue(overflowRendererMultipleChildren.getChildRenderers().size() > 0); stringBuilder.setLength(0); for (IRenderer childRenderer : overflowRendererMultipleChildren.getChildRenderers()) { stringBuilder.append(((TextRenderer) childRenderer).text.toString()); } String overflowTextMultipleChildren = stringBuilder.toString(); - Assert.assertEquals(splitTextOneChild, splitTextMultipleChildren); - Assert.assertEquals(overflowTextOneChild, overflowTextMultipleChildren); + Assertions.assertEquals(splitTextOneChild, splitTextMultipleChildren); + Assertions.assertEquals(overflowTextOneChild, overflowTextMultipleChildren); } @Test @@ -606,7 +605,7 @@ public void wordWrappingUnavailableWithNoCalligraph() throws IOException { LayoutArea layoutArea = new LayoutArea(1, new Rectangle(maxWidth / 2, 100)); lineRenderer.layout(new LayoutContext(layoutArea)); - Assert.assertNull(((TextRenderer) lineRenderer.getChildRenderers().get(0)).getSpecialScriptsWordBreakPoints()); + Assertions.assertNull(((TextRenderer) lineRenderer.getChildRenderers().get(0)).getSpecialScriptsWordBreakPoints()); } @Test @@ -629,7 +628,7 @@ public void nothingLayoutResult() throws IOException { new Rectangle(occupiedArea.getWidth(), occupiedArea.getHeight() - 1)); LayoutResult nothingExpected = lineRenderer.layout(new LayoutContext(decreasedHeightLayoutArea)); - Assert.assertEquals(LayoutResult.NOTHING, nothingExpected.getStatus()); + Assertions.assertEquals(LayoutResult.NOTHING, nothingExpected.getStatus()); } @Test @@ -648,7 +647,7 @@ public void resetTextSequenceLayoutResultsBecauseOfNonTextRenderer() { TextSequenceWordWrapping.resetTextSequenceIfItEnded(textRendererLayoutResults, false, tabRenderer, 1, minMaxWidthOfTextRendererSequenceHelper, false, widthHandler); - Assert.assertTrue(textRendererLayoutResults.isEmpty()); + Assertions.assertTrue(textRendererLayoutResults.isEmpty()); } @Test @@ -672,7 +671,7 @@ public void resetTextSequenceLayoutResultsBecauseOfFloatingRenderer() { TextSequenceWordWrapping .resetTextSequenceIfItEnded(textRendererLayoutResults, false, tabRenderer, childPosDuringResetAttempt, minMaxWidthOfTextRendererSequenceHelper, true, widthHandler); - Assert.assertTrue(textRendererLayoutResults.isEmpty()); + Assertions.assertTrue(textRendererLayoutResults.isEmpty()); } @Test @@ -686,7 +685,7 @@ public void updateSpecialScriptLayoutResultsNonTextRenderer() { TextSequenceWordWrapping .updateTextSequenceLayoutResults(textRendererLayoutResults, true, tabRenderer, childPosNotToBeAdded, new LayoutResult(LayoutResult.FULL, new LayoutArea(1, new Rectangle(10, 10)), null, null, null)); - Assert.assertTrue(textRendererLayoutResults.isEmpty()); + Assertions.assertTrue(textRendererLayoutResults.isEmpty()); } @Test @@ -704,7 +703,7 @@ public void resetSpecialScriptTextSequenceBecauseOfTextRendererWithNoSpecialScri TextSequenceWordWrapping.resetTextSequenceIfItEnded(specialScriptLayoutResults, true, textRenderer, 1, minMaxWidthOfTextRendererSequenceHelper, true, widthHandler); - Assert.assertTrue(specialScriptLayoutResults.isEmpty()); + Assertions.assertTrue(specialScriptLayoutResults.isEmpty()); } @Test @@ -716,7 +715,7 @@ public void updateSpecialScriptLayoutResultsTextRendererWithNoSpecialScripts() { new LayoutArea(0, new Rectangle(0, 0, 10, 10)), null, null); TextSequenceWordWrapping.updateTextSequenceLayoutResults(specialScriptLayoutResults, true, textRenderer, 1, res); - Assert.assertTrue(specialScriptLayoutResults.isEmpty()); + Assertions.assertTrue(specialScriptLayoutResults.isEmpty()); } @Test @@ -737,8 +736,8 @@ public void notResetSpecialScriptTextSequenceBecauseOfTextRendererWithSpecialScr int secondKey = firstKey + 1; TextSequenceWordWrapping.resetTextSequenceIfItEnded(specialScriptLayoutResults, true, textRenderer, secondKey, minMaxWidthOfTextRendererSequenceHelper, true, widthHandler); - Assert.assertEquals(1, specialScriptLayoutResults.size()); - Assert.assertTrue(specialScriptLayoutResults.containsKey(firstKey)); + Assertions.assertEquals(1, specialScriptLayoutResults.size()); + Assertions.assertTrue(specialScriptLayoutResults.containsKey(firstKey)); } @Test @@ -755,9 +754,9 @@ public void updateSpecialScriptLayoutResultsTextRendererWithSpecialScripts() { int secondKey = firstKey + 1; TextSequenceWordWrapping .updateTextSequenceLayoutResults(specialScriptLayoutResults, true, textRenderer, secondKey, res); - Assert.assertTrue(specialScriptLayoutResults.containsKey(firstKey)); - Assert.assertTrue(specialScriptLayoutResults.containsKey(secondKey)); - Assert.assertEquals(2, specialScriptLayoutResults.size()); + Assertions.assertTrue(specialScriptLayoutResults.containsKey(firstKey)); + Assertions.assertTrue(specialScriptLayoutResults.containsKey(secondKey)); + Assertions.assertEquals(2, specialScriptLayoutResults.size()); } @Test @@ -766,7 +765,7 @@ public void curWidthZeroDecrement() { float decrement = TextSequenceWordWrapping .getCurWidthRelayoutedTextSequenceDecrement(oldNewChildPos, oldNewChildPos, new HashMap()); - Assert.assertEquals(0.0f, decrement, 0.0001); + Assertions.assertEquals(0.0f, decrement, 0.0001); } @Test @@ -784,7 +783,7 @@ public void curWidthLayoutResultNothing() { specialScriptLayoutResults.put(2, simpleDecrement); float decrement = TextSequenceWordWrapping .getCurWidthRelayoutedTextSequenceDecrement(3, 0, specialScriptLayoutResults); - Assert.assertEquals(widthOfNewNothingResult + simpleWidth, decrement, 0.00001); + Assertions.assertEquals(widthOfNewNothingResult + simpleWidth, decrement, 0.00001); } @Test @@ -802,7 +801,7 @@ public void curWidthLayoutResultPartial() { specialScriptLayoutResults.put(2, simpleDecrement); float decrement = TextSequenceWordWrapping .getCurWidthRelayoutedTextSequenceDecrement(3, 0, specialScriptLayoutResults); - Assert.assertEquals(widthOfNewPartialResult + simpleWidth, decrement, 0.00001); + Assertions.assertEquals(widthOfNewPartialResult + simpleWidth, decrement, 0.00001); } @Test @@ -834,7 +833,7 @@ public void possibleBreakWithinActualText() throws IOException { lineRenderer, 0, 1, possibleBreakPoints, new ArrayList()); List distributed = ((TextRenderer) lineRenderer.getChildRenderers().get(0)) .getSpecialScriptsWordBreakPoints(); - Assert.assertEquals(new ArrayList(Arrays.asList(3, 6)), distributed); + Assertions.assertEquals(new ArrayList(Arrays.asList(3, 6)), distributed); } @Test @@ -856,9 +855,9 @@ public void trimFirstOnePossibleBreak() throws IOException { lineRenderer.trimFirst(); TextRenderer childTextRenderer = (TextRenderer) lineRenderer.getChildRenderers().get(0); - Assert.assertNotNull(childTextRenderer.getSpecialScriptsWordBreakPoints()); - Assert.assertEquals(1, childTextRenderer.getSpecialScriptsWordBreakPoints().size()); - Assert.assertEquals(-1, (int) childTextRenderer.getSpecialScriptsWordBreakPoints().get(0)); + Assertions.assertNotNull(childTextRenderer.getSpecialScriptsWordBreakPoints()); + Assertions.assertEquals(1, childTextRenderer.getSpecialScriptsWordBreakPoints().size()); + Assertions.assertEquals(-1, (int) childTextRenderer.getSpecialScriptsWordBreakPoints().get(0)); } @Test @@ -880,7 +879,7 @@ public void unfittingSequenceWithPrecedingTextRendererContainingNoSpecialScripts SpecialScriptsContainingSequenceStatus status = TextSequenceWordWrapping.getSpecialScriptsContainingSequenceStatus(lineRenderer, 1); - Assert.assertEquals(TextSequenceWordWrapping.SpecialScriptsContainingSequenceStatus + Assertions.assertEquals(TextSequenceWordWrapping.SpecialScriptsContainingSequenceStatus .MOVE_SEQUENCE_CONTAINING_SPECIAL_SCRIPTS_ON_NEXT_LINE, status); } @@ -903,7 +902,7 @@ public void unfittingSequenceWithPrecedingInlineBlockRenderer() throws IOExcepti SpecialScriptsContainingSequenceStatus status = TextSequenceWordWrapping.getSpecialScriptsContainingSequenceStatus(lineRenderer, 1); - Assert.assertEquals(TextSequenceWordWrapping.SpecialScriptsContainingSequenceStatus + Assertions.assertEquals(TextSequenceWordWrapping.SpecialScriptsContainingSequenceStatus .MOVE_SEQUENCE_CONTAINING_SPECIAL_SCRIPTS_ON_NEXT_LINE, status); } @@ -923,7 +922,7 @@ public void unfittingSingleTextRendererContainingSpecialScripts() throws IOExcep SpecialScriptsContainingSequenceStatus status = TextSequenceWordWrapping.getSpecialScriptsContainingSequenceStatus(lineRenderer, 0); - Assert.assertEquals(TextSequenceWordWrapping.SpecialScriptsContainingSequenceStatus.FORCED_SPLIT, status); + Assertions.assertEquals(TextSequenceWordWrapping.SpecialScriptsContainingSequenceStatus.FORCED_SPLIT, status); } @Test @@ -946,7 +945,7 @@ public void overflowXSingleWordSingleRenderer() throws IOException { LayoutArea layoutArea = new LayoutArea(1, new Rectangle(minWidth / 2, 100)); LayoutResult layoutResult = lineRenderer.layout(new LayoutContext(layoutArea)); - Assert.assertEquals(LayoutResult.FULL, layoutResult.getStatus()); + Assertions.assertEquals(LayoutResult.FULL, layoutResult.getStatus()); } @Test @@ -977,6 +976,6 @@ public void overflowXSingleWordOneGlyphPerTextRenderer() throws IOException { LayoutArea layoutArea = new LayoutArea(1, new Rectangle(minWidth / 2, 100)); LayoutResult layoutResult = lineRenderer.layout(new LayoutContext(layoutArea)); - Assert.assertEquals(LayoutResult.FULL, layoutResult.getStatus()); + Assertions.assertEquals(LayoutResult.FULL, layoutResult.getStatus()); } } diff --git a/layout/src/test/java/com/itextpdf/layout/renderer/objectfit/ObjectFitApplyingResultUnitTest.java b/layout/src/test/java/com/itextpdf/layout/renderer/objectfit/ObjectFitApplyingResultUnitTest.java index 14e30d4254..fdee8f2a63 100644 --- a/layout/src/test/java/com/itextpdf/layout/renderer/objectfit/ObjectFitApplyingResultUnitTest.java +++ b/layout/src/test/java/com/itextpdf/layout/renderer/objectfit/ObjectFitApplyingResultUnitTest.java @@ -23,20 +23,19 @@ This file is part of the iText (R) project. package com.itextpdf.layout.renderer.objectfit; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class ObjectFitApplyingResultUnitTest extends ExtendedITextTest { @Test public void constructorTest() { ObjectFitApplyingResult result = new ObjectFitApplyingResult(123., 456., true ); - Assert.assertEquals(123., result.getRenderedImageWidth(), 0.001); - Assert.assertEquals(456., result.getRenderedImageHeight(), 0.001); - Assert.assertTrue(result.isImageCuttingRequired()); + Assertions.assertEquals(123., result.getRenderedImageWidth(), 0.001); + Assertions.assertEquals(456., result.getRenderedImageHeight(), 0.001); + Assertions.assertTrue(result.isImageCuttingRequired()); } @Test @@ -45,8 +44,8 @@ public void setterTest() { result.setRenderedImageWidth(123.); result.setRenderedImageHeight(456.); result.setImageCuttingRequired(true); - Assert.assertEquals(123., result.getRenderedImageWidth(), 0.001); - Assert.assertEquals(456., result.getRenderedImageHeight(), 0.001); - Assert.assertTrue(result.isImageCuttingRequired()); + Assertions.assertEquals(123., result.getRenderedImageWidth(), 0.001); + Assertions.assertEquals(456., result.getRenderedImageHeight(), 0.001); + Assertions.assertTrue(result.isImageCuttingRequired()); } } diff --git a/layout/src/test/java/com/itextpdf/layout/renderer/objectfit/ObjectFitCalculatorUnitTest.java b/layout/src/test/java/com/itextpdf/layout/renderer/objectfit/ObjectFitCalculatorUnitTest.java index b7748e8b7f..f1d0b10760 100644 --- a/layout/src/test/java/com/itextpdf/layout/renderer/objectfit/ObjectFitCalculatorUnitTest.java +++ b/layout/src/test/java/com/itextpdf/layout/renderer/objectfit/ObjectFitCalculatorUnitTest.java @@ -24,13 +24,12 @@ This file is part of the iText (R) project. import com.itextpdf.layout.properties.ObjectFit; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class ObjectFitCalculatorUnitTest extends ExtendedITextTest { private final static float SMALL_WIDTH = 200; @@ -43,9 +42,9 @@ public void fillModeContainerIsGreaterThanImageTest() { ObjectFitApplyingResult result = ObjectFitCalculator.calculateRenderedImageSize( ObjectFit.FILL, SMALL_WIDTH, SMALL_HEIGHT, BIG_WIDTH, BIG_HEIGHT ); - Assert.assertEquals(BIG_WIDTH, result.getRenderedImageWidth(), 0.1); - Assert.assertEquals(BIG_HEIGHT, result.getRenderedImageHeight(), 0.1); - Assert.assertFalse(result.isImageCuttingRequired()); + Assertions.assertEquals(BIG_WIDTH, result.getRenderedImageWidth(), 0.1); + Assertions.assertEquals(BIG_HEIGHT, result.getRenderedImageHeight(), 0.1); + Assertions.assertFalse(result.isImageCuttingRequired()); } @Test @@ -53,9 +52,9 @@ public void fillModeContainerIsLessThanImageTest() { ObjectFitApplyingResult result = ObjectFitCalculator.calculateRenderedImageSize( ObjectFit.FILL, BIG_WIDTH, BIG_HEIGHT, SMALL_WIDTH, SMALL_HEIGHT ); - Assert.assertEquals(SMALL_WIDTH, result.getRenderedImageWidth(), 0.1); - Assert.assertEquals(SMALL_HEIGHT, result.getRenderedImageHeight(), 0.1); - Assert.assertFalse(result.isImageCuttingRequired()); + Assertions.assertEquals(SMALL_WIDTH, result.getRenderedImageWidth(), 0.1); + Assertions.assertEquals(SMALL_HEIGHT, result.getRenderedImageHeight(), 0.1); + Assertions.assertFalse(result.isImageCuttingRequired()); } @Test @@ -63,9 +62,9 @@ public void fillModeContainerIsHorizontalAndImageIsVerticalTest() { ObjectFitApplyingResult result = ObjectFitCalculator.calculateRenderedImageSize( ObjectFit.FILL, BIG_WIDTH, SMALL_HEIGHT, SMALL_WIDTH, BIG_HEIGHT ); - Assert.assertEquals(SMALL_WIDTH, result.getRenderedImageWidth(), 0.1); - Assert.assertEquals(BIG_HEIGHT, result.getRenderedImageHeight(), 0.1); - Assert.assertFalse(result.isImageCuttingRequired()); + Assertions.assertEquals(SMALL_WIDTH, result.getRenderedImageWidth(), 0.1); + Assertions.assertEquals(BIG_HEIGHT, result.getRenderedImageHeight(), 0.1); + Assertions.assertFalse(result.isImageCuttingRequired()); } @Test @@ -73,9 +72,9 @@ public void fillModeContainerIsVerticalAndImageIsHorizontalTest() { ObjectFitApplyingResult result = ObjectFitCalculator.calculateRenderedImageSize( ObjectFit.FILL, SMALL_WIDTH, BIG_HEIGHT, BIG_WIDTH, SMALL_HEIGHT ); - Assert.assertEquals(BIG_WIDTH, result.getRenderedImageWidth(), 0.1); - Assert.assertEquals(SMALL_HEIGHT, result.getRenderedImageHeight(), 0.1); - Assert.assertFalse(result.isImageCuttingRequired()); + Assertions.assertEquals(BIG_WIDTH, result.getRenderedImageWidth(), 0.1); + Assertions.assertEquals(SMALL_HEIGHT, result.getRenderedImageHeight(), 0.1); + Assertions.assertFalse(result.isImageCuttingRequired()); } @Test @@ -84,9 +83,9 @@ public void containModeContainerIsGreaterThanImageTest() { ObjectFit.CONTAIN, SMALL_WIDTH, SMALL_HEIGHT, BIG_WIDTH, BIG_HEIGHT ); float expectedWidth = SMALL_WIDTH / SMALL_HEIGHT * BIG_HEIGHT ; - Assert.assertEquals(expectedWidth, result.getRenderedImageWidth(), 0.1); - Assert.assertEquals(BIG_HEIGHT, result.getRenderedImageHeight(), 0.1); - Assert.assertFalse(result.isImageCuttingRequired()); + Assertions.assertEquals(expectedWidth, result.getRenderedImageWidth(), 0.1); + Assertions.assertEquals(BIG_HEIGHT, result.getRenderedImageHeight(), 0.1); + Assertions.assertFalse(result.isImageCuttingRequired()); } @Test @@ -95,9 +94,9 @@ public void containModeContainerIsLessThanImageTest() { ObjectFit.CONTAIN, BIG_WIDTH, BIG_HEIGHT, SMALL_WIDTH, SMALL_HEIGHT ); float expectedHeight = BIG_HEIGHT / BIG_WIDTH * SMALL_WIDTH; - Assert.assertEquals(SMALL_WIDTH, result.getRenderedImageWidth(), 0.1); - Assert.assertEquals(expectedHeight, result.getRenderedImageHeight(), 0.1); - Assert.assertFalse(result.isImageCuttingRequired()); + Assertions.assertEquals(SMALL_WIDTH, result.getRenderedImageWidth(), 0.1); + Assertions.assertEquals(expectedHeight, result.getRenderedImageHeight(), 0.1); + Assertions.assertFalse(result.isImageCuttingRequired()); } @Test @@ -106,9 +105,9 @@ public void containModeContainerIsHorizontalAndImageIsVerticalTest() { ObjectFit.CONTAIN, BIG_WIDTH, SMALL_HEIGHT, SMALL_WIDTH, BIG_HEIGHT ); float expectedHeight = SMALL_HEIGHT / BIG_WIDTH * SMALL_WIDTH; - Assert.assertEquals(SMALL_WIDTH, result.getRenderedImageWidth(), 0.1); - Assert.assertEquals(expectedHeight, result.getRenderedImageHeight(), 0.1); - Assert.assertFalse(result.isImageCuttingRequired()); + Assertions.assertEquals(SMALL_WIDTH, result.getRenderedImageWidth(), 0.1); + Assertions.assertEquals(expectedHeight, result.getRenderedImageHeight(), 0.1); + Assertions.assertFalse(result.isImageCuttingRequired()); } @Test @@ -117,9 +116,9 @@ public void containModeContainerIsVerticalAndImageIsHorizontalTest() { ObjectFit.CONTAIN, SMALL_WIDTH, BIG_HEIGHT, BIG_WIDTH, SMALL_HEIGHT ); float expectedWidth = SMALL_WIDTH / BIG_HEIGHT * SMALL_HEIGHT; - Assert.assertEquals(expectedWidth, result.getRenderedImageWidth(), 0.1); - Assert.assertEquals(SMALL_HEIGHT, result.getRenderedImageHeight(), 0.1); - Assert.assertFalse(result.isImageCuttingRequired()); + Assertions.assertEquals(expectedWidth, result.getRenderedImageWidth(), 0.1); + Assertions.assertEquals(SMALL_HEIGHT, result.getRenderedImageHeight(), 0.1); + Assertions.assertFalse(result.isImageCuttingRequired()); } @Test @@ -128,9 +127,9 @@ public void coverModeContainerIsGreaterThanImageTest() { ObjectFit.COVER, SMALL_WIDTH, SMALL_HEIGHT, BIG_WIDTH, BIG_HEIGHT ); float expectedHeight = SMALL_HEIGHT / SMALL_WIDTH * BIG_WIDTH; - Assert.assertEquals(BIG_WIDTH, result.getRenderedImageWidth(), 0.1); - Assert.assertEquals(expectedHeight, result.getRenderedImageHeight(), 0.1); - Assert.assertTrue(result.isImageCuttingRequired()); + Assertions.assertEquals(BIG_WIDTH, result.getRenderedImageWidth(), 0.1); + Assertions.assertEquals(expectedHeight, result.getRenderedImageHeight(), 0.1); + Assertions.assertTrue(result.isImageCuttingRequired()); } @Test @@ -139,9 +138,9 @@ public void coverModeContainerIsLessThanImageTest() { ObjectFit.COVER, BIG_WIDTH, BIG_HEIGHT, SMALL_WIDTH, SMALL_HEIGHT ); float expectedWidth = BIG_WIDTH / BIG_HEIGHT * SMALL_HEIGHT; - Assert.assertEquals(expectedWidth, result.getRenderedImageWidth(), 0.1); - Assert.assertEquals(SMALL_HEIGHT, result.getRenderedImageHeight(), 0.1); - Assert.assertTrue(result.isImageCuttingRequired()); + Assertions.assertEquals(expectedWidth, result.getRenderedImageWidth(), 0.1); + Assertions.assertEquals(SMALL_HEIGHT, result.getRenderedImageHeight(), 0.1); + Assertions.assertTrue(result.isImageCuttingRequired()); } @Test @@ -150,9 +149,9 @@ public void coverModeContainerIsHorizontalAndImageIsVerticalTest() { ObjectFit.COVER, BIG_WIDTH, SMALL_HEIGHT, SMALL_WIDTH, BIG_HEIGHT ); float expectedWidth = BIG_WIDTH / SMALL_HEIGHT * BIG_HEIGHT; - Assert.assertEquals(expectedWidth, result.getRenderedImageWidth(), 0.1); - Assert.assertEquals(BIG_HEIGHT, result.getRenderedImageHeight(), 0.1); - Assert.assertTrue(result.isImageCuttingRequired()); + Assertions.assertEquals(expectedWidth, result.getRenderedImageWidth(), 0.1); + Assertions.assertEquals(BIG_HEIGHT, result.getRenderedImageHeight(), 0.1); + Assertions.assertTrue(result.isImageCuttingRequired()); } @Test @@ -161,9 +160,9 @@ public void coverModeContainerIsVerticalAndImageIsHorizontalTest() { ObjectFit.COVER, SMALL_WIDTH, BIG_HEIGHT, BIG_WIDTH, SMALL_HEIGHT ); float expectedHeight = BIG_HEIGHT / SMALL_WIDTH * BIG_WIDTH; - Assert.assertEquals(BIG_WIDTH, result.getRenderedImageWidth(), 0.1); - Assert.assertEquals(expectedHeight, result.getRenderedImageHeight(), 0.1); - Assert.assertTrue(result.isImageCuttingRequired()); + Assertions.assertEquals(BIG_WIDTH, result.getRenderedImageWidth(), 0.1); + Assertions.assertEquals(expectedHeight, result.getRenderedImageHeight(), 0.1); + Assertions.assertTrue(result.isImageCuttingRequired()); } @Test @@ -171,9 +170,9 @@ public void scaleDownModeContainerIsGreaterThanImageTest() { ObjectFitApplyingResult result = ObjectFitCalculator.calculateRenderedImageSize( ObjectFit.SCALE_DOWN, SMALL_WIDTH, SMALL_HEIGHT, BIG_WIDTH, BIG_HEIGHT ); - Assert.assertEquals(SMALL_WIDTH, result.getRenderedImageWidth(), 0.1); - Assert.assertEquals(SMALL_HEIGHT, result.getRenderedImageHeight(), 0.1); - Assert.assertFalse(result.isImageCuttingRequired()); + Assertions.assertEquals(SMALL_WIDTH, result.getRenderedImageWidth(), 0.1); + Assertions.assertEquals(SMALL_HEIGHT, result.getRenderedImageHeight(), 0.1); + Assertions.assertFalse(result.isImageCuttingRequired()); } @Test @@ -182,9 +181,9 @@ public void scaleDownModeContainerIsLessThanImageTest() { ObjectFit.SCALE_DOWN, BIG_WIDTH, BIG_HEIGHT, SMALL_WIDTH, SMALL_HEIGHT ); float expectedHeight = BIG_HEIGHT / BIG_WIDTH * SMALL_WIDTH; - Assert.assertEquals(SMALL_WIDTH, result.getRenderedImageWidth(), 0.1); - Assert.assertEquals(expectedHeight, result.getRenderedImageHeight(), 0.1); - Assert.assertFalse(result.isImageCuttingRequired()); + Assertions.assertEquals(SMALL_WIDTH, result.getRenderedImageWidth(), 0.1); + Assertions.assertEquals(expectedHeight, result.getRenderedImageHeight(), 0.1); + Assertions.assertFalse(result.isImageCuttingRequired()); } @Test @@ -193,9 +192,9 @@ public void scaleDownModeContainerIsHorizontalAndImageIsVerticalTest() { ObjectFit.SCALE_DOWN, BIG_WIDTH, SMALL_HEIGHT, SMALL_WIDTH, BIG_HEIGHT ); float expectedHeight = SMALL_HEIGHT / BIG_WIDTH * SMALL_WIDTH; - Assert.assertEquals(SMALL_WIDTH, result.getRenderedImageWidth(), 0.1); - Assert.assertEquals(expectedHeight, result.getRenderedImageHeight(), 0.1); - Assert.assertFalse(result.isImageCuttingRequired()); + Assertions.assertEquals(SMALL_WIDTH, result.getRenderedImageWidth(), 0.1); + Assertions.assertEquals(expectedHeight, result.getRenderedImageHeight(), 0.1); + Assertions.assertFalse(result.isImageCuttingRequired()); } @Test @@ -204,9 +203,9 @@ public void scaleDownModeContainerIsVerticalAndImageIsHorizontalTest() { ObjectFit.SCALE_DOWN, SMALL_WIDTH, BIG_HEIGHT, BIG_WIDTH, SMALL_HEIGHT ); float expectedWidth = SMALL_WIDTH / BIG_HEIGHT * SMALL_HEIGHT; - Assert.assertEquals(expectedWidth, result.getRenderedImageWidth(), 0.1); - Assert.assertEquals(SMALL_HEIGHT, result.getRenderedImageHeight(), 0.1); - Assert.assertFalse(result.isImageCuttingRequired()); + Assertions.assertEquals(expectedWidth, result.getRenderedImageWidth(), 0.1); + Assertions.assertEquals(SMALL_HEIGHT, result.getRenderedImageHeight(), 0.1); + Assertions.assertFalse(result.isImageCuttingRequired()); } @@ -215,9 +214,9 @@ public void noneModeContainerIsGreaterThanImageTest() { ObjectFitApplyingResult result = ObjectFitCalculator.calculateRenderedImageSize( ObjectFit.NONE, SMALL_WIDTH, SMALL_HEIGHT, BIG_WIDTH, BIG_HEIGHT ); - Assert.assertEquals(SMALL_WIDTH, result.getRenderedImageWidth(), 0.1); - Assert.assertEquals(SMALL_HEIGHT, result.getRenderedImageHeight(), 0.1); - Assert.assertFalse(result.isImageCuttingRequired()); + Assertions.assertEquals(SMALL_WIDTH, result.getRenderedImageWidth(), 0.1); + Assertions.assertEquals(SMALL_HEIGHT, result.getRenderedImageHeight(), 0.1); + Assertions.assertFalse(result.isImageCuttingRequired()); } @Test @@ -225,9 +224,9 @@ public void noneModeContainerIsLessThanImageTest() { ObjectFitApplyingResult result = ObjectFitCalculator.calculateRenderedImageSize( ObjectFit.NONE, BIG_WIDTH, BIG_HEIGHT, SMALL_WIDTH, SMALL_HEIGHT ); - Assert.assertEquals(BIG_WIDTH, result.getRenderedImageWidth(), 0.1); - Assert.assertEquals(BIG_HEIGHT, result.getRenderedImageHeight(), 0.1); - Assert.assertTrue(result.isImageCuttingRequired()); + Assertions.assertEquals(BIG_WIDTH, result.getRenderedImageWidth(), 0.1); + Assertions.assertEquals(BIG_HEIGHT, result.getRenderedImageHeight(), 0.1); + Assertions.assertTrue(result.isImageCuttingRequired()); } @Test @@ -235,9 +234,9 @@ public void noneModeContainerIsHorizontalAndImageIsVerticalTest() { ObjectFitApplyingResult result = ObjectFitCalculator.calculateRenderedImageSize( ObjectFit.NONE, BIG_WIDTH, SMALL_HEIGHT, SMALL_WIDTH, BIG_HEIGHT ); - Assert.assertEquals(BIG_WIDTH, result.getRenderedImageWidth(), 0.1); - Assert.assertEquals(SMALL_HEIGHT, result.getRenderedImageHeight(), 0.1); - Assert.assertTrue(result.isImageCuttingRequired()); + Assertions.assertEquals(BIG_WIDTH, result.getRenderedImageWidth(), 0.1); + Assertions.assertEquals(SMALL_HEIGHT, result.getRenderedImageHeight(), 0.1); + Assertions.assertTrue(result.isImageCuttingRequired()); } @Test @@ -245,8 +244,8 @@ public void noneModeContainerIsVerticalAndImageIsHorizontalTest() { ObjectFitApplyingResult result = ObjectFitCalculator.calculateRenderedImageSize( ObjectFit.NONE, SMALL_WIDTH, BIG_HEIGHT, BIG_WIDTH, SMALL_HEIGHT ); - Assert.assertEquals(SMALL_WIDTH, result.getRenderedImageWidth(), 0.1); - Assert.assertEquals(BIG_HEIGHT, result.getRenderedImageHeight(), 0.1); - Assert.assertTrue(result.isImageCuttingRequired()); + Assertions.assertEquals(SMALL_WIDTH, result.getRenderedImageWidth(), 0.1); + Assertions.assertEquals(BIG_HEIGHT, result.getRenderedImageHeight(), 0.1); + Assertions.assertTrue(result.isImageCuttingRequired()); } } diff --git a/layout/src/test/java/com/itextpdf/layout/splitting/BreakAllSplitCharactersTest.java b/layout/src/test/java/com/itextpdf/layout/splitting/BreakAllSplitCharactersTest.java index b84432b9e2..12dddeae93 100644 --- a/layout/src/test/java/com/itextpdf/layout/splitting/BreakAllSplitCharactersTest.java +++ b/layout/src/test/java/com/itextpdf/layout/splitting/BreakAllSplitCharactersTest.java @@ -25,55 +25,54 @@ This file is part of the iText (R) project. import com.itextpdf.io.font.otf.Glyph; import com.itextpdf.io.font.otf.GlyphLine; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.util.ArrayList; import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class BreakAllSplitCharactersTest extends ExtendedITextTest { private static final char charWithFalse = '\u201b'; @Test public void lastCharTest() { - Assert.assertFalse(isSplitCharacter(new int[]{charWithFalse, charWithFalse, charWithFalse}, 1)); - Assert.assertTrue(isSplitCharacter(new int[]{charWithFalse, charWithFalse, charWithFalse}, 2)); + Assertions.assertFalse(isSplitCharacter(new int[]{charWithFalse, charWithFalse, charWithFalse}, 1)); + Assertions.assertTrue(isSplitCharacter(new int[]{charWithFalse, charWithFalse, charWithFalse}, 2)); } @Test public void currentIsNotUnicodeTest() { - Assert.assertTrue(isSplitCharacter(new int[]{charWithFalse, -1, charWithFalse}, 1)); + Assertions.assertTrue(isSplitCharacter(new int[]{charWithFalse, -1, charWithFalse}, 1)); } @Test public void nextIsNotUnicodeTest() { - Assert.assertTrue(isSplitCharacter(new int[]{charWithFalse, charWithFalse, -1}, 1)); + Assertions.assertTrue(isSplitCharacter(new int[]{charWithFalse, charWithFalse, -1}, 1)); } @Test public void beforeSpaceTest() { - Assert.assertTrue(isSplitCharacter(new int[]{'a', 'a', ' '}, 0)); - Assert.assertFalse(isSplitCharacter(new int[]{'a', 'a', ' '}, 1)); - Assert.assertTrue(isSplitCharacter(new int[]{'a', ' ', ' '}, 1)); - Assert.assertTrue(isSplitCharacter(new int[]{'a', '-', ' '}, 1)); - Assert.assertTrue(isSplitCharacter(new int[]{'a', '\u2010', ' '}, 1)); - Assert.assertTrue(isSplitCharacter(new int[]{'a', '\u2004', ' '}, 1)); + Assertions.assertTrue(isSplitCharacter(new int[]{'a', 'a', ' '}, 0)); + Assertions.assertFalse(isSplitCharacter(new int[]{'a', 'a', ' '}, 1)); + Assertions.assertTrue(isSplitCharacter(new int[]{'a', ' ', ' '}, 1)); + Assertions.assertTrue(isSplitCharacter(new int[]{'a', '-', ' '}, 1)); + Assertions.assertTrue(isSplitCharacter(new int[]{'a', '\u2010', ' '}, 1)); + Assertions.assertTrue(isSplitCharacter(new int[]{'a', '\u2004', ' '}, 1)); } @Test public void beforeSymbolTest() { - Assert.assertFalse(isSplitCharacter(new int[]{charWithFalse, charWithFalse}, 0)); - Assert.assertTrue(isSplitCharacter(new int[]{charWithFalse, 'a'}, 0)); + Assertions.assertFalse(isSplitCharacter(new int[]{charWithFalse, charWithFalse}, 0)); + Assertions.assertTrue(isSplitCharacter(new int[]{charWithFalse, 'a'}, 0)); // non spacing mark - Assert.assertTrue(isSplitCharacter(new int[]{charWithFalse, '\u0303'}, 0)); + Assertions.assertTrue(isSplitCharacter(new int[]{charWithFalse, '\u0303'}, 0)); // combining mark - Assert.assertTrue(isSplitCharacter(new int[]{charWithFalse, '\u093e'}, 0)); + Assertions.assertTrue(isSplitCharacter(new int[]{charWithFalse, '\u093e'}, 0)); // enclosing mark - Assert.assertTrue(isSplitCharacter(new int[]{charWithFalse, '\u0488'}, 0)); + Assertions.assertTrue(isSplitCharacter(new int[]{charWithFalse, '\u0488'}, 0)); } private static boolean isSplitCharacter(int[] unicodes, int glyphPosition) { diff --git a/layout/src/test/java/com/itextpdf/layout/splitting/DefaultSplitCharacterTest.java b/layout/src/test/java/com/itextpdf/layout/splitting/DefaultSplitCharacterTest.java index b4a682f775..6466148c96 100644 --- a/layout/src/test/java/com/itextpdf/layout/splitting/DefaultSplitCharacterTest.java +++ b/layout/src/test/java/com/itextpdf/layout/splitting/DefaultSplitCharacterTest.java @@ -25,19 +25,18 @@ This file is part of the iText (R) project. import com.itextpdf.io.font.otf.Glyph; import com.itextpdf.io.font.otf.GlyphLine; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.util.ArrayList; import java.util.List; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class DefaultSplitCharacterTest extends ExtendedITextTest { static List glyphs = new ArrayList<>(); - @BeforeClass + @BeforeAll public static void setup() { glyphs.add(new Glyph(1, '-')); glyphs.add(new Glyph(1, '5')); @@ -62,27 +61,27 @@ public static void setup() { @Test public void beginCharacterTest() { - Assert.assertFalse(isPsplitCharacter(0)); + Assertions.assertFalse(isPsplitCharacter(0)); } @Test public void middleCharacterTest() { - Assert.assertTrue(isPsplitCharacter(4)); + Assertions.assertTrue(isPsplitCharacter(4)); } @Test public void lastCharacterTest() { - Assert.assertTrue(isPsplitCharacter(8)); + Assertions.assertTrue(isPsplitCharacter(8)); } @Test public void firstMiddleCharacterTest() { - Assert.assertTrue(isPsplitCharacter(9)); + Assertions.assertTrue(isPsplitCharacter(9)); } @Test public void lastMiddleCharacterTest() { - Assert.assertTrue(isPsplitCharacter(14)); + Assertions.assertTrue(isPsplitCharacter(14)); } private static boolean isPsplitCharacter(int glyphPos) { diff --git a/layout/src/test/java/com/itextpdf/layout/splitting/KeepAllSplitCharactersTest.java b/layout/src/test/java/com/itextpdf/layout/splitting/KeepAllSplitCharactersTest.java index a1a8b48905..65adb387af 100644 --- a/layout/src/test/java/com/itextpdf/layout/splitting/KeepAllSplitCharactersTest.java +++ b/layout/src/test/java/com/itextpdf/layout/splitting/KeepAllSplitCharactersTest.java @@ -25,72 +25,71 @@ This file is part of the iText (R) project. import com.itextpdf.io.font.otf.Glyph; import com.itextpdf.io.font.otf.GlyphLine; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.util.ArrayList; import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class KeepAllSplitCharactersTest extends ExtendedITextTest { @Test public void dashAtStartTest() { - Assert.assertTrue(isSplitCharacter(new int[]{'-', 'a'}, 0)); + Assertions.assertTrue(isSplitCharacter(new int[]{'-', 'a'}, 0)); } @Test public void minusSignAtStartTest() { - Assert.assertFalse(isSplitCharacter(new int[]{'-', '5'}, 0)); + Assertions.assertFalse(isSplitCharacter(new int[]{'-', '5'}, 0)); } @Test public void dashBeforeLetterInTheMiddleTest() { - Assert.assertTrue(isSplitCharacter(new int[]{'a', ' ', '-', 'a'}, 2)); + Assertions.assertTrue(isSplitCharacter(new int[]{'a', ' ', '-', 'a'}, 2)); } @Test // TODO: DEVSIX-4863 minus sign for digests should not be split public void minusSignInTheMiddleTest() { - Assert.assertTrue(isSplitCharacter(new int[]{'a', ' ', '-', '5'}, 2)); + Assertions.assertTrue(isSplitCharacter(new int[]{'a', ' ', '-', '5'}, 2)); } @Test public void dashBeforeDigitInTheMiddleTest() { - Assert.assertTrue(isSplitCharacter(new int[]{'a', 'a', '-', '5'}, 2)); + Assertions.assertTrue(isSplitCharacter(new int[]{'a', 'a', '-', '5'}, 2)); } @Test public void dashAtTheEndTest() { int[] unicodes = new int[]{'a', '-'}; - Assert.assertTrue(isSplitCharacter(unicodes, unicodes.length - 1)); + Assertions.assertTrue(isSplitCharacter(unicodes, unicodes.length - 1)); } @Test public void dashCharacterTest() { - Assert.assertTrue(isSplitCharacter(new int[]{'a', '-', 'a'}, 1)); + Assertions.assertTrue(isSplitCharacter(new int[]{'a', '-', 'a'}, 1)); } @Test public void noUnicodeTest() { - Assert.assertFalse(isSplitCharacter(new int[]{'a', -1, 'a'}, 1)); + Assertions.assertFalse(isSplitCharacter(new int[]{'a', -1, 'a'}, 1)); } @Test public void unicode2010CharacterTest() { - Assert.assertTrue(isSplitCharacter(new int[]{'a', '\u2010', 'a'}, 1)); + Assertions.assertTrue(isSplitCharacter(new int[]{'a', '\u2010', 'a'}, 1)); } @Test public void unicode2003CharacterTest() { - Assert.assertTrue(isSplitCharacter(new int[]{'a', '\u2003', 'a'}, 1)); + Assertions.assertTrue(isSplitCharacter(new int[]{'a', '\u2003', 'a'}, 1)); } @Test public void unicode2e81CharacterTest() { - Assert.assertFalse(isSplitCharacter(new int[]{'a', '\u2e81', 'a'}, 1)); + Assertions.assertFalse(isSplitCharacter(new int[]{'a', '\u2e81', 'a'}, 1)); } private static boolean isSplitCharacter(int[] unicodes, int glyphPosition) { diff --git a/layout/src/test/java/com/itextpdf/layout/testutil/OrphansWidowsTestUtil.java b/layout/src/test/java/com/itextpdf/layout/testutil/OrphansWidowsTestUtil.java index 52d39dec6b..907517dcf8 100644 --- a/layout/src/test/java/com/itextpdf/layout/testutil/OrphansWidowsTestUtil.java +++ b/layout/src/test/java/com/itextpdf/layout/testutil/OrphansWidowsTestUtil.java @@ -53,6 +53,7 @@ This file is part of the iText (R) project. import com.itextpdf.layout.renderer.ParagraphRenderer; import java.io.FileNotFoundException; +import java.io.IOException; import java.net.MalformedURLException; public class OrphansWidowsTestUtil { @@ -73,7 +74,7 @@ public class OrphansWidowsTestUtil { public static final float LINES_SPACE_EPS = 5; public static void produceOrphansWidowsTestCase(String outPdf, int linesLeft, boolean orphans, Paragraph testPara, - boolean applyMarginsOnTestPara) throws FileNotFoundException { + boolean applyMarginsOnTestPara) throws IOException { PageSize pageSize = new PageSize(PageSize.A4.getWidth(), PageSize.A5.getHeight()); Document doc = new Document(new PdfDocument(new PdfWriter(outPdf)), pageSize); @@ -122,7 +123,7 @@ public static void produceOrphansWidowsTestCase(String outPdf, int linesLeft, bo } public static void produceOrphansWidowsAndMaxHeightLimitTestCase(String outPdf, boolean orphans) - throws FileNotFoundException { + throws IOException { Document document = new Document(new PdfDocument(new PdfWriter(outPdf))); singleMaxHeightCase(document, orphans, false); document.add(new AreaBreak(AreaBreakType.NEXT_PAGE)); @@ -131,7 +132,7 @@ public static void produceOrphansWidowsAndMaxHeightLimitTestCase(String outPdf, } public static void produceOrphansWidowsOnCanvasOfLimitedSizeTestCase(String outPdf, boolean orphans) - throws FileNotFoundException { + throws IOException { PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outPdf)); Document document = new Document(pdfDocument); String orphansOrWidows = orphans ? "orphans" : "widows"; @@ -161,7 +162,7 @@ public static void produceOrphansWidowsOnCanvasOfLimitedSizeTestCase(String outP } public static void produceOrphansWidowsWithinDivOfLimitedSizeTestCase(String outPdf, boolean orphans) - throws FileNotFoundException { + throws IOException { Document document = new Document(new PdfDocument(new PdfWriter(outPdf))); String orphansOrWidows = orphans ? "orphans" : "widows"; Paragraph testDescription = new Paragraph().setBorder(new SolidBorder(ColorConstants.RED, 1)); @@ -188,7 +189,7 @@ public static void produceOrphansWidowsWithinDivOfLimitedSizeTestCase(String out } public static void produceOrphansWidowsKeepTogetherTestCase(String outPdf, boolean orphans, boolean large) - throws FileNotFoundException { + throws IOException { Document document = new Document(new PdfDocument(new PdfWriter(outPdf))); Paragraph paragraph = new Paragraph(PARA_TEXT).setMargin(0).setBackgroundColor(new DeviceRgb(232, 232, 232)); if (large) { @@ -244,7 +245,7 @@ public static void produceOrphansWidowsKeepTogetherTestCase(String outPdf, boole } public static void produceOrphansWidowsInlineImageTestCase(String outPdf, String imagePath, boolean orphans) - throws FileNotFoundException, MalformedURLException { + throws IOException { PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outPdf)); Document document = new Document(pdfDocument); Image img = new Image(ImageDataFactory.create(imagePath)); @@ -255,7 +256,7 @@ public static void produceOrphansWidowsInlineImageTestCase(String outPdf, String } public static void produceOrphansWidowsHugeInlineImageTestCase(String outPdf, String imagePath, boolean orphans) - throws FileNotFoundException, MalformedURLException { + throws IOException { PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outPdf)); Document document = new Document(pdfDocument); Image img = new Image(ImageDataFactory.create(imagePath)); @@ -299,7 +300,7 @@ public static void produceOrphansWidowsHugeInlineImageTestCase(String outPdf, St } public static void produceOrphansWidowsInlineBlockTestCase(String outPdf, boolean orphans) - throws FileNotFoundException { + throws IOException { Document document = new Document(new PdfDocument(new PdfWriter(outPdf))); Paragraph inlineBlockParagraph = setParagraphStylingProperties(new Paragraph(OrphansWidowsTestUtil.PARA_TEXT), @@ -338,7 +339,7 @@ public static void produceOrphansWidowsInlineBlockTestCase(String outPdf, boolea } public static void produceOrphansWidowsInlineFloatTestCase(String outPdf, boolean orphans) - throws FileNotFoundException { + throws IOException { Document document = new Document(new PdfDocument(new PdfWriter(outPdf))); Paragraph inlineFloatParagraph = setParagraphStylingProperties(new Paragraph(OrphansWidowsTestUtil.PARA_TEXT), @@ -385,7 +386,7 @@ public static void produceOrphansWidowsInlineFloatTestCase(String outPdf, boolea } public static void produceOrphansWidowsFloatingDivTestCase(String outPdf, boolean orphans) - throws FileNotFoundException { + throws IOException { Document document = new Document(new PdfDocument(new PdfWriter(outPdf))); Paragraph paraInFloatingDiv = setParagraphStylingProperties(new Paragraph(OrphansWidowsTestUtil.PARA_TEXT), @@ -435,7 +436,7 @@ public static void produceOrphansWidowsFloatingDivTestCase(String outPdf, boolea } public static void produceOrphansWidowsBiggerThanLinesCountTestCase(String outPdf, boolean orphans, - boolean singleLine) throws FileNotFoundException { + boolean singleLine) throws IOException { Document document = new Document(new PdfDocument(new PdfWriter(outPdf))); Paragraph smallParagraph = setParagraphStylingProperties(new Paragraph(), false); @@ -466,7 +467,7 @@ public static void produceOrphansWidowsBiggerThanLinesCountTestCase(String outPd } public static void produceOrphansWidowsUnexpectedWidthOfNextAreaTestCase(String outPdf, boolean widerNextPage) - throws FileNotFoundException { + throws IOException { PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outPdf)); Document document = new Document(pdfDocument); pdfDocument.addNewPage(); @@ -512,7 +513,7 @@ public static void produceOrphansWidowsUnexpectedWidthOfNextAreaTestCase(String } public static void produceOrphansOrWidowsTestCase(String outPdf, int linesLeft, boolean orphans, - Paragraph testPara) throws FileNotFoundException { + Paragraph testPara) throws IOException { Document doc = new Document(new PdfDocument(new PdfWriter(outPdf))); PageSize pageSize = new PageSize(PageSize.A4.getWidth(), PageSize.A5.getHeight()); @@ -558,7 +559,7 @@ public static void produceOrphansOrWidowsTestCase(String outPdf, int linesLeft, doc.close(); } - public static void produceOrphansAndWidowsTestCase(String outPdf, Paragraph testPara) throws FileNotFoundException { + public static void produceOrphansAndWidowsTestCase(String outPdf, Paragraph testPara) throws IOException { Document doc = new Document(new PdfDocument(new PdfWriter(outPdf))); PageSize pageSize = new PageSize(PageSize.A4.getWidth(), PageSize.A5.getHeight()); diff --git a/layout/src/test/resources/com/itextpdf/layout/FloatAndAlignmentTest/cmp_blockWithLimitedHeightAndFixedPositionTest.pdf b/layout/src/test/resources/com/itextpdf/layout/FixedHeightTest/cmp_blockWithLimitedHeightAndFixedPositionTest.pdf similarity index 100% rename from layout/src/test/resources/com/itextpdf/layout/FloatAndAlignmentTest/cmp_blockWithLimitedHeightAndFixedPositionTest.pdf rename to layout/src/test/resources/com/itextpdf/layout/FixedHeightTest/cmp_blockWithLimitedHeightAndFixedPositionTest.pdf diff --git a/layout/src/test/resources/com/itextpdf/layout/FloatAndAlignmentTest/cmp_listWithFixedPositionTest.pdf b/layout/src/test/resources/com/itextpdf/layout/FixedHeightTest/cmp_listWithFixedPositionTest.pdf similarity index 100% rename from layout/src/test/resources/com/itextpdf/layout/FloatAndAlignmentTest/cmp_listWithFixedPositionTest.pdf rename to layout/src/test/resources/com/itextpdf/layout/FixedHeightTest/cmp_listWithFixedPositionTest.pdf diff --git a/layout/src/test/resources/com/itextpdf/layout/FlexContainerSplitTest/cmp_heightPropertyTest.pdf b/layout/src/test/resources/com/itextpdf/layout/FlexContainerSplitTest/cmp_heightPropertyTest.pdf index 0354980428..7392614d16 100644 Binary files a/layout/src/test/resources/com/itextpdf/layout/FlexContainerSplitTest/cmp_heightPropertyTest.pdf and b/layout/src/test/resources/com/itextpdf/layout/FlexContainerSplitTest/cmp_heightPropertyTest.pdf differ diff --git a/layout/src/test/resources/com/itextpdf/layout/FlexContainerSplitTest/cmp_reverseRowWrapRtlStartTest.pdf b/layout/src/test/resources/com/itextpdf/layout/FlexContainerSplitTest/cmp_reverseRowWrapRtlStartTest.pdf index e3d8056155..9c406db2a6 100644 Binary files a/layout/src/test/resources/com/itextpdf/layout/FlexContainerSplitTest/cmp_reverseRowWrapRtlStartTest.pdf and b/layout/src/test/resources/com/itextpdf/layout/FlexContainerSplitTest/cmp_reverseRowWrapRtlStartTest.pdf differ diff --git a/layout/src/test/resources/com/itextpdf/layout/FlexContainerSplitTest/cmp_reverseWrapEndHeightTest.pdf b/layout/src/test/resources/com/itextpdf/layout/FlexContainerSplitTest/cmp_reverseWrapEndHeightTest.pdf index 211d59f452..321f59abf9 100644 Binary files a/layout/src/test/resources/com/itextpdf/layout/FlexContainerSplitTest/cmp_reverseWrapEndHeightTest.pdf and b/layout/src/test/resources/com/itextpdf/layout/FlexContainerSplitTest/cmp_reverseWrapEndHeightTest.pdf differ diff --git a/layout/src/test/resources/com/itextpdf/layout/FlexContainerSplitTest/cmp_reverseWrapEndTest.pdf b/layout/src/test/resources/com/itextpdf/layout/FlexContainerSplitTest/cmp_reverseWrapEndTest.pdf index cd2445f4a9..10caaa24b3 100644 Binary files a/layout/src/test/resources/com/itextpdf/layout/FlexContainerSplitTest/cmp_reverseWrapEndTest.pdf and b/layout/src/test/resources/com/itextpdf/layout/FlexContainerSplitTest/cmp_reverseWrapEndTest.pdf differ diff --git a/layout/src/test/resources/com/itextpdf/layout/FlexContainerSplitTest/cmp_reverseWrapStartHeightTest.pdf b/layout/src/test/resources/com/itextpdf/layout/FlexContainerSplitTest/cmp_reverseWrapStartHeightTest.pdf index 9fea427496..43021b4eab 100644 Binary files a/layout/src/test/resources/com/itextpdf/layout/FlexContainerSplitTest/cmp_reverseWrapStartHeightTest.pdf and b/layout/src/test/resources/com/itextpdf/layout/FlexContainerSplitTest/cmp_reverseWrapStartHeightTest.pdf differ diff --git a/layout/src/test/resources/com/itextpdf/layout/FlexContainerSplitTest/cmp_reverseWrapStartTest.pdf b/layout/src/test/resources/com/itextpdf/layout/FlexContainerSplitTest/cmp_reverseWrapStartTest.pdf index 42834eb28f..1d73f8432c 100644 Binary files a/layout/src/test/resources/com/itextpdf/layout/FlexContainerSplitTest/cmp_reverseWrapStartTest.pdf and b/layout/src/test/resources/com/itextpdf/layout/FlexContainerSplitTest/cmp_reverseWrapStartTest.pdf differ diff --git a/layout/src/test/resources/com/itextpdf/layout/FlexContainerSplitTest/cmp_rowWrapRtlStartTest.pdf b/layout/src/test/resources/com/itextpdf/layout/FlexContainerSplitTest/cmp_rowWrapRtlStartTest.pdf index 3ce4a23e5a..3aa2d15472 100644 Binary files a/layout/src/test/resources/com/itextpdf/layout/FlexContainerSplitTest/cmp_rowWrapRtlStartTest.pdf and b/layout/src/test/resources/com/itextpdf/layout/FlexContainerSplitTest/cmp_rowWrapRtlStartTest.pdf differ diff --git a/layout/src/test/resources/com/itextpdf/layout/FlexContainerSplitTest/cmp_simpleTest.pdf b/layout/src/test/resources/com/itextpdf/layout/FlexContainerSplitTest/cmp_simpleTest.pdf index a86b7db40d..b607e5fafc 100644 Binary files a/layout/src/test/resources/com/itextpdf/layout/FlexContainerSplitTest/cmp_simpleTest.pdf and b/layout/src/test/resources/com/itextpdf/layout/FlexContainerSplitTest/cmp_simpleTest.pdf differ diff --git a/layout/src/test/resources/com/itextpdf/layout/FlexContainerSplitTest/cmp_simpleWrapCenterTest.pdf b/layout/src/test/resources/com/itextpdf/layout/FlexContainerSplitTest/cmp_simpleWrapCenterTest.pdf index 7794fafb5e..d45eb4b84c 100644 Binary files a/layout/src/test/resources/com/itextpdf/layout/FlexContainerSplitTest/cmp_simpleWrapCenterTest.pdf and b/layout/src/test/resources/com/itextpdf/layout/FlexContainerSplitTest/cmp_simpleWrapCenterTest.pdf differ diff --git a/layout/src/test/resources/com/itextpdf/layout/FlexContainerSplitTest/cmp_simpleWrapEndTest.pdf b/layout/src/test/resources/com/itextpdf/layout/FlexContainerSplitTest/cmp_simpleWrapEndTest.pdf index 93545e96dc..1ab7400b18 100644 Binary files a/layout/src/test/resources/com/itextpdf/layout/FlexContainerSplitTest/cmp_simpleWrapEndTest.pdf and b/layout/src/test/resources/com/itextpdf/layout/FlexContainerSplitTest/cmp_simpleWrapEndTest.pdf differ diff --git a/layout/src/test/resources/com/itextpdf/layout/FlexContainerSplitTest/cmp_simpleWrapStartTest.pdf b/layout/src/test/resources/com/itextpdf/layout/FlexContainerSplitTest/cmp_simpleWrapStartTest.pdf index 818bec3412..7b26a65b6f 100644 Binary files a/layout/src/test/resources/com/itextpdf/layout/FlexContainerSplitTest/cmp_simpleWrapStartTest.pdf and b/layout/src/test/resources/com/itextpdf/layout/FlexContainerSplitTest/cmp_simpleWrapStartTest.pdf differ diff --git a/layout/src/test/resources/com/itextpdf/layout/FlexContainerSplitTest/cmp_simpleWrapTest.pdf b/layout/src/test/resources/com/itextpdf/layout/FlexContainerSplitTest/cmp_simpleWrapTest.pdf index d2c6611bd5..db56524e72 100644 Binary files a/layout/src/test/resources/com/itextpdf/layout/FlexContainerSplitTest/cmp_simpleWrapTest.pdf and b/layout/src/test/resources/com/itextpdf/layout/FlexContainerSplitTest/cmp_simpleWrapTest.pdf differ diff --git a/layout/src/test/resources/com/itextpdf/layout/FlexContainerSplitTest/cmp_smallTrailingElementTest.pdf b/layout/src/test/resources/com/itextpdf/layout/FlexContainerSplitTest/cmp_smallTrailingElementTest.pdf index 87e98e31b2..f0f21d1941 100644 Binary files a/layout/src/test/resources/com/itextpdf/layout/FlexContainerSplitTest/cmp_smallTrailingElementTest.pdf and b/layout/src/test/resources/com/itextpdf/layout/FlexContainerSplitTest/cmp_smallTrailingElementTest.pdf differ diff --git a/layout/src/test/resources/com/itextpdf/layout/FlexContainerSplitTest/cmp_splitOverSeveralPagesTest.pdf b/layout/src/test/resources/com/itextpdf/layout/FlexContainerSplitTest/cmp_splitOverSeveralPagesTest.pdf index 5a8c264b27..29d88be436 100644 Binary files a/layout/src/test/resources/com/itextpdf/layout/FlexContainerSplitTest/cmp_splitOverSeveralPagesTest.pdf and b/layout/src/test/resources/com/itextpdf/layout/FlexContainerSplitTest/cmp_splitOverSeveralPagesTest.pdf differ diff --git a/layout/src/test/resources/com/itextpdf/layout/FlexContainerSplitTest/tableInFlexOnSplitTest.pdf b/layout/src/test/resources/com/itextpdf/layout/FlexContainerSplitTest/tableInFlexOnSplitTest.pdf new file mode 100644 index 0000000000..fc7da22c68 Binary files /dev/null and b/layout/src/test/resources/com/itextpdf/layout/FlexContainerSplitTest/tableInFlexOnSplitTest.pdf differ diff --git a/layout/src/test/resources/com/itextpdf/layout/FlexContainerTest/cmp_flexContainerDifferentChildrenDontFitVerticallyTest1.pdf b/layout/src/test/resources/com/itextpdf/layout/FlexContainerTest/cmp_flexContainerDifferentChildrenDontFitVerticallyTest1.pdf index a4ef980d1a..fa84d5c4b5 100644 Binary files a/layout/src/test/resources/com/itextpdf/layout/FlexContainerTest/cmp_flexContainerDifferentChildrenDontFitVerticallyTest1.pdf and b/layout/src/test/resources/com/itextpdf/layout/FlexContainerTest/cmp_flexContainerDifferentChildrenDontFitVerticallyTest1.pdf differ diff --git a/layout/src/test/resources/com/itextpdf/layout/FlexContainerTest/cmp_flexContainerDifferentChildrenDontFitVerticallyTest10.pdf b/layout/src/test/resources/com/itextpdf/layout/FlexContainerTest/cmp_flexContainerDifferentChildrenDontFitVerticallyTest10.pdf index a575194b9f..95a9a81897 100644 Binary files a/layout/src/test/resources/com/itextpdf/layout/FlexContainerTest/cmp_flexContainerDifferentChildrenDontFitVerticallyTest10.pdf and b/layout/src/test/resources/com/itextpdf/layout/FlexContainerTest/cmp_flexContainerDifferentChildrenDontFitVerticallyTest10.pdf differ diff --git a/layout/src/test/resources/com/itextpdf/layout/FlexContainerTest/cmp_flexContainerDifferentChildrenDontFitVerticallyTest11.pdf b/layout/src/test/resources/com/itextpdf/layout/FlexContainerTest/cmp_flexContainerDifferentChildrenDontFitVerticallyTest11.pdf index f93d8c9c3a..da35aba9d5 100644 Binary files a/layout/src/test/resources/com/itextpdf/layout/FlexContainerTest/cmp_flexContainerDifferentChildrenDontFitVerticallyTest11.pdf and b/layout/src/test/resources/com/itextpdf/layout/FlexContainerTest/cmp_flexContainerDifferentChildrenDontFitVerticallyTest11.pdf differ diff --git a/layout/src/test/resources/com/itextpdf/layout/FlexContainerTest/cmp_flexContainerDifferentChildrenDontFitVerticallyTest3.pdf b/layout/src/test/resources/com/itextpdf/layout/FlexContainerTest/cmp_flexContainerDifferentChildrenDontFitVerticallyTest3.pdf index 62c0d5dc01..3edff93e99 100644 Binary files a/layout/src/test/resources/com/itextpdf/layout/FlexContainerTest/cmp_flexContainerDifferentChildrenDontFitVerticallyTest3.pdf and b/layout/src/test/resources/com/itextpdf/layout/FlexContainerTest/cmp_flexContainerDifferentChildrenDontFitVerticallyTest3.pdf differ diff --git a/layout/src/test/resources/com/itextpdf/layout/FlexContainerTest/cmp_flexContainerDifferentChildrenDontFitVerticallyTest5.pdf b/layout/src/test/resources/com/itextpdf/layout/FlexContainerTest/cmp_flexContainerDifferentChildrenDontFitVerticallyTest5.pdf index b7add60e54..68c498b71f 100644 Binary files a/layout/src/test/resources/com/itextpdf/layout/FlexContainerTest/cmp_flexContainerDifferentChildrenDontFitVerticallyTest5.pdf and b/layout/src/test/resources/com/itextpdf/layout/FlexContainerTest/cmp_flexContainerDifferentChildrenDontFitVerticallyTest5.pdf differ diff --git a/layout/src/test/resources/com/itextpdf/layout/FlexContainerTest/cmp_flexContainerDifferentChildrenDontFitVerticallyTest6.pdf b/layout/src/test/resources/com/itextpdf/layout/FlexContainerTest/cmp_flexContainerDifferentChildrenDontFitVerticallyTest6.pdf index 9e8ccdea33..7775459559 100644 Binary files a/layout/src/test/resources/com/itextpdf/layout/FlexContainerTest/cmp_flexContainerDifferentChildrenDontFitVerticallyTest6.pdf and b/layout/src/test/resources/com/itextpdf/layout/FlexContainerTest/cmp_flexContainerDifferentChildrenDontFitVerticallyTest6.pdf differ diff --git a/layout/src/test/resources/com/itextpdf/layout/FlexContainerTest/cmp_flexContainerDifferentChildrenDontFitVerticallyTest7.pdf b/layout/src/test/resources/com/itextpdf/layout/FlexContainerTest/cmp_flexContainerDifferentChildrenDontFitVerticallyTest7.pdf index 630704d336..3dadeb443e 100644 Binary files a/layout/src/test/resources/com/itextpdf/layout/FlexContainerTest/cmp_flexContainerDifferentChildrenDontFitVerticallyTest7.pdf and b/layout/src/test/resources/com/itextpdf/layout/FlexContainerTest/cmp_flexContainerDifferentChildrenDontFitVerticallyTest7.pdf differ diff --git a/layout/src/test/resources/com/itextpdf/layout/FlexContainerTest/cmp_flexContainerDifferentChildrenDontFitVerticallyTest8.pdf b/layout/src/test/resources/com/itextpdf/layout/FlexContainerTest/cmp_flexContainerDifferentChildrenDontFitVerticallyTest8.pdf index 694d972ce5..4bcbcd9197 100644 Binary files a/layout/src/test/resources/com/itextpdf/layout/FlexContainerTest/cmp_flexContainerDifferentChildrenDontFitVerticallyTest8.pdf and b/layout/src/test/resources/com/itextpdf/layout/FlexContainerTest/cmp_flexContainerDifferentChildrenDontFitVerticallyTest8.pdf differ diff --git a/layout/src/test/resources/com/itextpdf/layout/FlexContainerTest/cmp_flexContainerDifferentChildrenFitContainerDoesNotFitVerticallyTest10.pdf b/layout/src/test/resources/com/itextpdf/layout/FlexContainerTest/cmp_flexContainerDifferentChildrenFitContainerDoesNotFitVerticallyTest10.pdf index b4b702e4db..a2c16c3562 100644 Binary files a/layout/src/test/resources/com/itextpdf/layout/FlexContainerTest/cmp_flexContainerDifferentChildrenFitContainerDoesNotFitVerticallyTest10.pdf and b/layout/src/test/resources/com/itextpdf/layout/FlexContainerTest/cmp_flexContainerDifferentChildrenFitContainerDoesNotFitVerticallyTest10.pdf differ diff --git a/layout/src/test/resources/com/itextpdf/layout/FlexContainerTest/cmp_flexContainerDifferentChildrenFitContainerDoesNotFitVerticallyTest11.pdf b/layout/src/test/resources/com/itextpdf/layout/FlexContainerTest/cmp_flexContainerDifferentChildrenFitContainerDoesNotFitVerticallyTest11.pdf index 31635a88da..49bdb4f34b 100644 Binary files a/layout/src/test/resources/com/itextpdf/layout/FlexContainerTest/cmp_flexContainerDifferentChildrenFitContainerDoesNotFitVerticallyTest11.pdf and b/layout/src/test/resources/com/itextpdf/layout/FlexContainerTest/cmp_flexContainerDifferentChildrenFitContainerDoesNotFitVerticallyTest11.pdf differ diff --git a/layout/src/test/resources/com/itextpdf/layout/FlexContainerTest/cmp_flexContainerDifferentChildrenFitContainerDoesNotFitVerticallyTest3.pdf b/layout/src/test/resources/com/itextpdf/layout/FlexContainerTest/cmp_flexContainerDifferentChildrenFitContainerDoesNotFitVerticallyTest3.pdf index 25d8e935be..5ad45bcda8 100644 Binary files a/layout/src/test/resources/com/itextpdf/layout/FlexContainerTest/cmp_flexContainerDifferentChildrenFitContainerDoesNotFitVerticallyTest3.pdf and b/layout/src/test/resources/com/itextpdf/layout/FlexContainerTest/cmp_flexContainerDifferentChildrenFitContainerDoesNotFitVerticallyTest3.pdf differ diff --git a/layout/src/test/resources/com/itextpdf/layout/FlexContainerTest/cmp_flexContainerDifferentChildrenFitContainerDoesNotFitVerticallyTest6.pdf b/layout/src/test/resources/com/itextpdf/layout/FlexContainerTest/cmp_flexContainerDifferentChildrenFitContainerDoesNotFitVerticallyTest6.pdf index f39a46bd71..ce379965db 100644 Binary files a/layout/src/test/resources/com/itextpdf/layout/FlexContainerTest/cmp_flexContainerDifferentChildrenFitContainerDoesNotFitVerticallyTest6.pdf and b/layout/src/test/resources/com/itextpdf/layout/FlexContainerTest/cmp_flexContainerDifferentChildrenFitContainerDoesNotFitVerticallyTest6.pdf differ diff --git a/layout/src/test/resources/com/itextpdf/layout/FlexContainerTest/cmp_flexContainerDifferentChildrenFitContainerDoesNotFitVerticallyTest8.pdf b/layout/src/test/resources/com/itextpdf/layout/FlexContainerTest/cmp_flexContainerDifferentChildrenFitContainerDoesNotFitVerticallyTest8.pdf index 0fd5301058..61c547d237 100644 Binary files a/layout/src/test/resources/com/itextpdf/layout/FlexContainerTest/cmp_flexContainerDifferentChildrenFitContainerDoesNotFitVerticallyTest8.pdf and b/layout/src/test/resources/com/itextpdf/layout/FlexContainerTest/cmp_flexContainerDifferentChildrenFitContainerDoesNotFitVerticallyTest8.pdf differ diff --git a/layout/src/test/resources/com/itextpdf/layout/FontSelectorTest/cmp_cyrillicAndLatinGroup.pdf b/layout/src/test/resources/com/itextpdf/layout/FontSelectorTest/cmp_cyrillicAndLatinGroup.pdf index 3e6f446fc3..4ed5f7f8cf 100644 Binary files a/layout/src/test/resources/com/itextpdf/layout/FontSelectorTest/cmp_cyrillicAndLatinGroup.pdf and b/layout/src/test/resources/com/itextpdf/layout/FontSelectorTest/cmp_cyrillicAndLatinGroup.pdf differ diff --git a/layout/src/test/resources/com/itextpdf/layout/FontSelectorTest/cmp_cyrillicAndLatinGroup2.pdf b/layout/src/test/resources/com/itextpdf/layout/FontSelectorTest/cmp_cyrillicAndLatinGroup2.pdf index 44bac01210..3606e69da7 100644 Binary files a/layout/src/test/resources/com/itextpdf/layout/FontSelectorTest/cmp_cyrillicAndLatinGroup2.pdf and b/layout/src/test/resources/com/itextpdf/layout/FontSelectorTest/cmp_cyrillicAndLatinGroup2.pdf differ diff --git a/layout/src/test/resources/com/itextpdf/layout/FontSelectorTest/cmp_cyrillicAndLatinGroup3.pdf b/layout/src/test/resources/com/itextpdf/layout/FontSelectorTest/cmp_cyrillicAndLatinGroup3.pdf index da66bbfdab..fbe7d8afa0 100644 Binary files a/layout/src/test/resources/com/itextpdf/layout/FontSelectorTest/cmp_cyrillicAndLatinGroup3.pdf and b/layout/src/test/resources/com/itextpdf/layout/FontSelectorTest/cmp_cyrillicAndLatinGroup3.pdf differ diff --git a/layout/src/test/resources/com/itextpdf/layout/FontSelectorTest/cmp_cyrillicAndLatinWithUnicodeRange.pdf b/layout/src/test/resources/com/itextpdf/layout/FontSelectorTest/cmp_cyrillicAndLatinWithUnicodeRange.pdf index f69a8b18e1..b4ccf49431 100644 Binary files a/layout/src/test/resources/com/itextpdf/layout/FontSelectorTest/cmp_cyrillicAndLatinWithUnicodeRange.pdf and b/layout/src/test/resources/com/itextpdf/layout/FontSelectorTest/cmp_cyrillicAndLatinWithUnicodeRange.pdf differ diff --git a/layout/src/test/resources/com/itextpdf/layout/FontSelectorTest/cmp_duplicateFontWithUnicodeRange.pdf b/layout/src/test/resources/com/itextpdf/layout/FontSelectorTest/cmp_duplicateFontWithUnicodeRange.pdf index 59e617c30b..d28b1a7a4b 100644 Binary files a/layout/src/test/resources/com/itextpdf/layout/FontSelectorTest/cmp_duplicateFontWithUnicodeRange.pdf and b/layout/src/test/resources/com/itextpdf/layout/FontSelectorTest/cmp_duplicateFontWithUnicodeRange.pdf differ diff --git a/layout/src/test/resources/com/itextpdf/layout/GridContainerTest/cmp_basicThreeColumnsTest.pdf b/layout/src/test/resources/com/itextpdf/layout/GridContainerTest/cmp_basicThreeColumnsTest.pdf index 89371e7953..0aa4e37347 100644 Binary files a/layout/src/test/resources/com/itextpdf/layout/GridContainerTest/cmp_basicThreeColumnsTest.pdf and b/layout/src/test/resources/com/itextpdf/layout/GridContainerTest/cmp_basicThreeColumnsTest.pdf differ diff --git a/layout/src/test/resources/com/itextpdf/layout/GridContainerTest/cmp_borderBoxChild.pdf b/layout/src/test/resources/com/itextpdf/layout/GridContainerTest/cmp_borderBoxChild.pdf new file mode 100644 index 0000000000..b8387843b9 Binary files /dev/null and b/layout/src/test/resources/com/itextpdf/layout/GridContainerTest/cmp_borderBoxChild.pdf differ diff --git a/layout/src/test/resources/com/itextpdf/layout/GridContainerTest/cmp_borderBoxWithNoBordersTest.pdf b/layout/src/test/resources/com/itextpdf/layout/GridContainerTest/cmp_borderBoxWithNoBordersTest.pdf new file mode 100644 index 0000000000..db964dcf55 Binary files /dev/null and b/layout/src/test/resources/com/itextpdf/layout/GridContainerTest/cmp_borderBoxWithNoBordersTest.pdf differ diff --git a/layout/src/test/resources/com/itextpdf/layout/HyphenationTreeTest/hyphen_pattern.xml b/layout/src/test/resources/com/itextpdf/layout/HyphenationTreeTest/hyphen_pattern.xml new file mode 100644 index 0000000000..fd7ac3b907 --- /dev/null +++ b/layout/src/test/resources/com/itextpdf/layout/HyphenationTreeTest/hyphen_pattern.xml @@ -0,0 +1,10 @@ + + + + + +.ab4i +.ac4i +.ad4i + + diff --git a/layout/src/test/resources/com/itextpdf/layout/HyphenationTreeTest/only_classes.xml b/layout/src/test/resources/com/itextpdf/layout/HyphenationTreeTest/only_classes.xml new file mode 100644 index 0000000000..070523640b --- /dev/null +++ b/layout/src/test/resources/com/itextpdf/layout/HyphenationTreeTest/only_classes.xml @@ -0,0 +1,35 @@ + + + + + + + +aA +bB +cC +dD +eE +fF +gG +hH +iI +jJ +kK +lL +mM +nN +oO +pP +qQ +rR +sS +tT +uU +vV +wW +xX +yY +zZ + + diff --git a/layout/src/test/resources/com/itextpdf/layout/LayoutTaggingTest/cmp_notAsciiCharTest.pdf b/layout/src/test/resources/com/itextpdf/layout/LayoutTaggingTest/cmp_notAsciiCharTest.pdf index 5ae6c5ea5d..b743463bab 100644 Binary files a/layout/src/test/resources/com/itextpdf/layout/LayoutTaggingTest/cmp_notAsciiCharTest.pdf and b/layout/src/test/resources/com/itextpdf/layout/LayoutTaggingTest/cmp_notAsciiCharTest.pdf differ diff --git a/layout/src/test/resources/com/itextpdf/layout/RotationTest/cmp_ignorePageRotationForContent.pdf b/layout/src/test/resources/com/itextpdf/layout/RotationTest/cmp_ignorePageRotationForContent.pdf new file mode 100644 index 0000000000..04824ffaa3 Binary files /dev/null and b/layout/src/test/resources/com/itextpdf/layout/RotationTest/cmp_ignorePageRotationForContent.pdf differ diff --git a/layout/src/test/resources/com/itextpdf/layout/RotationTest/rotated.pdf b/layout/src/test/resources/com/itextpdf/layout/RotationTest/rotated.pdf new file mode 100644 index 0000000000..54fd51c3d0 Binary files /dev/null and b/layout/src/test/resources/com/itextpdf/layout/RotationTest/rotated.pdf differ diff --git a/layout/src/test/resources/com/itextpdf/layout/XMPWriterTest/cmp_addUAXMPMetaDataNotTaggedTest.pdf b/layout/src/test/resources/com/itextpdf/layout/XMPWriterTest/cmp_addUAXMPMetaDataNotTaggedTest.pdf index d7ea61b08e..53e7e0f0cc 100644 Binary files a/layout/src/test/resources/com/itextpdf/layout/XMPWriterTest/cmp_addUAXMPMetaDataNotTaggedTest.pdf and b/layout/src/test/resources/com/itextpdf/layout/XMPWriterTest/cmp_addUAXMPMetaDataNotTaggedTest.pdf differ diff --git a/native-image-test/pom.xml b/native-image-test/pom.xml index 7b2b9e9c36..a56b50aa82 100644 --- a/native-image-test/pom.xml +++ b/native-image-test/pom.xml @@ -5,7 +5,7 @@ com.itextpdf root - 8.0.5 + 9.0.0 native-image-test @@ -66,6 +66,11 @@ sign ${itext.version} + + com.itextpdf + commons + ${itext.version} + com.itextpdf svg diff --git a/native-image-test/src/test/java/com/itextpdf/nativeimage/BouncyCastleTest.java b/native-image-test/src/test/java/com/itextpdf/nativeimage/BouncyCastleTest.java index 3b27f30c71..f0e97d883c 100644 --- a/native-image-test/src/test/java/com/itextpdf/nativeimage/BouncyCastleTest.java +++ b/native-image-test/src/test/java/com/itextpdf/nativeimage/BouncyCastleTest.java @@ -37,7 +37,7 @@ This file is part of the iText (R) project. import org.junit.jupiter.api.condition.DisabledInNativeImage; class BouncyCastleTest { - private static final String SOURCE_FOLDER = "com/itextpdf/nativeimage/BouncyCastleTest/"; + private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/nativeimage/BouncyCastleTest/"; @Test void readEncryptedDocument() throws IOException { diff --git a/native-image-test/src/test/java/com/itextpdf/nativeimage/KernelTest.java b/native-image-test/src/test/java/com/itextpdf/nativeimage/KernelTest.java index 711d12b831..0ae1293d8e 100644 --- a/native-image-test/src/test/java/com/itextpdf/nativeimage/KernelTest.java +++ b/native-image-test/src/test/java/com/itextpdf/nativeimage/KernelTest.java @@ -22,8 +22,14 @@ This file is part of the iText (R) project. */ package com.itextpdf.nativeimage; +import com.itextpdf.commons.datastructures.ISimpleList; +import com.itextpdf.commons.datastructures.SimpleArrayList; +import com.itextpdf.io.source.ByteArrayOutputStream; +import com.itextpdf.kernel.di.pagetree.IPageTreeListFactory; +import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfName; +import com.itextpdf.kernel.pdf.PdfWriter; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -32,4 +38,12 @@ class KernelTest { void staticPdfNames() { Assertions.assertTrue(PdfName.staticNames.size() > 800); } + + @Test + void testDefaultPagesFactory(){ + PdfDocument pdfDocument = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); + IPageTreeListFactory factory = pdfDocument.getDiContainer().getInstance(IPageTreeListFactory.class); + ISimpleList f = factory.createList(null); + Assertions.assertInstanceOf(SimpleArrayList.class, f); + } } diff --git a/pdfa/pom.xml b/pdfa/pom.xml index abe614082d..29a4f290a0 100644 --- a/pdfa/pom.xml +++ b/pdfa/pom.xml @@ -5,7 +5,7 @@ com.itextpdf root - 8.0.5 + 9.0.0 pdfa diff --git a/pdfa/src/main/java/com/itextpdf/pdfa/PdfAAgnosticPdfDocument.java b/pdfa/src/main/java/com/itextpdf/pdfa/PdfAAgnosticPdfDocument.java deleted file mode 100644 index 6b713606fc..0000000000 --- a/pdfa/src/main/java/com/itextpdf/pdfa/PdfAAgnosticPdfDocument.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - This file is part of the iText (R) project. - Copyright (c) 1998-2024 Apryse Group NV - Authors: Apryse Software. - - This program is offered under a commercial and under the AGPL license. - For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. - - AGPL licensing: - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . - */ -package com.itextpdf.pdfa; - -import com.itextpdf.kernel.pdf.PdfReader; -import com.itextpdf.kernel.pdf.PdfWriter; -import com.itextpdf.kernel.pdf.StampingProperties; - -/** - * This class extends {@link PdfADocument} and serves as {@link PdfADocument} for - * PDF/A compliant documents and as {@link com.itextpdf.kernel.pdf.PdfDocument} - * for non PDF/A documents. - * - *

    - * This class can throw various exceptions like {@link com.itextpdf.kernel.exceptions.PdfException} - * as well as {@link com.itextpdf.pdfa.exceptions.PdfAConformanceException} for PDF/A documents. - */ -public class PdfAAgnosticPdfDocument extends PdfADocument { - - - /** - * Opens a PDF/A document in stamping mode. - * - * @param reader the {@link PdfReader} - * @param writer the {@link PdfWriter} object to write to - */ - public PdfAAgnosticPdfDocument (PdfReader reader, PdfWriter writer) { - this(reader, writer, new StampingProperties()); - } - - /** - * Opens a PDF/A document in stamping mode. - * - * @param reader the {@link PdfReader} - * @param writer the {@link PdfWriter} object to write to - * @param properties {@link StampingProperties} of the stamping process - */ - public PdfAAgnosticPdfDocument (PdfReader reader, PdfWriter writer, StampingProperties properties) { - super(reader, writer, properties, true); - } -} diff --git a/pdfa/src/main/java/com/itextpdf/pdfa/PdfADefaultFontStrategy.java b/pdfa/src/main/java/com/itextpdf/pdfa/PdfADefaultFontStrategy.java new file mode 100644 index 0000000000..126f5b4ec9 --- /dev/null +++ b/pdfa/src/main/java/com/itextpdf/pdfa/PdfADefaultFontStrategy.java @@ -0,0 +1,50 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.pdfa; + +import com.itextpdf.kernel.font.PdfFont; +import com.itextpdf.kernel.pdf.DefaultFontStrategy; +import com.itextpdf.kernel.pdf.PdfDocument; + +/** + * The class presents default font strategy for PDF/A documents which + * doesn't provide default font because all used fonts must be embedded. + */ +public class PdfADefaultFontStrategy extends DefaultFontStrategy { + /** + * Instantiates a new {@link PdfADefaultFontStrategy} instance based on the document which will use that strategy. + * + * @param pdfDocument the pdf document which will use that strategy + */ + public PdfADefaultFontStrategy(PdfDocument pdfDocument) { + super(pdfDocument); + } + + /** + * {@inheritDoc}. + */ + @Override + public PdfFont getFont() { + return null; + } +} diff --git a/pdfa/src/main/java/com/itextpdf/pdfa/PdfADocument.java b/pdfa/src/main/java/com/itextpdf/pdfa/PdfADocument.java index 61572034f3..5ff1cf3804 100644 --- a/pdfa/src/main/java/com/itextpdf/pdfa/PdfADocument.java +++ b/pdfa/src/main/java/com/itextpdf/pdfa/PdfADocument.java @@ -22,30 +22,17 @@ This file is part of the iText (R) project. */ package com.itextpdf.pdfa; -import com.itextpdf.io.logs.IoLogMessageConstant; -import com.itextpdf.kernel.font.PdfFont; +import com.itextpdf.commons.utils.MessageFormatUtil; import com.itextpdf.kernel.pdf.DocumentProperties; -import com.itextpdf.kernel.pdf.IConformanceLevel; -import com.itextpdf.kernel.pdf.IPdfPageFactory; -import com.itextpdf.kernel.pdf.IsoKey; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfAConformance; +import com.itextpdf.kernel.pdf.PdfConformance; import com.itextpdf.kernel.pdf.PdfDocument; -import com.itextpdf.kernel.pdf.PdfName; -import com.itextpdf.kernel.pdf.PdfObject; import com.itextpdf.kernel.pdf.PdfOutputIntent; import com.itextpdf.kernel.pdf.PdfReader; -import com.itextpdf.kernel.pdf.PdfResources; -import com.itextpdf.kernel.pdf.PdfStream; import com.itextpdf.kernel.pdf.PdfVersion; import com.itextpdf.kernel.pdf.PdfWriter; import com.itextpdf.kernel.pdf.StampingProperties; -import com.itextpdf.kernel.pdf.tagutils.TagStructureContext; -import com.itextpdf.kernel.utils.ValidationContainer; -import com.itextpdf.kernel.xmp.XMPConst; -import com.itextpdf.kernel.xmp.XMPException; -import com.itextpdf.kernel.xmp.XMPMeta; -import com.itextpdf.kernel.xmp.XMPMetaFactory; -import com.itextpdf.kernel.xmp.XMPUtils; +import com.itextpdf.kernel.validation.ValidationContainer; import com.itextpdf.pdfa.checker.PdfA1Checker; import com.itextpdf.pdfa.checker.PdfA2Checker; import com.itextpdf.pdfa.checker.PdfA3Checker; @@ -55,75 +42,57 @@ This file is part of the iText (R) project. import com.itextpdf.pdfa.exceptions.PdfaExceptionMessageConstant; import com.itextpdf.pdfa.logs.PdfALogMessageConstant; -import java.io.IOException; -import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * This class extends {@link PdfDocument} and is in charge of creating files * that comply with the PDF/A standard. * + *

    * Client code is still responsible for making sure the file is actually PDF/A * compliant: multiple steps must be undertaken (depending on the - * {@link PdfAConformanceLevel}) to ensure that the PDF/A standard is followed. + * {@link PdfConformance}) to ensure that the PDF/A standard is followed. * + *

    * This class will throw exceptions, mostly {@link PdfAConformanceException}, * and thus refuse to output a PDF/A file if at any point the document does not - * adhere to the PDF/A guidelines specified by the {@link PdfAConformanceLevel}. + * adhere to the PDF/A guidelines specified by the {@link PdfConformance}. */ public class PdfADocument extends PdfDocument { - - private static IPdfPageFactory pdfAPageFactory = new PdfAPageFactory(); - - protected PdfAChecker checker; - - private boolean alreadyLoggedThatObjectFlushingWasNotPerformed = false; - - private boolean alreadyLoggedThatPageFlushingWasNotPerformed = false; - - private boolean isPdfADocument = true; - /** * Constructs a new PdfADocument for writing purposes, i.e. from scratch. A - * PDF/A file has a conformance level, and must have an explicit output + * PDF/A file has a conformance, and must have an explicit output * intent. * * @param writer the {@link PdfWriter} object to write to - * @param conformanceLevel the generation and strictness level of the PDF/A that must be followed. + * @param aConformance the generation and strictness level of the PDF/A that must be followed. * @param outputIntent a {@link PdfOutputIntent} */ - public PdfADocument(PdfWriter writer, PdfAConformanceLevel conformanceLevel, PdfOutputIntent outputIntent) { - this(writer, conformanceLevel, outputIntent, new DocumentProperties()); + public PdfADocument(PdfWriter writer, PdfAConformance aConformance, PdfOutputIntent outputIntent) { + this(writer, aConformance, outputIntent, new DocumentProperties()); } /** * Constructs a new PdfADocument for writing purposes, i.e. from scratch. A - * PDF/A file has a conformance level, and must have an explicit output + * PDF/A file has a conformance, and must have an explicit output * intent. * * @param writer the {@link PdfWriter} object to write to - * @param conformanceLevel the generation and strictness level of the PDF/A that must be followed. + * @param aConformance the generation and strictness level of the PDF/A that must be followed. * @param outputIntent a {@link PdfOutputIntent} * @param properties a {@link com.itextpdf.kernel.pdf.DocumentProperties} */ - public PdfADocument(PdfWriter writer, PdfAConformanceLevel conformanceLevel, PdfOutputIntent outputIntent, DocumentProperties properties) { - super(writer, properties); - setChecker(conformanceLevel); - addOutputIntent(outputIntent); - } - + public PdfADocument(PdfWriter writer, PdfAConformance aConformance, PdfOutputIntent outputIntent, DocumentProperties properties) { + super(configureWriterProperties(writer, aConformance), properties); - /** - * No default font for PDF/A documents. - * - * @return {@code null}. - */ - @Override - public PdfFont getDefaultFont() { - if (isPdfADocument) { - return null; - } - return super.getDefaultFont(); + PdfAChecker checker = getCorrectCheckerFromConformance(getConformance().getAConformance()); + ValidationContainer validationContainer = new ValidationContainer(); + validationContainer.addChecker(checker); + getDiContainer().register(ValidationContainer.class, validationContainer); + this.pdfPageFactory = new PdfAPageFactory(checker); + this.documentInfoHelper = new PdfADocumentInfoHelper(this); + this.defaultFontStrategy = new PdfADefaultFontStrategy(this); + addOutputIntent(outputIntent); } /** @@ -144,190 +113,44 @@ public PdfADocument(PdfReader reader, PdfWriter writer) { * @param properties properties of the stamping process */ public PdfADocument(PdfReader reader, PdfWriter writer, StampingProperties properties) { - this(reader, writer, properties, false); - } - - PdfADocument(PdfReader reader, PdfWriter writer, StampingProperties properties, boolean tolerant) { super(reader, writer, properties); - PdfAConformanceLevel conformanceLevel = reader.getPdfAConformanceLevel(); - if (conformanceLevel == null) { - if (tolerant) { - isPdfADocument = false; - } else { - throw new PdfAConformanceException( - PdfaExceptionMessageConstant. - DOCUMENT_TO_READ_FROM_SHALL_BE_A_PDFA_CONFORMANT_FILE_WITH_VALID_XMP_METADATA); - } - } - - setChecker(conformanceLevel); - } - - - /** - * {@inheritDoc} - */ - @Override - public IConformanceLevel getConformanceLevel() { - if (isPdfADocument) { - return checker.getConformanceLevel(); - } else { - return null; - } - } - - /** - * {@inheritDoc} - * - * @param outputIntent {@inheritDoc} - */ - @Override - public void addOutputIntent(PdfOutputIntent outputIntent) { - super.addOutputIntent(outputIntent); - checker.setPdfAOutputIntentColorSpace(getCatalog().getPdfObject()); - } - - void logThatPdfAPageFlushingWasNotPerformed() { - if (!alreadyLoggedThatPageFlushingWasNotPerformed) { - alreadyLoggedThatPageFlushingWasNotPerformed = true; - // This log message will be printed once for one instance of the document. - LoggerFactory.getLogger(PdfADocument.class).warn(PdfALogMessageConstant.PDFA_PAGE_FLUSHING_WAS_NOT_PERFORMED); - } - } - - @Override - protected void addCustomMetadataExtensions(XMPMeta xmpMeta) { - if (!isPdfADocument) { - super.addCustomMetadataExtensions(xmpMeta); - return; - } - - if (this.isTagged()) { - try { - if (xmpMeta.getPropertyInteger(XMPConst.NS_PDFUA_ID, XMPConst.PART) != null) { - XMPMeta taggedExtensionMeta = XMPMetaFactory.parseFromString(PdfAXMPUtil.PDF_UA_EXTENSION); - XMPUtils.appendProperties(taggedExtensionMeta, xmpMeta, true, false); - } - } catch (XMPException exc) { - Logger logger = LoggerFactory.getLogger(PdfADocument.class); - logger.error(IoLogMessageConstant.EXCEPTION_WHILE_UPDATING_XMPMETADATA, exc); - } - } - } - - @Override - protected void updateXmpMetadata() { - if (!isPdfADocument) { - super.updateXmpMetadata(); - return; - } - - try { - XMPMeta xmpMeta = updateDefaultXmpMetadata(); - xmpMeta.setProperty(XMPConst.NS_PDFA_ID, XMPConst.PART, checker.getConformanceLevel().getPart()); - if (checker.getConformanceLevel().getConformance() != null) { - xmpMeta.setProperty(XMPConst.NS_PDFA_ID, XMPConst.CONFORMANCE, - checker.getConformanceLevel().getConformance()); - } - if ("4".equals(checker.getConformanceLevel().getPart())) { - xmpMeta.setProperty(XMPConst.NS_PDFA_ID, XMPConst.REV, PdfAConformanceLevel.PDF_A_4_REVISION); - } - addCustomMetadataExtensions(xmpMeta); - setXmpMetadata(xmpMeta); - } catch (XMPException e) { - Logger logger = LoggerFactory.getLogger(PdfADocument.class); - logger.error(IoLogMessageConstant.EXCEPTION_WHILE_UPDATING_XMPMETADATA, e); - } - } - - @Override - protected void checkIsoConformance() { - setCheckerIfChanged(); - super.checkIsoConformance(); - } - - /** - * @param obj an object to conform. - * @param key type of object to conform. - * @param resources {@link PdfResources} associated with an object to check. - * @param contentStream current content stream. - * @param extra extra data required for the check. - */ - @Override - public void checkIsoConformance(Object obj, IsoKey key, PdfResources resources, PdfStream contentStream, - Object extra) { - setCheckerIfChanged(); - super.checkIsoConformance(obj, key, resources, contentStream, extra); - } + if (!getConformance().isPdfA()) { + throw new PdfAConformanceException( + PdfaExceptionMessageConstant. + DOCUMENT_TO_READ_FROM_SHALL_BE_A_PDFA_CONFORMANT_FILE_WITH_VALID_XMP_METADATA); - @Override - protected void flushObject(PdfObject pdfObject, boolean canBeInObjStm) throws IOException { - if (!isPdfADocument) { - super.flushObject(pdfObject, canBeInObjStm); - return; } - markObjectAsMustBeFlushed(pdfObject); - if (isClosing || checker.objectIsChecked(pdfObject)) { - super.flushObject(pdfObject, canBeInObjStm); - } else if (!alreadyLoggedThatObjectFlushingWasNotPerformed) { - alreadyLoggedThatObjectFlushingWasNotPerformed = true; - // This log message will be printed once for one instance of the document. - LoggerFactory.getLogger(PdfADocument.class) - .warn(PdfALogMessageConstant.PDFA_OBJECT_FLUSHING_WAS_NOT_PERFORMED); - } + PdfAChecker checker = getCorrectCheckerFromConformance(getConformance().getAConformance()); + ValidationContainer validationContainer = new ValidationContainer(); + validationContainer.addChecker(checker); + getDiContainer().register(ValidationContainer.class, validationContainer); + this.pdfPageFactory = new PdfAPageFactory(checker); + this.documentInfoHelper = new PdfADocumentInfoHelper(this); + this.defaultFontStrategy = new PdfADefaultFontStrategy(this); } /** - * Sets the checker that defines the requirements of the PDF/A standard - * depending on conformance level. + * Gets correct {@link PdfAChecker} for specified PDF/A conformance. + * + * @param aConformance the conformance for which checker is needed * - * @param conformanceLevel {@link PdfAConformanceLevel} + * @return the correct PDF/A checker */ - protected void setChecker(PdfAConformanceLevel conformanceLevel) { - if (!isPdfADocument) { - return; - } - setChecker(getCorrectCheckerFromConformance(conformanceLevel)); - } - - protected void setChecker(PdfAChecker checker) { - if (!isPdfADocument) { - return; - } - this.checker = checker; - ValidationContainer validationContainer = new ValidationContainer(); - validationContainer.addChecker(checker); - this.getDiContainer().register(ValidationContainer.class, validationContainer); - } - - private void setCheckerIfChanged() { - if (!isPdfADocument) { - return; - } - if (!getDiContainer().isRegistered(ValidationContainer.class)) { - return; - } - ValidationContainer validationContainer = getDiContainer().getInstance(ValidationContainer.class); - if (validationContainer != null && !validationContainer.containsChecker(checker)) { - setChecker(checker); - } - } - - private static PdfAChecker getCorrectCheckerFromConformance(PdfAConformanceLevel conformanceLevel) { + public static PdfAChecker getCorrectCheckerFromConformance(PdfAConformance aConformance) { PdfAChecker checker; - switch (conformanceLevel.getPart()) { + switch (aConformance.getPart()) { case "1": - checker = new PdfA1Checker(conformanceLevel); + checker = new PdfA1Checker(aConformance); break; case "2": - checker = new PdfA2Checker(conformanceLevel); + checker = new PdfA2Checker(aConformance); break; case "3": - checker = new PdfA3Checker(conformanceLevel); + checker = new PdfA3Checker(aConformance); break; case "4": - checker = new PdfA4Checker(conformanceLevel); + checker = new PdfA4Checker(aConformance); break; default: throw new IllegalArgumentException(PdfaExceptionMessageConstant @@ -336,66 +159,28 @@ private static PdfAChecker getCorrectCheckerFromConformance(PdfAConformanceLevel return checker; } - /** - * Initializes tagStructureContext to track necessary information of document's tag structure. - */ - @Override - protected void initTagStructureContext() { - if (isPdfADocument) { - tagStructureContext = new TagStructureContext(this, getPdfVersionForPdfA(checker.getConformanceLevel())); - } else { - super.initTagStructureContext(); - } - } - - @Override - protected IPdfPageFactory getPageFactory() { - if (isPdfADocument) { - return pdfAPageFactory; - } else { - return super.getPageFactory(); - } - } - - /** - * {@inheritDoc} - * - * @param appendMode {@inheritDoc} - */ - @Override - protected void flushInfoDictionary(boolean appendMode) { - if (!isPdfADocument || (!"4".equals(checker.getConformanceLevel().getPart()))) { - super.flushInfoDictionary(appendMode); - } else if (getCatalog().getPdfObject().get(PdfName.PieceInfo) != null) { - // Leave only ModDate as required by 6.1.3 File trailer of pdf/a-4 spec - getDocumentInfo().removeCreationDate(); - super.flushInfoDictionary(appendMode); - } - } - - boolean isClosing() { - return isClosing; - } - - private static PdfVersion getPdfVersionForPdfA(PdfAConformanceLevel conformanceLevel) { - PdfVersion version; - switch (conformanceLevel.getPart()) { + private static PdfVersion getPdfVersionAccordingToConformance(PdfAConformance aConformance) { + switch (aConformance.getPart()) { case "1": - version = PdfVersion.PDF_1_4; - break; + return PdfVersion.PDF_1_4; case "2": - version = PdfVersion.PDF_1_7; - break; case "3": - version = PdfVersion.PDF_1_7; - break; + return PdfVersion.PDF_1_7; case "4": - version = PdfVersion.PDF_2_0; - break; + return PdfVersion.PDF_2_0; default: - version = PdfVersion.PDF_1_4; - break; + return PdfVersion.PDF_1_7; + } + } + + private static PdfWriter configureWriterProperties(PdfWriter writer, PdfAConformance aConformance) { + writer.getProperties().addPdfAXmpMetadata(aConformance); + final PdfVersion aConformancePdfVersion = getPdfVersionAccordingToConformance(aConformance); + if (writer.getPdfVersion() != null && !writer.getPdfVersion().equals(aConformancePdfVersion)) { + LoggerFactory.getLogger(PdfADocument.class).warn(MessageFormatUtil.format( + PdfALogMessageConstant.WRITER_PROPERTIES_PDF_VERSION_WAS_OVERRIDDEN, aConformancePdfVersion)); } - return version; + writer.getProperties().setPdfVersion(aConformancePdfVersion); + return writer; } } diff --git a/pdfa/src/main/java/com/itextpdf/pdfa/PdfADocumentInfoHelper.java b/pdfa/src/main/java/com/itextpdf/pdfa/PdfADocumentInfoHelper.java new file mode 100644 index 0000000000..3fe02d8d2d --- /dev/null +++ b/pdfa/src/main/java/com/itextpdf/pdfa/PdfADocumentInfoHelper.java @@ -0,0 +1,69 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.pdfa; + +import com.itextpdf.kernel.pdf.DocumentInfoHelper; +import com.itextpdf.kernel.pdf.PdfDocument; +import com.itextpdf.kernel.pdf.PdfDocumentInfo; +import com.itextpdf.kernel.pdf.PdfName; + +/** + * The class is helper which used for PDF/A document to properly configure PDF document's info dictionary. + */ +public class PdfADocumentInfoHelper extends DocumentInfoHelper { + private final PdfDocument pdfDocument; + + /** + * Instantiates a new {@link PdfADocumentInfoHelper} instance based on the document. + * + * @param pdfDocument the pdf document which will use that helper + */ + public PdfADocumentInfoHelper(PdfDocument pdfDocument) { + this.pdfDocument = pdfDocument; + } + + /** + * {@inheritDoc}. + */ + @Override + public boolean shouldAddDocumentInfoToTrailer() { + if ("4".equals(pdfDocument.getConformance().getAConformance().getPart())) { + // In case of PieceInfo == null don't add Info to trailer + return pdfDocument.getCatalog().getPdfObject().get(PdfName.PieceInfo) != null; + } + return true; + } + + /** + * {@inheritDoc}. + */ + @Override + public void adjustDocumentInfo(PdfDocumentInfo documentInfo) { + if ("4".equals(pdfDocument.getConformance().getAConformance().getPart())) { + if (pdfDocument.getCatalog().getPdfObject().get(PdfName.PieceInfo) != null) { + // Leave only ModDate as required by 6.1.3 File trailer of pdf/a-4 spec + documentInfo.removeCreationDate(); + } + } + } +} diff --git a/pdfa/src/main/java/com/itextpdf/pdfa/PdfAPage.java b/pdfa/src/main/java/com/itextpdf/pdfa/PdfAPage.java index 70e6d823a7..f021cdfb0e 100644 --- a/pdfa/src/main/java/com/itextpdf/pdfa/PdfAPage.java +++ b/pdfa/src/main/java/com/itextpdf/pdfa/PdfAPage.java @@ -26,15 +26,19 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfPage; +import com.itextpdf.pdfa.checker.PdfAChecker; class PdfAPage extends PdfPage { + private final PdfAChecker checker; - PdfAPage(PdfDocument pdfDocument, PageSize pageSize) { + PdfAPage(PdfDocument pdfDocument, PageSize pageSize, PdfAChecker checker) { super(pdfDocument, pageSize); + this.checker = checker; } - PdfAPage(PdfDictionary pdfObject) { + PdfAPage(PdfDictionary pdfObject, PdfAChecker checker) { super(pdfObject); + this.checker = checker; } @Override @@ -42,12 +46,10 @@ public void flush(boolean flushResourcesContentStreams) { // We check in advance whether this PdfAPage can be flushed and call the flush method only if it is. // This avoids processing actions that are invoked during flushing (for example, sending the END_PAGE event) // if the page is not actually flushed. - if (flushResourcesContentStreams - || ((PdfADocument) getDocument()).isClosing() - || ((PdfADocument) getDocument()).checker.objectIsChecked(this.getPdfObject())) { + if (flushResourcesContentStreams || getDocument().isClosing() || + checker.isPdfObjectReadyToFlush(this.getPdfObject())) { + super.flush(flushResourcesContentStreams); - } else { - ((PdfADocument) getDocument()).logThatPdfAPageFlushingWasNotPerformed(); } } } diff --git a/pdfa/src/main/java/com/itextpdf/pdfa/PdfAPageFactory.java b/pdfa/src/main/java/com/itextpdf/pdfa/PdfAPageFactory.java index 697b128207..ddddc78f6c 100644 --- a/pdfa/src/main/java/com/itextpdf/pdfa/PdfAPageFactory.java +++ b/pdfa/src/main/java/com/itextpdf/pdfa/PdfAPageFactory.java @@ -27,16 +27,36 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfPage; +import com.itextpdf.pdfa.checker.PdfAChecker; -class PdfAPageFactory implements IPdfPageFactory { +/** + * The class implements PDF page factory which is used for creating correct PDF/A documents. + */ +public class PdfAPageFactory implements IPdfPageFactory { + private final PdfAChecker checker; + + /** + * Instantiates a new {@link PdfAPageFactory} instance based on {@link PdfAChecker}. + * + * @param checker the PDF/A checker + */ + public PdfAPageFactory(PdfAChecker checker) { + this.checker = checker; + } + /** + * {@inheritDoc}. + */ @Override public PdfPage createPdfPage(PdfDictionary pdfObject) { - return new PdfAPage(pdfObject); + return new PdfAPage(pdfObject, checker); } + /** + * {@inheritDoc}. + */ @Override public PdfPage createPdfPage(PdfDocument pdfDocument, PageSize pageSize) { - return new PdfAPage(pdfDocument, pageSize); + return new PdfAPage(pdfDocument, pageSize, checker); } } diff --git a/pdfa/src/main/java/com/itextpdf/pdfa/PdfAXMPUtil.java b/pdfa/src/main/java/com/itextpdf/pdfa/PdfAXMPUtil.java index 8f6b6e4789..11692780ca 100644 --- a/pdfa/src/main/java/com/itextpdf/pdfa/PdfAXMPUtil.java +++ b/pdfa/src/main/java/com/itextpdf/pdfa/PdfAXMPUtil.java @@ -30,46 +30,6 @@ This file is part of the iText (R) project. * Utilities to construct an XMP for a PDF/A file. */ public class PdfAXMPUtil { - - public static final String PDF_UA_EXTENSION = - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " pdfuaid\n" + - " PDF/UA identification schema\n" + - " \n" + - " \n" + - " \n" + - " internal\n" + - " PDF/UA version identifier\n" + - " part\n" + - " Integer\n" + - " \n" + - " \n" + - " internal\n" + - " PDF/UA amendment identifier\n" + - " amd\n" + - " Text\n" + - " \n" + - " \n" + - " internal\n" + - " PDF/UA corrigenda identifier\n" + - " corr\n" + - " Text\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " "; - /** * Check whether the given byte array is an UTF-8 encoded character sequence. * diff --git a/pdfa/src/main/java/com/itextpdf/pdfa/checker/PdfA1Checker.java b/pdfa/src/main/java/com/itextpdf/pdfa/checker/PdfA1Checker.java index 2603f7ccdb..1128e8ef2d 100644 --- a/pdfa/src/main/java/com/itextpdf/pdfa/checker/PdfA1Checker.java +++ b/pdfa/src/main/java/com/itextpdf/pdfa/checker/PdfA1Checker.java @@ -34,7 +34,7 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.font.PdfFont; import com.itextpdf.kernel.font.PdfTrueTypeFont; import com.itextpdf.kernel.font.PdfType3Font; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfAConformance; import com.itextpdf.kernel.pdf.PdfArray; import com.itextpdf.kernel.pdf.PdfBoolean; import com.itextpdf.kernel.pdf.PdfCatalog; @@ -116,13 +116,13 @@ public class PdfA1Checker extends PdfAChecker { private static final Logger logger = LoggerFactory.getLogger(PdfAChecker.class); /** - * Creates a PdfA1Checker with the required conformance level + * Creates a PdfA1Checker with the required conformance * - * @param conformanceLevel the required conformance level, a or + * @param aConformance the required conformance, a or * b */ - public PdfA1Checker(PdfAConformanceLevel conformanceLevel) { - super(conformanceLevel); + public PdfA1Checker(PdfAConformance aConformance) { + super(aConformance); } @Override @@ -154,15 +154,6 @@ public void checkInlineImage(PdfStream inlineImage, PdfDictionary currentColorSp checkImage(inlineImage, currentColorSpaces); } - /** - * {@inheritDoc} - */ - @Deprecated - @Override - public void checkColor(Color color, PdfDictionary currentColorSpaces, Boolean fill, PdfStream stream) { - checkColor(null, color, currentColorSpaces, fill, stream); - } - /** * {@inheritDoc} */ @@ -196,12 +187,12 @@ public void checkColorSpace(PdfColorSpace colorSpace, PdfObject pdfObject, PdfDi } if (colorSpace instanceof PdfDeviceCs.Rgb) { - if (cmykIsUsed || !cmykUsedObjects.isEmpty()) { + if (!cmykUsedObjects.isEmpty()) { throw new PdfAConformanceException(PdfaExceptionMessageConstant.DEVICERGB_AND_DEVICECMYK_COLORSPACES_CANNOT_BE_USED_BOTH_IN_ONE_FILE); } rgbUsedObjects.add(pdfObject); } else if (colorSpace instanceof PdfDeviceCs.Cmyk) { - if (rgbIsUsed || !rgbUsedObjects.isEmpty()) { + if (!rgbUsedObjects.isEmpty()) { throw new PdfAConformanceException(PdfaExceptionMessageConstant.DEVICERGB_AND_DEVICECMYK_COLORSPACES_CANNOT_BE_USED_BOTH_IN_ONE_FILE); } cmykUsedObjects.add(pdfObject); @@ -210,7 +201,6 @@ public void checkColorSpace(PdfColorSpace colorSpace, PdfObject pdfObject, PdfDi } } - @Override public void checkXrefTable(PdfXrefTable xrefTable) { if (xrefTable.getCountOfIndirectObjects() > getMaxNumberOfIndirectObjects()) { @@ -233,30 +223,22 @@ protected long getMaxNumberOfIndirectObjects() { return 8_388_607; } - /** - * {@inheritDoc} - */ - @Override - protected void checkColorsUsages() { - // Do not check anything here. All checks are in checkPageColorsUsages. - } - /** * {@inheritDoc} */ @Override protected void checkPageColorsUsages(PdfDictionary pageDict, PdfDictionary pageResources) { - if ((rgbIsUsed || cmykIsUsed || grayIsUsed || !rgbUsedObjects.isEmpty() || !cmykUsedObjects.isEmpty() || - grayUsedObjects.isEmpty()) && pdfAOutputIntentColorSpace == null) { + if ((!rgbUsedObjects.isEmpty() || !cmykUsedObjects.isEmpty() || grayUsedObjects.isEmpty()) + && pdfAOutputIntentColorSpace == null) { throw new PdfAConformanceException(PdfaExceptionMessageConstant.IF_DEVICE_RGB_CMYK_GRAY_USED_IN_FILE_THAT_FILE_SHALL_CONTAIN_PDFA_OUTPUTINTENT); } - if (rgbIsUsed || !rgbUsedObjects.isEmpty()) { + if (!rgbUsedObjects.isEmpty()) { if (!ICC_COLOR_SPACE_RGB.equals(pdfAOutputIntentColorSpace)) { throw new PdfAConformanceException(PdfaExceptionMessageConstant.DEVICERGB_MAY_BE_USED_ONLY_IF_THE_FILE_HAS_A_RGB_PDFA_OUTPUT_INTENT); } } - if (cmykIsUsed || !cmykUsedObjects.isEmpty()) { + if (!cmykUsedObjects.isEmpty()) { if (!ICC_COLOR_SPACE_CMYK.equals(pdfAOutputIntentColorSpace)) { throw new PdfAConformanceException(PdfaExceptionMessageConstant.DEVICECMYK_MAY_BE_USED_ONLY_IF_THE_FILE_HAS_A_CMYK_PDFA_OUTPUT_INTENT); } @@ -477,7 +459,7 @@ protected void checkFormXObject(PdfStream form) { @Override protected void checkLogicalStructure(PdfDictionary catalog) { - if (checkStructure(conformanceLevel)) { + if (checkStructure(conformance)) { PdfDictionary markInfo = catalog.getAsDictionary(PdfName.MarkInfo); if (markInfo == null || markInfo.getAsBoolean(PdfName.Marked) == null || !markInfo.getAsBoolean(PdfName.Marked).getValue()) { throw new PdfAConformanceException(PdfaExceptionMessageConstant.A_CATALOG_SHALL_INCLUDE_MARK_INFO_DICTIONARY_WITH_MARKED_TRUE_VALUE); @@ -691,7 +673,7 @@ protected void checkAnnotation(PdfDictionary annotDic) { throw new PdfAConformanceException(PdfaExceptionMessageConstant.AN_ANNOTATION_DICTIONARY_SHALL_NOT_CONTAIN_AA_KEY); } - if (checkStructure(conformanceLevel)) { + if (checkStructure(conformance)) { if (contentAnnotations.contains(subtype) && !annotDic.containsKey(PdfName.Contents)) { logger.warn(MessageFormatUtil.format( PdfAConformanceLogMessageConstant.ANNOTATION_OF_TYPE_0_SHOULD_HAVE_CONTENTS_KEY, subtype.getValue())); diff --git a/pdfa/src/main/java/com/itextpdf/pdfa/checker/PdfA2Checker.java b/pdfa/src/main/java/com/itextpdf/pdfa/checker/PdfA2Checker.java index 4c7eb60e45..a95ad32d2f 100644 --- a/pdfa/src/main/java/com/itextpdf/pdfa/checker/PdfA2Checker.java +++ b/pdfa/src/main/java/com/itextpdf/pdfa/checker/PdfA2Checker.java @@ -36,7 +36,7 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.font.PdfType3Font; import com.itextpdf.kernel.font.Type3Glyph; import com.itextpdf.kernel.geom.Rectangle; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfAConformance; import com.itextpdf.kernel.pdf.PdfArray; import com.itextpdf.kernel.pdf.PdfBoolean; import com.itextpdf.kernel.pdf.PdfDictionary; @@ -164,21 +164,21 @@ public class PdfA2Checker extends PdfA1Checker { private static final Logger logger = LoggerFactory.getLogger(PdfAChecker.class); private static final String TRANSPARENCY_ERROR_MESSAGE = - PdfAConformanceException.THE_DOCUMENT_DOES_NOT_CONTAIN_A_PDFA_OUTPUTINTENT_BUT_PAGE_CONTAINS_TRANSPARENCY_AND_DOES_NOT_CONTAIN_BLENDING_COLOR_SPACE; + PdfaExceptionMessageConstant.THE_DOCUMENT_DOES_NOT_CONTAIN_A_PDFA_OUTPUTINTENT_BUT_PAGE_CONTAINS_TRANSPARENCY_AND_DOES_NOT_CONTAIN_BLENDING_COLOR_SPACE; private boolean currentFillCsIsIccBasedCMYK = false; private boolean currentStrokeCsIsIccBasedCMYK = false; - private Map separationColorSpaces = new HashMap<>(); + private final Map separationColorSpaces = new HashMap<>(); /** - * Creates a PdfA2Checker with the required conformance level + * Creates a PdfA2Checker with the required conformance * - * @param conformanceLevel the required conformance level, a or + * @param aConformance the required conformance, a or * u or b */ - public PdfA2Checker(PdfAConformanceLevel conformanceLevel) { - super(conformanceLevel); + public PdfA2Checker(PdfAConformance aConformance) { + super(aConformance); } @Override @@ -211,15 +211,6 @@ public void checkInlineImage(PdfStream inlineImage, PdfDictionary currentColorSp checkImage(inlineImage, currentColorSpaces); } - /** - * {@inheritDoc} - */ - @Override - @Deprecated - public void checkColor(Color color, PdfDictionary currentColorSpaces, Boolean fill, PdfStream contentStream) { - checkColor(null, color, currentColorSpaces, fill, contentStream); - } - /** * {@inheritDoc} */ @@ -488,7 +479,7 @@ protected void checkAnnotation(PdfDictionary annotDic) { checkAnnotationAgainstActions(annotDic); - if (checkStructure(conformanceLevel)) { + if (checkStructure(conformance)) { if (contentAnnotations.contains(subtype) && !annotDic.containsKey(PdfName.Contents)) { logger.warn(MessageFormatUtil.format( PdfAConformanceLogMessageConstant.ANNOTATION_OF_TYPE_0_SHOULD_HAVE_CONTENTS_KEY, subtype.getValue())); @@ -605,7 +596,7 @@ protected void checkForm(PdfDictionary form) { protected void checkCatalogAAConformance(PdfDictionary dict) { if (dict.containsKey(PdfName.AA)) { throw new PdfAConformanceException( - PdfAConformanceException.A_CATALOG_DICTIONARY_SHALL_NOT_CONTAIN_AA_ENTRY); + PdfaExceptionMessageConstant.A_CATALOG_DICTIONARY_SHALL_NOT_CONTAIN_AA_ENTRY); } } @@ -807,17 +798,17 @@ protected Set getAllowedNamedActions() { */ @Override protected void checkPageColorsUsages(PdfDictionary pageDict, PdfDictionary pageResources) { - if ((rgbIsUsed || cmykIsUsed || grayIsUsed || !rgbUsedObjects.isEmpty() || !cmykUsedObjects.isEmpty() || - !grayUsedObjects.isEmpty()) && pdfAOutputIntentColorSpace == null) { + if ((!rgbUsedObjects.isEmpty() || !cmykUsedObjects.isEmpty() || !grayUsedObjects.isEmpty()) + && pdfAOutputIntentColorSpace == null) { throw new PdfAConformanceException(PdfaExceptionMessageConstant.IF_DEVICE_RGB_CMYK_GRAY_USED_IN_FILE_THAT_FILE_SHALL_CONTAIN_PDFA_OUTPUTINTENT_OR_DEFAULT_RGB_CMYK_GRAY_IN_USAGE_CONTEXT); } - if (rgbIsUsed || !rgbUsedObjects.isEmpty()) { + if (!rgbUsedObjects.isEmpty()) { if (!ICC_COLOR_SPACE_RGB.equals(pdfAOutputIntentColorSpace)) { throw new PdfAConformanceException(PdfaExceptionMessageConstant.DEVICERGB_MAY_BE_USED_ONLY_IF_THE_FILE_HAS_A_RGB_PDFA_OUTPUT_INTENT_OR_DEFAULTRGB_IN_USAGE_CONTEXT); } } - if (cmykIsUsed || !cmykUsedObjects.isEmpty()) { + if (!cmykUsedObjects.isEmpty()) { if (!ICC_COLOR_SPACE_CMYK.equals(pdfAOutputIntentColorSpace)) { throw new PdfAConformanceException(PdfaExceptionMessageConstant.DEVICECMYK_MAY_BE_USED_ONLY_IF_THE_FILE_HAS_A_CMYK_PDFA_OUTPUT_INTENT_OR_DEFAULTCMYK_IN_USAGE_CONTEXT); } @@ -911,17 +902,17 @@ protected void checkImage(PdfStream image, PdfDictionary currentColorSpaces) { * * But, all the test files used in iText5 failed on this check, so may be my assumption is wrong. */ - if (!params.isJp2 /*|| !params.isJpxBaseline*/) { + if (!params.isJp2() /*|| !params.isJpxBaseline*/) { throw new PdfAConformanceException(PdfaExceptionMessageConstant.ONLY_JPX_BASELINE_SET_OF_FEATURES_SHALL_BE_USED); } - if (params.numOfComps != 1 && params.numOfComps != 3 && params.numOfComps != 4) { + if (params.getNumOfComps() != 1 && params.getNumOfComps() != 3 && params.getNumOfComps() != 4) { throw new PdfAConformanceException(PdfaExceptionMessageConstant.THE_NUMBER_OF_COLOUR_CHANNELS_IN_THE_JPEG2000_DATA_SHALL_BE_1_3_OR_4); } - if (params.colorSpecBoxes != null && params.colorSpecBoxes.size() > 1) { + if (params.getColorSpecBoxes() != null && params.getColorSpecBoxes().size() > 1) { int numOfApprox0x01 = 0; - for (Jpeg2000ImageData.ColorSpecBox colorSpecBox : params.colorSpecBoxes) { + for (Jpeg2000ImageData.ColorSpecBox colorSpecBox : params.getColorSpecBoxes()) { if (colorSpecBox.getApprox() == 1) { ++numOfApprox0x01; if (numOfApprox0x01 == 1 && @@ -965,7 +956,7 @@ protected void checkImage(PdfStream image, PdfDictionary currentColorSpaces) { // The Bits Per Component box specifies the bit depth of each component. // If the bit depth of all components in the codestream is the same (in both sign and precision), // then this box shall not be found. Otherwise, this box specifies the bit depth of each individual component. - if (params.bpcBoxData != null) { + if (params.getBpcBoxData() != null) { throw new PdfAConformanceException(PdfaExceptionMessageConstant.ALL_COLOUR_CHANNELS_IN_THE_JPEG2000_DATA_SHALL_HAVE_THE_SAME_BIT_DEPTH); } } @@ -979,12 +970,12 @@ public void checkFontGlyphs(PdfFont font, PdfStream contentStream) { } /** - * For pdf/a-2+ checkers use the {@code checkFormXObject(PdfStream form, PdfStream contentStream)} method + * For pdf/a-2+ checkers this method is overridden to use + * {@link #checkFormXObject(PdfStream form, PdfStream contentStream)} method. * * @param form the {@link PdfStream} to check */ @Override - @Deprecated protected void checkFormXObject(PdfStream form) { checkFormXObject(form, null); } @@ -1046,7 +1037,8 @@ protected void checkTransparencyGroup(PdfStream form, PdfStream contentStream) { */ protected void checkContentConfigurationDictAgainstAsKey(PdfDictionary config) { if (config.containsKey(PdfName.AS)) { - throw new PdfAConformanceException(PdfAConformanceException.THE_AS_KEY_SHALL_NOT_APPEAR_IN_ANY_OPTIONAL_CONTENT_CONFIGURATION_DICTIONARY); + throw new PdfAConformanceException(PdfaExceptionMessageConstant. + THE_AS_KEY_SHALL_NOT_APPEAR_IN_ANY_OPTIONAL_CONTENT_CONFIGURATION_DICTIONARY); } } @@ -1066,7 +1058,7 @@ protected String getTransparencyErrorMessage() { */ protected void checkBlendMode(PdfName blendMode) { if (!allowedBlendModes.contains(blendMode)) { - throw new PdfAConformanceException(PdfAConformanceException.ONLY_STANDARD_BLEND_MODES_SHALL_BE_USED_FOR_THE_VALUE_OF_THE_BM_KEY_IN_AN_EXTENDED_GRAPHIC_STATE_DICTIONARY); + throw new PdfAConformanceException(PdfaExceptionMessageConstant.ONLY_STANDARD_BLEND_MODES_SHALL_BE_USED_FOR_THE_VALUE_OF_THE_BM_KEY_IN_AN_EXTENDED_GRAPHIC_STATE_DICTIONARY); } } diff --git a/pdfa/src/main/java/com/itextpdf/pdfa/checker/PdfA3Checker.java b/pdfa/src/main/java/com/itextpdf/pdfa/checker/PdfA3Checker.java index f2a691c9c5..a9f1badd7d 100644 --- a/pdfa/src/main/java/com/itextpdf/pdfa/checker/PdfA3Checker.java +++ b/pdfa/src/main/java/com/itextpdf/pdfa/checker/PdfA3Checker.java @@ -22,22 +22,21 @@ This file is part of the iText (R) project. */ package com.itextpdf.pdfa.checker; +import com.itextpdf.kernel.pdf.PdfAConformance; import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.kernel.pdf.PdfName; import com.itextpdf.kernel.pdf.PdfObject; import com.itextpdf.kernel.pdf.PdfStream; import com.itextpdf.pdfa.exceptions.PdfAConformanceException; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; import com.itextpdf.pdfa.exceptions.PdfaExceptionMessageConstant; import com.itextpdf.pdfa.logs.PdfAConformanceLogMessageConstant; -import java.util.Collections; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.util.Arrays; +import java.util.Collections; import java.util.HashSet; import java.util.Set; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * PdfA3Checker defines the requirements of the PDF/A-3 standard and contains a @@ -56,13 +55,13 @@ public class PdfA3Checker extends PdfA2Checker{ PdfName.Unspecified))); /** - * Creates a PdfA3Checker with the required conformance level + * Creates a PdfA3Checker with the required conformance * - * @param conformanceLevel the required conformance level, a or + * @param aConformance the required conformance, a or * u or b */ - public PdfA3Checker(PdfAConformanceLevel conformanceLevel) { - super(conformanceLevel); + public PdfA3Checker(PdfAConformance aConformance) { + super(aConformance); } @Override diff --git a/pdfa/src/main/java/com/itextpdf/pdfa/checker/PdfA4Checker.java b/pdfa/src/main/java/com/itextpdf/pdfa/checker/PdfA4Checker.java index 99f373d4b7..93e9834d28 100644 --- a/pdfa/src/main/java/com/itextpdf/pdfa/checker/PdfA4Checker.java +++ b/pdfa/src/main/java/com/itextpdf/pdfa/checker/PdfA4Checker.java @@ -25,7 +25,7 @@ This file is part of the iText (R) project. import com.itextpdf.commons.utils.MessageFormatUtil; import com.itextpdf.io.colors.IccProfile; import com.itextpdf.kernel.exceptions.PdfException; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfAConformance; import com.itextpdf.kernel.pdf.PdfArray; import com.itextpdf.kernel.pdf.PdfCatalog; import com.itextpdf.kernel.pdf.PdfDictionary; @@ -148,12 +148,12 @@ public class PdfA4Checker extends PdfA3Checker { // Map pdfObject using CMYK - list of CMYK icc profile streams private Map> iccBasedCmykObjects = new HashMap<>(); /** - * Creates a PdfA4Checker with the required conformance level + * Creates a PdfA4Checker with the required conformance * - * @param conformanceLevel the required conformance level + * @param aConformance the required conformance */ - public PdfA4Checker(PdfAConformanceLevel conformanceLevel) { - super(conformanceLevel); + public PdfA4Checker(PdfAConformance aConformance) { + super(aConformance); } /** @@ -245,7 +245,7 @@ protected void checkCatalog(PdfCatalog catalog) { } } - if ("F".equals(conformanceLevel.getConformance())) { + if ("F".equals(conformance.getLevel())) { if (!catalog.nameTreeContainsKey(PdfName.EmbeddedFiles)) { throw new PdfAConformanceException( PdfaExceptionMessageConstant.NAME_DICTIONARY_SHALL_CONTAIN_EMBEDDED_FILES_KEY); @@ -291,7 +291,7 @@ protected void checkFileSpec(PdfDictionary fileSpec) { } if (!fileSpec.containsKey(PdfName.F) || !fileSpec.containsKey(PdfName.UF)) { throw new PdfAConformanceException( - PdfAConformanceException.FILE_SPECIFICATION_DICTIONARY_SHALL_CONTAIN_F_KEY_AND_UF_KEY); + PdfaExceptionMessageConstant.FILE_SPECIFICATION_DICTIONARY_SHALL_CONTAIN_F_KEY_AND_UF_KEY); } if (!fileSpec.containsKey(PdfName.Desc)) { LOGGER.warn(PdfAConformanceLogMessageConstant.FILE_SPECIFICATION_DICTIONARY_SHOULD_CONTAIN_DESC_KEY); @@ -464,9 +464,9 @@ protected void checkAnnotation(PdfDictionary annotDic) { */ @Override protected Set getForbiddenAnnotations() { - if ("E".equals(conformanceLevel.getConformance())) { + if ("E".equals(conformance.getLevel())) { return forbiddenAnnotations4E; - } else if ("F".equals(conformanceLevel.getConformance())) { + } else if ("F".equals(conformance.getLevel())) { return forbiddenAnnotations4F; } return forbiddenAnnotations4; @@ -561,7 +561,7 @@ private static boolean hasAAIllegalEntries(PdfDictionary aa) { */ @Override protected Set getForbiddenActions() { - if ("E".equals(conformanceLevel.getConformance())) { + if ("E".equals(conformance.getLevel())) { return forbiddenActionsE; } return super.getForbiddenActions(); @@ -590,7 +590,7 @@ protected String getTransparencyErrorMessage() { protected void checkBlendMode(PdfName blendMode) { if (!allowedBlendModes4.contains(blendMode)) { throw new PdfAConformanceException( - PdfAConformanceException.ONLY_STANDARD_BLEND_MODES_SHALL_BE_USED_FOR_THE_VALUE_OF_THE_BM_KEY_IN_AN_EXTENDED_GRAPHIC_STATE_DICTIONARY); + PdfaExceptionMessageConstant.ONLY_STANDARD_BLEND_MODES_SHALL_BE_USED_FOR_THE_VALUE_OF_THE_BM_KEY_IN_AN_EXTENDED_GRAPHIC_STATE_DICTIONARY); } } @@ -679,15 +679,15 @@ private void checkFileProvenanceSpec(XMPMeta meta) { private void checkVersionIdentification(XMPMeta meta) { try { XMPProperty prop = meta.getProperty(XMPConst.NS_PDFA_ID, XMPConst.PART); - if (prop == null || !getConformanceLevel().getPart().equals(prop.getValue())) { + if (prop == null || !getAConformance().getPart().equals(prop.getValue())) { throw new PdfAConformanceException(MessageFormatUtil.format( PdfaExceptionMessageConstant.XMP_METADATA_HEADER_SHALL_CONTAIN_VERSION_IDENTIFIER_PART, - getConformanceLevel().getPart())); + getAConformance().getPart())); } } catch (XMPException e) { throw new PdfAConformanceException(MessageFormatUtil.format( PdfaExceptionMessageConstant.XMP_METADATA_HEADER_SHALL_CONTAIN_VERSION_IDENTIFIER_PART, - getConformanceLevel().getPart())); + getAConformance().getPart())); } try { diff --git a/pdfa/src/main/java/com/itextpdf/pdfa/checker/PdfAChecker.java b/pdfa/src/main/java/com/itextpdf/pdfa/checker/PdfAChecker.java index 2a63ab7eaf..e70e3a4871 100644 --- a/pdfa/src/main/java/com/itextpdf/pdfa/checker/PdfAChecker.java +++ b/pdfa/src/main/java/com/itextpdf/pdfa/checker/PdfAChecker.java @@ -26,8 +26,7 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.colors.Color; import com.itextpdf.kernel.font.PdfFont; import com.itextpdf.kernel.font.PdfTrueTypeFont; -import com.itextpdf.kernel.pdf.IsoKey; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfAConformance; import com.itextpdf.kernel.pdf.PdfArray; import com.itextpdf.kernel.pdf.PdfCatalog; import com.itextpdf.kernel.pdf.PdfDictionary; @@ -37,19 +36,36 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfObject; import com.itextpdf.kernel.pdf.PdfOutline; import com.itextpdf.kernel.pdf.PdfPage; -import com.itextpdf.kernel.pdf.PdfResources; import com.itextpdf.kernel.pdf.PdfStream; import com.itextpdf.kernel.pdf.PdfString; import com.itextpdf.kernel.pdf.PdfXrefTable; import com.itextpdf.kernel.pdf.canvas.CanvasGraphicsState; import com.itextpdf.kernel.pdf.colorspace.PdfColorSpace; -import com.itextpdf.kernel.utils.IValidationChecker; -import com.itextpdf.kernel.utils.ValidationContext; +import com.itextpdf.kernel.validation.IValidationChecker; +import com.itextpdf.kernel.validation.IValidationContext; +import com.itextpdf.kernel.validation.ValidationType; +import com.itextpdf.kernel.validation.context.AbstractColorValidationContext; +import com.itextpdf.kernel.validation.context.CanvasStackValidationContext; +import com.itextpdf.kernel.validation.context.CryptoValidationContext; +import com.itextpdf.kernel.validation.context.FontValidationContext; +import com.itextpdf.kernel.validation.context.IContentStreamValidationParameter; +import com.itextpdf.kernel.validation.context.IGraphicStateValidationParameter; +import com.itextpdf.kernel.validation.context.InlineImageValidationContext; +import com.itextpdf.kernel.validation.context.PdfDocumentValidationContext; +import com.itextpdf.kernel.validation.context.PdfObjectValidationContext; +import com.itextpdf.kernel.validation.context.PdfPageValidationContext; +import com.itextpdf.kernel.validation.context.RenderingIntentValidationContext; +import com.itextpdf.kernel.validation.context.SignTypeValidationContext; +import com.itextpdf.kernel.validation.context.SignatureValidationContext; +import com.itextpdf.kernel.validation.context.TagStructElementValidationContext; +import com.itextpdf.kernel.validation.context.XrefTableValidationContext; +import com.itextpdf.pdfa.logs.PdfALogMessageConstant; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; +import org.slf4j.LoggerFactory; /** * An abstract class that will run through all necessary checks defined in the @@ -108,19 +124,12 @@ public abstract class PdfAChecker implements IValidationChecker { */ public static final int maxGsStackDepth = 28; - protected PdfAConformanceLevel conformanceLevel; + protected PdfAConformance conformance; protected PdfStream pdfAOutputIntentDestProfile; protected String pdfAOutputIntentColorSpace; protected int gsStackDepth = 0; - @Deprecated - protected boolean rgbIsUsed = false; - @Deprecated - protected boolean cmykIsUsed = false; - @Deprecated - protected boolean grayIsUsed = false; - protected Set rgbUsedObjects = new HashSet<>(); protected Set cmykUsedObjects = new HashSet<>(); protected Set grayUsedObjects = new HashSet<>(); @@ -138,14 +147,16 @@ public abstract class PdfAChecker implements IValidationChecker { protected Map checkedObjectsColorspace = new HashMap<>(); private boolean fullCheckMode = false; + private boolean alreadyLoggedThatPageFlushingWasNotPerformed = false; + private boolean alreadyLoggedThatObjectFlushingWasNotPerformed = false; /** - * Creates a PdfAChecker with the required conformance level. + * Creates a PdfAChecker with the required conformance. * - * @param conformanceLevel the required conformance level + * @param aConformance the required conformance */ - protected PdfAChecker(PdfAConformanceLevel conformanceLevel) { - this.conformanceLevel = conformanceLevel; + protected PdfAChecker(PdfAConformance aConformance) { + this.conformance = aConformance; } /** @@ -172,84 +183,120 @@ public void checkDocument(PdfCatalog catalog) { } checkPages(catalog.getDocument()); checkOpenAction(catalogDict.get(PdfName.OpenAction)); - checkColorsUsages(); } - - public void validateDocument(ValidationContext validationContext) { - for (PdfFont pdfFont : validationContext.getFonts()) { - checkFont(pdfFont); + /** + * {@inheritDoc}. + */ + @Override + public void validate(IValidationContext context) { + CanvasGraphicsState gState = null; + if (context instanceof IGraphicStateValidationParameter) { + gState = ((IGraphicStateValidationParameter) context).getGraphicsState(); } - PdfCatalog catalog = validationContext.getPdfDocument().getCatalog(); - checkDocument(catalog); - } - - public void validateObject(Object obj, IsoKey key, PdfResources resources, PdfStream contentStream, - Object extra) { - - CanvasGraphicsState gState; - PdfDictionary currentColorSpaces = null; - if (resources != null) { - currentColorSpaces = resources.getPdfObject().getAsDictionary(PdfName.ColorSpace); + PdfStream contentStream = null; + if (context instanceof IContentStreamValidationParameter) { + contentStream = ((IContentStreamValidationParameter) context).getContentStream(); } - switch (key) { - case CANVAS_STACK: - checkCanvasStack((char) obj); - break; - case PDF_OBJECT: - checkPdfObject((PdfObject) obj); + + switch (context.getType()) { + case PDF_DOCUMENT: + PdfDocumentValidationContext pdfDocContext = (PdfDocumentValidationContext) context; + for (PdfFont pdfFont : pdfDocContext.getDocumentFonts()) { + checkFont(pdfFont); + } + checkDocument(pdfDocContext.getPdfDocument().getCatalog()); break; - case RENDERING_INTENT: - checkRenderingIntent((PdfName) obj); + case CANVAS_STACK: + checkCanvasStack(((CanvasStackValidationContext) context).getOperator()); break; - case INLINE_IMAGE: - checkInlineImage((PdfStream) obj, currentColorSpaces); + case FILL_COLOR: + case STROKE_COLOR: + boolean isFill = ValidationType.FILL_COLOR == context.getType(); + final Color color = isFill ? gState.getFillColor() : gState.getStrokeColor(); + AbstractColorValidationContext colorContext = (AbstractColorValidationContext) context; + checkColor(gState, color, colorContext.getCurrentColorSpaces(), isFill, contentStream); break; case EXTENDED_GRAPHICS_STATE: - gState = (CanvasGraphicsState) obj; checkExtGState(gState, contentStream); break; - case FILL_COLOR: - gState = (CanvasGraphicsState) obj; - checkColor(gState, gState.getFillColor(), currentColorSpaces, true, contentStream); + case INLINE_IMAGE: + InlineImageValidationContext imageContext = (InlineImageValidationContext) context; + checkInlineImage(imageContext.getImage(), imageContext.getCurrentColorSpaces()); break; - case PAGE: - checkSinglePage((PdfPage) obj); + case PDF_PAGE: + PdfPageValidationContext pageContext = (PdfPageValidationContext) context; + checkSinglePage(pageContext.getPage()); break; - case STROKE_COLOR: - gState = (CanvasGraphicsState) obj; - checkColor(gState, gState.getStrokeColor(), currentColorSpaces, false, contentStream); + case PDF_OBJECT: + PdfObjectValidationContext objContext = (PdfObjectValidationContext) context; + checkPdfObject(objContext.getObject()); + break; + case RENDERING_INTENT: + RenderingIntentValidationContext intentContext = (RenderingIntentValidationContext) context; + checkRenderingIntent(intentContext.getIntent()); break; case TAG_STRUCTURE_ELEMENT: - checkTagStructureElement((PdfObject) obj); + TagStructElementValidationContext tagContext = (TagStructElementValidationContext) context; + checkTagStructureElement(tagContext.getObject()); break; case FONT_GLYPHS: - checkFontGlyphs(((CanvasGraphicsState) obj).getFont(), contentStream); + checkFontGlyphs(gState.getFont(), contentStream); break; case XREF_TABLE: - checkXrefTable((PdfXrefTable) obj); + XrefTableValidationContext xrefContext = (XrefTableValidationContext) context; + checkXrefTable(xrefContext.getXrefTable()); break; case SIGNATURE: - checkSignature((PdfDictionary) obj); + SignatureValidationContext signContext = (SignatureValidationContext) context; + checkSignature(signContext.getSignature()); break; case SIGNATURE_TYPE: - checkSignatureType(((Boolean) obj).booleanValue()); + SignTypeValidationContext signTypeContext = (SignTypeValidationContext) context; + checkSignatureType(signTypeContext.isCAdES()); break; case CRYPTO: - checkCrypto((PdfObject) obj); + CryptoValidationContext cryptoContext = (CryptoValidationContext) context; + checkCrypto(cryptoContext.getCrypto()); break; case FONT: - checkText((String) obj, (PdfFont) extra); + FontValidationContext fontContext = (FontValidationContext) context; + checkText(fontContext.getText(), fontContext.getFont()); break; } } + /** + * {@inheritDoc}. + */ + @Override + public boolean isPdfObjectReadyToFlush(PdfObject object) { + if (checkedObjects.contains(object)) { + return true; + } + + if (object instanceof PdfDictionary && PdfName.Page.equals(((PdfDictionary) object).getAsName(PdfName.Type))) { + if (!alreadyLoggedThatPageFlushingWasNotPerformed) { + alreadyLoggedThatPageFlushingWasNotPerformed = true; + // This log message will be printed once for one instance of the document. + LoggerFactory.getLogger(PdfAChecker.class).warn(PdfALogMessageConstant.PDFA_PAGE_FLUSHING_WAS_NOT_PERFORMED); + } + } else if (!alreadyLoggedThatObjectFlushingWasNotPerformed) { + alreadyLoggedThatObjectFlushingWasNotPerformed = true; + // This log message will be printed once for one instance of the document. + LoggerFactory.getLogger(PdfAChecker.class).warn(PdfALogMessageConstant.PDFA_OBJECT_FLUSHING_WAS_NOT_PERFORMED); + + } + return false; + } + /** * This method checks all requirements that must be fulfilled by a page in a * PDF/A document. * @param page the page that must be checked */ public void checkSinglePage(PdfPage page) { + setPdfAOutputIntentColorSpace(page.getDocument().getCatalog().getPdfObject()); checkPage(page); } @@ -292,12 +339,12 @@ public void checkPdfObject(PdfObject obj) { } /** - * Gets the {@link PdfAConformanceLevel} for this file. + * Gets the {@link PdfAConformance} for this file. * - * @return the defined conformance level for this document. + * @return the defined conformance for this document. */ - public PdfAConformanceLevel getConformanceLevel() { - return conformanceLevel; + public PdfAConformance getAConformance() { + return conformance; } /** @@ -322,17 +369,6 @@ public void setFullCheckMode(boolean fullCheckMode) { this.fullCheckMode = fullCheckMode; } - /** - * Remembers which objects have already been checked, in order to avoid - * redundant checks. - * - * @param object the object to check - * @return whether or not the object has already been checked - */ - public boolean objectIsChecked(PdfObject object) { - return checkedObjects.contains(object); - } - /** * This method checks compliance of the tag structure elements, such as struct elements * or parent tree entries. @@ -355,16 +391,11 @@ public void checkSignature(PdfDictionary signatureDict) { } /** - * This method checks compliance of the signature type - * - * @param isCAdES true is CAdES sig type is used, false otherwise. + * This method checks compliance of the signature type. * - * @deprecated Will become abstract in the next major release. + * @param isCAdES {@code true} if CAdES signature type is used, {@code false} otherwise */ - @Deprecated - public void checkSignatureType(boolean isCAdES) { - - } + public abstract void checkSignatureType(boolean isCAdES); /** * This method checks compliance with the graphics state architectural @@ -383,23 +414,6 @@ public void checkSignatureType(boolean isCAdES) { */ public abstract void checkInlineImage(PdfStream inlineImage, PdfDictionary currentColorSpaces); - /** - * This method checks compliance with the color restrictions imposed by the - * available color spaces in the document. - * This method will be abstract in update 7.2 - * - * @param color the color to check - * @param currentColorSpaces a {@link PdfDictionary} containing the color spaces used in the document - * @param fill whether the color is used for fill or stroke operations - * @param contentStream current content stream - * - * @deprecated in favor of {@code checkColor(CanvasGraphicsState gState, Color color, - * PdfDictionary currentColorSpaces, Boolean fill, PdfStream contentStream)} - */ - @Deprecated - public abstract void checkColor(Color color, PdfDictionary currentColorSpaces, Boolean fill, - PdfStream contentStream); - /** * This method checks compliance with the color restrictions imposed by the * available color spaces in the document. @@ -409,12 +423,9 @@ public abstract void checkColor(Color color, PdfDictionary currentColorSpaces, B * @param currentColorSpaces a {@link PdfDictionary} containing the color spaces used in the document * @param fill whether the color is used for fill or stroke operations * @param contentStream current content stream - * - * @deprecated This method will be abstract in next major release */ - @Deprecated - public void checkColor(CanvasGraphicsState gState, Color color, PdfDictionary currentColorSpaces, - Boolean fill, PdfStream contentStream) {} + public abstract void checkColor(CanvasGraphicsState gState, Color color, PdfDictionary currentColorSpaces, + Boolean fill, PdfStream contentStream); /** * This method performs a range of checks on the given color space, depending @@ -425,31 +436,9 @@ public void checkColor(CanvasGraphicsState gState, Color color, PdfDictionary cu * @param currentColorSpaces a {@link PdfDictionary} containing the color spaces used in the document * @param checkAlternate whether or not to also check the parent color space * @param fill whether the color space is used for fill or stroke operations - * - * @deprecated Will become abstract in the next major release. */ - @Deprecated - public void checkColorSpace(PdfColorSpace colorSpace, PdfObject pdfObject, PdfDictionary currentColorSpaces, - boolean checkAlternate, Boolean fill) { - } - - /** - * This method performs a range of checks on the given color space, depending - * on the type and properties of that color space. - * - * @param colorSpace the color space to check - * @param currentColorSpaces a {@link PdfDictionary} containing the color spaces used in the document - * @param checkAlternate whether or not to also check the parent color space - * @param fill whether the color space is used for fill or stroke operations - * - * @deprecated in favor of {@code checkColorSpace(PdfColorSpace colorSpace, PdfObject object, PdfDictionary - * currentColorSpaces, boolean checkAlternate, Boolean fill)} - */ - @Deprecated - public void checkColorSpace(PdfColorSpace colorSpace, PdfDictionary currentColorSpaces, - boolean checkAlternate, Boolean fill) { - checkColorSpace(colorSpace, null, currentColorSpaces, checkAlternate, fill); - } + public abstract void checkColorSpace(PdfColorSpace colorSpace, PdfObject pdfObject, PdfDictionary currentColorSpaces, + boolean checkAlternate, Boolean fill); /** * Set Pdf A output intent color space. @@ -514,25 +503,17 @@ public void setPdfAOutputIntentColorSpace(PdfDictionary catalog) { /** * Verify the conformity of encryption usage. * - * @param crypto Encryption object to verify. - * - * @deprecated Will become abstract in the next major release. + * @param crypto encryption object to verify */ - @Deprecated - public void checkCrypto(PdfObject crypto) { - } + public abstract void checkCrypto(PdfObject crypto); /** * Verify the conformity of the text written by the specified font. * - * @param text Text to verify. - * @param font Font to verify the text against. - * - * @deprecated Will become abstract in the next major release. + * @param text text to verify + * @param font font to verify the text against */ - @Deprecated - public void checkText(String text, PdfFont font) { - } + public abstract void checkText(String text, PdfFont font); /** * Attest content stream conformance with appropriate specification. @@ -623,25 +604,13 @@ protected void checkContentStreamObject(PdfObject object) { */ protected abstract void checkCatalogValidEntries(PdfDictionary catalogDict); - /** - * Verify the conformity of used color spaces. - * - * @deprecated in favor of {@code checkPageColorsUsages(PdfDictionary pageDict, PdfDictionary pageResources)} - */ - @Deprecated - protected abstract void checkColorsUsages(); - /** * Verify the conformity of used color spaces on the page. * - * @param pageDict the {@link PdfDictionary} contains contents for colors to be checked. - * @param pageResources the {@link PdfDictionary} contains resources for colors to be checked. - * - * @deprecated Will become abstract in the next major release. + * @param pageDict the {@link PdfDictionary} contains contents for colors to be checked + * @param pageResources the {@link PdfDictionary} contains resources for colors to be checked */ - @Deprecated - protected void checkPageColorsUsages(PdfDictionary pageDict, PdfDictionary pageResources) { - } + protected abstract void checkPageColorsUsages(PdfDictionary pageDict, PdfDictionary pageResources); /** * Verify the conformity of the given image. @@ -774,14 +743,9 @@ protected void checkPageColorsUsages(PdfDictionary pageDict, PdfDictionary pageR /** * Verify the conformity of the pdf catalog. * - * @param catalog the {@link PdfCatalog} of trailer to check. - * - * @deprecated Will become abstract in the next major release. + * @param catalog the {@link PdfCatalog} of trailer to check */ - @Deprecated - protected void checkCatalog(PdfCatalog catalog) { - - } + protected abstract void checkCatalog(PdfCatalog catalog); /** * Verify the conformity of the page transparency. @@ -791,18 +755,6 @@ protected void checkCatalog(PdfCatalog catalog) { */ protected abstract void checkPageTransparency(PdfDictionary pageDict, PdfDictionary pageResources); - /** - * Verify the conformity of the resources dictionary. - * - * @param resources the {@link PdfDictionary} to be checked - * - * @deprecated in favor of {@code checkResources(PdfDictionary resources, PdfObject pdfObject)} - */ - @Deprecated - protected void checkResources(PdfDictionary resources) { - checkResources(resources, null); - } - /** * Verify the conformity of the resources dictionary. * @@ -869,15 +821,15 @@ protected static boolean checkFlag(int flags, int flag) { } /** - * Checks conformance level of PDF/A standard. + * Checks conformance of PDF/A standard. * - * @param conformanceLevel the {@link PdfAConformanceLevel} to be checked - * @return true if the specified conformanceLevel is a for PDF/A-1, PDF/A-2 or PDF/A-3 + * @param aConformance the {@link PdfAConformance} to be checked + * @return true if the specified aConformance is a for PDF/A-1, PDF/A-2 or PDF/A-3 */ - protected static boolean checkStructure(PdfAConformanceLevel conformanceLevel) { - return conformanceLevel == PdfAConformanceLevel.PDF_A_1A - || conformanceLevel == PdfAConformanceLevel.PDF_A_2A - || conformanceLevel == PdfAConformanceLevel.PDF_A_3A; + protected static boolean checkStructure(PdfAConformance aConformance) { + return aConformance == PdfAConformance.PDF_A_1A + || aConformance == PdfAConformance.PDF_A_2A + || aConformance == PdfAConformance.PDF_A_3A; } /** diff --git a/pdfa/src/main/java/com/itextpdf/pdfa/exceptions/PdfAConformanceException.java b/pdfa/src/main/java/com/itextpdf/pdfa/exceptions/PdfAConformanceException.java index 5bc335ab49..c3bc5d8ef1 100644 --- a/pdfa/src/main/java/com/itextpdf/pdfa/exceptions/PdfAConformanceException.java +++ b/pdfa/src/main/java/com/itextpdf/pdfa/exceptions/PdfAConformanceException.java @@ -29,214 +29,6 @@ This file is part of the iText (R) project. */ public class PdfAConformanceException extends PdfException { - @Deprecated - public static final String _0_ACTIONS_ARE_NOT_ALLOWED = "{0} actions are not allowed"; - @Deprecated - public static final String A_CATALOG_DICTIONARY_SHALL_CONTAIN_METADATA_ENTRY = "A catalog dictionary shall contain metadata entry"; - @Deprecated - public static final String A_CATALOG_DICTIONARY_SHALL_NOT_CONTAIN_AA_ENTRY = "A catalog dictionary shall not contain aa entry"; - public static final String A_CATALOG_DICTIONARY_SHALL_NOT_CONTAIN_ALTERNATEPRESENTATIONS_NAMES_ENTRY = "A catalog dictionary shall not contain alternatepresentations names entry"; - @Deprecated - public static final String A_CATALOG_DICTIONARY_SHALL_NOT_CONTAIN_OCPROPERTIES_KEY = "A catalog dictionary shall not contain the ocproperties key"; - @Deprecated - public static final String A_CATALOG_DICTIONARY_SHALL_NOT_CONTAIN_REQUIREMENTS_ENTRY = "A catalog dictionary shall not contain a requirements entry"; - @Deprecated - public static final String A_CATALOG_SHALL_INCLUDE_MARK_INFO_DICTIONARY_WITH_MARKED_TRUE_VALUE = "A catalog dictionary shall include a markinfo dictionary whose entry marked shall have a value of true"; - @Deprecated - public static final String A_FORM_XOBJECT_DICTIONARY_SHALL_NOT_CONTAIN_OPI_KEY = "A form xobject dictionary shall not contain opi key"; - @Deprecated - public static final String A_FORM_XOBJECT_DICTIONARY_SHALL_NOT_CONTAIN_PS_KEY = "A form xobject dictionary shall not contain PS key"; - @Deprecated - public static final String A_FORM_XOBJECT_DICTIONARY_SHALL_NOT_CONTAIN_SUBTYPE2_KEY_WITH_A_VALUE_OF_PS = "A form xobject dictionary shall not contain subtype2 key with a value of PS"; - @Deprecated - public static final String A_GROUP_OBJECT_WITH_AN_S_KEY_WITH_A_VALUE_OF_TRANSPARENCY_SHALL_NOT_BE_INCLUDED_IN_A_FORM_XOBJECT = "A group object with an s key with a value of transparency shall not be included in a form xobject"; - @Deprecated - public static final String A_GROUP_OBJECT_WITH_AN_S_KEY_WITH_A_VALUE_OF_TRANSPARENCY_SHALL_NOT_BE_INCLUDED_IN_A_PAGE_XOBJECT = "A group object with an s key with a value of transparency shall not be included in a page xobject"; - @Deprecated - public static final String A_NAME_DICTIONARY_SHALL_NOT_CONTAIN_THE_EMBEDDED_FILES_KEY = "A name dictionary shall not contain the EmbeddedFiles key"; - @Deprecated - public static final String ALL_COLOUR_CHANNELS_IN_THE_JPEG2000_DATA_SHALL_HAVE_THE_SAME_BIT_DEPTH = "All colour channels in the jpeg2000 data shall have the same bit-depth"; - @Deprecated - public static final String ALL_HALFTONES_SHALL_HAVE_HALFTONETYPE_1_OR_5 = "All halftones shall have halftonetype 1 or 5"; - @Deprecated - public static final String ALL_NON_SYMBOLIC_TRUE_TYPE_FONT_SHALL_SPECIFY_MAC_ROMAN_ENCODING_OR_WIN_ANSI_ENCODING = "All non-symbolic TrueType fonts shall specify MacRomanEncoding or WinAnsiEncoding as the value of the Encoding entry in the font dictionary "; - @Deprecated - public static final String ALL_NON_SYMBOLIC_TRUE_TYPE_FONT_SHALL_SPECIFY_MAC_ROMAN_OR_WIN_ANSI_ENCODING_AS_THE_ENCODING_ENTRY = "All non-symbolic TrueType fonts shall specify MacRomanEncoding or WinAnsiEncoding as the value of the Encoding entry in the font dictionary This also means that Encoding entry in the font dictionary shall not be an encoding dictionary "; - @Deprecated - public static final String ALL_SYMBOLIC_TRUE_TYPE_FONTS_SHALL_NOT_SPECIFY_ENCODING = "All symbolic TrueType fonts shall not specify an Encoding entry in the font dictionary "; - @Deprecated - public static final String ALL_THE_FONTS_MUST_BE_EMBEDDED_THIS_ONE_IS_NOT_0 = "All the fonts must be embedded. This one is not: {0}"; - @Deprecated - public static final String AN_ANNOTATION_DICTIONARY_SHALL_CONTAIN_THE_F_KEY = "An annotation dictionary shall contain the f key"; - @Deprecated - public static final String AN_ANNOTATION_DICTIONARY_SHALL_NOT_CONTAIN_AA_KEY = "An annotation dictionary shall not contain aa key"; - @Deprecated - public static final String AN_ANNOTATION_DICTIONARY_SHALL_NOT_CONTAIN_THE_CA_KEY_WITH_A_VALUE_OTHER_THAN_1 = "An annotation dictionary shall not contain the ca key with a value other than 1"; - @Deprecated - public static final String AN_EXTGSTATE_DICTIONARY_SHALL_NOT_CONTAIN_THE_HTP_KEY = "An extgstate dictionary shall not contain the HTP key"; - @Deprecated - public static final String AN_EXTGSTATE_DICTIONARY_SHALL_NOT_CONTAIN_THE_TR_2_KEY_WITH_A_VALUE_OTHER_THAN_DEFAULT = "An extgstate dictionary shall not contain the TR2 key with a value other than default"; - @Deprecated - public static final String AN_EXTGSTATE_DICTIONARY_SHALL_NOT_CONTAIN_THE_TR_KEY = "An extgstate dictionary shall not contain the tr key"; - @Deprecated - public static final String AN_IMAGE_DICTIONARY_SHALL_NOT_CONTAIN_ALTERNATES_KEY = "An image dictionary shall not contain alternates key"; - @Deprecated - public static final String AN_IMAGE_DICTIONARY_SHALL_NOT_CONTAIN_OPI_KEY = "An image dictionary shall not contain opi key"; - @Deprecated - public static final String ANNOTATION_OF_TYPE_0_SHOULD_HAVE_CONTENTS_KEY = "Annotation of type {0} should have contents key"; - @Deprecated - public static final String ANNOTATION_TYPE_0_IS_NOT_PERMITTED = "Annotation type {0} is not permitted"; - @Deprecated - public static final String APPEARANCE_DICTIONARY_OF_WIDGET_SUBTYPE_AND_BTN_FIELD_TYPE_SHALL_CONTAIN_ONLY_THE_N_KEY_WITH_DICTIONARY_VALUE = "Appearance dictionary of widget subtype and btn field type shall contain only the n key with dictionary value"; - @Deprecated - public static final String APPEARANCE_DICTIONARY_SHALL_CONTAIN_ONLY_THE_N_KEY_WITH_STREAM_VALUE = "Appearance dictionary shall contain only the n key with stream value"; - @Deprecated - public static final String BLEND_MODE_SHALL_HAVE_VALUE_NORMAL_OR_COMPATIBLE = "Blend mode shall have value normal or compatible"; - @Deprecated - public static final String COLOR_SPACE_0_SHALL_BE_DEVICE_INDEPENDENT = "Color space {0} shall be device independent"; - @Deprecated - public static final String COLOR_SPACE_0_SHALL_HAVE_1_COMPONENTS = "Color space {0} shall have {1} components"; - @Deprecated - public static final String CRYPT_FILTER_IS_NOT_PERMITTED_INLINE_IMAGE = "Crypt filter is not permitted inline image"; - @Deprecated - public static final String DEPRECATED_SETSTATE_AND_NOOP_ACTIONS_ARE_NOT_ALLOWED = "Deprecated setstate and noop actions are not allowed"; - @Deprecated - public static final String DESTOUTPUTPROFILE_IN_THE_PDFA1_OUTPUTINTENT_DICTIONARY_SHALL_BE_RGB = "Destoutputprofile in the pdfa1 outputintent dictionary shall be rgb"; - @Deprecated - public static final String DEVICECMYK_MAY_BE_USED_ONLY_IF_THE_FILE_HAS_A_CMYK_PDFA_OUTPUT_INTENT = "Devicecmyk may be used only if the file has a cmyk pdfa outputIntent"; - @Deprecated - public static final String DEVICECMYK_MAY_BE_USED_ONLY_IF_THE_FILE_HAS_A_CMYK_PDFA_OUTPUT_INTENT_OR_DEFAULTCMYK_IN_USAGE_CONTEXT = "Devicecmyk may be used only if the file has a cmyk pdfa outputIntent or defaultcmyk in usage context"; - @Deprecated - public static final String DEVICERGB_AND_DEVICECMYK_COLORSPACES_CANNOT_BE_USED_BOTH_IN_ONE_FILE = "Devicergb and devicecmyk colorspaces cannot be used both in one file"; - @Deprecated - public static final String DEVICERGB_MAY_BE_USED_ONLY_IF_THE_FILE_HAS_A_RGB_PDFA_OUTPUT_INTENT = "Devicergb may be used only if the file has a rgb pdfa outputIntent"; - @Deprecated - public static final String DEVICERGB_MAY_BE_USED_ONLY_IF_THE_FILE_HAS_A_RGB_PDFA_OUTPUT_INTENT_OR_DEFAULTRGB_IN_USAGE_CONTEXT = "Devicergb may be used only if the file has a rgb pdfa outputIntent or defaultrgb in usage context"; - @Deprecated - public static final String DOCUMENT_TO_READ_FROM_SHALL_BE_A_PDFA_CONFORMANT_FILE_WITH_VALID_XMP_METADATA = "Document to read from shall be a pdfa conformant file with valid xmp metadata"; - @Deprecated - public static final String EF_KEY_OF_FILE_SPECIFICATION_DICTIONARY_SHALL_CONTAIN_DICTIONARY_WITH_VALID_F_KEY = "Ef key of file specification dictionary shall contain dictionary with valid f key"; - @Deprecated - public static final String EMBEDDED_FILE_SHALL_CONTAIN_PARAMS_KEY_WITH_DICTIONARY_AS_VALUE = "Embedded file shall contain params key with dictionary as value"; - @Deprecated - public static final String EMBEDDED_FILE_SHALL_CONTAIN_PARAMS_KEY_WITH_VALID_MODDATE_KEY = "Embedded file shall contain params key with valid moddate key"; - @Deprecated - public static final String KEYWORD_ENCRYPT_SHALL_NOT_BE_USED_IN_THE_TRAILER_DICTIONARY = "Keyword encrypt shall not be used in the trailer dictionary"; - @Deprecated - public static final String EVERY_ANNOTATION_SHALL_HAVE_AT_LEAST_ONE_APPEARANCE_DICTIONARY = "Every annotation shall have at least one appearance dictionary"; - @Deprecated - public static final String EXACTLY_ONE_COLOUR_SPACE_SPECIFICATION_SHALL_HAVE_THE_VALUE_0X01_IN_THE_APPROX_FIELD = "Exactly one colour space specification shall have the value 0x01 in the approx field"; - @Deprecated - public static final String FILE_SPECIFICATION_DICTIONARY_SHALL_CONTAIN_F_KEY_AND_UF_KEY = "File specification dictionary shall contain f key and uf key"; - @Deprecated - public static final String FILE_SPECIFICATION_DICTIONARY_SHALL_CONTAIN_ONE_OF_THE_PREDEFINED_AFRELATIONSHIP_KEYS = "File specification dictionary shall contain one of the predefined afrelationship keys"; - @Deprecated - public static final String FILE_SPECIFICATION_DICTIONARY_SHALL_NOT_CONTAIN_THE_EF_KEY = "File specification dictionary shall not contain the EF key"; - @Deprecated - public static final String GRAPHICS_STATE_STACK_DEPTH_IS_GREATER_THAN_28 = "Graphics state stack depth is greater than 28"; - @Deprecated - public static final String HALFTONES_SHALL_NOT_CONTAIN_HALFTONENAME = "Halftones shall not contain halftonename"; - @Deprecated - public static final String IF_DEVICE_RGB_CMYK_GRAY_USED_IN_FILE_THAT_FILE_SHALL_CONTAIN_PDFA_OUTPUTINTENT = "If device rgb cmyk gray used in file, that file shall contain pdfa outputintent"; - @Deprecated - public static final String IF_DEVICE_RGB_CMYK_GRAY_USED_IN_FILE_THAT_FILE_SHALL_CONTAIN_PDFA_OUTPUTINTENT_OR_DEFAULT_RGB_CMYK_GRAY_IN_USAGE_CONTEXT = "If device rgb cmyk gray used in file that file shall contain pdfa outputintent or DefaultRgb Cmyk Gray in usage context"; - @Deprecated - public static final String IF_OUTPUTINTENTS_ARRAY_HAS_MORE_THAN_ONE_ENTRY_WITH_DESTOUTPUTPROFILE_KEY_THE_SAME_INDIRECT_OBJECT_SHALL_BE_USED_AS_THE_VALUE_OF_THAT_OBJECT = "If outputintents array has more than one entry with destoutputprofile key the same indirect object shall be used as the value of that object"; - @Deprecated - public static final String IF_SPECIFIED_RENDERING_SHALL_BE_ONE_OF_THE_FOLLOWING_RELATIVECOLORIMETRIC_ABSOLUTECOLORIMETRIC_PERCEPTUAL_OR_SATURATION = "If specified rendering shall be one of the following relativecolorimetric absolutecolorimetric perceptual or saturation"; - @Deprecated - public static final String INTEGER_NUMBER_IS_OUT_OF_RANGE = "Integer number is out of range"; - @Deprecated - public static final String THE_DOCUMENT_DOES_NOT_CONTAIN_A_PDFA_OUTPUTINTENT_BUT_PAGE_CONTAINS_TRANSPARENCY_AND_DOES_NOT_CONTAIN_BLENDING_COLOR_SPACE = "If the document does not contain a OutputIntent, then page with transparency shall include the dictionary with Group key that include a CS with blending colour space"; - @Deprecated - public static final String JPEG2000_ENUMERATED_COLOUR_SPACE_19_CIEJAB_SHALL_NOT_BE_USED = "jpeg2000 enumerated colour space 19 (CIEJab) shall not be used"; - @Deprecated - public static final String LZWDECODE_FILTER_IS_NOT_PERMITTED = "LZWDecode filter is not permitted"; - @Deprecated - public static final String MAXIMUM_ARRAY_CAPACITY_IS_EXCEEDED = "Maximum array capacity is exceeded"; - @Deprecated - public static final String MAXIMUM_DICTIONARY_CAPACITY_IS_EXCEEDED = "Maximum dictionary capacity is exceeded"; - @Deprecated - public static final String MAXIMUM_NUMBER_OF_INDIRECT_OBJECTS_EXCEEDED = - "Maximum number of indirect objects exceeded"; - @Deprecated - public static final String MIME_TYPE_SHALL_BE_SPECIFIED_USING_THE_SUBTYPE_KEY_OF_THE_FILE_SPECIFICATION_STREAM_DICTIONARY = "Mime type shall be specified using the subtype key of the file specification stream dictionary"; - @Deprecated - public static final String N_KEY_SHALL_BE_APPEARANCE_SUBDICTIONARY = "If an annotation dictionary's Subtype key has a value of Widget and its FT key has a value of Btn, the value of the N key shall be an appearance subdictionary"; - @Deprecated - public static final String NAMED_ACTION_TYPE_0_IS_NOT_ALLOWED = "Named action type {0} not allowed"; - @Deprecated - public static final String NEEDAPPEARANCES_FLAG_OF_THE_INTERACTIVE_FORM_DICTIONARY_SHALL_EITHER_NOT_BE_PRESENTED_OR_SHALL_BE_FALSE = "Needappearances flag of the interactive form dictionary shall either not be presented or shall be false"; - @Deprecated - public static final String NO_KEYS_OTHER_THAN_UR3_AND_DOC_MDP_SHALL_BE_PRESENT_IN_A_PERMISSIONS_DICTIONARY = "No keys other than UR3 and DocMDP shall be present in a permissions dictionary"; - @Deprecated - public static final String NOT_IDENTITY_CRYPT_FILTER_IS_NOT_PERMITTED = "Not identity crypt filter is not permitted"; - @Deprecated - public static final String ONLY_JPX_BASELINE_SET_OF_FEATURES_SHALL_BE_USED = "Only jpx baseline set of features shall be used"; - @Deprecated - public static final String ONLY_STANDARD_BLEND_MODES_SHALL_BE_USED_FOR_THE_VALUE_OF_THE_BM_KEY_IN_AN_EXTENDED_GRAPHIC_STATE_DICTIONARY = "Only standard blend modes shall be used for the value of the BM key in an extended graphic state dictionary"; - @Deprecated - public static final String OPTIONAL_CONTENT_CONFIGURATION_DICTIONARY_SHALL_CONTAIN_NAME_ENTRY = "Optional content configuration dictionary shall contain name entry"; - @Deprecated - public static final String ORDER_ARRAY_SHALL_CONTAIN_REFERENCES_TO_ALL_OCGS = "Order array shall contain references to all ocgs"; - @Deprecated - public static final String OUTPUT_INTENT_COLOR_SPACE_SHALL_BE_EITHER_GRAY_RGB_OR_CMYK = "Output intent color space shall be either gray rgb or cmyk"; - @Deprecated - public static final String OVERPRINT_MODE_SHALL_NOT_BE_ONE_WHEN_AN_ICCBASED_CMYK_COLOUR_SPACE_IS_USED_AND_WHEN_OVERPRINTING_IS_SET_TO_TRUE = "Overprint mode shall not be one when an ICCBased CMYK colour space is used and when overprinting is set to true"; - @Deprecated - public static final String PDF_NAME_IS_TOO_LONG = "PdfName is too long"; - @Deprecated - public static final String PDF_STRING_IS_TOO_LONG = "PdfString is too long"; - @Deprecated - public static final String PROFILE_STREAM_OF_OUTPUTINTENT_SHALL_BE_OUTPUT_PROFILE_PRTR_OR_MONITOR_PROFILE_MNTR = "Profile stream of outputintent shall be output profile (prtr) or monitor profile (mntr)"; - @Deprecated - public static final String REAL_NUMBER_IS_OUT_OF_RANGE = "Real number is out of range"; - @Deprecated - public static final String SIGNATURE_REFERENCES_DICTIONARY_SHALL_NOT_CONTAIN_DIGESTLOCATION_DIGESTMETHOD_DIGESTVALUE = "Signature references dictionary shall not contain digestlocation digestmethod digestvalue"; - @Deprecated - public static final String STREAM_OBJECT_DICTIONARY_SHALL_NOT_CONTAIN_THE_F_FFILTER_OR_FDECODEPARAMS_KEYS = "Stream object dictionary shall not contain the f ffilter or fdecodeparams keys"; - @Deprecated - public static final String THE_AS_KEY_SHALL_NOT_APPEAR_IN_ANY_OPTIONAL_CONTENT_CONFIGURATION_DICTIONARY = "The as key shall not appear in any optional content configuration dictionary"; - @Deprecated - public static final String THE_BIT_DEPTH_OF_THE_JPEG2000_DATA_SHALL_HAVE_A_VALUE_IN_THE_RANGE_1_TO_38 = "The bit-depth of the jpeg2000 data shall have a value in the range 1 to 38"; - @Deprecated - public static final String THE_CATALOG_DICTIONARY_SHALL_NOT_CONTAIN_THE_NEEDSRENDERING_KEY = "The catalog dictionary shall not contain the needsrendering key"; - @Deprecated - public static final String THE_F_KEYS_PRINT_FLAG_BIT_SHALL_BE_SET_TO_1_AND_ITS_HIDDEN_INVISIBLE_AND_NOVIEW_FLAG_BITS_SHALL_BE_SET_TO_0 = "The f keys print flag bit shall be set to 1 and its hidden invisible and noview flag bits shall be set to 0"; - @Deprecated - public static final String THE_F_KEYS_PRINT_FLAG_BIT_SHALL_BE_SET_TO_1_AND_ITS_HIDDEN_INVISIBLE_NOVIEW_AND_TOGGLENOVIEW_FLAG_BITS_SHALL_BE_SET_TO_0 = "The f keys print flag bit shall be set to 1 and its hidden invisible noview and togglenoview flag bits shall be set to 0"; - @Deprecated - public static final String THE_INTERACTIVE_FORM_DICTIONARY_SHALL_NOT_CONTAIN_THE_XFA_KEY = "The interactive form dictionary shall not contain the xfa key"; - @Deprecated - public static final String THE_NUMBER_OF_COLOR_COMPONENTS_IN_DEVICE_N_COLORSPACE_SHOULD_NOT_EXCEED = "The number of color components in DeviceN colorspace should not exceed {0}"; - @Deprecated - public static final String THE_NUMBER_OF_COLOUR_CHANNELS_IN_THE_JPEG2000_DATA_SHALL_BE_1_3_OR_4 = "The number of colour channels in the jpeg2000 data shall be 1, 3 or 4"; - @Deprecated - public static final String THE_PAGE_DICTIONARY_SHALL_NOT_CONTAIN_AA_ENTRY = "The page dictionary shall not contain aa entry"; - @Deprecated - public static final String THE_PAGE_DICTIONARY_SHALL_NOT_CONTAIN_PRESSTEPS_ENTRY = "The page dictionary shall not contain pressteps entry"; - @Deprecated - public static final String THE_PAGE_LESS_3_UNITS_NO_GREATER_14400_IN_EITHER_DIRECTION = "The page is less than 3 units or greater than 14400 in either direction"; - @Deprecated - public static final String THE_SMASK_KEY_IS_NOT_ALLOWED_IN_EXTGSTATE = "The smask key is not allowed in extgstate"; - @Deprecated - public static final String THE_SMASK_KEY_IS_NOT_ALLOWED_IN_XOBJECTS = "The smask key is not allowed in xobjects"; - @Deprecated - public static final String THE_VALUE_OF_INTERPOLATE_KEY_SHALL_BE_FALSE = "The value of interpolate key shall not be true"; - @Deprecated - public static final String THE_VALUE_OF_THE_METH_ENTRY_IN_COLR_BOX_SHALL_BE_1_2_OR_3 = "The value of the meth entry in colr box shall be 1, 2 or 3"; - @Deprecated - public static final String TINT_TRANSFORM_AND_ALTERNATE_SPACE_SHALL_BE_THE_SAME_FOR_THE_ALL_SEPARATION_CS_WITH_THE_SAME_NAME = "TintTransform and alternateSpace shall be the same for the all separation cs with the same name"; - @Deprecated - public static final String TRANSPARENCY_IS_NOT_ALLOWED_AND_CA_SHALL_BE_EQUAL_TO_1 = "Transparency is not allowed. ca shall be equal to 1"; - @Deprecated - public static final String TRANSPARENCY_IS_NOT_ALLOWED_CA_SHALL_BE_EQUAL_TO_1 = "Transparency is not allowed. CA shall be equal to 1"; - @Deprecated - public static final String VALUE_OF_NAME_ENTRY_SHALL_BE_UNIQUE_AMONG_ALL_OPTIONAL_CONTENT_CONFIGURATION_DICTIONARIES = "Value of name entry shall be unique among all optional content configuration dictionaries"; - @Deprecated - public static final String WIDGET_ANNOTATION_DICTIONARY_OR_FIELD_DICTIONARY_SHALL_NOT_INCLUDE_A_OR_AA_ENTRY = "Widget annotation dictionary or field dictionary shall not include a or aa entry"; - - /** * Creates a PdfAConformanceException. * diff --git a/pdfa/src/main/java/com/itextpdf/pdfa/exceptions/PdfaExceptionMessageConstant.java b/pdfa/src/main/java/com/itextpdf/pdfa/exceptions/PdfaExceptionMessageConstant.java index 647fb2fcc4..364663cc51 100644 --- a/pdfa/src/main/java/com/itextpdf/pdfa/exceptions/PdfaExceptionMessageConstant.java +++ b/pdfa/src/main/java/com/itextpdf/pdfa/exceptions/PdfaExceptionMessageConstant.java @@ -177,7 +177,7 @@ public final class PdfaExceptionMessageConstant { public static final String XMP_METADATA_HEADER_SHALL_CONTAIN_VERSION_IDENTIFIER_CONFORMANCE = "XMP metadata header shall" - + " contain version identifier pdfaid:rev F or E or absent if no conformance level is specified"; + + " contain version identifier pdfaid:rev F or E or absent if no conformance is specified"; public static final String XMP_METADATA_HISTORY_ENTRY_SHALL_CONTAIN_KEY = "XMP metadata history entry shall" + " contain key {0}"; diff --git a/pdfa/src/main/java/com/itextpdf/pdfa/logs/PdfALogMessageConstant.java b/pdfa/src/main/java/com/itextpdf/pdfa/logs/PdfALogMessageConstant.java index 8d667e4076..066eaa2ed0 100644 --- a/pdfa/src/main/java/com/itextpdf/pdfa/logs/PdfALogMessageConstant.java +++ b/pdfa/src/main/java/com/itextpdf/pdfa/logs/PdfALogMessageConstant.java @@ -33,6 +33,8 @@ public class PdfALogMessageConstant { public static final String PDFA_OBJECT_FLUSHING_WAS_NOT_PERFORMED = "Object flushing was not performed. Object in PDF/A mode can only be flushed if the document is closed or " + "if this object has already been checked for compliance with PDF/A rules."; + public static final String WRITER_PROPERTIES_PDF_VERSION_WAS_OVERRIDDEN = + "Pdf version from writer properties isn't compatible with specified PDF/A conformance, it was overridden to {0} version."; private PdfALogMessageConstant() { //Private constructor will prevent the instantiation of this class directly diff --git a/pdfa/src/test/java/com/itextpdf/pdfa/PdfA1AcroFormCheckTest.java b/pdfa/src/test/java/com/itextpdf/pdfa/PdfA1AcroFormCheckTest.java index e0723eb470..da24ed9ec9 100644 --- a/pdfa/src/test/java/com/itextpdf/pdfa/PdfA1AcroFormCheckTest.java +++ b/pdfa/src/test/java/com/itextpdf/pdfa/PdfA1AcroFormCheckTest.java @@ -24,7 +24,7 @@ This file is part of the iText (R) project. import com.itextpdf.commons.utils.FileUtil; import com.itextpdf.io.source.ByteArrayOutputStream; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfAConformance; import com.itextpdf.kernel.pdf.PdfBoolean; import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.kernel.pdf.PdfName; @@ -34,24 +34,22 @@ This file is part of the iText (R) project. import com.itextpdf.pdfa.exceptions.PdfAConformanceException; import com.itextpdf.pdfa.exceptions.PdfaExceptionMessageConstant; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; +import static org.junit.jupiter.api.Assertions.fail; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfA1AcroFormCheckTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/pdfa/"; public static final String cmpFolder = sourceFolder + "cmp/PdfA1AcroFormCheckTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/pdfa/PdfA1AcroFormCheckTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } @@ -60,14 +58,14 @@ public static void beforeClass() { public void acroFormCheck01() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.addNewPage(); PdfDictionary acroForm = new PdfDictionary(); acroForm.put(PdfName.NeedAppearances, new PdfBoolean(true)); doc.getCatalog().put(PdfName.AcroForm, acroForm); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(PdfaExceptionMessageConstant.NEEDAPPEARANCES_FLAG_OF_THE_INTERACTIVE_FORM_DICTIONARY_SHALL_EITHER_NOT_BE_PRESENTED_OR_SHALL_BE_FALSE, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(PdfaExceptionMessageConstant.NEEDAPPEARANCES_FLAG_OF_THE_INTERACTIVE_FORM_DICTIONARY_SHALL_EITHER_NOT_BE_PRESENTED_OR_SHALL_BE_FALSE, e.getMessage()); } @@ -78,7 +76,7 @@ public void acroFormCheck02() throws IOException, InterruptedException { PdfWriter writer = new PdfWriter(outPdf); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.addNewPage(); PdfDictionary acroForm = new PdfDictionary(); acroForm.put(PdfName.NeedAppearances, new PdfBoolean(false)); @@ -95,7 +93,7 @@ public void acroFormCheck03() throws IOException, InterruptedException { PdfWriter writer = new PdfWriter(outPdf); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.addNewPage(); PdfDictionary acroForm = new PdfDictionary(); doc.getCatalog().put(PdfName.AcroForm, acroForm); diff --git a/pdfa/src/test/java/com/itextpdf/pdfa/PdfA1ActionCheckTest.java b/pdfa/src/test/java/com/itextpdf/pdfa/PdfA1ActionCheckTest.java index 37dc6e1374..4561591ce3 100644 --- a/pdfa/src/test/java/com/itextpdf/pdfa/PdfA1ActionCheckTest.java +++ b/pdfa/src/test/java/com/itextpdf/pdfa/PdfA1ActionCheckTest.java @@ -25,7 +25,7 @@ This file is part of the iText (R) project. import com.itextpdf.commons.utils.FileUtil; import com.itextpdf.commons.utils.MessageFormatUtil; import com.itextpdf.io.source.ByteArrayOutputStream; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfAConformance; import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.kernel.pdf.PdfName; import com.itextpdf.kernel.pdf.PdfOutputIntent; @@ -35,15 +35,14 @@ This file is part of the iText (R) project. import com.itextpdf.pdfa.exceptions.PdfAConformanceException; import com.itextpdf.pdfa.exceptions.PdfaExceptionMessageConstant; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; import java.io.InputStream; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfA1ActionCheckTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/pdfa/"; @@ -51,28 +50,28 @@ public class PdfA1ActionCheckTest extends ExtendedITextTest { public void actionCheck01() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.addNewPage(); PdfDictionary openActions = new PdfDictionary(); openActions.put(PdfName.S, PdfName.Launch); doc.getCatalog().put(PdfName.OpenAction, openActions); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant._0_ACTIONS_ARE_NOT_ALLOWED, PdfName.Launch.getValue()), e.getMessage()); + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant._0_ACTIONS_ARE_NOT_ALLOWED, PdfName.Launch.getValue()), e.getMessage()); } @Test public void actionCheck02() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.addNewPage(); PdfDictionary openActions = new PdfDictionary(); openActions.put(PdfName.S, PdfName.Hide); doc.getCatalog().put(PdfName.OpenAction, openActions); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant._0_ACTIONS_ARE_NOT_ALLOWED, PdfName.Hide.getValue()), + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant._0_ACTIONS_ARE_NOT_ALLOWED, PdfName.Hide.getValue()), e.getMessage()); } @@ -80,28 +79,28 @@ public void actionCheck02() throws IOException { public void actionCheck03() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.addNewPage(); PdfDictionary openActions = new PdfDictionary(); openActions.put(PdfName.S, PdfName.Sound); doc.getCatalog().put(PdfName.OpenAction, openActions); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant._0_ACTIONS_ARE_NOT_ALLOWED, PdfName.Sound.getValue()), e.getMessage()); + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant._0_ACTIONS_ARE_NOT_ALLOWED, PdfName.Sound.getValue()), e.getMessage()); } @Test public void actionCheck04() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.addNewPage(); PdfDictionary openActions = new PdfDictionary(); openActions.put(PdfName.S, PdfName.Movie); doc.getCatalog().put(PdfName.OpenAction, openActions); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant._0_ACTIONS_ARE_NOT_ALLOWED, PdfName.Movie.getValue()), + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant._0_ACTIONS_ARE_NOT_ALLOWED, PdfName.Movie.getValue()), e.getMessage()); } @@ -109,14 +108,14 @@ public void actionCheck04() throws IOException { public void actionCheck05() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.addNewPage(); PdfDictionary openActions = new PdfDictionary(); openActions.put(PdfName.S, PdfName.ResetForm); doc.getCatalog().put(PdfName.OpenAction, openActions); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant._0_ACTIONS_ARE_NOT_ALLOWED, PdfName.ResetForm.getValue()), + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant._0_ACTIONS_ARE_NOT_ALLOWED, PdfName.ResetForm.getValue()), e.getMessage()); } @@ -124,14 +123,14 @@ public void actionCheck05() throws IOException { public void actionCheck06() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.addNewPage(); PdfDictionary openActions = new PdfDictionary(); openActions.put(PdfName.S, PdfName.ImportData); doc.getCatalog().put(PdfName.OpenAction, openActions); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant._0_ACTIONS_ARE_NOT_ALLOWED, PdfName.ImportData.getValue()), + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant._0_ACTIONS_ARE_NOT_ALLOWED, PdfName.ImportData.getValue()), e.getMessage()); } @@ -139,14 +138,14 @@ public void actionCheck06() throws IOException { public void actionCheck07() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.addNewPage(); PdfDictionary openActions = new PdfDictionary(); openActions.put(PdfName.S, PdfName.JavaScript); doc.getCatalog().put(PdfName.OpenAction, openActions); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant._0_ACTIONS_ARE_NOT_ALLOWED, PdfName.JavaScript.getValue()), + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant._0_ACTIONS_ARE_NOT_ALLOWED, PdfName.JavaScript.getValue()), e.getMessage()); } @@ -154,15 +153,15 @@ public void actionCheck07() throws IOException { public void actionCheck08() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.addNewPage(); PdfDictionary openActions = new PdfDictionary(); openActions.put(PdfName.S, PdfName.Named); openActions.put(PdfName.N, new PdfName("CustomName")); doc.getCatalog().put(PdfName.OpenAction, openActions); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.NAMED_ACTION_TYPE_0_IS_NOT_ALLOWED, "CustomName"), + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.NAMED_ACTION_TYPE_0_IS_NOT_ALLOWED, "CustomName"), e.getMessage()); } @@ -170,12 +169,12 @@ public void actionCheck08() throws IOException { public void actionCheck09() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); PdfPage page = doc.addNewPage(); page.setAdditionalAction(PdfName.C, PdfAction.createJavaScript("js")); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant._0_ACTIONS_ARE_NOT_ALLOWED, PdfName.JavaScript.getValue()), + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant._0_ACTIONS_ARE_NOT_ALLOWED, PdfName.JavaScript.getValue()), e.getMessage()); } @@ -183,25 +182,25 @@ public void actionCheck09() throws IOException { public void actionCheck10() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); PdfPage page = doc.addNewPage(); PdfDictionary action = new PdfDictionary(); action.put(PdfName.S, PdfName.SetState); page.setAdditionalAction(PdfName.C, new PdfAction(action)); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(PdfaExceptionMessageConstant.DEPRECATED_SETSTATE_AND_NOOP_ACTIONS_ARE_NOT_ALLOWED, e.getMessage()); + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(PdfaExceptionMessageConstant.DEPRECATED_SETSTATE_AND_NOOP_ACTIONS_ARE_NOT_ALLOWED, e.getMessage()); } @Test public void actionCheck11() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.addNewPage(); doc.getCatalog().setAdditionalAction(PdfName.C, PdfAction.createJavaScript("js")); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(PdfaExceptionMessageConstant.A_CATALOG_DICTIONARY_SHALL_NOT_CONTAIN_AA_ENTRY, e.getMessage()); + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(PdfaExceptionMessageConstant.A_CATALOG_DICTIONARY_SHALL_NOT_CONTAIN_AA_ENTRY, e.getMessage()); } } diff --git a/pdfa/src/test/java/com/itextpdf/pdfa/PdfA1AnnotationCheckTest.java b/pdfa/src/test/java/com/itextpdf/pdfa/PdfA1AnnotationCheckTest.java index ec2db3f41e..cda1a4fa4c 100644 --- a/pdfa/src/test/java/com/itextpdf/pdfa/PdfA1AnnotationCheckTest.java +++ b/pdfa/src/test/java/com/itextpdf/pdfa/PdfA1AnnotationCheckTest.java @@ -26,7 +26,7 @@ This file is part of the iText (R) project. import com.itextpdf.commons.utils.MessageFormatUtil; import com.itextpdf.io.source.ByteArrayOutputStream; import com.itextpdf.kernel.geom.Rectangle; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfAConformance; import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.kernel.pdf.PdfName; import com.itextpdf.kernel.pdf.PdfNumber; @@ -51,27 +51,24 @@ This file is part of the iText (R) project. import com.itextpdf.test.LogLevelConstants; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import com.itextpdf.test.pdfa.VeraPdfValidator; // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) -import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.nio.charset.StandardCharsets; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; +import static org.junit.jupiter.api.Assertions.fail; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfA1AnnotationCheckTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/pdfa/"; public static final String cmpFolder = sourceFolder + "cmp/PdfA1AnnotationCheckTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/pdfa/PdfA1AnnotationCheckTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } @@ -80,15 +77,15 @@ public static void beforeClass() { public void annotationCheckTest01() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); PdfPage page = doc.addNewPage(); Rectangle rect = new Rectangle(100, 100, 100, 100); PdfAnnotation annot = new PdfFileAttachmentAnnotation(rect); page.addAnnotation(annot); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.ANNOTATION_TYPE_0_IS_NOT_PERMITTED, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.ANNOTATION_TYPE_0_IS_NOT_PERMITTED, PdfName.FileAttachment.getValue()), e.getMessage()); } @@ -96,7 +93,7 @@ public void annotationCheckTest01() throws IOException { public void annotationCheckTest02() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); PdfPage page = doc.addNewPage(); Rectangle rect = new Rectangle(100, 100, 100, 100); @@ -106,8 +103,8 @@ public void annotationCheckTest02() throws IOException { page.addAnnotation(annot); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(PdfaExceptionMessageConstant.AN_ANNOTATION_DICTIONARY_SHALL_NOT_CONTAIN_THE_CA_KEY_WITH_A_VALUE_OTHER_THAN_1, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(PdfaExceptionMessageConstant.AN_ANNOTATION_DICTIONARY_SHALL_NOT_CONTAIN_THE_CA_KEY_WITH_A_VALUE_OTHER_THAN_1, e.getMessage()); } @@ -115,7 +112,7 @@ public void annotationCheckTest02() throws IOException { public void annotationCheckTest03() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); PdfPage page = doc.addNewPage(); Rectangle rect = new Rectangle(100, 100, 100, 100); @@ -124,10 +121,10 @@ public void annotationCheckTest03() throws IOException { page.addAnnotation(annot); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close() ); - Assert.assertEquals(PdfaExceptionMessageConstant.THE_F_KEYS_PRINT_FLAG_BIT_SHALL_BE_SET_TO_1_AND_ITS_HIDDEN_INVISIBLE_AND_NOVIEW_FLAG_BITS_SHALL_BE_SET_TO_0, + Assertions.assertEquals(PdfaExceptionMessageConstant.THE_F_KEYS_PRINT_FLAG_BIT_SHALL_BE_SET_TO_1_AND_ITS_HIDDEN_INVISIBLE_AND_NOVIEW_FLAG_BITS_SHALL_BE_SET_TO_0, e.getMessage()); } @@ -135,7 +132,7 @@ public void annotationCheckTest03() throws IOException { public void annotationCheckTest04() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); PdfPage page = doc.addNewPage(); Rectangle rect = new Rectangle(100, 100, 100, 100); @@ -145,8 +142,8 @@ public void annotationCheckTest04() throws IOException { page.addAnnotation(annot); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(PdfaExceptionMessageConstant.THE_F_KEYS_PRINT_FLAG_BIT_SHALL_BE_SET_TO_1_AND_ITS_HIDDEN_INVISIBLE_AND_NOVIEW_FLAG_BITS_SHALL_BE_SET_TO_0, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(PdfaExceptionMessageConstant.THE_F_KEYS_PRINT_FLAG_BIT_SHALL_BE_SET_TO_1_AND_ITS_HIDDEN_INVISIBLE_AND_NOVIEW_FLAG_BITS_SHALL_BE_SET_TO_0, e.getMessage()); } @@ -154,7 +151,7 @@ public void annotationCheckTest04() throws IOException { public void annotationCheckTest05() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); PdfPage page = doc.addNewPage(); Rectangle rect = new Rectangle(100, 100, 100, 100); @@ -167,8 +164,8 @@ public void annotationCheckTest05() throws IOException { page.addAnnotation(annot); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(PdfaExceptionMessageConstant.APPEARANCE_DICTIONARY_SHALL_CONTAIN_ONLY_THE_N_KEY_WITH_STREAM_VALUE, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(PdfaExceptionMessageConstant.APPEARANCE_DICTIONARY_SHALL_CONTAIN_ONLY_THE_N_KEY_WITH_STREAM_VALUE, e.getMessage()); } @@ -176,7 +173,7 @@ public void annotationCheckTest05() throws IOException { public void annotationCheckTest06() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); PdfPage page = doc.addNewPage(); Rectangle rect = new Rectangle(100, 100, 100, 100); @@ -187,8 +184,8 @@ public void annotationCheckTest06() throws IOException { page.addAnnotation(annot); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(PdfaExceptionMessageConstant.APPEARANCE_DICTIONARY_SHALL_CONTAIN_ONLY_THE_N_KEY_WITH_STREAM_VALUE, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(PdfaExceptionMessageConstant.APPEARANCE_DICTIONARY_SHALL_CONTAIN_ONLY_THE_N_KEY_WITH_STREAM_VALUE, e.getMessage()); } @@ -198,7 +195,7 @@ public void annotationCheckTest07() throws IOException, InterruptedException { String cmpPdf = cmpFolder + "cmp_pdfA1b_annotationCheckTest07.pdf"; PdfWriter writer = new PdfWriter(outPdf); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); PdfPage page = doc.addNewPage(); Rectangle rect = new Rectangle(100, 100, 100, 100); @@ -220,7 +217,7 @@ public void annotationCheckTest08() throws IOException, InterruptedException { PdfWriter writer = new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_1_4)); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1A, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_1A, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.setTagged(); doc.getCatalog().setLang(new PdfString("en-US")); PdfPage page = doc.addNewPage(); @@ -233,7 +230,7 @@ public void annotationCheckTest08() throws IOException, InterruptedException { doc.close(); compareResult(outPdf, cmpPdf); - Assert.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) } @Test @@ -243,7 +240,7 @@ public void annotationCheckTest09() throws IOException, InterruptedException { PdfWriter writer = new PdfWriter(outPdf); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1A, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_1A, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.setTagged(); doc.getCatalog().setLang(new PdfString("en-US")); PdfPage page = doc.addNewPage(); diff --git a/pdfa/src/test/java/com/itextpdf/pdfa/PdfA1CanvasCheckTest.java b/pdfa/src/test/java/com/itextpdf/pdfa/PdfA1CanvasCheckTest.java index 7afdccd10a..c66af576e2 100644 --- a/pdfa/src/test/java/com/itextpdf/pdfa/PdfA1CanvasCheckTest.java +++ b/pdfa/src/test/java/com/itextpdf/pdfa/PdfA1CanvasCheckTest.java @@ -23,7 +23,7 @@ This file is part of the iText (R) project. package com.itextpdf.pdfa; import com.itextpdf.commons.utils.FileUtil; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfAConformance; import com.itextpdf.kernel.pdf.PdfName; import com.itextpdf.kernel.pdf.PdfOutputIntent; import com.itextpdf.kernel.pdf.PdfWriter; @@ -32,27 +32,25 @@ This file is part of the iText (R) project. import com.itextpdf.pdfa.exceptions.PdfAConformanceException; import com.itextpdf.pdfa.exceptions.PdfaExceptionMessageConstant; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.ByteArrayOutputStream; -import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfA1CanvasCheckTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/pdfa/"; public static final String cmpFolder = sourceFolder + "cmp/PdfA1CanvasCheckTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/pdfa/PdfA1CanvasCheckTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } @@ -63,15 +61,15 @@ public void canvasCheckTest1() throws IOException { InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - try (PdfADocument pdfDocument = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, outputIntent)) { + try (PdfADocument pdfDocument = new PdfADocument(writer, PdfAConformance.PDF_A_1B, outputIntent)) { pdfDocument.addNewPage(); PdfCanvas canvas = new PdfCanvas(pdfDocument.getLastPage()); for (int i = 0; i < 28; i++) { canvas.saveState(); } - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> canvas.saveState()); - Assert.assertEquals(PdfaExceptionMessageConstant.GRAPHICS_STATE_STACK_DEPTH_IS_GREATER_THAN_28, e.getMessage()); + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> canvas.saveState()); + Assertions.assertEquals(PdfaExceptionMessageConstant.GRAPHICS_STATE_STACK_DEPTH_IS_GREATER_THAN_28, e.getMessage()); } } @@ -83,7 +81,7 @@ public void canvasCheckTest2() throws IOException, InterruptedException { PdfWriter writer = new PdfWriter(outPdf); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - PdfADocument pdfDocument = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, outputIntent); + PdfADocument pdfDocument = new PdfADocument(writer, PdfAConformance.PDF_A_1B, outputIntent); pdfDocument.addNewPage(); PdfCanvas canvas = new PdfCanvas(pdfDocument.getLastPage()); @@ -109,14 +107,14 @@ public void canvasCheckTest3() throws IOException { InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - try (PdfADocument pdfDocument = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, outputIntent)) { + try (PdfADocument pdfDocument = new PdfADocument(writer, PdfAConformance.PDF_A_1B, outputIntent)) { pdfDocument.addNewPage(); PdfCanvas canvas = new PdfCanvas(pdfDocument.getLastPage()); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> canvas.setRenderingIntent(new PdfName("Test")) ); - Assert.assertEquals( + Assertions.assertEquals( PdfaExceptionMessageConstant.IF_SPECIFIED_RENDERING_SHALL_BE_ONE_OF_THE_FOLLOWING_RELATIVECOLORIMETRIC_ABSOLUTECOLORIMETRIC_PERCEPTUAL_OR_SATURATION, e.getMessage()); } diff --git a/pdfa/src/test/java/com/itextpdf/pdfa/PdfA1EmbeddedFilesCheckTest.java b/pdfa/src/test/java/com/itextpdf/pdfa/PdfA1EmbeddedFilesCheckTest.java index e33dfe58e7..913dff7ee3 100644 --- a/pdfa/src/test/java/com/itextpdf/pdfa/PdfA1EmbeddedFilesCheckTest.java +++ b/pdfa/src/test/java/com/itextpdf/pdfa/PdfA1EmbeddedFilesCheckTest.java @@ -23,7 +23,7 @@ This file is part of the iText (R) project. package com.itextpdf.pdfa; import com.itextpdf.commons.utils.FileUtil; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfAConformance; import com.itextpdf.kernel.pdf.PdfArray; import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.kernel.pdf.PdfName; @@ -35,18 +35,16 @@ This file is part of the iText (R) project. import com.itextpdf.pdfa.exceptions.PdfAConformanceException; import com.itextpdf.pdfa.exceptions.PdfaExceptionMessageConstant; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.ByteArrayOutputStream; -import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfA1EmbeddedFilesCheckTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/pdfa/"; @@ -55,7 +53,7 @@ public void fileSpecCheckTest01() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - PdfADocument pdfDocument = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, outputIntent); + PdfADocument pdfDocument = new PdfADocument(writer, PdfAConformance.PDF_A_1B, outputIntent); PdfDictionary fileNames = new PdfDictionary(); pdfDocument.getCatalog().put(PdfName.Names, fileNames); @@ -72,8 +70,8 @@ public void fileSpecCheckTest01() throws IOException { pdfDocument.addNewPage(); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> pdfDocument.close()); - Assert.assertEquals(PdfaExceptionMessageConstant.A_NAME_DICTIONARY_SHALL_NOT_CONTAIN_THE_EMBEDDED_FILES_KEY, e.getMessage()); + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfDocument.close()); + Assertions.assertEquals(PdfaExceptionMessageConstant.A_NAME_DICTIONARY_SHALL_NOT_CONTAIN_THE_EMBEDDED_FILES_KEY, e.getMessage()); } @Test @@ -81,7 +79,7 @@ public void fileSpecCheckTest02() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - PdfADocument pdfDocument = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, outputIntent); + PdfADocument pdfDocument = new PdfADocument(writer, PdfAConformance.PDF_A_1B, outputIntent); PdfStream stream = new PdfStream(); pdfDocument.getCatalog().put(new PdfName("testStream"), stream); @@ -91,8 +89,8 @@ public void fileSpecCheckTest02() throws IOException { pdfDocument.addNewPage(); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> pdfDocument.close()); - Assert.assertEquals(PdfaExceptionMessageConstant.STREAM_OBJECT_DICTIONARY_SHALL_NOT_CONTAIN_THE_F_FFILTER_OR_FDECODEPARAMS_KEYS, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfDocument.close()); + Assertions.assertEquals(PdfaExceptionMessageConstant.STREAM_OBJECT_DICTIONARY_SHALL_NOT_CONTAIN_THE_F_FFILTER_OR_FDECODEPARAMS_KEYS, e.getMessage()); } @@ -101,7 +99,7 @@ public void fileSpecCheckTest03() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - PdfADocument pdfDocument = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, outputIntent); + PdfADocument pdfDocument = new PdfADocument(writer, PdfAConformance.PDF_A_1B, outputIntent); PdfStream stream = new PdfStream(); pdfDocument.getCatalog().put(new PdfName("testStream"), stream); @@ -111,7 +109,7 @@ public void fileSpecCheckTest03() throws IOException { pdfDocument.addNewPage(); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> pdfDocument.close()); - Assert.assertEquals(PdfaExceptionMessageConstant.FILE_SPECIFICATION_DICTIONARY_SHALL_NOT_CONTAIN_THE_EF_KEY, e.getMessage()); + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfDocument.close()); + Assertions.assertEquals(PdfaExceptionMessageConstant.FILE_SPECIFICATION_DICTIONARY_SHALL_NOT_CONTAIN_THE_EF_KEY, e.getMessage()); } } diff --git a/pdfa/src/test/java/com/itextpdf/pdfa/PdfA1GraphicsTest.java b/pdfa/src/test/java/com/itextpdf/pdfa/PdfA1GraphicsTest.java index 60608e58d1..f73db7c177 100644 --- a/pdfa/src/test/java/com/itextpdf/pdfa/PdfA1GraphicsTest.java +++ b/pdfa/src/test/java/com/itextpdf/pdfa/PdfA1GraphicsTest.java @@ -26,7 +26,7 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.colors.ColorConstants; import com.itextpdf.kernel.colors.DeviceCmyk; import com.itextpdf.kernel.geom.Rectangle; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfAConformance; import com.itextpdf.kernel.pdf.PdfName; import com.itextpdf.kernel.pdf.PdfOutputIntent; import com.itextpdf.kernel.pdf.PdfWriter; @@ -38,24 +38,23 @@ This file is part of the iText (R) project. import com.itextpdf.pdfa.exceptions.PdfAConformanceException; import com.itextpdf.pdfa.exceptions.PdfaExceptionMessageConstant; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; +import static org.junit.jupiter.api.Assertions.fail; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfA1GraphicsTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/pdfa/"; public static final String cmpFolder = sourceFolder + "cmp/PdfA1GraphicsTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/pdfa/PdfA1GraphicsTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } @@ -65,7 +64,7 @@ public void colorCheckTest1() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, outputIntent); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_1B, outputIntent); doc.addNewPage(); PdfCanvas canvas = new PdfCanvas(doc.getLastPage()); @@ -75,19 +74,19 @@ public void colorCheckTest1() throws IOException { canvas.lineTo(doc.getDefaultPageSize().getRight(), doc.getDefaultPageSize().getTop()); canvas.fill(); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> canvas.setFillColor(ColorConstants.RED) ); - Assert.assertEquals(PdfaExceptionMessageConstant.DEVICERGB_AND_DEVICECMYK_COLORSPACES_CANNOT_BE_USED_BOTH_IN_ONE_FILE, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.DEVICERGB_AND_DEVICECMYK_COLORSPACES_CANNOT_BE_USED_BOTH_IN_ONE_FILE, e.getMessage()); canvas.moveTo(doc.getDefaultPageSize().getRight(), doc.getDefaultPageSize().getTop()); canvas.lineTo(doc.getDefaultPageSize().getRight(), doc.getDefaultPageSize().getBottom()); canvas.lineTo(doc.getDefaultPageSize().getLeft(), doc.getDefaultPageSize().getBottom()); canvas.fill(); - Exception e2 = Assert.assertThrows(PdfAConformanceException.class, + Exception e2 = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close() ); - Assert.assertEquals(PdfaExceptionMessageConstant.DEVICECMYK_MAY_BE_USED_ONLY_IF_THE_FILE_HAS_A_CMYK_PDFA_OUTPUT_INTENT, e2.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.DEVICECMYK_MAY_BE_USED_ONLY_IF_THE_FILE_HAS_A_CMYK_PDFA_OUTPUT_INTENT, e2.getMessage()); } @Test @@ -95,7 +94,7 @@ public void colorCheckTest2() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, outputIntent); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_1B, outputIntent); doc.addNewPage(); PdfCanvas canvas = new PdfCanvas(doc.getLastPage()); @@ -105,16 +104,16 @@ public void colorCheckTest2() throws IOException { canvas.lineTo(doc.getDefaultPageSize().getRight(), doc.getDefaultPageSize().getTop()); canvas.fill(); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close() ); - Assert.assertEquals(PdfaExceptionMessageConstant.DEVICECMYK_MAY_BE_USED_ONLY_IF_THE_FILE_HAS_A_CMYK_PDFA_OUTPUT_INTENT, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.DEVICECMYK_MAY_BE_USED_ONLY_IF_THE_FILE_HAS_A_CMYK_PDFA_OUTPUT_INTENT, e.getMessage()); } @Test public void colorCheckTest3() { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, null); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_1B, null); doc.addNewPage(); PdfCanvas canvas = new PdfCanvas(doc.getLastPage()); @@ -124,10 +123,10 @@ public void colorCheckTest3() { canvas.lineTo(doc.getDefaultPageSize().getRight(), doc.getDefaultPageSize().getTop()); canvas.fill(); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close() ); - Assert.assertEquals(PdfaExceptionMessageConstant.IF_DEVICE_RGB_CMYK_GRAY_USED_IN_FILE_THAT_FILE_SHALL_CONTAIN_PDFA_OUTPUTINTENT + Assertions.assertEquals(PdfaExceptionMessageConstant.IF_DEVICE_RGB_CMYK_GRAY_USED_IN_FILE_THAT_FILE_SHALL_CONTAIN_PDFA_OUTPUTINTENT , e.getMessage()); } @@ -139,7 +138,7 @@ public void colorCheckTest4() throws IOException, InterruptedException { PdfWriter writer = new PdfWriter(outPdf); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, outputIntent); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_1B, outputIntent); doc.addNewPage(); PdfCanvas canvas = new PdfCanvas(doc.getLastPage()); @@ -159,14 +158,14 @@ public void egsCheckTest1() throws IOException { InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - try (PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, outputIntent)) { + try (PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_1B, outputIntent)) { doc.addNewPage(); PdfCanvas canvas = new PdfCanvas(doc.getLastPage()); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> canvas.setExtGState(new PdfExtGState().setTransferFunction(new PdfName("Test"))) ); - Assert.assertEquals(PdfaExceptionMessageConstant.AN_EXTGSTATE_DICTIONARY_SHALL_NOT_CONTAIN_THE_TR_KEY, + Assertions.assertEquals(PdfaExceptionMessageConstant.AN_EXTGSTATE_DICTIONARY_SHALL_NOT_CONTAIN_THE_TR_KEY, e.getMessage()); } } @@ -179,7 +178,7 @@ public void egsCheckTest2() throws IOException, InterruptedException { PdfWriter writer = new PdfWriter(outPdf); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, outputIntent); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_1B, outputIntent); doc.addNewPage(); PdfCanvas canvas = new PdfCanvas(doc.getLastPage()); @@ -196,14 +195,14 @@ public void egsCheckTest3() throws IOException { InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - try (PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, outputIntent)) { + try (PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_1B, outputIntent)) { doc.addNewPage(); PdfCanvas canvas = new PdfCanvas(doc.getLastPage()); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> canvas.setExtGState(new PdfExtGState().setTransferFunction2(new PdfName("Test"))) ); - Assert.assertEquals( + Assertions.assertEquals( PdfaExceptionMessageConstant.AN_EXTGSTATE_DICTIONARY_SHALL_NOT_CONTAIN_THE_TR_2_KEY_WITH_A_VALUE_OTHER_THAN_DEFAULT, e.getMessage()); } @@ -215,14 +214,14 @@ public void egsCheckTest4() throws IOException { InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - try (PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, outputIntent)) { + try (PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_1B, outputIntent)) { doc.addNewPage(); PdfCanvas canvas = new PdfCanvas(doc.getLastPage()); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> canvas.setExtGState(new PdfExtGState().setRenderingIntent(new PdfName("Test"))) ); - Assert.assertEquals( + Assertions.assertEquals( PdfaExceptionMessageConstant.IF_SPECIFIED_RENDERING_SHALL_BE_ONE_OF_THE_FOLLOWING_RELATIVECOLORIMETRIC_ABSOLUTECOLORIMETRIC_PERCEPTUAL_OR_SATURATION, e.getMessage()); } @@ -233,7 +232,7 @@ public void transparencyCheckTest1() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, outputIntent); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_1B, outputIntent); doc.addNewPage(); PdfCanvas canvas = new PdfCanvas(doc.getLastPage()); @@ -245,8 +244,8 @@ public void transparencyCheckTest1() throws IOException { xObject.setGroup(group); canvas.addXObjectFittedIntoRectangle(xObject, new Rectangle(300, 300)); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(PdfaExceptionMessageConstant.A_GROUP_OBJECT_WITH_AN_S_KEY_WITH_A_VALUE_OF_TRANSPARENCY_SHALL_NOT_BE_INCLUDED_IN_A_FORM_XOBJECT, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(PdfaExceptionMessageConstant.A_GROUP_OBJECT_WITH_AN_S_KEY_WITH_A_VALUE_OF_TRANSPARENCY_SHALL_NOT_BE_INCLUDED_IN_A_FORM_XOBJECT, e.getMessage()); } @@ -256,14 +255,14 @@ public void transparencyCheckTest2() throws IOException { InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - try (PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, outputIntent)) { + try (PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_1B, outputIntent)) { doc.addNewPage(); PdfCanvas canvas = new PdfCanvas(doc.getLastPage()); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> canvas.setExtGState(new PdfExtGState().setSoftMask(new PdfName("Test"))) ); - Assert.assertEquals(PdfaExceptionMessageConstant.THE_SMASK_KEY_IS_NOT_ALLOWED_IN_EXTGSTATE, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.THE_SMASK_KEY_IS_NOT_ALLOWED_IN_EXTGSTATE, e.getMessage()); } } @@ -275,7 +274,7 @@ public void transparencyCheckTest3() throws IOException, InterruptedException { PdfWriter writer = new PdfWriter(outPdf); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, outputIntent); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_1B, outputIntent); doc.addNewPage(); PdfCanvas canvas = new PdfCanvas(doc.getLastPage()); diff --git a/pdfa/src/test/java/com/itextpdf/pdfa/PdfA1LayoutListTest.java b/pdfa/src/test/java/com/itextpdf/pdfa/PdfA1LayoutListTest.java index 7b2be570cf..2cb18ec76c 100644 --- a/pdfa/src/test/java/com/itextpdf/pdfa/PdfA1LayoutListTest.java +++ b/pdfa/src/test/java/com/itextpdf/pdfa/PdfA1LayoutListTest.java @@ -27,7 +27,7 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.font.PdfFont; import com.itextpdf.kernel.font.PdfFontFactory; import com.itextpdf.kernel.font.PdfFontFactory.EmbeddingStrategy; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfAConformance; import com.itextpdf.kernel.pdf.PdfOutputIntent; import com.itextpdf.kernel.pdf.PdfWriter; import com.itextpdf.kernel.utils.CompareTool; @@ -36,22 +36,21 @@ This file is part of the iText (R) project. import com.itextpdf.layout.element.ListItem; import com.itextpdf.layout.element.Paragraph; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import java.io.FileInputStream; + import java.io.IOException; import java.io.InputStream; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfA1LayoutListTest extends ExtendedITextTest { public static final String destinationFolder = "./target/test/com/itextpdf/pdfa/PdfA1LayoutListTest/"; public static final String sourceFolder = "./src/test/resources/com/itextpdf/pdfa/"; public static final String cmpFolder = sourceFolder + "cmp/PdfA1LayoutListTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } @@ -63,7 +62,7 @@ public void listTest01() throws IOException, InterruptedException { InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - PdfADocument pdfDocument = new PdfADocument(new PdfWriter(outPdf), PdfAConformanceLevel.PDF_A_1B, outputIntent); + PdfADocument pdfDocument = new PdfADocument(new PdfWriter(outPdf), PdfAConformance.PDF_A_1B, outputIntent); Document doc = new Document(pdfDocument); pdfDocument.setTagged(); @@ -86,7 +85,7 @@ public void listTest01() throws IOException, InterruptedException { String result = new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_"); if (result != null) { - Assert.fail(result); + Assertions.fail(result); } } } diff --git a/pdfa/src/test/java/com/itextpdf/pdfa/PdfA1bCheckfieldAppearanceTest.java b/pdfa/src/test/java/com/itextpdf/pdfa/PdfA1bCheckfieldAppearanceTest.java index 235f69a625..fd2395ac06 100644 --- a/pdfa/src/test/java/com/itextpdf/pdfa/PdfA1bCheckfieldAppearanceTest.java +++ b/pdfa/src/test/java/com/itextpdf/pdfa/PdfA1bCheckfieldAppearanceTest.java @@ -30,29 +30,28 @@ This file is part of the iText (R) project. import com.itextpdf.forms.fields.properties.CheckBoxType; import com.itextpdf.kernel.colors.ColorConstants; import com.itextpdf.kernel.geom.Rectangle; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfAConformance; +import com.itextpdf.kernel.pdf.PdfConformance; import com.itextpdf.kernel.pdf.PdfOutputIntent; import com.itextpdf.kernel.pdf.PdfWriter; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfA1bCheckfieldAppearanceTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/pdfa/"; public static final String cmpFolder = "./src/test/resources/com/itextpdf/pdfa/cmp/PdfA1bCheckfieldAppearanceTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/pdfa/PdfA1bCheckfieldAppearanceTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } @@ -66,18 +65,18 @@ public void pdfA1bCheckFieldOffAppearanceTest() throws IOException, InterruptedE PdfWriter writer = new PdfWriter(outPath); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.addNewPage(); PdfAcroForm form = PdfFormCreator.getAcroForm(doc, true); PdfFormField chk = new CheckBoxFormFieldBuilder(doc, "name").setWidgetRectangle(new Rectangle(100, 500, 50, 50)) - .setCheckType(CheckBoxType.CHECK).setGenericConformanceLevel(PdfAConformanceLevel.PDF_A_1B) + .setCheckType(CheckBoxType.CHECK).setConformance(PdfConformance.PDF_A_1B) .createCheckBox().setValue("Off"); chk.getFirstFormAnnotation().setBorderColor(ColorConstants.BLACK); chk.getFirstFormAnnotation().setBorderWidth(1); form.addField(chk); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outPath, cmpPath, destinationFolder, diff)); + Assertions.assertNull(new CompareTool().compareByContent(outPath, cmpPath, destinationFolder, diff)); } @Test @@ -89,17 +88,17 @@ public void pdfA1bCheckFieldOnAppearanceTest() throws IOException, InterruptedEx PdfWriter writer = new PdfWriter(outPath); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.addNewPage(); PdfAcroForm form = PdfFormCreator.getAcroForm(doc, true); PdfFormField chk = new CheckBoxFormFieldBuilder(doc, "name").setWidgetRectangle(new Rectangle(100, 500, 50, 50)) - .setCheckType(CheckBoxType.CHECK).setGenericConformanceLevel(PdfAConformanceLevel.PDF_A_1B) + .setCheckType(CheckBoxType.CHECK).setConformance(PdfConformance.PDF_A_1B) .createCheckBox().setValue("On"); chk.getFirstFormAnnotation().setBorderColor(ColorConstants.BLACK); chk.getFirstFormAnnotation().setBorderWidth(1); form.addField(chk); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outPath, cmpPath, destinationFolder, diff)); + Assertions.assertNull(new CompareTool().compareByContent(outPath, cmpPath, destinationFolder, diff)); } } diff --git a/pdfa/src/test/java/com/itextpdf/pdfa/PdfA2AcroFormCheckTest.java b/pdfa/src/test/java/com/itextpdf/pdfa/PdfA2AcroFormCheckTest.java index 2f5c493e96..166dab3d3f 100644 --- a/pdfa/src/test/java/com/itextpdf/pdfa/PdfA2AcroFormCheckTest.java +++ b/pdfa/src/test/java/com/itextpdf/pdfa/PdfA2AcroFormCheckTest.java @@ -24,7 +24,7 @@ This file is part of the iText (R) project. import com.itextpdf.commons.utils.FileUtil; import com.itextpdf.io.source.ByteArrayOutputStream; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfAConformance; import com.itextpdf.kernel.pdf.PdfArray; import com.itextpdf.kernel.pdf.PdfBoolean; import com.itextpdf.kernel.pdf.PdfDictionary; @@ -35,27 +35,24 @@ This file is part of the iText (R) project. import com.itextpdf.pdfa.exceptions.PdfAConformanceException; import com.itextpdf.pdfa.exceptions.PdfaExceptionMessageConstant; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfA2AcroFormCheckTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/pdfa/"; public static final String cmpFolder = sourceFolder + "cmp/PdfA2AcroFormCheckTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/pdfa/PdfA2AcroFormCheckTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } @@ -64,14 +61,14 @@ public static void beforeClass() { public void acroFormCheck01() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.addNewPage(); PdfDictionary acroForm = new PdfDictionary(); acroForm.put(PdfName.NeedAppearances, new PdfBoolean(true)); doc.getCatalog().put(PdfName.AcroForm, acroForm); try { doc.close(); - Assert.fail("PdfAConformanceException expected"); + Assertions.fail("PdfAConformanceException expected"); } catch (PdfAConformanceException ignored) { } @@ -83,7 +80,7 @@ public void acroFormCheck02() throws IOException, InterruptedException { String cmpPdf = cmpFolder + "cmp_pdfA2b_acroFormCheck02.pdf"; PdfWriter writer = new PdfWriter(outPdf); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.addNewPage(); PdfDictionary acroForm = new PdfDictionary(); acroForm.put(PdfName.NeedAppearances, new PdfBoolean(false)); @@ -99,7 +96,7 @@ public void acroFormCheck03() throws IOException, InterruptedException { String cmpPdf = cmpFolder + "cmp_pdfA2b_acroFormCheck03.pdf"; PdfWriter writer = new PdfWriter(outPdf); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.addNewPage(); PdfDictionary acroForm = new PdfDictionary(); doc.getCatalog().put(PdfName.AcroForm, acroForm); @@ -112,14 +109,14 @@ public void acroFormCheck03() throws IOException, InterruptedException { public void acroFormCheck04() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.addNewPage(); PdfDictionary acroForm = new PdfDictionary(); acroForm.put(PdfName.XFA, new PdfArray()); doc.getCatalog().put(PdfName.AcroForm, acroForm); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(PdfaExceptionMessageConstant.THE_INTERACTIVE_FORM_DICTIONARY_SHALL_NOT_CONTAIN_THE_XFA_KEY, e.getMessage()); + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(PdfaExceptionMessageConstant.THE_INTERACTIVE_FORM_DICTIONARY_SHALL_NOT_CONTAIN_THE_XFA_KEY, e.getMessage()); } private void compareResult(String outPdf, String cmpPdf) throws IOException, InterruptedException { diff --git a/pdfa/src/test/java/com/itextpdf/pdfa/PdfA2ActionCheckTest.java b/pdfa/src/test/java/com/itextpdf/pdfa/PdfA2ActionCheckTest.java index 84b3b44b35..fe596e1069 100644 --- a/pdfa/src/test/java/com/itextpdf/pdfa/PdfA2ActionCheckTest.java +++ b/pdfa/src/test/java/com/itextpdf/pdfa/PdfA2ActionCheckTest.java @@ -25,7 +25,7 @@ This file is part of the iText (R) project. import com.itextpdf.commons.utils.FileUtil; import com.itextpdf.commons.utils.MessageFormatUtil; import com.itextpdf.io.source.ByteArrayOutputStream; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfAConformance; import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.kernel.pdf.PdfName; import com.itextpdf.kernel.pdf.PdfOutline; @@ -37,24 +37,21 @@ This file is part of the iText (R) project. import com.itextpdf.pdfa.exceptions.PdfAConformanceException; import com.itextpdf.pdfa.exceptions.PdfaExceptionMessageConstant; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; +import static org.junit.jupiter.api.Assertions.fail; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfA2ActionCheckTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/pdfa/"; public static final String destinationFolder = "./target/test/com/itextpdf/pdfa/PdfA2ActionCheckTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } @@ -63,14 +60,14 @@ public static void beforeClass() { public void actionCheck01() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.addNewPage(); PdfDictionary openActions = new PdfDictionary(); openActions.put(PdfName.S, PdfName.Launch); doc.getCatalog().put(PdfName.OpenAction, openActions); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant._0_ACTIONS_ARE_NOT_ALLOWED, PdfName.Launch.getValue()), + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant._0_ACTIONS_ARE_NOT_ALLOWED, PdfName.Launch.getValue()), e.getMessage()); } @@ -78,14 +75,14 @@ public void actionCheck01() throws IOException { public void actionCheck02() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.addNewPage(); PdfDictionary openActions = new PdfDictionary(); openActions.put(PdfName.S, PdfName.Hide); doc.getCatalog().put(PdfName.OpenAction, openActions); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant._0_ACTIONS_ARE_NOT_ALLOWED, PdfName.Hide.getValue()), + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant._0_ACTIONS_ARE_NOT_ALLOWED, PdfName.Hide.getValue()), e.getMessage()); } @@ -93,14 +90,14 @@ public void actionCheck02() throws IOException { public void actionCheck03() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.addNewPage(); PdfDictionary openActions = new PdfDictionary(); openActions.put(PdfName.S, PdfName.Sound); doc.getCatalog().put(PdfName.OpenAction, openActions); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant._0_ACTIONS_ARE_NOT_ALLOWED, PdfName.Sound.getValue()), + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant._0_ACTIONS_ARE_NOT_ALLOWED, PdfName.Sound.getValue()), e.getMessage()); } @@ -108,14 +105,14 @@ public void actionCheck03() throws IOException { public void actionCheck04() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.addNewPage(); PdfDictionary openActions = new PdfDictionary(); openActions.put(PdfName.S, PdfName.Movie); doc.getCatalog().put(PdfName.OpenAction, openActions); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant._0_ACTIONS_ARE_NOT_ALLOWED, PdfName.Movie.getValue()), + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant._0_ACTIONS_ARE_NOT_ALLOWED, PdfName.Movie.getValue()), e.getMessage()); } @@ -123,14 +120,14 @@ public void actionCheck04() throws IOException { public void actionCheck05() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.addNewPage(); PdfDictionary openActions = new PdfDictionary(); openActions.put(PdfName.S, PdfName.ResetForm); doc.getCatalog().put(PdfName.OpenAction, openActions); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant._0_ACTIONS_ARE_NOT_ALLOWED, PdfName.ResetForm.getValue()), + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant._0_ACTIONS_ARE_NOT_ALLOWED, PdfName.ResetForm.getValue()), e.getMessage()); } @@ -138,14 +135,14 @@ public void actionCheck05() throws IOException { public void actionCheck06() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.addNewPage(); PdfDictionary openActions = new PdfDictionary(); openActions.put(PdfName.S, PdfName.ImportData); doc.getCatalog().put(PdfName.OpenAction, openActions); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant._0_ACTIONS_ARE_NOT_ALLOWED, PdfName.ImportData.getValue()), + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant._0_ACTIONS_ARE_NOT_ALLOWED, PdfName.ImportData.getValue()), e.getMessage()); } @@ -153,29 +150,29 @@ public void actionCheck06() throws IOException { public void actionCheck07() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.addNewPage(); PdfDictionary openActions = new PdfDictionary(); openActions.put(PdfName.S, PdfName.JavaScript); doc.getCatalog().put(PdfName.OpenAction, openActions); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant._0_ACTIONS_ARE_NOT_ALLOWED, PdfName.JavaScript.getValue()), e.getMessage()); + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant._0_ACTIONS_ARE_NOT_ALLOWED, PdfName.JavaScript.getValue()), e.getMessage()); } @Test public void actionCheck08() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.addNewPage(); PdfDictionary openActions = new PdfDictionary(); openActions.put(PdfName.S, PdfName.Named); openActions.put(PdfName.N, new PdfName("CustomName")); doc.getCatalog().put(PdfName.OpenAction, openActions); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.NAMED_ACTION_TYPE_0_IS_NOT_ALLOWED, "CustomName"), + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.NAMED_ACTION_TYPE_0_IS_NOT_ALLOWED, "CustomName"), e.getMessage()); } @@ -183,14 +180,14 @@ public void actionCheck08() throws IOException { public void actionCheck09() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.addNewPage(); PdfDictionary openActions = new PdfDictionary(); openActions.put(PdfName.S, PdfName.SetOCGState); doc.getCatalog().put(PdfName.OpenAction, openActions); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant._0_ACTIONS_ARE_NOT_ALLOWED, PdfName.SetOCGState.getValue()), + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant._0_ACTIONS_ARE_NOT_ALLOWED, PdfName.SetOCGState.getValue()), e.getMessage()); } @@ -198,16 +195,16 @@ public void actionCheck09() throws IOException { public void actionCheck10() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.addNewPage(); PdfDictionary openActions = new PdfDictionary(); openActions.put(PdfName.S, PdfName.Rendition); doc.getCatalog().put(PdfName.OpenAction, openActions); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close() ); - Assert.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant._0_ACTIONS_ARE_NOT_ALLOWED, PdfName.Rendition.getValue()), + Assertions.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant._0_ACTIONS_ARE_NOT_ALLOWED, PdfName.Rendition.getValue()), e.getMessage()); } @@ -215,28 +212,28 @@ public void actionCheck10() throws IOException { public void actionCheck11() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.addNewPage(); PdfDictionary openActions = new PdfDictionary(); openActions.put(PdfName.S, PdfName.Trans); doc.getCatalog().put(PdfName.OpenAction, openActions); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant._0_ACTIONS_ARE_NOT_ALLOWED, PdfName.Trans.getValue()), e.getMessage()); + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant._0_ACTIONS_ARE_NOT_ALLOWED, PdfName.Trans.getValue()), e.getMessage()); } @Test public void actionCheck12() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.addNewPage(); PdfDictionary openActions = new PdfDictionary(); openActions.put(PdfName.S, PdfName.GoTo3DView); doc.getCatalog().put(PdfName.OpenAction, openActions); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant._0_ACTIONS_ARE_NOT_ALLOWED, PdfName.GoTo3DView.getValue()), + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant._0_ACTIONS_ARE_NOT_ALLOWED, PdfName.GoTo3DView.getValue()), e.getMessage()); } @@ -244,24 +241,24 @@ public void actionCheck12() throws IOException { public void actionCheck13() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); PdfPage page = doc.addNewPage(); page.setAdditionalAction(PdfName.C, PdfAction.createJavaScript("js")); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(PdfaExceptionMessageConstant.THE_PAGE_DICTIONARY_SHALL_NOT_CONTAIN_AA_ENTRY, e.getMessage()); + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(PdfaExceptionMessageConstant.THE_PAGE_DICTIONARY_SHALL_NOT_CONTAIN_AA_ENTRY, e.getMessage()); } @Test public void actionCheck14() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.addNewPage(); doc.getCatalog().setAdditionalAction(PdfName.C, PdfAction.createJavaScript("js")); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(PdfaExceptionMessageConstant.A_CATALOG_DICTIONARY_SHALL_NOT_CONTAIN_AA_ENTRY, e.getMessage()); + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(PdfaExceptionMessageConstant.A_CATALOG_DICTIONARY_SHALL_NOT_CONTAIN_AA_ENTRY, e.getMessage()); } @Test @@ -271,7 +268,7 @@ public void actionCheck15() throws IOException, InterruptedException { PdfWriter writer = new PdfWriter(outPdf); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.getOutlines(true); PdfOutline out = doc.getOutlines(false); out.addOutline("New").addAction(PdfAction.createGoTo("TestDest")); diff --git a/pdfa/src/test/java/com/itextpdf/pdfa/PdfA2AnnotationCheckTest.java b/pdfa/src/test/java/com/itextpdf/pdfa/PdfA2AnnotationCheckTest.java index 798776e241..bfd73e91b0 100644 --- a/pdfa/src/test/java/com/itextpdf/pdfa/PdfA2AnnotationCheckTest.java +++ b/pdfa/src/test/java/com/itextpdf/pdfa/PdfA2AnnotationCheckTest.java @@ -28,7 +28,7 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.font.PdfFontFactory; import com.itextpdf.kernel.font.PdfFontFactory.EmbeddingStrategy; import com.itextpdf.kernel.geom.Rectangle; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfAConformance; import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.kernel.pdf.PdfName; import com.itextpdf.kernel.pdf.PdfOutputIntent; @@ -52,24 +52,23 @@ This file is part of the iText (R) project. import com.itextpdf.test.LogLevelConstants; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import com.itextpdf.test.pdfa.VeraPdfValidator; // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) import java.io.IOException; import java.io.InputStream; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; +import static org.junit.jupiter.api.Assertions.fail; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfA2AnnotationCheckTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/pdfa/"; public static final String cmpFolder = sourceFolder + "cmp/PdfA2AnnotationCheckTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/pdfa/PdfA2AnnotationCheckTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } @@ -78,15 +77,15 @@ public static void beforeClass() { public void annotationCheckTest01() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); PdfPage page = doc.addNewPage(); Rectangle rect = new Rectangle(100, 650, 400, 100); PdfAnnotation annot = new PdfFileAttachmentAnnotation(rect); page.addAnnotation(annot); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(PdfaExceptionMessageConstant.AN_ANNOTATION_DICTIONARY_SHALL_CONTAIN_THE_F_KEY, e.getMessage()); + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(PdfaExceptionMessageConstant.AN_ANNOTATION_DICTIONARY_SHALL_CONTAIN_THE_F_KEY, e.getMessage()); } @Test @@ -95,7 +94,7 @@ public void annotationCheckTest02() throws IOException, InterruptedException { String cmpPdf = cmpFolder + "cmp_pdfA2b_annotationCheckTest02.pdf"; PdfWriter writer = new PdfWriter(outPdf); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); PdfPage page = doc.addNewPage(); Rectangle rect = new Rectangle(100, 650, 400, 100); @@ -112,7 +111,7 @@ public void annotationCheckTest03() throws IOException, InterruptedException { String cmpPdf = cmpFolder + "cmp_pdfA2b_annotationCheckTest03.pdf"; PdfWriter writer = new PdfWriter(outPdf); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); PdfPage page = doc.addNewPage(); Rectangle rect = new Rectangle(100, 100, 0, 0); @@ -129,7 +128,7 @@ public void annotationCheckTest03() throws IOException, InterruptedException { public void annotationCheckTest04() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); PdfPage page = doc.addNewPage(); Rectangle rect = new Rectangle(100, 650, 400, 100); @@ -139,15 +138,15 @@ public void annotationCheckTest04() throws IOException { page.addAnnotation(annot); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(PdfaExceptionMessageConstant.EVERY_ANNOTATION_SHALL_HAVE_AT_LEAST_ONE_APPEARANCE_DICTIONARY, e.getMessage()); + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(PdfaExceptionMessageConstant.EVERY_ANNOTATION_SHALL_HAVE_AT_LEAST_ONE_APPEARANCE_DICTIONARY, e.getMessage()); } @Test public void annotationCheckTest05() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); PdfPage page = doc.addNewPage(); Rectangle rect = new Rectangle(100, 650, 400, 100); @@ -156,8 +155,8 @@ public void annotationCheckTest05() throws IOException { page.addAnnotation(annot); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(PdfaExceptionMessageConstant.THE_F_KEYS_PRINT_FLAG_BIT_SHALL_BE_SET_TO_1_AND_ITS_HIDDEN_INVISIBLE_NOVIEW_AND_TOGGLENOVIEW_FLAG_BITS_SHALL_BE_SET_TO_0, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(PdfaExceptionMessageConstant.THE_F_KEYS_PRINT_FLAG_BIT_SHALL_BE_SET_TO_1_AND_ITS_HIDDEN_INVISIBLE_NOVIEW_AND_TOGGLENOVIEW_FLAG_BITS_SHALL_BE_SET_TO_0, e.getMessage()); } @@ -165,7 +164,7 @@ public void annotationCheckTest05() throws IOException { public void annotationCheckTest06() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); PdfPage page = doc.addNewPage(); Rectangle rect = new Rectangle(100, 650, 400, 100); @@ -174,8 +173,8 @@ public void annotationCheckTest06() throws IOException { page.addAnnotation(annot); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(PdfaExceptionMessageConstant.THE_F_KEYS_PRINT_FLAG_BIT_SHALL_BE_SET_TO_1_AND_ITS_HIDDEN_INVISIBLE_NOVIEW_AND_TOGGLENOVIEW_FLAG_BITS_SHALL_BE_SET_TO_0, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(PdfaExceptionMessageConstant.THE_F_KEYS_PRINT_FLAG_BIT_SHALL_BE_SET_TO_1_AND_ITS_HIDDEN_INVISIBLE_NOVIEW_AND_TOGGLENOVIEW_FLAG_BITS_SHALL_BE_SET_TO_0, e.getMessage()); } @@ -183,7 +182,7 @@ public void annotationCheckTest06() throws IOException { public void annotationCheckTest07() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); PdfPage page = doc.addNewPage(); Rectangle rect = new Rectangle(100, 650, 400, 100); @@ -197,8 +196,8 @@ public void annotationCheckTest07() throws IOException { page.addAnnotation(annot); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(PdfaExceptionMessageConstant.APPEARANCE_DICTIONARY_SHALL_CONTAIN_ONLY_THE_N_KEY_WITH_STREAM_VALUE, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(PdfaExceptionMessageConstant.APPEARANCE_DICTIONARY_SHALL_CONTAIN_ONLY_THE_N_KEY_WITH_STREAM_VALUE, e.getMessage()); } @@ -206,7 +205,7 @@ public void annotationCheckTest07() throws IOException { public void annotationCheckTest08() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); PdfPage page = doc.addNewPage(); Rectangle rect = new Rectangle(100, 650, 400, 100); @@ -220,8 +219,8 @@ public void annotationCheckTest08() throws IOException { page.addAnnotation(annot); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(PdfaExceptionMessageConstant.APPEARANCE_DICTIONARY_OF_WIDGET_SUBTYPE_AND_BTN_FIELD_TYPE_SHALL_CONTAIN_ONLY_THE_N_KEY_WITH_DICTIONARY_VALUE, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(PdfaExceptionMessageConstant.APPEARANCE_DICTIONARY_OF_WIDGET_SUBTYPE_AND_BTN_FIELD_TYPE_SHALL_CONTAIN_ONLY_THE_N_KEY_WITH_DICTIONARY_VALUE, e.getMessage()); } @@ -229,7 +228,7 @@ public void annotationCheckTest08() throws IOException { public void annotationCheckTest09() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); PdfPage page = doc.addNewPage(); Rectangle rect = new Rectangle(100, 650, 400, 100); @@ -241,8 +240,8 @@ public void annotationCheckTest09() throws IOException { page.addAnnotation(annot); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(PdfaExceptionMessageConstant.APPEARANCE_DICTIONARY_SHALL_CONTAIN_ONLY_THE_N_KEY_WITH_STREAM_VALUE, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(PdfaExceptionMessageConstant.APPEARANCE_DICTIONARY_SHALL_CONTAIN_ONLY_THE_N_KEY_WITH_STREAM_VALUE, e.getMessage()); } @@ -252,7 +251,7 @@ public void annotationCheckTest10() throws IOException, InterruptedException { String cmpPdf = cmpFolder + "cmp_pdfA2b_annotationCheckTest10.pdf"; PdfWriter writer = new PdfWriter(outPdf); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); PdfPage page = doc.addNewPage(); Rectangle rect = new Rectangle(100, 650, 400, 100); @@ -275,7 +274,7 @@ public void annotationCheckTest11() throws IOException, InterruptedException { PdfWriter writer = new PdfWriter(outPdf); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); PdfPage page = doc.addNewPage(); Rectangle rect = new Rectangle(100, 650, 400, 100); @@ -301,7 +300,7 @@ public void annotationCheckTest12() throws IOException, InterruptedException { PdfWriter writer = new PdfWriter(outPdf); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2A, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2A, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.setTagged(); doc.getCatalog().setLang(new PdfString("en-US")); PdfPage page = doc.addNewPage(); @@ -315,14 +314,14 @@ public void annotationCheckTest12() throws IOException, InterruptedException { doc.close(); compareResult(outPdf, cmpPdf); - Assert.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) } @Test public void annotationCheckTest13() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2A, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2A, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.setTagged(); doc.getCatalog().setLang(new PdfString("en-US")); PdfPage page = doc.addNewPage(); @@ -334,8 +333,8 @@ public void annotationCheckTest13() throws IOException { page.addAnnotation(annot); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(PdfaExceptionMessageConstant.EVERY_ANNOTATION_SHALL_HAVE_AT_LEAST_ONE_APPEARANCE_DICTIONARY, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(PdfaExceptionMessageConstant.EVERY_ANNOTATION_SHALL_HAVE_AT_LEAST_ONE_APPEARANCE_DICTIONARY, e.getMessage()); } @@ -345,7 +344,7 @@ public void annotationCheckTest14() throws IOException, InterruptedException { String cmpPdf = cmpFolder + "cmp_pdfA2a_annotationCheckTest14.pdf"; PdfWriter writer = new PdfWriter(outPdf); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2A, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2A, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.setTagged(); doc.getCatalog().setLang(new PdfString("en-US")); diff --git a/pdfa/src/test/java/com/itextpdf/pdfa/PdfA2CanvasCheckTest.java b/pdfa/src/test/java/com/itextpdf/pdfa/PdfA2CanvasCheckTest.java index 1cc044cb31..4c793d828d 100644 --- a/pdfa/src/test/java/com/itextpdf/pdfa/PdfA2CanvasCheckTest.java +++ b/pdfa/src/test/java/com/itextpdf/pdfa/PdfA2CanvasCheckTest.java @@ -24,7 +24,7 @@ This file is part of the iText (R) project. import com.itextpdf.commons.utils.FileUtil; import com.itextpdf.io.source.ByteArrayOutputStream; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfAConformance; import com.itextpdf.kernel.pdf.PdfName; import com.itextpdf.kernel.pdf.PdfOutputIntent; import com.itextpdf.kernel.pdf.PdfWriter; @@ -33,23 +33,21 @@ This file is part of the iText (R) project. import com.itextpdf.pdfa.exceptions.PdfAConformanceException; import com.itextpdf.pdfa.exceptions.PdfaExceptionMessageConstant; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; +import static org.junit.jupiter.api.Assertions.fail; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfA2CanvasCheckTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/pdfa/"; public static final String destinationFolder = "./target/test/com/itextpdf/pdfa/PdfA2CanvasCheckTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } @@ -60,18 +58,18 @@ public void canvasCheckTest1() throws IOException { InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - try (PdfADocument pdfDocument = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, outputIntent)) { + try (PdfADocument pdfDocument = new PdfADocument(writer, PdfAConformance.PDF_A_2B, outputIntent)) { pdfDocument.addNewPage(); PdfCanvas canvas = new PdfCanvas(pdfDocument.getLastPage()); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> { for (int i = 0; i < 29; i++) { canvas.saveState(); } } ); - Assert.assertEquals(PdfaExceptionMessageConstant.GRAPHICS_STATE_STACK_DEPTH_IS_GREATER_THAN_28, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.GRAPHICS_STATE_STACK_DEPTH_IS_GREATER_THAN_28, e.getMessage()); } } @@ -84,7 +82,7 @@ public void canvasCheckTest2() throws IOException, InterruptedException { InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - try (PdfADocument pdfDocument = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, outputIntent)) { + try (PdfADocument pdfDocument = new PdfADocument(writer, PdfAConformance.PDF_A_2B, outputIntent)) { pdfDocument.addNewPage(); PdfCanvas canvas = new PdfCanvas(pdfDocument.getLastPage()); @@ -110,14 +108,14 @@ public void canvasCheckTest3() throws IOException { InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - try (PdfADocument pdfDocument = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, outputIntent)) { + try (PdfADocument pdfDocument = new PdfADocument(writer, PdfAConformance.PDF_A_2B, outputIntent)) { pdfDocument.addNewPage(); PdfCanvas canvas = new PdfCanvas(pdfDocument.getLastPage()); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> canvas.setRenderingIntent(new PdfName("Test")) ); - Assert.assertEquals( + Assertions.assertEquals( PdfaExceptionMessageConstant.IF_SPECIFIED_RENDERING_SHALL_BE_ONE_OF_THE_FOLLOWING_RELATIVECOLORIMETRIC_ABSOLUTECOLORIMETRIC_PERCEPTUAL_OR_SATURATION, e.getMessage()); } diff --git a/pdfa/src/test/java/com/itextpdf/pdfa/PdfA2CatalogCheckTest.java b/pdfa/src/test/java/com/itextpdf/pdfa/PdfA2CatalogCheckTest.java index 3d5c8cb538..592efd1a63 100644 --- a/pdfa/src/test/java/com/itextpdf/pdfa/PdfA2CatalogCheckTest.java +++ b/pdfa/src/test/java/com/itextpdf/pdfa/PdfA2CatalogCheckTest.java @@ -24,7 +24,7 @@ This file is part of the iText (R) project. import com.itextpdf.commons.utils.FileUtil; import com.itextpdf.io.source.ByteArrayOutputStream; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfAConformance; import com.itextpdf.kernel.pdf.PdfArray; import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.kernel.pdf.PdfName; @@ -35,28 +35,25 @@ This file is part of the iText (R) project. import com.itextpdf.pdfa.exceptions.PdfAConformanceException; import com.itextpdf.pdfa.exceptions.PdfaExceptionMessageConstant; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import com.itextpdf.test.pdfa.VeraPdfValidator; // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfA2CatalogCheckTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/pdfa/"; public static final String cmpFolder = sourceFolder + "cmp/PdfA2CatalogCheckTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/pdfa/PdfA2CatalogCheckTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } @@ -67,7 +64,7 @@ public void catalogCheck03() throws IOException, InterruptedException { String cmpPdf = cmpFolder + "cmp_pdfA2b_catalogCheck03.pdf"; PdfWriter writer = new PdfWriter(outPdf); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.addNewPage(); PdfDictionary ocProperties = new PdfDictionary(); PdfDictionary d = new PdfDictionary(); @@ -86,7 +83,7 @@ public void catalogCheck03() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) compareResult(outPdf, cmpPdf); } @@ -94,7 +91,7 @@ public void catalogCheck03() throws IOException, InterruptedException { public void catalogCheck04() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.addNewPage(); PdfDictionary ocProperties = new PdfDictionary(); PdfDictionary d = new PdfDictionary(); @@ -110,8 +107,8 @@ public void catalogCheck04() throws IOException { doc.getCatalog().put(PdfName.OCProperties, ocProperties); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(PdfaExceptionMessageConstant.OPTIONAL_CONTENT_CONFIGURATION_DICTIONARY_SHALL_CONTAIN_NAME_ENTRY, e.getMessage()); + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(PdfaExceptionMessageConstant.OPTIONAL_CONTENT_CONFIGURATION_DICTIONARY_SHALL_CONTAIN_NAME_ENTRY, e.getMessage()); } @Test @@ -120,7 +117,7 @@ public void catalogCheck05() throws IOException, InterruptedException { String cmpPdf = cmpFolder + "cmp_pdfA2b_catalogCheck05.pdf"; PdfWriter writer = new PdfWriter(outPdf); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.addNewPage(); PdfDictionary ocProperties = new PdfDictionary(); PdfDictionary d = new PdfDictionary(); @@ -153,7 +150,7 @@ public void catalogCheck05() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) compareResult(outPdf, cmpPdf); } diff --git a/pdfa/src/test/java/com/itextpdf/pdfa/PdfA2EmbeddedFilesCheckTest.java b/pdfa/src/test/java/com/itextpdf/pdfa/PdfA2EmbeddedFilesCheckTest.java index 878654e0ab..fce6fadb7f 100644 --- a/pdfa/src/test/java/com/itextpdf/pdfa/PdfA2EmbeddedFilesCheckTest.java +++ b/pdfa/src/test/java/com/itextpdf/pdfa/PdfA2EmbeddedFilesCheckTest.java @@ -26,7 +26,7 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.font.PdfFont; import com.itextpdf.kernel.font.PdfFontFactory; import com.itextpdf.kernel.font.PdfFontFactory.EmbeddingStrategy; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfAConformance; import com.itextpdf.kernel.pdf.PdfName; import com.itextpdf.kernel.pdf.PdfOutputIntent; import com.itextpdf.kernel.pdf.PdfPage; @@ -38,24 +38,23 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; +import static org.junit.jupiter.api.Assertions.fail; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfA2EmbeddedFilesCheckTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/pdfa/"; public static final String cmpFolder = sourceFolder + "cmp/PdfA2EmbeddedFilesCheckTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/pdfa/PdfA2EmbeddedFilesCheckTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } @@ -73,7 +72,7 @@ public void fileSpecNonConformingTest01() throws IOException, InterruptedExcepti PdfWriter writer = new PdfWriter(outPdf); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - PdfADocument pdfDocument = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, outputIntent); + PdfADocument pdfDocument = new PdfADocument(writer, PdfAConformance.PDF_A_2B, outputIntent); PdfPage page = pdfDocument.addNewPage(); PdfFont font = PdfFontFactory.createFont(sourceFolder + "FreeSans.ttf", @@ -107,7 +106,7 @@ public void fileSpecCheckTest02() throws IOException, InterruptedException { PdfWriter writer = new PdfWriter(outPdf); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - PdfADocument pdfDocument = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, outputIntent); + PdfADocument pdfDocument = new PdfADocument(writer, PdfAConformance.PDF_A_2B, outputIntent); PdfPage page = pdfDocument.addNewPage(); PdfFont font = PdfFontFactory.createFont(sourceFolder + "FreeSans.ttf", @@ -143,7 +142,7 @@ public void fileSpecCheckTest03() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - PdfADocument pdfDocument = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, outputIntent); + PdfADocument pdfDocument = new PdfADocument(writer, PdfAConformance.PDF_A_2B, outputIntent); PdfPage page = pdfDocument.addNewPage(); PdfFont font = PdfFontFactory.createFont(sourceFolder + "FreeSans.ttf", diff --git a/pdfa/src/test/java/com/itextpdf/pdfa/PdfA2GraphicsCheckTest.java b/pdfa/src/test/java/com/itextpdf/pdfa/PdfA2GraphicsCheckTest.java index e0535588b3..d4fbbd98af 100644 --- a/pdfa/src/test/java/com/itextpdf/pdfa/PdfA2GraphicsCheckTest.java +++ b/pdfa/src/test/java/com/itextpdf/pdfa/PdfA2GraphicsCheckTest.java @@ -33,7 +33,7 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.font.PdfFont; import com.itextpdf.kernel.font.PdfFontFactory; import com.itextpdf.kernel.font.PdfFontFactory.EmbeddingStrategy; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfAConformance; import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfName; @@ -55,25 +55,24 @@ This file is part of the iText (R) project. import com.itextpdf.pdfa.exceptions.PdfAConformanceException; import com.itextpdf.pdfa.exceptions.PdfaExceptionMessageConstant; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.util.Collections; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; +import static org.junit.jupiter.api.Assertions.fail; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfA2GraphicsCheckTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/pdfa/"; public static final String cmpFolder = sourceFolder + "cmp/PdfA2GraphicsCheckTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/pdfa/PdfA2GraphicsCheckTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } @@ -84,7 +83,7 @@ public void colorCheckTest1() throws IOException { InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - try (PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, outputIntent)) { + try (PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2B, outputIntent)) { float[] whitePoint = {0.9505f, 1f, 1.089f}; float[] gamma = {2.2f, 2.2f, 2.2f}; @@ -95,10 +94,10 @@ public void colorCheckTest1() throws IOException { canvas.getResources().setDefaultCmyk(calRgb); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> canvas.setFillColor(new DeviceCmyk(0.1f, 0.1f, 0.1f, 0.1f)) ); - Assert.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.COLOR_SPACE_0_SHALL_HAVE_1_COMPONENTS, + Assertions.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.COLOR_SPACE_0_SHALL_HAVE_1_COMPONENTS, PdfName.DefaultCMYK.getValue(), 4), e.getMessage()); } } @@ -109,7 +108,7 @@ public void colorCheckTest2() throws IOException, InterruptedException { String cmpPdf = cmpFolder + "cmp_pdfA2b_colorCheckTest2.pdf"; PdfWriter writer = new PdfWriter(outPdf); - try (PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, null)) { + try (PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2B, null)) { float[] whitePoint = {0.9505f, 1f, 1.089f}; float[] gamma = {2.2f, 2.2f, 2.2f}; @@ -140,7 +139,7 @@ public void colorCheckTest3() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, outputIntent); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2B, outputIntent); PdfCanvas canvas = new PdfCanvas(doc.addNewPage()); @@ -150,10 +149,10 @@ public void colorCheckTest3() throws IOException { canvas.lineTo(doc.getDefaultPageSize().getRight(), doc.getDefaultPageSize().getTop()); canvas.fill(); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close() ); - Assert.assertEquals(PdfaExceptionMessageConstant.DEVICECMYK_MAY_BE_USED_ONLY_IF_THE_FILE_HAS_A_CMYK_PDFA_OUTPUT_INTENT_OR_DEFAULTCMYK_IN_USAGE_CONTEXT, + Assertions.assertEquals(PdfaExceptionMessageConstant.DEVICECMYK_MAY_BE_USED_ONLY_IF_THE_FILE_HAS_A_CMYK_PDFA_OUTPUT_INTENT_OR_DEFAULTCMYK_IN_USAGE_CONTEXT, e.getMessage()); } @@ -164,7 +163,7 @@ public void colorCheckTest4() throws IOException, InterruptedException { PdfWriter writer = new PdfWriter(outPdf); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, outputIntent); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2B, outputIntent); PdfCanvas canvas = new PdfCanvas(doc.addNewPage()); @@ -181,8 +180,8 @@ public void colorCheckTest4() throws IOException, InterruptedException { canvas.lineTo(doc.getDefaultPageSize().getRight(), doc.getDefaultPageSize().getTop()); canvas.fill(); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(PdfaExceptionMessageConstant.DEVICECMYK_MAY_BE_USED_ONLY_IF_THE_FILE_HAS_A_CMYK_PDFA_OUTPUT_INTENT_OR_DEFAULTCMYK_IN_USAGE_CONTEXT, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(PdfaExceptionMessageConstant.DEVICECMYK_MAY_BE_USED_ONLY_IF_THE_FILE_HAS_A_CMYK_PDFA_OUTPUT_INTENT_OR_DEFAULTCMYK_IN_USAGE_CONTEXT, e.getMessage()); } @@ -191,7 +190,7 @@ public void colorCheckTest5() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, outputIntent); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2B, outputIntent); PdfCanvas canvas = new PdfCanvas(doc.addNewPage()); @@ -209,8 +208,8 @@ public void colorCheckTest5() throws IOException { canvas.setTextRenderingMode(PdfCanvasConstants.TextRenderingMode.FILL); canvas.setFillColor(DeviceGray.GRAY).beginText().showText(shortText).endText(); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(PdfaExceptionMessageConstant.DEVICECMYK_MAY_BE_USED_ONLY_IF_THE_FILE_HAS_A_CMYK_PDFA_OUTPUT_INTENT_OR_DEFAULTCMYK_IN_USAGE_CONTEXT, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(PdfaExceptionMessageConstant.DEVICECMYK_MAY_BE_USED_ONLY_IF_THE_FILE_HAS_A_CMYK_PDFA_OUTPUT_INTENT_OR_DEFAULTCMYK_IN_USAGE_CONTEXT, e.getMessage()); } @@ -221,7 +220,7 @@ public void colorCheckTest6() throws IOException, InterruptedException { PdfWriter writer = new PdfWriter(outPdf); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, outputIntent); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2B, outputIntent); PdfCanvas canvas = new PdfCanvas(doc.addNewPage()); @@ -236,8 +235,8 @@ public void colorCheckTest6() throws IOException, InterruptedException { canvas.setFillColor(DeviceGray.GRAY).beginText().showText(shortText).endText(); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(PdfaExceptionMessageConstant.DEVICECMYK_MAY_BE_USED_ONLY_IF_THE_FILE_HAS_A_CMYK_PDFA_OUTPUT_INTENT_OR_DEFAULTCMYK_IN_USAGE_CONTEXT, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(PdfaExceptionMessageConstant.DEVICECMYK_MAY_BE_USED_ONLY_IF_THE_FILE_HAS_A_CMYK_PDFA_OUTPUT_INTENT_OR_DEFAULTCMYK_IN_USAGE_CONTEXT, e.getMessage()); } @@ -248,7 +247,7 @@ public void colorCheckTest7() throws IOException, InterruptedException { PdfWriter writer = new PdfWriter(outPdf); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, outputIntent); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2B, outputIntent); PdfCanvas canvas = new PdfCanvas(doc.addNewPage()); @@ -266,8 +265,8 @@ public void colorCheckTest7() throws IOException, InterruptedException { canvas.setTextRenderingMode(PdfCanvasConstants.TextRenderingMode.INVISIBLE); canvas.setFillColor(new DeviceCmyk(0.1f, 0.1f, 0.1f, 0.1f)).beginText().showText(shortText).endText(); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(PdfaExceptionMessageConstant.DEVICECMYK_MAY_BE_USED_ONLY_IF_THE_FILE_HAS_A_CMYK_PDFA_OUTPUT_INTENT_OR_DEFAULTCMYK_IN_USAGE_CONTEXT, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(PdfaExceptionMessageConstant.DEVICECMYK_MAY_BE_USED_ONLY_IF_THE_FILE_HAS_A_CMYK_PDFA_OUTPUT_INTENT_OR_DEFAULTCMYK_IN_USAGE_CONTEXT, e.getMessage()); } @@ -275,7 +274,7 @@ public void colorCheckTest7() throws IOException, InterruptedException { public void defaultTextColorCheckTest() throws IOException { String outPdf = destinationFolder + "defaultColorCheck.pdf"; - PdfDocument pdfDocument = new PdfADocument(new PdfWriter(outPdf), PdfAConformanceLevel.PDF_A_2B, null); + PdfDocument pdfDocument = new PdfADocument(new PdfWriter(outPdf), PdfAConformance.PDF_A_2B, null); PdfFont font = PdfFontFactory.createFont(sourceFolder + "FreeSans.ttf", "Identity-H", EmbeddingStrategy.FORCE_EMBEDDED); @@ -289,8 +288,8 @@ public void defaultTextColorCheckTest() throws IOException { .endText() .restoreState(); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> pdfDocument.close()); - Assert.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.IF_DEVICE_RGB_CMYK_GRAY_USED_IN_FILE_THAT_FILE_SHALL_CONTAIN_PDFA_OUTPUTINTENT_OR_DEFAULT_RGB_CMYK_GRAY_IN_USAGE_CONTEXT), + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfDocument.close()); + Assertions.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.IF_DEVICE_RGB_CMYK_GRAY_USED_IN_FILE_THAT_FILE_SHALL_CONTAIN_PDFA_OUTPUTINTENT_OR_DEFAULT_RGB_CMYK_GRAY_IN_USAGE_CONTEXT), e.getMessage()); } @@ -299,7 +298,7 @@ public void defaultTextColorCheckForInvisibleTextTest() throws IOException, Inte String outPdf = destinationFolder + "defaultColorCheckInvisibleText.pdf"; String cmpPdf = cmpFolder + "cmp_pdfA2b_defaultColorCheckInvisibleText.pdf"; - PdfDocument pdfDocument = new PdfADocument(new PdfWriter(outPdf), PdfAConformanceLevel.PDF_A_2B, null); + PdfDocument pdfDocument = new PdfADocument(new PdfWriter(outPdf), PdfAConformance.PDF_A_2B, null); PdfFont font = PdfFontFactory.createFont(sourceFolder + "FreeSans.ttf", "Identity-H", EmbeddingStrategy.FORCE_EMBEDDED); @@ -322,7 +321,7 @@ public void defaultTextColorCheckForInvisibleTextTest() throws IOException, Inte public void defaultStrokeColorCheckTest() throws IOException { String outPdf = destinationFolder + "defaultColorCheck.pdf"; - PdfDocument pdfDocument = new PdfADocument(new PdfWriter(outPdf), PdfAConformanceLevel.PDF_A_2B, null); + PdfDocument pdfDocument = new PdfADocument(new PdfWriter(outPdf), PdfAConformance.PDF_A_2B, null); PdfPage page = pdfDocument.addNewPage(); PdfCanvas canvas = new PdfCanvas(page); canvas.saveState(); @@ -338,8 +337,8 @@ public void defaultStrokeColorCheckTest() throws IOException { canvas.stroke(); // We set fill color but stroked so the exception should be thrown - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> pdfDocument.close()); - Assert.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.IF_DEVICE_RGB_CMYK_GRAY_USED_IN_FILE_THAT_FILE_SHALL_CONTAIN_PDFA_OUTPUTINTENT_OR_DEFAULT_RGB_CMYK_GRAY_IN_USAGE_CONTEXT), + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfDocument.close()); + Assertions.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.IF_DEVICE_RGB_CMYK_GRAY_USED_IN_FILE_THAT_FILE_SHALL_CONTAIN_PDFA_OUTPUTINTENT_OR_DEFAULT_RGB_CMYK_GRAY_IN_USAGE_CONTEXT), e.getMessage()); } @@ -348,15 +347,15 @@ public void egsCheckTest1() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, outputIntent); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2B, outputIntent); doc.addNewPage(); PdfCanvas canvas = new PdfCanvas(doc.getLastPage()); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> canvas.setExtGState(new PdfExtGState().put(PdfName.HTP, new PdfName("Test"))) ); - Assert.assertEquals(PdfaExceptionMessageConstant.AN_EXTGSTATE_DICTIONARY_SHALL_NOT_CONTAIN_THE_HTP_KEY, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.AN_EXTGSTATE_DICTIONARY_SHALL_NOT_CONTAIN_THE_HTP_KEY, e.getMessage()); canvas.rectangle(30, 30, 100, 100).fill(); doc.close(); @@ -368,7 +367,7 @@ public void egsCheckTest2() throws IOException { InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - try (PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, outputIntent)) { + try (PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2B, outputIntent)) { doc.addNewPage(); PdfCanvas canvas = new PdfCanvas(doc.getLastPage()); @@ -377,10 +376,10 @@ public void egsCheckTest2() throws IOException { dict.put(PdfName.HalftoneType, new PdfNumber(5)); dict.put(PdfName.HalftoneName, new PdfName("Test")); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> canvas.setExtGState(new PdfExtGState().setHalftone(dict)) ); - Assert.assertEquals(PdfaExceptionMessageConstant.HALFTONES_SHALL_NOT_CONTAIN_HALFTONENAME, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.HALFTONES_SHALL_NOT_CONTAIN_HALFTONENAME, e.getMessage()); } } @@ -389,15 +388,15 @@ public void imageCheckTest1() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, outputIntent); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2B, outputIntent); doc.addNewPage(); PdfCanvas canvas = new PdfCanvas(doc.getLastPage()); canvas.addImageAt(ImageDataFactory.create(sourceFolder + "jpeg2000/p0_01.j2k"), 300, 300, false); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(PdfaExceptionMessageConstant.ONLY_JPX_BASELINE_SET_OF_FEATURES_SHALL_BE_USED, e.getMessage()); + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(PdfaExceptionMessageConstant.ONLY_JPX_BASELINE_SET_OF_FEATURES_SHALL_BE_USED, e.getMessage()); } @Test @@ -405,15 +404,15 @@ public void imageCheckTest2() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, outputIntent); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2B, outputIntent); doc.addNewPage(); PdfCanvas canvas = new PdfCanvas(doc.getLastPage()); canvas.addImageAt(ImageDataFactory.create(sourceFolder + "jpeg2000/file5.jp2"), 300, 300, false); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(PdfaExceptionMessageConstant.EXACTLY_ONE_COLOUR_SPACE_SPECIFICATION_SHALL_HAVE_THE_VALUE_0X01_IN_THE_APPROX_FIELD, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(PdfaExceptionMessageConstant.EXACTLY_ONE_COLOUR_SPACE_SPECIFICATION_SHALL_HAVE_THE_VALUE_0X01_IN_THE_APPROX_FIELD, e.getMessage()); } @@ -422,15 +421,15 @@ public void imageCheckTest3() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, outputIntent); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2B, outputIntent); doc.addNewPage(); PdfCanvas canvas = new PdfCanvas(doc.getLastPage()); canvas.addImageAt(ImageDataFactory.create(sourceFolder + "jpeg2000/file7.jp2"), 300, 300, false); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(PdfaExceptionMessageConstant.EXACTLY_ONE_COLOUR_SPACE_SPECIFICATION_SHALL_HAVE_THE_VALUE_0X01_IN_THE_APPROX_FIELD, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(PdfaExceptionMessageConstant.EXACTLY_ONE_COLOUR_SPACE_SPECIFICATION_SHALL_HAVE_THE_VALUE_0X01_IN_THE_APPROX_FIELD, e.getMessage()); } @@ -449,7 +448,7 @@ public void imageCheckTest4() throws IOException, InterruptedException { PdfWriter writer = new PdfWriter(outPdf); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, outputIntent); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2B, outputIntent); PdfCanvas canvas; @@ -471,7 +470,7 @@ public void imageCheckTest4() throws IOException, InterruptedException { @Test public void transparencyCheckTest1() { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, null); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2B, null); PdfCanvas canvas = new PdfCanvas(doc.addNewPage()); @@ -487,8 +486,8 @@ public void transparencyCheckTest1() { canvas.fill(); canvas.restoreState(); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(PdfaExceptionMessageConstant.THE_DOCUMENT_DOES_NOT_CONTAIN_A_PDFA_OUTPUTINTENT_BUT_PAGE_CONTAINS_TRANSPARENCY_AND_DOES_NOT_CONTAIN_BLENDING_COLOR_SPACE, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(PdfaExceptionMessageConstant.THE_DOCUMENT_DOES_NOT_CONTAIN_A_PDFA_OUTPUTINTENT_BUT_PAGE_CONTAINS_TRANSPARENCY_AND_DOES_NOT_CONTAIN_BLENDING_COLOR_SPACE, e.getMessage()); } @@ -499,7 +498,7 @@ public void transparencyCheckTest2() throws IOException, InterruptedException { PdfWriter writer = new PdfWriter(outPdf); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, outputIntent); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2B, outputIntent); PdfCanvas canvas = new PdfCanvas(doc.addNewPage()); @@ -525,7 +524,7 @@ public void transparencyCheckTest3() throws IOException { InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - try (PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, outputIntent)) { + try (PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2B, outputIntent)) { PdfCanvas canvas = new PdfCanvas(doc.addNewPage()); @@ -536,10 +535,10 @@ public void transparencyCheckTest3() throws IOException { canvas.restoreState(); canvas.saveState(); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> canvas.setExtGState(new PdfExtGState().setBlendMode(new PdfName("UnknownBlendMode"))) ); - Assert.assertEquals( + Assertions.assertEquals( PdfaExceptionMessageConstant.ONLY_STANDARD_BLEND_MODES_SHALL_BE_USED_FOR_THE_VALUE_OF_THE_BM_KEY_IN_AN_EXTENDED_GRAPHIC_STATE_DICTIONARY, e.getMessage()); } @@ -549,7 +548,7 @@ public void transparencyCheckTest3() throws IOException { public void colourSpaceTest01() throws IOException { PdfWriter writer = new PdfWriter(new com.itextpdf.io.source.ByteArrayOutputStream()); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); PdfPage page = doc.addNewPage(); PdfColorSpace alternateSpace= new PdfDeviceCs.Rgb(); @@ -573,7 +572,7 @@ public void colourSpaceTest01() throws IOException { public void colourSpaceTest02() throws IOException { PdfWriter writer = new PdfWriter(new com.itextpdf.io.source.ByteArrayOutputStream()); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); PdfPage page = doc.addNewPage(); PdfColorSpace alternateSpace= new PdfDeviceCs.Rgb(); @@ -596,7 +595,7 @@ public void colourSpaceTest02() throws IOException { public void colourSpaceTest03() throws IOException { PdfWriter writer = new PdfWriter(new com.itextpdf.io.source.ByteArrayOutputStream()); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); PdfPage page = doc.addNewPage(); PdfColorSpace alternateSpace= new PdfDeviceCs.Rgb(); @@ -627,7 +626,7 @@ public void colourSpaceTest03() throws IOException { public void colourSpaceWithoutColourantsTest() throws IOException { PdfWriter writer = new PdfWriter(new com.itextpdf.io.source.ByteArrayOutputStream()); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); PdfPage page = doc.addNewPage(); PdfColorSpace alternateSpace= new PdfDeviceCs.Rgb(); @@ -648,9 +647,9 @@ public void colourSpaceWithoutColourantsTest() throws IOException { PdfDictionary colorantsDict = new PdfDictionary(); colorantsDict.put(new PdfName(separationName), new PdfSpecialCs.Separation(separationName, alternateSpace,type2).getPdfObject()); DeviceN deviceN = new DeviceN(new PdfSpecialCs.NChannel(Collections.singletonList(separationName), alternateSpace, type2, attributes), new float[]{0.5f}); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> canvas.setColor(deviceN, true)); - Assert.assertEquals(PdfaExceptionMessageConstant.COLORANTS_DICTIONARY_SHALL_NOT_BE_EMPTY_IN_DEVICE_N_COLORSPACE, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.COLORANTS_DICTIONARY_SHALL_NOT_BE_EMPTY_IN_DEVICE_N_COLORSPACE, e.getMessage()); doc.close(); } @@ -658,7 +657,7 @@ public void colourSpaceWithoutColourantsTest() throws IOException { public void colourSpaceWithoutAttributesTest() throws IOException { PdfWriter writer = new PdfWriter(new com.itextpdf.io.source.ByteArrayOutputStream()); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); PdfPage page = doc.addNewPage(); PdfColorSpace alternateSpace= new PdfDeviceCs.Rgb(); @@ -678,9 +677,9 @@ public void colourSpaceWithoutAttributesTest() throws IOException { PdfDictionary colorantsDict = new PdfDictionary(); colorantsDict.put(new PdfName(separationName), new PdfSpecialCs.Separation(separationName, alternateSpace,type2).getPdfObject()); DeviceN deviceN = new DeviceN(new PdfSpecialCs.DeviceN(Collections.singletonList(separationName), alternateSpace, type2), new float[]{0.5f}); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> canvas.setColor(deviceN, true)); - Assert.assertEquals(PdfaExceptionMessageConstant.COLORANTS_DICTIONARY_SHALL_NOT_BE_EMPTY_IN_DEVICE_N_COLORSPACE, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.COLORANTS_DICTIONARY_SHALL_NOT_BE_EMPTY_IN_DEVICE_N_COLORSPACE, e.getMessage()); doc.close(); } diff --git a/pdfa/src/test/java/com/itextpdf/pdfa/PdfA2LayoutOcgTest.java b/pdfa/src/test/java/com/itextpdf/pdfa/PdfA2LayoutOcgTest.java index d1f79caf78..589924756a 100644 --- a/pdfa/src/test/java/com/itextpdf/pdfa/PdfA2LayoutOcgTest.java +++ b/pdfa/src/test/java/com/itextpdf/pdfa/PdfA2LayoutOcgTest.java @@ -25,7 +25,7 @@ This file is part of the iText (R) project. import com.itextpdf.commons.utils.FileUtil; import com.itextpdf.io.image.ImageDataFactory; import com.itextpdf.kernel.geom.Rectangle; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfAConformance; import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfOutputIntent; import com.itextpdf.kernel.pdf.PdfString; @@ -36,23 +36,22 @@ This file is part of the iText (R) project. import com.itextpdf.layout.Canvas; import com.itextpdf.layout.element.Image; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import com.itextpdf.test.pdfa.VeraPdfValidator; // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) import java.io.IOException; import java.io.InputStream; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfA2LayoutOcgTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/pdfa/"; public static final String destinationFolder = "./target/test/com/itextpdf/pdfa/PdfA2LayoutOcgTest/"; - @Before + @BeforeEach public void configure() { createDestinationFolder(destinationFolder); } @@ -63,7 +62,7 @@ public void checkIfOcgForPdfA2Works() throws IOException, InterruptedException { InputStream colorStream = FileUtil.getInputStreamForFile(sourceFolder + "color/sRGB_CS_profile.icm"); String outFileName = destinationFolder + fileName; String cmpFileName = sourceFolder + "cmp/PdfA2LayoutOcgTest/cmp_" + fileName; - PdfDocument pdfDoc = new PdfADocument(new PdfWriter(outFileName), PdfAConformanceLevel.PDF_A_2A, + PdfDocument pdfDoc = new PdfADocument(new PdfWriter(outFileName), PdfAConformance.PDF_A_2A, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", colorStream)); pdfDoc.setTagged(); pdfDoc.getCatalog().setLang(new PdfString("en-US")); @@ -84,8 +83,8 @@ public void checkIfOcgForPdfA2Works() throws IOException, InterruptedException { canvas1.close(); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff01_")); - Assert.assertNull(new VeraPdfValidator().validate(outFileName)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, destinationFolder, "diff01_")); + Assertions.assertNull(new VeraPdfValidator().validate(outFileName)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) } } diff --git a/pdfa/src/test/java/com/itextpdf/pdfa/PdfA2OCPropertiesTest.java b/pdfa/src/test/java/com/itextpdf/pdfa/PdfA2OCPropertiesTest.java index 8f9fde0b7b..a1001c38ce 100644 --- a/pdfa/src/test/java/com/itextpdf/pdfa/PdfA2OCPropertiesTest.java +++ b/pdfa/src/test/java/com/itextpdf/pdfa/PdfA2OCPropertiesTest.java @@ -23,7 +23,7 @@ This file is part of the iText (R) project. package com.itextpdf.pdfa; import com.itextpdf.commons.utils.FileUtil; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfAConformance; import com.itextpdf.kernel.pdf.PdfArray; import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.kernel.pdf.PdfDocument; @@ -37,22 +37,21 @@ This file is part of the iText (R) project. import com.itextpdf.pdfa.exceptions.PdfAConformanceException; import com.itextpdf.pdfa.exceptions.PdfaExceptionMessageConstant; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import com.itextpdf.test.pdfa.VeraPdfValidator; // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) import java.io.IOException; import java.io.InputStream; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfA2OCPropertiesTest extends ExtendedITextTest { public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/pdfa/"; public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/pdfa/PdfA2OCPropertiesTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(DESTINATION_FOLDER); } @@ -62,7 +61,7 @@ public void checkNameEntryShouldBeUniqueBetweenDefaultAndAdditionalConfigsTest() String outPdf = DESTINATION_FOLDER + "pdfA2b_ocPropertiesCheck01.pdf"; PdfWriter writer = new PdfWriter(outPdf); InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.addNewPage(); PdfDictionary ocProperties = new PdfDictionary(); @@ -77,10 +76,10 @@ public void checkNameEntryShouldBeUniqueBetweenDefaultAndAdditionalConfigsTest() doc.getCatalog().put(PdfName.OCProperties, ocProperties); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close() ); - Assert.assertEquals(PdfaExceptionMessageConstant.VALUE_OF_NAME_ENTRY_SHALL_BE_UNIQUE_AMONG_ALL_OPTIONAL_CONTENT_CONFIGURATION_DICTIONARIES, + Assertions.assertEquals(PdfaExceptionMessageConstant.VALUE_OF_NAME_ENTRY_SHALL_BE_UNIQUE_AMONG_ALL_OPTIONAL_CONTENT_CONFIGURATION_DICTIONARIES, e.getMessage()); } @@ -89,7 +88,7 @@ public void checkAsKeyInContentConfigDictTest() throws IOException { String outPdf = DESTINATION_FOLDER + "pdfA2b_ocPropertiesCheck02.pdf"; PdfWriter writer = new PdfWriter(outPdf); InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.addNewPage(); PdfDictionary ocProperties = new PdfDictionary(); @@ -102,10 +101,10 @@ public void checkAsKeyInContentConfigDictTest() throws IOException { doc.getCatalog().put(PdfName.OCProperties, ocProperties); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close() ); - Assert.assertEquals(PdfaExceptionMessageConstant.THE_AS_KEY_SHALL_NOT_APPEAR_IN_ANY_OPTIONAL_CONTENT_CONFIGURATION_DICTIONARY, + Assertions.assertEquals(PdfaExceptionMessageConstant.THE_AS_KEY_SHALL_NOT_APPEAR_IN_ANY_OPTIONAL_CONTENT_CONFIGURATION_DICTIONARY, e.getMessage()); } @@ -115,7 +114,7 @@ public void checkNameEntryShouldBeUniqueBetweenAdditionalConfigsTest() throws IO String outPdf = DESTINATION_FOLDER + "pdfA2b_ocPropertiesCheck03.pdf"; PdfWriter writer = new PdfWriter(outPdf); InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.addNewPage(); PdfDictionary ocProperties = new PdfDictionary(); @@ -133,10 +132,10 @@ public void checkNameEntryShouldBeUniqueBetweenAdditionalConfigsTest() throws IO doc.getCatalog().put(PdfName.OCProperties, ocProperties); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close() ); - Assert.assertEquals(PdfaExceptionMessageConstant.VALUE_OF_NAME_ENTRY_SHALL_BE_UNIQUE_AMONG_ALL_OPTIONAL_CONTENT_CONFIGURATION_DICTIONARIES, + Assertions.assertEquals(PdfaExceptionMessageConstant.VALUE_OF_NAME_ENTRY_SHALL_BE_UNIQUE_AMONG_ALL_OPTIONAL_CONTENT_CONFIGURATION_DICTIONARIES, e.getMessage()); } @@ -145,7 +144,7 @@ public void checkOCCDContainNameTest() throws IOException { String outPdf = DESTINATION_FOLDER + "pdfA2b_ocPropertiesCheck04.pdf"; PdfWriter writer = new PdfWriter(outPdf); InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.addNewPage(); PdfDictionary ocProperties = new PdfDictionary(); @@ -162,10 +161,10 @@ public void checkOCCDContainNameTest() throws IOException { doc.getCatalog().put(PdfName.OCProperties, ocProperties); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close() ); - Assert.assertEquals(PdfaExceptionMessageConstant.OPTIONAL_CONTENT_CONFIGURATION_DICTIONARY_SHALL_CONTAIN_NAME_ENTRY, + Assertions.assertEquals(PdfaExceptionMessageConstant.OPTIONAL_CONTENT_CONFIGURATION_DICTIONARY_SHALL_CONTAIN_NAME_ENTRY, e.getMessage()); } @@ -174,7 +173,7 @@ public void checkOrderArrayContainsReferencesToAllOCGsTest() throws IOException String outPdf = DESTINATION_FOLDER + "pdfA2b_ocPropertiesCheck05.pdf"; PdfWriter writer = new PdfWriter(outPdf); InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.addNewPage(); PdfDictionary ocProperties = new PdfDictionary(); @@ -204,10 +203,10 @@ public void checkOrderArrayContainsReferencesToAllOCGsTest() throws IOException doc.getCatalog().put(PdfName.OCProperties, ocProperties); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close() ); - Assert.assertEquals(PdfaExceptionMessageConstant.ORDER_ARRAY_SHALL_CONTAIN_REFERENCES_TO_ALL_OCGS, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.ORDER_ARRAY_SHALL_CONTAIN_REFERENCES_TO_ALL_OCGS, e.getMessage()); } @Test @@ -216,7 +215,7 @@ public void checkDocWithOCGsWithoutOptionalOrderEntryTest() throws IOException, String cmpPdf = SOURCE_FOLDER + "cmp_pdfA2b_ocPropertiesCheck06.pdf"; PdfWriter writer = new PdfWriter(outPdf); InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.addNewPage(); PdfDictionary ocProperties = new PdfDictionary(); @@ -235,8 +234,8 @@ public void checkDocWithOCGsWithoutOptionalOrderEntryTest() throws IOException, doc.getCatalog().put(PdfName.OCProperties, ocProperties); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER, "diff01_")); - Assert.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER, "diff01_")); + Assertions.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) } @Test @@ -256,7 +255,7 @@ public void appendModeWithOCGsTest() throws IOException, InterruptedException { configs.add(config); ocProperties.put(PdfName.Configs, configs); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER, "diff01_")); - Assert.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER, "diff01_")); + Assertions.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) } } diff --git a/pdfa/src/test/java/com/itextpdf/pdfa/PdfA2PageCheckTest.java b/pdfa/src/test/java/com/itextpdf/pdfa/PdfA2PageCheckTest.java index 1d1374321c..b21c3ce29f 100644 --- a/pdfa/src/test/java/com/itextpdf/pdfa/PdfA2PageCheckTest.java +++ b/pdfa/src/test/java/com/itextpdf/pdfa/PdfA2PageCheckTest.java @@ -24,7 +24,7 @@ This file is part of the iText (R) project. import com.itextpdf.commons.utils.FileUtil; import com.itextpdf.io.source.ByteArrayOutputStream; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfAConformance; import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.kernel.pdf.PdfName; import com.itextpdf.kernel.pdf.PdfOutputIntent; @@ -33,15 +33,14 @@ This file is part of the iText (R) project. import com.itextpdf.pdfa.exceptions.PdfAConformanceException; import com.itextpdf.pdfa.exceptions.PdfaExceptionMessageConstant; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; import java.io.InputStream; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfA2PageCheckTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/pdfa/"; @@ -49,11 +48,11 @@ public class PdfA2PageCheckTest extends ExtendedITextTest { public void catalogCheck01() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); PdfPage page = doc.addNewPage(); page.getPdfObject().put(PdfName.PresSteps, new PdfDictionary()); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(PdfaExceptionMessageConstant.THE_PAGE_DICTIONARY_SHALL_NOT_CONTAIN_PRESSTEPS_ENTRY, e.getMessage()); + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(PdfaExceptionMessageConstant.THE_PAGE_DICTIONARY_SHALL_NOT_CONTAIN_PRESSTEPS_ENTRY, e.getMessage()); } } diff --git a/pdfa/src/test/java/com/itextpdf/pdfa/PdfA3CatalogCheckTest.java b/pdfa/src/test/java/com/itextpdf/pdfa/PdfA3CatalogCheckTest.java index bdacace050..5be3949678 100644 --- a/pdfa/src/test/java/com/itextpdf/pdfa/PdfA3CatalogCheckTest.java +++ b/pdfa/src/test/java/com/itextpdf/pdfa/PdfA3CatalogCheckTest.java @@ -23,7 +23,7 @@ This file is part of the iText (R) project. package com.itextpdf.pdfa; import com.itextpdf.commons.utils.FileUtil; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfAConformance; import com.itextpdf.kernel.pdf.PdfArray; import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.kernel.pdf.PdfName; @@ -32,23 +32,22 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfWriter; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import com.itextpdf.test.pdfa.VeraPdfValidator; // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) import java.io.IOException; import java.io.InputStream; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfA3CatalogCheckTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/pdfa/"; public static final String cmpFolder = sourceFolder + "cmp/PdfA3CatalogCheckTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/pdfa/PdfA3CatalogCheckTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } @@ -60,7 +59,7 @@ public void catalogCheck01() throws IOException, InterruptedException { PdfWriter writer = new PdfWriter(outPdf); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_3B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_3B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.addNewPage(); PdfDictionary ocProperties = new PdfDictionary(); @@ -79,8 +78,8 @@ public void catalogCheck01() throws IOException, InterruptedException { doc.getCatalog().put(PdfName.OCProperties, ocProperties); doc.close(); - Assert.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder)); + Assertions.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder)); } diff --git a/pdfa/src/test/java/com/itextpdf/pdfa/PdfA3EmbeddedFilesCheckTest.java b/pdfa/src/test/java/com/itextpdf/pdfa/PdfA3EmbeddedFilesCheckTest.java index 2fb5775427..350137b271 100644 --- a/pdfa/src/test/java/com/itextpdf/pdfa/PdfA3EmbeddedFilesCheckTest.java +++ b/pdfa/src/test/java/com/itextpdf/pdfa/PdfA3EmbeddedFilesCheckTest.java @@ -26,7 +26,7 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.font.PdfFont; import com.itextpdf.kernel.font.PdfFontFactory; import com.itextpdf.kernel.font.PdfFontFactory.EmbeddingStrategy; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfAConformance; import com.itextpdf.kernel.pdf.PdfName; import com.itextpdf.kernel.pdf.PdfOutputIntent; import com.itextpdf.kernel.pdf.PdfPage; @@ -35,24 +35,23 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.filespec.PdfFileSpec; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; +import static org.junit.jupiter.api.Assertions.fail; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfA3EmbeddedFilesCheckTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/pdfa/"; public static final String cmpFolder = sourceFolder + "cmp/PdfA3EmbeddedFilesCheckTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/pdfa/PdfA3EmbeddedFilesCheckTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } @@ -64,7 +63,7 @@ public void fileSpecCheckTest01() throws IOException, InterruptedException { PdfWriter writer = new PdfWriter(outPdf); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - PdfADocument pdfDocument = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_3B, outputIntent); + PdfADocument pdfDocument = new PdfADocument(writer, PdfAConformance.PDF_A_3B, outputIntent); PdfPage page = pdfDocument.addNewPage(); PdfFont font = PdfFontFactory.createFont(sourceFolder + "FreeSans.ttf", @@ -94,7 +93,7 @@ public void fileSpecCheckTest02() throws IOException, InterruptedException { PdfWriter writer = new PdfWriter(outPdf); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - PdfADocument pdfDocument = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_3B, outputIntent); + PdfADocument pdfDocument = new PdfADocument(writer, PdfAConformance.PDF_A_3B, outputIntent); PdfPage page = pdfDocument.addNewPage(); PdfFont font = PdfFontFactory.createFont(sourceFolder + "FreeSans.ttf", @@ -125,7 +124,7 @@ public void fileSpecCheckTest03() throws IOException, InterruptedException { PdfWriter writer = new PdfWriter(outPdf); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - PdfADocument pdfDocument = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_3B, outputIntent); + PdfADocument pdfDocument = new PdfADocument(writer, PdfAConformance.PDF_A_3B, outputIntent); PdfPage page = pdfDocument.addNewPage(); PdfFont font = PdfFontFactory.createFont(sourceFolder + "FreeSans.ttf", @@ -154,7 +153,7 @@ public void fileSpecCheckTest04() throws IOException, InterruptedException { PdfWriter writer = new PdfWriter(outPdf); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - PdfADocument pdfDocument = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_3B, outputIntent); + PdfADocument pdfDocument = new PdfADocument(writer, PdfAConformance.PDF_A_3B, outputIntent); PdfPage page = pdfDocument.addNewPage(); PdfFont font = PdfFontFactory.createFont(sourceFolder + "FreeSans.ttf", diff --git a/pdfa/src/test/java/com/itextpdf/pdfa/PdfA4ActionCheckTest.java b/pdfa/src/test/java/com/itextpdf/pdfa/PdfA4ActionCheckTest.java index 5a68ba6bf8..b14b273c02 100644 --- a/pdfa/src/test/java/com/itextpdf/pdfa/PdfA4ActionCheckTest.java +++ b/pdfa/src/test/java/com/itextpdf/pdfa/PdfA4ActionCheckTest.java @@ -27,7 +27,7 @@ This file is part of the iText (R) project. import com.itextpdf.commons.utils.MessageFormatUtil; import com.itextpdf.forms.form.element.CheckBox; import com.itextpdf.kernel.geom.Rectangle; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfAConformance; import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfName; @@ -49,10 +49,8 @@ This file is part of the iText (R) project. import com.itextpdf.pdfa.exceptions.PdfAConformanceException; import com.itextpdf.pdfa.exceptions.PdfaExceptionMessageConstant; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import com.itextpdf.test.pdfa.VeraPdfValidator; // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) -import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; @@ -61,43 +59,43 @@ This file is part of the iText (R) project. import java.util.List; import java.util.UUID; import java.util.function.Consumer; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfA4ActionCheckTest extends ExtendedITextTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/pdfa/"; private static final String CMP_FOLDER = SOURCE_FOLDER + "cmp/PdfA4ActionCheckTest/"; private static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/pdfa/PdfA4ActionCheckTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() throws FileNotFoundException { createOrClearDestinationFolder(DESTINATION_FOLDER); } @Test public void pdfA4ForbiddenActions_LAUNCH_ActionToPage_Test() { - Exception e = Assert.assertThrows(PdfAConformanceException.class, - () -> generatePdfADocument(PdfAConformanceLevel.PDF_A_4, null, (doc) -> { + Exception e = Assertions.assertThrows(PdfAConformanceException.class, + () -> generatePdfADocument(PdfAConformance.PDF_A_4, null, (doc) -> { doc.getFirstPage() .setAdditionalAction(PdfName.O, PdfAction.createLaunch(new PdfStringFS("launch.sh"))); })); - Assert.assertEquals(PdfaExceptionMessageConstant.PAGE_AA_DICTIONARY_SHALL_CONTAIN_ONLY_ALLOWED_KEYS, + Assertions.assertEquals(PdfaExceptionMessageConstant.PAGE_AA_DICTIONARY_SHALL_CONTAIN_ONLY_ALLOWED_KEYS, e.getMessage()); } @Test public void pdfA4ForbiddenActions_SOUND_ActionToPage_Test() { - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> { - generatePdfADocument(PdfAConformanceLevel.PDF_A_4, null, (doc) -> { + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> { + generatePdfADocument(PdfAConformance.PDF_A_4, null, (doc) -> { InputStream is = null; try { is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sample.aif"); } catch (IOException er) { - Assert.fail(er.getMessage()); + Assertions.fail(er.getMessage()); } PdfStream sound1 = new PdfStream(doc, is); sound1.put(PdfName.R, new PdfNumber(32117)); @@ -108,26 +106,26 @@ public void pdfA4ForbiddenActions_SOUND_ActionToPage_Test() { doc.addNewPage().setAdditionalAction(PdfName.O, PdfAction.createSound(sound1)); }); }); - Assert.assertEquals(PdfaExceptionMessageConstant.PAGE_AA_DICTIONARY_SHALL_CONTAIN_ONLY_ALLOWED_KEYS, + Assertions.assertEquals(PdfaExceptionMessageConstant.PAGE_AA_DICTIONARY_SHALL_CONTAIN_ONLY_ALLOWED_KEYS, e.getMessage()); } @Test public void pdfA4ForbiddenActions_MOVIE_ActionToPage_Test() throws FileNotFoundException { - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> { - generatePdfADocument(PdfAConformanceLevel.PDF_A_4, null, (doc) -> { + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> { + generatePdfADocument(PdfAConformance.PDF_A_4, null, (doc) -> { doc.addNewPage() .setAdditionalAction(PdfName.O, PdfAction.createMovie(null, "Some movie", PdfName.Play)); }); }); - Assert.assertEquals(PdfaExceptionMessageConstant.PAGE_AA_DICTIONARY_SHALL_CONTAIN_ONLY_ALLOWED_KEYS, + Assertions.assertEquals(PdfaExceptionMessageConstant.PAGE_AA_DICTIONARY_SHALL_CONTAIN_ONLY_ALLOWED_KEYS, e.getMessage()); } @Test public void pdfA4ForbiddenActions_RESETFORM_ActionToPage_Test() throws FileNotFoundException { - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> { - generatePdfADocument(PdfAConformanceLevel.PDF_A_4, null, (doc) -> { + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> { + generatePdfADocument(PdfAConformance.PDF_A_4, null, (doc) -> { CheckBox checkBox = new CheckBox("test"); checkBox.setChecked(true); Document document = new Document(doc); @@ -135,136 +133,136 @@ public void pdfA4ForbiddenActions_RESETFORM_ActionToPage_Test() throws FileNotFo doc.addNewPage().setAdditionalAction(PdfName.O, PdfAction.createResetForm(new Object[] {"test"}, 0)); }); }); - Assert.assertEquals(PdfaExceptionMessageConstant.PAGE_AA_DICTIONARY_SHALL_CONTAIN_ONLY_ALLOWED_KEYS, + Assertions.assertEquals(PdfaExceptionMessageConstant.PAGE_AA_DICTIONARY_SHALL_CONTAIN_ONLY_ALLOWED_KEYS, e.getMessage()); } @Test public void pdfA4ForbiddenActions_IMPORTDATA_ActionToPage_Test() { - Exception e = Assert.assertThrows(PdfAConformanceException.class, - () -> generatePdfADocument(PdfAConformanceLevel.PDF_A_4, null, (doc) -> { + Exception e = Assertions.assertThrows(PdfAConformanceException.class, + () -> generatePdfADocument(PdfAConformance.PDF_A_4, null, (doc) -> { doc.addNewPage(); PdfDictionary openActions = new PdfDictionary(); openActions.put(PdfName.S, PdfName.ImportData); doc.addNewPage().setAdditionalAction(PdfName.O, new PdfAction(openActions)); })); - Assert.assertEquals(PdfaExceptionMessageConstant.PAGE_AA_DICTIONARY_SHALL_CONTAIN_ONLY_ALLOWED_KEYS, + Assertions.assertEquals(PdfaExceptionMessageConstant.PAGE_AA_DICTIONARY_SHALL_CONTAIN_ONLY_ALLOWED_KEYS, e.getMessage()); } @Test public void pdfA4ForbiddenActions_HIDE_ActionToPage_Test() throws FileNotFoundException { - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> { - generatePdfADocument(PdfAConformanceLevel.PDF_A_4, null, (doc) -> { + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> { + generatePdfADocument(PdfAConformance.PDF_A_4, null, (doc) -> { PdfAnnotation[] annotations = new PdfAnnotation[] { new PdfLineAnnotation(new Rectangle(10, 10, 200, 200), new float[] {50, 750, 50, 750}), new PdfLineAnnotation(new Rectangle(200, 200, 200, 200), new float[] {50, 750, 50, 750})}; doc.addNewPage().setAdditionalAction(PdfName.O, PdfAction.createHide(annotations, true)); }); }); - Assert.assertEquals(PdfaExceptionMessageConstant.PAGE_AA_DICTIONARY_SHALL_CONTAIN_ONLY_ALLOWED_KEYS, + Assertions.assertEquals(PdfaExceptionMessageConstant.PAGE_AA_DICTIONARY_SHALL_CONTAIN_ONLY_ALLOWED_KEYS, e.getMessage()); } @Test public void pdfA4ForbiddenActions_RENDITION_ActionToPage_Test() throws FileNotFoundException { - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> { - generatePdfADocument(PdfAConformanceLevel.PDF_A_4, null, doc -> { + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> { + generatePdfADocument(PdfAConformance.PDF_A_4, null, doc -> { doc.addNewPage().setAdditionalAction(PdfName.O, PdfAction.createRendition("empty", PdfFileSpec.createEmbeddedFileSpec(doc, null, "bing", "bing", new PdfDictionary(), PdfName.AllOn), "something", new PdfCircleAnnotation(new Rectangle(10, 10, 200, 200)))); }); }); - Assert.assertEquals(PdfaExceptionMessageConstant.PAGE_AA_DICTIONARY_SHALL_CONTAIN_ONLY_ALLOWED_KEYS, + Assertions.assertEquals(PdfaExceptionMessageConstant.PAGE_AA_DICTIONARY_SHALL_CONTAIN_ONLY_ALLOWED_KEYS, e.getMessage()); } @Test public void pdfA4ForbiddenActions_TRANS_ActionToPage_Test() throws FileNotFoundException { - Exception e = Assert.assertThrows(PdfAConformanceException.class, - () -> generatePdfADocument(PdfAConformanceLevel.PDF_A_4, null, doc -> { + Exception e = Assertions.assertThrows(PdfAConformanceException.class, + () -> generatePdfADocument(PdfAConformance.PDF_A_4, null, doc -> { PdfDictionary openActions = new PdfDictionary(); openActions.put(PdfName.S, PdfName.Trans); doc.addNewPage().setAdditionalAction(PdfName.O, new PdfAction(openActions)); })); - Assert.assertEquals(PdfaExceptionMessageConstant.PAGE_AA_DICTIONARY_SHALL_CONTAIN_ONLY_ALLOWED_KEYS, + Assertions.assertEquals(PdfaExceptionMessageConstant.PAGE_AA_DICTIONARY_SHALL_CONTAIN_ONLY_ALLOWED_KEYS, e.getMessage()); } @Test public void pdfA4ForbiddenActions_SETSTATE_ActionToPage_Test() throws FileNotFoundException { - Exception e = Assert.assertThrows(PdfAConformanceException.class, - () -> generatePdfADocument(PdfAConformanceLevel.PDF_A_4, null, doc -> { + Exception e = Assertions.assertThrows(PdfAConformanceException.class, + () -> generatePdfADocument(PdfAConformance.PDF_A_4, null, doc -> { PdfDictionary action = new PdfDictionary(); action.put(PdfName.S, PdfName.SetState); doc.addNewPage().setAdditionalAction(PdfName.O, new PdfAction(action)); })); - Assert.assertEquals(PdfaExceptionMessageConstant.PAGE_AA_DICTIONARY_SHALL_CONTAIN_ONLY_ALLOWED_KEYS, + Assertions.assertEquals(PdfaExceptionMessageConstant.PAGE_AA_DICTIONARY_SHALL_CONTAIN_ONLY_ALLOWED_KEYS, e.getMessage()); } @Test public void pdfA4ForbiddenActions_NOOP_ActionToPage_Test() { - Exception e = Assert.assertThrows(PdfAConformanceException.class, - () -> generatePdfADocument(PdfAConformanceLevel.PDF_A_4, null, doc -> { + Exception e = Assertions.assertThrows(PdfAConformanceException.class, + () -> generatePdfADocument(PdfAConformance.PDF_A_4, null, doc -> { PdfDictionary action = new PdfDictionary(); action.put(PdfName.S, PdfName.NoOp); doc.addNewPage().setAdditionalAction(PdfName.O, new PdfAction(action)); })); - Assert.assertEquals(PdfaExceptionMessageConstant.PAGE_AA_DICTIONARY_SHALL_CONTAIN_ONLY_ALLOWED_KEYS, + Assertions.assertEquals(PdfaExceptionMessageConstant.PAGE_AA_DICTIONARY_SHALL_CONTAIN_ONLY_ALLOWED_KEYS, e.getMessage()); } @Test public void pdfA4ForbiddenActions_SETOCGSTATE_ActionToPage_Test() { - Exception e = Assert.assertThrows(PdfAConformanceException.class, - () -> generatePdfADocument(PdfAConformanceLevel.PDF_A_4, null, doc -> { + Exception e = Assertions.assertThrows(PdfAConformanceException.class, + () -> generatePdfADocument(PdfAConformance.PDF_A_4, null, doc -> { doc.addNewPage().setAdditionalAction(PdfName.O, PdfAction.createSetOcgState(new ArrayList<>())); })); - Assert.assertEquals(PdfaExceptionMessageConstant.PAGE_AA_DICTIONARY_SHALL_CONTAIN_ONLY_ALLOWED_KEYS, + Assertions.assertEquals(PdfaExceptionMessageConstant.PAGE_AA_DICTIONARY_SHALL_CONTAIN_ONLY_ALLOWED_KEYS, e.getMessage()); } @Test public void pdfA4ForbiddenActions_GOTO3DVIEW_ActionToPage_Test() throws FileNotFoundException { - Exception e = Assert.assertThrows(PdfAConformanceException.class, - () -> generatePdfADocument(PdfAConformanceLevel.PDF_A_4, null, doc -> { + Exception e = Assertions.assertThrows(PdfAConformanceException.class, + () -> generatePdfADocument(PdfAConformance.PDF_A_4, null, doc -> { PdfDictionary action = new PdfDictionary(); action.put(PdfName.S, PdfName.GoTo3DView); doc.addNewPage().setAdditionalAction(PdfName.O, new PdfAction(action)); })); - Assert.assertEquals(PdfaExceptionMessageConstant.PAGE_AA_DICTIONARY_SHALL_CONTAIN_ONLY_ALLOWED_KEYS, + Assertions.assertEquals(PdfaExceptionMessageConstant.PAGE_AA_DICTIONARY_SHALL_CONTAIN_ONLY_ALLOWED_KEYS, e.getMessage()); } @Test public void pdfA4_SETOCGSTATE_InCatalog_Test() { - Exception pdfa4Exception = Assert.assertThrows(PdfAConformanceException.class, () -> { - generatePdfADocument(PdfAConformanceLevel.PDF_A_4, null, doc -> { + Exception pdfa4Exception = Assertions.assertThrows(PdfAConformanceException.class, () -> { + generatePdfADocument(PdfAConformance.PDF_A_4, null, doc -> { doc.getCatalog().setAdditionalAction(PdfName.O, PdfAction.createSetOcgState(new ArrayList<>())); }); }); String messageFormat = MessageFormatUtil.format( PdfaExceptionMessageConstant.CATALOG_AA_DICTIONARY_SHALL_CONTAIN_ONLY_ALLOWED_KEYS, PdfName.SetOCGState.getValue()); - Assert.assertEquals(messageFormat, pdfa4Exception.getMessage()); + Assertions.assertEquals(messageFormat, pdfa4Exception.getMessage()); } @Test public void pdfA4_SETOCGSTATE_Annotation_Test() { - Exception pdfa4Exception = Assert.assertThrows(PdfAConformanceException.class, () -> { - generatePdfADocument(PdfAConformanceLevel.PDF_A_4, null, doc -> { + Exception pdfa4Exception = Assertions.assertThrows(PdfAConformanceException.class, () -> { + generatePdfADocument(PdfAConformance.PDF_A_4, null, doc -> { doc.addNewPage().addAnnotation(constructAnnotationWithAction(PdfName.SetOCGState)); }); }); - String messageFormat = MessageFormatUtil.format(PdfAConformanceException._0_ACTIONS_ARE_NOT_ALLOWED, + String messageFormat = MessageFormatUtil.format(PdfaExceptionMessageConstant._0_ACTIONS_ARE_NOT_ALLOWED, PdfName.SetOCGState.getValue()); - Assert.assertEquals(messageFormat, pdfa4Exception.getMessage()); + Assertions.assertEquals(messageFormat, pdfa4Exception.getMessage()); } @@ -272,7 +270,7 @@ public void pdfA4_SETOCGSTATE_Annotation_Test() { public void pdfA4E_SETOCGSTATE_Annotation_Test() throws IOException, InterruptedException { String outPdf = DESTINATION_FOLDER + "pdfA4ESetOCGStateAnnotation.pdf"; String cmpPdf = CMP_FOLDER + "cmp_pdfA4ESetOCGStateAnnotation.pdf"; - generatePdfADocument(PdfAConformanceLevel.PDF_A_4E, outPdf, doc -> { + generatePdfADocument(PdfAConformance.PDF_A_4E, outPdf, doc -> { doc.addNewPage().addAnnotation(constructAnnotationWithAction(PdfName.SetOCGState)); }); compareResult(outPdf, cmpPdf); @@ -281,21 +279,21 @@ public void pdfA4E_SETOCGSTATE_Annotation_Test() throws IOException, Interrupted @Test public void pdfA4_SETGOTO3DVIEW_Annotation_Test() { - Exception pdfa4Exception = Assert.assertThrows(PdfAConformanceException.class, () -> { - generatePdfADocument(PdfAConformanceLevel.PDF_A_4, null, doc -> { + Exception pdfa4Exception = Assertions.assertThrows(PdfAConformanceException.class, () -> { + generatePdfADocument(PdfAConformance.PDF_A_4, null, doc -> { doc.addNewPage().addAnnotation(constructAnnotationWithAction(PdfName.GoTo3DView)); }); }); - String messageFormat = MessageFormatUtil.format(PdfAConformanceException._0_ACTIONS_ARE_NOT_ALLOWED, + String messageFormat = MessageFormatUtil.format(PdfaExceptionMessageConstant._0_ACTIONS_ARE_NOT_ALLOWED, PdfName.GoTo3DView.getValue()); - Assert.assertEquals(messageFormat, pdfa4Exception.getMessage()); + Assertions.assertEquals(messageFormat, pdfa4Exception.getMessage()); } @Test public void pdfA4E_GOTO3DVIEW_Annotation_Test() throws IOException, InterruptedException { String outPdf = DESTINATION_FOLDER + "pdfA4ESetGoto3DViewAnnotation.pdf"; String cmpPdf = CMP_FOLDER + "cmp_pdfA4EGoto3DViewAnnotation.pdf"; - generatePdfADocument(PdfAConformanceLevel.PDF_A_4E, outPdf, doc -> { + generatePdfADocument(PdfAConformance.PDF_A_4E, outPdf, doc -> { doc.addNewPage().addAnnotation(constructAnnotationWithAction(PdfName.GoTo3DView)); }); compareResult(outPdf, cmpPdf); @@ -307,7 +305,7 @@ public void pdfA4_AllowedNamedActions_Test() throws IOException, InterruptedExce String outPdf = DESTINATION_FOLDER + "pdfA4AllowedNamedActions.pdf"; String cmpPdf = CMP_FOLDER + "cmp_pdfA4AllowedNamedActions.pdf"; List annots = Arrays.asList(PdfName.NextPage, PdfName.PrevPage, PdfName.FirstPage, PdfName.LastPage); - generatePdfADocument(PdfAConformanceLevel.PDF_A_4, outPdf, doc -> { + generatePdfADocument(PdfAConformance.PDF_A_4, outPdf, doc -> { PdfPage page = doc.getFirstPage(); for (PdfName annot : annots) { PdfAnnotation annotation = constructAnnotationWithAction(new PdfName("")); @@ -323,7 +321,7 @@ public void pdfA4_SpecialAllowedAction_Test() throws IOException, InterruptedExc String outPdf = DESTINATION_FOLDER + "pdfA4SpecialAllowedAction.pdf"; String cmpPdf = CMP_FOLDER + "cmp_pdfA4SpecialAllowedAction.pdf"; List annots = Arrays.asList(PdfName.GoToR, PdfName.GoToE, PdfName.URI, PdfName.SubmitForm); - generatePdfADocument(PdfAConformanceLevel.PDF_A_4, outPdf, doc -> { + generatePdfADocument(PdfAConformance.PDF_A_4, outPdf, doc -> { PdfPage page = doc.getFirstPage(); for (PdfName annot : annots) { PdfAnnotation annotation = constructAnnotationWithAction(annot); @@ -335,34 +333,34 @@ public void pdfA4_SpecialAllowedAction_Test() throws IOException, InterruptedExc @Test public void pdfA4F_SETOCGSTATE_InCatalog_Test() { - Exception pdfa4Exception = Assert.assertThrows(PdfAConformanceException.class, () -> { - generatePdfADocument(PdfAConformanceLevel.PDF_A_4F, null, doc -> { + Exception pdfa4Exception = Assertions.assertThrows(PdfAConformanceException.class, () -> { + generatePdfADocument(PdfAConformance.PDF_A_4F, null, doc -> { doc.getCatalog().setAdditionalAction(PdfName.O, PdfAction.createSetOcgState(new ArrayList<>())); }); }); String messageFormat = MessageFormatUtil.format( PdfaExceptionMessageConstant.CATALOG_AA_DICTIONARY_SHALL_CONTAIN_ONLY_ALLOWED_KEYS, PdfName.SetOCGState.getValue()); - Assert.assertEquals(messageFormat, pdfa4Exception.getMessage()); + Assertions.assertEquals(messageFormat, pdfa4Exception.getMessage()); } @Test public void pdfA4E_SETOCGSTATE_InCatalog_Test() { - Exception pdfa4Exception = Assert.assertThrows(PdfAConformanceException.class, () -> { - generatePdfADocument(PdfAConformanceLevel.PDF_A_4E, null, doc -> { + Exception pdfa4Exception = Assertions.assertThrows(PdfAConformanceException.class, () -> { + generatePdfADocument(PdfAConformance.PDF_A_4E, null, doc -> { doc.getCatalog().setAdditionalAction(PdfName.O, PdfAction.createSetOcgState(new ArrayList<>())); }); }); String messageFormat = MessageFormatUtil.format( PdfaExceptionMessageConstant.CATALOG_AA_DICTIONARY_SHALL_CONTAIN_ONLY_ALLOWED_KEYS, PdfName.SetOCGState.getValue()); - Assert.assertEquals(messageFormat, pdfa4Exception.getMessage()); + Assertions.assertEquals(messageFormat, pdfa4Exception.getMessage()); } @Test public void pdfA4_GOTO3DVIEW_InCatalog_Test() { - Exception pdfa4Exception = Assert.assertThrows(PdfAConformanceException.class, () -> { - generatePdfADocument(PdfAConformanceLevel.PDF_A_4, null, doc -> { + Exception pdfa4Exception = Assertions.assertThrows(PdfAConformanceException.class, () -> { + generatePdfADocument(PdfAConformance.PDF_A_4, null, doc -> { PdfDictionary action = new PdfDictionary(); action.put(PdfName.S, PdfName.GoTo3DView); doc.getCatalog().setAdditionalAction(PdfName.O, new PdfAction(action)); @@ -372,31 +370,31 @@ public void pdfA4_GOTO3DVIEW_InCatalog_Test() { String messageFormat = MessageFormatUtil.format( PdfaExceptionMessageConstant.CATALOG_AA_DICTIONARY_SHALL_CONTAIN_ONLY_ALLOWED_KEYS, PdfName.GoTo3DView.getValue()); - Assert.assertEquals(messageFormat, pdfa4Exception.getMessage()); + Assertions.assertEquals(messageFormat, pdfa4Exception.getMessage()); } @Test public void pdfA4F_GOTO3DView_InCatalog_Test() { - Exception pdfa4Exception = Assert.assertThrows(PdfAConformanceException.class, () -> { - generatePdfADocument(PdfAConformanceLevel.PDF_A_4F, null, doc -> { + Exception pdfa4Exception = Assertions.assertThrows(PdfAConformanceException.class, () -> { + generatePdfADocument(PdfAConformance.PDF_A_4F, null, doc -> { PdfDictionary action = new PdfDictionary(); action.put(PdfName.S, PdfName.GoTo3DView); doc.getCatalog().setAdditionalAction(PdfName.O, new PdfAction(action)); }); }); - Assert.assertEquals(pdfa4Exception.getMessage(), + Assertions.assertEquals(pdfa4Exception.getMessage(), PdfaExceptionMessageConstant.CATALOG_AA_DICTIONARY_SHALL_CONTAIN_ONLY_ALLOWED_KEYS); } @Test public void pdfA4E_GOTO3DView_InCatalog_Test() { - Exception e = Assert.assertThrows(PdfAConformanceException.class, - () -> generatePdfADocument(PdfAConformanceLevel.PDF_A_4E, null, doc -> { + Exception e = Assertions.assertThrows(PdfAConformanceException.class, + () -> generatePdfADocument(PdfAConformance.PDF_A_4E, null, doc -> { PdfDictionary action = new PdfDictionary(); action.put(PdfName.S, PdfName.GoTo3DView); doc.getCatalog().setAdditionalAction(PdfName.O, new PdfAction(action)); })); - Assert.assertEquals(PdfaExceptionMessageConstant.CATALOG_AA_DICTIONARY_SHALL_CONTAIN_ONLY_ALLOWED_KEYS, + Assertions.assertEquals(PdfaExceptionMessageConstant.CATALOG_AA_DICTIONARY_SHALL_CONTAIN_ONLY_ALLOWED_KEYS, e.getMessage()); } @@ -404,7 +402,7 @@ public void pdfA4E_GOTO3DView_InCatalog_Test() { public void pdfA4AAEntriesAllowedInAADocumentCatalog_Test() throws IOException, InterruptedException { String outPdf = DESTINATION_FOLDER + "pdfA4AAEntriesAllowedInAADocumentCatalog.pdf"; String cmpPdf = CMP_FOLDER + "cmp_pdfA4AAEntriesAllowedInAADocumentCatalog.pdf"; - generatePdfADocument(PdfAConformanceLevel.PDF_A_4, outPdf, doc -> { + generatePdfADocument(PdfAConformance.PDF_A_4, outPdf, doc -> { PdfDictionary allowedAA = new PdfDictionary(); allowedAA.put(PdfName.E, new PdfName("HELLO")); allowedAA.put(PdfName.X, new PdfName("HELLO")); @@ -421,7 +419,7 @@ public void pdfA4AAEntriesAllowedInAADocumentCatalog_Test() throws IOException, public void pdfA4AAEntriesAllowedInAAPage_Test() throws IOException, InterruptedException { String outPdf = DESTINATION_FOLDER + "pdfA4AAEntriesAllowedInAAPage.pdf"; String cmpPdf = CMP_FOLDER + "cmp_pdfA4AAEntriesAllowedInAAPage.pdf"; - generatePdfADocument(PdfAConformanceLevel.PDF_A_4, outPdf, doc -> { + generatePdfADocument(PdfAConformance.PDF_A_4, outPdf, doc -> { PdfDictionary allowedAA = new PdfDictionary(); allowedAA.put(PdfName.E, new PdfName("HELLO")); allowedAA.put(PdfName.X, new PdfName("HELLO")); @@ -446,22 +444,22 @@ private PdfAnnotation constructAnnotationWithAction(PdfName actionType) { } private void compareResult(String outPdf, String cmpPdf) throws IOException, InterruptedException { - Assert.assertNull(// Android-Conversion-Skip-Line TODO DEVSIX-7377 + Assertions.assertNull(// Android-Conversion-Skip-Line TODO DEVSIX-7377 new VeraPdfValidator().validate(outPdf));// Android-Conversion-Skip-Line TODO DEVSIX-7377 String result = new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_"); if (result != null) { - Assert.fail(result); + Assertions.fail(result); } } - private void generatePdfADocument(PdfAConformanceLevel conformanceLevel, String outPdf, + private void generatePdfADocument(PdfAConformance conformance, String outPdf, Consumer consumer) throws IOException { String filename = DESTINATION_FOLDER + UUID.randomUUID().toString() + ".pdf"; if (outPdf != null) { filename = outPdf; } PdfWriter writer = new PdfWriter(filename, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); - PdfADocument doc = new PdfADocument(writer, conformanceLevel, + PdfADocument doc = new PdfADocument(writer, conformance, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"))); doc.addNewPage(); diff --git a/pdfa/src/test/java/com/itextpdf/pdfa/PdfA4AnnotationCheckTest.java b/pdfa/src/test/java/com/itextpdf/pdfa/PdfA4AnnotationCheckTest.java index 106da510d0..2231e41f0d 100644 --- a/pdfa/src/test/java/com/itextpdf/pdfa/PdfA4AnnotationCheckTest.java +++ b/pdfa/src/test/java/com/itextpdf/pdfa/PdfA4AnnotationCheckTest.java @@ -27,7 +27,7 @@ This file is part of the iText (R) project. import com.itextpdf.io.source.ByteArrayOutputStream; import com.itextpdf.kernel.geom.Rectangle; import com.itextpdf.kernel.pdf.CompressionConstants; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfAConformance; import com.itextpdf.kernel.pdf.PdfArray; import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.kernel.pdf.PdfDocument; @@ -54,23 +54,22 @@ This file is part of the iText (R) project. import com.itextpdf.pdfa.exceptions.PdfAConformanceException; import com.itextpdf.pdfa.exceptions.PdfaExceptionMessageConstant; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import com.itextpdf.test.pdfa.VeraPdfValidator; // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) import java.io.FileNotFoundException; import java.io.IOException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfA4AnnotationCheckTest extends ExtendedITextTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/pdfa/"; private static final String CMP_FOLDER = SOURCE_FOLDER + "cmp/PdfA4AnnotationCheckTest/"; private static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/pdfa/PdfA4AnnotationCheckTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() throws FileNotFoundException { createOrClearDestinationFolder(DESTINATION_FOLDER); } @@ -78,42 +77,42 @@ public static void beforeClass() throws FileNotFoundException { @Test public void pdfA4ForbiddenAnnotations1Test() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream(), new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, createOutputIntent()); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4, createOutputIntent()); PdfPage page = doc.addNewPage(); PdfAnnotation annot = new PdfFileAttachmentAnnotation(new Rectangle(100, 100, 100, 100)); page.addAnnotation(annot); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.ANNOTATION_TYPE_0_IS_NOT_PERMITTED, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.ANNOTATION_TYPE_0_IS_NOT_PERMITTED, PdfName.FileAttachment.getValue()), e.getMessage()); } @Test public void pdfA4ForbiddenAnnotations2Test() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream(), new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, createOutputIntent()); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4, createOutputIntent()); PdfPage page = doc.addNewPage(); PdfAnnotation annot = new PdfSoundAnnotation(new Rectangle(100, 100, 100, 100), new PdfStream()); page.addAnnotation(annot); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.ANNOTATION_TYPE_0_IS_NOT_PERMITTED, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.ANNOTATION_TYPE_0_IS_NOT_PERMITTED, PdfName.Sound.getValue()), e.getMessage()); } @Test public void pdfA4ForbiddenAnnotations3Test() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream(), new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, createOutputIntent()); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4, createOutputIntent()); PdfPage page = doc.addNewPage(); PdfAnnotation annot = new Pdf3DAnnotation(new Rectangle(100, 100, 100, 100), new PdfArray()); page.addAnnotation(annot); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.ANNOTATION_TYPE_0_IS_NOT_PERMITTED, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.ANNOTATION_TYPE_0_IS_NOT_PERMITTED, PdfName._3D.getValue()), e.getMessage()); } @@ -123,7 +122,7 @@ public void pdfA4AllowedAnnotations1Test() throws IOException, InterruptedExcept String cmpPdf = CMP_FOLDER + "cmp_pdfA4AllowedAnnotations1Test.pdf"; PdfWriter writer = new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); - try (PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, createOutputIntent())) { + try (PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4, createOutputIntent())) { PdfPage page = doc.addNewPage(); PdfAnnotation annot = new PdfLinkAnnotation(new Rectangle(100, 100, 100, 100)); @@ -137,28 +136,28 @@ public void pdfA4AllowedAnnotations1Test() throws IOException, InterruptedExcept @Test public void pdfA4eForbiddenAnnotations1Test() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream(), new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4E, createOutputIntent()); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4E, createOutputIntent()); PdfPage page = doc.addNewPage(); PdfAnnotation annot = new PdfFileAttachmentAnnotation(new Rectangle(100, 100, 100, 100)); page.addAnnotation(annot); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.ANNOTATION_TYPE_0_IS_NOT_PERMITTED, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.ANNOTATION_TYPE_0_IS_NOT_PERMITTED, PdfName.FileAttachment.getValue()), e.getMessage()); } @Test public void pdfA4eForbiddenAnnotations2Test() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream(), new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4E, createOutputIntent()); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4E, createOutputIntent()); PdfPage page = doc.addNewPage(); PdfAnnotation annot = new PdfSoundAnnotation(new Rectangle(100, 100, 100, 100), new PdfStream()); page.addAnnotation(annot); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.ANNOTATION_TYPE_0_IS_NOT_PERMITTED, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.ANNOTATION_TYPE_0_IS_NOT_PERMITTED, PdfName.Sound.getValue()), e.getMessage()); } @@ -168,7 +167,7 @@ public void pdfA4eAllowedAnnotations1Test() throws IOException, InterruptedExcep String cmpPdf = CMP_FOLDER + "cmp_pdfA4eAllowedAnnotations1Test.pdf"; PdfWriter writer = new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); - try (PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4E, createOutputIntent())) { + try (PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4E, createOutputIntent())) { PdfPage page = doc.addNewPage(); PdfAnnotation annot = new PdfLinkAnnotation(new Rectangle(100, 100, 100, 100)); @@ -185,7 +184,7 @@ public void pdfA4eAllowedAnnotations2Test() throws IOException, InterruptedExcep String cmpPdf = CMP_FOLDER + "cmp_pdfA4eAllowedAnnotations2Test.pdf"; PdfWriter writer = new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); - try (PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4E, createOutputIntent())) { + try (PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4E, createOutputIntent())) { PdfPage page = doc.addNewPage(); PdfStream stream3D = new PdfStream(doc, FileUtil.getInputStreamForFile(CMP_FOLDER + "teapot.u3d")); @@ -216,7 +215,7 @@ public void pdfA4eAllowedAnnotations2Test() throws IOException, InterruptedExcep @Test public void pdfA4fForbiddenAnnotations1Test() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream(), new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4F, createOutputIntent()); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4F, createOutputIntent()); PdfPage page = doc.addNewPage(); addSimpleEmbeddedFile(doc); @@ -224,15 +223,15 @@ public void pdfA4fForbiddenAnnotations1Test() throws IOException { PdfAnnotation annot = new PdfSoundAnnotation(new Rectangle(100, 100, 100, 100), new PdfStream()); page.addAnnotation(annot); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.ANNOTATION_TYPE_0_IS_NOT_PERMITTED, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.ANNOTATION_TYPE_0_IS_NOT_PERMITTED, PdfName.Sound.getValue()), e.getMessage()); } @Test public void pdfA4fForbiddenAnnotations2Test() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream(), new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4F, createOutputIntent()); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4F, createOutputIntent()); PdfPage page = doc.addNewPage(); addSimpleEmbeddedFile(doc); @@ -240,15 +239,15 @@ public void pdfA4fForbiddenAnnotations2Test() throws IOException { PdfAnnotation annot = new Pdf3DAnnotation(new Rectangle(100, 100, 100, 100), new PdfArray()); page.addAnnotation(annot); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.ANNOTATION_TYPE_0_IS_NOT_PERMITTED, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.ANNOTATION_TYPE_0_IS_NOT_PERMITTED, PdfName._3D.getValue()), e.getMessage()); } @Test public void pdfA4fForbiddenAnnotations3Test() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream(), new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4F, createOutputIntent()); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4F, createOutputIntent()); PdfPage page = doc.addNewPage(); addSimpleEmbeddedFile(doc); @@ -256,15 +255,15 @@ public void pdfA4fForbiddenAnnotations3Test() throws IOException { PdfAnnotation annot = new PdfScreenAnnotation(new Rectangle(100, 100, 100, 100)); page.addAnnotation(annot); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.ANNOTATION_TYPE_0_IS_NOT_PERMITTED, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.ANNOTATION_TYPE_0_IS_NOT_PERMITTED, PdfName.Screen.getValue()), e.getMessage()); } @Test public void pdfA4fForbiddenAnnotations4Test() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream(), new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4F, createOutputIntent()); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4F, createOutputIntent()); PdfPage page = doc.addNewPage(); addSimpleEmbeddedFile(doc); @@ -273,8 +272,8 @@ public void pdfA4fForbiddenAnnotations4Test() throws IOException { annot.getPdfObject().put(PdfName.Subtype, PdfName.RichMedia); page.addAnnotation(annot); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.ANNOTATION_TYPE_0_IS_NOT_PERMITTED, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.ANNOTATION_TYPE_0_IS_NOT_PERMITTED, PdfName.RichMedia.getValue()), e.getMessage()); } @@ -284,7 +283,7 @@ public void pdfA4fAllowedAnnotations1Test() throws IOException, InterruptedExcep String cmpPdf = CMP_FOLDER + "cmp_pdfA4fAllowedAnnotations1Test.pdf"; PdfWriter writer = new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); - try (PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4F, createOutputIntent())) { + try (PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4F, createOutputIntent())) { PdfPage page = doc.addNewPage(); addSimpleEmbeddedFile(doc); @@ -304,7 +303,7 @@ public void pdfA4fAllowedAnnotations2Test() throws IOException, InterruptedExcep String cmpPdf = CMP_FOLDER + "cmp_pdfA4fAllowedAnnotations2Test.pdf"; PdfWriter writer = new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); - try (PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4F, createOutputIntent())) { + try (PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4F, createOutputIntent())) { PdfPage page = doc.addNewPage(); addSimpleEmbeddedFile(doc); @@ -323,7 +322,7 @@ public void pdfA4AllowedAnnotWithoutApTest() throws IOException, InterruptedExce String cmpPdf = CMP_FOLDER + "cmp_pdfA4AllowedAnnotWithoutApTest.pdf"; PdfWriter writer = new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); - try (PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, createOutputIntent())) { + try (PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4, createOutputIntent())) { PdfPage page = doc.addNewPage(); PdfAnnotation annot = new PdfProjectionAnnotation(new Rectangle(100, 100, 100, 100)); @@ -337,7 +336,7 @@ public void pdfA4AllowedAnnotWithoutApTest() throws IOException, InterruptedExce @Test public void pdfA4ForbiddenAKeyWidgetAnnotationTest() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream(), new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4F, createOutputIntent()); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4F, createOutputIntent()); PdfPage page = doc.addNewPage(); addSimpleEmbeddedFile(doc); @@ -347,8 +346,8 @@ public void pdfA4ForbiddenAKeyWidgetAnnotationTest() throws IOException { annot.setFlag(PdfAnnotation.PRINT); page.addAnnotation(annot); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(PdfaExceptionMessageConstant.WIDGET_ANNOTATION_DICTIONARY_OR_FIELD_DICTIONARY_SHALL_NOT_INCLUDE_A_ENTRY, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(PdfaExceptionMessageConstant.WIDGET_ANNOTATION_DICTIONARY_OR_FIELD_DICTIONARY_SHALL_NOT_INCLUDE_A_ENTRY, e.getMessage()); } @@ -358,7 +357,7 @@ public void pdfA4AllowedAAKeyWidgetAnnotationTest() throws IOException, Interrup String cmpPdf = CMP_FOLDER + "cmp_pdfA4AllowedAAKeyWidgetAnnotationTest.pdf"; PdfWriter writer = new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); - try (PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, createOutputIntent())) { + try (PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4, createOutputIntent())) { PdfPage page = doc.addNewPage(); PdfAnnotation annot = new PdfWidgetAnnotation(new Rectangle(100, 100, 100, 100)); @@ -373,7 +372,7 @@ public void pdfA4AllowedAAKeyWidgetAnnotationTest() throws IOException, Interrup @Test public void pdfA4BtnAppearanceContainsNStreamWidgetAnnotationTest() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream(), new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4F, createOutputIntent()); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4F, createOutputIntent()); PdfPage page = doc.addNewPage(); addSimpleEmbeddedFile(doc); @@ -384,15 +383,15 @@ public void pdfA4BtnAppearanceContainsNStreamWidgetAnnotationTest() throws IOExc annot.getPdfObject().put(PdfName.FT, PdfName.Btn); page.addAnnotation(annot); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(PdfaExceptionMessageConstant.APPEARANCE_DICTIONARY_OF_WIDGET_SUBTYPE_AND_BTN_FIELD_TYPE_SHALL_CONTAIN_ONLY_THE_N_KEY_WITH_DICTIONARY_VALUE, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(PdfaExceptionMessageConstant.APPEARANCE_DICTIONARY_OF_WIDGET_SUBTYPE_AND_BTN_FIELD_TYPE_SHALL_CONTAIN_ONLY_THE_N_KEY_WITH_DICTIONARY_VALUE, e.getMessage()); } @Test public void pdfA4AppearanceContainsNDictWidgetAnnotationTest() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream(), new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4F, createOutputIntent()); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4F, createOutputIntent()); PdfPage page = doc.addNewPage(); addSimpleEmbeddedFile(doc); @@ -403,15 +402,15 @@ public void pdfA4AppearanceContainsNDictWidgetAnnotationTest() throws IOExceptio annot.getPdfObject().put(PdfName.FT, PdfName.Tx); page.addAnnotation(annot); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(PdfaExceptionMessageConstant.APPEARANCE_DICTIONARY_SHALL_CONTAIN_ONLY_THE_N_KEY_WITH_STREAM_VALUE, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(PdfaExceptionMessageConstant.APPEARANCE_DICTIONARY_SHALL_CONTAIN_ONLY_THE_N_KEY_WITH_STREAM_VALUE, e.getMessage()); } @Test public void pdfA4AppearanceContainsOtherKeyWidgetAnnotationTest() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream(), new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4F, createOutputIntent()); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4F, createOutputIntent()); PdfPage page = doc.addNewPage(); addSimpleEmbeddedFile(doc); @@ -422,8 +421,8 @@ public void pdfA4AppearanceContainsOtherKeyWidgetAnnotationTest() throws IOExcep annot.getPdfObject().put(PdfName.FT, PdfName.Btn); page.addAnnotation(annot); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(PdfaExceptionMessageConstant.APPEARANCE_DICTIONARY_OF_WIDGET_SUBTYPE_AND_BTN_FIELD_TYPE_SHALL_CONTAIN_ONLY_THE_N_KEY_WITH_DICTIONARY_VALUE, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(PdfaExceptionMessageConstant.APPEARANCE_DICTIONARY_OF_WIDGET_SUBTYPE_AND_BTN_FIELD_TYPE_SHALL_CONTAIN_ONLY_THE_N_KEY_WITH_DICTIONARY_VALUE, e.getMessage()); } @@ -433,7 +432,7 @@ public void pdfA4ForbiddenAAKeyAnnotationTest() throws IOException, InterruptedE String outPdf = DESTINATION_FOLDER + "pdfA4ForbiddenAAKeyAnnotationTest.pdf"; String cmpPdf = CMP_FOLDER + "cmp_pdfA4ForbiddenAAKeyAnnotationTest.pdf"; PdfWriter writer = new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, createOutputIntent()); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4, createOutputIntent()); PdfPage page = doc.addNewPage(); PdfAnnotation annot = new PdfLinkAnnotation(new Rectangle(100, 100, 100, 100)); @@ -447,10 +446,10 @@ public void pdfA4ForbiddenAAKeyAnnotationTest() throws IOException, InterruptedE } private void compareResult(String outPdf, String cmpPdf) throws IOException, InterruptedException { - Assert.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) String result = new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_"); if (result != null) { - Assert.fail(result); + Assertions.fail(result); } } diff --git a/pdfa/src/test/java/com/itextpdf/pdfa/PdfA4CatalogCheckTest.java b/pdfa/src/test/java/com/itextpdf/pdfa/PdfA4CatalogCheckTest.java index 2de61d8cbc..6a1a7fa69d 100644 --- a/pdfa/src/test/java/com/itextpdf/pdfa/PdfA4CatalogCheckTest.java +++ b/pdfa/src/test/java/com/itextpdf/pdfa/PdfA4CatalogCheckTest.java @@ -22,13 +22,14 @@ This file is part of the iText (R) project. */ package com.itextpdf.pdfa; +import com.itextpdf.bouncycastleconnector.BouncyCastleFactoryCreator; import com.itextpdf.commons.utils.FileUtil; import com.itextpdf.commons.utils.MessageFormatUtil; import com.itextpdf.kernel.font.PdfFont; import com.itextpdf.kernel.font.PdfFontFactory; import com.itextpdf.kernel.geom.Rectangle; import com.itextpdf.kernel.pdf.EncryptionConstants; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfAConformance; import com.itextpdf.kernel.pdf.PdfDate; import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.kernel.pdf.PdfDocument; @@ -47,28 +48,28 @@ This file is part of the iText (R) project. import com.itextpdf.pdfa.exceptions.PdfAConformanceException; import com.itextpdf.pdfa.exceptions.PdfaExceptionMessageConstant; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import com.itextpdf.test.pdfa.VeraPdfValidator; // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) import java.io.ByteArrayOutputStream; -import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.nio.charset.StandardCharsets; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import java.security.Security; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfA4CatalogCheckTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/pdfa/"; public static final String cmpFolder = sourceFolder + "cmp/PdfA4CatalogCheckTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/pdfa/PdfA4CatalogCheckTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); + Security.addProvider(BouncyCastleFactoryCreator.getFactory().getProvider()); } @Test @@ -77,12 +78,12 @@ public void createSimpleDocTest() throws IOException { PdfWriter writer = new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.addNewPage(); doc.close(); - Assert.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) } @Test @@ -92,7 +93,7 @@ public void createSimpleTaggedDocTest() throws IOException, InterruptedException PdfWriter writer = new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument pdfDoc = (PdfADocument) new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)).setTagged(); + PdfADocument pdfDoc = (PdfADocument) new PdfADocument(writer, PdfAConformance.PDF_A_4, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)).setTagged(); PdfFont font = PdfFontFactory.createFont(sourceFolder + "FreeSans.ttf", "WinAnsi", PdfFontFactory.EmbeddingStrategy.FORCE_EMBEDDED); Document document = new Document(pdfDoc); @@ -101,11 +102,11 @@ public void createSimpleTaggedDocTest() throws IOException, InterruptedException list.add("123"); document.add(list); - Assert.assertEquals(PdfVersion.PDF_2_0, pdfDoc.getTagStructureContext().getTagStructureTargetVersion()); + Assertions.assertEquals(PdfVersion.PDF_2_0, pdfDoc.getTagStructureContext().getTagStructureTargetVersion()); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff")); - Assert.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff")); + Assertions.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) } @Test @@ -114,13 +115,13 @@ public void invalidCatalogVersionCheckTest() throws IOException { PdfWriter writer = new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.addNewPage(); doc.getCatalog().put(PdfName.Version, new PdfString("1.7")); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.THE_CATALOG_VERSION_SHALL_CONTAIN_RIGHT_PDF_VERSION, "2"), + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.THE_CATALOG_VERSION_SHALL_CONTAIN_RIGHT_PDF_VERSION, "2"), e.getMessage()); } @@ -135,16 +136,16 @@ public void encryptInTrailerTest() throws IOException { new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0) .setStandardEncryption(userPassword, ownerPassword, permissions, EncryptionConstants.ENCRYPTION_AES_256).setFullCompressionMode(false)); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.addNewPage(); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(PdfaExceptionMessageConstant.KEYWORD_ENCRYPT_SHALL_NOT_BE_USED_IN_THE_TRAILER_DICTIONARY, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(PdfaExceptionMessageConstant.KEYWORD_ENCRYPT_SHALL_NOT_BE_USED_IN_THE_TRAILER_DICTIONARY, e.getMessage()); } @Test public void encryptedDocumentTest() throws IOException { - String outPdf = destinationFolder + "pdfA4_catalogCheck03.pdf"; + String outPdf = destinationFolder + "pdfA4_encryptedDocument.pdf"; byte[] userPassword = "user".getBytes(StandardCharsets.ISO_8859_1); byte[] ownerPassword = "owner".getBytes(StandardCharsets.ISO_8859_1); @@ -153,10 +154,10 @@ public void encryptedDocumentTest() throws IOException { new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0) .setStandardEncryption(userPassword, ownerPassword, permissions, EncryptionConstants.ENCRYPTION_AES_256).setFullCompressionMode(true)); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.addNewPage(); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(PdfaExceptionMessageConstant.KEYWORD_ENCRYPT_SHALL_NOT_BE_USED_IN_THE_TRAILER_DICTIONARY, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(PdfaExceptionMessageConstant.KEYWORD_ENCRYPT_SHALL_NOT_BE_USED_IN_THE_TRAILER_DICTIONARY, e.getMessage()); } @@ -166,7 +167,7 @@ public void absentPieceInfoTest() throws IOException { PdfWriter writer = new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.addNewPage(); PdfDictionary info = new PdfDictionary(); @@ -174,8 +175,8 @@ public void absentPieceInfoTest() throws IOException { info.put(PdfName.ModDate, new PdfDate(PdfDate.decode(timeValue)).getPdfObject()); doc.getTrailer().put(PdfName.Info, info); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(PdfaExceptionMessageConstant.DOCUMENT_SHALL_NOT_CONTAIN_INFO_UNLESS_THERE_IS_PIECE_INFO, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(PdfaExceptionMessageConstant.DOCUMENT_SHALL_NOT_CONTAIN_INFO_UNLESS_THERE_IS_PIECE_INFO, e.getMessage()); } @@ -186,16 +187,16 @@ public void validCatalogCheckTest() throws IOException, InterruptedException { PdfWriter writer = new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.addNewPage(); doc.getCatalog().put(PdfName.PieceInfo, new PdfDictionary()); doc.close(); // This is required to check if ModDate is inside Info dictionary - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); - Assert.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) } @Test @@ -204,16 +205,29 @@ public void invalidInfoTest() throws IOException, InterruptedException { PdfWriter writer = new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.addNewPage(); doc.getTrailer().put(PdfName.Info, new PdfDictionary()); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(PdfaExceptionMessageConstant.DOCUMENT_INFO_DICTIONARY_SHALL_ONLY_CONTAIN_MOD_DATE, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(PdfaExceptionMessageConstant.DOCUMENT_INFO_DICTIONARY_SHALL_ONLY_CONTAIN_MOD_DATE, e.getMessage()); } + @Test + public void invalidInfoWithFullCompression() throws IOException { + String outPdf = destinationFolder + "invalidInfoWithFillCompression.pdf"; + + PdfWriter writer = new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0).setFullCompressionMode(true)); + InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); + try (PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is))) { + doc.addNewPage(); + } + + Assertions.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + } + @Test public void readValidDocumentTest() throws IOException { String outPdf = destinationFolder + "simplePdfA4_output01.pdf"; @@ -221,7 +235,7 @@ public void readValidDocumentTest() throws IOException { PdfReader reader = new PdfReader(sourceFolder + "pdfs/simplePdfA4.pdf"); PdfDocument document = new PdfADocument(reader, writer); document.close(); - Assert.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) } @Test @@ -230,13 +244,13 @@ public void invalidVersionInCatalogTest() throws IOException { PdfWriter writer = new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.addNewPage(); doc.getCatalog().put(PdfName.Version, new PdfString("1.7")); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.THE_CATALOG_VERSION_SHALL_CONTAIN_RIGHT_PDF_VERSION, 2), + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.THE_CATALOG_VERSION_SHALL_CONTAIN_RIGHT_PDF_VERSION, 2), e.getMessage()); } @@ -246,13 +260,13 @@ public void corruptedVersionInCatalogTest() throws IOException { PdfWriter writer = new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.addNewPage(); doc.getCatalog().put(PdfName.Version, new PdfString("2ae")); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.THE_CATALOG_VERSION_SHALL_CONTAIN_RIGHT_PDF_VERSION, 2), + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.THE_CATALOG_VERSION_SHALL_CONTAIN_RIGHT_PDF_VERSION, 2), e.getMessage()); } @@ -261,8 +275,8 @@ public void readDocumentWithInvalidVersionTest() throws IOException { PdfWriter writer = new PdfWriter(destinationFolder + "simplePdfA4_output02.pdf"); PdfReader reader = new PdfReader(sourceFolder + "pdfs/pdfA4WithInvalidVersion.pdf"); PdfDocument document = new PdfADocument(reader, writer); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> document.close()); - Assert.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.THE_FILE_HEADER_SHALL_CONTAIN_RIGHT_PDF_VERSION, 2), + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> document.close()); + Assertions.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.THE_FILE_HEADER_SHALL_CONTAIN_RIGHT_PDF_VERSION, 2), e.getMessage()); } @@ -271,7 +285,7 @@ public void checkReferenceXObject() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream(), new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, outputIntent); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4, outputIntent); doc.addNewPage(); PdfCanvas canvas = new PdfCanvas(doc.getLastPage()); @@ -281,8 +295,8 @@ public void checkReferenceXObject() throws IOException { xObjCanvas.rectangle(30, 30, 10, 10).fill(); canvas.addXObjectFittedIntoRectangle(xObject, new Rectangle(300, 300)); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(PdfaExceptionMessageConstant.A_FORM_XOBJECT_DICTIONARY_SHALL_NOT_CONTAIN_REF_KEY, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(PdfaExceptionMessageConstant.A_FORM_XOBJECT_DICTIONARY_SHALL_NOT_CONTAIN_REF_KEY, e.getMessage()); } @@ -291,7 +305,7 @@ public void checkOpiInXObject() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream(), new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, outputIntent); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4, outputIntent); doc.addNewPage(); PdfCanvas canvas = new PdfCanvas(doc.getLastPage()); @@ -301,8 +315,8 @@ public void checkOpiInXObject() throws IOException { xObjCanvas.rectangle(30, 30, 10, 10).fill(); canvas.addXObjectFittedIntoRectangle(xObject, new Rectangle(300, 300)); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(PdfaExceptionMessageConstant.A_FORM_XOBJECT_DICTIONARY_SHALL_NOT_CONTAIN_OPI_KEY, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(PdfaExceptionMessageConstant.A_FORM_XOBJECT_DICTIONARY_SHALL_NOT_CONTAIN_OPI_KEY, e.getMessage()); } @@ -313,7 +327,7 @@ public void validFormXObjectTest() throws IOException, InterruptedException { PdfWriter writer = new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, outputIntent); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4, outputIntent); doc.addNewPage(); PdfCanvas canvas = new PdfCanvas(doc.getLastPage()); @@ -325,21 +339,22 @@ public void validFormXObjectTest() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff_")); - Assert.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) } @Test public void createInvalidPdfAVersionNumberWithPDFA4() throws IOException { PdfWriter writer = new PdfWriter(new PdfWriter(new ByteArrayOutputStream()), - new WriterProperties().setPdfVersion(PdfVersion.PDF_1_7)); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, + new WriterProperties()); + PdfDocumentCustomVersion doc = new PdfDocumentCustomVersion(writer, PdfAConformance.PDF_A_4, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"))); + doc.setPdfVersion(PdfVersion.PDF_1_7); doc.addNewPage(); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals( + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals( MessageFormatUtil.format(PdfaExceptionMessageConstant.THE_FILE_HEADER_SHALL_CONTAIN_RIGHT_PDF_VERSION, "2"), e.getMessage()); } @@ -347,13 +362,14 @@ public void createInvalidPdfAVersionNumberWithPDFA4() throws IOException { @Test public void createInvalidPdfAVersionNumberWithPDFA4F() throws IOException { PdfWriter writer = new PdfWriter(new PdfWriter(new ByteArrayOutputStream()), - new WriterProperties().setPdfVersion(PdfVersion.PDF_1_7)); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4F, + new WriterProperties()); + PdfDocumentCustomVersion doc = new PdfDocumentCustomVersion(writer, PdfAConformance.PDF_A_4F, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"))); + doc.setPdfVersion(PdfVersion.PDF_1_7); doc.addNewPage(); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals( + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals( MessageFormatUtil.format(PdfaExceptionMessageConstant.THE_FILE_HEADER_SHALL_CONTAIN_RIGHT_PDF_VERSION, "2"), e.getMessage()); } @@ -361,13 +377,14 @@ public void createInvalidPdfAVersionNumberWithPDFA4F() throws IOException { @Test public void createInvalidPdfAVersionNumberWithPDFA4E() throws IOException { PdfWriter writer = new PdfWriter(new PdfWriter(new ByteArrayOutputStream()), - new WriterProperties().setPdfVersion(PdfVersion.PDF_1_7)); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4E, + new WriterProperties()); + PdfDocumentCustomVersion doc = new PdfDocumentCustomVersion(writer, PdfAConformance.PDF_A_4E, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"))); + doc.setPdfVersion(PdfVersion.PDF_1_7); doc.addNewPage(); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals( + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals( MessageFormatUtil.format(PdfaExceptionMessageConstant.THE_FILE_HEADER_SHALL_CONTAIN_RIGHT_PDF_VERSION, "2"), e.getMessage()); } @@ -375,13 +392,14 @@ public void createInvalidPdfAVersionNumberWithPDFA4E() throws IOException { @Test public void createInvalidPdfAVersion16NumberWithPDFA4() throws IOException { PdfWriter writer = new PdfWriter(new PdfWriter(new ByteArrayOutputStream()), - new WriterProperties().setPdfVersion(PdfVersion.PDF_1_6)); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, + new WriterProperties()); + PdfDocumentCustomVersion doc = new PdfDocumentCustomVersion(writer, PdfAConformance.PDF_A_4, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"))); + doc.setPdfVersion(PdfVersion.PDF_1_6); doc.addNewPage(); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals( + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals( MessageFormatUtil.format(PdfaExceptionMessageConstant.THE_FILE_HEADER_SHALL_CONTAIN_RIGHT_PDF_VERSION, "2"), e.getMessage()); } @@ -389,13 +407,14 @@ public void createInvalidPdfAVersion16NumberWithPDFA4() throws IOException { @Test public void createInvalidPdfAVersion13NumberWithPDFA4F() throws IOException { PdfWriter writer = new PdfWriter(new PdfWriter(new ByteArrayOutputStream()), - new WriterProperties().setPdfVersion(PdfVersion.PDF_1_3)); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4F, + new WriterProperties()); + PdfDocumentCustomVersion doc = new PdfDocumentCustomVersion(writer, PdfAConformance.PDF_A_4F, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"))); + doc.setPdfVersion(PdfVersion.PDF_1_3); doc.addNewPage(); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals( + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals( MessageFormatUtil.format(PdfaExceptionMessageConstant.THE_FILE_HEADER_SHALL_CONTAIN_RIGHT_PDF_VERSION, "2"), e.getMessage()); } @@ -403,14 +422,26 @@ public void createInvalidPdfAVersion13NumberWithPDFA4F() throws IOException { @Test public void createInvalidPdfAVersionNumber17WithPDFA4E() throws IOException { PdfWriter writer = new PdfWriter(new PdfWriter(new ByteArrayOutputStream()), - new WriterProperties().setPdfVersion(PdfVersion.PDF_1_7)); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4E, + new WriterProperties()); + PdfDocumentCustomVersion doc = new PdfDocumentCustomVersion(writer, PdfAConformance.PDF_A_4E, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"))); + doc.setPdfVersion(PdfVersion.PDF_1_7); doc.addNewPage(); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals( + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals( MessageFormatUtil.format(PdfaExceptionMessageConstant.THE_FILE_HEADER_SHALL_CONTAIN_RIGHT_PDF_VERSION, "2"), e.getMessage()); } + + private static class PdfDocumentCustomVersion extends PdfADocument { + + public PdfDocumentCustomVersion(PdfWriter writer, PdfAConformance aConformance, PdfOutputIntent outputIntent) { + super(writer, aConformance, outputIntent); + } + + public void setPdfVersion(PdfVersion pdfVersion) { + this.pdfVersion = pdfVersion; + } + } } diff --git a/pdfa/src/test/java/com/itextpdf/pdfa/PdfA4EmbeddedFilesCheckTest.java b/pdfa/src/test/java/com/itextpdf/pdfa/PdfA4EmbeddedFilesCheckTest.java index 3a454f1e85..397e808fba 100644 --- a/pdfa/src/test/java/com/itextpdf/pdfa/PdfA4EmbeddedFilesCheckTest.java +++ b/pdfa/src/test/java/com/itextpdf/pdfa/PdfA4EmbeddedFilesCheckTest.java @@ -23,7 +23,7 @@ This file is part of the iText (R) project. package com.itextpdf.pdfa; import com.itextpdf.commons.utils.FileUtil; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfAConformance; import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.kernel.pdf.PdfName; import com.itextpdf.kernel.pdf.PdfOutputIntent; @@ -34,22 +34,19 @@ This file is part of the iText (R) project. import com.itextpdf.pdfa.exceptions.PdfAConformanceException; import com.itextpdf.pdfa.exceptions.PdfaExceptionMessageConstant; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.IOException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfA4EmbeddedFilesCheckTest extends ExtendedITextTest { public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/pdfa/"; public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/pdfa/PdfA4EmbeddedFilesCheckTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(DESTINATION_FOLDER); } @@ -62,11 +59,11 @@ public void pdfA4fWithoutEmbeddedFilesTest() throws IOException { String outPdf = DESTINATION_FOLDER + "pdfA4fWithoutEmbeddedFilesTest.pdf"; PdfWriter writer = new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4F, createOutputIntent()); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4F, createOutputIntent()); doc.addNewPage(); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(PdfaExceptionMessageConstant.NAME_DICTIONARY_SHALL_CONTAIN_EMBEDDED_FILES_KEY, e.getMessage()); + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(PdfaExceptionMessageConstant.NAME_DICTIONARY_SHALL_CONTAIN_EMBEDDED_FILES_KEY, e.getMessage()); } @Test @@ -74,7 +71,7 @@ public void pdfA4fWithEmbeddedFilesWithoutFTest() throws IOException { String outPdf = DESTINATION_FOLDER + "pdfA4fWithEmbeddedFilesWithoutFTest.pdf"; PdfWriter writer = new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4F, createOutputIntent()); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4F, createOutputIntent()); doc.addNewPage(); PdfFileSpec fs = PdfFileSpec.createEmbeddedFileSpec( @@ -83,8 +80,8 @@ public void pdfA4fWithEmbeddedFilesWithoutFTest() throws IOException { fsDict.remove(PdfName.F); doc.addFileAttachment("file.txt", fs); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(PdfAConformanceException.FILE_SPECIFICATION_DICTIONARY_SHALL_CONTAIN_F_KEY_AND_UF_KEY, e.getMessage()); + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(PdfaExceptionMessageConstant.FILE_SPECIFICATION_DICTIONARY_SHALL_CONTAIN_F_KEY_AND_UF_KEY, e.getMessage()); } @Test @@ -92,7 +89,7 @@ public void pdfA4fWithEmbeddedFilesWithoutUFTest() throws IOException { String outPdf = DESTINATION_FOLDER + "pdfA4fWithEmbeddedFilesWithoutUFTest.pdf"; PdfWriter writer = new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4F, createOutputIntent()); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4F, createOutputIntent()); doc.addNewPage(); PdfFileSpec fs = PdfFileSpec.createEmbeddedFileSpec( @@ -101,8 +98,8 @@ public void pdfA4fWithEmbeddedFilesWithoutUFTest() throws IOException { fsDict.remove(PdfName.UF); doc.addFileAttachment("file.txt", fs); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(PdfAConformanceException.FILE_SPECIFICATION_DICTIONARY_SHALL_CONTAIN_F_KEY_AND_UF_KEY, e.getMessage()); + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(PdfaExceptionMessageConstant.FILE_SPECIFICATION_DICTIONARY_SHALL_CONTAIN_F_KEY_AND_UF_KEY, e.getMessage()); } @Test @@ -110,7 +107,7 @@ public void pdfA4fWithEmbeddedFilesWithoutAFRTest() throws IOException { String outPdf = DESTINATION_FOLDER + "pdfA4fWithEmbeddedFilesWithoutAFRTest.pdf"; PdfWriter writer = new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4F, createOutputIntent()); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4F, createOutputIntent()); doc.addNewPage(); PdfFileSpec fs = PdfFileSpec.createEmbeddedFileSpec( @@ -119,8 +116,8 @@ public void pdfA4fWithEmbeddedFilesWithoutAFRTest() throws IOException { fsDict.remove(PdfName.AFRelationship); doc.addFileAttachment("file.txt", fs); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(PdfaExceptionMessageConstant.FILE_SPECIFICATION_DICTIONARY_SHALL_CONTAIN_AFRELATIONSHIP_KEY, e.getMessage()); + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(PdfaExceptionMessageConstant.FILE_SPECIFICATION_DICTIONARY_SHALL_CONTAIN_AFRELATIONSHIP_KEY, e.getMessage()); } @Test @@ -128,7 +125,7 @@ public void pdfA4eWithEmbeddedFilesWithoutFTest() throws IOException { String outPdf = DESTINATION_FOLDER + "pdfA4eWithEmbeddedFilesWithoutFTest.pdf"; PdfWriter writer = new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4E, createOutputIntent()); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4E, createOutputIntent()); doc.addNewPage(); PdfFileSpec fs = PdfFileSpec.createEmbeddedFileSpec( @@ -137,8 +134,8 @@ public void pdfA4eWithEmbeddedFilesWithoutFTest() throws IOException { fsDict.remove(PdfName.F); doc.addFileAttachment("file.txt", fs); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(PdfAConformanceException.FILE_SPECIFICATION_DICTIONARY_SHALL_CONTAIN_F_KEY_AND_UF_KEY, e.getMessage()); + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(PdfaExceptionMessageConstant.FILE_SPECIFICATION_DICTIONARY_SHALL_CONTAIN_F_KEY_AND_UF_KEY, e.getMessage()); } @Test @@ -146,7 +143,7 @@ public void pdfA4WithEmbeddedFilesWithoutAFRTest() throws IOException { String outPdf = DESTINATION_FOLDER + "pdfA4WithEmbeddedFilesWithoutAFRTest.pdf"; PdfWriter writer = new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, createOutputIntent()); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4, createOutputIntent()); doc.addNewPage(); PdfFileSpec fs = PdfFileSpec.createEmbeddedFileSpec( @@ -155,8 +152,8 @@ public void pdfA4WithEmbeddedFilesWithoutAFRTest() throws IOException { fsDict.remove(PdfName.AFRelationship); doc.addFileAttachment("file.txt", fs); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(PdfaExceptionMessageConstant.FILE_SPECIFICATION_DICTIONARY_SHALL_CONTAIN_AFRELATIONSHIP_KEY, e.getMessage()); + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(PdfaExceptionMessageConstant.FILE_SPECIFICATION_DICTIONARY_SHALL_CONTAIN_AFRELATIONSHIP_KEY, e.getMessage()); } private PdfOutputIntent createOutputIntent() throws IOException { diff --git a/pdfa/src/test/java/com/itextpdf/pdfa/PdfA4GraphicsCheckTest.java b/pdfa/src/test/java/com/itextpdf/pdfa/PdfA4GraphicsCheckTest.java index c277377155..979d009aa5 100644 --- a/pdfa/src/test/java/com/itextpdf/pdfa/PdfA4GraphicsCheckTest.java +++ b/pdfa/src/test/java/com/itextpdf/pdfa/PdfA4GraphicsCheckTest.java @@ -36,7 +36,7 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.font.PdfFontFactory; import com.itextpdf.kernel.font.PdfFontFactory.EmbeddingStrategy; import com.itextpdf.kernel.geom.Rectangle; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfAConformance; import com.itextpdf.kernel.pdf.PdfArray; import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.kernel.pdf.PdfDocument; @@ -67,7 +67,6 @@ This file is part of the iText (R) project. import com.itextpdf.pdfa.exceptions.PdfAConformanceException; import com.itextpdf.pdfa.exceptions.PdfaExceptionMessageConstant; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import com.itextpdf.test.pdfa.VeraPdfValidator; // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) import java.io.ByteArrayOutputStream; @@ -77,20 +76,20 @@ This file is part of the iText (R) project. import java.nio.file.Files; import java.nio.file.Paths; import java.util.Collections; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.fail; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfA4GraphicsCheckTest extends ExtendedITextTest { public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/pdfa/"; public static final String CMP_FOLDER = SOURCE_FOLDER + "cmp/PdfA4GraphicsCheckTest/"; public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/pdfa/PdfA4GraphicsCheckTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(DESTINATION_FOLDER); } @@ -103,7 +102,7 @@ public void validHalftoneTest() throws IOException, InterruptedException { InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - try (PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, outputIntent)) { + try (PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4, outputIntent)) { doc.addNewPage(); PdfCanvas canvas = new PdfCanvas(doc.getLastPage()); PdfDictionary colourantHalftone = new PdfDictionary(); @@ -116,9 +115,9 @@ public void validHalftoneTest() throws IOException, InterruptedException { canvas.setExtGState(new PdfExtGState().setHalftone(halftone)); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); - Assert.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) } @Test @@ -129,7 +128,7 @@ public void validHalftoneType1Test() throws IOException, InterruptedException { InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - try (PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, outputIntent)) { + try (PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4, outputIntent)) { doc.addNewPage(); PdfCanvas canvas = new PdfCanvas(doc.getLastPage()); @@ -138,9 +137,9 @@ public void validHalftoneType1Test() throws IOException, InterruptedException { canvas.setExtGState(new PdfExtGState().setHalftone(halftone)); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); - Assert.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) } @Test @@ -151,7 +150,7 @@ public void validHalftoneTest2() throws IOException, InterruptedException { InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - try (PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, outputIntent)) { + try (PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4, outputIntent)) { doc.addNewPage(); PdfCanvas canvas = new PdfCanvas(doc.getLastPage()); PdfDictionary colourantHalftone = new PdfDictionary(); @@ -163,7 +162,7 @@ public void validHalftoneTest2() throws IOException, InterruptedException { canvas.setExtGState(new PdfExtGState().setHalftone(halftone)); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); //this pdf is invalid according to pdf 2.0 so we don't use verapdf check here //Table 128 — Entries in a Type 1 halftone dictionary @@ -180,7 +179,7 @@ public void validHalftoneTest3() throws IOException, InterruptedException { InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - try (PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, outputIntent)) { + try (PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4, outputIntent)) { doc.addNewPage(); PdfCanvas canvas = new PdfCanvas(doc.getLastPage()); PdfDictionary colourantHalftone = new PdfDictionary(); @@ -192,7 +191,7 @@ public void validHalftoneTest3() throws IOException, InterruptedException { canvas.setExtGState(new PdfExtGState().setHalftone(halftone)); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); //this pdf is invalid according to pdf 2.0 so we don't use verapdf check here //Table 128 — Entries in a Type 1 halftone dictionary @@ -207,17 +206,17 @@ public void invalidHalftoneTest1() throws IOException { InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - try (PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, outputIntent)) { + try (PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4, outputIntent)) { doc.addNewPage(); PdfCanvas canvas = new PdfCanvas(doc.getLastPage()); PdfDictionary halftone = new PdfDictionary(); halftone.put(PdfName.HalftoneType, new PdfNumber(1)); halftone.put(PdfName.TransferFunction, new PdfDictionary()); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> canvas.setExtGState(new PdfExtGState().setHalftone(halftone)) ); - Assert.assertEquals(PdfaExceptionMessageConstant.ALL_HALFTONES_CONTAINING_TRANSFER_FUNCTION_SHALL_HAVE_HALFTONETYPE_5, + Assertions.assertEquals(PdfaExceptionMessageConstant.ALL_HALFTONES_CONTAINING_TRANSFER_FUNCTION_SHALL_HAVE_HALFTONETYPE_5, e.getMessage()); } } @@ -228,17 +227,17 @@ public void invalidHalftoneTest2() throws IOException, InterruptedException { InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - try (PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, outputIntent)) { + try (PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4, outputIntent)) { doc.addNewPage(); PdfCanvas canvas = new PdfCanvas(doc.getLastPage()); PdfDictionary halftone = new PdfDictionary(); halftone.put(PdfName.HalftoneType, new PdfNumber(5)); halftone.put(PdfName.TransferFunction, new PdfDictionary()); halftone.put(PdfName.Magenta, new PdfDictionary()); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> canvas.setExtGState(new PdfExtGState().setHalftone(halftone)) ); - Assert.assertEquals(PdfaExceptionMessageConstant.ALL_HALFTONES_CONTAINING_TRANSFER_FUNCTION_SHALL_HAVE_HALFTONETYPE_5, + Assertions.assertEquals(PdfaExceptionMessageConstant.ALL_HALFTONES_CONTAINING_TRANSFER_FUNCTION_SHALL_HAVE_HALFTONETYPE_5, e.getMessage()); } } @@ -269,7 +268,7 @@ public void colorCheckTest1() throws IOException { InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - try (PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, outputIntent)) { + try (PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4, outputIntent)) { float[] whitePoint = {0.9505f, 1f, 1.089f}; float[] gamma = {2.2f, 2.2f, 2.2f}; @@ -280,10 +279,10 @@ public void colorCheckTest1() throws IOException { canvas.getResources().setDefaultCmyk(calRgb); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> canvas.setFillColor(new DeviceCmyk(0.1f, 0.1f, 0.1f, 0.1f)) ); - Assert.assertEquals(MessageFormatUtil.format(PdfAConformanceException.COLOR_SPACE_0_SHALL_HAVE_1_COMPONENTS, + Assertions.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.COLOR_SPACE_0_SHALL_HAVE_1_COMPONENTS, PdfName.DefaultCMYK.getValue(), 4), e.getMessage()); } } @@ -294,7 +293,7 @@ public void colorCheckTest2() throws IOException, InterruptedException { String cmpPdf = CMP_FOLDER + "cmp_pdfA4_colorCheckTest2.pdf"; PdfWriter writer = new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); - try (PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, null)) { + try (PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4, null)) { float[] whitePoint = {0.9505f, 1f, 1.089f}; float[] gamma = {2.2f, 2.2f, 2.2f}; @@ -326,7 +325,7 @@ public void colorCheckTest3() throws IOException { new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, outputIntent); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4, outputIntent); PdfCanvas canvas = new PdfCanvas(doc.addNewPage()); @@ -336,10 +335,10 @@ public void colorCheckTest3() throws IOException { canvas.lineTo(doc.getDefaultPageSize().getRight(), doc.getDefaultPageSize().getTop()); canvas.fill(); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close() ); - Assert.assertEquals(PdfaExceptionMessageConstant.DEVICECMYK_SHALL_ONLY_BE_USED_IF_CURRENT_CMYK_PDFA_OUTPUT_INTENT_OR_DEFAULTCMYK_IN_USAGE_CONTEXT, + Assertions.assertEquals(PdfaExceptionMessageConstant.DEVICECMYK_SHALL_ONLY_BE_USED_IF_CURRENT_CMYK_PDFA_OUTPUT_INTENT_OR_DEFAULTCMYK_IN_USAGE_CONTEXT, e.getMessage()); } @@ -351,7 +350,7 @@ public void colorCheckTest4() throws IOException { PdfWriter writer = new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, outputIntent); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4, outputIntent); PdfCanvas canvas = new PdfCanvas(doc.addNewPage()); @@ -368,8 +367,8 @@ public void colorCheckTest4() throws IOException { canvas.lineTo(doc.getDefaultPageSize().getRight(), doc.getDefaultPageSize().getTop()); canvas.fill(); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(PdfaExceptionMessageConstant.DEVICECMYK_SHALL_ONLY_BE_USED_IF_CURRENT_CMYK_PDFA_OUTPUT_INTENT_OR_DEFAULTCMYK_IN_USAGE_CONTEXT, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(PdfaExceptionMessageConstant.DEVICECMYK_SHALL_ONLY_BE_USED_IF_CURRENT_CMYK_PDFA_OUTPUT_INTENT_OR_DEFAULTCMYK_IN_USAGE_CONTEXT, e.getMessage()); } @@ -381,7 +380,7 @@ public void colorCheckTest5() throws IOException, InterruptedException { PdfWriter writer = new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, outputIntent); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4, outputIntent); PdfPage page = doc.addNewPage(); page.addOutputIntent(new PdfOutputIntent("Custom", "", "http://www.color.org", "cmyk", @@ -403,8 +402,8 @@ public void colorCheckTest5() throws IOException, InterruptedException { // Here we use RGB and CMYK at the same time. And only page output intent is taken into account not both. // So it throws on device RGB color. - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(PdfaExceptionMessageConstant.DEVICERGB_SHALL_ONLY_BE_USED_IF_CURRENT_RGB_PDFA_OUTPUT_INTENT_OR_DEFAULTRGB_IN_USAGE_CONTEXT, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(PdfaExceptionMessageConstant.DEVICERGB_SHALL_ONLY_BE_USED_IF_CURRENT_RGB_PDFA_OUTPUT_INTENT_OR_DEFAULTRGB_IN_USAGE_CONTEXT, e.getMessage()); } @@ -414,7 +413,7 @@ public void colorCheckTest6() throws IOException { new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, outputIntent); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4, outputIntent); PdfCanvas canvas = new PdfCanvas(doc.addNewPage()); @@ -432,8 +431,8 @@ public void colorCheckTest6() throws IOException { canvas.setTextRenderingMode(PdfCanvasConstants.TextRenderingMode.FILL); canvas.setFillColor(DeviceGray.GRAY).beginText().showText(shortText).endText(); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(PdfaExceptionMessageConstant.DEVICECMYK_SHALL_ONLY_BE_USED_IF_CURRENT_CMYK_PDFA_OUTPUT_INTENT_OR_DEFAULTCMYK_IN_USAGE_CONTEXT, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(PdfaExceptionMessageConstant.DEVICECMYK_SHALL_ONLY_BE_USED_IF_CURRENT_CMYK_PDFA_OUTPUT_INTENT_OR_DEFAULTCMYK_IN_USAGE_CONTEXT, e.getMessage()); } @@ -445,7 +444,7 @@ public void colorCheckTest7() throws IOException { PdfWriter writer = new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, outputIntent); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4, outputIntent); PdfPage page = doc.addNewPage(); page.addOutputIntent(new PdfOutputIntent("Custom", "", "http://www.color.org", "cmyk", @@ -468,8 +467,8 @@ public void colorCheckTest7() throws IOException { // Here we use RGB and CMYK at the same time. And only page output intent is taken into account not both. // So it throws on device RGB color. - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(PdfaExceptionMessageConstant.DEVICERGB_SHALL_ONLY_BE_USED_IF_CURRENT_RGB_PDFA_OUTPUT_INTENT_OR_DEFAULTRGB_IN_USAGE_CONTEXT, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(PdfaExceptionMessageConstant.DEVICERGB_SHALL_ONLY_BE_USED_IF_CURRENT_RGB_PDFA_OUTPUT_INTENT_OR_DEFAULTRGB_IN_USAGE_CONTEXT, e.getMessage()); } @@ -481,7 +480,7 @@ public void colorCheckTest8() throws IOException { PdfWriter writer = new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, outputIntent); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4, outputIntent); PdfCanvas canvas = new PdfCanvas(doc.addNewPage()); @@ -499,8 +498,8 @@ public void colorCheckTest8() throws IOException { canvas.setTextRenderingMode(PdfCanvasConstants.TextRenderingMode.INVISIBLE); canvas.setFillColor(new DeviceCmyk(0.1f, 0.1f, 0.1f, 0.1f)).beginText().showText(shortText).endText(); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(PdfaExceptionMessageConstant.DEVICECMYK_SHALL_ONLY_BE_USED_IF_CURRENT_CMYK_PDFA_OUTPUT_INTENT_OR_DEFAULTCMYK_IN_USAGE_CONTEXT, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(PdfaExceptionMessageConstant.DEVICECMYK_SHALL_ONLY_BE_USED_IF_CURRENT_CMYK_PDFA_OUTPUT_INTENT_OR_DEFAULTCMYK_IN_USAGE_CONTEXT, e.getMessage()); } @@ -512,7 +511,7 @@ public void colorCheckTest9() throws IOException, InterruptedException { PdfWriter writer = new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, outputIntent); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4, outputIntent); PdfPage page = doc.addNewPage(); page.addOutputIntent(new PdfOutputIntent("Custom", "", "http://www.color.org", "cmyk", @@ -544,7 +543,7 @@ public void colorCheckTest10() throws IOException, InterruptedException { String cmpPdf = CMP_FOLDER + "cmp_pdfA4_colorCheckTest10.pdf"; PdfWriter writer = new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); - PdfADocument pdfDoc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, null); + PdfADocument pdfDoc = new PdfADocument(writer, PdfAConformance.PDF_A_4, null); PdfPage page = pdfDoc.addNewPage(); // Add page blending colorspace @@ -569,7 +568,7 @@ public void colorCheckTest11() throws IOException, InterruptedException { String cmpPdf = CMP_FOLDER + "cmp_pdfA4_colorCheckTest11.pdf"; PdfWriter writer = new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); - PdfADocument pdfDoc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, null); + PdfADocument pdfDoc = new PdfADocument(writer, PdfAConformance.PDF_A_4, null); PdfPage page = pdfDoc.addNewPage(); // Add page blending colorspace @@ -598,7 +597,7 @@ public void colorCheckTest11() throws IOException, InterruptedException { // Here we have blending colorspaces set on page and xobject level but verapdf still asserts // That's very weird - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); } @Test @@ -607,7 +606,7 @@ public void colorCheckTest12() throws IOException, InterruptedException { String cmpPdf = CMP_FOLDER + "cmp_pdfA4_colorCheckTest12.pdf"; PdfWriter writer = new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); - PdfADocument pdfDoc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, null); + PdfADocument pdfDoc = new PdfADocument(writer, PdfAConformance.PDF_A_4, null); PdfPage page = pdfDoc.addNewPage(); // Add page blending colorspace @@ -632,7 +631,7 @@ public void defaultTextColorCheckTest() throws IOException { PdfDocument pdfDocument = new PdfADocument( new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)), - PdfAConformanceLevel.PDF_A_4, null); + PdfAConformance.PDF_A_4, null); PdfFont font = PdfFontFactory.createFont(SOURCE_FOLDER + "FreeSans.ttf", "Identity-H", EmbeddingStrategy.FORCE_EMBEDDED); @@ -646,8 +645,8 @@ public void defaultTextColorCheckTest() throws IOException { .endText() .restoreState(); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> pdfDocument.close()); - Assert.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.DEVICEGRAY_SHALL_ONLY_BE_USED_IF_CURRENT_PDFA_OUTPUT_INTENT_OR_DEFAULTGRAY_IN_USAGE_CONTEXT), + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfDocument.close()); + Assertions.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.DEVICEGRAY_SHALL_ONLY_BE_USED_IF_CURRENT_PDFA_OUTPUT_INTENT_OR_DEFAULTGRAY_IN_USAGE_CONTEXT), e.getMessage()); } @@ -658,7 +657,7 @@ public void defaultTextColorCheckWithPageOutputIntentTest() throws IOException, PdfDocument pdfDocument = new PdfADocument( new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)), - PdfAConformanceLevel.PDF_A_4, null); + PdfAConformance.PDF_A_4, null); PdfFont font = PdfFontFactory.createFont(SOURCE_FOLDER + "FreeSans.ttf", "Identity-H", EmbeddingStrategy.FORCE_EMBEDDED); @@ -687,7 +686,7 @@ public void defaultTextColorCheckForInvisibleTextTest() throws IOException, Inte PdfDocument pdfDocument = new PdfADocument( new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)), - PdfAConformanceLevel.PDF_A_4, null); + PdfAConformance.PDF_A_4, null); PdfFont font = PdfFontFactory.createFont(SOURCE_FOLDER + "FreeSans.ttf", "Identity-H", EmbeddingStrategy.FORCE_EMBEDDED); @@ -712,7 +711,7 @@ public void defaultStrokeColorCheckTest() throws IOException { PdfDocument pdfDocument = new PdfADocument( new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)), - PdfAConformanceLevel.PDF_A_4, null); + PdfAConformance.PDF_A_4, null); PdfPage page = pdfDocument.addNewPage(); PdfCanvas canvas = new PdfCanvas(page); canvas.saveState(); @@ -728,8 +727,8 @@ public void defaultStrokeColorCheckTest() throws IOException { canvas.stroke(); // We set fill color but don't set stroke, so the exception should be thrown - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> pdfDocument.close()); - Assert.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.DEVICEGRAY_SHALL_ONLY_BE_USED_IF_CURRENT_PDFA_OUTPUT_INTENT_OR_DEFAULTGRAY_IN_USAGE_CONTEXT), + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfDocument.close()); + Assertions.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.DEVICEGRAY_SHALL_ONLY_BE_USED_IF_CURRENT_PDFA_OUTPUT_INTENT_OR_DEFAULTGRAY_IN_USAGE_CONTEXT), e.getMessage()); } @@ -741,7 +740,7 @@ public void colorCheckWithDuplicatedCmykColorspaceTest1() throws IOException { PdfWriter writer = new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - PdfADocument pdfDoc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, outputIntent); + PdfADocument pdfDoc = new PdfADocument(writer, PdfAConformance.PDF_A_4, outputIntent); PdfPage page = pdfDoc.addNewPage(); page.addOutputIntent(new PdfOutputIntent("Custom", "", "http://www.color.org", "cmyk", @@ -754,8 +753,8 @@ public void colorCheckWithDuplicatedCmykColorspaceTest1() throws IOException { canvas.setStrokeColor(magenta).circle(250, 300, 50).stroke(); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> pdfDoc.close()); - Assert.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.ICCBASED_COLOUR_SPACE_SHALL_NOT_BE_USED_IF_IT_IS_CMYK_AND_IS_IDENTICAL_TO_CURRENT_PROFILE), + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfDoc.close()); + Assertions.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.ICCBASED_COLOUR_SPACE_SHALL_NOT_BE_USED_IF_IT_IS_CMYK_AND_IS_IDENTICAL_TO_CURRENT_PROFILE), e.getMessage()); } @@ -767,7 +766,7 @@ public void colorCheckWithDuplicatedCmykColorspaceTest2() throws IOException { PdfWriter writer = new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - PdfADocument pdfDoc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, outputIntent); + PdfADocument pdfDoc = new PdfADocument(writer, PdfAConformance.PDF_A_4, outputIntent); PdfPage page = pdfDoc.addNewPage(); // Add page blending colorspace @@ -785,8 +784,8 @@ public void colorCheckWithDuplicatedCmykColorspaceTest2() throws IOException { canvas.setStrokeColor(magenta).circle(250, 300, 50).stroke(); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> pdfDoc.close()); - Assert.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.ICCBASED_COLOUR_SPACE_SHALL_NOT_BE_USED_IF_IT_IS_CMYK_AND_IS_IDENTICAL_TO_CURRENT_PROFILE), + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfDoc.close()); + Assertions.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.ICCBASED_COLOUR_SPACE_SHALL_NOT_BE_USED_IF_IT_IS_CMYK_AND_IS_IDENTICAL_TO_CURRENT_PROFILE), e.getMessage()); } @@ -798,7 +797,7 @@ public void colorCheckWithDuplicatedCmykColorspaceTest3() throws IOException { PdfWriter writer = new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - PdfADocument pdfDoc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, outputIntent); + PdfADocument pdfDoc = new PdfADocument(writer, PdfAConformance.PDF_A_4, outputIntent); PdfPage page = pdfDoc.addNewPage(); // Add page blending colorspace @@ -825,8 +824,8 @@ public void colorCheckWithDuplicatedCmykColorspaceTest3() throws IOException { annot.setAppearance(PdfName.N, xObject.getPdfObject()); page.addAnnotation(annot); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> pdfDoc.close()); - Assert.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.ICCBASED_COLOUR_SPACE_SHALL_NOT_BE_USED_IF_IT_IS_CMYK_AND_IS_IDENTICAL_TO_CURRENT_PROFILE), + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfDoc.close()); + Assertions.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.ICCBASED_COLOUR_SPACE_SHALL_NOT_BE_USED_IF_IT_IS_CMYK_AND_IS_IDENTICAL_TO_CURRENT_PROFILE), e.getMessage()); } @@ -838,7 +837,7 @@ public void colorCheckWithDuplicatedCmykColorspaceTest4() throws IOException, In PdfWriter writer = new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - PdfADocument pdfDoc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, outputIntent); + PdfADocument pdfDoc = new PdfADocument(writer, PdfAConformance.PDF_A_4, outputIntent); PdfPage page = pdfDoc.addNewPage(); @@ -871,8 +870,8 @@ public void colorCheckWithDuplicatedCmykColorspaceTest4() throws IOException, In page.addAnnotation(annot); // Verapdf doesn't assert for such file however the expectation is that it's not a valid pdfa4 - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> pdfDoc.close()); - Assert.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.ICCBASED_COLOUR_SPACE_SHALL_NOT_BE_USED_IF_IT_IS_CMYK_AND_IS_IDENTICAL_TO_CURRENT_PROFILE), + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfDoc.close()); + Assertions.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.ICCBASED_COLOUR_SPACE_SHALL_NOT_BE_USED_IF_IT_IS_CMYK_AND_IS_IDENTICAL_TO_CURRENT_PROFILE), e.getMessage()); } @@ -884,7 +883,7 @@ public void colorCheckWithDuplicatedRgbColorspaceTest() throws IOException, Inte PdfWriter writer = new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - PdfADocument pdfDoc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, outputIntent); + PdfADocument pdfDoc = new PdfADocument(writer, PdfAConformance.PDF_A_4, outputIntent); PdfPage page = pdfDoc.addNewPage(); PdfCanvas canvas = new PdfCanvas(page); @@ -908,7 +907,7 @@ public void colorCheckWithDuplicatedRgbAndCmykColorspaceTest() throws IOExceptio PdfWriter writer = new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - PdfADocument pdfDoc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, outputIntent); + PdfADocument pdfDoc = new PdfADocument(writer, PdfAConformance.PDF_A_4, outputIntent); PdfPage page = pdfDoc.addNewPage(); page.addOutputIntent(new PdfOutputIntent("Custom", "", "http://www.color.org", "cmyk", @@ -923,8 +922,8 @@ public void colorCheckWithDuplicatedRgbAndCmykColorspaceTest() throws IOExceptio canvas.setStrokeColor(green).setFillColor(magenta).circle(250, 300, 50).fillStroke(); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> pdfDoc.close()); - Assert.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.ICCBASED_COLOUR_SPACE_SHALL_NOT_BE_USED_IF_IT_IS_CMYK_AND_IS_IDENTICAL_TO_CURRENT_PROFILE), + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfDoc.close()); + Assertions.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.ICCBASED_COLOUR_SPACE_SHALL_NOT_BE_USED_IF_IT_IS_CMYK_AND_IS_IDENTICAL_TO_CURRENT_PROFILE), e.getMessage()); } @@ -936,7 +935,7 @@ public void colorCheckWithDuplicated2CmykColorspacesTest() throws IOException { PdfWriter writer = new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - PdfADocument pdfDoc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, outputIntent); + PdfADocument pdfDoc = new PdfADocument(writer, PdfAConformance.PDF_A_4, outputIntent); PdfPage page = pdfDoc.addNewPage(); page.addOutputIntent(new PdfOutputIntent("Custom", "", "http://www.color.org", "cmyk", @@ -951,8 +950,8 @@ public void colorCheckWithDuplicated2CmykColorspacesTest() throws IOException { canvas.setStrokeColor(cayan).setFillColor(magenta).circle(250, 300, 50).fillStroke(); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> pdfDoc.close()); - Assert.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.ICCBASED_COLOUR_SPACE_SHALL_NOT_BE_USED_IF_IT_IS_CMYK_AND_IS_IDENTICAL_TO_CURRENT_PROFILE), + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfDoc.close()); + Assertions.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.ICCBASED_COLOUR_SPACE_SHALL_NOT_BE_USED_IF_IT_IS_CMYK_AND_IS_IDENTICAL_TO_CURRENT_PROFILE), e.getMessage()); } @@ -963,7 +962,7 @@ public void colourSpaceTest01() throws IOException, InterruptedException { PdfWriter writer = new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); PdfPage page = doc.addNewPage(); PdfColorSpace alternateSpace= new PdfDeviceCs.Rgb(); @@ -992,7 +991,7 @@ public void colourSpaceTest02() throws IOException, InterruptedException { PdfWriter writer = new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); PdfPage page = doc.addNewPage(); PdfColorSpace alternateSpace= new PdfDeviceCs.Rgb(); @@ -1020,7 +1019,7 @@ public void colourSpaceTest03() throws IOException, InterruptedException { PdfWriter writer = new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); PdfPage page = doc.addNewPage(); PdfColorSpace alternateSpace= new PdfDeviceCs.Rgb(); @@ -1056,7 +1055,7 @@ public void imageFailureTest() throws IOException { PdfDocument pdfDoc = new PdfADocument( new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)), - PdfAConformanceLevel.PDF_A_4, null); + PdfAConformance.PDF_A_4, null); PdfPage page = pdfDoc.addNewPage(); // This should suppress transparency issue @@ -1070,8 +1069,8 @@ public void imageFailureTest() throws IOException { canvas.restoreState(); // But devicergb should still be not allowed - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> pdfDoc.close()); - Assert.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.DEVICERGB_SHALL_ONLY_BE_USED_IF_CURRENT_RGB_PDFA_OUTPUT_INTENT_OR_DEFAULTRGB_IN_USAGE_CONTEXT), + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfDoc.close()); + Assertions.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.DEVICERGB_SHALL_ONLY_BE_USED_IF_CURRENT_RGB_PDFA_OUTPUT_INTENT_OR_DEFAULTRGB_IN_USAGE_CONTEXT), e.getMessage()); } @@ -1082,7 +1081,7 @@ public void imageTest() throws IOException, InterruptedException { PdfDocument pdfDoc = new PdfADocument( new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)), - PdfAConformanceLevel.PDF_A_4, null); + PdfAConformance.PDF_A_4, null); PdfPage page = pdfDoc.addNewPage(); // This should suppress transparency and device RGB @@ -1107,7 +1106,7 @@ public void imageJpeg20002ColorChannelsTest() throws IOException { PdfDocument pdfDoc = new PdfADocument( new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)), - PdfAConformanceLevel.PDF_A_4, null); + PdfAConformance.PDF_A_4, null); PdfPage page = pdfDoc.addNewPage(); // This should suppress transparency and device RGB @@ -1121,10 +1120,10 @@ public void imageJpeg20002ColorChannelsTest() throws IOException { new Rectangle(0, 0, page.getPageSize().getWidth() / 2, page.getPageSize().getHeight() / 2), false); canvas.restoreState(); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfDoc.close() ); - Assert.assertEquals(PdfaExceptionMessageConstant.THE_NUMBER_OF_COLOUR_CHANNELS_IN_THE_JPEG2000_DATA_SHALL_BE_1_3_OR_4, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.THE_NUMBER_OF_COLOUR_CHANNELS_IN_THE_JPEG2000_DATA_SHALL_BE_1_3_OR_4, e.getMessage()); } @Test @@ -1134,7 +1133,7 @@ public void imageJpeg2000Test() throws IOException, InterruptedException { PdfDocument pdfDoc = new PdfADocument( new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)), - PdfAConformanceLevel.PDF_A_4, null); + PdfAConformance.PDF_A_4, null); PdfPage page = pdfDoc.addNewPage(); // This should suppress transparency and device RGB @@ -1159,7 +1158,7 @@ public void pdfA4AnnotationsNoOutputIntentTest() throws IOException, Interrupted String cmpPdf = CMP_FOLDER + "cmp_pdfA4AnnotationsNoOutputIntent.pdf"; PdfWriter writer = new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); - PdfADocument pdfDoc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, null); + PdfADocument pdfDoc = new PdfADocument(writer, PdfAConformance.PDF_A_4, null); PdfPage page = pdfDoc.addNewPage(); PdfAnnotation annot = new PdfCircleAnnotation(new Rectangle(100, 100, 100, 100)); @@ -1174,8 +1173,8 @@ public void pdfA4AnnotationsNoOutputIntentTest() throws IOException, Interrupted annot.setAppearance(PdfName.N, xObject.getPdfObject()); page.addAnnotation(annot); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> pdfDoc.close()); - Assert.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.DEVICERGB_SHALL_ONLY_BE_USED_IF_CURRENT_RGB_PDFA_OUTPUT_INTENT_OR_DEFAULTRGB_IN_USAGE_CONTEXT), + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfDoc.close()); + Assertions.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.DEVICERGB_SHALL_ONLY_BE_USED_IF_CURRENT_RGB_PDFA_OUTPUT_INTENT_OR_DEFAULTRGB_IN_USAGE_CONTEXT), e.getMessage()); } @@ -1185,7 +1184,7 @@ public void pdfA4AnnotationsWrongPageOutputIntentTest() throws IOException, Inte String cmpPdf = CMP_FOLDER + "cmp_pdfA4AnnotationsWrongPageOutputIntent.pdf"; PdfWriter writer = new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); - PdfADocument pdfDoc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, null); + PdfADocument pdfDoc = new PdfADocument(writer, PdfAConformance.PDF_A_4, null); PdfPage page = pdfDoc.addNewPage(); page.addOutputIntent(new PdfOutputIntent("Custom", "", "http://www.color.org", "cmyk", FileUtil.getInputStreamForFile(SOURCE_FOLDER + "USWebUncoated.icc"))); @@ -1204,8 +1203,8 @@ public void pdfA4AnnotationsWrongPageOutputIntentTest() throws IOException, Inte annot.setAppearance(PdfName.N, xObject.getPdfObject()); page.addAnnotation(annot); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> pdfDoc.close()); - Assert.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.DEVICERGB_SHALL_ONLY_BE_USED_IF_CURRENT_RGB_PDFA_OUTPUT_INTENT_OR_DEFAULTRGB_IN_USAGE_CONTEXT), + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfDoc.close()); + Assertions.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.DEVICERGB_SHALL_ONLY_BE_USED_IF_CURRENT_RGB_PDFA_OUTPUT_INTENT_OR_DEFAULTRGB_IN_USAGE_CONTEXT), e.getMessage()); } @@ -1215,7 +1214,7 @@ public void pdfA4AnnotationsCorrectPageOutputIntentTest() throws IOException, In String cmpPdf = CMP_FOLDER + "cmp_pdfA4AnnotationsCorrectPageOutputIntent.pdf"; PdfWriter writer = new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); - PdfADocument pdfDoc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, null); + PdfADocument pdfDoc = new PdfADocument(writer, PdfAConformance.PDF_A_4, null); PdfPage page = pdfDoc.addNewPage(); page.addOutputIntent(new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", @@ -1246,7 +1245,7 @@ public void destOutputIntentProfileNotAllowedTest() throws IOException { String isoFilePath = SOURCE_FOLDER + "ISOcoated_v2_300_bas.icc"; PdfWriter writer = new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); - PdfADocument pdfDoc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, null); + PdfADocument pdfDoc = new PdfADocument(writer, PdfAConformance.PDF_A_4, null); byte[] bytes = Files.readAllBytes(Paths.get(isoFilePath)); byte[] manipulatedBytes = new String(bytes, StandardCharsets.US_ASCII).replace("prtr", "not_def").getBytes(StandardCharsets.US_ASCII); @@ -1256,10 +1255,10 @@ public void destOutputIntentProfileNotAllowedTest() throws IOException { pdfOutputIntent.getPdfObject().put(PdfName.DestOutputProfile, new PdfStream(manipulatedBytes)); pdfDoc.addOutputIntent(pdfOutputIntent); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfDoc.close() ); - Assert.assertEquals(PdfaExceptionMessageConstant.PROFILE_STREAM_OF_OUTPUTINTENT_SHALL_BE_OUTPUT_PROFILE_PRTR_OR_MONITOR_PROFILE_MNTR, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.PROFILE_STREAM_OF_OUTPUTINTENT_SHALL_BE_OUTPUT_PROFILE_PRTR_OR_MONITOR_PROFILE_MNTR, e.getMessage()); } @Test @@ -1268,7 +1267,7 @@ public void destOutputIntentProfileNotAllowedInPageTest() throws IOException { String isoFilePath = SOURCE_FOLDER + "ISOcoated_v2_300_bas.icc"; PdfWriter writer = new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); - PdfADocument pdfDoc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, null); + PdfADocument pdfDoc = new PdfADocument(writer, PdfAConformance.PDF_A_4, null); PdfPage page = pdfDoc.addNewPage(); byte[] bytes = Files.readAllBytes(Paths.get(isoFilePath)); @@ -1280,10 +1279,10 @@ public void destOutputIntentProfileNotAllowedInPageTest() throws IOException { pdfOutputIntent.getPdfObject().put(PdfName.DestOutputProfile, new PdfStream(manipulatedBytes)); page.addOutputIntent(pdfOutputIntent); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfDoc.close() ); - Assert.assertEquals(PdfaExceptionMessageConstant.PROFILE_STREAM_OF_OUTPUTINTENT_SHALL_BE_OUTPUT_PROFILE_PRTR_OR_MONITOR_PROFILE_MNTR, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.PROFILE_STREAM_OF_OUTPUTINTENT_SHALL_BE_OUTPUT_PROFILE_PRTR_OR_MONITOR_PROFILE_MNTR, e.getMessage()); } @Test @@ -1292,7 +1291,7 @@ public void destOutputIntentColorSpaceNotAllowedTest() throws IOException { String isoFilePath = SOURCE_FOLDER + "ISOcoated_v2_300_bas.icc"; PdfWriter writer = new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); - PdfADocument pdfDoc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, null); + PdfADocument pdfDoc = new PdfADocument(writer, PdfAConformance.PDF_A_4, null); byte[] bytes = Files.readAllBytes(Paths.get(isoFilePath)); byte[] manipulatedBytes = new String(bytes, StandardCharsets.US_ASCII).replace("CMYK", "not_def").getBytes(StandardCharsets.US_ASCII); @@ -1302,10 +1301,10 @@ public void destOutputIntentColorSpaceNotAllowedTest() throws IOException { pdfOutputIntent.getPdfObject().put(PdfName.DestOutputProfile, new PdfStream(manipulatedBytes)); pdfDoc.addOutputIntent(pdfOutputIntent); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfDoc.close() ); - Assert.assertEquals(PdfaExceptionMessageConstant.OUTPUT_INTENT_COLOR_SPACE_SHALL_BE_EITHER_GRAY_RGB_OR_CMYK, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.OUTPUT_INTENT_COLOR_SPACE_SHALL_BE_EITHER_GRAY_RGB_OR_CMYK, e.getMessage()); } @@ -1315,7 +1314,7 @@ public void destOutputIntentColorSpaceNotAllowedInPageTest() throws IOException String isoFilePath = SOURCE_FOLDER + "ISOcoated_v2_300_bas.icc"; PdfWriter writer = new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); - PdfADocument pdfDoc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, null); + PdfADocument pdfDoc = new PdfADocument(writer, PdfAConformance.PDF_A_4, null); PdfPage page = pdfDoc.addNewPage(); byte[] bytes = Files.readAllBytes(Paths.get(isoFilePath)); @@ -1326,10 +1325,10 @@ public void destOutputIntentColorSpaceNotAllowedInPageTest() throws IOException pdfOutputIntent.getPdfObject().put(PdfName.DestOutputProfile, new PdfStream(manipulatedBytes)); page.addOutputIntent(pdfOutputIntent); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfDoc.close() ); - Assert.assertEquals(PdfaExceptionMessageConstant.OUTPUT_INTENT_COLOR_SPACE_SHALL_BE_EITHER_GRAY_RGB_OR_CMYK, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.OUTPUT_INTENT_COLOR_SPACE_SHALL_BE_EITHER_GRAY_RGB_OR_CMYK, e.getMessage()); } @@ -1337,9 +1336,9 @@ public void destOutputIntentColorSpaceNotAllowedInPageTest() throws IOException @Test public void destOutputIntentRefNotAllowedTest() throws IOException { String outPdf = DESTINATION_FOLDER + "PdfWithOutputIntentProfileRef.pdf"; - PdfAConformanceLevel conformanceLevel = PdfAConformanceLevel.PDF_A_4; + PdfAConformance conformance = PdfAConformance.PDF_A_4; PdfWriter writer = new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); - PdfADocument pdfADocument = new PdfADocument(writer, conformanceLevel, + PdfADocument pdfADocument = new PdfADocument(writer, conformance, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"))); PdfPage page = pdfADocument.addNewPage(); @@ -1351,8 +1350,8 @@ public void destOutputIntentRefNotAllowedTest() throws IOException { outputIntents.add(outputIntent); catalog.put(PdfName.OutputIntents, outputIntents); - Exception exc = Assert.assertThrows(PdfAConformanceException.class, () -> pdfADocument.close()); - Assert.assertEquals(PdfaExceptionMessageConstant.OUTPUTINTENT_SHALL_NOT_CONTAIN_DESTOUTPUTPROFILEREF_KEY, + Exception exc = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfADocument.close()); + Assertions.assertEquals(PdfaExceptionMessageConstant.OUTPUTINTENT_SHALL_NOT_CONTAIN_DESTOUTPUTPROFILEREF_KEY, exc.getMessage()); } @@ -1364,7 +1363,7 @@ private void testWithColourant(PdfName color) throws IOException { PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - try (PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, outputIntent)) { + try (PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4, outputIntent)) { doc.addNewPage(); PdfCanvas canvas = new PdfCanvas(doc.getLastPage()); PdfDictionary colourantHalftone = new PdfDictionary(); @@ -1374,17 +1373,17 @@ private void testWithColourant(PdfName color) throws IOException { PdfDictionary halftone = new PdfDictionary(); halftone.put(PdfName.HalftoneType, new PdfNumber(5)); halftone.put(color, colourantHalftone); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> canvas.setExtGState(new PdfExtGState().setHalftone(halftone)) ); - Assert.assertEquals( + Assertions.assertEquals( PdfaExceptionMessageConstant.ALL_HALFTONES_CONTAINING_TRANSFER_FUNCTION_SHALL_HAVE_HALFTONETYPE_5, e.getMessage()); } } private void compareResult(String outPdf, String cmpPdf) throws IOException, InterruptedException { - Assert.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) String result = new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_"); if (result != null) { fail(result); diff --git a/pdfa/src/test/java/com/itextpdf/pdfa/PdfA4MiscCheckTest.java b/pdfa/src/test/java/com/itextpdf/pdfa/PdfA4MiscCheckTest.java index 80cb06af76..e5493c37c3 100644 --- a/pdfa/src/test/java/com/itextpdf/pdfa/PdfA4MiscCheckTest.java +++ b/pdfa/src/test/java/com/itextpdf/pdfa/PdfA4MiscCheckTest.java @@ -23,7 +23,7 @@ This file is part of the iText (R) project. package com.itextpdf.pdfa; import com.itextpdf.commons.utils.FileUtil; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfAConformance; import com.itextpdf.kernel.pdf.PdfArray; import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.kernel.pdf.PdfName; @@ -34,24 +34,21 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.WriterProperties; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import com.itextpdf.test.pdfa.VeraPdfValidator; // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) -import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.IOException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfA4MiscCheckTest extends ExtendedITextTest { public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/pdfa/"; public static final String CMP_FOLDER = SOURCE_FOLDER + "cmp/PdfA4MiscCheckTest/"; public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/pdfa/PdfA4MiscCheckTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(DESTINATION_FOLDER); } @@ -62,7 +59,7 @@ public void pdfA4CheckThatAsKeyIsAllowedTest() throws IOException, InterruptedEx String cmpPdf = CMP_FOLDER + "cmp_pdfA4CheckThatAsKeyIsAllowedTest.pdf"; PdfWriter writer = new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); - try (PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, createOutputIntent())) { + try (PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4, createOutputIntent())) { doc.addNewPage(); PdfArray configs = new PdfArray(); @@ -92,10 +89,10 @@ private PdfOutputIntent createOutputIntent() throws IOException { } private void compareResult(String outPdf, String cmpPdf) throws IOException, InterruptedException { - Assert.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) String result = new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_"); if (result != null) { - Assert.fail(result); + Assertions.fail(result); } } } diff --git a/pdfa/src/test/java/com/itextpdf/pdfa/PdfA4TransparencyCheckTest.java b/pdfa/src/test/java/com/itextpdf/pdfa/PdfA4TransparencyCheckTest.java index 5670adee69..188832d5ef 100644 --- a/pdfa/src/test/java/com/itextpdf/pdfa/PdfA4TransparencyCheckTest.java +++ b/pdfa/src/test/java/com/itextpdf/pdfa/PdfA4TransparencyCheckTest.java @@ -29,7 +29,7 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.font.PdfFontFactory; import com.itextpdf.kernel.font.PdfFontFactory.EmbeddingStrategy; import com.itextpdf.kernel.geom.Rectangle; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfAConformance; import com.itextpdf.kernel.pdf.PdfArray; import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.kernel.pdf.PdfDocument; @@ -52,25 +52,24 @@ This file is part of the iText (R) project. import com.itextpdf.pdfa.exceptions.PdfAConformanceException; import com.itextpdf.pdfa.exceptions.PdfaExceptionMessageConstant; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import com.itextpdf.test.pdfa.VeraPdfValidator; // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; +import static org.junit.jupiter.api.Assertions.fail; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfA4TransparencyCheckTest extends ExtendedITextTest { public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/pdfa/"; public static final String CMP_FOLDER = "./src/test/resources/com/itextpdf/pdfa/cmp/PdfA4TransparencyCheckTest/"; public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/pdfa/PdfA4TransparencyCheckTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(DESTINATION_FOLDER); } @@ -81,7 +80,7 @@ public void textTransparencyPageOutputIntentTest() throws IOException, Interrupt String cmpPdf = CMP_FOLDER + "cmp_textTransparencyPageOutputIntent.pdf"; PdfWriter writer = new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); - PdfDocument pdfDocument = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, null); + PdfDocument pdfDocument = new PdfADocument(writer, PdfAConformance.PDF_A_4, null); PdfFont font = PdfFontFactory.createFont(SOURCE_FOLDER + "FreeSans.ttf", "Identity-H", EmbeddingStrategy.FORCE_EMBEDDED); @@ -114,7 +113,7 @@ public void textTransparencyPageWrongOutputIntentTest() throws IOException { String outPdf = DESTINATION_FOLDER + "textTransparencyPageWrongOutputIntent.pdf"; PdfWriter writer = new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); - PdfDocument pdfDoc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, null); + PdfDocument pdfDoc = new PdfADocument(writer, PdfAConformance.PDF_A_4, null); PdfFont font = PdfFontFactory.createFont(SOURCE_FOLDER + "FreeSans.ttf", "Identity-H", EmbeddingStrategy.FORCE_EMBEDDED); @@ -137,8 +136,8 @@ public void textTransparencyPageWrongOutputIntentTest() throws IOException { .endText() .restoreState(); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> pdfDoc.close()); - Assert.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.THE_DOCUMENT_AND_THE_PAGE_DO_NOT_CONTAIN_A_PDFA_OUTPUTINTENT_BUT_PAGE_CONTAINS_TRANSPARENCY_AND_DOES_NOT_CONTAIN_BLENDING_COLOR_SPACE), + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfDoc.close()); + Assertions.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.THE_DOCUMENT_AND_THE_PAGE_DO_NOT_CONTAIN_A_PDFA_OUTPUTINTENT_BUT_PAGE_CONTAINS_TRANSPARENCY_AND_DOES_NOT_CONTAIN_BLENDING_COLOR_SPACE), e.getMessage()); } @@ -149,7 +148,7 @@ public void transparentTextWithGroupColorSpaceTest() throws IOException, Interru PdfDocument pdfDocument = new PdfADocument( new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)), - PdfAConformanceLevel.PDF_A_4, null); + PdfAConformance.PDF_A_4, null); PdfFont font = PdfFontFactory.createFont(SOURCE_FOLDER + "FreeSans.ttf", "Identity-H", EmbeddingStrategy.FORCE_EMBEDDED); @@ -195,7 +194,7 @@ public void transparentTextWithGroupColorSpaceTest() throws IOException, Interru @Test public void blendModeTest() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream(), new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); - try (PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, createOutputIntent())) { + try (PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4, createOutputIntent())) { PdfCanvas canvas = new PdfCanvas(doc.addNewPage()); canvas.saveState(); @@ -207,11 +206,11 @@ public void blendModeTest() throws IOException { canvas.saveState(); // Verapdf doesn't assert on PdfName.Compatible apparently but let's be strict here - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> canvas.setExtGState(new PdfExtGState().setBlendMode(PdfName.Compatible)) ); - Assert.assertEquals( - PdfAConformanceException.ONLY_STANDARD_BLEND_MODES_SHALL_BE_USED_FOR_THE_VALUE_OF_THE_BM_KEY_IN_AN_EXTENDED_GRAPHIC_STATE_DICTIONARY, + Assertions.assertEquals( + PdfaExceptionMessageConstant.ONLY_STANDARD_BLEND_MODES_SHALL_BE_USED_FOR_THE_VALUE_OF_THE_BM_KEY_IN_AN_EXTENDED_GRAPHIC_STATE_DICTIONARY, e.getMessage()); } @@ -220,7 +219,7 @@ public void blendModeTest() throws IOException { @Test public void blendModeAnnotationTest() { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream(), new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); - PdfDocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, null); + PdfDocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4, null); PdfFormXObject formXObject = new PdfFormXObject(new Rectangle(100f, 100f)); Canvas canvas = new Canvas(formXObject, doc); @@ -235,8 +234,8 @@ public void blendModeAnnotationTest() { PdfPage page = doc.addNewPage(); page.addAnnotation(annotation); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(PdfaExceptionMessageConstant.THE_DOCUMENT_AND_THE_PAGE_DO_NOT_CONTAIN_A_PDFA_OUTPUTINTENT_BUT_PAGE_CONTAINS_TRANSPARENCY_AND_DOES_NOT_CONTAIN_BLENDING_COLOR_SPACE, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(PdfaExceptionMessageConstant.THE_DOCUMENT_AND_THE_PAGE_DO_NOT_CONTAIN_A_PDFA_OUTPUTINTENT_BUT_PAGE_CONTAINS_TRANSPARENCY_AND_DOES_NOT_CONTAIN_BLENDING_COLOR_SPACE, e.getMessage()); } @@ -246,7 +245,7 @@ public void blendModeAnnotationOutputIntentTest() throws IOException, Interrupte String cmpPdf = CMP_FOLDER + "cmp_blendModeAnnotationOutputIntent.pdf"; PdfWriter writer = new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); - try (PdfDocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, null)) { + try (PdfDocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4, null)) { PdfFormXObject formXObject = new PdfFormXObject(new Rectangle(100f, 100f)); Canvas canvas = new Canvas(formXObject, doc); canvas.getPdfCanvas().circle(50f, 50f, 40f); @@ -269,7 +268,7 @@ public void blendModeAnnotationOutputIntentTest() throws IOException, Interrupte public void forbiddenBlendModeAnnotationTest() throws IOException { PdfWriter writer = new PdfWriter(new com.itextpdf.io.source.ByteArrayOutputStream(), new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, createOutputIntent()); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4, createOutputIntent()); PdfFormXObject formXObject = new PdfFormXObject(new Rectangle(0f, 0f)); PdfAnnotation annotation = new PdfPopupAnnotation(new Rectangle(0f, 0f)); @@ -279,13 +278,13 @@ public void forbiddenBlendModeAnnotationTest() throws IOException { PdfPage page = doc.addNewPage(); page.addAnnotation(annotation); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(PdfaExceptionMessageConstant.ONLY_STANDARD_BLEND_MODES_SHALL_BE_USED_FOR_THE_VALUE_OF_THE_BM_KEY_IN_A_GRAPHIC_STATE_AND_ANNOTATION_DICTIONARY, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(PdfaExceptionMessageConstant.ONLY_STANDARD_BLEND_MODES_SHALL_BE_USED_FOR_THE_VALUE_OF_THE_BM_KEY_IN_A_GRAPHIC_STATE_AND_ANNOTATION_DICTIONARY, e.getMessage()); } private void compareResult(String outPdf, String cmpPdf) throws IOException, InterruptedException { - Assert.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) String result = new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_"); if (result != null) { fail(result); diff --git a/pdfa/src/test/java/com/itextpdf/pdfa/PdfAAgnosticPdfDocumentUnitTest.java b/pdfa/src/test/java/com/itextpdf/pdfa/PdfAAgnosticPdfDocumentUnitTest.java deleted file mode 100644 index f38b1e3ab0..0000000000 --- a/pdfa/src/test/java/com/itextpdf/pdfa/PdfAAgnosticPdfDocumentUnitTest.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - This file is part of the iText (R) project. - Copyright (c) 1998-2024 Apryse Group NV - Authors: Apryse Software. - - This program is offered under a commercial and under the AGPL license. - For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. - - AGPL licensing: - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . - */ -package com.itextpdf.pdfa; - -import com.itextpdf.io.source.ByteArrayOutputStream; -import com.itextpdf.kernel.pdf.IPdfPageFactory; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; -import com.itextpdf.kernel.pdf.PdfObject; -import com.itextpdf.kernel.pdf.PdfReader; -import com.itextpdf.kernel.pdf.PdfWriter; -import com.itextpdf.kernel.pdf.StampingProperties; -import com.itextpdf.kernel.xmp.XMPConst; -import com.itextpdf.kernel.xmp.XMPException; -import com.itextpdf.kernel.xmp.XMPMeta; -import com.itextpdf.kernel.xmp.XMPMetaFactory; -import com.itextpdf.pdfa.logs.PdfALogMessageConstant; -import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.LogMessage; -import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.UnitTest; - -import java.io.IOException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -@Category(UnitTest.class) -public class PdfAAgnosticPdfDocumentUnitTest extends ExtendedITextTest { - public static final String sourceFolder = "./src/test/resources/com/itextpdf/pdfa/"; - public static final String destinationFolder = "./target/test/com/itextpdf/pdfa/AgnosticPdfDocumentUnitTest/"; - - @BeforeClass - public static void beforeClass() { - createOrClearDestinationFolder(destinationFolder); - } - - @Test - public void loadPdfDocumentTest() throws IOException, XMPException { - TestAgnosticPdfDocument pdfDoc = new TestAgnosticPdfDocument(new PdfReader(sourceFolder + "pdfs/simpleDoc.pdf"), - new PdfWriter(new ByteArrayOutputStream())); - - pdfDoc.flushObjectPublic(pdfDoc.getPage(1).getPdfObject(), true); - Assert.assertTrue(pdfDoc.getPage(1).getPdfObject().isFlushed()); - - pdfDoc.checkIsoConformancePublic(); // Does nothing for PdfDocument - Assert.assertFalse(pdfDoc.getPageFactoryPublic() instanceof PdfAPageFactory); - Assert.assertNull(pdfDoc.getConformanceLevel()); - - pdfDoc.updateXmpMetadataPublic(); - XMPMeta xmpMeta = XMPMetaFactory.parseFromBuffer(pdfDoc.getXmpMetadata(true)); - Assert.assertNull(xmpMeta.getProperty(XMPConst.NS_PDFA_ID, XMPConst.PART)); - Assert.assertNull(xmpMeta.getProperty(XMPConst.NS_PDFA_ID, XMPConst.CONFORMANCE)); - - pdfDoc.close(); - } - - @Test - public void getDefaultFont() throws IOException { - TestAgnosticPdfDocument pdfDoc = new TestAgnosticPdfDocument(new PdfReader(sourceFolder + "pdfs/simpleDoc.pdf"), - new PdfWriter(new ByteArrayOutputStream())); - Assert.assertNotNull(pdfDoc.getDefaultFont()); - } - - @Test - @LogMessages(messages = { - @LogMessage(messageTemplate = PdfALogMessageConstant.PDFA_OBJECT_FLUSHING_WAS_NOT_PERFORMED)}) - public void loadPdfADocumentTest() throws IOException, XMPException { - TestAgnosticPdfDocument pdfADoc = new TestAgnosticPdfDocument(new PdfReader(sourceFolder + "pdfs/pdfa.pdf"), - new PdfWriter(new ByteArrayOutputStream()), new StampingProperties()); - - pdfADoc.flushObjectPublic(pdfADoc.getPage(1).getPdfObject(), true); - Assert.assertFalse(pdfADoc.getPage(1).getPdfObject().isFlushed()); - - pdfADoc.checkIsoConformancePublic(); - Assert.assertEquals(PdfAConformanceLevel.PDF_A_2B, pdfADoc.getConformanceLevel()); - Assert.assertTrue(pdfADoc.getPageFactoryPublic() instanceof PdfAPageFactory); - - pdfADoc.updateXmpMetadataPublic(); - XMPMeta xmpMeta = XMPMetaFactory.parseFromBuffer(pdfADoc.getXmpMetadata(true)); - Assert.assertNotNull(xmpMeta.getProperty(XMPConst.NS_PDFA_ID, XMPConst.PART)); - Assert.assertNotNull(xmpMeta.getProperty(XMPConst.NS_PDFA_ID, XMPConst.CONFORMANCE)); - - // Extra PdfA error message check - pdfADoc.flushObjectPublic(pdfADoc.getCatalog().getPdfObject(), true); - Assert.assertFalse(pdfADoc.getCatalog().getPdfObject().isFlushed()); - - pdfADoc.close(); - } - - private class TestAgnosticPdfDocument extends PdfAAgnosticPdfDocument { - - public TestAgnosticPdfDocument(PdfReader reader, PdfWriter writer) { - super(reader, writer, new StampingProperties()); - } - - public TestAgnosticPdfDocument(PdfReader reader, PdfWriter writer, StampingProperties properties) { - super(reader, writer, properties); - } - - public void checkIsoConformancePublic() { - super.checkIsoConformance(); - } - - public IPdfPageFactory getPageFactoryPublic() { - return super.getPageFactory(); - } - - public void updateXmpMetadataPublic() { - super.updateXmpMetadata(); - } - - public void flushObjectPublic(PdfObject pdfObject, boolean canBeInObjStm) throws IOException { - super.flushObject(pdfObject, canBeInObjStm); - } - } -} diff --git a/pdfa/src/test/java/com/itextpdf/pdfa/PdfAAppendModeTest.java b/pdfa/src/test/java/com/itextpdf/pdfa/PdfAAppendModeTest.java index 0f2670eb9c..4beedc3e71 100644 --- a/pdfa/src/test/java/com/itextpdf/pdfa/PdfAAppendModeTest.java +++ b/pdfa/src/test/java/com/itextpdf/pdfa/PdfAAppendModeTest.java @@ -25,7 +25,7 @@ This file is part of the iText (R) project. import com.itextpdf.commons.utils.FileUtil; import com.itextpdf.kernel.font.PdfFontFactory; import com.itextpdf.kernel.font.PdfFontFactory.EmbeddingStrategy; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfAConformance; import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfOutputIntent; import com.itextpdf.kernel.pdf.PdfReader; @@ -35,25 +35,23 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.canvas.PdfCanvas; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import com.itextpdf.test.pdfa.VeraPdfValidator; // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) -import java.io.FileInputStream; import java.io.IOException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; +import static org.junit.jupiter.api.Assertions.fail; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfAAppendModeTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/pdfa/"; public static final String testDirName = "PdfAAppendModeTest/"; public static final String cmpFolder = sourceFolder + "cmp/" + testDirName; public static final String destinationFolder = "./target/test/com/itextpdf/pdfa/" + testDirName; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } @@ -77,14 +75,14 @@ public void addPageInAppendModeTest() throws IOException, InterruptedException { .restoreState(); canvas.release(); pdfADocument.close(); - Assert.assertNull(new VeraPdfValidator().validate(inputFile)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) - Assert.assertNull(new VeraPdfValidator().validate(outputFile)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) - Assert.assertNull(new CompareTool().compareByContent(outputFile, cmpFile, destinationFolder, "diff_")); + Assertions.assertNull(new VeraPdfValidator().validate(inputFile)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNull(new VeraPdfValidator().validate(outputFile)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNull(new CompareTool().compareByContent(outputFile, cmpFile, destinationFolder, "diff_")); } private static void createInputPdfADocument(String docName) throws IOException { PdfWriter writer = new PdfWriter(docName); - PdfADocument pdfDoc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1A, + PdfADocument pdfDoc = new PdfADocument(writer, PdfAConformance.PDF_A_1A, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"))); pdfDoc.setTagged(); diff --git a/pdfa/src/test/java/com/itextpdf/pdfa/PdfABarcodeTest.java b/pdfa/src/test/java/com/itextpdf/pdfa/PdfABarcodeTest.java index 82032937ea..9de9103369 100644 --- a/pdfa/src/test/java/com/itextpdf/pdfa/PdfABarcodeTest.java +++ b/pdfa/src/test/java/com/itextpdf/pdfa/PdfABarcodeTest.java @@ -33,7 +33,7 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.font.PdfFont; import com.itextpdf.kernel.font.PdfFontFactory; import com.itextpdf.kernel.font.PdfFontFactory.EmbeddingStrategy; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfAConformance; import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfOutputIntent; import com.itextpdf.kernel.pdf.PdfWriter; @@ -42,24 +42,22 @@ This file is part of the iText (R) project. import com.itextpdf.layout.Document; import com.itextpdf.layout.element.Image; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfABarcodeTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/pdfa/"; public static final String cmpFolder = sourceFolder + "cmp/PdfABarcodeTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/pdfa/PdfABarcodeTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } @@ -223,7 +221,7 @@ private void fillBarcode1D(Barcode1D barcode1D, String code) { private Document createPdfATaggedDocument(String outPdf) throws IOException { PdfWriter writer = new PdfWriter(outPdf); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfDocument pdfDocument = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfDocument pdfDocument = new PdfADocument(writer, PdfAConformance.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); Document doc = new Document(pdfDocument); pdfDocument.setTagged(); return doc; diff --git a/pdfa/src/test/java/com/itextpdf/pdfa/PdfACheckfieldTest.java b/pdfa/src/test/java/com/itextpdf/pdfa/PdfACheckfieldTest.java index 6c98a56562..591e5dea97 100644 --- a/pdfa/src/test/java/com/itextpdf/pdfa/PdfACheckfieldTest.java +++ b/pdfa/src/test/java/com/itextpdf/pdfa/PdfACheckfieldTest.java @@ -30,30 +30,29 @@ This file is part of the iText (R) project. import com.itextpdf.forms.fields.properties.CheckBoxType; import com.itextpdf.kernel.colors.ColorConstants; import com.itextpdf.kernel.geom.Rectangle; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfAConformance; +import com.itextpdf.kernel.pdf.PdfConformance; import com.itextpdf.kernel.pdf.PdfOutputIntent; import com.itextpdf.kernel.pdf.PdfString; import com.itextpdf.kernel.pdf.PdfWriter; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfACheckfieldTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/pdfa/"; public static final String cmpFolder = "./src/test/resources/com/itextpdf/pdfa/cmp/PdfACheckfieldTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/pdfa/PdfACheckfieldTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } @@ -67,20 +66,20 @@ public void pdfA1aCheckFieldOffAppearanceTest() throws IOException, InterruptedE PdfWriter writer = new PdfWriter(outPath); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1A, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_1A, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.setTagged(); doc.getCatalog().setLang(new PdfString("en-US")); doc.addNewPage(); PdfAcroForm form = PdfFormCreator.getAcroForm(doc, true); PdfFormField chk = new CheckBoxFormFieldBuilder(doc, "name").setWidgetRectangle(new Rectangle(100, 500, 50, 50)) - .setCheckType(CheckBoxType.CHECK).setGenericConformanceLevel(PdfAConformanceLevel.PDF_A_1A) + .setCheckType(CheckBoxType.CHECK).setConformance(PdfConformance.PDF_A_1A) .createCheckBox().setValue("Off"); chk.getFirstFormAnnotation().setBorderColor(ColorConstants.BLACK); chk.getFirstFormAnnotation().setBorderWidth(1); form.addField(chk); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outPath, cmpPath, destinationFolder, diff)); + Assertions.assertNull(new CompareTool().compareByContent(outPath, cmpPath, destinationFolder, diff)); } @Test @@ -92,20 +91,20 @@ public void pdfA1aCheckFieldOnAppearanceTest() throws IOException, InterruptedEx PdfWriter writer = new PdfWriter(outPath); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1A, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_1A, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.setTagged(); doc.getCatalog().setLang(new PdfString("en-US")); doc.addNewPage(); PdfAcroForm form = PdfFormCreator.getAcroForm(doc, true); PdfFormField chk = new CheckBoxFormFieldBuilder(doc, "name").setWidgetRectangle(new Rectangle(100, 500, 50, 50)) - .setCheckType(CheckBoxType.CHECK).setGenericConformanceLevel(PdfAConformanceLevel.PDF_A_1A) + .setCheckType(CheckBoxType.CHECK).setConformance(PdfConformance.PDF_A_1A) .createCheckBox().setValue("On"); chk.getFirstFormAnnotation().setBorderColor(ColorConstants.BLACK); chk.getFirstFormAnnotation().setBorderWidth(1); form.addField(chk); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outPath, cmpPath, destinationFolder, diff)); + Assertions.assertNull(new CompareTool().compareByContent(outPath, cmpPath, destinationFolder, diff)); } @Test @@ -117,18 +116,18 @@ public void pdfA1bCheckFieldOffAppearanceTest() throws IOException, InterruptedE PdfWriter writer = new PdfWriter(outPath); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.addNewPage(); PdfAcroForm form = PdfFormCreator.getAcroForm(doc, true); PdfFormField chk = new CheckBoxFormFieldBuilder(doc, "name").setWidgetRectangle(new Rectangle(100, 500, 50, 50)) - .setCheckType(CheckBoxType.CHECK).setGenericConformanceLevel(PdfAConformanceLevel.PDF_A_1B) + .setCheckType(CheckBoxType.CHECK).setConformance(PdfConformance.PDF_A_1B) .createCheckBox().setValue("Off"); chk.getFirstFormAnnotation().setBorderColor(ColorConstants.BLACK); chk.getFirstFormAnnotation().setBorderWidth(1); form.addField(chk); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outPath, cmpPath, destinationFolder, diff)); + Assertions.assertNull(new CompareTool().compareByContent(outPath, cmpPath, destinationFolder, diff)); } @Test @@ -140,18 +139,18 @@ public void pdfA1bCheckFieldOnAppearanceTest() throws IOException, InterruptedEx PdfWriter writer = new PdfWriter(outPath); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.addNewPage(); PdfAcroForm form = PdfFormCreator.getAcroForm(doc, true); PdfFormField chk = new CheckBoxFormFieldBuilder(doc, "name").setWidgetRectangle(new Rectangle(100, 500, 50, 50)) - .setCheckType(CheckBoxType.CHECK).setGenericConformanceLevel(PdfAConformanceLevel.PDF_A_1B) + .setCheckType(CheckBoxType.CHECK).setConformance(PdfConformance.PDF_A_1B) .createCheckBox().setValue("On"); chk.getFirstFormAnnotation().setBorderColor(ColorConstants.BLACK); chk.getFirstFormAnnotation().setBorderWidth(1); form.addField(chk); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outPath, cmpPath, destinationFolder, diff)); + Assertions.assertNull(new CompareTool().compareByContent(outPath, cmpPath, destinationFolder, diff)); } @Test @@ -163,20 +162,20 @@ public void pdfA2aCheckFieldOffAppearanceTest() throws IOException, InterruptedE PdfWriter writer = new PdfWriter(outPath); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2A, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2A, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.setTagged(); doc.getCatalog().setLang(new PdfString("en-US")); doc.addNewPage(); PdfAcroForm form = PdfFormCreator.getAcroForm(doc, true); PdfFormField chk = new CheckBoxFormFieldBuilder(doc, "name").setWidgetRectangle(new Rectangle(100, 500, 50, 50)) - .setCheckType(CheckBoxType.CHECK).setGenericConformanceLevel(PdfAConformanceLevel.PDF_A_2A) + .setCheckType(CheckBoxType.CHECK).setConformance(PdfConformance.PDF_A_2A) .createCheckBox().setValue("Off"); chk.getFirstFormAnnotation().setBorderColor(ColorConstants.BLACK); chk.getFirstFormAnnotation().setBorderWidth(1); form.addField(chk); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outPath, cmpPath, destinationFolder, diff)); + Assertions.assertNull(new CompareTool().compareByContent(outPath, cmpPath, destinationFolder, diff)); } @Test @@ -188,20 +187,20 @@ public void pdfA2aCheckFieldOnAppearanceTest() throws IOException, InterruptedEx PdfWriter writer = new PdfWriter(outPath); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2A, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2A, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.setTagged(); doc.getCatalog().setLang(new PdfString("en-US")); doc.addNewPage(); PdfAcroForm form = PdfFormCreator.getAcroForm(doc, true); PdfFormField chk = new CheckBoxFormFieldBuilder(doc, "name").setWidgetRectangle(new Rectangle(100, 500, 50, 50)) - .setCheckType(CheckBoxType.CHECK).setGenericConformanceLevel(PdfAConformanceLevel.PDF_A_2A) + .setCheckType(CheckBoxType.CHECK).setConformance(PdfConformance.PDF_A_2A) .createCheckBox().setValue("On"); chk.getFirstFormAnnotation().setBorderColor(ColorConstants.BLACK); chk.getFirstFormAnnotation().setBorderWidth(1); form.addField(chk); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outPath, cmpPath, destinationFolder, diff)); + Assertions.assertNull(new CompareTool().compareByContent(outPath, cmpPath, destinationFolder, diff)); } @Test @@ -213,18 +212,18 @@ public void pdfA2bCheckFieldOffAppearanceTest() throws IOException, InterruptedE PdfWriter writer = new PdfWriter(outPath); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.addNewPage(); PdfAcroForm form = PdfFormCreator.getAcroForm(doc, true); PdfFormField chk = new CheckBoxFormFieldBuilder(doc, "name").setWidgetRectangle(new Rectangle(100, 500, 50, 50)) - .setCheckType(CheckBoxType.CHECK).setGenericConformanceLevel(PdfAConformanceLevel.PDF_A_2B) + .setCheckType(CheckBoxType.CHECK).setConformance(PdfConformance.PDF_A_2B) .createCheckBox().setValue("Off"); chk.getFirstFormAnnotation().setBorderColor(ColorConstants.BLACK); chk.getFirstFormAnnotation().setBorderWidth(1); form.addField(chk); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outPath, cmpPath, destinationFolder, diff)); + Assertions.assertNull(new CompareTool().compareByContent(outPath, cmpPath, destinationFolder, diff)); } @Test @@ -236,18 +235,18 @@ public void pdfA2bCheckFieldOnAppearanceTest() throws IOException, InterruptedEx PdfWriter writer = new PdfWriter(outPath); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.addNewPage(); PdfAcroForm form = PdfFormCreator.getAcroForm(doc, true); PdfFormField chk = new CheckBoxFormFieldBuilder(doc, "name").setWidgetRectangle(new Rectangle(100, 500, 50, 50)) - .setCheckType(CheckBoxType.CHECK).setGenericConformanceLevel(PdfAConformanceLevel.PDF_A_2B) + .setCheckType(CheckBoxType.CHECK).setConformance(PdfConformance.PDF_A_2B) .createCheckBox().setValue("On"); chk.getFirstFormAnnotation().setBorderColor(ColorConstants.BLACK); chk.getFirstFormAnnotation().setBorderWidth(1); form.addField(chk); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outPath, cmpPath, destinationFolder, diff)); + Assertions.assertNull(new CompareTool().compareByContent(outPath, cmpPath, destinationFolder, diff)); } @Test @@ -259,18 +258,18 @@ public void pdfA2uCheckFieldOffAppearanceTest() throws IOException, InterruptedE PdfWriter writer = new PdfWriter(outPath); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2U, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2U, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.addNewPage(); PdfAcroForm form = PdfFormCreator.getAcroForm(doc, true); PdfFormField chk = new CheckBoxFormFieldBuilder(doc, "name").setWidgetRectangle(new Rectangle(100, 500, 50, 50)) - .setCheckType(CheckBoxType.CHECK).setGenericConformanceLevel(PdfAConformanceLevel.PDF_A_2U) + .setCheckType(CheckBoxType.CHECK).setConformance(PdfConformance.PDF_A_2U) .createCheckBox().setValue("Off"); chk.getFirstFormAnnotation().setBorderColor(ColorConstants.BLACK); chk.getFirstFormAnnotation().setBorderWidth(1); form.addField(chk); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outPath, cmpPath, destinationFolder, diff)); + Assertions.assertNull(new CompareTool().compareByContent(outPath, cmpPath, destinationFolder, diff)); } @Test @@ -282,18 +281,18 @@ public void pdfA2uCheckFieldOnAppearanceTest() throws IOException, InterruptedEx PdfWriter writer = new PdfWriter(outPath); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2U, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2U, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.addNewPage(); PdfAcroForm form = PdfFormCreator.getAcroForm(doc, true); PdfFormField chk = new CheckBoxFormFieldBuilder(doc, "name").setWidgetRectangle(new Rectangle(100, 500, 50, 50)) - .setCheckType(CheckBoxType.CHECK).setGenericConformanceLevel(PdfAConformanceLevel.PDF_A_2U) + .setCheckType(CheckBoxType.CHECK).setConformance(PdfConformance.PDF_A_2U) .createCheckBox().setValue("On"); chk.getFirstFormAnnotation().setBorderColor(ColorConstants.BLACK); chk.getFirstFormAnnotation().setBorderWidth(1); form.addField(chk); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outPath, cmpPath, destinationFolder, diff)); + Assertions.assertNull(new CompareTool().compareByContent(outPath, cmpPath, destinationFolder, diff)); } @Test @@ -305,20 +304,20 @@ public void pdfA3aCheckFieldOffAppearanceTest() throws IOException, InterruptedE PdfWriter writer = new PdfWriter(outPath); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_3A, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_3A, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.setTagged(); doc.getCatalog().setLang(new PdfString("en-US")); doc.addNewPage(); PdfAcroForm form = PdfFormCreator.getAcroForm(doc, true); PdfFormField chk = new CheckBoxFormFieldBuilder(doc, "name").setWidgetRectangle(new Rectangle(100, 500, 50, 50)) - .setCheckType(CheckBoxType.CHECK).setGenericConformanceLevel(PdfAConformanceLevel.PDF_A_3A) + .setCheckType(CheckBoxType.CHECK).setConformance(PdfConformance.PDF_A_3A) .createCheckBox().setValue("Off"); chk.getFirstFormAnnotation().setBorderColor(ColorConstants.BLACK); chk.getFirstFormAnnotation().setBorderWidth(1); form.addField(chk); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outPath, cmpPath, destinationFolder, diff)); + Assertions.assertNull(new CompareTool().compareByContent(outPath, cmpPath, destinationFolder, diff)); } @Test @@ -330,20 +329,20 @@ public void pdfA3aCheckFieldOnAppearanceTest() throws IOException, InterruptedEx PdfWriter writer = new PdfWriter(outPath); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_3A, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_3A, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.setTagged(); doc.getCatalog().setLang(new PdfString("en-US")); doc.addNewPage(); PdfAcroForm form = PdfFormCreator.getAcroForm(doc, true); PdfFormField chk = new CheckBoxFormFieldBuilder(doc, "name").setWidgetRectangle(new Rectangle(100, 500, 50, 50)) - .setCheckType(CheckBoxType.CHECK).setGenericConformanceLevel(PdfAConformanceLevel.PDF_A_3A) + .setCheckType(CheckBoxType.CHECK).setConformance(PdfConformance.PDF_A_3A) .createCheckBox().setValue("On"); chk.getFirstFormAnnotation().setBorderColor(ColorConstants.BLACK); chk.getFirstFormAnnotation().setBorderWidth(1); form.addField(chk); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outPath, cmpPath, destinationFolder, diff)); + Assertions.assertNull(new CompareTool().compareByContent(outPath, cmpPath, destinationFolder, diff)); } @Test @@ -355,18 +354,18 @@ public void pdfA3bCheckFieldOffAppearanceTest() throws IOException, InterruptedE PdfWriter writer = new PdfWriter(outPath); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_3B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_3B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.addNewPage(); PdfAcroForm form = PdfFormCreator.getAcroForm(doc, true); PdfFormField chk = new CheckBoxFormFieldBuilder(doc, "name").setWidgetRectangle(new Rectangle(100, 500, 50, 50)) - .setCheckType(CheckBoxType.CHECK).setGenericConformanceLevel(PdfAConformanceLevel.PDF_A_3B) + .setCheckType(CheckBoxType.CHECK).setConformance(PdfConformance.PDF_A_3B) .createCheckBox().setValue("Off"); chk.getFirstFormAnnotation().setBorderColor(ColorConstants.BLACK); chk.getFirstFormAnnotation().setBorderWidth(1); form.addField(chk); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outPath, cmpPath, destinationFolder, diff)); + Assertions.assertNull(new CompareTool().compareByContent(outPath, cmpPath, destinationFolder, diff)); } @Test @@ -378,18 +377,18 @@ public void pdfA3bCheckFieldOnAppearanceTest() throws IOException, InterruptedEx PdfWriter writer = new PdfWriter(outPath); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_3B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_3B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.addNewPage(); PdfAcroForm form = PdfFormCreator.getAcroForm(doc, true); PdfFormField chk = new CheckBoxFormFieldBuilder(doc, "name").setWidgetRectangle(new Rectangle(100, 500, 50, 50)) - .setCheckType(CheckBoxType.CHECK).setGenericConformanceLevel(PdfAConformanceLevel.PDF_A_3B) + .setCheckType(CheckBoxType.CHECK).setConformance(PdfConformance.PDF_A_3B) .createCheckBox().setValue("On"); chk.getFirstFormAnnotation().setBorderColor(ColorConstants.BLACK); chk.getFirstFormAnnotation().setBorderWidth(1); form.addField(chk); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outPath, cmpPath, destinationFolder, diff)); + Assertions.assertNull(new CompareTool().compareByContent(outPath, cmpPath, destinationFolder, diff)); } @Test @@ -401,18 +400,18 @@ public void pdfA3uCheckFieldOffAppearanceTest() throws IOException, InterruptedE PdfWriter writer = new PdfWriter(outPath); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_3U, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_3U, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.addNewPage(); PdfAcroForm form = PdfFormCreator.getAcroForm(doc, true); PdfFormField chk = new CheckBoxFormFieldBuilder(doc, "name").setWidgetRectangle(new Rectangle(100, 500, 50, 50)) - .setCheckType(CheckBoxType.CHECK).setGenericConformanceLevel(PdfAConformanceLevel.PDF_A_3U) + .setCheckType(CheckBoxType.CHECK).setConformance(PdfConformance.PDF_A_3U) .createCheckBox().setValue("Off"); chk.getFirstFormAnnotation().setBorderColor(ColorConstants.BLACK); chk.getFirstFormAnnotation().setBorderWidth(1); form.addField(chk); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outPath, cmpPath, destinationFolder, diff)); + Assertions.assertNull(new CompareTool().compareByContent(outPath, cmpPath, destinationFolder, diff)); } @Test @@ -424,17 +423,17 @@ public void pdfA3uCheckFieldOnAppearanceTest() throws IOException, InterruptedEx PdfWriter writer = new PdfWriter(outPath); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_3U, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_3U, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); doc.addNewPage(); PdfAcroForm form = PdfFormCreator.getAcroForm(doc, true); PdfFormField chk = new CheckBoxFormFieldBuilder(doc, "name").setWidgetRectangle(new Rectangle(100, 500, 50, 50)) - .setCheckType(CheckBoxType.CHECK).setGenericConformanceLevel(PdfAConformanceLevel.PDF_A_3U) + .setCheckType(CheckBoxType.CHECK).setConformance(PdfConformance.PDF_A_3U) .createCheckBox().setValue("On"); chk.getFirstFormAnnotation().setBorderColor(ColorConstants.BLACK); chk.getFirstFormAnnotation().setBorderWidth(1); form.addField(chk); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outPath, cmpPath, destinationFolder, diff)); + Assertions.assertNull(new CompareTool().compareByContent(outPath, cmpPath, destinationFolder, diff)); } } diff --git a/pdfa/src/test/java/com/itextpdf/pdfa/PdfADocumentTest.java b/pdfa/src/test/java/com/itextpdf/pdfa/PdfADocumentTest.java index 887a69db2c..a5834436b6 100644 --- a/pdfa/src/test/java/com/itextpdf/pdfa/PdfADocumentTest.java +++ b/pdfa/src/test/java/com/itextpdf/pdfa/PdfADocumentTest.java @@ -23,25 +23,31 @@ This file is part of the iText (R) project. package com.itextpdf.pdfa; import com.itextpdf.commons.utils.FileUtil; -import com.itextpdf.kernel.pdf.IsoKey; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfAConformance; +import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfOutputIntent; +import com.itextpdf.kernel.pdf.PdfReader; import com.itextpdf.kernel.pdf.PdfVersion; import com.itextpdf.kernel.pdf.PdfWriter; import com.itextpdf.kernel.pdf.WriterProperties; +import com.itextpdf.kernel.validation.context.SignTypeValidationContext; import com.itextpdf.pdfa.exceptions.PdfAConformanceException; import com.itextpdf.pdfa.exceptions.PdfaExceptionMessageConstant; +import com.itextpdf.pdfa.logs.PdfALogMessageConstant; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; +import com.itextpdf.test.LogLevelConstants; +import com.itextpdf.test.annotations.LogMessage; +import com.itextpdf.test.annotations.LogMessages; +import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfADocumentTest extends ExtendedITextTest { public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/pdfa/"; @@ -49,17 +55,44 @@ public class PdfADocumentTest extends ExtendedITextTest { public void checkCadesSignatureTypeIsoConformance() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream(), new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); - PdfADocument document = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); - document.checkIsoConformance(true, IsoKey.SIGNATURE_TYPE, null, null); + PdfADocument document = new PdfADocument(writer, PdfAConformance.PDF_A_4, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + document.checkIsoConformance(new SignTypeValidationContext(true)); } @Test public void checkCMSSignatureTypeIsoConformance() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream(), new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); - PdfADocument document = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> document.checkIsoConformance(false, IsoKey.SIGNATURE_TYPE, null, null)); - Assert.assertEquals(PdfaExceptionMessageConstant.SIGNATURE_SHALL_CONFORM_TO_ONE_OF_THE_PADES_PROFILE, e.getMessage()); + PdfADocument document = new PdfADocument(writer, PdfAConformance.PDF_A_4, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + Exception e = Assertions.assertThrows(PdfAConformanceException.class, + () -> document.checkIsoConformance(new SignTypeValidationContext(false))); + Assertions.assertEquals(PdfaExceptionMessageConstant.SIGNATURE_SHALL_CONFORM_TO_ONE_OF_THE_PADES_PROFILE, e.getMessage()); + } + + @Test + public void openingNonADocumentWithPdfADocumentTest() { + final ByteArrayOutputStream os = new ByteArrayOutputStream(); + try (PdfDocument pdfDocument = new PdfDocument(new PdfWriter(os))) { + pdfDocument.addNewPage(); + } + + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> new PdfADocument( + new PdfReader(new ByteArrayInputStream(os.toByteArray())), + new PdfWriter(new ByteArrayOutputStream()))); + Assertions.assertEquals(PdfaExceptionMessageConstant. + DOCUMENT_TO_READ_FROM_SHALL_BE_A_PDFA_CONFORMANT_FILE_WITH_VALID_XMP_METADATA, e.getMessage()); + } + + @Test + @LogMessages(messages = { + @LogMessage(messageTemplate = PdfALogMessageConstant.WRITER_PROPERTIES_PDF_VERSION_WAS_OVERRIDDEN, logLevel = LogLevelConstants.WARN) + }) + public void settingWrongPdfVersionTest() throws IOException { + InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); + final PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); + PdfADocument doc = new PdfADocument(new PdfWriter(new ByteArrayOutputStream(), + new WriterProperties().setPdfVersion(PdfVersion.PDF_1_4)), PdfAConformance.PDF_A_4, outputIntent); + doc.close(); } } diff --git a/pdfa/src/test/java/com/itextpdf/pdfa/PdfAFlushingTest.java b/pdfa/src/test/java/com/itextpdf/pdfa/PdfAFlushingTest.java index d5196dc80b..e28f9356e4 100644 --- a/pdfa/src/test/java/com/itextpdf/pdfa/PdfAFlushingTest.java +++ b/pdfa/src/test/java/com/itextpdf/pdfa/PdfAFlushingTest.java @@ -27,7 +27,7 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.font.PdfFont; import com.itextpdf.kernel.font.PdfFontFactory; import com.itextpdf.kernel.geom.Rectangle; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfAConformance; import com.itextpdf.kernel.pdf.PdfArray; import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.kernel.pdf.PdfDocument; @@ -50,25 +50,23 @@ This file is part of the iText (R) project. import com.itextpdf.test.LogLevelConstants; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import com.itextpdf.test.pdfa.VeraPdfValidator; // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) -import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; - -@Category(IntegrationTest.class) +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; + +@Tag("IntegrationTest") public class PdfAFlushingTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/pdfa/"; public static final String destinationFolder = "./target/test/com/itextpdf/pdfa/PdfAFlushingTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } @@ -81,7 +79,7 @@ public void flushingTest01() throws IOException, InterruptedException { PdfWriter writer = new PdfWriter(outPdf); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); PdfCanvas canvas = new PdfCanvas(doc.addNewPage()); PdfImageXObject imageXObject = new PdfImageXObject(ImageDataFactory.create(sourceFolder + "Desert.jpg")); imageXObject.makeIndirect(doc); @@ -105,7 +103,7 @@ public void flushingTest02() throws IOException, InterruptedException { PdfWriter writer = new PdfWriter(outPdf); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); PdfCanvas canvas = new PdfCanvas(doc.addNewPage()); PdfImageXObject imageXObject = new PdfImageXObject(ImageDataFactory.create(sourceFolder + "Desert.jpg")); imageXObject.makeIndirect(doc); @@ -129,7 +127,7 @@ public void flushingTest03() throws IOException, InterruptedException { PdfWriter writer = new PdfWriter(outPdf); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_3B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_3B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); PdfCanvas canvas = new PdfCanvas(doc.addNewPage()); PdfImageXObject imageXObject = new PdfImageXObject(ImageDataFactory.create(sourceFolder + "Desert.jpg")); canvas.addXObjectFittedIntoRectangle(imageXObject, new Rectangle(30, 300, 300, 300)); @@ -155,7 +153,7 @@ public void tryToFlushFontTest() throws IOException, InterruptedException { PdfWriter writer = new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument pdfDoc = (PdfADocument) new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)).setTagged(); + PdfADocument pdfDoc = (PdfADocument) new PdfADocument(writer, PdfAConformance.PDF_A_4, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)).setTagged(); PdfFont font = PdfFontFactory.createFont(sourceFolder + "FreeSans.ttf", "WinAnsi", PdfFontFactory.EmbeddingStrategy.FORCE_EMBEDDED); font.makeIndirect(pdfDoc); @@ -168,11 +166,11 @@ public void tryToFlushFontTest() throws IOException, InterruptedException { font.flush(); document.add(list); - Assert.assertEquals(PdfVersion.PDF_2_0, pdfDoc.getTagStructureContext().getTagStructureTargetVersion()); + assertEquals(PdfVersion.PDF_2_0, pdfDoc.getTagStructureContext().getTagStructureTargetVersion()); document.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff")); - Assert.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, destinationFolder, "diff")); + Assertions.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) } @Test @@ -184,7 +182,7 @@ public void addUnusedStreamObjectsTest() throws IOException, InterruptedExceptio PdfWriter writer = new PdfWriter(outPdf); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); - PdfADocument pdfDocument = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfADocument pdfDocument = new PdfADocument(writer, PdfAConformance.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); pdfDocument.addNewPage(); PdfDictionary unusedDictionary = new PdfDictionary(); diff --git a/pdfa/src/test/java/com/itextpdf/pdfa/PdfAFontTest.java b/pdfa/src/test/java/com/itextpdf/pdfa/PdfAFontTest.java index c9734fc32c..2188b07d03 100644 --- a/pdfa/src/test/java/com/itextpdf/pdfa/PdfAFontTest.java +++ b/pdfa/src/test/java/com/itextpdf/pdfa/PdfAFontTest.java @@ -36,7 +36,7 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.font.PdfType3Font; import com.itextpdf.kernel.font.Type3Glyph; import com.itextpdf.kernel.pdf.CompressionConstants; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfAConformance; import com.itextpdf.kernel.pdf.PdfArray; import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.kernel.pdf.PdfDocument; @@ -55,25 +55,24 @@ This file is part of the iText (R) project. import com.itextpdf.pdfa.exceptions.PdfAConformanceException; import com.itextpdf.pdfa.exceptions.PdfaExceptionMessageConstant; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import com.itextpdf.test.pdfa.VeraPdfValidator; // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.fail; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfAFontTest extends ExtendedITextTest { static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/pdfa/"; static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/pdfa/PdfAFontTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(DESTINATION_FOLDER); } @@ -84,7 +83,7 @@ public void fontCheckPdfA1_01() throws IOException, InterruptedException { String cmpPdf = SOURCE_FOLDER + "cmp/PdfAFontTest/cmp_pdfA1b_fontCheckPdfA1_01.pdf"; PdfWriter writer = new PdfWriter(outPdf); InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); - PdfDocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfDocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); PdfPage page = doc.addNewPage(); PdfFont font = PdfFontFactory.createFont(SOURCE_FOLDER + "FreeSans.ttf", "WinAnsi", EmbeddingStrategy.FORCE_EMBEDDED); @@ -105,7 +104,7 @@ public void fontCheckPdfA1_01() throws IOException, InterruptedException { public void fontCheckPdfA1_02() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); - PdfDocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfDocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); PdfPage page = doc.addNewPage(); PdfFont font = PdfFontFactory.createFont(SOURCE_FOLDER + "FreeSans.ttf", PdfEncodings.WINANSI, EmbeddingStrategy.FORCE_NOT_EMBEDDED); @@ -119,8 +118,8 @@ public void fontCheckPdfA1_02() throws IOException { .endText() .restoreState(); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.ALL_THE_FONTS_MUST_BE_EMBEDDED_THIS_ONE_IS_NOT_0, "FreeSans"), + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.ALL_THE_FONTS_MUST_BE_EMBEDDED_THIS_ONE_IS_NOT_0, "FreeSans"), e.getMessage()); } @@ -130,7 +129,7 @@ public void fontCheckPdfA1_03() throws IOException, InterruptedException { String cmpPdf = SOURCE_FOLDER + "cmp/PdfAFontTest/cmp_pdfA1b_fontCheckPdfA1_03.pdf"; PdfWriter writer = new PdfWriter(outPdf); InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); - PdfDocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfDocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); PdfPage page = doc.addNewPage(); // Identity-H must be embedded PdfFont font = PdfFontFactory.createFont(SOURCE_FOLDER + "FreeSans.ttf", @@ -152,7 +151,7 @@ public void fontCheckPdfA1_03() throws IOException, InterruptedException { public void fontCheckPdfA1_04() throws IOException { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); - PdfDocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfDocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); PdfPage page = doc.addNewPage(); PdfFont font = PdfFontFactory.createFont("Helvetica", "WinAnsi", EmbeddingStrategy.PREFER_EMBEDDED); @@ -166,8 +165,8 @@ public void fontCheckPdfA1_04() throws IOException { .endText() .restoreState(); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.ALL_THE_FONTS_MUST_BE_EMBEDDED_THIS_ONE_IS_NOT_0, "Helvetica"), + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.ALL_THE_FONTS_MUST_BE_EMBEDDED_THIS_ONE_IS_NOT_0, "Helvetica"), e.getMessage()); } @@ -177,7 +176,7 @@ public void fontCheckPdfA1_05() throws IOException, InterruptedException { String cmpPdf = SOURCE_FOLDER + "cmp/PdfAFontTest/cmp_pdfA1b_fontCheckPdfA1_05.pdf"; PdfWriter writer = new PdfWriter(outPdf); InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); - PdfDocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfDocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); PdfPage page = doc.addNewPage(); // Identity-H must be embedded PdfFont font = PdfFontFactory.createFont(SOURCE_FOLDER + "NotoSansCJKtc-Light.otf", "Identity-H"); @@ -201,7 +200,7 @@ public void fontCheckPdfA2_01() throws IOException, InterruptedException { String cmpPdf = SOURCE_FOLDER + "cmp/PdfAFontTest/cmp_pdfA2b_fontCheckPdfA2_01.pdf"; PdfWriter writer = new PdfWriter(outPdf); InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); - PdfDocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfDocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); PdfPage page = doc.addNewPage(); // Identity-H must be embedded PdfFont font = PdfFontFactory.createFont(SOURCE_FOLDER + "FreeSans.ttf", @@ -226,7 +225,7 @@ public void fontCheckPdfA3_01() throws IOException, InterruptedException { String cmpPdf = SOURCE_FOLDER + "cmp/PdfAFontTest/cmp_pdfA3b_fontCheckPdfA3_01.pdf"; PdfWriter writer = new PdfWriter(outPdf); InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); - PdfDocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_3B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfDocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_3B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); PdfPage page = doc.addNewPage(); // Identity-H must be embedded PdfFont font = PdfFontFactory.createFont(SOURCE_FOLDER + "FreeSans.ttf", @@ -277,39 +276,39 @@ public void symbolicTtfCharEncodingsPdfA1Test01() { // encoding must not be specified // Here we produced valid pdfa files in the past by silently removing not valid symbols // But right now we check for used glyphs which don't exist in the font and throw exception - Exception e = Assert.assertThrows(PdfAConformanceException.class, - () -> createDocumentWithFont("symbolicTtfCharEncodingsPdfA1Test01.pdf", "Symbols1.ttf", "", PdfAConformanceLevel.PDF_A_1B) + Exception e = Assertions.assertThrows(PdfAConformanceException.class, + () -> createDocumentWithFont("symbolicTtfCharEncodingsPdfA1Test01.pdf", "Symbols1.ttf", "", PdfAConformance.PDF_A_1B) ); - Assert.assertEquals(PdfaExceptionMessageConstant.EMBEDDED_FONTS_SHALL_DEFINE_ALL_REFERENCED_GLYPHS, + Assertions.assertEquals(PdfaExceptionMessageConstant.EMBEDDED_FONTS_SHALL_DEFINE_ALL_REFERENCED_GLYPHS, e.getMessage()); } @Test public void symbolicTtfCharEncodingsPdfA1Test02() { // if you specify encoding, symbolic font is treated as non-symbolic - Exception e = Assert.assertThrows(PdfAConformanceException.class, - () -> createDocumentWithFont("symbolicTtfCharEncodingsPdfA1Test02.pdf", "Symbols1.ttf", PdfEncodings.MACROMAN, PdfAConformanceLevel.PDF_A_1B) + Exception e = Assertions.assertThrows(PdfAConformanceException.class, + () -> createDocumentWithFont("symbolicTtfCharEncodingsPdfA1Test02.pdf", "Symbols1.ttf", PdfEncodings.MACROMAN, PdfAConformance.PDF_A_1B) ); - Assert.assertEquals(PdfaExceptionMessageConstant.EMBEDDED_FONTS_SHALL_DEFINE_ALL_REFERENCED_GLYPHS, + Assertions.assertEquals(PdfaExceptionMessageConstant.EMBEDDED_FONTS_SHALL_DEFINE_ALL_REFERENCED_GLYPHS, e.getMessage()); } @Test public void symbolicTtfCharEncodingsPdfA1Test03() { // if you specify encoding, symbolic font is treated as non-symbolic - Exception e = Assert.assertThrows(PdfAConformanceException.class, - () -> createDocumentWithFont("symbolicTtfCharEncodingsPdfA1Test03.pdf", "Symbols1.ttf", "ISO-8859-1", PdfAConformanceLevel.PDF_A_1B) + Exception e = Assertions.assertThrows(PdfAConformanceException.class, + () -> createDocumentWithFont("symbolicTtfCharEncodingsPdfA1Test03.pdf", "Symbols1.ttf", "ISO-8859-1", PdfAConformance.PDF_A_1B) ); - Assert.assertEquals(PdfaExceptionMessageConstant.EMBEDDED_FONTS_SHALL_DEFINE_ALL_REFERENCED_GLYPHS, + Assertions.assertEquals(PdfaExceptionMessageConstant.EMBEDDED_FONTS_SHALL_DEFINE_ALL_REFERENCED_GLYPHS, e.getMessage()); } @Test public void symbolicTtfCharEncodingsPdfA1Test04() { - Exception e = Assert.assertThrows(PdfAConformanceException.class, - () -> createDocumentWithFont("symbolicTtfCharEncodingsPdfA1Test04.pdf", "Symbols1.ttf", PdfEncodings.WINANSI, PdfAConformanceLevel.PDF_A_1B) + Exception e = Assertions.assertThrows(PdfAConformanceException.class, + () -> createDocumentWithFont("symbolicTtfCharEncodingsPdfA1Test04.pdf", "Symbols1.ttf", PdfEncodings.WINANSI, PdfAConformance.PDF_A_1B) ); - Assert.assertEquals(PdfaExceptionMessageConstant.EMBEDDED_FONTS_SHALL_DEFINE_ALL_REFERENCED_GLYPHS, + Assertions.assertEquals(PdfaExceptionMessageConstant.EMBEDDED_FONTS_SHALL_DEFINE_ALL_REFERENCED_GLYPHS, e.getMessage()); } @@ -318,27 +317,27 @@ public void symbolicTtfCharEncodingsPdfA1Test05() { // Identity-H behaviour should be the same as the default one, starting from 7.2 // Here we produced valid pdfa files in the past by silently removing not valid symbols // But right now we check for used glyphs which don't exist in the font and throw exception - Exception e = Assert.assertThrows(PdfAConformanceException.class, - () -> createDocumentWithFont("symbolicTtfCharEncodingsPdfA1Test05.pdf", "Symbols1.ttf", PdfEncodings.IDENTITY_H, PdfAConformanceLevel.PDF_A_1B) + Exception e = Assertions.assertThrows(PdfAConformanceException.class, + () -> createDocumentWithFont("symbolicTtfCharEncodingsPdfA1Test05.pdf", "Symbols1.ttf", PdfEncodings.IDENTITY_H, PdfAConformance.PDF_A_1B) ); - Assert.assertEquals(PdfaExceptionMessageConstant.EMBEDDED_FONTS_SHALL_DEFINE_ALL_REFERENCED_GLYPHS, + Assertions.assertEquals(PdfaExceptionMessageConstant.EMBEDDED_FONTS_SHALL_DEFINE_ALL_REFERENCED_GLYPHS, e.getMessage()); } @Test public void nonSymbolicTtfCharEncodingsPdfA1Test01() throws IOException, InterruptedException { // encoding must be either winansi or macroman, by default winansi is used - createDocumentWithFont("nonSymbolicTtfCharEncodingsPdfA1Test01.pdf", "FreeSans.ttf", PdfEncodings.WINANSI, PdfAConformanceLevel.PDF_A_1B); + createDocumentWithFont("nonSymbolicTtfCharEncodingsPdfA1Test01.pdf", "FreeSans.ttf", PdfEncodings.WINANSI, PdfAConformance.PDF_A_1B); } @Test public void nonSymbolicTtfCharEncodingsPdfA1Test02() { // encoding must be either winansi or macroman, by default winansi is used - Exception e = Assert.assertThrows(PdfAConformanceException.class, - () -> createDocumentWithFont("nonSymbolicTtfCharEncodingsPdfA1Test02.pdf", "FreeSans.ttf", "ISO-8859-1", PdfAConformanceLevel.PDF_A_2B) + Exception e = Assertions.assertThrows(PdfAConformanceException.class, + () -> createDocumentWithFont("nonSymbolicTtfCharEncodingsPdfA1Test02.pdf", "FreeSans.ttf", "ISO-8859-1", PdfAConformance.PDF_A_2B) ); - Assert.assertEquals(PdfaExceptionMessageConstant.ALL_NON_SYMBOLIC_TRUE_TYPE_FONT_SHALL_SPECIFY_MAC_ROMAN_ENCODING_OR_WIN_ANSI_ENCODING, + Assertions.assertEquals(PdfaExceptionMessageConstant.ALL_NON_SYMBOLIC_TRUE_TYPE_FONT_SHALL_SPECIFY_MAC_ROMAN_ENCODING_OR_WIN_ANSI_ENCODING, e.getMessage()); } @@ -348,7 +347,7 @@ public void notdefInTrueTypeFontTest() throws IOException { PdfWriter writer = new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); - PdfDocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, + PdfDocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); PdfFont font = PdfFontFactory.createFont(SOURCE_FOLDER + "FreeSans.ttf", "# simple 32 0020 00C5 1987", EmbeddingStrategy.PREFER_EMBEDDED); @@ -359,10 +358,10 @@ public void notdefInTrueTypeFontTest() throws IOException { moveText(36, 786). setFontAndSize(font, 36); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> canvas.showText("\u00C5 \u1987") ); - Assert.assertEquals(PdfaExceptionMessageConstant.EMBEDDED_FONTS_SHALL_DEFINE_ALL_REFERENCED_GLYPHS, + Assertions.assertEquals(PdfaExceptionMessageConstant.EMBEDDED_FONTS_SHALL_DEFINE_ALL_REFERENCED_GLYPHS, e.getMessage()); } @@ -372,7 +371,7 @@ public void notdefFontTest2() throws IOException { PdfWriter writer = new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); - PdfDocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, + PdfDocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); PdfFont font = PdfFontFactory.createFont(SOURCE_FOLDER + "NotoSans-Regular.ttf", "", EmbeddingStrategy.PREFER_EMBEDDED); @@ -383,10 +382,10 @@ public void notdefFontTest2() throws IOException { moveText(36, 786). setFontAndSize(font, 36); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> canvas.showText("\u898B\u7A4D\u3082\u308A") ); - Assert.assertEquals(PdfaExceptionMessageConstant.EMBEDDED_FONTS_SHALL_DEFINE_ALL_REFERENCED_GLYPHS, + Assertions.assertEquals(PdfaExceptionMessageConstant.EMBEDDED_FONTS_SHALL_DEFINE_ALL_REFERENCED_GLYPHS, e.getMessage()); } @@ -397,7 +396,7 @@ public void glyphLineWithUndefinedGlyphsTest() throws Exception { InputStream icm = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); Document document = new Document(new PdfADocument( new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)), - PdfAConformanceLevel.PDF_A_4, + PdfAConformance.PDF_A_4, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB ICC preference", icm))); PdfFont font = PdfFontFactory.createFont(SOURCE_FOLDER + "NotoSans-Regular.ttf", @@ -405,8 +404,8 @@ public void glyphLineWithUndefinedGlyphsTest() throws Exception { Paragraph p = new Paragraph("\u898B\u7A4D\u3082\u308A"); p.setFont(font); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> document.add(p)); - Assert.assertEquals(PdfaExceptionMessageConstant.EMBEDDED_FONTS_SHALL_DEFINE_ALL_REFERENCED_GLYPHS, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> document.add(p)); + Assertions.assertEquals(PdfaExceptionMessageConstant.EMBEDDED_FONTS_SHALL_DEFINE_ALL_REFERENCED_GLYPHS, e.getMessage()); } @@ -416,7 +415,7 @@ public void pdfArrayWithUndefinedGlyphsTest() throws Exception { PdfWriter writer = new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); - PdfDocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, + PdfDocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); PdfFont font = PdfFontFactory.createFont(SOURCE_FOLDER + "NotoSans-Regular.ttf", "", EmbeddingStrategy.PREFER_EMBEDDED); @@ -431,10 +430,10 @@ public void pdfArrayWithUndefinedGlyphsTest() throws Exception { pdfArray.add(new PdfString("ABC")); pdfArray.add(new PdfNumber(1)); pdfArray.add(new PdfString("\u898B\u7A4D\u3082\u308A")); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> canvas.showText(pdfArray) ); - Assert.assertEquals(PdfaExceptionMessageConstant.EMBEDDED_FONTS_SHALL_DEFINE_ALL_REFERENCED_GLYPHS, + Assertions.assertEquals(PdfaExceptionMessageConstant.EMBEDDED_FONTS_SHALL_DEFINE_ALL_REFERENCED_GLYPHS, e.getMessage()); } @@ -446,13 +445,13 @@ public void createDocumentWithType1FontAfmTest() throws IOException, Interrupted PdfWriter writer = new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); writer.setCompressionLevel(CompressionConstants.NO_COMPRESSION); InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); - PdfDocument pdfDoc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, + PdfDocument pdfDoc = new PdfADocument(writer, PdfAConformance.PDF_A_4, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); PdfFont pdfType1Font = PdfFontFactory.createFont(FontProgramFactory.createType1Font( SOURCE_FOLDER + "cmr10.afm", SOURCE_FOLDER + "cmr10.pfb"), FontEncoding.FONT_SPECIFIC, EmbeddingStrategy.PREFER_EMBEDDED); - Assert.assertTrue("PdfType1Font expected", pdfType1Font instanceof PdfType1Font); + Assertions.assertTrue(pdfType1Font instanceof PdfType1Font, "PdfType1Font expected"); new PdfCanvas(pdfDoc.addNewPage()) .saveState() @@ -468,7 +467,7 @@ public void createDocumentWithType1FontAfmTest() throws IOException, Interrupted byte[] pfb = StreamUtil.inputStreamToArray(FileUtil.getInputStreamForFile(SOURCE_FOLDER + "cmr10.pfb")); pdfType1Font = PdfFontFactory.createFont(FontProgramFactory.createType1Font(afm, pfb), FontEncoding.FONT_SPECIFIC, EmbeddingStrategy.PREFER_EMBEDDED); - Assert.assertTrue("PdfType1Font expected", pdfType1Font instanceof PdfType1Font); + Assertions.assertTrue(pdfType1Font instanceof PdfType1Font, "PdfType1Font expected"); new PdfCanvas(pdfDoc.addNewPage()) .saveState() @@ -493,7 +492,7 @@ public void checkPdfA4FreeSansForceEmbeddedTest() throws IOException, Interrupte writerProperties.setPdfVersion(PdfVersion.PDF_2_0); PdfWriter writer = new PdfWriter(outPdf, writerProperties); InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); - PdfDocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfDocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); PdfPage page = doc.addNewPage(); PdfFont font = PdfFontFactory.createFont(SOURCE_FOLDER + "FreeSans.ttf", "WinAnsi", EmbeddingStrategy.FORCE_EMBEDDED); @@ -516,7 +515,7 @@ public void checkPdfA4FreeSansForceNotEmbeddedTest() throws IOException { writerProperties.setPdfVersion(PdfVersion.PDF_2_0); PdfWriter writer = new PdfWriter(new ByteArrayOutputStream(), writerProperties); InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); - PdfDocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfDocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); PdfPage page = doc.addNewPage(); PdfFont font = PdfFontFactory.createFont(SOURCE_FOLDER + "FreeSans.ttf", PdfEncodings.WINANSI, EmbeddingStrategy.FORCE_NOT_EMBEDDED); @@ -530,8 +529,8 @@ public void checkPdfA4FreeSansForceNotEmbeddedTest() throws IOException { .endText() .restoreState(); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(MessageFormatUtil.format(PdfAConformanceException.ALL_THE_FONTS_MUST_BE_EMBEDDED_THIS_ONE_IS_NOT_0, "FreeSans"), + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.ALL_THE_FONTS_MUST_BE_EMBEDDED_THIS_ONE_IS_NOT_0, "FreeSans"), e.getMessage()); } @@ -543,7 +542,7 @@ public void checkPdfA4FreeSansPreferNotEmbeddedTest() throws IOException, Interr writerProperties.setPdfVersion(PdfVersion.PDF_2_0); PdfWriter writer = new PdfWriter(outPdf, writerProperties); InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); - PdfDocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfDocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); PdfPage page = doc.addNewPage(); // Identity-H must be embedded @@ -569,7 +568,7 @@ public void checkPdfA4HelveticaPreferEmbeddedTest() throws IOException { writerProperties.setPdfVersion(PdfVersion.PDF_2_0); PdfWriter writer = new PdfWriter(new ByteArrayOutputStream(), writerProperties); InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); - PdfDocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfDocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); PdfPage page = doc.addNewPage(); PdfFont font = PdfFontFactory.createFont("Helvetica", "WinAnsi", EmbeddingStrategy.PREFER_EMBEDDED); @@ -583,8 +582,8 @@ public void checkPdfA4HelveticaPreferEmbeddedTest() throws IOException { .endText() .restoreState(); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> doc.close()); - Assert.assertEquals(MessageFormatUtil.format(PdfAConformanceException.ALL_THE_FONTS_MUST_BE_EMBEDDED_THIS_ONE_IS_NOT_0, "Helvetica"), + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> doc.close()); + Assertions.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.ALL_THE_FONTS_MUST_BE_EMBEDDED_THIS_ONE_IS_NOT_0, "Helvetica"), e.getMessage()); } @@ -596,7 +595,7 @@ public void checkPdfA4NotoSansCJKtcLightTest() throws IOException, InterruptedEx writerProperties.setPdfVersion(PdfVersion.PDF_2_0); PdfWriter writer = new PdfWriter(outPdf, writerProperties); InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); - PdfDocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfDocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); PdfPage page = doc.addNewPage(); // Identity-H must be embedded PdfFont font = PdfFontFactory.createFont(SOURCE_FOLDER + "NotoSansCJKtc-Light.otf", "Identity-H"); @@ -624,7 +623,7 @@ public void checkPdfA4Puritan2Test() throws IOException, InterruptedException { writerProperties.setPdfVersion(PdfVersion.PDF_2_0); PdfWriter writer = new PdfWriter(outPdf, writerProperties); InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); - PdfDocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfDocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); PdfPage page = doc.addNewPage(); // Identity-H must be embedded PdfFont font = PdfFontFactory.createFont(SOURCE_FOLDER + "Puritan2.otf", "Identity-H"); @@ -651,7 +650,7 @@ public void checkPdfA4Type3Test() throws IOException, InterruptedException { writerProperties.setPdfVersion(PdfVersion.PDF_2_0); PdfWriter writer = new PdfWriter(outPdf, writerProperties); InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); - PdfDocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfDocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); // A A A A E E E ~ é String testString = "A A A A E E E ~ \u00E9"; @@ -718,7 +717,7 @@ public void checkPdfA4UmingTtcTest() throws IOException, InterruptedException { writerProperties.setPdfVersion(PdfVersion.PDF_2_0); PdfWriter writer = new PdfWriter(outPdf, writerProperties); InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); - PdfDocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfDocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); PdfPage page = doc.addNewPage(); PdfFont font = PdfFontFactory.createTtcFont(SOURCE_FOLDER + "uming.ttc", 0, "Identity-H", EmbeddingStrategy.FORCE_EMBEDDED, false); @@ -744,7 +743,7 @@ public void checkPdfA4WoffTest() throws IOException, InterruptedException { writerProperties.setPdfVersion(PdfVersion.PDF_2_0); PdfWriter writer = new PdfWriter(outPdf, writerProperties); InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); - PdfDocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfDocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); PdfPage page = doc.addNewPage(); PdfFont font = PdfFontFactory.createFont(SOURCE_FOLDER + "SourceSerif4-Black.woff", "Identity-H", EmbeddingStrategy.FORCE_EMBEDDED); @@ -770,7 +769,7 @@ public void checkPdfA4SurrogatePairTest() throws IOException, InterruptedExcepti writerProperties.setPdfVersion(PdfVersion.PDF_2_0); PdfWriter writer = new PdfWriter(outPdf, writerProperties); InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); - PdfDocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfDocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); PdfPage page = doc.addNewPage(); PdfFont font = PdfFontFactory.createFont(SOURCE_FOLDER + "NotoEmoji-Regular.ttf", "Identity-H", EmbeddingStrategy.FORCE_EMBEDDED); @@ -788,12 +787,12 @@ public void checkPdfA4SurrogatePairTest() throws IOException, InterruptedExcepti compareResult(outPdf, cmpPdf, null); } - private void createDocumentWithFont(String outFileName, String fontFileName, String encoding, PdfAConformanceLevel conformanceLevel) throws IOException, InterruptedException { + private void createDocumentWithFont(String outFileName, String fontFileName, String encoding, PdfAConformance conformance) throws IOException, InterruptedException { String outPdf = DESTINATION_FOLDER + outFileName; String cmpPdf = SOURCE_FOLDER + "cmp/PdfAFontTest/cmp_" + outFileName; PdfWriter writer = new PdfWriter(outPdf); InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); - PdfDocument doc = new PdfADocument(writer, conformanceLevel, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); + PdfDocument doc = new PdfADocument(writer, conformance, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); PdfPage page = doc.addNewPage(); PdfFont font = PdfFontFactory.createFont(SOURCE_FOLDER + fontFileName, @@ -814,7 +813,7 @@ private void createDocumentWithFont(String outFileName, String fontFileName, Str } private void compareResult(String outPdf, String cmpPdf, String expectedVeraPdfWarning) throws IOException, InterruptedException { - Assert.assertEquals(expectedVeraPdfWarning, new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertEquals(expectedVeraPdfWarning, new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) String result = new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_"); if (result != null) { fail(result); @@ -827,7 +826,7 @@ private void generatePdfA2WithCidFont(String fontFile, String outPdf) throws IOE InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); PdfDocument doc = new PdfADocument( writer, - PdfAConformanceLevel.PDF_A_2B, + PdfAConformance.PDF_A_2B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is) ) ) { diff --git a/pdfa/src/test/java/com/itextpdf/pdfa/PdfAFormFieldTest.java b/pdfa/src/test/java/com/itextpdf/pdfa/PdfAFormFieldTest.java index a965fbca1d..8336934e03 100644 --- a/pdfa/src/test/java/com/itextpdf/pdfa/PdfAFormFieldTest.java +++ b/pdfa/src/test/java/com/itextpdf/pdfa/PdfAFormFieldTest.java @@ -57,8 +57,9 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.font.PdfFontFactory.EmbeddingStrategy; import com.itextpdf.kernel.geom.PageSize; import com.itextpdf.kernel.geom.Rectangle; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfAConformance; import com.itextpdf.kernel.pdf.PdfArray; +import com.itextpdf.kernel.pdf.PdfConformance; import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfName; import com.itextpdf.kernel.pdf.PdfOutputIntent; @@ -83,7 +84,6 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import com.itextpdf.test.pdfa.VeraPdfValidator; // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) import java.io.IOException; @@ -93,18 +93,18 @@ This file is part of the iText (R) project. import java.util.Map.Entry; import java.util.function.Consumer; import java.util.function.Supplier; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfAFormFieldTest extends ExtendedITextTest { public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/pdfa/"; public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/pdfa/PdfAFormFieldTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(DESTINATION_FOLDER); } @@ -117,7 +117,7 @@ public void pdfAButtonFieldTest() throws Exception { String filename = DESTINATION_FOLDER + file; pdf = new PdfADocument( new PdfWriter(FileUtil.getFileOutputStream(filename)), - PdfAConformanceLevel.PDF_A_1B, + PdfAConformance.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB ICC preference", is)); PageSize pageSize = PageSize.LETTER; @@ -127,7 +127,7 @@ public void pdfAButtonFieldTest() throws Exception { SOURCE_FOLDER + "FreeSans.ttf", EmbeddingStrategy.PREFER_EMBEDDED); PdfButtonFormField group = new RadioFormFieldBuilder(pdf, "group") - .setGenericConformanceLevel(PdfAConformanceLevel.PDF_A_1B).createRadioGroup(); + .setConformance(PdfConformance.PDF_A_1B).createRadioGroup(); group.setValue(""); group.setReadOnly(true); @@ -163,7 +163,7 @@ public void pdfAButtonFieldTest() throws Exception { PdfFormCreator.getAcroForm(pdf, true).addField(group); pdf.close(); - Assert.assertNull( + Assertions.assertNull( new CompareTool().compareByContent(filename, SOURCE_FOLDER + "cmp/PdfAFormFieldTest/cmp_" + file, DESTINATION_FOLDER, "diff_")); } @@ -176,23 +176,23 @@ public void pdfA1DocWithPdfA1ButtonFieldTest() throws IOException, InterruptedEx InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); - PdfAConformanceLevel conformanceLevel = PdfAConformanceLevel.PDF_A_1B; + PdfConformance conformance = PdfConformance.PDF_A_1B; - PdfADocument pdfDoc = new PdfADocument(new PdfWriter(fileName), conformanceLevel, + PdfADocument pdfDoc = new PdfADocument(new PdfWriter(fileName), conformance.getAConformance(), new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); PdfAcroForm form = PdfFormCreator.getAcroForm(pdfDoc, true); PdfFormField emptyField = new NonTerminalFormFieldBuilder(pdfDoc, "empty") - .setGenericConformanceLevel(conformanceLevel).createNonTerminalFormField(); + .setConformance(conformance).createNonTerminalFormField(); emptyField.addKid(new PushButtonFormFieldBuilder(pdfDoc, "button") - .setWidgetRectangle(new Rectangle(36, 756, 20, 20)).setGenericConformanceLevel(conformanceLevel) + .setWidgetRectangle(new Rectangle(36, 756, 20, 20)).setConformance(conformance) .createPushButton().setFieldFlags(PdfAnnotation.PRINT) .setFieldName("button").setValue("hello")); form.addField(emptyField); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(fileName, cmp, DESTINATION_FOLDER)); - Assert.assertNull(new VeraPdfValidator().validate(fileName)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNull(new CompareTool().compareByContent(fileName, cmp, DESTINATION_FOLDER)); + Assertions.assertNull(new VeraPdfValidator().validate(fileName)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) } @Test @@ -203,19 +203,19 @@ public void pdfA1DocWithPdfA1CheckBoxFieldTest() throws IOException, Interrupted InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); - PdfAConformanceLevel conformanceLevel = PdfAConformanceLevel.PDF_A_1B; + PdfConformance conformance = PdfConformance.PDF_A_1B; - PdfADocument pdfDoc = new PdfADocument(new PdfWriter(fileName), conformanceLevel, + PdfADocument pdfDoc = new PdfADocument(new PdfWriter(fileName), conformance.getAConformance(), new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); PdfAcroForm form = PdfFormCreator.getAcroForm(pdfDoc, true); form.addField(new CheckBoxFormFieldBuilder(pdfDoc, "checkBox").setWidgetRectangle(new Rectangle(36, 726, 20, 20)) - .setCheckType(CheckBoxType.STAR).setGenericConformanceLevel(conformanceLevel) + .setCheckType(CheckBoxType.STAR).setConformance(conformance) .createCheckBox().setValue("1")); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(fileName, cmp, DESTINATION_FOLDER)); - Assert.assertNull(new VeraPdfValidator().validate(fileName)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNull(new CompareTool().compareByContent(fileName, cmp, DESTINATION_FOLDER)); + Assertions.assertNull(new VeraPdfValidator().validate(fileName)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) } @Test @@ -229,23 +229,23 @@ public void pdfA1DocWithPdfA1ChoiceFieldTest() throws IOException, InterruptedEx "WinAnsi", EmbeddingStrategy.FORCE_EMBEDDED); InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); - PdfAConformanceLevel conformanceLevel = PdfAConformanceLevel.PDF_A_1B; - PdfADocument pdfDoc = new PdfADocument(new PdfWriter(fileName), conformanceLevel, + PdfConformance conformance = PdfConformance.PDF_A_1B; + PdfADocument pdfDoc = new PdfADocument(new PdfWriter(fileName), conformance.getAConformance(), new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); PdfAcroForm form = PdfFormCreator.getAcroForm(pdfDoc, true); PdfArray options = new PdfArray(); options.add(new PdfString("Name")); options.add(new PdfString("Surname")); PdfFormField choiceFormField = new ChoiceFormFieldBuilder(pdfDoc, "choice").setWidgetRectangle(new Rectangle(36, 696, 100, 70)) - .setOptions(options).setGenericConformanceLevel(conformanceLevel) + .setOptions(options).setConformance(conformance) .createList().setValue("1", true); choiceFormField.setFont(fontFreeSans); form.addField(choiceFormField); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(fileName, cmp, DESTINATION_FOLDER)); - Assert.assertNull(new VeraPdfValidator().validate(fileName)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNull(new CompareTool().compareByContent(fileName, cmp, DESTINATION_FOLDER)); + Assertions.assertNull(new VeraPdfValidator().validate(fileName)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) } @Test @@ -259,25 +259,24 @@ public void pdfA1DocWithPdfA1ComboBoxFieldTest() throws IOException, Interrupted InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); - PdfAConformanceLevel conformanceLevel = PdfAConformanceLevel.PDF_A_1B; - PdfADocument pdfDoc = new PdfADocument(new PdfWriter(fileName), conformanceLevel, + PdfConformance conformance = PdfConformance.PDF_A_1B; + PdfADocument pdfDoc = new PdfADocument(new PdfWriter(fileName), conformance.getAConformance(), new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); PdfAcroForm form = PdfFormCreator.getAcroForm(pdfDoc, true); PdfFormField choiceFormField = new ChoiceFormFieldBuilder(pdfDoc, "combo") .setWidgetRectangle(new Rectangle(156, 616, 70, 70)).setOptions(new String[]{"用", "规", "表"}) - .setGenericConformanceLevel(conformanceLevel).createComboBox() + .setConformance(conformance).createComboBox() .setValue("用"); choiceFormField.setFont(fontCJK); form.addField(choiceFormField); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(fileName, cmp, DESTINATION_FOLDER)); - Assert.assertNull(new VeraPdfValidator().validate(fileName)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNull(new CompareTool().compareByContent(fileName, cmp, DESTINATION_FOLDER)); + Assertions.assertNull(new VeraPdfValidator().validate(fileName)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) } @Test - @LogMessages(messages = {@LogMessage(messageTemplate = IoLogMessageConstant.MULTIPLE_VALUES_ON_A_NON_MULTISELECT_FIELD)}) public void pdfA1DocWithPdfA1ListFieldTest() throws IOException, InterruptedException { String name = "pdfA1DocWithPdfA1ListField"; String fileName = DESTINATION_FOLDER + name + ".pdf"; @@ -288,8 +287,8 @@ public void pdfA1DocWithPdfA1ListFieldTest() throws IOException, InterruptedExce InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); - PdfAConformanceLevel conformanceLevel = PdfAConformanceLevel.PDF_A_1B; - PdfADocument pdfDoc = new PdfADocument(new PdfWriter(fileName), conformanceLevel, + PdfConformance conformance = PdfConformance.PDF_A_1B; + PdfADocument pdfDoc = new PdfADocument(new PdfWriter(fileName), conformance.getAConformance(), new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); @@ -297,16 +296,17 @@ public void pdfA1DocWithPdfA1ListFieldTest() throws IOException, InterruptedExce PdfChoiceFormField f = new ChoiceFormFieldBuilder(pdfDoc, "list") .setWidgetRectangle(new Rectangle(86, 556, 50, 200)).setOptions(new String[]{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"}) - .setGenericConformanceLevel(conformanceLevel).createList(); + .setConformance(conformance).createList(); f.setValue("9").setFont(fontFreeSans); f.setValue("4"); f.setTopIndex(2); + f.setMultiSelect(true); f.setListSelected(new String[] {"3", "5"}); form.addField(f); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(fileName, cmp, DESTINATION_FOLDER)); - Assert.assertNull(new VeraPdfValidator().validate(fileName)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNull(new CompareTool().compareByContent(fileName, cmp, DESTINATION_FOLDER)); + Assertions.assertNull(new VeraPdfValidator().validate(fileName)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) } @Test @@ -320,21 +320,21 @@ public void pdfA1DocWithPdfA1PushButtonFieldTest() throws IOException, Interrupt InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); - PdfAConformanceLevel conformanceLevel = PdfAConformanceLevel.PDF_A_1B; - PdfADocument pdfDoc = new PdfADocument(new PdfWriter(fileName), conformanceLevel, + PdfConformance conformance = PdfConformance.PDF_A_1B; + PdfADocument pdfDoc = new PdfADocument(new PdfWriter(fileName), conformance.getAConformance(), new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); PdfAcroForm form = PdfFormCreator.getAcroForm(pdfDoc, true); PdfFormField pushButtonFormField = new PushButtonFormFieldBuilder(pdfDoc, "push button").setWidgetRectangle(new Rectangle(36, 526, 100, 20)) - .setCaption("Push").setGenericConformanceLevel(conformanceLevel) + .setCaption("Push").setConformance(conformance) .createPushButton(); pushButtonFormField.setFont(fontFreeSans).setFontSize(12); form.addField(pushButtonFormField); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(fileName, cmp, DESTINATION_FOLDER)); - Assert.assertNull(new VeraPdfValidator().validate(fileName)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNull(new CompareTool().compareByContent(fileName, cmp, DESTINATION_FOLDER)); + Assertions.assertNull(new VeraPdfValidator().validate(fileName)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) } @Test @@ -345,16 +345,16 @@ public void pdfA1DocWithPdfA1RadioButtonFieldTest() throws IOException, Interrup InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); - PdfAConformanceLevel conformanceLevel = PdfAConformanceLevel.PDF_A_1B; - PdfADocument pdfDoc = new PdfADocument(new PdfWriter(fileName), conformanceLevel, + PdfConformance conformance = PdfConformance.PDF_A_1B; + PdfADocument pdfDoc = new PdfADocument(new PdfWriter(fileName), conformance.getAConformance(), new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); PdfAcroForm form = PdfFormCreator.getAcroForm(pdfDoc, true); String pdfFormFieldName = "radio group"; - RadioFormFieldBuilder builder = new RadioFormFieldBuilder(pdfDoc, pdfFormFieldName).setGenericConformanceLevel(conformanceLevel); - PdfButtonFormField radioGroup = builder.setGenericConformanceLevel(conformanceLevel) + RadioFormFieldBuilder builder = new RadioFormFieldBuilder(pdfDoc, pdfFormFieldName).setConformance(conformance); + PdfButtonFormField radioGroup = builder.setConformance(conformance) .createRadioGroup(); radioGroup.setValue(""); PdfFormAnnotation radio1 = builder @@ -371,8 +371,8 @@ public void pdfA1DocWithPdfA1RadioButtonFieldTest() throws IOException, Interrup pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(fileName, cmp, DESTINATION_FOLDER)); - Assert.assertNull(new VeraPdfValidator().validate(fileName)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNull(new CompareTool().compareByContent(fileName, cmp, DESTINATION_FOLDER)); + Assertions.assertNull(new VeraPdfValidator().validate(fileName)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) } @Test @@ -387,19 +387,19 @@ public void pdfA1DocWithPdfA1TextFieldTest() throws IOException, InterruptedExce InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); - PdfAConformanceLevel conformanceLevel = PdfAConformanceLevel.PDF_A_1B; - PdfADocument pdfDoc = new PdfADocument(new PdfWriter(fileName), conformanceLevel, + PdfConformance conformance = PdfConformance.PDF_A_1B; + PdfADocument pdfDoc = new PdfADocument(new PdfWriter(fileName), conformance.getAConformance(), new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); PdfAcroForm form = PdfFormCreator.getAcroForm(pdfDoc, true); PdfFormField textFormField = new TextFormFieldBuilder(pdfDoc, "text").setWidgetRectangle(new Rectangle(36, 466, 90, 20)) - .setGenericConformanceLevel(conformanceLevel).createText().setValue("textField").setValue("iText"); + .setConformance(conformance).createText().setValue("textField").setValue("iText"); textFormField.setFont(fontFreeSans).setFontSize(12); form.addField(textFormField); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(fileName, cmp, DESTINATION_FOLDER)); - Assert.assertNull(new VeraPdfValidator().validate(fileName)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNull(new CompareTool().compareByContent(fileName, cmp, DESTINATION_FOLDER)); + Assertions.assertNull(new VeraPdfValidator().validate(fileName)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) } @Test @@ -414,21 +414,21 @@ public void pdfA1DocWithPdfA1SignatureFieldTest() throws IOException, Interrupte InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); - PdfAConformanceLevel conformanceLevel = PdfAConformanceLevel.PDF_A_1B; - PdfADocument pdfDoc = new PdfADocument(new PdfWriter(fileName), conformanceLevel, + PdfConformance conformance = PdfConformance.PDF_A_1B; + PdfADocument pdfDoc = new PdfADocument(new PdfWriter(fileName), conformance.getAConformance(), new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is)); PdfAcroForm form = PdfFormCreator.getAcroForm(pdfDoc, true); PdfFormField signFormField = new SignatureFormFieldBuilder(pdfDoc, "signature") - .setGenericConformanceLevel(conformanceLevel).createSignature(); + .setConformance(conformance).createSignature(); signFormField.setFont(fontFreeSans).setFontSize(20); form.addField(signFormField); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(fileName, cmp, DESTINATION_FOLDER)); - Assert.assertNull(new VeraPdfValidator().validate(fileName)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNull(new CompareTool().compareByContent(fileName, cmp, DESTINATION_FOLDER)); + Assertions.assertNull(new VeraPdfValidator().validate(fileName)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) } @Test @@ -437,7 +437,7 @@ public void mergePdfADocWithFormTest() throws IOException, InterruptedException String mergedDocFileName = DESTINATION_FOLDER + "mergedPdfADoc.pdf"; try (InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); - PdfADocument pdfDoc = new PdfADocument(new PdfWriter(fileName), PdfAConformanceLevel.PDF_A_1B, + PdfADocument pdfDoc = new PdfADocument(new PdfWriter(fileName), PdfAConformance.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB ICC preference", is)); Document doc = new Document(pdfDoc)) { @@ -448,20 +448,20 @@ public void mergePdfADocWithFormTest() throws IOException, InterruptedException PdfAcroForm form = PdfFormCreator.getAcroForm(pdfDoc, true); PdfFormField field = new TextFormFieldBuilder(pdfDoc, "text").setWidgetRectangle(new Rectangle(150, 100, 100, 20)) - .setGenericConformanceLevel(PdfAConformanceLevel.PDF_A_1B).createText() + .setConformance(PdfConformance.PDF_A_1B).createText() .setValue("textField").setFieldName("text"); field.setFont(font).setFontSize(10); field.getFirstFormAnnotation().setPage(1); form.addField(field, pdfDoc.getPage(1)); } - Assert.assertNull(new VeraPdfValidator().validate(fileName)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNull(new VeraPdfValidator().validate(fileName)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) PdfADocument pdfDocToMerge; try (InputStream is = FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"); PdfDocument newDoc = new PdfDocument(new PdfReader(fileName))) { pdfDocToMerge = new PdfADocument(new PdfWriter(mergedDocFileName).setSmartMode(true), - PdfAConformanceLevel.PDF_A_1B, + PdfAConformance.PDF_A_1B, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB ICC preference", is)); @@ -470,8 +470,8 @@ public void mergePdfADocWithFormTest() throws IOException, InterruptedException pdfDocToMerge.close(); String cmp = SOURCE_FOLDER + "cmp/PdfAFormFieldTest/cmp_mergePdfADocWithForm.pdf"; - Assert.assertNull(new VeraPdfValidator().validate(mergedDocFileName)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) - Assert.assertNull(new CompareTool().compareByContent(mergedDocFileName, cmp, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new VeraPdfValidator().validate(mergedDocFileName)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNull(new CompareTool().compareByContent(mergedDocFileName, cmp, DESTINATION_FOLDER, "diff_")); } @@ -486,7 +486,7 @@ public void testComboBoxNoFont() throws IOException, InterruptedException { comboBoxField.addOption(new SelectFieldItem("item1")); comboBoxField.addOption(new SelectFieldItem("item2")); comboBoxField.addOption(new SelectFieldItem("item3")); - Assert.assertThrows(IllegalStateException.class, () -> { + Assertions.assertThrows(IllegalStateException.class, () -> { document.add(comboBoxField); }); })); @@ -499,7 +499,7 @@ public void testButtonNoFont() throws IOException, InterruptedException { Button button = new Button("button"); button.setValue("Hello there"); button.setInteractive(true); - Assert.assertThrows(IllegalStateException.class, () -> { + Assertions.assertThrows(IllegalStateException.class, () -> { document.add(button); }); })); @@ -513,7 +513,7 @@ public void testTextFieldNoFont() throws IOException, InterruptedException { inputField.setValue("Hello there"); inputField.setInteractive(true); - Assert.assertThrows(IllegalStateException.class, () -> { + Assertions.assertThrows(IllegalStateException.class, () -> { document.add(inputField); }); })); @@ -528,7 +528,7 @@ public void testCheckboxWithPDFA() throws IOException, InterruptedException { CheckBox checkBox = new CheckBox("CheckBox"); checkBox.setChecked(true); checkBox.setInteractive(true); - checkBox.setPdfAConformanceLevel(PdfAConformanceLevel.PDF_A_1A); + checkBox.setPdfConformance(PdfConformance.PDF_A_1A); doc.add(checkBox); }); } @@ -544,7 +544,11 @@ public void testMultipleCombinationsFontOnFieldSeparate() throws IOException, In for (Supplier formFieldSupplier : generateFormFields()) { IFormField formField = formFieldSupplier.get(); formField.setProperty(Property.FONT, font); - formField.setProperty(Property.BORDER, new SolidBorder(ColorConstants.BLACK, 1)); + SolidBorder border = new SolidBorder(ColorConstants.BLACK, 1); + formField.setProperty(Property.BORDER_TOP, border); + formField.setProperty(Property.BORDER_RIGHT, border); + formField.setProperty(Property.BORDER_BOTTOM, border); + formField.setProperty(Property.BORDER_LEFT, border); formField.setInteractive(true); document.add(formField); } @@ -561,7 +565,11 @@ public void testMultipleCombinationsWriteAndReload() throws IOException, Interru for (Supplier formFieldSupplier : generateFormFields()) { IFormField formField = formFieldSupplier.get(); formField.setProperty(Property.FONT, font); - formField.setProperty(Property.BORDER, new SolidBorder(ColorConstants.BLACK, 1)); + SolidBorder border = new SolidBorder(ColorConstants.BLACK, 1); + formField.setProperty(Property.BORDER_TOP, border); + formField.setProperty(Property.BORDER_RIGHT, border); + formField.setProperty(Property.BORDER_BOTTOM, border); + formField.setProperty(Property.BORDER_LEFT, border); formField.setInteractive(true); document.add(formField); } @@ -574,8 +582,8 @@ public void testMultipleCombinationsWriteAndReload() throws IOException, Interru stringPdfFormFieldEntry.getValue().setValue("item1"); } newDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf2, cmp, DESTINATION_FOLDER)); - Assert.assertNull(new VeraPdfValidator().validate(outPdf2)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNull(new CompareTool().compareByContent(outPdf2, cmp, DESTINATION_FOLDER)); + Assertions.assertNull(new VeraPdfValidator().validate(outPdf2)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) } @@ -589,7 +597,11 @@ public void testMultipleCombinationsOnDocument() throws IOException, Interrupted document.setFont(font); for (Supplier formFieldSupplier : generateFormFields()) { IFormField formField = formFieldSupplier.get(); - formField.setProperty(Property.BORDER, new SolidBorder(ColorConstants.BLACK, 1)); + SolidBorder border = new SolidBorder(ColorConstants.BLACK, 1); + formField.setProperty(Property.BORDER_TOP, border); + formField.setProperty(Property.BORDER_RIGHT, border); + formField.setProperty(Property.BORDER_BOTTOM, border); + formField.setProperty(Property.BORDER_LEFT, border); formField.setProperty(Property.FONT, font); formField.setInteractive(true); document.add(formField); @@ -607,7 +619,11 @@ public void testMultipleCombinationsFontOnFieldSeparateNonInteractive() throws I for (Supplier formFieldSupplier : generateFormFields()) { IFormField formField = formFieldSupplier.get(); formField.setProperty(Property.FONT, font); - formField.setProperty(Property.BORDER, new SolidBorder(ColorConstants.BLACK, 1)); + SolidBorder border = new SolidBorder(ColorConstants.BLACK, 1); + formField.setProperty(Property.BORDER_TOP, border); + formField.setProperty(Property.BORDER_RIGHT, border); + formField.setProperty(Property.BORDER_BOTTOM, border); + formField.setProperty(Property.BORDER_LEFT, border); formField.setInteractive(false); document.add(formField); } @@ -624,7 +640,11 @@ public void testMultipleCombinationsOnDocumentNonInteractive() throws IOExceptio document.setFont(font); for (Supplier formFieldSupplier : generateFormFields()) { IFormField formField = formFieldSupplier.get(); - formField.setProperty(Property.BORDER, new SolidBorder(ColorConstants.BLACK, 1)); + SolidBorder border = new SolidBorder(ColorConstants.BLACK, 1); + formField.setProperty(Property.BORDER_TOP, border); + formField.setProperty(Property.BORDER_RIGHT, border); + formField.setProperty(Property.BORDER_BOTTOM, border); + formField.setProperty(Property.BORDER_LEFT, border); formField.setProperty(Property.FONT, font); formField.setInteractive(false); document.add(formField); @@ -643,7 +663,7 @@ public void testCopyPagesDoesntEmbedHelveticaFont() throws IOException, Interrup PdfWriter writer = new PdfWriter(simplePdf, new WriterProperties() .setPdfVersion(PdfVersion.PDF_2_0)); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4E, + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4E, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"))); @@ -655,7 +675,7 @@ public void testCopyPagesDoesntEmbedHelveticaFont() throws IOException, Interrup PdfWriter writer2 = new PdfWriter(outPdf, new WriterProperties() .setPdfVersion(PdfVersion.PDF_2_0)); - PdfADocument doc2 = new PdfADocument(writer2, PdfAConformanceLevel.PDF_A_4, + PdfADocument doc2 = new PdfADocument(writer2, PdfAConformance.PDF_A_4, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"))); @@ -664,8 +684,8 @@ public void testCopyPagesDoesntEmbedHelveticaFont() throws IOException, Interrup docToCopy.close(); doc2.close(); - Assert.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmp, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmp, DESTINATION_FOLDER, "diff_")); } @@ -695,7 +715,7 @@ public void pdfASignatureFieldWithTextAndFontTest() throws IOException, Interrup PdfSignatureFormField signatureFormField = signatureFormFieldBuilder.setWidgetRectangle( new Rectangle(200, 200, 40, 40)) .setFont(fontFreeSans) - .setGenericConformanceLevel(PdfAConformanceLevel.PDF_A_4) + .setConformance(PdfConformance.PDF_A_4) .createSignature(); signatureFormField.getFirstFormAnnotation().setFormFieldElement(signatureFieldAppearance2); form.addField(signatureFormField); @@ -709,7 +729,7 @@ private void makePdfDocument(String outPdf, String cmp, Consumer consu PdfWriter writer = new PdfWriter(outPdf, new WriterProperties() .setPdfVersion(PdfVersion.PDF_2_0)); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4E, + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4E, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"))); @@ -719,8 +739,8 @@ private void makePdfDocument(String outPdf, String cmp, Consumer consu if (cmp == null) { return; } - Assert.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmp, DESTINATION_FOLDER)); + Assertions.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmp, DESTINATION_FOLDER)); } private List> generateFormFields() { @@ -729,13 +749,13 @@ private List> generateFormFields() { inputs.add(() -> { CheckBox checkBox = new CheckBox("CheckBox"); checkBox.setChecked(true); - checkBox.setPdfAConformanceLevel(PdfAConformanceLevel.PDF_A_4); + checkBox.setPdfConformance(PdfConformance.PDF_A_4); return checkBox; }); inputs.add(() -> { CheckBox checkBox = new CheckBox("CheckBox1"); checkBox.setChecked(false); - checkBox.setPdfAConformanceLevel(PdfAConformanceLevel.PDF_A_4); + checkBox.setPdfConformance(PdfConformance.PDF_A_4); return checkBox; }); inputs.add(() -> { @@ -813,7 +833,7 @@ public void draw(DrawContext context) { PdfDocument pdf = context.getDocument(); PdfAcroForm form = PdfFormCreator.getAcroForm(pdf, true); PdfFormAnnotation chk = new RadioFormFieldBuilder(pdf, "") - .setGenericConformanceLevel(PdfAConformanceLevel.PDF_A_1B).createRadioButton(_value, bbox); + .setConformance(PdfConformance.PDF_A_1B).createRadioButton(_value, bbox); _group.addKid(chk); chk.setPage(pageNumber); diff --git a/pdfa/src/test/java/com/itextpdf/pdfa/PdfAIndirectObjectsCountLimitTest.java b/pdfa/src/test/java/com/itextpdf/pdfa/PdfAIndirectObjectsCountLimitTest.java index 7bd3b5e8b9..b5c908a658 100644 --- a/pdfa/src/test/java/com/itextpdf/pdfa/PdfAIndirectObjectsCountLimitTest.java +++ b/pdfa/src/test/java/com/itextpdf/pdfa/PdfAIndirectObjectsCountLimitTest.java @@ -27,36 +27,35 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.font.PdfFont; import com.itextpdf.kernel.font.PdfFontFactory; import com.itextpdf.kernel.font.PdfFontFactory.EmbeddingStrategy; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfAConformance; import com.itextpdf.kernel.pdf.PdfOutputIntent; import com.itextpdf.kernel.pdf.PdfReader; import com.itextpdf.kernel.pdf.PdfWriter; import com.itextpdf.kernel.pdf.StampingProperties; +import com.itextpdf.kernel.validation.ValidationContainer; import com.itextpdf.layout.Document; import com.itextpdf.layout.element.Paragraph; import com.itextpdf.pdfa.checker.PdfA1Checker; import com.itextpdf.pdfa.exceptions.PdfAConformanceException; import com.itextpdf.pdfa.exceptions.PdfaExceptionMessageConstant; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.ByteArrayOutputStream; -import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.UUID; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfAIndirectObjectsCountLimitTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/pdfa/"; @Test public void validAmountOfIndirectObjectsTest() throws IOException { - PdfA1Checker testChecker = new PdfA1Checker(PdfAConformanceLevel.PDF_A_1B) { + PdfA1Checker testChecker = new PdfA1Checker(PdfAConformance.PDF_A_1B) { @Override protected long getMaxNumberOfIndirectObjects() { return 10; @@ -67,11 +66,13 @@ protected long getMaxNumberOfIndirectObjects() { InputStream icm = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); OutputStream fos = new ByteArrayOutputStream(); Document document = new Document(new PdfADocument(new PdfWriter(fos), - PdfAConformanceLevel.PDF_A_1B, + PdfAConformance.PDF_A_1B, getOutputIntent(icm))); ) { PdfADocument pdfa = (PdfADocument) document.getPdfDocument(); - pdfa.checker = testChecker; + final ValidationContainer container = new ValidationContainer(); + container.addChecker(testChecker); + pdfa.getDiContainer().register(ValidationContainer.class, container); document.add(buildContent()); // generated document contains exactly 10 indirect objects. Given 10 is the allowed @@ -81,7 +82,7 @@ protected long getMaxNumberOfIndirectObjects() { @Test public void invalidAmountOfIndirectObjectsTest() throws IOException { - PdfA1Checker testChecker = new PdfA1Checker(PdfAConformanceLevel.PDF_A_1B) { + PdfA1Checker testChecker = new PdfA1Checker(PdfAConformance.PDF_A_1B) { @Override protected long getMaxNumberOfIndirectObjects() { return 9; @@ -93,23 +94,25 @@ protected long getMaxNumberOfIndirectObjects() { OutputStream fos = new ByteArrayOutputStream(); ) { Document document = new Document(new PdfADocument(new PdfWriter(fos), - PdfAConformanceLevel.PDF_A_1B, + PdfAConformance.PDF_A_1B, getOutputIntent(icm))); PdfADocument pdfa = (PdfADocument) document.getPdfDocument(); - pdfa.checker = testChecker; + final ValidationContainer container = new ValidationContainer(); + container.addChecker(testChecker); + pdfa.getDiContainer().register(ValidationContainer.class, container); document.add(buildContent()); // generated document contains exactly 10 indirect objects. Given 9 is the allowed // limit per "mock specification" conformance exception should be thrown as the limit // is exceeded - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> document.close()); - Assert.assertEquals(PdfaExceptionMessageConstant.MAXIMUM_NUMBER_OF_INDIRECT_OBJECTS_EXCEEDED, e.getMessage()); + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> document.close()); + Assertions.assertEquals(PdfaExceptionMessageConstant.MAXIMUM_NUMBER_OF_INDIRECT_OBJECTS_EXCEEDED, e.getMessage()); } } @Test public void invalidAmountOfIndirectObjectsAppendModeTest() throws IOException { - PdfA1Checker testChecker = new PdfA1Checker(PdfAConformanceLevel.PDF_A_1B) { + PdfA1Checker testChecker = new PdfA1Checker(PdfAConformance.PDF_A_1B) { @Override protected long getMaxNumberOfIndirectObjects() { return 11; @@ -121,13 +124,15 @@ protected long getMaxNumberOfIndirectObjects() { OutputStream fos = new ByteArrayOutputStream(); ) { PdfADocument pdfa = new PdfADocument(new PdfReader(fis), new PdfWriter(fos), new StampingProperties().useAppendMode()); - pdfa.checker = testChecker; + final ValidationContainer container = new ValidationContainer(); + container.addChecker(testChecker); + pdfa.getDiContainer().register(ValidationContainer.class, container); pdfa.addNewPage(); // during closing of pdfa object exception will be thrown as new document will contain // 12 indirect objects and limit per "mock specification" conformance will be exceeded - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> pdfa.close()); - Assert.assertEquals(PdfaExceptionMessageConstant.MAXIMUM_NUMBER_OF_INDIRECT_OBJECTS_EXCEEDED, e.getMessage()); + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfa.close()); + Assertions.assertEquals(PdfaExceptionMessageConstant.MAXIMUM_NUMBER_OF_INDIRECT_OBJECTS_EXCEEDED, e.getMessage()); } } diff --git a/pdfa/src/test/java/com/itextpdf/pdfa/PdfAIndirectResourcesTest.java b/pdfa/src/test/java/com/itextpdf/pdfa/PdfAIndirectResourcesTest.java index 62f066b74f..f8e8785adf 100644 --- a/pdfa/src/test/java/com/itextpdf/pdfa/PdfAIndirectResourcesTest.java +++ b/pdfa/src/test/java/com/itextpdf/pdfa/PdfAIndirectResourcesTest.java @@ -29,21 +29,19 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -import java.io.FileNotFoundException; import java.io.IOException; import java.util.Set; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfAIndirectResourcesTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/pdfa/pdfs/"; public static final String destinationFolder = "./target/test/com/itextpdf/pdfa/PdfAIndirectResourcesTest/"; - @Before + @BeforeEach public void configure() { createDestinationFolder(destinationFolder); } @@ -70,7 +68,7 @@ public void indirectResources02Test() throws IOException { private static class CustomPdfWriter extends PdfWriter { private int objectToFlushNumber; - public CustomPdfWriter(String filename, int objectToFlushNumber) throws FileNotFoundException { + public CustomPdfWriter(String filename, int objectToFlushNumber) throws IOException { super(filename); this.objectToFlushNumber = objectToFlushNumber; } diff --git a/pdfa/src/test/java/com/itextpdf/pdfa/PdfALongStringTest.java b/pdfa/src/test/java/com/itextpdf/pdfa/PdfALongStringTest.java index 4dec152b8f..66e20182d5 100644 --- a/pdfa/src/test/java/com/itextpdf/pdfa/PdfALongStringTest.java +++ b/pdfa/src/test/java/com/itextpdf/pdfa/PdfALongStringTest.java @@ -26,7 +26,7 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.font.PdfFont; import com.itextpdf.kernel.font.PdfFontFactory; import com.itextpdf.kernel.font.PdfFontFactory.EmbeddingStrategy; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfAConformance; import com.itextpdf.kernel.pdf.PdfOutputIntent; import com.itextpdf.kernel.pdf.PdfWriter; import com.itextpdf.layout.Document; @@ -34,23 +34,22 @@ This file is part of the iText (R) project. import com.itextpdf.pdfa.exceptions.PdfAConformanceException; import com.itextpdf.pdfa.exceptions.PdfaExceptionMessageConstant; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.InputStream; import java.io.OutputStream; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfALongStringTest extends ExtendedITextTest { private static final String sourceFolder = "./src/test/resources/com/itextpdf/pdfa/"; private static final String destinationFolder = "./target/test/com/itextpdf/pdfa/PdfALongStringTest/"; private static final String LOREM_IPSUM = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis condimentum, tortor sit amet fermentum pharetra, sem felis finibus enim, vel consectetur nunc justo at nisi. In hac habitasse platea dictumst. Donec quis suscipit eros. Nam urna purus, scelerisque in placerat in, convallis vel sapien. Suspendisse sed lacus sit amet orci ornare vulputate. In hac habitasse platea dictumst. Ut eu aliquet felis, at consectetur neque."; private static final int STRING_LENGTH_LIMIT = 32767; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } @@ -61,7 +60,7 @@ public void runTest() throws Exception { String filename = destinationFolder + file; try (InputStream icm = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); OutputStream fos = FileUtil.getFileOutputStream(filename)) { - Document document = new Document(new PdfADocument(new PdfWriter(fos), PdfAConformanceLevel.PDF_A_3U, + Document document = new Document(new PdfADocument(new PdfWriter(fos), PdfAConformance.PDF_A_3U, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB ICC preference", icm)) ); StringBuilder stringBuilder = new StringBuilder(LOREM_IPSUM); @@ -79,8 +78,8 @@ public void runTest() throws Exception { // when document is closing, ISO conformance check is performed // this document contain a string which is longer than it is allowed // per specification. That is why conformance exception should be thrown - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> document.close()); - Assert.assertEquals(PdfaExceptionMessageConstant.PDF_STRING_IS_TOO_LONG, e.getMessage()); + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> document.close()); + Assertions.assertEquals(PdfaExceptionMessageConstant.PDF_STRING_IS_TOO_LONG, e.getMessage()); } } } diff --git a/pdfa/src/test/java/com/itextpdf/pdfa/PdfAPageTest.java b/pdfa/src/test/java/com/itextpdf/pdfa/PdfAPageTest.java index e2b768bd7c..240f8ec7a0 100644 --- a/pdfa/src/test/java/com/itextpdf/pdfa/PdfAPageTest.java +++ b/pdfa/src/test/java/com/itextpdf/pdfa/PdfAPageTest.java @@ -23,38 +23,37 @@ This file is part of the iText (R) project. package com.itextpdf.pdfa; import com.itextpdf.commons.utils.FileUtil; -import com.itextpdf.kernel.events.Event; -import com.itextpdf.kernel.events.IEventHandler; -import com.itextpdf.kernel.events.PdfDocumentEvent; +import com.itextpdf.kernel.pdf.event.AbstractPdfDocumentEventHandler; +import com.itextpdf.kernel.pdf.event.AbstractPdfDocumentEvent; +import com.itextpdf.kernel.pdf.event.PdfDocumentEvent; import com.itextpdf.kernel.geom.PageSize; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfAConformance; import com.itextpdf.kernel.pdf.PdfOutputIntent; import com.itextpdf.kernel.pdf.PdfPage; import com.itextpdf.kernel.pdf.PdfString; import com.itextpdf.kernel.pdf.PdfWriter; +import com.itextpdf.kernel.validation.ValidationContainer; +import com.itextpdf.kernel.validation.context.PdfPageValidationContext; import com.itextpdf.layout.Document; import com.itextpdf.layout.element.AreaBreak; import com.itextpdf.pdfa.logs.PdfALogMessageConstant; import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import com.itextpdf.test.pdfa.VeraPdfValidator; // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -import java.io.FileInputStream; import java.io.IOException; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfAPageTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/pdfa/"; private static final String destinationFolder = "./target/test/com/itextpdf/pdfa/PdfAPageTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } @@ -65,7 +64,7 @@ public void checkThatFlushingPreventedWhenAddingElementToDocument() throws IOExc // Expected log message that page flushing was not performed String outPdf = destinationFolder + "checkThatFlushingPreventedWhenAddingElementToDocument.pdf"; PdfWriter writer = new PdfWriter(outPdf); - PdfADocument pdfDoc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1A, + PdfADocument pdfDoc = new PdfADocument(writer, PdfAConformance.PDF_A_1A, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"))); pdfDoc.setTagged(); @@ -82,15 +81,15 @@ public void checkThatFlushingPreventedWhenAddingElementToDocument() throws IOExc } // Before closing document have 3 pages, but no one call of end page event - Assert.assertEquals(pageCount, document.getPdfDocument().getNumberOfPages()); - Assert.assertEquals(0, eventHandler.getCounter()); + Assertions.assertEquals(pageCount, document.getPdfDocument().getNumberOfPages()); + Assertions.assertEquals(0, eventHandler.getCounter()); document.close(); // During the closing event was called on each document page - Assert.assertEquals(pageCount, eventHandler.getCounter()); + Assertions.assertEquals(pageCount, eventHandler.getCounter()); - Assert.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) } @Test @@ -99,7 +98,7 @@ public void checkThatFlushingPreventedWithFalseFlushResourcesContentStreams() th // Expected log message that page flushing was not performed String outPdf = destinationFolder + "checkThatFlushingPreventedWithFalseFlushResourcesContentStreams.pdf"; PdfWriter writer = new PdfWriter(outPdf); - PdfADocument pdfDoc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1A, + PdfADocument pdfDoc = new PdfADocument(writer, PdfAConformance.PDF_A_1A, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"))); pdfDoc.setTagged(); @@ -113,21 +112,21 @@ public void checkThatFlushingPreventedWithFalseFlushResourcesContentStreams() th pdfDoc.addNewPage().flush(false); } - Assert.assertEquals(pageCount, pdfDoc.getNumberOfPages()); - Assert.assertEquals(0, eventHandler.getCounter()); + Assertions.assertEquals(pageCount, pdfDoc.getNumberOfPages()); + Assertions.assertEquals(0, eventHandler.getCounter()); pdfDoc.close(); - Assert.assertEquals(pageCount, eventHandler.getCounter()); + Assertions.assertEquals(pageCount, eventHandler.getCounter()); - Assert.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) } @Test public void checkFlushingWhenPdfDocumentIsClosing() throws IOException { String outPdf = destinationFolder + "checkFlushingWhenPdfDocumentIsClosing.pdf"; PdfWriter writer = new PdfWriter(outPdf); - PdfADocument pdfDoc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1A, + PdfADocument pdfDoc = new PdfADocument(writer, PdfAConformance.PDF_A_1A, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"))); pdfDoc.setTagged(); @@ -141,21 +140,21 @@ public void checkFlushingWhenPdfDocumentIsClosing() throws IOException { pdfDoc.addNewPage(); } - Assert.assertEquals(pageCount, pdfDoc.getNumberOfPages()); - Assert.assertEquals(0, eventHandler.getCounter()); + Assertions.assertEquals(pageCount, pdfDoc.getNumberOfPages()); + Assertions.assertEquals(0, eventHandler.getCounter()); pdfDoc.close(); - Assert.assertEquals(pageCount, eventHandler.getCounter()); + Assertions.assertEquals(pageCount, eventHandler.getCounter()); - Assert.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) } @Test public void checkFlushingWithTrueFlushResourcesContentStreams() throws IOException { String outPdf = destinationFolder + "checkFlushingWithTrueFlushResourcesContentStreams.pdf"; PdfWriter writer = new PdfWriter(outPdf); - PdfADocument pdfDoc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1A, + PdfADocument pdfDoc = new PdfADocument(writer, PdfAConformance.PDF_A_1A, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"))); pdfDoc.setTagged(); @@ -169,21 +168,21 @@ public void checkFlushingWithTrueFlushResourcesContentStreams() throws IOExcepti pdfDoc.addNewPage().flush(true); } - Assert.assertEquals(pageCount, pdfDoc.getNumberOfPages()); - Assert.assertEquals(pageCount, eventHandler.getCounter()); + Assertions.assertEquals(pageCount, pdfDoc.getNumberOfPages()); + Assertions.assertEquals(pageCount, eventHandler.getCounter()); pdfDoc.close(); - Assert.assertEquals(pageCount, eventHandler.getCounter()); + Assertions.assertEquals(pageCount, eventHandler.getCounter()); - Assert.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) } @Test public void checkFlushingOfCheckedPage() throws IOException { String outPdf = destinationFolder + "checkFlushingOfCheckedPage.pdf"; PdfWriter writer = new PdfWriter(outPdf); - PdfADocument pdfDoc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1A, + PdfADocument pdfDoc = new PdfADocument(writer, PdfAConformance.PDF_A_1A, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"))); pdfDoc.setTagged(); @@ -195,21 +194,21 @@ public void checkFlushingOfCheckedPage() throws IOException { int pageCount = 3; for (int i = 0; i < pageCount; i++) { PdfPage page = pdfDoc.addNewPage(); - pdfDoc.checker.checkSinglePage(page); + pdfDoc.getDiContainer().getInstance(ValidationContainer.class).validate(new PdfPageValidationContext(page)); page.flush(false); } - Assert.assertEquals(pageCount, pdfDoc.getNumberOfPages()); - Assert.assertEquals(pageCount, eventHandler.getCounter()); + Assertions.assertEquals(pageCount, pdfDoc.getNumberOfPages()); + Assertions.assertEquals(pageCount, eventHandler.getCounter()); pdfDoc.close(); - Assert.assertEquals(pageCount, eventHandler.getCounter()); + Assertions.assertEquals(pageCount, eventHandler.getCounter()); - Assert.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) } - static class EndPageEventHandler implements IEventHandler { + static class EndPageEventHandler extends AbstractPdfDocumentEventHandler { private int counter = 0; EndPageEventHandler() { @@ -220,7 +219,7 @@ public int getCounter() { } @Override - public void handleEvent(Event event) { + public void onAcceptedEvent(AbstractPdfDocumentEvent event) { counter++; } } diff --git a/pdfa/src/test/java/com/itextpdf/pdfa/PdfAPushbuttonfieldTest.java b/pdfa/src/test/java/com/itextpdf/pdfa/PdfAPushbuttonfieldTest.java index fd85cfbd84..785fd649de 100644 --- a/pdfa/src/test/java/com/itextpdf/pdfa/PdfAPushbuttonfieldTest.java +++ b/pdfa/src/test/java/com/itextpdf/pdfa/PdfAPushbuttonfieldTest.java @@ -31,31 +31,30 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.font.PdfFontFactory; import com.itextpdf.kernel.font.PdfFontFactory.EmbeddingStrategy; import com.itextpdf.kernel.geom.Rectangle; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfAConformance; +import com.itextpdf.kernel.pdf.PdfConformance; import com.itextpdf.kernel.pdf.PdfOutputIntent; import com.itextpdf.kernel.pdf.PdfString; import com.itextpdf.kernel.pdf.PdfWriter; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import com.itextpdf.test.pdfa.VeraPdfValidator; // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) -import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfAPushbuttonfieldTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/pdfa/"; public static final String cmpFolder = "./src/test/resources/com/itextpdf/pdfa/cmp/PdfAPushbuttonfieldTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/pdfa/PdfAPushbuttonfieldTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } @@ -70,7 +69,7 @@ public void pdfA1bButtonAppearanceTest() throws IOException, InterruptedExceptio PdfWriter writer = new PdfWriter(outPath); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, outputIntent); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_1B, outputIntent); doc.setTagged(); doc.getCatalog().setLang(new PdfString("en-US")); doc.addNewPage(); @@ -80,14 +79,14 @@ public void pdfA1bButtonAppearanceTest() throws IOException, InterruptedExceptio PdfFont font = PdfFontFactory.createFont(sourceFolder + "FreeSans.ttf", "WinAnsi", EmbeddingStrategy.FORCE_EMBEDDED); PdfFormField button = new PushButtonFormFieldBuilder(doc, "push button").setWidgetRectangle(rect) - .setCaption("push").setGenericConformanceLevel(PdfAConformanceLevel.PDF_A_1B) + .setCaption("push").setConformance(PdfConformance.PDF_A_1B) .createPushButton(); button.setFont(font).setFontSize(12); form.addField(button); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outPath, cmpPath, destinationFolder, diff)); - Assert.assertNull(new VeraPdfValidator().validate(outPath)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNull(new CompareTool().compareByContent(outPath, cmpPath, destinationFolder, diff)); + Assertions.assertNull(new VeraPdfValidator().validate(outPath)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) } @@ -101,7 +100,7 @@ public void pdfA1bButtonAppearanceRegenerateTest() throws IOException, Interrupt PdfWriter writer = new PdfWriter(outPath); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, outputIntent); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_1B, outputIntent); doc.setTagged(); doc.getCatalog().setLang(new PdfString("en-US")); doc.addNewPage(); @@ -111,15 +110,15 @@ public void pdfA1bButtonAppearanceRegenerateTest() throws IOException, Interrupt PdfFont font = PdfFontFactory.createFont(sourceFolder + "FreeSans.ttf", "WinAnsi", EmbeddingStrategy.FORCE_EMBEDDED); PdfFormField button = new PushButtonFormFieldBuilder(doc, "push button").setWidgetRectangle(rect) - .setCaption("push").setGenericConformanceLevel(PdfAConformanceLevel.PDF_A_1B) + .setCaption("push").setConformance(PdfConformance.PDF_A_1B) .createPushButton(); button.setFont(font).setFontSize(12); button.regenerateField(); form.addField(button); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outPath, cmpPath, destinationFolder, diff)); - Assert.assertNull(new VeraPdfValidator().validate(outPath)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNull(new CompareTool().compareByContent(outPath, cmpPath, destinationFolder, diff)); + Assertions.assertNull(new VeraPdfValidator().validate(outPath)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) } @Test @@ -132,7 +131,7 @@ public void pdfA1bButtonAppearanceSetValueTest() throws IOException, Interrupted PdfWriter writer = new PdfWriter(outPath); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, outputIntent); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_1B, outputIntent); doc.setTagged(); doc.getCatalog().setLang(new PdfString("en-US")); doc.addNewPage(); @@ -142,14 +141,14 @@ public void pdfA1bButtonAppearanceSetValueTest() throws IOException, Interrupted PdfFont font = PdfFontFactory.createFont(sourceFolder + "FreeSans.ttf", "WinAnsi", EmbeddingStrategy.FORCE_EMBEDDED); PdfFormField button = new PushButtonFormFieldBuilder(doc, "push button").setWidgetRectangle(rect) - .setCaption("push").setGenericConformanceLevel(PdfAConformanceLevel.PDF_A_1B) + .setCaption("push").setConformance(PdfConformance.PDF_A_1B) .createPushButton(); button.setFont(font).setFontSize(12); button.setValue("button"); form.addField(button); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outPath, cmpPath, destinationFolder, diff)); - Assert.assertNull(new VeraPdfValidator().validate(outPath)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNull(new CompareTool().compareByContent(outPath, cmpPath, destinationFolder, diff)); + Assertions.assertNull(new VeraPdfValidator().validate(outPath)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) } } diff --git a/pdfa/src/test/java/com/itextpdf/pdfa/PdfARadiofieldTest.java b/pdfa/src/test/java/com/itextpdf/pdfa/PdfARadiofieldTest.java index 840d6af54b..1a1802a7ad 100644 --- a/pdfa/src/test/java/com/itextpdf/pdfa/PdfARadiofieldTest.java +++ b/pdfa/src/test/java/com/itextpdf/pdfa/PdfARadiofieldTest.java @@ -27,34 +27,31 @@ This file is part of the iText (R) project. import com.itextpdf.forms.fields.PdfButtonFormField; import com.itextpdf.forms.fields.PdfFormAnnotation; import com.itextpdf.forms.fields.PdfFormCreator; -import com.itextpdf.forms.fields.PdfFormField; import com.itextpdf.forms.fields.RadioFormFieldBuilder; import com.itextpdf.kernel.colors.ColorConstants; import com.itextpdf.kernel.geom.Rectangle; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfAConformance; import com.itextpdf.kernel.pdf.PdfOutputIntent; import com.itextpdf.kernel.pdf.PdfString; import com.itextpdf.kernel.pdf.PdfWriter; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfARadiofieldTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/pdfa/"; public static final String cmpFolder = "./src/test/resources/com/itextpdf/pdfa/cmp/PdfARadiofieldTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/pdfa/PdfARadiofieldTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(destinationFolder); } @@ -69,7 +66,7 @@ public void pdfA1aRadioFieldOffAppearanceTest() throws IOException, InterruptedE PdfWriter writer = new PdfWriter(outPath); InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1B, outputIntent); + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_1B, outputIntent); doc.setTagged(); doc.getCatalog().setLang(new PdfString("en-US")); doc.addNewPage(); @@ -103,6 +100,6 @@ public void pdfA1aRadioFieldOffAppearanceTest() throws IOException, InterruptedE doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outPath, cmpPath, destinationFolder, diff)); + Assertions.assertNull(new CompareTool().compareByContent(outPath, cmpPath, destinationFolder, diff)); } } diff --git a/pdfa/src/test/java/com/itextpdf/pdfa/PdfAStampingModeTest.java b/pdfa/src/test/java/com/itextpdf/pdfa/PdfAStampingModeTest.java index c7c3fc2f9e..18f5953b1c 100644 --- a/pdfa/src/test/java/com/itextpdf/pdfa/PdfAStampingModeTest.java +++ b/pdfa/src/test/java/com/itextpdf/pdfa/PdfAStampingModeTest.java @@ -28,22 +28,21 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfWriter; import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import com.itextpdf.test.pdfa.VeraPdfValidator; // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) import java.io.IOException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfAStampingModeTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/pdfa/"; public static final String destinationFolder = "./target/test/com/itextpdf/pdfa/PdfAStampingModeTest/"; public static final String cmpFolder = sourceFolder + "cmp/PdfAStampingModeTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } @@ -57,9 +56,9 @@ public void pdfA1FieldStampingModeTest01() throws IOException, InterruptedExcept pdfDoc.close(); CompareTool compareTool = new CompareTool(); - Assert.assertNull(compareTool.compareByContent(destinationFolder + fileName, cmpFolder + "cmp_" + fileName, destinationFolder, "diff_")); - Assert.assertNull(compareTool.compareXmp(destinationFolder + fileName, cmpFolder + "cmp_" + fileName, true)); - Assert.assertNull(new VeraPdfValidator().validate(destinationFolder + fileName)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNull(compareTool.compareByContent(destinationFolder + fileName, cmpFolder + "cmp_" + fileName, destinationFolder, "diff_")); + Assertions.assertNull(compareTool.compareXmp(destinationFolder + fileName, cmpFolder + "cmp_" + fileName, true)); + Assertions.assertNull(new VeraPdfValidator().validate(destinationFolder + fileName)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) } @Test @@ -71,8 +70,8 @@ public void pdfA2FieldStampingModeTest01() throws IOException, InterruptedExcept pdfDoc.close(); CompareTool compareTool = new CompareTool(); - Assert.assertNull(compareTool.compareByContent(destinationFolder + fileName, cmpFolder + "cmp_" + fileName, destinationFolder, "diff_")); - Assert.assertNull(compareTool.compareXmp(destinationFolder + fileName, cmpFolder + "cmp_" + fileName, true)); - Assert.assertNull(new VeraPdfValidator().validate(destinationFolder + fileName)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNull(compareTool.compareByContent(destinationFolder + fileName, cmpFolder + "cmp_" + fileName, destinationFolder, "diff_")); + Assertions.assertNull(compareTool.compareXmp(destinationFolder + fileName, cmpFolder + "cmp_" + fileName, true)); + Assertions.assertNull(new VeraPdfValidator().validate(destinationFolder + fileName)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) } } diff --git a/pdfa/src/test/java/com/itextpdf/pdfa/PdfATransparencyCheckTest.java b/pdfa/src/test/java/com/itextpdf/pdfa/PdfATransparencyCheckTest.java index 96481323a4..9cfa4126f6 100644 --- a/pdfa/src/test/java/com/itextpdf/pdfa/PdfATransparencyCheckTest.java +++ b/pdfa/src/test/java/com/itextpdf/pdfa/PdfATransparencyCheckTest.java @@ -28,7 +28,7 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.font.PdfFontFactory; import com.itextpdf.kernel.font.PdfFontFactory.EmbeddingStrategy; import com.itextpdf.kernel.geom.Rectangle; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfAConformance; import com.itextpdf.kernel.pdf.PdfArray; import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.kernel.pdf.PdfDocument; @@ -44,22 +44,21 @@ This file is part of the iText (R) project. import com.itextpdf.pdfa.exceptions.PdfAConformanceException; import com.itextpdf.pdfa.exceptions.PdfaExceptionMessageConstant; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; +import static org.junit.jupiter.api.Assertions.fail; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfATransparencyCheckTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/pdfa/"; public static final String cmpFolder = "./src/test/resources/com/itextpdf/pdfa/cmp/PdfATransparencyCheckTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/pdfa/PdfATransparencyCheckTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } @@ -67,7 +66,7 @@ public static void beforeClass() { @Test public void textTransparencyNoOutputIntentTest() throws IOException { PdfWriter writer = new PdfWriter(new java.io.ByteArrayOutputStream()); - PdfDocument pdfDocument = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_3B, null); + PdfDocument pdfDocument = new PdfADocument(writer, PdfAConformance.PDF_A_3B, null); PdfFont font = PdfFontFactory.createFont(sourceFolder + "FreeSans.ttf", "Identity-H", EmbeddingStrategy.FORCE_EMBEDDED); @@ -86,8 +85,8 @@ public void textTransparencyNoOutputIntentTest() throws IOException { .endText() .restoreState(); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> pdfDocument.close()); - Assert.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.THE_DOCUMENT_DOES_NOT_CONTAIN_A_PDFA_OUTPUTINTENT_BUT_PAGE_CONTAINS_TRANSPARENCY_AND_DOES_NOT_CONTAIN_BLENDING_COLOR_SPACE), + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfDocument.close()); + Assertions.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.THE_DOCUMENT_DOES_NOT_CONTAIN_A_PDFA_OUTPUTINTENT_BUT_PAGE_CONTAINS_TRANSPARENCY_AND_DOES_NOT_CONTAIN_BLENDING_COLOR_SPACE), e.getMessage()); } @@ -96,7 +95,7 @@ public void transparentTextWithGroupColorSpaceTest() throws IOException, Interru String outPdf = destinationFolder + "transparencyAndCS.pdf"; String cmpPdf = cmpFolder + "cmp_transparencyAndCS.pdf"; - PdfDocument pdfDocument = new PdfADocument(new PdfWriter(outPdf), PdfAConformanceLevel.PDF_A_3B, null); + PdfDocument pdfDocument = new PdfADocument(new PdfWriter(outPdf), PdfAConformance.PDF_A_3B, null); PdfFont font = PdfFontFactory.createFont(sourceFolder + "FreeSans.ttf", "Identity-H", EmbeddingStrategy.FORCE_EMBEDDED); @@ -137,7 +136,7 @@ public void transparentTextWithGroupColorSpaceTest() throws IOException, Interru @Test public void imageTransparencyTest() throws IOException { - PdfDocument pdfDoc = new PdfADocument(new PdfWriter(new java.io.ByteArrayOutputStream()), PdfAConformanceLevel.PDF_A_3B, null); + PdfDocument pdfDoc = new PdfADocument(new PdfWriter(new java.io.ByteArrayOutputStream()), PdfAConformance.PDF_A_3B, null); PdfPage page = pdfDoc.addNewPage(); PdfCanvas canvas = new PdfCanvas(page); @@ -149,15 +148,15 @@ public void imageTransparencyTest() throws IOException { new Rectangle(0, 0, page.getPageSize().getWidth() / 2, page.getPageSize().getHeight() / 2), false); canvas.restoreState(); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> pdfDoc.close()); - Assert.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.THE_DOCUMENT_DOES_NOT_CONTAIN_A_PDFA_OUTPUTINTENT_BUT_PAGE_CONTAINS_TRANSPARENCY_AND_DOES_NOT_CONTAIN_BLENDING_COLOR_SPACE), + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfDoc.close()); + Assertions.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.THE_DOCUMENT_DOES_NOT_CONTAIN_A_PDFA_OUTPUTINTENT_BUT_PAGE_CONTAINS_TRANSPARENCY_AND_DOES_NOT_CONTAIN_BLENDING_COLOR_SPACE), e.getMessage()); } @Test public void nestedXObjectWithTransparencyTest() { PdfWriter writer = new PdfWriter(new java.io.ByteArrayOutputStream()); - PdfDocument pdfDocument = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_3B, null); + PdfDocument pdfDocument = new PdfADocument(writer, PdfAConformance.PDF_A_3B, null); PdfFormXObject form1 = new PdfFormXObject(new Rectangle(0, 0, 50, 50)); PdfCanvas canvas1 = new PdfCanvas(form1, pdfDocument); canvas1.saveState(); @@ -185,8 +184,8 @@ public void nestedXObjectWithTransparencyTest() { canvas.addXObjectAt(form, 0, 0); canvas.release(); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> pdfDocument.close()); - Assert.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.THE_DOCUMENT_DOES_NOT_CONTAIN_A_PDFA_OUTPUTINTENT_BUT_PAGE_CONTAINS_TRANSPARENCY_AND_DOES_NOT_CONTAIN_BLENDING_COLOR_SPACE), + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfDocument.close()); + Assertions.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.THE_DOCUMENT_DOES_NOT_CONTAIN_A_PDFA_OUTPUTINTENT_BUT_PAGE_CONTAINS_TRANSPARENCY_AND_DOES_NOT_CONTAIN_BLENDING_COLOR_SPACE), e.getMessage()); } @@ -195,7 +194,7 @@ public void testTransparencyObjectsAbsence() throws IOException, InterruptedExce String outPdf = destinationFolder + "transparencyObjectsAbsence.pdf"; String cmpPdf = cmpFolder + "cmp_transparencyObjectsAbsence.pdf"; - PdfDocument pdfDocument = new PdfADocument(new PdfWriter(outPdf), PdfAConformanceLevel.PDF_A_3B, null); + PdfDocument pdfDocument = new PdfADocument(new PdfWriter(outPdf), PdfAConformance.PDF_A_3B, null); PdfPage page = pdfDocument.addNewPage(); PdfFont font = PdfFontFactory.createFont(sourceFolder + "FreeSans.ttf", "Identity-H", EmbeddingStrategy.FORCE_EMBEDDED); diff --git a/pdfa/src/test/java/com/itextpdf/pdfa/PdfAXmpTest.java b/pdfa/src/test/java/com/itextpdf/pdfa/PdfAXmpTest.java index b88f3d69b8..59e50f4192 100644 --- a/pdfa/src/test/java/com/itextpdf/pdfa/PdfAXmpTest.java +++ b/pdfa/src/test/java/com/itextpdf/pdfa/PdfAXmpTest.java @@ -24,11 +24,12 @@ This file is part of the iText (R) project. import com.itextpdf.commons.utils.FileUtil; import com.itextpdf.io.source.ByteArrayOutputStream; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfAConformance; import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfOutputIntent; import com.itextpdf.kernel.pdf.PdfReader; import com.itextpdf.kernel.pdf.PdfString; +import com.itextpdf.kernel.pdf.PdfUAConformance; import com.itextpdf.kernel.pdf.PdfViewerPreferences; import com.itextpdf.kernel.pdf.PdfWriter; import com.itextpdf.kernel.pdf.WriterProperties; @@ -40,26 +41,25 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.xmp.options.PropertyOptions; import com.itextpdf.kernel.xmp.options.SerializeOptions; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.nio.charset.StandardCharsets; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfAXmpTest extends ExtendedITextTest { public static final String cmpFolder = "./src/test/resources/com/itextpdf/pdfa/cmp/PdfAXmpTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/pdfa/PdfAXmpTest/"; public static final String sourceFolder = "./src/test/resources/com/itextpdf/pdfa/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(destinationFolder); } @@ -71,7 +71,7 @@ public void keywordsInfoTestPdfA1b() throws IOException, InterruptedException { InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - PdfADocument doc = new PdfADocument(new PdfWriter(outFile), PdfAConformanceLevel.PDF_A_1B, outputIntent); + PdfADocument doc = new PdfADocument(new PdfWriter(outFile), PdfAConformance.PDF_A_1B, outputIntent); doc.addNewPage(); doc.getDocumentInfo().setKeywords("key1, key2 , key3;key4,key5"); @@ -79,9 +79,9 @@ public void keywordsInfoTestPdfA1b() throws IOException, InterruptedException { doc.close(); CompareTool ct = new CompareTool(); - Assert.assertNull(ct.compareByContent(outFile, cmpFile, destinationFolder)); - Assert.assertNull(ct.compareDocumentInfo(outFile, cmpFile)); - Assert.assertNull(ct.compareXmp(outFile, cmpFile, true)); + Assertions.assertNull(ct.compareByContent(outFile, cmpFile, destinationFolder)); + Assertions.assertNull(ct.compareDocumentInfo(outFile, cmpFile)); + Assertions.assertNull(ct.compareXmp(outFile, cmpFile, true)); } @Test @@ -91,7 +91,7 @@ public void keywordsInfoTestPdfA2b() throws IOException, InterruptedException { InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - PdfADocument doc = new PdfADocument(new PdfWriter(outFile), PdfAConformanceLevel.PDF_A_2B, outputIntent); + PdfADocument doc = new PdfADocument(new PdfWriter(outFile), PdfAConformance.PDF_A_2B, outputIntent); doc.addNewPage(); doc.getDocumentInfo().setKeywords("key1, key2 , key3;key4,key5"); @@ -99,27 +99,27 @@ public void keywordsInfoTestPdfA2b() throws IOException, InterruptedException { doc.close(); CompareTool ct = new CompareTool(); - Assert.assertNull(ct.compareByContent(outFile, cmpFile, destinationFolder)); - Assert.assertNull(ct.compareDocumentInfo(outFile, cmpFile)); - Assert.assertNull(ct.compareXmp(outFile, cmpFile, true)); + Assertions.assertNull(ct.compareByContent(outFile, cmpFile, destinationFolder)); + Assertions.assertNull(ct.compareDocumentInfo(outFile, cmpFile)); + Assertions.assertNull(ct.compareXmp(outFile, cmpFile, true)); } @Test public void saveAndReadDocumentWithCanonicalXmpMetadata() throws IOException, XMPException { String outFile = destinationFolder + "saveAndReadDocumentWithCanonicalXmpMetadata.pdf"; String cmpFile = cmpFolder + "cmp_saveAndReadDocumentWithCanonicalXmpMetadata.pdf"; - PdfAConformanceLevel conformanceLevel = PdfAConformanceLevel.PDF_A_2B; + PdfAConformance conformance = PdfAConformance.PDF_A_2B; PdfOutputIntent outputIntent; try (InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm")) { outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); } - try (PdfADocument doc = new PdfADocument(new PdfWriter(outFile), conformanceLevel, outputIntent)) { + try (PdfADocument doc = new PdfADocument(new PdfWriter(outFile), conformance, outputIntent)) { doc.addNewPage(); XMPMeta xmp = XMPMetaFactory.create(); - xmp.setProperty(XMPConst.NS_PDFA_ID, XMPConst.PART, conformanceLevel.getPart(), new PropertyOptions().setSchemaNode(true)); - xmp.setProperty(XMPConst.NS_PDFA_ID, XMPConst.CONFORMANCE, conformanceLevel.getConformance(), new PropertyOptions().setSchemaNode(true)); + xmp.setProperty(XMPConst.NS_PDFA_ID, XMPConst.PART, conformance.getPart(), new PropertyOptions().setSchemaNode(true)); + xmp.setProperty(XMPConst.NS_PDFA_ID, XMPConst.CONFORMANCE, conformance.getLevel(), new PropertyOptions().setSchemaNode(true)); SerializeOptions options = new SerializeOptions().setUseCanonicalFormat(true).setUseCompactFormat(false); doc.setXmpMetadata(xmp, options); doc.setTagged(); @@ -127,11 +127,11 @@ public void saveAndReadDocumentWithCanonicalXmpMetadata() throws IOException, XM // Closing document and reopening it to flush it XMP metadata ModifyDate try (PdfDocument doc = new PdfDocument(new PdfReader(outFile)); PdfDocument cmpDoc = new PdfDocument(new PdfReader(cmpFile))) { - byte[] rdf = doc.getXmpMetadata(); - byte[] expectedRdf = cmpDoc.getXmpMetadata(); + byte[] rdf = doc.getXmpMetadataBytes(); + byte[] expectedRdf = cmpDoc.getXmpMetadataBytes(); // Comparing angle brackets, since it's the main difference between canonical and compact format. - Assert.assertEquals(count(expectedRdf, (byte)'<'), count(rdf, (byte)'<')); - Assert.assertNull(new CompareTool().compareXmp(cmpFile, outFile, true)); + Assertions.assertEquals(count(expectedRdf, (byte)'<'), count(rdf, (byte)'<')); + Assertions.assertNull(new CompareTool().compareXmp(cmpFile, outFile, true)); } } @@ -146,7 +146,7 @@ public void testPdfUAExtensionMetadata() throws IOException { } CompareTool ct = new CompareTool(); - Assert.assertNull(ct.compareXmp(outFile, cmpFile, true)); + Assertions.assertNull(ct.compareXmp(outFile, cmpFile, true)); } @@ -157,16 +157,15 @@ public void testPdfUAIdSchemaNameSpaceUriIsNotText() throws IOException { // check whether the pdfuaid NS URI was properly encoded as a URI with rdf:resource PdfDocument readDoc = new PdfDocument(new PdfReader(new ByteArrayInputStream(baos.toByteArray()))); - String xmpString = new String(readDoc.getXmpMetadata(), StandardCharsets.UTF_8); - Assert.assertTrue( - "Did not find expected namespaceURI definition", - xmpString.contains("") - ); + String xmpString = new String(readDoc.getXmpMetadataBytes(), StandardCharsets.UTF_8); + Assertions.assertTrue( + xmpString.contains(""), + "Did not find expected namespaceURI definition"); } private void generatePdfAWithUA(OutputStream os) throws IOException { - WriterProperties wp = new WriterProperties().addUAXmpMetadata(); + WriterProperties wp = new WriterProperties().addPdfUaXmpMetadata(PdfUAConformance.PDF_UA_1); try (PdfWriter w = new PdfWriter(os, wp)) { PdfOutputIntent outputIntent; try (InputStream is = FileUtil.getInputStreamForFile(sourceFolder + "sRGB Color Space Profile.icm")) { @@ -177,7 +176,8 @@ private void generatePdfAWithUA(OutputStream os) throws IOException { is ); } - PdfDocument pdfDoc = new PdfADocument(w, PdfAConformanceLevel.PDF_A_2A, outputIntent).setTagged(); + PdfDocument pdfDoc = new PdfADocument(w, PdfAConformance.PDF_A_2A, outputIntent); + pdfDoc.setTagged(); pdfDoc.getDocumentInfo().setTitle("Test document"); pdfDoc.getCatalog().setViewerPreferences(new PdfViewerPreferences().setDisplayDocTitle(true)); pdfDoc.getCatalog().setLang(new PdfString("en")); diff --git a/pdfa/src/test/java/com/itextpdf/pdfa/checker/PdfA1CheckerTest.java b/pdfa/src/test/java/com/itextpdf/pdfa/checker/PdfA1CheckerTest.java index 4b27a076c0..be8d2f73f0 100644 --- a/pdfa/src/test/java/com/itextpdf/pdfa/checker/PdfA1CheckerTest.java +++ b/pdfa/src/test/java/com/itextpdf/pdfa/checker/PdfA1CheckerTest.java @@ -25,31 +25,29 @@ This file is part of the iText (R) project. import com.itextpdf.commons.utils.MessageFormatUtil; import com.itextpdf.kernel.colors.Color; import com.itextpdf.kernel.colors.PatternColor; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfAConformance; import com.itextpdf.kernel.pdf.PdfArray; import com.itextpdf.kernel.pdf.PdfBoolean; import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.kernel.pdf.PdfName; -import com.itextpdf.kernel.pdf.PdfNumber; import com.itextpdf.kernel.pdf.PdfStream; import com.itextpdf.kernel.pdf.colorspace.PdfPattern; import com.itextpdf.pdfa.exceptions.PdfAConformanceException; import com.itextpdf.pdfa.exceptions.PdfaExceptionMessageConstant; import com.itextpdf.test.AssertUtil; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfA1CheckerTest extends ExtendedITextTest { - private PdfA1Checker pdfA1Checker = new PdfA1Checker(PdfAConformanceLevel.PDF_A_1B); + private PdfA1Checker pdfA1Checker = new PdfA1Checker(PdfAConformance.PDF_A_1B); - @Before + @BeforeEach public void before() { pdfA1Checker.setFullCheckMode(true); } @@ -59,10 +57,10 @@ public void checkCatalogDictionaryWithoutAAEntry() { PdfDictionary catalog = new PdfDictionary(); catalog.put(PdfName.AA, new PdfDictionary()); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA1Checker.checkCatalogValidEntries(catalog) ); - Assert.assertEquals(PdfaExceptionMessageConstant.A_CATALOG_DICTIONARY_SHALL_NOT_CONTAIN_AA_ENTRY, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.A_CATALOG_DICTIONARY_SHALL_NOT_CONTAIN_AA_ENTRY, e.getMessage()); } @Test @@ -70,10 +68,10 @@ public void checkCatalogDictionaryWithoutOCPropertiesEntry() { PdfDictionary catalog = new PdfDictionary(); catalog.put(PdfName.OCProperties, new PdfDictionary()); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA1Checker.checkCatalogValidEntries(catalog) ); - Assert.assertEquals(PdfaExceptionMessageConstant.A_CATALOG_DICTIONARY_SHALL_NOT_CONTAIN_OCPROPERTIES_KEY, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.A_CATALOG_DICTIONARY_SHALL_NOT_CONTAIN_OCPROPERTIES_KEY, e.getMessage()); } @Test @@ -84,10 +82,10 @@ public void checkCatalogDictionaryWithoutEmbeddedFiles() { PdfDictionary catalog = new PdfDictionary(); catalog.put(PdfName.Names, names); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA1Checker.checkCatalogValidEntries(catalog) ); - Assert.assertEquals(PdfaExceptionMessageConstant.A_NAME_DICTIONARY_SHALL_NOT_CONTAIN_THE_EMBEDDED_FILES_KEY, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.A_NAME_DICTIONARY_SHALL_NOT_CONTAIN_THE_EMBEDDED_FILES_KEY, e.getMessage()); } @Test @@ -113,7 +111,7 @@ public void deprecatedCheckColorShadingTest() { Color color = new PatternColor(pattern); AssertUtil.doesNotThrow(() -> { - pdfA1Checker.checkColor(color, new PdfDictionary(), true, null); + pdfA1Checker.checkColor(null, color, new PdfDictionary(), true, null); }); } @@ -121,7 +119,7 @@ public void deprecatedCheckColorShadingTest() { public void checkSignatureTest() { PdfDictionary dict = new PdfDictionary(); pdfA1Checker.checkSignature(dict); - Assert.assertTrue(pdfA1Checker.objectIsChecked(dict)); + Assertions.assertTrue(pdfA1Checker.isPdfObjectReadyToFlush(dict)); } @Test @@ -134,10 +132,10 @@ public void checkSignatureTypeTest() { public void checkLZWDecodeInInlineImage() { PdfStream stream = new PdfStream(); stream.put(PdfName.Filter, PdfName.LZWDecode); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA1Checker.checkInlineImage(stream, null) ); - Assert.assertEquals(PdfaExceptionMessageConstant.LZWDECODE_FILTER_IS_NOT_PERMITTED, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.LZWDECODE_FILTER_IS_NOT_PERMITTED, e.getMessage()); } @Test @@ -146,10 +144,10 @@ public void checkLZWDecodeArrayInInlineImage() { PdfArray array = new PdfArray(); array.add(PdfName.LZWDecode); stream.put(PdfName.Filter, array); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA1Checker.checkInlineImage(stream, null) ); - Assert.assertEquals(PdfaExceptionMessageConstant.LZWDECODE_FILTER_IS_NOT_PERMITTED, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.LZWDECODE_FILTER_IS_NOT_PERMITTED, e.getMessage()); } @Test @@ -164,89 +162,89 @@ public void checkEmptyImageTwiceTest() { public void checkImageWithAlternateTest() { PdfStream image = new PdfStream(); image.put(PdfName.Alternates, PdfName.Identity); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA1Checker.checkImage(image, null) ); - Assert.assertEquals(PdfaExceptionMessageConstant.AN_IMAGE_DICTIONARY_SHALL_NOT_CONTAIN_ALTERNATES_KEY, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.AN_IMAGE_DICTIONARY_SHALL_NOT_CONTAIN_ALTERNATES_KEY, e.getMessage()); } @Test public void checkImageWithOPITest() { PdfStream image = new PdfStream(); image.put(PdfName.OPI, PdfName.Identity); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA1Checker.checkImage(image, null) ); - Assert.assertEquals(PdfaExceptionMessageConstant.AN_IMAGE_DICTIONARY_SHALL_NOT_CONTAIN_OPI_KEY, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.AN_IMAGE_DICTIONARY_SHALL_NOT_CONTAIN_OPI_KEY, e.getMessage()); } @Test public void checkImageWithInterpolateTest() { PdfStream image = new PdfStream(); image.put(PdfName.Interpolate, new PdfBoolean(true)); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA1Checker.checkImage(image, null) ); - Assert.assertEquals(PdfaExceptionMessageConstant.THE_VALUE_OF_INTERPOLATE_KEY_SHALL_BE_FALSE, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.THE_VALUE_OF_INTERPOLATE_KEY_SHALL_BE_FALSE, e.getMessage()); } @Test public void checkImageWithSMaskTest() { PdfStream image = new PdfStream(); image.put(PdfName.SMask, PdfName.Identity); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA1Checker.checkImage(image, null) ); - Assert.assertEquals(PdfaExceptionMessageConstant.THE_SMASK_KEY_IS_NOT_ALLOWED_IN_XOBJECTS, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.THE_SMASK_KEY_IS_NOT_ALLOWED_IN_XOBJECTS, e.getMessage()); } @Test public void checkFormXObjectWithOPITest() { PdfStream form = new PdfStream(); form.put(PdfName.OPI, PdfName.Identity); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA1Checker.checkFormXObject(form) ); - Assert.assertEquals(PdfaExceptionMessageConstant.A_FORM_XOBJECT_DICTIONARY_SHALL_NOT_CONTAIN_OPI_KEY, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.A_FORM_XOBJECT_DICTIONARY_SHALL_NOT_CONTAIN_OPI_KEY, e.getMessage()); } @Test public void checkFormXObjectWithPSTest() { PdfStream form = new PdfStream(); form.put(PdfName.PS, PdfName.Identity); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA1Checker.checkFormXObject(form) ); - Assert.assertEquals(PdfaExceptionMessageConstant.A_FORM_XOBJECT_DICTIONARY_SHALL_NOT_CONTAIN_PS_KEY, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.A_FORM_XOBJECT_DICTIONARY_SHALL_NOT_CONTAIN_PS_KEY, e.getMessage()); } @Test public void checkFormXObjectWithSubtype2PSTest() { PdfStream form = new PdfStream(); form.put(PdfName.Subtype2, PdfName.PS); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA1Checker.checkFormXObject(form) ); - Assert.assertEquals(PdfaExceptionMessageConstant.A_FORM_XOBJECT_DICTIONARY_SHALL_NOT_CONTAIN_SUBTYPE2_KEY_WITH_A_VALUE_OF_PS, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.A_FORM_XOBJECT_DICTIONARY_SHALL_NOT_CONTAIN_SUBTYPE2_KEY_WITH_A_VALUE_OF_PS, e.getMessage()); } @Test public void checkFormXObjectWithSMaskTest() { PdfStream form = new PdfStream(); form.put(PdfName.SMask, PdfName.Identity); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA1Checker.checkFormXObject(form) ); - Assert.assertEquals(PdfaExceptionMessageConstant.THE_SMASK_KEY_IS_NOT_ALLOWED_IN_XOBJECTS, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.THE_SMASK_KEY_IS_NOT_ALLOWED_IN_XOBJECTS, e.getMessage()); } @Test public void checkCatalogContainsMetadataTest() { PdfDictionary catalog = new PdfDictionary(); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA1Checker.checkMetaData(catalog) ); - Assert.assertEquals(PdfaExceptionMessageConstant.A_CATALOG_DICTIONARY_SHALL_CONTAIN_METADATA_ENTRY, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.A_CATALOG_DICTIONARY_SHALL_CONTAIN_METADATA_ENTRY, e.getMessage()); } @Test @@ -260,10 +258,10 @@ public void checkOutputIntentsTest() { array.add(dictionary); array.add(dictionary2); catalog.put(PdfName.OutputIntents, array); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA1Checker.checkOutputIntents(catalog) ); - Assert.assertEquals(PdfaExceptionMessageConstant.IF_OUTPUTINTENTS_ARRAY_HAS_MORE_THAN_ONE_ENTRY_WITH_DESTOUTPUTPROFILE_KEY_THE_SAME_INDIRECT_OBJECT_SHALL_BE_USED_AS_THE_VALUE_OF_THAT_OBJECT, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.IF_OUTPUTINTENTS_ARRAY_HAS_MORE_THAN_ONE_ENTRY_WITH_DESTOUTPUTPROFILE_KEY_THE_SAME_INDIRECT_OBJECT_SHALL_BE_USED_AS_THE_VALUE_OF_THAT_OBJECT, e.getMessage()); //nothing to check, expecting that no error is thrown } @@ -271,10 +269,10 @@ public void checkOutputIntentsTest() { public void checkLZWDecodeInPdfStreamTest() { PdfStream stream = new PdfStream(); stream.put(PdfName.Filter, PdfName.LZWDecode); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA1Checker.checkPdfStream(stream) ); - Assert.assertEquals(PdfaExceptionMessageConstant.LZWDECODE_FILTER_IS_NOT_PERMITTED, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.LZWDECODE_FILTER_IS_NOT_PERMITTED, e.getMessage()); } @Test @@ -283,10 +281,10 @@ public void checkLZWDecodeInPdfStreamArrayTest() { PdfArray array = new PdfArray(); array.add(PdfName.LZWDecode); stream.put(PdfName.Filter, array); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA1Checker.checkPdfStream(stream) ); - Assert.assertEquals(PdfaExceptionMessageConstant.LZWDECODE_FILTER_IS_NOT_PERMITTED, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.LZWDECODE_FILTER_IS_NOT_PERMITTED, e.getMessage()); } @Test @@ -298,19 +296,19 @@ public void checkFileSpecTest() { @Test public void checkEmptyAnnotationTest() { PdfDictionary annotation = new PdfDictionary(); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA1Checker.checkAnnotation(annotation) ); - Assert.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.ANNOTATION_TYPE_0_IS_NOT_PERMITTED, "null"), e.getMessage()); + Assertions.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.ANNOTATION_TYPE_0_IS_NOT_PERMITTED, "null"), e.getMessage()); } @Test public void checkAnnotationWithoutFKeyTest() { PdfDictionary annotation = new PdfDictionary(); annotation.put(PdfName.Subtype, PdfName.Identity); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA1Checker.checkAnnotation(annotation) ); - Assert.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.AN_ANNOTATION_DICTIONARY_SHALL_CONTAIN_THE_F_KEY, "null"), e.getMessage()); + Assertions.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.AN_ANNOTATION_DICTIONARY_SHALL_CONTAIN_THE_F_KEY, "null"), e.getMessage()); } } diff --git a/pdfa/src/test/java/com/itextpdf/pdfa/checker/PdfA1ImplementationLimitsCheckerTest.java b/pdfa/src/test/java/com/itextpdf/pdfa/checker/PdfA1ImplementationLimitsCheckerTest.java index 5056afe63a..04fde5096d 100644 --- a/pdfa/src/test/java/com/itextpdf/pdfa/checker/PdfA1ImplementationLimitsCheckerTest.java +++ b/pdfa/src/test/java/com/itextpdf/pdfa/checker/PdfA1ImplementationLimitsCheckerTest.java @@ -26,7 +26,7 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.colors.PatternColor; import com.itextpdf.kernel.font.PdfFont; import com.itextpdf.kernel.font.PdfFontFactory; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfAConformance; import com.itextpdf.kernel.pdf.PdfArray; import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.kernel.pdf.PdfName; @@ -46,23 +46,22 @@ This file is part of the iText (R) project. import com.itextpdf.pdfa.exceptions.PdfAConformanceException; import com.itextpdf.pdfa.exceptions.PdfaExceptionMessageConstant; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfA1ImplementationLimitsCheckerTest extends ExtendedITextTest { - private PdfA1Checker pdfA1Checker = new PdfA1Checker(PdfAConformanceLevel.PDF_A_1B); + private PdfA1Checker pdfA1Checker = new PdfA1Checker(PdfAConformance.PDF_A_1B); private final static int MAX_ARRAY_CAPACITY = 8191; private final static int MAX_DICTIONARY_CAPACITY = 4095; - @Before + @BeforeEach public void before() { pdfA1Checker.setFullCheckMode(true); } @@ -77,17 +76,17 @@ public void validObjectsTest() { final long minIntegerValue = pdfA1Checker.getMinIntegerValue(); final double maxRealValue = pdfA1Checker.getMaxRealValue(); - Assert.assertEquals(65535, maxStringLength); - Assert.assertEquals(127, maxNameLength); + Assertions.assertEquals(65535, maxStringLength); + Assertions.assertEquals(127, maxNameLength); PdfString longString = PdfACheckerTestUtils.getLongString(maxStringLength); PdfName longName = PdfACheckerTestUtils.getLongName(maxNameLength); PdfArray longArray = PdfACheckerTestUtils.getLongArray(maxArrayCapacity); PdfDictionary longDictionary = PdfACheckerTestUtils.getLongDictionary(maxDictionaryCapacity); - Assert.assertEquals(2147483647, maxIntegerValue); - Assert.assertEquals(-2147483648, minIntegerValue); - Assert.assertEquals(32767, maxRealValue, 0.001); + Assertions.assertEquals(2147483647, maxIntegerValue); + Assertions.assertEquals(-2147483648, minIntegerValue); + Assertions.assertEquals(32767, maxRealValue, 0.001); PdfNumber largeInteger = new PdfNumber(maxIntegerValue); PdfNumber negativeInteger = new PdfNumber(minIntegerValue); @@ -126,10 +125,10 @@ public void independentLongStringTest() { // An exception should be thrown as provided String is longer then // it is allowed per specification - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA1Checker.checkPdfObject(longString) ); - Assert.assertEquals(PdfaExceptionMessageConstant.PDF_STRING_IS_TOO_LONG, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.PDF_STRING_IS_TOO_LONG, e.getMessage()); } @Test @@ -138,10 +137,10 @@ public void independentLongNameTest() { // An exception should be thrown as provided name is longer then // it is allowed per specification - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA1Checker.checkPdfObject(longName) ); - Assert.assertEquals(PdfaExceptionMessageConstant.PDF_NAME_IS_TOO_LONG, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.PDF_NAME_IS_TOO_LONG, e.getMessage()); } @Test @@ -150,10 +149,10 @@ public void independentLargeIntegerTest() { // An exception should be thrown as provided integer is larger then // it is allowed per specification - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA1Checker.checkPdfObject(largeNumber) ); - Assert.assertEquals(PdfaExceptionMessageConstant.INTEGER_NUMBER_IS_OUT_OF_RANGE, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.INTEGER_NUMBER_IS_OUT_OF_RANGE, e.getMessage()); } @Test @@ -162,10 +161,10 @@ public void independentLargeNegativeIntegerTest() { // An exception should be thrown as provided integer is smaller then // it is allowed per specification - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA1Checker.checkPdfObject(largeNumber) ); - Assert.assertEquals(PdfaExceptionMessageConstant.INTEGER_NUMBER_IS_OUT_OF_RANGE, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.INTEGER_NUMBER_IS_OUT_OF_RANGE, e.getMessage()); } @Test @@ -183,10 +182,10 @@ public void independentLongArrayTest() { // An exception should be thrown as provided array has more elements then // it is allowed per specification - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA1Checker.checkPdfObject(longArray) ); - Assert.assertEquals(PdfaExceptionMessageConstant.MAXIMUM_ARRAY_CAPACITY_IS_EXCEEDED, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.MAXIMUM_ARRAY_CAPACITY_IS_EXCEEDED, e.getMessage()); } @Test @@ -195,10 +194,10 @@ public void independentLongDictionaryTest() { // An exception should be thrown as provided dictionary has more entries // then it is allowed per specification - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA1Checker.checkPdfObject(longDictionary) ); - Assert.assertEquals(PdfaExceptionMessageConstant.MAXIMUM_DICTIONARY_CAPACITY_IS_EXCEEDED, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.MAXIMUM_DICTIONARY_CAPACITY_IS_EXCEEDED, e.getMessage()); } @Test @@ -207,10 +206,10 @@ public void independentStreamWithLongDictionaryTest() { // An exception should be thrown as dictionary of the stream has more entries // then it is allowed per specification - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA1Checker.checkPdfObject(longStream) ); - Assert.assertEquals(PdfaExceptionMessageConstant.MAXIMUM_DICTIONARY_CAPACITY_IS_EXCEEDED, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.MAXIMUM_DICTIONARY_CAPACITY_IS_EXCEEDED, e.getMessage()); } @Test @@ -219,10 +218,10 @@ public void longStringInDictionaryTest() { // An exception should be thrown as dictionary contains value which is longer then // it is allowed per specification - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> checkInDictionary(longString) ); - Assert.assertEquals(PdfaExceptionMessageConstant.PDF_STRING_IS_TOO_LONG, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.PDF_STRING_IS_TOO_LONG, e.getMessage()); } @Test @@ -236,10 +235,10 @@ public void longNameAsKeyInDictionaryTest() { // An exception should be thrown as dictionary contains key which is longer then // it is allowed per specification - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA1Checker.checkPdfObject(dict) ); - Assert.assertEquals(PdfaExceptionMessageConstant.PDF_NAME_IS_TOO_LONG, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.PDF_NAME_IS_TOO_LONG, e.getMessage()); } @Test @@ -247,10 +246,10 @@ public void longStringInArrayTest() { PdfString longString = buildLongString(); // An exception should be thrown as one element is longer then // it is allowed per specification - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> checkInArray(longString) ); - Assert.assertEquals(PdfaExceptionMessageConstant.PDF_STRING_IS_TOO_LONG, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.PDF_STRING_IS_TOO_LONG, e.getMessage()); } @Test @@ -259,10 +258,10 @@ public void longStringInContentStreamTest() { // An exception should be thrown as content stream has a string which // is longer then it is allowed per specification - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> checkInContentStream(longString) ); - Assert.assertEquals(PdfaExceptionMessageConstant.PDF_STRING_IS_TOO_LONG, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.PDF_STRING_IS_TOO_LONG, e.getMessage()); } @Test @@ -271,10 +270,10 @@ public void longNameInContentStreamTest() { // An exception should be thrown as content stream has a name which // is longer then it is allowed per specification - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> checkInContentStream(longName) ); - Assert.assertEquals(PdfaExceptionMessageConstant.PDF_NAME_IS_TOO_LONG, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.PDF_NAME_IS_TOO_LONG, e.getMessage()); } @Test @@ -283,10 +282,10 @@ public void largeIntegerInContentStreamTest() { // An exception should be thrown as provided integer is larger then // it is allowed per specification - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> checkInContentStream(largeNumber) ); - Assert.assertEquals(PdfaExceptionMessageConstant.INTEGER_NUMBER_IS_OUT_OF_RANGE, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.INTEGER_NUMBER_IS_OUT_OF_RANGE, e.getMessage()); } @Test @@ -295,10 +294,10 @@ public void largeNegativeIntegerInContentStreamTest() { // An exception should be thrown as provided integer is smaller then // it is allowed per specification - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> checkInContentStream(largeNumber) ); - Assert.assertEquals(PdfaExceptionMessageConstant.INTEGER_NUMBER_IS_OUT_OF_RANGE, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.INTEGER_NUMBER_IS_OUT_OF_RANGE, e.getMessage()); } @Test @@ -317,10 +316,10 @@ public void LongArrayInContentStreamTest() { // An exception should be thrown as provided array has more elements then // it is allowed per specification - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> checkInContentStream(longArray) ); - Assert.assertEquals(PdfaExceptionMessageConstant.MAXIMUM_ARRAY_CAPACITY_IS_EXCEEDED, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.MAXIMUM_ARRAY_CAPACITY_IS_EXCEEDED, e.getMessage()); } @Test @@ -329,10 +328,10 @@ public void longDictionaryInContentStream() { // An exception should be thrown as provided dictionary has more entries // then it is allowed per specification - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> checkInContentStream(longDictionary) ); - Assert.assertEquals(PdfaExceptionMessageConstant.MAXIMUM_DICTIONARY_CAPACITY_IS_EXCEEDED, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.MAXIMUM_DICTIONARY_CAPACITY_IS_EXCEEDED, e.getMessage()); } @@ -369,10 +368,10 @@ public void longStringInArrayInContentStreamTest() { // An exception should be thrown as content stream has a string which // is longer then it is allowed per specification - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> checkInArrayInContentStream(longString) ); - Assert.assertEquals(PdfaExceptionMessageConstant.PDF_STRING_IS_TOO_LONG, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.PDF_STRING_IS_TOO_LONG, e.getMessage()); } @Test @@ -381,10 +380,10 @@ public void longStringInDictionaryInContentStreamTest() { // An exception should be thrown as content stream has a string which // is longer then it is allowed per specification - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> checkInDictionaryInContentStream(longString) ); - Assert.assertEquals(PdfaExceptionMessageConstant.PDF_STRING_IS_TOO_LONG, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.PDF_STRING_IS_TOO_LONG, e.getMessage()); } @Test @@ -398,10 +397,10 @@ public void longNameAsKeyInDictionaryInContentStreamTest() { // An exception should be thrown as content stream has a string which // is longer then it is allowed per specification - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> checkInContentStream(dict) ); - Assert.assertEquals(PdfaExceptionMessageConstant.PDF_NAME_IS_TOO_LONG, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.PDF_NAME_IS_TOO_LONG, e.getMessage()); } @Test @@ -410,10 +409,10 @@ public void longStringInComplexStructureTest() { // An exception should be thrown as there is a string element which // doesn't match the limitations provided in specification - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> checkInComplexStructure(longString) ); - Assert.assertEquals(PdfaExceptionMessageConstant.PDF_STRING_IS_TOO_LONG, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.PDF_STRING_IS_TOO_LONG, e.getMessage()); } @Test @@ -422,10 +421,10 @@ public void LongArrayInComplexStructureTest() { // An exception should be thrown as provided array has more elements then // it is allowed per specification - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> checkInComplexStructure(longArray) ); - Assert.assertEquals(PdfaExceptionMessageConstant.MAXIMUM_ARRAY_CAPACITY_IS_EXCEEDED, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.MAXIMUM_ARRAY_CAPACITY_IS_EXCEEDED, e.getMessage()); } @Test @@ -434,10 +433,10 @@ public void longDictionaryInComplexStructureTest() { // An exception should be thrown as provided dictionary has more entries // then it is allowed per specification - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> checkInComplexStructure(longDictionary) ); - Assert.assertEquals(PdfaExceptionMessageConstant.MAXIMUM_DICTIONARY_CAPACITY_IS_EXCEEDED, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.MAXIMUM_DICTIONARY_CAPACITY_IS_EXCEEDED, e.getMessage()); } @Test @@ -446,10 +445,10 @@ public void longStringInPdfFormXObjectTest() { // An exception should be thrown as form xobject content stream has a string which // is longer then it is allowed per specification - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> checkInFormXObject(longString) ); - Assert.assertEquals(PdfaExceptionMessageConstant.PDF_STRING_IS_TOO_LONG, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.PDF_STRING_IS_TOO_LONG, e.getMessage()); } @Test @@ -457,10 +456,10 @@ public void longStringInTilingPatternTest() { PdfString longString = buildLongString(); // An exception should be thrown as tiling pattern's content stream has a string which // is longer then it is allowed per specification - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> checkInTilingPattern(longString) ); - Assert.assertEquals(PdfaExceptionMessageConstant.PDF_STRING_IS_TOO_LONG, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.PDF_STRING_IS_TOO_LONG, e.getMessage()); } @Test @@ -477,18 +476,18 @@ public void longStringInType3FontTest() { PdfString longString = buildLongString(); // An exception should be thrown as content stream of type3 font has a string which // is longer then it is allowed per specification - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> checkInType3Font(longString) ); - Assert.assertEquals(PdfaExceptionMessageConstant.PDF_STRING_IS_TOO_LONG, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.PDF_STRING_IS_TOO_LONG, e.getMessage()); } @Test public void deviceNColorspaceWithMoreThan8Components() { - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> checkColorspace(buildDeviceNColorspace(10)) ); - Assert.assertEquals(PdfaExceptionMessageConstant.THE_NUMBER_OF_COLOR_COMPONENTS_IN_DEVICE_N_COLORSPACE_SHOULD_NOT_EXCEED, + Assertions.assertEquals(PdfaExceptionMessageConstant.THE_NUMBER_OF_COLOR_COMPONENTS_IN_DEVICE_N_COLORSPACE_SHOULD_NOT_EXCEED, e.getMessage()); } @@ -507,7 +506,7 @@ private PdfString buildLongString() { final int maxAllowedLength = pdfA1Checker.getMaxStringLength(); final int testLength = maxAllowedLength + 1; - Assert.assertEquals(65536, testLength); + Assertions.assertEquals(65536, testLength); return PdfACheckerTestUtils.getLongString(testLength); } @@ -517,7 +516,7 @@ private PdfName buildLongName() { final int maxAllowedLength = pdfA1Checker.getMaxNameLength(); final int testLength = maxAllowedLength + 1; - Assert.assertEquals(128, testLength); + Assertions.assertEquals(128, testLength); return PdfACheckerTestUtils.getLongName(testLength); } diff --git a/pdfa/src/test/java/com/itextpdf/pdfa/checker/PdfA2CheckerGlyphsTest.java b/pdfa/src/test/java/com/itextpdf/pdfa/checker/PdfA2CheckerGlyphsTest.java index d0916a205e..0a1b455390 100644 --- a/pdfa/src/test/java/com/itextpdf/pdfa/checker/PdfA2CheckerGlyphsTest.java +++ b/pdfa/src/test/java/com/itextpdf/pdfa/checker/PdfA2CheckerGlyphsTest.java @@ -25,7 +25,7 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.font.PdfFont; import com.itextpdf.kernel.font.PdfFontFactory; import com.itextpdf.kernel.geom.Rectangle; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfAConformance; import com.itextpdf.kernel.pdf.PdfArray; import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.kernel.pdf.PdfDocument; @@ -37,21 +37,20 @@ This file is part of the iText (R) project. import com.itextpdf.pdfa.exceptions.PdfAConformanceException; import com.itextpdf.pdfa.exceptions.PdfaExceptionMessageConstant; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.ByteArrayOutputStream; import java.io.IOException; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfA2CheckerGlyphsTest extends ExtendedITextTest { - private final PdfA2Checker pdfA2Checker = new PdfA2Checker(PdfAConformanceLevel.PDF_A_2B); + private final PdfA2Checker pdfA2Checker = new PdfA2Checker(PdfAConformance.PDF_A_2B); - @Before + @BeforeEach public void before() { pdfA2Checker.setFullCheckMode(true); } @@ -102,10 +101,10 @@ public void checkInvalidFontGlyphsTest() throws IOException { PdfFont font = createFontWithCharProcsAndEncodingDifferences(document, charProcs, differences); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA2Checker.checkFontGlyphs(font, null) ); - Assert.assertEquals(PdfaExceptionMessageConstant.A_FORM_XOBJECT_DICTIONARY_SHALL_NOT_CONTAIN_SUBTYPE2_KEY_WITH_A_VALUE_OF_PS, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.A_FORM_XOBJECT_DICTIONARY_SHALL_NOT_CONTAIN_SUBTYPE2_KEY_WITH_A_VALUE_OF_PS, e.getMessage()); } } diff --git a/pdfa/src/test/java/com/itextpdf/pdfa/checker/PdfA2CheckerTest.java b/pdfa/src/test/java/com/itextpdf/pdfa/checker/PdfA2CheckerTest.java index 3b5c93d452..b07fa90fb5 100644 --- a/pdfa/src/test/java/com/itextpdf/pdfa/checker/PdfA2CheckerTest.java +++ b/pdfa/src/test/java/com/itextpdf/pdfa/checker/PdfA2CheckerTest.java @@ -25,15 +25,18 @@ This file is part of the iText (R) project. import com.itextpdf.commons.utils.MessageFormatUtil; import com.itextpdf.kernel.colors.Color; import com.itextpdf.kernel.colors.PatternColor; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfAConformance; import com.itextpdf.kernel.pdf.PdfArray; import com.itextpdf.kernel.pdf.PdfBoolean; import com.itextpdf.kernel.pdf.PdfDictionary; +import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfName; import com.itextpdf.kernel.pdf.PdfNumber; import com.itextpdf.kernel.pdf.PdfStream; import com.itextpdf.kernel.pdf.PdfString; +import com.itextpdf.kernel.pdf.PdfWriter; import com.itextpdf.kernel.pdf.canvas.CanvasGraphicsState; +import com.itextpdf.kernel.pdf.canvas.PdfCanvas; import com.itextpdf.kernel.pdf.colorspace.PdfDeviceCs; import com.itextpdf.kernel.pdf.colorspace.PdfPattern; import com.itextpdf.kernel.pdf.colorspace.PdfSpecialCs; @@ -43,18 +46,18 @@ This file is part of the iText (R) project. import com.itextpdf.pdfa.exceptions.PdfaExceptionMessageConstant; import com.itextpdf.test.AssertUtil; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; +import java.io.ByteArrayOutputStream; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfA2CheckerTest extends ExtendedITextTest { - private PdfA2Checker pdfA2Checker = new PdfA2Checker(PdfAConformanceLevel.PDF_A_2B); + private PdfA2Checker pdfA2Checker = new PdfA2Checker(PdfAConformance.PDF_A_2B); @Test public void checkNameEntryShouldBeUniqueBetweenDefaultAndAdditionalConfigs() { @@ -71,10 +74,10 @@ public void checkNameEntryShouldBeUniqueBetweenDefaultAndAdditionalConfigs() { PdfDictionary catalog = new PdfDictionary(); catalog.put(PdfName.OCProperties, ocProperties); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA2Checker.checkCatalogValidEntries(catalog) ); - Assert.assertEquals(PdfaExceptionMessageConstant.VALUE_OF_NAME_ENTRY_SHALL_BE_UNIQUE_AMONG_ALL_OPTIONAL_CONTENT_CONFIGURATION_DICTIONARIES, + Assertions.assertEquals(PdfaExceptionMessageConstant.VALUE_OF_NAME_ENTRY_SHALL_BE_UNIQUE_AMONG_ALL_OPTIONAL_CONTENT_CONFIGURATION_DICTIONARIES, e.getMessage()); } @@ -91,9 +94,9 @@ public void checkAsKeyInContentConfigDictTest() { PdfDictionary catalog = new PdfDictionary(); catalog.put(PdfName.OCProperties, ocProperties); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> pdfA2Checker.checkCatalogValidEntries(catalog)); - Assert.assertEquals(PdfAConformanceException.THE_AS_KEY_SHALL_NOT_APPEAR_IN_ANY_OPTIONAL_CONTENT_CONFIGURATION_DICTIONARY, - e.getMessage()); + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA2Checker.checkCatalogValidEntries(catalog)); + Assertions.assertEquals(PdfaExceptionMessageConstant. + THE_AS_KEY_SHALL_NOT_APPEAR_IN_ANY_OPTIONAL_CONTENT_CONFIGURATION_DICTIONARY, e.getMessage()); } @Test @@ -114,10 +117,10 @@ public void checkNameEntryShouldBeUniqueBetweenAdditionalConfigs() { PdfDictionary catalog = new PdfDictionary(); catalog.put(PdfName.OCProperties, ocProperties); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA2Checker.checkCatalogValidEntries(catalog) ); - Assert.assertEquals(PdfaExceptionMessageConstant.VALUE_OF_NAME_ENTRY_SHALL_BE_UNIQUE_AMONG_ALL_OPTIONAL_CONTENT_CONFIGURATION_DICTIONARIES, + Assertions.assertEquals(PdfaExceptionMessageConstant.VALUE_OF_NAME_ENTRY_SHALL_BE_UNIQUE_AMONG_ALL_OPTIONAL_CONTENT_CONFIGURATION_DICTIONARIES, e.getMessage()); } @@ -138,10 +141,10 @@ public void checkOCCDContainName() { PdfDictionary catalog = new PdfDictionary(); catalog.put(PdfName.OCProperties, ocProperties); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA2Checker.checkCatalogValidEntries(catalog) ); - Assert.assertEquals(PdfaExceptionMessageConstant.OPTIONAL_CONTENT_CONFIGURATION_DICTIONARY_SHALL_CONTAIN_NAME_ENTRY, + Assertions.assertEquals(PdfaExceptionMessageConstant.OPTIONAL_CONTENT_CONFIGURATION_DICTIONARY_SHALL_CONTAIN_NAME_ENTRY, e.getMessage()); } @@ -176,10 +179,10 @@ public void checkOrderArrayDoesNotContainRedundantReferences() { PdfDictionary catalog = new PdfDictionary(); catalog.put(PdfName.OCProperties, ocProperties); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA2Checker.checkCatalogValidEntries(catalog) ); - Assert.assertEquals(PdfaExceptionMessageConstant.ORDER_ARRAY_SHALL_CONTAIN_REFERENCES_TO_ALL_OCGS, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.ORDER_ARRAY_SHALL_CONTAIN_REFERENCES_TO_ALL_OCGS, e.getMessage()); } @Test @@ -212,10 +215,10 @@ public void checkOrderArrayContainsReferencesToAllOCGs() { PdfDictionary catalog = new PdfDictionary(); catalog.put(PdfName.OCProperties, ocProperties); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA2Checker.checkCatalogValidEntries(catalog) ); - Assert.assertEquals(PdfaExceptionMessageConstant.ORDER_ARRAY_SHALL_CONTAIN_REFERENCES_TO_ALL_OCGS, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.ORDER_ARRAY_SHALL_CONTAIN_REFERENCES_TO_ALL_OCGS, e.getMessage()); } @Test @@ -253,10 +256,10 @@ public void checkOrderArrayAndOCGsMatch() { PdfDictionary catalog = new PdfDictionary(); catalog.put(PdfName.OCProperties, ocProperties); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA2Checker.checkCatalogValidEntries(catalog) ); - Assert.assertEquals(PdfaExceptionMessageConstant.ORDER_ARRAY_SHALL_CONTAIN_REFERENCES_TO_ALL_OCGS, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.ORDER_ARRAY_SHALL_CONTAIN_REFERENCES_TO_ALL_OCGS, e.getMessage()); } @Test @@ -330,10 +333,10 @@ public void checkCatalogDictionaryWithoutAlternatePresentations() { PdfDictionary catalog = new PdfDictionary(); catalog.put(PdfName.Names, names); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA2Checker.checkCatalogValidEntries(catalog) ); - Assert.assertEquals(PdfaExceptionMessageConstant.A_CATALOG_DICTIONARY_SHALL_NOT_CONTAIN_ALTERNATEPRESENTATIONS_NAMES_ENTRY, + Assertions.assertEquals(PdfaExceptionMessageConstant.A_CATALOG_DICTIONARY_SHALL_NOT_CONTAIN_ALTERNATEPRESENTATIONS_NAMES_ENTRY, e.getMessage()); } @@ -342,10 +345,10 @@ public void checkCatalogDictionaryWithoutRequirements() { PdfDictionary catalog = new PdfDictionary(); catalog.put(PdfName.Requirements, new PdfDictionary()); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA2Checker.checkCatalogValidEntries(catalog) ); - Assert.assertEquals(PdfaExceptionMessageConstant.A_CATALOG_DICTIONARY_SHALL_NOT_CONTAIN_REQUIREMENTS_ENTRY, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.A_CATALOG_DICTIONARY_SHALL_NOT_CONTAIN_REQUIREMENTS_ENTRY, e.getMessage()); } @Test @@ -367,7 +370,7 @@ public void deviceNColorspaceNoAttributesDictionary() { //TODO DEVSIX-4203 should not cause an IndexOutOfBoundException. // Should throw PdfAConformanceException as Colorants dictionary always must be present // for Pdf/A-2 - Assert.assertThrows(RuntimeException.class, + Assertions.assertThrows(RuntimeException.class, () -> pdfA2Checker.checkColorSpace(new PdfSpecialCs.DeviceN(tmpArray, new PdfDeviceCs.Rgb(), function), null, currentColorSpaces, true, false) ); @@ -403,7 +406,7 @@ public void deprecatedCheckColorShadingTest() { Color color = new PatternColor(pattern); AssertUtil.doesNotThrow(() -> { - pdfA2Checker.checkColor(color, new PdfDictionary(), true, null); + pdfA2Checker.checkColor(null, color, new PdfDictionary(), true, null); }); } @@ -429,7 +432,7 @@ public void checkColorShadingWithoutExtGStatePropertyInPatternDictTest() { public void checkSignatureTest() { PdfDictionary signatureDict = createSignatureDict(); pdfA2Checker.checkSignature(signatureDict); - Assert.assertTrue(pdfA2Checker.objectIsChecked(signatureDict)); + Assertions.assertTrue(pdfA2Checker.isPdfObjectReadyToFlush(signatureDict)); } @Test @@ -441,9 +444,9 @@ public void checkSignatureDigestMethodTest() { digestMethod.add(new PdfName("SHA256")); reference.put(PdfName.DigestMethod, digestMethod); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA2Checker.checkSignature(signatureDict)); - Assert.assertEquals(PdfaExceptionMessageConstant.SIGNATURE_REFERENCES_DICTIONARY_SHALL_NOT_CONTAIN_DIGESTLOCATION_DIGESTMETHOD_DIGESTVALUE, + Assertions.assertEquals(PdfaExceptionMessageConstant.SIGNATURE_REFERENCES_DICTIONARY_SHALL_NOT_CONTAIN_DIGESTLOCATION_DIGESTMETHOD_DIGESTVALUE, e.getMessage()); } @@ -451,70 +454,70 @@ public void checkSignatureDigestMethodTest() { public void checkLZWDecodeInInlineImage() { PdfStream stream = new PdfStream(); stream.put(PdfName.Filter, PdfName.LZWDecode); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA2Checker.checkInlineImage(stream, null) ); - Assert.assertEquals(PdfaExceptionMessageConstant.LZWDECODE_FILTER_IS_NOT_PERMITTED, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.LZWDECODE_FILTER_IS_NOT_PERMITTED, e.getMessage()); } @Test public void checkImageWithAlternateTest() { PdfStream image = new PdfStream(); image.put(PdfName.Alternates, PdfName.Identity); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA2Checker.checkImage(image, null) ); - Assert.assertEquals(PdfaExceptionMessageConstant.AN_IMAGE_DICTIONARY_SHALL_NOT_CONTAIN_ALTERNATES_KEY, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.AN_IMAGE_DICTIONARY_SHALL_NOT_CONTAIN_ALTERNATES_KEY, e.getMessage()); } @Test public void checkImageWithOPITest() { PdfStream image = new PdfStream(); image.put(PdfName.OPI, PdfName.Identity); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA2Checker.checkImage(image, null) ); - Assert.assertEquals(PdfaExceptionMessageConstant.AN_IMAGE_DICTIONARY_SHALL_NOT_CONTAIN_OPI_KEY, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.AN_IMAGE_DICTIONARY_SHALL_NOT_CONTAIN_OPI_KEY, e.getMessage()); } @Test public void checkImageWithInterpolateTest() { PdfStream image = new PdfStream(); image.put(PdfName.Interpolate, new PdfBoolean(true)); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA2Checker.checkImage(image, null) ); - Assert.assertEquals(PdfaExceptionMessageConstant.THE_VALUE_OF_INTERPOLATE_KEY_SHALL_BE_FALSE, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.THE_VALUE_OF_INTERPOLATE_KEY_SHALL_BE_FALSE, e.getMessage()); } @Test public void checkFormXObjectWithOPITest() { PdfStream form = new PdfStream(); form.put(PdfName.OPI, PdfName.Identity); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA2Checker.checkFormXObject(form) ); - Assert.assertEquals(PdfaExceptionMessageConstant.A_FORM_XOBJECT_DICTIONARY_SHALL_NOT_CONTAIN_OPI_KEY, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.A_FORM_XOBJECT_DICTIONARY_SHALL_NOT_CONTAIN_OPI_KEY, e.getMessage()); } @Test public void checkFormXObjectWithPSTest() { PdfStream form = new PdfStream(); form.put(PdfName.PS, PdfName.Identity); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA2Checker.checkFormXObject(form) ); - Assert.assertEquals(PdfaExceptionMessageConstant.A_FORM_XOBJECT_DICTIONARY_SHALL_NOT_CONTAIN_PS_KEY, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.A_FORM_XOBJECT_DICTIONARY_SHALL_NOT_CONTAIN_PS_KEY, e.getMessage()); } @Test public void checkCryptInInlineImage() { PdfStream stream = new PdfStream(); stream.put(PdfName.Filter, PdfName.Crypt); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA2Checker.checkInlineImage(stream, null) ); - Assert.assertEquals(PdfaExceptionMessageConstant.CRYPT_FILTER_IS_NOT_PERMITTED_INLINE_IMAGE, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.CRYPT_FILTER_IS_NOT_PERMITTED_INLINE_IMAGE, e.getMessage()); } @@ -524,10 +527,10 @@ public void checkLZWDecodeArrayInInlineImage() { PdfArray array = new PdfArray(); array.add(PdfName.LZWDecode); stream.put(PdfName.Filter, array); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA2Checker.checkInlineImage(stream, null) ); - Assert.assertEquals(PdfaExceptionMessageConstant.LZWDECODE_FILTER_IS_NOT_PERMITTED, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.LZWDECODE_FILTER_IS_NOT_PERMITTED, e.getMessage()); } @Test @@ -536,10 +539,10 @@ public void checkCryptArrayInInlineImage() { PdfArray array = new PdfArray(); array.add(PdfName.Crypt); stream.put(PdfName.Filter, array); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA2Checker.checkInlineImage(stream, null) ); - Assert.assertEquals(PdfaExceptionMessageConstant.CRYPT_FILTER_IS_NOT_PERMITTED_INLINE_IMAGE, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.CRYPT_FILTER_IS_NOT_PERMITTED_INLINE_IMAGE, e.getMessage()); } @Test @@ -548,29 +551,29 @@ public void checkAllowedArrayFilterInInlineImage() { PdfArray array = new PdfArray(); array.add(PdfName.Identity); stream.put(PdfName.Filter, array); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA2Checker.checkInlineImage(stream, null) ); - Assert.assertEquals(PdfaExceptionMessageConstant.INVALID_INLINE_IMAGE_FILTER_USAGE, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.INVALID_INLINE_IMAGE_FILTER_USAGE, e.getMessage()); } @Test public void checkAllowedFilterInInlineImage() { PdfStream stream = new PdfStream(); stream.put(PdfName.Filter, PdfName.Identity); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA2Checker.checkInlineImage(stream, null) ); - Assert.assertEquals(PdfaExceptionMessageConstant.INVALID_INLINE_IMAGE_FILTER_USAGE, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.INVALID_INLINE_IMAGE_FILTER_USAGE, e.getMessage()); } @Test public void checkEmptyAnnotationTest() { PdfDictionary annotation = new PdfDictionary(); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA2Checker.checkAnnotation(annotation) ); - Assert.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.ANNOTATION_TYPE_0_IS_NOT_PERMITTED, "null"), e.getMessage()); + Assertions.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.ANNOTATION_TYPE_0_IS_NOT_PERMITTED, "null"), e.getMessage()); } @Test @@ -578,40 +581,40 @@ public void checkAnnotationAgainstActionsWithATest() { PdfDictionary annotation = new PdfDictionary(); annotation.put(PdfName.A, PdfName.Identity); annotation.put(PdfName.Subtype, PdfName.Widget); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA2Checker.checkAnnotationAgainstActions(annotation) ); - Assert.assertEquals(PdfaExceptionMessageConstant.WIDGET_ANNOTATION_DICTIONARY_OR_FIELD_DICTIONARY_SHALL_NOT_INCLUDE_A_OR_AA_ENTRY, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.WIDGET_ANNOTATION_DICTIONARY_OR_FIELD_DICTIONARY_SHALL_NOT_INCLUDE_A_OR_AA_ENTRY, e.getMessage()); } @Test public void checkAnnotationAgainstActionsWithAATest() { PdfDictionary annotation = new PdfDictionary(); annotation.put(PdfName.AA, PdfName.Identity); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA2Checker.checkAnnotationAgainstActions(annotation) ); - Assert.assertEquals(PdfaExceptionMessageConstant.AN_ANNOTATION_DICTIONARY_SHALL_NOT_CONTAIN_AA_KEY, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.AN_ANNOTATION_DICTIONARY_SHALL_NOT_CONTAIN_AA_KEY, e.getMessage()); } @Test public void checkNeedsRenderingCatalogTest() { PdfDictionary catalog = new PdfDictionary(); catalog.put(PdfName.NeedsRendering, new PdfBoolean(true)); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA2Checker.checkCatalogValidEntries(catalog) ); - Assert.assertEquals(PdfaExceptionMessageConstant.THE_CATALOG_DICTIONARY_SHALL_NOT_CONTAIN_THE_NEEDSRENDERING_KEY, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.THE_CATALOG_DICTIONARY_SHALL_NOT_CONTAIN_THE_NEEDSRENDERING_KEY, e.getMessage()); } @Test public void checkCatalogContainsAATest() { PdfDictionary catalog = new PdfDictionary(); catalog.put(PdfName.AA, PdfName.Identity); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA2Checker.checkCatalogValidEntries(catalog) ); - Assert.assertEquals(PdfaExceptionMessageConstant.A_CATALOG_DICTIONARY_SHALL_NOT_CONTAIN_AA_ENTRY, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.A_CATALOG_DICTIONARY_SHALL_NOT_CONTAIN_AA_ENTRY, e.getMessage()); } @Test @@ -634,10 +637,10 @@ public void checkPageSizeTest() { rect.add(new PdfNumber(0)); rect.add(new PdfNumber(0)); page.put(PdfName.CropBox, rect); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA2Checker.checkPageSize(page) ); - Assert.assertEquals(PdfaExceptionMessageConstant.THE_PAGE_LESS_3_UNITS_NO_GREATER_14400_IN_EITHER_DIRECTION, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.THE_PAGE_LESS_3_UNITS_NO_GREATER_14400_IN_EITHER_DIRECTION, e.getMessage()); //nothing to check, expecting that no error is thrown } @@ -652,10 +655,10 @@ public void checkOutputIntentsTest() { array.add(dictionary); array.add(dictionary2); catalog.put(PdfName.OutputIntents, array); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA2Checker.checkOutputIntents(catalog) ); - Assert.assertEquals(PdfaExceptionMessageConstant.IF_OUTPUTINTENTS_ARRAY_HAS_MORE_THAN_ONE_ENTRY_WITH_DESTOUTPUTPROFILE_KEY_THE_SAME_INDIRECT_OBJECT_SHALL_BE_USED_AS_THE_VALUE_OF_THAT_OBJECT, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.IF_OUTPUTINTENTS_ARRAY_HAS_MORE_THAN_ONE_ENTRY_WITH_DESTOUTPUTPROFILE_KEY_THE_SAME_INDIRECT_OBJECT_SHALL_BE_USED_AS_THE_VALUE_OF_THAT_OBJECT, e.getMessage()); //nothing to check, expecting that no error is thrown } @Test @@ -664,20 +667,20 @@ public void checkCatalogContainsInvalidPermsTest() { PdfDictionary perms = new PdfDictionary(); perms.put(PdfName.Identity, PdfName.Identity); catalog.put(PdfName.Perms, perms); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA2Checker.checkCatalogValidEntries(catalog) ); - Assert.assertEquals(PdfaExceptionMessageConstant.NO_KEYS_OTHER_THAN_UR3_AND_DOC_MDP_SHALL_BE_PRESENT_IN_A_PERMISSIONS_DICTIONARY, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.NO_KEYS_OTHER_THAN_UR3_AND_DOC_MDP_SHALL_BE_PRESENT_IN_A_PERMISSIONS_DICTIONARY, e.getMessage()); } @Test public void checkFileSpecNotContainsFKeyTest() { PdfDictionary fileSpec = new PdfDictionary(); fileSpec.put(PdfName.EF, PdfName.Identity); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA2Checker.checkFileSpec(fileSpec) ); - Assert.assertEquals(PdfaExceptionMessageConstant.FILE_SPECIFICATION_DICTIONARY_SHALL_CONTAIN_F_KEY_AND_UF_KEY, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.FILE_SPECIFICATION_DICTIONARY_SHALL_CONTAIN_F_KEY_AND_UF_KEY, e.getMessage()); } @Test @@ -687,30 +690,30 @@ public void checkFileSpecContainsNullFKeyTest() { fileSpec.put(PdfName.F, PdfName.Identity); fileSpec.put(PdfName.UF, PdfName.Identity); fileSpec.put(PdfName.Desc, PdfName.Identity); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA2Checker.checkFileSpec(fileSpec) ); - Assert.assertEquals(PdfaExceptionMessageConstant.EF_KEY_OF_FILE_SPECIFICATION_DICTIONARY_SHALL_CONTAIN_DICTIONARY_WITH_VALID_F_KEY, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.EF_KEY_OF_FILE_SPECIFICATION_DICTIONARY_SHALL_CONTAIN_DICTIONARY_WITH_VALID_F_KEY, e.getMessage()); } @Test public void checkPdfStreamContainsFKeyTest() { PdfStream pdfStream = new PdfStream(); pdfStream.put(PdfName.F, PdfName.Identity); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA2Checker.checkPdfStream(pdfStream) ); - Assert.assertEquals(PdfaExceptionMessageConstant.STREAM_OBJECT_DICTIONARY_SHALL_NOT_CONTAIN_THE_F_FFILTER_OR_FDECODEPARAMS_KEYS, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.STREAM_OBJECT_DICTIONARY_SHALL_NOT_CONTAIN_THE_F_FFILTER_OR_FDECODEPARAMS_KEYS, e.getMessage()); } @Test public void checkPdfStreamContainsLZWDecodeKeyTest() { PdfStream pdfStream = new PdfStream(); pdfStream.put(PdfName.Filter, PdfName.LZWDecode); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA2Checker.checkPdfStream(pdfStream) ); - Assert.assertEquals(PdfaExceptionMessageConstant.LZWDECODE_FILTER_IS_NOT_PERMITTED, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.LZWDECODE_FILTER_IS_NOT_PERMITTED, e.getMessage()); } @Test @@ -719,10 +722,10 @@ public void checkPdfStreamContainsLZWDecodeArrayKeyTest() { PdfArray array = new PdfArray(); array.add(PdfName.LZWDecode); pdfStream.put(PdfName.Filter, array); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA2Checker.checkPdfStream(pdfStream) ); - Assert.assertEquals(PdfaExceptionMessageConstant.LZWDECODE_FILTER_IS_NOT_PERMITTED, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.LZWDECODE_FILTER_IS_NOT_PERMITTED, e.getMessage()); } @Test @@ -732,10 +735,10 @@ public void checkPdfStreamContainsCryptKeyTest() { PdfDictionary decodeParams = new PdfDictionary(); decodeParams.put(PdfName.Name, PdfName.Crypt); pdfStream.put(PdfName.DecodeParms, decodeParams); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA2Checker.checkPdfStream(pdfStream) ); - Assert.assertEquals(PdfaExceptionMessageConstant.NOT_IDENTITY_CRYPT_FILTER_IS_NOT_PERMITTED, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.NOT_IDENTITY_CRYPT_FILTER_IS_NOT_PERMITTED, e.getMessage()); } @Test @@ -749,10 +752,10 @@ public void checkPdfStreamContainsCryptArrayKeyTest() { decodeArray.add(decodeParams); decodeParams.put(PdfName.Name, PdfName.Crypt); pdfStream.put(PdfName.DecodeParms, decodeArray); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA2Checker.checkPdfStream(pdfStream) ); - Assert.assertEquals(PdfaExceptionMessageConstant.NOT_IDENTITY_CRYPT_FILTER_IS_NOT_PERMITTED, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.NOT_IDENTITY_CRYPT_FILTER_IS_NOT_PERMITTED, e.getMessage()); } @Test @@ -774,10 +777,11 @@ public void checkColorSpaceWithDeviceNWithoutAttributes() { PdfDictionary currentColorSpaces = new PdfDictionary(); - Exception e = Assert.assertThrows(PdfAConformanceException.class, - () -> pdfA2Checker.checkColorSpace(new PdfSpecialCs.DeviceN(deviceNAsArray), currentColorSpaces, true, false) + Exception e = Assertions.assertThrows(PdfAConformanceException.class, + () -> pdfA2Checker.checkColorSpace(new PdfSpecialCs.DeviceN(deviceNAsArray), null, + currentColorSpaces, true, false) ); - Assert.assertEquals(PdfaExceptionMessageConstant.COLORANTS_DICTIONARY_SHALL_NOT_BE_EMPTY_IN_DEVICE_N_COLORSPACE, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.COLORANTS_DICTIONARY_SHALL_NOT_BE_EMPTY_IN_DEVICE_N_COLORSPACE, e.getMessage()); } @@ -802,10 +806,64 @@ public void checkColorSpaceWithDeviceNWithoutColorants() { deviceNAsArray.add(attributes); - Exception e = Assert.assertThrows(PdfAConformanceException.class, - () -> pdfA2Checker.checkColorSpace(new PdfSpecialCs.DeviceN(deviceNAsArray), currentColorSpaces, true, false) + Exception e = Assertions.assertThrows(PdfAConformanceException.class, + () -> pdfA2Checker.checkColorSpace(new PdfSpecialCs.DeviceN(deviceNAsArray), null, + currentColorSpaces, true, false) ); - Assert.assertEquals(PdfaExceptionMessageConstant.COLORANTS_DICTIONARY_SHALL_NOT_BE_EMPTY_IN_DEVICE_N_COLORSPACE, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.COLORANTS_DICTIONARY_SHALL_NOT_BE_EMPTY_IN_DEVICE_N_COLORSPACE, e.getMessage()); + } + + @Test + public void checkColorSpaceWithIndexedTest() { + PdfDictionary currentColorSpaces = new PdfDictionary(); + PdfSpecialCs.Indexed indexed = new PdfSpecialCs.Indexed(PdfName.Indexed, 255, new PdfString(new String("".getBytes(StandardCharsets.UTF_8), + StandardCharsets.UTF_8))); + pdfA2Checker.checkColorSpace(indexed, null, + currentColorSpaces, Boolean.TRUE, Boolean.FALSE); + //Nothing to check, no error should be thrown. + } + + @Test + public void checkColorSpaceWithUnColoredTilingTest() { + PdfDictionary currentColorSpaces = new PdfDictionary(); + PdfSpecialCs.UncoloredTilingPattern uncoloredTilingCmykCs = new PdfSpecialCs.UncoloredTilingPattern(new PdfDeviceCs.Cmyk()); + pdfA2Checker.checkColorSpace(uncoloredTilingCmykCs, null, + currentColorSpaces, Boolean.TRUE, Boolean.FALSE); + //Nothing to check, no error should be thrown. + } + + @Test + public void checkExtGateTest() { + PdfExtGState egs = new PdfExtGState(); + egs.setOverprintMode(1); + egs.setFillOverPrintFlag(true); + egs.setSoftMask(new PdfDictionary()); + egs.setStrokeOpacity(0.3f); + PdfDocument dummyDoc = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); + PdfCanvas canvas = new PdfCanvas(dummyDoc.addNewPage()); + canvas.setExtGState(egs); + CanvasGraphicsState canvasGraphicsState = new CanvasGraphicsState(canvas.getGraphicsState()); + pdfA2Checker.checkExtGState(canvasGraphicsState, null); + + + Assertions.assertEquals(0.3f, canvasGraphicsState.getStrokeOpacity(), 0.00001); + Assertions.assertNotNull(canvasGraphicsState.getSoftMask()); + Assertions.assertTrue(canvasGraphicsState.getSoftMask().isDictionary()); + Assertions.assertTrue(canvasGraphicsState.getFillOverprint()); + Assertions.assertEquals(1, canvasGraphicsState.getOverprintMode()); + } + + @Test + public void checkExtGateOverprintModeTest() { + PdfExtGState egs = new PdfExtGState(); + egs.setSoftMask(new PdfDictionary()); + egs.setStrokeOpacity(0.3f); + PdfDocument dummyDoc = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); + PdfCanvas canvas = new PdfCanvas(dummyDoc.addNewPage()); + canvas.setExtGState(egs); + CanvasGraphicsState canvasGraphicsState = new CanvasGraphicsState(canvas.getGraphicsState()); + pdfA2Checker.checkExtGState(canvasGraphicsState, null); + //Nothing to check, no error should be thrown. } private static PdfDictionary createSignatureDict() { diff --git a/pdfa/src/test/java/com/itextpdf/pdfa/checker/PdfA2CheckerTransparencyTest.java b/pdfa/src/test/java/com/itextpdf/pdfa/checker/PdfA2CheckerTransparencyTest.java index 4a0006ee6c..cb1f0549fd 100644 --- a/pdfa/src/test/java/com/itextpdf/pdfa/checker/PdfA2CheckerTransparencyTest.java +++ b/pdfa/src/test/java/com/itextpdf/pdfa/checker/PdfA2CheckerTransparencyTest.java @@ -23,7 +23,7 @@ This file is part of the iText (R) project. package com.itextpdf.pdfa.checker; import com.itextpdf.kernel.geom.Rectangle; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfAConformance; import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfName; @@ -38,23 +38,22 @@ This file is part of the iText (R) project. import com.itextpdf.pdfa.exceptions.PdfAConformanceException; import com.itextpdf.pdfa.exceptions.PdfaExceptionMessageConstant; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.ByteArrayOutputStream; import java.io.IOException; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfA2CheckerTransparencyTest extends ExtendedITextTest { private PdfA2Checker pdfA2Checker; - @Before + @BeforeEach public void before() { - pdfA2Checker = new PdfA2Checker(PdfAConformanceLevel.PDF_A_2B); + pdfA2Checker = new PdfA2Checker(PdfAConformance.PDF_A_2B); pdfA2Checker.setFullCheckMode(true); } @@ -123,10 +122,10 @@ public void checkPatternWithTransparentFormResource() throws IOException { pageResources.addPattern(new PdfPattern.Shading(new PdfDictionary())); pageResources.addPattern(tillingPattern); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA2Checker.checkSinglePage(pageToCheck) ); - Assert.assertEquals(PdfaExceptionMessageConstant.THE_DOCUMENT_DOES_NOT_CONTAIN_A_PDFA_OUTPUTINTENT_BUT_PAGE_CONTAINS_TRANSPARENCY_AND_DOES_NOT_CONTAIN_BLENDING_COLOR_SPACE, + Assertions.assertEquals(PdfaExceptionMessageConstant.THE_DOCUMENT_DOES_NOT_CONTAIN_A_PDFA_OUTPUTINTENT_BUT_PAGE_CONTAINS_TRANSPARENCY_AND_DOES_NOT_CONTAIN_BLENDING_COLOR_SPACE, e.getMessage()); } } @@ -171,10 +170,10 @@ public void checkAppearanceStreamWithTransparencyGroup() throws IOException { pageToCheck.addAnnotation(new PdfPopupAnnotation(new Rectangle(0f, 0f))); pageToCheck.addAnnotation(annotation); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA2Checker.checkSinglePage(pageToCheck) ); - Assert.assertEquals(PdfaExceptionMessageConstant.THE_DOCUMENT_DOES_NOT_CONTAIN_A_PDFA_OUTPUTINTENT_BUT_PAGE_CONTAINS_TRANSPARENCY_AND_DOES_NOT_CONTAIN_BLENDING_COLOR_SPACE, + Assertions.assertEquals(PdfaExceptionMessageConstant.THE_DOCUMENT_DOES_NOT_CONTAIN_A_PDFA_OUTPUTINTENT_BUT_PAGE_CONTAINS_TRANSPARENCY_AND_DOES_NOT_CONTAIN_BLENDING_COLOR_SPACE, e.getMessage()); } } @@ -199,10 +198,10 @@ public void checkAppearanceStreamWithTransparencyGroup2() throws IOException { pageToCheck.addAnnotation(new PdfPopupAnnotation(new Rectangle(0f, 0f))); pageToCheck.addAnnotation(annotation); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA2Checker.checkSinglePage(pageToCheck) ); - Assert.assertEquals(PdfaExceptionMessageConstant.THE_DOCUMENT_DOES_NOT_CONTAIN_A_PDFA_OUTPUTINTENT_BUT_PAGE_CONTAINS_TRANSPARENCY_AND_DOES_NOT_CONTAIN_BLENDING_COLOR_SPACE, + Assertions.assertEquals(PdfaExceptionMessageConstant.THE_DOCUMENT_DOES_NOT_CONTAIN_A_PDFA_OUTPUTINTENT_BUT_PAGE_CONTAINS_TRANSPARENCY_AND_DOES_NOT_CONTAIN_BLENDING_COLOR_SPACE, e.getMessage()); } } diff --git a/pdfa/src/test/java/com/itextpdf/pdfa/checker/PdfA2ImplementationLimitsCheckerTest.java b/pdfa/src/test/java/com/itextpdf/pdfa/checker/PdfA2ImplementationLimitsCheckerTest.java index eb5fd99156..b12805d8a1 100644 --- a/pdfa/src/test/java/com/itextpdf/pdfa/checker/PdfA2ImplementationLimitsCheckerTest.java +++ b/pdfa/src/test/java/com/itextpdf/pdfa/checker/PdfA2ImplementationLimitsCheckerTest.java @@ -22,7 +22,7 @@ This file is part of the iText (R) project. */ package com.itextpdf.pdfa.checker; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfAConformance; import com.itextpdf.kernel.pdf.PdfArray; import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.kernel.pdf.PdfName; @@ -36,23 +36,22 @@ This file is part of the iText (R) project. import com.itextpdf.pdfa.exceptions.PdfAConformanceException; import com.itextpdf.pdfa.exceptions.PdfaExceptionMessageConstant; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfA2ImplementationLimitsCheckerTest extends ExtendedITextTest { private PdfA2Checker pdfA2Checker; - @Before + @BeforeEach public void before() { - pdfA2Checker = new PdfA2Checker(PdfAConformanceLevel.PDF_A_2B); + pdfA2Checker = new PdfA2Checker(PdfAConformance.PDF_A_2B); pdfA2Checker.setFullCheckMode(true); } @@ -61,15 +60,15 @@ public void independentLongStringTest() { final int maxAllowedLength = pdfA2Checker.getMaxStringLength(); final int testLength = maxAllowedLength + 1; - Assert.assertEquals(testLength, 32768); + Assertions.assertEquals(testLength, 32768); PdfString longString = PdfACheckerTestUtils.getLongString(testLength); // An exception should be thrown as provided String is longer then // it is allowed per specification - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA2Checker.checkPdfObject(longString) ); - Assert.assertEquals(PdfaExceptionMessageConstant.PDF_STRING_IS_TOO_LONG, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.PDF_STRING_IS_TOO_LONG, e.getMessage()); } @Test @@ -79,7 +78,7 @@ public void longStringInContentStreamTest() { final int maxAllowedLength = pdfA2Checker.getMaxStringLength(); final int testLength = maxAllowedLength + 1; - Assert.assertEquals(testLength, 32768); + Assertions.assertEquals(testLength, 32768); PdfString longString = PdfACheckerTestUtils.getLongString(testLength); String newContentString = PdfACheckerTestUtils.getStreamWithValue(longString); @@ -88,10 +87,10 @@ public void longStringInContentStreamTest() { // An exception should be thrown as content stream has a string which // is longer then it is allowed per specification - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA2Checker.checkContentStream(stream) ); - Assert.assertEquals(PdfaExceptionMessageConstant.PDF_STRING_IS_TOO_LONG, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.PDF_STRING_IS_TOO_LONG, e.getMessage()); } @Test @@ -128,18 +127,18 @@ public void independentLargeRealTest() { // TODO DEVSIX-4182 // An exception is thrown as any number greater then 32767 is considered as Integer - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA2Checker.checkPdfObject(largeNumber) ); - Assert.assertEquals(PdfaExceptionMessageConstant.INTEGER_NUMBER_IS_OUT_OF_RANGE, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.INTEGER_NUMBER_IS_OUT_OF_RANGE, e.getMessage()); } @Test public void deviceNColorspaceWithMoreThan32Components() { - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> checkColorspace(buildDeviceNColorspace(34)) ); - Assert.assertEquals(PdfaExceptionMessageConstant.THE_NUMBER_OF_COLOR_COMPONENTS_IN_DEVICE_N_COLORSPACE_SHOULD_NOT_EXCEED, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.THE_NUMBER_OF_COLOR_COMPONENTS_IN_DEVICE_N_COLORSPACE_SHOULD_NOT_EXCEED, e.getMessage()); } @Test diff --git a/pdfa/src/test/java/com/itextpdf/pdfa/checker/PdfA3CheckerTest.java b/pdfa/src/test/java/com/itextpdf/pdfa/checker/PdfA3CheckerTest.java index de04971d85..9f48e57f55 100644 --- a/pdfa/src/test/java/com/itextpdf/pdfa/checker/PdfA3CheckerTest.java +++ b/pdfa/src/test/java/com/itextpdf/pdfa/checker/PdfA3CheckerTest.java @@ -22,24 +22,23 @@ This file is part of the iText (R) project. */ package com.itextpdf.pdfa.checker; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfAConformance; import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.kernel.pdf.PdfName; import com.itextpdf.kernel.pdf.PdfStream; import com.itextpdf.pdfa.exceptions.PdfAConformanceException; import com.itextpdf.pdfa.exceptions.PdfaExceptionMessageConstant; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfA3CheckerTest extends ExtendedITextTest { - private PdfA1Checker pdfA3Checker = new PdfA3Checker(PdfAConformanceLevel.PDF_A_3B); + private PdfA1Checker pdfA3Checker = new PdfA3Checker(PdfAConformance.PDF_A_3B); - @Before + @BeforeEach public void before() { pdfA3Checker.setFullCheckMode(true); } @@ -48,10 +47,10 @@ public void before() { public void checkFileSpecNotContainsAFRelationshipKeyTest() { PdfDictionary fileSpec = new PdfDictionary(); fileSpec.put(PdfName.EF, PdfName.Identity); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA3Checker.checkFileSpec(fileSpec) ); - Assert.assertEquals(PdfaExceptionMessageConstant.FILE_SPECIFICATION_DICTIONARY_SHALL_CONTAIN_ONE_OF_THE_PREDEFINED_AFRELATIONSHIP_KEYS, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.FILE_SPECIFICATION_DICTIONARY_SHALL_CONTAIN_ONE_OF_THE_PREDEFINED_AFRELATIONSHIP_KEYS, e.getMessage()); } @Test @@ -59,10 +58,10 @@ public void checkFileSpecNotContainsFKeyTest() { PdfDictionary fileSpec = new PdfDictionary(); fileSpec.put(PdfName.EF, PdfName.Identity); fileSpec.put(PdfName.AFRelationship, PdfName.Data); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA3Checker.checkFileSpec(fileSpec) ); - Assert.assertEquals(PdfaExceptionMessageConstant.FILE_SPECIFICATION_DICTIONARY_SHALL_CONTAIN_F_KEY_AND_UF_KEY, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.FILE_SPECIFICATION_DICTIONARY_SHALL_CONTAIN_F_KEY_AND_UF_KEY, e.getMessage()); } @Test @@ -73,10 +72,10 @@ public void checkFileSpecContainsNullFKeyTest() { fileSpec.put(PdfName.UF, PdfName.Identity); fileSpec.put(PdfName.Desc, PdfName.Identity); fileSpec.put(PdfName.AFRelationship, PdfName.Data); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA3Checker.checkFileSpec(fileSpec) ); - Assert.assertEquals(PdfaExceptionMessageConstant.EF_KEY_OF_FILE_SPECIFICATION_DICTIONARY_SHALL_CONTAIN_DICTIONARY_WITH_VALID_F_KEY, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.EF_KEY_OF_FILE_SPECIFICATION_DICTIONARY_SHALL_CONTAIN_DICTIONARY_WITH_VALID_F_KEY, e.getMessage()); } @Test @@ -89,10 +88,10 @@ public void checkFileSpecContainsEmptyFKeyTest() { fileSpec.put(PdfName.UF, PdfName.Identity); fileSpec.put(PdfName.Desc, PdfName.Identity); fileSpec.put(PdfName.AFRelationship, PdfName.Data); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA3Checker.checkFileSpec(fileSpec) ); - Assert.assertEquals(PdfaExceptionMessageConstant.MIME_TYPE_SHALL_BE_SPECIFIED_USING_THE_SUBTYPE_KEY_OF_THE_FILE_SPECIFICATION_STREAM_DICTIONARY, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.MIME_TYPE_SHALL_BE_SPECIFIED_USING_THE_SUBTYPE_KEY_OF_THE_FILE_SPECIFICATION_STREAM_DICTIONARY, e.getMessage()); } @Test @@ -108,9 +107,9 @@ public void checkFileSpecContainsFKeyWithParamsTest() { fileSpec.put(PdfName.UF, PdfName.Identity); fileSpec.put(PdfName.Desc, PdfName.Identity); fileSpec.put(PdfName.AFRelationship, PdfName.Data); - Exception e = Assert.assertThrows(PdfAConformanceException.class, + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> pdfA3Checker.checkFileSpec(fileSpec) ); - Assert.assertEquals(PdfaExceptionMessageConstant.EMBEDDED_FILE_SHALL_CONTAIN_PARAMS_KEY_WITH_DICTIONARY_AS_VALUE, e.getMessage()); + Assertions.assertEquals(PdfaExceptionMessageConstant.EMBEDDED_FILE_SHALL_CONTAIN_PARAMS_KEY_WITH_DICTIONARY_AS_VALUE, e.getMessage()); } } diff --git a/pdfa/src/test/java/com/itextpdf/pdfa/checker/PdfA4ImplementationLimitsTest.java b/pdfa/src/test/java/com/itextpdf/pdfa/checker/PdfA4ImplementationLimitsTest.java index fa275d23e5..f7473b1701 100644 --- a/pdfa/src/test/java/com/itextpdf/pdfa/checker/PdfA4ImplementationLimitsTest.java +++ b/pdfa/src/test/java/com/itextpdf/pdfa/checker/PdfA4ImplementationLimitsTest.java @@ -22,7 +22,7 @@ This file is part of the iText (R) project. */ package com.itextpdf.pdfa.checker; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfAConformance; import com.itextpdf.kernel.pdf.PdfArray; import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.kernel.pdf.PdfName; @@ -32,48 +32,41 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.colorspace.PdfColorSpace; import com.itextpdf.kernel.pdf.colorspace.PdfDeviceCs; import com.itextpdf.kernel.pdf.colorspace.PdfSpecialCs; -import com.itextpdf.kernel.pdf.function.PdfType2Function; import com.itextpdf.kernel.pdf.function.PdfType4Function; -import com.itextpdf.pdfa.exceptions.PdfaExceptionMessageConstant; -import com.itextpdf.pdfa.logs.PdfAConformanceLogMessageConstant; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.LogMessage; -import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.nio.charset.StandardCharsets; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfA4ImplementationLimitsTest extends ExtendedITextTest { - private PdfA4Checker pdfA4Checker = new PdfA4Checker(PdfAConformanceLevel.PDF_A_4); + private PdfA4Checker pdfA4Checker = new PdfA4Checker(PdfAConformance.PDF_A_4); - @Before + @BeforeEach public void before() { pdfA4Checker.setFullCheckMode(true); } @Test public void independentLongStringTest() { - final int maxAllowedLength = new PdfA2Checker(PdfAConformanceLevel.PDF_A_2B).getMaxStringLength(); + final int maxAllowedLength = new PdfA2Checker(PdfAConformance.PDF_A_2B).getMaxStringLength(); final int testLength = maxAllowedLength + 1; PdfString longString = PdfACheckerTestUtils.getLongString(testLength); //An exception should not be thrown because pdf/a-4 spec allows any length strings pdfA4Checker.checkPdfObject(longString); - Assert.assertEquals(testLength, longString.toString().length()); + Assertions.assertEquals(testLength, longString.toString().length()); } @Test public void longStringInContentStreamTest() { - final int maxAllowedLength = new PdfA2Checker(PdfAConformanceLevel.PDF_A_2B).getMaxStringLength(); + final int maxAllowedLength = new PdfA2Checker(PdfAConformance.PDF_A_2B).getMaxStringLength(); final int testLength = maxAllowedLength + 1; PdfString longString = PdfACheckerTestUtils.getLongString(testLength); @@ -82,15 +75,15 @@ public void longStringInContentStreamTest() { PdfStream stream = new PdfStream(newContent); //An exception should not be thrown because pdf/a-4 spec allows any length strings pdfA4Checker.checkContentStream(stream); - Assert.assertEquals(testLength, longString.toString().length()); + Assertions.assertEquals(testLength, longString.toString().length()); } @Test public void independentLargeRealTest() { - PdfNumber largeNumber = new PdfNumber(new PdfA2Checker(PdfAConformanceLevel.PDF_A_2B).getMaxRealValue()); + PdfNumber largeNumber = new PdfNumber(new PdfA2Checker(PdfAConformance.PDF_A_2B).getMaxRealValue()); // An exception shall not be thrown pdf/a-4 has no number limits pdfA4Checker.checkPdfObject(largeNumber); - Assert.assertEquals(Float.MAX_VALUE, largeNumber.floatValue(), 0.001f); + Assertions.assertEquals(Float.MAX_VALUE, largeNumber.floatValue(), 0.001f); } @Test diff --git a/pdfa/src/test/java/com/itextpdf/pdfa/checker/PdfA4MetaDataTest.java b/pdfa/src/test/java/com/itextpdf/pdfa/checker/PdfA4MetaDataTest.java index 9ed1a2eab7..408fa8fb36 100644 --- a/pdfa/src/test/java/com/itextpdf/pdfa/checker/PdfA4MetaDataTest.java +++ b/pdfa/src/test/java/com/itextpdf/pdfa/checker/PdfA4MetaDataTest.java @@ -25,7 +25,7 @@ This file is part of the iText (R) project. import com.itextpdf.commons.utils.FileUtil; import com.itextpdf.commons.utils.MessageFormatUtil; import com.itextpdf.kernel.exceptions.PdfException; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfAConformance; import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfName; @@ -46,7 +46,6 @@ This file is part of the iText (R) project. import com.itextpdf.pdfa.exceptions.PdfaExceptionMessageConstant; import com.itextpdf.test.AssertUtil; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -55,19 +54,19 @@ This file is part of the iText (R) project. import java.nio.file.Files; import java.nio.file.Paths; import java.util.function.Consumer; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfA4MetaDataTest extends ExtendedITextTest { - private static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/pdfa/PdfA4ActionCheckTest/"; + private static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/pdfa/PdfA4MetaDataTest/"; private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/pdfa/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(DESTINATION_FOLDER); } @@ -76,11 +75,11 @@ public static void beforeClass() { public void pdfA4DocumentShallContainMetaDataKey() { PdfDictionary dictionary = new PdfDictionary(); - PdfA4Checker checker = new PdfA4Checker(PdfAConformanceLevel.PDF_A_4); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> { - new PdfA4Checker(PdfAConformanceLevel.PDF_A_4).checkMetaData(dictionary); + PdfA4Checker checker = new PdfA4Checker(PdfAConformance.PDF_A_4); + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> { + new PdfA4Checker(PdfAConformance.PDF_A_4).checkMetaData(dictionary); }); - Assert.assertEquals(e.getMessage(), PdfAConformanceException.A_CATALOG_DICTIONARY_SHALL_CONTAIN_METADATA_ENTRY); + Assertions.assertEquals(e.getMessage(), PdfaExceptionMessageConstant.A_CATALOG_DICTIONARY_SHALL_CONTAIN_METADATA_ENTRY); } @@ -90,13 +89,13 @@ public void pdfA4DocumentMetaDataDocumentShallNotContainBytes() { String startHeader = "\n"; byte[] bytes = startHeader.getBytes(); - PdfA4Checker checker = new PdfA4Checker(PdfAConformanceLevel.PDF_A_4); + PdfA4Checker checker = new PdfA4Checker(PdfAConformance.PDF_A_4); PdfDictionary catalog = new PdfDictionary(); catalog.put(PdfName.Metadata, new PdfStream(bytes)); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> { + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> { checker.checkMetaData(catalog); }); - Assert.assertEquals( + Assertions.assertEquals( PdfaExceptionMessageConstant.XMP_METADATA_HEADER_PACKET_MAY_NOT_CONTAIN_BYTES_OR_ENCODING_ATTRIBUTE, e.getMessage()); } @@ -107,13 +106,13 @@ public void pdfA4DocumentMetaDataDocumentShallNotContainEncoding() { byte[] bytes = startHeader.getBytes(); - PdfA4Checker checker = new PdfA4Checker(PdfAConformanceLevel.PDF_A_4); + PdfA4Checker checker = new PdfA4Checker(PdfAConformance.PDF_A_4); PdfDictionary catalog = new PdfDictionary(); catalog.put(PdfName.Metadata, new PdfStream(bytes)); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> { + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> { checker.checkMetaData(catalog); }); - Assert.assertEquals( + Assertions.assertEquals( PdfaExceptionMessageConstant.XMP_METADATA_HEADER_PACKET_MAY_NOT_CONTAIN_BYTES_OR_ENCODING_ATTRIBUTE, e.getMessage()); @@ -125,13 +124,13 @@ public void pdfA4DocumentMetaDataDocumentShallNotContainEncodingInAnyPacket() { startHeader += "\n"; byte[] bytes = startHeader.getBytes(); - PdfA4Checker checker = new PdfA4Checker(PdfAConformanceLevel.PDF_A_4); + PdfA4Checker checker = new PdfA4Checker(PdfAConformance.PDF_A_4); PdfDictionary catalog = new PdfDictionary(); catalog.put(PdfName.Metadata, new PdfStream(bytes)); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> { + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> { checker.checkMetaData(catalog); }); - Assert.assertEquals( + Assertions.assertEquals( PdfaExceptionMessageConstant.XMP_METADATA_HEADER_PACKET_MAY_NOT_CONTAIN_BYTES_OR_ENCODING_ATTRIBUTE, e.getMessage()); } @@ -139,7 +138,7 @@ public void pdfA4DocumentMetaDataDocumentShallNotContainEncodingInAnyPacket() { @Test public void pdfA4DocumentMetaDataDocumentShallNotThrowInAnyPacket() throws IOException { byte[] bytes = Files.readAllBytes(Paths.get(SOURCE_FOLDER + "xmp/xmpWithMultipleXmpHeaders.xmp")); - PdfA4Checker checker = new PdfA4Checker(PdfAConformanceLevel.PDF_A_4); + PdfA4Checker checker = new PdfA4Checker(PdfAConformance.PDF_A_4); PdfDictionary catalog = new PdfDictionary(); catalog.put(PdfName.Metadata, new PdfStream(bytes)); AssertUtil.doesNotThrow(() -> { @@ -151,11 +150,11 @@ public void pdfA4DocumentMetaDataDocumentShallNotThrowInAnyPacket() throws IOExc public void pdfA4DocumentMetaDataRevPropertyHasCorrectPrefix() throws IOException { byte[] bytes = Files.readAllBytes(Paths.get(SOURCE_FOLDER + "xmp/xmpWithMultipleXmpHeaders.xmp")); String xmpContent = new String(bytes, StandardCharsets.US_ASCII).replace("pdfaid:rev", "rev"); - PdfA4Checker checker = new PdfA4Checker(PdfAConformanceLevel.PDF_A_4); + PdfA4Checker checker = new PdfA4Checker(PdfAConformance.PDF_A_4); PdfDictionary catalog = new PdfDictionary(); catalog.put(PdfName.Metadata, new PdfStream(xmpContent.getBytes(StandardCharsets.UTF_8))); - Exception e = Assert.assertThrows(PdfException.class, () -> { + Exception e = Assertions.assertThrows(PdfException.class, () -> { checker.checkMetaData(catalog); }); } @@ -164,15 +163,15 @@ public void pdfA4DocumentMetaDataRevPropertyHasCorrectPrefix() throws IOExceptio public void pdfA4DocumentMetaDataIdentificationSchemaUsesCorrectNamespaceURI() throws IOException { byte[] bytes = Files.readAllBytes(Paths.get(SOURCE_FOLDER + "xmp/xmpWithMultipleXmpHeaders.xmp")); String xmpContent = new String(bytes, StandardCharsets.US_ASCII).replace("http://www.aiim.org/pdfa/ns/id/", "no_link"); - PdfA4Checker checker = new PdfA4Checker(PdfAConformanceLevel.PDF_A_4); + PdfA4Checker checker = new PdfA4Checker(PdfAConformance.PDF_A_4); PdfDictionary catalog = new PdfDictionary(); catalog.put(PdfName.Metadata, new PdfStream(xmpContent.getBytes(StandardCharsets.UTF_8))); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> { + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> { checker.checkMetaData(catalog); }); - Assert.assertEquals(MessageFormatUtil.format( + Assertions.assertEquals(MessageFormatUtil.format( PdfaExceptionMessageConstant.XMP_METADATA_HEADER_SHALL_CONTAIN_VERSION_IDENTIFIER_PART, "4"), e.getMessage()); } @@ -180,13 +179,13 @@ public void pdfA4DocumentMetaDataIdentificationSchemaUsesCorrectNamespaceURI() t @Test public void pdfA4DocumentMetaDataDocumentShallThrowInSecondPacket() throws IOException { byte[] bytes = Files.readAllBytes(Paths.get(SOURCE_FOLDER + "xmp/xmpWithMultipleXmpHeadersWithEnconding.xmp")); - PdfA4Checker checker = new PdfA4Checker(PdfAConformanceLevel.PDF_A_4); + PdfA4Checker checker = new PdfA4Checker(PdfAConformance.PDF_A_4); PdfDictionary catalog = new PdfDictionary(); catalog.put(PdfName.Metadata, new PdfStream(bytes)); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> { + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> { checker.checkMetaData(catalog); }); - Assert.assertEquals( + Assertions.assertEquals( PdfaExceptionMessageConstant.XMP_METADATA_HEADER_PACKET_MAY_NOT_CONTAIN_BYTES_OR_ENCODING_ATTRIBUTE, e.getMessage()); @@ -195,17 +194,17 @@ public void pdfA4DocumentMetaDataDocumentShallThrowInSecondPacket() throws IOExc @Test public void testAbsentPartPropertyPDFA4() throws IOException, XMPException { String outPdf = DESTINATION_FOLDER + "testAbsentPartPropertyPDFA4.pdf"; - PdfAConformanceLevel conformanceLevel = PdfAConformanceLevel.PDF_A_4; - generatePdfADocument(conformanceLevel, outPdf, (doc) -> { + PdfAConformance conformance = PdfAConformance.PDF_A_4; + generatePdfADocument(conformance, outPdf, (doc) -> { }); PdfADocument pdfADocument = new PdfADocument(new PdfReader(outPdf), new PdfWriter(new ByteArrayOutputStream())); PdfDictionary catalog = generateCustomXmpCatalog(pdfADocument, (xmpMeta -> { xmpMeta.deleteProperty(XMPConst.NS_PDFA_ID, XMPConst.PART); })); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> { - new PdfA4Checker(conformanceLevel).checkMetaData(catalog); + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> { + new PdfA4Checker(conformance).checkMetaData(catalog); }); - Assert.assertEquals(MessageFormatUtil.format( + Assertions.assertEquals(MessageFormatUtil.format( PdfaExceptionMessageConstant.XMP_METADATA_HEADER_SHALL_CONTAIN_VERSION_IDENTIFIER_PART, "4"), e.getMessage()); } @@ -213,8 +212,8 @@ public void testAbsentPartPropertyPDFA4() throws IOException, XMPException { @Test public void testInvalidPartPropertyPDFA4() throws IOException, XMPException { String outPdf = DESTINATION_FOLDER + "testInvalidPartPropertyPDFA4.pdf"; - PdfAConformanceLevel conformanceLevel = PdfAConformanceLevel.PDF_A_4; - generatePdfADocument(conformanceLevel, outPdf, (doc) -> { + PdfAConformance conformance = PdfAConformance.PDF_A_4; + generatePdfADocument(conformance, outPdf, (doc) -> { }); PdfADocument pdfADocument = new PdfADocument(new PdfReader(outPdf), new PdfWriter(new ByteArrayOutputStream())); PdfDictionary catalog = generateCustomXmpCatalog(pdfADocument, (xmpMeta -> { @@ -224,10 +223,10 @@ public void testInvalidPartPropertyPDFA4() throws IOException, XMPException { throw new PdfException(e); } })); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> { - new PdfA4Checker(conformanceLevel).checkMetaData(catalog); + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> { + new PdfA4Checker(conformance).checkMetaData(catalog); }); - Assert.assertEquals(MessageFormatUtil.format( + Assertions.assertEquals(MessageFormatUtil.format( PdfaExceptionMessageConstant.XMP_METADATA_HEADER_SHALL_CONTAIN_VERSION_IDENTIFIER_PART, "4"), e.getMessage()); } @@ -235,8 +234,8 @@ public void testInvalidPartPropertyPDFA4() throws IOException, XMPException { @Test public void testNullPartPropertyPDFA4() throws IOException, XMPException { String outPdf = DESTINATION_FOLDER + "testNullPartPropertyPDFA4.pdf"; - PdfAConformanceLevel conformanceLevel = PdfAConformanceLevel.PDF_A_4; - generatePdfADocument(conformanceLevel, outPdf, (doc) -> { + PdfAConformance conformance = PdfAConformance.PDF_A_4; + generatePdfADocument(conformance, outPdf, (doc) -> { }); PdfADocument pdfADocument = new PdfADocument(new PdfReader(outPdf), new PdfWriter(new ByteArrayOutputStream())); PdfDictionary catalog = generateCustomXmpCatalog(pdfADocument, (xmpMeta -> { @@ -246,10 +245,10 @@ public void testNullPartPropertyPDFA4() throws IOException, XMPException { throw new PdfException(e); } })); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> { - new PdfA4Checker(conformanceLevel).checkMetaData(catalog); + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> { + new PdfA4Checker(conformance).checkMetaData(catalog); }); - Assert.assertEquals(MessageFormatUtil.format( + Assertions.assertEquals(MessageFormatUtil.format( PdfaExceptionMessageConstant.XMP_METADATA_HEADER_SHALL_CONTAIN_VERSION_IDENTIFIER_PART, "4"), e.getMessage()); } @@ -257,25 +256,25 @@ public void testNullPartPropertyPDFA4() throws IOException, XMPException { @Test public void testAbsentRevisionPropertyPDFA4() throws IOException, XMPException { String outPdf = DESTINATION_FOLDER + "testNullRevisionPropertyPDFA4.pdf"; - PdfAConformanceLevel conformanceLevel = PdfAConformanceLevel.PDF_A_4; - generatePdfADocument(conformanceLevel, outPdf, (doc) -> { + PdfAConformance conformance = PdfAConformance.PDF_A_4; + generatePdfADocument(conformance, outPdf, (doc) -> { }); PdfADocument pdfADocument = new PdfADocument(new PdfReader(outPdf), new PdfWriter(new ByteArrayOutputStream())); PdfDictionary catalog = generateCustomXmpCatalog(pdfADocument, (xmpMeta -> { xmpMeta.deleteProperty(XMPConst.NS_PDFA_ID, XMPConst.REV); })); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> { - new PdfA4Checker(conformanceLevel).checkMetaData(catalog); + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> { + new PdfA4Checker(conformance).checkMetaData(catalog); }); - Assert.assertEquals(PdfaExceptionMessageConstant.XMP_METADATA_HEADER_SHALL_CONTAIN_VERSION_IDENTIFIER_REV, + Assertions.assertEquals(PdfaExceptionMessageConstant.XMP_METADATA_HEADER_SHALL_CONTAIN_VERSION_IDENTIFIER_REV, e.getMessage()); } @Test public void testInvalidValueNotNumberRevisionPropertyPDFA4() throws IOException, XMPException { String outPdf = DESTINATION_FOLDER + "testInvalidValueNotNumberRevisionPropertyPDFA4.pdf"; - PdfAConformanceLevel conformanceLevel = PdfAConformanceLevel.PDF_A_4; - generatePdfADocument(conformanceLevel, outPdf, (doc) -> { + PdfAConformance conformance = PdfAConformance.PDF_A_4; + generatePdfADocument(conformance, outPdf, (doc) -> { }); PdfADocument pdfADocument = new PdfADocument(new PdfReader(outPdf), new PdfWriter(new ByteArrayOutputStream())); PdfDictionary catalog = generateCustomXmpCatalog(pdfADocument, (xmpMeta -> { @@ -285,10 +284,10 @@ public void testInvalidValueNotNumberRevisionPropertyPDFA4() throws IOException, throw new PdfException(e); } })); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> { - new PdfA4Checker(conformanceLevel).checkMetaData(catalog); + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> { + new PdfA4Checker(conformance).checkMetaData(catalog); }); - Assert.assertEquals(PdfaExceptionMessageConstant.XMP_METADATA_HEADER_SHALL_CONTAIN_VERSION_IDENTIFIER_REV, + Assertions.assertEquals(PdfaExceptionMessageConstant.XMP_METADATA_HEADER_SHALL_CONTAIN_VERSION_IDENTIFIER_REV, e.getMessage()); } @@ -296,8 +295,8 @@ public void testInvalidValueNotNumberRevisionPropertyPDFA4() throws IOException, @Test public void testInvalidValueNotLength4RevisionPropertyPDFA4() throws IOException, XMPException { String outPdf = DESTINATION_FOLDER + "testInvalidValueNotLength4RevisionPropertyPDFA4.pdf"; - PdfAConformanceLevel conformanceLevel = PdfAConformanceLevel.PDF_A_4; - generatePdfADocument(conformanceLevel, outPdf, (doc) -> { + PdfAConformance conformance = PdfAConformance.PDF_A_4; + generatePdfADocument(conformance, outPdf, (doc) -> { }); PdfADocument pdfADocument = new PdfADocument(new PdfReader(outPdf), new PdfWriter(new ByteArrayOutputStream())); PdfDictionary catalog = generateCustomXmpCatalog(pdfADocument, (xmpMeta -> { @@ -307,18 +306,18 @@ public void testInvalidValueNotLength4RevisionPropertyPDFA4() throws IOException throw new PdfException(e); } })); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> { - new PdfA4Checker(conformanceLevel).checkMetaData(catalog); + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> { + new PdfA4Checker(conformance).checkMetaData(catalog); }); - Assert.assertEquals(PdfaExceptionMessageConstant.XMP_METADATA_HEADER_SHALL_CONTAIN_VERSION_IDENTIFIER_REV, + Assertions.assertEquals(PdfaExceptionMessageConstant.XMP_METADATA_HEADER_SHALL_CONTAIN_VERSION_IDENTIFIER_REV, e.getMessage()); } @Test public void testInvalidValueLength4ButContainsLettersRevisionPropertyPDFA4() throws IOException, XMPException { String outPdf = DESTINATION_FOLDER + "testInvalidValueLength4ButContainsLettersRevisionPropertyPDFA4.pdf"; - PdfAConformanceLevel conformanceLevel = PdfAConformanceLevel.PDF_A_4; - generatePdfADocument(conformanceLevel, outPdf, (doc) -> { + PdfAConformance conformance = PdfAConformance.PDF_A_4; + generatePdfADocument(conformance, outPdf, (doc) -> { }); PdfADocument pdfADocument = new PdfADocument(new PdfReader(outPdf), new PdfWriter(new ByteArrayOutputStream())); PdfDictionary catalog = generateCustomXmpCatalog(pdfADocument, (xmpMeta -> { @@ -328,24 +327,24 @@ public void testInvalidValueLength4ButContainsLettersRevisionPropertyPDFA4() thr throw new PdfException(e); } })); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> { - new PdfA4Checker(conformanceLevel).checkMetaData(catalog); + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> { + new PdfA4Checker(conformance).checkMetaData(catalog); }); - Assert.assertEquals(PdfaExceptionMessageConstant.XMP_METADATA_HEADER_SHALL_CONTAIN_VERSION_IDENTIFIER_REV, + Assertions.assertEquals(PdfaExceptionMessageConstant.XMP_METADATA_HEADER_SHALL_CONTAIN_VERSION_IDENTIFIER_REV, e.getMessage()); } @Test public void testValidPropertiesPDFA4() throws IOException, XMPException { String outPdf = DESTINATION_FOLDER + "testValidPropertiesPDFA4.pdf"; - PdfAConformanceLevel conformanceLevel = PdfAConformanceLevel.PDF_A_4; - generatePdfADocument(conformanceLevel, outPdf, (doc) -> { + PdfAConformance conformance = PdfAConformance.PDF_A_4; + generatePdfADocument(conformance, outPdf, (doc) -> { }); PdfADocument pdfADocument = new PdfADocument(new PdfReader(outPdf), new PdfWriter(new ByteArrayOutputStream())); PdfDictionary catalog = generateCustomXmpCatalog(pdfADocument, (xmpMeta -> { })); AssertUtil.doesNotThrow(() -> { - new PdfA4Checker(conformanceLevel).checkMetaData(catalog); + new PdfA4Checker(conformance).checkMetaData(catalog); }); } @@ -353,8 +352,8 @@ public void testValidPropertiesPDFA4() throws IOException, XMPException { @Test public void testValidPropertiesPDFA4F() throws IOException, XMPException { String outPdf = DESTINATION_FOLDER + "testValidPropertiesPDFA4F.pdf"; - PdfAConformanceLevel conformanceLevel = PdfAConformanceLevel.PDF_A_4F; - generatePdfADocument(conformanceLevel, outPdf, (doc) -> { + PdfAConformance conformance = PdfAConformance.PDF_A_4F; + generatePdfADocument(conformance, outPdf, (doc) -> { PdfFileSpec fs = PdfFileSpec.createEmbeddedFileSpec(doc, "file".getBytes(), "description", "file.txt", null, null, null); doc.addFileAttachment("file.txt", fs); @@ -365,7 +364,7 @@ public void testValidPropertiesPDFA4F() throws IOException, XMPException { })); AssertUtil.doesNotThrow(() -> { - new PdfA4Checker(conformanceLevel).checkMetaData(catalog); + new PdfA4Checker(conformance).checkMetaData(catalog); }); } @@ -373,23 +372,23 @@ public void testValidPropertiesPDFA4F() throws IOException, XMPException { @Test public void testValidPropertiesPDFA4E() throws IOException, XMPException { String outPdf = DESTINATION_FOLDER + "testValidPropertiesPDFA4E.pdf"; - PdfAConformanceLevel conformanceLevel = PdfAConformanceLevel.PDF_A_4E; - generatePdfADocument(conformanceLevel, outPdf, (doc) -> { + PdfAConformance conformance = PdfAConformance.PDF_A_4E; + generatePdfADocument(conformance, outPdf, (doc) -> { }); PdfADocument pdfADocument = new PdfADocument(new PdfReader(outPdf), new PdfWriter(new ByteArrayOutputStream())); PdfDictionary catalog = generateCustomXmpCatalog(pdfADocument, (xmpMeta -> { })); AssertUtil.doesNotThrow(() -> { - new PdfA4Checker(conformanceLevel).checkMetaData(catalog); + new PdfA4Checker(conformance).checkMetaData(catalog); }); } @Test public void testAbsentConformancePropertyPDFA4F() throws IOException, XMPException { String outPdf = DESTINATION_FOLDER + "testAbsentConformancePropertyPDFA4F.pdf"; - PdfAConformanceLevel conformanceLevel = PdfAConformanceLevel.PDF_A_4F; - generatePdfADocument(conformanceLevel, outPdf, (doc) -> { + PdfAConformance conformance = PdfAConformance.PDF_A_4F; + generatePdfADocument(conformance, outPdf, (doc) -> { PdfFileSpec fs = PdfFileSpec.createEmbeddedFileSpec(doc, "file".getBytes(), "description", "file.txt", null, null, null); doc.addFileAttachment("file.txt", fs); @@ -399,14 +398,14 @@ public void testAbsentConformancePropertyPDFA4F() throws IOException, XMPExcepti xmpMeta.deleteProperty(XMPConst.NS_PDFA_ID, XMPConst.CONFORMANCE); })); - AssertUtil.doesNotThrow(() -> new PdfA4Checker(conformanceLevel).checkMetaData(catalog)); + AssertUtil.doesNotThrow(() -> new PdfA4Checker(conformance).checkMetaData(catalog)); } @Test public void testInvalidConformancePropertyPDFA4F() throws IOException, XMPException { String outPdf = DESTINATION_FOLDER + "testInvalidConformancePropertyPDFA4F.pdf"; - PdfAConformanceLevel conformanceLevel = PdfAConformanceLevel.PDF_A_4F; - generatePdfADocument(conformanceLevel, outPdf, (doc) -> { + PdfAConformance conformance = PdfAConformance.PDF_A_4F; + generatePdfADocument(conformance, outPdf, (doc) -> { PdfFileSpec fs = PdfFileSpec.createEmbeddedFileSpec(doc, "file".getBytes(), "description", "file.txt", null, null, null); doc.addFileAttachment("file.txt", fs); @@ -419,76 +418,76 @@ public void testInvalidConformancePropertyPDFA4F() throws IOException, XMPExcept throw new PdfException(e); } })); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> { - new PdfA4Checker(conformanceLevel).checkMetaData(catalog); + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> { + new PdfA4Checker(conformance).checkMetaData(catalog); }); - Assert.assertEquals( + Assertions.assertEquals( PdfaExceptionMessageConstant.XMP_METADATA_HEADER_SHALL_CONTAIN_VERSION_IDENTIFIER_CONFORMANCE, e.getMessage()); } @Test public void historyWithXmpMetaData() throws IOException, XMPException { - PdfAConformanceLevel conformanceLevel = PdfAConformanceLevel.PDF_A_4; + PdfAConformance conformance = PdfAConformance.PDF_A_4; byte[] bytes = Files.readAllBytes(Paths.get(SOURCE_FOLDER + "xmp/xmpWithCorrectHistory.xmp")); XMPMeta xmpMeta = XMPMetaFactory.parse(new ByteArrayInputStream(bytes)); PdfDictionary catalog = new PdfDictionary(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); XMPMetaFactory.serialize(xmpMeta, baos); catalog.put(PdfName.Metadata, new PdfStream(baos.toByteArray())); - AssertUtil.doesNotThrow(() -> new PdfA4Checker(conformanceLevel).checkMetaData(catalog)); + AssertUtil.doesNotThrow(() -> new PdfA4Checker(conformance).checkMetaData(catalog)); } @Test public void historyWithInvalidWhenXmpMetaData() throws IOException, XMPException { - PdfAConformanceLevel conformanceLevel = PdfAConformanceLevel.PDF_A_4; + PdfAConformance conformance = PdfAConformance.PDF_A_4; byte[] bytes = Files.readAllBytes(Paths.get(SOURCE_FOLDER + "xmp/xmpWithInvalidWhen.xmp")); XMPMeta xmpMeta = XMPMetaFactory.parse(new ByteArrayInputStream(bytes)); PdfDictionary catalog = new PdfDictionary(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); XMPMetaFactory.serialize(xmpMeta, baos); catalog.put(PdfName.Metadata, new PdfStream(baos.toByteArray())); - Exception e = Assert.assertThrows(PdfAConformanceException.class, - () -> new PdfA4Checker(conformanceLevel).checkMetaData(catalog)); - Assert.assertEquals( + Exception e = Assertions.assertThrows(PdfAConformanceException.class, + () -> new PdfA4Checker(conformance).checkMetaData(catalog)); + Assertions.assertEquals( MessageFormatUtil.format(PdfaExceptionMessageConstant.XMP_METADATA_HISTORY_ENTRY_SHALL_CONTAIN_KEY, "stEvt:when"), e.getMessage()); } @Test public void historyWithInvalidActionXmpMetaData() throws IOException, XMPException { - PdfAConformanceLevel conformanceLevel = PdfAConformanceLevel.PDF_A_4; + PdfAConformance conformance = PdfAConformance.PDF_A_4; byte[] bytes = Files.readAllBytes(Paths.get(SOURCE_FOLDER + "xmp/xmpWithInvalidAction.xmp")); XMPMeta xmpMeta = XMPMetaFactory.parse(new ByteArrayInputStream(bytes)); PdfDictionary catalog = new PdfDictionary(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); XMPMetaFactory.serialize(xmpMeta, baos); catalog.put(PdfName.Metadata, new PdfStream(baos.toByteArray())); - Exception e = Assert.assertThrows(PdfAConformanceException.class, - () -> new PdfA4Checker(conformanceLevel).checkMetaData(catalog)); - Assert.assertEquals( + Exception e = Assertions.assertThrows(PdfAConformanceException.class, + () -> new PdfA4Checker(conformance).checkMetaData(catalog)); + Assertions.assertEquals( MessageFormatUtil.format(PdfaExceptionMessageConstant.XMP_METADATA_HISTORY_ENTRY_SHALL_CONTAIN_KEY, "stEvt:action"), e.getMessage()); } @Test public void historyWithEmptyEntryXmpMetaData() throws IOException, XMPException { - PdfAConformanceLevel conformanceLevel = PdfAConformanceLevel.PDF_A_4; + PdfAConformance conformance = PdfAConformance.PDF_A_4; byte[] bytes = Files.readAllBytes(Paths.get(SOURCE_FOLDER + "xmp/xmpWithEmpty.xmp")); XMPMeta xmpMeta = XMPMetaFactory.parse(new ByteArrayInputStream(bytes)); PdfDictionary catalog = new PdfDictionary(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); XMPMetaFactory.serialize(xmpMeta, baos); catalog.put(PdfName.Metadata, new PdfStream(baos.toByteArray())); - new PdfA4Checker(conformanceLevel).checkMetaData(catalog); - Assert.assertTrue(true); + new PdfA4Checker(conformance).checkMetaData(catalog); + Assertions.assertTrue(true); } @Test public void testNullConformancePropertyPDFA4F() throws IOException, XMPException { String outPdf = DESTINATION_FOLDER + "testNullConformancePropertyPDFA4F.pdf"; - PdfAConformanceLevel conformanceLevel = PdfAConformanceLevel.PDF_A_4F; - generatePdfADocument(conformanceLevel, outPdf, (doc) -> { + PdfAConformance conformance = PdfAConformance.PDF_A_4F; + generatePdfADocument(conformance, outPdf, (doc) -> { PdfFileSpec fs = PdfFileSpec.createEmbeddedFileSpec(doc, "file".getBytes(), "description", "file.txt", null, null, null); doc.addFileAttachment("file.txt", fs); @@ -501,10 +500,10 @@ public void testNullConformancePropertyPDFA4F() throws IOException, XMPException throw new PdfException(e); } })); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> { - new PdfA4Checker(conformanceLevel).checkMetaData(catalog); + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> { + new PdfA4Checker(conformance).checkMetaData(catalog); }); - Assert.assertEquals( + Assertions.assertEquals( PdfaExceptionMessageConstant.XMP_METADATA_HEADER_SHALL_CONTAIN_VERSION_IDENTIFIER_CONFORMANCE, e.getMessage()); } @@ -513,7 +512,7 @@ public void testNullConformancePropertyPDFA4F() throws IOException, XMPException public void pdfA4DocumentMetaDataIsNotUTF8Encoded() throws IOException, XMPException { String outPdf = DESTINATION_FOLDER + "metadataNotUTF8.pdf"; PdfWriter writer = new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"))); doc.addNewPage(); @@ -522,10 +521,10 @@ public void pdfA4DocumentMetaDataIsNotUTF8Encoded() throws IOException, XMPExcep ByteArrayOutputStream os = new ByteArrayOutputStream(); XMPMetaFactory.serialize(xmpMeta, os); doc.setXmpMetadata(xmpMeta, new SerializeOptions().setEncodeUTF16BE(true)); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> { + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> { doc.close(); }); - Assert.assertEquals( + Assertions.assertEquals( PdfaExceptionMessageConstant.INVALID_XMP_METADATA_ENCODING, e.getMessage()); } @@ -535,26 +534,26 @@ public void pdfA4DocumentPageMetaDataIsNotUTF8Encoded() throws IOException { byte[] bytes = Files.readAllBytes(Paths.get(SOURCE_FOLDER + "encodedXmp.xmp")); String outPdf = DESTINATION_FOLDER + "metadataNotUTF8.pdf"; PdfWriter writer = new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); - PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_4, + PdfADocument doc = new PdfADocument(writer, PdfAConformance.PDF_A_4, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"))); doc.addNewPage(); doc.getPage(1).setXmpMetadata(bytes); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> { + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> { doc.close(); }); - Assert.assertEquals( + Assertions.assertEquals( PdfaExceptionMessageConstant.INVALID_XMP_METADATA_ENCODING, e.getMessage()); } - private void generatePdfADocument(PdfAConformanceLevel conformanceLevel, String outPdf, + private void generatePdfADocument(PdfAConformance conformance, String outPdf, Consumer consumer) throws IOException { if (outPdf == null) { - Assert.fail(); + Assertions.fail(); } PdfWriter writer = new PdfWriter(outPdf, new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0)); - PdfADocument doc = new PdfADocument(writer, conformanceLevel, + PdfADocument doc = new PdfADocument(writer, conformance, new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", FileUtil.getInputStreamForFile(SOURCE_FOLDER + "sRGB Color Space Profile.icm"))); doc.addNewPage(); @@ -564,7 +563,7 @@ private void generatePdfADocument(PdfAConformanceLevel conformanceLevel, String private static PdfDictionary generateCustomXmpCatalog(PdfADocument pdfADocument, Consumer action) throws XMPException { - XMPMeta xmpMeta = XMPMetaFactory.parse(new ByteArrayInputStream(pdfADocument.getXmpMetadata())); + XMPMeta xmpMeta = pdfADocument.getXmpMetadata(); PdfDictionary catalog = pdfADocument.getCatalog().getPdfObject(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); action.accept(xmpMeta); diff --git a/pdfa/src/test/java/com/itextpdf/pdfa/checker/PdfACheckerTest.java b/pdfa/src/test/java/com/itextpdf/pdfa/checker/PdfACheckerTest.java index ca4554c62f..9fb6e0f5be 100644 --- a/pdfa/src/test/java/com/itextpdf/pdfa/checker/PdfACheckerTest.java +++ b/pdfa/src/test/java/com/itextpdf/pdfa/checker/PdfACheckerTest.java @@ -26,7 +26,7 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.font.PdfFont; import com.itextpdf.kernel.font.PdfTrueTypeFont; import com.itextpdf.kernel.geom.Rectangle; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfAConformance; import com.itextpdf.kernel.pdf.PdfArray; import com.itextpdf.kernel.pdf.PdfCatalog; import com.itextpdf.kernel.pdf.PdfDictionary; @@ -47,24 +47,23 @@ This file is part of the iText (R) project. import com.itextpdf.pdfa.PdfADocument; import com.itextpdf.test.AssertUtil; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; import java.util.Set; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfACheckerTest extends ExtendedITextTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/pdfa/pdfs/"; private PdfAChecker pdfAChecker; - @Before + @BeforeEach public void before() { pdfAChecker = new EmptyPdfAChecker(); pdfAChecker.setFullCheckMode(true); @@ -102,11 +101,12 @@ public void checkAppearanceStreamsWithCycle() throws IOException { @Test() //TODO adapt after DEVSIX-5759 is fixed public void checkContentStreamPdfAText() throws IOException { - PdfA1Checker testChecker = new PdfA1Checker(PdfAConformanceLevel.PDF_A_1B); + PdfA1Checker testChecker = new PdfA1Checker(PdfAConformance.PDF_A_1B); PdfADocument pdfa = new PdfADocument(new PdfReader(new File(SOURCE_FOLDER + "InlineImagesPdfA.pdf")), new PdfWriter(new ByteArrayOutputStream()).setSmartMode(true)); PdfStream firstContentStream = pdfa.getPage(1).getFirstContentStream(); testChecker.setFullCheckMode(true); - Assert.assertThrows("NullPointer was not thrown on inline image.", NullPointerException.class, ()-> testChecker.checkContentStream(firstContentStream)); + Assertions.assertThrows(NullPointerException.class, () -> testChecker.checkContentStream(firstContentStream), + "NullPointer was not thrown on inline image."); } private static class EmptyPdfAChecker extends PdfAChecker { @@ -115,6 +115,11 @@ protected EmptyPdfAChecker() { super(null); } + @Override + public void checkSignatureType(boolean isCAdES) { + + } + @Override public void checkCanvasStack(char stackOperation) { @@ -126,7 +131,7 @@ public void checkInlineImage(PdfStream inlineImage, PdfDictionary currentColorSp } @Override - public void checkColor(Color color, PdfDictionary currentColorSpaces, Boolean fill, PdfStream contentStream) { + public void checkColor(CanvasGraphicsState gState, Color color, PdfDictionary currentColorSpaces, Boolean fill, PdfStream contentStream) { } @@ -161,6 +166,16 @@ public void checkXrefTable(PdfXrefTable xrefTable) { } + @Override + public void checkCrypto(PdfObject crypto) { + + } + + @Override + public void checkText(String text, PdfFont font) { + + } + @Override protected void checkContentStream(PdfStream contentStream) { @@ -202,7 +217,7 @@ protected void checkCatalogValidEntries(PdfDictionary catalogDict) { } @Override - protected void checkColorsUsages() { + protected void checkPageColorsUsages(PdfDictionary pageDict, PdfDictionary pageResources) { } diff --git a/pdfa/src/test/resources/com/itextpdf/pdfa/cmp/PdfA1AnnotationCheckTest/cmp_pdfA1a_annotationCheckTest09.pdf b/pdfa/src/test/resources/com/itextpdf/pdfa/cmp/PdfA1AnnotationCheckTest/cmp_pdfA1a_annotationCheckTest09.pdf index 1d94298d1b..19f2793d77 100644 Binary files a/pdfa/src/test/resources/com/itextpdf/pdfa/cmp/PdfA1AnnotationCheckTest/cmp_pdfA1a_annotationCheckTest09.pdf and b/pdfa/src/test/resources/com/itextpdf/pdfa/cmp/PdfA1AnnotationCheckTest/cmp_pdfA1a_annotationCheckTest09.pdf differ diff --git a/pdfa/src/test/resources/com/itextpdf/pdfa/cmp/PdfA2GraphicsCheckTest/cmp_pdfA2b_colorCheckTest4.pdf b/pdfa/src/test/resources/com/itextpdf/pdfa/cmp/PdfA2GraphicsCheckTest/cmp_pdfA2b_colorCheckTest4.pdf deleted file mode 100644 index ca0fc0546f..0000000000 Binary files a/pdfa/src/test/resources/com/itextpdf/pdfa/cmp/PdfA2GraphicsCheckTest/cmp_pdfA2b_colorCheckTest4.pdf and /dev/null differ diff --git a/pdfa/src/test/resources/com/itextpdf/pdfa/cmp/PdfA2GraphicsCheckTest/cmp_pdfA2b_colorCheckTest6.pdf b/pdfa/src/test/resources/com/itextpdf/pdfa/cmp/PdfA2GraphicsCheckTest/cmp_pdfA2b_colorCheckTest6.pdf deleted file mode 100644 index 2a5ba75b8a..0000000000 Binary files a/pdfa/src/test/resources/com/itextpdf/pdfa/cmp/PdfA2GraphicsCheckTest/cmp_pdfA2b_colorCheckTest6.pdf and /dev/null differ diff --git a/pdfa/src/test/resources/com/itextpdf/pdfa/cmp/PdfA2GraphicsCheckTest/cmp_pdfA2b_colorCheckTest7.pdf b/pdfa/src/test/resources/com/itextpdf/pdfa/cmp/PdfA2GraphicsCheckTest/cmp_pdfA2b_colorCheckTest7.pdf deleted file mode 100644 index 89885ae339..0000000000 Binary files a/pdfa/src/test/resources/com/itextpdf/pdfa/cmp/PdfA2GraphicsCheckTest/cmp_pdfA2b_colorCheckTest7.pdf and /dev/null differ diff --git a/pdfa/src/test/resources/com/itextpdf/pdfa/cmp/PdfA4ActionCheckTest/cmp_GoTo3Dview.pdf b/pdfa/src/test/resources/com/itextpdf/pdfa/cmp/PdfA4ActionCheckTest/cmp_GoTo3Dview.pdf deleted file mode 100644 index aa615c7892..0000000000 Binary files a/pdfa/src/test/resources/com/itextpdf/pdfa/cmp/PdfA4ActionCheckTest/cmp_GoTo3Dview.pdf and /dev/null differ diff --git a/pdfa/src/test/resources/com/itextpdf/pdfa/cmp/PdfA4ActionCheckTest/cmp_pdfA4ESetOcgState.pdf b/pdfa/src/test/resources/com/itextpdf/pdfa/cmp/PdfA4ActionCheckTest/cmp_pdfA4ESetOcgState.pdf deleted file mode 100644 index 7524fd4868..0000000000 Binary files a/pdfa/src/test/resources/com/itextpdf/pdfa/cmp/PdfA4ActionCheckTest/cmp_pdfA4ESetOcgState.pdf and /dev/null differ diff --git a/pdfa/src/test/resources/com/itextpdf/pdfa/cmp/PdfA4CatalogCheckTest/cmp_invalidOperatorTest.pdf b/pdfa/src/test/resources/com/itextpdf/pdfa/cmp/PdfA4CatalogCheckTest/cmp_invalidOperatorTest.pdf deleted file mode 100644 index 0f1058f591..0000000000 Binary files a/pdfa/src/test/resources/com/itextpdf/pdfa/cmp/PdfA4CatalogCheckTest/cmp_invalidOperatorTest.pdf and /dev/null differ diff --git a/pdfa/src/test/resources/com/itextpdf/pdfa/cmp/PdfAFormFieldTest/cmp_pdfA1DocWithPdfA1ChoiceField.pdf b/pdfa/src/test/resources/com/itextpdf/pdfa/cmp/PdfAFormFieldTest/cmp_pdfA1DocWithPdfA1ChoiceField.pdf index 1e27c9906c..7936559ba2 100644 Binary files a/pdfa/src/test/resources/com/itextpdf/pdfa/cmp/PdfAFormFieldTest/cmp_pdfA1DocWithPdfA1ChoiceField.pdf and b/pdfa/src/test/resources/com/itextpdf/pdfa/cmp/PdfAFormFieldTest/cmp_pdfA1DocWithPdfA1ChoiceField.pdf differ diff --git a/pdfa/src/test/resources/com/itextpdf/pdfa/cmp/PdfAFormFieldTest/cmp_pdfA1DocWithPdfA1ComboBoxField.pdf b/pdfa/src/test/resources/com/itextpdf/pdfa/cmp/PdfAFormFieldTest/cmp_pdfA1DocWithPdfA1ComboBoxField.pdf index 619b096a9f..4d84455d50 100644 Binary files a/pdfa/src/test/resources/com/itextpdf/pdfa/cmp/PdfAFormFieldTest/cmp_pdfA1DocWithPdfA1ComboBoxField.pdf and b/pdfa/src/test/resources/com/itextpdf/pdfa/cmp/PdfAFormFieldTest/cmp_pdfA1DocWithPdfA1ComboBoxField.pdf differ diff --git a/pdfa/src/test/resources/com/itextpdf/pdfa/cmp/PdfAFormFieldTest/cmp_pdfA1DocWithPdfA1ListField.pdf b/pdfa/src/test/resources/com/itextpdf/pdfa/cmp/PdfAFormFieldTest/cmp_pdfA1DocWithPdfA1ListField.pdf index d7bfead506..abec3ad555 100644 Binary files a/pdfa/src/test/resources/com/itextpdf/pdfa/cmp/PdfAFormFieldTest/cmp_pdfA1DocWithPdfA1ListField.pdf and b/pdfa/src/test/resources/com/itextpdf/pdfa/cmp/PdfAFormFieldTest/cmp_pdfA1DocWithPdfA1ListField.pdf differ diff --git a/pdfa/src/test/resources/com/itextpdf/pdfa/cmp/PdfAFormFieldTest/cmp_testButtonNoFont.pdf b/pdfa/src/test/resources/com/itextpdf/pdfa/cmp/PdfAFormFieldTest/cmp_testButtonNoFont.pdf deleted file mode 100644 index c0bd611a0b..0000000000 Binary files a/pdfa/src/test/resources/com/itextpdf/pdfa/cmp/PdfAFormFieldTest/cmp_testButtonNoFont.pdf and /dev/null differ diff --git a/pdfa/src/test/resources/com/itextpdf/pdfa/cmp/PdfAFormFieldTest/cmp_testComboBoxNoFont.pdf b/pdfa/src/test/resources/com/itextpdf/pdfa/cmp/PdfAFormFieldTest/cmp_testComboBoxNoFont.pdf deleted file mode 100644 index 331f19c66f..0000000000 Binary files a/pdfa/src/test/resources/com/itextpdf/pdfa/cmp/PdfAFormFieldTest/cmp_testComboBoxNoFont.pdf and /dev/null differ diff --git a/pdfa/src/test/resources/com/itextpdf/pdfa/cmp/PdfAFormFieldTest/cmp_testMultipleCombinationsDefaultFont.pdf b/pdfa/src/test/resources/com/itextpdf/pdfa/cmp/PdfAFormFieldTest/cmp_testMultipleCombinationsDefaultFont.pdf deleted file mode 100644 index 791ee94be5..0000000000 Binary files a/pdfa/src/test/resources/com/itextpdf/pdfa/cmp/PdfAFormFieldTest/cmp_testMultipleCombinationsDefaultFont.pdf and /dev/null differ diff --git a/pdfa/src/test/resources/com/itextpdf/pdfa/cmp/PdfAFormFieldTest/cmp_testMultipleCombinationsWriteAndLoad.pdf b/pdfa/src/test/resources/com/itextpdf/pdfa/cmp/PdfAFormFieldTest/cmp_testMultipleCombinationsWriteAndLoad.pdf index 28535fd9c8..d570819439 100644 Binary files a/pdfa/src/test/resources/com/itextpdf/pdfa/cmp/PdfAFormFieldTest/cmp_testMultipleCombinationsWriteAndLoad.pdf and b/pdfa/src/test/resources/com/itextpdf/pdfa/cmp/PdfAFormFieldTest/cmp_testMultipleCombinationsWriteAndLoad.pdf differ diff --git a/pdftest/pom.xml b/pdftest/pom.xml index 68020837ff..886698c1d0 100644 --- a/pdftest/pom.xml +++ b/pdftest/pom.xml @@ -5,7 +5,7 @@ com.itextpdf root - 8.0.5 + 9.0.0 pdftest @@ -16,7 +16,6 @@ true 1.25.125 - 5.10.2 @@ -40,21 +39,11 @@ logback-classic ${logback.version} - - junit - junit - ${junit.version} - org.junit.jupiter junit-jupiter ${junit.jupiter.version} - - org.junit.vintage - junit-vintage-engine - ${junit.jupiter.version} - diff --git a/pdftest/src/main/java/com/itextpdf/test/AssertUtil.java b/pdftest/src/main/java/com/itextpdf/test/AssertUtil.java index 70791d16c1..34a6858257 100644 --- a/pdftest/src/main/java/com/itextpdf/test/AssertUtil.java +++ b/pdftest/src/main/java/com/itextpdf/test/AssertUtil.java @@ -22,7 +22,7 @@ This file is part of the iText (R) project. */ package com.itextpdf.test; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; /** * Utilities class for assertion operation. @@ -43,7 +43,7 @@ public static void doesNotThrow(Executor executor) { try { executor.execute(); } catch (Exception ex) { - Assert.fail(ex.getMessage()); + Assertions.fail(ex.getMessage()); } } @@ -59,7 +59,7 @@ public static void doesNotThrow(Executor executor, String message) { try { executor.execute(); } catch (Exception ex) { - Assert.fail(message); + Assertions.fail(message); } } } diff --git a/pdftest/src/main/java/com/itextpdf/test/ExtendedITextTest.java b/pdftest/src/main/java/com/itextpdf/test/ExtendedITextTest.java index 4662bc41d3..8bff8064a3 100644 --- a/pdftest/src/main/java/com/itextpdf/test/ExtendedITextTest.java +++ b/pdftest/src/main/java/com/itextpdf/test/ExtendedITextTest.java @@ -22,9 +22,6 @@ This file is part of the iText (R) project. */ package com.itextpdf.test; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.extension.ExtendWith; @@ -37,14 +34,10 @@ This file is part of the iText (R) project. @ExtendWith(LogListener.class) public abstract class ExtendedITextTest extends ITextTest { - @Rule - public LogListener logListener = new LogListener(); - /** * This method is called before each test method is executed */ @BeforeEach - @Before public void beforeTestMethodAction(){ } @@ -52,7 +45,6 @@ public void beforeTestMethodAction(){ * This method is called after each test method is executed */ @AfterEach - @After public void afterTestMethodAction(){ } } diff --git a/pdftest/src/main/java/com/itextpdf/test/ITextTest.java b/pdftest/src/main/java/com/itextpdf/test/ITextTest.java index cd32e086cb..512da08201 100644 --- a/pdftest/src/main/java/com/itextpdf/test/ITextTest.java +++ b/pdftest/src/main/java/com/itextpdf/test/ITextTest.java @@ -24,14 +24,14 @@ This file is part of the iText (R) project. import java.io.ByteArrayOutputStream; import java.io.File; -import java.io.FileInputStream; import java.io.IOException; +import java.io.InputStream; import java.lang.reflect.Field; import java.lang.reflect.Modifier; +import java.nio.file.Files; +import java.nio.file.Paths; import java.util.concurrent.TimeUnit; -import org.junit.Rule; -import org.junit.rules.Timeout; /** * This is a generic class for testing. Subclassing it, or its subclasses is considered a good practice of @@ -40,9 +40,6 @@ This file is part of the iText (R) project. @org.junit.jupiter.api.Timeout(value = 5, unit = TimeUnit.MINUTES) public abstract class ITextTest { - @Rule - public Timeout testTimeout = getTestTimeout(); - /** * Creates a folder with a given path, including all necessary nonexistent parent directories. * If a folder is already present, no action is performed. @@ -143,12 +140,8 @@ public static void printPathToConsole(String path, String comment) { System.out.println(comment + "file://" + new File(path).toURI().normalize().getPath()); } - protected Timeout getTestTimeout() { - return new Timeout(5, TimeUnit.MINUTES); - } - protected byte[] readFile(String filename) throws IOException { - FileInputStream input = new FileInputStream(filename); + InputStream input = Files.newInputStream(Paths.get(filename)); ByteArrayOutputStream output = new ByteArrayOutputStream(); byte[] buffer = new byte[8192]; int read; diff --git a/pdftest/src/main/java/com/itextpdf/test/LogListener.java b/pdftest/src/main/java/com/itextpdf/test/LogListener.java index fd4e2c5bd8..c8f2e4d98a 100644 --- a/pdftest/src/main/java/com/itextpdf/test/LogListener.java +++ b/pdftest/src/main/java/com/itextpdf/test/LogListener.java @@ -33,23 +33,17 @@ This file is part of the iText (R) project. import ch.qos.logback.classic.spi.StackTraceElementProxy; import ch.qos.logback.core.Appender; import ch.qos.logback.core.read.ListAppender; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import org.junit.jupiter.api.extension.AfterEachCallback; import org.junit.jupiter.api.extension.BeforeEachCallback; import org.junit.jupiter.api.extension.ExtensionContext; -import org.junit.rules.TestWatcher; -import org.junit.runner.Description; import org.slf4j.ILoggerFactory; import org.slf4j.LoggerFactory; import org.slf4j.helpers.SubstituteLoggerFactory; -import java.lang.annotation.Annotation; -public class LogListener extends TestWatcher implements BeforeEachCallback, AfterEachCallback { +public class LogListener implements BeforeEachCallback, AfterEachCallback { private static final String ROOT_ITEXT_PACKAGE = "com.itextpdf"; private static final String ITEXT_LICENCING_PACKAGE = "com.itextpdf.licensing"; @@ -67,43 +61,13 @@ public LogListener() { } @Override - public void beforeEach(ExtensionContext extensionContext) throws Exception { - Description description = convertToDescription(extensionContext); - before(description); + public void beforeEach(ExtensionContext extensionContext) { + before(extensionContext); } @Override - public void afterEach(ExtensionContext extensionContext) throws Exception { - Description description = convertToDescription(extensionContext); - checkLogMessages(description); - after(); - } - - private static Description convertToDescription(ExtensionContext extensionContext) { - Method testMethod = extensionContext.getRequiredTestMethod(); - Class testClass = extensionContext.getRequiredTestClass(); - - Annotation[] methodAnnotations = testMethod.getAnnotations(); - Annotation[] classAnnotations = testClass.getAnnotations(); - - List allAnnotations = new ArrayList<>(); - - Collections.addAll(allAnnotations, methodAnnotations); - - Collections.addAll(allAnnotations, classAnnotations); - - Annotation[] annotationsArray = allAnnotations.toArray(new Annotation[0]); - return Description.createTestDescription(testClass, testMethod.getName(), annotationsArray); - } - - @Override - protected void starting(Description description) { - before(description); - } - - @Override - protected void finished(Description description) { - checkLogMessages(description); + public void afterEach(ExtensionContext context) { + checkLogMessages(context); after(); } @@ -148,10 +112,10 @@ public int getSize() { return listAppender.list.size(); } - private void before(Description description) { + private void before(ExtensionContext context) { listAppender.clear(); - LogMessages logMessages = LoggerHelper.getTestAnnotation(description, LogMessages.class); + LogMessages logMessages = LoggerHelper.getTestAnnotation(context, LogMessages.class); if (logMessages != null) { Map expectedTemplates = new HashMap<>(); LogMessage[] messages = logMessages.messages(); @@ -190,8 +154,8 @@ private void resetLoggingContext() { } } - private void checkLogMessages(Description description) { - LogMessages logMessages = LoggerHelper.getTestAnnotation(description, LogMessages.class); + private void checkLogMessages(ExtensionContext context) { + LogMessages logMessages = LoggerHelper.getTestAnnotation(context, LogMessages.class); int checkedMessages = 0; if (logMessages != null) { LogMessage[] messages = logMessages.messages(); @@ -199,14 +163,14 @@ private void checkLogMessages(Description description) { int foundCount = contains(logMessage); if (foundCount != logMessage.count() && !logMessages.ignore() && !logMessage.ignore()) { LoggerHelper.failWrongMessageCount(logMessage.count(), foundCount, logMessage.messageTemplate(), - description); + context); } else { checkedMessages += foundCount; } } } if (getSize() > checkedMessages) { - LoggerHelper.failWrongTotalCount(getSize(), checkedMessages, description); + LoggerHelper.failWrongTotalCount(getSize(), checkedMessages, context); } } diff --git a/pdftest/src/main/java/com/itextpdf/test/LoggerHelper.java b/pdftest/src/main/java/com/itextpdf/test/LoggerHelper.java index a658e5cc56..82e98dcb19 100644 --- a/pdftest/src/main/java/com/itextpdf/test/LoggerHelper.java +++ b/pdftest/src/main/java/com/itextpdf/test/LoggerHelper.java @@ -33,29 +33,29 @@ This file is part of the iText (R) project. import java.util.regex.Pattern; import java.lang.annotation.Annotation; import java.text.MessageFormat; -import org.junit.Assert; -import org.junit.runner.Description; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.extension.ExtensionContext; import org.slf4j.LoggerFactory; public class LoggerHelper { - static T getTestAnnotation(Description description, Class annotationClass) { - T annotation = description.getAnnotation(annotationClass); + static T getTestAnnotation(ExtensionContext context, Class annotationClass) { + T annotation = context.getRequiredTestMethod().getAnnotation(annotationClass); if (annotation == null) { - annotation = description.getTestClass().getAnnotation(annotationClass); + annotation = context.getRequiredTestClass().getAnnotation(annotationClass); } return annotation; } - static void failWrongMessageCount(int expected, int actual, String messageTemplate, Description description) { - Assert.fail(MessageFormat.format("{0}:{1} Expected to find {2}, but found {3} messages with the following content: \"{4}\"", - description.getClassName(), description.getMethodName(), expected, actual, messageTemplate)); + static void failWrongMessageCount(int expected, int actual, String messageTemplate, ExtensionContext context) { + Assertions.fail(MessageFormat.format("{0}:{1} Expected to find {2}, but found {3} messages with the following content: \"{4}\"", + context.getRequiredTestClass().getName(), context.getRequiredTestMethod().getName(), expected, actual, messageTemplate)); } - static void failWrongTotalCount(int expected, int actual, Description description) { - Assert.fail(MessageFormat.format("{0}.{1}: The test does not check the message logging - {2} messages", - description.getClassName(), - description.getMethodName(), + static void failWrongTotalCount(int expected, int actual, ExtensionContext context) { + Assertions.fail(MessageFormat.format("{0}.{1}: The test does not check the message logging - {2} messages", + context.getRequiredTestClass().getName(), + context.getRequiredTestMethod().getName(), expected - actual)); } diff --git a/pdftest/src/main/java/com/itextpdf/test/annotations/type/BouncyCastleIntegrationTest.java b/pdftest/src/main/java/com/itextpdf/test/annotations/type/BouncyCastleIntegrationTest.java deleted file mode 100644 index 99ff65eea5..0000000000 --- a/pdftest/src/main/java/com/itextpdf/test/annotations/type/BouncyCastleIntegrationTest.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - This file is part of the iText (R) project. - Copyright (c) 1998-2024 Apryse Group NV - Authors: Apryse Software. - - This program is offered under a commercial and under the AGPL license. - For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. - - AGPL licensing: - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . - */ -package com.itextpdf.test.annotations.type; - -/** - * Integration tests which need to be run with several different bouncy-castle dependencies. - */ -public interface BouncyCastleIntegrationTest extends IntegrationTest { -} diff --git a/pdftest/src/main/java/com/itextpdf/test/annotations/type/IntegrationTest.java b/pdftest/src/main/java/com/itextpdf/test/annotations/type/IntegrationTest.java deleted file mode 100644 index 3104cec320..0000000000 --- a/pdftest/src/main/java/com/itextpdf/test/annotations/type/IntegrationTest.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - This file is part of the iText (R) project. - Copyright (c) 1998-2024 Apryse Group NV - Authors: Apryse Software. - - This program is offered under a commercial and under the AGPL license. - For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. - - AGPL licensing: - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . - */ -package com.itextpdf.test.annotations.type; - -/** - * Tests that cover more functionality than a simple Unit Test. Contrary to Unit - * Tests, they don't use mocked objects but real objects. These tests are - * intended to check end-to-end functionality of a feature. - *

    - * For example, if a test creates a Document, manipulates it, writes the result - * to disk, and then compares the file with a reference document, then it is - * definitely not a Unit Test but most likely an Integration Test. - */ -public interface IntegrationTest extends SlowTest { -} diff --git a/pdftest/src/main/java/com/itextpdf/test/annotations/type/SampleTest.java b/pdftest/src/main/java/com/itextpdf/test/annotations/type/SampleTest.java deleted file mode 100644 index 3187db6a6e..0000000000 --- a/pdftest/src/main/java/com/itextpdf/test/annotations/type/SampleTest.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - This file is part of the iText (R) project. - Copyright (c) 1998-2024 Apryse Group NV - Authors: Apryse Software. - - This program is offered under a commercial and under the AGPL license. - For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. - - AGPL licensing: - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . - */ -package com.itextpdf.test.annotations.type; - -/** - * Sample Tests give a Short, Self Contained, - * Correct, Example and can be used as documentation for end users. - */ -public interface SampleTest extends IntegrationTest { -} diff --git a/pdftest/src/main/java/com/itextpdf/test/annotations/type/UnitTest.java b/pdftest/src/main/java/com/itextpdf/test/annotations/type/UnitTest.java deleted file mode 100644 index b81e1e7621..0000000000 --- a/pdftest/src/main/java/com/itextpdf/test/annotations/type/UnitTest.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - This file is part of the iText (R) project. - Copyright (c) 1998-2024 Apryse Group NV - Authors: Apryse Software. - - This program is offered under a commercial and under the AGPL license. - For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. - - AGPL licensing: - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . - */ -package com.itextpdf.test.annotations.type; - -/** - * Unit Tests are used to check individual units of source code. A unit test - * will only use the Testing Framework and the individual unit that is being - * tested, but does not depend on any other functionality of the Software Under - * Test. - *

    - * A simple rule to determine if you have written a unit test: if your test - * produces a PDF file and uses the CompareTool to verify it with a sample file, - * then it is not a unit test. - *

    - * Typically a unit test will run very fast. - */ -public interface UnitTest { -} diff --git a/pdftest/src/main/java/com/itextpdf/test/pdfa/VeraPdfValidator.java b/pdftest/src/main/java/com/itextpdf/test/pdfa/VeraPdfValidator.java index 4e0a8e0412..839095f40e 100644 --- a/pdftest/src/main/java/com/itextpdf/test/pdfa/VeraPdfValidator.java +++ b/pdftest/src/main/java/com/itextpdf/test/pdfa/VeraPdfValidator.java @@ -25,6 +25,8 @@ This file is part of the iText (R) project. import java.io.File; import java.io.FileOutputStream; import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; import java.util.Collections; import java.util.EnumSet; import java.util.logging.Level; @@ -79,7 +81,7 @@ public String validate(String filePath) { BatchSummary summary = processor.process(Collections.singletonList(new File(filePath)), ProcessorFactory.getHandler(FormatOption.XML, true, - new FileOutputStream(String.valueOf(xmlReport)), false)); + Files.newOutputStream(Paths.get(String.valueOf(xmlReport))), false)); LogsSummary logsSummary = LogsSummaryImpl.getSummary(); String xmlReportPath = "file://" + xmlReport.toURI().normalize().getPath(); diff --git a/pdftest/src/main/java/com/itextpdf/test/runners/RetryOnFailure.java b/pdftest/src/main/java/com/itextpdf/test/runners/RetryOnFailure.java deleted file mode 100644 index 79420b4eb8..0000000000 --- a/pdftest/src/main/java/com/itextpdf/test/runners/RetryOnFailure.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - This file is part of the iText (R) project. - Copyright (c) 1998-2024 Apryse Group NV - Authors: Apryse Software. - - This program is offered under a commercial and under the AGPL license. - For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. - - AGPL licensing: - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . - */ -package com.itextpdf.test.runners; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * In current implementation it has no specified retries count - */ -@Retention(RetentionPolicy.CLASS) -@Target({ ElementType.METHOD}) -public @interface RetryOnFailure {} diff --git a/pdftest/src/main/java/com/itextpdf/test/runners/RetryRunner.java b/pdftest/src/main/java/com/itextpdf/test/runners/RetryRunner.java deleted file mode 100644 index 67a62fb2fe..0000000000 --- a/pdftest/src/main/java/com/itextpdf/test/runners/RetryRunner.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - This file is part of the iText (R) project. - Copyright (c) 1998-2024 Apryse Group NV - Authors: Apryse Software. - - This program is offered under a commercial and under the AGPL license. - For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. - - AGPL licensing: - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . - */ -package com.itextpdf.test.runners; - -import org.junit.AssumptionViolatedException; -import org.junit.Ignore; -import org.junit.internal.runners.model.EachTestNotifier; -import org.junit.runner.Description; -import org.junit.runner.notification.RunNotifier; -import org.junit.runner.notification.StoppedByUserException; -import org.junit.runners.BlockJUnit4ClassRunner; -import org.junit.runners.model.FrameworkMethod; -import org.junit.runners.model.InitializationError; -import org.junit.runners.model.Statement; - -/** - * This class is used for flaky test retry after failure. - * In current implementation we use specified retryCount = 3 - */ -public class RetryRunner extends BlockJUnit4ClassRunner { - private final int retryCount = 3; - private int failedAttempts = 0; - - public RetryRunner(Class klass) throws InitializationError { - super(klass); - } - - /** - * - * @param notifier RunNotifier - */ - public void run(RunNotifier notifier) { - EachTestNotifier eachTestNotifier = new EachTestNotifier(notifier, getDescription()); - Statement statement = classBlock(notifier); - try { - statement.evaluate(); - } catch (AssumptionViolatedException ave) { - eachTestNotifier.fireTestIgnored(); - } catch (StoppedByUserException sue) { - throw sue; - } catch (Throwable throwable) { - retry(eachTestNotifier, statement, throwable); - } - } - - /** - * - * @param method FrameworkMethod - * @param notifier RunNotifier - */ - @Override - protected void runChild(final FrameworkMethod method, RunNotifier notifier) { - Description description = describeChild(method); - if (method.getAnnotation(Ignore.class) != null) { - notifier.fireTestIgnored(description); - } else { - runTestUnit(methodBlock(method), description, notifier); - } - } - - /** - * Runs an atomic test - * - * @param statement Statement - * @param description Description - * @param notifier RunNotifier - */ - protected final void runTestUnit(Statement statement, Description description, - RunNotifier notifier) { - failedAttempts = 0; - EachTestNotifier eachNotifier = new EachTestNotifier(notifier, description); - eachNotifier.fireTestStarted(); - try { - statement.evaluate(); - } catch (AssumptionViolatedException avee) { - eachNotifier.addFailedAssumption(avee); - } catch (Throwable e) { - retry(eachNotifier, statement, e); - } finally { - eachNotifier.fireTestFinished(); - } - } - - /** - * Retry method, counts failed attempts, adds logging messages - * @param notifier EachTestNotifier - * @param statement Statement - * @param currentThrowable Throwable - */ - private void retry(EachTestNotifier notifier, Statement statement, Throwable currentThrowable) { - Throwable caughtThrowable = currentThrowable; - while (retryCount > failedAttempts) { - try { - statement.evaluate(); - break; - } catch (Throwable e) { - System.out.println("Test Failed on attempt #" + (failedAttempts + 1)); - failedAttempts++; - caughtThrowable = e; - } - } - notifier.addFailure(caughtThrowable); - } -} diff --git a/pdftest/src/main/java/com/itextpdf/test/signutils/Pkcs12FileHelper.java b/pdftest/src/main/java/com/itextpdf/test/signutils/Pkcs12FileHelper.java index 92dece37ac..f3f2d3a957 100644 --- a/pdftest/src/main/java/com/itextpdf/test/signutils/Pkcs12FileHelper.java +++ b/pdftest/src/main/java/com/itextpdf/test/signutils/Pkcs12FileHelper.java @@ -22,7 +22,6 @@ This file is part of the iText (R) project. */ package com.itextpdf.test.signutils; -import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; @@ -51,7 +50,7 @@ public static Certificate[] readFirstChain(String p12FileName, char[] ksPass) Certificate[] certChain = null; KeyStore p12 = KeyStore.getInstance("pkcs12"); - p12.load(new FileInputStream(p12FileName), ksPass); + p12.load(Files.newInputStream(Paths.get(p12FileName)), ksPass); Enumeration aliases = p12.aliases(); while (aliases.hasMoreElements()) { @@ -78,7 +77,7 @@ public static PrivateKey readFirstKey(String p12FileName, char[] ksPass, char[] PrivateKey pk = null; KeyStore p12 = KeyStore.getInstance("pkcs12"); - p12.load(new FileInputStream(p12FileName), ksPass); + p12.load(Files.newInputStream(Paths.get(p12FileName)), ksPass); Enumeration aliases = p12.aliases(); while (aliases.hasMoreElements()) { diff --git a/pdftest/src/test/java/com/itextpdf/test/LoggerHelperTest.java b/pdftest/src/test/java/com/itextpdf/test/LoggerHelperTest.java index a217903bc4..08ef560db0 100644 --- a/pdftest/src/test/java/com/itextpdf/test/LoggerHelperTest.java +++ b/pdftest/src/test/java/com/itextpdf/test/LoggerHelperTest.java @@ -22,118 +22,117 @@ This file is part of the iText (R) project. */ package com.itextpdf.test; -import com.itextpdf.test.annotations.type.UnitTest; import java.text.MessageFormat; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class LoggerHelperTest extends ExtendedITextTest { @Test public void notEqualMessageWithSimilarStartTest() { String pattern = "There might be a message: {0} with text."; String example = "There might be a message: TEMP with text. And add some other text."; - Assert.assertFalse(LoggerHelper.equalsMessageByTemplate(example, pattern)); + Assertions.assertFalse(LoggerHelper.equalsMessageByTemplate(example, pattern)); } @Test public void notEqualMessageWithSimilarEndTest() { String pattern = "a message: {0} with text."; String example = "There might be a message: TEMP with text."; - Assert.assertFalse(LoggerHelper.equalsMessageByTemplate(example, pattern)); + Assertions.assertFalse(LoggerHelper.equalsMessageByTemplate(example, pattern)); } @Test public void equalsMessageByTemplate() { String pattern = "There might be a message: {0}"; String example = MessageFormat.format(pattern, "message"); - Assert.assertTrue(LoggerHelper.equalsMessageByTemplate(example, pattern)); + Assertions.assertTrue(LoggerHelper.equalsMessageByTemplate(example, pattern)); } @Test public void equalsMessageByTemplateWithEmptyParameter() { String pattern = "There might be a message: {0}"; String example = MessageFormat.format(pattern, "message"); - Assert.assertTrue(LoggerHelper.equalsMessageByTemplate(example, pattern)); + Assertions.assertTrue(LoggerHelper.equalsMessageByTemplate(example, pattern)); } @Test public void equalsMessageByTemplateWithMultipleParameters() { String pattern = "There might be messages: {0} {1}"; String example = MessageFormat.format(pattern, "message1", "message2"); - Assert.assertTrue(LoggerHelper.equalsMessageByTemplate(example, pattern)); + Assertions.assertTrue(LoggerHelper.equalsMessageByTemplate(example, pattern)); } @Test public void equalsMessageByTemplateWithQuotes() { String pattern = "There might be a message '': {0}"; String example = "There might be a message ': message"; - Assert.assertTrue(LoggerHelper.equalsMessageByTemplate(example, pattern)); + Assertions.assertTrue(LoggerHelper.equalsMessageByTemplate(example, pattern)); } @Test public void equalsMessageByTemplateWithCyrillic() { String pattern = "There might be a cyrillic message: {0}"; String example = MessageFormat.format(pattern, "сообщение"); - Assert.assertTrue(LoggerHelper.equalsMessageByTemplate(example, pattern)); + Assertions.assertTrue(LoggerHelper.equalsMessageByTemplate(example, pattern)); } @Test public void equalsMessageByTemplateWithAsterisks() { String pattern = "some text * *** {0}"; String example = MessageFormat.format(pattern, "message"); - Assert.assertTrue(LoggerHelper.equalsMessageByTemplate(example, pattern)); + Assertions.assertTrue(LoggerHelper.equalsMessageByTemplate(example, pattern)); } @Test public void equalsMessageByTemplateWithBrackets() { String pattern = "some text ( ) (0) ( {0}"; String example = MessageFormat.format(pattern, "message"); - Assert.assertTrue(LoggerHelper.equalsMessageByTemplate(example, pattern)); + Assertions.assertTrue(LoggerHelper.equalsMessageByTemplate(example, pattern)); } @Test public void equalsMessageByTemplateWithSquareBrackets() { String pattern = "some text [ ] [0] [ {0}"; String example = MessageFormat.format(pattern, "message"); - Assert.assertTrue(LoggerHelper.equalsMessageByTemplate(example, pattern)); + Assertions.assertTrue(LoggerHelper.equalsMessageByTemplate(example, pattern)); } @Test public void equalsMessageByTemplateWithQuestionSign() { String pattern = "some text ? ??? .*? {0}"; String example = MessageFormat.format(pattern, "message"); - Assert.assertTrue(LoggerHelper.equalsMessageByTemplate(example, pattern)); + Assertions.assertTrue(LoggerHelper.equalsMessageByTemplate(example, pattern)); } @Test public void equalsMessageByTemplateWithDot() { String pattern = "some text . ... .* {0}"; String example = MessageFormat.format(pattern, "message"); - Assert.assertTrue(LoggerHelper.equalsMessageByTemplate(example, pattern)); + Assertions.assertTrue(LoggerHelper.equalsMessageByTemplate(example, pattern)); } @Test public void equalsMessageByTemplateWithBraces() { String pattern = "some text {} {a} { {0}"; String example = "some text {} {a} { message"; - Assert.assertTrue(LoggerHelper.equalsMessageByTemplate(example, pattern)); + Assertions.assertTrue(LoggerHelper.equalsMessageByTemplate(example, pattern)); } @Test public void equalsComplicatedMessageByTemplate() { String pattern = "Not supported list style type ? {a} [b] . * (not working) {0}"; String example = "Not supported list style type ? {a} [b] . * (not working) *some phrase instead of template*"; - Assert.assertTrue(LoggerHelper.equalsMessageByTemplate(example, pattern)); + Assertions.assertTrue(LoggerHelper.equalsMessageByTemplate(example, pattern)); } @Test public void notEqualsMessageByTemplate() { String pattern = "There might be a message: {0}"; String example = "There should be a message: message"; - Assert.assertFalse(LoggerHelper.equalsMessageByTemplate(example, pattern)); + Assertions.assertFalse(LoggerHelper.equalsMessageByTemplate(example, pattern)); } } diff --git a/pdftest/src/test/java/com/itextpdf/test/VeraPdfLoggerValidationTest.java b/pdftest/src/test/java/com/itextpdf/test/VeraPdfLoggerValidationTest.java index 49e3ba752e..d652037141 100644 --- a/pdftest/src/test/java/com/itextpdf/test/VeraPdfLoggerValidationTest.java +++ b/pdftest/src/test/java/com/itextpdf/test/VeraPdfLoggerValidationTest.java @@ -22,24 +22,23 @@ This file is part of the iText (R) project. */ package com.itextpdf.test; -import com.itextpdf.test.annotations.type.UnitTest; import com.itextpdf.test.pdfa.VeraPdfValidator; import com.itextpdf.test.utils.FileUtil; import java.io.IOException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; // Android-Conversion-Skip-File (TODO DEVSIX-7377 introduce pdf\a validation on Android) -@Category(UnitTest.class) +@Tag("UnitTest") public class VeraPdfLoggerValidationTest extends ExtendedITextTest { static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/pdftest/cmp/VeraPdfLoggerValidationTest/"; static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/pdftest/VeraPdfLoggerValidationTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(DESTINATION_FOLDER); } @@ -49,7 +48,7 @@ public void checkValidatorLogsNoOutputTest() throws IOException { String source = "pdfA2b_checkValidatorLogsTest.pdf"; String target = "checkValidatorLogsNoOutputTest.pdf"; FileUtil.copy(SOURCE_FOLDER + source, DESTINATION_FOLDER + target); - Assert.assertNull(new VeraPdfValidator().validate(DESTINATION_FOLDER + target)); + Assertions.assertNull(new VeraPdfValidator().validate(DESTINATION_FOLDER + target)); } @Test @@ -61,7 +60,7 @@ public void checkValidatorLogsWithWarningTest() throws IOException { + "WARNING: Invalid embedded cff font. Charset range exceeds number of glyphs\n" + "WARNING: Missing OutputConditionIdentifier in an output intent dictionary\n" + "WARNING: The Top DICT does not begin with ROS operator"; - Assert.assertEquals(expectedWarningsForFileWithWarnings, new VeraPdfValidator().validate(DESTINATION_FOLDER + target)); + Assertions.assertEquals(expectedWarningsForFileWithWarnings, new VeraPdfValidator().validate(DESTINATION_FOLDER + target)); } @Test @@ -75,10 +74,10 @@ public void checkValidatorLogsCleanupTest() throws IOException { + "WARNING: Invalid embedded cff font. Charset range exceeds number of glyphs\n" + "WARNING: Missing OutputConditionIdentifier in an output intent dictionary\n" + "WARNING: The Top DICT does not begin with ROS operator"; - Assert.assertEquals(expectedWarningsForFileWithWarnings, new VeraPdfValidator().validate(DESTINATION_FOLDER + fileNameWithWarnings)); + Assertions.assertEquals(expectedWarningsForFileWithWarnings, new VeraPdfValidator().validate(DESTINATION_FOLDER + fileNameWithWarnings)); //We check that the logs are empty after the first check - Assert.assertNull(new VeraPdfValidator().validate(DESTINATION_FOLDER + fileNameWithoutWarnings)); + Assertions.assertNull(new VeraPdfValidator().validate(DESTINATION_FOLDER + fileNameWithoutWarnings)); } @Test @@ -89,6 +88,6 @@ public void checkValidatorLogsForFileContainingErrorsTest() throws IOException { String expectedResponseForErrors = "VeraPDF verification failed. See verification results: file:"; String result = new VeraPdfValidator().validate(DESTINATION_FOLDER + target); - Assert.assertTrue(result.startsWith(expectedResponseForErrors)); + Assertions.assertTrue(result.startsWith(expectedResponseForErrors)); } } diff --git a/pdfua/pom.xml b/pdfua/pom.xml index 528bd4f3ea..c8ae15dea5 100644 --- a/pdfua/pom.xml +++ b/pdfua/pom.xml @@ -5,7 +5,7 @@ com.itextpdf root - 8.0.5 + 9.0.0 pdfua @@ -19,6 +19,11 @@ kernel ${project.version} + + com.itextpdf + commons + ${project.version} + com.itextpdf layout diff --git a/pdfua/src/main/java/com/itextpdf/pdfua/PdfUAConfig.java b/pdfua/src/main/java/com/itextpdf/pdfua/PdfUAConfig.java index 6abe7ffba4..b628ddc541 100644 --- a/pdfua/src/main/java/com/itextpdf/pdfua/PdfUAConfig.java +++ b/pdfua/src/main/java/com/itextpdf/pdfua/PdfUAConfig.java @@ -22,37 +22,37 @@ This file is part of the iText (R) project. */ package com.itextpdf.pdfua; -import com.itextpdf.kernel.pdf.PdfUAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfUAConformance; /** * Class that holds the configuration for the PDF/UA document. */ public class PdfUAConfig { - private final PdfUAConformanceLevel conformanceLevel; + private final PdfUAConformance conformance; private final String title; private final String language; /** * Creates a new PdfUAConfig instance. * - * @param conformanceLevel The conformance level of the PDF/UA document. - * @param title The title of the PDF/UA document. - * @param language The language of the PDF/UA document. + * @param conformance the conformance of the PDF/UA document + * @param title the title of the PDF/UA document + * @param language the language of the PDF/UA document */ - public PdfUAConfig(PdfUAConformanceLevel conformanceLevel, String title, String language) { - this.conformanceLevel = conformanceLevel; + public PdfUAConfig(PdfUAConformance conformance, String title, String language) { + this.conformance = conformance; this.title = title; this.language = language; } /** - * Gets the conformance level. + * Gets the UA conformance. * - * @return The {@link PdfUAConformanceLevel}. + * @return The {@link PdfUAConformance}. */ - public PdfUAConformanceLevel getConformanceLevel() { - return conformanceLevel; + public PdfUAConformance getConformance() { + return conformance; } /** diff --git a/pdfua/src/main/java/com/itextpdf/pdfua/PdfUADocument.java b/pdfua/src/main/java/com/itextpdf/pdfua/PdfUADocument.java index bb6c2f3770..1ad744ba0b 100644 --- a/pdfua/src/main/java/com/itextpdf/pdfua/PdfUADocument.java +++ b/pdfua/src/main/java/com/itextpdf/pdfua/PdfUADocument.java @@ -22,19 +22,21 @@ This file is part of the iText (R) project. */ package com.itextpdf.pdfua; +import com.itextpdf.commons.utils.MessageFormatUtil; import com.itextpdf.kernel.pdf.DocumentProperties; -import com.itextpdf.kernel.pdf.IConformanceLevel; -import com.itextpdf.kernel.pdf.IPdfPageFactory; +import com.itextpdf.kernel.pdf.PdfConformance; import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfDocumentInfo; import com.itextpdf.kernel.pdf.PdfReader; import com.itextpdf.kernel.pdf.PdfString; +import com.itextpdf.kernel.pdf.PdfUAConformance; +import com.itextpdf.kernel.pdf.PdfVersion; import com.itextpdf.kernel.pdf.PdfViewerPreferences; import com.itextpdf.kernel.pdf.PdfWriter; import com.itextpdf.kernel.pdf.StampingProperties; -import com.itextpdf.kernel.utils.ValidationContainer; +import com.itextpdf.kernel.validation.ValidationContainer; import com.itextpdf.pdfua.checkers.PdfUA1Checker; -import com.itextpdf.pdfua.exceptions.PdfUALogMessageConstants; +import com.itextpdf.pdfua.logs.PdfUALogMessageConstants; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -45,11 +47,7 @@ This file is part of the iText (R) project. * It will add necessary validation to guide the user to create a PDF/UA compliant document. */ public class PdfUADocument extends PdfDocument { - - private static final IPdfPageFactory pdfPageFactory = new PdfUAPageFactory(); private static final Logger LOGGER = LoggerFactory.getLogger(PdfUADocument.class); - private PdfUAConfig config; - private boolean warnedOnPageFlush = false; /** * Creates a PdfUADocument instance. @@ -70,7 +68,14 @@ public PdfUADocument(PdfWriter writer, PdfUAConfig config) { */ public PdfUADocument(PdfWriter writer, DocumentProperties properties, PdfUAConfig config) { super(configureWriterProperties(writer), properties); + this.pdfConformance = new PdfConformance(config.getConformance()); + setupUAConfiguration(config); + final ValidationContainer validationContainer = new ValidationContainer(); + final PdfUA1Checker checker = new PdfUA1Checker(this); + validationContainer.addChecker(checker); + this.getDiContainer().register(ValidationContainer.class, validationContainer); + this.pdfPageFactory = new PdfUAPageFactory(checker); } /** @@ -81,8 +86,7 @@ public PdfUADocument(PdfWriter writer, DocumentProperties properties, PdfUAConfi * @param config The configuration for the PDF/UA document. */ public PdfUADocument(PdfReader reader, PdfWriter writer, PdfUAConfig config) { - super(reader, configureWriterProperties(writer)); - setupUAConfiguration(config); + this(reader, writer, new StampingProperties(), config); } /** @@ -94,70 +98,36 @@ public PdfUADocument(PdfReader reader, PdfWriter writer, PdfUAConfig config) { * @param config The configuration for the PDF/UA document. */ public PdfUADocument(PdfReader reader, PdfWriter writer, StampingProperties properties, PdfUAConfig config) { - super(reader, configureWriterProperties(writer), properties); - setupUAConfiguration(config); - } - - /** - * {inheritDoc} - */ - @Override - public IConformanceLevel getConformanceLevel() { - return config.getConformanceLevel(); - } + super(reader, writer, properties); + if (!getConformance().isPdfUA()) { + LOGGER.warn(PdfUALogMessageConstants.PDF_TO_PDF_UA_CONVERSION_IS_NOT_SUPPORTED); + } - /** - * @return The PageFactory for the PDF/UA document. - */ - @Override - protected IPdfPageFactory getPageFactory() { - return pdfPageFactory; - } + setupUAConfiguration(config); - /** - * Returns if the document is in the closing state. - * - * @return true if the document is closing, false otherwise. - */ - boolean isClosing(){ - return this.isClosing; + final ValidationContainer validationContainer = new ValidationContainer(); + final PdfUA1Checker checker = new PdfUA1Checker(this); + validationContainer.addChecker(checker); + this.getDiContainer().register(ValidationContainer.class, validationContainer); + this.pdfPageFactory = new PdfUAPageFactory(checker); } - /** - * Warns the user that the page is being flushed. - * Will only warn once. - */ - void warnOnPageFlush() { - if (!warnedOnPageFlush) { - LOGGER.warn(PdfUALogMessageConstants.PAGE_FLUSHING_DISABLED); - warnedOnPageFlush = true; + private static PdfWriter configureWriterProperties(PdfWriter writer) { + writer.getProperties().addPdfUaXmpMetadata(PdfUAConformance.PDF_UA_1); + if (writer.getPdfVersion() != null && !writer.getPdfVersion().equals(PdfVersion.PDF_1_7)) { + LoggerFactory.getLogger(PdfUADocument.class).warn(MessageFormatUtil.format( + PdfUALogMessageConstants.WRITER_PROPERTIES_PDF_VERSION_WAS_OVERRIDDEN, PdfVersion.PDF_1_7)); + writer.getProperties().setPdfVersion(PdfVersion.PDF_1_7); } - } - - /** - * Disables the warning for page flushing. - */ - public void disablePageFlushingWarning() { - warnedOnPageFlush = true; + return writer; } private void setupUAConfiguration(PdfUAConfig config) { //basic configuration - this.config = config; this.setTagged(); this.getCatalog().setViewerPreferences(new PdfViewerPreferences().setDisplayDocTitle(true)); this.getCatalog().setLang(new PdfString(config.getLanguage())); final PdfDocumentInfo info = this.getDocumentInfo(); info.setTitle(config.getTitle()); - //validation - final ValidationContainer validationContainer = new ValidationContainer(); - validationContainer.addChecker(new PdfUA1Checker(this)); - this.getDiContainer().register(ValidationContainer.class, validationContainer); } - - private static PdfWriter configureWriterProperties(PdfWriter writer) { - writer.getProperties().addUAXmpMetadata(); - return writer; - } - } diff --git a/pdfua/src/main/java/com/itextpdf/pdfua/PdfUAPage.java b/pdfua/src/main/java/com/itextpdf/pdfua/PdfUAPage.java index 415b46074c..7b963af1ca 100644 --- a/pdfua/src/main/java/com/itextpdf/pdfua/PdfUAPage.java +++ b/pdfua/src/main/java/com/itextpdf/pdfua/PdfUAPage.java @@ -26,23 +26,27 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfPage; +import com.itextpdf.pdfua.checkers.PdfUA1Checker; class PdfUAPage extends PdfPage { - protected PdfUAPage(PdfDictionary pdfObject) { + private final PdfUA1Checker checker; + + protected PdfUAPage(PdfDictionary pdfObject, PdfUA1Checker checker) { super(pdfObject); + this.checker = checker; } - protected PdfUAPage(PdfDocument pdfDocument, PageSize pageSize) { + protected PdfUAPage(PdfDocument pdfDocument, PageSize pageSize, PdfUA1Checker checker) { super(pdfDocument, pageSize); + this.checker = checker; } @Override public void flush(boolean flushResourcesContentStreams) { - final PdfDocument document = getDocument(); - if (((PdfUADocument) document).isClosing()) { + if (getDocument().isClosing()) { super.flush(flushResourcesContentStreams); return; } - ((PdfUADocument) document).warnOnPageFlush(); + checker.warnOnPageFlush(); } } diff --git a/pdfua/src/main/java/com/itextpdf/pdfua/PdfUAPageFactory.java b/pdfua/src/main/java/com/itextpdf/pdfua/PdfUAPageFactory.java index 66117687e6..eb07a35562 100644 --- a/pdfua/src/main/java/com/itextpdf/pdfua/PdfUAPageFactory.java +++ b/pdfua/src/main/java/com/itextpdf/pdfua/PdfUAPageFactory.java @@ -27,12 +27,21 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfPage; +import com.itextpdf.pdfua.checkers.PdfUA1Checker; +/** + * The class implements PDF page factory which is used for creating correct PDF/UA documents. + */ class PdfUAPageFactory implements IPdfPageFactory { + private final PdfUA1Checker checker; - - public PdfUAPageFactory() { - //empty constructor + /** + * Instantiates a new {@link PdfUAPageFactory} instance based on {@link PdfUA1Checker}. + * + * @param checker the PDF/UA checker + */ + public PdfUAPageFactory(PdfUA1Checker checker) { + this.checker = checker; } /** @@ -42,7 +51,7 @@ public PdfUAPageFactory() { */ @Override public PdfPage createPdfPage(PdfDictionary pdfObject) { - return new PdfUAPage(pdfObject); + return new PdfUAPage(pdfObject, checker); } /** @@ -53,6 +62,6 @@ public PdfPage createPdfPage(PdfDictionary pdfObject) { */ @Override public PdfPage createPdfPage(PdfDocument pdfDocument, PageSize pageSize) { - return new PdfUAPage(pdfDocument, pageSize); + return new PdfUAPage(pdfDocument, pageSize, checker); } } diff --git a/pdfua/src/main/java/com/itextpdf/pdfua/checkers/PdfUA1Checker.java b/pdfua/src/main/java/com/itextpdf/pdfua/checkers/PdfUA1Checker.java index 3c9bc36626..6636f160e3 100644 --- a/pdfua/src/main/java/com/itextpdf/pdfua/checkers/PdfUA1Checker.java +++ b/pdfua/src/main/java/com/itextpdf/pdfua/checkers/PdfUA1Checker.java @@ -26,7 +26,6 @@ This file is part of the iText (R) project. import com.itextpdf.commons.utils.MessageFormatUtil; import com.itextpdf.kernel.font.PdfFont; import com.itextpdf.kernel.pdf.EncryptionConstants; -import com.itextpdf.kernel.pdf.IsoKey; import com.itextpdf.kernel.pdf.PdfArray; import com.itextpdf.kernel.pdf.PdfBoolean; import com.itextpdf.kernel.pdf.PdfCatalog; @@ -35,8 +34,7 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfName; import com.itextpdf.kernel.pdf.PdfNumber; import com.itextpdf.kernel.pdf.PdfObject; -import com.itextpdf.kernel.pdf.PdfResources; -import com.itextpdf.kernel.pdf.PdfStream; +import com.itextpdf.kernel.pdf.PdfPage; import com.itextpdf.kernel.pdf.PdfString; import com.itextpdf.kernel.pdf.PdfVersion; import com.itextpdf.kernel.pdf.tagging.PdfMcr; @@ -46,13 +44,20 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.tagutils.IRoleMappingResolver; import com.itextpdf.kernel.pdf.tagutils.TagStructureContext; import com.itextpdf.kernel.pdf.tagutils.TagTreeIterator; -import com.itextpdf.kernel.utils.IValidationChecker; -import com.itextpdf.kernel.utils.ValidationContext; import com.itextpdf.kernel.utils.checkers.FontCheckUtil; +import com.itextpdf.kernel.validation.IValidationChecker; +import com.itextpdf.kernel.validation.IValidationContext; +import com.itextpdf.kernel.validation.context.CanvasBmcValidationContext; +import com.itextpdf.kernel.validation.context.CanvasWritingContentValidationContext; +import com.itextpdf.kernel.validation.context.CryptoValidationContext; +import com.itextpdf.kernel.validation.context.DuplicateIdEntryValidationContext; +import com.itextpdf.kernel.validation.context.FontValidationContext; +import com.itextpdf.kernel.validation.context.PdfDocumentValidationContext; +import com.itextpdf.kernel.validation.context.PdfObjectValidationContext; import com.itextpdf.kernel.xmp.XMPConst; import com.itextpdf.kernel.xmp.XMPException; import com.itextpdf.kernel.xmp.XMPMeta; -import com.itextpdf.kernel.xmp.XMPMetaFactory; +import com.itextpdf.layout.validation.context.LayoutValidationContext; import com.itextpdf.pdfua.checkers.utils.AnnotationCheckUtil; import com.itextpdf.pdfua.checkers.utils.BCP47Validator; import com.itextpdf.pdfua.checkers.utils.FormCheckUtil; @@ -66,12 +71,14 @@ This file is part of the iText (R) project. import com.itextpdf.pdfua.checkers.utils.tables.TableCheckUtil; import com.itextpdf.pdfua.exceptions.PdfUAConformanceException; import com.itextpdf.pdfua.exceptions.PdfUAExceptionMessageConstants; +import com.itextpdf.pdfua.logs.PdfUALogMessageConstants; import java.util.Collection; import java.util.HashSet; import java.util.Map; import java.util.Set; import java.util.Stack; +import org.slf4j.LoggerFactory; /** * The class defines the requirements of the PDF/UA-1 standard. @@ -88,6 +95,8 @@ public class PdfUA1Checker implements IValidationChecker { private final PdfUAValidationContext context; + private boolean warnedOnPageFlush = false; + /** * Creates PdfUA1Checker instance with PDF document which will be validated against PDF/UA-1 standard. * @@ -101,44 +110,65 @@ public PdfUA1Checker(PdfDocument pdfDocument) { } /** - * {@inheritDoc} - */ - @Override - public void validateDocument(ValidationContext validationContext) { - checkCatalog(validationContext.getPdfDocument().getCatalog()); - checkStructureTreeRoot(validationContext.getPdfDocument().getStructTreeRoot()); - checkFonts(validationContext.getFonts()); - XfaCheckUtil.check(validationContext.getPdfDocument()); - } - - /** - * {@inheritDoc} + * {@inheritDoc}. */ @Override - public void validateObject(Object obj, IsoKey key, PdfResources resources, PdfStream contentStream, Object extra) { - switch (key) { - case LAYOUT: - new LayoutCheckUtil(context).checkRenderer(obj); - headingsChecker.checkLayoutElement(obj); + public void validate(IValidationContext context) { + switch (context.getType()) { + case PDF_DOCUMENT: + PdfDocumentValidationContext pdfDocContext = (PdfDocumentValidationContext) context; + checkCatalog(pdfDocContext.getPdfDocument().getCatalog()); + checkStructureTreeRoot(pdfDocContext.getPdfDocument().getStructTreeRoot()); + checkFonts(pdfDocContext.getDocumentFonts()); + XfaCheckUtil.check(pdfDocContext.getPdfDocument()); break; - case CANVAS_WRITING_CONTENT: - checkOnWritingCanvasToContent(obj); + case PDF_OBJECT: + PdfObjectValidationContext objContext = (PdfObjectValidationContext) context; + checkPdfObject(objContext.getObject()); break; - case CANVAS_BEGIN_MARKED_CONTENT: - checkOnOpeningBeginMarkedContent(obj, extra); + case CRYPTO: + CryptoValidationContext cryptoContext = (CryptoValidationContext) context; + checkCrypto((PdfDictionary) cryptoContext.getCrypto()); break; case FONT: - checkText((String) obj, (PdfFont) extra); + FontValidationContext fontContext = (FontValidationContext) context; + checkText(fontContext.getText(), fontContext.getFont()); break; - case DUPLICATE_ID_ENTRY: - throw new PdfUAConformanceException(MessageFormatUtil.format( - PdfUAExceptionMessageConstants.NON_UNIQUE_ID_ENTRY_IN_STRUCT_TREE_ROOT, obj)); - case PDF_OBJECT: - checkPdfObject((PdfObject) obj); + case CANVAS_BEGIN_MARKED_CONTENT: + CanvasBmcValidationContext bmcContext = (CanvasBmcValidationContext) context; + checkOnOpeningBeginMarkedContent(bmcContext.getTagStructureStack(), bmcContext.getCurrentBmc()); break; - case CRYPTO: - checkCrypto((PdfDictionary) obj); + case CANVAS_WRITING_CONTENT: + CanvasWritingContentValidationContext writingContext = (CanvasWritingContentValidationContext) context; + checkOnWritingCanvasToContent(writingContext.getTagStructureStack()); + break; + case LAYOUT: + LayoutValidationContext layoutContext = (LayoutValidationContext) context; + new LayoutCheckUtil(this.context).checkRenderer(layoutContext.getRenderer()); + headingsChecker.checkLayoutElement(layoutContext.getRenderer()); break; + case DUPLICATE_ID_ENTRY: + DuplicateIdEntryValidationContext idContext = (DuplicateIdEntryValidationContext) context; + throw new PdfUAConformanceException(MessageFormatUtil.format( + PdfUAExceptionMessageConstants.NON_UNIQUE_ID_ENTRY_IN_STRUCT_TREE_ROOT, idContext.getId())); + } + } + + /** + * {@inheritDoc}. + */ + @Override + public boolean isPdfObjectReadyToFlush(PdfObject object) { + return true; + } + + /** + * Logs a warn on page flushing that page flushing is disabled in PDF/UA mode. + */ + public void warnOnPageFlush() { + if (!warnedOnPageFlush) { + LoggerFactory.getLogger(PdfUA1Checker.class).warn(PdfUALogMessageConstants.PAGE_FLUSHING_DISABLED); + warnedOnPageFlush = true; } } @@ -155,7 +185,6 @@ protected void checkFileSpec(PdfDictionary fileSpec) { } } - private void checkText(String str, PdfFont font) { int index = FontCheckUtil.checkGlyphsOfText(str, font, new UaCharacterChecker()); @@ -170,14 +199,12 @@ protected void checkMetadata(PdfCatalog catalog) { throw new PdfUAConformanceException(PdfUAExceptionMessageConstants.INVALID_PDF_VERSION); } - PdfObject pdfMetadata = catalog.getPdfObject().get(PdfName.Metadata); - if (pdfMetadata == null || !pdfMetadata.isStream()) { - throw new PdfUAConformanceException(PdfUAExceptionMessageConstants.DOCUMENT_SHALL_CONTAIN_XMP_METADATA_STREAM); - } - byte[] metaBytes = ((PdfStream) pdfMetadata).getBytes(); - try { - XMPMeta metadata = XMPMetaFactory.parseFromBuffer(metaBytes); + XMPMeta metadata = catalog.getDocument().getXmpMetadata(); + if (metadata == null) { + throw new PdfUAConformanceException(PdfUAExceptionMessageConstants.DOCUMENT_SHALL_CONTAIN_XMP_METADATA_STREAM); + } + Integer part = metadata.getPropertyInteger(XMPConst.NS_PDFUA_ID, XMPConst.PART); if (!Integer.valueOf(1).equals(part)) { throw new PdfUAConformanceException(PdfUAExceptionMessageConstants.METADATA_SHALL_CONTAIN_UA_VERSION_IDENTIFIER); @@ -205,8 +232,7 @@ private void checkViewerPreferences(PdfCatalog catalog) { } - private void checkOnWritingCanvasToContent(Object data) { - Stack> tagStack = getTagStack(data); + private void checkOnWritingCanvasToContent(Stack> tagStack) { if (tagStack.isEmpty()) { throw new PdfUAConformanceException( PdfUAExceptionMessageConstants.TAG_HASNT_BEEN_ADDED_BEFORE_CONTENT_ADDING); @@ -223,15 +249,11 @@ private void checkOnWritingCanvasToContent(Object data) { } } - private Stack> getTagStack(Object data) { - return (Stack>) data; - } + private void checkOnOpeningBeginMarkedContent(Stack> stack, + Tuple2 currentBmc) { - private void checkOnOpeningBeginMarkedContent(Object obj, Object extra) { - Tuple2 currentBmc = (Tuple2) extra; checkStandardRoleMapping(currentBmc); - Stack> stack = getTagStack(obj); if (stack.isEmpty()) { return; } @@ -284,8 +306,7 @@ private boolean isRealContent(Tuple2 tag) { if (properties == null || !properties.containsKey(PdfName.MCID)) { return false; } - PdfMcr mcr = this.pdfDocument.getStructTreeRoot() - .findMcrByMcid(pdfDocument, (int) properties.getAsInt(PdfName.MCID)); + PdfMcr mcr = mcrExists(pdfDocument, (int) properties.getAsInt(PdfName.MCID)); if (mcr == null) { throw new PdfUAConformanceException( PdfUAExceptionMessageConstants.CONTENT_WITH_MCID_BUT_MCID_NOT_FOUND_IN_STRUCT_TREE_ROOT); @@ -293,6 +314,18 @@ private boolean isRealContent(Tuple2 tag) { return true; } + private PdfMcr mcrExists(PdfDocument document, int mcid) { + int amountOfPages = document.getNumberOfPages(); + for (int i = 1; i <= amountOfPages; ++i) { + PdfPage page = document.getPage(i); + PdfMcr mcr = document.getStructTreeRoot().findMcrByMcid(page.getPdfObject(), mcid); + if (mcr != null) { + return mcr; + } + } + return null; + } + private void checkCatalog(PdfCatalog catalog) { PdfDictionary catalogDict = catalog.getPdfObject(); if (!catalogDict.containsKey(PdfName.Metadata)) { diff --git a/pdfua/src/main/java/com/itextpdf/pdfua/checkers/utils/AnnotationCheckUtil.java b/pdfua/src/main/java/com/itextpdf/pdfua/checkers/utils/AnnotationCheckUtil.java index 0128fba36f..9b4e0b3518 100644 --- a/pdfua/src/main/java/com/itextpdf/pdfua/checkers/utils/AnnotationCheckUtil.java +++ b/pdfua/src/main/java/com/itextpdf/pdfua/checkers/utils/AnnotationCheckUtil.java @@ -89,11 +89,13 @@ public AnnotationHandler(PdfUAValidationContext context) { super(context); } - /** - * {@inheritDoc} - */ @Override - public void nextElement(IStructureNode elem) { + public boolean accept(IStructureNode node) { + return node != null; + } + + @Override + public void processElement(IStructureNode elem) { if (!(elem instanceof PdfObjRef)) { return; } diff --git a/pdfua/src/main/java/com/itextpdf/pdfua/checkers/utils/FormCheckUtil.java b/pdfua/src/main/java/com/itextpdf/pdfua/checkers/utils/FormCheckUtil.java index d169d28ea8..18fbb5b152 100644 --- a/pdfua/src/main/java/com/itextpdf/pdfua/checkers/utils/FormCheckUtil.java +++ b/pdfua/src/main/java/com/itextpdf/pdfua/checkers/utils/FormCheckUtil.java @@ -55,23 +55,25 @@ public FormTagHandler(PdfUAValidationContext context) { super(context); } - /** - * {@inheritDoc} - */ @Override - public void nextElement(IStructureNode elem) { + public boolean accept(IStructureNode node) { + return node != null; + } + + @Override + public void processElement(IStructureNode elem) { PdfStructElem form = context.getElementIfRoleMatches(PdfName.Form, elem); - if (form == null){ + if (form == null) { return; } PdfDictionary formField = getInteractiveKidForm(form); - if (formField == null){ + if (formField == null) { return; } // Check is not applicable for hidden annotations - if (!AnnotationCheckUtil.isAnnotationVisible(formField)){ + if (!AnnotationCheckUtil.isAnnotationVisible(formField)) { return; } diff --git a/pdfua/src/main/java/com/itextpdf/pdfua/checkers/utils/FormulaCheckUtil.java b/pdfua/src/main/java/com/itextpdf/pdfua/checkers/utils/FormulaCheckUtil.java index 1ba10b29f5..2743a445a6 100644 --- a/pdfua/src/main/java/com/itextpdf/pdfua/checkers/utils/FormulaCheckUtil.java +++ b/pdfua/src/main/java/com/itextpdf/pdfua/checkers/utils/FormulaCheckUtil.java @@ -67,11 +67,13 @@ public FormulaTagHandler(PdfUAValidationContext context) { super(context); } - /** - * {@inheritDoc} - */ @Override - public void nextElement(IStructureNode elem) { + public boolean accept(IStructureNode node) { + return node != null; + } + + @Override + public void processElement(IStructureNode elem) { final PdfStructElem structElem = context.getElementIfRoleMatches(PdfName.Formula, elem); if (structElem == null) { return; diff --git a/pdfua/src/main/java/com/itextpdf/pdfua/checkers/utils/GraphicsCheckUtil.java b/pdfua/src/main/java/com/itextpdf/pdfua/checkers/utils/GraphicsCheckUtil.java index f1be27b605..2ab65cf276 100644 --- a/pdfua/src/main/java/com/itextpdf/pdfua/checkers/utils/GraphicsCheckUtil.java +++ b/pdfua/src/main/java/com/itextpdf/pdfua/checkers/utils/GraphicsCheckUtil.java @@ -29,12 +29,10 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.tagging.PdfStructElem; import com.itextpdf.kernel.pdf.tagging.StandardRoles; import com.itextpdf.kernel.pdf.tagutils.AccessibilityProperties; -import com.itextpdf.kernel.pdf.tagutils.ITagTreeIteratorHandler; import com.itextpdf.layout.element.Image; import com.itextpdf.pdfua.exceptions.PdfUAConformanceException; import com.itextpdf.pdfua.exceptions.PdfUAExceptionMessageConstants; - /** * Class that provides methods for checking PDF/UA compliance of graphics elements. */ @@ -51,32 +49,6 @@ public GraphicsCheckUtil(PdfUAValidationContext context) { this.context = context; } - /** - * WARNING! This method is an artifact and currently does nothing. - * It is kept to ensure backward binary compatibility - * - * @param image image to check - * - * @throws PdfUAConformanceException if image doesn't have alternative description or actual text - * @deprecated This method is an artifact and will be removed. - */ - @Deprecated - public static void checkLayoutImage(Image image) { - //No impl - } - - /** - * WARNING! This method is an artifact and currently does nothing. - * It is kept to ensure backward binary compatibility - * - * @return {@link ITagTreeIteratorHandler} always null - * @deprecated This method is an artifact and will be removed. - */ - @Deprecated - public static ITagTreeIteratorHandler createFigureTagHandler() { - return null; - } - /** * Checks if image has alternative description or actual text. * @@ -130,11 +102,13 @@ public GraphicsHandler(PdfUAValidationContext context) { super(context); } - /** - * {@inheritDoc} - */ @Override - public void nextElement(IStructureNode elem) { + public boolean accept(IStructureNode node) { + return node != null; + } + + @Override + public void processElement(IStructureNode elem) { final PdfStructElem structElem = context.getElementIfRoleMatches(PdfName.Figure, elem); if (structElem == null) { return; diff --git a/pdfua/src/main/java/com/itextpdf/pdfua/checkers/utils/LayoutCheckUtil.java b/pdfua/src/main/java/com/itextpdf/pdfua/checkers/utils/LayoutCheckUtil.java index 64b58b3852..6a9c783d6c 100644 --- a/pdfua/src/main/java/com/itextpdf/pdfua/checkers/utils/LayoutCheckUtil.java +++ b/pdfua/src/main/java/com/itextpdf/pdfua/checkers/utils/LayoutCheckUtil.java @@ -44,26 +44,16 @@ public LayoutCheckUtil(PdfUAValidationContext context) { this.context = context; } - /** - * WARNING! This method is an artifact and currently does nothing. - * It is kept to ensure backward binary compatibility - * - * @param rendererObj layout element to check - */ - @Deprecated - public static void checkLayoutElements(Object rendererObj) { - } - /** * Checks renderer for PDF UA compliance. * - * @param rendererObj The renderer to check. + * @param renderer The renderer to check. */ - public void checkRenderer(Object rendererObj) { - if (rendererObj == null) { + public void checkRenderer(IRenderer renderer) { + if (renderer == null) { return; } - IPropertyContainer layoutElement = ((IRenderer) rendererObj).getModelElement(); + IPropertyContainer layoutElement = renderer.getModelElement(); if (layoutElement instanceof Image) { new GraphicsCheckUtil(context).checkLayoutElement((Image) layoutElement); } else if (layoutElement instanceof Table) { diff --git a/pdfua/src/main/java/com/itextpdf/pdfua/checkers/utils/NoteCheckUtil.java b/pdfua/src/main/java/com/itextpdf/pdfua/checkers/utils/NoteCheckUtil.java index 913adeb568..6c80083455 100644 --- a/pdfua/src/main/java/com/itextpdf/pdfua/checkers/utils/NoteCheckUtil.java +++ b/pdfua/src/main/java/com/itextpdf/pdfua/checkers/utils/NoteCheckUtil.java @@ -46,11 +46,13 @@ public NoteTagHandler(PdfUAValidationContext context) { super(context); } - /** - * {@inheritDoc} - */ @Override - public void nextElement(IStructureNode elem) { + public boolean accept(IStructureNode node) { + return node != null; + } + + @Override + public void processElement(IStructureNode elem) { final PdfStructElem structElem = context.getElementIfRoleMatches(PdfName.Note, elem); if (structElem == null) { return; diff --git a/pdfua/src/main/java/com/itextpdf/pdfua/checkers/utils/headings/HeadingsChecker.java b/pdfua/src/main/java/com/itextpdf/pdfua/checkers/utils/headings/HeadingsChecker.java index 752ff790e1..e9245705f3 100644 --- a/pdfua/src/main/java/com/itextpdf/pdfua/checkers/utils/headings/HeadingsChecker.java +++ b/pdfua/src/main/java/com/itextpdf/pdfua/checkers/utils/headings/HeadingsChecker.java @@ -64,12 +64,11 @@ public HeadingsChecker(PdfUAValidationContext context) { /** * Checks if layout element has correct heading. * - * @param rendererObj layout element to check + * @param renderer layout element to check * * @throws PdfUAConformanceException if headings sequence is incorrect */ - public void checkLayoutElement(Object rendererObj) { - IRenderer renderer = (IRenderer) rendererObj; + public void checkLayoutElement(IRenderer renderer) { IPropertyContainer element = renderer.getModelElement(); if (element instanceof IAccessibleElement) { IAccessibleElement accessibleElement = (IAccessibleElement) element; @@ -182,11 +181,13 @@ public HeadingHandler(PdfUAValidationContext context) { checker = new HeadingsChecker(context); } - /** - * {@inheritDoc} - */ @Override - public void nextElement(IStructureNode elem) { + public boolean accept(IStructureNode node) { + return node != null; + } + + @Override + public void processElement(IStructureNode elem) { checker.checkStructElement(elem); } } diff --git a/pdfua/src/main/java/com/itextpdf/pdfua/checkers/utils/tables/TableCheckUtil.java b/pdfua/src/main/java/com/itextpdf/pdfua/checkers/utils/tables/TableCheckUtil.java index fc07068a16..7b08525ed9 100644 --- a/pdfua/src/main/java/com/itextpdf/pdfua/checkers/utils/tables/TableCheckUtil.java +++ b/pdfua/src/main/java/com/itextpdf/pdfua/checkers/utils/tables/TableCheckUtil.java @@ -45,18 +45,6 @@ public TableCheckUtil(PdfUAValidationContext context) { this.context = context; } - /** - * WARNING! This method is an artifact and currently does nothing. - * It is kept to ensure backward binary compatibility - * - * @param table the table to check. - * @deprecated This method is an artifact and will be removed. - */ - @Deprecated - public static void checkLayoutTable(Table table) { - //No impl - } - /** * Checks if the table is pdf/ua compliant. * @@ -80,11 +68,13 @@ public TableHandler(PdfUAValidationContext context) { super(context); } - /** - * {@inheritDoc} - */ @Override - public void nextElement(IStructureNode elem) { + public boolean accept(IStructureNode node) { + return node != null; + } + + @Override + public void processElement(IStructureNode elem) { PdfStructElem table = context.getElementIfRoleMatches(PdfName.Table, elem); if (table == null) { return; diff --git a/pdfua/src/main/java/com/itextpdf/pdfua/exceptions/PdfUALogMessageConstants.java b/pdfua/src/main/java/com/itextpdf/pdfua/logs/PdfUALogMessageConstants.java similarity index 78% rename from pdfua/src/main/java/com/itextpdf/pdfua/exceptions/PdfUALogMessageConstants.java rename to pdfua/src/main/java/com/itextpdf/pdfua/logs/PdfUALogMessageConstants.java index bbbc882b49..7264f2c69e 100644 --- a/pdfua/src/main/java/com/itextpdf/pdfua/exceptions/PdfUALogMessageConstants.java +++ b/pdfua/src/main/java/com/itextpdf/pdfua/logs/PdfUALogMessageConstants.java @@ -20,7 +20,7 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.pdfua.exceptions; +package com.itextpdf.pdfua.logs; /** * Class containing the log message constants. @@ -29,6 +29,9 @@ public final class PdfUALogMessageConstants { public static final String PAGE_FLUSHING_DISABLED = "Page flushing is disabled in PDF/UA mode to allow UA checks " + "to be applied. Page will only be flushed on closing."; + public static final String PDF_TO_PDF_UA_CONVERSION_IS_NOT_SUPPORTED = "PDF to PDF/UA conversion is not supported."; + public static final String WRITER_PROPERTIES_PDF_VERSION_WAS_OVERRIDDEN = + "Pdf version from writer properties isn't compatible with specified PDF/UA conformance, it was overridden to {0} version."; private PdfUALogMessageConstants() { // empty constructor diff --git a/pdfua/src/test/java/com/itextpdf/pdfua/PdfUAAnnotationsTest.java b/pdfua/src/test/java/com/itextpdf/pdfua/PdfUAAnnotationsTest.java index 1fac472e33..c0d6d89309 100644 --- a/pdfua/src/test/java/com/itextpdf/pdfua/PdfUAAnnotationsTest.java +++ b/pdfua/src/test/java/com/itextpdf/pdfua/PdfUAAnnotationsTest.java @@ -39,19 +39,16 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.geom.Rectangle; import com.itextpdf.kernel.pdf.CompressionConstants; import com.itextpdf.kernel.pdf.PdfArray; +import com.itextpdf.kernel.pdf.PdfConformance; import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfName; import com.itextpdf.kernel.pdf.PdfNumber; -import com.itextpdf.kernel.pdf.PdfObject; import com.itextpdf.kernel.pdf.PdfPage; import com.itextpdf.kernel.pdf.PdfReader; import com.itextpdf.kernel.pdf.PdfStream; import com.itextpdf.kernel.pdf.PdfString; -import com.itextpdf.kernel.pdf.PdfUAConformanceLevel; -import com.itextpdf.kernel.pdf.PdfVersion; import com.itextpdf.kernel.pdf.PdfWriter; -import com.itextpdf.kernel.pdf.WriterProperties; import com.itextpdf.kernel.pdf.action.PdfAction; import com.itextpdf.kernel.pdf.action.PdfMediaClipData; import com.itextpdf.kernel.pdf.action.PdfRendition; @@ -78,7 +75,6 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.tagutils.TagTreePointer; import com.itextpdf.kernel.pdf.xobject.PdfFormXObject; import com.itextpdf.kernel.utils.CompareTool; -import com.itextpdf.kernel.xmp.XMPException; import com.itextpdf.layout.Document; import com.itextpdf.layout.element.IBlockElement; import com.itextpdf.layout.element.Link; @@ -89,18 +85,17 @@ This file is part of the iText (R) project. import com.itextpdf.pdfua.exceptions.PdfUAExceptionMessageConstants; import com.itextpdf.test.AssertUtil; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import com.itextpdf.test.pdfa.VeraPdfValidator; // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) import java.io.IOException; import java.nio.charset.StandardCharsets; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfUAAnnotationsTest extends ExtendedITextTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/pdfua/PdfUAAnnotationsTest/"; private static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/pdfua/PdfUAAnnotationsTest/"; @@ -108,12 +103,12 @@ public class PdfUAAnnotationsTest extends ExtendedITextTest { private UaValidationTestFramework framework; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(DESTINATION_FOLDER); } - @Before + @BeforeEach public void initializeFramework() { framework = new UaValidationTestFramework(DESTINATION_FOLDER); } @@ -144,7 +139,7 @@ public void ua1WidgetAnnotNoDirectChildOfAnnotTest() throws IOException, Interru PdfAcroForm acroForm = PdfFormCreator.getAcroForm(pdfDoc, true); PdfButtonFormField checkBox = new CheckBoxFormFieldBuilder(pdfDoc, "checkbox") .setWidgetRectangle(new Rectangle(10, 650, 40, 20)) - .setGenericConformanceLevel(PdfUAConformanceLevel.PDFUA_1) + .setConformance(PdfConformance.PDF_UA_1) .createCheckBox(); checkBox.setAlternativeName("widget"); @@ -193,11 +188,11 @@ public void ua1PrinterMAnnotNoDirectChildOfAnnotTest() throws IOException { pdfPage.addAnnotation(annot); } - Assert.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) try (PdfDocument pdfDoc = new PdfDocument(new PdfReader(outPdf))) { final IStructureNode docNode = pdfDoc.getStructTreeRoot().getKids().get(0); - Assert.assertEquals(PdfName.Document, docNode.getRole()); - Assert.assertEquals(PdfName.PrinterMark, ((PdfObjRef) docNode.getKids().get(0)).getReferencedObject().get(PdfName.Subtype)); + Assertions.assertEquals(PdfName.Document, docNode.getRole()); + Assertions.assertEquals(PdfName.PrinterMark, ((PdfObjRef) docNode.getKids().get(0)).getReferencedObject().get(PdfName.Subtype)); } } @@ -277,10 +272,10 @@ public void ua1StampAnnotWithAltTest() throws IOException, InterruptedException AssertUtil.doesNotThrow(() -> { pdfDoc.close(); }); - Assert.assertNull(new CompareTool().compareByContent(outPdf, + Assertions.assertNull(new CompareTool().compareByContent(outPdf, SOURCE_FOLDER + "cmp_ua1StampAnnotWithAltTest.pdf", DESTINATION_FOLDER, "diff_")); - Assert.assertNotNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) + Assertions.assertNotNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) } @Test @@ -294,10 +289,10 @@ public void ua1ScreenAnnotWithAltTest() throws IOException, InterruptedException AssertUtil.doesNotThrow(() -> { pdfDoc.close(); }); - Assert.assertNull(new CompareTool().compareByContent(outPdf, + Assertions.assertNull(new CompareTool().compareByContent(outPdf, SOURCE_FOLDER + "cmp_ua1ScreenAnnotWithAltTest.pdf", DESTINATION_FOLDER, "diff_")); - Assert.assertNotNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) + Assertions.assertNotNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) } @Test @@ -406,7 +401,7 @@ public void ua1PushBtnNestedWithinFormTest() throws IOException { // The rest of the tests for widgets can be found in com.itextpdf.pdfua.checkers.PdfUAFormFieldsTest PdfFormField button = new PushButtonFormFieldBuilder(pdfDoc, "push button") .setWidgetRectangle(new Rectangle(10, 650, 40, 20)) - .setGenericConformanceLevel(PdfUAConformanceLevel.PDFUA_1) + .setConformance(PdfConformance.PDF_UA_1) .setFont(loadFont()) .createPushButton(); @@ -591,7 +586,7 @@ public void screenAnnotationWithBEMediaDataTest() throws IOException, Interrupte screen.setContents("screen annotation"); page.addAnnotation(screen); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, + Assertions.assertNull(new CompareTool().compareByContent(outPdf, SOURCE_FOLDER + "cmp_screenAnnotationWithBEMediaDataTest.pdf", DESTINATION_FOLDER, "diff_")); //Verapdf throws runtime exception, so we don't do this check here. @@ -625,7 +620,7 @@ public void screenAnnotationWithMHMediaDataTest() throws IOException, Interrupte screen.setContents("screen annotation"); page.addAnnotation(screen); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, + Assertions.assertNull(new CompareTool().compareByContent(outPdf, SOURCE_FOLDER + "cmp_screenAnnotationWithMHMediaDataTest.pdf", DESTINATION_FOLDER, "diff_")); //Verapdf throws runtime exception, so we don't do this check here. @@ -658,10 +653,10 @@ public void screenAnnotationWithMHWithoutAltMediaDataTest() throws IOException, screen.setContents("screen annotation"); page.addAnnotation(screen); - Exception e = Assert.assertThrows(PdfUAConformanceException.class, () -> { + Exception e = Assertions.assertThrows(PdfUAConformanceException.class, () -> { pdfDoc.close(); }); - Assert.assertEquals(PdfUAExceptionMessageConstants.CT_OR_ALT_ENTRY_IS_MISSING_IN_MEDIA_CLIP, e.getMessage()); + Assertions.assertEquals(PdfUAExceptionMessageConstants.CT_OR_ALT_ENTRY_IS_MISSING_IN_MEDIA_CLIP, e.getMessage()); //Verapdf throws runtime exception, so we don't do this check here. } @@ -727,9 +722,9 @@ public void linkAnnotNotDirectChildOfLinkInvalidCropTest() throws IOException { PdfLinkAnnotation annot = new PdfLinkAnnotation(rect).setAction(PdfAction.createURI("https://itextpdf.com/")); annot.setContents("link annot"); page.addAnnotation(annot); - Exception e = Assert.assertThrows(PdfUAConformanceException.class, () -> pdfDoc.close()); + Exception e = Assertions.assertThrows(PdfUAConformanceException.class, () -> pdfDoc.close()); // VeraPdf doesn't complain, but the document is invalid, so it is also accepted behaviour - Assert.assertEquals(PdfUAExceptionMessageConstants.LINK_ANNOT_IS_NOT_NESTED_WITHIN_LINK, e.getMessage()); + Assertions.assertEquals(PdfUAExceptionMessageConstants.LINK_ANNOT_IS_NOT_NESTED_WITHIN_LINK, e.getMessage()); } @Test @@ -830,7 +825,7 @@ public void ua1PrinterMAnnotNotInTagStructureTest() throws IOException { AssertUtil.doesNotThrow(() -> pdfDoc.close()); // VeraPdf complains about the fact that PrinterMark annotation isn't wrapped by Annot tag. // But in that test we don't put PrinterMark annot in tag structure at all. - Assert.assertNotNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) + Assertions.assertNotNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) } private PdfTextAnnotation createRichTextAnnotation() { diff --git a/pdfua/src/test/java/com/itextpdf/pdfua/PdfUADocumentTest.java b/pdfua/src/test/java/com/itextpdf/pdfua/PdfUADocumentTest.java new file mode 100644 index 0000000000..36fce3e4cb --- /dev/null +++ b/pdfua/src/test/java/com/itextpdf/pdfua/PdfUADocumentTest.java @@ -0,0 +1,67 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.pdfua; + +import com.itextpdf.kernel.pdf.PdfReader; +import com.itextpdf.kernel.pdf.PdfUAConformance; +import com.itextpdf.kernel.pdf.PdfVersion; +import com.itextpdf.kernel.pdf.PdfWriter; +import com.itextpdf.kernel.pdf.WriterProperties; +import com.itextpdf.pdfua.logs.PdfUALogMessageConstants; +import com.itextpdf.test.AssertUtil; +import com.itextpdf.test.ExtendedITextTest; +import com.itextpdf.test.LogLevelConstants; +import com.itextpdf.test.annotations.LogMessage; +import com.itextpdf.test.annotations.LogMessages; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +@Tag("IntegrationTest") +public class PdfUADocumentTest extends ExtendedITextTest { + private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/pdfua/PdfUADocumentTest/"; + + @Test + @LogMessages(messages = { + @LogMessage(messageTemplate = PdfUALogMessageConstants.PDF_TO_PDF_UA_CONVERSION_IS_NOT_SUPPORTED, logLevel = LogLevelConstants.WARN) + }) + public void openNotUaDocumentTest() { + AssertUtil.doesNotThrow(() -> + new PdfUADocument( + new PdfReader(SOURCE_FOLDER + "usualPdf.pdf"), + new PdfWriter(new ByteArrayOutputStream()), + new PdfUAConfig(PdfUAConformance.PDF_UA_1, "simple doc", "eng"))); + } + + @Test + @LogMessages(messages = { + @LogMessage(messageTemplate = PdfUALogMessageConstants.WRITER_PROPERTIES_PDF_VERSION_WAS_OVERRIDDEN, logLevel = LogLevelConstants.WARN) + }) + public void settingWrongPdfVersionTest() throws IOException { + PdfUADocument doc = new PdfUADocument(new PdfWriter(new ByteArrayOutputStream(), + new WriterProperties().setPdfVersion(PdfVersion.PDF_1_4)), new PdfUAConfig(PdfUAConformance.PDF_UA_1, "en-us", "title")); + doc.close(); + } +} diff --git a/pdfua/src/test/java/com/itextpdf/pdfua/PdfUAFontsTest.java b/pdfua/src/test/java/com/itextpdf/pdfua/PdfUAFontsTest.java index e38159635b..b6cf77e92f 100644 --- a/pdfua/src/test/java/com/itextpdf/pdfua/PdfUAFontsTest.java +++ b/pdfua/src/test/java/com/itextpdf/pdfua/PdfUAFontsTest.java @@ -39,17 +39,16 @@ This file is part of the iText (R) project. import com.itextpdf.layout.element.Paragraph; import com.itextpdf.pdfua.exceptions.PdfUAExceptionMessageConstants; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import com.itextpdf.test.pdfa.VeraPdfValidator; // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) import java.io.IOException; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfUAFontsTest extends ExtendedITextTest { private static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/pdfua/PdfUAFontsTest/"; private static final String FONT = "./src/test/resources/com/itextpdf/pdfua/font/FreeSans.ttf"; @@ -57,12 +56,12 @@ public class PdfUAFontsTest extends ExtendedITextTest { private UaValidationTestFramework framework; - @BeforeClass + @BeforeAll public static void beforeClass() { createOrClearDestinationFolder(DESTINATION_FOLDER); } - @Before + @BeforeEach public void initializeFramework() { framework = new UaValidationTestFramework(DESTINATION_FOLDER); } @@ -171,7 +170,7 @@ public void trueTypeFontWithDifferencesTest() throws IOException { endText(). restoreState().closeTag(); } - Assert.assertNotNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) + Assertions.assertNotNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) } @Test diff --git a/pdfua/src/test/java/com/itextpdf/pdfua/PdfUAMetadataUnitTest.java b/pdfua/src/test/java/com/itextpdf/pdfua/PdfUAMetadataUnitTest.java index f3e20f037c..65f70bd80d 100644 --- a/pdfua/src/test/java/com/itextpdf/pdfua/PdfUAMetadataUnitTest.java +++ b/pdfua/src/test/java/com/itextpdf/pdfua/PdfUAMetadataUnitTest.java @@ -22,37 +22,37 @@ This file is part of the iText (R) project. */ package com.itextpdf.pdfua; +import com.itextpdf.io.logs.IoLogMessageConstant; import com.itextpdf.kernel.pdf.PdfCatalog; import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfName; import com.itextpdf.kernel.pdf.PdfStream; +import com.itextpdf.kernel.pdf.PdfUAConformance; import com.itextpdf.kernel.pdf.PdfVersion; import com.itextpdf.kernel.pdf.PdfWriter; -import com.itextpdf.kernel.pdf.WriterProperties; -import com.itextpdf.kernel.xmp.XMPException; import com.itextpdf.pdfua.checkers.PdfUA1Checker; import com.itextpdf.pdfua.exceptions.PdfUAConformanceException; import com.itextpdf.pdfua.exceptions.PdfUAExceptionMessageConstants; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import com.itextpdf.test.annotations.LogMessage; +import com.itextpdf.test.annotations.LogMessages; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfUAMetadataUnitTest extends ExtendedITextTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/pdfua/PdfUAMetadataUnitTest/"; @Test - public void documentWithNoTitleInMetadataTest() throws IOException, InterruptedException, XMPException { - try (PdfDocument pdfDocument = new PdfUATestPdfDocument( - new PdfWriter(new ByteArrayOutputStream()))) { + public void documentWithNoTitleInMetadataTest() throws IOException { + try (PdfDocument pdfDocument = new PdfUATestPdfDocument(new PdfWriter(new ByteArrayOutputStream()))) { pdfDocument.addNewPage(); PdfCatalog catalog = pdfDocument.getCatalog(); @@ -61,34 +61,33 @@ public void documentWithNoTitleInMetadataTest() throws IOException, InterruptedE catalog.put(PdfName.Metadata, new PdfStream(bytes)); PdfUA1MetadataChecker checker = new PdfUA1MetadataChecker(pdfDocument); - Exception e = Assert.assertThrows(PdfUAConformanceException.class, () -> checker.checkMetadata(catalog)); - Assert.assertEquals(PdfUAExceptionMessageConstants.METADATA_SHALL_CONTAIN_DC_TITLE_ENTRY, + Exception e = Assertions.assertThrows(PdfUAConformanceException.class, () -> checker.checkMetadata(catalog)); + Assertions.assertEquals(PdfUAExceptionMessageConstants.METADATA_SHALL_CONTAIN_DC_TITLE_ENTRY, e.getMessage()); } } @Test - public void documentWithInvalidMetadataVersionTest() throws IOException, InterruptedException, XMPException { - try (PdfDocument pdfDocument = new PdfUATestPdfDocument( - new PdfWriter(new ByteArrayOutputStream()))) { - pdfDocument.addNewPage(); - PdfCatalog catalog = pdfDocument.getCatalog(); - - - byte[] bytes = Files.readAllBytes(Paths.get(SOURCE_FOLDER + "invalid_version_metadata.xmp")); - catalog.put(PdfName.Metadata, new PdfStream(bytes)); - - PdfUA1MetadataChecker checker = new PdfUA1MetadataChecker(pdfDocument); - Exception e = Assert.assertThrows(PdfUAConformanceException.class, () -> checker.checkMetadata(catalog)); - Assert.assertEquals(PdfUAExceptionMessageConstants.METADATA_SHALL_CONTAIN_UA_VERSION_IDENTIFIER, - e.getMessage()); - } + public void documentWithInvalidMetadataVersionTest() throws IOException { + PdfDocument pdfDocument = new PdfUATestPdfDocument(new PdfWriter(new ByteArrayOutputStream())); + pdfDocument.addNewPage(); + PdfCatalog catalog = pdfDocument.getCatalog(); + + byte[] bytes = Files.readAllBytes(Paths.get(SOURCE_FOLDER + "invalid_version_metadata.xmp")); + catalog.put(PdfName.Metadata, new PdfStream(bytes)); + + PdfUA1MetadataChecker checker = new PdfUA1MetadataChecker(pdfDocument); + Exception e = Assertions.assertThrows(PdfUAConformanceException.class, () -> checker.checkMetadata(catalog)); + Assertions.assertEquals(PdfUAExceptionMessageConstants.METADATA_SHALL_CONTAIN_UA_VERSION_IDENTIFIER, + e.getMessage()); + e = Assertions.assertThrows(PdfUAConformanceException.class, () -> pdfDocument.close()); + Assertions.assertEquals(PdfUAExceptionMessageConstants.METADATA_SHALL_CONTAIN_UA_VERSION_IDENTIFIER, + e.getMessage()); } @Test - public void documentWithNoMetadataVersionTest() throws IOException, InterruptedException, XMPException { - try (PdfDocument pdfDocument = new PdfUATestPdfDocument( - new PdfWriter(new ByteArrayOutputStream()))) { + public void documentWithNoMetadataVersionTest() throws IOException { + try (PdfDocument pdfDocument = new PdfUATestPdfDocument(new PdfWriter(new ByteArrayOutputStream()))) { pdfDocument.addNewPage(); PdfCatalog catalog = pdfDocument.getCatalog(); @@ -97,54 +96,58 @@ public void documentWithNoMetadataVersionTest() throws IOException, InterruptedE catalog.put(PdfName.Metadata, new PdfStream(bytes)); PdfUA1MetadataChecker checker = new PdfUA1MetadataChecker(pdfDocument); - Exception e = Assert.assertThrows(PdfUAConformanceException.class, () -> checker.checkMetadata(catalog)); - Assert.assertEquals(PdfUAExceptionMessageConstants.METADATA_SHALL_CONTAIN_UA_VERSION_IDENTIFIER, + Exception e = Assertions.assertThrows(PdfUAConformanceException.class, () -> checker.checkMetadata(catalog)); + Assertions.assertEquals(PdfUAExceptionMessageConstants.METADATA_SHALL_CONTAIN_UA_VERSION_IDENTIFIER, e.getMessage()); } } @Test - public void documentWithInvalidMetadataTypeTest() throws IOException, InterruptedException, XMPException { - try (PdfDocument pdfDocument = new PdfUATestPdfDocument( - new PdfWriter(new ByteArrayOutputStream()))) { + public void documentWithInvalidMetadataTypeTest() { + try (PdfDocument pdfDocument = new PdfUATestPdfDocument(new PdfWriter(new ByteArrayOutputStream()))) { pdfDocument.addNewPage(); PdfCatalog catalog = pdfDocument.getCatalog(); catalog.put(PdfName.Metadata, new PdfDictionary()); PdfUA1MetadataChecker checker = new PdfUA1MetadataChecker(pdfDocument); - Exception e = Assert.assertThrows(PdfUAConformanceException.class, () -> checker.checkMetadata(catalog)); - Assert.assertEquals(PdfUAExceptionMessageConstants.DOCUMENT_SHALL_CONTAIN_XMP_METADATA_STREAM, + Exception e = Assertions.assertThrows(PdfUAConformanceException.class, () -> checker.checkMetadata(catalog)); + Assertions.assertEquals(PdfUAExceptionMessageConstants.DOCUMENT_SHALL_CONTAIN_XMP_METADATA_STREAM, e.getMessage()); } } @Test - public void documentWithInvalidPdfVersionTest() throws IOException, InterruptedException, XMPException { - PdfDocument pdfDocument = new PdfUATestPdfDocument( - new PdfWriter(new ByteArrayOutputStream(), - new WriterProperties().setPdfVersion(PdfVersion.PDF_2_0))); + public void documentWithInvalidPdfVersionTest() { + PdfDocumentCustomVersion pdfDocument = new PdfDocumentCustomVersion( + new PdfWriter(new ByteArrayOutputStream()), new PdfUAConfig( + PdfUAConformance.PDF_UA_1, "en-us", "title")); + pdfDocument.setPdfVersion(PdfVersion.PDF_2_0); pdfDocument.addNewPage(); - Exception e = Assert.assertThrows(PdfUAConformanceException.class, () -> pdfDocument.close()); - Assert.assertEquals(PdfUAExceptionMessageConstants.INVALID_PDF_VERSION, - e.getMessage()); + Exception e = Assertions.assertThrows(PdfUAConformanceException.class, () -> pdfDocument.close()); + Assertions.assertEquals(PdfUAExceptionMessageConstants.INVALID_PDF_VERSION, e.getMessage()); } @Test - public void documentWithBrokenMetadataTest() throws IOException, InterruptedException, XMPException { - try (PdfDocument pdfDocument = new PdfUATestPdfDocument( - new PdfWriter(new ByteArrayOutputStream()))) { - pdfDocument.addNewPage(); - PdfCatalog catalog = pdfDocument.getCatalog(); + @LogMessages(messages = { + @LogMessage(messageTemplate = IoLogMessageConstant.EXCEPTION_WHILE_UPDATING_XMPMETADATA) + }) + public void documentWithBrokenMetadataTest() throws IOException { + PdfDocument pdfDocument = new PdfUATestPdfDocument(new PdfWriter(new ByteArrayOutputStream())); + pdfDocument.addNewPage(); + PdfCatalog catalog = pdfDocument.getCatalog(); - byte[] bytes = Files.readAllBytes(Paths.get(SOURCE_FOLDER + "invalid_metadata.xmp")); - catalog.put(PdfName.Metadata, new PdfStream(bytes)); + byte[] bytes = Files.readAllBytes(Paths.get(SOURCE_FOLDER + "invalid_metadata.xmp")); + catalog.put(PdfName.Metadata, new PdfStream(bytes)); - PdfUA1MetadataChecker checker = new PdfUA1MetadataChecker(pdfDocument); - Exception e = Assert.assertThrows(PdfUAConformanceException.class, () -> checker.checkMetadata(catalog)); - Assert.assertEquals(PdfUAExceptionMessageConstants.DOCUMENT_SHALL_CONTAIN_XMP_METADATA_STREAM, - e.getMessage()); - } + PdfUA1MetadataChecker checker = new PdfUA1MetadataChecker(pdfDocument); + Exception e = Assertions.assertThrows(PdfUAConformanceException.class, () -> checker.checkMetadata(catalog)); + Assertions.assertEquals(PdfUAExceptionMessageConstants.DOCUMENT_SHALL_CONTAIN_XMP_METADATA_STREAM, + e.getMessage()); + + e = Assertions.assertThrows(PdfUAConformanceException.class, () -> pdfDocument.close()); + Assertions.assertEquals(PdfUAExceptionMessageConstants.DOCUMENT_SHALL_CONTAIN_XMP_METADATA_STREAM, + e.getMessage()); } private static class PdfUA1MetadataChecker extends PdfUA1Checker { @@ -162,4 +165,14 @@ public void checkMetadata(PdfCatalog catalog) { super.checkMetadata(catalog); } } + + private static class PdfDocumentCustomVersion extends PdfUADocument { + public PdfDocumentCustomVersion(PdfWriter writer, PdfUAConfig config) { + super(writer, config); + } + + public void setPdfVersion(PdfVersion pdfVersion) { + this.pdfVersion = pdfVersion; + } + } } diff --git a/pdfua/src/test/java/com/itextpdf/pdfua/PdfUATaggedGridContainerTest.java b/pdfua/src/test/java/com/itextpdf/pdfua/PdfUATaggedGridContainerTest.java new file mode 100644 index 0000000000..f072bf0906 --- /dev/null +++ b/pdfua/src/test/java/com/itextpdf/pdfua/PdfUATaggedGridContainerTest.java @@ -0,0 +1,250 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.pdfua; + +import com.itextpdf.io.font.PdfEncodings; +import com.itextpdf.kernel.colors.ColorConstants; +import com.itextpdf.kernel.font.PdfFont; +import com.itextpdf.kernel.font.PdfFontFactory; +import com.itextpdf.kernel.font.PdfFontFactory.EmbeddingStrategy; +import com.itextpdf.kernel.pdf.PdfWriter; +import com.itextpdf.layout.Document; +import com.itextpdf.layout.borders.SolidBorder; +import com.itextpdf.layout.element.Div; +import com.itextpdf.layout.element.GridContainer; +import com.itextpdf.layout.element.Paragraph; +import com.itextpdf.layout.element.Text; +import com.itextpdf.layout.properties.BoxSizingPropertyValue; +import com.itextpdf.layout.properties.Property; +import com.itextpdf.layout.properties.grid.PointValue; +import com.itextpdf.layout.properties.grid.TemplateValue; +import com.itextpdf.test.ExtendedITextTest; +import com.itextpdf.test.pdfa.VeraPdfValidator; // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) + +import java.io.IOException; +import java.util.Arrays; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +@Tag("IntegrationTest") +public class PdfUATaggedGridContainerTest extends ExtendedITextTest { + private static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/pdfua/PdfUATaggedGridContainerTest/"; + private static final String FONT = "./src/test/resources/com/itextpdf/pdfua/font/FreeSans.ttf"; + + + @BeforeEach + public void setup() { + createOrClearDestinationFolder(DESTINATION_FOLDER); + } + + + @Test + public void simpleBorderBoxSizingTest() throws IOException { + String outputPdf = DESTINATION_FOLDER + "border.pdf"; + PdfUATestPdfDocument doc = new PdfUATestPdfDocument(new PdfWriter(outputPdf)); + Document document = new Document(doc); + + PdfFont font = PdfFontFactory.createFont(FONT, PdfEncodings.WINANSI, EmbeddingStrategy.FORCE_EMBEDDED); + document.setFont(font); + + GridContainer gridContainer0 = createGridBoxWithText(); + document.add(new Paragraph("BOX_SIZING: BORDER_BOX")); + gridContainer0.setProperty(Property.BOX_SIZING, BoxSizingPropertyValue.BORDER_BOX); + gridContainer0.setBorder(new SolidBorder(ColorConstants.BLACK, 20)); + document.add(gridContainer0); + + document.add(new Paragraph("BOX_SIZING: CONTENT_BOX")); + GridContainer gridContainer1 = createGridBoxWithText(); + gridContainer1.setProperty(Property.BOX_SIZING, BoxSizingPropertyValue.CONTENT_BOX); + gridContainer1.setBorder(new SolidBorder(ColorConstants.BLACK, 20)); + + document.add(gridContainer1); + + document.close(); + + validateOutputPdf(outputPdf); + } + + @Test + public void simpleMarginTest() throws IOException { + String outputPdf = DESTINATION_FOLDER + "margin.pdf"; + PdfUATestPdfDocument doc = new PdfUATestPdfDocument(new PdfWriter(outputPdf)); + Document document = new Document(doc); + + PdfFont font = PdfFontFactory.createFont(FONT, PdfEncodings.WINANSI, EmbeddingStrategy.FORCE_EMBEDDED); + document.setFont(font); + + document.add(new Paragraph("Validate Grid Container with Margin ")); + GridContainer gridContainer0 = createGridBoxWithText(); + gridContainer0.setMarginTop(50); + gridContainer0.setMarginBottom(100); + gridContainer0.setMarginLeft(10); + gridContainer0.setMarginRight(10); + document.add(gridContainer0); + + document.close(); + + validateOutputPdf(outputPdf); + } + + @Test + public void simplePaddingTest() throws IOException { + String outputPdf = DESTINATION_FOLDER + "padding.pdf"; + PdfUATestPdfDocument doc = new PdfUATestPdfDocument(new PdfWriter(outputPdf)); + Document document = new Document(doc); + + PdfFont font = PdfFontFactory.createFont(FONT, PdfEncodings.WINANSI, EmbeddingStrategy.FORCE_EMBEDDED); + document.setFont(font); + + document.add(new Paragraph("Validate Grid Container with Padding")); + GridContainer gridContainer0 = createGridBoxWithText(); + gridContainer0.setPaddingTop(50); + gridContainer0.setPaddingBottom(100); + gridContainer0.setPaddingLeft(10); + gridContainer0.setPaddingRight(10); + document.add(gridContainer0); + + document.close(); + + validateOutputPdf(outputPdf); + } + + @Test + public void simpleBackgroundTest() throws IOException { + String outputPdf = DESTINATION_FOLDER + "background.pdf"; + PdfUATestPdfDocument doc = new PdfUATestPdfDocument(new PdfWriter(outputPdf)); + Document document = new Document(doc); + + PdfFont font = PdfFontFactory.createFont(FONT, PdfEncodings.WINANSI, EmbeddingStrategy.FORCE_EMBEDDED); + document.setFont(font); + + document.add(new Paragraph("Validate Grid Container with Background")); + GridContainer gridContainer0 = createGridBoxWithText(); + gridContainer0.setBackgroundColor(ColorConstants.RED); + document.add(gridContainer0); + + document.close(); + + validateOutputPdf(outputPdf); + } + + @Test + public void emptyGridContainerTest() throws IOException { + String outputPdf = DESTINATION_FOLDER + "emptyGridContainer.pdf"; + PdfUATestPdfDocument doc = new PdfUATestPdfDocument(new PdfWriter(outputPdf)); + Document document = new Document(doc); + + GridContainer gridContainer0 = new GridContainer(); + + gridContainer0.setProperty(Property.COLUMN_GAP_BORDER, null); + gridContainer0.setBackgroundColor(ColorConstants.RED); + gridContainer0.setProperty(Property.GRID_TEMPLATE_COLUMNS, + Arrays.asList( + (TemplateValue) new PointValue(150.0f), + (TemplateValue) new PointValue(150.0f), + (TemplateValue) new PointValue(150.0f))); + gridContainer0.setProperty(Property.COLUMN_GAP, 12.0f); + document.add(gridContainer0); + + document.close(); + + validateOutputPdf(outputPdf); + } + + private void validateOutputPdf(String outputPdf) { + Assertions.assertNull(new VeraPdfValidator().validate(outputPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) + } + + private GridContainer createGridBoxWithText() { + GridContainer gridContainer0 = new GridContainer(); + + gridContainer0.setProperty(Property.COLUMN_GAP_BORDER, null); + gridContainer0.setProperty(Property.GRID_TEMPLATE_COLUMNS, + Arrays.asList( + (TemplateValue) new PointValue(150.0f), + (TemplateValue) new PointValue(150.0f), + (TemplateValue) new PointValue(150.0f))); + gridContainer0.setProperty(Property.COLUMN_GAP, 12.0f); + Div div1 = new Div(); + div1.setBackgroundColor(ColorConstants.YELLOW); + div1.setProperty(Property.COLUMN_GAP_BORDER, null); + div1.setProperty(Property.COLUMN_GAP, 12.0f); + Paragraph paragraph2 = new Paragraph(); + Text text3 = new Text("One"); + paragraph2.add(text3); + + div1.add(paragraph2); + + gridContainer0.add(div1); + + Div div4 = new Div(); + div4.setProperty(Property.COLUMN_GAP_BORDER, null); + div4.setProperty(Property.COLUMN_GAP, 12.0f); + Paragraph paragraph5 = new Paragraph(); + Text text6 = new Text("Two"); + paragraph5.add(text6); + + div4.add(paragraph5); + + gridContainer0.add(div4); + + Div div7 = new Div(); + div7.setBackgroundColor(ColorConstants.GREEN); + div7.setProperty(Property.COLUMN_GAP_BORDER, null); + div7.setProperty(Property.COLUMN_GAP, 12.0f); + Paragraph paragraph8 = new Paragraph(); + Text text9 = new Text("Three"); + paragraph8.add(text9); + + div7.add(paragraph8); + + gridContainer0.add(div7); + + Div div10 = new Div(); + div10.setBackgroundColor(ColorConstants.CYAN); + div10.setProperty(Property.COLUMN_GAP_BORDER, null); + div10.setProperty(Property.COLUMN_GAP, 12.0f); + Paragraph paragraph11 = new Paragraph(); + Text text12 = new Text("Four"); + paragraph11.add(text12); + + div10.add(paragraph11); + + gridContainer0.add(div10); + + Div div13 = new Div(); + + div13.setProperty(Property.COLUMN_GAP_BORDER, null); + div13.setProperty(Property.COLUMN_GAP, 12.0f); + Paragraph paragraph14 = new Paragraph(); + Text text15 = new Text("Five"); + paragraph14.add(text15); + + div13.add(paragraph14); + + gridContainer0.add(div13); + return gridContainer0; + } +} diff --git a/pdfua/src/test/java/com/itextpdf/pdfua/PdfUATestPdfDocument.java b/pdfua/src/test/java/com/itextpdf/pdfua/PdfUATestPdfDocument.java index 2df3d712ba..52d5417095 100644 --- a/pdfua/src/test/java/com/itextpdf/pdfua/PdfUATestPdfDocument.java +++ b/pdfua/src/test/java/com/itextpdf/pdfua/PdfUATestPdfDocument.java @@ -23,18 +23,10 @@ This file is part of the iText (R) project. package com.itextpdf.pdfua; import com.itextpdf.kernel.pdf.DocumentProperties; -import com.itextpdf.kernel.pdf.IConformanceLevel; -import com.itextpdf.kernel.pdf.PdfDocument; -import com.itextpdf.kernel.pdf.PdfDocumentInfo; import com.itextpdf.kernel.pdf.PdfReader; -import com.itextpdf.kernel.pdf.PdfString; -import com.itextpdf.kernel.pdf.PdfUAConformanceLevel; -import com.itextpdf.kernel.pdf.PdfViewerPreferences; +import com.itextpdf.kernel.pdf.PdfUAConformance; import com.itextpdf.kernel.pdf.PdfWriter; import com.itextpdf.kernel.pdf.StampingProperties; -import com.itextpdf.kernel.pdf.WriterProperties; -import com.itextpdf.kernel.utils.ValidationContainer; -import com.itextpdf.pdfua.checkers.PdfUA1Checker; /** * PdfDocument extension for testing purposes. @@ -58,6 +50,6 @@ public PdfUATestPdfDocument(PdfReader reader, PdfWriter writer, StampingProperti } private static PdfUAConfig createConfig() { - return new PdfUAConfig(PdfUAConformanceLevel.PDFUA_1, "English pangram", "en-US"); + return new PdfUAConfig(PdfUAConformance.PDF_UA_1, "English pangram", "en-US"); } } diff --git a/pdfua/src/test/java/com/itextpdf/pdfua/UaValidationTestFramework.java b/pdfua/src/test/java/com/itextpdf/pdfua/UaValidationTestFramework.java index e05025cf6f..672cfcbcbf 100644 --- a/pdfua/src/test/java/com/itextpdf/pdfua/UaValidationTestFramework.java +++ b/pdfua/src/test/java/com/itextpdf/pdfua/UaValidationTestFramework.java @@ -26,18 +26,19 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfReader; import com.itextpdf.kernel.pdf.PdfWriter; -import com.itextpdf.kernel.utils.ValidationContainer; +import com.itextpdf.kernel.validation.ValidationContainer; import com.itextpdf.layout.Document; import com.itextpdf.layout.element.IBlockElement; import com.itextpdf.pdfua.exceptions.PdfUAConformanceException; import com.itextpdf.test.pdfa.VeraPdfValidator; // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) import java.io.FileNotFoundException; +import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.function.Consumer; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; /** * Class that helps to test PDF/UA conformance. @@ -65,25 +66,25 @@ public void addSuppliers(Generator... suppliers) { Collections.addAll(elementProducers, suppliers); } - public void assertBothFail(String filename) throws FileNotFoundException { + public void assertBothFail(String filename) throws IOException { assertBothFail(filename, null); } - public void assertBothFail(String filename, boolean checkDocClosing) throws FileNotFoundException { + public void assertBothFail(String filename, boolean checkDocClosing) throws IOException { assertBothFail(filename, null, checkDocClosing); } - public void assertBothFail(String filename, String expectedMsg) throws FileNotFoundException { + public void assertBothFail(String filename, String expectedMsg) throws IOException { assertBothFail(filename, expectedMsg, defaultCheckDocClosingByReopening); } - public void assertBothFail(String filename, String expectedMsg, boolean checkDocClosing) throws FileNotFoundException { + public void assertBothFail(String filename, String expectedMsg, boolean checkDocClosing) throws IOException { checkError(checkErrorLayout("layout_" + filename + ".pdf"), expectedMsg); final String createdFileName = "vera_" + filename + ".pdf"; String veraPdf = verAPdfResult(createdFileName); System.out.println(veraPdf); - Assert.assertNotNull(veraPdf);// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) + Assertions.assertNotNull(veraPdf);// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) if (checkDocClosing) { System.out.println("Checking closing"); @@ -91,7 +92,7 @@ public void assertBothFail(String filename, String expectedMsg, boolean checkDoc } } - public void assertBothValid(String fileName) throws FileNotFoundException { + public void assertBothValid(String fileName) throws IOException { Exception e = checkErrorLayout("layout_" + fileName + ".pdf"); String veraPdf = verAPdfResult("vera_" + fileName + ".pdf"); Exception eClosing = checkErrorOnClosing("vera_" + fileName + ".pdf"); @@ -118,12 +119,12 @@ public void assertBothValid(String fileName) throws FileNotFoundException { sb.append("OnClosing no expection expected but was:\n").append(eClosing); } if (counter != 3) { - Assert.fail("One of the checks did not throw\n\n" + sb.toString()); + Assertions.fail("One of the checks did not throw\n\n" + sb.toString()); } - Assert.fail(sb.toString()); + Assertions.fail(sb.toString()); } - public String verAPdfResult(String filename) throws FileNotFoundException { + public String verAPdfResult(String filename) throws IOException { String outfile = UrlUtil.getNormalizedFileUriString(destinationFolder + filename); System.out.println(outfile); PdfDocument pdfDoc = new PdfUATestPdfDocument( @@ -149,13 +150,13 @@ public void addBeforeGenerationHook(Consumer action) { } private void checkError(Exception e, String expectedMsg) { - Assert.assertNotNull(e); + Assertions.assertNotNull(e); if (!(e instanceof PdfUAConformanceException)) { System.out.println(printStackTrace(e)); - Assert.fail(); + Assertions.fail(); } if (expectedMsg != null) { - Assert.assertEquals(expectedMsg, e.getMessage()); + Assertions.assertEquals(expectedMsg, e.getMessage()); } System.out.println(printStackTrace(e)); } diff --git a/pdfua/src/test/java/com/itextpdf/pdfua/checkers/PdfUACanvasTest.java b/pdfua/src/test/java/com/itextpdf/pdfua/checkers/PdfUACanvasTest.java index 40fa5e7464..b451dea5da 100644 --- a/pdfua/src/test/java/com/itextpdf/pdfua/checkers/PdfUACanvasTest.java +++ b/pdfua/src/test/java/com/itextpdf/pdfua/checkers/PdfUACanvasTest.java @@ -37,6 +37,7 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfPage; import com.itextpdf.kernel.pdf.PdfString; import com.itextpdf.kernel.pdf.PdfWriter; +import com.itextpdf.kernel.pdf.canvas.CanvasArtifact; import com.itextpdf.kernel.pdf.canvas.CanvasTag; import com.itextpdf.kernel.pdf.canvas.PdfCanvas; import com.itextpdf.kernel.pdf.tagging.PdfMcr; @@ -50,20 +51,20 @@ This file is part of the iText (R) project. import com.itextpdf.pdfua.exceptions.PdfUAConformanceException; import com.itextpdf.pdfua.exceptions.PdfUAExceptionMessageConstants; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import com.itextpdf.test.pdfa.VeraPdfValidator; // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua // validation on Android) import java.io.ByteArrayOutputStream; import java.io.FileNotFoundException; import java.io.IOException; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; -@Category(UnitTest.class) +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; + +@Tag("UnitTest") public class PdfUACanvasTest extends ExtendedITextTest { private static final String FONT = "./src/test/resources/com/itextpdf/pdfua/font/FreeSans.ttf"; private static final String FONT_FOLDER = "./src/test/resources/com/itextpdf/pdfua/font/"; @@ -73,12 +74,12 @@ public class PdfUACanvasTest extends ExtendedITextTest { private UaValidationTestFramework framework; - @BeforeClass + @BeforeAll public static void before() { createOrClearDestinationFolder(DESTINATION_FOLDER); } - @Before + @BeforeEach public void initializeFramework() { framework = new UaValidationTestFramework(DESTINATION_FOLDER); } @@ -135,13 +136,13 @@ public void checkPoint_01_005_TextContentIsCorrectlyTaggedAsContent() throws IOE .restoreState() .closeTag(); pdfDoc.close(); - Assert.assertNull( + Assertions.assertNull( new CompareTool().compareByContent(outPdf, SOURCE_FOLDER + "cmp_01_005_TextContentIsCorrectlyTaggedAsContent.pdf", DESTINATION_FOLDER, "diff_") ); - Assert.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) + Assertions.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) } @Test @@ -159,10 +160,10 @@ public void checkPoint_01_005_TextContentIsNotInTagTree() throws IOException, In .beginText() .setFontAndSize(font, 12) .moveText(200, 200); - Exception e = Assert.assertThrows(PdfUAConformanceException.class, () -> { + Exception e = Assertions.assertThrows(PdfUAConformanceException.class, () -> { canvas.showText("Hello World!"); }); - Assert.assertEquals(PdfUAExceptionMessageConstants.CONTENT_IS_NOT_REAL_CONTENT_AND_NOT_ARTIFACT, + Assertions.assertEquals(PdfUAExceptionMessageConstants.CONTENT_IS_NOT_REAL_CONTENT_AND_NOT_ARTIFACT, e.getMessage()); } @@ -188,10 +189,10 @@ public void checkPoint_01_005_TextArtifactIsNotInTagTree() throws IOException, I .closeTag(); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, + Assertions.assertNull(new CompareTool().compareByContent(outPdf, SOURCE_FOLDER + "cmp_01_005_TextArtifactIsNotInTagTree.pdf", DESTINATION_FOLDER, "diff_")); - Assert.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) + Assertions.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) } @Test @@ -211,10 +212,10 @@ public void checkPoint_01_005_TextContentWithMCIDButNotInTagTree() throws IOExce .setFontAndSize(font, 12) .moveText(200, 200); - Exception e = Assert.assertThrows(PdfUAConformanceException.class, () -> { + Exception e = Assertions.assertThrows(PdfUAConformanceException.class, () -> { canvas.showText("Hello World!"); }); - Assert.assertEquals(PdfUAExceptionMessageConstants.CONTENT_WITH_MCID_BUT_MCID_NOT_FOUND_IN_STRUCT_TREE_ROOT, + Assertions.assertEquals(PdfUAExceptionMessageConstants.CONTENT_WITH_MCID_BUT_MCID_NOT_FOUND_IN_STRUCT_TREE_ROOT, e.getMessage()); } @@ -232,10 +233,50 @@ public void checkPoint_01_005_TextGlyphLineContentIsTaggedButNotInTagTree() thro .beginText() .moveText(200, 200) .setColor(ColorConstants.RED, true); - Exception e = Assert.assertThrows(PdfUAConformanceException.class, () -> { + Exception e = Assertions.assertThrows(PdfUAConformanceException.class, () -> { + canvas.showText(glyphLine); + }); + Assertions.assertEquals(PdfUAExceptionMessageConstants.CONTENT_IS_NOT_REAL_CONTENT_AND_NOT_ARTIFACT, + e.getMessage()); + } + + @Test + public void checkPoint_01_005_TextGlyphLineInBadStructure() throws IOException { + String outPdf = DESTINATION_FOLDER + "checkPoint_01_005_TextGlyphLineInBadStructure.pdf"; + PdfUATestPdfDocument pdfDoc = new PdfUATestPdfDocument( + new PdfWriter(outPdf)); + PdfFont font = PdfFontFactory.createFont(FONT, PdfEncodings.WINANSI, EmbeddingStrategy.FORCE_EMBEDDED); + PdfCanvas canvas = new PdfCanvas(pdfDoc.addNewPage()) { + + @Override + public PdfCanvas openTag(CanvasTag tag) { + // disable the checkIsoConformance call check by simulating generating not tagged content + // same as in annotations of formfields. + setDrawingOnPage(false); + super.openTag(tag); + setDrawingOnPage(true); + return this; + } + }; + + GlyphLine glyphLine = font.createGlyphLine("Hello World!"); + + TagTreePointer pointer = pdfDoc.getTagStructureContext().getAutoTaggingPointer(); + pointer.addTag(StandardRoles.DIV); + pointer.setPageForTagging(pdfDoc.getFirstPage()); + canvas.saveState(); + canvas.openTag(pointer.getTagReference()); + canvas.openTag(new CanvasArtifact()); + pointer.addTag(StandardRoles.P); + canvas.openTag(pointer.getTagReference()); + canvas.setFontAndSize(font, 12); + canvas.beginText(); + canvas.moveText(200, 200); + canvas.setColor(ColorConstants.RED, true); + Exception e = Assertions.assertThrows(PdfUAConformanceException.class, () -> { canvas.showText(glyphLine); }); - Assert.assertEquals(PdfUAExceptionMessageConstants.CONTENT_IS_NOT_REAL_CONTENT_AND_NOT_ARTIFACT, + Assertions.assertEquals(PdfUAExceptionMessageConstants.REAL_CONTENT_INSIDE_ARTIFACT_OR_VICE_VERSA, e.getMessage()); } @@ -259,10 +300,10 @@ public void checkPoint_01_005_TextGlyphLineContentIsArtifact() throws IOExceptio .restoreState(); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, + Assertions.assertNull(new CompareTool().compareByContent(outPdf, SOURCE_FOLDER + "cmp_01_005_TextGlyphLineContentIsArtifact.pdf", DESTINATION_FOLDER, "diff_")); - Assert.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) + Assertions.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) } @Test @@ -290,10 +331,10 @@ public void checkPoint_01_005_TextGlyphLineContentIsContentCorrect() throws IOEx .restoreState(); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, + Assertions.assertNull(new CompareTool().compareByContent(outPdf, SOURCE_FOLDER + "cmp_01_005_TextGlyphLineContentIsContentCorrect.pdf", DESTINATION_FOLDER, "diff_")); - Assert.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) + Assertions.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) } @Test @@ -318,10 +359,10 @@ public void checkPoint_01_005_allowPureBmcInArtifact() throws IOException, Inter .restoreState(); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, + Assertions.assertNull(new CompareTool().compareByContent(outPdf, SOURCE_FOLDER + "cmp_01_005_allowPureBmcInArtifact.pdf", DESTINATION_FOLDER, "diff_")); - Assert.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) + Assertions.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) } @Test @@ -348,27 +389,27 @@ public void checkPoint_01_005_allowNestedPureBmcInArtifact() throws IOException, .restoreState(); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, + Assertions.assertNull(new CompareTool().compareByContent(outPdf, SOURCE_FOLDER + "cmp_01_005_allowNestedPureBmcInArtifact.pdf", DESTINATION_FOLDER, "diff_")); - Assert.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) + Assertions.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) } @Test - public void checkPoint_01_005_LineContentThatIsContentIsNotTagged() throws FileNotFoundException { + public void checkPoint_01_005_LineContentThatIsContentIsNotTagged() throws IOException { framework.addBeforeGenerationHook((pdfDoc) -> { PdfCanvas canvas = new PdfCanvas(pdfDoc.addNewPage()); canvas.setColor(ColorConstants.RED, true) .setLineWidth(2); - canvas.lineTo(200, 200).fill(); + canvas.lineTo(200, 200).fill(); }); framework.assertBothFail("checkPoint_01_005_LineContentThatIsContentIsNotTagged", PdfUAExceptionMessageConstants.TAG_HASNT_BEEN_ADDED_BEFORE_CONTENT_ADDING, false); } @Test - public void checkPoint_01_005_LineContentThatIsContentIsNotTagged_noContent() throws FileNotFoundException { + public void checkPoint_01_005_LineContentThatIsContentIsNotTagged_noContent() throws IOException { framework.addBeforeGenerationHook((pdfDoc) -> { PdfCanvas canvas = new PdfCanvas(pdfDoc.addNewPage()); @@ -380,14 +421,14 @@ public void checkPoint_01_005_LineContentThatIsContentIsNotTagged_noContent() th } @Test - public void checkPoint_01_005_LineContentThatIsContentIsTaggedButIsNotAnArtifact() throws FileNotFoundException { + public void checkPoint_01_005_LineContentThatIsContentIsTaggedButIsNotAnArtifact() throws IOException { framework.addBeforeGenerationHook((pdfDocument) -> { PdfCanvas canvas = new PdfCanvas(pdfDocument.addNewPage()); canvas.openTag(new CanvasTag(PdfName.P)) .setColor(ColorConstants.RED, true) .setLineWidth(2); - canvas.lineTo(200, 200).fill(); + canvas.lineTo(200, 200).fill(); }); framework.assertBothFail("checkPoint_01_005_LineContentThatIsContentIsTaggedButIsNotAnArtifact", @@ -396,7 +437,7 @@ public void checkPoint_01_005_LineContentThatIsContentIsTaggedButIsNotAnArtifact @Test - public void checkPoint_01_005_LineContentThatIsContentIsTaggedButIsNotAnArtifact_no_drawing() throws FileNotFoundException { + public void checkPoint_01_005_LineContentThatIsContentIsTaggedButIsNotAnArtifact_no_drawing() throws IOException { framework.addBeforeGenerationHook((pdfDocument) -> { PdfCanvas canvas = new PdfCanvas(pdfDocument.addNewPage()); @@ -432,14 +473,14 @@ public void checkPoint_01_005_LineContentThatIsMarkedAsArtifact() throws IOExcep .closeTag(); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, + Assertions.assertNull(new CompareTool().compareByContent(outPdf, SOURCE_FOLDER + "cmp_01_005_LineContentThatIsMarkedAsArtifact.pdf", DESTINATION_FOLDER, "diff_")); - Assert.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) + Assertions.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) } @Test - public void checkPoint_01_005_RectangleNotMarked() throws FileNotFoundException { + public void checkPoint_01_005_RectangleNotMarked() throws IOException { framework.addBeforeGenerationHook((pdfDoc) -> { PdfCanvas canvas = new PdfCanvas(pdfDoc.addNewPage()); @@ -454,7 +495,7 @@ public void checkPoint_01_005_RectangleNotMarked() throws FileNotFoundException @Test - public void checkPoint_01_005_RectangleNoContent() throws FileNotFoundException { + public void checkPoint_01_005_RectangleNoContent() throws IOException { framework.addBeforeGenerationHook((pdfDoc) -> { PdfCanvas canvas = new PdfCanvas(pdfDoc.addNewPage()); canvas.setColor(ColorConstants.RED, true) @@ -466,7 +507,7 @@ public void checkPoint_01_005_RectangleNoContent() throws FileNotFoundException @Test - public void checkPoint_01_005_RectangleClip() throws FileNotFoundException { + public void checkPoint_01_005_RectangleClip() throws IOException { framework.addBeforeGenerationHook((pdfDoc) -> { PdfCanvas canvas = new PdfCanvas(pdfDoc.addNewPage()); canvas.setColor(ColorConstants.RED, true) @@ -478,7 +519,7 @@ public void checkPoint_01_005_RectangleClip() throws FileNotFoundException { } @Test - public void checkPoint_01_005_RectangleClosePathStroke() throws FileNotFoundException { + public void checkPoint_01_005_RectangleClosePathStroke() throws IOException { framework.addBeforeGenerationHook((pdfDoc) -> { PdfCanvas canvas = new PdfCanvas(pdfDoc.addNewPage()); canvas.setColor(ColorConstants.RED, true) @@ -492,7 +533,7 @@ public void checkPoint_01_005_RectangleClosePathStroke() throws FileNotFoundExce } @Test - public void checkPoint_01_005_Rectangle_EOFIllStroke() throws FileNotFoundException { + public void checkPoint_01_005_Rectangle_EOFIllStroke() throws IOException { framework.addBeforeGenerationHook((pdfDoc) -> { PdfCanvas canvas = new PdfCanvas(pdfDoc.addNewPage()); canvas.setColor(ColorConstants.RED, true) @@ -505,7 +546,7 @@ public void checkPoint_01_005_Rectangle_EOFIllStroke() throws FileNotFoundExcept } @Test - public void checkPoint_01_005_Rectangle_FillStroke() throws FileNotFoundException { + public void checkPoint_01_005_Rectangle_FillStroke() throws IOException { framework.addBeforeGenerationHook((pdfDoc) -> { PdfCanvas canvas = new PdfCanvas(pdfDoc.addNewPage()); canvas.setColor(ColorConstants.RED, true) @@ -518,7 +559,7 @@ public void checkPoint_01_005_Rectangle_FillStroke() throws FileNotFoundExceptio } @Test - public void checkPoint_01_005_Rectangle_eoFill() throws FileNotFoundException { + public void checkPoint_01_005_Rectangle_eoFill() throws IOException { framework.addBeforeGenerationHook((pdfDoc) -> { PdfCanvas canvas = new PdfCanvas(pdfDoc.addNewPage()); canvas.setColor(ColorConstants.RED, true) @@ -531,7 +572,7 @@ public void checkPoint_01_005_Rectangle_eoFill() throws FileNotFoundException { } @Test - public void checkPoint_01_005_Rectangle_eoFillStroke() throws FileNotFoundException { + public void checkPoint_01_005_Rectangle_eoFillStroke() throws IOException { framework.addBeforeGenerationHook((pdfDoc) -> { PdfCanvas canvas = new PdfCanvas(pdfDoc.addNewPage()); canvas.setColor(ColorConstants.RED, true) @@ -560,10 +601,10 @@ public void checkPoint_01_005_RectangleMarkedArtifact() throws IOException, Inte pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, + Assertions.assertNull(new CompareTool().compareByContent(outPdf, SOURCE_FOLDER + "cmp_01_005_RectangleMarkedArtifact.pdf", DESTINATION_FOLDER, "diff_")); - Assert.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) + Assertions.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) } @Test @@ -575,7 +616,7 @@ public void checkPoint_01_005_RectangleMarkedContentWithoutMcid() throws IOExcep .saveState() .openTag(new CanvasTag(PdfName.P)) .setFillColor(ColorConstants.RED); - canvas.rectangle(new Rectangle(200, 200, 100, 100)).fill(); + canvas.rectangle(new Rectangle(200, 200, 100, 100)).fill(); }); framework.assertBothFail("checkPoint_01_005_RectangleMarkedContentWithoutMcid", @@ -618,10 +659,10 @@ public void checkPoint_01_005_RectangleMarkedContent() throws IOException, Inter pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, + Assertions.assertNull(new CompareTool().compareByContent(outPdf, SOURCE_FOLDER + "cmp_01_005_RectangleMarkedContent.pdf", DESTINATION_FOLDER, "diff_")); - Assert.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) + Assertions.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) } @Test @@ -647,8 +688,8 @@ public void checkPoint_01_004_bezierMarkedAsContent() throws IOException, Interr .restoreState(); pdfDoc.close(); - Assert.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) - Assert.assertNull(new CompareTool().compareByContent(outPdf, + Assertions.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) + Assertions.assertNull(new CompareTool().compareByContent(outPdf, SOURCE_FOLDER + "cmp_01_004_bezierCurveShouldBeTagged.pdf", DESTINATION_FOLDER, "diff_")); } @@ -672,8 +713,8 @@ public void checkPoint_01_004_bezierMarkedAsArtifact() throws IOException, Inter .restoreState(); pdfDoc.close(); - Assert.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) - Assert.assertNull(new CompareTool().compareByContent(outPdf, + Assertions.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) + Assertions.assertNull(new CompareTool().compareByContent(outPdf, SOURCE_FOLDER + "cmp_01_004_bezierMarkedAsArtifact.pdf", DESTINATION_FOLDER, "diff_")); } @@ -728,10 +769,10 @@ public void checkPoint_01_005_RandomOperationsWithoutActuallyAddingContent() pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, + Assertions.assertNull(new CompareTool().compareByContent(outPdf, SOURCE_FOLDER + "cmp_01_005_RandomOperationsWithoutActuallyAddingContent.pdf", DESTINATION_FOLDER, "diff_")); - Assert.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) + Assertions.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) } @Test @@ -756,10 +797,10 @@ public void checkPoint_01_003_ContentMarkedAsArtifactsPresentInsideTaggedContent .moveText(200, 200) .showText("Hello World!") .endText(); - Exception e = Assert.assertThrows(PdfUAConformanceException.class, () -> { + Exception e = Assertions.assertThrows(PdfUAConformanceException.class, () -> { canvas.openTag(new CanvasTag(PdfName.Artifact)); }); - Assert.assertEquals( + Assertions.assertEquals( PdfUAExceptionMessageConstants.ARTIFACT_CANT_BE_INSIDE_REAL_CONTENT, e.getMessage()); } @@ -793,11 +834,11 @@ public void checkPoint_validRoleAddedInsideMarkedContent() throws IOException, I .closeTag(); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, - SOURCE_FOLDER + "cmp_validRoleAddedInsideMarkedContent.pdf", + Assertions.assertNull(new CompareTool().compareByContent(outPdf, + SOURCE_FOLDER + "cmp_validRoleAddedInsideMarkedContent.pdf", DESTINATION_FOLDER, "diff_") ); - Assert.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) + Assertions.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) } @Test @@ -835,8 +876,8 @@ public void checkPoint_validRoleAddedInsideMarkedContentMultiple() throws IOExce .closeTag(); pdfDoc.close(); - Assert.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) - Assert.assertNull(new CompareTool().compareByContent(outPdf, + Assertions.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) + Assertions.assertNull(new CompareTool().compareByContent(outPdf, SOURCE_FOLDER + "cmp_validRoleAddedInsideMarkedContentMultiple.pdf", DESTINATION_FOLDER, "diff_") ); @@ -880,8 +921,8 @@ public void checkPoint_validRoleAddedInsideMarkedContentMCR_IN_MCR() throws IOEx .closeTag(); pdfDoc.close(); - Assert.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) - Assert.assertNull(new CompareTool().compareByContent(outPdf, + Assertions.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) + Assertions.assertNull(new CompareTool().compareByContent(outPdf, SOURCE_FOLDER + "cmp_validRoleAddedInsideMarkedContentMCR_IN_MCR.pdf", DESTINATION_FOLDER, "diff_") ); @@ -910,10 +951,10 @@ public void checkPoint_01_004_TaggedContentShouldNotBeInsideArtifact() throws IO .moveText(200, 200) .showText("Hello World!") .endText(); - Exception e = Assert.assertThrows(PdfUAConformanceException.class, () -> { + Exception e = Assertions.assertThrows(PdfUAConformanceException.class, () -> { canvas.openTag(tagPointer.getTagReference()); }); - Assert.assertEquals( + Assertions.assertEquals( PdfUAExceptionMessageConstants.REAL_CONTENT_CANT_BE_INSIDE_ARTIFACT, e.getMessage()); } @@ -933,10 +974,10 @@ public void checkPoint_31_009_FontIsNotEmbedded() throws IOException { .showText("Please crash on close, tyvm") .endText() .closeTag(); - Exception e = Assert.assertThrows(PdfUAConformanceException.class, () -> { + Exception e = Assertions.assertThrows(PdfUAConformanceException.class, () -> { pdfDoc.close(); }); - Assert.assertEquals(MessageFormatUtil.format(PdfUAExceptionMessageConstants.FONT_SHOULD_BE_EMBEDDED, "Courier"), + Assertions.assertEquals(MessageFormatUtil.format(PdfUAExceptionMessageConstants.FONT_SHOULD_BE_EMBEDDED, "Courier"), e.getMessage()); } @@ -1004,7 +1045,7 @@ public void checkPoint_19_003_validNoteTagIsPresent() throws IOException, Interr framework.assertBothValid("validNoteTagPresent"); String outPdf = DESTINATION_FOLDER + "layout_validNoteTagPresent.pdf"; - Assert.assertNull(new CompareTool().compareByContent(outPdf, + Assertions.assertNull(new CompareTool().compareByContent(outPdf, SOURCE_FOLDER + "cmp_validNoteTagPresent.pdf", DESTINATION_FOLDER, "diff_") ); diff --git a/pdfua/src/test/java/com/itextpdf/pdfua/checkers/PdfUACanvasXObjectTest.java b/pdfua/src/test/java/com/itextpdf/pdfua/checkers/PdfUACanvasXObjectTest.java new file mode 100644 index 0000000000..346d7ddedb --- /dev/null +++ b/pdfua/src/test/java/com/itextpdf/pdfua/checkers/PdfUACanvasXObjectTest.java @@ -0,0 +1,486 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.pdfua.checkers; + +import com.itextpdf.io.font.PdfEncodings; +import com.itextpdf.io.image.ImageData; +import com.itextpdf.io.image.ImageDataFactory; +import com.itextpdf.kernel.colors.ColorConstants; +import com.itextpdf.kernel.font.PdfFont; +import com.itextpdf.kernel.font.PdfFontFactory; +import com.itextpdf.kernel.geom.Rectangle; +import com.itextpdf.kernel.pdf.PdfDocument; +import com.itextpdf.kernel.pdf.PdfName; +import com.itextpdf.kernel.pdf.PdfReader; +import com.itextpdf.kernel.pdf.PdfWriter; +import com.itextpdf.kernel.pdf.canvas.CanvasArtifact; +import com.itextpdf.kernel.pdf.canvas.PdfCanvas; +import com.itextpdf.kernel.pdf.tagging.StandardRoles; +import com.itextpdf.kernel.pdf.tagutils.TagTreePointer; +import com.itextpdf.kernel.pdf.xobject.PdfFormXObject; +import com.itextpdf.kernel.utils.CompareTool; +import com.itextpdf.layout.Document; +import com.itextpdf.layout.borders.SolidBorder; +import com.itextpdf.layout.element.Image; +import com.itextpdf.layout.element.Paragraph; +import com.itextpdf.layout.logs.LayoutLogMessageConstant; +import com.itextpdf.pdfua.PdfUATestPdfDocument; +import com.itextpdf.pdfua.UaValidationTestFramework; +import com.itextpdf.pdfua.exceptions.PdfUAExceptionMessageConstants; +import com.itextpdf.test.ExtendedITextTest; +import com.itextpdf.test.annotations.LogMessage; +import com.itextpdf.test.annotations.LogMessages; +import com.itextpdf.test.pdfa.VeraPdfValidator; // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) +import org.junit.jupiter.api.*; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; + + +@Tag("IntegrationTest") +public class PdfUACanvasXObjectTest extends ExtendedITextTest { + + + private static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/pdfua/PdfUACanvasXObjectTest/"; + private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/pdfua/PdfUACanvasXObjectTest/"; + + private static final String DOG = "./src/test/resources/com/itextpdf/pdfua/img/DOG.bmp"; + private static final String FONT = "./src/test/resources/com/itextpdf/pdfua/font/FreeSans.ttf"; + + private UaValidationTestFramework framework; + + @BeforeAll + public static void before() { + createOrClearDestinationFolder(DESTINATION_FOLDER); + } + + @BeforeEach + public void initializeFramework() { + framework = new UaValidationTestFramework(DESTINATION_FOLDER); + } + + + @Test + @LogMessages(messages = {@LogMessage(messageTemplate = LayoutLogMessageConstant.ELEMENT_DOES_NOT_FIT_AREA, count = 1)}) + public void copyPageAsFormXobjectWithTaggedPdf() throws IOException, InterruptedException { + String outPdf = DESTINATION_FOLDER + "xobjectTesting.pdf"; + String inputPdf = SOURCE_FOLDER + "cmp_manualPdfUaCreation.pdf"; + String cmpFIle = SOURCE_FOLDER + "cmp_xobjectTesting.pdf"; + PdfUATestPdfDocument doc = new PdfUATestPdfDocument(new PdfWriter(outPdf)); + + PdfDocument inputDoc = new PdfDocument(new PdfReader(inputPdf)); + PdfFormXObject xObject = inputDoc.getFirstPage().copyAsFormXObject(doc); + + Document document = new Document(doc); + + Image img = new Image(xObject); + img.getAccessibilityProperties().setAlternateDescription("Some description"); + document.add(img); + document.close(); + doc.close(); + + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpFIle, DESTINATION_FOLDER, "diff_")); + VeraPdfValidator validator = new VeraPdfValidator(); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) + // We expect verapdf to fail because we are embedding tagged content which contains artifacts + Assertions.assertNotNull("We expect vera pdf to fail, because we are embedding tagged content which contains artifacts into a tagged item", validator.validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) + + } + + @Test + @LogMessages(messages = {@LogMessage(messageTemplate = LayoutLogMessageConstant.ELEMENT_DOES_NOT_FIT_AREA, count = 1)}) + public void copyPageAsFormXobjectWithUnTaggedContentButInvalidBecauseOfFont() throws IOException, InterruptedException { + //itext should thrown an exception here but it does not. + // because even if it's not tagged the inner content stream is not compliant as the font is not embeded + String outputPdf = DESTINATION_FOLDER + "copyPageAsFormXobjectWithUnTaggedPdf.pdf"; + String cmpFile = SOURCE_FOLDER + "cmp_copyPageAsFormXobjectWithUnTaggedPdf.pdf"; + + ByteArrayOutputStream os = new ByteArrayOutputStream(); + PdfDocument dummyDoc = new PdfDocument(new PdfWriter(os)); + Document document = new Document(dummyDoc); + document.add(new Paragraph("Hello World!")); + document.close(); + + PdfDocument pdfDoc = new PdfUATestPdfDocument(new PdfWriter(outputPdf)); + + PdfFormXObject xObject = new PdfDocument(new PdfReader(new ByteArrayInputStream(os.toByteArray()))).getFirstPage().copyAsFormXObject(pdfDoc); + + Image img = new Image(xObject); + img.getAccessibilityProperties().setAlternateDescription("Some description"); + Document doc = new Document(pdfDoc); + doc.add(img); + doc.close(); + pdfDoc.close(); + + Assertions.assertNull(new CompareTool().compareByContent(outputPdf, cmpFile, DESTINATION_FOLDER, "diff_")); + VeraPdfValidator validator = new VeraPdfValidator(); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) + Assertions.assertNotNull("Fails are expected because the content inside the xobject isn't valid because of not embedded font, and iText doesn't parse the content streams", validator.validate(outputPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) + + } + + + @LogMessages(messages = {@LogMessage(messageTemplate = LayoutLogMessageConstant.ELEMENT_DOES_NOT_FIT_AREA, count = 1)}) + @Test + public void copyPageAsFormWithUntaggedContentAndCorrectFont() throws IOException, InterruptedException { + + String outputPdf = DESTINATION_FOLDER + "copyPageAsFormWithCorrectFontXobjectWithUnTaggedPdf.pdf"; + String cmpFile = SOURCE_FOLDER + "cmp_copyPageAsFormWithCorrectFontXobjectWithUnTaggedPdf.pdf"; + + ByteArrayOutputStream os = new ByteArrayOutputStream(); + PdfDocument dummyDoc = new PdfDocument(new PdfWriter(os)); + Document document = new Document(dummyDoc); + + PdfFont font = PdfFontFactory.createFont(FONT, PdfEncodings.WINANSI, PdfFontFactory.EmbeddingStrategy.PREFER_EMBEDDED); + document.add(new Paragraph("Hello World!").setFont(font)); + document.close(); + + PdfDocument pdfDoc = new PdfUATestPdfDocument(new PdfWriter(outputPdf)); + + PdfFormXObject xObject = new PdfDocument(new PdfReader(new ByteArrayInputStream(os.toByteArray()))).getFirstPage().copyAsFormXObject(pdfDoc); + + Image img = new Image(xObject); + img.getAccessibilityProperties().setAlternateDescription("Some description"); + Document doc = new Document(pdfDoc); + doc.add(img); + doc.close(); + pdfDoc.close(); + + Assertions.assertNull(new CompareTool().compareByContent(outputPdf, cmpFile, DESTINATION_FOLDER, "diff_")); + VeraPdfValidator validator = new VeraPdfValidator(); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) + Assertions.assertNull(validator.validate(outputPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) + + } + + @Test + public void manuallyAddToCanvasWithUnTaggedContentButBadFont() throws IOException, InterruptedException { + String outputPdf = DESTINATION_FOLDER + "manuallyAddToCanvasWithUnTaggedPdf.pdf"; + String cmpFile = SOURCE_FOLDER + "cmp_manuallyAddToCanvasWithUnTaggedPdf.pdf"; + + + ByteArrayOutputStream os = new ByteArrayOutputStream(); + PdfDocument dummyDoc = new PdfDocument(new PdfWriter(os)); + Document document = new Document(dummyDoc); + document.add(new Paragraph("Hello World!")); + document.close(); + + PdfDocument pdfDoc = new PdfUATestPdfDocument(new PdfWriter(outputPdf)); + + PdfFormXObject xObject = new PdfDocument(new PdfReader(new ByteArrayInputStream(os.toByteArray()))).getFirstPage().copyAsFormXObject(pdfDoc); + + PdfCanvas canvas = new PdfCanvas(pdfDoc.addNewPage()); + canvas.beginMarkedContent(PdfName.Artifact); + canvas.addXObject(xObject); + canvas.endMarkedContent(); + pdfDoc.close(); + + Assertions.assertNull(new CompareTool().compareByContent(outputPdf, cmpFile, DESTINATION_FOLDER, "diff_")); + VeraPdfValidator validator = new VeraPdfValidator(); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) + Assertions.assertNotNull("Content of the xobject is not valid causing it to be an non compliant", validator.validate(outputPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) + + } + + @Test + public void manuallyAddToCanvasCorrectFontAndUnTaggedContent() throws IOException, InterruptedException { + framework.addBeforeGenerationHook(pdfDoc -> { + try { + ByteArrayOutputStream os = new ByteArrayOutputStream(); + PdfDocument dummyDoc = new PdfDocument(new PdfWriter(os)); + Document document = new Document(dummyDoc); + PdfFont font = PdfFontFactory.createFont(FONT, PdfEncodings.WINANSI, PdfFontFactory.EmbeddingStrategy.FORCE_EMBEDDED); + document.add(new Paragraph("Hello World!").setFont(font)); + document.close(); + + PdfFormXObject xObject = null; + xObject = new PdfDocument(new PdfReader(new ByteArrayInputStream(os.toByteArray()))).getFirstPage().copyAsFormXObject(pdfDoc); + + PdfCanvas canvas = new PdfCanvas(pdfDoc.addNewPage()); + TagTreePointer tagPointer = pdfDoc.getTagStructureContext().getAutoTaggingPointer().addTag(StandardRoles.DIV); + tagPointer.setPageForTagging(pdfDoc.getPage(1)); + canvas.openTag(tagPointer.getTagReference()); + canvas.addXObject(xObject); + canvas.closeTag(); + } catch (IOException e) { + throw new RuntimeException(); + } + }); + framework.assertBothValid("manuallyAddToCanvasCorrectFontAndUnTaggedContent"); + + } + + @Test + public void manuallyAddToCanvasAndCorrectFontAndArtifactUnTaggedContent() throws IOException, InterruptedException { + //Now we are again adding untagged content with some artifacts and embedded font's so we should also be fine + framework.addBeforeGenerationHook(pdfDocument -> { + ByteArrayOutputStream os = new ByteArrayOutputStream(); + PdfDocument dummyDoc = new PdfDocument(new PdfWriter(os)); + Document document = new Document(dummyDoc); + try { + PdfFont font = PdfFontFactory.createFont(FONT, PdfEncodings.WINANSI, PdfFontFactory.EmbeddingStrategy.FORCE_EMBEDDED); + + document.add(new Paragraph("Hello World!").setFont(font).setBorder(new SolidBorder(ColorConstants.CYAN, 2))); + document.close(); + PdfFormXObject xObject = new PdfDocument(new PdfReader(new ByteArrayInputStream(os.toByteArray()))).getFirstPage().copyAsFormXObject(pdfDocument); + + PdfCanvas canvas = new PdfCanvas(pdfDocument.addNewPage()); + TagTreePointer tagPointer = pdfDocument.getTagStructureContext().getAutoTaggingPointer().addTag(StandardRoles.DIV); + tagPointer.setPageForTagging(pdfDocument.getPage(1)); + canvas.openTag(tagPointer.getTagReference()); + canvas.addXObject(xObject); + canvas.closeTag(); + } catch (IOException e) { + throw new RuntimeException(); + } + }); + framework.assertBothValid("manuallyAddToCanvasAndCorrectFontAndArtifactUnTaggedContent"); + } + + @Test + public void manuallyAddToCanvasAndCorrectFontAndArtifactTaggedContent() throws IOException, InterruptedException { + String outputPdf = DESTINATION_FOLDER + "manuallyAddToCanvasWithUnAndCorrectFontAndArtifactUnPdf.pdf"; + String cmpFile = SOURCE_FOLDER + "cmp_manuallyAddToCanvasWithUnAndCorrectFontUnAndArtifactPdf.pdf"; + + ByteArrayOutputStream os = new ByteArrayOutputStream(); + PdfDocument dummyDoc = new PdfDocument(new PdfWriter(os)); + dummyDoc.setTagged(); + Document document = new Document(dummyDoc); + PdfFont font = PdfFontFactory.createFont(FONT, PdfEncodings.WINANSI, PdfFontFactory.EmbeddingStrategy.FORCE_EMBEDDED); + document.add(new Paragraph("Hello World!").setFont(font).setBorder(new SolidBorder(ColorConstants.CYAN, 2))); + document.close(); + + PdfDocument pdfDoc = new PdfUATestPdfDocument(new PdfWriter(outputPdf)); + + PdfFormXObject xObject = new PdfDocument(new PdfReader(new ByteArrayInputStream(os.toByteArray()))).getFirstPage().copyAsFormXObject(pdfDoc); + + + PdfCanvas canvas = new PdfCanvas(pdfDoc.addNewPage()); + TagTreePointer tagPointer = pdfDoc.getTagStructureContext().getAutoTaggingPointer().addTag(StandardRoles.DIV); + tagPointer.setPageForTagging(pdfDoc.getPage(1)); + + canvas.openTag(tagPointer.getTagReference()); + canvas.addXObject(xObject); + canvas.closeTag(); + pdfDoc.close(); + + Assertions.assertNull(new CompareTool().compareByContent(outputPdf, cmpFile, DESTINATION_FOLDER, "diff_")); + VeraPdfValidator validator = new VeraPdfValidator(); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) + Assertions.assertNotNull("The content is non compliant because it contains both artifacts, and real content", validator.validate(outputPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) + + } + + @Test + public void manuallyAddToCanvasAndCorrectFontAndArtifactTaggedContentInsideArtifact() throws IOException, InterruptedException { + // We are adding tagged content to an artifact. Looks like Verapdf doesn't check xobject stream at all because + // page content is marked as artifact. We think it's wrong though. + framework.addBeforeGenerationHook(pdfDoc -> { + try { + ByteArrayOutputStream os = new ByteArrayOutputStream(); + PdfDocument dummyDoc = new PdfDocument(new PdfWriter(os)); + dummyDoc.setTagged(); + Document document = new Document(dummyDoc); + PdfFont font = PdfFontFactory.createFont(FONT, PdfEncodings.WINANSI, PdfFontFactory.EmbeddingStrategy.FORCE_EMBEDDED); + document.add(new Paragraph("Hello World!").setFont(font).setBorder(new SolidBorder(ColorConstants.CYAN, 2))); + document.close(); + + PdfFormXObject xObject = new PdfDocument(new PdfReader(new ByteArrayInputStream(os.toByteArray()))).getFirstPage().copyAsFormXObject(pdfDoc); + + PdfCanvas canvas = new PdfCanvas(pdfDoc.addNewPage()); + canvas.openTag(new CanvasArtifact()); + canvas.addXObject(xObject); + canvas.closeTag(); + + } catch (IOException e) { + throw new RuntimeException(); + } + }); + framework.assertBothValid("manuallyAddToCanvasAndCorrectFontInsideArtifact"); + + } + + @Test + public void manuallyAddToCanvasAndCorrectFontAndArtifactTaggedContentInsideUntaggedPageContent() throws IOException, InterruptedException { + ByteArrayOutputStream os = new ByteArrayOutputStream(); + PdfDocument dummyDoc = new PdfDocument(new PdfWriter(os)); + dummyDoc.setTagged(); + Document document = new Document(dummyDoc); + PdfFont font = PdfFontFactory.createFont(FONT, PdfEncodings.WINANSI, PdfFontFactory.EmbeddingStrategy.FORCE_EMBEDDED); + document.add(new Paragraph("Hello World!").setFont(font).setBorder(new SolidBorder(ColorConstants.CYAN, 2))); + document.close(); + dummyDoc.close(); + + framework.addBeforeGenerationHook(pdfDocument -> { + PdfCanvas canvas = new PdfCanvas(pdfDocument.addNewPage()); + PdfFormXObject xObject = null; + try { + xObject = new PdfDocument(new PdfReader(new ByteArrayInputStream(os.toByteArray()))).getFirstPage().copyAsFormXObject(pdfDocument); + } catch (IOException e) { + throw new RuntimeException(); + } + canvas.addXObject(xObject); + }); + + framework.assertBothFail("untaggedAddXobject", PdfUAExceptionMessageConstants.TAG_HASNT_BEEN_ADDED_BEFORE_CONTENT_ADDING, false); + } + + + @Test + public void manuallyAddToCanvasAtLocationAndCorrectFontAndArtifactTaggedContentInsideUntaggedPageContent() throws IOException, InterruptedException { + //We are adding untagged content we should throw an exception + ByteArrayOutputStream os = new ByteArrayOutputStream(); + PdfDocument dummyDoc = new PdfDocument(new PdfWriter(os)); + dummyDoc.setTagged(); + Document document = new Document(dummyDoc); + PdfFont font = PdfFontFactory.createFont(FONT, PdfEncodings.WINANSI, PdfFontFactory.EmbeddingStrategy.FORCE_EMBEDDED); + document.add(new Paragraph("Hello World!").setFont(font).setBorder(new SolidBorder(ColorConstants.CYAN, 2))); + document.close(); + dummyDoc.close(); + + framework.addBeforeGenerationHook(pdfDocument -> { + PdfCanvas canvas = new PdfCanvas(pdfDocument.addNewPage()); + PdfFormXObject xObject = null; + try { + xObject = new PdfDocument(new PdfReader(new ByteArrayInputStream(os.toByteArray()))).getFirstPage().copyAsFormXObject(pdfDocument); + } catch (IOException e) { + throw new RuntimeException(); + } + canvas.addXObjectAt(xObject, 200f, 200f); + }); + framework.assertBothFail("untaggedAddXobjectAt", PdfUAExceptionMessageConstants.TAG_HASNT_BEEN_ADDED_BEFORE_CONTENT_ADDING, false); + } + + @Test + public void manuallyAddToCanvasAtLocationAndCorrectFontAndArtifactTaggedContentInsideUntaggedPageContenta() throws IOException, InterruptedException { + //We are adding untagged content we should throw an exception + UaValidationTestFramework framework = new UaValidationTestFramework(DESTINATION_FOLDER); + + ByteArrayOutputStream os = new ByteArrayOutputStream(); + PdfDocument dummyDoc = new PdfDocument(new PdfWriter(os)); + Document document = new Document(dummyDoc); + PdfFont font = PdfFontFactory.createFont(FONT, PdfEncodings.WINANSI, PdfFontFactory.EmbeddingStrategy.FORCE_EMBEDDED); + document.add(new Paragraph("Hello World!").setFont(font).setBorder(new SolidBorder(ColorConstants.CYAN, 2))); + document.close(); + dummyDoc.close(); + + framework.addBeforeGenerationHook(pdfDocument -> { + PdfCanvas canvas = new PdfCanvas(pdfDocument.addNewPage()); + PdfFormXObject xObject = null; + try { + xObject = new PdfDocument(new PdfReader(new ByteArrayInputStream(os.toByteArray()))).getFirstPage().copyAsFormXObject(pdfDocument); + } catch (IOException e) { + throw new RuntimeException(); + } + canvas.addXObjectFittedIntoRectangle(xObject, new Rectangle(200, 200, 200, 200)); + }); + framework.assertBothFail("addXObjectFitted", PdfUAExceptionMessageConstants.TAG_HASNT_BEEN_ADDED_BEFORE_CONTENT_ADDING, false); + } + + @Test + public void manuallyAddToCanvasAtLocationAndCorrectFontAndArtifactTaggedContentInsideUntaggedPageContentab() throws IOException, InterruptedException { + //We are adding untagged content we should throw an exception + + ByteArrayOutputStream os = new ByteArrayOutputStream(); + PdfDocument dummyDoc = new PdfDocument(new PdfWriter(os)); + Document document = new Document(dummyDoc); + PdfFont font = PdfFontFactory.createFont(FONT, PdfEncodings.WINANSI, PdfFontFactory.EmbeddingStrategy.FORCE_EMBEDDED); + document.add(new Paragraph("Hello World!").setFont(font).setBorder(new SolidBorder(ColorConstants.CYAN, 2))); + document.close(); + dummyDoc.close(); + + framework.addBeforeGenerationHook(pdfDocument -> { + PdfCanvas canvas = new PdfCanvas(pdfDocument.addNewPage()); + PdfFormXObject xObject = null; + try { + xObject = new PdfDocument(new PdfReader(new ByteArrayInputStream(os.toByteArray()))).getFirstPage().copyAsFormXObject(pdfDocument); + } catch (IOException e) { + throw new RuntimeException(); + } + canvas.addXObjectWithTransformationMatrix(xObject, 1, 1, 1, 1, 1, 1); + }); + framework.assertBothFail("addXObjectWithTransfoMatrix", PdfUAExceptionMessageConstants.TAG_HASNT_BEEN_ADDED_BEFORE_CONTENT_ADDING, false); + } + + @Test + public void addImageObjectNotInline() throws IOException, InterruptedException { + //We are adding untagged content we should throw an exception + framework.addBeforeGenerationHook(pdfDocument -> { + PdfCanvas canvas = new PdfCanvas(pdfDocument.addNewPage()); + ImageData imd = null; + try { + imd = ImageDataFactory.create(DOG); + } catch (IOException e) { + throw new RuntimeException(); + } + canvas.addImageAt(imd, 200, 200, false); + }); + framework.assertBothFail("addIMageObjectNotInline", PdfUAExceptionMessageConstants.TAG_HASNT_BEEN_ADDED_BEFORE_CONTENT_ADDING, false); + } + + + @Test + public void addImageObjectInline() throws IOException, InterruptedException { + //We are adding untagged content we should throw an exception + framework.addBeforeGenerationHook(pdfDocument -> { + PdfCanvas canvas = new PdfCanvas(pdfDocument.addNewPage()); + ImageData imd = null; + try { + imd = ImageDataFactory.create(DOG); + } catch (IOException e) { + throw new RuntimeException(); + } + canvas.addImageAt(imd, 200, 200, false); + }); + framework.assertBothFail("addIMageObjectInline", PdfUAExceptionMessageConstants.TAG_HASNT_BEEN_ADDED_BEFORE_CONTENT_ADDING, false); + } + + @Test + public void addImageTranformationMatrix() throws IOException, InterruptedException { + //We are adding untagged content we should throw an exception + framework.addBeforeGenerationHook(pdfDocument -> { + PdfCanvas canvas = new PdfCanvas(pdfDocument.addNewPage()); + ImageData imd = null; + try { + imd = ImageDataFactory.create(DOG); + } catch (IOException e) { + throw new RuntimeException(); + } + canvas.addImageWithTransformationMatrix(imd, 1, 1, 1, 1, 1, 1, false); + }); + framework.assertBothFail("addIMageObjectTransfo", PdfUAExceptionMessageConstants.TAG_HASNT_BEEN_ADDED_BEFORE_CONTENT_ADDING, false); + } + + + @Test + public void addImageFittedIntoRectangle() throws IOException, InterruptedException { + //We are adding untagged content we should throw an exception + framework.addBeforeGenerationHook(pdfDocument -> { + PdfCanvas canvas = new PdfCanvas(pdfDocument.addNewPage()); + ImageData imd = null; + try { + imd = ImageDataFactory.create(DOG); + } catch (IOException e) { + throw new RuntimeException(); + } + canvas.addImageFittedIntoRectangle(imd, new Rectangle(200, 200, 200, 200), false); + }); + framework.assertBothFail("addImageFittedIntoRectangle", PdfUAExceptionMessageConstants.TAG_HASNT_BEEN_ADDED_BEFORE_CONTENT_ADDING, false); + } +} diff --git a/pdfua/src/test/java/com/itextpdf/pdfua/checkers/PdfUAEmbeddedFilesCheckTest.java b/pdfua/src/test/java/com/itextpdf/pdfua/checkers/PdfUAEmbeddedFilesCheckTest.java index 16b5cceaad..c4fec3b8f5 100644 --- a/pdfua/src/test/java/com/itextpdf/pdfua/checkers/PdfUAEmbeddedFilesCheckTest.java +++ b/pdfua/src/test/java/com/itextpdf/pdfua/checkers/PdfUAEmbeddedFilesCheckTest.java @@ -35,16 +35,15 @@ This file is part of the iText (R) project. import com.itextpdf.pdfua.UaValidationTestFramework; import com.itextpdf.pdfua.exceptions.PdfUAExceptionMessageConstants; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.FileNotFoundException; import java.io.IOException; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfUAEmbeddedFilesCheckTest extends ExtendedITextTest { private static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/pdfua/PdfUAFormulaTest/"; @@ -53,18 +52,18 @@ public class PdfUAEmbeddedFilesCheckTest extends ExtendedITextTest { private UaValidationTestFramework framework; - @BeforeClass + @BeforeAll public static void before() { createOrClearDestinationFolder(DESTINATION_FOLDER); } - @Before + @BeforeEach public void initializeFramework() { framework = new UaValidationTestFramework(DESTINATION_FOLDER); } @Test - public void pdfuaWithEmbeddedFilesWithoutFTest() throws FileNotFoundException { + public void pdfuaWithEmbeddedFilesWithoutFTest() throws IOException { framework.addBeforeGenerationHook((pdfDocument) -> { PdfFileSpec fs = PdfFileSpec.createEmbeddedFileSpec( pdfDocument, "file".getBytes(), "description", "file.txt", null, null, null); @@ -77,7 +76,7 @@ public void pdfuaWithEmbeddedFilesWithoutFTest() throws FileNotFoundException { } @Test - public void pdfuaWithEmbeddedFilesWithoutUFTest() throws FileNotFoundException { + public void pdfuaWithEmbeddedFilesWithoutUFTest() throws IOException { framework.addBeforeGenerationHook((pdfDocument) -> { pdfDocument.addNewPage(); PdfFileSpec fs = PdfFileSpec.createEmbeddedFileSpec( @@ -91,7 +90,7 @@ public void pdfuaWithEmbeddedFilesWithoutUFTest() throws FileNotFoundException { } @Test - public void pdfuaWithValidEmbeddedFileTest() throws FileNotFoundException { + public void pdfuaWithValidEmbeddedFileTest() throws IOException { framework.addBeforeGenerationHook((pdfDocument -> { PdfFont font; try { diff --git a/pdfua/src/test/java/com/itextpdf/pdfua/checkers/PdfUAEncryptionTest.java b/pdfua/src/test/java/com/itextpdf/pdfua/checkers/PdfUAEncryptionTest.java index 6e1ab6c1d1..13fa34e0c5 100644 --- a/pdfua/src/test/java/com/itextpdf/pdfua/checkers/PdfUAEncryptionTest.java +++ b/pdfua/src/test/java/com/itextpdf/pdfua/checkers/PdfUAEncryptionTest.java @@ -41,16 +41,15 @@ This file is part of the iText (R) project. import com.itextpdf.pdfua.exceptions.PdfUAConformanceException; import com.itextpdf.pdfua.exceptions.PdfUAExceptionMessageConstants; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; import java.nio.charset.StandardCharsets; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfUAEncryptionTest extends ExtendedITextTest { private static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/pdfua/PdfUAEncryptionTest/"; @@ -59,7 +58,7 @@ public class PdfUAEncryptionTest extends ExtendedITextTest { private static final byte[] USER_PASSWORD = "user".getBytes(StandardCharsets.UTF_8); private static final byte[] OWNER_PASSWORD = "owner".getBytes(StandardCharsets.UTF_8); - @BeforeClass + @BeforeAll public static void before() { createOrClearDestinationFolder(DESTINATION_FOLDER); } @@ -75,7 +74,7 @@ public void encryptWithPassword() PdfUATestPdfDocument document = new PdfUATestPdfDocument(writer)) { writeTextToDocument(document); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, + Assertions.assertNull(new CompareTool().compareByContent(outPdf, SOURCE_FOLDER + "cmp_" + "encryptWithPassword.pdf", DESTINATION_FOLDER, "diff", USER_PASSWORD, USER_PASSWORD)); } @@ -87,8 +86,8 @@ public void encryptWithPasswordWithInvalidPermissionsTest() .setStandardEncryption(USER_PASSWORD, OWNER_PASSWORD, ~EncryptionConstants.ALLOW_SCREENREADERS, 3); PdfUATestPdfDocument document = new PdfUATestPdfDocument(new PdfWriter(outPdf, writerProperties)); writeTextToDocument(document); - Exception e = Assert.assertThrows(PdfUAConformanceException.class, () -> document.close()); - Assert.assertEquals(PdfUAExceptionMessageConstants.TENTH_BIT_OF_P_VALUE_IN_ENCRYPTION_SHOULD_BE_NON_ZERO, + Exception e = Assertions.assertThrows(PdfUAConformanceException.class, () -> document.close()); + Assertions.assertEquals(PdfUAExceptionMessageConstants.TENTH_BIT_OF_P_VALUE_IN_ENCRYPTION_SHOULD_BE_NON_ZERO, e.getMessage()); } diff --git a/pdfua/src/test/java/com/itextpdf/pdfua/checkers/PdfUAFormFieldsTest.java b/pdfua/src/test/java/com/itextpdf/pdfua/checkers/PdfUAFormFieldsTest.java index 3e9dea162e..76cf447c26 100644 --- a/pdfua/src/test/java/com/itextpdf/pdfua/checkers/PdfUAFormFieldsTest.java +++ b/pdfua/src/test/java/com/itextpdf/pdfua/checkers/PdfUAFormFieldsTest.java @@ -23,23 +23,37 @@ This file is part of the iText (R) project. package com.itextpdf.pdfua.checkers; import com.itextpdf.forms.PdfAcroForm; -import com.itextpdf.forms.fields.*; -import com.itextpdf.forms.form.element.SignatureFieldAppearance; +import com.itextpdf.forms.fields.ChoiceFormFieldBuilder; +import com.itextpdf.forms.fields.PdfButtonFormField; +import com.itextpdf.forms.fields.PdfChoiceFormField; +import com.itextpdf.forms.fields.PdfFormAnnotation; +import com.itextpdf.forms.fields.PdfSignatureFormField; +import com.itextpdf.forms.fields.PdfTextFormField; +import com.itextpdf.forms.fields.PushButtonFormFieldBuilder; +import com.itextpdf.forms.fields.RadioFormFieldBuilder; +import com.itextpdf.forms.fields.SignatureFormFieldBuilder; +import com.itextpdf.forms.fields.TextFormFieldBuilder; import com.itextpdf.forms.fields.properties.CheckBoxType; import com.itextpdf.forms.fields.properties.SignedAppearanceText; import com.itextpdf.forms.form.element.Button; -import com.itextpdf.forms.form.element.ComboBoxField; import com.itextpdf.forms.form.element.CheckBox; -import com.itextpdf.forms.form.element.SelectFieldItem; -import com.itextpdf.forms.form.element.TextArea; +import com.itextpdf.forms.form.element.ComboBoxField; +import com.itextpdf.forms.form.element.InputField; import com.itextpdf.forms.form.element.ListBoxField; import com.itextpdf.forms.form.element.Radio; -import com.itextpdf.forms.form.element.InputField; +import com.itextpdf.forms.form.element.SelectFieldItem; +import com.itextpdf.forms.form.element.SignatureFieldAppearance; +import com.itextpdf.forms.form.element.TextArea; import com.itextpdf.kernel.colors.ColorConstants; import com.itextpdf.kernel.font.PdfFont; import com.itextpdf.kernel.font.PdfFontFactory; import com.itextpdf.kernel.geom.Rectangle; -import com.itextpdf.kernel.pdf.*; +import com.itextpdf.kernel.pdf.PdfConformance; +import com.itextpdf.kernel.pdf.PdfDictionary; +import com.itextpdf.kernel.pdf.PdfName; +import com.itextpdf.kernel.pdf.PdfObject; +import com.itextpdf.kernel.pdf.PdfStream; +import com.itextpdf.kernel.pdf.PdfString; import com.itextpdf.kernel.pdf.tagging.PdfStructElem; import com.itextpdf.kernel.pdf.tagging.StandardRoles; import com.itextpdf.kernel.pdf.tagutils.DefaultAccessibilityProperties; @@ -50,18 +64,15 @@ This file is part of the iText (R) project. import com.itextpdf.pdfua.UaValidationTestFramework; import com.itextpdf.pdfua.exceptions.PdfUAExceptionMessageConstants; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import java.io.FileNotFoundException; import java.io.IOException; import java.util.List; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfUAFormFieldsTest extends ExtendedITextTest { private static final String FONT = "./src/test/resources/com/itextpdf/pdfua/font/FreeSans.ttf"; @@ -69,18 +80,18 @@ public class PdfUAFormFieldsTest extends ExtendedITextTest { private UaValidationTestFramework framework; - @BeforeClass + @BeforeAll public static void before() { createOrClearDestinationFolder(DESTINATION_FOLDER); } - @Before + @BeforeEach public void setUp() { framework = new UaValidationTestFramework(DESTINATION_FOLDER, false); } @Test - public void testCheckBox() throws FileNotFoundException { + public void testCheckBox() throws IOException { framework.addSuppliers(new UaValidationTestFramework.Generator() { @Override public IBlockElement generate() { @@ -91,12 +102,12 @@ public IBlockElement generate() { } @Test - public void testCheckBoxWithCustomAppearance() throws FileNotFoundException { + public void testCheckBoxWithCustomAppearance() throws IOException { framework.addSuppliers(new UaValidationTestFramework.Generator() { @Override public IBlockElement generate() { CheckBox cb = new CheckBox("name"); - cb.setPdfConformanceLevel(PdfUAConformanceLevel.PDFUA_1); + cb.setPdfConformance(PdfConformance.PDF_UA_1); cb.setBorder(new SolidBorder(ColorConstants.MAGENTA, 2)); cb.setBackgroundColor(ColorConstants.YELLOW); return cb; @@ -106,12 +117,12 @@ public IBlockElement generate() { } @Test - public void testCheckBoxChecked() throws FileNotFoundException { + public void testCheckBoxChecked() throws IOException { framework.addSuppliers(new UaValidationTestFramework.Generator() { @Override public IBlockElement generate() { CheckBox cb = new CheckBox("name"); - cb.setPdfConformanceLevel(PdfUAConformanceLevel.PDFUA_1); + cb.setPdfConformance(PdfConformance.PDF_UA_1); cb.setChecked(true); return cb; } @@ -120,12 +131,12 @@ public IBlockElement generate() { } @Test - public void testCheckBoxCheckedAlternativeDescription() throws FileNotFoundException { + public void testCheckBoxCheckedAlternativeDescription() throws IOException { framework.addSuppliers(new UaValidationTestFramework.Generator() { @Override public IBlockElement generate() { CheckBox cb = new CheckBox("name"); - cb.setPdfConformanceLevel(PdfUAConformanceLevel.PDFUA_1); + cb.setPdfConformance(PdfConformance.PDF_UA_1); cb.getAccessibilityProperties().setAlternateDescription("Yello"); cb.setChecked(true); return cb; @@ -135,12 +146,12 @@ public IBlockElement generate() { } @Test - public void testCheckBoxCheckedCustomAppearance() throws FileNotFoundException { + public void testCheckBoxCheckedCustomAppearance() throws IOException { framework.addSuppliers(new UaValidationTestFramework.Generator() { @Override public IBlockElement generate() { CheckBox cb = new CheckBox("name"); - cb.setPdfConformanceLevel(PdfUAConformanceLevel.PDFUA_1); + cb.setPdfConformance(PdfConformance.PDF_UA_1); cb.setChecked(true); cb.setBorder(new SolidBorder(ColorConstants.CYAN, 2)); cb.setBackgroundColor(ColorConstants.GREEN); @@ -158,7 +169,7 @@ public void testCheckBoxInteractive() throws IOException { @Override public IBlockElement generate() { CheckBox checkBox = (CheckBox) new CheckBox("name").setInteractive(true); - checkBox.setPdfConformanceLevel(PdfUAConformanceLevel.PDFUA_1); + checkBox.setPdfConformance(PdfConformance.PDF_UA_1); checkBox.getAccessibilityProperties().setAlternateDescription("Alternative description"); return checkBox; } @@ -172,7 +183,7 @@ public void testCheckBoxInteractiveCustomAppearance() throws IOException { @Override public IBlockElement generate() { CheckBox checkBox = (CheckBox) new CheckBox("name").setInteractive(true); - checkBox.setPdfConformanceLevel(PdfUAConformanceLevel.PDFUA_1); + checkBox.setPdfConformance(PdfConformance.PDF_UA_1); checkBox.getAccessibilityProperties().setAlternateDescription("Alternative description"); checkBox.setBorder(new SolidBorder(ColorConstants.CYAN, 2)); checkBox.setBackgroundColor(ColorConstants.GREEN); @@ -190,7 +201,7 @@ public void testCheckBoxInteractiveCustomAppearanceChecked() throws IOException @Override public IBlockElement generate() { CheckBox checkBox = (CheckBox) new CheckBox("name").setInteractive(true); - checkBox.setPdfConformanceLevel(PdfUAConformanceLevel.PDFUA_1); + checkBox.setPdfConformance(PdfConformance.PDF_UA_1); checkBox.getAccessibilityProperties().setAlternateDescription("Alternative description"); checkBox.setBorder(new SolidBorder(ColorConstants.CYAN, 2)); checkBox.setBackgroundColor(ColorConstants.GREEN); @@ -1174,7 +1185,7 @@ public IBlockElement generate() { } @Test - public void testSignatureAppearance() throws FileNotFoundException { + public void testSignatureAppearance() throws IOException { framework.addSuppliers(new UaValidationTestFramework.Generator() { @Override public IBlockElement generate() { @@ -1188,7 +1199,7 @@ public IBlockElement generate() { } @Test - public void testSignatureAppearanceWithSignedAppearanceText() throws FileNotFoundException { + public void testSignatureAppearanceWithSignedAppearanceText() throws IOException { framework.addSuppliers(new UaValidationTestFramework.Generator() { @Override public IBlockElement generate() { @@ -1206,7 +1217,7 @@ public IBlockElement generate() { } @Test - public void testSignatureAppearanceWithCustomContent() throws FileNotFoundException { + public void testSignatureAppearanceWithCustomContent() throws IOException { framework.addSuppliers(new UaValidationTestFramework.Generator() { @Override public IBlockElement generate() { @@ -1223,7 +1234,7 @@ public IBlockElement generate() { } @Test - public void testSignatureAppearanceWithSignedAppearanceAndCustomAppearanceText() throws FileNotFoundException { + public void testSignatureAppearanceWithSignedAppearanceAndCustomAppearanceText() throws IOException { framework.addSuppliers(new UaValidationTestFramework.Generator() { @Override public IBlockElement generate() { @@ -1243,7 +1254,7 @@ public IBlockElement generate() { } @Test - public void testSignatureAppearanceInteractive() throws FileNotFoundException { + public void testSignatureAppearanceInteractive() throws IOException { framework.addSuppliers(new UaValidationTestFramework.Generator() { @Override public IBlockElement generate() { @@ -1259,7 +1270,7 @@ public IBlockElement generate() { } @Test - public void testSignatureAppearanceWithSignedAppearanceTextInteractive() throws FileNotFoundException { + public void testSignatureAppearanceWithSignedAppearanceTextInteractive() throws IOException { framework.addSuppliers(new UaValidationTestFramework.Generator() { @Override public IBlockElement generate() { @@ -1280,7 +1291,7 @@ public IBlockElement generate() { } @Test - public void testSignatureAppearanceWithCustomContentInteractive() throws FileNotFoundException { + public void testSignatureAppearanceWithCustomContentInteractive() throws IOException { framework.addSuppliers(new UaValidationTestFramework.Generator() { @Override public IBlockElement generate() { @@ -1300,7 +1311,7 @@ public IBlockElement generate() { @Test public void testSignedAndCustomAppearanceTextInteractive() - throws FileNotFoundException { + throws IOException { framework.addSuppliers(new UaValidationTestFramework.Generator() { @Override public IBlockElement generate() { @@ -1322,12 +1333,12 @@ public IBlockElement generate() { } @Test - public void testInteractiveCheckBoxNoAlternativeDescription() throws FileNotFoundException { + public void testInteractiveCheckBoxNoAlternativeDescription() throws IOException { framework.addSuppliers(new UaValidationTestFramework.Generator() { @Override public IBlockElement generate() { CheckBox cb = new CheckBox("name"); - cb.setPdfConformanceLevel(PdfUAConformanceLevel.PDFUA_1); + cb.setPdfConformance(PdfConformance.PDF_UA_1); cb.setInteractive(true); return cb; } @@ -1337,7 +1348,7 @@ public IBlockElement generate() { } @Test - public void testInteractiveRadioButtonNoAlternativeDescription() throws FileNotFoundException { + public void testInteractiveRadioButtonNoAlternativeDescription() throws IOException { framework.addSuppliers(new UaValidationTestFramework.Generator() { @Override public IBlockElement generate() { @@ -1351,7 +1362,7 @@ public IBlockElement generate() { } @Test - public void testInteractiveButtonNoAlternativeDescription() throws FileNotFoundException { + public void testInteractiveButtonNoAlternativeDescription() throws IOException { framework.addSuppliers(new UaValidationTestFramework.Generator() { @Override public IBlockElement generate() { @@ -1366,7 +1377,7 @@ public IBlockElement generate() { } @Test - public void testInteractiveInputFieldNoAlternativeDescription() throws FileNotFoundException { + public void testInteractiveInputFieldNoAlternativeDescription() throws IOException { framework.addSuppliers(new UaValidationTestFramework.Generator() { @Override public IBlockElement generate() { @@ -1381,7 +1392,7 @@ public IBlockElement generate() { } @Test - public void testInteractiveTextAreaNoAlternativeDescription() throws FileNotFoundException { + public void testInteractiveTextAreaNoAlternativeDescription() throws IOException { framework.addSuppliers(new UaValidationTestFramework.Generator() { @Override public IBlockElement generate() { @@ -1396,7 +1407,7 @@ public IBlockElement generate() { } @Test - public void testInteractiveListBoxNoAlternativeDescription() throws FileNotFoundException { + public void testInteractiveListBoxNoAlternativeDescription() throws IOException { framework.addSuppliers(new UaValidationTestFramework.Generator() { @Override public IBlockElement generate() { @@ -1411,7 +1422,7 @@ public IBlockElement generate() { } @Test - public void testInteractiveComboBoxNoAlternativeDescription() throws FileNotFoundException { + public void testInteractiveComboBoxNoAlternativeDescription() throws IOException { framework.addSuppliers(new UaValidationTestFramework.Generator() { @Override public IBlockElement generate() { @@ -1426,7 +1437,7 @@ public IBlockElement generate() { } @Test - public void testInteractiveSignatureAppearanceNoAlternativeDescription() throws FileNotFoundException { + public void testInteractiveSignatureAppearanceNoAlternativeDescription() throws IOException { framework.addSuppliers(new UaValidationTestFramework.Generator() { @Override public IBlockElement generate() { @@ -1441,12 +1452,12 @@ public IBlockElement generate() { } @Test - public void testCheckBoxDifferentRole() throws FileNotFoundException { + public void testCheckBoxDifferentRole() throws IOException { framework.addSuppliers(new UaValidationTestFramework.Generator() { @Override public IBlockElement generate() { CheckBox cb = new CheckBox("name"); - cb.setPdfConformanceLevel(PdfUAConformanceLevel.PDFUA_1); + cb.setPdfConformance(PdfConformance.PDF_UA_1); cb.getAccessibilityProperties().setRole(StandardRoles.FIGURE); cb.getAccessibilityProperties().setAlternateDescription("Hello"); return cb; @@ -1456,7 +1467,7 @@ public IBlockElement generate() { @Override public IBlockElement generate() { CheckBox cb = new CheckBox("name"); - cb.setPdfConformanceLevel(PdfUAConformanceLevel.PDFUA_1); + cb.setPdfConformance(PdfConformance.PDF_UA_1); cb.getAccessibilityProperties().setRole(StandardRoles.ARTIFACT); return cb; } @@ -1465,7 +1476,7 @@ public IBlockElement generate() { } @Test - public void testRadioButtonDifferentRole() throws FileNotFoundException { + public void testRadioButtonDifferentRole() throws IOException { framework.addSuppliers(new UaValidationTestFramework.Generator() { @Override public IBlockElement generate() { @@ -1498,7 +1509,7 @@ public IBlockElement generate() { } @Test - public void testButtonDifferentRole() throws FileNotFoundException { + public void testButtonDifferentRole() throws IOException { framework.addSuppliers(new UaValidationTestFramework.Generator() { @Override public IBlockElement generate() { @@ -1524,7 +1535,7 @@ public IBlockElement generate() { } @Test - public void testInputFieldDifferentRole() throws FileNotFoundException { + public void testInputFieldDifferentRole() throws IOException { framework.addSuppliers(new UaValidationTestFramework.Generator() { @Override public IBlockElement generate() { @@ -1561,7 +1572,7 @@ public IBlockElement generate() { } @Test - public void testTextAreaDifferentRole() throws FileNotFoundException { + public void testTextAreaDifferentRole() throws IOException { framework.addSuppliers(new UaValidationTestFramework.Generator() { @Override public IBlockElement generate() { @@ -1595,7 +1606,7 @@ public IBlockElement generate() { } @Test - public void testListBoxDifferentRole() throws FileNotFoundException { + public void testListBoxDifferentRole() throws IOException { framework.addSuppliers(new UaValidationTestFramework.Generator() { @Override public IBlockElement generate() { @@ -1621,7 +1632,7 @@ public IBlockElement generate() { } @Test - public void testComboBoxDifferentRole() throws FileNotFoundException { + public void testComboBoxDifferentRole() throws IOException { framework.addSuppliers(new UaValidationTestFramework.Generator() { @Override public IBlockElement generate() { @@ -1648,7 +1659,7 @@ public IBlockElement generate() { } @Test - public void testSignatureAppearanceDifferentRole() throws FileNotFoundException { + public void testSignatureAppearanceDifferentRole() throws IOException { framework.addSuppliers(new UaValidationTestFramework.Generator() { @Override public IBlockElement generate() { @@ -1675,13 +1686,13 @@ public IBlockElement generate() { } @Test - public void testTextBuilderWithTu() throws FileNotFoundException { + public void testTextBuilderWithTu() throws IOException { framework.addBeforeGenerationHook((pdfDoc) ->{ PdfAcroForm form = PdfAcroForm.getAcroForm(pdfDoc, true); PdfTextFormField field = new TextFormFieldBuilder(pdfDoc,"hello") .setWidgetRectangle(new Rectangle(100, 100, 100, 100)) .setFont(getFont()) - .setGenericConformanceLevel(PdfUAConformanceLevel.PDFUA_1) + .setConformance(PdfConformance.PDF_UA_1) .createText(); field.setValue("Some value"); field.setAlternativeName("Some tu entry value"); @@ -1691,13 +1702,13 @@ public void testTextBuilderWithTu() throws FileNotFoundException { } @Test - public void testTextBuilderNoTu() throws FileNotFoundException { + public void testTextBuilderNoTu() throws IOException { framework.addBeforeGenerationHook((pdfDoc) ->{ PdfAcroForm form = PdfAcroForm.getAcroForm(pdfDoc, true); PdfTextFormField field = new TextFormFieldBuilder(pdfDoc,"hello") .setWidgetRectangle(new Rectangle(100, 100, 100, 100)) .setFont(getFont()) - .setGenericConformanceLevel(PdfUAConformanceLevel.PDFUA_1) + .setConformance(PdfConformance.PDF_UA_1) .createText(); field.setValue("Some value"); form.addField(field); @@ -1706,13 +1717,13 @@ public void testTextBuilderNoTu() throws FileNotFoundException { } @Test - public void testChoiceBuilderWithTu() throws FileNotFoundException { + public void testChoiceBuilderWithTu() throws IOException { framework.addBeforeGenerationHook((pdfDoc) ->{ PdfAcroForm form = PdfAcroForm.getAcroForm(pdfDoc, true); PdfChoiceFormField field = new ChoiceFormFieldBuilder(pdfDoc,"hello") .setWidgetRectangle(new Rectangle(100, 100, 100, 100)) .setFont(getFont()) - .setGenericConformanceLevel(PdfUAConformanceLevel.PDFUA_1) + .setConformance(PdfConformance.PDF_UA_1) .createComboBox(); field.setAlternativeName("Some tu entry value"); form.addField(field); @@ -1721,13 +1732,13 @@ public void testChoiceBuilderWithTu() throws FileNotFoundException { } @Test - public void testChoiceBuilderNoTu() throws FileNotFoundException { + public void testChoiceBuilderNoTu() throws IOException { framework.addBeforeGenerationHook((pdfDoc) ->{ PdfAcroForm form = PdfAcroForm.getAcroForm(pdfDoc, true); PdfChoiceFormField field = new ChoiceFormFieldBuilder(pdfDoc,"hello") .setWidgetRectangle(new Rectangle(100, 100, 100, 100)) .setFont(getFont()) - .setGenericConformanceLevel(PdfUAConformanceLevel.PDFUA_1) + .setConformance(PdfConformance.PDF_UA_1) .createComboBox(); form.addField(field); }); @@ -1735,13 +1746,13 @@ public void testChoiceBuilderNoTu() throws FileNotFoundException { } @Test - public void testButtonBuilderWithTu() throws FileNotFoundException { + public void testButtonBuilderWithTu() throws IOException { framework.addBeforeGenerationHook((pdfDoc) ->{ PdfAcroForm form = PdfAcroForm.getAcroForm(pdfDoc, true); PdfButtonFormField field = new PushButtonFormFieldBuilder(pdfDoc,"hello") .setWidgetRectangle(new Rectangle(100, 100, 100, 100)) .setFont(getFont()) - .setGenericConformanceLevel(PdfUAConformanceLevel.PDFUA_1) + .setConformance(PdfConformance.PDF_UA_1) .createPushButton(); field.setAlternativeName("Some tu entry value"); form.addField(field); @@ -1750,13 +1761,13 @@ public void testButtonBuilderWithTu() throws FileNotFoundException { } @Test - public void testButtonBuilderNoTu() throws FileNotFoundException { + public void testButtonBuilderNoTu() throws IOException { framework.addBeforeGenerationHook((pdfDoc) ->{ PdfAcroForm form = PdfAcroForm.getAcroForm(pdfDoc, true); PdfButtonFormField field = new PushButtonFormFieldBuilder(pdfDoc,"hello") .setWidgetRectangle(new Rectangle(100, 100, 100, 100)) .setFont(getFont()) - .setGenericConformanceLevel(PdfUAConformanceLevel.PDFUA_1) + .setConformance(PdfConformance.PDF_UA_1) .createPushButton(); form.addField(field); }); @@ -1764,13 +1775,13 @@ public void testButtonBuilderNoTu() throws FileNotFoundException { } @Test - public void testButtonBuilderNoTuNotVisible() throws FileNotFoundException { + public void testButtonBuilderNoTuNotVisible() throws IOException { framework.addBeforeGenerationHook((pdfDoc) ->{ PdfAcroForm form = PdfAcroForm.getAcroForm(pdfDoc, true); PdfButtonFormField field = new PushButtonFormFieldBuilder(pdfDoc,"hello") .setWidgetRectangle(new Rectangle(100, 100, 100, 100)) .setFont(getFont()) - .setGenericConformanceLevel(PdfUAConformanceLevel.PDFUA_1) + .setConformance(PdfConformance.PDF_UA_1) .createPushButton(); List annList = field.getChildFormAnnotations(); annList.get(0).setVisibility(PdfFormAnnotation.HIDDEN); @@ -1780,7 +1791,7 @@ public void testButtonBuilderNoTuNotVisible() throws FileNotFoundException { } @Test - public void testRadioButtonBuilderNoTu() throws FileNotFoundException { + public void testRadioButtonBuilderNoTu() throws IOException { framework.addBeforeGenerationHook((pdfDoc) ->{ PdfAcroForm form = PdfAcroForm.getAcroForm(pdfDoc, true); RadioFormFieldBuilder builder = new RadioFormFieldBuilder(pdfDoc, "Radio"); @@ -1800,7 +1811,7 @@ public void testRadioButtonBuilderNoTu() throws FileNotFoundException { } @Test - public void testRadioButtonBuilderWithTu() throws FileNotFoundException { + public void testRadioButtonBuilderWithTu() throws IOException { framework.addBeforeGenerationHook((pdfDoc) ->{ PdfAcroForm form = PdfAcroForm.getAcroForm(pdfDoc, true); RadioFormFieldBuilder builder = new RadioFormFieldBuilder(pdfDoc, "Radio"); @@ -1822,13 +1833,13 @@ public void testRadioButtonBuilderWithTu() throws FileNotFoundException { } @Test - public void testSignatureBuilderWithTu() throws FileNotFoundException { + public void testSignatureBuilderWithTu() throws IOException { framework.addBeforeGenerationHook((pdfDoc) ->{ PdfAcroForm form = PdfAcroForm.getAcroForm(pdfDoc, true); PdfSignatureFormField field = new SignatureFormFieldBuilder(pdfDoc,"hello") .setWidgetRectangle(new Rectangle(100, 100, 100, 100)) .setFont(getFont()) - .setGenericConformanceLevel(PdfUAConformanceLevel.PDFUA_1) + .setConformance(PdfConformance.PDF_UA_1) .createSignature(); field.setValue("some value"); field.setAlternativeName("Some tu entry value"); @@ -1838,13 +1849,13 @@ public void testSignatureBuilderWithTu() throws FileNotFoundException { } @Test - public void testSignatureBuilderNoTu() throws FileNotFoundException { + public void testSignatureBuilderNoTu() throws IOException { framework.addBeforeGenerationHook((pdfDoc) ->{ PdfAcroForm form = PdfAcroForm.getAcroForm(pdfDoc, true); PdfSignatureFormField field = new SignatureFormFieldBuilder(pdfDoc,"hello") .setWidgetRectangle(new Rectangle(100, 100, 100, 100)) .setFont(getFont()) - .setGenericConformanceLevel(PdfUAConformanceLevel.PDFUA_1) + .setConformance(PdfConformance.PDF_UA_1) .createSignature(); field.setValue("some value"); form.addField(field); @@ -1859,7 +1870,7 @@ public void testFormFieldWithAltEntry() throws IOException { PdfTextFormField field = new TextFormFieldBuilder(pdfDoc,"hello") .setWidgetRectangle(new Rectangle(100, 100, 100, 100)) .setFont(getFont()) - .setGenericConformanceLevel(PdfUAConformanceLevel.PDFUA_1) + .setConformance(PdfConformance.PDF_UA_1) .createText(); field.setValue("Some value"); pdfDoc.getTagStructureContext().getAutoTaggingPointer().addTag( diff --git a/pdfua/src/test/java/com/itextpdf/pdfua/checkers/PdfUAFormulaTest.java b/pdfua/src/test/java/com/itextpdf/pdfua/checkers/PdfUAFormulaTest.java index 05b741eeb5..3dfa31abb0 100644 --- a/pdfua/src/test/java/com/itextpdf/pdfua/checkers/PdfUAFormulaTest.java +++ b/pdfua/src/test/java/com/itextpdf/pdfua/checkers/PdfUAFormulaTest.java @@ -41,17 +41,16 @@ This file is part of the iText (R) project. import com.itextpdf.pdfua.exceptions.PdfUAExceptionMessageConstants; import com.itextpdf.test.AssertUtil; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.ByteArrayOutputStream; import java.io.IOException; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfUAFormulaTest extends ExtendedITextTest { @@ -59,12 +58,12 @@ public class PdfUAFormulaTest extends ExtendedITextTest { private static final String FONT = "./src/test/resources/com/itextpdf/pdfua/font/FreeSans.ttf"; private UaValidationTestFramework framework; - @BeforeClass + @BeforeAll public static void before() { createOrClearDestinationFolder(DESTINATION_FOLDER); } - @Before + @BeforeEach public void initializeFramework() { framework = new UaValidationTestFramework(DESTINATION_FOLDER); } @@ -220,7 +219,7 @@ public void canvasTest01() throws IOException { tagPointer.addTag(StandardRoles.FORMULA); canvas.openTag(tagPointer.getTagReference()).saveState().beginText().setFontAndSize(font, 12).showText("E=mc²") .endText().closeTag(); - Assert.assertThrows(PdfUAConformanceException.class, () -> { + Assertions.assertThrows(PdfUAConformanceException.class, () -> { document.close(); }); @@ -260,8 +259,8 @@ public void canvasTest03() throws IOException { tagPointer.setPageForTagging(document.getFirstPage()); tagPointer.addTag(StandardRoles.FORMULA); canvas.openTag(tagPointer.getTagReference()).saveState().beginText().setFontAndSize(font, 12); - Exception e = Assert.assertThrows(PdfUAConformanceException.class, () -> canvas.showText("⫊")); - Assert.assertEquals( + Exception e = Assertions.assertThrows(PdfUAConformanceException.class, () -> canvas.showText("⫊")); + Assertions.assertEquals( MessageFormatUtil.format(PdfUAExceptionMessageConstants.GLYPH_IS_NOT_DEFINED_OR_WITHOUT_UNICODE, "⫊"), e.getMessage()); } diff --git a/pdfua/src/test/java/com/itextpdf/pdfua/checkers/PdfUAGraphicsTest.java b/pdfua/src/test/java/com/itextpdf/pdfua/checkers/PdfUAGraphicsTest.java index a26eb3d0f2..5d64d42bf8 100644 --- a/pdfua/src/test/java/com/itextpdf/pdfua/checkers/PdfUAGraphicsTest.java +++ b/pdfua/src/test/java/com/itextpdf/pdfua/checkers/PdfUAGraphicsTest.java @@ -27,9 +27,7 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.font.PdfFontFactory; import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfPage; -import com.itextpdf.kernel.pdf.PdfVersion; import com.itextpdf.kernel.pdf.PdfWriter; -import com.itextpdf.kernel.pdf.WriterProperties; import com.itextpdf.kernel.pdf.canvas.PdfCanvas; import com.itextpdf.kernel.pdf.tagging.PdfStructTreeRoot; import com.itextpdf.kernel.pdf.tagging.StandardRoles; @@ -49,20 +47,18 @@ This file is part of the iText (R) project. import com.itextpdf.pdfua.exceptions.PdfUAExceptionMessageConstants; import com.itextpdf.test.AssertUtil; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import com.itextpdf.test.pdfa.VeraPdfValidator;// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) import java.io.ByteArrayOutputStream; -import java.io.FileNotFoundException; import java.io.IOException; import java.net.MalformedURLException; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfUAGraphicsTest extends ExtendedITextTest { @@ -76,26 +72,25 @@ public class PdfUAGraphicsTest extends ExtendedITextTest { private UaValidationTestFramework framework; - @BeforeClass + @BeforeAll public static void before() { createOrClearDestinationFolder(DESTINATION_FOLDER); } - @Before + @BeforeEach public void initializeFramework() { framework = new UaValidationTestFramework(DESTINATION_FOLDER); } @Test public void imageWithoutAlternativeDescription_ThrowsInLayout() throws MalformedURLException { - PdfDocument pdfDoc = new PdfUATestPdfDocument(new PdfWriter(new ByteArrayOutputStream(), - new WriterProperties().addUAXmpMetadata().setPdfVersion(PdfVersion.PDF_1_7))); + PdfDocument pdfDoc = new PdfUATestPdfDocument(new PdfWriter(new ByteArrayOutputStream())); Document document = new Document(pdfDoc); Image img = new Image(ImageDataFactory.create(DOG)); - Exception e = Assert.assertThrows(PdfUAConformanceException.class, () -> { + Exception e = Assertions.assertThrows(PdfUAConformanceException.class, () -> { document.add(img); }); - Assert.assertEquals(PdfUAExceptionMessageConstants.IMAGE_SHALL_HAVE_ALT, e.getMessage()); + Assertions.assertEquals(PdfUAExceptionMessageConstants.IMAGE_SHALL_HAVE_ALT, e.getMessage()); } @Test @@ -105,21 +100,20 @@ public void layoutCheckUtilTest() { @Test public void imageWithEmptyAlternativeDescription_ThrowsInLayout() throws MalformedURLException { - PdfDocument pdfDoc = new PdfUATestPdfDocument(new PdfWriter(new ByteArrayOutputStream(), - new WriterProperties().addUAXmpMetadata().setPdfVersion(PdfVersion.PDF_1_7))); + PdfDocument pdfDoc = new PdfUATestPdfDocument(new PdfWriter(new ByteArrayOutputStream())); Document document = new Document(pdfDoc); Image img = new Image(ImageDataFactory.create(DOG)); img.getAccessibilityProperties().setAlternateDescription(""); - Exception e = Assert.assertThrows(PdfUAConformanceException.class, () -> { + Exception e = Assertions.assertThrows(PdfUAConformanceException.class, () -> { document.add(img); }); - Assert.assertEquals(PdfUAExceptionMessageConstants.IMAGE_SHALL_HAVE_ALT, e.getMessage()); + Assertions.assertEquals(PdfUAExceptionMessageConstants.IMAGE_SHALL_HAVE_ALT, e.getMessage()); } @Test - public void imageCustomRole_Ok() throws FileNotFoundException { + public void imageCustomRole_Ok() throws IOException { framework.addBeforeGenerationHook((pdfDocument) -> { PdfStructTreeRoot root = pdfDocument.getStructTreeRoot(); root.addRoleMapping("CustomImage", StandardRoles.FIGURE); @@ -142,7 +136,7 @@ public IBlockElement generate() { } @Test - public void imageCustomDoubleMapping_Ok() throws FileNotFoundException { + public void imageCustomDoubleMapping_Ok() throws IOException { framework.addBeforeGenerationHook((pdfDocument) -> { PdfStructTreeRoot root = pdfDocument.getStructTreeRoot(); root.addRoleMapping("CustomImage", StandardRoles.FIGURE); @@ -166,7 +160,7 @@ public IBlockElement generate() { } @Test - public void imageCustomRoleNoAlternateDescription_Throws() throws FileNotFoundException { + public void imageCustomRoleNoAlternateDescription_Throws() throws IOException { framework.addBeforeGenerationHook((pdfDocument) -> { PdfStructTreeRoot root = pdfDocument.getStructTreeRoot(); root.addRoleMapping("CustomImage", StandardRoles.FIGURE); @@ -188,7 +182,7 @@ public IBlockElement generate() { } @Test - public void imageCustomDoubleMapping_Throws() throws FileNotFoundException { + public void imageCustomDoubleMapping_Throws() throws IOException { framework.addBeforeGenerationHook((pdfDocument) -> { PdfStructTreeRoot root = pdfDocument.getStructTreeRoot(); root.addRoleMapping("CustomImage", StandardRoles.FIGURE); @@ -213,15 +207,14 @@ public IBlockElement generate() { @Test public void imageWithValidAlternativeDescription_OK() throws IOException, InterruptedException { final String OUTPUT_FILE = DESTINATION_FOLDER + "imageWithValidAlternativeDescription_OK.pdf"; - PdfDocument pdfDoc = new PdfUATestPdfDocument(new PdfWriter(OUTPUT_FILE, - new WriterProperties().addUAXmpMetadata().setPdfVersion(PdfVersion.PDF_1_7))); + PdfDocument pdfDoc = new PdfUATestPdfDocument(new PdfWriter(OUTPUT_FILE)); Document document = new Document(pdfDoc); Image img = new Image(ImageDataFactory.create(DOG)); img.getAccessibilityProperties().setAlternateDescription("Alternative description"); document.add(img); document.close(); - Assert.assertNull(new VeraPdfValidator().validate(OUTPUT_FILE));// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) - Assert.assertNull(new CompareTool().compareByContent(OUTPUT_FILE, + Assertions.assertNull(new VeraPdfValidator().validate(OUTPUT_FILE));// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNull(new CompareTool().compareByContent(OUTPUT_FILE, SOURCE_FOLDER + "cmp_imageWithValidAlternativeDescription_OK.pdf", DESTINATION_FOLDER, "diff_")); } @@ -229,15 +222,14 @@ public void imageWithValidAlternativeDescription_OK() throws IOException, Interr @Test public void imageWithValidActualText_OK() throws IOException, InterruptedException { final String OUTPUT_FILE = DESTINATION_FOLDER + "imageWithValidActualText_OK.pdf"; - PdfDocument pdfDoc = new PdfUATestPdfDocument(new PdfWriter(OUTPUT_FILE, - new WriterProperties().addUAXmpMetadata().setPdfVersion(PdfVersion.PDF_1_7))); + PdfDocument pdfDoc = new PdfUATestPdfDocument(new PdfWriter(OUTPUT_FILE)); Document document = new Document(pdfDoc); Image img = new Image(ImageDataFactory.create(DOG)); img.getAccessibilityProperties().setActualText("Actual text"); document.add(img); document.close(); - Assert.assertNull(new VeraPdfValidator().validate(OUTPUT_FILE));// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) - Assert.assertNull( + Assertions.assertNull(new VeraPdfValidator().validate(OUTPUT_FILE));// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNull( new CompareTool().compareByContent(OUTPUT_FILE, SOURCE_FOLDER + "cmp_imageWithValidActualText_OK.pdf", DESTINATION_FOLDER, "diff_")); } @@ -245,8 +237,7 @@ public void imageWithValidActualText_OK() throws IOException, InterruptedExcepti @Test public void imageWithCaption_OK() throws IOException, InterruptedException { final String OUTPUT_FILE = DESTINATION_FOLDER + "imageWithCaption_OK.pdf"; - PdfDocument pdfDoc = new PdfUATestPdfDocument(new PdfWriter(OUTPUT_FILE, - new WriterProperties().addUAXmpMetadata().setPdfVersion(PdfVersion.PDF_1_7))); + PdfDocument pdfDoc = new PdfUATestPdfDocument(new PdfWriter(OUTPUT_FILE)); Document document = new Document(pdfDoc); Div imgWithCaption = new Div(); @@ -264,16 +255,15 @@ public void imageWithCaption_OK() throws IOException, InterruptedException { document.add(imgWithCaption); document.close(); - Assert.assertNull(new VeraPdfValidator().validate(OUTPUT_FILE)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) - Assert.assertNull( + Assertions.assertNull(new VeraPdfValidator().validate(OUTPUT_FILE)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNull( new CompareTool().compareByContent(OUTPUT_FILE, SOURCE_FOLDER + "cmp_imageWithCaption_OK.pdf", DESTINATION_FOLDER, "diff_")); } @Test public void imageWithCaptionWithoutAlternateDescription_Throws() throws IOException { - PdfDocument pdfDoc = new PdfUATestPdfDocument(new PdfWriter(new ByteArrayOutputStream(), - new WriterProperties().addUAXmpMetadata().setPdfVersion(PdfVersion.PDF_1_7))); + PdfDocument pdfDoc = new PdfUATestPdfDocument(new PdfWriter(new ByteArrayOutputStream())); Document document = new Document(pdfDoc); Div imgWithCaption = new Div(); @@ -288,29 +278,27 @@ public void imageWithCaptionWithoutAlternateDescription_Throws() throws IOExcept // will not throw in layout but will throw on close this is expected document.add(imgWithCaption); - Exception e = Assert.assertThrows(PdfUAConformanceException.class, () -> { + Exception e = Assertions.assertThrows(PdfUAConformanceException.class, () -> { document.close(); }); - Assert.assertEquals(PdfUAExceptionMessageConstants.IMAGE_SHALL_HAVE_ALT, e.getMessage()); + Assertions.assertEquals(PdfUAExceptionMessageConstants.IMAGE_SHALL_HAVE_ALT, e.getMessage()); } @Test public void imageWithoutActualText_ThrowsInLayout() throws MalformedURLException { - PdfDocument pdfDoc = new PdfUATestPdfDocument(new PdfWriter(new ByteArrayOutputStream(), - new WriterProperties().addUAXmpMetadata().setPdfVersion(PdfVersion.PDF_1_7))); + PdfDocument pdfDoc = new PdfUATestPdfDocument(new PdfWriter(new ByteArrayOutputStream())); Document document = new Document(pdfDoc); Image img = new Image(ImageDataFactory.create(DOG)); img.getAccessibilityProperties().setActualText(null); - Exception e = Assert.assertThrows(PdfUAConformanceException.class, () -> { + Exception e = Assertions.assertThrows(PdfUAConformanceException.class, () -> { document.add(img); }); - Assert.assertEquals(PdfUAExceptionMessageConstants.IMAGE_SHALL_HAVE_ALT, e.getMessage()); + Assertions.assertEquals(PdfUAExceptionMessageConstants.IMAGE_SHALL_HAVE_ALT, e.getMessage()); } @Test public void imageWithEmptyActualText_ThrowsInLayout() throws MalformedURLException { - PdfDocument pdfDoc = new PdfUATestPdfDocument(new PdfWriter(new ByteArrayOutputStream(), - new WriterProperties().addUAXmpMetadata().setPdfVersion(PdfVersion.PDF_1_7))); + PdfDocument pdfDoc = new PdfUATestPdfDocument(new PdfWriter(new ByteArrayOutputStream())); Document document = new Document(pdfDoc); Image img = new Image(ImageDataFactory.create(DOG)); @@ -322,8 +310,7 @@ public void imageWithEmptyActualText_ThrowsInLayout() throws MalformedURLExcepti @Test public void imageDirectlyOnCanvas_OK() throws IOException, InterruptedException { String OUTPUT_FILE = DESTINATION_FOLDER + "imageDirectlyOnCanvas_OK.pdf"; - PdfDocument pdfDoc = new PdfUATestPdfDocument(new PdfWriter(OUTPUT_FILE, - new WriterProperties().addUAXmpMetadata().setPdfVersion(PdfVersion.PDF_1_7))); + PdfDocument pdfDoc = new PdfUATestPdfDocument(new PdfWriter(OUTPUT_FILE)); Document document = new Document(pdfDoc); Image img = new Image(ImageDataFactory.create(DOG)); @@ -351,7 +338,7 @@ public void imageDirectlyOnCanvas_OK() throws IOException, InterruptedException canvas.closeTag(); pdfDoc.close(); - Assert.assertNull(new VeraPdfValidator().validate(OUTPUT_FILE)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNull(new VeraPdfValidator().validate(OUTPUT_FILE)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) new CompareTool().compareByContent(OUTPUT_FILE, SOURCE_FOLDER + "cmp_imageDirectlyOnCanvas_OK.pdf", DESTINATION_FOLDER, "diff_"); } @@ -359,8 +346,7 @@ public void imageDirectlyOnCanvas_OK() throws IOException, InterruptedException @Test public void imageDirectlyOnCanvasWithoutAlternateDescription_ThrowsOnClose() throws IOException { - PdfDocument pdfDoc = new PdfUATestPdfDocument(new PdfWriter(new ByteArrayOutputStream(), - new WriterProperties().addUAXmpMetadata().setPdfVersion(PdfVersion.PDF_1_7))); + PdfDocument pdfDoc = new PdfUATestPdfDocument(new PdfWriter(new ByteArrayOutputStream())); TagTreePointer pointerForImage = new TagTreePointer(pdfDoc); PdfPage page = pdfDoc.addNewPage(); @@ -370,17 +356,16 @@ public void imageDirectlyOnCanvasWithoutAlternateDescription_ThrowsOnClose() canvas.openTag(tmp.getTagReference()); canvas.addImageAt(ImageDataFactory.create(DOG), 200, 200, false); canvas.closeTag(); - Exception e = Assert.assertThrows(PdfUAConformanceException.class, () -> { + Exception e = Assertions.assertThrows(PdfUAConformanceException.class, () -> { pdfDoc.close(); }); - Assert.assertEquals(PdfUAExceptionMessageConstants.IMAGE_SHALL_HAVE_ALT, e.getMessage()); + Assertions.assertEquals(PdfUAExceptionMessageConstants.IMAGE_SHALL_HAVE_ALT, e.getMessage()); } @Test public void imageDirectlyOnCanvasWithEmptyActualText_OK() throws IOException { - PdfDocument pdfDoc = new PdfUATestPdfDocument(new PdfWriter(new ByteArrayOutputStream(), - new WriterProperties().addUAXmpMetadata().setPdfVersion(PdfVersion.PDF_1_7))); + PdfDocument pdfDoc = new PdfUATestPdfDocument(new PdfWriter(new ByteArrayOutputStream())); TagTreePointer pointerForImage = new TagTreePointer(pdfDoc); PdfPage page = pdfDoc.addNewPage(); @@ -396,13 +381,12 @@ public void imageDirectlyOnCanvasWithEmptyActualText_OK() @Test public void testOverflowImage() throws IOException { - PdfDocument pdfDoc = new PdfUATestPdfDocument(new PdfWriter(new ByteArrayOutputStream(), - new WriterProperties().addUAXmpMetadata().setPdfVersion(PdfVersion.PDF_1_7))); + PdfDocument pdfDoc = new PdfUATestPdfDocument(new PdfWriter(new ByteArrayOutputStream())); Image img = new Image(ImageDataFactory.create(DOG)); Document document = new Document(pdfDoc); document.add(new Div().setHeight(730).setBackgroundColor(ColorConstants.CYAN)); - Assert.assertThrows(PdfUAConformanceException.class, () -> { + Assertions.assertThrows(PdfUAConformanceException.class, () -> { document.add(img); }); @@ -410,8 +394,7 @@ public void testOverflowImage() throws IOException { @Test public void testEmbeddedImageInTable() throws MalformedURLException { - PdfDocument pdfDoc = new PdfUATestPdfDocument(new PdfWriter(new ByteArrayOutputStream(), - new WriterProperties().addUAXmpMetadata().setPdfVersion(PdfVersion.PDF_1_7))); + PdfDocument pdfDoc = new PdfUATestPdfDocument(new PdfWriter(new ByteArrayOutputStream())); Image img = new Image(ImageDataFactory.create(DOG)); Document document = new Document(pdfDoc); Table table = new Table(2); @@ -420,33 +403,31 @@ public void testEmbeddedImageInTable() throws MalformedURLException { } table.addCell(img); - Assert.assertThrows(PdfUAConformanceException.class, () -> { + Assertions.assertThrows(PdfUAConformanceException.class, () -> { document.add(table); }); } @Test public void testEmbeddedImageInDiv() throws MalformedURLException { - PdfDocument pdfDoc = new PdfUATestPdfDocument(new PdfWriter(new ByteArrayOutputStream(), - new WriterProperties().addUAXmpMetadata().setPdfVersion(PdfVersion.PDF_1_7))); + PdfDocument pdfDoc = new PdfUATestPdfDocument(new PdfWriter(new ByteArrayOutputStream())); Image img = new Image(ImageDataFactory.create(DOG)); Document document = new Document(pdfDoc); Div div = new Div(); div.add(img); - Assert.assertThrows(PdfUAConformanceException.class, () -> { + Assertions.assertThrows(PdfUAConformanceException.class, () -> { document.add(div); }); } @Test public void testEmbeddedImageInParagraph() throws MalformedURLException { - PdfDocument pdfDoc = new PdfUATestPdfDocument(new PdfWriter(new ByteArrayOutputStream(), - new WriterProperties().addUAXmpMetadata().setPdfVersion(PdfVersion.PDF_1_7))); + PdfDocument pdfDoc = new PdfUATestPdfDocument(new PdfWriter(new ByteArrayOutputStream())); Image img = new Image(ImageDataFactory.create(DOG)); Document document = new Document(pdfDoc); Div div = new Div(); div.add(img); - Assert.assertThrows(PdfUAConformanceException.class, () -> { + Assertions.assertThrows(PdfUAConformanceException.class, () -> { document.add(div); }); } diff --git a/pdfua/src/test/java/com/itextpdf/pdfua/checkers/PdfUAHeadingsTest.java b/pdfua/src/test/java/com/itextpdf/pdfua/checkers/PdfUAHeadingsTest.java index 716bf38c96..8d00950fc4 100644 --- a/pdfua/src/test/java/com/itextpdf/pdfua/checkers/PdfUAHeadingsTest.java +++ b/pdfua/src/test/java/com/itextpdf/pdfua/checkers/PdfUAHeadingsTest.java @@ -44,22 +44,20 @@ This file is part of the iText (R) project. import com.itextpdf.pdfua.UaValidationTestFramework.Generator; import com.itextpdf.pdfua.exceptions.PdfUAConformanceException; import com.itextpdf.pdfua.exceptions.PdfUAExceptionMessageConstants; -import com.itextpdf.pdfua.exceptions.PdfUALogMessageConstants; +import com.itextpdf.pdfua.logs.PdfUALogMessageConstants; import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import com.itextpdf.test.pdfa.VeraPdfValidator; // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) -import java.io.FileNotFoundException; import java.io.IOException; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfUAHeadingsTest extends ExtendedITextTest { private static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/pdfua/PdfUAHeadingsTest/"; private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/pdfua/PdfUAHeadingsTest/"; @@ -67,12 +65,12 @@ public class PdfUAHeadingsTest extends ExtendedITextTest { private UaValidationTestFramework framework; - @BeforeClass + @BeforeAll public static void before() { createOrClearDestinationFolder(DESTINATION_FOLDER); } - @Before + @BeforeEach public void initializeFramework() { framework = new UaValidationTestFramework(DESTINATION_FOLDER); } @@ -365,7 +363,7 @@ public IBlockElement generate() { } @Test - public void directWritingToCanvasTest() throws FileNotFoundException { + public void directWritingToCanvasTest() throws IOException { String outPdf = DESTINATION_FOLDER + "directWritingToCanvasTest.pdf"; PdfUATestPdfDocument pdfDoc = new PdfUATestPdfDocument( @@ -380,8 +378,8 @@ public void directWritingToCanvasTest() throws FileNotFoundException { canvas.openTag(tmp.getTagReference()); canvas.writeLiteral("Heading level 3"); canvas.closeTag(); - Exception e = Assert.assertThrows(PdfUAConformanceException.class, () -> pdfDoc.close()); - Assert.assertEquals(PdfUAExceptionMessageConstants.H1_IS_SKIPPED, e.getMessage()); + Exception e = Assertions.assertThrows(PdfUAConformanceException.class, () -> pdfDoc.close()); + Assertions.assertEquals(PdfUAExceptionMessageConstants.H1_IS_SKIPPED, e.getMessage()); } // -------- Positive tests -------- @@ -440,8 +438,8 @@ public void flushPreviousPageTest() throws IOException, InterruptedException { } } doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); - Assert.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) } @Test @@ -633,7 +631,7 @@ public void usualHTest() throws IOException, InterruptedException { doc.add(div); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); // VeraPdf here throw exception that "A node contains more than one H tag", because // it seems that VeraPdf consider div as a not grouping element. See usualHTest2 test // with the same code, but div role is replaced by section role diff --git a/pdfua/src/test/java/com/itextpdf/pdfua/checkers/PdfUALayoutTest.java b/pdfua/src/test/java/com/itextpdf/pdfua/checkers/PdfUALayoutTest.java index b12b5b1a81..59bcb55089 100644 --- a/pdfua/src/test/java/com/itextpdf/pdfua/checkers/PdfUALayoutTest.java +++ b/pdfua/src/test/java/com/itextpdf/pdfua/checkers/PdfUALayoutTest.java @@ -54,19 +54,18 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import com.itextpdf.test.pdfa.VeraPdfValidator; // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) import java.io.IOException; import java.nio.charset.StandardCharsets; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfUALayoutTest extends ExtendedITextTest { private static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/pdfua/PdfUALayoutTest/"; private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/pdfua/PdfUALayoutTest/"; @@ -74,12 +73,12 @@ public class PdfUALayoutTest extends ExtendedITextTest { private UaValidationTestFramework framework; - @Before + @BeforeEach public void initializeFramework() { framework = new UaValidationTestFramework(DESTINATION_FOLDER); } - @BeforeClass + @BeforeAll public static void before() { createOrClearDestinationFolder(DESTINATION_FOLDER); } @@ -97,13 +96,13 @@ public void simpleParagraphTest() throws IOException, InterruptedException { doc.add(new Paragraph("Simple layout PDF/UA-1 test").setFont(font)); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); - Assert.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) } @Test public void simpleParagraphWithUnderlineTest() throws IOException, InterruptedException { - String outPdf = DESTINATION_FOLDER + "simpleParagraphTest.pdf"; + String outPdf = DESTINATION_FOLDER + "simpleParagraphUnderlinesTest.pdf"; String cmpPdf = SOURCE_FOLDER + "cmp_simpleParagraphWithUnderlineTest.pdf"; PdfUATestPdfDocument pdfDoc = new PdfUATestPdfDocument( @@ -114,8 +113,8 @@ public void simpleParagraphWithUnderlineTest() throws IOException, InterruptedEx doc.add(new Paragraph("Simple layout PDF/UA-1 with underline test").setFont(font).setUnderline()); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); - Assert.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) } @Test @@ -135,8 +134,8 @@ public void simpleBorderTest() throws IOException, InterruptedException { } - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER, "diff")); - Assert.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) } @Test @@ -154,8 +153,8 @@ public void simpleTableTest() throws IOException, InterruptedException { doc.add(table); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); - Assert.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) } @Test diff --git a/pdfua/src/test/java/com/itextpdf/pdfua/checkers/PdfUARoleMappingTest.java b/pdfua/src/test/java/com/itextpdf/pdfua/checkers/PdfUARoleMappingTest.java index 376bcba662..6e3f5c619f 100644 --- a/pdfua/src/test/java/com/itextpdf/pdfua/checkers/PdfUARoleMappingTest.java +++ b/pdfua/src/test/java/com/itextpdf/pdfua/checkers/PdfUARoleMappingTest.java @@ -50,23 +50,22 @@ This file is part of the iText (R) project. import com.itextpdf.test.LogLevelConstants; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import com.itextpdf.test.pdfa.VeraPdfValidator; // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) import java.io.IOException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfUARoleMappingTest extends ExtendedITextTest { private static final String FONT = "./src/test/resources/com/itextpdf/pdfua/font/FreeSans.ttf"; private static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/pdfua/PdfUARoleMappingTest/"; private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/pdfua/PdfUARoleMappingTest/"; - @BeforeClass + @BeforeAll public static void before() { createOrClearDestinationFolder(DESTINATION_FOLDER); } @@ -81,8 +80,8 @@ public void nonStandardMappingViaTagTreePointer1_02_001_Test() throws IOExceptio TagTreePointer tagPointer = new TagTreePointer(pdfDoc).setPageForTagging(page1); - Exception e = Assert.assertThrows(PdfException.class, () -> tagPointer.addTag("chapter")); - Assert.assertEquals( + Exception e = Assertions.assertThrows(PdfException.class, () -> tagPointer.addTag("chapter")); + Assertions.assertEquals( MessageFormatUtil.format(KernelExceptionMessageConstant.ROLE_IS_NOT_MAPPED_TO_ANY_STANDARD_ROLE, "chapter"), e.getMessage()); } @@ -101,8 +100,8 @@ public void nonStandardMappingViaTagTreePointer2_02_001_Test() throws IOExceptio TagTreePointer tagPointer = new TagTreePointer(pdfDoc).setPageForTagging(page1); - Exception e = Assert.assertThrows(PdfException.class, () -> tagPointer.addTag("chapter")); - Assert.assertEquals( + Exception e = Assertions.assertThrows(PdfException.class, () -> tagPointer.addTag("chapter")); + Assertions.assertEquals( MessageFormatUtil.format(KernelExceptionMessageConstant.ROLE_IS_NOT_MAPPED_TO_ANY_STANDARD_ROLE, "chapter"), e.getMessage()); } @@ -120,8 +119,8 @@ public void nonStandardMappingViaTagTreePointer3_02_001_Test() throws IOExceptio // Although PDF/UA defines the nomenclature for heading levels above

    (), these are not standard // structure types and therefore tags must be role-mapped to a standard structure type. // According to PDF/UA-1, PDF/UA-conforming processors are expected to ignore such mappings and respect the heading level. - Exception e = Assert.assertThrows(PdfException.class, () -> tagPointer.addTag("H7")); - Assert.assertEquals( + Exception e = Assertions.assertThrows(PdfException.class, () -> tagPointer.addTag("H7")); + Assertions.assertEquals( MessageFormatUtil.format(KernelExceptionMessageConstant.ROLE_IS_NOT_MAPPED_TO_ANY_STANDARD_ROLE, "H7"), e.getMessage()); } @@ -139,8 +138,8 @@ public void nonStandardMappingViaPdfName_02_001_Test() throws IOException { // Another attempts of PDF/UA document creation with non-standard tags see in PdfUACanvasTest class - Exception e = Assert.assertThrows(PdfUAConformanceException.class, () -> canvas.openTag(new CanvasTag(new PdfName("chapter")))); - Assert.assertEquals( + Exception e = Assertions.assertThrows(PdfUAConformanceException.class, () -> canvas.openTag(new CanvasTag(new PdfName("chapter")))); + Assertions.assertEquals( MessageFormatUtil.format(PdfUAExceptionMessageConstants.TAG_MAPPING_DOESNT_TERMINATE_WITH_STANDARD_TYPE, "chapter"), e.getMessage()); } @@ -160,8 +159,8 @@ public void nonStandardMappingViaPdfMcr_02_001_Test() throws IOException { PdfCanvas canvas = new PdfCanvas(page1); - Exception e = Assert.assertThrows(PdfUAConformanceException.class, () -> canvas.openTag(new CanvasTag(mcr))); - Assert.assertEquals( + Exception e = Assertions.assertThrows(PdfUAConformanceException.class, () -> canvas.openTag(new CanvasTag(mcr))); + Assertions.assertEquals( MessageFormatUtil.format(PdfUAExceptionMessageConstants.TAG_MAPPING_DOESNT_TERMINATE_WITH_STANDARD_TYPE, "chapter"), e.getMessage()); } @@ -196,8 +195,8 @@ public void standardMappingViaTagTreePointer_02_001_Test() throws IOException, I pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); - Assert.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) } @Test @@ -226,8 +225,8 @@ public void standardMappingViaNamespace_02_001_Test() throws IOException { PdfCanvas canvas = new PdfCanvas(page1); // VeraPdf also complains about non-standard mapping - Exception e = Assert.assertThrows(PdfUAConformanceException.class, () -> canvas.openTag(new CanvasTag(mcr))); - Assert.assertEquals( + Exception e = Assertions.assertThrows(PdfUAConformanceException.class, () -> canvas.openTag(new CanvasTag(mcr))); + Assertions.assertEquals( MessageFormatUtil.format(PdfUAExceptionMessageConstants.TAG_MAPPING_DOESNT_TERMINATE_WITH_STANDARD_TYPE, "chapter"), e.getMessage()); } @@ -249,8 +248,8 @@ public void cycleMappingViaTagTreePointer1_02_003_Test() throws IOException { TagTreePointer tagPointer = new TagTreePointer(pdfDoc).setPageForTagging(page1); - Exception e = Assert.assertThrows(PdfException.class, () -> tagPointer.addTag("chapter")); - Assert.assertEquals( + Exception e = Assertions.assertThrows(PdfException.class, () -> tagPointer.addTag("chapter")); + Assertions.assertEquals( MessageFormatUtil.format(KernelExceptionMessageConstant.ROLE_IS_NOT_MAPPED_TO_ANY_STANDARD_ROLE, "chapter"), e.getMessage()); } @@ -281,8 +280,8 @@ public void cycleMappingViaTagTreePointer2_02_003_Test() throws IOException { .closeTag(); // VeraPdf complains about circular mapping - Exception e = Assert.assertThrows(PdfException.class, () -> pdfDoc.close()); - Assert.assertEquals(PdfUAExceptionMessageConstants.ONE_OR_MORE_STANDARD_ROLE_REMAPPED, e.getMessage()); + Exception e = Assertions.assertThrows(PdfException.class, () -> pdfDoc.close()); + Assertions.assertEquals(PdfUAExceptionMessageConstants.ONE_OR_MORE_STANDARD_ROLE_REMAPPED, e.getMessage()); } @Test @@ -311,7 +310,7 @@ public void mappingStandardRoles_02_004_Test() throws IOException { .closeTag(); // VeraPdf doesn't complain - Exception e = Assert.assertThrows(PdfException.class, () -> pdfDoc.close()); - Assert.assertEquals(PdfUAExceptionMessageConstants.ONE_OR_MORE_STANDARD_ROLE_REMAPPED, e.getMessage()); + Exception e = Assertions.assertThrows(PdfException.class, () -> pdfDoc.close()); + Assertions.assertEquals(PdfUAExceptionMessageConstants.ONE_OR_MORE_STANDARD_ROLE_REMAPPED, e.getMessage()); } } diff --git a/pdfua/src/test/java/com/itextpdf/pdfua/checkers/PdfUATableTest.java b/pdfua/src/test/java/com/itextpdf/pdfua/checkers/PdfUATableTest.java index a4a51e5d3b..0a9b25ed61 100644 --- a/pdfua/src/test/java/com/itextpdf/pdfua/checkers/PdfUATableTest.java +++ b/pdfua/src/test/java/com/itextpdf/pdfua/checkers/PdfUATableTest.java @@ -37,43 +37,41 @@ This file is part of the iText (R) project. import com.itextpdf.layout.element.Table; import com.itextpdf.pdfua.UaValidationTestFramework; import com.itextpdf.pdfua.UaValidationTestFramework.Generator; -import com.itextpdf.pdfua.exceptions.PdfUALogMessageConstants; +import com.itextpdf.pdfua.logs.PdfUALogMessageConstants; import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; -import java.io.FileNotFoundException; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfUATableTest extends ExtendedITextTest { private static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/pdfua/PdfUATableTest/"; private static final String FONT = "./src/test/resources/com/itextpdf/pdfua/font/FreeSans.ttf"; - @BeforeClass + @BeforeAll public static void before() { createOrClearDestinationFolder(DESTINATION_FOLDER); } private UaValidationTestFramework framework; - @Before + @BeforeEach public void initializeFramework(){ framework = new UaValidationTestFramework(DESTINATION_FOLDER); } @Test - public void tableWithoutHeaders01() throws FileNotFoundException { + public void tableWithoutHeaders01() throws IOException { TableBuilder tableBuilder = new TableBuilder(4); for (int i = 0; i < 16; i++) { tableBuilder.addBodyCell(new DataCellSupplier("Data 1", 1, 1, null)); @@ -84,7 +82,7 @@ public void tableWithoutHeaders01() throws FileNotFoundException { } @Test - public void tableWithoutHeaders02() throws FileNotFoundException { + public void tableWithoutHeaders02() throws IOException { TableBuilder tableBuilder = new TableBuilder(4); for (int i = 0; i < 4; i++) { tableBuilder.addHeaderCell(new DataCellSupplier("Data 1", 1, 1, null)); @@ -101,7 +99,7 @@ public void tableWithoutHeaders02() throws FileNotFoundException { } @Test - public void tableWithHeaderScopeColumn01() throws FileNotFoundException { + public void tableWithHeaderScopeColumn01() throws IOException { TableBuilder tableBuilder = new TableBuilder(4); tableBuilder.addBodyCell(new HeaderCellSupplier(null, "Header 1", 1, 1, "Column")); tableBuilder.addBodyCell(new HeaderCellSupplier(null, "Header 2", 1, 1, "Column")); @@ -116,7 +114,7 @@ public void tableWithHeaderScopeColumn01() throws FileNotFoundException { } @Test - public void tableWithHeaderScopeColumn02() throws FileNotFoundException { + public void tableWithHeaderScopeColumn02() throws IOException { TableBuilder tableBuilder = new TableBuilder(4); tableBuilder.addHeaderCell(new HeaderCellSupplier(null, "Header 1", 1, 1, "Column")); tableBuilder.addHeaderCell(new HeaderCellSupplier(null, "Header 2", 1, 1, "Column")); @@ -131,7 +129,7 @@ public void tableWithHeaderScopeColumn02() throws FileNotFoundException { } @Test - public void tableWithHeaderScopeColumn03() throws FileNotFoundException { + public void tableWithHeaderScopeColumn03() throws IOException { TableBuilder tableBuilder = new TableBuilder(4); tableBuilder.addFooterCell(new HeaderCellSupplier(null, "Header 1", 1, 1, "Column")); tableBuilder.addFooterCell(new HeaderCellSupplier(null, "Header 2", 1, 1, "Column")); @@ -149,7 +147,7 @@ public void tableWithHeaderScopeColumn03() throws FileNotFoundException { @LogMessages(messages = { @LogMessage(messageTemplate = IoLogMessageConstant.LAST_ROW_IS_NOT_COMPLETE, count = 2) }) - public void tableWithHeaderScopeColumn04() throws FileNotFoundException { + public void tableWithHeaderScopeColumn04() throws IOException { TableBuilder tableBuilder = new TableBuilder(4); tableBuilder.addBodyCell(new HeaderCellSupplier(null, "Header 1", 1, 1, "Column")); tableBuilder.addBodyCell(new HeaderCellSupplier(null, "Header 2", 1, 1, "Column")); @@ -166,7 +164,7 @@ public void tableWithHeaderScopeColumn04() throws FileNotFoundException { @Test - public void tableWithHeaderScopeColumn05() throws FileNotFoundException { + public void tableWithHeaderScopeColumn05() throws IOException { TableBuilder tableBuilder = new TableBuilder(4); tableBuilder.addBodyCell(new HeaderCellSupplier(null, "Header 1", 1, 1, "Column")); tableBuilder.addBodyCell(new HeaderCellSupplier(null, "Header 2", 1, 1, "Column")); @@ -181,7 +179,7 @@ public void tableWithHeaderScopeColumn05() throws FileNotFoundException { } @Test - public void tableWithHeaderScopeColumn06() throws FileNotFoundException { + public void tableWithHeaderScopeColumn06() throws IOException { TableBuilder tableBuilder = new TableBuilder(4); tableBuilder.addBodyCell(new HeaderCellSupplier(null, "Header 1", 2, 1, "Column")); tableBuilder.addBodyCell(new HeaderCellSupplier(null, "Header 2", 1, 1, "Column")); @@ -196,7 +194,7 @@ public void tableWithHeaderScopeColumn06() throws FileNotFoundException { } @Test - public void tableWithHeaderScopeColumn07() throws FileNotFoundException { + public void tableWithHeaderScopeColumn07() throws IOException { TableBuilder tableBuilder = new TableBuilder(4); tableBuilder.addBodyCell(new HeaderCellSupplier(null, "Header 1", 4, 1, "Column")); for (int i = 0; i < 12; i++) { @@ -208,7 +206,7 @@ public void tableWithHeaderScopeColumn07() throws FileNotFoundException { } @Test - public void tableWithHeaderScopeColumn08() throws FileNotFoundException { + public void tableWithHeaderScopeColumn08() throws IOException { TableBuilder tableBuilder = new TableBuilder(4); tableBuilder.addBodyCell(new HeaderCellSupplier(null, "Header 1", 1, 1, "Column")); tableBuilder.addBodyCell(new HeaderCellSupplier(null, "Header 2", 1, 1, "Column")); @@ -226,7 +224,7 @@ public void tableWithHeaderScopeColumn08() throws FileNotFoundException { } @Test - public void tableWithHeaderScopeColumn09() throws FileNotFoundException { + public void tableWithHeaderScopeColumn09() throws IOException { TableBuilder tableBuilder = new TableBuilder(4); tableBuilder.addBodyCell(new HeaderCellSupplier(null, "Header 1", 1, 1, "Column")); tableBuilder.addBodyCell(new HeaderCellSupplier(null, "Header 2", 1, 1, "Column")); @@ -243,7 +241,7 @@ public void tableWithHeaderScopeColumn09() throws FileNotFoundException { } @Test - public void tableWithHeaderScopeColumn10() throws FileNotFoundException { + public void tableWithHeaderScopeColumn10() throws IOException { TableBuilder tableBuilder = new TableBuilder(4); tableBuilder.addBodyCell(new HeaderCellSupplier(null, "Header 1", 1, 1, "Column")); tableBuilder.addBodyCell(new HeaderCellSupplier(null, "Header 2", 1, 1, "Column")); @@ -259,7 +257,7 @@ public void tableWithHeaderScopeColumn10() throws FileNotFoundException { } @Test - public void tableWithHeaderScopeColumn11() throws FileNotFoundException { + public void tableWithHeaderScopeColumn11() throws IOException { TableBuilder tableBuilder = new TableBuilder(4); tableBuilder.addFooterCell(new HeaderCellSupplier(null, "Header 1", 1, 1, "Column")); tableBuilder.addFooterCell(new HeaderCellSupplier(null, "Header 2", 1, 1, "Column")); @@ -276,7 +274,7 @@ public void tableWithHeaderScopeColumn11() throws FileNotFoundException { @Test - public void tableWithHeaderScopeColumn12() throws FileNotFoundException { + public void tableWithHeaderScopeColumn12() throws IOException { TableBuilder tableBuilder = new TableBuilder(5); for (int i = 0; i < 10; i++) { tableBuilder.addBodyCell(new DataCellSupplier("Data 1", 1, 1, null)); @@ -296,7 +294,7 @@ public void tableWithHeaderScopeColumn12() throws FileNotFoundException { @Test - public void tableWithHeaderScopeColumn13() throws FileNotFoundException { + public void tableWithHeaderScopeColumn13() throws IOException { TableBuilder tableBuilder = new TableBuilder(3); tableBuilder.addHeaderCell(new HeaderCellSupplier(null, "Header 1", 1, 1, "Column")); tableBuilder.addHeaderCell(new HeaderCellSupplier(null, "Header 2", 1, 1, "Column")); @@ -319,7 +317,7 @@ public Cell generate() { } @Test - public void tableWithHeaderScopeColumn14() throws FileNotFoundException { + public void tableWithHeaderScopeColumn14() throws IOException { TableBuilder tableBuilder = new TableBuilder(4); tableBuilder.addBodyCell(new HeaderCellSupplier(null, "Header 1", 1, 1, "Column")); tableBuilder.addBodyCell(new HeaderCellSupplier(null, "Header 2", 1, 1, "None")); @@ -335,7 +333,7 @@ public void tableWithHeaderScopeColumn14() throws FileNotFoundException { @Test - public void tableWithHeaderScopeColumn15() throws FileNotFoundException { + public void tableWithHeaderScopeColumn15() throws IOException { TableBuilder tableBuilder = new TableBuilder(4); tableBuilder.addBodyCell(new HeaderCellSupplier(null, "Header 1", 1, 1, "Column")); tableBuilder.addBodyCell(new DataCellSupplier("Data 1", 1, 1, null)); @@ -350,7 +348,7 @@ public void tableWithHeaderScopeColumn15() throws FileNotFoundException { } @Test - public void tableWithHeaderScopeColumn16() throws FileNotFoundException { + public void tableWithHeaderScopeColumn16() throws IOException { TableBuilder tableBuilder = new TableBuilder(4); for (int i = 0; i < 4; i++) { tableBuilder.addBodyCell(new DataCellSupplier("Data 1", 1, 1, null)); @@ -367,7 +365,7 @@ public void tableWithHeaderScopeColumn16() throws FileNotFoundException { } @Test - public void tableWithHeaderRowScope01() throws FileNotFoundException { + public void tableWithHeaderRowScope01() throws IOException { TableBuilder tableBuilder = new TableBuilder(4); tableBuilder.addHeaderCell(new HeaderCellSupplier(null, "Header 1", 1, 1, "Row")); @@ -391,7 +389,7 @@ public void tableWithHeaderRowScope01() throws FileNotFoundException { } @Test - public void tableWithHeaderRowScope02() throws FileNotFoundException { + public void tableWithHeaderRowScope02() throws IOException { TableBuilder tableBuilder = new TableBuilder(4); tableBuilder.addBodyCell(new HeaderCellSupplier(null, "Header 1", 1, 1, "Row")); @@ -404,7 +402,7 @@ public void tableWithHeaderRowScope02() throws FileNotFoundException { } @Test - public void tableWithHeaderRowScope03() throws FileNotFoundException { + public void tableWithHeaderRowScope03() throws IOException { TableBuilder tableBuilder = new TableBuilder(4); tableBuilder.addBodyCell(new DataCellSupplier("Data 1", 3, 1, null)); @@ -417,7 +415,7 @@ public void tableWithHeaderRowScope03() throws FileNotFoundException { } @Test - public void tableWithHeaderRowScope04() throws FileNotFoundException { + public void tableWithHeaderRowScope04() throws IOException { TableBuilder tableBuilder = new TableBuilder(4); tableBuilder.addBodyCell(new DataCellSupplier("Data 1", 2, 1, null)); @@ -435,7 +433,7 @@ public void tableWithHeaderRowScope04() throws FileNotFoundException { } @Test - public void tableWithHeaderRowScope05() throws FileNotFoundException { + public void tableWithHeaderRowScope05() throws IOException { TableBuilder tableBuilder = new TableBuilder(3); tableBuilder.addBodyCell(new HeaderCellSupplier(null, "Header 1", 1, 4, "Row")); @@ -455,7 +453,7 @@ public void tableWithHeaderRowScope05() throws FileNotFoundException { } @Test - public void tableWithHeaderRowScope06() throws FileNotFoundException { + public void tableWithHeaderRowScope06() throws IOException { TableBuilder tableBuilder = new TableBuilder(3); tableBuilder.addBodyCell(new DataCellSupplier("Data 1", 1, 1, null)); tableBuilder.addBodyCell(new HeaderCellSupplier(null, "Header 1", 1, 4, "Row")); @@ -500,7 +498,7 @@ public void tableWithHeaderRowScope06() throws FileNotFoundException { } @Test - public void tableWithHeaderRowScope07() throws FileNotFoundException { + public void tableWithHeaderRowScope07() throws IOException { TableBuilder tableBuilder = new TableBuilder(3); tableBuilder.addBodyCell(new HeaderCellSupplier(null, "Header 1", 1, 1, "Row")); @@ -524,7 +522,7 @@ public Cell generate() { } @Test - public void tableWithHeaderRowScope08() throws FileNotFoundException { + public void tableWithHeaderRowScope08() throws IOException { TableBuilder tableBuilder = new TableBuilder(3); tableBuilder.addBodyCell(new HeaderCellSupplier(null, "Header 1", 1, 1, "Row")); @@ -542,7 +540,7 @@ public void tableWithHeaderRowScope08() throws FileNotFoundException { } @Test - public void tableWithHeaderRowScope09() throws FileNotFoundException { + public void tableWithHeaderRowScope09() throws IOException { TableBuilder tableBuilder = new TableBuilder(3); tableBuilder.addBodyCell(new HeaderCellSupplier(null, "Header 1", 1, 1, "Row")); @@ -560,7 +558,7 @@ public void tableWithHeaderRowScope09() throws FileNotFoundException { } @Test - public void tableWithHeaderBothScope01() throws FileNotFoundException { + public void tableWithHeaderBothScope01() throws IOException { TableBuilder tableBuilder = new TableBuilder(3); tableBuilder.addBodyCell(new DataCellSupplier("Data1", 1, 1, null)); tableBuilder.addBodyCell(new DataCellSupplier("Data1", 1, 1, null)); @@ -579,7 +577,7 @@ public void tableWithHeaderBothScope01() throws FileNotFoundException { @Test - public void tableWithHeaderBothScope02() throws FileNotFoundException { + public void tableWithHeaderBothScope02() throws IOException { TableBuilder tableBuilder = new TableBuilder(3); tableBuilder.addBodyCell(new DataCellSupplier("Data1", 1, 1, null)); tableBuilder.addBodyCell(new DataCellSupplier("Data1", 1, 1, null)); @@ -600,7 +598,7 @@ public void tableWithHeaderBothScope02() throws FileNotFoundException { } @Test - public void tableWithHeaderBothScope03() throws FileNotFoundException { + public void tableWithHeaderBothScope03() throws IOException { TableBuilder tableBuilder = new TableBuilder(3); tableBuilder.addBodyCell(new HeaderCellSupplier(null, "Header", 3, 1, "Both")); @@ -616,7 +614,7 @@ public void tableWithHeaderBothScope03() throws FileNotFoundException { @Test - public void tableWithId01() throws FileNotFoundException { + public void tableWithId01() throws IOException { TableBuilder tableBuilder = new TableBuilder(3); tableBuilder.addBodyCell(new HeaderCellSupplier("id1", "Header", 1, 1, "None")); tableBuilder.addBodyCell(new HeaderCellSupplier("id2", "Header", 1, 1, "None")); @@ -633,7 +631,7 @@ public void tableWithId01() throws FileNotFoundException { @Test - public void tableWithId02() throws FileNotFoundException { + public void tableWithId02() throws IOException { TableBuilder tableBuilder = new TableBuilder(3); tableBuilder.addBodyCell(new HeaderCellSupplier("id1", "Header", 1, 1, "None")); tableBuilder.addBodyCell(new HeaderCellSupplier(null, "Header", 1, 1, "None")); @@ -650,7 +648,7 @@ public void tableWithId02() throws FileNotFoundException { @Test - public void tableWithId03() throws FileNotFoundException { + public void tableWithId03() throws IOException { TableBuilder tableBuilder = new TableBuilder(3); tableBuilder.addBodyCell(new HeaderCellSupplier("id1", "Header", 1, 1, "None")); tableBuilder.addBodyCell(new HeaderCellSupplier("id2", "Header", 1, 1, "None")); @@ -666,7 +664,7 @@ public void tableWithId03() throws FileNotFoundException { } @Test - public void tableWithId04() throws FileNotFoundException { + public void tableWithId04() throws IOException { TableBuilder tableBuilder = new TableBuilder(3); tableBuilder.addHeaderCell(new HeaderCellSupplier("id1", "Header", 1, 1, "None")); tableBuilder.addHeaderCell(new HeaderCellSupplier("id2", "Header", 1, 1, "None")); @@ -682,7 +680,7 @@ public void tableWithId04() throws FileNotFoundException { } @Test - public void tableWithId05() throws FileNotFoundException { + public void tableWithId05() throws IOException { TableBuilder tableBuilder = new TableBuilder(3); tableBuilder.addHeaderCell(new HeaderCellSupplier("id1", "Header", 1, 1, "None")); tableBuilder.addHeaderCell(new HeaderCellSupplier("id2", "Header", 1, 1, "None")); @@ -699,7 +697,7 @@ public void tableWithId05() throws FileNotFoundException { @Test - public void tableWithId06() throws FileNotFoundException { + public void tableWithId06() throws IOException { TableBuilder tableBuilder = new TableBuilder(3); tableBuilder.addHeaderCell(new HeaderCellSupplier("id1", "Header", 1, 1, "None")); tableBuilder.addHeaderCell(new HeaderCellSupplier("id2", "Header", 1, 1, "None")); @@ -720,7 +718,7 @@ public void tableWithId06() throws FileNotFoundException { @Test - public void tableWithId07() throws FileNotFoundException { + public void tableWithId07() throws IOException { TableBuilder tableBuilder = new TableBuilder(3); tableBuilder.addBodyCell(new DataCellSupplier("Data1", 1, 1, Collections.singletonList("id1"))); @@ -741,7 +739,7 @@ public void tableWithId07() throws FileNotFoundException { } @Test - public void tableWithId08() throws FileNotFoundException { + public void tableWithId08() throws IOException { TableBuilder tableBuilder = new TableBuilder(3); tableBuilder.addBodyCell(new DataCellSupplier("Data1", 1, 1, Collections.singletonList("id1"))); @@ -759,7 +757,7 @@ public void tableWithId08() throws FileNotFoundException { @Test - public void tableWithId09() throws FileNotFoundException { + public void tableWithId09() throws IOException { TableBuilder tableBuilder = new TableBuilder(3); tableBuilder.addBodyCell(new HeaderCellSupplier("id1", "Header", 3, 1, "None")); @@ -774,7 +772,7 @@ public void tableWithId09() throws FileNotFoundException { } @Test - public void tableWithId10() throws FileNotFoundException { + public void tableWithId10() throws IOException { TableBuilder tableBuilder = new TableBuilder(3); tableBuilder.addBodyCell(new DataCellSupplier("Data1", 1, 1, Collections.singletonList("id1"))); @@ -790,7 +788,7 @@ public void tableWithId10() throws FileNotFoundException { @Test - public void tableWithId11() throws FileNotFoundException { + public void tableWithId11() throws IOException { TableBuilder tableBuilder = new TableBuilder(3); tableBuilder.addBodyCell(new HeaderCellSupplier("id1", "Header", 1, 3, "None")); @@ -808,7 +806,7 @@ public void tableWithId11() throws FileNotFoundException { } @Test - public void tableWithId12() throws FileNotFoundException { + public void tableWithId12() throws IOException { TableBuilder tableBuilder = new TableBuilder(3); tableBuilder.addBodyCell(new DataCellSupplier("Data1", 1, 1, Collections.singletonList("id1"))); @@ -825,7 +823,7 @@ public void tableWithId12() throws FileNotFoundException { } @Test - public void tableWithId13() throws FileNotFoundException { + public void tableWithId13() throws IOException { TableBuilder tableBuilder = new TableBuilder(3); tableBuilder.addBodyCell(new DataCellSupplier("Data1", 1, 1, Collections.singletonList("id1"))); @@ -842,7 +840,7 @@ public void tableWithId13() throws FileNotFoundException { } @Test - public void tableWithId14() throws FileNotFoundException { + public void tableWithId14() throws IOException { TableBuilder tableBuilder = new TableBuilder(3); tableBuilder.addBodyCell(new DataCellSupplier("Data1", 1, 1, Arrays.asList("id1", "id2"))); @@ -859,7 +857,7 @@ public void tableWithId14() throws FileNotFoundException { } @Test - public void combination01() throws FileNotFoundException { + public void combination01() throws IOException { TableBuilder tableBuilder = new TableBuilder(3); tableBuilder.addBodyCell(new HeaderCellSupplier("id1", "Header1", 1, 1, "None")); @@ -878,7 +876,7 @@ public void combination01() throws FileNotFoundException { @Test @LogMessages(messages = {@LogMessage(messageTemplate = PdfUALogMessageConstants.PAGE_FLUSHING_DISABLED, count = 2)}) - public void combination02() throws FileNotFoundException { + public void combination02() throws IOException { TableBuilder tableBuilder = new TableBuilder(3); for (int i = 0; i < 201; i++) { tableBuilder.addBodyCell(new HeaderCellSupplier("id" + i, "Header1", 1, 1, "None")); @@ -890,7 +888,7 @@ public void combination02() throws FileNotFoundException { @Test @LogMessages(messages = {@LogMessage(messageTemplate = PdfUALogMessageConstants.PAGE_FLUSHING_DISABLED, count = 2)}) - public void combination04() throws FileNotFoundException { + public void combination04() throws IOException { TableBuilder tableBuilder = new TableBuilder(3); for (int i = 0; i < 12; i++) { @@ -914,7 +912,7 @@ public void combination04() throws FileNotFoundException { @Test - public void combination05() throws FileNotFoundException { + public void combination05() throws IOException { TableBuilder tableBuilder = new TableBuilder(3); tableBuilder.addBodyCell(new HeaderCellSupplier("id1", "Header1", 1, 1, "None")); @@ -932,7 +930,7 @@ public void combination05() throws FileNotFoundException { } @Test - public void combination06() throws FileNotFoundException { + public void combination06() throws IOException { TableBuilder tableBuilder = new TableBuilder(3); tableBuilder.addHeaderCell(new HeaderCellSupplier("id1", "Header1", 1, 1, "None")); @@ -950,7 +948,7 @@ public void combination06() throws FileNotFoundException { } @Test - public void combination07() throws FileNotFoundException { + public void combination07() throws IOException { TableBuilder tableBuilder = new TableBuilder(3); tableBuilder.addFooterCell(new HeaderCellSupplier("id1", "Header1", 1, 1, "None")); @@ -968,7 +966,7 @@ public void combination07() throws FileNotFoundException { } @Test - public void combination08() throws FileNotFoundException { + public void combination08() throws IOException { TableBuilder tableBuilder = new TableBuilder(3); tableBuilder.addHeaderCell(new HeaderCellSupplier("id1", "Header1", 1, 1, "None")); @@ -986,7 +984,7 @@ public void combination08() throws FileNotFoundException { } @Test - public void combination09() throws FileNotFoundException { + public void combination09() throws IOException { TableBuilder tableBuilder = new TableBuilder(3); tableBuilder.addBodyCell(new HeaderCellSupplier(null, "Header1", 1, 1, "None")); tableBuilder.addBodyCell(new HeaderCellSupplier("id2", "Header2", 1, 1, "Column")); @@ -1000,7 +998,7 @@ public void combination09() throws FileNotFoundException { } @Test - public void roleMapping01() throws FileNotFoundException { + public void roleMapping01() throws IOException { TableBuilder tableBuilder = new TableBuilder(2); framework.addBeforeGenerationHook((pdfDocument -> { PdfStructTreeRoot root = pdfDocument.getStructTreeRoot(); diff --git a/pdfua/src/test/java/com/itextpdf/pdfua/checkers/PdfUATest.java b/pdfua/src/test/java/com/itextpdf/pdfua/checkers/PdfUATest.java index 3ed4fe75ba..ee2b14f19a 100644 --- a/pdfua/src/test/java/com/itextpdf/pdfua/checkers/PdfUATest.java +++ b/pdfua/src/test/java/com/itextpdf/pdfua/checkers/PdfUATest.java @@ -40,6 +40,7 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfPage; import com.itextpdf.kernel.pdf.PdfReader; import com.itextpdf.kernel.pdf.PdfString; +import com.itextpdf.kernel.pdf.PdfUAConformance; import com.itextpdf.kernel.pdf.PdfVersion; import com.itextpdf.kernel.pdf.PdfViewerPreferences; import com.itextpdf.kernel.pdf.PdfWriter; @@ -52,36 +53,36 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.tagutils.DefaultAccessibilityProperties; import com.itextpdf.kernel.pdf.tagutils.TagTreePointer; import com.itextpdf.kernel.utils.CompareTool; -import com.itextpdf.kernel.utils.ValidationContainer; +import com.itextpdf.kernel.validation.ValidationContainer; import com.itextpdf.layout.Document; import com.itextpdf.layout.element.Image; import com.itextpdf.layout.element.List; import com.itextpdf.layout.element.ListItem; import com.itextpdf.layout.element.Paragraph; +import com.itextpdf.pdfua.PdfUAConfig; +import com.itextpdf.pdfua.PdfUADocument; import com.itextpdf.pdfua.PdfUATestPdfDocument; import com.itextpdf.pdfua.UaValidationTestFramework; import com.itextpdf.pdfua.exceptions.PdfUAConformanceException; import com.itextpdf.pdfua.exceptions.PdfUAExceptionMessageConstants; -import com.itextpdf.pdfua.exceptions.PdfUALogMessageConstants; +import com.itextpdf.pdfua.logs.PdfUALogMessageConstants; import com.itextpdf.test.AssertUtil; import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import com.itextpdf.test.pdfa.VeraPdfValidator; // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) import java.io.ByteArrayOutputStream; import java.io.File; -import java.io.FileNotFoundException; import java.io.IOException; import java.nio.file.Files; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfUATest extends ExtendedITextTest { private static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/pdfua/PdfUATest/"; @@ -93,52 +94,31 @@ public class PdfUATest extends ExtendedITextTest { private UaValidationTestFramework framework; - @BeforeClass + @BeforeAll public static void before() { createOrClearDestinationFolder(DESTINATION_FOLDER); } - @Before + @BeforeEach public void initializeFramework() { framework = new UaValidationTestFramework(DESTINATION_FOLDER); } - @Test - public void flushingOnPageWarningDisabledDoesntLog() throws IOException, InterruptedException { - String outPdf = DESTINATION_FOLDER + "flushingOnPageCloseLogsWarningDisabledTest.pdf"; - String cmpPdf = SOURCE_FOLDER + "cmp_flushingOnPageCloseLogsWarningDisabledTest.pdf"; - PdfUATestPdfDocument pdfDoc = new PdfUATestPdfDocument(new PdfWriter(outPdf)); - pdfDoc.disablePageFlushingWarning(); - Document document = new Document(pdfDoc); - PdfFont font = PdfFontFactory.createFont(FONT, PdfEncodings.WINANSI, EmbeddingStrategy.PREFER_EMBEDDED); - document.setFont(font); - for (int i = 0; i < 40; i++) { - document.add(new Paragraph("Hello World!")); - } - pdfDoc.getPage(1).flush(); - pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); - - } - - @Test public void checkPoint01_007_suspectsHasEntryTrue() { - PdfUATestPdfDocument pdfDoc = new PdfUATestPdfDocument( - new PdfWriter(new ByteArrayOutputStream())); + PdfUATestPdfDocument pdfDoc = new PdfUATestPdfDocument(new PdfWriter(new ByteArrayOutputStream())); PdfDictionary markInfo = (PdfDictionary) pdfDoc.getCatalog().getPdfObject().get(PdfName.MarkInfo); - Assert.assertNotNull(markInfo); + Assertions.assertNotNull(markInfo); markInfo.put(PdfName.Suspects, new PdfBoolean(true)); - Exception e = Assert.assertThrows(PdfUAConformanceException.class, () -> pdfDoc.close()); - Assert.assertEquals(PdfUAExceptionMessageConstants.SUSPECTS_ENTRY_IN_MARK_INFO_DICTIONARY_SHALL_NOT_HAVE_A_VALUE_OF_TRUE, + Exception e = Assertions.assertThrows(PdfUAConformanceException.class, () -> pdfDoc.close()); + Assertions.assertEquals(PdfUAExceptionMessageConstants.SUSPECTS_ENTRY_IN_MARK_INFO_DICTIONARY_SHALL_NOT_HAVE_A_VALUE_OF_TRUE, e.getMessage()); } @Test public void checkPoint01_007_suspectsHasEntryFalse() { - PdfUATestPdfDocument pdfDoc = new PdfUATestPdfDocument( - new PdfWriter(new ByteArrayOutputStream())); + PdfUATestPdfDocument pdfDoc = new PdfUATestPdfDocument(new PdfWriter(new ByteArrayOutputStream())); PdfDictionary markInfo = (PdfDictionary) pdfDoc.getCatalog().getPdfObject().get(PdfName.MarkInfo); markInfo.put(PdfName.Suspects, new PdfBoolean(false)); AssertUtil.doesNotThrow(() -> pdfDoc.close()); @@ -147,8 +127,7 @@ public void checkPoint01_007_suspectsHasEntryFalse() { @Test public void checkPoint01_007_suspectsHasNoEntry() { // suspects entry is optional so it is ok to not have it according to the spec - PdfUATestPdfDocument pdfDoc = new PdfUATestPdfDocument( - new PdfWriter(new ByteArrayOutputStream())); + PdfUATestPdfDocument pdfDoc = new PdfUATestPdfDocument(new PdfWriter(new ByteArrayOutputStream())); AssertUtil.doesNotThrow(() -> pdfDoc.close()); } @@ -156,13 +135,12 @@ public void checkPoint01_007_suspectsHasNoEntry() { @Test public void emptyPageDocument() throws IOException, InterruptedException { String outPdf = DESTINATION_FOLDER + "emptyPageDocument.pdf"; - try (PdfDocument pdfDocument = new PdfUATestPdfDocument( - new PdfWriter(outPdf))) { + try (PdfDocument pdfDocument = new PdfUATestPdfDocument(new PdfWriter(outPdf))) { pdfDocument.addNewPage(); } - Assert.assertNull(new CompareTool().compareByContent(outPdf, SOURCE_FOLDER + "cmp_emptyPageDocument.pdf", + Assertions.assertNull(new CompareTool().compareByContent(outPdf, SOURCE_FOLDER + "cmp_emptyPageDocument.pdf", DESTINATION_FOLDER, "diff_")); - Assert.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) + Assertions.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) } @Test @@ -173,15 +151,14 @@ public void invalidUA1DocumentWithFlushedPageTest() throws IOException, Interrup PdfPage page = pdfDocument.addNewPage(); PdfFileSpec spec = PdfFileSpec.createExternalFileSpec(pdfDocument, "sample.wav"); PdfScreenAnnotation screen = new PdfScreenAnnotation(new Rectangle(100, 100)); - PdfAction action = PdfAction.createRendition("sample.wav", - spec, "audio/x-wav", screen); + PdfAction action = PdfAction.createRendition("sample.wav", spec, "audio/x-wav", screen); screen.setAction(action); screen.setContents("screen annotation"); page.addAnnotation(screen); AssertUtil.doesNotThrow(() -> { page.flush(); }); - Assert.assertThrows(PdfUAConformanceException.class, () -> pdfDocument.close()); + Assertions.assertThrows(PdfUAConformanceException.class, () -> pdfDocument.close()); } @@ -189,7 +166,7 @@ public void invalidUA1DocumentWithFlushedPageTest() throws IOException, Interrup public void documentWithNoLangEntryTest() throws IOException { final String outPdf = DESTINATION_FOLDER + "documentWithNoLangEntryTest.pdf"; PdfDocument pdfDoc = new PdfDocument(new PdfWriter(outPdf, - new WriterProperties().addUAXmpMetadata().setPdfVersion(PdfVersion.PDF_1_7))); + new WriterProperties().addPdfUaXmpMetadata(PdfUAConformance.PDF_UA_1).setPdfVersion(PdfVersion.PDF_1_7))); pdfDoc.setTagged(); ValidationContainer validationContainer = new ValidationContainer(); validationContainer.addChecker(new PdfUA1Checker(pdfDoc)); @@ -199,8 +176,8 @@ public void documentWithNoLangEntryTest() throws IOException { PdfDocumentInfo info = pdfDoc.getDocumentInfo(); info.setTitle("English pangram"); - Exception e = Assert.assertThrows(PdfUAConformanceException.class, () -> pdfDoc.close()); - Assert.assertEquals(PdfUAExceptionMessageConstants.DOCUMENT_SHALL_CONTAIN_VALID_LANG_ENTRY, + Exception e = Assertions.assertThrows(PdfUAConformanceException.class, () -> pdfDoc.close()); + Assertions.assertEquals(PdfUAExceptionMessageConstants.DOCUMENT_SHALL_CONTAIN_VALID_LANG_ENTRY, e.getMessage()); } @@ -208,7 +185,7 @@ public void documentWithNoLangEntryTest() throws IOException { public void documentWithEmptyStringLangEntryTest() throws IOException { final String outPdf = DESTINATION_FOLDER + "documentWithEmptyStringLangEntryTest.pdf"; PdfDocument pdfDoc = new PdfDocument(new PdfWriter(outPdf, - new WriterProperties().addUAXmpMetadata().setPdfVersion(PdfVersion.PDF_1_7))); + new WriterProperties().addPdfUaXmpMetadata(PdfUAConformance.PDF_UA_1).setPdfVersion(PdfVersion.PDF_1_7))); pdfDoc.setTagged(); ValidationContainer validationContainer = new ValidationContainer(); validationContainer.addChecker(new PdfUA1Checker(pdfDoc)); @@ -217,35 +194,26 @@ public void documentWithEmptyStringLangEntryTest() throws IOException { pdfDoc.getCatalog().setViewerPreferences(new PdfViewerPreferences().setDisplayDocTitle(true)); PdfDocumentInfo info = pdfDoc.getDocumentInfo(); info.setTitle("English pangram"); - Exception e = Assert.assertThrows(PdfUAConformanceException.class, () -> pdfDoc.close()); - Assert.assertEquals(PdfUAExceptionMessageConstants.DOCUMENT_SHALL_CONTAIN_VALID_LANG_ENTRY, + Exception e = Assertions.assertThrows(PdfUAConformanceException.class, () -> pdfDoc.close()); + Assertions.assertEquals(PdfUAExceptionMessageConstants.DOCUMENT_SHALL_CONTAIN_VALID_LANG_ENTRY, e.getMessage()); } @Test public void documentWithComplexLangEntryTest() throws IOException, InterruptedException { final String outPdf = DESTINATION_FOLDER + "documentWithComplexLangEntryTest.pdf"; - PdfDocument pdfDoc = new PdfDocument(new PdfWriter(outPdf, - new WriterProperties().addUAXmpMetadata().setPdfVersion(PdfVersion.PDF_1_7))); - pdfDoc.setTagged(); - ValidationContainer validationContainer = new ValidationContainer(); - validationContainer.addChecker(new PdfUA1Checker(pdfDoc)); - pdfDoc.getDiContainer().register(ValidationContainer.class, validationContainer); - pdfDoc.getCatalog().setLang(new PdfString("qaa-Qaaa-QM-x-southern")); - pdfDoc.getCatalog().setViewerPreferences(new PdfViewerPreferences().setDisplayDocTitle(true)); - PdfDocumentInfo info = pdfDoc.getDocumentInfo(); - info.setTitle("English pangram"); + PdfDocument pdfDoc = new PdfUADocument(new PdfWriter(outPdf), new PdfUAConfig(PdfUAConformance.PDF_UA_1, "English pangram", "qaa-Qaaa-QM-x-southern")); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, SOURCE_FOLDER + "cmp_documentWithComplexLangEntryTest.pdf", + Assertions.assertNull(new CompareTool().compareByContent(outPdf, SOURCE_FOLDER + "cmp_documentWithComplexLangEntryTest.pdf", DESTINATION_FOLDER, "diff_")); - Assert.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) + Assertions.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) } @Test public void documentWithoutViewerPreferencesTest() throws IOException { final String outPdf = DESTINATION_FOLDER + "documentWithoutViewerPreferencesTest.pdf"; PdfDocument pdfDoc = new PdfDocument(new PdfWriter(outPdf, - new WriterProperties().addUAXmpMetadata().setPdfVersion(PdfVersion.PDF_1_7))); + new WriterProperties().addPdfUaXmpMetadata(PdfUAConformance.PDF_UA_1).setPdfVersion(PdfVersion.PDF_1_7))); pdfDoc.setTagged(); ValidationContainer validationContainer = new ValidationContainer(); validationContainer.addChecker(new PdfUA1Checker(pdfDoc)); @@ -255,8 +223,8 @@ public void documentWithoutViewerPreferencesTest() throws IOException { PdfDocumentInfo info = pdfDoc.getDocumentInfo(); info.setTitle("English pangram"); - Exception e = Assert.assertThrows(PdfUAConformanceException.class, () -> pdfDoc.close()); - Assert.assertEquals(PdfUAExceptionMessageConstants.MISSING_VIEWER_PREFERENCES, + Exception e = Assertions.assertThrows(PdfUAConformanceException.class, () -> pdfDoc.close()); + Assertions.assertEquals(PdfUAExceptionMessageConstants.MISSING_VIEWER_PREFERENCES, e.getMessage()); } @@ -264,7 +232,7 @@ public void documentWithoutViewerPreferencesTest() throws IOException { public void documentWithEmptyViewerPreferencesTest() throws IOException { final String outPdf = DESTINATION_FOLDER + "documentWithEmptyViewerPreferencesTest.pdf"; PdfDocument pdfDoc = new PdfDocument(new PdfWriter(outPdf, - new WriterProperties().addUAXmpMetadata().setPdfVersion(PdfVersion.PDF_1_7))); + new WriterProperties().addPdfUaXmpMetadata(PdfUAConformance.PDF_UA_1).setPdfVersion(PdfVersion.PDF_1_7))); pdfDoc.setTagged(); ValidationContainer validationContainer = new ValidationContainer(); validationContainer.addChecker(new PdfUA1Checker(pdfDoc)); @@ -275,8 +243,8 @@ public void documentWithEmptyViewerPreferencesTest() throws IOException { PdfDocumentInfo info = pdfDoc.getDocumentInfo(); info.setTitle("English pangram"); - Exception e = Assert.assertThrows(PdfUAConformanceException.class, () -> pdfDoc.close()); - Assert.assertEquals(PdfUAExceptionMessageConstants.MISSING_VIEWER_PREFERENCES, + Exception e = Assertions.assertThrows(PdfUAConformanceException.class, () -> pdfDoc.close()); + Assertions.assertEquals(PdfUAExceptionMessageConstants.MISSING_VIEWER_PREFERENCES, e.getMessage()); } @@ -284,7 +252,7 @@ public void documentWithEmptyViewerPreferencesTest() throws IOException { public void documentWithInvalidViewerPreferencesTest() throws IOException { final String outPdf = DESTINATION_FOLDER + "documentWithEmptyViewerPreferencesTest.pdf"; PdfDocument pdfDoc = new PdfDocument(new PdfWriter(outPdf, - new WriterProperties().addUAXmpMetadata().setPdfVersion(PdfVersion.PDF_1_7))); + new WriterProperties().addPdfUaXmpMetadata(PdfUAConformance.PDF_UA_1).setPdfVersion(PdfVersion.PDF_1_7))); pdfDoc.setTagged(); ValidationContainer validationContainer = new ValidationContainer(); validationContainer.addChecker(new PdfUA1Checker(pdfDoc)); @@ -295,13 +263,13 @@ public void documentWithInvalidViewerPreferencesTest() throws IOException { PdfDocumentInfo info = pdfDoc.getDocumentInfo(); info.setTitle("English pangram"); - Exception e = Assert.assertThrows(PdfUAConformanceException.class, () -> pdfDoc.close()); - Assert.assertEquals(PdfUAExceptionMessageConstants.VIEWER_PREFERENCES_IS_FALSE, + Exception e = Assertions.assertThrows(PdfUAConformanceException.class, () -> pdfDoc.close()); + Assertions.assertEquals(PdfUAExceptionMessageConstants.VIEWER_PREFERENCES_IS_FALSE, e.getMessage()); } @Test - public void checkNameEntryShouldPresentInAllOCGDictionariesTest() throws FileNotFoundException { + public void checkNameEntryShouldPresentInAllOCGDictionariesTest() throws IOException { framework.addBeforeGenerationHook((pdfDocument) -> { pdfDocument.addNewPage(); PdfDictionary ocProperties = new PdfDictionary(); @@ -314,12 +282,11 @@ public void checkNameEntryShouldPresentInAllOCGDictionariesTest() throws FileNot ocProperties.put(PdfName.Configs, configs); pdfDocument.getCatalog().put(PdfName.OCProperties, ocProperties); }); - framework.assertBothFail("pdfuaOCGPropertiesCheck01", - PdfUAExceptionMessageConstants.NAME_ENTRY_IS_MISSING_OR_EMPTY_IN_OCG); + framework.assertBothFail("pdfuaOCGPropertiesCheck01", PdfUAExceptionMessageConstants.NAME_ENTRY_IS_MISSING_OR_EMPTY_IN_OCG); } @Test - public void checkAsKeyInContentConfigDictTest() throws FileNotFoundException { + public void checkAsKeyInContentConfigDictTest() throws IOException { framework.addBeforeGenerationHook((pdfDocument) -> { pdfDocument.addNewPage(); PdfDictionary ocProperties = new PdfDictionary(); @@ -331,12 +298,11 @@ public void checkAsKeyInContentConfigDictTest() throws FileNotFoundException { ocProperties.put(PdfName.Configs, configs); pdfDocument.getCatalog().put(PdfName.OCProperties, ocProperties); }); - framework.assertBothFail("pdfuaOCGPropertiesCheck02", - PdfUAExceptionMessageConstants.OCG_SHALL_NOT_CONTAIN_AS_ENTRY); + framework.assertBothFail("pdfuaOCGPropertiesCheck02", PdfUAExceptionMessageConstants.OCG_SHALL_NOT_CONTAIN_AS_ENTRY); } @Test - public void nameEntryisEmptyTest() throws FileNotFoundException { + public void nameEntryisEmptyTest() throws IOException { framework.addBeforeGenerationHook((pdfDocument) -> { PdfDictionary ocProperties = new PdfDictionary(); PdfDictionary d = new PdfDictionary(); @@ -350,12 +316,11 @@ public void nameEntryisEmptyTest() throws FileNotFoundException { pdfDocument.getCatalog().put(PdfName.OCProperties, ocProperties); }); - framework.assertBothFail("pdfuaOCGPropertiesCheck03", - PdfUAExceptionMessageConstants.NAME_ENTRY_IS_MISSING_OR_EMPTY_IN_OCG); + framework.assertBothFail("pdfuaOCGPropertiesCheck03", PdfUAExceptionMessageConstants.NAME_ENTRY_IS_MISSING_OR_EMPTY_IN_OCG); } @Test - public void configsEntryisNotAnArrayTest() throws FileNotFoundException { + public void configsEntryisNotAnArrayTest() throws IOException { framework.addBeforeGenerationHook((pdfDocument) -> { PdfDictionary ocProperties = new PdfDictionary(); PdfDictionary d = new PdfDictionary(); @@ -366,8 +331,7 @@ public void configsEntryisNotAnArrayTest() throws FileNotFoundException { pdfDocument.getCatalog().put(PdfName.OCProperties, ocProperties); }); - framework.assertBothFail("pdfuaOCGPropertiesCheck04", - PdfUAExceptionMessageConstants.OCG_PROPERTIES_CONFIG_SHALL_BE_AN_ARRAY); + framework.assertBothFail("pdfuaOCGPropertiesCheck04", PdfUAExceptionMessageConstants.OCG_PROPERTIES_CONFIG_SHALL_BE_AN_ARRAY); } @Test @@ -425,25 +389,20 @@ public void documentWithDuplicatingIdInStructTree() throws IOException { PdfCanvas canvas = new PdfCanvas(page1); PdfFont font = PdfFontFactory.createFont(FONT, PdfEncodings.WINANSI, EmbeddingStrategy.PREFER_EMBEDDED); - canvas.beginText() - .setFontAndSize(font, 12) - .setTextMatrix(1, 0, 0, 1, 32, 512); + canvas.beginText().setFontAndSize(font, 12).setTextMatrix(1, 0, 0, 1, 32, 512); - DefaultAccessibilityProperties paraProps - = new DefaultAccessibilityProperties(StandardRoles.P); + DefaultAccessibilityProperties paraProps = new DefaultAccessibilityProperties(StandardRoles.P); tagPointer.addTag(paraProps).addTag(StandardRoles.SPAN); tagPointer.getProperties().setStructureElementIdString("hello-element"); - canvas.openTag(tagPointer.getTagReference()) - .showText("Hello ") - .closeTag(); + canvas.openTag(tagPointer.getTagReference()).showText("Hello ").closeTag(); tagPointer.moveToParent().addTag(StandardRoles.SPAN); tagPointer.getProperties().setStructureElementIdString("world-element"); - Exception e = Assert.assertThrows(PdfUAConformanceException.class, () -> tagPointer.getProperties().setStructureElementIdString("hello-element")); - Assert.assertEquals(MessageFormatUtil.format( - PdfUAExceptionMessageConstants.NON_UNIQUE_ID_ENTRY_IN_STRUCT_TREE_ROOT, "hello-element"), + Exception e = Assertions.assertThrows(PdfUAConformanceException.class, () -> tagPointer.getProperties().setStructureElementIdString("hello-element")); + Assertions.assertEquals(MessageFormatUtil.format( + PdfUAExceptionMessageConstants.NON_UNIQUE_ID_ENTRY_IN_STRUCT_TREE_ROOT, "hello-element"), e.getMessage()); } @@ -458,15 +417,15 @@ public void openDocumentWithDuplicatingIdInStructTree() throws IOException { pdfDocument.getDiContainer().register(ValidationContainer.class, validationContainer); } //Vera pdf doesn't complain on this document - Assert.assertNull(new VeraPdfValidator().validate(dest)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) + Assertions.assertNull(new VeraPdfValidator().validate(dest)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) } @Test public void manualPdfUaCreation() throws IOException, InterruptedException { - final String outPdf = DESTINATION_FOLDER + "manualPdfUaCreation.pdf"; - PdfDocument pdfDoc = new PdfDocument(new PdfWriter(outPdf, - new WriterProperties().addUAXmpMetadata().setPdfVersion(PdfVersion.PDF_1_7))); + final WriterProperties properties = new WriterProperties().addPdfUaXmpMetadata(PdfUAConformance.PDF_UA_1) + .setPdfVersion(PdfVersion.PDF_1_7); + PdfDocument pdfDoc = new PdfDocument(new PdfWriter(outPdf, properties)); Document document = new Document(pdfDoc, PageSize.A4.rotate()); //TAGGED PDF @@ -522,8 +481,8 @@ public void manualPdfUaCreation() throws IOException, InterruptedException { document.close(); - Assert.assertNull(new CompareTool().compareByContent(outPdf, SOURCE_FOLDER + "cmp_manualPdfUaCreation.pdf", + Assertions.assertNull(new CompareTool().compareByContent(outPdf, SOURCE_FOLDER + "cmp_manualPdfUaCreation.pdf", DESTINATION_FOLDER, "diff_")); - Assert.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) + Assertions.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) } } diff --git a/pdfua/src/test/java/com/itextpdf/pdfua/checkers/PdfUAXfaTest.java b/pdfua/src/test/java/com/itextpdf/pdfua/checkers/PdfUAXfaTest.java index cc22b6a1df..687525f427 100644 --- a/pdfua/src/test/java/com/itextpdf/pdfua/checkers/PdfUAXfaTest.java +++ b/pdfua/src/test/java/com/itextpdf/pdfua/checkers/PdfUAXfaTest.java @@ -30,23 +30,22 @@ This file is part of the iText (R) project. import com.itextpdf.pdfua.exceptions.PdfUAExceptionMessageConstants; import com.itextpdf.test.AssertUtil; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import com.itextpdf.test.pdfa.VeraPdfValidator; // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) import com.itextpdf.test.utils.FileUtil; import java.io.IOException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfUAXfaTest extends ExtendedITextTest { private static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/pdfua/PdfUAXfaTest/"; private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/pdfua/PdfUAXfaTest/"; - @BeforeClass + @BeforeAll public static void before() { createOrClearDestinationFolder(DESTINATION_FOLDER); } @@ -60,14 +59,14 @@ public void dynamicRenderRequiredValueTest() throws IOException { new PdfReader(input), new PdfWriter(output)); - Exception e = Assert.assertThrows(PdfUAConformanceException.class, () -> pdfDoc.close()); - Assert.assertEquals(PdfUAExceptionMessageConstants.DYNAMIC_XFA_FORMS_SHALL_NOT_BE_USED, e.getMessage()); + Exception e = Assertions.assertThrows(PdfUAConformanceException.class, () -> pdfDoc.close()); + Assertions.assertEquals(PdfUAExceptionMessageConstants.DYNAMIC_XFA_FORMS_SHALL_NOT_BE_USED, e.getMessage()); FileUtil.copy(input, output); final String result = new VeraPdfValidator().validate(output); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) System.out.println(result); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) // VeraPdf also complains only about the dynamic XFA forms - Assert.assertNotNull(result); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) + Assertions.assertNotNull(result); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) } @Test @@ -82,6 +81,6 @@ public void dynamicRenderForbiddenValueTest() throws IOException { AssertUtil.doesNotThrow(() -> pdfDoc.close()); final String result = new VeraPdfValidator().validate(output); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) - Assert.assertNull(result); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) + Assertions.assertNull(result); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) } } diff --git a/pdfua/src/test/java/com/itextpdf/pdfua/checkers/utils/BCP47ValidatorTest.java b/pdfua/src/test/java/com/itextpdf/pdfua/checkers/utils/BCP47ValidatorTest.java index f7dbb7af84..4a70effae8 100644 --- a/pdfua/src/test/java/com/itextpdf/pdfua/checkers/utils/BCP47ValidatorTest.java +++ b/pdfua/src/test/java/com/itextpdf/pdfua/checkers/utils/BCP47ValidatorTest.java @@ -23,117 +23,116 @@ This file is part of the iText (R) project. package com.itextpdf.pdfua.checkers.utils; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class BCP47ValidatorTest extends ExtendedITextTest { @Test public void simpleLanguageSubtagTest() { - Assert.assertTrue(BCP47Validator.validate("de")); - Assert.assertTrue(BCP47Validator.validate("fr")); + Assertions.assertTrue(BCP47Validator.validate("de")); + Assertions.assertTrue(BCP47Validator.validate("fr")); //example of a grandfathered tag - Assert.assertTrue(BCP47Validator.validate("i-enochian")); + Assertions.assertTrue(BCP47Validator.validate("i-enochian")); } @Test public void languageSubtagAndScriptSubtagTest() { //Chinese written using the Traditional Chinese script - Assert.assertTrue(BCP47Validator.validate("zh-Hant")); + Assertions.assertTrue(BCP47Validator.validate("zh-Hant")); //Chinese written using the Simplified Chinese script - Assert.assertTrue(BCP47Validator.validate("zh-Hans")); + Assertions.assertTrue(BCP47Validator.validate("zh-Hans")); //Serbian written using the Cyrillic script - Assert.assertTrue(BCP47Validator.validate("sr-Cyrl")); + Assertions.assertTrue(BCP47Validator.validate("sr-Cyrl")); //Serbian written using the Latin script - Assert.assertTrue(BCP47Validator.validate("sr-Latn")); + Assertions.assertTrue(BCP47Validator.validate("sr-Latn")); } @Test public void extLangSubtagsAndPrimaryLangSubtagsTest() { //Chinese, Mandarin, Simplified script, as used in China - Assert.assertTrue(BCP47Validator.validate("zh-cmn-Hans-CN")); + Assertions.assertTrue(BCP47Validator.validate("zh-cmn-Hans-CN")); //Mandarin Chinese, Simplified script, as used in China - Assert.assertTrue(BCP47Validator.validate("cmn-Hans-CN")); + Assertions.assertTrue(BCP47Validator.validate("cmn-Hans-CN")); //Chinese, Cantonese, as used in Hong Kong SAR - Assert.assertTrue(BCP47Validator.validate("zh-yue-HK")); - Assert.assertTrue(BCP47Validator.validate("sr-Latn")); + Assertions.assertTrue(BCP47Validator.validate("zh-yue-HK")); + Assertions.assertTrue(BCP47Validator.validate("sr-Latn")); } @Test public void languageScriptRegionsTest() { //Chinese written using the Simplified script as used in mainland China - Assert.assertTrue(BCP47Validator.validate("zh-Hans-CN")); + Assertions.assertTrue(BCP47Validator.validate("zh-Hans-CN")); //Serbian written using the Latin script as used in Serbia - Assert.assertTrue(BCP47Validator.validate("sr-Latn-RS")); + Assertions.assertTrue(BCP47Validator.validate("sr-Latn-RS")); } @Test public void languageVariantTest() { //Resian dialect of Slovenian - Assert.assertTrue(BCP47Validator.validate("sl-rozaj")); + Assertions.assertTrue(BCP47Validator.validate("sl-rozaj")); //San Giorgio dialect of Resian dialect of Slovenian - Assert.assertTrue(BCP47Validator.validate("sl-rozaj-biske")); + Assertions.assertTrue(BCP47Validator.validate("sl-rozaj-biske")); //Nadiza dialect of Slovenian - Assert.assertTrue(BCP47Validator.validate("sl-nedis")); + Assertions.assertTrue(BCP47Validator.validate("sl-nedis")); } @Test public void languageRegionVariantTest() { //German as used in Switzerland using the 1901 variant [orthography] - Assert.assertTrue(BCP47Validator.validate("de-CH-1901")); + Assertions.assertTrue(BCP47Validator.validate("de-CH-1901")); //Slovenian as used in Italy, Nadiza dialect - Assert.assertTrue(BCP47Validator.validate("sl-IT-nedis")); + Assertions.assertTrue(BCP47Validator.validate("sl-IT-nedis")); } @Test public void languageScriptRegionVariantTest() { //Eastern Armenian written in Latin script, as used in Italy - Assert.assertTrue(BCP47Validator.validate("hy-Latn-IT-arevela")); + Assertions.assertTrue(BCP47Validator.validate("hy-Latn-IT-arevela")); } @Test public void languageRegionTest() { //German for Germany - Assert.assertTrue(BCP47Validator.validate("de-DE")); + Assertions.assertTrue(BCP47Validator.validate("de-DE")); //English as used in the United States - Assert.assertTrue(BCP47Validator.validate("en-US")); + Assertions.assertTrue(BCP47Validator.validate("en-US")); //Spanish appropriate for the Latin America and Caribbean region using the UN region code - Assert.assertTrue(BCP47Validator.validate("es-419")); + Assertions.assertTrue(BCP47Validator.validate("es-419")); //Invalid, two region tags - Assert.assertFalse(BCP47Validator.validate("de-419-DE")); + Assertions.assertFalse(BCP47Validator.validate("de-419-DE")); //use of a single-character subtag in primary position; note //that there are a few grandfathered tags that start with "i-" that //are valid - Assert.assertFalse(BCP47Validator.validate("a-DE")); + Assertions.assertFalse(BCP47Validator.validate("a-DE")); } @Test public void privateUseSubtagsTest() { - Assert.assertTrue(BCP47Validator.validate("de-CH-x-phonebk")); - Assert.assertTrue(BCP47Validator.validate("az-Arab-x-AZE-derbend")); + Assertions.assertTrue(BCP47Validator.validate("de-CH-x-phonebk")); + Assertions.assertTrue(BCP47Validator.validate("az-Arab-x-AZE-derbend")); } @Test public void privateUseRegistryValuesTest() { //private use using the singleton 'x' - Assert.assertTrue(BCP47Validator.validate("x-whatever")); + Assertions.assertTrue(BCP47Validator.validate("x-whatever")); //all private tags - Assert.assertTrue(BCP47Validator.validate("qaa-Qaaa-QM-x-southern")); + Assertions.assertTrue(BCP47Validator.validate("qaa-Qaaa-QM-x-southern")); //German, with a private script - Assert.assertTrue(BCP47Validator.validate("de-Qaaa")); + Assertions.assertTrue(BCP47Validator.validate("de-Qaaa")); //Serbian, Latin script, private region - Assert.assertTrue(BCP47Validator.validate("sr-Latn-QM")); + Assertions.assertTrue(BCP47Validator.validate("sr-Latn-QM")); //Serbian, private script, for Serbia - Assert.assertTrue(BCP47Validator.validate("sr-Qaaa-RS")); + Assertions.assertTrue(BCP47Validator.validate("sr-Qaaa-RS")); } @Test public void tagsWithExtensions() { - Assert.assertTrue(BCP47Validator.validate("en-US-u-islamcal")); - Assert.assertTrue(BCP47Validator.validate("zh-CN-a-myext-x-private")); - Assert.assertTrue(BCP47Validator.validate("en-a-myext-b-another")); + Assertions.assertTrue(BCP47Validator.validate("en-US-u-islamcal")); + Assertions.assertTrue(BCP47Validator.validate("zh-CN-a-myext-x-private")); + Assertions.assertTrue(BCP47Validator.validate("en-a-myext-b-another")); } } diff --git a/pdfua/src/test/resources/com/itextpdf/pdfua/PdfUACanvasTest/cmp_01_003_ContentMarkedAsArtifactsPresentInsideTaggedContent.pdf b/pdfua/src/test/resources/com/itextpdf/pdfua/PdfUACanvasXObjectTest/cmp_copyPageAsFormWithCorrectFontXobjectWithUnTaggedPdf.pdf similarity index 85% rename from pdfua/src/test/resources/com/itextpdf/pdfua/PdfUACanvasTest/cmp_01_003_ContentMarkedAsArtifactsPresentInsideTaggedContent.pdf rename to pdfua/src/test/resources/com/itextpdf/pdfua/PdfUACanvasXObjectTest/cmp_copyPageAsFormWithCorrectFontXobjectWithUnTaggedPdf.pdf index be27b91d32..4293d9eb0a 100644 Binary files a/pdfua/src/test/resources/com/itextpdf/pdfua/PdfUACanvasTest/cmp_01_003_ContentMarkedAsArtifactsPresentInsideTaggedContent.pdf and b/pdfua/src/test/resources/com/itextpdf/pdfua/PdfUACanvasXObjectTest/cmp_copyPageAsFormWithCorrectFontXobjectWithUnTaggedPdf.pdf differ diff --git a/pdfua/src/test/resources/com/itextpdf/pdfua/PdfUATest/cmp_invalidDocWithFlushedPageTest.pdf b/pdfua/src/test/resources/com/itextpdf/pdfua/PdfUACanvasXObjectTest/cmp_copyPageAsFormXobjectWithUnTaggedPdf.pdf similarity index 64% rename from pdfua/src/test/resources/com/itextpdf/pdfua/PdfUATest/cmp_invalidDocWithFlushedPageTest.pdf rename to pdfua/src/test/resources/com/itextpdf/pdfua/PdfUACanvasXObjectTest/cmp_copyPageAsFormXobjectWithUnTaggedPdf.pdf index ffa318c266..e96e7e16ef 100644 Binary files a/pdfua/src/test/resources/com/itextpdf/pdfua/PdfUATest/cmp_invalidDocWithFlushedPageTest.pdf and b/pdfua/src/test/resources/com/itextpdf/pdfua/PdfUACanvasXObjectTest/cmp_copyPageAsFormXobjectWithUnTaggedPdf.pdf differ diff --git a/pdfua/src/test/resources/com/itextpdf/pdfua/PdfUACanvasXObjectTest/cmp_manualPdfUaCreation.pdf b/pdfua/src/test/resources/com/itextpdf/pdfua/PdfUACanvasXObjectTest/cmp_manualPdfUaCreation.pdf new file mode 100644 index 0000000000..db16029824 Binary files /dev/null and b/pdfua/src/test/resources/com/itextpdf/pdfua/PdfUACanvasXObjectTest/cmp_manualPdfUaCreation.pdf differ diff --git a/pdfua/src/test/resources/com/itextpdf/pdfua/PdfUACanvasTest/cmp_01_005_TextContentIsNotInTagTree.pdf b/pdfua/src/test/resources/com/itextpdf/pdfua/PdfUACanvasXObjectTest/cmp_manuallyAddToCanvasWithUnAndCorrectFontUnAndArtifactPdf.pdf similarity index 84% rename from pdfua/src/test/resources/com/itextpdf/pdfua/PdfUACanvasTest/cmp_01_005_TextContentIsNotInTagTree.pdf rename to pdfua/src/test/resources/com/itextpdf/pdfua/PdfUACanvasXObjectTest/cmp_manuallyAddToCanvasWithUnAndCorrectFontUnAndArtifactPdf.pdf index f7d58f9479..693feea3cc 100644 Binary files a/pdfua/src/test/resources/com/itextpdf/pdfua/PdfUACanvasTest/cmp_01_005_TextContentIsNotInTagTree.pdf and b/pdfua/src/test/resources/com/itextpdf/pdfua/PdfUACanvasXObjectTest/cmp_manuallyAddToCanvasWithUnAndCorrectFontUnAndArtifactPdf.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/PdfEncryptionTest/encryptedAes128EmbeddedFilesOnly.pdf b/pdfua/src/test/resources/com/itextpdf/pdfua/PdfUACanvasXObjectTest/cmp_manuallyAddToCanvasWithUnTaggedPdf.pdf similarity index 50% rename from kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/PdfEncryptionTest/encryptedAes128EmbeddedFilesOnly.pdf rename to pdfua/src/test/resources/com/itextpdf/pdfua/PdfUACanvasXObjectTest/cmp_manuallyAddToCanvasWithUnTaggedPdf.pdf index df3c74612d..01fc714ebf 100644 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/crypto/pdfencryption/PdfEncryptionTest/encryptedAes128EmbeddedFilesOnly.pdf and b/pdfua/src/test/resources/com/itextpdf/pdfua/PdfUACanvasXObjectTest/cmp_manuallyAddToCanvasWithUnTaggedPdf.pdf differ diff --git a/pdfua/src/test/resources/com/itextpdf/pdfua/PdfUACanvasXObjectTest/cmp_xobjectTesting.pdf b/pdfua/src/test/resources/com/itextpdf/pdfua/PdfUACanvasXObjectTest/cmp_xobjectTesting.pdf new file mode 100644 index 0000000000..d7b244aa07 Binary files /dev/null and b/pdfua/src/test/resources/com/itextpdf/pdfua/PdfUACanvasXObjectTest/cmp_xobjectTesting.pdf differ diff --git a/pdfua/src/test/resources/com/itextpdf/pdfua/PdfUADocumentTest/usualPdf.pdf b/pdfua/src/test/resources/com/itextpdf/pdfua/PdfUADocumentTest/usualPdf.pdf new file mode 100644 index 0000000000..09ec41b5bb Binary files /dev/null and b/pdfua/src/test/resources/com/itextpdf/pdfua/PdfUADocumentTest/usualPdf.pdf differ diff --git a/pdfua/src/test/resources/com/itextpdf/pdfua/PdfUAHeadingsTest/cmp_roleMappingTest.pdf b/pdfua/src/test/resources/com/itextpdf/pdfua/PdfUAHeadingsTest/cmp_roleMappingTest.pdf deleted file mode 100644 index 65756af185..0000000000 Binary files a/pdfua/src/test/resources/com/itextpdf/pdfua/PdfUAHeadingsTest/cmp_roleMappingTest.pdf and /dev/null differ diff --git a/pdfua/src/test/resources/com/itextpdf/pdfua/PdfUAHeadingsTest/invalidSequence.pdf b/pdfua/src/test/resources/com/itextpdf/pdfua/PdfUAHeadingsTest/invalidSequence.pdf deleted file mode 100644 index f2d886340d..0000000000 Binary files a/pdfua/src/test/resources/com/itextpdf/pdfua/PdfUAHeadingsTest/invalidSequence.pdf and /dev/null differ diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/RootSvgNodeRendererTest/svg/cmp_invalidHeight.pdf b/pdfua/src/test/resources/com/itextpdf/pdfua/PdfUAMetadataUnitTest/result.pdf similarity index 100% rename from svg/src/test/resources/com/itextpdf/svg/renderers/impl/RootSvgNodeRendererTest/svg/cmp_invalidHeight.pdf rename to pdfua/src/test/resources/com/itextpdf/pdfua/PdfUAMetadataUnitTest/result.pdf diff --git a/pom.xml b/pom.xml index 7ea62cab28..34b2dd6fe1 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.itextpdf root - 8.0.5 + 9.0.0 pom iText @@ -85,34 +85,27 @@ -Xmx1024m 1.78 - com.itextpdf.test.annotations.type.BouncyCastleIntegrationTest - com.itextpdf.test.annotations.type.BouncyCastleUnitTest 7.0.0 3.0.0-M3 - com.itextpdf.test.annotations.type.IntegrationTest 0.8.4 1.8 https://docs.oracle.com/javase/8/docs/api/ 3.7.0 - 4.13.2 + 5.10.2 1.0.4 - 1.2.13 + 1.3.14 1.8 1.8 3.1.0 3.0.1 - com.itextpdf.test.annotations.type.PerformanceTest UTF-8 UTF-8 - com.itextpdf.test.annotations.type.SampleTest true - 1.7.36 - com.itextpdf.test.annotations.type.SlowTest + 2.0.16 target/dependency-check-report.html target/dependency-check-report.xml 3.0.0-M3 - com.itextpdf.test.annotations.type.UnitTest @@ -128,15 +121,9 @@ test - junit - junit - ${junit.version} - test - - - pl.pragmatists - JUnitParams - ${junitparams.version} + org.junit.jupiter + junit-jupiter + ${junit.jupiter.version} test @@ -496,10 +483,8 @@ true true + com.itextpdf.commons.bouncycastle - com.itextpdf.pdfua.exceptions.PdfUAConformanceException - com.itextpdf.signatures.validation.v1.DocumentRevisionsValidator - com.itextpdf.signatures.validation.v1.SignatureValidator bouncy-castle-adapter @@ -507,6 +492,8 @@ bouncy-castle-fips-adapter + + true @@ -606,7 +593,7 @@ **/*.java - ${slowtests},SlowTest,PerformanceTest,IntegrationTest,BouncyCastleIntegrationTest,SampleTest + SlowTest,PerformanceTest,IntegrationTest,BouncyCastleIntegrationTest,SampleTest ${project.build.directory}/surefire-reports @{jacoco.agent.argLine} 1 @@ -629,7 +616,7 @@ maven-surefire-plugin false - ${unittests},UnitTest,BouncyCastleUnitTest + UnitTest,BouncyCastleUnitTest @{jacoco.agent.argLine} @@ -702,7 +689,7 @@ **/*.java - ${bouncycastleintegrationtests} + BouncyCastleIntegrationTest @@ -730,7 +717,7 @@ org.apache.maven.plugins maven-surefire-plugin - ${bouncycastleunittests} + BouncyCastleUnitTest diff --git a/sharpenConfiguration.xml b/sharpenConfiguration.xml index 3dd9379830..9d9b91e4a2 100644 --- a/sharpenConfiguration.xml +++ b/sharpenConfiguration.xml @@ -70,10 +70,10 @@ - + @@ -147,11 +147,13 @@ - - + + + + @@ -163,6 +165,7 @@ + @@ -186,6 +189,8 @@ + + @@ -221,12 +226,14 @@ + + @@ -252,6 +259,7 @@ + @@ -291,6 +299,7 @@ + @@ -350,10 +359,6 @@ - - - - @@ -464,20 +469,12 @@ - - - - - - - - - + @@ -515,10 +512,10 @@ - - - - + + + + @@ -576,7 +573,8 @@ - + + @@ -659,6 +657,14 @@ + + + + + + + + @@ -689,4 +695,4 @@ - \ No newline at end of file + diff --git a/sign/pom.xml b/sign/pom.xml index a06cf64374..f9d29298a8 100644 --- a/sign/pom.xml +++ b/sign/pom.xml @@ -5,7 +5,7 @@ com.itextpdf root - 8.0.5 + 9.0.0 sign @@ -34,6 +34,11 @@ pdfa ${project.version} + + com.itextpdf + pdfua + ${project.version} + com.itextpdf pdftest diff --git a/sign/src/main/java/com/itextpdf/signatures/BouncyCastleDigest.java b/sign/src/main/java/com/itextpdf/signatures/BouncyCastleDigest.java index 9490fc453b..eeb874dd0a 100644 --- a/sign/src/main/java/com/itextpdf/signatures/BouncyCastleDigest.java +++ b/sign/src/main/java/com/itextpdf/signatures/BouncyCastleDigest.java @@ -23,6 +23,8 @@ This file is part of the iText (R) project. package com.itextpdf.signatures; import com.itextpdf.bouncycastleconnector.BouncyCastleFactoryCreator; +import com.itextpdf.kernel.crypto.DigestAlgorithms; +import com.itextpdf.kernel.crypto.OID; import java.security.GeneralSecurityException; import java.security.MessageDigest; @@ -42,38 +44,38 @@ public MessageDigest getMessageDigest(String hashAlgorithm) throws GeneralSecuri if (oid == null) { throw new NoSuchAlgorithmException(hashAlgorithm); } - + Provider provider = BouncyCastleFactoryCreator.getFactory().getProvider(); switch (oid) { // SHA1 case "1.3.14.3.2.26": return MessageDigest.getInstance("SHA1", provider); // SHA224 - case "2.16.840.1.101.3.4.2.4": + case OID.SHA_224: return MessageDigest.getInstance("SHA224", provider); // SHA256 - case "2.16.840.1.101.3.4.2.1": + case OID.SHA_256: return MessageDigest.getInstance("SHA256", provider); // SHA384 - case "2.16.840.1.101.3.4.2.2": + case OID.SHA_384: return MessageDigest.getInstance("SHA384", provider); // SHA512 - case "2.16.840.1.101.3.4.2.3": + case OID.SHA_512: return MessageDigest.getInstance("SHA512", provider); // SHA3-224 - case "2.16.840.1.101.3.4.2.7": + case OID.SHA3_224: return MessageDigest.getInstance("SHA3-224", provider); // SHA3-256 - case "2.16.840.1.101.3.4.2.8": + case OID.SHA3_256: return MessageDigest.getInstance("SHA3-256", provider); // SHA3-384 - case "2.16.840.1.101.3.4.2.9": + case OID.SHA3_384: return MessageDigest.getInstance("SHA3-384", provider); // SHA3-512 - case "2.16.840.1.101.3.4.2.10": + case OID.SHA3_512: return MessageDigest.getInstance("SHA3-512", provider); // SHAKE-256 (512-bit) - case "2.16.840.1.101.3.4.2.12": + case OID.SHAKE_256: return MessageDigest.getInstance("SHAKE256", provider); // RIPEMD128 case "1.3.36.3.2.2": diff --git a/sign/src/main/java/com/itextpdf/signatures/CRLVerifier.java b/sign/src/main/java/com/itextpdf/signatures/CRLVerifier.java index b61ee0b1f2..8f95d2573e 100644 --- a/sign/src/main/java/com/itextpdf/signatures/CRLVerifier.java +++ b/sign/src/main/java/com/itextpdf/signatures/CRLVerifier.java @@ -39,7 +39,7 @@ This file is part of the iText (R) project. * one or more Certificate Revocation Lists. * * @deprecated starting from 8.0.5. - * {@link com.itextpdf.signatures.validation.v1.CRLValidator} should be used instead. + * {@link com.itextpdf.signatures.validation.CRLValidator} should be used instead. */ @Deprecated public class CRLVerifier extends RootStoreVerifier { @@ -141,12 +141,12 @@ public boolean verify(X509CRL crl, X509Certificate signCert, X509Certificate iss public X509CRL getCRL(X509Certificate signCert, X509Certificate issuerCert) { try { // gets the URL from the certificate - String crlurl = CertificateUtil.getCRLURL(signCert); - if (crlurl == null) { + List crlurl = CertificateUtil.getCRLURLs(signCert); + if (crlurl.isEmpty()) { return null; } - LOGGER.info("Getting CRL from " + crlurl); - return (X509CRL) SignUtils.parseCrlFromStream(new URL(crlurl).openStream()); + LOGGER.info("Getting CRL from " + crlurl.get(0)); + return (X509CRL) SignUtils.parseCrlFromStream(new URL(crlurl.get(0)).openStream()); } catch (IOException | GeneralSecurityException e) { return null; } diff --git a/sign/src/main/java/com/itextpdf/signatures/CertificateInfo.java b/sign/src/main/java/com/itextpdf/signatures/CertificateInfo.java index f7e5e7ad65..a02db8d752 100644 --- a/sign/src/main/java/com/itextpdf/signatures/CertificateInfo.java +++ b/sign/src/main/java/com/itextpdf/signatures/CertificateInfo.java @@ -174,7 +174,7 @@ public static class X500Name { /** * A Map with values. */ - public Map> values = new HashMap<>(); + private final Map> values = new HashMap<>(); /** * Constructs an X509 name. diff --git a/sign/src/main/java/com/itextpdf/signatures/CertificateUtil.java b/sign/src/main/java/com/itextpdf/signatures/CertificateUtil.java index 16548a64d3..15e24445f6 100644 --- a/sign/src/main/java/com/itextpdf/signatures/CertificateUtil.java +++ b/sign/src/main/java/com/itextpdf/signatures/CertificateUtil.java @@ -46,9 +46,8 @@ This file is part of the iText (R) project. import com.itextpdf.commons.bouncycastle.cert.ocsp.IBasicOCSPResp; import com.itextpdf.commons.bouncycastle.cert.ocsp.ICertificateID; import com.itextpdf.commons.bouncycastle.operator.AbstractOperatorCreationException; +import com.itextpdf.kernel.crypto.OID; import com.itextpdf.signatures.logs.SignLogMessageConstant; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.io.ByteArrayInputStream; import java.io.IOException; @@ -60,13 +59,15 @@ This file is part of the iText (R) project. import java.security.cert.Certificate; import java.security.cert.CertificateEncodingException; import java.security.cert.CertificateException; -import java.security.cert.X509Certificate; import java.security.cert.X509CRL; +import java.security.cert.X509Certificate; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Enumeration; import java.util.List; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * This class contains a series of static methods that @@ -79,24 +80,6 @@ public class CertificateUtil { // Certificate Revocation Lists - /** - * Gets a CRL from an X509 certificate. - * - * @param certificate the X509Certificate to extract the CRL from - * - * @return CRL or null if there's no CRL available - * - * @throws IOException thrown when the URL couldn't be opened properly. - * @throws CertificateException thrown if there's no X509 implementation in the provider. - * @throws CRLException thrown when encountering errors when parsing the CRL. - * - * @deprecated use {@link #getCRLs(X509Certificate)}. - */ - @Deprecated - public static CRL getCRL(X509Certificate certificate) throws CertificateException, CRLException, IOException { - return CertificateUtil.getCRL(CertificateUtil.getCRLURL(certificate)); - } - /** * Gets a CRLs from the X509 certificate. * @@ -117,21 +100,6 @@ public static List getCRLs(X509Certificate certificate) return crls; } - /** - * Gets the URL of the Certificate Revocation List for a Certificate - * - * @param certificate the Certificate - * - * @return the String where you can check if the certificate was revoked. - * - * @deprecated use {@link #getCRLURLs(X509Certificate)}. - */ - @Deprecated - public static String getCRLURL(X509Certificate certificate) { - List urls = getCRLURLs(certificate); - return urls.isEmpty() ? null : urls.get(0); - } - /** * Gets the list of the Certificate Revocation List URLs for a Certificate. * @@ -248,7 +216,7 @@ public static String getIssuerCertURL(CRL crl) { IASN1Primitive obj; try { obj = getExtensionValue(crl, FACTORY.createExtension().getAuthorityInfoAccess().getId()); - return getValueFromAIAExtension(obj, SecurityIDs.ID_CA_ISSUERS); + return getValueFromAIAExtension(obj, OID.CA_ISSUERS); } catch (IOException e) { return null; } @@ -267,7 +235,7 @@ public static String getOCSPURL(X509Certificate certificate) { IASN1Primitive obj; try { obj = getExtensionValue(certificate, FACTORY.createExtension().getAuthorityInfoAccess().getId()); - return getValueFromAIAExtension(obj, SecurityIDs.ID_OCSP); + return getValueFromAIAExtension(obj, OID.OCSP); } catch (IOException e) { return null; } @@ -286,7 +254,7 @@ public static String getIssuerCertURL(X509Certificate certificate) { IASN1Primitive obj; try { obj = getExtensionValue(certificate, FACTORY.createExtension().getAuthorityInfoAccess().getId()); - return getValueFromAIAExtension(obj, SecurityIDs.ID_CA_ISSUERS); + return getValueFromAIAExtension(obj, OID.CA_ISSUERS); } catch (IOException e) { return null; } @@ -302,7 +270,7 @@ public static String getIssuerCertURL(X509Certificate certificate) { * @return a TSA URL */ public static String getTSAURL(X509Certificate certificate) { - byte[] der = SignUtils.getExtensionValueByOid(certificate, SecurityIDs.ID_TSA); + byte[] der = SignUtils.getExtensionValueByOid(certificate, OID.TSA); if (der == null) { return null; } @@ -353,7 +321,7 @@ public static void retrieveRevocationInfoFromSignedData(IASN1TaggedObject tagged while (revInfo.hasMoreElements()) { IASN1Sequence s = FACTORY.createASN1Sequence(revInfo.nextElement()); IASN1ObjectIdentifier o = FACTORY.createASN1ObjectIdentifier(s.getObjectAt(0)); - if (o != null && SecurityIDs.ID_RI_OCSP_RESPONSE.equals(o.getId())) { + if (o != null && OID.RI_OCSP_RESPONSE.equals(o.getId())) { IASN1Sequence ocspResp = FACTORY.createASN1Sequence(s.getObjectAt(1)); IASN1Enumerated respStatus = FACTORY.createASN1Enumerated(ocspResp.getObjectAt(0)); if (respStatus.intValueExact() == FACTORY.createOCSPRespBuilderInstance().getSuccessful()) { @@ -406,7 +374,7 @@ public static void retrieveRevocationInfoFromSignedData(IASN1TaggedObject tagged public static IDERSet createRevocationInfoChoices(Collection crls, Collection ocsps, Collection otherRevocationInfoFormats) throws CRLException, IOException { - if (crls.size() == 0 && ocsps.size() == 0) { + if (crls.isEmpty() && ocsps.isEmpty()) { return null; } IASN1EncodableVector revocationInfoChoices = FACTORY.createASN1EncodableVector(); @@ -421,7 +389,7 @@ public static IDERSet createRevocationInfoChoices(Collection crls, Collecti for (IBasicOCSPResponse element : ocsps) { IASN1EncodableVector ocspResponseRevInfo = FACTORY.createASN1EncodableVector(); // Add otherRevInfoFormat (ID_RI_OCSP_RESPONSE) - ocspResponseRevInfo.add(FACTORY.createASN1ObjectIdentifier(SecurityIDs.ID_RI_OCSP_RESPONSE)); + ocspResponseRevInfo.add(FACTORY.createASN1ObjectIdentifier(OID.RI_OCSP_RESPONSE)); IASN1EncodableVector ocspResponse = FACTORY.createASN1EncodableVector(); ocspResponse.add(FACTORY.createOCSPResponseStatus( diff --git a/sign/src/main/java/com/itextpdf/signatures/CertificateVerification.java b/sign/src/main/java/com/itextpdf/signatures/CertificateVerification.java index 0c6603b17f..8382b2fe0f 100644 --- a/sign/src/main/java/com/itextpdf/signatures/CertificateVerification.java +++ b/sign/src/main/java/com/itextpdf/signatures/CertificateVerification.java @@ -25,31 +25,34 @@ This file is part of the iText (R) project. import com.itextpdf.commons.bouncycastle.cert.ocsp.IBasicOCSPResp; import com.itextpdf.commons.bouncycastle.tsp.ITimeStampToken; import com.itextpdf.commons.utils.DateTimeUtil; +import com.itextpdf.kernel.crypto.OID; import com.itextpdf.signatures.exceptions.SignExceptionMessageConstant; import com.itextpdf.signatures.logs.SignLogMessageConstant; -import java.security.cert.CertificateEncodingException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.security.KeyStore; import java.security.cert.CRL; import java.security.cert.Certificate; +import java.security.cert.CertificateEncodingException; import java.security.cert.X509Certificate; import java.util.ArrayList; import java.util.Calendar; import java.util.Collection; import java.util.List; - +import java.util.Set; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * This class consists of some methods that allow you to verify certificates. + * + * @deprecated starting from 9.0.0. + * {@link com.itextpdf.signatures.validation.CertificateChainValidator} should be used instead. */ +@Deprecated public class CertificateVerification { public static final String HAS_UNSUPPORTED_EXTENSIONS = "Has unsupported critical extension"; public static final String CERTIFICATE_REVOKED = "Certificate revoked"; - /** * The Logger instance. */ @@ -77,7 +80,7 @@ public static String verifyCertificate(X509Certificate cert, Collection crl * if no error */ public static String verifyCertificate(X509Certificate cert, Collection crls, Calendar calendar) { - if (SignUtils.hasUnsupportedCriticalExtension(cert)) { + if (hasUnsupportedCriticalExtension(cert)) { return CertificateVerification.HAS_UNSUPPORTED_EXTENSIONS; } try { @@ -263,6 +266,31 @@ public static boolean verifyTimestampCertificates(ITimeStampToken ts, KeyStore k return false; } + /** + * Check if the provided certificate has a critical extension that iText doesn't support. + * + * @param cert X509Certificate instance to check + * + * @return {@code true} if there are unsupported critical extensions, false if there are none + */ + protected static boolean hasUnsupportedCriticalExtension(X509Certificate cert) { + if (cert == null) { + throw new IllegalArgumentException("X509Certificate can't be null."); + } + + Set criticalExtensionsSet = cert.getCriticalExtensionOIDs(); + if (criticalExtensionsSet != null) { + for (String oid : criticalExtensionsSet) { + if (OID.X509Extensions.SUPPORTED_CRITICAL_EXTENSIONS.contains(oid)) { + continue; + } + return true; + } + } + + return false; + } + private static void logExceptionMessages(List exceptionsThrown) { for (Exception ex : exceptionsThrown) { LOGGER.error(ex.getMessage() == null diff --git a/sign/src/main/java/com/itextpdf/signatures/CertificateVerifier.java b/sign/src/main/java/com/itextpdf/signatures/CertificateVerifier.java index 98ec4bb4f4..a7dfdaf36b 100644 --- a/sign/src/main/java/com/itextpdf/signatures/CertificateVerifier.java +++ b/sign/src/main/java/com/itextpdf/signatures/CertificateVerifier.java @@ -36,7 +36,7 @@ This file is part of the iText (R) project. * method will be called. * * @deprecated starting from 8.0.5. - * {@link com.itextpdf.signatures.validation.v1.CertificateChainValidator} should be used instead. + * {@link com.itextpdf.signatures.validation.CertificateChainValidator} should be used instead. */ @Deprecated public class CertificateVerifier { diff --git a/sign/src/main/java/com/itextpdf/signatures/DefaultIssuingCertificateRetriever.java b/sign/src/main/java/com/itextpdf/signatures/DefaultIssuingCertificateRetriever.java index 0240d05a07..d393a594c2 100644 --- a/sign/src/main/java/com/itextpdf/signatures/DefaultIssuingCertificateRetriever.java +++ b/sign/src/main/java/com/itextpdf/signatures/DefaultIssuingCertificateRetriever.java @@ -60,6 +60,11 @@ public Certificate[] getCrlIssuerCertificates(CRL crl) { return new Certificate[0]; } + @Override + public Certificate[][] getCrlIssuerCertificatesByName(CRL crl) { + return new Certificate[0][]; + } + /** * {@inheritDoc} * diff --git a/sign/src/main/java/com/itextpdf/signatures/IIssuingCertificateRetriever.java b/sign/src/main/java/com/itextpdf/signatures/IIssuingCertificateRetriever.java index 9733356be1..9fd088e878 100644 --- a/sign/src/main/java/com/itextpdf/signatures/IIssuingCertificateRetriever.java +++ b/sign/src/main/java/com/itextpdf/signatures/IIssuingCertificateRetriever.java @@ -42,8 +42,8 @@ public interface IIssuingCertificateRetriever { Certificate[] retrieveMissingCertificates(Certificate[] chain); /** - * Retrieves certificates that can be used to verify the signature on the CRL response using CRL - * Authority Information Access (AIA) Extension. + * Retrieves the certificate chain for the certificate that should be used to verify the signature on the + * CRL response using CRL Authority Information Access (AIA) Extension and known certificates. * * @param crl CRL response to retrieve issuer for. * @@ -51,6 +51,16 @@ public interface IIssuingCertificateRetriever { */ Certificate[] getCrlIssuerCertificates(CRL crl); + /** + * Retrieves the certificate chaind for the certificates that could be used to verify the signature on the + * CRL response using CRL Authority Information Access (AIA) Extension and known certificates. + * + * @param crl CRL response to retrieve issuer for. + * + * @return certificates retrieved from CRL AIA extension or an empty list in case certificates cannot be retrieved. + */ + Certificate[][] getCrlIssuerCertificatesByName(CRL crl); + /** * Sets trusted certificate list to be used for the missing certificates retrieving by the issuer name. * diff --git a/sign/src/main/java/com/itextpdf/signatures/IssuingCertificateRetriever.java b/sign/src/main/java/com/itextpdf/signatures/IssuingCertificateRetriever.java index ce3f23f458..41e2f885d9 100644 --- a/sign/src/main/java/com/itextpdf/signatures/IssuingCertificateRetriever.java +++ b/sign/src/main/java/com/itextpdf/signatures/IssuingCertificateRetriever.java @@ -22,10 +22,15 @@ This file is part of the iText (R) project. */ package com.itextpdf.signatures; +import com.itextpdf.bouncycastleconnector.BouncyCastleFactoryCreator; +import com.itextpdf.commons.bouncycastle.IBouncyCastleFactory; import com.itextpdf.commons.bouncycastle.cert.ocsp.IBasicOCSPResp; import com.itextpdf.signatures.logs.SignLogMessageConstant; -import com.itextpdf.signatures.validation.v1.TrustedCertificatesStore; +import com.itextpdf.signatures.validation.TrustedCertificatesStore; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -48,10 +53,11 @@ This file is part of the iText (R) project. */ public class IssuingCertificateRetriever implements IIssuingCertificateRetriever { + private static final IBouncyCastleFactory FACTORY = BouncyCastleFactoryCreator.getFactory(); private static final Logger LOGGER = LoggerFactory.getLogger(IssuingCertificateRetriever.class); private final TrustedCertificatesStore trustedCertificatesStore = new TrustedCertificatesStore(); - private final Map knownCertificates = new HashMap<>(); + private final Map> knownCertificates = new HashMap<>(); /** * Creates {@link IssuingCertificateRetriever} instance. @@ -87,10 +93,11 @@ public Certificate[] retrieveMissingCertificates(Certificate[] chain) { Collection certificatesFromAIA = processCertificatesFromAIA(url); if (certificatesFromAIA == null || certificatesFromAIA.isEmpty()) { // Retrieve Issuer from the certificate store - Certificate issuer = trustedCertificatesStore - .getKnownCertificate(lastAddedCert.getIssuerX500Principal().getName()); - if (issuer == null) { - issuer = knownCertificates.get(lastAddedCert.getIssuerX500Principal().getName()); + Certificate issuer = getIssuerFromCertificateSet(lastAddedCert, trustedCertificatesStore + .getKnownCertificates(lastAddedCert.getIssuerX500Principal().getName())); + if (issuer == null || !isSignedBy(lastAddedCert, issuer)) { + issuer = getIssuerFromCertificateSet(lastAddedCert, knownCertificates.get( + lastAddedCert.getIssuerX500Principal().getName())); if (issuer == null) { // Unable to retrieve missing certificates while (i < chain.length) { @@ -111,6 +118,92 @@ public Certificate[] retrieveMissingCertificates(Certificate[] chain) { return fullChain.toArray(new Certificate[0]); } + /** + * This method tries to rebuild certificate issuer chain. The result contains all possible chains + * starting with the given certificate based on issuer names and public keys. + * + * @param certificate {@link X509Certificate} for which issuer chains shall be built + * + * @return all possible issuer chains + */ + public List buildCertificateChains(X509Certificate certificate) { + return buildCertificateChains(new X509Certificate[] {certificate}); + } + + /** + * This method tries to rebuild certificate issuer chain. The result contains all possible chains + * starting with the given certificate array based on issuer names and public keys. + * + * @param certificate {@link X509Certificate} array for which issuer chains shall be built + * + * @return all possible issuer chains + */ + public List buildCertificateChains(X509Certificate[] certificate) { + List> allCertificateChains = buildCertificateChainsList(certificate); + List result = new ArrayList<>(allCertificateChains.size() * 5); + for (List chain : allCertificateChains) { + Collections.reverse(chain); + result.add(chain.toArray(new X509Certificate[0])); + } + return result; + } + + private List> buildCertificateChainsList(X509Certificate[] certificates) { + List> allChains = + new ArrayList<>(buildCertificateChainsList(certificates[certificates.length - 1])); + for (List issuerChain : allChains) { + for (int i = certificates.length - 2; i >= 0; --i) { + issuerChain.add(certificates[i]); + } + } + return allChains; + } + + private List> buildCertificateChainsList(X509Certificate certificate) { + if (CertificateUtil.isSelfSigned(certificate)) { + List> singleChain = new ArrayList<>(); + List chain = new ArrayList<>(); + chain.add(certificate); + singleChain.add(chain); + return singleChain; + } + + List> allChains = new ArrayList<>(); + // Get missing certificates using AIA Extensions + String url = CertificateUtil.getIssuerCertURL(certificate); + Collection certificatesFromAIA = processCertificatesFromAIA(url); + if (certificatesFromAIA != null && !certificatesFromAIA.isEmpty()) { + List> issuerChains = buildCertificateChainsList(certificatesFromAIA + .toArray(new X509Certificate[0])); + for (List issuerChain : issuerChains) { + issuerChain.add(certificate); + allChains.add(issuerChain); + } + } else { + Set possibleIssuers = trustedCertificatesStore + .getKnownCertificates(certificate.getIssuerX500Principal().getName()); + if (knownCertificates.get( + certificate.getIssuerX500Principal().getName()) != null) { + possibleIssuers.addAll(knownCertificates.get(certificate.getIssuerX500Principal().getName())); + } + if (possibleIssuers.isEmpty()) { + List> singleChain = new ArrayList<>(); + List chain = new ArrayList<>(); + chain.add(certificate); + singleChain.add(chain); + return singleChain; + } + for (Certificate possibleIssuer : possibleIssuers) { + List> issuerChains = buildCertificateChainsList((X509Certificate) possibleIssuer); + for (List issuerChain : issuerChains) { + issuerChain.add(certificate); + allChains.add(issuerChain); + } + } + } + return allChains; + } + /** * Retrieve issuer certificate for the provided certificate. * @@ -118,53 +211,46 @@ public Certificate[] retrieveMissingCertificates(Certificate[] chain) { * * @return issuer certificate. {@code null} if there is no issuer certificate, or it cannot be retrieved. */ - public Certificate retrieveIssuerCertificate(Certificate certificate) { - Certificate[] certificateChain = retrieveMissingCertificates(new Certificate[]{certificate}); - if (certificateChain.length > 1) { - return certificateChain[1]; + public List retrieveIssuerCertificate(Certificate certificate) { + List result = new ArrayList<>(); + for (X509Certificate[] certificateChain : buildCertificateChains((X509Certificate) certificate)) { + if (certificateChain.length > 1) { + result.add(certificateChain[1]); + } } - return null; + return result; } /** - * Retrieves OCSP responder certificate either from the response certs or + * Retrieves OCSP responder certificate candidates either from the response certs or * trusted store in case responder certificate isn't found in /Certs. * * @param ocspResp basic OCSP response to get responder certificate for * - * @return retrieved OCSP responder certificate or null in case it wasn't found. + * @return retrieved OCSP responder candidates or an empty set in case none were found. */ - public Certificate retrieveOCSPResponderCertificate(IBasicOCSPResp ocspResp) { + public Set retrieveOCSPResponderByNameCertificate(IBasicOCSPResp ocspResp) { + + String name = null; + name = FACTORY.createX500Name( FACTORY.createASN1Sequence( + ocspResp.getResponderId().toASN1Primitive().getName().toASN1Primitive())).getName(); + // Look for the existence of an Authorized OCSP responder inside the cert chain in the ocsp response. Iterable certs = SignUtils.getCertsFromOcspResponse(ocspResp); for (X509Certificate cert : certs) { try { - if (CertificateUtil.isSignatureValid(ocspResp, cert)) { - return cert; + if (name.equals(cert.getSubjectX500Principal().getName())) { + return Collections.singleton(cert); } } catch (Exception ignored) { // Ignore. } } - // Certificate chain is not present in the response. - // Try to verify using trusted store according to RFC 6960 2.2. Response: - // "The key used to sign the response MUST belong to one of the following: - // - ... - // - a Trusted Responder whose public key is trusted by the requester; - // - ..." - try { - for (Certificate anchor : trustedCertificatesStore.getAllTrustedCertificates()) { - if (CertificateUtil.isSignatureValid(ocspResp, anchor)) { - // Certificate from the root store is considered trusted and valid by this method. - return anchor; - } - } - } catch (Exception ignored) { - // Ignore. - } - return null; + // Certificate chain is not present in the response, or is does not contain the responder. + return trustedCertificatesStore.getKnownCertificates(name); } + /** * {@inheritDoc} * @@ -174,6 +260,27 @@ public Certificate retrieveOCSPResponderCertificate(IBasicOCSPResp ocspResp) { */ @Override public Certificate[] getCrlIssuerCertificates(CRL crl) { + Certificate[][] result = getCrlIssuerCertificatesGeneric(crl, true); + if (result.length == 0) { + return new Certificate[0]; + } + return result[0]; + } + + /** + * {@inheritDoc} + * + * @param crl {@inheritDoc} + * + * @return {@inheritDoc} + */ + + @Override + public Certificate[][] getCrlIssuerCertificatesByName(CRL crl) { + return getCrlIssuerCertificatesGeneric(crl, false); + } + + private Certificate[][] getCrlIssuerCertificatesGeneric(CRL crl, boolean verify) { // Usually CRLs are signed using CA certificate, so we don’t need to do anything extra and the revocation data // is already collected. However, it is possible to sign it with any other certificate. @@ -181,22 +288,33 @@ public Certificate[] getCrlIssuerCertificates(CRL crl) { // Nothing special for the indirect CRLs. // AIA Extension + ArrayList matches = new ArrayList(); String url = CertificateUtil.getIssuerCertURL(crl); List certificatesFromAIA = (List) processCertificatesFromAIA(url); if (certificatesFromAIA == null) { // Retrieve Issuer from the certificate store - Certificate issuer = trustedCertificatesStore - .getKnownCertificate(((X509CRL) crl).getIssuerX500Principal().getName()); - if (issuer == null) { - issuer = knownCertificates.get(((X509CRL) crl).getIssuerX500Principal().getName()); - if (issuer == null) { - // Unable to retrieve CRL issuer - return new Certificate[0]; + Set issuers = trustedCertificatesStore + .getKnownCertificates(((X509CRL) crl).getIssuerX500Principal().getName()); + if (issuers == null) { + issuers = new HashSet<>(); + } + List localIssuers = getCrlIssuersFromKnownCertificates((X509CRL) crl); + if (localIssuers != null) { + issuers.addAll(localIssuers); + } + if (issuers.isEmpty()) { + // Unable to retrieve CRL issuer + return new Certificate[0][]; + } + for (Certificate i: issuers) { + if (!verify || isSignedBy((X509CRL) crl, i)) { + matches.addAll(buildCertificateChains((X509Certificate) i)); } } - return retrieveMissingCertificates(new Certificate[]{issuer}); + return matches.toArray(new Certificate[][]{}); } - return retrieveMissingCertificates(certificatesFromAIA.toArray(new Certificate[0])); + return buildCertificateChains(certificatesFromAIA.toArray(new X509Certificate[0])) + .toArray(new Certificate[][]{}); } /** @@ -227,7 +345,9 @@ public void addTrustedCertificates(Collection certificates) { */ public void addKnownCertificates(Collection certificates) { for (Certificate certificate : certificates) { - knownCertificates.put(((X509Certificate) certificate).getSubjectX500Principal().getName(), certificate); + String name = ((X509Certificate) certificate).getSubjectX500Principal().getName(); + List certs = knownCertificates.computeIfAbsent(name,k -> new ArrayList<>()); + certs.add(certificate); } } @@ -290,4 +410,38 @@ private Collection processCertificatesFromAIA(String url) { return null; } } + + private static boolean isSignedBy(X509Certificate certificate, Certificate issuer) { + try { + certificate.verify(issuer.getPublicKey()); + return true; + } catch (Exception e) { + return false; + } + } + + private static boolean isSignedBy(X509CRL crl, Certificate issuer) { + try { + crl.verify(issuer.getPublicKey()); + return true; + } catch (Exception e) { + return false; + } + } + + private static Certificate getIssuerFromCertificateSet(X509Certificate lastAddedCert, + Collection certs) { + if (certs != null) { + for (Certificate cert : certs) { + if (isSignedBy(lastAddedCert, cert)) { + return cert; + } + } + } + return null; + } + + private List getCrlIssuersFromKnownCertificates(X509CRL crl) { + return knownCertificates.get(crl.getIssuerX500Principal().getName()); + } } diff --git a/sign/src/main/java/com/itextpdf/signatures/LtvVerification.java b/sign/src/main/java/com/itextpdf/signatures/LtvVerification.java index 917d1effe0..29739f7ae8 100644 --- a/sign/src/main/java/com/itextpdf/signatures/LtvVerification.java +++ b/sign/src/main/java/com/itextpdf/signatures/LtvVerification.java @@ -34,6 +34,7 @@ This file is part of the iText (R) project. import com.itextpdf.commons.utils.MessageFormatUtil; import com.itextpdf.io.font.PdfEncodings; import com.itextpdf.io.source.ByteBuffer; +import com.itextpdf.kernel.crypto.OID.X509Extensions; import com.itextpdf.kernel.exceptions.PdfException; import com.itextpdf.kernel.pdf.CompressionConstants; import com.itextpdf.kernel.pdf.PdfArray; @@ -47,7 +48,6 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfStream; import com.itextpdf.kernel.pdf.PdfString; import com.itextpdf.kernel.pdf.PdfVersion; -import com.itextpdf.signatures.OID.X509Extensions; import com.itextpdf.signatures.exceptions.SignExceptionMessageConstant; import com.itextpdf.signatures.logs.SignLogMessageConstant; @@ -56,21 +56,20 @@ This file is part of the iText (R) project. import java.security.GeneralSecurityException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; +import java.security.cert.CRLException; import java.security.cert.Certificate; import java.security.cert.CertificateException; -import java.security.cert.CRLException; import java.security.cert.X509Certificate; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; -import java.util.LinkedHashMap; import java.util.HashMap; import java.util.HashSet; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Set; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -254,11 +253,13 @@ public boolean addVerification(String signatureName, IOcspClient ocsp, ICrlClien } if (certInclude == CertificateInclusion.YES) { for (X509Certificate processedCert : processedCerts) { - validationData.certs.add(processedCert.getEncoded()); + List certs = validationData.getCerts(); + certs.add(processedCert.getEncoded()); + validationData.setCerts(certs); } } - if (validationData.crls.size() == 0 && validationData.ocsps.size() == 0) { + if (validationData.getCrls().isEmpty() && validationData.getOcsps().isEmpty()) { return false; } validated.put(getSignatureHashKey(signatureName), validationData); @@ -287,14 +288,20 @@ public boolean addVerification(String signatureName, Collection ocsps, C ValidationData vd = new ValidationData(); if (ocsps != null) { for (byte[] ocsp : ocsps) { - vd.ocsps.add(LtvVerification.buildOCSPResponse(ocsp)); + List ocspsArr = vd.getOcsps(); + ocspsArr.add(LtvVerification.buildOCSPResponse(ocsp)); + vd.setOcsps(ocspsArr); } } if (crls != null) { - vd.crls.addAll(crls); + List crlsArr = vd.getCrls(); + crlsArr.addAll(crls); + vd.setCrls(crlsArr); } if (certs != null) { - vd.certs.addAll(certs); + List certsArr = vd.getCerts(); + certsArr.addAll(certs); + vd.setCerts(certsArr); } validated.put(getSignatureHashKey(signatureName), vd); return true; @@ -304,7 +311,7 @@ public boolean addVerification(String signatureName, Collection ocsps, C * Merges the validation with any validation already in the document or creates a new one. */ public void merge() { - if (used || validated.size() == 0) { + if (used || validated.isEmpty()) { return; } used = true; @@ -392,7 +399,9 @@ private void addRevocationDataForCertificate(X509Certificate signingCert, Certif ocspEnc = ocsp.getEncoded(cert, getParent(cert, certificateChain), null); if (ocspEnc != null && BOUNCY_CASTLE_FACTORY.createCertificateStatus().getGood().equals( OcspClientBouncyCastle.getCertificateStatus(ocspEnc))) { - validationData.ocsps.add(LtvVerification.buildOCSPResponse(ocspEnc)); + List ocsps = validationData.getOcsps(); + ocsps.add(LtvVerification.buildOCSPResponse(ocspEnc)); + validationData.setOcsps(ocsps); revocationDataAdded = true; LOGGER.info("OCSP added"); if (certOption == CertificateOption.ALL_CERTIFICATES) { @@ -409,16 +418,18 @@ private void addRevocationDataForCertificate(X509Certificate signingCert, Certif Collection cims = crl.getEncoded(cert, null); if (cims != null) { for (byte[] cim : cims) { + revocationDataAdded = true; boolean dup = false; - for (byte[] b : validationData.crls) { + for (byte[] b : validationData.getCrls()) { if (Arrays.equals(b, cim)) { dup = true; break; } } if (!dup) { - validationData.crls.add(cim); - revocationDataAdded = true; + List crls = validationData.getCrls(); + crls.add(cim); + validationData.setCrls(crls); LOGGER.info("CRL added"); if (certOption == CertificateOption.ALL_CERTIFICATES) { Certificate[] certsList = issuingCertificateRetriever.getCrlIssuerCertificates( @@ -568,7 +579,7 @@ private void outputDss(PdfDictionary dss, PdfDictionary vrim, PdfArray ocsps, Pd PdfArray crl = new PdfArray(); PdfArray cert = new PdfArray(); PdfDictionary vri = new PdfDictionary(); - for (byte[] b : validated.get(vkey).crls) { + for (byte[] b : validated.get(vkey).getCrls()) { PdfStream ps = new PdfStream(b); ps.setCompressionLevel(CompressionConstants.DEFAULT_COMPRESSION); ps.makeIndirect(document); @@ -576,14 +587,14 @@ private void outputDss(PdfDictionary dss, PdfDictionary vrim, PdfArray ocsps, Pd crls.add(ps); crls.setModified(); } - for (byte[] b : validated.get(vkey).ocsps) { + for (byte[] b : validated.get(vkey).getOcsps()) { PdfStream ps = new PdfStream(b); ps.setCompressionLevel(CompressionConstants.DEFAULT_COMPRESSION); ocsp.add(ps); ocsps.add(ps); ocsps.setModified(); } - for (byte[] b : validated.get(vkey).certs) { + for (byte[] b : validated.get(vkey).getCerts()) { PdfStream ps = new PdfStream(b); ps.setCompressionLevel(CompressionConstants.DEFAULT_COMPRESSION); ps.makeIndirect(document); @@ -591,15 +602,15 @@ private void outputDss(PdfDictionary dss, PdfDictionary vrim, PdfArray ocsps, Pd certs.add(ps); certs.setModified(); } - if (ocsp.size() > 0) { + if (!ocsp.isEmpty()) { ocsp.makeIndirect(document); vri.put(PdfName.OCSP, ocsp); } - if (crl.size() > 0) { + if (!crl.isEmpty()) { crl.makeIndirect(document); vri.put(PdfName.CRL, crl); } - if (cert.size() > 0) { + if (!cert.isEmpty()) { cert.makeIndirect(document); vri.put(PdfName.Cert, cert); } @@ -609,15 +620,15 @@ private void outputDss(PdfDictionary dss, PdfDictionary vrim, PdfArray ocsps, Pd vrim.makeIndirect(document); vrim.setModified(); dss.put(PdfName.VRI, vrim); - if (ocsps.size() > 0) { + if (!ocsps.isEmpty()) { ocsps.makeIndirect(document); dss.put(PdfName.OCSPs, ocsps); } - if (crls.size() > 0) { + if (!crls.isEmpty()) { crls.makeIndirect(document); dss.put(PdfName.CRLs, crls); } - if (certs.size() > 0) { + if (!certs.isEmpty()) { certs.makeIndirect(document); dss.put(PdfName.Certs, certs); } @@ -628,9 +639,63 @@ private void outputDss(PdfDictionary dss, PdfDictionary vrim, PdfArray ocsps, Pd } private static class ValidationData { - public List crls = new ArrayList<>(); - public List ocsps = new ArrayList<>(); - public List certs = new ArrayList<>(); + private List crls = new ArrayList<>(); + private List ocsps = new ArrayList<>(); + private List certs = new ArrayList<>(); + + /** + * Sets the crls byte array. + * + * @param crls crls + */ + public void setCrls(List crls) { + this.crls = crls; + } + + /** + * Retrieves Crls byte array. + * + * @return crls + */ + public List getCrls() { + return crls; + } + + /** + * Sets the ocsps array. + * + * @param ocsps ocsps + */ + public void setOcsps(List ocsps) { + this.ocsps = ocsps; + } + + /** + * Retrieves ocsps byte array. + * + * @return ocsps + */ + public List getOcsps() { + return ocsps; + } + + /** + * Sets the certs byte array. + * + * @param certs certs + */ + public void setCerts(List certs) { + this.certs = certs; + } + + /** + * Retrieves cert byte array. + * + * @return cert + */ + public List getCerts() { + return certs; + } } private Certificate[] retrieveMissingCertificates(Certificate[] certChain) { @@ -645,4 +710,5 @@ private Certificate[] retrieveMissingCertificates(Certificate[] certChain) { return restoredChain.values().toArray(new Certificate[0]); } + } diff --git a/sign/src/main/java/com/itextpdf/signatures/LtvVerifier.java b/sign/src/main/java/com/itextpdf/signatures/LtvVerifier.java index 560f08edd9..1e5e8ba418 100644 --- a/sign/src/main/java/com/itextpdf/signatures/LtvVerifier.java +++ b/sign/src/main/java/com/itextpdf/signatures/LtvVerifier.java @@ -58,7 +58,7 @@ This file is part of the iText (R) project. * Verifies the signatures in an LTV document. * * @deprecated starting from 8.0.5. - * {@link com.itextpdf.signatures.validation.v1.SignatureValidator} should be used instead. + * {@link com.itextpdf.signatures.validation.SignatureValidator} should be used instead. */ @Deprecated public class LtvVerifier extends RootStoreVerifier { diff --git a/sign/src/main/java/com/itextpdf/signatures/OCSPVerifier.java b/sign/src/main/java/com/itextpdf/signatures/OCSPVerifier.java index ab559c6230..6e98281395 100644 --- a/sign/src/main/java/com/itextpdf/signatures/OCSPVerifier.java +++ b/sign/src/main/java/com/itextpdf/signatures/OCSPVerifier.java @@ -53,7 +53,7 @@ This file is part of the iText (R) project. * one or more OCSP responses. * * @deprecated starting from 8.0.5. - * {@link com.itextpdf.signatures.validation.v1.OCSPValidator} should be used instead. + * {@link com.itextpdf.signatures.validation.OCSPValidator} should be used instead. */ @Deprecated public class OCSPVerifier extends RootStoreVerifier { diff --git a/sign/src/main/java/com/itextpdf/signatures/OcspClientBouncyCastle.java b/sign/src/main/java/com/itextpdf/signatures/OcspClientBouncyCastle.java index 89da1b2602..3ed56dc4a4 100644 --- a/sign/src/main/java/com/itextpdf/signatures/OcspClientBouncyCastle.java +++ b/sign/src/main/java/com/itextpdf/signatures/OcspClientBouncyCastle.java @@ -32,10 +32,9 @@ This file is part of the iText (R) project. import com.itextpdf.commons.bouncycastle.cert.ocsp.IOCSPReq; import com.itextpdf.commons.bouncycastle.cert.ocsp.ISingleResp; import com.itextpdf.commons.bouncycastle.operator.AbstractOperatorCreationException; -import com.itextpdf.commons.utils.DateTimeUtil; import com.itextpdf.io.logs.IoLogMessageConstant; import com.itextpdf.io.util.StreamUtil; -import com.itextpdf.signatures.validation.v1.OCSPValidator; +import com.itextpdf.signatures.validation.OCSPValidator; import java.io.IOException; import java.io.InputStream; @@ -60,30 +59,18 @@ public class OcspClientBouncyCastle implements IOcspClient { */ private static final Logger LOGGER = LoggerFactory.getLogger(OcspClientBouncyCastle.class); - private final OCSPVerifier verifier; - - /** - * Creates {@code OcspClient}. - * - * @param verifier will be used for response verification. - * - * @deprecated starting from 8.0.5. {@link OcspClientBouncyCastle#OcspClientBouncyCastle()} should be used instead. - * If required, {@link IBasicOCSPResp} can be checked using {@link OCSPValidator} class. - */ - @Deprecated - public OcspClientBouncyCastle(OCSPVerifier verifier) { - this.verifier = verifier; - } - /** * Creates new {@link OcspClientBouncyCastle} instance. */ public OcspClientBouncyCastle() { - this.verifier = null; + // Empty constructor in order for default one to not be removed if another one is added. } /** - * Gets OCSP response. If {@link OCSPVerifier} was set, the response will be checked. + * Gets OCSP response. + * + *

    + * If required, {@link IBasicOCSPResp} can be checked using {@link OCSPValidator} class. * * @param checkCert the certificate to check * @param rootCert parent certificate @@ -100,11 +87,7 @@ public IBasicOCSPResp getBasicOCSPResp(X509Certificate checkCert, X509Certificat if (ocspResponse.getStatus() != BOUNCY_CASTLE_FACTORY.createOCSPResponseStatus().getSuccessful()) { return null; } - IBasicOCSPResp basicResponse = BOUNCY_CASTLE_FACTORY.createBasicOCSPResp(ocspResponse.getResponseObject()); - if (verifier != null) { - verifier.isValidResponse(basicResponse, rootCert, DateTimeUtil.getCurrentTimeDate()); - } - return basicResponse; + return BOUNCY_CASTLE_FACTORY.createBasicOCSPResp(ocspResponse.getResponseObject()); } catch (Exception ex) { LOGGER.error(ex.getMessage()); } @@ -155,9 +138,6 @@ public byte[] getEncoded(X509Certificate checkCert, X509Certificate rootCert, St */ protected static IOCSPReq generateOCSPRequest(X509Certificate issuerCert, BigInteger serialNumber) throws AbstractOCSPException, IOException, CertificateEncodingException, AbstractOperatorCreationException { - //Add provider BC - Security.addProvider(BOUNCY_CASTLE_FACTORY.getProvider()); - // Generate the id for the certificate we are looking for ICertificateID id = SignUtils.generateCertificateId(issuerCert, serialNumber, BOUNCY_CASTLE_FACTORY.createCertificateID().getHashSha1()); diff --git a/sign/src/main/java/com/itextpdf/signatures/PKCS7ExternalSignatureContainer.java b/sign/src/main/java/com/itextpdf/signatures/PKCS7ExternalSignatureContainer.java index 3859bb777b..b13dc68565 100644 --- a/sign/src/main/java/com/itextpdf/signatures/PKCS7ExternalSignatureContainer.java +++ b/sign/src/main/java/com/itextpdf/signatures/PKCS7ExternalSignatureContainer.java @@ -23,6 +23,7 @@ This file is part of the iText (R) project. package com.itextpdf.signatures; import com.itextpdf.bouncycastleconnector.BouncyCastleFactoryCreator; +import com.itextpdf.kernel.crypto.DigestAlgorithms; import com.itextpdf.kernel.exceptions.PdfException; import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.kernel.pdf.PdfName; diff --git a/sign/src/main/java/com/itextpdf/signatures/PadesTwoPhaseSigningHelper.java b/sign/src/main/java/com/itextpdf/signatures/PadesTwoPhaseSigningHelper.java index 07e6c66a23..ad2b6a34ed 100644 --- a/sign/src/main/java/com/itextpdf/signatures/PadesTwoPhaseSigningHelper.java +++ b/sign/src/main/java/com/itextpdf/signatures/PadesTwoPhaseSigningHelper.java @@ -27,6 +27,8 @@ This file is part of the iText (R) project. import com.itextpdf.commons.bouncycastle.asn1.IASN1InputStream; import com.itextpdf.commons.bouncycastle.asn1.IASN1Sequence; import com.itextpdf.commons.utils.MessageFormatUtil; +import com.itextpdf.kernel.crypto.DigestAlgorithms; +import com.itextpdf.kernel.crypto.OID; import com.itextpdf.kernel.exceptions.PdfException; import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfName; @@ -313,7 +315,7 @@ public void signCMSContainerWithBaselineTProfile(IExternalSignature externalSign try (IASN1InputStream tempStream = FACTORY.createASN1InputStream(new ByteArrayInputStream(timestamp))) { IASN1Sequence seq = FACTORY.createASN1Sequence(tempStream.readObject()); CmsAttribute timestampAttribute = new CmsAttribute( - SecurityIDs.ID_AA_TIME_STAMP_TOKEN, FACTORY.createDERSet(seq)); + OID.AA_TIME_STAMP_TOKEN, FACTORY.createDERSet(seq)); cmsContainer.getSignerInfo().addUnSignedAttribute(timestampAttribute); } diff --git a/sign/src/main/java/com/itextpdf/signatures/PdfPKCS7.java b/sign/src/main/java/com/itextpdf/signatures/PdfPKCS7.java index fbe933d752..bd500daabf 100644 --- a/sign/src/main/java/com/itextpdf/signatures/PdfPKCS7.java +++ b/sign/src/main/java/com/itextpdf/signatures/PdfPKCS7.java @@ -56,6 +56,8 @@ This file is part of the iText (R) project. import com.itextpdf.commons.bouncycastle.cert.ocsp.ICertificateID; import com.itextpdf.commons.bouncycastle.cert.ocsp.ISingleResp; import com.itextpdf.commons.utils.MessageFormatUtil; +import com.itextpdf.kernel.crypto.DigestAlgorithms; +import com.itextpdf.kernel.crypto.OID; import com.itextpdf.kernel.exceptions.PdfException; import com.itextpdf.kernel.pdf.PdfName; import com.itextpdf.signatures.exceptions.SignExceptionMessageConstant; @@ -133,6 +135,8 @@ public class PdfPKCS7 { */ private final Collection signedDataRevocationInfo = new ArrayList<>(); + private final IASN1EncodableVector unsignedAttributes = BOUNCY_CASTLE_FACTORY.createASN1EncodableVector(); + // Constructors for creating new signatures /** @@ -275,7 +279,7 @@ public PdfPKCS7(byte[] contentsKey, PdfName filterSubtype, String provider) { SignExceptionMessageConstant.NOT_A_VALID_PKCS7_OBJECT_NOT_A_SEQUENCE); } IASN1ObjectIdentifier objId = BOUNCY_CASTLE_FACTORY.createASN1ObjectIdentifier(signedData.getObjectAt(0)); - if (!objId.getId().equals(SecurityIDs.ID_PKCS7_SIGNED_DATA)) { + if (!objId.getId().equals(OID.PKCS7_SIGNED_DATA)) { throw new IllegalArgumentException( SignExceptionMessageConstant.NOT_A_VALID_PKCS7_OBJECT_NOT_SIGNED_DATA); } @@ -367,10 +371,10 @@ public PdfPKCS7(byte[] contentsKey, PdfName filterSubtype, String provider) { for (int k = 0; k < sseq.size(); ++k) { IASN1Sequence seq2 = BOUNCY_CASTLE_FACTORY.createASN1Sequence(sseq.getObjectAt(k)); String idSeq2 = BOUNCY_CASTLE_FACTORY.createASN1ObjectIdentifier(seq2.getObjectAt(0)).getId(); - if (idSeq2.equals(SecurityIDs.ID_MESSAGE_DIGEST)) { + if (idSeq2.equals(OID.MESSAGE_DIGEST)) { IASN1Set set = BOUNCY_CASTLE_FACTORY.createASN1Set(seq2.getObjectAt(1)); digestAttr = BOUNCY_CASTLE_FACTORY.createASN1OctetString(set.getObjectAt(0)).getOctets(); - } else if (idSeq2.equals(SecurityIDs.ID_ADBE_REVOCATION)) { + } else if (idSeq2.equals(OID.ADBE_REVOCATION)) { IASN1Set setout = BOUNCY_CASTLE_FACTORY.createASN1Set(seq2.getObjectAt(1)); IASN1Sequence seqout = BOUNCY_CASTLE_FACTORY.createASN1Sequence(setout.getObjectAt(0)); for (int j = 0; j < seqout.size(); ++j) { @@ -384,7 +388,7 @@ public PdfPKCS7(byte[] contentsKey, PdfName filterSubtype, String provider) { findOcsp(seqin); } } - } else if (isCades && idSeq2.equals(SecurityIDs.ID_AA_SIGNING_CERTIFICATE_V1)) { + } else if (isCades && idSeq2.equals(OID.AA_SIGNING_CERTIFICATE_V1)) { IASN1Set setout = BOUNCY_CASTLE_FACTORY.createASN1Set(seq2.getObjectAt(1)); IASN1Sequence seqout = BOUNCY_CASTLE_FACTORY.createASN1Sequence(setout.getObjectAt(0)); ISigningCertificate sv2 = BOUNCY_CASTLE_FACTORY.createSigningCertificate(seqout); @@ -399,7 +403,7 @@ public PdfPKCS7(byte[] contentsKey, PdfName filterSubtype, String provider) { "Signing certificate doesn't match the ESS information."); } foundCades = true; - } else if (isCades && idSeq2.equals(SecurityIDs.ID_AA_SIGNING_CERTIFICATE_V2)) { + } else if (isCades && idSeq2.equals(OID.AA_SIGNING_CERTIFICATE_V2)) { IASN1Set setout = BOUNCY_CASTLE_FACTORY.createASN1Set(seq2.getObjectAt(1)); IASN1Sequence seqout = BOUNCY_CASTLE_FACTORY.createASN1Sequence(setout.getObjectAt(0)); ISigningCertificateV2 sv2 = BOUNCY_CASTLE_FACTORY.createSigningCertificateV2(seqout); @@ -481,6 +485,15 @@ public PdfPKCS7(byte[] contentsKey, PdfName filterSubtype, String provider) { } } + /** + * Get unsigned attributes associated with this PKCS7 signature container. + * + * @return unsigned attributes as {@link IASN1EncodableVector} + */ + public IASN1EncodableVector getUnsignedAttributes() { + return unsignedAttributes; + } + /** * Set signature policy identifier to be used during signature creation. * @@ -657,13 +670,13 @@ public String getDigestAlgorithmName() { // Ed25519 and Ed448 do not allow a choice of hashing algorithm, // and ISO 32002 requires using a fixed hashing algorithm to // digest the document content - if (SecurityIDs.ID_ED25519.equals(this.signatureMechanismOid) - && !SecurityIDs.ID_SHA512.equals(digestAlgorithmOid)) { + if (OID.ED25519.equals(this.signatureMechanismOid) + && !OID.SHA_512.equals(digestAlgorithmOid)) { // We compare based on OID to ensure that there are no name normalisation issues. throw new PdfException(SignExceptionMessageConstant.ALGO_REQUIRES_SPECIFIC_HASH) .setMessageParams("Ed25519", "SHA-512", hashAlgoName); - } else if (SecurityIDs.ID_ED448.equals(this.signatureMechanismOid) - && !SecurityIDs.ID_SHAKE256.equals(digestAlgorithmOid)) { + } else if (OID.ED448.equals(this.signatureMechanismOid) + && !OID.SHAKE_256.equals(digestAlgorithmOid)) { throw new PdfException(SignExceptionMessageConstant.ALGO_REQUIRES_SPECIFIC_HASH) .setMessageParams("Ed448", "512-bit SHAKE256", hashAlgoName); } @@ -689,12 +702,12 @@ public String getSignatureMechanismOid() { */ public String getSignatureMechanismName() { switch (this.signatureMechanismOid) { - case SecurityIDs.ID_ED25519: + case OID.ED25519: // Ed25519 and Ed448 do not involve a choice of hashing algorithm return "Ed25519"; - case SecurityIDs.ID_ED448: + case OID.ED448: return "Ed448"; - case SecurityIDs.ID_RSASSA_PSS: + case OID.RSASSA_PSS: // For RSASSA-PSS, the algorithm parameters dictate everything, so // there's no need to duplicate that information in the algorithm name. return "RSASSA-PSS"; @@ -821,10 +834,10 @@ private Signature initSignature(PublicKey key) throws NoSuchAlgorithmException, } private void configureSignatureMechanismParameters(Signature signature) { - if (SecurityIDs.ID_RSASSA_PSS.equals(this.signatureMechanismOid)) { + if (OID.RSASSA_PSS.equals(this.signatureMechanismOid)) { IRSASSAPSSParams params = BOUNCY_CASTLE_FACTORY.createRSASSAPSSParams(this.signatureMechanismParameters); String mgfOid = params.getMaskGenAlgorithm().getAlgorithm().getId(); - if (!SecurityIDs.ID_MGF1.equals(mgfOid)) { + if (!OID.MGF1.equals(mgfOid)) { throw new IllegalArgumentException(SignExceptionMessageConstant.ONLY_MGF1_SUPPORTED_IN_RSASSA_PSS); } // Even though having separate digests at all "layers" is mathematically fine, @@ -979,7 +992,7 @@ public byte[] getEncodedPKCS7(byte[] secondDigest, PdfSigner.CryptoStandard sigt // Create the contentInfo. IASN1EncodableVector v = BOUNCY_CASTLE_FACTORY.createASN1EncodableVector(); - v.add(BOUNCY_CASTLE_FACTORY.createASN1ObjectIdentifier(SecurityIDs.ID_PKCS7_DATA)); + v.add(BOUNCY_CASTLE_FACTORY.createASN1ObjectIdentifier(OID.PKCS7_DATA)); if (encapMessageContent != null) { v.add(BOUNCY_CASTLE_FACTORY.createDERTaggedObject(0, BOUNCY_CASTLE_FACTORY.createDEROctetString(encapMessageContent))); @@ -1043,13 +1056,11 @@ public byte[] getEncodedPKCS7(byte[] secondDigest, PdfSigner.CryptoStandard sigt if (tsaClient != null) { byte[] tsImprint = tsaClient.getMessageDigest().digest(signatureValue); byte[] tsToken = tsaClient.getTimeStampToken(tsImprint); - if (tsToken != null) { - IASN1EncodableVector unauthAttributes = buildUnauthenticatedAttributes(tsToken); - if (unauthAttributes != null) { - signerInfo.add(BOUNCY_CASTLE_FACTORY.createDERTaggedObject( - false, 1, BOUNCY_CASTLE_FACTORY.createDERSet(unauthAttributes))); - } - } + addTimestampTokenToUnsignedAttributes(tsToken); + } + if (unsignedAttributes.size() > 0) { + signerInfo.add(BOUNCY_CASTLE_FACTORY.createDERTaggedObject( + false, 1, BOUNCY_CASTLE_FACTORY.createDERSet(unsignedAttributes))); } // Finally build the body out of all the components above @@ -1069,7 +1080,7 @@ public byte[] getEncodedPKCS7(byte[] secondDigest, PdfSigner.CryptoStandard sigt // and return it // IASN1EncodableVector whole = BOUNCY_CASTLE_FACTORY.createASN1EncodableVector(); - whole.add(BOUNCY_CASTLE_FACTORY.createASN1ObjectIdentifier(SecurityIDs.ID_PKCS7_SIGNED_DATA)); + whole.add(BOUNCY_CASTLE_FACTORY.createASN1ObjectIdentifier(OID.PKCS7_SIGNED_DATA)); whole.add(BOUNCY_CASTLE_FACTORY.createDERTaggedObject(0, BOUNCY_CASTLE_FACTORY.createDERSequence(body))); ByteArrayOutputStream bOut = new ByteArrayOutputStream(); @@ -1092,27 +1103,22 @@ public byte[] getEncodedPKCS7(byte[] secondDigest, PdfSigner.CryptoStandard sigt * * @param timeStampToken byte[] - time stamp token, DER encoded signedData * - * @return {@link IASN1EncodableVector} - * * @throws IOException if an I/O error occurs. */ - private IASN1EncodableVector buildUnauthenticatedAttributes(byte[] timeStampToken) throws IOException { + private void addTimestampTokenToUnsignedAttributes(byte[] timeStampToken) throws IOException { if (timeStampToken == null) { - return null; + return; } - IASN1EncodableVector unauthAttributes = BOUNCY_CASTLE_FACTORY.createASN1EncodableVector(); - IASN1EncodableVector v = BOUNCY_CASTLE_FACTORY.createASN1EncodableVector(); - v.add(BOUNCY_CASTLE_FACTORY.createASN1ObjectIdentifier(SecurityIDs.ID_AA_TIME_STAMP_TOKEN)); + v.add(BOUNCY_CASTLE_FACTORY.createASN1ObjectIdentifier(OID.AA_TIME_STAMP_TOKEN)); try (IASN1InputStream tempstream = BOUNCY_CASTLE_FACTORY.createASN1InputStream(new ByteArrayInputStream(timeStampToken))) { IASN1Sequence seq = BOUNCY_CASTLE_FACTORY.createASN1Sequence(tempstream.readObject()); v.add(BOUNCY_CASTLE_FACTORY.createDERSet(seq)); } - unauthAttributes.add(BOUNCY_CASTLE_FACTORY.createDERSequence(v)); - return unauthAttributes; + unsignedAttributes.add(BOUNCY_CASTLE_FACTORY.createDERSequence(v)); } // Authenticated attributes @@ -1181,12 +1187,12 @@ private IDERSet getAuthenticatedAttributeSet(byte[] secondDigest, Collection certs; - + private Collection timestampCerts; /** @@ -1420,7 +1426,7 @@ public Certificate[] getCertificates() { /** * Get all X.509 certificates associated with this PKCS#7 object timestamp in no particular order. - * + * * @return {@link Certificate[]} array */ public Certificate[] getTimestampCertificates() { diff --git a/sign/src/main/java/com/itextpdf/signatures/PdfPadesSigner.java b/sign/src/main/java/com/itextpdf/signatures/PdfPadesSigner.java index 042820bfd8..0a6e3507bb 100644 --- a/sign/src/main/java/com/itextpdf/signatures/PdfPadesSigner.java +++ b/sign/src/main/java/com/itextpdf/signatures/PdfPadesSigner.java @@ -26,7 +26,7 @@ This file is part of the iText (R) project. import com.itextpdf.commons.bouncycastle.IBouncyCastleFactory; import com.itextpdf.commons.utils.FileUtil; import com.itextpdf.commons.utils.MessageFormatUtil; -import com.itextpdf.forms.PdfSigFieldLock; +import com.itextpdf.kernel.crypto.DigestAlgorithms; import com.itextpdf.kernel.exceptions.PdfException; import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfReader; @@ -40,7 +40,6 @@ This file is part of the iText (R) project. import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; -import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -69,8 +68,6 @@ public class PdfPadesSigner { private int estimatedSize = 0; private String timestampSignatureName; private String temporaryDirectoryPath = null; - private AccessPermissions accessPermissions = AccessPermissions.UNSPECIFIED; - private PdfSigFieldLock fieldLock = null; private IExternalDigest externalDigest = new BouncyCastleDigest(); private StampingProperties stampingProperties = new StampingProperties().useAppendMode(); private StampingProperties stampingPropertiesWithMetaInfo = (StampingProperties) new StampingProperties() @@ -303,30 +300,6 @@ public PdfPadesSigner setTemporaryDirectoryPath(String temporaryDirectoryPath) { return this; } - /** - * Set certification level which specifies DocMDP level which is expected to be set. - * - * @param accessPermissions {@link AccessPermissions} certification level - * - * @return same instance of {@link PdfPadesSigner} - */ - public PdfPadesSigner setCertificationLevel(AccessPermissions accessPermissions) { - this.accessPermissions = accessPermissions; - return this; - } - - /** - * Set FieldMDP rules to be applied for this signature. - * - * @param fieldLock {@link PdfSigFieldLock} field lock dictionary. - * - * @return same instance of {@link PdfPadesSigner} - */ - public PdfPadesSigner setSignatureFieldLock(PdfSigFieldLock fieldLock) { - this.fieldLock = fieldLock; - return this; - } - /** * Set the name to be used for timestamp signature creation. *

    @@ -487,7 +460,7 @@ void deleteTempFiles() { } } - OutputStream createOutputStream() throws FileNotFoundException { + OutputStream createOutputStream() throws IOException { if (temporaryDirectoryPath != null) { return FileUtil.getFileOutputStream(getNextTempFile()); } @@ -523,8 +496,6 @@ private void performSignDetached(SignerProperties signerProperties, boolean isFi throws GeneralSecurityException, IOException { Certificate[] fullChain = issuingCertificateRetriever.retrieveMissingCertificates(chain); PdfSigner signer = createPdfSigner(signerProperties, isFinal); - signer.setCertificationLevel(accessPermissions); - signer.setFieldLockDict(fieldLock); try { signer.signDetached(externalDigest, externalSignature, fullChain, null, null, tsaClient, estimatedSize, CryptoStandard.CADES); diff --git a/sign/src/main/java/com/itextpdf/signatures/PdfSignatureAppearance.java b/sign/src/main/java/com/itextpdf/signatures/PdfSignatureAppearance.java deleted file mode 100644 index 11fb248ce1..0000000000 --- a/sign/src/main/java/com/itextpdf/signatures/PdfSignatureAppearance.java +++ /dev/null @@ -1,1045 +0,0 @@ -/* - This file is part of the iText (R) project. - Copyright (c) 1998-2024 Apryse Group NV - Authors: Apryse Software. - - This program is offered under a commercial and under the AGPL license. - For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. - - AGPL licensing: - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . - */ -package com.itextpdf.signatures; - -import com.itextpdf.forms.fields.PdfFormCreator; -import com.itextpdf.forms.fields.PdfSignatureFormField; -import com.itextpdf.forms.fields.SignatureFormFieldBuilder; -import com.itextpdf.forms.fields.properties.SignedAppearanceText; -import com.itextpdf.forms.form.element.SignatureFieldAppearance; -import com.itextpdf.io.exceptions.IOException; -import com.itextpdf.io.image.ImageData; -import com.itextpdf.kernel.colors.Color; -import com.itextpdf.kernel.font.PdfFont; -import com.itextpdf.kernel.geom.Rectangle; -import com.itextpdf.kernel.pdf.PdfDocument; -import com.itextpdf.kernel.pdf.PdfName; -import com.itextpdf.kernel.pdf.xobject.PdfFormXObject; -import com.itextpdf.kernel.pdf.xobject.PdfImageXObject; -import com.itextpdf.layout.font.FontProvider; -import com.itextpdf.layout.properties.BackgroundImage; -import com.itextpdf.layout.properties.BackgroundPosition; -import com.itextpdf.layout.properties.BackgroundRepeat; -import com.itextpdf.layout.properties.BackgroundSize; -import com.itextpdf.layout.properties.Property; -import com.itextpdf.layout.properties.UnitValue; - -import java.security.cert.Certificate; -import java.security.cert.X509Certificate; -import java.util.Calendar; - -/** - * Provides convenient methods to make a signature appearance. Use it in conjunction with {@link PdfSigner}. - */ -public class PdfSignatureAppearance { - - /** - * The document to be signed. - */ - private final PdfDocument document; - - /** - * Signature model element. - */ - private SignatureFieldAppearance modelElement; - - /** - * The page where the signature will appear. - */ - private int page = 1; - - /** - * The coordinates of the rectangle for a visible signature, - * or a zero-width, zero-height rectangle for an invisible signature. - */ - private Rectangle rect; - - /** - * Rectangle that represent the position and dimension of the signature in the page. - */ - private Rectangle pageRect; - - /** - * The rendering mode chosen for visible signatures. - */ - private RenderingMode renderingMode = RenderingMode.DESCRIPTION; - - /** - * The reason for signing. - */ - private String reason = ""; - - /** - * The caption for the reason for signing. - */ - private String reasonCaption = "Reason: "; - - /** - * Holds value of property location. - */ - private String location = ""; - - /** - * The caption for the location of signing. - */ - private String locationCaption = "Location: "; - - /** - * Holds value of the application that creates the signature. - */ - private String signatureCreator = ""; - - /** - * The contact name of the signer. - */ - private String contact = ""; - - /** - * Holds value of property signDate. - */ - private Calendar signDate; - - /** - * The signing certificate. - */ - private Certificate signCertificate; - - /** - * The image that needs to be used for a visible signature. - */ - private ImageData signatureGraphic = null; - - /** - * A background image for the text in layer 2. - */ - private ImageData image; - - /** - * The scaling to be applied to the background image. - */ - private float imageScale; - - /** - * The text that goes in Layer 2 of the signature appearance. - */ - private String description; - - /** - * Font for the text in Layer 2. - */ - private PdfFont font; - - /** - * Font provider for the text. - */ - private FontProvider fontProvider; - - /** - * Font family for the text. - */ - private String[] fontFamilyNames; - - /** - * Font size for the font of Layer 2. - */ - private float fontSize = 0; - - /** - * Font color for the font of Layer 2. - */ - private Color fontColor; - - /** - * Zero level of the signature appearance. - */ - private PdfFormXObject n0; - - /** - * Second level of the signature appearance. - */ - private PdfFormXObject n2; - - /** - * Indicates the field to be signed. - */ - private String fieldName = ""; - - /** - * Indicates if we need to reuse the existing appearance as layer 0. - */ - private boolean reuseAppearance = false; - // Option for backward compatibility. - private boolean reuseAppearanceSet = false; - - - /** - * Creates a PdfSignatureAppearance. - * - * @param document PdfDocument - * @param pageRect Rectangle of the appearance - * @param pageNumber Number of the page the appearance should be on - */ - protected PdfSignatureAppearance(PdfDocument document, Rectangle pageRect, int pageNumber) { - this.document = document; - this.pageRect = new Rectangle(pageRect); - this.rect = new Rectangle(pageRect.getWidth(), pageRect.getHeight()); - this.page = pageNumber; - } - - /** - * Provides the page number of the signature field which this signature - * appearance is associated with. - * - * @return The page number of the signature field which this signature - * appearance is associated with. - * - * @deprecated won't be public in the next major release. Use {@link PdfSigner#getPageNumber()} instead. - */ - @Deprecated - public int getPageNumber() { - return page; - } - - /** - * Sets the page number of the signature field which this signature - * appearance is associated with. Implicitly calls {@link PdfSignatureAppearance#setPageRect} - * which considers page number to process the rectangle correctly. - * - * @param pageNumber The page number of the signature field which - * this signature appearance is associated with. - * - * @return this instance to support fluent interface. - * - * @deprecated won't be public in the next major release. Use {@link PdfSigner#setPageNumber(int)} instead. - */ - @Deprecated - public PdfSignatureAppearance setPageNumber(int pageNumber) { - this.page = pageNumber; - setPageRect(pageRect); - return this; - } - - /** - * Provides the rectangle that represent the position and dimension - * of the signature field in the page. - * - * @return the rectangle that represent the position and dimension - * of the signature field in the page. - * - * @deprecated won't be public in the next major release. Use {@link PdfSigner#getPageRect()} instead. - */ - @Deprecated - public Rectangle getPageRect() { - return pageRect; - } - - /** - * Sets the rectangle that represent the position and dimension of - * the signature field in the page. - * - * @param pageRect The rectangle that represents the position and - * dimension of the signature field in the page. - * - * @return this instance to support fluent interface. - * - * @deprecated won't be public in the next major release. Use {@link PdfSigner#setPageRect(Rectangle)} instead. - */ - @Deprecated - public PdfSignatureAppearance setPageRect(Rectangle pageRect) { - this.pageRect = new Rectangle(pageRect); - this.rect = new Rectangle(pageRect.getWidth(), pageRect.getHeight()); - return this; - } - - /** - * Get Layer 0 of the appearance. - * - *

    - * The size of the layer is determined by the rectangle set via - * {@link PdfSignatureAppearance#setPageRect(Rectangle)} - * - * @return layer 0. - * - * @deprecated will be deleted in the next major release. - * See {@link PdfSignatureFormField#setBackgroundLayer(PdfFormXObject)}. Note that it should be called - * for the field retrieved with {@link PdfSigner#getSignatureField()} method. - */ - @Deprecated - public PdfFormXObject getLayer0() { - if (n0 == null) { - n0 = new PdfFormXObject(rect); - n0.makeIndirect(document); - } - return n0; - } - - /** - * Get Layer 2 of the appearance. - * - *

    - * The size of the layer is determined by the rectangle set via - * {@link PdfSignatureAppearance#setPageRect(Rectangle)} - * - * @return layer 2. - * - * @deprecated will be deleted in the next major release. - * See {@link PdfSignatureFormField#setSignatureAppearanceLayer(PdfFormXObject)}. Note that it should be called - * for the field retrieved with {@link PdfSigner#getSignatureField()} method. - */ - @Deprecated - public PdfFormXObject getLayer2() { - if (n2 == null) { - n2 = new PdfFormXObject(rect); - n2.makeIndirect(document); - } - return n2; - } - - /** - * Gets the rendering mode for this signature. - * - * @return the rendering mode for this signature. - * - * @deprecated in favour of {@link SignatureFieldAppearance}, rendering mode will be detected depending on specified - * {@code setContent} method parameters. - */ - @Deprecated - public RenderingMode getRenderingMode() { - return renderingMode; - } - - /** - * Sets the rendering mode for this signature. - * - * @param renderingMode the rendering mode. - * - * @return this instance to support fluent interface. - * - * @deprecated in favour of {@link SignatureFieldAppearance}, rendering mode will be detected depending on specified - * {@code setContent} method parameters. - */ - @Deprecated - public PdfSignatureAppearance setRenderingMode(RenderingMode renderingMode) { - this.renderingMode = renderingMode; - return this; - } - - /** - * Returns the signing reason. - * - * @return reason for signing. - * - * @deprecated won't be public in the next major release. Use {@link PdfSigner#getReason()} instead. - */ - @Deprecated - public String getReason() { - return reason; - } - - /** - * Sets the signing reason. - * - * @param reason signing reason. - * - * @return this instance to support fluent interface. - * - * @deprecated won't be public in the next major release. Use {@link PdfSigner#setReason} instead. - */ - @Deprecated - public PdfSignatureAppearance setReason(String reason) { - this.reason = reason; - return this; - } - - /** - * Sets the caption for the signing reason. - * - * @param reasonCaption A new signing reason caption. - * - * @return this instance to support fluent interface. - * - * @deprecated in favour of {@link SignedAppearanceText} that should be used for {@link SignatureFieldAppearance}. - */ - @Deprecated - public PdfSignatureAppearance setReasonCaption(String reasonCaption) { - this.reasonCaption = reasonCaption; - return this; - } - - /** - * Returns the signing location. - * - * @return signing location. - * - * @deprecated won't be public in the next major release. Use {@link PdfSigner#getLocation()} instead. - */ - @Deprecated - public String getLocation() { - return location; - } - - /** - * Sets the signing location. - * - * @param location A new signing location. - * - * @return this instance to support fluent interface. - * - * @deprecated won't be public in the next major release. Use {@link PdfSigner#setLocation} instead. - */ - @Deprecated - public PdfSignatureAppearance setLocation(String location) { - this.location = location; - return this; - } - - /** - * Sets the caption for the signing location. - * - * @param locationCaption A new signing location caption. - * - * @return this instance to support fluent interface. - * - * @deprecated in favour of {@link SignedAppearanceText} that should be used for {@link SignatureFieldAppearance}. - */ - @Deprecated - public PdfSignatureAppearance setLocationCaption(String locationCaption) { - this.locationCaption = locationCaption; - return this; - } - - /** - * Returns the signature creator. - * - * @return The signature creator. - * - * @deprecated Use {@link PdfSigner#getSignatureCreator()} instead. - */ - @Deprecated - public String getSignatureCreator() { - return signatureCreator; - } - - /** - * Sets the name of the application used to create the signature. - * - * @param signatureCreator A new name of the application signing a document. - * - * @return this instance to support fluent interface. - * - * @deprecated Use {@link PdfSigner#setSignatureCreator(String)} instead. - */ - @Deprecated - public PdfSignatureAppearance setSignatureCreator(String signatureCreator) { - this.signatureCreator = signatureCreator; - return this; - } - - /** - * Returns the signing contact. - * - * @return The signing contact. - * - * @deprecated Use {@link PdfSigner#getContact()} instead. - */ - @Deprecated - public String getContact() { - return contact; - } - - /** - * Sets the signing contact. - * - * @param contact A new signing contact. - * - * @return this instance to support fluent interface. - * - * @deprecated Use {@link PdfSigner#setContact(String)} instead. - */ - @Deprecated - public PdfSignatureAppearance setContact(String contact) { - this.contact = contact; - return this; - } - - /** - * Sets the certificate used to provide the text in the appearance. - * This certificate doesn't take part in the actual signing process. - * - * @param signCertificate the certificate. - * - * @return this instance to support fluent interface. - * - * @deprecated in favour of {@link SignedAppearanceText} that should be used for {@link SignatureFieldAppearance}. - * Specified certificate provides signer name. - */ - @Deprecated - public PdfSignatureAppearance setCertificate(Certificate signCertificate) { - this.signCertificate = signCertificate; - return this; - } - - /** - * Get the signing certificate. - * - * @return the signing certificate. - * - * @deprecated in favour of {@link SignedAppearanceText} that should be used for {@link SignatureFieldAppearance}. - */ - @Deprecated - public Certificate getCertificate() { - return signCertificate; - } - - /** - * Gets the Image object to render. - * - * @return the image. - * - * @deprecated in favour of {@link SignatureFieldAppearance}. - */ - @Deprecated - public ImageData getSignatureGraphic() { - return signatureGraphic; - } - - /** - * Sets the Image object to render when Render is set to RenderingMode.GRAPHIC or RenderingMode.GRAPHIC_AND_DESCRIPTION. - * - * @param signatureGraphic image rendered. If null the mode is defaulted to RenderingMode.DESCRIPTION - * - * @return this instance to support fluent interface. - * - * @deprecated in favour of {@link SignatureFieldAppearance#setContent(ImageData)} or - * {@link SignatureFieldAppearance#setContent(String, ImageData)}. - */ - @Deprecated - public PdfSignatureAppearance setSignatureGraphic(ImageData signatureGraphic) { - this.signatureGraphic = signatureGraphic; - return this; - } - - /** - * Indicates that the existing appearances needs to be reused as a background layer. - * - * @param reuseAppearance is an appearances reusing flag value to set. - * - * @return this instance to support fluent interface. - * - * @deprecated in favour of {@link PdfSignatureFormField#setReuseAppearance(boolean)}. Note that it should be called - * for the field retrieved with {@link PdfSigner#getSignatureField()} method. - */ - @Deprecated - public PdfSignatureAppearance setReuseAppearance(boolean reuseAppearance) { - this.reuseAppearance = reuseAppearance; - this.reuseAppearanceSet = true; - return this; - } - - /** - * Gets the background image for the layer 2. - * - * @return the background image for the layer 2. - * - * @deprecated in favour of {@link SignatureFieldAppearance#setBackgroundImage(BackgroundImage)}. - */ - @Deprecated - public ImageData getImage() { - return image; - } - - /** - * Sets the background image for the text in the layer 2. - * - * @param image the background image for the layer 2. - * - * @return this instance to support fluent interface. - * - * @deprecated in favour of {@link SignatureFieldAppearance#setBackgroundImage(BackgroundImage)}. - */ - @Deprecated - public PdfSignatureAppearance setImage(ImageData image) { - this.image = image; - return this; - } - - /** - * Gets the scaling to be applied to the background image. - * - * @return the scaling to be applied to the background image. - * - * @deprecated in favour of {@link SignatureFieldAppearance#setBackgroundImage(BackgroundImage)}. - */ - @Deprecated - public float getImageScale() { - return imageScale; - } - - /** - * Sets the scaling to be applied to the background image. If it's zero the image - * will fully fill the rectangle. If it's less than zero the image will fill the rectangle but - * will keep the proportions. If it's greater than zero that scaling will be applied. - * In any of the cases the image will always be centered. It's zero by default. - * - * @param imageScale the scaling to be applied to the background image. - * - * @return this instance to support fluent interface. - * - * @deprecated in favour of {@link SignatureFieldAppearance#setBackgroundImage(BackgroundImage)}. - */ - @Deprecated - public PdfSignatureAppearance setImageScale(float imageScale) { - this.imageScale = imageScale; - return this; - } - - /** - * Sets the signature text identifying the signer. - * - * @param text the signature text identifying the signer. If null or not set - * a standard description will be used. - * - * @return this instance to support fluent interface. - * - * @deprecated in favour of {@link SignatureFieldAppearance}. - */ - @Deprecated - public PdfSignatureAppearance setLayer2Text(String text) { - this.description = text; - return this; - } - - /** - * Gets the signature text identifying the signer if set by setLayer2Text(). - * - * @return the signature text identifying the signer. - * - * @deprecated in favour of {@link SignatureFieldAppearance}. - */ - @Deprecated - public String getLayer2Text() { - return description; - } - - /** - * Gets the n2 and n4 layer font. - * - * @return the n2 and n4 layer font. - * - * @deprecated in favour of {@link SignatureFieldAppearance}. - */ - @Deprecated - public PdfFont getLayer2Font() { - return this.font; - } - - /** - * Sets the n2 layer font. If the font size is zero, auto-fit will be used. - * - * @param font the n2 font. - * - * @return this instance to support fluent interface. - * - * @deprecated in favour of {@link SignatureFieldAppearance#setFont(PdfFont)}. - */ - @Deprecated - public PdfSignatureAppearance setLayer2Font(PdfFont font) { - this.font = font; - return this; - } - - /** - * Sets the n2 and n4 layer font size. - * - * @param fontSize font size. - * - * @return this instance to support fluent interface. - * - * @deprecated in favour of {@link SignatureFieldAppearance#setFontSize(float)}. - */ - @Deprecated - public PdfSignatureAppearance setLayer2FontSize(float fontSize) { - this.fontSize = fontSize; - return this; - } - - /** - * Gets the n2 and n4 layer font size. - * - * @return the n2 and n4 layer font size. - * - * @deprecated in favour of {@link SignatureFieldAppearance}. - */ - @Deprecated - public float getLayer2FontSize() { - return fontSize; - } - - /** - * Sets the n2 and n4 layer font color. - * - * @param color font color. - * - * @return this instance to support fluent interface. - * - * @deprecated in favour of {@link SignatureFieldAppearance#setFontColor(Color)}. - */ - @Deprecated - public PdfSignatureAppearance setLayer2FontColor(Color color) { - this.fontColor = color; - return this; - } - - /** - * Gets the n2 layer font color. - * - * @return the n2 layer font color. - * - * @deprecated in favour of {@link SignatureFieldAppearance}. - */ - @Deprecated - public Color getLayer2FontColor() { - return fontColor; - } - - /** - * Gets the signature layout element. - * - * @return the signature layout element. - */ - public SignatureFieldAppearance getSignatureAppearance() { - if (modelElement == null) { - modelElement = new SignatureFieldAppearance(fieldName); - setContent(); - setFontRelatedProperties(); - applyBackgroundImage(); - } else { - populateExistingModelElement(); - } - return modelElement; - } - - /** - * Sets the signature layout element. - * - * @param modelElement the signature layout element. - * - * @return this instance to support fluent interface. - * - * @deprecated Use {@link PdfSigner#setSignatureAppearance(SignatureFieldAppearance)} instead. - */ - @Deprecated - public PdfSignatureAppearance setSignatureAppearance(SignatureFieldAppearance modelElement) { - this.modelElement = modelElement; - return this; - } - - /** - * Sets {@link FontProvider}. Note, font provider is inherited property. - * - * @param fontProvider the instance of {@link FontProvider}. - * - * @return this instance to support fluent interface. - * - * @deprecated in favour of {@link SignatureFieldAppearance#setProperty(int, Object)}. - */ - @Deprecated - public PdfSignatureAppearance setFontProvider(FontProvider fontProvider) { - this.fontProvider = fontProvider; - return this; - } - - /** - * Sets the preferable font families for the signature content. - * Note that {@link com.itextpdf.layout.font.FontProvider} shall be set as well. - * - * @param fontFamilyNames defines an ordered list of preferable font families for the signature element. - * - * @return this instance to support fluent interface. - * - * @deprecated in favour of {@link SignatureFieldAppearance#setFontFamily(String...)}. - */ - @Deprecated - public PdfSignatureAppearance setFontFamily(String... fontFamilyNames) { - this.fontFamilyNames = fontFamilyNames; - return this; - } - - /** - * Gets the visibility status of the signature. - * - * @return the visibility status of the signature. - * - * @deprecated won't be public in the next major release. - */ - @Deprecated - public boolean isInvisible() { - return rect == null || rect.getWidth() == 0 || rect.getHeight() == 0; - } - - /** - * Constructs appearance (top-level) for a signature. - * - * @return a top-level signature appearance. - * - * @throws IOException if font cannot be created. - * - * @see Adobe Pdf Digital - * Signature Appearances - * - * @deprecated in favour of {@link SignatureFieldAppearance}. Shouldn't be used. - */ - @Deprecated - protected PdfFormXObject getAppearance() throws IOException { - SignatureUtil signatureUtil = new SignatureUtil(document); - boolean fieldExist = signatureUtil.doesSignatureFieldExist(fieldName); - PdfSignatureFormField sigField; - if (fieldExist) { - sigField = (PdfSignatureFormField) PdfFormCreator.getAcroForm(document, true).getField(fieldName); - } else { - sigField = new SignatureFormFieldBuilder(document, fieldName) - .setWidgetRectangle(rect).createSignature(); - } - sigField.getFirstFormAnnotation().setFormFieldElement(getSignatureAppearance()); - return new PdfFormXObject(sigField.getFirstFormAnnotation().getPdfObject() - .getAsDictionary(PdfName.AP).getAsStream(PdfName.N)); - } - - /** - * Returns the signature date. - * - * @return the signature date. - * - * @deprecated use {@link PdfSigner#getSignDate()} instead. - */ - @Deprecated - protected java.util.Calendar getSignDate() { - return signDate; - } - - /** - * Sets the signature date. - * - * @param signDate A new signature date. - * - * @return this instance to support fluent interface. - * - * @deprecated use {@link PdfSigner#setSignDate(Calendar)} instead. - */ - @Deprecated - protected PdfSignatureAppearance setSignDate(java.util.Calendar signDate) { - this.signDate = signDate; - return this; - } - - /** - * Set the field name of the appearance. Field name indicates the field to be signed if it is already presented - * in the document (signing existing field). Required for reuseAppearance option. - * - * @param fieldName name of the field - * - * @return this instance to support fluent interface - */ - protected PdfSignatureAppearance setFieldName(String fieldName) { - this.fieldName = fieldName; - return this; - } - - /** - * Returns reuseAppearance value which indicates that the existing appearances needs to be reused - * as a background layer. - * - * @return an appearances reusing flag value. - */ - boolean isReuseAppearance() { - return reuseAppearance; - } - - /** - * Checks if reuseAppearance value was set using {@link this#setReuseAppearance(boolean)}. - * Used for backward compatibility. - * - * @return boolean value. - */ - boolean isReuseAppearanceSet() { - return reuseAppearanceSet; - } - - /** - * Gets the background layer that is present when creating the signature field if it was set. - * - * @return n0 layer xObject. - */ - PdfFormXObject getBackgroundLayer() { - return n0; - } - - /** - * Gets the signature appearance layer that contains information about the signature if it was set. - * - * @return n2 layer xObject. - */ - PdfFormXObject getSignatureAppearanceLayer() { - return n2; - } - - void applyBackgroundImage() { - if (image != null) { - BackgroundRepeat repeat = new BackgroundRepeat(BackgroundRepeat.BackgroundRepeatValue.NO_REPEAT); - BackgroundPosition position = new BackgroundPosition() - .setPositionX(BackgroundPosition.PositionX.CENTER) - .setPositionY(BackgroundPosition.PositionY.CENTER); - BackgroundSize size = new BackgroundSize(); - final float EPS = 1e-5f; - if (Math.abs(imageScale) < EPS) { - size.setBackgroundSizeToValues(UnitValue.createPercentValue(100), - UnitValue.createPercentValue(100)); - } else {; - if (imageScale < 0) { - size.setBackgroundSizeToContain(); - } else { - size.setBackgroundSizeToValues( - UnitValue.createPointValue(imageScale * image.getWidth()), - UnitValue.createPointValue(imageScale * image.getHeight())); - } - } - modelElement.setBackgroundImage(new BackgroundImage.Builder() - .setImage(new PdfImageXObject(image)) - .setBackgroundSize(size) - .setBackgroundRepeat(repeat) - .setBackgroundPosition(position) - .build()); - } - } - - SignedAppearanceText generateSignatureText() { - return new SignedAppearanceText() - .setSignedBy(getSignerName()) - .setSignDate(signDate) - .setReasonLine(reasonCaption + reason) - .setLocationLine(locationCaption + location); - } - - private void setFontRelatedProperties() { - if (fontProvider != null) { - modelElement.setProperty(Property.FONT_PROVIDER, fontProvider); - modelElement.setFontFamily(fontFamilyNames); - } else { - modelElement.setFont(font); - } - modelElement.setFontSize(fontSize); - modelElement.setFontColor(fontColor); - } - - private void setContent() { - if (isInvisible()) { - return; - } - switch (renderingMode) { - case GRAPHIC: { - if (signatureGraphic == null) { - throw new IllegalStateException("A signature image must be present when rendering mode is " + - "graphic and description. Use setSignatureGraphic()"); - } - modelElement.setContent(signatureGraphic); - break; - } - case GRAPHIC_AND_DESCRIPTION: { - if (signatureGraphic == null) { - throw new IllegalStateException("A signature image must be present when rendering mode is " + - "graphic and description. Use setSignatureGraphic()"); - } - if (description != null) { - modelElement.setContent(description, signatureGraphic); - } else { - modelElement.setContent(generateSignatureText(), signatureGraphic); - } - break; - } - case NAME_AND_DESCRIPTION: { - if (description != null) { - modelElement.setContent(getSignerName(), description); - } else { - modelElement.setContent(getSignerName(), generateSignatureText()); - } - break; - } - default: { - if (description != null) { - modelElement.setContent(description); - } else { - modelElement.setContent(generateSignatureText()); - } - } - } - } - - private void populateExistingModelElement() { - modelElement.setSignerName(getSignerName()); - SignedAppearanceText signedAppearanceText = modelElement.getSignedAppearanceText(); - if (signedAppearanceText != null) { - signedAppearanceText.setSignedBy(getSignerName()).setSignDate(signDate); - if (signedAppearanceText.getReasonLine().isEmpty()) { - signedAppearanceText.setReasonLine(reasonCaption + reason); - } - if (signedAppearanceText.getLocationLine().isEmpty()) { - signedAppearanceText.setLocationLine(locationCaption + location); - } - } - } - - private String getSignerName() { - String name = null; - CertificateInfo.X500Name x500name = CertificateInfo.getSubjectFields((X509Certificate)signCertificate); - if (x500name != null) { - name = x500name.getField("CN"); - if (name == null) { - name = x500name.getField("E"); - } - } - return name == null? "" : name; - } - - /** - * Signature rendering modes. - */ - @Deprecated - public enum RenderingMode { - /** - * The rendering mode is just the description. - */ - DESCRIPTION, - /** - * The rendering mode is the name of the signer and the description. - */ - NAME_AND_DESCRIPTION, - /** - * The rendering mode is an image and the description. - */ - GRAPHIC_AND_DESCRIPTION, - /** - * The rendering mode is just an image. - */ - GRAPHIC - } -} diff --git a/sign/src/main/java/com/itextpdf/signatures/PdfSigner.java b/sign/src/main/java/com/itextpdf/signatures/PdfSigner.java index 5459ac0aa5..2a45030f90 100644 --- a/sign/src/main/java/com/itextpdf/signatures/PdfSigner.java +++ b/sign/src/main/java/com/itextpdf/signatures/PdfSigner.java @@ -23,7 +23,11 @@ This file is part of the iText (R) project. package com.itextpdf.signatures; import com.itextpdf.bouncycastleconnector.BouncyCastleFactoryCreator; +import com.itextpdf.commons.bouncycastle.IBouncyCastleFactory; +import com.itextpdf.commons.bouncycastle.asn1.IASN1EncodableVector; +import com.itextpdf.commons.bouncycastle.asn1.IASN1Sequence; import com.itextpdf.commons.bouncycastle.asn1.esf.ISignaturePolicyIdentifier; +import com.itextpdf.commons.utils.FileUtil; import com.itextpdf.commons.utils.MessageFormatUtil; import com.itextpdf.forms.PdfAcroForm; import com.itextpdf.forms.PdfSigFieldLock; @@ -32,19 +36,19 @@ This file is part of the iText (R) project. import com.itextpdf.forms.fields.PdfFormField; import com.itextpdf.forms.fields.PdfSignatureFormField; import com.itextpdf.forms.fields.SignatureFormFieldBuilder; +import com.itextpdf.forms.fields.properties.SignedAppearanceText; import com.itextpdf.forms.form.element.SignatureFieldAppearance; import com.itextpdf.forms.util.BorderStyleUtil; import com.itextpdf.io.source.ByteBuffer; import com.itextpdf.io.source.IRandomAccessSource; import com.itextpdf.io.source.RASInputStream; import com.itextpdf.io.source.RandomAccessSourceFactory; -import com.itextpdf.commons.utils.DateTimeUtil; -import com.itextpdf.commons.utils.FileUtil; import com.itextpdf.io.util.StreamUtil; +import com.itextpdf.kernel.crypto.DigestAlgorithms; import com.itextpdf.kernel.exceptions.PdfException; import com.itextpdf.kernel.font.PdfFont; import com.itextpdf.kernel.geom.Rectangle; -import com.itextpdf.kernel.pdf.IsoKey; +import com.itextpdf.kernel.mac.IMacContainerLocator; import com.itextpdf.kernel.pdf.PdfArray; import com.itextpdf.kernel.pdf.PdfDate; import com.itextpdf.kernel.pdf.PdfDeveloperExtension; @@ -63,13 +67,27 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.StampingProperties; import com.itextpdf.kernel.pdf.annot.PdfAnnotation; import com.itextpdf.kernel.pdf.annot.PdfWidgetAnnotation; +import com.itextpdf.kernel.pdf.tagutils.AccessibilityProperties; +import com.itextpdf.kernel.validation.ValidationContainer; +import com.itextpdf.kernel.validation.context.SignTypeValidationContext; +import com.itextpdf.kernel.validation.context.SignatureValidationContext; import com.itextpdf.layout.properties.Background; import com.itextpdf.layout.properties.Property; import com.itextpdf.layout.properties.TextAlignment; import com.itextpdf.layout.properties.TransparentColor; import com.itextpdf.layout.properties.UnitValue; -import com.itextpdf.pdfa.PdfAAgnosticPdfDocument; +import com.itextpdf.layout.tagging.IAccessibleElement; +import com.itextpdf.pdfa.PdfADefaultFontStrategy; +import com.itextpdf.pdfa.PdfADocument; +import com.itextpdf.pdfa.PdfADocumentInfoHelper; +import com.itextpdf.pdfa.PdfAPageFactory; +import com.itextpdf.pdfa.checker.PdfAChecker; +import com.itextpdf.signatures.cms.CMSContainer; +import com.itextpdf.signatures.cms.CmsAttribute; import com.itextpdf.signatures.exceptions.SignExceptionMessageConstant; +import com.itextpdf.signatures.mac.SignatureContainerGenerationEvent; +import com.itextpdf.signatures.mac.SignatureDocumentClosingEvent; +import com.itextpdf.signatures.mac.SignatureMacContainerLocator; import java.io.ByteArrayOutputStream; import java.io.EOFException; @@ -96,6 +114,10 @@ This file is part of the iText (R) project. * Takes care of the cryptographic options and appearances that form a signature. */ public class PdfSigner { + static final int MAXIMUM_MAC_SIZE = 788; + private static final IBouncyCastleFactory FACTORY = BouncyCastleFactoryCreator.getFactory(); + private static final String ID_ATTR_PDF_MAC_DATA = "1.0.32004.1.2"; + /** * Enum containing the Cryptographic Standards. Possible values are "CMS" and "CADES". */ @@ -111,36 +133,6 @@ public enum CryptoStandard { CADES } - /** - * Approval signature. - */ - public static final int NOT_CERTIFIED = 0; - - /** - * Author signature, no changes allowed. - */ - public static final int CERTIFIED_NO_CHANGES_ALLOWED = 1; - - /** - * Author signature, form filling allowed. - */ - public static final int CERTIFIED_FORM_FILLING = 2; - - /** - * Author signature, form filling and annotations allowed. - */ - public static final int CERTIFIED_FORM_FILLING_AND_ANNOTATIONS = 3; - - /** - * The certification level. - */ - protected int certificationLevel = NOT_CERTIFIED; - - /** - * The name of the field. - */ - protected String fieldName; - /** * The file right before the signature is added (can be null). */ @@ -197,29 +189,24 @@ public enum CryptoStandard { protected boolean preClosed = false; /** - * Signature field lock dictionary. - */ - protected PdfSigFieldLock fieldLock; - - /** - * The signature appearance. + * Boolean to check if this PdfSigner instance has been closed already or not. */ - protected PdfSignatureAppearance appearance; + protected boolean closed = false; /** - * Holds value of property signDate. + * AcroForm for the PdfDocument. */ - protected Calendar signDate = DateTimeUtil.getCurrentTimeCalendar(); + private final PdfAcroForm acroForm; /** - * Boolean to check if this PdfSigner instance has been closed already or not. + * The name of the signer extracted from the signing certificate. */ - protected boolean closed = false; + private String signerName = ""; /** - * AcroForm for the PdfDocument. + * Properties to be used in signing operations. */ - private final PdfAcroForm acroForm; + private SignerProperties signerProperties = new SignerProperties(); /** * Creates a PdfSigner instance. Uses a {@link java.io.ByteArrayOutputStream} instead of a temporary file. @@ -228,6 +215,7 @@ public enum CryptoStandard { * @param outputStream OutputStream to write the signed PDF file * @param properties {@link StampingProperties} for the signing document. Note that encryption will be * preserved regardless of what is set in properties. + * * @throws IOException if some I/O problem occurs */ public PdfSigner(PdfReader reader, OutputStream outputStream, StampingProperties properties) throws IOException { @@ -237,30 +225,20 @@ public PdfSigner(PdfReader reader, OutputStream outputStream, StampingProperties /** * Creates a PdfSigner instance. Uses a {@link java.io.ByteArrayOutputStream} instead of a temporary file. * - * @param reader PdfReader that reads the PDF file - * @param outputStream OutputStream to write the signed PDF file - * @param path File to which the output is temporarily written - * @param stampingProperties {@link StampingProperties} for the signing document. Note that encryption will be - * preserved regardless of what is set in properties. - * @param signerProperties {@link SignerProperties} bundled properties to be used in signing operations. + * @param reader PdfReader that reads the PDF file + * @param outputStream OutputStream to write the signed PDF file + * @param path File to which the output is temporarily written + * @param stampingProperties {@link StampingProperties} for the signing document. Note that encryption will be + * preserved regardless of what is set in properties. + * @param signerProperties {@link SignerProperties} bundled properties to be used in signing operations. + * * @throws IOException if some I/O problem occurs */ public PdfSigner(PdfReader reader, OutputStream outputStream, String path, StampingProperties stampingProperties, SignerProperties signerProperties) throws IOException { this(reader, outputStream, path, stampingProperties); - this.fieldLock = signerProperties.getFieldLockDict(); - updateFieldName(signerProperties.getFieldName()); - // We need to update field name because the setter could change it and the user can rely on this field - signerProperties.setFieldName(fieldName); - certificationLevel =signerProperties.getCertificationLevel(); - appearance.setPageRect(signerProperties.getPageRect()); - appearance.setPageNumber(signerProperties.getPageNumber()); - appearance.setSignDate(signerProperties.getSignDate()); - appearance.setSignatureCreator(signerProperties.getSignatureCreator()); - appearance.setContact(signerProperties.getContact()); - appearance.setReason(signerProperties.getReason()); - appearance.setLocation(signerProperties.getLocation()); - this.appearance.setSignatureAppearance(signerProperties.getSignatureAppearance()); + this.signerProperties = signerProperties; + updateFieldName(); } /** @@ -271,24 +249,24 @@ public PdfSigner(PdfReader reader, OutputStream outputStream, String path, Stamp * @param path File to which the output is temporarily written * @param properties {@link StampingProperties} for the signing document. Note that encryption will be * preserved regardless of what is set in properties. + * * @throws IOException if some I/O problem occurs */ public PdfSigner(PdfReader reader, OutputStream outputStream, String path, StampingProperties properties) throws IOException { StampingProperties localProps = new StampingProperties(properties).preserveEncryption(); + localProps.registerDependency(IMacContainerLocator.class, new SignatureMacContainerLocator()); if (path == null) { - temporaryOS = new ByteArrayOutputStream(); - document = initDocument(reader, new PdfWriter(temporaryOS), localProps); + this.temporaryOS = new ByteArrayOutputStream(); + this.document = initDocument(reader, new PdfWriter(temporaryOS), localProps); } else { this.tempFile = FileUtil.createTempFile(path); - document = initDocument(reader, new PdfWriter(FileUtil.getFileOutputStream(tempFile)), localProps); + this.document = initDocument(reader, new PdfWriter(FileUtil.getFileOutputStream(tempFile)), localProps); } - acroForm = PdfFormCreator.getAcroForm(document, true); + this.acroForm = PdfFormCreator.getAcroForm(document, true); - originalOS = outputStream; - fieldName = getNewSigFieldName(); - appearance = new PdfSignatureAppearance(document, new Rectangle(0, 0), 1); - appearance.setSignDate(signDate); + this.originalOS = outputStream; + this.signerProperties.setFieldName(getNewSigFieldName()); } PdfSigner(PdfDocument document, OutputStream outputStream, ByteArrayOutputStream temporaryOS, File tempFile) { @@ -300,126 +278,51 @@ public PdfSigner(PdfReader reader, OutputStream outputStream, String path, Stamp this.document = document; this.acroForm = PdfFormCreator.getAcroForm(document, true); this.originalOS = outputStream; - this.fieldName = getNewSigFieldName(); - this.appearance = new PdfSignatureAppearance(document, new Rectangle(0, 0), 1); - this.appearance.setSignDate(this.signDate); + this.signerProperties.setFieldName(getNewSigFieldName()); } /** * Initialize new {@link PdfDocument} instance by using provided parameters. * - * @param reader {@link PdfReader} to be used as a reader in the new document - * @param writer {@link PdfWriter} to be used as a writer in the new document + * @param reader {@link PdfReader} to be used as a reader in the new document + * @param writer {@link PdfWriter} to be used as a writer in the new document * @param properties {@link StampingProperties} to be provided in the new document * * @return new {@link PdfDocument} instance */ protected PdfDocument initDocument(PdfReader reader, PdfWriter writer, StampingProperties properties) { - return new PdfAAgnosticPdfDocument(reader, writer, properties); - } - - /** - * Gets the signature date. - * - * @return Calendar set to the signature date - */ - public java.util.Calendar getSignDate() { - return signDate; - } - - /** - * Sets the signature date. - * - * @param signDate the signature date - */ - public void setSignDate(java.util.Calendar signDate) { - this.signDate = signDate; - this.appearance.setSignDate(signDate); - } - - /** - * Provides access to a signature appearance object. Use it to - * customize the appearance of the signature. - *

    - * Be aware: - *

      - *
    • If you create new signature field (either use {@link #setFieldName} with - * the name that doesn't exist in the document or don't specify it at all) then - * the signature is invisible by default. - *
    • If you sign already existing field, then the signature appearance object - * is modified to have all the properties (page num., rect etc.) consistent with - * the state of the field (if you customized the appearance object - * before the {@link #setFieldName} call you'll have to do it again) - *
    - *

    - * - * @return {@link PdfSignatureAppearance} object. - */ - @Deprecated - public PdfSignatureAppearance getSignatureAppearance() { - return appearance; + // TODO DEVSIX-8676 Enable keeping A and UA conformance in PdfSigner + // TODO DEVSIX-8677 let users preserve document's conformance without knowing upfront their conformance + return new PdfSignerDocument(reader, writer, properties); } /** - * Sets the signature field layout element to customize the appearance of the signature. Signer's sign date will - * be set. + * Sets the properties to be used in signing operations. * - * @param appearance the {@link SignatureFieldAppearance} layout element. - */ - public void setSignatureAppearance(SignatureFieldAppearance appearance) { - this.appearance.setSignatureAppearance(appearance); - } - - /** - * Returns the document's certification level. - * For possible values see {@link #setCertificationLevel(int)}. + * @param properties the signer properties * - * @return The certified status. + * @return this instance to support fluent interface */ - public int getCertificationLevel() { - return this.certificationLevel; - } - - /** - * Sets the document's certification level. - * This method overrides the value set by {@link #setCertificationLevel(AccessPermissions)}. - * - * @param certificationLevel a new certification level for a document. - * Possible values are:

      - *
    • {@link #NOT_CERTIFIED} - *
    • {@link #CERTIFIED_NO_CHANGES_ALLOWED} - *
    • {@link #CERTIFIED_FORM_FILLING} - *
    • {@link #CERTIFIED_FORM_FILLING_AND_ANNOTATIONS} - *
    - */ - public void setCertificationLevel(int certificationLevel) { - this.certificationLevel = certificationLevel; - } - - /** - * Sets the document's certification level. - * This method overrides the value set by {@link #setCertificationLevel(int)}. - * - * @param accessPermissions {@link AccessPermissions} enum which specifies which certification level shall be used - */ - public void setCertificationLevel(AccessPermissions accessPermissions) { - this.certificationLevel = accessPermissions.ordinal(); + public PdfSigner setSignerProperties(SignerProperties properties) { + this.signerProperties = properties; + updateFieldName(); + return this; } /** - * Gets the field name. + * Gets the properties to be used in signing operations. * - * @return the field name + * @return the signer properties */ - public String getFieldName() { - return fieldName; + public SignerProperties getSignerProperties() { + return this.signerProperties; } /** * Returns the user made signature dictionary. This is the dictionary at the /V key * of the signature field. * - * @return The user made signature dictionary. + * @return the user made signature dictionary */ public PdfSignature getSignatureDictionary() { return cryptoDictionary; @@ -428,7 +331,7 @@ public PdfSignature getSignatureDictionary() { /** * Getter for property signatureEvent. * - * @return Value of property signatureEvent. + * @return value of property signatureEvent */ public ISignatureEvent getSignatureEvent() { return this.signatureEvent; @@ -459,16 +362,6 @@ public String getNewSigFieldName() { return name + step; } - /** - * Sets the name indicating the field to be signed. The field can already be presented in the - * document but shall not be signed. If the field is not presented in the document, it will be created. - * - * @param fieldName The name indicating the field to be signed. - */ - public void setFieldName(String fieldName) { - updateFieldName(fieldName); - } - /** * Gets the PdfDocument associated with this instance. * @@ -490,57 +383,6 @@ protected void setDocument(PdfDocument document) { this.document = document; } - /** - * Provides the page number of the signature field which this signature - * appearance is associated with. - * - * @return The page number of the signature field which this signature - * appearance is associated with. - */ - public int getPageNumber() { - return appearance.getPageNumber(); - } - - /** - * Sets the page number of the signature field which this signature - * appearance is associated with. Implicitly calls {@link PdfSigner#setPageRect} - * which considers page number to process the rectangle correctly. - * - * @param pageNumber The page number of the signature field which - * this signature appearance is associated with. - * - * @return this instance to support fluent interface. - */ - public PdfSigner setPageNumber(int pageNumber) { - appearance.setPageNumber(pageNumber); - return this; - } - - /** - * Provides the rectangle that represent the position and dimension - * of the signature field in the page. - * - * @return the rectangle that represent the position and dimension - * of the signature field in the page - */ - public Rectangle getPageRect() { - return appearance.getPageRect(); - } - - /** - * Sets the rectangle that represent the position and dimension of - * the signature field in the page. - * - * @param pageRect The rectangle that represents the position and - * dimension of the signature field in the page. - * - * @return this instance to support fluent interface. - */ - public PdfSigner setPageRect(Rectangle pageRect) { - appearance.setPageRect(pageRect); - return this; - } - /** * Setter for the OutputStream. * @@ -550,111 +392,6 @@ public void setOriginalOutputStream(OutputStream originalOS) { this.originalOS = originalOS; } - /** - * Getter for the field lock dictionary. - * - * @return Field lock dictionary. - */ - public PdfSigFieldLock getFieldLockDict() { - return fieldLock; - } - - /** - * Setter for the field lock dictionary. - *

    - * Be aware: if a signature is created on an existing signature field, - * then its /Lock dictionary takes the precedence (if it exists). - * - * @param fieldLock Field lock dictionary - */ - public void setFieldLockDict(PdfSigFieldLock fieldLock) { - this.fieldLock = fieldLock; - } - - /** - * Returns the signature creator. - * - * @return The signature creator. - */ - public String getSignatureCreator() { - return appearance.getSignatureCreator(); - } - - /** - * Sets the name of the application used to create the signature. - * - * @param signatureCreator A new name of the application signing a document. - * - * @return this instance to support fluent interface. - */ - public PdfSigner setSignatureCreator(String signatureCreator) { - appearance.setSignatureCreator(signatureCreator); - return this; - } - - /** - * Returns the signing contact. - * - * @return The signing contact. - */ - public String getContact() { - return appearance.getContact(); - } - - /** - * Sets the signing contact. - * - * @param contact A new signing contact. - * - * @return this instance to support fluent interface. - */ - public PdfSigner setContact(String contact) { - appearance.setContact(contact); - return this; - } - - /** - * Returns the signing reason. - * - * @return The signing reason. - */ - public String getReason() { - return appearance.getReason(); - } - - /** - * Sets the signing reason. - * - * @param reason A new signing reason. - * - * @return this instance to support fluent interface. - */ - public PdfSigner setReason(String reason) { - appearance.setReason(reason); - return this; - } - - /** - * Returns the signing location. - * - * @return The signing location. - */ - public String getLocation() { - return appearance.getLocation(); - } - - /** - * Sets the signing location. - * - * @param location A new signing location. - * - * @return this instance to support fluent interface. - */ - public PdfSigner setLocation(String location) { - appearance.setLocation(location); - return this; - } - /** * Gets the signature field to be signed. The field can already be presented in the document. If the field is * not presented in the document, it will be created. @@ -664,14 +401,29 @@ public PdfSigner setLocation(String location) { * {@link PdfSignatureFormField#setReuseAppearance}, {@link PdfSignatureFormField#setBackgroundLayer} and * {@link PdfSignatureFormField#setSignatureAppearanceLayer}. * - * @return the {@link PdfSignatureFormField} instance. + *

    + * Note that for the new signature field {@link SignerProperties#setPageRect(Rectangle)} and + * {@link SignerProperties#setPageNumber(int)} should be called before this method. + * + * @return the {@link PdfSignatureFormField} instance */ public PdfSignatureFormField getSignatureField() { - PdfFormField field = acroForm.getField(fieldName); + PdfFormField field = acroForm.getField(getFieldName()); if (field == null) { - PdfSignatureFormField sigField = new SignatureFormFieldBuilder(document, fieldName) - .setWidgetRectangle(getPageRect()).createSignature(); + PdfSignatureFormField sigField = + new SignatureFormFieldBuilder(document, this.signerProperties.getFieldName()) + .setWidgetRectangle(this.signerProperties.getPageRect()) + .setPage(this.signerProperties.getPageNumber()) + .createSignature(); acroForm.addField(sigField); + + if (acroForm.getPdfObject().isIndirect()) { + acroForm.setModified(); + } else { + // Acroform dictionary is a Direct dictionary, + // for proper flushing, catalog needs to be marked as modified + document.getCatalog().setModified(); + } return sigField; } if (field instanceof PdfSignatureFormField) { @@ -694,12 +446,13 @@ public PdfSignatureFormField getSignatureField() { * @param externalDigest an implementation that provides the digest * @param estimatedSize the reserved size for the signature. It will be estimated if 0 * @param sigtype Either Signature.CMS or Signature.CADES + * * @throws IOException if some I/O problem occurs * @throws GeneralSecurityException if some problem during apply security algorithms occurs */ public void signDetached(IExternalDigest externalDigest, IExternalSignature externalSignature, Certificate[] chain, - Collection crlList, IOcspClient ocspClient, ITSAClient tsaClient, int estimatedSize, - CryptoStandard sigtype) throws IOException, GeneralSecurityException { + Collection crlList, IOcspClient ocspClient, ITSAClient tsaClient, int estimatedSize, + CryptoStandard sigtype) throws IOException, GeneralSecurityException { signDetached(externalDigest, externalSignature, chain, crlList, ocspClient, tsaClient, estimatedSize, sigtype, (ISignaturePolicyIdentifier) null); } @@ -717,6 +470,7 @@ public void signDetached(IExternalDigest externalDigest, IExternalSignature exte * @param tsaClient the Timestamp client * @param estimatedSize the reserved size for the signature. It will be estimated if 0 * @param sigtype Either Signature.CMS or Signature.CADES + * * @throws IOException if some I/O problem occurs * @throws GeneralSecurityException if some problem during apply security algorithms occurs */ @@ -742,12 +496,13 @@ public void signDetached(IExternalSignature externalSignature, Certificate[] cha * @param estimatedSize the reserved size for the signature. It will be estimated if 0 * @param sigtype Either Signature.CMS or Signature.CADES * @param signaturePolicy the signature policy (for EPES signatures) + * * @throws IOException if some I/O problem occurs * @throws GeneralSecurityException if some problem during apply security algorithms occurs */ public void signDetached(IExternalDigest externalDigest, IExternalSignature externalSignature, Certificate[] chain, - Collection crlList, IOcspClient ocspClient, ITSAClient tsaClient, int estimatedSize, - CryptoStandard sigtype, SignaturePolicyInfo signaturePolicy) throws IOException, GeneralSecurityException { + Collection crlList, IOcspClient ocspClient, ITSAClient tsaClient, int estimatedSize, + CryptoStandard sigtype, SignaturePolicyInfo signaturePolicy) throws IOException, GeneralSecurityException { signDetached(externalDigest, externalSignature, chain, crlList, ocspClient, tsaClient, estimatedSize, sigtype, signaturePolicy.toSignaturePolicyIdentifier()); } @@ -766,6 +521,7 @@ public void signDetached(IExternalDigest externalDigest, IExternalSignature exte * @param estimatedSize the reserved size for the signature. It will be estimated if 0 * @param sigtype Either Signature.CMS or Signature.CADES * @param signaturePolicy the signature policy (for EPES signatures) + * * @throws IOException if some I/O problem occurs * @throws GeneralSecurityException if some problem during apply security algorithms occurs */ @@ -790,6 +546,7 @@ public void signDetached(IExternalSignature externalSignature, Certificate[] cha * @param estimatedSize the reserved size for the signature. It will be estimated if 0 * @param sigtype Either Signature.CMS or Signature.CADES * @param signaturePolicy the signature policy (for EPES signatures) + * * @throws IOException if some I/O problem occurs * @throws GeneralSecurityException if some problem during apply security algorithms occurs */ @@ -816,25 +573,26 @@ public void signDetached(IExternalSignature externalSignature, Certificate[] cha * @param estimatedSize the reserved size for the signature. It will be estimated if 0 * @param sigtype Either Signature.CMS or Signature.CADES * @param signaturePolicy the signature policy (for EPES signatures) + * * @throws IOException if some I/O problem occurs * @throws GeneralSecurityException if some problem during apply security algorithms occurs */ public void signDetached(IExternalDigest externalDigest, IExternalSignature externalSignature, Certificate[] chain, - Collection crlList, IOcspClient ocspClient, ITSAClient tsaClient, int estimatedSize, - CryptoStandard sigtype, ISignaturePolicyIdentifier signaturePolicy) + Collection crlList, IOcspClient ocspClient, ITSAClient tsaClient, int estimatedSize, + CryptoStandard sigtype, ISignaturePolicyIdentifier signaturePolicy) throws IOException, GeneralSecurityException { if (closed) { throw new PdfException(SignExceptionMessageConstant.THIS_INSTANCE_OF_PDF_SIGNER_ALREADY_CLOSED); } - if (certificationLevel > 0 && isDocumentPdf2()) { + if (this.signerProperties.getCertificationLevel().ordinal() > 0 && isDocumentPdf2()) { if (documentContainsCertificationOrApprovalSignatures()) { throw new PdfException( SignExceptionMessageConstant.CERTIFICATION_SIGNATURE_CREATION_FAILED_DOC_SHALL_NOT_CONTAIN_SIGS); } } - document.checkIsoConformance(sigtype == CryptoStandard.CADES, IsoKey.SIGNATURE_TYPE); + document.checkIsoConformance(new SignTypeValidationContext(sigtype == CryptoStandard.CADES)); Collection crlBytes = null; int i = 0; @@ -854,8 +612,12 @@ public void signDetached(IExternalDigest externalDigest, IExternalSignature exte if (tsaClient != null) { estimatedSize += tsaClient.getTokenSizeEstimate() + 96; } + if (document.getDiContainer().getInstance(IMacContainerLocator.class).isMacContainerLocated()) { + // If MAC container was located, we presume MAC will be embedded and allocate additional space. + estimatedSize += MAXIMUM_MAC_SIZE; + } } - appearance.setCertificate(chain[0]); + this.signerName = PdfSigner.getSignerName((X509Certificate) chain[0]); if (sigtype == CryptoStandard.CADES && !isDocumentPdf2()) { addDeveloperExtension(PdfDeveloperExtension.ESIC_1_7_EXTENSIONLEVEL2); } @@ -866,17 +628,20 @@ public void signDetached(IExternalDigest externalDigest, IExternalSignature exte // the curve is on the ISO/TS 32002 allowed curves list. That responsibility is delegated to the user. } String hashAlgorithm = externalSignature.getDigestAlgorithmName(); - if(hashAlgorithm.startsWith("SHA3-") || hashAlgorithm.equals(DigestAlgorithms.SHAKE256)) { + if (hashAlgorithm.startsWith("SHA3-") || hashAlgorithm.equals(DigestAlgorithms.SHAKE256)) { addDeveloperExtension(PdfDeveloperExtension.ISO_32001); } PdfSignature dic = new PdfSignature(PdfName.Adobe_PPKLite, sigtype == CryptoStandard.CADES ? PdfName.ETSI_CAdES_DETACHED : PdfName.Adbe_pkcs7_detached); - dic.setReason(getReason()); - dic.setLocation(getLocation()); - dic.setSignatureCreator(getSignatureCreator()); - dic.setContact(getContact()); - dic.setDate(new PdfDate(getSignDate())); // time-stamp will over-rule this + dic.setReason(this.signerProperties.getReason()); + dic.setLocation(this.signerProperties.getLocation()); + dic.setSignatureCreator(this.signerProperties.getSignatureCreator()); + dic.setContact(this.signerProperties.getContact()); + Calendar claimedSignDate = this.signerProperties.getClaimedSignDate(); + if (claimedSignDate != TimestampConstants.UNDEFINED_TIMESTAMP_DATE) { + dic.setDate(new PdfDate(claimedSignDate)); // time-stamp will over-rule this + } cryptoDictionary = dic; Map exc = new HashMap<>(); @@ -888,7 +653,7 @@ public void signDetached(IExternalDigest externalDigest, IExternalSignature exte sgn.setSignaturePolicy(signaturePolicy); } InputStream data = getRangeStream(); - byte[] hash = DigestAlgorithms.digest(data, hashAlgorithm, externalDigest); + byte[] hash = DigestAlgorithms.digest(data, SignUtils.getMessageDigest(hashAlgorithm, externalDigest)); List ocspList = new ArrayList<>(); if (chain.length > 1 && ocspClient != null) { for (int j = 0; j < chain.length - 1; ++j) { @@ -908,6 +673,9 @@ public void signDetached(IExternalDigest externalDigest, IExternalSignature exte externalSignature.getSignatureMechanismParameters() ); + document.dispatchEvent(new SignatureContainerGenerationEvent(sgn.getUnsignedAttributes(), extSignature, + getRangeStream())); + byte[] encodedSig = sgn.getEncodedPKCS7(hash, sigtype, tsaClient, ocspList, crlBytes); if (estimatedSize < encodedSig.length) { @@ -933,6 +701,7 @@ public void signDetached(IExternalDigest externalDigest, IExternalSignature exte * * @param externalSignatureContainer the interface providing the actual signing * @param estimatedSize the reserved size for the signature + * * @throws GeneralSecurityException if some problem during apply security algorithms occurs * @throws IOException if some I/O problem occurs */ @@ -945,12 +714,18 @@ public void signExternalContainer(IExternalSignatureContainer externalSignatureC externalSignatureContainer.modifySigningDictionary(dic.getPdfObject()); cryptoDictionary = dic; + if (document.getDiContainer().getInstance(IMacContainerLocator.class).isMacContainerLocated()) { + // If MAC container was located, we presume MAC will be embedded and allocate additional space. + estimatedSize += MAXIMUM_MAC_SIZE; + } + Map exc = new HashMap<>(); exc.put(PdfName.Contents, estimatedSize * 2 + 2); preClose(exc); InputStream data = getRangeStream(); byte[] encodedSig = externalSignatureContainer.sign(data); + encodedSig = embedMacTokenIntoSignatureContainer(encodedSig); if (estimatedSize < encodedSig.length) { throw new IOException(SignExceptionMessageConstant.NOT_ENOUGH_SPACE); @@ -975,6 +750,7 @@ public void signExternalContainer(IExternalSignatureContainer externalSignatureC * @param tsa the timestamp generator * @param signatureName the signature name or null to have a name generated * automatically + * * @throws IOException if some I/O problem occurs or estimation for timestamp signature, * provided with {@link ITSAClient#getTokenSizeEstimate()}, is not big enough * @throws GeneralSecurityException if some problem during apply security algorithms occurs @@ -988,10 +764,14 @@ public void timestamp(ITSAClient tsa, String signatureName) throws IOException, } int contentEstimated = tsa.getTokenSizeEstimate(); + if (document.getDiContainer().getInstance(IMacContainerLocator.class).isMacContainerLocated()) { + // If MAC container was located, we presume MAC will be embedded and allocate additional space. + contentEstimated += MAXIMUM_MAC_SIZE; + } if (!isDocumentPdf2()) { addDeveloperExtension(PdfDeveloperExtension.ESIC_1_7_EXTENSIONLEVEL5); } - setFieldName(signatureName); + this.signerProperties.setFieldName(signatureName); PdfSignature dic = new PdfSignature(PdfName.Adobe_PPKLite, PdfName.ETSI_RFC3161); dic.put(PdfName.Type, PdfName.DocTimeStamp); @@ -1015,6 +795,8 @@ public void timestamp(ITSAClient tsa, String signatureName) throws IOException, throw new GeneralSecurityException(e.getMessage(), e); } + tsToken = embedMacTokenIntoSignatureContainer(tsToken); + if (contentEstimated + 2 < tsToken.length) { throw new IOException(MessageFormatUtil.format( SignExceptionMessageConstant.TOKEN_ESTIMATION_SIZE_IS_NOT_LARGE_ENOUGH, @@ -1039,6 +821,7 @@ public void timestamp(ITSAClient tsa, String signatureName) throws IOException, * @param outs the output PDF * @param externalSignatureContainer the signature container doing the actual signing. Only the * method ExternalSignatureContainer.sign is used + * * @throws IOException if some I/O problem occurs * @throws GeneralSecurityException if some problem during apply security algorithms occurs */ @@ -1054,7 +837,9 @@ public static void signDeferred(PdfDocument document, String fieldName, OutputSt * * @param cert a Certificate if one of the CrlList implementations needs to retrieve the CRL URL from it. * @param crlList a list of CrlClient implementations + * * @return a collection of CRL bytes that can be embedded in a PDF + * * @throws CertificateEncodingException if an encoding error occurs in {@link Certificate}. */ protected Collection processCrl(Certificate cert, Collection crlList) @@ -1073,7 +858,7 @@ protected Collection processCrl(Certificate cert, Collection } crlBytes.addAll(b); } - return crlBytes.size() == 0 ? null : crlBytes; + return crlBytes.isEmpty() ? null : crlBytes; } /** @@ -1105,6 +890,7 @@ protected boolean isPreClosed() { * @param exclusionSizes Map with names and sizes to be excluded in the signature * calculation. The key is a PdfName and the value an Integer. * At least the /Contents must be present + * * @throws IOException on error */ protected void preClose(Map exclusionSizes) throws IOException { @@ -1123,6 +909,8 @@ protected void preClose(Map exclusionSizes) throws IOException } cryptoDictionary.getPdfObject().makeIndirect(document); + document.dispatchEvent( + new SignatureDocumentClosingEvent(cryptoDictionary.getPdfObject().getIndirectReference())); if (fieldExist) { fieldLock = populateExistingSignatureFormField(acroForm); @@ -1141,7 +929,7 @@ protected void preClose(Map exclusionSizes) throws IOException exclusionLocations.put(key, lit); cryptoDictionary.put(key, lit); } - if (certificationLevel > 0) { + if (this.signerProperties.getCertificationLevel().ordinal() > 0) { addDocMDP(cryptoDictionary); } if (fieldLock != null) { @@ -1151,14 +939,14 @@ protected void preClose(Map exclusionSizes) throws IOException signatureEvent.getSignatureDictionary(cryptoDictionary); } - if (certificationLevel > 0) { + if (this.signerProperties.getCertificationLevel().ordinal() > 0) { // add DocMDP entry to root PdfDictionary docmdp = new PdfDictionary(); docmdp.put(PdfName.DocMDP, cryptoDictionary.getPdfObject()); document.getCatalog().put(PdfName.Perms, docmdp); document.getCatalog().setModified(); } - document.checkIsoConformance(cryptoDictionary.getPdfObject(), IsoKey.SIGNATURE); + document.checkIsoConformance(new SignatureValidationContext(cryptoDictionary.getPdfObject())); cryptoDictionary.getPdfObject().flush(false); document.close(); @@ -1181,8 +969,8 @@ protected void preClose(Map exclusionSizes) throws IOException ByteArrayOutputStream bos = new ByteArrayOutputStream(); PdfOutputStream os = new PdfOutputStream(bos); os.write('['); - for (int k = 0; k < range.length; ++k) { - os.writeLong(range[k]).write(' '); + for (long l : range) { + os.writeLong(l).write(' '); } os.write(']'); System.arraycopy(bos.toByteArray(), 0, bout, (int) byteRangePosition, (int) bos.size()); @@ -1194,8 +982,8 @@ protected void preClose(Map exclusionSizes) throws IOException ByteArrayOutputStream bos = new ByteArrayOutputStream(); PdfOutputStream os = new PdfOutputStream(bos); os.write('['); - for (int k = 0; k < range.length; ++k) { - os.writeLong(range[k]).write(' '); + for (long l : range) { + os.writeLong(l).write(' '); } os.write(']'); raf.seek(byteRangePosition); @@ -1214,26 +1002,58 @@ protected void preClose(Map exclusionSizes) throws IOException } } + /** + * Returns final signature appearance object set by + * {@link SignerProperties#setSignatureAppearance(SignatureFieldAppearance)} and + * customized using {@link PdfSigner} properties such as signing date, reason, location and signer name + * in case they weren't specified by the user, or, if none was set, returns a new one with default appearance. + * + *

    + * To customize the appearance of the signature, create new {@link SignatureFieldAppearance} object and set it + * using {@link SignerProperties#setSignatureAppearance(SignatureFieldAppearance)}. + * + *

    + * Note that in case you create new signature field (either use {@link SignerProperties#setFieldName} with the name + * that doesn't exist in the document or don't specify it at all) then the signature is invisible by default. + * + *

    + * It is possible to set other appearance related properties such as + * {@link PdfSignatureFormField#setReuseAppearance}, {@link PdfSignatureFormField#setBackgroundLayer} (n0 layer) and + * {@link PdfSignatureFormField#setSignatureAppearanceLayer} (n2 layer) for the signature field using + * {@link #getSignatureField()}. Page, rectangle and other properties could be set up via {@link SignerProperties}. + * + * @return {@link SignatureFieldAppearance} object representing signature appearance + */ + protected SignatureFieldAppearance getSignatureAppearance() { + if (this.signerProperties.getSignatureAppearance() == null) { + this.signerProperties.setSignatureAppearance(new SignatureFieldAppearance(SignerProperties.IGNORED_ID)); + setContent(); + } else { + populateExistingModelElement(); + } + return this.signerProperties.getSignatureAppearance(); + } + /** * Populates already existing signature form field in the acroForm object. * This method is called during the {@link PdfSigner#preClose(Map)} method if the signature field already exists. * * @param acroForm {@link PdfAcroForm} object in which the signature field will be populated + * * @return signature field lock dictionary - * @throws IOException if font for the appearance dictionary cannot be created */ - protected PdfSigFieldLock populateExistingSignatureFormField(PdfAcroForm acroForm) throws IOException { - PdfSignatureFormField sigField = (PdfSignatureFormField) acroForm.getField(fieldName); + protected PdfSigFieldLock populateExistingSignatureFormField(PdfAcroForm acroForm) { + PdfSignatureFormField sigField = (PdfSignatureFormField) acroForm.getField(this.signerProperties.getFieldName()); PdfSigFieldLock sigFieldLock = sigField.getSigFieldLockDictionary(); - if (sigFieldLock == null && this.fieldLock != null) { - this.fieldLock.getPdfObject().makeIndirect(document); - sigField.put(PdfName.Lock, this.fieldLock.getPdfObject()); - sigFieldLock = this.fieldLock; + if (sigFieldLock == null && this.signerProperties.getFieldLockDict() != null) { + this.signerProperties.getFieldLockDict().getPdfObject().makeIndirect(document); + sigField.put(PdfName.Lock, this.signerProperties.getFieldLockDict().getPdfObject()); + sigFieldLock = this.signerProperties.getFieldLockDict(); } - sigField.put(PdfName.P, document.getPage(getPageNumber()).getPdfObject()); + sigField.put(PdfName.P, document.getPage(this.signerProperties.getPageNumber()).getPdfObject()); sigField.put(PdfName.V, cryptoDictionary.getPdfObject()); PdfObject obj = sigField.getPdfObject().get(PdfName.F); int flags = 0; @@ -1245,18 +1065,8 @@ protected PdfSigFieldLock populateExistingSignatureFormField(PdfAcroForm acroFor flags |= PdfAnnotation.LOCKED; sigField.put(PdfName.F, new PdfNumber(flags)); - sigField.disableFieldRegeneration(); - if (appearance.isReuseAppearanceSet()) { - sigField.setReuseAppearance(appearance.isReuseAppearance()); - } - if (appearance.getSignatureAppearanceLayer() != null) { - sigField.setSignatureAppearanceLayer(appearance.getSignatureAppearanceLayer()); - } - if (appearance.getBackgroundLayer() != null) { - sigField.setBackgroundLayer(appearance.getBackgroundLayer()); - } - sigField.getFirstFormAnnotation().setFormFieldElement(appearance.getSignatureAppearance()); - sigField.enableFieldRegeneration(); + sigField.getFirstFormAnnotation().setFormFieldElement(getSignatureAppearance()); + sigField.regenerateField(); sigField.setModified(); @@ -1269,11 +1079,11 @@ protected PdfSigFieldLock populateExistingSignatureFormField(PdfAcroForm acroFor * * @param acroForm {@link PdfAcroForm} object in which new signature field will be added * @param name the name of the field + * * @return signature field lock dictionary - * @throws IOException if font for the appearance dictionary cannot be created */ - protected PdfSigFieldLock createNewSignatureFormField(PdfAcroForm acroForm, String name) throws IOException { - PdfWidgetAnnotation widget = new PdfWidgetAnnotation(getPageRect()); + protected PdfSigFieldLock createNewSignatureFormField(PdfAcroForm acroForm, String name) { + PdfWidgetAnnotation widget = new PdfWidgetAnnotation(this.signerProperties.getPageRect()); widget.setFlags(PdfAnnotation.PRINT | PdfAnnotation.LOCKED); PdfSignatureFormField sigField = new SignatureFormFieldBuilder(document, name).createSignature(); @@ -1282,19 +1092,16 @@ protected PdfSigFieldLock createNewSignatureFormField(PdfAcroForm acroForm, Stri PdfSigFieldLock sigFieldLock = sigField.getSigFieldLockDictionary(); - if (this.fieldLock != null) { - this.fieldLock.getPdfObject().makeIndirect(document); - sigField.put(PdfName.Lock, this.fieldLock.getPdfObject()); - sigFieldLock = this.fieldLock; + if (this.signerProperties.getFieldLockDict() != null) { + this.signerProperties.getFieldLockDict().getPdfObject().makeIndirect(document); + sigField.put(PdfName.Lock, this.signerProperties.getFieldLockDict().getPdfObject()); + sigFieldLock = this.signerProperties.getFieldLockDict(); } - int pagen = getPageNumber(); + int pagen = this.signerProperties.getPageNumber(); widget.setPage(document.getPage(pagen)); sigField.disableFieldRegeneration(); - sigField.setReuseAppearance(appearance.isReuseAppearance()) - .setSignatureAppearanceLayer(appearance.getSignatureAppearanceLayer()) - .setBackgroundLayer(appearance.getBackgroundLayer()); applyDefaultPropertiesForTheNewField(sigField); sigField.enableFieldRegeneration(); acroForm.addField(sigField, document.getPage(pagen)); @@ -1315,7 +1122,8 @@ protected PdfSigFieldLock createNewSignatureFormField(PdfAcroForm acroForm, Stri * The general sequence is: * {@link #preClose(Map)}, {@link #getRangeStream()} and {@link #close(PdfDictionary)}. * - * @return The {@link InputStream} of bytes to be signed. + * @return the {@link InputStream} of bytes to be signed + * * @throws IOException if some I/O problem occurs */ protected InputStream getRangeStream() throws IOException { @@ -1333,6 +1141,7 @@ protected InputStream getRangeStream() throws IOException { * * @param update a PdfDictionary with the key/value that will fill the holes defined * in {@link #preClose(Map)} + * * @throws IOException on error */ protected void close(PdfDictionary update) throws IOException { @@ -1399,6 +1208,7 @@ protected void close(PdfDictionary update) throws IOException { * Returns the underlying source. * * @return the underlying source + * * @throws IOException if some I/O problem occurs */ protected IRandomAccessSource getUnderlyingSource() throws IOException { @@ -1415,7 +1225,7 @@ protected IRandomAccessSource getUnderlyingSource() throws IOException { protected void addDocMDP(PdfSignature crypto) { PdfDictionary reference = new PdfDictionary(); PdfDictionary transformParams = new PdfDictionary(); - transformParams.put(PdfName.P, new PdfNumber(certificationLevel)); + transformParams.put(PdfName.P, new PdfNumber(this.signerProperties.getCertificationLevel().ordinal())); transformParams.put(PdfName.V, new PdfName("1.2")); transformParams.put(PdfName.Type, PdfName.TransformParams); reference.put(PdfName.TransformMethod, PdfName.DocMDP); @@ -1491,6 +1301,7 @@ protected boolean documentContainsCertificationOrApprovalSignatures() { * Get the rectangle associated to the provided widget. * * @param widget PdfWidgetAnnotation to extract the rectangle from + * * @return Rectangle */ protected Rectangle getWidgetRectangle(PdfWidgetAnnotation widget) { @@ -1501,6 +1312,7 @@ protected Rectangle getWidgetRectangle(PdfWidgetAnnotation widget) { * Get the page number associated to the provided widget. * * @param widget PdfWidgetAnnotation from which to extract the page number + * * @return page number */ protected int getWidgetPageNumber(PdfWidgetAnnotation widget) { @@ -1522,9 +1334,34 @@ protected int getWidgetPageNumber(PdfWidgetAnnotation widget) { return pageNumber; } - private void updateFieldName(String fieldName) { - if (fieldName != null) { - PdfFormField field = acroForm.getField(fieldName); + PdfSignature createSignatureDictionary(boolean includeDate) { + PdfSignature dic = new PdfSignature(); + dic.setReason(this.signerProperties.getReason()); + dic.setLocation(this.signerProperties.getLocation()); + dic.setSignatureCreator(this.signerProperties.getSignatureCreator()); + dic.setContact(this.signerProperties.getContact()); + Calendar claimedSignDate = this.signerProperties.getClaimedSignDate(); + if (includeDate && claimedSignDate != TimestampConstants.UNDEFINED_TIMESTAMP_DATE) { + dic.setDate(new PdfDate(claimedSignDate)); // time-stamp will over-rule this + } + return dic; + } + + private static String getSignerName(X509Certificate certificate) { + String name = null; + CertificateInfo.X500Name x500name = CertificateInfo.getSubjectFields(certificate); + if (x500name != null) { + name = x500name.getField("CN"); + if (name == null) { + name = x500name.getField("E"); + } + } + return name == null? "" : name; + } + + private void updateFieldName() { + if (signerProperties.getFieldName() != null) { + PdfFormField field = acroForm.getField(signerProperties.getFieldName()); if (field != null) { if (!PdfName.Sig.equals(field.getFormType())) { throw new IllegalArgumentException( @@ -1538,40 +1375,63 @@ private void updateFieldName(String fieldName) { List widgets = field.getWidgets(); if (!widgets.isEmpty()) { PdfWidgetAnnotation widget = widgets.get(0); - setPageRect(getWidgetRectangle(widget)); - setPageNumber(getWidgetPageNumber(widget)); + this.signerProperties.setPageRect(getWidgetRectangle(widget)); + this.signerProperties.setPageNumber(getWidgetPageNumber(widget)); } } else { // Do not allow dots for new fields // For existing fields dots are allowed because there it might be fully qualified name - if (fieldName.indexOf('.') >= 0) { + if (signerProperties.getFieldName().indexOf('.') >= 0) { throw new IllegalArgumentException(SignExceptionMessageConstant.FIELD_NAMES_CANNOT_CONTAIN_A_DOT); } } - this.appearance.setFieldName(fieldName); - this.fieldName = fieldName; + } else { + this.signerProperties.setFieldName(getNewSigFieldName()); } } - private boolean isDocumentPdf2() { return document.getPdfVersion().compareTo(PdfVersion.PDF_2_0) >= 0; } - PdfSignature createSignatureDictionary(boolean includeDate) { - PdfSignature dic = new PdfSignature(); - dic.setReason(getReason()); - dic.setLocation(getLocation()); - dic.setSignatureCreator(getSignatureCreator()); - dic.setContact(getContact()); - if (includeDate) { - dic.setDate(new PdfDate(getSignDate())); // time-stamp will over-rule this + protected void applyAccessibilityProperties(PdfFormField formField, IAccessibleElement modelElement, + PdfDocument pdfDocument) { + if (!pdfDocument.isTagged()) { + return; } - return dic; + final AccessibilityProperties properties = modelElement.getAccessibilityProperties(); + final String alternativeDescription = properties.getAlternateDescription(); + if (alternativeDescription != null && !alternativeDescription.isEmpty()) { + formField.setAlternativeName(alternativeDescription); + } + } + + private byte[] embedMacTokenIntoSignatureContainer(byte[] signatureContainer) { + if (document.getDiContainer().getInstance(IMacContainerLocator.class).isMacContainerLocated()) { + try { + CMSContainer cmsContainer = new CMSContainer(signatureContainer); + // If MAC is in the signature already, we regenerate it anyway. + cmsContainer.getSignerInfo().removeUnSignedAttribute(ID_ATTR_PDF_MAC_DATA); + IASN1EncodableVector unsignedVector = FACTORY.createASN1EncodableVector(); + document.dispatchEvent(new SignatureContainerGenerationEvent(unsignedVector, + cmsContainer.getSignerInfo().getSignatureData(), getRangeStream())); + if (FACTORY.createDERSequence(unsignedVector).size() != 0) { + IASN1Sequence sequence = + FACTORY.createASN1Sequence(FACTORY.createDERSequence(unsignedVector).getObjectAt(0)); + cmsContainer.getSignerInfo().addUnSignedAttribute(new CmsAttribute( + FACTORY.createASN1ObjectIdentifier(sequence.getObjectAt(0)).getId(), + sequence.getObjectAt(1).toASN1Primitive())); + return cmsContainer.serialize(); + } + } catch (Exception exception) { + throw new PdfException(SignExceptionMessageConstant.NOT_POSSIBLE_TO_EMBED_MAC_TO_SIGNATURE, exception); + } + } + return signatureContainer; } private void applyDefaultPropertiesForTheNewField(PdfSignatureFormField sigField) { - SignatureFieldAppearance formFieldElement = appearance.getSignatureAppearance(); + SignatureFieldAppearance formFieldElement = getSignatureAppearance(); PdfFormAnnotation annotation = sigField.getFirstFormAnnotation(); annotation.setFormFieldElement(formFieldElement); // Apply default field properties: @@ -1591,11 +1451,57 @@ private void applyDefaultPropertiesForTheNewField(PdfSignatureFormField sigField } BorderStyleUtil.applyBorderProperty(formFieldElement, annotation); Background background = formFieldElement.getProperty(Property.BACKGROUND); + applyAccessibilityProperties(sigField, formFieldElement, document); if (background != null) { sigField.getFirstFormAnnotation().setBackgroundColor(background.getColor()); } } + private void setContent() { + if (this.signerProperties.getPageRect() == null || this.signerProperties.getPageRect().getWidth() == 0 || + this.signerProperties.getPageRect().getHeight() == 0) { + return; + } + this.signerProperties.getSignatureAppearance().setContent(generateSignatureText()); + } + + private SignedAppearanceText generateSignatureText() { + SignedAppearanceText signedAppearanceText = new SignedAppearanceText(); + fillInAppearanceText(signedAppearanceText); + return signedAppearanceText; + } + + private void populateExistingModelElement() { + this.signerProperties.getSignatureAppearance().setSignerName(signerName); + SignedAppearanceText appearanceText = this.signerProperties.getSignatureAppearance().getSignedAppearanceText(); + if (appearanceText != null) { + fillInAppearanceText(appearanceText); + } + } + + private void fillInAppearanceText(SignedAppearanceText appearanceText) { + appearanceText.setSignedBy(signerName); + Calendar claimedSignDate = this.signerProperties.getClaimedSignDate(); + if (claimedSignDate != TimestampConstants.UNDEFINED_TIMESTAMP_DATE) { + appearanceText.setSignDate(claimedSignDate); + } + String reason = signerProperties.getReason(); + boolean setReason = appearanceText.getReasonLine() != null && appearanceText.getReasonLine().isEmpty(); + if (setReason && reason != null && !reason.isEmpty()) { + appearanceText.setReasonLine("Reason: " + reason); + } + String location = signerProperties.getLocation(); + boolean setLocation = appearanceText.getLocationLine() != null && appearanceText.getLocationLine().isEmpty(); + if (setLocation && location != null && !location.isEmpty()) { + appearanceText.setLocationLine("Location: " + location); + } + } + + private String getFieldName() { + updateFieldName(); + return signerProperties.getFieldName(); + } + /** * An interface to retrieve the signature dictionary for modification. */ @@ -1632,7 +1538,7 @@ public void apply(ISignatureDataProvider signatureDataProvider) throws IOExcepti } if (!signatureUtil.signatureCoversWholeDocument(fieldName)) { throw new PdfException( - SignExceptionMessageConstant.SIGNATURE_WITH_THIS_NAME_IS_NOT_THE_LAST_IT_DOES_NOT_COVER_WHOLE_DOCUMENT + SignExceptionMessageConstant.SIGNATURE_WITH_THIS_NAME_IS_NOT_THE_LAST_IT_DOES_NOT_COVER_WHOLE_DOCUMENT ).setMessageParams(fieldName); } @@ -1675,4 +1581,20 @@ public InputStream getDataToSign() throws IOException { interface ISignatureDataProvider { byte[] sign(SignatureApplier applier) throws GeneralSecurityException, IOException; } + + private static class PdfSignerDocument extends PdfDocument { + public PdfSignerDocument(PdfReader reader, PdfWriter writer, StampingProperties properties) { + super(reader, writer, properties); + if (getConformance().isPdfA()) { + PdfAChecker checker = PdfADocument.getCorrectCheckerFromConformance(getConformance().getAConformance()); + ValidationContainer validationContainer = new ValidationContainer(); + validationContainer.addChecker(checker); + getDiContainer().register(ValidationContainer.class, validationContainer); + this.pdfPageFactory = new PdfAPageFactory(checker); + this.documentInfoHelper = new PdfADocumentInfoHelper(this); + this.defaultFontStrategy = new PdfADefaultFontStrategy(this); + setFlushUnusedObjects(true); + } + } + } } diff --git a/sign/src/main/java/com/itextpdf/signatures/PdfTwoPhaseSigner.java b/sign/src/main/java/com/itextpdf/signatures/PdfTwoPhaseSigner.java index de9671a752..29297e2772 100644 --- a/sign/src/main/java/com/itextpdf/signatures/PdfTwoPhaseSigner.java +++ b/sign/src/main/java/com/itextpdf/signatures/PdfTwoPhaseSigner.java @@ -22,7 +22,9 @@ This file is part of the iText (R) project. */ package com.itextpdf.signatures; +import com.itextpdf.kernel.crypto.DigestAlgorithms; import com.itextpdf.kernel.exceptions.PdfException; +import com.itextpdf.kernel.mac.IMacContainerLocator; import com.itextpdf.kernel.pdf.PdfDeveloperExtension; import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.kernel.pdf.PdfDocument; @@ -88,42 +90,14 @@ public PdfTwoPhaseSigner(PdfReader reader, OutputStream outputStream) { public byte[] prepareDocumentForSignature(SignerProperties signerProperties, String digestAlgorithm, PdfName filter, PdfName subFilter, int estimatedSize, boolean includeDate) throws IOException, GeneralSecurityException { - if (closed) { - throw new PdfException(SignExceptionMessageConstant.THIS_INSTANCE_OF_PDF_SIGNER_ALREADY_CLOSED); - } - PdfSigner pdfSigner = createPdfSigner(signerProperties); - - PdfDocument document = pdfSigner.getDocument(); - if (document.getPdfVersion().compareTo(PdfVersion.PDF_2_0) < 0) { - document.getCatalog().addDeveloperExtension(PdfDeveloperExtension.ESIC_1_7_EXTENSIONLEVEL2); - } - document.getCatalog().addDeveloperExtension(PdfDeveloperExtension.ISO_32002); - document.getCatalog().addDeveloperExtension(PdfDeveloperExtension.ISO_32001); - - PdfSignature cryptoDictionary = pdfSigner.createSignatureDictionary(includeDate); - cryptoDictionary.put(PdfName.Filter, filter); - cryptoDictionary.put(PdfName.SubFilter, subFilter); - pdfSigner.cryptoDictionary = cryptoDictionary; - - Map exc = new HashMap<>(); - exc.put(PdfName.Contents, estimatedSize * 2 + 2); - pdfSigner.preClose(exc); - - InputStream data = pdfSigner.getRangeStream(); - byte[] digest; + MessageDigest digest; if (externalDigest != null) { - digest = DigestAlgorithms.digest(data, digestAlgorithm, externalDigest); + digest = externalDigest.getMessageDigest(digestAlgorithm); } else { - digest = DigestAlgorithms.digest(data, SignUtils.getMessageDigest(digestAlgorithm)); + digest = SignUtils.getMessageDigest(digestAlgorithm); } - byte[] paddedSig = new byte[estimatedSize]; - - PdfDictionary dic2 = new PdfDictionary(); - dic2.put(PdfName.Contents, new PdfString(paddedSig).setHexWriting(true)); - pdfSigner.close(dic2); - pdfSigner.closed = true; - closed = true; - return digest; + return prepareDocumentForSignature(signerProperties, digest, filter, subFilter, + estimatedSize, includeDate); } /** @@ -191,4 +165,46 @@ PdfSigner createPdfSigner(SignerProperties signerProperties) throws IOException return new PdfSigner(reader, outputStream, null, stampingProperties, signerProperties); } + private byte[] prepareDocumentForSignature(SignerProperties signerProperties, MessageDigest messageDigest, + PdfName filter, PdfName subFilter, int estimatedSize, + boolean includeDate) throws IOException { + if (closed) { + throw new PdfException(SignExceptionMessageConstant.THIS_INSTANCE_OF_PDF_SIGNER_ALREADY_CLOSED); + } + PdfSigner pdfSigner = createPdfSigner(signerProperties); + + + PdfDocument document = pdfSigner.getDocument(); + if (document.getDiContainer().getInstance(IMacContainerLocator.class).isMacContainerLocated()) { + throw new PdfException(SignExceptionMessageConstant.NOT_POSSIBLE_TO_EMBED_MAC_TO_SIGNATURE); + } + if (document.getPdfVersion().compareTo(PdfVersion.PDF_2_0) < 0) { + document.getCatalog().addDeveloperExtension(PdfDeveloperExtension.ESIC_1_7_EXTENSIONLEVEL2); + } + document.getCatalog().addDeveloperExtension(PdfDeveloperExtension.ISO_32002); + document.getCatalog().addDeveloperExtension(PdfDeveloperExtension.ISO_32001); + + + + PdfSignature cryptoDictionary = pdfSigner.createSignatureDictionary(includeDate); + cryptoDictionary.put(PdfName.Filter, filter); + cryptoDictionary.put(PdfName.SubFilter, subFilter); + pdfSigner.cryptoDictionary = cryptoDictionary; + + Map exc = new HashMap<>(); + exc.put(PdfName.Contents, estimatedSize * 2 + 2); + pdfSigner.preClose(exc); + + InputStream data = pdfSigner.getRangeStream(); + byte[] digest = DigestAlgorithms.digest(data, messageDigest); + byte[] paddedSig = new byte[estimatedSize]; + + PdfDictionary dic2 = new PdfDictionary(); + dic2.put(PdfName.Contents, new PdfString(paddedSig).setHexWriting(true)); + pdfSigner.close(dic2); + pdfSigner.closed = true; + closed = true; + return digest; + } + } diff --git a/sign/src/main/java/com/itextpdf/signatures/PrivateKeySignature.java b/sign/src/main/java/com/itextpdf/signatures/PrivateKeySignature.java index ddfbf6b690..ebe920c836 100644 --- a/sign/src/main/java/com/itextpdf/signatures/PrivateKeySignature.java +++ b/sign/src/main/java/com/itextpdf/signatures/PrivateKeySignature.java @@ -23,6 +23,8 @@ This file is part of the iText (R) project. package com.itextpdf.signatures; import com.itextpdf.commons.utils.MessageFormatUtil; +import com.itextpdf.kernel.crypto.DigestAlgorithms; +import com.itextpdf.kernel.crypto.OID; import com.itextpdf.kernel.exceptions.PdfException; import com.itextpdf.signatures.exceptions.SignExceptionMessageConstant; @@ -100,14 +102,14 @@ public PrivateKeySignature(PrivateKey pk, String hashAlgorithm, String signature switch (this.signatureAlgorithm) { case "Ed25519": - if (!SecurityIDs.ID_SHA512.equals(digestAlgorithmOid)) { + if (!OID.SHA_512.equals(digestAlgorithmOid)) { throw new PdfException(SignExceptionMessageConstant.ALGO_REQUIRES_SPECIFIC_HASH) .setMessageParams("Ed25519", "SHA-512", this.hashAlgorithm); } this.parameters = null; break; case "Ed448": - if (!SecurityIDs.ID_SHAKE256.equals(digestAlgorithmOid)) { + if (!OID.SHAKE_256.equals(digestAlgorithmOid)) { throw new PdfException(SignExceptionMessageConstant.ALGO_REQUIRES_SPECIFIC_HASH) .setMessageParams("Ed448", "512-bit SHAKE256", this.hashAlgorithm); } diff --git a/sign/src/main/java/com/itextpdf/signatures/ProviderDigest.java b/sign/src/main/java/com/itextpdf/signatures/ProviderDigest.java index 36525545fc..949a891c85 100644 --- a/sign/src/main/java/com/itextpdf/signatures/ProviderDigest.java +++ b/sign/src/main/java/com/itextpdf/signatures/ProviderDigest.java @@ -22,6 +22,8 @@ This file is part of the iText (R) project. */ package com.itextpdf.signatures; +import com.itextpdf.kernel.crypto.DigestAlgorithms; + import java.security.GeneralSecurityException; import java.security.MessageDigest; diff --git a/sign/src/main/java/com/itextpdf/signatures/RSASSAPSSMechanismParams.java b/sign/src/main/java/com/itextpdf/signatures/RSASSAPSSMechanismParams.java index c641b36971..e0182a18aa 100644 --- a/sign/src/main/java/com/itextpdf/signatures/RSASSAPSSMechanismParams.java +++ b/sign/src/main/java/com/itextpdf/signatures/RSASSAPSSMechanismParams.java @@ -26,6 +26,7 @@ This file is part of the iText (R) project. import com.itextpdf.commons.bouncycastle.IBouncyCastleFactory; import com.itextpdf.commons.bouncycastle.asn1.IASN1Encodable; import com.itextpdf.commons.bouncycastle.asn1.IASN1ObjectIdentifier; +import com.itextpdf.kernel.crypto.DigestAlgorithms; import com.itextpdf.kernel.exceptions.PdfException; import java.security.InvalidAlgorithmParameterException; diff --git a/sign/src/main/java/com/itextpdf/signatures/RootStoreVerifier.java b/sign/src/main/java/com/itextpdf/signatures/RootStoreVerifier.java index 28850160fd..929ced3873 100644 --- a/sign/src/main/java/com/itextpdf/signatures/RootStoreVerifier.java +++ b/sign/src/main/java/com/itextpdf/signatures/RootStoreVerifier.java @@ -34,7 +34,7 @@ This file is part of the iText (R) project. * containing trusted anchors. * * @deprecated starting from 8.0.5. - * {@link com.itextpdf.signatures.validation.v1.CertificateChainValidator} should be used instead. + * {@link com.itextpdf.signatures.validation.CertificateChainValidator} should be used instead. */ @Deprecated public class RootStoreVerifier extends CertificateVerifier { diff --git a/sign/src/main/java/com/itextpdf/signatures/SecurityIDs.java b/sign/src/main/java/com/itextpdf/signatures/SecurityIDs.java deleted file mode 100644 index 5759652e2e..0000000000 --- a/sign/src/main/java/com/itextpdf/signatures/SecurityIDs.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - This file is part of the iText (R) project. - Copyright (c) 1998-2024 Apryse Group NV - Authors: Apryse Software. - - This program is offered under a commercial and under the AGPL license. - For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. - - AGPL licensing: - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . - */ -package com.itextpdf.signatures; - -/** - * A list of IDs that are used by the security classes - */ -public class SecurityIDs { - - public static final String ID_PKCS7_DATA = "1.2.840.113549.1.7.1"; - public static final String ID_PKCS7_SIGNED_DATA = "1.2.840.113549.1.7.2"; - public static final String ID_RSA = "1.2.840.113549.1.1.1"; - public static final String ID_RSASSA_PSS = "1.2.840.113549.1.1.10"; - public static final String ID_RSA_WITH_SHA256 = "1.2.840.113549.1.1.11"; - public static final String ID_RSA_WITH_SHA3_512 = "2.16.840.1.101.3.4.3.16"; - public static final String ID_DSA = "1.2.840.10040.4.1"; - public static final String ID_ECDSA = "1.2.840.10045.2.1"; - public static final String ID_ED25519 = "1.3.101.112"; - public static final String ID_ED448 = "1.3.101.113"; - public static final String ID_SHA256 = "2.16.840.1.101.3.4.2.1"; - public static final String ID_SHA384 = "2.16.840.1.101.3.4.2.2"; - public static final String ID_SHA512 = "2.16.840.1.101.3.4.2.3"; - public static final String ID_SHAKE256 = "2.16.840.1.101.3.4.2.12"; - public static final String ID_CONTENT_TYPE = "1.2.840.113549.1.9.3"; - public static final String ID_MESSAGE_DIGEST = "1.2.840.113549.1.9.4"; - public static final String ID_SIGNING_TIME = "1.2.840.113549.1.9.5"; - public static final String ID_ADBE_REVOCATION = "1.2.840.113583.1.1.8"; - public static final String ID_TSA = "1.2.840.113583.1.1.9.1"; - public static final String ID_OCSP = "1.3.6.1.5.5.7.48.1"; - public static final String ID_CA_ISSUERS = "1.3.6.1.5.5.7.48.2"; - public static final String ID_AA_SIGNING_CERTIFICATE_V1 = "1.2.840.113549.1.9.16.2.12"; - public static final String ID_AA_SIGNING_CERTIFICATE_V2 = "1.2.840.113549.1.9.16.2.47"; - public static final String ID_MGF1 = "1.2.840.113549.1.1.8"; - public static final String ID_AA_TIME_STAMP_TOKEN = "1.2.840.113549.1.9.16.2.14"; - public static final String ID_RI_OCSP_RESPONSE = "1.3.6.1.5.5.7.16.2"; -} diff --git a/sign/src/main/java/com/itextpdf/signatures/SignUtils.java b/sign/src/main/java/com/itextpdf/signatures/SignUtils.java index 81e4512fa0..24d22b75c7 100644 --- a/sign/src/main/java/com/itextpdf/signatures/SignUtils.java +++ b/sign/src/main/java/com/itextpdf/signatures/SignUtils.java @@ -75,8 +75,8 @@ This file is part of the iText (R) project. import java.security.cert.CertificateEncodingException; import java.security.cert.CertificateException; import java.security.cert.CertificateFactory; -import java.security.cert.X509Certificate; import java.security.cert.X509CRL; +import java.security.cert.X509Certificate; import java.security.spec.MGF1ParameterSpec; import java.security.spec.PSSParameterSpec; import java.text.ParseException; @@ -130,15 +130,6 @@ static MessageDigest getMessageDigest(String hashAlgorithm, IExternalDigest exte return externalDigest.getMessageDigest(hashAlgorithm); } - static MessageDigest getMessageDigest(String hashAlgorithm, String provider) - throws NoSuchAlgorithmException, NoSuchProviderException { - if (provider == null || provider.startsWith("SunPKCS11") || provider.startsWith("SunMSCAPI")) { - return MessageDigest.getInstance(DigestAlgorithms.normalizeDigestName(hashAlgorithm)); - } else { - return MessageDigest.getInstance(hashAlgorithm, provider); - } - } - static InputStream getHttpResponse(URL urlt) throws IOException { HttpURLConnection con = (HttpURLConnection) urlt.openConnection(); if (con.getResponseCode() / 100 != 2) { @@ -306,38 +297,6 @@ static TsaResponse getTsaResponseForUserRequest(String tsaUrl, byte[] requestByt return response; } - /** - * Check if the provided certificate has a critical extension that iText doesn't support. - * - * @param cert X509Certificate instance to check - * @return true if there are unsupported critical extensions, false if there are none - * @deprecated this behavior is different in Java and .NET, because in Java we use this - * two-step check: first via #hasUnsupportedCriticalExtension method, and then additionally allowing - * standard critical extensions; in .NET there's only second step. However, removing - * first step in Java can be a breaking change for some users and moreover we don't - * have any means of providing customization for unsupported extensions check as of right now. - *

    - * During major release I'd suggest changing java unsupported extensions check logic to the same as in .NET, - * but only if it is possible to customize this logic. - */ - // TODO DEVSIX-2634 - @Deprecated - static boolean hasUnsupportedCriticalExtension(X509Certificate cert) { - if (cert == null) { - throw new IllegalArgumentException("X509Certificate can't be null."); - } - if (cert.hasUnsupportedCriticalExtension()) { - for (String oid : cert.getCriticalExtensionOIDs()) { - if (OID.X509Extensions.SUPPORTED_CRITICAL_EXTENSIONS.contains(oid)) { - continue; - } - return true; - } - } - - return false; - } - static Calendar getTimeStampDate(ITSTInfo timeStampTokenInfo) { GregorianCalendar calendar = new GregorianCalendar(); try { diff --git a/sign/src/main/java/com/itextpdf/signatures/SignatureMechanisms.java b/sign/src/main/java/com/itextpdf/signatures/SignatureMechanisms.java index d498a96606..9f4ba994ed 100644 --- a/sign/src/main/java/com/itextpdf/signatures/SignatureMechanisms.java +++ b/sign/src/main/java/com/itextpdf/signatures/SignatureMechanisms.java @@ -24,7 +24,8 @@ This file is part of the iText (R) project. import com.itextpdf.bouncycastleconnector.BouncyCastleFactoryCreator; import com.itextpdf.commons.bouncycastle.IBouncyCastleFactory; -import com.itextpdf.signatures.logs.SignLogMessageConstant; +import com.itextpdf.kernel.crypto.OID; +import com.itextpdf.kernel.logs.KernelLogMessageConstant; import java.util.HashMap; import java.util.Map; @@ -104,11 +105,11 @@ public class SignatureMechanisms { * the digest is required to be specified in the algorithm params anyway, * and the OID does not depend on the digest. BouncyCastle accepts both. */ - algorithmNames.put(SecurityIDs.ID_RSASSA_PSS, "RSASSA-PSS"); + algorithmNames.put(OID.RSASSA_PSS, "RSASSA-PSS"); // EdDSA - algorithmNames.put(SecurityIDs.ID_ED25519, "Ed25519"); - algorithmNames.put(SecurityIDs.ID_ED448, "Ed448"); + algorithmNames.put(OID.ED25519, "Ed25519"); + algorithmNames.put(OID.ED448, "Ed448"); rsaOidsByDigest.put("SHA224", "1.2.840.113549.1.1.14"); rsaOidsByDigest.put("SHA256", "1.2.840.113549.1.1.11"); @@ -155,7 +156,7 @@ public static String getSignatureMechanismOid(String signatureAlgorithmName, Str switch (signatureAlgorithmName) { case "RSA": final String oId = rsaOidsByDigest.get(digestAlgorithmName); - resultingOId = oId == null ? SecurityIDs.ID_RSA : oId; + resultingOId = oId == null ? OID.RSA : oId; break; case "DSA": resultingOId = dsaOidsByDigest.get(digestAlgorithmName); @@ -164,14 +165,14 @@ public static String getSignatureMechanismOid(String signatureAlgorithmName, Str resultingOId = ecdsaOidsByDigest.get(digestAlgorithmName); break; case "Ed25519": - resultingOId = SecurityIDs.ID_ED25519; + resultingOId = OID.ED25519; break; case "Ed448": - resultingOId = SecurityIDs.ID_ED448; + resultingOId = OID.ED448; break; case "RSASSA-PSS": case "RSA/PSS": - resultingOId = SecurityIDs.ID_RSASSA_PSS; + resultingOId = OID.RSASSA_PSS; break; default: resultingOId = null; @@ -179,7 +180,7 @@ public static String getSignatureMechanismOid(String signatureAlgorithmName, Str if (resultingOId != null) { return resultingOId; } - LOGGER.warn(SignLogMessageConstant.ALGORITHM_NOT_FROM_SPEC); + LOGGER.warn(KernelLogMessageConstant.ALGORITHM_NOT_FROM_SPEC); resultingOId = BOUNCY_CASTLE_FACTORY.getAlgorithmOid(digestAlgorithmName + "with" + signatureAlgorithmName); if (resultingOId == null) { return BOUNCY_CASTLE_FACTORY.getAlgorithmOid(signatureAlgorithmName); @@ -215,7 +216,7 @@ public static String getMechanism(String oid, String digest) { if (!algorithm.equals(oid)) { return digest + "with" + algorithm; } - LOGGER.warn(SignLogMessageConstant.ALGORITHM_NOT_FROM_SPEC); + LOGGER.warn(KernelLogMessageConstant.ALGORITHM_NOT_FROM_SPEC); return BOUNCY_CASTLE_FACTORY.getAlgorithmName(oid); } } diff --git a/sign/src/main/java/com/itextpdf/signatures/SignaturePolicyInfo.java b/sign/src/main/java/com/itextpdf/signatures/SignaturePolicyInfo.java index ea3c2aaca0..077e648150 100644 --- a/sign/src/main/java/com/itextpdf/signatures/SignaturePolicyInfo.java +++ b/sign/src/main/java/com/itextpdf/signatures/SignaturePolicyInfo.java @@ -30,6 +30,7 @@ This file is part of the iText (R) project. import com.itextpdf.commons.bouncycastle.asn1.esf.ISignaturePolicyId; import com.itextpdf.commons.bouncycastle.asn1.esf.ISignaturePolicyIdentifier; import com.itextpdf.commons.utils.Base64; +import com.itextpdf.kernel.crypto.DigestAlgorithms; /** * Class that encapsulates the signature policy information diff --git a/sign/src/main/java/com/itextpdf/signatures/SignatureUtil.java b/sign/src/main/java/com/itextpdf/signatures/SignatureUtil.java index 4a3137fa64..09aec85c63 100644 --- a/sign/src/main/java/com/itextpdf/signatures/SignatureUtil.java +++ b/sign/src/main/java/com/itextpdf/signatures/SignatureUtil.java @@ -46,6 +46,7 @@ This file is part of the iText (R) project. import java.io.IOException; import java.io.InputStream; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -406,7 +407,6 @@ public int compare(Object[] o1, Object[] o2) { } private static class ContentsChecker extends PdfReader { - public static final int OBJECT_HEADER_OFFSET = 6; private long rangeExclusionStart; private long rangeExlusionEnd; @@ -417,8 +417,7 @@ private static class ContentsChecker extends PdfReader { private boolean rangeIsCorrect = false; - - public ContentsChecker(IRandomAccessSource byteSource, PdfDocument doc ) throws IOException { + public ContentsChecker(IRandomAccessSource byteSource, PdfDocument doc) throws IOException { super(byteSource, null); pdfDocument = doc; } @@ -427,9 +426,27 @@ public boolean checkWhetherSignatureCoversWholeDocument(PdfFormField signatureFi rangeIsCorrect = false; PdfDictionary signature = (PdfDictionary) signatureField.getValue(); int[] byteRange = ((PdfArray) signature.get(PdfName.ByteRange)).toIntArray(); - if (4 != byteRange.length || 0 != byteRange[0] - || tokens.getSafeFile().length() != byteRange[2] + byteRange[3]) { + if (4 != byteRange.length || 0 != byteRange[0]) { + return false; + } + if (tokens.getSafeFile().length() < byteRange[2] + byteRange[3]) { return false; + } else { + // We allow up to 4 EOL bytes to not be included into byte range. + tokens.seek(byteRange[2] + byteRange[3]); + try { + String remainingBytes = tokens.readString(5); + if (remainingBytes.length() > 4) { + return false; + } + for (byte b : remainingBytes.getBytes(StandardCharsets.UTF_8)) { + if (b != '\n' && b != '\r') { + return false; + } + } + } catch (IOException e) { + return false; + } } rangeExclusionStart = byteRange[1]; diff --git a/sign/src/main/java/com/itextpdf/signatures/SignerProperties.java b/sign/src/main/java/com/itextpdf/signatures/SignerProperties.java index 90a051ff00..465a3c9a5d 100644 --- a/sign/src/main/java/com/itextpdf/signatures/SignerProperties.java +++ b/sign/src/main/java/com/itextpdf/signatures/SignerProperties.java @@ -24,6 +24,8 @@ This file is part of the iText (R) project. import com.itextpdf.commons.utils.DateTimeUtil; import com.itextpdf.forms.PdfSigFieldLock; +import com.itextpdf.forms.fields.PdfSignatureFormField; +import com.itextpdf.forms.fields.properties.SignedAppearanceText; import com.itextpdf.forms.form.element.SignatureFieldAppearance; import com.itextpdf.kernel.geom.Rectangle; @@ -33,11 +35,18 @@ This file is part of the iText (R) project. * Properties to be used in signing operations. */ public class SignerProperties { + /** + * This string could be used to create the {@link SignatureFieldAppearance} instance which will be used for signing + * since its ID will be ignored anyway in that case, and specified ID won't override the field name. + * + * @see #setSignatureAppearance(SignatureFieldAppearance) + */ + public static final String IGNORED_ID = ""; private PdfSigFieldLock fieldLock; private SignatureFieldAppearance appearance; private Calendar signDate = DateTimeUtil.getCurrentTimeCalendar(); - private int certificationLevel = PdfSigner.NOT_CERTIFIED; + private AccessPermissions certificationLevel = AccessPermissions.UNSPECIFIED; private String fieldName; private int pageNumber = 1; private Rectangle pageRect = new Rectangle(0, 0); @@ -56,31 +65,50 @@ public SignerProperties() { /** * Gets the signature date. * - * @return Calendar set to the signature date. + * @return calendar set to the signature date */ - public java.util.Calendar getSignDate() { + public java.util.Calendar getClaimedSignDate() { return signDate; } /** * Sets the signature date. * - * @param signDate the signature date. + * @param signDate the signature date * - * @return this instance to support fluent interface. + * @return this instance to support fluent interface */ - public SignerProperties setSignDate(java.util.Calendar signDate) { + public SignerProperties setClaimedSignDate(java.util.Calendar signDate) { this.signDate = signDate; return this; } /** - * Sets the signature field layout element to customize the appearance of the signature. Signer's sign date will - * be set. + * Sets the signature field layout element to customize the appearance of the signature. + * ID specified for {@link SignatureFieldAppearance} will be ignored and won't override field name, so + * {@link #IGNORED_ID} could be used. To specify signature name use {@link SignerProperties#setFieldName}. * - * @param appearance the {@link SignatureFieldAppearance} layout element. + *

    + * Note that if {@link SignedAppearanceText} was set as the content (or part of the content) + * for {@link SignatureFieldAppearance} object, {@link PdfSigner} properties such as signing date, reason, location + * and signer name could be set automatically. * - * @return this instance to support fluent interface. + *

    + * In case you create new signature field (either using {@link SignerProperties#setFieldName} with the name + * that doesn't exist in the document or do not specifying it at all) then the signature is invisible by default. + * Use {@link SignerProperties#setPageRect(Rectangle)} and {@link SignerProperties#setPageNumber(int)} to provide + * the rectangle that represent the position and dimension of the signature field in the specified page. + * + *

    + * It is possible to set other appearance related properties such as + * {@link PdfSignatureFormField#setReuseAppearance}, {@link PdfSignatureFormField#setBackgroundLayer} (n0 layer) and + * {@link PdfSignatureFormField#setSignatureAppearanceLayer} (n2 layer) for the signature field using + * {@link PdfSigner#getSignatureField()}. Page, rectangle and other properties could be also set up via + * {@link SignerProperties}. + * + * @param appearance the {@link SignatureFieldAppearance} layout element representing signature appearance + * + * @return this instance to support fluent interface */ public SignerProperties setSignatureAppearance(SignatureFieldAppearance appearance) { this.appearance = appearance; @@ -88,9 +116,13 @@ public SignerProperties setSignatureAppearance(SignatureFieldAppearance appearan } /** - * Gets signature field layout element, which customizes the appearance of a signature. + * Gets signature field appearance object representing the appearance of the signature. * - * @return {@link SignatureFieldAppearance} layout element. + *

    + * To customize the signature appearance, create new {@link SignatureFieldAppearance} object and set it + * using {@link SignerProperties#setSignatureAppearance(SignatureFieldAppearance)}. + * + * @return {@link SignatureFieldAppearance} object representing signature appearance */ public SignatureFieldAppearance getSignatureAppearance() { return this.appearance; @@ -98,36 +130,30 @@ public SignatureFieldAppearance getSignatureAppearance() { /** * Returns the document's certification level. - * For possible values see {@link #setCertificationLevel(int)}. + * For possible values see {@link AccessPermissions}. * - * @return The certified status. + * @return {@link AccessPermissions} enum which specifies which certification level shall be used */ - public int getCertificationLevel() { + public AccessPermissions getCertificationLevel() { return this.certificationLevel; } /** * Sets the document's certification level. * - * @param certificationLevel a new certification level for a document. - * Possible values are:

      - *
    • {@link PdfSigner#NOT_CERTIFIED} - *
    • {@link PdfSigner#CERTIFIED_NO_CHANGES_ALLOWED} - *
    • {@link PdfSigner#CERTIFIED_FORM_FILLING} - *
    • {@link PdfSigner#CERTIFIED_FORM_FILLING_AND_ANNOTATIONS} - *
    + * @param accessPermissions {@link AccessPermissions} enum which specifies which certification level shall be used * - * @return this instance to support fluent interface. + * @return this instance to support fluent interface */ - public SignerProperties setCertificationLevel(int certificationLevel) { - this.certificationLevel = certificationLevel; + public SignerProperties setCertificationLevel(AccessPermissions accessPermissions) { + this.certificationLevel = accessPermissions; return this; } /** * Gets the field name. * - * @return the field name. + * @return the field name */ public String getFieldName() { return fieldName; @@ -137,35 +163,36 @@ public String getFieldName() { * Sets the name indicating the field to be signed. The field can already be presented in the * document but shall not be signed. If the field is not presented in the document, it will be created. * - * @param fieldName The name indicating the field to be signed. + *

    + * Note that ID specified for {@link SignatureFieldAppearance} set by {@link #setSignatureAppearance} will be + * ignored and won't override the field name. + * + * @param fieldName the name indicating the field to be signed * - * @return this instance to support fluent interface. + * @return this instance to support fluent interface */ public SignerProperties setFieldName(String fieldName) { - this.fieldName = fieldName; + if (fieldName != null) { + this.fieldName = fieldName; + } return this; } /** - * Provides the page number of the signature field which this signature - * appearance is associated with. + * Provides the page number of the signature field which this signature appearance is associated with. * - * @return The page number of the signature field which this signature - * appearance is associated with. + * @return the page number of the signature field which this signature appearance is associated with */ public int getPageNumber() { return this.pageNumber; } /** - * Sets the page number of the signature field which this signature - * appearance is associated with. Implicitly calls {@link PdfSigner#setPageRect} - * which considers page number to process the rectangle correctly. + * Sets the page number of the signature field which this signature appearance is associated with. * - * @param pageNumber The page number of the signature field which - * this signature appearance is associated with. + * @param pageNumber the page number of the signature field which this signature appearance is associated with * - * @return this instance to support fluent interface. + * @return this instance to support fluent interface */ public SignerProperties setPageNumber(int pageNumber) { this.pageNumber = pageNumber; @@ -173,24 +200,20 @@ public SignerProperties setPageNumber(int pageNumber) { } /** - * Provides the rectangle that represent the position and dimension - * of the signature field in the page. + * Provides the rectangle that represent the position and dimension of the signature field in the page. * - * @return the rectangle that represent the position and dimension - * of the signature field in the page + * @return the rectangle that represent the position and dimension of the signature field in the page */ public Rectangle getPageRect() { return this.pageRect; } /** - * Sets the rectangle that represent the position and dimension of - * the signature field in the page. + * Sets the rectangle that represent the position and dimension of the signature field in the page. * - * @param pageRect The rectangle that represents the position and - * dimension of the signature field in the page. + * @param pageRect the rectangle that represents the position and dimension of the signature field in the page * - * @return this instance to support fluent interface. + * @return this instance to support fluent interface */ public SignerProperties setPageRect(Rectangle pageRect) { this.pageRect = pageRect; @@ -200,7 +223,7 @@ public SignerProperties setPageRect(Rectangle pageRect) { /** * Getter for the field lock dictionary. * - * @return Field lock dictionary. + * @return field lock dictionary */ public PdfSigFieldLock getFieldLockDict() { return fieldLock; @@ -212,9 +235,9 @@ public PdfSigFieldLock getFieldLockDict() { * Be aware: if a signature is created on an existing signature field, * then its /Lock dictionary takes the precedence (if it exists). * - * @param fieldLock Field lock dictionary. + * @param fieldLock field lock dictionary * - * @return this instance to support fluent interface. + * @return this instance to support fluent interface */ public SignerProperties setFieldLockDict(PdfSigFieldLock fieldLock) { this.fieldLock = fieldLock; @@ -224,7 +247,7 @@ public SignerProperties setFieldLockDict(PdfSigFieldLock fieldLock) { /** * Returns the signature creator. * - * @return The signature creator. + * @return the signature creator */ public String getSignatureCreator() { return this.signatureCreator; @@ -245,7 +268,7 @@ public SignerProperties setSignatureCreator(String signatureCreator) { /** * Returns the signing contact. * - * @return The signing contact. + * @return the signing contact */ public String getContact() { return this.contact; @@ -254,9 +277,9 @@ public String getContact() { /** * Sets the signing contact. * - * @param contact A new signing contact. + * @param contact a new signing contact * - * @return this instance to support fluent interface. + * @return this instance to support fluent interface */ public SignerProperties setContact(String contact) { this.contact = contact; @@ -266,7 +289,7 @@ public SignerProperties setContact(String contact) { /** * Returns the signing reason. * - * @return The signing reason. + * @return the signing reason */ public String getReason() { return this.reason; @@ -275,9 +298,9 @@ public String getReason() { /** * Sets the signing reason. * - * @param reason A new signing reason. + * @param reason a new signing reason * - * @return this instance to support fluent interface. + * @return this instance to support fluent interface */ public SignerProperties setReason(String reason) { this.reason = reason; @@ -287,7 +310,7 @@ public SignerProperties setReason(String reason) { /** * Returns the signing location. * - * @return The signing location. + * @return the signing location */ public String getLocation() { return this.location; @@ -296,9 +319,9 @@ public String getLocation() { /** * Sets the signing location. * - * @param location A new signing location. + * @param location a new signing location * - * @return this instance to support fluent interface. + * @return this instance to support fluent interface */ public SignerProperties setLocation(String location) { this.location = location; diff --git a/sign/src/main/java/com/itextpdf/signatures/TSAClientBouncyCastle.java b/sign/src/main/java/com/itextpdf/signatures/TSAClientBouncyCastle.java index 812d8bb0b2..6303170d9f 100644 --- a/sign/src/main/java/com/itextpdf/signatures/TSAClientBouncyCastle.java +++ b/sign/src/main/java/com/itextpdf/signatures/TSAClientBouncyCastle.java @@ -24,8 +24,8 @@ This file is part of the iText (R) project. import com.itextpdf.bouncycastleconnector.BouncyCastleFactoryCreator; import com.itextpdf.commons.bouncycastle.IBouncyCastleFactory; -import com.itextpdf.commons.bouncycastle.tsp.AbstractTSPException; import com.itextpdf.commons.bouncycastle.asn1.cmp.IPKIFailureInfo; +import com.itextpdf.commons.bouncycastle.tsp.AbstractTSPException; import com.itextpdf.commons.bouncycastle.tsp.ITimeStampRequest; import com.itextpdf.commons.bouncycastle.tsp.ITimeStampRequestGenerator; import com.itextpdf.commons.bouncycastle.tsp.ITimeStampResponse; @@ -33,6 +33,7 @@ This file is part of the iText (R) project. import com.itextpdf.commons.bouncycastle.tsp.ITimeStampTokenInfo; import com.itextpdf.commons.utils.Base64; import com.itextpdf.commons.utils.SystemUtil; +import com.itextpdf.kernel.crypto.DigestAlgorithms; import com.itextpdf.kernel.exceptions.PdfException; import com.itextpdf.signatures.exceptions.SignExceptionMessageConstant; diff --git a/sign/src/main/java/com/itextpdf/signatures/VerificationException.java b/sign/src/main/java/com/itextpdf/signatures/VerificationException.java index f5e8738d4f..a53c64ebaa 100644 --- a/sign/src/main/java/com/itextpdf/signatures/VerificationException.java +++ b/sign/src/main/java/com/itextpdf/signatures/VerificationException.java @@ -34,7 +34,11 @@ This file is part of the iText (R) project. /** * An exception that is thrown when something is wrong with a certificate. + * + * @deprecated starting from 9.0.0 since all the classes that use this one are also deprecated in favour of + * new signature validation logic in the {@link com.itextpdf.signatures.validation} package. */ +@Deprecated public class VerificationException extends GeneralSecurityException { private static final IBouncyCastleFactory BOUNCY_CASTLE_FACTORY = BouncyCastleFactoryCreator.getFactory(); diff --git a/sign/src/main/java/com/itextpdf/signatures/VerificationOK.java b/sign/src/main/java/com/itextpdf/signatures/VerificationOK.java index 437a1039d2..2cc6a7cdc4 100644 --- a/sign/src/main/java/com/itextpdf/signatures/VerificationOK.java +++ b/sign/src/main/java/com/itextpdf/signatures/VerificationOK.java @@ -30,7 +30,7 @@ This file is part of the iText (R) project. * reason. * * @deprecated starting from 8.0.5. - * {@link com.itextpdf.signatures.validation.v1.report.ReportItem} should be used instead. + * {@link com.itextpdf.signatures.validation.report.ReportItem} should be used instead. */ @Deprecated public class VerificationOK { diff --git a/sign/src/main/java/com/itextpdf/signatures/cms/CMSContainer.java b/sign/src/main/java/com/itextpdf/signatures/cms/CMSContainer.java index eefafe62f4..e8017508cd 100644 --- a/sign/src/main/java/com/itextpdf/signatures/cms/CMSContainer.java +++ b/sign/src/main/java/com/itextpdf/signatures/cms/CMSContainer.java @@ -29,21 +29,21 @@ This file is part of the iText (R) project. import com.itextpdf.commons.bouncycastle.asn1.IASN1InputStream; import com.itextpdf.commons.bouncycastle.asn1.IASN1Sequence; import com.itextpdf.commons.bouncycastle.asn1.IASN1Set; -import com.itextpdf.commons.bouncycastle.asn1.IDERSet; import com.itextpdf.commons.bouncycastle.asn1.IASN1TaggedObject; +import com.itextpdf.commons.bouncycastle.asn1.IDERSet; import com.itextpdf.commons.bouncycastle.asn1.ocsp.IBasicOCSPResponse; +import com.itextpdf.kernel.crypto.OID; import com.itextpdf.kernel.exceptions.PdfException; import com.itextpdf.signatures.CertificateUtil; -import com.itextpdf.signatures.SecurityIDs; import com.itextpdf.signatures.exceptions.SignExceptionMessageConstant; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; -import java.security.cert.CertificateEncodingException; -import java.security.cert.CertificateException; import java.security.cert.CRL; import java.security.cert.CRLException; +import java.security.cert.CertificateEncodingException; +import java.security.cert.CertificateException; import java.security.cert.X509Certificate; import java.util.ArrayList; import java.util.Arrays; @@ -98,6 +98,8 @@ public class CMSContainer { */ private SignerInfo signerInfo = new SignerInfo(); + private int version = 1; + /** * Creates an empty SignedData structure. */ @@ -119,6 +121,7 @@ public CMSContainer(byte[] encodedCMSdata) throws IOException, CertificateExcept IASN1Sequence contentInfo = BC_FACTORY.createASN1Sequence(is.readObject()); IASN1Sequence signedData = BC_FACTORY.createASN1Sequence( BC_FACTORY.createASN1TaggedObject(contentInfo.getObjectAt(1)).getObject()); + version = BC_FACTORY.createASN1Integer(signedData.getObjectAt(0)).getValue().intValue(); // The digest algorithm is retrieved from SignerInfo later on, here we just validate // that there is exactly 1 digest algorithm. @@ -184,12 +187,12 @@ public long getSizeEstimation() throws CertificateEncodingException, IOException } /** - * Only version 1 is supported by this class. + * The version of the CMS container. * - * @return 1 as CMSversion + * @return version of the CMS container */ public int getCmsVersion() { - return 1; + return version; } /** @@ -356,7 +359,7 @@ otherRevInfo ANY DEFINED BY otherRevInfoFormat (SEQUENCE for OCSP) */ IASN1EncodableVector contentInfoV = BC_FACTORY.createASN1EncodableVector(); - contentInfoV.add(BC_FACTORY.createASN1ObjectIdentifier(SecurityIDs.ID_PKCS7_SIGNED_DATA)); + contentInfoV.add(BC_FACTORY.createASN1ObjectIdentifier(OID.PKCS7_SIGNED_DATA)); IASN1EncodableVector singedDataV = BC_FACTORY.createASN1EncodableVector(); singedDataV.add(BC_FACTORY.createASN1Integer(getCmsVersion())); // version IASN1EncodableVector digestAlgorithmsV = BC_FACTORY.createASN1EncodableVector(); @@ -365,7 +368,7 @@ otherRevInfo ANY DEFINED BY otherRevInfoFormat (SEQUENCE for OCSP) IASN1EncodableVector encapContentInfoV = BC_FACTORY.createASN1EncodableVector(); encapContentInfoV.add(BC_FACTORY.createASN1ObjectIdentifier(encapContentInfo.getContentType())); if (encapContentInfo.getContent() != null) { - encapContentInfoV.add(encapContentInfo.getContent()); + encapContentInfoV.add(BC_FACTORY.createDERTaggedObject(0, encapContentInfo.getContent())); } singedDataV.add(BC_FACTORY.createDERSequence(encapContentInfoV)); IASN1EncodableVector certificateSetV = BC_FACTORY.createASN1EncodableVector(); diff --git a/sign/src/main/java/com/itextpdf/signatures/cms/EncapsulatedContentInfo.java b/sign/src/main/java/com/itextpdf/signatures/cms/EncapsulatedContentInfo.java index 98382bc9cf..f82db5d082 100644 --- a/sign/src/main/java/com/itextpdf/signatures/cms/EncapsulatedContentInfo.java +++ b/sign/src/main/java/com/itextpdf/signatures/cms/EncapsulatedContentInfo.java @@ -28,6 +28,7 @@ This file is part of the iText (R) project. import com.itextpdf.commons.bouncycastle.asn1.IASN1OctetString; import com.itextpdf.commons.bouncycastle.asn1.IASN1Sequence; import com.itextpdf.commons.bouncycastle.asn1.IASN1TaggedObject; +import com.itextpdf.kernel.crypto.OID; /** * This class represents the signed content. @@ -39,7 +40,7 @@ public class EncapsulatedContentInfo { /** * Object identifier of the content field */ - private String eContentType = "1.2.840.113549.1.7.1"; + private String eContentType = OID.PKCS7_DATA; /** * Optional. * diff --git a/sign/src/main/java/com/itextpdf/signatures/cms/SignerInfo.java b/sign/src/main/java/com/itextpdf/signatures/cms/SignerInfo.java index fb71cd7201..2a8f1cb201 100644 --- a/sign/src/main/java/com/itextpdf/signatures/cms/SignerInfo.java +++ b/sign/src/main/java/com/itextpdf/signatures/cms/SignerInfo.java @@ -24,7 +24,6 @@ This file is part of the iText (R) project. import com.itextpdf.bouncycastleconnector.BouncyCastleFactoryCreator; import com.itextpdf.commons.bouncycastle.IBouncyCastleFactory; - import com.itextpdf.commons.bouncycastle.asn1.IASN1Encodable; import com.itextpdf.commons.bouncycastle.asn1.IASN1EncodableVector; import com.itextpdf.commons.bouncycastle.asn1.IASN1Enumerated; @@ -43,16 +42,13 @@ This file is part of the iText (R) project. import com.itextpdf.commons.bouncycastle.asn1.ocsp.IOCSPObjectIdentifiers; import com.itextpdf.commons.bouncycastle.asn1.x509.IAlgorithmIdentifier; import com.itextpdf.commons.bouncycastle.asn1.x509.ITBSCertificate; +import com.itextpdf.kernel.crypto.DigestAlgorithms; +import com.itextpdf.kernel.crypto.OID; import com.itextpdf.kernel.exceptions.PdfException; - import com.itextpdf.signatures.CertificateInfo; import com.itextpdf.signatures.CertificateUtil; -import com.itextpdf.signatures.DigestAlgorithms; -import com.itextpdf.signatures.OID; -import com.itextpdf.signatures.SecurityIDs; import com.itextpdf.signatures.exceptions.SignExceptionMessageConstant; - import java.io.ByteArrayInputStream; import java.io.IOException; import java.security.MessageDigest; @@ -89,8 +85,8 @@ public class SignerInfo { */ public SignerInfo() { CmsAttribute contentType = - new CmsAttribute(SecurityIDs.ID_CONTENT_TYPE, - BC_FACTORY.createDERSet(BC_FACTORY.createASN1ObjectIdentifier(SecurityIDs.ID_PKCS7_DATA))); + new CmsAttribute(OID.CONTENT_TYPE, + BC_FACTORY.createDERSet(BC_FACTORY.createASN1ObjectIdentifier(OID.PKCS7_DATA))); signedAttributes.add(contentType); unSignedAttributes = new ArrayList<>(); } @@ -167,7 +163,7 @@ public void setMessageDigest(byte[] digest) { if (signedAttributesReadOnly) { throw new IllegalStateException(SignExceptionMessageConstant.CMS_SIGNERINFO_READONLY); } - CmsAttribute digestAttribute = new CmsAttribute(SecurityIDs.ID_MESSAGE_DIGEST, BC_FACTORY.createDERSet( + CmsAttribute digestAttribute = new CmsAttribute(OID.MESSAGE_DIGEST, BC_FACTORY.createDERSet( BC_FACTORY.createDEROctetString(digest))); signedAttributes.add(digestAttribute); } @@ -280,7 +276,7 @@ public void addSignerCertificateToSignedAttributes(X509Certificate cert, String BC_FACTORY.getProviderName()); IASN1EncodableVector certContents = BC_FACTORY.createASN1EncodableVector(); // don't add if it is the default value - if (!SecurityIDs.ID_SHA256.equals(digestAlgorithmOid)) { + if (!OID.SHA_256.equals(digestAlgorithmOid)) { IAlgorithmIdentifier algoId = BC_FACTORY.createAlgorithmIdentifier( BC_FACTORY.createASN1ObjectIdentifier(digestAlgorithmOid)); certContents.add(algoId); @@ -301,7 +297,7 @@ public void addSignerCertificateToSignedAttributes(X509Certificate cert, String IDERSequence certContentsSeqSeq = BC_FACTORY.createDERSequence(certContentsSeq); IDERSequence certContentsSeqSeqSeq = BC_FACTORY.createDERSequence(certContentsSeqSeq); IDERSet certContentsSeqSeqSeqSet = BC_FACTORY.createDERSet(certContentsSeqSeqSeq); - CmsAttribute attribute = new CmsAttribute(SecurityIDs.ID_AA_SIGNING_CERTIFICATE_V2, certContentsSeqSeqSeqSet); + CmsAttribute attribute = new CmsAttribute(OID.AA_SIGNING_CERTIFICATE_V2, certContentsSeqSeqSeqSet); signedAttributes.add(attribute); } @@ -398,6 +394,15 @@ public void addUnSignedAttribute(CmsAttribute attribute) { unSignedAttributes.add(attribute); } + /** + * Removes unsigned attribute from signer info object based on attribute type. + * + * @param type {@link String} attribute type + */ + public void removeUnSignedAttribute(String type) { + unSignedAttributes.removeIf(cmsAttribute -> cmsAttribute.getType().equals(type)); + } + /** * Retrieves the encoded signed attributes of the signer info. * This makes the signed attributes read only. @@ -575,7 +580,7 @@ private static Collection processAttributeSet(IASN1Encodable asnSt } private void setRevocationInfo() { - signedAttributes.removeIf(a -> SecurityIDs.ID_ADBE_REVOCATION.equals(a.getType())); + signedAttributes.removeIf(a -> OID.ADBE_REVOCATION.equals(a.getType())); if (containsRevocationData()) { @@ -585,7 +590,7 @@ private void setRevocationInfo() { createOCPSStructure(revocationV); CmsAttribute digestAttribute = - new CmsAttribute(SecurityIDs.ID_ADBE_REVOCATION, + new CmsAttribute(OID.ADBE_REVOCATION, BC_FACTORY.createDERSequence(revocationV)); signedAttributes.add(digestAttribute); } diff --git a/sign/src/main/java/com/itextpdf/signatures/exceptions/SignExceptionMessageConstant.java b/sign/src/main/java/com/itextpdf/signatures/exceptions/SignExceptionMessageConstant.java index 2fd1362d37..e97ea054f7 100644 --- a/sign/src/main/java/com/itextpdf/signatures/exceptions/SignExceptionMessageConstant.java +++ b/sign/src/main/java/com/itextpdf/signatures/exceptions/SignExceptionMessageConstant.java @@ -70,13 +70,14 @@ public final class SignExceptionMessageConstant { public static final String NOT_A_VALID_PKCS7_OBJECT_NOT_SIGNED_DATA = "Not a valid PKCS#7 object - not signed " + "data."; public static final String NOT_ENOUGH_SPACE = "Not enough space."; + public static final String NOT_POSSIBLE_TO_EMBED_MAC_TO_SIGNATURE = + "It was not possible to embed MAC token into signature. Most likely signature container is empty."; public static final String PATH_IS_NOT_DIRECTORY = "Provided path: {0} is not a directory. " + "Please provide a directory path to store temporary pdf files which are required for signing."; public static final String PROVIDED_TSA_CLIENT_IS_NULL = "Provided TSA client is null. TSA client is required for timestamp signing."; public static final String SIGNATURE_WITH_THIS_NAME_IS_NOT_THE_LAST_IT_DOES_NOT_COVER_WHOLE_DOCUMENT = "Signature " + "with name {0} is not the last. It doesn't cover the whole document."; - public static final String THE_NAME_OF_THE_DIGEST_ALGORITHM_IS_NULL = "The name of the digest algorithm is null."; public static final String THERE_IS_NO_FIELD_IN_THE_DOCUMENT_WITH_SUCH_NAME = "There is no field in the document " + "with such name: {0}."; public static final String THIS_PKCS7_OBJECT_HAS_MULTIPLE_SIGNERINFOS_ONLY_ONE_IS_SUPPORTED_AT_THIS_TIME = "This " diff --git a/sign/src/main/java/com/itextpdf/signatures/logs/SignLogMessageConstant.java b/sign/src/main/java/com/itextpdf/signatures/logs/SignLogMessageConstant.java index ea90eb45a6..dcde5f7333 100644 --- a/sign/src/main/java/com/itextpdf/signatures/logs/SignLogMessageConstant.java +++ b/sign/src/main/java/com/itextpdf/signatures/logs/SignLogMessageConstant.java @@ -26,9 +26,6 @@ This file is part of the iText (R) project. * Class which contains constants to be used in logging inside sign module. */ public final class SignLogMessageConstant { - - public static final String ALGORITHM_NOT_FROM_SPEC = - "Requested algorithm might not be supported by the pdf specification."; public static final String EXCEPTION_WITHOUT_MESSAGE = "Unexpected exception without message was thrown during keystore processing"; public static final String UNABLE_TO_PARSE_AIA_CERT = "Unable to parse certificates coming from authority info " diff --git a/sign/src/main/java/com/itextpdf/signatures/mac/SignatureContainerGenerationEvent.java b/sign/src/main/java/com/itextpdf/signatures/mac/SignatureContainerGenerationEvent.java new file mode 100644 index 0000000000..f81a7e94a2 --- /dev/null +++ b/sign/src/main/java/com/itextpdf/signatures/mac/SignatureContainerGenerationEvent.java @@ -0,0 +1,81 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.signatures.mac; + +import com.itextpdf.commons.bouncycastle.asn1.IASN1EncodableVector; +import com.itextpdf.kernel.pdf.event.AbstractPdfDocumentEvent; + +import java.io.InputStream; + +/** + * Represents an event firing before creating signature container. + */ +public class SignatureContainerGenerationEvent extends AbstractPdfDocumentEvent { + public static final String START_SIGNATURE_CONTAINER_GENERATION = "StartSignatureContainerGeneration"; + + private final IASN1EncodableVector unsignedAttributes; + private final byte[] signature; + private final InputStream documentInputStream; + + /** + * Creates an event firing before creating the signature container. + * + * @param unsignedAttributes {@link IASN1EncodableVector} unsigned signature attributes + * @param signature {@code byte[]} signature value + * @param documentInputStream {@link InputStream} containing document bytes considering byte range + */ + public SignatureContainerGenerationEvent(IASN1EncodableVector unsignedAttributes, byte[] signature, + InputStream documentInputStream) { + super(START_SIGNATURE_CONTAINER_GENERATION); + this.unsignedAttributes = unsignedAttributes; + this.signature = signature; + this.documentInputStream = documentInputStream; + } + + /** + * Gets {@link IASN1EncodableVector} unsigned signature attributes. + * + * @return {@link IASN1EncodableVector} unsigned signature attributes + */ + public IASN1EncodableVector getUnsignedAttributes() { + return unsignedAttributes; + } + + /** + * Gets {@code byte[]} signature value. + * + * @return {@code byte[]} signature value + */ + public byte[] getSignature() { + return signature; + } + + /** + * Gets {@link InputStream} containing document bytes considering byte range. + * + * @return {@link InputStream} containing document bytes considering byte range + */ + public InputStream getDocumentInputStream() { + return documentInputStream; + } +} diff --git a/sign/src/main/java/com/itextpdf/signatures/mac/SignatureDocumentClosingEvent.java b/sign/src/main/java/com/itextpdf/signatures/mac/SignatureDocumentClosingEvent.java new file mode 100644 index 0000000000..0b181dda11 --- /dev/null +++ b/sign/src/main/java/com/itextpdf/signatures/mac/SignatureDocumentClosingEvent.java @@ -0,0 +1,55 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.signatures.mac; + +import com.itextpdf.kernel.pdf.event.AbstractPdfDocumentEvent; +import com.itextpdf.kernel.pdf.PdfIndirectReference; + +/** + * Represents an event firing before embedding the signature into the document. + */ +public class SignatureDocumentClosingEvent extends AbstractPdfDocumentEvent { + public static final String START_SIGNATURE_PRE_CLOSE = "StartSignaturePreClose"; + + private final PdfIndirectReference signatureReference; + + /** + * Creates an event firing before embedding the signature into the document. + * It contains the reference to the signature object. + * + * @param signatureReference {@link PdfIndirectReference} to the signature object + */ + public SignatureDocumentClosingEvent(PdfIndirectReference signatureReference) { + super(START_SIGNATURE_PRE_CLOSE); + this.signatureReference = signatureReference; + } + + /** + * Gets {@link PdfIndirectReference} to the signature object. + * + * @return {@link PdfIndirectReference} to the signature object + */ + public PdfIndirectReference getSignatureReference() { + return signatureReference; + } +} diff --git a/sign/src/main/java/com/itextpdf/signatures/mac/SignatureMacContainerLocator.java b/sign/src/main/java/com/itextpdf/signatures/mac/SignatureMacContainerLocator.java new file mode 100644 index 0000000000..a676292e85 --- /dev/null +++ b/sign/src/main/java/com/itextpdf/signatures/mac/SignatureMacContainerLocator.java @@ -0,0 +1,81 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.signatures.mac; + +import com.itextpdf.kernel.mac.IMacContainerLocator; +import com.itextpdf.kernel.mac.AbstractMacIntegrityProtector; +import com.itextpdf.kernel.mac.MacProperties; +import com.itextpdf.kernel.mac.MacValidationException; +import com.itextpdf.kernel.pdf.PdfDictionary; +import com.itextpdf.kernel.pdf.PdfDocument; + +/** + * {@link IMacContainerLocator} strategy, which should be used specifically in case of signature creation. + * This strategy locates MAC container in signature unsigned attributes. + */ +public class SignatureMacContainerLocator implements IMacContainerLocator { + private boolean macContainerLocated = false; + + /** + * {@inheritDoc}. + */ + @Override + public void locateMacContainer(AbstractMacIntegrityProtector macIntegrityProtector) { + ((SignatureMacIntegrityProtector) macIntegrityProtector).prepareDocument(); + macContainerLocated = true; + } + + /** + * {@inheritDoc}. + */ + @Override + public boolean isMacContainerLocated() { + return macContainerLocated; + } + + /** + * {@inheritDoc}. + */ + @Override + public AbstractMacIntegrityProtector createMacIntegrityProtector(PdfDocument document, + MacProperties macProperties) { + return new SignatureMacIntegrityProtector(document, macProperties); + } + + /** + * {@inheritDoc}. + */ + @Override + public AbstractMacIntegrityProtector createMacIntegrityProtector(PdfDocument document, + PdfDictionary authDictionary) { + return new SignatureMacIntegrityProtector(document, authDictionary); + } + + /** + * {@inheritDoc} + */ + @Override + public void handleMacValidationError(MacValidationException exception) { + throw exception; + } +} diff --git a/sign/src/main/java/com/itextpdf/signatures/mac/SignatureMacIntegrityProtector.java b/sign/src/main/java/com/itextpdf/signatures/mac/SignatureMacIntegrityProtector.java new file mode 100644 index 0000000000..633e5d146b --- /dev/null +++ b/sign/src/main/java/com/itextpdf/signatures/mac/SignatureMacIntegrityProtector.java @@ -0,0 +1,107 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.signatures.mac; + +import com.itextpdf.bouncycastleconnector.BouncyCastleFactoryCreator; +import com.itextpdf.commons.bouncycastle.IBouncyCastleFactory; +import com.itextpdf.commons.bouncycastle.asn1.IASN1EncodableVector; +import com.itextpdf.commons.bouncycastle.asn1.IDERSequence; +import com.itextpdf.kernel.pdf.event.AbstractPdfDocumentEventHandler; +import com.itextpdf.kernel.pdf.event.AbstractPdfDocumentEvent; +import com.itextpdf.kernel.exceptions.KernelExceptionMessageConstant; +import com.itextpdf.kernel.exceptions.PdfException; +import com.itextpdf.kernel.mac.AbstractMacIntegrityProtector; +import com.itextpdf.kernel.mac.MacProperties; +import com.itextpdf.kernel.pdf.PdfDictionary; +import com.itextpdf.kernel.pdf.PdfDocument; +import com.itextpdf.kernel.pdf.PdfName; + +import java.io.IOException; +import java.io.InputStream; +import java.security.GeneralSecurityException; + +/** + * Class responsible for integrity protection in encrypted documents which uses MAC container in the signature mode. + */ +class SignatureMacIntegrityProtector extends AbstractMacIntegrityProtector { + private static final IBouncyCastleFactory BC_FACTORY = BouncyCastleFactoryCreator.getFactory(); + private static final String ID_ATTR_PDF_MAC_DATA = "1.0.32004.1.2"; + + SignatureMacIntegrityProtector(PdfDocument document, MacProperties macProperties) { + super(document, macProperties); + } + + SignatureMacIntegrityProtector(PdfDocument document, PdfDictionary authDictionary) { + super(document, authDictionary); + } + + void prepareDocument() { + document.addEventHandler(SignatureDocumentClosingEvent.START_SIGNATURE_PRE_CLOSE, + new SignatureMacIntegrityProtector.SignatureMacPdfObjectAdder()); + document.addEventHandler(SignatureContainerGenerationEvent.START_SIGNATURE_CONTAINER_GENERATION, + new SignatureMacIntegrityProtector.SignatureMacContainerEmbedder()); + } + + private void embedMacContainerInUnsignedAttributes(IASN1EncodableVector unsignedAttributes, + InputStream documentInputStream, byte[] signature) throws IOException { + IDERSequence mac; + try { + byte[] dataDigest = digestBytes(documentInputStream); + mac = createMacContainer(dataDigest, generateRandomBytes(32), signature); + } catch (GeneralSecurityException e) { + throw new PdfException(KernelExceptionMessageConstant.CONTAINER_GENERATION_EXCEPTION, e); + } + IASN1EncodableVector macAttribute = BC_FACTORY.createASN1EncodableVector(); + macAttribute.add(BC_FACTORY.createASN1ObjectIdentifier(ID_ATTR_PDF_MAC_DATA)); + macAttribute.add(BC_FACTORY.createDERSet(mac)); + unsignedAttributes.add(BC_FACTORY.createDERSequence(macAttribute)); + } + + private final class SignatureMacPdfObjectAdder extends AbstractPdfDocumentEventHandler { + @Override + public void onAcceptedEvent(AbstractPdfDocumentEvent event) { + if (event instanceof SignatureDocumentClosingEvent) { + PdfDictionary signatureMacDictionary = new PdfDictionary(); + signatureMacDictionary.put(PdfName.MACLocation, PdfName.AttachedToSig); + signatureMacDictionary.put(PdfName.SigObjRef, + ((SignatureDocumentClosingEvent) event).getSignatureReference()); + document.getTrailer().put(PdfName.AuthCode, signatureMacDictionary); + } + } + } + + private final class SignatureMacContainerEmbedder extends AbstractPdfDocumentEventHandler { + @Override + public void onAcceptedEvent(AbstractPdfDocumentEvent event) { + if (event instanceof SignatureContainerGenerationEvent) { + SignatureContainerGenerationEvent signatureEvent = (SignatureContainerGenerationEvent) event; + try { + embedMacContainerInUnsignedAttributes(signatureEvent.getUnsignedAttributes(), + signatureEvent.getDocumentInputStream(), signatureEvent.getSignature()); + } catch (IOException e) { + throw new PdfException(KernelExceptionMessageConstant.CONTAINER_EMBEDDING_EXCEPTION, e); + } + } + } + } +} diff --git a/sign/src/main/java/com/itextpdf/signatures/validation/v1/CRLValidator.java b/sign/src/main/java/com/itextpdf/signatures/validation/CRLValidator.java similarity index 79% rename from sign/src/main/java/com/itextpdf/signatures/validation/v1/CRLValidator.java rename to sign/src/main/java/com/itextpdf/signatures/validation/CRLValidator.java index 663855b649..33055ef72a 100644 --- a/sign/src/main/java/com/itextpdf/signatures/validation/v1/CRLValidator.java +++ b/sign/src/main/java/com/itextpdf/signatures/validation/CRLValidator.java @@ -20,7 +20,7 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.signatures.validation.v1; +package com.itextpdf.signatures.validation; import com.itextpdf.bouncycastleconnector.BouncyCastleFactoryCreator; import com.itextpdf.commons.bouncycastle.IBouncyCastleFactory; @@ -35,14 +35,15 @@ This file is part of the iText (R) project. import com.itextpdf.signatures.IssuingCertificateRetriever; import com.itextpdf.signatures.TimestampConstants; import com.itextpdf.signatures.logs.SignLogMessageConstant; -import com.itextpdf.signatures.validation.v1.context.CertificateSource; -import com.itextpdf.signatures.validation.v1.context.ValidationContext; -import com.itextpdf.signatures.validation.v1.context.ValidatorContext; -import com.itextpdf.signatures.validation.v1.extensions.DynamicBasicConstraintsExtension; -import com.itextpdf.signatures.validation.v1.report.CertificateReportItem; -import com.itextpdf.signatures.validation.v1.report.ReportItem; -import com.itextpdf.signatures.validation.v1.report.ReportItem.ReportItemStatus; -import com.itextpdf.signatures.validation.v1.report.ValidationReport; +import com.itextpdf.signatures.validation.context.CertificateSource; +import com.itextpdf.signatures.validation.context.ValidationContext; +import com.itextpdf.signatures.validation.context.ValidatorContext; +import com.itextpdf.signatures.validation.extensions.DynamicBasicConstraintsExtension; +import com.itextpdf.signatures.validation.report.CertificateReportItem; +import com.itextpdf.signatures.validation.report.ReportItem; +import com.itextpdf.signatures.validation.report.ReportItem.ReportItemStatus; +import com.itextpdf.signatures.validation.report.ValidationReport; +import com.itextpdf.signatures.validation.report.ValidationReport.ValidationResult; import java.io.IOException; import java.security.cert.Certificate; @@ -51,11 +52,14 @@ This file is part of the iText (R) project. import java.security.cert.X509CRLEntry; import java.security.cert.X509Certificate; import java.time.Duration; +import java.util.Arrays; import java.util.Date; import java.util.HashMap; +import java.util.List; import java.util.Map; +import java.util.stream.Collectors; -import static com.itextpdf.signatures.validation.v1.SafeCalling.onExceptionLog; +import static com.itextpdf.signatures.validation.SafeCalling.onExceptionLog; /** * Class that allows you to validate a certificate against a Certificate Revocation List (CRL) Response. @@ -85,6 +89,8 @@ public class CRLValidator { "not all reason codes are covered by the current CRL."; static final String SAME_REASONS_CHECK = "CRLs that cover the same reason codes were already verified."; static final String UPDATE_DATE_BEFORE_CHECK_DATE = "nextUpdate: {0} of CRLResponse is before validation date {1}."; + static final String CERTIFICATE_IN_ISSUER_CHAIN = "Unable to validate CRL response: validated certificate is" + + " part of issuer certificate chain."; // All reasons without unspecified. static final int ALL_REASONS = 32895; @@ -107,23 +113,6 @@ protected CRLValidator(ValidatorChainBuilder builder) { this.builder = builder; } - /** - * Validates a certificate against Certificate Revocation List (CRL) Responses. - * - * @param report to store all the chain verification results - * @param context the context in which to perform the validation - * @param certificate the certificate to check against CRL response - * @param crl the crl response to be validated - * @param validationDate validation date to check for - * - * @deprecated starting from 8.0.5. TODO DEVSIX-8398 To be removed. - */ - @Deprecated - public void validate(ValidationReport report, ValidationContext context, X509Certificate certificate, X509CRL crl, - Date validationDate) { - validate(report, context, certificate, crl, validationDate, DateTimeUtil.getCurrentTimeDate()); - } - /** * Validates a certificate against Certificate Revocation List (CRL) Responses. * @@ -137,6 +126,7 @@ public void validate(ValidationReport report, ValidationContext context, X509Cer public void validate(ValidationReport report, ValidationContext context, X509Certificate certificate, X509CRL crl, Date validationDate, Date responseGenerationDate) { ValidationContext localContext = context.setValidatorContext(ValidatorContext.CRL_VALIDATOR); + if (CertificateUtil.isSelfSigned(certificate)) { report.addReportItem(new CertificateReportItem(certificate, CRL_CHECK, RevocationDataValidator.SELF_SIGNED_CERTIFICATE, ReportItemStatus.INFO)); @@ -290,43 +280,62 @@ private static int computeInterimReasonsMask(IIssuingDistributionPoint issuingDi private void verifyCrlIntegrity(ValidationReport report, ValidationContext context, X509Certificate certificate, X509CRL crl, Date responseGenerationDate) { - Certificate[] certs = null; + Certificate[][] certificateSets = null; try { - certs = certificateRetriever.getCrlIssuerCertificates(crl); + certificateSets = certificateRetriever.getCrlIssuerCertificatesByName(crl); } catch (RuntimeException e) { report.addReportItem(new CertificateReportItem(certificate, CRL_CHECK, CRL_ISSUER_REQUEST_FAILED, e, ReportItemStatus.INDETERMINATE)); return; } - - if (certs == null || certs.length == 0) { + if (certificateSets == null || certificateSets.length == 0) { report.addReportItem(new CertificateReportItem(certificate, CRL_CHECK, CRL_ISSUER_NOT_FOUND, ReportItemStatus.INDETERMINATE)); return; } - Certificate crlIssuer = certs[0]; - Certificate crlIssuerRoot = getRoot(crlIssuer); - Certificate subjectRoot = getRoot(certificate); - if (!crlIssuerRoot.equals(subjectRoot)) { - report.addReportItem(new CertificateReportItem(certificate, CRL_CHECK, CRL_ISSUER_NO_COMMON_ROOT, - ReportItemStatus.INDETERMINATE)); - return; + ValidationReport[] candidateReports = new ValidationReport[certificateSets.length]; + for (int i = 0; i < certificateSets.length; i++) { + ValidationReport candidateReport = new ValidationReport(); + candidateReports[i] = candidateReport; + Certificate[] certs = certificateSets[i]; + if (Arrays.asList(certs).contains(certificate)) { + candidateReport.addReportItem(new CertificateReportItem(certificate, + CRL_CHECK, CERTIFICATE_IN_ISSUER_CHAIN, ReportItemStatus.INDETERMINATE)); + continue; + } + Certificate crlIssuer = certs[0]; + List crlIssuerRoots = getRoots(crlIssuer); + List subjectRoots = getRoots(certificate); + if (!crlIssuerRoots.stream().anyMatch(cert -> subjectRoots.contains(cert))) { + candidateReport.addReportItem(new CertificateReportItem(certificate, + CRL_CHECK, CRL_ISSUER_NO_COMMON_ROOT, ReportItemStatus.INDETERMINATE)); + continue; + } + onExceptionLog(() -> crl.verify(crlIssuer.getPublicKey()), candidateReport, + e -> new CertificateReportItem(certificate, CRL_CHECK, CRL_INVALID, e, + ReportItemStatus.INDETERMINATE)); + ValidationReport responderReport = new ValidationReport(); + onExceptionLog(() -> builder.getCertificateChainValidator().validate(responderReport, + context.setCertificateSource(CertificateSource.CRL_ISSUER), + (X509Certificate) crlIssuer, responseGenerationDate), candidateReport, e -> + new CertificateReportItem(certificate, CRL_CHECK, CRL_ISSUER_CHAIN_FAILED, e, + ReportItemStatus.INDETERMINATE)); + addResponderValidationReport(candidateReport, responderReport); + if (candidateReport.getValidationResult() == ValidationResult.VALID) { + report.merge(candidateReport); + return; + } + } + // if failed, add all logs + for (ValidationReport candidateReport : candidateReports) { + report.merge(candidateReport); } - onExceptionLog(() -> crl.verify(crlIssuer.getPublicKey()), report, - e -> new CertificateReportItem(certificate, CRL_CHECK, CRL_INVALID, e, ReportItemStatus.INDETERMINATE)); - ValidationReport responderReport = new ValidationReport(); - onExceptionLog(() -> builder.getCertificateChainValidator().validate(responderReport, - context.setCertificateSource(CertificateSource.CRL_ISSUER), - (X509Certificate) crlIssuer, responseGenerationDate), report, e -> - new CertificateReportItem(certificate, CRL_CHECK, CRL_ISSUER_CHAIN_FAILED, e, - ReportItemStatus.INDETERMINATE)); - addResponderValidationReport(report, responderReport); } - private Certificate getRoot(Certificate cert) { - Certificate[] chain = certificateRetriever.retrieveMissingCertificates(new Certificate[]{cert}); - return chain[chain.length - 1]; + private List getRoots(Certificate cert) { + List chains = certificateRetriever.buildCertificateChains((X509Certificate) cert); + return chains.stream().map(certArray -> certArray[certArray.length - 1]).collect(Collectors.toList()); } private static void addResponderValidationReport(ValidationReport report, ValidationReport responderReport) { diff --git a/sign/src/main/java/com/itextpdf/signatures/validation/v1/CertificateChainValidator.java b/sign/src/main/java/com/itextpdf/signatures/validation/CertificateChainValidator.java similarity index 81% rename from sign/src/main/java/com/itextpdf/signatures/validation/v1/CertificateChainValidator.java rename to sign/src/main/java/com/itextpdf/signatures/validation/CertificateChainValidator.java index 7270d92616..f6e9e9c3f7 100644 --- a/sign/src/main/java/com/itextpdf/signatures/validation/v1/CertificateChainValidator.java +++ b/sign/src/main/java/com/itextpdf/signatures/validation/CertificateChainValidator.java @@ -20,20 +20,19 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.signatures.validation.v1; +package com.itextpdf.signatures.validation; import com.itextpdf.commons.utils.MessageFormatUtil; -import com.itextpdf.signatures.ICrlClient; -import com.itextpdf.signatures.IOcspClient; import com.itextpdf.signatures.IssuingCertificateRetriever; -import com.itextpdf.signatures.validation.v1.context.CertificateSource; -import com.itextpdf.signatures.validation.v1.context.ValidationContext; -import com.itextpdf.signatures.validation.v1.context.ValidatorContext; -import com.itextpdf.signatures.validation.v1.extensions.CertificateExtension; -import com.itextpdf.signatures.validation.v1.extensions.DynamicCertificateExtension; -import com.itextpdf.signatures.validation.v1.report.CertificateReportItem; -import com.itextpdf.signatures.validation.v1.report.ValidationReport; -import com.itextpdf.signatures.validation.v1.report.ReportItem.ReportItemStatus; +import com.itextpdf.signatures.validation.context.CertificateSource; +import com.itextpdf.signatures.validation.context.ValidationContext; +import com.itextpdf.signatures.validation.context.ValidatorContext; +import com.itextpdf.signatures.validation.extensions.CertificateExtension; +import com.itextpdf.signatures.validation.extensions.DynamicCertificateExtension; +import com.itextpdf.signatures.validation.report.CertificateReportItem; +import com.itextpdf.signatures.validation.report.ValidationReport; +import com.itextpdf.signatures.validation.report.ReportItem.ReportItemStatus; +import com.itextpdf.signatures.validation.report.ValidationReport.ValidationResult; import java.security.GeneralSecurityException; import java.security.cert.CertificateExpiredException; @@ -42,8 +41,8 @@ This file is part of the iText (R) project. import java.util.Date; import java.util.List; -import static com.itextpdf.signatures.validation.v1.SafeCalling.onExceptionLog; -import static com.itextpdf.signatures.validation.v1.SafeCalling.onRuntimeExceptionLog; +import static com.itextpdf.signatures.validation.SafeCalling.onExceptionLog; +import static com.itextpdf.signatures.validation.SafeCalling.onRuntimeExceptionLog; /** * Validator class, which is expected to be used for certificates chain validation. @@ -91,38 +90,6 @@ protected CertificateChainValidator(ValidatorChainBuilder builder) { this.revocationDataValidator = builder.getRevocationDataValidator(); } - /** - * Add {@link ICrlClient} to be used for CRL responses receiving. - * - * @param crlClient {@link ICrlClient} to be used for CRL responses receiving - * - * @return same instance of {@link CertificateChainValidator}. - * - * @deprecated in favour of either {@link SignatureValidationProperties#addCrlClient} - * or {@link RevocationDataValidator#addCrlClient}. TODO DEVSIX-8398 To be removed. - */ - @Deprecated - public CertificateChainValidator addCrlClient(ICrlClient crlClient) { - revocationDataValidator.addCrlClient(crlClient); - return this; - } - - /** - * Add {@link IOcspClient} to be used for OCSP responses receiving. - * - * @param ocpsClient {@link IOcspClient} to be used for OCSP responses receiving - * - * @return same instance of {@link CertificateChainValidator}. - * - * @deprecated in favour of either {@link SignatureValidationProperties#addOcspClient} - * or {@link RevocationDataValidator#addOcspClient}. TODO DEVSIX-8398 To be removed. - */ - @Deprecated - public CertificateChainValidator addOcspClient(IOcspClient ocpsClient) { - revocationDataValidator.addOcspClient(ocpsClient); - return this; - } - /** * Validate given certificate using provided validation date and required extensions. * @@ -295,34 +262,48 @@ private void validateRevocationData(ValidationReport report, ValidationContext c private void validateChain(ValidationReport result, ValidationContext context, X509Certificate certificate, Date validationDate, int certificateChainSize) { - X509Certificate issuerCertificate = null; + List issuerCertificates; try { - issuerCertificate = - (X509Certificate) certificateRetriever.retrieveIssuerCertificate(certificate); + issuerCertificates = certificateRetriever.retrieveIssuerCertificate(certificate); } catch (RuntimeException e) { result.addReportItem(new CertificateReportItem(certificate, CERTIFICATE_CHECK, ISSUER_RETRIEVAL_FAILED, e, ReportItemStatus.INDETERMINATE)); return; } - if (issuerCertificate == null) { + if (issuerCertificates.isEmpty()) { result.addReportItem(new CertificateReportItem(certificate, CERTIFICATE_CHECK, MessageFormatUtil.format( ISSUER_MISSING, certificate.getSubjectX500Principal()), ReportItemStatus.INDETERMINATE)); return; } - try { - certificate.verify(issuerCertificate.getPublicKey()); - } catch (GeneralSecurityException e) { - result.addReportItem(new CertificateReportItem(certificate, CERTIFICATE_CHECK, - MessageFormatUtil.format(ISSUER_CANNOT_BE_VERIFIED, issuerCertificate.getSubjectX500Principal(), - certificate.getSubjectX500Principal()), e, ReportItemStatus.INVALID)); - return; - } catch (RuntimeException e) { - result.addReportItem(new CertificateReportItem(certificate, CERTIFICATE_CHECK, - MessageFormatUtil.format(ISSUER_VERIFICATION_FAILED, issuerCertificate.getSubjectX500Principal(), - certificate.getSubjectX500Principal()), e, ReportItemStatus.INVALID)); - return; + ValidationReport[] candidateReports = new ValidationReport[issuerCertificates.size()]; + for (int i = 0; i < issuerCertificates.size(); i++) { + candidateReports[i] = new ValidationReport(); + try { + certificate.verify(issuerCertificates.get(i).getPublicKey()); + } catch (GeneralSecurityException e) { + candidateReports[i].addReportItem(new CertificateReportItem(certificate, CERTIFICATE_CHECK, + MessageFormatUtil.format(ISSUER_CANNOT_BE_VERIFIED, + issuerCertificates.get(i).getSubjectX500Principal(), + certificate.getSubjectX500Principal()), e, ReportItemStatus.INVALID)); + continue; + } catch (RuntimeException e) { + candidateReports[i].addReportItem(new CertificateReportItem(certificate, CERTIFICATE_CHECK, + MessageFormatUtil.format(ISSUER_VERIFICATION_FAILED, + issuerCertificates.get(i).getSubjectX500Principal(), + certificate.getSubjectX500Principal()), e, ReportItemStatus.INVALID)); + continue; + } + this.validate(candidateReports[i], context.setCertificateSource(CertificateSource.CERT_ISSUER), + issuerCertificates.get(i), validationDate, certificateChainSize + 1); + if (candidateReports[i].getValidationResult() == ValidationResult.VALID) { + // We found valid issuer, no need to try other ones. + result.merge(candidateReports[i]); + return; + } + } + // Valid issuer wasn't found, add all the reports + for (ValidationReport candidateReport : candidateReports) { + result.merge(candidateReport); } - this.validate(result, context.setCertificateSource(CertificateSource.CERT_ISSUER), - issuerCertificate, validationDate, certificateChainSize + 1); } } diff --git a/sign/src/main/java/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidator.java b/sign/src/main/java/com/itextpdf/signatures/validation/DocumentRevisionsValidator.java similarity index 89% rename from sign/src/main/java/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidator.java rename to sign/src/main/java/com/itextpdf/signatures/validation/DocumentRevisionsValidator.java index d24432a50a..cc47a2025c 100644 --- a/sign/src/main/java/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidator.java +++ b/sign/src/main/java/com/itextpdf/signatures/validation/DocumentRevisionsValidator.java @@ -20,7 +20,7 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.signatures.validation.v1; +package com.itextpdf.signatures.validation; import com.itextpdf.commons.actions.contexts.IMetaInfo; import com.itextpdf.commons.utils.MessageFormatUtil; @@ -49,12 +49,12 @@ This file is part of the iText (R) project. import com.itextpdf.signatures.AccessPermissions; import com.itextpdf.signatures.PdfSignature; import com.itextpdf.signatures.SignatureUtil; -import com.itextpdf.signatures.validation.v1.context.ValidationContext; -import com.itextpdf.signatures.validation.v1.context.ValidatorContext; -import com.itextpdf.signatures.validation.v1.report.ReportItem; -import com.itextpdf.signatures.validation.v1.report.ReportItem.ReportItemStatus; -import com.itextpdf.signatures.validation.v1.report.ValidationReport; -import com.itextpdf.signatures.validation.v1.report.ValidationReport.ValidationResult; +import com.itextpdf.signatures.validation.context.ValidationContext; +import com.itextpdf.signatures.validation.context.ValidatorContext; +import com.itextpdf.signatures.validation.report.ReportItem; +import com.itextpdf.signatures.validation.report.ReportItem.ReportItemStatus; +import com.itextpdf.signatures.validation.report.ValidationReport; +import com.itextpdf.signatures.validation.report.ValidationReport.ValidationResult; import java.io.IOException; import java.io.InputStream; @@ -97,8 +97,6 @@ public class DocumentRevisionsValidator { static final String FIELD_NOT_DICTIONARY = "Form field \"{0}\" or one of its widgets is not a dictionary. It will not be validated."; static final String FIELD_REMOVED = "Form field {0} was removed or unexpectedly modified."; - static final String LINEARIZED_NOT_SUPPORTED = - "Linearized PDF documents are not supported by DocumentRevisionsValidator."; static final String LOCKED_FIELD_KIDS_ADDED = "Kids were added to locked form field \"{0}\"."; static final String LOCKED_FIELD_KIDS_REMOVED = @@ -112,10 +110,10 @@ public class DocumentRevisionsValidator { "DSS dictionary and DTS addition (docMDP level >= 1), " + "form fill-in and digital signatures (docMDP level >= 2), " + "adding or editing annotations (docMDP level 3)."; + static final String NOT_ALLOWED_CERTIFICATION_SIGNATURE = "Certification signature is applied after " + + "the approval signature which is not allowed."; static final String OBJECT_REMOVED = "Object \"{0}\", which is not allowed to be removed, was removed from the document through XREF table."; - static final String OUTLINES_MODIFIED = "Outlines entry in catalog dictionary was modified. " - + "iText currently cannot identify if these modifications are allowed."; static final String PAGES_MODIFIED = "Pages structure was unexpectedly modified."; static final String PAGE_ANNOTATIONS_MODIFIED = "Page annotations were unexpectedly modified."; static final String PAGE_MODIFIED = "Page was unexpectedly modified."; @@ -160,6 +158,7 @@ public class DocumentRevisionsValidator { private Set newlyAddedFields; private Set removedTaggedObjects; private Set addedTaggedObjects; + private Pair, Set> usuallyModifiedObjects; /** * Creates new instance of {@link DocumentRevisionsValidator}. @@ -217,6 +216,21 @@ public DocumentRevisionsValidator setUnexpectedXrefChangesStatus(ReportItemStatu * @return {@link ValidationReport} which contains detailed validation results. */ public ValidationReport validateAllDocumentRevisions(ValidationContext context, PdfDocument document) { + return validateAllDocumentRevisions(context, document, null); + } + + /** + * Validate all document revisions according to docMDP and fieldMDP transform methods and collect validation report + * related to the single signature field checks if specified. + * + * @param context the validation context in which to validate document revisions + * @param document the document to be validated + * @param signatureName signature field to collect validation result for. If null, all signatures will be checked + * + * @return {@link ValidationReport} which contains detailed validation results. + */ + ValidationReport validateAllDocumentRevisions(ValidationContext context, PdfDocument document, + String signatureName) { resetClassFields(); ValidationContext localContext = context.setValidatorContext(ValidatorContext.DOCUMENT_REVISIONS_VALIDATOR); ValidationReport report = new ValidationReport(); @@ -235,50 +249,69 @@ public ValidationReport validateAllDocumentRevisions(ValidationContext context, ReportItemStatus.INDETERMINATE)); return report; } + mergeRevisionsInLinearizedDocument(document, documentRevisions); SignatureUtil signatureUtil = new SignatureUtil(document); List signatures = new ArrayList<>(signatureUtil.getSignatureNames()); if (signatures.isEmpty()) { report.addReportItem(new ReportItem(DOC_MDP_CHECK, DOCUMENT_WITHOUT_SIGNATURES, ReportItemStatus.INFO)); return report; } - boolean signatureFound = false; + boolean updateAccessPermissions = true; + boolean documentSigned = false; boolean certificationSignatureFound = false; - PdfSignature currentSignature = signatureUtil.getSignature(signatures.get(0)); + boolean collectRevisionsValidationReport = signatureName == null; + String currentSignatureName = signatures.get(0); + PdfSignature currentSignature = signatureUtil.getSignature(currentSignatureName); for (int i = 0; i < documentRevisions.size(); i++) { if (currentSignature != null && - revisionContainsSignature(documentRevisions.get(i), signatures.get(0), document, report)) { - signatureFound = true; + revisionContainsSignature(documentRevisions.get(i), currentSignatureName, document, report)) { if (isCertificationSignature(currentSignature)) { if (certificationSignatureFound) { report.addReportItem(new ReportItem(DOC_MDP_CHECK, TOO_MANY_CERTIFICATION_SIGNATURES, ReportItemStatus.INDETERMINATE)); + } else if (documentSigned) { + report.addReportItem(new ReportItem(DOC_MDP_CHECK, + NOT_ALLOWED_CERTIFICATION_SIGNATURE, ReportItemStatus.INDETERMINATE)); } else { certificationSignatureFound = true; - updateCertificationSignatureAccessPermissions(currentSignature, report); + if (updateAccessPermissions) { + updateCertificationSignatureAccessPermissions(currentSignature, report); + } } } - updateApprovalSignatureAccessPermissions( - signatureUtil.getSignatureFormFieldDictionary(signatures.get(0)), report); - updateApprovalSignatureFieldLock(documentRevisions.get(i), - signatureUtil.getSignatureFormFieldDictionary(signatures.get(0)), document, report); + documentSigned = true; + if (updateAccessPermissions) { + updateApprovalSignatureAccessPermissions( + signatureUtil.getSignatureFormFieldDictionary(currentSignatureName), report); + updateApprovalSignatureFieldLock(documentRevisions.get(i), + signatureUtil.getSignatureFormFieldDictionary(currentSignatureName), document, report); + } + if (signatureName != null && signatureName.equals(currentSignatureName)) { + updateAccessPermissions = false; + collectRevisionsValidationReport = true; + } signatures.remove(0); if (signatures.isEmpty()) { currentSignature = null; } else { - currentSignature = signatureUtil.getSignature(signatures.get(0)); + currentSignatureName = signatures.get(0); + currentSignature = signatureUtil.getSignature(currentSignatureName); } } - if (signatureFound && i < documentRevisions.size() - 1) { - validateRevision(documentRevisions.get(i), documentRevisions.get(i + 1), - document, report, localContext); + if (documentSigned && i < documentRevisions.size() - 1) { + ValidationReport validationReport = new ValidationReport(); + validateRevision(documentRevisions.get(i), documentRevisions.get(i + 1), document, validationReport, + localContext); + if (collectRevisionsValidationReport) { + report.merge(validationReport); + } } if (stopValidation(report, localContext)) { break; } } - if (!signatureFound) { - report.addReportItem( - new ReportItem(DOC_MDP_CHECK, SIGNATURE_REVISION_NOT_FOUND, ReportItemStatus.INVALID)); + if (!documentSigned) { + report.addReportItem(new ReportItem(DOC_MDP_CHECK, SIGNATURE_REVISION_NOT_FOUND, ReportItemStatus.INVALID)); } return report; } @@ -292,15 +325,38 @@ void validateRevision(DocumentRevision previousRevision, DocumentRevision curren documentWithoutRevision, documentWithRevision, currentRevision))); } + private void mergeRevisionsInLinearizedDocument(PdfDocument document, List documentRevisions) { + if (documentRevisions.size() > 1) { + // We need to check if document is linearized in first revision + // We don't need to populate validation report in case of exceptions, it will happen later + createDocumentAndPerformOperation(documentRevisions.get(0), document, new ValidationReport(), + firstRevisionDocument -> { + if (isLinearizedPdf(document)) { + Set mergedModifiedReferences = + new HashSet<>(documentRevisions.get(0).getModifiedObjects()); + mergedModifiedReferences.addAll(documentRevisions.get(1).getModifiedObjects()); + DocumentRevision mergedRevision = new DocumentRevision( + documentRevisions.get(0).getEofOffset(), + mergedModifiedReferences); + documentRevisions.add(0, mergedRevision); + documentRevisions.remove(1); + documentRevisions.remove(1); + } + return true; + }); + } + } + private boolean validateRevision(ValidationReport validationReport, ValidationContext context, PdfDocument documentWithoutRevision, PdfDocument documentWithRevision, DocumentRevision currentRevision) { - Set indirectReferences = currentRevision.getModifiedObjects(); + usuallyModifiedObjects = new Pair<>(createUsuallyModifiedObjectsSet(documentWithoutRevision), + createUsuallyModifiedObjectsSet(documentWithRevision)); if (!compareCatalogs(documentWithoutRevision, documentWithRevision, validationReport, context)) { return false; } Set currentAllowedReferences = createAllowedReferences(documentWithRevision); Set previousAllowedReferences = createAllowedReferences(documentWithoutRevision); - for (PdfIndirectReference indirectReference : indirectReferences) { + for (PdfIndirectReference indirectReference : currentRevision.getModifiedObjects()) { if (indirectReference.isFree()) { // In this boolean flag we check that reference which is about to be removed is the one which // changed in the new revision. For instance DSS reference was 5 0 obj and changed to be 6 0 obj. @@ -519,18 +575,14 @@ private boolean revisionContainsSignature(DocumentRevision revision, String sign private boolean createDocumentAndPerformOperation(DocumentRevision revision, PdfDocument originalDocument, ValidationReport report, Function operation) { try (InputStream inputStream = createInputStreamFromRevision(originalDocument, revision); - PdfReader reader = new PdfReader(inputStream).setStrictnessLevel(StrictnessLevel.CONSERVATIVE); + PdfReader reader = new PdfReader(inputStream, originalDocument.getReader().getPropertiesCopy()) + .setStrictnessLevel(StrictnessLevel.CONSERVATIVE); PdfDocument documentWithRevision = new PdfDocument(reader, new DocumentProperties().setEventCountingMetaInfo(metaInfo))) { return (boolean) operation.apply(documentWithRevision); } catch (IOException | RuntimeException exception) { - if (isLinearizedPdf(originalDocument)) { - report.addReportItem(new ReportItem(DOC_MDP_CHECK, LINEARIZED_NOT_SUPPORTED, exception, - ReportItemStatus.INDETERMINATE)); - } else { - report.addReportItem(new ReportItem(DOC_MDP_CHECK, REVISIONS_READING_EXCEPTION, exception, - ReportItemStatus.INDETERMINATE)); - } + report.addReportItem(new ReportItem(DOC_MDP_CHECK, REVISIONS_READING_EXCEPTION, exception, + ReportItemStatus.INDETERMINATE)); return false; } } @@ -557,7 +609,7 @@ private boolean compareCatalogs(PdfDocument documentWithoutRevision, PdfDocument removedTaggedObjects = new HashSet<>(); addedTaggedObjects = new HashSet<>(); - if (!comparePdfObjects(previousCatalogCopy, currentCatalogCopy)) { + if (!comparePdfObjects(previousCatalogCopy, currentCatalogCopy, usuallyModifiedObjects)) { report.addReportItem(new ReportItem(DOC_MDP_CHECK, NOT_ALLOWED_CATALOG_CHANGES, ReportItemStatus.INVALID)); return false; } @@ -589,27 +641,12 @@ private boolean compareCatalogs(PdfDocument documentWithoutRevision, PdfDocument if (stopValidation(report, context)) { return result; } - result = result && compareStructTreeRoot(previousCatalog.get(PdfName.StructTreeRoot), + return result && compareStructTreeRoot(previousCatalog.get(PdfName.StructTreeRoot), currentCatalog.get(PdfName.StructTreeRoot), report); - if (stopValidation(report, context)) { - return result; - } - result = result && - compareOutlines(previousCatalog.get(PdfName.Outlines), currentCatalog.get(PdfName.Outlines), report); - - return result; } // Compare catalogs nested methods section: - private boolean compareOutlines(PdfObject previousOutlines, PdfObject currentOutlines, ValidationReport report) { - if (!comparePdfObjects(previousOutlines, currentOutlines)) { - report.addReportItem(new ReportItem(DOC_MDP_CHECK, OUTLINES_MODIFIED, ReportItemStatus.INDETERMINATE)); - return false; - } - return true; - } - private boolean compareStructTreeRoot(PdfObject previousStructTreeRoot, PdfObject currentStructTreeRoot, ValidationReport report) { if (previousStructTreeRoot == currentStructTreeRoot) { @@ -634,7 +671,7 @@ private boolean compareStructTreeRoot(PdfObject previousStructTreeRoot, PdfObjec } } if (!(previousStructTreeRoot instanceof PdfDictionary)) { - if (comparePdfObjects(previousStructTreeRoot, currentStructTreeRoot)) { + if (comparePdfObjects(previousStructTreeRoot, currentStructTreeRoot, usuallyModifiedObjects)) { return true; } else { report.addReportItem( @@ -656,7 +693,7 @@ private boolean compareStructTreeRoot(PdfObject previousStructTreeRoot, PdfObjec previousStructTreeRootDict.remove(PdfName.K); currentStructTreeRootDict.remove(PdfName.K); // Everything else is expected to remain unmodified and compared directly. - if (!comparePdfObjects(previousStructTreeRootDict, currentStructTreeRootDict)) { + if (!comparePdfObjects(previousStructTreeRootDict, currentStructTreeRootDict, usuallyModifiedObjects)) { report.addReportItem(new ReportItem(DOC_MDP_CHECK, STRUCT_TREE_ROOT_MODIFIED, ReportItemStatus.INVALID)); return false; } @@ -763,7 +800,7 @@ private boolean compareStructTreeElements(PdfDictionary previousStructElement, P currentStructElementCopy.remove(PdfName.P); currentStructElementCopy.remove(PdfName.Ref); currentStructElementCopy.remove(PdfName.Pg); - if (!comparePdfObjects(previousStructElementCopy, currentStructElementCopy)) { + if (!comparePdfObjects(previousStructElementCopy, currentStructElementCopy, usuallyModifiedObjects)) { report.addReportItem(new ReportItem(DOC_MDP_CHECK, STRUCT_TREE_ELEMENT_MODIFIED, ReportItemStatus.INVALID)); return false; } @@ -786,7 +823,8 @@ private boolean compareStructTreeContents(PdfObject previousStructTreeContent, P PdfDictionary currentContentDictionaryCopy = new PdfDictionary(currentContentDictionary); currentContentDictionaryCopy.remove(PdfName.Pg); currentContentDictionaryCopy.remove(PdfName.Obj); - if (!comparePdfObjects(previousContentDictionaryCopy, currentContentDictionaryCopy)) { + if (!comparePdfObjects(previousContentDictionaryCopy, currentContentDictionaryCopy, + usuallyModifiedObjects)) { report.addReportItem(new ReportItem( DOC_MDP_CHECK, STRUCT_TREE_CONTENT_MODIFIED, ReportItemStatus.INVALID)); return false; @@ -796,13 +834,14 @@ private boolean compareStructTreeContents(PdfObject previousStructTreeContent, P && compareIndirectReferencesObjNums(previousContentDictionary.get(PdfName.Obj), currentContentDictionary.get(PdfName.Obj), report, "Object reference dictionary obj entry"); } else { - return comparePdfObjects(previousStructTreeContent, currentStructTreeContent); + return comparePdfObjects(previousStructTreeContent, currentStructTreeContent, usuallyModifiedObjects); } } private boolean compareExtensions(PdfObject previousExtensions, PdfObject currentExtensions, ValidationReport report) { - if (previousExtensions == null || comparePdfObjects(previousExtensions, currentExtensions)) { + if (previousExtensions == null || + comparePdfObjects(previousExtensions, currentExtensions, usuallyModifiedObjects)) { return true; } if (currentExtensions == null) { @@ -830,7 +869,7 @@ private boolean compareExtensions(PdfObject previousExtensions, PdfObject curren previousExtensionCopy.remove(PdfName.ExtensionLevel); previousExtensionCopy.remove(PdfName.BaseVersion); // Apart from extension level and base version dictionaries are expected to be equal. - if (!comparePdfObjects(previousExtensionCopy, currentExtensionCopy)) { + if (!comparePdfObjects(previousExtensionCopy, currentExtensionCopy, usuallyModifiedObjects)) { report.addReportItem(new ReportItem(DOC_MDP_CHECK, MessageFormatUtil.format( DEVELOPER_EXTENSION_REMOVED, previousExtension.getKey()), ReportItemStatus.INVALID)); result = false; @@ -870,7 +909,7 @@ private boolean compareExtensions(PdfObject previousExtensions, PdfObject curren } private boolean comparePermissions(PdfObject previousPerms, PdfObject currentPerms, ValidationReport report) { - if (previousPerms == null || comparePdfObjects(previousPerms, currentPerms)) { + if (previousPerms == null || comparePdfObjects(previousPerms, currentPerms, usuallyModifiedObjects)) { return true; } if (currentPerms == null) { @@ -959,7 +998,7 @@ private boolean compareFormFieldWithFieldMDP(PdfDictionary previousField, PdfDic currentFieldCopy.remove(PdfName.P); currentFieldCopy.remove(PdfName.Parent); currentFieldCopy.remove(PdfName.V); - if (!comparePdfObjects(previousFieldCopy, currentFieldCopy)) { + if (!comparePdfObjects(previousFieldCopy, currentFieldCopy, usuallyModifiedObjects)) { report.addReportItem(new ReportItem(FIELD_MDP_CHECK, MessageFormatUtil.format( LOCKED_FIELD_MODIFIED, fieldName), ReportItemStatus.INVALID)); return false; @@ -973,7 +1012,7 @@ private boolean compareFormFieldWithFieldMDP(PdfDictionary previousField, PdfDic LOCKED_FIELD_MODIFIED, fieldName), ReportItemStatus.INVALID)); return false; } - } else if (!comparePdfObjects(prevValue, currValue)) { + } else if (!comparePdfObjects(prevValue, currValue, usuallyModifiedObjects)) { report.addReportItem(new ReportItem(FIELD_MDP_CHECK, MessageFormatUtil.format( LOCKED_FIELD_MODIFIED, fieldName), ReportItemStatus.INVALID)); return false; @@ -1058,7 +1097,7 @@ private boolean compareAcroForms(PdfDictionary prevAcroForm, PdfDictionary currA PdfArray prevFields = prevAcroForm.getAsArray(PdfName.Fields); PdfArray currFields = currAcroForm.getAsArray(PdfName.Fields); - if (!comparePdfObjects(previousAcroFormCopy, currentAcroFormCopy) || + if (!comparePdfObjects(previousAcroFormCopy, currentAcroFormCopy, usuallyModifiedObjects) || (prevFields.size() > currFields.size()) || !compareFormFields(prevFields, currFields, report)) { report.addReportItem(new ReportItem(DOC_MDP_CHECK, NOT_ALLOWED_ACROFORM_CHANGES, ReportItemStatus.INVALID)); @@ -1101,7 +1140,7 @@ private PdfDictionary retrieveTheSameField(Set currFields, PdfDic for (PdfDictionary currentField : currFields) { PdfDictionary prevFormDict = copyFieldDictionary(previousField); PdfDictionary currFormDict = copyFieldDictionary(currentField); - if (comparePdfObjects(prevFormDict, currFormDict) && + if (comparePdfObjects(prevFormDict, currFormDict, usuallyModifiedObjects) && compareIndirectReferencesObjNums(prevFormDict.get(PdfName.Parent), currFormDict.get(PdfName.Parent), new ValidationReport(), "Form field parent") && compareIndirectReferencesObjNums(prevFormDict.get(PdfName.P), currFormDict.get(PdfName.P), @@ -1140,7 +1179,7 @@ private boolean compareFields(PdfDictionary previousField, PdfDictionary current return false; } } else if (getAccessPermissions() == AccessPermissions.NO_CHANGES_PERMITTED - && !comparePdfObjects(prevValue, currValue)) { + && !comparePdfObjects(prevValue, currValue, usuallyModifiedObjects)) { return false; } @@ -1162,7 +1201,7 @@ private boolean compareSignatureDictionaries(PdfObject prevSigDict, PdfObject cu PdfDictionary previousSigDictCopy = new PdfDictionary((PdfDictionary) prevSigDict); previousSigDictCopy.remove(PdfName.Reference); // Apart from the reference, dictionaries are expected to be equal. - if (!comparePdfObjects(previousSigDictCopy, currentSigDictCopy)) { + if (!comparePdfObjects(previousSigDictCopy, currentSigDictCopy, usuallyModifiedObjects)) { return false; } PdfArray previousReference = ((PdfDictionary) prevSigDict).getAsArray(PdfName.Reference); @@ -1172,7 +1211,8 @@ private boolean compareSignatureDictionaries(PdfObject prevSigDict, PdfObject cu private boolean compareSignatureReferenceDictionaries(PdfArray previousReferences, PdfArray currentReferences, ValidationReport report) { - if (previousReferences == null || comparePdfObjects(previousReferences, currentReferences)) { + if (previousReferences == null || + comparePdfObjects(previousReferences, currentReferences, usuallyModifiedObjects)) { return true; } if (currentReferences == null || previousReferences.size() != currentReferences.size()) { @@ -1186,7 +1226,7 @@ private boolean compareSignatureReferenceDictionaries(PdfArray previousReference previousReferenceCopy.remove(PdfName.Data); // Apart from the data, dictionaries are expected to be equal. Data is an indirect reference // to the object in the document upon which the object modification analysis should be performed. - if (!comparePdfObjects(previousReferenceCopy, currentReferenceCopy) || + if (!comparePdfObjects(previousReferenceCopy, currentReferenceCopy, usuallyModifiedObjects) || !compareIndirectReferencesObjNums(previousReferences.getAsDictionary(i).get(PdfName.Data), currentReferences.getAsDictionary(i).get(PdfName.Data), report, "Data entry in the signature reference dictionary")) { @@ -1213,7 +1253,7 @@ private boolean compareWidgets(PdfArray prevFields, PdfArray currFields, Validat removeAppearanceRelatedProperties(prevAnnot); PdfDictionary currAnnot = new PdfDictionary(currAnnots.get(i)); removeAppearanceRelatedProperties(currAnnot); - if (!comparePdfObjects(prevAnnot, currAnnot) || + if (!comparePdfObjects(prevAnnot, currAnnot, usuallyModifiedObjects) || !compareIndirectReferencesObjNums( prevAnnots.get(i).get(PdfName.P), currAnnots.get(i).get(PdfName.P), report, "Page object with which annotation is associated") || @@ -1243,7 +1283,7 @@ private boolean comparePages(PdfDictionary prevPages, PdfDictionary currPages, V PdfDictionary currentPagesCopy = new PdfDictionary(currPages); currentPagesCopy.remove(PdfName.Kids); currentPagesCopy.remove(PdfName.Parent); - if (!comparePdfObjects(previousPagesCopy, currentPagesCopy) || + if (!comparePdfObjects(previousPagesCopy, currentPagesCopy, usuallyModifiedObjects) || !compareIndirectReferencesObjNums(prevPages.get(PdfName.Parent), currPages.get(PdfName.Parent), report, "Page tree node parent")) { report.addReportItem(new ReportItem(DOC_MDP_CHECK, PAGES_MODIFIED, ReportItemStatus.INVALID)); @@ -1274,8 +1314,9 @@ private boolean comparePages(PdfDictionary prevPages, PdfDictionary currPages, V currentPageCopy.remove(PdfName.Annots); currentPageCopy.remove(PdfName.Parent); currentPageCopy.remove(PdfName.StructParents); - if (!comparePdfObjects(previousPageCopy, currentPageCopy) || !compareIndirectReferencesObjNums( - previousKid.get(PdfName.Parent), currentKid.get(PdfName.Parent), report, "Page parent")) { + if (!comparePdfObjects(previousPageCopy, currentPageCopy, usuallyModifiedObjects) || + !compareIndirectReferencesObjNums(previousKid.get(PdfName.Parent), + currentKid.get(PdfName.Parent), report, "Page parent")) { report.addReportItem(new ReportItem(DOC_MDP_CHECK, PAGE_MODIFIED, ReportItemStatus.INVALID)); return false; } @@ -1357,7 +1398,7 @@ private boolean comparePageAnnotations(PdfDictionary prevAnnot, PdfDictionary cu currAnnotCopy.remove(PdfName.V); } } - return comparePdfObjects(prevAnnotCopy, currAnnotCopy) && + return comparePdfObjects(prevAnnotCopy, currAnnotCopy, usuallyModifiedObjects) && compareIndirectReferencesObjNums(prevAnnot.get(PdfName.P), currAnnot.get(PdfName.P), report, "Page object with which annotation is associated") && compareIndirectReferencesObjNums(prevAnnot.get(PdfName.Parent), currAnnot.get(PdfName.Parent), report, @@ -1470,7 +1511,7 @@ private PdfDictionary copyCatalogEntriesToCompare(PdfDictionary catalog) { catalogCopy.remove(PdfName.AcroForm); catalogCopy.remove(PdfName.Pages); catalogCopy.remove(PdfName.StructTreeRoot); - catalogCopy.remove(PdfName.Outlines); + catalogCopy.remove(PdfName.Version); return catalogCopy; } @@ -1518,12 +1559,14 @@ private void removeAppearanceRelatedProperties(PdfDictionary annotDict) { // // - private static boolean comparePdfObjects(PdfObject pdfObject1, PdfObject pdfObject2) { - return comparePdfObjects(pdfObject1, pdfObject2, new ArrayList<>()); + private static boolean comparePdfObjects(PdfObject pdfObject1, PdfObject pdfObject2, + Pair, Set> usuallyModifiedObjects) { + return comparePdfObjects(pdfObject1, pdfObject2, new ArrayList<>(), usuallyModifiedObjects); } private static boolean comparePdfObjects(PdfObject pdfObject1, PdfObject pdfObject2, - List> visitedObjects) { + List> visitedObjects, + Pair, Set> usuallyModifiedObjects) { for (Pair pair : visitedObjects) { if (pair.getKey() == pdfObject1) { return pair.getValue() == pdfObject2; @@ -1539,6 +1582,16 @@ private static boolean comparePdfObjects(PdfObject pdfObject1, PdfObject pdfObje if (pdfObject1.getClass() != pdfObject2.getClass()) { return false; } + if (pdfObject1.getIndirectReference() != null && + usuallyModifiedObjects.getKey().stream().anyMatch( + reference -> isSameReference(reference, pdfObject1.getIndirectReference())) && + pdfObject2.getIndirectReference() != null && + usuallyModifiedObjects.getValue().stream().anyMatch( + reference -> isSameReference(reference, pdfObject2.getIndirectReference()))) { + // These two objects are expected to not be completely equal, we check them independently. + // However, we still need to make sure those are same instances. + return isSameReference(pdfObject1.getIndirectReference(), pdfObject2.getIndirectReference()); + } // We don't allow objects to change from being direct to indirect and vice versa. // Acrobat allows it, but such change can invalidate the document. if (pdfObject1.getIndirectReference() == null ^ pdfObject2.getIndirectReference() == null) { @@ -1554,26 +1607,29 @@ private static boolean comparePdfObjects(PdfObject pdfObject1, PdfObject pdfObje return pdfObject1.equals(pdfObject2); case PdfObject.INDIRECT_REFERENCE: return comparePdfObjects(((PdfIndirectReference) pdfObject1).getRefersTo(), - ((PdfIndirectReference) pdfObject2).getRefersTo(), visitedObjects); + ((PdfIndirectReference) pdfObject2).getRefersTo(), visitedObjects, usuallyModifiedObjects); case PdfObject.ARRAY: - return comparePdfArrays((PdfArray) pdfObject1, (PdfArray) pdfObject2, visitedObjects); + return comparePdfArrays((PdfArray) pdfObject1, (PdfArray) pdfObject2, visitedObjects, + usuallyModifiedObjects); case PdfObject.DICTIONARY: return comparePdfDictionaries((PdfDictionary) pdfObject1, (PdfDictionary) pdfObject2, - visitedObjects); + visitedObjects, usuallyModifiedObjects); case PdfObject.STREAM: - return comparePdfStreams((PdfStream) pdfObject1, (PdfStream) pdfObject2, visitedObjects); + return comparePdfStreams((PdfStream) pdfObject1, (PdfStream) pdfObject2, visitedObjects, + usuallyModifiedObjects); default: return false; } } private static boolean comparePdfArrays(PdfArray array1, PdfArray array2, - List> visitedObjects) { + List> visitedObjects, + Pair, Set> usuallyModifiedObjects) { if (array1.size() != array2.size()) { return false; } for (int i = 0; i < array1.size(); i++) { - if (!comparePdfObjects(array1.get(i), array2.get(i), visitedObjects)) { + if (!comparePdfObjects(array1.get(i), array2.get(i), visitedObjects, usuallyModifiedObjects)) { return false; } } @@ -1581,7 +1637,8 @@ private static boolean comparePdfArrays(PdfArray array1, PdfArray array2, } private static boolean comparePdfDictionaries(PdfDictionary dictionary1, PdfDictionary dictionary2, - List> visitedObjects) { + List> visitedObjects, + Pair, Set> usuallyModifiedObjects) { Set> entrySet1 = dictionary1.entrySet(); Set> entrySet2 = dictionary2.entrySet(); if (entrySet1.size() != entrySet2.size()) { @@ -1589,7 +1646,7 @@ private static boolean comparePdfDictionaries(PdfDictionary dictionary1, PdfDict } for (Map.Entry entry1 : entrySet1) { if (!entrySet2.stream().anyMatch(entry2 -> entry2.getKey().equals(entry1.getKey()) && - comparePdfObjects(entry2.getValue(), entry1.getValue(), visitedObjects))) { + comparePdfObjects(entry2.getValue(), entry1.getValue(), visitedObjects, usuallyModifiedObjects))) { return false; } } @@ -1597,9 +1654,10 @@ private static boolean comparePdfDictionaries(PdfDictionary dictionary1, PdfDict } private static boolean comparePdfStreams(PdfStream stream1, PdfStream stream2, - List> visitedObjects) { + List> visitedObjects, + Pair, Set> usuallyModifiedObjects) { return Arrays.equals(stream1.getBytes(), stream2.getBytes()) && - comparePdfDictionaries(stream1, stream2, visitedObjects); + comparePdfDictionaries(stream1, stream2, visitedObjects, usuallyModifiedObjects); } private static boolean isSameReference(PdfIndirectReference indirectReference1, @@ -1624,6 +1682,62 @@ private static boolean isMaxGenerationObject(PdfIndirectReference indirectRefere // // + private Set createUsuallyModifiedObjectsSet(PdfDocument document) { + Set usuallyModifiedObjectsSet = new HashSet<>(); + usuallyModifiedObjectsSet.add(document.getCatalog().getPdfObject().getIndirectReference()); + PdfDictionary catalog = document.getCatalog().getPdfObject(); + + if (catalog.get(PdfName.Pages) != null) { + usuallyModifiedObjectsSet.add(catalog.get(PdfName.Pages).getIndirectReference()); + if (catalog.getAsDictionary(PdfName.Pages) != null) { + addPageEntriesToSet(catalog.getAsDictionary(PdfName.Pages), usuallyModifiedObjectsSet); + } + } + if (catalog.get(PdfName.StructTreeRoot) != null) { + usuallyModifiedObjectsSet.add(catalog.get(PdfName.StructTreeRoot).getIndirectReference()); + if (catalog.getAsDictionary(PdfName.StructTreeRoot) != null && + catalog.getAsDictionary(PdfName.StructTreeRoot).get(PdfName.K) != null) { + addStructTreeElementsToSet(catalog.getAsDictionary(PdfName.StructTreeRoot).get(PdfName.K), + usuallyModifiedObjectsSet); + } + } + return usuallyModifiedObjectsSet; + } + + private void addStructTreeElementsToSet(PdfObject structTreeRootKids, Set set) { + if (structTreeRootKids instanceof PdfArray) { + set.add(structTreeRootKids.getIndirectReference()); + addStructTreeElementsToSet((PdfArray) structTreeRootKids, set); + } else { + addStructTreeElementsToSet(new PdfArray(structTreeRootKids), set); + } + } + + private void addStructTreeElementsToSet(PdfArray structTreeRootKids, Set set) { + for (PdfObject kid : structTreeRootKids) { + if (kid != null) { + set.add(kid.getIndirectReference()); + if (isStructTreeElement(kid) && ((PdfDictionary) kid).get(PdfName.K) != null) { + addStructTreeElementsToSet(((PdfDictionary) kid).get(PdfName.K), set); + } + } + } + } + + private void addPageEntriesToSet(PdfDictionary page, Set set) { + PdfArray kids = page.getAsArray(PdfName.Kids); + if (kids != null) { + set.add(kids.getIndirectReference()); + for (int i = 0; i < kids.size(); ++i) { + set.add(kids.get(i).getIndirectReference()); + PdfDictionary pageNode = kids.getAsDictionary(i); + if (pageNode != null && PdfName.Pages.equals(pageNode.getAsName(PdfName.Type))) { + addPageEntriesToSet(pageNode, set); + } + } + } + } + private Set createAllowedReferences(PdfDocument document) { // Each indirect reference in the set is an allowed reference to be present in the new xref table // or the same entry in the previous document. diff --git a/sign/src/main/java/com/itextpdf/signatures/validation/OCSPValidator.java b/sign/src/main/java/com/itextpdf/signatures/validation/OCSPValidator.java new file mode 100644 index 0000000000..7f0c451b08 --- /dev/null +++ b/sign/src/main/java/com/itextpdf/signatures/validation/OCSPValidator.java @@ -0,0 +1,360 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.signatures.validation; + +import com.itextpdf.bouncycastleconnector.BouncyCastleFactoryCreator; +import com.itextpdf.commons.bouncycastle.IBouncyCastleFactory; +import com.itextpdf.commons.bouncycastle.asn1.IASN1Encodable; +import com.itextpdf.commons.bouncycastle.cert.ocsp.IBasicOCSPResp; +import com.itextpdf.commons.bouncycastle.cert.ocsp.ICertificateStatus; +import com.itextpdf.commons.bouncycastle.cert.ocsp.IRevokedStatus; +import com.itextpdf.commons.bouncycastle.cert.ocsp.ISingleResp; +import com.itextpdf.commons.utils.DateTimeUtil; +import com.itextpdf.commons.utils.MessageFormatUtil; +import com.itextpdf.signatures.CertificateUtil; +import com.itextpdf.signatures.IssuingCertificateRetriever; +import com.itextpdf.signatures.TimestampConstants; +import com.itextpdf.signatures.logs.SignLogMessageConstant; +import com.itextpdf.signatures.validation.context.CertificateSource; +import com.itextpdf.signatures.validation.context.ValidationContext; +import com.itextpdf.signatures.validation.context.ValidatorContext; +import com.itextpdf.signatures.validation.report.CertificateReportItem; +import com.itextpdf.signatures.validation.report.ReportItem; +import com.itextpdf.signatures.validation.report.ReportItem.ReportItemStatus; +import com.itextpdf.signatures.validation.report.ValidationReport; +import com.itextpdf.signatures.validation.report.ValidationReport.ValidationResult; + +import java.security.cert.Certificate; +import java.security.cert.X509Certificate; +import java.time.Duration; +import java.util.Collections; +import java.util.Date; +import java.util.List; +import java.util.Set; + +/** + * Class that allows you to validate a single OCSP response. + */ +public class OCSPValidator { + static final String CERT_IS_EXPIRED = "Certificate is expired on {0}. Its revocation status could have been " + + "removed from the database, so the OCSP response status could be falsely valid."; + static final String CERT_IS_REVOKED = "Certificate status is revoked."; + static final String CERT_STATUS_IS_UNKNOWN = "Certificate status is unknown."; + static final String INVALID_OCSP = "OCSP response is invalid."; + static final String ISSUERS_DO_NOT_MATCH = "OCSP: Issuers don't match."; + static final String ISSUER_MISSING = "Issuer certificate wasn't found."; + static final String FRESHNESS_CHECK = + "OCSP response is not fresh enough: " + "this update: {0}, validation date: {1}, freshness: {2}."; + static final String OCSP_COULD_NOT_BE_VERIFIED = "OCSP response could not be verified: " + + "it does not contain responder in the certificate chain and response is not signed " + + "by issuer certificate or any from the trusted store."; + static final String OCSP_RESPONDER_NOT_RETRIEVED = "OCSP response could not be verified: \" +\n" + + " \"Unexpected exception occurred retrieving responder."; + static final String OCSP_RESPONDER_NOT_VERIFIED = "OCSP response could not be verified: \" +\n" + + " \" Unexpected exception occurred while validating responder certificate."; + + static final String OCSP_RESPONDER_DID_NOT_SIGN = "OCSP response could not be verified against this responder."; + + static final String OCSP_RESPONDER_TRUST_NOT_RETRIEVED = "OCSP response could not be verified: \" +\n" + + " \"responder trust state could not be retrieved."; + static final String OCSP_RESPONDER_TRUSTED = "Responder certificate is a trusted certificate."; + static final String OCSP_RESPONDER_IS_CA = "Responder certificate is the CA certificate."; + static final String OCSP_IS_NO_LONGER_VALID = "OCSP is no longer valid: {0} after {1}"; + static final String SERIAL_NUMBERS_DO_NOT_MATCH = "OCSP: Serial numbers don't match."; + static final String UNABLE_TO_CHECK_IF_ISSUERS_MATCH = "OCSP response could not be verified: Unexpected exception" + + " occurred checking if issuers match."; + + static final String UNABLE_TO_RETRIEVE_ISSUER = "OCSP response could not be verified: Unexpected exception " + + "occurred while retrieving issuer"; + + static final String OCSP_CHECK = "OCSP response check."; + + private static final IBouncyCastleFactory BOUNCY_CASTLE_FACTORY = BouncyCastleFactoryCreator.getFactory(); + + private final IssuingCertificateRetriever certificateRetriever; + private final SignatureValidationProperties properties; + private final ValidatorChainBuilder builder; + + /** + * Creates new {@link OCSPValidator} instance. + * + * @param builder See {@link ValidatorChainBuilder} + */ + protected OCSPValidator(ValidatorChainBuilder builder) { + this.certificateRetriever = builder.getCertificateRetriever(); + this.properties = builder.getProperties(); + this.builder = builder; + } + + /** + * Validates a certificate against single OCSP Response. + * + * @param report to store all the chain verification results + * @param context the context in which to perform the validation + * @param certificate the certificate to check for + * @param singleResp single response to check + * @param ocspResp basic OCSP response which contains single response to check + * @param validationDate validation date to check for + * @param responseGenerationDate trusted date at which response is generated + */ + public void validate(ValidationReport report, ValidationContext context, X509Certificate certificate, + ISingleResp singleResp, IBasicOCSPResp ocspResp, Date validationDate, Date responseGenerationDate) { + ValidationContext localContext = context.setValidatorContext(ValidatorContext.OCSP_VALIDATOR); + if (CertificateUtil.isSelfSigned(certificate)) { + report.addReportItem( + new CertificateReportItem(certificate, OCSP_CHECK, RevocationDataValidator.SELF_SIGNED_CERTIFICATE, + ReportItemStatus.INFO)); + return; + } + // SingleResp contains the basic information of the status of the certificate identified by the certID. + // Check if the serial numbers of the signCert and certID corresponds: + if (!certificate.getSerialNumber().equals(singleResp.getCertID().getSerialNumber())) { + report.addReportItem(new CertificateReportItem(certificate, OCSP_CHECK, SERIAL_NUMBERS_DO_NOT_MATCH, + ReportItemStatus.INDETERMINATE)); + return; + } + List issuerCerts; + try { + issuerCerts = certificateRetriever.retrieveIssuerCertificate(certificate); + } catch (RuntimeException e) { + report.addReportItem(new CertificateReportItem(certificate, OCSP_CHECK, UNABLE_TO_RETRIEVE_ISSUER, e, + ReportItemStatus.INDETERMINATE)); + return; + } + if (issuerCerts.isEmpty()) { + report.addReportItem(new CertificateReportItem(certificate, OCSP_CHECK, MessageFormatUtil.format( + ISSUER_MISSING, certificate.getSubjectX500Principal()), ReportItemStatus.INDETERMINATE)); + return; + } + ValidationReport[] candidateReports = new ValidationReport[issuerCerts.size()]; + for (int i = 0; i < issuerCerts.size(); i++) { + candidateReports[i] = new ValidationReport(); + // Check if the issuer of the certID and signCert matches, i.e. check that issuerNameHash and issuerKeyHash + // fields of the certID is the hash of the issuer's name and public key: + try { + if (!CertificateUtil.checkIfIssuersMatch(singleResp.getCertID(), issuerCerts.get(i))) { + candidateReports[i].addReportItem(new CertificateReportItem(certificate, OCSP_CHECK, + ISSUERS_DO_NOT_MATCH, ReportItemStatus.INDETERMINATE)); + continue; + } + } catch (Exception e) { + candidateReports[i].addReportItem( + new CertificateReportItem(certificate, OCSP_CHECK, UNABLE_TO_CHECK_IF_ISSUERS_MATCH, e, + ReportItemStatus.INDETERMINATE)); + continue; + } + // So, since the issuer name and serial number identify a unique certificate, we found the single response + // for the provided certificate. + + Duration freshness = properties.getFreshness(localContext); + // Check that thisUpdate + freshness < validation. + if (DateTimeUtil.addMillisToDate(singleResp.getThisUpdate(), (long) freshness.toMillis()) + .before(validationDate)) { + candidateReports[i].addReportItem(new CertificateReportItem(certificate, OCSP_CHECK, + MessageFormatUtil.format(FRESHNESS_CHECK, singleResp.getThisUpdate(), validationDate, + freshness), + ReportItemStatus.INDETERMINATE)); + continue; + } + + // If nextUpdate is not set, the responder is indicating that newer revocation information + // is available all the time. + if (singleResp.getNextUpdate() != TimestampConstants.UNDEFINED_TIMESTAMP_DATE && validationDate.after( + singleResp.getNextUpdate())) { + candidateReports[i].addReportItem(new CertificateReportItem(certificate, OCSP_CHECK, + MessageFormatUtil.format(OCSP_IS_NO_LONGER_VALID, validationDate, singleResp.getNextUpdate()), + ReportItemStatus.INDETERMINATE)); + continue; + } + + // Check the status of the certificate: + ICertificateStatus status = singleResp.getCertStatus(); + IRevokedStatus revokedStatus = BOUNCY_CASTLE_FACTORY.createRevokedStatus(status); + boolean isStatusGood = BOUNCY_CASTLE_FACTORY.createCertificateStatus().getGood().equals(status); + + // Check OCSP Archive Cutoff extension in case OCSP response was generated after the certificate is expired. + if (isStatusGood && certificate.getNotAfter().before(ocspResp.getProducedAt())) { + Date startExpirationDate = getArchiveCutoffExtension(ocspResp); + if (TimestampConstants.UNDEFINED_TIMESTAMP_DATE == startExpirationDate || certificate.getNotAfter() + .before(startExpirationDate)) { + candidateReports[i].addReportItem(new CertificateReportItem(certificate, OCSP_CHECK, + MessageFormatUtil.format(CERT_IS_EXPIRED, certificate.getNotAfter()), + ReportItemStatus.INDETERMINATE)); + continue; + } + } + + if (isStatusGood || (revokedStatus != null && validationDate.before(revokedStatus.getRevocationTime()))) { + // Check if the OCSP response is genuine. + verifyOcspResponder(candidateReports[i], localContext, ocspResp, issuerCerts.get(i), + responseGenerationDate); + if (!isStatusGood) { + candidateReports[i].addReportItem(new CertificateReportItem(certificate, OCSP_CHECK, + MessageFormatUtil.format(SignLogMessageConstant.VALID_CERTIFICATE_IS_REVOKED, + revokedStatus.getRevocationTime()), ReportItemStatus.INFO)); + } + } else if (revokedStatus != null) { + candidateReports[i].addReportItem( + new CertificateReportItem(certificate, OCSP_CHECK, CERT_IS_REVOKED, ReportItemStatus.INVALID)); + } else { + candidateReports[i].addReportItem(new CertificateReportItem(certificate, OCSP_CHECK, + CERT_STATUS_IS_UNKNOWN, ReportItemStatus.INDETERMINATE)); + } + if (candidateReports[i].getValidationResult() == ValidationResult.VALID) { + // We found valid issuer, no need to try other ones. + report.merge(candidateReports[i]); + return; + } + } + // Valid issuer wasn't found, add all the reports + for (ValidationReport candidateReport : candidateReports) { + report.merge(candidateReport); + } + } + + /** + * Verifies if an OCSP response is genuine. + * If it doesn't verify against the issuer certificate and response's certificates, it may verify + * using a trusted anchor or cert. + * + * @param report to store all the chain verification results + * @param context the context in which to perform the validation + * @param ocspResp {@link IBasicOCSPResp} the OCSP response wrapper + * @param issuerCert the issuer of the certificate for which the OCSP is checked + */ + private void verifyOcspResponder(ValidationReport report, ValidationContext context, IBasicOCSPResp ocspResp, + X509Certificate issuerCert, Date responseGenerationDate) { + ValidationContext localContext = context.setCertificateSource(CertificateSource.OCSP_ISSUER); + // OCSP response might be signed by the issuer certificate or + // the Authorized OCSP responder certificate containing the id-kp-OCSPSigning extended key usage extension. + + // First check if the issuer certificate signed the response since it is expected to be the most common case: + // the CA will already be validated by the chain validator + if (CertificateUtil.isSignatureValid(ocspResp, issuerCert)) { + report.addReportItem(new CertificateReportItem(issuerCert, OCSP_CHECK, OCSP_RESPONDER_IS_CA, + ReportItemStatus.INFO)); + return; + } + + // If the issuer certificate didn't sign the ocsp response, look for authorized ocsp responses + // from the properties or from the certificate chain received with response. + Set candidates = SafeCalling.onRuntimeExceptionLog( + () -> certificateRetriever.retrieveOCSPResponderByNameCertificate(ocspResp), + Collections.emptySet(), report, + e -> new CertificateReportItem(issuerCert, OCSP_CHECK, OCSP_RESPONDER_NOT_RETRIEVED, e, + ReportItemStatus.INDETERMINATE)); + + if (candidates.isEmpty()) { + report.addReportItem(new CertificateReportItem(issuerCert, OCSP_CHECK, OCSP_COULD_NOT_BE_VERIFIED, + ReportItemStatus.INDETERMINATE)); + return; + } + ValidationReport[] candidateReports = new ValidationReport[candidates.size()]; + int reportIndex = 0; + for (Certificate cert : candidates) { + X509Certificate responderCert = (X509Certificate) cert; + ValidationReport candidateReport = new ValidationReport(); + candidateReports[reportIndex++] = candidateReport; + + // if the response was not signed by this candidate we can stop further processing + if (!CertificateUtil.isSignatureValid(ocspResp, responderCert)) { + candidateReport.addReportItem(new CertificateReportItem(responderCert, + OCSP_CHECK, OCSP_RESPONDER_DID_NOT_SIGN, ReportItemStatus.INDETERMINATE)); + continue; + } + + // if the responder is trusted validation is successful + try { + if (certificateRetriever.getTrustedCertificatesStore().isCertificateTrustedForOcsp(responderCert) + || certificateRetriever.getTrustedCertificatesStore().isCertificateGenerallyTrusted(responderCert)) { + candidateReport.addReportItem(new CertificateReportItem(responderCert, + OCSP_CHECK, OCSP_RESPONDER_TRUSTED, ReportItemStatus.INFO)); + report.merge(candidateReport); + return; + } + } catch (RuntimeException e) { + report.addReportItem(new CertificateReportItem(responderCert, OCSP_CHECK, + OCSP_RESPONDER_TRUST_NOT_RETRIEVED, e, + ReportItemStatus.INDETERMINATE)); + continue; + } + + // RFC 6960 4.2.2.2. Authorized Responders: + // "Systems relying on OCSP responses MUST recognize a delegation certificate as being issued + // by the CA that issued the certificate in question only if the delegation certificate and the + // certificate being checked for revocation were signed by the same key." + // and "This certificate MUST be issued directly by the CA that is identified in the request". + try { + responderCert.verify(issuerCert.getPublicKey()); + } catch (Exception e) { + candidateReport.addReportItem(new CertificateReportItem(responderCert, OCSP_CHECK, INVALID_OCSP, e, + ReportItemStatus.INVALID)); + continue; + } + + // Validating of the ocsp signer's certificate (responderCert) described in the + // RFC6960 4.2.2.2.1. Revocation Checking of an Authorized Responder. + ValidationReport responderReport = new ValidationReport(); + try { + builder.getCertificateChainValidator() + .validate(responderReport, localContext, responderCert, responseGenerationDate); + } catch (RuntimeException e) { + candidateReport.addReportItem( + new CertificateReportItem(responderCert, OCSP_CHECK, OCSP_RESPONDER_NOT_VERIFIED, e, + ReportItemStatus.INDETERMINATE)); + continue; + } + addResponderValidationReport(candidateReport, responderReport); + if (candidateReport.getValidationResult() == ValidationResult.VALID) { + addResponderValidationReport(report, candidateReport); + return; + } + } + //if we get here, none of the candidates were successful + for (ValidationReport subReport : candidateReports) { + report.merge(subReport); + } + } + + private static void addResponderValidationReport(ValidationReport report, ValidationReport responderReport) { + for (ReportItem reportItem : responderReport.getLogs()) { + report.addReportItem(ReportItemStatus.INVALID == reportItem.getStatus() ? reportItem.setStatus( + ReportItemStatus.INDETERMINATE) : reportItem); + } + } + + private Date getArchiveCutoffExtension(IBasicOCSPResp ocspResp) { + // OCSP containing this extension specifies the reliable revocation status of the certificate + // that expired after the date specified in the Archive Cutoff extension or at that date. + IASN1Encodable archiveCutoff = ocspResp.getExtensionParsedValue( + BOUNCY_CASTLE_FACTORY.createOCSPObjectIdentifiers().getIdPkixOcspArchiveCutoff()); + if (!archiveCutoff.isNull()) { + try { + return BOUNCY_CASTLE_FACTORY.createASN1GeneralizedTime(archiveCutoff).getDate(); + } catch (Exception e) { + // Ignore exception. + } + } + return (Date) TimestampConstants.UNDEFINED_TIMESTAMP_DATE; + } +} diff --git a/sign/src/main/java/com/itextpdf/signatures/validation/v1/RevocationDataValidator.java b/sign/src/main/java/com/itextpdf/signatures/validation/RevocationDataValidator.java similarity index 77% rename from sign/src/main/java/com/itextpdf/signatures/validation/v1/RevocationDataValidator.java rename to sign/src/main/java/com/itextpdf/signatures/validation/RevocationDataValidator.java index 50ae9459e0..44b4cfb8b0 100644 --- a/sign/src/main/java/com/itextpdf/signatures/validation/v1/RevocationDataValidator.java +++ b/sign/src/main/java/com/itextpdf/signatures/validation/RevocationDataValidator.java @@ -20,7 +20,7 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.signatures.validation.v1; +package com.itextpdf.signatures.validation; import com.itextpdf.bouncycastleconnector.BouncyCastleFactoryCreator; import com.itextpdf.commons.bouncycastle.IBouncyCastleFactory; @@ -28,21 +28,21 @@ This file is part of the iText (R) project. import com.itextpdf.commons.bouncycastle.cert.ocsp.ISingleResp; import com.itextpdf.commons.utils.DateTimeUtil; import com.itextpdf.commons.utils.MessageFormatUtil; +import com.itextpdf.kernel.crypto.OID; import com.itextpdf.signatures.CertificateUtil; import com.itextpdf.signatures.CrlClientOnline; import com.itextpdf.signatures.ICrlClient; import com.itextpdf.signatures.IOcspClient; import com.itextpdf.signatures.IssuingCertificateRetriever; -import com.itextpdf.signatures.OID; import com.itextpdf.signatures.OcspClientBouncyCastle; -import com.itextpdf.signatures.validation.v1.context.CertificateSource; -import com.itextpdf.signatures.validation.v1.context.TimeBasedContext; -import com.itextpdf.signatures.validation.v1.context.ValidationContext; -import com.itextpdf.signatures.validation.v1.context.ValidatorContext; -import com.itextpdf.signatures.validation.v1.report.CertificateReportItem; -import com.itextpdf.signatures.validation.v1.report.ReportItem; -import com.itextpdf.signatures.validation.v1.report.ReportItem.ReportItemStatus; -import com.itextpdf.signatures.validation.v1.report.ValidationReport; +import com.itextpdf.signatures.validation.context.CertificateSource; +import com.itextpdf.signatures.validation.context.TimeBasedContext; +import com.itextpdf.signatures.validation.context.ValidationContext; +import com.itextpdf.signatures.validation.context.ValidatorContext; +import com.itextpdf.signatures.validation.report.CertificateReportItem; +import com.itextpdf.signatures.validation.report.ReportItem; +import com.itextpdf.signatures.validation.report.ReportItem.ReportItemStatus; +import com.itextpdf.signatures.validation.report.ValidationReport; import java.io.IOException; import java.security.cert.X509CRL; @@ -54,9 +54,8 @@ This file is part of the iText (R) project. import java.util.List; import java.util.Map; import java.util.stream.Collectors; - -import static com.itextpdf.signatures.validation.v1.SafeCalling.onExceptionLog; -import static com.itextpdf.signatures.validation.v1.SafeCalling.onRuntimeExceptionLog; +import static com.itextpdf.signatures.validation.SafeCalling.onExceptionLog; +import static com.itextpdf.signatures.validation.SafeCalling.onRuntimeExceptionLog; /** * Class that allows you to fetch and validate revocation data for the certificate. @@ -69,6 +68,10 @@ public class RevocationDataValidator { static final String TRUSTED_OCSP_RESPONDER = "Authorized OCSP Responder certificate has id-pkix-ocsp-nocheck " + "extension so it is trusted by the definition and no revocation checking is performed."; static final String VALIDITY_ASSURED = "Certificate is trusted due to validity assured - short term extension."; + static final String NO_REV_AVAILABLE = "noRevAvail extension from RFC 9608 is present on {0} certificate. " + + "Revocation data checks are not required."; + static final String NO_REV_AVAILABLE_CA = "noRevAvail extension from RFC 9608 is present on {0} certificate, " + + "however this certificate is a CA, which is not allowed."; static final String CANNOT_PARSE_OCSP = "OCSP response from \"{0}\" OCSP response cannot be parsed."; static final String CANNOT_PARSE_CRL = @@ -78,6 +81,8 @@ public class RevocationDataValidator { static final String CRL_CLIENT_FAILURE = "Unexpected exception occurred in CRL client \"{0}\"."; static final String OCSP_VALIDATOR_FAILURE = "Unexpected exception occurred in OCSP validator."; static final String CRL_VALIDATOR_FAILURE = "Unexpected exception occurred in CRL validator."; + static final String UNABLE_TO_RETRIEVE_REV_DATA_ONLINE = + "Online revocation data wasn't generated: Unexpected exception occurred."; private static final IBouncyCastleFactory BOUNCY_CASTLE_FACTORY = BouncyCastleFactoryCreator.getFactory(); @@ -151,6 +156,18 @@ public void validate(ValidationReport report, ValidationContext context, X509Cer ReportItemStatus.INFO)); return; } + if (CertificateUtil.getExtensionValueByOid(certificate, OID.X509Extensions.NO_REV_AVAILABLE) != null) { + if (certificate.getBasicConstraints() < 0) { + report.addReportItem(new CertificateReportItem(certificate, REVOCATION_DATA_CHECK, + MessageFormatUtil.format(NO_REV_AVAILABLE, certificate.getSubjectX500Principal()), + ReportItemStatus.INFO)); + } else { + report.addReportItem(new CertificateReportItem(certificate, REVOCATION_DATA_CHECK, + MessageFormatUtil.format(NO_REV_AVAILABLE_CA, certificate.getSubjectX500Principal()), + ReportItemStatus.INDETERMINATE)); + } + return; + } if (CertificateSource.OCSP_ISSUER == localContext.getCertificateSource()) { // Check if Authorised OCSP Responder certificate has id-pkix-ocsp-nocheck extension, in which case we // do not perform revocation check for it. @@ -179,7 +196,12 @@ public void validate(ValidationReport report, ValidationContext context, X509Cer if (ValidationReport.ValidationResult.INDETERMINATE == revDataValidationReport.getValidationResult()) { List onlineCrlResponses = new ArrayList<>(); List onlineOcspResponses = new ArrayList<>(); - tryToFetchRevInfoOnline(report, context, certificate, onlineCrlResponses, onlineOcspResponses); + try { + tryToFetchRevInfoOnline(report, context, certificate, onlineCrlResponses, onlineOcspResponses); + } catch (RuntimeException e) { + report.addReportItem(new CertificateReportItem(certificate, REVOCATION_DATA_CHECK, + UNABLE_TO_RETRIEVE_REV_DATA_ONLINE, e, ReportItemStatus.INFO)); + } if (!onlineCrlResponses.isEmpty() || !onlineOcspResponses.isEmpty()) { // Merge the report excluding NO_REVOCATION_DATA message. for (ReportItem reportItem : revDataValidationReport.getLogs()) { @@ -281,9 +303,9 @@ private List retrieveAllOCSPResponses(ValidationRepo ValidationContext context, X509Certificate certificate) { List ocspResponses = new ArrayList<>(); - X509Certificate issuerCert; + List issuerCerts; try { - issuerCert = (X509Certificate) certificateRetriever.retrieveIssuerCertificate(certificate); + issuerCerts = certificateRetriever.retrieveIssuerCertificate(certificate); } catch (RuntimeException e) { report.addReportItem(new CertificateReportItem(certificate, REVOCATION_DATA_CHECK, ISSUER_RETRIEVAL_FAILED, e, ReportItemStatus.INDETERMINATE)); @@ -298,21 +320,25 @@ private List retrieveAllOCSPResponses(ValidationRepo response.getValue().timeBasedContext); } } else { - byte[] basicOcspRespBytes = null; - basicOcspRespBytes = onRuntimeExceptionLog(() -> - ocspClient.getEncoded(certificate, issuerCert, null), null, report, e -> - new CertificateReportItem(certificate, REVOCATION_DATA_CHECK, - MessageFormatUtil.format(OCSP_CLIENT_FAILURE, ocspClient), e, ReportItemStatus.INFO)); - if (basicOcspRespBytes != null) { - try { - IBasicOCSPResp basicOCSPResp = BOUNCY_CASTLE_FACTORY.createBasicOCSPResp( - BOUNCY_CASTLE_FACTORY.createBasicOCSPResponse(BOUNCY_CASTLE_FACTORY.createASN1Primitive( - basicOcspRespBytes))); - fillOcspResponses(ocspResponses, basicOCSPResp, DateTimeUtil.getCurrentTimeDate(), - TimeBasedContext.PRESENT); - } catch (IOException | RuntimeException e) { - report.addReportItem(new ReportItem(REVOCATION_DATA_CHECK, MessageFormatUtil.format( - CANNOT_PARSE_OCSP, ocspClient), e, ReportItemStatus.INFO)); + for (X509Certificate issuerCert : issuerCerts) { + byte[] basicOcspRespBytes = null; + basicOcspRespBytes = onRuntimeExceptionLog(() -> + ocspClient.getEncoded(certificate, issuerCert, null), null, report, e -> + new CertificateReportItem(certificate, REVOCATION_DATA_CHECK, + MessageFormatUtil.format(OCSP_CLIENT_FAILURE, ocspClient), e, + ReportItemStatus.INFO)); + if (basicOcspRespBytes != null) { + try { + IBasicOCSPResp basicOCSPResp = BOUNCY_CASTLE_FACTORY.createBasicOCSPResp( + BOUNCY_CASTLE_FACTORY.createBasicOCSPResponse( + BOUNCY_CASTLE_FACTORY.createASN1Primitive( + basicOcspRespBytes))); + fillOcspResponses(ocspResponses, basicOCSPResp, DateTimeUtil.getCurrentTimeDate(), + TimeBasedContext.PRESENT); + } catch (IOException | RuntimeException e) { + report.addReportItem(new ReportItem(REVOCATION_DATA_CHECK, MessageFormatUtil.format( + CANNOT_PARSE_OCSP, ocspClient), e, ReportItemStatus.INFO)); + } } } } @@ -320,14 +346,16 @@ private List retrieveAllOCSPResponses(ValidationRepo SignatureValidationProperties.OnlineFetching onlineFetching = properties.getRevocationOnlineFetching( context.setValidatorContext(ValidatorContext.OCSP_VALIDATOR)); if (SignatureValidationProperties.OnlineFetching.ALWAYS_FETCH == onlineFetching) { - onRuntimeExceptionLog(() -> { - IBasicOCSPResp basicOCSPResp = new OcspClientBouncyCastle().getBasicOCSPResp(certificate, - issuerCert, null); - fillOcspResponses(ocspResponses, basicOCSPResp, DateTimeUtil.getCurrentTimeDate(), - TimeBasedContext.PRESENT); - }, report, e -> new CertificateReportItem(certificate, REVOCATION_DATA_CHECK, - MessageFormatUtil.format(OCSP_CLIENT_FAILURE, "OcspClientBouncyCastle"), e, - ReportItemStatus.INDETERMINATE)); + for (X509Certificate issuerCert : issuerCerts) { + onRuntimeExceptionLog(() -> { + IBasicOCSPResp basicOCSPResp = new OcspClientBouncyCastle().getBasicOCSPResp(certificate, + issuerCert, null); + fillOcspResponses(ocspResponses, basicOCSPResp, DateTimeUtil.getCurrentTimeDate(), + TimeBasedContext.PRESENT); + }, report, e -> new CertificateReportItem(certificate, REVOCATION_DATA_CHECK, + MessageFormatUtil.format(OCSP_CLIENT_FAILURE, "OcspClientBouncyCastle"), e, + ReportItemStatus.INDETERMINATE)); + } } return ocspResponses; } @@ -363,19 +391,21 @@ private void tryToFetchRevInfoOnline(ValidationReport report, ValidationContext SignatureValidationProperties.OnlineFetching ocspOnlineFetching = properties.getRevocationOnlineFetching( context.setValidatorContext(ValidatorContext.OCSP_VALIDATOR)); if (SignatureValidationProperties.OnlineFetching.FETCH_IF_NO_OTHER_DATA_AVAILABLE == ocspOnlineFetching) { - onRuntimeExceptionLog(() -> { - IBasicOCSPResp basicOCSPResp = new OcspClientBouncyCastle().getBasicOCSPResp(certificate, - (X509Certificate) certificateRetriever.retrieveIssuerCertificate(certificate), null); - List ocspResponses = new ArrayList<>(); - fillOcspResponses(ocspResponses, basicOCSPResp, DateTimeUtil.getCurrentTimeDate(), - TimeBasedContext.PRESENT); - // Sort all the OCSP responses available based on the most recent revocation data. - onlineOcspResponses.addAll(ocspResponses.stream().sorted((o1, o2) -> - o2.singleResp.getThisUpdate().compareTo(o1.singleResp.getThisUpdate())) - .collect(Collectors.toList())); - }, report, e -> new CertificateReportItem(certificate, REVOCATION_DATA_CHECK, - MessageFormatUtil.format(OCSP_CLIENT_FAILURE, "OcspClientBouncyCastle"), e, - ReportItemStatus.INDETERMINATE)); + for (X509Certificate issuerCert : certificateRetriever.retrieveIssuerCertificate(certificate)) { + onRuntimeExceptionLog(() -> { + IBasicOCSPResp basicOCSPResp = new OcspClientBouncyCastle().getBasicOCSPResp(certificate, + issuerCert, null); + List ocspResponses = new ArrayList<>(); + fillOcspResponses(ocspResponses, basicOCSPResp, DateTimeUtil.getCurrentTimeDate(), + TimeBasedContext.PRESENT); + // Sort all the OCSP responses available based on the most recent revocation data. + onlineOcspResponses.addAll(ocspResponses.stream().sorted((o1, o2) -> + o2.singleResp.getThisUpdate().compareTo(o1.singleResp.getThisUpdate())) + .collect(Collectors.toList())); + }, report, e -> new CertificateReportItem(certificate, REVOCATION_DATA_CHECK, + MessageFormatUtil.format(OCSP_CLIENT_FAILURE, "OcspClientBouncyCastle"), e, + ReportItemStatus.INDETERMINATE)); + } } } diff --git a/sign/src/main/java/com/itextpdf/signatures/validation/v1/SafeCalling.java b/sign/src/main/java/com/itextpdf/signatures/validation/SafeCalling.java similarity index 95% rename from sign/src/main/java/com/itextpdf/signatures/validation/v1/SafeCalling.java rename to sign/src/main/java/com/itextpdf/signatures/validation/SafeCalling.java index 2295a2d62c..e2d4004c8a 100644 --- a/sign/src/main/java/com/itextpdf/signatures/validation/v1/SafeCalling.java +++ b/sign/src/main/java/com/itextpdf/signatures/validation/SafeCalling.java @@ -20,13 +20,13 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.signatures.validation.v1; +package com.itextpdf.signatures.validation; import com.itextpdf.commons.utils.Action; import com.itextpdf.commons.utils.ThrowingAction; import com.itextpdf.commons.utils.ThrowingSupplier; -import com.itextpdf.signatures.validation.v1.report.ReportItem; -import com.itextpdf.signatures.validation.v1.report.ValidationReport; +import com.itextpdf.signatures.validation.report.ReportItem; +import com.itextpdf.signatures.validation.report.ValidationReport; import java.util.function.Function; import java.util.function.Supplier; diff --git a/sign/src/main/java/com/itextpdf/signatures/validation/v1/SignatureValidationProperties.java b/sign/src/main/java/com/itextpdf/signatures/validation/SignatureValidationProperties.java similarity index 94% rename from sign/src/main/java/com/itextpdf/signatures/validation/v1/SignatureValidationProperties.java rename to sign/src/main/java/com/itextpdf/signatures/validation/SignatureValidationProperties.java index 92cddd9fc2..e6e0e07274 100644 --- a/sign/src/main/java/com/itextpdf/signatures/validation/v1/SignatureValidationProperties.java +++ b/sign/src/main/java/com/itextpdf/signatures/validation/SignatureValidationProperties.java @@ -20,7 +20,7 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.signatures.validation.v1; +package com.itextpdf.signatures.validation; import java.time.Duration; import java.util.EnumSet; @@ -29,19 +29,19 @@ This file is part of the iText (R) project. import com.itextpdf.signatures.ICrlClient; import com.itextpdf.signatures.IOcspClient; -import com.itextpdf.signatures.validation.v1.context.CertificateSource; -import com.itextpdf.signatures.validation.v1.context.CertificateSources; -import com.itextpdf.signatures.validation.v1.context.TimeBasedContext; -import com.itextpdf.signatures.validation.v1.context.TimeBasedContexts; -import com.itextpdf.signatures.validation.v1.context.ValidationContext; -import com.itextpdf.signatures.validation.v1.context.ValidatorContext; -import com.itextpdf.signatures.validation.v1.context.ValidatorContexts; -import com.itextpdf.signatures.validation.v1.extensions.CertificateExtension; -import com.itextpdf.signatures.validation.v1.extensions.DynamicBasicConstraintsExtension; -import com.itextpdf.signatures.validation.v1.extensions.ExtendedKeyUsageExtension; -import com.itextpdf.signatures.validation.v1.extensions.KeyUsage; -import com.itextpdf.signatures.validation.v1.extensions.KeyUsageExtension; -import com.itextpdf.signatures.validation.v1.report.ValidationReport.ValidationResult; +import com.itextpdf.signatures.validation.context.CertificateSource; +import com.itextpdf.signatures.validation.context.CertificateSources; +import com.itextpdf.signatures.validation.context.TimeBasedContext; +import com.itextpdf.signatures.validation.context.TimeBasedContexts; +import com.itextpdf.signatures.validation.context.ValidationContext; +import com.itextpdf.signatures.validation.context.ValidatorContext; +import com.itextpdf.signatures.validation.context.ValidatorContexts; +import com.itextpdf.signatures.validation.extensions.CertificateExtension; +import com.itextpdf.signatures.validation.extensions.DynamicBasicConstraintsExtension; +import com.itextpdf.signatures.validation.extensions.ExtendedKeyUsageExtension; +import com.itextpdf.signatures.validation.extensions.KeyUsage; +import com.itextpdf.signatures.validation.extensions.KeyUsageExtension; +import com.itextpdf.signatures.validation.report.ValidationReport.ValidationResult; import java.util.ArrayList; import java.util.Collections; diff --git a/sign/src/main/java/com/itextpdf/signatures/validation/v1/SignatureValidator.java b/sign/src/main/java/com/itextpdf/signatures/validation/SignatureValidator.java similarity index 85% rename from sign/src/main/java/com/itextpdf/signatures/validation/v1/SignatureValidator.java rename to sign/src/main/java/com/itextpdf/signatures/validation/SignatureValidator.java index d085bf832b..376d7c9291 100644 --- a/sign/src/main/java/com/itextpdf/signatures/validation/v1/SignatureValidator.java +++ b/sign/src/main/java/com/itextpdf/signatures/validation/SignatureValidator.java @@ -20,7 +20,7 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.signatures.validation.v1; +package com.itextpdf.signatures.validation; import com.itextpdf.commons.actions.contexts.IMetaInfo; import com.itextpdf.bouncycastleconnector.BouncyCastleFactoryCreator; @@ -30,6 +30,7 @@ This file is part of the iText (R) project. import com.itextpdf.commons.bouncycastle.cert.ocsp.AbstractOCSPException; import com.itextpdf.commons.utils.DateTimeUtil; import com.itextpdf.commons.utils.MessageFormatUtil; +import com.itextpdf.kernel.exceptions.PdfException; import com.itextpdf.kernel.pdf.DocumentProperties; import com.itextpdf.kernel.pdf.PdfArray; import com.itextpdf.kernel.pdf.PdfDictionary; @@ -44,15 +45,15 @@ This file is part of the iText (R) project. import com.itextpdf.signatures.IssuingCertificateRetriever; import com.itextpdf.signatures.PdfPKCS7; import com.itextpdf.signatures.SignatureUtil; -import com.itextpdf.signatures.validation.v1.context.CertificateSource; -import com.itextpdf.signatures.validation.v1.context.TimeBasedContext; -import com.itextpdf.signatures.validation.v1.context.ValidationContext; -import com.itextpdf.signatures.validation.v1.context.ValidatorContext; -import com.itextpdf.signatures.validation.v1.report.CertificateReportItem; -import com.itextpdf.signatures.validation.v1.report.ReportItem; -import com.itextpdf.signatures.validation.v1.report.ReportItem.ReportItemStatus; -import com.itextpdf.signatures.validation.v1.report.ValidationReport; -import com.itextpdf.signatures.validation.v1.report.ValidationReport.ValidationResult; +import com.itextpdf.signatures.validation.context.CertificateSource; +import com.itextpdf.signatures.validation.context.TimeBasedContext; +import com.itextpdf.signatures.validation.context.ValidationContext; +import com.itextpdf.signatures.validation.context.ValidatorContext; +import com.itextpdf.signatures.validation.report.CertificateReportItem; +import com.itextpdf.signatures.validation.report.ReportItem; +import com.itextpdf.signatures.validation.report.ReportItem.ReportItemStatus; +import com.itextpdf.signatures.validation.report.ValidationReport; +import com.itextpdf.signatures.validation.report.ValidationReport.ValidationResult; import java.io.ByteArrayInputStream; import java.io.IOException; @@ -67,8 +68,8 @@ This file is part of the iText (R) project. import java.util.Date; import java.util.List; -import static com.itextpdf.signatures.validation.v1.SafeCalling.onExceptionLog; -import static com.itextpdf.signatures.validation.v1.SafeCalling.onRuntimeExceptionLog; +import static com.itextpdf.signatures.validation.SafeCalling.onExceptionLog; +import static com.itextpdf.signatures.validation.SafeCalling.onRuntimeExceptionLog; /** * Validator class, which is expected to be used for signatures validation. @@ -97,6 +98,10 @@ public class SignatureValidator { static final String REVISIONS_VALIDATION_FAILED = "Unexpected exception occurred during revisions validation."; static final String ADD_KNOWN_CERTIFICATES_FAILED = "Unexpected exception occurred adding known certificates to certificate retriever."; + static final String SIGNATURE_NOT_FOUND = "Document doesn't contain signature field {0}."; + static final String VALIDATION_PERFORMED = "Validation has already been performed. " + + "You should create new SignatureValidator instance for each validation call."; + private static final IBouncyCastleFactory BOUNCY_CASTLE_FACTORY = BouncyCastleFactoryCreator.getFactory(); private ValidationContext validationContext = new ValidationContext(ValidatorContext.SIGNATURE_VALIDATOR, @@ -111,6 +116,8 @@ public class SignatureValidator { private ValidationOcspClient validationOcspClient; private ValidationCrlClient validationCrlClient; + private boolean validationPerformed = false; + /** * Creates new instance of {@link SignatureValidator}. * @@ -144,6 +151,10 @@ public SignatureValidator setEventCountingMetaInfo(IMetaInfo metaInfo) { * @return {@link ValidationReport} which contains detailed validation results */ public ValidationReport validateSignatures() { + if (validationPerformed) { + throw new PdfException(VALIDATION_PERFORMED); + } + validationPerformed = true; ValidationReport report = new ValidationReport(); onRuntimeExceptionLog(() -> { documentRevisionsValidator.setEventCountingMetaInfo(metaInfo); @@ -157,24 +168,36 @@ public ValidationReport validateSignatures() { return report; } - SignatureUtil util = new SignatureUtil(originalDocument); - List signatureNames = util.getSignatureNames(); - Collections.reverse(signatureNames); + return report.merge(validate(null)); + } - for (String fieldName : signatureNames) { - try (PdfDocument doc = new PdfDocument(new PdfReader(util.extractRevision(fieldName)), - new DocumentProperties().setEventCountingMetaInfo(metaInfo))) { - ValidationReport subReport = validateLatestSignature(doc); - report.merge(subReport); - if (stopValidation(report, validationContext)) { - return report; - } - } catch (IOException | RuntimeException e) { - report.addReportItem(new ReportItem(SIGNATURE_VERIFICATION, REVISIONS_RETRIEVAL_FAILED, - e, ReportItemStatus.INDETERMINATE)); - } + /** + * Validate single signature in the document. + * + * @param signatureName name of the signature to validate + * + * @return {@link ValidationReport} which contains detailed validation results. + */ + public ValidationReport validateSignature(String signatureName) { + if (validationPerformed) { + throw new PdfException(VALIDATION_PERFORMED); } - return report; + validationPerformed = true; + ValidationReport report = new ValidationReport(); + onRuntimeExceptionLog(() -> { + documentRevisionsValidator.setEventCountingMetaInfo(metaInfo); + ValidationReport revisionsValidationReport = + documentRevisionsValidator.validateAllDocumentRevisions(validationContext, originalDocument, + signatureName); + report.merge(revisionsValidationReport); + }, report, e -> + new ReportItem(SIGNATURE_VERIFICATION, REVISIONS_VALIDATION_FAILED, e, ReportItemStatus.INDETERMINATE)); + + if (stopValidation(report, validationContext)) { + return report; + } + + return report.merge(validate(signatureName)); } ValidationReport validateLatestSignature(PdfDocument document) { @@ -242,6 +265,42 @@ ValidationReport validateLatestSignature(PdfDocument document) { return validationReport.merge(signatureReport); } + private ValidationReport validate(String signatureName) { + ValidationReport validationReport = new ValidationReport(); + boolean validateSingleSignature = signatureName != null; + + SignatureUtil util = new SignatureUtil(originalDocument); + List signatureNames = util.getSignatureNames(); + Collections.reverse(signatureNames); + + for (String fieldName : signatureNames) { + ValidationReport subReport = new ValidationReport(); + try (PdfDocument doc = new PdfDocument( + new PdfReader(util.extractRevision(fieldName), originalDocument.getReader().getPropertiesCopy()) + .setStrictnessLevel(PdfReader.StrictnessLevel.CONSERVATIVE), + new DocumentProperties().setEventCountingMetaInfo(metaInfo))) { + subReport.merge(validateLatestSignature(doc)); + } catch (IOException | RuntimeException e) { + subReport.addReportItem(new ReportItem(SIGNATURE_VERIFICATION, REVISIONS_RETRIEVAL_FAILED, + e, ReportItemStatus.INDETERMINATE)); + } + if (!validateSingleSignature) { + validationReport.merge(subReport); + if (stopValidation(subReport, validationContext)) { + return validationReport; + } + } else if (fieldName.equals(signatureName)) { + return subReport; + } + } + if (validateSingleSignature) { + validationReport.addReportItem(new ReportItem(SIGNATURE_VERIFICATION, + MessageFormatUtil.format(SIGNATURE_NOT_FOUND, signatureName), + ReportItemStatus.INDETERMINATE)); + } + return validationReport; + } + private void findValidationClients() { for (IOcspClient ocspClient : this.properties.getOcspClients()) { if (ocspClient.getClass() == ValidationOcspClient.class) { diff --git a/sign/src/main/java/com/itextpdf/signatures/validation/v1/TrustedCertificatesStore.java b/sign/src/main/java/com/itextpdf/signatures/validation/TrustedCertificatesStore.java similarity index 50% rename from sign/src/main/java/com/itextpdf/signatures/validation/v1/TrustedCertificatesStore.java rename to sign/src/main/java/com/itextpdf/signatures/validation/TrustedCertificatesStore.java index 0c34f3a729..75d36e6ae8 100644 --- a/sign/src/main/java/com/itextpdf/signatures/validation/v1/TrustedCertificatesStore.java +++ b/sign/src/main/java/com/itextpdf/signatures/validation/TrustedCertificatesStore.java @@ -20,25 +20,26 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.signatures.validation.v1; +package com.itextpdf.signatures.validation; import java.security.cert.Certificate; import java.security.cert.X509Certificate; -import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.HashMap; -import java.util.List; +import java.util.HashSet; import java.util.Map; +import java.util.Set; /** * Trusted certificates storage class to be used to configure trusted certificates in a particular way. */ public class TrustedCertificatesStore { - private final Map generallyTrustedCertificates = new HashMap<>(); - private final Map ocspTrustedCertificates = new HashMap<>(); - private final Map timestampTrustedCertificates = new HashMap<>(); - private final Map crlTrustedCertificates = new HashMap<>(); - private final Map caTrustedCertificates = new HashMap<>(); + private final Map> generallyTrustedCertificates = new HashMap<>(); + private final Map> ocspTrustedCertificates = new HashMap<>(); + private final Map> timestampTrustedCertificates = new HashMap<>(); + private final Map> crlTrustedCertificates = new HashMap<>(); + private final Map> caTrustedCertificates = new HashMap<>(); /** * Add collection of certificates to be trusted for any possible usage. @@ -47,8 +48,7 @@ public class TrustedCertificatesStore { */ public void addGenerallyTrustedCertificates(Collection certificates) { for (Certificate certificate : certificates) { - generallyTrustedCertificates.put(((X509Certificate) certificate) - .getSubjectX500Principal().getName(), certificate); + addCertificateToMap(certificate, generallyTrustedCertificates); } } @@ -61,8 +61,7 @@ public void addGenerallyTrustedCertificates(Collection certificates */ public void addOcspTrustedCertificates(Collection certificates) { for (Certificate certificate : certificates) { - ocspTrustedCertificates.put(((X509Certificate) certificate) - .getSubjectX500Principal().getName(), certificate); + addCertificateToMap(certificate, ocspTrustedCertificates); } } @@ -75,8 +74,7 @@ public void addOcspTrustedCertificates(Collection certificates) { */ public void addCrlTrustedCertificates(Collection certificates) { for (Certificate certificate : certificates) { - crlTrustedCertificates.put(((X509Certificate) certificate) - .getSubjectX500Principal().getName(), certificate); + addCertificateToMap(certificate, crlTrustedCertificates); } } @@ -89,8 +87,7 @@ public void addCrlTrustedCertificates(Collection certificates) { */ public void addTimestampTrustedCertificates(Collection certificates) { for (Certificate certificate : certificates) { - timestampTrustedCertificates.put(((X509Certificate) certificate) - .getSubjectX500Principal().getName(), certificate); + addCertificateToMap(certificate, timestampTrustedCertificates); } } @@ -102,7 +99,7 @@ public void addTimestampTrustedCertificates(Collection certificates */ public void addCATrustedCertificates(Collection certificates) { for (Certificate certificate : certificates) { - caTrustedCertificates.put(((X509Certificate) certificate).getSubjectX500Principal().getName(), certificate); + addCertificateToMap(certificate, caTrustedCertificates); } } @@ -114,10 +111,10 @@ public void addCATrustedCertificates(Collection certificates) { * @return {@code true} is provided certificate is generally trusted, {@code false} otherwise */ public boolean isCertificateGenerallyTrusted(Certificate certificate) { - return generallyTrustedCertificates.containsKey( - ((X509Certificate) certificate).getSubjectX500Principal().getName()); + return mapContainsCertificate(certificate, generallyTrustedCertificates); } + /** * Check if provided certificate is configured to be trusted for OCSP response generation. * @@ -126,7 +123,7 @@ public boolean isCertificateGenerallyTrusted(Certificate certificate) { * @return {@code true} is provided certificate is trusted for OCSP generation, {@code false} otherwise */ public boolean isCertificateTrustedForOcsp(Certificate certificate) { - return ocspTrustedCertificates.containsKey(((X509Certificate) certificate).getSubjectX500Principal().getName()); + return mapContainsCertificate(certificate, ocspTrustedCertificates); } /** @@ -137,7 +134,7 @@ public boolean isCertificateTrustedForOcsp(Certificate certificate) { * @return {@code true} is provided certificate is trusted for CRL generation, {@code false} otherwise */ public boolean isCertificateTrustedForCrl(Certificate certificate) { - return crlTrustedCertificates.containsKey(((X509Certificate) certificate).getSubjectX500Principal().getName()); + return mapContainsCertificate(certificate, crlTrustedCertificates); } /** @@ -148,8 +145,7 @@ public boolean isCertificateTrustedForCrl(Certificate certificate) { * @return {@code true} is provided certificate is trusted for timestamp generation, {@code false} otherwise */ public boolean isCertificateTrustedForTimestamp(Certificate certificate) { - return timestampTrustedCertificates.containsKey( - ((X509Certificate) certificate).getSubjectX500Principal().getName()); + return mapContainsCertificate(certificate, timestampTrustedCertificates); } /** @@ -160,41 +156,42 @@ public boolean isCertificateTrustedForTimestamp(Certificate certificate) { * @return {@code true} is provided certificate is trusted for certificates generation, {@code false} otherwise */ public boolean isCertificateTrustedForCA(Certificate certificate) { - return caTrustedCertificates.containsKey(((X509Certificate) certificate).getSubjectX500Principal().getName()); + return mapContainsCertificate(certificate, caTrustedCertificates); } /** - * Get certificate, if any, which is trusted for any usage, which corresponds to the provided certificate name. + * Get certificates, if any, which is trusted for any usage, which corresponds to the provided certificate name. * * @param certificateName {@link String} certificate name * - * @return {@link Certificate} which corresponds to the provided certificate name + * @return set of {@link Certificate} which correspond to the provided certificate name */ - public Certificate getGenerallyTrustedCertificate(String certificateName) { - return generallyTrustedCertificates.get(certificateName); + public Set getGenerallyTrustedCertificates(String certificateName) { + return generallyTrustedCertificates.getOrDefault(certificateName, Collections.emptySet()); } /** - * Get certificate, if any, which is trusted for OCSP response generation, + * Get certificates, if any, which is trusted for OCSP response generation, * which corresponds to the provided certificate name. * * @param certificateName {@link String} certificate name * - * @return {@link Certificate} which corresponds to the provided certificate name + * @return set of {@link Certificate} which correspond to the provided certificate name */ - public Certificate getCertificateTrustedForOcsp(String certificateName) { - return ocspTrustedCertificates.get(certificateName); + public Set getCertificatesTrustedForOcsp(String certificateName) { + return ocspTrustedCertificates.getOrDefault(certificateName, Collections.emptySet()); } /** - * Get certificate, if any, which is trusted for CRL generation, which corresponds to the provided certificate name. + * Get certificates, if any, which is trusted for CRL generation, + * which corresponds to the provided certificate name. * * @param certificateName {@link String} certificate name * - * @return {@link Certificate} which corresponds to the provided certificate name + * @return set of {@link Certificate} which correspond to the provided certificate name */ - public Certificate getCertificateTrustedForCrl(String certificateName) { - return crlTrustedCertificates.get(certificateName); + public Set getCertificatesTrustedForCrl(String certificateName) { + return crlTrustedCertificates.getOrDefault(certificateName, Collections.emptySet()); } /** @@ -203,58 +200,119 @@ public Certificate getCertificateTrustedForCrl(String certificateName) { * * @param certificateName {@link String} certificate name * - * @return {@link Certificate} which corresponds to the provided certificate name + * @return set of {@link Certificate} which correspond to the provided certificate name */ - public Certificate getCertificateTrustedForTimestamp(String certificateName) { - return timestampTrustedCertificates.get(certificateName); + public Set getCertificatesTrustedForTimestamp(String certificateName) { + return timestampTrustedCertificates.getOrDefault(certificateName, Collections.emptySet()); } /** - * Get certificate, if any, which is trusted to be a CA, which corresponds to the provided certificate name. + * Get certificates, if any, + * which is trusted to be a CA, which corresponds to the provided certificate name. * * @param certificateName {@link String} certificate name * - * @return {@link Certificate} which corresponds to the provided certificate name + * @return set of {@link Certificate} which correspond to the provided certificate name */ - public Certificate getCertificateTrustedForCA(String certificateName) { - return caTrustedCertificates.get(certificateName); + public Set getCertificatesTrustedForCA(String certificateName) { + return caTrustedCertificates.getOrDefault(certificateName, Collections.emptySet()); } /** - * Get certificate, if any, which corresponds to the provided certificate name. + * Get certificates, if any, which corresponds to the provided certificate name. * * @param certificateName {@link String} certificate name * - * @return {@link Certificate} which corresponds to the provided certificate name + * @return set of {@link Certificate} which correspond to the provided certificate name + */ + public Set getKnownCertificates(String certificateName) { + Set result = new HashSet<>(); + addMatched(result, generallyTrustedCertificates, certificateName); + addMatched(result, ocspTrustedCertificates, certificateName); + addMatched(result, crlTrustedCertificates, certificateName); + addMatched(result, timestampTrustedCertificates, certificateName); + addMatched(result, caTrustedCertificates, certificateName); + return result; + } + + /** + * Get all the certificates, which where provided to this storage as trusted certificate. + * + * @return {@link Collection} of {@link Certificate} instances */ - public Certificate getKnownCertificate(String certificateName) { - if (generallyTrustedCertificates.containsKey(certificateName)) { - return generallyTrustedCertificates.get(certificateName); + public Collection getAllTrustedCertificates() { + Set certificates = new HashSet<>(); + for (Set set : generallyTrustedCertificates.values()) { + certificates.addAll(set); } - if (ocspTrustedCertificates.containsKey(certificateName)) { - return ocspTrustedCertificates.get(certificateName); + for (Set set : ocspTrustedCertificates.values()) { + certificates.addAll(set); } - if (crlTrustedCertificates.containsKey(certificateName)) { - return crlTrustedCertificates.get(certificateName); + for (Set set : crlTrustedCertificates.values()) { + certificates.addAll(set); } - if (timestampTrustedCertificates.containsKey(certificateName)) { - return timestampTrustedCertificates.get(certificateName); + for (Set set : timestampTrustedCertificates.values()) { + certificates.addAll(set); } - return caTrustedCertificates.get(certificateName); + for (Set set : caTrustedCertificates.values()) { + certificates.addAll(set); + } + return certificates; } /** - * Get all the certificates, which where provided to this storage as trusted certificate. + * Get all the certificates having name as subject, which where provided to this storage as trusted certificate. * - * @return {@link Collection} of {@link Certificate} instances + * @param name the subject name value for which to retrieve all trusted certificate + * + * @return set of {@link Certificate} which correspond to the provided certificate name */ - public Collection getAllTrustedCertificates() { - List certificates = new ArrayList<>(); - certificates.addAll(generallyTrustedCertificates.values()); - certificates.addAll(ocspTrustedCertificates.values()); - certificates.addAll(crlTrustedCertificates.values()); - certificates.addAll(timestampTrustedCertificates.values()); - certificates.addAll(caTrustedCertificates.values()); + public Set getAllTrustedCertificates(String name) { + Set certificates = new HashSet<>(); + Set set = generallyTrustedCertificates.get(name); + if (set != null) { + certificates.addAll(set); + } + set = ocspTrustedCertificates.get(name); + if (set != null) { + certificates.addAll(set); + } + set = crlTrustedCertificates.get(name); + if (set != null) { + certificates.addAll(set); + } + set = timestampTrustedCertificates.get(name); + if (set != null) { + certificates.addAll(set); + } + set = caTrustedCertificates.get(name); + if (set != null) { + certificates.addAll(set); + } return certificates; } + + + private static void addCertificateToMap(Certificate certificate, Map> map) { + String name = ((X509Certificate) certificate).getSubjectX500Principal().getName(); + + Set set = map.computeIfAbsent(name, k -> new HashSet<>()); + set.add(certificate); + } + + private static boolean mapContainsCertificate(Certificate certificate, Map> map) { + Set set = map.get(((X509Certificate) certificate).getSubjectX500Principal().getName()); + if (set == null) { + return false; + } + return set.contains(certificate); + } + + private static void addMatched(Set target, Map> source, + String certificateName) { + Set subset = source.get(certificateName); + if (subset != null) { + target.addAll(subset); + } + } } diff --git a/sign/src/main/java/com/itextpdf/signatures/validation/v1/ValidationCrlClient.java b/sign/src/main/java/com/itextpdf/signatures/validation/ValidationCrlClient.java similarity index 93% rename from sign/src/main/java/com/itextpdf/signatures/validation/v1/ValidationCrlClient.java rename to sign/src/main/java/com/itextpdf/signatures/validation/ValidationCrlClient.java index bb215f51f6..5d5ba39da8 100644 --- a/sign/src/main/java/com/itextpdf/signatures/validation/v1/ValidationCrlClient.java +++ b/sign/src/main/java/com/itextpdf/signatures/validation/ValidationCrlClient.java @@ -20,11 +20,11 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.signatures.validation.v1; +package com.itextpdf.signatures.validation; import com.itextpdf.signatures.ICrlClient; -import com.itextpdf.signatures.validation.v1.RevocationDataValidator.CrlValidationInfo; -import com.itextpdf.signatures.validation.v1.context.TimeBasedContext; +import com.itextpdf.signatures.validation.RevocationDataValidator.CrlValidationInfo; +import com.itextpdf.signatures.validation.context.TimeBasedContext; import java.security.cert.CRLException; import java.security.cert.CertificateEncodingException; diff --git a/sign/src/main/java/com/itextpdf/signatures/validation/v1/ValidationMetaInfo.java b/sign/src/main/java/com/itextpdf/signatures/validation/ValidationMetaInfo.java similarity index 95% rename from sign/src/main/java/com/itextpdf/signatures/validation/v1/ValidationMetaInfo.java rename to sign/src/main/java/com/itextpdf/signatures/validation/ValidationMetaInfo.java index e2ca1d5cea..3e272a17f9 100644 --- a/sign/src/main/java/com/itextpdf/signatures/validation/v1/ValidationMetaInfo.java +++ b/sign/src/main/java/com/itextpdf/signatures/validation/ValidationMetaInfo.java @@ -20,7 +20,7 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.signatures.validation.v1; +package com.itextpdf.signatures.validation; import com.itextpdf.commons.actions.contexts.IMetaInfo; diff --git a/sign/src/main/java/com/itextpdf/signatures/validation/v1/ValidationOcspClient.java b/sign/src/main/java/com/itextpdf/signatures/validation/ValidationOcspClient.java similarity index 93% rename from sign/src/main/java/com/itextpdf/signatures/validation/v1/ValidationOcspClient.java rename to sign/src/main/java/com/itextpdf/signatures/validation/ValidationOcspClient.java index a6eaa7c50a..a51b945963 100644 --- a/sign/src/main/java/com/itextpdf/signatures/validation/v1/ValidationOcspClient.java +++ b/sign/src/main/java/com/itextpdf/signatures/validation/ValidationOcspClient.java @@ -20,12 +20,12 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.signatures.validation.v1; +package com.itextpdf.signatures.validation; import com.itextpdf.commons.bouncycastle.cert.ocsp.IBasicOCSPResp; import com.itextpdf.signatures.IOcspClient; -import com.itextpdf.signatures.validation.v1.RevocationDataValidator.OcspResponseValidationInfo; -import com.itextpdf.signatures.validation.v1.context.TimeBasedContext; +import com.itextpdf.signatures.validation.RevocationDataValidator.OcspResponseValidationInfo; +import com.itextpdf.signatures.validation.context.TimeBasedContext; import java.io.IOException; import java.security.cert.X509Certificate; diff --git a/sign/src/main/java/com/itextpdf/signatures/validation/v1/ValidatorChainBuilder.java b/sign/src/main/java/com/itextpdf/signatures/validation/ValidatorChainBuilder.java similarity index 62% rename from sign/src/main/java/com/itextpdf/signatures/validation/v1/ValidatorChainBuilder.java rename to sign/src/main/java/com/itextpdf/signatures/validation/ValidatorChainBuilder.java index e23acd8157..e18db21c48 100644 --- a/sign/src/main/java/com/itextpdf/signatures/validation/v1/ValidatorChainBuilder.java +++ b/sign/src/main/java/com/itextpdf/signatures/validation/ValidatorChainBuilder.java @@ -20,13 +20,15 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.signatures.validation.v1; +package com.itextpdf.signatures.validation; import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.signatures.IssuingCertificateRetriever; import java.security.cert.Certificate; +import java.util.ArrayList; import java.util.Collection; +import java.util.function.Supplier; /** * A builder class to construct all necessary parts of a validation chain. @@ -34,12 +36,14 @@ This file is part of the iText (R) project. */ public class ValidatorChainBuilder { private SignatureValidationProperties properties; - private IssuingCertificateRetriever certificateRetriever; - private CertificateChainValidator certificateChainValidator; - private RevocationDataValidator revocationDataValidator; - private OCSPValidator ocspValidator; - private CRLValidator crlValidator; - private DocumentRevisionsValidator documentRevisionsValidator; + private Supplier certificateRetrieverFactory; + private Supplier certificateChainValidatorFactory; + private Supplier revocationDataValidatorFactory; + private Supplier ocspValidatorFactory; + private Supplier crlValidatorFactory; + private Supplier documentRevisionsValidatorFactory; + private Collection trustedCertificates; + private Collection knownCertificates; /** * Create a new {@link SignatureValidator} instance with the current configuration. @@ -104,62 +108,66 @@ public CRLValidator buildCRLValidator() { } /** - * Use this instance of a {@link DocumentRevisionsValidator} in the validation chain. + * Use this factory method to create instances of {@link DocumentRevisionsValidator} + * for use in the validation chain. * - * @param documentRevisionsValidator the document revisions validator instance to use + * @param documentRevisionsValidatorFactory the document revisions validator factory method to use * * @return the current ValidatorChainBuilder. */ - public ValidatorChainBuilder withDocumentRevisionsValidator(DocumentRevisionsValidator documentRevisionsValidator) { - this.documentRevisionsValidator = documentRevisionsValidator; + public ValidatorChainBuilder withDocumentRevisionsValidatorFactory( + Supplier documentRevisionsValidatorFactory) { + this.documentRevisionsValidatorFactory = documentRevisionsValidatorFactory; return this; } /** - * Use this instance of a {@link CRLValidator} in the validation chain. + * Use this factory method to create instances of {@link CRLValidator} for use in the validation chain. * - * @param crlValidator the CRLValidator instance to use + * @param crlValidatorFactory the CRLValidatorFactory method to use * * @return the current ValidatorChainBuilder. */ - public ValidatorChainBuilder withCRLValidator(CRLValidator crlValidator) { - this.crlValidator = crlValidator; + public ValidatorChainBuilder withCRLValidatorFactory(Supplier crlValidatorFactory) { + this.crlValidatorFactory = crlValidatorFactory; return this; } /** - * Use this instance of a {@link OCSPValidator} in the validation chain. + * Use this factory method to create instances of {@link OCSPValidator} for use in the validation chain. * - * @param ocspValidator the OCSPValidator instance to use + * @param ocspValidatorFactory the OCSPValidatorFactory method to use * * @return the current ValidatorChainBuilder. */ - public ValidatorChainBuilder withOCSPValidator(OCSPValidator ocspValidator) { - this.ocspValidator = ocspValidator; + public ValidatorChainBuilder withOCSPValidatorFactory(Supplier ocspValidatorFactory) { + this.ocspValidatorFactory = ocspValidatorFactory; return this; } /** - * Use this instance of a {@link RevocationDataValidator} in the validation chain. + * Use this factory method to create instances of {@link RevocationDataValidator} for use in the validation chain. * - * @param revocationDataValidator the RevocationDataValidator instance to use + * @param revocationDataValidatorFactory the RevocationDataValidator factory method to use * * @return the current ValidatorChainBuilder. */ - public ValidatorChainBuilder withRevocationDataValidator(RevocationDataValidator revocationDataValidator) { - this.revocationDataValidator = revocationDataValidator; + public ValidatorChainBuilder withRevocationDataValidatorFactory( + Supplier revocationDataValidatorFactory) { + this.revocationDataValidatorFactory = revocationDataValidatorFactory; return this; } /** - * Use this instance of a {@link CertificateChainValidator} in the validation chain. + * Use this factory method to create instances of {@link CertificateChainValidator} for use in the validation chain. * - * @param certificateChainValidator the CertificateChainValidator instance to use + * @param certificateChainValidatorFactory the CertificateChainValidator factory method to use * * @return the current ValidatorChainBuilder. */ - public ValidatorChainBuilder withCertificateChainValidator(CertificateChainValidator certificateChainValidator) { - this.certificateChainValidator = certificateChainValidator; + public ValidatorChainBuilder withCertificateChainValidatorFactory( + Supplier certificateChainValidatorFactory) { + this.certificateChainValidatorFactory = certificateChainValidatorFactory; return this; } @@ -176,14 +184,16 @@ public ValidatorChainBuilder withSignatureValidationProperties(SignatureValidati } /** - * Use this instance of a {@link IssuingCertificateRetriever} in the validation chain. + * Use this factory method to create instances of {@link IssuingCertificateRetriever} + * for use in the validation chain. * - * @param certificateRetriever the IssuingCertificateRetriever instance to use + * @param certificateRetrieverFactory the IssuingCertificateRetriever factory method to use * * @return the current ValidatorChainBuilder. */ - public ValidatorChainBuilder withIssuingCertificateRetriever(IssuingCertificateRetriever certificateRetriever) { - this.certificateRetriever = certificateRetriever; + public ValidatorChainBuilder withIssuingCertificateRetrieverFactory( + Supplier certificateRetrieverFactory) { + this.certificateRetrieverFactory = certificateRetrieverFactory; return this; } @@ -195,7 +205,7 @@ public ValidatorChainBuilder withIssuingCertificateRetriever(IssuingCertificateR * @return the current ValidatorChainBuilder. */ public ValidatorChainBuilder withKnownCertificates(Collection knownCertificates) { - getCertificateRetriever().addKnownCertificates(knownCertificates); + this.knownCertificates = new ArrayList<>(knownCertificates); return this; } @@ -207,20 +217,44 @@ public ValidatorChainBuilder withKnownCertificates(Collection known * @return the current ValidatorChainBuilder. */ public ValidatorChainBuilder withTrustedCertificates(Collection trustedCertificates) { - getCertificateRetriever().setTrustedCertificates(trustedCertificates); + this.trustedCertificates = new ArrayList<>(trustedCertificates); return this; } + /** + * Retrieves the explicitly added or automatically created {@link IssuingCertificateRetriever} instance. + * + * @return the explicitly added or automatically created {@link IssuingCertificateRetriever} instance. + */ + public IssuingCertificateRetriever getCertificateRetriever() { + if (certificateRetrieverFactory == null) { + return buildIssuingCertificateRetriever(); + } + return certificateRetrieverFactory.get(); + } + + /** + * Retrieves the explicitly added or automatically created {@link SignatureValidationProperties} instance. + * + * @return the explicitly added or automatically created {@link SignatureValidationProperties} instance. + */ + public SignatureValidationProperties getProperties() { + if (properties == null) { + properties = new SignatureValidationProperties(); + } + return properties; + } + /** * Retrieves the explicitly added or automatically created {@link DocumentRevisionsValidator} instance. * * @return the explicitly added or automatically created {@link DocumentRevisionsValidator} instance. */ DocumentRevisionsValidator getDocumentRevisionsValidator() { - if (documentRevisionsValidator == null) { - documentRevisionsValidator = buildDocumentRevisionsValidator(); + if (documentRevisionsValidatorFactory == null) { + return buildDocumentRevisionsValidator(); } - return documentRevisionsValidator; + return documentRevisionsValidatorFactory.get(); } /** @@ -229,10 +263,10 @@ DocumentRevisionsValidator getDocumentRevisionsValidator() { * @return the explicitly added or automatically created {@link CertificateChainValidator} instance. */ CertificateChainValidator getCertificateChainValidator() { - if (certificateChainValidator == null) { - certificateChainValidator = buildCertificateChainValidator(); + if (certificateChainValidatorFactory == null) { + return buildCertificateChainValidator(); } - return certificateChainValidator; + return certificateChainValidatorFactory.get(); } /** @@ -241,10 +275,10 @@ CertificateChainValidator getCertificateChainValidator() { * @return the explicitly added or automatically created {@link RevocationDataValidator} instance. */ RevocationDataValidator getRevocationDataValidator() { - if (revocationDataValidator == null) { - revocationDataValidator = buildRevocationDataValidator(); + if (revocationDataValidatorFactory == null) { + return buildRevocationDataValidator(); } - return revocationDataValidator; + return revocationDataValidatorFactory.get(); } /** @@ -253,10 +287,10 @@ RevocationDataValidator getRevocationDataValidator() { * @return the explicitly added or automatically created {@link CRLValidator} instance. */ CRLValidator getCRLValidator() { - if (crlValidator == null) { - crlValidator = buildCRLValidator(); + if (crlValidatorFactory == null) { + return buildCRLValidator(); } - return crlValidator; + return crlValidatorFactory.get(); } /** @@ -265,33 +299,20 @@ CRLValidator getCRLValidator() { * @return the explicitly added or automatically created {@link OCSPValidator} instance. */ OCSPValidator getOCSPValidator() { - if (ocspValidator == null) { - ocspValidator = buildOCSPValidator(); + if (ocspValidatorFactory == null) { + return buildOCSPValidator(); } - return ocspValidator; + return ocspValidatorFactory.get(); } - /** - * Retrieves the explicitly added or automatically created {@link IssuingCertificateRetriever} instance. - * - * @return the explicitly added or automatically created {@link IssuingCertificateRetriever} instance. - */ - public IssuingCertificateRetriever getCertificateRetriever() { - if (certificateRetriever == null) { - certificateRetriever = new IssuingCertificateRetriever(); + private IssuingCertificateRetriever buildIssuingCertificateRetriever() { + IssuingCertificateRetriever result = new IssuingCertificateRetriever(); + if (trustedCertificates != null) { + result.setTrustedCertificates(trustedCertificates); } - return certificateRetriever; - } - - /** - * Retrieves the explicitly added or automatically created {@link SignatureValidationProperties} instance. - * - * @return the explicitly added or automatically created {@link SignatureValidationProperties} instance. - */ - public SignatureValidationProperties getProperties() { - if (properties == null) { - properties = new SignatureValidationProperties(); + if (knownCertificates != null) { + result.addKnownCertificates(knownCertificates); } - return properties; + return result; } } diff --git a/sign/src/main/java/com/itextpdf/signatures/validation/v1/context/CertificateSource.java b/sign/src/main/java/com/itextpdf/signatures/validation/context/CertificateSource.java similarity index 96% rename from sign/src/main/java/com/itextpdf/signatures/validation/v1/context/CertificateSource.java rename to sign/src/main/java/com/itextpdf/signatures/validation/context/CertificateSource.java index 2f3dc0cee5..a06addcba8 100644 --- a/sign/src/main/java/com/itextpdf/signatures/validation/v1/context/CertificateSource.java +++ b/sign/src/main/java/com/itextpdf/signatures/validation/context/CertificateSource.java @@ -20,7 +20,7 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.signatures.validation.v1.context; +package com.itextpdf.signatures.validation.context; /** * This enum lists all possible contexts related to the certificate origin in which a validation may take place diff --git a/sign/src/main/java/com/itextpdf/signatures/validation/v1/context/CertificateSources.java b/sign/src/main/java/com/itextpdf/signatures/validation/context/CertificateSources.java similarity index 98% rename from sign/src/main/java/com/itextpdf/signatures/validation/v1/context/CertificateSources.java rename to sign/src/main/java/com/itextpdf/signatures/validation/context/CertificateSources.java index b7224155e9..56919eadf9 100644 --- a/sign/src/main/java/com/itextpdf/signatures/validation/v1/context/CertificateSources.java +++ b/sign/src/main/java/com/itextpdf/signatures/validation/context/CertificateSources.java @@ -20,7 +20,7 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.signatures.validation.v1.context; +package com.itextpdf.signatures.validation.context; import java.util.EnumSet; diff --git a/sign/src/main/java/com/itextpdf/signatures/validation/v1/context/TimeBasedContext.java b/sign/src/main/java/com/itextpdf/signatures/validation/context/TimeBasedContext.java similarity index 95% rename from sign/src/main/java/com/itextpdf/signatures/validation/v1/context/TimeBasedContext.java rename to sign/src/main/java/com/itextpdf/signatures/validation/context/TimeBasedContext.java index 6da4a671ee..704b27948e 100644 --- a/sign/src/main/java/com/itextpdf/signatures/validation/v1/context/TimeBasedContext.java +++ b/sign/src/main/java/com/itextpdf/signatures/validation/context/TimeBasedContext.java @@ -20,7 +20,7 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.signatures.validation.v1.context; +package com.itextpdf.signatures.validation.context; /** * This enum is used for giving a perspective on a time period at which validation is happening. diff --git a/sign/src/main/java/com/itextpdf/signatures/validation/v1/context/TimeBasedContexts.java b/sign/src/main/java/com/itextpdf/signatures/validation/context/TimeBasedContexts.java similarity index 98% rename from sign/src/main/java/com/itextpdf/signatures/validation/v1/context/TimeBasedContexts.java rename to sign/src/main/java/com/itextpdf/signatures/validation/context/TimeBasedContexts.java index 7bd36443a3..0df64f812b 100644 --- a/sign/src/main/java/com/itextpdf/signatures/validation/v1/context/TimeBasedContexts.java +++ b/sign/src/main/java/com/itextpdf/signatures/validation/context/TimeBasedContexts.java @@ -20,7 +20,7 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.signatures.validation.v1.context; +package com.itextpdf.signatures.validation.context; import java.util.EnumSet; diff --git a/sign/src/main/java/com/itextpdf/signatures/validation/v1/context/ValidationContext.java b/sign/src/main/java/com/itextpdf/signatures/validation/context/ValidationContext.java similarity index 99% rename from sign/src/main/java/com/itextpdf/signatures/validation/v1/context/ValidationContext.java rename to sign/src/main/java/com/itextpdf/signatures/validation/context/ValidationContext.java index 04f3d76719..43f0a666b7 100644 --- a/sign/src/main/java/com/itextpdf/signatures/validation/v1/context/ValidationContext.java +++ b/sign/src/main/java/com/itextpdf/signatures/validation/context/ValidationContext.java @@ -20,7 +20,7 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.signatures.validation.v1.context; +package com.itextpdf.signatures.validation.context; import java.util.Objects; diff --git a/sign/src/main/java/com/itextpdf/signatures/validation/v1/context/ValidatorContext.java b/sign/src/main/java/com/itextpdf/signatures/validation/context/ValidatorContext.java similarity index 83% rename from sign/src/main/java/com/itextpdf/signatures/validation/v1/context/ValidatorContext.java rename to sign/src/main/java/com/itextpdf/signatures/validation/context/ValidatorContext.java index 2f3e01021c..8df7b001e2 100644 --- a/sign/src/main/java/com/itextpdf/signatures/validation/v1/context/ValidatorContext.java +++ b/sign/src/main/java/com/itextpdf/signatures/validation/context/ValidatorContext.java @@ -20,13 +20,13 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.signatures.validation.v1.context; +package com.itextpdf.signatures.validation.context; -import com.itextpdf.signatures.validation.v1.CRLValidator; -import com.itextpdf.signatures.validation.v1.CertificateChainValidator; -import com.itextpdf.signatures.validation.v1.OCSPValidator; -import com.itextpdf.signatures.validation.v1.RevocationDataValidator; -import com.itextpdf.signatures.validation.v1.DocumentRevisionsValidator; +import com.itextpdf.signatures.validation.CRLValidator; +import com.itextpdf.signatures.validation.CertificateChainValidator; +import com.itextpdf.signatures.validation.OCSPValidator; +import com.itextpdf.signatures.validation.RevocationDataValidator; +import com.itextpdf.signatures.validation.DocumentRevisionsValidator; /** * This enum lists all possible contexts related to the validator in which the validation is taking place. diff --git a/sign/src/main/java/com/itextpdf/signatures/validation/v1/context/ValidatorContexts.java b/sign/src/main/java/com/itextpdf/signatures/validation/context/ValidatorContexts.java similarity index 98% rename from sign/src/main/java/com/itextpdf/signatures/validation/v1/context/ValidatorContexts.java rename to sign/src/main/java/com/itextpdf/signatures/validation/context/ValidatorContexts.java index 74aeb05470..575bc7f519 100644 --- a/sign/src/main/java/com/itextpdf/signatures/validation/v1/context/ValidatorContexts.java +++ b/sign/src/main/java/com/itextpdf/signatures/validation/context/ValidatorContexts.java @@ -20,7 +20,7 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.signatures.validation.v1.context; +package com.itextpdf.signatures.validation.context; import java.util.EnumSet; diff --git a/sign/src/main/java/com/itextpdf/signatures/validation/v1/extensions/CertificateExtension.java b/sign/src/main/java/com/itextpdf/signatures/validation/extensions/CertificateExtension.java similarity index 98% rename from sign/src/main/java/com/itextpdf/signatures/validation/v1/extensions/CertificateExtension.java rename to sign/src/main/java/com/itextpdf/signatures/validation/extensions/CertificateExtension.java index 18c0ca4f69..c00a8b3211 100644 --- a/sign/src/main/java/com/itextpdf/signatures/validation/v1/extensions/CertificateExtension.java +++ b/sign/src/main/java/com/itextpdf/signatures/validation/extensions/CertificateExtension.java @@ -20,7 +20,7 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.signatures.validation.v1.extensions; +package com.itextpdf.signatures.validation.extensions; import com.itextpdf.commons.bouncycastle.asn1.IASN1Primitive; import com.itextpdf.signatures.CertificateUtil; diff --git a/sign/src/main/java/com/itextpdf/signatures/validation/v1/extensions/DynamicBasicConstraintsExtension.java b/sign/src/main/java/com/itextpdf/signatures/validation/extensions/DynamicBasicConstraintsExtension.java similarity index 96% rename from sign/src/main/java/com/itextpdf/signatures/validation/v1/extensions/DynamicBasicConstraintsExtension.java rename to sign/src/main/java/com/itextpdf/signatures/validation/extensions/DynamicBasicConstraintsExtension.java index 77871b02bd..357cc40979 100644 --- a/sign/src/main/java/com/itextpdf/signatures/validation/v1/extensions/DynamicBasicConstraintsExtension.java +++ b/sign/src/main/java/com/itextpdf/signatures/validation/extensions/DynamicBasicConstraintsExtension.java @@ -20,12 +20,12 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.signatures.validation.v1.extensions; +package com.itextpdf.signatures.validation.extensions; import com.itextpdf.bouncycastleconnector.BouncyCastleFactoryCreator; import com.itextpdf.commons.bouncycastle.IBouncyCastleFactory; +import com.itextpdf.kernel.crypto.OID; import com.itextpdf.signatures.CertificateUtil; -import com.itextpdf.signatures.OID; import java.io.IOException; import java.security.cert.X509Certificate; diff --git a/sign/src/main/java/com/itextpdf/signatures/validation/v1/extensions/DynamicCertificateExtension.java b/sign/src/main/java/com/itextpdf/signatures/validation/extensions/DynamicCertificateExtension.java similarity index 97% rename from sign/src/main/java/com/itextpdf/signatures/validation/v1/extensions/DynamicCertificateExtension.java rename to sign/src/main/java/com/itextpdf/signatures/validation/extensions/DynamicCertificateExtension.java index bf52d01885..cd3d67ca7e 100644 --- a/sign/src/main/java/com/itextpdf/signatures/validation/v1/extensions/DynamicCertificateExtension.java +++ b/sign/src/main/java/com/itextpdf/signatures/validation/extensions/DynamicCertificateExtension.java @@ -20,7 +20,7 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.signatures.validation.v1.extensions; +package com.itextpdf.signatures.validation.extensions; import com.itextpdf.commons.bouncycastle.asn1.IASN1Primitive; diff --git a/sign/src/main/java/com/itextpdf/signatures/validation/v1/extensions/ExtendedKeyUsageExtension.java b/sign/src/main/java/com/itextpdf/signatures/validation/extensions/ExtendedKeyUsageExtension.java similarity index 97% rename from sign/src/main/java/com/itextpdf/signatures/validation/v1/extensions/ExtendedKeyUsageExtension.java rename to sign/src/main/java/com/itextpdf/signatures/validation/extensions/ExtendedKeyUsageExtension.java index 409cad7e19..bd1651aab9 100644 --- a/sign/src/main/java/com/itextpdf/signatures/validation/v1/extensions/ExtendedKeyUsageExtension.java +++ b/sign/src/main/java/com/itextpdf/signatures/validation/extensions/ExtendedKeyUsageExtension.java @@ -20,12 +20,12 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.signatures.validation.v1.extensions; +package com.itextpdf.signatures.validation.extensions; import com.itextpdf.bouncycastleconnector.BouncyCastleFactoryCreator; import com.itextpdf.commons.bouncycastle.IBouncyCastleFactory; import com.itextpdf.commons.bouncycastle.asn1.x509.IKeyPurposeId; -import com.itextpdf.signatures.OID; +import com.itextpdf.kernel.crypto.OID; import java.security.cert.CertificateParsingException; import java.security.cert.X509Certificate; diff --git a/sign/src/main/java/com/itextpdf/signatures/validation/v1/extensions/KeyUsage.java b/sign/src/main/java/com/itextpdf/signatures/validation/extensions/KeyUsage.java similarity index 96% rename from sign/src/main/java/com/itextpdf/signatures/validation/v1/extensions/KeyUsage.java rename to sign/src/main/java/com/itextpdf/signatures/validation/extensions/KeyUsage.java index 7b16001ac1..c5bec63dcd 100644 --- a/sign/src/main/java/com/itextpdf/signatures/validation/v1/extensions/KeyUsage.java +++ b/sign/src/main/java/com/itextpdf/signatures/validation/extensions/KeyUsage.java @@ -20,7 +20,7 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.signatures.validation.v1.extensions; +package com.itextpdf.signatures.validation.extensions; /** * Enum representing possible "Key Usage" extension values. diff --git a/sign/src/main/java/com/itextpdf/signatures/validation/v1/extensions/KeyUsageExtension.java b/sign/src/main/java/com/itextpdf/signatures/validation/extensions/KeyUsageExtension.java similarity index 98% rename from sign/src/main/java/com/itextpdf/signatures/validation/v1/extensions/KeyUsageExtension.java rename to sign/src/main/java/com/itextpdf/signatures/validation/extensions/KeyUsageExtension.java index 6b01a5c6f7..45d1355a1f 100644 --- a/sign/src/main/java/com/itextpdf/signatures/validation/v1/extensions/KeyUsageExtension.java +++ b/sign/src/main/java/com/itextpdf/signatures/validation/extensions/KeyUsageExtension.java @@ -20,11 +20,11 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.signatures.validation.v1.extensions; +package com.itextpdf.signatures.validation.extensions; import com.itextpdf.bouncycastleconnector.BouncyCastleFactoryCreator; import com.itextpdf.commons.bouncycastle.IBouncyCastleFactory; -import com.itextpdf.signatures.OID; +import com.itextpdf.kernel.crypto.OID; import java.security.cert.X509Certificate; import java.util.Collections; diff --git a/sign/src/main/java/com/itextpdf/signatures/validation/v1/report/CertificateReportItem.java b/sign/src/main/java/com/itextpdf/signatures/validation/report/CertificateReportItem.java similarity index 98% rename from sign/src/main/java/com/itextpdf/signatures/validation/v1/report/CertificateReportItem.java rename to sign/src/main/java/com/itextpdf/signatures/validation/report/CertificateReportItem.java index 4cb97be0f8..274fa54fe9 100644 --- a/sign/src/main/java/com/itextpdf/signatures/validation/v1/report/CertificateReportItem.java +++ b/sign/src/main/java/com/itextpdf/signatures/validation/report/CertificateReportItem.java @@ -20,7 +20,7 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.signatures.validation.v1.report; +package com.itextpdf.signatures.validation.report; import java.security.cert.X509Certificate; diff --git a/sign/src/main/java/com/itextpdf/signatures/validation/v1/report/ReportItem.java b/sign/src/main/java/com/itextpdf/signatures/validation/report/ReportItem.java similarity index 98% rename from sign/src/main/java/com/itextpdf/signatures/validation/v1/report/ReportItem.java rename to sign/src/main/java/com/itextpdf/signatures/validation/report/ReportItem.java index 0da9734543..8a57155384 100644 --- a/sign/src/main/java/com/itextpdf/signatures/validation/v1/report/ReportItem.java +++ b/sign/src/main/java/com/itextpdf/signatures/validation/report/ReportItem.java @@ -20,7 +20,7 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.signatures.validation.v1.report; +package com.itextpdf.signatures.validation.report; /** * Report item to be used for single failure or log message. diff --git a/sign/src/main/java/com/itextpdf/signatures/validation/v1/report/ValidationReport.java b/sign/src/main/java/com/itextpdf/signatures/validation/report/ValidationReport.java similarity index 97% rename from sign/src/main/java/com/itextpdf/signatures/validation/v1/report/ValidationReport.java rename to sign/src/main/java/com/itextpdf/signatures/validation/report/ValidationReport.java index af7d99d0ae..a90322112f 100644 --- a/sign/src/main/java/com/itextpdf/signatures/validation/v1/report/ValidationReport.java +++ b/sign/src/main/java/com/itextpdf/signatures/validation/report/ValidationReport.java @@ -20,9 +20,9 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.signatures.validation.v1.report; +package com.itextpdf.signatures.validation.report; -import com.itextpdf.signatures.validation.v1.report.ReportItem.ReportItemStatus; +import com.itextpdf.signatures.validation.report.ReportItem.ReportItemStatus; import java.util.ArrayList; import java.util.Collections; diff --git a/sign/src/main/java/com/itextpdf/signatures/validation/v1/OCSPValidator.java b/sign/src/main/java/com/itextpdf/signatures/validation/v1/OCSPValidator.java deleted file mode 100644 index 2f93a9ab24..0000000000 --- a/sign/src/main/java/com/itextpdf/signatures/validation/v1/OCSPValidator.java +++ /dev/null @@ -1,345 +0,0 @@ -/* - This file is part of the iText (R) project. - Copyright (c) 1998-2024 Apryse Group NV - Authors: Apryse Software. - - This program is offered under a commercial and under the AGPL license. - For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. - - AGPL licensing: - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . - */ -package com.itextpdf.signatures.validation.v1; - -import com.itextpdf.bouncycastleconnector.BouncyCastleFactoryCreator; -import com.itextpdf.commons.bouncycastle.IBouncyCastleFactory; -import com.itextpdf.commons.bouncycastle.asn1.IASN1Encodable; -import com.itextpdf.commons.bouncycastle.cert.ocsp.IBasicOCSPResp; -import com.itextpdf.commons.bouncycastle.cert.ocsp.ICertificateStatus; -import com.itextpdf.commons.bouncycastle.cert.ocsp.IRevokedStatus; -import com.itextpdf.commons.bouncycastle.cert.ocsp.ISingleResp; -import com.itextpdf.commons.utils.DateTimeUtil; -import com.itextpdf.commons.utils.MessageFormatUtil; -import com.itextpdf.signatures.CertificateUtil; -import com.itextpdf.signatures.IssuingCertificateRetriever; -import com.itextpdf.signatures.TimestampConstants; -import com.itextpdf.signatures.logs.SignLogMessageConstant; -import com.itextpdf.signatures.validation.v1.context.CertificateSource; -import com.itextpdf.signatures.validation.v1.context.ValidationContext; -import com.itextpdf.signatures.validation.v1.context.ValidatorContext; -import com.itextpdf.signatures.validation.v1.report.CertificateReportItem; -import com.itextpdf.signatures.validation.v1.report.ReportItem; -import com.itextpdf.signatures.validation.v1.report.ReportItem.ReportItemStatus; -import com.itextpdf.signatures.validation.v1.report.ValidationReport; - -import java.security.cert.Certificate; -import java.security.cert.X509Certificate; -import java.time.Duration; -import java.util.Date; - -/** - * Class that allows you to validate a single OCSP response. - */ -public class OCSPValidator { - static final String CERT_IS_EXPIRED = "Certificate is expired on {0}. Its revocation status could have been " + - "removed from the database, so the OCSP response status could be falsely valid."; - static final String CERT_IS_REVOKED = "Certificate status is revoked."; - static final String CERT_STATUS_IS_UNKNOWN = "Certificate status is unknown."; - static final String INVALID_OCSP = "OCSP response is invalid."; - static final String ISSUERS_DO_NOT_MATCH = "OCSP: Issuers don't match."; - static final String FRESHNESS_CHECK = "OCSP response is not fresh enough: " + - "this update: {0}, validation date: {1}, freshness: {2}."; - static final String OCSP_COULD_NOT_BE_VERIFIED = "OCSP response could not be verified: " + - "it does not contain responder in the certificate chain and response is not signed " + - "by issuer certificate or any from the trusted store."; - static final String OCSP_RESPONDER_NOT_RETRIEVED = "OCSP response could not be verified: \" +\n" + - " \"Unexpected exception occurred retrieving responder."; - static final String OCSP_RESPONDER_NOT_VERIFIED = "OCSP response could not be verified: \" +\n" + - " \" Unexpected exception occurred while validating responder certificate."; - static final String OCSP_RESPONDER_TRUST_NOT_RETRIEVED = "OCSP response could not be verified: \" +\n" + - " \"responder trust state could not be retrieved."; - static final String OCSP_IS_NO_LONGER_VALID = "OCSP is no longer valid: {0} after {1}"; - static final String SERIAL_NUMBERS_DO_NOT_MATCH = "OCSP: Serial numbers don't match."; - static final String UNABLE_TO_CHECK_IF_ISSUERS_MATCH = - "OCSP response could not be verified: Unexpected exception occurred checking if issuers match."; - - static final String UNABLE_TO_RETRIEVE_ISSUER = - "OCSP response could not be verified: Unexpected exception occurred while retrieving issuer"; - - static final String OCSP_CHECK = "OCSP response check."; - - private static final IBouncyCastleFactory BOUNCY_CASTLE_FACTORY = BouncyCastleFactoryCreator.getFactory(); - - private final IssuingCertificateRetriever certificateRetriever; - private final SignatureValidationProperties properties; - private final ValidatorChainBuilder builder; - - /** - * Creates new {@link OCSPValidator} instance. - * - * @param builder See {@link ValidatorChainBuilder} - */ - protected OCSPValidator(ValidatorChainBuilder builder) { - this.certificateRetriever = builder.getCertificateRetriever(); - this.properties = builder.getProperties(); - this.builder = builder; - } - - /** - * Validates a certificate against single OCSP Response. - * - * @param report to store all the chain verification results - * @param context the context in which to perform the validation - * @param certificate the certificate to check for - * @param singleResp single response to check - * @param ocspResp basic OCSP response which contains single response to check - * @param validationDate validation date to check for - * - * @deprecated starting from 8.0.5. TODO DEVSIX-8398 To be removed. - */ - @Deprecated - public void validate(ValidationReport report, ValidationContext context, X509Certificate certificate, - ISingleResp singleResp, IBasicOCSPResp ocspResp, Date validationDate) { - validate(report, context, certificate, singleResp, ocspResp, validationDate, DateTimeUtil.getCurrentTimeDate()); - } - - /** - * Validates a certificate against single OCSP Response. - * - * @param report to store all the chain verification results - * @param context the context in which to perform the validation - * @param certificate the certificate to check for - * @param singleResp single response to check - * @param ocspResp basic OCSP response which contains single response to check - * @param validationDate validation date to check for - * @param responseGenerationDate trusted date at which response is generated - */ - public void validate(ValidationReport report, ValidationContext context, X509Certificate certificate, - ISingleResp singleResp, IBasicOCSPResp ocspResp, Date validationDate, Date responseGenerationDate) { - ValidationContext localContext = context.setValidatorContext(ValidatorContext.OCSP_VALIDATOR); - if (CertificateUtil.isSelfSigned(certificate)) { - report.addReportItem(new CertificateReportItem(certificate, OCSP_CHECK, - RevocationDataValidator.SELF_SIGNED_CERTIFICATE, ReportItemStatus.INFO)); - return; - } - // SingleResp contains the basic information of the status of the certificate identified by the certID. - // Check if the serial numbers of the signCert and certID corresponds: - if (!certificate.getSerialNumber().equals(singleResp.getCertID().getSerialNumber())) { - report.addReportItem(new CertificateReportItem(certificate, OCSP_CHECK, SERIAL_NUMBERS_DO_NOT_MATCH, - ReportItemStatus.INDETERMINATE)); - return; - } - Certificate issuerCert; - try { - issuerCert = certificateRetriever.retrieveIssuerCertificate(certificate); - } catch (RuntimeException e) { - report.addReportItem(new CertificateReportItem(certificate, OCSP_CHECK, UNABLE_TO_RETRIEVE_ISSUER, e, - ReportItemStatus.INDETERMINATE)); - return; - } - // Check if the issuer of the certID and signCert matches, i.e. check that issuerNameHash and issuerKeyHash - // fields of the certID is the hash of the issuer's name and public key: - try { - if (!CertificateUtil.checkIfIssuersMatch(singleResp.getCertID(), (X509Certificate) issuerCert)) { - report.addReportItem(new CertificateReportItem(certificate, OCSP_CHECK, ISSUERS_DO_NOT_MATCH, - ReportItemStatus.INDETERMINATE)); - return; - } - } catch (Exception e) { - report.addReportItem(new CertificateReportItem(certificate, OCSP_CHECK, UNABLE_TO_CHECK_IF_ISSUERS_MATCH, e, - ReportItemStatus.INDETERMINATE)); - return; - } - // So, since the issuer name and serial number identify a unique certificate, we found the single response - // for the provided certificate. - - Duration freshness = properties.getFreshness(localContext); - // Check that thisUpdate + freshness < validation. - if (DateTimeUtil.addMillisToDate(singleResp.getThisUpdate(), (long) freshness.toMillis()) - .before(validationDate)) { - report.addReportItem(new CertificateReportItem(certificate, OCSP_CHECK, - MessageFormatUtil.format(FRESHNESS_CHECK, singleResp.getThisUpdate(), validationDate, - freshness), ReportItemStatus.INDETERMINATE)); - return; - } - - // If nextUpdate is not set, the responder is indicating that newer revocation information - // is available all the time. - if (singleResp.getNextUpdate() != TimestampConstants.UNDEFINED_TIMESTAMP_DATE && - validationDate.after(singleResp.getNextUpdate())) { - report.addReportItem(new CertificateReportItem(certificate, OCSP_CHECK, - MessageFormatUtil.format(OCSP_IS_NO_LONGER_VALID, validationDate, - singleResp.getNextUpdate()), ReportItemStatus.INDETERMINATE)); - return; - } - - // Check the status of the certificate: - ICertificateStatus status = singleResp.getCertStatus(); - IRevokedStatus revokedStatus = BOUNCY_CASTLE_FACTORY.createRevokedStatus(status); - boolean isStatusGood = BOUNCY_CASTLE_FACTORY.createCertificateStatus().getGood().equals(status); - - // Check OCSP Archive Cutoff extension in case OCSP response was generated after the certificate is expired. - if (isStatusGood && certificate.getNotAfter().before(ocspResp.getProducedAt())) { - Date startExpirationDate = getArchiveCutoffExtension(ocspResp); - if (TimestampConstants.UNDEFINED_TIMESTAMP_DATE == startExpirationDate || - certificate.getNotAfter().before(startExpirationDate)) { - report.addReportItem(new CertificateReportItem(certificate, OCSP_CHECK, MessageFormatUtil.format( - CERT_IS_EXPIRED, certificate.getNotAfter()), ReportItemStatus.INDETERMINATE)); - return; - } - } - - if (isStatusGood || (revokedStatus != null && validationDate.before(revokedStatus.getRevocationTime()))) { - // Check if the OCSP response is genuine. - verifyOcspResponder(report, localContext, ocspResp, (X509Certificate) issuerCert, responseGenerationDate); - if (!isStatusGood) { - report.addReportItem(new CertificateReportItem(certificate, OCSP_CHECK, - MessageFormatUtil.format(SignLogMessageConstant.VALID_CERTIFICATE_IS_REVOKED, - revokedStatus.getRevocationTime()), ReportItemStatus.INFO)); - } - } else if (revokedStatus != null) { - report.addReportItem(new CertificateReportItem(certificate, OCSP_CHECK, CERT_IS_REVOKED, - ReportItemStatus.INVALID)); - } else { - report.addReportItem(new CertificateReportItem(certificate, OCSP_CHECK, CERT_STATUS_IS_UNKNOWN, - ReportItemStatus.INDETERMINATE)); - } - } - - /** - * Verifies if an OCSP response is genuine. - * If it doesn't verify against the issuer certificate and response's certificates, it may verify - * using a trusted anchor or cert. - * - * @param report to store all the chain verification results - * @param context the context in which to perform the validation - * @param ocspResp {@link IBasicOCSPResp} the OCSP response wrapper - * @param issuerCert the issuer of the certificate for which the OCSP is checked - */ - private void verifyOcspResponder(ValidationReport report, ValidationContext context, IBasicOCSPResp ocspResp, - X509Certificate issuerCert, Date responseGenerationDate) { - ValidationContext localContext = context.setCertificateSource(CertificateSource.OCSP_ISSUER); - ValidationReport responderReport = new ValidationReport(); - - // OCSP response might be signed by the issuer certificate or - // the Authorized OCSP responder certificate containing the id-kp-OCSPSigning extended key usage extension. - X509Certificate responderCert = null; - - // First check if the issuer certificate signed the response since it is expected to be the most common case: - if (CertificateUtil.isSignatureValid(ocspResp, issuerCert)) { - responderCert = issuerCert; - } - - // If the issuer certificate didn't sign the ocsp response, look for authorized ocsp responses - // from the properties or from the certificate chain received with response. - if (responderCert == null) { - try { - responderCert = (X509Certificate) certificateRetriever.retrieveOCSPResponderCertificate(ocspResp); - } catch (RuntimeException e) { - report.addReportItem(new CertificateReportItem(issuerCert, OCSP_CHECK, OCSP_RESPONDER_NOT_RETRIEVED, e, - ReportItemStatus.INDETERMINATE)); - return; - } - if (responderCert == null) { - report.addReportItem(new CertificateReportItem(issuerCert, OCSP_CHECK, OCSP_COULD_NOT_BE_VERIFIED, - ReportItemStatus.INDETERMINATE)); - return; - } - - boolean needsToBeSignedByIssuer = false; - try { - needsToBeSignedByIssuer = (!certificateRetriever.isCertificateTrusted(responderCert) && - !certificateRetriever.getTrustedCertificatesStore().isCertificateTrustedForOcsp(responderCert)); - } catch (RuntimeException e) { - report.addReportItem(new CertificateReportItem(responderCert, OCSP_CHECK, - OCSP_RESPONDER_TRUST_NOT_RETRIEVED, e, - ReportItemStatus.INDETERMINATE)); - return; - } - - if (needsToBeSignedByIssuer) { - // RFC 6960 4.2.2.2. Authorized Responders: - // "Systems relying on OCSP responses MUST recognize a delegation certificate as being issued - // by the CA that issued the certificate in question only if the delegation certificate and the - // certificate being checked for revocation were signed by the same key." - // and "This certificate MUST be issued directly by the CA that is identified in the request". - try { - responderCert.verify(issuerCert.getPublicKey()); - } catch (Exception e) { - report.addReportItem(new CertificateReportItem(responderCert, OCSP_CHECK, INVALID_OCSP, e, - ReportItemStatus.INVALID)); - return; - } - - // Validating of the ocsp signer's certificate (responderCert) described in the - // RFC6960 4.2.2.2.1. Revocation Checking of an Authorized Responder. - try { - builder.getCertificateChainValidator().validate(responderReport, - localContext, - responderCert, responseGenerationDate); - } catch (RuntimeException e) { - report.addReportItem(new CertificateReportItem(responderCert, OCSP_CHECK, - OCSP_RESPONDER_NOT_VERIFIED, e, - ReportItemStatus.INDETERMINATE)); - return; - } - } else { - try { - builder.getCertificateChainValidator().validate(responderReport, - localContext.setCertificateSource(CertificateSource.TRUSTED), - responderCert, responseGenerationDate); - } catch (RuntimeException e) { - report.addReportItem(new CertificateReportItem(responderCert, OCSP_CHECK, - OCSP_RESPONDER_NOT_VERIFIED, e, - ReportItemStatus.INDETERMINATE)); - return; - } - } - } else { - try { - builder.getCertificateChainValidator().validate(responderReport, - localContext.setCertificateSource(CertificateSource.CERT_ISSUER), - responderCert, responseGenerationDate); - } catch (RuntimeException e) { - report.addReportItem(new CertificateReportItem(responderCert, OCSP_CHECK, - OCSP_RESPONDER_NOT_VERIFIED, e, - ReportItemStatus.INDETERMINATE)); - return; - } - } - addResponderValidationReport(report, responderReport); - } - - private static void addResponderValidationReport(ValidationReport report, ValidationReport responderReport) { - for (ReportItem reportItem : responderReport.getLogs()) { - report.addReportItem(ReportItemStatus.INVALID == reportItem.getStatus() ? - reportItem.setStatus(ReportItemStatus.INDETERMINATE) : reportItem); - } - } - - private Date getArchiveCutoffExtension(IBasicOCSPResp ocspResp) { - // OCSP containing this extension specifies the reliable revocation status of the certificate - // that expired after the date specified in the Archive Cutoff extension or at that date. - IASN1Encodable archiveCutoff = ocspResp.getExtensionParsedValue( - BOUNCY_CASTLE_FACTORY.createOCSPObjectIdentifiers().getIdPkixOcspArchiveCutoff()); - if (!archiveCutoff.isNull()) { - try { - return BOUNCY_CASTLE_FACTORY.createASN1GeneralizedTime(archiveCutoff).getDate(); - } catch (Exception e) { - // Ignore exception. - } - } - return (Date) TimestampConstants.UNDEFINED_TIMESTAMP_DATE; - } -} diff --git a/sign/src/main/java/com/itextpdf/signatures/validation/v1/extensions/BasicConstraintsExtension.java b/sign/src/main/java/com/itextpdf/signatures/validation/v1/extensions/BasicConstraintsExtension.java deleted file mode 100644 index d6235309e3..0000000000 --- a/sign/src/main/java/com/itextpdf/signatures/validation/v1/extensions/BasicConstraintsExtension.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - This file is part of the iText (R) project. - Copyright (c) 1998-2024 Apryse Group NV - Authors: Apryse Software. - - This program is offered under a commercial and under the AGPL license. - For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. - - AGPL licensing: - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . - */ -package com.itextpdf.signatures.validation.v1.extensions; - -import com.itextpdf.bouncycastleconnector.BouncyCastleFactoryCreator; -import com.itextpdf.commons.bouncycastle.IBouncyCastleFactory; -import com.itextpdf.signatures.CertificateUtil; -import com.itextpdf.signatures.OID; - -import java.io.IOException; -import java.security.cert.X509Certificate; - -/** - * Class representing "Basic Constraints" certificate extension. - * - * @deprecated since 8.0.5. To be removed. - */ -@Deprecated -public class BasicConstraintsExtension extends CertificateExtension { - private static final IBouncyCastleFactory FACTORY = BouncyCastleFactoryCreator.getFactory(); - - private final int pathLength; - - /** - * Create new {@link BasicConstraintsExtension} instance using provided {@code boolean} value. - * - * @param ca {@code boolean} value, which represents if this certificate is a "Certificate Authority" - */ - public BasicConstraintsExtension(boolean ca) { - super(OID.X509Extensions.BASIC_CONSTRAINTS, FACTORY.createBasicConstraints(ca).toASN1Primitive()); - if (ca) { - this.pathLength = Integer.MAX_VALUE; - } else { - this.pathLength = -1; - } - } - - /** - * Create new {@link BasicConstraintsExtension} instance using provided {@code int} path length. - * - * @param pathLength {@code int} value, which represents acceptable path length for this certificate as a "CA" - */ - public BasicConstraintsExtension(int pathLength) { - super(OID.X509Extensions.BASIC_CONSTRAINTS, FACTORY.createBasicConstraints(pathLength).toASN1Primitive()); - this.pathLength = pathLength; - } - - /** - * Check if this extension is present in the provided certificate. In case of {@link BasicConstraintsExtension}, - * check if path length for this extension is less or equal to the path length, specified in the certificate. - * - * @param certificate {@link X509Certificate} in which this extension shall be present - * - * @return {@code true} if this path length is less or equal to a one from the certificate, {@code false} otherwise - */ - @Override - public boolean existsInCertificate(X509Certificate certificate) { - try { - if (CertificateUtil.getExtensionValue(certificate, OID.X509Extensions.BASIC_CONSTRAINTS) == null) { - return false; - } - } catch (IOException | RuntimeException e) { - return false; - } - if (pathLength >= 0) { - return certificate.getBasicConstraints() >= pathLength; - } - return certificate.getBasicConstraints() < 0; - } -} diff --git a/sign/src/test/java/com/itextpdf/signatures/BouncyCastleDigestUnitTest.java b/sign/src/test/java/com/itextpdf/signatures/BouncyCastleDigestUnitTest.java index 084aa81b7f..48fc9c0e41 100644 --- a/sign/src/test/java/com/itextpdf/signatures/BouncyCastleDigestUnitTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/BouncyCastleDigestUnitTest.java @@ -25,30 +25,29 @@ This file is part of the iText (R) project. import com.itextpdf.bouncycastleconnector.BouncyCastleFactoryCreator; import com.itextpdf.commons.bouncycastle.IBouncyCastleFactory; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.BouncyCastleUnitTest; import java.security.GeneralSecurityException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import org.bouncycastle.crypto.CryptoServicesRegistrar; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(BouncyCastleUnitTest.class) +@Tag("BouncyCastleUnitTest") public class BouncyCastleDigestUnitTest extends ExtendedITextTest { private static final IBouncyCastleFactory FACTORY = BouncyCastleFactoryCreator.getFactory(); @Test public void getMessageDigestMD2Test() { IExternalDigest digest = new BouncyCastleDigest(); - Assert.assertThrows(NoSuchAlgorithmException.class, () -> digest.getMessageDigest("MD2")); + Assertions.assertThrows(NoSuchAlgorithmException.class, () -> digest.getMessageDigest("MD2")); } @Test public void getMessageDigestMD5Test() throws GeneralSecurityException { IExternalDigest digest = new BouncyCastleDigest(); - Assert.assertThrows(NoSuchAlgorithmException.class, () -> digest.getMessageDigest("MD5")); + Assertions.assertThrows(NoSuchAlgorithmException.class, () -> digest.getMessageDigest("MD5")); } @Test @@ -79,7 +78,7 @@ public void getMessageDigestSHA512Test() throws GeneralSecurityException { @Test public void getMessageDigestRIPEMD128Test() throws GeneralSecurityException { if (FACTORY.isInApprovedOnlyMode()) { - Assert.assertThrows(NoSuchAlgorithmException.class, + Assertions.assertThrows(NoSuchAlgorithmException.class, () -> new BouncyCastleDigest().getMessageDigest("RIPEMD128")); } else { getMessageDigestTest("RIPEMD128", "RIPEMD128"); @@ -89,7 +88,7 @@ public void getMessageDigestRIPEMD128Test() throws GeneralSecurityException { @Test public void getMessageDigestRIPEMD160Test() throws GeneralSecurityException { if (FACTORY.isInApprovedOnlyMode()) { - Assert.assertThrows(NoSuchAlgorithmException.class, + Assertions.assertThrows(NoSuchAlgorithmException.class, () -> new BouncyCastleDigest().getMessageDigest("RIPEMD160")); } else { getMessageDigestTest("RIPEMD160", "RIPEMD160"); @@ -99,7 +98,7 @@ public void getMessageDigestRIPEMD160Test() throws GeneralSecurityException { @Test public void getMessageDigestRIPEMD256Test() throws GeneralSecurityException { if (FACTORY.isInApprovedOnlyMode()) { - Assert.assertThrows(NoSuchAlgorithmException.class, + Assertions.assertThrows(NoSuchAlgorithmException.class, () -> new BouncyCastleDigest().getMessageDigest("RIPEMD256")); } else { getMessageDigestTest("RIPEMD256", "RIPEMD256"); @@ -109,7 +108,7 @@ public void getMessageDigestRIPEMD256Test() throws GeneralSecurityException { @Test public void getMessageDigestGOST3411Test() throws GeneralSecurityException { if (FACTORY.isInApprovedOnlyMode()) { - Assert.assertThrows(NoSuchAlgorithmException.class, + Assertions.assertThrows(NoSuchAlgorithmException.class, () -> new BouncyCastleDigest().getMessageDigest("GOST3411")); } else { getMessageDigestTest("GOST3411", "GOST3411"); @@ -119,19 +118,19 @@ public void getMessageDigestGOST3411Test() throws GeneralSecurityException { @Test public void getMessageDigestNullTest() { IExternalDigest digest = new BouncyCastleDigest(); - Assert.assertThrows(IllegalArgumentException.class, () -> digest.getMessageDigest(null)); + Assertions.assertThrows(IllegalArgumentException.class, () -> digest.getMessageDigest(null)); } @Test public void getMessageDigestUnknownTest() { IExternalDigest digest = new BouncyCastleDigest(); - Assert.assertThrows(NoSuchAlgorithmException.class, () -> digest.getMessageDigest("unknown")); + Assertions.assertThrows(NoSuchAlgorithmException.class, () -> digest.getMessageDigest("unknown")); } private static void getMessageDigestTest(String hashAlgorithm, String expectedDigestAlgorithm) throws GeneralSecurityException { MessageDigest digest = new BouncyCastleDigest().getMessageDigest(hashAlgorithm); - Assert.assertNotNull(digest); - Assert.assertEquals(expectedDigestAlgorithm, digest.getAlgorithm()); + Assertions.assertNotNull(digest); + Assertions.assertEquals(expectedDigestAlgorithm, digest.getAlgorithm()); } } diff --git a/sign/src/test/java/com/itextpdf/signatures/CertificateInfoTest.java b/sign/src/test/java/com/itextpdf/signatures/CertificateInfoTest.java index 927910843a..164e188bef 100644 --- a/sign/src/test/java/com/itextpdf/signatures/CertificateInfoTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/CertificateInfoTest.java @@ -26,17 +26,16 @@ This file is part of the iText (R) project. import com.itextpdf.commons.bouncycastle.IBouncyCastleFactory; import com.itextpdf.kernel.exceptions.PdfException; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.BouncyCastleUnitTest; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Map; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(BouncyCastleUnitTest.class) +@Tag("BouncyCastleUnitTest") public class CertificateInfoTest extends ExtendedITextTest { private static final IBouncyCastleFactory FACTORY = BouncyCastleFactoryCreator.getFactory(); @@ -44,7 +43,7 @@ public class CertificateInfoTest extends ExtendedITextTest { @Test public void X500InvalidDirectoryConstructorTest() { - Assert.assertThrows(IllegalArgumentException.class, () -> new CertificateInfo.X500Name("some_dir")); + Assertions.assertThrows(IllegalArgumentException.class, () -> new CertificateInfo.X500Name("some_dir")); } @Test @@ -52,26 +51,26 @@ public void X500ValidDirectoryConstructorTest() { CertificateInfo.X500Name name = new CertificateInfo.X500Name("some=dir,another=dir,some=value"); Map> values = name.getFields(); - Assert.assertEquals(2, values.size()); + Assertions.assertEquals(2, values.size()); - Assert.assertEquals(Arrays.asList("dir", "value"), values.get("SOME")); - Assert.assertEquals(Collections.singletonList("dir"), values.get("ANOTHER")); + Assertions.assertEquals(Arrays.asList("dir", "value"), values.get("SOME")); + Assertions.assertEquals(Collections.singletonList("dir"), values.get("ANOTHER")); } @Test public void X500GetFieldTest() { CertificateInfo.X500Name name = new CertificateInfo.X500Name("some=value,another=dir,some=dir"); - Assert.assertEquals("value", name.getField("SOME")); - Assert.assertEquals("dir", name.getField("ANOTHER")); + Assertions.assertEquals("value", name.getField("SOME")); + Assertions.assertEquals("dir", name.getField("ANOTHER")); } @Test public void X500GetFieldArrayTest() { CertificateInfo.X500Name name = new CertificateInfo.X500Name("some=value,another=dir,some=dir"); - Assert.assertEquals(Arrays.asList("value", "dir"), name.getFieldArray("SOME")); - Assert.assertEquals(Collections.singletonList("dir"), name.getFieldArray("ANOTHER")); + Assertions.assertEquals(Arrays.asList("value", "dir"), name.getFieldArray("SOME")); + Assertions.assertEquals(Collections.singletonList("dir"), name.getFieldArray("ANOTHER")); } @Test @@ -79,21 +78,21 @@ public void X509NameTokenizerNextTokenComplicatedTest() { CertificateInfo.X509NameTokenizer tokenizer = new CertificateInfo.X509NameTokenizer("quoted\",\"comma=escaped\\,comma_escaped\\\"quote"); String token = tokenizer.nextToken(); - Assert.assertEquals("quoted,comma=escaped,comma_escaped\"quote", token); - Assert.assertNull(tokenizer.nextToken()); + Assertions.assertEquals("quoted,comma=escaped,comma_escaped\"quote", token); + Assertions.assertNull(tokenizer.nextToken()); } @Test public void getIssuerFieldsExceptionTest() { Exception exception = - Assert.assertThrows(PdfException.class, () -> CertificateInfo.getIssuer(new byte[] {4, 8, 15, 16, 23, 42})); - Assert.assertEquals(EXPECTED_EXCEPTION_MESSAGE, exception.getCause().getMessage()); + Assertions.assertThrows(PdfException.class, () -> CertificateInfo.getIssuer(new byte[] {4, 8, 15, 16, 23, 42})); + Assertions.assertEquals(EXPECTED_EXCEPTION_MESSAGE, exception.getCause().getMessage()); } @Test public void getSubjectExceptionTest() { Exception exception = - Assert.assertThrows(PdfException.class, () -> CertificateInfo.getSubject(new byte[] {4, 8, 15, 16, 23, 42})); - Assert.assertEquals(EXPECTED_EXCEPTION_MESSAGE, exception.getCause().getMessage()); + Assertions.assertThrows(PdfException.class, () -> CertificateInfo.getSubject(new byte[] {4, 8, 15, 16, 23, 42})); + Assertions.assertEquals(EXPECTED_EXCEPTION_MESSAGE, exception.getCause().getMessage()); } } diff --git a/sign/src/test/java/com/itextpdf/signatures/CertificateSupportedCriticalExtensionsTest.java b/sign/src/test/java/com/itextpdf/signatures/CertificateSupportedCriticalExtensionsTest.java index 08788270a4..a6aeffa0e6 100644 --- a/sign/src/test/java/com/itextpdf/signatures/CertificateSupportedCriticalExtensionsTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/CertificateSupportedCriticalExtensionsTest.java @@ -24,22 +24,21 @@ This file is part of the iText (R) project. import com.itextpdf.bouncycastleconnector.BouncyCastleFactoryCreator; import com.itextpdf.commons.bouncycastle.IBouncyCastleFactory; +import com.itextpdf.kernel.crypto.OID; import com.itextpdf.signatures.testutils.X509MockCertificate; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.BouncyCastleUnitTest; import java.security.Security; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -@Category(BouncyCastleUnitTest.class) +@Tag("BouncyCastleUnitTest") public class CertificateSupportedCriticalExtensionsTest extends ExtendedITextTest { private static final IBouncyCastleFactory BOUNCY_CASTLE_FACTORY = BouncyCastleFactoryCreator.getFactory(); - @BeforeClass + @BeforeAll public static void beforeClass() { Security.addProvider(BOUNCY_CASTLE_FACTORY.getProvider()); } @@ -52,7 +51,7 @@ public void supportedCriticalOIDsTest() { .setCriticalExtensionOIDs(OID.X509Extensions.KEY_USAGE, OID.X509Extensions.BASIC_CONSTRAINTS) .setKeyUsage(true, true); - Assert.assertFalse(SignUtils.hasUnsupportedCriticalExtension(cert)); + Assertions.assertFalse(CertificateVerification.hasUnsupportedCriticalExtension(cert)); } @Test @@ -63,7 +62,7 @@ public void basicConstraintsSupportedTest() { .setCriticalExtensionOIDs(OID.X509Extensions.BASIC_CONSTRAINTS) .setKeyUsage(true, true); - Assert.assertFalse(SignUtils.hasUnsupportedCriticalExtension(cert)); + Assertions.assertFalse(CertificateVerification.hasUnsupportedCriticalExtension(cert)); } @Test @@ -75,7 +74,7 @@ public void extendedKeyUsageWithIdKpTimestampingTest() { .setExtendedKeyUsage(OID.X509Extensions.ID_KP_TIMESTAMPING) .setKeyUsage(true, true); - Assert.assertTrue(SignUtils.hasUnsupportedCriticalExtension(cert)); + Assertions.assertTrue(CertificateVerification.hasUnsupportedCriticalExtension(cert)); } @Test @@ -87,7 +86,7 @@ public void extendedKeyUsageWithoutIdKpTimestampingTest() { .setExtendedKeyUsage("Not ID KP TIMESTAMPING.") .setKeyUsage(true, true); - Assert.assertFalse(SignUtils.hasUnsupportedCriticalExtension(cert)); + Assertions.assertFalse(CertificateVerification.hasUnsupportedCriticalExtension(cert)); } @Test @@ -98,7 +97,7 @@ public void idKpTimestampingWithoutExtendedKeyUsageTest() { .setCriticalExtensionOIDs(OID.X509Extensions.ID_KP_TIMESTAMPING) .setKeyUsage(true, true); - Assert.assertTrue(SignUtils.hasUnsupportedCriticalExtension(cert)); + Assertions.assertTrue(CertificateVerification.hasUnsupportedCriticalExtension(cert)); } @Test @@ -109,7 +108,7 @@ public void unsupportedCriticalOIDsTest() { .setCriticalExtensionOIDs("Totally not supported OID") .setKeyUsage(true, true); - Assert.assertTrue(SignUtils.hasUnsupportedCriticalExtension(cert)); + Assertions.assertTrue(CertificateVerification.hasUnsupportedCriticalExtension(cert)); } @Test @@ -118,14 +117,14 @@ public void noUnsupportedCriticalOIDsTest() { cert.setHasUnsupportedCriticalExtension(false); - Assert.assertFalse(SignUtils.hasUnsupportedCriticalExtension(cert)); + Assertions.assertFalse(CertificateVerification.hasUnsupportedCriticalExtension(cert)); } @Test public void certificateIsNullTest() { - Exception e = Assert.assertThrows(IllegalArgumentException.class, - () -> SignUtils.hasUnsupportedCriticalExtension(null) + Exception e = Assertions.assertThrows(IllegalArgumentException.class, + () -> CertificateVerification.hasUnsupportedCriticalExtension(null) ); - Assert.assertEquals("X509Certificate can't be null.", e.getMessage()); + Assertions.assertEquals("X509Certificate can't be null.", e.getMessage()); } } diff --git a/sign/src/test/java/com/itextpdf/signatures/CertificateUtilTest.java b/sign/src/test/java/com/itextpdf/signatures/CertificateUtilTest.java index 504d4f7631..6a3f6674dd 100644 --- a/sign/src/test/java/com/itextpdf/signatures/CertificateUtilTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/CertificateUtilTest.java @@ -24,20 +24,19 @@ This file is part of the iText (R) project. import com.itextpdf.signatures.testutils.PemFileHelper; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.BouncyCastleUnitTest; import java.io.IOException; import java.security.cert.CRL; import java.security.cert.CRLException; import java.security.cert.CertificateException; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.security.cert.X509Certificate; import java.util.List; -@Category(BouncyCastleUnitTest.class) +@Tag("BouncyCastleUnitTest") public class CertificateUtilTest extends ExtendedITextTest { private static final String CERTS_SRC = "./src/test/resources/com/itextpdf/signatures/certs/"; @@ -48,7 +47,7 @@ public void getTSAURLAdobeExtensionTest() throws Exception { (X509Certificate) PemFileHelper.readFirstChain(CERTS_SRC + "adobeExtensionCert.pem")[0]; String url = CertificateUtil.getTSAURL(tsaCert); - Assert.assertEquals("https://itextpdf.com/en", url); + Assertions.assertEquals("https://itextpdf.com/en", url); } @Test @@ -57,7 +56,7 @@ public void getTSAURLUsualTimestampCertificateTest() throws Exception { (X509Certificate) PemFileHelper.readFirstChain(CERTS_SRC + "tsCertRsa.pem")[0]; String url = CertificateUtil.getTSAURL(tsaCert); - Assert.assertNull(url); + Assertions.assertNull(url); } @Test @@ -65,21 +64,12 @@ public void getTSAURLAdobeExtensionNotTaggedTest() throws Exception { X509Certificate tsaCert = (X509Certificate) PemFileHelper.readFirstChain(CERTS_SRC + "adobeExtensionCertWithoutTag.pem")[0]; - Assert.assertThrows(NullPointerException.class, () -> CertificateUtil.getTSAURL(tsaCert)); + Assertions.assertThrows(NullPointerException.class, () -> CertificateUtil.getTSAURL(tsaCert)); } @Test public void getCRLFromStringNullTest() throws CertificateException, CRLException, IOException { - Assert.assertNull(CertificateUtil.getCRL((String) null)); - } - - @Test - public void getCRLFromCertificateWithoutCRLTest() throws IOException, CertificateException, CRLException { - X509Certificate tsaCert = - (X509Certificate) PemFileHelper.readFirstChain(CERTS_SRC + "rootRsa.pem")[0]; - CRL crl = CertificateUtil.getCRL(tsaCert); - - Assert.assertNull(crl); + Assertions.assertNull(CertificateUtil.getCRL((String) null)); } @Test @@ -88,6 +78,6 @@ public void getCRLsFromCertificateWithoutCRLTest() throws IOException, Certifica (X509Certificate) PemFileHelper.readFirstChain(CERTS_SRC + "rootRsa.pem")[0]; List crls = CertificateUtil.getCRLs(tsaCert); - Assert.assertTrue(crls.isEmpty()); + Assertions.assertTrue(crls.isEmpty()); } } diff --git a/sign/src/test/java/com/itextpdf/signatures/CrlClientOfflineTest.java b/sign/src/test/java/com/itextpdf/signatures/CrlClientOfflineTest.java index 85a032832d..978212ddca 100644 --- a/sign/src/test/java/com/itextpdf/signatures/CrlClientOfflineTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/CrlClientOfflineTest.java @@ -33,18 +33,17 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfStream; import com.itextpdf.signatures.testutils.PemFileHelper; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.IOException; import java.security.GeneralSecurityException; import java.security.cert.CertificateException; import java.security.cert.X509Certificate; import java.util.Collection; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class CrlClientOfflineTest extends ExtendedITextTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/signatures/CrlClientOfflineTest/"; @@ -54,10 +53,10 @@ public class CrlClientOfflineTest extends ExtendedITextTest { @Test public void checkUnknownPdfExceptionWhenCrlIsNull() { - Exception e = Assert.assertThrows(PdfException.class, + Exception e = Assertions.assertThrows(PdfException.class, () -> listOfByteArrays = new CrlClientOffline( BouncyCastleFactoryCreator.getFactory().createNullCrl()).getEncoded(null, "")); - Assert.assertEquals(KernelExceptionMessageConstant.UNKNOWN_PDF_EXCEPTION, e.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.UNKNOWN_PDF_EXCEPTION, e.getMessage()); } @Test @@ -152,7 +151,7 @@ private static void validateCrlBytes(byte[] testBytes, String crlDistPoint) //These checks are enough, because there is exactly one element in the collection, //and these are the same test bytes - Assert.assertEquals(1, listOfByteArrays.size()); - Assert.assertTrue(listOfByteArrays.contains(testBytes)); + Assertions.assertEquals(1, listOfByteArrays.size()); + Assertions.assertTrue(listOfByteArrays.contains(testBytes)); } } diff --git a/sign/src/test/java/com/itextpdf/signatures/DigestAlgorithmsManualTest.java b/sign/src/test/java/com/itextpdf/signatures/DigestAlgorithmsManualTest.java index 668a5449e2..28ae587f4b 100644 --- a/sign/src/test/java/com/itextpdf/signatures/DigestAlgorithmsManualTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/DigestAlgorithmsManualTest.java @@ -22,18 +22,21 @@ This file is part of the iText (R) project. */ package com.itextpdf.signatures; +import com.itextpdf.kernel.crypto.DigestAlgorithms; +import com.itextpdf.kernel.logs.KernelLogMessageConstant; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; +import com.itextpdf.test.annotations.LogMessage; +import com.itextpdf.test.annotations.LogMessages; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.security.GeneralSecurityException; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(UnitTest.class) +@Tag("BouncyCastleUnitTest") public class DigestAlgorithmsManualTest extends ExtendedITextTest { @Test @@ -42,7 +45,7 @@ public void digestSHA1SunPKCS11Test() throws GeneralSecurityException, IOExcepti byte[] hash = DigestAlgorithms.digest(data, DigestAlgorithms.SHA1, "SunPKCS11"); byte[] expected = new byte[] {15, 20, 1, 9, -106, 49, -37, -65, -45, -63, 53, -70, 76, -71, 102, -68, 78, -51, -100, 50}; - Assert.assertArrayEquals(expected, hash); + Assertions.assertArrayEquals(expected, hash); } @Test @@ -53,6 +56,15 @@ public void digestSHA256SUNTest() throws GeneralSecurityException, IOException { byte[] expected = new byte[] {19, -84, -84, -45, -36, 121, -15, -18, -89, 97, -17, 51, 81, 119, -42, -59, -31, 121, -87, -82, -45, 119, 61, 92, 110, -99, 105, 4, 97, 12, 127, -62}; - Assert.assertArrayEquals(expected, hash); + Assertions.assertArrayEquals(expected, hash); + } + + @LogMessages(messages = { + @LogMessage(messageTemplate = KernelLogMessageConstant.ALGORITHM_NOT_FROM_SPEC, ignore = true)}) + @Test + public void notAllowedNameGetAllowedDigestTest() { + String name = "SM3"; + String oid = "1.2.156.10197.1.401"; + Assertions.assertEquals(oid, DigestAlgorithms.getAllowedDigest(name)); } } diff --git a/sign/src/test/java/com/itextpdf/signatures/DigestAlgorithmsTest.java b/sign/src/test/java/com/itextpdf/signatures/DigestAlgorithmsTest.java index 7b8206fe41..6dd4a0159a 100644 --- a/sign/src/test/java/com/itextpdf/signatures/DigestAlgorithmsTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/DigestAlgorithmsTest.java @@ -24,24 +24,24 @@ This file is part of the iText (R) project. import com.itextpdf.bouncycastleconnector.BouncyCastleFactoryCreator; import com.itextpdf.commons.bouncycastle.IBouncyCastleFactory; -import com.itextpdf.signatures.logs.SignLogMessageConstant; +import com.itextpdf.kernel.crypto.DigestAlgorithms; +import com.itextpdf.kernel.logs.KernelLogMessageConstant; import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.BouncyCastleUnitTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; import java.security.Security; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(BouncyCastleUnitTest.class) +@Tag("BouncyCastleUnitTest") public class DigestAlgorithmsTest extends ExtendedITextTest { private static final IBouncyCastleFactory BOUNCY_CASTLE_FACTORY = BouncyCastleFactoryCreator.getFactory(); private static final boolean FIPS_MODE = "BCFIPS".equals(BOUNCY_CASTLE_FACTORY.getProviderName()); - @BeforeClass + @BeforeAll public static void before() { Security.addProvider(BOUNCY_CASTLE_FACTORY.getProvider()); } @@ -49,45 +49,36 @@ public static void before() { @Test public void emptyStringOidGetDigestTest() { String oid = ""; - Assert.assertEquals(oid, DigestAlgorithms.getDigest(oid)); + Assertions.assertEquals(oid, DigestAlgorithms.getDigest(oid)); } @Test public void nonExistingOidGetDigestTest() { String oid = "non_existing_oid"; - Assert.assertEquals(oid, DigestAlgorithms.getDigest(oid)); + Assertions.assertEquals(oid, DigestAlgorithms.getDigest(oid)); } @Test public void emptyStringNameGetAllowedDigestTest() { - Assert.assertNull(DigestAlgorithms.getAllowedDigest("")); + Assertions.assertNull(DigestAlgorithms.getAllowedDigest("")); } @Test public void nonExistingNameGetAllowedDigestTest() { - Assert.assertNull(DigestAlgorithms.getAllowedDigest("non_existing_oid")); + Assertions.assertNull(DigestAlgorithms.getAllowedDigest("non_existing_oid")); } @Test public void nullNameGetAllowedDigestTest() { - Assert.assertThrows(IllegalArgumentException.class, () -> DigestAlgorithms.getAllowedDigest(null)); + Assertions.assertThrows(IllegalArgumentException.class, () -> DigestAlgorithms.getAllowedDigest(null)); } @LogMessages(messages = { - @LogMessage(messageTemplate = SignLogMessageConstant.ALGORITHM_NOT_FROM_SPEC, ignore = true)}) + @LogMessage(messageTemplate = KernelLogMessageConstant.ALGORITHM_NOT_FROM_SPEC, ignore = true)}) @Test public void notAllowedOidGetDigestTest() { String name = "SM3"; String oid = "1.2.156.10197.1.401"; - Assert.assertEquals(FIPS_MODE ? oid : name, DigestAlgorithms.getDigest(oid)); - } - - @LogMessages(messages = { - @LogMessage(messageTemplate = SignLogMessageConstant.ALGORITHM_NOT_FROM_SPEC, ignore = true)}) - @Test - public void notAllowedNameGetAllowedDigestTest() { - String name = "SM3"; - String oid = "1.2.156.10197.1.401"; - Assert.assertEquals(FIPS_MODE ? null : oid, DigestAlgorithms.getAllowedDigest(name)); + Assertions.assertEquals(FIPS_MODE ? oid : name, DigestAlgorithms.getDigest(oid)); } } diff --git a/sign/src/test/java/com/itextpdf/signatures/ExternalBlankSignatureContainerUnitTest.java b/sign/src/test/java/com/itextpdf/signatures/ExternalBlankSignatureContainerUnitTest.java index b9f37dd878..3d038f95f9 100644 --- a/sign/src/test/java/com/itextpdf/signatures/ExternalBlankSignatureContainerUnitTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/ExternalBlankSignatureContainerUnitTest.java @@ -25,22 +25,21 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.kernel.pdf.PdfName; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.ByteArrayInputStream; import java.security.GeneralSecurityException; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class ExternalBlankSignatureContainerUnitTest extends ExtendedITextTest { @Test public void createBlankSignTest() throws GeneralSecurityException { IExternalSignatureContainer container = new ExternalBlankSignatureContainer(new PdfDictionary()); byte[] blankSign = container.sign(new ByteArrayInputStream(new byte[] {1, 0, 32, 5})); - Assert.assertEquals(0, blankSign.length); + Assertions.assertEquals(0, blankSign.length); } @Test @@ -55,6 +54,6 @@ public void modifySigningDictionarySignTest() throws GeneralSecurityException { container.modifySigningDictionary(addDict); byte[] blankSign = container.sign(new ByteArrayInputStream(new byte[] {1, 0, 32, 5})); - Assert.assertEquals(0, blankSign.length); + Assertions.assertEquals(0, blankSign.length); } } diff --git a/sign/src/test/java/com/itextpdf/signatures/KeyStoreUtilUnitTest.java b/sign/src/test/java/com/itextpdf/signatures/KeyStoreUtilUnitTest.java index 04f4d2a873..1fe4282125 100644 --- a/sign/src/test/java/com/itextpdf/signatures/KeyStoreUtilUnitTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/KeyStoreUtilUnitTest.java @@ -24,53 +24,52 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.exceptions.PdfException; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.security.KeyStore; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class KeyStoreUtilUnitTest extends ExtendedITextTest { @Test // Android-Conversion-Ignore-Test (TODO DEVSIX-6446 fix differences in java.security) public void loadCacertsKeyStoreSUNTest() { KeyStore keyStore = KeyStoreUtil.loadCacertsKeyStore("SUN"); - Assert.assertEquals("JKS", keyStore.getType()); - Assert.assertEquals("SUN", keyStore.getProvider().getName()); + Assertions.assertEquals("JKS", keyStore.getType()); + Assertions.assertEquals("SUN", keyStore.getProvider().getName()); } @Test // Android-Conversion-Ignore-Test (TODO DEVSIX-6446 fix differences in java.security) public void loadCaCertsKeyStoreNoSuchProviderTest() { - PdfException e = Assert.assertThrows(PdfException.class, + PdfException e = Assertions.assertThrows(PdfException.class, () -> KeyStoreUtil.loadCacertsKeyStore("unknown provider")); - Assert.assertEquals("no such provider: unknown provider", e.getCause().getMessage()); + Assertions.assertEquals("no such provider: unknown provider", e.getCause().getMessage()); } @Test // Android-Conversion-Ignore-Test (TODO DEVSIX-6446 fix differences in java.security) public void loadCaCertsKeyStoreJKSNotFoundTest() { - PdfException e = Assert.assertThrows(PdfException.class, + PdfException e = Assertions.assertThrows(PdfException.class, () -> KeyStoreUtil.loadCacertsKeyStore("SunPCSC")); - Assert.assertEquals("JKS not found", e.getCause().getMessage()); + Assertions.assertEquals("JKS not found", e.getCause().getMessage()); } @Test // Android-Conversion-Ignore-Test (TODO DEVSIX-6446 fix differences in java.security) public void loadCaCertsKeyStoreNullTest() { KeyStore keyStore = KeyStoreUtil.loadCacertsKeyStore(null); - Assert.assertEquals("JKS", keyStore.getType()); - Assert.assertEquals("SUN", keyStore.getProvider().getName()); + Assertions.assertEquals("JKS", keyStore.getType()); + Assertions.assertEquals("SUN", keyStore.getProvider().getName()); } @Test // Android-Conversion-Ignore-Test (TODO DEVSIX-6446 fix differences in java.security) public void loadCaCertsKeyStoreEmptyTest() { - PdfException e = Assert.assertThrows(PdfException.class, + PdfException e = Assertions.assertThrows(PdfException.class, () -> KeyStoreUtil.loadCacertsKeyStore("")); - Assert.assertEquals("missing provider", e.getCause().getMessage()); + Assertions.assertEquals("missing provider", e.getCause().getMessage()); } } diff --git a/sign/src/test/java/com/itextpdf/signatures/LtvVerificationTest.java b/sign/src/test/java/com/itextpdf/signatures/LtvVerificationTest.java index 7033c67fd7..241ee86a6a 100644 --- a/sign/src/test/java/com/itextpdf/signatures/LtvVerificationTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/LtvVerificationTest.java @@ -44,7 +44,6 @@ This file is part of the iText (R) project. import com.itextpdf.test.LogLevelConstants; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.BouncyCastleUnitTest; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -56,13 +55,12 @@ This file is part of the iText (R) project. import java.security.cert.X509Certificate; import java.util.ArrayList; import java.util.List; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(BouncyCastleUnitTest.class) +@Tag("BouncyCastleUnitTest") public class LtvVerificationTest extends ExtendedITextTest { private static final IBouncyCastleFactory BOUNCY_CASTLE_FACTORY = BouncyCastleFactoryCreator.getFactory(); @@ -75,7 +73,7 @@ public class LtvVerificationTest extends ExtendedITextTest { private static LtvVerification TEST_VERIFICATION; - @BeforeClass + @BeforeAll public static void before() throws IOException { Security.addProvider(BOUNCY_CASTLE_FACTORY.getProvider()); PdfDocument pdfDoc = new PdfDocument(new PdfReader(SRC_PDF)); @@ -96,18 +94,18 @@ public void addVerificationToDocumentWithAlreadyExistedDss() try (PdfDocument pdfDocument = new PdfDocument(new PdfReader(input))) { PdfDictionary dss = pdfDocument.getCatalog().getPdfObject().getAsDictionary(PdfName.DSS); - Assert.assertNull(dss.get(PdfName.CRLs)); + Assertions.assertNull(dss.get(PdfName.CRLs)); PdfArray ocsps = dss.getAsArray(PdfName.OCSPs); - Assert.assertEquals(1, ocsps.size()); + Assertions.assertEquals(1, ocsps.size()); PdfIndirectReference pir = ocsps.get(0).getIndirectReference(); PdfDictionary vri = dss.getAsDictionary(PdfName.VRI); - Assert.assertEquals(1, vri.entrySet().size()); + Assertions.assertEquals(1, vri.entrySet().size()); PdfDictionary vriElem = vri.getAsDictionary(new PdfName(signatureHash)); - Assert.assertEquals(1, vriElem.entrySet().size()); + Assertions.assertEquals(1, vriElem.entrySet().size()); final PdfArray vriOcsp = vriElem.getAsArray(PdfName.OCSP); - Assert.assertEquals(1, vriOcsp.size()); - Assert.assertEquals(pir, vriOcsp.get(0).getIndirectReference()); + Assertions.assertEquals(1, vriOcsp.size()); + Assertions.assertEquals(pir, vriOcsp.get(0).getIndirectReference()); } ByteArrayOutputStream baos = new ByteArrayOutputStream(); @@ -126,18 +124,18 @@ public void addVerificationToDocumentWithAlreadyExistedDss() try (PdfDocument pdfDocument = new PdfDocument(new PdfReader(new ByteArrayInputStream(baos.toByteArray())))) { PdfDictionary dss = pdfDocument.getCatalog().getPdfObject().getAsDictionary(PdfName.DSS); - Assert.assertNull(dss.get(PdfName.OCSPs)); + Assertions.assertNull(dss.get(PdfName.OCSPs)); PdfArray crls = dss.getAsArray(PdfName.CRLs); - Assert.assertEquals(1, crls.size()); + Assertions.assertEquals(1, crls.size()); PdfIndirectReference pir = crls.get(0).getIndirectReference(); PdfDictionary vri = dss.getAsDictionary(PdfName.VRI); - Assert.assertEquals(1, vri.entrySet().size()); + Assertions.assertEquals(1, vri.entrySet().size()); PdfDictionary vriElem = vri.getAsDictionary(new PdfName(signatureHash)); - Assert.assertEquals(1, vriElem.entrySet().size()); + Assertions.assertEquals(1, vriElem.entrySet().size()); final PdfArray vriCrl = vriElem.getAsArray(PdfName.CRL); - Assert.assertEquals(1, vriCrl.size()); - Assert.assertEquals(pir, vriCrl.get(0).getIndirectReference()); + Assertions.assertEquals(1, vriCrl.size()); + Assertions.assertEquals(pir, vriCrl.get(0).getIndirectReference()); } } @@ -150,7 +148,7 @@ public void validateSigNameWithEmptyByteArrayCrlOcspCertTest() throws IOExceptio List certs = new ArrayList<>(); certs.add(new byte[0]); - Assert.assertTrue(TEST_VERIFICATION.addVerification(SIG_FIELD_NAME, ocsps, crls, certs)); + Assertions.assertTrue(TEST_VERIFICATION.addVerification(SIG_FIELD_NAME, ocsps, crls, certs)); } @Test @@ -169,34 +167,34 @@ public void tryAddVerificationAfterMerge() throws IOException, GeneralSecurityEx verificationWithWriter.addVerification(SIG_FIELD_NAME, ocsps, crls, certs); verificationWithWriter.merge(); - Exception exception1 = Assert.assertThrows(IllegalStateException.class, + Exception exception1 = Assertions.assertThrows(IllegalStateException.class, () -> verificationWithWriter.addVerification(SIG_FIELD_NAME, ocsps, crls, certs)); - Assert.assertEquals(SignExceptionMessageConstant.VERIFICATION_ALREADY_OUTPUT, exception1.getMessage()); + Assertions.assertEquals(SignExceptionMessageConstant.VERIFICATION_ALREADY_OUTPUT, exception1.getMessage()); verificationWithWriter.merge(); - Exception exception2 = Assert.assertThrows(IllegalStateException.class, + Exception exception2 = Assertions.assertThrows(IllegalStateException.class, () -> verificationWithWriter.addVerification(null, null, null, CertificateOption.SIGNING_CERTIFICATE, Level.CRL, CertificateInclusion.YES)); - Assert.assertEquals(SignExceptionMessageConstant.VERIFICATION_ALREADY_OUTPUT, exception2.getMessage()); + Assertions.assertEquals(SignExceptionMessageConstant.VERIFICATION_ALREADY_OUTPUT, exception2.getMessage()); } } @Test public void validateSigNameWithNullCrlOcspCertTest() throws GeneralSecurityException, IOException { - Assert.assertTrue(TEST_VERIFICATION.addVerification(SIG_FIELD_NAME, null, null, null)); + Assertions.assertTrue(TEST_VERIFICATION.addVerification(SIG_FIELD_NAME, null, null, null)); } @Test //TODO DEVSIX-5696 Sign: NPE is thrown because no such a signature public void exceptionWhenValidateNonExistentSigNameTest() { - Assert.assertThrows(NullPointerException.class, + Assertions.assertThrows(NullPointerException.class, () -> TEST_VERIFICATION.addVerification("nonExistentSigName", null, null, null)); } @Test //TODO DEVSIX-5696 Sign: NPE is thrown because no such a signature public void exceptionWhenValidateParticularNonExistentSigNameTest() { - Assert.assertThrows(NullPointerException.class, + Assertions.assertThrows(NullPointerException.class, () -> TEST_VERIFICATION.addVerification("nonExistentSigName", null, null, CertificateOption.SIGNING_CERTIFICATE, Level.OCSP_CRL, CertificateInclusion.YES)); } @@ -563,7 +561,7 @@ public void validateSigNameWholeChainCrlNoTest() throws IOException, GeneralSecu public void getParentWithoutCertsTest() { try (PdfDocument document = new PdfDocument(new PdfWriter(new ByteArrayOutputStream()))) { LtvVerification verification = new LtvVerification(document); - Assert.assertNull(verification.getParent(null, new Certificate[0])); + Assertions.assertNull(verification.getParent(null, new Certificate[0])); } } @@ -577,7 +575,7 @@ private static void validateOptionLevelInclusion(String crlUrl, CertificateOptio } else { crl = new CrlClientOnline(crlUrl); } - Assert.assertEquals(expectedResult, + Assertions.assertEquals(expectedResult, TEST_VERIFICATION.addVerification(SIG_FIELD_NAME, ocsp, crl, certificateOption, level, inclusion)); } } diff --git a/sign/src/test/java/com/itextpdf/signatures/LtvVerifierIntegrationTest.java b/sign/src/test/java/com/itextpdf/signatures/LtvVerifierIntegrationTest.java index 564f1df449..7fbfa0fa87 100644 --- a/sign/src/test/java/com/itextpdf/signatures/LtvVerifierIntegrationTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/LtvVerifierIntegrationTest.java @@ -31,23 +31,22 @@ This file is part of the iText (R) project. import com.itextpdf.test.LogLevelConstants; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.BouncyCastleIntegrationTest; import java.io.IOException; import java.security.GeneralSecurityException; import java.security.Security; import java.util.List; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(BouncyCastleIntegrationTest.class) +@Tag("BouncyCastleIntegrationTest") public class LtvVerifierIntegrationTest extends ExtendedITextTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/signatures/LtvVerifierIntegrationTest/"; private static final IBouncyCastleFactory BOUNCY_CASTLE_FACTORY = BouncyCastleFactoryCreator.getFactory(); - @BeforeClass + @BeforeAll public static void before() { Security.addProvider(BOUNCY_CASTLE_FACTORY.getProvider()); } @@ -71,7 +70,7 @@ public void verifySigningCertIsSelfSignedWithoutRevocationDataTest() throws IOEx LtvVerifier verifier = new LtvVerifier(pdfDocument); verifier.setVerifyRootCertificate(false); List verificationOKList = verifier.verifySignature(); - Assert.assertTrue(verificationOKList.isEmpty()); + Assertions.assertTrue(verificationOKList.isEmpty()); } } @@ -91,8 +90,8 @@ public void verifySigningCertHasChainWithoutRevocationDataTest() throws IOExcept try (PdfDocument pdfDocument = new PdfDocument(new PdfReader(src))) { LtvVerifier verifier = new LtvVerifier(pdfDocument); verifier.setVerifyRootCertificate(false); - Exception ex = Assert.assertThrows(VerificationException.class, () -> verifier.verifySignature()); - Assert.assertEquals("Certificate C=BY,L=Minsk,O=iText,OU=test,CN=iTextTestRsaCert01 failed: " + Exception ex = Assertions.assertThrows(VerificationException.class, () -> verifier.verifySignature()); + Assertions.assertEquals("Certificate C=BY,L=Minsk,O=iText,OU=test,CN=iTextTestRsaCert01 failed: " + "Couldn't verify with CRL or OCSP or trusted anchor", ex.getMessage()); } } @@ -129,16 +128,16 @@ public void verifySigningCertHasChainWithOcspOnlyForChildCertNotVerifyRootTest() List verificationOKList = verifier.verifySignature(); - Assert.assertEquals(2, verificationOKList.size()); + Assertions.assertEquals(2, verificationOKList.size()); VerificationOK verificationOK = verificationOKList.get(0); - Assert.assertEquals("C=BY,L=Minsk,O=iText,OU=test,CN=iTextTestRsaCert01", + Assertions.assertEquals("C=BY,L=Minsk,O=iText,OU=test,CN=iTextTestRsaCert01", BOUNCY_CASTLE_FACTORY.createX500Name(verificationOK.certificate).toString()); - Assert.assertEquals("Valid OCSPs Found: 1", verificationOK.message); + Assertions.assertEquals("Valid OCSPs Found: 1", verificationOK.message); verificationOK = verificationOKList.get(1); - Assert.assertEquals("C=BY,L=Minsk,O=iText,OU=test,CN=iTextTestRoot", + Assertions.assertEquals("C=BY,L=Minsk,O=iText,OU=test,CN=iTextTestRoot", BOUNCY_CASTLE_FACTORY.createX500Name(verificationOK.certificate).toString()); - Assert.assertEquals("Root certificate passed without checking", verificationOK.message); + Assertions.assertEquals("Root certificate passed without checking", verificationOK.message); } } @@ -171,8 +170,8 @@ public void verifySigningCertHasChainWithOcspOnlyForChildCertVerifyRootTest() // The second is main revision which verifying we want to test. verifier.switchToPreviousRevision(); - Exception ex = Assert.assertThrows(VerificationException.class, () -> verifier.verifySignature()); - Assert.assertEquals("Certificate C=BY,L=Minsk,O=iText,OU=test,CN=iTextTestRoot failed: " + Exception ex = Assertions.assertThrows(VerificationException.class, () -> verifier.verifySignature()); + Assertions.assertEquals("Certificate C=BY,L=Minsk,O=iText,OU=test,CN=iTextTestRoot failed: " + "Couldn't verify with CRL or OCSP or trusted anchor", ex.getMessage()); } } @@ -206,8 +205,8 @@ public void verifySigningCertHas3ChainWithOcspOnlyForChildCertVerifyRootTest() // The second is main revision which verifying we want to test. verifier.switchToPreviousRevision(); - Exception ex = Assert.assertThrows(VerificationException.class, () -> verifier.verifySignature()); - Assert.assertEquals("Certificate C=BY,L=Minsk,O=iText,OU=test,CN=iTextTestIntermediateRsa01 failed: " + Exception ex = Assertions.assertThrows(VerificationException.class, () -> verifier.verifySignature()); + Assertions.assertEquals("Certificate C=BY,L=Minsk,O=iText,OU=test,CN=iTextTestIntermediateRsa01 failed: " + "Couldn't verify with CRL or OCSP or trusted anchor", ex.getMessage()); } } @@ -247,21 +246,21 @@ public void notTrustedRootCertificateInLatestRevisionTest() List verificationOKList = verifier.verifySignature(); - Assert.assertEquals(3, verificationOKList.size()); + Assertions.assertEquals(3, verificationOKList.size()); VerificationOK verificationOK = verificationOKList.get(0); - Assert.assertEquals("C=BY,L=Minsk,O=iText,OU=test,CN=iTextTestRsaCert01", + Assertions.assertEquals("C=BY,L=Minsk,O=iText,OU=test,CN=iTextTestRsaCert01", BOUNCY_CASTLE_FACTORY.createX500Name(verificationOK.certificate).toString()); - Assert.assertEquals("Valid OCSPs Found: 1", verificationOK.message); + Assertions.assertEquals("Valid OCSPs Found: 1", verificationOK.message); verificationOK = verificationOKList.get(1); - Assert.assertEquals("C=BY,L=Minsk,O=iText,OU=test,CN=iTextTestRoot", + Assertions.assertEquals("C=BY,L=Minsk,O=iText,OU=test,CN=iTextTestRoot", BOUNCY_CASTLE_FACTORY.createX500Name(verificationOK.certificate).toString()); - Assert.assertEquals("Root certificate in final revision", verificationOK.message); + Assertions.assertEquals("Root certificate in final revision", verificationOK.message); verificationOK = verificationOKList.get(2); - Assert.assertEquals("C=BY,L=Minsk,O=iText,OU=test,CN=iTextTestRoot", + Assertions.assertEquals("C=BY,L=Minsk,O=iText,OU=test,CN=iTextTestRoot", BOUNCY_CASTLE_FACTORY.createX500Name(verificationOK.certificate).toString()); - Assert.assertEquals("Root certificate passed without checking", verificationOK.message); + Assertions.assertEquals("Root certificate passed without checking", verificationOK.message); } } @@ -273,13 +272,13 @@ public void switchBetweenSeveralRevisionsTest() throws IOException, GeneralSecur LtvVerifier ltvVerifier = new LtvVerifier(pdfDoc); - Assert.assertEquals("timestampSig2", ltvVerifier.signatureName); + Assertions.assertEquals("timestampSig2", ltvVerifier.signatureName); ltvVerifier.switchToPreviousRevision(); - Assert.assertEquals("Signature2", ltvVerifier.signatureName); + Assertions.assertEquals("Signature2", ltvVerifier.signatureName); ltvVerifier.switchToPreviousRevision(); - Assert.assertEquals("timestampSig1", ltvVerifier.signatureName); + Assertions.assertEquals("timestampSig1", ltvVerifier.signatureName); ltvVerifier.switchToPreviousRevision(); - Assert.assertEquals("Signature1", ltvVerifier.signatureName); + Assertions.assertEquals("Signature1", ltvVerifier.signatureName); ltvVerifier.switchToPreviousRevision(); } } diff --git a/sign/src/test/java/com/itextpdf/signatures/LtvVerifierUnitTest.java b/sign/src/test/java/com/itextpdf/signatures/LtvVerifierUnitTest.java index c64a65f301..64052596fa 100644 --- a/sign/src/test/java/com/itextpdf/signatures/LtvVerifierUnitTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/LtvVerifierUnitTest.java @@ -27,18 +27,17 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfReader; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.BouncyCastleUnitTest; import java.io.IOException; import java.security.GeneralSecurityException; import java.util.ArrayList; import java.util.Collections; import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(BouncyCastleUnitTest.class) +@Tag("BouncyCastleUnitTest") public class LtvVerifierUnitTest extends ExtendedITextTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/signatures/LtvVerifierUnitTest/"; @@ -50,7 +49,7 @@ public void setVerifierTest() throws GeneralSecurityException, IOException { FileUtil.getInputStreamForFile(SOURCE_FOLDER + "ltvDoc.pdf")))); verifier1.setVerifier(verifier2); - Assert.assertSame(verifier2, verifier1.verifier); + Assertions.assertSame(verifier2, verifier1.verifier); } @Test @@ -58,7 +57,7 @@ public void setVerifyRootCertificateTest() throws GeneralSecurityException, IOEx LtvVerifier verifier = new LtvVerifier(new PdfDocument(new PdfReader(FileUtil.getInputStreamForFile(SOURCE_FOLDER + "ltvDoc.pdf")))); verifier.setVerifyRootCertificate(true); - Assert.assertTrue(verifier.verifyRootCertificate); + Assertions.assertTrue(verifier.verifyRootCertificate); } @Test @@ -67,7 +66,7 @@ public void verifyNotNullTest() throws GeneralSecurityException, IOException { verifier.pkcs7 = null; List list = Collections.emptyList(); - Assert.assertSame(list, verifier.verify(list)); + Assertions.assertSame(list, verifier.verify(list)); } @Test @@ -75,7 +74,7 @@ public void getCRLsFromDSSCRLsNullTest() throws GeneralSecurityException, IOExce LtvVerifier verifier = new LtvVerifier(new PdfDocument(new PdfReader(FileUtil.getInputStreamForFile(SOURCE_FOLDER + "ltvDoc.pdf")))); verifier.dss = new PdfDictionary(); - Assert.assertEquals(new ArrayList<>(), verifier.getCRLsFromDSS()); + Assertions.assertEquals(new ArrayList<>(), verifier.getCRLsFromDSS()); } @Test @@ -83,6 +82,6 @@ public void getOCSPResponsesFromDSSOCSPsNullTest() throws GeneralSecurityExcepti LtvVerifier verifier = new LtvVerifier(new PdfDocument(new PdfReader(FileUtil.getInputStreamForFile(SOURCE_FOLDER + "ltvDoc.pdf")))); verifier.dss = new PdfDictionary(); - Assert.assertEquals(new ArrayList<>(), verifier.getOCSPResponsesFromDSS()); + Assertions.assertEquals(new ArrayList<>(), verifier.getOCSPResponsesFromDSS()); } } diff --git a/sign/src/test/java/com/itextpdf/signatures/OcspClientBouncyCastleTest.java b/sign/src/test/java/com/itextpdf/signatures/OcspClientBouncyCastleTest.java index c1e663081e..971e1c2201 100644 --- a/sign/src/test/java/com/itextpdf/signatures/OcspClientBouncyCastleTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/OcspClientBouncyCastleTest.java @@ -41,7 +41,7 @@ This file is part of the iText (R) project. import com.itextpdf.test.LogLevelConstants; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.BouncyCastleUnitTest; + import java.io.IOException; import java.net.ConnectException; @@ -53,13 +53,13 @@ This file is part of the iText (R) project. import java.security.cert.CertificateException; import java.security.cert.X509Certificate; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; -@Category(BouncyCastleUnitTest.class) +@Tag("BouncyCastleUnitTest") public class OcspClientBouncyCastleTest extends ExtendedITextTest { private static final String ocspCertsSrc = "./src/test/resources/com/itextpdf/signatures/OcspClientBouncyCastleTest/"; private static final String rootOcspCert = ocspCertsSrc + "ocspRootRsa.pem"; @@ -72,12 +72,12 @@ public class OcspClientBouncyCastleTest extends ExtendedITextTest { private static X509Certificate rootCert; private static TestOcspResponseBuilder builder; - @BeforeClass + @BeforeAll public static void before() { Security.addProvider(BOUNCY_CASTLE_FACTORY.getProvider()); } - @Before + @BeforeEach public void setUp() throws CertificateException, IOException, AbstractPKCSException, AbstractOperatorCreationException { builder = createBuilder(BOUNCY_CASTLE_FACTORY.createCertificateStatus().getGood()); @@ -89,27 +89,27 @@ public void setUp() public void getOcspResponseWhenCheckCertIsNullTest() throws GeneralSecurityException, IOException, AbstractOperatorCreationException, AbstractOCSPException { OcspClientBouncyCastle castle = new OcspClientBouncyCastle(); - Assert.assertNull(castle.getOcspResponse(null, rootCert, ocspServiceUrl)); + Assertions.assertNull(castle.getOcspResponse(null, rootCert, ocspServiceUrl)); } @Test public void getOcspResponseWhenRootCertIsNullTest() throws GeneralSecurityException, IOException, AbstractOperatorCreationException, AbstractOCSPException { OcspClientBouncyCastle castle = new OcspClientBouncyCastle(); - Assert.assertNull(castle.getOcspResponse(checkCert, null, ocspServiceUrl)); + Assertions.assertNull(castle.getOcspResponse(checkCert, null, ocspServiceUrl)); } @Test public void getOcspResponseWhenRootAndCheckCertIsNullTest() throws GeneralSecurityException, IOException, AbstractOperatorCreationException, AbstractOCSPException { OcspClientBouncyCastle castle = new OcspClientBouncyCastle(); - Assert.assertNull(castle.getOcspResponse(null, null, ocspServiceUrl)); + Assertions.assertNull(castle.getOcspResponse(null, null, ocspServiceUrl)); } @Test public void getOcspResponseWhenUrlCertIsNullTest() { OcspClientBouncyCastle castle = new OcspClientBouncyCastle(); - Assert.assertThrows(ConnectException.class, + Assertions.assertThrows(ConnectException.class, () -> castle.getOcspResponse(checkCert, rootCert, null)); } @@ -119,7 +119,7 @@ public void getOcspResponseWhenUrlCertIsNullTest() { }) public void incorrectUrlTest() { OcspClientBouncyCastle castle = new OcspClientBouncyCastle(); - Assert.assertThrows(UnknownHostException.class, + Assertions.assertThrows(UnknownHostException.class, () -> castle.getOcspResponse(checkCert, rootCert, "http://asd")); } @@ -129,7 +129,7 @@ public void incorrectUrlTest() { }) public void malformedUrlTest() { OcspClientBouncyCastle castle = new OcspClientBouncyCastle(); - Assert.assertThrows(MalformedURLException.class, + Assertions.assertThrows(MalformedURLException.class, () -> castle.getOcspResponse(checkCert, rootCert, "")); } @@ -140,7 +140,7 @@ public void malformedUrlTest() { }) public void connectionRefusedTest() { OcspClientBouncyCastle castle = new OcspClientBouncyCastle(); - Assert.assertThrows(ConnectException.class, + Assertions.assertThrows(ConnectException.class, () -> castle.getOcspResponse(checkCert, rootCert, ocspServiceUrl)); } @@ -150,8 +150,8 @@ public void getBasicOcspRespTest() { IBasicOCSPResp basicOCSPResp = ocspClientBouncyCastle .getBasicOCSPResp(checkCert, rootCert, ocspServiceUrl); - Assert.assertNotNull(basicOCSPResp); - Assert.assertTrue(basicOCSPResp.getResponses().length > 0); + Assertions.assertNotNull(basicOCSPResp); + Assertions.assertTrue(basicOCSPResp.getResponses().length > 0); } @Test @@ -160,17 +160,7 @@ public void getBasicOcspRespNullTest() { IBasicOCSPResp basicOCSPResp = ocspClientBouncyCastle .getBasicOCSPResp(checkCert, null, ocspServiceUrl); - Assert.assertNull(basicOCSPResp); - } - - @Test - @LogMessages(messages = - @LogMessage(messageTemplate = "OCSP response could not be verified")) - public void getBasicOCSPRespLogMessageTest() { - OcspClientBouncyCastle ocspClientBouncyCastle = createOcspClient(); - - IBasicOCSPResp basicOCSPResp = ocspClientBouncyCastle.getBasicOCSPResp(null, null, null); - Assert.assertNull(basicOCSPResp); + Assertions.assertNull(basicOCSPResp); } @Test @@ -178,8 +168,8 @@ public void getEncodedTest() { OcspClientBouncyCastle ocspClientBouncyCastle = createOcspClient(); byte[] encoded = ocspClientBouncyCastle.getEncoded(checkCert, rootCert, ocspServiceUrl); - Assert.assertNotNull(encoded); - Assert.assertTrue(encoded.length > 0); + Assertions.assertNotNull(encoded); + Assertions.assertTrue(encoded.length > 0); } @Test @@ -191,7 +181,7 @@ public void ocspStatusIsRevokedTest() OcspClientBouncyCastle ocspClientBouncyCastle = createTestOcspClient(responseBuilder); byte[] encoded = ocspClientBouncyCastle.getEncoded(checkCert, rootCert, ocspServiceUrl); - Assert.assertNotNull( + Assertions.assertNotNull( BOUNCY_CASTLE_FACTORY.createRevokedStatus(OcspClientBouncyCastle.getCertificateStatus(encoded))); } @@ -203,16 +193,16 @@ public void ocspStatusIsUnknownTest() OcspClientBouncyCastle ocspClientBouncyCastle = createTestOcspClient(responseBuilder); byte[] encoded = ocspClientBouncyCastle.getEncoded(checkCert, rootCert, ocspServiceUrl); - Assert.assertNotEquals(BOUNCY_CASTLE_FACTORY.createCertificateStatus().getGood(), + Assertions.assertNotEquals(BOUNCY_CASTLE_FACTORY.createCertificateStatus().getGood(), OcspClientBouncyCastle.getCertificateStatus(encoded)); - Assert.assertNull( + Assertions.assertNull( BOUNCY_CASTLE_FACTORY.createRevokedStatus(OcspClientBouncyCastle.getCertificateStatus(encoded))); } @Test public void invalidOcspStatusIsNullTest() { byte[] encoded = new byte[0]; - Assert.assertNull(OcspClientBouncyCastle.getCertificateStatus(encoded)); + Assertions.assertNull(OcspClientBouncyCastle.getCertificateStatus(encoded)); } private static OcspClientBouncyCastle createOcspClient() { @@ -220,8 +210,7 @@ private static OcspClientBouncyCastle createOcspClient() { } private static OcspClientBouncyCastle createOcspClient(TestOcspResponseBuilder builder) { - OCSPVerifier ocspVerifier = new OCSPVerifier(null, null); - return new TestOcspClientBouncyCastle(ocspVerifier, builder); + return new TestOcspClientBouncyCastle(builder); } private static OcspClientBouncyCastle createTestOcspClient(TestOcspResponseBuilder responseBuilder) { @@ -238,8 +227,8 @@ private static TestOcspResponseBuilder createBuilder(ICertificateStatus status) private static final class TestOcspClientBouncyCastle extends OcspClientBouncyCastle { private static TestOcspResponseBuilder testOcspBuilder; - public TestOcspClientBouncyCastle(OCSPVerifier verifier, TestOcspResponseBuilder testBuilder) { - super(verifier); + public TestOcspClientBouncyCastle(TestOcspResponseBuilder testBuilder) { + super(); testOcspBuilder = testBuilder; } diff --git a/sign/src/test/java/com/itextpdf/signatures/PKCS7ExternalSignatureContainerTest.java b/sign/src/test/java/com/itextpdf/signatures/PKCS7ExternalSignatureContainerTest.java index 4649bd2a0c..f9f06dc553 100644 --- a/sign/src/test/java/com/itextpdf/signatures/PKCS7ExternalSignatureContainerTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/PKCS7ExternalSignatureContainerTest.java @@ -30,6 +30,7 @@ This file is part of the iText (R) project. import com.itextpdf.commons.utils.DateTimeUtil; import com.itextpdf.commons.utils.FileUtil; import com.itextpdf.io.source.ByteArrayOutputStream; +import com.itextpdf.kernel.crypto.DigestAlgorithms; import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfReader; import com.itextpdf.kernel.pdf.PdfVersion; @@ -44,7 +45,6 @@ This file is part of the iText (R) project. import com.itextpdf.signatures.testutils.client.TestOcspClient; import com.itextpdf.signatures.testutils.client.TestTsaClient; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.BouncyCastleUnitTest; import java.io.ByteArrayInputStream; import java.io.IOException; @@ -55,13 +55,13 @@ This file is part of the iText (R) project. import java.security.cert.CertificateException; import java.security.cert.X509Certificate; import java.util.Arrays; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(BouncyCastleUnitTest.class) +@Tag("BouncyCastleUnitTest") public class PKCS7ExternalSignatureContainerTest extends ExtendedITextTest { private static final IBouncyCastleFactory FACTORY = BouncyCastleFactoryCreator.getFactory(); private static final boolean FIPS_MODE = "BCFIPS".equals(FACTORY.getProviderName()); @@ -84,13 +84,13 @@ public class PKCS7ExternalSignatureContainerTest extends ExtendedITextTest { private X509Certificate caCert; private PrivateKey caPrivateKey; - @BeforeClass + @BeforeAll public static void before() { Security.addProvider(FACTORY.getProvider()); createOrClearDestinationFolder(DESTINATION_FOLDER); } - @Before + @BeforeEach public void init() throws IOException, CertificateException, AbstractPKCSException, AbstractOperatorCreationException { pk = PemFileHelper.readFirstKey(CERTS_SRC + "signCertRsa01.pem", PASSWORD); @@ -111,7 +111,7 @@ public void testTroughPdfSigner() throws IOException, GeneralSecurityException { pk, chain, DigestAlgorithms.SHA256); pdfSigner.signExternalContainer(pkcs7ExternalSignatureContainer, 12000); - Assert.assertNull(SignaturesCompareTool.compareSignatures(outFileName, cmpFileName)); + Assertions.assertNull(SignaturesCompareTool.compareSignatures(outFileName, cmpFileName)); } @Test @@ -131,7 +131,7 @@ public void testTroughPdfSignerWithCrlClient() throws IOException, GeneralSecuri pdfSigner.signExternalContainer(pkcs7ExternalSignatureContainer, 12000); - Assert.assertNull(SignaturesCompareTool.compareSignatures(outFileName, cmpFileName)); + Assertions.assertNull(SignaturesCompareTool.compareSignatures(outFileName, cmpFileName)); } @Test @@ -149,7 +149,7 @@ public void testTroughPdfSignerWithOcspClient() throws IOException, GeneralSecur pkcs7ExternalSignatureContainer.setOcspClient(ocspClient); pdfSigner.signExternalContainer(pkcs7ExternalSignatureContainer, 12000); - Assert.assertNull(SignaturesCompareTool.compareSignatures(outFileName, cmpFileName)); + Assertions.assertNull(SignaturesCompareTool.compareSignatures(outFileName, cmpFileName)); } @Test @@ -169,7 +169,7 @@ public void testTroughPdfSignerWithTsaClient() throws IOException, GeneralSecuri pdfSigner.signExternalContainer(pkcs7ExternalSignatureContainer, 12000); - Assert.assertNull(SignaturesCompareTool.compareSignatures(outFileName, cmpFileName)); + Assertions.assertNull(SignaturesCompareTool.compareSignatures(outFileName, cmpFileName)); } @Test @@ -183,7 +183,7 @@ public void testTroughPdfSignerWithCadesType() throws IOException, GeneralSecuri pkcs7ExternalSignatureContainer.setSignatureType(PdfSigner.CryptoStandard.CADES); pdfSigner.signExternalContainer(pkcs7ExternalSignatureContainer, 12000); - Assert.assertNull(SignaturesCompareTool.compareSignatures(outFileName, cmpFileName)); + Assertions.assertNull(SignaturesCompareTool.compareSignatures(outFileName, cmpFileName)); } @Test @@ -199,7 +199,7 @@ public void testTroughPdfSignerWithSignaturePolicy() throws IOException, General pkcs7ExternalSignatureContainer.setSignaturePolicy(policy); pdfSigner.signExternalContainer(pkcs7ExternalSignatureContainer, 12000); - Assert.assertNull(SignaturesCompareTool.compareSignatures(outFileName, cmpFileName)); + Assertions.assertNull(SignaturesCompareTool.compareSignatures(outFileName, cmpFileName)); } private static ByteArrayInputStream createSimpleDocument() { diff --git a/sign/src/test/java/com/itextpdf/signatures/PdfPKCS7BasicTest.java b/sign/src/test/java/com/itextpdf/signatures/PdfPKCS7BasicTest.java index 984df269e0..48057386e0 100644 --- a/sign/src/test/java/com/itextpdf/signatures/PdfPKCS7BasicTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/PdfPKCS7BasicTest.java @@ -30,7 +30,6 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfReader; import com.itextpdf.signatures.testutils.PemFileHelper; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.BouncyCastleUnitTest; import java.io.IOException; import java.security.GeneralSecurityException; @@ -38,11 +37,11 @@ This file is part of the iText (R) project. import java.security.Security; import java.security.cert.Certificate; import java.security.cert.CertificateException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; -@Category(BouncyCastleUnitTest.class) +@Tag("BouncyCastleUnitTest") public class PdfPKCS7BasicTest extends ExtendedITextTest { protected static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/signatures/PdfPKCS7Test/"; @@ -56,7 +55,7 @@ public class PdfPKCS7BasicTest extends ExtendedITextTest { private static final char[] PASSWORD = "testpassphrase".toCharArray(); - @BeforeClass + @BeforeAll public static void init() throws IOException, CertificateException, AbstractPKCSException, AbstractOperatorCreationException { Security.addProvider(BOUNCY_CASTLE_FACTORY.getProvider()); @@ -78,8 +77,8 @@ Also, default providers (in 2022) don't always have the parameters for Brainpool it causes a runtime error. */ PdfPKCS7 data = u.readSignatureData("Signature", BOUNCY_CASTLE_FACTORY.getProviderName()); - Assert.assertEquals(expectedSigMechanismName, data.getSignatureMechanismName()); - Assert.assertTrue(data.verifySignatureIntegrityAndAuthenticity()); + Assertions.assertEquals(expectedSigMechanismName, data.getSignatureMechanismName()); + Assertions.assertTrue(data.verifySignatureIntegrityAndAuthenticity()); } } } diff --git a/sign/src/test/java/com/itextpdf/signatures/PdfPKCS7ManuallyPortedTest.java b/sign/src/test/java/com/itextpdf/signatures/PdfPKCS7ManuallyPortedTest.java index 4e354f8ef0..4ca2cf3a6f 100644 --- a/sign/src/test/java/com/itextpdf/signatures/PdfPKCS7ManuallyPortedTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/PdfPKCS7ManuallyPortedTest.java @@ -23,16 +23,15 @@ This file is part of the iText (R) project. package com.itextpdf.signatures; import com.itextpdf.kernel.exceptions.PdfException; -import com.itextpdf.test.annotations.type.BouncyCastleUnitTest; import java.io.IOException; import java.security.GeneralSecurityException; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; // The behavior is different on .NET -@Category(BouncyCastleUnitTest.class) +@Tag("BouncyCastleUnitTest") public class PdfPKCS7ManuallyPortedTest extends PdfPKCS7BasicTest { @Test @@ -40,7 +39,7 @@ public void verifyEd25519SignatureTest() throws IOException, GeneralSecurityException { // ED25519 is not available in FIPS approved mode if (BOUNCY_CASTLE_FACTORY.isInApprovedOnlyMode()) { - Assert.assertThrows(PdfException.class, + Assertions.assertThrows(PdfException.class, () -> verifyIsoExtensionExample("Ed25519", "sample-ed25519-sha512.pdf")); } else { verifyIsoExtensionExample("Ed25519", "sample-ed25519-sha512.pdf"); @@ -67,4 +66,14 @@ public void verifyRsaPssSha3SignatureTest() throws IOException, GeneralSecurityE verifyIsoExtensionExample("RSASSA-PSS", "sample-pss-sha3_256.pdf"); } + @Test + public void verifyEd448SignatureTest() throws IOException, GeneralSecurityException { + // Ed448 is not available in BCFIPS approved mode + if (BOUNCY_CASTLE_FACTORY.isInApprovedOnlyMode()) { + Assertions.assertThrows(PdfException.class, + () -> verifyIsoExtensionExample("Ed448", "sample-ed448-shake256.pdf")); + } else { + verifyIsoExtensionExample("Ed448", "sample-ed448-shake256.pdf"); + } + } } diff --git a/sign/src/test/java/com/itextpdf/signatures/PdfPKCS7Test.java b/sign/src/test/java/com/itextpdf/signatures/PdfPKCS7Test.java index 6b0d0e9c65..70e0cec026 100644 --- a/sign/src/test/java/com/itextpdf/signatures/PdfPKCS7Test.java +++ b/sign/src/test/java/com/itextpdf/signatures/PdfPKCS7Test.java @@ -29,6 +29,8 @@ This file is part of the iText (R) project. import com.itextpdf.commons.utils.DateTimeUtil; import com.itextpdf.commons.utils.FileUtil; import com.itextpdf.commons.utils.MessageFormatUtil; +import com.itextpdf.kernel.crypto.DigestAlgorithms; +import com.itextpdf.kernel.crypto.OID; import com.itextpdf.kernel.exceptions.KernelExceptionMessageConstant; import com.itextpdf.kernel.exceptions.PdfException; import com.itextpdf.kernel.pdf.PdfDocument; @@ -38,7 +40,6 @@ This file is part of the iText (R) project. import com.itextpdf.signatures.testutils.SignTestPortUtil; import com.itextpdf.signatures.testutils.TimeTestUtil; import com.itextpdf.signatures.testutils.client.TestTsaClient; -import com.itextpdf.test.annotations.type.BouncyCastleUnitTest; import java.io.IOException; import java.nio.file.Files; @@ -57,11 +58,11 @@ This file is part of the iText (R) project. import java.util.Collections; import java.util.List; import java.util.stream.Collectors; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(BouncyCastleUnitTest.class) +@Tag("BouncyCastleUnitTest") public class PdfPKCS7Test extends PdfPKCS7BasicTest { private static final double EPS = 0.001; @@ -71,10 +72,10 @@ public class PdfPKCS7Test extends PdfPKCS7BasicTest { // only the hash algorithm is altered public void unknownHashAlgorithmTest() { String hashAlgorithm = ""; - Exception e = Assert.assertThrows(PdfException.class, + Exception e = Assertions.assertThrows(PdfException.class, () -> new PdfPKCS7(null, chain, hashAlgorithm, null, new BouncyCastleDigest(), false)); - Assert.assertEquals( + Assertions.assertEquals( MessageFormatUtil.format(SignExceptionMessageConstant.UNKNOWN_HASH_ALGORITHM, hashAlgorithm), e.getMessage()); } @@ -86,14 +87,14 @@ public void simpleCreationTest() PdfPKCS7 pkcs7 = new PdfPKCS7(null, chain, hashAlgorithm, null, false); String expectedOid = DigestAlgorithms.getAllowedDigest(hashAlgorithm); - Assert.assertEquals(expectedOid, pkcs7.getDigestAlgorithmOid()); - Assert.assertEquals(chain[0], pkcs7.getSigningCertificate()); - Assert.assertArrayEquals(chain, pkcs7.getCertificates()); - Assert.assertNull(pkcs7.getSignatureMechanismOid()); + Assertions.assertEquals(expectedOid, pkcs7.getDigestAlgorithmOid()); + Assertions.assertEquals(chain[0], pkcs7.getSigningCertificate()); + Assertions.assertArrayEquals(chain, pkcs7.getCertificates()); + Assertions.assertNull(pkcs7.getSignatureMechanismOid()); // test default fields - Assert.assertEquals(1, pkcs7.getVersion()); - Assert.assertEquals(1, pkcs7.getSigningInfoVersion()); + Assertions.assertEquals(1, pkcs7.getVersion()); + Assertions.assertEquals(1, pkcs7.getSigningInfoVersion()); } @Test @@ -103,17 +104,17 @@ public void simpleCreationWithPrivateKeyTest() PdfPKCS7 pkcs7 = new PdfPKCS7(pk, chain, hashAlgorithm, null, new BouncyCastleDigest(), false); String expectedOid = DigestAlgorithms.getAllowedDigest(hashAlgorithm); - Assert.assertEquals(expectedOid, pkcs7.getDigestAlgorithmOid()); - Assert.assertEquals(chain[0], pkcs7.getSigningCertificate()); - Assert.assertArrayEquals(chain, pkcs7.getCertificates()); - Assert.assertEquals(SecurityIDs.ID_RSA_WITH_SHA256, pkcs7.getSignatureMechanismOid()); + Assertions.assertEquals(expectedOid, pkcs7.getDigestAlgorithmOid()); + Assertions.assertEquals(chain[0], pkcs7.getSigningCertificate()); + Assertions.assertArrayEquals(chain, pkcs7.getCertificates()); + Assertions.assertEquals(OID.RSA_WITH_SHA256, pkcs7.getSignatureMechanismOid()); } @Test public void notAvailableSignatureTest() { String hashAlgorithm = "GOST3411"; // Throws different exceptions on .net and java, bc/bcfips - Assert.assertThrows(Exception.class, + Assertions.assertThrows(Exception.class, () -> new PdfPKCS7(pk, chain, hashAlgorithm, null, new BouncyCastleDigest(), false)); } @@ -121,44 +122,44 @@ public void notAvailableSignatureTest() { public void reasonSetGetTest() throws NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException { PdfPKCS7 pkcs7 = createSimplePdfPKCS7(); - Assert.assertNull(pkcs7.getReason()); + Assertions.assertNull(pkcs7.getReason()); String testReason = "testReason"; pkcs7.setReason(testReason); - Assert.assertEquals(testReason, pkcs7.getReason()); + Assertions.assertEquals(testReason, pkcs7.getReason()); } @Test public void locationSetGetTest() throws NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException { PdfPKCS7 pkcs7 = createSimplePdfPKCS7(); - Assert.assertNull(pkcs7.getLocation()); + Assertions.assertNull(pkcs7.getLocation()); String testLocation = "testLocation"; pkcs7.setLocation(testLocation); - Assert.assertEquals(testLocation, pkcs7.getLocation()); + Assertions.assertEquals(testLocation, pkcs7.getLocation()); } @Test public void signNameSetGetTest() throws NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException { PdfPKCS7 pkcs7 = createSimplePdfPKCS7(); - Assert.assertNull(pkcs7.getSignName()); + Assertions.assertNull(pkcs7.getSignName()); String testSignName = "testSignName"; pkcs7.setSignName(testSignName); - Assert.assertEquals(testSignName, pkcs7.getSignName()); + Assertions.assertEquals(testSignName, pkcs7.getSignName()); } @Test public void signDateSetGetTest() throws NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException { PdfPKCS7 pkcs7 = createSimplePdfPKCS7(); - Assert.assertEquals(TimestampConstants.UNDEFINED_TIMESTAMP_DATE, pkcs7.getSignDate()); + Assertions.assertEquals(TimestampConstants.UNDEFINED_TIMESTAMP_DATE, pkcs7.getSignDate()); Calendar testSignDate = DateTimeUtil.getCurrentTimeCalendar(); pkcs7.setSignDate(testSignDate); - Assert.assertEquals(testSignDate, pkcs7.getSignDate()); + Assertions.assertEquals(testSignDate, pkcs7.getSignDate()); } @Test @@ -168,20 +169,20 @@ public void ocspGetTest() throws IOException, ParseException { SignatureUtil sigUtil = new SignatureUtil(outDocument); PdfPKCS7 pkcs7 = sigUtil.readSignatureData("Signature1"); - Assert.assertNull(pkcs7.getCRLs()); + Assertions.assertNull(pkcs7.getCRLs()); // it's tested here that ocsp and time stamp token were found while // constructing PdfPKCS7 instance ITSTInfo timeStampTokenInfo = pkcs7.getTimeStampTokenInfo(); - Assert.assertNotNull(timeStampTokenInfo); + Assertions.assertNotNull(timeStampTokenInfo); // The number corresponds to 3 September, 2021 13:32:33. double expectedMillis = (double) 1630675953000L; - Assert.assertEquals( + Assertions.assertEquals( TimeTestUtil.getFullDaysMillis(expectedMillis), TimeTestUtil.getFullDaysMillis(DateTimeUtil.getUtcMillisFromEpoch( DateTimeUtil.getCalendar(timeStampTokenInfo.getGenTime()))), EPS); - Assert.assertEquals( + Assertions.assertEquals( TimeTestUtil.getFullDaysMillis(expectedMillis), TimeTestUtil.getFullDaysMillis(DateTimeUtil.getUtcMillisFromEpoch( DateTimeUtil.getCalendar(pkcs7.getOcsp().getProducedAtDate()))), @@ -193,7 +194,7 @@ public void verifyTimestampImprintSimpleSignatureTest() throws IOException, Gene PdfDocument outDocument = new PdfDocument( new PdfReader(SOURCE_FOLDER + "simpleSignature.pdf")); PdfPKCS7 pkcs7 = new SignatureUtil(outDocument).readSignatureData("Signature1"); - Assert.assertFalse(pkcs7.verifyTimestampImprint()); + Assertions.assertFalse(pkcs7.verifyTimestampImprint()); } @Test @@ -201,7 +202,7 @@ public void verifyTimestampImprintTimeStampSignatureTest() throws IOException, G PdfDocument outDocument = new PdfDocument( new PdfReader(SOURCE_FOLDER + "timeStampSignature.pdf")); PdfPKCS7 pkcs7 = new SignatureUtil(outDocument).readSignatureData("timestampSig1"); - Assert.assertFalse(pkcs7.verifyTimestampImprint()); + Assertions.assertFalse(pkcs7.verifyTimestampImprint()); } @Test @@ -209,7 +210,7 @@ public void verifyTimestampImprintEmbeddedTimeStampSignatureTest() throws IOExce PdfDocument outDocument = new PdfDocument( new PdfReader(SOURCE_FOLDER + "embeddedTimeStampSignature.pdf")); PdfPKCS7 pkcs7 = new SignatureUtil(outDocument).readSignatureData("Signature1"); - Assert.assertTrue(pkcs7.verifyTimestampImprint()); + Assertions.assertTrue(pkcs7.verifyTimestampImprint()); } @Test @@ -217,7 +218,7 @@ public void verifyTimestampImprintCorruptedTimeStampSignatureTest() throws IOExc PdfDocument outDocument = new PdfDocument( new PdfReader(SOURCE_FOLDER + "embeddedTimeStampCorruptedSignature.pdf")); PdfPKCS7 pkcs7 = new SignatureUtil(outDocument).readSignatureData("Signature1"); - Assert.assertTrue(pkcs7.verifyTimestampImprint()); + Assertions.assertTrue(pkcs7.verifyTimestampImprint()); } @Test @@ -227,10 +228,10 @@ public void findCrlIsNotNullTest() throws IOException, CRLException { SignatureUtil sigUtil = new SignatureUtil(outDocument); PdfPKCS7 pkcs7 = sigUtil.readSignatureData("Signature1"); List crls = pkcs7.getCRLs().stream().map(crl -> (X509CRL) crl).collect(Collectors.toList()); - Assert.assertEquals(2, crls.size()); - Assert.assertArrayEquals(crls.get(0).getEncoded(), + Assertions.assertEquals(2, crls.size()); + Assertions.assertArrayEquals(crls.get(0).getEncoded(), Files.readAllBytes(Paths.get(SOURCE_FOLDER, "firstCrl.bin"))); - Assert.assertArrayEquals(crls.get(1).getEncoded(), + Assertions.assertArrayEquals(crls.get(1).getEncoded(), Files.readAllBytes(Paths.get(SOURCE_FOLDER, "secondCrl.bin"))); } @@ -239,7 +240,7 @@ public void findCrlNullSequenceNoExceptionTest() throws NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException { PdfPKCS7 pkcs7 = createSimplePdfPKCS7(); pkcs7.findCRL(null); - Assert.assertTrue(pkcs7.getCRLs().isEmpty()); + Assertions.assertTrue(pkcs7.getCRLs().isEmpty()); } @Test @@ -248,7 +249,7 @@ public void isRevocationValidWithInvalidOcspTest() throws IOException { new PdfReader(SOURCE_FOLDER + "signatureWithInvalidOcspTest.pdf")); SignatureUtil sigUtil = new SignatureUtil(outDocument); PdfPKCS7 pkcs7 = sigUtil.readSignatureData("Signature1"); - Assert.assertFalse(pkcs7.isRevocationValid()); + Assertions.assertFalse(pkcs7.isRevocationValid()); } @Test @@ -257,7 +258,7 @@ public void isRevocationValidWithValidOcspTest() throws IOException { new PdfReader(SOURCE_FOLDER + "signatureWithValidOcspTest.pdf")); SignatureUtil sigUtil = new SignatureUtil(outDocument); PdfPKCS7 pkcs7 = sigUtil.readSignatureData("Signature1"); - Assert.assertTrue(pkcs7.isRevocationValid()); + Assertions.assertTrue(pkcs7.isRevocationValid()); } @Test @@ -265,7 +266,7 @@ public void isRevocationValidOcspResponseIsNullTest() throws NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException { PdfPKCS7 pkcs7 = createSimplePdfPKCS7(); pkcs7.basicResp = null; - Assert.assertFalse(pkcs7.isRevocationValid()); + Assertions.assertFalse(pkcs7.isRevocationValid()); } @Test @@ -276,7 +277,7 @@ public void isRevocationValidLackOfSignCertsTest() BOUNCY_CASTLE_FACTORY.createASN1InputStream( Files.readAllBytes(Paths.get(SOURCE_FOLDER, "simpleOCSPResponse.bin"))).readObject()); pkcs7.signCerts = Collections.singleton(chain[0]); - Assert.assertFalse(pkcs7.isRevocationValid()); + Assertions.assertFalse(pkcs7.isRevocationValid()); } @Test @@ -287,7 +288,7 @@ public void isRevocationValidExceptionDuringValidationTest() BOUNCY_CASTLE_FACTORY.createASN1InputStream( Files.readAllBytes(Paths.get(SOURCE_FOLDER, "simpleOCSPResponse.bin"))).readObject()); pkcs7.signCerts = Arrays.asList(new Certificate[] {null, null}); - Assert.assertFalse(pkcs7.isRevocationValid()); + Assertions.assertFalse(pkcs7.isRevocationValid()); } @Test @@ -299,7 +300,7 @@ public void getEncodedPkcs1Test() byte[] cmpBytes = Files.readAllBytes(Paths.get(SOURCE_FOLDER + "cmpBytesPkcs1.txt")); IASN1OctetString outOctetString = BOUNCY_CASTLE_FACTORY.createASN1OctetString(bytes); IASN1OctetString cmpOctetString = BOUNCY_CASTLE_FACTORY.createASN1OctetString(cmpBytes); - Assert.assertEquals(outOctetString, cmpOctetString); + Assertions.assertEquals(outOctetString, cmpOctetString); } @Test @@ -307,8 +308,8 @@ public void getEncodedPkcs1NullPrivateKeyTest() throws NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException { String hashAlgorithm = DigestAlgorithms.SHA256; PdfPKCS7 pkcs7 = new PdfPKCS7(null, chain, hashAlgorithm, null, new BouncyCastleDigest(), true); - Exception exception = Assert.assertThrows(PdfException.class, () -> pkcs7.getEncodedPKCS1()); - Assert.assertEquals(KernelExceptionMessageConstant.UNKNOWN_PDF_EXCEPTION, exception.getMessage()); + Exception exception = Assertions.assertThrows(PdfException.class, () -> pkcs7.getEncodedPKCS1()); + Assertions.assertEquals(KernelExceptionMessageConstant.UNKNOWN_PDF_EXCEPTION, exception.getMessage()); } @Test @@ -317,9 +318,9 @@ public void getEncodedPkcs7UnknownExceptionTest() String hashAlgorithm = DigestAlgorithms.SHA256; PdfPKCS7 pkcs7 = new PdfPKCS7(pk, chain, hashAlgorithm, null, new BouncyCastleDigest(), true); TestTsaClient testTsa = new TestTsaClient(Arrays.asList(chain), pk); - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> pkcs7.getEncodedPKCS7(null, CryptoStandard.CMS, testTsa, null, null)); - Assert.assertEquals(KernelExceptionMessageConstant.UNKNOWN_PDF_EXCEPTION, exception.getMessage()); + Assertions.assertEquals(KernelExceptionMessageConstant.UNKNOWN_PDF_EXCEPTION, exception.getMessage()); } @Test @@ -331,8 +332,8 @@ public void getEncodedPkcs7Test() byte[] cmpBytes = Files.readAllBytes(Paths.get(SOURCE_FOLDER + "cmpBytesPkcs7.txt")); IASN1Primitive outStream = BOUNCY_CASTLE_FACTORY.createASN1Primitive(bytes); IASN1Primitive cmpStream = BOUNCY_CASTLE_FACTORY.createASN1Primitive(cmpBytes); - Assert.assertEquals("SHA256withRSA", pkcs7.getSignatureMechanismName()); - Assert.assertEquals(outStream, cmpStream); + Assertions.assertEquals("SHA256withRSA", pkcs7.getSignatureMechanismName()); + Assertions.assertEquals(outStream, cmpStream); } @Test @@ -345,19 +346,8 @@ public void getEncodedPkcs7WithRevocationInfoTest() throws NoSuchAlgorithmExcept Files.readAllBytes(Paths.get(SOURCE_FOLDER, "simpleOCSPResponse.bin"))).readObject())); byte[] bytes = pkcs7.getEncodedPKCS7(); byte[] cmpBytes = Files.readAllBytes(Paths.get(SOURCE_FOLDER + "cmpBytesPkcs7WithRevInfo.txt")); - Assert.assertEquals("SHA256withRSA", pkcs7.getSignatureMechanismName()); - Assert.assertEquals(serializedAsString(bytes), serializedAsString(cmpBytes)); - } - - @Test - public void verifyEd448SignatureTest() throws IOException, GeneralSecurityException { - // SHAKE256 is not available in BCFIPS - if ("BCFIPS".equals(BOUNCY_CASTLE_FACTORY.getProviderName())) { - Assert.assertThrows(PdfException.class, - () -> verifyIsoExtensionExample("Ed448", "sample-ed448-shake256.pdf")); - } else { - verifyIsoExtensionExample("Ed448", "sample-ed448-shake256.pdf"); - } + Assertions.assertEquals("SHA256withRSA", pkcs7.getSignatureMechanismName()); + Assertions.assertEquals(serializedAsString(bytes), serializedAsString(cmpBytes)); } @Test diff --git a/sign/src/test/java/com/itextpdf/signatures/PdfSignatureAppearanceUnitTest.java b/sign/src/test/java/com/itextpdf/signatures/PdfSignatureAppearanceUnitTest.java deleted file mode 100644 index 880886d1fe..0000000000 --- a/sign/src/test/java/com/itextpdf/signatures/PdfSignatureAppearanceUnitTest.java +++ /dev/null @@ -1,335 +0,0 @@ -/* - This file is part of the iText (R) project. - Copyright (c) 1998-2024 Apryse Group NV - Authors: Apryse Software. - - This program is offered under a commercial and under the AGPL license. - For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. - - AGPL licensing: - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . - */ -package com.itextpdf.signatures; - -import com.itextpdf.bouncycastleconnector.BouncyCastleFactoryCreator; -import com.itextpdf.commons.bouncycastle.IBouncyCastleFactory; -import com.itextpdf.commons.utils.DateTimeUtil; -import com.itextpdf.forms.form.FormProperty; -import com.itextpdf.forms.form.element.SignatureFieldAppearance; -import com.itextpdf.io.font.constants.StandardFonts; -import com.itextpdf.io.image.ImageData; -import com.itextpdf.io.image.ImageDataFactory; -import com.itextpdf.kernel.colors.Color; -import com.itextpdf.kernel.colors.ColorConstants; -import com.itextpdf.kernel.font.PdfFont; -import com.itextpdf.kernel.font.PdfFontFactory; -import com.itextpdf.kernel.geom.Rectangle; -import com.itextpdf.kernel.pdf.PdfDocument; -import com.itextpdf.kernel.pdf.PdfReader; -import com.itextpdf.kernel.pdf.PdfWriter; -import com.itextpdf.kernel.pdf.StampingProperties; -import com.itextpdf.kernel.pdf.xobject.PdfFormXObject; -import com.itextpdf.kernel.utils.CompareTool; -import com.itextpdf.layout.Document; -import com.itextpdf.layout.borders.SolidBorder; -import com.itextpdf.layout.font.FontProvider; -import com.itextpdf.layout.properties.Property; -import com.itextpdf.layout.properties.TextAlignment; -import com.itextpdf.signatures.PdfSignatureAppearance.RenderingMode; -import com.itextpdf.signatures.testutils.PemFileHelper; -import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.BouncyCastleUnitTest; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.security.Security; -import java.security.cert.Certificate; -import java.security.cert.CertificateException; -import java.util.Calendar; - -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -/** - * The idea of this test is to check the {@link PdfSignatureAppearance}'s getters. - * For actual result of setters invocations one should check the integration test for this class. - */ -@Category(BouncyCastleUnitTest.class) -public class PdfSignatureAppearanceUnitTest extends ExtendedITextTest { - // The source folder points to the integration test, so that the resources are nor duplicated - public static final String SOURCE_FOLDER - = "./src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/"; - public static final String DESTINATION_FOLDER - = "./target/test/com/itextpdf/signatures/sign/PdfSignatureAppearanceUnitTest/"; - public static final String KEYSTORE_PATH - = "./src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/test.pem"; - public static final char[] PASSWORD = "kspass".toCharArray(); - - private static final IBouncyCastleFactory BOUNCY_CASTLE_FACTORY = BouncyCastleFactoryCreator.getFactory(); - - private static Certificate[] chain; - - @BeforeClass - public static void before() throws IOException, CertificateException { - Security.addProvider(BOUNCY_CASTLE_FACTORY.getProvider()); - createOrClearDestinationFolder(DESTINATION_FOLDER); - chain = PemFileHelper.readFirstChain(KEYSTORE_PATH); - } - - @Test - public void reasonCaptionTest() throws IOException { - PdfSignatureAppearance signatureAppearance = getTestSignatureAppearance(); - - String newReasonCaption = "Hello World"; - - Assert.assertNull(signatureAppearance.getLayer2Text()); - - String layer2Text = signatureAppearance.generateSignatureText().generateDescriptionText(); - // There is no text from new reason caption in the default layer 2 text - Assert.assertFalse(layer2Text.contains(newReasonCaption)); - - signatureAppearance.setReasonCaption(newReasonCaption); - layer2Text = signatureAppearance.generateSignatureText().generateDescriptionText(); - // Now layer 2 text contains text from new reason caption - Assert.assertTrue(layer2Text.contains(newReasonCaption)); - } - - @Test - public void locationCaptionTest() throws IOException { - PdfSignatureAppearance signatureAppearance = getTestSignatureAppearance(); - - String newLocationCaption = "Hello World"; - - Assert.assertNull(signatureAppearance.getLayer2Text()); - - String layer2Text = signatureAppearance.generateSignatureText().generateDescriptionText(); - // There is no text from new location caption in the default layer 2 text - Assert.assertFalse(layer2Text.contains(newLocationCaption)); - - signatureAppearance.setLocationCaption(newLocationCaption); - layer2Text = signatureAppearance.generateSignatureText().generateDescriptionText(); - // Now layer 2 text contains text from new location caption - Assert.assertTrue(layer2Text.contains(newLocationCaption)); - } - - @Test - public void renderingModeSetGetTest() throws IOException { - PdfSignatureAppearance signatureAppearance = getTestSignatureAppearance(); - - RenderingMode defaultMode = signatureAppearance.getRenderingMode(); - Assert.assertEquals(RenderingMode.DESCRIPTION, defaultMode); - - RenderingMode testRenderingMode = RenderingMode.GRAPHIC_AND_DESCRIPTION; - signatureAppearance.setRenderingMode(testRenderingMode); - Assert.assertEquals(testRenderingMode, signatureAppearance.getRenderingMode()); - } - - @Test - public void signatureCreatorSetGetTest() throws IOException { - PdfSignatureAppearance signatureAppearance = getTestSignatureAppearance(); - - Assert.assertEquals("", signatureAppearance.getSignatureCreator()); - - String signatureCreator = "Hello World"; - signatureAppearance.setSignatureCreator(signatureCreator); - Assert.assertEquals(signatureCreator, signatureAppearance.getSignatureCreator()); - } - - @Test - public void contactSetGetTest() throws IOException { - PdfSignatureAppearance signatureAppearance = getTestSignatureAppearance(); - - Assert.assertEquals("", signatureAppearance.getContact()); - - String contact = "Hello World"; - signatureAppearance.setContact(contact); - Assert.assertEquals(contact, signatureAppearance.getContact()); - } - - @Test - public void certificateSetGetTest() throws IOException { - PdfSignatureAppearance signatureAppearance = getTestSignatureAppearance(); - - Assert.assertNull(signatureAppearance.getCertificate()); - - Certificate testCertificate = chain[0]; - signatureAppearance.setCertificate(testCertificate); - Assert.assertEquals(testCertificate, signatureAppearance.getCertificate()); - } - - @Test - public void signatureGraphicSetGetTest() throws IOException { - PdfSignatureAppearance signatureAppearance = getTestSignatureAppearance(); - - Assert.assertNull(signatureAppearance.getSignatureGraphic()); - - ImageData testImageData = ImageDataFactory.create(SOURCE_FOLDER + "itext.png"); - signatureAppearance.setSignatureGraphic(testImageData); - Assert.assertEquals(testImageData, signatureAppearance.getSignatureGraphic()); - } - - @Test - public void imageSetGetTest() throws IOException { - PdfSignatureAppearance signatureAppearance = getTestSignatureAppearance(); - - Assert.assertNull(signatureAppearance.getImage()); - - ImageData testImageData = ImageDataFactory.create(SOURCE_FOLDER + "itext.png"); - signatureAppearance.setImage(testImageData); - Assert.assertEquals(testImageData, signatureAppearance.getImage()); - } - - @Test - public void imageScalingSetGetTest() throws IOException { - PdfSignatureAppearance signatureAppearance = getTestSignatureAppearance(); - - Assert.assertEquals(0, signatureAppearance.getImageScale(), 0.0001); - - float newScale = 1F; - signatureAppearance.setImageScale(newScale); - Assert.assertEquals(newScale, signatureAppearance.getImageScale(), 0.0001); - } - - @Test - public void layer2FontSetGetTest() throws IOException { - PdfSignatureAppearance signatureAppearance = getTestSignatureAppearance(); - - Assert.assertNull(signatureAppearance.getLayer2Font()); - - PdfFont newFont = PdfFontFactory.createFont(); - signatureAppearance.setLayer2Font(newFont); - Assert.assertEquals(newFont, signatureAppearance.getLayer2Font()); - } - - @Test - public void setFontProviderAndFamilyTest() throws IOException { - PdfSignatureAppearance appearance = getTestSignatureAppearance(); - - FontProvider fontProvider = new FontProvider(); - fontProvider.getFontSet().addFont(StandardFonts.HELVETICA, ""); - String fontFamilyName = "fontFamily"; - appearance.setFontProvider(fontProvider).setFontFamily(fontFamilyName); - Assert.assertEquals(fontProvider, - appearance.getSignatureAppearance().getProperty(Property.FONT_PROVIDER)); - Assert.assertEquals(fontFamilyName, - ((String[]) appearance.getSignatureAppearance().getProperty(Property.FONT))[0]); - } - - @Test - public void layer2FontSizeSetGetTest() throws IOException { - PdfSignatureAppearance signatureAppearance = getTestSignatureAppearance(); - - Assert.assertEquals(0, signatureAppearance.getLayer2FontSize(), 0.0001); - - float newSize = 12F; - signatureAppearance.setLayer2FontSize(newSize); - Assert.assertEquals(newSize, signatureAppearance.getLayer2FontSize(), 0.0001); - } - - - @Test - public void layer2FontColorSetGetTest() throws IOException { - PdfSignatureAppearance signatureAppearance = getTestSignatureAppearance(); - - Assert.assertNull(signatureAppearance.getLayer2FontColor()); - - Color newColor = ColorConstants.RED; - signatureAppearance.setLayer2FontColor(newColor); - Assert.assertEquals(newColor, signatureAppearance.getLayer2FontColor()); - } - - @Test - public void getAppearanceInvisibleTest() { - PdfSignatureAppearance appearance = new PdfSignatureAppearance( - new PdfDocument(new PdfWriter(new ByteArrayOutputStream())), - new Rectangle(0, 100), 1); - PdfFormXObject xObject = appearance.getAppearance(); - - Assert.assertTrue(new Rectangle(0, 0).equalsWithEpsilon(xObject.getBBox().toRectangle())); - } - - @Test - public void getSignDateTest() { - PdfSignatureAppearance appearance = new PdfSignatureAppearance(null, new Rectangle(100, 100), 1); - - Calendar current = DateTimeUtil.getCurrentTimeCalendar(); - appearance.setSignDate(current); - Assert.assertEquals(current, appearance.getSignDate()); - } - - @Test - public void wrongRenderingModeTest() { - try (Document ignored = new Document(new PdfDocument(new PdfWriter(new ByteArrayOutputStream())))) { - PdfSignatureAppearance appearance = new PdfSignatureAppearance(null, new Rectangle(100, 100), 1); - appearance.setRenderingMode(RenderingMode.GRAPHIC_AND_DESCRIPTION); - Assert.assertThrows(IllegalStateException.class, () -> appearance.getSignatureAppearance()); - - PdfSignatureAppearance appearance2 = new PdfSignatureAppearance(null, new Rectangle(100, 100), 1); - appearance2.setRenderingMode(RenderingMode.GRAPHIC); - Assert.assertThrows(IllegalStateException.class, () -> appearance2.getSignatureAppearance()); - } - } - - @Test - public void backgroundImageTest() throws IOException, InterruptedException { - String outPdf = DESTINATION_FOLDER + "signatureFieldBackground.pdf"; - String cmpPdf = SOURCE_FOLDER + "cmp_signatureFieldBackground.pdf"; - PdfSignatureAppearance appearance = new PdfSignatureAppearance(null, new Rectangle(100, 100), 1); - - try (Document document = new Document(new PdfDocument(new PdfWriter(outPdf)))) { - SignatureFieldAppearance field1 = new SignatureFieldAppearance("field1"); - field1.setProperty(FormProperty.FORM_FIELD_FLATTEN, true); - field1.setContent("scale -1").setFontColor(ColorConstants.GREEN).setFontSize(50) - .setBorder(new SolidBorder(ColorConstants.RED, 10)).setHeight(200).setWidth(300) - .setProperty(Property.TEXT_ALIGNMENT, TextAlignment.CENTER); - appearance.setSignatureAppearance(field1) - .setImage(ImageDataFactory.create(SOURCE_FOLDER + "1.png")) - .setImageScale(-1) - .applyBackgroundImage(); - document.add(field1); - - SignatureFieldAppearance field2 = new SignatureFieldAppearance("field2"); - field2.setProperty(FormProperty.FORM_FIELD_FLATTEN, true); - field2.setContent("scale 0").setFontColor(ColorConstants.GREEN).setFontSize(50) - .setBorder(new SolidBorder(ColorConstants.YELLOW, 10)).setHeight(200).setWidth(300) - .setProperty(Property.TEXT_ALIGNMENT, TextAlignment.CENTER); - appearance.setSignatureAppearance(field2) - .setImage(ImageDataFactory.create(SOURCE_FOLDER + "1.png")) - .setImageScale(0) - .applyBackgroundImage(); - document.add(field2); - - SignatureFieldAppearance field3 = new SignatureFieldAppearance("field3"); - field3.setProperty(FormProperty.FORM_FIELD_FLATTEN, true); - field3.setContent("scale 0.5").setFontColor(ColorConstants.GREEN).setFontSize(50) - .setBorder(new SolidBorder(ColorConstants.GREEN, 10)).setHeight(200).setWidth(300) - .setProperty(Property.TEXT_ALIGNMENT, TextAlignment.CENTER); - appearance.setSignatureAppearance(field3) - .setImage(ImageDataFactory.create(SOURCE_FOLDER + "1.png")) - .setImageScale(0.5f) - .applyBackgroundImage(); - document.add(field3); - } - - Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); - } - - private static PdfSignatureAppearance getTestSignatureAppearance() throws IOException { - String src = SOURCE_FOLDER + "simpleDocument.pdf"; - PdfSigner signer = new PdfSigner(new PdfReader(src), new ByteArrayOutputStream(), new StampingProperties()); - return signer.getSignatureAppearance(); - } -} diff --git a/sign/src/test/java/com/itextpdf/signatures/PdfSignatureBuildPropertiesUnitTest.java b/sign/src/test/java/com/itextpdf/signatures/PdfSignatureBuildPropertiesUnitTest.java index 6eafbae194..a2e3f8e7c3 100644 --- a/sign/src/test/java/com/itextpdf/signatures/PdfSignatureBuildPropertiesUnitTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/PdfSignatureBuildPropertiesUnitTest.java @@ -26,12 +26,11 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfName; import com.itextpdf.kernel.pdf.PdfObject; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfSignatureBuildPropertiesUnitTest extends ExtendedITextTest { @Test @@ -41,9 +40,9 @@ public void setSignatureCreatorTest() { properties.getPdfObject().put(PdfName.App, appPropDic); properties.setSignatureCreator("sign_creator"); PdfObject appDict = properties.getPdfObject().get(PdfName.App); - Assert.assertTrue(appDict instanceof PdfDictionary); + Assertions.assertTrue(appDict instanceof PdfDictionary); PdfObject name = ((PdfDictionary) appDict).get(PdfName.Name); - Assert.assertTrue(name instanceof PdfName); - Assert.assertEquals("sign_creator", ((PdfName) name).getValue()); + Assertions.assertTrue(name instanceof PdfName); + Assertions.assertEquals("sign_creator", ((PdfName) name).getValue()); } } diff --git a/sign/src/test/java/com/itextpdf/signatures/PdfSignerUnitTest.java b/sign/src/test/java/com/itextpdf/signatures/PdfSignerUnitTest.java index 5a2d7cd205..4a99662a4e 100644 --- a/sign/src/test/java/com/itextpdf/signatures/PdfSignerUnitTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/PdfSignerUnitTest.java @@ -35,12 +35,14 @@ This file is part of the iText (R) project. import com.itextpdf.forms.fields.PdfFormField; import com.itextpdf.forms.fields.PdfSignatureFormField; import com.itextpdf.forms.fields.SignatureFormFieldBuilder; +import com.itextpdf.forms.form.element.SignatureFieldAppearance; import com.itextpdf.io.source.ByteArrayOutputStream; +import com.itextpdf.kernel.crypto.DigestAlgorithms; import com.itextpdf.kernel.exceptions.PdfException; import com.itextpdf.kernel.geom.Rectangle; import com.itextpdf.kernel.logs.KernelLogMessageConstant; import com.itextpdf.kernel.pdf.EncryptionConstants; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfAConformance; import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfName; @@ -54,7 +56,6 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.WriterProperties; import com.itextpdf.kernel.pdf.annot.PdfWidgetAnnotation; import com.itextpdf.kernel.pdf.xobject.PdfFormXObject; -import com.itextpdf.pdfa.PdfAAgnosticPdfDocument; import com.itextpdf.pdfa.PdfADocument; import com.itextpdf.signatures.PdfSigner.ISignatureEvent; import com.itextpdf.signatures.exceptions.SignExceptionMessageConstant; @@ -62,7 +63,6 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.BouncyCastleUnitTest; import java.io.ByteArrayInputStream; import java.io.IOException; @@ -73,13 +73,13 @@ This file is part of the iText (R) project. import java.security.cert.Certificate; import java.security.cert.CertificateException; import java.util.Calendar; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(BouncyCastleUnitTest.class) +@Tag("BouncyCastleUnitTest") public class PdfSignerUnitTest extends ExtendedITextTest { private static final IBouncyCastleFactory FACTORY = BouncyCastleFactoryCreator.getFactory(); @@ -96,13 +96,13 @@ public class PdfSignerUnitTest extends ExtendedITextTest { private PrivateKey pk; - @BeforeClass + @BeforeAll public static void before() { Security.addProvider(FACTORY.getProvider()); createOrClearDestinationFolder(DESTINATION_FOLDER); } - @Before + @BeforeEach public void init() throws IOException, CertificateException, AbstractPKCSException, AbstractOperatorCreationException { pk = PemFileHelper.readFirstKey(CERTS_SRC + "signCertRsa01.pem", PASSWORD); @@ -117,17 +117,19 @@ public void createNewSignatureFormFieldInvisibleAnnotationTest() throws IOExcept new ByteArrayInputStream(createEncryptedDocumentWithoutWidgetAnnotation()), new ReaderProperties().setPassword(OWNER)), new ByteArrayOutputStream(), new StampingProperties()); signer.cryptoDictionary = new PdfSignature(); - signer.setPageRect(new Rectangle(100, 100, 0, 0)); + SignerProperties signerProperties = new SignerProperties() + .setPageRect(new Rectangle(100, 100, 0, 0)); + signer.setSignerProperties(signerProperties); PdfAcroForm acroForm = PdfFormCreator.getAcroForm(signer.document, true); - signer.createNewSignatureFormField(acroForm, signer.fieldName); - PdfFormField formField = acroForm.getField(signer.fieldName); + signer.createNewSignatureFormField(acroForm, signerProperties.getFieldName()); + PdfFormField formField = acroForm.getField(signerProperties.getFieldName()); PdfDictionary formFieldDictionary = formField.getPdfObject(); - Assert.assertNotNull(formFieldDictionary); - Assert.assertTrue(formFieldDictionary.containsKey(PdfName.AP)); + Assertions.assertNotNull(formFieldDictionary); + Assertions.assertTrue(formFieldDictionary.containsKey(PdfName.AP)); PdfFormXObject ap = new PdfFormXObject(formFieldDictionary.getAsDictionary(PdfName.AP).getAsStream(PdfName.N)); - Assert.assertTrue(new Rectangle(0, 0).equalsWithEpsilon(ap.getBBox().toRectangle())); + Assertions.assertTrue(new Rectangle(0, 0).equalsWithEpsilon(ap.getBBox().toRectangle())); } @Test @@ -138,17 +140,19 @@ public void createNewSignatureFormFieldNotInvisibleAnnotationTest() throws IOExc new PdfReader(new ByteArrayInputStream(createEncryptedDocumentWithoutWidgetAnnotation()), new ReaderProperties().setPassword(OWNER)), new ByteArrayOutputStream(), new StampingProperties()); signer.cryptoDictionary = new PdfSignature(); - signer.setPageRect(new Rectangle(100, 100, 10, 10)); PdfSigFieldLock fieldLock = new PdfSigFieldLock(); - signer.fieldLock = fieldLock; + SignerProperties signerProperties = new SignerProperties() + .setPageRect(new Rectangle(100, 100, 10, 10)) + .setFieldLockDict(fieldLock); + signer.setSignerProperties(signerProperties); PdfAcroForm acroForm = PdfFormCreator.getAcroForm(signer.document, true); - Assert.assertEquals(fieldLock, signer.createNewSignatureFormField(acroForm, signer.fieldName)); - PdfFormField formField = acroForm.getField(signer.fieldName); + Assertions.assertEquals(fieldLock, signer.createNewSignatureFormField(acroForm, signerProperties.getFieldName())); + PdfFormField formField = acroForm.getField(signerProperties.getFieldName()); PdfDictionary formFieldDictionary = formField.getPdfObject(); - Assert.assertNotNull(formFieldDictionary); - Assert.assertTrue(formFieldDictionary.containsKey(PdfName.AP)); + Assertions.assertNotNull(formFieldDictionary); + Assertions.assertTrue(formFieldDictionary.containsKey(PdfName.AP)); } @Test @@ -158,12 +162,14 @@ public void signWithFieldLockNotNullTest() throws IOException, GeneralSecurityEx new ByteArrayOutputStream(), new StampingProperties()); signer.cryptoDictionary = new PdfSignature(); - signer.setPageRect(new Rectangle(100, 100, 10, 10)); - signer.fieldLock = new PdfSigFieldLock(); + SignerProperties signerProperties = new SignerProperties() + .setPageRect(new Rectangle(100, 100, 10, 10)) + .setFieldLockDict(new PdfSigFieldLock()); + signer.setSignerProperties(signerProperties); IExternalSignature pks = new PrivateKeySignature(pk, DigestAlgorithms.SHA256, FACTORY.getProviderName()); signer.signDetached(new BouncyCastleDigest(), pks, chain, null, null, null, 0, PdfSigner.CryptoStandard.CADES); - Assert.assertTrue(signer.closed); + Assertions.assertTrue(signer.closed); } @Test @@ -175,10 +181,10 @@ public void signDetachedWhenAlreadySignedIsNotPossibleTest() throws IOException, IExternalSignature pks = new PrivateKeySignature(pk, DigestAlgorithms.SHA256, FACTORY.getProviderName()); signer.signDetached(new BouncyCastleDigest(), pks, chain, null, null, null, 0, PdfSigner.CryptoStandard.CADES); - Exception e = Assert.assertThrows(PdfException.class, () -> + Exception e = Assertions.assertThrows(PdfException.class, () -> signer.signDetached(new BouncyCastleDigest(), pks, chain, null, null, null, 0, PdfSigner.CryptoStandard.CADES)); - Assert.assertEquals(SignExceptionMessageConstant.THIS_INSTANCE_OF_PDF_SIGNER_ALREADY_CLOSED, e.getMessage()); + Assertions.assertEquals(SignExceptionMessageConstant.THIS_INSTANCE_OF_PDF_SIGNER_ALREADY_CLOSED, e.getMessage()); } @Test @@ -190,9 +196,9 @@ public void signExternalWhenAlreadySignedIsNotPossibleTest() throws IOException, IExternalSignature pks = new PrivateKeySignature(pk, DigestAlgorithms.SHA256, FACTORY.getProviderName()); signer.signDetached(new BouncyCastleDigest(), pks, chain, null, null, null, 0, PdfSigner.CryptoStandard.CADES); - Exception e = Assert.assertThrows(PdfException.class, () -> + Exception e = Assertions.assertThrows(PdfException.class, () -> signer.signExternalContainer(new ExternalBlankSignatureContainer(new PdfDictionary()), 0)); - Assert.assertEquals(SignExceptionMessageConstant.THIS_INSTANCE_OF_PDF_SIGNER_ALREADY_CLOSED, e.getMessage()); + Assertions.assertEquals(SignExceptionMessageConstant.THIS_INSTANCE_OF_PDF_SIGNER_ALREADY_CLOSED, e.getMessage()); } @Test @@ -210,21 +216,23 @@ public void populateExistingSignatureFormFieldInvisibleAnnotationTest() throws I new PdfReader(new ByteArrayInputStream(outputStream.toByteArray()), new ReaderProperties().setPassword(OWNER)), new ByteArrayOutputStream(), new StampingProperties()); signer.cryptoDictionary = new PdfSignature(); - signer.setPageRect(new Rectangle(100, 100, 0, 0)); + SignerProperties signerProperties = new SignerProperties() + .setPageRect(new Rectangle(100, 100, 0, 0)); + signer.setSignerProperties(signerProperties); widgetAnnotation = (PdfWidgetAnnotation) signer.document.getPage(1).getAnnotations().get(0); PdfAcroForm acroForm = PdfFormCreator.getAcroForm(signer.document, true); PdfFormField formField = new ExtendedPdfSignatureFormField(widgetAnnotation, signer.document); - formField.setFieldName(signer.fieldName); + formField.setFieldName(signerProperties.getFieldName()); acroForm.addField(formField); signer.populateExistingSignatureFormField(acroForm); - formField = acroForm.getField(signer.fieldName); + formField = acroForm.getField(signerProperties.getFieldName()); PdfDictionary formFieldDictionary = formField.getPdfObject(); - Assert.assertNotNull(formFieldDictionary); - Assert.assertTrue(formFieldDictionary.containsKey(PdfName.AP)); + Assertions.assertNotNull(formFieldDictionary); + Assertions.assertTrue(formFieldDictionary.containsKey(PdfName.AP)); PdfFormXObject ap = new PdfFormXObject(formFieldDictionary.getAsDictionary(PdfName.AP).getAsStream(PdfName.N)); - Assert.assertTrue(new Rectangle(0, 0).equalsWithEpsilon(ap.getBBox().toRectangle())); + Assertions.assertTrue(new Rectangle(0, 0).equalsWithEpsilon(ap.getBBox().toRectangle())); } @Test @@ -243,20 +251,56 @@ public void populateExistingSignatureFormFieldNotInvisibleAnnotationTest() throw new ByteArrayOutputStream(), new StampingProperties()); signer.cryptoDictionary = new PdfSignature(); PdfSigFieldLock fieldLock = new PdfSigFieldLock(); - signer.fieldLock = fieldLock; - signer.setPageRect(new Rectangle(100, 100, 10, 10)); + SignerProperties signerProperties = new SignerProperties() + .setPageRect(new Rectangle(100, 100, 10, 10)) + .setFieldLockDict(fieldLock); + signer.setSignerProperties(signerProperties); widgetAnnotation = (PdfWidgetAnnotation) signer.document.getPage(1).getAnnotations().get(0); PdfAcroForm acroForm = PdfFormCreator.getAcroForm(signer.document, true); PdfFormField formField = new ExtendedPdfSignatureFormField(widgetAnnotation, signer.document); - formField.setFieldName(signer.fieldName); + formField.setFieldName(signerProperties.getFieldName()); acroForm.addField(formField); - Assert.assertEquals(signer.populateExistingSignatureFormField(acroForm), fieldLock); - formField = acroForm.getField(signer.fieldName); + Assertions.assertEquals(signer.populateExistingSignatureFormField(acroForm), fieldLock); + formField = acroForm.getField(signerProperties.getFieldName()); PdfDictionary formFieldDictionary = formField.getPdfObject(); - Assert.assertNotNull(formFieldDictionary); - Assert.assertTrue(formFieldDictionary.containsKey(PdfName.AP)); + Assertions.assertNotNull(formFieldDictionary); + Assertions.assertTrue(formFieldDictionary.containsKey(PdfName.AP)); + } + + @Test + public void setAlternativeName() throws IOException, GeneralSecurityException { + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + PdfDocument document = new PdfDocument(new PdfWriter(outputStream, new WriterProperties())); + document.setTagged(); + document.addNewPage(); + document.close(); + + ByteArrayOutputStream signedOutputStream = new ByteArrayOutputStream(); + PdfSigner signer = new PdfSigner( + new PdfReader(new ByteArrayInputStream(outputStream.toByteArray())), signedOutputStream, + new StampingProperties()); + SignerProperties signerProperties = new SignerProperties() + .setFieldName("Signature1") + .setPageNumber(1) + .setPageRect(new Rectangle(100, 100, 10, 10)); + signer.setSignerProperties(signerProperties); + + SignatureFieldAppearance appearance = new SignatureFieldAppearance(SignerProperties.IGNORED_ID); + appearance.setContent("Some text"); + appearance.getAccessibilityProperties().setAlternateDescription("Alternate description"); + signerProperties.setSignatureAppearance(appearance); + + IExternalSignature pks = new PrivateKeySignature(pk, DigestAlgorithms.SHA256, FACTORY.getProviderName()); + signer.signDetached(new BouncyCastleDigest(), pks, chain, null, null, null, 0, PdfSigner.CryptoStandard.CADES); + + signer.document.close(); + + PdfDocument signedDocument = new PdfDocument(new PdfReader(new ByteArrayInputStream(signedOutputStream.toByteArray())), new PdfWriter(new ByteArrayOutputStream())); + PdfAcroForm acroForm = PdfFormCreator.getAcroForm(signedDocument, true); + PdfFormField formField = acroForm.getField(signerProperties.getFieldName()); + Assertions.assertEquals("Alternate description", formField.getPdfObject().get(PdfName.TU).toString()); } @Test @@ -265,9 +309,9 @@ public void tempFileProvidedTest() throws IOException { PdfSigner signer = new PdfSigner( new PdfReader(new ByteArrayInputStream(createSimpleDocument())), new ByteArrayOutputStream(), DESTINATION_FOLDER + tempFileName, new StampingProperties()); - Assert.assertNotNull(signer.tempFile); - Assert.assertEquals(tempFileName, signer.tempFile.getName()); - Assert.assertNull(signer.temporaryOS); + Assertions.assertNotNull(signer.tempFile); + Assertions.assertEquals(tempFileName, signer.tempFile.getName()); + Assertions.assertNull(signer.temporaryOS); } // Android-Conversion-Skip-Block-Start (TODO DEVSIX-7372 investigate why a few tests related to PdfA in PdfSignerUnitTest were cut) @@ -276,7 +320,7 @@ public void initPdfaDocumentTest() throws IOException { PdfSigner signer = new PdfSigner( new PdfReader(new ByteArrayInputStream(createSimplePdfaDocument())), new ByteArrayOutputStream(), new StampingProperties()); - Assert.assertEquals(PdfAConformanceLevel.PDF_A_1A, ((PdfAAgnosticPdfDocument) signer.getDocument()).getConformanceLevel()); + Assertions.assertEquals(PdfAConformance.PDF_A_1A, signer.getDocument().getConformance().getAConformance()); } @Test @@ -285,9 +329,11 @@ public void signingDateSetGetTest() throws IOException { new PdfReader(new ByteArrayInputStream(createSimplePdfaDocument())), new ByteArrayOutputStream(), new StampingProperties()); Calendar testDate = DateTimeUtil.getCurrentTimeCalendar(); - signer.setSignDate(testDate); + SignerProperties signerProperties = new SignerProperties() + .setClaimedSignDate(testDate); + signer.setSignerProperties(signerProperties); - Assert.assertEquals(testDate, signer.getSignDate()); + Assertions.assertEquals(testDate, signerProperties.getClaimedSignDate()); } @Test @@ -295,11 +341,11 @@ public void certificationLevelSetGetTest() throws IOException { PdfSigner signer = new PdfSigner( new PdfReader(new ByteArrayInputStream(createSimplePdfaDocument())), new ByteArrayOutputStream(), new StampingProperties()); - Assert.assertEquals(PdfSigner.NOT_CERTIFIED, signer.getCertificationLevel()); + Assertions.assertEquals(AccessPermissions.UNSPECIFIED, signer.getSignerProperties().getCertificationLevel()); - int testLevel = PdfSigner.CERTIFIED_NO_CHANGES_ALLOWED; - signer.setCertificationLevel(testLevel); - Assert.assertEquals(testLevel, signer.getCertificationLevel()); + AccessPermissions testLevel = AccessPermissions.NO_CHANGES_PERMITTED; + signer.getSignerProperties().setCertificationLevel(testLevel); + Assertions.assertEquals(testLevel, signer.getSignerProperties().getCertificationLevel()); } @Test @@ -307,11 +353,11 @@ public void signatureDictionarySetGetTest() throws IOException { PdfSigner signer = new PdfSigner( new PdfReader(new ByteArrayInputStream(createSimplePdfaDocument())), new ByteArrayOutputStream(), new StampingProperties()); - Assert.assertNull(signer.getSignatureDictionary()); + Assertions.assertNull(signer.getSignatureDictionary()); PdfSignature testSignature = new PdfSignature(); signer.cryptoDictionary = testSignature; - Assert.assertEquals(testSignature, signer.getSignatureDictionary()); + Assertions.assertEquals(testSignature, signer.getSignatureDictionary()); } @Test @@ -319,11 +365,11 @@ public void signatureEventSetGetTest() throws IOException { PdfSigner signer = new PdfSigner( new PdfReader(new ByteArrayInputStream(createSimplePdfaDocument())), new ByteArrayOutputStream(), new StampingProperties()); - Assert.assertNull(signer.getSignatureEvent()); + Assertions.assertNull(signer.getSignatureEvent()); ISignatureEvent testEvent = new DummySignatureEvent(); signer.setSignatureEvent(testEvent); - Assert.assertEquals(testEvent, signer.getSignatureEvent()); + Assertions.assertEquals(testEvent, signer.getSignatureEvent()); } @Test @@ -331,10 +377,31 @@ public void signatureFieldNameMustNotContainDotTest() throws IOException { PdfSigner signer = new PdfSigner( new PdfReader(new ByteArrayInputStream(createSimplePdfaDocument())), new ByteArrayOutputStream(), new StampingProperties()); + SignerProperties signerProperties = new SignerProperties() + .setFieldName("name.with.dots"); + Exception exception = + Assertions.assertThrows(IllegalArgumentException.class, () -> signer.setSignerProperties(signerProperties)); + Assertions.assertEquals(SignExceptionMessageConstant.FIELD_NAMES_CANNOT_CONTAIN_A_DOT, exception.getMessage()); + } + + @Test + public void changeSignatureFieldNameToInvalidTest() throws IOException { + PdfSigner signer = new PdfSigner( + new PdfReader(new ByteArrayInputStream(createSimplePdfaDocument())), + new ByteArrayOutputStream(), new StampingProperties()); + SignerProperties signerProperties = new SignerProperties(); + signer.setSignerProperties(signerProperties); + Assertions.assertEquals("Signature1", signer.getSignerProperties().getFieldName()); + + signerProperties.setFieldName("name.with.dots"); + Assertions.assertEquals("name.with.dots", signer.getSignerProperties().getFieldName()); + IExternalSignature pks = new PrivateKeySignature(pk, DigestAlgorithms.SHA256, FACTORY.getProviderName()); Exception exception = - Assert.assertThrows(IllegalArgumentException.class, () -> signer.setFieldName("name.with.dots")); - Assert.assertEquals(SignExceptionMessageConstant.FIELD_NAMES_CANNOT_CONTAIN_A_DOT, exception.getMessage()); + Assertions.assertThrows(IllegalArgumentException.class, + () -> signer.signDetached(new BouncyCastleDigest(), pks, chain, null, null, null, 0, + PdfSigner.CryptoStandard.CADES)); + Assertions.assertEquals(SignExceptionMessageConstant.FIELD_NAMES_CANNOT_CONTAIN_A_DOT, exception.getMessage()); } @Test @@ -344,8 +411,8 @@ public void documentWithoutReaderCannotBeSetToSignerTest() throws IOException { PdfDocument documentWithoutReader = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); Exception e = - Assert.assertThrows(IllegalArgumentException.class, () -> signer.setDocument(documentWithoutReader)); - Assert.assertEquals(SignExceptionMessageConstant.DOCUMENT_MUST_HAVE_READER, e.getMessage()); + Assertions.assertThrows(IllegalArgumentException.class, () -> signer.setDocument(documentWithoutReader)); + Assertions.assertEquals(SignExceptionMessageConstant.DOCUMENT_MUST_HAVE_READER, e.getMessage()); } @Test @@ -354,13 +421,13 @@ public void documentSetGetTest() throws IOException { PdfSigner signer = new PdfSigner(reader, new ByteArrayOutputStream(), new StampingProperties()); PdfDocument document = signer.getDocument(); - Assert.assertEquals(reader, document.getReader()); + Assertions.assertEquals(reader, document.getReader()); PdfDocument documentWithoutReader = new PdfDocument( new PdfReader(new ByteArrayInputStream(createSimpleDocument())), new PdfWriter(new ByteArrayOutputStream())); signer.setDocument(documentWithoutReader); - Assert.assertEquals(documentWithoutReader, signer.getDocument()); + Assertions.assertEquals(documentWithoutReader, signer.getDocument()); } @Test @@ -369,11 +436,11 @@ public void outputStreamSetGetTest() throws IOException { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); PdfSigner signer = new PdfSigner(reader, outputStream, new StampingProperties()); - Assert.assertEquals(outputStream, signer.originalOS); + Assertions.assertEquals(outputStream, signer.originalOS); ByteArrayOutputStream anotherStream = new ByteArrayOutputStream(); signer.setOriginalOutputStream(anotherStream); - Assert.assertEquals(anotherStream, signer.originalOS); + Assertions.assertEquals(anotherStream, signer.originalOS); } @Test @@ -382,11 +449,11 @@ public void fieldLockSetGetTest() throws IOException { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); PdfSigner signer = new PdfSigner(reader, outputStream, new StampingProperties()); - Assert.assertNull(signer.getFieldLockDict()); + Assertions.assertNull(signer.getSignerProperties().getFieldLockDict()); PdfSigFieldLock fieldLock = new PdfSigFieldLock(); - signer.setFieldLockDict(fieldLock); - Assert.assertEquals(fieldLock, signer.getFieldLockDict()); + signer.getSignerProperties().setFieldLockDict(fieldLock); + Assertions.assertEquals(fieldLock, signer.getSignerProperties().getFieldLockDict()); } // Android-Conversion-Skip-Block-End @@ -396,8 +463,10 @@ public void setFieldNameNullForDefaultSignerTest() throws IOException { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); PdfSigner signer = new PdfSigner(reader, outputStream, new StampingProperties()); - signer.setFieldName(null); - Assert.assertEquals("Signature1", signer.getFieldName()); + SignerProperties signerProperties = new SignerProperties() + .setFieldName(null); + signer.setSignerProperties(signerProperties); + Assertions.assertEquals("Signature1", signer.getSignerProperties().getFieldName()); } @Test @@ -407,9 +476,10 @@ public void keepFieldNameAfterSetToNullTest() throws IOException { PdfSigner signer = new PdfSigner(reader, outputStream, new StampingProperties()); String testName = "test_name"; - signer.setFieldName(testName); - signer.setFieldName(null); - Assert.assertEquals(testName, signer.getFieldName()); + SignerProperties signerProperties = new SignerProperties().setFieldName(testName); + signer.setSignerProperties(signerProperties); + signerProperties.setFieldName(null); + Assertions.assertEquals(testName, signer.getSignerProperties().getFieldName()); } @Test @@ -417,8 +487,10 @@ public void setFieldNameToFieldWithSameNameAndNoSigTest() throws IOException { PdfReader reader = new PdfReader(new ByteArrayInputStream(createDocumentWithEmptyField())); PdfSigner signer = new PdfSigner(reader, new ByteArrayOutputStream(), new StampingProperties()); - Exception e = Assert.assertThrows(IllegalArgumentException.class, () -> signer.setFieldName("test_field")); - Assert.assertEquals(SignExceptionMessageConstant.FIELD_TYPE_IS_NOT_A_SIGNATURE_FIELD_TYPE, e.getMessage()); + SignerProperties signerProperties = new SignerProperties().setFieldName("test_field"); + Exception e = Assertions.assertThrows(IllegalArgumentException.class, + () -> signer.setSignerProperties(signerProperties)); + Assertions.assertEquals(SignExceptionMessageConstant.FIELD_TYPE_IS_NOT_A_SIGNATURE_FIELD_TYPE, e.getMessage()); reader.close(); } @@ -431,8 +503,10 @@ public void setFieldNameToSigFieldWithValueTest() throws IOException { new ByteArrayInputStream(createDocumentWithSignatureWithTestValueField(fieldName, fieldValue))); PdfSigner signer = new PdfSigner(reader, new ByteArrayOutputStream(), new StampingProperties()); - Exception e = Assert.assertThrows(IllegalArgumentException.class, () -> signer.setFieldName(fieldName)); - Assert.assertEquals(SignExceptionMessageConstant.FIELD_ALREADY_SIGNED, e.getMessage()); + SignerProperties signerProperties = new SignerProperties().setFieldName(fieldName); + Exception e = Assertions.assertThrows(IllegalArgumentException.class, + () -> signer.setSignerProperties(signerProperties)); + Assertions.assertEquals(SignExceptionMessageConstant.FIELD_ALREADY_SIGNED, e.getMessage()); reader.close(); } @@ -443,8 +517,9 @@ public void setFieldNameToSigFieldWithoutWidgetsTest() throws IOException { PdfReader reader = new PdfReader(new ByteArrayInputStream(createDocumentWithSignatureField(fieldName))); PdfSigner signer = new PdfSigner(reader, new ByteArrayOutputStream(), new StampingProperties()); - signer.setFieldName(fieldName); - Assert.assertEquals(fieldName, signer.getFieldName()); + SignerProperties signerProperties = new SignerProperties().setFieldName(fieldName); + signer.setSignerProperties(signerProperties); + Assertions.assertEquals(fieldName, signer.getSignerProperties().getFieldName()); reader.close(); } @@ -513,7 +588,7 @@ private static byte[] createSimplePdfaDocument() throws IOException { InputStream is = FileUtil.getInputStreamForFile(PDFA_RESOURCES + "sRGB Color Space Profile.icm"); PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", is); - PdfDocument document = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_1A, outputIntent); + PdfDocument document = new PdfADocument(writer, PdfAConformance.PDF_A_1A, outputIntent); document.setTagged(); document.getCatalog().setLang(new PdfString("en-US")); diff --git a/sign/src/test/java/com/itextpdf/signatures/PdfTwoPhaseSignerUnitTest.java b/sign/src/test/java/com/itextpdf/signatures/PdfTwoPhaseSignerUnitTest.java index 51ca02ffa9..e7806eb29f 100644 --- a/sign/src/test/java/com/itextpdf/signatures/PdfTwoPhaseSignerUnitTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/PdfTwoPhaseSignerUnitTest.java @@ -26,6 +26,7 @@ This file is part of the iText (R) project. import com.itextpdf.commons.bouncycastle.IBouncyCastleFactory; import com.itextpdf.io.source.ByteArrayOutputStream; import com.itextpdf.io.source.ByteUtils; +import com.itextpdf.kernel.crypto.DigestAlgorithms; import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfName; import com.itextpdf.kernel.pdf.PdfReader; @@ -33,19 +34,18 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfWriter; import com.itextpdf.kernel.pdf.WriterProperties; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.BouncyCastleUnitTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; import java.io.ByteArrayInputStream; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.security.GeneralSecurityException; import java.security.Security; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(BouncyCastleUnitTest.class) +@Tag("BouncyCastleUnitTest") public class PdfTwoPhaseSignerUnitTest extends ExtendedITextTest { private static final IBouncyCastleFactory FACTORY = BouncyCastleFactoryCreator.getFactory(); @@ -59,7 +59,7 @@ public class PdfTwoPhaseSignerUnitTest extends ExtendedITextTest { private static final char[] PASSWORD = "testpassphrase".toCharArray(); - @BeforeClass + @BeforeAll public static void before() { Security.addProvider(FACTORY.getProvider()); createOrClearDestinationFolder(DESTINATION_FOLDER); @@ -81,7 +81,7 @@ public void prepareDocumentTestWithSHA256() throws IOException, GeneralSecurityE PdfDocument resultDoc = new PdfDocument(resultReader); SignatureUtil signatureUtil = new SignatureUtil(resultDoc); PdfSignature signature = signatureUtil.getSignature(fieldName); - Assert.assertEquals(estimatedSize, signature.getContents().getValueBytes().length); + Assertions.assertEquals(estimatedSize, signature.getContents().getValueBytes().length); } @@ -103,7 +103,7 @@ public void prepareDocumentTestWithExternalDigest() throws IOException, GeneralS PdfDocument resultDoc = new PdfDocument(resultReader); SignatureUtil signatureUtil = new SignatureUtil(resultDoc); PdfSignature signature = signatureUtil.getSignature(fieldName); - Assert.assertEquals(estimatedSize, signature.getContents().getValueBytes().length); + Assertions.assertEquals(estimatedSize, signature.getContents().getValueBytes().length); } @Test @@ -133,7 +133,7 @@ public void addSignatureToPreparedDocumentTest() throws IOException, GeneralSecu PdfSignature signature = signatureUtil.getSignature(fieldName); byte[] content = signature.getContents().getValueBytes(); for (int i = 0; i < testData.length; i++) { - Assert.assertEquals(testData[i], content[i]); + Assertions.assertEquals(testData[i], content[i]); } } diff --git a/sign/src/test/java/com/itextpdf/signatures/PdfUASignerTest.java b/sign/src/test/java/com/itextpdf/signatures/PdfUASignerTest.java new file mode 100644 index 0000000000..1474b5dd0e --- /dev/null +++ b/sign/src/test/java/com/itextpdf/signatures/PdfUASignerTest.java @@ -0,0 +1,334 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.signatures; + +import com.itextpdf.bouncycastleconnector.BouncyCastleFactoryCreator; +import com.itextpdf.commons.bouncycastle.IBouncyCastleFactory; +import com.itextpdf.commons.bouncycastle.operator.AbstractOperatorCreationException; +import com.itextpdf.commons.bouncycastle.pkcs.AbstractPKCSException; +import com.itextpdf.commons.utils.FileUtil; +import com.itextpdf.forms.fields.properties.SignedAppearanceText; +import com.itextpdf.forms.form.element.SignatureFieldAppearance; +import com.itextpdf.io.util.UrlUtil; +import com.itextpdf.kernel.crypto.DigestAlgorithms; +import com.itextpdf.kernel.font.PdfFont; +import com.itextpdf.kernel.font.PdfFontFactory; +import com.itextpdf.kernel.geom.Rectangle; +import com.itextpdf.kernel.pdf.PdfDocument; +import com.itextpdf.kernel.pdf.PdfReader; +import com.itextpdf.kernel.pdf.PdfUAConformance; +import com.itextpdf.kernel.pdf.PdfWriter; +import com.itextpdf.kernel.pdf.StampingProperties; +import com.itextpdf.pdfua.PdfUAConfig; +import com.itextpdf.pdfua.PdfUADocument; +import com.itextpdf.pdfua.exceptions.PdfUAConformanceException; +import com.itextpdf.pdfua.exceptions.PdfUAExceptionMessageConstants; +import com.itextpdf.signatures.testutils.PemFileHelper; +import com.itextpdf.test.ExtendedITextTest; +import com.itextpdf.test.pdfa.VeraPdfValidator; // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.security.GeneralSecurityException; +import java.security.PrivateKey; +import java.security.Security; +import java.security.cert.Certificate; +import java.util.function.Consumer; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@Tag("IntegrationTest") +public class PdfUASignerTest extends ExtendedITextTest { + private static final IBouncyCastleFactory BOUNCY_CASTLE_FACTORY = BouncyCastleFactoryCreator.getFactory(); + + private static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/signatures/PdfUASignerTest/"; + private static final String FONT = "./src/test/resources/com/itextpdf/signatures/font/FreeSans.ttf"; + private static final Logger logger = LoggerFactory.getLogger(PdfUASignerTest.class); + + public static final String CERTIFICATE_FOLDER = "./src/test/resources/com/itextpdf/signatures/certs/"; + private static final char[] PASSWORD = "testpassphrase".toCharArray(); + + @BeforeAll + public static void beforeClass() { + createOrClearDestinationFolder(DESTINATION_FOLDER); + } + + @Test + public void invisibleSignatureWithNoTU() { + ByteArrayInputStream inPdf = generateSimplePdfUA1Document(); + Exception e = Assertions.assertThrows(PdfUAConformanceException.class, () -> { + generateSignature(inPdf, "invisibleSignatureWithNoTU", (signer) -> { + }); + }); + Assertions.assertEquals(PdfUAExceptionMessageConstants.MISSING_FORM_FIELD_DESCRIPTION, e.getMessage()); + } + + @Test + public void invisibleSignatureWithTU() throws GeneralSecurityException, IOException, AbstractOperatorCreationException, AbstractPKCSException { + ByteArrayInputStream inPdf = generateSimplePdfUA1Document(); + String outPdf = generateSignature(inPdf, "invisibleSignatureWithTU", (signer) -> { + signer.setSignerProperties(new SignerProperties().setFieldName("Signature12")); + SignatureFieldAppearance appearance = new SignatureFieldAppearance(SignerProperties.IGNORED_ID); + appearance.getAccessibilityProperties().setAlternateDescription("Some alternate description"); + signer.getSignerProperties().setSignatureAppearance(appearance); + }); + Assertions.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + } + + @Test + public void visibleSignatureWithTUButNotAFont() throws GeneralSecurityException, IOException, AbstractOperatorCreationException, AbstractPKCSException { + ByteArrayInputStream inPdf = generateSimplePdfUA1Document(); + String outPdf = generateSignature(inPdf, "visibleSignatureWithTUButNotAFont", (signer) -> { + signer.setSignerProperties(new SignerProperties().setFieldName("Signature12")); + SignatureFieldAppearance appearance = new SignatureFieldAppearance(SignerProperties.IGNORED_ID); + appearance.getAccessibilityProperties().setAlternateDescription("Some alternate description"); + try { + appearance.setFont(PdfFontFactory.createFont(FONT)); + } catch (IOException e) { + throw new RuntimeException(); + } + appearance.setContent("Some signature content"); + signer.getSignerProperties() + .setPageNumber(1) + .setPageRect(new Rectangle(36, 648, 200, 100)) + .setSignatureAppearance(appearance); + }); + Assertions.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + } + + @Test + public void visibleSignatureWithoutTUFont() { + ByteArrayInputStream inPdf = generateSimplePdfUA1Document(); + Exception e = Assertions.assertThrows(PdfUAConformanceException.class, () -> { + generateSignature(inPdf, "visibleSignatureWithoutTUFont", (signer) -> { + signer.setSignerProperties(new SignerProperties().setFieldName("Signature12")); + SignatureFieldAppearance appearance = new SignatureFieldAppearance(SignerProperties.IGNORED_ID); + appearance.setContent(new SignedAppearanceText().setLocationLine("Dummy location").setReasonLine("Dummy reason").setSignedBy("Dummy")); + + try { + appearance.setFont(PdfFontFactory.createFont(FONT)); + } catch (IOException f) { + throw new RuntimeException(); + } + + signer.getSignerProperties() + .setPageNumber(1) + .setPageRect(new Rectangle(36, 648, 200, 100)) + .setSignatureAppearance(appearance); + }); + }); + } + + @Test + public void visibleSignatureWithNoFontSelected() { + ByteArrayInputStream inPdf = generateSimplePdfUA1Document(); + Exception e = Assertions.assertThrows(PdfUAConformanceException.class, () -> { + generateSignature(inPdf, "visibleSignatureWithNoFontSelected", (signer) -> { + signer.setSignerProperties(new SignerProperties().setFieldName("Signature12")); + SignatureFieldAppearance appearance = new SignatureFieldAppearance(SignerProperties.IGNORED_ID); + appearance.setContent("Some signature content"); + signer.getSignerProperties().setPageNumber(1).setPageRect(new Rectangle(36, 648, 200, 100)); + appearance.getAccessibilityProperties().setAlternateDescription("Some alternate description"); + appearance.setContent(new SignedAppearanceText().setSignedBy("Dummy").setReasonLine("Dummy reason").setLocationLine("Dummy location")); + signer.getSignerProperties().setSignatureAppearance(appearance); + }); + }); + } + + + @Test + public void normalPdfSignerInvisibleSignatureWithTU() throws GeneralSecurityException, IOException, AbstractOperatorCreationException, AbstractPKCSException { + ByteArrayInputStream inPdf = generateSimplePdfUA1Document(); + String outPdf = generateSignatureNormal(inPdf, "normalPdfSignerInvisibleSignatureWithTU", (signer) -> { + signer.setSignerProperties(new SignerProperties().setFieldName("Signature12")); + SignatureFieldAppearance appearance = new SignatureFieldAppearance(SignerProperties.IGNORED_ID); + appearance.getAccessibilityProperties().setAlternateDescription("Some alternate description"); + signer.getSignerProperties().setSignatureAppearance(appearance); + }); + Assertions.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + } + + @Test + public void normalPdfSignerInvisibleSignatureWithoutTU() throws GeneralSecurityException, IOException, AbstractOperatorCreationException, AbstractPKCSException { + ByteArrayInputStream inPdf = generateSimplePdfUA1Document(); + String outPdf = generateSignatureNormal(inPdf, "normalPdfSignerInvisibleSignatureWithoutTU", (signer) -> { + signer.setSignerProperties(new SignerProperties().setFieldName("Signature12")); + SignatureFieldAppearance appearance = new SignatureFieldAppearance(SignerProperties.IGNORED_ID); + signer.getSignerProperties().setSignatureAppearance(appearance); + }); + Assertions.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + } + + @Test + // TODO DEVSIX-8676 Enable keeping A and UA conformance in PdfSigner + public void normalPdfSignerVisibleSignatureWithoutFont() throws GeneralSecurityException, IOException, AbstractOperatorCreationException, AbstractPKCSException { + //This test should fail with the appropriate exception + ByteArrayInputStream inPdf = generateSimplePdfUA1Document(); + String outPdf = generateSignatureNormal(inPdf, "normalPdfSignerVisibleSignatureWithoutFont", (signer) -> { + signer.setSignerProperties(new SignerProperties().setFieldName("Signature12")); + SignatureFieldAppearance appearance = new SignatureFieldAppearance(SignerProperties.IGNORED_ID); + appearance.getAccessibilityProperties().setAlternateDescription("Some alternate description"); + appearance.setContent(new SignedAppearanceText().setLocationLine("Dummy location").setReasonLine("Dummy reason").setSignedBy("Dummy")); + signer.getSignerProperties() + .setPageNumber(1) + .setPageRect(new Rectangle(36, 648, 200, 100)) + .setSignatureAppearance(appearance); + }); + Assertions.assertNotNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + } + + + @Test + public void normalPdfSignerVisibleSignatureWithFont() throws GeneralSecurityException, IOException, AbstractOperatorCreationException, AbstractPKCSException { + ByteArrayInputStream inPdf = generateSimplePdfUA1Document(); + PdfFont font = PdfFontFactory.createFont(FONT); + String outPdf = generateSignatureNormal(inPdf, "normalPdfSignerVisibleSignatureWithFont", (signer) -> { + signer.setSignerProperties(new SignerProperties().setFieldName("Signature12")); + SignatureFieldAppearance appearance = new SignatureFieldAppearance(SignerProperties.IGNORED_ID); + appearance.getAccessibilityProperties().setAlternateDescription("Some alternate description"); + appearance.setContent(new SignedAppearanceText().setLocationLine("Dummy location").setReasonLine("Dummy reason").setSignedBy("Dummy")); + appearance.setFont(font); + signer.getSignerProperties() + .setPageNumber(1) + .setPageRect(new Rectangle(36, 648, 200, 100)) + .setSignatureAppearance(appearance); + }); + Assertions.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + } + + @Test + // TODO DEVSIX-8676 Enable keeping A and UA conformance in PdfSigner + public void normalPdfSignerVisibleSignatureWithFontEmptyTU() throws GeneralSecurityException, IOException, AbstractOperatorCreationException, AbstractPKCSException { + //Should throw the correct exception if the font is not set + ByteArrayInputStream inPdf = generateSimplePdfUA1Document(); + PdfFont font = PdfFontFactory.createFont(FONT); + String outPdf = generateSignatureNormal(inPdf, "normalPdfSignerVisibleSignatureWithFontEmptyTU", (signer) -> { + signer.setSignerProperties(new SignerProperties().setFieldName("Signature12")); + SignatureFieldAppearance appearance = new SignatureFieldAppearance(SignerProperties.IGNORED_ID); + appearance.getAccessibilityProperties().setAlternateDescription(""); + appearance.setContent(new SignedAppearanceText().setLocationLine("Dummy location").setReasonLine("Dummy reason").setSignedBy("Dummy")); + appearance.setFont(font); + signer.getSignerProperties() + .setPageNumber(1) + .setPageRect(new Rectangle(36, 648, 200, 100)) + .setSignatureAppearance(appearance); + }); + Assertions.assertNotNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + } + + @Test + public void pdfSignerVisibleSignatureWithFontEmptyTU() throws IOException { + //Should throw the correct exception if the font is not set + ByteArrayInputStream inPdf = generateSimplePdfUA1Document(); + PdfFont font = PdfFontFactory.createFont(FONT); + Assertions.assertThrows(PdfUAConformanceException.class, () -> { + generateSignature(inPdf, "pdfSignerVisibleSignatureWithFontEmptyTU", (signer) -> { + signer.setSignerProperties(new SignerProperties().setFieldName("Signature12")); + SignatureFieldAppearance appearance = new SignatureFieldAppearance(SignerProperties.IGNORED_ID); + appearance.getAccessibilityProperties().setAlternateDescription(""); + appearance.setContent(new SignedAppearanceText().setLocationLine("Dummy location").setReasonLine("Dummy reason").setSignedBy("Dummy")); + appearance.setFont(font); + signer.getSignerProperties() + .setPageNumber(1) + .setPageRect(new Rectangle(36, 648, 200, 100)) + .setSignatureAppearance(appearance); + }); + }); + } + + + private ByteArrayInputStream generateSimplePdfUA1Document() { + ByteArrayOutputStream out = new ByteArrayOutputStream(); + PdfUADocument pdfUADocument = new PdfUADocument(new PdfWriter(out), new PdfUAConfig(PdfUAConformance.PDF_UA_1, "Title", "en-US")); + pdfUADocument.addNewPage(); + pdfUADocument.close(); + return new ByteArrayInputStream(out.toByteArray()); + } + + + private String generateSignature(ByteArrayInputStream inPdf, String name, Consumer signingAction) throws GeneralSecurityException, IOException, AbstractOperatorCreationException, AbstractPKCSException { + String certFileName = CERTIFICATE_FOLDER + "sign.pem"; + + Security.addProvider(BOUNCY_CASTLE_FACTORY.getProvider()); + PrivateKey signPrivateKey = PemFileHelper.readFirstKey(certFileName, PASSWORD); + IExternalSignature pks = new PrivateKeySignature(signPrivateKey, DigestAlgorithms.SHA256, BOUNCY_CASTLE_FACTORY.getProviderName()); + Certificate[] signChain = PemFileHelper.readFirstChain(certFileName); + + String outPdf = DESTINATION_FOLDER + name + ".pdf"; + PdfSigner signer = new PdfUaSigner(new PdfReader(inPdf), FileUtil.getFileOutputStream(outPdf), new StampingProperties()); + + + signingAction.accept(signer); + signer.signDetached(new BouncyCastleDigest(), pks, signChain, null, null, null, 0, PdfSigner.CryptoStandard.CADES); + logger.info("Out pdf: " + UrlUtil.getNormalizedFileUriString(outPdf)); + return outPdf; + } + + + private String generateSignatureNormal(ByteArrayInputStream inPdf, String name, Consumer signingAction) throws GeneralSecurityException, IOException, AbstractOperatorCreationException, AbstractPKCSException { + String certFileName = CERTIFICATE_FOLDER + "sign.pem"; + + Security.addProvider(BOUNCY_CASTLE_FACTORY.getProvider()); + PrivateKey signPrivateKey = PemFileHelper.readFirstKey(certFileName, PASSWORD); + IExternalSignature pks = new PrivateKeySignature(signPrivateKey, DigestAlgorithms.SHA256, BOUNCY_CASTLE_FACTORY.getProviderName()); + Certificate[] signChain = PemFileHelper.readFirstChain(certFileName); + + String outPdf = DESTINATION_FOLDER + name + ".pdf"; + PdfSigner signer = new PdfSigner(new PdfReader(inPdf), FileUtil.getFileOutputStream(outPdf), new StampingProperties()); + + signingAction.accept(signer); + signer.signDetached(new BouncyCastleDigest(), pks, signChain, null, null, null, 0, PdfSigner.CryptoStandard.CADES); + + logger.info("Out pdf: " + UrlUtil.getNormalizedFileUriString(outPdf)); + return outPdf; + } + + + static class PdfUaSigner extends PdfSigner { + + public PdfUaSigner(PdfReader reader, OutputStream outputStream, StampingProperties properties) throws IOException { + super(reader, outputStream, properties); + } + + public PdfUaSigner(PdfReader reader, OutputStream outputStream, String path, StampingProperties stampingProperties, SignerProperties signerProperties) throws IOException { + super(reader, outputStream, path, stampingProperties, signerProperties); + } + + public PdfUaSigner(PdfReader reader, OutputStream outputStream, String path, StampingProperties properties) throws IOException { + super(reader, outputStream, path, properties); + } + + @Override + protected PdfDocument initDocument(PdfReader reader, PdfWriter writer, StampingProperties properties) { + return new PdfUADocument(reader, writer, new PdfUAConfig(PdfUAConformance.PDF_UA_1, "Title", "en-US")); + } + } + + +} diff --git a/sign/src/test/java/com/itextpdf/signatures/ProviderDigestUnitTest.java b/sign/src/test/java/com/itextpdf/signatures/ProviderDigestUnitTest.java index ced467daaf..544fdb2d4c 100644 --- a/sign/src/test/java/com/itextpdf/signatures/ProviderDigestUnitTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/ProviderDigestUnitTest.java @@ -22,18 +22,18 @@ This file is part of the iText (R) project. */ package com.itextpdf.signatures; +import com.itextpdf.kernel.crypto.DigestAlgorithms; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.security.GeneralSecurityException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.security.NoSuchProviderException; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(UnitTest.class) +@Tag("UnitTest") public class ProviderDigestUnitTest extends ExtendedITextTest { @Test @@ -41,9 +41,9 @@ public class ProviderDigestUnitTest extends ExtendedITextTest { public void getMessageDigestSunPKCS11SHA1Test() throws GeneralSecurityException { ProviderDigest providerDigest = new ProviderDigest("SunPKCS11"); MessageDigest digest = providerDigest.getMessageDigest(DigestAlgorithms.SHA1); - Assert.assertNotNull(digest); - Assert.assertEquals("SUN", digest.getProvider().getName()); - Assert.assertEquals(DigestAlgorithms.SHA1, digest.getAlgorithm()); + Assertions.assertNotNull(digest); + Assertions.assertEquals("SUN", digest.getProvider().getName()); + Assertions.assertEquals(DigestAlgorithms.SHA1, digest.getAlgorithm()); } @Test @@ -51,32 +51,32 @@ public void getMessageDigestSunPKCS11SHA1Test() throws GeneralSecurityException public void getMessageDigestSUNSHA256Test() throws GeneralSecurityException { ProviderDigest providerDigest = new ProviderDigest("SUN"); MessageDigest digest = providerDigest.getMessageDigest(DigestAlgorithms.SHA256); - Assert.assertNotNull(digest); - Assert.assertEquals("SUN", digest.getProvider().getName()); - Assert.assertEquals(DigestAlgorithms.SHA256, digest.getAlgorithm()); + Assertions.assertNotNull(digest); + Assertions.assertEquals("SUN", digest.getProvider().getName()); + Assertions.assertEquals(DigestAlgorithms.SHA256, digest.getAlgorithm()); } @Test public void getMessageDigestNoSuchProviderExceptionTest() { ProviderDigest providerDigest = new ProviderDigest("doesn't exist"); - Exception e = Assert.assertThrows(NoSuchProviderException.class, + Exception e = Assertions.assertThrows(NoSuchProviderException.class, () -> providerDigest.getMessageDigest(DigestAlgorithms.SHA256)); - Assert.assertEquals("no such provider: doesn't exist", e.getMessage()); + Assertions.assertEquals("no such provider: doesn't exist", e.getMessage()); } @Test public void getMessageDigestNoSuchAlgorithmExceptionTest() { ProviderDigest providerDigest = new ProviderDigest("SunPKCS11"); - Exception e = Assert.assertThrows(NoSuchAlgorithmException.class, + Exception e = Assertions.assertThrows(NoSuchAlgorithmException.class, () -> providerDigest.getMessageDigest("doesn't exist")); - Assert.assertEquals("doesn't exist MessageDigest not available", e.getMessage()); + Assertions.assertEquals("doesn't exist MessageDigest not available", e.getMessage()); } @Test public void getMessageDigestMissingProviderExceptionTest() { ProviderDigest providerDigest = new ProviderDigest(""); - Exception e = Assert.assertThrows(IllegalArgumentException.class, + Exception e = Assertions.assertThrows(IllegalArgumentException.class, () -> providerDigest.getMessageDigest(DigestAlgorithms.SHA1)); - Assert.assertEquals("missing provider", e.getMessage()); + Assertions.assertEquals("missing provider", e.getMessage()); } } diff --git a/sign/src/test/java/com/itextpdf/signatures/SignMetaInfoHandlingTest.java b/sign/src/test/java/com/itextpdf/signatures/SignMetaInfoHandlingTest.java index af6f01b0b7..9a603a1451 100644 --- a/sign/src/test/java/com/itextpdf/signatures/SignMetaInfoHandlingTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/SignMetaInfoHandlingTest.java @@ -35,6 +35,7 @@ This file is part of the iText (R) project. import com.itextpdf.commons.utils.FileUtil; import com.itextpdf.io.source.ByteArrayOutputStream; import com.itextpdf.kernel.actions.events.ITextCoreProductEvent; +import com.itextpdf.kernel.crypto.DigestAlgorithms; import com.itextpdf.kernel.pdf.DocumentProperties; import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfReader; @@ -46,13 +47,6 @@ This file is part of the iText (R) project. import com.itextpdf.signatures.testutils.client.TestOcspClient; import com.itextpdf.signatures.testutils.client.TestTsaClient; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; import java.io.ByteArrayInputStream; import java.security.PrivateKey; @@ -62,8 +56,14 @@ This file is part of the iText (R) project. import java.util.ArrayList; import java.util.Arrays; import java.util.List; - -@Category(IntegrationTest.class) +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +@Tag("IntegrationTest") public class SignMetaInfoHandlingTest extends ExtendedITextTest { public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/signatures/SignMetaInfoHandlingTest/"; public static final String CERTS = "./src/test/resources/com/itextpdf/signatures/certs/"; @@ -97,18 +97,18 @@ public class SignMetaInfoHandlingTest extends ExtendedITextTest { } } - @BeforeClass + @BeforeAll public static void before() { Security.addProvider(BouncyCastleFactoryCreator.getFactory().getProvider()); } - @Before + @BeforeEach public void setUpHandler() { handler = new StoreEventsHandler(UnknownContext.PERMISSIVE); EventManager.getInstance().register(handler); } - @After + @AfterEach public void resetHandler() { EventManager.getInstance().unregister(handler); } @@ -124,10 +124,10 @@ public void createDocumentWithSignMetaInfoTest() { List confirmedEvents = CONFIGURATION_ACCESS.getPublicEvents(docSequenceId); // No confirmed events. - Assert.assertEquals(0, confirmedEvents.size()); + Assertions.assertEquals(0, confirmedEvents.size()); List events = handler.getEvents(); - Assert.assertEquals(0, events.size()); + Assertions.assertEquals(0, events.size()); } @Test @@ -144,14 +144,14 @@ public void signWithBaselineLTProfileEventHandlingTest() throws Exception { padesSigner.signWithBaselineLTProfile(signerProperties, signRsaChain, signRsaPrivateKey, testTsa); List events = handler.getEvents(); - Assert.assertEquals(2, events.size()); - Assert.assertTrue(events.get(0) instanceof ITextCoreProductEvent); + Assertions.assertEquals(2, events.size()); + Assertions.assertTrue(events.get(0) instanceof ITextCoreProductEvent); ITextCoreProductEvent iTextCoreProductEvent = (ITextCoreProductEvent) events.get(0); - Assert.assertEquals(ITextCoreProductEvent.PROCESS_PDF, iTextCoreProductEvent.getEventType()); + Assertions.assertEquals(ITextCoreProductEvent.PROCESS_PDF, iTextCoreProductEvent.getEventType()); // Only first iTextCoreProductEvent is confirmed. - Assert.assertTrue(events.get(1) instanceof ConfirmEvent); + Assertions.assertTrue(events.get(1) instanceof ConfirmEvent); ConfirmEvent confirmEvent = (ConfirmEvent) events.get(1); - Assert.assertEquals(iTextCoreProductEvent, confirmEvent.getConfirmedEvent()); + Assertions.assertEquals(iTextCoreProductEvent, confirmEvent.getConfirmedEvent()); } @Test @@ -167,14 +167,14 @@ public void signWithBaselineLTAProfileEventHandlingTest() throws Exception { padesSigner.signWithBaselineLTAProfile(signerProperties, signRsaChain, signRsaPrivateKey, testTsa); List events = handler.getEvents(); - Assert.assertEquals(2, events.size()); - Assert.assertTrue(events.get(0) instanceof ITextCoreProductEvent); + Assertions.assertEquals(2, events.size()); + Assertions.assertTrue(events.get(0) instanceof ITextCoreProductEvent); ITextCoreProductEvent iTextCoreProductEvent = (ITextCoreProductEvent) events.get(0); - Assert.assertEquals(ITextCoreProductEvent.PROCESS_PDF, iTextCoreProductEvent.getEventType()); + Assertions.assertEquals(ITextCoreProductEvent.PROCESS_PDF, iTextCoreProductEvent.getEventType()); // Only first iTextCoreProductEvent is confirmed. - Assert.assertTrue(events.get(1) instanceof ConfirmEvent); + Assertions.assertTrue(events.get(1) instanceof ConfirmEvent); ConfirmEvent confirmEvent = (ConfirmEvent) events.get(1); - Assert.assertEquals(iTextCoreProductEvent, confirmEvent.getConfirmedEvent()); + Assertions.assertEquals(iTextCoreProductEvent, confirmEvent.getConfirmedEvent()); } @Test @@ -201,21 +201,21 @@ public void signCMSContainerWithBaselineLTProfileEventHandlingTest() throws Exce } List events = handler.getEvents(); - Assert.assertEquals(4, events.size()); - Assert.assertTrue(events.get(0) instanceof ITextCoreProductEvent); + Assertions.assertEquals(4, events.size()); + Assertions.assertTrue(events.get(0) instanceof ITextCoreProductEvent); ITextCoreProductEvent iTextCoreProductEvent = (ITextCoreProductEvent) events.get(0); - Assert.assertEquals(ITextCoreProductEvent.PROCESS_PDF, iTextCoreProductEvent.getEventType()); + Assertions.assertEquals(ITextCoreProductEvent.PROCESS_PDF, iTextCoreProductEvent.getEventType()); // First iTextCoreProductEvent is confirmed (coming from createCMSContainerWithoutSignature). - Assert.assertTrue(events.get(1) instanceof ConfirmEvent); + Assertions.assertTrue(events.get(1) instanceof ConfirmEvent); ConfirmEvent confirmEvent = (ConfirmEvent) events.get(1); - Assert.assertEquals(iTextCoreProductEvent, confirmEvent.getConfirmedEvent()); - Assert.assertTrue(events.get(2) instanceof ITextCoreProductEvent); + Assertions.assertEquals(iTextCoreProductEvent, confirmEvent.getConfirmedEvent()); + Assertions.assertTrue(events.get(2) instanceof ITextCoreProductEvent); iTextCoreProductEvent = (ITextCoreProductEvent) events.get(2); - Assert.assertEquals(ITextCoreProductEvent.PROCESS_PDF, iTextCoreProductEvent.getEventType()); + Assertions.assertEquals(ITextCoreProductEvent.PROCESS_PDF, iTextCoreProductEvent.getEventType()); // Second iTextCoreProductEvent is confirmed (coming from signCMSContainerWithBaselineLTProfile). - Assert.assertTrue(events.get(3) instanceof ConfirmEvent); + Assertions.assertTrue(events.get(3) instanceof ConfirmEvent); confirmEvent = (ConfirmEvent) events.get(3); - Assert.assertEquals(iTextCoreProductEvent, confirmEvent.getConfirmedEvent()); + Assertions.assertEquals(iTextCoreProductEvent, confirmEvent.getConfirmedEvent()); } @Test @@ -242,21 +242,21 @@ public void signCMSContainerWithBaselineLTAProfileEventHandlingTest() throws Exc } List events = handler.getEvents(); - Assert.assertEquals(4, events.size()); - Assert.assertTrue(events.get(0) instanceof ITextCoreProductEvent); + Assertions.assertEquals(4, events.size()); + Assertions.assertTrue(events.get(0) instanceof ITextCoreProductEvent); ITextCoreProductEvent iTextCoreProductEvent = (ITextCoreProductEvent) events.get(0); - Assert.assertEquals(ITextCoreProductEvent.PROCESS_PDF, iTextCoreProductEvent.getEventType()); + Assertions.assertEquals(ITextCoreProductEvent.PROCESS_PDF, iTextCoreProductEvent.getEventType()); // First iTextCoreProductEvent is confirmed (coming from createCMSContainerWithoutSignature). - Assert.assertTrue(events.get(1) instanceof ConfirmEvent); + Assertions.assertTrue(events.get(1) instanceof ConfirmEvent); ConfirmEvent confirmEvent = (ConfirmEvent) events.get(1); - Assert.assertEquals(iTextCoreProductEvent, confirmEvent.getConfirmedEvent()); - Assert.assertTrue(events.get(2) instanceof ITextCoreProductEvent); + Assertions.assertEquals(iTextCoreProductEvent, confirmEvent.getConfirmedEvent()); + Assertions.assertTrue(events.get(2) instanceof ITextCoreProductEvent); iTextCoreProductEvent = (ITextCoreProductEvent) events.get(2); - Assert.assertEquals(ITextCoreProductEvent.PROCESS_PDF, iTextCoreProductEvent.getEventType()); + Assertions.assertEquals(ITextCoreProductEvent.PROCESS_PDF, iTextCoreProductEvent.getEventType()); // Second iTextCoreProductEvent is confirmed (coming from signCMSContainerWithBaselineLTAProfile). - Assert.assertTrue(events.get(3) instanceof ConfirmEvent); + Assertions.assertTrue(events.get(3) instanceof ConfirmEvent); confirmEvent = (ConfirmEvent) events.get(3); - Assert.assertEquals(iTextCoreProductEvent, confirmEvent.getConfirmedEvent()); + Assertions.assertEquals(iTextCoreProductEvent, confirmEvent.getConfirmedEvent()); } @Test @@ -274,7 +274,7 @@ public void passSignMetaInfoThroughStampingPropertiesTest() throws Exception { padesSigner.signWithBaselineLTProfile(signerProperties, signRsaChain, signRsaPrivateKey, testTsa); List events = handler.getEvents(); - Assert.assertEquals(0, events.size()); + Assertions.assertEquals(0, events.size()); } private static class TestConfigurationEvent extends AbstractITextConfigurationEvent { diff --git a/sign/src/test/java/com/itextpdf/signatures/SignUtilsManualTest.java b/sign/src/test/java/com/itextpdf/signatures/SignUtilsManualTest.java index 5ea1e1459f..dfdecbd303 100644 --- a/sign/src/test/java/com/itextpdf/signatures/SignUtilsManualTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/SignUtilsManualTest.java @@ -23,16 +23,15 @@ This file is part of the iText (R) project. package com.itextpdf.signatures; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.security.KeyStoreException; import java.security.cert.X509Certificate; import java.util.Iterator; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class SignUtilsManualTest extends ExtendedITextTest { @Test @@ -40,7 +39,7 @@ public class SignUtilsManualTest extends ExtendedITextTest { public void removeCertificatesIteratorTest() throws KeyStoreException { Iterable iterable = SignUtils.getCertificates(KeyStoreUtil.loadCacertsKeyStore()); Iterator it = iterable.iterator(); - Exception e = Assert.assertThrows(UnsupportedOperationException.class, it::remove); - Assert.assertEquals("remove", e.getMessage()); + Exception e = Assertions.assertThrows(UnsupportedOperationException.class, it::remove); + Assertions.assertEquals("remove", e.getMessage()); } } diff --git a/sign/src/test/java/com/itextpdf/signatures/SignUtilsUnitTest.java b/sign/src/test/java/com/itextpdf/signatures/SignUtilsUnitTest.java index c16e1b974d..772fa818f5 100644 --- a/sign/src/test/java/com/itextpdf/signatures/SignUtilsUnitTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/SignUtilsUnitTest.java @@ -23,20 +23,19 @@ This file is part of the iText (R) project. package com.itextpdf.signatures; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.util.Date; -@Category(UnitTest.class) +@Tag("UnitTest") public class SignUtilsUnitTest extends ExtendedITextTest { @Test public void add180SecTest() { // use int value in month for porting compatibility - Assert.assertEquals(new Date(2021, 8, 19, 0, 3, 20), + Assertions.assertEquals(new Date(2021, 8, 19, 0, 3, 20), SignUtils.add180Sec(new Date(2021, 8, 19, 0, 0, 20))); } } diff --git a/sign/src/test/java/com/itextpdf/signatures/SignatureMechanismsManualTest.java b/sign/src/test/java/com/itextpdf/signatures/SignatureMechanismsManualTest.java index 119a529eea..67c712516b 100644 --- a/sign/src/test/java/com/itextpdf/signatures/SignatureMechanismsManualTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/SignatureMechanismsManualTest.java @@ -23,17 +23,16 @@ This file is part of the iText (R) project. package com.itextpdf.signatures; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class SignatureMechanismsManualTest extends ExtendedITextTest { @Test public void getAlgorithmNullTest() { - Assert.assertNull(SignatureMechanisms.getAlgorithm(null)); + Assertions.assertNull(SignatureMechanisms.getAlgorithm(null)); } } diff --git a/sign/src/test/java/com/itextpdf/signatures/SignatureMechanismsTest.java b/sign/src/test/java/com/itextpdf/signatures/SignatureMechanismsTest.java index ed7ad2a172..1f9e020fbb 100644 --- a/sign/src/test/java/com/itextpdf/signatures/SignatureMechanismsTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/SignatureMechanismsTest.java @@ -23,37 +23,36 @@ This file is part of the iText (R) project. package com.itextpdf.signatures; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class SignatureMechanismsTest extends ExtendedITextTest { @Test public void getAlgorithmRSATest() { - Assert.assertEquals("RSA", SignatureMechanisms.getAlgorithm("1.2.840.113549.1.1.1")); + Assertions.assertEquals("RSA", SignatureMechanisms.getAlgorithm("1.2.840.113549.1.1.1")); } @Test public void getAlgorithmECDSATest() { - Assert.assertEquals("ECDSA", SignatureMechanisms.getAlgorithm("1.2.840.10045.2.1")); + Assertions.assertEquals("ECDSA", SignatureMechanisms.getAlgorithm("1.2.840.10045.2.1")); } @Test public void getAlgorithmEmptyTest() { - Assert.assertEquals("", SignatureMechanisms.getAlgorithm("")); + Assertions.assertEquals("", SignatureMechanisms.getAlgorithm("")); } @Test public void getAlgorithmEmptySpaceTest() { - Assert.assertEquals(" ", SignatureMechanisms.getAlgorithm(" ")); + Assertions.assertEquals(" ", SignatureMechanisms.getAlgorithm(" ")); } @Test public void getAlgorithmUndefinedTest() { - Assert.assertEquals("undefined", SignatureMechanisms.getAlgorithm("undefined")); + Assertions.assertEquals("undefined", SignatureMechanisms.getAlgorithm("undefined")); } } diff --git a/sign/src/test/java/com/itextpdf/signatures/SignaturePermissionsTest.java b/sign/src/test/java/com/itextpdf/signatures/SignaturePermissionsTest.java index f66f988527..6bdd749a44 100644 --- a/sign/src/test/java/com/itextpdf/signatures/SignaturePermissionsTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/SignaturePermissionsTest.java @@ -29,23 +29,22 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfString; import com.itextpdf.signatures.SignaturePermissions.FieldLock; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.util.ArrayList; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class SignaturePermissionsTest extends ExtendedITextTest { @Test public void defaultValuesTest() { SignaturePermissions permissions = new SignaturePermissions(new PdfDictionary(), null); - Assert.assertEquals(new ArrayList<>(), permissions.getFieldLocks()); - Assert.assertTrue(permissions.isAnnotationsAllowed()); - Assert.assertFalse(permissions.isCertification()); - Assert.assertTrue(permissions.isFillInAllowed()); + Assertions.assertEquals(new ArrayList<>(), permissions.getFieldLocks()); + Assertions.assertTrue(permissions.isAnnotationsAllowed()); + Assertions.assertFalse(permissions.isCertification()); + Assertions.assertTrue(permissions.isFillInAllowed()); } @Test @@ -62,11 +61,11 @@ public void transformedMethodDocMDPIsPresentedTest() { SignaturePermissions permissions = new SignaturePermissions(dict, null); - Assert.assertTrue(permissions.isCertification()); + Assertions.assertTrue(permissions.isCertification()); - Assert.assertEquals(new ArrayList<>(), permissions.getFieldLocks()); - Assert.assertTrue(permissions.isAnnotationsAllowed()); - Assert.assertTrue(permissions.isFillInAllowed()); + Assertions.assertEquals(new ArrayList<>(), permissions.getFieldLocks()); + Assertions.assertTrue(permissions.isAnnotationsAllowed()); + Assertions.assertTrue(permissions.isFillInAllowed()); } @Test @@ -92,14 +91,14 @@ public void actionIsPresentedTest() { SignaturePermissions permissions = new SignaturePermissions(dict, null); - Assert.assertEquals(1, permissions.getFieldLocks().size()); + Assertions.assertEquals(1, permissions.getFieldLocks().size()); FieldLock fieldLock = permissions.getFieldLocks().get(0); - Assert.assertEquals(action, fieldLock.getAction()); - Assert.assertEquals(fields, fieldLock.getFields()); + Assertions.assertEquals(action, fieldLock.getAction()); + Assertions.assertEquals(fields, fieldLock.getFields()); - Assert.assertTrue(permissions.isAnnotationsAllowed()); - Assert.assertFalse(permissions.isCertification()); - Assert.assertTrue(permissions.isFillInAllowed()); + Assertions.assertTrue(permissions.isAnnotationsAllowed()); + Assertions.assertFalse(permissions.isCertification()); + Assertions.assertTrue(permissions.isFillInAllowed()); } @Test @@ -128,15 +127,15 @@ public void multipleActionsArePresentedTest() { SignaturePermissions permissions = new SignaturePermissions(dict, null); - Assert.assertEquals(3, permissions.getFieldLocks().size()); + Assertions.assertEquals(3, permissions.getFieldLocks().size()); for(FieldLock fieldLock: permissions.getFieldLocks()) { - Assert.assertEquals(action, fieldLock.getAction()); - Assert.assertEquals(fields, fieldLock.getFields()); + Assertions.assertEquals(action, fieldLock.getAction()); + Assertions.assertEquals(fields, fieldLock.getFields()); } - Assert.assertTrue(permissions.isAnnotationsAllowed()); - Assert.assertFalse(permissions.isCertification()); - Assert.assertTrue(permissions.isFillInAllowed()); + Assertions.assertTrue(permissions.isAnnotationsAllowed()); + Assertions.assertFalse(permissions.isCertification()); + Assertions.assertTrue(permissions.isFillInAllowed()); } @Test @@ -155,11 +154,11 @@ public void pParamEqualsTo1Test() { SignaturePermissions permissions = new SignaturePermissions(dict, null); - Assert.assertFalse(permissions.isFillInAllowed()); - Assert.assertFalse(permissions.isAnnotationsAllowed()); + Assertions.assertFalse(permissions.isFillInAllowed()); + Assertions.assertFalse(permissions.isAnnotationsAllowed()); - Assert.assertEquals(new ArrayList<>(), permissions.getFieldLocks()); - Assert.assertFalse(permissions.isCertification()); + Assertions.assertEquals(new ArrayList<>(), permissions.getFieldLocks()); + Assertions.assertFalse(permissions.isCertification()); } @Test @@ -178,11 +177,11 @@ public void pParamEqualsTo2Test() { SignaturePermissions permissions = new SignaturePermissions(dict, null); - Assert.assertFalse(permissions.isAnnotationsAllowed()); + Assertions.assertFalse(permissions.isAnnotationsAllowed()); - Assert.assertEquals(new ArrayList<>(), permissions.getFieldLocks()); - Assert.assertTrue(permissions.isFillInAllowed()); - Assert.assertFalse(permissions.isCertification()); + Assertions.assertEquals(new ArrayList<>(), permissions.getFieldLocks()); + Assertions.assertTrue(permissions.isFillInAllowed()); + Assertions.assertFalse(permissions.isCertification()); } @Test @@ -210,13 +209,13 @@ public void previousIsSetTest() { SignaturePermissions previousPermissions = new SignaturePermissions(previousDict, null); SignaturePermissions permissions = new SignaturePermissions(new PdfDictionary(), previousPermissions); - Assert.assertEquals(1, permissions.getFieldLocks().size()); + Assertions.assertEquals(1, permissions.getFieldLocks().size()); FieldLock fieldLock = permissions.getFieldLocks().get(0); - Assert.assertEquals(action, fieldLock.getAction()); - Assert.assertEquals(fields, fieldLock.getFields()); + Assertions.assertEquals(action, fieldLock.getAction()); + Assertions.assertEquals(fields, fieldLock.getFields()); - Assert.assertFalse(permissions.isAnnotationsAllowed()); - Assert.assertFalse(permissions.isCertification()); - Assert.assertFalse(permissions.isFillInAllowed()); + Assertions.assertFalse(permissions.isAnnotationsAllowed()); + Assertions.assertFalse(permissions.isCertification()); + Assertions.assertFalse(permissions.isFillInAllowed()); } } diff --git a/sign/src/test/java/com/itextpdf/signatures/SignaturePolicyInfoTest.java b/sign/src/test/java/com/itextpdf/signatures/SignaturePolicyInfoTest.java index 7cd2cc3a9d..f7d311e117 100644 --- a/sign/src/test/java/com/itextpdf/signatures/SignaturePolicyInfoTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/SignaturePolicyInfoTest.java @@ -33,14 +33,14 @@ This file is part of the iText (R) project. import com.itextpdf.commons.bouncycastle.asn1.esf.ISignaturePolicyIdentifier; import com.itextpdf.commons.bouncycastle.asn1.x509.IAlgorithmIdentifier; import com.itextpdf.commons.utils.Base64; +import com.itextpdf.kernel.crypto.DigestAlgorithms; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.BouncyCastleUnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(BouncyCastleUnitTest.class) +@Tag("BouncyCastleUnitTest") public class SignaturePolicyInfoTest extends ExtendedITextTest { private static final IBouncyCastleFactory BOUNCY_CASTLE_FACTORY = BouncyCastleFactoryCreator.getFactory(); private final static String POLICY_IDENTIFIER = "2.16.724.1.3.1.1.2.1.9"; @@ -54,10 +54,10 @@ public void checkConstructorTest() { SignaturePolicyInfo info = new SignaturePolicyInfo(POLICY_IDENTIFIER, POLICY_HASH, POLICY_DIGEST_ALGORITHM, POLICY_URI); - Assert.assertEquals(POLICY_IDENTIFIER, info.getPolicyIdentifier()); - Assert.assertArrayEquals(POLICY_HASH, info.getPolicyHash()); - Assert.assertEquals(POLICY_DIGEST_ALGORITHM, info.getPolicyDigestAlgorithm()); - Assert.assertEquals(POLICY_URI, info.getPolicyUri()); + Assertions.assertEquals(POLICY_IDENTIFIER, info.getPolicyIdentifier()); + Assertions.assertArrayEquals(POLICY_HASH, info.getPolicyHash()); + Assertions.assertEquals(POLICY_DIGEST_ALGORITHM, info.getPolicyDigestAlgorithm()); + Assertions.assertEquals(POLICY_URI, info.getPolicyUri()); } @Test @@ -65,58 +65,58 @@ public void checkConstructorWithEncodedHashTest() { SignaturePolicyInfo info = new SignaturePolicyInfo(POLICY_IDENTIFIER, POLICY_HASH_BASE64, POLICY_DIGEST_ALGORITHM, POLICY_URI); - Assert.assertEquals(POLICY_IDENTIFIER, info.getPolicyIdentifier()); - Assert.assertArrayEquals(POLICY_HASH, info.getPolicyHash()); - Assert.assertEquals(POLICY_DIGEST_ALGORITHM, info.getPolicyDigestAlgorithm()); - Assert.assertEquals(POLICY_URI, info.getPolicyUri()); + Assertions.assertEquals(POLICY_IDENTIFIER, info.getPolicyIdentifier()); + Assertions.assertArrayEquals(POLICY_HASH, info.getPolicyHash()); + Assertions.assertEquals(POLICY_DIGEST_ALGORITHM, info.getPolicyDigestAlgorithm()); + Assertions.assertEquals(POLICY_URI, info.getPolicyUri()); } @Test public void nullIdentifierIsNotAllowedTest() { - Exception e = Assert.assertThrows(IllegalArgumentException.class, + Exception e = Assertions.assertThrows(IllegalArgumentException.class, () -> new SignaturePolicyInfo(null, POLICY_HASH, POLICY_DIGEST_ALGORITHM, POLICY_URI) ); - Assert.assertEquals("Policy identifier cannot be null", e.getMessage()); + Assertions.assertEquals("Policy identifier cannot be null", e.getMessage()); } @Test public void emptyIdentifierIsNotAllowedTest() { - Exception e = Assert.assertThrows(IllegalArgumentException.class, + Exception e = Assertions.assertThrows(IllegalArgumentException.class, () -> new SignaturePolicyInfo("", POLICY_HASH, POLICY_DIGEST_ALGORITHM, POLICY_URI) ); - Assert.assertEquals("Policy identifier cannot be null", e.getMessage()); + Assertions.assertEquals("Policy identifier cannot be null", e.getMessage()); } @Test public void nullPolicyHashIsNotAllowedTest() { - Exception e = Assert.assertThrows(IllegalArgumentException.class, + Exception e = Assertions.assertThrows(IllegalArgumentException.class, () -> new SignaturePolicyInfo(POLICY_IDENTIFIER, (byte[]) null, POLICY_DIGEST_ALGORITHM, POLICY_URI) ); - Assert.assertEquals("Policy hash cannot be null", e.getMessage()); + Assertions.assertEquals("Policy hash cannot be null", e.getMessage()); } @Test public void nullEncodedPolicyHashIsNotAllowedTest() { - Exception e = Assert.assertThrows(IllegalArgumentException.class, + Exception e = Assertions.assertThrows(IllegalArgumentException.class, () -> new SignaturePolicyInfo(POLICY_IDENTIFIER, (String) null, POLICY_DIGEST_ALGORITHM, POLICY_URI) ); - Assert.assertEquals("Policy hash cannot be null", e.getMessage()); + Assertions.assertEquals("Policy hash cannot be null", e.getMessage()); } @Test public void nullDigestAlgorithmIsNotAllowedTest() { - Exception e = Assert.assertThrows(IllegalArgumentException.class, + Exception e = Assertions.assertThrows(IllegalArgumentException.class, () -> new SignaturePolicyInfo(POLICY_IDENTIFIER, POLICY_HASH, null, POLICY_URI) ); - Assert.assertEquals("Policy digest algorithm cannot be null", e.getMessage()); + Assertions.assertEquals("Policy digest algorithm cannot be null", e.getMessage()); } @Test public void emptyDigestAlgorithmIsNotAllowedTest() { - Exception e = Assert.assertThrows(IllegalArgumentException.class, + Exception e = Assertions.assertThrows(IllegalArgumentException.class, () -> new SignaturePolicyInfo(POLICY_IDENTIFIER, POLICY_HASH, "", POLICY_URI) ); - Assert.assertEquals("Policy digest algorithm cannot be null", e.getMessage()); + Assertions.assertEquals("Policy digest algorithm cannot be null", e.getMessage()); } @Test @@ -143,16 +143,16 @@ public void toSignaturePolicyIdentifierTest() { ISignaturePolicyIdentifier expected = BOUNCY_CASTLE_FACTORY.createSignaturePolicyIdentifier(signaturePolicyId); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test public void toSignaturePolicyIdentifierUnexpectedAlgorithmTest() { SignaturePolicyInfo info = new SignaturePolicyInfo(POLICY_IDENTIFIER, POLICY_HASH, "SHA-12345", POLICY_URI); - Exception e = Assert.assertThrows(IllegalArgumentException.class, + Exception e = Assertions.assertThrows(IllegalArgumentException.class, () -> info.toSignaturePolicyIdentifier() ); - Assert.assertEquals("Invalid policy hash algorithm", e.getMessage()); + Assertions.assertEquals("Invalid policy hash algorithm", e.getMessage()); } } diff --git a/sign/src/test/java/com/itextpdf/signatures/SignatureUtilTest.java b/sign/src/test/java/com/itextpdf/signatures/SignatureUtilTest.java index 65d214e2b6..f6ba398236 100644 --- a/sign/src/test/java/com/itextpdf/signatures/SignatureUtilTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/SignatureUtilTest.java @@ -30,25 +30,24 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfReader; import com.itextpdf.signatures.testutils.TimeTestUtil; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.BouncyCastleIntegrationTest; import java.security.Security; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; import java.util.List; -@Category(BouncyCastleIntegrationTest.class) +@Tag("BouncyCastleIntegrationTest") public class SignatureUtilTest extends ExtendedITextTest { private static final IBouncyCastleFactory BOUNCY_CASTLE_FACTORY = BouncyCastleFactoryCreator.getFactory(); private static final String sourceFolder = "./src/test/resources/com/itextpdf/signatures/SignatureUtilTest/"; private static final double EPS = 0.001; - @BeforeClass + @BeforeAll public static void before() { Security.addProvider(BOUNCY_CASTLE_FACTORY.getProvider()); } @@ -60,8 +59,8 @@ public void getSignaturesTest01() throws IOException { SignatureUtil signatureUtil = new SignatureUtil(pdfDocument); List signatureNames = signatureUtil.getSignatureNames(); - Assert.assertEquals(1, signatureNames.size()); - Assert.assertEquals("Signature1", signatureNames.get(0)); + Assertions.assertEquals(1, signatureNames.size()); + Assertions.assertEquals("Signature1", signatureNames.get(0)); } @Test @@ -71,7 +70,34 @@ public void getSignaturesTest02() throws IOException { SignatureUtil signatureUtil = new SignatureUtil(pdfDocument); List signatureNames = signatureUtil.getSignatureNames(); - Assert.assertEquals(0, signatureNames.size()); + Assertions.assertEquals(0, signatureNames.size()); + } + + @Test + public void eolNotIncludedIntoByteRangeTest1() throws IOException { + String inPdf = sourceFolder + "eolNotIncludedIntoByteRange1.pdf"; + PdfDocument pdfDocument = new PdfDocument(new PdfReader(inPdf)); + SignatureUtil signatureUtil = new SignatureUtil(pdfDocument); + + Assertions.assertFalse(signatureUtil.signatureCoversWholeDocument("Signature1")); + } + + @Test + public void eolNotIncludedIntoByteRangeTest2() throws IOException { + String inPdf = sourceFolder + "eolNotIncludedIntoByteRange2.pdf"; + PdfDocument pdfDocument = new PdfDocument(new PdfReader(inPdf)); + SignatureUtil signatureUtil = new SignatureUtil(pdfDocument); + + Assertions.assertTrue(signatureUtil.signatureCoversWholeDocument("Signature1")); + } + + @Test + public void eolNotIncludedIntoByteRangeTest3() throws IOException { + String inPdf = sourceFolder + "eolNotIncludedIntoByteRange3.pdf"; + PdfDocument pdfDocument = new PdfDocument(new PdfReader(inPdf)); + SignatureUtil signatureUtil = new SignatureUtil(pdfDocument); + + Assertions.assertFalse(signatureUtil.signatureCoversWholeDocument("Signature1")); } @Test @@ -80,7 +106,7 @@ public void firstBytesNotCoveredTest01() throws IOException { PdfDocument pdfDocument = new PdfDocument(new PdfReader(inPdf)); SignatureUtil signatureUtil = new SignatureUtil(pdfDocument); - Assert.assertFalse(signatureUtil.signatureCoversWholeDocument("Signature1")); + Assertions.assertFalse(signatureUtil.signatureCoversWholeDocument("Signature1")); } @Test @@ -89,7 +115,7 @@ public void lastBytesNotCoveredTest01() throws IOException { PdfDocument pdfDocument = new PdfDocument(new PdfReader(inPdf)); SignatureUtil signatureUtil = new SignatureUtil(pdfDocument); - Assert.assertFalse(signatureUtil.signatureCoversWholeDocument("Signature1")); + Assertions.assertFalse(signatureUtil.signatureCoversWholeDocument("Signature1")); } @Test @@ -98,7 +124,7 @@ public void lastBytesNotCoveredTest02() throws IOException { PdfDocument pdfDocument = new PdfDocument(new PdfReader(inPdf)); SignatureUtil signatureUtil = new SignatureUtil(pdfDocument); - Assert.assertFalse(signatureUtil.signatureCoversWholeDocument("Signature1")); + Assertions.assertFalse(signatureUtil.signatureCoversWholeDocument("Signature1")); } @Test @@ -107,7 +133,7 @@ public void exclusionSmallerThenContentsTest01() throws IOException { PdfDocument pdfDocument = new PdfDocument(new PdfReader(inPdf)); SignatureUtil signatureUtil = new SignatureUtil(pdfDocument); - Assert.assertFalse(signatureUtil.signatureCoversWholeDocument("Signature1")); + Assertions.assertFalse(signatureUtil.signatureCoversWholeDocument("Signature1")); } @Test @@ -116,7 +142,7 @@ public void bytesAreCoveredTest01() throws IOException { PdfDocument pdfDocument = new PdfDocument(new PdfReader(inPdf)); SignatureUtil signatureUtil = new SignatureUtil(pdfDocument); - Assert.assertTrue(signatureUtil.signatureCoversWholeDocument("Signature1")); + Assertions.assertTrue(signatureUtil.signatureCoversWholeDocument("Signature1")); } @Test @@ -125,7 +151,7 @@ public void bytesAreCoveredTest02() throws IOException { PdfDocument pdfDocument = new PdfDocument(new PdfReader(inPdf)); SignatureUtil signatureUtil = new SignatureUtil(pdfDocument); - Assert.assertTrue(signatureUtil.signatureCoversWholeDocument("sig")); + Assertions.assertTrue(signatureUtil.signatureCoversWholeDocument("sig")); } @Test @@ -134,7 +160,7 @@ public void indirectBytesAreCoveredTest01() throws IOException { PdfDocument pdfDocument = new PdfDocument(new PdfReader(inPdf)); SignatureUtil signatureUtil = new SignatureUtil(pdfDocument); - Assert.assertTrue(signatureUtil.signatureCoversWholeDocument("Signature1")); + Assertions.assertTrue(signatureUtil.signatureCoversWholeDocument("Signature1")); } @Test @@ -143,7 +169,7 @@ public void commentsBytesAreCoveredTest01() throws IOException { PdfDocument pdfDocument = new PdfDocument(new PdfReader(inPdf)); SignatureUtil signatureUtil = new SignatureUtil(pdfDocument); - Assert.assertTrue(signatureUtil.signatureCoversWholeDocument("Signature1")); + Assertions.assertTrue(signatureUtil.signatureCoversWholeDocument("Signature1")); } @Test @@ -152,7 +178,7 @@ public void commentsBytesAreNotCoveredTest01() throws IOException { PdfDocument pdfDocument = new PdfDocument(new PdfReader(inPdf)); SignatureUtil signatureUtil = new SignatureUtil(pdfDocument); - Assert.assertFalse(signatureUtil.signatureCoversWholeDocument("Signature1")); + Assertions.assertFalse(signatureUtil.signatureCoversWholeDocument("Signature1")); } @Test @@ -161,7 +187,7 @@ public void indirectBytesAreCoveredTest02() throws IOException { PdfDocument pdfDocument = new PdfDocument(new PdfReader(inPdf)); SignatureUtil signatureUtil = new SignatureUtil(pdfDocument); - Assert.assertTrue(signatureUtil.signatureCoversWholeDocument("Signature1")); + Assertions.assertTrue(signatureUtil.signatureCoversWholeDocument("Signature1")); } @Test @@ -170,7 +196,7 @@ public void indirectBytesAreNotCoveredTest01() throws IOException { PdfDocument pdfDocument = new PdfDocument(new PdfReader(inPdf)); SignatureUtil signatureUtil = new SignatureUtil(pdfDocument); - Assert.assertFalse(signatureUtil.signatureCoversWholeDocument("Signature1")); + Assertions.assertFalse(signatureUtil.signatureCoversWholeDocument("Signature1")); } @@ -180,7 +206,7 @@ public void twoContentsTest01() throws IOException { PdfDocument pdfDocument = new PdfDocument(new PdfReader(inPdf)); SignatureUtil signatureUtil = new SignatureUtil(pdfDocument); - Assert.assertFalse(signatureUtil.signatureCoversWholeDocument("Signature1")); + Assertions.assertFalse(signatureUtil.signatureCoversWholeDocument("Signature1")); } @Test @@ -189,7 +215,7 @@ public void spacesBeforeContentsTest01() throws IOException { PdfDocument pdfDocument = new PdfDocument(new PdfReader(inPdf)); SignatureUtil signatureUtil = new SignatureUtil(pdfDocument); - Assert.assertFalse(signatureUtil.signatureCoversWholeDocument("Signature1")); + Assertions.assertFalse(signatureUtil.signatureCoversWholeDocument("Signature1")); } @Test @@ -198,7 +224,7 @@ public void notIndirectSigDictionaryTest() throws IOException { PdfDocument pdfDocument = new PdfDocument(new PdfReader(inPdf)); SignatureUtil signatureUtil = new SignatureUtil(pdfDocument); - Assert.assertTrue(signatureUtil.signatureCoversWholeDocument("Signature1")); + Assertions.assertTrue(signatureUtil.signatureCoversWholeDocument("Signature1")); } @Test @@ -207,7 +233,7 @@ public void emptySignatureReadSignatureDataTest() throws IOException { PdfDocument pdfDocument = new PdfDocument(new PdfReader(inPdf)); SignatureUtil signatureUtil = new SignatureUtil(pdfDocument); - Assert.assertNull(signatureUtil.readSignatureData("Signature1", null)); + Assertions.assertNull(signatureUtil.readSignatureData("Signature1", null)); } @Test @@ -217,13 +243,13 @@ public void readSignatureDataTest() throws IOException { SignatureUtil signatureUtil = new SignatureUtil(pdfDocument); PdfPKCS7 pkcs7 = signatureUtil.readSignatureData("Signature1"); - Assert.assertNotNull(pkcs7); - Assert.assertEquals("Test 1", pkcs7.getReason()); - Assert.assertNull(pkcs7.getSignName()); - Assert.assertEquals("TestCity", pkcs7.getLocation()); + Assertions.assertNotNull(pkcs7); + Assertions.assertEquals("Test 1", pkcs7.getReason()); + Assertions.assertNull(pkcs7.getSignName()); + Assertions.assertEquals("TestCity", pkcs7.getLocation()); // The number corresponds to 18 May, 2021 17:23:59. double expectedMillis = (double) 1621347839000L; - Assert.assertEquals( + Assertions.assertEquals( TimeTestUtil.getFullDaysMillis(expectedMillis), TimeTestUtil.getFullDaysMillis(DateTimeUtil.getUtcMillisFromEpoch(pkcs7.getSignDate())), EPS); @@ -236,14 +262,14 @@ public void readSignatureDataWithSpecialSubFilterTest() throws IOException { SignatureUtil signatureUtil = new SignatureUtil(pdfDocument); PdfPKCS7 pkcs7 = signatureUtil.readSignatureData("Signature1"); - Assert.assertNotNull(pkcs7); - Assert.assertNotNull(pkcs7); - Assert.assertEquals("Test", pkcs7.getReason()); - Assert.assertNull(pkcs7.getSignName()); - Assert.assertEquals("TestCity", pkcs7.getLocation()); + Assertions.assertNotNull(pkcs7); + Assertions.assertNotNull(pkcs7); + Assertions.assertEquals("Test", pkcs7.getReason()); + Assertions.assertNull(pkcs7.getSignName()); + Assertions.assertEquals("TestCity", pkcs7.getLocation()); // The number corresponds to 18 May, 2021 11:28:40. double expectedMillis = (double) 1621326520000L; - Assert.assertEquals( + Assertions.assertEquals( TimeTestUtil.getFullDaysMillis(expectedMillis), TimeTestUtil.getFullDaysMillis(DateTimeUtil.getUtcMillisFromEpoch(pkcs7.getSignDate())), EPS); @@ -255,7 +281,7 @@ public void byteRangeAndContentsEntriesTest() throws IOException { PdfDocument pdfDocument = new PdfDocument(new PdfReader(inPdf)); SignatureUtil signatureUtil = new SignatureUtil(pdfDocument); - Assert.assertThrows(PdfException.class, + Assertions.assertThrows(PdfException.class, () -> signatureUtil.readSignatureData("Signature1")); } @@ -265,7 +291,7 @@ public void doesSignatureFieldExistTest() throws IOException { PdfDocument pdfDocument = new PdfDocument(new PdfReader(inPdf)); SignatureUtil signatureUtil = new SignatureUtil(pdfDocument); - Assert.assertTrue(signatureUtil.doesSignatureFieldExist("Signature1")); + Assertions.assertTrue(signatureUtil.doesSignatureFieldExist("Signature1")); } @Test @@ -274,7 +300,7 @@ public void doesSignatureFieldExistEmptySignatureTest() throws IOException { PdfDocument pdfDocument = new PdfDocument(new PdfReader(inPdf)); SignatureUtil signatureUtil = new SignatureUtil(pdfDocument); - Assert.assertTrue(signatureUtil.doesSignatureFieldExist("Signature1")); + Assertions.assertTrue(signatureUtil.doesSignatureFieldExist("Signature1")); } @Test @@ -283,7 +309,7 @@ public void signatureInTextTypeFieldTest() throws IOException { PdfDocument pdfDocument = new PdfDocument(new PdfReader(inPdf)); SignatureUtil signatureUtil = new SignatureUtil(pdfDocument); - Assert.assertFalse(signatureUtil.doesSignatureFieldExist("Signature1")); + Assertions.assertFalse(signatureUtil.doesSignatureFieldExist("Signature1")); } @Test @@ -292,7 +318,7 @@ public void getTotalRevisionsTest() throws IOException { PdfDocument pdfDocument = new PdfDocument(new PdfReader(inPdf)); SignatureUtil signatureUtil = new SignatureUtil(pdfDocument); - Assert.assertEquals(1, signatureUtil.getTotalRevisions()); + Assertions.assertEquals(1, signatureUtil.getTotalRevisions()); } @Test @@ -301,7 +327,7 @@ public void getRevisionTest() throws IOException { PdfDocument pdfDocument = new PdfDocument(new PdfReader(inPdf)); SignatureUtil signatureUtil = new SignatureUtil(pdfDocument); - Assert.assertEquals(1, signatureUtil.getRevision("Signature1")); + Assertions.assertEquals(1, signatureUtil.getRevision("Signature1")); } @Test @@ -310,7 +336,7 @@ public void getRevisionEmptyFieldsTest() throws IOException { PdfDocument pdfDocument = new PdfDocument(new PdfReader(inPdf)); SignatureUtil signatureUtil = new SignatureUtil(pdfDocument); - Assert.assertEquals(0, signatureUtil.getRevision("Signature1")); + Assertions.assertEquals(0, signatureUtil.getRevision("Signature1")); } @Test @@ -319,7 +345,7 @@ public void getRevisionXfaFormTest() throws IOException { PdfDocument pdfDocument = new PdfDocument(new PdfReader(inPdf)); SignatureUtil signatureUtil = new SignatureUtil(pdfDocument); - Assert.assertEquals(1, signatureUtil.getRevision("Signature1")); + Assertions.assertEquals(1, signatureUtil.getRevision("Signature1")); } @Test @@ -328,7 +354,7 @@ public void extractRevisionTest() throws IOException { PdfDocument pdfDocument = new PdfDocument(new PdfReader(inPdf)); SignatureUtil signatureUtil = new SignatureUtil(pdfDocument); - Assert.assertNotNull(signatureUtil.extractRevision("Signature1")); + Assertions.assertNotNull(signatureUtil.extractRevision("Signature1")); } @Test @@ -337,6 +363,6 @@ public void extractRevisionNotSignatureFieldTest() throws IOException { PdfDocument pdfDocument = new PdfDocument(new PdfReader(inPdf)); SignatureUtil signatureUtil = new SignatureUtil(pdfDocument); - Assert.assertNull(signatureUtil.extractRevision("Signature1")); + Assertions.assertNull(signatureUtil.extractRevision("Signature1")); } } diff --git a/sign/src/test/java/com/itextpdf/signatures/SignatureUtilUnitTest.java b/sign/src/test/java/com/itextpdf/signatures/SignatureUtilUnitTest.java index 59e35d4a4c..ec8c0ace7b 100644 --- a/sign/src/test/java/com/itextpdf/signatures/SignatureUtilUnitTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/SignatureUtilUnitTest.java @@ -25,14 +25,13 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfWriter; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.ByteArrayOutputStream; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class SignatureUtilUnitTest extends ExtendedITextTest { @Test @@ -42,6 +41,6 @@ public void signatureCoversWholeDocumentBlankDocTest() { SignatureUtil signatureUtil = new SignatureUtil(blankDoc); covers = signatureUtil.signatureCoversWholeDocument("sign"); } - Assert.assertFalse(covers); + Assertions.assertFalse(covers); } } diff --git a/sign/src/test/java/com/itextpdf/signatures/TSAClientBouncyCastleTest.java b/sign/src/test/java/com/itextpdf/signatures/TSAClientBouncyCastleTest.java index 0fc2805624..44954c66f8 100644 --- a/sign/src/test/java/com/itextpdf/signatures/TSAClientBouncyCastleTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/TSAClientBouncyCastleTest.java @@ -32,7 +32,6 @@ This file is part of the iText (R) project. import com.itextpdf.signatures.testutils.PemFileHelper; import com.itextpdf.signatures.testutils.builder.TestTimestampTokenBuilder; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.BouncyCastleUnitTest; import java.security.GeneralSecurityException; import java.security.MessageDigest; @@ -40,11 +39,11 @@ This file is part of the iText (R) project. import java.security.cert.Certificate; import java.util.Arrays; import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(BouncyCastleUnitTest.class) +@Tag("BouncyCastleUnitTest") public class TSAClientBouncyCastleTest extends ExtendedITextTest { private static final IBouncyCastleFactory BOUNCY_CASTLE_FACTORY = BouncyCastleFactoryCreator.getFactory(); @@ -53,7 +52,7 @@ public void setTSAInfoTest() { TSAClientBouncyCastle clientBouncyCastle = new TSAClientBouncyCastle("url"); CustomItsaInfoBouncyCastle infoBouncyCastle = new CustomItsaInfoBouncyCastle(); clientBouncyCastle.setTSAInfo(infoBouncyCastle); - Assert.assertEquals(infoBouncyCastle, clientBouncyCastle.tsaInfo); + Assertions.assertEquals(infoBouncyCastle, clientBouncyCastle.tsaInfo); } @Test @@ -63,11 +62,11 @@ public void testTsaClientBouncyCastleConstructor3Args() { String url = "url"; TSAClientBouncyCastle tsaClientBouncyCastle = new TSAClientBouncyCastle(url, userName, password); - Assert.assertEquals(url, tsaClientBouncyCastle.tsaURL); - Assert.assertEquals(userName, tsaClientBouncyCastle.tsaUsername); - Assert.assertEquals(password, tsaClientBouncyCastle.tsaPassword); - Assert.assertEquals(TSAClientBouncyCastle.DEFAULTTOKENSIZE, tsaClientBouncyCastle.getTokenSizeEstimate()); - Assert.assertEquals(TSAClientBouncyCastle.DEFAULTHASHALGORITHM, tsaClientBouncyCastle.digestAlgorithm); + Assertions.assertEquals(url, tsaClientBouncyCastle.tsaURL); + Assertions.assertEquals(userName, tsaClientBouncyCastle.tsaUsername); + Assertions.assertEquals(password, tsaClientBouncyCastle.tsaPassword); + Assertions.assertEquals(TSAClientBouncyCastle.DEFAULTTOKENSIZE, tsaClientBouncyCastle.getTokenSizeEstimate()); + Assertions.assertEquals(TSAClientBouncyCastle.DEFAULTHASHALGORITHM, tsaClientBouncyCastle.digestAlgorithm); } @Test @@ -80,12 +79,12 @@ public void testTsaClientBouncyCastleConstructorAllArgs() { TSAClientBouncyCastle tsaClientBouncyCastle = new TSAClientBouncyCastle(url, userName, password, tokenSize, digestAlgorithm); - Assert.assertEquals(url, tsaClientBouncyCastle.tsaURL); - Assert.assertEquals(userName, tsaClientBouncyCastle.tsaUsername); - Assert.assertEquals(password, tsaClientBouncyCastle.tsaPassword); - Assert.assertEquals(TSAClientBouncyCastle.DEFAULTTOKENSIZE, tsaClientBouncyCastle.tokenSizeEstimate); - Assert.assertEquals(tokenSize, tsaClientBouncyCastle.getTokenSizeEstimate()); - Assert.assertEquals(digestAlgorithm, tsaClientBouncyCastle.digestAlgorithm); + Assertions.assertEquals(url, tsaClientBouncyCastle.tsaURL); + Assertions.assertEquals(userName, tsaClientBouncyCastle.tsaUsername); + Assertions.assertEquals(password, tsaClientBouncyCastle.tsaPassword); + Assertions.assertEquals(TSAClientBouncyCastle.DEFAULTTOKENSIZE, tsaClientBouncyCastle.tokenSizeEstimate); + Assertions.assertEquals(tokenSize, tsaClientBouncyCastle.getTokenSizeEstimate()); + Assertions.assertEquals(digestAlgorithm, tsaClientBouncyCastle.digestAlgorithm); } @Test @@ -93,11 +92,11 @@ public void testTsaClientBouncyCastleConstructor1Arg() { String url = "url"; TSAClientBouncyCastle tsaClientBouncyCastle = new TSAClientBouncyCastle(url); - Assert.assertEquals(url, tsaClientBouncyCastle.tsaURL); - Assert.assertNull(tsaClientBouncyCastle.tsaUsername); - Assert.assertNull(tsaClientBouncyCastle.tsaPassword); - Assert.assertEquals(TSAClientBouncyCastle.DEFAULTTOKENSIZE, tsaClientBouncyCastle.tokenSizeEstimate); - Assert.assertEquals(TSAClientBouncyCastle.DEFAULTHASHALGORITHM, tsaClientBouncyCastle.digestAlgorithm); + Assertions.assertEquals(url, tsaClientBouncyCastle.tsaURL); + Assertions.assertNull(tsaClientBouncyCastle.tsaUsername); + Assertions.assertNull(tsaClientBouncyCastle.tsaPassword); + Assertions.assertEquals(TSAClientBouncyCastle.DEFAULTTOKENSIZE, tsaClientBouncyCastle.tokenSizeEstimate); + Assertions.assertEquals(TSAClientBouncyCastle.DEFAULTHASHALGORITHM, tsaClientBouncyCastle.digestAlgorithm); } @Test @@ -110,7 +109,7 @@ public void getTokenSizeEstimateTest() { TSAClientBouncyCastle tsaClientBouncyCastle = new TSAClientBouncyCastle(url, userName, password, tokenSizeEstimate, digestAlgorithm); - Assert.assertEquals(tokenSizeEstimate, tsaClientBouncyCastle.getTokenSizeEstimate()); + Assertions.assertEquals(tokenSizeEstimate, tsaClientBouncyCastle.getTokenSizeEstimate()); } @Test @@ -119,7 +118,7 @@ public void setGetTsaReqPolicyTest() { TSAClientBouncyCastle clientBouncyCastle = new TSAClientBouncyCastle("url"); clientBouncyCastle.setTSAReqPolicy(regPolicy); - Assert.assertEquals(regPolicy, clientBouncyCastle.getTSAReqPolicy()); + Assertions.assertEquals(regPolicy, clientBouncyCastle.getTSAReqPolicy()); } @Test @@ -133,8 +132,8 @@ public void getMessageDigestTest() throws GeneralSecurityException { TSAClientBouncyCastle tsaClientBouncyCastle = new TSAClientBouncyCastle(url, userName, password, tokenSizeEstimate, digestAlgorithm); MessageDigest digest = tsaClientBouncyCastle.getMessageDigest(); - Assert.assertNotNull(digest); - Assert.assertEquals(digestAlgorithm, digest.getAlgorithm()); + Assertions.assertNotNull(digest); + Assertions.assertEquals(digestAlgorithm, digest.getAlgorithm()); } @Test @@ -156,10 +155,10 @@ public void getTimeStampTokenTest() throws Exception { ITimeStampTokenInfo expectedTsTokenInfo = expectedToken.getTimeStampInfo(); ITimeStampTokenInfo resultTsTokenInfo = itsaInfoBouncyCastle.getTimeStampTokenInfo(); - Assert.assertNotNull(timestampTokenArray); - Assert.assertNotNull(resultTsTokenInfo); - Assert.assertArrayEquals(expectedTsTokenInfo.getEncoded(), resultTsTokenInfo.getEncoded()); - Assert.assertArrayEquals(expectedToken.getEncoded(), timestampTokenArray); + Assertions.assertNotNull(timestampTokenArray); + Assertions.assertNotNull(resultTsTokenInfo); + Assertions.assertArrayEquals(expectedTsTokenInfo.getEncoded(), resultTsTokenInfo.getEncoded()); + Assertions.assertArrayEquals(expectedToken.getEncoded(), timestampTokenArray); } @Test @@ -173,11 +172,11 @@ public void getTimeStampTokenFailureExceptionTest() throws Exception { tsaClientBouncyCastle.setTSAInfo(new CustomItsaInfoBouncyCastle()); byte[] digest = tsaClientBouncyCastle.getMessageDigest().digest(); - Exception e = Assert.assertThrows(PdfException.class, + Exception e = Assertions.assertThrows(PdfException.class, () -> tsaClientBouncyCastle.getTimeStampToken(digest) ); - Assert.assertEquals(MessageFormatUtil.format(SignExceptionMessageConstant.INVALID_TSA_RESPONSE, url, + Assertions.assertEquals(MessageFormatUtil.format(SignExceptionMessageConstant.INVALID_TSA_RESPONSE, url, "128: request contains unknown algorithm"), e.getMessage()); } diff --git a/sign/src/test/java/com/itextpdf/signatures/TestSignUtils.java b/sign/src/test/java/com/itextpdf/signatures/TestSignUtils.java index 111e924817..304e3e4728 100644 --- a/sign/src/test/java/com/itextpdf/signatures/TestSignUtils.java +++ b/sign/src/test/java/com/itextpdf/signatures/TestSignUtils.java @@ -51,7 +51,7 @@ This file is part of the iText (R) project. import java.util.HashMap; import java.util.List; import java.util.Map; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; public final class TestSignUtils { private static final IBouncyCastleFactory FACTORY = BouncyCastleFactoryCreator.getFactory(); @@ -72,17 +72,17 @@ public static void assertDssDict(InputStream inputStream, Map e Map realNumberOfOcsp = createOcspMap(ocsps); if (expectedCerts != null) { - Assert.assertEquals("Certs entry in DSS dictionary isn't correct", realCertificates.size(), - expectedCerts.size()); + Assertions.assertEquals(realCertificates.size(), expectedCerts.size(), + "Certs entry in DSS dictionary isn't correct"); // Order agnostic list comparison. for (String expectedCert : expectedCerts) { - Assert.assertTrue(realCertificates.stream().anyMatch(cert -> cert.equals(expectedCert))); + Assertions.assertTrue(realCertificates.stream().anyMatch(cert -> cert.equals(expectedCert))); } } - Assert.assertTrue("CRLs entry in DSS dictionary isn't correct", - MapUtil.equals(expectedNumberOfCrls, realNumberOfCrls)); - Assert.assertTrue("OCSPs entry in DSS dictionary isn't correct", - MapUtil.equals(expectedNumberOfOcsp, realNumberOfOcsp)); + Assertions.assertTrue(MapUtil.equals(expectedNumberOfCrls, realNumberOfCrls), + "CRLs entry in DSS dictionary isn't correct"); + Assertions.assertTrue(MapUtil.equals(expectedNumberOfOcsp, realNumberOfOcsp), + "OCSPs entry in DSS dictionary isn't correct"); } } @@ -102,7 +102,7 @@ public static void basicCheckSignedDoc(InputStream inputStream, String signature try (PdfDocument outDocument = new PdfDocument(new PdfReader(inputStream))) { SignatureUtil sigUtil = new SignatureUtil(outDocument); PdfPKCS7 signatureData = sigUtil.readSignatureData(signatureName); - Assert.assertTrue(signatureData.verifySignatureIntegrityAndAuthenticity()); + Assertions.assertTrue(signatureData.verifySignatureIntegrityAndAuthenticity()); } } @@ -113,9 +113,9 @@ public static void signedDocumentContainsCerts(InputStream inputStream, List actualCertificates = Arrays.asList(sigUtil.readSignatureData(signatureName).getCertificates()); // Searching for every certificate we expect should be in the resulting document. - Assert.assertEquals(expectedCertificates.size(), actualCertificates.size()); + Assertions.assertEquals(expectedCertificates.size(), actualCertificates.size()); for (X509Certificate expectedCert : expectedCertificates) { - Assert.assertTrue(actualCertificates.stream().anyMatch(cert -> + Assertions.assertTrue(actualCertificates.stream().anyMatch(cert -> ((X509Certificate) cert).getSubjectX500Principal().equals(expectedCert.getSubjectX500Principal()))); } } diff --git a/sign/src/test/java/com/itextpdf/signatures/TrustedCerrtificatesStoreTest.java b/sign/src/test/java/com/itextpdf/signatures/TrustedCerrtificatesStoreTest.java new file mode 100644 index 0000000000..26a4d501ca --- /dev/null +++ b/sign/src/test/java/com/itextpdf/signatures/TrustedCerrtificatesStoreTest.java @@ -0,0 +1,286 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.signatures; + +import com.itextpdf.bouncycastleconnector.BouncyCastleFactoryCreator; +import com.itextpdf.commons.bouncycastle.IBouncyCastleFactory; +import com.itextpdf.commons.utils.DateTimeUtil; +import com.itextpdf.commons.utils.FileUtil; +import com.itextpdf.signatures.logs.SignLogMessageConstant; +import com.itextpdf.signatures.testutils.PemFileHelper; +import com.itextpdf.signatures.testutils.TimeTestUtil; +import com.itextpdf.signatures.testutils.builder.TestCrlBuilder; +import com.itextpdf.signatures.validation.AssertValidationReport; +import com.itextpdf.signatures.validation.CRLValidator; +import com.itextpdf.signatures.validation.SignatureValidationProperties; +import com.itextpdf.signatures.validation.TrustedCertificatesStore; +import com.itextpdf.signatures.validation.ValidatorChainBuilder; +import com.itextpdf.signatures.validation.context.CertificateSource; +import com.itextpdf.signatures.validation.context.TimeBasedContext; +import com.itextpdf.signatures.validation.context.ValidationContext; +import com.itextpdf.signatures.validation.context.ValidatorContext; +import com.itextpdf.signatures.validation.mocks.MockChainValidator; +import com.itextpdf.signatures.validation.mocks.MockIssuingCertificateRetriever; +import com.itextpdf.signatures.validation.report.ReportItem; +import com.itextpdf.signatures.validation.report.ValidationReport; +import com.itextpdf.signatures.validation.report.ValidationReport.ValidationResult; +import com.itextpdf.test.ExtendedITextTest; + +import com.fasterxml.jackson.annotation.JsonTypeInfo.As; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.security.PrivateKey; +import java.security.Security; +import java.security.cert.Certificate; +import java.security.cert.CertificateException; +import java.security.cert.X509CRL; +import java.security.cert.X509Certificate; +import java.util.Arrays; +import java.util.Collections; +import java.util.Date; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +@Tag("BouncyCastleUnitTest") +public class TrustedCerrtificatesStoreTest extends ExtendedITextTest { + private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/signatures/certs/"; + + private static final char[] KEY_PASSWORD = "testpassphrase".toCharArray(); + private static X509Certificate crlCert; + private static X509Certificate crlRootCert; + private static X509Certificate intermediateCert; + private static X509Certificate ocspCert; + private static X509Certificate rootCert; + private static X509Certificate signCert; + private static X509Certificate tsaCert; + private static X509Certificate tsaRootCert; + + @BeforeAll + public static void setUpOnce() throws CertificateException, IOException { + crlCert = (X509Certificate) PemFileHelper.readFirstChain(SOURCE_FOLDER + "crlCert.pem")[0]; + crlRootCert= (X509Certificate) PemFileHelper.readFirstChain(SOURCE_FOLDER + "crlRoot.pem")[0]; + intermediateCert = (X509Certificate) PemFileHelper.readFirstChain(SOURCE_FOLDER + "intermediate.pem")[0]; + ocspCert = (X509Certificate) PemFileHelper.readFirstChain(SOURCE_FOLDER + "ocspCert.pem")[0]; + rootCert = (X509Certificate) PemFileHelper.readFirstChain(SOURCE_FOLDER + "root.pem")[0]; + signCert = (X509Certificate) PemFileHelper.readFirstChain(SOURCE_FOLDER + "sign.pem")[0]; + tsaCert = (X509Certificate) PemFileHelper.readFirstChain(SOURCE_FOLDER + "tsaCert.pem")[0]; + tsaRootCert = (X509Certificate) PemFileHelper.readFirstChain(SOURCE_FOLDER + "tsaRoot.pem")[0]; + } + + @Test + public void testIsCertificateGenerallyTrusted() { + TrustedCertificatesStore sut = new TrustedCertificatesStore(); + sut.addCATrustedCertificates(Collections.singletonList(rootCert)); + sut.addTimestampTrustedCertificates(Collections.singletonList(rootCert)); + sut.addOcspTrustedCertificates(Collections.singletonList(rootCert)); + sut.addCrlTrustedCertificates(Collections.singletonList(rootCert)); + Assertions.assertFalse(sut.isCertificateGenerallyTrusted(rootCert)); + sut.addGenerallyTrustedCertificates(Collections.singletonList(rootCert)); + Assertions.assertTrue(sut.isCertificateGenerallyTrusted(rootCert)); + } + + @Test + public void testIsCertificateTrustedForCA() { + TrustedCertificatesStore sut = new TrustedCertificatesStore(); + sut.addGenerallyTrustedCertificates(Collections.singletonList(rootCert)); + sut.addTimestampTrustedCertificates(Collections.singletonList(rootCert)); + sut.addOcspTrustedCertificates(Collections.singletonList(rootCert)); + sut.addCrlTrustedCertificates(Collections.singletonList(rootCert)); + Assertions.assertFalse(sut.isCertificateTrustedForCA(rootCert)); + sut.addCATrustedCertificates(Collections.singletonList(rootCert)); + Assertions.assertTrue(sut.isCertificateTrustedForCA(rootCert)); + } + + @Test + public void testIsCertificateTrustedForTimestamp() { + TrustedCertificatesStore sut = new TrustedCertificatesStore(); + sut.addGenerallyTrustedCertificates(Collections.singletonList(rootCert)); + sut.addCATrustedCertificates(Collections.singletonList(rootCert)); + sut.addOcspTrustedCertificates(Collections.singletonList(rootCert)); + sut.addCrlTrustedCertificates(Collections.singletonList(rootCert)); + Assertions.assertFalse(sut.isCertificateTrustedForTimestamp(rootCert)); + sut.addTimestampTrustedCertificates(Collections.singletonList(rootCert)); + Assertions.assertTrue(sut.isCertificateTrustedForTimestamp(rootCert)); + } + + @Test + public void testIsCertificateTrustedForOcsp() { + TrustedCertificatesStore sut = new TrustedCertificatesStore(); + sut.addGenerallyTrustedCertificates(Collections.singletonList(rootCert)); + sut.addCATrustedCertificates(Collections.singletonList(rootCert)); + sut.addTimestampTrustedCertificates(Collections.singletonList(rootCert)); + sut.addCrlTrustedCertificates(Collections.singletonList(rootCert)); + Assertions.assertFalse(sut.isCertificateTrustedForOcsp(rootCert)); + sut.addOcspTrustedCertificates(Collections.singletonList(rootCert)); + Assertions.assertTrue(sut.isCertificateTrustedForOcsp(rootCert)); + } + + @Test + public void testIsCertificateTrustedForCrl() { + TrustedCertificatesStore sut = new TrustedCertificatesStore(); + sut.addGenerallyTrustedCertificates(Collections.singletonList(rootCert)); + sut.addCATrustedCertificates(Collections.singletonList(rootCert)); + sut.addTimestampTrustedCertificates(Collections.singletonList(rootCert)); + sut.addOcspTrustedCertificates(Collections.singletonList(rootCert)); + Assertions.assertFalse(sut.isCertificateTrustedForCrl(rootCert)); + sut.addCrlTrustedCertificates(Collections.singletonList(rootCert)); + Assertions.assertTrue(sut.isCertificateTrustedForCrl(rootCert)); + } + + @Test + public void testGetKnownCertificates() { + TrustedCertificatesStore sut = new TrustedCertificatesStore(); + sut.addCrlTrustedCertificates(Collections.singletonList(crlCert)); + sut.addCATrustedCertificates(Collections.singletonList(rootCert)); + sut.addOcspTrustedCertificates(Collections.singletonList(ocspCert)); + sut.addTimestampTrustedCertificates(Collections.singletonList(tsaCert)); + sut.addGenerallyTrustedCertificates(Collections.singletonList(tsaRootCert)); + + Assertions.assertEquals(1, sut.getKnownCertificates(crlCert.getSubjectX500Principal().getName()).size()); + Assertions.assertEquals(1, sut.getKnownCertificates(rootCert.getSubjectX500Principal().getName()).size()); + } + + + @Test + public void testGetAllTrustedCertificates() { + TrustedCertificatesStore sut = new TrustedCertificatesStore(); + sut.addCrlTrustedCertificates(Collections.singletonList(tsaRootCert)); + sut.addCATrustedCertificates(Collections.singletonList(rootCert)); + sut.addOcspTrustedCertificates(Collections.singletonList(tsaRootCert)); + sut.addTimestampTrustedCertificates(Collections.singletonList(tsaCert)); + sut.addGenerallyTrustedCertificates(Collections.singletonList(tsaRootCert)); + + //duplicates should be removed + Assertions.assertEquals(3, sut.getAllTrustedCertificates().size()); + Assertions.assertTrue(sut.getAllTrustedCertificates().contains(tsaRootCert)); + Assertions.assertTrue(sut.getAllTrustedCertificates().contains(rootCert)); + Assertions.assertTrue(sut.getAllTrustedCertificates().contains(tsaCert)); + } + + @Test + public void testGetAllTrustedCertificatesByName() { + TrustedCertificatesStore sut = new TrustedCertificatesStore(); + sut.addCrlTrustedCertificates(Collections.singletonList(tsaRootCert)); + sut.addCATrustedCertificates(Collections.singletonList(rootCert)); + sut.addOcspTrustedCertificates(Collections.singletonList(tsaRootCert)); + sut.addTimestampTrustedCertificates(Collections.singletonList(tsaCert)); + sut.addGenerallyTrustedCertificates(Collections.singletonList(tsaRootCert)); + + //duplicates should be removed + Assertions.assertEquals(1, sut.getAllTrustedCertificates(tsaRootCert.getSubjectX500Principal().getName()).size()); + Assertions.assertTrue(sut.getAllTrustedCertificates(tsaRootCert.getSubjectX500Principal().getName()).contains(tsaRootCert)); + Assertions.assertTrue(sut.getAllTrustedCertificates(rootCert.getSubjectX500Principal().getName()).contains(rootCert)); + Assertions.assertTrue(sut.getAllTrustedCertificates(tsaCert.getSubjectX500Principal().getName()).contains(tsaCert)); + } + + @Test + public void testGetGenerallyTrustedCertificates() { + TrustedCertificatesStore sut = new TrustedCertificatesStore(); + sut.addGenerallyTrustedCertificates(Collections.singletonList(signCert)); + sut.addCATrustedCertificates(Collections.singletonList(rootCert)); + sut.addTimestampTrustedCertificates(Collections.singletonList(tsaCert)); + sut.addOcspTrustedCertificates(Collections.singletonList(ocspCert)); + sut.addCrlTrustedCertificates(Collections.singletonList(crlCert)); + + String name = signCert.getSubjectX500Principal().getName(); + + Assertions.assertEquals(1,sut.getGenerallyTrustedCertificates(name).size()); + Assertions.assertEquals(0,sut.getCertificatesTrustedForCA(name).size()); + Assertions.assertEquals(0,sut.getCertificatesTrustedForCrl(name).size()); + Assertions.assertEquals(0,sut.getCertificatesTrustedForOcsp(name).size()); + Assertions.assertEquals(0,sut.getCertificatesTrustedForTimestamp(name).size()); + } + + + @Test + public void testGetCertificatesTrustedForCA() { + TrustedCertificatesStore sut = new TrustedCertificatesStore(); + sut.addGenerallyTrustedCertificates(Collections.singletonList(signCert)); + sut.addCATrustedCertificates(Collections.singletonList(rootCert)); + sut.addTimestampTrustedCertificates(Collections.singletonList(tsaCert)); + sut.addOcspTrustedCertificates(Collections.singletonList(ocspCert)); + sut.addCrlTrustedCertificates(Collections.singletonList(crlCert)); + + String name = rootCert.getSubjectX500Principal().getName(); + + Assertions.assertEquals(0,sut.getGenerallyTrustedCertificates(name).size()); + Assertions.assertEquals(1,sut.getCertificatesTrustedForCA(name).size()); + Assertions.assertEquals(0,sut.getCertificatesTrustedForCrl(name).size()); + Assertions.assertEquals(0,sut.getCertificatesTrustedForOcsp(name).size()); + Assertions.assertEquals(0,sut.getCertificatesTrustedForTimestamp(name).size()); + } + @Test + public void testGetCertificatesTrustedForTimeStamp() { + TrustedCertificatesStore sut = new TrustedCertificatesStore(); + sut.addGenerallyTrustedCertificates(Collections.singletonList(signCert)); + sut.addCATrustedCertificates(Collections.singletonList(rootCert)); + sut.addTimestampTrustedCertificates(Collections.singletonList(tsaCert)); + sut.addOcspTrustedCertificates(Collections.singletonList(ocspCert)); + sut.addCrlTrustedCertificates(Collections.singletonList(crlCert)); + + String name = tsaCert.getSubjectX500Principal().getName(); + + Assertions.assertEquals(0,sut.getGenerallyTrustedCertificates(name).size()); + Assertions.assertEquals(0,sut.getCertificatesTrustedForCA(name).size()); + Assertions.assertEquals(0,sut.getCertificatesTrustedForCrl(name).size()); + Assertions.assertEquals(0,sut.getCertificatesTrustedForOcsp(name).size()); + Assertions.assertEquals(1,sut.getCertificatesTrustedForTimestamp(name).size()); + } + @Test + public void testGetCertificatesTrustedForOcsp() { + TrustedCertificatesStore sut = new TrustedCertificatesStore(); + sut.addGenerallyTrustedCertificates(Collections.singletonList(signCert)); + sut.addCATrustedCertificates(Collections.singletonList(rootCert)); + sut.addTimestampTrustedCertificates(Collections.singletonList(tsaCert)); + sut.addOcspTrustedCertificates(Collections.singletonList(ocspCert)); + sut.addCrlTrustedCertificates(Collections.singletonList(crlCert)); + + String name = ocspCert.getSubjectX500Principal().getName(); + + Assertions.assertEquals(0,sut.getGenerallyTrustedCertificates(name).size()); + Assertions.assertEquals(0,sut.getCertificatesTrustedForCA(name).size()); + Assertions.assertEquals(0,sut.getCertificatesTrustedForCrl(name).size()); + Assertions.assertEquals(1,sut.getCertificatesTrustedForOcsp(name).size()); + Assertions.assertEquals(0,sut.getCertificatesTrustedForTimestamp(name).size()); + } + @Test + public void testGetCertificatesTrustedForCrl() { + TrustedCertificatesStore sut = new TrustedCertificatesStore(); + sut.addGenerallyTrustedCertificates(Collections.singletonList(signCert)); + sut.addCATrustedCertificates(Collections.singletonList(rootCert)); + sut.addTimestampTrustedCertificates(Collections.singletonList(tsaCert)); + sut.addOcspTrustedCertificates(Collections.singletonList(ocspCert)); + sut.addCrlTrustedCertificates(Collections.singletonList(crlCert)); + + String name = crlCert.getSubjectX500Principal().getName(); + + Assertions.assertEquals(0,sut.getGenerallyTrustedCertificates(name).size()); + Assertions.assertEquals(0,sut.getCertificatesTrustedForCA(name).size()); + Assertions.assertEquals(1,sut.getCertificatesTrustedForCrl(name).size()); + Assertions.assertEquals(0,sut.getCertificatesTrustedForOcsp(name).size()); + Assertions.assertEquals(0,sut.getCertificatesTrustedForTimestamp(name).size()); + } +} diff --git a/sign/src/test/java/com/itextpdf/signatures/VerificationOKTest.java b/sign/src/test/java/com/itextpdf/signatures/VerificationOKTest.java index 5370f52406..560bb8faa5 100644 --- a/sign/src/test/java/com/itextpdf/signatures/VerificationOKTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/VerificationOKTest.java @@ -24,24 +24,23 @@ This file is part of the iText (R) project. import com.itextpdf.signatures.testutils.X509MockCertificate; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class VerificationOKTest extends ExtendedITextTest { @Test public void toStringTest() { VerificationOK verificationOK = new VerificationOK(null, CRLVerifier.class, "Mock verification"); - Assert.assertEquals(CRLVerifier.class.getName() + ": Mock verification", verificationOK.toString()); + Assertions.assertEquals(CRLVerifier.class.getName() + ": Mock verification", verificationOK.toString()); } @Test public void toStringWithCertificateNotNullTest() { VerificationOK verificationOK = new VerificationOK(new X509MockCertificate(), CRLVerifier.class, "Mock verification"); // NPE is thrown because getSubjectDN method returns null for X509MockCertificate class. - Assert.assertThrows(NullPointerException.class, () -> verificationOK.toString()); + Assertions.assertThrows(NullPointerException.class, () -> verificationOK.toString()); } } diff --git a/sign/src/test/java/com/itextpdf/signatures/cms/CMSContainerTest.java b/sign/src/test/java/com/itextpdf/signatures/cms/CMSContainerTest.java index 55e3163947..95daf64d8c 100644 --- a/sign/src/test/java/com/itextpdf/signatures/cms/CMSContainerTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/cms/CMSContainerTest.java @@ -29,11 +29,11 @@ This file is part of the iText (R) project. import com.itextpdf.commons.bouncycastle.operator.AbstractOperatorCreationException; import com.itextpdf.commons.bouncycastle.pkcs.AbstractPKCSException; import com.itextpdf.commons.utils.Base64; +import com.itextpdf.kernel.crypto.DigestAlgorithms; +import com.itextpdf.kernel.crypto.OID; import com.itextpdf.kernel.exceptions.PdfException; import com.itextpdf.kernel.pdf.PdfName; -import com.itextpdf.signatures.DigestAlgorithms; import com.itextpdf.signatures.PdfPKCS7; -import com.itextpdf.signatures.SecurityIDs; import com.itextpdf.signatures.SignatureMechanisms; import com.itextpdf.signatures.exceptions.SignExceptionMessageConstant; import com.itextpdf.signatures.logs.SignLogMessageConstant; @@ -43,11 +43,6 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.BouncyCastleUnitTest; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; import java.io.ByteArrayInputStream; import java.io.IOException; @@ -57,15 +52,19 @@ This file is part of the iText (R) project. import java.security.NoSuchProviderException; import java.security.PrivateKey; import java.security.Security; +import java.security.cert.CRLException; import java.security.cert.Certificate; import java.security.cert.CertificateEncodingException; import java.security.cert.CertificateException; -import java.security.cert.CRLException; import java.security.cert.X509Certificate; import java.util.ArrayList; import java.util.Collections; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(BouncyCastleUnitTest.class) +@Tag("BouncyCastleUnitTest") public class CMSContainerTest extends ExtendedITextTest { private static final IBouncyCastleFactory FACTORY = BouncyCastleFactoryCreator.getFactory(); @@ -78,7 +77,7 @@ public class CMSContainerTest extends ExtendedITextTest { private byte[] testCrlResponse; - @Before + @BeforeEach public void init() throws IOException, CertificateException, AbstractPKCSException, AbstractOperatorCreationException { Security.addProvider(FACTORY.getProvider()); @@ -108,15 +107,15 @@ public void testSerialize() throws CertificateEncodingException, IOException, No si.setMessageDigest(new byte[256]); si.setOcspResponses(fakeOcspREsponses); si.setCrlResponses(Collections.singletonList(testCrlResponse)); - si.setDigestAlgorithm(new AlgorithmIdentifier(SecurityIDs.ID_SHA512)); - si.setSigningCertificateAndAddToSignedAttributes(signCert, SecurityIDs.ID_SHA512); + si.setDigestAlgorithm(new AlgorithmIdentifier(OID.SHA_512)); + si.setSigningCertificateAndAddToSignedAttributes(signCert, OID.SHA_512); si.setSignatureAlgorithm(new AlgorithmIdentifier( SignatureMechanisms.getSignatureMechanismOid("RSA", DigestAlgorithms.SHA512))); si.setSignature(new byte[256]); sut.setSignerInfo(si); byte[] serRes = sut.serialize(); - Assert.assertEquals(serializedAsString(Base64.decode(CMSTestHelper.EXPECTED_RESULT_CMS_CONTAINER_TEST)), + Assertions.assertEquals(serializedAsString(Base64.decode(CMSTestHelper.EXPECTED_RESULT_CMS_CONTAINER_TEST)), serializedAsString(serRes)); } @@ -132,8 +131,8 @@ public void testSerializationWithRevocationData() throws CertificateException, I SignerInfo si = new SignerInfo(); si.setSigningCertificate(signCert); si.setMessageDigest(new byte[256]); - si.setDigestAlgorithm(new AlgorithmIdentifier(SecurityIDs.ID_SHA512)); - si.setSigningCertificateAndAddToSignedAttributes(signCert, SecurityIDs.ID_SHA512); + si.setDigestAlgorithm(new AlgorithmIdentifier(OID.SHA_512)); + si.setSigningCertificateAndAddToSignedAttributes(signCert, OID.SHA_512); si.setSignatureAlgorithm(new AlgorithmIdentifier( SignatureMechanisms.getSignatureMechanismOid("RSA", DigestAlgorithms.SHA512))); si.setSignature(new byte[256]); @@ -141,7 +140,7 @@ public void testSerializationWithRevocationData() throws CertificateException, I byte[] serRes = sut.serialize(); - Assert.assertEquals(serializedAsString(Base64.decode(CMSTestHelper.CMS_CONTAINER_WITH_OCSP_AND_CRL)), + Assertions.assertEquals(serializedAsString(Base64.decode(CMSTestHelper.CMS_CONTAINER_WITH_OCSP_AND_CRL)), serializedAsString(serRes)); } @@ -158,32 +157,32 @@ public void testGetSizeEstimation() throws CertificateEncodingException, IOExcep si.setMessageDigest(new byte[256]); si.setOcspResponses(fakeOcspREsponses); si.setCrlResponses(Collections.singletonList(testCrlResponse)); - si.setDigestAlgorithm(new AlgorithmIdentifier(SecurityIDs.ID_SHA512)); + si.setDigestAlgorithm(new AlgorithmIdentifier(OID.SHA_512)); si.setSignatureAlgorithm(new AlgorithmIdentifier( SignatureMechanisms.getSignatureMechanismOid("RSA", DigestAlgorithms.SHA512))); - si.setSigningCertificateAndAddToSignedAttributes(signCert, SecurityIDs.ID_SHA512); + si.setSigningCertificateAndAddToSignedAttributes(signCert, OID.SHA_512); si.setSignature(new byte[256]); sut.setSignerInfo(si); long size = sut.getSizeEstimation(); - Assert.assertEquals(4821, size); + Assertions.assertEquals(4821, size); } @Test public void testDeserialization() throws CertificateException, IOException, CRLException { byte[] rawData = Base64.decode(CMSTestHelper.EXPECTED_RESULT_CMS_CONTAINER_TEST); CMSContainer sd = new CMSContainer(rawData); - Assert.assertEquals("2.16.840.1.101.3.4.2.3", sd.getDigestAlgorithm().getAlgorithmOid()); - Assert.assertEquals("1.2.840.113549.1.7.1", sd.getEncapContentInfo().getContentType()); - Assert.assertEquals(3, sd.getCertificates().size()); - Assert.assertEquals(0, sd.getCrls().size()); - Assert.assertEquals(0, sd.getOcsps().size()); + Assertions.assertEquals("2.16.840.1.101.3.4.2.3", sd.getDigestAlgorithm().getAlgorithmOid()); + Assertions.assertEquals("1.2.840.113549.1.7.1", sd.getEncapContentInfo().getContentType()); + Assertions.assertEquals(3, sd.getCertificates().size()); + Assertions.assertEquals(0, sd.getCrls().size()); + Assertions.assertEquals(0, sd.getOcsps().size()); for (X509Certificate certificate : chain) { - Assert.assertTrue(sd.getCertificates().stream() + Assertions.assertTrue(sd.getCertificates().stream() .anyMatch(c -> certificate.getSerialNumber().toString().equals(c.getSerialNumber().toString()))); } - Assert.assertEquals(chain[0].getSerialNumber().toString(), + Assertions.assertEquals(chain[0].getSerialNumber().toString(), sd.getSignerInfo().getSigningCertificate().getSerialNumber().toString()); } @@ -191,16 +190,16 @@ public void testDeserialization() throws CertificateException, IOException, CRLE public void testDeserializationWithRevocationData() throws CertificateException, IOException, CRLException { byte[] rawData = Base64.decode(CMSTestHelper.CMS_CONTAINER_WITH_OCSP_AND_CRL); CMSContainer sd = new CMSContainer(rawData); - Assert.assertEquals("2.16.840.1.101.3.4.2.3", sd.getDigestAlgorithm().getAlgorithmOid()); - Assert.assertEquals("1.2.840.113549.1.7.1", sd.getEncapContentInfo().getContentType()); - Assert.assertEquals(3, sd.getCertificates().size()); - Assert.assertEquals(1, sd.getCrls().size()); - Assert.assertEquals(1, sd.getOcsps().size()); + Assertions.assertEquals("2.16.840.1.101.3.4.2.3", sd.getDigestAlgorithm().getAlgorithmOid()); + Assertions.assertEquals("1.2.840.113549.1.7.1", sd.getEncapContentInfo().getContentType()); + Assertions.assertEquals(3, sd.getCertificates().size()); + Assertions.assertEquals(1, sd.getCrls().size()); + Assertions.assertEquals(1, sd.getOcsps().size()); for (X509Certificate certificate : chain) { - Assert.assertTrue(sd.getCertificates().stream() + Assertions.assertTrue(sd.getCertificates().stream() .anyMatch(c -> certificate.getSerialNumber().toString().equals(c.getSerialNumber().toString()))); } - Assert.assertEquals(chain[0].getSerialNumber().toString(), + Assertions.assertEquals(chain[0].getSerialNumber().toString(), sd.getSignerInfo().getSigningCertificate().getSerialNumber().toString()); } @@ -209,54 +208,54 @@ public void testDeserializationWithRevocationData() throws CertificateException, public void testDeserializationWithIncorrectRevocationData() throws CertificateException, IOException, CRLException { byte[] rawData = Base64.decode(CMSTestHelper.CMS_CONTAINER_WITH_INCORRECT_REV_INFO); CMSContainer sd = new CMSContainer(rawData); - Assert.assertEquals(1, sd.getCrls().size()); - Assert.assertEquals(1, sd.getOcsps().size()); - Assert.assertEquals(1, sd.otherRevocationInfo.size()); + Assertions.assertEquals(1, sd.getCrls().size()); + Assertions.assertEquals(1, sd.getOcsps().size()); + Assertions.assertEquals(1, sd.otherRevocationInfo.size()); } @Test public void createPkcs7WithRevocationInfoTest() { PdfPKCS7 pkcs7 = new PdfPKCS7(Base64.decode(CMSTestHelper.CMS_CONTAINER_WITH_OCSP_AND_CRL), PdfName.Adbe_pkcs7_detached, FACTORY.getProviderName()); - Assert.assertEquals(1, pkcs7.getSignedDataCRLs().size()); - Assert.assertEquals(1, pkcs7.getSignedDataOcsps().size()); + Assertions.assertEquals(1, pkcs7.getSignedDataCRLs().size()); + Assertions.assertEquals(1, pkcs7.getSignedDataOcsps().size()); } @Test public void testMultipleDigestAlgorithms() { byte[] rawData = Base64.decode(CMSTestHelper.SERIALIZED_B64_2DIGEST_ALGOS); - Exception e = Assert.assertThrows(PdfException.class, () -> { + Exception e = Assertions.assertThrows(PdfException.class, () -> { CMSContainer sd = new CMSContainer(rawData); }); - Assert.assertEquals(SignExceptionMessageConstant.CMS_ONLY_ONE_SIGNER_ALLOWED, e.getMessage()); + Assertions.assertEquals(SignExceptionMessageConstant.CMS_ONLY_ONE_SIGNER_ALLOWED, e.getMessage()); } @Test public void testMultipleSignerInfos() { byte[] rawData = Base64.decode(CMSTestHelper.SERIALIZED_B64_2SIGNERS); - Exception e = Assert.assertThrows(PdfException.class, () -> { + Exception e = Assertions.assertThrows(PdfException.class, () -> { CMSContainer sd = new CMSContainer(rawData); }); - Assert.assertEquals(SignExceptionMessageConstant.CMS_ONLY_ONE_SIGNER_ALLOWED, e.getMessage()); + Assertions.assertEquals(SignExceptionMessageConstant.CMS_ONLY_ONE_SIGNER_ALLOWED, e.getMessage()); } @Test public void testCertificatesMissing() { byte[] rawData = Base64.decode(CMSTestHelper.SERIALIZED_B64_MISSING_CERTIFICATES); - Exception e = Assert.assertThrows(PdfException.class, () -> { + Exception e = Assertions.assertThrows(PdfException.class, () -> { CMSContainer sd = new CMSContainer(rawData); }); - Assert.assertEquals(SignExceptionMessageConstant.CMS_MISSING_CERTIFICATES, e.getMessage()); + Assertions.assertEquals(SignExceptionMessageConstant.CMS_MISSING_CERTIFICATES, e.getMessage()); } @Test public void testCertificatesEmpty() { byte[] rawData = Base64.decode(CMSTestHelper.SERIALIZED_B64_EMPTY_CERTIFICATES); - Exception e = Assert.assertThrows(PdfException.class, () -> { + Exception e = Assertions.assertThrows(PdfException.class, () -> { CMSContainer sd = new CMSContainer(rawData); }); - Assert.assertEquals(SignExceptionMessageConstant.CMS_MISSING_CERTIFICATES, e.getMessage()); + Assertions.assertEquals(SignExceptionMessageConstant.CMS_MISSING_CERTIFICATES, e.getMessage()); } private String toUnixStringEnding(String in) { diff --git a/sign/src/test/java/com/itextpdf/signatures/cms/EncapsulatedContentInfoTest.java b/sign/src/test/java/com/itextpdf/signatures/cms/EncapsulatedContentInfoTest.java index fb7aa25eed..ed6d254de0 100644 --- a/sign/src/test/java/com/itextpdf/signatures/cms/EncapsulatedContentInfoTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/cms/EncapsulatedContentInfoTest.java @@ -27,16 +27,15 @@ This file is part of the iText (R) project. import com.itextpdf.commons.bouncycastle.asn1.IASN1EncodableVector; import com.itextpdf.commons.bouncycastle.asn1.IASN1Sequence; import com.itextpdf.commons.utils.Base64; -import com.itextpdf.signatures.SecurityIDs; +import com.itextpdf.kernel.crypto.OID; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.BouncyCastleUnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; import java.io.IOException; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(BouncyCastleUnitTest.class) +@Tag("BouncyCastleUnitTest") public class EncapsulatedContentInfoTest extends ExtendedITextTest { private static final IBouncyCastleFactory FACTORY = BouncyCastleFactoryCreator.getFactory(); @@ -47,34 +46,34 @@ public class EncapsulatedContentInfoTest extends ExtendedITextTest { @Test public void testDeserializationWithoutContent() { IASN1EncodableVector v = FACTORY.createASN1EncodableVector(); - v.add(FACTORY.createASN1ObjectIdentifier(SecurityIDs.ID_PKCS7_DATA)); + v.add(FACTORY.createASN1ObjectIdentifier(OID.PKCS7_DATA)); IASN1Sequence testData = FACTORY.createDERSequence(v); EncapsulatedContentInfo sut = new EncapsulatedContentInfo(testData); - Assert.assertEquals(SecurityIDs.ID_PKCS7_DATA, sut.getContentType()); - Assert.assertNull(sut.getContent()); + Assertions.assertEquals(OID.PKCS7_DATA, sut.getContentType()); + Assertions.assertNull(sut.getContent()); } @Test public void testDeserializationWithContent() throws IOException { IASN1Sequence testData = FACTORY.createASN1Sequence(Base64.decode(ENCODED_WITH_CONTENT_B64)); EncapsulatedContentInfo sut = new EncapsulatedContentInfo(testData); - Assert.assertEquals("1.2.840.113549.1.9.16.1.4", sut.getContentType()); - Assert.assertNotNull(sut.getContent()); + Assertions.assertEquals("1.2.840.113549.1.9.16.1.4", sut.getContentType()); + Assertions.assertNotNull(sut.getContent()); } @Test public void testCreation() { - EncapsulatedContentInfo sut = new EncapsulatedContentInfo(SecurityIDs.ID_PKCS7_DATA); - Assert.assertEquals(SecurityIDs.ID_PKCS7_DATA, sut.getContentType()); - Assert.assertNull(sut.getContent()); + EncapsulatedContentInfo sut = new EncapsulatedContentInfo(OID.PKCS7_DATA); + Assertions.assertEquals(OID.PKCS7_DATA, sut.getContentType()); + Assertions.assertNull(sut.getContent()); } @Test public void testCreationWithContent() { - EncapsulatedContentInfo sut = new EncapsulatedContentInfo(SecurityIDs.ID_PKCS7_DATA, + EncapsulatedContentInfo sut = new EncapsulatedContentInfo(OID.PKCS7_DATA, FACTORY.createDEROctetString(new byte[20])); - Assert.assertEquals(SecurityIDs.ID_PKCS7_DATA, sut.getContentType()); - Assert.assertNotNull(sut.getContent()); + Assertions.assertEquals(OID.PKCS7_DATA, sut.getContentType()); + Assertions.assertNotNull(sut.getContent()); } } diff --git a/sign/src/test/java/com/itextpdf/signatures/cms/SignerInfoTest.java b/sign/src/test/java/com/itextpdf/signatures/cms/SignerInfoTest.java index eeaaf68f17..8e856d0500 100644 --- a/sign/src/test/java/com/itextpdf/signatures/cms/SignerInfoTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/cms/SignerInfoTest.java @@ -34,19 +34,13 @@ This file is part of the iText (R) project. import com.itextpdf.commons.bouncycastle.pkcs.AbstractPKCSException; import com.itextpdf.commons.utils.Base64; import com.itextpdf.commons.utils.MessageFormatUtil; +import com.itextpdf.kernel.crypto.OID; import com.itextpdf.kernel.exceptions.PdfException; -import com.itextpdf.signatures.SecurityIDs; import com.itextpdf.signatures.exceptions.SignExceptionMessageConstant; import com.itextpdf.signatures.testutils.PemFileHelper; import com.itextpdf.signatures.testutils.SignTestPortUtil; import com.itextpdf.signatures.testutils.builder.TestCrlBuilder; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.BouncyCastleUnitTest; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; import java.io.IOException; import java.nio.charset.StandardCharsets; @@ -62,8 +56,13 @@ This file is part of the iText (R) project. import java.util.Collections; import java.util.List; import java.util.Objects; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(BouncyCastleUnitTest.class) +@Tag("BouncyCastleUnitTest") public class SignerInfoTest extends ExtendedITextTest { private static final IBouncyCastleFactory FACTORY = BouncyCastleFactoryCreator.getFactory(); @@ -96,12 +95,12 @@ public class SignerInfoTest extends ExtendedITextTest { private X509Certificate signCert; private List testCrlResponse; - @BeforeClass + @BeforeAll public static void before() { Security.addProvider(FACTORY.getProvider()); } - @Before + @BeforeEach public void init() throws IOException, CertificateException, AbstractPKCSException, AbstractOperatorCreationException { signCert = chain.get(0); @@ -114,84 +113,84 @@ public void init() @Test public void testSignedAttributesReadonlyModeActivatedByGettingSerializedData() throws IOException, CertificateEncodingException { SignerInfo si = new SignerInfo(); - si.setSignatureAlgorithm(new AlgorithmIdentifier(SecurityIDs.ID_RSA)); + si.setSignatureAlgorithm(new AlgorithmIdentifier(OID.RSA)); si.setSigningCertificate(signCert); ArrayList fakeOcspREsponses = new ArrayList<>(); fakeOcspREsponses.add(Base64.decode(CMSTestHelper.BASE64_OCSP_RESPONSE)); si.setMessageDigest(new byte[1024]); si.setOcspResponses(fakeOcspREsponses); si.setCrlResponses(testCrlResponse); - si.setDigestAlgorithm(new AlgorithmIdentifier(SecurityIDs.ID_SHA512)); + si.setDigestAlgorithm(new AlgorithmIdentifier(OID.SHA_512)); si.serializeSignedAttributes(); - Assert.assertThrows(IllegalStateException.class, () -> si.setSerializedSignedAttributes(new byte[1235])); - Assert.assertThrows(IllegalStateException.class, + Assertions.assertThrows(IllegalStateException.class, () -> si.setSerializedSignedAttributes(new byte[1235])); + Assertions.assertThrows(IllegalStateException.class, () -> si.setCrlResponses(testCrlResponse)); - Assert.assertThrows(IllegalStateException.class, () -> si.setOcspResponses(fakeOcspREsponses)); - Assert.assertThrows(IllegalStateException.class, () -> si.setMessageDigest(new byte[1024])); + Assertions.assertThrows(IllegalStateException.class, () -> si.setOcspResponses(fakeOcspREsponses)); + Assertions.assertThrows(IllegalStateException.class, () -> si.setMessageDigest(new byte[1024])); CmsAttribute attribute = new CmsAttribute("", FACTORY.createASN1Integer(1)); - Assert.assertThrows(IllegalStateException.class, + Assertions.assertThrows(IllegalStateException.class, () -> si.addSignedAttribute(attribute)); - Assert.assertThrows(IllegalStateException.class, () -> - si.addSignerCertificateToSignedAttributes(signCert, SecurityIDs.ID_SHA512)); + Assertions.assertThrows(IllegalStateException.class, () -> + si.addSignerCertificateToSignedAttributes(signCert, OID.SHA_512)); } @Test public void testGetSerializedBasicSignedAttributes() throws IOException, CertificateEncodingException { SignerInfo si = new SignerInfo(); - si.setSignatureAlgorithm(new AlgorithmIdentifier(SecurityIDs.ID_RSASSA_PSS)); + si.setSignatureAlgorithm(new AlgorithmIdentifier(OID.RSASSA_PSS)); si.setSigningCertificate(signCert); si.setMessageDigest(MESSAGE_DIGEST); - si.setDigestAlgorithm(new AlgorithmIdentifier(SecurityIDs.ID_SHA512)); + si.setDigestAlgorithm(new AlgorithmIdentifier(OID.SHA_512)); byte[] serRes = si.serializeSignedAttributes(); - Assert.assertEquals(serializedAsString(EXPECTEDRESULT_1), serializedAsString(serRes)); + Assertions.assertEquals(serializedAsString(EXPECTEDRESULT_1), serializedAsString(serRes)); } @Test public void testGetSerializedExtendedSignedAttributes() throws IOException, CertificateEncodingException { SignerInfo si = new SignerInfo(); - si.setSignatureAlgorithm(new AlgorithmIdentifier(SecurityIDs.ID_RSASSA_PSS)); + si.setSignatureAlgorithm(new AlgorithmIdentifier(OID.RSASSA_PSS)); si.setSigningCertificate(signCert); ArrayList fakeOcspREsponses = new ArrayList<>(); fakeOcspREsponses.add(Base64.decode(CMSTestHelper.BASE64_OCSP_RESPONSE)); si.setOcspResponses(fakeOcspREsponses); si.setCrlResponses(testCrlResponse); si.setMessageDigest(new byte[1024]); - si.setDigestAlgorithm(new AlgorithmIdentifier(SecurityIDs.ID_SHA512)); + si.setDigestAlgorithm(new AlgorithmIdentifier(OID.SHA_512)); byte[] serRes = si.serializeSignedAttributes(); - Assert.assertEquals(serializedAsString(EXPECTEDRESULT_2), serializedAsString(serRes)); + Assertions.assertEquals(serializedAsString(EXPECTEDRESULT_2), serializedAsString(serRes)); } @Test public void testGetSerializedExtendedSignedAttributesCrlOnly() throws IOException, CertificateEncodingException { SignerInfo si = new SignerInfo(); - si.setSignatureAlgorithm(new AlgorithmIdentifier(SecurityIDs.ID_RSASSA_PSS)); + si.setSignatureAlgorithm(new AlgorithmIdentifier(OID.RSASSA_PSS)); si.setSigningCertificate(signCert); si.setCrlResponses(testCrlResponse); si.setMessageDigest(new byte[1024]); - si.setDigestAlgorithm(new AlgorithmIdentifier(SecurityIDs.ID_SHA512)); + si.setDigestAlgorithm(new AlgorithmIdentifier(OID.SHA_512)); byte[] serRes = si.serializeSignedAttributes(); - Assert.assertEquals(serializedAsString(EXPECTEDRESULT_5), serializedAsString(serRes)); + Assertions.assertEquals(serializedAsString(EXPECTEDRESULT_5), serializedAsString(serRes)); } @Test public void testAddSignedAttribute() { SignerInfo si = new SignerInfo(); - Assert.assertFalse(si.getSignedAttributes().stream().anyMatch(a -> - Objects.equals(a.getType(), SecurityIDs.ID_SIGNING_TIME))); - CmsAttribute attrib = new CmsAttribute(SecurityIDs.ID_SIGNING_TIME, FACTORY.createNullASN1Set()); + Assertions.assertFalse(si.getSignedAttributes().stream().anyMatch(a -> + Objects.equals(a.getType(), OID.SIGNING_TIME))); + CmsAttribute attrib = new CmsAttribute(OID.SIGNING_TIME, FACTORY.createNullASN1Set()); si.addSignedAttribute(attrib); - Assert.assertTrue(si.getSignedAttributes().stream().anyMatch(a -> - Objects.equals(a.getType(), SecurityIDs.ID_SIGNING_TIME))); + Assertions.assertTrue(si.getSignedAttributes().stream().anyMatch(a -> + Objects.equals(a.getType(), OID.SIGNING_TIME))); } @Test public void testAddUnsignedAttribute() { SignerInfo si = new SignerInfo(); - CmsAttribute attrib = new CmsAttribute(SecurityIDs.ID_SIGNING_TIME, FACTORY.createNullASN1Set()); + CmsAttribute attrib = new CmsAttribute(OID.SIGNING_TIME, FACTORY.createNullASN1Set()); si.addUnSignedAttribute(attrib); - Assert.assertEquals(SecurityIDs.ID_SIGNING_TIME, + Assertions.assertEquals(OID.SIGNING_TIME, SignTestPortUtil.getFirstElement(si.getUnSignedAttributes()).getType()); } @@ -199,25 +198,25 @@ public void testAddUnsignedAttribute() { public void testGetSerializedSignedAttributesWithCertificateId() throws CertificateEncodingException, NoSuchAlgorithmException, NoSuchProviderException, IOException { SignerInfo si = new SignerInfo(); - si.setSignatureAlgorithm(new AlgorithmIdentifier(SecurityIDs.ID_RSASSA_PSS)); + si.setSignatureAlgorithm(new AlgorithmIdentifier(OID.RSASSA_PSS)); si.setSigningCertificate(signCert); si.setMessageDigest(new byte[1024]); - si.setDigestAlgorithm(new AlgorithmIdentifier(SecurityIDs.ID_SHA512)); + si.setDigestAlgorithm(new AlgorithmIdentifier(OID.SHA_512)); si.addSignerCertificateToSignedAttributes(signCert, "2.16.840.1.101.3.4.2.3"); byte[] serRes = si.serializeSignedAttributes(); - Assert.assertEquals(serializedAsString(EXPECTEDRESULT_3), serializedAsString(serRes)); + Assertions.assertEquals(serializedAsString(EXPECTEDRESULT_3), serializedAsString(serRes)); } @Test public void testGetSerializedSignedAttributesWithCertificateIdTroughCertSetter() throws CertificateEncodingException, NoSuchAlgorithmException, NoSuchProviderException, IOException { SignerInfo si = new SignerInfo(); - si.setSignatureAlgorithm(new AlgorithmIdentifier(SecurityIDs.ID_RSASSA_PSS)); + si.setSignatureAlgorithm(new AlgorithmIdentifier(OID.RSASSA_PSS)); si.setSigningCertificateAndAddToSignedAttributes(signCert, "2.16.840.1.101.3.4.2.3"); si.setMessageDigest(new byte[1024]); - si.setDigestAlgorithm(new AlgorithmIdentifier(SecurityIDs.ID_SHA512)); + si.setDigestAlgorithm(new AlgorithmIdentifier(OID.SHA_512)); byte[] serRes = si.serializeSignedAttributes(); - Assert.assertEquals(serializedAsString(EXPECTEDRESULT_3), serializedAsString(serRes)); + Assertions.assertEquals(serializedAsString(EXPECTEDRESULT_3), serializedAsString(serRes)); } @Test @@ -225,16 +224,16 @@ public void testGetAsDerSequence() throws CertificateEncodingException, NoSuchAl NoSuchProviderException, IOException { SignerInfo si = new SignerInfo(); - si.addUnSignedAttribute(new CmsAttribute(SecurityIDs.ID_SIGNING_TIME, FACTORY. + si.addUnSignedAttribute(new CmsAttribute(OID.SIGNING_TIME, FACTORY. createDERSet(FACTORY.createASN1Integer(123456)))); si.setSigningCertificateAndAddToSignedAttributes(signCert, "2.16.840.1.101.3.4.2.3"); - si.setSignatureAlgorithm(new AlgorithmIdentifier(SecurityIDs.ID_RSASSA_PSS)); + si.setSignatureAlgorithm(new AlgorithmIdentifier(OID.RSASSA_PSS)); si.setMessageDigest(new byte[1024]); - si.setDigestAlgorithm(new AlgorithmIdentifier(SecurityIDs.ID_SHA512)); + si.setDigestAlgorithm(new AlgorithmIdentifier(OID.SHA_512)); si.setSignature(new byte[512]); IDERSequence res = si.getAsDerSequence(); - Assert.assertEquals(serializedAsString(EXPECTEDRESULT_4), + Assertions.assertEquals(serializedAsString(EXPECTEDRESULT_4), serializedAsString(res.getEncoded())); } @@ -243,18 +242,18 @@ public void testEstimatedSizeWithSignature() throws CertificateEncodingException NoSuchProviderException, IOException { SignerInfo si = new SignerInfo(); - si.addUnSignedAttribute(new CmsAttribute(SecurityIDs.ID_SIGNING_TIME, FACTORY. + si.addUnSignedAttribute(new CmsAttribute(OID.SIGNING_TIME, FACTORY. createDERSet(FACTORY.createASN1Integer(123456)))); - si.setSignatureAlgorithm(new AlgorithmIdentifier(SecurityIDs.ID_RSASSA_PSS)); + si.setSignatureAlgorithm(new AlgorithmIdentifier(OID.RSASSA_PSS)); si.setSigningCertificateAndAddToSignedAttributes(signCert, "2.16.840.1.101.3.4.2.3"); si.setMessageDigest(new byte[1024]); - si.setDigestAlgorithm(new AlgorithmIdentifier(SecurityIDs.ID_SHA512)); + si.setDigestAlgorithm(new AlgorithmIdentifier(OID.SHA_512)); si.setSignature(new byte[512]); long res = si.getEstimatedSize(); - Assert.assertEquals(1973, res); + Assertions.assertEquals(1973, res); } @Test @@ -262,21 +261,22 @@ public void testSignedAttributesSerializationRoundTrip() throws CertificateEncod NoSuchAlgorithmException, IOException, NoSuchProviderException { SignerInfo si = new SignerInfo(); - si.setSignatureAlgorithm(new AlgorithmIdentifier(SecurityIDs.ID_RSASSA_PSS)); + si.setSignatureAlgorithm(new AlgorithmIdentifier(OID.RSASSA_PSS)); si.setSigningCertificateAndAddToSignedAttributes(signCert, "2.16.840.1.101.3.4.2.3"); si.setMessageDigest(new byte[1024]); - si.setDigestAlgorithm(new AlgorithmIdentifier(SecurityIDs.ID_SHA512)); + si.setDigestAlgorithm(new AlgorithmIdentifier(OID.SHA_512)); si.setSignature(new byte[512]); byte[] serialized = si.serializeSignedAttributes(); SignerInfo si2 = new SignerInfo(); si2.setSerializedSignedAttributes(serialized); - Assert.assertEquals(si.getSignedAttributes().size(), si2.getSignedAttributes().size()); + Assertions.assertEquals(si.getSignedAttributes().size(), si2.getSignedAttributes().size()); for (CmsAttribute attribute : si.getSignedAttributes()) { - Assert.assertTrue(MessageFormatUtil.format("Expected to find an attribute with id {0} and value {1}", - attribute.getType(), attribute.getValue().toString()), si2.getSignedAttributes().stream() - .anyMatch(a -> a.getType().equals(attribute.getType()) && a.getValue().equals(attribute.getValue()))); + Assertions.assertTrue(si2.getSignedAttributes().stream().anyMatch( + a -> a.getType().equals(attribute.getType()) && a.getValue().equals(attribute.getValue())), + MessageFormatUtil.format("Expected to find an attribute with id {0} and value {1}", + attribute.getType(), attribute.getValue().toString())); } } @@ -285,16 +285,16 @@ public void testEstimatedSizeEstimatedSignature() throws CertificateEncodingExce NoSuchProviderException, IOException { SignerInfo si = new SignerInfo(); - si.addUnSignedAttribute(new CmsAttribute(SecurityIDs.ID_SIGNING_TIME, FACTORY. + si.addUnSignedAttribute(new CmsAttribute(OID.SIGNING_TIME, FACTORY. createDERSet(FACTORY.createASN1Integer(123456)))); - si.setSignatureAlgorithm(new AlgorithmIdentifier(SecurityIDs.ID_RSASSA_PSS)); + si.setSignatureAlgorithm(new AlgorithmIdentifier(OID.RSASSA_PSS)); si.setSigningCertificateAndAddToSignedAttributes(signCert, "2.16.840.1.101.3.4.2.3"); si.setMessageDigest(new byte[1024]); - si.setDigestAlgorithm(new AlgorithmIdentifier(SecurityIDs.ID_SHA512)); + si.setDigestAlgorithm(new AlgorithmIdentifier(OID.SHA_512)); long res = si.getEstimatedSize(); - Assert.assertEquals(2485, res); + Assertions.assertEquals(2485, res); } @Test @@ -302,18 +302,18 @@ public void testSerializeAndDeserializeSignerInfo() throws CertificateEncodingEx NoSuchProviderException, IOException { SignerInfo si = new SignerInfo(); - si.addUnSignedAttribute(new CmsAttribute(SecurityIDs.ID_SIGNING_TIME, FACTORY. + si.addUnSignedAttribute(new CmsAttribute(OID.SIGNING_TIME, FACTORY. createDERSet(FACTORY.createASN1Integer(123456)))); - si.setSignatureAlgorithm(new AlgorithmIdentifier(SecurityIDs.ID_RSASSA_PSS)); + si.setSignatureAlgorithm(new AlgorithmIdentifier(OID.RSASSA_PSS)); si.setSigningCertificateAndAddToSignedAttributes(signCert, "2.16.840.1.101.3.4.2.3"); si.setMessageDigest(new byte[1024]); - si.setDigestAlgorithm(new AlgorithmIdentifier(SecurityIDs.ID_SHA512)); + si.setDigestAlgorithm(new AlgorithmIdentifier(OID.SHA_512)); IDERSequence encoded = si.getAsDerSequence(false); SignerInfo si2 = new SignerInfo(encoded, Collections.singletonList(signCert)); - Assert.assertEquals(si.getSignedAttributes().size(), si2.getSignedAttributes().size()); + Assertions.assertEquals(si.getSignedAttributes().size(), si2.getSignedAttributes().size()); } @@ -322,7 +322,7 @@ public void testSerializeAndDeserializeSignedAttributes() throws CertificateEnco NoSuchAlgorithmException, NoSuchProviderException, IOException { SignerInfo si = new SignerInfo(); - si.addSignerCertificateToSignedAttributes(signCert, SecurityIDs.ID_SHA256); + si.addSignerCertificateToSignedAttributes(signCert, OID.SHA_256); si.setMessageDigest(new byte[20]); byte[] attribs = si.serializeSignedAttributes(); @@ -330,7 +330,7 @@ public void testSerializeAndDeserializeSignedAttributes() throws CertificateEnco SignerInfo si2 = new SignerInfo(); si2.setSerializedSignedAttributes(attribs); - Assert.assertEquals(si.getSignedAttributes().size(), si2.getSignedAttributes().size()); + Assertions.assertEquals(si.getSignedAttributes().size(), si2.getSignedAttributes().size()); } @Test @@ -338,16 +338,16 @@ public void testDeserializationMissingSignedAttributes() throws IOException { IASN1Encodable testData = FACTORY.createASN1Primitive( Base64.decode(CMSTestHelper.B64_ENCODED_NO_SIGNED_ATTRIBS)); SignerInfo si = new SignerInfo(testData, chain); - Assert.assertEquals(0, si.getSignedAttributes().size()); + Assertions.assertEquals(0, si.getSignedAttributes().size()); } @Test public void testMissingSignerCertificate() throws IOException { IASN1Encodable testData = FACTORY.createASN1Primitive( Base64.decode(CMSTestHelper.B64_ENCODED_NO_SIGNED_ATTRIBS)); - Exception e = Assert.assertThrows(PdfException.class, () -> + Exception e = Assertions.assertThrows(PdfException.class, () -> new SignerInfo(testData, chain.subList(1, chain.size() - 1))); - Assert.assertEquals(SignExceptionMessageConstant.CMS_CERTIFICATE_NOT_FOUND, e.getMessage()); + Assertions.assertEquals(SignExceptionMessageConstant.CMS_CERTIFICATE_NOT_FOUND, e.getMessage()); } @Test @@ -355,16 +355,16 @@ public void testSidWithSubjectKeyIdentifier() throws IOException { IASN1Encodable testData = FACTORY.createASN1Primitive( Base64.decode(CMSTestHelper.B64_ENCODED_SUBJECTKEY_IDENTIFIER)); SignerInfo si = new SignerInfo(testData, chain); - Assert.assertEquals(signCert.getSerialNumber(), si.getSigningCertificate().getSerialNumber()); + Assertions.assertEquals(signCert.getSerialNumber(), si.getSigningCertificate().getSerialNumber()); } @Test public void testMissingCertificateWithSubjectKeyIdentifier() throws IOException { IASN1Encodable testData = FACTORY.createASN1Primitive( Base64.decode(CMSTestHelper.B64_ENCODED_SUBJECTKEY_IDENTIFIER)); - Exception e = Assert.assertThrows(PdfException.class, () -> + Exception e = Assertions.assertThrows(PdfException.class, () -> new SignerInfo(testData, chain.subList(1, chain.size() - 1))); - Assert.assertEquals(SignExceptionMessageConstant.CMS_CERTIFICATE_NOT_FOUND, e.getMessage()); + Assertions.assertEquals(SignExceptionMessageConstant.CMS_CERTIFICATE_NOT_FOUND, e.getMessage()); } @Test @@ -374,9 +374,9 @@ public void testInvalidStructure() { //should be tagged with 0 v.add(FACTORY.createDERSequence(FACTORY.createASN1EncodableVector())); IASN1Encodable testData = FACTORY.createASN1Sequence(v); - Exception e = Assert.assertThrows(PdfException.class, () -> + Exception e = Assertions.assertThrows(PdfException.class, () -> new SignerInfo(testData, chain.subList(1, chain.size() - 1))); - Assert.assertEquals(SignExceptionMessageConstant.CMS_INVALID_CONTAINER_STRUCTURE, e.getMessage()); + Assertions.assertEquals(SignExceptionMessageConstant.CMS_INVALID_CONTAINER_STRUCTURE, e.getMessage()); } private String toUnixStringEnding(String in) { diff --git a/sign/src/test/java/com/itextpdf/signatures/mac/ReadSignedMacProtectedDocumentTest.java b/sign/src/test/java/com/itextpdf/signatures/mac/ReadSignedMacProtectedDocumentTest.java new file mode 100644 index 0000000000..7547799d3d --- /dev/null +++ b/sign/src/test/java/com/itextpdf/signatures/mac/ReadSignedMacProtectedDocumentTest.java @@ -0,0 +1,96 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.signatures.mac; + +import com.itextpdf.bouncycastleconnector.BouncyCastleFactoryCreator; +import com.itextpdf.commons.bouncycastle.IBouncyCastleFactory; +import com.itextpdf.commons.utils.FileUtil; +import com.itextpdf.kernel.exceptions.KernelExceptionMessageConstant; +import com.itextpdf.kernel.exceptions.PdfException; +import com.itextpdf.kernel.logs.KernelLogMessageConstant; +import com.itextpdf.kernel.pdf.PdfDocument; +import com.itextpdf.kernel.pdf.PdfReader; +import com.itextpdf.kernel.pdf.PdfWriter; +import com.itextpdf.kernel.pdf.ReaderProperties; +import com.itextpdf.kernel.pdf.StampingProperties; +import com.itextpdf.kernel.utils.CompareTool; +import com.itextpdf.test.ExtendedITextTest; +import com.itextpdf.test.annotations.LogMessage; +import com.itextpdf.test.annotations.LogMessages; + +import java.security.Security; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +@Tag("BouncyCastleIntegrationTest") +public class ReadSignedMacProtectedDocumentTest extends ExtendedITextTest { + private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/signatures/mac/ReadSignedMacProtectedDocumentTest/"; + private static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/signatures/mac/ReadSignedMacProtectedDocumentTest/"; + private static final byte[] ENCRYPTION_PASSWORD = "123".getBytes(); + + @BeforeAll + public static void before() { + Security.addProvider(BouncyCastleFactoryCreator.getFactory().getProvider()); + createOrClearDestinationFolder(DESTINATION_FOLDER); + } + + @Test + @LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT, + ignore = true)) + public void readSignedMacProtectedInvalidDocTest() { + String srcFileName = SOURCE_FOLDER + "signedMacProtectedInvalidDoc.pdf"; + + String exceptionMessage = Assertions.assertThrows(PdfException.class, () -> { + try (PdfDocument ignored = new PdfDocument( + new PdfReader(srcFileName, new ReaderProperties().setPassword(ENCRYPTION_PASSWORD)))) { + // Do nothing. + } + }).getMessage(); + Assertions.assertEquals(KernelExceptionMessageConstant.MAC_VALIDATION_FAILED, exceptionMessage); + } + + @Test + @LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT, + ignore = true)) + public void updateSignedMacProtectedDocumentTest() throws Exception { + String fileName = "updateSignedMacProtectedDocumentTest.pdf"; + String srcFileName = SOURCE_FOLDER + "thirdPartyMacProtectedAndSignedDocument.pdf"; + String outputFileName = DESTINATION_FOLDER + fileName; + String cmpFileName = SOURCE_FOLDER + "cmp_" + fileName; + + try (PdfDocument ignored = new PdfDocument( + new PdfReader(srcFileName, new ReaderProperties().setPassword(ENCRYPTION_PASSWORD)), + new PdfWriter(FileUtil.getFileOutputStream(outputFileName)), + new StampingProperties().useAppendMode())) { + // Do nothing. + } + + // This call produces INFO log from AESCipher caused by exception while decrypting. The reason is that, + // while comparing encrypted signed documents, CompareTool needs to mark signature value as unencrypted. + // Instead, it tries to decrypt not encrypted value which results in exception. + Assertions.assertNull(new CompareTool().compareByContent( + outputFileName, cmpFileName, DESTINATION_FOLDER, "diff", ENCRYPTION_PASSWORD, ENCRYPTION_PASSWORD)); + } +} diff --git a/sign/src/test/java/com/itextpdf/signatures/mac/SignedDocumentWithMacTest.java b/sign/src/test/java/com/itextpdf/signatures/mac/SignedDocumentWithMacTest.java new file mode 100644 index 0000000000..49e022d257 --- /dev/null +++ b/sign/src/test/java/com/itextpdf/signatures/mac/SignedDocumentWithMacTest.java @@ -0,0 +1,346 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.signatures.mac; + +import com.itextpdf.bouncycastleconnector.BouncyCastleFactoryCreator; +import com.itextpdf.commons.bouncycastle.IBouncyCastleFactory; +import com.itextpdf.commons.utils.FileUtil; +import com.itextpdf.kernel.crypto.CryptoUtil; +import com.itextpdf.kernel.crypto.DigestAlgorithms; +import com.itextpdf.kernel.exceptions.PdfException; +import com.itextpdf.kernel.logs.KernelLogMessageConstant; +import com.itextpdf.kernel.pdf.PdfName; +import com.itextpdf.kernel.pdf.PdfReader; +import com.itextpdf.kernel.pdf.ReaderProperties; +import com.itextpdf.kernel.pdf.StampingProperties; +import com.itextpdf.signatures.ExternalBlankSignatureContainer; +import com.itextpdf.signatures.PKCS7ExternalSignatureContainer; +import com.itextpdf.signatures.PdfSigner; +import com.itextpdf.signatures.PdfSigner.CryptoStandard; +import com.itextpdf.signatures.PrivateKeySignature; +import com.itextpdf.signatures.testutils.PemFileHelper; +import com.itextpdf.signatures.testutils.SignaturesCompareTool; +import com.itextpdf.signatures.testutils.client.TestTsaClient; +import com.itextpdf.test.ExtendedITextTest; +import com.itextpdf.test.annotations.LogMessage; +import com.itextpdf.test.annotations.LogMessages; + +import java.io.IOException; +import java.io.OutputStream; +import java.security.GeneralSecurityException; +import java.security.PrivateKey; +import java.security.Security; +import java.security.cert.Certificate; +import java.util.Arrays; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +@Tag("BouncyCastleIntegrationTest") +public class SignedDocumentWithMacTest extends ExtendedITextTest { + private static final IBouncyCastleFactory FACTORY = BouncyCastleFactoryCreator.getFactory(); + private static final String CERTS_SRC = "./src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/certs/"; + private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/"; + private static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/"; + private static final byte[] ENCRYPTION_PASSWORD = "123".getBytes(); + private static final char[] PRIVATE_KEY_PASSWORD = "testpassphrase".toCharArray(); + + @BeforeAll + public static void before() { + Security.addProvider(FACTORY.getProvider()); + createOrClearDestinationFolder(DESTINATION_FOLDER); + } + + public static Iterable createParameters() { + return Arrays.asList(new Object[] {"signCertRsa01.pem", "signDetached"}, + new Object[] {"tsaCert.pem", "timestamping"}, + new Object[] {"signCertRsa01.pem", "signExternalContainerReal"}, + new Object[] {"signCertRsa01.pem", "signExternalContainerBlank"}); + } + + @ParameterizedTest(name = "Signing operation: {1}") + @MethodSource("createParameters") + @LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT, + ignore = true)) + public void signMacProtectedDocTest(String certName, String signingOperation) throws Exception { + String fileName = "signMacProtectedDocTest_" + signingOperation + ".pdf"; + String srcFileName = SOURCE_FOLDER + "macEncryptedDoc.pdf"; + String outputFileName = DESTINATION_FOLDER + fileName; + String signCertFileName = CERTS_SRC + certName; + String cmpFileName = SOURCE_FOLDER + "cmp_" + fileName; + + Certificate[] signRsaChain = PemFileHelper.readFirstChain(signCertFileName); + PrivateKey signRsaPrivateKey = PemFileHelper.readFirstKey(signCertFileName, PRIVATE_KEY_PASSWORD); + + try (PdfReader reader = new PdfReader(srcFileName, new ReaderProperties().setPassword(ENCRYPTION_PASSWORD)); + OutputStream outputStream = FileUtil.getFileOutputStream(outputFileName)) { + PdfSigner pdfSigner = new PdfSigner(reader, outputStream, new StampingProperties()); + if (signingOperation.equals("signExternalContainerBlank")) { + Assertions.assertThrows(PdfException.class, + () -> performSigningOperation(signingOperation, pdfSigner, signRsaPrivateKey, signRsaChain)); + } else { + performSigningOperation(signingOperation, pdfSigner, signRsaPrivateKey, signRsaChain); + } + } + + if (!signingOperation.equals("signExternalContainerBlank")) { + ReaderProperties properties = new ReaderProperties().setPassword(ENCRYPTION_PASSWORD); + Assertions.assertNull( + SignaturesCompareTool.compareSignatures(outputFileName, cmpFileName, properties, properties)); + } + } + + @ParameterizedTest(name = "Signing operation: {1}") + @MethodSource("createParameters") + @LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT, + ignore = true)) + public void signNotMacProtectedDocTest(String certName, String signingOperation) throws Exception { + String fileName = "signNotMacProtectedDocTest_" + signingOperation + ".pdf"; + String srcFileName = SOURCE_FOLDER + "noMacProtectionDocument.pdf"; + String outputFileName = DESTINATION_FOLDER + fileName; + String signCertFileName = CERTS_SRC + certName; + String cmpFileName = SOURCE_FOLDER + "cmp_" + fileName; + + Certificate[] signRsaChain = PemFileHelper.readFirstChain(signCertFileName); + PrivateKey signRsaPrivateKey = PemFileHelper.readFirstKey(signCertFileName, PRIVATE_KEY_PASSWORD); + + try (PdfReader reader = new PdfReader(srcFileName, new ReaderProperties().setPassword(ENCRYPTION_PASSWORD)); + OutputStream outputStream = FileUtil.getFileOutputStream(outputFileName)) { + PdfSigner pdfSigner = new PdfSigner(reader, outputStream, new StampingProperties()); + if (signingOperation.equals("signExternalContainerBlank")) { + Assertions.assertThrows(PdfException.class, + () -> performSigningOperation(signingOperation, pdfSigner, signRsaPrivateKey, signRsaChain)); + } else { + performSigningOperation(signingOperation, pdfSigner, signRsaPrivateKey, signRsaChain); + } + } + + if (!signingOperation.equals("signExternalContainerBlank")) { + ReaderProperties properties = new ReaderProperties().setPassword(ENCRYPTION_PASSWORD); + Assertions.assertNull( + SignaturesCompareTool.compareSignatures(outputFileName, cmpFileName, properties, properties)); + } + } + + @ParameterizedTest(name = "Signing operation: {1}") + @MethodSource("createParameters") + @LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT, + ignore = true)) + public void signNotMacProtectedDoc17Test(String certName, String signingOperation) throws Exception { + String fileName = "signNotMacProtectedDoc17Test_" + signingOperation + ".pdf"; + String srcFileName = SOURCE_FOLDER + "noMacProtectionDocument_1_7.pdf"; + String outputFileName = DESTINATION_FOLDER + fileName; + String signCertFileName = CERTS_SRC + certName; + String cmpFileName = SOURCE_FOLDER + "cmp_" + fileName; + + Certificate[] signRsaChain = PemFileHelper.readFirstChain(signCertFileName); + PrivateKey signRsaPrivateKey = PemFileHelper.readFirstKey(signCertFileName, PRIVATE_KEY_PASSWORD); + + try (PdfReader reader = new PdfReader(srcFileName, new ReaderProperties().setPassword(ENCRYPTION_PASSWORD)); + OutputStream outputStream = FileUtil.getFileOutputStream(outputFileName)) { + PdfSigner pdfSigner = new PdfSigner(reader, outputStream, new StampingProperties()); + performSigningOperation(signingOperation, pdfSigner, signRsaPrivateKey, signRsaChain); + } + + // TODO DEVSIX-8637 Add else statement for empty signature container + if (!signingOperation.equals("signExternalContainerBlank")) { + ReaderProperties properties = new ReaderProperties().setPassword(ENCRYPTION_PASSWORD); + Assertions.assertNull( + SignaturesCompareTool.compareSignatures(outputFileName, cmpFileName, properties, properties)); + } + } + + @ParameterizedTest(name = "Signing operation: {1}") + @MethodSource("createParameters") + @LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT, + ignore = true)) + public void signNotMacProtectedDocInAppendModeTest(String certName, String signingOperation) throws Exception { + // MAC should not be added in append mode + String fileName = "signNotMacProtectedDocInAppendModeTest_" + signingOperation + ".pdf"; + String srcFileName = SOURCE_FOLDER + "noMacProtectionDocument.pdf"; + String outputFileName = DESTINATION_FOLDER + fileName; + String signCertFileName = CERTS_SRC + certName; + String cmpFileName = SOURCE_FOLDER + "cmp_" + fileName; + + Certificate[] signRsaChain = PemFileHelper.readFirstChain(signCertFileName); + PrivateKey signRsaPrivateKey = PemFileHelper.readFirstKey(signCertFileName, PRIVATE_KEY_PASSWORD); + + try (PdfReader reader = new PdfReader(srcFileName, new ReaderProperties().setPassword(ENCRYPTION_PASSWORD)); + OutputStream outputStream = FileUtil.getFileOutputStream(outputFileName)) { + PdfSigner pdfSigner = new PdfSigner(reader, outputStream, new StampingProperties().useAppendMode()); + performSigningOperation(signingOperation, pdfSigner, signRsaPrivateKey, signRsaChain); + } + + // TODO DEVSIX-8637 Add else statement for empty signature container + if (!signingOperation.equals("signExternalContainerBlank")) { + ReaderProperties properties = new ReaderProperties().setPassword(ENCRYPTION_PASSWORD); + Assertions.assertNull( + SignaturesCompareTool.compareSignatures(outputFileName, cmpFileName, properties, properties)); + } + } + + @ParameterizedTest(name = "Signing operation: {1}") + @MethodSource("createParameters") + @LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT, + ignore = true)) + public void signMacProtectedDocInAppendModeTest(String certName, String signingOperation) throws Exception { + String fileName = "signMacProtectedDocInAppendModeTest_" + signingOperation + ".pdf"; + String srcFileName = SOURCE_FOLDER + "macEncryptedDoc.pdf"; + String outputFileName = DESTINATION_FOLDER + fileName; + String signCertFileName = CERTS_SRC + certName; + String cmpFileName = SOURCE_FOLDER + "cmp_" + fileName; + + Certificate[] signRsaChain = PemFileHelper.readFirstChain(signCertFileName); + PrivateKey signRsaPrivateKey = PemFileHelper.readFirstKey(signCertFileName, PRIVATE_KEY_PASSWORD); + + try (PdfReader reader = new PdfReader(srcFileName, new ReaderProperties().setPassword(ENCRYPTION_PASSWORD)); + OutputStream outputStream = FileUtil.getFileOutputStream(outputFileName)) { + PdfSigner pdfSigner = new PdfSigner(reader, outputStream, new StampingProperties().useAppendMode()); + if (signingOperation.equals("signExternalContainerBlank")) { + Assertions.assertThrows(PdfException.class, + () -> performSigningOperation(signingOperation, pdfSigner, signRsaPrivateKey, signRsaChain)); + } else { + performSigningOperation(signingOperation, pdfSigner, signRsaPrivateKey, signRsaChain); + } + } + + if (!signingOperation.equals("signExternalContainerBlank")) { + ReaderProperties properties = new ReaderProperties().setPassword(ENCRYPTION_PASSWORD); + Assertions.assertNull( + SignaturesCompareTool.compareSignatures(outputFileName, cmpFileName, properties, properties)); + } + } + + @ParameterizedTest(name = "Signing operation: {1}") + @MethodSource("createParameters") + @LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT, + ignore = true)) + public void signMacProtectedDocWithSHA3_384Test(String certName, String signingOperation) throws Exception { + String fileName = "signMacProtectedDocWithSHA3_384Test_" + signingOperation + ".pdf"; + String srcFileName = SOURCE_FOLDER + "macEncryptedDocSHA3_384.pdf"; + String outputFileName = DESTINATION_FOLDER + fileName; + String signCertFileName = CERTS_SRC + certName; + String cmpFileName = SOURCE_FOLDER + "cmp_" + fileName; + + Certificate[] signRsaChain = PemFileHelper.readFirstChain(signCertFileName); + PrivateKey signRsaPrivateKey = PemFileHelper.readFirstKey(signCertFileName, PRIVATE_KEY_PASSWORD); + + try (PdfReader reader = new PdfReader(srcFileName, new ReaderProperties().setPassword(ENCRYPTION_PASSWORD)); + OutputStream outputStream = FileUtil.getFileOutputStream(outputFileName)) { + PdfSigner pdfSigner = new PdfSigner(reader, outputStream, new StampingProperties()); + if (signingOperation.equals("signExternalContainerBlank")) { + Assertions.assertThrows(PdfException.class, + () -> performSigningOperation(signingOperation, pdfSigner, signRsaPrivateKey, signRsaChain)); + } else { + performSigningOperation(signingOperation, pdfSigner, signRsaPrivateKey, signRsaChain); + } + } + + if (!signingOperation.equals("signExternalContainerBlank")) { + ReaderProperties properties = new ReaderProperties().setPassword(ENCRYPTION_PASSWORD); + Assertions.assertNull( + SignaturesCompareTool.compareSignatures(outputFileName, cmpFileName, properties, properties)); + } + } + + @ParameterizedTest(name = "Signing operation: {1}") + @MethodSource("createParameters") + @LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT, + ignore = true)) + public void signMacPublicEncryptionDocTest(String certName, String signingOperation) throws Exception { + try { + BouncyCastleFactoryCreator.getFactory().isEncryptionFeatureSupported(0, true); + } catch (Exception ignored) { + Assumptions.assumeTrue(false); + } + String fileName = "signMacPublicEncryptionDocTest_" + signingOperation + ".pdf"; + String srcFileName = SOURCE_FOLDER + "macEncryptedWithPublicHandlerDoc.pdf"; + String outputFileName = DESTINATION_FOLDER + fileName; + String signCertFileName = CERTS_SRC + certName; + String cmpFileName = SOURCE_FOLDER + "cmp_" + fileName; + + Certificate[] signRsaChain = PemFileHelper.readFirstChain(signCertFileName); + PrivateKey signRsaPrivateKey = PemFileHelper.readFirstKey(signCertFileName, PRIVATE_KEY_PASSWORD); + Certificate certificate = CryptoUtil.readPublicCertificate(FileUtil.getInputStreamForFile(CERTS_SRC + "SHA256withRSA.cer")); + PrivateKey privateKey = PemFileHelper.readFirstKey(CERTS_SRC + "SHA256withRSA.key", PRIVATE_KEY_PASSWORD); + ReaderProperties properties = new ReaderProperties().setPublicKeySecurityParams(certificate, privateKey, FACTORY.getProviderName(), null); + + try (PdfReader reader = new PdfReader(srcFileName, properties); + OutputStream outputStream = FileUtil.getFileOutputStream(outputFileName)) { + PdfSigner pdfSigner = new PdfSigner(reader, outputStream, new StampingProperties()); + if (signingOperation.equals("signExternalContainerBlank")) { + Assertions.assertThrows(PdfException.class, + () -> performSigningOperation(signingOperation, pdfSigner, signRsaPrivateKey, signRsaChain)); + } else { + performSigningOperation(signingOperation, pdfSigner, signRsaPrivateKey, signRsaChain); + } + } + + if (!signingOperation.equals("signExternalContainerBlank")) { + Assertions.assertNull( + SignaturesCompareTool.compareSignatures(outputFileName, cmpFileName, properties, properties)); + } + } + + private static void performSigningOperation(String signingOperation, PdfSigner pdfSigner, PrivateKey privateKey, Certificate[] chain) + throws Exception { + switch (signingOperation) { + case "signDetached": + performSignDetached(pdfSigner, privateKey, chain); + break; + case "timestamping": + performTimestamping(pdfSigner, privateKey, chain); + break; + case "signExternalContainerReal": + performSignExternalContainerReal(pdfSigner, privateKey, chain); + break; + case "signExternalContainerBlank": + performSignExternalContainerBlank(pdfSigner); + break; + } + } + + private static void performSignDetached(PdfSigner pdfSigner, PrivateKey privateKey, Certificate[] chain) throws Exception { + pdfSigner.signDetached( + new PrivateKeySignature(privateKey, DigestAlgorithms.SHA256, FACTORY.getProviderName()), + chain, null, null, null, 0, CryptoStandard.CADES); + } + + private static void performSignExternalContainerReal(PdfSigner pdfSigner, PrivateKey privateKey, Certificate[] chain) + throws GeneralSecurityException, IOException { + pdfSigner.signExternalContainer(new PKCS7ExternalSignatureContainer(privateKey, chain, "SHA-512"), 5000); + } + + private static void performSignExternalContainerBlank(PdfSigner pdfSigner) + throws GeneralSecurityException, IOException { + pdfSigner.signExternalContainer(new ExternalBlankSignatureContainer(PdfName.Adobe_PPKLite, PdfName.Adbe_pkcs7_detached), 5000); + } + + private static void performTimestamping(PdfSigner pdfSigner, PrivateKey privateKey, Certificate[] chain) + throws GeneralSecurityException, IOException { + pdfSigner.timestamp(new TestTsaClient(Arrays.asList(chain), privateKey), "timestamp1"); + } +} diff --git a/sign/src/test/java/com/itextpdf/signatures/sign/AnnotationsSigningTest.java b/sign/src/test/java/com/itextpdf/signatures/sign/AnnotationsSigningTest.java index d98f0bc401..2c1b6d96fd 100644 --- a/sign/src/test/java/com/itextpdf/signatures/sign/AnnotationsSigningTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/sign/AnnotationsSigningTest.java @@ -27,20 +27,22 @@ This file is part of the iText (R) project. import com.itextpdf.commons.bouncycastle.operator.AbstractOperatorCreationException; import com.itextpdf.commons.bouncycastle.pkcs.AbstractPKCSException; import com.itextpdf.commons.utils.FileUtil; +import com.itextpdf.forms.fields.properties.SignedAppearanceText; +import com.itextpdf.forms.form.element.SignatureFieldAppearance; +import com.itextpdf.kernel.crypto.DigestAlgorithms; import com.itextpdf.kernel.geom.Rectangle; import com.itextpdf.kernel.pdf.PdfReader; import com.itextpdf.kernel.pdf.StampingProperties; import com.itextpdf.kernel.utils.CompareTool; +import com.itextpdf.signatures.AccessPermissions; import com.itextpdf.signatures.BouncyCastleDigest; -import com.itextpdf.signatures.DigestAlgorithms; import com.itextpdf.signatures.IExternalSignature; -import com.itextpdf.signatures.PdfSignatureAppearance; import com.itextpdf.signatures.PdfSigner; import com.itextpdf.signatures.PrivateKeySignature; +import com.itextpdf.signatures.SignerProperties; import com.itextpdf.signatures.testutils.PemFileHelper; import com.itextpdf.signatures.testutils.SignaturesCompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.BouncyCastleIntegrationTest; import java.io.IOException; import java.security.GeneralSecurityException; @@ -52,13 +54,13 @@ This file is part of the iText (R) project. import java.util.HashMap; import java.util.List; import java.util.Map; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(BouncyCastleIntegrationTest.class) +@Tag("BouncyCastleIntegrationTest") public class AnnotationsSigningTest extends ExtendedITextTest { private static final IBouncyCastleFactory FACTORY = BouncyCastleFactoryCreator.getFactory(); @@ -72,13 +74,13 @@ public class AnnotationsSigningTest extends ExtendedITextTest { private Certificate[] chain; private PrivateKey pk; - @BeforeClass + @BeforeAll public static void before() { Security.addProvider(FACTORY.getProvider()); createOrClearDestinationFolder(DESTINATION_FOLDER); } - @Before + @BeforeEach public void init() throws IOException, CertificateException, AbstractPKCSException, AbstractOperatorCreationException { pk = PemFileHelper.readFirstKey(CERTS_SRC + "signCertRsa01.pem", PASSWORD); @@ -96,12 +98,12 @@ public void signingDocumentAppendModeIndirectPageAnnotsTest() String fieldName = "Signature1"; sign(srcFile, fieldName, outPdf, chain, pk, DigestAlgorithms.SHA256, PdfSigner.CryptoStandard.CADES, "Test 1", - "TestCity", rect, false, true, PdfSigner.NOT_CERTIFIED, 12f); + "TestCity", rect, false, true, AccessPermissions.UNSPECIFIED, 12f); - Assert.assertNull(new CompareTool().compareVisually(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_", + Assertions.assertNull(new CompareTool().compareVisually(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_", getTestMap(rect))); - Assert.assertNull(SignaturesCompareTool.compareSignatures(outPdf, cmpPdf)); + Assertions.assertNull(SignaturesCompareTool.compareSignatures(outPdf, cmpPdf)); } @Test @@ -114,12 +116,12 @@ public void signingIntoExistingFieldWithPKeyTest() String fieldName = "Signature1"; sign(srcFile, fieldName, outPdf, chain, pk, DigestAlgorithms.SHA256, PdfSigner.CryptoStandard.CADES, "Test 1", - "TestCity", null, false, false, PdfSigner.NOT_CERTIFIED, 12f); + "TestCity", null, false, false, AccessPermissions.UNSPECIFIED, 12f); - Assert.assertNull(new CompareTool().compareVisually(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_", + Assertions.assertNull(new CompareTool().compareVisually(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_", getTestMap(new Rectangle(41, 693, 237, 781)))); - Assert.assertNull(SignaturesCompareTool.compareSignatures(outPdf, cmpPdf)); + Assertions.assertNull(SignaturesCompareTool.compareSignatures(outPdf, cmpPdf)); } @Test @@ -132,12 +134,12 @@ public void signingIntoExistingFieldWithoutPKeyTest() String fieldName = "Signature1"; sign(srcFile, fieldName, outPdf, chain, pk, DigestAlgorithms.SHA256, PdfSigner.CryptoStandard.CADES, "Test 1", - "TestCity", null, false, false, PdfSigner.NOT_CERTIFIED, 12f); + "TestCity", null, false, false, AccessPermissions.UNSPECIFIED, 12f); - Assert.assertNull(new CompareTool().compareVisually(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_", + Assertions.assertNull(new CompareTool().compareVisually(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_", getTestMap(new Rectangle(41, 693, 237, 781)))); - Assert.assertNull(SignaturesCompareTool.compareSignatures(outPdf, cmpPdf)); + Assertions.assertNull(SignaturesCompareTool.compareSignatures(outPdf, cmpPdf)); } @Test @@ -151,7 +153,7 @@ public void signingIntoExistingReuseAppearanceTest() sign(srcFile, fieldName, outPdf, chain, pk, DigestAlgorithms.SHA256, PdfSigner.CryptoStandard.CADES, "Test 1", "TestCity", null, true, false); - Assert.assertNull(SignaturesCompareTool.compareSignatures(outPdf, cmpPdf)); + Assertions.assertNull(SignaturesCompareTool.compareSignatures(outPdf, cmpPdf)); } protected void sign(String src, String name, String dest, @@ -160,14 +162,14 @@ protected void sign(String src, String name, String dest, String reason, String location, Rectangle rectangleForNewField, boolean setReuseAppearance, boolean isAppendMode) throws GeneralSecurityException, IOException { sign(src, name, dest, chain, pk, digestAlgorithm, subfilter, reason, location, rectangleForNewField, - setReuseAppearance, isAppendMode, PdfSigner.NOT_CERTIFIED, null); + setReuseAppearance, isAppendMode, AccessPermissions.UNSPECIFIED, null); } protected void sign(String src, String name, String dest, Certificate[] chain, PrivateKey pk, String digestAlgorithm, PdfSigner.CryptoStandard subfilter, String reason, String location, Rectangle rectangleForNewField, boolean setReuseAppearance, - boolean isAppendMode, int certificationLevel, Float fontSize) + boolean isAppendMode, AccessPermissions certificationLevel, Float fontSize) throws GeneralSecurityException, IOException { PdfReader reader = new PdfReader(src); @@ -177,21 +179,25 @@ protected void sign(String src, String name, String dest, } PdfSigner signer = new PdfSigner(reader, FileUtil.getFileOutputStream(dest), properties); - signer.setCertificationLevel(certificationLevel); - signer.setFieldName(name); + SignerProperties signerProperties = new SignerProperties() + .setCertificationLevel(certificationLevel) + .setFieldName(name); // Creating the appearance - PdfSignatureAppearance appearance = signer.getSignatureAppearance(); - appearance.setReason(reason) + SignatureFieldAppearance appearance = new SignatureFieldAppearance(SignerProperties.IGNORED_ID) + .setContent(new SignedAppearanceText()); + signerProperties + .setReason(reason) .setLocation(location) - .setReuseAppearance(setReuseAppearance); - + .setSignatureAppearance(appearance); if (rectangleForNewField != null) { - signer.setPageRect(rectangleForNewField); + signerProperties.setPageRect(rectangleForNewField); } if (fontSize != null) { - appearance.setLayer2FontSize((float) fontSize); + appearance.setFontSize((float) fontSize); } + signer.setSignerProperties(signerProperties); + signer.getSignatureField().setReuseAppearance(setReuseAppearance); // Creating the signature IExternalSignature pks = new PrivateKeySignature(pk, digestAlgorithm, FACTORY.getProviderName()); diff --git a/sign/src/test/java/com/itextpdf/signatures/sign/CrlClientOnlineTest.java b/sign/src/test/java/com/itextpdf/signatures/sign/CrlClientOnlineTest.java index c10acb5892..ba45cb0cd2 100644 --- a/sign/src/test/java/com/itextpdf/signatures/sign/CrlClientOnlineTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/sign/CrlClientOnlineTest.java @@ -32,7 +32,6 @@ This file is part of the iText (R) project. import com.itextpdf.test.LogLevelConstants; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.BouncyCastleUnitTest; import java.io.ByteArrayInputStream; import java.io.IOException; @@ -44,11 +43,11 @@ This file is part of the iText (R) project. import java.security.cert.CertificateException; import java.security.cert.X509Certificate; import java.util.Collection; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(BouncyCastleUnitTest.class) +@Tag("BouncyCastleUnitTest") public class CrlClientOnlineTest extends ExtendedITextTest { private static final String certSrc = "./src/test/resources/com/itextpdf/signatures/sign/CrlClientOnlineTest/"; @@ -68,7 +67,7 @@ public void crlClientOnlineURLConstructorTest() throws MalformedURLException { }; CrlClientOnline crlClientOnline = new CrlClientOnline(urls); - Assert.assertEquals(2, crlClientOnline.getUrlsSize()); + Assertions.assertEquals(2, crlClientOnline.getUrlsSize()); } @Test @@ -77,7 +76,7 @@ public void crlClientOnlineURLConstructorTest() throws MalformedURLException { }) public void addCrlUrlTest() { CrlClientOnline crlClientOnline = new CrlClientOnline("https://examples.com"); - Assert.assertEquals(1, crlClientOnline.getUrlsSize()); + Assertions.assertEquals(1, crlClientOnline.getUrlsSize()); } @Test @@ -86,7 +85,7 @@ public void addCrlUrlTest() { }) public void addEmptyCrlUrlTest() { CrlClientOnline crlClientOnline = new CrlClientOnline(""); - Assert.assertEquals(0, crlClientOnline.getUrlsSize()); + Assertions.assertEquals(0, crlClientOnline.getUrlsSize()); } @Test @@ -95,7 +94,7 @@ public void addEmptyCrlUrlTest() { }) public void addWrongCrlUrlTest() { CrlClientOnline crlClientOnline = new CrlClientOnline("test"); - Assert.assertEquals(0, crlClientOnline.getUrlsSize()); + Assertions.assertEquals(0, crlClientOnline.getUrlsSize()); } @Test @@ -107,7 +106,7 @@ public void addWrongCrlUrlTest() { public void checkCrlCertWithMalformedUrlTest() throws CertificateException, IOException { Certificate chain = CryptoUtil.readPublicCertificate(FileUtil.getInputStreamForFile(certWithMalformedUrl)); CrlClientOnline crlClientOnline = new CrlClientOnline(new Certificate[] {chain}); - Assert.assertEquals(0, crlClientOnline.getUrlsSize()); + Assertions.assertEquals(0, crlClientOnline.getUrlsSize()); } @Test @@ -119,7 +118,7 @@ public void checkCrlCertWithMalformedUrlTest() throws CertificateException, IOEx public void checkCrlCertWithCorrectUrlTest() throws CertificateException, IOException { Certificate chain = CryptoUtil.readPublicCertificate(FileUtil.getInputStreamForFile(certWithCorrectUrl)); CrlClientOnline crlClientOnline = new CrlClientOnline(new Certificate[] {chain}); - Assert.assertEquals(1, crlClientOnline.getUrlsSize()); + Assertions.assertEquals(1, crlClientOnline.getUrlsSize()); } @Test @@ -131,14 +130,14 @@ public void checkCrlCertWithSeveralUrlsTest() throws CertificateException, IOExc // Root certificate with 1 CRL and leaf certificate with 3 CRLs in 3 Distribution Points. Certificate[] chain = PemFileHelper.readFirstChain(chainWithSeveralUrls); CrlClientOnline crlClientOnline = new CrlClientOnline(chain); - Assert.assertEquals(4, crlClientOnline.getUrlsSize()); + Assertions.assertEquals(4, crlClientOnline.getUrlsSize()); } @Test public void cannotGetEncodedWhenCertIsNullTest() throws CertificateEncodingException { CrlClientOnline crlClientOnline = new CrlClientOnline(); - Assert.assertNull(crlClientOnline.getEncoded(null, "")); - Assert.assertEquals(0, crlClientOnline.getUrlsSize()); + Assertions.assertNull(crlClientOnline.getEncoded(null, "")); + Assertions.assertEquals(0, crlClientOnline.getUrlsSize()); } @Test @@ -157,7 +156,7 @@ protected InputStream getCrlResponse(X509Certificate cert, URL url) { }; X509Certificate checkCert = (X509Certificate) PemFileHelper.readFirstChain(chainWithSeveralUrls)[1]; Collection bytes = crlClientOnline.getEncoded(checkCert, null); - Assert.assertEquals(3, bytes.size()); + Assertions.assertEquals(3, bytes.size()); } @Test @@ -173,8 +172,8 @@ public void unreachableCrlDistributionPointTest() throws CertificateEncodingExce CrlClientOnline crlClientOnline = new CrlClientOnline("http://www.example.com/crl/test.crl"); X509Certificate checkCert = new X509MockCertificate(); Collection bytes = crlClientOnline.getEncoded(checkCert, "http://www.example.com/crl/test.crl"); - Assert.assertTrue(bytes.isEmpty()); - Assert.assertEquals(1, crlClientOnline.getUrlsSize()); + Assertions.assertTrue(bytes.isEmpty()); + Assertions.assertEquals(1, crlClientOnline.getUrlsSize()); } @Test @@ -191,7 +190,7 @@ public void unreachableCrlDistributionPointFromCertChainTest() throws Certificat CrlClientOnline crlClientOnline = new CrlClientOnline(); X509Certificate checkCert = new X509MockCertificate(); Collection bytes = crlClientOnline.getEncoded(checkCert, "http://www.example.com/crl/test.crl"); - Assert.assertTrue(bytes.isEmpty()); - Assert.assertEquals(0, crlClientOnline.getUrlsSize()); + Assertions.assertTrue(bytes.isEmpty()); + Assertions.assertEquals(0, crlClientOnline.getUrlsSize()); } } diff --git a/sign/src/test/java/com/itextpdf/signatures/sign/EncryptedSigningTest.java b/sign/src/test/java/com/itextpdf/signatures/sign/EncryptedSigningTest.java index 167125f8d3..c4405d361e 100644 --- a/sign/src/test/java/com/itextpdf/signatures/sign/EncryptedSigningTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/sign/EncryptedSigningTest.java @@ -27,21 +27,21 @@ This file is part of the iText (R) project. import com.itextpdf.commons.bouncycastle.operator.AbstractOperatorCreationException; import com.itextpdf.commons.bouncycastle.pkcs.AbstractPKCSException; import com.itextpdf.commons.utils.FileUtil; +import com.itextpdf.kernel.crypto.DigestAlgorithms; import com.itextpdf.kernel.logs.KernelLogMessageConstant; import com.itextpdf.kernel.pdf.PdfReader; import com.itextpdf.kernel.pdf.ReaderProperties; import com.itextpdf.kernel.pdf.StampingProperties; import com.itextpdf.signatures.BouncyCastleDigest; -import com.itextpdf.signatures.DigestAlgorithms; import com.itextpdf.signatures.IExternalSignature; import com.itextpdf.signatures.PdfSigner; import com.itextpdf.signatures.PrivateKeySignature; +import com.itextpdf.signatures.SignerProperties; import com.itextpdf.signatures.testutils.PemFileHelper; import com.itextpdf.signatures.testutils.SignaturesCompareTool; import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.BouncyCastleIntegrationTest; import java.io.IOException; import java.security.GeneralSecurityException; @@ -49,13 +49,13 @@ This file is part of the iText (R) project. import java.security.Security; import java.security.cert.Certificate; import java.security.cert.CertificateException; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(BouncyCastleIntegrationTest.class) +@Tag("BouncyCastleIntegrationTest") public class EncryptedSigningTest extends ExtendedITextTest { private static final IBouncyCastleFactory FACTORY = BouncyCastleFactoryCreator.getFactory(); @@ -69,13 +69,13 @@ public class EncryptedSigningTest extends ExtendedITextTest { private Certificate[] chain; private PrivateKey pk; - @BeforeClass + @BeforeAll public static void before() { Security.addProvider(FACTORY.getProvider()); createOrClearDestinationFolder(DESTINATION_FOLDER); } - @Before + @BeforeEach public void init() throws IOException, CertificateException, AbstractPKCSException, AbstractOperatorCreationException { pk = PemFileHelper.readFirstKey(CERTS_SRC + "signCertRsa01.pem", PASSWORD); @@ -97,7 +97,8 @@ public void signEncryptedPdfTest() throws GeneralSecurityException, IOException PdfSigner signer = new PdfSigner(reader, FileUtil.getFileOutputStream(outPdf), new StampingProperties().useAppendMode()); - signer.setFieldName(fieldName); + SignerProperties signerProperties = new SignerProperties().setFieldName(fieldName); + signer.setSignerProperties(signerProperties); // Creating the signature IExternalSignature pks = new PrivateKeySignature(pk, DigestAlgorithms.SHA256, FACTORY.getProviderName()); @@ -106,7 +107,7 @@ public void signEncryptedPdfTest() throws GeneralSecurityException, IOException //Password to open out and cmp files are the same ReaderProperties properties = new ReaderProperties().setPassword(ownerPass); - Assert.assertNull(SignaturesCompareTool.compareSignatures(outPdf, cmpPdf, properties, properties)); + Assertions.assertNull(SignaturesCompareTool.compareSignatures(outPdf, cmpPdf, properties, properties)); } @Test @@ -132,7 +133,7 @@ public void signCertificateSecurityPdfTest() throws IOException, GeneralSecurity FACTORY.getProviderName(), null); //Public key to open out and cmp files are the same - Assert.assertNull(SignaturesCompareTool.compareSignatures(outPdf, cmpPdf, properties, properties)); + Assertions.assertNull(SignaturesCompareTool.compareSignatures(outPdf, cmpPdf, properties, properties)); } } } diff --git a/sign/src/test/java/com/itextpdf/signatures/sign/IsoSignatureExtensionsRoundtripTest.java b/sign/src/test/java/com/itextpdf/signatures/sign/IsoSignatureExtensionsRoundtripTest.java index 2bdee9d5bb..aba84bb8fa 100644 --- a/sign/src/test/java/com/itextpdf/signatures/sign/IsoSignatureExtensionsRoundtripTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/sign/IsoSignatureExtensionsRoundtripTest.java @@ -26,8 +26,12 @@ This file is part of the iText (R) project. import com.itextpdf.commons.bouncycastle.IBouncyCastleFactory; import com.itextpdf.commons.bouncycastle.cert.IX509CertificateHolder; import com.itextpdf.commons.utils.FileUtil; +import com.itextpdf.forms.form.element.SignatureFieldAppearance; +import com.itextpdf.kernel.crypto.DigestAlgorithms; +import com.itextpdf.kernel.crypto.OID; import com.itextpdf.kernel.exceptions.PdfException; import com.itextpdf.kernel.geom.Rectangle; +import com.itextpdf.kernel.logs.KernelLogMessageConstant; import com.itextpdf.kernel.pdf.PdfArray; import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.kernel.pdf.PdfDocument; @@ -35,19 +39,16 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfReader; import com.itextpdf.kernel.pdf.StampingProperties; import com.itextpdf.signatures.BouncyCastleDigest; -import com.itextpdf.signatures.DigestAlgorithms; import com.itextpdf.signatures.IExternalSignature; import com.itextpdf.signatures.PdfPKCS7; import com.itextpdf.signatures.PdfSigner; import com.itextpdf.signatures.PrivateKeySignature; -import com.itextpdf.signatures.SecurityIDs; import com.itextpdf.signatures.SignatureUtil; -import com.itextpdf.signatures.logs.SignLogMessageConstant; +import com.itextpdf.signatures.SignerProperties; import com.itextpdf.signatures.testutils.PemFileHelper; import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.BouncyCastleIntegrationTest; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -59,7 +60,6 @@ This file is part of the iText (R) project. import java.nio.file.Paths; import java.security.GeneralSecurityException; import java.security.KeyException; -import java.security.NoSuchAlgorithmException; import java.security.PrivateKey; import java.security.Security; import java.security.cert.Certificate; @@ -74,13 +74,13 @@ This file is part of the iText (R) project. import org.bouncycastle.asn1.edec.EdECObjectIdentifiers; import org.bouncycastle.asn1.nist.NISTObjectIdentifiers; import org.bouncycastle.asn1.x9.X9ObjectIdentifiers; -import org.junit.Assert; -import org.junit.Assume; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(BouncyCastleIntegrationTest.class) +@Tag("BouncyCastleIntegrationTest") public class IsoSignatureExtensionsRoundtripTest extends ExtendedITextTest { private static final IBouncyCastleFactory BOUNCY_CASTLE_FACTORY = BouncyCastleFactoryCreator.getFactory(); @@ -92,9 +92,9 @@ public class IsoSignatureExtensionsRoundtripTest extends ExtendedITextTest { private static final String SOURCE_FILE = SOURCE_FOLDER + "helloWorldDoc.pdf"; private static final String SIGNATURE_FIELD = "Signature"; - @BeforeClass + @BeforeAll public static void before() { - Assume.assumeFalse(BOUNCY_CASTLE_FACTORY.isInApprovedOnlyMode()); + Assumptions.assumeFalse(BOUNCY_CASTLE_FACTORY.isInApprovedOnlyMode()); Security.addProvider(BOUNCY_CASTLE_FACTORY.getProvider()); createOrClearDestinationFolder(DESTINATION_FOLDER); } @@ -106,13 +106,7 @@ public void testEd25519() throws Exception { @Test public void testEd448() throws Exception { - if ("BC".equals(BOUNCY_CASTLE_FACTORY.getProviderName())) { - doRoundTrip("ed448", DigestAlgorithms.SHAKE256, EdECObjectIdentifiers.id_Ed448); - } else { - // SHAKE256 is currently not supported in BCFIPS - Exception e = Assert.assertThrows(NoSuchAlgorithmException.class, () -> - doRoundTrip("ed448", DigestAlgorithms.SHAKE256, EdECObjectIdentifiers.id_Ed448)); - } + doRoundTrip("ed448", DigestAlgorithms.SHAKE256, EdECObjectIdentifiers.id_Ed448); } @Test @@ -121,28 +115,28 @@ public void testBrainpoolP384r1WithSha384() throws Exception { } @Test - @LogMessages(messages = @LogMessage(messageTemplate = SignLogMessageConstant.ALGORITHM_NOT_FROM_SPEC, count = 3), ignore = true) + @LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.ALGORITHM_NOT_FROM_SPEC, count = 3), ignore = true) public void testPlainBrainpoolP384r1WithSha384() throws Exception { if ("BC".equals(BOUNCY_CASTLE_FACTORY.getProviderName())) { doRoundTrip("plainBrainpoolP384r1", DigestAlgorithms.SHA384, "PLAIN-ECDSA", BSIObjectIdentifiers.ecdsa_plain_SHA384); } else { // PLAIN_ECDSA is currently not supported in BCFIPS - Assert.assertThrows(PdfException.class, + Assertions.assertThrows(PdfException.class, () -> doRoundTrip("plainBrainpoolP384r1", DigestAlgorithms.SHA384, "PLAIN-ECDSA", BSIObjectIdentifiers.ecdsa_plain_SHA384)); } } @Test - @LogMessages(messages = @LogMessage(messageTemplate = SignLogMessageConstant.ALGORITHM_NOT_FROM_SPEC, count = 3), ignore = true) + @LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.ALGORITHM_NOT_FROM_SPEC, count = 3), ignore = true) public void testCvcBrainpoolP384r1WithSha384() throws Exception { if ("BC".equals(BOUNCY_CASTLE_FACTORY.getProviderName())) { doRoundTrip("cvcBrainpoolP384r1", DigestAlgorithms.SHA384, "CVC-ECDSA", EACObjectIdentifiers.id_TA_ECDSA_SHA_384); } else { // CVC_ECDSA is currently not supported in BCFIPS - Assert.assertThrows(PdfException.class, + Assertions.assertThrows(PdfException.class, () -> doRoundTrip("cvcBrainpoolP384r1", DigestAlgorithms.SHA384, "CVC-ECDSA", EACObjectIdentifiers.id_TA_ECDSA_SHA_384)); } @@ -162,12 +156,12 @@ public void testNistP256WithSha3_256() throws Exception { public void testRsaWithSha3_512() throws Exception { // For now we use a generic OID, but NISTObjectIdentifiers.id_rsassa_pkcs1_v1_5_with_sha3_512 would // be more appropriate - doRoundTrip("rsa", DigestAlgorithms.SHA3_512, new ASN1ObjectIdentifier(SecurityIDs.ID_RSA_WITH_SHA3_512)); + doRoundTrip("rsa", DigestAlgorithms.SHA3_512, new ASN1ObjectIdentifier(OID.RSA_WITH_SHA3_512)); } @Test public void testRsaSsaPssWithSha3_256() throws Exception { - doRoundTrip("rsa", DigestAlgorithms.SHA3_256, "RSASSA-PSS", new ASN1ObjectIdentifier(SecurityIDs.ID_RSASSA_PSS)); + doRoundTrip("rsa", DigestAlgorithms.SHA3_256, "RSASSA-PSS", new ASN1ObjectIdentifier(OID.RSASSA_PSS)); } @Test @@ -177,10 +171,10 @@ public void testRsaWithSha3_256() throws Exception { @Test public void testEd25519ForceSha512WhenSigning() { - Exception e = Assert.assertThrows(PdfException.class, () -> + Exception e = Assertions.assertThrows(PdfException.class, () -> doSign("ed25519", DigestAlgorithms.SHA1, null, new ByteArrayOutputStream()) ); - Assert.assertEquals( + Assertions.assertEquals( "Ed25519 requires the document to be digested using SHA-512, not SHA1", e.getMessage() ); } @@ -188,15 +182,15 @@ public void testEd25519ForceSha512WhenSigning() { @Test public void testEd448ForceShake256WhenSigning() { if ("BC".equals(BOUNCY_CASTLE_FACTORY.getProviderName())) { - Exception e = Assert.assertThrows(PdfException.class, () -> + Exception e = Assertions.assertThrows(PdfException.class, () -> doSign("ed448", DigestAlgorithms.SHA1, null, new ByteArrayOutputStream()) ); - Assert.assertEquals( + Assertions.assertEquals( "Ed448 requires the document to be digested using 512-bit SHAKE256, not SHA1", e.getMessage() ); } else { // SHAKE256 is currently not supported in BCFIPS - Exception e = Assert.assertThrows(PdfException.class, () -> + Exception e = Assertions.assertThrows(PdfException.class, () -> doSign("ed448", DigestAlgorithms.SHA1, null, new ByteArrayOutputStream())); } } @@ -205,8 +199,8 @@ public void testEd448ForceShake256WhenSigning() { public void testEd25519ForceSha512WhenValidating() { // file contains an Ed25519 signature where the document digest is computed using SHA-1 String referenceFile = Paths.get(SOURCE_FOLDER, "bad-digest-ed25519.pdf").toString(); - Exception e = Assert.assertThrows(PdfException.class, () -> doVerify(referenceFile, null)); - Assert.assertEquals( + Exception e = Assertions.assertThrows(PdfException.class, () -> doVerify(referenceFile, null)); + Assertions.assertEquals( "Ed25519 requires the document to be digested using SHA-512, not SHA1", e.getCause().getCause().getMessage() ); @@ -216,8 +210,8 @@ public void testEd25519ForceSha512WhenValidating() { public void testEd448ForceShake256WhenValidating() { // file contains an Ed448 signature where the document digest is computed using SHA-1 String referenceFile = Paths.get(SOURCE_FOLDER, "bad-digest-ed448.pdf").toString(); - Exception e = Assert.assertThrows(PdfException.class, () -> doVerify(referenceFile, null)); - Assert.assertEquals( + Exception e = Assertions.assertThrows(PdfException.class, () -> doVerify(referenceFile, null)); + Assertions.assertEquals( "Ed448 requires the document to be digested using 512-bit SHAKE256, not SHA1", e.getCause().getCause().getMessage() ); @@ -240,14 +234,8 @@ public void testEd25519ExtensionDeclarations() throws Exception { @Test public void testEd448ExtensionDeclarations() throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); - if ("BC".equals(BOUNCY_CASTLE_FACTORY.getProviderName())) { - doSign("ed448", DigestAlgorithms.SHAKE256, null, baos); - checkIsoExtensions(baos.toByteArray(), Arrays.asList(32001, 32002)); - } else { - // SHAKE256 is currently not supported in BCFIPS - Exception e = Assert.assertThrows(NoSuchAlgorithmException.class, () -> - doSign("ed448", DigestAlgorithms.SHAKE256, null, baos)); - } + doSign("ed448", DigestAlgorithms.SHAKE256, null, baos); + checkIsoExtensions(baos.toByteArray(), Arrays.asList(32001, 32002)); } @Test @@ -271,7 +259,8 @@ public void testIsoExtensionsWithMultipleSignatures() throws Exception { ); PdfSigner signer = new PdfSigner(new PdfReader(in1), baos1, new StampingProperties()); - signer.setFieldName("Signature1"); + SignerProperties signerProperties = new SignerProperties().setFieldName("Signature1"); + signer.setSignerProperties(signerProperties); signer.signDetached( new BouncyCastleDigest(), pks, signChain1, null, null, null, 0, PdfSigner.CryptoStandard.CMS); @@ -284,7 +273,8 @@ public void testIsoExtensionsWithMultipleSignatures() throws Exception { ); PdfSigner signer = new PdfSigner(new PdfReader(in2), baos2, new StampingProperties()); - signer.setFieldName("Signature2"); + SignerProperties signerProperties = new SignerProperties().setFieldName("Signature2"); + signer.setSignerProperties(signerProperties); signer.signDetached( new BouncyCastleDigest(), pks, signChain2, null, null, null, 0, PdfSigner.CryptoStandard.CMS); @@ -322,12 +312,15 @@ private void doSign(String keySampleName, String digestAlgo, String signatureAlg IExternalSignature pks = new PrivateKeySignature(signPrivateKey, digestAlgo, signatureAlgo, BOUNCY_CASTLE_FACTORY.getProviderName(), null); PdfSigner signer = new PdfSigner(new PdfReader(SOURCE_FILE), os, new StampingProperties()); - signer.setFieldName(SIGNATURE_FIELD); - signer.getSignatureAppearance() + SignatureFieldAppearance appearance = new SignatureFieldAppearance(SignerProperties.IGNORED_ID) + .setContent("Approval test signature.\nCreated by iText."); + SignerProperties signerProperties = new SignerProperties() + .setFieldName(SIGNATURE_FIELD) .setPageRect(new Rectangle(50, 650, 200, 100)) .setReason("Test") .setLocation("TestCity") - .setLayer2Text("Approval test signature.\nCreated by iText."); + .setSignatureAppearance(appearance); + signer.setSignerProperties(signerProperties); signer.signDetached( new BouncyCastleDigest(), pks, signChain, null, null, null, 0, @@ -339,10 +332,10 @@ private void doVerify(String fileName, ASN1ObjectIdentifier expectedSigAlgoIdent try (PdfReader r = new PdfReader(fileName); PdfDocument pdfDoc = new PdfDocument(r)) { SignatureUtil u = new SignatureUtil(pdfDoc); PdfPKCS7 data = u.readSignatureData(SIGNATURE_FIELD, BOUNCY_CASTLE_FACTORY.getProviderName()); - Assert.assertTrue(data.verifySignatureIntegrityAndAuthenticity()); + Assertions.assertTrue(data.verifySignatureIntegrityAndAuthenticity()); if (expectedSigAlgoIdentifier != null) { ASN1ObjectIdentifier oid = new ASN1ObjectIdentifier(data.getSignatureMechanismOid()); - Assert.assertEquals(expectedSigAlgoIdentifier, oid); + Assertions.assertEquals(expectedSigAlgoIdentifier, oid); } } } @@ -356,7 +349,7 @@ private void checkIsoExtensions(byte[] fileData, Collection expectedLev .getPdfObject() .getAsDictionary(PdfName.Extensions) .getAsArray(PdfName.ISO_); - Assert.assertEquals(expectedLevels.size(), isoExtensions.size()); + Assertions.assertEquals(expectedLevels.size(), isoExtensions.size()); Set actualLevels = new HashSet<>(); for (int i = 0; i < isoExtensions.size(); i++) { @@ -365,7 +358,7 @@ private void checkIsoExtensions(byte[] fileData, Collection expectedLev } Set expectedLevelSet = new HashSet<>(expectedLevels); - Assert.assertEquals(expectedLevelSet, actualLevels); + Assertions.assertEquals(expectedLevelSet, actualLevels); } } diff --git a/sign/src/test/java/com/itextpdf/signatures/sign/LtvSigTest.java b/sign/src/test/java/com/itextpdf/signatures/sign/LtvSigTest.java index 3af9c9f155..e467f187a0 100644 --- a/sign/src/test/java/com/itextpdf/signatures/sign/LtvSigTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/sign/LtvSigTest.java @@ -27,6 +27,7 @@ This file is part of the iText (R) project. import com.itextpdf.commons.bouncycastle.operator.AbstractOperatorCreationException; import com.itextpdf.commons.bouncycastle.pkcs.AbstractPKCSException; import com.itextpdf.commons.utils.FileUtil; +import com.itextpdf.kernel.crypto.DigestAlgorithms; import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfName; @@ -34,12 +35,12 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfWriter; import com.itextpdf.kernel.pdf.StampingProperties; import com.itextpdf.signatures.BouncyCastleDigest; -import com.itextpdf.signatures.DigestAlgorithms; import com.itextpdf.signatures.ICrlClient; import com.itextpdf.signatures.IExternalSignature; import com.itextpdf.signatures.LtvVerification; import com.itextpdf.signatures.PdfSigner; import com.itextpdf.signatures.PrivateKeySignature; +import com.itextpdf.signatures.SignerProperties; import com.itextpdf.signatures.TestSignUtils; import com.itextpdf.signatures.testutils.PemFileHelper; import com.itextpdf.signatures.testutils.SignaturesCompareTool; @@ -47,7 +48,6 @@ This file is part of the iText (R) project. import com.itextpdf.signatures.testutils.client.TestOcspClient; import com.itextpdf.signatures.testutils.client.TestTsaClient; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.BouncyCastleIntegrationTest; import java.io.IOException; import java.security.GeneralSecurityException; @@ -59,12 +59,12 @@ This file is part of the iText (R) project. import java.util.Arrays; import java.util.Collection; import java.util.Collections; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(BouncyCastleIntegrationTest.class) +@Tag("BouncyCastleIntegrationTest") public class LtvSigTest extends ExtendedITextTest { private static final IBouncyCastleFactory FACTORY = BouncyCastleFactoryCreator.getFactory(); @@ -75,7 +75,7 @@ public class LtvSigTest extends ExtendedITextTest { private static final char[] PASSWORD = "testpassphrase".toCharArray(); - @BeforeClass + @BeforeAll public static void before() { Security.addProvider(FACTORY.getProvider()); createOrClearDestinationFolder(DESTINATION_FOLDER); @@ -109,7 +109,7 @@ public void ltvEnabledTest01() basicCheckLtvDoc("ltvEnabledTsTest01.pdf", "timestampSig1"); - Assert.assertNull( + Assertions.assertNull( SignaturesCompareTool.compareSignatures(ltvTsFileName, SOURCE_FOLDER + "cmp_ltvEnabledTsTest01.pdf")); } @@ -136,12 +136,12 @@ public Collection getEncoded(X509Certificate checkCert, String url) { PdfSigner signer = new PdfSigner(new PdfReader(srcFileName), FileUtil.getFileOutputStream(ltvFileName), new StampingProperties()); - signer.setFieldName("Signature1"); + signer.setSignerProperties(new SignerProperties().setFieldName("Signature1")); signer.signDetached(new BouncyCastleDigest(), pks, signChain, crlNotAvailableList, testOcspClient, testTsa, 0, PdfSigner.CryptoStandard.CADES); - Assert.assertNull(SignaturesCompareTool.compareSignatures( + Assertions.assertNull(SignaturesCompareTool.compareSignatures( ltvFileName, SOURCE_FOLDER + "cmp_ltvEnabledSingleSignatureNoCrlDataTest.pdf")); } @@ -162,11 +162,11 @@ public void ltvEnabledSingleSignatureNoOcspDataTest() PdfSigner signer = new PdfSigner(new PdfReader(srcFileName), FileUtil.getFileOutputStream(ltvFileName), new StampingProperties()); - signer.setFieldName("Signature1"); + signer.setSignerProperties(new SignerProperties().setFieldName("Signature1")); signer.signDetached(new BouncyCastleDigest(), pks, signChain, Collections.singletonList(testCrlClient), null, testTsa, 0, PdfSigner.CryptoStandard.CADES); - Assert.assertNull(SignaturesCompareTool.compareSignatures( + Assertions.assertNull(SignaturesCompareTool.compareSignatures( ltvFileName, SOURCE_FOLDER + "cmp_ltvEnabledSingleSignatureNoOcspDataTest.pdf")); } @@ -198,7 +198,7 @@ public void secondLtvOriginalHasNoVri01() basicCheckLtvDoc("secondLtvOriginalHasNoVriTs01.pdf", "timestampSig2"); - Assert.assertNull(SignaturesCompareTool.compareSignatures( + Assertions.assertNull(SignaturesCompareTool.compareSignatures( ltvTsFileName, SOURCE_FOLDER + "cmp_secondLtvOriginalHasNoVriTs01.pdf")); } @@ -243,8 +243,8 @@ private static TestTsaClient prepareTsaClient(String tsaCertP12FileName) private void basicCheckLtvDoc(String outFileName, String tsSigName) throws IOException, GeneralSecurityException { PdfDocument outDocument = new PdfDocument(new PdfReader(DESTINATION_FOLDER + outFileName)); PdfDictionary dssDict = outDocument.getCatalog().getPdfObject().getAsDictionary(PdfName.DSS); - Assert.assertNotNull(dssDict); - Assert.assertEquals(4, dssDict.size()); + Assertions.assertNotNull(dssDict); + Assertions.assertEquals(4, dssDict.size()); outDocument.close(); TestSignUtils.basicCheckSignedDoc(DESTINATION_FOLDER + outFileName, tsSigName); diff --git a/sign/src/test/java/com/itextpdf/signatures/sign/LtvWithTwoSignaturesTest.java b/sign/src/test/java/com/itextpdf/signatures/sign/LtvWithTwoSignaturesTest.java index 3d1e332546..b89e8c3e9c 100644 --- a/sign/src/test/java/com/itextpdf/signatures/sign/LtvWithTwoSignaturesTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/sign/LtvWithTwoSignaturesTest.java @@ -38,19 +38,18 @@ This file is part of the iText (R) project. import com.itextpdf.signatures.testutils.client.TestCrlClient; import com.itextpdf.signatures.testutils.client.TestOcspClient; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.BouncyCastleIntegrationTest; import java.security.GeneralSecurityException; import java.security.PrivateKey; import java.security.Security; import java.security.cert.X509Certificate; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(BouncyCastleIntegrationTest.class) +@Tag("BouncyCastleIntegrationTest") public class LtvWithTwoSignaturesTest extends ExtendedITextTest { private static final IBouncyCastleFactory FACTORY = BouncyCastleFactoryCreator.getFactory(); @@ -61,7 +60,7 @@ public class LtvWithTwoSignaturesTest extends ExtendedITextTest { private static final char[] password = "testpassphrase".toCharArray(); - @BeforeClass + @BeforeAll public static void before() { Security.addProvider(FACTORY.getProvider()); createOrClearDestinationFolder(destinationFolder); @@ -96,20 +95,20 @@ public void addLtvInfo() throws GeneralSecurityException, java.io.IOException, A PdfDictionary dssDictionary = catalogDictionary.getAsDictionary(PdfName.DSS); PdfDictionary vri = dssDictionary.getAsDictionary(PdfName.VRI); - Assert.assertNotNull(vri); - Assert.assertEquals(2, vri.size()); + Assertions.assertNotNull(vri); + Assertions.assertEquals(2, vri.size()); PdfArray ocsps = dssDictionary.getAsArray(PdfName.OCSPs); - Assert.assertNotNull(ocsps); - Assert.assertEquals(5, ocsps.size()); + Assertions.assertNotNull(ocsps); + Assertions.assertEquals(5, ocsps.size()); PdfArray certs = dssDictionary.getAsArray(PdfName.Certs); - Assert.assertNotNull(certs); - Assert.assertEquals(5, certs.size()); + Assertions.assertNotNull(certs); + Assertions.assertEquals(5, certs.size()); PdfArray crls = dssDictionary.getAsArray(PdfName.CRLs); - Assert.assertNotNull(crls); - Assert.assertEquals(2, crls.size()); + Assertions.assertNotNull(crls); + Assertions.assertEquals(2, crls.size()); } private void addLtvInfo(String src, String dest, String sigName, TestOcspClient testOcspClient, diff --git a/sign/src/test/java/com/itextpdf/signatures/sign/PadesSigTest.java b/sign/src/test/java/com/itextpdf/signatures/sign/PadesSigTest.java index 6ff43f7bcf..f75e1a8458 100644 --- a/sign/src/test/java/com/itextpdf/signatures/sign/PadesSigTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/sign/PadesSigTest.java @@ -32,32 +32,33 @@ This file is part of the iText (R) project. import com.itextpdf.commons.bouncycastle.operator.AbstractOperatorCreationException; import com.itextpdf.commons.bouncycastle.pkcs.AbstractPKCSException; import com.itextpdf.commons.utils.FileUtil; +import com.itextpdf.forms.form.element.SignatureFieldAppearance; +import com.itextpdf.kernel.crypto.DigestAlgorithms; import com.itextpdf.kernel.geom.Rectangle; import com.itextpdf.kernel.pdf.PdfReader; import com.itextpdf.kernel.pdf.StampingProperties; -import com.itextpdf.signatures.DigestAlgorithms; import com.itextpdf.signatures.IExternalSignature; import com.itextpdf.signatures.PdfSigner; import com.itextpdf.signatures.PrivateKeySignature; import com.itextpdf.signatures.SignaturePolicyInfo; +import com.itextpdf.signatures.SignerProperties; import com.itextpdf.signatures.TestSignUtils; import com.itextpdf.signatures.testutils.PemFileHelper; import com.itextpdf.signatures.testutils.SignaturesCompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.BouncyCastleIntegrationTest; import java.io.IOException; import java.security.GeneralSecurityException; import java.security.PrivateKey; import java.security.Security; import java.security.cert.Certificate; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(BouncyCastleIntegrationTest.class) +@Tag("BouncyCastleIntegrationTest") public class PadesSigTest extends ExtendedITextTest { private static final IBouncyCastleFactory FACTORY = BouncyCastleFactoryCreator.getFactory(); @@ -68,7 +69,7 @@ public class PadesSigTest extends ExtendedITextTest { private static final char[] password = "testpassphrase".toCharArray(); - @BeforeClass + @BeforeAll public static void before() { Security.addProvider(FACTORY.getProvider()); createOrClearDestinationFolder(destinationFolder); @@ -80,7 +81,7 @@ public void padesRsaSigTest01() signApproval(certsSrc + "signCertRsa01.pem", destinationFolder + "padesRsaSigTest01.pdf"); TestSignUtils.basicCheckSignedDoc(destinationFolder + "padesRsaSigTest01.pdf", "Signature1"); - Assert.assertNull(SignaturesCompareTool.compareSignatures(destinationFolder + Assertions.assertNull(SignaturesCompareTool.compareSignatures(destinationFolder + "padesRsaSigTest01.pdf", sourceFolder + "cmp_padesRsaSigTest01.pdf")); } @@ -90,12 +91,12 @@ public void padesRsaSigTestWithChain01() signApproval(certsSrc + "signCertRsaWithChain.pem", destinationFolder + "padesRsaSigTestWithChain01.pdf"); TestSignUtils.basicCheckSignedDoc(destinationFolder + "padesRsaSigTestWithChain01.pdf", "Signature1"); - Assert.assertNull(SignaturesCompareTool.compareSignatures(destinationFolder + Assertions.assertNull(SignaturesCompareTool.compareSignatures(destinationFolder + "padesRsaSigTestWithChain01.pdf", sourceFolder + "cmp_padesRsaSigTestWithChain01.pdf")); } @Test - @Ignore("DEVSIX-1620: For some reason signatures created with the given cert (either by iText or acrobat) are considered invalid") + @Disabled("DEVSIX-1620: For some reason signatures created with the given cert (either by iText or acrobat) are considered invalid") public void padesDsaSigTest01() throws IOException, GeneralSecurityException, AbstractPKCSException, AbstractOperatorCreationException { signApproval(certsSrc + "signCertDsa01.pem", destinationFolder + "padesDsaSigTest01.pdf"); @@ -108,7 +109,7 @@ public void padesEccSigTest01() destinationFolder + "padesEccSigTest01.pdf"); TestSignUtils.basicCheckSignedDoc(destinationFolder + "padesEccSigTest01.pdf", "Signature1"); - Assert.assertNull(SignaturesCompareTool.compareSignatures(destinationFolder + Assertions.assertNull(SignaturesCompareTool.compareSignatures(destinationFolder + "padesEccSigTest01.pdf", sourceFolder + "cmp_padesEccSigTest01.pdf")); } @@ -132,7 +133,7 @@ public void padesEpesProfileTest01() signApproval(certsSrc + "signCertRsa01.pem", destinationFolder + "padesEpesProfileTest01.pdf", sigPolicyIdentifier); TestSignUtils.basicCheckSignedDoc(destinationFolder + "padesEpesProfileTest01.pdf", "Signature1"); - Assert.assertNull(SignaturesCompareTool.compareSignatures(destinationFolder + + Assertions.assertNull(SignaturesCompareTool.compareSignatures(destinationFolder + "padesEpesProfileTest01.pdf", sourceFolder + "cmp_padesEpesProfileTest01.pdf")); } @@ -148,7 +149,7 @@ public void signaturePolicyInfoUnavailableUrlTest() signApproval(certsSrc + "signCertRsa01.pem", signedFileName, spi); TestSignUtils.basicCheckSignedDoc(signedFileName, "Signature1"); - Assert.assertNull(SignaturesCompareTool.compareSignatures(signedFileName, + Assertions.assertNull(SignaturesCompareTool.compareSignatures(signedFileName, sourceFolder + "cmp_signaturePolicyInfoUnavailableUrl_signed.pdf")); } @@ -177,13 +178,17 @@ private void signApproval(String signCertFileName, String outFileName, IExternalSignature pks = new PrivateKeySignature(signPrivateKey, DigestAlgorithms.SHA256, FACTORY.getProviderName()); - PdfSigner signer = new PdfSigner(new PdfReader(srcFileName), FileUtil.getFileOutputStream(outFileName), new StampingProperties()); - signer.setFieldName("Signature1"); - signer.getSignatureAppearance() + PdfSigner signer = new PdfSigner(new PdfReader(srcFileName), FileUtil.getFileOutputStream(outFileName), + new StampingProperties()); + SignerProperties signerProperties = new SignerProperties().setFieldName("Signature1"); + signer.setSignerProperties(signerProperties); + SignatureFieldAppearance appearance = new SignatureFieldAppearance(SignerProperties.IGNORED_ID) + .setContent("Approval test signature.\nCreated by iText."); + signerProperties .setPageRect(new Rectangle(50, 650, 200, 100)) .setReason("Test") .setLocation("TestCity") - .setLayer2Text("Approval test signature.\nCreated by iText."); + .setSignatureAppearance(appearance); if (sigPolicyIdentifier != null) { signer.signDetached(pks, signChain, null, null, null, 0, diff --git a/sign/src/test/java/com/itextpdf/signatures/sign/PadesSignatureLevelTest.java b/sign/src/test/java/com/itextpdf/signatures/sign/PadesSignatureLevelTest.java index f2bf33d38a..80cf9f3429 100644 --- a/sign/src/test/java/com/itextpdf/signatures/sign/PadesSignatureLevelTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/sign/PadesSignatureLevelTest.java @@ -27,18 +27,20 @@ This file is part of the iText (R) project. import com.itextpdf.commons.bouncycastle.operator.AbstractOperatorCreationException; import com.itextpdf.commons.bouncycastle.pkcs.AbstractPKCSException; import com.itextpdf.commons.utils.FileUtil; +import com.itextpdf.forms.form.element.SignatureFieldAppearance; +import com.itextpdf.kernel.crypto.DigestAlgorithms; import com.itextpdf.kernel.geom.Rectangle; import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfReader; import com.itextpdf.kernel.pdf.PdfWriter; import com.itextpdf.kernel.pdf.StampingProperties; import com.itextpdf.signatures.BouncyCastleDigest; -import com.itextpdf.signatures.DigestAlgorithms; import com.itextpdf.signatures.ICrlClient; import com.itextpdf.signatures.IExternalSignature; import com.itextpdf.signatures.LtvVerification; import com.itextpdf.signatures.PdfSigner; import com.itextpdf.signatures.PrivateKeySignature; +import com.itextpdf.signatures.SignerProperties; import com.itextpdf.signatures.TestSignUtils; import com.itextpdf.signatures.testutils.PemFileHelper; import com.itextpdf.signatures.testutils.SignaturesCompareTool; @@ -46,7 +48,6 @@ This file is part of the iText (R) project. import com.itextpdf.signatures.testutils.client.TestOcspClient; import com.itextpdf.signatures.testutils.client.TestTsaClient; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.BouncyCastleIntegrationTest; import java.io.IOException; import java.security.GeneralSecurityException; @@ -55,12 +56,12 @@ This file is part of the iText (R) project. import java.security.cert.Certificate; import java.security.cert.X509Certificate; import java.util.Arrays; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(BouncyCastleIntegrationTest.class) +@Tag("BouncyCastleIntegrationTest") public class PadesSignatureLevelTest extends ExtendedITextTest { private static final IBouncyCastleFactory FACTORY = BouncyCastleFactoryCreator.getFactory(); @@ -71,7 +72,7 @@ public class PadesSignatureLevelTest extends ExtendedITextTest { private static final char[] password = "testpassphrase".toCharArray(); - @BeforeClass + @BeforeAll public static void before() { Security.addProvider(FACTORY.getProvider()); createOrClearDestinationFolder(destinationFolder); @@ -94,13 +95,15 @@ public void padesSignatureLevelTTest01() PrivateKey tsaPrivateKey = PemFileHelper.readFirstKey(tsaCertFileName, password); PdfSigner signer = new PdfSigner(new PdfReader(srcFileName), FileUtil.getFileOutputStream(outFileName), new StampingProperties()); - signer.setFieldName("Signature1"); - signer.getSignatureAppearance() + SignatureFieldAppearance appearance = new SignatureFieldAppearance(SignerProperties.IGNORED_ID) + .setContent("Approval test signature.\nCreated by iText."); + SignerProperties signerProperties = new SignerProperties() + .setFieldName("Signature1") .setPageRect(new Rectangle(50, 650, 200, 100)) .setReason("Test") .setLocation("TestCity") - .setLayer2Text("Approval test signature.\nCreated by iText."); - + .setSignatureAppearance(appearance); + signer.setSignerProperties(signerProperties); TestTsaClient testTsa = new TestTsaClient(Arrays.asList(tsaChain), tsaPrivateKey); @@ -108,7 +111,7 @@ public void padesSignatureLevelTTest01() TestSignUtils.basicCheckSignedDoc(destinationFolder + "padesSignatureLevelTTest01.pdf", "Signature1"); - Assert.assertNull(SignaturesCompareTool.compareSignatures( + Assertions.assertNull(SignaturesCompareTool.compareSignatures( outFileName, sourceFolder + "cmp_padesSignatureLevelTTest01.pdf")); } @@ -131,7 +134,7 @@ public void padesSignatureLevelLTTest01() ltvVerification.merge(); document.close(); - Assert.assertNull(SignaturesCompareTool.compareSignatures( + Assertions.assertNull(SignaturesCompareTool.compareSignatures( outFileName, sourceFolder + "cmp_padesSignatureLevelLTTest01.pdf")); } @@ -150,7 +153,7 @@ public void padesSignatureLevelLTATest01() TestTsaClient testTsa = new TestTsaClient(Arrays.asList(tsaChain), tsaPrivateKey); signer.timestamp(testTsa, "timestampSig1"); - Assert.assertNull(SignaturesCompareTool.compareSignatures( + Assertions.assertNull(SignaturesCompareTool.compareSignatures( outFileName, sourceFolder + "cmp_padesSignatureLevelLTATest01.pdf")); } } diff --git a/sign/src/test/java/com/itextpdf/signatures/sign/PadesTwoPhaseSigningLevelsTest.java b/sign/src/test/java/com/itextpdf/signatures/sign/PadesTwoPhaseSigningLevelsTest.java index 885a390021..19299273e6 100644 --- a/sign/src/test/java/com/itextpdf/signatures/sign/PadesTwoPhaseSigningLevelsTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/sign/PadesTwoPhaseSigningLevelsTest.java @@ -26,9 +26,9 @@ This file is part of the iText (R) project. import com.itextpdf.commons.bouncycastle.IBouncyCastleFactory; import com.itextpdf.commons.utils.FileUtil; import com.itextpdf.forms.form.element.SignatureFieldAppearance; +import com.itextpdf.kernel.crypto.DigestAlgorithms; import com.itextpdf.kernel.geom.Rectangle; import com.itextpdf.kernel.pdf.PdfReader; -import com.itextpdf.signatures.DigestAlgorithms; import com.itextpdf.signatures.IExternalSignature; import com.itextpdf.signatures.PadesTwoPhaseSigningHelper; import com.itextpdf.signatures.PrivateKeySignature; @@ -41,27 +41,22 @@ This file is part of the iText (R) project. import com.itextpdf.signatures.testutils.client.TestOcspClient; import com.itextpdf.signatures.testutils.client.TestTsaClient; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.BouncyCastleIntegrationTest; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; -import java.security.NoSuchAlgorithmException; import java.security.PrivateKey; import java.security.Security; import java.security.cert.Certificate; import java.security.cert.X509Certificate; import java.util.Arrays; -import org.junit.Assert; -import org.junit.Assume; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; - -@RunWith(Parameterized.class) -@Category(BouncyCastleIntegrationTest.class) +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +@Tag("BouncyCastleIntegrationTest") public class PadesTwoPhaseSigningLevelsTest extends ExtendedITextTest { private static final IBouncyCastleFactory FACTORY = BouncyCastleFactoryCreator.getFactory(); private static final boolean FIPS_MODE = "BCFIPS".equals(FACTORY.getProviderName()); @@ -70,35 +65,20 @@ public class PadesTwoPhaseSigningLevelsTest extends ExtendedITextTest { private static final String sourceFolder = "./src/test/resources/com/itextpdf/signatures/sign/PadesTwoPhaseSigningLevelsTest/"; private static final String destinationFolder = "./target/test/com/itextpdf/signatures/sign/PadesTwoPhaseSigningLevelsTest/"; - private final Boolean useTempFolder; - private final Integer comparisonPdfId; - private final String digestAlgorithm; - private final String signAlgorithm; + private String signAlgorithm; private String signCertName; private String rootCertName; private static final char[] PASSWORD = "testpassphrase".toCharArray(); - @BeforeClass + @BeforeAll public static void before() { Security.addProvider(FACTORY.getProvider()); createOrClearDestinationFolder(destinationFolder); } - @Before - public void beforeTest() { - if ("ED448".equals(signAlgorithm)) { - Assume.assumeFalse(FACTORY.isInApprovedOnlyMode()); - } - } - - public PadesTwoPhaseSigningLevelsTest(Object useTempFolder, Object digestAlgorithm, - Object signAlgorithm, Object comparisonPdfId) { - this.useTempFolder = (Boolean) useTempFolder; - this.digestAlgorithm = (String) digestAlgorithm; - this.comparisonPdfId = (Integer) comparisonPdfId; - this.signAlgorithm = (String) signAlgorithm; - + public void setUp(String signAlgorithm) { + this.signAlgorithm = signAlgorithm; switch (this.signAlgorithm) { case "RSA": signCertName = "signCertRsa01.pem"; @@ -113,19 +93,25 @@ public PadesTwoPhaseSigningLevelsTest(Object useTempFolder, Object digestAlgorit rootCertName = "rootEd448.pem"; break; } + if ("ED448".equals(signAlgorithm)) { + Assumptions.assumeFalse(FACTORY.isInApprovedOnlyMode()); + } } - @Parameterized.Parameters(name = "{3}: folder path: {0}; digest algorithm: {1}; signature algorithm: {2}") public static Iterable createParameters() { - return Arrays.asList(new Object[] {true, DigestAlgorithms.SHA256, "RSA", 1}, + return Arrays.asList( + new Object[] {true, DigestAlgorithms.SHA256, "RSA", 1}, new Object[] {false, DigestAlgorithms.SHA256, "RSASSA", 2}, new Object[] {false, DigestAlgorithms.SHAKE256, "ED448", 3}, new Object[] {false, DigestAlgorithms.SHA3_384, "RSA", 4}); } - @Test + @ParameterizedTest(name = "{3}: folder path: {0}; digest algorithm: {1}; signature algorithm: {2}") + @MethodSource("createParameters") // Android-Conversion-Ignore-Test (TODO DEVSIX-8113 Fix signatures tests) - public void twoStepSigningBaselineBTest() throws Exception { + public void twoStepSigningBaselineBTest(Boolean useTempFolder, String digestAlgorithm, String signAlgorithm, + Integer comparisonPdfId) throws Exception { + setUp(signAlgorithm); String fileName = "twoStepSigningBaselineBTest" + comparisonPdfId + ".pdf"; String outFileName = destinationFolder + fileName; String cmpFileName = sourceFolder + "cmp_" + fileName; @@ -145,12 +131,6 @@ public void twoStepSigningBaselineBTest() throws Exception { } try (ByteArrayOutputStream preparedDoc = new ByteArrayOutputStream()) { - if (DigestAlgorithms.SHAKE256.equals(digestAlgorithm) && FIPS_MODE) { - Assert.assertThrows(NoSuchAlgorithmException.class, () -> - twoPhaseSigningHelper.createCMSContainerWithoutSignature(certChain, digestAlgorithm, - new PdfReader(srcFileName), preparedDoc, createSignerProperties())); - return; - } CMSContainer container = twoPhaseSigningHelper.createCMSContainerWithoutSignature(certChain, digestAlgorithm, new PdfReader(srcFileName), preparedDoc, createSignerProperties()); @@ -166,12 +146,15 @@ public void twoStepSigningBaselineBTest() throws Exception { FileUtil.getFileOutputStream(outFileName), "Signature1", container); } TestSignUtils.basicCheckSignedDoc(outFileName, "Signature1"); - Assert.assertNull(SignaturesCompareTool.compareSignatures(outFileName, cmpFileName)); + Assertions.assertNull(SignaturesCompareTool.compareSignatures(outFileName, cmpFileName)); } - @Test + @ParameterizedTest(name = "{3}: folder path: {0}; digest algorithm: {1}; signature algorithm: {2}") + @MethodSource("createParameters") // Android-Conversion-Ignore-Test (TODO DEVSIX-8113 Fix signatures tests) - public void twoStepSigningBaselineTTest() throws Exception { + public void twoStepSigningBaselineTTest(Boolean useTempFolder, String digestAlgorithm, String signAlgorithm, + Integer comparisonPdfId) throws Exception { + setUp(signAlgorithm); String fileName = "twoStepSigningBaselineTTest" + comparisonPdfId + ".pdf"; String outFileName = destinationFolder + fileName; String cmpFileName = sourceFolder + "cmp_" + fileName; @@ -197,12 +180,6 @@ public void twoStepSigningBaselineTTest() throws Exception { } try (ByteArrayOutputStream preparedDoc = new ByteArrayOutputStream()) { - if (DigestAlgorithms.SHAKE256.equals(digestAlgorithm) && FIPS_MODE) { - Assert.assertThrows(NoSuchAlgorithmException.class, () -> - twoPhaseSigningHelper.createCMSContainerWithoutSignature(certChain, digestAlgorithm, - new PdfReader(srcFileName), preparedDoc, createSignerProperties())); - return; - } CMSContainer container = twoPhaseSigningHelper.createCMSContainerWithoutSignature(certChain, digestAlgorithm, new PdfReader(srcFileName), preparedDoc, createSignerProperties()); @@ -217,13 +194,17 @@ public void twoStepSigningBaselineTTest() throws Exception { FileUtil.getFileOutputStream(outFileName), "Signature1", container); } TestSignUtils.basicCheckSignedDoc(outFileName, "Signature1"); - Assert.assertNull(SignaturesCompareTool.compareSignatures(outFileName, cmpFileName)); + Assertions.assertNull(SignaturesCompareTool.compareSignatures(outFileName, cmpFileName)); } - @Test + @ParameterizedTest(name = "{3}: folder path: {0}; digest algorithm: {1}; signature algorithm: {2}") + @MethodSource("createParameters") // Android-Conversion-Ignore-Test (TODO DEVSIX-8113 Fix signatures tests) - public void twoStepSigningBaselineLTTest() throws Exception { - String fileName = "twoStepSigningBaselineLTTest" + comparisonPdfId + (FIPS_MODE && "RSASSA".equals(signAlgorithm) ? "_FIPS.pdf" : ".pdf"); + public void twoStepSigningBaselineLTTest(Boolean useTempFolder, String digestAlgorithm, String signAlgorithm, + Integer comparisonPdfId) throws Exception { + setUp(signAlgorithm); + String fileName = "twoStepSigningBaselineLTTest" + comparisonPdfId + + (FIPS_MODE && ("RSASSA".equals(signAlgorithm) || "ED448".equals(signAlgorithm)) ? "_FIPS.pdf" : ".pdf"); String outFileName = destinationFolder + fileName; String cmpFileName = sourceFolder + "cmp_" + fileName; String srcFileName = sourceFolder + "helloWorldDoc.pdf"; @@ -256,12 +237,6 @@ public void twoStepSigningBaselineLTTest() throws Exception { } try (ByteArrayOutputStream preparedDoc = new ByteArrayOutputStream()) { - if (DigestAlgorithms.SHAKE256.equals(digestAlgorithm) && FIPS_MODE) { - Assert.assertThrows(NoSuchAlgorithmException.class, () -> - twoPhaseSigningHelper.createCMSContainerWithoutSignature(certChain, digestAlgorithm, - new PdfReader(srcFileName), preparedDoc, createSignerProperties())); - return; - } CMSContainer container = twoPhaseSigningHelper.createCMSContainerWithoutSignature(certChain, digestAlgorithm, new PdfReader(srcFileName), preparedDoc, createSignerProperties()); @@ -276,13 +251,17 @@ public void twoStepSigningBaselineLTTest() throws Exception { FileUtil.getFileOutputStream(outFileName), "Signature1", container); } TestSignUtils.basicCheckSignedDoc(outFileName, "Signature1"); - Assert.assertNull(SignaturesCompareTool.compareSignatures(outFileName, cmpFileName)); + Assertions.assertNull(SignaturesCompareTool.compareSignatures(outFileName, cmpFileName)); } - @Test + @ParameterizedTest(name = "{3}: folder path: {0}; digest algorithm: {1}; signature algorithm: {2}") + @MethodSource("createParameters") // Android-Conversion-Ignore-Test (TODO DEVSIX-8113 Fix signatures tests) - public void twoStepSigningBaselineLTATest() throws Exception { - String fileName = "twoStepSigningBaselineLTATest" + comparisonPdfId + (FIPS_MODE && "RSASSA".equals(signAlgorithm) ? "_FIPS.pdf" : ".pdf"); + public void twoStepSigningBaselineLTATest(Boolean useTempFolder, String digestAlgorithm, String signAlgorithm, + Integer comparisonPdfId) throws Exception { + setUp(signAlgorithm); + String fileName = "twoStepSigningBaselineLTATest" + comparisonPdfId + + (FIPS_MODE && ("RSASSA".equals(signAlgorithm) || "ED448".equals(signAlgorithm)) ? "_FIPS.pdf" : ".pdf"); String outFileName = destinationFolder + fileName; String cmpFileName = sourceFolder + "cmp_" + fileName; String srcFileName = sourceFolder + "helloWorldDoc.pdf"; @@ -315,12 +294,6 @@ public void twoStepSigningBaselineLTATest() throws Exception { } try (ByteArrayOutputStream preparedDoc = new ByteArrayOutputStream()) { - if (DigestAlgorithms.SHAKE256.equals(digestAlgorithm) && FIPS_MODE) { - Assert.assertThrows(NoSuchAlgorithmException.class, () -> - twoPhaseSigningHelper.createCMSContainerWithoutSignature(certChain, digestAlgorithm, - new PdfReader(srcFileName), preparedDoc, createSignerProperties())); - return; - } CMSContainer container = twoPhaseSigningHelper.createCMSContainerWithoutSignature(certChain, digestAlgorithm, new PdfReader(srcFileName), preparedDoc, createSignerProperties()); @@ -335,13 +308,13 @@ public void twoStepSigningBaselineLTATest() throws Exception { FileUtil.getFileOutputStream(outFileName), "Signature1", container); } TestSignUtils.basicCheckSignedDoc(outFileName, "Signature1"); - Assert.assertNull(SignaturesCompareTool.compareSignatures(outFileName, cmpFileName)); + Assertions.assertNull(SignaturesCompareTool.compareSignatures(outFileName, cmpFileName)); } private SignerProperties createSignerProperties() { SignerProperties signerProperties = new SignerProperties(); signerProperties.setFieldName("Signature1"); - SignatureFieldAppearance appearance = new SignatureFieldAppearance(signerProperties.getFieldName()) + SignatureFieldAppearance appearance = new SignatureFieldAppearance(SignerProperties.IGNORED_ID) .setContent("Approval test signature.\nCreated by iText."); signerProperties.setPageRect(new Rectangle(50, 650, 200, 100)) .setSignatureAppearance(appearance); diff --git a/sign/src/test/java/com/itextpdf/signatures/sign/PadesTwoPhaseSigningTest.java b/sign/src/test/java/com/itextpdf/signatures/sign/PadesTwoPhaseSigningTest.java index 06cdac7f96..1d804540c6 100644 --- a/sign/src/test/java/com/itextpdf/signatures/sign/PadesTwoPhaseSigningTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/sign/PadesTwoPhaseSigningTest.java @@ -27,10 +27,10 @@ This file is part of the iText (R) project. import com.itextpdf.commons.utils.FileUtil; import com.itextpdf.commons.utils.MessageFormatUtil; import com.itextpdf.forms.form.element.SignatureFieldAppearance; +import com.itextpdf.kernel.crypto.DigestAlgorithms; import com.itextpdf.kernel.exceptions.PdfException; import com.itextpdf.kernel.geom.Rectangle; import com.itextpdf.kernel.pdf.PdfReader; -import com.itextpdf.signatures.DigestAlgorithms; import com.itextpdf.signatures.PadesTwoPhaseSigningHelper; import com.itextpdf.signatures.PrivateKeySignature; import com.itextpdf.signatures.SignerProperties; @@ -41,7 +41,6 @@ This file is part of the iText (R) project. import com.itextpdf.signatures.testutils.client.TestOcspClient; import com.itextpdf.signatures.testutils.client.TestTsaClient; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.BouncyCastleIntegrationTest; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -50,12 +49,12 @@ This file is part of the iText (R) project. import java.security.cert.Certificate; import java.security.cert.X509Certificate; import java.util.Arrays; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(BouncyCastleIntegrationTest.class) +@Tag("BouncyCastleIntegrationTest") public class PadesTwoPhaseSigningTest extends ExtendedITextTest { private static final IBouncyCastleFactory FACTORY = BouncyCastleFactoryCreator.getFactory(); private static final String sourceFolder = "./src/test/resources/com/itextpdf/signatures/sign/PadesTwoPhaseSigningTest/"; @@ -63,7 +62,7 @@ public class PadesTwoPhaseSigningTest extends ExtendedITextTest { private static final String certsSrc = "./src/test/resources/com/itextpdf/signatures/certs/"; private static final char[] PASSWORD = "testpassphrase".toCharArray(); - @BeforeClass + @BeforeAll public static void before() { Security.addProvider(FACTORY.getProvider()); createOrClearDestinationFolder(destinationFolder); @@ -101,12 +100,12 @@ public void differentDigestAlgorithmsTest() throws Exception { CMSContainer container = twoPhaseSigningHelper.createCMSContainerWithoutSignature(certChain, DigestAlgorithms.SHA256, new PdfReader(srcFileName), preparedDoc, createSignerProperties()); - Exception exception = Assert.assertThrows(PdfException.class, () -> + Exception exception = Assertions.assertThrows(PdfException.class, () -> twoPhaseSigningHelper.signCMSContainerWithBaselineLTAProfile( new PrivateKeySignature(signPrivateKey, DigestAlgorithms.SHA512, FACTORY.getProviderName()), new PdfReader(new ByteArrayInputStream(preparedDoc.toByteArray())), FileUtil.getFileOutputStream(outFileName), "Signature1", container)); - Assert.assertEquals(MessageFormatUtil.format(SignExceptionMessageConstant.DIGEST_ALGORITHMS_ARE_NOT_SAME, + Assertions.assertEquals(MessageFormatUtil.format(SignExceptionMessageConstant.DIGEST_ALGORITHMS_ARE_NOT_SAME, "SHA256", "SHA512"), exception.getMessage()); } } @@ -139,19 +138,19 @@ public void missingTimestampClientTest() throws Exception { CMSContainer container = twoPhaseSigningHelper.createCMSContainerWithoutSignature(certChain, DigestAlgorithms.SHA256, new PdfReader(srcFileName), preparedDoc, createSignerProperties()); - Exception exception = Assert.assertThrows(PdfException.class, () -> + Exception exception = Assertions.assertThrows(PdfException.class, () -> twoPhaseSigningHelper.signCMSContainerWithBaselineLTAProfile( new PrivateKeySignature(signPrivateKey, DigestAlgorithms.SHA256, FACTORY.getProviderName()), new PdfReader(new ByteArrayInputStream(preparedDoc.toByteArray())), FileUtil.getFileOutputStream(outFileName), "Signature1", container)); - Assert.assertEquals(SignExceptionMessageConstant.TSA_CLIENT_IS_MISSING, exception.getMessage()); + Assertions.assertEquals(SignExceptionMessageConstant.TSA_CLIENT_IS_MISSING, exception.getMessage()); } } private SignerProperties createSignerProperties() { SignerProperties signerProperties = new SignerProperties(); signerProperties.setFieldName("Signature1"); - SignatureFieldAppearance appearance = new SignatureFieldAppearance(signerProperties.getFieldName()) + SignatureFieldAppearance appearance = new SignatureFieldAppearance(SignerProperties.IGNORED_ID) .setContent("Approval test signature.\nCreated by iText."); signerProperties.setPageRect(new Rectangle(50, 650, 200, 100)) .setSignatureAppearance(appearance); diff --git a/sign/src/test/java/com/itextpdf/signatures/sign/Pdf20SigningTest.java b/sign/src/test/java/com/itextpdf/signatures/sign/Pdf20SigningTest.java index 7ed3938d37..ba2ba79408 100644 --- a/sign/src/test/java/com/itextpdf/signatures/sign/Pdf20SigningTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/sign/Pdf20SigningTest.java @@ -27,6 +27,10 @@ This file is part of the iText (R) project. import com.itextpdf.commons.bouncycastle.operator.AbstractOperatorCreationException; import com.itextpdf.commons.bouncycastle.pkcs.AbstractPKCSException; import com.itextpdf.commons.utils.FileUtil; +import com.itextpdf.forms.fields.properties.SignedAppearanceText; +import com.itextpdf.forms.form.element.SignatureFieldAppearance; +import com.itextpdf.io.logs.IoLogMessageConstant; +import com.itextpdf.kernel.crypto.DigestAlgorithms; import com.itextpdf.kernel.exceptions.PdfException; import com.itextpdf.kernel.geom.Rectangle; import com.itextpdf.kernel.pdf.PdfDocument; @@ -36,17 +40,18 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfWriter; import com.itextpdf.kernel.pdf.StampingProperties; import com.itextpdf.kernel.utils.CompareTool; +import com.itextpdf.signatures.AccessPermissions; import com.itextpdf.signatures.BouncyCastleDigest; -import com.itextpdf.signatures.DigestAlgorithms; import com.itextpdf.signatures.IExternalSignature; -import com.itextpdf.signatures.PdfSignatureAppearance; import com.itextpdf.signatures.PdfSigner; import com.itextpdf.signatures.PrivateKeySignature; +import com.itextpdf.signatures.SignerProperties; import com.itextpdf.signatures.exceptions.SignExceptionMessageConstant; import com.itextpdf.signatures.testutils.PemFileHelper; import com.itextpdf.signatures.testutils.SignaturesCompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.BouncyCastleIntegrationTest; +import com.itextpdf.test.annotations.LogMessage; +import com.itextpdf.test.annotations.LogMessages; import java.io.IOException; import java.security.GeneralSecurityException; @@ -59,13 +64,13 @@ This file is part of the iText (R) project. import java.util.HashMap; import java.util.List; import java.util.Map; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(BouncyCastleIntegrationTest.class) +@Tag("BouncyCastleIntegrationTest") public class Pdf20SigningTest extends ExtendedITextTest { private static final IBouncyCastleFactory FACTORY = BouncyCastleFactoryCreator.getFactory(); @@ -79,13 +84,13 @@ public class Pdf20SigningTest extends ExtendedITextTest { private Certificate[] chain; private PrivateKey pk; - @BeforeClass + @BeforeAll public static void before() { Security.addProvider(FACTORY.getProvider()); createOrClearDestinationFolder(DESTINATION_FOLDER); } - @Before + @BeforeEach public void init() throws IOException, CertificateException, AbstractPKCSException, AbstractOperatorCreationException { pk = PemFileHelper.readFirstKey(KEYSTORE_PATH, PASSWORD); @@ -100,16 +105,19 @@ public void signExistingFieldWhenDirectAcroformAndNoSigFlagTest() throws General String fieldName = "Signature1"; sign(srcFile, fieldName, outPdf, chain, pk, DigestAlgorithms.SHA256, PdfSigner.CryptoStandard.CADES, - PdfSigner.NOT_CERTIFIED); + AccessPermissions.UNSPECIFIED); PdfDocument doc = new PdfDocument(new PdfReader(outPdf)); PdfNumber sigFlag = doc.getCatalog().getPdfObject().getAsDictionary(PdfName.AcroForm) .getAsNumber(PdfName.SigFlags); - Assert.assertEquals(new PdfNumber(3).intValue(), sigFlag.intValue()); + Assertions.assertEquals(new PdfNumber(3).intValue(), sigFlag.intValue()); } @Test + @LogMessages(messages = { + @LogMessage(messageTemplate = IoLogMessageConstant.EXISTING_TAG_STRUCTURE_ROOT_IS_NOT_STANDARD) + }) public void signPdf2CertificationAfterApprovalTest() { String srcFile = SOURCE_FOLDER + "approvalSignedDocPdf2.pdf"; String outPdf = DESTINATION_FOLDER + "signedPdf2CertificationAfterApproval.pdf"; @@ -118,11 +126,11 @@ public void signPdf2CertificationAfterApprovalTest() { String fieldName = "Signature2"; - Exception e = Assert.assertThrows(PdfException.class, + Exception e = Assertions.assertThrows(PdfException.class, () -> sign(srcFile, fieldName, outPdf, chain, pk, DigestAlgorithms.RIPEMD160, PdfSigner.CryptoStandard.CADES, "Test 1", "TestCity", rect, false, true, - PdfSigner.CERTIFIED_NO_CHANGES_ALLOWED, null)); - Assert.assertEquals( + AccessPermissions.NO_CHANGES_PERMITTED, null)); + Assertions.assertEquals( SignExceptionMessageConstant.CERTIFICATION_SIGNATURE_CREATION_FAILED_DOC_SHALL_NOT_CONTAIN_SIGS, e.getMessage()); } @@ -156,7 +164,7 @@ public void signedTwicePdf2Test() throws GeneralSecurityException, IOException { list.add(rectangle2); map.put(1, list); - Assert.assertNull(SignaturesCompareTool.compareSignatures(outPdfFileThree, cmpPdfFileThree)); + Assertions.assertNull(SignaturesCompareTool.compareSignatures(outPdfFileThree, cmpPdfFileThree)); } @Test @@ -169,12 +177,12 @@ public void signPdf2CmsTest() throws GeneralSecurityException, IOException, Inte String fieldName = "Signature1"; sign(srcFile, fieldName, outPdf, chain, pk, DigestAlgorithms.SHA256, PdfSigner.CryptoStandard.CMS, "Test 1", - "TestCity", rect, false, true, PdfSigner.NOT_CERTIFIED, 12f); + "TestCity", rect, false, true, AccessPermissions.UNSPECIFIED, 12f); - Assert.assertNull(new CompareTool().compareVisually(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_", + Assertions.assertNull(new CompareTool().compareVisually(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_", getTestMap(rect))); - Assert.assertNull(SignaturesCompareTool.compareSignatures(outPdf, cmpPdf)); + Assertions.assertNull(SignaturesCompareTool.compareSignatures(outPdf, cmpPdf)); } @Test @@ -186,17 +194,17 @@ public void signPdf2CadesTest() throws GeneralSecurityException, IOException, In Rectangle rect = new Rectangle(30, 200, 200, 100); String fieldName = "Signature1"; - sign(srcFile, fieldName, outPdf, chain, pk, DigestAlgorithms.SHA256, - PdfSigner.CryptoStandard.CADES, "Test 1", "TestCity", rect, false, true, PdfSigner.NOT_CERTIFIED, 12f); + sign(srcFile, fieldName, outPdf, chain, pk, DigestAlgorithms.SHA256, PdfSigner.CryptoStandard.CADES, + "Test 1", "TestCity", rect, false, true, AccessPermissions.UNSPECIFIED, 12f); - Assert.assertNull(new CompareTool().compareVisually(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_", + Assertions.assertNull(new CompareTool().compareVisually(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_", getTestMap(rect))); - Assert.assertNull(SignaturesCompareTool.compareSignatures(outPdf, cmpPdf)); + Assertions.assertNull(SignaturesCompareTool.compareSignatures(outPdf, cmpPdf)); } protected void sign(String src, String name, String dest, Certificate[] chain, PrivateKey pk, - String digestAlgorithm, PdfSigner.CryptoStandard subfilter, int certificationLevel) + String digestAlgorithm, PdfSigner.CryptoStandard subfilter, AccessPermissions certificationLevel) throws GeneralSecurityException, IOException { PdfReader reader = new PdfReader(src); @@ -205,9 +213,10 @@ protected void sign(String src, String name, String dest, Certificate[] chain, P properties.useAppendMode(); PdfSigner signer = new PdfSigner(reader, FileUtil.getFileOutputStream(dest), properties); - signer.setCertificationLevel(certificationLevel); - - signer.setFieldName(name); + SignerProperties signerProperties = new SignerProperties() + .setCertificationLevel(certificationLevel) + .setFieldName(name); + signer.setSignerProperties(signerProperties); // Creating the signature IExternalSignature pks = new PrivateKeySignature(pk, digestAlgorithm, FACTORY.getProviderName()); signer.signDetached(new BouncyCastleDigest(), pks, chain, null, null, null, @@ -218,7 +227,7 @@ protected void sign(String src, String name, String dest, Certificate[] chain, PrivateKey pk, String digestAlgorithm, PdfSigner.CryptoStandard subfilter, String reason, String location, Rectangle rectangleForNewField, boolean setReuseAppearance, - boolean isAppendMode, int certificationLevel, Float fontSize) + boolean isAppendMode, AccessPermissions certificationLevel, Float fontSize) throws GeneralSecurityException, IOException { PdfReader reader = new PdfReader(src); @@ -228,21 +237,23 @@ protected void sign(String src, String name, String dest, } PdfSigner signer = new PdfSigner(reader, FileUtil.getFileOutputStream(dest), properties); - signer.setCertificationLevel(certificationLevel); - signer.setFieldName(name); - - // Creating the appearance - PdfSignatureAppearance appearance = signer.getSignatureAppearance() + SignerProperties signerProperties = new SignerProperties() + .setCertificationLevel(certificationLevel) + .setFieldName(name) .setReason(reason) - .setLocation(location) - .setReuseAppearance(setReuseAppearance); + .setLocation(location); + // Creating the appearance + SignatureFieldAppearance appearance = new SignatureFieldAppearance(SignerProperties.IGNORED_ID) + .setContent(new SignedAppearanceText()); if (rectangleForNewField != null) { - signer.setPageRect(rectangleForNewField); + signerProperties.setPageRect(rectangleForNewField); } if (fontSize != null) { - appearance.setLayer2FontSize((float) fontSize); + appearance.setFontSize((float) fontSize); } + signer.setSignerProperties(signerProperties); + signer.getSignatureField().setReuseAppearance(setReuseAppearance); // Creating the signature IExternalSignature pks = new PrivateKeySignature(pk, digestAlgorithm, FACTORY.getProviderName()); signer.signDetached(new BouncyCastleDigest(), pks, chain, null, null, null, 0, subfilter); @@ -254,7 +265,7 @@ protected void sign(String src, String name, String dest, String reason, String location, Rectangle rectangleForNewField, boolean setReuseAppearance, boolean isAppendMode) throws GeneralSecurityException, IOException { sign(src, name, dest, chain, pk, digestAlgorithm, subfilter, reason, location, rectangleForNewField, - setReuseAppearance, isAppendMode, PdfSigner.NOT_CERTIFIED, null); + setReuseAppearance, isAppendMode, AccessPermissions.UNSPECIFIED, null); } private static Map> getTestMap(Rectangle ignoredArea) { diff --git a/sign/src/test/java/com/itextpdf/signatures/sign/PdfASigningTest.java b/sign/src/test/java/com/itextpdf/signatures/sign/PdfASigningTest.java index 72e6141232..4ea27db795 100644 --- a/sign/src/test/java/com/itextpdf/signatures/sign/PdfASigningTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/sign/PdfASigningTest.java @@ -29,6 +29,9 @@ This file is part of the iText (R) project. import com.itextpdf.commons.utils.FileUtil; import com.itextpdf.commons.utils.MessageFormatUtil; import com.itextpdf.forms.PdfSigFieldLock; +import com.itextpdf.forms.fields.properties.SignedAppearanceText; +import com.itextpdf.forms.form.element.SignatureFieldAppearance; +import com.itextpdf.kernel.crypto.DigestAlgorithms; import com.itextpdf.kernel.font.PdfFont; import com.itextpdf.kernel.font.PdfFontFactory; import com.itextpdf.kernel.font.PdfFontFactory.EmbeddingStrategy; @@ -38,16 +41,15 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.utils.CompareTool; import com.itextpdf.pdfa.exceptions.PdfAConformanceException; import com.itextpdf.pdfa.exceptions.PdfaExceptionMessageConstant; +import com.itextpdf.signatures.AccessPermissions; import com.itextpdf.signatures.BouncyCastleDigest; -import com.itextpdf.signatures.DigestAlgorithms; import com.itextpdf.signatures.IExternalSignature; -import com.itextpdf.signatures.PdfSignatureAppearance; import com.itextpdf.signatures.PdfSigner; import com.itextpdf.signatures.PrivateKeySignature; +import com.itextpdf.signatures.SignerProperties; import com.itextpdf.signatures.testutils.PemFileHelper; import com.itextpdf.signatures.testutils.SignaturesCompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.BouncyCastleIntegrationTest; import com.itextpdf.test.pdfa.VeraPdfValidator; // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) import java.io.IOException; @@ -60,13 +62,13 @@ This file is part of the iText (R) project. import java.util.HashMap; import java.util.List; import java.util.Map; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(BouncyCastleIntegrationTest.class) +@Tag("BouncyCastleIntegrationTest") public class PdfASigningTest extends ExtendedITextTest { private static final IBouncyCastleFactory FACTORY = BouncyCastleFactoryCreator.getFactory(); @@ -80,13 +82,13 @@ public class PdfASigningTest extends ExtendedITextTest { private Certificate[] chain; private PrivateKey pk; - @BeforeClass + @BeforeAll public static void before() { Security.addProvider(FACTORY.getProvider()); createOrClearDestinationFolder(destinationFolder); } - @Before + @BeforeEach public void init() throws IOException, CertificateException, AbstractPKCSException, AbstractOperatorCreationException { pk = PemFileHelper.readFirstKey(keystorePath, password); @@ -107,11 +109,12 @@ public void simpleSigningTest() throws GeneralSecurityException, IOException, In String fieldName = "Signature1"; sign(src, fieldName, dest, chain, pk, - DigestAlgorithms.SHA256, PdfSigner.CryptoStandard.CADES, "Test 1", "TestCity", rect, false, false, PdfSigner.NOT_CERTIFIED, 12f); + DigestAlgorithms.SHA256, PdfSigner.CryptoStandard.CADES, "Test 1", "TestCity", rect, false, false, + AccessPermissions.UNSPECIFIED, 12f); - Assert.assertNull(new VeraPdfValidator().validate(dest)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) - Assert.assertNull(SignaturesCompareTool.compareSignatures(dest, sourceFolder + "cmp_" + fileName)); - Assert.assertNull(new CompareTool().compareVisually(dest, sourceFolder + "cmp_" + fileName, destinationFolder, + Assertions.assertNull(new VeraPdfValidator().validate(dest)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNull(SignaturesCompareTool.compareSignatures(dest, sourceFolder + "cmp_" + fileName)); + Assertions.assertNull(new CompareTool().compareVisually(dest, sourceFolder + "cmp_" + fileName, destinationFolder, "diff_", getTestMap(new Rectangle(27, 550, 195, 40)))); } @@ -122,14 +125,16 @@ public void signingPdfA2DocumentTest() throws IOException, GeneralSecurityExcept PdfReader reader = new PdfReader(FileUtil.getInputStreamForFile(src)); PdfSigner signer = new PdfSigner(reader, FileUtil.getFileOutputStream(out), new StampingProperties()); - signer.setFieldLockDict(new PdfSigFieldLock()); - signer.setCertificationLevel(PdfSigner.CERTIFIED_NO_CHANGES_ALLOWED); + SignerProperties signerProperties = new SignerProperties() + .setFieldLockDict(new PdfSigFieldLock()) + .setCertificationLevel(AccessPermissions.NO_CHANGES_PERMITTED); + signer.setSignerProperties(signerProperties); IExternalSignature pks = new PrivateKeySignature(pk, DigestAlgorithms.SHA256, FACTORY.getProviderName()); signer.signDetached(new BouncyCastleDigest(), pks, chain, null, null, null, 0, PdfSigner.CryptoStandard.CADES); - Assert.assertNull(new VeraPdfValidator().validate(out)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNull(new VeraPdfValidator().validate(out)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) } @Test @@ -142,10 +147,10 @@ public void signPdf2CmsTest() { String fieldName = "Signature1"; - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> sign(srcFile, fieldName, outPdf, chain, pk, DigestAlgorithms.SHA256, PdfSigner.CryptoStandard.CMS, "Test 1", - "TestCity", rect, false, true, PdfSigner.NOT_CERTIFIED, 12f)); - Assert.assertEquals(PdfaExceptionMessageConstant.SIGNATURE_SHALL_CONFORM_TO_ONE_OF_THE_PADES_PROFILE, e.getMessage()); + "TestCity", rect, false, true, AccessPermissions.UNSPECIFIED, 12f)); + Assertions.assertEquals(PdfaExceptionMessageConstant.SIGNATURE_SHALL_CONFORM_TO_ONE_OF_THE_PADES_PROFILE, e.getMessage()); } @Test @@ -157,14 +162,14 @@ public void signPdf2CadesTest() throws GeneralSecurityException, IOException, In Rectangle rect = new Rectangle(30, 200, 200, 100); String fieldName = "Signature1"; - sign(srcFile, fieldName, outPdf, chain, pk, DigestAlgorithms.SHA256, - PdfSigner.CryptoStandard.CADES, "Test 1", "TestCity", rect, false, true, PdfSigner.NOT_CERTIFIED, 12f); + sign(srcFile, fieldName, outPdf, chain, pk, DigestAlgorithms.SHA256, PdfSigner.CryptoStandard.CADES, + "Test 1", "TestCity", rect, false, true, AccessPermissions.UNSPECIFIED, 12f); - Assert.assertNull(new CompareTool().compareVisually(outPdf, cmpPdf, destinationFolder, "diff_", + Assertions.assertNull(new CompareTool().compareVisually(outPdf, cmpPdf, destinationFolder, "diff_", getTestMap(rect))); - Assert.assertNull(SignaturesCompareTool.compareSignatures(outPdf, cmpPdf)); - Assert.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNull(SignaturesCompareTool.compareSignatures(outPdf, cmpPdf)); + Assertions.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) } @Test @@ -174,8 +179,10 @@ public void failedSigningPdfA2DocumentTest() throws IOException { PdfReader reader = new PdfReader(FileUtil.getInputStreamForFile(src)); PdfSigner signer = new PdfSigner(reader, FileUtil.getFileOutputStream(out), new StampingProperties()); - signer.setFieldLockDict(new PdfSigFieldLock()); - signer.setCertificationLevel(PdfSigner.NOT_CERTIFIED); + SignerProperties signerProperties = new SignerProperties() + .setFieldLockDict(new PdfSigFieldLock()) + .setCertificationLevel(AccessPermissions.UNSPECIFIED); + signer.setSignerProperties(signerProperties); int x = 36; int y = 548; @@ -185,33 +192,39 @@ public void failedSigningPdfA2DocumentTest() throws IOException { PdfFont font = PdfFontFactory.createFont("Helvetica","WinAnsi", EmbeddingStrategy.PREFER_EMBEDDED); - signer.setPageRect(rect) - .getSignatureAppearance() + SignatureFieldAppearance appearance = new SignatureFieldAppearance(SignerProperties.IGNORED_ID) + .setContent(new SignedAppearanceText()) + .setFont(font); + signerProperties + .setPageRect(rect) .setReason("pdfA test") .setLocation("TestCity") - .setLayer2Font(font) - .setReuseAppearance(false); + .setSignatureAppearance(appearance); + signer + .getSignatureField().setReuseAppearance(false); IExternalSignature pks = new PrivateKeySignature(pk, DigestAlgorithms.SHA256, FACTORY.getProviderName()); - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> signer.signDetached(new BouncyCastleDigest(), pks, chain, null, null, null, 0, PdfSigner.CryptoStandard.CADES)); - Assert.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.ALL_THE_FONTS_MUST_BE_EMBEDDED_THIS_ONE_IS_NOT_0, + Assertions.assertEquals(MessageFormatUtil.format(PdfaExceptionMessageConstant.ALL_THE_FONTS_MUST_BE_EMBEDDED_THIS_ONE_IS_NOT_0, "Helvetica"), e.getMessage()); } - protected void sign(String src, String name, String dest, - Certificate[] chain, PrivateKey pk, - String digestAlgorithm, PdfSigner.CryptoStandard subfilter, - String reason, String location, Rectangle rectangleForNewField, boolean setReuseAppearance, boolean isAppendMode) throws GeneralSecurityException, IOException { - sign(src, name, dest, chain, pk, digestAlgorithm, subfilter, reason, location, rectangleForNewField, setReuseAppearance, isAppendMode, PdfSigner.NOT_CERTIFIED, null); + protected void sign(String src, String name, String dest, Certificate[] chain, PrivateKey pk, + String digestAlgorithm, PdfSigner.CryptoStandard subfilter, String reason, String location, + Rectangle rectangleForNewField, boolean setReuseAppearance, boolean isAppendMode) + throws GeneralSecurityException, IOException { + sign(src, name, dest, chain, pk, digestAlgorithm, subfilter, reason, location, rectangleForNewField, + setReuseAppearance, isAppendMode, AccessPermissions.UNSPECIFIED, null); } protected void sign(String src, String name, String dest, Certificate[] chain, PrivateKey pk, String digestAlgorithm, PdfSigner.CryptoStandard subfilter, - String reason, String location, Rectangle rectangleForNewField, boolean setReuseAppearance, boolean isAppendMode, int certificationLevel, Float fontSize) + String reason, String location, Rectangle rectangleForNewField, boolean setReuseAppearance, + boolean isAppendMode, AccessPermissions certificationLevel, Float fontSize) throws GeneralSecurityException, IOException { PdfReader reader = new PdfReader(src); @@ -220,25 +233,28 @@ protected void sign(String src, String name, String dest, properties.useAppendMode(); } PdfSigner signer = new PdfSigner(reader, FileUtil.getFileOutputStream(dest), properties); - - signer.setCertificationLevel(certificationLevel); + SignerProperties signerProperties = new SignerProperties() + .setCertificationLevel(certificationLevel) + .setFieldName(name); + signer.setSignerProperties(signerProperties); PdfFont font = PdfFontFactory.createFont(FONT, "WinAnsi", EmbeddingStrategy.PREFER_EMBEDDED); - signer.setFieldName(name); // Creating the appearance - PdfSignatureAppearance appearance = signer.getSignatureAppearance() + SignatureFieldAppearance appearance = new SignatureFieldAppearance(SignerProperties.IGNORED_ID) + .setContent(new SignedAppearanceText()); + appearance.setFont(font); + signerProperties .setReason(reason) .setLocation(location) - .setLayer2Font(font) - .setReuseAppearance(setReuseAppearance); - + .setSignatureAppearance(appearance); if (rectangleForNewField != null) { - signer.setPageRect(rectangleForNewField); + signerProperties.setPageRect(rectangleForNewField); } if (fontSize != null) { - appearance.setLayer2FontSize((float) fontSize); + appearance.setFontSize((float) fontSize); } + signer.getSignatureField().setReuseAppearance(setReuseAppearance); // Creating the signature IExternalSignature pks = new PrivateKeySignature(pk, digestAlgorithm, FACTORY.getProviderName()); diff --git a/sign/src/test/java/com/itextpdf/signatures/sign/PdfPadesAdvancedTest.java b/sign/src/test/java/com/itextpdf/signatures/sign/PdfPadesAdvancedTest.java index d6378b023f..dd2c4efa1a 100644 --- a/sign/src/test/java/com/itextpdf/signatures/sign/PdfPadesAdvancedTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/sign/PdfPadesAdvancedTest.java @@ -29,11 +29,10 @@ This file is part of the iText (R) project. import com.itextpdf.commons.bouncycastle.pkcs.AbstractPKCSException; import com.itextpdf.commons.utils.FileUtil; import com.itextpdf.forms.form.element.SignatureFieldAppearance; -import com.itextpdf.io.logs.IoLogMessageConstant; +import com.itextpdf.kernel.crypto.DigestAlgorithms; import com.itextpdf.kernel.exceptions.PdfException; import com.itextpdf.kernel.geom.Rectangle; import com.itextpdf.kernel.pdf.PdfReader; -import com.itextpdf.signatures.DigestAlgorithms; import com.itextpdf.signatures.IExternalSignature; import com.itextpdf.signatures.PdfPadesSigner; import com.itextpdf.signatures.PrivateKeySignature; @@ -48,9 +47,6 @@ This file is part of the iText (R) project. import com.itextpdf.signatures.testutils.client.AdvancedTestOcspClient; import com.itextpdf.signatures.testutils.client.TestTsaClient; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.LogMessage; -import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.BouncyCastleIntegrationTest; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -67,15 +63,13 @@ This file is part of the iText (R) project. import java.util.HashMap; import java.util.List; import java.util.Map; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; - -@RunWith(Parameterized.class) -@Category(BouncyCastleIntegrationTest.class) +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +@Tag("BouncyCastleIntegrationTest") public class PdfPadesAdvancedTest extends ExtendedITextTest { private static final IBouncyCastleFactory FACTORY = BouncyCastleFactoryCreator.getFactory(); private static final String CERTS_SRC = "./src/test/resources/com/itextpdf/signatures/sign/PdfPadesAdvancedTest/certs/"; @@ -83,37 +77,13 @@ public class PdfPadesAdvancedTest extends ExtendedITextTest { private static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/signatures/sign/PdfPadesAdvancedTest/"; private static final char[] PASSWORD = "testpassphrase".toCharArray(); - - private final String signingCertName; - private final String rootCertName; - private final Boolean isOcspRevoked; - private final String cmpFilePostfix; - - private final Integer amountOfCrlsForSign; - private final Integer amountOfOcspsForSign; - private final Integer amountOfCrlsForRoot; - private final Integer amountOfOcspsForRoot; - @BeforeClass + @BeforeAll public static void before() { Security.addProvider(FACTORY.getProvider()); createOrClearDestinationFolder(DESTINATION_FOLDER); } - public PdfPadesAdvancedTest(Object signingCertName, Object rootCertName, Object isOcspRevoked, Object cmpFilePostfix, - Object amountOfCrlsForSign, Object amountOfOcspsForSign, Object amountOfCrlsForRoot, Object amountOfOcspsForRoot) { - this.signingCertName = (String) signingCertName; - this.rootCertName = (String) rootCertName; - this.isOcspRevoked = (Boolean) isOcspRevoked; - this.cmpFilePostfix = (String) cmpFilePostfix; - - this.amountOfCrlsForSign = (Integer) amountOfCrlsForSign; - this.amountOfOcspsForSign = (Integer) amountOfOcspsForSign; - this.amountOfCrlsForRoot = (Integer) amountOfCrlsForRoot; - this.amountOfOcspsForRoot = (Integer) amountOfOcspsForRoot; - } - - @Parameterized.Parameters(name = "{3}: signing cert: {0}; root cert: {1}; revoked: {2}") public static Iterable createParameters() { List parameters = new ArrayList<>(); parameters.addAll(createParametersUsingRootName("rootCertNoCrlNoOcsp", 0, 0)); @@ -140,8 +110,11 @@ private static List createParametersUsingRootName(String rootCertName, ); } - @Test - public void signWithAdvancedClientsTest() + @ParameterizedTest(name = "{3}: signing cert: {0}; root cert: {1}; revoked: {2}") + @MethodSource("createParameters") + public void signWithAdvancedClientsTest(String signingCertName, String rootCertName, Boolean isOcspRevoked, + String cmpFilePostfix, Integer amountOfCrlsForSign, Integer amountOfOcspsForSign, + Integer amountOfCrlsForRoot, Integer amountOfOcspsForRoot) throws IOException, GeneralSecurityException, AbstractOperatorCreationException, AbstractPKCSException, AbstractOCSPException { String srcFileName = SOURCE_FOLDER + "helloWorldDoc.pdf"; String signCertFileName = CERTS_SRC + signingCertName; @@ -158,7 +131,7 @@ public void signWithAdvancedClientsTest() TestTsaClient testTsa = new TestTsaClient(Arrays.asList(tsaChain), tsaPrivateKey); - AdvancedTestOcspClient testOcspClient = new AdvancedTestOcspClient(null); + AdvancedTestOcspClient testOcspClient = new AdvancedTestOcspClient(); TestOcspResponseBuilder ocspBuilderMainCert = new TestOcspResponseBuilder(rootCert, rootPrivateKey); if ((boolean) isOcspRevoked) { ocspBuilderMainCert.setCertificateStatus(FACTORY.createRevokedStatus(TimeTestUtil.TEST_DATE_TIME, @@ -191,9 +164,9 @@ public void signWithAdvancedClientsTest() Certificate[] signRsaChain = new Certificate[] {signRsaCert, rootCert}; if (signCertFileName.contains("NoOcspNoCrl") || (signCertFileName.contains("OcspNoCrl") && (boolean) isOcspRevoked)) { try { - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> padesSigner.signWithBaselineLTAProfile(signerProperties, signRsaChain, pks, testTsa)); - Assert.assertEquals(SignExceptionMessageConstant.NO_REVOCATION_DATA_FOR_SIGNING_CERTIFICATE, + Assertions.assertEquals(SignExceptionMessageConstant.NO_REVOCATION_DATA_FOR_SIGNING_CERTIFICATE, exception.getMessage()); } finally { outputStream.close(); @@ -202,12 +175,14 @@ public void signWithAdvancedClientsTest() padesSigner.signWithBaselineLTAProfile(signerProperties, signRsaChain, pks, testTsa); TestSignUtils.basicCheckSignedDoc(new ByteArrayInputStream(outputStream.toByteArray()), "Signature1"); - assertDss(outputStream, rootCert, signRsaCert, (X509Certificate) tsaChain[0], (X509Certificate) tsaChain[1]); + assertDss(outputStream, rootCert, signRsaCert, (X509Certificate) tsaChain[0], (X509Certificate) tsaChain[1], + amountOfCrlsForRoot, amountOfCrlsForSign, amountOfOcspsForRoot, amountOfOcspsForSign); } } - + private void assertDss(ByteArrayOutputStream outputStream, X509Certificate rootCert, X509Certificate signRsaCert, - X509Certificate tsaCert, X509Certificate rootTsaCert) + X509Certificate tsaCert, X509Certificate rootTsaCert, Integer amountOfCrlsForRoot, + Integer amountOfCrlsForSign, Integer amountOfOcspsForRoot, Integer amountOfOcspsForSign) throws AbstractOCSPException, CertificateException, IOException, CRLException { Map expectedNumberOfCrls = new HashMap<>(); if (amountOfCrlsForRoot + amountOfCrlsForSign != 0) { @@ -230,7 +205,7 @@ private String getCertName(X509Certificate certificate) { private SignerProperties createSignerProperties() { SignerProperties signerProperties = new SignerProperties(); signerProperties.setFieldName("Signature1"); - SignatureFieldAppearance appearance = new SignatureFieldAppearance(signerProperties.getFieldName()) + SignatureFieldAppearance appearance = new SignatureFieldAppearance(SignerProperties.IGNORED_ID) .setContent("Approval test signature.\nCreated by iText."); signerProperties.setPageRect(new Rectangle(50, 650, 200, 100)) .setSignatureAppearance(appearance); diff --git a/sign/src/test/java/com/itextpdf/signatures/sign/PdfPadesMissingCertificatesTest.java b/sign/src/test/java/com/itextpdf/signatures/sign/PdfPadesMissingCertificatesTest.java index 596071b79a..90ef09316d 100644 --- a/sign/src/test/java/com/itextpdf/signatures/sign/PdfPadesMissingCertificatesTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/sign/PdfPadesMissingCertificatesTest.java @@ -41,10 +41,9 @@ This file is part of the iText (R) project. import com.itextpdf.signatures.testutils.client.AdvancedTestOcspClient; import com.itextpdf.signatures.testutils.client.TestTsaClient; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -63,7 +62,7 @@ This file is part of the iText (R) project. import java.util.List; import java.util.Map; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfPadesMissingCertificatesTest extends ExtendedITextTest { private static final IBouncyCastleFactory FACTORY = BouncyCastleFactoryCreator.getFactory(); @@ -72,7 +71,7 @@ public class PdfPadesMissingCertificatesTest extends ExtendedITextTest { private static final String destinationFolder = "./target/test/com/itextpdf/signatures/sign/PdfPadesMissingCertificatesTest/"; private static final char[] password = "testpassphrase".toCharArray(); - @BeforeClass + @BeforeAll public static void before() { Security.addProvider(FACTORY.getProvider()); createOrClearDestinationFolder(destinationFolder); @@ -127,7 +126,7 @@ protected InputStream getCrlResponse(X509Certificate cert, URL urlt) throws IOEx X509Certificate tsaIntermediateCert = (X509Certificate) PemFileHelper.readFirstChain(intermediateTsaFileName)[0]; X509Certificate intermediateCert = (X509Certificate) PemFileHelper.readFirstChain(intermediateCertFileName)[0]; - AdvancedTestOcspClient ocspClient = new AdvancedTestOcspClient(null); + AdvancedTestOcspClient ocspClient = new AdvancedTestOcspClient(); ocspClient.addBuilderForCertIssuer(signCert, ocspCert, ocspPrivateKey); ocspClient.addBuilderForCertIssuer(ocspIntermediateCert, ocspCert, ocspPrivateKey); ocspClient.addBuilderForCertIssuer(crlIntermediateCert, ocspCert, ocspPrivateKey); @@ -268,7 +267,7 @@ private String getCertName(X509Certificate certificate) { private SignerProperties createSignerProperties() { SignerProperties signerProperties = new SignerProperties(); signerProperties.setFieldName("Signature1"); - SignatureFieldAppearance appearance = new SignatureFieldAppearance(signerProperties.getFieldName()) + SignatureFieldAppearance appearance = new SignatureFieldAppearance(SignerProperties.IGNORED_ID) .setContent("Approval test signature.\nCreated by iText."); signerProperties.setPageRect(new Rectangle(50, 650, 200, 100)) .setSignatureAppearance(appearance); diff --git a/sign/src/test/java/com/itextpdf/signatures/sign/PdfPadesSignerLevelsTest.java b/sign/src/test/java/com/itextpdf/signatures/sign/PdfPadesSignerLevelsTest.java index d014238c46..b2645434f6 100644 --- a/sign/src/test/java/com/itextpdf/signatures/sign/PdfPadesSignerLevelsTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/sign/PdfPadesSignerLevelsTest.java @@ -28,16 +28,21 @@ This file is part of the iText (R) project. import com.itextpdf.commons.bouncycastle.pkcs.AbstractPKCSException; import com.itextpdf.commons.utils.FileUtil; import com.itextpdf.forms.form.element.SignatureFieldAppearance; +import com.itextpdf.kernel.crypto.DigestAlgorithms; import com.itextpdf.kernel.geom.Rectangle; import com.itextpdf.kernel.pdf.PdfReader; -import com.itextpdf.signatures.*; +import com.itextpdf.signatures.ICrlClient; +import com.itextpdf.signatures.IExternalSignature; +import com.itextpdf.signatures.PdfPadesSigner; +import com.itextpdf.signatures.PrivateKeySignature; +import com.itextpdf.signatures.SignerProperties; +import com.itextpdf.signatures.TestSignUtils; import com.itextpdf.signatures.testutils.PemFileHelper; import com.itextpdf.signatures.testutils.SignaturesCompareTool; import com.itextpdf.signatures.testutils.client.TestCrlClient; import com.itextpdf.signatures.testutils.client.TestOcspClient; import com.itextpdf.signatures.testutils.client.TestTsaClient; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.BouncyCastleIntegrationTest; import java.io.IOException; import java.security.GeneralSecurityException; @@ -46,15 +51,13 @@ This file is part of the iText (R) project. import java.security.cert.Certificate; import java.security.cert.X509Certificate; import java.util.Arrays; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; - -@RunWith(Parameterized.class) -@Category(BouncyCastleIntegrationTest.class) +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +@Tag("BouncyCastleIntegrationTest") public class PdfPadesSignerLevelsTest extends ExtendedITextTest { private static final IBouncyCastleFactory FACTORY = BouncyCastleFactoryCreator.getFactory(); @@ -64,34 +67,23 @@ public class PdfPadesSignerLevelsTest extends ExtendedITextTest { private static final String certsSrc = "./src/test/resources/com/itextpdf/signatures/certs/"; private static final String sourceFolder = "./src/test/resources/com/itextpdf/signatures/sign/PdfPadesSignerLevelsTest/"; private static final String destinationFolder = "./target/test/com/itextpdf/signatures/sign/PdfPadesSignerLevelsTest/"; - - private final Boolean useTempFolder; - private final Integer comparisonPdfId; - private final Boolean useSignature; - private static final char[] password = "testpassphrase".toCharArray(); - @BeforeClass + @BeforeAll public static void before() { Security.addProvider(FACTORY.getProvider()); createOrClearDestinationFolder(destinationFolder); } - public PdfPadesSignerLevelsTest(Object useTempFolder, Object useSignature, Object comparisonPdfId) { - this.useTempFolder = (Boolean) useTempFolder; - this.useSignature = (Boolean) useSignature; - this.comparisonPdfId = (Integer) comparisonPdfId; - } - - @Parameterized.Parameters(name = "{2}: folder path: {0}; pass whole signature: {1}") public static Iterable createParameters() { return Arrays.asList(new Object[] {true, true, 1}, new Object[] {false, true, 2}, new Object[] {false, false, 3}); } - - @Test - public void padesSignatureLevelBTest() + + @ParameterizedTest(name = "{2}: folder path: {0}; pass whole signature: {1}") + @MethodSource("createParameters") + public void padesSignatureLevelBTest(Boolean useTempFolder, Boolean useSignature, Integer comparisonPdfId) throws IOException, GeneralSecurityException, AbstractOperatorCreationException, AbstractPKCSException { String fileName = "padesSignatureLevelBTest" + comparisonPdfId + ".pdf"; String outFileName = destinationFolder + fileName; @@ -118,11 +110,12 @@ public void padesSignatureLevelBTest() TestSignUtils.basicCheckSignedDoc(outFileName, "Signature1"); - Assert.assertNull(SignaturesCompareTool.compareSignatures(outFileName, cmpFileName)); + Assertions.assertNull(SignaturesCompareTool.compareSignatures(outFileName, cmpFileName)); } - @Test - public void padesSignatureLevelTTest() + @ParameterizedTest(name = "{2}: folder path: {0}; pass whole signature: {1}") + @MethodSource("createParameters") + public void padesSignatureLevelTTest(Boolean useTempFolder, Boolean useSignature, Integer comparisonPdfId) throws IOException, GeneralSecurityException, AbstractOperatorCreationException, AbstractPKCSException { String fileName = "padesSignatureLevelTTest" + comparisonPdfId + ".pdf"; String outFileName = destinationFolder + fileName; @@ -154,11 +147,12 @@ public void padesSignatureLevelTTest() TestSignUtils.basicCheckSignedDoc(outFileName, "Signature1"); - Assert.assertNull(SignaturesCompareTool.compareSignatures(outFileName, cmpFileName)); + Assertions.assertNull(SignaturesCompareTool.compareSignatures(outFileName, cmpFileName)); } - @Test - public void padesSignatureLevelLTTest() + @ParameterizedTest(name = "{2}: folder path: {0}; pass whole signature: {1}") + @MethodSource("createParameters") + public void padesSignatureLevelLTTest(Boolean useTempFolder, Boolean useSignature, Integer comparisonPdfId) throws IOException, GeneralSecurityException, AbstractOperatorCreationException, AbstractPKCSException { String fileName = "padesSignatureLevelLTTest" + comparisonPdfId + ".pdf"; String outFileName = destinationFolder + fileName; @@ -197,11 +191,12 @@ public void padesSignatureLevelLTTest() TestSignUtils.basicCheckSignedDoc(outFileName, "Signature1"); - Assert.assertNull(SignaturesCompareTool.compareSignatures(outFileName, cmpFileName)); + Assertions.assertNull(SignaturesCompareTool.compareSignatures(outFileName, cmpFileName)); } - @Test - public void padesSignatureLevelLTATest() + @ParameterizedTest(name = "{2}: folder path: {0}; pass whole signature: {1}") + @MethodSource("createParameters") + public void padesSignatureLevelLTATest(Boolean useTempFolder, Boolean useSignature, Integer comparisonPdfId) throws IOException, GeneralSecurityException, AbstractOperatorCreationException, AbstractPKCSException { String fileName = "padesSignatureLevelLTATest" + comparisonPdfId + ".pdf"; String outFileName = destinationFolder + fileName; @@ -241,11 +236,12 @@ public void padesSignatureLevelLTATest() TestSignUtils.basicCheckSignedDoc(outFileName, "Signature1"); - Assert.assertNull(SignaturesCompareTool.compareSignatures(outFileName, cmpFileName)); + Assertions.assertNull(SignaturesCompareTool.compareSignatures(outFileName, cmpFileName)); } - - @Test - public void prolongDocumentSignaturesTest() + + @ParameterizedTest(name = "{2}: folder path: {0}; pass whole signature: {1}") + @MethodSource("createParameters") + public void prolongDocumentSignaturesTest(Boolean useTempFolder, Boolean useSignature, Integer comparisonPdfId) throws GeneralSecurityException, IOException, AbstractOperatorCreationException, AbstractPKCSException { String fileName = "prolongDocumentSignaturesTest" + comparisonPdfId + (FIPS_MODE ? "_FIPS.pdf" : ".pdf"); String outFileName = destinationFolder + fileName; @@ -275,13 +271,13 @@ public void prolongDocumentSignaturesTest() } TestSignUtils.basicCheckSignedDoc(outFileName, "Signature1"); - Assert.assertNull(SignaturesCompareTool.compareSignatures(outFileName, cmpFileName)); + Assertions.assertNull(SignaturesCompareTool.compareSignatures(outFileName, cmpFileName)); } private SignerProperties createSignerProperties() { SignerProperties signerProperties = new SignerProperties(); signerProperties.setFieldName("Signature1"); - SignatureFieldAppearance appearance = new SignatureFieldAppearance(signerProperties.getFieldName()) + SignatureFieldAppearance appearance = new SignatureFieldAppearance(SignerProperties.IGNORED_ID) .setContent("Approval test signature.\nCreated by iText."); signerProperties.setPageRect(new Rectangle(50, 650, 200, 100)) .setSignatureAppearance(appearance); diff --git a/sign/src/test/java/com/itextpdf/signatures/sign/PdfPadesSignerLtvExtensionsTest.java b/sign/src/test/java/com/itextpdf/signatures/sign/PdfPadesSignerLtvExtensionsTest.java index c2e8298616..2326b6f0da 100644 --- a/sign/src/test/java/com/itextpdf/signatures/sign/PdfPadesSignerLtvExtensionsTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/sign/PdfPadesSignerLtvExtensionsTest.java @@ -29,9 +29,9 @@ This file is part of the iText (R) project. import com.itextpdf.commons.bouncycastle.pkcs.AbstractPKCSException; import com.itextpdf.commons.utils.FileUtil; import com.itextpdf.forms.form.element.SignatureFieldAppearance; +import com.itextpdf.kernel.crypto.DigestAlgorithms; import com.itextpdf.kernel.geom.Rectangle; import com.itextpdf.kernel.pdf.PdfReader; -import com.itextpdf.signatures.DigestAlgorithms; import com.itextpdf.signatures.IExternalSignature; import com.itextpdf.signatures.PdfPadesSigner; import com.itextpdf.signatures.PrivateKeySignature; @@ -46,7 +46,6 @@ This file is part of the iText (R) project. import com.itextpdf.test.LogLevelConstants; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.BouncyCastleIntegrationTest; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -60,11 +59,11 @@ This file is part of the iText (R) project. import java.util.HashMap; import java.util.List; import java.util.Map; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(BouncyCastleIntegrationTest.class) +@Tag("BouncyCastleIntegrationTest") public class PdfPadesSignerLtvExtensionsTest extends ExtendedITextTest { private static final IBouncyCastleFactory FACTORY = BouncyCastleFactoryCreator.getFactory(); @@ -73,7 +72,7 @@ public class PdfPadesSignerLtvExtensionsTest extends ExtendedITextTest { private static final char[] PASSWORD = "testpassphrase".toCharArray(); - @BeforeClass + @BeforeAll public static void before() { Security.addProvider(FACTORY.getProvider()); } @@ -178,7 +177,7 @@ private String getCertName(X509Certificate certificate) { private SignerProperties createSignerProperties() { SignerProperties signerProperties = new SignerProperties(); signerProperties.setFieldName("Signature1"); - SignatureFieldAppearance appearance = new SignatureFieldAppearance(signerProperties.getFieldName()) + SignatureFieldAppearance appearance = new SignatureFieldAppearance(SignerProperties.IGNORED_ID) .setContent("Approval test signature.\nCreated by iText."); signerProperties.setPageRect(new Rectangle(50, 650, 200, 100)) .setSignatureAppearance(appearance); diff --git a/sign/src/test/java/com/itextpdf/signatures/sign/PdfPadesSignerTest.java b/sign/src/test/java/com/itextpdf/signatures/sign/PdfPadesSignerTest.java index 26756f917f..614b7dd09f 100644 --- a/sign/src/test/java/com/itextpdf/signatures/sign/PdfPadesSignerTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/sign/PdfPadesSignerTest.java @@ -29,10 +29,16 @@ This file is part of the iText (R) project. import com.itextpdf.commons.utils.FileUtil; import com.itextpdf.commons.utils.MessageFormatUtil; import com.itextpdf.forms.form.element.SignatureFieldAppearance; +import com.itextpdf.kernel.crypto.DigestAlgorithms; import com.itextpdf.kernel.exceptions.PdfException; import com.itextpdf.kernel.geom.Rectangle; import com.itextpdf.kernel.pdf.PdfReader; -import com.itextpdf.signatures.*; +import com.itextpdf.signatures.ICrlClient; +import com.itextpdf.signatures.IExternalSignature; +import com.itextpdf.signatures.PdfPadesSigner; +import com.itextpdf.signatures.PrivateKeySignature; +import com.itextpdf.signatures.SignerProperties; +import com.itextpdf.signatures.TestSignUtils; import com.itextpdf.signatures.exceptions.SignExceptionMessageConstant; import com.itextpdf.signatures.testutils.PemFileHelper; import com.itextpdf.signatures.testutils.SignaturesCompareTool; @@ -40,24 +46,22 @@ This file is part of the iText (R) project. import com.itextpdf.signatures.testutils.client.TestOcspClient; import com.itextpdf.signatures.testutils.client.TestTsaClient; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.BouncyCastleIntegrationTest; -import org.junit.Assert; -import org.junit.Assume; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; import java.io.IOException; import java.security.GeneralSecurityException; -import java.security.NoSuchAlgorithmException; import java.security.PrivateKey; import java.security.Security; import java.security.cert.Certificate; import java.security.cert.CertificateException; import java.security.cert.X509Certificate; import java.util.Arrays; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(BouncyCastleIntegrationTest.class) +@Tag("BouncyCastleIntegrationTest") public class PdfPadesSignerTest extends ExtendedITextTest { private static final IBouncyCastleFactory FACTORY = BouncyCastleFactoryCreator.getFactory(); @@ -68,7 +72,7 @@ public class PdfPadesSignerTest extends ExtendedITextTest { private static final boolean FIPS_MODE = "BCFIPS".equals(FACTORY.getProviderName()); - @BeforeClass + @BeforeAll public static void before() { Security.addProvider(FACTORY.getProvider()); createOrClearDestinationFolder(destinationFolder); @@ -104,9 +108,9 @@ public void directoryPathIsNotADirectoryTest() padesSigner.setTemporaryDirectoryPath(destinationFolder + "newPdf.pdf"); padesSigner.setOcspClient(ocspClient).setCrlClient(crlClient); - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> padesSigner.signWithBaselineLTProfile(signerProperties, signRsaChain, pks, testTsa)); - Assert.assertEquals(MessageFormatUtil.format(SignExceptionMessageConstant.PATH_IS_NOT_DIRECTORY, + Assertions.assertEquals(MessageFormatUtil.format(SignExceptionMessageConstant.PATH_IS_NOT_DIRECTORY, destinationFolder + "newPdf.pdf"), exception.getMessage()); } @@ -131,9 +135,9 @@ public void noSignaturesToProlongTest() PdfPadesSigner padesSigner = createPdfPadesSigner(srcFileName, outFileName); padesSigner.setOcspClient(ocspClient).setCrlClient(crlClient); - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> padesSigner.prolongSignatures(testTsa)); - Assert.assertEquals(SignExceptionMessageConstant.NO_SIGNATURES_TO_PROLONG, exception.getMessage()); + Assertions.assertEquals(SignExceptionMessageConstant.NO_SIGNATURES_TO_PROLONG, exception.getMessage()); } @Test @@ -160,9 +164,9 @@ public void defaultClientsCannotBeCreated() padesSigner.setTemporaryDirectoryPath(destinationFolder); - Exception exception = Assert.assertThrows(PdfException.class, + Exception exception = Assertions.assertThrows(PdfException.class, () -> padesSigner.signWithBaselineLTProfile(signerProperties, signRsaChain, pks, testTsa)); - Assert.assertEquals(SignExceptionMessageConstant.DEFAULT_CLIENTS_CANNOT_BE_CREATED, exception.getMessage()); + Assertions.assertEquals(SignExceptionMessageConstant.DEFAULT_CLIENTS_CANNOT_BE_CREATED, exception.getMessage()); } @Test @@ -198,7 +202,7 @@ public void defaultSignerPropertiesTest() padesSigner.signWithBaselineLTAProfile(signerProperties, signRsaChain, pks, testTsa); TestSignUtils.basicCheckSignedDoc(outFileName, "Signature1"); - Assert.assertNull(SignaturesCompareTool.compareSignatures(outFileName, cmpFileName)); + Assertions.assertNull(SignaturesCompareTool.compareSignatures(outFileName, cmpFileName)); } @Test @@ -235,16 +239,16 @@ public int getTokenSizeEstimate() { padesSigner.setOcspClient(ocspClient).setCrlClient(crlClient); - Exception e = Assert.assertThrows(IOException.class, + Exception e = Assertions.assertThrows(IOException.class, () -> padesSigner.signWithBaselineLTAProfile(signerProperties, signRsaChain, pks, testTsa)); - Assert.assertEquals(MessageFormatUtil.format( + Assertions.assertEquals(MessageFormatUtil.format( SignExceptionMessageConstant.TOKEN_ESTIMATION_SIZE_IS_NOT_LARGE_ENOUGH, 1024, 2780), e.getMessage()); } @Test public void padesSignatureEd25519Test() throws IOException, GeneralSecurityException, AbstractOperatorCreationException, AbstractPKCSException { - Assume.assumeFalse(FACTORY.isInApprovedOnlyMode()); + Assumptions.assumeFalse(FACTORY.isInApprovedOnlyMode()); String fileName = "padesSignatureEd25519Test.pdf"; String outFileName = destinationFolder + fileName; String cmpFileName = sourceFolder + "cmp_" + fileName; @@ -258,13 +262,13 @@ public void padesSignatureEd25519Test() PdfPadesSigner padesSigner = createPdfPadesSigner(srcFileName, outFileName); padesSigner.signWithBaselineBProfile(signerProperties, signEdDSAChain, signEdDSAPrivateKey); TestSignUtils.basicCheckSignedDoc(outFileName, "Signature1"); - Assert.assertNull(SignaturesCompareTool.compareSignatures(outFileName, cmpFileName)); + Assertions.assertNull(SignaturesCompareTool.compareSignatures(outFileName, cmpFileName)); } @Test public void padesSignatureEd448Test() throws IOException, GeneralSecurityException, AbstractOperatorCreationException, AbstractPKCSException { - Assume.assumeFalse(FACTORY.isInApprovedOnlyMode()); + Assumptions.assumeFalse(FACTORY.isInApprovedOnlyMode()); String fileName = "padesSignatureEd448Test.pdf"; String outFileName = destinationFolder + fileName; String cmpFileName = sourceFolder + "cmp_" + fileName; @@ -276,21 +280,16 @@ public void padesSignatureEd448Test() SignerProperties signerProperties = createSignerProperties(); PdfPadesSigner padesSigner = createPdfPadesSigner(srcFileName, outFileName); - if (FIPS_MODE) { - // SHAKE256 is currently not supported in BCFIPS - Exception exception = Assert.assertThrows(NoSuchAlgorithmException.class, - () -> padesSigner.signWithBaselineBProfile(signerProperties, signEdDSAChain, signEdDSAPrivateKey)); - } else { - padesSigner.signWithBaselineBProfile(signerProperties, signEdDSAChain, signEdDSAPrivateKey); - TestSignUtils.basicCheckSignedDoc(outFileName, "Signature1"); - Assert.assertNull(SignaturesCompareTool.compareSignatures(outFileName, cmpFileName)); - } + + padesSigner.signWithBaselineBProfile(signerProperties, signEdDSAChain, signEdDSAPrivateKey); + TestSignUtils.basicCheckSignedDoc(outFileName, "Signature1"); + Assertions.assertNull(SignaturesCompareTool.compareSignatures(outFileName, cmpFileName)); } private SignerProperties createSignerProperties() { SignerProperties signerProperties = new SignerProperties(); signerProperties.setFieldName("Signature1"); - SignatureFieldAppearance appearance = new SignatureFieldAppearance(signerProperties.getFieldName()) + SignatureFieldAppearance appearance = new SignatureFieldAppearance(SignerProperties.IGNORED_ID) .setContent("Approval test signature.\nCreated by iText."); signerProperties.setPageRect(new Rectangle(50, 650, 200, 100)) .setSignatureAppearance(appearance); diff --git a/sign/src/test/java/com/itextpdf/signatures/sign/PdfPadesWithCrlCertificateTest.java b/sign/src/test/java/com/itextpdf/signatures/sign/PdfPadesWithCrlCertificateTest.java index 6077d46a64..4668c96a71 100644 --- a/sign/src/test/java/com/itextpdf/signatures/sign/PdfPadesWithCrlCertificateTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/sign/PdfPadesWithCrlCertificateTest.java @@ -40,10 +40,9 @@ This file is part of the iText (R) project. import com.itextpdf.signatures.testutils.PemFileHelper; import com.itextpdf.signatures.testutils.client.TestTsaClient; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.BouncyCastleIntegrationTest; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.*; import java.net.URL; @@ -56,7 +55,7 @@ This file is part of the iText (R) project. import java.util.HashMap; import java.util.Map; -@Category(BouncyCastleIntegrationTest.class) +@Tag("BouncyCastleIntegrationTest") public class PdfPadesWithCrlCertificateTest extends ExtendedITextTest { private static final IBouncyCastleFactory FACTORY = BouncyCastleFactoryCreator.getFactory(); @@ -66,7 +65,7 @@ public class PdfPadesWithCrlCertificateTest extends ExtendedITextTest { private static final char[] PASSWORD = "testpassphrase".toCharArray(); - @BeforeClass + @BeforeAll public static void before() { Security.addProvider(FACTORY.getProvider()); createOrClearDestinationFolder(destinationFolder); @@ -135,7 +134,7 @@ protected InputStream getIssuerCertByURI(String uri) throws IOException { private SignerProperties createSignerProperties() { SignerProperties signerProperties = new SignerProperties(); signerProperties.setFieldName("Signature1"); - SignatureFieldAppearance appearance = new SignatureFieldAppearance(signerProperties.getFieldName()) + SignatureFieldAppearance appearance = new SignatureFieldAppearance(SignerProperties.IGNORED_ID) .setContent("Approval test signature.\nCreated by iText."); signerProperties.setPageRect(new Rectangle(50, 650, 200, 100)) .setSignatureAppearance(appearance); diff --git a/sign/src/test/java/com/itextpdf/signatures/sign/PdfPadesWithMissingCertTest.java b/sign/src/test/java/com/itextpdf/signatures/sign/PdfPadesWithMissingCertTest.java index cd3d38eb13..f58ba07443 100644 --- a/sign/src/test/java/com/itextpdf/signatures/sign/PdfPadesWithMissingCertTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/sign/PdfPadesWithMissingCertTest.java @@ -40,7 +40,6 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.BouncyCastleIntegrationTest; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -54,14 +53,12 @@ This file is part of the iText (R) project. import java.security.cert.X509Certificate; import java.util.Arrays; import java.util.List; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; - -@RunWith(Parameterized.class) -@Category(BouncyCastleIntegrationTest.class) +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +@Tag("BouncyCastleIntegrationTest") public class PdfPadesWithMissingCertTest extends ExtendedITextTest { private static final IBouncyCastleFactory FACTORY = BouncyCastleFactoryCreator.getFactory(); @@ -70,22 +67,13 @@ public class PdfPadesWithMissingCertTest extends ExtendedITextTest { private static final String destinationFolder = "./target/test/com/itextpdf/signatures/sign/PdfPadesWithMissingCertTest/"; private static final char[] PASSWORD = "testpassphrase".toCharArray(); - - private final String missingCertName1; - private final String missingCertName2; - @BeforeClass + @BeforeAll public static void before() { Security.addProvider(FACTORY.getProvider()); createOrClearDestinationFolder(destinationFolder); } - public PdfPadesWithMissingCertTest(Object missingCertName1, Object missingCertName2) { - this.missingCertName1 = (String) missingCertName1; - this.missingCertName2 = (String) missingCertName2; - } - - @Parameterized.Parameters(name = "first missing cert: {0}; second missing cert: {1};") public static Iterable createParameters() { return Arrays.asList(new Object[] {"missing_cert1.cer", "missing_cert2.cer"}, new Object[] {"missing_cert1.crt", "missing_cert2.crt"}, @@ -93,10 +81,11 @@ public static Iterable createParameters() { new Object[] {"not_existing_file", "not_existing_file"}, new Object[] {"missing_cert1.der", "missing_cert2.der"}); } - - @Test + + @ParameterizedTest(name = "first missing cert: {0}; second missing cert: {1};") + @MethodSource("createParameters") @LogMessages(messages = @LogMessage(messageTemplate = SignLogMessageConstant.UNABLE_TO_PARSE_AIA_CERT), ignore = true) - public void missingCertTest() + public void missingCertTest(String missingCertName1, String missingCertName2) throws GeneralSecurityException, IOException, AbstractOperatorCreationException, AbstractPKCSException { String srcFileName = sourceFolder + "helloWorldDoc.pdf"; String signCertFileName = certsSrc + "sign_cert.pem"; @@ -145,7 +134,7 @@ protected InputStream getIssuerCertByURI(String uri) throws IOException { private SignerProperties createSignerProperties() { SignerProperties signerProperties = new SignerProperties(); signerProperties.setFieldName("Signature1"); - SignatureFieldAppearance appearance = new SignatureFieldAppearance(signerProperties.getFieldName()) + SignatureFieldAppearance appearance = new SignatureFieldAppearance(SignerProperties.IGNORED_ID) .setContent("Approval test signature.\nCreated by iText."); signerProperties.setPageRect(new Rectangle(50, 650, 200, 100)) .setSignatureAppearance(appearance); diff --git a/sign/src/test/java/com/itextpdf/signatures/sign/PdfPadesWithOcspCertificateTest.java b/sign/src/test/java/com/itextpdf/signatures/sign/PdfPadesWithOcspCertificateTest.java index 648e31dcc6..7c30548ecf 100644 --- a/sign/src/test/java/com/itextpdf/signatures/sign/PdfPadesWithOcspCertificateTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/sign/PdfPadesWithOcspCertificateTest.java @@ -40,7 +40,6 @@ This file is part of the iText (R) project. import com.itextpdf.signatures.testutils.client.AdvancedTestOcspClient; import com.itextpdf.signatures.testutils.client.TestTsaClient; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.BouncyCastleIntegrationTest; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -55,12 +54,12 @@ This file is part of the iText (R) project. import java.util.HashMap; import java.util.List; import java.util.Map; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(BouncyCastleIntegrationTest.class) +@Tag("BouncyCastleIntegrationTest") public class PdfPadesWithOcspCertificateTest extends ExtendedITextTest { private static final IBouncyCastleFactory FACTORY = BouncyCastleFactoryCreator.getFactory(); @@ -70,7 +69,7 @@ public class PdfPadesWithOcspCertificateTest extends ExtendedITextTest { private static final char[] PASSWORD = "testpassphrase".toCharArray(); - @BeforeClass + @BeforeAll public static void before() { Security.addProvider(FACTORY.getProvider()); createOrClearDestinationFolder(destinationFolder); @@ -95,7 +94,7 @@ public void signCertWithOcspTest() throws GeneralSecurityException, IOException, SignerProperties signerProperties = createSignerProperties(); TestTsaClient testTsa = new TestTsaClient(Arrays.asList(tsaChain), tsaPrivateKey); - AdvancedTestOcspClient ocspClient = new AdvancedTestOcspClient(null); + AdvancedTestOcspClient ocspClient = new AdvancedTestOcspClient(); ocspClient.addBuilderForCertIssuer(signRsaCert, ocspCert, ocspPrivateKey); ocspClient.addBuilderForCertIssuer(ocspCert, ocspCert, ocspPrivateKey); @@ -140,7 +139,7 @@ public void signCertWithoutOcspTest() SignerProperties signerProperties = createSignerProperties(); TestTsaClient testTsa = new TestTsaClient(Arrays.asList(tsaChain), tsaPrivateKey); - AdvancedTestOcspClient ocspClient = new AdvancedTestOcspClient(null); + AdvancedTestOcspClient ocspClient = new AdvancedTestOcspClient(); ocspClient.addBuilderForCertIssuer((X509Certificate) signRsaCert, (X509Certificate) ocspCert, ocspPrivateKey); ocspClient.addBuilderForCertIssuer((X509Certificate) ocspCert, (X509Certificate) ocspCert, ocspPrivateKey); @@ -148,9 +147,9 @@ public void signCertWithoutOcspTest() PdfPadesSigner padesSigner = createPdfPadesSigner(srcFileName, outputStream); padesSigner.setOcspClient(ocspClient); - Exception exception = Assert.assertThrows(PdfException.class, () -> + Exception exception = Assertions.assertThrows(PdfException.class, () -> padesSigner.signWithBaselineLTProfile(signerProperties, signRsaChain, signRsaPrivateKey, testTsa)); - Assert.assertEquals(SignExceptionMessageConstant.NO_REVOCATION_DATA_FOR_SIGNING_CERTIFICATE, exception.getMessage()); + Assertions.assertEquals(SignExceptionMessageConstant.NO_REVOCATION_DATA_FOR_SIGNING_CERTIFICATE, exception.getMessage()); } } @@ -170,7 +169,7 @@ public void signCertWithOcspOcspCertSameAsSignCertTest() throws GeneralSecurityE SignerProperties signerProperties = createSignerProperties(); TestTsaClient testTsa = new TestTsaClient(Arrays.asList(tsaChain), tsaPrivateKey); - AdvancedTestOcspClient ocspClient = new AdvancedTestOcspClient(null); + AdvancedTestOcspClient ocspClient = new AdvancedTestOcspClient(); ocspClient.addBuilderForCertIssuer(signRsaCert, signRsaCert, signRsaPrivateKey); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); @@ -198,7 +197,7 @@ private String getCertName(X509Certificate certificate) { private SignerProperties createSignerProperties() { SignerProperties signerProperties = new SignerProperties(); signerProperties.setFieldName("Signature1"); - SignatureFieldAppearance appearance = new SignatureFieldAppearance(signerProperties.getFieldName()) + SignatureFieldAppearance appearance = new SignatureFieldAppearance(SignerProperties.IGNORED_ID) .setContent("Approval test signature.\nCreated by iText."); signerProperties.setPageRect(new Rectangle(50, 650, 200, 100)) .setSignatureAppearance(appearance); diff --git a/sign/src/test/java/com/itextpdf/signatures/sign/PdfPadesWithTimestampCertificateTest.java b/sign/src/test/java/com/itextpdf/signatures/sign/PdfPadesWithTimestampCertificateTest.java index 9617831406..d96333b37b 100644 --- a/sign/src/test/java/com/itextpdf/signatures/sign/PdfPadesWithTimestampCertificateTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/sign/PdfPadesWithTimestampCertificateTest.java @@ -39,7 +39,6 @@ This file is part of the iText (R) project. import com.itextpdf.signatures.testutils.client.AdvancedTestOcspClient; import com.itextpdf.signatures.testutils.client.TestTsaClient; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.BouncyCastleIntegrationTest; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -54,11 +53,11 @@ This file is part of the iText (R) project. import java.util.HashMap; import java.util.List; import java.util.Map; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(BouncyCastleIntegrationTest.class) +@Tag("BouncyCastleIntegrationTest") public class PdfPadesWithTimestampCertificateTest extends ExtendedITextTest { private static final IBouncyCastleFactory FACTORY = BouncyCastleFactoryCreator.getFactory(); @@ -69,7 +68,7 @@ public class PdfPadesWithTimestampCertificateTest extends ExtendedITextTest { private static final char[] PASSWORD = "testpassphrase".toCharArray(); - @BeforeClass + @BeforeAll public static void before() { Security.addProvider(FACTORY.getProvider()); createOrClearDestinationFolder(destinationFolder); @@ -97,7 +96,7 @@ public void differentTimestampCertTest() TestTsaClient testTsa = new TestTsaClient(Arrays.asList(tsaChain), tsaPrivateKey); - AdvancedTestOcspClient ocspClient = new AdvancedTestOcspClient(null); + AdvancedTestOcspClient ocspClient = new AdvancedTestOcspClient(); ocspClient.addBuilderForCertIssuer((X509Certificate) tsaChain[0], caCert, caPrivateKey); ocspClient.addBuilderForCertIssuer((X509Certificate) tsaChain[1], caCert, caPrivateKey); padesSigner.setOcspClient(ocspClient); @@ -129,7 +128,7 @@ private String getCertName(X509Certificate certificate) { private SignerProperties createSignerProperties() { SignerProperties signerProperties = new SignerProperties(); signerProperties.setFieldName("Signature1"); - SignatureFieldAppearance appearance = new SignatureFieldAppearance(signerProperties.getFieldName()) + SignatureFieldAppearance appearance = new SignatureFieldAppearance(SignerProperties.IGNORED_ID) .setContent("Approval test signature.\nCreated by iText."); signerProperties.setPageRect(new Rectangle(50, 650, 200, 100)) .setSignatureAppearance(appearance); diff --git a/sign/src/test/java/com/itextpdf/signatures/sign/PdfSignatureTest.java b/sign/src/test/java/com/itextpdf/signatures/sign/PdfSignatureTest.java index 5eb7fc58cf..85a1ddd8ec 100644 --- a/sign/src/test/java/com/itextpdf/signatures/sign/PdfSignatureTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/sign/PdfSignatureTest.java @@ -32,14 +32,13 @@ This file is part of the iText (R) project. import com.itextpdf.signatures.PdfSignatureApp; import com.itextpdf.signatures.SignatureUtil; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.IOException; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfSignatureTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/signatures/sign/PdfSignatureTest/"; @@ -50,7 +49,7 @@ public void setByteRangeTest() throws IOException { signature.setByteRange(byteRange); PdfArray expected = new PdfArray((new int[] {0, 141, 16526, 2494})); - Assert.assertArrayEquals(expected.toIntArray(), signature.getByteRange().toIntArray()); + Assertions.assertArrayEquals(expected.toIntArray(), signature.getByteRange().toIntArray()); } @Test @@ -60,7 +59,7 @@ public void setContentsTest() throws IOException { byte[] newContents = new PdfString("new iText signature").getValueBytes(); signature.setContents(newContents); - Assert.assertEquals("new iText signature", signature.getContents().getValue()); + Assertions.assertEquals("new iText signature", signature.getContents().getValue()); } @Test @@ -70,43 +69,43 @@ public void setAndGetCertTest() throws IOException { byte[] certChain = new PdfString("Hello, iText!!").getValueBytes(); signature.setCert(certChain); - Assert.assertEquals("Hello, iText!!", signature.getCertObject().toString()); + Assertions.assertEquals("Hello, iText!!", signature.getCertObject().toString()); } @Test public void getCertObjectTest() throws IOException { PdfSignature signature = getTestSignature(sourceFolder + "adbe.x509.rsa_sha1_signature.pdf"); - Assert.assertTrue(signature.getCertObject().isArray()); + Assertions.assertTrue(signature.getCertObject().isArray()); } @Test public void setAndGetNameTest() throws IOException { PdfSignature signature = getTestSignature(sourceFolder + "simpleSignature.pdf"); - Assert.assertNull(signature.getName()); + Assertions.assertNull(signature.getName()); String name = "iText person"; signature.setName(name); - Assert.assertEquals(name, signature.getName()); + Assertions.assertEquals(name, signature.getName()); } @Test public void setSignatureCreatorTest() throws IOException { PdfSignature signature = getTestSignature(sourceFolder + "noPropBuilds.pdf"); - Assert.assertNull(signature.getPdfObject().getAsDictionary(PdfName.Prop_Build)); + Assertions.assertNull(signature.getPdfObject().getAsDictionary(PdfName.Prop_Build)); signature.setSignatureCreator("iText.Name"); String propBuild = signature.getPdfObject().getAsDictionary(PdfName.Prop_Build) .getAsDictionary(PdfName.App).getAsName(PdfName.Name).getValue(); - Assert.assertEquals("iText.Name", propBuild); + Assertions.assertEquals("iText.Name", propBuild); } @Test public void pdfSignatureAppDefaultConstructorTest() { PdfSignatureApp signatureApp = new PdfSignatureApp(); - Assert.assertTrue(signatureApp.getPdfObject().isDictionary()); + Assertions.assertTrue(signatureApp.getPdfObject().isDictionary()); } @Test @@ -114,8 +113,8 @@ public void certAsArrayNotStringTest() throws IOException { PdfSignature signature = getTestSignature(sourceFolder + "adbe.x509.rsa_sha1_signature.pdf"); PdfObject certObject = signature.getCertObject(); - Assert.assertTrue(certObject instanceof PdfArray); - Assert.assertNull(signature.getCert()); + Assertions.assertTrue(certObject instanceof PdfArray); + Assertions.assertNull(signature.getCert()); } private static PdfSignature getTestSignature(String pathToPdf) throws IOException { diff --git a/sign/src/test/java/com/itextpdf/signatures/sign/RSASSAPSSTest.java b/sign/src/test/java/com/itextpdf/signatures/sign/RSASSAPSSTest.java index 7aa6432eed..8ef965cff3 100644 --- a/sign/src/test/java/com/itextpdf/signatures/sign/RSASSAPSSTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/sign/RSASSAPSSTest.java @@ -24,43 +24,41 @@ This file is part of the iText (R) project. import com.itextpdf.bouncycastleconnector.BouncyCastleFactoryCreator; import com.itextpdf.commons.bouncycastle.IBouncyCastleFactory; -import com.itextpdf.commons.bouncycastle.cert.IX509CertificateHolder; +import com.itextpdf.commons.bouncycastle.operator.AbstractOperatorCreationException; +import com.itextpdf.commons.bouncycastle.pkcs.AbstractPKCSException; import com.itextpdf.commons.utils.FileUtil; +import com.itextpdf.kernel.crypto.DigestAlgorithms; +import com.itextpdf.kernel.crypto.OID; import com.itextpdf.kernel.exceptions.PdfException; import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfReader; import com.itextpdf.kernel.pdf.StampingProperties; import com.itextpdf.signatures.BouncyCastleDigest; -import com.itextpdf.signatures.DigestAlgorithms; import com.itextpdf.signatures.IApplicableSignatureParams; import com.itextpdf.signatures.IExternalSignature; import com.itextpdf.signatures.PdfPKCS7; import com.itextpdf.signatures.PdfSigner; import com.itextpdf.signatures.PrivateKeySignature; import com.itextpdf.signatures.RSASSAPSSMechanismParams; -import com.itextpdf.signatures.SecurityIDs; import com.itextpdf.signatures.SignatureUtil; +import com.itextpdf.signatures.SignerProperties; import com.itextpdf.signatures.testutils.PemFileHelper; import com.itextpdf.signatures.testutils.SignaturesCompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.BouncyCastleUnitTest; import java.io.IOException; import java.io.OutputStream; -import java.nio.file.Files; -import java.nio.file.Path; import java.nio.file.Paths; import java.security.GeneralSecurityException; -import java.security.KeyException; import java.security.PrivateKey; import java.security.Security; import java.security.cert.Certificate; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(BouncyCastleUnitTest.class) +@Tag("BouncyCastleUnitTest") public class RSASSAPSSTest extends ExtendedITextTest { private static final IBouncyCastleFactory FACTORY = BouncyCastleFactoryCreator.getFactory(); @@ -70,14 +68,15 @@ public class RSASSAPSSTest extends ExtendedITextTest { private static final String SIGNATURE_FIELD = "Signature"; private static final char[] SAMPLE_KEY_PASSPHRASE = "pdfpdfpdfsecretsecret".toCharArray(); - @BeforeClass + @BeforeAll public static void before() { Security.addProvider(FACTORY.getProvider()); createOrClearDestinationFolder(DESTINATION_FOLDER); } @Test - public void signWithRsaSsaPssTest() throws GeneralSecurityException, IOException { + public void signWithRsaSsaPssTest() + throws GeneralSecurityException, IOException, AbstractOperatorCreationException, AbstractPKCSException { String digestName = "SHA256"; String outFileName = "simplePssSignature.pdf"; @@ -88,7 +87,7 @@ public void signWithRsaSsaPssTest() throws GeneralSecurityException, IOException RSASSAPSSMechanismParams.createForDigestAlgorithm(digestName) ); - Assert.assertNull( + Assertions.assertNull( SignaturesCompareTool.compareSignatures( Paths.get(DESTINATION_FOLDER, outFileName).toString(), Paths.get(SOURCE_FOLDER, cmpFileName).toString() @@ -97,7 +96,8 @@ public void signWithRsaSsaPssTest() throws GeneralSecurityException, IOException } @Test - public void signWithRsaSsaPssAlternativeNomenclatureTest() throws GeneralSecurityException, IOException { + public void signWithRsaSsaPssAlternativeNomenclatureTest() + throws GeneralSecurityException, IOException, AbstractOperatorCreationException, AbstractPKCSException { String digestName = "SHA256"; String outFileName = "simplePssAlternativeNomenclatureSignature.pdf"; String cmpFileName = "cmp_simplePssSignature.pdf"; @@ -109,7 +109,7 @@ public void signWithRsaSsaPssAlternativeNomenclatureTest() throws GeneralSecurit RSASSAPSSMechanismParams.createForDigestAlgorithm(digestName) ); - Assert.assertNull( + Assertions.assertNull( SignaturesCompareTool.compareSignatures( Paths.get(DESTINATION_FOLDER, outFileName).toString(), Paths.get(SOURCE_FOLDER, cmpFileName).toString() @@ -118,7 +118,8 @@ public void signWithRsaSsaPssAlternativeNomenclatureTest() throws GeneralSecurit } @Test - public void signWithRsaSsaSha384PssTest() throws GeneralSecurityException, IOException { + public void signWithRsaSsaSha384PssTest() + throws GeneralSecurityException, IOException, AbstractOperatorCreationException, AbstractPKCSException { String digestName = "SHA384"; String outFileName = "simplePssSignatureSha384.pdf"; @@ -130,7 +131,8 @@ public void signWithRsaSsaSha384PssTest() throws GeneralSecurityException, IOExc } @Test - public void signWithRsaSsaCustomSaltLengthTest() throws GeneralSecurityException, IOException { + public void signWithRsaSsaCustomSaltLengthTest() + throws GeneralSecurityException, IOException, AbstractOperatorCreationException, AbstractPKCSException { String digestName = "SHA256"; String outFileName = "customSaltLength.pdf"; @@ -149,8 +151,8 @@ public void signWithRsaSsaCustomSaltLengthTest() throws GeneralSecurityException Paths.get(DESTINATION_FOLDER, outFileName).toString(), Paths.get(SOURCE_FOLDER, cmpFileName).toString() ); - Assert.assertTrue(cmpOut.contains("out: Integer(40)")); - Assert.assertTrue(cmpOut.contains("cmp: Integer(32)")); + Assertions.assertTrue(cmpOut.contains("out: Integer(40)")); + Assertions.assertTrue(cmpOut.contains("cmp: Integer(32)")); } @Test @@ -162,32 +164,29 @@ public void rejectMgfDigestDiscrepancy() throws IOException { SignatureUtil u = new SignatureUtil(pdfDoc); String provider = FACTORY.getProviderName(); - PdfException pdfException = Assert.assertThrows( - PdfException.class, - () -> u.readSignatureData(SIGNATURE_FIELD, provider) - ); + Assertions.assertThrows(PdfException.class, () -> u.readSignatureData(SIGNATURE_FIELD, provider)); } } private void doRoundTrip(String digestAlgo, String signatureAlgo, String outFileName, IApplicableSignatureParams params) - throws GeneralSecurityException, IOException { + throws GeneralSecurityException, IOException, AbstractOperatorCreationException, AbstractPKCSException { String outFile = Paths.get(DESTINATION_FOLDER, outFileName).toString(); doSign(digestAlgo, signatureAlgo, outFile, params); doVerify(outFile); } private void doSign(String digestAlgo, String signatureAlgo, String outFile, IApplicableSignatureParams params) - throws IOException, GeneralSecurityException { + throws IOException, GeneralSecurityException, AbstractOperatorCreationException, AbstractPKCSException { // write to a file for easier inspection when debugging try (OutputStream fos = FileUtil.getFileOutputStream(outFile)) { - Certificate root = readCertificate(Paths.get(SOURCE_FOLDER, "ca.crt")); - Certificate signerCert = readCertificate(Paths.get(SOURCE_FOLDER, "rsa.crt")); + Certificate root = PemFileHelper.readFirstChain(SOURCE_FOLDER + "ca.pem")[0]; + Certificate signerCert = PemFileHelper.readFirstChain(SOURCE_FOLDER + "rsa.pem")[0]; Certificate[] signChain = new Certificate[]{signerCert, root}; - PrivateKey signPrivateKey = readPrivateKey(Paths.get(SOURCE_FOLDER, "rsa.key.pem")); + PrivateKey signPrivateKey = PemFileHelper.readFirstKey(SOURCE_FOLDER + "rsa.key.pem", SAMPLE_KEY_PASSPHRASE); IExternalSignature pks = new PrivateKeySignature(signPrivateKey, digestAlgo, signatureAlgo, FACTORY.getProviderName(), params); PdfSigner signer = new PdfSigner(new PdfReader(SOURCE_FILE), fos, new StampingProperties()); - signer.setFieldName(SIGNATURE_FIELD); + signer.setSignerProperties(new SignerProperties().setFieldName(SIGNATURE_FIELD)); signer.signDetached( new BouncyCastleDigest(), pks, signChain, null, null, null, 0, PdfSigner.CryptoStandard.CMS); @@ -198,22 +197,8 @@ private void doVerify(String fileName) throws IOException, GeneralSecurityExcept try (PdfReader r = new PdfReader(fileName); PdfDocument pdfDoc = new PdfDocument(r)) { SignatureUtil u = new SignatureUtil(pdfDoc); PdfPKCS7 data = u.readSignatureData(SIGNATURE_FIELD, FACTORY.getProviderName()); - Assert.assertEquals(SecurityIDs.ID_RSASSA_PSS, data.getSignatureMechanismOid()); - Assert.assertTrue(data.verifySignatureIntegrityAndAuthenticity()); + Assertions.assertEquals(OID.RSASSA_PSS, data.getSignatureMechanismOid()); + Assertions.assertTrue(data.verifySignatureIntegrityAndAuthenticity()); } } - - private PrivateKey readPrivateKey(Path path) throws GeneralSecurityException { - try { - return PemFileHelper.readFirstKey(path.toString(), SAMPLE_KEY_PASSPHRASE); - } catch (Exception e) { - throw new KeyException(e); - } - } - - private Certificate readCertificate(Path path) throws IOException, GeneralSecurityException { - byte[] content = Files.readAllBytes(path); - IX509CertificateHolder certHolder = FACTORY.createX509CertificateHolder(content); - return FACTORY.createJcaX509CertificateConverter().getCertificate(certHolder); - } } diff --git a/sign/src/test/java/com/itextpdf/signatures/sign/SequentialSignaturesTest.java b/sign/src/test/java/com/itextpdf/signatures/sign/SequentialSignaturesTest.java index dd01bf352c..a27302d678 100644 --- a/sign/src/test/java/com/itextpdf/signatures/sign/SequentialSignaturesTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/sign/SequentialSignaturesTest.java @@ -27,6 +27,8 @@ This file is part of the iText (R) project. import com.itextpdf.commons.bouncycastle.operator.AbstractOperatorCreationException; import com.itextpdf.commons.bouncycastle.pkcs.AbstractPKCSException; import com.itextpdf.commons.utils.FileUtil; +import com.itextpdf.forms.form.element.SignatureFieldAppearance; +import com.itextpdf.kernel.crypto.DigestAlgorithms; import com.itextpdf.kernel.geom.Rectangle; import com.itextpdf.kernel.pdf.CompressionConstants; import com.itextpdf.kernel.pdf.PdfDocument; @@ -34,29 +36,27 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfReader; import com.itextpdf.kernel.pdf.StampingProperties; import com.itextpdf.signatures.BouncyCastleDigest; -import com.itextpdf.signatures.DigestAlgorithms; import com.itextpdf.signatures.IExternalSignature; -import com.itextpdf.signatures.PdfSignatureAppearance; import com.itextpdf.signatures.PdfSigner; import com.itextpdf.signatures.PdfSigner.CryptoStandard; import com.itextpdf.signatures.PrivateKeySignature; +import com.itextpdf.signatures.SignerProperties; import com.itextpdf.signatures.TestSignUtils; import com.itextpdf.signatures.testutils.PemFileHelper; import com.itextpdf.signatures.testutils.SignaturesCompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.BouncyCastleIntegrationTest; import java.io.IOException; import java.security.GeneralSecurityException; import java.security.PrivateKey; import java.security.Security; import java.security.cert.Certificate; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(BouncyCastleIntegrationTest.class) +@Tag("BouncyCastleIntegrationTest") public class SequentialSignaturesTest extends ExtendedITextTest { private static final IBouncyCastleFactory FACTORY = BouncyCastleFactoryCreator.getFactory(); @@ -67,7 +67,7 @@ public class SequentialSignaturesTest extends ExtendedITextTest { private static final char[] password = "testpassphrase".toCharArray(); - @BeforeClass + @BeforeAll public static void before() { Security.addProvider(FACTORY.getProvider()); createOrClearDestinationFolder(destinationFolder); @@ -88,17 +88,20 @@ public void sequentialSignOfFileWithAnnots() String signatureName = "Signature2"; PdfSigner signer = new PdfSigner(new PdfReader(srcFileName), FileUtil.getFileOutputStream(outFileName), new StampingProperties().useAppendMode()); - signer.setFieldName(signatureName); - signer.getSignatureAppearance() + SignatureFieldAppearance appearance = new SignatureFieldAppearance(SignerProperties.IGNORED_ID) + .setContent("Approval test signature.\nCreated by iText."); + SignerProperties signerProperties = new SignerProperties() + .setFieldName(signatureName) .setPageRect(new Rectangle(50, 350, 200, 100)) .setReason("Test") .setLocation("TestCity") - .setLayer2Text("Approval test signature.\nCreated by iText."); + .setSignatureAppearance(appearance); + signer.setSignerProperties(signerProperties); signer.signDetached(new BouncyCastleDigest(), pks, signChain, null, null, null, 0, PdfSigner.CryptoStandard.CADES); TestSignUtils.basicCheckSignedDoc(outFileName, signatureName); - Assert.assertNull(SignaturesCompareTool.compareSignatures(outFileName, cmpFileName)); + Assertions.assertNull(SignaturesCompareTool.compareSignatures(outFileName, cmpFileName)); } @Test @@ -123,14 +126,16 @@ public void secondSignOfTaggedDocTest() PdfDocument document = signer.getDocument(); document.getWriter().setCompressionLevel(CompressionConstants.NO_COMPRESSION); - signer.setFieldName(signatureName); - PdfSignatureAppearance appearance = signer.getSignatureAppearance(); - appearance.setPageNumber(1); - signer.getSignatureAppearance() + SignatureFieldAppearance appearance = new SignatureFieldAppearance(SignerProperties.IGNORED_ID) + .setContent("Approval test signature #2.\nCreated by iText."); + SignerProperties signerProperties = new SignerProperties() + .setFieldName(signatureName) + .setPageNumber(1) .setPageRect(new Rectangle(50, 550, 200, 100)) .setReason("Test2") .setLocation("TestCity2") - .setLayer2Text("Approval test signature #2.\nCreated by iText."); + .setSignatureAppearance(appearance); + signer.setSignerProperties(signerProperties); signer.signDetached(new BouncyCastleDigest(), pks, signChain, null, null, null, 0, CryptoStandard.CADES); @@ -151,9 +156,9 @@ public void secondSignOfTaggedDocTest() // as the original signature validation failed by Adobe because of struct tree change. If the fix // would make this tree unchanged, then the assertion should be adjusted with comparing the tree of // objects in StructTreeRoot to ensure that it won't be changed. - Assert.assertNotEquals(resourceStrElemNumber, outStrElemNumber); + Assertions.assertNotEquals(resourceStrElemNumber, outStrElemNumber); } - Assert.assertNull(SignaturesCompareTool.compareSignatures(outFileName, cmpFileName)); + Assertions.assertNull(SignaturesCompareTool.compareSignatures(outFileName, cmpFileName)); } } diff --git a/sign/src/test/java/com/itextpdf/signatures/sign/SignDeferredTest.java b/sign/src/test/java/com/itextpdf/signatures/sign/SignDeferredTest.java index c1d81aadc2..b73bfd6efc 100644 --- a/sign/src/test/java/com/itextpdf/signatures/sign/SignDeferredTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/sign/SignDeferredTest.java @@ -28,6 +28,8 @@ This file is part of the iText (R) project. import com.itextpdf.commons.bouncycastle.pkcs.AbstractPKCSException; import com.itextpdf.commons.utils.FileUtil; import com.itextpdf.forms.fields.PdfFormCreator; +import com.itextpdf.forms.form.element.SignatureFieldAppearance; +import com.itextpdf.kernel.crypto.DigestAlgorithms; import com.itextpdf.kernel.geom.Rectangle; import com.itextpdf.kernel.pdf.PdfArray; import com.itextpdf.kernel.pdf.PdfDictionary; @@ -38,21 +40,20 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfString; import com.itextpdf.kernel.pdf.StampingProperties; import com.itextpdf.kernel.utils.CompareTool; +import com.itextpdf.signatures.AccessPermissions; import com.itextpdf.signatures.BouncyCastleDigest; -import com.itextpdf.signatures.DigestAlgorithms; import com.itextpdf.signatures.ExternalBlankSignatureContainer; import com.itextpdf.signatures.IExternalSignatureContainer; import com.itextpdf.signatures.PdfPKCS7; -import com.itextpdf.signatures.PdfSignatureAppearance; import com.itextpdf.signatures.PdfSigner; import com.itextpdf.signatures.PrivateKeySignature; +import com.itextpdf.signatures.SignerProperties; import com.itextpdf.signatures.TestSignUtils; import com.itextpdf.signatures.exceptions.SignExceptionMessageConstant; import com.itextpdf.signatures.testutils.PemFileHelper; import com.itextpdf.signatures.testutils.SignTestPortUtil; import com.itextpdf.signatures.testutils.SignaturesCompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.BouncyCastleIntegrationTest; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -63,12 +64,12 @@ This file is part of the iText (R) project. import java.security.PrivateKey; import java.security.Security; import java.security.cert.Certificate; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(BouncyCastleIntegrationTest.class) +@Tag("BouncyCastleIntegrationTest") public class SignDeferredTest extends ExtendedITextTest { private static final IBouncyCastleFactory FACTORY = BouncyCastleFactoryCreator.getFactory(); @@ -80,7 +81,7 @@ public class SignDeferredTest extends ExtendedITextTest { private static final char[] password = "testpassphrase".toCharArray(); private static final String HASH_ALGORITHM = DigestAlgorithms.SHA256; - @BeforeClass + @BeforeAll public static void before() { Security.addProvider(FACTORY.getProvider()); createOrClearDestinationFolder(destinationFolder); @@ -98,12 +99,15 @@ public void prepareDocForSignDeferredTest() throws IOException, GeneralSecurityE PdfReader reader = new PdfReader(input); PdfSigner signer = new PdfSigner(reader, FileUtil.getFileOutputStream(output), new StampingProperties()); - PdfSignatureAppearance appearance = signer.getSignatureAppearance(); - appearance - .setLayer2Text("Signature field which signing is deferred.") + SignerProperties signerProperties = new SignerProperties().setFieldName(sigFieldName); + signer.setSignerProperties(signerProperties); + SignatureFieldAppearance appearance = new SignatureFieldAppearance(SignerProperties.IGNORED_ID) + .setContent("Signature field which signing is deferred."); + signerProperties .setPageRect(new Rectangle(36, 600, 200, 100)) - .setPageNumber(1); - signer.setFieldName(sigFieldName); + .setPageNumber(1) + .setSignatureAppearance(appearance); + IExternalSignatureContainer external = new ExternalBlankSignatureContainer(filter, subFilter); signer.signExternalContainer(external, estimatedSize); @@ -121,19 +125,21 @@ public void prepareDocForSignDeferredNotEnoughSizeTest() throws IOException { PdfReader reader = new PdfReader(input); PdfSigner signer = new PdfSigner(reader, new ByteArrayOutputStream(), new StampingProperties()); - PdfSignatureAppearance appearance = signer.getSignatureAppearance(); - appearance - .setLayer2Text("Signature field which signing is deferred.") + SignerProperties signerProperties = new SignerProperties().setFieldName(sigFieldName); + signer.setSignerProperties(signerProperties); + SignatureFieldAppearance appearance = new SignatureFieldAppearance(SignerProperties.IGNORED_ID) + .setContent("Signature field which signing is deferred."); + signerProperties .setPageRect(new Rectangle(36, 600, 200, 100)) - .setPageNumber(1); - signer.setFieldName(sigFieldName); + .setPageNumber(1) + .setSignatureAppearance(appearance); IExternalSignatureContainer external = new ExternalBlankSignatureContainer(filter, subFilter); // This size is definitely not enough int estimatedSize = -1; - Exception e = Assert.assertThrows(IOException.class, + Exception e = Assertions.assertThrows(IOException.class, () -> signer.signExternalContainer(external, estimatedSize)); - Assert.assertEquals(SignExceptionMessageConstant.NOT_ENOUGH_SPACE, e.getMessage()); + Assertions.assertEquals(SignExceptionMessageConstant.NOT_ENOUGH_SPACE, e.getMessage()); } @Test @@ -146,20 +152,22 @@ public void prepareDocForSignDeferredLittleSpaceTest() throws IOException { PdfReader reader = new PdfReader(input); PdfSigner signer = new PdfSigner(reader, new ByteArrayOutputStream(), new StampingProperties()); - PdfSignatureAppearance appearance = signer.getSignatureAppearance(); - appearance - .setLayer2Text("Signature field which signing is deferred.") + SignerProperties signerProperties = new SignerProperties().setFieldName(sigFieldName); + signer.setSignerProperties(signerProperties); + SignatureFieldAppearance appearance = new SignatureFieldAppearance(SignerProperties.IGNORED_ID) + .setContent("Signature field which signing is deferred."); + signerProperties .setPageRect(new Rectangle(36, 600, 200, 100)) - .setPageNumber(1); - signer.setFieldName(sigFieldName); + .setPageNumber(1) + .setSignatureAppearance(appearance); IExternalSignatureContainer external = new ExternalBlankSignatureContainer(filter, subFilter); // This size is definitely not enough, however, the size check will pass. // The test will fail lately on an invalid key int estimatedSize = 0; - Exception e = Assert.assertThrows(IllegalArgumentException.class, + Exception e = Assertions.assertThrows(IllegalArgumentException.class, () -> signer.signExternalContainer(external, estimatedSize)); - Assert.assertEquals(SignExceptionMessageConstant.TOO_BIG_KEY, e.getMessage()); + Assertions.assertEquals(SignExceptionMessageConstant.TOO_BIG_KEY, e.getMessage()); } @Test @@ -184,8 +192,8 @@ public void deferredHashCalcAndSignTest01() throws IOException, GeneralSecurityE // validate result TestSignUtils.basicCheckSignedDoc(outFileName, sigFieldName); - Assert.assertNull(new CompareTool().compareVisually(outFileName, cmpFileName, destinationFolder, null)); - Assert.assertNull(SignaturesCompareTool.compareSignatures(outFileName, cmpFileName)); + Assertions.assertNull(new CompareTool().compareVisually(outFileName, cmpFileName, destinationFolder, null)); + Assertions.assertNull(SignaturesCompareTool.compareSignatures(outFileName, cmpFileName)); } @Test @@ -204,26 +212,27 @@ public void calcHashOnDocCreationThenDeferredSignTest01() throws IOException, Ge PdfReader reader = new PdfReader(input); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PdfSigner signer = new PdfSigner(reader, baos, new StampingProperties()); - signer.setCertificationLevel(PdfSigner.CERTIFIED_NO_CHANGES_ALLOWED); - PdfSignatureAppearance appearance = signer.getSignatureAppearance(); - appearance - .setLayer2Text("Signature field which signing is deferred.") + SignerProperties signerProperties = new SignerProperties() + .setCertificationLevel(AccessPermissions.NO_CHANGES_PERMITTED) + .setFieldName(sigFieldName); + signer.setSignerProperties(signerProperties); + SignatureFieldAppearance appearance = new SignatureFieldAppearance(SignerProperties.IGNORED_ID) + .setContent("Signature field which signing is deferred."); + signerProperties .setPageRect(new Rectangle(36, 600, 200, 100)) - .setPageNumber(1); - signer.setFieldName(sigFieldName); + .setPageNumber(1) + .setSignatureAppearance(appearance); DigestCalcBlankSigner external = new DigestCalcBlankSigner(filter, subFilter); signer.signExternalContainer(external, estimatedSize); byte[] docBytesHash = external.getDocBytesHash(); byte[] preSignedBytes = baos.toByteArray(); - // sign the hash String signCertFileName = certsSrc + "signCertRsa01.pem"; Certificate[] signChain = PemFileHelper.readFirstChain(signCertFileName); PrivateKey signPrivateKey = PemFileHelper.readFirstKey(signCertFileName, password); byte[] cmsSignature = signDocBytesHash(docBytesHash, signPrivateKey, signChain); - // fill the signature to the presigned document ReadySignatureSigner extSigContainer = new ReadySignatureSigner(cmsSignature); @@ -236,29 +245,29 @@ public void calcHashOnDocCreationThenDeferredSignTest01() throws IOException, Ge // validate result TestSignUtils.basicCheckSignedDoc(outFileName, sigFieldName); - Assert.assertNull(new CompareTool().compareVisually(outFileName, cmpFileName, destinationFolder, null)); - Assert.assertNull(SignaturesCompareTool.compareSignatures(outFileName, cmpFileName)); + Assertions.assertNull(new CompareTool().compareVisually(outFileName, cmpFileName, destinationFolder, null)); + Assertions.assertNull(SignaturesCompareTool.compareSignatures(outFileName, cmpFileName)); } static void validateTemplateForSignedDeferredResult(String output, String sigFieldName, PdfName filter, PdfName subFilter, int estimatedSize) throws IOException { PdfDocument outDocument = new PdfDocument(new PdfReader(output)); PdfObject outSigDictObj = PdfFormCreator.getAcroForm(outDocument, false).getField(sigFieldName).getValue(); - Assert.assertTrue(outSigDictObj.isDictionary()); + Assertions.assertTrue(outSigDictObj.isDictionary()); PdfDictionary outSigDict = (PdfDictionary) outSigDictObj; PdfArray byteRange = outSigDict.getAsArray(PdfName.ByteRange); - Assert.assertNotNull(byteRange); - Assert.assertTrue(byteRange.size() == 4); + Assertions.assertNotNull(byteRange); + Assertions.assertTrue(byteRange.size() == 4); - Assert.assertEquals(filter, outSigDict.getAsName(PdfName.Filter)); - Assert.assertEquals(subFilter, outSigDict.getAsName(PdfName.SubFilter)); + Assertions.assertEquals(filter, outSigDict.getAsName(PdfName.Filter)); + Assertions.assertEquals(subFilter, outSigDict.getAsName(PdfName.SubFilter)); PdfString outSigContents = outSigDict.getAsString(PdfName.Contents); - Assert.assertTrue(outSigContents.isHexWriting()); - Assert.assertArrayEquals(new byte[estimatedSize], outSigContents.getValueBytes()); + Assertions.assertTrue(outSigContents.isHexWriting()); + Assertions.assertArrayEquals(new byte[estimatedSize], outSigContents.getValueBytes()); } static byte[] calcDocBytesHash(InputStream docBytes) { diff --git a/sign/src/test/java/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest.java b/sign/src/test/java/com/itextpdf/signatures/sign/SignatureAppearanceTest.java similarity index 59% rename from sign/src/test/java/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest.java rename to sign/src/test/java/com/itextpdf/signatures/sign/SignatureAppearanceTest.java index e623083383..cb871d007b 100644 --- a/sign/src/test/java/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/sign/SignatureAppearanceTest.java @@ -32,9 +32,14 @@ This file is part of the iText (R) project. import com.itextpdf.forms.fields.PdfFormCreator; import com.itextpdf.forms.fields.PdfSignatureFormField; import com.itextpdf.forms.fields.SignatureFormFieldBuilder; +import com.itextpdf.forms.fields.properties.SignedAppearanceText; +import com.itextpdf.forms.form.FormProperty; import com.itextpdf.forms.form.element.SignatureFieldAppearance; +import com.itextpdf.io.image.ImageData; import com.itextpdf.io.image.ImageDataFactory; +import com.itextpdf.io.logs.IoLogMessageConstant; import com.itextpdf.kernel.colors.ColorConstants; +import com.itextpdf.kernel.crypto.DigestAlgorithms; import com.itextpdf.kernel.geom.Rectangle; import com.itextpdf.kernel.pdf.PdfDictionary; import com.itextpdf.kernel.pdf.PdfDocument; @@ -45,24 +50,32 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.StampingProperties; import com.itextpdf.kernel.pdf.canvas.PdfCanvas; import com.itextpdf.kernel.pdf.xobject.PdfFormXObject; +import com.itextpdf.kernel.pdf.xobject.PdfImageXObject; import com.itextpdf.kernel.utils.CompareTool; +import com.itextpdf.layout.Document; import com.itextpdf.layout.borders.SolidBorder; +import com.itextpdf.layout.properties.BackgroundImage; +import com.itextpdf.layout.properties.BackgroundPosition; +import com.itextpdf.layout.properties.BackgroundRepeat; +import com.itextpdf.layout.properties.BackgroundSize; import com.itextpdf.layout.properties.Property; import com.itextpdf.layout.properties.TextAlignment; +import com.itextpdf.layout.properties.UnitValue; import com.itextpdf.layout.properties.VerticalAlignment; +import com.itextpdf.signatures.AccessPermissions; import com.itextpdf.signatures.BouncyCastleDigest; -import com.itextpdf.signatures.DigestAlgorithms; import com.itextpdf.signatures.IExternalSignature; import com.itextpdf.signatures.PdfPKCS7; -import com.itextpdf.signatures.PdfSignatureAppearance; import com.itextpdf.signatures.PdfSigner; import com.itextpdf.signatures.PrivateKeySignature; import com.itextpdf.signatures.SignatureUtil; +import com.itextpdf.signatures.SignerProperties; import com.itextpdf.signatures.testutils.PemFileHelper; import com.itextpdf.signatures.testutils.SignaturesCompareTool; import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.ITextTest; -import com.itextpdf.test.annotations.type.BouncyCastleIntegrationTest; +import com.itextpdf.test.annotations.LogMessage; +import com.itextpdf.test.annotations.LogMessages; import java.io.IOException; import java.security.GeneralSecurityException; @@ -74,32 +87,32 @@ This file is part of the iText (R) project. import java.util.HashMap; import java.util.List; import java.util.Map; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(BouncyCastleIntegrationTest.class) -public class PdfSignatureAppearanceTest extends ExtendedITextTest { +@Tag("BouncyCastleIntegrationTest") +public class SignatureAppearanceTest extends ExtendedITextTest { private static final IBouncyCastleFactory FACTORY = BouncyCastleFactoryCreator.getFactory(); - public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/"; - public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/"; - public static final String KEYSTORE_PATH = "./src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/test.pem"; + public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/"; + public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/signatures/sign/SignatureAppearanceTest/"; + public static final String KEYSTORE_PATH = "./src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/test.pem"; public static final char[] PASSWORD = "testpassphrase".toCharArray(); private Certificate[] chain; private PrivateKey pk; - @BeforeClass + @BeforeAll public static void before() { Security.addProvider(FACTORY.getProvider()); createOrClearDestinationFolder(DESTINATION_FOLDER); } - @Before + @BeforeEach public void init() throws IOException, CertificateException, AbstractPKCSException, AbstractOperatorCreationException { pk = PemFileHelper.readFirstKey(KEYSTORE_PATH, PASSWORD); @@ -112,7 +125,7 @@ public void textAutoscaleTest01() throws GeneralSecurityException, IOException { String dest = DESTINATION_FOLDER + fileName; Rectangle rect = new Rectangle(36, 648, 200, 100); - testSignatureAppearanceAutoscale(dest, rect, PdfSignatureAppearance.RenderingMode.DESCRIPTION); + testSignatureAppearanceAutoscale(dest, rect, null, null); assertAppearanceFontSize(dest, 13.72f); } @@ -123,7 +136,7 @@ public void textAutoscaleTest02() throws GeneralSecurityException, IOException { String dest = DESTINATION_FOLDER + fileName; Rectangle rect = new Rectangle(36, 648, 150, 50); - testSignatureAppearanceAutoscale(dest, rect, PdfSignatureAppearance.RenderingMode.DESCRIPTION); + testSignatureAppearanceAutoscale(dest, rect, null, null); assertAppearanceFontSize(dest, 7.73f); } @@ -134,7 +147,7 @@ public void textAutoscaleTest03() throws GeneralSecurityException, IOException { String dest = DESTINATION_FOLDER + fileName; Rectangle rect = new Rectangle(36, 648, 200, 100); - testSignatureAppearanceAutoscale(dest, rect, PdfSignatureAppearance.RenderingMode.NAME_AND_DESCRIPTION); + testSignatureAppearanceAutoscale(dest, rect, "SignerName", null); assertAppearanceFontSize(dest, 44.35f); } @@ -145,7 +158,7 @@ public void textAutoscaleTest04() throws GeneralSecurityException, IOException { String dest = DESTINATION_FOLDER + fileName; Rectangle rect = new Rectangle(36, 648, 100, 50); - testSignatureAppearanceAutoscale(dest, rect, PdfSignatureAppearance.RenderingMode.NAME_AND_DESCRIPTION); + testSignatureAppearanceAutoscale(dest, rect, "SignerName", null); assertAppearanceFontSize(dest, 21.25f); } @@ -156,7 +169,7 @@ public void textAutoscaleTest05() throws GeneralSecurityException, IOException { String dest = DESTINATION_FOLDER + fileName; Rectangle rect = new Rectangle(36, 648, 200, 100); - testSignatureAppearanceAutoscale(dest, rect, PdfSignatureAppearance.RenderingMode.GRAPHIC_AND_DESCRIPTION); + testSignatureAppearanceAutoscale(dest, rect, null, ImageDataFactory.create(SOURCE_FOLDER + "itext.png")); assertAppearanceFontSize(dest, 12.77f); } @@ -167,7 +180,7 @@ public void textAutoscaleTest06() throws GeneralSecurityException, IOException { String dest = DESTINATION_FOLDER + fileName; Rectangle rect = new Rectangle(36, 648, 100, 50); - testSignatureAppearanceAutoscale(dest, rect, PdfSignatureAppearance.RenderingMode.GRAPHIC_AND_DESCRIPTION); + testSignatureAppearanceAutoscale(dest, rect, null, ImageDataFactory.create(SOURCE_FOLDER + "itext.png")); assertAppearanceFontSize(dest, 6.26f); } @@ -184,15 +197,18 @@ public void testSigningInAppendModeWithHybridDocument() String fieldName = "Sign1"; - SignatureFieldAppearance appearance = new SignatureFieldAppearance(fieldName).setFontSize(13.8f); + SignatureFieldAppearance appearance = new SignatureFieldAppearance(SignerProperties.IGNORED_ID) + .setContent(new SignedAppearanceText()).setFontSize(13.8f); - signer.setFieldName(fieldName); - signer.setReason("Test").setLocation("Nagpur") - .setPageRect(new Rectangle(36, 748, 200, 100)) + SignerProperties signerProperties = new SignerProperties() + .setFieldName(fieldName) + .setReason("Test") + .setLocation("Nagpur") + .setPageRect(new Rectangle(36, 748, 250, 100)) .setPageNumber(1) - .setSignatureAppearance(appearance); - - signer.setCertificationLevel(PdfSigner.NOT_CERTIFIED); + .setSignatureAppearance(appearance) + .setCertificationLevel(AccessPermissions.UNSPECIFIED); + signer.setSignerProperties(signerProperties); IExternalSignature pks = new PrivateKeySignature(pk, DigestAlgorithms.SHA256, FACTORY.getProviderName()); @@ -202,8 +218,8 @@ public void testSigningInAppendModeWithHybridDocument() new PdfDocument(new PdfReader(dest)).close(); // Assert that the document can be rendered correctly - Assert.assertNull(new CompareTool().compareVisually(dest, cmp, DESTINATION_FOLDER, "diff_", - getIgnoredAreaTestMap(new Rectangle(36, 748, 200, 100)))); + Assertions.assertNull(new CompareTool().compareVisually(dest, cmp, DESTINATION_FOLDER, "diff_", + getIgnoredAreaTestMap(new Rectangle(36, 748, 250, 100)))); } @Test @@ -215,10 +231,12 @@ public void fontColorTest01() throws GeneralSecurityException, IOException, Inte String src = SOURCE_FOLDER + "simpleDocument.pdf"; PdfSigner signer = new PdfSigner(new PdfReader(src), FileUtil.getFileOutputStream(dest), new StampingProperties()); - signer.setFieldName("Signature1"); + SignerProperties signerProperties = new SignerProperties().setFieldName("Signature1"); + signer.setSignerProperties(signerProperties); // Creating the appearance - signer.setPageRect(rect) - .setSignatureAppearance(new SignatureFieldAppearance(signer.getFieldName()) + signerProperties + .setPageRect(rect) + .setSignatureAppearance(new SignatureFieldAppearance(SignerProperties.IGNORED_ID) .setFontColor(ColorConstants.RED) .setContent("Verified and signed by me.")); @@ -227,23 +245,23 @@ public void fontColorTest01() throws GeneralSecurityException, IOException, Inte FACTORY.getProviderName()); signer.signDetached(new BouncyCastleDigest(), pks, chain, null, null, null, 0, PdfSigner.CryptoStandard.CADES); - Assert.assertNull(new CompareTool().compareVisually(dest, SOURCE_FOLDER + "cmp_" + fileName, DESTINATION_FOLDER, + Assertions.assertNull(new CompareTool().compareVisually(dest, SOURCE_FOLDER + "cmp_" + fileName, DESTINATION_FOLDER, "diff_")); } @Test + @LogMessages(messages = @LogMessage(messageTemplate = IoLogMessageConstant.CLIP_ELEMENT), ignore = true) public void signaturesOnRotatedPages() throws IOException, GeneralSecurityException, InterruptedException { StringBuilder assertionResults = new StringBuilder(); for (int i = 1; i <= 4; i++) { - testSignatureOnRotatedPage(i, PdfSignatureAppearance.RenderingMode.GRAPHIC_AND_DESCRIPTION, - assertionResults); - testSignatureOnRotatedPage(i, PdfSignatureAppearance.RenderingMode.GRAPHIC, assertionResults); - testSignatureOnRotatedPage(i, PdfSignatureAppearance.RenderingMode.NAME_AND_DESCRIPTION, assertionResults); - testSignatureOnRotatedPage(i, PdfSignatureAppearance.RenderingMode.DESCRIPTION, assertionResults); + testSignatureOnRotatedPage(i, true, false, true, assertionResults); + testSignatureOnRotatedPage(i, false, false, true, assertionResults); + testSignatureOnRotatedPage(i, true, true, false, assertionResults); + testSignatureOnRotatedPage(i, true, false, false, assertionResults); } - Assert.assertEquals("", assertionResults.toString()); + Assertions.assertEquals("", assertionResults.toString()); } @Test @@ -253,7 +271,7 @@ public void signatureFieldNotMergedWithWidgetTest() throws IOException, GeneralS SignatureUtil sigUtil = new SignatureUtil(outputDoc); PdfPKCS7 signatureData = sigUtil.readSignatureData("Signature1"); - Assert.assertTrue(signatureData.verifySignatureIntegrityAndAuthenticity()); + Assertions.assertTrue(signatureData.verifySignatureIntegrityAndAuthenticity()); } } @@ -268,13 +286,13 @@ public void signExistingNotMergedFieldNotReusedAPTest() throws GeneralSecurityEx PdfReader reader = new PdfReader(src); PdfSigner signer = new PdfSigner(reader, FileUtil.getFileOutputStream(dest), new StampingProperties()); - signer.setCertificationLevel(PdfSigner.NOT_CERTIFIED); - - signer.setFieldName("Signature1"); - signer + SignerProperties signerProperties = new SignerProperties() + .setFieldName("Signature1") + .setCertificationLevel(AccessPermissions.UNSPECIFIED) .setReason("Test 1") - .setLocation("TestCity") - .setSignatureAppearance(new SignatureFieldAppearance(signer.getFieldName()) + .setLocation("TestCity"); + signer.setSignerProperties(signerProperties); + signerProperties.setSignatureAppearance(new SignatureFieldAppearance(SignerProperties.IGNORED_ID) .setContent("Verified and signed by me.")); signer.getSignatureField().setReuseAppearance(false); @@ -283,7 +301,7 @@ public void signExistingNotMergedFieldNotReusedAPTest() throws GeneralSecurityEx signer.signDetached(new BouncyCastleDigest(), pks, chain, null, null, null, 0, PdfSigner.CryptoStandard.CADES); - Assert.assertNull(new CompareTool().compareVisually( + Assertions.assertNull(new CompareTool().compareVisually( dest, SOURCE_FOLDER + "cmp_" + fileName, DESTINATION_FOLDER, "diff_")); } @@ -298,14 +316,15 @@ public void signExistingNotMergedFieldReusedAPTest() throws GeneralSecurityExcep PdfReader reader = new PdfReader(src); PdfSigner signer = new PdfSigner(reader, FileUtil.getFileOutputStream(dest), new StampingProperties()); - signer.setCertificationLevel(PdfSigner.NOT_CERTIFIED); - - signer.setFieldName("Signature1"); - SignatureFieldAppearance appearance = new SignatureFieldAppearance(signer.getFieldName()) + SignerProperties signerProperties = new SignerProperties() + .setCertificationLevel(AccessPermissions.UNSPECIFIED) + .setFieldName("Signature1"); + signer.setSignerProperties(signerProperties); + SignatureFieldAppearance appearance = new SignatureFieldAppearance(SignerProperties.IGNORED_ID) .setContent("SIGNED") .setFontColor(ColorConstants.GREEN); appearance.setProperty(Property.VERTICAL_ALIGNMENT, VerticalAlignment.MIDDLE); - signer.setReason("Test 1") + signerProperties.setReason("Test 1") .setLocation("TestCity") .setSignatureAppearance(appearance); signer.getSignatureField().setReuseAppearance(true); @@ -315,7 +334,7 @@ public void signExistingNotMergedFieldReusedAPTest() throws GeneralSecurityExcep signer.signDetached(new BouncyCastleDigest(), pks, chain, null, null, null, 0, PdfSigner.CryptoStandard.CADES); - Assert.assertNull(new CompareTool().compareVisually( + Assertions.assertNull(new CompareTool().compareVisually( dest, SOURCE_FOLDER + "cmp_" + fileName, DESTINATION_FOLDER, "diff_")); } @@ -330,12 +349,13 @@ public void signExistingNotMergedFieldReusedAPEntryNDicTest() PdfReader reader = new PdfReader(src); PdfSigner signer = new PdfSigner(reader, FileUtil.getFileOutputStream(dest), new StampingProperties()); - signer.setCertificationLevel(PdfSigner.NOT_CERTIFIED); - - signer.setFieldName("Signature1"); - signer.setReason("Test 1") - .setLocation("TestCity") - .setSignatureAppearance(new SignatureFieldAppearance(signer.getFieldName()) + SignerProperties signerProperties = new SignerProperties() + .setCertificationLevel(AccessPermissions.UNSPECIFIED) + .setFieldName("Signature1") + .setReason("Test 1") + .setLocation("TestCity"); + signer.setSignerProperties(signerProperties); + signerProperties.setSignatureAppearance(new SignatureFieldAppearance(SignerProperties.IGNORED_ID) .setContent("Verified and signed by me.")); signer.getSignatureField().setReuseAppearance(true); @@ -344,186 +364,42 @@ public void signExistingNotMergedFieldReusedAPEntryNDicTest() signer.signDetached(new BouncyCastleDigest(), pks, chain, null, null, null, 0, PdfSigner.CryptoStandard.CADES); - Assert.assertNull(new CompareTool().compareVisually( + Assertions.assertNull(new CompareTool().compareVisually( dest, SOURCE_FOLDER + "cmp_" + fileName, DESTINATION_FOLDER, "diff_")); } @Test - public void layer0Test() throws IOException, GeneralSecurityException { - String src = SOURCE_FOLDER + "simpleDocument.pdf"; - String fileName = "layer0Test.pdf"; - String dest = DESTINATION_FOLDER + fileName; - - PdfSigner signer = new PdfSigner(new PdfReader(src), FileUtil.getFileOutputStream(dest), new StampingProperties()); - - // Creating the appearance - PdfSignatureAppearance appearance = signer.getSignatureAppearance(); - signer.setFieldName("Signature1"); - - Rectangle rect = new Rectangle(0, 600, 100, 100); - appearance.setPageRect(rect); - // If we do not set any text, the text will be generated and the current date will be used, - // which we want to avoid because of visual comparison - appearance.setLayer2Text("Hello"); - - PdfFormXObject layer0 = appearance.getLayer0(); - - // Draw red rectangle with blue border - new PdfCanvas(layer0, signer.getDocument()) - .saveState() - .setFillColor(ColorConstants.RED) - .setStrokeColor(ColorConstants.BLUE) - .rectangle(0, 0, 100, 100) - .fillStroke() - .restoreState(); - - // Get the same layer once more, so that the logic when n0 is not null is triggered - layer0 = appearance.getLayer0(); - - // Draw yellow circle with black border - new PdfCanvas(layer0, signer.getDocument()) - .saveState() - .setFillColor(ColorConstants.YELLOW) - .setStrokeColor(ColorConstants.BLACK) - .circle(50, 50, 50) - .fillStroke() - .restoreState(); - - // Signing - IExternalSignature pks = new PrivateKeySignature(pk, DigestAlgorithms.SHA256, - FACTORY.getProviderName()); - signer.signDetached(new BouncyCastleDigest(), pks, chain, null, null, null, 0, PdfSigner.CryptoStandard.CADES); - - compareSignatureAppearances(dest, SOURCE_FOLDER + "cmp_" + fileName); - } - - @Test - public void layer0WithImageTest() throws IOException, GeneralSecurityException { - String src = SOURCE_FOLDER + "simpleDocument.pdf"; - String fileName = "layer0WithImageTest.pdf"; - String dest = DESTINATION_FOLDER + fileName; - - PdfSigner signer = new PdfSigner(new PdfReader(src), FileUtil.getFileOutputStream(dest), new StampingProperties()); - - // Creating the appearance - PdfSignatureAppearance appearance = signer.getSignatureAppearance(); - appearance.setImage(ImageDataFactory.create(SOURCE_FOLDER + "itext.png")); - signer.setFieldName("Signature1"); - - Rectangle rect = new Rectangle(0, 600, 100, 100); - appearance.setPageRect(rect); - // If we do not set any text, the text will be generated and the current date will be used, - // which we want to avoid because of visual comparison - appearance.setLayer2Text("Hello"); - - // Signing - IExternalSignature pks = new PrivateKeySignature(pk, DigestAlgorithms.SHA256, - FACTORY.getProviderName()); - signer.signDetached(new BouncyCastleDigest(), pks, chain, null, null, null, 0, PdfSigner.CryptoStandard.CADES); - - compareSignatureAppearances(dest, SOURCE_FOLDER + "cmp_" + fileName); - } - - @Test - public void layer0WithImageAndPositiveImageScaleTest() throws IOException, GeneralSecurityException { - String src = SOURCE_FOLDER + "simpleDocument.pdf"; - String fileName = "layer0WithImageAndPositiveImageScaleTest.pdf"; - String dest = DESTINATION_FOLDER + fileName; - - PdfSigner signer = new PdfSigner(new PdfReader(src), FileUtil.getFileOutputStream(dest), new StampingProperties()); - - // Creating the appearance - PdfSignatureAppearance appearance = signer.getSignatureAppearance(); - appearance.setImage(ImageDataFactory.create(SOURCE_FOLDER + "itext.png")); - appearance.setImageScale(1.5F); - signer.setFieldName("Signature1"); - - Rectangle rect = new Rectangle(0, 600, 100, 100); - appearance.setPageRect(rect); - // If we do not set any text, the text will be generated and the current date will be used, - // which we want to avoid because of visual comparison - appearance.setLayer2Text("Hello"); - - // Signing - IExternalSignature pks = new PrivateKeySignature(pk, DigestAlgorithms.SHA256, - FACTORY.getProviderName()); - signer.signDetached(new BouncyCastleDigest(), pks, chain, null, null, null, 0, PdfSigner.CryptoStandard.CADES); - - compareSignatureAppearances(dest, SOURCE_FOLDER + "cmp_" + fileName); - } - - @Test - public void layer0WithImageAndNegativeImageScaleTest() throws IOException, GeneralSecurityException { - String src = SOURCE_FOLDER + "simpleDocument.pdf"; - String fileName = "layer0WithImageAndNegativeImageScale.pdf"; - String dest = DESTINATION_FOLDER + fileName; - - PdfSigner signer = new PdfSigner(new PdfReader(src), FileUtil.getFileOutputStream(dest), new StampingProperties()); - - // Creating the appearance - PdfSignatureAppearance appearance = signer.getSignatureAppearance(); - appearance.setImage(ImageDataFactory.create(SOURCE_FOLDER + "itext.png")); - appearance.setImageScale(-15F); - signer.setFieldName("Signature1"); - - Rectangle rect = new Rectangle(0, 600, 100, 100); - appearance.setPageRect(rect); - // If we do not set any text, the text will be generated and the current date will be used, - // which we want to avoid because of visual comparison - appearance.setLayer2Text("Hello"); - - // Signing - IExternalSignature pks = new PrivateKeySignature(pk, DigestAlgorithms.SHA256, - FACTORY.getProviderName()); - signer.signDetached(new BouncyCastleDigest(), pks, chain, null, null, null, 0, PdfSigner.CryptoStandard.CADES); - - compareSignatureAppearances(dest, SOURCE_FOLDER + "cmp_" + fileName); - } - - @Test - public void layer2Test() throws IOException, GeneralSecurityException { - String src = SOURCE_FOLDER + "simpleDocument.pdf"; - String fileName = "layer2Test.pdf"; - String dest = DESTINATION_FOLDER + fileName; - - PdfSigner signer = new PdfSigner(new PdfReader(src), FileUtil.getFileOutputStream(dest), new StampingProperties()); - - // Creating the appearance - PdfSignatureAppearance appearance = signer.getSignatureAppearance(); - signer.setFieldName("Signature1"); - - Rectangle rect = new Rectangle(0, 600, 100, 100); - appearance.setPageRect(rect); - - PdfFormXObject layer2 = appearance.getLayer2(); - - // Draw red rectangle with blue border - new PdfCanvas(layer2, signer.getDocument()) - .saveState() - .setFillColor(ColorConstants.RED) - .setStrokeColor(ColorConstants.BLUE) - .rectangle(0, 0, 100, 100) - .fillStroke() - .restoreState(); - - // Get the same layer once more, so that the logic when n2 is not null is triggered - layer2 = appearance.getLayer2(); - - // Draw yellow circle with black border - new PdfCanvas(layer2, signer.getDocument()) - .saveState() - .setFillColor(ColorConstants.YELLOW) - .setStrokeColor(ColorConstants.BLACK) - .circle(50, 50, 50) - .fillStroke() - .restoreState(); - - // Signing - IExternalSignature pks = new PrivateKeySignature(pk, DigestAlgorithms.SHA256, - FACTORY.getProviderName()); - signer.signDetached(new BouncyCastleDigest(), pks, chain, null, null, null, 0, PdfSigner.CryptoStandard.CADES); + public void backgroundImageTest() throws IOException, InterruptedException { + String outPdf = DESTINATION_FOLDER + "signatureFieldBackground.pdf"; + String cmpPdf = SOURCE_FOLDER + "cmp_signatureFieldBackground.pdf"; + + try (Document document = new Document(new PdfDocument(new PdfWriter(outPdf)))) { + SignatureFieldAppearance field1 = new SignatureFieldAppearance("field1"); + field1.setProperty(FormProperty.FORM_FIELD_FLATTEN, true); + field1.setContent("scale -1").setFontColor(ColorConstants.GREEN).setFontSize(50) + .setBorder(new SolidBorder(ColorConstants.RED, 10)).setHeight(200).setWidth(300) + .setProperty(Property.TEXT_ALIGNMENT, TextAlignment.CENTER); + applyBackgroundImage(field1, ImageDataFactory.create(SOURCE_FOLDER + "1.png"), -1); + document.add(field1); + + SignatureFieldAppearance field2 = new SignatureFieldAppearance("field2"); + field2.setProperty(FormProperty.FORM_FIELD_FLATTEN, true); + field2.setContent("scale 0").setFontColor(ColorConstants.GREEN).setFontSize(50) + .setBorder(new SolidBorder(ColorConstants.YELLOW, 10)).setHeight(200).setWidth(300) + .setProperty(Property.TEXT_ALIGNMENT, TextAlignment.CENTER); + applyBackgroundImage(field2, ImageDataFactory.create(SOURCE_FOLDER + "1.png"), 0); + document.add(field2); + + SignatureFieldAppearance field3 = new SignatureFieldAppearance("field3"); + field3.setProperty(FormProperty.FORM_FIELD_FLATTEN, true); + field3.setContent("scale 0.5").setFontColor(ColorConstants.GREEN).setFontSize(50) + .setBorder(new SolidBorder(ColorConstants.GREEN, 10)).setHeight(200).setWidth(300) + .setProperty(Property.TEXT_ALIGNMENT, TextAlignment.CENTER); + applyBackgroundImage(field3, ImageDataFactory.create(SOURCE_FOLDER + "1.png"), 0.5f); + document.add(field3); + } - compareSignatureAppearances(dest, SOURCE_FOLDER + "cmp_" + fileName); + Assertions.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER)); } @Test @@ -541,12 +417,14 @@ public void createAndSignSignatureFieldTest() throws IOException, GeneralSecurit document.close(); PdfSigner signer = new PdfSigner(new PdfReader(unsignedDoc), FileUtil.getFileOutputStream(dest), new StampingProperties()); - signer.setFieldName(fieldName); + SignerProperties signerProperties = new SignerProperties().setFieldName(fieldName); + signer.setSignerProperties(signerProperties); // Creating the appearance - SignatureFieldAppearance appearance = new SignatureFieldAppearance(fieldName) + SignatureFieldAppearance appearance = new SignatureFieldAppearance(SignerProperties.IGNORED_ID) .setContent("Test signature field appearance. Test signature field appearance. " + "Test signature field appearance. Test signature field appearance"); - signer.setReason("Appearance is tested") + signerProperties + .setReason("Appearance is tested") .setLocation("TestCity") .setSignatureAppearance(appearance); @@ -564,13 +442,14 @@ public void signExistedSignatureFieldTest() throws IOException, GeneralSecurityE String dest = DESTINATION_FOLDER + fileName; PdfSigner signer = new PdfSigner(new PdfReader(src), FileUtil.getFileOutputStream(dest), new StampingProperties()); - signer.setFieldName("Signature1"); + SignerProperties signerProperties = new SignerProperties().setFieldName("Signature1"); + signer.setSignerProperties(signerProperties); // Creating the appearance - SignatureFieldAppearance appearance = new SignatureFieldAppearance(signer.getFieldName()) + SignatureFieldAppearance appearance = new SignatureFieldAppearance(SignerProperties.IGNORED_ID) .setContent("Test signature field appearance. Test signature field appearance. " + "Test signature field appearance. Test signature field appearance"); - signer.setReason("Appearance is tested") + signerProperties.setReason("Appearance is tested") .setLocation("TestCity") .setSignatureAppearance(appearance); signer.getSignatureField().setReuseAppearance(true); @@ -588,39 +467,14 @@ public void reuseAppearanceTest() throws GeneralSecurityException, // Field is not merged with widget and has /P key String src = SOURCE_FOLDER + "emptyFieldNotMerged.pdf"; String fileName = "reuseAppearance.pdf"; - testReuseAppearance(src, fileName, false, true, false); - } - - @Test - public void reuseAppearanceDeprecatedTest() throws GeneralSecurityException, - IOException, InterruptedException { - // Field is not merged with widget and has /P key - String src = SOURCE_FOLDER + "emptyFieldNotMerged.pdf"; - String fileName = "reuseAppearanceDeprecated.pdf"; - testReuseAppearance(src, fileName, true, false, true); - } - - @Test - public void reuseAppearanceCompatibilityTest() throws GeneralSecurityException, - IOException, InterruptedException { - // Field is not merged with widget and has /P key - String src = SOURCE_FOLDER + "emptyFieldNotMerged.pdf"; - String fileName = "reuseAppearanceCompatibility.pdf"; - testReuseAppearance(src, fileName, true, true, false); + testReuseAppearance(src, fileName); } @Test public void fieldLayersTest() throws IOException, GeneralSecurityException { String src = SOURCE_FOLDER + "noSignatureField.pdf"; String fileName = "fieldLayersTest.pdf"; - testLayers(src, fileName, false); - } - - @Test - public void deprecatedLayersTest() throws IOException, GeneralSecurityException { - String src = SOURCE_FOLDER + "noSignatureField.pdf"; - String fileName = "deprecatedLayersTest.pdf"; - testLayers(src, fileName, true); + testLayers(src, fileName); } @Test @@ -632,15 +486,19 @@ public void signatureFieldAppearanceTest() throws IOException, GeneralSecurityEx String fieldName = "Signature1"; PdfSigner signer = new PdfSigner(new PdfReader(src), FileUtil.getFileOutputStream(dest), new StampingProperties()); - signer.setFieldName(fieldName); - SignatureFieldAppearance appearance = new SignatureFieldAppearance(fieldName) + SignerProperties signerProperties = new SignerProperties().setFieldName(fieldName); + signer.setSignerProperties(signerProperties); + SignatureFieldAppearance appearance = new SignatureFieldAppearance(SignerProperties.IGNORED_ID) .setContent("Signature field") .setBackgroundColor(ColorConstants.GREEN) .setBorder(new SolidBorder(ColorConstants.LIGHT_GRAY, 3)) .setFontColor(ColorConstants.DARK_GRAY) .setFontSize(20) .setTextAlignment(TextAlignment.CENTER); - signer.setPageRect(new Rectangle(250, 500, 100, 100)).setReason("Test 1").setLocation("TestCity") + signerProperties + .setPageRect(new Rectangle(250, 500, 100, 100)) + .setReason("Test 1") + .setLocation("TestCity") .setSignatureAppearance(appearance); // Signing @@ -648,8 +506,8 @@ public void signatureFieldAppearanceTest() throws IOException, GeneralSecurityEx FACTORY.getProviderName()); signer.signDetached(new BouncyCastleDigest(), pks, chain, null, null, null, 0, PdfSigner.CryptoStandard.CADES); - Assert.assertNull(SignaturesCompareTool.compareSignatures(dest, cmp)); - Assert.assertNull(new CompareTool().compareVisually(dest, cmp, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(SignaturesCompareTool.compareSignatures(dest, cmp)); + Assertions.assertNull(new CompareTool().compareVisually(dest, cmp, DESTINATION_FOLDER, "diff_")); } @Test @@ -660,20 +518,24 @@ public void emptySignatureAppearanceTest() throws GeneralSecurityException, IOEx Rectangle rect = new Rectangle(36, 648, 200, 100); String fieldName = "Signature1"; - SignatureFieldAppearance appearance = new SignatureFieldAppearance(fieldName); + SignatureFieldAppearance appearance = new SignatureFieldAppearance(SignerProperties.IGNORED_ID); PdfSigner signer = new PdfSigner(new PdfReader(srcFile), FileUtil.getFileOutputStream(outPdf), new StampingProperties()); - signer.setCertificationLevel(PdfSigner.NOT_CERTIFIED); - signer.setFieldName(fieldName); - signer.setReason("test reason").setLocation("test location").setSignatureAppearance(appearance); - signer.setPageRect(rect); + SignerProperties signerProperties = new SignerProperties() + .setCertificationLevel(AccessPermissions.UNSPECIFIED) + .setFieldName(fieldName) + .setReason("test reason") + .setLocation("test location") + .setSignatureAppearance(appearance) + .setPageRect(rect); + signer.setSignerProperties(signerProperties); // Creating the signature IExternalSignature pks = new PrivateKeySignature(pk, DigestAlgorithms.SHA256, FACTORY.getProviderName()); signer.signDetached(new BouncyCastleDigest(), pks, chain, null, null, null, 0, PdfSigner.CryptoStandard.CADES); - Assert.assertNull(new CompareTool().compareVisually(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); - Assert.assertNull(SignaturesCompareTool.compareSignatures(outPdf, cmpPdf)); + Assertions.assertNull(new CompareTool().compareVisually(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(SignaturesCompareTool.compareSignatures(outPdf, cmpPdf)); } private static void compareSignatureAppearances(String outPdf, String cmpPdf) throws IOException { @@ -686,43 +548,47 @@ private static void compareSignatureAppearances(String outPdf, String cmpPdf) th PdfDictionary cmpN = (PdfDictionary) PdfFormCreator.getAcroForm(cmpDoc, false) .getField("Signature1").getPdfObject() .getAsDictionary(PdfName.AP).get(PdfName.N).getIndirectReference().getRefersTo(); - Assert.assertNull(new CompareTool().compareDictionariesStructure(outN, cmpN)); + Assertions.assertNull(new CompareTool().compareDictionariesStructure(outN, cmpN)); } } } - private void testReuseAppearance(String src, String fileName, boolean useDeprecated, boolean fieldReuseAp, - boolean deprecatedReuseAp) throws IOException, GeneralSecurityException, InterruptedException { + private void testReuseAppearance(String src, String fileName) + throws IOException, GeneralSecurityException, InterruptedException { String cmp = SOURCE_FOLDER + "cmp_" + fileName; String dest = DESTINATION_FOLDER + fileName; String fieldName = "Signature1"; PdfSigner signer = new PdfSigner(new PdfReader(src), FileUtil.getFileOutputStream(dest), new StampingProperties()); - signer.setFieldName(fieldName); - signer.getSignatureField().setReuseAppearance(fieldReuseAp); - if (useDeprecated) { - signer.getSignatureAppearance().setReuseAppearance(deprecatedReuseAp); - } + SignerProperties signerProperties = new SignerProperties().setFieldName(fieldName); + signer.setSignerProperties(signerProperties); + signer.getSignatureField().setReuseAppearance(true); - signer.setReason("Test 1").setLocation("TestCity") - .setSignatureAppearance(new SignatureFieldAppearance(fieldName) + signerProperties + .setReason("Test 1") + .setLocation("TestCity") + .setSignatureAppearance(new SignatureFieldAppearance(SignerProperties.IGNORED_ID) .setContent("New appearance").setFontColor(ColorConstants.GREEN)); IExternalSignature pks = new PrivateKeySignature(pk, DigestAlgorithms.SHA256, FACTORY.getProviderName()); signer.signDetached(new BouncyCastleDigest(), pks, chain, null, null, null, 0, PdfSigner.CryptoStandard.CADES); - Assert.assertNull(new CompareTool().compareVisually(dest, cmp, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareVisually(dest, cmp, DESTINATION_FOLDER, "diff_")); } - private void testLayers(String src, String fileName, boolean useDeprecated) + private void testLayers(String src, String fileName) throws IOException, GeneralSecurityException { String dest = DESTINATION_FOLDER + fileName; String fieldName = "Signature1"; PdfSigner signer = new PdfSigner(new PdfReader(src), FileUtil.getFileOutputStream(dest), new StampingProperties()); - signer.setFieldName(fieldName); - signer.setPageRect(new Rectangle(250, 500, 100, 100)).setReason("Test 1").setLocation("TestCity") - .setSignatureAppearance(new SignatureFieldAppearance(fieldName)); + SignerProperties signerProperties = new SignerProperties() + .setFieldName(fieldName) + .setPageRect(new Rectangle(250, 500, 100, 100)) + .setReason("Test 1") + .setLocation("TestCity") + .setSignatureAppearance(new SignatureFieldAppearance(SignerProperties.IGNORED_ID)); + signer.setSignerProperties(signerProperties); PdfFormXObject layer0 = new PdfFormXObject(new Rectangle(0, 0, 100, 100)); // Draw pink rectangle with blue border @@ -746,31 +612,6 @@ private void testLayers(String src, String fileName, boolean useDeprecated) signer.getSignatureField().setBackgroundLayer(layer0).setSignatureAppearanceLayer(layer2); - if (useDeprecated) { - // Creating the appearance - PdfSignatureAppearance appearance = signer.getSignatureAppearance(); - - PdfFormXObject deprecatedLayer0 = appearance.getLayer0(); - // Draw yellow rectangle with gray border - new PdfCanvas(deprecatedLayer0, signer.getDocument()) - .saveState() - .setFillColor(ColorConstants.YELLOW) - .setStrokeColor(ColorConstants.DARK_GRAY) - .rectangle(0, 0, 100, 100) - .fillStroke() - .restoreState(); - - PdfFormXObject deprecatedLayer2 = appearance.getLayer2(); - // Draw pink circle with blue border - new PdfCanvas(deprecatedLayer2, signer.getDocument()) - .saveState() - .setFillColor(ColorConstants.PINK) - .setStrokeColor(ColorConstants.BLUE) - .circle(50, 50, 50) - .fillStroke() - .restoreState(); - } - // Signing IExternalSignature pks = new PrivateKeySignature(pk, DigestAlgorithms.SHA256, FACTORY.getProviderName()); @@ -779,25 +620,42 @@ private void testLayers(String src, String fileName, boolean useDeprecated) compareSignatureAppearances(dest, SOURCE_FOLDER + "cmp_" + fileName); } - private void testSignatureOnRotatedPage(int pageNum, PdfSignatureAppearance.RenderingMode renderingMode, - StringBuilder assertionResults) throws IOException, GeneralSecurityException, InterruptedException { - String fileName = "signaturesOnRotatedPages" + pageNum + "_mode_" + renderingMode.name() + ".pdf"; + private void testSignatureOnRotatedPage(int pageNum, boolean useDescription, boolean useSignerName, + boolean useImage, StringBuilder assertionResults) + throws IOException, GeneralSecurityException, InterruptedException { + + String fileName = "signaturesOnRotatedPages" + pageNum + "_mode_"; String src = SOURCE_FOLDER + "documentWithRotatedPages.pdf"; - String dest = DESTINATION_FOLDER + fileName; + String signatureName = "Signature1"; + SignatureFieldAppearance appearance = new SignatureFieldAppearance(SignerProperties.IGNORED_ID); + String description = "Digitally signed by Test User. All rights reserved. Take care!"; + if (useImage) { + if (useDescription) { + appearance.setContent(description, ImageDataFactory.create(SOURCE_FOLDER + "itext.png")); + fileName += "GRAPHIC_AND_DESCRIPTION.pdf"; + } else { + appearance.setContent(ImageDataFactory.create(SOURCE_FOLDER + "itext.png")); + fileName += "GRAPHIC.pdf"; + } + } else if (useSignerName) { + appearance.setContent("signerName", description); + fileName += "NAME_AND_DESCRIPTION.pdf"; + } else { + appearance.setContent(description); + fileName += "DESCRIPTION.pdf"; + } + + String dest = DESTINATION_FOLDER + fileName; PdfSigner signer = new PdfSigner(new PdfReader(src), FileUtil.getFileOutputStream(dest), new StampingProperties().useAppendMode()); - - PdfSignatureAppearance appearance = signer.getSignatureAppearance(); - - appearance - .setLayer2Text("Digitally signed by Test User. All rights reserved. Take care!") + SignerProperties signerProperties = new SignerProperties() + .setFieldName(signatureName) .setPageRect(new Rectangle(100, 100, 100, 50)) - .setRenderingMode(renderingMode) - .setSignatureGraphic(ImageDataFactory.create(SOURCE_FOLDER + "itext.png")) - .setPageNumber(pageNum); - - signer.setCertificationLevel(PdfSigner.NOT_CERTIFIED); + .setPageNumber(pageNum) + .setSignatureAppearance(appearance) + .setCertificationLevel(AccessPermissions.UNSPECIFIED); + signer.setSignerProperties(signerProperties); IExternalSignature pks = new PrivateKeySignature(pk, DigestAlgorithms.SHA256, FACTORY.getProviderName()); @@ -818,27 +676,64 @@ private void testSignatureOnRotatedPage(int pageNum, PdfSignatureAppearance.Rend } } - private void testSignatureAppearanceAutoscale(String dest, Rectangle rect, - PdfSignatureAppearance.RenderingMode renderingMode) throws IOException, GeneralSecurityException { + private void testSignatureAppearanceAutoscale(String dest, Rectangle rect, String signerName, ImageData image) + throws IOException, GeneralSecurityException { String src = SOURCE_FOLDER + "simpleDocument.pdf"; PdfSigner signer = new PdfSigner(new PdfReader(src), FileUtil.getFileOutputStream(dest), new StampingProperties()); + SignerProperties signerProperties = new SignerProperties().setFieldName("Signature1"); + signer.setSignerProperties(signerProperties); // Creating the appearance - signer.getSignatureAppearance() - .setLayer2FontSize(0) + SignatureFieldAppearance appearance = new SignatureFieldAppearance(SignerProperties.IGNORED_ID); + if (image != null) { + appearance.setContent(new SignedAppearanceText(), image); + } else if (signerName != null) { + appearance.setContent(signerName, new SignedAppearanceText()); + } else { + appearance.setContent(new SignedAppearanceText()); + } + appearance.setFontSize(0); + signerProperties .setReason("Test 1") .setLocation("TestCity") .setPageRect(rect) - .setRenderingMode(renderingMode) - .setSignatureGraphic(ImageDataFactory.create(SOURCE_FOLDER + "itext.png")); + .setSignatureAppearance(appearance); - signer.setFieldName("Signature1"); // Creating the signature IExternalSignature pks = new PrivateKeySignature(pk, DigestAlgorithms.SHA256, FACTORY.getProviderName()); signer.signDetached(new BouncyCastleDigest(), pks, chain, null, null, null, 0, PdfSigner.CryptoStandard.CADES); } + void applyBackgroundImage(SignatureFieldAppearance appearance, ImageData image, float imageScale) { + if (image != null) { + BackgroundRepeat repeat = new BackgroundRepeat(BackgroundRepeat.BackgroundRepeatValue.NO_REPEAT); + BackgroundPosition position = new BackgroundPosition() + .setPositionX(BackgroundPosition.PositionX.CENTER) + .setPositionY(BackgroundPosition.PositionY.CENTER); + BackgroundSize size = new BackgroundSize(); + final float EPS = 1e-5f; + if (Math.abs(imageScale) < EPS) { + size.setBackgroundSizeToValues(UnitValue.createPercentValue(100), + UnitValue.createPercentValue(100)); + } else { + if (imageScale < 0) { + size.setBackgroundSizeToContain(); + } else { + size.setBackgroundSizeToValues( + UnitValue.createPointValue(imageScale * image.getWidth()), + UnitValue.createPointValue(imageScale * image.getHeight())); + } + } + appearance.setBackgroundImage(new BackgroundImage.Builder() + .setImage(new PdfImageXObject(image)) + .setBackgroundSize(size) + .setBackgroundRepeat(repeat) + .setBackgroundPosition(position) + .build()); + } + } + private static void assertAppearanceFontSize(String filename, float expectedFontSize) throws IOException { PdfDocument pdfDocument = new PdfDocument(new PdfReader(filename)); PdfAcroForm acroForm = PdfFormCreator.getAcroForm(pdfDocument, false); @@ -855,8 +750,8 @@ private static void assertAppearanceFontSize(String filename, float expectedFont } } float foundFontSize = Float.parseFloat(fontSize); - Assert.assertTrue(MessageFormatUtil.format("Font size: expected {0}, found {1}", - expectedFontSize, fontSize), Math.abs(foundFontSize - expectedFontSize) < 0.1 * expectedFontSize); + Assertions.assertTrue(Math.abs(foundFontSize - expectedFontSize) < 0.1 * expectedFontSize, + MessageFormatUtil.format("Font size: expected {0}, found {1}", expectedFontSize, fontSize)); } private static Map> getIgnoredAreaTestMap(Rectangle ignoredArea) { diff --git a/sign/src/test/java/com/itextpdf/signatures/sign/SignedAppearanceTextTest.java b/sign/src/test/java/com/itextpdf/signatures/sign/SignedAppearanceTextTest.java index e0b5bc1dba..e2a9838e61 100644 --- a/sign/src/test/java/com/itextpdf/signatures/sign/SignedAppearanceTextTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/sign/SignedAppearanceTextTest.java @@ -35,11 +35,12 @@ This file is part of the iText (R) project. import com.itextpdf.io.image.ImageDataFactory; import com.itextpdf.io.logs.IoLogMessageConstant; import com.itextpdf.kernel.colors.ColorConstants; +import com.itextpdf.kernel.crypto.DigestAlgorithms; import com.itextpdf.kernel.font.PdfFont; import com.itextpdf.kernel.font.PdfFontFactory; import com.itextpdf.kernel.font.PdfFontFactory.EmbeddingStrategy; import com.itextpdf.kernel.geom.Rectangle; -import com.itextpdf.kernel.pdf.PdfAConformanceLevel; +import com.itextpdf.kernel.pdf.PdfAConformance; import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfOutputIntent; import com.itextpdf.kernel.pdf.PdfReader; @@ -54,17 +55,18 @@ This file is part of the iText (R) project. import com.itextpdf.pdfa.PdfADocument; import com.itextpdf.pdfa.exceptions.PdfAConformanceException; import com.itextpdf.pdfa.exceptions.PdfaExceptionMessageConstant; +import com.itextpdf.signatures.AccessPermissions; import com.itextpdf.signatures.BouncyCastleDigest; -import com.itextpdf.signatures.DigestAlgorithms; import com.itextpdf.signatures.IExternalSignature; import com.itextpdf.signatures.PdfSigner; import com.itextpdf.signatures.PrivateKeySignature; +import com.itextpdf.signatures.SignerProperties; +import com.itextpdf.signatures.TimestampConstants; import com.itextpdf.signatures.testutils.PemFileHelper; import com.itextpdf.signatures.testutils.SignaturesCompareTool; import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.BouncyCastleIntegrationTest; import com.itextpdf.test.pdfa.VeraPdfValidator; // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) import java.io.IOException; @@ -74,16 +76,18 @@ This file is part of the iText (R) project. import java.security.cert.Certificate; import java.security.cert.CertificateException; import java.util.Arrays; +import java.util.Calendar; import java.util.HashMap; import java.util.List; import java.util.Map; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; -@Category(BouncyCastleIntegrationTest.class) +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +@Tag("BouncyCastleIntegrationTest") public class SignedAppearanceTextTest extends ExtendedITextTest { private static final IBouncyCastleFactory FACTORY = BouncyCastleFactoryCreator.getFactory(); @@ -99,13 +103,13 @@ public class SignedAppearanceTextTest extends ExtendedITextTest { private Certificate[] chain; private PrivateKey pk; - @BeforeClass + @BeforeAll public static void before() { Security.addProvider(FACTORY.getProvider()); createOrClearDestinationFolder(DESTINATION_FOLDER); } - @Before + @BeforeEach public void init() throws IOException, CertificateException, AbstractPKCSException, AbstractOperatorCreationException { pk = PemFileHelper.readFirstKey(CERTS_SRC + "signCertRsa01.pem", PASSWORD); @@ -121,14 +125,49 @@ public void defaultSignedAppearanceTextTest() throws GeneralSecurityException, I Rectangle rect = new Rectangle(36, 648, 200, 100); String fieldName = "Signature1"; - SignatureFieldAppearance appearance = new SignatureFieldAppearance(fieldName) + SignatureFieldAppearance appearance = new SignatureFieldAppearance(SignerProperties.IGNORED_ID) .setContent(new SignedAppearanceText()); sign(srcFile, fieldName, outPdf, "Test 1", "TestCity 1", rect, appearance); - Assert.assertNull(new CompareTool().compareVisually(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_", + Assertions.assertNull(new CompareTool().compareVisually(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_", + getTestMap(new Rectangle(36, 676, 200, 15)))); + + Assertions.assertNull(SignaturesCompareTool.compareSignatures(outPdf, cmpPdf)); + } + + @Test + public void noReasonLocationSignDateInAppearanceTextTest() throws GeneralSecurityException, IOException, InterruptedException { + String srcFile = SOURCE_FOLDER + "simpleDocument.pdf"; + String cmpPdf = SOURCE_FOLDER + "cmp_noReasonLocationSignDateInAppearanceText.pdf"; + String outPdf = DESTINATION_FOLDER + "noReasonLocationSignDateInAppearanceText.pdf"; + + Rectangle rect = new Rectangle(36, 648, 200, 100); + + String fieldName = "Signature1"; + SignatureFieldAppearance appearance = new SignatureFieldAppearance(SignerProperties.IGNORED_ID) + .setContent(new SignedAppearanceText().setReasonLine(null).setLocationLine(null)); + + PdfSigner signer = new PdfSigner(new PdfReader(srcFile), FileUtil.getFileOutputStream(outPdf), + new StampingProperties()); + + SignerProperties signerProperties = new SignerProperties() + .setCertificationLevel(AccessPermissions.UNSPECIFIED) + .setFieldName(fieldName) + .setReason("Test 1") + .setLocation("TestCity 1") + .setSignatureAppearance(appearance) + .setClaimedSignDate((Calendar) TimestampConstants.UNDEFINED_TIMESTAMP_DATE) + .setPageRect(rect); + signer.setSignerProperties(signerProperties); + + // Creating the signature + IExternalSignature pks = new PrivateKeySignature(pk, DigestAlgorithms.SHA256, FACTORY.getProviderName()); + signer.signDetached(new BouncyCastleDigest(), pks, chain, null, null, null, 0, PdfSigner.CryptoStandard.CADES); + + Assertions.assertNull(new CompareTool().compareVisually(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_", getTestMap(new Rectangle(36, 676, 200, 15)))); - Assert.assertNull(SignaturesCompareTool.compareSignatures(outPdf, cmpPdf)); + Assertions.assertNull(SignaturesCompareTool.compareSignatures(outPdf, cmpPdf)); } @Test @@ -139,17 +178,17 @@ public void signPDFADocumentWithoutSettingFont() throws IOException { Rectangle rect = new Rectangle(50, 70, 400, 200); String fieldName = "Signature1"; - SignatureFieldAppearance appearance = new SignatureFieldAppearance(fieldName) + SignatureFieldAppearance appearance = new SignatureFieldAppearance(SignerProperties.IGNORED_ID) .setContent(new SignedAppearanceText() .setSignedBy("Test") .setSignDate(DateTimeUtil.getCurrentTimeCalendar()) .setLocationLine("Test City")); String outPdf = DESTINATION_FOLDER + "signPDFADocumentWithoutSettingFont.pdf"; - Exception e = Assert.assertThrows(Exception.class, () -> { + Exception e = Assertions.assertThrows(Exception.class, () -> { sign(srcFile, fieldName, outPdf, "Test 1", "TestCity 1", rect, appearance); }); - Assert.assertEquals(LayoutExceptionMessageConstant.INVALID_FONT_PROPERTY_VALUE, e.getMessage()); + Assertions.assertEquals(LayoutExceptionMessageConstant.INVALID_FONT_PROPERTY_VALUE, e.getMessage()); } @Test @@ -160,7 +199,7 @@ public void signPDFADocumentSettingBadFont() throws IOException { Rectangle rect = new Rectangle(50, 70, 400, 200); String fieldName = "Signature1"; - SignatureFieldAppearance appearance = new SignatureFieldAppearance(fieldName) + SignatureFieldAppearance appearance = new SignatureFieldAppearance(SignerProperties.IGNORED_ID) .setFont(PdfFontFactory.createFont(StandardFonts.COURIER)) .setContent(new SignedAppearanceText() .setSignedBy("Test") @@ -168,10 +207,10 @@ public void signPDFADocumentSettingBadFont() throws IOException { .setLocationLine("Test City")); String outPdf = DESTINATION_FOLDER + "signPDFADocumentBadFont.pdf"; - Exception e = Assert.assertThrows(PdfAConformanceException.class, () -> { + Exception e = Assertions.assertThrows(PdfAConformanceException.class, () -> { sign(srcFile, fieldName, outPdf, "Test 1", "TestCity 1", rect, appearance); }); - Assert.assertEquals(e.getMessage(), + Assertions.assertEquals(e.getMessage(), MessageFormatUtil.format(PdfaExceptionMessageConstant.ALL_THE_FONTS_MUST_BE_EMBEDDED_THIS_ONE_IS_NOT_0, "Courier")); } @@ -181,7 +220,7 @@ public void defaultPdfATextTest() throws GeneralSecurityException, IOException, String srcFile = DESTINATION_FOLDER + "simplePDFADocument.pdf"; createSimplePDFADocument(srcFile).close(); - Assert.assertNull(new VeraPdfValidator().validate(srcFile)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNull(new VeraPdfValidator().validate(srcFile)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) String cmpPdf = SOURCE_FOLDER + "cmp_defaultSignedPDFAAppearanceTextTest.pdf"; String outPdf = DESTINATION_FOLDER + "defaultSignedPDFAAppearanceTextTest.pdf"; @@ -189,7 +228,7 @@ public void defaultPdfATextTest() throws GeneralSecurityException, IOException, PdfFont font = PdfFontFactory.createFont(FONT_FOLDER + "FreeSans.ttf", EmbeddingStrategy.FORCE_EMBEDDED); String fieldName = "Signature1"; - SignatureFieldAppearance appearance = new SignatureFieldAppearance(fieldName) + SignatureFieldAppearance appearance = new SignatureFieldAppearance(SignerProperties.IGNORED_ID) .setFont(font) .setContent(new SignedAppearanceText() .setSignedBy("Test") @@ -198,11 +237,11 @@ public void defaultPdfATextTest() throws GeneralSecurityException, IOException, sign(srcFile, fieldName, outPdf, "Test 1", "TestCity 1", rect, appearance); - Assert.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) - Assert.assertNull(new CompareTool().compareVisually(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_", + Assertions.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNull(new CompareTool().compareVisually(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_", getTestMap(rect))); - Assert.assertNull(SignaturesCompareTool.compareSignatures(outPdf, cmpPdf)); + Assertions.assertNull(SignaturesCompareTool.compareSignatures(outPdf, cmpPdf)); } @@ -233,7 +272,7 @@ public void signPdfAWithFormfieldAlreadyExistingTest() Rectangle rect = new Rectangle(50, 200, 400, 100); PdfFont font1 = PdfFontFactory.createFont(FONT_FOLDER + "FreeSans.ttf", EmbeddingStrategy.FORCE_EMBEDDED); - SignatureFieldAppearance appearance = new SignatureFieldAppearance(fieldName) + SignatureFieldAppearance appearance = new SignatureFieldAppearance(SignerProperties.IGNORED_ID) .setFont(font1) .setContent(new SignedAppearanceText() .setSignedBy("Test") @@ -242,8 +281,8 @@ public void signPdfAWithFormfieldAlreadyExistingTest() sign(srcFile, fieldName, outPdf, "Test 1", "TestCity 1", rect, appearance); - Assert.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) - Assert.assertNull(SignaturesCompareTool.compareSignatures(outPdf, cmpPdf)); + Assertions.assertNull(new VeraPdfValidator().validate(outPdf)); // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) + Assertions.assertNull(SignaturesCompareTool.compareSignatures(outPdf, cmpPdf)); } private static Document createSimplePDFADocument(String filename) throws IOException { @@ -252,7 +291,7 @@ private static Document createSimplePDFADocument(String filename) throws IOExcep PdfOutputIntent outputIntent = new PdfOutputIntent("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", FileUtil.getInputStreamForFile(icmProfile)); PdfDocument document = new PdfADocument(new PdfWriter(filename, writerProperties), - PdfAConformanceLevel.PDF_A_4, + PdfAConformance.PDF_A_4, outputIntent); Document doc = new Document(document); PdfFont font = PdfFontFactory.createFont(FONT_FOLDER + "FreeSans.ttf", EmbeddingStrategy.FORCE_EMBEDDED); @@ -271,14 +310,14 @@ public void defaultSignedAppearanceTextAndSignerTest() throws GeneralSecurityExc Rectangle rect = new Rectangle(36, 648, 200, 100); String fieldName = "Signature2"; - SignatureFieldAppearance appearance = new SignatureFieldAppearance(fieldName) + SignatureFieldAppearance appearance = new SignatureFieldAppearance(SignerProperties.IGNORED_ID) .setContent("", new SignedAppearanceText()); sign(srcFile, fieldName, outPdf, "Test 2", "TestCity 2", rect, appearance); - Assert.assertNull(new CompareTool().compareVisually(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_", + Assertions.assertNull(new CompareTool().compareVisually(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_", getTestMap(new Rectangle(136, 686, 100, 25)))); - Assert.assertNull(SignaturesCompareTool.compareSignatures(outPdf, cmpPdf)); + Assertions.assertNull(SignaturesCompareTool.compareSignatures(outPdf, cmpPdf)); } @Test @@ -292,14 +331,14 @@ public void defaultSignedAppearanceTextWithImageTest() throws GeneralSecurityExc Rectangle rect = new Rectangle(36, 648, 300, 100); String fieldName = "Signature3"; - SignatureFieldAppearance appearance = new SignatureFieldAppearance(fieldName) + SignatureFieldAppearance appearance = new SignatureFieldAppearance(SignerProperties.IGNORED_ID) .setContent(new SignedAppearanceText(), ImageDataFactory.create(imagePath)); sign(srcFile, fieldName, outPdf, "Test 3", "TestCity 3", rect, appearance); - Assert.assertNull(new CompareTool().compareVisually(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_", + Assertions.assertNull(new CompareTool().compareVisually(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_", getTestMap(new Rectangle(186, 681, 150, 36)))); - Assert.assertNull(SignaturesCompareTool.compareSignatures(outPdf, cmpPdf)); + Assertions.assertNull(SignaturesCompareTool.compareSignatures(outPdf, cmpPdf)); } @Test @@ -313,7 +352,7 @@ public void modifiedSignedAppearanceTextTest() throws GeneralSecurityException, String fieldName = "Signature4"; String reason = "Test 4"; String location = "TestCity 4"; - SignatureFieldAppearance appearance = new SignatureFieldAppearance(fieldName) + SignatureFieldAppearance appearance = new SignatureFieldAppearance(SignerProperties.IGNORED_ID) .setContent(new SignedAppearanceText() .setSignedBy(" wrong signer ") .setReasonLine(" Signing reason: " + reason) @@ -321,10 +360,10 @@ public void modifiedSignedAppearanceTextTest() throws GeneralSecurityException, .setSignDate(DateTimeUtil.getCurrentTimeCalendar())); sign(srcFile, fieldName, outPdf, reason, location, rect, appearance); - Assert.assertNull(new CompareTool().compareVisually(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_", + Assertions.assertNull(new CompareTool().compareVisually(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_", getTestMap(new Rectangle(36, 676, 200, 15)))); - Assert.assertNull(SignaturesCompareTool.compareSignatures(outPdf, cmpPdf)); + Assertions.assertNull(SignaturesCompareTool.compareSignatures(outPdf, cmpPdf)); } protected void sign(String src, String name, String dest, @@ -336,12 +375,16 @@ protected void sign(String src, String name, String dest, StampingProperties properties = new StampingProperties(); PdfSigner signer = new PdfSigner(reader, FileUtil.getFileOutputStream(dest), properties); - signer.setCertificationLevel(PdfSigner.NOT_CERTIFIED); - signer.setFieldName(name); - signer.setReason(reason).setLocation(location).setSignatureAppearance(appearance); + SignerProperties signerProperties = new SignerProperties() + .setCertificationLevel(AccessPermissions.UNSPECIFIED) + .setFieldName(name) + .setReason(reason) + .setLocation(location) + .setSignatureAppearance(appearance); if (rectangleForNewField != null) { - signer.setPageRect(rectangleForNewField); + signerProperties.setPageRect(rectangleForNewField); } + signer.setSignerProperties(signerProperties); // Creating the signature IExternalSignature pks = new PrivateKeySignature(pk, DigestAlgorithms.SHA256, FACTORY.getProviderName()); diff --git a/sign/src/test/java/com/itextpdf/signatures/sign/SimpleSigningTest.java b/sign/src/test/java/com/itextpdf/signatures/sign/SimpleSigningTest.java index ec94c26346..ab7de43531 100644 --- a/sign/src/test/java/com/itextpdf/signatures/sign/SimpleSigningTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/sign/SimpleSigningTest.java @@ -27,21 +27,23 @@ This file is part of the iText (R) project. import com.itextpdf.commons.bouncycastle.operator.AbstractOperatorCreationException; import com.itextpdf.commons.bouncycastle.pkcs.AbstractPKCSException; import com.itextpdf.commons.utils.FileUtil; +import com.itextpdf.forms.fields.properties.SignedAppearanceText; +import com.itextpdf.forms.form.element.SignatureFieldAppearance; +import com.itextpdf.kernel.crypto.DigestAlgorithms; import com.itextpdf.kernel.geom.Rectangle; import com.itextpdf.kernel.pdf.PdfReader; import com.itextpdf.kernel.pdf.PdfWriter; import com.itextpdf.kernel.pdf.StampingProperties; import com.itextpdf.kernel.utils.CompareTool; +import com.itextpdf.signatures.AccessPermissions; import com.itextpdf.signatures.BouncyCastleDigest; -import com.itextpdf.signatures.DigestAlgorithms; import com.itextpdf.signatures.IExternalSignature; -import com.itextpdf.signatures.PdfSignatureAppearance; import com.itextpdf.signatures.PdfSigner; import com.itextpdf.signatures.PrivateKeySignature; +import com.itextpdf.signatures.SignerProperties; import com.itextpdf.signatures.testutils.PemFileHelper; import com.itextpdf.signatures.testutils.SignaturesCompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.BouncyCastleIntegrationTest; import java.io.IOException; import java.security.GeneralSecurityException; @@ -53,13 +55,13 @@ This file is part of the iText (R) project. import java.util.HashMap; import java.util.List; import java.util.Map; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(BouncyCastleIntegrationTest.class) +@Tag("BouncyCastleIntegrationTest") public class SimpleSigningTest extends ExtendedITextTest { private static final IBouncyCastleFactory FACTORY = BouncyCastleFactoryCreator.getFactory(); @@ -73,13 +75,13 @@ public class SimpleSigningTest extends ExtendedITextTest { private Certificate[] chain; private PrivateKey pk; - @BeforeClass + @BeforeAll public static void before() { Security.addProvider(FACTORY.getProvider()); createOrClearDestinationFolder(DESTINATION_FOLDER); } - @Before + @BeforeEach public void init() throws IOException, CertificateException, AbstractPKCSException, AbstractOperatorCreationException { pk = PemFileHelper.readFirstKey(CERTS_SRC + "signCertRsa01.pem", PASSWORD); @@ -96,12 +98,12 @@ public void pdfDocWithParagraphSigningTest() throws GeneralSecurityException, IO String fieldName = "Signature1"; sign(srcFile, fieldName, outPdf, chain, pk, DigestAlgorithms.SHA256, PdfSigner.CryptoStandard.CADES, "Test 1", - "TestCity", rect, false, false, PdfSigner.NOT_CERTIFIED, 12f); + "TestCity", rect, false, false, AccessPermissions.UNSPECIFIED, 12f); - Assert.assertNull(new CompareTool().compareVisually(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_", + Assertions.assertNull(new CompareTool().compareVisually(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_", getTestMap(rect))); - Assert.assertNull(SignaturesCompareTool.compareSignatures(outPdf, cmpPdf)); + Assertions.assertNull(SignaturesCompareTool.compareSignatures(outPdf, cmpPdf)); } @Test @@ -114,12 +116,12 @@ public void signWithoutPKeyTest() throws GeneralSecurityException, IOException, String fieldName = "Signature1"; sign(srcFile, fieldName, outPdf, chain, pk, DigestAlgorithms.SHA256, PdfSigner.CryptoStandard.CADES, "Test 1", - "TestCity", rect, false, false, PdfSigner.NOT_CERTIFIED, 12f); + "TestCity", rect, false, false, AccessPermissions.UNSPECIFIED, 12f); - Assert.assertNull(new CompareTool().compareVisually(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_", + Assertions.assertNull(new CompareTool().compareVisually(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_", getTestMap(rect))); - Assert.assertNull(SignaturesCompareTool.compareSignatures(outPdf, cmpPdf)); + Assertions.assertNull(SignaturesCompareTool.compareSignatures(outPdf, cmpPdf)); } @Test @@ -131,12 +133,12 @@ public void signIntoExistingFieldWithDotsTest() throws GeneralSecurityException, Rectangle randomRect = new Rectangle(1, 1, 100, 100); String fieldName = "Signature1.1"; sign(srcFile, fieldName, outPdf, chain, pk, DigestAlgorithms.SHA256, PdfSigner.CryptoStandard.CADES, "Test 1", - "TestCity", randomRect, false, false, PdfSigner.NOT_CERTIFIED, 12f); + "TestCity", randomRect, false, false, AccessPermissions.UNSPECIFIED, 12f); - Assert.assertNull(new CompareTool().compareVisually(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_", + Assertions.assertNull(new CompareTool().compareVisually(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_", getTestMap(new Rectangle(163, 128, 430, 202)))); - Assert.assertNull(SignaturesCompareTool.compareSignatures(outPdf, cmpPdf)); + Assertions.assertNull(SignaturesCompareTool.compareSignatures(outPdf, cmpPdf)); } @Test @@ -151,27 +153,29 @@ public void signWithTempFileTest() throws GeneralSecurityException, IOException, new PdfWriter(outPdf), DESTINATION_FOLDER + tempFileName, new StampingProperties()); Rectangle rect = new Rectangle(36, 648, 200, 100); - signer.setCertificationLevel(PdfSigner.NOT_CERTIFIED); - signer.setFieldName("Signature1"); + SignerProperties signerProperties = new SignerProperties() + .setCertificationLevel(AccessPermissions.UNSPECIFIED) + .setFieldName("Signature1"); + signer.setSignerProperties(signerProperties); // Creating the appearance - createAppearance(signer, "Test 1", "TestCity", false, rect, 12f); + createAppearance(signer, "Signature1", "Test 1", "TestCity", false, rect, 12f); // Creating the signature IExternalSignature pks = new PrivateKeySignature(pk, DigestAlgorithms.SHA256, FACTORY.getProviderName()); signer.signDetached(new BouncyCastleDigest(), pks, chain, null, null, null, 0, PdfSigner.CryptoStandard.CADES); - Assert.assertNull(new CompareTool().compareVisually(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_", + Assertions.assertNull(new CompareTool().compareVisually(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_", getTestMap(rect))); - Assert.assertNull(SignaturesCompareTool.compareSignatures(outPdf, cmpPdf)); + Assertions.assertNull(SignaturesCompareTool.compareSignatures(outPdf, cmpPdf)); } protected void sign(String src, String name, String dest, Certificate[] chain, PrivateKey pk, String digestAlgorithm, PdfSigner.CryptoStandard subfilter, String reason, String location, Rectangle rectangleForNewField, boolean setReuseAppearance, - boolean isAppendMode, int certificationLevel, Float fontSize) + boolean isAppendMode, AccessPermissions certificationLevel, Float fontSize) throws GeneralSecurityException, IOException { PdfReader reader = new PdfReader(src); @@ -181,11 +185,13 @@ protected void sign(String src, String name, String dest, } PdfSigner signer = new PdfSigner(reader, FileUtil.getFileOutputStream(dest), properties); - signer.setCertificationLevel(certificationLevel); - signer.setFieldName(name); + SignerProperties signerProperties = new SignerProperties() + .setCertificationLevel(certificationLevel) + .setFieldName(name); + signer.setSignerProperties(signerProperties); // Creating the appearance - createAppearance(signer, reason, location, setReuseAppearance, rectangleForNewField, fontSize); + createAppearance(signer, name, reason, location, setReuseAppearance, rectangleForNewField, fontSize); // Creating the signature IExternalSignature pks = new PrivateKeySignature(pk, digestAlgorithm, FACTORY.getProviderName()); @@ -198,18 +204,20 @@ private static Map> getTestMap(Rectangle ignoredArea) { return result; } - private static void createAppearance(PdfSigner signer, String reason, String location, boolean setReuseAppearance, - Rectangle rectangleForNewField, Float fontSize) { - PdfSignatureAppearance appearance = signer.getSignatureAppearance() + private static void createAppearance(PdfSigner signer, String signatureName, String reason, String location, + boolean setReuseAppearance, Rectangle rectangleForNewField, Float fontSize) { + SignatureFieldAppearance appearance = new SignatureFieldAppearance(SignerProperties.IGNORED_ID) + .setContent(new SignedAppearanceText()); + signer.getSignerProperties() .setReason(reason) .setLocation(location) - .setReuseAppearance(setReuseAppearance); - + .setSignatureAppearance(appearance); if (rectangleForNewField != null) { - signer.setPageRect(rectangleForNewField); + signer.getSignerProperties().setPageRect(rectangleForNewField); } if (fontSize != null) { - appearance.setLayer2FontSize((float) fontSize); + appearance.setFontSize((float) fontSize); } + signer.getSignatureField().setReuseAppearance(setReuseAppearance); } } diff --git a/sign/src/test/java/com/itextpdf/signatures/sign/TaggedPdfSigningTest.java b/sign/src/test/java/com/itextpdf/signatures/sign/TaggedPdfSigningTest.java index c2125f3bf3..e45f4a1fa4 100644 --- a/sign/src/test/java/com/itextpdf/signatures/sign/TaggedPdfSigningTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/sign/TaggedPdfSigningTest.java @@ -27,20 +27,22 @@ This file is part of the iText (R) project. import com.itextpdf.commons.bouncycastle.operator.AbstractOperatorCreationException; import com.itextpdf.commons.bouncycastle.pkcs.AbstractPKCSException; import com.itextpdf.commons.utils.FileUtil; +import com.itextpdf.forms.fields.properties.SignedAppearanceText; +import com.itextpdf.forms.form.element.SignatureFieldAppearance; +import com.itextpdf.kernel.crypto.DigestAlgorithms; import com.itextpdf.kernel.geom.Rectangle; import com.itextpdf.kernel.pdf.PdfReader; import com.itextpdf.kernel.pdf.StampingProperties; import com.itextpdf.kernel.utils.CompareTool; +import com.itextpdf.signatures.AccessPermissions; import com.itextpdf.signatures.BouncyCastleDigest; -import com.itextpdf.signatures.DigestAlgorithms; import com.itextpdf.signatures.IExternalSignature; -import com.itextpdf.signatures.PdfSignatureAppearance; import com.itextpdf.signatures.PdfSigner; import com.itextpdf.signatures.PrivateKeySignature; +import com.itextpdf.signatures.SignerProperties; import com.itextpdf.signatures.testutils.PemFileHelper; import com.itextpdf.signatures.testutils.SignaturesCompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.BouncyCastleIntegrationTest; import java.io.IOException; import java.security.GeneralSecurityException; @@ -53,14 +55,14 @@ This file is part of the iText (R) project. import java.util.List; import java.util.Map; import javax.xml.parsers.ParserConfigurationException; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import org.xml.sax.SAXException; -@Category(BouncyCastleIntegrationTest.class) +@Tag("BouncyCastleIntegrationTest") public class TaggedPdfSigningTest extends ExtendedITextTest { private static final IBouncyCastleFactory FACTORY = BouncyCastleFactoryCreator.getFactory(); @@ -74,13 +76,13 @@ public class TaggedPdfSigningTest extends ExtendedITextTest { private Certificate[] chain; private PrivateKey pk; - @BeforeClass + @BeforeAll public static void before() { Security.addProvider(FACTORY.getProvider()); createOrClearDestinationFolder(DESTINATION_FOLDER); } - @Before + @BeforeEach public void init() throws IOException, CertificateException, AbstractPKCSException, AbstractOperatorCreationException { pk = PemFileHelper.readFirstKey(CERTS_SRC + "signCertRsa01.pem", PASSWORD); @@ -100,12 +102,12 @@ public void signingTaggedDocumentTest() sign(srcFile, fieldName, outPdf, chain, pk, DigestAlgorithms.SHA256, PdfSigner.CryptoStandard.CADES, "Test 1", "TestCity", rect, false, false); - Assert.assertNull(new CompareTool().compareVisually(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_", + Assertions.assertNull(new CompareTool().compareVisually(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_", getTestMap(rect))); - Assert.assertNull(new CompareTool().compareTagStructures(outPdf, cmpPdf)); + Assertions.assertNull(new CompareTool().compareTagStructures(outPdf, cmpPdf)); - Assert.assertNull(SignaturesCompareTool.compareSignatures(outPdf, cmpPdf)); + Assertions.assertNull(SignaturesCompareTool.compareSignatures(outPdf, cmpPdf)); } @Test @@ -121,12 +123,12 @@ public void signingTaggedDocumentAppendModeTest() sign(srcFile, fieldName, outPdf, chain, pk, DigestAlgorithms.SHA256, PdfSigner.CryptoStandard.CADES, "Test 1", "TestCity", rect, false, true); - Assert.assertNull(new CompareTool().compareVisually(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_", + Assertions.assertNull(new CompareTool().compareVisually(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_", getTestMap(rect))); - Assert.assertNull(new CompareTool().compareTagStructures(outPdf, cmpPdf)); + Assertions.assertNull(new CompareTool().compareTagStructures(outPdf, cmpPdf)); - Assert.assertNull(SignaturesCompareTool.compareSignatures(outPdf, cmpPdf)); + Assertions.assertNull(SignaturesCompareTool.compareSignatures(outPdf, cmpPdf)); } protected void sign(String src, String name, String dest, @@ -135,14 +137,14 @@ protected void sign(String src, String name, String dest, String reason, String location, Rectangle rectangleForNewField, boolean setReuseAppearance, boolean isAppendMode) throws GeneralSecurityException, IOException { sign(src, name, dest, chain, pk, digestAlgorithm, subfilter, reason, location, rectangleForNewField, - setReuseAppearance, isAppendMode, PdfSigner.NOT_CERTIFIED, null); + setReuseAppearance, isAppendMode, AccessPermissions.UNSPECIFIED, null); } protected void sign(String src, String name, String dest, Certificate[] chain, PrivateKey pk, String digestAlgorithm, PdfSigner.CryptoStandard subfilter, String reason, String location, Rectangle rectangleForNewField, boolean setReuseAppearance, - boolean isAppendMode, int certificationLevel, Float fontSize) + boolean isAppendMode, AccessPermissions certificationLevel, Float fontSize) throws GeneralSecurityException, IOException { PdfReader reader = new PdfReader(src); @@ -152,22 +154,26 @@ protected void sign(String src, String name, String dest, } PdfSigner signer = new PdfSigner(reader, FileUtil.getFileOutputStream(dest), properties); - signer.setCertificationLevel(certificationLevel); + SignerProperties signerProperties = new SignerProperties() + .setCertificationLevel(certificationLevel) + .setFieldName(name); + signer.setSignerProperties(signerProperties); // Creating the appearance - PdfSignatureAppearance appearance = signer.getSignatureAppearance() - .setReason(reason) - .setLocation(location) - .setReuseAppearance(setReuseAppearance); - + SignatureFieldAppearance appearance = new SignatureFieldAppearance(SignerProperties.IGNORED_ID) + .setContent(new SignedAppearanceText()); if (rectangleForNewField != null) { - appearance.setPageRect(rectangleForNewField); + signerProperties.setPageRect(rectangleForNewField); } if (fontSize != null) { - appearance.setLayer2FontSize((float) fontSize); + appearance.setFontSize((float) fontSize); } + signerProperties + .setReason(reason) + .setLocation(location) + .setSignatureAppearance(appearance); + signer.getSignatureField().setReuseAppearance(setReuseAppearance); - signer.setFieldName(name); // Creating the signature IExternalSignature pks = new PrivateKeySignature(pk, digestAlgorithm, FACTORY.getProviderName()); signer.signDetached(new BouncyCastleDigest(), pks, chain, null, null, null, 0, subfilter); diff --git a/sign/src/test/java/com/itextpdf/signatures/sign/TaggedSigningFieldTest.java b/sign/src/test/java/com/itextpdf/signatures/sign/TaggedSigningFieldTest.java index a711c3c98b..f81c53ea0f 100644 --- a/sign/src/test/java/com/itextpdf/signatures/sign/TaggedSigningFieldTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/sign/TaggedSigningFieldTest.java @@ -35,15 +35,14 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.tagging.StandardRoles; import com.itextpdf.kernel.pdf.tagutils.TagTreePointer; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") // TODO DEVSIX-5438: Change assertions after implementing signature field tagging public class TaggedSigningFieldTest extends ExtendedITextTest { @@ -60,7 +59,7 @@ public void checkSigningFieldTest() { form.addField(signField); TagTreePointer tagPointer = new TagTreePointer(pdfDoc); - Assert.assertNotNull(tagPointer.moveToKid(StandardRoles.FORM)); + Assertions.assertNotNull(tagPointer.moveToKid(StandardRoles.FORM)); } } @@ -77,7 +76,7 @@ public void checkSigningFieldZeroSizeRectangleTest() { form.addField(signField); TagTreePointer tagPointer = new TagTreePointer(pdfDoc); - Assert.assertNotNull(tagPointer.moveToKid(StandardRoles.FORM)); + Assertions.assertNotNull(tagPointer.moveToKid(StandardRoles.FORM)); } } @@ -97,7 +96,7 @@ public void checkSigningFieldPrintFlagTest() { annotations.get(0).setFlag(PdfAnnotation.PRINT); TagTreePointer tagPointer = new TagTreePointer(pdfDoc); - Assert.assertNotNull(tagPointer.moveToKid(StandardRoles.FORM)); + Assertions.assertNotNull(tagPointer.moveToKid(StandardRoles.FORM)); } } @@ -117,7 +116,7 @@ public void checkSigningFieldHiddenFlagTest() { annotations.get(0).setFlag(PdfAnnotation.HIDDEN); TagTreePointer tagPointer = new TagTreePointer(pdfDoc); - Assert.assertNotNull(tagPointer.moveToKid(StandardRoles.FORM)); + Assertions.assertNotNull(tagPointer.moveToKid(StandardRoles.FORM)); } } @@ -137,7 +136,7 @@ public void checkSigningFieldNoViewFlagTest() { annotations.get(0).setFlag(PdfAnnotation.NO_VIEW); TagTreePointer tagPointer = new TagTreePointer(pdfDoc); - Assert.assertNotNull(tagPointer.moveToKid(StandardRoles.FORM)); + Assertions.assertNotNull(tagPointer.moveToKid(StandardRoles.FORM)); } } @@ -157,7 +156,7 @@ public void checkSigningFieldInvisibleFlagTest() { annotations.get(0).setFlag(PdfAnnotation.INVISIBLE); TagTreePointer tagPointer = new TagTreePointer(pdfDoc); - Assert.assertNotNull(tagPointer.moveToKid(StandardRoles.FORM)); + Assertions.assertNotNull(tagPointer.moveToKid(StandardRoles.FORM)); } } @@ -174,7 +173,7 @@ public void checkSigningFieldOutsidePageTest() { form.addField(signField); TagTreePointer tagPointer = new TagTreePointer(pdfDoc); - Assert.assertNotNull(tagPointer.moveToKid(StandardRoles.FORM)); + Assertions.assertNotNull(tagPointer.moveToKid(StandardRoles.FORM)); } } @@ -194,7 +193,7 @@ public void checkSigningFieldOutsidePageAndHiddenTest() { annotations.get(0).setFlag(PdfAnnotation.HIDDEN); TagTreePointer tagPointer = new TagTreePointer(pdfDoc); - Assert.assertNotNull(tagPointer.moveToKid(StandardRoles.FORM)); + Assertions.assertNotNull(tagPointer.moveToKid(StandardRoles.FORM)); } } } diff --git a/sign/src/test/java/com/itextpdf/signatures/sign/TimestampSigTest.java b/sign/src/test/java/com/itextpdf/signatures/sign/TimestampSigTest.java index 2d2320a50c..fd11730668 100644 --- a/sign/src/test/java/com/itextpdf/signatures/sign/TimestampSigTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/sign/TimestampSigTest.java @@ -35,7 +35,6 @@ This file is part of the iText (R) project. import com.itextpdf.signatures.testutils.SignaturesCompareTool; import com.itextpdf.signatures.testutils.client.TestTsaClient; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.BouncyCastleIntegrationTest; import java.io.IOException; import java.security.GeneralSecurityException; @@ -43,12 +42,12 @@ This file is part of the iText (R) project. import java.security.Security; import java.security.cert.Certificate; import java.util.Arrays; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(BouncyCastleIntegrationTest.class) +@Tag("BouncyCastleIntegrationTest") public class TimestampSigTest extends ExtendedITextTest { private static final IBouncyCastleFactory FACTORY = BouncyCastleFactoryCreator.getFactory(); @@ -60,7 +59,7 @@ public class TimestampSigTest extends ExtendedITextTest { private static final char[] password = "testpassphrase".toCharArray(); - @BeforeClass + @BeforeAll public static void before() { Security.addProvider(FACTORY.getProvider()); createOrClearDestinationFolder(destinationFolder); @@ -83,7 +82,7 @@ public void timestampTest01() TestSignUtils.basicCheckSignedDoc(destinationFolder + "timestampTest01.pdf", "timestampSig1"); - Assert.assertNull( + Assertions.assertNull( SignaturesCompareTool.compareSignatures(outFileName, sourceFolder + "cmp_timestampTest01.pdf")); } diff --git a/sign/src/test/java/com/itextpdf/signatures/sign/TwoPhaseSigningTest.java b/sign/src/test/java/com/itextpdf/signatures/sign/TwoPhaseSigningTest.java index 8f64302e52..19e73c45ef 100644 --- a/sign/src/test/java/com/itextpdf/signatures/sign/TwoPhaseSigningTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/sign/TwoPhaseSigningTest.java @@ -30,19 +30,19 @@ This file is part of the iText (R) project. import com.itextpdf.commons.utils.FileUtil; import com.itextpdf.commons.utils.MessageFormatUtil; import com.itextpdf.io.source.ByteArrayOutputStream; +import com.itextpdf.kernel.crypto.DigestAlgorithms; +import com.itextpdf.kernel.crypto.OID; import com.itextpdf.kernel.exceptions.PdfException; import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfName; import com.itextpdf.kernel.pdf.PdfReader; import com.itextpdf.kernel.pdf.PdfString; import com.itextpdf.signatures.BouncyCastleDigest; -import com.itextpdf.signatures.DigestAlgorithms; import com.itextpdf.signatures.PdfPKCS7; import com.itextpdf.signatures.PdfSignature; import com.itextpdf.signatures.PdfSigner; import com.itextpdf.signatures.PdfTwoPhaseSigner; import com.itextpdf.signatures.PrivateKeySignature; -import com.itextpdf.signatures.SecurityIDs; import com.itextpdf.signatures.SignatureUtil; import com.itextpdf.signatures.SignerProperties; import com.itextpdf.signatures.cms.AlgorithmIdentifier; @@ -52,31 +52,35 @@ This file is part of the iText (R) project. import com.itextpdf.signatures.testutils.PemFileHelper; import com.itextpdf.signatures.testutils.SignaturesCompareTool; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.BouncyCastleIntegrationTest; -import org.bouncycastle.asn1.ASN1ObjectIdentifier; -import org.bouncycastle.asn1.DERNull; -import org.bouncycastle.asn1.x509.DigestInfo; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import javax.crypto.BadPaddingException; -import javax.crypto.Cipher; -import javax.crypto.IllegalBlockSizeException; -import javax.crypto.NoSuchPaddingException; import java.io.ByteArrayInputStream; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.security.*; +import java.security.GeneralSecurityException; +import java.security.InvalidKeyException; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.security.PrivateKey; +import java.security.Security; import java.security.cert.Certificate; import java.security.cert.CertificateException; import java.security.cert.X509Certificate; +import javax.crypto.BadPaddingException; +import javax.crypto.Cipher; +import javax.crypto.IllegalBlockSizeException; +import javax.crypto.NoSuchPaddingException; +import org.bouncycastle.asn1.ASN1ObjectIdentifier; +import org.bouncycastle.asn1.DERNull; +import org.bouncycastle.asn1.x509.DigestInfo; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(BouncyCastleIntegrationTest.class) +@Tag("BouncyCastleIntegrationTest") public class TwoPhaseSigningTest extends ExtendedITextTest { private static final IBouncyCastleFactory FACTORY = BouncyCastleFactoryCreator.getFactory(); @@ -89,20 +93,20 @@ public class TwoPhaseSigningTest extends ExtendedITextTest { private static final String SIMPLE_DOC_PATH = SOURCE_FOLDER + "SimpleDoc.pdf"; private static final String DIGEST_ALGORITHM = DigestAlgorithms.SHA384; - private static final String DIGEST_ALGORITHM_OID = SecurityIDs.ID_SHA384; + private static final String DIGEST_ALGORITHM_OID = OID.SHA_384; public static final String FIELD_NAME = "Signature1"; private PrivateKey pk; private X509Certificate[] chain; - @BeforeClass + @BeforeAll public static void before() { Security.addProvider(FACTORY.getProvider()); createOrClearDestinationFolder(DESTINATION_FOLDER); } - @Before + @BeforeEach public void init() throws IOException, CertificateException, AbstractPKCSException, AbstractOperatorCreationException { pk = PemFileHelper.readFirstKey(CERTS_SRC + "signCertRsa01.pem", PASSWORD); @@ -123,11 +127,11 @@ public void testPreparationWithClosedPdfSigner() throws IOException, GeneralSecu signer.prepareDocumentForSignature(new SignerProperties(), DIGEST_ALGORITHM, PdfName.Adobe_PPKLite, PdfName.Adbe_pkcs7_detached, 5000, false); - Exception e = Assert.assertThrows(PdfException.class, () -> { + Exception e = Assertions.assertThrows(PdfException.class, () -> { byte[] digest = signer.prepareDocumentForSignature(new SignerProperties(),DIGEST_ALGORITHM, PdfName.Adobe_PPKLite, PdfName.Adbe_pkcs7_detached, 5000, false); }); - Assert.assertEquals(SignExceptionMessageConstant.THIS_INSTANCE_OF_PDF_SIGNER_ALREADY_CLOSED, e.getMessage()); + Assertions.assertEquals(SignExceptionMessageConstant.THIS_INSTANCE_OF_PDF_SIGNER_ALREADY_CLOSED, e.getMessage()); } } @@ -139,10 +143,10 @@ public void testCompletionWithWrongFieldName() throws IOException { new PdfDocument(new PdfReader(new File(SOURCE_FOLDER + "2PhasePreparedSignature.pdf"))); OutputStream signedDoc = new ByteArrayOutputStream()) { // add signature - Exception e = Assert.assertThrows(PdfException.class, () -> + Exception e = Assertions.assertThrows(PdfException.class, () -> PdfTwoPhaseSigner.addSignatureToPreparedDocument(preparedDoc, "wrong" + FIELD_NAME, signedDoc, signData)); - Assert.assertEquals(MessageFormatUtil.format( + Assertions.assertEquals(MessageFormatUtil.format( SignExceptionMessageConstant.THERE_IS_NO_FIELD_IN_THE_DOCUMENT_WITH_SUCH_NAME, "wrong" + FIELD_NAME), e.getMessage()); } @@ -156,10 +160,10 @@ public void testCompletionWithNotEnoughSpace() throws IOException { new PdfDocument(new PdfReader(new File(SOURCE_FOLDER + "2PhasePreparedSignature.pdf"))); OutputStream signedDoc = new ByteArrayOutputStream()) { // add signature - Exception e = Assert.assertThrows(PdfException.class, () -> + Exception e = Assertions.assertThrows(PdfException.class, () -> PdfTwoPhaseSigner.addSignatureToPreparedDocument(preparedDoc, FIELD_NAME, signedDoc, signData)); - Assert.assertEquals(SignExceptionMessageConstant.AVAILABLE_SPACE_IS_NOT_ENOUGH_FOR_SIGNATURE, + Assertions.assertEquals(SignExceptionMessageConstant.AVAILABLE_SPACE_IS_NOT_ENOUGH_FOR_SIGNATURE, e.getMessage()); } } @@ -178,10 +182,10 @@ public void testCompletionWithSignatureFieldNotLastOne() throws IOException, Gen try (OutputStream outputStreamPhase2 = FileUtil.getFileOutputStream(DESTINATION_FOLDER + "2PhaseCompleteCycle.pdf"); PdfDocument doc = new PdfDocument(new PdfReader(new ByteArrayInputStream(outputStream.toByteArray())))) { - Exception e = Assert.assertThrows(PdfException.class, () -> + Exception e = Assertions.assertThrows(PdfException.class, () -> PdfTwoPhaseSigner.addSignatureToPreparedDocument(doc, FIELD_NAME, outputStreamPhase2, signData)); - Assert.assertEquals(MessageFormatUtil.format(SignExceptionMessageConstant. + Assertions.assertEquals(MessageFormatUtil.format(SignExceptionMessageConstant. SIGNATURE_WITH_THIS_NAME_IS_NOT_THE_LAST_IT_DOES_NOT_COVER_WHOLE_DOCUMENT, FIELD_NAME), e.getMessage()); } } @@ -210,8 +214,8 @@ public void testPreparation() throws IOException, GeneralSecurityException { signatureUtil = new SignatureUtil(outDocument); PdfSignature outSignature = signatureUtil.getSignature(fieldName); try { - Assert.assertTrue(signatureUtil.signatureCoversWholeDocument(FIELD_NAME)); - Assert.assertArrayEquals(cmpSignature.getContents().getValueBytes(), outSignature.getContents().getValueBytes()); + Assertions.assertTrue(signatureUtil.signatureCoversWholeDocument(FIELD_NAME)); + Assertions.assertArrayEquals(cmpSignature.getContents().getValueBytes(), outSignature.getContents().getValueBytes()); } catch (Exception e) { OutputStream fs = FileUtil.getFileOutputStream(DESTINATION_FOLDER + "testPreparation.pdf"); fs.write(outputStream.toByteArray()); @@ -241,7 +245,7 @@ public void testCompleteCycle() throws IOException, GeneralSecurityException { PdfDocument doc = new PdfDocument(new PdfReader(new ByteArrayInputStream(outputStream.toByteArray())))) { PdfTwoPhaseSigner.addSignatureToPreparedDocument(doc, fieldName, outputStreamPhase2, signData); } - Assert.assertNull(SignaturesCompareTool.compareSignatures(DESTINATION_FOLDER + "2PhaseCompleteCycle.pdf", + Assertions.assertNull(SignaturesCompareTool.compareSignatures(DESTINATION_FOLDER + "2PhaseCompleteCycle.pdf", SOURCE_FOLDER + "cmp_2PhaseCompleteCycle.pdf")); } } @@ -261,7 +265,7 @@ public void testCompletion() throws IOException, GeneralSecurityException { PdfTwoPhaseSigner.addSignatureToPreparedDocument(preparedDoc, FIELD_NAME, signedDoc, signData); } - Assert.assertNull(SignaturesCompareTool.compareSignatures(DESTINATION_FOLDER + "2PhaseCompletion.pdf", + Assertions.assertNull(SignaturesCompareTool.compareSignatures(DESTINATION_FOLDER + "2PhaseCompletion.pdf", SOURCE_FOLDER + "cmp_2PhaseCompleteCycle.pdf")); } @@ -304,10 +308,10 @@ public void testWithCMS() throws IOException, GeneralSecurityException { SignatureUtil su = new SignatureUtil(finalDoc); PdfPKCS7 cms = su.readSignatureData(signatureName); - Assert.assertTrue("Signature should be valid", cms.verifySignatureIntegrityAndAuthenticity()); + Assertions.assertTrue(cms.verifySignatureIntegrityAndAuthenticity(), "Signature should be valid"); } // compare result - Assert.assertNull(SignaturesCompareTool.compareSignatures(signedDocumentName, + Assertions.assertNull(SignaturesCompareTool.compareSignatures(signedDocumentName, SOURCE_FOLDER + "cmp_2PhaseCompleteCycleCMS.pdf")); } } @@ -347,7 +351,7 @@ private byte[] prepareDocumentAndCMS(File document, ByteArrayOutputStream prepar CMSContainer cms = new CMSContainer(); SignerInfo signerInfo = new SignerInfo(); - //signerInfo.setSigningCertificateAndAddToSignedAttributes(chain[0], SecurityIDs.ID_SHA384); + //signerInfo.setSigningCertificateAndAddToSignedAttributes(chain[0], OID.ID_SHA384); signerInfo.setSigningCertificate(chain[0]); // in the two phase scenario,; we don't have the private key! So we start from the signing certificate diff --git a/sign/src/test/java/com/itextpdf/signatures/testutils/SignaturesCompareTool.java b/sign/src/test/java/com/itextpdf/signatures/testutils/SignaturesCompareTool.java index 266c760cc3..ccb84bab1f 100644 --- a/sign/src/test/java/com/itextpdf/signatures/testutils/SignaturesCompareTool.java +++ b/sign/src/test/java/com/itextpdf/signatures/testutils/SignaturesCompareTool.java @@ -68,6 +68,7 @@ public class SignaturesCompareTool { private static final String OID_ADBE_REVOCATION_INFO_ARCHIVAL = "1.2.840.113583.1.1.8"; private static final String OID_OCSP_RESPONSE = "1.3.6.1.5.5.7.48.1.1"; private static final String OID_OCSP_NONCE_EXTENSION = "1.3.6.1.5.5.7.48.1.2"; + private static final String ID_ATTR_PDF_MAC_DATA = "1.0.32004.1.2"; private static final IASN1Dump DUMP = BOUNCY_CASTLE_FACTORY.createASN1Dump(); @@ -79,6 +80,7 @@ public class SignaturesCompareTool { tempSet.add(OID_TST_INFO); tempSet.add(OID_SIGNING_TIME); tempSet.add(OID_OCSP_NONCE_EXTENSION); + tempSet.add(ID_ATTR_PDF_MAC_DATA); IGNORED_OIDS = Collections.unmodifiableSet(tempSet); } diff --git a/sign/src/test/java/com/itextpdf/signatures/testutils/builder/TestTimestampTokenBuilder.java b/sign/src/test/java/com/itextpdf/signatures/testutils/builder/TestTimestampTokenBuilder.java index ec9eb2bb58..5252b31e37 100644 --- a/sign/src/test/java/com/itextpdf/signatures/testutils/builder/TestTimestampTokenBuilder.java +++ b/sign/src/test/java/com/itextpdf/signatures/testutils/builder/TestTimestampTokenBuilder.java @@ -37,7 +37,7 @@ This file is part of the iText (R) project. import com.itextpdf.commons.bouncycastle.tsp.ITimeStampTokenGenerator; import com.itextpdf.commons.utils.DateTimeUtil; import com.itextpdf.commons.utils.SystemUtil; -import com.itextpdf.signatures.DigestAlgorithms; +import com.itextpdf.kernel.crypto.DigestAlgorithms; import java.io.IOException; import java.math.BigInteger; diff --git a/sign/src/test/java/com/itextpdf/signatures/testutils/client/AdvancedTestOcspClient.java b/sign/src/test/java/com/itextpdf/signatures/testutils/client/AdvancedTestOcspClient.java index 2b16184e8e..e02e647b1b 100644 --- a/sign/src/test/java/com/itextpdf/signatures/testutils/client/AdvancedTestOcspClient.java +++ b/sign/src/test/java/com/itextpdf/signatures/testutils/client/AdvancedTestOcspClient.java @@ -48,8 +48,8 @@ public class AdvancedTestOcspClient extends OcspClientBouncyCastle { private final Map subjectNameToResponseBuilder = new LinkedHashMap<>(); - public AdvancedTestOcspClient(OCSPVerifier verifier) { - super(verifier); + public AdvancedTestOcspClient() { + super(); } @Override diff --git a/sign/src/test/java/com/itextpdf/signatures/testutils/client/TestTsaClient.java b/sign/src/test/java/com/itextpdf/signatures/testutils/client/TestTsaClient.java index 03f55da803..932dfd01e8 100644 --- a/sign/src/test/java/com/itextpdf/signatures/testutils/client/TestTsaClient.java +++ b/sign/src/test/java/com/itextpdf/signatures/testutils/client/TestTsaClient.java @@ -27,10 +27,11 @@ This file is part of the iText (R) project. import com.itextpdf.commons.bouncycastle.tsp.ITimeStampRequest; import com.itextpdf.commons.bouncycastle.tsp.ITimeStampRequestGenerator; import com.itextpdf.commons.utils.SystemUtil; -import com.itextpdf.signatures.DigestAlgorithms; +import com.itextpdf.kernel.crypto.DigestAlgorithms; import com.itextpdf.signatures.ITSAClient; import com.itextpdf.signatures.testutils.SignTestPortUtil; import com.itextpdf.signatures.testutils.builder.TestTimestampTokenBuilder; + import java.math.BigInteger; import java.security.GeneralSecurityException; import java.security.MessageDigest; diff --git a/sign/src/test/java/com/itextpdf/signatures/validation/v1/AssertValidationReport.java b/sign/src/test/java/com/itextpdf/signatures/validation/AssertValidationReport.java similarity index 98% rename from sign/src/test/java/com/itextpdf/signatures/validation/v1/AssertValidationReport.java rename to sign/src/test/java/com/itextpdf/signatures/validation/AssertValidationReport.java index 416bd40abb..e8cd88de32 100644 --- a/sign/src/test/java/com/itextpdf/signatures/validation/v1/AssertValidationReport.java +++ b/sign/src/test/java/com/itextpdf/signatures/validation/AssertValidationReport.java @@ -20,12 +20,12 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.signatures.validation.v1; +package com.itextpdf.signatures.validation; import com.itextpdf.commons.utils.MessageFormatUtil; -import com.itextpdf.signatures.validation.v1.report.CertificateReportItem; -import com.itextpdf.signatures.validation.v1.report.ReportItem; -import com.itextpdf.signatures.validation.v1.report.ValidationReport; +import com.itextpdf.signatures.validation.report.CertificateReportItem; +import com.itextpdf.signatures.validation.report.ReportItem; +import com.itextpdf.signatures.validation.report.ValidationReport; import java.security.cert.X509Certificate; import java.util.ArrayList; diff --git a/sign/src/test/java/com/itextpdf/signatures/validation/v1/CRLValidatorTest.java b/sign/src/test/java/com/itextpdf/signatures/validation/CRLValidatorTest.java similarity index 82% rename from sign/src/test/java/com/itextpdf/signatures/validation/v1/CRLValidatorTest.java rename to sign/src/test/java/com/itextpdf/signatures/validation/CRLValidatorTest.java index 38b228b672..02992fbf90 100644 --- a/sign/src/test/java/com/itextpdf/signatures/validation/v1/CRLValidatorTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/validation/CRLValidatorTest.java @@ -20,7 +20,7 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.signatures.validation.v1; +package com.itextpdf.signatures.validation; import com.itextpdf.bouncycastleconnector.BouncyCastleFactoryCreator; import com.itextpdf.commons.bouncycastle.IBouncyCastleFactory; @@ -33,21 +33,21 @@ This file is part of the iText (R) project. import com.itextpdf.signatures.testutils.PemFileHelper; import com.itextpdf.signatures.testutils.TimeTestUtil; import com.itextpdf.signatures.testutils.builder.TestCrlBuilder; -import com.itextpdf.signatures.validation.v1.context.CertificateSource; -import com.itextpdf.signatures.validation.v1.context.TimeBasedContext; -import com.itextpdf.signatures.validation.v1.context.ValidationContext; -import com.itextpdf.signatures.validation.v1.context.ValidatorContext; -import com.itextpdf.signatures.validation.v1.mocks.MockChainValidator; -import com.itextpdf.signatures.validation.v1.mocks.MockIssuingCertificateRetriever; -import com.itextpdf.signatures.validation.v1.report.ReportItem; -import com.itextpdf.signatures.validation.v1.report.ValidationReport; +import com.itextpdf.signatures.validation.context.CertificateSource; +import com.itextpdf.signatures.validation.context.TimeBasedContext; +import com.itextpdf.signatures.validation.context.ValidationContext; +import com.itextpdf.signatures.validation.context.ValidatorContext; +import com.itextpdf.signatures.validation.mocks.MockChainValidator; +import com.itextpdf.signatures.validation.mocks.MockIssuingCertificateRetriever; +import com.itextpdf.signatures.validation.report.ReportItem; +import com.itextpdf.signatures.validation.report.ValidationReport; +import com.itextpdf.signatures.validation.report.ValidationReport.ValidationResult; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.BouncyCastleUnitTest; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.ByteArrayInputStream; import java.security.PrivateKey; @@ -59,9 +59,9 @@ This file is part of the iText (R) project. import java.util.Collections; import java.util.Date; -@Category(BouncyCastleUnitTest.class) +@Tag("BouncyCastleUnitTest") public class CRLValidatorTest extends ExtendedITextTest { - private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/"; + private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/"; private static final IBouncyCastleFactory FACTORY = BouncyCastleFactoryCreator.getFactory(); private static final char[] KEY_PASSWORD = "testpassphrase".toCharArray(); @@ -75,20 +75,20 @@ public class CRLValidatorTest extends ExtendedITextTest { private IssuingCertificateRetriever certificateRetriever; private ValidatorChainBuilder validatorChainBuilder; - @BeforeClass + @BeforeAll public static void setUpOnce() { Security.addProvider(FACTORY.getProvider()); } - @Before + @BeforeEach public void setUp() { certificateRetriever = new IssuingCertificateRetriever(); SignatureValidationProperties parameters = new SignatureValidationProperties(); mockChainValidator = new MockChainValidator(); validatorChainBuilder = new ValidatorChainBuilder() - .withIssuingCertificateRetriever(certificateRetriever) + .withIssuingCertificateRetrieverFactory(()-> certificateRetriever) .withSignatureValidationProperties(parameters) - .withCertificateChainValidator(mockChainValidator); + .withCertificateChainValidatorFactory(()-> mockChainValidator); } @Test @@ -106,6 +106,62 @@ public void happyPathTest() throws Exception { .hasStatus(ValidationReport.ValidationResult.VALID)); } + + @Test + public void multipleIssuersWithOneMatch() throws Exception { + retrieveTestResources("multipleCrlIssuerCandidates"); + byte[] crl = createCrl( + crlIssuerCert, + crlIssuerKey, + DateTimeUtil.addDaysToDate(TimeTestUtil.TEST_DATE_TIME, -5), + DateTimeUtil.addDaysToDate(TimeTestUtil.TEST_DATE_TIME, +5) + ); + X509Certificate candidateCrlIssuerCert1 = (X509Certificate) PemFileHelper.readFirstChain( + SOURCE_FOLDER + "multipleCrlIssuerCandidates/crl-issuer-candidate1.cert.pem")[0]; + X509Certificate candidateCrlIssuerCert2 = (X509Certificate) PemFileHelper.readFirstChain( + SOURCE_FOLDER + "multipleCrlIssuerCandidates/crl-issuer-candidate2.cert.pem")[0]; + + certificateRetriever.addTrustedCertificates(Arrays.asList(candidateCrlIssuerCert1, crlIssuerCert, + candidateCrlIssuerCert2)); + + ValidationReport report = performValidation("multipleCrlIssuerCandidates", TimeTestUtil.TEST_DATE_TIME, + crl); + AssertValidationReport.assertThat(report, a -> a + .hasStatus(ValidationReport.ValidationResult.VALID)); + // expected the CRL validator to stop after correct issuer was found + Assertions.assertEquals(2, mockChainValidator.verificationCalls.size()); + } + + + @Test + public void multipleIssuersWithNoMatch() throws Exception { + retrieveTestResources("multipleCrlIssuerCandidates"); + byte[] crl = createCrl( + crlIssuerCert, + crlIssuerKey, + DateTimeUtil.addDaysToDate(TimeTestUtil.TEST_DATE_TIME, -5), + DateTimeUtil.addDaysToDate(TimeTestUtil.TEST_DATE_TIME, +5) + ); + X509Certificate candidateCrlIssuerCert1 = (X509Certificate) PemFileHelper.readFirstChain( + SOURCE_FOLDER + "multipleCrlIssuerCandidates/crl-issuer-candidate1.cert.pem")[0]; + X509Certificate candidateCrlIssuerCert2 = (X509Certificate) PemFileHelper.readFirstChain( + SOURCE_FOLDER + "multipleCrlIssuerCandidates/crl-issuer-candidate2.cert.pem")[0]; + + certificateRetriever.addTrustedCertificates(Arrays.asList(candidateCrlIssuerCert1, + candidateCrlIssuerCert2)); + + X509Certificate certificateUnderTest = + (X509Certificate) PemFileHelper.readFirstChain(SOURCE_FOLDER + "multipleCrlIssuerCandidates/sign.cert.pem")[0]; + ValidationReport result = new ValidationReport(); + ValidationContext context = new ValidationContext( + ValidatorContext.REVOCATION_DATA_VALIDATOR, CertificateSource.SIGNER_CERT, + TimeBasedContext.PRESENT); + validatorChainBuilder.getCRLValidator().validate(result, context, certificateUnderTest, + (X509CRL) CertificateUtil.parseCrlFromStream(new ByteArrayInputStream(crl)), TimeTestUtil.TEST_DATE_TIME, TimeTestUtil.TEST_DATE_TIME); + AssertValidationReport.assertThat(result, a -> a + .hasStatus(ValidationResult.INDETERMINATE)); + } + @Test public void nextUpdateBeforeValidationTest() throws Exception { retrieveTestResources("happyPath"); @@ -135,13 +191,13 @@ public void chainValidatorUsageTest() throws Exception { ); ValidationReport report = performValidation("happyPath", TimeTestUtil.TEST_DATE_TIME, crl); - Assert.assertEquals(ValidationReport.ValidationResult.VALID, report.getValidationResult()); + Assertions.assertEquals(ValidationReport.ValidationResult.VALID, report.getValidationResult()); - Assert.assertEquals(1, mockChainValidator.verificationCalls.size()); - Assert.assertEquals(crlIssuerCert, mockChainValidator.verificationCalls.get(0).certificate); - Assert.assertEquals(CertificateSource.CRL_ISSUER, + Assertions.assertEquals(1, mockChainValidator.verificationCalls.size()); + Assertions.assertEquals(crlIssuerCert, mockChainValidator.verificationCalls.get(0).certificate); + Assertions.assertEquals(CertificateSource.CRL_ISSUER, mockChainValidator.verificationCalls.get(0).context.getCertificateSource()); - Assert.assertEquals(ValidatorContext.CRL_VALIDATOR, + Assertions.assertEquals(ValidatorContext.CRL_VALIDATOR, mockChainValidator.verificationCalls.get(0).context.getValidatorContext()); } @@ -261,7 +317,7 @@ public void crlContainsOnlyCACertsTest() throws Exception { public void crlContainsOnlyUserCertsTest() throws Exception { String crlPath = SOURCE_FOLDER + "issuingDistributionPointTest/onlyUser.crl"; ValidationReport report = checkCrlScope(crlPath); - Assert.assertEquals(ValidationReport.ValidationResult.VALID, report.getValidationResult()); + Assertions.assertEquals(ValidationReport.ValidationResult.VALID, report.getValidationResult()); } @Test @@ -293,7 +349,7 @@ public void onlySomeReasonsTest() throws Exception { CRLValidator validator = validatorChainBuilder.getCRLValidator(); validator.validate(report, context, signCert, (X509CRL) CertificateUtil.parseCrlFromStream(new ByteArrayInputStream(builder.makeCrl())), - TimeTestUtil.TEST_DATE_TIME); + TimeTestUtil.TEST_DATE_TIME, TimeTestUtil.TEST_DATE_TIME); AssertValidationReport.assertThat(report, a -> a .hasStatus(ValidationReport.ValidationResult.INDETERMINATE) .hasLogItem(al -> al @@ -320,14 +376,15 @@ public void checkLessReasonsTest() throws Exception { ValidationContext context = new ValidationContext( ValidatorContext.REVOCATION_DATA_VALIDATOR, CertificateSource.SIGNER_CERT, TimeBasedContext.PRESENT); + CRLValidator validator = validatorChainBuilder.getCRLValidator(); // Validate full CRL. - validatorChainBuilder.getCRLValidator().validate(report, context, signCert, + validator.validate(report, context, signCert, (X509CRL) CertificateUtil.parseCrlFromStream(FileUtil.getInputStreamForFile(fullCrlPath)), - TimeTestUtil.TEST_DATE_TIME); + TimeTestUtil.TEST_DATE_TIME, TimeTestUtil.TEST_DATE_TIME); // Validate CRL with onlySomeReasons. - validatorChainBuilder.getCRLValidator().validate(report, context, signCert, + validator.validate(report, context, signCert, (X509CRL) CertificateUtil.parseCrlFromStream(new ByteArrayInputStream(builder.makeCrl())), - TimeTestUtil.TEST_DATE_TIME); + TimeTestUtil.TEST_DATE_TIME, TimeTestUtil.TEST_DATE_TIME); AssertValidationReport.assertThat(report, a -> a .hasStatus(ValidationReport.ValidationResult.VALID) ); @@ -350,7 +407,7 @@ public void removeFromCrlTest() throws Exception { TimeBasedContext.PRESENT); validatorChainBuilder.getCRLValidator().validate(report, context, signCert, (X509CRL) CertificateUtil.parseCrlFromStream(new ByteArrayInputStream(builder.makeCrl())), - TimeTestUtil.TEST_DATE_TIME); + TimeTestUtil.TEST_DATE_TIME, TimeTestUtil.TEST_DATE_TIME); AssertValidationReport.assertThat(report, a -> a .hasStatus(ValidationReport.ValidationResult.VALID) .hasLogItem(la -> la @@ -382,7 +439,8 @@ public void fullCrlButDistributionPointWithReasonsTest() throws Exception { ValidatorContext.REVOCATION_DATA_VALIDATOR, CertificateSource.SIGNER_CERT, TimeBasedContext.PRESENT); validatorChainBuilder.getCRLValidator().validate(report, context, cert, - (X509CRL) CertificateUtil.parseCrlFromStream(new ByteArrayInputStream(builder.makeCrl())), checkDate); + (X509CRL) CertificateUtil.parseCrlFromStream(new ByteArrayInputStream(builder.makeCrl())), checkDate, + checkDate); AssertValidationReport.assertThat(report, a -> a .hasStatus(ValidationReport.ValidationResult.INDETERMINATE) @@ -457,9 +515,9 @@ public void certificateRetrieverFailureTest() throws Exception { DateTimeUtil.addDaysToDate(TimeTestUtil.TEST_DATE_TIME, +5) ); MockIssuingCertificateRetriever mockCertificateRetriever = new MockIssuingCertificateRetriever(); - mockCertificateRetriever.ongetCrlIssuerCertificatesDo(c -> {throw new RuntimeException("just testing");}); - validatorChainBuilder.withIssuingCertificateRetriever(mockCertificateRetriever); - validatorChainBuilder.withCRLValidator(new CRLValidator(validatorChainBuilder)); + mockCertificateRetriever.ongetCrlIssuerCertificatesByNameDo(c -> {throw new RuntimeException("just testing");}); + validatorChainBuilder.withIssuingCertificateRetrieverFactory(() -> mockCertificateRetriever); + validatorChainBuilder.withCRLValidatorFactory(() -> new CRLValidator(validatorChainBuilder)); ValidationReport report = performValidation("happyPath", TimeTestUtil.TEST_DATE_TIME, crl); AssertValidationReport.assertThat(report, a -> a @@ -496,7 +554,7 @@ public void providedTimeIsUsedForResponderValidation() throws Exception { DateTimeUtil.addDaysToDate(TimeTestUtil.TEST_DATE_TIME, -5), DateTimeUtil.addDaysToDate(TimeTestUtil.TEST_DATE_TIME, +5) ); - mockChainValidator.onCallDo(c -> Assert.assertEquals(TimeTestUtil.TEST_DATE_TIME, c.checkDate)); + mockChainValidator.onCallDo(c -> Assertions.assertEquals(TimeTestUtil.TEST_DATE_TIME, c.checkDate)); ValidationReport report = performValidation("happyPath", TimeTestUtil.TEST_DATE_TIME, crl); AssertValidationReport.assertThat(report, a -> a @@ -515,7 +573,7 @@ private ValidationReport checkCrlScope(String crlPath) throws Exception { TimeBasedContext.PRESENT); validatorChainBuilder.getCRLValidator().validate(report, context, signCert, (X509CRL) CertificateUtil.parseCrlFromStream(FileUtil.getInputStreamForFile(crlPath)), - TimeTestUtil.TEST_DATE_TIME); + TimeTestUtil.TEST_DATE_TIME, TimeTestUtil.TEST_DATE_TIME); return report; } diff --git a/sign/src/test/java/com/itextpdf/signatures/validation/v1/CertificateChainValidatorTest.java b/sign/src/test/java/com/itextpdf/signatures/validation/CertificateChainValidatorTest.java similarity index 89% rename from sign/src/test/java/com/itextpdf/signatures/validation/v1/CertificateChainValidatorTest.java rename to sign/src/test/java/com/itextpdf/signatures/validation/CertificateChainValidatorTest.java index a4984f9ff9..3fb0adf94f 100644 --- a/sign/src/test/java/com/itextpdf/signatures/validation/v1/CertificateChainValidatorTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/validation/CertificateChainValidatorTest.java @@ -20,34 +20,30 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.signatures.validation.v1; +package com.itextpdf.signatures.validation; import com.itextpdf.commons.utils.DateTimeUtil; import com.itextpdf.commons.utils.MessageFormatUtil; +import com.itextpdf.kernel.crypto.OID.X509Extensions; import com.itextpdf.signatures.IssuingCertificateRetriever; -import com.itextpdf.signatures.OID.X509Extensions; import com.itextpdf.signatures.testutils.PemFileHelper; import com.itextpdf.signatures.testutils.TimeTestUtil; -import com.itextpdf.signatures.testutils.client.TestCrlClient; -import com.itextpdf.signatures.testutils.client.TestOcspClient; -import com.itextpdf.signatures.validation.v1.context.CertificateSource; -import com.itextpdf.signatures.validation.v1.context.CertificateSources; -import com.itextpdf.signatures.validation.v1.context.TimeBasedContext; -import com.itextpdf.signatures.validation.v1.context.ValidationContext; -import com.itextpdf.signatures.validation.v1.context.ValidatorContext; -import com.itextpdf.signatures.validation.v1.context.ValidatorContexts; -import com.itextpdf.signatures.validation.v1.extensions.CertificateExtension; -import com.itextpdf.signatures.validation.v1.extensions.KeyUsage; -import com.itextpdf.signatures.validation.v1.extensions.KeyUsageExtension; -import com.itextpdf.signatures.validation.v1.mocks.MockIssuingCertificateRetriever; -import com.itextpdf.signatures.validation.v1.mocks.MockRevocationDataValidator; -import com.itextpdf.signatures.validation.v1.mocks.MockTrustedCertificatesStore; -import com.itextpdf.signatures.validation.v1.report.CertificateReportItem; -import com.itextpdf.signatures.validation.v1.report.ReportItem; -import com.itextpdf.signatures.validation.v1.report.ValidationReport; -import com.itextpdf.signatures.validation.v1.report.ValidationReport.ValidationResult; +import com.itextpdf.signatures.validation.context.CertificateSource; +import com.itextpdf.signatures.validation.context.CertificateSources; +import com.itextpdf.signatures.validation.context.TimeBasedContext; +import com.itextpdf.signatures.validation.context.ValidationContext; +import com.itextpdf.signatures.validation.context.ValidatorContext; +import com.itextpdf.signatures.validation.context.ValidatorContexts; +import com.itextpdf.signatures.validation.extensions.CertificateExtension; +import com.itextpdf.signatures.validation.extensions.KeyUsage; +import com.itextpdf.signatures.validation.extensions.KeyUsageExtension; +import com.itextpdf.signatures.validation.mocks.MockIssuingCertificateRetriever; +import com.itextpdf.signatures.validation.mocks.MockRevocationDataValidator; +import com.itextpdf.signatures.validation.report.CertificateReportItem; +import com.itextpdf.signatures.validation.report.ReportItem; +import com.itextpdf.signatures.validation.report.ValidationReport; +import com.itextpdf.signatures.validation.report.ValidationReport.ValidationResult; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.BouncyCastleUnitTest; import java.io.IOException; import java.security.cert.Certificate; @@ -56,15 +52,14 @@ This file is part of the iText (R) project. import java.security.cert.CertificateNotYetValidException; import java.security.cert.X509Certificate; import java.util.Collections; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -@Category(BouncyCastleUnitTest.class) +@Tag("BouncyCastleUnitTest") public class CertificateChainValidatorTest extends ExtendedITextTest { - private static final String CERTS_SRC = "./src/test/resources/com/itextpdf/signatures/validation/v1/CertificateChainValidatorTest/"; + private static final String CERTS_SRC = "./src/test/resources/com/itextpdf/signatures/validation/CertificateChainValidatorTest/"; private ValidatorChainBuilder validatorChainBuilder; private SignatureValidationProperties properties; @@ -73,15 +68,15 @@ public class CertificateChainValidatorTest extends ExtendedITextTest { CertificateSource.SIGNER_CERT, TimeBasedContext.PRESENT); private MockRevocationDataValidator mockRevocationDataValidator; - @Before + @BeforeEach public void setup() { mockRevocationDataValidator = new MockRevocationDataValidator(); properties = new SignatureValidationProperties(); certificateRetriever = new IssuingCertificateRetriever(); validatorChainBuilder = new ValidatorChainBuilder() - .withIssuingCertificateRetriever(certificateRetriever) + .withIssuingCertificateRetrieverFactory(()-> certificateRetriever) .withSignatureValidationProperties(properties) - .withRevocationDataValidator(mockRevocationDataValidator); + .withRevocationDataValidatorFactory(()-> mockRevocationDataValidator); } @Test @@ -189,19 +184,19 @@ public void revocationValidationCallTest() throws CertificateException, IOExcept validator.validateCertificate(baseContext, signingCert, TimeTestUtil.TEST_DATE_TIME); - Assert.assertEquals(2, mockRevocationDataValidator.calls.size()); + Assertions.assertEquals(2, mockRevocationDataValidator.calls.size()); MockRevocationDataValidator.RevocationDataValidatorCall call1 = mockRevocationDataValidator.calls.get(0); - Assert.assertEquals(signingCert, call1.certificate); - Assert.assertEquals(CertificateSource.SIGNER_CERT, call1.context.getCertificateSource()); - Assert.assertEquals(ValidatorContext.CERTIFICATE_CHAIN_VALIDATOR, call1.context.getValidatorContext()); - Assert.assertEquals(TimeTestUtil.TEST_DATE_TIME, call1.validationDate); + Assertions.assertEquals(signingCert, call1.certificate); + Assertions.assertEquals(CertificateSource.SIGNER_CERT, call1.context.getCertificateSource()); + Assertions.assertEquals(ValidatorContext.CERTIFICATE_CHAIN_VALIDATOR, call1.context.getValidatorContext()); + Assertions.assertEquals(TimeTestUtil.TEST_DATE_TIME, call1.validationDate); MockRevocationDataValidator.RevocationDataValidatorCall call2 = mockRevocationDataValidator.calls.get(1); - Assert.assertEquals(intermediateCert, call2.certificate); - Assert.assertEquals(CertificateSource.CERT_ISSUER, call2.context.getCertificateSource()); - Assert.assertEquals(ValidatorContext.CERTIFICATE_CHAIN_VALIDATOR, call2.context.getValidatorContext()); - Assert.assertEquals(TimeTestUtil.TEST_DATE_TIME, call2.validationDate); + Assertions.assertEquals(intermediateCert, call2.certificate); + Assertions.assertEquals(CertificateSource.CERT_ISSUER, call2.context.getCertificateSource()); + Assertions.assertEquals(ValidatorContext.CERTIFICATE_CHAIN_VALIDATOR, call2.context.getValidatorContext()); + Assertions.assertEquals(TimeTestUtil.TEST_DATE_TIME, call2.validationDate); } @Test @@ -223,29 +218,29 @@ public void severalFailuresWithProceedAfterFailTest() throws CertificateExceptio ValidationReport report = validator.validateCertificate(baseContext, signingCert, DateTimeUtil.getCurrentTimeDate()); - Assert.assertEquals(ValidationResult.INVALID, report.getValidationResult()); - Assert.assertEquals(3, report.getFailures().size()); - Assert.assertEquals(4, report.getLogs().size()); - Assert.assertEquals(report.getFailures().get(0), report.getLogs().get(0)); - Assert.assertEquals(report.getFailures().get(1), report.getLogs().get(1)); - Assert.assertEquals(report.getFailures().get(2), report.getLogs().get(2)); + Assertions.assertEquals(ValidationResult.INVALID, report.getValidationResult()); + Assertions.assertEquals(3, report.getFailures().size()); + Assertions.assertEquals(4, report.getLogs().size()); + Assertions.assertEquals(report.getFailures().get(0), report.getLogs().get(0)); + Assertions.assertEquals(report.getFailures().get(1), report.getLogs().get(1)); + Assertions.assertEquals(report.getFailures().get(2), report.getLogs().get(2)); CertificateReportItem failure1 = report.getCertificateFailures().get(0); - Assert.assertEquals(signingCert, failure1.getCertificate()); - Assert.assertEquals("Required certificate extensions check.", failure1.getCheckName()); - Assert.assertEquals(MessageFormatUtil.format( + Assertions.assertEquals(signingCert, failure1.getCertificate()); + Assertions.assertEquals("Required certificate extensions check.", failure1.getCheckName()); + Assertions.assertEquals(MessageFormatUtil.format( "Required extension {0} is missing or incorrect.", X509Extensions.KEY_USAGE), failure1.getMessage()); CertificateReportItem failure2 = report.getCertificateFailures().get(1); - Assert.assertEquals(intermediateCert, failure2.getCertificate()); - Assert.assertEquals("Required certificate extensions check.", failure2.getCheckName()); - Assert.assertEquals(MessageFormatUtil.format( + Assertions.assertEquals(intermediateCert, failure2.getCertificate()); + Assertions.assertEquals("Required certificate extensions check.", failure2.getCheckName()); + Assertions.assertEquals(MessageFormatUtil.format( "Required extension {0} is missing or incorrect.", X509Extensions.KEY_USAGE), failure2.getMessage()); CertificateReportItem failure3 = report.getCertificateFailures().get(2); - Assert.assertEquals(rootCert, failure3.getCertificate()); - Assert.assertEquals("Required certificate extensions check.", failure3.getCheckName()); - Assert.assertEquals(MessageFormatUtil.format( + Assertions.assertEquals(rootCert, failure3.getCertificate()); + Assertions.assertEquals("Required certificate extensions check.", failure3.getCheckName()); + Assertions.assertEquals(MessageFormatUtil.format( "Required extension {0} is missing or incorrect.", X509Extensions.KEY_USAGE), failure3.getMessage()); } @@ -268,15 +263,15 @@ public void severalFailuresWithoutProceedAfterFailTest() throws CertificateExcep ValidationReport report = validator.validateCertificate(baseContext, signingCert, DateTimeUtil.getCurrentTimeDate()); - Assert.assertEquals(ValidationResult.INVALID, report.getValidationResult()); - Assert.assertEquals(1, report.getFailures().size()); - Assert.assertEquals(1, report.getLogs().size()); - Assert.assertEquals(report.getFailures().get(0), report.getLogs().get(0)); + Assertions.assertEquals(ValidationResult.INVALID, report.getValidationResult()); + Assertions.assertEquals(1, report.getFailures().size()); + Assertions.assertEquals(1, report.getLogs().size()); + Assertions.assertEquals(report.getFailures().get(0), report.getLogs().get(0)); CertificateReportItem failure1 = report.getCertificateFailures().get(0); - Assert.assertEquals(signingCert, failure1.getCertificate()); - Assert.assertEquals("Required certificate extensions check.", failure1.getCheckName()); - Assert.assertEquals(MessageFormatUtil.format( + Assertions.assertEquals(signingCert, failure1.getCertificate()); + Assertions.assertEquals("Required certificate extensions check.", failure1.getCheckName()); + Assertions.assertEquals(MessageFormatUtil.format( "Required extension {0} is missing or incorrect.", X509Extensions.KEY_USAGE), failure1.getMessage()); } @@ -770,7 +765,7 @@ public void trustStoreFailureTest() throws CertificateException, IOException { throw new RuntimeException("Test trust store failure"); }); - validatorChainBuilder.withIssuingCertificateRetriever(mockCertificateRetriever); + validatorChainBuilder.withIssuingCertificateRetrieverFactory(()-> mockCertificateRetriever); CertificateChainValidator validator = validatorChainBuilder.buildCertificateChainValidator(); certificateRetriever.addKnownCertificates(Collections.singletonList(intermediateCert)); @@ -801,7 +796,7 @@ public void issuerRetrievalFailureTest() throws CertificateException, IOExceptio throw new RuntimeException("Test issuer retrieval failure"); }); - validatorChainBuilder.withIssuingCertificateRetriever(mockCertificateRetriever); + validatorChainBuilder.withIssuingCertificateRetrieverFactory(()-> mockCertificateRetriever); CertificateChainValidator validator = validatorChainBuilder.buildCertificateChainValidator(); certificateRetriever.addKnownCertificates(Collections.singletonList(intermediateCert)); @@ -845,20 +840,6 @@ public void revocationValidationFailureTest() throws CertificateException, IOExc )); } - @Test - public void addCrlClientPasstroughTest() { - CertificateChainValidator validator = validatorChainBuilder.buildCertificateChainValidator(); - validator.addCrlClient(new TestCrlClient()); - Assert.assertEquals(1, mockRevocationDataValidator.crlClientsAdded.size()); - } - - @Test - public void addOcdpClientPasstroughTest() { - CertificateChainValidator validator = validatorChainBuilder.buildCertificateChainValidator(); - validator.addOcspClient(new TestOcspClient()); - Assert.assertEquals(1, mockRevocationDataValidator.ocspClientsAdded.size()); - } - @Test public void testStopOnInvalidRevocationResultTest() throws CertificateException, IOException { mockRevocationDataValidator.onValidateDo(c -> @@ -874,7 +855,7 @@ public void testStopOnInvalidRevocationResultTest() throws CertificateException, properties.setContinueAfterFailure(ValidatorContexts.all(), CertificateSources.all(), false); MockIssuingCertificateRetriever mockCertificateRetriever = new MockIssuingCertificateRetriever(certificateRetriever); - validatorChainBuilder.withIssuingCertificateRetriever(mockCertificateRetriever); + validatorChainBuilder.withIssuingCertificateRetrieverFactory(()-> mockCertificateRetriever); CertificateChainValidator validator = validatorChainBuilder.buildCertificateChainValidator(); certificateRetriever.addKnownCertificates(Collections.singletonList(intermediateCert)); @@ -885,7 +866,8 @@ public void testStopOnInvalidRevocationResultTest() throws CertificateException, AssertValidationReport.assertThat(report, a -> a .hasStatus(ValidationResult.INVALID) ); - Assert.assertEquals(0, mockCertificateRetriever.getCrlIssuerCertificatesCalls.size()); - Assert.assertEquals(1, mockRevocationDataValidator.calls.size()); + Assertions.assertEquals(0, mockCertificateRetriever.getCrlIssuerCertificatesCalls.size()); + Assertions.assertEquals(0, mockCertificateRetriever.getCrlIssuerCertificatesByNameCalls.size()); + Assertions.assertEquals(1, mockRevocationDataValidator.calls.size()); } } \ No newline at end of file diff --git a/sign/src/test/java/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest.java b/sign/src/test/java/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest.java similarity index 66% rename from sign/src/test/java/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest.java rename to sign/src/test/java/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest.java index 7aa3375df2..8e85016482 100644 --- a/sign/src/test/java/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest.java @@ -20,7 +20,7 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.signatures.validation.v1; +package com.itextpdf.signatures.validation; import com.itextpdf.bouncycastleconnector.BouncyCastleFactoryCreator; import com.itextpdf.commons.bouncycastle.IBouncyCastleFactory; @@ -29,64 +29,53 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfName; import com.itextpdf.kernel.pdf.PdfReader; import com.itextpdf.signatures.AccessPermissions; -import com.itextpdf.signatures.validation.v1.context.CertificateSource; -import com.itextpdf.signatures.validation.v1.context.CertificateSources; -import com.itextpdf.signatures.validation.v1.context.TimeBasedContext; -import com.itextpdf.signatures.validation.v1.context.ValidationContext; -import com.itextpdf.signatures.validation.v1.context.ValidatorContext; -import com.itextpdf.signatures.validation.v1.context.ValidatorContexts; -import com.itextpdf.signatures.validation.v1.report.ReportItem.ReportItemStatus; -import com.itextpdf.signatures.validation.v1.report.ValidationReport; -import com.itextpdf.signatures.validation.v1.report.ValidationReport.ValidationResult; +import com.itextpdf.signatures.validation.context.CertificateSource; +import com.itextpdf.signatures.validation.context.CertificateSources; +import com.itextpdf.signatures.validation.context.TimeBasedContext; +import com.itextpdf.signatures.validation.context.ValidationContext; +import com.itextpdf.signatures.validation.context.ValidatorContext; +import com.itextpdf.signatures.validation.context.ValidatorContexts; +import com.itextpdf.signatures.validation.report.ReportItem.ReportItemStatus; +import com.itextpdf.signatures.validation.report.ValidationReport; +import com.itextpdf.signatures.validation.report.ValidationReport.ValidationResult; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.BouncyCastleIntegrationTest; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import java.io.IOException; import java.security.Security; - import java.util.Arrays; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; - -@RunWith(Parameterized.class) -@Category(BouncyCastleIntegrationTest.class) + +@Tag("BouncyCastleIntegrationTest") public class DocumentRevisionsValidatorIntegrationTest extends ExtendedITextTest { - private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/"; + private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/"; private static final IBouncyCastleFactory FACTORY = BouncyCastleFactoryCreator.getFactory(); private ValidatorChainBuilder builder; private final ValidationContext validationContext = new ValidationContext( ValidatorContext.DOCUMENT_REVISIONS_VALIDATOR, CertificateSource.SIGNER_CERT, TimeBasedContext.PRESENT); - private final boolean continueValidationAfterFail; - @BeforeClass + @BeforeAll public static void before() { Security.addProvider(FACTORY.getProvider()); } - - @Before - public void setUp() { + public void setUp(boolean continueValidationAfterFail) { builder = new ValidatorChainBuilder(); builder.getProperties().setContinueAfterFailure(ValidatorContexts.all(), CertificateSources.all(), continueValidationAfterFail); } - public DocumentRevisionsValidatorIntegrationTest(Object continueValidationAfterFail) { - this.continueValidationAfterFail = (boolean) continueValidationAfterFail; - } - - @Parameterized.Parameters(name = "Continue validation after failure: {0}") public static Iterable createParameters() { - return Arrays.asList(new Object[] {false}, new Object[] {true}); + return Arrays.asList(new Object[]{false}, new Object[]{true}); } - @Test - public void noSignaturesDocTest() throws IOException { + @ParameterizedTest(name = "Continue validation after failure: {0}") + @MethodSource("createParameters") + public void noSignaturesDocTest(boolean continueValidationAfterFail) throws IOException { + setUp(continueValidationAfterFail); try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "noSignaturesDoc.pdf"))) { DocumentRevisionsValidator validator = builder.buildDocumentRevisionsValidator(); ValidationReport report = validator.validateAllDocumentRevisions(validationContext, document); @@ -97,52 +86,69 @@ public void noSignaturesDocTest() throws IOException { .withMessage(DocumentRevisionsValidator.DOCUMENT_WITHOUT_SIGNATURES) .withStatus(ReportItemStatus.INFO))); - Assert.assertEquals(AccessPermissions.ANNOTATION_MODIFICATION, validator.getAccessPermissions()); + Assertions.assertEquals(AccessPermissions.ANNOTATION_MODIFICATION, validator.getAccessPermissions()); } } - @Test - public void linearizedDocTest() throws IOException { + @ParameterizedTest(name = "Continue validation after failure: {0}") + @MethodSource("createParameters") + public void linearizedDocTest(boolean continueValidationAfterFail) throws IOException { + setUp(continueValidationAfterFail); try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "linearizedDoc.pdf"))) { DocumentRevisionsValidator validator = builder.buildDocumentRevisionsValidator(); ValidationReport report = validator.validateAllDocumentRevisions(validationContext, document); - AssertValidationReport.assertThat(report, a -> a.hasStatus(ValidationResult.INDETERMINATE) - .hasNumberOfFailures(1).hasNumberOfLogs(1) - .hasLogItem(l -> l.withCheckName(DocumentRevisionsValidator.DOC_MDP_CHECK) - .withMessage(DocumentRevisionsValidator.LINEARIZED_NOT_SUPPORTED) - .withStatus(ReportItemStatus.INDETERMINATE))); + AssertValidationReport.assertThat(report, a -> a.hasStatus(ValidationResult.VALID) + .hasNumberOfFailures(0).hasNumberOfLogs(0)); - Assert.assertEquals(AccessPermissions.ANNOTATION_MODIFICATION, validator.getAccessPermissions()); + Assertions.assertEquals(AccessPermissions.ANNOTATION_MODIFICATION, validator.getAccessPermissions()); } } - @Test - public void multipleRevisionsDocumentWithoutPermissionsTest() throws IOException { + @ParameterizedTest(name = "Continue validation after failure: {0}") + @MethodSource("createParameters") + public void multipleRevisionsDocumentWithoutPermissionsTest(boolean continueValidationAfterFail) throws IOException { + setUp(continueValidationAfterFail); try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "multipleRevisionsDocumentWithoutPermissions.pdf"))) { DocumentRevisionsValidator validator = builder.buildDocumentRevisionsValidator(); ValidationReport report = validator.validateAllDocumentRevisions(validationContext, document); AssertValidationReport.assertThat(report, a -> a.hasStatus(ValidationResult.VALID)); - Assert.assertEquals(AccessPermissions.ANNOTATION_MODIFICATION, validator.getAccessPermissions()); + Assertions.assertEquals(AccessPermissions.ANNOTATION_MODIFICATION, validator.getAccessPermissions()); } } - @Test - public void multipleRevisionsDocumentWithPermissionsTest() throws IOException { + @ParameterizedTest(name = "Continue validation after failure: {0}") + @MethodSource("createParameters") + public void multipleRevisionsDocumentWithPermissionsTest(boolean continueValidationAfterFail) throws IOException { + setUp(continueValidationAfterFail); try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "multipleRevisionsDocumentWithPermissions.pdf"))) { DocumentRevisionsValidator validator = builder.buildDocumentRevisionsValidator(); ValidationReport report = validator.validateAllDocumentRevisions(validationContext, document); AssertValidationReport.assertThat(report, a -> a.hasStatus(ValidationResult.VALID)); - Assert.assertEquals(AccessPermissions.FORM_FIELDS_MODIFICATION, validator.getAccessPermissions()); + Assertions.assertEquals(AccessPermissions.FORM_FIELDS_MODIFICATION, validator.getAccessPermissions()); } } - @Test - public void twoCertificationSignaturesTest() throws IOException { + @ParameterizedTest(name = "Continue validation after failure: {0}") + @MethodSource("createParameters") + public void eolNotIncludedIntoByteRangeTest(boolean continueValidationAfterFail) throws IOException { + setUp(continueValidationAfterFail); + try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "eolNotIncludedIntoByteRange.pdf"))) { + DocumentRevisionsValidator validator = builder.buildDocumentRevisionsValidator(); + ValidationReport report = validator.validateAllDocumentRevisions(validationContext, document); + + AssertValidationReport.assertThat(report, a -> a.hasStatus(ValidationResult.VALID)); + } + } + + @ParameterizedTest(name = "Continue validation after failure: {0}") + @MethodSource("createParameters") + public void twoCertificationSignaturesTest(boolean continueValidationAfterFail) throws IOException { + setUp(continueValidationAfterFail); try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "twoCertificationSignatures.pdf"))) { DocumentRevisionsValidator validator = builder.buildDocumentRevisionsValidator(); ValidationReport report = validator.validateAllDocumentRevisions(validationContext, document); @@ -164,12 +170,14 @@ public void twoCertificationSignaturesTest() throws IOException { .withStatus(ReportItemStatus.INVALID))); } - Assert.assertEquals(AccessPermissions.FORM_FIELDS_MODIFICATION, validator.getAccessPermissions()); + Assertions.assertEquals(AccessPermissions.FORM_FIELDS_MODIFICATION, validator.getAccessPermissions()); } } - @Test - public void signatureNotFoundTest() throws IOException { + @ParameterizedTest(name = "Continue validation after failure: {0}") + @MethodSource("createParameters") + public void signatureNotFoundTest(boolean continueValidationAfterFail) throws IOException { + setUp(continueValidationAfterFail); try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "signatureNotFound.pdf"))) { DocumentRevisionsValidator validator = builder.buildDocumentRevisionsValidator(); ValidationReport report = validator.validateAllDocumentRevisions(validationContext, document); @@ -180,12 +188,14 @@ public void signatureNotFoundTest() throws IOException { .withMessage(DocumentRevisionsValidator.SIGNATURE_REVISION_NOT_FOUND) .withStatus(ReportItemStatus.INVALID))); - Assert.assertEquals(AccessPermissions.ANNOTATION_MODIFICATION, validator.getAccessPermissions()); + Assertions.assertEquals(AccessPermissions.ANNOTATION_MODIFICATION, validator.getAccessPermissions()); } } - @Test - public void differentFieldLockLevelsTest() throws IOException { + @ParameterizedTest(name = "Continue validation after failure: {0}") + @MethodSource("createParameters") + public void differentFieldLockLevelsTest(boolean continueValidationAfterFail) throws IOException { + setUp(continueValidationAfterFail); try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "differentFieldLockLevels.pdf"))) { DocumentRevisionsValidator validator = builder.buildDocumentRevisionsValidator(); ValidationReport report = validator.validateAllDocumentRevisions(validationContext, document); @@ -199,12 +209,14 @@ public void differentFieldLockLevelsTest() throws IOException { .withMessage(DocumentRevisionsValidator.NOT_ALLOWED_ACROFORM_CHANGES) .withStatus(ReportItemStatus.INVALID))); - Assert.assertEquals(AccessPermissions.NO_CHANGES_PERMITTED, validator.getAccessPermissions()); + Assertions.assertEquals(AccessPermissions.NO_CHANGES_PERMITTED, validator.getAccessPermissions()); } } - @Test - public void fieldLockLevelIncreaseTest() throws IOException { + @ParameterizedTest(name = "Continue validation after failure: {0}") + @MethodSource("createParameters") + public void fieldLockLevelIncreaseTest(boolean continueValidationAfterFail) throws IOException { + setUp(continueValidationAfterFail); try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "fieldLockLevelIncrease.pdf"))) { DocumentRevisionsValidator validator = builder.buildDocumentRevisionsValidator(); ValidationReport report = validator.validateAllDocumentRevisions(validationContext, document); @@ -215,25 +227,34 @@ public void fieldLockLevelIncreaseTest() throws IOException { .withMessage(DocumentRevisionsValidator.ACCESS_PERMISSIONS_ADDED, i -> "Signature3") .withStatus(ReportItemStatus.INDETERMINATE))); - Assert.assertEquals(AccessPermissions.FORM_FIELDS_MODIFICATION, validator.getAccessPermissions()); + Assertions.assertEquals(AccessPermissions.FORM_FIELDS_MODIFICATION, validator.getAccessPermissions()); } } - @Test - public void certificationSignatureAfterApprovalTest() throws IOException { + @ParameterizedTest(name = "Continue validation after failure: {0}") + @MethodSource("createParameters") + public void certificationSignatureAfterApprovalTest(boolean continueValidationAfterFail) throws IOException { + setUp(continueValidationAfterFail); try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "certificationSignatureAfterApproval.pdf"))) { DocumentRevisionsValidator validator = builder.buildDocumentRevisionsValidator(); ValidationReport report = validator.validateAllDocumentRevisions(validationContext, document); - AssertValidationReport.assertThat(report, a -> a.hasStatus(ValidationResult.VALID)); + AssertValidationReport.assertThat(report, a -> a + .hasStatus(ValidationResult.INDETERMINATE) + .hasNumberOfFailures(1) + .hasLogItem(l -> l + .withCheckName(DocumentRevisionsValidator.DOC_MDP_CHECK) + .withMessage(DocumentRevisionsValidator.NOT_ALLOWED_CERTIFICATION_SIGNATURE) + .withStatus(ReportItemStatus.INDETERMINATE))); - Assert.assertEquals(AccessPermissions.FORM_FIELDS_MODIFICATION, validator.getAccessPermissions()); + Assertions.assertEquals(AccessPermissions.FORM_FIELDS_MODIFICATION, validator.getAccessPermissions()); } } - - @Test - public void fieldLockChildModificationAllowedTest() throws IOException { + @ParameterizedTest(name = "Continue validation after failure: {0}") + @MethodSource("createParameters") + public void fieldLockChildModificationAllowedTest(boolean continueValidationAfterFail) throws IOException { + setUp(continueValidationAfterFail); try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "fieldLockChildModificationAllowed.pdf"))) { DocumentRevisionsValidator validator = builder.buildDocumentRevisionsValidator(); ValidationReport report = validator.validateAllDocumentRevisions(validationContext, document); @@ -242,8 +263,10 @@ public void fieldLockChildModificationAllowedTest() throws IOException { } } - @Test - public void fieldLockChildModificationNotAllowedTest() throws IOException { + @ParameterizedTest(name = "Continue validation after failure: {0}") + @MethodSource("createParameters") + public void fieldLockChildModificationNotAllowedTest(boolean continueValidationAfterFail) throws IOException { + setUp(continueValidationAfterFail); try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "fieldLockChildModificationNotAllowed.pdf"))) { DocumentRevisionsValidator validator = builder.buildDocumentRevisionsValidator(); ValidationReport report = validator.validateAllDocumentRevisions(validationContext, document); @@ -256,8 +279,10 @@ public void fieldLockChildModificationNotAllowedTest() throws IOException { } } - @Test - public void fieldLockRootModificationAllowedTest() throws IOException { + @ParameterizedTest(name = "Continue validation after failure: {0}") + @MethodSource("createParameters") + public void fieldLockRootModificationAllowedTest(boolean continueValidationAfterFail) throws IOException { + setUp(continueValidationAfterFail); try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "fieldLockRootModificationAllowed.pdf"))) { DocumentRevisionsValidator validator = builder.buildDocumentRevisionsValidator(); ValidationReport report = validator.validateAllDocumentRevisions(validationContext, document); @@ -266,8 +291,10 @@ public void fieldLockRootModificationAllowedTest() throws IOException { } } - @Test - public void fieldLockRootModificationNotAllowedTest() throws IOException { + @ParameterizedTest(name = "Continue validation after failure: {0}") + @MethodSource("createParameters") + public void fieldLockRootModificationNotAllowedTest(boolean continueValidationAfterFail) throws IOException { + setUp(continueValidationAfterFail); try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "fieldLockRootModificationNotAllowed.pdf"))) { DocumentRevisionsValidator validator = builder.buildDocumentRevisionsValidator(); ValidationReport report = validator.validateAllDocumentRevisions(validationContext, document); @@ -280,8 +307,10 @@ public void fieldLockRootModificationNotAllowedTest() throws IOException { } } - @Test - public void fieldLockSequentialExcludeValuesTest() throws IOException { + @ParameterizedTest(name = "Continue validation after failure: {0}") + @MethodSource("createParameters") + public void fieldLockSequentialExcludeValuesTest(boolean continueValidationAfterFail) throws IOException { + setUp(continueValidationAfterFail); try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "fieldLockSequentialExcludeValues.pdf"))) { DocumentRevisionsValidator validator = builder.buildDocumentRevisionsValidator(); ValidationReport report = validator.validateAllDocumentRevisions(validationContext, document); @@ -294,8 +323,10 @@ public void fieldLockSequentialExcludeValuesTest() throws IOException { } } - @Test - public void fieldLockSequentialIncludeValuesTest() throws IOException { + @ParameterizedTest(name = "Continue validation after failure: {0}") + @MethodSource("createParameters") + public void fieldLockSequentialIncludeValuesTest(boolean continueValidationAfterFail) throws IOException { + setUp(continueValidationAfterFail); try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "fieldLockSequentialIncludeValues.pdf"))) { DocumentRevisionsValidator validator = builder.buildDocumentRevisionsValidator(); ValidationReport report = validator.validateAllDocumentRevisions(validationContext, document); @@ -321,8 +352,10 @@ public void fieldLockSequentialIncludeValuesTest() throws IOException { } } - @Test - public void fieldLockKidsRemovedAndAddedTest() throws IOException { + @ParameterizedTest(name = "Continue validation after failure: {0}") + @MethodSource("createParameters") + public void fieldLockKidsRemovedAndAddedTest(boolean continueValidationAfterFail) throws IOException { + setUp(continueValidationAfterFail); try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "fieldLockKidsRemovedAndAdded.pdf"))) { DocumentRevisionsValidator validator = builder.buildDocumentRevisionsValidator(); ValidationReport report = validator.validateAllDocumentRevisions(validationContext, document); @@ -346,8 +379,10 @@ public void fieldLockKidsRemovedAndAddedTest() throws IOException { } } - @Test - public void pageAndParentIndirectReferenceModifiedTest() throws IOException { + @ParameterizedTest(name = "Continue validation after failure: {0}") + @MethodSource("createParameters") + public void pageAndParentIndirectReferenceModifiedTest(boolean continueValidationAfterFail) throws IOException { + setUp(continueValidationAfterFail); try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "pageAndParentIndirectReferenceModified.pdf"))) { DocumentRevisionsValidator validator = builder.buildDocumentRevisionsValidator(); ValidationReport report = validator.validateAllDocumentRevisions(validationContext, document); @@ -360,8 +395,10 @@ public void pageAndParentIndirectReferenceModifiedTest() throws IOException { } } - @Test - public void lockedSignatureFieldModifiedTest() throws IOException { + @ParameterizedTest(name = "Continue validation after failure: {0}") + @MethodSource("createParameters") + public void lockedSignatureFieldModifiedTest(boolean continueValidationAfterFail) throws IOException { + setUp(continueValidationAfterFail); try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "lockedSignatureFieldModified.pdf"))) { DocumentRevisionsValidator validator = builder.buildDocumentRevisionsValidator(); ValidationReport report = validator.validateAllDocumentRevisions(validationContext, document); @@ -374,8 +411,10 @@ public void lockedSignatureFieldModifiedTest() throws IOException { } } - @Test - public void lockedFieldRemoveAddKidsEntryTest() throws IOException { + @ParameterizedTest(name = "Continue validation after failure: {0}") + @MethodSource("createParameters") + public void lockedFieldRemoveAddKidsEntryTest(boolean continueValidationAfterFail) throws IOException { + setUp(continueValidationAfterFail); try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "lockedFieldRemoveAddKidsEntry.pdf"))) { DocumentRevisionsValidator validator = builder.buildDocumentRevisionsValidator(); ValidationReport report = validator.validateAllDocumentRevisions(validationContext, document); @@ -399,8 +438,10 @@ public void lockedFieldRemoveAddKidsEntryTest() throws IOException { } } - @Test - public void removedLockedFieldTest() throws IOException { + @ParameterizedTest(name = "Continue validation after failure: {0}") + @MethodSource("createParameters") + public void removedLockedFieldTest(boolean continueValidationAfterFail) throws IOException { + setUp(continueValidationAfterFail); try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "removedLockedField.pdf"))) { DocumentRevisionsValidator validator = builder.buildDocumentRevisionsValidator(); ValidationReport report = validator.validateAllDocumentRevisions(validationContext, document); @@ -413,8 +454,10 @@ public void removedLockedFieldTest() throws IOException { } } - @Test - public void danglingWidgetAnnotationTest() throws IOException { + @ParameterizedTest(name = "Continue validation after failure: {0}") + @MethodSource("createParameters") + public void danglingWidgetAnnotationTest(boolean continueValidationAfterFail) throws IOException { + setUp(continueValidationAfterFail); try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "danglingWidgetAnnotation.pdf"))) { DocumentRevisionsValidator validator = builder.buildDocumentRevisionsValidator(); ValidationReport report = validator.validateAllDocumentRevisions(validationContext, document); @@ -426,12 +469,14 @@ public void danglingWidgetAnnotationTest() throws IOException { .withMessage(DocumentRevisionsValidator.PAGE_ANNOTATIONS_MODIFIED) .withStatus(ReportItemStatus.INVALID))); - Assert.assertEquals(AccessPermissions.FORM_FIELDS_MODIFICATION, validator.getAccessPermissions()); + Assertions.assertEquals(AccessPermissions.FORM_FIELDS_MODIFICATION, validator.getAccessPermissions()); } } - @Test - public void removeAllThePageAnnotationsTest() throws IOException { + @ParameterizedTest(name = "Continue validation after failure: {0}") + @MethodSource("createParameters") + public void removeAllThePageAnnotationsTest(boolean continueValidationAfterFail) throws IOException { + setUp(continueValidationAfterFail); try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "removeAllAnnots.pdf"))) { DocumentRevisionsValidator validator = builder.buildDocumentRevisionsValidator(); ValidationReport report = validator.validateAllDocumentRevisions(validationContext, document); @@ -439,12 +484,14 @@ public void removeAllThePageAnnotationsTest() throws IOException { // All the annotations on the 2nd page were removed. AssertValidationReport.assertThat(report, a -> a.hasStatus(ValidationResult.VALID)); - Assert.assertEquals(AccessPermissions.ANNOTATION_MODIFICATION, validator.getAccessPermissions()); + Assertions.assertEquals(AccessPermissions.ANNOTATION_MODIFICATION, validator.getAccessPermissions()); } } - @Test - public void removeAllTheFieldAnnotationsTest() throws IOException { + @ParameterizedTest(name = "Continue validation after failure: {0}") + @MethodSource("createParameters") + public void removeAllTheFieldAnnotationsTest(boolean continueValidationAfterFail) throws IOException { + setUp(continueValidationAfterFail); try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "removeFieldAnnots.pdf"))) { DocumentRevisionsValidator validator = builder.buildDocumentRevisionsValidator(); ValidationReport report = validator.validateAllDocumentRevisions(validationContext, document); @@ -452,12 +499,14 @@ public void removeAllTheFieldAnnotationsTest() throws IOException { // All the annotations of the text field were removed. Note that Acrobat considers it invalid. AssertValidationReport.assertThat(report, a -> a.hasStatus(ValidationResult.VALID)); - Assert.assertEquals(AccessPermissions.ANNOTATION_MODIFICATION, validator.getAccessPermissions()); + Assertions.assertEquals(AccessPermissions.ANNOTATION_MODIFICATION, validator.getAccessPermissions()); } } - @Test - public void simpleTaggedDocTest() throws IOException { + @ParameterizedTest(name = "Continue validation after failure: {0}") + @MethodSource("createParameters") + public void simpleTaggedDocTest(boolean continueValidationAfterFail) throws IOException { + setUp(continueValidationAfterFail); try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "simpleTaggedDoc.pdf"))) { DocumentRevisionsValidator validator = builder.buildDocumentRevisionsValidator(); ValidationReport report = validator.validateAllDocumentRevisions(validationContext, document); @@ -466,8 +515,10 @@ public void simpleTaggedDocTest() throws IOException { } } - @Test - public void taggedDocAddAndRemoveAnnotationsTest() throws IOException { + @ParameterizedTest(name = "Continue validation after failure: {0}") + @MethodSource("createParameters") + public void taggedDocAddAndRemoveAnnotationsTest(boolean continueValidationAfterFail) throws IOException { + setUp(continueValidationAfterFail); try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "taggedDocAddAndRemoveAnnotations.pdf"))) { DocumentRevisionsValidator validator = builder.buildDocumentRevisionsValidator(); ValidationReport report = validator.validateAllDocumentRevisions(validationContext, document); @@ -483,8 +534,10 @@ public void taggedDocAddAndRemoveAnnotationsTest() throws IOException { } } - @Test - public void taggedDocRemoveStructTreeElementTest() throws IOException { + @ParameterizedTest(name = "Continue validation after failure: {0}") + @MethodSource("createParameters") + public void taggedDocRemoveStructTreeElementTest(boolean continueValidationAfterFail) throws IOException { + setUp(continueValidationAfterFail); try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "taggedDocRemoveStructTreeElement.pdf"))) { DocumentRevisionsValidator validator = builder.buildDocumentRevisionsValidator(); ValidationReport report = validator.validateAllDocumentRevisions(validationContext, document); @@ -497,8 +550,38 @@ public void taggedDocRemoveStructTreeElementTest() throws IOException { } } - @Test - public void taggedDocRemoveStructTreeAnnotationTest() throws IOException { + @ParameterizedTest(name = "Continue validation after failure: {0}") + @MethodSource("createParameters") + public void outlinesNotModifiedTest(boolean continueValidationAfterFail) throws IOException { + setUp(continueValidationAfterFail); + try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "outlinesNotModified.pdf"))) { + DocumentRevisionsValidator validator = builder.buildDocumentRevisionsValidator(); + ValidationReport report = validator.validateAllDocumentRevisions(validationContext, document); + + AssertValidationReport.assertThat(report, a -> a.hasStatus(ValidationResult.VALID)); + } + } + + @ParameterizedTest(name = "Continue validation after failure: {0}") + @MethodSource("createParameters") + public void outlinesModifiedTest(boolean continueValidationAfterFail) throws IOException { + setUp(continueValidationAfterFail); + try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "outlinesModified.pdf"))) { + DocumentRevisionsValidator validator = builder.buildDocumentRevisionsValidator(); + ValidationReport report = validator.validateAllDocumentRevisions(validationContext, document); + + AssertValidationReport.assertThat(report, a -> a.hasStatus(ValidationResult.INVALID) + .hasNumberOfFailures(1) + .hasLogItem(l -> l.withCheckName(DocumentRevisionsValidator.DOC_MDP_CHECK) + .withMessage(DocumentRevisionsValidator.NOT_ALLOWED_CATALOG_CHANGES) + .withStatus(ReportItemStatus.INVALID))); + } + } + + @ParameterizedTest(name = "Continue validation after failure: {0}") + @MethodSource("createParameters") + public void taggedDocRemoveStructTreeAnnotationTest(boolean continueValidationAfterFail) throws IOException { + setUp(continueValidationAfterFail); try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "taggedDocRemoveStructTreeAnnotation.pdf"))) { DocumentRevisionsValidator validator = builder.buildDocumentRevisionsValidator(); ValidationReport report = validator.validateAllDocumentRevisions(validationContext, document); @@ -511,8 +594,10 @@ public void taggedDocRemoveStructTreeAnnotationTest() throws IOException { } } - @Test - public void taggedDocModifyAnnotationTest() throws IOException { + @ParameterizedTest(name = "Continue validation after failure: {0}") + @MethodSource("createParameters") + public void taggedDocModifyAnnotationTest(boolean continueValidationAfterFail) throws IOException { + setUp(continueValidationAfterFail); try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "taggedDocModifyAnnotation.pdf"))) { DocumentRevisionsValidator validator = builder.buildDocumentRevisionsValidator(); ValidationReport report = validator.validateAllDocumentRevisions(validationContext, document); @@ -521,8 +606,10 @@ public void taggedDocModifyAnnotationTest() throws IOException { } } - @Test - public void taggedDocModifyAnnotationAndStructElementTest() throws IOException { + @ParameterizedTest(name = "Continue validation after failure: {0}") + @MethodSource("createParameters") + public void taggedDocModifyAnnotationAndStructElementTest(boolean continueValidationAfterFail) throws IOException { + setUp(continueValidationAfterFail); try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "taggedDocModifyAnnotationAndStructElement.pdf"))) { DocumentRevisionsValidator validator = builder.buildDocumentRevisionsValidator(); ValidationReport report = validator.validateAllDocumentRevisions(validationContext, document); @@ -538,8 +625,10 @@ public void taggedDocModifyAnnotationAndStructElementTest() throws IOException { } } - @Test - public void taggedDocModifyAnnotationAndStructContentTest() throws IOException { + @ParameterizedTest(name = "Continue validation after failure: {0}") + @MethodSource("createParameters") + public void taggedDocModifyAnnotationAndStructContentTest(boolean continueValidationAfterFail) throws IOException { + setUp(continueValidationAfterFail); try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "taggedDocModifyAnnotationAndStructContent.pdf"))) { DocumentRevisionsValidator validator = builder.buildDocumentRevisionsValidator(); ValidationReport report = validator.validateAllDocumentRevisions(validationContext, document); @@ -548,8 +637,10 @@ public void taggedDocModifyAnnotationAndStructContentTest() throws IOException { } } - @Test - public void taggedDocModifyStructElementTest() throws IOException { + @ParameterizedTest(name = "Continue validation after failure: {0}") + @MethodSource("createParameters") + public void taggedDocModifyStructElementTest(boolean continueValidationAfterFail) throws IOException { + setUp(continueValidationAfterFail); try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "taggedDocModifyStructElement.pdf"))) { DocumentRevisionsValidator validator = builder.buildDocumentRevisionsValidator(); ValidationReport report = validator.validateAllDocumentRevisions(validationContext, document); @@ -565,8 +656,10 @@ public void taggedDocModifyStructElementTest() throws IOException { } } - @Test - public void removeUnnamedFieldTest() throws Exception { + @ParameterizedTest(name = "Continue validation after failure: {0}") + @MethodSource("createParameters") + public void removeUnnamedFieldTest(boolean continueValidationAfterFail) throws Exception { + setUp(continueValidationAfterFail); try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "removeUnnamedField.pdf"))) { DocumentRevisionsValidator validator = builder.buildDocumentRevisionsValidator(); ValidationReport report = validator.validateAllDocumentRevisions(validationContext, document); @@ -581,46 +674,64 @@ public void removeUnnamedFieldTest() throws Exception { .withMessage(DocumentRevisionsValidator.NOT_ALLOWED_ACROFORM_CHANGES) .withStatus(ReportItemStatus.INVALID))); - Assert.assertEquals(AccessPermissions.ANNOTATION_MODIFICATION, validator.getAccessPermissions()); + Assertions.assertEquals(AccessPermissions.ANNOTATION_MODIFICATION, validator.getAccessPermissions()); } } - @Test - public void fullCompressionModeLevel1Test() throws Exception { + @ParameterizedTest(name = "Continue validation after failure: {0}") + @MethodSource("createParameters") + public void fullCompressionModeLevel1Test(boolean continueValidationAfterFail) throws Exception { + setUp(continueValidationAfterFail); try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "fullCompressionModeLevel1.pdf"))) { DocumentRevisionsValidator validator = builder.buildDocumentRevisionsValidator(); ValidationReport report = validator.validateAllDocumentRevisions(validationContext, document); - Assert.assertEquals(AccessPermissions.NO_CHANGES_PERMITTED, validator.getAccessPermissions()); + Assertions.assertEquals(AccessPermissions.NO_CHANGES_PERMITTED, validator.getAccessPermissions()); AssertValidationReport.assertThat(report, a -> a.hasStatus(ValidationResult.VALID) .hasNumberOfFailures(0).hasNumberOfLogs(0)); } } - @Test - public void fullCompressionModeLevel2Test() throws Exception { + @ParameterizedTest(name = "Continue validation after failure: {0}") + @MethodSource("createParameters") + public void fullCompressionModeLevel2Test(boolean continueValidationAfterFail) throws Exception { + setUp(continueValidationAfterFail); try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "fullCompressionModeLevel2.pdf"))) { DocumentRevisionsValidator validator = builder.buildDocumentRevisionsValidator(); ValidationReport report = validator.validateAllDocumentRevisions(validationContext, document); - Assert.assertEquals(AccessPermissions.FORM_FIELDS_MODIFICATION, validator.getAccessPermissions()); + Assertions.assertEquals(AccessPermissions.FORM_FIELDS_MODIFICATION, validator.getAccessPermissions()); AssertValidationReport.assertThat(report, a -> a.hasStatus(ValidationResult.VALID) .hasNumberOfFailures(0).hasNumberOfLogs(0)); } } - @Test - public void fullCompressionModeLevel3Test() throws Exception { + @ParameterizedTest(name = "Continue validation after failure: {0}") + @MethodSource("createParameters") + public void fullCompressionModeLevel3Test(boolean continueValidationAfterFail) throws Exception { + setUp(continueValidationAfterFail); try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "fullCompressionModeLevel3.pdf"))) { DocumentRevisionsValidator validator = builder.buildDocumentRevisionsValidator(); ValidationReport report = validator.validateAllDocumentRevisions(validationContext, document); - Assert.assertEquals(AccessPermissions.ANNOTATION_MODIFICATION, validator.getAccessPermissions()); + Assertions.assertEquals(AccessPermissions.ANNOTATION_MODIFICATION, validator.getAccessPermissions()); AssertValidationReport.assertThat(report, a -> a.hasStatus(ValidationResult.VALID) .hasNumberOfFailures(0).hasNumberOfLogs(0)); } } + + @ParameterizedTest(name = "Continue validation after failure: {0}") + @MethodSource("createParameters") + public void pdfVersionAddedTest(boolean continueValidationAfterFail) throws IOException { + setUp(continueValidationAfterFail); + try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "pdfVersionAdded.pdf"))) { + DocumentRevisionsValidator validator = builder.buildDocumentRevisionsValidator(); + ValidationReport report = validator.validateAllDocumentRevisions(validationContext, document); + + AssertValidationReport.assertThat(report, a -> a.hasStatus(ValidationResult.VALID)); + } + } } diff --git a/sign/src/test/java/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorTest.java b/sign/src/test/java/com/itextpdf/signatures/validation/DocumentRevisionsValidatorTest.java similarity index 76% rename from sign/src/test/java/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorTest.java rename to sign/src/test/java/com/itextpdf/signatures/validation/DocumentRevisionsValidatorTest.java index 5cca14a9cc..fcc99ac351 100644 --- a/sign/src/test/java/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/validation/DocumentRevisionsValidatorTest.java @@ -20,7 +20,7 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.signatures.validation.v1; +package com.itextpdf.signatures.validation; import com.itextpdf.bouncycastleconnector.BouncyCastleFactoryCreator; import com.itextpdf.commons.bouncycastle.IBouncyCastleFactory; @@ -30,63 +30,54 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfReader; import com.itextpdf.kernel.pdf.PdfRevisionsReader; import com.itextpdf.signatures.AccessPermissions; -import com.itextpdf.signatures.validation.v1.context.CertificateSource; -import com.itextpdf.signatures.validation.v1.context.CertificateSources; -import com.itextpdf.signatures.validation.v1.context.TimeBasedContext; -import com.itextpdf.signatures.validation.v1.context.ValidationContext; -import com.itextpdf.signatures.validation.v1.context.ValidatorContext; -import com.itextpdf.signatures.validation.v1.context.ValidatorContexts; -import com.itextpdf.signatures.validation.v1.report.ReportItem.ReportItemStatus; -import com.itextpdf.signatures.validation.v1.report.ValidationReport; -import com.itextpdf.signatures.validation.v1.report.ValidationReport.ValidationResult; +import com.itextpdf.signatures.validation.context.CertificateSource; +import com.itextpdf.signatures.validation.context.CertificateSources; +import com.itextpdf.signatures.validation.context.TimeBasedContext; +import com.itextpdf.signatures.validation.context.ValidationContext; +import com.itextpdf.signatures.validation.context.ValidatorContext; +import com.itextpdf.signatures.validation.context.ValidatorContexts; +import com.itextpdf.signatures.validation.report.ReportItem.ReportItemStatus; +import com.itextpdf.signatures.validation.report.ValidationReport; +import com.itextpdf.signatures.validation.report.ValidationReport.ValidationResult; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.BouncyCastleUnitTest; import java.io.IOException; import java.security.Security; import java.util.Arrays; import java.util.List; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(Parameterized.class) -@Category(BouncyCastleUnitTest.class) +@Tag("BouncyCastleUnitTest") public class DocumentRevisionsValidatorTest extends ExtendedITextTest { - private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorTest/"; + private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorTest/"; private static final IBouncyCastleFactory FACTORY = BouncyCastleFactoryCreator.getFactory(); private ValidatorChainBuilder builder; private final ValidationContext validationContext = new ValidationContext( ValidatorContext.DOCUMENT_REVISIONS_VALIDATOR, CertificateSource.SIGNER_CERT, TimeBasedContext.PRESENT); - private final boolean continueValidationAfterFail; - @BeforeClass + @BeforeAll public static void before() { Security.addProvider(FACTORY.getProvider()); } - @Before - public void setUp() { + public void setUp(boolean continueValidationAfterFail) { builder = new ValidatorChainBuilder(); builder.getProperties().setContinueAfterFailure(ValidatorContexts.all(), CertificateSources.all(), continueValidationAfterFail); } - public DocumentRevisionsValidatorTest(Object continueValidationAfterFail) { - this.continueValidationAfterFail = (boolean) continueValidationAfterFail; - } - - @Parameterized.Parameters(name = "Continue validation after failure: {0}") public static Iterable createParameters() { return Arrays.asList(new Object[] {false}, new Object[] {true}); } - @Test - public void multipleRevisionsDocumentLevel1Test() throws IOException { + @ParameterizedTest(name = "Continue validation after failure: {0}") + @MethodSource("createParameters") + public void multipleRevisionsDocumentLevel1Test(boolean continueValidationAfterFail) throws IOException { + setUp(continueValidationAfterFail); try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "multipleRevisionsDocument.pdf"))) { DocumentRevisionsValidator validator = builder.buildDocumentRevisionsValidator(); validator.setAccessPermissions(AccessPermissions.NO_CHANGES_PERMITTED); @@ -112,8 +103,10 @@ public void multipleRevisionsDocumentLevel1Test() throws IOException { } } - @Test - public void hugeDocumentTest() throws IOException { + @ParameterizedTest(name = "Continue validation after failure: {0}") + @MethodSource("createParameters") + public void hugeDocumentTest(boolean continueValidationAfterFail) throws IOException { + setUp(continueValidationAfterFail); try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "hugeDocument.pdf"))) { DocumentRevisionsValidator validator = builder.buildDocumentRevisionsValidator(); validator.setAccessPermissions(AccessPermissions.NO_CHANGES_PERMITTED); @@ -127,8 +120,10 @@ public void hugeDocumentTest() throws IOException { } } - @Test - public void extensionsModificationsTest() throws IOException { + @ParameterizedTest(name = "Continue validation after failure: {0}") + @MethodSource("createParameters") + public void extensionsModificationsTest(boolean continueValidationAfterFail) throws IOException { + setUp(continueValidationAfterFail); try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "extensionsModifications.pdf"))) { DocumentRevisionsValidator validator = builder.buildDocumentRevisionsValidator(); validator.setAccessPermissions(AccessPermissions.NO_CHANGES_PERMITTED); @@ -179,8 +174,10 @@ public void extensionsModificationsTest() throws IOException { } } - @Test - public void completelyInvalidDocumentTest() throws IOException { + @ParameterizedTest(name = "Continue validation after failure: {0}") + @MethodSource("createParameters") + public void completelyInvalidDocumentTest(boolean continueValidationAfterFail) throws IOException { + setUp(continueValidationAfterFail); try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "completelyInvalidDocument.pdf"))) { DocumentRevisionsValidator validator = builder.buildDocumentRevisionsValidator(); validator.setAccessPermissions(AccessPermissions.NO_CHANGES_PERMITTED); @@ -198,8 +195,10 @@ public void completelyInvalidDocumentTest() throws IOException { } } - @Test - public void makeFontDirectAndIndirectTest() throws IOException { + @ParameterizedTest(name = "Continue validation after failure: {0}") + @MethodSource("createParameters") + public void makeFontDirectAndIndirectTest(boolean continueValidationAfterFail) throws IOException { + setUp(continueValidationAfterFail); try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "makeFontDirectAndIndirect.pdf"))) { DocumentRevisionsValidator validator = builder.buildDocumentRevisionsValidator(); PdfRevisionsReader revisionsReader = new PdfRevisionsReader(document.getReader()); @@ -234,8 +233,10 @@ public void makeFontDirectAndIndirectTest() throws IOException { } } - @Test - public void randomEntryAddedTest() throws IOException { + @ParameterizedTest(name = "Continue validation after failure: {0}") + @MethodSource("createParameters") + public void randomEntryAddedTest(boolean continueValidationAfterFail) throws IOException { + setUp(continueValidationAfterFail); try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "randomEntryAdded.pdf"))) { DocumentRevisionsValidator validator = builder.buildDocumentRevisionsValidator(); validator.setAccessPermissions(AccessPermissions.NO_CHANGES_PERMITTED); @@ -254,8 +255,10 @@ public void randomEntryAddedTest() throws IOException { } } - @Test - public void randomEntryWithoutUsageTest() throws IOException { + @ParameterizedTest(name = "Continue validation after failure: {0}") + @MethodSource("createParameters") + public void randomEntryWithoutUsageTest(boolean continueValidationAfterFail) throws IOException { + setUp(continueValidationAfterFail); try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "randomEntryWithoutUsage.pdf"))) { DocumentRevisionsValidator validator = builder.buildDocumentRevisionsValidator() .setAccessPermissions(AccessPermissions.NO_CHANGES_PERMITTED) @@ -275,8 +278,10 @@ public void randomEntryWithoutUsageTest() throws IOException { } } - @Test - public void changeExistingFontTest() throws IOException { + @ParameterizedTest(name = "Continue validation after failure: {0}") + @MethodSource("createParameters") + public void changeExistingFontTest(boolean continueValidationAfterFail) throws IOException { + setUp(continueValidationAfterFail); try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "changeExistingFont.pdf"))) { DocumentRevisionsValidator validator = builder.buildDocumentRevisionsValidator(); validator.setAccessPermissions(AccessPermissions.NO_CHANGES_PERMITTED); @@ -294,8 +299,10 @@ public void changeExistingFontTest() throws IOException { } } - @Test - public void changeExistingFontAndAddAsDssTest() throws IOException { + @ParameterizedTest(name = "Continue validation after failure: {0}") + @MethodSource("createParameters") + public void changeExistingFontAndAddAsDssTest(boolean continueValidationAfterFail) throws IOException { + setUp(continueValidationAfterFail); try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "changeExistingFontAndAddAsDss.pdf"))) { DocumentRevisionsValidator validator = builder.buildDocumentRevisionsValidator(); validator.setAccessPermissions(AccessPermissions.NO_CHANGES_PERMITTED); @@ -314,8 +321,10 @@ public void changeExistingFontAndAddAsDssTest() throws IOException { } } - @Test - public void fillInFieldAtLevel1Test() throws IOException { + @ParameterizedTest(name = "Continue validation after failure: {0}") + @MethodSource("createParameters") + public void fillInFieldAtLevel1Test(boolean continueValidationAfterFail) throws IOException { + setUp(continueValidationAfterFail); try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "fillInField.pdf"))) { DocumentRevisionsValidator validator = builder.buildDocumentRevisionsValidator(); validator.setAccessPermissions(AccessPermissions.NO_CHANGES_PERMITTED); @@ -337,8 +346,10 @@ public void fillInFieldAtLevel1Test() throws IOException { } } - @Test - public void multipleRevisionsDocumentLevel2Test() throws IOException { + @ParameterizedTest(name = "Continue validation after failure: {0}") + @MethodSource("createParameters") + public void multipleRevisionsDocumentLevel2Test(boolean continueValidationAfterFail) throws IOException { + setUp(continueValidationAfterFail); try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "multipleRevisionsDocument2.pdf"))) { DocumentRevisionsValidator validator = builder.buildDocumentRevisionsValidator(); validator.setAccessPermissions(AccessPermissions.FORM_FIELDS_MODIFICATION); @@ -368,8 +379,10 @@ public void multipleRevisionsDocumentLevel2Test() throws IOException { } } - @Test - public void removePermissionsTest() throws IOException { + @ParameterizedTest(name = "Continue validation after failure: {0}") + @MethodSource("createParameters") + public void removePermissionsTest(boolean continueValidationAfterFail) throws IOException { + setUp(continueValidationAfterFail); try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "removePermissions.pdf"))) { DocumentRevisionsValidator validator = builder.buildDocumentRevisionsValidator(); validator.setAccessPermissions(AccessPermissions.FORM_FIELDS_MODIFICATION); @@ -389,8 +402,10 @@ public void removePermissionsTest() throws IOException { } } - @Test - public void removeDSSTest() throws IOException { + @ParameterizedTest(name = "Continue validation after failure: {0}") + @MethodSource("createParameters") + public void removeDSSTest(boolean continueValidationAfterFail) throws IOException { + setUp(continueValidationAfterFail); try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "removeDSS.pdf"))) { DocumentRevisionsValidator validator = builder.buildDocumentRevisionsValidator(); validator.setAccessPermissions(AccessPermissions.FORM_FIELDS_MODIFICATION); @@ -410,8 +425,10 @@ public void removeDSSTest() throws IOException { } } - @Test - public void removeAcroformTest() throws IOException { + @ParameterizedTest(name = "Continue validation after failure: {0}") + @MethodSource("createParameters") + public void removeAcroformTest(boolean continueValidationAfterFail) throws IOException { + setUp(continueValidationAfterFail); try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "removeAcroform.pdf"))) { DocumentRevisionsValidator validator = builder.buildDocumentRevisionsValidator(); validator.setAccessPermissions(AccessPermissions.FORM_FIELDS_MODIFICATION); @@ -431,8 +448,10 @@ public void removeAcroformTest() throws IOException { } } - @Test - public void removeFieldTest() throws IOException { + @ParameterizedTest(name = "Continue validation after failure: {0}") + @MethodSource("createParameters") + public void removeFieldTest(boolean continueValidationAfterFail) throws IOException { + setUp(continueValidationAfterFail); try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "removeField.pdf"))) { DocumentRevisionsValidator validator = builder.buildDocumentRevisionsValidator(); validator.setAccessPermissions(AccessPermissions.FORM_FIELDS_MODIFICATION); @@ -452,8 +471,10 @@ public void removeFieldTest() throws IOException { } } - @Test - public void renameFieldTest() throws IOException { + @ParameterizedTest(name = "Continue validation after failure: {0}") + @MethodSource("createParameters") + public void renameFieldTest(boolean continueValidationAfterFail) throws IOException { + setUp(continueValidationAfterFail); try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "renameField.pdf"))) { DocumentRevisionsValidator validator = builder.buildDocumentRevisionsValidator(); validator.setAccessPermissions(AccessPermissions.FORM_FIELDS_MODIFICATION); @@ -476,8 +497,10 @@ public void renameFieldTest() throws IOException { } } - @Test - public void addTextFieldTest() throws IOException { + @ParameterizedTest(name = "Continue validation after failure: {0}") + @MethodSource("createParameters") + public void addTextFieldTest(boolean continueValidationAfterFail) throws IOException { + setUp(continueValidationAfterFail); try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "addTextField.pdf"))) { DocumentRevisionsValidator validator = builder.buildDocumentRevisionsValidator(); validator.setAccessPermissions(AccessPermissions.FORM_FIELDS_MODIFICATION); @@ -500,8 +523,10 @@ public void addTextFieldTest() throws IOException { } } - @Test - public void addUnsignedSignatureFieldTest() throws IOException { + @ParameterizedTest(name = "Continue validation after failure: {0}") + @MethodSource("createParameters") + public void addUnsignedSignatureFieldTest(boolean continueValidationAfterFail) throws IOException { + setUp(continueValidationAfterFail); try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "addUnsignedSignatureField.pdf"))) { DocumentRevisionsValidator validator = builder.buildDocumentRevisionsValidator(); validator.setAccessPermissions(AccessPermissions.FORM_FIELDS_MODIFICATION); @@ -524,8 +549,10 @@ public void addUnsignedSignatureFieldTest() throws IOException { } } - @Test - public void brokenSignatureFieldDictionaryTest() throws IOException { + @ParameterizedTest(name = "Continue validation after failure: {0}") + @MethodSource("createParameters") + public void brokenSignatureFieldDictionaryTest(boolean continueValidationAfterFail) throws IOException { + setUp(continueValidationAfterFail); try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "brokenSignatureFieldDictionary.pdf"))) { DocumentRevisionsValidator validator = builder.buildDocumentRevisionsValidator(); validator.setAccessPermissions(AccessPermissions.FORM_FIELDS_MODIFICATION); @@ -551,8 +578,10 @@ public void brokenSignatureFieldDictionaryTest() throws IOException { } } - @Test - public void modifyPageAnnotsTest() throws IOException { + @ParameterizedTest(name = "Continue validation after failure: {0}") + @MethodSource("createParameters") + public void modifyPageAnnotsTest(boolean continueValidationAfterFail) throws IOException { + setUp(continueValidationAfterFail); try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "modifyPageAnnots.pdf"))) { DocumentRevisionsValidator validator = builder.buildDocumentRevisionsValidator(); validator.setAccessPermissions(AccessPermissions.FORM_FIELDS_MODIFICATION); @@ -572,8 +601,72 @@ public void modifyPageAnnotsTest() throws IOException { } } - @Test - public void multipleRevisionsDocumentLevel3Test() throws IOException { + @ParameterizedTest(name = "Continue validation after failure: {0}") + @MethodSource("createParameters") + public void gotoReferencesModifiedStructTreeElemTest(boolean continueValidationAfterFail) throws IOException { + setUp(continueValidationAfterFail); + try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "gotoReferencesModifiedStructTreeElem.pdf"))) { + DocumentRevisionsValidator validator = builder.buildDocumentRevisionsValidator(); + validator.setAccessPermissions(AccessPermissions.FORM_FIELDS_MODIFICATION); + PdfRevisionsReader revisionsReader = new PdfRevisionsReader(document.getReader()); + List documentRevisions = revisionsReader.getAllRevisions(); + + ValidationReport validationReport = new ValidationReport(); + validator.validateRevision(documentRevisions.get(documentRevisions.size() - 2), + documentRevisions.get(documentRevisions.size() - 1), document, validationReport, validationContext); + + AssertValidationReport.assertThat(validationReport, a -> a.hasStatus(ValidationResult.VALID)); + } + } + + @ParameterizedTest(name = "Continue validation after failure: {0}") + @MethodSource("createParameters") + public void catalogReferenceInRandomPlaceTest(boolean continueValidationAfterFail) throws IOException { + setUp(continueValidationAfterFail); + try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "catalogReferenceInRandomPlace.pdf"))) { + DocumentRevisionsValidator validator = builder.buildDocumentRevisionsValidator(); + validator.setAccessPermissions(AccessPermissions.FORM_FIELDS_MODIFICATION); + PdfRevisionsReader revisionsReader = new PdfRevisionsReader(document.getReader()); + List documentRevisions = revisionsReader.getAllRevisions(); + + ValidationReport validationReport = new ValidationReport(); + validator.validateRevision(documentRevisions.get(documentRevisions.size() - 2), + documentRevisions.get(documentRevisions.size() - 1), document, validationReport, validationContext); + + AssertValidationReport.assertThat(validationReport, a -> a.hasStatus(ValidationResult.VALID)); + + validator.validateRevision(documentRevisions.get(documentRevisions.size() - 3), + documentRevisions.get(documentRevisions.size() - 2), document, validationReport, validationContext); + AssertValidationReport.assertThat(validationReport, a -> a.hasStatus(ValidationResult.VALID)); + } + } + + @ParameterizedTest(name = "Continue validation after failure: {0}") + @MethodSource("createParameters") + public void catalogReferenceInRandomPlaceModifiedTest(boolean continueValidationAfterFail) throws IOException { + setUp(continueValidationAfterFail); + try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "catalogReferenceInRandomPlaceModified.pdf"))) { + DocumentRevisionsValidator validator = builder.buildDocumentRevisionsValidator(); + validator.setAccessPermissions(AccessPermissions.FORM_FIELDS_MODIFICATION); + PdfRevisionsReader revisionsReader = new PdfRevisionsReader(document.getReader()); + List documentRevisions = revisionsReader.getAllRevisions(); + + ValidationReport validationReport = new ValidationReport(); + validator.validateRevision(documentRevisions.get(documentRevisions.size() - 2), + documentRevisions.get(documentRevisions.size() - 1), document, validationReport, validationContext); + + AssertValidationReport.assertThat(validationReport, a -> a.hasStatus(ValidationResult.INVALID) + .hasNumberOfFailures(1).hasNumberOfLogs(1) + .hasLogItem(l -> l.withCheckName(DocumentRevisionsValidator.DOC_MDP_CHECK) + .withMessage(DocumentRevisionsValidator.PAGE_MODIFIED) + .withStatus(ReportItemStatus.INVALID))); + } + } + + @ParameterizedTest(name = "Continue validation after failure: {0}") + @MethodSource("createParameters") + public void multipleRevisionsDocumentLevel3Test(boolean continueValidationAfterFail) throws IOException { + setUp(continueValidationAfterFail); try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "multipleRevisionsDocument3.pdf"))) { DocumentRevisionsValidator validator = builder.buildDocumentRevisionsValidator(); validator.setAccessPermissions(AccessPermissions.ANNOTATION_MODIFICATION); diff --git a/sign/src/test/java/com/itextpdf/signatures/validation/v1/OCSPValidatorIntegrationTest.java b/sign/src/test/java/com/itextpdf/signatures/validation/OCSPValidatorIntegrationTest.java similarity index 88% rename from sign/src/test/java/com/itextpdf/signatures/validation/v1/OCSPValidatorIntegrationTest.java rename to sign/src/test/java/com/itextpdf/signatures/validation/OCSPValidatorIntegrationTest.java index 085ad70c99..30b021eb65 100644 --- a/sign/src/test/java/com/itextpdf/signatures/validation/v1/OCSPValidatorIntegrationTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/validation/OCSPValidatorIntegrationTest.java @@ -20,7 +20,7 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.signatures.validation.v1; +package com.itextpdf.signatures.validation; import com.itextpdf.bouncycastleconnector.BouncyCastleFactoryCreator; import com.itextpdf.commons.bouncycastle.IBouncyCastleFactory; @@ -29,29 +29,23 @@ This file is part of the iText (R) project. import com.itextpdf.commons.bouncycastle.operator.AbstractOperatorCreationException; import com.itextpdf.commons.bouncycastle.pkcs.AbstractPKCSException; import com.itextpdf.commons.utils.DateTimeUtil; +import com.itextpdf.kernel.crypto.OID; import com.itextpdf.signatures.IssuingCertificateRetriever; -import com.itextpdf.signatures.OID; import com.itextpdf.signatures.testutils.PemFileHelper; import com.itextpdf.signatures.testutils.TimeTestUtil; import com.itextpdf.signatures.testutils.builder.TestOcspResponseBuilder; import com.itextpdf.signatures.testutils.client.TestOcspClient; -import com.itextpdf.signatures.validation.v1.context.CertificateSource; -import com.itextpdf.signatures.validation.v1.context.CertificateSources; -import com.itextpdf.signatures.validation.v1.context.TimeBasedContext; -import com.itextpdf.signatures.validation.v1.context.TimeBasedContexts; -import com.itextpdf.signatures.validation.v1.context.ValidationContext; -import com.itextpdf.signatures.validation.v1.context.ValidatorContext; -import com.itextpdf.signatures.validation.v1.context.ValidatorContexts; -import com.itextpdf.signatures.validation.v1.report.CertificateReportItem; -import com.itextpdf.signatures.validation.v1.report.ReportItem; -import com.itextpdf.signatures.validation.v1.report.ValidationReport; +import com.itextpdf.signatures.validation.context.CertificateSource; +import com.itextpdf.signatures.validation.context.CertificateSources; +import com.itextpdf.signatures.validation.context.TimeBasedContext; +import com.itextpdf.signatures.validation.context.TimeBasedContexts; +import com.itextpdf.signatures.validation.context.ValidationContext; +import com.itextpdf.signatures.validation.context.ValidatorContext; +import com.itextpdf.signatures.validation.context.ValidatorContexts; +import com.itextpdf.signatures.validation.report.CertificateReportItem; +import com.itextpdf.signatures.validation.report.ReportItem; +import com.itextpdf.signatures.validation.report.ValidationReport; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.BouncyCastleUnitTest; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; import java.io.IOException; import java.security.GeneralSecurityException; @@ -63,10 +57,15 @@ This file is part of the iText (R) project. import java.util.Arrays; import java.util.Collections; import java.util.Date; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(BouncyCastleUnitTest.class) +@Tag("BouncyCastleUnitTest") public class OCSPValidatorIntegrationTest extends ExtendedITextTest { - private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/signatures/validation/v1/OCSPValidatorTest/"; + private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/signatures/validation/OCSPValidatorTest/"; private static final IBouncyCastleFactory FACTORY = BouncyCastleFactoryCreator.getFactory(); private static final char[] PASSWORD = "testpassphrase".toCharArray(); @@ -81,7 +80,7 @@ public class OCSPValidatorIntegrationTest extends ExtendedITextTest { CertificateSource.SIGNER_CERT, TimeBasedContext.PRESENT); private ValidatorChainBuilder validatorChainBuilder; - @BeforeClass + @BeforeAll public static void before() throws CertificateException, IOException, AbstractOperatorCreationException, AbstractPKCSException { Security.addProvider(FACTORY.getProvider()); @@ -97,13 +96,13 @@ public static void before() ocspRespPrivateKey = PemFileHelper.readFirstKey(ocspResponderCertFileName, PASSWORD); } - @Before + @BeforeEach public void setUp() { certificateRetriever = new IssuingCertificateRetriever(); parameters = new SignatureValidationProperties(); validatorChainBuilder = new ValidatorChainBuilder() .withSignatureValidationProperties(parameters) - .withIssuingCertificateRetriever(certificateRetriever); + .withIssuingCertificateRetrieverFactory(() -> certificateRetriever); } @Test @@ -134,11 +133,15 @@ public void validateAuthorizedOCSPResponderWithOcspTest() AssertValidationReport.assertThat(report, a -> a .hasNumberOfFailures(0) .hasNumberOfLogs(2) - .hasLogItems(2, al -> al + .hasLogItem(al -> al .withCheckName(CertificateChainValidator.CERTIFICATE_CHECK) .withMessage(CertificateChainValidator.CERTIFICATE_TRUSTED, l-> ((CertificateReportItem) l).getCertificate().getSubjectX500Principal()) ) + .hasLogItem(al -> al + .withCheckName(OCSPValidator.OCSP_CHECK) + .withMessage(OCSPValidator.OCSP_RESPONDER_IS_CA) + ) .hasStatus(ValidationReport.ValidationResult.VALID) ); } @@ -167,8 +170,8 @@ public void validateAuthorizedOCSPResponderWithOcspRevokedTest() public void validateAuthorizedOCSPResponderFromTheTrustedStoreTest() throws GeneralSecurityException, IOException { ValidationReport report = validateOcspWithoutCertsTest(); - Assert.assertEquals(0, report.getFailures().size()); - Assert.assertEquals(ValidationReport.ValidationResult.VALID, report.getValidationResult()); + Assertions.assertEquals(0, report.getFailures().size()); + Assertions.assertEquals(ValidationReport.ValidationResult.VALID, report.getValidationResult()); } @Test @@ -295,10 +298,13 @@ private ValidationReport verifyResponderWithOcsp(boolean revokedOcsp) if (revokedOcsp) { parameters.setContinueAfterFailure(ValidatorContexts.all(), CertificateSources.all(), false); } - validatorChainBuilder.getRevocationDataValidator().addOcspClient(ocspClient); - validatorChainBuilder.getRevocationDataValidator().addOcspClient(ocspClient2); + RevocationDataValidator revocationDataValidator = validatorChainBuilder.getRevocationDataValidator(); + revocationDataValidator.addOcspClient(ocspClient); + revocationDataValidator.addOcspClient(ocspClient2); + validatorChainBuilder.withRevocationDataValidatorFactory(() -> revocationDataValidator); OCSPValidator validator = validatorChainBuilder.buildOCSPValidator(); - validator.validate(report, baseContext, checkCert, basicOCSPResp.getResponses()[0], basicOCSPResp, checkDate, checkDate); + validator.validate(report, baseContext, checkCert, basicOCSPResp.getResponses()[0], + basicOCSPResp, checkDate, checkDate); return report; } } diff --git a/sign/src/test/java/com/itextpdf/signatures/validation/v1/OCSPValidatorTest.java b/sign/src/test/java/com/itextpdf/signatures/validation/OCSPValidatorTest.java similarity index 82% rename from sign/src/test/java/com/itextpdf/signatures/validation/v1/OCSPValidatorTest.java rename to sign/src/test/java/com/itextpdf/signatures/validation/OCSPValidatorTest.java index 5224463342..b17e098d29 100644 --- a/sign/src/test/java/com/itextpdf/signatures/validation/v1/OCSPValidatorTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/validation/OCSPValidatorTest.java @@ -20,7 +20,7 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.signatures.validation.v1; +package com.itextpdf.signatures.validation; import com.itextpdf.bouncycastleconnector.BouncyCastleFactoryCreator; import com.itextpdf.commons.bouncycastle.IBouncyCastleFactory; @@ -36,25 +36,30 @@ This file is part of the iText (R) project. import com.itextpdf.signatures.testutils.TimeTestUtil; import com.itextpdf.signatures.testutils.builder.TestOcspResponseBuilder; import com.itextpdf.signatures.testutils.client.TestOcspClient; -import com.itextpdf.signatures.validation.v1.context.CertificateSource; -import com.itextpdf.signatures.validation.v1.context.CertificateSources; -import com.itextpdf.signatures.validation.v1.context.TimeBasedContext; -import com.itextpdf.signatures.validation.v1.context.TimeBasedContexts; -import com.itextpdf.signatures.validation.v1.context.ValidationContext; -import com.itextpdf.signatures.validation.v1.context.ValidatorContext; -import com.itextpdf.signatures.validation.v1.context.ValidatorContexts; -import com.itextpdf.signatures.validation.v1.mocks.MockChainValidator; -import com.itextpdf.signatures.validation.v1.mocks.MockIssuingCertificateRetriever; -import com.itextpdf.signatures.validation.v1.mocks.MockTrustedCertificatesStore; -import com.itextpdf.signatures.validation.v1.report.ReportItem; -import com.itextpdf.signatures.validation.v1.report.ValidationReport; +import com.itextpdf.signatures.validation.context.CertificateSource; +import com.itextpdf.signatures.validation.context.CertificateSources; +import com.itextpdf.signatures.validation.context.TimeBasedContext; +import com.itextpdf.signatures.validation.context.TimeBasedContexts; +import com.itextpdf.signatures.validation.context.ValidationContext; +import com.itextpdf.signatures.validation.context.ValidatorContext; +import com.itextpdf.signatures.validation.context.ValidatorContexts; +import com.itextpdf.signatures.validation.mocks.MockChainValidator; +import com.itextpdf.signatures.validation.mocks.MockIssuingCertificateRetriever; +import com.itextpdf.signatures.validation.mocks.MockTrustedCertificatesStore; +import com.itextpdf.signatures.validation.report.ReportItem; +import com.itextpdf.signatures.validation.report.ValidationReport; +import com.itextpdf.signatures.validation.report.ValidationReport.ValidationResult; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.BouncyCastleUnitTest; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.function.Supplier; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; import java.security.GeneralSecurityException; @@ -68,9 +73,9 @@ This file is part of the iText (R) project. import java.util.Collections; import java.util.Date; -@Category(BouncyCastleUnitTest.class) +@Tag("BouncyCastleUnitTest") public class OCSPValidatorTest extends ExtendedITextTest { - private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/signatures/validation/v1/OCSPValidatorTest/"; + private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/signatures/validation/OCSPValidatorTest/"; private static final IBouncyCastleFactory FACTORY = BouncyCastleFactoryCreator.getFactory(); private static final char[] PASSWORD = "testpassphrase".toCharArray(); @@ -86,7 +91,7 @@ public class OCSPValidatorTest extends ExtendedITextTest { private ValidatorChainBuilder validatorChainBuilder; private MockChainValidator mockCertificateChainValidator; - @BeforeClass + @BeforeAll public static void before() throws CertificateException, IOException, AbstractOperatorCreationException, AbstractPKCSException { Security.addProvider(FACTORY.getProvider()); @@ -102,15 +107,15 @@ public static void before() ocspRespPrivateKey = PemFileHelper.readFirstKey(ocspResponderCertFileName, PASSWORD); } - @Before + @BeforeEach public void setUp() { certificateRetriever = new IssuingCertificateRetriever(); parameters = new SignatureValidationProperties(); mockCertificateChainValidator = new MockChainValidator(); validatorChainBuilder = new ValidatorChainBuilder() .withSignatureValidationProperties(parameters) - .withIssuingCertificateRetriever(certificateRetriever) - .withCertificateChainValidator(mockCertificateChainValidator); + .withIssuingCertificateRetrieverFactory(()-> certificateRetriever) + .withCertificateChainValidatorFactory(()-> mockCertificateChainValidator); } @Test @@ -122,16 +127,70 @@ public void happyPathTest() throws GeneralSecurityException, IOException { .hasStatus(ValidationReport.ValidationResult.VALID)); } + + @Test + public void multipleIssuerCandidatesHappyPathTest() throws GeneralSecurityException, IOException { + X509Certificate candidateOcspIssuerCert1 = (X509Certificate) PemFileHelper.readFirstChain( + SOURCE_FOLDER + "candidate1-ocsp-issuer.cert.pem")[0]; + X509Certificate candidateOcspIssuerCert2 = (X509Certificate) PemFileHelper.readFirstChain( + SOURCE_FOLDER + "candidate2-ocsp-issuer.cert.pem")[0]; + + certificateRetriever.addTrustedCertificates(Arrays.asList(candidateOcspIssuerCert1, responderCert, + candidateOcspIssuerCert2)); + + TestOcspResponseBuilder builder = new TestOcspResponseBuilder(responderCert, ocspRespPrivateKey); + builder.setOcspCertsChain(new IX509CertificateHolder[]{FACTORY.createJcaX509CertificateHolder(caCert)}); + TestOcspClient ocspClient = new TestOcspClient().addBuilderForCertIssuer(caCert, builder); + IBasicOCSPResp basicOCSPResp = FACTORY.createBasicOCSPResp(FACTORY.createBasicOCSPResponse( + FACTORY.createASN1Primitive(ocspClient.getEncoded(checkCert, caCert, null)))); + + ValidationReport report = new ValidationReport(); + certificateRetriever.addTrustedCertificates(Collections.singletonList(caCert)); + + OCSPValidator validator = validatorChainBuilder.buildOCSPValidator(); + validator.validate(report, baseContext, checkCert, basicOCSPResp.getResponses()[0], basicOCSPResp, + TimeTestUtil.TEST_DATE_TIME, TimeTestUtil.TEST_DATE_TIME); + + AssertValidationReport.assertThat(report, a -> a + .hasStatus(ValidationReport.ValidationResult.VALID)); + } + + @Test + public void multipleIssuerCandidatesFailingTest() throws GeneralSecurityException, IOException { + X509Certificate candidateOcspIssuerCert1 = (X509Certificate) PemFileHelper.readFirstChain( + SOURCE_FOLDER + "candidate1-ocsp-issuer.cert.pem")[0]; + X509Certificate candidateOcspIssuerCert2 = (X509Certificate) PemFileHelper.readFirstChain( + SOURCE_FOLDER + "candidate2-ocsp-issuer.cert.pem")[0]; + + certificateRetriever.addTrustedCertificates(Arrays.asList(candidateOcspIssuerCert1, + candidateOcspIssuerCert2)); + + TestOcspResponseBuilder builder = new TestOcspResponseBuilder(responderCert, ocspRespPrivateKey); + builder.setOcspCertsChain(new IX509CertificateHolder[]{FACTORY.createJcaX509CertificateHolder(caCert)}); + TestOcspClient ocspClient = new TestOcspClient().addBuilderForCertIssuer(caCert, builder); + IBasicOCSPResp basicOCSPResp = FACTORY.createBasicOCSPResp(FACTORY.createBasicOCSPResponse( + FACTORY.createASN1Primitive(ocspClient.getEncoded(checkCert, caCert, null)))); + + ValidationReport report = new ValidationReport(); + certificateRetriever.addTrustedCertificates(Collections.singletonList(caCert)); + + OCSPValidator validator = validatorChainBuilder.buildOCSPValidator(); + validator.validate(report, baseContext, checkCert, basicOCSPResp.getResponses()[0], basicOCSPResp, + TimeTestUtil.TEST_DATE_TIME, TimeTestUtil.TEST_DATE_TIME); + + AssertValidationReport.assertThat(report, a -> a + .hasStatus(ValidationResult.INDETERMINATE)); + } @Test public void ocpsIssuerChainValidationsUsesCorrectParametersTest() throws CertificateException, IOException { Date checkDate = TimeTestUtil.TEST_DATE_TIME; validateTest(checkDate); - Assert.assertEquals(1, mockCertificateChainValidator.verificationCalls.size()); - Assert.assertEquals(responderCert, mockCertificateChainValidator.verificationCalls.get(0).certificate); - Assert.assertEquals(ValidatorContext.OCSP_VALIDATOR, mockCertificateChainValidator.verificationCalls.get(0).context.getValidatorContext()); - Assert.assertEquals(CertificateSource.OCSP_ISSUER, mockCertificateChainValidator.verificationCalls.get(0).context.getCertificateSource()); - Assert.assertEquals(checkDate, mockCertificateChainValidator.verificationCalls.get(0).checkDate); + Assertions.assertEquals(1, mockCertificateChainValidator.verificationCalls.size()); + Assertions.assertEquals(responderCert, mockCertificateChainValidator.verificationCalls.get(0).certificate); + Assertions.assertEquals(ValidatorContext.OCSP_VALIDATOR, mockCertificateChainValidator.verificationCalls.get(0).context.getValidatorContext()); + Assertions.assertEquals(CertificateSource.OCSP_ISSUER, mockCertificateChainValidator.verificationCalls.get(0).context.getCertificateSource()); + Assertions.assertEquals(checkDate, mockCertificateChainValidator.verificationCalls.get(0).checkDate); } @Test @@ -155,7 +214,7 @@ public void ocspForSelfSignedCertShouldNotValdateFurtherTest() throws GeneralSec .withMessage(RevocationDataValidator.SELF_SIGNED_CERTIFICATE) .withCertificate(caCert)) ); - Assert.assertEquals(0, mockCertificateChainValidator.verificationCalls.size()); + Assertions.assertEquals(0, mockCertificateChainValidator.verificationCalls.size()); } @Test @@ -199,7 +258,7 @@ public void serialNumbersDoNotMatchTest() throws GeneralSecurityException, IOExc .withMessage(OCSPValidator.SERIAL_NUMBERS_DO_NOT_MATCH) .withCertificate(checkCert)) ); - Assert.assertEquals(0, mockCertificateChainValidator.verificationCalls.size()); + Assertions.assertEquals(0, mockCertificateChainValidator.verificationCalls.size()); } @@ -213,8 +272,9 @@ public void issuersDoNotMatchTest() throws GeneralSecurityException, IOException FACTORY.createASN1Primitive(ocspClient.getEncoded(checkCert, caCert, null)))); ValidationReport report = new ValidationReport(); - validatorChainBuilder.withIssuingCertificateRetriever( - new TestIssuingCertificateRetriever(wrongRootCertFileName)); + TestIssuingCertificateRetriever wrongRootCertificateRetriever = new TestIssuingCertificateRetriever( + wrongRootCertFileName); + validatorChainBuilder.withIssuingCertificateRetrieverFactory(()-> wrongRootCertificateRetriever); OCSPValidator validator = validatorChainBuilder.buildOCSPValidator(); validator.validate(report, baseContext, checkCert, basicOCSPResp.getResponses()[0], basicOCSPResp, @@ -320,7 +380,7 @@ public void certificateStatusIsUnknownTest() throws GeneralSecurityException, IO .withMessage(OCSPValidator.CERT_STATUS_IS_UNKNOWN) .withCertificate(checkCert))); - Assert.assertEquals(0, mockCertificateChainValidator.verificationCalls.size()); + Assertions.assertEquals(0, mockCertificateChainValidator.verificationCalls.size()); } @Test @@ -506,7 +566,7 @@ public void certExpiredAfterArchiveCutoffDateTest() throws Exception { public void certificateRetrieverRetrieveIssuerCertificateFailureTest() throws GeneralSecurityException, IOException { Date checkDate = TimeTestUtil.TEST_DATE_TIME; MockIssuingCertificateRetriever mockCertificateRetriever = new MockIssuingCertificateRetriever(); - validatorChainBuilder.withIssuingCertificateRetriever(mockCertificateRetriever); + validatorChainBuilder.withIssuingCertificateRetrieverFactory(() -> mockCertificateRetriever); mockCertificateRetriever.onRetrieveIssuerCertificateDo(c -> { throw new RuntimeException("Test retrieveMissingCertificates failure"); }); @@ -524,7 +584,7 @@ public void certificateRetrieverRetrieveOCSPResponderCertificateFailureTest() th Date checkDate = TimeTestUtil.TEST_DATE_TIME; MockIssuingCertificateRetriever mockCertificateRetriever = new MockIssuingCertificateRetriever(certificateRetriever); - validatorChainBuilder.withIssuingCertificateRetriever(mockCertificateRetriever); + validatorChainBuilder.withIssuingCertificateRetrieverFactory(() -> mockCertificateRetriever); mockCertificateRetriever.onRetrieveOCSPResponderCertificateDo(c -> { throw new RuntimeException("Test retrieveMissingCertificates failure"); }); @@ -542,10 +602,15 @@ public void certificateRetrieverIsCertificateTrustedFailureTest() throws General Date checkDate = TimeTestUtil.TEST_DATE_TIME; MockIssuingCertificateRetriever mockCertificateRetriever = new MockIssuingCertificateRetriever(certificateRetriever); - validatorChainBuilder.withIssuingCertificateRetriever(mockCertificateRetriever); + validatorChainBuilder.withIssuingCertificateRetrieverFactory(() -> mockCertificateRetriever); mockCertificateRetriever.onIsCertificateTrustedDo(c -> { throw new RuntimeException("Test isCertificateTrusted failure"); }); + MockTrustedCertificatesStore mockTrustStore = new MockTrustedCertificatesStore(); + mockTrustStore.onIsCertificateTrustedForOcspDo(c -> { + throw new RuntimeException("Test isCertificateTrusted failure"); + }); + mockCertificateRetriever.onGetTrustedCertificatesStoreDo(() ->mockTrustStore); ValidationReport report = validateTest(checkDate); @@ -559,7 +624,7 @@ public void certificateRetrieverIsCertificateTrustedForOcspFailureTest() throws Date checkDate = TimeTestUtil.TEST_DATE_TIME; MockIssuingCertificateRetriever mockCertificateRetriever = new MockIssuingCertificateRetriever(certificateRetriever); - validatorChainBuilder.withIssuingCertificateRetriever(mockCertificateRetriever); + validatorChainBuilder.withIssuingCertificateRetrieverFactory(() -> mockCertificateRetriever); mockCertificateRetriever.onIsCertificateTrustedDo(c -> false); MockTrustedCertificatesStore mockTrustedStore = new MockTrustedCertificatesStore(certificateRetriever.getTrustedCertificatesStore()); @@ -639,8 +704,8 @@ public TestIssuingCertificateRetriever(String issuerPath) throws CertificateExce } @Override - public Certificate retrieveIssuerCertificate(Certificate certificate) { - return issuerCertificate; + public List retrieveIssuerCertificate(Certificate certificate) { + return Collections.singletonList((X509Certificate) issuerCertificate); } } } diff --git a/sign/src/test/java/com/itextpdf/signatures/validation/RevocationDataValidatorIntegrationTest.java b/sign/src/test/java/com/itextpdf/signatures/validation/RevocationDataValidatorIntegrationTest.java new file mode 100644 index 0000000000..8c649395a8 --- /dev/null +++ b/sign/src/test/java/com/itextpdf/signatures/validation/RevocationDataValidatorIntegrationTest.java @@ -0,0 +1,250 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2024 Apryse Group NV + Authors: Apryse Software. + + This program is offered under a commercial and under the AGPL license. + For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + + AGPL licensing: + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ +package com.itextpdf.signatures.validation; + +import com.itextpdf.bouncycastleconnector.BouncyCastleFactoryCreator; +import com.itextpdf.commons.bouncycastle.IBouncyCastleFactory; +import com.itextpdf.commons.bouncycastle.operator.AbstractOperatorCreationException; +import com.itextpdf.commons.bouncycastle.pkcs.AbstractPKCSException; +import com.itextpdf.commons.utils.DateTimeUtil; +import com.itextpdf.signatures.CertificateUtil; +import com.itextpdf.signatures.IssuingCertificateRetriever; +import com.itextpdf.signatures.testutils.PemFileHelper; +import com.itextpdf.signatures.testutils.TimeTestUtil; +import com.itextpdf.signatures.testutils.builder.TestCrlBuilder; +import com.itextpdf.signatures.testutils.builder.TestOcspResponseBuilder; +import com.itextpdf.signatures.testutils.client.TestCrlClient; +import com.itextpdf.signatures.testutils.client.TestOcspClient; +import com.itextpdf.signatures.validation.SignatureValidationProperties.OnlineFetching; +import com.itextpdf.signatures.validation.context.CertificateSource; +import com.itextpdf.signatures.validation.context.CertificateSources; +import com.itextpdf.signatures.validation.context.TimeBasedContext; +import com.itextpdf.signatures.validation.context.TimeBasedContexts; +import com.itextpdf.signatures.validation.context.ValidationContext; +import com.itextpdf.signatures.validation.context.ValidatorContext; +import com.itextpdf.signatures.validation.context.ValidatorContexts; +import com.itextpdf.signatures.validation.report.ReportItem; +import com.itextpdf.signatures.validation.report.ValidationReport; +import com.itextpdf.test.ExtendedITextTest; + +import java.security.cert.X509CRL; +import java.time.Duration; +import java.util.Date; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; + +import java.io.IOException; +import java.security.PrivateKey; +import java.security.Security; +import java.security.cert.CertificateException; +import java.security.cert.X509Certificate; +import java.util.Collections; + +@Tag("BouncyCastleUnitTest") +public class RevocationDataValidatorIntegrationTest extends ExtendedITextTest { + private static final IBouncyCastleFactory FACTORY = BouncyCastleFactoryCreator.getFactory(); + private static final String SOURCE_FOLDER = + "./src/test/resources/com/itextpdf/signatures/validation/RevocationDataValidatorTest/"; + + private static final String CRL_TEST_SOURCE_FOLDER = + "./src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/"; + + private static final char[] PASSWORD = "testpassphrase".toCharArray(); + + + private static X509Certificate caCert; + private static PrivateKey caPrivateKey; + private static X509Certificate checkCert; + private static X509Certificate responderCert; + private static PrivateKey ocspRespPrivateKey; + private IssuingCertificateRetriever certificateRetriever; + private SignatureValidationProperties parameters; + private ValidatorChainBuilder validatorChainBuilder; + private final ValidationContext baseContext = new ValidationContext(ValidatorContext.SIGNATURE_VALIDATOR, + CertificateSource.SIGNER_CERT, TimeBasedContext.PRESENT); + + @BeforeAll + public static void before() + throws CertificateException, IOException, AbstractOperatorCreationException, AbstractPKCSException { + Security.addProvider(FACTORY.getProvider()); + + String rootCertFileName = SOURCE_FOLDER + "rootCert.pem"; + String checkCertFileName = SOURCE_FOLDER + "signCert.pem"; + String ocspResponderCertFileName = SOURCE_FOLDER + "ocspResponderCert.pem"; + + caCert = (X509Certificate) PemFileHelper.readFirstChain(rootCertFileName)[0]; + caPrivateKey = PemFileHelper.readFirstKey(rootCertFileName, PASSWORD); + checkCert = (X509Certificate) PemFileHelper.readFirstChain(checkCertFileName)[0]; + responderCert = (X509Certificate) PemFileHelper.readFirstChain(ocspResponderCertFileName)[0]; + ocspRespPrivateKey = PemFileHelper.readFirstKey(ocspResponderCertFileName, PASSWORD); + } + + @BeforeEach + public void setUp() { + certificateRetriever = new IssuingCertificateRetriever(); + parameters = new SignatureValidationProperties(); + validatorChainBuilder = new ValidatorChainBuilder() + .withIssuingCertificateRetrieverFactory(() -> certificateRetriever) + .withSignatureValidationProperties(parameters); + } + + + @Test + public void crlWithOnlySomeReasonsTest() throws Exception { + TestCrlBuilder builder1 = new TestCrlBuilder(caCert, caPrivateKey); + builder1.addExtension(FACTORY.createExtension().getIssuingDistributionPoint(), true, + FACTORY.createIssuingDistributionPoint(null, false, false, + FACTORY.createReasonFlags(CRLValidator.ALL_REASONS - 31), false, false)); + TestCrlBuilder builder2 = new TestCrlBuilder(caCert, caPrivateKey); + builder2.addExtension(FACTORY.createExtension().getIssuingDistributionPoint(), true, + FACTORY.createIssuingDistributionPoint(null, false, false, + FACTORY.createReasonFlags(31), false, false)); + TestCrlClient crlClient = new TestCrlClient() + .addBuilderForCertIssuer(builder1) + .addBuilderForCertIssuer(builder2); + TestOcspResponseBuilder ocspBuilder = new TestOcspResponseBuilder(responderCert, ocspRespPrivateKey); + ocspBuilder.setProducedAt(DateTimeUtil.addDaysToDate(TimeTestUtil.TEST_DATE_TIME, -100)); + + certificateRetriever.setTrustedCertificates(Collections.singletonList(caCert)); + + parameters.setRevocationOnlineFetching(ValidatorContexts.all(), CertificateSources.all(), + TimeBasedContexts.all(), SignatureValidationProperties.OnlineFetching.NEVER_FETCH); + + + ValidationReport report = new ValidationReport(); + RevocationDataValidator validator = validatorChainBuilder.buildRevocationDataValidator(); + validator + .addOcspClient(new TestOcspClient().addBuilderForCertIssuer(caCert, ocspBuilder)) + .addCrlClient(crlClient); + + validator.validate(report, baseContext, checkCert, TimeTestUtil.TEST_DATE_TIME); + + AssertValidationReport.assertThat(report, a -> a + .hasNumberOfFailures(0) + .hasLogItem(la -> la + .withCertificate(checkCert) + .withStatus(ReportItem.ReportItemStatus.INFO) + .withMessage(CRLValidator.ONLY_SOME_REASONS_CHECKED) + )); + + } + + @Test + public void crlSignerIsValidatedCertificate() throws Exception { + + String rootCertFileName = CRL_TEST_SOURCE_FOLDER + "happyPath/ca.cert.pem"; + String crlSignerKeyFileName = CRL_TEST_SOURCE_FOLDER + "keys/crl-key.pem"; + String crlSignerFileName = CRL_TEST_SOURCE_FOLDER + "happyPath/crl-issuer.cert.pem"; + String checkCertFileName = CRL_TEST_SOURCE_FOLDER + "happyPath/sign.cert.pem"; + + X509Certificate caCert = (X509Certificate) PemFileHelper.readFirstChain(rootCertFileName)[0]; + X509Certificate crlSigner = (X509Certificate) PemFileHelper.readFirstChain(crlSignerFileName)[0]; + PrivateKey crlPrivateKey = PemFileHelper.readFirstKey(crlSignerKeyFileName, PASSWORD); + X509Certificate checkCert = (X509Certificate) PemFileHelper.readFirstChain(checkCertFileName)[0]; + + + certificateRetriever.addTrustedCertificates(Collections.singletonList(caCert)); + certificateRetriever.addKnownCertificates(Collections.singletonList(crlSigner)); + + Date checkDate = TimeTestUtil.TEST_DATE_TIME; + Date revocationDate = DateTimeUtil.addDaysToDate(checkDate, -1); + TestCrlBuilder builder = new TestCrlBuilder(crlSigner, crlPrivateKey, checkDate); + builder.setNextUpdate(DateTimeUtil.addDaysToDate(checkDate, 10)); + //builder.addCrlEntry(caCert, revocationDate, FACTORY.createCRLReason().getKeyCompromise()); + //TestCrlClientWrapper crlClient = new TestCrlClientWrapper(new TestCrlClient().addBuilderForCertIssuer(builder)); + + ValidationCrlClient crlClient = (ValidationCrlClient) parameters.getCrlClients().get(0); + crlClient.addCrl((X509CRL) CertificateUtil.parseCrlFromBytes(builder.makeCrl()), checkDate, TimeBasedContext.HISTORICAL ); + + ValidationReport report = new ValidationReport(); + certificateRetriever.addTrustedCertificates(Collections.singletonList(caCert)); + + parameters.setRevocationOnlineFetching(ValidatorContexts.all(), CertificateSources.all(), TimeBasedContexts.all(), OnlineFetching.FETCH_IF_NO_OTHER_DATA_AVAILABLE); + parameters.setFreshness(ValidatorContexts.all(), CertificateSources.all(), TimeBasedContexts.all(),Duration.ofDays(0)); + + + RevocationDataValidator validator = validatorChainBuilder.buildRevocationDataValidator(); + validatorChainBuilder.withRevocationDataValidatorFactory(()->validator); + + validator.validate(report, baseContext, crlSigner, checkDate); + + AssertValidationReport.assertThat(report, a -> a + .hasNumberOfFailures(1) + .hasLogItem(l-> l.withMessage(CRLValidator.CERTIFICATE_IN_ISSUER_CHAIN)) + ); + } + + @Test + public void crlSignerIssuerIsValidatedCertificate() throws Exception { + + String rootCertFileName = CRL_TEST_SOURCE_FOLDER + "crlSignerInValidatedChain/ca.cert.pem"; + String intermediateFileName = CRL_TEST_SOURCE_FOLDER + "crlSignerInValidatedChain/intermediate.cert.pem"; + String intermediate2FileName = CRL_TEST_SOURCE_FOLDER + "crlSignerInValidatedChain/intermediate2.cert.pem"; + String crlSignerKeyFileName = CRL_TEST_SOURCE_FOLDER + "keys/crl-key.pem"; + String crlSignerFileName = CRL_TEST_SOURCE_FOLDER + "crlSignerInValidatedChain/crl-issuer.cert.pem"; + String checkCertFileName = CRL_TEST_SOURCE_FOLDER + "crlSignerInValidatedChain/sign.cert.pem"; + + X509Certificate caCert = (X509Certificate) PemFileHelper.readFirstChain(rootCertFileName)[0]; + X509Certificate intermediateCert = (X509Certificate) PemFileHelper.readFirstChain(intermediateFileName)[0]; + X509Certificate intermediate2Cert = (X509Certificate) PemFileHelper.readFirstChain(intermediate2FileName)[0]; + X509Certificate crlSigner = (X509Certificate) PemFileHelper.readFirstChain(crlSignerFileName)[0]; + PrivateKey crlPrivateKey = PemFileHelper.readFirstKey(crlSignerKeyFileName, PASSWORD); + X509Certificate checkCert = (X509Certificate) PemFileHelper.readFirstChain(checkCertFileName)[0]; + + + certificateRetriever.addTrustedCertificates(Collections.singletonList(caCert)); + certificateRetriever.addKnownCertificates(Collections.singletonList(crlSigner)); + certificateRetriever.addKnownCertificates(Collections.singletonList(intermediateCert)); + certificateRetriever.addKnownCertificates(Collections.singletonList(intermediate2Cert)); + + Date checkDate = TimeTestUtil.TEST_DATE_TIME; + Date revocationDate = DateTimeUtil.addDaysToDate(checkDate, -1); + TestCrlBuilder builder = new TestCrlBuilder(crlSigner, crlPrivateKey, checkDate); + builder.setNextUpdate(DateTimeUtil.addDaysToDate(checkDate, 10)); + //builder.addCrlEntry(caCert, revocationDate, FACTORY.createCRLReason().getKeyCompromise()); + //TestCrlClientWrapper crlClient = new TestCrlClientWrapper(new TestCrlClient().addBuilderForCertIssuer(builder)); + + ValidationCrlClient crlClient = (ValidationCrlClient) parameters.getCrlClients().get(0); + crlClient.addCrl((X509CRL) CertificateUtil.parseCrlFromBytes(builder.makeCrl()), checkDate, TimeBasedContext.HISTORICAL ); + + ValidationReport report = new ValidationReport(); + //certificateRetriever.addTrustedCertificates(Collections.singletonList(caCert)); + + parameters.setRevocationOnlineFetching(ValidatorContexts.all(), CertificateSources.all(), TimeBasedContexts.all(), OnlineFetching.FETCH_IF_NO_OTHER_DATA_AVAILABLE); + parameters.setFreshness(ValidatorContexts.all(), CertificateSources.all(), TimeBasedContexts.all(),Duration.ofDays(0)); + + + RevocationDataValidator validator = validatorChainBuilder.buildRevocationDataValidator(); + validatorChainBuilder.withRevocationDataValidatorFactory(()->validator); + + validator.validate(report, baseContext, intermediateCert, checkDate); + + AssertValidationReport.assertThat(report, a -> a + .hasNumberOfFailures(1) + .hasLogItem(l-> l.withMessage(CRLValidator.CERTIFICATE_IN_ISSUER_CHAIN)) + ); + } +} + diff --git a/sign/src/test/java/com/itextpdf/signatures/validation/v1/RevocationDataValidatorTest.java b/sign/src/test/java/com/itextpdf/signatures/validation/RevocationDataValidatorTest.java similarity index 86% rename from sign/src/test/java/com/itextpdf/signatures/validation/v1/RevocationDataValidatorTest.java rename to sign/src/test/java/com/itextpdf/signatures/validation/RevocationDataValidatorTest.java index 0b933b4a7f..dc9a872728 100644 --- a/sign/src/test/java/com/itextpdf/signatures/validation/v1/RevocationDataValidatorTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/validation/RevocationDataValidatorTest.java @@ -20,7 +20,7 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.signatures.validation.v1; +package com.itextpdf.signatures.validation; import com.itextpdf.bouncycastleconnector.BouncyCastleFactoryCreator; import com.itextpdf.commons.bouncycastle.IBouncyCastleFactory; @@ -42,33 +42,31 @@ This file is part of the iText (R) project. import com.itextpdf.signatures.testutils.client.TestOcspClientWrapper; import com.itextpdf.signatures.testutils.client.TestCrlClient; import com.itextpdf.signatures.testutils.client.TestOcspClient; -import com.itextpdf.signatures.validation.v1.context.CertificateSource; -import com.itextpdf.signatures.validation.v1.context.CertificateSources; -import com.itextpdf.signatures.validation.v1.context.TimeBasedContext; -import com.itextpdf.signatures.validation.v1.context.TimeBasedContexts; -import com.itextpdf.signatures.validation.v1.context.ValidationContext; -import com.itextpdf.signatures.validation.v1.context.ValidatorContext; -import com.itextpdf.signatures.validation.v1.context.ValidatorContexts; -import com.itextpdf.signatures.validation.v1.mocks.MockCrlValidator; -import com.itextpdf.signatures.validation.v1.mocks.MockIssuingCertificateRetriever; -import com.itextpdf.signatures.validation.v1.mocks.MockOCSPValidator; -import com.itextpdf.signatures.validation.v1.mocks.MockSignatureValidationProperties; -import com.itextpdf.signatures.validation.v1.report.ReportItem; -import com.itextpdf.signatures.validation.v1.report.ValidationReport; +import com.itextpdf.signatures.validation.context.CertificateSource; +import com.itextpdf.signatures.validation.context.CertificateSources; +import com.itextpdf.signatures.validation.context.TimeBasedContext; +import com.itextpdf.signatures.validation.context.TimeBasedContexts; +import com.itextpdf.signatures.validation.context.ValidationContext; +import com.itextpdf.signatures.validation.context.ValidatorContext; +import com.itextpdf.signatures.validation.context.ValidatorContexts; +import com.itextpdf.signatures.validation.mocks.MockCrlValidator; +import com.itextpdf.signatures.validation.mocks.MockIssuingCertificateRetriever; +import com.itextpdf.signatures.validation.mocks.MockOCSPValidator; +import com.itextpdf.signatures.validation.mocks.MockSignatureValidationProperties; +import com.itextpdf.signatures.validation.report.ReportItem; +import com.itextpdf.signatures.validation.report.ValidationReport; +import com.itextpdf.signatures.validation.report.ValidationReport.ValidationResult; import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.LogLevelConstants; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.BouncyCastleUnitTest; + import java.security.cert.X509CRL; import java.util.ArrayList; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.security.GeneralSecurityException; @@ -81,12 +79,15 @@ This file is part of the iText (R) project. import java.util.Collection; import java.util.Collections; import java.util.Date; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; -@Category(BouncyCastleUnitTest.class) +@Tag("BouncyCastleUnitTest") public class RevocationDataValidatorTest extends ExtendedITextTest { private static final IBouncyCastleFactory FACTORY = BouncyCastleFactoryCreator.getFactory(); private static final String SOURCE_FOLDER = - "./src/test/resources/com/itextpdf/signatures/validation/v1/RevocationDataValidatorTest/"; + "./src/test/resources/com/itextpdf/signatures/validation/RevocationDataValidatorTest/"; private static final char[] PASSWORD = "testpassphrase".toCharArray(); private static X509Certificate caCert; private static PrivateKey caPrivateKey; @@ -104,7 +105,7 @@ public class RevocationDataValidatorTest extends ExtendedITextTest { private MockOCSPValidator mockOCSPValidator; private MockSignatureValidationProperties mockParameters; - @BeforeClass + @BeforeAll public static void before() throws CertificateException, IOException, AbstractOperatorCreationException, AbstractPKCSException { Security.addProvider(FACTORY.getProvider()); @@ -122,7 +123,7 @@ public static void before() trustedOcspResponderCert = (X509Certificate) PemFileHelper.readFirstChain(ocspResponderCertFileName)[0]; } - @Before + @BeforeEach public void setUp() { certificateRetriever = new IssuingCertificateRetriever(); parameters = new SignatureValidationProperties(); @@ -130,10 +131,10 @@ public void setUp() { mockOCSPValidator = new MockOCSPValidator(); mockParameters = new MockSignatureValidationProperties(parameters); validatorChainBuilder = new ValidatorChainBuilder() - .withIssuingCertificateRetriever(certificateRetriever) + .withIssuingCertificateRetrieverFactory(() -> certificateRetriever) .withSignatureValidationProperties(mockParameters) - .withCRLValidator(mockCrlValidator) - .withOCSPValidator(mockOCSPValidator); + .withCRLValidatorFactory(() -> mockCrlValidator) + .withOCSPValidatorFactory(() -> mockOCSPValidator); } @Test @@ -167,19 +168,19 @@ public void basicOCSPValidatorUsageTest() throws GeneralSecurityException, IOExc .hasNumberOfLogs(1) .hasLogItem(reportItem)); // there should be one call per ocspClient - Assert.assertEquals(1, ocspClient.getCalls().size()); + Assertions.assertEquals(1, ocspClient.getCalls().size()); // There was only one ocsp response so we expect 1 call to the ocsp validator - Assert.assertEquals(1, mockOCSPValidator.calls.size()); + Assertions.assertEquals(1, mockOCSPValidator.calls.size()); // the validationDate should be passed as is - Assert.assertEquals(checkDate, mockOCSPValidator.calls.get(0).validationDate); + Assertions.assertEquals(checkDate, mockOCSPValidator.calls.get(0).validationDate); // the response should be passed as is - Assert.assertEquals(ocspClient.getCalls().get(0).response, mockOCSPValidator.calls.get(0).ocspResp); + Assertions.assertEquals(ocspClient.getCalls().get(0).response, mockOCSPValidator.calls.get(0).ocspResp); // There should be a new report generated and any logs must be copied the actual report. - Assert.assertNotEquals(report, mockOCSPValidator.calls.get(0).report); + Assertions.assertNotEquals(report, mockOCSPValidator.calls.get(0).report); } @Test @@ -212,14 +213,14 @@ public void basicCrlValidatorUsageTest() throws GeneralSecurityException { .hasNumberOfLogs(1) .hasLogItem(reportItem)); // there should be one call per CrlClient - Assert.assertEquals(1, crlClient.getCalls().size()); + Assertions.assertEquals(1, crlClient.getCalls().size()); // since there was one response there should be one validator call - Assert.assertEquals(1, mockCrlValidator.calls.size()); - Assert.assertEquals(checkCert, mockCrlValidator.calls.get(0).certificate); - Assert.assertEquals(checkDate, mockCrlValidator.calls.get(0).validationDate); + Assertions.assertEquals(1, mockCrlValidator.calls.size()); + Assertions.assertEquals(checkCert, mockCrlValidator.calls.get(0).certificate); + Assertions.assertEquals(checkDate, mockCrlValidator.calls.get(0).validationDate); // There should be a new report generated and any logs must be copied the actual report. - Assert.assertNotEquals(report, mockCrlValidator.calls.get(0).report); - Assert.assertEquals(crlClient.getCalls().get(0).responses.get(0), mockCrlValidator.calls.get(0).crl); + Assertions.assertNotEquals(report, mockCrlValidator.calls.get(0).report); + Assertions.assertEquals(crlClient.getCalls().get(0).responses.get(0), mockCrlValidator.calls.get(0).crl); } @Test @@ -253,9 +254,9 @@ public void crlResponseOrderingTest() throws CertificateEncodingException { ValidationReport report = new ValidationReport(); validator.validate(report, baseContext, checkCert, checkDate); - Assert.assertEquals(crlClient3.getCalls().get(0).responses.get(0), mockCrlValidator.calls.get(0).crl); - Assert.assertEquals(crlClient2.getCalls().get(0).responses.get(0), mockCrlValidator.calls.get(1).crl); - Assert.assertEquals(crlClient1.getCalls().get(0).responses.get(0), mockCrlValidator.calls.get(2).crl); + Assertions.assertEquals(crlClient3.getCalls().get(0).responses.get(0), mockCrlValidator.calls.get(0).crl); + Assertions.assertEquals(crlClient2.getCalls().get(0).responses.get(0), mockCrlValidator.calls.get(1).crl); + Assertions.assertEquals(crlClient1.getCalls().get(0).responses.get(0), mockCrlValidator.calls.get(2).crl); } @Test @@ -301,9 +302,9 @@ public void ocspResponseOrderingTest() throws GeneralSecurityException, IOExcept validator.validate(report, baseContext, checkCert, checkDate); - Assert.assertEquals(ocspClient2.getCalls().get(0).response, mockOCSPValidator.calls.get(0).ocspResp); - Assert.assertEquals(ocspClient3.getCalls().get(0).response, mockOCSPValidator.calls.get(1).ocspResp); - Assert.assertEquals(ocspClient1.getCalls().get(0).response, mockOCSPValidator.calls.get(2).ocspResp); + Assertions.assertEquals(ocspClient2.getCalls().get(0).response, mockOCSPValidator.calls.get(0).ocspResp); + Assertions.assertEquals(ocspClient3.getCalls().get(0).response, mockOCSPValidator.calls.get(1).ocspResp); + Assertions.assertEquals(ocspClient1.getCalls().get(0).response, mockOCSPValidator.calls.get(2).ocspResp); } @Test @@ -326,6 +327,46 @@ public void validityAssuredTest() throws CertificateException, IOException { )); } + @Test + public void noRevAvailTest() throws CertificateException, IOException { + String checkCertFileName = SOURCE_FOLDER + "noRevAvailCertWithoutCA.pem"; + X509Certificate certificate = (X509Certificate) PemFileHelper.readFirstChain(checkCertFileName)[0]; + Date checkDate = TimeTestUtil.TEST_DATE_TIME; + + ValidationReport report = new ValidationReport(); + RevocationDataValidator validator = validatorChainBuilder.buildRevocationDataValidator(); + + validator.validate(report, baseContext, certificate, checkDate); + + AssertValidationReport.assertThat(report, a -> a + .hasStatus(ValidationResult.VALID) + .hasLogItem(la -> la + .withCheckName(RevocationDataValidator.REVOCATION_DATA_CHECK) + .withMessage(RevocationDataValidator.NO_REV_AVAILABLE, m -> certificate.getSubjectX500Principal()) + .withCertificate(certificate) + )); + } + + @Test + public void noRevAvailWithCATest() throws CertificateException, IOException { + String checkCertFileName = SOURCE_FOLDER + "noRevAvailCert.pem"; + X509Certificate certificate = (X509Certificate) PemFileHelper.readFirstChain(checkCertFileName)[0]; + Date checkDate = TimeTestUtil.TEST_DATE_TIME; + + ValidationReport report = new ValidationReport(); + RevocationDataValidator validator = validatorChainBuilder.buildRevocationDataValidator(); + + validator.validate(report, baseContext, certificate, checkDate); + + AssertValidationReport.assertThat(report, a -> a + .hasStatus(ValidationResult.INDETERMINATE) + .hasLogItem(la -> la + .withCheckName(RevocationDataValidator.REVOCATION_DATA_CHECK) + .withMessage(RevocationDataValidator.NO_REV_AVAILABLE_CA, m -> certificate.getSubjectX500Principal()) + .withCertificate(certificate) + )); + } + @Test public void selfSignedCertificateIsNotValidatedTest() { Date checkDate = TimeTestUtil.TEST_DATE_TIME; @@ -605,16 +646,16 @@ public void sortResponsesTest() throws GeneralSecurityException, IOException { }); validator.validate(report, baseContext, checkCert, checkDate); - Assert.assertTrue(mockOCSPValidator.calls.get(0).timeStamp.before(mockOCSPValidator.calls.get(1).timeStamp)); - Assert.assertTrue(mockOCSPValidator.calls.get(1).timeStamp.before(mockCrlValidator.calls.get(0).timeStamp)); - Assert.assertTrue(mockCrlValidator.calls.get(0).timeStamp.before(mockCrlValidator.calls.get(1).timeStamp)); - Assert.assertTrue(mockCrlValidator.calls.get(1).timeStamp.before(mockOCSPValidator.calls.get(2).timeStamp)); + Assertions.assertTrue(mockOCSPValidator.calls.get(0).timeStamp.before(mockOCSPValidator.calls.get(1).timeStamp)); + Assertions.assertTrue(mockOCSPValidator.calls.get(1).timeStamp.before(mockCrlValidator.calls.get(0).timeStamp)); + Assertions.assertTrue(mockCrlValidator.calls.get(0).timeStamp.before(mockCrlValidator.calls.get(1).timeStamp)); + Assertions.assertTrue(mockCrlValidator.calls.get(1).timeStamp.before(mockOCSPValidator.calls.get(2).timeStamp)); - Assert.assertEquals(ocspClient1.getCalls().get(0).response, mockOCSPValidator.calls.get(2).ocspResp); - Assert.assertEquals(ocspClient2.getCalls().get(0).response, mockOCSPValidator.calls.get(1).ocspResp); - Assert.assertEquals(ocspClient3.getCalls().get(0).response, mockOCSPValidator.calls.get(0).ocspResp); - Assert.assertEquals(crlClient.getCalls().get(0).responses.get(0), mockCrlValidator.calls.get(1).crl); - Assert.assertEquals(crlClient.getCalls().get(0).responses.get(1), mockCrlValidator.calls.get(0).crl); + Assertions.assertEquals(ocspClient1.getCalls().get(0).response, mockOCSPValidator.calls.get(2).ocspResp); + Assertions.assertEquals(ocspClient2.getCalls().get(0).response, mockOCSPValidator.calls.get(1).ocspResp); + Assertions.assertEquals(ocspClient3.getCalls().get(0).response, mockOCSPValidator.calls.get(0).ocspResp); + Assertions.assertEquals(crlClient.getCalls().get(0).responses.get(0), mockCrlValidator.calls.get(1).crl); + Assertions.assertEquals(crlClient.getCalls().get(0).responses.get(1), mockCrlValidator.calls.get(0).crl); } @Test @@ -623,11 +664,11 @@ public void responsesFromValidationClientArePassedTest() throws GeneralSecurityE Date ocspGeneration = DateTimeUtil.addDaysToDate(checkDate, 2); // Here we check that proper generation time was set. - mockOCSPValidator.onCallDo(c -> Assert.assertEquals(ocspGeneration, c.responseGenerationDate)); + mockOCSPValidator.onCallDo(c -> Assertions.assertEquals(ocspGeneration, c.responseGenerationDate)); Date crlGeneration = DateTimeUtil.addDaysToDate(checkDate, 3); // Here we check that proper generation time was set. - mockCrlValidator.onCallDo(c -> Assert.assertEquals(crlGeneration, c.responseGenerationDate)); + mockCrlValidator.onCallDo(c -> Assertions.assertEquals(crlGeneration, c.responseGenerationDate)); ValidationReport report = new ValidationReport(); RevocationDataValidator validator = validatorChainBuilder.getRevocationDataValidator(); @@ -635,7 +676,7 @@ public void responsesFromValidationClientArePassedTest() throws GeneralSecurityE ValidationOcspClient ocspClient = new ValidationOcspClient() { @Override public byte[] getEncoded(X509Certificate checkCert, X509Certificate issuerCert, String url) { - Assert.fail("This method shall not be called"); + Assertions.fail("This method shall not be called"); return null; } }; @@ -650,7 +691,7 @@ public byte[] getEncoded(X509Certificate checkCert, X509Certificate issuerCert, ValidationCrlClient crlClient = new ValidationCrlClient() { @Override public Collection getEncoded(X509Certificate checkCert, String url) { - Assert.fail("This method shall not be called"); + Assertions.fail("This method shall not be called"); return null; } }; @@ -667,9 +708,9 @@ public Collection getEncoded(X509Certificate checkCert, String url) { public void timeBasedContextProperlySetValidationClientsTest() throws GeneralSecurityException, IOException { Date checkDate = TimeTestUtil.TEST_DATE_TIME; - mockOCSPValidator.onCallDo(c -> Assert.assertEquals(TimeBasedContext.HISTORICAL, c.context.getTimeBasedContext())); + mockOCSPValidator.onCallDo(c -> Assertions.assertEquals(TimeBasedContext.HISTORICAL, c.context.getTimeBasedContext())); - mockCrlValidator.onCallDo(c -> Assert.assertEquals(TimeBasedContext.HISTORICAL, c.context.getTimeBasedContext())); + mockCrlValidator.onCallDo(c -> Assertions.assertEquals(TimeBasedContext.HISTORICAL, c.context.getTimeBasedContext())); ValidationReport report = new ValidationReport(); RevocationDataValidator validator = validatorChainBuilder.getRevocationDataValidator(); @@ -698,8 +739,8 @@ public void timeBasedContextProperlySetRandomClientsTest() throws GeneralSecurit Date checkDate = TimeTestUtil.TEST_DATE_TIME; certificateRetriever.addTrustedCertificates(Collections.singletonList(caCert)); - mockOCSPValidator.onCallDo(c -> Assert.assertEquals(TimeBasedContext.PRESENT, c.context.getTimeBasedContext())); - mockCrlValidator.onCallDo(c -> Assert.assertEquals(TimeBasedContext.PRESENT, c.context.getTimeBasedContext())); + mockOCSPValidator.onCallDo(c -> Assertions.assertEquals(TimeBasedContext.PRESENT, c.context.getTimeBasedContext())); + mockCrlValidator.onCallDo(c -> Assertions.assertEquals(TimeBasedContext.PRESENT, c.context.getTimeBasedContext())); ValidationReport report = new ValidationReport(); RevocationDataValidator validator = validatorChainBuilder.getRevocationDataValidator(); @@ -718,8 +759,8 @@ public void timeBasedContextProperlySetOnlineClientsTest() throws GeneralSecurit Date checkDate = TimeTestUtil.TEST_DATE_TIME; certificateRetriever.addTrustedCertificates(Collections.singletonList(caCert)); - mockOCSPValidator.onCallDo(c -> Assert.assertEquals(TimeBasedContext.PRESENT, c.context.getTimeBasedContext())); - mockCrlValidator.onCallDo(c -> Assert.assertEquals(TimeBasedContext.PRESENT, c.context.getTimeBasedContext())); + mockOCSPValidator.onCallDo(c -> Assertions.assertEquals(TimeBasedContext.PRESENT, c.context.getTimeBasedContext())); + mockCrlValidator.onCallDo(c -> Assertions.assertEquals(TimeBasedContext.PRESENT, c.context.getTimeBasedContext())); ValidationReport report = new ValidationReport(); RevocationDataValidator validator = validatorChainBuilder.getRevocationDataValidator(); @@ -827,7 +868,7 @@ public void certificateRetrieverRetrieveIssuerCertificateFailureTest() throws Ge new MockIssuingCertificateRetriever(certificateRetriever).onRetrieveIssuerCertificateDo(c -> { throw new RuntimeException("Test retrieveIssuerCertificate failure"); }); - validatorChainBuilder.withIssuingCertificateRetriever(mockCertificateRetreiver); + validatorChainBuilder.withIssuingCertificateRetrieverFactory(()-> mockCertificateRetreiver); RevocationDataValidator validator = validatorChainBuilder.buildRevocationDataValidator(); validator.addOcspClient(ocspClient); @@ -840,7 +881,7 @@ public void certificateRetrieverRetrieveIssuerCertificateFailureTest() throws Ge AssertValidationReport.assertThat(report, a -> a .hasStatus(ValidationReport.ValidationResult.INDETERMINATE) - .hasLogItem(l -> l.withMessage(RevocationDataValidator.ISSUER_RETRIEVAL_FAILED))); + .hasLogItem(l -> l.withMessage(RevocationDataValidator.UNABLE_TO_RETRIEVE_REV_DATA_ONLINE))); } @Test diff --git a/sign/src/test/java/com/itextpdf/signatures/validation/v1/SignatureValidationPropertiesTest.java b/sign/src/test/java/com/itextpdf/signatures/validation/SignatureValidationPropertiesTest.java similarity index 79% rename from sign/src/test/java/com/itextpdf/signatures/validation/v1/SignatureValidationPropertiesTest.java rename to sign/src/test/java/com/itextpdf/signatures/validation/SignatureValidationPropertiesTest.java index 6787770f04..6c4320cd18 100644 --- a/sign/src/test/java/com/itextpdf/signatures/validation/v1/SignatureValidationPropertiesTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/validation/SignatureValidationPropertiesTest.java @@ -20,29 +20,28 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.signatures.validation.v1; - -import com.itextpdf.signatures.validation.v1.SignatureValidationProperties.ContextProperties; -import com.itextpdf.signatures.validation.v1.context.CertificateSource; -import com.itextpdf.signatures.validation.v1.context.CertificateSources; -import com.itextpdf.signatures.validation.v1.context.TimeBasedContext; -import com.itextpdf.signatures.validation.v1.context.TimeBasedContexts; -import com.itextpdf.signatures.validation.v1.context.ValidationContext; -import com.itextpdf.signatures.validation.v1.context.ValidatorContext; -import com.itextpdf.signatures.validation.v1.context.ValidatorContexts; -import com.itextpdf.signatures.validation.v1.extensions.CertificateExtension; -import com.itextpdf.signatures.validation.v1.extensions.KeyUsageExtension; +package com.itextpdf.signatures.validation; + +import com.itextpdf.signatures.validation.SignatureValidationProperties.ContextProperties; +import com.itextpdf.signatures.validation.context.CertificateSource; +import com.itextpdf.signatures.validation.context.CertificateSources; +import com.itextpdf.signatures.validation.context.TimeBasedContext; +import com.itextpdf.signatures.validation.context.TimeBasedContexts; +import com.itextpdf.signatures.validation.context.ValidationContext; +import com.itextpdf.signatures.validation.context.ValidatorContext; +import com.itextpdf.signatures.validation.context.ValidatorContexts; +import com.itextpdf.signatures.validation.extensions.CertificateExtension; +import com.itextpdf.signatures.validation.extensions.KeyUsageExtension; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.time.Duration; import java.util.Collections; import java.util.function.Consumer; -@Category(UnitTest.class) +@Tag("UnitTest") public class SignatureValidationPropertiesTest extends ExtendedITextTest { @Test @@ -56,19 +55,19 @@ public void getParametersValueForSpecificTest() { new IncrementalFreshnessValueSetter(10, 1).getAction()); // test the last value added - Assert.assertEquals(Duration.ofDays(18), + Assertions.assertEquals(Duration.ofDays(18), sut.getParametersValueFor(ValidatorContext.SIGNATURE_VALIDATOR, CertificateSource.TIMESTAMP, TimeBasedContext.HISTORICAL, (p -> p.getFreshness()))); //test the fifth value added - Assert.assertEquals(Duration.ofDays(14), + Assertions.assertEquals(Duration.ofDays(14), sut.getParametersValueFor(ValidatorContext.CRL_VALIDATOR, CertificateSource.SIGNER_CERT, TimeBasedContext.HISTORICAL, (p -> p.getFreshness()))); // test the general default - Assert.assertEquals(SignatureValidationProperties.DEFAULT_FRESHNESS_HISTORICAL, + Assertions.assertEquals(SignatureValidationProperties.DEFAULT_FRESHNESS_HISTORICAL, sut.getParametersValueFor(ValidatorContext.CERTIFICATE_CHAIN_VALIDATOR, CertificateSource.OCSP_ISSUER, TimeBasedContext.HISTORICAL, (p -> p.getFreshness()))); @@ -87,7 +86,7 @@ public void getParametersValueForDefaultTest() { new IncrementalFreshnessValueSetter(10, 1).getAction()); // test the general default - Assert.assertEquals(SignatureValidationProperties.DEFAULT_FRESHNESS_PRESENT_OCSP, + Assertions.assertEquals(SignatureValidationProperties.DEFAULT_FRESHNESS_PRESENT_OCSP, sut.getParametersValueFor(ValidatorContext.CERTIFICATE_CHAIN_VALIDATOR, CertificateSource.OCSP_ISSUER, TimeBasedContext.PRESENT, (p -> p.getFreshness()))); @@ -110,7 +109,7 @@ public void setDefaultAsLastShouldOverrideAll() { p -> p.setFreshness(Duration.ofDays(25))); // test the general default - Assert.assertEquals(Duration.ofDays(25), + Assertions.assertEquals(Duration.ofDays(25), sut.getParametersValueFor(ValidatorContext.OCSP_VALIDATOR, CertificateSource.SIGNER_CERT, TimeBasedContext.PRESENT, (p -> p.getFreshness()))); @@ -122,12 +121,12 @@ public void setAndGetFreshnessTest() { sut.setFreshness(ValidatorContexts.of(ValidatorContext.CRL_VALIDATOR), CertificateSources.of(CertificateSource.CERT_ISSUER), TimeBasedContexts.of(TimeBasedContext.HISTORICAL), Duration.ofDays(-10)); - Assert.assertEquals(Duration.ofDays(-10), + Assertions.assertEquals(Duration.ofDays(-10), sut.getFreshness( new ValidationContext(ValidatorContext.CRL_VALIDATOR, CertificateSource.CERT_ISSUER, TimeBasedContext.HISTORICAL))); - Assert.assertEquals(SignatureValidationProperties.DEFAULT_FRESHNESS_PRESENT_CRL, + Assertions.assertEquals(SignatureValidationProperties.DEFAULT_FRESHNESS_PRESENT_CRL, sut.getFreshness( new ValidationContext(ValidatorContext.CRL_VALIDATOR, CertificateSource.CERT_ISSUER, TimeBasedContext.PRESENT))); @@ -141,10 +140,10 @@ public void setAndGetContinueAfterFailure() { sut.setContinueAfterFailure(ValidatorContexts.of(ValidatorContext.SIGNATURE_VALIDATOR), CertificateSources.of(CertificateSource.OCSP_ISSUER), false); - Assert.assertEquals(Boolean.TRUE, sut.getContinueAfterFailure( + Assertions.assertEquals(Boolean.TRUE, sut.getContinueAfterFailure( new ValidationContext(ValidatorContext.SIGNATURE_VALIDATOR, CertificateSource.CERT_ISSUER, TimeBasedContext.PRESENT))); - Assert.assertEquals(Boolean.FALSE, sut.getContinueAfterFailure( + Assertions.assertEquals(Boolean.FALSE, sut.getContinueAfterFailure( new ValidationContext(ValidatorContext.SIGNATURE_VALIDATOR, CertificateSource.OCSP_ISSUER, TimeBasedContext.PRESENT))); } @@ -155,13 +154,13 @@ public void setRevocationOnlineFetchingTest() { sut.setRevocationOnlineFetching(ValidatorContexts.of(ValidatorContext.CRL_VALIDATOR), CertificateSources.all(), TimeBasedContexts.of(TimeBasedContext.PRESENT), SignatureValidationProperties.OnlineFetching.ALWAYS_FETCH); - Assert.assertEquals(SignatureValidationProperties.DEFAULT_ONLINE_FETCHING, sut.getRevocationOnlineFetching( + Assertions.assertEquals(SignatureValidationProperties.DEFAULT_ONLINE_FETCHING, sut.getRevocationOnlineFetching( new ValidationContext(ValidatorContext.CRL_VALIDATOR, CertificateSource.OCSP_ISSUER, TimeBasedContext.HISTORICAL))); - Assert.assertEquals(SignatureValidationProperties.DEFAULT_ONLINE_FETCHING, sut.getRevocationOnlineFetching( + Assertions.assertEquals(SignatureValidationProperties.DEFAULT_ONLINE_FETCHING, sut.getRevocationOnlineFetching( new ValidationContext(ValidatorContext.OCSP_VALIDATOR, CertificateSource.OCSP_ISSUER, TimeBasedContext.PRESENT))); - Assert.assertEquals(SignatureValidationProperties.OnlineFetching.ALWAYS_FETCH, sut.getRevocationOnlineFetching( + Assertions.assertEquals(SignatureValidationProperties.OnlineFetching.ALWAYS_FETCH, sut.getRevocationOnlineFetching( new ValidationContext(ValidatorContext.CRL_VALIDATOR, CertificateSource.OCSP_ISSUER, TimeBasedContext.PRESENT))); } @@ -176,13 +175,13 @@ public void setRequiredExtensionsTest() { sut.setRequiredExtensions(CertificateSources.of(CertificateSource.OCSP_ISSUER), Collections.singletonList(new KeyUsageExtension(3))); - Assert.assertEquals(Collections.singletonList(new KeyUsageExtension(1)), + Assertions.assertEquals(Collections.singletonList(new KeyUsageExtension(1)), sut.getRequiredExtensions(new ValidationContext(ValidatorContext.CERTIFICATE_CHAIN_VALIDATOR, CertificateSource.SIGNER_CERT, TimeBasedContext.PRESENT))); - Assert.assertEquals(Collections.singletonList(new KeyUsageExtension(2)), sut.getRequiredExtensions( + Assertions.assertEquals(Collections.singletonList(new KeyUsageExtension(2)), sut.getRequiredExtensions( new ValidationContext(ValidatorContext.CERTIFICATE_CHAIN_VALIDATOR, CertificateSource.CERT_ISSUER, TimeBasedContext.PRESENT))); - Assert.assertEquals(Collections.singletonList(new KeyUsageExtension(3)), sut.getRequiredExtensions( + Assertions.assertEquals(Collections.singletonList(new KeyUsageExtension(3)), sut.getRequiredExtensions( new ValidationContext(ValidatorContext.CERTIFICATE_CHAIN_VALIDATOR, CertificateSource.OCSP_ISSUER, TimeBasedContext.HISTORICAL))); } diff --git a/sign/src/test/java/com/itextpdf/signatures/validation/v1/SignatureValidatorIntegrationTest.java b/sign/src/test/java/com/itextpdf/signatures/validation/SignatureValidatorIntegrationTest.java similarity index 66% rename from sign/src/test/java/com/itextpdf/signatures/validation/v1/SignatureValidatorIntegrationTest.java rename to sign/src/test/java/com/itextpdf/signatures/validation/SignatureValidatorIntegrationTest.java index f1da5ba4e2..6f75d86115 100644 --- a/sign/src/test/java/com/itextpdf/signatures/validation/v1/SignatureValidatorIntegrationTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/validation/SignatureValidatorIntegrationTest.java @@ -20,41 +20,46 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.signatures.validation.v1; +package com.itextpdf.signatures.validation; import com.itextpdf.bouncycastleconnector.BouncyCastleFactoryCreator; import com.itextpdf.commons.bouncycastle.IBouncyCastleFactory; import com.itextpdf.commons.bouncycastle.operator.AbstractOperatorCreationException; import com.itextpdf.commons.bouncycastle.pkcs.AbstractPKCSException; import com.itextpdf.commons.utils.DateTimeUtil; +import com.itextpdf.commons.utils.FileUtil; +import com.itextpdf.kernel.crypto.CryptoUtil; +import com.itextpdf.kernel.logs.KernelLogMessageConstant; import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfReader; +import com.itextpdf.kernel.pdf.ReaderProperties; import com.itextpdf.signatures.ICrlClient; import com.itextpdf.signatures.IOcspClient; import com.itextpdf.signatures.IssuingCertificateRetriever; import com.itextpdf.signatures.testutils.PemFileHelper; import com.itextpdf.signatures.testutils.builder.TestOcspResponseBuilder; import com.itextpdf.signatures.testutils.client.TestOcspClient; -import com.itextpdf.signatures.validation.v1.context.CertificateSource; -import com.itextpdf.signatures.validation.v1.context.CertificateSources; -import com.itextpdf.signatures.validation.v1.context.TimeBasedContext; -import com.itextpdf.signatures.validation.v1.context.TimeBasedContexts; -import com.itextpdf.signatures.validation.v1.context.ValidatorContext; -import com.itextpdf.signatures.validation.v1.context.ValidatorContexts; -import com.itextpdf.signatures.validation.v1.mocks.MockRevocationDataValidator; -import com.itextpdf.signatures.validation.v1.report.ReportItem; -import com.itextpdf.signatures.validation.v1.report.ValidationReport; -import com.itextpdf.signatures.validation.v1.report.ValidationReport.ValidationResult; +import com.itextpdf.signatures.validation.context.CertificateSource; +import com.itextpdf.signatures.validation.context.CertificateSources; +import com.itextpdf.signatures.validation.context.TimeBasedContext; +import com.itextpdf.signatures.validation.context.TimeBasedContexts; +import com.itextpdf.signatures.validation.context.ValidatorContext; +import com.itextpdf.signatures.validation.context.ValidatorContexts; +import com.itextpdf.signatures.validation.mocks.MockRevocationDataValidator; +import com.itextpdf.signatures.validation.report.ReportItem; +import com.itextpdf.signatures.validation.report.ValidationReport; +import com.itextpdf.signatures.validation.report.ValidationReport.ValidationResult; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.BouncyCastleIntegrationTest; +import com.itextpdf.test.annotations.LogMessage; +import com.itextpdf.test.annotations.LogMessages; +import java.nio.charset.StandardCharsets; import java.util.List; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; + +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.security.GeneralSecurityException; @@ -67,11 +72,14 @@ This file is part of the iText (R) project. import java.util.Arrays; import java.util.Collections; import java.util.Date; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; -@Category(BouncyCastleIntegrationTest.class) +@Tag("BouncyCastleIntegrationTest") public class SignatureValidatorIntegrationTest extends ExtendedITextTest { - private static final String CERTS_SRC = "./src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorIntegrationTest/certs/"; - private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorIntegrationTest/"; + private static final String CERTS_SRC = "./src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorIntegrationTest/certs/"; + private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorIntegrationTest/"; private static final IBouncyCastleFactory FACTORY = BouncyCastleFactoryCreator.getFactory(); private static final char[] PASSWORD = "testpassphrase".toCharArray(); @@ -79,17 +87,17 @@ public class SignatureValidatorIntegrationTest extends ExtendedITextTest { private IssuingCertificateRetriever certificateRetriever; private ValidatorChainBuilder builder; - @BeforeClass + @BeforeAll public static void before() { Security.addProvider(FACTORY.getProvider()); } - @Before + @BeforeEach public void setUp() { parameters = new SignatureValidationProperties(); certificateRetriever = new IssuingCertificateRetriever(); builder = new ValidatorChainBuilder() - .withIssuingCertificateRetriever(certificateRetriever) + .withIssuingCertificateRetrieverFactory(()-> certificateRetriever) .withSignatureValidationProperties(parameters); } @@ -106,16 +114,100 @@ public void validLatestSignatureTest() throws GeneralSecurityException, IOExcept addRevDataClients(); SignatureValidator signatureValidator = builder.buildSignatureValidator(document); - report = signatureValidator.validateLatestSignature(document); + report = signatureValidator.validateSignatures(); } AssertValidationReport.assertThat(report, a -> a .hasStatus(ValidationResult.VALID) - .hasLogItems(3, al -> al + .hasLogItem(al -> al .withCertificate(rootCert) .withCheckName(CertificateChainValidator.CERTIFICATE_CHECK) .withMessage(CertificateChainValidator.CERTIFICATE_TRUSTED, i -> rootCert.getSubjectX500Principal())) + .hasLogItem(al -> al + .withCheckName(OCSPValidator.OCSP_CHECK) + .withMessage(OCSPValidator.OCSP_RESPONDER_TRUSTED)) + .hasLogItem(al -> al + .withCheckName(OCSPValidator.OCSP_CHECK) + .withMessage(OCSPValidator.OCSP_RESPONDER_IS_CA)) + ); + } + + @Test + @LogMessages(messages = { + @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT, ignore = true)}) + public void validateSignatureInEncryptedDocumentTest() + throws IOException, CertificateException { + String chainName = CERTS_SRC + "signCertRsa01.pem"; + Certificate[] certificateChain = PemFileHelper.readFirstChain(chainName); + X509Certificate rootCert = (X509Certificate) certificateChain[1]; + + ValidationReport report; + try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "encryptedDoc.pdf", + new ReaderProperties().setPassword("123".getBytes(StandardCharsets.ISO_8859_1))))) { + SignatureValidator signatureValidator = builder.buildSignatureValidator(document); + report = signatureValidator.validateSignatures(); + } + + Assertions.assertEquals(2, report.getFailures().size()); + AssertValidationReport.assertThat(report, a -> a + .hasStatus(ValidationResult.INDETERMINATE) + .hasLogItem(al -> al + .withCertificate(rootCert) + .withCheckName(CertificateChainValidator.CERTIFICATE_CHECK) + .withMessage(CertificateChainValidator.ISSUER_MISSING, + i -> rootCert.getSubjectX500Principal())) + .hasLogItem(al -> al + .withCheckName(RevocationDataValidator.REVOCATION_DATA_CHECK) + .withMessage(RevocationDataValidator.NO_REVOCATION_DATA)) + .hasLogItem(al -> al + .withCheckName(RevocationDataValidator.REVOCATION_DATA_CHECK) + .withMessage(RevocationDataValidator.SELF_SIGNED_CERTIFICATE)) + ); + } + + @Test + @LogMessages(messages = { + @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT, ignore = true)}) + public void validateSignatureInEncryptedPubKeyDocumentTest() + throws IOException, CertificateException, AbstractOperatorCreationException, AbstractPKCSException { + try { + BouncyCastleFactoryCreator.getFactory().isEncryptionFeatureSupported(0, true); + } catch (Exception ignored) { + Assumptions.assumeTrue(false); + } + + String chainName = CERTS_SRC + "signCertRsa01.pem"; + Certificate[] certificateChain = PemFileHelper.readFirstChain(chainName); + X509Certificate rootCert = (X509Certificate) certificateChain[1]; + + ValidationReport report; + Certificate certificate = CryptoUtil.readPublicCertificate( + FileUtil.getInputStreamForFile(CERTS_SRC + "SHA256withRSA.cer")); + PrivateKey privateKey = PemFileHelper.readFirstKey(CERTS_SRC + "SHA256withRSA.key", PASSWORD); + ReaderProperties properties = new ReaderProperties().setPublicKeySecurityParams(certificate, privateKey, + FACTORY.getProviderName(), null); + + try (PdfDocument document = new PdfDocument( + new PdfReader(SOURCE_FOLDER + "encryptedPublicKeyDocTest.pdf", properties))) { + SignatureValidator signatureValidator = builder.buildSignatureValidator(document); + report = signatureValidator.validateSignatures(); + } + + Assertions.assertEquals(2, report.getFailures().size()); + AssertValidationReport.assertThat(report, a -> a + .hasStatus(ValidationResult.INDETERMINATE) + .hasLogItem(al -> al + .withCertificate(rootCert) + .withCheckName(CertificateChainValidator.CERTIFICATE_CHECK) + .withMessage(CertificateChainValidator.ISSUER_MISSING, + i -> rootCert.getSubjectX500Principal())) + .hasLogItem(al -> al + .withCheckName(RevocationDataValidator.REVOCATION_DATA_CHECK) + .withMessage(RevocationDataValidator.NO_REVOCATION_DATA)) + .hasLogItem(al -> al + .withCheckName(RevocationDataValidator.REVOCATION_DATA_CHECK) + .withMessage(RevocationDataValidator.SELF_SIGNED_CERTIFICATE)) ); } @@ -137,7 +229,7 @@ public void shortValidityCertsWithOcspTest() throws GeneralSecurityException, IO SignatureValidator signatureValidator = builder.buildSignatureValidator(document); report = signatureValidator.validateSignatures(); } -// ocsp validation date is wrong but why + AssertValidationReport.assertThat(report, a -> a .hasStatus(ValidationResult.VALID) .hasLogItem(al -> al @@ -149,11 +241,11 @@ public void shortValidityCertsWithOcspTest() throws GeneralSecurityException, IO .hasLogItem(al -> al .withCheckName(SignatureValidator.SIGNATURE_VERIFICATION) .withMessage(SignatureValidator.VALIDATING_SIGNATURE_NAME, i -> "Signature1")) - .hasLogItems(2, al -> al + .hasLogItem(al -> al .withCertificate(rootCert) .withCheckName(CertificateChainValidator.CERTIFICATE_CHECK) .withMessage(CertificateChainValidator.CERTIFICATE_TRUSTED, i -> rootCert.getSubjectX500Principal())) - .hasLogItems(4, al -> al + .hasLogItems(2, al -> al .withCertificate(tsRootCert) .withCheckName(CertificateChainValidator.CERTIFICATE_CHECK) .withMessage(CertificateChainValidator.CERTIFICATE_TRUSTED, i -> tsRootCert.getSubjectX500Principal())) @@ -227,14 +319,122 @@ public void validateMultipleDocumentsTest() throws GeneralSecurityException, IOE List crlClients = builder.getProperties().getCrlClients(); List ocspClients = builder.getProperties().getOcspClients(); - Assert.assertEquals(1, crlClients.size()); - Assert.assertEquals(1, ocspClients.size()); - Assert.assertTrue(crlClients.get(0) instanceof ValidationCrlClient); - Assert.assertTrue(ocspClients.get(0) instanceof ValidationOcspClient); + Assertions.assertEquals(1, crlClients.size()); + Assertions.assertEquals(1, ocspClients.size()); + Assertions.assertTrue(crlClients.get(0) instanceof ValidationCrlClient); + Assertions.assertTrue(ocspClients.get(0) instanceof ValidationOcspClient); ValidationCrlClient validationCrlClient = (ValidationCrlClient) crlClients.get(0); ValidationOcspClient validationOcspClient = (ValidationOcspClient) ocspClients.get(0); - Assert.assertEquals(2, validationCrlClient.getCrls().size()); - Assert.assertEquals(2, validationOcspClient.getResponses().size()); + Assertions.assertEquals(2, validationCrlClient.getCrls().size()); + Assertions.assertEquals(2, validationOcspClient.getResponses().size()); + } + + @Test + public void validateSingleSignatureTest1() throws Exception { + String rootCertName = CERTS_SRC + "root_cert.pem"; + X509Certificate rootCert = (X509Certificate) PemFileHelper.readFirstChain(rootCertName)[0]; + + ValidationReport report1; + ValidationReport report2; + try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "validateSingleSignature1.pdf"))) { + certificateRetriever.setTrustedCertificates(Collections.singletonList(rootCert)); + addRevDataClients(); + + SignatureValidator signatureValidator1 = builder.buildSignatureValidator(document); + report1 = signatureValidator1.validateSignature("Signature1"); + + SignatureValidator signatureValidator2 = builder.buildSignatureValidator(document); + report2 = signatureValidator2.validateSignature("Signature2"); + } + + // Signature1 set access permissions to level 3, Signature2 - to level 1, after that annotation was added. + AssertValidationReport.assertThat(report1, a -> a + .hasStatus(ValidationResult.VALID) + .hasNumberOfLogs(4).hasNumberOfFailures(0) + .hasLogItem(al -> al + .withCheckName(DocumentRevisionsValidator.DOC_MDP_CHECK) + .withMessage(DocumentRevisionsValidator.UNEXPECTED_ENTRY_IN_XREF, i -> 17) + .withStatus(ReportItem.ReportItemStatus.INFO)) + .hasLogItem(al -> al + .withCheckName(SignatureValidator.SIGNATURE_VERIFICATION) + .withMessage(SignatureValidator.VALIDATING_SIGNATURE_NAME, p -> "Signature1")) + .hasLogItem(al -> al + .withCertificate(rootCert) + .withCheckName(CertificateChainValidator.CERTIFICATE_CHECK) + .withMessage(CertificateChainValidator.CERTIFICATE_TRUSTED, + i -> rootCert.getSubjectX500Principal())) + .hasLogItem(al -> al + .withCheckName(OCSPValidator.OCSP_CHECK) + .withMessage(OCSPValidator.OCSP_RESPONDER_IS_CA)) + ); + + AssertValidationReport.assertThat(report2, a -> a + .hasStatus(ValidationResult.INVALID) + .hasNumberOfLogs(4).hasNumberOfFailures(1) + .hasLogItem(al -> al + .withCheckName(DocumentRevisionsValidator.DOC_MDP_CHECK) + .withMessage(DocumentRevisionsValidator.PAGE_ANNOTATIONS_MODIFIED) + .withStatus(ReportItem.ReportItemStatus.INVALID)) + .hasLogItem(al -> al + .withCheckName(SignatureValidator.SIGNATURE_VERIFICATION) + .withMessage(SignatureValidator.VALIDATING_SIGNATURE_NAME, p -> "Signature2")) + .hasLogItem(al -> al + .withCertificate(rootCert) + .withCheckName(CertificateChainValidator.CERTIFICATE_CHECK) + .withMessage(CertificateChainValidator.CERTIFICATE_TRUSTED, + i -> rootCert.getSubjectX500Principal())) + .hasLogItem(al -> al + .withCheckName(OCSPValidator.OCSP_CHECK) + .withMessage(OCSPValidator.OCSP_RESPONDER_IS_CA)) + ); + } + + @Test + public void validateSingleSignatureTest2() throws Exception { + String rootCertName = CERTS_SRC + "root_cert.pem"; + X509Certificate rootCert = (X509Certificate) PemFileHelper.readFirstChain(rootCertName)[0]; + + ValidationReport report1; + ValidationReport report2; + try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "validateSingleSignature2.pdf"))) { + certificateRetriever.setTrustedCertificates(Collections.singletonList(rootCert)); + addRevDataClients(); + + SignatureValidator signatureValidator1 = builder.buildSignatureValidator(document); + report1 = signatureValidator1.validateSignature("Signature1"); + + SignatureValidator signatureValidator2 = builder.buildSignatureValidator(document); + report2 = signatureValidator2.validateSignature("Signature2"); + } + + // Signature1 set access permissions to level 1, after that annotation was added and then Signature2 applied. + AssertValidationReport.assertThat(report1, a -> a + .hasStatus(ValidationResult.INVALID) + .hasNumberOfFailures(3) + .hasLogItem(al -> al + .withCheckName(DocumentRevisionsValidator.DOC_MDP_CHECK) + .withMessage(DocumentRevisionsValidator.PAGE_ANNOTATIONS_MODIFIED) + .withStatus(ReportItem.ReportItemStatus.INVALID)) + .hasLogItem(al -> al + .withCheckName(DocumentRevisionsValidator.DOC_MDP_CHECK) + .withMessage(DocumentRevisionsValidator.UNEXPECTED_FORM_FIELD, p -> "Signature2") + .withStatus(ReportItem.ReportItemStatus.INVALID)) + .hasLogItem(al -> al + .withCheckName(DocumentRevisionsValidator.DOC_MDP_CHECK) + .withMessage(DocumentRevisionsValidator.NOT_ALLOWED_ACROFORM_CHANGES) + .withStatus(ReportItem.ReportItemStatus.INVALID)) + .hasLogItem(al -> al + .withCheckName(SignatureValidator.SIGNATURE_VERIFICATION) + .withMessage(SignatureValidator.VALIDATING_SIGNATURE_NAME, p -> "Signature1")) + ); + + AssertValidationReport.assertThat(report2, a -> a + .hasStatus(ValidationResult.VALID) + .hasNumberOfFailures(0) + .hasLogItem(al -> al + .withCheckName(SignatureValidator.SIGNATURE_VERIFICATION) + .withMessage(SignatureValidator.VALIDATING_SIGNATURE_NAME, p -> "Signature2")) + ); } @Test @@ -337,20 +537,24 @@ public void latestSignatureIsTimestampTest() throws GeneralSecurityException, IO ocspBuilder.setThisUpdate(DateTimeUtil.getCalendar(DateTimeUtil.addDaysToDate(currentDate, 3))); ocspBuilder.setNextUpdate(DateTimeUtil.getCalendar(DateTimeUtil.addDaysToDate(currentDate, 30))); TestOcspClient ocspClient = new TestOcspClient().addBuilderForCertIssuer(rootCert, ocspBuilder); - builder.getRevocationDataValidator().addOcspClient(ocspClient); + + RevocationDataValidator revocationDataValidator = builder.buildRevocationDataValidator(); + revocationDataValidator.addOcspClient(ocspClient); + builder.withRevocationDataValidatorFactory(() -> revocationDataValidator); parameters.setRevocationOnlineFetching(ValidatorContexts.all(), CertificateSources.all(), TimeBasedContexts.all(), SignatureValidationProperties.OnlineFetching.NEVER_FETCH) .setFreshness(ValidatorContexts.all(), CertificateSources.all(), TimeBasedContexts.all(), Duration.ofDays(-2)); SignatureValidator signatureValidator = builder.buildSignatureValidator(document); + report = signatureValidator.validateLatestSignature(document); } AssertValidationReport.assertThat(report, a -> a .hasNumberOfFailures(0) .hasNumberOfLogs(3) - .hasLogItems(2, la -> la + .hasLogItem(la -> la .withCheckName(CertificateChainValidator.CERTIFICATE_CHECK) .withMessage(CertificateChainValidator.CERTIFICATE_TRUSTED, l -> rootCert.getSubjectX500Principal()) @@ -412,11 +616,17 @@ public void certificatesNotInLatestSignatureButSetAsKnownTest() throws GeneralSe } AssertValidationReport.assertThat(report, a -> a .hasStatus(ValidationResult.VALID) - .hasLogItems(3, al -> al + .hasLogItem(al -> al .withCheckName(CertificateChainValidator.CERTIFICATE_CHECK) .withMessage(CertificateChainValidator.CERTIFICATE_TRUSTED, i -> rootCert.getSubjectX500Principal()) .withCertificate(rootCert)) + .hasLogItem(al -> al + .withCheckName(OCSPValidator.OCSP_CHECK) + .withMessage(OCSPValidator.OCSP_RESPONDER_TRUSTED)) + .hasLogItem(al -> al + .withCheckName(OCSPValidator.OCSP_CHECK) + .withMessage(OCSPValidator.OCSP_RESPONDER_IS_CA)) ); } @@ -461,10 +671,12 @@ public void validateMultipleSignaturesUsingLastKnownPoETest() throws Exception { String trustedCertsFileName = CERTS_SRC + "trustedCerts.pem"; Certificate[] trustedCerts = PemFileHelper.readFirstChain(trustedCertsFileName); - try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "signatureSigningCertExpired.pdf"))) { + try (PdfDocument document = new PdfDocument( + new PdfReader(SOURCE_FOLDER + "signatureSigningCertExpired.pdf"))) { SignatureValidator signatureValidator = new ValidatorChainBuilder() .withTrustedCertificates(Arrays.asList(trustedCerts)) - .withRevocationDataValidator(new MockRevocationDataValidator()).buildSignatureValidator(document); + .withRevocationDataValidatorFactory(()-> + new MockRevocationDataValidator()).buildSignatureValidator(document); ValidationReport report = signatureValidator.validateSignatures(); AssertValidationReport.assertThat(report, r -> r @@ -487,11 +699,13 @@ public void validateMultipleSignaturesUsingLastKnownPoETest() throws Exception { @Test public void stopAfterTimestampChainValidationFailureTest() throws Exception { - try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "validDocWithTimestamp.pdf"))) { + try (PdfDocument document = new PdfDocument( + new PdfReader(SOURCE_FOLDER + "validDocWithTimestamp.pdf"))) { SignatureValidator signatureValidator = new ValidatorChainBuilder() .withSignatureValidationProperties(new SignatureValidationProperties() .setContinueAfterFailure(ValidatorContexts.all(), CertificateSources.all(), false)) - .withRevocationDataValidator(new MockRevocationDataValidator()).buildSignatureValidator(document); + .withRevocationDataValidatorFactory(()-> + new MockRevocationDataValidator()).buildSignatureValidator(document); ValidationReport report = signatureValidator.validateSignatures(); AssertValidationReport.assertThat(report, r -> r @@ -527,7 +741,9 @@ private void addRevDataClients() builder2.setNextUpdate(DateTimeUtil.getCalendar(DateTimeUtil.addDaysToDate(currentDate, 30))); TestOcspClient ocspClient = new TestOcspClient().addBuilderForCertIssuer(rootCert, builder1) .addBuilderForCertIssuer(intermediateCert, builder2); - builder.getRevocationDataValidator().addOcspClient(ocspClient); + RevocationDataValidator revocationDataValidator = builder.getRevocationDataValidator() + .addOcspClient(ocspClient); + builder.withRevocationDataValidatorFactory(() -> revocationDataValidator); parameters.setRevocationOnlineFetching(ValidatorContexts.all(), CertificateSources.all(), TimeBasedContexts.all(), SignatureValidationProperties.OnlineFetching.NEVER_FETCH); } diff --git a/sign/src/test/java/com/itextpdf/signatures/validation/v1/SignatureValidatorTest.java b/sign/src/test/java/com/itextpdf/signatures/validation/SignatureValidatorTest.java similarity index 79% rename from sign/src/test/java/com/itextpdf/signatures/validation/v1/SignatureValidatorTest.java rename to sign/src/test/java/com/itextpdf/signatures/validation/SignatureValidatorTest.java index 45b8069420..bcb8aa7cfe 100644 --- a/sign/src/test/java/com/itextpdf/signatures/validation/v1/SignatureValidatorTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/validation/SignatureValidatorTest.java @@ -20,7 +20,7 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.signatures.validation.v1; +package com.itextpdf.signatures.validation; import com.itextpdf.bouncycastleconnector.BouncyCastleFactoryCreator; import com.itextpdf.commons.bouncycastle.IBouncyCastleFactory; @@ -28,36 +28,37 @@ This file is part of the iText (R) project. import com.itextpdf.commons.bouncycastle.pkcs.AbstractPKCSException; import com.itextpdf.commons.utils.DateTimeUtil; import com.itextpdf.commons.utils.MessageFormatUtil; +import com.itextpdf.kernel.exceptions.PdfException; import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfReader; import com.itextpdf.signatures.testutils.PemFileHelper; import com.itextpdf.signatures.testutils.TimeTestUtil; import com.itextpdf.signatures.testutils.builder.TestOcspResponseBuilder; import com.itextpdf.signatures.testutils.client.TestOcspClient; -import com.itextpdf.signatures.validation.v1.context.CertificateSource; -import com.itextpdf.signatures.validation.v1.context.CertificateSources; -import com.itextpdf.signatures.validation.v1.context.TimeBasedContext; -import com.itextpdf.signatures.validation.v1.context.TimeBasedContexts; -import com.itextpdf.signatures.validation.v1.context.ValidatorContext; -import com.itextpdf.signatures.validation.v1.context.ValidatorContexts; -import com.itextpdf.signatures.validation.v1.mocks.MockChainValidator; -import com.itextpdf.signatures.validation.v1.mocks.MockChainValidator.ValidationCallBack; -import com.itextpdf.signatures.validation.v1.mocks.MockDocumentRevisionsValidator; -import com.itextpdf.signatures.validation.v1.mocks.MockIssuingCertificateRetriever; -import com.itextpdf.signatures.validation.v1.mocks.MockRevocationDataValidator; -import com.itextpdf.signatures.validation.v1.report.ReportItem; -import com.itextpdf.signatures.validation.v1.report.ReportItem.ReportItemStatus; -import com.itextpdf.signatures.validation.v1.report.ValidationReport; -import com.itextpdf.signatures.validation.v1.report.ValidationReport.ValidationResult; +import com.itextpdf.signatures.validation.context.CertificateSource; +import com.itextpdf.signatures.validation.context.CertificateSources; +import com.itextpdf.signatures.validation.context.TimeBasedContext; +import com.itextpdf.signatures.validation.context.TimeBasedContexts; +import com.itextpdf.signatures.validation.context.ValidatorContext; +import com.itextpdf.signatures.validation.context.ValidatorContexts; +import com.itextpdf.signatures.validation.mocks.MockChainValidator; +import com.itextpdf.signatures.validation.mocks.MockChainValidator.ValidationCallBack; +import com.itextpdf.signatures.validation.mocks.MockDocumentRevisionsValidator; +import com.itextpdf.signatures.validation.mocks.MockIssuingCertificateRetriever; +import com.itextpdf.signatures.validation.mocks.MockRevocationDataValidator; +import com.itextpdf.signatures.validation.report.ReportItem; +import com.itextpdf.signatures.validation.report.ReportItem.ReportItemStatus; +import com.itextpdf.signatures.validation.report.ValidationReport; +import com.itextpdf.signatures.validation.report.ValidationReport.ValidationResult; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.BouncyCastleUnitTest; import java.util.List; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; import java.security.GeneralSecurityException; @@ -70,10 +71,10 @@ This file is part of the iText (R) project. import java.util.Collections; import java.util.Date; -@Category(BouncyCastleUnitTest.class) +@Tag("BouncyCastleUnitTest") public class SignatureValidatorTest extends ExtendedITextTest { - private static final String CERTS_SRC = "./src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorTest/certs/"; - private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorTest/"; + private static final String CERTS_SRC = "./src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorTest/certs/"; + private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorTest/"; private static final IBouncyCastleFactory FACTORY = BouncyCastleFactoryCreator.getFactory(); private static final char[] PASSWORD = "testpassphrase".toCharArray(); @@ -84,23 +85,23 @@ public class SignatureValidatorTest extends ExtendedITextTest { private MockChainValidator mockCertificateChainValidator; private MockDocumentRevisionsValidator mockDocumentRevisionsValidator; - @BeforeClass + @BeforeAll public static void before() { Security.addProvider(FACTORY.getProvider()); } - @Before + @BeforeEach public void setUp() { mockCertificateChainValidator = new MockChainValidator(); parameters = new SignatureValidationProperties(); mockCertificateRetriever = new MockIssuingCertificateRetriever(); mockDocumentRevisionsValidator = new MockDocumentRevisionsValidator(); builder = new ValidatorChainBuilder() - .withIssuingCertificateRetriever(mockCertificateRetriever) + .withIssuingCertificateRetrieverFactory(() -> mockCertificateRetriever) .withSignatureValidationProperties(parameters) - .withCertificateChainValidator(mockCertificateChainValidator) - .withRevocationDataValidator(new MockRevocationDataValidator()) - .withDocumentRevisionsValidator(mockDocumentRevisionsValidator); + .withCertificateChainValidatorFactory(() -> mockCertificateChainValidator) + .withRevocationDataValidatorFactory(() -> new MockRevocationDataValidator()) + .withDocumentRevisionsValidatorFactory(() -> mockDocumentRevisionsValidator); } @Test @@ -139,11 +140,11 @@ public void latestSignatureIsTimestampTest() throws GeneralSecurityException, IO .hasStatus(ValidationResult.VALID) .hasNumberOfLogs(1).hasNumberOfFailures(0)); - Assert.assertEquals(1, mockCertificateChainValidator.verificationCalls.size()); + Assertions.assertEquals(1, mockCertificateChainValidator.verificationCalls.size()); MockChainValidator.ValidationCallBack call = mockCertificateChainValidator.verificationCalls.get(0); - Assert.assertEquals(CertificateSource.TIMESTAMP, call.context.getCertificateSource()); - Assert.assertEquals(ValidatorContext.SIGNATURE_VALIDATOR, call.context.getValidatorContext()); - Assert.assertEquals(timeStampCert.getSubjectX500Principal(), call.certificate.getSubjectX500Principal()); + Assertions.assertEquals(CertificateSource.TIMESTAMP, call.context.getCertificateSource()); + Assertions.assertEquals(ValidatorContext.SIGNATURE_VALIDATOR, call.context.getValidatorContext()); + Assertions.assertEquals(timeStampCert.getSubjectX500Principal(), call.certificate.getSubjectX500Principal()); } @Test @@ -184,7 +185,7 @@ public void latestSignatureIsDocTimestampWithModifiedDateTest() throws GeneralSe .hasLogItem(al -> al .withCheckName(SignatureValidator.SIGNATURE_VERIFICATION) .withMessage(MessageFormatUtil.format(SignatureValidator.CANNOT_VERIFY_SIGNATURE, - "timestampSignature1")) + "timestampSignature1")) .withStatus(ReportItem.ReportItemStatus.INVALID)) ); } @@ -213,7 +214,7 @@ public void latestSignatureWithModifiedTimestampDateTest() throws GeneralSecurit TimeBasedContexts.all(), SignatureValidationProperties.OnlineFetching.NEVER_FETCH) .setFreshness(ValidatorContexts.all(), CertificateSources.all(), TimeBasedContexts.all(), Duration.ofDays(-2)) - .setContinueAfterFailure(ValidatorContexts.all() , CertificateSources.all(), false); + .setContinueAfterFailure(ValidatorContexts.all(), CertificateSources.all(), false); SignatureValidator signatureValidator = builder.buildSignatureValidator(document); report = signatureValidator.validateLatestSignature(document); @@ -308,7 +309,7 @@ public void latestSignatureInvalidStopValidationTest() throws GeneralSecurityExc .withStatus(ReportItem.ReportItemStatus.INVALID)) ); // check that no requests are made after failure - Assert.assertEquals(0, mockCertificateChainValidator.verificationCalls.size()); + Assertions.assertEquals(0, mockCertificateChainValidator.verificationCalls.size()); } @Test @@ -327,12 +328,12 @@ public void certificatesNotInLatestSignatureButTakenFromDSSTest() throws General signatureValidator.validateLatestSignature(document); } - Assert.assertEquals(2, mockCertificateRetriever.addKnownCertificatesCalls.size()); + Assertions.assertEquals(2, mockCertificateRetriever.addKnownCertificatesCalls.size()); Collection dssCall = mockCertificateRetriever.addKnownCertificatesCalls.get(0); - Assert.assertEquals(3, dssCall.size()); - Assert.assertEquals(1, dssCall.stream().filter(c -> ((X509Certificate) c).equals(rootCert)).count()); - Assert.assertEquals(1, dssCall.stream().filter(c -> ((X509Certificate) c).equals(intermediateCert)).count()); - Assert.assertEquals(1, dssCall.stream().filter(c -> ((X509Certificate) c).equals(signCert)).count()); + Assertions.assertEquals(3, dssCall.size()); + Assertions.assertEquals(1, dssCall.stream().filter(c -> ((X509Certificate) c).equals(rootCert)).count()); + Assertions.assertEquals(1, dssCall.stream().filter(c -> ((X509Certificate) c).equals(intermediateCert)).count()); + Assertions.assertEquals(1, dssCall.stream().filter(c -> ((X509Certificate) c).equals(signCert)).count()); } @@ -455,24 +456,24 @@ public void validateMultipleSignatures() throws IOException { // 2 signatures with timestamp // 3 document timestamps List verificationCalls = mockCertificateChainValidator.verificationCalls; - Assert.assertEquals(7, verificationCalls.size()); - Assert.assertEquals(TimeBasedContext.PRESENT, verificationCalls.get(0).context.getTimeBasedContext()); + Assertions.assertEquals(7, verificationCalls.size()); + Assertions.assertEquals(TimeBasedContext.PRESENT, verificationCalls.get(0).context.getTimeBasedContext()); for (int i = 1; i < verificationCalls.size(); ++i) { - Assert.assertEquals(TimeBasedContext.HISTORICAL, verificationCalls.get(i).context.getTimeBasedContext()); + Assertions.assertEquals(TimeBasedContext.HISTORICAL, verificationCalls.get(i).context.getTimeBasedContext()); } - Assert.assertTrue(verificationCalls.stream().anyMatch(c -> + Assertions.assertTrue(verificationCalls.stream().anyMatch(c -> c.certificate.getSerialNumber().toString().equals("1491571297") - && c.checkDate.equals(date3))); - Assert.assertTrue(verificationCalls.stream().anyMatch(c -> + && c.checkDate.equals(date3))); + Assertions.assertTrue(verificationCalls.stream().anyMatch(c -> c.certificate.getSerialNumber().toString().equals("1491571297") && c.checkDate.equals(date2))); - Assert.assertTrue(verificationCalls.stream().anyMatch(c -> + Assertions.assertTrue(verificationCalls.stream().anyMatch(c -> c.certificate.getSerialNumber().toString().equals("1491571297") && c.checkDate.equals(date1))); - Assert.assertTrue(verificationCalls.stream().anyMatch(c -> + Assertions.assertTrue(verificationCalls.stream().anyMatch(c -> c.certificate.getSerialNumber().toString().equals("1550593058") && c.checkDate.equals(date2))); - Assert.assertTrue(verificationCalls.stream().anyMatch(c -> + Assertions.assertTrue(verificationCalls.stream().anyMatch(c -> c.certificate.getSerialNumber().toString().equals("1701704311986") && c.checkDate.equals(date1))); } @@ -486,32 +487,34 @@ public void signatureChainValidatorFailureTest() throws GeneralSecurityException try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "validDoc.pdf"))) { mockCertificateRetriever.setTrustedCertificates(Collections.singletonList(rootCert)); - mockCertificateChainValidator.onCallDo(c-> {throw new RuntimeException("Test chain validation failure");}); + mockCertificateChainValidator.onCallDo(c -> { + throw new RuntimeException("Test chain validation failure"); + }); SignatureValidator signatureValidator = builder.buildSignatureValidator(document); ValidationReport report = signatureValidator.validateLatestSignature(document); - AssertValidationReport.assertThat(report, r-> - r.hasLogItem(l-> l + AssertValidationReport.assertThat(report, r -> + r.hasLogItem(l -> l .withMessage(SignatureValidator.CHAIN_VALIDATION_FAILED))); } } + @Test public void timeStampChainValidatorFailureTest() throws GeneralSecurityException, IOException { String chainName = CERTS_SRC + "validCertsChain.pem"; Certificate[] certificateChain = PemFileHelper.readFirstChain(chainName); X509Certificate rootCert = (X509Certificate) certificateChain[2]; - X509Certificate intermediateCert = (X509Certificate) certificateChain[1]; - X509Certificate signCert = (X509Certificate) certificateChain[0]; try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "timestampSignatureDoc.pdf"))) { mockCertificateRetriever.setTrustedCertificates(Collections.singletonList(rootCert)); - mockCertificateChainValidator.onCallDo(c-> {throw new RuntimeException("Test chain validation failure");}); + mockCertificateChainValidator.onCallDo(c -> { + throw new RuntimeException("Test chain validation failure"); + }); SignatureValidator signatureValidator = builder.buildSignatureValidator(document); ValidationReport report = signatureValidator.validateLatestSignature(document); - AssertValidationReport.assertThat(report, r-> - r.hasLogItem(l-> l - .withMessage(SignatureValidator.CHAIN_VALIDATION_FAILED))); + AssertValidationReport.assertThat(report, r -> r.hasLogItem(l -> l + .withMessage(SignatureValidator.CHAIN_VALIDATION_FAILED))); } } @@ -524,16 +527,18 @@ public void certificateRetrieverAddKnownCertificatesFromDSSFailureTest() throws try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "docWithDss.pdf"))) { mockCertificateRetriever.setTrustedCertificates(Collections.singletonList(rootCert)); - mockCertificateRetriever.onAddKnownCertificatesDo( c -> { + mockCertificateRetriever.onAddKnownCertificatesDo(c -> { throw new RuntimeException("Test add know certificates failure"); }); SignatureValidator signatureValidator = builder.buildSignatureValidator(document); ValidationReport report = signatureValidator.validateLatestSignature(document); - AssertValidationReport.assertThat(report, r-> r - .hasLogItems(1,Integer.MAX_VALUE,l -> l.withMessage(SignatureValidator.ADD_KNOWN_CERTIFICATES_FAILED))); + AssertValidationReport.assertThat(report, r -> r + .hasLogItems(1, Integer.MAX_VALUE, l -> + l.withMessage(SignatureValidator.ADD_KNOWN_CERTIFICATES_FAILED))); } } + @Test public void certificateRetrieverAddKnownCertificatesFromSignatureFailureTest() throws GeneralSecurityException, IOException { String chainName = CERTS_SRC + "validCertsChain.pem"; @@ -542,16 +547,18 @@ public void certificateRetrieverAddKnownCertificatesFromSignatureFailureTest() t try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "validDoc.pdf"))) { mockCertificateRetriever.setTrustedCertificates(Collections.singletonList(rootCert)); - mockCertificateRetriever.onAddKnownCertificatesDo( c -> { + mockCertificateRetriever.onAddKnownCertificatesDo(c -> { throw new RuntimeException("Test add know certificates failure"); }); SignatureValidator signatureValidator = builder.buildSignatureValidator(document); ValidationReport report = signatureValidator.validateLatestSignature(document); - AssertValidationReport.assertThat(report, r-> r - .hasLogItems(1,Integer.MAX_VALUE, l -> l.withMessage(SignatureValidator.ADD_KNOWN_CERTIFICATES_FAILED))); + AssertValidationReport.assertThat(report, r -> r + .hasLogItems(1, Integer.MAX_VALUE, l -> + l.withMessage(SignatureValidator.ADD_KNOWN_CERTIFICATES_FAILED))); } } + @Test public void certificateRetrieverAddKnownCertificatesFromTimestampFailureTest() throws GeneralSecurityException, IOException { String chainName = CERTS_SRC + "validCertsChain.pem"; @@ -560,14 +567,15 @@ public void certificateRetrieverAddKnownCertificatesFromTimestampFailureTest() t try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "timestampSignatureDoc.pdf"))) { mockCertificateRetriever.setTrustedCertificates(Collections.singletonList(rootCert)); - mockCertificateRetriever.onAddKnownCertificatesDo( c -> { + mockCertificateRetriever.onAddKnownCertificatesDo(c -> { throw new RuntimeException("Test add know certificates failure"); }); SignatureValidator signatureValidator = builder.buildSignatureValidator(document); ValidationReport report = signatureValidator.validateLatestSignature(document); - AssertValidationReport.assertThat(report, r-> r - .hasLogItems(1,Integer.MAX_VALUE, l -> l.withMessage(SignatureValidator.ADD_KNOWN_CERTIFICATES_FAILED))); + AssertValidationReport.assertThat(report, r -> r + .hasLogItems(1, Integer.MAX_VALUE, l -> + l.withMessage(SignatureValidator.ADD_KNOWN_CERTIFICATES_FAILED))); } } @@ -579,15 +587,45 @@ public void documentRevisionValidatorFailureTest() throws GeneralSecurityExcepti try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "validDoc.pdf"))) { mockCertificateRetriever.setTrustedCertificates(Collections.singletonList(rootCert)); - mockDocumentRevisionsValidator.onCallDo( c -> { + mockDocumentRevisionsValidator.onCallDo(c -> { throw new RuntimeException("Test add know certificates failure"); }); SignatureValidator signatureValidator = builder.buildSignatureValidator(document); ValidationReport report = signatureValidator.validateSignatures(); - AssertValidationReport.assertThat(report, r-> r + AssertValidationReport.assertThat(report, r -> r .hasLogItem(l -> l.withMessage(SignatureValidator.REVISIONS_VALIDATION_FAILED))); } } + + @Test + public void throwExceptionOnTheSecondValidationAttempt() throws IOException { + try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "timestampSignatureDoc.pdf"))) { + SignatureValidator signatureValidator = builder.buildSignatureValidator(document); + signatureValidator.validateSignatures(); + Exception exception = Assertions.assertThrows(PdfException.class, + () -> signatureValidator.validateSignatures()); + Assertions.assertEquals(SignatureValidator.VALIDATION_PERFORMED, exception.getMessage()); + exception = Assertions.assertThrows(PdfException.class, + () -> signatureValidator.validateSignature("Signature1")); + Assertions.assertEquals(SignatureValidator.VALIDATION_PERFORMED, exception.getMessage()); + } + } + + @Test + public void signatureWithSpecifiedNameNotFound() throws IOException { + ValidationReport report; + try (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "timestampSignatureDoc.pdf"))) { + SignatureValidator signatureValidator = builder.buildSignatureValidator(document); + report = signatureValidator.validateSignature("Invalid signature name"); + } + AssertValidationReport.assertThat(report, a -> a + .hasStatus(ValidationResult.INDETERMINATE) + .hasNumberOfLogs(1).hasNumberOfFailures(1) + .hasLogItem(l -> l + .withCheckName(SignatureValidator.SIGNATURE_VERIFICATION) + .withMessage(SignatureValidator.SIGNATURE_NOT_FOUND, p -> "Invalid signature name") + .withStatus(ReportItemStatus.INDETERMINATE))); + } } diff --git a/sign/src/test/java/com/itextpdf/signatures/validation/v1/ValidationMetaInfoEventsTest.java b/sign/src/test/java/com/itextpdf/signatures/validation/ValidationMetaInfoEventsTest.java similarity index 78% rename from sign/src/test/java/com/itextpdf/signatures/validation/v1/ValidationMetaInfoEventsTest.java rename to sign/src/test/java/com/itextpdf/signatures/validation/ValidationMetaInfoEventsTest.java index 56faf8f44b..88b286548b 100644 --- a/sign/src/test/java/com/itextpdf/signatures/validation/v1/ValidationMetaInfoEventsTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/validation/ValidationMetaInfoEventsTest.java @@ -20,7 +20,7 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.signatures.validation.v1; +package com.itextpdf.signatures.validation; import com.itextpdf.bouncycastleconnector.BouncyCastleFactoryCreator; import com.itextpdf.commons.actions.AbstractContextBasedEventHandler; @@ -33,45 +33,44 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.DocumentProperties; import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfReader; -import com.itextpdf.signatures.validation.v1.context.CertificateSource; -import com.itextpdf.signatures.validation.v1.context.TimeBasedContext; -import com.itextpdf.signatures.validation.v1.context.ValidationContext; -import com.itextpdf.signatures.validation.v1.context.ValidatorContext; +import com.itextpdf.signatures.validation.context.CertificateSource; +import com.itextpdf.signatures.validation.context.TimeBasedContext; +import com.itextpdf.signatures.validation.context.ValidationContext; +import com.itextpdf.signatures.validation.context.ValidatorContext; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; import java.security.Security; import java.util.ArrayList; import java.util.List; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -@Category(IntegrationTest.class) +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; + +@Tag("IntegrationTest") public class ValidationMetaInfoEventsTest extends ExtendedITextTest { - private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/signatures/validation/v1/ValidationMetaInfoEventsTest/"; + private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/signatures/validation/ValidationMetaInfoEventsTest/"; private static StoreEventsHandler handler; private final ValidatorChainBuilder builder = new ValidatorChainBuilder(); private final ValidationContext validationContext = new ValidationContext( ValidatorContext.DOCUMENT_REVISIONS_VALIDATOR, CertificateSource.SIGNER_CERT, TimeBasedContext.PRESENT); - @BeforeClass + @BeforeAll public static void before() { Security.addProvider(BouncyCastleFactoryCreator.getFactory().getProvider()); } - @Before + @BeforeEach public void setUpHandler() { handler = new StoreEventsHandler(UnknownContext.PERMISSIVE); EventManager.getInstance().register(handler); } - @After + @AfterEach public void resetHandler() { EventManager.getInstance().unregister(handler); } @@ -84,14 +83,14 @@ public void documentRevisionsValidatorSingleEventTest() throws Exception { } List events = handler.getEvents(); - Assert.assertEquals(2, events.size()); - Assert.assertTrue(events.get(0) instanceof ITextCoreProductEvent); + Assertions.assertEquals(2, events.size()); + Assertions.assertTrue(events.get(0) instanceof ITextCoreProductEvent); ITextCoreProductEvent iTextCoreProductEvent = (ITextCoreProductEvent) events.get(0); - Assert.assertEquals(ITextCoreProductEvent.PROCESS_PDF, iTextCoreProductEvent.getEventType()); + Assertions.assertEquals(ITextCoreProductEvent.PROCESS_PDF, iTextCoreProductEvent.getEventType()); // Only first iTextCoreProductEvent is confirmed. - Assert.assertTrue(events.get(1) instanceof ConfirmEvent); + Assertions.assertTrue(events.get(1) instanceof ConfirmEvent); ConfirmEvent confirmEvent = (ConfirmEvent) events.get(1); - Assert.assertEquals(iTextCoreProductEvent, confirmEvent.getConfirmedEvent()); + Assertions.assertEquals(iTextCoreProductEvent, confirmEvent.getConfirmedEvent()); } @Test @@ -104,7 +103,7 @@ public void documentRevisionsValidatorZeroEventsTest() throws Exception { } List events = handler.getEvents(); - Assert.assertEquals(0, events.size()); + Assertions.assertEquals(0, events.size()); } @Test @@ -115,14 +114,14 @@ public void signatureValidatorSingleEventTest() throws IOException { } List events = handler.getEvents(); - Assert.assertEquals(2, events.size()); - Assert.assertTrue(events.get(0) instanceof ITextCoreProductEvent); + Assertions.assertEquals(2, events.size()); + Assertions.assertTrue(events.get(0) instanceof ITextCoreProductEvent); ITextCoreProductEvent iTextCoreProductEvent = (ITextCoreProductEvent) events.get(0); - Assert.assertEquals(ITextCoreProductEvent.PROCESS_PDF, iTextCoreProductEvent.getEventType()); + Assertions.assertEquals(ITextCoreProductEvent.PROCESS_PDF, iTextCoreProductEvent.getEventType()); // Only first iTextCoreProductEvent is confirmed. - Assert.assertTrue(events.get(1) instanceof ConfirmEvent); + Assertions.assertTrue(events.get(1) instanceof ConfirmEvent); ConfirmEvent confirmEvent = (ConfirmEvent) events.get(1); - Assert.assertEquals(iTextCoreProductEvent, confirmEvent.getConfirmedEvent()); + Assertions.assertEquals(iTextCoreProductEvent, confirmEvent.getConfirmedEvent()); } @Test @@ -135,7 +134,7 @@ public void signatureValidatorZeroEventsTest() throws IOException { } List events = handler.getEvents(); - Assert.assertEquals(0, events.size()); + Assertions.assertEquals(0, events.size()); } private static class StoreEventsHandler extends AbstractContextBasedEventHandler { diff --git a/sign/src/test/java/com/itextpdf/signatures/validation/v1/context/ValidationContextTest.java b/sign/src/test/java/com/itextpdf/signatures/validation/context/ValidationContextTest.java similarity index 76% rename from sign/src/test/java/com/itextpdf/signatures/validation/v1/context/ValidationContextTest.java rename to sign/src/test/java/com/itextpdf/signatures/validation/context/ValidationContextTest.java index b75705f33e..f6f08430eb 100644 --- a/sign/src/test/java/com/itextpdf/signatures/validation/v1/context/ValidationContextTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/validation/context/ValidationContextTest.java @@ -20,24 +20,23 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.signatures.validation.v1.context; +package com.itextpdf.signatures.validation.context; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class ValidationContextTest extends ExtendedITextTest { @Test public void testInitializingConstructor() { ValidationContext sut = new ValidationContext(ValidatorContext.CRL_VALIDATOR, CertificateSource.CERT_ISSUER, TimeBasedContext.HISTORICAL); - Assert.assertEquals(ValidatorContext.CRL_VALIDATOR, sut.getValidatorContext()); - Assert.assertEquals(CertificateSource.CERT_ISSUER, sut.getCertificateSource()); - Assert.assertEquals(TimeBasedContext.HISTORICAL, sut.getTimeBasedContext()); + Assertions.assertEquals(ValidatorContext.CRL_VALIDATOR, sut.getValidatorContext()); + Assertions.assertEquals(CertificateSource.CERT_ISSUER, sut.getCertificateSource()); + Assertions.assertEquals(TimeBasedContext.HISTORICAL, sut.getTimeBasedContext()); } @Test @@ -45,7 +44,7 @@ public void testSetAndGetCertificateSource() { ValidationContext sut = new ValidationContext(ValidatorContext.CRL_VALIDATOR, CertificateSource.CERT_ISSUER, TimeBasedContext.HISTORICAL); sut = sut.setCertificateSource(CertificateSource.CRL_ISSUER); - Assert.assertEquals(CertificateSource.CRL_ISSUER, sut.getCertificateSource()); + Assertions.assertEquals(CertificateSource.CRL_ISSUER, sut.getCertificateSource()); } @Test @@ -53,7 +52,7 @@ public void testSetAndGetTemporalContext() { ValidationContext sut = new ValidationContext(ValidatorContext.CRL_VALIDATOR, CertificateSource.CERT_ISSUER, TimeBasedContext.HISTORICAL); sut = sut.setTimeBasedContext(TimeBasedContext.PRESENT); - Assert.assertEquals(TimeBasedContext.PRESENT, sut.getTimeBasedContext()); + Assertions.assertEquals(TimeBasedContext.PRESENT, sut.getTimeBasedContext()); } @Test @@ -61,7 +60,7 @@ public void testSetAndGetValidator() { ValidationContext sut = new ValidationContext(ValidatorContext.CRL_VALIDATOR, CertificateSource.CERT_ISSUER, TimeBasedContext.HISTORICAL); sut = sut.setValidatorContext(ValidatorContext.SIGNATURE_VALIDATOR); - Assert.assertEquals(ValidatorContext.SIGNATURE_VALIDATOR, sut.getValidatorContext()); + Assertions.assertEquals(ValidatorContext.SIGNATURE_VALIDATOR, sut.getValidatorContext()); } @Test @@ -70,8 +69,8 @@ public void testEquals() { TimeBasedContext.HISTORICAL); ValidationContext sutB = new ValidationContext(ValidatorContext.CRL_VALIDATOR, CertificateSource.CERT_ISSUER, TimeBasedContext.HISTORICAL); - Assert.assertEquals(sutA, sutB); - Assert.assertEquals(sutB, sutA); + Assertions.assertEquals(sutA, sutB); + Assertions.assertEquals(sutB, sutA); } @Test @@ -84,10 +83,10 @@ public void testNotEquals() { TimeBasedContext.HISTORICAL); ValidationContext sutD = new ValidationContext(ValidatorContext.CRL_VALIDATOR, CertificateSource.CERT_ISSUER, TimeBasedContext.PRESENT); - Assert.assertNotEquals(sutA, sutB); - Assert.assertNotEquals(sutB, sutA); - Assert.assertNotEquals(sutC, sutA); - Assert.assertNotEquals(sutD, sutA); + Assertions.assertNotEquals(sutA, sutB); + Assertions.assertNotEquals(sutB, sutA); + Assertions.assertNotEquals(sutC, sutA); + Assertions.assertNotEquals(sutD, sutA); } @Test @@ -103,10 +102,10 @@ public void testHashCode() { ValidationContext sutD = new ValidationContext(ValidatorContext.CRL_VALIDATOR, CertificateSource.CERT_ISSUER, TimeBasedContext.PRESENT); - Assert.assertEquals(sutA.hashCode(), sut0.hashCode()); - Assert.assertNotEquals(sutA.hashCode(), sutB.hashCode()); - Assert.assertNotEquals(sutA.hashCode(), sutC.hashCode()); - Assert.assertNotEquals(sutA.hashCode(), sutD.hashCode()); + Assertions.assertEquals(sutA.hashCode(), sut0.hashCode()); + Assertions.assertNotEquals(sutA.hashCode(), sutB.hashCode()); + Assertions.assertNotEquals(sutA.hashCode(), sutC.hashCode()); + Assertions.assertNotEquals(sutA.hashCode(), sutD.hashCode()); } @Test @@ -130,9 +129,9 @@ public void hashCodeTest() { ValidationContext vc5 = new ValidationContext(ValidatorContext.OCSP_VALIDATOR, CertificateSource.OCSP_ISSUER, TimeBasedContext.PRESENT); - Assert.assertEquals(vc1.hashCode(), vc2.hashCode()); - Assert.assertNotEquals(vc1.hashCode(), vc3.hashCode()); - Assert.assertNotEquals(vc1.hashCode(), vc4.hashCode()); - Assert.assertNotEquals(vc1.hashCode(), vc5.hashCode()); + Assertions.assertEquals(vc1.hashCode(), vc2.hashCode()); + Assertions.assertNotEquals(vc1.hashCode(), vc3.hashCode()); + Assertions.assertNotEquals(vc1.hashCode(), vc4.hashCode()); + Assertions.assertNotEquals(vc1.hashCode(), vc5.hashCode()); } } \ No newline at end of file diff --git a/sign/src/test/java/com/itextpdf/signatures/validation/v1/extensions/CertificateExtensionTest.java b/sign/src/test/java/com/itextpdf/signatures/validation/extensions/CertificateExtensionTest.java similarity index 82% rename from sign/src/test/java/com/itextpdf/signatures/validation/v1/extensions/CertificateExtensionTest.java rename to sign/src/test/java/com/itextpdf/signatures/validation/extensions/CertificateExtensionTest.java index a158eaa812..9aecf2593f 100644 --- a/sign/src/test/java/com/itextpdf/signatures/validation/v1/extensions/CertificateExtensionTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/validation/extensions/CertificateExtensionTest.java @@ -20,26 +20,25 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.signatures.validation.v1.extensions; +package com.itextpdf.signatures.validation.extensions; import com.itextpdf.bouncycastleconnector.BouncyCastleFactoryCreator; import com.itextpdf.commons.bouncycastle.IBouncyCastleFactory; -import com.itextpdf.signatures.OID; -import com.itextpdf.signatures.OID.X509Extensions; +import com.itextpdf.kernel.crypto.OID; +import com.itextpdf.kernel.crypto.OID.X509Extensions; import com.itextpdf.signatures.testutils.PemFileHelper; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.BouncyCastleUnitTest; import java.io.IOException; import java.security.cert.CertificateException; import java.security.cert.X509Certificate; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(BouncyCastleUnitTest.class) +@Tag("BouncyCastleUnitTest") public class CertificateExtensionTest extends ExtendedITextTest { - private static final String certsSrc = "./src/test/resources/com/itextpdf/signatures/validation/v1/extensions/CertificateExtensionTest/"; + private static final String certsSrc = "./src/test/resources/com/itextpdf/signatures/validation/extensions/CertificateExtensionTest/"; private static final IBouncyCastleFactory FACTORY = BouncyCastleFactoryCreator.getFactory(); @@ -51,7 +50,7 @@ public void keyUsageNotSetExpectedTest() throws CertificateException, IOExceptio CertificateExtension extension = new CertificateExtension( OID.X509Extensions.KEY_USAGE, null); - Assert.assertTrue(extension.existsInCertificate(certificate)); + Assertions.assertTrue(extension.existsInCertificate(certificate)); } @Test @@ -62,7 +61,7 @@ public void keyUsageNotSetNotExpectedTest() throws CertificateException, IOExcep CertificateExtension extension = new CertificateExtension( OID.X509Extensions.KEY_USAGE, FACTORY.createKeyUsage(98).toASN1Primitive()); - Assert.assertFalse(extension.existsInCertificate(certificate)); + Assertions.assertFalse(extension.existsInCertificate(certificate)); } @Test @@ -73,7 +72,7 @@ public void keyUsageWrongOIDTest() throws CertificateException, IOException { CertificateExtension extension = new CertificateExtension( X509Extensions.BASIC_CONSTRAINTS, FACTORY.createKeyUsage(98).toASN1Primitive()); - Assert.assertFalse(extension.existsInCertificate(certificate)); + Assertions.assertFalse(extension.existsInCertificate(certificate)); } @Test @@ -84,7 +83,7 @@ public void keyUsageExpectedValueTest() throws CertificateException, IOException CertificateExtension extension = new CertificateExtension( OID.X509Extensions.KEY_USAGE, FACTORY.createKeyUsage(98).toASN1Primitive()); - Assert.assertTrue(extension.existsInCertificate(certificate)); + Assertions.assertTrue(extension.existsInCertificate(certificate)); } @Test @@ -96,7 +95,7 @@ public void keyUsagePartiallyExpectedTest() throws CertificateException, IOExcep OID.X509Extensions.KEY_USAGE, FACTORY.createKeyUsage(66).toASN1Primitive()); // CertificateExtension#existsInCertificate only returns true in case of complete match, therefore false. - Assert.assertFalse(extension.existsInCertificate(certificate)); + Assertions.assertFalse(extension.existsInCertificate(certificate)); } @Test @@ -107,7 +106,7 @@ public void keyUsagePartiallyNotExpectedTest() throws CertificateException, IOEx CertificateExtension extension = new CertificateExtension( OID.X509Extensions.KEY_USAGE, FACTORY.createKeyUsage(32802).toASN1Primitive()); - Assert.assertFalse(extension.existsInCertificate(certificate)); + Assertions.assertFalse(extension.existsInCertificate(certificate)); } @Test @@ -118,7 +117,7 @@ public void equalsTest() { CertificateExtension extension2 = new CertificateExtension( OID.X509Extensions.KEY_USAGE, FACTORY.createKeyUsage(32802).toASN1Primitive()); - Assert.assertEquals(extension1, extension2); + Assertions.assertEquals(extension1, extension2); } @Test @@ -126,7 +125,7 @@ public void equalsOtherTypeTest() { CertificateExtension extension1 = new CertificateExtension( OID.X509Extensions.KEY_USAGE, FACTORY.createKeyUsage(32802).toASN1Primitive()); - Assert.assertNotEquals("extension1", extension1); + Assertions.assertNotEquals("extension1", extension1); } @Test @@ -137,7 +136,7 @@ public void equalsOtherExtensionTest() { CertificateExtension extension2 = new CertificateExtension( X509Extensions.EXTENDED_KEY_USAGE, FACTORY.createKeyUsage(32802).toASN1Primitive()); - Assert.assertNotEquals(extension1, extension2); + Assertions.assertNotEquals(extension1, extension2); } @Test @@ -148,7 +147,7 @@ public void equalsOtherValueTest() { CertificateExtension extension2 = new CertificateExtension( OID.X509Extensions.KEY_USAGE, FACTORY.createKeyUsage(32800).toASN1Primitive()); - Assert.assertNotEquals(extension1, extension2); + Assertions.assertNotEquals(extension1, extension2); } @Test @@ -159,7 +158,7 @@ public void sameHashCode() { CertificateExtension extension2 = new CertificateExtension( OID.X509Extensions.KEY_USAGE, FACTORY.createKeyUsage(32802).toASN1Primitive()); - Assert.assertEquals(extension1.hashCode(), extension2.hashCode()); + Assertions.assertEquals(extension1.hashCode(), extension2.hashCode()); } @Test @@ -170,7 +169,7 @@ public void hashOtherValueTest() { CertificateExtension extension2 = new CertificateExtension( OID.X509Extensions.KEY_USAGE, FACTORY.createKeyUsage(32800).toASN1Primitive()); - Assert.assertNotEquals(extension1.hashCode(), extension2.hashCode()); + Assertions.assertNotEquals(extension1.hashCode(), extension2.hashCode()); } @Test @@ -181,7 +180,7 @@ public void hashOtherExtensionTest() { CertificateExtension extension2 = new CertificateExtension( X509Extensions.EXTENDED_KEY_USAGE, FACTORY.createKeyUsage(32802).toASN1Primitive()); - Assert.assertNotEquals(extension1.hashCode(), extension2.hashCode()); + Assertions.assertNotEquals(extension1.hashCode(), extension2.hashCode()); } @@ -189,14 +188,14 @@ public void hashOtherExtensionTest() { public void getExtensionValueTest() { CertificateExtension extension = new CertificateExtension( OID.X509Extensions.KEY_USAGE, FACTORY.createKeyUsage(32802).toASN1Primitive()); - Assert.assertEquals(FACTORY.createKeyUsage(32802).toASN1Primitive(), extension.getExtensionValue()); + Assertions.assertEquals(FACTORY.createKeyUsage(32802).toASN1Primitive(), extension.getExtensionValue()); } @Test public void getExtensionOidTest() { CertificateExtension extension = new CertificateExtension( OID.X509Extensions.KEY_USAGE, FACTORY.createKeyUsage(32802).toASN1Primitive()); - Assert.assertEquals(OID.X509Extensions.KEY_USAGE, extension.getExtensionOid()); + Assertions.assertEquals(OID.X509Extensions.KEY_USAGE, extension.getExtensionOid()); } } diff --git a/sign/src/test/java/com/itextpdf/signatures/validation/v1/extensions/ExtendedKeyUsageExtensionTest.java b/sign/src/test/java/com/itextpdf/signatures/validation/extensions/ExtendedKeyUsageExtensionTest.java similarity index 85% rename from sign/src/test/java/com/itextpdf/signatures/validation/v1/extensions/ExtendedKeyUsageExtensionTest.java rename to sign/src/test/java/com/itextpdf/signatures/validation/extensions/ExtendedKeyUsageExtensionTest.java index dc5913ec95..c2dbb5a7da 100644 --- a/sign/src/test/java/com/itextpdf/signatures/validation/v1/extensions/ExtendedKeyUsageExtensionTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/validation/extensions/ExtendedKeyUsageExtensionTest.java @@ -20,24 +20,23 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.signatures.validation.v1.extensions; +package com.itextpdf.signatures.validation.extensions; import com.itextpdf.signatures.testutils.PemFileHelper; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.BouncyCastleUnitTest; import java.io.IOException; import java.security.cert.CertificateException; import java.security.cert.X509Certificate; import java.util.Arrays; import java.util.Collections; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(BouncyCastleUnitTest.class) +@Tag("BouncyCastleUnitTest") public class ExtendedKeyUsageExtensionTest extends ExtendedITextTest { - private static final String certsSrc = "./src/test/resources/com/itextpdf/signatures/validation/v1/extensions/ExtendedKeyUsageExtensionTest/"; + private static final String certsSrc = "./src/test/resources/com/itextpdf/signatures/validation/extensions/ExtendedKeyUsageExtensionTest/"; @Test public void extendedKeyUsageNotSetExpectedTest() throws CertificateException, IOException { @@ -46,7 +45,7 @@ public void extendedKeyUsageNotSetExpectedTest() throws CertificateException, IO ExtendedKeyUsageExtension extension = new ExtendedKeyUsageExtension(Collections.emptyList()); - Assert.assertFalse(extension.existsInCertificate(certificate)); + Assertions.assertFalse(extension.existsInCertificate(certificate)); } @Test @@ -57,7 +56,7 @@ public void extendedKeyUsageNotSetNotExpectedTest() throws CertificateException, ExtendedKeyUsageExtension extension = new ExtendedKeyUsageExtension( Collections.singletonList(ExtendedKeyUsageExtension.TIME_STAMPING)); - Assert.assertFalse(extension.existsInCertificate(certificate)); + Assertions.assertFalse(extension.existsInCertificate(certificate)); } @Test @@ -68,7 +67,7 @@ public void extendedKeyUsageTimestampingExpectedTest() throws CertificateExcepti ExtendedKeyUsageExtension extension = new ExtendedKeyUsageExtension( Collections.singletonList(ExtendedKeyUsageExtension.TIME_STAMPING)); - Assert.assertTrue(extension.existsInCertificate(certificate)); + Assertions.assertTrue(extension.existsInCertificate(certificate)); } @Test @@ -79,7 +78,7 @@ public void extendedKeyUsageTimestampingNotExpectedTest() throws CertificateExce ExtendedKeyUsageExtension extension = new ExtendedKeyUsageExtension( Collections.singletonList(ExtendedKeyUsageExtension.OCSP_SIGNING)); - Assert.assertFalse(extension.existsInCertificate(certificate)); + Assertions.assertFalse(extension.existsInCertificate(certificate)); } @Test @@ -90,7 +89,7 @@ public void extendedKeyUsageOcspSigningExpectedTest() throws CertificateExceptio ExtendedKeyUsageExtension extension = new ExtendedKeyUsageExtension( Collections.singletonList(ExtendedKeyUsageExtension.OCSP_SIGNING)); - Assert.assertTrue(extension.existsInCertificate(certificate)); + Assertions.assertTrue(extension.existsInCertificate(certificate)); } @Test @@ -101,7 +100,7 @@ public void extendedKeyUsageOcspSigningNotExpectedTest() throws CertificateExcep ExtendedKeyUsageExtension extension = new ExtendedKeyUsageExtension( Collections.singletonList(ExtendedKeyUsageExtension.CODE_SIGNING)); - Assert.assertFalse(extension.existsInCertificate(certificate)); + Assertions.assertFalse(extension.existsInCertificate(certificate)); } @Test @@ -112,7 +111,7 @@ public void extendedKeyUsageAnyUsageTest1() throws CertificateException, IOExcep ExtendedKeyUsageExtension extension = new ExtendedKeyUsageExtension( Collections.singletonList(ExtendedKeyUsageExtension.CODE_SIGNING)); - Assert.assertTrue(extension.existsInCertificate(certificate)); + Assertions.assertTrue(extension.existsInCertificate(certificate)); } @Test @@ -123,7 +122,7 @@ public void extendedKeyUsageAnyUsageTest2() throws CertificateException, IOExcep ExtendedKeyUsageExtension extension = new ExtendedKeyUsageExtension( Arrays.asList(ExtendedKeyUsageExtension.CODE_SIGNING, ExtendedKeyUsageExtension.OCSP_SIGNING)); - Assert.assertTrue(extension.existsInCertificate(certificate)); + Assertions.assertTrue(extension.existsInCertificate(certificate)); } @Test @@ -134,7 +133,7 @@ public void extendedKeyUsageSeveralValues1PartiallyExpectedTest() throws Certifi ExtendedKeyUsageExtension extension = new ExtendedKeyUsageExtension( Arrays.asList(ExtendedKeyUsageExtension.TIME_STAMPING, ExtendedKeyUsageExtension.OCSP_SIGNING)); - Assert.assertTrue(extension.existsInCertificate(certificate)); + Assertions.assertTrue(extension.existsInCertificate(certificate)); } @Test @@ -145,7 +144,7 @@ public void extendedKeyUsageSeveralValues1PartiallyNotExpectedTest() throws Cert ExtendedKeyUsageExtension extension = new ExtendedKeyUsageExtension(Arrays.asList( ExtendedKeyUsageExtension.TIME_STAMPING, ExtendedKeyUsageExtension.ANY_EXTENDED_KEY_USAGE_OID)); - Assert.assertFalse(extension.existsInCertificate(certificate)); + Assertions.assertFalse(extension.existsInCertificate(certificate)); } @Test @@ -156,7 +155,7 @@ public void extendedKeyUsageSeveralValues2PartiallyExpectedTest() throws Certifi ExtendedKeyUsageExtension extension = new ExtendedKeyUsageExtension( Arrays.asList(ExtendedKeyUsageExtension.OCSP_SIGNING, ExtendedKeyUsageExtension.CLIENT_AUTH)); - Assert.assertTrue(extension.existsInCertificate(certificate)); + Assertions.assertTrue(extension.existsInCertificate(certificate)); } @Test @@ -168,6 +167,6 @@ public void extendedKeyUsageSeveralValues2PartiallyNotExpectedTest() throws Cert Arrays.asList(ExtendedKeyUsageExtension.CODE_SIGNING, ExtendedKeyUsageExtension.CLIENT_AUTH)); // Certificate contains any_extended_key_usage OID, that's why results is always true. - Assert.assertTrue(extension.existsInCertificate(certificate)); + Assertions.assertTrue(extension.existsInCertificate(certificate)); } } diff --git a/sign/src/test/java/com/itextpdf/signatures/validation/v1/extensions/KeyUsageExtensionTest.java b/sign/src/test/java/com/itextpdf/signatures/validation/extensions/KeyUsageExtensionTest.java similarity index 83% rename from sign/src/test/java/com/itextpdf/signatures/validation/v1/extensions/KeyUsageExtensionTest.java rename to sign/src/test/java/com/itextpdf/signatures/validation/extensions/KeyUsageExtensionTest.java index 4a257d9ff1..09ab05035f 100644 --- a/sign/src/test/java/com/itextpdf/signatures/validation/v1/extensions/KeyUsageExtensionTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/validation/extensions/KeyUsageExtensionTest.java @@ -20,23 +20,22 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.signatures.validation.v1.extensions; +package com.itextpdf.signatures.validation.extensions; import com.itextpdf.signatures.testutils.PemFileHelper; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.BouncyCastleUnitTest; import java.io.IOException; import java.security.cert.CertificateException; import java.security.cert.X509Certificate; import java.util.Arrays; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(BouncyCastleUnitTest.class) +@Tag("BouncyCastleUnitTest") public class KeyUsageExtensionTest extends ExtendedITextTest { - private static final String certsSrc = "./src/test/resources/com/itextpdf/signatures/validation/v1/extensions/KeyUsageExtensionTest/"; + private static final String certsSrc = "./src/test/resources/com/itextpdf/signatures/validation/extensions/KeyUsageExtensionTest/"; @Test public void keyUsageNotSetExpectedTest() throws CertificateException, IOException { @@ -45,7 +44,7 @@ public void keyUsageNotSetExpectedTest() throws CertificateException, IOExceptio KeyUsageExtension extension = new KeyUsageExtension(0); - Assert.assertFalse(extension.existsInCertificate(certificate)); + Assertions.assertFalse(extension.existsInCertificate(certificate)); } @Test @@ -55,7 +54,7 @@ public void keyUsageNotSetNotExpectedTest() throws CertificateException, IOExcep KeyUsageExtension extension = new KeyUsageExtension(8); - Assert.assertFalse(extension.existsInCertificate(certificate)); + Assertions.assertFalse(extension.existsInCertificate(certificate)); } @Test @@ -65,7 +64,7 @@ public void keyUsageKeyCertSignExpectedTest() throws CertificateException, IOExc KeyUsageExtension extension = new KeyUsageExtension(KeyUsage.KEY_CERT_SIGN); - Assert.assertTrue(extension.existsInCertificate(certificate)); + Assertions.assertTrue(extension.existsInCertificate(certificate)); } @Test @@ -75,7 +74,7 @@ public void keyUsageKeyCertSignPartiallyExpectedTest() throws CertificateExcepti KeyUsageExtension extension = new KeyUsageExtension(Arrays.asList(KeyUsage.KEY_CERT_SIGN, KeyUsage.CRL_SIGN)); - Assert.assertFalse(extension.existsInCertificate(certificate)); + Assertions.assertFalse(extension.existsInCertificate(certificate)); } @Test @@ -85,7 +84,7 @@ public void keyUsageKeyCertSignNotExpectedTest() throws CertificateException, IO KeyUsageExtension extension = new KeyUsageExtension(KeyUsage.CRL_SIGN); - Assert.assertFalse(extension.existsInCertificate(certificate)); + Assertions.assertFalse(extension.existsInCertificate(certificate)); } @Test @@ -95,7 +94,7 @@ public void keyUsageDigitalSignatureTest() throws CertificateException, IOExcept KeyUsageExtension extension = new KeyUsageExtension(KeyUsage.DIGITAL_SIGNATURE); - Assert.assertTrue(extension.existsInCertificate(certificate)); + Assertions.assertTrue(extension.existsInCertificate(certificate)); } @Test @@ -105,7 +104,7 @@ public void keyUsageDecipherOnlyExpectedTest() throws CertificateException, IOEx KeyUsageExtension extension = new KeyUsageExtension(KeyUsage.DECIPHER_ONLY); - Assert.assertTrue(extension.existsInCertificate(certificate)); + Assertions.assertTrue(extension.existsInCertificate(certificate)); } @Test @@ -115,7 +114,7 @@ public void keyUsageDecipherOnlyNotExpectedTest() throws CertificateException, I KeyUsageExtension extension = new KeyUsageExtension(KeyUsage.ENCIPHER_ONLY); - Assert.assertFalse(extension.existsInCertificate(certificate)); + Assertions.assertFalse(extension.existsInCertificate(certificate)); } @Test @@ -125,7 +124,7 @@ public void keyUsageSeveralKeys1PartiallyExpectedTest() throws CertificateExcept KeyUsageExtension extension = new KeyUsageExtension(Arrays.asList(KeyUsage.CRL_SIGN, KeyUsage.NON_REPUDIATION)); - Assert.assertTrue(extension.existsInCertificate(certificate)); + Assertions.assertTrue(extension.existsInCertificate(certificate)); } @Test @@ -136,7 +135,7 @@ public void keyUsageSeveralKeys1ExpectedTest() throws CertificateException, IOEx KeyUsageExtension extension = new KeyUsageExtension(Arrays.asList(KeyUsage.CRL_SIGN, KeyUsage.NON_REPUDIATION, KeyUsage.KEY_ENCIPHERMENT)); - Assert.assertTrue(extension.existsInCertificate(certificate)); + Assertions.assertTrue(extension.existsInCertificate(certificate)); } @Test @@ -147,7 +146,7 @@ public void keyUsageSeveralKeys1PartiallyNotExpectedTest() throws CertificateExc KeyUsageExtension extension = new KeyUsageExtension(Arrays.asList(KeyUsage.CRL_SIGN, KeyUsage.DECIPHER_ONLY, KeyUsage.KEY_ENCIPHERMENT)); - Assert.assertFalse(extension.existsInCertificate(certificate)); + Assertions.assertFalse(extension.existsInCertificate(certificate)); } @Test @@ -157,7 +156,7 @@ public void keyUsageSeveralKeys2PartiallyExpectedTest() throws CertificateExcept KeyUsageExtension extension = new KeyUsageExtension(Arrays.asList(KeyUsage.DECIPHER_ONLY, KeyUsage.DIGITAL_SIGNATURE)); - Assert.assertTrue(extension.existsInCertificate(certificate)); + Assertions.assertTrue(extension.existsInCertificate(certificate)); } @Test @@ -168,7 +167,7 @@ public void keyUsageSeveralKeys2ExpectedTest() throws CertificateException, IOEx KeyUsageExtension extension = new KeyUsageExtension(Arrays.asList(KeyUsage.DECIPHER_ONLY, KeyUsage.DIGITAL_SIGNATURE, KeyUsage.KEY_AGREEMENT)); - Assert.assertTrue(extension.existsInCertificate(certificate)); + Assertions.assertTrue(extension.existsInCertificate(certificate)); } @Test @@ -179,6 +178,6 @@ public void keyUsageSeveralKeys2PartiallyNotExpectedTest() throws CertificateExc KeyUsageExtension extension = new KeyUsageExtension(Arrays.asList(KeyUsage.CRL_SIGN, KeyUsage.DECIPHER_ONLY, KeyUsage.DIGITAL_SIGNATURE)); - Assert.assertFalse(extension.existsInCertificate(certificate)); + Assertions.assertFalse(extension.existsInCertificate(certificate)); } } diff --git a/sign/src/test/java/com/itextpdf/signatures/validation/v1/mocks/MockChainValidator.java b/sign/src/test/java/com/itextpdf/signatures/validation/mocks/MockChainValidator.java similarity index 88% rename from sign/src/test/java/com/itextpdf/signatures/validation/v1/mocks/MockChainValidator.java rename to sign/src/test/java/com/itextpdf/signatures/validation/mocks/MockChainValidator.java index 0b5b71e753..3229663e04 100644 --- a/sign/src/test/java/com/itextpdf/signatures/validation/v1/mocks/MockChainValidator.java +++ b/sign/src/test/java/com/itextpdf/signatures/validation/mocks/MockChainValidator.java @@ -20,12 +20,12 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.signatures.validation.v1.mocks; +package com.itextpdf.signatures.validation.mocks; -import com.itextpdf.signatures.validation.v1.CertificateChainValidator; -import com.itextpdf.signatures.validation.v1.ValidatorChainBuilder; -import com.itextpdf.signatures.validation.v1.context.ValidationContext; -import com.itextpdf.signatures.validation.v1.report.ValidationReport; +import com.itextpdf.signatures.validation.CertificateChainValidator; +import com.itextpdf.signatures.validation.ValidatorChainBuilder; +import com.itextpdf.signatures.validation.context.ValidationContext; +import com.itextpdf.signatures.validation.report.ValidationReport; import java.security.cert.X509Certificate; import java.util.ArrayList; diff --git a/sign/src/test/java/com/itextpdf/signatures/validation/v1/mocks/MockCrlValidator.java b/sign/src/test/java/com/itextpdf/signatures/validation/mocks/MockCrlValidator.java similarity index 90% rename from sign/src/test/java/com/itextpdf/signatures/validation/v1/mocks/MockCrlValidator.java rename to sign/src/test/java/com/itextpdf/signatures/validation/mocks/MockCrlValidator.java index 02e54504e3..79a6d71926 100644 --- a/sign/src/test/java/com/itextpdf/signatures/validation/v1/mocks/MockCrlValidator.java +++ b/sign/src/test/java/com/itextpdf/signatures/validation/mocks/MockCrlValidator.java @@ -20,13 +20,13 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.signatures.validation.v1.mocks; +package com.itextpdf.signatures.validation.mocks; import com.itextpdf.commons.utils.DateTimeUtil; -import com.itextpdf.signatures.validation.v1.CRLValidator; -import com.itextpdf.signatures.validation.v1.ValidatorChainBuilder; -import com.itextpdf.signatures.validation.v1.context.ValidationContext; -import com.itextpdf.signatures.validation.v1.report.ValidationReport; +import com.itextpdf.signatures.validation.CRLValidator; +import com.itextpdf.signatures.validation.ValidatorChainBuilder; +import com.itextpdf.signatures.validation.context.ValidationContext; +import com.itextpdf.signatures.validation.report.ValidationReport; import java.security.cert.X509CRL; import java.security.cert.X509Certificate; diff --git a/sign/src/test/java/com/itextpdf/signatures/validation/v1/mocks/MockDocumentRevisionsValidator.java b/sign/src/test/java/com/itextpdf/signatures/validation/mocks/MockDocumentRevisionsValidator.java similarity index 84% rename from sign/src/test/java/com/itextpdf/signatures/validation/v1/mocks/MockDocumentRevisionsValidator.java rename to sign/src/test/java/com/itextpdf/signatures/validation/mocks/MockDocumentRevisionsValidator.java index 7f2ed0181e..3fa8823be8 100644 --- a/sign/src/test/java/com/itextpdf/signatures/validation/v1/mocks/MockDocumentRevisionsValidator.java +++ b/sign/src/test/java/com/itextpdf/signatures/validation/mocks/MockDocumentRevisionsValidator.java @@ -20,15 +20,15 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.signatures.validation.v1.mocks; +package com.itextpdf.signatures.validation.mocks; import com.itextpdf.kernel.pdf.PdfDocument; -import com.itextpdf.signatures.validation.v1.DocumentRevisionsValidator; -import com.itextpdf.signatures.validation.v1.ValidatorChainBuilder; -import com.itextpdf.signatures.validation.v1.context.ValidationContext; -import com.itextpdf.signatures.validation.v1.report.ReportItem; -import com.itextpdf.signatures.validation.v1.report.ReportItem.ReportItemStatus; -import com.itextpdf.signatures.validation.v1.report.ValidationReport; +import com.itextpdf.signatures.validation.DocumentRevisionsValidator; +import com.itextpdf.signatures.validation.ValidatorChainBuilder; +import com.itextpdf.signatures.validation.context.ValidationContext; +import com.itextpdf.signatures.validation.report.ReportItem; +import com.itextpdf.signatures.validation.report.ReportItem.ReportItemStatus; +import com.itextpdf.signatures.validation.report.ValidationReport; import java.util.ArrayList; import java.util.List; diff --git a/sign/src/test/java/com/itextpdf/signatures/validation/v1/mocks/MockIssuingCertificateRetriever.java b/sign/src/test/java/com/itextpdf/signatures/validation/mocks/MockIssuingCertificateRetriever.java similarity index 84% rename from sign/src/test/java/com/itextpdf/signatures/validation/v1/mocks/MockIssuingCertificateRetriever.java rename to sign/src/test/java/com/itextpdf/signatures/validation/mocks/MockIssuingCertificateRetriever.java index a2ce857287..78a2420410 100644 --- a/sign/src/test/java/com/itextpdf/signatures/validation/v1/mocks/MockIssuingCertificateRetriever.java +++ b/sign/src/test/java/com/itextpdf/signatures/validation/mocks/MockIssuingCertificateRetriever.java @@ -20,19 +20,22 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.signatures.validation.v1.mocks; +package com.itextpdf.signatures.validation.mocks; import com.itextpdf.commons.bouncycastle.cert.ocsp.IBasicOCSPResp; import com.itextpdf.signatures.IssuingCertificateRetriever; -import com.itextpdf.signatures.validation.v1.TrustedCertificatesStore; +import com.itextpdf.signatures.validation.TrustedCertificatesStore; import java.io.IOException; import java.io.InputStream; import java.security.cert.CRL; import java.security.cert.Certificate; +import java.security.cert.X509Certificate; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.List; +import java.util.Set; import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Supplier; @@ -41,6 +44,7 @@ public class MockIssuingCertificateRetriever extends IssuingCertificateRetriever private final IssuingCertificateRetriever wrapped; public List retrieveMissingCertificatesCalls = new ArrayList<>(); public List getCrlIssuerCertificatesCalls = new ArrayList<>(); + public List getCrlIssuerCertificatesByNameCalls = new ArrayList<>(); public List retrieveIssuerCertificateCalls = new ArrayList<>(); public List retrieveOCSPResponderCertificateCalls = new ArrayList<>(); @@ -54,8 +58,9 @@ public class MockIssuingCertificateRetriever extends IssuingCertificateRetriever private Function retrieveMissingCertificatesHandler; private Function getCrlIssuerCertificatesHandler; + private Function getCrlIssuerCertificatesByNameHandler; private Function retrieveIssuerCertificateHandler; - private Function retrieveOCSPResponderCertificateHandler; + private Function> retrieveOCSPResponderCertificateHandler; private Consumer> setTrustedCertificatesHandler; private Consumer> addKnownCertificatesHandler; @@ -98,10 +103,22 @@ public Certificate[] getCrlIssuerCertificates(CRL crl) { } @Override - public Certificate retrieveIssuerCertificate(Certificate certificate) { + public Certificate[][] getCrlIssuerCertificatesByName(CRL crl) { + getCrlIssuerCertificatesByNameCalls.add(crl); + if (getCrlIssuerCertificatesByNameHandler != null) { + return getCrlIssuerCertificatesByNameHandler.apply(crl); + } + if (wrapped != null) { + return wrapped.getCrlIssuerCertificatesByName(crl); + } + return new Certificate[0][]; + } + + @Override + public List retrieveIssuerCertificate(Certificate certificate) { retrieveIssuerCertificateCalls.add(certificate); if (retrieveIssuerCertificateHandler != null) { - return retrieveIssuerCertificateHandler.apply(certificate); + return Collections.singletonList((X509Certificate) retrieveIssuerCertificateHandler.apply(certificate)); } if (wrapped != null) { return wrapped.retrieveIssuerCertificate(certificate); @@ -110,13 +127,13 @@ public Certificate retrieveIssuerCertificate(Certificate certificate) { } @Override - public Certificate retrieveOCSPResponderCertificate(IBasicOCSPResp ocspResp) { + public Set retrieveOCSPResponderByNameCertificate(IBasicOCSPResp ocspResp) { retrieveOCSPResponderCertificateCalls.add(ocspResp); if (retrieveOCSPResponderCertificateHandler != null) { return retrieveOCSPResponderCertificateHandler.apply(ocspResp); } if (wrapped != null) { - return wrapped.retrieveOCSPResponderCertificate(ocspResp); + return wrapped.retrieveOCSPResponderByNameCertificate(ocspResp); } return null; } @@ -200,12 +217,18 @@ public MockIssuingCertificateRetriever ongetCrlIssuerCertificatesDo(Function callback) { + getCrlIssuerCertificatesByNameHandler = callback; + return this; + } + public MockIssuingCertificateRetriever onRetrieveIssuerCertificateDo(Function callback) { retrieveIssuerCertificateHandler = callback; return this; } - public MockIssuingCertificateRetriever onRetrieveOCSPResponderCertificateDo(Function callback) { + public MockIssuingCertificateRetriever onRetrieveOCSPResponderCertificateDo( + Function> callback) { retrieveOCSPResponderCertificateHandler = callback; return this; } @@ -230,7 +253,8 @@ public MockIssuingCertificateRetriever onIsCertificateTrustedDo(Function callBack) { + public MockIssuingCertificateRetriever onGetTrustedCertificatesStoreDo( + Supplier callBack) { getTrustedCertificatesStoreHandler = callBack; return this; } diff --git a/sign/src/test/java/com/itextpdf/signatures/validation/v1/mocks/MockOCSPValidator.java b/sign/src/test/java/com/itextpdf/signatures/validation/mocks/MockOCSPValidator.java similarity index 91% rename from sign/src/test/java/com/itextpdf/signatures/validation/v1/mocks/MockOCSPValidator.java rename to sign/src/test/java/com/itextpdf/signatures/validation/mocks/MockOCSPValidator.java index f9de105e61..fec1726c03 100644 --- a/sign/src/test/java/com/itextpdf/signatures/validation/v1/mocks/MockOCSPValidator.java +++ b/sign/src/test/java/com/itextpdf/signatures/validation/mocks/MockOCSPValidator.java @@ -20,15 +20,15 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.signatures.validation.v1.mocks; +package com.itextpdf.signatures.validation.mocks; import com.itextpdf.commons.bouncycastle.cert.ocsp.IBasicOCSPResp; import com.itextpdf.commons.bouncycastle.cert.ocsp.ISingleResp; import com.itextpdf.commons.utils.DateTimeUtil; -import com.itextpdf.signatures.validation.v1.OCSPValidator; -import com.itextpdf.signatures.validation.v1.ValidatorChainBuilder; -import com.itextpdf.signatures.validation.v1.context.ValidationContext; -import com.itextpdf.signatures.validation.v1.report.ValidationReport; +import com.itextpdf.signatures.validation.OCSPValidator; +import com.itextpdf.signatures.validation.ValidatorChainBuilder; +import com.itextpdf.signatures.validation.context.ValidationContext; +import com.itextpdf.signatures.validation.report.ValidationReport; import java.security.cert.X509Certificate; import java.util.ArrayList; diff --git a/sign/src/test/java/com/itextpdf/signatures/validation/v1/mocks/MockRevocationDataValidator.java b/sign/src/test/java/com/itextpdf/signatures/validation/mocks/MockRevocationDataValidator.java similarity index 92% rename from sign/src/test/java/com/itextpdf/signatures/validation/v1/mocks/MockRevocationDataValidator.java rename to sign/src/test/java/com/itextpdf/signatures/validation/mocks/MockRevocationDataValidator.java index 3e3ae5649b..72525a979d 100644 --- a/sign/src/test/java/com/itextpdf/signatures/validation/v1/mocks/MockRevocationDataValidator.java +++ b/sign/src/test/java/com/itextpdf/signatures/validation/mocks/MockRevocationDataValidator.java @@ -20,14 +20,14 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.signatures.validation.v1.mocks; +package com.itextpdf.signatures.validation.mocks; import com.itextpdf.signatures.ICrlClient; import com.itextpdf.signatures.IOcspClient; -import com.itextpdf.signatures.validation.v1.RevocationDataValidator; -import com.itextpdf.signatures.validation.v1.ValidatorChainBuilder; -import com.itextpdf.signatures.validation.v1.context.ValidationContext; -import com.itextpdf.signatures.validation.v1.report.ValidationReport; +import com.itextpdf.signatures.validation.RevocationDataValidator; +import com.itextpdf.signatures.validation.ValidatorChainBuilder; +import com.itextpdf.signatures.validation.context.ValidationContext; +import com.itextpdf.signatures.validation.report.ValidationReport; import java.security.cert.X509Certificate; import java.util.ArrayList; diff --git a/sign/src/test/java/com/itextpdf/signatures/validation/v1/mocks/MockSignatureValidationProperties.java b/sign/src/test/java/com/itextpdf/signatures/validation/mocks/MockSignatureValidationProperties.java similarity index 94% rename from sign/src/test/java/com/itextpdf/signatures/validation/v1/mocks/MockSignatureValidationProperties.java rename to sign/src/test/java/com/itextpdf/signatures/validation/mocks/MockSignatureValidationProperties.java index 92719991cd..790600f6d3 100644 --- a/sign/src/test/java/com/itextpdf/signatures/validation/v1/mocks/MockSignatureValidationProperties.java +++ b/sign/src/test/java/com/itextpdf/signatures/validation/mocks/MockSignatureValidationProperties.java @@ -20,11 +20,11 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.signatures.validation.v1.mocks; +package com.itextpdf.signatures.validation.mocks; -import com.itextpdf.signatures.validation.v1.SignatureValidationProperties; -import com.itextpdf.signatures.validation.v1.context.ValidationContext; -import com.itextpdf.signatures.validation.v1.extensions.CertificateExtension; +import com.itextpdf.signatures.validation.SignatureValidationProperties; +import com.itextpdf.signatures.validation.context.ValidationContext; +import com.itextpdf.signatures.validation.extensions.CertificateExtension; import java.time.Duration; import java.util.ArrayList; diff --git a/sign/src/test/java/com/itextpdf/signatures/validation/v1/mocks/MockTrustedCertificatesStore.java b/sign/src/test/java/com/itextpdf/signatures/validation/mocks/MockTrustedCertificatesStore.java similarity index 83% rename from sign/src/test/java/com/itextpdf/signatures/validation/v1/mocks/MockTrustedCertificatesStore.java rename to sign/src/test/java/com/itextpdf/signatures/validation/mocks/MockTrustedCertificatesStore.java index 9f7fa5fd44..7dfa2d66cc 100644 --- a/sign/src/test/java/com/itextpdf/signatures/validation/v1/mocks/MockTrustedCertificatesStore.java +++ b/sign/src/test/java/com/itextpdf/signatures/validation/mocks/MockTrustedCertificatesStore.java @@ -20,14 +20,15 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.signatures.validation.v1.mocks; +package com.itextpdf.signatures.validation.mocks; -import com.itextpdf.signatures.validation.v1.TrustedCertificatesStore; +import com.itextpdf.signatures.validation.TrustedCertificatesStore; import java.security.cert.Certificate; import java.util.ArrayList; import java.util.Collection; import java.util.List; +import java.util.Set; import java.util.function.Function; import java.util.function.Supplier; @@ -53,12 +54,12 @@ public class MockTrustedCertificatesStore extends TrustedCertificatesStore { private Function isCertificateTrustedForCrlHandler; private Function isCertificateTrustedForTimestampHandler; private Function isCertificateTrustedForCAHandler; - private Function getGenerallyTrustedCertificateHandler; - private Function getCertificateTrustedForOcspHandler; - private Function getCertificateTrustedForCrlHandler; - private Function getCertificateTrustedForTimestampHandler; - private Function getCertificateTrustedForCAHandler; - private Function getKnownCertificateHandler; + private Function> getGenerallyTrustedCertificateHandler; + private Function> getCertificateTrustedForOcspHandler; + private Function> getCertificateTrustedForCrlHandler; + private Function> getCertificateTrustedForTimestampHandler; + private Function> getCertificateTrustedForCAHandler; + private Function> getKnownCertificateHandler; private Supplier> getAllTrustedCertificatesHandler; @@ -130,73 +131,73 @@ public boolean isCertificateTrustedForCA(Certificate certificate) { } @Override - public Certificate getGenerallyTrustedCertificate(String certificateName) { + public Set getGenerallyTrustedCertificates(String certificateName) { getGenerallyTrustedCertificateCalls.add(certificateName); if (getGenerallyTrustedCertificateHandler != null) { return getGenerallyTrustedCertificateHandler.apply(certificateName); } if (wrapped != null) { - return wrapped.getGenerallyTrustedCertificate(certificateName); + return wrapped.getGenerallyTrustedCertificates(certificateName); } return null; } @Override - public Certificate getCertificateTrustedForOcsp(String certificateName) { + public Set getCertificatesTrustedForOcsp(String certificateName) { getCertificateTrustedForOcspCalls.add(certificateName); if (getCertificateTrustedForOcspHandler != null) { return getCertificateTrustedForOcspHandler.apply(certificateName); } if (wrapped != null) { - return wrapped.getCertificateTrustedForOcsp(certificateName); + return wrapped.getCertificatesTrustedForOcsp(certificateName); } return null; } @Override - public Certificate getCertificateTrustedForCrl(String certificateName) { + public Set getCertificatesTrustedForCrl(String certificateName) { getCertificateTrustedForCrlCalls.add(certificateName); if (getCertificateTrustedForCrlHandler != null) { return getCertificateTrustedForCrlHandler.apply(certificateName); } if (wrapped != null) { - return wrapped.getCertificateTrustedForCrl(certificateName); + return wrapped.getCertificatesTrustedForCrl(certificateName); } return null; } @Override - public Certificate getCertificateTrustedForTimestamp(String certificateName) { + public Set getCertificatesTrustedForTimestamp(String certificateName) { getCertificateTrustedForTimestampCalls.add(certificateName); if (getCertificateTrustedForTimestampHandler != null) { return getCertificateTrustedForTimestampHandler.apply(certificateName); } if (wrapped != null) { - return wrapped.getCertificateTrustedForTimestamp(certificateName); + return wrapped.getCertificatesTrustedForTimestamp(certificateName); } return null; } @Override - public Certificate getCertificateTrustedForCA(String certificateName) { + public Set getCertificatesTrustedForCA(String certificateName) { getCertificateTrustedForCACalls.add(certificateName); if (getCertificateTrustedForCAHandler != null) { return getCertificateTrustedForCAHandler.apply(certificateName); } if (wrapped != null) { - return wrapped.getCertificateTrustedForCA(certificateName); + return wrapped.getCertificatesTrustedForCA(certificateName); } return null; } @Override - public Certificate getKnownCertificate(String certificateName) { + public Set getKnownCertificates(String certificateName) { getKnownCertificateCalls.add(certificateName); if (getKnownCertificateHandler != null) { return getKnownCertificateHandler.apply(certificateName); } if (wrapped != null) { - return wrapped.getKnownCertificate(certificateName); + return wrapped.getKnownCertificates(certificateName); } return null; } @@ -235,27 +236,27 @@ public MockTrustedCertificatesStore onIsCertificateTrustedForCADo(Function callBack) { + public MockTrustedCertificatesStore onGetGenerallyTrustedCertificateDo(Function> callBack) { getGenerallyTrustedCertificateHandler = callBack; return this; } - public MockTrustedCertificatesStore onGetCertificateTrustedForOcspDo(Function callBack) { + public MockTrustedCertificatesStore onGetCertificateTrustedForOcspDo(Function> callBack) { getCertificateTrustedForOcspHandler = callBack; return this; } - public MockTrustedCertificatesStore onGetCertificateTrustedForCrlDo(Function callBack) { + public MockTrustedCertificatesStore onGetCertificateTrustedForCrlDo(Function> callBack) { getCertificateTrustedForCrlHandler = callBack; return this; } - public MockTrustedCertificatesStore onGetCertificateTrustedForTimestampDo(Function callBack) { + public MockTrustedCertificatesStore onGetCertificateTrustedForTimestampDo(Function> callBack) { getCertificateTrustedForTimestampHandler = callBack; return this; } - public MockTrustedCertificatesStore onGetCertificateTrustedForCADo(Function callBack) { + public MockTrustedCertificatesStore onGetCertificateTrustedForCADo(Function> callBack) { getCertificateTrustedForCAHandler = callBack; return this; } - public MockTrustedCertificatesStore onGetKnownCertificateDo(Function callBack) { + public MockTrustedCertificatesStore onGetKnownCertificateDo(Function> callBack) { getKnownCertificateHandler = callBack; return this; } diff --git a/sign/src/test/java/com/itextpdf/signatures/validation/v1/report/ValidationReportTest.java b/sign/src/test/java/com/itextpdf/signatures/validation/report/ValidationReportTest.java similarity index 77% rename from sign/src/test/java/com/itextpdf/signatures/validation/v1/report/ValidationReportTest.java rename to sign/src/test/java/com/itextpdf/signatures/validation/report/ValidationReportTest.java index 1ad378df19..c328393072 100644 --- a/sign/src/test/java/com/itextpdf/signatures/validation/v1/report/ValidationReportTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/validation/report/ValidationReportTest.java @@ -20,20 +20,19 @@ This file is part of the iText (R) project. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package com.itextpdf.signatures.validation.v1.report; +package com.itextpdf.signatures.validation.report; import com.itextpdf.signatures.testutils.PemFileHelper; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.BouncyCastleUnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; import java.security.cert.CertificateException; import java.security.cert.X509Certificate; -@Category(BouncyCastleUnitTest.class) +@Tag("BouncyCastleUnitTest") public class ValidationReportTest extends ExtendedITextTest { private static final String CERTS_SRC = "./src/test/resources/com/itextpdf/signatures/certs/"; @@ -41,7 +40,7 @@ public class ValidationReportTest extends ExtendedITextTest { @Test public void getValidationResultWithNoLogsShouldBeValid() { ValidationReport sut = new ValidationReport(); - Assert.assertEquals(ValidationReport.ValidationResult.VALID, sut.getValidationResult()); + Assertions.assertEquals(ValidationReport.ValidationResult.VALID, sut.getValidationResult()); } @Test @@ -50,7 +49,7 @@ public void getValidationResultWithOnlyValidLogsShouldBeValid() { sut.addReportItem(new ReportItem("test1", "test1", ReportItem.ReportItemStatus.INFO)); sut.addReportItem(new ReportItem("test2", "test2", ReportItem.ReportItemStatus.INFO)); sut.addReportItem(new ReportItem("test3", "test3", ReportItem.ReportItemStatus.INFO)); - Assert.assertEquals(ValidationReport.ValidationResult.VALID, sut.getValidationResult()); + Assertions.assertEquals(ValidationReport.ValidationResult.VALID, sut.getValidationResult()); } @Test @@ -59,7 +58,7 @@ public void getValidationResultWithValidAndIndeterminateLogsShouldBeIndeterminat sut.addReportItem(new ReportItem("test1", "test1", ReportItem.ReportItemStatus.INFO)); sut.addReportItem(new ReportItem("test2", "test2", ReportItem.ReportItemStatus.INDETERMINATE)); sut.addReportItem(new ReportItem("test3", "test3", ReportItem.ReportItemStatus.INFO)); - Assert.assertEquals(ValidationReport.ValidationResult.INDETERMINATE, sut.getValidationResult()); + Assertions.assertEquals(ValidationReport.ValidationResult.INDETERMINATE, sut.getValidationResult()); } @Test @@ -68,7 +67,7 @@ public void getValidationResultWithInvalidLogsShouldBeInvalid() { sut.addReportItem(new ReportItem("test1", "test1", ReportItem.ReportItemStatus.INFO)); sut.addReportItem(new ReportItem("test2", "test2", ReportItem.ReportItemStatus.INVALID)); sut.addReportItem(new ReportItem("test3", "test3", ReportItem.ReportItemStatus.INDETERMINATE)); - Assert.assertEquals(ValidationReport.ValidationResult.INVALID, sut.getValidationResult()); + Assertions.assertEquals(ValidationReport.ValidationResult.INVALID, sut.getValidationResult()); } @Test @@ -79,9 +78,9 @@ public void testGetFailures() { sut.addReportItem(failure1); ReportItem failure2 = new ReportItem("test3", "test3", ReportItem.ReportItemStatus.INDETERMINATE); sut.addReportItem(failure2); - Assert.assertTrue(sut.getFailures().contains(failure1)); - Assert.assertTrue(sut.getFailures().contains(failure2)); - Assert.assertEquals(2, sut.getFailures().size()); + Assertions.assertTrue(sut.getFailures().contains(failure1)); + Assertions.assertTrue(sut.getFailures().contains(failure2)); + Assertions.assertEquals(2, sut.getFailures().size()); } @Test @@ -94,8 +93,8 @@ public void getCertificateFailuresTest() throws CertificateException, IOExceptio sut.addReportItem(failure1); ReportItem failure2 = new ReportItem("test3", "test3", ReportItem.ReportItemStatus.INDETERMINATE); sut.addReportItem(failure2); - Assert.assertTrue(sut.getCertificateFailures().contains(failure1)); - Assert.assertEquals(1, sut.getCertificateFailures().size()); + Assertions.assertTrue(sut.getCertificateFailures().contains(failure1)); + Assertions.assertEquals(1, sut.getCertificateFailures().size()); } @Test @@ -109,10 +108,10 @@ public void getLogsTest() throws CertificateException, IOException { sut.addReportItem(failure1); ReportItem failure2 = new ReportItem("test3", "test3", ReportItem.ReportItemStatus.INDETERMINATE); sut.addReportItem(failure2); - Assert.assertEquals(item1, sut.getLogs().get(0)); - Assert.assertEquals(failure1, sut.getLogs().get(1)); - Assert.assertEquals(failure2, sut.getLogs().get(2)); - Assert.assertEquals(3, sut.getLogs().size()); + Assertions.assertEquals(item1, sut.getLogs().get(0)); + Assertions.assertEquals(failure1, sut.getLogs().get(1)); + Assertions.assertEquals(failure2, sut.getLogs().get(2)); + Assertions.assertEquals(3, sut.getLogs().size()); } @Test @@ -125,8 +124,8 @@ public void getCertificateLogsTest() throws CertificateException, IOException { sut.addReportItem(failure1); ReportItem failure2 = new ReportItem("test3", "test3", ReportItem.ReportItemStatus.INDETERMINATE); sut.addReportItem(failure2); - Assert.assertTrue(sut.getCertificateLogs().contains(failure1)); - Assert.assertEquals(1, sut.getCertificateLogs().size()); + Assertions.assertTrue(sut.getCertificateLogs().contains(failure1)); + Assertions.assertEquals(1, sut.getCertificateLogs().size()); } @Test @@ -140,11 +139,11 @@ public void toStringTest() throws CertificateException, IOException { ReportItem failure2 = new ReportItem("test3check", "test3message", ReportItem.ReportItemStatus.INDETERMINATE); sut.addReportItem(failure2); - Assert.assertTrue(sut.toString().contains("INVALID")); - Assert.assertTrue(sut.toString().contains("test1check")); - Assert.assertTrue(sut.toString().contains("test1message")); - Assert.assertTrue(sut.toString().contains("test2check")); - Assert.assertTrue(sut.toString().contains("test2message")); - Assert.assertTrue(sut.toString().contains("test3check")); + Assertions.assertTrue(sut.toString().contains("INVALID")); + Assertions.assertTrue(sut.toString().contains("test1check")); + Assertions.assertTrue(sut.toString().contains("test1message")); + Assertions.assertTrue(sut.toString().contains("test2check")); + Assertions.assertTrue(sut.toString().contains("test2message")); + Assertions.assertTrue(sut.toString().contains("test3check")); } } \ No newline at end of file diff --git a/sign/src/test/java/com/itextpdf/signatures/validation/v1/RevocationDataValidatorIntegrationTest.java b/sign/src/test/java/com/itextpdf/signatures/validation/v1/RevocationDataValidatorIntegrationTest.java deleted file mode 100644 index 6859e776ae..0000000000 --- a/sign/src/test/java/com/itextpdf/signatures/validation/v1/RevocationDataValidatorIntegrationTest.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - This file is part of the iText (R) project. - Copyright (c) 1998-2024 Apryse Group NV - Authors: Apryse Software. - - This program is offered under a commercial and under the AGPL license. - For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. - - AGPL licensing: - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . - */ -package com.itextpdf.signatures.validation.v1; - -import com.itextpdf.bouncycastleconnector.BouncyCastleFactoryCreator; -import com.itextpdf.commons.bouncycastle.IBouncyCastleFactory; -import com.itextpdf.commons.bouncycastle.operator.AbstractOperatorCreationException; -import com.itextpdf.commons.bouncycastle.pkcs.AbstractPKCSException; -import com.itextpdf.commons.utils.DateTimeUtil; -import com.itextpdf.signatures.IssuingCertificateRetriever; -import com.itextpdf.signatures.testutils.PemFileHelper; -import com.itextpdf.signatures.testutils.TimeTestUtil; -import com.itextpdf.signatures.testutils.builder.TestCrlBuilder; -import com.itextpdf.signatures.testutils.builder.TestOcspResponseBuilder; -import com.itextpdf.signatures.testutils.client.TestCrlClient; -import com.itextpdf.signatures.testutils.client.TestOcspClient; -import com.itextpdf.signatures.validation.v1.context.CertificateSource; -import com.itextpdf.signatures.validation.v1.context.CertificateSources; -import com.itextpdf.signatures.validation.v1.context.TimeBasedContext; -import com.itextpdf.signatures.validation.v1.context.TimeBasedContexts; -import com.itextpdf.signatures.validation.v1.context.ValidationContext; -import com.itextpdf.signatures.validation.v1.context.ValidatorContext; -import com.itextpdf.signatures.validation.v1.context.ValidatorContexts; -import com.itextpdf.signatures.validation.v1.report.ReportItem; -import com.itextpdf.signatures.validation.v1.report.ValidationReport; -import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.BouncyCastleUnitTest; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -import java.io.IOException; -import java.security.PrivateKey; -import java.security.Security; -import java.security.cert.CertificateException; -import java.security.cert.X509Certificate; -import java.util.Collections; - -@Category(BouncyCastleUnitTest.class) -public class RevocationDataValidatorIntegrationTest extends ExtendedITextTest { - private static final IBouncyCastleFactory FACTORY = BouncyCastleFactoryCreator.getFactory(); - private static final String SOURCE_FOLDER = - "./src/test/resources/com/itextpdf/signatures/validation/v1/RevocationDataValidatorTest/"; - private static final char[] PASSWORD = "testpassphrase".toCharArray(); - - - private static X509Certificate caCert; - private static PrivateKey caPrivateKey; - private static X509Certificate checkCert; - private static X509Certificate responderCert; - private static PrivateKey ocspRespPrivateKey; - private IssuingCertificateRetriever certificateRetriever; - private SignatureValidationProperties parameters; - private ValidatorChainBuilder validatorChainBuilder; - private final ValidationContext baseContext = new ValidationContext(ValidatorContext.SIGNATURE_VALIDATOR, - CertificateSource.SIGNER_CERT, TimeBasedContext.PRESENT); - - @BeforeClass - public static void before() - throws CertificateException, IOException, AbstractOperatorCreationException, AbstractPKCSException { - Security.addProvider(FACTORY.getProvider()); - - String rootCertFileName = SOURCE_FOLDER + "rootCert.pem"; - String checkCertFileName = SOURCE_FOLDER + "signCert.pem"; - String ocspResponderCertFileName = SOURCE_FOLDER + "ocspResponderCert.pem"; - - caCert = (X509Certificate) PemFileHelper.readFirstChain(rootCertFileName)[0]; - caPrivateKey = PemFileHelper.readFirstKey(rootCertFileName, PASSWORD); - checkCert = (X509Certificate) PemFileHelper.readFirstChain(checkCertFileName)[0]; - responderCert = (X509Certificate) PemFileHelper.readFirstChain(ocspResponderCertFileName)[0]; - ocspRespPrivateKey = PemFileHelper.readFirstKey(ocspResponderCertFileName, PASSWORD); - } - - @Before - public void setUp() { - certificateRetriever = new IssuingCertificateRetriever(); - parameters = new SignatureValidationProperties(); - validatorChainBuilder = new ValidatorChainBuilder() - .withIssuingCertificateRetriever(certificateRetriever) - .withSignatureValidationProperties(parameters); - } - - - @Test - public void crlWithOnlySomeReasonsTest() throws Exception { - TestCrlBuilder builder1 = new TestCrlBuilder(caCert, caPrivateKey); - builder1.addExtension(FACTORY.createExtension().getIssuingDistributionPoint(), true, - FACTORY.createIssuingDistributionPoint(null, false, false, - FACTORY.createReasonFlags(CRLValidator.ALL_REASONS - 31), false, false)); - TestCrlBuilder builder2 = new TestCrlBuilder(caCert, caPrivateKey); - builder2.addExtension(FACTORY.createExtension().getIssuingDistributionPoint(), true, - FACTORY.createIssuingDistributionPoint(null, false, false, - FACTORY.createReasonFlags(31), false, false)); - TestCrlClient crlClient = new TestCrlClient() - .addBuilderForCertIssuer(builder1) - .addBuilderForCertIssuer(builder2); - TestOcspResponseBuilder ocspBuilder = new TestOcspResponseBuilder(responderCert, ocspRespPrivateKey); - ocspBuilder.setProducedAt(DateTimeUtil.addDaysToDate(TimeTestUtil.TEST_DATE_TIME, -100)); - - certificateRetriever.setTrustedCertificates(Collections.singletonList(caCert)); - - parameters.setRevocationOnlineFetching(ValidatorContexts.all(), CertificateSources.all(), - TimeBasedContexts.all(), SignatureValidationProperties.OnlineFetching.NEVER_FETCH); - - - ValidationReport report = new ValidationReport(); - RevocationDataValidator validator = validatorChainBuilder.buildRevocationDataValidator(); - validator - .addOcspClient(new TestOcspClient().addBuilderForCertIssuer(caCert, ocspBuilder)) - .addCrlClient(crlClient); - - validator.validate(report, baseContext, checkCert, TimeTestUtil.TEST_DATE_TIME); - - AssertValidationReport.assertThat(report, a -> a - .hasNumberOfFailures(0) - .hasLogItem(la -> la - .withCertificate(checkCert) - .withStatus(ReportItem.ReportItemStatus.INFO) - .withMessage(CRLValidator.ONLY_SOME_REASONS_CHECKED) - )); - - } -} diff --git a/sign/src/test/java/com/itextpdf/signatures/validation/v1/extensions/BasicConstraintsExtensionTest.java b/sign/src/test/java/com/itextpdf/signatures/validation/v1/extensions/BasicConstraintsExtensionTest.java deleted file mode 100644 index ad219fe619..0000000000 --- a/sign/src/test/java/com/itextpdf/signatures/validation/v1/extensions/BasicConstraintsExtensionTest.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - This file is part of the iText (R) project. - Copyright (c) 1998-2024 Apryse Group NV - Authors: Apryse Software. - - This program is offered under a commercial and under the AGPL license. - For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. - - AGPL licensing: - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . - */ -package com.itextpdf.signatures.validation.v1.extensions; - -import com.itextpdf.signatures.testutils.PemFileHelper; -import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.BouncyCastleUnitTest; - -import java.io.IOException; -import java.security.cert.CertificateException; -import java.security.cert.X509Certificate; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -@Category(BouncyCastleUnitTest.class) -public class BasicConstraintsExtensionTest extends ExtendedITextTest { - private static final String certsSrc = "./src/test/resources/com/itextpdf/signatures/validation/v1/extensions/BasicConstraintsExtensionTest/"; - - @Test - public void basicConstraintNotSetExpectedTest() throws CertificateException, IOException { - String certName = certsSrc + "basicConstraintsNotSetCert.pem"; - X509Certificate certificate = (X509Certificate) PemFileHelper.readFirstChain(certName)[0]; - - BasicConstraintsExtension extension = new BasicConstraintsExtension(-2); - - Assert.assertFalse(extension.existsInCertificate(certificate)); - } - - @Test - public void basicConstraintNotSetNotExpectedTest() throws CertificateException, IOException { - String certName = certsSrc + "basicConstraintsNotSetCert.pem"; - X509Certificate certificate = (X509Certificate) PemFileHelper.readFirstChain(certName)[0]; - - BasicConstraintsExtension extension = new BasicConstraintsExtension(10); - - Assert.assertFalse(extension.existsInCertificate(certificate)); - } - - @Test - public void basicConstraintMaxLengthExpectedTest() throws CertificateException, IOException { - String certName = certsSrc + "basicConstraintsMaxCert.pem"; - X509Certificate certificate = (X509Certificate) PemFileHelper.readFirstChain(certName)[0]; - - BasicConstraintsExtension extension = new BasicConstraintsExtension(true); - - Assert.assertTrue(extension.existsInCertificate(certificate)); - } - - @Test - public void basicConstraintMaxLengthNotExpectedTest() throws CertificateException, IOException { - String certName = certsSrc + "basicConstraintsMaxCert.pem"; - X509Certificate certificate = (X509Certificate) PemFileHelper.readFirstChain(certName)[0]; - - BasicConstraintsExtension extension = new BasicConstraintsExtension(false); - - Assert.assertFalse(extension.existsInCertificate(certificate)); - } - - @Test - public void basicConstraintLength10Test() throws CertificateException, IOException { - String certName = certsSrc + "basicConstraints10Cert.pem"; - X509Certificate certificate = (X509Certificate) PemFileHelper.readFirstChain(certName)[0]; - - BasicConstraintsExtension extension = new BasicConstraintsExtension(10); - - Assert.assertTrue(extension.existsInCertificate(certificate)); - } - - @Test - public void basicConstraintLength5ExpectedTest() throws CertificateException, IOException { - String certName = certsSrc + "basicConstraints5Cert.pem"; - X509Certificate certificate = (X509Certificate) PemFileHelper.readFirstChain(certName)[0]; - - BasicConstraintsExtension extension = new BasicConstraintsExtension(2); - - Assert.assertTrue(extension.existsInCertificate(certificate)); - } - - @Test - public void basicConstraintLength5NotExpectedTest() throws CertificateException, IOException { - String certName = certsSrc + "basicConstraints5Cert.pem"; - X509Certificate certificate = (X509Certificate) PemFileHelper.readFirstChain(certName)[0]; - - BasicConstraintsExtension extension = new BasicConstraintsExtension(10); - - Assert.assertFalse(extension.existsInCertificate(certificate)); - } - - @Test - public void basicConstraintFalseExpectedTest() throws CertificateException, IOException { - String certName = certsSrc + "basicConstraintsFalseCert.pem"; - X509Certificate certificate = (X509Certificate) PemFileHelper.readFirstChain(certName)[0]; - - BasicConstraintsExtension extension = new BasicConstraintsExtension(false); - - Assert.assertTrue(extension.existsInCertificate(certificate)); - } - - @Test - public void basicConstraintFalseNotExpectedTest() throws CertificateException, IOException { - String certName = certsSrc + "basicConstraintsFalseCert.pem"; - X509Certificate certificate = (X509Certificate) PemFileHelper.readFirstChain(certName)[0]; - - BasicConstraintsExtension extension = new BasicConstraintsExtension(10); - - Assert.assertFalse(extension.existsInCertificate(certificate)); - } -} diff --git a/sign/src/test/java/com/itextpdf/signatures/verify/CertificateVerificationClassTest.java b/sign/src/test/java/com/itextpdf/signatures/verify/CertificateVerificationClassTest.java index 37365040a5..03e7aa8502 100644 --- a/sign/src/test/java/com/itextpdf/signatures/verify/CertificateVerificationClassTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/verify/CertificateVerificationClassTest.java @@ -42,7 +42,6 @@ This file is part of the iText (R) project. import com.itextpdf.test.ITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.BouncyCastleUnitTest; import java.io.ByteArrayInputStream; import java.io.IOException; @@ -62,13 +61,13 @@ This file is part of the iText (R) project. import java.util.Collection; import java.util.Collections; import java.util.List; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(BouncyCastleUnitTest.class) +@Tag("BouncyCastleUnitTest") public class CertificateVerificationClassTest extends ExtendedITextTest { private static final IBouncyCastleFactory FACTORY = BouncyCastleFactoryCreator.getFactory(); @@ -81,13 +80,13 @@ public class CertificateVerificationClassTest extends ExtendedITextTest { private static final String CERTS_SRC = "./src/test/resources/com/itextpdf/signatures/certs/"; private static final char[] PASSWORD = "testpassphrase".toCharArray(); - @BeforeClass + @BeforeAll public static void before() { Security.addProvider(PROVIDER); ITextTest.removeCryptographyRestrictions(); } - @AfterClass + @AfterAll public static void after() { ITextTest.restoreCryptographyRestrictions(); } @@ -102,7 +101,7 @@ public void validCertificateChain01() List verificationExceptions = CertificateVerification.verifyCertificates(certChain, caKeyStore); - Assert.assertTrue(verificationExceptions.isEmpty()); + Assertions.assertTrue(verificationExceptions.isEmpty()); } @Test @@ -111,7 +110,7 @@ public void timestampCertificateAndKeyStoreCorrespondTest() throws Exception { KeyStore caKeyStore = PemFileHelper.initStore(tsaCertFileName, PASSWORD, PROVIDER); - Assert.assertTrue(verifyTimestampCertificates(tsaCertFileName, caKeyStore)); + Assertions.assertTrue(verifyTimestampCertificates(tsaCertFileName, caKeyStore)); } @Test @@ -122,7 +121,7 @@ public void timestampCertificateAndKeyStoreDoNotCorrespondTest() throws Exceptio KeyStore caKeyStore = PemFileHelper.initStore(notTsaCertFileName, PASSWORD, PROVIDER); - Assert.assertFalse(verifyTimestampCertificates(tsaCertFileName, caKeyStore)); + Assertions.assertFalse(verifyTimestampCertificates(tsaCertFileName, caKeyStore)); } @Test @@ -130,7 +129,7 @@ public void timestampCertificateAndKeyStoreDoNotCorrespondTest() throws Exceptio public void keyStoreWithoutCertificatesTest() throws Exception { String tsaCertFileName = CERTS_SRC + "tsCertRsa.pem"; - Assert.assertFalse(verifyTimestampCertificates(tsaCertFileName, null)); + Assertions.assertFalse(verifyTimestampCertificates(tsaCertFileName, null)); } @Test @@ -143,7 +142,7 @@ public void expiredCertificateTest() throws CertificateException, IOException { final String verificationResult = CertificateVerification.verifyCertificate(expiredCert, null); final String expectedResultString = SignaturesTestUtils.getExpiredMessage(expiredCert); - Assert.assertEquals(expectedResultString, verificationResult); + Assertions.assertEquals(expectedResultString, verificationResult); } @Test @@ -153,7 +152,7 @@ public void unsupportedCriticalExtensionTest() throws CertificateException, IOEx final String verificationResult = CertificateVerification.verifyCertificate(unsupportedExtensionCert, null); - Assert.assertEquals(CertificateVerification.HAS_UNSUPPORTED_EXTENSIONS, verificationResult); + Assertions.assertEquals(CertificateVerification.HAS_UNSUPPORTED_EXTENSIONS, verificationResult); } @Test @@ -195,7 +194,7 @@ public void clrWithGivenCertificateTest() final String verificationResult = CertificateVerification.verifyCertificate(checkCert, crls); - Assert.assertEquals(CertificateVerification.CERTIFICATE_REVOKED, verificationResult); + Assertions.assertEquals(CertificateVerification.CERTIFICATE_REVOKED, verificationResult); } @Test @@ -205,7 +204,7 @@ public void validCertWithEmptyCrlCollectionTest() throws CertificateException, I final String verificationResult = CertificateVerification.verifyCertificate(rootCert, Collections.emptyList()); - Assert.assertNull(verificationResult); + Assertions.assertNull(verificationResult); } @Test @@ -232,7 +231,7 @@ public void validCertWithCrlDoesNotContainCertTest() crls.add(SignTestPortUtil.parseCrlFromStream(new ByteArrayInputStream(crlBytes))); } - Assert.assertNull(CertificateVerification.verifyCertificate(rootCert, crls)); + Assertions.assertNull(CertificateVerification.verifyCertificate(rootCert, crls)); } @Test @@ -244,8 +243,8 @@ public void emptyCertChainTest() throws CertificateEncodingException { List resultedExceptionList = CertificateVerification.verifyCertificates(emptyCertChain, null, (Collection) null); - Assert.assertEquals(1, resultedExceptionList.size()); - Assert.assertEquals(expectedResult, resultedExceptionList.get(0).getMessage()); + Assertions.assertEquals(1, resultedExceptionList.size()); + Assertions.assertEquals(expectedResult, resultedExceptionList.get(0).getMessage()); } @Test @@ -265,8 +264,8 @@ public void validCertChainWithEmptyKeyStoreTest() FACTORY.createX500Name((X509Certificate) validCertChain[2]).toString(), SignExceptionMessageConstant.CANNOT_BE_VERIFIED_CERTIFICATE_CHAIN); - Assert.assertEquals(1, resultedExceptionList.size()); - Assert.assertEquals(expectedResult, resultedExceptionList.get(0).getMessage()); + Assertions.assertEquals(1, resultedExceptionList.size()); + Assertions.assertEquals(expectedResult, resultedExceptionList.get(0).getMessage()); } @Test @@ -281,7 +280,7 @@ public void validCertChainWithRootCertAsKeyStoreTest() List resultedExceptionList = CertificateVerification.verifyCertificates(validCertChain, emptyKeyStore, (Collection) null); - Assert.assertEquals(0, resultedExceptionList.size()); + Assertions.assertEquals(0, resultedExceptionList.size()); } @Test @@ -300,7 +299,7 @@ public void certChainWithExpiredCertTest() List resultedExceptionList = CertificateVerification.verifyCertificates(validCertChain, null, (Collection) null); - Assert.assertEquals(2, resultedExceptionList.size()); + Assertions.assertEquals(2, resultedExceptionList.size()); final String expectedFirstResultMessage = MessageFormatUtil.format( SignExceptionMessageConstant.CERTIFICATE_TEMPLATE_FOR_EXCEPTION_MESSAGE, expiredCertName, SignaturesTestUtils.getExpiredMessage(expectedExpiredCert)); @@ -308,8 +307,8 @@ public void certChainWithExpiredCertTest() SignExceptionMessageConstant.CERTIFICATE_TEMPLATE_FOR_EXCEPTION_MESSAGE, rootCertName, SignExceptionMessageConstant.CANNOT_BE_VERIFIED_CERTIFICATE_CHAIN); - Assert.assertEquals(expectedFirstResultMessage, resultedExceptionList.get(0).getMessage()); - Assert.assertEquals(expectedSecondResultMessage, resultedExceptionList.get(1).getMessage()); + Assertions.assertEquals(expectedFirstResultMessage, resultedExceptionList.get(0).getMessage()); + Assertions.assertEquals(expectedSecondResultMessage, resultedExceptionList.get(1).getMessage()); } private static boolean verifyTimestampCertificates(String tsaClientCertificate, KeyStore caKeyStore) diff --git a/sign/src/test/java/com/itextpdf/signatures/verify/CrlVerifierTest.java b/sign/src/test/java/com/itextpdf/signatures/verify/CrlVerifierTest.java index c33dbd7c9f..648c4b38a6 100644 --- a/sign/src/test/java/com/itextpdf/signatures/verify/CrlVerifierTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/verify/CrlVerifierTest.java @@ -35,11 +35,10 @@ This file is part of the iText (R) project. import com.itextpdf.signatures.testutils.builder.TestCrlBuilder; import com.itextpdf.signatures.testutils.client.TestCrlClient; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.BouncyCastleUnitTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.ByteArrayInputStream; import java.io.IOException; @@ -50,14 +49,14 @@ This file is part of the iText (R) project. import java.security.cert.X509Certificate; import java.util.Collection; -@Category(BouncyCastleUnitTest.class) +@Tag("BouncyCastleUnitTest") public class CrlVerifierTest extends ExtendedITextTest { private static final IBouncyCastleFactory FACTORY = BouncyCastleFactoryCreator.getFactory(); private static final String certsSrc = "./src/test/resources/com/itextpdf/signatures/certs/"; private static final char[] password = "testpassphrase".toCharArray(); - @BeforeClass + @BeforeAll public static void before() { Security.addProvider(FACTORY.getProvider()); } @@ -69,7 +68,7 @@ public void validCrl01() throws GeneralSecurityException, IOException, AbstractP X509Certificate caCert = (X509Certificate) PemFileHelper.readFirstChain(caCertP12FileName)[0]; PrivateKey caPrivateKey = PemFileHelper.readFirstKey(caCertP12FileName, password); TestCrlBuilder crlBuilder = new TestCrlBuilder(caCert, caPrivateKey, DateTimeUtil.addDaysToDate(TimeTestUtil.TEST_DATE_TIME, -1)); - Assert.assertTrue(verifyTest(crlBuilder)); + Assertions.assertTrue(verifyTest(crlBuilder)); } @Test @@ -85,7 +84,7 @@ public void invalidRevokedCrl01() crlBuilder.addCrlEntry(checkCert, DateTimeUtil.addDaysToDate(TimeTestUtil.TEST_DATE_TIME, -40), FACTORY.createCRLReason().getKeyCompromise()); - Assert.assertThrows(VerificationException.class, () -> verifyTest(crlBuilder)); + Assertions.assertThrows(VerificationException.class, () -> verifyTest(crlBuilder)); } @Test @@ -97,7 +96,7 @@ public void invalidOutdatedCrl01() TestCrlBuilder crlBuilder = new TestCrlBuilder(caCert, caPrivateKey, DateTimeUtil.addDaysToDate(TimeTestUtil.TEST_DATE_TIME, -2)); crlBuilder.setNextUpdate(DateTimeUtil.addDaysToDate(TimeTestUtil.TEST_DATE_TIME, -1)); - Assert.assertFalse(verifyTest(crlBuilder)); + Assertions.assertFalse(verifyTest(crlBuilder)); } private boolean verifyTest(TestCrlBuilder crlBuilder) throws GeneralSecurityException, IOException { diff --git a/sign/src/test/java/com/itextpdf/signatures/verify/LtvVerifierTest.java b/sign/src/test/java/com/itextpdf/signatures/verify/LtvVerifierTest.java index c6a2123639..d971260060 100644 --- a/sign/src/test/java/com/itextpdf/signatures/verify/LtvVerifierTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/verify/LtvVerifierTest.java @@ -34,20 +34,19 @@ This file is part of the iText (R) project. import com.itextpdf.signatures.testutils.PemFileHelper; import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.ITextTest; -import com.itextpdf.test.annotations.type.BouncyCastleIntegrationTest; import java.io.IOException; import java.security.GeneralSecurityException; import java.security.Provider; import java.security.Security; import java.util.List; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(BouncyCastleIntegrationTest.class) +@Tag("BouncyCastleIntegrationTest") public class LtvVerifierTest extends ExtendedITextTest { private static final String sourceFolder = "./src/test/resources/com/itextpdf/signatures/verify/LtvVerifierTest/"; private static final String certsSrc = "./src/test/resources/com/itextpdf/signatures/certs/"; @@ -57,13 +56,13 @@ public class LtvVerifierTest extends ExtendedITextTest { private static final Provider PROVIDER = FACTORY.getProvider(); - @BeforeClass + @BeforeAll public static void before() { Security.addProvider(PROVIDER); ITextTest.removeCryptographyRestrictions(); } - @AfterClass + @AfterAll public static void after() { ITextTest.restoreCryptographyRestrictions(); } @@ -78,7 +77,7 @@ public void validLtvDocTest01() verifier.setRootStore(PemFileHelper.initStore(certsSrc + "rootStore.pem", password, PROVIDER)); List verificationMessages = verifier.verify(null); - Assert.assertEquals(7, verificationMessages.size()); + Assertions.assertEquals(7, verificationMessages.size()); } @Test public void validLtvDocTest02() @@ -93,7 +92,7 @@ public void validLtvDocTest02() verifier.setRootStore(PemFileHelper.initStore(certsSrc + "rootStore.pem", password, PROVIDER)); List verificationMessages = verifier.verify(null); - Assert.assertEquals(7, verificationMessages.size()); + Assertions.assertEquals(7, verificationMessages.size()); } } diff --git a/sign/src/test/java/com/itextpdf/signatures/verify/OcspCertificateVerificationTest.java b/sign/src/test/java/com/itextpdf/signatures/verify/OcspCertificateVerificationTest.java index 868fde4aaf..bcd3e05891 100644 --- a/sign/src/test/java/com/itextpdf/signatures/verify/OcspCertificateVerificationTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/verify/OcspCertificateVerificationTest.java @@ -32,18 +32,17 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.BouncyCastleUnitTest; import java.security.PrivateKey; import java.security.Provider; import java.security.Security; import java.security.cert.X509Certificate; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(BouncyCastleUnitTest.class) +@Tag("BouncyCastleUnitTest") public class OcspCertificateVerificationTest extends ExtendedITextTest { private static final IBouncyCastleFactory FACTORY = BouncyCastleFactoryCreator.getFactory(); @@ -65,7 +64,7 @@ public class OcspCertificateVerificationTest extends ExtendedITextTest { private static X509Certificate checkCert; private static X509Certificate rootCert; - @BeforeClass + @BeforeAll public static void before() throws Exception { Security.addProvider(PROVIDER); checkCert = (X509Certificate) PemFileHelper.readFirstChain(signOcspCert)[0]; @@ -76,7 +75,7 @@ public static void before() throws Exception { public void keyStoreWithRootOcspCertificateTest() throws Exception { IBasicOCSPResp response = getOcspResponse(); - Assert.assertTrue(CertificateVerification.verifyOcspCertificates( + Assertions.assertTrue(CertificateVerification.verifyOcspCertificates( response, PemFileHelper.initStore(rootOcspCert, password, PROVIDER), null)); } @@ -84,7 +83,7 @@ public void keyStoreWithRootOcspCertificateTest() throws Exception { public void keyStoreWithSignOcspCertificateTest() throws Exception { IBasicOCSPResp response = getOcspResponse(); - Assert.assertFalse(CertificateVerification.verifyOcspCertificates( + Assertions.assertFalse(CertificateVerification.verifyOcspCertificates( response, PemFileHelper.initStore(signOcspCert, password, PROVIDER), null)); } @@ -92,14 +91,14 @@ public void keyStoreWithSignOcspCertificateTest() throws Exception { public void keyStoreWithNotOcspAndOcspCertificatesTest() throws Exception { IBasicOCSPResp response = getOcspResponse(); - Assert.assertTrue(CertificateVerification.verifyOcspCertificates( + Assertions.assertTrue(CertificateVerification.verifyOcspCertificates( response, PemFileHelper.initStore(notOcspAndOcspCert, password, PROVIDER), null)); } @Test @LogMessages(messages = @LogMessage(messageTemplate = ANY_LOG_MESSAGE)) public void keyStoreWithNotOcspCertificateTest() throws Exception { - Assert.assertFalse(CertificateVerification.verifyOcspCertificates( + Assertions.assertFalse(CertificateVerification.verifyOcspCertificates( null, PemFileHelper.initStore(signOcspCert, password, PROVIDER), null)); } diff --git a/sign/src/test/java/com/itextpdf/signatures/verify/OcspVerifierTest.java b/sign/src/test/java/com/itextpdf/signatures/verify/OcspVerifierTest.java index 11ab835667..626928c2e1 100644 --- a/sign/src/test/java/com/itextpdf/signatures/verify/OcspVerifierTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/verify/OcspVerifierTest.java @@ -45,7 +45,6 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.BouncyCastleUnitTest; import java.io.IOException; import java.security.GeneralSecurityException; @@ -63,12 +62,12 @@ This file is part of the iText (R) project. import java.util.Date; import java.util.List; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(BouncyCastleUnitTest.class) +@Tag("BouncyCastleUnitTest") public class OcspVerifierTest extends ExtendedITextTest { private static final IBouncyCastleFactory FACTORY = BouncyCastleFactoryCreator.getFactory(); @@ -77,7 +76,7 @@ public class OcspVerifierTest extends ExtendedITextTest { private static final char[] password = "testpassphrase".toCharArray(); private static final String caCertFileName = certsSrc + "rootRsa.pem"; - @BeforeClass + @BeforeAll public static void before() { Security.addProvider(FACTORY.getProvider()); } @@ -93,7 +92,7 @@ public void validOcspTest01() builder.setThisUpdate(thisUpdate); builder.setNextUpdate(nextUpdate); builder.setProducedAt(caCert.getNotBefore()); - Assert.assertTrue(verifyTest(builder, certsSrc + "signCertRsa01.pem", caCert.getNotAfter())); + Assertions.assertTrue(verifyTest(builder, certsSrc + "signCertRsa01.pem", caCert.getNotAfter())); } @Test @@ -103,7 +102,7 @@ public void validOcspWithoutOcspResponseBuilderTest() throws IOException, Genera Date checkDate = TimeTestUtil.TEST_DATE_TIME; OCSPVerifier ocspVerifier = new OCSPVerifier(null, null); - Assert.assertTrue(ocspVerifier.verify(caCert, rootCert, checkDate).isEmpty()); + Assertions.assertTrue(ocspVerifier.verify(caCert, rootCert, checkDate).isEmpty()); } @Test @@ -116,7 +115,7 @@ public void verifyOcspWhenCertificateWasRevokedBeforeSignDateTest() builder.setCertificateStatus(FACTORY.createRevokedStatus( DateTimeUtil.addDaysToDate(TimeTestUtil.TEST_DATE_TIME, -20), FACTORY.createCRLReason().getKeyCompromise())); - Assert.assertFalse(verifyTest(builder)); + Assertions.assertFalse(verifyTest(builder)); } @Test @@ -132,7 +131,7 @@ public void verifyOcspWhenCertificateWasRevokedAfterSignDateTest() builder.setCertificateStatus(FACTORY.createRevokedStatus( DateTimeUtil.addDaysToDate(TimeTestUtil.TEST_DATE_TIME, 20), FACTORY.createCRLReason().getKeyCompromise())); - Assert.assertTrue(verifyTest(builder, checkCertFileName, TimeTestUtil.TEST_DATE_TIME)); + Assertions.assertTrue(verifyTest(builder, checkCertFileName, TimeTestUtil.TEST_DATE_TIME)); } @Test @@ -143,7 +142,7 @@ public void invalidUnknownOcspTest01() TestOcspResponseBuilder builder = new TestOcspResponseBuilder(caCert, caPrivateKey); builder.setCertificateStatus(FACTORY.createUnknownStatus()); - Assert.assertFalse(verifyTest(builder)); + Assertions.assertFalse(verifyTest(builder)); } @Test @@ -157,7 +156,7 @@ public void invalidOutdatedOcspTest01() Calendar nextUpdate = DateTimeUtil.addDaysToCalendar(DateTimeUtil.getCalendar(TimeTestUtil.TEST_DATE_TIME), -15); builder.setThisUpdate(thisUpdate); builder.setNextUpdate(nextUpdate); - Assert.assertFalse(verifyTest(builder)); + Assertions.assertFalse(verifyTest(builder)); } @Test @@ -173,7 +172,7 @@ public void validOcspCreatedAfterSignDateTest01() Calendar nextUpdate = DateTimeUtil.addDaysToCalendar(DateTimeUtil.getCalendar(TimeTestUtil.TEST_DATE_TIME), 30); builder.setThisUpdate(thisUpdate); builder.setNextUpdate(nextUpdate); - Assert.assertTrue(verifyTest(builder, checkCertFileName, TimeTestUtil.TEST_DATE_TIME)); + Assertions.assertTrue(verifyTest(builder, checkCertFileName, TimeTestUtil.TEST_DATE_TIME)); } @Test @@ -187,7 +186,7 @@ public void expiredIssuerCertTest01_atValidPeriod() builder.setThisUpdate(thisUpdate); builder.setNextUpdate(nextUpdate); builder.setProducedAt(caCert.getNotBefore()); - Assert.assertTrue(verifyTest(builder, certsSrc + "signCertRsaWithExpiredChain.pem", + Assertions.assertTrue(verifyTest(builder, certsSrc + "signCertRsaWithExpiredChain.pem", DateTimeUtil.addDaysToDate(caCert.getNotAfter(), -1))); } @@ -202,7 +201,7 @@ public void expiredIssuerCertTest01_afterValidPeriod() builder.setThisUpdate(thisUpdate); builder.setNextUpdate(nextUpdate); builder.setProducedAt(DateTimeUtil.addDaysToDate(caCert.getNotAfter(), 1)); - Assert.assertThrows(CertificateExpiredException.class, () -> + Assertions.assertThrows(CertificateExpiredException.class, () -> verifyTest(builder, certsSrc + "signCertRsaWithExpiredChain.pem", DateTimeUtil.addDaysToDate(caCert.getNotAfter(), 1))); } @@ -216,7 +215,7 @@ public void authorizedOCSPResponderTest() throws GeneralSecurityException, IOExc boolean verifyRes = verifyAuthorizedOCSPResponderWithOCSPNoCheckTest(ocspResponderCertStartDate, ocspResponderCertEndDate, checkDate); - Assert.assertTrue(verifyRes); + Assertions.assertTrue(verifyRes); } @Test @@ -228,7 +227,7 @@ public void expiredAuthorizedOCSPResponderTest_atValidPeriod() throws GeneralSec boolean verifyRes = verifyAuthorizedOCSPResponderWithOCSPNoCheckTest(ocspResponderCertStartDate, ocspResponderCertEndDate, checkDate); - Assert.assertTrue(verifyRes); + Assertions.assertTrue(verifyRes); } @Test @@ -237,7 +236,7 @@ public void expiredAuthorizedOCSPResponderTest_afterValidPeriod() { Date ocspResponderCertEndDate = DateTimeUtil.addYearsToDate(TimeTestUtil.TEST_DATE_TIME, -1); Date checkDate = TimeTestUtil.TEST_DATE_TIME; - Assert.assertThrows(CertificateExpiredException.class, () -> verifyAuthorizedOCSPResponderWithOCSPNoCheckTest( + Assertions.assertThrows(CertificateExpiredException.class, () -> verifyAuthorizedOCSPResponderWithOCSPNoCheckTest( ocspResponderCertStartDate, ocspResponderCertEndDate, checkDate) ); } @@ -247,13 +246,13 @@ public void expiredResponderFromRootStoreTestAtValidPeriod() throws GeneralSecur AbstractPKCSException, AbstractOperatorCreationException { Date checkDate = TimeTestUtil.TEST_DATE_TIME; boolean verifyRes = verifyOcspResponseWithResponderFromRootStoreTest(checkDate); - Assert.assertTrue(verifyRes); + Assertions.assertTrue(verifyRes); } @Test public void expiredResponderFromRootStoreTestAfterValidPeriod() { Date checkDate = DateTimeUtil.addDaysToDate(TimeTestUtil.TEST_DATE_TIME, 365 * 100); - Assert.assertThrows(CertificateExpiredException.class, () -> verifyOcspResponseWithResponderFromRootStoreTest( + Assertions.assertThrows(CertificateExpiredException.class, () -> verifyOcspResponseWithResponderFromRootStoreTest( checkDate) ); } @@ -266,7 +265,7 @@ public void authorizedOCSPResponderWithOcspTest() String ocspResponderCertFileName = src + "ocspResponderCertForOcspTest.pem"; boolean verifyRes = verifyOcspResponseWithRevocationCheckTest(rootCertFileName, checkCertFileName, ocspResponderCertFileName, true, false); - Assert.assertTrue(verifyRes); + Assertions.assertTrue(verifyRes); } @Test @@ -278,7 +277,7 @@ public void authorizedOCSPResponderWithOcspRevokedStatusTest() String ocspResponderCertFileName = src + "ocspResponderCertForOcspTest.pem"; boolean verifyRes = verifyOcspResponseWithRevocationCheckTest(rootCertFileName, checkCertFileName, ocspResponderCertFileName, true, true); - Assert.assertTrue(verifyRes); + Assertions.assertTrue(verifyRes); } @Test @@ -289,7 +288,7 @@ public void authorizedOCSPResponderWithCrlTest() throws GeneralSecurityException String ocspResponderCertFileName = src + "ocspResponderCertForCrlTest.pem"; boolean verifyRes = verifyOcspResponseWithRevocationCheckTest(rootCertFileName, checkCertFileName, ocspResponderCertFileName, false, false); - Assert.assertTrue(verifyRes); + Assertions.assertTrue(verifyRes); } @Test @@ -298,7 +297,7 @@ public void authorizedOCSPResponderWithoutRevocationDataTest() { Date ocspResponderCertEndDate = DateTimeUtil.addDaysToDate(ocspResponderCertStartDate, 365 * 100); Date checkDate = TimeTestUtil.TEST_DATE_TIME; - Assert.assertThrows(VerificationException.class, () -> verifyAuthorizedOCSPResponderCheckRevDataTest + Assertions.assertThrows(VerificationException.class, () -> verifyAuthorizedOCSPResponderCheckRevDataTest (ocspResponderCertStartDate, ocspResponderCertEndDate, checkDate)); } @@ -308,7 +307,7 @@ public void authorizedOCSPResponderSetResponderOcspsTest() throws AbstractOperat Date ocspResponderCertEndDate = DateTimeUtil.addDaysToDate(ocspResponderCertStartDate, 365 * 100); Date checkDate = DateTimeUtil.addDaysToDate(TimeTestUtil.TEST_DATE_TIME, 365 * 20); - Assert.assertTrue(verifyAuthorizedOCSPResponderWithProvidedOcspsTest(ocspResponderCertStartDate, + Assertions.assertTrue(verifyAuthorizedOCSPResponderWithProvidedOcspsTest(ocspResponderCertStartDate, ocspResponderCertEndDate, checkDate)); } @@ -318,7 +317,7 @@ public void authorizedOCSPResponderSetResponderCrlsTest() throws AbstractOperato Date ocspResponderCertEndDate = DateTimeUtil.addDaysToDate(ocspResponderCertStartDate, 365 * 100); Date checkDate = DateTimeUtil.addDaysToDate(TimeTestUtil.TEST_DATE_TIME, 365 * 20); - Assert.assertTrue(verifyAuthorizedOCSPResponderWithProvidedCrlsTest(ocspResponderCertStartDate, + Assertions.assertTrue(verifyAuthorizedOCSPResponderWithProvidedCrlsTest(ocspResponderCertStartDate, ocspResponderCertEndDate, checkDate)); } @@ -326,21 +325,21 @@ public void authorizedOCSPResponderSetResponderCrlsTest() throws AbstractOperato public void ocspResponseCouldNotBeVerifiedTest() throws CertificateException, IOException { X509Certificate wrongCert = (X509Certificate) PemFileHelper.readFirstChain(certsSrc + "intermediateExpiredCert.pem")[0]; - Assert.assertThrows(VerificationException.class, () -> + Assertions.assertThrows(VerificationException.class, () -> verifyOcspResponseWithoutResponderAvailableTest(new IX509CertificateHolder[] {FACTORY.createJcaX509CertificateHolder(wrongCert)})); } @Test public void ocspResponseWithoutCertsCouldNotBeVerifiedTest() { - Assert.assertThrows(VerificationException.class, () -> + Assertions.assertThrows(VerificationException.class, () -> verifyOcspResponseWithoutResponderAvailableTest(new IX509CertificateHolder[0])); } @Test public void getOcspResponseNullTest() { OCSPVerifier verifier = new OCSPVerifier(null, null); - Assert.assertNull(verifier.getOcspResponse(null, null)); + Assertions.assertNull(verifier.getOcspResponse(null, null)); } @Test @@ -348,7 +347,7 @@ public void certificateDoesNotVerifyWithSuppliedKeyTest() { String rootCertFileName = src + "rootCertForCrlTest.pem"; String checkCertFileName = src + "signCertForCrlTest.pem"; String ocspResponderCertFileName = src + "ocspResponderCertForOcspTest.pem"; - Assert.assertThrows(SignatureException.class, () -> + Assertions.assertThrows(SignatureException.class, () -> verifyOcspResponseWithRevocationCheckTest(rootCertFileName, checkCertFileName, ocspResponderCertFileName, true, false)); } @@ -375,7 +374,7 @@ public void issuersDoesNotMatchTest() FACTORY.createASN1Primitive(ocspClient.getEncoded(checkCert, caCert, null)))); OCSPVerifier ocspVerifier = new OCSPVerifier(null, null); - Assert.assertFalse(ocspVerifier.verify(basicOCSPResp, checkCert, wrongCaCert, checkDate)); + Assertions.assertFalse(ocspVerifier.verify(basicOCSPResp, checkCert, wrongCaCert, checkDate)); } @Test @@ -403,7 +402,7 @@ public void checkBothOnlineAndProvidedOcspsTest() OCSPVerifier ocspVerifier = new CustomOCSPVerifier(null, Collections.singletonList(basicOCSPResp)); ocspVerifier.setRootStore(PemFileHelper.initStore(ocspResponderCertFileName, password, FACTORY.getProvider())); - Assert.assertTrue(ocspVerifier.verify(checkCert, caCert, checkDate).get(0).toString() + Assertions.assertTrue(ocspVerifier.verify(checkCert, caCert, checkDate).get(0).toString() .contains("Valid OCSPs Found: 2 (1 online)")); } @@ -429,7 +428,7 @@ public void authorizedOCSPResponderCreatedAfterSignDateTest() FACTORY.createASN1Primitive(ocspClient.getEncoded(checkCert, caCert, null)))); OCSPVerifier ocspVerifier = new OCSPVerifier(null, null); - Assert.assertTrue(ocspVerifier.verify(basicOCSPResp, checkCert, caCert, checkDate)); + Assertions.assertTrue(ocspVerifier.verify(basicOCSPResp, checkCert, caCert, checkDate)); } private boolean verifyTest(TestOcspResponseBuilder rootRsaOcspBuilder) throws IOException, GeneralSecurityException { diff --git a/sign/src/test/java/com/itextpdf/signatures/verify/pdfinsecurity/IncrementalSavingAttackTest.java b/sign/src/test/java/com/itextpdf/signatures/verify/pdfinsecurity/IncrementalSavingAttackTest.java index 743b73548d..8cec7c018b 100644 --- a/sign/src/test/java/com/itextpdf/signatures/verify/pdfinsecurity/IncrementalSavingAttackTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/verify/pdfinsecurity/IncrementalSavingAttackTest.java @@ -33,29 +33,28 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.BouncyCastleIntegrationTest; import java.io.IOException; import java.io.InputStream; import java.security.GeneralSecurityException; import java.security.Security; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(BouncyCastleIntegrationTest.class) +@Tag("BouncyCastleIntegrationTest") public class IncrementalSavingAttackTest extends ExtendedITextTest { private static final IBouncyCastleFactory FACTORY = BouncyCastleFactoryCreator.getFactory(); private static final String sourceFolder = "./src/test/resources/com/itextpdf/signatures/verify/pdfinsecurity/IncrementalSavingAttackTest/"; - @BeforeClass + @BeforeAll public static void before() { Security.addProvider(FACTORY.getProvider()); } @Test - @LogMessages(messages = @LogMessage(messageTemplate = IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT)) + @LogMessages(messages = @LogMessage(messageTemplate = IoLogMessageConstant.XREF_ERROR_WHILE_READING_TABLE_WILL_BE_REBUILT_WITH_CAUSE)) public void testISA03() throws IOException, GeneralSecurityException { String filePath = sourceFolder + "isa-3.pdf"; String signatureName = "Signature1"; @@ -63,8 +62,8 @@ public void testISA03() throws IOException, GeneralSecurityException { PdfDocument document = new PdfDocument(new PdfReader(filePath)); SignatureUtil sigUtil = new SignatureUtil(document); PdfPKCS7 pdfPKCS7 = sigUtil.readSignatureData(signatureName); - Assert.assertTrue(pdfPKCS7.verifySignatureIntegrityAndAuthenticity()); - Assert.assertFalse(sigUtil.signatureCoversWholeDocument(signatureName)); + Assertions.assertTrue(pdfPKCS7.verifySignatureIntegrityAndAuthenticity()); + Assertions.assertFalse(sigUtil.signatureCoversWholeDocument(signatureName)); document.close(); } @@ -76,25 +75,25 @@ public void testISAValidPdf() throws IOException, GeneralSecurityException { PdfDocument document = new PdfDocument(new PdfReader(filePath)); SignatureUtil sigUtil = new SignatureUtil(document); PdfPKCS7 pdfPKCS7 = sigUtil.readSignatureData(signatureName); - Assert.assertTrue(pdfPKCS7.verifySignatureIntegrityAndAuthenticity()); - Assert.assertFalse(sigUtil.signatureCoversWholeDocument(signatureName)); + Assertions.assertTrue(pdfPKCS7.verifySignatureIntegrityAndAuthenticity()); + Assertions.assertFalse(sigUtil.signatureCoversWholeDocument(signatureName)); String textFromPage = PdfTextExtractor.getTextFromPage(document.getPage(1)); // We are working with the latest revision of the document, that's why we should get amended page text. // However Signature shall be marked as not covering the complete document, indicating its invalidity // for the current revision. - Assert.assertEquals("This is manipulated malicious text, ha-ha!", textFromPage); + Assertions.assertEquals("This is manipulated malicious text, ha-ha!", textFromPage); - Assert.assertEquals(2, sigUtil.getTotalRevisions()); - Assert.assertEquals(1, sigUtil.getRevision(signatureName)); + Assertions.assertEquals(2, sigUtil.getTotalRevisions()); + Assertions.assertEquals(1, sigUtil.getRevision(signatureName)); InputStream sigInputStream = sigUtil.extractRevision(signatureName); PdfDocument sigRevDocument = new PdfDocument(new PdfReader(sigInputStream)); SignatureUtil sigRevUtil = new SignatureUtil(sigRevDocument); PdfPKCS7 sigRevSignatureData = sigRevUtil.readSignatureData(signatureName); - Assert.assertTrue(sigRevSignatureData.verifySignatureIntegrityAndAuthenticity()); - Assert.assertTrue(sigRevUtil.signatureCoversWholeDocument(signatureName)); + Assertions.assertTrue(sigRevSignatureData.verifySignatureIntegrityAndAuthenticity()); + Assertions.assertTrue(sigRevUtil.signatureCoversWholeDocument(signatureName)); sigRevDocument.close(); document.close(); diff --git a/sign/src/test/java/com/itextpdf/signatures/verify/pdfinsecurity/SignatureWrappingAttackTest.java b/sign/src/test/java/com/itextpdf/signatures/verify/pdfinsecurity/SignatureWrappingAttackTest.java index 346277eac6..790c90e6f5 100644 --- a/sign/src/test/java/com/itextpdf/signatures/verify/pdfinsecurity/SignatureWrappingAttackTest.java +++ b/sign/src/test/java/com/itextpdf/signatures/verify/pdfinsecurity/SignatureWrappingAttackTest.java @@ -29,22 +29,21 @@ This file is part of the iText (R) project. import com.itextpdf.signatures.PdfPKCS7; import com.itextpdf.signatures.SignatureUtil; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.BouncyCastleIntegrationTest; import java.io.IOException; import java.security.GeneralSecurityException; import java.security.Security; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(BouncyCastleIntegrationTest.class) +@Tag("BouncyCastleIntegrationTest") public class SignatureWrappingAttackTest extends ExtendedITextTest { private static final IBouncyCastleFactory FACTORY = BouncyCastleFactoryCreator.getFactory(); private static final String sourceFolder = "./src/test/resources/com/itextpdf/signatures/verify/pdfinsecurity/SignatureWrappingAttackTest/"; - @BeforeClass + @BeforeAll public static void before() { Security.addProvider(FACTORY.getProvider()); } @@ -57,8 +56,8 @@ public void testSWA01() throws IOException, GeneralSecurityException { PdfDocument document = new PdfDocument(new PdfReader(filePath)); SignatureUtil sigUtil = new SignatureUtil(document); PdfPKCS7 pdfPKCS7 = sigUtil.readSignatureData(signatureName); - Assert.assertTrue(pdfPKCS7.verifySignatureIntegrityAndAuthenticity()); - Assert.assertFalse(sigUtil.signatureCoversWholeDocument(signatureName)); + Assertions.assertTrue(pdfPKCS7.verifySignatureIntegrityAndAuthenticity()); + Assertions.assertFalse(sigUtil.signatureCoversWholeDocument(signatureName)); document.close(); } } diff --git a/sign/src/test/resources/com/itextpdf/signatures/SignatureUtilTest/eolNotIncludedIntoByteRange1.pdf b/sign/src/test/resources/com/itextpdf/signatures/SignatureUtilTest/eolNotIncludedIntoByteRange1.pdf new file mode 100644 index 0000000000..93b89a4fc1 Binary files /dev/null and b/sign/src/test/resources/com/itextpdf/signatures/SignatureUtilTest/eolNotIncludedIntoByteRange1.pdf differ diff --git a/sign/src/test/resources/com/itextpdf/signatures/sign/PadesSignatureLevelTest/cmp_padesSignatureLevelBTest01.pdf b/sign/src/test/resources/com/itextpdf/signatures/SignatureUtilTest/eolNotIncludedIntoByteRange2.pdf similarity index 68% rename from sign/src/test/resources/com/itextpdf/signatures/sign/PadesSignatureLevelTest/cmp_padesSignatureLevelBTest01.pdf rename to sign/src/test/resources/com/itextpdf/signatures/SignatureUtilTest/eolNotIncludedIntoByteRange2.pdf index 83eb59250e..fa22db2c24 100644 Binary files a/sign/src/test/resources/com/itextpdf/signatures/sign/PadesSignatureLevelTest/cmp_padesSignatureLevelBTest01.pdf and b/sign/src/test/resources/com/itextpdf/signatures/SignatureUtilTest/eolNotIncludedIntoByteRange2.pdf differ diff --git a/sign/src/test/resources/com/itextpdf/signatures/SignatureUtilTest/eolNotIncludedIntoByteRange3.pdf b/sign/src/test/resources/com/itextpdf/signatures/SignatureUtilTest/eolNotIncludedIntoByteRange3.pdf new file mode 100644 index 0000000000..3e2afa6cbe Binary files /dev/null and b/sign/src/test/resources/com/itextpdf/signatures/SignatureUtilTest/eolNotIncludedIntoByteRange3.pdf differ diff --git a/sign/src/test/resources/com/itextpdf/signatures/mac/ReadSignedMacProtectedDocumentTest/cmp_updateSignedMacProtectedDocumentTest.pdf b/sign/src/test/resources/com/itextpdf/signatures/mac/ReadSignedMacProtectedDocumentTest/cmp_updateSignedMacProtectedDocumentTest.pdf new file mode 100644 index 0000000000..7df7decda8 Binary files /dev/null and b/sign/src/test/resources/com/itextpdf/signatures/mac/ReadSignedMacProtectedDocumentTest/cmp_updateSignedMacProtectedDocumentTest.pdf differ diff --git a/sign/src/test/resources/com/itextpdf/signatures/mac/ReadSignedMacProtectedDocumentTest/signedMacProtectedInvalidDoc.pdf b/sign/src/test/resources/com/itextpdf/signatures/mac/ReadSignedMacProtectedDocumentTest/signedMacProtectedInvalidDoc.pdf new file mode 100644 index 0000000000..9b46b247b0 Binary files /dev/null and b/sign/src/test/resources/com/itextpdf/signatures/mac/ReadSignedMacProtectedDocumentTest/signedMacProtectedInvalidDoc.pdf differ diff --git a/sign/src/test/resources/com/itextpdf/signatures/mac/ReadSignedMacProtectedDocumentTest/thirdPartyMacProtectedAndSignedDocument.pdf b/sign/src/test/resources/com/itextpdf/signatures/mac/ReadSignedMacProtectedDocumentTest/thirdPartyMacProtectedAndSignedDocument.pdf new file mode 100644 index 0000000000..e0b03c2b7b Binary files /dev/null and b/sign/src/test/resources/com/itextpdf/signatures/mac/ReadSignedMacProtectedDocumentTest/thirdPartyMacProtectedAndSignedDocument.pdf differ diff --git a/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/certs/SHA256withRSA.cer b/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/certs/SHA256withRSA.cer new file mode 100644 index 0000000000..fbaad2b382 Binary files /dev/null and b/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/certs/SHA256withRSA.cer differ diff --git a/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/certs/SHA256withRSA.key b/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/certs/SHA256withRSA.key new file mode 100644 index 0000000000..d7e9b5e825 --- /dev/null +++ b/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/certs/SHA256withRSA.key @@ -0,0 +1,51 @@ +-----BEGIN ENCRYPTED PRIVATE KEY----- +MIIFNTBfBgkqhkiG9w0BBQ0wUjAxBgkqhkiG9w0BBQwwJAQQdOaEUfD0sZWtUR11 +xwgn0gICCAAwDAYIKoZIhvcNAgkFADAdBglghkgBZQMEASoEEBaNXSfwUjF5SS7n +ce1JFoUEggTQ6eV+IsckiVP7I9VTldLkpP5OKB8brmw5t20fO11HyCnqkkhooR2b +t2fBj4fWv0IRUe266L+fVs7AOngjkWfezEvGR6nte4pNXEFrOwt/U8A6IYZXBdA5 +dvqs6VMPHbjQ8CufVLGvksuYFQVRcGy0rk1DH2Of44GU4X0GtROlFFJnkmfZhVPS +Hx2MXXGQ02Ko1i1eKoEGgvmSAsDcPijiX96DKlQZJ4YMtI/8rRsdvNJsJ2beyZDa +T3aJMmSSBF92mS2dtS21DwjzEu8utquguYA0KYzjZM9onOuBEEUifam8Fjnvlui6 +beQJya4zldoA6QZPSd2PUAP6l1U/d8UXqcisjzArDZDmRu58dPxn4rs0NgTOIO8h +fEUIvfS+wuknff1b/wdGnwXkXoeSrrjS9dhP9KVU1SJ/FWKc6BY+P+JmE5vLjAtn +AmbyZhXY0jX7ZHFh0z0y1y1fTIXL1aj4iB+cUwhJ1ZdlGkT5HdG4ts/oTGCnpB6O +F1GvGyhprmtjp/dspLH5ha0I+4aTn46yFpnBNyg8w9c2+xj8Jiqy9J/ppVtPdhxt +wrE1/ThUGIWUTsbGbLW87WIrZq6IlSGtztbxAMYxXoe4solYueE3pI3eYFzgnBcq +T6Byktr71gt9AGD/N/p+Kk5RM4JT8XpQjLjz9TlmsGpJzUoBGeG6KFLsqqLLSD+0 +c5lAGWsFhec3uCu4fCyBqxpQc0y5j2bgUiTRGYn1NOdyZg+ERO/aWGfkDOAtlL1i +B79NGIBxIXgt508g83UeaQC6KjuG/8hPY6UHmU5mlgRT9H5jvkSX3mEtl1Gdk2y0 +M5pZTTrhbG4p66GhBi8vM5tQfiBoLUKEM/kgiGXPC6Kob42nb3ufP0rmnKklcDGC ++898hW5ge+VNmOkHpVuV5ZD9aWUSVEU4+8QNZj8pcyL0GXFyEL/HxNxUESdz3k0S +bInuxO49mgGPjBqtx5ZvaxyWFnzOp6rmHZUHymejxxdnlnTnSnXKkJFjcm7n0sKO +575ofHtk0OdqIK6YiPgfeF6nZkIg3C0PbReZ05kTplrW182ZWuQQyJgv+RPzF4+9 +5rCe67nJhJrt7hXFRsUScHXNj+HF9Av8WR2RnHTRbpQBJszijM+Xgl+VeYcY5ckB +fk+AfcR9r0Jud4O9795OOWVxWqGVu/b1RGonfjMkGW+JdnZL0vkOYYcHt4iMZmzW +M0ZowZPGO5dFBV7/ZkVzb0fexw+f+E0lUBEK1cx0gxnzjmcGJO+C9if1uIEfwpon +3wBOTDsU7XKDx9v6ibcDMOXrZa+rcJWxgNkXt5nRpozZkddYctBkehGu+snV2g4n +SdOwr0eIVv/L+v4IywZmeWWEVnbSAvB0p7nB89bgLMr9tV0ly7MWxPH+gPnNJ1gE +7Mp3AgN5BxEmLfW3+ou3QLoqnOS2MCw/xcgLP0nJACSPI7/nWy95iKXKgkCkAgF9 +4Ztk7uBG4tiK14KcKq8ToCW2YNliT3g0CWjBLtVPUS6qboudMiuedxTxE8WEirpT +A77nfDNg4MVjl4kP9jhV0Phpn9rDMJ2jw0BqFc1Vou4aNDXYandAFJea44Wce9H+ +qAowcrfsWehD01HBQ2KwWVg3sLnwwBHw0nvbATS41hdxsP2OmCnxWkc= +-----END ENCRYPTED PRIVATE KEY----- +-----BEGIN CERTIFICATE----- +MIIDfzCCAmegAwIBAgIEUFic9zANBgkqhkiG9w0BAQsFADBvMQswCQYDVQQGEwJU +UzETMBEGA1UECBMKVGVzdCBTdGF0ZTESMBAGA1UEBxMJVGVzdCBUb3duMREwDwYD +VQQKEwhUZXN0IG9yZzEQMA4GA1UECxMHVGVzdCBPVTESMBAGA1UEAxMJVGVzdCBV +c2VyMCAXDTE0MDkyMjA5MTExMVoYDzIxMTQwODI5MDkxMTExWjBvMQswCQYDVQQG +EwJUUzETMBEGA1UECBMKVGVzdCBTdGF0ZTESMBAGA1UEBxMJVGVzdCBUb3duMREw +DwYDVQQKEwhUZXN0IG9yZzEQMA4GA1UECxMHVGVzdCBPVTESMBAGA1UEAxMJVGVz +dCBVc2VyMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA+6g5sYzXiNOA +hR7C8wc8buxU/JgcbdHpHIR44iuXjpepBYAE7hRsWM7H4cuXrKiRxS9UMOadqkGF +Qqb5sG6lo2UUhcj4qlN6hKDc/+AMZMIW1mvQldiygCAkqgM8iso+kw56dpVuerG/ +k1nd8f+X9rjXN6/DIMznZcMy2d9ByIFuixFKElPvOWx9q9N4aiueOd5FM5eHxp+3 +F4uCTrpM5zkS7Rmf5GVtCofc8KgaTLLp4D0Ge5VUJm7yW8fuU3eIpin4ivjk+Gye +Q3t0BsrmNyQy3CmKGOBP/vX0+wEMvGN2xqNgAFP9dxA+AbJMiAfsmoWvxXaPktqC +DOspTCFqbwIDAQABoyEwHzAdBgNVHQ4EFgQUILviRCmSrhuLDmF0nus4pv2uu7gw +DQYJKoZIhvcNAQELBQADggEBAGnfGYL7nDm5taDPRxuGGMqUPwRnH2bXwef6S2Xb +/nIEFtNheVFQFtKNn5Ikq68DTFMP06yXLnI7F40+ZiQezRBB1EPPmDL2fYKc9fL1 +SHntu6HLgP/Y5nnCVegtL8l9745gQZnnXlMtkTs2HFwffznIHW/3STO0Bcj0+KMa +p8vebMjmvV7bZEGvrcrVXL55QPZXJwRuQMXJB3f5XhAEH1VqAhTW6DrvBUnuESwo +9fxxA5gmblt80SQYdKr2I08OTk0qmyF8zNuffTOiSS8/V6Cf7CntuPWjSuVf1EVP +MH6KkSjceLZ99Y7bvl7KKvQ4Kj5Bp27PwlRvtYbfCUmQEG8= +-----END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/certs/signCertRsa01.pem b/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/certs/signCertRsa01.pem new file mode 100644 index 0000000000..5f2f1f25a8 --- /dev/null +++ b/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/certs/signCertRsa01.pem @@ -0,0 +1,76 @@ +-----BEGIN ENCRYPTED PRIVATE KEY----- +MIIFNTBfBgkqhkiG9w0BBQ0wUjAxBgkqhkiG9w0BBQwwJAQQgLsVp4wmljjCRgEy +kw2LWgICCAAwDAYIKoZIhvcNAgkFADAdBglghkgBZQMEASoEELyxbQ1T8vAMXX6t +md0GgdwEggTQXjePuN2mrJ4C7uFP/ErLys5cwO7QSOL5z7jUUep96YkZgMjau99o +6JolOHyJRzDbUNbTCfku8PqwDfdPrCPfMZ+e9UU/Y5uVZbEL+UtIkcH/uyFCd1k7 +AVOhAux7KZwgHlq66iUHqTQFd58Ly7KOoMKGZS07CtIxjYluFZZbx44EZrgqRwEa +ZAbIsdR2xZ092Who4CzkuF31m2TuyzfYir7kocJsdQU6k9OdptfJRda2UpZiUXW8 +GMg/qvF7RwkAbfu7gLkcmc5FETlY+E3P8tYDutN737wnd/VqO9Bd25umOAl3CHUA +5+YSXvWOSuAJjz7kEI2DEG/ov//oO0wohJPLKRF7jUI2WbIwCAypPZPvSS506ulO +ofuLTY0+Jii0ZO5SyC4Uu90lh8RISvi9RzRx2G4sN+gyeCBBg1R1f5IRNeBImpEw +aKqk4VrcUrLe623Z3el1Z8ErJBJ6G0ZV/EAFC7dmpTknrVOFzdO6sohtnHygm0Ce +h5QdqiWvb0QKHv3GZumdtCcdh8vPMRT1PEWVvfV/cyIOc5BH6sYNtxiohosl6DLz +I84vj3n8I+cFHrYIFCtghy9iZJ0GvvPxaiJCS5A+eDiOO3rhk3ZMkmTlVCpOBiY2 +QKdljhmRaN1Y6XfQ8SRNmr/qVfwFJ4JgYnk3VVHVvzt0EvEImNusOvTH2U4zMryP +FRhgGNIL0f5gflo2LxSPqsnqNfJLRHCmXkYeB4Pu8/xv6biFqtwC2UBaL7FCjIgY +NI+hi9Mt9fJpYqF4XGHcT2b6Aq7otgxX+5iiQg10bEjqI/gcZrFvBvmz/97OBe7X +BFa5F8nYeSxnr5XQiJ04oBVBjdvAFeS7ZZ4Quq2beEgcgCj7EU/OXLLHwBCCmD8s +8kgkhsv7+sPtNnC1YeoW6xHezt/FSDYxS1lPWsnr4AE4jpxOJgM8CNSDq0E52e83 +2uDNm3gIo133RRn9V8gNQzfIJv1BZFRUtOn9CRxrJBTptSxUJX1at+btTM7hlY2z +MwXM5i7ZGDVQOPSpKrlbmA8bHDRHeGryXz0HNWs5RWiTVSEhCuVTrrlQG4nmbhVm +b6xbd/DWs3NdEXwLLdg1W+fbeS2qIJtJqu0LU+PcGkhaVXeobc6MFGw06hDVtVg9 +Hm1/AZJ4OuD/+GyH9ku4Z9tPDh4NmXsVVV8CpzxRJ37gLrGPwbxXwW3v6B6NBRvz +W8KuWQjlNDxVcFb9Si7Mj81xX2k1818hwSm3iEQIwT0Q7BNUj3oJhTsNlB/Id79J +tl7AKam1ofDZVmU7gPcv0FPKxhEZIyjoqeAzLGuW1Hmp45HbJ94tL2uvbgPq2Mj7 +j4jllaPoN9J1QBVDHBqEzLZGeWKZYK2L9Sw4SdkZjLp96hxoQ7MYvTrsX4eSV0HH +xMLp5hhIiM8zGIsMYlwcfOSpQh/H1AnbiQIJ0/tzO6uBZ73fq59rTReRf+PtXqqT +5vg89nN6kNvJcrwNLyEhdC7uaqsoimTMi59BE36ZZcL0jHKMmPl9g/vbPj9CiRdu +B0+4lQD0hAqK6FVfl6ENpj4zLdU6/EER5L7v+Syv8d5AeFtdKrqxH3oCGPXmXCol +j2rALoIlZt0D+jjmcDo6C32qtu8w40zBD/+J8iZXVWC/U9cauP00N9E= +-----END ENCRYPTED PRIVATE KEY----- +-----BEGIN CERTIFICATE----- +MIID6TCCAtGgAwIBAgIEWOew7DANBgkqhkiG9w0BAQsFADBUMQswCQYDVQQGEwJC +WTEOMAwGA1UEBwwFTWluc2sxDjAMBgNVBAoMBWlUZXh0MQ0wCwYDVQQLDAR0ZXN0 +MRYwFAYDVQQDDA1pVGV4dFRlc3RSb290MCAXDTE3MDQwNzE1MzM0MFoYDzIxMTcw +NDA3MTUzMzQwWjBZMQswCQYDVQQGEwJCWTEOMAwGA1UEBwwFTWluc2sxDjAMBgNV +BAoMBWlUZXh0MQ0wCwYDVQQLDAR0ZXN0MRswGQYDVQQDDBJpVGV4dFRlc3RSc2FD +ZXJ0MDEwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCfr2PnZ6DjvrSY +g0cWtDR6drgvCowB5hQH7CHSAMTeVGZxUOBT1ylfxySioRU4ckq3uQu7jOe7Te6Y +xEenjFhTv8bT0/ZrL2w6OGBH4iUs3Kwx5jzbRHPuZt7+gCKLBXhRH6ytDnbTHNgT +4tjGXUmGa4sMbal1mXvKN/xaK+hGDskRW6cHZq7ZtdgfM8yBQWZzshAz7dQepmUH +ZYWxplTwJ8cuVLqjgXMXWfTatio6yYwf+5AkWszBcCA6oxm16wN2pLUeNx5aBLiF +Dhtj6qqHLwN/7tPb0ojqXRU3AfocC2y8a4WeVOOp2du0ja4E9P7IQNKiBBlOfNcF +D700qPFpAgMBAAGjgbswgbgwCQYDVR0TBAIwADB/BgNVHSMEeDB2gBRdKnF1rt3Y +vlm6ILFmkcl2NlNc7qFYpFYwVDELMAkGA1UEBhMCQlkxDjAMBgNVBAcMBU1pbnNr +MQ4wDAYDVQQKDAVpVGV4dDENMAsGA1UECwwEdGVzdDEWMBQGA1UEAwwNaVRleHRU +ZXN0Um9vdIIEWOeR1jAdBgNVHQ4EFgQUz41Jo8H/HAqxhMN/inuhKuLZU8gwCwYD +VR0PBAQDAgXgMA0GCSqGSIb3DQEBCwUAA4IBAQCT597xhkVzrYP7NudRgIZCDwT3 +TDnL+Xv8H4c9p+CdHJtFMoxAQlzcQi4uEIo5nfBKMEXK0d1OnO8zEBfK98EPahUI +++PDnNk82kh64CbZQ95Ms1Usq1XGd31bkXWWRM3LY2P7VG0nR+eLutVAClIcbTLN +yL9ZhiL33jCk1W5PeXJy13kL3XV/Awt8zb9fcinkuXkV5LoZHxh2Ob19R//5fGxH +hnUywReGptnIbEPiWGYyX1QCQeOqi3vmqZaGr+RZfF8+zqtSP5p4gFpryuTJxkcZ +UOeroaBv3sHCI9rtzcwZPYsW0BroFliEhNIDq5HxJgdwdu6uDOMMrC2QxB17 +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIID6jCCAtKgAwIBAgIEWOeR1jANBgkqhkiG9w0BAQsFADBUMQswCQYDVQQGEwJC +WTEOMAwGA1UEBwwFTWluc2sxDjAMBgNVBAoMBWlUZXh0MQ0wCwYDVQQLDAR0ZXN0 +MRYwFAYDVQQDDA1pVGV4dFRlc3RSb290MCAXDTE3MDQwNzEzMjAwMVoYDzIxMTcw +NDA3MTMyMDAxWjBUMQswCQYDVQQGEwJCWTEOMAwGA1UEBwwFTWluc2sxDjAMBgNV +BAoMBWlUZXh0MQ0wCwYDVQQLDAR0ZXN0MRYwFAYDVQQDDA1pVGV4dFRlc3RSb290 +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAz/fz7iq1wzhMMYcGfmMm +teCY/ZtdE26PB1OTTBuDSN86sVNmur5FV/mLPU9ZK2ofrs+wMrqn0agmFlRl4dTh +f5u5WSEQ/ARwXzYOn2uEkwR/0dwwZUL3VWhrPSD5SxX5MzFo8UXTNlXW2bClLC0F +QU2qLjIwwRFwwWDSQPR8r/Mv181RljVpEjPk6DfkDtHWWA4daGlQU0nXbuZszplv +iPafXmyKn+2w4G9Jw/8pHIK2VhWYstLI+bUZk662ZVldNvnpMyHn12FfB0Nbf/Z6 +V2WTGviEr8EEE2cA7I+H7ZGUDzug7umNCCJn3ilC6vAt9i9OLaZRDh6jPMOjMUiz +TwIDAQABo4HBMIG+MA8GA1UdEwEB/wQFMAMBAf8wfwYDVR0jBHgwdoAUXSpxda7d +2L5ZuiCxZpHJdjZTXO6hWKRWMFQxCzAJBgNVBAYTAkJZMQ4wDAYDVQQHDAVNaW5z +azEOMAwGA1UECgwFaVRleHQxDTALBgNVBAsMBHRlc3QxFjAUBgNVBAMMDWlUZXh0 +VGVzdFJvb3SCBFjnkdYwHQYDVR0OBBYEFF0qcXWu3di+WbogsWaRyXY2U1zuMAsG +A1UdDwQEAwIB9jANBgkqhkiG9w0BAQsFAAOCAQEAdhby6EaopoUF8j7oR44Mhe/N +3y9hzGb/zLmmgTavPd2plv6NlAPt9W+8rezKO6jQCsBRFw8JY+Lx6j3W0K6rWigB +pPGU/B/0bXLlOIv2a4uW8nBmq6jxAe5Xbtwm8HcKOOLMzxPIChHJIJy5NWw9ArD4 +Ul+FEt/VuEW1NfPZm1U5ixMOrBfn0C8pxIX4+VSHN9I8WoFjSfYX4Y3ldRLTeqxQ +rhZQlbhGNymp3Kcvtuq5At6vopskyB8Q1b7L4e+hRWK2prz/7p4Bdhu2TmkEfWZc +YKpgrkVFqa/Z1uZ0q4KVBOP3cyaQmqRXTV37SfpNyHAJdol5ueF68VVVNZFRXw== +-----END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/certs/tsaCert.pem b/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/certs/tsaCert.pem new file mode 100644 index 0000000000..173990cb2f --- /dev/null +++ b/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/certs/tsaCert.pem @@ -0,0 +1,56 @@ +-----BEGIN ENCRYPTED PRIVATE KEY----- +MIIFNTBfBgkqhkiG9w0BBQ0wUjAxBgkqhkiG9w0BBQwwJAQQC6J4wXR/ZAEc5RnK +8VKKvAICCAAwDAYIKoZIhvcNAgkFADAdBglghkgBZQMEAQIEEIH5lyIZUGdzvVqX +cvANBXUEggTQ4IqSPz58RZzYvimG3BoBJ9353e5H7UQlNi2OurPPLykLLHEY/gGd +c2n2hUZTXxPvmYXQkVoGhsUg59SQRjlhkeGyrrlkkjpmzYAjOMNF9YAwdoXVdA2H +lzOd4yYG+fUCfYma5pMXaqLBOUmB5l+nfBCvYM3hy6U5mnP2ZybR1GpYxkWJAGbG +b+0dz96EUjRPTuPhH8VBW1W0F0asBCTkEDOKAIfrxt6cD3kcnko1WK7wteU4Ln5c +wxnrtJTmSaFeHzSQXUTMfpwGe8ImMtUV0z/DS5x0pHmK/V+3MZN+RfdUXwF7LXwL +8J3CrGoIzGWzmHgGqRXuK9Z+Tdumm1MvRJnmBZp6CWM7j7f8iWKXzFJItDLLuaaJ +H4ZEUt5K7fb8JSPCiVovNmnnBaG7ua3n/5aGvym22TOBgelS0e+bee4YELGolU2g +yRNb24+casHZ/kyenHR4dyrxDTZHmPU9bPhzb05l3Vk+PiHJLxAqFtUiP4buSeoh +TPVYQXAE8EPInwyZxzYvWeSN1JSU3hdOpj+hVnZHoUxGYzZbatVzuJ+MQ3BW3z4g +PfoR3QfTjNNvB+zRp/rveBhbEf7tbvQrFSeQb0Dlta08+LDec6kKA10fzFMtlJcp +IrrH0Zafke95r1bNbqGZrMWSUdBKB2IS2PY/Q8ITGnB/RxIfE7odDVgFnrxrrhf8 +GRErkP1w9xz/+cBw6OeobGPK9ED/jAnOUpAXo22Jl/BsBt7SLTr4h+O3pV3ft79z +J9cOcWAHQy5BknIdahA88bMBnrA/NfHgWhKv1AaD4ICwydMWfxpqelzOiNF+LDq9 +D2fTR9SLiOkHpWgk7NJZAqkZRKrs1MHf9yuq0NDEIojqcQN+rK8O8DiT64XZuSqH +P84jatubXoXbulfRxC+6RkMpuJRjr/N9DNWNj6A61uquPLs9XgVlZNp4ND3tTDaa +tiM45qjxJWjcnI4zm4BtVYTrrU0z7kL2F/rBJEENCYAK5pWgAYA2t44on+k6sLYN +8Fp+J8t22H4v/ssfXUUk3oi7cP66chSNDyPNgWw1GnYqDVogI0bX6+Cx8t7/G9t7 +bWJZxhrgXC1yQeC4FrBfYE8j2m7qRMeINeU/jqdiwbCHlhoMmbMLDKFK9LW4A5mK +VMiLbF1zPnxY4ZxR5MxMJSnODf0RQWgsPX3Vno1pQfJ+1Jjy2m1gKUxqbIevux8Q +QMcRqrx5Mm1d0aztEoygShnkCjhf0yvkFZGyj1J0abgbstPaaOCR/BPMyyhh9znn +5FOViSg204d8j3oJdp/xuxJFJE8+vyB5baA0vudQIQ7+23tA9Fw3dE9Pszm4w8so +jhz1wv/8BoxLQ/4PZcKbQ+MSCzGnse6vlHaV3hXO1SEdN69LCIf65AYYvrdFmv48 +gU5bbYcJRYVdni3tZB7Lht1tmAjgZi+0dn6ApyLAeaaGiov1i622bhSe2REpUCRz +NbdSUl+3lAzNiLxPpR8cTscwf+ow4OEfChNAOzyaUvRdNTolcEhVwox0CUj0ELFE +XS9mK+XZEWJ+fiOGiKoUKDY2sdKRl4stucyah61RQUf/cPL4EmSFhB7i8lD6nyb5 +3cFrNW7nvH+Eu5QzywqGOxTqKJpWXfLTRmNgY+Y6UugnWIfKLcdNMy4= +-----END ENCRYPTED PRIVATE KEY----- +-----BEGIN CERTIFICATE----- +MIIEUjCCAzqgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwQDELMAkGA1UEBhMCQkUx +DjAMBgNVBAoMBWlUZXh0MSEwHwYDVQQDDBhpVGV4dFRlc3RUU0FJbnRlcm1lZGlh +dGUwIBcNMjAwMTAxMDAwMDAwWhgPMjQwMDAxMDEwMDAwMDBaMDgxCzAJBgNVBAYT +AkJFMQ4wDAYDVQQKDAVpVGV4dDEZMBcGA1UEAwwQaVRleHRUZXN0VFNBTGVhZjCC +ASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJ/HVl5COupS9fnTfblPgwSv +nsc7uqqqxKmQ4cqxhl2Xf9rOzFePOZVFlR+A7SW2Ax10x0in10WURwLErpZ47FGq +ytLdIfDIDUb4oBdx2BeToanRQHWEOOLZlb6Z9bEeWLVSWaDRNVSQm+xtBOKB6I6P +5ux7Q4X1115wwFGC0UYumTI5eIjMchWDI6rWcDdi5noA8/qEeQD4894yis5LEy2/ +s0M1OmBnilXxx8urQ0fYXiwf39Uh2yZsgu01urSmnOfVXS3d9+Y9jiJ4CB9w63sa +nbLv7NEB39wjJPrnlyG0bcdCn0mKamJSqdU4RG5nmB1BAH0Wn63IsWQJkjPGrssC +AwEAAaOCAVowggFWMB0GA1UdDgQWBBQVf4Hj+sEkGTEpxe8XFNtQFyGrJDAfBgNV +HSMEGDAWgBS2Vx2D2SIYPmYxGkT9a/4t6i0IaTAOBgNVHQ8BAf8EBAMCBeAwFgYD +VR0lAQH/BAwwCgYIKwYBBQUHAwgwgZ8GCCsGAQUFBwEBBIGSMIGPMD8GCCsGAQUF +BzABhjNodHRwOi8vdGVzdC5leGFtcGxlLmNvbS9leGFtcGxlLWNhL29jc3AvdHNh +LWNhLW9jc3AwTAYIKwYBBQUHMAKGQGh0dHA6Ly90ZXN0LmV4YW1wbGUuY29tL2V4 +YW1wbGUtY2EvY2VydHMvdHNhX2ludGVybWVkaWF0ZS9jYS5jcnQwSgYDVR0fBEMw +QTA/oD2gO4Y5aHR0cDovL3Rlc3QuZXhhbXBsZS5jb20vZXhhbXBsZS1jYS9jcmxz +L2NhLWNybC9sYXRlc3QuY3JsMA0GCSqGSIb3DQEBCwUAA4IBAQAPc81dvV0zZi9P +A4Tpr4nj28DAAPDkjBPiqmeP8FWomG3bF/pTi+vvpO79tR+sKh+38Pn6YwuGsK4d +UVyZ98gTQoTe/x2zviEer0+cdWNVgdTq1MTpiHQNTBN01kggjGdQzZXJNKg9L+Kb +Sw+t9QxzKjRFCUrr4txPxv4O6Yvc3cesM2Dxx0EPsgTqxIbSEliHtXU+K0WBXokw +mzCUXN+ry3iomQkqTIyohySA2dumbaxlxdcQ96pnU8swFwJ5jYEHITbepqDFq6NM +M8ewAFnrtnqqA6GU0thyZSUh4YXphBEkzAKhm2NIye2BXGirzB7DGfhev8kLD+6a +9qBtibHs +-----END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signMacProtectedDocInAppendModeTest_signDetached.pdf b/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signMacProtectedDocInAppendModeTest_signDetached.pdf new file mode 100644 index 0000000000..aa00ed849e Binary files /dev/null and b/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signMacProtectedDocInAppendModeTest_signDetached.pdf differ diff --git a/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signMacProtectedDocInAppendModeTest_signExternalContainerReal.pdf b/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signMacProtectedDocInAppendModeTest_signExternalContainerReal.pdf new file mode 100644 index 0000000000..b3ac6a3dec Binary files /dev/null and b/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signMacProtectedDocInAppendModeTest_signExternalContainerReal.pdf differ diff --git a/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signMacProtectedDocInAppendModeTest_timestamping.pdf b/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signMacProtectedDocInAppendModeTest_timestamping.pdf new file mode 100644 index 0000000000..1b3b253029 Binary files /dev/null and b/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signMacProtectedDocInAppendModeTest_timestamping.pdf differ diff --git a/kernel/src/test/resources/com/itextpdf/kernel/pdf/xobject/GetImageBytesTest/separationCSWithDeviceRgbAsAlternative.tif.png b/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signMacProtectedDocTest_signDetached.pdf similarity index 50% rename from kernel/src/test/resources/com/itextpdf/kernel/pdf/xobject/GetImageBytesTest/separationCSWithDeviceRgbAsAlternative.tif.png rename to sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signMacProtectedDocTest_signDetached.pdf index 9fac666868..e4563ea8d0 100644 Binary files a/kernel/src/test/resources/com/itextpdf/kernel/pdf/xobject/GetImageBytesTest/separationCSWithDeviceRgbAsAlternative.tif.png and b/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signMacProtectedDocTest_signDetached.pdf differ diff --git a/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signMacProtectedDocTest_signExternalContainerReal.pdf b/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signMacProtectedDocTest_signExternalContainerReal.pdf new file mode 100644 index 0000000000..63b2e42a1c Binary files /dev/null and b/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signMacProtectedDocTest_signExternalContainerReal.pdf differ diff --git a/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signMacProtectedDocTest_timestamping.pdf b/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signMacProtectedDocTest_timestamping.pdf new file mode 100644 index 0000000000..d70fe2a288 Binary files /dev/null and b/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signMacProtectedDocTest_timestamping.pdf differ diff --git a/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signMacProtectedDocWithSHA3_384Test_signDetached.pdf b/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signMacProtectedDocWithSHA3_384Test_signDetached.pdf new file mode 100644 index 0000000000..f03b74c3e0 Binary files /dev/null and b/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signMacProtectedDocWithSHA3_384Test_signDetached.pdf differ diff --git a/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signMacProtectedDocWithSHA3_384Test_signExternalContainerReal.pdf b/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signMacProtectedDocWithSHA3_384Test_signExternalContainerReal.pdf new file mode 100644 index 0000000000..d7270a7dd4 Binary files /dev/null and b/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signMacProtectedDocWithSHA3_384Test_signExternalContainerReal.pdf differ diff --git a/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signMacProtectedDocWithSHA3_384Test_timestamping.pdf b/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signMacProtectedDocWithSHA3_384Test_timestamping.pdf new file mode 100644 index 0000000000..18dabc3cc2 Binary files /dev/null and b/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signMacProtectedDocWithSHA3_384Test_timestamping.pdf differ diff --git a/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signMacPublicEncryptionDocTest_signDetached.pdf b/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signMacPublicEncryptionDocTest_signDetached.pdf new file mode 100644 index 0000000000..9a0546801d Binary files /dev/null and b/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signMacPublicEncryptionDocTest_signDetached.pdf differ diff --git a/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signMacPublicEncryptionDocTest_signExternalContainerReal.pdf b/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signMacPublicEncryptionDocTest_signExternalContainerReal.pdf new file mode 100644 index 0000000000..7b140c8a5c Binary files /dev/null and b/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signMacPublicEncryptionDocTest_signExternalContainerReal.pdf differ diff --git a/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signMacPublicEncryptionDocTest_timestamping.pdf b/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signMacPublicEncryptionDocTest_timestamping.pdf new file mode 100644 index 0000000000..c2646c7360 Binary files /dev/null and b/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signMacPublicEncryptionDocTest_timestamping.pdf differ diff --git a/sign/src/test/resources/com/itextpdf/signatures/sign/PadesSigTest/templateForSignDeferred.pdf b/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signNotMacProtectedDoc17Test_signDetached.pdf similarity index 60% rename from sign/src/test/resources/com/itextpdf/signatures/sign/PadesSigTest/templateForSignDeferred.pdf rename to sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signNotMacProtectedDoc17Test_signDetached.pdf index db70f46305..1435110eed 100644 Binary files a/sign/src/test/resources/com/itextpdf/signatures/sign/PadesSigTest/templateForSignDeferred.pdf and b/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signNotMacProtectedDoc17Test_signDetached.pdf differ diff --git a/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signNotMacProtectedDoc17Test_signExternalContainerBlank.pdf b/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signNotMacProtectedDoc17Test_signExternalContainerBlank.pdf new file mode 100644 index 0000000000..79830a83ba Binary files /dev/null and b/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signNotMacProtectedDoc17Test_signExternalContainerBlank.pdf differ diff --git a/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signNotMacProtectedDoc17Test_signExternalContainerReal.pdf b/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signNotMacProtectedDoc17Test_signExternalContainerReal.pdf new file mode 100644 index 0000000000..6532a6e0a7 Binary files /dev/null and b/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signNotMacProtectedDoc17Test_signExternalContainerReal.pdf differ diff --git a/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signNotMacProtectedDoc17Test_timestamping.pdf b/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signNotMacProtectedDoc17Test_timestamping.pdf new file mode 100644 index 0000000000..1030884f36 Binary files /dev/null and b/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signNotMacProtectedDoc17Test_timestamping.pdf differ diff --git a/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signNotMacProtectedDocInAppendModeTest_signDetached.pdf b/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signNotMacProtectedDocInAppendModeTest_signDetached.pdf new file mode 100644 index 0000000000..2b1bc1e5d2 Binary files /dev/null and b/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signNotMacProtectedDocInAppendModeTest_signDetached.pdf differ diff --git a/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signNotMacProtectedDocInAppendModeTest_signExternalContainerBlank.pdf b/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signNotMacProtectedDocInAppendModeTest_signExternalContainerBlank.pdf new file mode 100644 index 0000000000..abb3c4610d Binary files /dev/null and b/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signNotMacProtectedDocInAppendModeTest_signExternalContainerBlank.pdf differ diff --git a/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signNotMacProtectedDocInAppendModeTest_signExternalContainerReal.pdf b/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signNotMacProtectedDocInAppendModeTest_signExternalContainerReal.pdf new file mode 100644 index 0000000000..96d972f054 Binary files /dev/null and b/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signNotMacProtectedDocInAppendModeTest_signExternalContainerReal.pdf differ diff --git a/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signNotMacProtectedDocInAppendModeTest_timestamping.pdf b/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signNotMacProtectedDocInAppendModeTest_timestamping.pdf new file mode 100644 index 0000000000..239aa27950 Binary files /dev/null and b/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signNotMacProtectedDocInAppendModeTest_timestamping.pdf differ diff --git a/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signNotMacProtectedDocTest_signDetached.pdf b/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signNotMacProtectedDocTest_signDetached.pdf new file mode 100644 index 0000000000..1ecb485b3d Binary files /dev/null and b/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signNotMacProtectedDocTest_signDetached.pdf differ diff --git a/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signNotMacProtectedDocTest_signExternalContainerReal.pdf b/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signNotMacProtectedDocTest_signExternalContainerReal.pdf new file mode 100644 index 0000000000..baafa3d807 Binary files /dev/null and b/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signNotMacProtectedDocTest_signExternalContainerReal.pdf differ diff --git a/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signNotMacProtectedDocTest_timestamping.pdf b/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signNotMacProtectedDocTest_timestamping.pdf new file mode 100644 index 0000000000..20397bad6c Binary files /dev/null and b/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/cmp_signNotMacProtectedDocTest_timestamping.pdf differ diff --git a/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/macEncryptedDoc.pdf b/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/macEncryptedDoc.pdf new file mode 100644 index 0000000000..f8bffedbdc Binary files /dev/null and b/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/macEncryptedDoc.pdf differ diff --git a/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/macEncryptedDocSHA3_384.pdf b/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/macEncryptedDocSHA3_384.pdf new file mode 100644 index 0000000000..e4dfce5bbe Binary files /dev/null and b/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/macEncryptedDocSHA3_384.pdf differ diff --git a/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/macEncryptedWithPublicHandlerDoc.pdf b/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/macEncryptedWithPublicHandlerDoc.pdf new file mode 100644 index 0000000000..e62dcb8d79 Binary files /dev/null and b/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/macEncryptedWithPublicHandlerDoc.pdf differ diff --git a/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/noMacProtectionDocument.pdf b/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/noMacProtectionDocument.pdf new file mode 100644 index 0000000000..318f529543 Binary files /dev/null and b/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/noMacProtectionDocument.pdf differ diff --git a/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/noMacProtectionDocument_1_7.pdf b/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/noMacProtectionDocument_1_7.pdf new file mode 100644 index 0000000000..db862c7069 Binary files /dev/null and b/sign/src/test/resources/com/itextpdf/signatures/mac/SignedDocumentWithMacTest/noMacProtectionDocument_1_7.pdf differ diff --git a/sign/src/test/resources/com/itextpdf/signatures/sign/PadesTwoPhaseSigningLevelsTest/cmp_twoStepSigningBaselineLTATest3_FIPS.pdf b/sign/src/test/resources/com/itextpdf/signatures/sign/PadesTwoPhaseSigningLevelsTest/cmp_twoStepSigningBaselineLTATest3_FIPS.pdf new file mode 100644 index 0000000000..4232f9ec75 Binary files /dev/null and b/sign/src/test/resources/com/itextpdf/signatures/sign/PadesTwoPhaseSigningLevelsTest/cmp_twoStepSigningBaselineLTATest3_FIPS.pdf differ diff --git a/sign/src/test/resources/com/itextpdf/signatures/sign/PadesTwoPhaseSigningLevelsTest/cmp_twoStepSigningBaselineLTTest3_FIPS.pdf b/sign/src/test/resources/com/itextpdf/signatures/sign/PadesTwoPhaseSigningLevelsTest/cmp_twoStepSigningBaselineLTTest3_FIPS.pdf new file mode 100644 index 0000000000..3840acbadf Binary files /dev/null and b/sign/src/test/resources/com/itextpdf/signatures/sign/PadesTwoPhaseSigningLevelsTest/cmp_twoStepSigningBaselineLTTest3_FIPS.pdf differ diff --git a/sign/src/test/resources/com/itextpdf/signatures/sign/Pdf20SigningTest/cmp_signPdf2CadesWithRipemd.pdf b/sign/src/test/resources/com/itextpdf/signatures/sign/Pdf20SigningTest/cmp_signPdf2CadesWithRipemd.pdf deleted file mode 100644 index 1f58edfa82..0000000000 Binary files a/sign/src/test/resources/com/itextpdf/signatures/sign/Pdf20SigningTest/cmp_signPdf2CadesWithRipemd.pdf and /dev/null differ diff --git a/sign/src/test/resources/com/itextpdf/signatures/sign/Pdf20SigningTest/signPdf2CadesWithRipemd.pdf b/sign/src/test/resources/com/itextpdf/signatures/sign/Pdf20SigningTest/signPdf2CadesWithRipemd.pdf deleted file mode 100644 index 7b6d1701fb..0000000000 Binary files a/sign/src/test/resources/com/itextpdf/signatures/sign/Pdf20SigningTest/signPdf2CadesWithRipemd.pdf and /dev/null differ diff --git a/sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/test.pem b/sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/test.pem deleted file mode 100644 index a9307d180a..0000000000 --- a/sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/test.pem +++ /dev/null @@ -1,51 +0,0 @@ ------BEGIN ENCRYPTED PRIVATE KEY----- -MIIFNTBfBgkqhkiG9w0BBQ0wUjAxBgkqhkiG9w0BBQwwJAQQYh8g3qiMhxsnV5xf -S4sK7AICCAAwDAYIKoZIhvcNAgkFADAdBglghkgBZQMEASoEEMTVVdwTGHC+ynMw -BzHDt/kEggTQnubx8WeyfN5T2csCAqoBKCa0OkT3be7W9zJl3y3L7zZYKxxEG4L2 -vFCbGog85tvrwnziaqRYOmmYJbp86rTuY/M4+7gYKiMwibvrE6JIqE3YwBvFoH49 -q+MobF/QLIyKg5TiUrunqbmF/xZGOfCuSimnIGHFxpzDjAJAP/rhSfNYIqmKd7gW -6egJSsmgZ1LhTYhylKHlcDt52bS+tTmeuQpWslJ6hmojqnZToT8ihSEBgYJG3qis -06XnsZHt324vJRa2LCksm0mJD3rkpZlzfvveRr0MiU2U25KL8s1VQKfDoWWG3HGj -mNOUc0ggCQXsgVmfCsIq8QX46n/j/xHMs0gUu3NLfOlii8tt7BQKsmDtaufIo4+k -+Q42b/KPeAbMWOYJc6WozCwkaKjWCHi0GeiFfbnJLt2KMjMDw2qxArgXcjAvlyKk -1r8OD3je9/2NdknSVD5qv+WAhARJGk/aqx+TDMtMmr/5tevc/VzVuI8e5SeREI6m -H4yAd45EDw+OpPz9Tff1xPH5ZBnDAPYIodm4xXW42uIdPsmJbQYh1aX5ijLjmLSW -zjMqvN+ysDUMc0lBOn0HR8h8P+uObWigPk3J9n+7ABh4uAMEdjbXhSPbbjV2Gwri -irwJgGQt4F7a6vi8ypUf7leLLYn/Y0nFn438/eDjMmnj5nCZIlwM9f48NwTNRn5X -J7R+U98xsQHvu/23HLSVfXk5pRNi5++WEVDocb/vyEXmn7SdHAeL9QxzhxoM6xgs -5LGNyT5dsoxM7YoAUcRC7W4fDq4WFit3qxRTNXsqSVHOfZWZbkUuGSvBxQHFTL1Z -amItasoXZbOeA89LD2LXd9FrxXdDf702OOJonutl+OtszyNHHv/BXcktDEJmsVUz -qhmLrip6eB/boxSCJhWnMIcMb97/pkFex5YEMBxntx5mnO8ICD64vbIosYSHBdBv -9NQ8qczCqYJXVJD1AB/IhQDK+HC4EyMV9/h3dfzN2flZZHW64cHFG4YjFz2k00sF -mdGhbTXJAuC5vxRUWqf4/dlAc4uSmUeoxZqHfiiJ+hGXrbpLxx41/ZvBl6sgOHZ2 -Zb+yv/qZeu507eAQFNq+BYSu+B9shhxRB1VkMz9ZxdKiU1ywU0TFxPsxq62FtoF7 -REwVLUBUzQMS1t+gq+P9yGSSx8eZMvQgviTIX2iBWgVbgq4LKx5UgfVeFIxHqp6F -Ba1eYzEXSqGKZYWWtM4rjDhgOjZsM6wNQ8bsRSSkjYcg9JvIpZ13oT1HiCecohR4 -N2GNo5bLxDxTlfyZNTKr2SVPkARvmjBhxfVbnbNlRRmOe3uEh9PFDPl/mWa+Ql11 -YODqdYG4xVzYpqHpr1P49/Peib6Pr5LkHOp8R8tjD8L2ARFe9lZlS31c2Jqt0qgb -TC1IzV8DTxIxL1Lvpsklr+0sXkcwC/gYcWwkw/ADNik+pRSfSZ6T2AVAoS475erA -cIFYCD0uCrosMjaw1hL4TRwKh+8BVZi7CUFZPp0jvMyAN77aV+K2u8Nx1UcvZDzp -OTbudK1jnvbuMnYqCTPfGObbkbR6HoFN6OLdKa5QV3VAMuqOj/4n+3zUSfsI4WYX -Les4a5l7cbz5R68BD9XC03LJCFBK91yDKRFocrl5g6RzW9bfC7AzfCU= ------END ENCRYPTED PRIVATE KEY----- ------BEGIN CERTIFICATE----- -MIIDfzCCAmegAwIBAgIEUFic9zANBgkqhkiG9w0BAQsFADBvMQswCQYDVQQGEwJU -UzETMBEGA1UECBMKVGVzdCBTdGF0ZTESMBAGA1UEBxMJVGVzdCBUb3duMREwDwYD -VQQKEwhUZXN0IG9yZzEQMA4GA1UECxMHVGVzdCBPVTESMBAGA1UEAxMJVGVzdCBV -c2VyMCAXDTE0MDkyMjA5MTExMVoYDzIxMTQwODI5MDkxMTExWjBvMQswCQYDVQQG -EwJUUzETMBEGA1UECBMKVGVzdCBTdGF0ZTESMBAGA1UEBxMJVGVzdCBUb3duMREw -DwYDVQQKEwhUZXN0IG9yZzEQMA4GA1UECxMHVGVzdCBPVTESMBAGA1UEAxMJVGVz -dCBVc2VyMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA+6g5sYzXiNOA -hR7C8wc8buxU/JgcbdHpHIR44iuXjpepBYAE7hRsWM7H4cuXrKiRxS9UMOadqkGF -Qqb5sG6lo2UUhcj4qlN6hKDc/+AMZMIW1mvQldiygCAkqgM8iso+kw56dpVuerG/ -k1nd8f+X9rjXN6/DIMznZcMy2d9ByIFuixFKElPvOWx9q9N4aiueOd5FM5eHxp+3 -F4uCTrpM5zkS7Rmf5GVtCofc8KgaTLLp4D0Ge5VUJm7yW8fuU3eIpin4ivjk+Gye -Q3t0BsrmNyQy3CmKGOBP/vX0+wEMvGN2xqNgAFP9dxA+AbJMiAfsmoWvxXaPktqC -DOspTCFqbwIDAQABoyEwHzAdBgNVHQ4EFgQUILviRCmSrhuLDmF0nus4pv2uu7gw -DQYJKoZIhvcNAQELBQADggEBAGnfGYL7nDm5taDPRxuGGMqUPwRnH2bXwef6S2Xb -/nIEFtNheVFQFtKNn5Ikq68DTFMP06yXLnI7F40+ZiQezRBB1EPPmDL2fYKc9fL1 -SHntu6HLgP/Y5nnCVegtL8l9745gQZnnXlMtkTs2HFwffznIHW/3STO0Bcj0+KMa -p8vebMjmvV7bZEGvrcrVXL55QPZXJwRuQMXJB3f5XhAEH1VqAhTW6DrvBUnuESwo -9fxxA5gmblt80SQYdKr2I08OTk0qmyF8zNuffTOiSS8/V6Cf7CntuPWjSuVf1EVP -MH6KkSjceLZ99Y7bvl7KKvQ4Kj5Bp27PwlRvtYbfCUmQEG8= ------END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/sign/RSASSAPSSTest/ca.crt b/sign/src/test/resources/com/itextpdf/signatures/sign/RSASSAPSSTest/ca.crt deleted file mode 100644 index cd2f996d99..0000000000 Binary files a/sign/src/test/resources/com/itextpdf/signatures/sign/RSASSAPSSTest/ca.crt and /dev/null differ diff --git a/sign/src/test/resources/com/itextpdf/signatures/certs/ed448.pem b/sign/src/test/resources/com/itextpdf/signatures/sign/RSASSAPSSTest/ca.pem similarity index 50% rename from sign/src/test/resources/com/itextpdf/signatures/certs/ed448.pem rename to sign/src/test/resources/com/itextpdf/signatures/sign/RSASSAPSSTest/ca.pem index a353daabbd..a923e6ec69 100644 --- a/sign/src/test/resources/com/itextpdf/signatures/certs/ed448.pem +++ b/sign/src/test/resources/com/itextpdf/signatures/sign/RSASSAPSSTest/ca.pem @@ -1,25 +1,3 @@ ------BEGIN ENCRYPTED PRIVATE KEY----- -MIGrMFcGCSqGSIb3DQEFDTBKMCkGCSqGSIb3DQEFDDAcBAjjXVpbVVssSQICCAAw -DAYIKoZIhvcNAgkFADAdBglghkgBZQMEASoEEHeL6O3rZ8BWr8G5nXTj/S8EUIoH -PbIxONLZuCNhv/NGjAaE7Ma53fuOKjD/NpPfEa7pR81KMBwC8ykfRTpWfs0/aVY1 -5SYX6iMMDGHkWwDx+x2Gczk3/HO/QbVPtcFi9CKI ------END ENCRYPTED PRIVATE KEY----- ------BEGIN CERTIFICATE----- -MIICdDCCAVygAwIBAgICEAYwDQYJKoZIhvcNAQELBQAwPTEYMBYGA1UECgwPUERG -IEFzc29jaWF0aW9uMSEwHwYDVQQDDBhEaWdTaWcgRXh0ZW5zaW9uIERlbW8gQ0Ew -HhcNMjEwMTAxMDAwMDAwWhcNMzEwMTAxMDAwMDAwWjBKMRgwFgYDVQQKDA9QREYg -QXNzb2NpYXRpb24xGDAWBgNVBAwMD0RvY3VtZW50IFNpZ25lcjEUMBIGA1UEAwwL -QWxpY2UgTWNGb28wQzAFBgMrZXEDOgBQxzLqZ+9E8y/dHuCD8RPlqyq8dBRjxSiB -4RZl/TvsuALmIPsKOnoiB/gIa4+8IxiM1R08tcfomYCjUjBQMB0GA1UdDgQWBBSY -hRROaQ1ta3BSa8OPktt26bEy5TAfBgNVHSMEGDAWgBRGdbBGXT7btNdUkKKffG3L -TD1i0zAOBgNVHQ8BAf8EBAMCBsAwDQYJKoZIhvcNAQELBQADggEBANfIM6oT5Qe7 -/F9eb7plMUVy5JFQips8IDz5DmrrkYyJHYciFm2rccO7hKUMNsNSx6tyiMJwZS8D -RjjeDCwJjF+msgLGoMGu0Ql26ZWYtNaBfGmCsdUIJUIcrDPPvkOmdgmcsQjMyevj -/0mkXPTBu2gYss7Z/k9rO6us2ZkIU8ucRZ2M6jIF1cwq19oH6rnm5/iAnQKCm6Ye -ezXCFE5jgerKqyMBByOT/gBE8rR8KDdpFz+LED81DnNu4Yqf5b0bAy1MI9TfO9YR -gDW3G8bEPZVQ6UoJs1ZuIB//LDu+gcbHjnIpEXPO5ndaKzdtRpOeTIkhNuOb5HNV -d6uRcAfj1oc= ------END CERTIFICATE----- -----BEGIN CERTIFICATE----- MIIDWzCCAkOgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwPTEYMBYGA1UECgwPUERG IEFzc29jaWF0aW9uMSEwHwYDVQQDDBhEaWdTaWcgRXh0ZW5zaW9uIERlbW8gQ0Ew diff --git a/sign/src/test/resources/com/itextpdf/signatures/sign/RSASSAPSSTest/rsa.crt b/sign/src/test/resources/com/itextpdf/signatures/sign/RSASSAPSSTest/rsa.crt deleted file mode 100644 index c6fa6b6714..0000000000 Binary files a/sign/src/test/resources/com/itextpdf/signatures/sign/RSASSAPSSTest/rsa.crt and /dev/null differ diff --git a/sign/src/test/resources/com/itextpdf/signatures/sign/RSASSAPSSTest/rsa.pem b/sign/src/test/resources/com/itextpdf/signatures/sign/RSASSAPSSTest/rsa.pem new file mode 100644 index 0000000000..7c0810c589 --- /dev/null +++ b/sign/src/test/resources/com/itextpdf/signatures/sign/RSASSAPSSTest/rsa.pem @@ -0,0 +1,20 @@ +-----BEGIN CERTIFICATE----- +MIIDVTCCAj2gAwIBAgICEAEwDQYJKoZIhvcNAQELBQAwPTEYMBYGA1UECgwPUERG +IEFzc29jaWF0aW9uMSEwHwYDVQQDDBhEaWdTaWcgRXh0ZW5zaW9uIERlbW8gQ0Ew +HhcNMjEwMTAxMDAwMDAwWhcNMzEwMTAxMDAwMDAwWjBKMRgwFgYDVQQKDA9QREYg +QXNzb2NpYXRpb24xGDAWBgNVBAwMD0RvY3VtZW50IFNpZ25lcjEUMBIGA1UEAwwL +QWxpY2UgTWNGb28wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDGGDbm +XUfRFuAgvp+ODOOXC04rmsXpcruTUcNuz6XBNcqQfUm8Zdms1jG+PwzCuiYDArIt +GB7b00/ueZUMrqx23l6jXr3mL3B7644m61kfPRRDsApIdLnTULRCLp5waEQDDAWa +uYANAVqpl93A7x7SeF/SeEX0e7OXS5zT5NnZ0AydyExPbKMmsE5+P/Hrh1aBqTiG +hLPlxfYAHeLWD+2N/zIlNVLUdZV96pNKRS5WReY0Mu9PvBtvdWnZzVTlLJXDGjyY +A9drxM6/zy06bQWjImnES9V4mCwfNGYhhNOYgeO1f3G7u4MqQtlkjyJfdBNi4a6f +xU0ZfY5TumgQXZKXAgMBAAGjUjBQMB0GA1UdDgQWBBRadoeKDREfL2wDVEkhlhoD +x1NI6TAfBgNVHSMEGDAWgBRGdbBGXT7btNdUkKKffG3LTD1i0zAOBgNVHQ8BAf8E +BAMCBsAwDQYJKoZIhvcNAQELBQADggEBAGaefIP/MAj3OTQMoCHjgs6SykwWg2z1 +lWm+6OEvnG2dsHs2+mIlRU5n1HlEqaEJrCN9DknAl86T1qkZWqsVE0556/ctTdii +rUK3LhxwtnfMqkZxWyQIUMDbeAFhMqk4tjSGGLWlwjjXQbwmA4tdP1C8L2EoPXm8 ++jZ8JbUoDwE61JaTkTYsrtVpXu5ZOPBoPrgBQvyExj8H8ZRkeX0Kg22eosDqXQQ9 +IOm9ej8V0wfC6+IJded6ZurJVD4XDSyNZh9Bi3ro4tPz+kikwxVyCIBUa6NG+ndF +Hx3ZbkhZcx0Y1P+ypogf3M36QKy7BHfjw5/vbjV5YLou7VyYIM5a9/k= +-----END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/1.png b/sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/1.png similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/1.png rename to sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/1.png diff --git a/sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_createdAndSignedSignatureField.pdf b/sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_createdAndSignedSignatureField.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_createdAndSignedSignatureField.pdf rename to sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_createdAndSignedSignatureField.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_deprecatedLayersTest.pdf b/sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_deprecatedLayersTest.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_deprecatedLayersTest.pdf rename to sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_deprecatedLayersTest.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_emptySignatureAppearance.pdf b/sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_emptySignatureAppearance.pdf similarity index 71% rename from sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_emptySignatureAppearance.pdf rename to sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_emptySignatureAppearance.pdf index e5a2cb45f3..34d21d1fd0 100644 Binary files a/sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_emptySignatureAppearance.pdf and b/sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_emptySignatureAppearance.pdf differ diff --git a/sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_fieldLayersTest.pdf b/sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_fieldLayersTest.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_fieldLayersTest.pdf rename to sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_fieldLayersTest.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_fontColorTest01.pdf b/sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_fontColorTest01.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_fontColorTest01.pdf rename to sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_fontColorTest01.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_layer0Test.pdf b/sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_layer0Test.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_layer0Test.pdf rename to sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_layer0Test.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_layer0WithImageAndNegativeImageScale.pdf b/sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_layer0WithImageAndNegativeImageScale.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_layer0WithImageAndNegativeImageScale.pdf rename to sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_layer0WithImageAndNegativeImageScale.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_layer0WithImageAndPositiveImageScaleTest.pdf b/sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_layer0WithImageAndPositiveImageScaleTest.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_layer0WithImageAndPositiveImageScaleTest.pdf rename to sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_layer0WithImageAndPositiveImageScaleTest.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_layer0WithImageTest.pdf b/sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_layer0WithImageTest.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_layer0WithImageTest.pdf rename to sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_layer0WithImageTest.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_layer2Test.pdf b/sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_layer2Test.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_layer2Test.pdf rename to sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_layer2Test.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_reuseAppearance.pdf b/sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_reuseAppearance.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_reuseAppearance.pdf rename to sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_reuseAppearance.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_reuseAppearanceCompatibility.pdf b/sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_reuseAppearanceCompatibility.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_reuseAppearanceCompatibility.pdf rename to sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_reuseAppearanceCompatibility.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_reuseAppearanceDeprecated.pdf b/sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_reuseAppearanceDeprecated.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_reuseAppearanceDeprecated.pdf rename to sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_reuseAppearanceDeprecated.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_signExistingNotMergedFieldNotReusedAP.pdf b/sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_signExistingNotMergedFieldNotReusedAP.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_signExistingNotMergedFieldNotReusedAP.pdf rename to sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_signExistingNotMergedFieldNotReusedAP.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_signExistingNotMergedFieldReusedAP.pdf b/sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_signExistingNotMergedFieldReusedAP.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_signExistingNotMergedFieldReusedAP.pdf rename to sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_signExistingNotMergedFieldReusedAP.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_signExistingNotMergedFieldReusedAPEntryNDic.pdf b/sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_signExistingNotMergedFieldReusedAPEntryNDic.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_signExistingNotMergedFieldReusedAPEntryNDic.pdf rename to sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_signExistingNotMergedFieldReusedAPEntryNDic.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_signatureFieldAppearanceTest.pdf b/sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_signatureFieldAppearanceTest.pdf similarity index 79% rename from sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_signatureFieldAppearanceTest.pdf rename to sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_signatureFieldAppearanceTest.pdf index 3b4b50654a..0963394d15 100644 Binary files a/sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_signatureFieldAppearanceTest.pdf and b/sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_signatureFieldAppearanceTest.pdf differ diff --git a/sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_signatureFieldBackground.pdf b/sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_signatureFieldBackground.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_signatureFieldBackground.pdf rename to sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_signatureFieldBackground.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_signaturesOnRotatedPages1_mode_DESCRIPTION.pdf b/sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_signaturesOnRotatedPages1_mode_DESCRIPTION.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_signaturesOnRotatedPages1_mode_DESCRIPTION.pdf rename to sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_signaturesOnRotatedPages1_mode_DESCRIPTION.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_signaturesOnRotatedPages1_mode_GRAPHIC.pdf b/sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_signaturesOnRotatedPages1_mode_GRAPHIC.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_signaturesOnRotatedPages1_mode_GRAPHIC.pdf rename to sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_signaturesOnRotatedPages1_mode_GRAPHIC.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_signaturesOnRotatedPages1_mode_GRAPHIC_AND_DESCRIPTION.pdf b/sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_signaturesOnRotatedPages1_mode_GRAPHIC_AND_DESCRIPTION.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_signaturesOnRotatedPages1_mode_GRAPHIC_AND_DESCRIPTION.pdf rename to sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_signaturesOnRotatedPages1_mode_GRAPHIC_AND_DESCRIPTION.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_signaturesOnRotatedPages1_mode_NAME_AND_DESCRIPTION.pdf b/sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_signaturesOnRotatedPages1_mode_NAME_AND_DESCRIPTION.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_signaturesOnRotatedPages1_mode_NAME_AND_DESCRIPTION.pdf rename to sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_signaturesOnRotatedPages1_mode_NAME_AND_DESCRIPTION.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_signaturesOnRotatedPages2_mode_DESCRIPTION.pdf b/sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_signaturesOnRotatedPages2_mode_DESCRIPTION.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_signaturesOnRotatedPages2_mode_DESCRIPTION.pdf rename to sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_signaturesOnRotatedPages2_mode_DESCRIPTION.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_signaturesOnRotatedPages2_mode_GRAPHIC.pdf b/sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_signaturesOnRotatedPages2_mode_GRAPHIC.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_signaturesOnRotatedPages2_mode_GRAPHIC.pdf rename to sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_signaturesOnRotatedPages2_mode_GRAPHIC.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_signaturesOnRotatedPages2_mode_GRAPHIC_AND_DESCRIPTION.pdf b/sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_signaturesOnRotatedPages2_mode_GRAPHIC_AND_DESCRIPTION.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_signaturesOnRotatedPages2_mode_GRAPHIC_AND_DESCRIPTION.pdf rename to sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_signaturesOnRotatedPages2_mode_GRAPHIC_AND_DESCRIPTION.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_signaturesOnRotatedPages2_mode_NAME_AND_DESCRIPTION.pdf b/sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_signaturesOnRotatedPages2_mode_NAME_AND_DESCRIPTION.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_signaturesOnRotatedPages2_mode_NAME_AND_DESCRIPTION.pdf rename to sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_signaturesOnRotatedPages2_mode_NAME_AND_DESCRIPTION.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_signaturesOnRotatedPages3_mode_DESCRIPTION.pdf b/sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_signaturesOnRotatedPages3_mode_DESCRIPTION.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_signaturesOnRotatedPages3_mode_DESCRIPTION.pdf rename to sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_signaturesOnRotatedPages3_mode_DESCRIPTION.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_signaturesOnRotatedPages3_mode_GRAPHIC.pdf b/sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_signaturesOnRotatedPages3_mode_GRAPHIC.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_signaturesOnRotatedPages3_mode_GRAPHIC.pdf rename to sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_signaturesOnRotatedPages3_mode_GRAPHIC.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_signaturesOnRotatedPages3_mode_GRAPHIC_AND_DESCRIPTION.pdf b/sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_signaturesOnRotatedPages3_mode_GRAPHIC_AND_DESCRIPTION.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_signaturesOnRotatedPages3_mode_GRAPHIC_AND_DESCRIPTION.pdf rename to sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_signaturesOnRotatedPages3_mode_GRAPHIC_AND_DESCRIPTION.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_signaturesOnRotatedPages3_mode_NAME_AND_DESCRIPTION.pdf b/sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_signaturesOnRotatedPages3_mode_NAME_AND_DESCRIPTION.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_signaturesOnRotatedPages3_mode_NAME_AND_DESCRIPTION.pdf rename to sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_signaturesOnRotatedPages3_mode_NAME_AND_DESCRIPTION.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_signaturesOnRotatedPages4_mode_DESCRIPTION.pdf b/sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_signaturesOnRotatedPages4_mode_DESCRIPTION.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_signaturesOnRotatedPages4_mode_DESCRIPTION.pdf rename to sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_signaturesOnRotatedPages4_mode_DESCRIPTION.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_signaturesOnRotatedPages4_mode_GRAPHIC.pdf b/sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_signaturesOnRotatedPages4_mode_GRAPHIC.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_signaturesOnRotatedPages4_mode_GRAPHIC.pdf rename to sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_signaturesOnRotatedPages4_mode_GRAPHIC.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_signaturesOnRotatedPages4_mode_GRAPHIC_AND_DESCRIPTION.pdf b/sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_signaturesOnRotatedPages4_mode_GRAPHIC_AND_DESCRIPTION.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_signaturesOnRotatedPages4_mode_GRAPHIC_AND_DESCRIPTION.pdf rename to sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_signaturesOnRotatedPages4_mode_GRAPHIC_AND_DESCRIPTION.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_signaturesOnRotatedPages4_mode_NAME_AND_DESCRIPTION.pdf b/sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_signaturesOnRotatedPages4_mode_NAME_AND_DESCRIPTION.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_signaturesOnRotatedPages4_mode_NAME_AND_DESCRIPTION.pdf rename to sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_signaturesOnRotatedPages4_mode_NAME_AND_DESCRIPTION.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_signedSignatureField.pdf b/sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_signedSignatureField.pdf similarity index 76% rename from sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_signedSignatureField.pdf rename to sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_signedSignatureField.pdf index 804629ccd2..da2ba9f986 100644 Binary files a/sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_signedSignatureField.pdf and b/sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_signedSignatureField.pdf differ diff --git a/sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_signed_hybrid.pdf b/sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_signed_hybrid.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/cmp_signed_hybrid.pdf rename to sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/cmp_signed_hybrid.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/documentWithRotatedPages.pdf b/sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/documentWithRotatedPages.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/documentWithRotatedPages.pdf rename to sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/documentWithRotatedPages.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/emptyFieldNotMerged.pdf b/sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/emptyFieldNotMerged.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/emptyFieldNotMerged.pdf rename to sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/emptyFieldNotMerged.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/emptyFieldNotMergedEntryNDict.pdf b/sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/emptyFieldNotMergedEntryNDict.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/emptyFieldNotMergedEntryNDict.pdf rename to sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/emptyFieldNotMergedEntryNDict.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/hybrid.pdf b/sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/hybrid.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/hybrid.pdf rename to sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/hybrid.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/itext.png b/sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/itext.png similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/itext.png rename to sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/itext.png diff --git a/sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/noSignatureField.pdf b/sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/noSignatureField.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/noSignatureField.pdf rename to sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/noSignatureField.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/signatureFieldNotMergedWithWidget.pdf b/sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/signatureFieldNotMergedWithWidget.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/signatureFieldNotMergedWithWidget.pdf rename to sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/signatureFieldNotMergedWithWidget.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/simpleDocument.pdf b/sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/simpleDocument.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/simpleDocument.pdf rename to sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/simpleDocument.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/test.cer b/sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/test.cer new file mode 100644 index 0000000000..fbaad2b382 Binary files /dev/null and b/sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/test.cer differ diff --git a/sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/test.pem b/sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/test.pem new file mode 100644 index 0000000000..4cbee8fcbd --- /dev/null +++ b/sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/test.pem @@ -0,0 +1,74 @@ +-----BEGIN ENCRYPTED PRIVATE KEY----- +MIIFNTBfBgkqhkiG9w0BBQ0wUjAxBgkqhkiG9w0BBQwwJAQQrCI2KefPpkSRg93G +8wROsAICCAAwDAYIKoZIhvcNAgkFADAdBglghkgBZQMEAQIEEERFvpTFKlKcFCBG +BvnLqGIEggTQjNcHtHwyEdouh5ct4ZXV3GZ0H8N6CZCi/tuiVn/BOWdgA7deGC6P ++7dg+1vcLj7VofkHM2//7wREw13GrYPfqULXWTxRJ978KM2mipcEEaaxCf7GWYoO +Y2gRcsc5Y/C4XS5Erpj+OMW/yXXiBmOGQRImC1hzc2Ggm3KoQuv5j7XDrMlfnMpm +QSURPxRoo1YwFgyHhL5gziCu7a9Vy+IygicrEUzlcJ2ooDKR/SiSBQXiVJbL7MmZ +bPmHhQ5TwD4mUcBgT+unkkTW67RsH1Le6ajCvjo1UBEdtmRAsygaoUpD3hBeon1F +gzrjBV3UgmvWcWDWJlBN8f5/3RZrINxHfl2aZoGpV+KyeniWaSRgpeuqFUkdvgVG +4y2rCaBse7NUMjVN5eq81tN5kClmvZFvdTZGlcYnUZ14b7ZVeGS0TC0yW/DloeNm +UdQ6qo2XZ/s/ZdL2erNKO2jvybIjEGihP3ttTPTLGgiCg62qa+8TSDxOc3Ue6g6s +OEwuI+ENTPs+kmWo814foXo/uEJ5E2NU7u38RFqnj6ksV9olAtin8NcN3Eh9OBBn +LA9bqh9A1NkGjN+A8Rlu25SxmSsxOIa8iR3L+h7lZRO5/72gu7SxnjJxbflS1ktF +gko7XIZOuN8psJ7lMAB+LGUZp2cK6oB9/naH/InoMVKU55f/Ln3YOc+cCpPlEzlz +oJsbkajNnfIESKEO+EnXOGNLhtsyq7fh3cjf7eGMN7FGdZVVIYfQG7ZrtLwDT5zc +9DMYZfdmUqGT20MtG04MpeQqqCBlSATjTz51wLcFFdctyGBBPRvbSWAO49M8PvKx +ASrtGrc/x/UjmgZc1Td6wW6lsp9GiAWbiSuqsHd9CSIeertpDXiow0zjfNMMBp8Z +4rfR2Kx5DkEJhTnoZiiNE8dYFPRGZoNqFzpEa5XNj9GLiFDyUM/TDnaW+GCsopn2 +FFH2TLqYS4GTp9yfiO9QZFVw9aXhzrvqC0mCirrxJjpa7on72nYvKUZXKFZjRJuk +0zIcYZq+7aFoNLuxyjnqCvvVCuR1aMbi1SQIFbk1ipfcT6DoDe3zoKkAmxs9d31f +8O+OYhGSev7WgXM4lLUf7aNmn56NrQ+gKJxx6fUsYK7/qcteqExpH2NDfCay55Nd +qa9WScL/uaTEM+YGosye5WbDJJ81aedsCPpAzYpOPNnpFYlMtIzyxVDqtjHNzKuq +ui2SbugZ1oAzWZHPttohdHvdrNgJydNg8d0LHuceqZbmvQOXhPLagPUgVQnMczyj +TJqX+Z1uCIlwpjM+kgQ7EL8LV/b8Tttdd294080q/j20yMUfj9ZVlyl0ZeqgaDXF +M204HVB/k3IqHjagR0Qnc45NglFVUOtitJ+TOlFTu/hQYCNG7UPSwW1kZfP1dNZf +MNrh/UmeQAlJoAxIjY2ndGMkDuHU+/3WuETkYtY019DMSHHqMB3lN7kKBcs1Ssdj +gvIypodexktcG2N8xMji1Su5Gp2HB14hGWtGCeA7rsCFft3SoLuwoYIoXQasqV9e +ETyH4UJ+eNtO1aSvG4dGZwq/uEKVQMBQkCMWi1G/moiEjDMSBauomnWWSnVf4qn2 +oPq3XcxDJFb9oCzxSZwjM5MFuVik07pRLZXgmY/tGYhTtB2HatSpscc= +-----END ENCRYPTED PRIVATE KEY----- +-----BEGIN CERTIFICATE----- +MIIDkTCCAnmgAwIBAgICEAEwDQYJKoZIhvcNAQELBQAwPzELMAkGA1UEBhMCQkUx +DjAMBgNVBAoMBWlUZXh0MSAwHgYDVQQDDBdpVGV4dFRlc3RBcHBlYXJhbmNlUm9v +dDAgFw0yMDAxMDEwMDAwMDBaGA8yNDAwMDEwMTAwMDAwMFowMDELMAkGA1UEBhMC +QkUxDjAMBgNVBAoMBWlUZXh0MREwDwYDVQQDDAhUZXN0VXNlcjCCASIwDQYJKoZI +hvcNAQEBBQADggEPADCCAQoCggEBALcm1EvBk22gj9FrzoW6vJk9ixjDHS7SxrSn +nX7DUHvldq6ZRFqDSDZNlcd9HgoQ7/YGvXtquqYbqMVupk8uphtR7m2XRzLM9/YJ +h2Na1z7FrwsvJNtSYgLblzgFovcRhFE5ej2EKyjhh6BPIxBpYRAqy/kdPCRykNbU +XuIhvCG96+0RUqNoDZuAZx2Qhis6A9MkcuPXKH0Mh77qw/LJBM20ceNHxB4BOib3 +Vh6BUi5TrxSZCAW42X5qTZNlNNcgXI/aRMOaU9wJAbcsf9mbwN+V7Fz241DvrMX/ +H/ofpMS1g++xbXRQ7Ux7RwQnS5rBISsML0VlnXaj51aaKoeZsXkCAwEAAaOBozCB +oDAdBgNVHQ4EFgQUULQWZW++8B+zjGS2jnFK9twidOEwHwYDVR0jBBgwFoAU31+h +p8yurVuCSb47mYffu69v3cowDgYDVR0PAQH/BAQDAgXgME4GA1UdHwRHMEUwQ6BB +oD+GPWh0dHA6Ly90ZXN0LmV4YW1wbGUuY29tL2V4YW1wbGUtY2EvY3Jscy9sZWFm +LTEtY3JsL2xhdGVzdC5jcmwwDQYJKoZIhvcNAQELBQADggEBAD5EZH232RWoDPWp +TZzRdNRwKwXxVw/s148L+wyvzDretF6oIaV62KkwLndOsyGgMW+3cfgKbhjd36lW +3Hhk+VcWQBMW5/EctFvf9JMX2oDF8hKVcai0gaTIpVhpQKKk/jcBa7I0K2BD6Ply +xmRHManmXm8pFLDVoe6VSBr8uQGb951uvzhacy9nN+BdqZYBOLo1Qw5RgZpiaN9z +wjwMOTtgbfR9DmvAuurpBkK7zzYJ0u0uOilfX+DCaJz5wQweSxLDXFObJ8vkLFYY +I5GZRvJjZGVCUVIAM0p5iNlFnPMrOMVx3OVw5NDXkIdOynDBc3Q6TKhoxiCng6fs ++3D5f3w= +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDsjCCApqgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwPzELMAkGA1UEBhMCQkUx +DjAMBgNVBAoMBWlUZXh0MSAwHgYDVQQDDBdpVGV4dFRlc3RBcHBlYXJhbmNlUm9v +dDAgFw0wMDAxMDEwMDAwMDBaGA8yNTAwMDEwMTAwMDAwMFowPzELMAkGA1UEBhMC +QkUxDjAMBgNVBAoMBWlUZXh0MSAwHgYDVQQDDBdpVGV4dFRlc3RBcHBlYXJhbmNl +Um9vdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJ6ftTqEedqlfU8C +BluXWlNf2P3bn1dgV2/W/vBFlPfuEa1Cx/CrhlpXWr+aHFeTr0Q0LYgInJaUFvb2 +p0VJy4q25D9t6zVuwrlJ9wo3CUKk9nC7FUykSBI9Rbwid8dpUznqjGeGoT7LIAt7 +qyfRGbdSuA3qeNJkHVW6wZ7wKCduyfqrD8eYV8DAZEpeK0UWqkfm8biaupsu8znI +hdXW1pueDMA3Maotjm2PybvQNxwMLEaQ7MqiPje1p1pk4hvY1g+LD75n1p/9nyPe +l7eCMiAO2fcG15M/nI/riloQp7oeGPxkY562M9JpZvy5EgoUm9w39ZWUAbvFWPl1 +pqkQgwsCAwEAAaOBtTCBsjAdBgNVHQ4EFgQU31+hp8yurVuCSb47mYffu69v3cow +HwYDVR0jBBgwFoAU31+hp8yurVuCSb47mYffu69v3cowDwYDVR0TAQH/BAUwAwEB +/zAOBgNVHQ8BAf8EBAMCAeYwTwYDVR0fBEgwRjBEoEKgQIY+aHR0cDovL3Rlc3Qu +ZXhhbXBsZS5jb20vZXhhbXBsZS1jYS9jcmxzL3Jvb3QtY2EtY3JsL2xhdGVzdC5j +cmwwDQYJKoZIhvcNAQELBQADggEBAADuDp8U0cVqTZLSPMZnCQK/0VjosgG+Mnrj +9MpOp/S8Htf+zvpDoyJkOVITNPX0rtzkqr2BF8JskEN65LyWiIlLGre7uojn07pf +dlNk44RHM/Jc692avM+3QHulgF92rtvF8Zw9kfi+MeT+/FDspKzEEcrEUUaA2Hll +7A4j7pInPG9VPZRAbu1kgDBzor/t23oreEIsnbpdM1iSbDTpIoz3oAD9ZlYPk9fk +3jrFpLIo9Hwn0iHxB0c/lB2M9kRRQhywhWnTEnhS2Eb6RYZwIvcCFTiv+OP0KCAO ++OhlFwKkLEGGR7Qn0X5JA0CVJ45vC/+u/XU1asYTR2J4zWQHvfs= +-----END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/unsignedSignatureField.pdf b/sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/unsignedSignatureField.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/sign/PdfSignatureAppearanceTest/unsignedSignatureField.pdf rename to sign/src/test/resources/com/itextpdf/signatures/sign/SignatureAppearanceTest/unsignedSignatureField.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/sign/LtvSigTest/cmp_ltvEnabledTest01.pdf b/sign/src/test/resources/com/itextpdf/signatures/sign/SignedAppearanceTextTest/cmp_noReasonLocationSignDateInAppearanceText.pdf similarity index 71% rename from sign/src/test/resources/com/itextpdf/signatures/sign/LtvSigTest/cmp_ltvEnabledTest01.pdf rename to sign/src/test/resources/com/itextpdf/signatures/sign/SignedAppearanceTextTest/cmp_noReasonLocationSignDateInAppearanceText.pdf index ee48153393..724bfc6182 100644 Binary files a/sign/src/test/resources/com/itextpdf/signatures/sign/LtvSigTest/cmp_ltvEnabledTest01.pdf and b/sign/src/test/resources/com/itextpdf/signatures/sign/SignedAppearanceTextTest/cmp_noReasonLocationSignDateInAppearanceText.pdf differ diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/README.md b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/README.md similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/README.md rename to sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/README.md diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/createTestData.cmd b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/createTestData.cmd similarity index 53% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/createTestData.cmd rename to sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/createTestData.cmd index 0675533643..ba87e44b37 100644 --- a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/createTestData.cmd +++ b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/createTestData.cmd @@ -1,15 +1,18 @@ REM create the test keys IF [%1] == [] goto continue md keys -openssl genrsa -out keys/root_key.pem -passout pass:testpassphrase 2048 -openssl genrsa -out keys/im_key.pem -passout pass:testpassphrase 2048 -openssl genrsa -out keys/sign-key.pem -passout pass:testpassphrase 2048 -openssl genrsa -out keys/crl-key.pem -passout pass:testpassphrase 2048 +openssl genrsa -out keys/root_key.pem -aes256 -passout pass:testpassphrase 2048 +openssl genrsa -out keys/im_key.pem -aes256 -passout pass:testpassphrase 2048 +openssl genrsa -out keys/im2_key.pem -aes256 -passout pass:testpassphrase 2048 +openssl genrsa -out keys/sign-key.pem -aes256 -passout pass:testpassphrase 2048 +openssl genrsa -out keys/crl-key.pem -aes256 -passout pass:testpassphrase 2048 :continue call :runTestCase happyPath call :runTestCase crlIssuerRevokedBeforeSigningDate call :runTestCase crlIssuerAndSignCertHaveNoSharedRoot +call :runTestCase crlSignerInValidatedChain +call :runTestCase multipleCrlIssuerCandidates EXIT :runTestCase diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/crlIssuerAndSignCertHaveNoSharedRoot.yml b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/crlIssuerAndSignCertHaveNoSharedRoot.yml similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/crlIssuerAndSignCertHaveNoSharedRoot.yml rename to sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/crlIssuerAndSignCertHaveNoSharedRoot.yml diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/crlIssuerAndSignCertHaveNoSharedRoot/ca.cert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/crlIssuerAndSignCertHaveNoSharedRoot/ca.cert.pem new file mode 100644 index 0000000000..efb7717302 --- /dev/null +++ b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/crlIssuerAndSignCertHaveNoSharedRoot/ca.cert.pem @@ -0,0 +1,20 @@ +-----BEGIN CERTIFICATE----- +MIIDSzCCAjOgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwNTELMAkGA1UEBhMCQkUx +DjAMBgNVBAoMBWlUZXh0MRYwFAYDVQQDDA1pVGV4dFRlc3RSb290MCAXDTAwMDEw +MTAwMDAwMFoYDzI1MDAwMTAxMDAwMDAwWjA1MQswCQYDVQQGEwJCRTEOMAwGA1UE +CgwFaVRleHQxFjAUBgNVBAMMDWlUZXh0VGVzdFJvb3QwggEiMA0GCSqGSIb3DQEB +AQUAA4IBDwAwggEKAoIBAQDYxUs+SgZkRkOhOfddCnPeuE1QP2kAm6gAsg4qjNzr +rZpZvwziyWaz6bXXq8fATjXEAdypAiWL/BDZscdCM/M11jds9mMv7dMvCtLns6Oe +4GbChYxxloN2rVxElFPK2siKBaEeWyItr2Ms0P+hSR5uHjFt+krzl2zv828fyEnH +fPvln42SAcuCKsLmfjtutus5jFKBFF8oiqDFlI2eXYggKV7JELttgPLobv2ZyFa5 +nXo/xbtzlPb8AvV3/mxpX4prFhBXupJXuCwmqmzVRqGbwKSz/Bewb/4aJGSpg32x +yIWeXTld58f+Jntfes8xHwK0aJB/Tm2WrH+RWoV+TN/pAgMBAAGjYzBhMB0GA1Ud +DgQWBBR0MlTFwFzoq8mPVusDjIEnL5avqzAfBgNVHSMEGDAWgBR0MlTFwFzoq8mP +VusDjIEnL5avqzAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIC5DANBgkq +hkiG9w0BAQsFAAOCAQEAK2dbxbQ7jEdtqvnMpKOZsB55PDO5OZ2hPYilT5ZVZNt1 +jdE94HdCBHED3upmOeBH+XtsK/MLk+eYICM5SZwWVCBY0aQQR0URyTsX4SA/12A5 +VhrnP6bqy4b+3mO3J9s0go59cZOtSkxQ7191teEQMsDeh8GxXGLW/7Tf4x6v7U34 +B7UghMhUD2bHJ7U8MOqto9fVar/9S93tc9vRtYOXZbfRwjFKOYD4IFm7cH3VnrX7 +od3KUEKGKhQ2ZaqrtnW19xNTbdRcMT3+8QSai9DLV0kGGSSY09AHDO3WvxkAs9ZI +cIsMM/n+mLK0Km9fh5uE3k6NmiN3GV+QMyjbmFnVNg== +-----END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/crlIssuerAndSignCertHaveNoSharedRoot/chain.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/crlIssuerAndSignCertHaveNoSharedRoot/chain.pem new file mode 100644 index 0000000000..c1951e4162 --- /dev/null +++ b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/crlIssuerAndSignCertHaveNoSharedRoot/chain.pem @@ -0,0 +1,101 @@ +-----BEGIN CERTIFICATE----- +MIIDSzCCAjOgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwNTELMAkGA1UEBhMCQkUx +DjAMBgNVBAoMBWlUZXh0MRYwFAYDVQQDDA1pVGV4dFRlc3RSb290MCAXDTAwMDEw +MTAwMDAwMFoYDzI1MDAwMTAxMDAwMDAwWjA1MQswCQYDVQQGEwJCRTEOMAwGA1UE +CgwFaVRleHQxFjAUBgNVBAMMDWlUZXh0VGVzdFJvb3QwggEiMA0GCSqGSIb3DQEB +AQUAA4IBDwAwggEKAoIBAQDYxUs+SgZkRkOhOfddCnPeuE1QP2kAm6gAsg4qjNzr +rZpZvwziyWaz6bXXq8fATjXEAdypAiWL/BDZscdCM/M11jds9mMv7dMvCtLns6Oe +4GbChYxxloN2rVxElFPK2siKBaEeWyItr2Ms0P+hSR5uHjFt+krzl2zv828fyEnH +fPvln42SAcuCKsLmfjtutus5jFKBFF8oiqDFlI2eXYggKV7JELttgPLobv2ZyFa5 +nXo/xbtzlPb8AvV3/mxpX4prFhBXupJXuCwmqmzVRqGbwKSz/Bewb/4aJGSpg32x +yIWeXTld58f+Jntfes8xHwK0aJB/Tm2WrH+RWoV+TN/pAgMBAAGjYzBhMB0GA1Ud +DgQWBBR0MlTFwFzoq8mPVusDjIEnL5avqzAfBgNVHSMEGDAWgBR0MlTFwFzoq8mP +VusDjIEnL5avqzAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIC5DANBgkq +hkiG9w0BAQsFAAOCAQEAK2dbxbQ7jEdtqvnMpKOZsB55PDO5OZ2hPYilT5ZVZNt1 +jdE94HdCBHED3upmOeBH+XtsK/MLk+eYICM5SZwWVCBY0aQQR0URyTsX4SA/12A5 +VhrnP6bqy4b+3mO3J9s0go59cZOtSkxQ7191teEQMsDeh8GxXGLW/7Tf4x6v7U34 +B7UghMhUD2bHJ7U8MOqto9fVar/9S93tc9vRtYOXZbfRwjFKOYD4IFm7cH3VnrX7 +od3KUEKGKhQ2ZaqrtnW19xNTbdRcMT3+8QSai9DLV0kGGSSY09AHDO3WvxkAs9ZI +cIsMM/n+mLK0Km9fh5uE3k6NmiN3GV+QMyjbmFnVNg== +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDijCCAnKgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwOjELMAkGA1UEBhMCQkUx +DjAMBgNVBAoMBWlUZXh0MRswGQYDVQQDDBJpVGV4dE90aGVyVGVzdFJvb3QwIBcN +MDAwMTAxMDAwMDAwWhgPMjQ1MDAxMDEwMDAwMDBaMDoxCzAJBgNVBAYTAkJFMQ4w +DAYDVQQKDAVpVGV4dDEbMBkGA1UEAwwSaVRleHRUZXN0Q3JsSXNzdWVyMIIBIjAN +BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwnsONfztmnDdLJKbWd8sE/2txomx +72HBnrBM3G2bLpGfcvAFm9n/F0WLf1dPDYY94JAFKsBGG0Enh4eBJ753ZHgug/qw +DIiF5DnRH57e2EtoJWwXjeSm5KLIsaWcUsUGHJDfS8SfWDqOIDCp+qm2mv1M98po +KsIo4lRHyM4XDL5ERGUAYklA0h5noHP1V1JnCQ0/4Z+j4dX0tfTnsxp4wA+Cu8Am +sfL+UP3LTu7Soo3rbHMtn8yf12j7eohMRTX71eRf1fR1Nes0wA72RPe6RHpd1kiX +yW8P/Y+BNNpqujnW/R6LcjsVlc2iSPK4XonwBExXGp44yVVQjEt4G/uPrQIDAQAB +o4GXMIGUMB0GA1UdDgQWBBQSbqEw8HXXDUnva1e6YGF7DBbGdTAfBgNVHSMEGDAW +gBSJQJIqlFRpEC9NMuebZTa38Lxk1TAOBgNVHQ8BAf8EBAMCAcIwQgYDVR0fBDsw +OTA3oDWgM4YxaHR0cDovL2xvY2FsaG9zdC50ZXN0L2RlZmF1bHQvY3Jscy9jcmwv +bGF0ZXN0LmNybDANBgkqhkiG9w0BAQsFAAOCAQEAY6Ql0oP20FsZrtKyLVFYJSkL +c3R4mTRHJ5JbrgtPSLkLDxN3QGssgwmhZUyf8TvaCYVBomedFvOVd3xizmQPcAkD +yDeX7XTvkrg9aSaGyjtKcOduk8eVHyPvAnFZ4eJ7m0vYJThLeVlupRYKnMcVR9AA +HMxKk+YTTaTr6o2zWE63vbzkdAvJTYuVzfDw2Qo+6IeAGL3jD9ipa6+krN/h6z8k +EPun+ndDEijo9TcPv+pPT+DHcXiWcLCQFi7611h4ErvFtUJoDl3xoTMsgqMKRzJJ +46HaLTKqkLikI/s4bKZ23brDHUYzpFCHs5WkQpRfdq6jHek9lBHNRK+tp66s6w== +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDQjCCAiqgAwIBAgICEAEwDQYJKoZIhvcNAQELBQAwNTELMAkGA1UEBhMCQkUx +DjAMBgNVBAoMBWlUZXh0MRYwFAYDVQQDDA1pVGV4dFRlc3RSb290MCAXDTAwMDEw +MTAwMDAwMFoYDzI0NTAwMTAxMDAwMDAwWjA9MQswCQYDVQQGEwJCRTEOMAwGA1UE +CgwFaVRleHQxHjAcBgNVBAMMFWlUZXh0VGVzdEludGVybWVkaWF0ZTCCASIwDQYJ +KoZIhvcNAQEBBQADggEPADCCAQoCggEBAJ6M9OSQgx20Fw14rYFeM6HQuQxBD276 +e6kXMpmdsbbkvExq5mrAWPvFGYHCmRAtH7pGm1pL91Zlgh1CbUPzwSa/Lfp9FeAX +83G7OJn0sY3kJRthtj5B0dGinXSIFCIb6gx9ICzoVpY9Ljvl4tyBr0dkGmED3MBx +SFltOMPplDhYwFekL7woNXMFIAxMnDWuS7dZ7xEpLAwNfH9D92I4lzSrQ9TrxwDP +dW2gWGvi2eu77W4YqFQgydgbKmFHAzDUTA01LNmKZkASBcLUoiLnLBMmVYgDMH4f +o4oj+2/J/OZNuGv5DK9dRCryAhnY3f8/9b8JzoPeRCmgRO9IU7ObZ/0CAwEAAaNS +MFAwHQYDVR0OBBYEFIlAkiqUVGkQL00y55tlNrfwvGTVMB8GA1UdIwQYMBaAFHQy +VMXAXOiryY9W6wOMgScvlq+rMA4GA1UdDwEB/wQEAwIB5jANBgkqhkiG9w0BAQsF +AAOCAQEAMoIJ86nzczzR41l5EFHlxGvUEQY/w7BJ42LICN3F12WPmJ+A3i/GAJSQ +14W+Jy8CXEhEFZF3R45vuOAGhOkF7igtbXeeVXunM3rmi8XIlpGjqbBZxC5w1Fd8 +IPOTArrzcF8agwthRzKOEpFSklmpUDT4MYZkdzR7TVM6TkdL+ModYFrhf9/+OFGb +qHzKUPVv+dvNaKn6JvKfQ311MKG3fLU7vyKEUNoolAnLMy3VETsnhMTk6Wa5rfzJ +eq2sdBiLxgwC3xhYk33Cla0X3hsr++Yqb8BX1ztKaRxu0PSi+KKJ9kvXAxRkFlwh +Xa7iIRXelUhftWRF/4VgDsDhWx+eDQ== +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDVTCCAj2gAwIBAgICEAEwDQYJKoZIhvcNAQELBQAwOjELMAkGA1UEBhMCQkUx +DjAMBgNVBAoMBWlUZXh0MRswGQYDVQQDDBJpVGV4dE90aGVyVGVzdFJvb3QwIBcN +MDAwMTAxMDAwMDAwWhgPMjUwMDAxMDEwMDAwMDBaMDoxCzAJBgNVBAYTAkJFMQ4w +DAYDVQQKDAVpVGV4dDEbMBkGA1UEAwwSaVRleHRPdGhlclRlc3RSb290MIIBIjAN +BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnoz05JCDHbQXDXitgV4zodC5DEEP +bvp7qRcymZ2xtuS8TGrmasBY+8UZgcKZEC0fukabWkv3VmWCHUJtQ/PBJr8t+n0V +4Bfzcbs4mfSxjeQlG2G2PkHR0aKddIgUIhvqDH0gLOhWlj0uO+Xi3IGvR2QaYQPc +wHFIWW04w+mUOFjAV6QvvCg1cwUgDEycNa5Lt1nvESksDA18f0P3YjiXNKtD1OvH +AM91baBYa+LZ67vtbhioVCDJ2BsqYUcDMNRMDTUs2YpmQBIFwtSiIucsEyZViAMw +fh+jiiP7b8n85k24a/kMr11EKvICGdjd/z/1vwnOg95EKaBE70hTs5tn/QIDAQAB +o2MwYTAdBgNVHQ4EFgQUiUCSKpRUaRAvTTLnm2U2t/C8ZNUwHwYDVR0jBBgwFoAU +iUCSKpRUaRAvTTLnm2U2t/C8ZNUwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8E +BAMCAuQwDQYJKoZIhvcNAQELBQADggEBAFYU69yV334eE2i93VyIs/sXpvuX7ZGd +EXn3SwQ+hlo4Bm2Diabs6Z/4AC0CKyA8vzTJ7Hp7qb77/cjlno25/uR76vUJQEp2 +LSWWeN80Mzzn3tOLjVd5wew5tcGZ97j/4aaDWSg/6geRfo4SuMHkahFe3V8JzE1O +vtpIvkb7q+K6B0GR/IIr4bub6dAKsVQVIQozUmmRsQU7lmQXurdkq9u1XLZKLF6J +A2j1ORzFpCMFfvXW3yACTUbmGKvdTWoEnhSaU45hJ9KA9+SYS3xR/CGgjHRSvJRV +O2D83nPDnIk8dN5PW0NWpyQvmotsjv89kBrSanL8yMoD8FnClJnMSSQ= +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDQjCCAiqgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwPTELMAkGA1UEBhMCQkUx +DjAMBgNVBAoMBWlUZXh0MR4wHAYDVQQDDBVpVGV4dFRlc3RJbnRlcm1lZGlhdGUw +IBcNMDAwMTAxMDAwMDAwWhgPMjQwMDAxMDEwMDAwMDBaMDUxCzAJBgNVBAYTAkJF +MQ4wDAYDVQQKDAVpVGV4dDEWMBQGA1UEAwwNaVRleHRUZXN0U2lnbjCCASIwDQYJ +KoZIhvcNAQEBBQADggEPADCCAQoCggEBALMHHzTZo1BOQkZzEZl2Q3leNfBH20Yf +O4R0l0ZBWbnpg/099ON4I8ItO0f24Wq0gs//+1adlJqeUMeUVxQ0fpu0cHQOc9h7 +CWJLnPAJjEvItZ5WXW4l8/ppo1bo4WLB1hToF42NfHgh7Laoj2gqVLWXS6Ngd8ch +VxITaxfKA9PG56dje+PlJnTNi+ayudB/O57dhoaAu+sbxBhog/7zRAV87OsH9zxc +Nuw+3ZzHhss5Lpn6F+/WDcHPyXsT7QkX6rvbRvxUOpcysXtCH3v5+ZRKyUqRPlI6 +3/hyMMZBDqYtFDHiawk587hbMp2swHF6z56d10Za22Vq9lxiX4MdftsCAwEAAaNS +MFAwHQYDVR0OBBYEFFVqj/1gRbt6YJdo1/zMvcyOmY1cMB8GA1UdIwQYMBaAFIlA +kiqUVGkQL00y55tlNrfwvGTVMA4GA1UdDwEB/wQEAwIGwDANBgkqhkiG9w0BAQsF +AAOCAQEAMsIeJp6AHJwChOEddcGu5dD/Q4R6l7dMIe3Q8g8vDVz94572jmvHIOa5 +Q/xJALRFn5rG1oC06q6Gy4ffbUm5S1dNBXdmwyfNzAa5yAwXraIWkXLPM5zFUueB +qu2ekfPhHq0NjCqhVCCYkhngaf+mqeuw8usML6mMf8o0aC6TlQu7GXm/6Z4SSKmY +wDyM4iSVR3fZHb3R/VBP7+GNKsamapZPThdxueWnm6o2vsMKSfgGHRV/41BrUqb7 +t5SXDihXCImTpUr89EL7kix42Q/BFQ60hO3LYsKn4w8gjUQffQdlB2zR6cQJx2eK +9jrkP1+J6xcuWHHrn2l9YXw6rI7r0g== +-----END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/crlIssuerAndSignCertHaveNoSharedRoot/crl-issuer.cert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/crlIssuerAndSignCertHaveNoSharedRoot/crl-issuer.cert.pem new file mode 100644 index 0000000000..956cf849d3 --- /dev/null +++ b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/crlIssuerAndSignCertHaveNoSharedRoot/crl-issuer.cert.pem @@ -0,0 +1,21 @@ +-----BEGIN CERTIFICATE----- +MIIDijCCAnKgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwOjELMAkGA1UEBhMCQkUx +DjAMBgNVBAoMBWlUZXh0MRswGQYDVQQDDBJpVGV4dE90aGVyVGVzdFJvb3QwIBcN +MDAwMTAxMDAwMDAwWhgPMjQ1MDAxMDEwMDAwMDBaMDoxCzAJBgNVBAYTAkJFMQ4w +DAYDVQQKDAVpVGV4dDEbMBkGA1UEAwwSaVRleHRUZXN0Q3JsSXNzdWVyMIIBIjAN +BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwnsONfztmnDdLJKbWd8sE/2txomx +72HBnrBM3G2bLpGfcvAFm9n/F0WLf1dPDYY94JAFKsBGG0Enh4eBJ753ZHgug/qw +DIiF5DnRH57e2EtoJWwXjeSm5KLIsaWcUsUGHJDfS8SfWDqOIDCp+qm2mv1M98po +KsIo4lRHyM4XDL5ERGUAYklA0h5noHP1V1JnCQ0/4Z+j4dX0tfTnsxp4wA+Cu8Am +sfL+UP3LTu7Soo3rbHMtn8yf12j7eohMRTX71eRf1fR1Nes0wA72RPe6RHpd1kiX +yW8P/Y+BNNpqujnW/R6LcjsVlc2iSPK4XonwBExXGp44yVVQjEt4G/uPrQIDAQAB +o4GXMIGUMB0GA1UdDgQWBBQSbqEw8HXXDUnva1e6YGF7DBbGdTAfBgNVHSMEGDAW +gBSJQJIqlFRpEC9NMuebZTa38Lxk1TAOBgNVHQ8BAf8EBAMCAcIwQgYDVR0fBDsw +OTA3oDWgM4YxaHR0cDovL2xvY2FsaG9zdC50ZXN0L2RlZmF1bHQvY3Jscy9jcmwv +bGF0ZXN0LmNybDANBgkqhkiG9w0BAQsFAAOCAQEAY6Ql0oP20FsZrtKyLVFYJSkL +c3R4mTRHJ5JbrgtPSLkLDxN3QGssgwmhZUyf8TvaCYVBomedFvOVd3xizmQPcAkD +yDeX7XTvkrg9aSaGyjtKcOduk8eVHyPvAnFZ4eJ7m0vYJThLeVlupRYKnMcVR9AA +HMxKk+YTTaTr6o2zWE63vbzkdAvJTYuVzfDw2Qo+6IeAGL3jD9ipa6+krN/h6z8k +EPun+ndDEijo9TcPv+pPT+DHcXiWcLCQFi7611h4ErvFtUJoDl3xoTMsgqMKRzJJ +46HaLTKqkLikI/s4bKZ23brDHUYzpFCHs5WkQpRfdq6jHek9lBHNRK+tp66s6w== +-----END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/crlIssuerAndSignCertHaveNoSharedRoot/intermediate.cert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/crlIssuerAndSignCertHaveNoSharedRoot/intermediate.cert.pem new file mode 100644 index 0000000000..ca4cf7ba9c --- /dev/null +++ b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/crlIssuerAndSignCertHaveNoSharedRoot/intermediate.cert.pem @@ -0,0 +1,20 @@ +-----BEGIN CERTIFICATE----- +MIIDQjCCAiqgAwIBAgICEAEwDQYJKoZIhvcNAQELBQAwNTELMAkGA1UEBhMCQkUx +DjAMBgNVBAoMBWlUZXh0MRYwFAYDVQQDDA1pVGV4dFRlc3RSb290MCAXDTAwMDEw +MTAwMDAwMFoYDzI0NTAwMTAxMDAwMDAwWjA9MQswCQYDVQQGEwJCRTEOMAwGA1UE +CgwFaVRleHQxHjAcBgNVBAMMFWlUZXh0VGVzdEludGVybWVkaWF0ZTCCASIwDQYJ +KoZIhvcNAQEBBQADggEPADCCAQoCggEBAJ6M9OSQgx20Fw14rYFeM6HQuQxBD276 +e6kXMpmdsbbkvExq5mrAWPvFGYHCmRAtH7pGm1pL91Zlgh1CbUPzwSa/Lfp9FeAX +83G7OJn0sY3kJRthtj5B0dGinXSIFCIb6gx9ICzoVpY9Ljvl4tyBr0dkGmED3MBx +SFltOMPplDhYwFekL7woNXMFIAxMnDWuS7dZ7xEpLAwNfH9D92I4lzSrQ9TrxwDP +dW2gWGvi2eu77W4YqFQgydgbKmFHAzDUTA01LNmKZkASBcLUoiLnLBMmVYgDMH4f +o4oj+2/J/OZNuGv5DK9dRCryAhnY3f8/9b8JzoPeRCmgRO9IU7ObZ/0CAwEAAaNS +MFAwHQYDVR0OBBYEFIlAkiqUVGkQL00y55tlNrfwvGTVMB8GA1UdIwQYMBaAFHQy +VMXAXOiryY9W6wOMgScvlq+rMA4GA1UdDwEB/wQEAwIB5jANBgkqhkiG9w0BAQsF +AAOCAQEAMoIJ86nzczzR41l5EFHlxGvUEQY/w7BJ42LICN3F12WPmJ+A3i/GAJSQ +14W+Jy8CXEhEFZF3R45vuOAGhOkF7igtbXeeVXunM3rmi8XIlpGjqbBZxC5w1Fd8 +IPOTArrzcF8agwthRzKOEpFSklmpUDT4MYZkdzR7TVM6TkdL+ModYFrhf9/+OFGb +qHzKUPVv+dvNaKn6JvKfQ311MKG3fLU7vyKEUNoolAnLMy3VETsnhMTk6Wa5rfzJ +eq2sdBiLxgwC3xhYk33Cla0X3hsr++Yqb8BX1ztKaRxu0PSi+KKJ9kvXAxRkFlwh +Xa7iIRXelUhftWRF/4VgDsDhWx+eDQ== +-----END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/crlIssuerAndSignCertHaveNoSharedRoot/otherca.cert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/crlIssuerAndSignCertHaveNoSharedRoot/otherca.cert.pem new file mode 100644 index 0000000000..046922df36 --- /dev/null +++ b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/crlIssuerAndSignCertHaveNoSharedRoot/otherca.cert.pem @@ -0,0 +1,20 @@ +-----BEGIN CERTIFICATE----- +MIIDVTCCAj2gAwIBAgICEAEwDQYJKoZIhvcNAQELBQAwOjELMAkGA1UEBhMCQkUx +DjAMBgNVBAoMBWlUZXh0MRswGQYDVQQDDBJpVGV4dE90aGVyVGVzdFJvb3QwIBcN +MDAwMTAxMDAwMDAwWhgPMjUwMDAxMDEwMDAwMDBaMDoxCzAJBgNVBAYTAkJFMQ4w +DAYDVQQKDAVpVGV4dDEbMBkGA1UEAwwSaVRleHRPdGhlclRlc3RSb290MIIBIjAN +BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnoz05JCDHbQXDXitgV4zodC5DEEP +bvp7qRcymZ2xtuS8TGrmasBY+8UZgcKZEC0fukabWkv3VmWCHUJtQ/PBJr8t+n0V +4Bfzcbs4mfSxjeQlG2G2PkHR0aKddIgUIhvqDH0gLOhWlj0uO+Xi3IGvR2QaYQPc +wHFIWW04w+mUOFjAV6QvvCg1cwUgDEycNa5Lt1nvESksDA18f0P3YjiXNKtD1OvH +AM91baBYa+LZ67vtbhioVCDJ2BsqYUcDMNRMDTUs2YpmQBIFwtSiIucsEyZViAMw +fh+jiiP7b8n85k24a/kMr11EKvICGdjd/z/1vwnOg95EKaBE70hTs5tn/QIDAQAB +o2MwYTAdBgNVHQ4EFgQUiUCSKpRUaRAvTTLnm2U2t/C8ZNUwHwYDVR0jBBgwFoAU +iUCSKpRUaRAvTTLnm2U2t/C8ZNUwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8E +BAMCAuQwDQYJKoZIhvcNAQELBQADggEBAFYU69yV334eE2i93VyIs/sXpvuX7ZGd +EXn3SwQ+hlo4Bm2Diabs6Z/4AC0CKyA8vzTJ7Hp7qb77/cjlno25/uR76vUJQEp2 +LSWWeN80Mzzn3tOLjVd5wew5tcGZ97j/4aaDWSg/6geRfo4SuMHkahFe3V8JzE1O +vtpIvkb7q+K6B0GR/IIr4bub6dAKsVQVIQozUmmRsQU7lmQXurdkq9u1XLZKLF6J +A2j1ORzFpCMFfvXW3yACTUbmGKvdTWoEnhSaU45hJ9KA9+SYS3xR/CGgjHRSvJRV +O2D83nPDnIk8dN5PW0NWpyQvmotsjv89kBrSanL8yMoD8FnClJnMSSQ= +-----END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/crlIssuerAndSignCertHaveNoSharedRoot/sign.cert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/crlIssuerAndSignCertHaveNoSharedRoot/sign.cert.pem new file mode 100644 index 0000000000..bfcfbf0242 --- /dev/null +++ b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/crlIssuerAndSignCertHaveNoSharedRoot/sign.cert.pem @@ -0,0 +1,20 @@ +-----BEGIN CERTIFICATE----- +MIIDQjCCAiqgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwPTELMAkGA1UEBhMCQkUx +DjAMBgNVBAoMBWlUZXh0MR4wHAYDVQQDDBVpVGV4dFRlc3RJbnRlcm1lZGlhdGUw +IBcNMDAwMTAxMDAwMDAwWhgPMjQwMDAxMDEwMDAwMDBaMDUxCzAJBgNVBAYTAkJF +MQ4wDAYDVQQKDAVpVGV4dDEWMBQGA1UEAwwNaVRleHRUZXN0U2lnbjCCASIwDQYJ +KoZIhvcNAQEBBQADggEPADCCAQoCggEBALMHHzTZo1BOQkZzEZl2Q3leNfBH20Yf +O4R0l0ZBWbnpg/099ON4I8ItO0f24Wq0gs//+1adlJqeUMeUVxQ0fpu0cHQOc9h7 +CWJLnPAJjEvItZ5WXW4l8/ppo1bo4WLB1hToF42NfHgh7Laoj2gqVLWXS6Ngd8ch +VxITaxfKA9PG56dje+PlJnTNi+ayudB/O57dhoaAu+sbxBhog/7zRAV87OsH9zxc +Nuw+3ZzHhss5Lpn6F+/WDcHPyXsT7QkX6rvbRvxUOpcysXtCH3v5+ZRKyUqRPlI6 +3/hyMMZBDqYtFDHiawk587hbMp2swHF6z56d10Za22Vq9lxiX4MdftsCAwEAAaNS +MFAwHQYDVR0OBBYEFFVqj/1gRbt6YJdo1/zMvcyOmY1cMB8GA1UdIwQYMBaAFIlA +kiqUVGkQL00y55tlNrfwvGTVMA4GA1UdDwEB/wQEAwIGwDANBgkqhkiG9w0BAQsF +AAOCAQEAMsIeJp6AHJwChOEddcGu5dD/Q4R6l7dMIe3Q8g8vDVz94572jmvHIOa5 +Q/xJALRFn5rG1oC06q6Gy4ffbUm5S1dNBXdmwyfNzAa5yAwXraIWkXLPM5zFUueB +qu2ekfPhHq0NjCqhVCCYkhngaf+mqeuw8usML6mMf8o0aC6TlQu7GXm/6Z4SSKmY +wDyM4iSVR3fZHb3R/VBP7+GNKsamapZPThdxueWnm6o2vsMKSfgGHRV/41BrUqb7 +t5SXDihXCImTpUr89EL7kix42Q/BFQ60hO3LYsKn4w8gjUQffQdlB2zR6cQJx2eK +9jrkP1+J6xcuWHHrn2l9YXw6rI7r0g== +-----END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/crlIssuerRevokedBeforeSigningDate.yml b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/crlIssuerRevokedBeforeSigningDate.yml similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/crlIssuerRevokedBeforeSigningDate.yml rename to sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/crlIssuerRevokedBeforeSigningDate.yml diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/crlIssuerRevokedBeforeSigningDate/ca.cert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/crlIssuerRevokedBeforeSigningDate/ca.cert.pem new file mode 100644 index 0000000000..efb7717302 --- /dev/null +++ b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/crlIssuerRevokedBeforeSigningDate/ca.cert.pem @@ -0,0 +1,20 @@ +-----BEGIN CERTIFICATE----- +MIIDSzCCAjOgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwNTELMAkGA1UEBhMCQkUx +DjAMBgNVBAoMBWlUZXh0MRYwFAYDVQQDDA1pVGV4dFRlc3RSb290MCAXDTAwMDEw +MTAwMDAwMFoYDzI1MDAwMTAxMDAwMDAwWjA1MQswCQYDVQQGEwJCRTEOMAwGA1UE +CgwFaVRleHQxFjAUBgNVBAMMDWlUZXh0VGVzdFJvb3QwggEiMA0GCSqGSIb3DQEB +AQUAA4IBDwAwggEKAoIBAQDYxUs+SgZkRkOhOfddCnPeuE1QP2kAm6gAsg4qjNzr +rZpZvwziyWaz6bXXq8fATjXEAdypAiWL/BDZscdCM/M11jds9mMv7dMvCtLns6Oe +4GbChYxxloN2rVxElFPK2siKBaEeWyItr2Ms0P+hSR5uHjFt+krzl2zv828fyEnH +fPvln42SAcuCKsLmfjtutus5jFKBFF8oiqDFlI2eXYggKV7JELttgPLobv2ZyFa5 +nXo/xbtzlPb8AvV3/mxpX4prFhBXupJXuCwmqmzVRqGbwKSz/Bewb/4aJGSpg32x +yIWeXTld58f+Jntfes8xHwK0aJB/Tm2WrH+RWoV+TN/pAgMBAAGjYzBhMB0GA1Ud +DgQWBBR0MlTFwFzoq8mPVusDjIEnL5avqzAfBgNVHSMEGDAWgBR0MlTFwFzoq8mP +VusDjIEnL5avqzAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIC5DANBgkq +hkiG9w0BAQsFAAOCAQEAK2dbxbQ7jEdtqvnMpKOZsB55PDO5OZ2hPYilT5ZVZNt1 +jdE94HdCBHED3upmOeBH+XtsK/MLk+eYICM5SZwWVCBY0aQQR0URyTsX4SA/12A5 +VhrnP6bqy4b+3mO3J9s0go59cZOtSkxQ7191teEQMsDeh8GxXGLW/7Tf4x6v7U34 +B7UghMhUD2bHJ7U8MOqto9fVar/9S93tc9vRtYOXZbfRwjFKOYD4IFm7cH3VnrX7 +od3KUEKGKhQ2ZaqrtnW19xNTbdRcMT3+8QSai9DLV0kGGSSY09AHDO3WvxkAs9ZI +cIsMM/n+mLK0Km9fh5uE3k6NmiN3GV+QMyjbmFnVNg== +-----END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/crlIssuerRevokedBeforeSigningDate/chain.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/crlIssuerRevokedBeforeSigningDate/chain.pem new file mode 100644 index 0000000000..2965925da3 --- /dev/null +++ b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/crlIssuerRevokedBeforeSigningDate/chain.pem @@ -0,0 +1,81 @@ +-----BEGIN CERTIFICATE----- +MIIDSzCCAjOgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwNTELMAkGA1UEBhMCQkUx +DjAMBgNVBAoMBWlUZXh0MRYwFAYDVQQDDA1pVGV4dFRlc3RSb290MCAXDTAwMDEw +MTAwMDAwMFoYDzI1MDAwMTAxMDAwMDAwWjA1MQswCQYDVQQGEwJCRTEOMAwGA1UE +CgwFaVRleHQxFjAUBgNVBAMMDWlUZXh0VGVzdFJvb3QwggEiMA0GCSqGSIb3DQEB +AQUAA4IBDwAwggEKAoIBAQDYxUs+SgZkRkOhOfddCnPeuE1QP2kAm6gAsg4qjNzr +rZpZvwziyWaz6bXXq8fATjXEAdypAiWL/BDZscdCM/M11jds9mMv7dMvCtLns6Oe +4GbChYxxloN2rVxElFPK2siKBaEeWyItr2Ms0P+hSR5uHjFt+krzl2zv828fyEnH +fPvln42SAcuCKsLmfjtutus5jFKBFF8oiqDFlI2eXYggKV7JELttgPLobv2ZyFa5 +nXo/xbtzlPb8AvV3/mxpX4prFhBXupJXuCwmqmzVRqGbwKSz/Bewb/4aJGSpg32x +yIWeXTld58f+Jntfes8xHwK0aJB/Tm2WrH+RWoV+TN/pAgMBAAGjYzBhMB0GA1Ud +DgQWBBR0MlTFwFzoq8mPVusDjIEnL5avqzAfBgNVHSMEGDAWgBR0MlTFwFzoq8mP +VusDjIEnL5avqzAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIC5DANBgkq +hkiG9w0BAQsFAAOCAQEAK2dbxbQ7jEdtqvnMpKOZsB55PDO5OZ2hPYilT5ZVZNt1 +jdE94HdCBHED3upmOeBH+XtsK/MLk+eYICM5SZwWVCBY0aQQR0URyTsX4SA/12A5 +VhrnP6bqy4b+3mO3J9s0go59cZOtSkxQ7191teEQMsDeh8GxXGLW/7Tf4x6v7U34 +B7UghMhUD2bHJ7U8MOqto9fVar/9S93tc9vRtYOXZbfRwjFKOYD4IFm7cH3VnrX7 +od3KUEKGKhQ2ZaqrtnW19xNTbdRcMT3+8QSai9DLV0kGGSSY09AHDO3WvxkAs9ZI +cIsMM/n+mLK0Km9fh5uE3k6NmiN3GV+QMyjbmFnVNg== +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDiTCCAnGgAwIBAgICEAIwDQYJKoZIhvcNAQELBQAwNTELMAkGA1UEBhMCQkUx +DjAMBgNVBAoMBWlUZXh0MRYwFAYDVQQDDA1pVGV4dFRlc3RSb290MCAXDTAwMDEw +MTAwMDAwMFoYDzI0NTAwMTAxMDAwMDAwWjA6MQswCQYDVQQGEwJCRTEOMAwGA1UE +CgwFaVRleHQxGzAZBgNVBAMMEmlUZXh0VGVzdENybElzc3VlcjCCASIwDQYJKoZI +hvcNAQEBBQADggEPADCCAQoCggEBAMJ7DjX87Zpw3SySm1nfLBP9rcaJse9hwZ6w +TNxtmy6Rn3LwBZvZ/xdFi39XTw2GPeCQBSrARhtBJ4eHgSe+d2R4LoP6sAyIheQ5 +0R+e3thLaCVsF43kpuSiyLGlnFLFBhyQ30vEn1g6jiAwqfqptpr9TPfKaCrCKOJU +R8jOFwy+RERlAGJJQNIeZ6Bz9VdSZwkNP+Gfo+HV9LX057MaeMAPgrvAJrHy/lD9 +y07u0qKN62xzLZ/Mn9do+3qITEU1+9XkX9X0dTXrNMAO9kT3ukR6XdZIl8lvD/2P +gTTaaro51v0ei3I7FZXNokjyuF6J8ARMVxqeOMlVUIxLeBv7j60CAwEAAaOBmzCB +mDAdBgNVHQ4EFgQUEm6hMPB11w1J72tXumBhewwWxnUwHwYDVR0jBBgwFoAUdDJU +xcBc6KvJj1brA4yBJy+Wr6swDgYDVR0PAQH/BAQDAgHCMEYGA1UdHwQ/MD0wO6A5 +oDeGNWh0dHA6Ly9sb2NhbGhvc3QudGVzdC9kZWZhdWx0L2NybHMvZGVmYXVsdC9s +YXRlc3QuY3JsMA0GCSqGSIb3DQEBCwUAA4IBAQCmoFeEZPbeDx/k45qhsk34MGkV +2mDEhE29G9qzy1FSUfQFJO0LI5nWNUyjLiYKox53MZ5+ltL8Oe5wB0r2EnepOK+U +VHNrqOL9f/weszwH5uyZLyu5+NhzZm08U9t6hxebwF6TajP8eob5PZ1dRZSSShQF +SU5mSlgBbaZGiXdvUnQhoowtmYOGnbUYrYavrQIAuTZ0A3nL0UaVlFljgecOYR2M +ovxHTO08DkrFyD22tkbGZOpLXP+B3BwhUwlhJPIl84/BzdYZCav/llrMr1CztzgW +Ox29pB8ayAXDbY7Uen9wD9fUdIXmOiDkUHsEBk46Utd8Ril628Ev4I2lhPpd +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDQjCCAiqgAwIBAgICEAEwDQYJKoZIhvcNAQELBQAwNTELMAkGA1UEBhMCQkUx +DjAMBgNVBAoMBWlUZXh0MRYwFAYDVQQDDA1pVGV4dFRlc3RSb290MCAXDTAwMDEw +MTAwMDAwMFoYDzI0NTAwMTAxMDAwMDAwWjA9MQswCQYDVQQGEwJCRTEOMAwGA1UE +CgwFaVRleHQxHjAcBgNVBAMMFWlUZXh0VGVzdEludGVybWVkaWF0ZTCCASIwDQYJ +KoZIhvcNAQEBBQADggEPADCCAQoCggEBAJ6M9OSQgx20Fw14rYFeM6HQuQxBD276 +e6kXMpmdsbbkvExq5mrAWPvFGYHCmRAtH7pGm1pL91Zlgh1CbUPzwSa/Lfp9FeAX +83G7OJn0sY3kJRthtj5B0dGinXSIFCIb6gx9ICzoVpY9Ljvl4tyBr0dkGmED3MBx +SFltOMPplDhYwFekL7woNXMFIAxMnDWuS7dZ7xEpLAwNfH9D92I4lzSrQ9TrxwDP +dW2gWGvi2eu77W4YqFQgydgbKmFHAzDUTA01LNmKZkASBcLUoiLnLBMmVYgDMH4f +o4oj+2/J/OZNuGv5DK9dRCryAhnY3f8/9b8JzoPeRCmgRO9IU7ObZ/0CAwEAAaNS +MFAwHQYDVR0OBBYEFIlAkiqUVGkQL00y55tlNrfwvGTVMB8GA1UdIwQYMBaAFHQy +VMXAXOiryY9W6wOMgScvlq+rMA4GA1UdDwEB/wQEAwIB5jANBgkqhkiG9w0BAQsF +AAOCAQEAMoIJ86nzczzR41l5EFHlxGvUEQY/w7BJ42LICN3F12WPmJ+A3i/GAJSQ +14W+Jy8CXEhEFZF3R45vuOAGhOkF7igtbXeeVXunM3rmi8XIlpGjqbBZxC5w1Fd8 +IPOTArrzcF8agwthRzKOEpFSklmpUDT4MYZkdzR7TVM6TkdL+ModYFrhf9/+OFGb +qHzKUPVv+dvNaKn6JvKfQ311MKG3fLU7vyKEUNoolAnLMy3VETsnhMTk6Wa5rfzJ +eq2sdBiLxgwC3xhYk33Cla0X3hsr++Yqb8BX1ztKaRxu0PSi+KKJ9kvXAxRkFlwh +Xa7iIRXelUhftWRF/4VgDsDhWx+eDQ== +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDQjCCAiqgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwPTELMAkGA1UEBhMCQkUx +DjAMBgNVBAoMBWlUZXh0MR4wHAYDVQQDDBVpVGV4dFRlc3RJbnRlcm1lZGlhdGUw +IBcNMDAwMTAxMDAwMDAwWhgPMjQwMDAxMDEwMDAwMDBaMDUxCzAJBgNVBAYTAkJF +MQ4wDAYDVQQKDAVpVGV4dDEWMBQGA1UEAwwNaVRleHRUZXN0U2lnbjCCASIwDQYJ +KoZIhvcNAQEBBQADggEPADCCAQoCggEBALMHHzTZo1BOQkZzEZl2Q3leNfBH20Yf +O4R0l0ZBWbnpg/099ON4I8ItO0f24Wq0gs//+1adlJqeUMeUVxQ0fpu0cHQOc9h7 +CWJLnPAJjEvItZ5WXW4l8/ppo1bo4WLB1hToF42NfHgh7Laoj2gqVLWXS6Ngd8ch +VxITaxfKA9PG56dje+PlJnTNi+ayudB/O57dhoaAu+sbxBhog/7zRAV87OsH9zxc +Nuw+3ZzHhss5Lpn6F+/WDcHPyXsT7QkX6rvbRvxUOpcysXtCH3v5+ZRKyUqRPlI6 +3/hyMMZBDqYtFDHiawk587hbMp2swHF6z56d10Za22Vq9lxiX4MdftsCAwEAAaNS +MFAwHQYDVR0OBBYEFFVqj/1gRbt6YJdo1/zMvcyOmY1cMB8GA1UdIwQYMBaAFIlA +kiqUVGkQL00y55tlNrfwvGTVMA4GA1UdDwEB/wQEAwIGwDANBgkqhkiG9w0BAQsF +AAOCAQEAMsIeJp6AHJwChOEddcGu5dD/Q4R6l7dMIe3Q8g8vDVz94572jmvHIOa5 +Q/xJALRFn5rG1oC06q6Gy4ffbUm5S1dNBXdmwyfNzAa5yAwXraIWkXLPM5zFUueB +qu2ekfPhHq0NjCqhVCCYkhngaf+mqeuw8usML6mMf8o0aC6TlQu7GXm/6Z4SSKmY +wDyM4iSVR3fZHb3R/VBP7+GNKsamapZPThdxueWnm6o2vsMKSfgGHRV/41BrUqb7 +t5SXDihXCImTpUr89EL7kix42Q/BFQ60hO3LYsKn4w8gjUQffQdlB2zR6cQJx2eK +9jrkP1+J6xcuWHHrn2l9YXw6rI7r0g== +-----END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/crlIssuerRevokedBeforeSigningDate/crl-issuer.cert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/crlIssuerRevokedBeforeSigningDate/crl-issuer.cert.pem new file mode 100644 index 0000000000..f29734904d --- /dev/null +++ b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/crlIssuerRevokedBeforeSigningDate/crl-issuer.cert.pem @@ -0,0 +1,21 @@ +-----BEGIN CERTIFICATE----- +MIIDiTCCAnGgAwIBAgICEAIwDQYJKoZIhvcNAQELBQAwNTELMAkGA1UEBhMCQkUx +DjAMBgNVBAoMBWlUZXh0MRYwFAYDVQQDDA1pVGV4dFRlc3RSb290MCAXDTAwMDEw +MTAwMDAwMFoYDzI0NTAwMTAxMDAwMDAwWjA6MQswCQYDVQQGEwJCRTEOMAwGA1UE +CgwFaVRleHQxGzAZBgNVBAMMEmlUZXh0VGVzdENybElzc3VlcjCCASIwDQYJKoZI +hvcNAQEBBQADggEPADCCAQoCggEBAMJ7DjX87Zpw3SySm1nfLBP9rcaJse9hwZ6w +TNxtmy6Rn3LwBZvZ/xdFi39XTw2GPeCQBSrARhtBJ4eHgSe+d2R4LoP6sAyIheQ5 +0R+e3thLaCVsF43kpuSiyLGlnFLFBhyQ30vEn1g6jiAwqfqptpr9TPfKaCrCKOJU +R8jOFwy+RERlAGJJQNIeZ6Bz9VdSZwkNP+Gfo+HV9LX057MaeMAPgrvAJrHy/lD9 +y07u0qKN62xzLZ/Mn9do+3qITEU1+9XkX9X0dTXrNMAO9kT3ukR6XdZIl8lvD/2P +gTTaaro51v0ei3I7FZXNokjyuF6J8ARMVxqeOMlVUIxLeBv7j60CAwEAAaOBmzCB +mDAdBgNVHQ4EFgQUEm6hMPB11w1J72tXumBhewwWxnUwHwYDVR0jBBgwFoAUdDJU +xcBc6KvJj1brA4yBJy+Wr6swDgYDVR0PAQH/BAQDAgHCMEYGA1UdHwQ/MD0wO6A5 +oDeGNWh0dHA6Ly9sb2NhbGhvc3QudGVzdC9kZWZhdWx0L2NybHMvZGVmYXVsdC9s +YXRlc3QuY3JsMA0GCSqGSIb3DQEBCwUAA4IBAQCmoFeEZPbeDx/k45qhsk34MGkV +2mDEhE29G9qzy1FSUfQFJO0LI5nWNUyjLiYKox53MZ5+ltL8Oe5wB0r2EnepOK+U +VHNrqOL9f/weszwH5uyZLyu5+NhzZm08U9t6hxebwF6TajP8eob5PZ1dRZSSShQF +SU5mSlgBbaZGiXdvUnQhoowtmYOGnbUYrYavrQIAuTZ0A3nL0UaVlFljgecOYR2M +ovxHTO08DkrFyD22tkbGZOpLXP+B3BwhUwlhJPIl84/BzdYZCav/llrMr1CztzgW +Ox29pB8ayAXDbY7Uen9wD9fUdIXmOiDkUHsEBk46Utd8Ril628Ev4I2lhPpd +-----END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/crlIssuerRevokedBeforeSigningDate/intermediate.cert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/crlIssuerRevokedBeforeSigningDate/intermediate.cert.pem new file mode 100644 index 0000000000..ca4cf7ba9c --- /dev/null +++ b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/crlIssuerRevokedBeforeSigningDate/intermediate.cert.pem @@ -0,0 +1,20 @@ +-----BEGIN CERTIFICATE----- +MIIDQjCCAiqgAwIBAgICEAEwDQYJKoZIhvcNAQELBQAwNTELMAkGA1UEBhMCQkUx +DjAMBgNVBAoMBWlUZXh0MRYwFAYDVQQDDA1pVGV4dFRlc3RSb290MCAXDTAwMDEw +MTAwMDAwMFoYDzI0NTAwMTAxMDAwMDAwWjA9MQswCQYDVQQGEwJCRTEOMAwGA1UE +CgwFaVRleHQxHjAcBgNVBAMMFWlUZXh0VGVzdEludGVybWVkaWF0ZTCCASIwDQYJ +KoZIhvcNAQEBBQADggEPADCCAQoCggEBAJ6M9OSQgx20Fw14rYFeM6HQuQxBD276 +e6kXMpmdsbbkvExq5mrAWPvFGYHCmRAtH7pGm1pL91Zlgh1CbUPzwSa/Lfp9FeAX +83G7OJn0sY3kJRthtj5B0dGinXSIFCIb6gx9ICzoVpY9Ljvl4tyBr0dkGmED3MBx +SFltOMPplDhYwFekL7woNXMFIAxMnDWuS7dZ7xEpLAwNfH9D92I4lzSrQ9TrxwDP +dW2gWGvi2eu77W4YqFQgydgbKmFHAzDUTA01LNmKZkASBcLUoiLnLBMmVYgDMH4f +o4oj+2/J/OZNuGv5DK9dRCryAhnY3f8/9b8JzoPeRCmgRO9IU7ObZ/0CAwEAAaNS +MFAwHQYDVR0OBBYEFIlAkiqUVGkQL00y55tlNrfwvGTVMB8GA1UdIwQYMBaAFHQy +VMXAXOiryY9W6wOMgScvlq+rMA4GA1UdDwEB/wQEAwIB5jANBgkqhkiG9w0BAQsF +AAOCAQEAMoIJ86nzczzR41l5EFHlxGvUEQY/w7BJ42LICN3F12WPmJ+A3i/GAJSQ +14W+Jy8CXEhEFZF3R45vuOAGhOkF7igtbXeeVXunM3rmi8XIlpGjqbBZxC5w1Fd8 +IPOTArrzcF8agwthRzKOEpFSklmpUDT4MYZkdzR7TVM6TkdL+ModYFrhf9/+OFGb +qHzKUPVv+dvNaKn6JvKfQ311MKG3fLU7vyKEUNoolAnLMy3VETsnhMTk6Wa5rfzJ +eq2sdBiLxgwC3xhYk33Cla0X3hsr++Yqb8BX1ztKaRxu0PSi+KKJ9kvXAxRkFlwh +Xa7iIRXelUhftWRF/4VgDsDhWx+eDQ== +-----END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/crlIssuerRevokedBeforeSigningDate/sign.cert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/crlIssuerRevokedBeforeSigningDate/sign.cert.pem new file mode 100644 index 0000000000..bfcfbf0242 --- /dev/null +++ b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/crlIssuerRevokedBeforeSigningDate/sign.cert.pem @@ -0,0 +1,20 @@ +-----BEGIN CERTIFICATE----- +MIIDQjCCAiqgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwPTELMAkGA1UEBhMCQkUx +DjAMBgNVBAoMBWlUZXh0MR4wHAYDVQQDDBVpVGV4dFRlc3RJbnRlcm1lZGlhdGUw +IBcNMDAwMTAxMDAwMDAwWhgPMjQwMDAxMDEwMDAwMDBaMDUxCzAJBgNVBAYTAkJF +MQ4wDAYDVQQKDAVpVGV4dDEWMBQGA1UEAwwNaVRleHRUZXN0U2lnbjCCASIwDQYJ +KoZIhvcNAQEBBQADggEPADCCAQoCggEBALMHHzTZo1BOQkZzEZl2Q3leNfBH20Yf +O4R0l0ZBWbnpg/099ON4I8ItO0f24Wq0gs//+1adlJqeUMeUVxQ0fpu0cHQOc9h7 +CWJLnPAJjEvItZ5WXW4l8/ppo1bo4WLB1hToF42NfHgh7Laoj2gqVLWXS6Ngd8ch +VxITaxfKA9PG56dje+PlJnTNi+ayudB/O57dhoaAu+sbxBhog/7zRAV87OsH9zxc +Nuw+3ZzHhss5Lpn6F+/WDcHPyXsT7QkX6rvbRvxUOpcysXtCH3v5+ZRKyUqRPlI6 +3/hyMMZBDqYtFDHiawk587hbMp2swHF6z56d10Za22Vq9lxiX4MdftsCAwEAAaNS +MFAwHQYDVR0OBBYEFFVqj/1gRbt6YJdo1/zMvcyOmY1cMB8GA1UdIwQYMBaAFIlA +kiqUVGkQL00y55tlNrfwvGTVMA4GA1UdDwEB/wQEAwIGwDANBgkqhkiG9w0BAQsF +AAOCAQEAMsIeJp6AHJwChOEddcGu5dD/Q4R6l7dMIe3Q8g8vDVz94572jmvHIOa5 +Q/xJALRFn5rG1oC06q6Gy4ffbUm5S1dNBXdmwyfNzAa5yAwXraIWkXLPM5zFUueB +qu2ekfPhHq0NjCqhVCCYkhngaf+mqeuw8usML6mMf8o0aC6TlQu7GXm/6Z4SSKmY +wDyM4iSVR3fZHb3R/VBP7+GNKsamapZPThdxueWnm6o2vsMKSfgGHRV/41BrUqb7 +t5SXDihXCImTpUr89EL7kix42Q/BFQ60hO3LYsKn4w8gjUQffQdlB2zR6cQJx2eK +9jrkP1+J6xcuWHHrn2l9YXw6rI7r0g== +-----END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/crlSignerInValidatedChain.yml b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/crlSignerInValidatedChain.yml new file mode 100644 index 0000000000..141ebe7616 --- /dev/null +++ b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/crlSignerInValidatedChain.yml @@ -0,0 +1,109 @@ +external-url-prefix: "http://localhost.test" +keysets: + testkeys: + keys: + ca: + path: keys/root_key.pem + password: testpassphrase + intermediate: + path: keys/im_key.pem + password: testpassphrase + intermediate2: + path: keys/im2_key.pem + password: testpassphrase + sign: + path: keys/sign-key.pem + password: testpassphrase + crl-issuer: + path: keys/crl-key.pem + password: testpassphrase + +pki-architectures: + default: + keyset: testkeys + entity-defaults: + country-name: BE + organization-name: iText + entities: + ca: + common-name: iTextTestRoot + intermediate: + common-name: iTextTestIntermediate + intermediate2: + common-name: iTextTestIntermediate2 + sign: + common-name: iTextTestSign + crl-issuer: + common-name: iTextTestCrlIssuer + certs: + ca: + subject: ca + issuer: ca + validity: + valid-from: "2000-01-01T00:00:00+0000" + valid-to: "2500-01-01T00:00:00+0000" + extensions: + - id: basic_constraints + critical: true + value: + ca: true + - id: key_usage + critical: true + smart-value: + schema: key-usage + params: [digital_signature, non_repudiation, key_encipherment, key_cert_sign] + intermediate: + issuer: ca + validity: + valid-from: "2000-01-01T00:00:00+0000" + valid-to: "2450-01-01T00:00:00+0000" + extensions: + - id: key_usage + critical: true + smart-value: + schema: key-usage + params: [digital_signature, non_repudiation, key_encipherment, key_cert_sign, crl_sign] + intermediate2: + issuer: intermediate + validity: + valid-from: "2000-01-01T00:00:00+0000" + valid-to: "2450-01-01T00:00:00+0000" + extensions: + - id: key_usage + critical: true + smart-value: + schema: key-usage + params: [ digital_signature, non_repudiation, key_encipherment, key_cert_sign, crl_sign ] + sign: + issuer: intermediate2 + validity: + valid-from: "2000-01-01T00:00:00+0000" + valid-to: "2400-01-01T00:00:00+0000" + extensions: + - id: key_usage + critical: true + smart-value: + schema: key-usage + params: [digital_signature, non_repudiation] + crl-issuer: + issuer: intermediate + validity: + valid-from: "2000-01-01T00:00:00+0000" + valid-to: "2450-01-01T00:00:00+0000" + extensions: + - id: key_usage + critical: true + smart-value: + schema: key-usage + params: [ digital_signature, non_repudiation, crl_sign] + - id: crl_distribution_points + smart-value: + schema: crl-dist-url + params: + crl-repo-names: [crl] + services: + crl-repo: + crl: + for-issuer: crl-issuer + signing-key: crl-issuer + simulated-update-schedule: "P90D" \ No newline at end of file diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/crlSignerInValidatedChain/ca.cert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/crlSignerInValidatedChain/ca.cert.pem new file mode 100644 index 0000000000..efb7717302 --- /dev/null +++ b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/crlSignerInValidatedChain/ca.cert.pem @@ -0,0 +1,20 @@ +-----BEGIN CERTIFICATE----- +MIIDSzCCAjOgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwNTELMAkGA1UEBhMCQkUx +DjAMBgNVBAoMBWlUZXh0MRYwFAYDVQQDDA1pVGV4dFRlc3RSb290MCAXDTAwMDEw +MTAwMDAwMFoYDzI1MDAwMTAxMDAwMDAwWjA1MQswCQYDVQQGEwJCRTEOMAwGA1UE +CgwFaVRleHQxFjAUBgNVBAMMDWlUZXh0VGVzdFJvb3QwggEiMA0GCSqGSIb3DQEB +AQUAA4IBDwAwggEKAoIBAQDYxUs+SgZkRkOhOfddCnPeuE1QP2kAm6gAsg4qjNzr +rZpZvwziyWaz6bXXq8fATjXEAdypAiWL/BDZscdCM/M11jds9mMv7dMvCtLns6Oe +4GbChYxxloN2rVxElFPK2siKBaEeWyItr2Ms0P+hSR5uHjFt+krzl2zv828fyEnH +fPvln42SAcuCKsLmfjtutus5jFKBFF8oiqDFlI2eXYggKV7JELttgPLobv2ZyFa5 +nXo/xbtzlPb8AvV3/mxpX4prFhBXupJXuCwmqmzVRqGbwKSz/Bewb/4aJGSpg32x +yIWeXTld58f+Jntfes8xHwK0aJB/Tm2WrH+RWoV+TN/pAgMBAAGjYzBhMB0GA1Ud +DgQWBBR0MlTFwFzoq8mPVusDjIEnL5avqzAfBgNVHSMEGDAWgBR0MlTFwFzoq8mP +VusDjIEnL5avqzAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIC5DANBgkq +hkiG9w0BAQsFAAOCAQEAK2dbxbQ7jEdtqvnMpKOZsB55PDO5OZ2hPYilT5ZVZNt1 +jdE94HdCBHED3upmOeBH+XtsK/MLk+eYICM5SZwWVCBY0aQQR0URyTsX4SA/12A5 +VhrnP6bqy4b+3mO3J9s0go59cZOtSkxQ7191teEQMsDeh8GxXGLW/7Tf4x6v7U34 +B7UghMhUD2bHJ7U8MOqto9fVar/9S93tc9vRtYOXZbfRwjFKOYD4IFm7cH3VnrX7 +od3KUEKGKhQ2ZaqrtnW19xNTbdRcMT3+8QSai9DLV0kGGSSY09AHDO3WvxkAs9ZI +cIsMM/n+mLK0Km9fh5uE3k6NmiN3GV+QMyjbmFnVNg== +-----END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/crlSignerInValidatedChain/chain.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/crlSignerInValidatedChain/chain.pem new file mode 100644 index 0000000000..eb0c61e73a --- /dev/null +++ b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/crlSignerInValidatedChain/chain.pem @@ -0,0 +1,102 @@ +-----BEGIN CERTIFICATE----- +MIIDSzCCAjOgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwNTELMAkGA1UEBhMCQkUx +DjAMBgNVBAoMBWlUZXh0MRYwFAYDVQQDDA1pVGV4dFRlc3RSb290MCAXDTAwMDEw +MTAwMDAwMFoYDzI1MDAwMTAxMDAwMDAwWjA1MQswCQYDVQQGEwJCRTEOMAwGA1UE +CgwFaVRleHQxFjAUBgNVBAMMDWlUZXh0VGVzdFJvb3QwggEiMA0GCSqGSIb3DQEB +AQUAA4IBDwAwggEKAoIBAQDYxUs+SgZkRkOhOfddCnPeuE1QP2kAm6gAsg4qjNzr +rZpZvwziyWaz6bXXq8fATjXEAdypAiWL/BDZscdCM/M11jds9mMv7dMvCtLns6Oe +4GbChYxxloN2rVxElFPK2siKBaEeWyItr2Ms0P+hSR5uHjFt+krzl2zv828fyEnH +fPvln42SAcuCKsLmfjtutus5jFKBFF8oiqDFlI2eXYggKV7JELttgPLobv2ZyFa5 +nXo/xbtzlPb8AvV3/mxpX4prFhBXupJXuCwmqmzVRqGbwKSz/Bewb/4aJGSpg32x +yIWeXTld58f+Jntfes8xHwK0aJB/Tm2WrH+RWoV+TN/pAgMBAAGjYzBhMB0GA1Ud +DgQWBBR0MlTFwFzoq8mPVusDjIEnL5avqzAfBgNVHSMEGDAWgBR0MlTFwFzoq8mP +VusDjIEnL5avqzAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIC5DANBgkq +hkiG9w0BAQsFAAOCAQEAK2dbxbQ7jEdtqvnMpKOZsB55PDO5OZ2hPYilT5ZVZNt1 +jdE94HdCBHED3upmOeBH+XtsK/MLk+eYICM5SZwWVCBY0aQQR0URyTsX4SA/12A5 +VhrnP6bqy4b+3mO3J9s0go59cZOtSkxQ7191teEQMsDeh8GxXGLW/7Tf4x6v7U34 +B7UghMhUD2bHJ7U8MOqto9fVar/9S93tc9vRtYOXZbfRwjFKOYD4IFm7cH3VnrX7 +od3KUEKGKhQ2ZaqrtnW19xNTbdRcMT3+8QSai9DLV0kGGSSY09AHDO3WvxkAs9ZI +cIsMM/n+mLK0Km9fh5uE3k6NmiN3GV+QMyjbmFnVNg== +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDjTCCAnWgAwIBAgICEAEwDQYJKoZIhvcNAQELBQAwPTELMAkGA1UEBhMCQkUx +DjAMBgNVBAoMBWlUZXh0MR4wHAYDVQQDDBVpVGV4dFRlc3RJbnRlcm1lZGlhdGUw +IBcNMDAwMTAxMDAwMDAwWhgPMjQ1MDAxMDEwMDAwMDBaMDoxCzAJBgNVBAYTAkJF +MQ4wDAYDVQQKDAVpVGV4dDEbMBkGA1UEAwwSaVRleHRUZXN0Q3JsSXNzdWVyMIIB +IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwnsONfztmnDdLJKbWd8sE/2t +xomx72HBnrBM3G2bLpGfcvAFm9n/F0WLf1dPDYY94JAFKsBGG0Enh4eBJ753ZHgu +g/qwDIiF5DnRH57e2EtoJWwXjeSm5KLIsaWcUsUGHJDfS8SfWDqOIDCp+qm2mv1M +98poKsIo4lRHyM4XDL5ERGUAYklA0h5noHP1V1JnCQ0/4Z+j4dX0tfTnsxp4wA+C +u8AmsfL+UP3LTu7Soo3rbHMtn8yf12j7eohMRTX71eRf1fR1Nes0wA72RPe6RHpd +1kiXyW8P/Y+BNNpqujnW/R6LcjsVlc2iSPK4XonwBExXGp44yVVQjEt4G/uPrQID +AQABo4GXMIGUMB0GA1UdDgQWBBQSbqEw8HXXDUnva1e6YGF7DBbGdTAfBgNVHSME +GDAWgBSJQJIqlFRpEC9NMuebZTa38Lxk1TAOBgNVHQ8BAf8EBAMCAcIwQgYDVR0f +BDswOTA3oDWgM4YxaHR0cDovL2xvY2FsaG9zdC50ZXN0L2RlZmF1bHQvY3Jscy9j +cmwvbGF0ZXN0LmNybDANBgkqhkiG9w0BAQsFAAOCAQEAIei53b7VB3ZL8Axad3Jt +MjjzTp4+rGrh4RneoCEMUd04CjjcNToF3uCadAaBpi6j+eYEq/FTdebVrsdwGUvT +W+GqzYlesyv9BcbIGpla2ajw8SGBxpOOUPlZdHLkFlu9X86LXf/4acRglj02HDSf +kmvz3xmKwMLmctS6PpYVYfWUFdiBBHTnPTVm4dHQCHUiwyaSxLiShO9LaFtzQSZ4 +hfH4RD112fIFtW0srEwTCZtrQkttkTdBYJPg6SorGjBDsQqK9bkACYfyBOt+9hQY +Kcb1WRX3VfnBT+l7Nwzf7X37onRrm08gUefoHHAB1lUEN63tbGYnWy0az+0UYMMn +Fw== +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDQjCCAiqgAwIBAgICEAEwDQYJKoZIhvcNAQELBQAwNTELMAkGA1UEBhMCQkUx +DjAMBgNVBAoMBWlUZXh0MRYwFAYDVQQDDA1pVGV4dFRlc3RSb290MCAXDTAwMDEw +MTAwMDAwMFoYDzI0NTAwMTAxMDAwMDAwWjA9MQswCQYDVQQGEwJCRTEOMAwGA1UE +CgwFaVRleHQxHjAcBgNVBAMMFWlUZXh0VGVzdEludGVybWVkaWF0ZTCCASIwDQYJ +KoZIhvcNAQEBBQADggEPADCCAQoCggEBAJ6M9OSQgx20Fw14rYFeM6HQuQxBD276 +e6kXMpmdsbbkvExq5mrAWPvFGYHCmRAtH7pGm1pL91Zlgh1CbUPzwSa/Lfp9FeAX +83G7OJn0sY3kJRthtj5B0dGinXSIFCIb6gx9ICzoVpY9Ljvl4tyBr0dkGmED3MBx +SFltOMPplDhYwFekL7woNXMFIAxMnDWuS7dZ7xEpLAwNfH9D92I4lzSrQ9TrxwDP +dW2gWGvi2eu77W4YqFQgydgbKmFHAzDUTA01LNmKZkASBcLUoiLnLBMmVYgDMH4f +o4oj+2/J/OZNuGv5DK9dRCryAhnY3f8/9b8JzoPeRCmgRO9IU7ObZ/0CAwEAAaNS +MFAwHQYDVR0OBBYEFIlAkiqUVGkQL00y55tlNrfwvGTVMB8GA1UdIwQYMBaAFHQy +VMXAXOiryY9W6wOMgScvlq+rMA4GA1UdDwEB/wQEAwIB5jANBgkqhkiG9w0BAQsF +AAOCAQEAMoIJ86nzczzR41l5EFHlxGvUEQY/w7BJ42LICN3F12WPmJ+A3i/GAJSQ +14W+Jy8CXEhEFZF3R45vuOAGhOkF7igtbXeeVXunM3rmi8XIlpGjqbBZxC5w1Fd8 +IPOTArrzcF8agwthRzKOEpFSklmpUDT4MYZkdzR7TVM6TkdL+ModYFrhf9/+OFGb +qHzKUPVv+dvNaKn6JvKfQ311MKG3fLU7vyKEUNoolAnLMy3VETsnhMTk6Wa5rfzJ +eq2sdBiLxgwC3xhYk33Cla0X3hsr++Yqb8BX1ztKaRxu0PSi+KKJ9kvXAxRkFlwh +Xa7iIRXelUhftWRF/4VgDsDhWx+eDQ== +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDSzCCAjOgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwPTELMAkGA1UEBhMCQkUx +DjAMBgNVBAoMBWlUZXh0MR4wHAYDVQQDDBVpVGV4dFRlc3RJbnRlcm1lZGlhdGUw +IBcNMDAwMTAxMDAwMDAwWhgPMjQ1MDAxMDEwMDAwMDBaMD4xCzAJBgNVBAYTAkJF +MQ4wDAYDVQQKDAVpVGV4dDEfMB0GA1UEAwwWaVRleHRUZXN0SW50ZXJtZWRpYXRl +MjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKN7p56CI+QpTP773pE1 +MjK9gKerROMznvSyRhyrXit89y9XbQXE4vyy136Wp3hJrNvb5oEg4np+knpRplQ/ +Z3Pypn4VsQSfN/VZHn7OsS9DUNAXpf48W8hph2/eLx8S3vs35bPdcF2PZGiy1L82 +GrEJS68lZ0iQw6KKxeGA87k1qL67uzRZq1MHHg4LSdMi5ffouGBv5oWyGQuD6AXs +aS70kKD8+Hj2Yg1lg0dM9tMGdzJ+ija4qASFo36/WouS4pcXwZUNB6kGWJJAdDbo +KzzWyaG0ygl3HtvBvrQjlERjq4PXIkDtCvA1gp0WFxNyIC/brUuaktK2V0I5uvzW +eS8CAwEAAaNSMFAwHQYDVR0OBBYEFGAHlG/vhI4aheowsOg1wfgcIpb5MB8GA1Ud +IwQYMBaAFIlAkiqUVGkQL00y55tlNrfwvGTVMA4GA1UdDwEB/wQEAwIB5jANBgkq +hkiG9w0BAQsFAAOCAQEAIiyAUyICl5tGxOkVpbdIvm7TYRGgivoUcLONpke4ypo6 +Yeh+2KmPAhIM6npUpuGIBMSsXfBVwQkWGUDHi3BMTbzO9Q5ivFx5GK68RYQryPkI +A4chJNnoxtbLJogsLpl3DxBmZc83z8RoHKbqyxOcR1NhQQXqcXz9ZxvAwfW8v6tJ +tD5IS55zBvcROB4AdH2+dVtjlHgBGniQheZ/JHI/74iXQCyiynEh3Bc54iH9qDUj +oQGY/cjDJJS6Xwqts1SCoLkpQTHO/GrAIRZwpIvTDeAVS0F16c5h+oAr4vV3iVEL +B/dPAG3gZDWO8zeOS4BF+yRYzt28zooQFNOUMUi4XQ== +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDQzCCAiugAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwPjELMAkGA1UEBhMCQkUx +DjAMBgNVBAoMBWlUZXh0MR8wHQYDVQQDDBZpVGV4dFRlc3RJbnRlcm1lZGlhdGUy +MCAXDTAwMDEwMTAwMDAwMFoYDzI0MDAwMTAxMDAwMDAwWjA1MQswCQYDVQQGEwJC +RTEOMAwGA1UECgwFaVRleHQxFjAUBgNVBAMMDWlUZXh0VGVzdFNpZ24wggEiMA0G +CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCzBx802aNQTkJGcxGZdkN5XjXwR9tG +HzuEdJdGQVm56YP9PfTjeCPCLTtH9uFqtILP//tWnZSanlDHlFcUNH6btHB0DnPY +ewliS5zwCYxLyLWeVl1uJfP6aaNW6OFiwdYU6BeNjXx4Iey2qI9oKlS1l0ujYHfH +IVcSE2sXygPTxuenY3vj5SZ0zYvmsrnQfzue3YaGgLvrG8QYaIP+80QFfOzrB/c8 +XDbsPt2cx4bLOS6Z+hfv1g3Bz8l7E+0JF+q720b8VDqXMrF7Qh97+fmUSslKkT5S +Ot/4cjDGQQ6mLRQx4msJOfO4WzKdrMBxes+enddGWttlavZcYl+DHX7bAgMBAAGj +UjBQMB0GA1UdDgQWBBRVao/9YEW7emCXaNf8zL3MjpmNXDAfBgNVHSMEGDAWgBRg +B5Rv74SOGoXqMLDoNcH4HCKW+TAOBgNVHQ8BAf8EBAMCBsAwDQYJKoZIhvcNAQEL +BQADggEBABuMF3tRpfmvjt96ZH0Bb8NWjB/WXUu6Pfv8lcO1PgDYsm0XLiVnN1Bl +4hhOJVL9Ceus1YB2uOqr8ukNYLuBidGtgaV3gxrT9CkqlnZHsRppNbUiKHER9hS8 +xAgja27YOM/qeyzzp6HZUfiFNsfz/oAddoDUWVPdQx1+EpQ0mlY9nAqHlFXhhoyU +H3RVA8N/DJiFHGhn/JAzUHFDorrxDHXWDOqCIZtVGOtTvNZ4KHeD9vKKtMNBlAfE +SpCPPml1gl1w70ou+GsMHaqioXfNgd6+H+y6xa+vBmjzmYenrUSA1IstNq3aHBVU ++ncyOb8+CbSUmWuYUu7HTpNWGBaGRxg= +-----END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/crlSignerInValidatedChain/crl-issuer.cert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/crlSignerInValidatedChain/crl-issuer.cert.pem new file mode 100644 index 0000000000..d5d2bebf26 --- /dev/null +++ b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/crlSignerInValidatedChain/crl-issuer.cert.pem @@ -0,0 +1,22 @@ +-----BEGIN CERTIFICATE----- +MIIDjTCCAnWgAwIBAgICEAEwDQYJKoZIhvcNAQELBQAwPTELMAkGA1UEBhMCQkUx +DjAMBgNVBAoMBWlUZXh0MR4wHAYDVQQDDBVpVGV4dFRlc3RJbnRlcm1lZGlhdGUw +IBcNMDAwMTAxMDAwMDAwWhgPMjQ1MDAxMDEwMDAwMDBaMDoxCzAJBgNVBAYTAkJF +MQ4wDAYDVQQKDAVpVGV4dDEbMBkGA1UEAwwSaVRleHRUZXN0Q3JsSXNzdWVyMIIB +IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwnsONfztmnDdLJKbWd8sE/2t +xomx72HBnrBM3G2bLpGfcvAFm9n/F0WLf1dPDYY94JAFKsBGG0Enh4eBJ753ZHgu +g/qwDIiF5DnRH57e2EtoJWwXjeSm5KLIsaWcUsUGHJDfS8SfWDqOIDCp+qm2mv1M +98poKsIo4lRHyM4XDL5ERGUAYklA0h5noHP1V1JnCQ0/4Z+j4dX0tfTnsxp4wA+C +u8AmsfL+UP3LTu7Soo3rbHMtn8yf12j7eohMRTX71eRf1fR1Nes0wA72RPe6RHpd +1kiXyW8P/Y+BNNpqujnW/R6LcjsVlc2iSPK4XonwBExXGp44yVVQjEt4G/uPrQID +AQABo4GXMIGUMB0GA1UdDgQWBBQSbqEw8HXXDUnva1e6YGF7DBbGdTAfBgNVHSME +GDAWgBSJQJIqlFRpEC9NMuebZTa38Lxk1TAOBgNVHQ8BAf8EBAMCAcIwQgYDVR0f +BDswOTA3oDWgM4YxaHR0cDovL2xvY2FsaG9zdC50ZXN0L2RlZmF1bHQvY3Jscy9j +cmwvbGF0ZXN0LmNybDANBgkqhkiG9w0BAQsFAAOCAQEAIei53b7VB3ZL8Axad3Jt +MjjzTp4+rGrh4RneoCEMUd04CjjcNToF3uCadAaBpi6j+eYEq/FTdebVrsdwGUvT +W+GqzYlesyv9BcbIGpla2ajw8SGBxpOOUPlZdHLkFlu9X86LXf/4acRglj02HDSf +kmvz3xmKwMLmctS6PpYVYfWUFdiBBHTnPTVm4dHQCHUiwyaSxLiShO9LaFtzQSZ4 +hfH4RD112fIFtW0srEwTCZtrQkttkTdBYJPg6SorGjBDsQqK9bkACYfyBOt+9hQY +Kcb1WRX3VfnBT+l7Nwzf7X37onRrm08gUefoHHAB1lUEN63tbGYnWy0az+0UYMMn +Fw== +-----END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/crlSignerInValidatedChain/intermediate.cert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/crlSignerInValidatedChain/intermediate.cert.pem new file mode 100644 index 0000000000..ca4cf7ba9c --- /dev/null +++ b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/crlSignerInValidatedChain/intermediate.cert.pem @@ -0,0 +1,20 @@ +-----BEGIN CERTIFICATE----- +MIIDQjCCAiqgAwIBAgICEAEwDQYJKoZIhvcNAQELBQAwNTELMAkGA1UEBhMCQkUx +DjAMBgNVBAoMBWlUZXh0MRYwFAYDVQQDDA1pVGV4dFRlc3RSb290MCAXDTAwMDEw +MTAwMDAwMFoYDzI0NTAwMTAxMDAwMDAwWjA9MQswCQYDVQQGEwJCRTEOMAwGA1UE +CgwFaVRleHQxHjAcBgNVBAMMFWlUZXh0VGVzdEludGVybWVkaWF0ZTCCASIwDQYJ +KoZIhvcNAQEBBQADggEPADCCAQoCggEBAJ6M9OSQgx20Fw14rYFeM6HQuQxBD276 +e6kXMpmdsbbkvExq5mrAWPvFGYHCmRAtH7pGm1pL91Zlgh1CbUPzwSa/Lfp9FeAX +83G7OJn0sY3kJRthtj5B0dGinXSIFCIb6gx9ICzoVpY9Ljvl4tyBr0dkGmED3MBx +SFltOMPplDhYwFekL7woNXMFIAxMnDWuS7dZ7xEpLAwNfH9D92I4lzSrQ9TrxwDP +dW2gWGvi2eu77W4YqFQgydgbKmFHAzDUTA01LNmKZkASBcLUoiLnLBMmVYgDMH4f +o4oj+2/J/OZNuGv5DK9dRCryAhnY3f8/9b8JzoPeRCmgRO9IU7ObZ/0CAwEAAaNS +MFAwHQYDVR0OBBYEFIlAkiqUVGkQL00y55tlNrfwvGTVMB8GA1UdIwQYMBaAFHQy +VMXAXOiryY9W6wOMgScvlq+rMA4GA1UdDwEB/wQEAwIB5jANBgkqhkiG9w0BAQsF +AAOCAQEAMoIJ86nzczzR41l5EFHlxGvUEQY/w7BJ42LICN3F12WPmJ+A3i/GAJSQ +14W+Jy8CXEhEFZF3R45vuOAGhOkF7igtbXeeVXunM3rmi8XIlpGjqbBZxC5w1Fd8 +IPOTArrzcF8agwthRzKOEpFSklmpUDT4MYZkdzR7TVM6TkdL+ModYFrhf9/+OFGb +qHzKUPVv+dvNaKn6JvKfQ311MKG3fLU7vyKEUNoolAnLMy3VETsnhMTk6Wa5rfzJ +eq2sdBiLxgwC3xhYk33Cla0X3hsr++Yqb8BX1ztKaRxu0PSi+KKJ9kvXAxRkFlwh +Xa7iIRXelUhftWRF/4VgDsDhWx+eDQ== +-----END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/crlSignerInValidatedChain/intermediate2.cert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/crlSignerInValidatedChain/intermediate2.cert.pem new file mode 100644 index 0000000000..713d7be544 --- /dev/null +++ b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/crlSignerInValidatedChain/intermediate2.cert.pem @@ -0,0 +1,20 @@ +-----BEGIN CERTIFICATE----- +MIIDSzCCAjOgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwPTELMAkGA1UEBhMCQkUx +DjAMBgNVBAoMBWlUZXh0MR4wHAYDVQQDDBVpVGV4dFRlc3RJbnRlcm1lZGlhdGUw +IBcNMDAwMTAxMDAwMDAwWhgPMjQ1MDAxMDEwMDAwMDBaMD4xCzAJBgNVBAYTAkJF +MQ4wDAYDVQQKDAVpVGV4dDEfMB0GA1UEAwwWaVRleHRUZXN0SW50ZXJtZWRpYXRl +MjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKN7p56CI+QpTP773pE1 +MjK9gKerROMznvSyRhyrXit89y9XbQXE4vyy136Wp3hJrNvb5oEg4np+knpRplQ/ +Z3Pypn4VsQSfN/VZHn7OsS9DUNAXpf48W8hph2/eLx8S3vs35bPdcF2PZGiy1L82 +GrEJS68lZ0iQw6KKxeGA87k1qL67uzRZq1MHHg4LSdMi5ffouGBv5oWyGQuD6AXs +aS70kKD8+Hj2Yg1lg0dM9tMGdzJ+ija4qASFo36/WouS4pcXwZUNB6kGWJJAdDbo +KzzWyaG0ygl3HtvBvrQjlERjq4PXIkDtCvA1gp0WFxNyIC/brUuaktK2V0I5uvzW +eS8CAwEAAaNSMFAwHQYDVR0OBBYEFGAHlG/vhI4aheowsOg1wfgcIpb5MB8GA1Ud +IwQYMBaAFIlAkiqUVGkQL00y55tlNrfwvGTVMA4GA1UdDwEB/wQEAwIB5jANBgkq +hkiG9w0BAQsFAAOCAQEAIiyAUyICl5tGxOkVpbdIvm7TYRGgivoUcLONpke4ypo6 +Yeh+2KmPAhIM6npUpuGIBMSsXfBVwQkWGUDHi3BMTbzO9Q5ivFx5GK68RYQryPkI +A4chJNnoxtbLJogsLpl3DxBmZc83z8RoHKbqyxOcR1NhQQXqcXz9ZxvAwfW8v6tJ +tD5IS55zBvcROB4AdH2+dVtjlHgBGniQheZ/JHI/74iXQCyiynEh3Bc54iH9qDUj +oQGY/cjDJJS6Xwqts1SCoLkpQTHO/GrAIRZwpIvTDeAVS0F16c5h+oAr4vV3iVEL +B/dPAG3gZDWO8zeOS4BF+yRYzt28zooQFNOUMUi4XQ== +-----END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/crlSignerInValidatedChain/sign.cert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/crlSignerInValidatedChain/sign.cert.pem new file mode 100644 index 0000000000..a6aaacc0ff --- /dev/null +++ b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/crlSignerInValidatedChain/sign.cert.pem @@ -0,0 +1,20 @@ +-----BEGIN CERTIFICATE----- +MIIDQzCCAiugAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwPjELMAkGA1UEBhMCQkUx +DjAMBgNVBAoMBWlUZXh0MR8wHQYDVQQDDBZpVGV4dFRlc3RJbnRlcm1lZGlhdGUy +MCAXDTAwMDEwMTAwMDAwMFoYDzI0MDAwMTAxMDAwMDAwWjA1MQswCQYDVQQGEwJC +RTEOMAwGA1UECgwFaVRleHQxFjAUBgNVBAMMDWlUZXh0VGVzdFNpZ24wggEiMA0G +CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCzBx802aNQTkJGcxGZdkN5XjXwR9tG +HzuEdJdGQVm56YP9PfTjeCPCLTtH9uFqtILP//tWnZSanlDHlFcUNH6btHB0DnPY +ewliS5zwCYxLyLWeVl1uJfP6aaNW6OFiwdYU6BeNjXx4Iey2qI9oKlS1l0ujYHfH +IVcSE2sXygPTxuenY3vj5SZ0zYvmsrnQfzue3YaGgLvrG8QYaIP+80QFfOzrB/c8 +XDbsPt2cx4bLOS6Z+hfv1g3Bz8l7E+0JF+q720b8VDqXMrF7Qh97+fmUSslKkT5S +Ot/4cjDGQQ6mLRQx4msJOfO4WzKdrMBxes+enddGWttlavZcYl+DHX7bAgMBAAGj +UjBQMB0GA1UdDgQWBBRVao/9YEW7emCXaNf8zL3MjpmNXDAfBgNVHSMEGDAWgBRg +B5Rv74SOGoXqMLDoNcH4HCKW+TAOBgNVHQ8BAf8EBAMCBsAwDQYJKoZIhvcNAQEL +BQADggEBABuMF3tRpfmvjt96ZH0Bb8NWjB/WXUu6Pfv8lcO1PgDYsm0XLiVnN1Bl +4hhOJVL9Ceus1YB2uOqr8ukNYLuBidGtgaV3gxrT9CkqlnZHsRppNbUiKHER9hS8 +xAgja27YOM/qeyzzp6HZUfiFNsfz/oAddoDUWVPdQx1+EpQ0mlY9nAqHlFXhhoyU +H3RVA8N/DJiFHGhn/JAzUHFDorrxDHXWDOqCIZtVGOtTvNZ4KHeD9vKKtMNBlAfE +SpCPPml1gl1w70ou+GsMHaqioXfNgd6+H+y6xa+vBmjzmYenrUSA1IstNq3aHBVU ++ncyOb8+CbSUmWuYUu7HTpNWGBaGRxg= +-----END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/happyPath.yml b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/happyPath.yml similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/happyPath.yml rename to sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/happyPath.yml diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/happyPath/ca.cert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/happyPath/ca.cert.pem new file mode 100644 index 0000000000..efb7717302 --- /dev/null +++ b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/happyPath/ca.cert.pem @@ -0,0 +1,20 @@ +-----BEGIN CERTIFICATE----- +MIIDSzCCAjOgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwNTELMAkGA1UEBhMCQkUx +DjAMBgNVBAoMBWlUZXh0MRYwFAYDVQQDDA1pVGV4dFRlc3RSb290MCAXDTAwMDEw +MTAwMDAwMFoYDzI1MDAwMTAxMDAwMDAwWjA1MQswCQYDVQQGEwJCRTEOMAwGA1UE +CgwFaVRleHQxFjAUBgNVBAMMDWlUZXh0VGVzdFJvb3QwggEiMA0GCSqGSIb3DQEB +AQUAA4IBDwAwggEKAoIBAQDYxUs+SgZkRkOhOfddCnPeuE1QP2kAm6gAsg4qjNzr +rZpZvwziyWaz6bXXq8fATjXEAdypAiWL/BDZscdCM/M11jds9mMv7dMvCtLns6Oe +4GbChYxxloN2rVxElFPK2siKBaEeWyItr2Ms0P+hSR5uHjFt+krzl2zv828fyEnH +fPvln42SAcuCKsLmfjtutus5jFKBFF8oiqDFlI2eXYggKV7JELttgPLobv2ZyFa5 +nXo/xbtzlPb8AvV3/mxpX4prFhBXupJXuCwmqmzVRqGbwKSz/Bewb/4aJGSpg32x +yIWeXTld58f+Jntfes8xHwK0aJB/Tm2WrH+RWoV+TN/pAgMBAAGjYzBhMB0GA1Ud +DgQWBBR0MlTFwFzoq8mPVusDjIEnL5avqzAfBgNVHSMEGDAWgBR0MlTFwFzoq8mP +VusDjIEnL5avqzAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIC5DANBgkq +hkiG9w0BAQsFAAOCAQEAK2dbxbQ7jEdtqvnMpKOZsB55PDO5OZ2hPYilT5ZVZNt1 +jdE94HdCBHED3upmOeBH+XtsK/MLk+eYICM5SZwWVCBY0aQQR0URyTsX4SA/12A5 +VhrnP6bqy4b+3mO3J9s0go59cZOtSkxQ7191teEQMsDeh8GxXGLW/7Tf4x6v7U34 +B7UghMhUD2bHJ7U8MOqto9fVar/9S93tc9vRtYOXZbfRwjFKOYD4IFm7cH3VnrX7 +od3KUEKGKhQ2ZaqrtnW19xNTbdRcMT3+8QSai9DLV0kGGSSY09AHDO3WvxkAs9ZI +cIsMM/n+mLK0Km9fh5uE3k6NmiN3GV+QMyjbmFnVNg== +-----END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/happyPath/chain.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/happyPath/chain.pem new file mode 100644 index 0000000000..f444b02a80 --- /dev/null +++ b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/happyPath/chain.pem @@ -0,0 +1,81 @@ +-----BEGIN CERTIFICATE----- +MIIDSzCCAjOgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwNTELMAkGA1UEBhMCQkUx +DjAMBgNVBAoMBWlUZXh0MRYwFAYDVQQDDA1pVGV4dFRlc3RSb290MCAXDTAwMDEw +MTAwMDAwMFoYDzI1MDAwMTAxMDAwMDAwWjA1MQswCQYDVQQGEwJCRTEOMAwGA1UE +CgwFaVRleHQxFjAUBgNVBAMMDWlUZXh0VGVzdFJvb3QwggEiMA0GCSqGSIb3DQEB +AQUAA4IBDwAwggEKAoIBAQDYxUs+SgZkRkOhOfddCnPeuE1QP2kAm6gAsg4qjNzr +rZpZvwziyWaz6bXXq8fATjXEAdypAiWL/BDZscdCM/M11jds9mMv7dMvCtLns6Oe +4GbChYxxloN2rVxElFPK2siKBaEeWyItr2Ms0P+hSR5uHjFt+krzl2zv828fyEnH +fPvln42SAcuCKsLmfjtutus5jFKBFF8oiqDFlI2eXYggKV7JELttgPLobv2ZyFa5 +nXo/xbtzlPb8AvV3/mxpX4prFhBXupJXuCwmqmzVRqGbwKSz/Bewb/4aJGSpg32x +yIWeXTld58f+Jntfes8xHwK0aJB/Tm2WrH+RWoV+TN/pAgMBAAGjYzBhMB0GA1Ud +DgQWBBR0MlTFwFzoq8mPVusDjIEnL5avqzAfBgNVHSMEGDAWgBR0MlTFwFzoq8mP +VusDjIEnL5avqzAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIC5DANBgkq +hkiG9w0BAQsFAAOCAQEAK2dbxbQ7jEdtqvnMpKOZsB55PDO5OZ2hPYilT5ZVZNt1 +jdE94HdCBHED3upmOeBH+XtsK/MLk+eYICM5SZwWVCBY0aQQR0URyTsX4SA/12A5 +VhrnP6bqy4b+3mO3J9s0go59cZOtSkxQ7191teEQMsDeh8GxXGLW/7Tf4x6v7U34 +B7UghMhUD2bHJ7U8MOqto9fVar/9S93tc9vRtYOXZbfRwjFKOYD4IFm7cH3VnrX7 +od3KUEKGKhQ2ZaqrtnW19xNTbdRcMT3+8QSai9DLV0kGGSSY09AHDO3WvxkAs9ZI +cIsMM/n+mLK0Km9fh5uE3k6NmiN3GV+QMyjbmFnVNg== +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDhTCCAm2gAwIBAgICEAIwDQYJKoZIhvcNAQELBQAwNTELMAkGA1UEBhMCQkUx +DjAMBgNVBAoMBWlUZXh0MRYwFAYDVQQDDA1pVGV4dFRlc3RSb290MCAXDTAwMDEw +MTAwMDAwMFoYDzI0NTAwMTAxMDAwMDAwWjA6MQswCQYDVQQGEwJCRTEOMAwGA1UE +CgwFaVRleHQxGzAZBgNVBAMMEmlUZXh0VGVzdENybElzc3VlcjCCASIwDQYJKoZI +hvcNAQEBBQADggEPADCCAQoCggEBAMJ7DjX87Zpw3SySm1nfLBP9rcaJse9hwZ6w +TNxtmy6Rn3LwBZvZ/xdFi39XTw2GPeCQBSrARhtBJ4eHgSe+d2R4LoP6sAyIheQ5 +0R+e3thLaCVsF43kpuSiyLGlnFLFBhyQ30vEn1g6jiAwqfqptpr9TPfKaCrCKOJU +R8jOFwy+RERlAGJJQNIeZ6Bz9VdSZwkNP+Gfo+HV9LX057MaeMAPgrvAJrHy/lD9 +y07u0qKN62xzLZ/Mn9do+3qITEU1+9XkX9X0dTXrNMAO9kT3ukR6XdZIl8lvD/2P +gTTaaro51v0ei3I7FZXNokjyuF6J8ARMVxqeOMlVUIxLeBv7j60CAwEAAaOBlzCB +lDAdBgNVHQ4EFgQUEm6hMPB11w1J72tXumBhewwWxnUwHwYDVR0jBBgwFoAUdDJU +xcBc6KvJj1brA4yBJy+Wr6swDgYDVR0PAQH/BAQDAgHCMEIGA1UdHwQ7MDkwN6A1 +oDOGMWh0dHA6Ly9sb2NhbGhvc3QudGVzdC9kZWZhdWx0L2NybHMvY3JsL2xhdGVz +dC5jcmwwDQYJKoZIhvcNAQELBQADggEBAEg69NBvQJkOO25o1UxRoJqKb7PdwF5K +xiidxXjJQTZHVR56rWoMfg/31eDwBdc6bmSAELd2wPSs3Ov3HJJP4f31+plXB3Qb +B5pQUEc5i4IZiE0jz7Be4GLqSVNaLh9ay4o8PnpvcIZiKNukJzPhGsOzW8xrTF7R +Cc6VSjmLHG2UnEt2CBbkaWnVXV8ibENSawv4Ar2AKpcU9LLoT1F92zx/7YpUQLr1 +k/RwWxkKByV5ko001DuwiWf/BjZ67pu5WTgdHQP9KaNMahnSqrjERCTLWVipdvJ2 +o3bHCe9I0OQMVlMeesKMWPRqLiAMpz7f7q09AXlqjvZT9+FPSi6nsss= +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDQjCCAiqgAwIBAgICEAEwDQYJKoZIhvcNAQELBQAwNTELMAkGA1UEBhMCQkUx +DjAMBgNVBAoMBWlUZXh0MRYwFAYDVQQDDA1pVGV4dFRlc3RSb290MCAXDTAwMDEw +MTAwMDAwMFoYDzI0NTAwMTAxMDAwMDAwWjA9MQswCQYDVQQGEwJCRTEOMAwGA1UE +CgwFaVRleHQxHjAcBgNVBAMMFWlUZXh0VGVzdEludGVybWVkaWF0ZTCCASIwDQYJ +KoZIhvcNAQEBBQADggEPADCCAQoCggEBAJ6M9OSQgx20Fw14rYFeM6HQuQxBD276 +e6kXMpmdsbbkvExq5mrAWPvFGYHCmRAtH7pGm1pL91Zlgh1CbUPzwSa/Lfp9FeAX +83G7OJn0sY3kJRthtj5B0dGinXSIFCIb6gx9ICzoVpY9Ljvl4tyBr0dkGmED3MBx +SFltOMPplDhYwFekL7woNXMFIAxMnDWuS7dZ7xEpLAwNfH9D92I4lzSrQ9TrxwDP +dW2gWGvi2eu77W4YqFQgydgbKmFHAzDUTA01LNmKZkASBcLUoiLnLBMmVYgDMH4f +o4oj+2/J/OZNuGv5DK9dRCryAhnY3f8/9b8JzoPeRCmgRO9IU7ObZ/0CAwEAAaNS +MFAwHQYDVR0OBBYEFIlAkiqUVGkQL00y55tlNrfwvGTVMB8GA1UdIwQYMBaAFHQy +VMXAXOiryY9W6wOMgScvlq+rMA4GA1UdDwEB/wQEAwIB5jANBgkqhkiG9w0BAQsF +AAOCAQEAMoIJ86nzczzR41l5EFHlxGvUEQY/w7BJ42LICN3F12WPmJ+A3i/GAJSQ +14W+Jy8CXEhEFZF3R45vuOAGhOkF7igtbXeeVXunM3rmi8XIlpGjqbBZxC5w1Fd8 +IPOTArrzcF8agwthRzKOEpFSklmpUDT4MYZkdzR7TVM6TkdL+ModYFrhf9/+OFGb +qHzKUPVv+dvNaKn6JvKfQ311MKG3fLU7vyKEUNoolAnLMy3VETsnhMTk6Wa5rfzJ +eq2sdBiLxgwC3xhYk33Cla0X3hsr++Yqb8BX1ztKaRxu0PSi+KKJ9kvXAxRkFlwh +Xa7iIRXelUhftWRF/4VgDsDhWx+eDQ== +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDQjCCAiqgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwPTELMAkGA1UEBhMCQkUx +DjAMBgNVBAoMBWlUZXh0MR4wHAYDVQQDDBVpVGV4dFRlc3RJbnRlcm1lZGlhdGUw +IBcNMDAwMTAxMDAwMDAwWhgPMjQwMDAxMDEwMDAwMDBaMDUxCzAJBgNVBAYTAkJF +MQ4wDAYDVQQKDAVpVGV4dDEWMBQGA1UEAwwNaVRleHRUZXN0U2lnbjCCASIwDQYJ +KoZIhvcNAQEBBQADggEPADCCAQoCggEBALMHHzTZo1BOQkZzEZl2Q3leNfBH20Yf +O4R0l0ZBWbnpg/099ON4I8ItO0f24Wq0gs//+1adlJqeUMeUVxQ0fpu0cHQOc9h7 +CWJLnPAJjEvItZ5WXW4l8/ppo1bo4WLB1hToF42NfHgh7Laoj2gqVLWXS6Ngd8ch +VxITaxfKA9PG56dje+PlJnTNi+ayudB/O57dhoaAu+sbxBhog/7zRAV87OsH9zxc +Nuw+3ZzHhss5Lpn6F+/WDcHPyXsT7QkX6rvbRvxUOpcysXtCH3v5+ZRKyUqRPlI6 +3/hyMMZBDqYtFDHiawk587hbMp2swHF6z56d10Za22Vq9lxiX4MdftsCAwEAAaNS +MFAwHQYDVR0OBBYEFFVqj/1gRbt6YJdo1/zMvcyOmY1cMB8GA1UdIwQYMBaAFIlA +kiqUVGkQL00y55tlNrfwvGTVMA4GA1UdDwEB/wQEAwIGwDANBgkqhkiG9w0BAQsF +AAOCAQEAMsIeJp6AHJwChOEddcGu5dD/Q4R6l7dMIe3Q8g8vDVz94572jmvHIOa5 +Q/xJALRFn5rG1oC06q6Gy4ffbUm5S1dNBXdmwyfNzAa5yAwXraIWkXLPM5zFUueB +qu2ekfPhHq0NjCqhVCCYkhngaf+mqeuw8usML6mMf8o0aC6TlQu7GXm/6Z4SSKmY +wDyM4iSVR3fZHb3R/VBP7+GNKsamapZPThdxueWnm6o2vsMKSfgGHRV/41BrUqb7 +t5SXDihXCImTpUr89EL7kix42Q/BFQ60hO3LYsKn4w8gjUQffQdlB2zR6cQJx2eK +9jrkP1+J6xcuWHHrn2l9YXw6rI7r0g== +-----END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/happyPath/crl-issuer.cert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/happyPath/crl-issuer.cert.pem new file mode 100644 index 0000000000..3656f9e733 --- /dev/null +++ b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/happyPath/crl-issuer.cert.pem @@ -0,0 +1,21 @@ +-----BEGIN CERTIFICATE----- +MIIDhTCCAm2gAwIBAgICEAIwDQYJKoZIhvcNAQELBQAwNTELMAkGA1UEBhMCQkUx +DjAMBgNVBAoMBWlUZXh0MRYwFAYDVQQDDA1pVGV4dFRlc3RSb290MCAXDTAwMDEw +MTAwMDAwMFoYDzI0NTAwMTAxMDAwMDAwWjA6MQswCQYDVQQGEwJCRTEOMAwGA1UE +CgwFaVRleHQxGzAZBgNVBAMMEmlUZXh0VGVzdENybElzc3VlcjCCASIwDQYJKoZI +hvcNAQEBBQADggEPADCCAQoCggEBAMJ7DjX87Zpw3SySm1nfLBP9rcaJse9hwZ6w +TNxtmy6Rn3LwBZvZ/xdFi39XTw2GPeCQBSrARhtBJ4eHgSe+d2R4LoP6sAyIheQ5 +0R+e3thLaCVsF43kpuSiyLGlnFLFBhyQ30vEn1g6jiAwqfqptpr9TPfKaCrCKOJU +R8jOFwy+RERlAGJJQNIeZ6Bz9VdSZwkNP+Gfo+HV9LX057MaeMAPgrvAJrHy/lD9 +y07u0qKN62xzLZ/Mn9do+3qITEU1+9XkX9X0dTXrNMAO9kT3ukR6XdZIl8lvD/2P +gTTaaro51v0ei3I7FZXNokjyuF6J8ARMVxqeOMlVUIxLeBv7j60CAwEAAaOBlzCB +lDAdBgNVHQ4EFgQUEm6hMPB11w1J72tXumBhewwWxnUwHwYDVR0jBBgwFoAUdDJU +xcBc6KvJj1brA4yBJy+Wr6swDgYDVR0PAQH/BAQDAgHCMEIGA1UdHwQ7MDkwN6A1 +oDOGMWh0dHA6Ly9sb2NhbGhvc3QudGVzdC9kZWZhdWx0L2NybHMvY3JsL2xhdGVz +dC5jcmwwDQYJKoZIhvcNAQELBQADggEBAEg69NBvQJkOO25o1UxRoJqKb7PdwF5K +xiidxXjJQTZHVR56rWoMfg/31eDwBdc6bmSAELd2wPSs3Ov3HJJP4f31+plXB3Qb +B5pQUEc5i4IZiE0jz7Be4GLqSVNaLh9ay4o8PnpvcIZiKNukJzPhGsOzW8xrTF7R +Cc6VSjmLHG2UnEt2CBbkaWnVXV8ibENSawv4Ar2AKpcU9LLoT1F92zx/7YpUQLr1 +k/RwWxkKByV5ko001DuwiWf/BjZ67pu5WTgdHQP9KaNMahnSqrjERCTLWVipdvJ2 +o3bHCe9I0OQMVlMeesKMWPRqLiAMpz7f7q09AXlqjvZT9+FPSi6nsss= +-----END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/happyPath/intermediate.cert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/happyPath/intermediate.cert.pem new file mode 100644 index 0000000000..ca4cf7ba9c --- /dev/null +++ b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/happyPath/intermediate.cert.pem @@ -0,0 +1,20 @@ +-----BEGIN CERTIFICATE----- +MIIDQjCCAiqgAwIBAgICEAEwDQYJKoZIhvcNAQELBQAwNTELMAkGA1UEBhMCQkUx +DjAMBgNVBAoMBWlUZXh0MRYwFAYDVQQDDA1pVGV4dFRlc3RSb290MCAXDTAwMDEw +MTAwMDAwMFoYDzI0NTAwMTAxMDAwMDAwWjA9MQswCQYDVQQGEwJCRTEOMAwGA1UE +CgwFaVRleHQxHjAcBgNVBAMMFWlUZXh0VGVzdEludGVybWVkaWF0ZTCCASIwDQYJ +KoZIhvcNAQEBBQADggEPADCCAQoCggEBAJ6M9OSQgx20Fw14rYFeM6HQuQxBD276 +e6kXMpmdsbbkvExq5mrAWPvFGYHCmRAtH7pGm1pL91Zlgh1CbUPzwSa/Lfp9FeAX +83G7OJn0sY3kJRthtj5B0dGinXSIFCIb6gx9ICzoVpY9Ljvl4tyBr0dkGmED3MBx +SFltOMPplDhYwFekL7woNXMFIAxMnDWuS7dZ7xEpLAwNfH9D92I4lzSrQ9TrxwDP +dW2gWGvi2eu77W4YqFQgydgbKmFHAzDUTA01LNmKZkASBcLUoiLnLBMmVYgDMH4f +o4oj+2/J/OZNuGv5DK9dRCryAhnY3f8/9b8JzoPeRCmgRO9IU7ObZ/0CAwEAAaNS +MFAwHQYDVR0OBBYEFIlAkiqUVGkQL00y55tlNrfwvGTVMB8GA1UdIwQYMBaAFHQy +VMXAXOiryY9W6wOMgScvlq+rMA4GA1UdDwEB/wQEAwIB5jANBgkqhkiG9w0BAQsF +AAOCAQEAMoIJ86nzczzR41l5EFHlxGvUEQY/w7BJ42LICN3F12WPmJ+A3i/GAJSQ +14W+Jy8CXEhEFZF3R45vuOAGhOkF7igtbXeeVXunM3rmi8XIlpGjqbBZxC5w1Fd8 +IPOTArrzcF8agwthRzKOEpFSklmpUDT4MYZkdzR7TVM6TkdL+ModYFrhf9/+OFGb +qHzKUPVv+dvNaKn6JvKfQ311MKG3fLU7vyKEUNoolAnLMy3VETsnhMTk6Wa5rfzJ +eq2sdBiLxgwC3xhYk33Cla0X3hsr++Yqb8BX1ztKaRxu0PSi+KKJ9kvXAxRkFlwh +Xa7iIRXelUhftWRF/4VgDsDhWx+eDQ== +-----END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/happyPath/sign.cert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/happyPath/sign.cert.pem new file mode 100644 index 0000000000..bfcfbf0242 --- /dev/null +++ b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/happyPath/sign.cert.pem @@ -0,0 +1,20 @@ +-----BEGIN CERTIFICATE----- +MIIDQjCCAiqgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwPTELMAkGA1UEBhMCQkUx +DjAMBgNVBAoMBWlUZXh0MR4wHAYDVQQDDBVpVGV4dFRlc3RJbnRlcm1lZGlhdGUw +IBcNMDAwMTAxMDAwMDAwWhgPMjQwMDAxMDEwMDAwMDBaMDUxCzAJBgNVBAYTAkJF +MQ4wDAYDVQQKDAVpVGV4dDEWMBQGA1UEAwwNaVRleHRUZXN0U2lnbjCCASIwDQYJ +KoZIhvcNAQEBBQADggEPADCCAQoCggEBALMHHzTZo1BOQkZzEZl2Q3leNfBH20Yf +O4R0l0ZBWbnpg/099ON4I8ItO0f24Wq0gs//+1adlJqeUMeUVxQ0fpu0cHQOc9h7 +CWJLnPAJjEvItZ5WXW4l8/ppo1bo4WLB1hToF42NfHgh7Laoj2gqVLWXS6Ngd8ch +VxITaxfKA9PG56dje+PlJnTNi+ayudB/O57dhoaAu+sbxBhog/7zRAV87OsH9zxc +Nuw+3ZzHhss5Lpn6F+/WDcHPyXsT7QkX6rvbRvxUOpcysXtCH3v5+ZRKyUqRPlI6 +3/hyMMZBDqYtFDHiawk587hbMp2swHF6z56d10Za22Vq9lxiX4MdftsCAwEAAaNS +MFAwHQYDVR0OBBYEFFVqj/1gRbt6YJdo1/zMvcyOmY1cMB8GA1UdIwQYMBaAFIlA +kiqUVGkQL00y55tlNrfwvGTVMA4GA1UdDwEB/wQEAwIGwDANBgkqhkiG9w0BAQsF +AAOCAQEAMsIeJp6AHJwChOEddcGu5dD/Q4R6l7dMIe3Q8g8vDVz94572jmvHIOa5 +Q/xJALRFn5rG1oC06q6Gy4ffbUm5S1dNBXdmwyfNzAa5yAwXraIWkXLPM5zFUueB +qu2ekfPhHq0NjCqhVCCYkhngaf+mqeuw8usML6mMf8o0aC6TlQu7GXm/6Z4SSKmY +wDyM4iSVR3fZHb3R/VBP7+GNKsamapZPThdxueWnm6o2vsMKSfgGHRV/41BrUqb7 +t5SXDihXCImTpUr89EL7kix42Q/BFQ60hO3LYsKn4w8gjUQffQdlB2zR6cQJx2eK +9jrkP1+J6xcuWHHrn2l9YXw6rI7r0g== +-----END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/issuingDistributionPointTest/certWithDPReasons.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/issuingDistributionPointTest/certWithDPReasons.pem similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/issuingDistributionPointTest/certWithDPReasons.pem rename to sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/issuingDistributionPointTest/certWithDPReasons.pem diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/issuingDistributionPointTest/onlyAttr.crl b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/issuingDistributionPointTest/onlyAttr.crl similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/issuingDistributionPointTest/onlyAttr.crl rename to sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/issuingDistributionPointTest/onlyAttr.crl diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/issuingDistributionPointTest/onlyCA.crl b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/issuingDistributionPointTest/onlyCA.crl similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/issuingDistributionPointTest/onlyCA.crl rename to sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/issuingDistributionPointTest/onlyCA.crl diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/issuingDistributionPointTest/onlyUser.crl b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/issuingDistributionPointTest/onlyUser.crl similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/issuingDistributionPointTest/onlyUser.crl rename to sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/issuingDistributionPointTest/onlyUser.crl diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/issuingDistributionPointTest/root.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/issuingDistributionPointTest/root.pem similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/issuingDistributionPointTest/root.pem rename to sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/issuingDistributionPointTest/root.pem diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/issuingDistributionPointTest/rootCert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/issuingDistributionPointTest/rootCert.pem similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/issuingDistributionPointTest/rootCert.pem rename to sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/issuingDistributionPointTest/rootCert.pem diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/issuingDistributionPointTest/sign.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/issuingDistributionPointTest/sign.pem similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/issuingDistributionPointTest/sign.pem rename to sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/issuingDistributionPointTest/sign.pem diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/keys/crl-key.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/keys/crl-key.pem new file mode 100644 index 0000000000..2d3cc82ac3 --- /dev/null +++ b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/keys/crl-key.pem @@ -0,0 +1,30 @@ +-----BEGIN ENCRYPTED PRIVATE KEY----- +MIIFNTBfBgkqhkiG9w0BBQ0wUjAxBgkqhkiG9w0BBQwwJAQQ+urJds/EcAU2OgmN +7A3GxgICCAAwDAYIKoZIhvcNAgkFADAdBglghkgBZQMEASoEELjgW4C64QNqkHi/ +9UbE+ksEggTQdbe6Y1LtVHoDERy5p7sy0FEy1k7Co5xmUKPUOLhrFhEPBXs3Lawl +su/CemkwRXt2sdlOUl01wXkDazZEZIkGevGZ6v8COag8CUcMs/woh+dEFRYfSmj9 +fxfFLNCvtR726GLuUboztWmhbsS6jMbAOM2soQoVQwxK5C3P0xQQ2KwL4avK/nYp +OZibBvepGR7cFnkqCCw5Mk/wMe0uTiPqhHf27t7qcXrEXIh/vhT6R0RUDC3wZWRX +gRd+oQbCQ44yeisboPEMC1xs/qAHPd+tfQBX/z6uNeHcwoabwF3fOHxjJmB70ydz +R3vS86uSeOe9/xa0Fz4Vl5nelYek6p+MzhMhmom7OwyNHRlUQfRsemgy6RqXgVbe +hR91V1oH+lkv4cFeV3tBREOWWXbwvU1LUTW2gk2NskLYNZ8SLcURXo1+7M3jZ5EK +X4kTsgcWVJJ/DXVEDsKRQv5OWGZW7IYJkrhUEKAn1OOodlY5irNa7fR6Aj1qc86+ +D7zTF7Mr5VHHqjY0o/nQ145s8KGdx46gPQLvZGw1ipZfXh7ZSv/kRmdYfs6SEZRd +IMF2VOcsgw/SnGfHz3i0YH7SX+G1/lH3YKRr9j+4ZFdIim6qd68l0UlnoheTEKIq +4/5f8dYxmBgeEg2OR0oWvjtX55sXNOSRpoboM1AZlVHBRvXEKZuTXLaj8GjCP6Fy +ww58rug0ZakvcIcoGmZBw0QjS4n3FzoHmIU2U6pJAcYu92yYjhtgCy/BOhmOE/1e +wiLr8r9Jg4gRhGq8it1voNebK0PkpngVKW20gfIlrilww2q6zXlsEm2NBxa9yaif +FGolpBvxjCsPCPTC1/wjj659PCCnflnWu+YMJ7a8VPAeFlKW+D5DV5PXzmJTiIPM +H0BiwNj1wzJBtsqiFRdLlJHO1ys7kqEWVsh4rWJ7aqiq1Nfok2aM/z6TlcBQwtcs +qKmkD+eLKTXhyYByc1oGcV+sc5taAp2ktiMknFGen/jd4DThTxXg+F0E6Jrr0EJb +kKkVPfayQvVczDEoJpwluRuOFyjUWwUybkBvvhu845gi7CEei8T9NoZI+8waCMWq +tQKqIy6HqW4VqFDOmKaS1D0vXaWB64majlvUCRMzGW/XtTZYDnKIqWEcztCjlDNa +tOUUAHFu7NcRwOi9h9Y8tVCL19U2RRDOW4ZpLwcPCPYb1z9WAvLfW9QEhJLu10id +2R5WeCmrTglZpeTgSUsbjmMfyVPROK5Mfp4poNzWvnuyoj0wUk+y9PmExatCqZ+r +yBPJGhC5mYPGun3LaBDAE0vrW8Op3GdSBtdPpV70yZa2t4YqIrgrCSSylmXQSd/K +6fRAsLS/T0stsQ+t9v7nR08EWtEeKYz2DYP94GT21B+1Vi80UR/Rw3z0Wd1FyGMw +Rtp2eIotHGevA9spef1fG8ckjvVfZPow7TAsZsHBhnDZvSu8DByK/1hji1l++QSe +w4z+PwjQnTf1mK0j7R+NKrWOdI0lHKA+T9LfuC5W6T0jAqZxnMefGitOe//fPdKf +MzJd2XZYTCNTUYCZArCxQZwID6kE0dOnomv9f1NB3SrKnkRw3IDMtUsvDanuWHJo +XNEodRiuhObecRmNp7Zl0cX6WQTVyYoMUys/Kei7NVehkVsHmJ7xFd8= +-----END ENCRYPTED PRIVATE KEY----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/keys/im2_key.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/keys/im2_key.pem new file mode 100644 index 0000000000..3bc1ae1572 --- /dev/null +++ b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/keys/im2_key.pem @@ -0,0 +1,30 @@ +-----BEGIN ENCRYPTED PRIVATE KEY----- +MIIFNTBfBgkqhkiG9w0BBQ0wUjAxBgkqhkiG9w0BBQwwJAQQ20H7VWfD+2t4fdMK +eME51AICCAAwDAYIKoZIhvcNAgkFADAdBglghkgBZQMEASoEEDieWNlVjwWqZxb0 +ZX/Z8pkEggTQXND6t2DXbjSWT/dtPiAsb0c6DuwFH4CsHglZvGHJIyT8KEuX6Cjc +AAxaZACpA1/3/Wh3S62UTkK1jbaRApZFZMYP8mkgOkw1cHVDGv3wIb1dzVz1Ql1h +4wrotPAw+obZDFWYG7zS5C8qazlVoH56CxLafKNi/CWjgLcg9lDgkrnBZvLpjHF7 +py9V9BPUOD31TEGY5ZdtJTbYucp5QCBer+MLXoqsF2eI4iMWs0BlGpF46cL01zN6 +W0l+uOznu3d/h81iFYfWAENSpRi+lapzMqbD/cJlQBc/S1U8LEthRKa2p7Yt6NAf +1pRR/NuucXc/GnYrkCC55RK7Y4kuusSO2SU8B66MXbUory9J+pBCizuqqScf+qdh +52Y+tEgrthyQkZP3gw145u6MFYA6ZGcyNma7BWcNDmwQ9ImLBMDSmRVdHqSLujXx +rI3ASvUJtoCq9yOCPrhgha9j6fg/MnYYZL6hmS0osx+AeeCZ/VCOqq5/ctmcoAPX +fmXivH9NrQs7Hv/rMibbRbZumBD3/ueymbnUf17Lf0PGlLe5oMpJUTn6AaTPLqTa +HRQkDDBMsSrRErekAMyYgfQVNRSSmmHxPkoe1woQdVYtkBYcYY0b/B4rI1JW2qV6 +0khSRwPbUlX01z7R3Gwhx/Z18DIGcCHQXM/CHCXVFB56N92TRSpCulJ2fec0sJr7 +nZP4QGXnjmjKwjqITsBwqzgrNhM+yN6IzaLPH/Lu5/fq6yIM58wE3nsM61Zfixig +rBXSyj5fKUQ0sahHEbtFEhxFIiRwflrdCCBI/SXWG2U1lwuhRKRybsMoWB6+9KmZ +tdZUZlw0BUBT+yFTn4Ov8OwMCFhRg9nn/DTqUyju0vLSUitc15or309cgDE2YtHB +UT+GOqVtLcPcTjuBUWgrUIxDT9qUNa7az26tIDr7MNk0iQ4NPJ0COoe2W5sUDMJl +Nwz1k2xRjLsr20+75qm81zhi+1TZptMMTuMwx3NEZPkz2mYx7DL3oLk/7CMFYlZG +lbTr6Xl9deL+ExXMGQfGmCLG9X6lYL+666GI+ADPDw4wsKre6hWgu7BBkFxCyUSB +NxhM1ekh+wY5zwFVEMVCST97AopBWwu2frfa3WnHycQk/jwINSroqgTEmp/DjK1R +H2rye/OXCtSnv1CWxTHCjmIxxXNh5dXZ/M1It9F/+u7sYWlvwxs0Y4FIkBAwp+PY +J5iTLG5Rcuac483k0+kSJw+W2IEcrfLxr0dvTQkP/mUkx6OmHT8f3+2uMjXeVRD6 +tnYVPACAa8toA75DW9lvQeQllGTIStrD3LgQqEDlAEH+D3b0eGFSSX5E/7OnLeKS +SZBikPUHVJSKBXH/HsxzLWRwop640adE7rKTTcHbI9VAZ2H+mozyPibZGzRE43bw +Z8CV3XiCmlM4uxmi9QKGhedjP3Ak14ns/MYiyoK0Z22mNHWgD3DpQB3k2nd67eZw +oX2ddqwcQfjIjhwRcbnsMBHGeCtIS8u3r6trE0DA9dGCScMxVcfkel+y5rtZU3+u +sxdWlFS7bzV4/5PldL/3F2tvn8vYrFzUkmOy43gV6tSnL9ht4znWQLI/nXUcCdOW +eFXWZTwzlZfs4SmII3hfsJFrskP80PC6AjcsfIbBxWphTiL7B2aN2D4= +-----END ENCRYPTED PRIVATE KEY----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/keys/im_key.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/keys/im_key.pem new file mode 100644 index 0000000000..3ba75b5380 --- /dev/null +++ b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/keys/im_key.pem @@ -0,0 +1,30 @@ +-----BEGIN ENCRYPTED PRIVATE KEY----- +MIIFNTBfBgkqhkiG9w0BBQ0wUjAxBgkqhkiG9w0BBQwwJAQQ3MrI44qDJ1HV28m3 +64fDSAICCAAwDAYIKoZIhvcNAgkFADAdBglghkgBZQMEASoEEJMmQPDYjRL7Xj3a +kdVCihUEggTQPUogB6yfRJrKa7T1GngdDkcLrbTo5IPb30bKoEuCLvvq72+rRSH/ +PgKAMWJRvvEtVj7c/EPeRxryo+m92ljFF4A36xAedBBQKcQGwF0a/Jp7uNsofOrr +ZWa013g3SBYCh75s0+7sW9CJ/TeAb4TwVeWXsQZMzAtYcG7QPXYSd4CDTuVYBhh0 +zfGn6DNggfvNwxPIq1MHyY1wGyfkSp/ILRBR4XQ4hF/BdWV190ol7ewtae2GuREk +gDp0XReYvKXKa5k0J3tdIUwCsGxtnmD9tWeBQpPFNahtcx0Ga7RBxnQyJVsY4naf +20RzT8l0bfCv62nHyLU1afMivT1A9uZAngvZXz2eW2vYsCsFxAOoc/6BcCa5ivV8 +X4iFWa9kQPk1nbslaExK/ZsYKsdkpwX8/g+8iVdHGO/D64C0ohiXdSf5XBe/2EJ4 +bFAUR+Ku6+EhUK4ceysq9hSC4eqCyN2e8FR4YHu48jrwiyPyI9oqGuvNic0aPyyW +gUYfpgI2PP/Q6bO9YwM+2wfpQXcfpQy8i+JOlbd6m8YGafYj3rXGvwHEHOUmhdg6 +5jkA92lNrrYR6gvA+QZnYn2AcM+aToi1mx3eJ1sEzXn0UgQJUcCPDFJeGhhhpK+e +j17vltRo9W61qr1ttQ+y9UQGmNCkLUO20NW/0EFLoFrFzB8qhIX/CjA1mPIllaiG +R8Xf/Q1Mdhe/ZbQ/ufc4VuM3p7pf3udYyGAGY+/TadIECXd6ZEllzCOXQfoO0T5o +Sb6rvW2G1LulZ797EAAdLpPjinIHv/snEhLBSyYZUN+XTIpTdG+zxFE/wCyG4ML3 +1GHNmd/OfngRpkqb9rB1K2xCBvnZaJK9t1G799EGLF/EIK9Tc24O3bTcFoA2wKPh +NVmHEHXad2iZuQO8gQvQCezgwHKyk4Z4B5Klmd1uG0nMB6c1q5VpW3x3cgQs72uz +/X/vbdrPitP5fZNb3DrpoIOGFd8HeyMUryoebHducCj6W19xkaHATbyLdnd3Dl1i +fzLPzPnfDv9XyPjizZjyg3MCM9TaJ8YY+zry0x4VwadYM3XZfPGCLUxlEFlM0I9T +N+52ahoWh1U/6E6lr/mQcpKa+BJ/caU5L1X3j1cVU3KKtjz9FJVida/lbZgJS7tJ +aWEFCjq95ihfireDuoOfLDIiKfFU0yQd5q45dEgyuoWsHC1qt4iM+zwS+1fUmrQV +m49S3fm8nsaPrSc2bVp/F8KKi0eeAhfzXICtwVcTTHAoVz3XREbWQ0BpLZxWIkvk +DRK2BCa1HLbtOwwZ/tmgcmOgVdwvdXAUnlXN2ZA0KwfKDY3v0pvwzEnatSU7DH+T +K28EqBDnPY4mrelYaGT3qRZo7R4itH2fvC7M/hwzaX8mR0lyMkJADzOleWHC288W +Ku2uV4LGo0gtenICTdogcUctK8AgUAz4qF8oa8Xij0ZaB2ncYL837ZCOYiguHFQs +LrbsO6zB3wyi00PcozmjNUjgsni51ku9ftLpneR5t6d3dF6jkZlggXRRiGmbVNpb +OHkLyGEt4kryQGzw8Y+uf11Zoffzr0UjzTnTKpPHniqjUSb5YCKEG2erwb+HN0D/ +27AXRMlMACYOwoX7krgGcGrYeJJa3h9Y442TNMtMMpd3yJKOMr8OEaw= +-----END ENCRYPTED PRIVATE KEY----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/keys/root_key.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/keys/root_key.pem new file mode 100644 index 0000000000..3c8d16b9c4 --- /dev/null +++ b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/keys/root_key.pem @@ -0,0 +1,30 @@ +-----BEGIN ENCRYPTED PRIVATE KEY----- +MIIFNTBfBgkqhkiG9w0BBQ0wUjAxBgkqhkiG9w0BBQwwJAQQCCEV6O6sip4xlX6V +9cfMcAICCAAwDAYIKoZIhvcNAgkFADAdBglghkgBZQMEASoEEGMdp4t7kRReyjMr +R/DJhnwEggTQCtpkMGabpm+2IipjEdhnw+rXUkNSNFqg7nN5A+zXE9W3V/mPFJdu +/AVCkagFCUM7z5Wx4k4GIfwX0q/S1TDorcDisg9sgGWO5TYwqHCJRffOcFkf9GoJ +TSUABpYyctbpC6gbUhOAG9xCeWkYwhQ5RdIKd4I7xuPFmJm/aYclCNpFx2ymydIc +0lC+OmfrosIMlhCpX7WMB/zwubMUD7NDtxOqzvoE2HOKljfOWGWgbW6I4BGKiU7z +vZV4nJXOpcthK/qqTZbuxZDwzY3ZHYgPh9bUTTRg53jSPi6wQT+DFOjYa+HXco62 +Zsyr8ER9vdnX+GNZCRyY7AYpJZv8aIk5hh7c88/kQSluWiz6twDlSG211eMV6tOW +6N1QyscQoyay8+Ug3XxMpd3KA+rVNNBvmixj8hk6L9Aek3jGbMM+X7EcgZ66z3Q0 +kXuweb4cynaBVpryAQLT0zbUj3J5xdnJmE7+4/8PE4qKw3aZOKfL2+WlrejiUfP9 +lXa6GYhlPL435RdFw/Kv6huJ6vAL1az07G7GysImvkcLWxs4EhsSjxNB6ecGjhG0 +eAqXtMDK7yFweALT2RJSNhlKXiEyvs9Nm+kGDyBrCAqk7GTpp1fXLtKr4Nf9dTKO +6TyqjadT0hJLUVnoTxX+L8peYm2JVSeS/oCi0Im9bq1zW6MXQ74mDeSdLXWfXJjA +J9dA+CojSH9i07E/yalQxtA4nED74XmOSNK8Y8NSuZpdrZMvRmpOoWkZzMA46HQL +za0QtVNaMiHfiFV3a7ktbDCNFmAZyXz+L+4qB4V19k8Y13RgMbhDYYkwp5z1Z+Md +875DYb5QTxGDQfuYrCyDMR5TGezJ7QAvBRtN6ytxHJttqCP6pBSOOcyIsJxg5FnV +mjfGf/C7V9pkXne83IG+S9pF7IncTGRmql9QEfd7PMThuUoY16E9HN0ynCYO/x+Z +5quPMukfwh9d2fSNtpFptyXrcHGLOrvh2l4Hxypx6g+WG49q1cyUKoOldloY1o6Z +W2+LoFj1o+lJUoIAADrSTsRUEBazSygz3LevHWA+3nh1ljDfTd3eV02+CNB7xdHe +kpt8WU7yrA2a/MOgsfcUvZOaBwgDqf0mzGuPmZITjTXJzTrWoMlJKaMpw+1lPSnS +7k1RRs6KGso1E7S1JIgHeo0DZgP95+IoFL5APGwBZHX3w4LHtciR0spIVQ0lI9Um +WtDYHugnfR+j4GRmpnC9WUCBv+kRgsZxBzcPd53NfIVWu/1Vk0GH6qcCNngGwlLn +SJZncwG5bZj5IH82dNzZrtnahxLJ4n72aU3SFevxu/9KokB39doJYQU9Ifud2YwM +kYWIhDBtukpE4FWdcO7dt4Xwh9ThFttTG4VAkLNYFHOg2OINW2WmoPInD/HnYkik +qTRF1q4ItJHY9I8Tj0wTKvtqCoO1HjhVgkWdk7+BgEOII19V7OSFOeTvG+6hmCSj +WBSA+bth2RlsjCgxLx8YshbctBFhBJ/Vqm08InjRTCYmqFJm7WdUtssfZWCog63f +3TJBwwq8TPQIle8gTAsuPPjqnm+7mjzLVe6a3MY36rNB55zsxbkc9BysDKRMLDOh +0EXYDWgavFGlaycsK5HohOovpwtR9YFJ/QWHGONb3ABF48yQHq3IogE= +-----END ENCRYPTED PRIVATE KEY----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/keys/sign-key.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/keys/sign-key.pem new file mode 100644 index 0000000000..ca58df688f --- /dev/null +++ b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/keys/sign-key.pem @@ -0,0 +1,30 @@ +-----BEGIN ENCRYPTED PRIVATE KEY----- +MIIFNTBfBgkqhkiG9w0BBQ0wUjAxBgkqhkiG9w0BBQwwJAQQ19Lc6P09f69/8SfZ +XiijZgICCAAwDAYIKoZIhvcNAgkFADAdBglghkgBZQMEASoEEFDB/s9gDONS6aOH +lX2oEnEEggTQDm6xQuhgWpBClEy0wjynzXFvQvEL+IQxBauz81wr0wQvlHiDgBS/ +BDtojvYNXbaNtpt8c5vV41twVtBu0JUCfL17EMpOUq0XAYQhEWul+DcMGXy+g9A9 +WMaXBUTz96KLUk1n9B0mwZvcttNA5mq0bxRL/wc3lPSKOMDVrxUruu7et1dzC8jU +y/K5W7clmivxwLUiRrkMYVWlesDQSa+TqpdcA/K0vJXfMF6jY5ssNRhcs2EWzQwo +27U5EVTaTV3c32y+UgYAaOnmy7vlw0rhc8AR5vbUHCSKa4UTRLzlJbk47tYW/rKM +YvjeV+GZqaInkQkCoF81GoR3UF/4QQVkT0rYQEUtvSsz24MYU+irT0KBdvkxj7ah +gYSFcDXlPGBuHot8+ZwB7ofARai/O41vLnqMsLogKK9KiuIxvwJlSE1yGtZMmd/w +oJ+qpH0dY+gUCN+Cwcd9z7vyRwPfmh8e22aO97UKoA3X+wtFYt7jUycZHFe85FLW +e8N1/Ly5P2E5aSdku6x07ye596RYEi8kw+KrAL1NCSOfiejaKxpzcHaO7C6C5SGq +dTDVpi4moH5GOG2ksqlL928EwmLklMoFMgMs0CnBcKVAHOdUleIA87blVTFh8U3r +8CSStkohnhPHPgptwoXppl4wbACiZ257jDgo24GEWx82Kdaff4KReZZtlwEUUAa4 +jd+OGbAClAYJW6DGYKBcoXXYCs8Kuaoyze3YNozAXl2n9W00FS/mAG3GTK6HbzEz +7KnrpgPNWQh/jjm9YnS02pTy1g2Gk2LW0CV1HxMkTOBRRdMM4ZZejLQPPftouYnv +ZebDCUUC8fV9vEowJ0FDqgcI2k640x3xDJwtQee3GUDPtietyYHV2QvsStcVbDdg +pGaMBYnbppafyJrh5nUT8Lyvolq3G1ejd1GEFatLuFxXTCUbJ+NKwl1dC0xaexVs +439ExdWlzGwkqSMEvyB9cV79ZWaYVtIf/SpGquO0ywTu/uU8FAossWuX907OVQtz +3LOIhGDcYrpZUqeK/gc8FrOjA27UwI9/+NGaLE18On1EkYIqnN2ncguPhZrGXwGR +dfuGgmpJxSSm55Wd4WvVmLYgX0xIUKVAUv6nl8oMPOh8GRAycFRAW50yNUWjriuw +RCGO2cWBeLQodtZ1G9+5oWq5T6KBsbeFjagUONVWo8aZX4cULLZsUD5Ay3yRLdnd +ACGI0bJ1HtRfHX6hMlXj7VCosaA/4IpjSUg5yOry5bzYQ5aOyWiLGY+EV9zM5Wl5 +/tfvGFGHVi1T6yjLlHytriq9xhbWdwA+D6jEGv24c05zQUoOsNUGUncEuonx4eBN +oSVmv5TIMxK/umqnZ6LrUMxDLi+B/CWnN/sNskZP4QRKnG56/KMVk9XdmYT1ql4m +Q0yTTsy9TbXmOkIkUmm+XTRPuLH/NFjX4+zE0O2jf4PvtzYyEzHCiA0uWwEq6zrv +gsuWsCr1Y588qK6W/VC9zgfqgh/2HhSnmv/uNi5bNqnj82m3eEyrlmp4b9wtRR3k +bgoq7PyOHmP2Bj4wdUQe2+QOMLySBJm3odA7NWkBeCaq6M3ZqdHf56q/nKVReUlS +9THEOrp3W81kStFZ0ueilyviJalJq575FAQntnlFy1wgBqBmk0/0qaU= +-----END ENCRYPTED PRIVATE KEY----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/missingIssuer/chain.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/missingIssuer/chain.pem similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/missingIssuer/chain.pem rename to sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/missingIssuer/chain.pem diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/crlEncodingError/crl-issuer.cert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/missingIssuer/crl-issuer.cert.pem similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/crlEncodingError/crl-issuer.cert.pem rename to sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/missingIssuer/crl-issuer.cert.pem diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/missingIssuer/crl.crl b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/missingIssuer/crl.crl similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/missingIssuer/crl.crl rename to sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/missingIssuer/crl.crl diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/crlAndSignCertRootIssuerMismatch/sign.cert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/missingIssuer/sign.cert.pem similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/crlAndSignCertRootIssuerMismatch/sign.cert.pem rename to sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/missingIssuer/sign.cert.pem diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/multipleCrlIssuerCandidates.yml b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/multipleCrlIssuerCandidates.yml new file mode 100644 index 0000000000..28a382457b --- /dev/null +++ b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/multipleCrlIssuerCandidates.yml @@ -0,0 +1,113 @@ +external-url-prefix: "http://localhost.test" +keysets: + testkeys: + keys: + ca: + path: keys/root_key.pem + password: testpassphrase + intermediate: + path: keys/im_key.pem + password: testpassphrase + sign: + path: keys/sign-key.pem + password: testpassphrase + crl-issuer: + path: keys/crl-key.pem + password: testpassphrase + crl-issuer-candidate1: + path: keys/im_key.pem + password: testpassphrase + crl-issuer-candidate2: + path: keys/sign-key.pem + password: testpassphrase + +pki-architectures: + default: + keyset: testkeys + entity-defaults: + country-name: BE + organization-name: iText + entities: + ca: + common-name: iTextTestRoot + intermediate: + common-name: iTextTestIntermediate + sign: + common-name: iTextTestSign + crl-issuer: + common-name: iTextTestCrlIssuer + crl-issuer-candidate1: + common-name: iTextTestCrlIssuer + crl-issuer-candidate2: + common-name: iTextTestCrlIssuer + certs: + ca: + subject: ca + issuer: ca + validity: + valid-from: "2000-01-01T00:00:00+0000" + valid-to: "2500-01-01T00:00:00+0000" + extensions: + - id: basic_constraints + critical: true + value: + ca: true + - id: key_usage + critical: true + smart-value: + schema: key-usage + params: [digital_signature, non_repudiation, key_encipherment, key_cert_sign] + intermediate: + issuer: ca + validity: + valid-from: "2000-01-01T00:00:00+0000" + valid-to: "2450-01-01T00:00:00+0000" + extensions: + - id: key_usage + critical: true + smart-value: + schema: key-usage + params: [digital_signature, non_repudiation, key_encipherment, key_cert_sign, crl_sign] + sign: + issuer: intermediate + validity: + valid-from: "2000-01-01T00:00:00+0000" + valid-to: "2400-01-01T00:00:00+0000" + extensions: + - id: key_usage + critical: true + smart-value: + schema: key-usage + params: [digital_signature, non_repudiation] + crl-issuer: + issuer: ca + validity: + valid-from: "2000-01-01T00:00:00+0000" + valid-to: "2450-01-01T00:00:00+0000" + extensions: + - id: key_usage + critical: true + smart-value: + schema: key-usage + params: [ digital_signature, non_repudiation, crl_sign] + - id: crl_distribution_points + smart-value: + schema: crl-dist-url + params: + crl-repo-names: [crl] + crl-issuer-candidate1: + issuer: ca + validity: + valid-from: "2000-01-01T00:00:00+0000" + valid-to: "2450-01-01T00:00:00+0000" + crl-issuer-candidate2: + issuer: ca + validity: + valid-from: "2000-01-01T00:00:00+0000" + valid-to: "2450-01-01T00:00:00+0000" + services: + crl-repo: + crl: + for-issuer: crl-issuer + signing-key: crl-issuer + simulated-update-schedule: "P90D" \ No newline at end of file diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/multipleCrlIssuerCandidates/ca.cert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/multipleCrlIssuerCandidates/ca.cert.pem new file mode 100644 index 0000000000..efb7717302 --- /dev/null +++ b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/multipleCrlIssuerCandidates/ca.cert.pem @@ -0,0 +1,20 @@ +-----BEGIN CERTIFICATE----- +MIIDSzCCAjOgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwNTELMAkGA1UEBhMCQkUx +DjAMBgNVBAoMBWlUZXh0MRYwFAYDVQQDDA1pVGV4dFRlc3RSb290MCAXDTAwMDEw +MTAwMDAwMFoYDzI1MDAwMTAxMDAwMDAwWjA1MQswCQYDVQQGEwJCRTEOMAwGA1UE +CgwFaVRleHQxFjAUBgNVBAMMDWlUZXh0VGVzdFJvb3QwggEiMA0GCSqGSIb3DQEB +AQUAA4IBDwAwggEKAoIBAQDYxUs+SgZkRkOhOfddCnPeuE1QP2kAm6gAsg4qjNzr +rZpZvwziyWaz6bXXq8fATjXEAdypAiWL/BDZscdCM/M11jds9mMv7dMvCtLns6Oe +4GbChYxxloN2rVxElFPK2siKBaEeWyItr2Ms0P+hSR5uHjFt+krzl2zv828fyEnH +fPvln42SAcuCKsLmfjtutus5jFKBFF8oiqDFlI2eXYggKV7JELttgPLobv2ZyFa5 +nXo/xbtzlPb8AvV3/mxpX4prFhBXupJXuCwmqmzVRqGbwKSz/Bewb/4aJGSpg32x +yIWeXTld58f+Jntfes8xHwK0aJB/Tm2WrH+RWoV+TN/pAgMBAAGjYzBhMB0GA1Ud +DgQWBBR0MlTFwFzoq8mPVusDjIEnL5avqzAfBgNVHSMEGDAWgBR0MlTFwFzoq8mP +VusDjIEnL5avqzAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIC5DANBgkq +hkiG9w0BAQsFAAOCAQEAK2dbxbQ7jEdtqvnMpKOZsB55PDO5OZ2hPYilT5ZVZNt1 +jdE94HdCBHED3upmOeBH+XtsK/MLk+eYICM5SZwWVCBY0aQQR0URyTsX4SA/12A5 +VhrnP6bqy4b+3mO3J9s0go59cZOtSkxQ7191teEQMsDeh8GxXGLW/7Tf4x6v7U34 +B7UghMhUD2bHJ7U8MOqto9fVar/9S93tc9vRtYOXZbfRwjFKOYD4IFm7cH3VnrX7 +od3KUEKGKhQ2ZaqrtnW19xNTbdRcMT3+8QSai9DLV0kGGSSY09AHDO3WvxkAs9ZI +cIsMM/n+mLK0Km9fh5uE3k6NmiN3GV+QMyjbmFnVNg== +-----END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/multipleCrlIssuerCandidates/chain.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/multipleCrlIssuerCandidates/chain.pem new file mode 100644 index 0000000000..c5a2a1b14e --- /dev/null +++ b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/multipleCrlIssuerCandidates/chain.pem @@ -0,0 +1,121 @@ +-----BEGIN CERTIFICATE----- +MIIDSzCCAjOgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwNTELMAkGA1UEBhMCQkUx +DjAMBgNVBAoMBWlUZXh0MRYwFAYDVQQDDA1pVGV4dFRlc3RSb290MCAXDTAwMDEw +MTAwMDAwMFoYDzI1MDAwMTAxMDAwMDAwWjA1MQswCQYDVQQGEwJCRTEOMAwGA1UE +CgwFaVRleHQxFjAUBgNVBAMMDWlUZXh0VGVzdFJvb3QwggEiMA0GCSqGSIb3DQEB +AQUAA4IBDwAwggEKAoIBAQDYxUs+SgZkRkOhOfddCnPeuE1QP2kAm6gAsg4qjNzr +rZpZvwziyWaz6bXXq8fATjXEAdypAiWL/BDZscdCM/M11jds9mMv7dMvCtLns6Oe +4GbChYxxloN2rVxElFPK2siKBaEeWyItr2Ms0P+hSR5uHjFt+krzl2zv828fyEnH +fPvln42SAcuCKsLmfjtutus5jFKBFF8oiqDFlI2eXYggKV7JELttgPLobv2ZyFa5 +nXo/xbtzlPb8AvV3/mxpX4prFhBXupJXuCwmqmzVRqGbwKSz/Bewb/4aJGSpg32x +yIWeXTld58f+Jntfes8xHwK0aJB/Tm2WrH+RWoV+TN/pAgMBAAGjYzBhMB0GA1Ud +DgQWBBR0MlTFwFzoq8mPVusDjIEnL5avqzAfBgNVHSMEGDAWgBR0MlTFwFzoq8mP +VusDjIEnL5avqzAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIC5DANBgkq +hkiG9w0BAQsFAAOCAQEAK2dbxbQ7jEdtqvnMpKOZsB55PDO5OZ2hPYilT5ZVZNt1 +jdE94HdCBHED3upmOeBH+XtsK/MLk+eYICM5SZwWVCBY0aQQR0URyTsX4SA/12A5 +VhrnP6bqy4b+3mO3J9s0go59cZOtSkxQ7191teEQMsDeh8GxXGLW/7Tf4x6v7U34 +B7UghMhUD2bHJ7U8MOqto9fVar/9S93tc9vRtYOXZbfRwjFKOYD4IFm7cH3VnrX7 +od3KUEKGKhQ2ZaqrtnW19xNTbdRcMT3+8QSai9DLV0kGGSSY09AHDO3WvxkAs9ZI +cIsMM/n+mLK0Km9fh5uE3k6NmiN3GV+QMyjbmFnVNg== +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDLzCCAhegAwIBAgICEAMwDQYJKoZIhvcNAQELBQAwNTELMAkGA1UEBhMCQkUx +DjAMBgNVBAoMBWlUZXh0MRYwFAYDVQQDDA1pVGV4dFRlc3RSb290MCAXDTAwMDEw +MTAwMDAwMFoYDzI0NTAwMTAxMDAwMDAwWjA6MQswCQYDVQQGEwJCRTEOMAwGA1UE +CgwFaVRleHQxGzAZBgNVBAMMEmlUZXh0VGVzdENybElzc3VlcjCCASIwDQYJKoZI +hvcNAQEBBQADggEPADCCAQoCggEBAJ6M9OSQgx20Fw14rYFeM6HQuQxBD276e6kX +MpmdsbbkvExq5mrAWPvFGYHCmRAtH7pGm1pL91Zlgh1CbUPzwSa/Lfp9FeAX83G7 +OJn0sY3kJRthtj5B0dGinXSIFCIb6gx9ICzoVpY9Ljvl4tyBr0dkGmED3MBxSFlt +OMPplDhYwFekL7woNXMFIAxMnDWuS7dZ7xEpLAwNfH9D92I4lzSrQ9TrxwDPdW2g +WGvi2eu77W4YqFQgydgbKmFHAzDUTA01LNmKZkASBcLUoiLnLBMmVYgDMH4fo4oj ++2/J/OZNuGv5DK9dRCryAhnY3f8/9b8JzoPeRCmgRO9IU7ObZ/0CAwEAAaNCMEAw +HQYDVR0OBBYEFIlAkiqUVGkQL00y55tlNrfwvGTVMB8GA1UdIwQYMBaAFHQyVMXA +XOiryY9W6wOMgScvlq+rMA0GCSqGSIb3DQEBCwUAA4IBAQAPKoa+iFhdqGoBXjuj ++m/xG2NAetvfpN4Sfy8RGOhEypsre2Xk/MzL6UBa59IYK3cd/x8ceAqPoBozL+NZ +Xu3WzvD65zoLDJxBtHpOjaz3Mi/Yjxlfw7mb+loUj8tusouGhqhvJuKTzpXafFYu +Ue1gwk+Lb3KsunkMhPc5s2h/yTkgbnrBbHuP5g8HRW0pbk3xZC4qHmrMsWHFGLba +CAZ+AcyRaIGHqFQwnflWuMBNXr2KNL6J9IBs33mPNEaJZEqyIr5N7urXcTUS0Cog +ZA3eugW6tacN8hR+6RA4dBIpPVth/tV2V3OtyeRUFKPrFYmaalgfSXYQPzoKDZpr +SP8t +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDLzCCAhegAwIBAgICEAQwDQYJKoZIhvcNAQELBQAwNTELMAkGA1UEBhMCQkUx +DjAMBgNVBAoMBWlUZXh0MRYwFAYDVQQDDA1pVGV4dFRlc3RSb290MCAXDTAwMDEw +MTAwMDAwMFoYDzI0NTAwMTAxMDAwMDAwWjA6MQswCQYDVQQGEwJCRTEOMAwGA1UE +CgwFaVRleHQxGzAZBgNVBAMMEmlUZXh0VGVzdENybElzc3VlcjCCASIwDQYJKoZI +hvcNAQEBBQADggEPADCCAQoCggEBALMHHzTZo1BOQkZzEZl2Q3leNfBH20YfO4R0 +l0ZBWbnpg/099ON4I8ItO0f24Wq0gs//+1adlJqeUMeUVxQ0fpu0cHQOc9h7CWJL +nPAJjEvItZ5WXW4l8/ppo1bo4WLB1hToF42NfHgh7Laoj2gqVLWXS6Ngd8chVxIT +axfKA9PG56dje+PlJnTNi+ayudB/O57dhoaAu+sbxBhog/7zRAV87OsH9zxcNuw+ +3ZzHhss5Lpn6F+/WDcHPyXsT7QkX6rvbRvxUOpcysXtCH3v5+ZRKyUqRPlI63/hy +MMZBDqYtFDHiawk587hbMp2swHF6z56d10Za22Vq9lxiX4MdftsCAwEAAaNCMEAw +HQYDVR0OBBYEFFVqj/1gRbt6YJdo1/zMvcyOmY1cMB8GA1UdIwQYMBaAFHQyVMXA +XOiryY9W6wOMgScvlq+rMA0GCSqGSIb3DQEBCwUAA4IBAQC5ZQAycuP/G9srjdfF +nT33PWTfQn98+YybTBcb1Zj1zsD8ELBvN1esksMknNyYwL212CuY0pN32adV9eUQ +A3GrLWEeBICJB6TR6UJ/BSI/0kLeN5TaAb0aRzjENQDAe3tJPXD1vVmNWvYxrDCk +ncdKVOODsz4N+v0+EO8iUUNENDp69VyPBbw0oLjTHCwtqx5B3m35oHibXT3BuQPd +OVDxFfd3PB/CrDWibobVOWw6MaTt5Oiv9WKbo0l0qZ76vyKdjqbQwqHdSfr23k/Y +5PB9YYlqqPPxdSExzka/Oi7n21x1NhAr2T42p1Ff3ph3oQ2P3Qwn72ESu3riImmK +18vH +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDhTCCAm2gAwIBAgICEAIwDQYJKoZIhvcNAQELBQAwNTELMAkGA1UEBhMCQkUx +DjAMBgNVBAoMBWlUZXh0MRYwFAYDVQQDDA1pVGV4dFRlc3RSb290MCAXDTAwMDEw +MTAwMDAwMFoYDzI0NTAwMTAxMDAwMDAwWjA6MQswCQYDVQQGEwJCRTEOMAwGA1UE +CgwFaVRleHQxGzAZBgNVBAMMEmlUZXh0VGVzdENybElzc3VlcjCCASIwDQYJKoZI +hvcNAQEBBQADggEPADCCAQoCggEBAMJ7DjX87Zpw3SySm1nfLBP9rcaJse9hwZ6w +TNxtmy6Rn3LwBZvZ/xdFi39XTw2GPeCQBSrARhtBJ4eHgSe+d2R4LoP6sAyIheQ5 +0R+e3thLaCVsF43kpuSiyLGlnFLFBhyQ30vEn1g6jiAwqfqptpr9TPfKaCrCKOJU +R8jOFwy+RERlAGJJQNIeZ6Bz9VdSZwkNP+Gfo+HV9LX057MaeMAPgrvAJrHy/lD9 +y07u0qKN62xzLZ/Mn9do+3qITEU1+9XkX9X0dTXrNMAO9kT3ukR6XdZIl8lvD/2P +gTTaaro51v0ei3I7FZXNokjyuF6J8ARMVxqeOMlVUIxLeBv7j60CAwEAAaOBlzCB +lDAdBgNVHQ4EFgQUEm6hMPB11w1J72tXumBhewwWxnUwHwYDVR0jBBgwFoAUdDJU +xcBc6KvJj1brA4yBJy+Wr6swDgYDVR0PAQH/BAQDAgHCMEIGA1UdHwQ7MDkwN6A1 +oDOGMWh0dHA6Ly9sb2NhbGhvc3QudGVzdC9kZWZhdWx0L2NybHMvY3JsL2xhdGVz +dC5jcmwwDQYJKoZIhvcNAQELBQADggEBAEg69NBvQJkOO25o1UxRoJqKb7PdwF5K +xiidxXjJQTZHVR56rWoMfg/31eDwBdc6bmSAELd2wPSs3Ov3HJJP4f31+plXB3Qb +B5pQUEc5i4IZiE0jz7Be4GLqSVNaLh9ay4o8PnpvcIZiKNukJzPhGsOzW8xrTF7R +Cc6VSjmLHG2UnEt2CBbkaWnVXV8ibENSawv4Ar2AKpcU9LLoT1F92zx/7YpUQLr1 +k/RwWxkKByV5ko001DuwiWf/BjZ67pu5WTgdHQP9KaNMahnSqrjERCTLWVipdvJ2 +o3bHCe9I0OQMVlMeesKMWPRqLiAMpz7f7q09AXlqjvZT9+FPSi6nsss= +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDQjCCAiqgAwIBAgICEAEwDQYJKoZIhvcNAQELBQAwNTELMAkGA1UEBhMCQkUx +DjAMBgNVBAoMBWlUZXh0MRYwFAYDVQQDDA1pVGV4dFRlc3RSb290MCAXDTAwMDEw +MTAwMDAwMFoYDzI0NTAwMTAxMDAwMDAwWjA9MQswCQYDVQQGEwJCRTEOMAwGA1UE +CgwFaVRleHQxHjAcBgNVBAMMFWlUZXh0VGVzdEludGVybWVkaWF0ZTCCASIwDQYJ +KoZIhvcNAQEBBQADggEPADCCAQoCggEBAJ6M9OSQgx20Fw14rYFeM6HQuQxBD276 +e6kXMpmdsbbkvExq5mrAWPvFGYHCmRAtH7pGm1pL91Zlgh1CbUPzwSa/Lfp9FeAX +83G7OJn0sY3kJRthtj5B0dGinXSIFCIb6gx9ICzoVpY9Ljvl4tyBr0dkGmED3MBx +SFltOMPplDhYwFekL7woNXMFIAxMnDWuS7dZ7xEpLAwNfH9D92I4lzSrQ9TrxwDP +dW2gWGvi2eu77W4YqFQgydgbKmFHAzDUTA01LNmKZkASBcLUoiLnLBMmVYgDMH4f +o4oj+2/J/OZNuGv5DK9dRCryAhnY3f8/9b8JzoPeRCmgRO9IU7ObZ/0CAwEAAaNS +MFAwHQYDVR0OBBYEFIlAkiqUVGkQL00y55tlNrfwvGTVMB8GA1UdIwQYMBaAFHQy +VMXAXOiryY9W6wOMgScvlq+rMA4GA1UdDwEB/wQEAwIB5jANBgkqhkiG9w0BAQsF +AAOCAQEAMoIJ86nzczzR41l5EFHlxGvUEQY/w7BJ42LICN3F12WPmJ+A3i/GAJSQ +14W+Jy8CXEhEFZF3R45vuOAGhOkF7igtbXeeVXunM3rmi8XIlpGjqbBZxC5w1Fd8 +IPOTArrzcF8agwthRzKOEpFSklmpUDT4MYZkdzR7TVM6TkdL+ModYFrhf9/+OFGb +qHzKUPVv+dvNaKn6JvKfQ311MKG3fLU7vyKEUNoolAnLMy3VETsnhMTk6Wa5rfzJ +eq2sdBiLxgwC3xhYk33Cla0X3hsr++Yqb8BX1ztKaRxu0PSi+KKJ9kvXAxRkFlwh +Xa7iIRXelUhftWRF/4VgDsDhWx+eDQ== +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIDQjCCAiqgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwPTELMAkGA1UEBhMCQkUx +DjAMBgNVBAoMBWlUZXh0MR4wHAYDVQQDDBVpVGV4dFRlc3RJbnRlcm1lZGlhdGUw +IBcNMDAwMTAxMDAwMDAwWhgPMjQwMDAxMDEwMDAwMDBaMDUxCzAJBgNVBAYTAkJF +MQ4wDAYDVQQKDAVpVGV4dDEWMBQGA1UEAwwNaVRleHRUZXN0U2lnbjCCASIwDQYJ +KoZIhvcNAQEBBQADggEPADCCAQoCggEBALMHHzTZo1BOQkZzEZl2Q3leNfBH20Yf +O4R0l0ZBWbnpg/099ON4I8ItO0f24Wq0gs//+1adlJqeUMeUVxQ0fpu0cHQOc9h7 +CWJLnPAJjEvItZ5WXW4l8/ppo1bo4WLB1hToF42NfHgh7Laoj2gqVLWXS6Ngd8ch +VxITaxfKA9PG56dje+PlJnTNi+ayudB/O57dhoaAu+sbxBhog/7zRAV87OsH9zxc +Nuw+3ZzHhss5Lpn6F+/WDcHPyXsT7QkX6rvbRvxUOpcysXtCH3v5+ZRKyUqRPlI6 +3/hyMMZBDqYtFDHiawk587hbMp2swHF6z56d10Za22Vq9lxiX4MdftsCAwEAAaNS +MFAwHQYDVR0OBBYEFFVqj/1gRbt6YJdo1/zMvcyOmY1cMB8GA1UdIwQYMBaAFIlA +kiqUVGkQL00y55tlNrfwvGTVMA4GA1UdDwEB/wQEAwIGwDANBgkqhkiG9w0BAQsF +AAOCAQEAMsIeJp6AHJwChOEddcGu5dD/Q4R6l7dMIe3Q8g8vDVz94572jmvHIOa5 +Q/xJALRFn5rG1oC06q6Gy4ffbUm5S1dNBXdmwyfNzAa5yAwXraIWkXLPM5zFUueB +qu2ekfPhHq0NjCqhVCCYkhngaf+mqeuw8usML6mMf8o0aC6TlQu7GXm/6Z4SSKmY +wDyM4iSVR3fZHb3R/VBP7+GNKsamapZPThdxueWnm6o2vsMKSfgGHRV/41BrUqb7 +t5SXDihXCImTpUr89EL7kix42Q/BFQ60hO3LYsKn4w8gjUQffQdlB2zR6cQJx2eK +9jrkP1+J6xcuWHHrn2l9YXw6rI7r0g== +-----END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/multipleCrlIssuerCandidates/crl-issuer-candidate1.cert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/multipleCrlIssuerCandidates/crl-issuer-candidate1.cert.pem new file mode 100644 index 0000000000..cb1f374156 --- /dev/null +++ b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/multipleCrlIssuerCandidates/crl-issuer-candidate1.cert.pem @@ -0,0 +1,20 @@ +-----BEGIN CERTIFICATE----- +MIIDLzCCAhegAwIBAgICEAMwDQYJKoZIhvcNAQELBQAwNTELMAkGA1UEBhMCQkUx +DjAMBgNVBAoMBWlUZXh0MRYwFAYDVQQDDA1pVGV4dFRlc3RSb290MCAXDTAwMDEw +MTAwMDAwMFoYDzI0NTAwMTAxMDAwMDAwWjA6MQswCQYDVQQGEwJCRTEOMAwGA1UE +CgwFaVRleHQxGzAZBgNVBAMMEmlUZXh0VGVzdENybElzc3VlcjCCASIwDQYJKoZI +hvcNAQEBBQADggEPADCCAQoCggEBAJ6M9OSQgx20Fw14rYFeM6HQuQxBD276e6kX +MpmdsbbkvExq5mrAWPvFGYHCmRAtH7pGm1pL91Zlgh1CbUPzwSa/Lfp9FeAX83G7 +OJn0sY3kJRthtj5B0dGinXSIFCIb6gx9ICzoVpY9Ljvl4tyBr0dkGmED3MBxSFlt +OMPplDhYwFekL7woNXMFIAxMnDWuS7dZ7xEpLAwNfH9D92I4lzSrQ9TrxwDPdW2g +WGvi2eu77W4YqFQgydgbKmFHAzDUTA01LNmKZkASBcLUoiLnLBMmVYgDMH4fo4oj ++2/J/OZNuGv5DK9dRCryAhnY3f8/9b8JzoPeRCmgRO9IU7ObZ/0CAwEAAaNCMEAw +HQYDVR0OBBYEFIlAkiqUVGkQL00y55tlNrfwvGTVMB8GA1UdIwQYMBaAFHQyVMXA +XOiryY9W6wOMgScvlq+rMA0GCSqGSIb3DQEBCwUAA4IBAQAPKoa+iFhdqGoBXjuj ++m/xG2NAetvfpN4Sfy8RGOhEypsre2Xk/MzL6UBa59IYK3cd/x8ceAqPoBozL+NZ +Xu3WzvD65zoLDJxBtHpOjaz3Mi/Yjxlfw7mb+loUj8tusouGhqhvJuKTzpXafFYu +Ue1gwk+Lb3KsunkMhPc5s2h/yTkgbnrBbHuP5g8HRW0pbk3xZC4qHmrMsWHFGLba +CAZ+AcyRaIGHqFQwnflWuMBNXr2KNL6J9IBs33mPNEaJZEqyIr5N7urXcTUS0Cog +ZA3eugW6tacN8hR+6RA4dBIpPVth/tV2V3OtyeRUFKPrFYmaalgfSXYQPzoKDZpr +SP8t +-----END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/multipleCrlIssuerCandidates/crl-issuer-candidate2.cert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/multipleCrlIssuerCandidates/crl-issuer-candidate2.cert.pem new file mode 100644 index 0000000000..dba77cd210 --- /dev/null +++ b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/multipleCrlIssuerCandidates/crl-issuer-candidate2.cert.pem @@ -0,0 +1,20 @@ +-----BEGIN CERTIFICATE----- +MIIDLzCCAhegAwIBAgICEAQwDQYJKoZIhvcNAQELBQAwNTELMAkGA1UEBhMCQkUx +DjAMBgNVBAoMBWlUZXh0MRYwFAYDVQQDDA1pVGV4dFRlc3RSb290MCAXDTAwMDEw +MTAwMDAwMFoYDzI0NTAwMTAxMDAwMDAwWjA6MQswCQYDVQQGEwJCRTEOMAwGA1UE +CgwFaVRleHQxGzAZBgNVBAMMEmlUZXh0VGVzdENybElzc3VlcjCCASIwDQYJKoZI +hvcNAQEBBQADggEPADCCAQoCggEBALMHHzTZo1BOQkZzEZl2Q3leNfBH20YfO4R0 +l0ZBWbnpg/099ON4I8ItO0f24Wq0gs//+1adlJqeUMeUVxQ0fpu0cHQOc9h7CWJL +nPAJjEvItZ5WXW4l8/ppo1bo4WLB1hToF42NfHgh7Laoj2gqVLWXS6Ngd8chVxIT +axfKA9PG56dje+PlJnTNi+ayudB/O57dhoaAu+sbxBhog/7zRAV87OsH9zxcNuw+ +3ZzHhss5Lpn6F+/WDcHPyXsT7QkX6rvbRvxUOpcysXtCH3v5+ZRKyUqRPlI63/hy +MMZBDqYtFDHiawk587hbMp2swHF6z56d10Za22Vq9lxiX4MdftsCAwEAAaNCMEAw +HQYDVR0OBBYEFFVqj/1gRbt6YJdo1/zMvcyOmY1cMB8GA1UdIwQYMBaAFHQyVMXA +XOiryY9W6wOMgScvlq+rMA0GCSqGSIb3DQEBCwUAA4IBAQC5ZQAycuP/G9srjdfF +nT33PWTfQn98+YybTBcb1Zj1zsD8ELBvN1esksMknNyYwL212CuY0pN32adV9eUQ +A3GrLWEeBICJB6TR6UJ/BSI/0kLeN5TaAb0aRzjENQDAe3tJPXD1vVmNWvYxrDCk +ncdKVOODsz4N+v0+EO8iUUNENDp69VyPBbw0oLjTHCwtqx5B3m35oHibXT3BuQPd +OVDxFfd3PB/CrDWibobVOWw6MaTt5Oiv9WKbo0l0qZ76vyKdjqbQwqHdSfr23k/Y +5PB9YYlqqPPxdSExzka/Oi7n21x1NhAr2T42p1Ff3ph3oQ2P3Qwn72ESu3riImmK +18vH +-----END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/multipleCrlIssuerCandidates/crl-issuer.cert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/multipleCrlIssuerCandidates/crl-issuer.cert.pem new file mode 100644 index 0000000000..3656f9e733 --- /dev/null +++ b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/multipleCrlIssuerCandidates/crl-issuer.cert.pem @@ -0,0 +1,21 @@ +-----BEGIN CERTIFICATE----- +MIIDhTCCAm2gAwIBAgICEAIwDQYJKoZIhvcNAQELBQAwNTELMAkGA1UEBhMCQkUx +DjAMBgNVBAoMBWlUZXh0MRYwFAYDVQQDDA1pVGV4dFRlc3RSb290MCAXDTAwMDEw +MTAwMDAwMFoYDzI0NTAwMTAxMDAwMDAwWjA6MQswCQYDVQQGEwJCRTEOMAwGA1UE +CgwFaVRleHQxGzAZBgNVBAMMEmlUZXh0VGVzdENybElzc3VlcjCCASIwDQYJKoZI +hvcNAQEBBQADggEPADCCAQoCggEBAMJ7DjX87Zpw3SySm1nfLBP9rcaJse9hwZ6w +TNxtmy6Rn3LwBZvZ/xdFi39XTw2GPeCQBSrARhtBJ4eHgSe+d2R4LoP6sAyIheQ5 +0R+e3thLaCVsF43kpuSiyLGlnFLFBhyQ30vEn1g6jiAwqfqptpr9TPfKaCrCKOJU +R8jOFwy+RERlAGJJQNIeZ6Bz9VdSZwkNP+Gfo+HV9LX057MaeMAPgrvAJrHy/lD9 +y07u0qKN62xzLZ/Mn9do+3qITEU1+9XkX9X0dTXrNMAO9kT3ukR6XdZIl8lvD/2P +gTTaaro51v0ei3I7FZXNokjyuF6J8ARMVxqeOMlVUIxLeBv7j60CAwEAAaOBlzCB +lDAdBgNVHQ4EFgQUEm6hMPB11w1J72tXumBhewwWxnUwHwYDVR0jBBgwFoAUdDJU +xcBc6KvJj1brA4yBJy+Wr6swDgYDVR0PAQH/BAQDAgHCMEIGA1UdHwQ7MDkwN6A1 +oDOGMWh0dHA6Ly9sb2NhbGhvc3QudGVzdC9kZWZhdWx0L2NybHMvY3JsL2xhdGVz +dC5jcmwwDQYJKoZIhvcNAQELBQADggEBAEg69NBvQJkOO25o1UxRoJqKb7PdwF5K +xiidxXjJQTZHVR56rWoMfg/31eDwBdc6bmSAELd2wPSs3Ov3HJJP4f31+plXB3Qb +B5pQUEc5i4IZiE0jz7Be4GLqSVNaLh9ay4o8PnpvcIZiKNukJzPhGsOzW8xrTF7R +Cc6VSjmLHG2UnEt2CBbkaWnVXV8ibENSawv4Ar2AKpcU9LLoT1F92zx/7YpUQLr1 +k/RwWxkKByV5ko001DuwiWf/BjZ67pu5WTgdHQP9KaNMahnSqrjERCTLWVipdvJ2 +o3bHCe9I0OQMVlMeesKMWPRqLiAMpz7f7q09AXlqjvZT9+FPSi6nsss= +-----END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/multipleCrlIssuerCandidates/intermediate.cert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/multipleCrlIssuerCandidates/intermediate.cert.pem new file mode 100644 index 0000000000..ca4cf7ba9c --- /dev/null +++ b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/multipleCrlIssuerCandidates/intermediate.cert.pem @@ -0,0 +1,20 @@ +-----BEGIN CERTIFICATE----- +MIIDQjCCAiqgAwIBAgICEAEwDQYJKoZIhvcNAQELBQAwNTELMAkGA1UEBhMCQkUx +DjAMBgNVBAoMBWlUZXh0MRYwFAYDVQQDDA1pVGV4dFRlc3RSb290MCAXDTAwMDEw +MTAwMDAwMFoYDzI0NTAwMTAxMDAwMDAwWjA9MQswCQYDVQQGEwJCRTEOMAwGA1UE +CgwFaVRleHQxHjAcBgNVBAMMFWlUZXh0VGVzdEludGVybWVkaWF0ZTCCASIwDQYJ +KoZIhvcNAQEBBQADggEPADCCAQoCggEBAJ6M9OSQgx20Fw14rYFeM6HQuQxBD276 +e6kXMpmdsbbkvExq5mrAWPvFGYHCmRAtH7pGm1pL91Zlgh1CbUPzwSa/Lfp9FeAX +83G7OJn0sY3kJRthtj5B0dGinXSIFCIb6gx9ICzoVpY9Ljvl4tyBr0dkGmED3MBx +SFltOMPplDhYwFekL7woNXMFIAxMnDWuS7dZ7xEpLAwNfH9D92I4lzSrQ9TrxwDP +dW2gWGvi2eu77W4YqFQgydgbKmFHAzDUTA01LNmKZkASBcLUoiLnLBMmVYgDMH4f +o4oj+2/J/OZNuGv5DK9dRCryAhnY3f8/9b8JzoPeRCmgRO9IU7ObZ/0CAwEAAaNS +MFAwHQYDVR0OBBYEFIlAkiqUVGkQL00y55tlNrfwvGTVMB8GA1UdIwQYMBaAFHQy +VMXAXOiryY9W6wOMgScvlq+rMA4GA1UdDwEB/wQEAwIB5jANBgkqhkiG9w0BAQsF +AAOCAQEAMoIJ86nzczzR41l5EFHlxGvUEQY/w7BJ42LICN3F12WPmJ+A3i/GAJSQ +14W+Jy8CXEhEFZF3R45vuOAGhOkF7igtbXeeVXunM3rmi8XIlpGjqbBZxC5w1Fd8 +IPOTArrzcF8agwthRzKOEpFSklmpUDT4MYZkdzR7TVM6TkdL+ModYFrhf9/+OFGb +qHzKUPVv+dvNaKn6JvKfQ311MKG3fLU7vyKEUNoolAnLMy3VETsnhMTk6Wa5rfzJ +eq2sdBiLxgwC3xhYk33Cla0X3hsr++Yqb8BX1ztKaRxu0PSi+KKJ9kvXAxRkFlwh +Xa7iIRXelUhftWRF/4VgDsDhWx+eDQ== +-----END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/multipleCrlIssuerCandidates/sign.cert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/multipleCrlIssuerCandidates/sign.cert.pem new file mode 100644 index 0000000000..bfcfbf0242 --- /dev/null +++ b/sign/src/test/resources/com/itextpdf/signatures/validation/CRLValidatorTest/multipleCrlIssuerCandidates/sign.cert.pem @@ -0,0 +1,20 @@ +-----BEGIN CERTIFICATE----- +MIIDQjCCAiqgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwPTELMAkGA1UEBhMCQkUx +DjAMBgNVBAoMBWlUZXh0MR4wHAYDVQQDDBVpVGV4dFRlc3RJbnRlcm1lZGlhdGUw +IBcNMDAwMTAxMDAwMDAwWhgPMjQwMDAxMDEwMDAwMDBaMDUxCzAJBgNVBAYTAkJF +MQ4wDAYDVQQKDAVpVGV4dDEWMBQGA1UEAwwNaVRleHRUZXN0U2lnbjCCASIwDQYJ +KoZIhvcNAQEBBQADggEPADCCAQoCggEBALMHHzTZo1BOQkZzEZl2Q3leNfBH20Yf +O4R0l0ZBWbnpg/099ON4I8ItO0f24Wq0gs//+1adlJqeUMeUVxQ0fpu0cHQOc9h7 +CWJLnPAJjEvItZ5WXW4l8/ppo1bo4WLB1hToF42NfHgh7Laoj2gqVLWXS6Ngd8ch +VxITaxfKA9PG56dje+PlJnTNi+ayudB/O57dhoaAu+sbxBhog/7zRAV87OsH9zxc +Nuw+3ZzHhss5Lpn6F+/WDcHPyXsT7QkX6rvbRvxUOpcysXtCH3v5+ZRKyUqRPlI6 +3/hyMMZBDqYtFDHiawk587hbMp2swHF6z56d10Za22Vq9lxiX4MdftsCAwEAAaNS +MFAwHQYDVR0OBBYEFFVqj/1gRbt6YJdo1/zMvcyOmY1cMB8GA1UdIwQYMBaAFIlA +kiqUVGkQL00y55tlNrfwvGTVMA4GA1UdDwEB/wQEAwIGwDANBgkqhkiG9w0BAQsF +AAOCAQEAMsIeJp6AHJwChOEddcGu5dD/Q4R6l7dMIe3Q8g8vDVz94572jmvHIOa5 +Q/xJALRFn5rG1oC06q6Gy4ffbUm5S1dNBXdmwyfNzAa5yAwXraIWkXLPM5zFUueB +qu2ekfPhHq0NjCqhVCCYkhngaf+mqeuw8usML6mMf8o0aC6TlQu7GXm/6Z4SSKmY +wDyM4iSVR3fZHb3R/VBP7+GNKsamapZPThdxueWnm6o2vsMKSfgGHRV/41BrUqb7 +t5SXDihXCImTpUr89EL7kix42Q/BFQ60hO3LYsKn4w8gjUQffQdlB2zR6cQJx2eK +9jrkP1+J6xcuWHHrn2l9YXw6rI7r0g== +-----END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/crlIssuerAndSignCertHaveNoSharedRoot/ca.cert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/CertificateChainValidatorTest/ca.cert.pem similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/crlIssuerAndSignCertHaveNoSharedRoot/ca.cert.pem rename to sign/src/test/resources/com/itextpdf/signatures/validation/CertificateChainValidatorTest/ca.cert.pem diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CertificateChainValidatorTest/chain.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/CertificateChainValidatorTest/chain.pem similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/CertificateChainValidatorTest/chain.pem rename to sign/src/test/resources/com/itextpdf/signatures/validation/CertificateChainValidatorTest/chain.pem diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CertificateChainValidatorTest/chainValidator.yml b/sign/src/test/resources/com/itextpdf/signatures/validation/CertificateChainValidatorTest/chainValidator.yml similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/CertificateChainValidatorTest/chainValidator.yml rename to sign/src/test/resources/com/itextpdf/signatures/validation/CertificateChainValidatorTest/chainValidator.yml diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CertificateChainValidatorTest/expired-intermediate.cert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/CertificateChainValidatorTest/expired-intermediate.cert.pem similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/CertificateChainValidatorTest/expired-intermediate.cert.pem rename to sign/src/test/resources/com/itextpdf/signatures/validation/CertificateChainValidatorTest/expired-intermediate.cert.pem diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CertificateChainValidatorTest/invalidCertsChain.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/CertificateChainValidatorTest/invalidCertsChain.pem similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/CertificateChainValidatorTest/invalidCertsChain.pem rename to sign/src/test/resources/com/itextpdf/signatures/validation/CertificateChainValidatorTest/invalidCertsChain.pem diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CertificateChainValidatorTest/not-yet-valid-intermediate.cert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/CertificateChainValidatorTest/not-yet-valid-intermediate.cert.pem similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/CertificateChainValidatorTest/not-yet-valid-intermediate.cert.pem rename to sign/src/test/resources/com/itextpdf/signatures/validation/CertificateChainValidatorTest/not-yet-valid-intermediate.cert.pem diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CertificateChainValidatorTest/signChainWithInvalidNumericBasicConstraints.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/CertificateChainValidatorTest/signChainWithInvalidNumericBasicConstraints.pem similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/CertificateChainValidatorTest/signChainWithInvalidNumericBasicConstraints.pem rename to sign/src/test/resources/com/itextpdf/signatures/validation/CertificateChainValidatorTest/signChainWithInvalidNumericBasicConstraints.pem diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CertificateChainValidatorTest/signChainWithValidNumericBasicConstraints.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/CertificateChainValidatorTest/signChainWithValidNumericBasicConstraints.pem similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/CertificateChainValidatorTest/signChainWithValidNumericBasicConstraints.pem rename to sign/src/test/resources/com/itextpdf/signatures/validation/CertificateChainValidatorTest/signChainWithValidNumericBasicConstraints.pem diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/certificationSignatureAfterApproval.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/certificationSignatureAfterApproval.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/certificationSignatureAfterApproval.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/certificationSignatureAfterApproval.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/complicatedTaggedDoc.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/complicatedTaggedDoc.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/complicatedTaggedDoc.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/complicatedTaggedDoc.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/danglingWidgetAnnotation.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/danglingWidgetAnnotation.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/danglingWidgetAnnotation.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/danglingWidgetAnnotation.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/differentFieldLockLevels.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/differentFieldLockLevels.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/differentFieldLockLevels.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/differentFieldLockLevels.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/eolNotIncludedIntoByteRange.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/eolNotIncludedIntoByteRange.pdf new file mode 100644 index 0000000000..419903479d Binary files /dev/null and b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/eolNotIncludedIntoByteRange.pdf differ diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/fieldLockChildModificationAllowed.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/fieldLockChildModificationAllowed.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/fieldLockChildModificationAllowed.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/fieldLockChildModificationAllowed.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/fieldLockChildModificationNotAllowed.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/fieldLockChildModificationNotAllowed.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/fieldLockChildModificationNotAllowed.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/fieldLockChildModificationNotAllowed.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/fieldLockKidsRemovedAndAdded.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/fieldLockKidsRemovedAndAdded.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/fieldLockKidsRemovedAndAdded.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/fieldLockKidsRemovedAndAdded.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/fieldLockLevelIncrease.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/fieldLockLevelIncrease.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/fieldLockLevelIncrease.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/fieldLockLevelIncrease.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/fieldLockRootModificationAllowed.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/fieldLockRootModificationAllowed.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/fieldLockRootModificationAllowed.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/fieldLockRootModificationAllowed.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/fieldLockRootModificationNotAllowed.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/fieldLockRootModificationNotAllowed.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/fieldLockRootModificationNotAllowed.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/fieldLockRootModificationNotAllowed.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/fieldLockSequentialExcludeValues.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/fieldLockSequentialExcludeValues.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/fieldLockSequentialExcludeValues.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/fieldLockSequentialExcludeValues.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/fieldLockSequentialIncludeValues.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/fieldLockSequentialIncludeValues.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/fieldLockSequentialIncludeValues.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/fieldLockSequentialIncludeValues.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/fullCompressionModeLevel1.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/fullCompressionModeLevel1.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/fullCompressionModeLevel1.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/fullCompressionModeLevel1.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/fullCompressionModeLevel2.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/fullCompressionModeLevel2.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/fullCompressionModeLevel2.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/fullCompressionModeLevel2.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/fullCompressionModeLevel3.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/fullCompressionModeLevel3.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/fullCompressionModeLevel3.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/fullCompressionModeLevel3.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/linearizedDoc.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/linearizedDoc.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/linearizedDoc.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/linearizedDoc.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/lockedFieldRemoveAddKidsEntry.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/lockedFieldRemoveAddKidsEntry.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/lockedFieldRemoveAddKidsEntry.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/lockedFieldRemoveAddKidsEntry.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/lockedSignatureFieldModified.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/lockedSignatureFieldModified.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/lockedSignatureFieldModified.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/lockedSignatureFieldModified.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/multipleRevisionsDocumentWithPermissions.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/multipleRevisionsDocumentWithPermissions.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/multipleRevisionsDocumentWithPermissions.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/multipleRevisionsDocumentWithPermissions.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/multipleRevisionsDocumentWithoutPermissions.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/multipleRevisionsDocumentWithoutPermissions.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/multipleRevisionsDocumentWithoutPermissions.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/multipleRevisionsDocumentWithoutPermissions.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/noSignaturesDoc.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/noSignaturesDoc.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/noSignaturesDoc.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/noSignaturesDoc.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/outlinesModified.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/outlinesModified.pdf new file mode 100644 index 0000000000..c802384f39 Binary files /dev/null and b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/outlinesModified.pdf differ diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/outlinesNotModified.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/outlinesNotModified.pdf new file mode 100644 index 0000000000..0ace1bc0ee Binary files /dev/null and b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/outlinesNotModified.pdf differ diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/pageAndParentIndirectReferenceModified.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/pageAndParentIndirectReferenceModified.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/pageAndParentIndirectReferenceModified.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/pageAndParentIndirectReferenceModified.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/pdfVersionAdded.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/pdfVersionAdded.pdf new file mode 100644 index 0000000000..844f68281b Binary files /dev/null and b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/pdfVersionAdded.pdf differ diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/removeAllAnnots.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/removeAllAnnots.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/removeAllAnnots.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/removeAllAnnots.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/removeFieldAnnots.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/removeFieldAnnots.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/removeFieldAnnots.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/removeFieldAnnots.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/removeUnnamedField.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/removeUnnamedField.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/removeUnnamedField.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/removeUnnamedField.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/removedLockedField.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/removedLockedField.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/removedLockedField.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/removedLockedField.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/signatureNotFound.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/signatureNotFound.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/signatureNotFound.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/signatureNotFound.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/simpleTaggedDoc.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/simpleTaggedDoc.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/simpleTaggedDoc.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/simpleTaggedDoc.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/taggedDocAddAndRemoveAnnotations.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/taggedDocAddAndRemoveAnnotations.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/taggedDocAddAndRemoveAnnotations.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/taggedDocAddAndRemoveAnnotations.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/taggedDocModifyAnnotation.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/taggedDocModifyAnnotation.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/taggedDocModifyAnnotation.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/taggedDocModifyAnnotation.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/taggedDocModifyAnnotationAndStructContent.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/taggedDocModifyAnnotationAndStructContent.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/taggedDocModifyAnnotationAndStructContent.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/taggedDocModifyAnnotationAndStructContent.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/taggedDocModifyAnnotationAndStructElement.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/taggedDocModifyAnnotationAndStructElement.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/taggedDocModifyAnnotationAndStructElement.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/taggedDocModifyAnnotationAndStructElement.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/taggedDocModifyStructElement.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/taggedDocModifyStructElement.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/taggedDocModifyStructElement.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/taggedDocModifyStructElement.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/taggedDocRemoveStructTreeAnnotation.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/taggedDocRemoveStructTreeAnnotation.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/taggedDocRemoveStructTreeAnnotation.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/taggedDocRemoveStructTreeAnnotation.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/taggedDocRemoveStructTreeElement.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/taggedDocRemoveStructTreeElement.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/taggedDocRemoveStructTreeElement.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/taggedDocRemoveStructTreeElement.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/twoCertificationSignatures.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/twoCertificationSignatures.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorIntegrationTest/twoCertificationSignatures.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorIntegrationTest/twoCertificationSignatures.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorTest/addTextField.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorTest/addTextField.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorTest/addTextField.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorTest/addTextField.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorTest/addUnsignedSignatureField.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorTest/addUnsignedSignatureField.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorTest/addUnsignedSignatureField.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorTest/addUnsignedSignatureField.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorTest/brokenSignatureFieldDictionary.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorTest/brokenSignatureFieldDictionary.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorTest/brokenSignatureFieldDictionary.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorTest/brokenSignatureFieldDictionary.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorTest/catalogReferenceInRandomPlace.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorTest/catalogReferenceInRandomPlace.pdf new file mode 100644 index 0000000000..1bea315b4d Binary files /dev/null and b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorTest/catalogReferenceInRandomPlace.pdf differ diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorTest/catalogReferenceInRandomPlaceModified.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorTest/catalogReferenceInRandomPlaceModified.pdf new file mode 100644 index 0000000000..db762a13cb Binary files /dev/null and b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorTest/catalogReferenceInRandomPlaceModified.pdf differ diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorTest/changeExistingFont.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorTest/changeExistingFont.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorTest/changeExistingFont.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorTest/changeExistingFont.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorTest/changeExistingFontAndAddAsDss.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorTest/changeExistingFontAndAddAsDss.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorTest/changeExistingFontAndAddAsDss.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorTest/changeExistingFontAndAddAsDss.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorTest/completelyInvalidDocument.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorTest/completelyInvalidDocument.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorTest/completelyInvalidDocument.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorTest/completelyInvalidDocument.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorTest/extensionsModifications.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorTest/extensionsModifications.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorTest/extensionsModifications.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorTest/extensionsModifications.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorTest/fillInField.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorTest/fillInField.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorTest/fillInField.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorTest/fillInField.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorTest/gotoReferencesModifiedStructTreeElem.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorTest/gotoReferencesModifiedStructTreeElem.pdf new file mode 100644 index 0000000000..03d96af0be Binary files /dev/null and b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorTest/gotoReferencesModifiedStructTreeElem.pdf differ diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorTest/hugeDocument.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorTest/hugeDocument.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorTest/hugeDocument.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorTest/hugeDocument.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorTest/makeFontDirectAndIndirect.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorTest/makeFontDirectAndIndirect.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorTest/makeFontDirectAndIndirect.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorTest/makeFontDirectAndIndirect.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorTest/modifyPageAnnots.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorTest/modifyPageAnnots.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorTest/modifyPageAnnots.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorTest/modifyPageAnnots.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorTest/multipleRevisionsDocument.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorTest/multipleRevisionsDocument.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorTest/multipleRevisionsDocument.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorTest/multipleRevisionsDocument.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorTest/multipleRevisionsDocument2.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorTest/multipleRevisionsDocument2.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorTest/multipleRevisionsDocument2.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorTest/multipleRevisionsDocument2.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorTest/multipleRevisionsDocument3.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorTest/multipleRevisionsDocument3.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorTest/multipleRevisionsDocument3.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorTest/multipleRevisionsDocument3.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorTest/randomEntryAdded.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorTest/randomEntryAdded.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorTest/randomEntryAdded.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorTest/randomEntryAdded.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorTest/randomEntryWithoutUsage.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorTest/randomEntryWithoutUsage.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorTest/randomEntryWithoutUsage.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorTest/randomEntryWithoutUsage.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorTest/removeAcroform.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorTest/removeAcroform.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorTest/removeAcroform.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorTest/removeAcroform.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorTest/removeDSS.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorTest/removeDSS.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorTest/removeDSS.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorTest/removeDSS.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorTest/removeField.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorTest/removeField.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorTest/removeField.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorTest/removeField.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorTest/removePermissions.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorTest/removePermissions.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorTest/removePermissions.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorTest/removePermissions.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorTest/renameField.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorTest/renameField.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/DocumentRevisionsValidatorTest/renameField.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/DocumentRevisionsValidatorTest/renameField.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/OCSPValidatorTest/candidate1-ocsp-issuer.cert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/OCSPValidatorTest/candidate1-ocsp-issuer.cert.pem new file mode 100644 index 0000000000..d65da4d99c --- /dev/null +++ b/sign/src/test/resources/com/itextpdf/signatures/validation/OCSPValidatorTest/candidate1-ocsp-issuer.cert.pem @@ -0,0 +1,20 @@ +-----BEGIN CERTIFICATE----- +MIIDMzCCAhugAwIBAgICEAMwDQYJKoZIhvcNAQELBQAwNTELMAkGA1UEBhMCQlkx +DjAMBgNVBAoMBWlUZXh0MRYwFAYDVQQDDA1pVGV4dFRlc3RSb290MCAXDTAwMDEw +MTAwMDAwMFoYDzI0NTAwMTAxMDAwMDAwWjA+MQswCQYDVQQGEwJCWTEOMAwGA1UE +CgwFaVRleHQxHzAdBgNVBAMMFmlUZXh0VGVzdE9jc3BSZXNwb25kZXIwggEiMA0G +CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCejPTkkIMdtBcNeK2BXjOh0LkMQQ9u ++nupFzKZnbG25LxMauZqwFj7xRmBwpkQLR+6RptaS/dWZYIdQm1D88Emvy36fRXg +F/NxuziZ9LGN5CUbYbY+QdHRop10iBQiG+oMfSAs6FaWPS475eLcga9HZBphA9zA +cUhZbTjD6ZQ4WMBXpC+8KDVzBSAMTJw1rku3We8RKSwMDXx/Q/diOJc0q0PU68cA +z3VtoFhr4tnru+1uGKhUIMnYGyphRwMw1EwNNSzZimZAEgXC1KIi5ywTJlWIAzB+ +H6OKI/tvyfzmTbhr+QyvXUQq8gIZ2N3/P/W/Cc6D3kQpoETvSFOzm2f9AgMBAAGj +QjBAMB0GA1UdDgQWBBSJQJIqlFRpEC9NMuebZTa38Lxk1TAfBgNVHSMEGDAWgBR0 +MlTFwFzoq8mPVusDjIEnL5avqzANBgkqhkiG9w0BAQsFAAOCAQEAlA1IOlUFvoOj +HM1VqwYmbTNUUSFpuZV9+njFCLNg6FaLDSB28uszcEzH4NhWfA8YydM+zPLwqIxg +0mOBjaeFaLgWAjPR3ejCexc4jcF6gc3hZTBx5m7i6REiDChWvodCwoa6fZ7dBDvH +3vd4Rlj/h3Ir67L7lTwI9AnBqmrQ49UhkGRHHK4RK9hHdhr1pqZnvRKjuAtApFWC +McTQYJxFIhZPdhF6fHjoozUbEtq6GrviuaYMBul306lXCd5/OzkW84CvOihgT1q7 +OtgCRuOawdMFZTqjk6OHqQ50GFhEfp3WqubYFkH7ADYNO5E8k3rWNVK08ldfKF1s +McB+a0FXzw== +-----END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/OCSPValidatorTest/candidate2-ocsp-issuer.cert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/OCSPValidatorTest/candidate2-ocsp-issuer.cert.pem new file mode 100644 index 0000000000..25be340dad --- /dev/null +++ b/sign/src/test/resources/com/itextpdf/signatures/validation/OCSPValidatorTest/candidate2-ocsp-issuer.cert.pem @@ -0,0 +1,20 @@ +-----BEGIN CERTIFICATE----- +MIIDMzCCAhugAwIBAgICEAQwDQYJKoZIhvcNAQELBQAwNTELMAkGA1UEBhMCQlkx +DjAMBgNVBAoMBWlUZXh0MRYwFAYDVQQDDA1pVGV4dFRlc3RSb290MCAXDTAwMDEw +MTAwMDAwMFoYDzI0NTAwMTAxMDAwMDAwWjA+MQswCQYDVQQGEwJCWTEOMAwGA1UE +CgwFaVRleHQxHzAdBgNVBAMMFmlUZXh0VGVzdE9jc3BSZXNwb25kZXIwggEiMA0G +CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCzBx802aNQTkJGcxGZdkN5XjXwR9tG +HzuEdJdGQVm56YP9PfTjeCPCLTtH9uFqtILP//tWnZSanlDHlFcUNH6btHB0DnPY +ewliS5zwCYxLyLWeVl1uJfP6aaNW6OFiwdYU6BeNjXx4Iey2qI9oKlS1l0ujYHfH +IVcSE2sXygPTxuenY3vj5SZ0zYvmsrnQfzue3YaGgLvrG8QYaIP+80QFfOzrB/c8 +XDbsPt2cx4bLOS6Z+hfv1g3Bz8l7E+0JF+q720b8VDqXMrF7Qh97+fmUSslKkT5S +Ot/4cjDGQQ6mLRQx4msJOfO4WzKdrMBxes+enddGWttlavZcYl+DHX7bAgMBAAGj +QjBAMB0GA1UdDgQWBBRVao/9YEW7emCXaNf8zL3MjpmNXDAfBgNVHSMEGDAWgBR0 +MlTFwFzoq8mPVusDjIEnL5avqzANBgkqhkiG9w0BAQsFAAOCAQEAte8X2bL+SorE +EK4pU75vmhr1X8W8rSNXJfy6p6m6GaigNIK4rmAu6bR9B4ai3qZNX9LE/eeKhwZu +yinLPGHema9vbG23FpHnM31mU7P3XAKprjrnrpxWBZ/dNx4IEYKtvDOKFIrR31Pt +stCOm7WXsPc8ovGQj+OnBh+lKaAy7yLNg7o8/8RxOwH9T2VbXcUBcMTnvKVsGiWa +tAiqa15EqnAEN7wAi9OpRkDKOfHdnR/bIv8CC6F3WWIwWmWcyi9st7ISv4ywtBmm +RriPwkjsBmyUu5DKBzFSfLEfnPpD1PjW+XMx0aHFuCf+HYAG8TDRkrhASwFCVb2B +6fFX5LBgew== +-----END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/OCSPValidatorTest/ocsp/certomancer.yml b/sign/src/test/resources/com/itextpdf/signatures/validation/OCSPValidatorTest/ocsp/certomancer.yml similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/OCSPValidatorTest/ocsp/certomancer.yml rename to sign/src/test/resources/com/itextpdf/signatures/validation/OCSPValidatorTest/ocsp/certomancer.yml diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/OCSPValidatorTest/ocspResponderCert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/OCSPValidatorTest/ocspResponderCert.pem similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/OCSPValidatorTest/ocspResponderCert.pem rename to sign/src/test/resources/com/itextpdf/signatures/validation/OCSPValidatorTest/ocspResponderCert.pem diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/OCSPValidatorTest/ocspResponderCertForOcspTest.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/OCSPValidatorTest/ocspResponderCertForOcspTest.pem similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/OCSPValidatorTest/ocspResponderCertForOcspTest.pem rename to sign/src/test/resources/com/itextpdf/signatures/validation/OCSPValidatorTest/ocspResponderCertForOcspTest.pem diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/OCSPValidatorTest/ocspResponderCertWithoutOcspSigning.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/OCSPValidatorTest/ocspResponderCertWithoutOcspSigning.pem similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/OCSPValidatorTest/ocspResponderCertWithoutOcspSigning.pem rename to sign/src/test/resources/com/itextpdf/signatures/validation/OCSPValidatorTest/ocspResponderCertWithoutOcspSigning.pem diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/OCSPValidatorTest/rootCert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/OCSPValidatorTest/rootCert.pem similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/OCSPValidatorTest/rootCert.pem rename to sign/src/test/resources/com/itextpdf/signatures/validation/OCSPValidatorTest/rootCert.pem diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/OCSPValidatorTest/rootCertForOcspTest.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/OCSPValidatorTest/rootCertForOcspTest.pem similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/OCSPValidatorTest/rootCertForOcspTest.pem rename to sign/src/test/resources/com/itextpdf/signatures/validation/OCSPValidatorTest/rootCertForOcspTest.pem diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/OCSPValidatorTest/signCert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/OCSPValidatorTest/signCert.pem similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/OCSPValidatorTest/signCert.pem rename to sign/src/test/resources/com/itextpdf/signatures/validation/OCSPValidatorTest/signCert.pem diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/OCSPValidatorTest/signCertForOcspTest.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/OCSPValidatorTest/signCertForOcspTest.pem similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/OCSPValidatorTest/signCertForOcspTest.pem rename to sign/src/test/resources/com/itextpdf/signatures/validation/OCSPValidatorTest/signCertForOcspTest.pem diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/RevocationDataValidatorTest/noRevAvailCert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/RevocationDataValidatorTest/noRevAvailCert.pem new file mode 100644 index 0000000000..1b86f4122b --- /dev/null +++ b/sign/src/test/resources/com/itextpdf/signatures/validation/RevocationDataValidatorTest/noRevAvailCert.pem @@ -0,0 +1,18 @@ +-----BEGIN CERTIFICATE----- +MIIDijCCAnKgAwIBAgIGAZDC/HsyMA0GCSqGSIb3DQEBCwUAMDgxCzAJBgNVBAYTAkJZMQ4wDAYD +VQQKDAVpVGV4dDEZMBcGA1UEAwwQaVRleHRUZXN0Um9vdFJzYTAgFw0yNDA3MTcyMzE3MjRaGA8y +MTI0MDYyMzIzMTcyNFowPTEcMBoGA1UEAwwTaVRleHRUZXN0Tm9SZXZBdmFpbDENMAsGA1UECwwE +dGVzdDEOMAwGA1UECgwFaVRleHQwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCc9FG+ +7SqyynBdYM3sOxE8ls7lnlmNlyiHhIka7BjDlwu+7ANUta/a2xh5M3SGFJqyOQ9Z21SFyJ3/XRcQ +bvpn454ltu6QS0cusqKL3ipkF58v/shBBlxj/w+oGC+mkJiV8kKYA1n672aI04BZi0SI3dGWLxn9 +S90y6ewXYGAx+/mdPLxwtQWF67UZRfvyTSGRpRFgjSZLHrDydvp0UrbsZLFtJIsZm2kV/ALiX9Xj +BAD2ZdPa7vGfek695dOX03J/WsT/rBggRGKT9qxZMhBVzamdUV4y3bXnqcB7fPpqtVdYslBLKJaj +2XnBnfUrMUGv/DeBeK8KOjv91xBLRwczAgMBAAGjgZIwgY8wDwYDVR0TAQH/BAUwAwEB/zAPBgkr +BgEFBQcwAQUEAgUAMAsGA1UdDwQEAwIGwDATBgNVHSUEDDAKBggrBgEFBQcDCTAJBgNVHTgEAgUA +MB8GA1UdIwQYMBaAFCmDtomMMsK6Vi+UTmnCrNwKNIVBMB0GA1UdDgQWBBQpg7aJjDLCulYvlE5p +wqzcCjSFQTANBgkqhkiG9w0BAQsFAAOCAQEAQnCZWiSh43VOvCRNIo2/Iy6bNgqGEVTRpIo7c7i2 +pLBoln0LwSZq8qscba+0EZ16U6JRxpJ2qsQ1qSWCiv4OfwGDxqOKJT8EJxpR8MYjj2UVKHKPHdPI +cP2SWRNTxelVLg3A5Twgf/LhDXSUMXVmZ7oViYt/hQc37+tcmVmyHAfEkPnx0d8VQcpmS3TuF2/u +QfxtyRekPMAAmlYshwjeEGQ7tzO6QKdEvony+jSia+wnAvO/jyYVin17afwMcPYqEpQCXN0xC8QL +Im+4nIdVbeIVLkUD9wWmZyDulX6YCQwFkYqUnK9mop3nqNCYXxppKfdNYMk3MiPzPsFuCyapfQ== +-----END CERTIFICATE----- \ No newline at end of file diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/RevocationDataValidatorTest/noRevAvailCertWithoutCA.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/RevocationDataValidatorTest/noRevAvailCertWithoutCA.pem new file mode 100644 index 0000000000..fdc4799d97 --- /dev/null +++ b/sign/src/test/resources/com/itextpdf/signatures/validation/RevocationDataValidatorTest/noRevAvailCertWithoutCA.pem @@ -0,0 +1,18 @@ +-----BEGIN CERTIFICATE----- +MIIDgTCCAmmgAwIBAgIGAZDFnFH8MA0GCSqGSIb3DQEBCwUAMDgxCzAJBgNVBAYTAkJZMQ4wDAYD +VQQKDAVpVGV4dDEZMBcGA1UEAwwQaVRleHRUZXN0Um9vdFJzYTAgFw0yNDA3MTgxMTMxMTRaGA8y +MTI0MDYyNDExMzExNFowRjElMCMGA1UEAwwcaVRleHRUZXN0Tm9SZXZBdmFpbFdpdGhvdXRDQTEN +MAsGA1UECwwEdGVzdDEOMAwGA1UECgwFaVRleHQwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEK +AoIBAQCNLM4D1cmHha3WodOrf6DmKsSIDNMP/FlUXWnbIqDQ3dbeb/JwHKVe2UicPzqZq5Ees6Qq +Pg8z9TzT/YRQDQglci3v82yn3ufy5REw7dGaGzoHU/vgCeDlygRd25tbhdsLfIfedKtz0tQIbJab +0jFlvvzgrmY6Q4Pk22IF5ujQE+N/z4ft8xs5BuII8szCaAacV6MsswzqeNbfYhmnmbs+25fZD0qs +wlVsO9OjVOqLlDVQAeSIO7ip1Ws/6LBG8fAjXsPm0BX7a1MxkyDsrUUFWfq3Pz2aK7DW1F34MPWE +YX0LAFIP269fG+S91fVtrw8b7b8WBQxWi8jv4OOl6kkTAgMBAAGjgYAwfjAPBgkrBgEFBQcwAQUE +AgUAMAsGA1UdDwQEAwIGwDATBgNVHSUEDDAKBggrBgEFBQcDCTAJBgNVHTgEAgUAMB8GA1UdIwQY +MBaAFCmDtomMMsK6Vi+UTmnCrNwKNIVBMB0GA1UdDgQWBBQpg7aJjDLCulYvlE5pwqzcCjSFQTAN +BgkqhkiG9w0BAQsFAAOCAQEAK93ANxcNwQCqM/ZDqcpkHtk+fXcKFLgSkpAQWxWjxEeumlRD61Yi +8dJ6VfIy95Flh4Kbg6EH1UsrkiquOQ2+k/V1oE5hJu7RT7RqSDu3VCcMAtekRwdfY6AGCX/9IHqE +CazzShdcCr/YZ2jz3Uy/kr6/fu4sq1enAunsM6WMuO7bZU/WYimzHu9TTRQ00oFjCW5s3TFgP3HV +BfaL4oSh7Ksvjsu2ZqjwFb8J5DT/oObIdeAw/Pl3NShjALbQ5PJkzkLp00FcT4A1ItKkW+p/xwPk +QCR2NnYjIk9yvhFgse5/VrYkNlJEknzN4upJ2ldVCC2F5yVyQ+mG7b8l7MgEKA== +-----END CERTIFICATE----- \ No newline at end of file diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/RevocationDataValidatorTest/ocspResponderCert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/RevocationDataValidatorTest/ocspResponderCert.pem similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/RevocationDataValidatorTest/ocspResponderCert.pem rename to sign/src/test/resources/com/itextpdf/signatures/validation/RevocationDataValidatorTest/ocspResponderCert.pem diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/RevocationDataValidatorTest/rootCert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/RevocationDataValidatorTest/rootCert.pem similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/RevocationDataValidatorTest/rootCert.pem rename to sign/src/test/resources/com/itextpdf/signatures/validation/RevocationDataValidatorTest/rootCert.pem diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/RevocationDataValidatorTest/signCert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/RevocationDataValidatorTest/signCert.pem similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/RevocationDataValidatorTest/signCert.pem rename to sign/src/test/resources/com/itextpdf/signatures/validation/RevocationDataValidatorTest/signCert.pem diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/RevocationDataValidatorTest/trustedOcspResponderCert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/RevocationDataValidatorTest/trustedOcspResponderCert.pem similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/RevocationDataValidatorTest/trustedOcspResponderCert.pem rename to sign/src/test/resources/com/itextpdf/signatures/validation/RevocationDataValidatorTest/trustedOcspResponderCert.pem diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/RevocationDataValidatorTest/validityAssuredSigningCert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/RevocationDataValidatorTest/validityAssuredSigningCert.pem similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/RevocationDataValidatorTest/validityAssuredSigningCert.pem rename to sign/src/test/resources/com/itextpdf/signatures/validation/RevocationDataValidatorTest/validityAssuredSigningCert.pem diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorIntegrationTest/certs/SHA256withRSA.cer b/sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorIntegrationTest/certs/SHA256withRSA.cer new file mode 100644 index 0000000000..fbaad2b382 Binary files /dev/null and b/sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorIntegrationTest/certs/SHA256withRSA.cer differ diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorIntegrationTest/certs/SHA256withRSA.key b/sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorIntegrationTest/certs/SHA256withRSA.key new file mode 100644 index 0000000000..d7e9b5e825 --- /dev/null +++ b/sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorIntegrationTest/certs/SHA256withRSA.key @@ -0,0 +1,51 @@ +-----BEGIN ENCRYPTED PRIVATE KEY----- +MIIFNTBfBgkqhkiG9w0BBQ0wUjAxBgkqhkiG9w0BBQwwJAQQdOaEUfD0sZWtUR11 +xwgn0gICCAAwDAYIKoZIhvcNAgkFADAdBglghkgBZQMEASoEEBaNXSfwUjF5SS7n +ce1JFoUEggTQ6eV+IsckiVP7I9VTldLkpP5OKB8brmw5t20fO11HyCnqkkhooR2b +t2fBj4fWv0IRUe266L+fVs7AOngjkWfezEvGR6nte4pNXEFrOwt/U8A6IYZXBdA5 +dvqs6VMPHbjQ8CufVLGvksuYFQVRcGy0rk1DH2Of44GU4X0GtROlFFJnkmfZhVPS +Hx2MXXGQ02Ko1i1eKoEGgvmSAsDcPijiX96DKlQZJ4YMtI/8rRsdvNJsJ2beyZDa +T3aJMmSSBF92mS2dtS21DwjzEu8utquguYA0KYzjZM9onOuBEEUifam8Fjnvlui6 +beQJya4zldoA6QZPSd2PUAP6l1U/d8UXqcisjzArDZDmRu58dPxn4rs0NgTOIO8h +fEUIvfS+wuknff1b/wdGnwXkXoeSrrjS9dhP9KVU1SJ/FWKc6BY+P+JmE5vLjAtn +AmbyZhXY0jX7ZHFh0z0y1y1fTIXL1aj4iB+cUwhJ1ZdlGkT5HdG4ts/oTGCnpB6O +F1GvGyhprmtjp/dspLH5ha0I+4aTn46yFpnBNyg8w9c2+xj8Jiqy9J/ppVtPdhxt +wrE1/ThUGIWUTsbGbLW87WIrZq6IlSGtztbxAMYxXoe4solYueE3pI3eYFzgnBcq +T6Byktr71gt9AGD/N/p+Kk5RM4JT8XpQjLjz9TlmsGpJzUoBGeG6KFLsqqLLSD+0 +c5lAGWsFhec3uCu4fCyBqxpQc0y5j2bgUiTRGYn1NOdyZg+ERO/aWGfkDOAtlL1i +B79NGIBxIXgt508g83UeaQC6KjuG/8hPY6UHmU5mlgRT9H5jvkSX3mEtl1Gdk2y0 +M5pZTTrhbG4p66GhBi8vM5tQfiBoLUKEM/kgiGXPC6Kob42nb3ufP0rmnKklcDGC ++898hW5ge+VNmOkHpVuV5ZD9aWUSVEU4+8QNZj8pcyL0GXFyEL/HxNxUESdz3k0S +bInuxO49mgGPjBqtx5ZvaxyWFnzOp6rmHZUHymejxxdnlnTnSnXKkJFjcm7n0sKO +575ofHtk0OdqIK6YiPgfeF6nZkIg3C0PbReZ05kTplrW182ZWuQQyJgv+RPzF4+9 +5rCe67nJhJrt7hXFRsUScHXNj+HF9Av8WR2RnHTRbpQBJszijM+Xgl+VeYcY5ckB +fk+AfcR9r0Jud4O9795OOWVxWqGVu/b1RGonfjMkGW+JdnZL0vkOYYcHt4iMZmzW +M0ZowZPGO5dFBV7/ZkVzb0fexw+f+E0lUBEK1cx0gxnzjmcGJO+C9if1uIEfwpon +3wBOTDsU7XKDx9v6ibcDMOXrZa+rcJWxgNkXt5nRpozZkddYctBkehGu+snV2g4n +SdOwr0eIVv/L+v4IywZmeWWEVnbSAvB0p7nB89bgLMr9tV0ly7MWxPH+gPnNJ1gE +7Mp3AgN5BxEmLfW3+ou3QLoqnOS2MCw/xcgLP0nJACSPI7/nWy95iKXKgkCkAgF9 +4Ztk7uBG4tiK14KcKq8ToCW2YNliT3g0CWjBLtVPUS6qboudMiuedxTxE8WEirpT +A77nfDNg4MVjl4kP9jhV0Phpn9rDMJ2jw0BqFc1Vou4aNDXYandAFJea44Wce9H+ +qAowcrfsWehD01HBQ2KwWVg3sLnwwBHw0nvbATS41hdxsP2OmCnxWkc= +-----END ENCRYPTED PRIVATE KEY----- +-----BEGIN CERTIFICATE----- +MIIDfzCCAmegAwIBAgIEUFic9zANBgkqhkiG9w0BAQsFADBvMQswCQYDVQQGEwJU +UzETMBEGA1UECBMKVGVzdCBTdGF0ZTESMBAGA1UEBxMJVGVzdCBUb3duMREwDwYD +VQQKEwhUZXN0IG9yZzEQMA4GA1UECxMHVGVzdCBPVTESMBAGA1UEAxMJVGVzdCBV +c2VyMCAXDTE0MDkyMjA5MTExMVoYDzIxMTQwODI5MDkxMTExWjBvMQswCQYDVQQG +EwJUUzETMBEGA1UECBMKVGVzdCBTdGF0ZTESMBAGA1UEBxMJVGVzdCBUb3duMREw +DwYDVQQKEwhUZXN0IG9yZzEQMA4GA1UECxMHVGVzdCBPVTESMBAGA1UEAxMJVGVz +dCBVc2VyMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA+6g5sYzXiNOA +hR7C8wc8buxU/JgcbdHpHIR44iuXjpepBYAE7hRsWM7H4cuXrKiRxS9UMOadqkGF +Qqb5sG6lo2UUhcj4qlN6hKDc/+AMZMIW1mvQldiygCAkqgM8iso+kw56dpVuerG/ +k1nd8f+X9rjXN6/DIMznZcMy2d9ByIFuixFKElPvOWx9q9N4aiueOd5FM5eHxp+3 +F4uCTrpM5zkS7Rmf5GVtCofc8KgaTLLp4D0Ge5VUJm7yW8fuU3eIpin4ivjk+Gye +Q3t0BsrmNyQy3CmKGOBP/vX0+wEMvGN2xqNgAFP9dxA+AbJMiAfsmoWvxXaPktqC +DOspTCFqbwIDAQABoyEwHzAdBgNVHQ4EFgQUILviRCmSrhuLDmF0nus4pv2uu7gw +DQYJKoZIhvcNAQELBQADggEBAGnfGYL7nDm5taDPRxuGGMqUPwRnH2bXwef6S2Xb +/nIEFtNheVFQFtKNn5Ikq68DTFMP06yXLnI7F40+ZiQezRBB1EPPmDL2fYKc9fL1 +SHntu6HLgP/Y5nnCVegtL8l9745gQZnnXlMtkTs2HFwffznIHW/3STO0Bcj0+KMa +p8vebMjmvV7bZEGvrcrVXL55QPZXJwRuQMXJB3f5XhAEH1VqAhTW6DrvBUnuESwo +9fxxA5gmblt80SQYdKr2I08OTk0qmyF8zNuffTOiSS8/V6Cf7CntuPWjSuVf1EVP +MH6KkSjceLZ99Y7bvl7KKvQ4Kj5Bp27PwlRvtYbfCUmQEG8= +-----END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorIntegrationTest/certs/rootCertKey.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorIntegrationTest/certs/rootCertKey.pem similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorIntegrationTest/certs/rootCertKey.pem rename to sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorIntegrationTest/certs/rootCertKey.pem diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorIntegrationTest/certs/rootRsa.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorIntegrationTest/certs/rootRsa.pem similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorIntegrationTest/certs/rootRsa.pem rename to sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorIntegrationTest/certs/rootRsa.pem diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorIntegrationTest/certs/root_cert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorIntegrationTest/certs/root_cert.pem new file mode 100644 index 0000000000..9e88d77c4c --- /dev/null +++ b/sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorIntegrationTest/certs/root_cert.pem @@ -0,0 +1,20 @@ +-----BEGIN CERTIFICATE----- +MIIDSzCCAjOgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwNTELMAkGA1UEBhMCQkUx +DjAMBgNVBAoMBWlUZXh0MRYwFAYDVQQDDA1pVGV4dFRlc3RSb290MCAXDTAwMDEw +MTAwMDAwMFoYDzI1MDAwMTAxMDAwMDAwWjA1MQswCQYDVQQGEwJCRTEOMAwGA1UE +CgwFaVRleHQxFjAUBgNVBAMMDWlUZXh0VGVzdFJvb3QwggEiMA0GCSqGSIb3DQEB +AQUAA4IBDwAwggEKAoIBAQCu7i/J0WEuTz8rwYTkQsAAwarnoiSYxEdolqz2b5jl +nSDjPs0uifW2bChiWWkGMeHgAtXl6NsaCaSR7UvgzZ2ah1PtyJ4IaYEG5uXsPH8L +X+m5BHt9RmplVYIYPFejb6ffdtpeCnwk7EPpd6UAc1WbFA6WwyEOG0D6HvjTRjW4 +OOIn48XVN8HzpGMvO9Afz5tunPuDCxhcdNGMn6BvBHJ9fLcl5xbyzURwUm4cE35V +q2RzbFfxsOh3saU2FHYY9w7Vh6VcOPPlP1RMARVP9KLt36mQlLfgPxW4xU3v97Ji +6NmkB7rbEi58jtrLs6T0FEPGkf2YFU451mFFqeVnLfh/AgMBAAGjYzBhMB0GA1Ud +DgQWBBTJedkaWwgZlvir4jCx+E02XFK+RjAfBgNVHSMEGDAWgBTJedkaWwgZlvir +4jCx+E02XFK+RjAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIB5jANBgkq +hkiG9w0BAQsFAAOCAQEAQ+M7mqNO3sLxIM+TzG2tHIgKPke5Bju1s+/tk6b8rY65 +9CLYNtQYakturcq5ApjOk/1WvPEcypiRze6Jy+i6/38Fi0VeRi6fN0z4EMa7/6lL +P63QTkZ1BRI9OiP+p0dOCY2hUyjOvJ9mEJH1H6rFLONwgKIWInIBFh9zIkE7Qn98 +G/1+ebUXGkarlENknUcgMWgG0B9lSroC+as0TPt3N2HnYYoUIg8iIIk2kEan8iwx +n3FKAKDDHWB+9B1H49yY5YwGjXNo7XJsk6hmR97CMRmnKLnlaklKu4l2C2E/mnDb +6Mq9vMmwK6+VJZB75423I/7WvsX9QvNK+kti/xNIpg== +-----END CERTIFICATE----- \ No newline at end of file diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorIntegrationTest/certs/short_validity_root_cert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorIntegrationTest/certs/short_validity_root_cert.pem similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorIntegrationTest/certs/short_validity_root_cert.pem rename to sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorIntegrationTest/certs/short_validity_root_cert.pem diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorIntegrationTest/certs/signCertRsa01.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorIntegrationTest/certs/signCertRsa01.pem new file mode 100644 index 0000000000..5f2f1f25a8 --- /dev/null +++ b/sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorIntegrationTest/certs/signCertRsa01.pem @@ -0,0 +1,76 @@ +-----BEGIN ENCRYPTED PRIVATE KEY----- +MIIFNTBfBgkqhkiG9w0BBQ0wUjAxBgkqhkiG9w0BBQwwJAQQgLsVp4wmljjCRgEy +kw2LWgICCAAwDAYIKoZIhvcNAgkFADAdBglghkgBZQMEASoEELyxbQ1T8vAMXX6t +md0GgdwEggTQXjePuN2mrJ4C7uFP/ErLys5cwO7QSOL5z7jUUep96YkZgMjau99o +6JolOHyJRzDbUNbTCfku8PqwDfdPrCPfMZ+e9UU/Y5uVZbEL+UtIkcH/uyFCd1k7 +AVOhAux7KZwgHlq66iUHqTQFd58Ly7KOoMKGZS07CtIxjYluFZZbx44EZrgqRwEa +ZAbIsdR2xZ092Who4CzkuF31m2TuyzfYir7kocJsdQU6k9OdptfJRda2UpZiUXW8 +GMg/qvF7RwkAbfu7gLkcmc5FETlY+E3P8tYDutN737wnd/VqO9Bd25umOAl3CHUA +5+YSXvWOSuAJjz7kEI2DEG/ov//oO0wohJPLKRF7jUI2WbIwCAypPZPvSS506ulO +ofuLTY0+Jii0ZO5SyC4Uu90lh8RISvi9RzRx2G4sN+gyeCBBg1R1f5IRNeBImpEw +aKqk4VrcUrLe623Z3el1Z8ErJBJ6G0ZV/EAFC7dmpTknrVOFzdO6sohtnHygm0Ce +h5QdqiWvb0QKHv3GZumdtCcdh8vPMRT1PEWVvfV/cyIOc5BH6sYNtxiohosl6DLz +I84vj3n8I+cFHrYIFCtghy9iZJ0GvvPxaiJCS5A+eDiOO3rhk3ZMkmTlVCpOBiY2 +QKdljhmRaN1Y6XfQ8SRNmr/qVfwFJ4JgYnk3VVHVvzt0EvEImNusOvTH2U4zMryP +FRhgGNIL0f5gflo2LxSPqsnqNfJLRHCmXkYeB4Pu8/xv6biFqtwC2UBaL7FCjIgY +NI+hi9Mt9fJpYqF4XGHcT2b6Aq7otgxX+5iiQg10bEjqI/gcZrFvBvmz/97OBe7X +BFa5F8nYeSxnr5XQiJ04oBVBjdvAFeS7ZZ4Quq2beEgcgCj7EU/OXLLHwBCCmD8s +8kgkhsv7+sPtNnC1YeoW6xHezt/FSDYxS1lPWsnr4AE4jpxOJgM8CNSDq0E52e83 +2uDNm3gIo133RRn9V8gNQzfIJv1BZFRUtOn9CRxrJBTptSxUJX1at+btTM7hlY2z +MwXM5i7ZGDVQOPSpKrlbmA8bHDRHeGryXz0HNWs5RWiTVSEhCuVTrrlQG4nmbhVm +b6xbd/DWs3NdEXwLLdg1W+fbeS2qIJtJqu0LU+PcGkhaVXeobc6MFGw06hDVtVg9 +Hm1/AZJ4OuD/+GyH9ku4Z9tPDh4NmXsVVV8CpzxRJ37gLrGPwbxXwW3v6B6NBRvz +W8KuWQjlNDxVcFb9Si7Mj81xX2k1818hwSm3iEQIwT0Q7BNUj3oJhTsNlB/Id79J +tl7AKam1ofDZVmU7gPcv0FPKxhEZIyjoqeAzLGuW1Hmp45HbJ94tL2uvbgPq2Mj7 +j4jllaPoN9J1QBVDHBqEzLZGeWKZYK2L9Sw4SdkZjLp96hxoQ7MYvTrsX4eSV0HH +xMLp5hhIiM8zGIsMYlwcfOSpQh/H1AnbiQIJ0/tzO6uBZ73fq59rTReRf+PtXqqT +5vg89nN6kNvJcrwNLyEhdC7uaqsoimTMi59BE36ZZcL0jHKMmPl9g/vbPj9CiRdu +B0+4lQD0hAqK6FVfl6ENpj4zLdU6/EER5L7v+Syv8d5AeFtdKrqxH3oCGPXmXCol +j2rALoIlZt0D+jjmcDo6C32qtu8w40zBD/+J8iZXVWC/U9cauP00N9E= +-----END ENCRYPTED PRIVATE KEY----- +-----BEGIN CERTIFICATE----- +MIID6TCCAtGgAwIBAgIEWOew7DANBgkqhkiG9w0BAQsFADBUMQswCQYDVQQGEwJC +WTEOMAwGA1UEBwwFTWluc2sxDjAMBgNVBAoMBWlUZXh0MQ0wCwYDVQQLDAR0ZXN0 +MRYwFAYDVQQDDA1pVGV4dFRlc3RSb290MCAXDTE3MDQwNzE1MzM0MFoYDzIxMTcw +NDA3MTUzMzQwWjBZMQswCQYDVQQGEwJCWTEOMAwGA1UEBwwFTWluc2sxDjAMBgNV +BAoMBWlUZXh0MQ0wCwYDVQQLDAR0ZXN0MRswGQYDVQQDDBJpVGV4dFRlc3RSc2FD +ZXJ0MDEwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCfr2PnZ6DjvrSY +g0cWtDR6drgvCowB5hQH7CHSAMTeVGZxUOBT1ylfxySioRU4ckq3uQu7jOe7Te6Y +xEenjFhTv8bT0/ZrL2w6OGBH4iUs3Kwx5jzbRHPuZt7+gCKLBXhRH6ytDnbTHNgT +4tjGXUmGa4sMbal1mXvKN/xaK+hGDskRW6cHZq7ZtdgfM8yBQWZzshAz7dQepmUH +ZYWxplTwJ8cuVLqjgXMXWfTatio6yYwf+5AkWszBcCA6oxm16wN2pLUeNx5aBLiF +Dhtj6qqHLwN/7tPb0ojqXRU3AfocC2y8a4WeVOOp2du0ja4E9P7IQNKiBBlOfNcF +D700qPFpAgMBAAGjgbswgbgwCQYDVR0TBAIwADB/BgNVHSMEeDB2gBRdKnF1rt3Y +vlm6ILFmkcl2NlNc7qFYpFYwVDELMAkGA1UEBhMCQlkxDjAMBgNVBAcMBU1pbnNr +MQ4wDAYDVQQKDAVpVGV4dDENMAsGA1UECwwEdGVzdDEWMBQGA1UEAwwNaVRleHRU +ZXN0Um9vdIIEWOeR1jAdBgNVHQ4EFgQUz41Jo8H/HAqxhMN/inuhKuLZU8gwCwYD +VR0PBAQDAgXgMA0GCSqGSIb3DQEBCwUAA4IBAQCT597xhkVzrYP7NudRgIZCDwT3 +TDnL+Xv8H4c9p+CdHJtFMoxAQlzcQi4uEIo5nfBKMEXK0d1OnO8zEBfK98EPahUI +++PDnNk82kh64CbZQ95Ms1Usq1XGd31bkXWWRM3LY2P7VG0nR+eLutVAClIcbTLN +yL9ZhiL33jCk1W5PeXJy13kL3XV/Awt8zb9fcinkuXkV5LoZHxh2Ob19R//5fGxH +hnUywReGptnIbEPiWGYyX1QCQeOqi3vmqZaGr+RZfF8+zqtSP5p4gFpryuTJxkcZ +UOeroaBv3sHCI9rtzcwZPYsW0BroFliEhNIDq5HxJgdwdu6uDOMMrC2QxB17 +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIID6jCCAtKgAwIBAgIEWOeR1jANBgkqhkiG9w0BAQsFADBUMQswCQYDVQQGEwJC +WTEOMAwGA1UEBwwFTWluc2sxDjAMBgNVBAoMBWlUZXh0MQ0wCwYDVQQLDAR0ZXN0 +MRYwFAYDVQQDDA1pVGV4dFRlc3RSb290MCAXDTE3MDQwNzEzMjAwMVoYDzIxMTcw +NDA3MTMyMDAxWjBUMQswCQYDVQQGEwJCWTEOMAwGA1UEBwwFTWluc2sxDjAMBgNV +BAoMBWlUZXh0MQ0wCwYDVQQLDAR0ZXN0MRYwFAYDVQQDDA1pVGV4dFRlc3RSb290 +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAz/fz7iq1wzhMMYcGfmMm +teCY/ZtdE26PB1OTTBuDSN86sVNmur5FV/mLPU9ZK2ofrs+wMrqn0agmFlRl4dTh +f5u5WSEQ/ARwXzYOn2uEkwR/0dwwZUL3VWhrPSD5SxX5MzFo8UXTNlXW2bClLC0F +QU2qLjIwwRFwwWDSQPR8r/Mv181RljVpEjPk6DfkDtHWWA4daGlQU0nXbuZszplv +iPafXmyKn+2w4G9Jw/8pHIK2VhWYstLI+bUZk662ZVldNvnpMyHn12FfB0Nbf/Z6 +V2WTGviEr8EEE2cA7I+H7ZGUDzug7umNCCJn3ilC6vAt9i9OLaZRDh6jPMOjMUiz +TwIDAQABo4HBMIG+MA8GA1UdEwEB/wQFMAMBAf8wfwYDVR0jBHgwdoAUXSpxda7d +2L5ZuiCxZpHJdjZTXO6hWKRWMFQxCzAJBgNVBAYTAkJZMQ4wDAYDVQQHDAVNaW5z +azEOMAwGA1UECgwFaVRleHQxDTALBgNVBAsMBHRlc3QxFjAUBgNVBAMMDWlUZXh0 +VGVzdFJvb3SCBFjnkdYwHQYDVR0OBBYEFF0qcXWu3di+WbogsWaRyXY2U1zuMAsG +A1UdDwQEAwIB9jANBgkqhkiG9w0BAQsFAAOCAQEAdhby6EaopoUF8j7oR44Mhe/N +3y9hzGb/zLmmgTavPd2plv6NlAPt9W+8rezKO6jQCsBRFw8JY+Lx6j3W0K6rWigB +pPGU/B/0bXLlOIv2a4uW8nBmq6jxAe5Xbtwm8HcKOOLMzxPIChHJIJy5NWw9ArD4 +Ul+FEt/VuEW1NfPZm1U5ixMOrBfn0C8pxIX4+VSHN9I8WoFjSfYX4Y3ldRLTeqxQ +rhZQlbhGNymp3Kcvtuq5At6vopskyB8Q1b7L4e+hRWK2prz/7p4Bdhu2TmkEfWZc +YKpgrkVFqa/Z1uZ0q4KVBOP3cyaQmqRXTV37SfpNyHAJdol5ueF68VVVNZFRXw== +-----END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorIntegrationTest/certs/trustedCerts.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorIntegrationTest/certs/trustedCerts.pem similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorIntegrationTest/certs/trustedCerts.pem rename to sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorIntegrationTest/certs/trustedCerts.pem diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorIntegrationTest/certs/ts_root_cert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorIntegrationTest/certs/ts_root_cert.pem similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorIntegrationTest/certs/ts_root_cert.pem rename to sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorIntegrationTest/certs/ts_root_cert.pem diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorIntegrationTest/certs/validCertsChain.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorIntegrationTest/certs/validCertsChain.pem similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorIntegrationTest/certs/validCertsChain.pem rename to sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorIntegrationTest/certs/validCertsChain.pem diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorIntegrationTest/encryptedDoc.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorIntegrationTest/encryptedDoc.pdf new file mode 100644 index 0000000000..e4563ea8d0 Binary files /dev/null and b/sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorIntegrationTest/encryptedDoc.pdf differ diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorIntegrationTest/encryptedPublicKeyDocTest.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorIntegrationTest/encryptedPublicKeyDocTest.pdf new file mode 100644 index 0000000000..929f7454d5 Binary files /dev/null and b/sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorIntegrationTest/encryptedPublicKeyDocTest.pdf differ diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorIntegrationTest/revDataInTheSignatureContainer.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorIntegrationTest/revDataInTheSignatureContainer.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorIntegrationTest/revDataInTheSignatureContainer.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorIntegrationTest/revDataInTheSignatureContainer.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorIntegrationTest/revDataInTheSignerInfo.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorIntegrationTest/revDataInTheSignerInfo.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorIntegrationTest/revDataInTheSignerInfo.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorIntegrationTest/revDataInTheSignerInfo.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorIntegrationTest/shortValidityCertsWithCrl.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorIntegrationTest/shortValidityCertsWithCrl.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorIntegrationTest/shortValidityCertsWithCrl.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorIntegrationTest/shortValidityCertsWithCrl.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorIntegrationTest/shortValidityCertsWithOcsp.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorIntegrationTest/shortValidityCertsWithOcsp.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorIntegrationTest/shortValidityCertsWithOcsp.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorIntegrationTest/shortValidityCertsWithOcsp.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorIntegrationTest/signatureSigningCertExpired.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorIntegrationTest/signatureSigningCertExpired.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorIntegrationTest/signatureSigningCertExpired.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorIntegrationTest/signatureSigningCertExpired.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorIntegrationTest/timestampSignatureDoc.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorIntegrationTest/timestampSignatureDoc.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorIntegrationTest/timestampSignatureDoc.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorIntegrationTest/timestampSignatureDoc.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorIntegrationTest/validDoc.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorIntegrationTest/validDoc.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorIntegrationTest/validDoc.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorIntegrationTest/validDoc.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorIntegrationTest/validDocWithTimestamp.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorIntegrationTest/validDocWithTimestamp.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorIntegrationTest/validDocWithTimestamp.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorIntegrationTest/validDocWithTimestamp.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorIntegrationTest/validDocWithoutChain.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorIntegrationTest/validDocWithoutChain.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorIntegrationTest/validDocWithoutChain.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorIntegrationTest/validDocWithoutChain.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorIntegrationTest/validateSingleSignature1.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorIntegrationTest/validateSingleSignature1.pdf new file mode 100644 index 0000000000..218e5a36cb Binary files /dev/null and b/sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorIntegrationTest/validateSingleSignature1.pdf differ diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorIntegrationTest/validateSingleSignature2.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorIntegrationTest/validateSingleSignature2.pdf new file mode 100644 index 0000000000..fe7b0c6a0d Binary files /dev/null and b/sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorIntegrationTest/validateSingleSignature2.pdf differ diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorTest/certs/rootCertKey.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorTest/certs/rootCertKey.pem similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorTest/certs/rootCertKey.pem rename to sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorTest/certs/rootCertKey.pem diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorTest/certs/timestamp.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorTest/certs/timestamp.pem similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorTest/certs/timestamp.pem rename to sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorTest/certs/timestamp.pem diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorTest/certs/validCertsChain.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorTest/certs/validCertsChain.pem similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorTest/certs/validCertsChain.pem rename to sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorTest/certs/validCertsChain.pem diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorTest/docWithBrokenDss.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorTest/docWithBrokenDss.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorTest/docWithBrokenDss.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorTest/docWithBrokenDss.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorTest/docWithBrokenTimestamp.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorTest/docWithBrokenTimestamp.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorTest/docWithBrokenTimestamp.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorTest/docWithBrokenTimestamp.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorTest/docWithDss.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorTest/docWithDss.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorTest/docWithDss.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorTest/docWithDss.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorTest/docWithMultipleSignaturesAndTimeStamp.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorTest/docWithMultipleSignaturesAndTimeStamp.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorTest/docWithMultipleSignaturesAndTimeStamp.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorTest/docWithMultipleSignaturesAndTimeStamp.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorTest/modifiedDoc.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorTest/modifiedDoc.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorTest/modifiedDoc.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorTest/modifiedDoc.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorTest/modifiedDocTimestampDate.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorTest/modifiedDocTimestampDate.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorTest/modifiedDocTimestampDate.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorTest/modifiedDocTimestampDate.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorTest/signatureWithModifiedTimestampDate.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorTest/signatureWithModifiedTimestampDate.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorTest/signatureWithModifiedTimestampDate.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorTest/signatureWithModifiedTimestampDate.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorTest/timestampSignatureDoc.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorTest/timestampSignatureDoc.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorTest/timestampSignatureDoc.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorTest/timestampSignatureDoc.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorTest/validDoc.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorTest/validDoc.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorTest/validDoc.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/SignatureValidatorTest/validDoc.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/ValidationMetaInfoEventsTest/multipleRevisionsDocument.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/ValidationMetaInfoEventsTest/multipleRevisionsDocument.pdf similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/ValidationMetaInfoEventsTest/multipleRevisionsDocument.pdf rename to sign/src/test/resources/com/itextpdf/signatures/validation/ValidationMetaInfoEventsTest/multipleRevisionsDocument.pdf diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/extensions/BasicConstraintsExtensionTest/basicConstraints10Cert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/extensions/BasicConstraintsExtensionTest/basicConstraints10Cert.pem similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/extensions/BasicConstraintsExtensionTest/basicConstraints10Cert.pem rename to sign/src/test/resources/com/itextpdf/signatures/validation/extensions/BasicConstraintsExtensionTest/basicConstraints10Cert.pem diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/extensions/BasicConstraintsExtensionTest/basicConstraints5Cert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/extensions/BasicConstraintsExtensionTest/basicConstraints5Cert.pem similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/extensions/BasicConstraintsExtensionTest/basicConstraints5Cert.pem rename to sign/src/test/resources/com/itextpdf/signatures/validation/extensions/BasicConstraintsExtensionTest/basicConstraints5Cert.pem diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/extensions/BasicConstraintsExtensionTest/basicConstraintsFalseCert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/extensions/BasicConstraintsExtensionTest/basicConstraintsFalseCert.pem similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/extensions/BasicConstraintsExtensionTest/basicConstraintsFalseCert.pem rename to sign/src/test/resources/com/itextpdf/signatures/validation/extensions/BasicConstraintsExtensionTest/basicConstraintsFalseCert.pem diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/extensions/BasicConstraintsExtensionTest/basicConstraintsMaxCert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/extensions/BasicConstraintsExtensionTest/basicConstraintsMaxCert.pem similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/extensions/BasicConstraintsExtensionTest/basicConstraintsMaxCert.pem rename to sign/src/test/resources/com/itextpdf/signatures/validation/extensions/BasicConstraintsExtensionTest/basicConstraintsMaxCert.pem diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/extensions/BasicConstraintsExtensionTest/basicConstraintsNotSetCert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/extensions/BasicConstraintsExtensionTest/basicConstraintsNotSetCert.pem similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/extensions/BasicConstraintsExtensionTest/basicConstraintsNotSetCert.pem rename to sign/src/test/resources/com/itextpdf/signatures/validation/extensions/BasicConstraintsExtensionTest/basicConstraintsNotSetCert.pem diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/extensions/CertificateExtensionTest/keyUsageNotSetCert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/extensions/CertificateExtensionTest/keyUsageNotSetCert.pem similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/extensions/CertificateExtensionTest/keyUsageNotSetCert.pem rename to sign/src/test/resources/com/itextpdf/signatures/validation/extensions/CertificateExtensionTest/keyUsageNotSetCert.pem diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/extensions/CertificateExtensionTest/keyUsageSeveralKeys1Cert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/extensions/CertificateExtensionTest/keyUsageSeveralKeys1Cert.pem similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/extensions/CertificateExtensionTest/keyUsageSeveralKeys1Cert.pem rename to sign/src/test/resources/com/itextpdf/signatures/validation/extensions/CertificateExtensionTest/keyUsageSeveralKeys1Cert.pem diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/extensions/ExtendedKeyUsageExtensionTest/extendedKeyUsageAnyUsageCert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/extensions/ExtendedKeyUsageExtensionTest/extendedKeyUsageAnyUsageCert.pem similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/extensions/ExtendedKeyUsageExtensionTest/extendedKeyUsageAnyUsageCert.pem rename to sign/src/test/resources/com/itextpdf/signatures/validation/extensions/ExtendedKeyUsageExtensionTest/extendedKeyUsageAnyUsageCert.pem diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/extensions/ExtendedKeyUsageExtensionTest/extendedKeyUsageNoSetCert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/extensions/ExtendedKeyUsageExtensionTest/extendedKeyUsageNoSetCert.pem similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/extensions/ExtendedKeyUsageExtensionTest/extendedKeyUsageNoSetCert.pem rename to sign/src/test/resources/com/itextpdf/signatures/validation/extensions/ExtendedKeyUsageExtensionTest/extendedKeyUsageNoSetCert.pem diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/extensions/ExtendedKeyUsageExtensionTest/extendedKeyUsageOcspSigningCert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/extensions/ExtendedKeyUsageExtensionTest/extendedKeyUsageOcspSigningCert.pem similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/extensions/ExtendedKeyUsageExtensionTest/extendedKeyUsageOcspSigningCert.pem rename to sign/src/test/resources/com/itextpdf/signatures/validation/extensions/ExtendedKeyUsageExtensionTest/extendedKeyUsageOcspSigningCert.pem diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/extensions/ExtendedKeyUsageExtensionTest/extendedKeyUsageSeveralValues1Cert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/extensions/ExtendedKeyUsageExtensionTest/extendedKeyUsageSeveralValues1Cert.pem similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/extensions/ExtendedKeyUsageExtensionTest/extendedKeyUsageSeveralValues1Cert.pem rename to sign/src/test/resources/com/itextpdf/signatures/validation/extensions/ExtendedKeyUsageExtensionTest/extendedKeyUsageSeveralValues1Cert.pem diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/extensions/ExtendedKeyUsageExtensionTest/extendedKeyUsageSeveralValues2Cert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/extensions/ExtendedKeyUsageExtensionTest/extendedKeyUsageSeveralValues2Cert.pem similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/extensions/ExtendedKeyUsageExtensionTest/extendedKeyUsageSeveralValues2Cert.pem rename to sign/src/test/resources/com/itextpdf/signatures/validation/extensions/ExtendedKeyUsageExtensionTest/extendedKeyUsageSeveralValues2Cert.pem diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/extensions/ExtendedKeyUsageExtensionTest/extendedKeyUsageTimeStampingCert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/extensions/ExtendedKeyUsageExtensionTest/extendedKeyUsageTimeStampingCert.pem similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/extensions/ExtendedKeyUsageExtensionTest/extendedKeyUsageTimeStampingCert.pem rename to sign/src/test/resources/com/itextpdf/signatures/validation/extensions/ExtendedKeyUsageExtensionTest/extendedKeyUsageTimeStampingCert.pem diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/extensions/KeyUsageExtensionTest/keyUsageDecipherOnlyCert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/extensions/KeyUsageExtensionTest/keyUsageDecipherOnlyCert.pem similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/extensions/KeyUsageExtensionTest/keyUsageDecipherOnlyCert.pem rename to sign/src/test/resources/com/itextpdf/signatures/validation/extensions/KeyUsageExtensionTest/keyUsageDecipherOnlyCert.pem diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/extensions/KeyUsageExtensionTest/keyUsageDigitalSignatureCert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/extensions/KeyUsageExtensionTest/keyUsageDigitalSignatureCert.pem similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/extensions/KeyUsageExtensionTest/keyUsageDigitalSignatureCert.pem rename to sign/src/test/resources/com/itextpdf/signatures/validation/extensions/KeyUsageExtensionTest/keyUsageDigitalSignatureCert.pem diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/extensions/KeyUsageExtensionTest/keyUsageKeyCertSignCert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/extensions/KeyUsageExtensionTest/keyUsageKeyCertSignCert.pem similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/extensions/KeyUsageExtensionTest/keyUsageKeyCertSignCert.pem rename to sign/src/test/resources/com/itextpdf/signatures/validation/extensions/KeyUsageExtensionTest/keyUsageKeyCertSignCert.pem diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/extensions/KeyUsageExtensionTest/keyUsageNotSetCert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/extensions/KeyUsageExtensionTest/keyUsageNotSetCert.pem similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/extensions/KeyUsageExtensionTest/keyUsageNotSetCert.pem rename to sign/src/test/resources/com/itextpdf/signatures/validation/extensions/KeyUsageExtensionTest/keyUsageNotSetCert.pem diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/extensions/KeyUsageExtensionTest/keyUsageSeveralKeys1Cert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/extensions/KeyUsageExtensionTest/keyUsageSeveralKeys1Cert.pem similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/extensions/KeyUsageExtensionTest/keyUsageSeveralKeys1Cert.pem rename to sign/src/test/resources/com/itextpdf/signatures/validation/extensions/KeyUsageExtensionTest/keyUsageSeveralKeys1Cert.pem diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/extensions/KeyUsageExtensionTest/keyUsageSeveralKeys2Cert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/extensions/KeyUsageExtensionTest/keyUsageSeveralKeys2Cert.pem similarity index 100% rename from sign/src/test/resources/com/itextpdf/signatures/validation/v1/extensions/KeyUsageExtensionTest/keyUsageSeveralKeys2Cert.pem rename to sign/src/test/resources/com/itextpdf/signatures/validation/extensions/KeyUsageExtensionTest/keyUsageSeveralKeys2Cert.pem diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/crlAndSignCertRootIssuerMismatch/chain.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/crlAndSignCertRootIssuerMismatch/chain.pem deleted file mode 100644 index 07a850f63e..0000000000 --- a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/crlAndSignCertRootIssuerMismatch/chain.pem +++ /dev/null @@ -1,103 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDSzCCAjOgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwNTELMAkGA1UEBhMCQkUx -DjAMBgNVBAoMBWlUZXh0MRYwFAYDVQQDDA1pVGV4dFRlc3RSb290MCAXDTAwMDEw -MTAwMDAwMFoYDzI1MDAwMTAxMDAwMDAwWjA1MQswCQYDVQQGEwJCRTEOMAwGA1UE -CgwFaVRleHQxFjAUBgNVBAMMDWlUZXh0VGVzdFJvb3QwggEiMA0GCSqGSIb3DQEB -AQUAA4IBDwAwggEKAoIBAQDP6KUmxQzeXKuwodaQZ7IUoidvDeXWrjW7BNYmKhey -DX9SIeIwvuiKDVUD85pWyk6jhNUvQaYvGVOv/Pbu4NJHv9FKch2d9759ckMT+MXG -fGk/B6Ww1rlKsiHccWizQxah7R79eGweEvryPIx+hqxreCBH4yzMPjHld1C34/vC -nUGmozKT4KENiT6lXXiBm4D+u3siCPt1Gzxavvm2MUBTHBbhQ3/n1eS/FcqT4NhI -vXDpPiNouD9goI+4LwCW7b52dg7dXreQY/IfGCcHTcu7YK/OEW4Pqjpr13B5mEDS -DsCqrStoh8EQ+jB62n2Xv8TT4lQju/sZh0l65IiT8fUfAgMBAAGjYzBhMB0GA1Ud -DgQWBBRkxUEzwLkf0rdu5Txco5JSsf8WCzAfBgNVHSMEGDAWgBRkxUEzwLkf0rdu -5Txco5JSsf8WCzAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIC5DANBgkq -hkiG9w0BAQsFAAOCAQEARJOOUQkv9AgqElJmQjGDkRdJPxkDHZtRLGOk9p0E1KbL -lqQQdgzL7RuE4vfCROan6aBZmXFRviIPg/Gxw2hDSIv1NUZv3AIgM2b9+3y+4SQ6 -2a/sqh1JPLxwnLN+Mo5KwY/E/YlJ0N7rw3AONrLlqH89BRrBIiPjrg74zi6qPzGn -WB2awHsbl7AOtkD2dEud7lbyLda/hCw2RGPSBQMm50pWsuInWXzdtX/Ii9yTGMyD -kavUHX6DDVouZBSKOjmChP0fGPM17ORJNR92RbT2ygy+F0Zokh5XUgrKPr4/JTW5 -iIkycpjAXY9UEMfi8pFnnzVSRj65kkZvZZJzybelMQ== ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIDQjCCAiqgAwIBAgICEAEwDQYJKoZIhvcNAQELBQAwNTELMAkGA1UEBhMCQkUx -DjAMBgNVBAoMBWlUZXh0MRYwFAYDVQQDDA1pVGV4dFRlc3RSb290MCAXDTAwMDEw -MTAwMDAwMFoYDzI0NTAwMTAxMDAwMDAwWjA9MQswCQYDVQQGEwJCRTEOMAwGA1UE -CgwFaVRleHQxHjAcBgNVBAMMFWlUZXh0VGVzdEludGVybWVkaWF0ZTCCASIwDQYJ -KoZIhvcNAQEBBQADggEPADCCAQoCggEBAM3t0dlZupS+5Z0EGHsnruz2ZRoVKwbp -IXwuOGuetobCTaaTfAyXmgXqcH1ZPi0u1dSzkWbHOdBNhRQLlk3ZtTfnCQrtijjU -U6jqkiMoMhap1/jEQPoU6CHP3bbwkSdZrnNriVxyGp2IKGwNDlg9fOBGuXdNei8N -fP5q9daV3oC9ckverNNKpcn9/0wYchISH9Y0a8N6FFUBqEYnjsEee7a5VIfgsP70 -jrhk53pNQJSObJhAFzhsbFNXxmWkZpi/YUJaBCSQYwQCUToRINyUMZOtsUIBh4es -8EpBt2utPkVifZvBo+prKUPTYX64iKko7zY5WHyP6vIV5BihYYv3Em8CAwEAAaNS -MFAwHQYDVR0OBBYEFKekg+UBOOgzMM6Ft6zCMa6k6H89MB8GA1UdIwQYMBaAFGTF -QTPAuR/St27lPFyjklKx/xYLMA4GA1UdDwEB/wQEAwIB5jANBgkqhkiG9w0BAQsF -AAOCAQEAadrnESocLAKEhOVcKC1tGOlDEI3oYkODcT4E3AOBqBq+gy4s5hfrQEpC -HqCje0pGNY1xgdcG5OPaKNSMT7+/PLE5As7aktNQxWuhDSH0SwKQPBbG+pfs0m3J -1R6M0WKsqvLWUtUgkzQp2f9pqu/XBrjqJnI5RwtNBBXJV8QBhLf4z/kGIk4noDM7 -2PcXdGNfl6dINcX8q3meZ1DkWTypgZ1pcEcvHU0rUPo+UPUpg6pOruOVnCERRiSx -z97Gqp1ZDa/jH1a+tjmbq4EN1vbULzVw+xsBIMuT7lsPTLdy/AHIx2UXVMGhHoYV -BHO096jz11DkzNKHloHf5sKPK2Ecjg== ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIDQjCCAiqgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwPTELMAkGA1UEBhMCQkUx -DjAMBgNVBAoMBWlUZXh0MR4wHAYDVQQDDBVpVGV4dFRlc3RJbnRlcm1lZGlhdGUw -IBcNMDAwMTAxMDAwMDAwWhgPMjQwMDAxMDEwMDAwMDBaMDUxCzAJBgNVBAYTAkJF -MQ4wDAYDVQQKDAVpVGV4dDEWMBQGA1UEAwwNaVRleHRUZXN0U2lnbjCCASIwDQYJ -KoZIhvcNAQEBBQADggEPADCCAQoCggEBAMaJ+B8HlKGXBhb64LuOiG/xGWn3RgU+ -D1i42xD4jRIjP3oL3hLefVtqQAgaP4HJa0mI1VWU2ezTbp5u11qo9eAefPq6jxaO -rbC3VyT/FE4EcoEvr48N/1ZB0jnKLQlO2lzzVCqnL9gyC+soakGwLzFs9SKjkI4h -/9YCnkoVtxOI/9ZDBf/QlJxrpknOPS9RQ8Y0OK+2OIb0kvK0f28EcvfopAnvOaVb -AHIWypIDabuRcw/YXRbmxvj2c+t1dGC7f4CLv7YKiFsEpydUJDWRUYGLnE7GvO9d -mS3oEFaI+Kre4HjSsaCF/Rgp9fpHKgaFTr8rKOGVgQHPlRFOrtGqXV8CAwEAAaNS -MFAwHQYDVR0OBBYEFKwAjNPp8T/Q6cWJGYu9aMR/ujVCMB8GA1UdIwQYMBaAFKek -g+UBOOgzMM6Ft6zCMa6k6H89MA4GA1UdDwEB/wQEAwIGwDANBgkqhkiG9w0BAQsF -AAOCAQEARWKct75OvbvIGRpTN4lvqyPJS/ZoVa/Dddbdo2rD669qltAce3/DFY2R -W0CNwIAxBh4CHqdlG5Od1qQ+BJH2pNGB6F2W/kmQuzaoo2PecDXNOfigRJASZO9O -nSFh+tQc+9DTNWrYyBb1MUEgZd4z0Q98dX3mWJ3YMG5Fb0pbexgpiAX5s9T3X+Da -olCzzmIRVIbce3UWv6T3fGvRJ/tyJ0VqvR8YBbVW15KaPabyZDE+v7QFizmoRFdw -7Dfv2tKIA/8ENO13BztYq1USTYhirfrR5Ki2oiul1Nmg48JgQRMHgfeBKMl9auyR -B6hPOeazdx/aJXMcZVIkYoWOPQsqVg== ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIDvDCCAqSgAwIBAgICEAEwDQYJKoZIhvcNAQELBQAwTzELMAkGA1UEBhMCQkUx -DjAMBgNVBAoMBWlUZXh0MTAwLgYDVQQDDCdpVGV4dE1pc3NpbmdDZXJ0aWZpY2F0 -ZXNUZXN0Q1JMUm9vdENlcnQwIBcNMjAwMTAxMDAwMDAwWhgPMjQwMDAxMDEwMDAw -MDBaME8xCzAJBgNVBAYTAkJFMQ4wDAYDVQQKDAVpVGV4dDEwMC4GA1UEAwwnaVRl -eHRNaXNzaW5nQ2VydGlmaWNhdGVzVGVzdENSTFNpZ25DZXJ0MIIBIjANBgkqhkiG -9w0BAQEFAAOCAQ8AMIIBCgKCAQEAk0rgFNDp8zelAj9o73RqZUK6pStgVbBL0Zn9 -HhM5O0e3OuWEgJtOm+foMayksOQHESxS6t/AiKdkTQc6nVl8cXncZURnsEi6SpHo -r/WMkOmKUvnYdXda2mPuRmxRopG4TMqW6S0A9N8E29+xdG3LcmV/HP4MU78nRoOH -WGi+Op1I4tyC9i8CfoRJcq7WI51fyh87TrxITS80Cjq9AXoBvmJrx90DgP7u7WUT -NAPvVayapLG3VtnexSDuM/7+73dT15a4QxPdLmFUYbyhSfH77iI11FZd/06i9v/f -uRcVZBobCs8+FzmN1OhSs1Uk7aAj/QkQkuyvVyK6uhrstfT4GwIDAQABo4GfMIGc -MB0GA1UdDgQWBBT3CXRcQ9OYneGbRjM5g/NWB0LT4DAfBgNVHSMEGDAWgBTDTbEm -iGJjiJdOu6soHhD/ha1kGjAOBgNVHQ8BAf8EBAMCBeAwSgYDVR0fBEMwQTA/oD2g -O4Y5aHR0cDovL3Rlc3QuZXhhbXBsZS5jb20vZXhhbXBsZS1jYS9jcmxzL2NhLWNy -bC9sYXRlc3QuY3JsMA0GCSqGSIb3DQEBCwUAA4IBAQAhTj5txV1IAyfe7K/bxDlK -nKRJYYLsY8iTCu3dNF7mjSD7eZf7wWvGdfR2a910uS6U0/ZDIYyKSOnxdlRvNrU5 -nGxk48JuUZgSlSmzq1RmvdPx6dBLJT3Dctm7hkzQHemYNNAlkvDVX2GMPrEgcoTY -S5gwKOvoQi5hXIYNxX43CaxVGyForNBMBn4502ThTs/M58EKNEZvUaNbYs2iLNkS -CU1M0KZ4fMlihP9xtAhTBeqHUqEubKP45T0KzqWOZPH/WyQPeIrNAnXk2H0gIZP5 -ElI5Wm7r+EhCWTDfaBK3OormNoBOYKU0tawzzKVh1MHOg+31BqJud7H+t5REbTck ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIDfzCCAmegAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwTzELMAkGA1UEBhMCQkUx -DjAMBgNVBAoMBWlUZXh0MTAwLgYDVQQDDCdpVGV4dE1pc3NpbmdDZXJ0aWZpY2F0 -ZXNUZXN0Q1JMUm9vdENlcnQwIBcNMDAwMTAxMDAwMDAwWhgPMjUwMDAxMDEwMDAw -MDBaME8xCzAJBgNVBAYTAkJFMQ4wDAYDVQQKDAVpVGV4dDEwMC4GA1UEAwwnaVRl -eHRNaXNzaW5nQ2VydGlmaWNhdGVzVGVzdENSTFJvb3RDZXJ0MIIBIjANBgkqhkiG -9w0BAQEFAAOCAQ8AMIIBCgKCAQEAu8ePfGsGJ2JOMKSzy1vSZW0vutjJCdi5mW+Y -vqYJ+kQLOr0+gb3Wu0BonyFzl8wF9ogfaAyBqjzswaKw9uGfhHanzh5vqNwSHNlR -/2aa56I1GidrprnaMSZiNy4lFAGxajFfb0D++UNjdLrkARjVcKenrwauR+GbT5bM -tQw3yJVyMzAA6uy4xGMMNW/ZZwEUmKvWPNXqJHq0BvJICWWlZFQI2dMQo4DR7Npk -D8dVd/Fdwtpp59E6xGz6WDk9/x6NH7wcZGW8xjZTtkrTOoppMG6A7Wrb+VWrXVbT -lKaCo/1DY4whfnkKUwDsNXIk4vn9sU6PRvp0iEZGqk5Z25wQJwIDAQABo2MwYTAd -BgNVHQ4EFgQUw02xJohiY4iXTrurKB4Q/4WtZBowHwYDVR0jBBgwFoAUw02xJohi -Y4iXTrurKB4Q/4WtZBowDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAeYw -DQYJKoZIhvcNAQELBQADggEBAC5DclkIZBL7k5uqMA+TwzwwPSE0pCNrN0wLMy8I -qaooT3IKuLLjo7FLH28ZRkrUYBdrg7W60NZfbDNcLoVSEyyOFMrplQNdUDPByrTU -BUERxQ7r+7g+pHuF93o/3DbwvN8fykm4pC7d0JlFwge+LOu7pICHa8Ctj6K+C0kN -lwhoz3Rafg+1tj5GUoGj2ZX82yXwb+rnSIn0hj6HhDpPXYRn2GssOqkOs1MJElw+ -GPn8vD7a3wI++4alki52TuR1Ydu41z4lQjfy3JSaFuflsPFf0KjNeCkH/D6PgwZg -KCcD7fbk2IcIj70d5xye3v53wkbc9wZhqYm9CtKYunrKGoM= ------END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/crlAndSignCertRootIssuerMismatch/crl-issuer.cert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/crlAndSignCertRootIssuerMismatch/crl-issuer.cert.pem deleted file mode 100644 index 10dca028c1..0000000000 --- a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/crlAndSignCertRootIssuerMismatch/crl-issuer.cert.pem +++ /dev/null @@ -1,22 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDvDCCAqSgAwIBAgICEAEwDQYJKoZIhvcNAQELBQAwTzELMAkGA1UEBhMCQkUx -DjAMBgNVBAoMBWlUZXh0MTAwLgYDVQQDDCdpVGV4dE1pc3NpbmdDZXJ0aWZpY2F0 -ZXNUZXN0Q1JMUm9vdENlcnQwIBcNMjAwMTAxMDAwMDAwWhgPMjQwMDAxMDEwMDAw -MDBaME8xCzAJBgNVBAYTAkJFMQ4wDAYDVQQKDAVpVGV4dDEwMC4GA1UEAwwnaVRl -eHRNaXNzaW5nQ2VydGlmaWNhdGVzVGVzdENSTFNpZ25DZXJ0MIIBIjANBgkqhkiG -9w0BAQEFAAOCAQ8AMIIBCgKCAQEAk0rgFNDp8zelAj9o73RqZUK6pStgVbBL0Zn9 -HhM5O0e3OuWEgJtOm+foMayksOQHESxS6t/AiKdkTQc6nVl8cXncZURnsEi6SpHo -r/WMkOmKUvnYdXda2mPuRmxRopG4TMqW6S0A9N8E29+xdG3LcmV/HP4MU78nRoOH -WGi+Op1I4tyC9i8CfoRJcq7WI51fyh87TrxITS80Cjq9AXoBvmJrx90DgP7u7WUT -NAPvVayapLG3VtnexSDuM/7+73dT15a4QxPdLmFUYbyhSfH77iI11FZd/06i9v/f -uRcVZBobCs8+FzmN1OhSs1Uk7aAj/QkQkuyvVyK6uhrstfT4GwIDAQABo4GfMIGc -MB0GA1UdDgQWBBT3CXRcQ9OYneGbRjM5g/NWB0LT4DAfBgNVHSMEGDAWgBTDTbEm -iGJjiJdOu6soHhD/ha1kGjAOBgNVHQ8BAf8EBAMCBeAwSgYDVR0fBEMwQTA/oD2g -O4Y5aHR0cDovL3Rlc3QuZXhhbXBsZS5jb20vZXhhbXBsZS1jYS9jcmxzL2NhLWNy -bC9sYXRlc3QuY3JsMA0GCSqGSIb3DQEBCwUAA4IBAQAhTj5txV1IAyfe7K/bxDlK -nKRJYYLsY8iTCu3dNF7mjSD7eZf7wWvGdfR2a910uS6U0/ZDIYyKSOnxdlRvNrU5 -nGxk48JuUZgSlSmzq1RmvdPx6dBLJT3Dctm7hkzQHemYNNAlkvDVX2GMPrEgcoTY -S5gwKOvoQi5hXIYNxX43CaxVGyForNBMBn4502ThTs/M58EKNEZvUaNbYs2iLNkS -CU1M0KZ4fMlihP9xtAhTBeqHUqEubKP45T0KzqWOZPH/WyQPeIrNAnXk2H0gIZP5 -ElI5Wm7r+EhCWTDfaBK3OormNoBOYKU0tawzzKVh1MHOg+31BqJud7H+t5REbTck ------END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/crlAndSignCertRootIssuerMismatch/crl.crl b/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/crlAndSignCertRootIssuerMismatch/crl.crl deleted file mode 100644 index 286fba41ce..0000000000 Binary files a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/crlAndSignCertRootIssuerMismatch/crl.crl and /dev/null differ diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/crlAndSignCertRootIssuerMismatch/crlRoot.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/crlAndSignCertRootIssuerMismatch/crlRoot.pem deleted file mode 100644 index fcc6491e2e..0000000000 --- a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/crlAndSignCertRootIssuerMismatch/crlRoot.pem +++ /dev/null @@ -1,21 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDfzCCAmegAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwTzELMAkGA1UEBhMCQkUx -DjAMBgNVBAoMBWlUZXh0MTAwLgYDVQQDDCdpVGV4dE1pc3NpbmdDZXJ0aWZpY2F0 -ZXNUZXN0Q1JMUm9vdENlcnQwIBcNMDAwMTAxMDAwMDAwWhgPMjUwMDAxMDEwMDAw -MDBaME8xCzAJBgNVBAYTAkJFMQ4wDAYDVQQKDAVpVGV4dDEwMC4GA1UEAwwnaVRl -eHRNaXNzaW5nQ2VydGlmaWNhdGVzVGVzdENSTFJvb3RDZXJ0MIIBIjANBgkqhkiG -9w0BAQEFAAOCAQ8AMIIBCgKCAQEAu8ePfGsGJ2JOMKSzy1vSZW0vutjJCdi5mW+Y -vqYJ+kQLOr0+gb3Wu0BonyFzl8wF9ogfaAyBqjzswaKw9uGfhHanzh5vqNwSHNlR -/2aa56I1GidrprnaMSZiNy4lFAGxajFfb0D++UNjdLrkARjVcKenrwauR+GbT5bM -tQw3yJVyMzAA6uy4xGMMNW/ZZwEUmKvWPNXqJHq0BvJICWWlZFQI2dMQo4DR7Npk -D8dVd/Fdwtpp59E6xGz6WDk9/x6NH7wcZGW8xjZTtkrTOoppMG6A7Wrb+VWrXVbT -lKaCo/1DY4whfnkKUwDsNXIk4vn9sU6PRvp0iEZGqk5Z25wQJwIDAQABo2MwYTAd -BgNVHQ4EFgQUw02xJohiY4iXTrurKB4Q/4WtZBowHwYDVR0jBBgwFoAUw02xJohi -Y4iXTrurKB4Q/4WtZBowDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAeYw -DQYJKoZIhvcNAQELBQADggEBAC5DclkIZBL7k5uqMA+TwzwwPSE0pCNrN0wLMy8I -qaooT3IKuLLjo7FLH28ZRkrUYBdrg7W60NZfbDNcLoVSEyyOFMrplQNdUDPByrTU -BUERxQ7r+7g+pHuF93o/3DbwvN8fykm4pC7d0JlFwge+LOu7pICHa8Ctj6K+C0kN -lwhoz3Rafg+1tj5GUoGj2ZX82yXwb+rnSIn0hj6HhDpPXYRn2GssOqkOs1MJElw+ -GPn8vD7a3wI++4alki52TuR1Ydu41z4lQjfy3JSaFuflsPFf0KjNeCkH/D6PgwZg -KCcD7fbk2IcIj70d5xye3v53wkbc9wZhqYm9CtKYunrKGoM= ------END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/crlEncodingError/chain.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/crlEncodingError/chain.pem deleted file mode 100644 index 1c28583267..0000000000 --- a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/crlEncodingError/chain.pem +++ /dev/null @@ -1,81 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDSzCCAjOgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwNTELMAkGA1UEBhMCQkUx -DjAMBgNVBAoMBWlUZXh0MRYwFAYDVQQDDA1pVGV4dFRlc3RSb290MCAXDTAwMDEw -MTAwMDAwMFoYDzI1MDAwMTAxMDAwMDAwWjA1MQswCQYDVQQGEwJCRTEOMAwGA1UE -CgwFaVRleHQxFjAUBgNVBAMMDWlUZXh0VGVzdFJvb3QwggEiMA0GCSqGSIb3DQEB -AQUAA4IBDwAwggEKAoIBAQDP6KUmxQzeXKuwodaQZ7IUoidvDeXWrjW7BNYmKhey -DX9SIeIwvuiKDVUD85pWyk6jhNUvQaYvGVOv/Pbu4NJHv9FKch2d9759ckMT+MXG -fGk/B6Ww1rlKsiHccWizQxah7R79eGweEvryPIx+hqxreCBH4yzMPjHld1C34/vC -nUGmozKT4KENiT6lXXiBm4D+u3siCPt1Gzxavvm2MUBTHBbhQ3/n1eS/FcqT4NhI -vXDpPiNouD9goI+4LwCW7b52dg7dXreQY/IfGCcHTcu7YK/OEW4Pqjpr13B5mEDS -DsCqrStoh8EQ+jB62n2Xv8TT4lQju/sZh0l65IiT8fUfAgMBAAGjYzBhMB0GA1Ud -DgQWBBRkxUEzwLkf0rdu5Txco5JSsf8WCzAfBgNVHSMEGDAWgBRkxUEzwLkf0rdu -5Txco5JSsf8WCzAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIC5DANBgkq -hkiG9w0BAQsFAAOCAQEARJOOUQkv9AgqElJmQjGDkRdJPxkDHZtRLGOk9p0E1KbL -lqQQdgzL7RuE4vfCROan6aBZmXFRviIPg/Gxw2hDSIv1NUZv3AIgM2b9+3y+4SQ6 -2a/sqh1JPLxwnLN+Mo5KwY/E/YlJ0N7rw3AONrLlqH89BRrBIiPjrg74zi6qPzGn -WB2awHsbl7AOtkD2dEud7lbyLda/hCw2RGPSBQMm50pWsuInWXzdtX/Ii9yTGMyD -kavUHX6DDVouZBSKOjmChP0fGPM17ORJNR92RbT2ygy+F0Zokh5XUgrKPr4/JTW5 -iIkycpjAXY9UEMfi8pFnnzVSRj65kkZvZZJzybelMQ== ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIDhzCCAm+gAwIBAgICEAIwDQYJKoZIhvcNAQELBQAwNTELMAkGA1UEBhMCQkUx -DjAMBgNVBAoMBWlUZXh0MRYwFAYDVQQDDA1pVGV4dFRlc3RSb290MCAXDTAwMDEw -MTAwMDAwMFoYDzI0NTAwMTAxMDAwMDAwWjA6MQswCQYDVQQGEwJCRTEOMAwGA1UE -CgwFaVRleHQxGzAZBgNVBAMMEmlUZXh0VGVzdENybElzc3VlcjCCASIwDQYJKoZI -hvcNAQEBBQADggEPADCCAQoCggEBAJV6eBrtpxfCCiAkgz3wdLUqRio0/TBHDHg5 -oU1lHNeKoNkEG/kwdgPFN4YN9qufVZBi5mRY54NaVySKHo2w7/CrscZhbXtrBIQY -WzR0vRptsbmqV2xfBlqtPyPlRMt2SRnwe3Q4XqZSnX13bUTLO0SBlddGt7h/HQfD -vSzbekJWd8bPt+cH5Ke3y0cdFNylwP5yXEZdDyU9CtkzaBpHFM8vAEO00/kqahap -8Ox+Tea7zrAfoT58juJdGOlt7DRJs6jsLXsDT04zk47cpZ904R29lzU1zoMoiEjf -UTDO0c5fj4q4RCYzSpT3jX5VJEfKlooP6TX/GDVtH58+A3YQXuMCAwEAAaOBmTCB -ljAdBgNVHQ4EFgQU0zydGfhFz0j/TGolSJNUJEx9j2UwHwYDVR0jBBgwFoAUZMVB -M8C5H9K3buU8XKOSUrH/FgswDgYDVR0PAQH/BAQDAgHCMEQGA1UdHwQ9MDswOaA3 -oDWGM2h0dHA6Ly9sb2NhbGhvc3QudGVzdC9oYXBweVBhdGgvY3Jscy9jcmwvbGF0 -ZXN0LmNybDANBgkqhkiG9w0BAQsFAAOCAQEALXE8wl8A0vUP0CDs8/2nTSramr3N -M8bwkiQx88d2QAvq5pq0j4U/kfxnQk6PqQ+mJJIRn2U+Mc8Z/48VcGpYwqmO3wXc -0pRSohNCyD7vj48Og0dWKsMDimrzUEDqy6qaODfczqtQIpkwRyn/A9HQDzCOwtAr -6A86xnrOn96xxt/cnBeJ6SIw9tE461ZJ/pDJevzt64GYJBvbB+QE+NsAA4SOZgVG -iZ39xNt7WFrBuaU/n5ysZVbvN8tDJYSnfFPxD0kHmvWCDVxVzk5cckoRv6RQRA1s -m6IHnGQuPEoXa+y0/oyaEUDby/0G2Pe1CoBpaHMX9n4CSSnhaPB5tPpjrw== ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIDQjCCAiqgAwIBAgICEAEwDQYJKoZIhvcNAQELBQAwNTELMAkGA1UEBhMCQkUx -DjAMBgNVBAoMBWlUZXh0MRYwFAYDVQQDDA1pVGV4dFRlc3RSb290MCAXDTAwMDEw -MTAwMDAwMFoYDzI0NTAwMTAxMDAwMDAwWjA9MQswCQYDVQQGEwJCRTEOMAwGA1UE -CgwFaVRleHQxHjAcBgNVBAMMFWlUZXh0VGVzdEludGVybWVkaWF0ZTCCASIwDQYJ -KoZIhvcNAQEBBQADggEPADCCAQoCggEBAM3t0dlZupS+5Z0EGHsnruz2ZRoVKwbp -IXwuOGuetobCTaaTfAyXmgXqcH1ZPi0u1dSzkWbHOdBNhRQLlk3ZtTfnCQrtijjU -U6jqkiMoMhap1/jEQPoU6CHP3bbwkSdZrnNriVxyGp2IKGwNDlg9fOBGuXdNei8N -fP5q9daV3oC9ckverNNKpcn9/0wYchISH9Y0a8N6FFUBqEYnjsEee7a5VIfgsP70 -jrhk53pNQJSObJhAFzhsbFNXxmWkZpi/YUJaBCSQYwQCUToRINyUMZOtsUIBh4es -8EpBt2utPkVifZvBo+prKUPTYX64iKko7zY5WHyP6vIV5BihYYv3Em8CAwEAAaNS -MFAwHQYDVR0OBBYEFKekg+UBOOgzMM6Ft6zCMa6k6H89MB8GA1UdIwQYMBaAFGTF -QTPAuR/St27lPFyjklKx/xYLMA4GA1UdDwEB/wQEAwIB5jANBgkqhkiG9w0BAQsF -AAOCAQEAadrnESocLAKEhOVcKC1tGOlDEI3oYkODcT4E3AOBqBq+gy4s5hfrQEpC -HqCje0pGNY1xgdcG5OPaKNSMT7+/PLE5As7aktNQxWuhDSH0SwKQPBbG+pfs0m3J -1R6M0WKsqvLWUtUgkzQp2f9pqu/XBrjqJnI5RwtNBBXJV8QBhLf4z/kGIk4noDM7 -2PcXdGNfl6dINcX8q3meZ1DkWTypgZ1pcEcvHU0rUPo+UPUpg6pOruOVnCERRiSx -z97Gqp1ZDa/jH1a+tjmbq4EN1vbULzVw+xsBIMuT7lsPTLdy/AHIx2UXVMGhHoYV -BHO096jz11DkzNKHloHf5sKPK2Ecjg== ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIDQjCCAiqgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwPTELMAkGA1UEBhMCQkUx -DjAMBgNVBAoMBWlUZXh0MR4wHAYDVQQDDBVpVGV4dFRlc3RJbnRlcm1lZGlhdGUw -IBcNMDAwMTAxMDAwMDAwWhgPMjQwMDAxMDEwMDAwMDBaMDUxCzAJBgNVBAYTAkJF -MQ4wDAYDVQQKDAVpVGV4dDEWMBQGA1UEAwwNaVRleHRUZXN0U2lnbjCCASIwDQYJ -KoZIhvcNAQEBBQADggEPADCCAQoCggEBAMaJ+B8HlKGXBhb64LuOiG/xGWn3RgU+ -D1i42xD4jRIjP3oL3hLefVtqQAgaP4HJa0mI1VWU2ezTbp5u11qo9eAefPq6jxaO -rbC3VyT/FE4EcoEvr48N/1ZB0jnKLQlO2lzzVCqnL9gyC+soakGwLzFs9SKjkI4h -/9YCnkoVtxOI/9ZDBf/QlJxrpknOPS9RQ8Y0OK+2OIb0kvK0f28EcvfopAnvOaVb -AHIWypIDabuRcw/YXRbmxvj2c+t1dGC7f4CLv7YKiFsEpydUJDWRUYGLnE7GvO9d -mS3oEFaI+Kre4HjSsaCF/Rgp9fpHKgaFTr8rKOGVgQHPlRFOrtGqXV8CAwEAAaNS -MFAwHQYDVR0OBBYEFKwAjNPp8T/Q6cWJGYu9aMR/ujVCMB8GA1UdIwQYMBaAFKek -g+UBOOgzMM6Ft6zCMa6k6H89MA4GA1UdDwEB/wQEAwIGwDANBgkqhkiG9w0BAQsF -AAOCAQEARWKct75OvbvIGRpTN4lvqyPJS/ZoVa/Dddbdo2rD669qltAce3/DFY2R -W0CNwIAxBh4CHqdlG5Od1qQ+BJH2pNGB6F2W/kmQuzaoo2PecDXNOfigRJASZO9O -nSFh+tQc+9DTNWrYyBb1MUEgZd4z0Q98dX3mWJ3YMG5Fb0pbexgpiAX5s9T3X+Da -olCzzmIRVIbce3UWv6T3fGvRJ/tyJ0VqvR8YBbVW15KaPabyZDE+v7QFizmoRFdw -7Dfv2tKIA/8ENO13BztYq1USTYhirfrR5Ki2oiul1Nmg48JgQRMHgfeBKMl9auyR -B6hPOeazdx/aJXMcZVIkYoWOPQsqVg== ------END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/crlEncodingError/sign.cert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/crlEncodingError/sign.cert.pem deleted file mode 100644 index 26c2432936..0000000000 --- a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/crlEncodingError/sign.cert.pem +++ /dev/null @@ -1,20 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDQjCCAiqgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwPTELMAkGA1UEBhMCQkUx -DjAMBgNVBAoMBWlUZXh0MR4wHAYDVQQDDBVpVGV4dFRlc3RJbnRlcm1lZGlhdGUw -IBcNMDAwMTAxMDAwMDAwWhgPMjQwMDAxMDEwMDAwMDBaMDUxCzAJBgNVBAYTAkJF -MQ4wDAYDVQQKDAVpVGV4dDEWMBQGA1UEAwwNaVRleHRUZXN0U2lnbjCCASIwDQYJ -KoZIhvcNAQEBBQADggEPADCCAQoCggEBAMaJ+B8HlKGXBhb64LuOiG/xGWn3RgU+ -D1i42xD4jRIjP3oL3hLefVtqQAgaP4HJa0mI1VWU2ezTbp5u11qo9eAefPq6jxaO -rbC3VyT/FE4EcoEvr48N/1ZB0jnKLQlO2lzzVCqnL9gyC+soakGwLzFs9SKjkI4h -/9YCnkoVtxOI/9ZDBf/QlJxrpknOPS9RQ8Y0OK+2OIb0kvK0f28EcvfopAnvOaVb -AHIWypIDabuRcw/YXRbmxvj2c+t1dGC7f4CLv7YKiFsEpydUJDWRUYGLnE7GvO9d -mS3oEFaI+Kre4HjSsaCF/Rgp9fpHKgaFTr8rKOGVgQHPlRFOrtGqXV8CAwEAAaNS -MFAwHQYDVR0OBBYEFKwAjNPp8T/Q6cWJGYu9aMR/ujVCMB8GA1UdIwQYMBaAFKek -g+UBOOgzMM6Ft6zCMa6k6H89MA4GA1UdDwEB/wQEAwIGwDANBgkqhkiG9w0BAQsF -AAOCAQEARWKct75OvbvIGRpTN4lvqyPJS/ZoVa/Dddbdo2rD669qltAce3/DFY2R -W0CNwIAxBh4CHqdlG5Od1qQ+BJH2pNGB6F2W/kmQuzaoo2PecDXNOfigRJASZO9O -nSFh+tQc+9DTNWrYyBb1MUEgZd4z0Q98dX3mWJ3YMG5Fb0pbexgpiAX5s9T3X+Da -olCzzmIRVIbce3UWv6T3fGvRJ/tyJ0VqvR8YBbVW15KaPabyZDE+v7QFizmoRFdw -7Dfv2tKIA/8ENO13BztYq1USTYhirfrR5Ki2oiul1Nmg48JgQRMHgfeBKMl9auyR -B6hPOeazdx/aJXMcZVIkYoWOPQsqVg== ------END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/crlIssuerAndSignCertHaveNoSharedRoot/chain.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/crlIssuerAndSignCertHaveNoSharedRoot/chain.pem deleted file mode 100644 index d8645c076d..0000000000 --- a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/crlIssuerAndSignCertHaveNoSharedRoot/chain.pem +++ /dev/null @@ -1,101 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDSzCCAjOgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwNTELMAkGA1UEBhMCQkUx -DjAMBgNVBAoMBWlUZXh0MRYwFAYDVQQDDA1pVGV4dFRlc3RSb290MCAXDTAwMDEw -MTAwMDAwMFoYDzI1MDAwMTAxMDAwMDAwWjA1MQswCQYDVQQGEwJCRTEOMAwGA1UE -CgwFaVRleHQxFjAUBgNVBAMMDWlUZXh0VGVzdFJvb3QwggEiMA0GCSqGSIb3DQEB -AQUAA4IBDwAwggEKAoIBAQDP6KUmxQzeXKuwodaQZ7IUoidvDeXWrjW7BNYmKhey -DX9SIeIwvuiKDVUD85pWyk6jhNUvQaYvGVOv/Pbu4NJHv9FKch2d9759ckMT+MXG -fGk/B6Ww1rlKsiHccWizQxah7R79eGweEvryPIx+hqxreCBH4yzMPjHld1C34/vC -nUGmozKT4KENiT6lXXiBm4D+u3siCPt1Gzxavvm2MUBTHBbhQ3/n1eS/FcqT4NhI -vXDpPiNouD9goI+4LwCW7b52dg7dXreQY/IfGCcHTcu7YK/OEW4Pqjpr13B5mEDS -DsCqrStoh8EQ+jB62n2Xv8TT4lQju/sZh0l65IiT8fUfAgMBAAGjYzBhMB0GA1Ud -DgQWBBRkxUEzwLkf0rdu5Txco5JSsf8WCzAfBgNVHSMEGDAWgBRkxUEzwLkf0rdu -5Txco5JSsf8WCzAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIC5DANBgkq -hkiG9w0BAQsFAAOCAQEARJOOUQkv9AgqElJmQjGDkRdJPxkDHZtRLGOk9p0E1KbL -lqQQdgzL7RuE4vfCROan6aBZmXFRviIPg/Gxw2hDSIv1NUZv3AIgM2b9+3y+4SQ6 -2a/sqh1JPLxwnLN+Mo5KwY/E/YlJ0N7rw3AONrLlqH89BRrBIiPjrg74zi6qPzGn -WB2awHsbl7AOtkD2dEud7lbyLda/hCw2RGPSBQMm50pWsuInWXzdtX/Ii9yTGMyD -kavUHX6DDVouZBSKOjmChP0fGPM17ORJNR92RbT2ygy+F0Zokh5XUgrKPr4/JTW5 -iIkycpjAXY9UEMfi8pFnnzVSRj65kkZvZZJzybelMQ== ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIDijCCAnKgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwOjELMAkGA1UEBhMCQkUx -DjAMBgNVBAoMBWlUZXh0MRswGQYDVQQDDBJpVGV4dE90aGVyVGVzdFJvb3QwIBcN -MDAwMTAxMDAwMDAwWhgPMjQ1MDAxMDEwMDAwMDBaMDoxCzAJBgNVBAYTAkJFMQ4w -DAYDVQQKDAVpVGV4dDEbMBkGA1UEAwwSaVRleHRUZXN0Q3JsSXNzdWVyMIIBIjAN -BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAlXp4Gu2nF8IKICSDPfB0tSpGKjT9 -MEcMeDmhTWUc14qg2QQb+TB2A8U3hg32q59VkGLmZFjng1pXJIoejbDv8KuxxmFt -e2sEhBhbNHS9Gm2xuapXbF8GWq0/I+VEy3ZJGfB7dDheplKdfXdtRMs7RIGV10a3 -uH8dB8O9LNt6QlZ3xs+35wfkp7fLRx0U3KXA/nJcRl0PJT0K2TNoGkcUzy8AQ7TT -+SpqFqnw7H5N5rvOsB+hPnyO4l0Y6W3sNEmzqOwtewNPTjOTjtyln3ThHb2XNTXO -gyiISN9RMM7Rzl+PirhEJjNKlPeNflUkR8qWig/pNf8YNW0fnz4DdhBe4wIDAQAB -o4GXMIGUMB0GA1UdDgQWBBTTPJ0Z+EXPSP9MaiVIk1QkTH2PZTAfBgNVHSMEGDAW -gBSnpIPlATjoMzDOhbeswjGupOh/PTAOBgNVHQ8BAf8EBAMCAcIwQgYDVR0fBDsw -OTA3oDWgM4YxaHR0cDovL2xvY2FsaG9zdC50ZXN0L2RlZmF1bHQvY3Jscy9jcmwv -bGF0ZXN0LmNybDANBgkqhkiG9w0BAQsFAAOCAQEAoX9g8yKhzXz+FirY5WtC1nbJ -DSeggirm4NFWeNvZY/nahleeO4+0RXRYp3maIjaEieWqgov4KukdtGl1SjQfvy6a -ghoznl3fwTR/TO2d5ms6LFfETEptY0p6zDnLjMDeYFNjLLZiXFDtnEV1DjrafrXI -PGFgF+jaYiZUp9H3oFyMUpi+gQDWmAoCppt8XBqoyWUmSqwfEk6Ls5qBu1N5KJQU -TIV6zCK90cqGNvypKbynb0LAvQAkJiMoprOxf2PHoahNIsbuvasJp/LB2xJWbVjR -B3/Qb8SelSNFgwwHjGq7Zqx3zknNxSMKX+9wqAMGovgyJD411faSdBL9l4KaoA== ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIDQjCCAiqgAwIBAgICEAEwDQYJKoZIhvcNAQELBQAwNTELMAkGA1UEBhMCQkUx -DjAMBgNVBAoMBWlUZXh0MRYwFAYDVQQDDA1pVGV4dFRlc3RSb290MCAXDTAwMDEw -MTAwMDAwMFoYDzI0NTAwMTAxMDAwMDAwWjA9MQswCQYDVQQGEwJCRTEOMAwGA1UE -CgwFaVRleHQxHjAcBgNVBAMMFWlUZXh0VGVzdEludGVybWVkaWF0ZTCCASIwDQYJ -KoZIhvcNAQEBBQADggEPADCCAQoCggEBAM3t0dlZupS+5Z0EGHsnruz2ZRoVKwbp -IXwuOGuetobCTaaTfAyXmgXqcH1ZPi0u1dSzkWbHOdBNhRQLlk3ZtTfnCQrtijjU -U6jqkiMoMhap1/jEQPoU6CHP3bbwkSdZrnNriVxyGp2IKGwNDlg9fOBGuXdNei8N -fP5q9daV3oC9ckverNNKpcn9/0wYchISH9Y0a8N6FFUBqEYnjsEee7a5VIfgsP70 -jrhk53pNQJSObJhAFzhsbFNXxmWkZpi/YUJaBCSQYwQCUToRINyUMZOtsUIBh4es -8EpBt2utPkVifZvBo+prKUPTYX64iKko7zY5WHyP6vIV5BihYYv3Em8CAwEAAaNS -MFAwHQYDVR0OBBYEFKekg+UBOOgzMM6Ft6zCMa6k6H89MB8GA1UdIwQYMBaAFGTF -QTPAuR/St27lPFyjklKx/xYLMA4GA1UdDwEB/wQEAwIB5jANBgkqhkiG9w0BAQsF -AAOCAQEAadrnESocLAKEhOVcKC1tGOlDEI3oYkODcT4E3AOBqBq+gy4s5hfrQEpC -HqCje0pGNY1xgdcG5OPaKNSMT7+/PLE5As7aktNQxWuhDSH0SwKQPBbG+pfs0m3J -1R6M0WKsqvLWUtUgkzQp2f9pqu/XBrjqJnI5RwtNBBXJV8QBhLf4z/kGIk4noDM7 -2PcXdGNfl6dINcX8q3meZ1DkWTypgZ1pcEcvHU0rUPo+UPUpg6pOruOVnCERRiSx -z97Gqp1ZDa/jH1a+tjmbq4EN1vbULzVw+xsBIMuT7lsPTLdy/AHIx2UXVMGhHoYV -BHO096jz11DkzNKHloHf5sKPK2Ecjg== ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIDVTCCAj2gAwIBAgICEAEwDQYJKoZIhvcNAQELBQAwOjELMAkGA1UEBhMCQkUx -DjAMBgNVBAoMBWlUZXh0MRswGQYDVQQDDBJpVGV4dE90aGVyVGVzdFJvb3QwIBcN -MDAwMTAxMDAwMDAwWhgPMjUwMDAxMDEwMDAwMDBaMDoxCzAJBgNVBAYTAkJFMQ4w -DAYDVQQKDAVpVGV4dDEbMBkGA1UEAwwSaVRleHRPdGhlclRlc3RSb290MIIBIjAN -BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAze3R2Vm6lL7lnQQYeyeu7PZlGhUr -BukhfC44a562hsJNppN8DJeaBepwfVk+LS7V1LORZsc50E2FFAuWTdm1N+cJCu2K -ONRTqOqSIygyFqnX+MRA+hToIc/dtvCRJ1muc2uJXHIanYgobA0OWD184Ea5d016 -Lw18/mr11pXegL1yS96s00qlyf3/TBhyEhIf1jRrw3oUVQGoRieOwR57trlUh+Cw -/vSOuGTnek1AlI5smEAXOGxsU1fGZaRmmL9hQloEJJBjBAJROhEg3JQxk62xQgGH -h6zwSkG3a60+RWJ9m8Gj6mspQ9NhfriIqSjvNjlYfI/q8hXkGKFhi/cSbwIDAQAB -o2MwYTAdBgNVHQ4EFgQUp6SD5QE46DMwzoW3rMIxrqTofz0wHwYDVR0jBBgwFoAU -p6SD5QE46DMwzoW3rMIxrqTofz0wDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8E -BAMCAuQwDQYJKoZIhvcNAQELBQADggEBAB+QFs5zu6uD0+IEyAt8B+jxK2lV7025 -vENBQhFsnAKqsa7KJ5BCg4MrphMKvLTYopJz8TxQ4N6lmjS2VbdYZDqaP6M0mzwc -8E4biuW/6YptjLfoKZU73UqKPPvdh2qkll/nF/pMy8v6bf6Wg12b8pQAIrgaqu4/ -kopcba/2TftGy5/JUGVePif9+CUL95+UiUf9nvQr0KFL0+8k8L1DLs0wABKAPHXu -dFtfs1ofM5cC8pmVlJhoiIoHCWnIYOK2ea80Z2Xl/Y5ZtvAcluLW+0Ll+hsJ3pfy -80FH0UU7VsEJIOYrVCNx/JpXBH/AKQT0FcVzWU94FeSGb0vfihuL7nY= ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIDQjCCAiqgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwPTELMAkGA1UEBhMCQkUx -DjAMBgNVBAoMBWlUZXh0MR4wHAYDVQQDDBVpVGV4dFRlc3RJbnRlcm1lZGlhdGUw -IBcNMDAwMTAxMDAwMDAwWhgPMjQwMDAxMDEwMDAwMDBaMDUxCzAJBgNVBAYTAkJF -MQ4wDAYDVQQKDAVpVGV4dDEWMBQGA1UEAwwNaVRleHRUZXN0U2lnbjCCASIwDQYJ -KoZIhvcNAQEBBQADggEPADCCAQoCggEBAMaJ+B8HlKGXBhb64LuOiG/xGWn3RgU+ -D1i42xD4jRIjP3oL3hLefVtqQAgaP4HJa0mI1VWU2ezTbp5u11qo9eAefPq6jxaO -rbC3VyT/FE4EcoEvr48N/1ZB0jnKLQlO2lzzVCqnL9gyC+soakGwLzFs9SKjkI4h -/9YCnkoVtxOI/9ZDBf/QlJxrpknOPS9RQ8Y0OK+2OIb0kvK0f28EcvfopAnvOaVb -AHIWypIDabuRcw/YXRbmxvj2c+t1dGC7f4CLv7YKiFsEpydUJDWRUYGLnE7GvO9d -mS3oEFaI+Kre4HjSsaCF/Rgp9fpHKgaFTr8rKOGVgQHPlRFOrtGqXV8CAwEAAaNS -MFAwHQYDVR0OBBYEFKwAjNPp8T/Q6cWJGYu9aMR/ujVCMB8GA1UdIwQYMBaAFKek -g+UBOOgzMM6Ft6zCMa6k6H89MA4GA1UdDwEB/wQEAwIGwDANBgkqhkiG9w0BAQsF -AAOCAQEARWKct75OvbvIGRpTN4lvqyPJS/ZoVa/Dddbdo2rD669qltAce3/DFY2R -W0CNwIAxBh4CHqdlG5Od1qQ+BJH2pNGB6F2W/kmQuzaoo2PecDXNOfigRJASZO9O -nSFh+tQc+9DTNWrYyBb1MUEgZd4z0Q98dX3mWJ3YMG5Fb0pbexgpiAX5s9T3X+Da -olCzzmIRVIbce3UWv6T3fGvRJ/tyJ0VqvR8YBbVW15KaPabyZDE+v7QFizmoRFdw -7Dfv2tKIA/8ENO13BztYq1USTYhirfrR5Ki2oiul1Nmg48JgQRMHgfeBKMl9auyR -B6hPOeazdx/aJXMcZVIkYoWOPQsqVg== ------END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/crlIssuerAndSignCertHaveNoSharedRoot/crl-issuer.cert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/crlIssuerAndSignCertHaveNoSharedRoot/crl-issuer.cert.pem deleted file mode 100644 index f8c18553f3..0000000000 --- a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/crlIssuerAndSignCertHaveNoSharedRoot/crl-issuer.cert.pem +++ /dev/null @@ -1,21 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDijCCAnKgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwOjELMAkGA1UEBhMCQkUx -DjAMBgNVBAoMBWlUZXh0MRswGQYDVQQDDBJpVGV4dE90aGVyVGVzdFJvb3QwIBcN -MDAwMTAxMDAwMDAwWhgPMjQ1MDAxMDEwMDAwMDBaMDoxCzAJBgNVBAYTAkJFMQ4w -DAYDVQQKDAVpVGV4dDEbMBkGA1UEAwwSaVRleHRUZXN0Q3JsSXNzdWVyMIIBIjAN -BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAlXp4Gu2nF8IKICSDPfB0tSpGKjT9 -MEcMeDmhTWUc14qg2QQb+TB2A8U3hg32q59VkGLmZFjng1pXJIoejbDv8KuxxmFt -e2sEhBhbNHS9Gm2xuapXbF8GWq0/I+VEy3ZJGfB7dDheplKdfXdtRMs7RIGV10a3 -uH8dB8O9LNt6QlZ3xs+35wfkp7fLRx0U3KXA/nJcRl0PJT0K2TNoGkcUzy8AQ7TT -+SpqFqnw7H5N5rvOsB+hPnyO4l0Y6W3sNEmzqOwtewNPTjOTjtyln3ThHb2XNTXO -gyiISN9RMM7Rzl+PirhEJjNKlPeNflUkR8qWig/pNf8YNW0fnz4DdhBe4wIDAQAB -o4GXMIGUMB0GA1UdDgQWBBTTPJ0Z+EXPSP9MaiVIk1QkTH2PZTAfBgNVHSMEGDAW -gBSnpIPlATjoMzDOhbeswjGupOh/PTAOBgNVHQ8BAf8EBAMCAcIwQgYDVR0fBDsw -OTA3oDWgM4YxaHR0cDovL2xvY2FsaG9zdC50ZXN0L2RlZmF1bHQvY3Jscy9jcmwv -bGF0ZXN0LmNybDANBgkqhkiG9w0BAQsFAAOCAQEAoX9g8yKhzXz+FirY5WtC1nbJ -DSeggirm4NFWeNvZY/nahleeO4+0RXRYp3maIjaEieWqgov4KukdtGl1SjQfvy6a -ghoznl3fwTR/TO2d5ms6LFfETEptY0p6zDnLjMDeYFNjLLZiXFDtnEV1DjrafrXI -PGFgF+jaYiZUp9H3oFyMUpi+gQDWmAoCppt8XBqoyWUmSqwfEk6Ls5qBu1N5KJQU -TIV6zCK90cqGNvypKbynb0LAvQAkJiMoprOxf2PHoahNIsbuvasJp/LB2xJWbVjR -B3/Qb8SelSNFgwwHjGq7Zqx3zknNxSMKX+9wqAMGovgyJD411faSdBL9l4KaoA== ------END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/crlIssuerAndSignCertHaveNoSharedRoot/intermediate.cert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/crlIssuerAndSignCertHaveNoSharedRoot/intermediate.cert.pem deleted file mode 100644 index 420f53b153..0000000000 --- a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/crlIssuerAndSignCertHaveNoSharedRoot/intermediate.cert.pem +++ /dev/null @@ -1,20 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDQjCCAiqgAwIBAgICEAEwDQYJKoZIhvcNAQELBQAwNTELMAkGA1UEBhMCQkUx -DjAMBgNVBAoMBWlUZXh0MRYwFAYDVQQDDA1pVGV4dFRlc3RSb290MCAXDTAwMDEw -MTAwMDAwMFoYDzI0NTAwMTAxMDAwMDAwWjA9MQswCQYDVQQGEwJCRTEOMAwGA1UE -CgwFaVRleHQxHjAcBgNVBAMMFWlUZXh0VGVzdEludGVybWVkaWF0ZTCCASIwDQYJ -KoZIhvcNAQEBBQADggEPADCCAQoCggEBAM3t0dlZupS+5Z0EGHsnruz2ZRoVKwbp -IXwuOGuetobCTaaTfAyXmgXqcH1ZPi0u1dSzkWbHOdBNhRQLlk3ZtTfnCQrtijjU -U6jqkiMoMhap1/jEQPoU6CHP3bbwkSdZrnNriVxyGp2IKGwNDlg9fOBGuXdNei8N -fP5q9daV3oC9ckverNNKpcn9/0wYchISH9Y0a8N6FFUBqEYnjsEee7a5VIfgsP70 -jrhk53pNQJSObJhAFzhsbFNXxmWkZpi/YUJaBCSQYwQCUToRINyUMZOtsUIBh4es -8EpBt2utPkVifZvBo+prKUPTYX64iKko7zY5WHyP6vIV5BihYYv3Em8CAwEAAaNS -MFAwHQYDVR0OBBYEFKekg+UBOOgzMM6Ft6zCMa6k6H89MB8GA1UdIwQYMBaAFGTF -QTPAuR/St27lPFyjklKx/xYLMA4GA1UdDwEB/wQEAwIB5jANBgkqhkiG9w0BAQsF -AAOCAQEAadrnESocLAKEhOVcKC1tGOlDEI3oYkODcT4E3AOBqBq+gy4s5hfrQEpC -HqCje0pGNY1xgdcG5OPaKNSMT7+/PLE5As7aktNQxWuhDSH0SwKQPBbG+pfs0m3J -1R6M0WKsqvLWUtUgkzQp2f9pqu/XBrjqJnI5RwtNBBXJV8QBhLf4z/kGIk4noDM7 -2PcXdGNfl6dINcX8q3meZ1DkWTypgZ1pcEcvHU0rUPo+UPUpg6pOruOVnCERRiSx -z97Gqp1ZDa/jH1a+tjmbq4EN1vbULzVw+xsBIMuT7lsPTLdy/AHIx2UXVMGhHoYV -BHO096jz11DkzNKHloHf5sKPK2Ecjg== ------END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/crlIssuerAndSignCertHaveNoSharedRoot/otherca.cert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/crlIssuerAndSignCertHaveNoSharedRoot/otherca.cert.pem deleted file mode 100644 index e66c160433..0000000000 --- a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/crlIssuerAndSignCertHaveNoSharedRoot/otherca.cert.pem +++ /dev/null @@ -1,20 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDVTCCAj2gAwIBAgICEAEwDQYJKoZIhvcNAQELBQAwOjELMAkGA1UEBhMCQkUx -DjAMBgNVBAoMBWlUZXh0MRswGQYDVQQDDBJpVGV4dE90aGVyVGVzdFJvb3QwIBcN -MDAwMTAxMDAwMDAwWhgPMjUwMDAxMDEwMDAwMDBaMDoxCzAJBgNVBAYTAkJFMQ4w -DAYDVQQKDAVpVGV4dDEbMBkGA1UEAwwSaVRleHRPdGhlclRlc3RSb290MIIBIjAN -BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAze3R2Vm6lL7lnQQYeyeu7PZlGhUr -BukhfC44a562hsJNppN8DJeaBepwfVk+LS7V1LORZsc50E2FFAuWTdm1N+cJCu2K -ONRTqOqSIygyFqnX+MRA+hToIc/dtvCRJ1muc2uJXHIanYgobA0OWD184Ea5d016 -Lw18/mr11pXegL1yS96s00qlyf3/TBhyEhIf1jRrw3oUVQGoRieOwR57trlUh+Cw -/vSOuGTnek1AlI5smEAXOGxsU1fGZaRmmL9hQloEJJBjBAJROhEg3JQxk62xQgGH -h6zwSkG3a60+RWJ9m8Gj6mspQ9NhfriIqSjvNjlYfI/q8hXkGKFhi/cSbwIDAQAB -o2MwYTAdBgNVHQ4EFgQUp6SD5QE46DMwzoW3rMIxrqTofz0wHwYDVR0jBBgwFoAU -p6SD5QE46DMwzoW3rMIxrqTofz0wDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8E -BAMCAuQwDQYJKoZIhvcNAQELBQADggEBAB+QFs5zu6uD0+IEyAt8B+jxK2lV7025 -vENBQhFsnAKqsa7KJ5BCg4MrphMKvLTYopJz8TxQ4N6lmjS2VbdYZDqaP6M0mzwc -8E4biuW/6YptjLfoKZU73UqKPPvdh2qkll/nF/pMy8v6bf6Wg12b8pQAIrgaqu4/ -kopcba/2TftGy5/JUGVePif9+CUL95+UiUf9nvQr0KFL0+8k8L1DLs0wABKAPHXu -dFtfs1ofM5cC8pmVlJhoiIoHCWnIYOK2ea80Z2Xl/Y5ZtvAcluLW+0Ll+hsJ3pfy -80FH0UU7VsEJIOYrVCNx/JpXBH/AKQT0FcVzWU94FeSGb0vfihuL7nY= ------END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/crlIssuerAndSignCertHaveNoSharedRoot/sign.cert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/crlIssuerAndSignCertHaveNoSharedRoot/sign.cert.pem deleted file mode 100644 index 26c2432936..0000000000 --- a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/crlIssuerAndSignCertHaveNoSharedRoot/sign.cert.pem +++ /dev/null @@ -1,20 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDQjCCAiqgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwPTELMAkGA1UEBhMCQkUx -DjAMBgNVBAoMBWlUZXh0MR4wHAYDVQQDDBVpVGV4dFRlc3RJbnRlcm1lZGlhdGUw -IBcNMDAwMTAxMDAwMDAwWhgPMjQwMDAxMDEwMDAwMDBaMDUxCzAJBgNVBAYTAkJF -MQ4wDAYDVQQKDAVpVGV4dDEWMBQGA1UEAwwNaVRleHRUZXN0U2lnbjCCASIwDQYJ -KoZIhvcNAQEBBQADggEPADCCAQoCggEBAMaJ+B8HlKGXBhb64LuOiG/xGWn3RgU+ -D1i42xD4jRIjP3oL3hLefVtqQAgaP4HJa0mI1VWU2ezTbp5u11qo9eAefPq6jxaO -rbC3VyT/FE4EcoEvr48N/1ZB0jnKLQlO2lzzVCqnL9gyC+soakGwLzFs9SKjkI4h -/9YCnkoVtxOI/9ZDBf/QlJxrpknOPS9RQ8Y0OK+2OIb0kvK0f28EcvfopAnvOaVb -AHIWypIDabuRcw/YXRbmxvj2c+t1dGC7f4CLv7YKiFsEpydUJDWRUYGLnE7GvO9d -mS3oEFaI+Kre4HjSsaCF/Rgp9fpHKgaFTr8rKOGVgQHPlRFOrtGqXV8CAwEAAaNS -MFAwHQYDVR0OBBYEFKwAjNPp8T/Q6cWJGYu9aMR/ujVCMB8GA1UdIwQYMBaAFKek -g+UBOOgzMM6Ft6zCMa6k6H89MA4GA1UdDwEB/wQEAwIGwDANBgkqhkiG9w0BAQsF -AAOCAQEARWKct75OvbvIGRpTN4lvqyPJS/ZoVa/Dddbdo2rD669qltAce3/DFY2R -W0CNwIAxBh4CHqdlG5Od1qQ+BJH2pNGB6F2W/kmQuzaoo2PecDXNOfigRJASZO9O -nSFh+tQc+9DTNWrYyBb1MUEgZd4z0Q98dX3mWJ3YMG5Fb0pbexgpiAX5s9T3X+Da -olCzzmIRVIbce3UWv6T3fGvRJ/tyJ0VqvR8YBbVW15KaPabyZDE+v7QFizmoRFdw -7Dfv2tKIA/8ENO13BztYq1USTYhirfrR5Ki2oiul1Nmg48JgQRMHgfeBKMl9auyR -B6hPOeazdx/aJXMcZVIkYoWOPQsqVg== ------END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/crlIssuerRevokedBeforeSigningDate/ca.cert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/crlIssuerRevokedBeforeSigningDate/ca.cert.pem deleted file mode 100644 index 607e8e4816..0000000000 --- a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/crlIssuerRevokedBeforeSigningDate/ca.cert.pem +++ /dev/null @@ -1,20 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDSzCCAjOgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwNTELMAkGA1UEBhMCQkUx -DjAMBgNVBAoMBWlUZXh0MRYwFAYDVQQDDA1pVGV4dFRlc3RSb290MCAXDTAwMDEw -MTAwMDAwMFoYDzI1MDAwMTAxMDAwMDAwWjA1MQswCQYDVQQGEwJCRTEOMAwGA1UE -CgwFaVRleHQxFjAUBgNVBAMMDWlUZXh0VGVzdFJvb3QwggEiMA0GCSqGSIb3DQEB -AQUAA4IBDwAwggEKAoIBAQDP6KUmxQzeXKuwodaQZ7IUoidvDeXWrjW7BNYmKhey -DX9SIeIwvuiKDVUD85pWyk6jhNUvQaYvGVOv/Pbu4NJHv9FKch2d9759ckMT+MXG -fGk/B6Ww1rlKsiHccWizQxah7R79eGweEvryPIx+hqxreCBH4yzMPjHld1C34/vC -nUGmozKT4KENiT6lXXiBm4D+u3siCPt1Gzxavvm2MUBTHBbhQ3/n1eS/FcqT4NhI -vXDpPiNouD9goI+4LwCW7b52dg7dXreQY/IfGCcHTcu7YK/OEW4Pqjpr13B5mEDS -DsCqrStoh8EQ+jB62n2Xv8TT4lQju/sZh0l65IiT8fUfAgMBAAGjYzBhMB0GA1Ud -DgQWBBRkxUEzwLkf0rdu5Txco5JSsf8WCzAfBgNVHSMEGDAWgBRkxUEzwLkf0rdu -5Txco5JSsf8WCzAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIC5DANBgkq -hkiG9w0BAQsFAAOCAQEARJOOUQkv9AgqElJmQjGDkRdJPxkDHZtRLGOk9p0E1KbL -lqQQdgzL7RuE4vfCROan6aBZmXFRviIPg/Gxw2hDSIv1NUZv3AIgM2b9+3y+4SQ6 -2a/sqh1JPLxwnLN+Mo5KwY/E/YlJ0N7rw3AONrLlqH89BRrBIiPjrg74zi6qPzGn -WB2awHsbl7AOtkD2dEud7lbyLda/hCw2RGPSBQMm50pWsuInWXzdtX/Ii9yTGMyD -kavUHX6DDVouZBSKOjmChP0fGPM17ORJNR92RbT2ygy+F0Zokh5XUgrKPr4/JTW5 -iIkycpjAXY9UEMfi8pFnnzVSRj65kkZvZZJzybelMQ== ------END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/crlIssuerRevokedBeforeSigningDate/chain.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/crlIssuerRevokedBeforeSigningDate/chain.pem deleted file mode 100644 index cab4cb8209..0000000000 --- a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/crlIssuerRevokedBeforeSigningDate/chain.pem +++ /dev/null @@ -1,81 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDSzCCAjOgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwNTELMAkGA1UEBhMCQkUx -DjAMBgNVBAoMBWlUZXh0MRYwFAYDVQQDDA1pVGV4dFRlc3RSb290MCAXDTAwMDEw -MTAwMDAwMFoYDzI1MDAwMTAxMDAwMDAwWjA1MQswCQYDVQQGEwJCRTEOMAwGA1UE -CgwFaVRleHQxFjAUBgNVBAMMDWlUZXh0VGVzdFJvb3QwggEiMA0GCSqGSIb3DQEB -AQUAA4IBDwAwggEKAoIBAQDP6KUmxQzeXKuwodaQZ7IUoidvDeXWrjW7BNYmKhey -DX9SIeIwvuiKDVUD85pWyk6jhNUvQaYvGVOv/Pbu4NJHv9FKch2d9759ckMT+MXG -fGk/B6Ww1rlKsiHccWizQxah7R79eGweEvryPIx+hqxreCBH4yzMPjHld1C34/vC -nUGmozKT4KENiT6lXXiBm4D+u3siCPt1Gzxavvm2MUBTHBbhQ3/n1eS/FcqT4NhI -vXDpPiNouD9goI+4LwCW7b52dg7dXreQY/IfGCcHTcu7YK/OEW4Pqjpr13B5mEDS -DsCqrStoh8EQ+jB62n2Xv8TT4lQju/sZh0l65IiT8fUfAgMBAAGjYzBhMB0GA1Ud -DgQWBBRkxUEzwLkf0rdu5Txco5JSsf8WCzAfBgNVHSMEGDAWgBRkxUEzwLkf0rdu -5Txco5JSsf8WCzAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIC5DANBgkq -hkiG9w0BAQsFAAOCAQEARJOOUQkv9AgqElJmQjGDkRdJPxkDHZtRLGOk9p0E1KbL -lqQQdgzL7RuE4vfCROan6aBZmXFRviIPg/Gxw2hDSIv1NUZv3AIgM2b9+3y+4SQ6 -2a/sqh1JPLxwnLN+Mo5KwY/E/YlJ0N7rw3AONrLlqH89BRrBIiPjrg74zi6qPzGn -WB2awHsbl7AOtkD2dEud7lbyLda/hCw2RGPSBQMm50pWsuInWXzdtX/Ii9yTGMyD -kavUHX6DDVouZBSKOjmChP0fGPM17ORJNR92RbT2ygy+F0Zokh5XUgrKPr4/JTW5 -iIkycpjAXY9UEMfi8pFnnzVSRj65kkZvZZJzybelMQ== ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIDiTCCAnGgAwIBAgICEAIwDQYJKoZIhvcNAQELBQAwNTELMAkGA1UEBhMCQkUx -DjAMBgNVBAoMBWlUZXh0MRYwFAYDVQQDDA1pVGV4dFRlc3RSb290MCAXDTAwMDEw -MTAwMDAwMFoYDzI0NTAwMTAxMDAwMDAwWjA6MQswCQYDVQQGEwJCRTEOMAwGA1UE -CgwFaVRleHQxGzAZBgNVBAMMEmlUZXh0VGVzdENybElzc3VlcjCCASIwDQYJKoZI -hvcNAQEBBQADggEPADCCAQoCggEBAJV6eBrtpxfCCiAkgz3wdLUqRio0/TBHDHg5 -oU1lHNeKoNkEG/kwdgPFN4YN9qufVZBi5mRY54NaVySKHo2w7/CrscZhbXtrBIQY -WzR0vRptsbmqV2xfBlqtPyPlRMt2SRnwe3Q4XqZSnX13bUTLO0SBlddGt7h/HQfD -vSzbekJWd8bPt+cH5Ke3y0cdFNylwP5yXEZdDyU9CtkzaBpHFM8vAEO00/kqahap -8Ox+Tea7zrAfoT58juJdGOlt7DRJs6jsLXsDT04zk47cpZ904R29lzU1zoMoiEjf -UTDO0c5fj4q4RCYzSpT3jX5VJEfKlooP6TX/GDVtH58+A3YQXuMCAwEAAaOBmzCB -mDAdBgNVHQ4EFgQU0zydGfhFz0j/TGolSJNUJEx9j2UwHwYDVR0jBBgwFoAUZMVB -M8C5H9K3buU8XKOSUrH/FgswDgYDVR0PAQH/BAQDAgHCMEYGA1UdHwQ/MD0wO6A5 -oDeGNWh0dHA6Ly9sb2NhbGhvc3QudGVzdC9kZWZhdWx0L2NybHMvZGVmYXVsdC9s -YXRlc3QuY3JsMA0GCSqGSIb3DQEBCwUAA4IBAQC21PZDRIiPsN/mNQYZYxrpLksz -XYEgl0ZWJzv5noTRmcDY4ZCqR+eOm2BT86QPTNAhjM8CxBMd0Y23vayojh8UYihO -EmLrBJI/DsiWABgBXOvKWyI0EWXciOamVhSprmrgE2ff8Q9v1ZeraukPZwT03lL9 -obaQOa2aUsUMuPyZn46fDZq2j1O+V9M1K7OEtv/+exK9YZdi5mDZwgvOMp0pSRk6 -8Un/564/WsmRrRFaNw+dd0JxQrO08EAM7mOzFmbzCxfeUEKT+KF4qt5JWP/gOPSY -TDgbYqv5t1Co4woZCS2nVwKaJi0KhqEhOdFvPv12yGBoDvlDceAx8TSIl+Ym ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIDQjCCAiqgAwIBAgICEAEwDQYJKoZIhvcNAQELBQAwNTELMAkGA1UEBhMCQkUx -DjAMBgNVBAoMBWlUZXh0MRYwFAYDVQQDDA1pVGV4dFRlc3RSb290MCAXDTAwMDEw -MTAwMDAwMFoYDzI0NTAwMTAxMDAwMDAwWjA9MQswCQYDVQQGEwJCRTEOMAwGA1UE -CgwFaVRleHQxHjAcBgNVBAMMFWlUZXh0VGVzdEludGVybWVkaWF0ZTCCASIwDQYJ -KoZIhvcNAQEBBQADggEPADCCAQoCggEBAM3t0dlZupS+5Z0EGHsnruz2ZRoVKwbp -IXwuOGuetobCTaaTfAyXmgXqcH1ZPi0u1dSzkWbHOdBNhRQLlk3ZtTfnCQrtijjU -U6jqkiMoMhap1/jEQPoU6CHP3bbwkSdZrnNriVxyGp2IKGwNDlg9fOBGuXdNei8N -fP5q9daV3oC9ckverNNKpcn9/0wYchISH9Y0a8N6FFUBqEYnjsEee7a5VIfgsP70 -jrhk53pNQJSObJhAFzhsbFNXxmWkZpi/YUJaBCSQYwQCUToRINyUMZOtsUIBh4es -8EpBt2utPkVifZvBo+prKUPTYX64iKko7zY5WHyP6vIV5BihYYv3Em8CAwEAAaNS -MFAwHQYDVR0OBBYEFKekg+UBOOgzMM6Ft6zCMa6k6H89MB8GA1UdIwQYMBaAFGTF -QTPAuR/St27lPFyjklKx/xYLMA4GA1UdDwEB/wQEAwIB5jANBgkqhkiG9w0BAQsF -AAOCAQEAadrnESocLAKEhOVcKC1tGOlDEI3oYkODcT4E3AOBqBq+gy4s5hfrQEpC -HqCje0pGNY1xgdcG5OPaKNSMT7+/PLE5As7aktNQxWuhDSH0SwKQPBbG+pfs0m3J -1R6M0WKsqvLWUtUgkzQp2f9pqu/XBrjqJnI5RwtNBBXJV8QBhLf4z/kGIk4noDM7 -2PcXdGNfl6dINcX8q3meZ1DkWTypgZ1pcEcvHU0rUPo+UPUpg6pOruOVnCERRiSx -z97Gqp1ZDa/jH1a+tjmbq4EN1vbULzVw+xsBIMuT7lsPTLdy/AHIx2UXVMGhHoYV -BHO096jz11DkzNKHloHf5sKPK2Ecjg== ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIDQjCCAiqgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwPTELMAkGA1UEBhMCQkUx -DjAMBgNVBAoMBWlUZXh0MR4wHAYDVQQDDBVpVGV4dFRlc3RJbnRlcm1lZGlhdGUw -IBcNMDAwMTAxMDAwMDAwWhgPMjQwMDAxMDEwMDAwMDBaMDUxCzAJBgNVBAYTAkJF -MQ4wDAYDVQQKDAVpVGV4dDEWMBQGA1UEAwwNaVRleHRUZXN0U2lnbjCCASIwDQYJ -KoZIhvcNAQEBBQADggEPADCCAQoCggEBAMaJ+B8HlKGXBhb64LuOiG/xGWn3RgU+ -D1i42xD4jRIjP3oL3hLefVtqQAgaP4HJa0mI1VWU2ezTbp5u11qo9eAefPq6jxaO -rbC3VyT/FE4EcoEvr48N/1ZB0jnKLQlO2lzzVCqnL9gyC+soakGwLzFs9SKjkI4h -/9YCnkoVtxOI/9ZDBf/QlJxrpknOPS9RQ8Y0OK+2OIb0kvK0f28EcvfopAnvOaVb -AHIWypIDabuRcw/YXRbmxvj2c+t1dGC7f4CLv7YKiFsEpydUJDWRUYGLnE7GvO9d -mS3oEFaI+Kre4HjSsaCF/Rgp9fpHKgaFTr8rKOGVgQHPlRFOrtGqXV8CAwEAAaNS -MFAwHQYDVR0OBBYEFKwAjNPp8T/Q6cWJGYu9aMR/ujVCMB8GA1UdIwQYMBaAFKek -g+UBOOgzMM6Ft6zCMa6k6H89MA4GA1UdDwEB/wQEAwIGwDANBgkqhkiG9w0BAQsF -AAOCAQEARWKct75OvbvIGRpTN4lvqyPJS/ZoVa/Dddbdo2rD669qltAce3/DFY2R -W0CNwIAxBh4CHqdlG5Od1qQ+BJH2pNGB6F2W/kmQuzaoo2PecDXNOfigRJASZO9O -nSFh+tQc+9DTNWrYyBb1MUEgZd4z0Q98dX3mWJ3YMG5Fb0pbexgpiAX5s9T3X+Da -olCzzmIRVIbce3UWv6T3fGvRJ/tyJ0VqvR8YBbVW15KaPabyZDE+v7QFizmoRFdw -7Dfv2tKIA/8ENO13BztYq1USTYhirfrR5Ki2oiul1Nmg48JgQRMHgfeBKMl9auyR -B6hPOeazdx/aJXMcZVIkYoWOPQsqVg== ------END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/crlIssuerRevokedBeforeSigningDate/crl-issuer.cert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/crlIssuerRevokedBeforeSigningDate/crl-issuer.cert.pem deleted file mode 100644 index 6236fcbf96..0000000000 --- a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/crlIssuerRevokedBeforeSigningDate/crl-issuer.cert.pem +++ /dev/null @@ -1,21 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDiTCCAnGgAwIBAgICEAIwDQYJKoZIhvcNAQELBQAwNTELMAkGA1UEBhMCQkUx -DjAMBgNVBAoMBWlUZXh0MRYwFAYDVQQDDA1pVGV4dFRlc3RSb290MCAXDTAwMDEw -MTAwMDAwMFoYDzI0NTAwMTAxMDAwMDAwWjA6MQswCQYDVQQGEwJCRTEOMAwGA1UE -CgwFaVRleHQxGzAZBgNVBAMMEmlUZXh0VGVzdENybElzc3VlcjCCASIwDQYJKoZI -hvcNAQEBBQADggEPADCCAQoCggEBAJV6eBrtpxfCCiAkgz3wdLUqRio0/TBHDHg5 -oU1lHNeKoNkEG/kwdgPFN4YN9qufVZBi5mRY54NaVySKHo2w7/CrscZhbXtrBIQY -WzR0vRptsbmqV2xfBlqtPyPlRMt2SRnwe3Q4XqZSnX13bUTLO0SBlddGt7h/HQfD -vSzbekJWd8bPt+cH5Ke3y0cdFNylwP5yXEZdDyU9CtkzaBpHFM8vAEO00/kqahap -8Ox+Tea7zrAfoT58juJdGOlt7DRJs6jsLXsDT04zk47cpZ904R29lzU1zoMoiEjf -UTDO0c5fj4q4RCYzSpT3jX5VJEfKlooP6TX/GDVtH58+A3YQXuMCAwEAAaOBmzCB -mDAdBgNVHQ4EFgQU0zydGfhFz0j/TGolSJNUJEx9j2UwHwYDVR0jBBgwFoAUZMVB -M8C5H9K3buU8XKOSUrH/FgswDgYDVR0PAQH/BAQDAgHCMEYGA1UdHwQ/MD0wO6A5 -oDeGNWh0dHA6Ly9sb2NhbGhvc3QudGVzdC9kZWZhdWx0L2NybHMvZGVmYXVsdC9s -YXRlc3QuY3JsMA0GCSqGSIb3DQEBCwUAA4IBAQC21PZDRIiPsN/mNQYZYxrpLksz -XYEgl0ZWJzv5noTRmcDY4ZCqR+eOm2BT86QPTNAhjM8CxBMd0Y23vayojh8UYihO -EmLrBJI/DsiWABgBXOvKWyI0EWXciOamVhSprmrgE2ff8Q9v1ZeraukPZwT03lL9 -obaQOa2aUsUMuPyZn46fDZq2j1O+V9M1K7OEtv/+exK9YZdi5mDZwgvOMp0pSRk6 -8Un/564/WsmRrRFaNw+dd0JxQrO08EAM7mOzFmbzCxfeUEKT+KF4qt5JWP/gOPSY -TDgbYqv5t1Co4woZCS2nVwKaJi0KhqEhOdFvPv12yGBoDvlDceAx8TSIl+Ym ------END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/crlIssuerRevokedBeforeSigningDate/intermediate.cert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/crlIssuerRevokedBeforeSigningDate/intermediate.cert.pem deleted file mode 100644 index 420f53b153..0000000000 --- a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/crlIssuerRevokedBeforeSigningDate/intermediate.cert.pem +++ /dev/null @@ -1,20 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDQjCCAiqgAwIBAgICEAEwDQYJKoZIhvcNAQELBQAwNTELMAkGA1UEBhMCQkUx -DjAMBgNVBAoMBWlUZXh0MRYwFAYDVQQDDA1pVGV4dFRlc3RSb290MCAXDTAwMDEw -MTAwMDAwMFoYDzI0NTAwMTAxMDAwMDAwWjA9MQswCQYDVQQGEwJCRTEOMAwGA1UE -CgwFaVRleHQxHjAcBgNVBAMMFWlUZXh0VGVzdEludGVybWVkaWF0ZTCCASIwDQYJ -KoZIhvcNAQEBBQADggEPADCCAQoCggEBAM3t0dlZupS+5Z0EGHsnruz2ZRoVKwbp -IXwuOGuetobCTaaTfAyXmgXqcH1ZPi0u1dSzkWbHOdBNhRQLlk3ZtTfnCQrtijjU -U6jqkiMoMhap1/jEQPoU6CHP3bbwkSdZrnNriVxyGp2IKGwNDlg9fOBGuXdNei8N -fP5q9daV3oC9ckverNNKpcn9/0wYchISH9Y0a8N6FFUBqEYnjsEee7a5VIfgsP70 -jrhk53pNQJSObJhAFzhsbFNXxmWkZpi/YUJaBCSQYwQCUToRINyUMZOtsUIBh4es -8EpBt2utPkVifZvBo+prKUPTYX64iKko7zY5WHyP6vIV5BihYYv3Em8CAwEAAaNS -MFAwHQYDVR0OBBYEFKekg+UBOOgzMM6Ft6zCMa6k6H89MB8GA1UdIwQYMBaAFGTF -QTPAuR/St27lPFyjklKx/xYLMA4GA1UdDwEB/wQEAwIB5jANBgkqhkiG9w0BAQsF -AAOCAQEAadrnESocLAKEhOVcKC1tGOlDEI3oYkODcT4E3AOBqBq+gy4s5hfrQEpC -HqCje0pGNY1xgdcG5OPaKNSMT7+/PLE5As7aktNQxWuhDSH0SwKQPBbG+pfs0m3J -1R6M0WKsqvLWUtUgkzQp2f9pqu/XBrjqJnI5RwtNBBXJV8QBhLf4z/kGIk4noDM7 -2PcXdGNfl6dINcX8q3meZ1DkWTypgZ1pcEcvHU0rUPo+UPUpg6pOruOVnCERRiSx -z97Gqp1ZDa/jH1a+tjmbq4EN1vbULzVw+xsBIMuT7lsPTLdy/AHIx2UXVMGhHoYV -BHO096jz11DkzNKHloHf5sKPK2Ecjg== ------END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/crlIssuerRevokedBeforeSigningDate/sign.cert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/crlIssuerRevokedBeforeSigningDate/sign.cert.pem deleted file mode 100644 index 26c2432936..0000000000 --- a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/crlIssuerRevokedBeforeSigningDate/sign.cert.pem +++ /dev/null @@ -1,20 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDQjCCAiqgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwPTELMAkGA1UEBhMCQkUx -DjAMBgNVBAoMBWlUZXh0MR4wHAYDVQQDDBVpVGV4dFRlc3RJbnRlcm1lZGlhdGUw -IBcNMDAwMTAxMDAwMDAwWhgPMjQwMDAxMDEwMDAwMDBaMDUxCzAJBgNVBAYTAkJF -MQ4wDAYDVQQKDAVpVGV4dDEWMBQGA1UEAwwNaVRleHRUZXN0U2lnbjCCASIwDQYJ -KoZIhvcNAQEBBQADggEPADCCAQoCggEBAMaJ+B8HlKGXBhb64LuOiG/xGWn3RgU+ -D1i42xD4jRIjP3oL3hLefVtqQAgaP4HJa0mI1VWU2ezTbp5u11qo9eAefPq6jxaO -rbC3VyT/FE4EcoEvr48N/1ZB0jnKLQlO2lzzVCqnL9gyC+soakGwLzFs9SKjkI4h -/9YCnkoVtxOI/9ZDBf/QlJxrpknOPS9RQ8Y0OK+2OIb0kvK0f28EcvfopAnvOaVb -AHIWypIDabuRcw/YXRbmxvj2c+t1dGC7f4CLv7YKiFsEpydUJDWRUYGLnE7GvO9d -mS3oEFaI+Kre4HjSsaCF/Rgp9fpHKgaFTr8rKOGVgQHPlRFOrtGqXV8CAwEAAaNS -MFAwHQYDVR0OBBYEFKwAjNPp8T/Q6cWJGYu9aMR/ujVCMB8GA1UdIwQYMBaAFKek -g+UBOOgzMM6Ft6zCMa6k6H89MA4GA1UdDwEB/wQEAwIGwDANBgkqhkiG9w0BAQsF -AAOCAQEARWKct75OvbvIGRpTN4lvqyPJS/ZoVa/Dddbdo2rD669qltAce3/DFY2R -W0CNwIAxBh4CHqdlG5Od1qQ+BJH2pNGB6F2W/kmQuzaoo2PecDXNOfigRJASZO9O -nSFh+tQc+9DTNWrYyBb1MUEgZd4z0Q98dX3mWJ3YMG5Fb0pbexgpiAX5s9T3X+Da -olCzzmIRVIbce3UWv6T3fGvRJ/tyJ0VqvR8YBbVW15KaPabyZDE+v7QFizmoRFdw -7Dfv2tKIA/8ENO13BztYq1USTYhirfrR5Ki2oiul1Nmg48JgQRMHgfeBKMl9auyR -B6hPOeazdx/aJXMcZVIkYoWOPQsqVg== ------END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/happyPath/ca.cert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/happyPath/ca.cert.pem deleted file mode 100644 index 607e8e4816..0000000000 --- a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/happyPath/ca.cert.pem +++ /dev/null @@ -1,20 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDSzCCAjOgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwNTELMAkGA1UEBhMCQkUx -DjAMBgNVBAoMBWlUZXh0MRYwFAYDVQQDDA1pVGV4dFRlc3RSb290MCAXDTAwMDEw -MTAwMDAwMFoYDzI1MDAwMTAxMDAwMDAwWjA1MQswCQYDVQQGEwJCRTEOMAwGA1UE -CgwFaVRleHQxFjAUBgNVBAMMDWlUZXh0VGVzdFJvb3QwggEiMA0GCSqGSIb3DQEB -AQUAA4IBDwAwggEKAoIBAQDP6KUmxQzeXKuwodaQZ7IUoidvDeXWrjW7BNYmKhey -DX9SIeIwvuiKDVUD85pWyk6jhNUvQaYvGVOv/Pbu4NJHv9FKch2d9759ckMT+MXG -fGk/B6Ww1rlKsiHccWizQxah7R79eGweEvryPIx+hqxreCBH4yzMPjHld1C34/vC -nUGmozKT4KENiT6lXXiBm4D+u3siCPt1Gzxavvm2MUBTHBbhQ3/n1eS/FcqT4NhI -vXDpPiNouD9goI+4LwCW7b52dg7dXreQY/IfGCcHTcu7YK/OEW4Pqjpr13B5mEDS -DsCqrStoh8EQ+jB62n2Xv8TT4lQju/sZh0l65IiT8fUfAgMBAAGjYzBhMB0GA1Ud -DgQWBBRkxUEzwLkf0rdu5Txco5JSsf8WCzAfBgNVHSMEGDAWgBRkxUEzwLkf0rdu -5Txco5JSsf8WCzAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIC5DANBgkq -hkiG9w0BAQsFAAOCAQEARJOOUQkv9AgqElJmQjGDkRdJPxkDHZtRLGOk9p0E1KbL -lqQQdgzL7RuE4vfCROan6aBZmXFRviIPg/Gxw2hDSIv1NUZv3AIgM2b9+3y+4SQ6 -2a/sqh1JPLxwnLN+Mo5KwY/E/YlJ0N7rw3AONrLlqH89BRrBIiPjrg74zi6qPzGn -WB2awHsbl7AOtkD2dEud7lbyLda/hCw2RGPSBQMm50pWsuInWXzdtX/Ii9yTGMyD -kavUHX6DDVouZBSKOjmChP0fGPM17ORJNR92RbT2ygy+F0Zokh5XUgrKPr4/JTW5 -iIkycpjAXY9UEMfi8pFnnzVSRj65kkZvZZJzybelMQ== ------END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/happyPath/chain.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/happyPath/chain.pem deleted file mode 100644 index 2275b63aaa..0000000000 --- a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/happyPath/chain.pem +++ /dev/null @@ -1,81 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDSzCCAjOgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwNTELMAkGA1UEBhMCQkUx -DjAMBgNVBAoMBWlUZXh0MRYwFAYDVQQDDA1pVGV4dFRlc3RSb290MCAXDTAwMDEw -MTAwMDAwMFoYDzI1MDAwMTAxMDAwMDAwWjA1MQswCQYDVQQGEwJCRTEOMAwGA1UE -CgwFaVRleHQxFjAUBgNVBAMMDWlUZXh0VGVzdFJvb3QwggEiMA0GCSqGSIb3DQEB -AQUAA4IBDwAwggEKAoIBAQDP6KUmxQzeXKuwodaQZ7IUoidvDeXWrjW7BNYmKhey -DX9SIeIwvuiKDVUD85pWyk6jhNUvQaYvGVOv/Pbu4NJHv9FKch2d9759ckMT+MXG -fGk/B6Ww1rlKsiHccWizQxah7R79eGweEvryPIx+hqxreCBH4yzMPjHld1C34/vC -nUGmozKT4KENiT6lXXiBm4D+u3siCPt1Gzxavvm2MUBTHBbhQ3/n1eS/FcqT4NhI -vXDpPiNouD9goI+4LwCW7b52dg7dXreQY/IfGCcHTcu7YK/OEW4Pqjpr13B5mEDS -DsCqrStoh8EQ+jB62n2Xv8TT4lQju/sZh0l65IiT8fUfAgMBAAGjYzBhMB0GA1Ud -DgQWBBRkxUEzwLkf0rdu5Txco5JSsf8WCzAfBgNVHSMEGDAWgBRkxUEzwLkf0rdu -5Txco5JSsf8WCzAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIC5DANBgkq -hkiG9w0BAQsFAAOCAQEARJOOUQkv9AgqElJmQjGDkRdJPxkDHZtRLGOk9p0E1KbL -lqQQdgzL7RuE4vfCROan6aBZmXFRviIPg/Gxw2hDSIv1NUZv3AIgM2b9+3y+4SQ6 -2a/sqh1JPLxwnLN+Mo5KwY/E/YlJ0N7rw3AONrLlqH89BRrBIiPjrg74zi6qPzGn -WB2awHsbl7AOtkD2dEud7lbyLda/hCw2RGPSBQMm50pWsuInWXzdtX/Ii9yTGMyD -kavUHX6DDVouZBSKOjmChP0fGPM17ORJNR92RbT2ygy+F0Zokh5XUgrKPr4/JTW5 -iIkycpjAXY9UEMfi8pFnnzVSRj65kkZvZZJzybelMQ== ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIDhTCCAm2gAwIBAgICEAIwDQYJKoZIhvcNAQELBQAwNTELMAkGA1UEBhMCQkUx -DjAMBgNVBAoMBWlUZXh0MRYwFAYDVQQDDA1pVGV4dFRlc3RSb290MCAXDTAwMDEw -MTAwMDAwMFoYDzI0NTAwMTAxMDAwMDAwWjA6MQswCQYDVQQGEwJCRTEOMAwGA1UE -CgwFaVRleHQxGzAZBgNVBAMMEmlUZXh0VGVzdENybElzc3VlcjCCASIwDQYJKoZI -hvcNAQEBBQADggEPADCCAQoCggEBAJV6eBrtpxfCCiAkgz3wdLUqRio0/TBHDHg5 -oU1lHNeKoNkEG/kwdgPFN4YN9qufVZBi5mRY54NaVySKHo2w7/CrscZhbXtrBIQY -WzR0vRptsbmqV2xfBlqtPyPlRMt2SRnwe3Q4XqZSnX13bUTLO0SBlddGt7h/HQfD -vSzbekJWd8bPt+cH5Ke3y0cdFNylwP5yXEZdDyU9CtkzaBpHFM8vAEO00/kqahap -8Ox+Tea7zrAfoT58juJdGOlt7DRJs6jsLXsDT04zk47cpZ904R29lzU1zoMoiEjf -UTDO0c5fj4q4RCYzSpT3jX5VJEfKlooP6TX/GDVtH58+A3YQXuMCAwEAAaOBlzCB -lDAdBgNVHQ4EFgQU0zydGfhFz0j/TGolSJNUJEx9j2UwHwYDVR0jBBgwFoAUZMVB -M8C5H9K3buU8XKOSUrH/FgswDgYDVR0PAQH/BAQDAgHCMEIGA1UdHwQ7MDkwN6A1 -oDOGMWh0dHA6Ly9sb2NhbGhvc3QudGVzdC9kZWZhdWx0L2NybHMvY3JsL2xhdGVz -dC5jcmwwDQYJKoZIhvcNAQELBQADggEBALybI7Erkso0mOvu9ZVU2jzfE+aSZd9m -cCIQyytQtv8xi6Q4BfsEc/QLvLViybqkBvmrME/kFqVrFeEONgTy0LUO+OOZl1yZ -d/SWk81YVL3PJ2txHpehfHF5wlorDnZ5d/pn0sXu+tg55dmXQDniiZEHJxKQUEW2 -bYnC4qXhx0AXhpuTe6QbBZEY5DVNUVnenjtaixtlKqxA5hbTxkMiNol6A3wcTAgS -7yn8Bv5EzJobSI9rKoQuKMvnlj1FRX/0zr6hONAF6EOUjGG82GA2Aw4CrT4wOixL -s+fOY2SRtpZRMqD2hOF0t3kVKUDQx5HH87xc2ruGUM/rPLOYksnD7IQ= ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIDQjCCAiqgAwIBAgICEAEwDQYJKoZIhvcNAQELBQAwNTELMAkGA1UEBhMCQkUx -DjAMBgNVBAoMBWlUZXh0MRYwFAYDVQQDDA1pVGV4dFRlc3RSb290MCAXDTAwMDEw -MTAwMDAwMFoYDzI0NTAwMTAxMDAwMDAwWjA9MQswCQYDVQQGEwJCRTEOMAwGA1UE -CgwFaVRleHQxHjAcBgNVBAMMFWlUZXh0VGVzdEludGVybWVkaWF0ZTCCASIwDQYJ -KoZIhvcNAQEBBQADggEPADCCAQoCggEBAM3t0dlZupS+5Z0EGHsnruz2ZRoVKwbp -IXwuOGuetobCTaaTfAyXmgXqcH1ZPi0u1dSzkWbHOdBNhRQLlk3ZtTfnCQrtijjU -U6jqkiMoMhap1/jEQPoU6CHP3bbwkSdZrnNriVxyGp2IKGwNDlg9fOBGuXdNei8N -fP5q9daV3oC9ckverNNKpcn9/0wYchISH9Y0a8N6FFUBqEYnjsEee7a5VIfgsP70 -jrhk53pNQJSObJhAFzhsbFNXxmWkZpi/YUJaBCSQYwQCUToRINyUMZOtsUIBh4es -8EpBt2utPkVifZvBo+prKUPTYX64iKko7zY5WHyP6vIV5BihYYv3Em8CAwEAAaNS -MFAwHQYDVR0OBBYEFKekg+UBOOgzMM6Ft6zCMa6k6H89MB8GA1UdIwQYMBaAFGTF -QTPAuR/St27lPFyjklKx/xYLMA4GA1UdDwEB/wQEAwIB5jANBgkqhkiG9w0BAQsF -AAOCAQEAadrnESocLAKEhOVcKC1tGOlDEI3oYkODcT4E3AOBqBq+gy4s5hfrQEpC -HqCje0pGNY1xgdcG5OPaKNSMT7+/PLE5As7aktNQxWuhDSH0SwKQPBbG+pfs0m3J -1R6M0WKsqvLWUtUgkzQp2f9pqu/XBrjqJnI5RwtNBBXJV8QBhLf4z/kGIk4noDM7 -2PcXdGNfl6dINcX8q3meZ1DkWTypgZ1pcEcvHU0rUPo+UPUpg6pOruOVnCERRiSx -z97Gqp1ZDa/jH1a+tjmbq4EN1vbULzVw+xsBIMuT7lsPTLdy/AHIx2UXVMGhHoYV -BHO096jz11DkzNKHloHf5sKPK2Ecjg== ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIDQjCCAiqgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwPTELMAkGA1UEBhMCQkUx -DjAMBgNVBAoMBWlUZXh0MR4wHAYDVQQDDBVpVGV4dFRlc3RJbnRlcm1lZGlhdGUw -IBcNMDAwMTAxMDAwMDAwWhgPMjQwMDAxMDEwMDAwMDBaMDUxCzAJBgNVBAYTAkJF -MQ4wDAYDVQQKDAVpVGV4dDEWMBQGA1UEAwwNaVRleHRUZXN0U2lnbjCCASIwDQYJ -KoZIhvcNAQEBBQADggEPADCCAQoCggEBAMaJ+B8HlKGXBhb64LuOiG/xGWn3RgU+ -D1i42xD4jRIjP3oL3hLefVtqQAgaP4HJa0mI1VWU2ezTbp5u11qo9eAefPq6jxaO -rbC3VyT/FE4EcoEvr48N/1ZB0jnKLQlO2lzzVCqnL9gyC+soakGwLzFs9SKjkI4h -/9YCnkoVtxOI/9ZDBf/QlJxrpknOPS9RQ8Y0OK+2OIb0kvK0f28EcvfopAnvOaVb -AHIWypIDabuRcw/YXRbmxvj2c+t1dGC7f4CLv7YKiFsEpydUJDWRUYGLnE7GvO9d -mS3oEFaI+Kre4HjSsaCF/Rgp9fpHKgaFTr8rKOGVgQHPlRFOrtGqXV8CAwEAAaNS -MFAwHQYDVR0OBBYEFKwAjNPp8T/Q6cWJGYu9aMR/ujVCMB8GA1UdIwQYMBaAFKek -g+UBOOgzMM6Ft6zCMa6k6H89MA4GA1UdDwEB/wQEAwIGwDANBgkqhkiG9w0BAQsF -AAOCAQEARWKct75OvbvIGRpTN4lvqyPJS/ZoVa/Dddbdo2rD669qltAce3/DFY2R -W0CNwIAxBh4CHqdlG5Od1qQ+BJH2pNGB6F2W/kmQuzaoo2PecDXNOfigRJASZO9O -nSFh+tQc+9DTNWrYyBb1MUEgZd4z0Q98dX3mWJ3YMG5Fb0pbexgpiAX5s9T3X+Da -olCzzmIRVIbce3UWv6T3fGvRJ/tyJ0VqvR8YBbVW15KaPabyZDE+v7QFizmoRFdw -7Dfv2tKIA/8ENO13BztYq1USTYhirfrR5Ki2oiul1Nmg48JgQRMHgfeBKMl9auyR -B6hPOeazdx/aJXMcZVIkYoWOPQsqVg== ------END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/happyPath/crl-issuer.cert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/happyPath/crl-issuer.cert.pem deleted file mode 100644 index 030a6784df..0000000000 --- a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/happyPath/crl-issuer.cert.pem +++ /dev/null @@ -1,21 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDhTCCAm2gAwIBAgICEAIwDQYJKoZIhvcNAQELBQAwNTELMAkGA1UEBhMCQkUx -DjAMBgNVBAoMBWlUZXh0MRYwFAYDVQQDDA1pVGV4dFRlc3RSb290MCAXDTAwMDEw -MTAwMDAwMFoYDzI0NTAwMTAxMDAwMDAwWjA6MQswCQYDVQQGEwJCRTEOMAwGA1UE -CgwFaVRleHQxGzAZBgNVBAMMEmlUZXh0VGVzdENybElzc3VlcjCCASIwDQYJKoZI -hvcNAQEBBQADggEPADCCAQoCggEBAJV6eBrtpxfCCiAkgz3wdLUqRio0/TBHDHg5 -oU1lHNeKoNkEG/kwdgPFN4YN9qufVZBi5mRY54NaVySKHo2w7/CrscZhbXtrBIQY -WzR0vRptsbmqV2xfBlqtPyPlRMt2SRnwe3Q4XqZSnX13bUTLO0SBlddGt7h/HQfD -vSzbekJWd8bPt+cH5Ke3y0cdFNylwP5yXEZdDyU9CtkzaBpHFM8vAEO00/kqahap -8Ox+Tea7zrAfoT58juJdGOlt7DRJs6jsLXsDT04zk47cpZ904R29lzU1zoMoiEjf -UTDO0c5fj4q4RCYzSpT3jX5VJEfKlooP6TX/GDVtH58+A3YQXuMCAwEAAaOBlzCB -lDAdBgNVHQ4EFgQU0zydGfhFz0j/TGolSJNUJEx9j2UwHwYDVR0jBBgwFoAUZMVB -M8C5H9K3buU8XKOSUrH/FgswDgYDVR0PAQH/BAQDAgHCMEIGA1UdHwQ7MDkwN6A1 -oDOGMWh0dHA6Ly9sb2NhbGhvc3QudGVzdC9kZWZhdWx0L2NybHMvY3JsL2xhdGVz -dC5jcmwwDQYJKoZIhvcNAQELBQADggEBALybI7Erkso0mOvu9ZVU2jzfE+aSZd9m -cCIQyytQtv8xi6Q4BfsEc/QLvLViybqkBvmrME/kFqVrFeEONgTy0LUO+OOZl1yZ -d/SWk81YVL3PJ2txHpehfHF5wlorDnZ5d/pn0sXu+tg55dmXQDniiZEHJxKQUEW2 -bYnC4qXhx0AXhpuTe6QbBZEY5DVNUVnenjtaixtlKqxA5hbTxkMiNol6A3wcTAgS -7yn8Bv5EzJobSI9rKoQuKMvnlj1FRX/0zr6hONAF6EOUjGG82GA2Aw4CrT4wOixL -s+fOY2SRtpZRMqD2hOF0t3kVKUDQx5HH87xc2ruGUM/rPLOYksnD7IQ= ------END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/happyPath/intermediate.cert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/happyPath/intermediate.cert.pem deleted file mode 100644 index 420f53b153..0000000000 --- a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/happyPath/intermediate.cert.pem +++ /dev/null @@ -1,20 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDQjCCAiqgAwIBAgICEAEwDQYJKoZIhvcNAQELBQAwNTELMAkGA1UEBhMCQkUx -DjAMBgNVBAoMBWlUZXh0MRYwFAYDVQQDDA1pVGV4dFRlc3RSb290MCAXDTAwMDEw -MTAwMDAwMFoYDzI0NTAwMTAxMDAwMDAwWjA9MQswCQYDVQQGEwJCRTEOMAwGA1UE -CgwFaVRleHQxHjAcBgNVBAMMFWlUZXh0VGVzdEludGVybWVkaWF0ZTCCASIwDQYJ -KoZIhvcNAQEBBQADggEPADCCAQoCggEBAM3t0dlZupS+5Z0EGHsnruz2ZRoVKwbp -IXwuOGuetobCTaaTfAyXmgXqcH1ZPi0u1dSzkWbHOdBNhRQLlk3ZtTfnCQrtijjU -U6jqkiMoMhap1/jEQPoU6CHP3bbwkSdZrnNriVxyGp2IKGwNDlg9fOBGuXdNei8N -fP5q9daV3oC9ckverNNKpcn9/0wYchISH9Y0a8N6FFUBqEYnjsEee7a5VIfgsP70 -jrhk53pNQJSObJhAFzhsbFNXxmWkZpi/YUJaBCSQYwQCUToRINyUMZOtsUIBh4es -8EpBt2utPkVifZvBo+prKUPTYX64iKko7zY5WHyP6vIV5BihYYv3Em8CAwEAAaNS -MFAwHQYDVR0OBBYEFKekg+UBOOgzMM6Ft6zCMa6k6H89MB8GA1UdIwQYMBaAFGTF -QTPAuR/St27lPFyjklKx/xYLMA4GA1UdDwEB/wQEAwIB5jANBgkqhkiG9w0BAQsF -AAOCAQEAadrnESocLAKEhOVcKC1tGOlDEI3oYkODcT4E3AOBqBq+gy4s5hfrQEpC -HqCje0pGNY1xgdcG5OPaKNSMT7+/PLE5As7aktNQxWuhDSH0SwKQPBbG+pfs0m3J -1R6M0WKsqvLWUtUgkzQp2f9pqu/XBrjqJnI5RwtNBBXJV8QBhLf4z/kGIk4noDM7 -2PcXdGNfl6dINcX8q3meZ1DkWTypgZ1pcEcvHU0rUPo+UPUpg6pOruOVnCERRiSx -z97Gqp1ZDa/jH1a+tjmbq4EN1vbULzVw+xsBIMuT7lsPTLdy/AHIx2UXVMGhHoYV -BHO096jz11DkzNKHloHf5sKPK2Ecjg== ------END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/happyPath/sign.cert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/happyPath/sign.cert.pem deleted file mode 100644 index 26c2432936..0000000000 --- a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/happyPath/sign.cert.pem +++ /dev/null @@ -1,20 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDQjCCAiqgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwPTELMAkGA1UEBhMCQkUx -DjAMBgNVBAoMBWlUZXh0MR4wHAYDVQQDDBVpVGV4dFRlc3RJbnRlcm1lZGlhdGUw -IBcNMDAwMTAxMDAwMDAwWhgPMjQwMDAxMDEwMDAwMDBaMDUxCzAJBgNVBAYTAkJF -MQ4wDAYDVQQKDAVpVGV4dDEWMBQGA1UEAwwNaVRleHRUZXN0U2lnbjCCASIwDQYJ -KoZIhvcNAQEBBQADggEPADCCAQoCggEBAMaJ+B8HlKGXBhb64LuOiG/xGWn3RgU+ -D1i42xD4jRIjP3oL3hLefVtqQAgaP4HJa0mI1VWU2ezTbp5u11qo9eAefPq6jxaO -rbC3VyT/FE4EcoEvr48N/1ZB0jnKLQlO2lzzVCqnL9gyC+soakGwLzFs9SKjkI4h -/9YCnkoVtxOI/9ZDBf/QlJxrpknOPS9RQ8Y0OK+2OIb0kvK0f28EcvfopAnvOaVb -AHIWypIDabuRcw/YXRbmxvj2c+t1dGC7f4CLv7YKiFsEpydUJDWRUYGLnE7GvO9d -mS3oEFaI+Kre4HjSsaCF/Rgp9fpHKgaFTr8rKOGVgQHPlRFOrtGqXV8CAwEAAaNS -MFAwHQYDVR0OBBYEFKwAjNPp8T/Q6cWJGYu9aMR/ujVCMB8GA1UdIwQYMBaAFKek -g+UBOOgzMM6Ft6zCMa6k6H89MA4GA1UdDwEB/wQEAwIGwDANBgkqhkiG9w0BAQsF -AAOCAQEARWKct75OvbvIGRpTN4lvqyPJS/ZoVa/Dddbdo2rD669qltAce3/DFY2R -W0CNwIAxBh4CHqdlG5Od1qQ+BJH2pNGB6F2W/kmQuzaoo2PecDXNOfigRJASZO9O -nSFh+tQc+9DTNWrYyBb1MUEgZd4z0Q98dX3mWJ3YMG5Fb0pbexgpiAX5s9T3X+Da -olCzzmIRVIbce3UWv6T3fGvRJ/tyJ0VqvR8YBbVW15KaPabyZDE+v7QFizmoRFdw -7Dfv2tKIA/8ENO13BztYq1USTYhirfrR5Ki2oiul1Nmg48JgQRMHgfeBKMl9auyR -B6hPOeazdx/aJXMcZVIkYoWOPQsqVg== ------END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/keys/crl-key.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/keys/crl-key.pem deleted file mode 100644 index de681e12e4..0000000000 --- a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/keys/crl-key.pem +++ /dev/null @@ -1,28 +0,0 @@ ------BEGIN PRIVATE KEY----- -MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCVenga7acXwgog -JIM98HS1KkYqNP0wRwx4OaFNZRzXiqDZBBv5MHYDxTeGDfarn1WQYuZkWOeDWlck -ih6NsO/wq7HGYW17awSEGFs0dL0abbG5qldsXwZarT8j5UTLdkkZ8Ht0OF6mUp19 -d21EyztEgZXXRre4fx0Hw70s23pCVnfGz7fnB+Snt8tHHRTcpcD+clxGXQ8lPQrZ -M2gaRxTPLwBDtNP5KmoWqfDsfk3mu86wH6E+fI7iXRjpbew0SbOo7C17A09OM5OO -3KWfdOEdvZc1Nc6DKIhI31EwztHOX4+KuEQmM0qU941+VSRHypaKD+k1/xg1bR+f -PgN2EF7jAgMBAAECggEAA5Go5urOYYi59dT0A+sjg49l1iVC2ziRuYoHm849PJw9 -9yXcFK5KFp71Lvs2l4nEtjvyuk2Gc1s113Erd5Xw7Y+YWdEC0BPnDuxcnnQf/Yep -ohyswJThI2ePVAu/Omv4sxOE9jGJBzma3UMJ8k0bC37qXGspudBTmayjUZFsafxd -2mfQZOIUtMU0/LZPwr/TTdqFlHZmBIuUkcH8P9vIEyKXaFC/lfrhnRAi9Hu56S/H -VWiYFX/tSX7Up0DqAKruCVTEzSvskWp9xICs6IzfwB6Y4LEFi9QD7SezA5DdDX8k -wyqCJosOM2ZS+vHf33qGoCaYANUlEQcpYhItNB/6GQKBgQDOgb57wvRArXeG/cxe -L3qZgSVToRBhODi9UkbuXusPjl48nBj/QcxmFfEN3PFVe2Hw7TqcN1b6GoxYuc2I -0PCGzo37gru+OUPrGmnCAPECsDqRXwmA7NbJCvVwN1S7S3aZ0W2psPOTFDlYy9+T -7JgVXkRVgNWheMOrTzXky3eQPwKBgQC5Tbz1Wdw6iI/tAlYI+ektgRxDnhYfHGZV -/0ew9r3iIPxpYU6p3FsL4grZLfpo6zFad72aG6r81a8iMA+TwVuIPtCV4rX8Xe3Y -t+OiXBw94ZgEzsqFePqpCXDJOiNCf2NBSxthObNaLPKa8L4RtQ7udIs4VID4hHRq -o+dyCSEIXQKBgC++b3vNpwsNEAV1yDo+X+n9odOj+VWA2h1rWFrkNxRxpff9Xwok -/Ezd5c1+t4076Xj6YAKeCM3qNWiODKcFJ5cDSnBL2XwxYTKJ+MmRzicA94mEn33f -RAlXL0eygzSKTfFiKiiBcM8gbeHJwPdCTCcklEfwcXPTp+mDdsJfCFWhAoGAMQf1 -0MHXORG7a44rr7JY1baNAQNKfS7pkSW8FYIkWjo6L7QUuXNaD/nevvqggLSC2ZpH -bAiYJNBxx80JwiHuk01zqcVUPBOqhKabr/FJc8JGlDcXdVu+j4207znX7JeCbttt -wjsfTuQHyaGb2VmcOtJRqDUL7zY1C6aU7iKmP+0CgYEAl3AtXkFCGhHJDOHLD25z -Se4qR1u2rr3mQnqjcpkoGzvI26UoQbcGHHvh6m8G7Vl1xdIbeGBQQhGR5iL0Mw0e -FsasXqhh9YiG7Zf3eOwCJ/rGL4OJhCWLZVrcCX4eWaq2eVuQ5W3SARDKYb7mVhkr -TdVlWVdlYXCWQHqp1jQ6cio= ------END PRIVATE KEY----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/keys/im_key.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/keys/im_key.pem deleted file mode 100644 index 7a85540d40..0000000000 --- a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/keys/im_key.pem +++ /dev/null @@ -1,28 +0,0 @@ ------BEGIN PRIVATE KEY----- -MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQDN7dHZWbqUvuWd -BBh7J67s9mUaFSsG6SF8LjhrnraGwk2mk3wMl5oF6nB9WT4tLtXUs5FmxznQTYUU -C5ZN2bU35wkK7Yo41FOo6pIjKDIWqdf4xED6FOghz9228JEnWa5za4lcchqdiChs -DQ5YPXzgRrl3TXovDXz+avXWld6AvXJL3qzTSqXJ/f9MGHISEh/WNGvDehRVAahG -J47BHnu2uVSH4LD+9I64ZOd6TUCUjmyYQBc4bGxTV8ZlpGaYv2FCWgQkkGMEAlE6 -ESDclDGTrbFCAYeHrPBKQbdrrT5FYn2bwaPqaylD02F+uIipKO82OVh8j+ryFeQY -oWGL9xJvAgMBAAECggEADxzAVTSOCkN2I089IrCXWEF+yuq5xSCPugbEUjWMDJiu -zSYuqNfpUDzTs4c8lmFFBP6GkaXWOtCtjvqItb7f2zHjyn8DMUd3ukI4pkbZYitl -s5ZndFLbdDvGeBnwdRRSRpsiMfwXsu7elItivZwJkYXvL2+qo1BYl20vDGfkM8tR -mrCDFmW9RG73XKpn6Dd9C5HPV27r1nNQTjFNKx+Vv2ALNkNN1Ap3tZ7cTibY/Bt/ -muCU7SWWBXwjJsKQkkZUjVajWDRBA3wq9rnOilMt7rRbVyq6QIT6uCZYd9ouBBg0 -gcKjbA0FdUqJIdHWPSaJobuvtIAhoN6onhULOdq4hQKBgQDy3qbFpsmonXctY5mC -WV8PkX+YQZC0jC6YGLYbWO7lZ4rfrQvKEI8VbkMS82XzGLoSN05rAJonccsb0/Ch -4Z5AeR77o2z+AE71EzvEKXWGABWf1n+kiiu/2S6TfvTui3ToAPMrFr5p8y6Qer2h -V+1r2o5akm9JQQsEJ9e/z3Zm3QKBgQDZD+dNFWmBs9HbDm7iYZ/BJFMoVwXBweWS -qmPik99hIvyak76srnQtkW1kKXrzKICB9dbiBPYb8eicQZv1Nu9efrOIGa82gdCO -6QV3ToHYzMWnyan/j38nYtU0CtABQO3YWr0pxfHqpw9NmnUPBqwFpVGLppcA+Dg5 -xs8LbQk7uwKBgB9dwgwkzkaIj6u9AUZkZHKOR/xR+25V7G6YQmylv7TA+p6Iqs0d -9ly+MMtxw+jxeJaBrg8DtOUDPUgKxzkg+l85RVcadCkZwRjFsyJSeGsl96T8/t8x -ORU951YFP3zPZfnQpZcbCNyGG61tLLB5uqADSf9Iijbbv6B5xNNw58nBAoGAY4pd -ggX9ulMiO5ik1P/76PCliexOYYpvoxCsea1iVQNcX+69FCd0c6krRzGWhofeVrrM -bh3kVvBawb18rbkhkG3+Gr3ckdx6Le9CaHICLc/KHKXoZaACqaczKoiC1vBVolAK -S2vRAtDVvbrFT7y5imVDvg0JVpJ+BlDbhdvczh0CgYA14jJLY+IWAjxNzo8NdCi7 -iayF+nM4n0z0eW7/5T3hEPDan7DSg1O1cEUiKckt5LjZWv6xoxQcqYoN3H9jkchM -kMUOqvkb2UE+MllGVX+GLZkCJdTXpmDIXL/o23sM8awmiIpYWAbgQ9cSBoR13Pka -Nn3HfG6ejOSPFRHun+cw7g== ------END PRIVATE KEY----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/keys/root_key.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/keys/root_key.pem deleted file mode 100644 index 971c1f3141..0000000000 --- a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/keys/root_key.pem +++ /dev/null @@ -1,28 +0,0 @@ ------BEGIN PRIVATE KEY----- -MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDP6KUmxQzeXKuw -odaQZ7IUoidvDeXWrjW7BNYmKheyDX9SIeIwvuiKDVUD85pWyk6jhNUvQaYvGVOv -/Pbu4NJHv9FKch2d9759ckMT+MXGfGk/B6Ww1rlKsiHccWizQxah7R79eGweEvry -PIx+hqxreCBH4yzMPjHld1C34/vCnUGmozKT4KENiT6lXXiBm4D+u3siCPt1Gzxa -vvm2MUBTHBbhQ3/n1eS/FcqT4NhIvXDpPiNouD9goI+4LwCW7b52dg7dXreQY/If -GCcHTcu7YK/OEW4Pqjpr13B5mEDSDsCqrStoh8EQ+jB62n2Xv8TT4lQju/sZh0l6 -5IiT8fUfAgMBAAECggEAN3LV/PGHvZQcjBaVeVzWfy9B8hnURv2eQdsH3BTUzf1Q -jBCSWSrJLOxiVJP3AReignTOQHSzRBNuoNyH5Oyb2FvdjwvBP1yP9rfvENgDsyyC -CzfYZkHWGAhLBJZQdKK7WgM6BSLFPv4T5F/mnmX/fQgEH/gD/hLGTusT4X9RqTS4 -1cnScT+zPn/FedqLHiNQ3MTAQQBrSl/DoUPU8HyDDN1uF9/TbvEaMYl/iXyBPYpZ -AqhS7Je6Hue5Q86Tqd7Hj044OzRcjci2X6XeB0aAQc9VppAoI92hYsv59zLiHpw7 -81fRXazsyzQuctu8ep6Q08YMBN2YJN2XLj0IANs6lQKBgQD/lxTVtP1nffeV/Csj -j051N7N0SYASZtAXjM4x2z/0dRpka0C05kimT5ZpYGIVmWmTb4EzGYzIBOO4mEyz -1AawmDLkFDELc03XM7Ng8YrMvi0pl7TpPorc1fvVjcEXCfzRC5FiQ8kTBZ68zcMA -5+6uNt4lxaCiiqWswWQWl8l2xQKBgQDQPf2hHYOkNtUg7AsSdou3+dTQj90DlXOE -V/SotkStwIQcWefD/IcGQbAI1NGzXwipXsxQ//G9slDXZSKgxHpXT+pmrUDc5FHW -v8XMH+dtzOkCrExh9S2r7HFp6UlwOWomwePkMEKWWCZIV/wz8HzuERH7MZvgcTYU -Cb1mlZPakwKBgQCvC3XFdxMl0evC2NVioT8GoINS3RPNhoR13IVLN/FxJtJQe/Pw -8NZIsLE+sjf6uvrHctJ1gMYeJtsfDY9aiZebUmFoOzvrr6hb/piXiFWbK5QarD/G -joLkA9lZxJ+9e6WeNeH3/pyzXmH8xJ8M+8tHnWQ/Uj5Vk8crrbcykfn0UQKBgH0O -TUs9SzoJx9I+jqOm119DxF7/lk25qaa3n3DWDMZ/j5brEvkqpPfH6OxUyh47GxuD -l5WpLsap2EySKsp7U7Eth+njb8l3wAIEJsff/P5+iQwW5sQJFkVh9/YPqA+iGzJt -S+tUZBiflVXqqMWUTaI2VCMS9rZBpqU/+CMr/p/LAoGBAIWfEfkqU2miHOcyEVjr -6PmTzhii9nXjV/E5tK84v3a9B+ItLLYiiPiD15t1l7tu3Rq2hnwItM4/8nM6AxNR -Q9kDjj+UdTiK2sc2vxry/nlrnyjl/ls8z02QUiIGMNZLdqf58dROc5h5QEM+dNaU -LuDLIIf61vUhT2UHcQXJ33N+ ------END PRIVATE KEY----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/keys/sign-key.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/keys/sign-key.pem deleted file mode 100644 index 61f32d1105..0000000000 --- a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/keys/sign-key.pem +++ /dev/null @@ -1,28 +0,0 @@ ------BEGIN PRIVATE KEY----- -MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDGifgfB5ShlwYW -+uC7johv8Rlp90YFPg9YuNsQ+I0SIz96C94S3n1bakAIGj+ByWtJiNVVlNns026e -btdaqPXgHnz6uo8Wjq2wt1ck/xROBHKBL6+PDf9WQdI5yi0JTtpc81Qqpy/YMgvr -KGpBsC8xbPUio5COIf/WAp5KFbcTiP/WQwX/0JSca6ZJzj0vUUPGNDivtjiG9JLy -tH9vBHL36KQJ7zmlWwByFsqSA2m7kXMP2F0W5sb49nPrdXRgu3+Ai7+2CohbBKcn -VCQ1kVGBi5xOxrzvXZkt6BBWiPiq3uB40rGghf0YKfX6RyoGhU6/KyjhlYEBz5UR -Tq7Rql1fAgMBAAECggEAFCf+sjvFSbB49E1NEo2SaXb7QwhRKggWa8X8q5joTY6Z -i6z3w0emR2kejhQIHYeS5ljHe9RMWaBPizMqlvAvYi0GODhHfZ1HofjDFqT07UTD -UT1DoAzmPt4Y1zgg4WCJh8VGZrwpfdP65MlqHDgkWmq66mTbsKpf/FywsEnLF+bz -WWgKJP8NIxtI+iSipgGLOW+DtYO9gvmF9dDjPHISWkcYGetuz2k+a3n1NE6vwx6S -NZVC7pkzFGTg+IH8b4e64mN3jUoxSi9+KBZRApFYJRL07v8wBeJf7cN58NEzQjhG -5RwpBEjpcqEP/dYUbze6WBXC8G2KGrteBFBSqdb+5QKBgQDyMlDVblRWDBjD8RYL -9bXBooXsMIeP+i2fiTEEzpTsumha4T8KmPJr33bXOW9CZw/SUJ5WI3bBIzdzbxf9 -elBCoUJgO94wmnJdZNHeuLLb0AwTc0CMW5V8/5gu7e9Kxkyh6hojEo6POlWagGJz -3B1deqpJVe76oyLXMY4tavgLfQKBgQDR2q6zbHuubTeowDJD8CsrORB2+SJEo4Pe -1WzkP+0PX9y6n8Uk9FvjyU3MIPdD3hVruJwj7cHfpNg/UksTOjaWMI26VBKUfcQo -uZ84i4iwRrREAasgPc+evm1xAkmH5qDcXwIx7PxYW1tnRd8BuJZ6DpNDiY3rEf5D -Q2k0TumLCwKBgQDFHUJAkmy9I1c8kYgZ774ffAB2/AA4o6ph/ywP93mpOQUZgdzm -6RfTx6lW/P2aE3sC9m4HORG7msfUgQQLXnLX55q368Gn2OtfK2DLXZLj520Mn25X -TWpas0LOXwOz3bQcywS+qqmv1BA7kGWQWgLkQ6M30GKRRhhi/4fxWu/JmQKBgC6G -r2j0Sk+Xw1lUk1BgtRF2K2JVRfW10wzagLPyQFrCRCvUNF9HFgBgpzD0th2D5Xfm -jCejFPLCl3cihaaTp3qQ9Ts0XJIzeAQXc2eT+BAs/NZ/EDOrwJZPXfBKM4c/6LYz -EkeDZUcpqhAxe4nkJOiWxquYmbBeYuMC1RZV0I2VAoGAac0Kt0+Rk1jJithh6STu -BNQgswvfE2XFuMtySyByeNClzJofE4fHFhAHlhoHszPGSiNEDw4RvOxPWgBdLyFz -cWUXtL0GMzkwLfLCwRedFx65ijXbxUMIZXWYiG0GQA3w9fcDFYwugRMP5wKC9vMm -nTRzEOnBVWIXKLw7RdTBV4o= ------END PRIVATE KEY----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/missingIssuer/crl-issuer.cert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/missingIssuer/crl-issuer.cert.pem deleted file mode 100644 index 030a6784df..0000000000 --- a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/missingIssuer/crl-issuer.cert.pem +++ /dev/null @@ -1,21 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDhTCCAm2gAwIBAgICEAIwDQYJKoZIhvcNAQELBQAwNTELMAkGA1UEBhMCQkUx -DjAMBgNVBAoMBWlUZXh0MRYwFAYDVQQDDA1pVGV4dFRlc3RSb290MCAXDTAwMDEw -MTAwMDAwMFoYDzI0NTAwMTAxMDAwMDAwWjA6MQswCQYDVQQGEwJCRTEOMAwGA1UE -CgwFaVRleHQxGzAZBgNVBAMMEmlUZXh0VGVzdENybElzc3VlcjCCASIwDQYJKoZI -hvcNAQEBBQADggEPADCCAQoCggEBAJV6eBrtpxfCCiAkgz3wdLUqRio0/TBHDHg5 -oU1lHNeKoNkEG/kwdgPFN4YN9qufVZBi5mRY54NaVySKHo2w7/CrscZhbXtrBIQY -WzR0vRptsbmqV2xfBlqtPyPlRMt2SRnwe3Q4XqZSnX13bUTLO0SBlddGt7h/HQfD -vSzbekJWd8bPt+cH5Ke3y0cdFNylwP5yXEZdDyU9CtkzaBpHFM8vAEO00/kqahap -8Ox+Tea7zrAfoT58juJdGOlt7DRJs6jsLXsDT04zk47cpZ904R29lzU1zoMoiEjf -UTDO0c5fj4q4RCYzSpT3jX5VJEfKlooP6TX/GDVtH58+A3YQXuMCAwEAAaOBlzCB -lDAdBgNVHQ4EFgQU0zydGfhFz0j/TGolSJNUJEx9j2UwHwYDVR0jBBgwFoAUZMVB -M8C5H9K3buU8XKOSUrH/FgswDgYDVR0PAQH/BAQDAgHCMEIGA1UdHwQ7MDkwN6A1 -oDOGMWh0dHA6Ly9sb2NhbGhvc3QudGVzdC9kZWZhdWx0L2NybHMvY3JsL2xhdGVz -dC5jcmwwDQYJKoZIhvcNAQELBQADggEBALybI7Erkso0mOvu9ZVU2jzfE+aSZd9m -cCIQyytQtv8xi6Q4BfsEc/QLvLViybqkBvmrME/kFqVrFeEONgTy0LUO+OOZl1yZ -d/SWk81YVL3PJ2txHpehfHF5wlorDnZ5d/pn0sXu+tg55dmXQDniiZEHJxKQUEW2 -bYnC4qXhx0AXhpuTe6QbBZEY5DVNUVnenjtaixtlKqxA5hbTxkMiNol6A3wcTAgS -7yn8Bv5EzJobSI9rKoQuKMvnlj1FRX/0zr6hONAF6EOUjGG82GA2Aw4CrT4wOixL -s+fOY2SRtpZRMqD2hOF0t3kVKUDQx5HH87xc2ruGUM/rPLOYksnD7IQ= ------END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/missingIssuer/sign.cert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/missingIssuer/sign.cert.pem deleted file mode 100644 index 26c2432936..0000000000 --- a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CRLValidatorTest/missingIssuer/sign.cert.pem +++ /dev/null @@ -1,20 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDQjCCAiqgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwPTELMAkGA1UEBhMCQkUx -DjAMBgNVBAoMBWlUZXh0MR4wHAYDVQQDDBVpVGV4dFRlc3RJbnRlcm1lZGlhdGUw -IBcNMDAwMTAxMDAwMDAwWhgPMjQwMDAxMDEwMDAwMDBaMDUxCzAJBgNVBAYTAkJF -MQ4wDAYDVQQKDAVpVGV4dDEWMBQGA1UEAwwNaVRleHRUZXN0U2lnbjCCASIwDQYJ -KoZIhvcNAQEBBQADggEPADCCAQoCggEBAMaJ+B8HlKGXBhb64LuOiG/xGWn3RgU+ -D1i42xD4jRIjP3oL3hLefVtqQAgaP4HJa0mI1VWU2ezTbp5u11qo9eAefPq6jxaO -rbC3VyT/FE4EcoEvr48N/1ZB0jnKLQlO2lzzVCqnL9gyC+soakGwLzFs9SKjkI4h -/9YCnkoVtxOI/9ZDBf/QlJxrpknOPS9RQ8Y0OK+2OIb0kvK0f28EcvfopAnvOaVb -AHIWypIDabuRcw/YXRbmxvj2c+t1dGC7f4CLv7YKiFsEpydUJDWRUYGLnE7GvO9d -mS3oEFaI+Kre4HjSsaCF/Rgp9fpHKgaFTr8rKOGVgQHPlRFOrtGqXV8CAwEAAaNS -MFAwHQYDVR0OBBYEFKwAjNPp8T/Q6cWJGYu9aMR/ujVCMB8GA1UdIwQYMBaAFKek -g+UBOOgzMM6Ft6zCMa6k6H89MA4GA1UdDwEB/wQEAwIGwDANBgkqhkiG9w0BAQsF -AAOCAQEARWKct75OvbvIGRpTN4lvqyPJS/ZoVa/Dddbdo2rD669qltAce3/DFY2R -W0CNwIAxBh4CHqdlG5Od1qQ+BJH2pNGB6F2W/kmQuzaoo2PecDXNOfigRJASZO9O -nSFh+tQc+9DTNWrYyBb1MUEgZd4z0Q98dX3mWJ3YMG5Fb0pbexgpiAX5s9T3X+Da -olCzzmIRVIbce3UWv6T3fGvRJ/tyJ0VqvR8YBbVW15KaPabyZDE+v7QFizmoRFdw -7Dfv2tKIA/8ENO13BztYq1USTYhirfrR5Ki2oiul1Nmg48JgQRMHgfeBKMl9auyR -B6hPOeazdx/aJXMcZVIkYoWOPQsqVg== ------END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CertificateChainValidatorTest/ca.cert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CertificateChainValidatorTest/ca.cert.pem deleted file mode 100644 index 607e8e4816..0000000000 --- a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CertificateChainValidatorTest/ca.cert.pem +++ /dev/null @@ -1,20 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDSzCCAjOgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwNTELMAkGA1UEBhMCQkUx -DjAMBgNVBAoMBWlUZXh0MRYwFAYDVQQDDA1pVGV4dFRlc3RSb290MCAXDTAwMDEw -MTAwMDAwMFoYDzI1MDAwMTAxMDAwMDAwWjA1MQswCQYDVQQGEwJCRTEOMAwGA1UE -CgwFaVRleHQxFjAUBgNVBAMMDWlUZXh0VGVzdFJvb3QwggEiMA0GCSqGSIb3DQEB -AQUAA4IBDwAwggEKAoIBAQDP6KUmxQzeXKuwodaQZ7IUoidvDeXWrjW7BNYmKhey -DX9SIeIwvuiKDVUD85pWyk6jhNUvQaYvGVOv/Pbu4NJHv9FKch2d9759ckMT+MXG -fGk/B6Ww1rlKsiHccWizQxah7R79eGweEvryPIx+hqxreCBH4yzMPjHld1C34/vC -nUGmozKT4KENiT6lXXiBm4D+u3siCPt1Gzxavvm2MUBTHBbhQ3/n1eS/FcqT4NhI -vXDpPiNouD9goI+4LwCW7b52dg7dXreQY/IfGCcHTcu7YK/OEW4Pqjpr13B5mEDS -DsCqrStoh8EQ+jB62n2Xv8TT4lQju/sZh0l65IiT8fUfAgMBAAGjYzBhMB0GA1Ud -DgQWBBRkxUEzwLkf0rdu5Txco5JSsf8WCzAfBgNVHSMEGDAWgBRkxUEzwLkf0rdu -5Txco5JSsf8WCzAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIC5DANBgkq -hkiG9w0BAQsFAAOCAQEARJOOUQkv9AgqElJmQjGDkRdJPxkDHZtRLGOk9p0E1KbL -lqQQdgzL7RuE4vfCROan6aBZmXFRviIPg/Gxw2hDSIv1NUZv3AIgM2b9+3y+4SQ6 -2a/sqh1JPLxwnLN+Mo5KwY/E/YlJ0N7rw3AONrLlqH89BRrBIiPjrg74zi6qPzGn -WB2awHsbl7AOtkD2dEud7lbyLda/hCw2RGPSBQMm50pWsuInWXzdtX/Ii9yTGMyD -kavUHX6DDVouZBSKOjmChP0fGPM17ORJNR92RbT2ygy+F0Zokh5XUgrKPr4/JTW5 -iIkycpjAXY9UEMfi8pFnnzVSRj65kkZvZZJzybelMQ== ------END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CertificateChainValidatorTest/intermediate.cert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CertificateChainValidatorTest/intermediate.cert.pem deleted file mode 100644 index 07b60159ef..0000000000 --- a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CertificateChainValidatorTest/intermediate.cert.pem +++ /dev/null @@ -1,20 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDUTCCAjmgAwIBAgICEAEwDQYJKoZIhvcNAQELBQAwNTELMAkGA1UEBhMCQkUx -DjAMBgNVBAoMBWlUZXh0MRYwFAYDVQQDDA1pVGV4dFRlc3RSb290MB4XDTAyMDEw -MTAwMDAwMFoXDTAzMDEwMTAwMDAwMFowPTELMAkGA1UEBhMCQkUxDjAMBgNVBAoM -BWlUZXh0MR4wHAYDVQQDDBVpVGV4dFRlc3RJbnRlcm1lZGlhdGUwggEiMA0GCSqG -SIb3DQEBAQUAA4IBDwAwggEKAoIBAQDN7dHZWbqUvuWdBBh7J67s9mUaFSsG6SF8 -LjhrnraGwk2mk3wMl5oF6nB9WT4tLtXUs5FmxznQTYUUC5ZN2bU35wkK7Yo41FOo -6pIjKDIWqdf4xED6FOghz9228JEnWa5za4lcchqdiChsDQ5YPXzgRrl3TXovDXz+ -avXWld6AvXJL3qzTSqXJ/f9MGHISEh/WNGvDehRVAahGJ47BHnu2uVSH4LD+9I64 -ZOd6TUCUjmyYQBc4bGxTV8ZlpGaYv2FCWgQkkGMEAlE6ESDclDGTrbFCAYeHrPBK -QbdrrT5FYn2bwaPqaylD02F+uIipKO82OVh8j+ryFeQYoWGL9xJvAgMBAAGjYzBh -MB0GA1UdDgQWBBSnpIPlATjoMzDOhbeswjGupOh/PTAfBgNVHSMEGDAWgBRkxUEz -wLkf0rdu5Txco5JSsf8WCzAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIB -5jANBgkqhkiG9w0BAQsFAAOCAQEAjhn3BZ/n3Pj7nwJrkdjANCphv9xS/gHiVMrz -InVr7ltMFl8f+pCWNLvhMIDJ5jJpDE02nJ1uMQH2lzkaoG+/m1ZHgPeXUIK9wYOm -il1zG2YxT8PPHdV3fnghbh1gsIUTqCb69zdxe/Lm0tMYRgSbcdknxVuezBTFSfYJ -dSVIMHhbmiUyje7hPnJ8wGz9kF08ZxcMuV1gvRCDBxN8+4gPa8AYJ1zCJBERF8Tf -DyqvSAbQ71Bbxw2YWpOxNEM2IaQCpHvQs1c1W7coRip7kTJUgYjZy3aM9M+1d4UL -eJ7XkcroOjajfuySyS66csCB12uInGF6FKJAQnEDAc5YSWEZ/w== ------END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CertificateChainValidatorTest/keys/im_key.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CertificateChainValidatorTest/keys/im_key.pem deleted file mode 100644 index 7a85540d40..0000000000 --- a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CertificateChainValidatorTest/keys/im_key.pem +++ /dev/null @@ -1,28 +0,0 @@ ------BEGIN PRIVATE KEY----- -MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQDN7dHZWbqUvuWd -BBh7J67s9mUaFSsG6SF8LjhrnraGwk2mk3wMl5oF6nB9WT4tLtXUs5FmxznQTYUU -C5ZN2bU35wkK7Yo41FOo6pIjKDIWqdf4xED6FOghz9228JEnWa5za4lcchqdiChs -DQ5YPXzgRrl3TXovDXz+avXWld6AvXJL3qzTSqXJ/f9MGHISEh/WNGvDehRVAahG -J47BHnu2uVSH4LD+9I64ZOd6TUCUjmyYQBc4bGxTV8ZlpGaYv2FCWgQkkGMEAlE6 -ESDclDGTrbFCAYeHrPBKQbdrrT5FYn2bwaPqaylD02F+uIipKO82OVh8j+ryFeQY -oWGL9xJvAgMBAAECggEADxzAVTSOCkN2I089IrCXWEF+yuq5xSCPugbEUjWMDJiu -zSYuqNfpUDzTs4c8lmFFBP6GkaXWOtCtjvqItb7f2zHjyn8DMUd3ukI4pkbZYitl -s5ZndFLbdDvGeBnwdRRSRpsiMfwXsu7elItivZwJkYXvL2+qo1BYl20vDGfkM8tR -mrCDFmW9RG73XKpn6Dd9C5HPV27r1nNQTjFNKx+Vv2ALNkNN1Ap3tZ7cTibY/Bt/ -muCU7SWWBXwjJsKQkkZUjVajWDRBA3wq9rnOilMt7rRbVyq6QIT6uCZYd9ouBBg0 -gcKjbA0FdUqJIdHWPSaJobuvtIAhoN6onhULOdq4hQKBgQDy3qbFpsmonXctY5mC -WV8PkX+YQZC0jC6YGLYbWO7lZ4rfrQvKEI8VbkMS82XzGLoSN05rAJonccsb0/Ch -4Z5AeR77o2z+AE71EzvEKXWGABWf1n+kiiu/2S6TfvTui3ToAPMrFr5p8y6Qer2h -V+1r2o5akm9JQQsEJ9e/z3Zm3QKBgQDZD+dNFWmBs9HbDm7iYZ/BJFMoVwXBweWS -qmPik99hIvyak76srnQtkW1kKXrzKICB9dbiBPYb8eicQZv1Nu9efrOIGa82gdCO -6QV3ToHYzMWnyan/j38nYtU0CtABQO3YWr0pxfHqpw9NmnUPBqwFpVGLppcA+Dg5 -xs8LbQk7uwKBgB9dwgwkzkaIj6u9AUZkZHKOR/xR+25V7G6YQmylv7TA+p6Iqs0d -9ly+MMtxw+jxeJaBrg8DtOUDPUgKxzkg+l85RVcadCkZwRjFsyJSeGsl96T8/t8x -ORU951YFP3zPZfnQpZcbCNyGG61tLLB5uqADSf9Iijbbv6B5xNNw58nBAoGAY4pd -ggX9ulMiO5ik1P/76PCliexOYYpvoxCsea1iVQNcX+69FCd0c6krRzGWhofeVrrM -bh3kVvBawb18rbkhkG3+Gr3ckdx6Le9CaHICLc/KHKXoZaACqaczKoiC1vBVolAK -S2vRAtDVvbrFT7y5imVDvg0JVpJ+BlDbhdvczh0CgYA14jJLY+IWAjxNzo8NdCi7 -iayF+nM4n0z0eW7/5T3hEPDan7DSg1O1cEUiKckt5LjZWv6xoxQcqYoN3H9jkchM -kMUOqvkb2UE+MllGVX+GLZkCJdTXpmDIXL/o23sM8awmiIpYWAbgQ9cSBoR13Pka -Nn3HfG6ejOSPFRHun+cw7g== ------END PRIVATE KEY----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CertificateChainValidatorTest/keys/root_key.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CertificateChainValidatorTest/keys/root_key.pem deleted file mode 100644 index 971c1f3141..0000000000 --- a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CertificateChainValidatorTest/keys/root_key.pem +++ /dev/null @@ -1,28 +0,0 @@ ------BEGIN PRIVATE KEY----- -MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDP6KUmxQzeXKuw -odaQZ7IUoidvDeXWrjW7BNYmKheyDX9SIeIwvuiKDVUD85pWyk6jhNUvQaYvGVOv -/Pbu4NJHv9FKch2d9759ckMT+MXGfGk/B6Ww1rlKsiHccWizQxah7R79eGweEvry -PIx+hqxreCBH4yzMPjHld1C34/vCnUGmozKT4KENiT6lXXiBm4D+u3siCPt1Gzxa -vvm2MUBTHBbhQ3/n1eS/FcqT4NhIvXDpPiNouD9goI+4LwCW7b52dg7dXreQY/If -GCcHTcu7YK/OEW4Pqjpr13B5mEDSDsCqrStoh8EQ+jB62n2Xv8TT4lQju/sZh0l6 -5IiT8fUfAgMBAAECggEAN3LV/PGHvZQcjBaVeVzWfy9B8hnURv2eQdsH3BTUzf1Q -jBCSWSrJLOxiVJP3AReignTOQHSzRBNuoNyH5Oyb2FvdjwvBP1yP9rfvENgDsyyC -CzfYZkHWGAhLBJZQdKK7WgM6BSLFPv4T5F/mnmX/fQgEH/gD/hLGTusT4X9RqTS4 -1cnScT+zPn/FedqLHiNQ3MTAQQBrSl/DoUPU8HyDDN1uF9/TbvEaMYl/iXyBPYpZ -AqhS7Je6Hue5Q86Tqd7Hj044OzRcjci2X6XeB0aAQc9VppAoI92hYsv59zLiHpw7 -81fRXazsyzQuctu8ep6Q08YMBN2YJN2XLj0IANs6lQKBgQD/lxTVtP1nffeV/Csj -j051N7N0SYASZtAXjM4x2z/0dRpka0C05kimT5ZpYGIVmWmTb4EzGYzIBOO4mEyz -1AawmDLkFDELc03XM7Ng8YrMvi0pl7TpPorc1fvVjcEXCfzRC5FiQ8kTBZ68zcMA -5+6uNt4lxaCiiqWswWQWl8l2xQKBgQDQPf2hHYOkNtUg7AsSdou3+dTQj90DlXOE -V/SotkStwIQcWefD/IcGQbAI1NGzXwipXsxQ//G9slDXZSKgxHpXT+pmrUDc5FHW -v8XMH+dtzOkCrExh9S2r7HFp6UlwOWomwePkMEKWWCZIV/wz8HzuERH7MZvgcTYU -Cb1mlZPakwKBgQCvC3XFdxMl0evC2NVioT8GoINS3RPNhoR13IVLN/FxJtJQe/Pw -8NZIsLE+sjf6uvrHctJ1gMYeJtsfDY9aiZebUmFoOzvrr6hb/piXiFWbK5QarD/G -joLkA9lZxJ+9e6WeNeH3/pyzXmH8xJ8M+8tHnWQ/Uj5Vk8crrbcykfn0UQKBgH0O -TUs9SzoJx9I+jqOm119DxF7/lk25qaa3n3DWDMZ/j5brEvkqpPfH6OxUyh47GxuD -l5WpLsap2EySKsp7U7Eth+njb8l3wAIEJsff/P5+iQwW5sQJFkVh9/YPqA+iGzJt -S+tUZBiflVXqqMWUTaI2VCMS9rZBpqU/+CMr/p/LAoGBAIWfEfkqU2miHOcyEVjr -6PmTzhii9nXjV/E5tK84v3a9B+ItLLYiiPiD15t1l7tu3Rq2hnwItM4/8nM6AxNR -Q9kDjj+UdTiK2sc2vxry/nlrnyjl/ls8z02QUiIGMNZLdqf58dROc5h5QEM+dNaU -LuDLIIf61vUhT2UHcQXJ33N+ ------END PRIVATE KEY----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CertificateChainValidatorTest/keys/sign-key.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CertificateChainValidatorTest/keys/sign-key.pem deleted file mode 100644 index 61f32d1105..0000000000 --- a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CertificateChainValidatorTest/keys/sign-key.pem +++ /dev/null @@ -1,28 +0,0 @@ ------BEGIN PRIVATE KEY----- -MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDGifgfB5ShlwYW -+uC7johv8Rlp90YFPg9YuNsQ+I0SIz96C94S3n1bakAIGj+ByWtJiNVVlNns026e -btdaqPXgHnz6uo8Wjq2wt1ck/xROBHKBL6+PDf9WQdI5yi0JTtpc81Qqpy/YMgvr -KGpBsC8xbPUio5COIf/WAp5KFbcTiP/WQwX/0JSca6ZJzj0vUUPGNDivtjiG9JLy -tH9vBHL36KQJ7zmlWwByFsqSA2m7kXMP2F0W5sb49nPrdXRgu3+Ai7+2CohbBKcn -VCQ1kVGBi5xOxrzvXZkt6BBWiPiq3uB40rGghf0YKfX6RyoGhU6/KyjhlYEBz5UR -Tq7Rql1fAgMBAAECggEAFCf+sjvFSbB49E1NEo2SaXb7QwhRKggWa8X8q5joTY6Z -i6z3w0emR2kejhQIHYeS5ljHe9RMWaBPizMqlvAvYi0GODhHfZ1HofjDFqT07UTD -UT1DoAzmPt4Y1zgg4WCJh8VGZrwpfdP65MlqHDgkWmq66mTbsKpf/FywsEnLF+bz -WWgKJP8NIxtI+iSipgGLOW+DtYO9gvmF9dDjPHISWkcYGetuz2k+a3n1NE6vwx6S -NZVC7pkzFGTg+IH8b4e64mN3jUoxSi9+KBZRApFYJRL07v8wBeJf7cN58NEzQjhG -5RwpBEjpcqEP/dYUbze6WBXC8G2KGrteBFBSqdb+5QKBgQDyMlDVblRWDBjD8RYL -9bXBooXsMIeP+i2fiTEEzpTsumha4T8KmPJr33bXOW9CZw/SUJ5WI3bBIzdzbxf9 -elBCoUJgO94wmnJdZNHeuLLb0AwTc0CMW5V8/5gu7e9Kxkyh6hojEo6POlWagGJz -3B1deqpJVe76oyLXMY4tavgLfQKBgQDR2q6zbHuubTeowDJD8CsrORB2+SJEo4Pe -1WzkP+0PX9y6n8Uk9FvjyU3MIPdD3hVruJwj7cHfpNg/UksTOjaWMI26VBKUfcQo -uZ84i4iwRrREAasgPc+evm1xAkmH5qDcXwIx7PxYW1tnRd8BuJZ6DpNDiY3rEf5D -Q2k0TumLCwKBgQDFHUJAkmy9I1c8kYgZ774ffAB2/AA4o6ph/ywP93mpOQUZgdzm -6RfTx6lW/P2aE3sC9m4HORG7msfUgQQLXnLX55q368Gn2OtfK2DLXZLj520Mn25X -TWpas0LOXwOz3bQcywS+qqmv1BA7kGWQWgLkQ6M30GKRRhhi/4fxWu/JmQKBgC6G -r2j0Sk+Xw1lUk1BgtRF2K2JVRfW10wzagLPyQFrCRCvUNF9HFgBgpzD0th2D5Xfm -jCejFPLCl3cihaaTp3qQ9Ts0XJIzeAQXc2eT+BAs/NZ/EDOrwJZPXfBKM4c/6LYz -EkeDZUcpqhAxe4nkJOiWxquYmbBeYuMC1RZV0I2VAoGAac0Kt0+Rk1jJithh6STu -BNQgswvfE2XFuMtySyByeNClzJofE4fHFhAHlhoHszPGSiNEDw4RvOxPWgBdLyFz -cWUXtL0GMzkwLfLCwRedFx65ijXbxUMIZXWYiG0GQA3w9fcDFYwugRMP5wKC9vMm -nTRzEOnBVWIXKLw7RdTBV4o= ------END PRIVATE KEY----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CertificateChainValidatorTest/sign.cert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CertificateChainValidatorTest/sign.cert.pem deleted file mode 100644 index 26c2432936..0000000000 --- a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/CertificateChainValidatorTest/sign.cert.pem +++ /dev/null @@ -1,20 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDQjCCAiqgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwPTELMAkGA1UEBhMCQkUx -DjAMBgNVBAoMBWlUZXh0MR4wHAYDVQQDDBVpVGV4dFRlc3RJbnRlcm1lZGlhdGUw -IBcNMDAwMTAxMDAwMDAwWhgPMjQwMDAxMDEwMDAwMDBaMDUxCzAJBgNVBAYTAkJF -MQ4wDAYDVQQKDAVpVGV4dDEWMBQGA1UEAwwNaVRleHRUZXN0U2lnbjCCASIwDQYJ -KoZIhvcNAQEBBQADggEPADCCAQoCggEBAMaJ+B8HlKGXBhb64LuOiG/xGWn3RgU+ -D1i42xD4jRIjP3oL3hLefVtqQAgaP4HJa0mI1VWU2ezTbp5u11qo9eAefPq6jxaO -rbC3VyT/FE4EcoEvr48N/1ZB0jnKLQlO2lzzVCqnL9gyC+soakGwLzFs9SKjkI4h -/9YCnkoVtxOI/9ZDBf/QlJxrpknOPS9RQ8Y0OK+2OIb0kvK0f28EcvfopAnvOaVb -AHIWypIDabuRcw/YXRbmxvj2c+t1dGC7f4CLv7YKiFsEpydUJDWRUYGLnE7GvO9d -mS3oEFaI+Kre4HjSsaCF/Rgp9fpHKgaFTr8rKOGVgQHPlRFOrtGqXV8CAwEAAaNS -MFAwHQYDVR0OBBYEFKwAjNPp8T/Q6cWJGYu9aMR/ujVCMB8GA1UdIwQYMBaAFKek -g+UBOOgzMM6Ft6zCMa6k6H89MA4GA1UdDwEB/wQEAwIGwDANBgkqhkiG9w0BAQsF -AAOCAQEARWKct75OvbvIGRpTN4lvqyPJS/ZoVa/Dddbdo2rD669qltAce3/DFY2R -W0CNwIAxBh4CHqdlG5Od1qQ+BJH2pNGB6F2W/kmQuzaoo2PecDXNOfigRJASZO9O -nSFh+tQc+9DTNWrYyBb1MUEgZd4z0Q98dX3mWJ3YMG5Fb0pbexgpiAX5s9T3X+Da -olCzzmIRVIbce3UWv6T3fGvRJ/tyJ0VqvR8YBbVW15KaPabyZDE+v7QFizmoRFdw -7Dfv2tKIA/8ENO13BztYq1USTYhirfrR5Ki2oiul1Nmg48JgQRMHgfeBKMl9auyR -B6hPOeazdx/aJXMcZVIkYoWOPQsqVg== ------END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/OCSPValidatorTest/ocsp/keys/key.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/v1/OCSPValidatorTest/ocsp/keys/key.pem deleted file mode 100644 index 5fb891d53b..0000000000 --- a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/OCSPValidatorTest/ocsp/keys/key.pem +++ /dev/null @@ -1,30 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -Proc-Type: 4,ENCRYPTED -DEK-Info: AES-128-CBC,1C5866CA354FCFAF85B1B5DF8D373D52 - -b90+S05shvUKtr7iOJ061wwv0mKHkN92uq9v0MvObA+IuazjuI3DHcAQSU9l5eCM -N2rHq+cW/mBdgQeNVFG4IyOWDpGKUj5Rq0BGovAIrYAKrLsZS8RsTosNb/ICP74k -ZK+OloFnJFehNH5NfRTUdfnuJj9jq3q/7XrA3E41bsOFMbQPsRESVjO424vjPkN4 -KQwsIaDLOPGu0kzZmsuO2FPN7l5dMuS7Bf29Ns/U1w5JEcDIEPt8kWrQF3FN3bxv -7pJGzOe33s/7jby83VtGtEcWYjoZW0l+x72yQxz3PkCzgvqeq1MWy6EGCcGtX4af -ss7SQVmEMDkIAZrJ0Sw64chSqhk4ZBG43tejrn6Ed9eLHBrDIShERgq+Unw2xf4U -ILjBB4reZzDf9H7Jo//XgMa+8Wp+kuR7fXLtcCebUW/C5zpWRV/2gmgDAxn46RlA -mqKhQ0jUwgJkxvkK9kb2NWEfGvYZZ1ZHEuSbDXLu7zGufWW4nOK9lN3bhGlTWhTm -R2biS2SkPiMRuxiADI9BlMLgkHR1GcnDWqql157TBSe8pnH8j665F782x2RWF/j+ -l0Sl6yLkN4MXlAVdx4QfBnH3u1s/Y9T7OytzWwCApxMGNrsJx/+v12MV+s3M4vUg -bUE/mWd5j/xRixiAMrW492d++TItxz7yQe08tARRvtICwY5HL8WU1DzePTjLHPUa -1UNCrLNiVt2p4owygkYBseqgTfTguYtv72MHAoYMduoCNbKcoemuGj61I1BUiytn -wC8NMw/9H3OmTJ5IwDCSDqDcpjlJwpQI9/vZncf/fbodBEwxUTtDVFlX4RhaSrIy -FuFZnbcvpSdMwTxs8TjwEuJNQtzejaIH49DoGD8+qoR96ICD62b/Rqbbi7xi1DKs -tnG3au443YCFnPMEiuzDY0f2sFLOFEJZvLiW+vVi644My/ox6FQtgf9Jx79yCHZO -sq1VRfjteby2gO8jl2aMuw9ubDe8rxfoScU6bLcWSLNJ1KorNssoSg45r+NU0NOc -m2F8OXGu9zgwMMs35/oMrkLo64j7uA/5uPkxW43HeDxtx6K0XZRrP38HhVjKTnqO -O3+OQJXrkBtWOwE3Nn3bqxbQfTwtCTZBXQpmADhzwmBMKUL8tVy34gL7yqSClveE -2gxb4Vc+/pFs6bPAiBJr/7x77ya7sSYHBHzEBzUOlm9DMjTFrgMTi4bLMF7o5+hT -7votJYtIR7p4nowmBIeRBAJ+V6MM/LZ/v8DDUPgmsk7sEfOSEsDr4JDW8ChGeSr8 -uiXbaFnTBblrFSNQOElQsIzFG3cu9sD7PsxsUqfHCO6XuBFIcCnzyhcwX8o+Xcbw -Nqprgf3kbXErTcywM89Xg1RGa5Eu0wAqCqvEzsLm1dGsAQ/iTMuIitr9uJ+rell4 -/7TsLue9YFFcGXL3HcbV1RKGami14UXY+8t0BRYUnG49x3QTVXco0JKKtrhPT93s -eQ/jHDaZJXvVTjhiOR2bW6XkZ9KKlMXViwRRbJ7BlDUhbKltJXjIYJt+KbOmyGxP -ORE0EV9Le0hJBLXmgkXvr3AynL+twUEKLR9D91Ky/ZHcAyw61wmiuFq24U4aKWh0 ------END RSA PRIVATE KEY----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/OCSPValidatorTest/ocsp/keys/key1.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/v1/OCSPValidatorTest/ocsp/keys/key1.pem deleted file mode 100644 index 9b62b4a33d..0000000000 --- a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/OCSPValidatorTest/ocsp/keys/key1.pem +++ /dev/null @@ -1,31 +0,0 @@ ------BEGIN ENCRYPTED PRIVATE KEY----- -MIIFNTBfBgkqhkiG9w0BBQ0wUjAxBgkqhkiG9w0BBQwwJAQQ86aONneT2rZ4OxSP -Dm+4cAICCAAwDAYIKoZIhvcNAgkFADAdBglghkgBZQMEAQIEEF9NVK7Q8njCcRuJ -rMR4K0EEggTQHHXOcf7/lWrCNH2itwUuqgz4V3M1mX6QiIjJuHFsf/03PJj08bbb -Ne1x+LQCZzG63vBZmYchDvjj7QVPSecmEIfLrmISv8+qu1iBlzNXWScLBTul33wT -TbSFEfDl/AoH8sX1S+f2yZqmQEssdfV5gg7yoFXFEo27mRkBW378OOQWXKgXUI0A -z7CBRjDlr/0nt4CHDSib75MtE2oNMbyihAVb+LMsro7y2pWXHadH/U4PTyNMjTvv -HsA8+lmJHDiPVmzTbR3Aur0wIMR8LqaNUJ8NgfHFRHDiE94Q4g8DLTnMDOtLifAT -cneGIIEBbPuLBh6IDzaR55b5QJ7ZAaoO2BMEuRTP5PJtTrheKF8X8PjAZ7LPPc8n -FLY0hYc9RWw/MfFuiPRpiD2vzY5R19tFrFOSyNZz9r2haqwJ5lNfFEI5IQn6q0Bm -B77USRn0q5OlGXb3mxB1EqaOAVnZyppbbw1NXITFttKps2rplYJXUtNsc273UNgB -Clyc2vsmW27H8aEa/zHr+KVDMyz+JTyLorxECaRfvRl3XlBIVdpeFCrd8viIWjV/ -wp3RYMKMXPS1VvcJk6A388IAi+b7vnVDxtX+emAkrOMtAa4IZJwQyIfuy0qBdx1K -OQYS8qFUg+ErIJwOcgXlu4YV/ebgC0ESabTjNCAeVpPQ20ypgqTerAaP6QZMDrLl -Q+50eOLWl7E5mcdxsL+2MCu+eX6yc9njrvidtKKz7H+Qt4gWspRpKCDJpk4YTKof -zRQLSBhgMYWHDGM1uGx9bMnZYnM8aB1dph+7BJuETUXzp7Q3tJgUL+mYNUtrLvkG -eflHjUcFNj+24RDnzoDsdxv9YWBj5nF1mM9pdGUfe2VGMgAQ/ZQxdNDYGWF2zkfJ -tba+ylRNjprtn0Bt3PaCUPKYLZ0JMPoup9uENJIMx+4BB3z8Q038Ejrdr5xDmkOV -2zMFXSqSH/NE78ovi3Sg+cBpjqrX+rZtyksQlo8gQqFjzruxHokM41NnTJwOTitU -VLzJjh8ljjhwqPW9AY9o/k3Zrg0i7NxfVr2PnEeZnuI8atn+J0/2tbS67TCAxra3 -ZdZ3u9tYBof9sNPq2WmVmLWnC2DpkVvKN7uIOEJbONlCKCxxYYV/UpM9HPvYWvRC -Fl2qfzn1T6FeCISn7zJiwxXUZZQIT8PVJUnRoT5tptp71OkpfH83AZ/lyQg3WzcN -KUPDO6z8zLiihq7tgFOJ38kMZA0fs9UahfsxVgjgweQjcX2x927uWccd7VAqkCri -yY1L2xwgfiHF8ZR7Q2XzI71EwXhcpRkdzJEYUpPaD2FVrZWLeEDv8WHeo9BtnX+f -Z0Jc5BUtMB05Nwf7MAusdj7PrZ2yCg20f03o8W0lFF2V67uKDfumjX7HAaUL6uNi -+h3i4HuvKUVeMcIj5DxvMHKfEDgwytCCZkVqmlllseLkKGjnbRleJwGfC4shQlyE -0a0baa4vlAczT9ZAdxWJOLqELixZH5QxzctS6587Q9MuY4YwVc6NNRjPVfOmOoZO -o6BWVN2lOeMME9YV5Im+jDMZ1MeN0FlOfkoy4K5lt/e59ibdzaTQQp7jYIMsjeQZ -Lacc5oY0cY0UKZefRFtg8Lisen6WG4195B5cErHT5mF9N6FOaI7Eox8= ------END ENCRYPTED PRIVATE KEY----- - diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/OCSPValidatorTest/ocsp/keys/key2.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/v1/OCSPValidatorTest/ocsp/keys/key2.pem deleted file mode 100644 index 73dcde347c..0000000000 --- a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/OCSPValidatorTest/ocsp/keys/key2.pem +++ /dev/null @@ -1,30 +0,0 @@ ------BEGIN ENCRYPTED PRIVATE KEY----- -MIIFNTBfBgkqhkiG9w0BBQ0wUjAxBgkqhkiG9w0BBQwwJAQQF0kKZGhuRjc0ReXs -rguJdwICCAAwDAYIKoZIhvcNAgkFADAdBglghkgBZQMEAQIEEGF+EL8evTXnqMNG -Cxyic6wEggTQTM4EBzYhNo76Y+YPJC5ozvrp1Wl0/veYDj8kAkfUUEkL/CarBQ/N -lifnuusLtSU6lRj4H4rDmB209kk3XQ9Q1ca6s9kwpXBlTWk9ya5PGIpKAR2+OIzq -wb8JwhldgRD9p9cuSaVLcWvRMpEuBQCXSoIVGsB/erj1Ek7EjamAoPjStJ0y0QGG -iFrGCKzAIsVZxQ5dCaR8r6kZi60cLaFMt6dWhpfimJqOCpXyCW112ZVinjHNEYEd -ufHwXXIvzMnft/X21pkE/MLr3xZyzkbC5d+zX3pzW5HpKrIOlET13uvIstB0nWQI -9y1vTBwb+C6iZiZw7KP73OWu/vjZWOj/NF+yu6RhfsDV3xl23heKp+uF+JGlv79t -MqBXtxp3P1DdpE0iexALw1dpZTAfNn+qfwiYY2OPOhkc7ZASgaEduM0Zz+jKOhqI -ib5amuXs+T827kD9VKRWID0DDnfQWpANcKLCuwhLR4FhmaBGUr1s1qDZploc/QVu -B5k8wt/DanFsACx51Zsdj/c7x/mnI6Bv5md0HHy3t8XZYYICO9KKMDucoENtuxhq -XsyYppgznYRwU0uT49JFFx5die2QyE5RB8MjYPZlre21b0pVodOiTU0H9ZbS/5HY -OvlEed+OakvU/U10QU0chBRYF6B9wziK5lGSEtUbz+eoWg5UYvWEJtK7ZqROG94M -qHF7QYgzysX9/AtJCs/KR5Av7uRFyUme6Pajw8DQEoXzP6vwNnDVA317f+/nClrj -4rYb+UgqKFy9iTSJMpPrQUTPATbair6vWuRrmFGr1WAl7iydBMVUWWdEVJl9U/ql -PNqS+wAT2KXGKGkSZv2KfK1TQxHwsWVZOBybQwct3ydrFR0lN9hZDsFTBg3QyeNF -mNkn/J1YOnoZQQzidQCUz59vU0DNtQBRgdOejirbnhcUpfx5X5XOvZnHiWIpM5f0 -JLKocR7kGJ0ccCXv9p7cyic3Iu2osKL/h/0SmAn7WZWCeBW4s5akQJCzoEZLxZJH -Vgb0h3FO6g1HS/YUv6WnsFH+NDDdyyWI5LYtknSWSQQLtlpHuBhY5GSqUFGOCkG8 -b4waEUMDdOj85B4dSY3hhDOCLtpfUI5haJbAR9KNZ4nzbDwP6ItaVKL2JP7MaS3X -3nIDo7hu6T0xI25sAaZZhGOd2EJ9rMzQC4fMuSYVVZJRgFADAyySklJpqVmkv3sT -5uKcUOK/iQOmVnL9EWLwstcdiRYg1Q8FQcWObntmUY8O99gMkvYOhQgWx50KoKnr -YrGDn3LnA5wfotKniNquHWbE2NsFvmVvKPEjj0mNbxF0oZxv9nBeUN34l7rjyzfV -D9xBywazBXkIN4lgKUyicy8M8LoFbpwy8DBFLZhb1npTAI+HI/w0jpfQpi5YZxiH -9t2UfBUR3yhP1Jj53SBby+TWnmvxdL+WIQKAd3TC/z9ONdDMM+7A3pMnIJ5np7qa -8jKNY4jumgtR+0WVsYjTkhQZeVMoknb8gcq06FKI0/duM2YDtItEalU67m6GBKFF -jqDjLSANO9W43wkPJEfb3/0mU5Eq/MdQeIommE84TRjg7X0TD7/a+KyR5Yc2UU9v -cfHxPXI3FHBBHMnetOabyXC7jfvIaMCnOsyiQWghfkWawiCc1EgvRSI= ------END ENCRYPTED PRIVATE KEY----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/OCSPValidatorTest/ocsp/keys/key3.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/v1/OCSPValidatorTest/ocsp/keys/key3.pem deleted file mode 100644 index 7e63e5fbc0..0000000000 --- a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/OCSPValidatorTest/ocsp/keys/key3.pem +++ /dev/null @@ -1,30 +0,0 @@ ------BEGIN ENCRYPTED PRIVATE KEY----- -MIIFNTBfBgkqhkiG9w0BBQ0wUjAxBgkqhkiG9w0BBQwwJAQQAYAHt8zWxpTT+SPd -rIySKgICCAAwDAYIKoZIhvcNAgkFADAdBglghkgBZQMEAQIEEKZoItUClr1nqMtK -fpMWOkIEggTQokjE2mbLL2lSdNZjzge6rK6AGppQetH1iILY9UqVmx8DbK8v4i1C -TsHuvJ0nlMtGSa2xfdwc96dZwn5gTm3SjhgClyIWtotbjWyG4a2qUGgTowGWmxuH -Dz/4D7hP8gIMzVg2nzhiHlTjs+IddQesZyCUIu7tf0QgXcHI9PoogjIi2djgOL4m -c22h6vYNKo0kDFoCjZvzDpK8wt5LsAwDEERNM73vUh73AXqSUDBYqvFEQN+QmVEf -pSuac0JXWmpXHGllkrT2DmcUHmde6HB1ZBPhWryuoQZfRpwLORXSPDQ0rQXuwWcP -uUd+iXHMMkzLEIsb9du41u2DlDEcRXnCrGR+oMSV4wyQdosc7nlOzVXVB4RCTBgY -AEVQag7IjH/1/3FXT9YS7vBTKaF1OqS2ibquGmw5ibxCUVPOowD08F5HhQgh5WjI -9x3uP83f8eKqRLsSQRUJzCqHU8pxpEhBEk6uOEGY6Z7Nvn9wKWNjJhqrndzsO0bS -iee7AvbgntoLWU91LnH7mc+Tg9MwbKEH2vtx45kbHFuhqeqToRWHZyxjx7x4DuDP -i/2h/Dp9gWDbQ+BscVTZlJcssKRcKEecXWfFHctgsI4IhzZGojcq0iKE4hRlRaX1 -ZH2xpQNBazIhlGt5kdLY2LCUlPSYbFzb5MmkRy+8uUUfZJOu/4BwgqgJJPh0jvIy -zU4vYr3gD+qKsXsJMkXBVjiPWQJNCRuDgC1ayGLgRNxXqkaAdjFkWotB9vIfWMb4 -Q2c0O/cqmRbNOxxu4Uoh3ia9k9mVShrl+VIEtDK7egfke0xK0NHu5mmgSYmZ2Wod -q5xTKw1xiw/X4TgtlK0JqBL8MkupOEsRkkHS+pUIfEQQ3Y7dx8WRl6nse53TE7bH -y8TTKC4lIJl61vYRtdXV8jqZQOzAHxXcwwATyD8j/ugnyKC6bgti0mJReM5gh4pZ -NxT3Up2WJvvD02eFrCacu3mS6ueOjHMXq2VJ5Yu8s9DxJfN+aIN1iCMO7hNKlX9S -bZ+ZXnJQ1SVwY5NqdxaxdJQ35X4KClb7hmF82SHEL9ybySwRs2epvSu15Rf5rN1p -AmvgPbIXv7GRgNoVuii79lKukDLqijB7GXPLAv6YjwryuuJ4fVusVphpOcUUj3Ih -dsp4DeArB/uT4ju4AAg6EhLG94k/nc/EXWFxc0pOF8smeyA1EzvJe3cecEuj/LjX -YqU5H1uOuU/lIv2lLEqF6HYnXW+TdxsWxLY86XFy8mM41GwGso5EChl9H4cSfdSR -qtv9zR6WVJQeVJXMoQQlPntO4JSLDgS+WpWH8LYa4duyahAAoVQJGkEcNKcMVdOL -XL8cvRyXsVo/tY8+BtepmXhxduReM501p0zn2IathorTgu5gN6Pi2PcCmYoCD5jI -Iv3XWKTBDgD36j/PG2mjH1PTDfjZvn99uvTT5KXl2oHki8NEybJt5Hv+BmMRfncu -clg3G9QmshEGRL2exps7u5zOV+wdYp17l5WMGCPy0qo72l4Z1DAoB1fle8VTmO5n -G3/V5oi5fZGN5InTe098ge99wYJNyKye/Q3Nt7YAodBQBBt1CJb6qMe9wtC9onkb -IV2DQw3+XE3hdwFCTzahQjxT5wJDMMxdtNWgnlAD0t0R/wztA/bZPqM= ------END ENCRYPTED PRIVATE KEY----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorIntegrationTest/certs/short_validity_sign_cert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorIntegrationTest/certs/short_validity_sign_cert.pem deleted file mode 100644 index 2d90e06b74..0000000000 --- a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorIntegrationTest/certs/short_validity_sign_cert.pem +++ /dev/null @@ -1,20 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDVTCCAj2gAwIBAgICEAEwDQYJKoZIhvcNAQELBQAwQjELMAkGA1UEBhMCQkUx -DjAMBgNVBAoMBWlUZXh0MSMwIQYDVQQDDBppVGV4dFRlc3RTaG9ydFZhbGlkaXR5 -Um9vdDAeFw0yNDA2MDYwMDAwMDBaFw0yNDA2MDcwMDAwMDBaMEUxCzAJBgNVBAYT -AkJFMQ4wDAYDVQQKDAVpVGV4dDEmMCQGA1UEAwwdaVRleHRUZXN0U2hvcnRWYWxp -ZGl0eVNpZ25pbmcwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDBjVE5 -g+cvznWx1lVVpl9yg4dS3TCrB2kRO/meweFHcHSBhL+LEZDgA7m+k+fR+WHE/I1g -KbAFbX3/5dj8gcD8pQyOO9QuBkgvSi3uejpk/O2Zi/6hxItfiUu2O2SLvpGv72Zi -MVV0RgyS78i2s+uTno+vmbvooTKEbLyg1zQf4cfcQY+kX7q3JN192TfqEQQnNuK2 -STBERsk3MZ/lmXrfdn5SLQ6vEui4FKf/d2UWKXp+ZcLX9h47tRU0o1zBaZVvUf/d -/z1MNzo+jFMUrC9Zy6Jn2IOj3EoUg9xp/R77KoqQ/DbnoS/FiYTsyew9+pIptDSu -gLjTTxrFixkEkK4jAgMBAAGjUjBQMB0GA1UdDgQWBBSxHey9ksvff7hxUU3MLaSF -Nb++zTAfBgNVHSMEGDAWgBQPU6vHmmiV36QSlV44n86WrnzBHDAOBgNVHQ8BAf8E -BAMCBkAwDQYJKoZIhvcNAQELBQADggEBAHJNNuclJp1ZTRIGX0wAu8WfULnCHg7l -lUfY2BebGKpCnciwlgDTBDLV+2nLtjWmlxO9j0v/OOw+TV/SuQ2nWIDbfj1mEm5i -WzgNd5PvzI2EHb4kZ1DF4HVhxzjd5Syhk821fmLIyugel8Oe10D7PWlf/tQZiUoV -ca3xh64aoYE8khYzwREQGSSj9VRJkHddd+k73kp20kdk72YrAi72GzkPan/Fj8ar -6FH2EjGannaKdUDWf6EN9BLb/URqn49bCbLev9Xxj7wfQiu0KhYDq33wlZwBgVdT -3lEvqT9hvDMTurdrkrpcO9+qA4QQ3xObAZLhsXygm+tz9Mm109pLEjQ= ------END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorIntegrationTest/certs/ts_cert.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorIntegrationTest/certs/ts_cert.pem deleted file mode 100644 index c5ca173fa5..0000000000 --- a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorIntegrationTest/certs/ts_cert.pem +++ /dev/null @@ -1,20 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDUDCCAjigAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwPjELMAkGA1UEBhMCQkUx -DjAMBgNVBAoMBWlUZXh0MR8wHQYDVQQDDBZpVGV4dFRlc3RUaW1lc3RhbXBSb290 -MCAXDTAwMDEwMTAwMDAwMFoYDzI1MDAwMTAxMDAwMDAwWjA6MQswCQYDVQQGEwJC -RTEOMAwGA1UECgwFaVRleHQxGzAZBgNVBAMMEmlUZXh0VGVzdFRpbWVzdGFtcDCC -ASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALe0riefIAla5GYrx2DJ7tUC -coIBGKpuQdGT6/TQETmVgAJ+04f6A+xpviaABT6wanDEjxIwc4AY24Z03MoN9mTq -tMSL8p2/C7fEYM5QPMaKRLjvKQs4pdloe69bpe4qnaXrnhspafC40kh4opKHwAm8 -2xpEPnrcrIoldlNzUZ0wDlu9ScSdu9HnDc7l5ShScRhz5pEqTmpclOUCU4P4lvMP -o7ESpDGVK6dLb5psfQkPx06MDY7HiXq3kG4ZTf4l37TZTQq+MPoICh0Vcuk1Rwo8 -Iqkk0M6cBgI+xvQzGm+wr/xH7tiWeWGUuoxqgYxsBotOlX7WW7hMDC+woGRGKSkC -AwEAAaNaMFgwHQYDVR0OBBYEFLT7THY3zBbfAlt6XxIDWZ/y+PKKMB8GA1UdIwQY -MBaAFAjHQmCYQVscTRw/3JXqLE36LcsPMBYGA1UdJQEB/wQMMAoGCCsGAQUFBwMI -MA0GCSqGSIb3DQEBCwUAA4IBAQCYeEO0M7GTyEhaOHCH/vUTlxueSUnqAX5oMcGW -1IUXtQpG7bgBMA7GnW5FZztk2pX+GwyPCSXaWrPBpJDBQtH/4bsHSDtM9OSahlgr -9aYEqaoKzjJCgPKTb1iEluE9NL43tMS8frJkPYDioEv6zGaMwpcvXs5+s5JXTBS8 -1OwGKuVXi1KAM8Bw4BNDcH29iy4LhVuTL+J5iBXbzZc+YVTs+5drewJU2DjWB2Cj -mBOY52p8WE6pAuoHGogLk+ubqjv/v+rMCEFSQzciP2lB2IbDq7zKJ0ZTjyzHEKMf -DEQ3moy3EM6z9nhtkyt0/DCojEOB4uqO8MOvo27S1TV1kaid ------END CERTIFICATE----- diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorTest/certs/trustedCerts.pem b/sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorTest/certs/trustedCerts.pem deleted file mode 100644 index 91cf8349d9..0000000000 --- a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorTest/certs/trustedCerts.pem +++ /dev/null @@ -1,43 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDSzCCAjOgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwNTELMAkGA1UEBhMCQkUx -DjAMBgNVBAoMBWlUZXh0MRYwFAYDVQQDDA1pVGV4dFRlc3RSb290MCAXDTAwMDEw -MTAwMDAwMFoYDzI1MDAwMTAxMDAwMDAwWjA1MQswCQYDVQQGEwJCRTEOMAwGA1UE -CgwFaVRleHQxFjAUBgNVBAMMDWlUZXh0VGVzdFJvb3QwggEiMA0GCSqGSIb3DQEB -AQUAA4IBDwAwggEKAoIBAQC0X3R+3mERB2TiXd+AbcFNqXQWdIMNY39fr/93QQgT -mqp/QCQ5YTBDS52DAMWXC1twQCYTLzq4hW4awcYFrxawVvSxR4qR93hr5f19vwIW -hDiKy+RGNQ3aTs6W8NE41ZXqxrbgFelMmJ3/UUcCcwXL8wmviSXFCOBEkIPNwuHZ -vkoPqM7lKDYF4OTRkfQ6B5/hEikiZ7JhHbr5uPEHKt6xvpGY8jh8rECGDfJwqPAo -YIjFUoALHDnRyc9avuYU5sdZxgdBpVvjYSbmZXECUy5YTiMyhKusArk0kR/QH51c -8mXzYrhrAGJD8x084D+KpniCKwj2v8lRDezCohzAkpgLAgMBAAGjYzBhMB0GA1Ud -DgQWBBQ3hv2LhpBxKeA4pviBxff1Jcja9DAfBgNVHSMEGDAWgBQ3hv2LhpBxKeA4 -pviBxff1Jcja9DAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIC5DANBgkq -hkiG9w0BAQsFAAOCAQEAc1W5CE+h5o9dTBUT6h8RAjyjYnUZgNlhTqFZBG5MyixQ -c0CpVulgmCuZ7edYO9/BqeWiTcMsckSoMQk5+33xUlCqOfogpM0CPqfDKWDFl8no -XS3bvfl+s5LOPV2ENNMUVlgZVPuSIzGrOeUAfVJrhhYtaayN6YR7Ky7XroTliX0W -dCcJVaJ/xvysWUIBA/IKGUn8MofR9p30ub7ig0vPMyIFcj5Swo0LsejfFU0Mb/E4 -N8Y/NRNmMZG31j+6Fjuevb9bUh5jz5jx+HD2lIioWaDvIu9cqKoL5muNecbnxL8u -mtMd2BcnDCWaH5CiYV50pLAfupP1tByUmNotNDmK1g== ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIID6jCCAtKgAwIBAgIEWOeR1jANBgkqhkiG9w0BAQsFADBUMQswCQYDVQQGEwJC -WTEOMAwGA1UEBwwFTWluc2sxDjAMBgNVBAoMBWlUZXh0MQ0wCwYDVQQLDAR0ZXN0 -MRYwFAYDVQQDDA1pVGV4dFRlc3RSb290MCAXDTE3MDQwNzEzMjAwMVoYDzIxMTcw -NDA3MTMyMDAxWjBUMQswCQYDVQQGEwJCWTEOMAwGA1UEBwwFTWluc2sxDjAMBgNV -BAoMBWlUZXh0MQ0wCwYDVQQLDAR0ZXN0MRYwFAYDVQQDDA1pVGV4dFRlc3RSb290 -MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAz/fz7iq1wzhMMYcGfmMm -teCY/ZtdE26PB1OTTBuDSN86sVNmur5FV/mLPU9ZK2ofrs+wMrqn0agmFlRl4dTh -f5u5WSEQ/ARwXzYOn2uEkwR/0dwwZUL3VWhrPSD5SxX5MzFo8UXTNlXW2bClLC0F -QU2qLjIwwRFwwWDSQPR8r/Mv181RljVpEjPk6DfkDtHWWA4daGlQU0nXbuZszplv -iPafXmyKn+2w4G9Jw/8pHIK2VhWYstLI+bUZk662ZVldNvnpMyHn12FfB0Nbf/Z6 -V2WTGviEr8EEE2cA7I+H7ZGUDzug7umNCCJn3ilC6vAt9i9OLaZRDh6jPMOjMUiz -TwIDAQABo4HBMIG+MA8GA1UdEwEB/wQFMAMBAf8wfwYDVR0jBHgwdoAUXSpxda7d -2L5ZuiCxZpHJdjZTXO6hWKRWMFQxCzAJBgNVBAYTAkJZMQ4wDAYDVQQHDAVNaW5z -azEOMAwGA1UECgwFaVRleHQxDTALBgNVBAsMBHRlc3QxFjAUBgNVBAMMDWlUZXh0 -VGVzdFJvb3SCBFjnkdYwHQYDVR0OBBYEFF0qcXWu3di+WbogsWaRyXY2U1zuMAsG -A1UdDwQEAwIB9jANBgkqhkiG9w0BAQsFAAOCAQEAdhby6EaopoUF8j7oR44Mhe/N -3y9hzGb/zLmmgTavPd2plv6NlAPt9W+8rezKO6jQCsBRFw8JY+Lx6j3W0K6rWigB -pPGU/B/0bXLlOIv2a4uW8nBmq6jxAe5Xbtwm8HcKOOLMzxPIChHJIJy5NWw9ArD4 -Ul+FEt/VuEW1NfPZm1U5ixMOrBfn0C8pxIX4+VSHN9I8WoFjSfYX4Y3ldRLTeqxQ -rhZQlbhGNymp3Kcvtuq5At6vopskyB8Q1b7L4e+hRWK2prz/7p4Bdhu2TmkEfWZc -YKpgrkVFqa/Z1uZ0q4KVBOP3cyaQmqRXTV37SfpNyHAJdol5ueF68VVVNZFRXw== ------END CERTIFICATE----- \ No newline at end of file diff --git a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorTest/helloWorldDoc.pdf b/sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorTest/helloWorldDoc.pdf deleted file mode 100644 index 7e6f851581..0000000000 Binary files a/sign/src/test/resources/com/itextpdf/signatures/validation/v1/SignatureValidatorTest/helloWorldDoc.pdf and /dev/null differ diff --git a/styled-xml-parser/pom.xml b/styled-xml-parser/pom.xml index 37d6bb5550..78fdff266d 100644 --- a/styled-xml-parser/pom.xml +++ b/styled-xml-parser/pom.xml @@ -5,7 +5,7 @@ com.itextpdf root - 8.0.5 + 9.0.0 styled-xml-parser diff --git a/styled-xml-parser/src/main/java/com/itextpdf/styledxmlparser/PortUtil.java b/styled-xml-parser/src/main/java/com/itextpdf/styledxmlparser/PortUtil.java index 94a7d049eb..854b6df7f4 100644 --- a/styled-xml-parser/src/main/java/com/itextpdf/styledxmlparser/PortUtil.java +++ b/styled-xml-parser/src/main/java/com/itextpdf/styledxmlparser/PortUtil.java @@ -28,7 +28,7 @@ This file is part of the iText (R) project. /** * This file is a helper class for internal usage only. - * Be aware that its API and functionality may be changed in future. + * Be aware that its API and functionality may be changed in the future. */ public class PortUtil { diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/CssFontFaceRuleTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/CssFontFaceRuleTest.java index e6d17690e2..af4159a404 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/CssFontFaceRuleTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/CssFontFaceRuleTest.java @@ -24,15 +24,14 @@ This file is part of the iText (R) project. import com.itextpdf.layout.font.Range; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import java.util.ArrayList; import java.util.List; -@Category(UnitTest.class) +@Tag("UnitTest") public class CssFontFaceRuleTest extends ExtendedITextTest { @Test @@ -47,7 +46,7 @@ public void verifyThatToStringProducesValidCss() { " font-family: test-font-family;\n" + " font-weight: bold;\n" + "}"; - Assert.assertEquals(expectedCss, fontFaceRule.toString()); + Assertions.assertEquals(expectedCss, fontFaceRule.toString()); } @Test @@ -57,8 +56,8 @@ public void resolveUnicodeRangeTest() { declarations.add(new CssDeclaration("unicode-range", "U+75")); fontFaceRule.addBodyCssDeclarations(declarations); Range range = fontFaceRule.resolveUnicodeRange(); - Assert.assertNotNull(range); - Assert.assertTrue(range.contains(117)); + Assertions.assertNotNull(range); + Assertions.assertTrue(range.contains(117)); } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/CssFontFaceSrcTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/CssFontFaceSrcTest.java index fbd3ce0613..1e19cb916a 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/CssFontFaceSrcTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/CssFontFaceSrcTest.java @@ -30,19 +30,18 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.UnitTest; import java.util.regex.Matcher; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class CssFontFaceSrcTest extends ExtendedITextTest { private static final String sourceFolder = "./src/test/resources/com/itextpdf/styledxmlparser/css/CssFontFaceSrcTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { } @@ -55,48 +54,48 @@ public void srcPropertyTest() throws Exception { CssFontFaceRule fontFaceRule = (CssFontFaceRule)styleSheet.getStatements().get(0); CssDeclaration src = fontFaceRule.getProperties().get(0); - Assert.assertEquals("src expected", "src", src.getProperty()); + Assertions.assertEquals("src", src.getProperty(), "src expected"); String[] sources = src.getExpression().split(","); - Assert.assertEquals("27 sources expected", 27 , sources.length); + Assertions.assertEquals(27 , sources.length, "27 sources expected"); for (int i = 0; i < sources.length; i++) { Matcher m = CssFontFace.CssFontFaceSrc.UrlPattern.matcher(sources[i]); - Assert.assertTrue("Expression doesn't match pattern: " + sources[i], m.matches()); + Assertions.assertTrue(m.matches(), "Expression doesn't match pattern: " + sources[i]); String format = m.group(CssFontFace.CssFontFaceSrc.FormatGroup); String source2 = MessageFormatUtil.format("{0}({1}){2}", m.group(CssFontFace.CssFontFaceSrc.TypeGroup), m.group(CssFontFace.CssFontFaceSrc.UrlGroup), format != null ? MessageFormatUtil.format(" format({0})", format) : ""); String url = CssFontFace.CssFontFaceSrc.unquote(m.group(CssFontFace.CssFontFaceSrc.UrlGroup)); - Assert.assertTrue("Invalid url: " + url, url.startsWith(fontSrc)); + Assertions.assertTrue(url.startsWith(fontSrc), "Invalid url: " + url); - Assert.assertTrue("Invalid format: " + format, format == null || CssFontFace.CssFontFaceSrc.parseFormat(format) != CssFontFace.FontFormat.None); + Assertions.assertTrue(format == null || CssFontFace.CssFontFaceSrc.parseFormat(format) != CssFontFace.FontFormat.None, "Invalid format: " + format); - Assert.assertEquals("Group check fails: ", sources[i], source2); + Assertions.assertEquals(sources[i], source2, "Group check fails: "); CssFontFace.CssFontFaceSrc fontFaceSrc = CssFontFace.CssFontFaceSrc.create(sources[i]); - Assert.assertTrue("Invalid url: " + fontSrc, fontFaceSrc.getSrc().startsWith(fontSrc)); + Assertions.assertTrue(fontFaceSrc.getSrc().startsWith(fontSrc), "Invalid url: " + fontSrc); String type = "url"; if (fontFaceSrc.isLocal()) { type = "local"; } - Assert.assertTrue("Type '" + type + "' expected: " + sources[i], sources[i].startsWith(type)); + Assertions.assertTrue(sources[i].startsWith(type), "Type '" + type + "' expected: " + sources[i]); switch (fontFaceSrc.getFormat()) { case OpenType: - Assert.assertTrue("Format " + fontFaceSrc.getFormat() + " expected: " + sources[i], sources[i].contains("opentype")); + Assertions.assertTrue(sources[i].contains("opentype"), "Format " + fontFaceSrc.getFormat() + " expected: " + sources[i]); break; case TrueType: - Assert.assertTrue("Format " + fontFaceSrc.getFormat() + " expected: " + sources[i], sources[i].contains("truetype")); + Assertions.assertTrue(sources[i].contains("truetype"), "Format " + fontFaceSrc.getFormat() + " expected: " + sources[i]); break; case SVG: - Assert.assertTrue("Format " + fontFaceSrc.getFormat() + " expected: " + sources[i], sources[i].contains("svg")); + Assertions.assertTrue(sources[i].contains("svg"), "Format " + fontFaceSrc.getFormat() + " expected: " + sources[i]); break; case None: - Assert.assertFalse("Format " + fontFaceSrc.getFormat() + " expected: " + sources[i], sources[i].contains("format(")); + Assertions.assertFalse(sources[i].contains("format("), "Format " + fontFaceSrc.getFormat() + " expected: " + sources[i]); break; } @@ -110,20 +109,20 @@ public void parseBase64SrcTest() throws Exception { CssFontFaceRule fontFaceRule = (CssFontFaceRule)styleSheet.getStatements().get(0); CssDeclaration src = fontFaceRule.getProperties().get(0); - Assert.assertEquals("src expected", "src", src.getProperty()); + Assertions.assertEquals("src", src.getProperty(), "src expected"); String[] sources = CssFontFace.splitSourcesSequence(src.getExpression()); - Assert.assertEquals("8 sources expected", 8, sources.length); + Assertions.assertEquals(8, sources.length, "8 sources expected"); for (int i = 0; i < 6; i++) { Matcher m = CssFontFace.CssFontFaceSrc.UrlPattern.matcher(sources[i]); - Assert.assertTrue("Expression doesn't match pattern: " + sources[i], m.matches()); + Assertions.assertTrue(m.matches(), "Expression doesn't match pattern: " + sources[i]); } for (int i = 6; i < sources.length; i++) { Matcher m = CssFontFace.CssFontFaceSrc.UrlPattern.matcher(sources[i]); - Assert.assertFalse("Expression matches pattern (though it shouldn't!): " + sources[i], m.matches()); + Assertions.assertFalse(m.matches(), "Expression matches pattern (though it shouldn't!): " + sources[i]); } } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/CssFontFaceTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/CssFontFaceTest.java index 339580ac81..fdab84225e 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/CssFontFaceTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/CssFontFaceTest.java @@ -25,15 +25,14 @@ This file is part of the iText (R) project. import com.itextpdf.styledxmlparser.css.font.CssFontFace; import com.itextpdf.styledxmlparser.css.font.CssFontFace.CssFontFaceSrc; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.util.ArrayList; import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class CssFontFaceTest extends ExtendedITextTest { @Test @@ -44,12 +43,12 @@ public void createCssFontFaceTest() { CssFontFace fontFace = CssFontFace.create(properties); - Assert.assertNotNull(fontFace); - Assert.assertEquals("droid italic", fontFace.getFontFamily()); + Assertions.assertNotNull(fontFace); + Assertions.assertEquals("droid italic", fontFace.getFontFamily()); List sources = fontFace.getSources(); - Assert.assertNotNull(sources); - Assert.assertEquals(1, sources.size()); - Assert.assertEquals("web-fonts/droid-serif-italic.ttf", sources.get(0).getSrc()); + Assertions.assertNotNull(sources); + Assertions.assertEquals(1, sources.size()); + Assertions.assertEquals("web-fonts/droid-serif-italic.ttf", sources.get(0).getSrc()); } @Test @@ -60,7 +59,7 @@ public void createCssFontFaceNullSrcTest() { CssFontFace fontFace = CssFontFace.create(properties); - Assert.assertNull(fontFace); + Assertions.assertNull(fontFace); } @Test @@ -71,7 +70,7 @@ public void createCssFontFaceNullFontFamilyTest() { CssFontFace fontFace = CssFontFace.create(properties); - Assert.assertNull(fontFace); + Assertions.assertNull(fontFace); } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/CssMatchingTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/CssMatchingTest.java index 017a0eabf9..5a241e1847 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/CssMatchingTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/CssMatchingTest.java @@ -32,23 +32,22 @@ This file is part of the iText (R) project. import com.itextpdf.styledxmlparser.node.impl.jsoup.node.JsoupDocumentNode; import com.itextpdf.styledxmlparser.node.impl.jsoup.node.JsoupElementNode; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.FileInputStream; import java.io.IOException; import java.util.List; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class CssMatchingTest extends ExtendedITextTest { private static final String sourceFolder = "./src/test/resources/com/itextpdf/styledxmlparser/css/CssMatchingTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { } @@ -62,8 +61,8 @@ public void test01() throws IOException { MediaDeviceDescription deviceDescription = new MediaDeviceDescription("all"); IElementNode element = new JsoupElementNode(((JsoupDocumentNode)document).getDocument().getElementsByTag("p").first()); List declarations = css.getCssDeclarations(element, deviceDescription); - Assert.assertEquals(1, declarations.size()); - Assert.assertEquals("font-weight: bold", declarations.get(0).toString()); + Assertions.assertEquals(1, declarations.size()); + Assertions.assertEquals("font-weight: bold", declarations.get(0).toString()); } @Test @@ -76,9 +75,9 @@ public void test02() throws IOException { MediaDeviceDescription deviceDescription = new MediaDeviceDescription("all"); IElementNode element = new JsoupElementNode(((JsoupDocumentNode)document).getDocument().getElementsByTag("p").first()); List declarations = css.getCssDeclarations(element, deviceDescription); - Assert.assertEquals(2, declarations.size()); - Assert.assertEquals("font-weight: bold", declarations.get(1).toString()); - Assert.assertEquals("color: red", declarations.get(0).toString()); + Assertions.assertEquals(2, declarations.size()); + Assertions.assertEquals("font-weight: bold", declarations.get(1).toString()); + Assertions.assertEquals("color: red", declarations.get(0).toString()); } @Test @@ -91,9 +90,9 @@ public void test03() throws IOException { MediaDeviceDescription deviceDescription = new MediaDeviceDescription("all"); IElementNode element = new JsoupElementNode(((JsoupDocumentNode)document).getDocument().getElementsByTag("p").first()); List declarations = css.getCssDeclarations(element, deviceDescription); - Assert.assertEquals(2, declarations.size()); - Assert.assertEquals("font-weight: bold", declarations.get(0).toString()); - Assert.assertEquals("color: black", declarations.get(1).toString()); + Assertions.assertEquals(2, declarations.size()); + Assertions.assertEquals("font-weight: bold", declarations.get(0).toString()); + Assertions.assertEquals("color: black", declarations.get(1).toString()); } @Test @@ -106,8 +105,8 @@ public void test04() throws IOException { MediaDeviceDescription deviceDescription = new MediaDeviceDescription("all"); IElementNode element = new JsoupElementNode(((JsoupDocumentNode)document).getDocument().getElementsByTag("p").first()); List declarations = css.getCssDeclarations(element, deviceDescription); - Assert.assertEquals(1, declarations.size()); - Assert.assertEquals("font-size: 100px", declarations.get(0).toString()); + Assertions.assertEquals(1, declarations.size()); + Assertions.assertEquals("font-size: 100px", declarations.get(0).toString()); } @Test @@ -120,8 +119,8 @@ public void test05() throws IOException { MediaDeviceDescription deviceDescription = new MediaDeviceDescription("all"); IElementNode element = new JsoupElementNode(((JsoupDocumentNode)document).getDocument().getElementsByTag("p").first()); List declarations = css.getCssDeclarations(element, deviceDescription); - Assert.assertEquals(1, declarations.size()); - Assert.assertEquals("color: red", declarations.get(0).toString()); + Assertions.assertEquals(1, declarations.size()); + Assertions.assertEquals("color: red", declarations.get(0).toString()); } @Test @@ -134,8 +133,8 @@ public void test06() throws IOException { MediaDeviceDescription deviceDescription = new MediaDeviceDescription("all"); IElementNode element = new JsoupElementNode(((JsoupDocumentNode)document).getDocument().getElementsByTag("p").first()); List declarations = css.getCssDeclarations(element, deviceDescription); - Assert.assertEquals(1, declarations.size()); - Assert.assertEquals("color: blue", declarations.get(0).toString()); + Assertions.assertEquals(1, declarations.size()); + Assertions.assertEquals("color: blue", declarations.get(0).toString()); } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/CssNestedAtRuleFactoryTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/CssNestedAtRuleFactoryTest.java index 5c0a06f467..b8808d9476 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/CssNestedAtRuleFactoryTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/CssNestedAtRuleFactoryTest.java @@ -25,28 +25,27 @@ This file is part of the iText (R) project. import com.itextpdf.styledxmlparser.css.page.CssMarginRule; import com.itextpdf.styledxmlparser.css.page.CssPageRule; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class CssNestedAtRuleFactoryTest extends ExtendedITextTest { @Test public void testCreatingNestedRule() { CssNestedAtRule pageRule = CssNestedAtRuleFactory.createNestedRule("page:first"); - Assert.assertTrue(pageRule instanceof CssPageRule); - Assert.assertEquals(CssRuleName.PAGE, pageRule.getRuleName()); - Assert.assertEquals(":first", pageRule.getRuleParameters()); + Assertions.assertTrue(pageRule instanceof CssPageRule); + Assertions.assertEquals(CssRuleName.PAGE, pageRule.getRuleName()); + Assertions.assertEquals(":first", pageRule.getRuleParameters()); CssNestedAtRule rightBottomMarginRule = CssNestedAtRuleFactory.createNestedRule("bottom-right"); - Assert.assertTrue(rightBottomMarginRule instanceof CssMarginRule); - Assert.assertEquals(CssRuleName.BOTTOM_RIGHT, rightBottomMarginRule.getRuleName()); + Assertions.assertTrue(rightBottomMarginRule instanceof CssMarginRule); + Assertions.assertEquals(CssRuleName.BOTTOM_RIGHT, rightBottomMarginRule.getRuleName()); CssNestedAtRule fontFaceRule = CssNestedAtRuleFactory.createNestedRule("font-face"); - Assert.assertTrue(fontFaceRule instanceof CssFontFaceRule); - Assert.assertEquals(CssRuleName.FONT_FACE, fontFaceRule.getRuleName()); + Assertions.assertTrue(fontFaceRule instanceof CssFontFaceRule); + Assertions.assertEquals(CssRuleName.FONT_FACE, fontFaceRule.getRuleName()); } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/CssRuleSetTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/CssRuleSetTest.java index d14be74547..aeffc3f382 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/CssRuleSetTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/CssRuleSetTest.java @@ -25,14 +25,13 @@ This file is part of the iText (R) project. import com.itextpdf.styledxmlparser.css.parse.CssRuleSetParser; import com.itextpdf.styledxmlparser.css.selector.CssSelector; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class CssRuleSetTest extends ExtendedITextTest { @Test @@ -66,11 +65,11 @@ public void addCssRuleSetWithNormalImportantDeclarationsTest() { CssRuleSet cssRuleSet = new CssRuleSet(selector, declarations); List normalDeclarations = cssRuleSet.getNormalDeclarations(); for (int i = 0; i < expectedNormal.length; i++) { - Assert.assertEquals(expectedNormal[i], normalDeclarations.get(i).toString()); + Assertions.assertEquals(expectedNormal[i], normalDeclarations.get(i).toString()); } List importantDeclarations = cssRuleSet.getImportantDeclarations(); for (int i = 0; i < expectedImportant.length; i++) { - Assert.assertEquals(expectedImportant[i], importantDeclarations.get(i).toString()); + Assertions.assertEquals(expectedImportant[i], importantDeclarations.get(i).toString()); } } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/media/CssMediaRuleTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/media/CssMediaRuleTest.java index a91b385cf7..d076ca18a7 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/media/CssMediaRuleTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/media/CssMediaRuleTest.java @@ -34,21 +34,20 @@ This file is part of the iText (R) project. import com.itextpdf.styledxmlparser.node.impl.jsoup.node.JsoupDocumentNode; import com.itextpdf.styledxmlparser.node.impl.jsoup.node.JsoupElementNode; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.FileInputStream; import java.io.IOException; import java.util.List; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class CssMediaRuleTest extends ExtendedITextTest { private static final String sourceFolder = "./src/test/resources/com/itextpdf/styledxmlparser/css/media/MediaRuleTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { } @@ -63,10 +62,10 @@ public void test01() throws IOException { MediaDeviceDescription deviceDescription = new MediaDeviceDescription(MediaType.PRINT); IElementNode element = new JsoupElementNode(((JsoupDocumentNode) document).getDocument().getElementsByTag("p").first()); List declarations = css.getCssDeclarations(element, deviceDescription); - Assert.assertEquals(3, declarations.size()); - Assert.assertEquals("font-weight: bold", declarations.get(0).toString()); - Assert.assertEquals("color: red", declarations.get(1).toString()); - Assert.assertEquals("font-size: 20pt", declarations.get(2).toString()); + Assertions.assertEquals(3, declarations.size()); + Assertions.assertEquals("font-weight: bold", declarations.get(0).toString()); + Assertions.assertEquals("color: red", declarations.get(1).toString()); + Assertions.assertEquals("font-size: 20pt", declarations.get(2).toString()); } @Test @@ -87,10 +86,10 @@ public void test02() throws IOException { List declarations1 = css.getCssDeclarations(element, deviceDescription1); List declarations2 = css.getCssDeclarations(element, deviceDescription2); - Assert.assertTrue(declarations1.equals(declarations2)); + Assertions.assertTrue(declarations1.equals(declarations2)); - Assert.assertEquals(1, declarations1.size()); - Assert.assertEquals("font-weight: bold", declarations1.get(0).toString()); + Assertions.assertEquals(1, declarations1.size()); + Assertions.assertEquals("font-weight: bold", declarations1.get(0).toString()); } @Test @@ -104,8 +103,8 @@ public void test03() throws IOException { deviceDescription.setResolution(300); IElementNode element = new JsoupElementNode(((JsoupDocumentNode) document).getDocument().getElementsByTag("p").first()); List declarations = css.getCssDeclarations(element, deviceDescription); - Assert.assertEquals(1, declarations.size()); - Assert.assertEquals("color: black", declarations.get(0).toString()); + Assertions.assertEquals(1, declarations.size()); + Assertions.assertEquals("color: black", declarations.get(0).toString()); } @Test @@ -120,9 +119,9 @@ public void test04() throws IOException { IElementNode element = new JsoupElementNode(((JsoupDocumentNode) document).getDocument().getElementsByTag("p").first()); List declarations = css.getCssDeclarations(element, deviceDescription); - Assert.assertEquals(2, declarations.size()); - Assert.assertEquals("color: red", declarations.get(0).toString()); - Assert.assertEquals("font-size: 20em", declarations.get(1).toString()); + Assertions.assertEquals(2, declarations.size()); + Assertions.assertEquals("color: red", declarations.get(0).toString()); + Assertions.assertEquals("font-size: 20em", declarations.get(1).toString()); } @Test @@ -143,10 +142,10 @@ public void test05() throws IOException { List declarations1 = css.getCssDeclarations(element, deviceDescription1); List declarations2 = css.getCssDeclarations(element, deviceDescription2); - Assert.assertEquals(0, declarations1.size()); + Assertions.assertEquals(0, declarations1.size()); - Assert.assertEquals(1, declarations2.size()); - Assert.assertEquals("color: red", declarations2.get(0).toString()); + Assertions.assertEquals(1, declarations2.size()); + Assertions.assertEquals("color: red", declarations2.get(0).toString()); } @Test @@ -171,11 +170,11 @@ public void test06() throws IOException { List declarations2 = css.getCssDeclarations(element, deviceDescription2); List declarations3 = css.getCssDeclarations(element, deviceDescription3); - Assert.assertTrue(declarations1.equals(declarations2)); - Assert.assertEquals(0, declarations3.size()); + Assertions.assertTrue(declarations1.equals(declarations2)); + Assertions.assertEquals(0, declarations3.size()); - Assert.assertEquals(1, declarations1.size()); - Assert.assertEquals("color: red", declarations1.get(0).toString()); + Assertions.assertEquals(1, declarations1.size()); + Assertions.assertEquals("color: red", declarations1.get(0).toString()); } @@ -185,7 +184,7 @@ public void matchMediaDeviceTest() { deviceDescription.setHeight(450); deviceDescription.setWidth(600); CssMediaRule rule = new CssMediaRule("@media all and (min-width: 600px) and (min-height: 600px)"); - Assert.assertTrue(rule.matchMediaDevice(deviceDescription)); + Assertions.assertTrue(rule.matchMediaDevice(deviceDescription)); } @Test @@ -194,6 +193,6 @@ public void getCssRuleSetsTest() { String html = ""; IDocumentNode node = new JsoupHtmlParser().parse(html); List ruleSets = new CssMediaRule("only all and (min-width: 600px) and (min-height: 600px)").getCssRuleSets(node, deviceDescription); - Assert.assertNotNull(ruleSets); + Assertions.assertNotNull(ruleSets); } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/media/MediaExpressionTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/media/MediaExpressionTest.java index acf4f15827..302eee72a9 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/media/MediaExpressionTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/media/MediaExpressionTest.java @@ -23,12 +23,11 @@ This file is part of the iText (R) project. package com.itextpdf.styledxmlparser.css.media; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class MediaExpressionTest extends ExtendedITextTest { @Test public void mediaExpressionTestTest01() { @@ -39,8 +38,8 @@ public void mediaExpressionTestTest01() { deviceDescription.setWidth(600); deviceDescription.setHeight(600); - Assert.assertTrue(minHeight.matches(deviceDescription)); - Assert.assertTrue(minWidth.matches(deviceDescription)); + Assertions.assertTrue(minHeight.matches(deviceDescription)); + Assertions.assertTrue(minWidth.matches(deviceDescription)); } @Test @@ -52,8 +51,8 @@ public void mediaExpressionTestTest02() { deviceDescription.setWidth(450); deviceDescription.setHeight(450); - Assert.assertTrue(maxHeight.matches(deviceDescription)); - Assert.assertTrue(maxWidth.matches(deviceDescription)); + Assertions.assertTrue(maxHeight.matches(deviceDescription)); + Assertions.assertTrue(maxWidth.matches(deviceDescription)); } @Test @@ -78,14 +77,14 @@ public void mediaExpressionTestTest03() { deviceDescription.setWidth(32); deviceDescription.setHeight(20); - Assert.assertTrue(resolution.matches(deviceDescription)); - Assert.assertTrue(orientation.matches(deviceDescription)); - Assert.assertTrue(grid.matches(deviceDescription)); - Assert.assertTrue(colorIndex.matches(deviceDescription)); - Assert.assertTrue(monochrome.matches(deviceDescription)); - Assert.assertTrue(scan.matches(deviceDescription)); - Assert.assertTrue(color.matches(deviceDescription)); - Assert.assertTrue(minAspectRatio.matches(deviceDescription)); + Assertions.assertTrue(resolution.matches(deviceDescription)); + Assertions.assertTrue(orientation.matches(deviceDescription)); + Assertions.assertTrue(grid.matches(deviceDescription)); + Assertions.assertTrue(colorIndex.matches(deviceDescription)); + Assertions.assertTrue(monochrome.matches(deviceDescription)); + Assertions.assertTrue(scan.matches(deviceDescription)); + Assertions.assertTrue(color.matches(deviceDescription)); + Assertions.assertTrue(minAspectRatio.matches(deviceDescription)); } @Test @@ -102,10 +101,10 @@ public void mediaExpressionTestTest04() { deviceDescription.setWidth(32); deviceDescription.setHeight(20); - Assert.assertTrue(minAspectRatio.matches(deviceDescription)); - Assert.assertTrue(minColorIndex.matches(deviceDescription)); - Assert.assertTrue(minColor.matches(deviceDescription)); - Assert.assertTrue(minResolution.matches(deviceDescription)); + Assertions.assertTrue(minAspectRatio.matches(deviceDescription)); + Assertions.assertTrue(minColorIndex.matches(deviceDescription)); + Assertions.assertTrue(minColor.matches(deviceDescription)); + Assertions.assertTrue(minResolution.matches(deviceDescription)); } @Test @@ -125,12 +124,12 @@ public void mediaExpressionTestTest05() { deviceDescription.setMonochrome(0); deviceDescription.setResolution(150); - Assert.assertTrue(maxMonochrome.matches(deviceDescription)); - Assert.assertTrue(maxHeight.matches(deviceDescription)); - Assert.assertTrue(maxWidth.matches(deviceDescription)); - Assert.assertFalse(maxColorIndex.matches(deviceDescription)); - Assert.assertFalse(maxColor.matches(deviceDescription)); - Assert.assertTrue(maxResolution.matches(deviceDescription)); + Assertions.assertTrue(maxMonochrome.matches(deviceDescription)); + Assertions.assertTrue(maxHeight.matches(deviceDescription)); + Assertions.assertTrue(maxWidth.matches(deviceDescription)); + Assertions.assertFalse(maxColorIndex.matches(deviceDescription)); + Assertions.assertFalse(maxColor.matches(deviceDescription)); + Assertions.assertTrue(maxResolution.matches(deviceDescription)); } @Test @@ -152,13 +151,13 @@ public void mediaExpressionTestTest06() { deviceDescription.setHeight(2.00000000f); deviceDescription.setColorIndex(15000); - Assert.assertTrue(aspectRatio.matches(deviceDescription)); - Assert.assertTrue(minMonochrome.matches(deviceDescription)); - Assert.assertFalse(minColorIndex.matches(deviceDescription)); - Assert.assertFalse(minColor.matches(deviceDescription)); - Assert.assertFalse(resolution.matches(deviceDescription)); - Assert.assertFalse(defaultExpression.matches(deviceDescription)); - Assert.assertFalse(colorIndex.matches(deviceDescription)); + Assertions.assertTrue(aspectRatio.matches(deviceDescription)); + Assertions.assertTrue(minMonochrome.matches(deviceDescription)); + Assertions.assertFalse(minColorIndex.matches(deviceDescription)); + Assertions.assertFalse(minColor.matches(deviceDescription)); + Assertions.assertFalse(resolution.matches(deviceDescription)); + Assertions.assertFalse(defaultExpression.matches(deviceDescription)); + Assertions.assertFalse(colorIndex.matches(deviceDescription)); } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/media/MediaQueryTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/media/MediaQueryTest.java index 622a4811a6..4f823afa3a 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/media/MediaQueryTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/media/MediaQueryTest.java @@ -23,13 +23,12 @@ This file is part of the iText (R) project. package com.itextpdf.styledxmlparser.css.media; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class MediaQueryTest extends ExtendedITextTest { @Test @@ -37,8 +36,8 @@ public void matchTest() { MediaDeviceDescription deviceDescription = new MediaDeviceDescription("all"); MediaQuery query = MediaQueryParser.parseMediaQuery("not all and (min-width: 600px)"); List queries = MediaQueryParser.parseMediaQueries("not all and (min-width: 600px), not all and (min-width: 500px)"); - Assert.assertTrue(query.matches(deviceDescription)); - Assert.assertTrue(queries.get(0).matches(deviceDescription)); - Assert.assertTrue(queries.get(1).matches(deviceDescription)); + Assertions.assertTrue(query.matches(deviceDescription)); + Assertions.assertTrue(queries.get(0).matches(deviceDescription)); + Assertions.assertTrue(queries.get(1).matches(deviceDescription)); } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/page/PageMarginBoxContextNodeTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/page/PageMarginBoxContextNodeTest.java index 51ddeb76f5..b67eacc080 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/page/PageMarginBoxContextNodeTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/page/PageMarginBoxContextNodeTest.java @@ -26,14 +26,13 @@ This file is part of the iText (R) project. import com.itextpdf.styledxmlparser.css.pseudo.CssPseudoElementNode; import com.itextpdf.styledxmlparser.node.IAttributes; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.util.HashMap; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PageMarginBoxContextNodeTest extends ExtendedITextTest { @Test @@ -42,34 +41,34 @@ public void defaultBehaviourTest() { PageMarginBoxContextNode pageMarginBoxContextNode = new PageMarginBoxContextNode(new PageContextNode(), marginBoxName); - Assert.assertEquals(marginBoxName, pageMarginBoxContextNode.getMarginBoxName()); - Assert.assertEquals(PageMarginBoxContextNode.PAGE_MARGIN_BOX_TAG, pageMarginBoxContextNode.name()); + Assertions.assertEquals(marginBoxName, pageMarginBoxContextNode.getMarginBoxName()); + Assertions.assertEquals(PageMarginBoxContextNode.PAGE_MARGIN_BOX_TAG, pageMarginBoxContextNode.name()); - Assert.assertThrows(UnsupportedOperationException.class, () -> pageMarginBoxContextNode.getLang()); - Assert.assertNull(pageMarginBoxContextNode.getAdditionalHtmlStyles()); - Assert.assertThrows(UnsupportedOperationException.class, + Assertions.assertThrows(UnsupportedOperationException.class, () -> pageMarginBoxContextNode.getLang()); + Assertions.assertNull(pageMarginBoxContextNode.getAdditionalHtmlStyles()); + Assertions.assertThrows(UnsupportedOperationException.class, () -> pageMarginBoxContextNode.addAdditionalHtmlStyles(new HashMap<>())); IAttributes attributes = pageMarginBoxContextNode.getAttributes(); - Assert.assertNotNull(attributes); - Assert.assertEquals(0, attributes.size()); + Assertions.assertNotNull(attributes); + Assertions.assertEquals(0, attributes.size()); String someKey = "someKey"; String someValue = "someValue"; - Assert.assertThrows(UnsupportedOperationException.class, + Assertions.assertThrows(UnsupportedOperationException.class, () -> attributes.setAttribute(someKey, someValue)); - Assert.assertNull(attributes.getAttribute(someKey)); - Assert.assertNull(pageMarginBoxContextNode.getAttribute(someKey)); + Assertions.assertNull(attributes.getAttribute(someKey)); + Assertions.assertNull(pageMarginBoxContextNode.getAttribute(someKey)); - Assert.assertNull(pageMarginBoxContextNode.getContainingBlockForMarginBox()); + Assertions.assertNull(pageMarginBoxContextNode.getContainingBlockForMarginBox()); Rectangle someRectangle = new Rectangle(100, 100); pageMarginBoxContextNode.setContainingBlockForMarginBox(someRectangle); - Assert.assertEquals(someRectangle, pageMarginBoxContextNode.getContainingBlockForMarginBox()); + Assertions.assertEquals(someRectangle, pageMarginBoxContextNode.getContainingBlockForMarginBox()); - Assert.assertNull(pageMarginBoxContextNode.getPageMarginBoxRectangle()); + Assertions.assertNull(pageMarginBoxContextNode.getPageMarginBoxRectangle()); Rectangle someRectangle2 = new Rectangle(200, 200); pageMarginBoxContextNode.setPageMarginBoxRectangle(someRectangle2); - Assert.assertEquals(someRectangle2, pageMarginBoxContextNode.getPageMarginBoxRectangle()); + Assertions.assertEquals(someRectangle2, pageMarginBoxContextNode.getPageMarginBoxRectangle()); } @@ -80,9 +79,9 @@ public void parentNotPageTest() { CssPseudoElementNode pseudoElementNode = new CssPseudoElementNode(pageContextNode, "test"); // Pass this mode to the constructor - Exception e = Assert.assertThrows(IllegalArgumentException.class, + Exception e = Assertions.assertThrows(IllegalArgumentException.class, () -> new PageMarginBoxContextNode(pseudoElementNode, "test")); - Assert.assertEquals( + Assertions.assertEquals( "Page-margin-box context node shall have a page context node as parent.", e.getMessage()); diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/parse/CssRuleSetParserTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/parse/CssRuleSetParserTest.java index fe99d4afb0..5f9f2fe574 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/parse/CssRuleSetParserTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/parse/CssRuleSetParserTest.java @@ -25,14 +25,13 @@ This file is part of the iText (R) project. import com.itextpdf.io.exceptions.IOException; import com.itextpdf.styledxmlparser.css.CssDeclaration; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class CssRuleSetParserTest extends ExtendedITextTest { @Test @@ -56,9 +55,9 @@ public void parsePropertyDeclarationsTest() throws IOException { }; List declarations = CssRuleSetParser.parsePropertyDeclarations(src); - Assert.assertEquals(expected.length, declarations.size()); + Assertions.assertEquals(expected.length, declarations.size()); for (int i = 0; i < expected.length; i++) { - Assert.assertEquals(expected[i], declarations.get(i).toString()); + Assertions.assertEquals(expected[i], declarations.get(i).toString()); } } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/parse/CssSelectorParserTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/parse/CssSelectorParserTest.java index 557de927e0..164f2a68e7 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/parse/CssSelectorParserTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/parse/CssSelectorParserTest.java @@ -26,13 +26,12 @@ This file is part of the iText (R) project. import com.itextpdf.io.exceptions.IOException; import com.itextpdf.styledxmlparser.exceptions.StyledXmlParserExceptionMessage; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class CssSelectorParserTest extends ExtendedITextTest { @Test @@ -40,9 +39,9 @@ public void selectorBeginsWithSpaceTest() throws IOException { String space = " "; String selectorWithSpaceAtTheBeginning = space + ".spaceBefore"; - Exception expectedException = Assert.assertThrows(IllegalArgumentException.class, + Exception expectedException = Assertions.assertThrows(IllegalArgumentException.class, () -> CssSelectorParser.parseSelectorItems(selectorWithSpaceAtTheBeginning)); - Assert.assertEquals( + Assertions.assertEquals( MessageFormatUtil.format(StyledXmlParserExceptionMessage.INVALID_TOKEN_AT_THE_BEGINNING_OF_SELECTOR, space), expectedException.getMessage()); diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/parse/CssStyleAttributeParseTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/parse/CssStyleAttributeParseTest.java index fb8eb05413..cae9a87a47 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/parse/CssStyleAttributeParseTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/parse/CssStyleAttributeParseTest.java @@ -30,17 +30,16 @@ This file is part of the iText (R) project. import com.itextpdf.styledxmlparser.node.INode; import com.itextpdf.styledxmlparser.node.impl.jsoup.JsoupHtmlParser; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.FileInputStream; import java.io.IOException; import java.util.ArrayList; import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class CssStyleAttributeParseTest extends ExtendedITextTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/styledxmlparser/css/parse/CssStyleAttributeParseTest/"; @@ -68,10 +67,10 @@ public void styleAttributeParseTest() throws IOException { parseStyleAttrForSubtree(document, styleDeclarations); - Assert.assertEquals(styleDeclarations.size(), expectStyleDeclarations.size()); + Assertions.assertEquals(styleDeclarations.size(), expectStyleDeclarations.size()); for (int i = 0; i < expectStyleDeclarations.size(); i++) { - Assert.assertEquals(expectStyleDeclarations.get(i), styleDeclarations.get(i)); + Assertions.assertEquals(expectStyleDeclarations.get(i), styleDeclarations.get(i)); } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/parse/CssStyleSheetParserTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/parse/CssStyleSheetParserTest.java index d96d1a79fb..abd3f54b53 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/parse/CssStyleSheetParserTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/parse/CssStyleSheetParserTest.java @@ -26,14 +26,13 @@ This file is part of the iText (R) project. import com.itextpdf.io.util.StreamUtil; import com.itextpdf.styledxmlparser.css.CssStyleSheet; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.IOException; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class CssStyleSheetParserTest extends ExtendedITextTest { private static final String sourceFolder = "./src/test/resources/com/itextpdf/styledxmlparser/css/parse/CssStyleSheetParserTest/"; @@ -42,7 +41,7 @@ public class CssStyleSheetParserTest extends ExtendedITextTest { public void test01() throws IOException { String cssFile = sourceFolder + "css01.css"; CssStyleSheet styleSheet = CssStyleSheetParser.parse(FileUtil.getInputStreamForFile(cssFile)); - Assert.assertEquals(getCssFileContents(cssFile), styleSheet.toString()); + Assertions.assertEquals(getCssFileContents(cssFile), styleSheet.toString()); } @Test @@ -50,7 +49,7 @@ public void test02() throws IOException { String cssFile = sourceFolder + "css02.css"; String cmpFile = sourceFolder + "cmp_css02.css"; CssStyleSheet styleSheet = CssStyleSheetParser.parse(FileUtil.getInputStreamForFile(cssFile)); - Assert.assertEquals(getCssFileContents(cmpFile), styleSheet.toString()); + Assertions.assertEquals(getCssFileContents(cmpFile), styleSheet.toString()); } @Test @@ -58,14 +57,14 @@ public void test03() throws IOException { String cssFile = sourceFolder + "css03.css"; String cmpFile = sourceFolder + "cmp_css03.css"; CssStyleSheet styleSheet = CssStyleSheetParser.parse(FileUtil.getInputStreamForFile(cssFile)); - Assert.assertEquals(getCssFileContents(cmpFile), styleSheet.toString()); + Assertions.assertEquals(getCssFileContents(cmpFile), styleSheet.toString()); } @Test public void test04() throws IOException { String cssFile = sourceFolder + "css04.css"; CssStyleSheet styleSheet = CssStyleSheetParser.parse(FileUtil.getInputStreamForFile(cssFile)); - Assert.assertEquals("", styleSheet.toString()); + Assertions.assertEquals("", styleSheet.toString()); } @Test @@ -73,7 +72,7 @@ public void test05() throws IOException { String cssFile = sourceFolder + "css05.css"; String cmpFile = sourceFolder + "cmp_css05.css"; CssStyleSheet styleSheet = CssStyleSheetParser.parse(FileUtil.getInputStreamForFile(cssFile)); - Assert.assertEquals(getCssFileContents(cmpFile), styleSheet.toString()); + Assertions.assertEquals(getCssFileContents(cmpFile), styleSheet.toString()); } @Test @@ -81,14 +80,14 @@ public void test06() throws IOException { String cssFile = sourceFolder + "css06.css"; String cmpFile = sourceFolder + "cmp_css06.css"; CssStyleSheet styleSheet = CssStyleSheetParser.parse(FileUtil.getInputStreamForFile(cssFile)); - Assert.assertEquals(getCssFileContents(cmpFile), styleSheet.toString()); + Assertions.assertEquals(getCssFileContents(cmpFile), styleSheet.toString()); } @Test public void test07() throws IOException { String cssFile = sourceFolder + "css07.css"; CssStyleSheet styleSheet = CssStyleSheetParser.parse(FileUtil.getInputStreamForFile(cssFile)); - Assert.assertEquals(getCssFileContents(cssFile), styleSheet.toString()); + Assertions.assertEquals(getCssFileContents(cssFile), styleSheet.toString()); } @Test @@ -96,14 +95,14 @@ public void test08() throws IOException { String cssFile = sourceFolder + "css08.css"; String cmpFile = sourceFolder + "cmp_css08.css"; CssStyleSheet styleSheet = CssStyleSheetParser.parse(FileUtil.getInputStreamForFile(cssFile)); - Assert.assertEquals(getCssFileContents(cmpFile), styleSheet.toString()); + Assertions.assertEquals(getCssFileContents(cmpFile), styleSheet.toString()); } @Test public void test09() throws IOException { String cssFile = sourceFolder + "css09.css"; CssStyleSheet styleSheet = CssStyleSheetParser.parse(FileUtil.getInputStreamForFile(cssFile)); - Assert.assertEquals(getCssFileContents(cssFile), styleSheet.toString()); + Assertions.assertEquals(getCssFileContents(cssFile), styleSheet.toString()); } @Test @@ -111,7 +110,7 @@ public void test10() throws IOException { String cssFile = sourceFolder + "css10.css"; String cmpFile = sourceFolder + "cmp_css10.css"; CssStyleSheet styleSheet = CssStyleSheetParser.parse(FileUtil.getInputStreamForFile(cssFile)); - Assert.assertEquals(getCssFileContents(cmpFile), styleSheet.toString()); + Assertions.assertEquals(getCssFileContents(cmpFile), styleSheet.toString()); } @Test @@ -120,7 +119,7 @@ public void test11() throws IOException { String cssFile = sourceFolder + "css11.css"; String cmpFile = sourceFolder + "cmp_css11.css"; CssStyleSheet styleSheet = CssStyleSheetParser.parse(FileUtil.getInputStreamForFile(cssFile)); - Assert.assertEquals(getCssFileContents(cmpFile), styleSheet.toString()); + Assertions.assertEquals(getCssFileContents(cmpFile), styleSheet.toString()); } @Test @@ -128,7 +127,7 @@ public void test12() throws IOException { String cssFile = sourceFolder + "css12.css"; String cmpFile = sourceFolder + "cmp_css12.css"; CssStyleSheet styleSheet = CssStyleSheetParser.parse(FileUtil.getInputStreamForFile(cssFile)); - Assert.assertEquals(getCssFileContents(cmpFile), styleSheet.toString()); + Assertions.assertEquals(getCssFileContents(cmpFile), styleSheet.toString()); } private String getCssFileContents(String filePath) throws IOException { diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/pseudo/CssPseudoElementNodeTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/pseudo/CssPseudoElementNodeTest.java index d7fe687caa..1086722740 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/pseudo/CssPseudoElementNodeTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/pseudo/CssPseudoElementNodeTest.java @@ -25,51 +25,50 @@ This file is part of the iText (R) project. import com.itextpdf.styledxmlparser.node.IAttribute; import com.itextpdf.styledxmlparser.node.IAttributes; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.util.HashMap; import java.util.Map; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class CssPseudoElementNodeTest extends ExtendedITextTest { @Test public void getPseudoElementNameTest() { CssPseudoElementNode pseudoElementNode = new CssPseudoElementNode(null, "after"); - Assert.assertEquals("after", pseudoElementNode.getPseudoElementName()); + Assertions.assertEquals("after", pseudoElementNode.getPseudoElementName()); } @Test public void getPseudoElementTagNameTest() { CssPseudoElementNode pseudoElementNode = new CssPseudoElementNode(null, "after"); - Assert.assertEquals("pseudo-element::after", pseudoElementNode.name()); + Assertions.assertEquals("pseudo-element::after", pseudoElementNode.name()); } @Test public void getAttributeStringTest() { CssPseudoElementNode pseudoElementNode = new CssPseudoElementNode(null, "after"); - Assert.assertNull(pseudoElementNode.getAttribute("after")); + Assertions.assertNull(pseudoElementNode.getAttribute("after")); } @Test public void getAttributesTest() { CssPseudoElementNode pseudoElementNode = new CssPseudoElementNode(null, "after"); - Assert.assertTrue(pseudoElementNode.getAttributes() instanceof IAttributes); - Assert.assertFalse(pseudoElementNode.getAttributes() == pseudoElementNode.getAttributes()); + Assertions.assertTrue(pseudoElementNode.getAttributes() instanceof IAttributes); + Assertions.assertFalse(pseudoElementNode.getAttributes() == pseudoElementNode.getAttributes()); } @Test public void getAdditionalHtmlStylesTest() { CssPseudoElementNode pseudoElementNode = new CssPseudoElementNode(null, "after"); - Assert.assertNull(pseudoElementNode.getAdditionalHtmlStyles()); + Assertions.assertNull(pseudoElementNode.getAdditionalHtmlStyles()); } @Test @@ -80,14 +79,14 @@ public void addAdditionalHtmlStylesTest() { styles.put("font-size", "12px"); styles.put("color", "red"); - Assert.assertThrows(UnsupportedOperationException.class, () -> pseudoElementNode.addAdditionalHtmlStyles(styles)); + Assertions.assertThrows(UnsupportedOperationException.class, () -> pseudoElementNode.addAdditionalHtmlStyles(styles)); } @Test public void getLangTest() { CssPseudoElementNode pseudoElementNode = new CssPseudoElementNode(null, "after"); - Assert.assertNull(pseudoElementNode.getLang()); + Assertions.assertNull(pseudoElementNode.getLang()); } @Test @@ -95,28 +94,28 @@ public void attributesStubSetAttributeTest() { CssPseudoElementNode pseudoElementNode = new CssPseudoElementNode(null, "after"); IAttributes attributes = pseudoElementNode.getAttributes(); - Assert.assertThrows(UnsupportedOperationException.class, () -> attributes.setAttribute("content", "iText")); + Assertions.assertThrows(UnsupportedOperationException.class, () -> attributes.setAttribute("content", "iText")); } @Test public void attributesStubGetSizeTest() { CssPseudoElementNode pseudoElementNode = new CssPseudoElementNode(null, "after"); - Assert.assertEquals(0, pseudoElementNode.getAttributes().size()); + Assertions.assertEquals(0, pseudoElementNode.getAttributes().size()); } @Test public void attributesStubGetAttributeTest() { CssPseudoElementNode pseudoElementNode = new CssPseudoElementNode(null, "after"); - Assert.assertNull(pseudoElementNode.getAttributes().getAttribute("after")); + Assertions.assertNull(pseudoElementNode.getAttributes().getAttribute("after")); } @Test public void attributesStubIteratorTest() { CssPseudoElementNode pseudoElementNode = new CssPseudoElementNode(null, "after"); for (IAttribute attr : pseudoElementNode.getAttributes()) { - Assert.fail("AttributesStub must return an empty iterator"); + Assertions.fail("AttributesStub must return an empty iterator"); } } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/pseudo/CssPseudoElementUtilTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/pseudo/CssPseudoElementUtilTest.java index ad04310ff1..decdd38655 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/pseudo/CssPseudoElementUtilTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/pseudo/CssPseudoElementUtilTest.java @@ -27,13 +27,11 @@ This file is part of the iText (R) project. import com.itextpdf.styledxmlparser.node.IElementNode; import com.itextpdf.styledxmlparser.node.impl.jsoup.node.JsoupElementNode; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; -@Category(UnitTest.class) +@org.junit.jupiter.api.Tag("UnitTest") public class CssPseudoElementUtilTest extends ExtendedITextTest { @Test @@ -41,17 +39,17 @@ public void createPseudoElementTagNameTest() { String beforePseudoElemName = CssPseudoElementUtil.createPseudoElementTagName("before"); String expected = "pseudo-element::before"; - Assert.assertEquals(expected, beforePseudoElemName); + Assertions.assertEquals(expected, beforePseudoElemName); } @Test public void hasBeforeAfterElementsNullScenarioTest() { - Assert.assertFalse(CssPseudoElementUtil.hasBeforeAfterElements(null)); + Assertions.assertFalse(CssPseudoElementUtil.hasBeforeAfterElements(null)); } @Test public void hasBeforeAfterElementsInstanceOfTest() { - Assert.assertFalse(CssPseudoElementUtil + Assertions.assertFalse(CssPseudoElementUtil .hasBeforeAfterElements(new CssPseudoElementNode(null, ""))); } @@ -60,7 +58,7 @@ public void hasBeforeAfterElementsNodeNameTest() { Element element = new Element(Tag.valueOf("pseudo-element::"), ""); IElementNode node = new JsoupElementNode(element); - Assert.assertFalse(CssPseudoElementUtil.hasBeforeAfterElements(node)); + Assertions.assertFalse(CssPseudoElementUtil.hasBeforeAfterElements(node)); } @Test @@ -68,7 +66,7 @@ public void hasAfterElementTest() { Element element = new Element(Tag.valueOf("after"), ""); IElementNode node = new JsoupElementNode(element); - Assert.assertTrue(CssPseudoElementUtil.hasBeforeAfterElements(node)); + Assertions.assertTrue(CssPseudoElementUtil.hasBeforeAfterElements(node)); } @Test @@ -76,6 +74,6 @@ public void hasBeforeElementTest() { Element element = new Element(Tag.valueOf("before"), ""); IElementNode node = new JsoupElementNode(element); - Assert.assertTrue(CssPseudoElementUtil.hasBeforeAfterElements(node)); + Assertions.assertTrue(CssPseudoElementUtil.hasBeforeAfterElements(node)); } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/CssDeclarationValueTokenizerTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/CssDeclarationValueTokenizerTest.java index 3588bd4735..16cc66c6d6 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/CssDeclarationValueTokenizerTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/CssDeclarationValueTokenizerTest.java @@ -24,16 +24,15 @@ This file is part of the iText (R) project. import com.itextpdf.styledxmlparser.css.parse.CssDeclarationValueTokenizer; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.util.Arrays; import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class CssDeclarationValueTokenizerTest extends ExtendedITextTest { @Test public void functionTest01() { @@ -101,13 +100,13 @@ public void functionWithSquareBracketsTest04() { private void runTest(String src, List tokenValues, List tokenTypes) { CssDeclarationValueTokenizer tokenizer = new CssDeclarationValueTokenizer(src); CssDeclarationValueTokenizer.Token token = null; - Assert.assertTrue("Value and type arrays size should be equal", tokenValues.size() == tokenTypes.size()); + Assertions.assertTrue(tokenValues.size() == tokenTypes.size(), "Value and type arrays size should be equal"); int index = 0; while ((token = tokenizer.getNextValidToken()) != null) { - Assert.assertEquals(tokenValues.get(index), token.getValue()); - Assert.assertEquals(tokenTypes.get(index), token.getType()); + Assertions.assertEquals(tokenValues.get(index), token.getValue()); + Assertions.assertEquals(tokenTypes.get(index), token.getType()); ++index; } - Assert.assertTrue(index == tokenValues.size()); + Assertions.assertTrue(index == tokenValues.size()); } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/CssInheritanceUnitTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/CssInheritanceUnitTest.java index a240dcaaee..94d096e43b 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/CssInheritanceUnitTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/CssInheritanceUnitTest.java @@ -24,23 +24,22 @@ This file is part of the iText (R) project. import com.itextpdf.styledxmlparser.css.CommonCssConstants; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class CssInheritanceUnitTest extends ExtendedITextTest { @Test public void isInheritablePositiveTest(){ IStyleInheritance cssInheritance = new CssInheritance(); - Assert.assertTrue(cssInheritance.isInheritable(CommonCssConstants.FONT_SIZE)); + Assertions.assertTrue(cssInheritance.isInheritable(CommonCssConstants.FONT_SIZE)); } @Test public void isInheritableNegativeTest(){ IStyleInheritance cssInheritance = new CssInheritance(); - Assert.assertFalse(cssInheritance.isInheritable(CommonCssConstants.FOCUS)); + Assertions.assertFalse(cssInheritance.isInheritable(CommonCssConstants.FOCUS)); } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/CssPropertyMergerUnitTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/CssPropertyMergerUnitTest.java index 6697ce1c3a..d25aa90528 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/CssPropertyMergerUnitTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/CssPropertyMergerUnitTest.java @@ -23,12 +23,11 @@ This file is part of the iText (R) project. package com.itextpdf.styledxmlparser.css.resolve; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class CssPropertyMergerUnitTest extends ExtendedITextTest { @Test @@ -39,7 +38,7 @@ public void mergeTextDecorationSimpleTest(){ String expected="underline strikethrough bold"; String actual = CssPropertyMerger.mergeTextDecoration(firstValue,secondValue); - Assert.assertEquals(expected,actual); + Assertions.assertEquals(expected,actual); } @Test @@ -50,7 +49,7 @@ public void mergeTextDecorationNormalizeFirstTest(){ String expected="underline strikethrough bold"; String actual = CssPropertyMerger.mergeTextDecoration(firstValue,secondValue); - Assert.assertEquals(expected,actual); + Assertions.assertEquals(expected,actual); } @@ -62,7 +61,7 @@ public void mergeTextDecorationNormalizeSecondTest(){ String expected="underline strikethrough bold"; String actual = CssPropertyMerger.mergeTextDecoration(firstValue,secondValue); - Assert.assertEquals(expected,actual); + Assertions.assertEquals(expected,actual); } @Test @@ -73,7 +72,7 @@ public void mergeTextDecorationFirstNullTest(){ String expected="strikethrough bold"; String actual = CssPropertyMerger.mergeTextDecoration(firstValue,secondValue); - Assert.assertEquals(expected,actual); + Assertions.assertEquals(expected,actual); } @Test @@ -84,7 +83,7 @@ public void mergeTextDecorationSecondNullTest(){ String expected="underline"; String actual = CssPropertyMerger.mergeTextDecoration(firstValue,secondValue); - Assert.assertEquals(expected,actual); + Assertions.assertEquals(expected,actual); } @Test @@ -95,7 +94,7 @@ public void mergeTextDecorationBothNullTest(){ String expected=null; String actual = CssPropertyMerger.mergeTextDecoration(firstValue,secondValue); - Assert.assertEquals(expected,actual); + Assertions.assertEquals(expected,actual); } @@ -107,7 +106,7 @@ public void mergeTextDecorationEmpyInputsTest(){ String expected="none"; String actual = CssPropertyMerger.mergeTextDecoration(firstValue,secondValue); - Assert.assertEquals(expected,actual); + Assertions.assertEquals(expected,actual); } @Test @@ -118,7 +117,7 @@ public void mergeTextDecorationSecondInputContainsNoneTest(){ String expected="underline"; String actual = CssPropertyMerger.mergeTextDecoration(firstValue,secondValue); - Assert.assertEquals(expected,actual); + Assertions.assertEquals(expected,actual); } @Test @@ -129,7 +128,7 @@ public void mergeTextDecorationFirstInputNoneTest(){ String expected="strikethrough"; String actual = CssPropertyMerger.mergeTextDecoration(firstValue,secondValue); - Assert.assertEquals(expected,actual); + Assertions.assertEquals(expected,actual); } @Test @@ -140,7 +139,7 @@ public void mergeTextDecorationBothInputsNoneTest(){ String expected="none"; String actual = CssPropertyMerger.mergeTextDecoration(firstValue,secondValue); - Assert.assertEquals(expected,actual); + Assertions.assertEquals(expected,actual); } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/shorthand/BackgroundPositionShorthandResolverTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/shorthand/BackgroundPositionShorthandResolverTest.java index ae9b4b5abc..6f55b94dcb 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/shorthand/BackgroundPositionShorthandResolverTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/shorthand/BackgroundPositionShorthandResolverTest.java @@ -28,19 +28,18 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Set; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotNull; -@Category(UnitTest.class) +@Tag("UnitTest") public class BackgroundPositionShorthandResolverTest extends ExtendedITextTest { @Test diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/shorthand/BackgroundShorthandResolverTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/shorthand/BackgroundShorthandResolverTest.java index a8d7b282fa..a8c32b99b1 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/shorthand/BackgroundShorthandResolverTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/shorthand/BackgroundShorthandResolverTest.java @@ -27,9 +27,8 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.util.ArrayList; import java.util.Arrays; @@ -37,9 +36,9 @@ This file is part of the iText (R) project. import java.util.List; import java.util.Set; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotNull; -@Category(UnitTest.class) +@Tag("UnitTest") public class BackgroundShorthandResolverTest extends ExtendedITextTest { @Test diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/shorthand/BorderRadiusShorthandResolverTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/shorthand/BorderRadiusShorthandResolverTest.java index 4a16d42bb7..38b90f94b9 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/shorthand/BorderRadiusShorthandResolverTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/shorthand/BorderRadiusShorthandResolverTest.java @@ -25,18 +25,17 @@ This file is part of the iText (R) project. import com.itextpdf.styledxmlparser.css.CommonCssConstants; import com.itextpdf.styledxmlparser.css.CssDeclaration; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Set; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotNull; -@Category(UnitTest.class) +@Tag("UnitTest") public class BorderRadiusShorthandResolverTest extends ExtendedITextTest { @Test diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/shorthand/ColumnsShorthandResolverTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/shorthand/ColumnsShorthandResolverTest.java index dc8f0ba61d..6674939b18 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/shorthand/ColumnsShorthandResolverTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/shorthand/ColumnsShorthandResolverTest.java @@ -29,15 +29,14 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.UnitTest; import java.util.Collections; import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class ColumnsShorthandResolverTest extends ExtendedITextTest { @Test public void initialOrInheritOrUnsetValuesTest() { @@ -45,27 +44,27 @@ public void initialOrInheritOrUnsetValuesTest() { String initialShorthand = CommonCssConstants.INITIAL; List resolvedShorthand = resolver.resolveShorthand(initialShorthand); - Assert.assertEquals(2, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.COLUMN_COUNT, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals(CommonCssConstants.INITIAL, resolvedShorthand.get(0).getExpression()); - Assert.assertEquals(CommonCssConstants.COLUMN_WIDTH, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals(CommonCssConstants.INITIAL, resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals(2, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.COLUMN_COUNT, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals(CommonCssConstants.INITIAL, resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(CommonCssConstants.COLUMN_WIDTH, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals(CommonCssConstants.INITIAL, resolvedShorthand.get(1).getExpression()); String inheritShorthand = CommonCssConstants.INHERIT; resolvedShorthand = resolver.resolveShorthand(inheritShorthand); - Assert.assertEquals(2, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.COLUMN_COUNT, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals(CommonCssConstants.INHERIT, resolvedShorthand.get(0).getExpression()); - Assert.assertEquals(CommonCssConstants.COLUMN_WIDTH, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals(CommonCssConstants.INHERIT, resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals(2, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.COLUMN_COUNT, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals(CommonCssConstants.INHERIT, resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(CommonCssConstants.COLUMN_WIDTH, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals(CommonCssConstants.INHERIT, resolvedShorthand.get(1).getExpression()); String unsetShorthand = CommonCssConstants.UNSET; resolvedShorthand = resolver.resolveShorthand(unsetShorthand); - Assert.assertEquals(2, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.COLUMN_COUNT, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals(CommonCssConstants.UNSET, resolvedShorthand.get(0).getExpression()); - Assert.assertEquals(CommonCssConstants.COLUMN_WIDTH, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals(CommonCssConstants.UNSET, resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals(2, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.COLUMN_COUNT, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals(CommonCssConstants.UNSET, resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(CommonCssConstants.COLUMN_WIDTH, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals(CommonCssConstants.UNSET, resolvedShorthand.get(1).getExpression()); } @Test @@ -73,10 +72,10 @@ public void initialOrInheritOrUnsetValuesTest() { public void emptyShorthandTest() { IShorthandResolver resolver = new ColumnsShorthandResolver(); String emptyShorthand = ""; - Assert.assertEquals(Collections.emptyList(), resolver.resolveShorthand(emptyShorthand)); + Assertions.assertEquals(Collections.emptyList(), resolver.resolveShorthand(emptyShorthand)); String shorthandWithSpaces = " "; - Assert.assertEquals(Collections.emptyList(), resolver.resolveShorthand(shorthandWithSpaces)); + Assertions.assertEquals(Collections.emptyList(), resolver.resolveShorthand(shorthandWithSpaces)); } @Test @@ -86,9 +85,9 @@ public void columnsWithOneAbsoluteValueTest() { String shorthand = "10px"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(1, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.COLUMN_WIDTH, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals("10px", resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(1, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.COLUMN_WIDTH, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals("10px", resolvedShorthand.get(0).getExpression()); } @Test @@ -98,9 +97,9 @@ public void columnWithOneMetricValueTest() { String shorthand = "10px"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(1, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.COLUMN_WIDTH, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals("10px", resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(1, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.COLUMN_WIDTH, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals("10px", resolvedShorthand.get(0).getExpression()); } @Test @@ -110,9 +109,9 @@ public void columnWithOneRelativeValueTest() { String shorthand = "10em"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(1, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.COLUMN_WIDTH, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals("10em", resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(1, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.COLUMN_WIDTH, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals("10em", resolvedShorthand.get(0).getExpression()); } @Test @@ -122,9 +121,9 @@ public void columnWithColumnCountTest() { String shorthand = "3"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(1, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.COLUMN_COUNT, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals("3", resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(1, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.COLUMN_COUNT, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals("3", resolvedShorthand.get(0).getExpression()); } @Test @@ -134,7 +133,7 @@ public void columnWithAutoValuesTest() { String shorthand = "auto auto"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertTrue(resolvedShorthand.isEmpty()); + Assertions.assertTrue(resolvedShorthand.isEmpty()); } @Test @@ -144,9 +143,9 @@ public void columnWithAutoAndRelativeValueTest() { String shorthand = "3em auto"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(1, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.COLUMN_WIDTH, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals("3em", resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(1, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.COLUMN_WIDTH, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals("3em", resolvedShorthand.get(0).getExpression()); } @Test @@ -156,9 +155,9 @@ public void columnWithRelativeAndAutoValueTest() { String shorthand = "auto 3em"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(1, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.COLUMN_WIDTH, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals("3em", resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(1, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.COLUMN_WIDTH, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals("3em", resolvedShorthand.get(0).getExpression()); } @Test @@ -168,11 +167,11 @@ public void columnWithRelativeAndCountValueTest() { String shorthand = "12 3em"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(2, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.COLUMN_COUNT, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals("12", resolvedShorthand.get(0).getExpression()); - Assert.assertEquals(CommonCssConstants.COLUMN_WIDTH, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals("3em", resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals(2, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.COLUMN_COUNT, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals("12", resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(CommonCssConstants.COLUMN_WIDTH, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals("3em", resolvedShorthand.get(1).getExpression()); } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/shorthand/CssShorthandResolverTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/shorthand/CssShorthandResolverTest.java index 27ca9310dd..906d40b078 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/shorthand/CssShorthandResolverTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/shorthand/CssShorthandResolverTest.java @@ -25,7 +25,6 @@ This file is part of the iText (R) project. import com.itextpdf.styledxmlparser.css.CommonCssConstants; import com.itextpdf.styledxmlparser.css.CssDeclaration; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.util.Set; import java.util.HashSet; @@ -33,13 +32,13 @@ This file is part of the iText (R) project. import java.util.List; import java.util.TreeSet; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotNull; -@Category(UnitTest.class) +@Tag("UnitTest") public class CssShorthandResolverTest extends ExtendedITextTest { @Test @@ -532,7 +531,7 @@ public void linearGradientInlistStyleImageTest() { )); IShorthandResolver resolver = ShorthandResolverFactory.getShorthandResolver(com.itextpdf.styledxmlparser.css.CommonCssConstants.LIST_STYLE); - Assert.assertNotNull(resolver); + Assertions.assertNotNull(resolver); List resolvedShorthandProps = resolver.resolveShorthand(shorthandExpression); compareResolvedProps(resolvedShorthandProps, expectedResolvedProperties); } @@ -547,7 +546,7 @@ public void repeatingLinearGradientInlistStyleImageTest() { )); IShorthandResolver resolver = ShorthandResolverFactory.getShorthandResolver(com.itextpdf.styledxmlparser.css.CommonCssConstants.LIST_STYLE); - Assert.assertNotNull(resolver); + Assertions.assertNotNull(resolver); List resolvedShorthandProps = resolver.resolveShorthand(shorthandExpression); compareResolvedProps(resolvedShorthandProps, expectedResolvedProperties); } @@ -562,7 +561,7 @@ public void noneInlistStyleImageTest() { )); IShorthandResolver resolver = ShorthandResolverFactory.getShorthandResolver(com.itextpdf.styledxmlparser.css.CommonCssConstants.LIST_STYLE); - Assert.assertNotNull(resolver); + Assertions.assertNotNull(resolver); List resolvedShorthandProps = resolver.resolveShorthand(shorthandExpression); compareResolvedProps(resolvedShorthandProps, expectedResolvedProperties); } @@ -580,7 +579,7 @@ public void fontTest01() { )); IShorthandResolver resolver = ShorthandResolverFactory.getShorthandResolver(com.itextpdf.styledxmlparser.css.CommonCssConstants.FONT); - Assert.assertNotNull(resolver); + Assertions.assertNotNull(resolver); List resolvedShorthandProps = resolver.resolveShorthand(shorthandExpression); compareResolvedProps(resolvedShorthandProps, expectedResolvedProperties); } @@ -598,7 +597,7 @@ public void fontTest02() { )); IShorthandResolver resolver = ShorthandResolverFactory.getShorthandResolver(com.itextpdf.styledxmlparser.css.CommonCssConstants.FONT); - Assert.assertNotNull(resolver); + Assertions.assertNotNull(resolver); List resolvedShorthandProps = resolver.resolveShorthand(shorthandExpression); compareResolvedProps(resolvedShorthandProps, expectedResolvedProperties); } @@ -616,7 +615,7 @@ public void fontTest03() { )); IShorthandResolver resolver = ShorthandResolverFactory.getShorthandResolver(com.itextpdf.styledxmlparser.css.CommonCssConstants.FONT); - Assert.assertNotNull(resolver); + Assertions.assertNotNull(resolver); List resolvedShorthandProps = resolver.resolveShorthand(shorthandExpression); compareResolvedProps(resolvedShorthandProps, expectedResolvedProperties); } @@ -634,7 +633,7 @@ public void fontTest04() { )); IShorthandResolver resolver = ShorthandResolverFactory.getShorthandResolver(com.itextpdf.styledxmlparser.css.CommonCssConstants.FONT); - Assert.assertNotNull(resolver); + Assertions.assertNotNull(resolver); List resolvedShorthandProps = resolver.resolveShorthand(shorthandExpression); compareResolvedProps(resolvedShorthandProps, expectedResolvedProperties); } @@ -652,7 +651,7 @@ public void fontTest05() { )); IShorthandResolver resolver = ShorthandResolverFactory.getShorthandResolver(com.itextpdf.styledxmlparser.css.CommonCssConstants.FONT); - Assert.assertNotNull(resolver); + Assertions.assertNotNull(resolver); List resolvedShorthandProps = resolver.resolveShorthand(shorthandExpression); compareResolvedProps(resolvedShorthandProps, expectedResolvedProperties); } @@ -670,7 +669,7 @@ public void fontTest06() { )); IShorthandResolver resolver = ShorthandResolverFactory.getShorthandResolver(com.itextpdf.styledxmlparser.css.CommonCssConstants.FONT); - Assert.assertNotNull(resolver); + Assertions.assertNotNull(resolver); List resolvedShorthandProps = resolver.resolveShorthand(shorthandExpression); compareResolvedProps(resolvedShorthandProps, expectedResolvedProperties); } @@ -688,7 +687,7 @@ public void fontTest07() { )); IShorthandResolver resolver = ShorthandResolverFactory.getShorthandResolver(com.itextpdf.styledxmlparser.css.CommonCssConstants.FONT); - Assert.assertNotNull(resolver); + Assertions.assertNotNull(resolver); List resolvedShorthandProps = resolver.resolveShorthand(shorthandExpression); compareResolvedProps(resolvedShorthandProps, expectedResolvedProperties); } @@ -706,7 +705,7 @@ public void fontTest08() { )); IShorthandResolver resolver = ShorthandResolverFactory.getShorthandResolver(com.itextpdf.styledxmlparser.css.CommonCssConstants.FONT); - Assert.assertNotNull(resolver); + Assertions.assertNotNull(resolver); List resolvedShorthandProps = resolver.resolveShorthand(shorthandExpression); compareResolvedProps(resolvedShorthandProps, expectedResolvedProperties); } @@ -724,7 +723,7 @@ public void fontTest09() { )); IShorthandResolver resolver = ShorthandResolverFactory.getShorthandResolver(com.itextpdf.styledxmlparser.css.CommonCssConstants.FONT); - Assert.assertNotNull(resolver); + Assertions.assertNotNull(resolver); List resolvedShorthandProps = resolver.resolveShorthand(shorthandExpression); compareResolvedProps(resolvedShorthandProps, expectedResolvedProperties); } @@ -758,7 +757,7 @@ static void compareResolvedProps(List actual, Set expect } if (areDifferent) { - Assert.fail(sb.toString()); + Assertions.fail(sb.toString()); } } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/shorthand/FlexFlowShorthandResolverTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/shorthand/FlexFlowShorthandResolverTest.java index c7acc75e64..a839f14692 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/shorthand/FlexFlowShorthandResolverTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/shorthand/FlexFlowShorthandResolverTest.java @@ -29,15 +29,14 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.util.Collections; import java.util.List; -@Category(UnitTest.class) +@Tag("UnitTest") public class FlexFlowShorthandResolverTest extends ExtendedITextTest { @Test public void initialOrInheritOrUnsetValuesTest() { @@ -45,27 +44,27 @@ public void initialOrInheritOrUnsetValuesTest() { String initialShorthand = CommonCssConstants.INITIAL; List resolvedShorthand = resolver.resolveShorthand(initialShorthand); - Assert.assertEquals(2, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.FLEX_DIRECTION, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals(CommonCssConstants.INITIAL, resolvedShorthand.get(0).getExpression()); - Assert.assertEquals(CommonCssConstants.FLEX_WRAP, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals(CommonCssConstants.INITIAL, resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals(2, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.FLEX_DIRECTION, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals(CommonCssConstants.INITIAL, resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(CommonCssConstants.FLEX_WRAP, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals(CommonCssConstants.INITIAL, resolvedShorthand.get(1).getExpression()); String inheritShorthand = CommonCssConstants.INHERIT; resolvedShorthand = resolver.resolveShorthand(inheritShorthand); - Assert.assertEquals(2, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.FLEX_DIRECTION, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals(CommonCssConstants.INHERIT, resolvedShorthand.get(0).getExpression()); - Assert.assertEquals(CommonCssConstants.FLEX_WRAP, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals(CommonCssConstants.INHERIT, resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals(2, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.FLEX_DIRECTION, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals(CommonCssConstants.INHERIT, resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(CommonCssConstants.FLEX_WRAP, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals(CommonCssConstants.INHERIT, resolvedShorthand.get(1).getExpression()); String unsetShorthand = CommonCssConstants.UNSET; resolvedShorthand = resolver.resolveShorthand(unsetShorthand); - Assert.assertEquals(2, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.FLEX_DIRECTION, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals(CommonCssConstants.UNSET, resolvedShorthand.get(0).getExpression()); - Assert.assertEquals(CommonCssConstants.FLEX_WRAP, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals(CommonCssConstants.UNSET, resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals(2, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.FLEX_DIRECTION, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals(CommonCssConstants.UNSET, resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(CommonCssConstants.FLEX_WRAP, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals(CommonCssConstants.UNSET, resolvedShorthand.get(1).getExpression()); } @Test @@ -74,11 +73,11 @@ public void initialWithSpacesTest() { String initialWithSpacesShorthand = " initial "; List resolvedShorthand = resolver.resolveShorthand(initialWithSpacesShorthand); - Assert.assertEquals(2, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.FLEX_DIRECTION, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals(CommonCssConstants.INITIAL, resolvedShorthand.get(0).getExpression()); - Assert.assertEquals(CommonCssConstants.FLEX_WRAP, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals(CommonCssConstants.INITIAL, resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals(2, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.FLEX_DIRECTION, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals(CommonCssConstants.INITIAL, resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(CommonCssConstants.FLEX_WRAP, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals(CommonCssConstants.INITIAL, resolvedShorthand.get(1).getExpression()); } @Test @@ -87,13 +86,13 @@ public void containsInitialOrInheritOrUnsetShorthandTest() { IShorthandResolver resolver = new FlexFlowShorthandResolver(); String containsInitialShorthand = "row initial "; - Assert.assertEquals(Collections.emptyList(), resolver.resolveShorthand(containsInitialShorthand)); + Assertions.assertEquals(Collections.emptyList(), resolver.resolveShorthand(containsInitialShorthand)); String containsInheritShorthand = "inherit wrap"; - Assert.assertEquals(Collections.emptyList(), resolver.resolveShorthand(containsInheritShorthand)); + Assertions.assertEquals(Collections.emptyList(), resolver.resolveShorthand(containsInheritShorthand)); String containsUnsetShorthand = "wrap unset"; - Assert.assertEquals(Collections.emptyList(), resolver.resolveShorthand(containsUnsetShorthand)); + Assertions.assertEquals(Collections.emptyList(), resolver.resolveShorthand(containsUnsetShorthand)); } @Test @@ -101,10 +100,10 @@ public void containsInitialOrInheritOrUnsetShorthandTest() { public void emptyShorthandTest() { IShorthandResolver resolver = new FlexFlowShorthandResolver(); String emptyShorthand = ""; - Assert.assertEquals(Collections.emptyList(), resolver.resolveShorthand(emptyShorthand)); + Assertions.assertEquals(Collections.emptyList(), resolver.resolveShorthand(emptyShorthand)); String shorthandWithSpaces = " "; - Assert.assertEquals(Collections.emptyList(), resolver.resolveShorthand(shorthandWithSpaces)); + Assertions.assertEquals(Collections.emptyList(), resolver.resolveShorthand(shorthandWithSpaces)); } @Test @@ -114,11 +113,11 @@ public void shorthandWithOneDirectionValueTest() { String shorthand = "column"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(2, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.FLEX_DIRECTION, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals("column", resolvedShorthand.get(0).getExpression()); - Assert.assertEquals(CommonCssConstants.FLEX_WRAP, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals("nowrap", resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals(2, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.FLEX_DIRECTION, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals("column", resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(CommonCssConstants.FLEX_WRAP, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals("nowrap", resolvedShorthand.get(1).getExpression()); } @Test @@ -128,11 +127,11 @@ public void shorthandWithOneWrapValueTest() { String shorthand = CommonCssConstants.WRAP_REVERSE; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(2, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.FLEX_WRAP, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals(CommonCssConstants.WRAP_REVERSE, resolvedShorthand.get(0).getExpression()); - Assert.assertEquals(CommonCssConstants.FLEX_DIRECTION, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals(CommonCssConstants.ROW, resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals(2, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.FLEX_WRAP, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals(CommonCssConstants.WRAP_REVERSE, resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(CommonCssConstants.FLEX_DIRECTION, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals(CommonCssConstants.ROW, resolvedShorthand.get(1).getExpression()); } @Test @@ -143,7 +142,7 @@ public void shorthandWithOneInvalidValueTest() { String shorthand = "invalid"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(0, resolvedShorthand.size()); + Assertions.assertEquals(0, resolvedShorthand.size()); } @Test @@ -153,10 +152,10 @@ public void shorthandWithDirectionAndWrapValuesTest() { String shorthand = CommonCssConstants.ROW_REVERSE + " " + CommonCssConstants.WRAP; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(CommonCssConstants.FLEX_DIRECTION, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals(CommonCssConstants.ROW_REVERSE, resolvedShorthand.get(0).getExpression()); - Assert.assertEquals(CommonCssConstants.FLEX_WRAP, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals(CommonCssConstants.WRAP, resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals(CommonCssConstants.FLEX_DIRECTION, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals(CommonCssConstants.ROW_REVERSE, resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(CommonCssConstants.FLEX_WRAP, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals(CommonCssConstants.WRAP, resolvedShorthand.get(1).getExpression()); } @Test @@ -166,10 +165,10 @@ public void shorthandWithWrapAndDirectionValuesTest() { String shorthand = "wrap-reverse column"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(CommonCssConstants.FLEX_DIRECTION, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals(CommonCssConstants.COLUMN, resolvedShorthand.get(0).getExpression()); - Assert.assertEquals(CommonCssConstants.FLEX_WRAP, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals(CommonCssConstants.WRAP_REVERSE, resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals(CommonCssConstants.FLEX_DIRECTION, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals(CommonCssConstants.COLUMN, resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(CommonCssConstants.FLEX_WRAP, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals(CommonCssConstants.WRAP_REVERSE, resolvedShorthand.get(1).getExpression()); } @Test @@ -180,7 +179,7 @@ public void shorthandWithTwoDirectionValuesTest() { String shorthand = "column-reverse row"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(Collections.emptyList(), resolvedShorthand); + Assertions.assertEquals(Collections.emptyList(), resolvedShorthand); } @Test @@ -191,7 +190,7 @@ public void shorthandWithTwoWrapValuesTest() { String shorthand = "nowrap wrap-reverse"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(Collections.emptyList(), resolvedShorthand); + Assertions.assertEquals(Collections.emptyList(), resolvedShorthand); } @Test @@ -202,6 +201,6 @@ public void shorthandWithTwoValuesAndSecondIsInvalidTest() { String shorthand = "column-reverse invalid"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(Collections.emptyList(), resolvedShorthand); + Assertions.assertEquals(Collections.emptyList(), resolvedShorthand); } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/shorthand/FlexShorthandResolverTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/shorthand/FlexShorthandResolverTest.java index 28534a7898..bf400ad690 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/shorthand/FlexShorthandResolverTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/shorthand/FlexShorthandResolverTest.java @@ -29,25 +29,24 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.util.Collections; import java.util.List; -@Category(UnitTest.class) +@Tag("UnitTest") public class FlexShorthandResolverTest extends ExtendedITextTest { @Test @LogMessages(messages = @LogMessage(messageTemplate = StyledXmlParserLogMessageConstant.SHORTHAND_PROPERTY_CANNOT_BE_EMPTY, count = 2)) public void emptyShorthandTest() { String emptyShorthand = ""; IShorthandResolver resolver = new FlexShorthandResolver(); - Assert.assertEquals(Collections.emptyList(), resolver.resolveShorthand(emptyShorthand)); + Assertions.assertEquals(Collections.emptyList(), resolver.resolveShorthand(emptyShorthand)); String shorthandWithSpaces = " "; - Assert.assertEquals(Collections.emptyList(), resolver.resolveShorthand(shorthandWithSpaces)); + Assertions.assertEquals(Collections.emptyList(), resolver.resolveShorthand(shorthandWithSpaces)); } @Test @@ -55,33 +54,33 @@ public void initialOrInheritOrUnsetShorthandTest() { String initialShorthand = CommonCssConstants.INITIAL; IShorthandResolver resolver = new FlexShorthandResolver(); List resolvedShorthand = resolver.resolveShorthand(initialShorthand); - Assert.assertEquals(3, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.FLEX_GROW, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals(CommonCssConstants.INITIAL, resolvedShorthand.get(0).getExpression()); - Assert.assertEquals(CommonCssConstants.FLEX_SHRINK, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals(CommonCssConstants.INITIAL, resolvedShorthand.get(1).getExpression()); - Assert.assertEquals(CommonCssConstants.FLEX_BASIS, resolvedShorthand.get(2).getProperty()); - Assert.assertEquals(CommonCssConstants.INITIAL, resolvedShorthand.get(2).getExpression()); + Assertions.assertEquals(3, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.FLEX_GROW, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals(CommonCssConstants.INITIAL, resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(CommonCssConstants.FLEX_SHRINK, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals(CommonCssConstants.INITIAL, resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals(CommonCssConstants.FLEX_BASIS, resolvedShorthand.get(2).getProperty()); + Assertions.assertEquals(CommonCssConstants.INITIAL, resolvedShorthand.get(2).getExpression()); String inheritShorthand = CommonCssConstants.INHERIT; resolvedShorthand = resolver.resolveShorthand(inheritShorthand); - Assert.assertEquals(3, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.FLEX_GROW, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals(CommonCssConstants.INHERIT, resolvedShorthand.get(0).getExpression()); - Assert.assertEquals(CommonCssConstants.FLEX_SHRINK, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals(CommonCssConstants.INHERIT, resolvedShorthand.get(1).getExpression()); - Assert.assertEquals(CommonCssConstants.FLEX_BASIS, resolvedShorthand.get(2).getProperty()); - Assert.assertEquals(CommonCssConstants.INHERIT, resolvedShorthand.get(2).getExpression()); + Assertions.assertEquals(3, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.FLEX_GROW, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals(CommonCssConstants.INHERIT, resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(CommonCssConstants.FLEX_SHRINK, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals(CommonCssConstants.INHERIT, resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals(CommonCssConstants.FLEX_BASIS, resolvedShorthand.get(2).getProperty()); + Assertions.assertEquals(CommonCssConstants.INHERIT, resolvedShorthand.get(2).getExpression()); String unsetShorthand = CommonCssConstants.UNSET; resolvedShorthand = resolver.resolveShorthand(unsetShorthand); - Assert.assertEquals(3, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.FLEX_GROW, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals(CommonCssConstants.UNSET, resolvedShorthand.get(0).getExpression()); - Assert.assertEquals(CommonCssConstants.FLEX_SHRINK, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals(CommonCssConstants.UNSET, resolvedShorthand.get(1).getExpression()); - Assert.assertEquals(CommonCssConstants.FLEX_BASIS, resolvedShorthand.get(2).getProperty()); - Assert.assertEquals(CommonCssConstants.UNSET, resolvedShorthand.get(2).getExpression()); + Assertions.assertEquals(3, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.FLEX_GROW, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals(CommonCssConstants.UNSET, resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(CommonCssConstants.FLEX_SHRINK, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals(CommonCssConstants.UNSET, resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals(CommonCssConstants.FLEX_BASIS, resolvedShorthand.get(2).getProperty()); + Assertions.assertEquals(CommonCssConstants.UNSET, resolvedShorthand.get(2).getExpression()); } @Test @@ -90,13 +89,13 @@ public void initialWithSpacesTest() { String initialWithSpacesShorthand = " initial "; List resolvedShorthand = resolver.resolveShorthand(initialWithSpacesShorthand); - Assert.assertEquals(3, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.FLEX_GROW, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals(CommonCssConstants.INITIAL, resolvedShorthand.get(0).getExpression()); - Assert.assertEquals(CommonCssConstants.FLEX_SHRINK, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals(CommonCssConstants.INITIAL, resolvedShorthand.get(1).getExpression()); - Assert.assertEquals(CommonCssConstants.FLEX_BASIS, resolvedShorthand.get(2).getProperty()); - Assert.assertEquals(CommonCssConstants.INITIAL, resolvedShorthand.get(2).getExpression()); + Assertions.assertEquals(3, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.FLEX_GROW, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals(CommonCssConstants.INITIAL, resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(CommonCssConstants.FLEX_SHRINK, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals(CommonCssConstants.INITIAL, resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals(CommonCssConstants.FLEX_BASIS, resolvedShorthand.get(2).getProperty()); + Assertions.assertEquals(CommonCssConstants.INITIAL, resolvedShorthand.get(2).getExpression()); } @Test @@ -104,13 +103,13 @@ public void autoShorthandTest() { String initialShorthand = CommonCssConstants.AUTO; IShorthandResolver resolver = new FlexShorthandResolver(); List resolvedShorthand = resolver.resolveShorthand(initialShorthand); - Assert.assertEquals(3, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.FLEX_GROW, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals("1", resolvedShorthand.get(0).getExpression()); - Assert.assertEquals(CommonCssConstants.FLEX_SHRINK, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals("1", resolvedShorthand.get(1).getExpression()); - Assert.assertEquals(CommonCssConstants.FLEX_BASIS, resolvedShorthand.get(2).getProperty()); - Assert.assertEquals(CommonCssConstants.AUTO, resolvedShorthand.get(2).getExpression()); + Assertions.assertEquals(3, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.FLEX_GROW, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals("1", resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(CommonCssConstants.FLEX_SHRINK, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals("1", resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals(CommonCssConstants.FLEX_BASIS, resolvedShorthand.get(2).getProperty()); + Assertions.assertEquals(CommonCssConstants.AUTO, resolvedShorthand.get(2).getExpression()); } @Test @@ -118,13 +117,13 @@ public void noneShorthandTest() { String initialShorthand = CommonCssConstants.NONE; IShorthandResolver resolver = new FlexShorthandResolver(); List resolvedShorthand = resolver.resolveShorthand(initialShorthand); - Assert.assertEquals(3, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.FLEX_GROW, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals("0", resolvedShorthand.get(0).getExpression()); - Assert.assertEquals(CommonCssConstants.FLEX_SHRINK, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals("0", resolvedShorthand.get(1).getExpression()); - Assert.assertEquals(CommonCssConstants.FLEX_BASIS, resolvedShorthand.get(2).getProperty()); - Assert.assertEquals(CommonCssConstants.AUTO, resolvedShorthand.get(2).getExpression()); + Assertions.assertEquals(3, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.FLEX_GROW, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals("0", resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(CommonCssConstants.FLEX_SHRINK, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals("0", resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals(CommonCssConstants.FLEX_BASIS, resolvedShorthand.get(2).getProperty()); + Assertions.assertEquals(CommonCssConstants.AUTO, resolvedShorthand.get(2).getExpression()); } @Test @@ -133,13 +132,13 @@ public void containsInitialOrInheritOrUnsetShorthandTest() { IShorthandResolver resolver = new FlexShorthandResolver(); String containsInitialShorthand = "1 initial 50px"; - Assert.assertEquals(Collections.emptyList(), resolver.resolveShorthand(containsInitialShorthand)); + Assertions.assertEquals(Collections.emptyList(), resolver.resolveShorthand(containsInitialShorthand)); String containsInheritShorthand = "inherit 2 50px"; - Assert.assertEquals(Collections.emptyList(), resolver.resolveShorthand(containsInheritShorthand)); + Assertions.assertEquals(Collections.emptyList(), resolver.resolveShorthand(containsInheritShorthand)); String containsUnsetShorthand = "0 2 unset"; - Assert.assertEquals(Collections.emptyList(), resolver.resolveShorthand(containsUnsetShorthand)); + Assertions.assertEquals(Collections.emptyList(), resolver.resolveShorthand(containsUnsetShorthand)); } @Test @@ -149,13 +148,13 @@ public void shorthandWithOneUnitlessNumberValueTest() { String shorthand = "5"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(3, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.FLEX_GROW, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals("5", resolvedShorthand.get(0).getExpression()); - Assert.assertEquals(CommonCssConstants.FLEX_SHRINK, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals("1", resolvedShorthand.get(1).getExpression()); - Assert.assertEquals(CommonCssConstants.FLEX_BASIS, resolvedShorthand.get(2).getProperty()); - Assert.assertEquals("0", resolvedShorthand.get(2).getExpression()); + Assertions.assertEquals(3, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.FLEX_GROW, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals("5", resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(CommonCssConstants.FLEX_SHRINK, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals("1", resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals(CommonCssConstants.FLEX_BASIS, resolvedShorthand.get(2).getProperty()); + Assertions.assertEquals("0", resolvedShorthand.get(2).getExpression()); } @Test @@ -165,13 +164,13 @@ public void shorthandWithOneUnitNumberValueTest() { String shorthand = "5px"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(3, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.FLEX_BASIS, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals("5px", resolvedShorthand.get(0).getExpression()); - Assert.assertEquals(CommonCssConstants.FLEX_GROW, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals("0", resolvedShorthand.get(1).getExpression()); - Assert.assertEquals(CommonCssConstants.FLEX_SHRINK, resolvedShorthand.get(2).getProperty()); - Assert.assertEquals("1", resolvedShorthand.get(2).getExpression()); + Assertions.assertEquals(3, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.FLEX_BASIS, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals("5px", resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(CommonCssConstants.FLEX_GROW, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals("0", resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals(CommonCssConstants.FLEX_SHRINK, resolvedShorthand.get(2).getProperty()); + Assertions.assertEquals("1", resolvedShorthand.get(2).getExpression()); } @Test @@ -182,7 +181,7 @@ public void shorthandWithOneInvalidValueTest() { String shorthand = "5pixels"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(0, resolvedShorthand.size()); + Assertions.assertEquals(0, resolvedShorthand.size()); } @Test @@ -192,13 +191,13 @@ public void shorthandWithTwoUnitlessNumberValuesTest() { String shorthand = "5 7"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(3, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.FLEX_GROW, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals("5", resolvedShorthand.get(0).getExpression()); - Assert.assertEquals(CommonCssConstants.FLEX_SHRINK, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals("7", resolvedShorthand.get(1).getExpression()); - Assert.assertEquals(CommonCssConstants.FLEX_BASIS, resolvedShorthand.get(2).getProperty()); - Assert.assertEquals("0", resolvedShorthand.get(2).getExpression()); + Assertions.assertEquals(3, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.FLEX_GROW, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals("5", resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(CommonCssConstants.FLEX_SHRINK, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals("7", resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals(CommonCssConstants.FLEX_BASIS, resolvedShorthand.get(2).getProperty()); + Assertions.assertEquals("0", resolvedShorthand.get(2).getExpression()); } @Test @@ -208,13 +207,13 @@ public void shorthandWithUnitlessAndUnitNumberValuesTest() { String shorthand = "5 7px"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(3, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.FLEX_GROW, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals("5", resolvedShorthand.get(0).getExpression()); - Assert.assertEquals(CommonCssConstants.FLEX_BASIS, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals("7px", resolvedShorthand.get(1).getExpression()); - Assert.assertEquals(CommonCssConstants.FLEX_SHRINK, resolvedShorthand.get(2).getProperty()); - Assert.assertEquals("1", resolvedShorthand.get(2).getExpression()); + Assertions.assertEquals(3, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.FLEX_GROW, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals("5", resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(CommonCssConstants.FLEX_BASIS, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals("7px", resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals(CommonCssConstants.FLEX_SHRINK, resolvedShorthand.get(2).getProperty()); + Assertions.assertEquals("1", resolvedShorthand.get(2).getExpression()); } @Test @@ -224,13 +223,13 @@ public void shorthandWithUnitAndUnitlessNumberValuesTest() { String shorthand = "5px 7"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(3, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.FLEX_BASIS, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals("5px", resolvedShorthand.get(0).getExpression()); - Assert.assertEquals(CommonCssConstants.FLEX_GROW, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals("7", resolvedShorthand.get(1).getExpression()); - Assert.assertEquals(CommonCssConstants.FLEX_SHRINK, resolvedShorthand.get(2).getProperty()); - Assert.assertEquals("1", resolvedShorthand.get(2).getExpression()); + Assertions.assertEquals(3, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.FLEX_BASIS, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals("5px", resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(CommonCssConstants.FLEX_GROW, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals("7", resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals(CommonCssConstants.FLEX_SHRINK, resolvedShorthand.get(2).getProperty()); + Assertions.assertEquals("1", resolvedShorthand.get(2).getExpression()); } @Test @@ -241,7 +240,7 @@ public void shorthandWithTwoUnitValuesTest() { String shorthand = "5px 7px"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(0, resolvedShorthand.size()); + Assertions.assertEquals(0, resolvedShorthand.size()); } @Test @@ -252,7 +251,7 @@ public void shorthandWithOneUnitlessAndOneInvalidValuesTest() { String shorthand = "5 invalid"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(0, resolvedShorthand.size()); + Assertions.assertEquals(0, resolvedShorthand.size()); } @Test @@ -263,7 +262,7 @@ public void shorthandWithTwoValuesAndFirstIsInvalidTest() { String shorthand = "invalid 5px"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(0, resolvedShorthand.size()); + Assertions.assertEquals(0, resolvedShorthand.size()); } @Test @@ -273,13 +272,13 @@ public void shorthandWithTwoUnitlessAndOneUnitValuesTest() { String shorthand = "5 7 10px"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(3, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.FLEX_GROW, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals("5", resolvedShorthand.get(0).getExpression()); - Assert.assertEquals(CommonCssConstants.FLEX_SHRINK, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals("7", resolvedShorthand.get(1).getExpression()); - Assert.assertEquals(CommonCssConstants.FLEX_BASIS, resolvedShorthand.get(2).getProperty()); - Assert.assertEquals("10px", resolvedShorthand.get(2).getExpression()); + Assertions.assertEquals(3, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.FLEX_GROW, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals("5", resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(CommonCssConstants.FLEX_SHRINK, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals("7", resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals(CommonCssConstants.FLEX_BASIS, resolvedShorthand.get(2).getProperty()); + Assertions.assertEquals("10px", resolvedShorthand.get(2).getExpression()); } @Test @@ -289,13 +288,13 @@ public void shorthandWithOneUnitAndTwoUnitlessValuesTest() { String shorthand = "5px 7 10"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(3, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.FLEX_GROW, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals("7", resolvedShorthand.get(0).getExpression()); - Assert.assertEquals(CommonCssConstants.FLEX_SHRINK, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals("10", resolvedShorthand.get(1).getExpression()); - Assert.assertEquals(CommonCssConstants.FLEX_BASIS, resolvedShorthand.get(2).getProperty()); - Assert.assertEquals("5px", resolvedShorthand.get(2).getExpression()); + Assertions.assertEquals(3, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.FLEX_GROW, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals("7", resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(CommonCssConstants.FLEX_SHRINK, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals("10", resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals(CommonCssConstants.FLEX_BASIS, resolvedShorthand.get(2).getProperty()); + Assertions.assertEquals("5px", resolvedShorthand.get(2).getExpression()); } @Test @@ -306,7 +305,7 @@ public void shorthandWithThreeUnitlessValuesTest() { String shorthand = "5 7 10"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(0, resolvedShorthand.size()); + Assertions.assertEquals(0, resolvedShorthand.size()); } @Test @@ -317,7 +316,7 @@ public void shorthandWithOneUnitlessOneUnitAndOneUnitlessValuesTest() { String shorthand = "5 7px 10"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(0, resolvedShorthand.size()); + Assertions.assertEquals(0, resolvedShorthand.size()); } @Test @@ -328,7 +327,7 @@ public void shorthandWithThreeUnitValuesTest() { String shorthand = "5px 7px 10px"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(0, resolvedShorthand.size()); + Assertions.assertEquals(0, resolvedShorthand.size()); } @Test @@ -339,7 +338,7 @@ public void shorthandWithOneUnitOneUnitlessAndOneUnitValuesTest() { String shorthand = "5px 7 10px"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(0, resolvedShorthand.size()); + Assertions.assertEquals(0, resolvedShorthand.size()); } @Test @@ -350,7 +349,7 @@ public void shorthandWithThreeValuesAndFirstIsInvalidTest() { String shorthand = "invalid 7 10"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(0, resolvedShorthand.size()); + Assertions.assertEquals(0, resolvedShorthand.size()); } @Test @@ -361,6 +360,6 @@ public void shorthandWithFourValuesTest() { String shorthand = "5 7 10 13"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(Collections.emptyList(), resolvedShorthand); + Assertions.assertEquals(Collections.emptyList(), resolvedShorthand); } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/shorthand/GapShorthandResolverTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/shorthand/GapShorthandResolverTest.java index 938c4fc621..c24503d15d 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/shorthand/GapShorthandResolverTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/shorthand/GapShorthandResolverTest.java @@ -29,15 +29,14 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.UnitTest; import java.util.Collections; import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(UnitTest.class) +@Tag("UnitTest") public class GapShorthandResolverTest extends ExtendedITextTest { @Test public void initialOrInheritOrUnsetValuesTest() { @@ -45,27 +44,27 @@ public void initialOrInheritOrUnsetValuesTest() { String initialShorthand = CommonCssConstants.INITIAL; List resolvedShorthand = resolver.resolveShorthand(initialShorthand); - Assert.assertEquals(2, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.ROW_GAP, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals(CommonCssConstants.INITIAL, resolvedShorthand.get(0).getExpression()); - Assert.assertEquals(CommonCssConstants.COLUMN_GAP, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals(CommonCssConstants.INITIAL, resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals(2, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.ROW_GAP, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals(CommonCssConstants.INITIAL, resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(CommonCssConstants.COLUMN_GAP, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals(CommonCssConstants.INITIAL, resolvedShorthand.get(1).getExpression()); String inheritShorthand = CommonCssConstants.INHERIT; resolvedShorthand = resolver.resolveShorthand(inheritShorthand); - Assert.assertEquals(2, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.ROW_GAP, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals(CommonCssConstants.INHERIT, resolvedShorthand.get(0).getExpression()); - Assert.assertEquals(CommonCssConstants.COLUMN_GAP, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals(CommonCssConstants.INHERIT, resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals(2, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.ROW_GAP, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals(CommonCssConstants.INHERIT, resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(CommonCssConstants.COLUMN_GAP, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals(CommonCssConstants.INHERIT, resolvedShorthand.get(1).getExpression()); String unsetShorthand = CommonCssConstants.UNSET; resolvedShorthand = resolver.resolveShorthand(unsetShorthand); - Assert.assertEquals(2, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.ROW_GAP, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals(CommonCssConstants.UNSET, resolvedShorthand.get(0).getExpression()); - Assert.assertEquals(CommonCssConstants.COLUMN_GAP, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals(CommonCssConstants.UNSET, resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals(2, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.ROW_GAP, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals(CommonCssConstants.UNSET, resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(CommonCssConstants.COLUMN_GAP, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals(CommonCssConstants.UNSET, resolvedShorthand.get(1).getExpression()); } @Test @@ -74,11 +73,11 @@ public void initialWithSpacesTest() { String initialWithSpacesShorthand = " initial "; List resolvedShorthand = resolver.resolveShorthand(initialWithSpacesShorthand); - Assert.assertEquals(2, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.ROW_GAP, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals(CommonCssConstants.INITIAL, resolvedShorthand.get(0).getExpression()); - Assert.assertEquals(CommonCssConstants.COLUMN_GAP, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals(CommonCssConstants.INITIAL, resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals(2, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.ROW_GAP, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals(CommonCssConstants.INITIAL, resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(CommonCssConstants.COLUMN_GAP, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals(CommonCssConstants.INITIAL, resolvedShorthand.get(1).getExpression()); } @Test @@ -87,13 +86,13 @@ public void containsInitialOrInheritOrUnsetShorthandTest() { IShorthandResolver resolver = new GapShorthandResolver(); String containsInitialShorthand = "10px initial "; - Assert.assertEquals(Collections.emptyList(), resolver.resolveShorthand(containsInitialShorthand)); + Assertions.assertEquals(Collections.emptyList(), resolver.resolveShorthand(containsInitialShorthand)); String containsInheritShorthand = "inherit 10%"; - Assert.assertEquals(Collections.emptyList(), resolver.resolveShorthand(containsInheritShorthand)); + Assertions.assertEquals(Collections.emptyList(), resolver.resolveShorthand(containsInheritShorthand)); String containsUnsetShorthand = "0 unset"; - Assert.assertEquals(Collections.emptyList(), resolver.resolveShorthand(containsUnsetShorthand)); + Assertions.assertEquals(Collections.emptyList(), resolver.resolveShorthand(containsUnsetShorthand)); } @Test @@ -101,10 +100,10 @@ public void containsInitialOrInheritOrUnsetShorthandTest() { public void emptyShorthandTest() { IShorthandResolver resolver = new GapShorthandResolver(); String emptyShorthand = ""; - Assert.assertEquals(Collections.emptyList(), resolver.resolveShorthand(emptyShorthand)); + Assertions.assertEquals(Collections.emptyList(), resolver.resolveShorthand(emptyShorthand)); String shorthandWithSpaces = " "; - Assert.assertEquals(Collections.emptyList(), resolver.resolveShorthand(shorthandWithSpaces)); + Assertions.assertEquals(Collections.emptyList(), resolver.resolveShorthand(shorthandWithSpaces)); } @Test @@ -114,11 +113,11 @@ public void gapWithOneValidValueTest() { String shorthand = "10px"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(2, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.ROW_GAP, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals("10px", resolvedShorthand.get(0).getExpression()); - Assert.assertEquals(CommonCssConstants.COLUMN_GAP, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals("10px", resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals(2, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.ROW_GAP, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals("10px", resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(CommonCssConstants.COLUMN_GAP, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals("10px", resolvedShorthand.get(1).getExpression()); } @Test @@ -129,7 +128,7 @@ public void gapWithOneInvalidValueTest() { String shorthand = "10"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(0, resolvedShorthand.size()); + Assertions.assertEquals(0, resolvedShorthand.size()); } @Test @@ -139,11 +138,11 @@ public void gapWithTwoValidValuesTest() { String shorthand = "10px 15px"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(2, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.ROW_GAP, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals("10px", resolvedShorthand.get(0).getExpression()); - Assert.assertEquals(CommonCssConstants.COLUMN_GAP, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals("15px", resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals(2, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.ROW_GAP, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals("10px", resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(CommonCssConstants.COLUMN_GAP, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals("15px", resolvedShorthand.get(1).getExpression()); } @Test @@ -153,11 +152,11 @@ public void gridGapWithTwoValidValuesTest() { String shorthand = "10px 15px"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(2, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.ROW_GAP, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals("10px", resolvedShorthand.get(0).getExpression()); - Assert.assertEquals(CommonCssConstants.COLUMN_GAP, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals("15px", resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals(2, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.ROW_GAP, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals("10px", resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(CommonCssConstants.COLUMN_GAP, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals("15px", resolvedShorthand.get(1).getExpression()); } @Test @@ -168,7 +167,7 @@ public void gapWithValidAndInvalidValuesTest() { String shorthand = "10px 15"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(0, resolvedShorthand.size()); + Assertions.assertEquals(0, resolvedShorthand.size()); } @Test @@ -179,7 +178,7 @@ public void gapWithInvalidAndValidValuesTest() { String shorthand = "10 15px"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(0, resolvedShorthand.size()); + Assertions.assertEquals(0, resolvedShorthand.size()); } @Test @@ -189,11 +188,11 @@ public void gapWithZeroNumberTest() { String shorthand = "0 10px"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(2, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.ROW_GAP, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals("0", resolvedShorthand.get(0).getExpression()); - Assert.assertEquals(CommonCssConstants.COLUMN_GAP, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals("10px", resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals(2, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.ROW_GAP, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals("0", resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(CommonCssConstants.COLUMN_GAP, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals("10px", resolvedShorthand.get(1).getExpression()); } @Test @@ -204,6 +203,6 @@ public void gapWithThreeValuesTest() { String shorthand = "10px 15px 20px"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(Collections.emptyList(), resolvedShorthand); + Assertions.assertEquals(Collections.emptyList(), resolvedShorthand); } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/shorthand/PlaceItemsShorthandResolverTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/shorthand/PlaceItemsShorthandResolverTest.java index f33e6d9133..1bedad4032 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/shorthand/PlaceItemsShorthandResolverTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/shorthand/PlaceItemsShorthandResolverTest.java @@ -29,15 +29,14 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.util.Collections; import java.util.List; -@Category(UnitTest.class) +@Tag("UnitTest") public class PlaceItemsShorthandResolverTest extends ExtendedITextTest { @Test public void initialOrInheritOrUnsetValuesTest() { @@ -45,27 +44,27 @@ public void initialOrInheritOrUnsetValuesTest() { String initialShorthand = CommonCssConstants.INITIAL; List resolvedShorthand = resolver.resolveShorthand(initialShorthand); - Assert.assertEquals(2, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.ALIGN_ITEMS, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals(CommonCssConstants.INITIAL, resolvedShorthand.get(0).getExpression()); - Assert.assertEquals(CommonCssConstants.JUSTIFY_ITEMS, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals(CommonCssConstants.INITIAL, resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals(2, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.ALIGN_ITEMS, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals(CommonCssConstants.INITIAL, resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(CommonCssConstants.JUSTIFY_ITEMS, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals(CommonCssConstants.INITIAL, resolvedShorthand.get(1).getExpression()); String inheritShorthand = CommonCssConstants.INHERIT; resolvedShorthand = resolver.resolveShorthand(inheritShorthand); - Assert.assertEquals(2, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.ALIGN_ITEMS, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals(CommonCssConstants.INHERIT, resolvedShorthand.get(0).getExpression()); - Assert.assertEquals(CommonCssConstants.JUSTIFY_ITEMS, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals(CommonCssConstants.INHERIT, resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals(2, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.ALIGN_ITEMS, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals(CommonCssConstants.INHERIT, resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(CommonCssConstants.JUSTIFY_ITEMS, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals(CommonCssConstants.INHERIT, resolvedShorthand.get(1).getExpression()); String unsetShorthand = CommonCssConstants.UNSET; resolvedShorthand = resolver.resolveShorthand(unsetShorthand); - Assert.assertEquals(2, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.ALIGN_ITEMS, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals(CommonCssConstants.UNSET, resolvedShorthand.get(0).getExpression()); - Assert.assertEquals(CommonCssConstants.JUSTIFY_ITEMS, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals(CommonCssConstants.UNSET, resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals(2, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.ALIGN_ITEMS, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals(CommonCssConstants.UNSET, resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(CommonCssConstants.JUSTIFY_ITEMS, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals(CommonCssConstants.UNSET, resolvedShorthand.get(1).getExpression()); } @Test @@ -74,11 +73,11 @@ public void initialWithSpacesTest() { String initialWithSpacesShorthand = " initial "; List resolvedShorthand = resolver.resolveShorthand(initialWithSpacesShorthand); - Assert.assertEquals(2, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.ALIGN_ITEMS, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals(CommonCssConstants.INITIAL, resolvedShorthand.get(0).getExpression()); - Assert.assertEquals(CommonCssConstants.JUSTIFY_ITEMS, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals(CommonCssConstants.INITIAL, resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals(2, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.ALIGN_ITEMS, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals(CommonCssConstants.INITIAL, resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(CommonCssConstants.JUSTIFY_ITEMS, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals(CommonCssConstants.INITIAL, resolvedShorthand.get(1).getExpression()); } @Test @@ -87,13 +86,13 @@ public void containsInitialOrInheritOrUnsetShorthandTest() { IShorthandResolver resolver = new PlaceItemsShorthandResolver(); String containsInitialShorthand = "start initial "; - Assert.assertEquals(Collections.emptyList(), resolver.resolveShorthand(containsInitialShorthand)); + Assertions.assertEquals(Collections.emptyList(), resolver.resolveShorthand(containsInitialShorthand)); String containsInheritShorthand = "inherit safe end"; - Assert.assertEquals(Collections.emptyList(), resolver.resolveShorthand(containsInheritShorthand)); + Assertions.assertEquals(Collections.emptyList(), resolver.resolveShorthand(containsInheritShorthand)); String containsUnsetShorthand = "baseline unset"; - Assert.assertEquals(Collections.emptyList(), resolver.resolveShorthand(containsUnsetShorthand)); + Assertions.assertEquals(Collections.emptyList(), resolver.resolveShorthand(containsUnsetShorthand)); } @Test @@ -101,10 +100,10 @@ public void containsInitialOrInheritOrUnsetShorthandTest() { public void emptyShorthandTest() { IShorthandResolver resolver = new PlaceItemsShorthandResolver(); String emptyShorthand = ""; - Assert.assertEquals(Collections.emptyList(), resolver.resolveShorthand(emptyShorthand)); + Assertions.assertEquals(Collections.emptyList(), resolver.resolveShorthand(emptyShorthand)); String shorthandWithSpaces = " "; - Assert.assertEquals(Collections.emptyList(), resolver.resolveShorthand(shorthandWithSpaces)); + Assertions.assertEquals(Collections.emptyList(), resolver.resolveShorthand(shorthandWithSpaces)); } @Test @@ -114,11 +113,11 @@ public void shorthandWithOneValidWordTest() { String shorthand = "baseline"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(2, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.ALIGN_ITEMS, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals("baseline", resolvedShorthand.get(0).getExpression()); - Assert.assertEquals(CommonCssConstants.JUSTIFY_ITEMS, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals("baseline", resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals(2, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.ALIGN_ITEMS, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals("baseline", resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(CommonCssConstants.JUSTIFY_ITEMS, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals("baseline", resolvedShorthand.get(1).getExpression()); } @Test @@ -129,7 +128,7 @@ public void shorthandWithOneInvalidAlignItemsWordTest() { String shorthand = "legacy"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(0, resolvedShorthand.size()); + Assertions.assertEquals(0, resolvedShorthand.size()); } @Test @@ -140,7 +139,7 @@ public void shorthandWithOneInvalidWordTest() { String shorthand = "invalid"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(0, resolvedShorthand.size()); + Assertions.assertEquals(0, resolvedShorthand.size()); } @Test @@ -150,11 +149,11 @@ public void shorthandWithTwoWordsAlignItemsTest() { String shorthand = "unsafe start"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(2, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.ALIGN_ITEMS, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals("unsafe start", resolvedShorthand.get(0).getExpression()); - Assert.assertEquals(CommonCssConstants.JUSTIFY_ITEMS, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals("unsafe start", resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals(2, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.ALIGN_ITEMS, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals("unsafe start", resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(CommonCssConstants.JUSTIFY_ITEMS, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals("unsafe start", resolvedShorthand.get(1).getExpression()); } @Test @@ -164,11 +163,11 @@ public void shorthandWithOneWordAlignItemsAndOneWordJustifyItemsTest() { String shorthand = CommonCssConstants.CENTER + " " + CommonCssConstants.LEGACY + " " + CommonCssConstants.RIGHT; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(2, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.ALIGN_ITEMS, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals(CommonCssConstants.CENTER, resolvedShorthand.get(0).getExpression()); - Assert.assertEquals(CommonCssConstants.JUSTIFY_ITEMS, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals(CommonCssConstants.LEGACY + " " + CommonCssConstants.RIGHT, resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals(2, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.ALIGN_ITEMS, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals(CommonCssConstants.CENTER, resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(CommonCssConstants.JUSTIFY_ITEMS, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals(CommonCssConstants.LEGACY + " " + CommonCssConstants.RIGHT, resolvedShorthand.get(1).getExpression()); } @Test @@ -179,7 +178,7 @@ public void shorthandWithTwoWordsAndFirstWordIsInvalidTest() { String shorthand = "invalid self-end"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(0, resolvedShorthand.size()); + Assertions.assertEquals(0, resolvedShorthand.size()); } @Test @@ -190,7 +189,7 @@ public void shorthandWithTwoWordsAndSecondWordIsInvalidTest() { String shorthand = "flex-start invalid"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(0, resolvedShorthand.size()); + Assertions.assertEquals(0, resolvedShorthand.size()); } @Test @@ -200,11 +199,11 @@ public void shorthandWithOneWordAlignItemsAndTwoWordsJustifyItemsTest() { String shorthand = "flex-start legacy right"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(2, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.ALIGN_ITEMS, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals("flex-start", resolvedShorthand.get(0).getExpression()); - Assert.assertEquals(CommonCssConstants.JUSTIFY_ITEMS, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals("legacy right", resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals(2, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.ALIGN_ITEMS, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals("flex-start", resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(CommonCssConstants.JUSTIFY_ITEMS, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals("legacy right", resolvedShorthand.get(1).getExpression()); } @Test @@ -215,7 +214,7 @@ public void shorthandWithOneWordAlignItemsAndInvalidTwoWordsJustifyItemsTest() { String shorthand = "flex-start legacy invalid"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(0, resolvedShorthand.size()); + Assertions.assertEquals(0, resolvedShorthand.size()); } @Test @@ -225,11 +224,11 @@ public void shorthandWithTwoWordsAlignItemsAndOneWordJustifyItemsTest() { String shorthand = "unsafe flex-start normal"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(2, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.ALIGN_ITEMS, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals("unsafe flex-start", resolvedShorthand.get(0).getExpression()); - Assert.assertEquals(CommonCssConstants.JUSTIFY_ITEMS, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals("normal", resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals(2, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.ALIGN_ITEMS, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals("unsafe flex-start", resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(CommonCssConstants.JUSTIFY_ITEMS, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals("normal", resolvedShorthand.get(1).getExpression()); } @Test @@ -240,7 +239,7 @@ public void shorthandWithTwoWordsAlignItemsAndInvalidOneWordJustifyItemsTest() { String shorthand = "unsafe flex-start invalid"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(0, resolvedShorthand.size()); + Assertions.assertEquals(0, resolvedShorthand.size()); } @Test @@ -251,7 +250,7 @@ public void shorthandWithThreeWordsAndInvalidAlignItemsTest() { String shorthand = "invalid safe self-end"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(0, resolvedShorthand.size()); + Assertions.assertEquals(0, resolvedShorthand.size()); } @Test @@ -261,11 +260,11 @@ public void shorthandWithTwoWordsAlignItemsAndTwoWordsJustifyItemsTest() { String shorthand = "first baseline legacy center"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(2, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.ALIGN_ITEMS, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals("first baseline", resolvedShorthand.get(0).getExpression()); - Assert.assertEquals(CommonCssConstants.JUSTIFY_ITEMS, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals("legacy center", resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals(2, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.ALIGN_ITEMS, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals("first baseline", resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(CommonCssConstants.JUSTIFY_ITEMS, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals("legacy center", resolvedShorthand.get(1).getExpression()); } @Test @@ -276,7 +275,7 @@ public void shorthandWithTwoWordsAlignItemsAndInvalidTwoWordsJustifyItemsTest() String shorthand = "first baseline invalid center"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(0, resolvedShorthand.size()); + Assertions.assertEquals(0, resolvedShorthand.size()); } @Test @@ -287,7 +286,7 @@ public void shorthandWithInvalidTwoWordsAlignItemsAndTwoWordsJustifyItemsTest() String shorthand = "invalid baseline legacy left"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(0, resolvedShorthand.size()); + Assertions.assertEquals(0, resolvedShorthand.size()); } @Test @@ -298,6 +297,6 @@ public void shorthandWithFiveWordsTest() { String shorthand = "last baseline unsafe safe center"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(Collections.emptyList(), resolvedShorthand); + Assertions.assertEquals(Collections.emptyList(), resolvedShorthand); } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/shorthand/TextDecorationUnitTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/shorthand/TextDecorationUnitTest.java index 373ee9ff8f..8ac6ff3a79 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/shorthand/TextDecorationUnitTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/shorthand/TextDecorationUnitTest.java @@ -25,16 +25,15 @@ This file is part of the iText (R) project. import com.itextpdf.styledxmlparser.css.CssDeclaration; import com.itextpdf.styledxmlparser.css.resolve.shorthand.impl.TextDecorationShorthandResolver; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.util.HashMap; import java.util.List; import java.util.Map; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class TextDecorationUnitTest extends ExtendedITextTest { @Test @@ -42,10 +41,10 @@ public void resolveShorthandLineEmptyTest() { TextDecorationShorthandResolver resolver = new TextDecorationShorthandResolver(); List result = resolver.resolveShorthand(""); Map resultMap = convertCssDeclarationsToMap(result); - Assert.assertEquals(3, resultMap.size()); - Assert.assertEquals("initial", resultMap.get("text-decoration-line")); - Assert.assertEquals("initial", resultMap.get("text-decoration-style")); - Assert.assertEquals("initial", resultMap.get("text-decoration-color")); + Assertions.assertEquals(3, resultMap.size()); + Assertions.assertEquals("initial", resultMap.get("text-decoration-line")); + Assertions.assertEquals("initial", resultMap.get("text-decoration-style")); + Assertions.assertEquals("initial", resultMap.get("text-decoration-color")); } @Test @@ -53,10 +52,10 @@ public void resolveShorthandLineNoneTest() { TextDecorationShorthandResolver resolver = new TextDecorationShorthandResolver(); List result = resolver.resolveShorthand("none"); Map resultMap = convertCssDeclarationsToMap(result); - Assert.assertEquals(3, resultMap.size()); - Assert.assertEquals("none", resultMap.get("text-decoration-line")); - Assert.assertEquals("initial", resultMap.get("text-decoration-style")); - Assert.assertEquals("initial", resultMap.get("text-decoration-color")); + Assertions.assertEquals(3, resultMap.size()); + Assertions.assertEquals("none", resultMap.get("text-decoration-line")); + Assertions.assertEquals("initial", resultMap.get("text-decoration-style")); + Assertions.assertEquals("initial", resultMap.get("text-decoration-color")); } @Test @@ -64,11 +63,11 @@ public void resolveShorthandLineNoneAndUnderlineTogetherTest() { TextDecorationShorthandResolver resolver = new TextDecorationShorthandResolver(); List result = resolver.resolveShorthand("none underline"); Map resultMap = convertCssDeclarationsToMap(result); - Assert.assertEquals(3, resultMap.size()); + Assertions.assertEquals(3, resultMap.size()); String line = resultMap.get("text-decoration-line"); - Assert.assertTrue(line != null && line.contains("underline") && line.contains("none")); - Assert.assertEquals("initial", resultMap.get("text-decoration-style")); - Assert.assertEquals("initial", resultMap.get("text-decoration-color")); + Assertions.assertTrue(line != null && line.contains("underline") && line.contains("none")); + Assertions.assertEquals("initial", resultMap.get("text-decoration-style")); + Assertions.assertEquals("initial", resultMap.get("text-decoration-color")); } @Test @@ -76,10 +75,10 @@ public void resolveShorthandLineOnePropertyTest() { TextDecorationShorthandResolver resolver = new TextDecorationShorthandResolver(); List result = resolver.resolveShorthand("underline"); Map resultMap = convertCssDeclarationsToMap(result); - Assert.assertEquals(3, resultMap.size()); - Assert.assertEquals("underline", resultMap.get("text-decoration-line")); - Assert.assertEquals("initial", resultMap.get("text-decoration-style")); - Assert.assertEquals("initial", resultMap.get("text-decoration-color")); + Assertions.assertEquals(3, resultMap.size()); + Assertions.assertEquals("underline", resultMap.get("text-decoration-line")); + Assertions.assertEquals("initial", resultMap.get("text-decoration-style")); + Assertions.assertEquals("initial", resultMap.get("text-decoration-color")); } @Test @@ -87,11 +86,11 @@ public void resolveShorthandLineTwoPropertiesTest() { TextDecorationShorthandResolver resolver = new TextDecorationShorthandResolver(); List result = resolver.resolveShorthand("underline overline"); Map resultMap = convertCssDeclarationsToMap(result); - Assert.assertEquals(3, resultMap.size()); + Assertions.assertEquals(3, resultMap.size()); String line = resultMap.get("text-decoration-line"); - Assert.assertTrue(line != null && line.contains("underline") && line.contains("overline")); - Assert.assertEquals("initial", resultMap.get("text-decoration-style")); - Assert.assertEquals("initial", resultMap.get("text-decoration-color")); + Assertions.assertTrue(line != null && line.contains("underline") && line.contains("overline")); + Assertions.assertEquals("initial", resultMap.get("text-decoration-style")); + Assertions.assertEquals("initial", resultMap.get("text-decoration-color")); } @Test @@ -99,10 +98,10 @@ public void resolveShorthandColorNamedTest() { TextDecorationShorthandResolver resolver = new TextDecorationShorthandResolver(); List result = resolver.resolveShorthand("underline red"); Map resultMap = convertCssDeclarationsToMap(result); - Assert.assertEquals(3, resultMap.size()); - Assert.assertEquals("underline", resultMap.get("text-decoration-line")); - Assert.assertEquals("initial", resultMap.get("text-decoration-style")); - Assert.assertEquals("red", resultMap.get("text-decoration-color")); + Assertions.assertEquals(3, resultMap.size()); + Assertions.assertEquals("underline", resultMap.get("text-decoration-line")); + Assertions.assertEquals("initial", resultMap.get("text-decoration-style")); + Assertions.assertEquals("red", resultMap.get("text-decoration-color")); } @Test @@ -110,10 +109,10 @@ public void resolveShorthandColorRgbTest() { TextDecorationShorthandResolver resolver = new TextDecorationShorthandResolver(); List result = resolver.resolveShorthand("underline rgb(255, 255, 0)"); Map resultMap = convertCssDeclarationsToMap(result); - Assert.assertEquals(3, resultMap.size()); - Assert.assertEquals("underline", resultMap.get("text-decoration-line")); - Assert.assertEquals("initial", resultMap.get("text-decoration-style")); - Assert.assertEquals("rgb(255,255,0)", resultMap.get("text-decoration-color")); + Assertions.assertEquals(3, resultMap.size()); + Assertions.assertEquals("underline", resultMap.get("text-decoration-line")); + Assertions.assertEquals("initial", resultMap.get("text-decoration-style")); + Assertions.assertEquals("rgb(255,255,0)", resultMap.get("text-decoration-color")); } @Test @@ -121,10 +120,10 @@ public void resolveShorthandColorRgbWithOpacityTest() { TextDecorationShorthandResolver resolver = new TextDecorationShorthandResolver(); List result = resolver.resolveShorthand("underline rgb(255, 255, 0, 0.5)"); Map resultMap = convertCssDeclarationsToMap(result); - Assert.assertEquals(3, resultMap.size()); - Assert.assertEquals("underline", resultMap.get("text-decoration-line")); - Assert.assertEquals("initial", resultMap.get("text-decoration-style")); - Assert.assertEquals("rgb(255,255,0,0.5)", resultMap.get("text-decoration-color")); + Assertions.assertEquals(3, resultMap.size()); + Assertions.assertEquals("underline", resultMap.get("text-decoration-line")); + Assertions.assertEquals("initial", resultMap.get("text-decoration-style")); + Assertions.assertEquals("rgb(255,255,0,0.5)", resultMap.get("text-decoration-color")); } @Test @@ -132,10 +131,10 @@ public void resolveShorthandColorHslTest() { TextDecorationShorthandResolver resolver = new TextDecorationShorthandResolver(); List result = resolver.resolveShorthand("underline hsl(300, 76%, 72%)"); Map resultMap = convertCssDeclarationsToMap(result); - Assert.assertEquals(3, resultMap.size()); - Assert.assertEquals("underline", resultMap.get("text-decoration-line")); - Assert.assertEquals("initial", resultMap.get("text-decoration-style")); - Assert.assertEquals("hsl(300,76%,72%)", resultMap.get("text-decoration-color")); + Assertions.assertEquals(3, resultMap.size()); + Assertions.assertEquals("underline", resultMap.get("text-decoration-line")); + Assertions.assertEquals("initial", resultMap.get("text-decoration-style")); + Assertions.assertEquals("hsl(300,76%,72%)", resultMap.get("text-decoration-color")); } @Test @@ -143,10 +142,10 @@ public void resolveShorthandColorHexTest() { TextDecorationShorthandResolver resolver = new TextDecorationShorthandResolver(); List result = resolver.resolveShorthand("underline #DDAA55"); Map resultMap = convertCssDeclarationsToMap(result); - Assert.assertEquals(3, resultMap.size()); - Assert.assertEquals("underline", resultMap.get("text-decoration-line")); - Assert.assertEquals("initial", resultMap.get("text-decoration-style")); - Assert.assertEquals("#ddaa55", resultMap.get("text-decoration-color")); + Assertions.assertEquals(3, resultMap.size()); + Assertions.assertEquals("underline", resultMap.get("text-decoration-line")); + Assertions.assertEquals("initial", resultMap.get("text-decoration-style")); + Assertions.assertEquals("#ddaa55", resultMap.get("text-decoration-color")); } @Test @@ -154,10 +153,10 @@ public void resolveShorthandStyleOnePropertyTest() { TextDecorationShorthandResolver resolver = new TextDecorationShorthandResolver(); List result = resolver.resolveShorthand("underline wavy"); Map resultMap = convertCssDeclarationsToMap(result); - Assert.assertEquals(3, resultMap.size()); - Assert.assertEquals("underline", resultMap.get("text-decoration-line")); - Assert.assertEquals("wavy", resultMap.get("text-decoration-style")); - Assert.assertEquals("initial", resultMap.get("text-decoration-color")); + Assertions.assertEquals(3, resultMap.size()); + Assertions.assertEquals("underline", resultMap.get("text-decoration-line")); + Assertions.assertEquals("wavy", resultMap.get("text-decoration-style")); + Assertions.assertEquals("initial", resultMap.get("text-decoration-color")); } @Test @@ -165,10 +164,10 @@ public void resolveShorthandStyleTwoPropertiesTest() { TextDecorationShorthandResolver resolver = new TextDecorationShorthandResolver(); List result = resolver.resolveShorthand("underline wavy dotted"); Map resultMap = convertCssDeclarationsToMap(result); - Assert.assertEquals(3, resultMap.size()); - Assert.assertEquals("underline", resultMap.get("text-decoration-line")); - Assert.assertEquals("dotted", resultMap.get("text-decoration-style")); - Assert.assertEquals("initial", resultMap.get("text-decoration-color")); + Assertions.assertEquals(3, resultMap.size()); + Assertions.assertEquals("underline", resultMap.get("text-decoration-line")); + Assertions.assertEquals("dotted", resultMap.get("text-decoration-style")); + Assertions.assertEquals("initial", resultMap.get("text-decoration-color")); } private Map convertCssDeclarationsToMap(List declarations) { diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/shorthand/impl/ColumnRuleShorthandResolverTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/shorthand/impl/ColumnRuleShorthandResolverTest.java index 355a6d1873..fa993d0c1e 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/shorthand/impl/ColumnRuleShorthandResolverTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/shorthand/impl/ColumnRuleShorthandResolverTest.java @@ -29,15 +29,14 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.UnitTest; import java.util.Collections; import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class ColumnRuleShorthandResolverTest extends ExtendedITextTest { @@ -47,34 +46,34 @@ public void initialOrInheritOrUnsetValuesTest() { String initialShorthand = CommonCssConstants.INITIAL; List resolvedShorthand = resolver.resolveShorthand(initialShorthand); - Assert.assertEquals(3, resolvedShorthand.size()); + Assertions.assertEquals(3, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.COLUMN_RULE_COLOR, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals(CommonCssConstants.INITIAL, resolvedShorthand.get(0).getExpression()); - Assert.assertEquals(CommonCssConstants.COLUMN_RULE_WIDTH, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals(CommonCssConstants.INITIAL, resolvedShorthand.get(1).getExpression()); - Assert.assertEquals(CommonCssConstants.COLUMN_RULE_STYLE, resolvedShorthand.get(2).getProperty()); - Assert.assertEquals(CommonCssConstants.INITIAL, resolvedShorthand.get(2).getExpression()); + Assertions.assertEquals(CommonCssConstants.COLUMN_RULE_COLOR, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals(CommonCssConstants.INITIAL, resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(CommonCssConstants.COLUMN_RULE_WIDTH, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals(CommonCssConstants.INITIAL, resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals(CommonCssConstants.COLUMN_RULE_STYLE, resolvedShorthand.get(2).getProperty()); + Assertions.assertEquals(CommonCssConstants.INITIAL, resolvedShorthand.get(2).getExpression()); String inheritShorthand = CommonCssConstants.INHERIT; resolvedShorthand = resolver.resolveShorthand(inheritShorthand); - Assert.assertEquals(3, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.COLUMN_RULE_COLOR, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals(CommonCssConstants.INHERIT, resolvedShorthand.get(0).getExpression()); - Assert.assertEquals(CommonCssConstants.COLUMN_RULE_WIDTH, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals(CommonCssConstants.INHERIT, resolvedShorthand.get(1).getExpression()); - Assert.assertEquals(CommonCssConstants.COLUMN_RULE_STYLE, resolvedShorthand.get(2).getProperty()); - Assert.assertEquals(CommonCssConstants.INHERIT, resolvedShorthand.get(2).getExpression()); + Assertions.assertEquals(3, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.COLUMN_RULE_COLOR, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals(CommonCssConstants.INHERIT, resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(CommonCssConstants.COLUMN_RULE_WIDTH, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals(CommonCssConstants.INHERIT, resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals(CommonCssConstants.COLUMN_RULE_STYLE, resolvedShorthand.get(2).getProperty()); + Assertions.assertEquals(CommonCssConstants.INHERIT, resolvedShorthand.get(2).getExpression()); String unsetShorthand = CommonCssConstants.UNSET; resolvedShorthand = resolver.resolveShorthand(unsetShorthand); - Assert.assertEquals(3, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.COLUMN_RULE_COLOR, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals(CommonCssConstants.UNSET, resolvedShorthand.get(0).getExpression()); - Assert.assertEquals(CommonCssConstants.COLUMN_RULE_WIDTH, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals(CommonCssConstants.UNSET, resolvedShorthand.get(1).getExpression()); - Assert.assertEquals(CommonCssConstants.COLUMN_RULE_STYLE, resolvedShorthand.get(2).getProperty()); - Assert.assertEquals(CommonCssConstants.UNSET, resolvedShorthand.get(2).getExpression()); + Assertions.assertEquals(3, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.COLUMN_RULE_COLOR, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals(CommonCssConstants.UNSET, resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(CommonCssConstants.COLUMN_RULE_WIDTH, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals(CommonCssConstants.UNSET, resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals(CommonCssConstants.COLUMN_RULE_STYLE, resolvedShorthand.get(2).getProperty()); + Assertions.assertEquals(CommonCssConstants.UNSET, resolvedShorthand.get(2).getExpression()); } @@ -85,16 +84,16 @@ public void initialOrInheritOrUnsetValuesTest() { public void emptyShorthandTest() { IShorthandResolver resolver = new ColumnRuleShortHandResolver(); String emptyShorthand = ""; - Assert.assertEquals(Collections.emptyList(), resolver.resolveShorthand(emptyShorthand)); + Assertions.assertEquals(Collections.emptyList(), resolver.resolveShorthand(emptyShorthand)); String shorthandWithSpaces = " "; - Assert.assertEquals(Collections.emptyList(), resolver.resolveShorthand(shorthandWithSpaces)); + Assertions.assertEquals(Collections.emptyList(), resolver.resolveShorthand(shorthandWithSpaces)); String shorthandWithTabs = "\t"; - Assert.assertEquals(Collections.emptyList(), resolver.resolveShorthand(shorthandWithTabs)); + Assertions.assertEquals(Collections.emptyList(), resolver.resolveShorthand(shorthandWithTabs)); String shorthandWithNewLines = "\n"; - Assert.assertEquals(Collections.emptyList(), resolver.resolveShorthand(shorthandWithNewLines)); + Assertions.assertEquals(Collections.emptyList(), resolver.resolveShorthand(shorthandWithNewLines)); } @Test @@ -104,9 +103,9 @@ public void columnsWidthSingleTest01() { String shorthand = "10px"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(1, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.COLUMN_RULE_WIDTH, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals("10px", resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(1, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.COLUMN_RULE_WIDTH, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals("10px", resolvedShorthand.get(0).getExpression()); } @@ -117,9 +116,9 @@ public void columnsWidthSingleTest02() { String shorthand = "10em"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(1, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.COLUMN_RULE_WIDTH, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals("10em", resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(1, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.COLUMN_RULE_WIDTH, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals("10em", resolvedShorthand.get(0).getExpression()); } @Test @@ -129,9 +128,9 @@ public void columnsWidthSingleTest03() { String shorthand = "thin"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(1, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.COLUMN_RULE_WIDTH, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals("thin", resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(1, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.COLUMN_RULE_WIDTH, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals("thin", resolvedShorthand.get(0).getExpression()); } @Test @@ -142,7 +141,7 @@ public void columnsWidthSingleInvalidTest01() { String shorthand = "10dfx"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(0, resolvedShorthand.size()); + Assertions.assertEquals(0, resolvedShorthand.size()); } @@ -153,7 +152,7 @@ public void columnsWidthSingleInvalidTest02() { IShorthandResolver resolver = new ColumnRuleShortHandResolver(); String shorthand = "big"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(0, resolvedShorthand.size()); + Assertions.assertEquals(0, resolvedShorthand.size()); } @Test @@ -161,9 +160,9 @@ public void columnsStyleSingleTest01() { IShorthandResolver resolver = new ColumnRuleShortHandResolver(); for (String borderStyleValue : CommonCssConstants.BORDER_STYLE_VALUES) { List resolvedShorthand = resolver.resolveShorthand(borderStyleValue); - Assert.assertEquals(1, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.COLUMN_RULE_STYLE, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals(borderStyleValue, resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(1, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.COLUMN_RULE_STYLE, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals(borderStyleValue, resolvedShorthand.get(0).getExpression()); } } @@ -176,7 +175,7 @@ public void columnsWidthStyleInvalidTest01() { String shorthand = "curly"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(0, resolvedShorthand.size()); + Assertions.assertEquals(0, resolvedShorthand.size()); } @@ -184,9 +183,9 @@ public void columnsWidthStyleInvalidTest01() { public void columnsColorSingleTest01() { IShorthandResolver resolver = new ColumnRuleShortHandResolver(); List resolvedShorthand = resolver.resolveShorthand("red"); - Assert.assertEquals(1, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.COLUMN_RULE_COLOR, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals("red", resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(1, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.COLUMN_RULE_COLOR, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals("red", resolvedShorthand.get(0).getExpression()); } @@ -194,27 +193,27 @@ public void columnsColorSingleTest01() { public void columnsColorSingleTest02() { IShorthandResolver resolver = new ColumnRuleShortHandResolver(); List resolvedShorthand = resolver.resolveShorthand("rgb(10,20,30)"); - Assert.assertEquals(1, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.COLUMN_RULE_COLOR, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals("rgb(10,20,30)", resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(1, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.COLUMN_RULE_COLOR, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals("rgb(10,20,30)", resolvedShorthand.get(0).getExpression()); } @Test public void columnsColorSingleTest03() { IShorthandResolver resolver = new ColumnRuleShortHandResolver(); List resolvedShorthand = resolver.resolveShorthand("rgb(10 ,20 ,30)"); - Assert.assertEquals(1, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.COLUMN_RULE_COLOR, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals("rgb(10,20,30)", resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(1, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.COLUMN_RULE_COLOR, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals("rgb(10,20,30)", resolvedShorthand.get(0).getExpression()); } @Test public void columnsColorSingleTest04() { IShorthandResolver resolver = new ColumnRuleShortHandResolver(); List resolvedShorthand = resolver.resolveShorthand("#aabbcc"); - Assert.assertEquals(1, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.COLUMN_RULE_COLOR, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals("#aabbcc", resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(1, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.COLUMN_RULE_COLOR, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals("#aabbcc", resolvedShorthand.get(0).getExpression()); } @Test @@ -222,13 +221,13 @@ public void multipleTogether01() { IShorthandResolver resolver = new ColumnRuleShortHandResolver(); String shorthand = "10px solid red"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(3, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.COLUMN_RULE_WIDTH, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals("10px", resolvedShorthand.get(0).getExpression()); - Assert.assertEquals(CommonCssConstants.COLUMN_RULE_STYLE, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals("solid", resolvedShorthand.get(1).getExpression()); - Assert.assertEquals(CommonCssConstants.COLUMN_RULE_COLOR, resolvedShorthand.get(2).getProperty()); - Assert.assertEquals("red", resolvedShorthand.get(2).getExpression()); + Assertions.assertEquals(3, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.COLUMN_RULE_WIDTH, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals("10px", resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(CommonCssConstants.COLUMN_RULE_STYLE, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals("solid", resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals(CommonCssConstants.COLUMN_RULE_COLOR, resolvedShorthand.get(2).getProperty()); + Assertions.assertEquals("red", resolvedShorthand.get(2).getExpression()); } @Test @@ -236,11 +235,11 @@ public void multipleTogether02() { IShorthandResolver resolver = new ColumnRuleShortHandResolver(); String shorthand = "10px solid"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(2, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.COLUMN_RULE_WIDTH, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals("10px", resolvedShorthand.get(0).getExpression()); - Assert.assertEquals(CommonCssConstants.COLUMN_RULE_STYLE, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals("solid", resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals(2, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.COLUMN_RULE_WIDTH, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals("10px", resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(CommonCssConstants.COLUMN_RULE_STYLE, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals("solid", resolvedShorthand.get(1).getExpression()); } @Test @@ -248,11 +247,11 @@ public void multipleTogether03() { IShorthandResolver resolver = new ColumnRuleShortHandResolver(); String shorthand = "solid blue"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(2, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.COLUMN_RULE_STYLE, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals("solid", resolvedShorthand.get(0).getExpression()); - Assert.assertEquals(CommonCssConstants.COLUMN_RULE_COLOR, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals("blue", resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals(2, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.COLUMN_RULE_STYLE, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals("solid", resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(CommonCssConstants.COLUMN_RULE_COLOR, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals("blue", resolvedShorthand.get(1).getExpression()); } @Test @@ -260,13 +259,13 @@ public void multipleTogether04() { IShorthandResolver resolver = new ColumnRuleShortHandResolver(); String shorthand = "thick inset blue"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(3, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.COLUMN_RULE_WIDTH, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals("thick", resolvedShorthand.get(0).getExpression()); - Assert.assertEquals(CommonCssConstants.COLUMN_RULE_STYLE, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals("inset", resolvedShorthand.get(1).getExpression()); - Assert.assertEquals(CommonCssConstants.COLUMN_RULE_COLOR, resolvedShorthand.get(2).getProperty()); - Assert.assertEquals("blue", resolvedShorthand.get(2).getExpression()); + Assertions.assertEquals(3, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.COLUMN_RULE_WIDTH, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals("thick", resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(CommonCssConstants.COLUMN_RULE_STYLE, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals("inset", resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals(CommonCssConstants.COLUMN_RULE_COLOR, resolvedShorthand.get(2).getProperty()); + Assertions.assertEquals("blue", resolvedShorthand.get(2).getExpression()); } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/shorthand/impl/GridItemShorthandResolverTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/shorthand/impl/GridItemShorthandResolverTest.java index 1e5cd2317f..a058a30677 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/shorthand/impl/GridItemShorthandResolverTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/shorthand/impl/GridItemShorthandResolverTest.java @@ -29,15 +29,14 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.util.Collections; import java.util.List; -@Category(UnitTest.class) +@Tag("UnitTest") public class GridItemShorthandResolverTest extends ExtendedITextTest { @Test public void initialOrInheritOrUnsetValuesTest() { @@ -45,15 +44,15 @@ public void initialOrInheritOrUnsetValuesTest() { String initialShorthand = CommonCssConstants.INITIAL; List resolvedShorthand = resolver.resolveShorthand(initialShorthand); - Assert.assertEquals(0, resolvedShorthand.size()); + Assertions.assertEquals(0, resolvedShorthand.size()); String inheritShorthand = CommonCssConstants.INHERIT; resolvedShorthand = resolver.resolveShorthand(inheritShorthand); - Assert.assertEquals(0, resolvedShorthand.size()); + Assertions.assertEquals(0, resolvedShorthand.size()); String unsetShorthand = CommonCssConstants.UNSET; resolvedShorthand = resolver.resolveShorthand(unsetShorthand); - Assert.assertEquals(0, resolvedShorthand.size()); + Assertions.assertEquals(0, resolvedShorthand.size()); } @Test @@ -62,16 +61,16 @@ public void initialOrInheritOrUnsetValuesTest() { public void emptyShorthandTest() { IShorthandResolver resolver = new GridColumnShorthandResolver(); String emptyShorthand = ""; - Assert.assertEquals(Collections.emptyList(), resolver.resolveShorthand(emptyShorthand)); + Assertions.assertEquals(Collections.emptyList(), resolver.resolveShorthand(emptyShorthand)); String shorthandWithSpaces = " "; - Assert.assertEquals(Collections.emptyList(), resolver.resolveShorthand(shorthandWithSpaces)); + Assertions.assertEquals(Collections.emptyList(), resolver.resolveShorthand(shorthandWithSpaces)); String shorthandWithTabs = "\t"; - Assert.assertEquals(Collections.emptyList(), resolver.resolveShorthand(shorthandWithTabs)); + Assertions.assertEquals(Collections.emptyList(), resolver.resolveShorthand(shorthandWithTabs)); String shorthandWithNewLines = "\n"; - Assert.assertEquals(Collections.emptyList(), resolver.resolveShorthand(shorthandWithNewLines)); + Assertions.assertEquals(Collections.emptyList(), resolver.resolveShorthand(shorthandWithNewLines)); } @Test @@ -81,11 +80,11 @@ public void basicRowValuesTest() { String shorthand = "span 2 / 4"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(2, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.GRID_ROW_START, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals(CommonCssConstants.GRID_ROW_END, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals("span 2", resolvedShorthand.get(0).getExpression()); - Assert.assertEquals("4", resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals(2, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.GRID_ROW_START, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals(CommonCssConstants.GRID_ROW_END, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals("span 2", resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals("4", resolvedShorthand.get(1).getExpression()); } @Test @@ -95,11 +94,11 @@ public void basicColumnValuesTest() { String shorthand = "3 / span 6"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(2, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.GRID_COLUMN_START, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals(CommonCssConstants.GRID_COLUMN_END, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals("3", resolvedShorthand.get(0).getExpression()); - Assert.assertEquals("span 6", resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals(2, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.GRID_COLUMN_START, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals(CommonCssConstants.GRID_COLUMN_END, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals("3", resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals("span 6", resolvedShorthand.get(1).getExpression()); } @Test @@ -109,11 +108,11 @@ public void singleValueTest() { String shorthand = "3"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(2, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.GRID_COLUMN_START, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals(CommonCssConstants.GRID_COLUMN_END, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals("3", resolvedShorthand.get(0).getExpression()); - Assert.assertEquals("3", resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals(2, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.GRID_COLUMN_START, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals(CommonCssConstants.GRID_COLUMN_END, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals("3", resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals("3", resolvedShorthand.get(1).getExpression()); } @Test @@ -123,8 +122,8 @@ public void singleValueSpanTest() { String shorthand = "span 3"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(1, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.GRID_COLUMN_START, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals("span 3", resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(1, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.GRID_COLUMN_START, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals("span 3", resolvedShorthand.get(0).getExpression()); } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/shorthand/impl/GridShorthandResolverTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/shorthand/impl/GridShorthandResolverTest.java index 607ff51140..fd54b2c3d5 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/shorthand/impl/GridShorthandResolverTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/shorthand/impl/GridShorthandResolverTest.java @@ -26,14 +26,13 @@ This file is part of the iText (R) project. import com.itextpdf.styledxmlparser.css.CssDeclaration; import com.itextpdf.styledxmlparser.css.resolve.shorthand.IShorthandResolver; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.util.List; -@Category(UnitTest.class) +@Tag("UnitTest") public class GridShorthandResolverTest extends ExtendedITextTest { /** * Creates grid shorthand resolver. @@ -48,13 +47,13 @@ public void templateAreasTest() { String shorthand = "[header-top] 'a a a' [header-bottom] [main-top] 'b b b' 1fr [main-bottom] / auto 1fr auto"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(3, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.GRID_TEMPLATE_ROWS, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals(CommonCssConstants.GRID_TEMPLATE_COLUMNS, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals(CommonCssConstants.GRID_TEMPLATE_AREAS, resolvedShorthand.get(2).getProperty()); - Assert.assertEquals("[header-top] [header-bottom] [main-top] 1fr [main-bottom]", resolvedShorthand.get(0).getExpression()); - Assert.assertEquals("auto 1fr auto", resolvedShorthand.get(1).getExpression()); - Assert.assertEquals("'a a a' 'b b b'", resolvedShorthand.get(2).getExpression()); + Assertions.assertEquals(3, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.GRID_TEMPLATE_ROWS, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals(CommonCssConstants.GRID_TEMPLATE_COLUMNS, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals(CommonCssConstants.GRID_TEMPLATE_AREAS, resolvedShorthand.get(2).getProperty()); + Assertions.assertEquals("[header-top] [header-bottom] [main-top] 1fr [main-bottom]", resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals("auto 1fr auto", resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals("'a a a' 'b b b'", resolvedShorthand.get(2).getExpression()); } @Test @@ -64,13 +63,13 @@ public void columnFlowTest() { String shorthand = "20% 100px 1fr / auto-flow dense 50px"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(3, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.GRID_TEMPLATE_ROWS, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals(CommonCssConstants.GRID_AUTO_FLOW, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals(CommonCssConstants.GRID_AUTO_COLUMNS, resolvedShorthand.get(2).getProperty()); - Assert.assertEquals("20% 100px 1fr", resolvedShorthand.get(0).getExpression()); - Assert.assertEquals("column dense", resolvedShorthand.get(1).getExpression()); - Assert.assertEquals("50px", resolvedShorthand.get(2).getExpression()); + Assertions.assertEquals(3, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.GRID_TEMPLATE_ROWS, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals(CommonCssConstants.GRID_AUTO_FLOW, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals(CommonCssConstants.GRID_AUTO_COLUMNS, resolvedShorthand.get(2).getProperty()); + Assertions.assertEquals("20% 100px 1fr", resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals("column dense", resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals("50px", resolvedShorthand.get(2).getExpression()); } @Test @@ -80,13 +79,13 @@ public void rowFlowTest() { String shorthand = "auto-flow dense auto / 1fr auto minmax(100px, 1fr)"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(3, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.GRID_AUTO_FLOW, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals(CommonCssConstants.GRID_AUTO_ROWS, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals(CommonCssConstants.GRID_TEMPLATE_COLUMNS, resolvedShorthand.get(2).getProperty()); - Assert.assertEquals("dense", resolvedShorthand.get(0).getExpression()); - Assert.assertEquals("auto", resolvedShorthand.get(1).getExpression()); - Assert.assertEquals("1fr auto minmax(100px,1fr)", resolvedShorthand.get(2).getExpression()); + Assertions.assertEquals(3, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.GRID_AUTO_FLOW, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals(CommonCssConstants.GRID_AUTO_ROWS, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals(CommonCssConstants.GRID_TEMPLATE_COLUMNS, resolvedShorthand.get(2).getProperty()); + Assertions.assertEquals("dense", resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals("auto", resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals("1fr auto minmax(100px,1fr)", resolvedShorthand.get(2).getExpression()); } @Test @@ -96,11 +95,11 @@ public void noRowTemplateTest() { String shorthand = "auto-flow dense / 1fr auto minmax(100px, 1fr)"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(2, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.GRID_AUTO_FLOW, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals(CommonCssConstants.GRID_TEMPLATE_COLUMNS, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals("dense", resolvedShorthand.get(0).getExpression()); - Assert.assertEquals("1fr auto minmax(100px,1fr)", resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals(2, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.GRID_AUTO_FLOW, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals(CommonCssConstants.GRID_TEMPLATE_COLUMNS, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals("dense", resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals("1fr auto minmax(100px,1fr)", resolvedShorthand.get(1).getExpression()); } @Test @@ -110,10 +109,10 @@ public void noColumnTemplateTest() { String shorthand = "1fr auto minmax(100px, 1fr) / auto-flow dense"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(2, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.GRID_TEMPLATE_ROWS, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals(CommonCssConstants.GRID_AUTO_FLOW, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals("1fr auto minmax(100px,1fr)", resolvedShorthand.get(0).getExpression()); - Assert.assertEquals("column dense", resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals(2, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.GRID_TEMPLATE_ROWS, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals(CommonCssConstants.GRID_AUTO_FLOW, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals("1fr auto minmax(100px,1fr)", resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals("column dense", resolvedShorthand.get(1).getExpression()); } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/shorthand/impl/GridTemplateShorthandResolverTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/shorthand/impl/GridTemplateShorthandResolverTest.java index 4bd6eedd1f..5ac87c1e61 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/shorthand/impl/GridTemplateShorthandResolverTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/resolve/shorthand/impl/GridTemplateShorthandResolverTest.java @@ -29,15 +29,14 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.util.Collections; import java.util.List; -@Category(UnitTest.class) +@Tag("UnitTest") public class GridTemplateShorthandResolverTest extends ExtendedITextTest { @Test public void initialOrInheritOrUnsetValuesTest() { @@ -45,15 +44,15 @@ public void initialOrInheritOrUnsetValuesTest() { String initialShorthand = CommonCssConstants.INITIAL; List resolvedShorthand = resolver.resolveShorthand(initialShorthand); - Assert.assertEquals(0, resolvedShorthand.size()); + Assertions.assertEquals(0, resolvedShorthand.size()); String inheritShorthand = CommonCssConstants.INHERIT; resolvedShorthand = resolver.resolveShorthand(inheritShorthand); - Assert.assertEquals(0, resolvedShorthand.size()); + Assertions.assertEquals(0, resolvedShorthand.size()); String unsetShorthand = CommonCssConstants.UNSET; resolvedShorthand = resolver.resolveShorthand(unsetShorthand); - Assert.assertEquals(0, resolvedShorthand.size()); + Assertions.assertEquals(0, resolvedShorthand.size()); } @Test @@ -62,16 +61,16 @@ public void initialOrInheritOrUnsetValuesTest() { public void emptyShorthandTest() { IShorthandResolver resolver = new GridTemplateShorthandResolver(); String emptyShorthand = ""; - Assert.assertEquals(Collections.emptyList(), resolver.resolveShorthand(emptyShorthand)); + Assertions.assertEquals(Collections.emptyList(), resolver.resolveShorthand(emptyShorthand)); String shorthandWithSpaces = " "; - Assert.assertEquals(Collections.emptyList(), resolver.resolveShorthand(shorthandWithSpaces)); + Assertions.assertEquals(Collections.emptyList(), resolver.resolveShorthand(shorthandWithSpaces)); String shorthandWithTabs = "\t"; - Assert.assertEquals(Collections.emptyList(), resolver.resolveShorthand(shorthandWithTabs)); + Assertions.assertEquals(Collections.emptyList(), resolver.resolveShorthand(shorthandWithTabs)); String shorthandWithNewLines = "\n"; - Assert.assertEquals(Collections.emptyList(), resolver.resolveShorthand(shorthandWithNewLines)); + Assertions.assertEquals(Collections.emptyList(), resolver.resolveShorthand(shorthandWithNewLines)); } @Test @@ -81,11 +80,11 @@ public void basicTest() { String shorthand = "auto 1fr / auto 1fr auto"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(2, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.GRID_TEMPLATE_ROWS, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals(CommonCssConstants.GRID_TEMPLATE_COLUMNS, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals("auto 1fr", resolvedShorthand.get(0).getExpression()); - Assert.assertEquals("auto 1fr auto", resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals(2, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.GRID_TEMPLATE_ROWS, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals(CommonCssConstants.GRID_TEMPLATE_COLUMNS, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals("auto 1fr", resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals("auto 1fr auto", resolvedShorthand.get(1).getExpression()); } @Test @@ -95,11 +94,11 @@ public void lineNamesTest() { String shorthand = "[linename] 100px / [columnname1] 30% [columnname2] 70%"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(2, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.GRID_TEMPLATE_ROWS, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals(CommonCssConstants.GRID_TEMPLATE_COLUMNS, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals("[linename] 100px", resolvedShorthand.get(0).getExpression()); - Assert.assertEquals("[columnname1] 30% [columnname2] 70%", resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals(2, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.GRID_TEMPLATE_ROWS, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals(CommonCssConstants.GRID_TEMPLATE_COLUMNS, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals("[linename] 100px", resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals("[columnname1] 30% [columnname2] 70%", resolvedShorthand.get(1).getExpression()); } @Test @@ -109,9 +108,9 @@ public void areaTest() { String shorthand = "'a a a' 'b b b'"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(1, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.GRID_TEMPLATE_AREAS, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals("'a a a' 'b b b'", resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals(1, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.GRID_TEMPLATE_AREAS, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals("'a a a' 'b b b'", resolvedShorthand.get(0).getExpression()); } @Test @@ -121,11 +120,11 @@ public void areaWithRowsTest() { String shorthand = " 'a a a' 20% 'b b b' auto"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(2, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.GRID_TEMPLATE_ROWS, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals(CommonCssConstants.GRID_TEMPLATE_AREAS, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals("20% auto", resolvedShorthand.get(0).getExpression()); - Assert.assertEquals("'a a a' 'b b b'", resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals(2, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.GRID_TEMPLATE_ROWS, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals(CommonCssConstants.GRID_TEMPLATE_AREAS, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals("20% auto", resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals("'a a a' 'b b b'", resolvedShorthand.get(1).getExpression()); } @Test @@ -135,13 +134,13 @@ public void areaWithRowsAndColumnsTest() { String shorthand = " 'a a a' 20% 'b b b' auto / auto 1fr auto"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(3, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.GRID_TEMPLATE_ROWS, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals(CommonCssConstants.GRID_TEMPLATE_COLUMNS, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals(CommonCssConstants.GRID_TEMPLATE_AREAS, resolvedShorthand.get(2).getProperty()); - Assert.assertEquals("20% auto", resolvedShorthand.get(0).getExpression()); - Assert.assertEquals("auto 1fr auto", resolvedShorthand.get(1).getExpression()); - Assert.assertEquals("'a a a' 'b b b'", resolvedShorthand.get(2).getExpression()); + Assertions.assertEquals(3, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.GRID_TEMPLATE_ROWS, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals(CommonCssConstants.GRID_TEMPLATE_COLUMNS, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals(CommonCssConstants.GRID_TEMPLATE_AREAS, resolvedShorthand.get(2).getProperty()); + Assertions.assertEquals("20% auto", resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals("auto 1fr auto", resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals("'a a a' 'b b b'", resolvedShorthand.get(2).getExpression()); } @Test @@ -151,13 +150,13 @@ public void areaWithMissingRowAtTheEndTest() { String shorthand = " 'a a a' 20% 'b b b' 1fr 'c c c' / auto 1fr auto"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(3, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.GRID_TEMPLATE_ROWS, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals(CommonCssConstants.GRID_TEMPLATE_COLUMNS, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals(CommonCssConstants.GRID_TEMPLATE_AREAS, resolvedShorthand.get(2).getProperty()); - Assert.assertEquals("20% 1fr auto", resolvedShorthand.get(0).getExpression()); - Assert.assertEquals("auto 1fr auto", resolvedShorthand.get(1).getExpression()); - Assert.assertEquals("'a a a' 'b b b' 'c c c'", resolvedShorthand.get(2).getExpression()); + Assertions.assertEquals(3, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.GRID_TEMPLATE_ROWS, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals(CommonCssConstants.GRID_TEMPLATE_COLUMNS, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals(CommonCssConstants.GRID_TEMPLATE_AREAS, resolvedShorthand.get(2).getProperty()); + Assertions.assertEquals("20% 1fr auto", resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals("auto 1fr auto", resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals("'a a a' 'b b b' 'c c c'", resolvedShorthand.get(2).getExpression()); } @Test @@ -167,13 +166,13 @@ public void areaWithMissingRowAtTheStartTest() { String shorthand = " 'a a a' 'b b b' 1fr 'c c c' 80% / auto 1fr auto"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(3, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.GRID_TEMPLATE_ROWS, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals(CommonCssConstants.GRID_TEMPLATE_COLUMNS, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals(CommonCssConstants.GRID_TEMPLATE_AREAS, resolvedShorthand.get(2).getProperty()); - Assert.assertEquals("auto 1fr 80%", resolvedShorthand.get(0).getExpression()); - Assert.assertEquals("auto 1fr auto", resolvedShorthand.get(1).getExpression()); - Assert.assertEquals("'a a a' 'b b b' 'c c c'", resolvedShorthand.get(2).getExpression()); + Assertions.assertEquals(3, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.GRID_TEMPLATE_ROWS, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals(CommonCssConstants.GRID_TEMPLATE_COLUMNS, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals(CommonCssConstants.GRID_TEMPLATE_AREAS, resolvedShorthand.get(2).getProperty()); + Assertions.assertEquals("auto 1fr 80%", resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals("auto 1fr auto", resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals("'a a a' 'b b b' 'c c c'", resolvedShorthand.get(2).getExpression()); } @Test @@ -183,13 +182,13 @@ public void complexAreaTest() { String shorthand = "[header-top] 'a a a' [header-bottom] [main-top] 'b b b' 1fr [main-bottom] / auto 1fr auto"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(3, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.GRID_TEMPLATE_ROWS, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals(CommonCssConstants.GRID_TEMPLATE_COLUMNS, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals(CommonCssConstants.GRID_TEMPLATE_AREAS, resolvedShorthand.get(2).getProperty()); - Assert.assertEquals("[header-top] [header-bottom] [main-top] 1fr [main-bottom]", resolvedShorthand.get(0).getExpression()); - Assert.assertEquals("auto 1fr auto", resolvedShorthand.get(1).getExpression()); - Assert.assertEquals("'a a a' 'b b b'", resolvedShorthand.get(2).getExpression()); + Assertions.assertEquals(3, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.GRID_TEMPLATE_ROWS, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals(CommonCssConstants.GRID_TEMPLATE_COLUMNS, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals(CommonCssConstants.GRID_TEMPLATE_AREAS, resolvedShorthand.get(2).getProperty()); + Assertions.assertEquals("[header-top] [header-bottom] [main-top] 1fr [main-bottom]", resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals("auto 1fr auto", resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals("'a a a' 'b b b'", resolvedShorthand.get(2).getExpression()); } @Test @@ -199,12 +198,12 @@ public void complexAreaWithoutLineNamesTest() { String shorthand = "'head head' 30px 'nav main' 1fr 'nav foot' 30px / 120px 1fr"; List resolvedShorthand = resolver.resolveShorthand(shorthand); - Assert.assertEquals(3, resolvedShorthand.size()); - Assert.assertEquals(CommonCssConstants.GRID_TEMPLATE_ROWS, resolvedShorthand.get(0).getProperty()); - Assert.assertEquals(CommonCssConstants.GRID_TEMPLATE_COLUMNS, resolvedShorthand.get(1).getProperty()); - Assert.assertEquals(CommonCssConstants.GRID_TEMPLATE_AREAS, resolvedShorthand.get(2).getProperty()); - Assert.assertEquals("30px 1fr 30px", resolvedShorthand.get(0).getExpression()); - Assert.assertEquals("120px 1fr", resolvedShorthand.get(1).getExpression()); - Assert.assertEquals("'head head' 'nav main' 'nav foot'", resolvedShorthand.get(2).getExpression()); + Assertions.assertEquals(3, resolvedShorthand.size()); + Assertions.assertEquals(CommonCssConstants.GRID_TEMPLATE_ROWS, resolvedShorthand.get(0).getProperty()); + Assertions.assertEquals(CommonCssConstants.GRID_TEMPLATE_COLUMNS, resolvedShorthand.get(1).getProperty()); + Assertions.assertEquals(CommonCssConstants.GRID_TEMPLATE_AREAS, resolvedShorthand.get(2).getProperty()); + Assertions.assertEquals("30px 1fr 30px", resolvedShorthand.get(0).getExpression()); + Assertions.assertEquals("120px 1fr", resolvedShorthand.get(1).getExpression()); + Assertions.assertEquals("'head head' 'nav main' 'nav foot'", resolvedShorthand.get(2).getExpression()); } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/selector/item/CssMatchesTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/selector/item/CssMatchesTest.java index 0f17e578d8..6ced8b4bd5 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/selector/item/CssMatchesTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/selector/item/CssMatchesTest.java @@ -28,12 +28,11 @@ This file is part of the iText (R) project. import com.itextpdf.styledxmlparser.node.INode; import com.itextpdf.styledxmlparser.node.impl.jsoup.JsoupHtmlParser; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class CssMatchesTest extends ExtendedITextTest { @Test @@ -49,7 +48,7 @@ public void matchesEmptySelectorItemTest() { .childNodes().get(0) .childNodes().get(0); - Assert.assertTrue(item.matches(divNode)); + Assertions.assertTrue(item.matches(divNode)); } @Test @@ -64,7 +63,7 @@ public void matchesEmptySelectorItemNotTaggedTextTest() { INode divNode = bodyNode .childNodes().get(0); - Assert.assertFalse(item.matches(divNode)); + Assertions.assertFalse(item.matches(divNode)); } @Test @@ -79,7 +78,7 @@ public void matchesEmptySelectorItemSpaceTest() { INode divNode = bodyNode .childNodes().get(0); - Assert.assertFalse(item.matches(divNode)); + Assertions.assertFalse(item.matches(divNode)); } @Test @@ -95,7 +94,7 @@ public void matchesFirstOfTypeSelectorItemTest() { .childNodes().get(0) .childNodes().get(0); - Assert.assertTrue(item.matches(divNode)); + Assertions.assertTrue(item.matches(divNode)); } @Test @@ -110,7 +109,7 @@ public void matchesFirstOfTypeSelectorItemTestNotTaggedText() { INode divNode = bodyNode .childNodes().get(0); - Assert.assertFalse(item.matches(divNode)); + Assertions.assertFalse(item.matches(divNode)); } @Test @@ -126,7 +125,7 @@ public void matchesLastOfTypeSelectorItemTest() { .childNodes().get(0) .childNodes().get(1); - Assert.assertTrue(item.matches(divNode)); + Assertions.assertTrue(item.matches(divNode)); } @Test @@ -141,7 +140,7 @@ public void matchesLastOfTypeSelectorItemTestNotTaggedText() { INode divNode = bodyNode .childNodes().get(0); - Assert.assertFalse(item.matches(divNode)); + Assertions.assertFalse(item.matches(divNode)); } @Test @@ -157,7 +156,7 @@ public void matchesLastChildSelectorItemTest() { .childNodes().get(0) .childNodes().get(1); - Assert.assertTrue(item.matches(divNode)); + Assertions.assertTrue(item.matches(divNode)); } @Test @@ -172,7 +171,7 @@ public void matchesLastChildSelectorItemTestNotTaggedText() { INode divNode = bodyNode .childNodes().get(0); - Assert.assertFalse(item.matches(divNode)); + Assertions.assertFalse(item.matches(divNode)); } @Test @@ -188,7 +187,7 @@ public void matchesNthOfTypeSelectorItemTest() { .childNodes().get(0) .childNodes().get(0); - Assert.assertTrue(item.matches(divNode)); + Assertions.assertTrue(item.matches(divNode)); } @Test @@ -203,7 +202,7 @@ public void matchesNthOfTypeSelectorItemTestNotTaggedText() { INode divNode = bodyNode .childNodes().get(0); - Assert.assertFalse(item.matches(divNode)); + Assertions.assertFalse(item.matches(divNode)); } @Test @@ -219,7 +218,7 @@ public void matchesNthOfTypeSelectorItemTestBadNodeArgument() { .childNodes().get(0) .childNodes().get(0); - Assert.assertFalse(item.matches(divNode)); + Assertions.assertFalse(item.matches(divNode)); } @Test @@ -231,7 +230,7 @@ public void matchesRootSelectorItemTest() { INode headNode = documentNode .childNodes().get(0); - Assert.assertTrue(item.matches(headNode)); + Assertions.assertTrue(item.matches(headNode)); } @Test @@ -246,6 +245,6 @@ public void matchesRootSelectorItemTestNotTaggedText() { INode divNode = bodyNode .childNodes().get(0); - Assert.assertFalse(item.matches(divNode)); + Assertions.assertFalse(item.matches(divNode)); } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/selector/item/CssPseudoClassDisabledSelectorItemTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/selector/item/CssPseudoClassDisabledSelectorItemTest.java index 5e6e4168ae..d420037974 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/selector/item/CssPseudoClassDisabledSelectorItemTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/selector/item/CssPseudoClassDisabledSelectorItemTest.java @@ -34,16 +34,15 @@ This file is part of the iText (R) project. import com.itextpdf.styledxmlparser.node.impl.jsoup.node.JsoupDocumentNode; import com.itextpdf.styledxmlparser.node.impl.jsoup.node.JsoupElementNode; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; -@Category(UnitTest.class) +@Tag("UnitTest") public class CssPseudoClassDisabledSelectorItemTest extends ExtendedITextTest { private static final String sourceFolder = "./src/test/resources/com/itextpdf/styledxmlparser/css/selector/item/CssPseudoClassDisabledSelectorItemTest/"; @@ -58,9 +57,9 @@ public void testDisabledSelector() throws IOException { IElementNode disabledInput = new JsoupElementNode(((JsoupDocumentNode)documentNode).getDocument().getElementsByTag("input").first()); IElementNode enabledInput = new JsoupElementNode(((JsoupDocumentNode)documentNode).getDocument().getElementsByTag("input").get(1)); - Assert.assertFalse(item.matches(documentNode)); - Assert.assertTrue(item.matches(disabledInput)); - Assert.assertFalse(item.matches(enabledInput)); - Assert.assertFalse(item.matches(null)); + Assertions.assertFalse(item.matches(documentNode)); + Assertions.assertTrue(item.matches(disabledInput)); + Assertions.assertFalse(item.matches(enabledInput)); + Assertions.assertFalse(item.matches(null)); } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/selector/item/SpecificityCalculationTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/selector/item/SpecificityCalculationTest.java index 0497bb1dd5..a695f9f4ad 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/selector/item/SpecificityCalculationTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/selector/item/SpecificityCalculationTest.java @@ -25,12 +25,11 @@ This file is part of the iText (R) project. import com.itextpdf.styledxmlparser.css.selector.CssPageSelector; import com.itextpdf.styledxmlparser.css.selector.CssSelector; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class SpecificityCalculationTest extends ExtendedITextTest { // https://www.smashingmagazine.com/2007/07/css-specificity-things-you-should-know/ @@ -38,143 +37,143 @@ public class SpecificityCalculationTest extends ExtendedITextTest { @Test public void test01() { - Assert.assertEquals(0, getSpecificity("*")); + Assertions.assertEquals(0, getSpecificity("*")); } @Test public void test02() { - Assert.assertEquals(1, getSpecificity("li")); + Assertions.assertEquals(1, getSpecificity("li")); } @Test public void test03() { - Assert.assertEquals(2, getSpecificity("li:first-line")); + Assertions.assertEquals(2, getSpecificity("li:first-line")); } @Test public void test04() { - Assert.assertEquals(2, getSpecificity("ul li")); + Assertions.assertEquals(2, getSpecificity("ul li")); } @Test public void test05() { - Assert.assertEquals(3, getSpecificity("ul ol+li")); + Assertions.assertEquals(3, getSpecificity("ul ol+li")); } @Test public void test06() { - Assert.assertEquals(CssSpecificityConstants.CLASS_SPECIFICITY + CssSpecificityConstants.ELEMENT_SPECIFICITY, getSpecificity("h1 + *[rel=up]")); + Assertions.assertEquals(CssSpecificityConstants.CLASS_SPECIFICITY + CssSpecificityConstants.ELEMENT_SPECIFICITY, getSpecificity("h1 + *[rel=up]")); } @Test public void test07() { - Assert.assertEquals(CssSpecificityConstants.CLASS_SPECIFICITY + CssSpecificityConstants.ELEMENT_SPECIFICITY * 3, getSpecificity("ul ol li.red")); + Assertions.assertEquals(CssSpecificityConstants.CLASS_SPECIFICITY + CssSpecificityConstants.ELEMENT_SPECIFICITY * 3, getSpecificity("ul ol li.red")); } @Test public void test08() { - Assert.assertEquals(CssSpecificityConstants.CLASS_SPECIFICITY * 2 + CssSpecificityConstants.ELEMENT_SPECIFICITY, getSpecificity("li.red.level")); + Assertions.assertEquals(CssSpecificityConstants.CLASS_SPECIFICITY * 2 + CssSpecificityConstants.ELEMENT_SPECIFICITY, getSpecificity("li.red.level")); } @Test public void test09() { - Assert.assertEquals(CssSpecificityConstants.CLASS_SPECIFICITY, getSpecificity(".sith")); + Assertions.assertEquals(CssSpecificityConstants.CLASS_SPECIFICITY, getSpecificity(".sith")); } @Test public void test10() { - Assert.assertEquals(CssSpecificityConstants.CLASS_SPECIFICITY + CssSpecificityConstants.ELEMENT_SPECIFICITY * 2, getSpecificity("div p.sith")); + Assertions.assertEquals(CssSpecificityConstants.CLASS_SPECIFICITY + CssSpecificityConstants.ELEMENT_SPECIFICITY * 2, getSpecificity("div p.sith")); } @Test public void test11() { - Assert.assertEquals(CssSpecificityConstants.ID_SPECIFICITY, getSpecificity("#sith")); + Assertions.assertEquals(CssSpecificityConstants.ID_SPECIFICITY, getSpecificity("#sith")); } @Test public void test12() { - Assert.assertEquals(CssSpecificityConstants.ID_SPECIFICITY + CssSpecificityConstants.CLASS_SPECIFICITY + CssSpecificityConstants.ELEMENT_SPECIFICITY * 2, getSpecificity("body #darkside .sith p")); + Assertions.assertEquals(CssSpecificityConstants.ID_SPECIFICITY + CssSpecificityConstants.CLASS_SPECIFICITY + CssSpecificityConstants.ELEMENT_SPECIFICITY * 2, getSpecificity("body #darkside .sith p")); } @Test public void test13() { - Assert.assertEquals(CssSpecificityConstants.CLASS_SPECIFICITY * 2 + CssSpecificityConstants.ELEMENT_SPECIFICITY * 2, getSpecificity("li:first-child h2 .title")); + Assertions.assertEquals(CssSpecificityConstants.CLASS_SPECIFICITY * 2 + CssSpecificityConstants.ELEMENT_SPECIFICITY * 2, getSpecificity("li:first-child h2 .title")); } @Test public void test14() { - Assert.assertEquals(CssSpecificityConstants.ID_SPECIFICITY + CssSpecificityConstants.CLASS_SPECIFICITY * 2 + CssSpecificityConstants.ELEMENT_SPECIFICITY, getSpecificity("#nav .selected > a:hover")); + Assertions.assertEquals(CssSpecificityConstants.ID_SPECIFICITY + CssSpecificityConstants.CLASS_SPECIFICITY * 2 + CssSpecificityConstants.ELEMENT_SPECIFICITY, getSpecificity("#nav .selected > a:hover")); } @Test public void test15() { - Assert.assertEquals(2, getSpecificity("p:before")); - Assert.assertEquals(2, getSpecificity("p::before")); + Assertions.assertEquals(2, getSpecificity("p:before")); + Assertions.assertEquals(2, getSpecificity("p::before")); } @Test public void test16() { - Assert.assertEquals(2, getSpecificity("a::hover")); + Assertions.assertEquals(2, getSpecificity("a::hover")); } @Test public void test17() { - Assert.assertEquals(CssSpecificityConstants.CLASS_SPECIFICITY * 2, getSpecificity(".class_name:nth-child(3n + 1)")); + Assertions.assertEquals(CssSpecificityConstants.CLASS_SPECIFICITY * 2, getSpecificity(".class_name:nth-child(3n + 1)")); } @Test public void test18() { - Assert.assertEquals(CssSpecificityConstants.CLASS_SPECIFICITY * 2, getSpecificity(".class_name:nth-child(2n - 3)")); + Assertions.assertEquals(CssSpecificityConstants.CLASS_SPECIFICITY * 2, getSpecificity(".class_name:nth-child(2n - 3)")); } @Test public void test19() { - Assert.assertEquals(CssSpecificityConstants.CLASS_SPECIFICITY * 2, getSpecificity(".class_name:hover")); + Assertions.assertEquals(CssSpecificityConstants.CLASS_SPECIFICITY * 2, getSpecificity(".class_name:hover")); } @Test public void test20() { - Assert.assertEquals(CssSpecificityConstants.CLASS_SPECIFICITY, getSpecificity(":not(p)")); + Assertions.assertEquals(CssSpecificityConstants.CLASS_SPECIFICITY, getSpecificity(":not(p)")); } @Test public void test21() { - Assert.assertEquals(CssSpecificityConstants.CLASS_SPECIFICITY, getSpecificity(":not(#id)")); + Assertions.assertEquals(CssSpecificityConstants.CLASS_SPECIFICITY, getSpecificity(":not(#id)")); } @Test public void test22() { - Assert.assertEquals(CssSpecificityConstants.CLASS_SPECIFICITY, getSpecificity(":not(.class_name)")); + Assertions.assertEquals(CssSpecificityConstants.CLASS_SPECIFICITY, getSpecificity(":not(.class_name)")); } @Test public void pageTest01() { - Assert.assertEquals(CssSpecificityConstants.ID_SPECIFICITY, getPageSelectorSpecificity("customPageName")); + Assertions.assertEquals(CssSpecificityConstants.ID_SPECIFICITY, getPageSelectorSpecificity("customPageName")); } @Test public void pageTest02() { - Assert.assertEquals(CssSpecificityConstants.ID_SPECIFICITY + CssSpecificityConstants.CLASS_SPECIFICITY, getPageSelectorSpecificity("customPageName:first")); + Assertions.assertEquals(CssSpecificityConstants.ID_SPECIFICITY + CssSpecificityConstants.CLASS_SPECIFICITY, getPageSelectorSpecificity("customPageName:first")); } @Test public void pageTest03() { - Assert.assertEquals(CssSpecificityConstants.ID_SPECIFICITY + CssSpecificityConstants.CLASS_SPECIFICITY * 2, getPageSelectorSpecificity("customPageName:first:blank")); + Assertions.assertEquals(CssSpecificityConstants.ID_SPECIFICITY + CssSpecificityConstants.CLASS_SPECIFICITY * 2, getPageSelectorSpecificity("customPageName:first:blank")); } @Test public void pageTest04() { - Assert.assertEquals(CssSpecificityConstants.ELEMENT_SPECIFICITY * 2, getPageSelectorSpecificity(":left:right")); + Assertions.assertEquals(CssSpecificityConstants.ELEMENT_SPECIFICITY * 2, getPageSelectorSpecificity(":left:right")); } @Test public void pageTest05() { - Assert.assertEquals(CssSpecificityConstants.ID_SPECIFICITY + CssSpecificityConstants.CLASS_SPECIFICITY, getPageSelectorSpecificity("left:blank")); + Assertions.assertEquals(CssSpecificityConstants.ID_SPECIFICITY + CssSpecificityConstants.CLASS_SPECIFICITY, getPageSelectorSpecificity("left:blank")); } @Test public void pageTest06() { - Assert.assertEquals(CssSpecificityConstants.ELEMENT_SPECIFICITY + CssSpecificityConstants.CLASS_SPECIFICITY, getPageSelectorSpecificity(":left:blank")); + Assertions.assertEquals(CssSpecificityConstants.ELEMENT_SPECIFICITY + CssSpecificityConstants.CLASS_SPECIFICITY, getPageSelectorSpecificity(":left:blank")); } private int getSpecificity(String selector) { diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/util/CssBackgroundUtilsTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/util/CssBackgroundUtilsTest.java index 5296be13b3..70ee11a785 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/util/CssBackgroundUtilsTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/util/CssBackgroundUtilsTest.java @@ -28,89 +28,88 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class CssBackgroundUtilsTest extends ExtendedITextTest { @Test public void parseBackgroundRepeatTest() { - Assert.assertEquals(BackgroundRepeatValue.REPEAT, CssBackgroundUtils.parseBackgroundRepeat("repeat")); - Assert.assertEquals(BackgroundRepeatValue.REPEAT, CssBackgroundUtils.parseBackgroundRepeat("RePeAt")); + Assertions.assertEquals(BackgroundRepeatValue.REPEAT, CssBackgroundUtils.parseBackgroundRepeat("repeat")); + Assertions.assertEquals(BackgroundRepeatValue.REPEAT, CssBackgroundUtils.parseBackgroundRepeat("RePeAt")); - Assert.assertEquals(BackgroundRepeatValue.NO_REPEAT, CssBackgroundUtils.parseBackgroundRepeat("no-repeat")); - Assert.assertEquals(BackgroundRepeatValue.REPEAT, CssBackgroundUtils.parseBackgroundRepeat("no- repeat")); + Assertions.assertEquals(BackgroundRepeatValue.NO_REPEAT, CssBackgroundUtils.parseBackgroundRepeat("no-repeat")); + Assertions.assertEquals(BackgroundRepeatValue.REPEAT, CssBackgroundUtils.parseBackgroundRepeat("no- repeat")); - Assert.assertEquals(BackgroundRepeatValue.ROUND, CssBackgroundUtils.parseBackgroundRepeat("round")); - Assert.assertEquals(BackgroundRepeatValue.REPEAT, CssBackgroundUtils.parseBackgroundRepeat("ro!und")); + Assertions.assertEquals(BackgroundRepeatValue.ROUND, CssBackgroundUtils.parseBackgroundRepeat("round")); + Assertions.assertEquals(BackgroundRepeatValue.REPEAT, CssBackgroundUtils.parseBackgroundRepeat("ro!und")); - Assert.assertEquals(BackgroundRepeatValue.SPACE, CssBackgroundUtils.parseBackgroundRepeat("space")); - Assert.assertEquals(BackgroundRepeatValue.REPEAT, CssBackgroundUtils.parseBackgroundRepeat(" space ")); + Assertions.assertEquals(BackgroundRepeatValue.SPACE, CssBackgroundUtils.parseBackgroundRepeat("space")); + Assertions.assertEquals(BackgroundRepeatValue.REPEAT, CssBackgroundUtils.parseBackgroundRepeat(" space ")); - Assert.assertEquals(BackgroundRepeatValue.REPEAT, CssBackgroundUtils.parseBackgroundRepeat("something")); + Assertions.assertEquals(BackgroundRepeatValue.REPEAT, CssBackgroundUtils.parseBackgroundRepeat("something")); } @LogMessages(messages = {@LogMessage(messageTemplate = StyledXmlParserLogMessageConstant.URL_IS_NOT_CLOSED_IN_CSS_EXPRESSION)}) @Test public void resolveBackgroundPropertyTypeTest() { - Assert.assertEquals(CssBackgroundUtils.BackgroundPropertyType.UNDEFINED, + Assertions.assertEquals(CssBackgroundUtils.BackgroundPropertyType.UNDEFINED, CssBackgroundUtils.resolveBackgroundPropertyType("jaja")); - Assert.assertEquals(CssBackgroundUtils.BackgroundPropertyType.UNDEFINED, + Assertions.assertEquals(CssBackgroundUtils.BackgroundPropertyType.UNDEFINED, CssBackgroundUtils.resolveBackgroundPropertyType("ul(rock_texture.jpg)")); - Assert.assertEquals(CssBackgroundUtils.BackgroundPropertyType.UNDEFINED, + Assertions.assertEquals(CssBackgroundUtils.BackgroundPropertyType.UNDEFINED, CssBackgroundUtils.resolveBackgroundPropertyType("url(rock_texture.jpg")); - Assert.assertEquals(CssBackgroundUtils.BackgroundPropertyType.UNDEFINED, + Assertions.assertEquals(CssBackgroundUtils.BackgroundPropertyType.UNDEFINED, CssBackgroundUtils.resolveBackgroundPropertyType("url(rock(_texture.jpg)")); - Assert.assertEquals(CssBackgroundUtils.BackgroundPropertyType.UNDEFINED, + Assertions.assertEquals(CssBackgroundUtils.BackgroundPropertyType.UNDEFINED, CssBackgroundUtils.resolveBackgroundPropertyType("url(rock_t(ext)ure.jpg)")); - Assert.assertEquals(CssBackgroundUtils.BackgroundPropertyType.UNDEFINED, + Assertions.assertEquals(CssBackgroundUtils.BackgroundPropertyType.UNDEFINED, CssBackgroundUtils.resolveBackgroundPropertyType("url(url(rock_texture.jpg)")); - Assert.assertEquals(CssBackgroundUtils.BackgroundPropertyType.BACKGROUND_IMAGE, + Assertions.assertEquals(CssBackgroundUtils.BackgroundPropertyType.BACKGROUND_IMAGE, CssBackgroundUtils.resolveBackgroundPropertyType("url(rock_texture.jpg)")); - Assert.assertEquals(CssBackgroundUtils.BackgroundPropertyType.BACKGROUND_IMAGE, + Assertions.assertEquals(CssBackgroundUtils.BackgroundPropertyType.BACKGROUND_IMAGE, CssBackgroundUtils.resolveBackgroundPropertyType("linear-gradient(#e66465, #9198e5)")); - Assert.assertEquals(CssBackgroundUtils.BackgroundPropertyType.BACKGROUND_IMAGE, + Assertions.assertEquals(CssBackgroundUtils.BackgroundPropertyType.BACKGROUND_IMAGE, CssBackgroundUtils.resolveBackgroundPropertyType("none")); - Assert.assertEquals(CssBackgroundUtils.BackgroundPropertyType.BACKGROUND_REPEAT, + Assertions.assertEquals(CssBackgroundUtils.BackgroundPropertyType.BACKGROUND_REPEAT, CssBackgroundUtils.resolveBackgroundPropertyType("repeat-x")); - Assert.assertEquals(CssBackgroundUtils.BackgroundPropertyType.BACKGROUND_POSITION_X, + Assertions.assertEquals(CssBackgroundUtils.BackgroundPropertyType.BACKGROUND_POSITION_X, CssBackgroundUtils.resolveBackgroundPropertyType("left")); - Assert.assertEquals(CssBackgroundUtils.BackgroundPropertyType.BACKGROUND_POSITION_Y, + Assertions.assertEquals(CssBackgroundUtils.BackgroundPropertyType.BACKGROUND_POSITION_Y, CssBackgroundUtils.resolveBackgroundPropertyType("bottom")); - Assert.assertEquals(CssBackgroundUtils.BackgroundPropertyType.BACKGROUND_POSITION, + Assertions.assertEquals(CssBackgroundUtils.BackgroundPropertyType.BACKGROUND_POSITION, CssBackgroundUtils.resolveBackgroundPropertyType("center")); - Assert.assertEquals(CssBackgroundUtils.BackgroundPropertyType.BACKGROUND_POSITION_OR_SIZE, + Assertions.assertEquals(CssBackgroundUtils.BackgroundPropertyType.BACKGROUND_POSITION_OR_SIZE, CssBackgroundUtils.resolveBackgroundPropertyType("10%")); - Assert.assertEquals(CssBackgroundUtils.BackgroundPropertyType.BACKGROUND_SIZE, + Assertions.assertEquals(CssBackgroundUtils.BackgroundPropertyType.BACKGROUND_SIZE, CssBackgroundUtils.resolveBackgroundPropertyType("contain")); - Assert.assertEquals(CssBackgroundUtils.BackgroundPropertyType.BACKGROUND_ORIGIN_OR_CLIP, + Assertions.assertEquals(CssBackgroundUtils.BackgroundPropertyType.BACKGROUND_ORIGIN_OR_CLIP, CssBackgroundUtils.resolveBackgroundPropertyType("padding-box")); - Assert.assertEquals(CssBackgroundUtils.BackgroundPropertyType.BACKGROUND_ATTACHMENT, + Assertions.assertEquals(CssBackgroundUtils.BackgroundPropertyType.BACKGROUND_ATTACHMENT, CssBackgroundUtils.resolveBackgroundPropertyType("fixed")); } @Test public void getBackgroundPropertyNameFromType() { - Assert.assertEquals(CommonCssConstants.BACKGROUND_COLOR, + Assertions.assertEquals(CommonCssConstants.BACKGROUND_COLOR, CssBackgroundUtils.getBackgroundPropertyNameFromType(CssBackgroundUtils.BackgroundPropertyType.BACKGROUND_COLOR)); - Assert.assertEquals(CommonCssConstants.BACKGROUND_IMAGE, + Assertions.assertEquals(CommonCssConstants.BACKGROUND_IMAGE, CssBackgroundUtils.getBackgroundPropertyNameFromType(CssBackgroundUtils.BackgroundPropertyType.BACKGROUND_IMAGE)); - Assert.assertEquals(CommonCssConstants.BACKGROUND_CLIP, + Assertions.assertEquals(CommonCssConstants.BACKGROUND_CLIP, CssBackgroundUtils.getBackgroundPropertyNameFromType(CssBackgroundUtils.BackgroundPropertyType.BACKGROUND_CLIP)); - Assert.assertEquals(CommonCssConstants.BACKGROUND_ORIGIN, + Assertions.assertEquals(CommonCssConstants.BACKGROUND_ORIGIN, CssBackgroundUtils.getBackgroundPropertyNameFromType(CssBackgroundUtils.BackgroundPropertyType.BACKGROUND_ORIGIN)); - Assert.assertEquals(CommonCssConstants.BACKGROUND_POSITION, + Assertions.assertEquals(CommonCssConstants.BACKGROUND_POSITION, CssBackgroundUtils.getBackgroundPropertyNameFromType(CssBackgroundUtils.BackgroundPropertyType.BACKGROUND_POSITION)); - Assert.assertEquals(CommonCssConstants.BACKGROUND_REPEAT, + Assertions.assertEquals(CommonCssConstants.BACKGROUND_REPEAT, CssBackgroundUtils.getBackgroundPropertyNameFromType(CssBackgroundUtils.BackgroundPropertyType.BACKGROUND_REPEAT)); - Assert.assertEquals(CommonCssConstants.BACKGROUND_SIZE, + Assertions.assertEquals(CommonCssConstants.BACKGROUND_SIZE, CssBackgroundUtils.getBackgroundPropertyNameFromType(CssBackgroundUtils.BackgroundPropertyType.BACKGROUND_SIZE)); - Assert.assertEquals(CommonCssConstants.BACKGROUND_ATTACHMENT, + Assertions.assertEquals(CommonCssConstants.BACKGROUND_ATTACHMENT, CssBackgroundUtils.getBackgroundPropertyNameFromType(CssBackgroundUtils.BackgroundPropertyType.BACKGROUND_ATTACHMENT)); - Assert.assertEquals(CommonCssConstants.UNDEFINED_NAME, + Assertions.assertEquals(CommonCssConstants.UNDEFINED_NAME, CssBackgroundUtils.getBackgroundPropertyNameFromType(CssBackgroundUtils.BackgroundPropertyType.UNDEFINED)); } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/util/CssDimensionParsingUtilsTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/util/CssDimensionParsingUtilsTest.java index e3b4fd8cc0..b802826222 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/util/CssDimensionParsingUtilsTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/util/CssDimensionParsingUtilsTest.java @@ -32,60 +32,59 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class CssDimensionParsingUtilsTest extends ExtendedITextTest { private static final float EPS = 0.0001f; @Test public void parseAbsoluteFontSizeTest() { - Assert.assertEquals(75, CssDimensionParsingUtils.parseAbsoluteFontSize("100", CommonCssConstants.PX), EPS); - Assert.assertEquals(75, CssDimensionParsingUtils.parseAbsoluteFontSize("100px"), EPS); - Assert.assertEquals(12, CssDimensionParsingUtils.parseAbsoluteFontSize(CommonCssConstants.MEDIUM), EPS); - Assert.assertEquals(0, CssDimensionParsingUtils.parseAbsoluteFontSize("", ""), EPS); + Assertions.assertEquals(75, CssDimensionParsingUtils.parseAbsoluteFontSize("100", CommonCssConstants.PX), EPS); + Assertions.assertEquals(75, CssDimensionParsingUtils.parseAbsoluteFontSize("100px"), EPS); + Assertions.assertEquals(12, CssDimensionParsingUtils.parseAbsoluteFontSize(CommonCssConstants.MEDIUM), EPS); + Assertions.assertEquals(0, CssDimensionParsingUtils.parseAbsoluteFontSize("", ""), EPS); } @Test public void parseRelativeFontSizeTest() { - Assert.assertEquals(120, CssDimensionParsingUtils.parseRelativeFontSize("10em", 12), EPS); - Assert.assertEquals(12.5f, CssDimensionParsingUtils.parseRelativeFontSize(CommonCssConstants.SMALLER, 15), EPS); + Assertions.assertEquals(120, CssDimensionParsingUtils.parseRelativeFontSize("10em", 12), EPS); + Assertions.assertEquals(12.5f, CssDimensionParsingUtils.parseRelativeFontSize(CommonCssConstants.SMALLER, 15), EPS); } @Test public void parseResolutionValidDpiUnit() { - Assert.assertEquals(10f, CssDimensionParsingUtils.parseResolution("10dpi"), 0); + Assertions.assertEquals(10f, CssDimensionParsingUtils.parseResolution("10dpi"), 0); } @Test public void parseResolutionValidDpcmUnit() { - Assert.assertEquals(25.4f, CssDimensionParsingUtils.parseResolution("10dpcm"), 0); + Assertions.assertEquals(25.4f, CssDimensionParsingUtils.parseResolution("10dpcm"), 0); } @Test public void parseResolutionValidDppxUnit() { - Assert.assertEquals(960f, CssDimensionParsingUtils.parseResolution("10dppx"), 0); + Assertions.assertEquals(960f, CssDimensionParsingUtils.parseResolution("10dppx"), 0); } @Test public void parseResolutionInvalidUnit() { - Exception e = Assert.assertThrows(StyledXMLParserException.class, + Exception e = Assertions.assertThrows(StyledXMLParserException.class, () -> CssDimensionParsingUtils.parseResolution("10incorrectUnit") ); - Assert.assertEquals(StyledXmlParserLogMessageConstant.INCORRECT_RESOLUTION_UNIT_VALUE, e.getMessage()); + Assertions.assertEquals(StyledXmlParserLogMessageConstant.INCORRECT_RESOLUTION_UNIT_VALUE, e.getMessage()); } @Test public void parseInvalidFloat() { String value = "invalidFloat"; try { - Assert.assertNull(CssDimensionParsingUtils.parseFloat(value)); + Assertions.assertNull(CssDimensionParsingUtils.parseFloat(value)); } catch (Exception e){ - Assert.fail(); + Assertions.fail(); } } @@ -95,7 +94,7 @@ public void parseAbsoluteLengthFrom10px() { float actual = CssDimensionParsingUtils.parseAbsoluteLength(value, CommonCssConstants.PX); float expected = 7.5f; - Assert.assertEquals(expected, actual, 0); + Assertions.assertEquals(expected, actual, 0); } @Test @@ -104,7 +103,7 @@ public void parseAbsoluteLengthFrom10cm() { float actual = CssDimensionParsingUtils.parseAbsoluteLength(value, CommonCssConstants.CM); float expected = 283.46457f; - Assert.assertEquals(expected, actual, 0); + Assertions.assertEquals(expected, actual, 0); } @Test @@ -113,7 +112,7 @@ public void parseAbsoluteLengthFrom10in() { float actual = CssDimensionParsingUtils.parseAbsoluteLength(value, CommonCssConstants.IN); float expected = 720.0f; - Assert.assertEquals(expected, actual, 0); + Assertions.assertEquals(expected, actual, 0); } @Test @@ -122,7 +121,7 @@ public void parseAbsoluteLengthFrom10pt() { float actual = CssDimensionParsingUtils.parseAbsoluteLength(value, CommonCssConstants.PT); float expected = 10.0f; - Assert.assertEquals(expected, actual, 0); + Assertions.assertEquals(expected, actual, 0); } @Test @@ -132,30 +131,30 @@ public void parseAbsoluteLengthFromUnknownType() { float actual = CssDimensionParsingUtils.parseAbsoluteLength(value, "pateekes"); float expected = 10.0f; - Assert.assertEquals(expected, actual, 0); + Assertions.assertEquals(expected, actual, 0); } @Test public void parseLength() { - Assert.assertEquals(9, CssDimensionParsingUtils.parseAbsoluteLength("12"), 0); - Assert.assertEquals(576, CssDimensionParsingUtils.parseAbsoluteLength("8inch"), 0); - Assert.assertEquals(576, CssDimensionParsingUtils.parseAbsoluteLength("8", CommonCssConstants.IN), 0); + Assertions.assertEquals(9, CssDimensionParsingUtils.parseAbsoluteLength("12"), 0); + Assertions.assertEquals(576, CssDimensionParsingUtils.parseAbsoluteLength("8inch"), 0); + Assertions.assertEquals(576, CssDimensionParsingUtils.parseAbsoluteLength("8", CommonCssConstants.IN), 0); } @Test public void parseAbsoluteLengthTest() { - Assert.assertEquals(75, CssDimensionParsingUtils.parseAbsoluteLength("100", CommonCssConstants.PX), EPS); - Assert.assertEquals(75, CssDimensionParsingUtils.parseAbsoluteLength("100px"), EPS); + Assertions.assertEquals(75, CssDimensionParsingUtils.parseAbsoluteLength("100", CommonCssConstants.PX), EPS); + Assertions.assertEquals(75, CssDimensionParsingUtils.parseAbsoluteLength("100px"), EPS); } @Test public void parseAbsoluteLengthFromNAN() { String value = "Definitely not a number"; - Exception e = Assert.assertThrows(StyledXMLParserException.class, + Exception e = Assertions.assertThrows(StyledXMLParserException.class, () -> CssDimensionParsingUtils.parseAbsoluteLength(value) ); - Assert.assertEquals(MessageFormatUtil.format(StyledXMLParserException.NAN, "Definitely not a number"), + Assertions.assertEquals(MessageFormatUtil.format(StyledXMLParserException.NAN, "Definitely not a number"), e.getMessage()); } @@ -163,10 +162,10 @@ public void parseAbsoluteLengthFromNAN() { public void parseAbsoluteLengthFromNull() { String value = null; - Exception e = Assert.assertThrows(StyledXMLParserException.class, + Exception e = Assertions.assertThrows(StyledXMLParserException.class, () -> CssDimensionParsingUtils.parseAbsoluteLength(value) ); - Assert.assertEquals(MessageFormatUtil.format(StyledXMLParserException.NAN, "null"), e.getMessage()); + Assertions.assertEquals(MessageFormatUtil.format(StyledXMLParserException.NAN, "null"), e.getMessage()); } @Test @@ -175,7 +174,7 @@ public void parseAbsoluteLengthExponentialPtTest() { float actual = CssDimensionParsingUtils.parseAbsoluteLength(value); float expected = 1e2f; - Assert.assertEquals(expected, actual, 0); + Assertions.assertEquals(expected, actual, 0); } @Test @@ -184,7 +183,7 @@ public void parseAbsoluteLengthExponentialPxTest() { float actual = CssDimensionParsingUtils.parseAbsoluteLength(value); float expected = 1e2f * 0.75f; - Assert.assertEquals(expected, actual, 0); + Assertions.assertEquals(expected, actual, 0); } @Test @@ -193,7 +192,7 @@ public void parseAbsoluteLengthExponentialCapitalTest() { float actual = CssDimensionParsingUtils.parseAbsoluteLength(value); float expected = 1e-4f * 0.75f; - Assert.assertEquals(expected, actual, 1e-9); + Assertions.assertEquals(expected, actual, 1e-9); } @Test @@ -201,7 +200,7 @@ public void parseAbsoluteLength12cmTest() { // Calculations in CssUtils#parseAbsoluteLength were changed to work // with double values instead of float to improve precision and eliminate // the difference between java and .net. So the test verifies this fix. - Assert.assertEquals(340.15747f, CssDimensionParsingUtils.parseAbsoluteLength("12cm"), 0f); + Assertions.assertEquals(340.15747f, CssDimensionParsingUtils.parseAbsoluteLength("12cm"), 0f); } @@ -210,7 +209,7 @@ public void parseAbsoluteLength12qTest() { // Calculations in CssUtils#parseAbsoluteLength were changed to work // with double values instead of float to improve precision and eliminate // the difference between java and .net. So the test verifies this fix - Assert.assertEquals(8.503937f, CssDimensionParsingUtils.parseAbsoluteLength("12q"), 0f); + Assertions.assertEquals(8.503937f, CssDimensionParsingUtils.parseAbsoluteLength("12q"), 0f); } @Test @@ -218,7 +217,7 @@ public void parseDoubleIntegerValueTest(){ Double expectedString = 5.0; Double actualString = CssDimensionParsingUtils.parseDouble("5"); - Assert.assertEquals(expectedString, actualString); + Assertions.assertEquals(expectedString, actualString); } @Test @@ -226,7 +225,7 @@ public void parseDoubleManyCharsAfterDotTest(){ Double expectedString = 5.123456789; Double actualString = CssDimensionParsingUtils.parseDouble("5.123456789"); - Assert.assertEquals(expectedString, actualString); + Assertions.assertEquals(expectedString, actualString); } @Test @@ -234,7 +233,7 @@ public void parseDoubleManyCharsAfterDotNegativeTest(){ Double expectedString = -5.123456789; Double actualString = CssDimensionParsingUtils.parseDouble("-5.123456789"); - Assert.assertEquals(expectedString, actualString); + Assertions.assertEquals(expectedString, actualString); } @Test @@ -242,7 +241,7 @@ public void parseDoubleNullValueTest(){ Double expectedString = null; Double actualString = CssDimensionParsingUtils.parseDouble(null); - Assert.assertEquals(expectedString, actualString); + Assertions.assertEquals(expectedString, actualString); } @Test @@ -250,7 +249,7 @@ public void parseDoubleNegativeTextTest(){ Double expectedString = null; Double actualString = CssDimensionParsingUtils.parseDouble("text"); - Assert.assertEquals(expectedString, actualString); + Assertions.assertEquals(expectedString, actualString); } @Test @@ -258,8 +257,8 @@ public void parseSimpleDeviceCmykTest(){ TransparentColor expected = new TransparentColor(new DeviceCmyk(0f, 0.4f, 0.6f, 1f), 1); TransparentColor actual = CssDimensionParsingUtils.parseColor("device-cmyk(0 40% 60% 100%)"); - Assert.assertEquals(expected.getColor(), actual.getColor()); - Assert.assertEquals(expected.getOpacity(), actual.getOpacity(), 0.0001f); + Assertions.assertEquals(expected.getColor(), actual.getColor()); + Assertions.assertEquals(expected.getOpacity(), actual.getOpacity(), 0.0001f); } @Test @@ -267,8 +266,8 @@ public void parseDeviceCmykWithOpacityTest(){ TransparentColor expected = new TransparentColor(new DeviceCmyk(0f, 0.4f, 0.6f, 1f), 0.5f); TransparentColor actual = CssDimensionParsingUtils.parseColor("device-cmyk(0 40% 60% 100% / .5)"); - Assert.assertEquals(expected.getColor(), actual.getColor()); - Assert.assertEquals(expected.getOpacity(), actual.getOpacity(), 0.0001f); + Assertions.assertEquals(expected.getColor(), actual.getColor()); + Assertions.assertEquals(expected.getOpacity(), actual.getOpacity(), 0.0001f); } @Test @@ -276,8 +275,8 @@ public void parseDeviceCmykWithFallbackAndOpacityTest(){ TransparentColor expected = new TransparentColor(new DeviceCmyk(0f, 0.4f, 0.6f, 1f), 0.5f); TransparentColor actual = CssDimensionParsingUtils.parseColor("device-cmyk(0 40% 60% 100% / .5 rgb(178 34 34))"); - Assert.assertEquals(expected.getColor(), actual.getColor()); - Assert.assertEquals(expected.getOpacity(), actual.getOpacity(), 0.0001f); + Assertions.assertEquals(expected.getColor(), actual.getColor()); + Assertions.assertEquals(expected.getOpacity(), actual.getOpacity(), 0.0001f); } @Test @@ -285,8 +284,8 @@ public void parseRgbTest(){ TransparentColor expected = new TransparentColor(new DeviceRgb(255, 255, 128), 1f); TransparentColor actual = CssDimensionParsingUtils.parseColor("rgb(255, 255, 128)"); - Assert.assertEquals(expected.getColor(), actual.getColor()); - Assert.assertEquals(expected.getOpacity(), actual.getOpacity(), 0.0001f); + Assertions.assertEquals(expected.getColor(), actual.getColor()); + Assertions.assertEquals(expected.getOpacity(), actual.getOpacity(), 0.0001f); } @Test @@ -294,51 +293,51 @@ public void parseInvalidColorTest(){ TransparentColor expected = new TransparentColor(new DeviceRgb(0, 0, 0), 1f); TransparentColor actual = CssDimensionParsingUtils.parseColor("currentcolor"); - Assert.assertEquals(expected.getColor(), actual.getColor()); - Assert.assertEquals(expected.getOpacity(), actual.getOpacity(), 0.0001f); + Assertions.assertEquals(expected.getColor(), actual.getColor()); + Assertions.assertEquals(expected.getOpacity(), actual.getOpacity(), 0.0001f); } @Test public void parseLengthAbsoluteTest() { float result = CssDimensionParsingUtils.parseLength("10pt", 1, 2, 1, 1); - Assert.assertEquals(10, result, 0.0001f); + Assertions.assertEquals(10, result, 0.0001f); result = CssDimensionParsingUtils.parseLength("10px", 1, 1, 2, 1); - Assert.assertEquals(7.5, result, 0.0001f); + Assertions.assertEquals(7.5, result, 0.0001f); result = CssDimensionParsingUtils.parseLength("10in", 1, 1, 2, 1); - Assert.assertEquals(720, result, 0.0001f); + Assertions.assertEquals(720, result, 0.0001f); } @Test public void parseLengthPercentTest() { final float result = CssDimensionParsingUtils.parseLength("10%", 10, 2, 1, 1); - Assert.assertEquals(1, result, 0.0001f); + Assertions.assertEquals(1, result, 0.0001f); } @Test public void parseLengthFontTest() { float result = CssDimensionParsingUtils.parseLength("10em", 10, 2, 8, 9); - Assert.assertEquals(80, result, 0.0001f); + Assertions.assertEquals(80, result, 0.0001f); result = CssDimensionParsingUtils.parseLength("10rem", 10, 2, 8, 9); - Assert.assertEquals(90, result, 0.0001f); + Assertions.assertEquals(90, result, 0.0001f); } @Test public void parseLengthInvalidTest() { final float result = CssDimensionParsingUtils.parseLength("10cmm", 10, 2, 8, 9); - Assert.assertEquals(2, result, 0.0001f); + Assertions.assertEquals(2, result, 0.0001f); } @Test public void parseFlexTest() { - Assert.assertEquals(13.3f, CssDimensionParsingUtils.parseFlex("13.3fr"), 0.0001); - Assert.assertEquals(13.3f, CssDimensionParsingUtils.parseFlex("13.3fr "), 0.0001); - Assert.assertEquals(13.3f, CssDimensionParsingUtils.parseFlex(" 13.3fr "), 0.0001); - Assert.assertNull(CssDimensionParsingUtils.parseFlex("13.3 fr")); - Assert.assertNull(CssDimensionParsingUtils.parseFlex("13.3f")); - Assert.assertNull(CssDimensionParsingUtils.parseFlex("13.3")); - Assert.assertNull(CssDimensionParsingUtils.parseFlex(null)); + Assertions.assertEquals(13.3f, CssDimensionParsingUtils.parseFlex("13.3fr"), 0.0001); + Assertions.assertEquals(13.3f, CssDimensionParsingUtils.parseFlex("13.3fr "), 0.0001); + Assertions.assertEquals(13.3f, CssDimensionParsingUtils.parseFlex(" 13.3fr "), 0.0001); + Assertions.assertNull(CssDimensionParsingUtils.parseFlex("13.3 fr")); + Assertions.assertNull(CssDimensionParsingUtils.parseFlex("13.3f")); + Assertions.assertNull(CssDimensionParsingUtils.parseFlex("13.3")); + Assertions.assertNull(CssDimensionParsingUtils.parseFlex(null)); } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/util/CssGradientUtilTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/util/CssGradientUtilTest.java index 535a2ea576..195575598f 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/util/CssGradientUtilTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/util/CssGradientUtilTest.java @@ -32,41 +32,40 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.colors.gradients.StrategyBasedLinearGradientBuilder.GradientStrategy; import com.itextpdf.styledxmlparser.exceptions.StyledXMLParserException; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.util.ArrayList; import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class CssGradientUtilTest extends ExtendedITextTest { @Test public void nullValueTest() { String gradientValue = null; - Assert.assertFalse(CssGradientUtil.isCssLinearGradientValue(gradientValue)); - Assert.assertNull(CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12)); + Assertions.assertFalse(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertNull(CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12)); } @Test public void webkitExtensionLinearGradientTest() { String gradientValue = "-webkit-linear-gradient(red, green, blue)"; - Assert.assertFalse(CssGradientUtil.isCssLinearGradientValue(gradientValue)); - Assert.assertNull(CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12)); + Assertions.assertFalse(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertNull(CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12)); } @Test public void linearGradientWithNamesTest() { String gradientValue = " linear-gradient(red, green, blue) \t "; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 0f, 0f}, 0f, OffsetType.RELATIVE)); @@ -79,10 +78,10 @@ public void linearGradientWithNamesTest() { public void linearGradientWithHexColorsTest() { String gradientValue = "linear-grADIENt(#ff0000, #008000, #0000ff)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 0f, 0f}, 0f, OffsetType.RELATIVE)); @@ -95,10 +94,10 @@ public void linearGradientWithHexColorsTest() { public void linearGradientWithRgbFunctionsTest() { String gradientValue = "linear-gradient( rgb(255, 0, 0), rgb(0, 127, 0), rgb(0, 0, 255))"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 0f, 0f}, 0f, OffsetType.RELATIVE)); @@ -111,10 +110,10 @@ public void linearGradientWithRgbFunctionsTest() { public void repeatingLinearGradientWithNamesTest() { String gradientValue = " repeating-linear-gradient(red, green, blue) \t "; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 0f, 0f}, 0f, OffsetType.RELATIVE)); @@ -127,10 +126,10 @@ public void repeatingLinearGradientWithNamesTest() { public void repeatingLinearGradientWithHexColorsAndUpperCaseTest() { String gradientValue = "rePEATing-linear-grADIENt(#ff0000, #008000, #0000ff)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 0f, 0f}, 0f, OffsetType.RELATIVE)); @@ -143,10 +142,10 @@ public void repeatingLinearGradientWithHexColorsAndUpperCaseTest() { public void repeatingLinearGradientWithRgbFunctionsTest() { String gradientValue = "repeating-linear-gradient( rgb(255, 0, 0), rgb(0, 127, 0), rgb(0, 0, 255))"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 0f, 0f}, 0f, OffsetType.RELATIVE)); @@ -159,11 +158,11 @@ public void repeatingLinearGradientWithRgbFunctionsTest() { public void emptyParsedArguments1Test() { String gradientValue = "linear-gradient()"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); - Exception e = Assert.assertThrows(StyledXMLParserException.class, + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Exception e = Assertions.assertThrows(StyledXMLParserException.class, () -> CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12) ); - Assert.assertEquals(MessageFormatUtil.format(StyledXMLParserException.INVALID_GRADIENT_FUNCTION_ARGUMENTS_LIST, "linear-gradient()"), + Assertions.assertEquals(MessageFormatUtil.format(StyledXMLParserException.INVALID_GRADIENT_FUNCTION_ARGUMENTS_LIST, "linear-gradient()"), e.getMessage()); } @@ -171,11 +170,11 @@ public void emptyParsedArguments1Test() { public void emptyParsedArguments2Test() { String gradientValue = "linear-gradient( , )"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); - Exception e = Assert.assertThrows(StyledXMLParserException.class, + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Exception e = Assertions.assertThrows(StyledXMLParserException.class, () -> CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12) ); - Assert.assertEquals(MessageFormatUtil.format(StyledXMLParserException.INVALID_GRADIENT_FUNCTION_ARGUMENTS_LIST, "linear-gradient( , )"), + Assertions.assertEquals(MessageFormatUtil.format(StyledXMLParserException.INVALID_GRADIENT_FUNCTION_ARGUMENTS_LIST, "linear-gradient( , )"), e.getMessage()); } @@ -183,11 +182,11 @@ public void emptyParsedArguments2Test() { public void invalidFirstArgumentTest() { String gradientValue = "linear-gradient(not-angle-or-color, orange 100pt, red 150pt, green 200pt, blue 250pt)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); - Exception e = Assert.assertThrows(StyledXMLParserException.class, + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Exception e = Assertions.assertThrows(StyledXMLParserException.class, () -> CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12) ); - Assert.assertEquals(MessageFormatUtil.format(StyledXMLParserException.INVALID_GRADIENT_COLOR_STOP_VALUE, "not-angle-or-color"), + Assertions.assertEquals(MessageFormatUtil.format(StyledXMLParserException.INVALID_GRADIENT_COLOR_STOP_VALUE, "not-angle-or-color"), e.getMessage()); } @@ -195,11 +194,11 @@ public void invalidFirstArgumentTest() { public void invalidToSideTest0() { String gradientValue = "linear-gradient(to , orange 100pt, red 150pt, green 200pt, blue 250pt)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); - Exception e = Assert.assertThrows(StyledXMLParserException.class, + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Exception e = Assertions.assertThrows(StyledXMLParserException.class, () -> CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12) ); - Assert.assertEquals(MessageFormatUtil.format(StyledXMLParserException.INVALID_GRADIENT_COLOR_STOP_VALUE, "to"), + Assertions.assertEquals(MessageFormatUtil.format(StyledXMLParserException.INVALID_GRADIENT_COLOR_STOP_VALUE, "to"), e.getMessage()); } @@ -207,11 +206,11 @@ public void invalidToSideTest0() { public void invalidToSideTest1() { String gradientValue = "linear-gradient(to, orange 100pt, red 150pt, green 200pt, blue 250pt)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); - Exception e = Assert.assertThrows(StyledXMLParserException.class, + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Exception e = Assertions.assertThrows(StyledXMLParserException.class, () -> CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12) ); - Assert.assertEquals(MessageFormatUtil.format(StyledXMLParserException.INVALID_GRADIENT_COLOR_STOP_VALUE, "to"), + Assertions.assertEquals(MessageFormatUtil.format(StyledXMLParserException.INVALID_GRADIENT_COLOR_STOP_VALUE, "to"), e.getMessage()); } @@ -219,11 +218,11 @@ public void invalidToSideTest1() { public void invalidToSideTest2() { String gradientValue = "linear-gradient(to left left, orange 100pt, red 150pt, green 200pt, blue 250pt)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); - Exception e = Assert.assertThrows(StyledXMLParserException.class, + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Exception e = Assertions.assertThrows(StyledXMLParserException.class, () -> CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12) ); - Assert.assertEquals(MessageFormatUtil.format(StyledXMLParserException.INVALID_GRADIENT_TO_SIDE_OR_CORNER_STRING, "to left left"), + Assertions.assertEquals(MessageFormatUtil.format(StyledXMLParserException.INVALID_GRADIENT_TO_SIDE_OR_CORNER_STRING, "to left left"), e.getMessage()); } @@ -231,11 +230,11 @@ public void invalidToSideTest2() { public void invalidToSideTest3() { String gradientValue = "linear-gradient(to bottom top, orange 100pt, red 150pt, green 200pt, blue 250pt)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); - Exception e = Assert.assertThrows(StyledXMLParserException.class, + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Exception e = Assertions.assertThrows(StyledXMLParserException.class, () -> CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12) ); - Assert.assertEquals(MessageFormatUtil.format(StyledXMLParserException.INVALID_GRADIENT_TO_SIDE_OR_CORNER_STRING, "to bottom top"), + Assertions.assertEquals(MessageFormatUtil.format(StyledXMLParserException.INVALID_GRADIENT_TO_SIDE_OR_CORNER_STRING, "to bottom top"), e.getMessage()); } @@ -243,11 +242,11 @@ public void invalidToSideTest3() { public void invalidToSideTest4() { String gradientValue = "linear-gradient(to left right, orange 100pt, red 150pt, green 200pt, blue 250pt)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); - Exception e = Assert.assertThrows(StyledXMLParserException.class, + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Exception e = Assertions.assertThrows(StyledXMLParserException.class, () -> CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12) ); - Assert.assertEquals(MessageFormatUtil.format(StyledXMLParserException.INVALID_GRADIENT_TO_SIDE_OR_CORNER_STRING, "to left right"), + Assertions.assertEquals(MessageFormatUtil.format(StyledXMLParserException.INVALID_GRADIENT_TO_SIDE_OR_CORNER_STRING, "to left right"), e.getMessage()); } @@ -255,11 +254,11 @@ public void invalidToSideTest4() { public void invalidToSideTest5() { String gradientValue = "linear-gradient(to top right right, orange 100pt, red 150pt, green 200pt, blue 250pt)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); - Exception e = Assert.assertThrows(StyledXMLParserException.class, + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Exception e = Assertions.assertThrows(StyledXMLParserException.class, () -> CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12) ); - Assert.assertEquals(MessageFormatUtil.format(StyledXMLParserException.INVALID_GRADIENT_TO_SIDE_OR_CORNER_STRING, "to top right right"), + Assertions.assertEquals(MessageFormatUtil.format(StyledXMLParserException.INVALID_GRADIENT_TO_SIDE_OR_CORNER_STRING, "to top right right"), e.getMessage()); } @@ -267,11 +266,11 @@ public void invalidToSideTest5() { public void invalidColorWithThreeOffsetsValueTest() { String gradientValue = "linear-gradient(red, orange 20pt 30pt 100pt, green 200pt, blue 250pt)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); - Exception e = Assert.assertThrows(StyledXMLParserException.class, + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Exception e = Assertions.assertThrows(StyledXMLParserException.class, () -> CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12) ); - Assert.assertEquals(MessageFormatUtil.format(StyledXMLParserException.INVALID_GRADIENT_COLOR_STOP_VALUE, "orange 20pt 30pt 100pt"), + Assertions.assertEquals(MessageFormatUtil.format(StyledXMLParserException.INVALID_GRADIENT_COLOR_STOP_VALUE, "orange 20pt 30pt 100pt"), e.getMessage()); } @@ -279,11 +278,11 @@ public void invalidColorWithThreeOffsetsValueTest() { public void invalidColorOffsetValueTest() { String gradientValue = "linear-gradient(red, orange 20, green 200pt, blue 250pt)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); - Exception e = Assert.assertThrows(StyledXMLParserException.class, + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Exception e = Assertions.assertThrows(StyledXMLParserException.class, () -> CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12) ); - Assert.assertEquals(MessageFormatUtil.format(StyledXMLParserException.INVALID_GRADIENT_COLOR_STOP_VALUE, "orange 20"), + Assertions.assertEquals(MessageFormatUtil.format(StyledXMLParserException.INVALID_GRADIENT_COLOR_STOP_VALUE, "orange 20"), e.getMessage()); } @@ -291,11 +290,11 @@ public void invalidColorOffsetValueTest() { public void invalidMultipleHintsInARowValueTest() { String gradientValue = "linear-gradient(red, orange, 20%, 30%, green 200pt, blue 250pt)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); - Exception e = Assert.assertThrows(StyledXMLParserException.class, + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Exception e = Assertions.assertThrows(StyledXMLParserException.class, () -> CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12) ); - Assert.assertEquals(MessageFormatUtil.format(StyledXMLParserException.INVALID_GRADIENT_COLOR_STOP_VALUE, "30%"), + Assertions.assertEquals(MessageFormatUtil.format(StyledXMLParserException.INVALID_GRADIENT_COLOR_STOP_VALUE, "30%"), e.getMessage()); } @@ -303,11 +302,11 @@ public void invalidMultipleHintsInARowValueTest() { public void invalidMultipleHintsInARowWithoutCommaValueTest() { String gradientValue = "linear-gradient(red, orange, 20% 30%, green 200pt, blue 250pt)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); - Exception e = Assert.assertThrows(StyledXMLParserException.class, + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Exception e = Assertions.assertThrows(StyledXMLParserException.class, () -> CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12) ); - Assert.assertEquals(MessageFormatUtil.format(StyledXMLParserException.INVALID_GRADIENT_COLOR_STOP_VALUE, "20% 30%"), + Assertions.assertEquals(MessageFormatUtil.format(StyledXMLParserException.INVALID_GRADIENT_COLOR_STOP_VALUE, "20% 30%"), e.getMessage()); } @@ -315,11 +314,11 @@ public void invalidMultipleHintsInARowWithoutCommaValueTest() { public void invalidFirstElementIsAHintValueTest() { String gradientValue = "linear-gradient(5%, red, orange, 30%, green 200pt, blue 250pt)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); - Exception e = Assert.assertThrows(StyledXMLParserException.class, + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Exception e = Assertions.assertThrows(StyledXMLParserException.class, () -> CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12) ); - Assert.assertEquals(MessageFormatUtil.format(StyledXMLParserException.INVALID_GRADIENT_COLOR_STOP_VALUE, "5%"), + Assertions.assertEquals(MessageFormatUtil.format(StyledXMLParserException.INVALID_GRADIENT_COLOR_STOP_VALUE, "5%"), e.getMessage()); } @@ -327,11 +326,11 @@ public void invalidFirstElementIsAHintValueTest() { public void invalidLastElementIsAHintValueTest() { String gradientValue = "linear-gradient(red, orange, 30%, green 200pt, blue 250pt, 120%)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); - Exception e = Assert.assertThrows(StyledXMLParserException.class, + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Exception e = Assertions.assertThrows(StyledXMLParserException.class, () -> CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12) ); - Assert.assertEquals(MessageFormatUtil.format(StyledXMLParserException.INVALID_GRADIENT_COLOR_STOP_VALUE, "120%"), + Assertions.assertEquals(MessageFormatUtil.format(StyledXMLParserException.INVALID_GRADIENT_COLOR_STOP_VALUE, "120%"), e.getMessage()); } @@ -339,10 +338,10 @@ public void invalidLastElementIsAHintValueTest() { public void linearGradDifferentSidesLeftTest() { String gradientValue = "linear-gradient(to left, orange -20pt, red 0%, blue 100%, orange 120%)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, -20f, OffsetType.ABSOLUTE)); @@ -358,10 +357,10 @@ public void linearGradDifferentSidesLeftTest() { public void linearGradDifferentSidesRightTest() { String gradientValue = "linear-gradient(to right, orange -20pt, red 0%, blue 100%, orange 120%)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, -20f, OffsetType.ABSOLUTE)); @@ -377,10 +376,10 @@ public void linearGradDifferentSidesRightTest() { public void linearGradDifferentSidesBottomTest() { String gradientValue = "linear-gradient(to bottom, orange -20pt, red 0%, blue 100%, orange 120%)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, -20f, OffsetType.ABSOLUTE)); @@ -396,10 +395,10 @@ public void linearGradDifferentSidesBottomTest() { public void linearGradDifferentSidesTopTest() { String gradientValue = "linear-gradient(to top, orange -20pt, red 0%, blue 100%, orange 120%)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, -20f, OffsetType.ABSOLUTE)); @@ -415,10 +414,10 @@ public void linearGradDifferentSidesTopTest() { public void linearGradDifferentCornersToLeftTopTest() { String gradientValue = "linear-gradient(to left top, orange -20pt, red 0%, green, blue 100%, orange 120%)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, -20f, OffsetType.ABSOLUTE)); @@ -435,10 +434,10 @@ public void linearGradDifferentCornersToLeftTopTest() { public void linearGradDifferentCornersToTopLeftTest() { String gradientValue = "linear-gradient(to top left, orange -20pt, red 0%, green, blue 100%, orange 120%)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, -20f, OffsetType.ABSOLUTE)); @@ -455,10 +454,10 @@ public void linearGradDifferentCornersToTopLeftTest() { public void linearGradDifferentCornersToLeftBottomTest() { String gradientValue = "linear-gradient(to left bottom, orange -20pt, red 0%, green, blue 100%, orange 120%)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, -20f, OffsetType.ABSOLUTE)); @@ -475,10 +474,10 @@ public void linearGradDifferentCornersToLeftBottomTest() { public void linearGradDifferentCornersToBottomLeftTest() { String gradientValue = "linear-gradient(to bottom left, orange -20pt, red 0%, green, blue 100%, orange 120%)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, -20f, OffsetType.ABSOLUTE)); @@ -495,10 +494,10 @@ public void linearGradDifferentCornersToBottomLeftTest() { public void linearGradDifferentCornersToRightTopTest() { String gradientValue = "linear-gradient(to right top, orange -20pt, red 0%, green, blue 100%, orange 120%)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, -20f, OffsetType.ABSOLUTE)); @@ -515,10 +514,10 @@ public void linearGradDifferentCornersToRightTopTest() { public void linearGradDifferentCornersToTopRightTest() { String gradientValue = "linear-gradient(to top right, orange -20pt, red 0%, green, blue 100%, orange 120%)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, -20f, OffsetType.ABSOLUTE)); @@ -535,10 +534,10 @@ public void linearGradDifferentCornersToTopRightTest() { public void linearGradDifferentCornersToRightBottomTest() { String gradientValue = "linear-gradient(to right bottom, orange -20pt, red 0%, green, blue 100%, orange 120%)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, -20f, OffsetType.ABSOLUTE)); @@ -555,10 +554,10 @@ public void linearGradDifferentCornersToRightBottomTest() { public void linearGradDifferentCornersToBottomRightTest() { String gradientValue = "linear-gradient(to bottom right, orange -20pt, red 0%, green, blue 100%, orange 120%)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, -20f, OffsetType.ABSOLUTE)); @@ -575,10 +574,10 @@ public void linearGradDifferentCornersToBottomRightTest() { public void linearGradDifferentDegPositiveTest() { String gradientValue = "linear-gradient(41deg, orange -20pt, red 0%, green, blue 100%, orange 120%)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, -20f, OffsetType.ABSOLUTE)); @@ -595,10 +594,10 @@ public void linearGradDifferentDegPositiveTest() { public void linearGradDifferentDegNegativeTest() { String gradientValue = "linear-gradient(-41deg, orange -20pt, red 0%, green, blue 100%, orange 120%)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, -20f, OffsetType.ABSOLUTE)); @@ -615,10 +614,10 @@ public void linearGradDifferentDegNegativeTest() { public void linearGradDifferentDegZeroTest() { String gradientValue = "linear-gradient(0deg, orange -20pt, red 0%, green, blue 100%, orange 120%)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, -20f, OffsetType.ABSOLUTE)); @@ -635,10 +634,10 @@ public void linearGradDifferentDegZeroTest() { public void linearGradDifferentRadPositiveTest() { String gradientValue = "linear-gradient(0.5rad, orange -20pt, red 0%, green, blue 100%, orange 120%)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, -20f, OffsetType.ABSOLUTE)); @@ -655,10 +654,10 @@ public void linearGradDifferentRadPositiveTest() { public void linearGradDifferentRadNegativeTest() { String gradientValue = "linear-gradient(-0.5rad, orange -20pt, red 0%, green, blue 100%, orange 120%)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, -20f, OffsetType.ABSOLUTE)); @@ -675,10 +674,10 @@ public void linearGradDifferentRadNegativeTest() { public void linearGradDifferentRadZeroTest() { String gradientValue = "linear-gradient(0rad, orange -20pt, red 0%, green, blue 100%, orange 120%)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, -20f, OffsetType.ABSOLUTE)); @@ -695,10 +694,10 @@ public void linearGradDifferentRadZeroTest() { public void linearGradDifferentGradPositiveTest() { String gradientValue = "linear-gradient(41grad, orange -20pt, red 0%, green, blue 100%, orange 120%)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, -20f, OffsetType.ABSOLUTE)); @@ -715,10 +714,10 @@ public void linearGradDifferentGradPositiveTest() { public void linearGradDifferentGradNegativeTest() { String gradientValue = "linear-gradient(-41grad, orange -20pt, red 0%, green, blue 100%, orange 120%)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, -20f, OffsetType.ABSOLUTE)); @@ -735,10 +734,10 @@ public void linearGradDifferentGradNegativeTest() { public void linearGradDifferentGradZeroTest() { String gradientValue = "linear-gradient(0grad, orange -20pt, red 0%, green, blue 100%, orange 120%)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, -20f, OffsetType.ABSOLUTE)); @@ -756,12 +755,12 @@ public void linearGradDifferentGradZeroTest() { public void linearGradDifferentTurnPositiveTest() { String gradientValue = "linear-gradient(0.17turn, orange -20pt, red 0%, green, blue 100%, orange 120%)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); - Exception e = Assert.assertThrows(StyledXMLParserException.class, + Exception e = Assertions.assertThrows(StyledXMLParserException.class, () -> CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12) ); - Assert.assertEquals(MessageFormatUtil.format(StyledXMLParserException.INVALID_GRADIENT_COLOR_STOP_VALUE, "0.17turn"), + Assertions.assertEquals(MessageFormatUtil.format(StyledXMLParserException.INVALID_GRADIENT_COLOR_STOP_VALUE, "0.17turn"), e.getMessage()); } @@ -770,12 +769,12 @@ public void linearGradDifferentTurnPositiveTest() { public void linearGradDifferentTurnNegativeTest() { String gradientValue = "linear-gradient(-0.17turn, orange -20pt, red 0%, green, blue 100%, orange 120%)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); - Exception e = Assert.assertThrows(StyledXMLParserException.class, + Exception e = Assertions.assertThrows(StyledXMLParserException.class, () -> CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12) ); - Assert.assertEquals(MessageFormatUtil.format(StyledXMLParserException.INVALID_GRADIENT_COLOR_STOP_VALUE, "-0.17turn"), + Assertions.assertEquals(MessageFormatUtil.format(StyledXMLParserException.INVALID_GRADIENT_COLOR_STOP_VALUE, "-0.17turn"), e.getMessage()); } @@ -784,12 +783,12 @@ public void linearGradDifferentTurnNegativeTest() { public void linearGradDifferentTurnZeroTest() { String gradientValue = "linear-gradient(0turn, orange -20pt, red 0%, green, blue 100%, orange 120%)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); - Exception e = Assert.assertThrows(StyledXMLParserException.class, + Exception e = Assertions.assertThrows(StyledXMLParserException.class, () -> CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12) ); - Assert.assertEquals(MessageFormatUtil.format(StyledXMLParserException.INVALID_GRADIENT_COLOR_STOP_VALUE, "0turn"), + Assertions.assertEquals(MessageFormatUtil.format(StyledXMLParserException.INVALID_GRADIENT_COLOR_STOP_VALUE, "0turn"), e.getMessage()); } @@ -797,10 +796,10 @@ public void linearGradDifferentTurnZeroTest() { public void repeatingLinearGradDifferentSidesLeftTest() { String gradientValue = "repeating-linear-gradient(to left, orange -20pt, red 0%, blue 100%, orange 120%)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, -20f, OffsetType.ABSOLUTE)); @@ -816,10 +815,10 @@ public void repeatingLinearGradDifferentSidesLeftTest() { public void repeatingLinearGradDifferentSidesRightTest() { String gradientValue = "repeating-linear-gradient(to right, orange -20pt, red 0%, blue 100%, orange 120%)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, -20f, OffsetType.ABSOLUTE)); @@ -835,10 +834,10 @@ public void repeatingLinearGradDifferentSidesRightTest() { public void repeatingLinearGradDifferentSidesBottomTest() { String gradientValue = "repeating-linear-gradient(to bottom, orange -20pt, red 0%, blue 100%, orange 120%)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, -20f, OffsetType.ABSOLUTE)); @@ -854,10 +853,10 @@ public void repeatingLinearGradDifferentSidesBottomTest() { public void repeatingLinearGradDifferentSidesTopTest() { String gradientValue = "repeating-linear-gradient(to top, orange -20pt, red 0%, blue 100%, orange 120%)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, -20f, OffsetType.ABSOLUTE)); @@ -873,10 +872,10 @@ public void repeatingLinearGradDifferentSidesTopTest() { public void repeatingLinearGradDifferentCornersToLeftTopTest() { String gradientValue = "repeating-linear-gradient(to left top, orange -20pt, red 0%, green, blue 100%, orange 120%)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, -20f, OffsetType.ABSOLUTE)); @@ -893,10 +892,10 @@ public void repeatingLinearGradDifferentCornersToLeftTopTest() { public void repeatingLinearGradDifferentCornersToTopLeftTest() { String gradientValue = "repeating-linear-gradient(to top left, orange -20pt, red 0%, green, blue 100%, orange 120%)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, -20f, OffsetType.ABSOLUTE)); @@ -913,10 +912,10 @@ public void repeatingLinearGradDifferentCornersToTopLeftTest() { public void repeatingLinearGradDifferentCornersToLeftBottomTest() { String gradientValue = "repeating-linear-gradient(to left bottom, orange -20pt, red 0%, green, blue 100%, orange 120%)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, -20f, OffsetType.ABSOLUTE)); @@ -933,10 +932,10 @@ public void repeatingLinearGradDifferentCornersToLeftBottomTest() { public void repeatingLinearGradDifferentCornersToBottomLeftTest() { String gradientValue = "repeating-linear-gradient(to bottom left, orange -20pt, red 0%, green, blue 100%, orange 120%)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, -20f, OffsetType.ABSOLUTE)); @@ -953,10 +952,10 @@ public void repeatingLinearGradDifferentCornersToBottomLeftTest() { public void repeatingLinearGradDifferentCornersToRightTopTest() { String gradientValue = "repeating-linear-gradient(to right top, orange -20pt, red 0%, green, blue 100%, orange 120%)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, -20f, OffsetType.ABSOLUTE)); @@ -973,10 +972,10 @@ public void repeatingLinearGradDifferentCornersToRightTopTest() { public void repeatingLinearGradDifferentCornersToTopRightTest() { String gradientValue = "repeating-linear-gradient(to top right, orange -20pt, red 0%, green, blue 100%, orange 120%)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, -20f, OffsetType.ABSOLUTE)); @@ -993,10 +992,10 @@ public void repeatingLinearGradDifferentCornersToTopRightTest() { public void repeatingLinearGradDifferentCornersToRightBottomTest() { String gradientValue = "repeating-linear-gradient(to right bottom, orange -20pt, red 0%, green, blue 100%, orange 120%)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, -20f, OffsetType.ABSOLUTE)); @@ -1013,10 +1012,10 @@ public void repeatingLinearGradDifferentCornersToRightBottomTest() { public void repeatingLinearGradDifferentCornersToBottomRightTest() { String gradientValue = "repeating-linear-gradient(to bottom right, orange -20pt, red 0%, green, blue 100%, orange 120%)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, -20f, OffsetType.ABSOLUTE)); @@ -1033,10 +1032,10 @@ public void repeatingLinearGradDifferentCornersToBottomRightTest() { public void repeatingLinearGradDifferentDegPositiveTest() { String gradientValue = "repeating-linear-gradient(41deg, orange -20pt, red 0%, green, blue 100%, orange 120%)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, -20f, OffsetType.ABSOLUTE)); @@ -1053,10 +1052,10 @@ public void repeatingLinearGradDifferentDegPositiveTest() { public void repeatingLinearGradDifferentDegNegativeTest() { String gradientValue = "repeating-linear-gradient(-41deg, orange -20pt, red 0%, green, blue 100%, orange 120%)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, -20f, OffsetType.ABSOLUTE)); @@ -1073,10 +1072,10 @@ public void repeatingLinearGradDifferentDegNegativeTest() { public void repeatingLinearGradDifferentDegZeroTest() { String gradientValue = "repeating-linear-gradient(0deg, orange -20pt, red 0%, green, blue 100%, orange 120%)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, -20f, OffsetType.ABSOLUTE)); @@ -1093,10 +1092,10 @@ public void repeatingLinearGradDifferentDegZeroTest() { public void repeatingLinearGradDifferentRadPositiveTest() { String gradientValue = "repeating-linear-gradient(0.5rad, orange -20pt, red 0%, green, blue 100%, orange 120%)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, -20f, OffsetType.ABSOLUTE)); @@ -1113,10 +1112,10 @@ public void repeatingLinearGradDifferentRadPositiveTest() { public void repeatingLinearGradDifferentRadNegativeTest() { String gradientValue = "repeating-linear-gradient(-0.5rad, orange -20pt, red 0%, green, blue 100%, orange 120%)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, -20f, OffsetType.ABSOLUTE)); @@ -1133,10 +1132,10 @@ public void repeatingLinearGradDifferentRadNegativeTest() { public void repeatingLinearGradDifferentRadZeroTest() { String gradientValue = "repeating-linear-gradient(0rad, orange -20pt, red 0%, green, blue 100%, orange 120%)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, -20f, OffsetType.ABSOLUTE)); @@ -1153,10 +1152,10 @@ public void repeatingLinearGradDifferentRadZeroTest() { public void repeatingLinearGradDifferentGradPositiveTest() { String gradientValue = "repeating-linear-gradient(41grad, orange -20pt, red 0%, green, blue 100%, orange 120%)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, -20f, OffsetType.ABSOLUTE)); @@ -1173,10 +1172,10 @@ public void repeatingLinearGradDifferentGradPositiveTest() { public void repeatingLinearGradDifferentGradNegativeTest() { String gradientValue = "repeating-linear-gradient(-41grad, orange -20pt, red 0%, green, blue 100%, orange 120%)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, -20f, OffsetType.ABSOLUTE)); @@ -1193,10 +1192,10 @@ public void repeatingLinearGradDifferentGradNegativeTest() { public void repeatingLinearGradDifferentGradZeroTest() { String gradientValue = "repeating-linear-gradient(0grad, orange -20pt, red 0%, green, blue 100%, orange 120%)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, -20f, OffsetType.ABSOLUTE)); @@ -1214,12 +1213,12 @@ public void repeatingLinearGradDifferentGradZeroTest() { public void repeatingLinearGradDifferentTurnPositiveTest() { String gradientValue = "repeating-linear-gradient(0.17turn, orange -20pt, red 0%, green, blue 100%, orange 120%)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); - Exception e = Assert.assertThrows(StyledXMLParserException.class, + Exception e = Assertions.assertThrows(StyledXMLParserException.class, () -> CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12) ); - Assert.assertEquals(MessageFormatUtil.format(StyledXMLParserException.INVALID_GRADIENT_COLOR_STOP_VALUE, "0.17turn"), + Assertions.assertEquals(MessageFormatUtil.format(StyledXMLParserException.INVALID_GRADIENT_COLOR_STOP_VALUE, "0.17turn"), e.getMessage()); } @@ -1228,12 +1227,12 @@ public void repeatingLinearGradDifferentTurnPositiveTest() { public void repeatingLinearGradDifferentTurnNegativeTest() { String gradientValue = "repeating-linear-gradient(-0.17turn, orange -20pt, red 0%, green, blue 100%, orange 120%)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); - Exception e = Assert.assertThrows(StyledXMLParserException.class, + Exception e = Assertions.assertThrows(StyledXMLParserException.class, () -> CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12) ); - Assert.assertEquals(MessageFormatUtil.format(StyledXMLParserException.INVALID_GRADIENT_COLOR_STOP_VALUE, "-0.17turn"), + Assertions.assertEquals(MessageFormatUtil.format(StyledXMLParserException.INVALID_GRADIENT_COLOR_STOP_VALUE, "-0.17turn"), e.getMessage()); } @@ -1242,12 +1241,12 @@ public void repeatingLinearGradDifferentTurnNegativeTest() { public void repeatingLinearGradDifferentTurnZeroTest() { String gradientValue = "repeating-linear-gradient(0turn, orange -20pt, red 0%, green, blue 100%, orange 120%)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); - Exception e = Assert.assertThrows(StyledXMLParserException.class, + Exception e = Assertions.assertThrows(StyledXMLParserException.class, () -> CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12) ); - Assert.assertEquals(MessageFormatUtil.format(StyledXMLParserException.INVALID_GRADIENT_COLOR_STOP_VALUE, "0turn"), + Assertions.assertEquals(MessageFormatUtil.format(StyledXMLParserException.INVALID_GRADIENT_COLOR_STOP_VALUE, "0turn"), e.getMessage()); } @@ -1255,10 +1254,10 @@ public void repeatingLinearGradDifferentTurnZeroTest() { public void linearGradDiffColorNameTest() { String gradientValue = "linear-gradient(red, green, blue)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 0f, 0f}, 0f, OffsetType.RELATIVE)); @@ -1273,10 +1272,10 @@ public void linearGradDiffColorNameTest() { public void linearGradDiffColorHexTest() { String gradientValue = "linear-gradient(#ff0000, #008000, #0000ff)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 0f, 0f}, 0f, OffsetType.RELATIVE)); @@ -1291,10 +1290,10 @@ public void linearGradDiffColorHexTest() { public void linearGradDiffColorRGBTest() { String gradientValue = "linear-gradient(rgb(255, 0, 0), rgb(0, 128, 0), rgb(0, 0, 255))"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 0f, 0f}, 0f, OffsetType.RELATIVE)); @@ -1309,10 +1308,10 @@ public void linearGradDiffColorRGBTest() { public void linearGradDiffColorRGBaTest() { String gradientValue = "linear-gradient(rgba(255, 0, 0, 1), rgba(0, 128, 0, 1), rgba(0, 0, 255, 1))"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 0f, 0f}, 0f, OffsetType.RELATIVE)); @@ -1327,10 +1326,10 @@ public void linearGradDiffColorRGBaTest() { public void linearGradComplexArgsLeftTopTest() { String gradientValue = "linear-gradient(to left top, red, green, blue)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 0f, 0f}, 0f, OffsetType.RELATIVE)); @@ -1345,10 +1344,10 @@ public void linearGradComplexArgsLeftTopTest() { public void linearGradComplexArgsLeftTopRGBTest() { String gradientValue = "linear-gradient(to left top, red, rgb(0, 127, 0), blue)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 0f, 0f}, 0f, OffsetType.RELATIVE)); @@ -1363,10 +1362,10 @@ public void linearGradComplexArgsLeftTopRGBTest() { public void linearGradComplexArgsLeftTopRGBOffsetsHintsTest() { String gradientValue = "linear-gradient(to left top, red 10% 20%, 30%, rgb(0, 127, 0) 80%, blue)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 0f, 0f}, 0.1f, OffsetType.RELATIVE)); @@ -1383,10 +1382,10 @@ public void linearGradComplexArgsLeftTopRGBOffsetsHintsTest() { public void repeatingLinearGradDiffColorNameTest() { String gradientValue = "repeating-linear-gradient(red, green, blue)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 0f, 0f}, 0f, OffsetType.RELATIVE)); @@ -1401,10 +1400,10 @@ public void repeatingLinearGradDiffColorNameTest() { public void repeatingLinearGradDiffColorHexTest() { String gradientValue = "repeating-linear-gradient(#ff0000, #008000, #0000ff)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 0f, 0f}, 0f, OffsetType.RELATIVE)); @@ -1419,10 +1418,10 @@ public void repeatingLinearGradDiffColorHexTest() { public void repeatingLinearGradDiffColorRGBTest() { String gradientValue = "repeating-linear-gradient(rgb(255, 0, 0), rgb(0, 128, 0), rgb(0, 0, 255))"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 0f, 0f}, 0f, OffsetType.RELATIVE)); @@ -1437,10 +1436,10 @@ public void repeatingLinearGradDiffColorRGBTest() { public void repeatingLinearGradDiffColorRGBaTest() { String gradientValue = "repeating-linear-gradient(rgba(255, 0, 0, 1), rgba(0, 128, 0, 1), rgba(0, 0, 255, 1))"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 0f, 0f}, 0f, OffsetType.RELATIVE)); @@ -1455,10 +1454,10 @@ public void repeatingLinearGradDiffColorRGBaTest() { public void repeatingLinearGradComplexArgsLeftTopTest() { String gradientValue = "repeating-linear-gradient(to left top, red, green, blue)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 0f, 0f}, 0f, OffsetType.RELATIVE)); @@ -1473,10 +1472,10 @@ public void repeatingLinearGradComplexArgsLeftTopTest() { public void repeatingLinearGradComplexArgsLeftTopRGBTest() { String gradientValue = "repeating-linear-gradient(to left top, red, rgb(0, 127, 0), blue)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 0f, 0f}, 0f, OffsetType.RELATIVE)); @@ -1491,10 +1490,10 @@ public void repeatingLinearGradComplexArgsLeftTopRGBTest() { public void repeatingLinearGradComplexArgsLeftTopRGBOffsetsHintsTest() { String gradientValue = "repeating-linear-gradient(to left top, red 10% 20%, 30%, rgb(0, 127, 0) 80%, blue)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 0f, 0f}, 0.1f, OffsetType.RELATIVE)); @@ -1511,10 +1510,10 @@ public void repeatingLinearGradComplexArgsLeftTopRGBOffsetsHintsTest() { public void linearGradDiffMetricsAbsoluteCMTest() { String gradientValue = "linear-gradient(to right, orange 3cm, red 3cm, green 9cm, blue 9cm)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, (float) ((3 / 2.54) * 72), OffsetType.ABSOLUTE)); @@ -1531,10 +1530,10 @@ public void linearGradDiffMetricsAbsoluteCMTest() { public void linearGradDiffMetricsAbsoluteMMTest() { String gradientValue = "linear-gradient(to right, orange 3mm, red 3mm, green 9mm, blue 9mm)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, (float) ((3f / 25.4) * 72), OffsetType.ABSOLUTE)); @@ -1551,10 +1550,10 @@ public void linearGradDiffMetricsAbsoluteMMTest() { public void linearGradDiffMetricsAbsoluteQTest() { String gradientValue = "linear-gradient(to right, orange 30Q, red 30Q, green 90Q, blue 90Q)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, (float) ((30f/2.54)*72/40), OffsetType.ABSOLUTE)); @@ -1571,10 +1570,10 @@ public void linearGradDiffMetricsAbsoluteQTest() { public void linearGradDiffMetricsAbsoluteInTest() { String gradientValue = "linear-gradient(to right, orange 1in, red 1in, green 3in, blue 3in)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, 1*72f, OffsetType.ABSOLUTE)); @@ -1591,10 +1590,10 @@ public void linearGradDiffMetricsAbsoluteInTest() { public void linearGradDiffMetricsAbsolutePcTest() { String gradientValue = "linear-gradient(to right, orange 10pc, red 10pc, green 30pc, blue 30pc)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, 10*12f, OffsetType.ABSOLUTE)); @@ -1611,10 +1610,10 @@ public void linearGradDiffMetricsAbsolutePcTest() { public void linearGradDiffMetricsAbsolutePtTest() { String gradientValue = "linear-gradient(to right, orange 100pt, red 100pt, green 300pt, blue 300pt)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, 100f, OffsetType.ABSOLUTE)); @@ -1631,10 +1630,10 @@ public void linearGradDiffMetricsAbsolutePtTest() { public void linearGradDiffMetricsAbsolutePxTest() { String gradientValue = "linear-gradient(to right, orange 100px, red 100px, green 300px, blue 300px)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, 100*0.75f, OffsetType.ABSOLUTE)); @@ -1651,10 +1650,10 @@ public void linearGradDiffMetricsAbsolutePxTest() { public void linearGradDiffMetricsFontRelatedEmTest() { String gradientValue = "linear-gradient(to right, orange 3em, red 3em, green 9em, blue 9em)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 12, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, 3*12f, OffsetType.ABSOLUTE)); @@ -1671,10 +1670,10 @@ public void linearGradDiffMetricsFontRelatedEmTest() { public void linearGradDiffMetricsFontRelatedRemTest() { String gradientValue = "linear-gradient(to right, orange 3rem, red 3rem, green 9rem, blue 9rem)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, 3*12f, OffsetType.ABSOLUTE)); @@ -1691,10 +1690,10 @@ public void linearGradDiffMetricsFontRelatedRemTest() { public void linearGradDiffMetricsFontRelatedExTest() { String gradientValue = "linear-gradient(to right, orange 3ex, red 3ex, green 9ex, blue 9ex)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 12, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, 3*6f, OffsetType.ABSOLUTE)); @@ -1712,12 +1711,12 @@ public void linearGradDiffMetricsFontRelatedExTest() { public void linearGradDiffMetricsFontRelatedChTest() { String gradientValue = "linear-gradient(to right, orange 3ch, red 3ch, green 9ch, blue 9ch)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); - Exception e = Assert.assertThrows(StyledXMLParserException.class, + Exception e = Assertions.assertThrows(StyledXMLParserException.class, () -> CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12) ); - Assert.assertEquals(MessageFormatUtil.format(StyledXMLParserException.INVALID_GRADIENT_COLOR_STOP_VALUE, "orange 3ch"), + Assertions.assertEquals(MessageFormatUtil.format(StyledXMLParserException.INVALID_GRADIENT_COLOR_STOP_VALUE, "orange 3ch"), e.getMessage()); } @@ -1726,12 +1725,12 @@ public void linearGradDiffMetricsFontRelatedChTest() { public void linearGradDiffMetricsFontRelatedVhTest() { String gradientValue = "linear-gradient(to right, orange 3vh, red 3vh, green 9vh, blue 9vh)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); - Exception e = Assert.assertThrows(StyledXMLParserException.class, + Exception e = Assertions.assertThrows(StyledXMLParserException.class, () -> CssGradientUtil.parseCssLinearGradient(gradientValue, 12, 12) ); - Assert.assertEquals(MessageFormatUtil.format(StyledXMLParserException.INVALID_GRADIENT_COLOR_STOP_VALUE, "orange 3vh"), + Assertions.assertEquals(MessageFormatUtil.format(StyledXMLParserException.INVALID_GRADIENT_COLOR_STOP_VALUE, "orange 3vh"), e.getMessage()); } @@ -1740,12 +1739,12 @@ public void linearGradDiffMetricsFontRelatedVhTest() { public void linearGradDiffMetricsViewPortVwTest() { String gradientValue = "linear-gradient(to right, orange 3vw, red 3vw, green 9vw, blue 9vw)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); - Exception e = Assert.assertThrows(StyledXMLParserException.class, + Exception e = Assertions.assertThrows(StyledXMLParserException.class, () -> CssGradientUtil.parseCssLinearGradient(gradientValue, 12, 12) ); - Assert.assertEquals(MessageFormatUtil.format(StyledXMLParserException.INVALID_GRADIENT_COLOR_STOP_VALUE, "orange 3vw"), + Assertions.assertEquals(MessageFormatUtil.format(StyledXMLParserException.INVALID_GRADIENT_COLOR_STOP_VALUE, "orange 3vw"), e.getMessage()); } @@ -1754,12 +1753,12 @@ public void linearGradDiffMetricsViewPortVwTest() { public void linearGradDiffMetricsViewPortVminTest() { String gradientValue = "linear-gradient(to right, orange 3vmin, red 3vmin, green 9vmin, blue 9vmin)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); - Exception e = Assert.assertThrows(StyledXMLParserException.class, + Exception e = Assertions.assertThrows(StyledXMLParserException.class, () -> CssGradientUtil.parseCssLinearGradient(gradientValue, 12, 12) ); - Assert.assertEquals(MessageFormatUtil.format(StyledXMLParserException.INVALID_GRADIENT_COLOR_STOP_VALUE, "orange 3vmin"), + Assertions.assertEquals(MessageFormatUtil.format(StyledXMLParserException.INVALID_GRADIENT_COLOR_STOP_VALUE, "orange 3vmin"), e.getMessage()); } @@ -1768,12 +1767,12 @@ public void linearGradDiffMetricsViewPortVminTest() { public void linearGradDiffMetricsViewPortVmaxTest() { String gradientValue = "linear-gradient(to right, orange 3vmax, red 3vmax, green 9vmax, blue 9vmax)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); - Exception e = Assert.assertThrows(StyledXMLParserException.class, + Exception e = Assertions.assertThrows(StyledXMLParserException.class, () -> CssGradientUtil.parseCssLinearGradient(gradientValue, 12, 12) ); - Assert.assertEquals(MessageFormatUtil.format(StyledXMLParserException.INVALID_GRADIENT_COLOR_STOP_VALUE, "orange 3vmax"), + Assertions.assertEquals(MessageFormatUtil.format(StyledXMLParserException.INVALID_GRADIENT_COLOR_STOP_VALUE, "orange 3vmax"), e.getMessage()); } @@ -1781,10 +1780,10 @@ public void linearGradDiffMetricsViewPortVmaxTest() { public void repeatLinearGradDiffMetricsAbsoluteCMTest() { String gradientValue = "repeating-linear-gradient(to right, orange 3cm, red 3cm, green 9cm, blue 9cm)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, (float) ((3 / 2.54) * 72), OffsetType.ABSOLUTE)); @@ -1801,10 +1800,10 @@ public void repeatLinearGradDiffMetricsAbsoluteCMTest() { public void repeatLinearGradDiffMetricsAbsoluteMMTest() { String gradientValue = "repeating-linear-gradient(to right, orange 3mm, red 3mm, green 9mm, blue 9mm)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, (float) ((3f / 25.4) * 72), OffsetType.ABSOLUTE)); @@ -1821,10 +1820,10 @@ public void repeatLinearGradDiffMetricsAbsoluteMMTest() { public void repeatLinearGradDiffMetricsAbsoluteQTest() { String gradientValue = "repeating-linear-gradient(to right, orange 30Q, red 30Q, green 90Q, blue 90Q)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, (float) ((30f/2.54)*72/40), OffsetType.ABSOLUTE)); @@ -1841,10 +1840,10 @@ public void repeatLinearGradDiffMetricsAbsoluteQTest() { public void repeatLinearGradDiffMetricsAbsoluteInTest() { String gradientValue = "repeating-linear-gradient(to right, orange 1in, red 1in, green 3in, blue 3in)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, 1*72f, OffsetType.ABSOLUTE)); @@ -1861,10 +1860,10 @@ public void repeatLinearGradDiffMetricsAbsoluteInTest() { public void repeatLinearGradDiffMetricsAbsolutePcTest() { String gradientValue = "repeating-linear-gradient(to right, orange 10pc, red 10pc, green 30pc, blue 30pc)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, 10*12f, OffsetType.ABSOLUTE)); @@ -1881,10 +1880,10 @@ public void repeatLinearGradDiffMetricsAbsolutePcTest() { public void repeatLinearGradDiffMetricsAbsolutePtTest() { String gradientValue = "repeating-linear-gradient(to right, orange 100pt, red 100pt, green 300pt, blue 300pt)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, 100f, OffsetType.ABSOLUTE)); @@ -1901,10 +1900,10 @@ public void repeatLinearGradDiffMetricsAbsolutePtTest() { public void repeatLinearGradDiffMetricsAbsolutePxTest() { String gradientValue = "repeating-linear-gradient(to right, orange 100px, red 100px, green 300px, blue 300px)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, 100*0.75f, OffsetType.ABSOLUTE)); @@ -1921,10 +1920,10 @@ public void repeatLinearGradDiffMetricsAbsolutePxTest() { public void repeatLinearGradDiffMetricsFontRelatedEmTest() { String gradientValue = "repeating-linear-gradient(to right, orange 3em, red 3em, green 9em, blue 9em)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 12, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, 3*12f, OffsetType.ABSOLUTE)); @@ -1941,10 +1940,10 @@ public void repeatLinearGradDiffMetricsFontRelatedEmTest() { public void repeatLinearGradDiffMetricsFontRelatedRemTest() { String gradientValue = "repeating-linear-gradient(to right, orange 3rem, red 3rem, green 9rem, blue 9rem)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 24, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, 3*12f, OffsetType.ABSOLUTE)); @@ -1961,10 +1960,10 @@ public void repeatLinearGradDiffMetricsFontRelatedRemTest() { public void repeatLinearGradDiffMetricsFontRelatedExTest() { String gradientValue = "repeating-linear-gradient(to right, orange 3ex, red 3ex, green 9ex, blue 9ex)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 12, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, 3*6f, OffsetType.ABSOLUTE)); @@ -1982,12 +1981,12 @@ public void repeatLinearGradDiffMetricsFontRelatedExTest() { public void repeatLinearGradDiffMetricsFontRelatedChTest() { String gradientValue = "repeating-linear-gradient(to right, orange 3ch, red 3ch, green 9ch, blue 9ch)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); - Exception e = Assert.assertThrows(StyledXMLParserException.class, + Exception e = Assertions.assertThrows(StyledXMLParserException.class, () -> CssGradientUtil.parseCssLinearGradient(gradientValue, 12, 12) ); - Assert.assertEquals(MessageFormatUtil.format(StyledXMLParserException.INVALID_GRADIENT_COLOR_STOP_VALUE, "orange 3ch"), + Assertions.assertEquals(MessageFormatUtil.format(StyledXMLParserException.INVALID_GRADIENT_COLOR_STOP_VALUE, "orange 3ch"), e.getMessage()); } @@ -1996,12 +1995,12 @@ public void repeatLinearGradDiffMetricsFontRelatedChTest() { public void repeatLinearGradDiffMetricsFontRelatedVhTest() { String gradientValue = "repeating-linear-gradient(to right, orange 3vh, red 3vh, green 9vh, blue 9vh)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); - Exception e = Assert.assertThrows(StyledXMLParserException.class, + Exception e = Assertions.assertThrows(StyledXMLParserException.class, () -> CssGradientUtil.parseCssLinearGradient(gradientValue, 12, 12) ); - Assert.assertEquals(MessageFormatUtil.format(StyledXMLParserException.INVALID_GRADIENT_COLOR_STOP_VALUE, "orange 3vh"), + Assertions.assertEquals(MessageFormatUtil.format(StyledXMLParserException.INVALID_GRADIENT_COLOR_STOP_VALUE, "orange 3vh"), e.getMessage()); } @@ -2010,12 +2009,12 @@ public void repeatLinearGradDiffMetricsFontRelatedVhTest() { public void repeatLinearGradDiffMetricsViewPortVwTest() { String gradientValue = "repeating-linear-gradient(to right, orange 3vw, red 3vw, green 9vw, blue 9vw)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); - Exception e = Assert.assertThrows(StyledXMLParserException.class, + Exception e = Assertions.assertThrows(StyledXMLParserException.class, () -> CssGradientUtil.parseCssLinearGradient(gradientValue, 12, 12) ); - Assert.assertEquals(MessageFormatUtil.format(StyledXMLParserException.INVALID_GRADIENT_COLOR_STOP_VALUE, "orange 3vw"), + Assertions.assertEquals(MessageFormatUtil.format(StyledXMLParserException.INVALID_GRADIENT_COLOR_STOP_VALUE, "orange 3vw"), e.getMessage()); } @@ -2024,12 +2023,12 @@ public void repeatLinearGradDiffMetricsViewPortVwTest() { public void repeatLinearGradDiffMetricsViewPortVminTest() { String gradientValue = "repeating-linear-gradient(to right, orange 3vmin, red 3vmin, green 9vmin, blue 9vmin)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); - Exception e = Assert.assertThrows(StyledXMLParserException.class, + Exception e = Assertions.assertThrows(StyledXMLParserException.class, () -> CssGradientUtil.parseCssLinearGradient(gradientValue, 12, 12) ); - Assert.assertEquals(MessageFormatUtil.format(StyledXMLParserException.INVALID_GRADIENT_COLOR_STOP_VALUE, "orange 3vmin"), + Assertions.assertEquals(MessageFormatUtil.format(StyledXMLParserException.INVALID_GRADIENT_COLOR_STOP_VALUE, "orange 3vmin"), e.getMessage()); } @@ -2038,12 +2037,12 @@ public void repeatLinearGradDiffMetricsViewPortVminTest() { public void repeatLinearGradDiffMetricsViewPortVmaxTest() { String gradientValue = "repeating-linear-gradient(to right, orange 3vmax, red 3vmax, green 9vmax, blue 9vmax)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); - Exception e = Assert.assertThrows(StyledXMLParserException.class, + Exception e = Assertions.assertThrows(StyledXMLParserException.class, () -> CssGradientUtil.parseCssLinearGradient(gradientValue, 12, 12) ); - Assert.assertEquals(MessageFormatUtil.format(StyledXMLParserException.INVALID_GRADIENT_COLOR_STOP_VALUE, "orange 3vmax"), + Assertions.assertEquals(MessageFormatUtil.format(StyledXMLParserException.INVALID_GRADIENT_COLOR_STOP_VALUE, "orange 3vmax"), e.getMessage()); } @@ -2051,10 +2050,10 @@ public void repeatLinearGradDiffMetricsViewPortVmaxTest() { public void linearGradDiffOffsetStartEndInsideTest() { String gradientValue = "linear-gradient(to right, orange 100pt, red 150pt, green 200pt, blue 250pt)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 12, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, 100, OffsetType.ABSOLUTE)); @@ -2070,10 +2069,10 @@ public void linearGradDiffOffsetStartEndInsideTest() { public void linearGradDiffOffsetStartEndOutTest() { String gradientValue = "linear-gradient(to right, orange -100pt, red 150pt, green 200pt, blue 750pt)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 12, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, -100, OffsetType.ABSOLUTE)); @@ -2089,10 +2088,10 @@ public void linearGradDiffOffsetStartEndOutTest() { public void linearGradDiffOffsetAutoStartEndMiddleElementsOutRangeTest() { String gradientValue = "linear-gradient(to right, orange, red -20%, green 120%, blue)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 12, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, 0, OffsetType.RELATIVE)); @@ -2108,10 +2107,10 @@ public void linearGradDiffOffsetAutoStartEndMiddleElementsOutRangeTest() { public void linearGradDiffOffsetAutoBetweenAbsoluteRelativeTest() { String gradientValue = "linear-gradient(to right, orange, red 300pt, green, blue 80%, black)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 12, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, 0, OffsetType.RELATIVE)); @@ -2128,10 +2127,10 @@ public void linearGradDiffOffsetAutoBetweenAbsoluteRelativeTest() { public void linearGradDiffOffsetAutoBetweenRelativeHintTest() { String gradientValue = "linear-gradient(to right, orange, red 10%, lime, 80%, blue 80.5%, black)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 12, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, 0, OffsetType.RELATIVE)); @@ -2149,10 +2148,10 @@ public void linearGradDiffOffsetAutoBetweenRelativeHintTest() { public void linearGradDiffOffsetHintBetweenAutosTest() { String gradientValue = "linear-gradient(to right, orange 10%, red, lime, 40%, blue, black 90%)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 12, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, 0.1f, OffsetType.RELATIVE)); @@ -2170,10 +2169,10 @@ public void linearGradDiffOffsetHintBetweenAutosTest() { public void linearGradDiffOffsetSmallHintTest() { String gradientValue = "linear-gradient(to right, orange, 1%, blue)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 12, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, 0, OffsetType.RELATIVE) @@ -2188,10 +2187,10 @@ public void linearGradDiffOffsetSmallHintTest() { public void linearGradDiffOffsetNegativeHintTest() { String gradientValue = "linear-gradient(to right, orange, -100pt, blue)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 12, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, 0, OffsetType.RELATIVE) @@ -2206,10 +2205,10 @@ public void linearGradDiffOffsetNegativeHintTest() { public void linearGradDiffOffsetHintTest() { String gradientValue = "linear-gradient(to right, orange, 100pt, blue)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 12, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, 0, OffsetType.RELATIVE) @@ -2224,10 +2223,10 @@ public void linearGradDiffOffsetHintTest() { public void linearGradDiffMultipleOffsetsTest() { String gradientValue = "linear-gradient(to right, orange 10%, blue 60% 70%, black 90%)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 12, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, 0.1f, OffsetType.RELATIVE)); @@ -2243,10 +2242,10 @@ public void linearGradDiffMultipleOffsetsTest() { public void repeatingLinearGradDiffOffsetStartEndInsideTest() { String gradientValue = "repeating-linear-gradient(to right, orange 100pt, red 150pt, green 200pt, blue 250pt)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 12, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, 100, OffsetType.ABSOLUTE)); @@ -2262,10 +2261,10 @@ public void repeatingLinearGradDiffOffsetStartEndInsideTest() { public void repeatingLinearGradDiffOffsetStartEndOutTest() { String gradientValue = "repeating-linear-gradient(to right, orange -100pt, red 150pt, green 200pt, blue 750pt)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 12, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, -100, OffsetType.ABSOLUTE)); @@ -2281,10 +2280,10 @@ public void repeatingLinearGradDiffOffsetStartEndOutTest() { public void repeatingLinearGradDiffOffsetAutoStartEndMiddleElementsOutRangeTest() { String gradientValue = "repeating-linear-gradient(to right, orange, red -20%, green 120%, blue)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 12, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, 0, OffsetType.RELATIVE)); @@ -2300,10 +2299,10 @@ public void repeatingLinearGradDiffOffsetAutoStartEndMiddleElementsOutRangeTest( public void repeatingLinearGradDiffOffsetAutoBetweenAbsoluteRelativeTest() { String gradientValue = "repeating-linear-gradient(to right, orange, red 300pt, green, blue 80%, black)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 12, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, 0, OffsetType.RELATIVE)); @@ -2320,10 +2319,10 @@ public void repeatingLinearGradDiffOffsetAutoBetweenAbsoluteRelativeTest() { public void repeatingLinearGradDiffOffsetAutoBetweenRelativeHintTest() { String gradientValue = "repeating-linear-gradient(to right, orange, red 10%, lime, 80%, blue 80.5%, black)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 12, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, 0, OffsetType.RELATIVE)); @@ -2341,10 +2340,10 @@ public void repeatingLinearGradDiffOffsetAutoBetweenRelativeHintTest() { public void repeatingLinearGradDiffOffsetHintBetweenAutosTest() { String gradientValue = "repeating-linear-gradient(to right, orange 10%, red, lime, 40%, blue, black 90%)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 12, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, 0.1f, OffsetType.RELATIVE)); @@ -2362,10 +2361,10 @@ public void repeatingLinearGradDiffOffsetHintBetweenAutosTest() { public void repeatingLinearGradDiffOffsetSmallHintTest() { String gradientValue = "repeating-linear-gradient(to right, orange, 1%, blue)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 12, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, 0, OffsetType.RELATIVE) @@ -2380,10 +2379,10 @@ public void repeatingLinearGradDiffOffsetSmallHintTest() { public void repeatingLinearGradDiffOffsetNegativeHintTest() { String gradientValue = "repeating-linear-gradient(to right, orange, -100pt, blue)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 12, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, 0, OffsetType.RELATIVE) @@ -2398,10 +2397,10 @@ public void repeatingLinearGradDiffOffsetNegativeHintTest() { public void repeatingLinearGradDiffOffsetHintTest() { String gradientValue = "repeating-linear-gradient(to right, orange, 100pt, blue)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 12, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, 0, OffsetType.RELATIVE) @@ -2416,10 +2415,10 @@ public void repeatingLinearGradDiffOffsetHintTest() { public void repeatingLinearGradDiffMultipleOffsetsTest() { String gradientValue = "repeating-linear-gradient(to right, orange 10%, blue 60% 70%, black 90%)"; - Assert.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); + Assertions.assertTrue(CssGradientUtil.isCssLinearGradientValue(gradientValue)); StrategyBasedLinearGradientBuilder gradientBuilder = CssGradientUtil.parseCssLinearGradient(gradientValue, 12, 12); - Assert.assertNotNull(gradientBuilder); + Assertions.assertNotNull(gradientBuilder); List colorStops = new ArrayList<>(); colorStops.add(new GradientColorStop(new float[]{1f, 165f/255f, 0f}, 0.1f, OffsetType.RELATIVE)); @@ -2435,18 +2434,18 @@ private void assertStrategyBasedBuilderEquals(AbstractLinearGradientBuilder grad boolean isCentralRotationStrategy, double rotateVectorAngle, GradientStrategy gradientStrategy, GradientSpreadMethod spreadMethod, List stops) { - Assert.assertTrue(gradientBuilder instanceof StrategyBasedLinearGradientBuilder); + Assertions.assertTrue(gradientBuilder instanceof StrategyBasedLinearGradientBuilder); StrategyBasedLinearGradientBuilder builder = (StrategyBasedLinearGradientBuilder) gradientBuilder; - Assert.assertEquals(isCentralRotationStrategy, builder.isCentralRotationAngleStrategy()); - Assert.assertEquals(rotateVectorAngle, builder.getRotateVectorAngle(), 1e-10); - Assert.assertEquals(gradientStrategy, builder.getGradientStrategy()); - Assert.assertEquals(spreadMethod, builder.getSpreadMethod()); + Assertions.assertEquals(isCentralRotationStrategy, builder.isCentralRotationAngleStrategy()); + Assertions.assertEquals(rotateVectorAngle, builder.getRotateVectorAngle(), 1e-10); + Assertions.assertEquals(gradientStrategy, builder.getGradientStrategy()); + Assertions.assertEquals(spreadMethod, builder.getSpreadMethod()); List actualStops = builder.getColorStops(); - Assert.assertEquals(stops.size(), actualStops.size()); + Assertions.assertEquals(stops.size(), actualStops.size()); for (int i = 0; i < stops.size(); ++i) { - Assert.assertEquals(stops.get(i), actualStops.get(i)); + Assertions.assertEquals(stops.get(i), actualStops.get(i)); } } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/util/CssPropertyNormalizerTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/util/CssPropertyNormalizerTest.java index c2ca3d998e..77fa4b3a73 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/util/CssPropertyNormalizerTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/util/CssPropertyNormalizerTest.java @@ -23,13 +23,12 @@ This file is part of the iText (R) project. package com.itextpdf.styledxmlparser.css.util; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class CssPropertyNormalizerTest extends ExtendedITextTest { @Test @@ -60,6 +59,6 @@ public void checkUrlNormalizationLineTerminatorsTest() { private void test(String input, String expectedOutput) { String result = CssPropertyNormalizer.normalize(input); - Assert.assertEquals(expectedOutput, result); + Assertions.assertEquals(expectedOutput, result); } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/util/CssTypesValidationUtilsTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/util/CssTypesValidationUtilsTest.java index 6799b72a48..6f0747a1fc 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/util/CssTypesValidationUtilsTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/util/CssTypesValidationUtilsTest.java @@ -23,116 +23,115 @@ This file is part of the iText (R) project. package com.itextpdf.styledxmlparser.css.util; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class CssTypesValidationUtilsTest extends ExtendedITextTest { @Test public void testIsAngleCorrectValues() { - Assert.assertTrue(CssTypesValidationUtils.isAngleValue("10deg")); - Assert.assertTrue(CssTypesValidationUtils.isAngleValue("-20grad")); - Assert.assertTrue(CssTypesValidationUtils.isAngleValue("30.5rad")); - Assert.assertTrue(CssTypesValidationUtils.isAngleValue("0rad")); + Assertions.assertTrue(CssTypesValidationUtils.isAngleValue("10deg")); + Assertions.assertTrue(CssTypesValidationUtils.isAngleValue("-20grad")); + Assertions.assertTrue(CssTypesValidationUtils.isAngleValue("30.5rad")); + Assertions.assertTrue(CssTypesValidationUtils.isAngleValue("0rad")); } @Test public void testIsAngleNullValue() { - Assert.assertFalse(CssTypesValidationUtils.isAngleValue(null)); + Assertions.assertFalse(CssTypesValidationUtils.isAngleValue(null)); } @Test public void testIsAngleIncorrectValues() { - Assert.assertFalse(CssTypesValidationUtils.isAngleValue("deg")); - Assert.assertFalse(CssTypesValidationUtils.isAngleValue("-20,6grad")); - Assert.assertFalse(CssTypesValidationUtils.isAngleValue("0")); - Assert.assertFalse(CssTypesValidationUtils.isAngleValue("10in")); - Assert.assertFalse(CssTypesValidationUtils.isAngleValue("10px")); + Assertions.assertFalse(CssTypesValidationUtils.isAngleValue("deg")); + Assertions.assertFalse(CssTypesValidationUtils.isAngleValue("-20,6grad")); + Assertions.assertFalse(CssTypesValidationUtils.isAngleValue("0")); + Assertions.assertFalse(CssTypesValidationUtils.isAngleValue("10in")); + Assertions.assertFalse(CssTypesValidationUtils.isAngleValue("10px")); } @Test public void validateMetricValue() { - Assert.assertTrue(CssTypesValidationUtils.isMetricValue("1px")); - Assert.assertTrue(CssTypesValidationUtils.isMetricValue("1in")); - Assert.assertTrue(CssTypesValidationUtils.isMetricValue("1cm")); - Assert.assertTrue(CssTypesValidationUtils.isMetricValue("1mm")); - Assert.assertTrue(CssTypesValidationUtils.isMetricValue("1pc")); - Assert.assertFalse(CssTypesValidationUtils.isMetricValue("1em")); - Assert.assertFalse(CssTypesValidationUtils.isMetricValue("1rem")); - Assert.assertFalse(CssTypesValidationUtils.isMetricValue("1ex")); - Assert.assertTrue(CssTypesValidationUtils.isMetricValue("1pt")); - Assert.assertFalse(CssTypesValidationUtils.isMetricValue("1inch")); - Assert.assertFalse(CssTypesValidationUtils.isMetricValue("+1m")); + Assertions.assertTrue(CssTypesValidationUtils.isMetricValue("1px")); + Assertions.assertTrue(CssTypesValidationUtils.isMetricValue("1in")); + Assertions.assertTrue(CssTypesValidationUtils.isMetricValue("1cm")); + Assertions.assertTrue(CssTypesValidationUtils.isMetricValue("1mm")); + Assertions.assertTrue(CssTypesValidationUtils.isMetricValue("1pc")); + Assertions.assertFalse(CssTypesValidationUtils.isMetricValue("1em")); + Assertions.assertFalse(CssTypesValidationUtils.isMetricValue("1rem")); + Assertions.assertFalse(CssTypesValidationUtils.isMetricValue("1ex")); + Assertions.assertTrue(CssTypesValidationUtils.isMetricValue("1pt")); + Assertions.assertFalse(CssTypesValidationUtils.isMetricValue("1inch")); + Assertions.assertFalse(CssTypesValidationUtils.isMetricValue("+1m")); } @Test public void isNegativeValueTest() { // Invalid values - Assert.assertFalse(CssTypesValidationUtils.isNegativeValue(null)); - Assert.assertFalse(CssTypesValidationUtils.isNegativeValue("-..23")); - Assert.assertFalse(CssTypesValidationUtils.isNegativeValue("12 34")); - Assert.assertFalse(CssTypesValidationUtils.isNegativeValue("12reeem")); + Assertions.assertFalse(CssTypesValidationUtils.isNegativeValue(null)); + Assertions.assertFalse(CssTypesValidationUtils.isNegativeValue("-..23")); + Assertions.assertFalse(CssTypesValidationUtils.isNegativeValue("12 34")); + Assertions.assertFalse(CssTypesValidationUtils.isNegativeValue("12reeem")); // Valid not negative values - Assert.assertFalse(CssTypesValidationUtils.isNegativeValue(".23")); - Assert.assertFalse(CssTypesValidationUtils.isNegativeValue("+123")); - Assert.assertFalse(CssTypesValidationUtils.isNegativeValue("57%")); - Assert.assertFalse(CssTypesValidationUtils.isNegativeValue("3.7em")); + Assertions.assertFalse(CssTypesValidationUtils.isNegativeValue(".23")); + Assertions.assertFalse(CssTypesValidationUtils.isNegativeValue("+123")); + Assertions.assertFalse(CssTypesValidationUtils.isNegativeValue("57%")); + Assertions.assertFalse(CssTypesValidationUtils.isNegativeValue("3.7em")); // Valid negative values - Assert.assertTrue(CssTypesValidationUtils.isNegativeValue("-1.7rem")); - Assert.assertTrue(CssTypesValidationUtils.isNegativeValue("-43.56%")); - Assert.assertTrue(CssTypesValidationUtils.isNegativeValue("-12")); - Assert.assertTrue(CssTypesValidationUtils.isNegativeValue("-0.123")); - Assert.assertTrue(CssTypesValidationUtils.isNegativeValue("-.34")); + Assertions.assertTrue(CssTypesValidationUtils.isNegativeValue("-1.7rem")); + Assertions.assertTrue(CssTypesValidationUtils.isNegativeValue("-43.56%")); + Assertions.assertTrue(CssTypesValidationUtils.isNegativeValue("-12")); + Assertions.assertTrue(CssTypesValidationUtils.isNegativeValue("-0.123")); + Assertions.assertTrue(CssTypesValidationUtils.isNegativeValue("-.34")); } @Test public void validateNumericValue() { - Assert.assertTrue(CssTypesValidationUtils.isNumber("1")); - Assert.assertTrue(CssTypesValidationUtils.isNumber("12")); - Assert.assertTrue(CssTypesValidationUtils.isNumber("1.2")); - Assert.assertTrue(CssTypesValidationUtils.isNumber(".12")); - Assert.assertFalse(CssTypesValidationUtils.isNumber("12f")); - Assert.assertFalse(CssTypesValidationUtils.isNumber("f1.2")); - Assert.assertFalse(CssTypesValidationUtils.isNumber(".12f")); + Assertions.assertTrue(CssTypesValidationUtils.isNumber("1")); + Assertions.assertTrue(CssTypesValidationUtils.isNumber("12")); + Assertions.assertTrue(CssTypesValidationUtils.isNumber("1.2")); + Assertions.assertTrue(CssTypesValidationUtils.isNumber(".12")); + Assertions.assertFalse(CssTypesValidationUtils.isNumber("12f")); + Assertions.assertFalse(CssTypesValidationUtils.isNumber("f1.2")); + Assertions.assertFalse(CssTypesValidationUtils.isNumber(".12f")); } @Test public void validateIntegerNumericValue() { - Assert.assertTrue(CssTypesValidationUtils.isIntegerNumber("1")); - Assert.assertTrue(CssTypesValidationUtils.isIntegerNumber("+12")); - Assert.assertTrue(CssTypesValidationUtils.isIntegerNumber("-12")); - Assert.assertFalse(CssTypesValidationUtils.isIntegerNumber(".12")); - Assert.assertFalse(CssTypesValidationUtils.isIntegerNumber("1.2")); - Assert.assertFalse(CssTypesValidationUtils.isIntegerNumber("1,2")); - Assert.assertFalse(CssTypesValidationUtils.isIntegerNumber("12f")); - Assert.assertFalse(CssTypesValidationUtils.isIntegerNumber("f1.2")); - Assert.assertFalse(CssTypesValidationUtils.isIntegerNumber(".12f")); + Assertions.assertTrue(CssTypesValidationUtils.isIntegerNumber("1")); + Assertions.assertTrue(CssTypesValidationUtils.isIntegerNumber("+12")); + Assertions.assertTrue(CssTypesValidationUtils.isIntegerNumber("-12")); + Assertions.assertFalse(CssTypesValidationUtils.isIntegerNumber(".12")); + Assertions.assertFalse(CssTypesValidationUtils.isIntegerNumber("1.2")); + Assertions.assertFalse(CssTypesValidationUtils.isIntegerNumber("1,2")); + Assertions.assertFalse(CssTypesValidationUtils.isIntegerNumber("12f")); + Assertions.assertFalse(CssTypesValidationUtils.isIntegerNumber("f1.2")); + Assertions.assertFalse(CssTypesValidationUtils.isIntegerNumber(".12f")); } @Test public void testSpacesBeforeUnitTypes() { - Assert.assertFalse(CssTypesValidationUtils.isAngleValue("10 deg")); - Assert.assertFalse(CssTypesValidationUtils.isEmValue("10 em")); - Assert.assertFalse(CssTypesValidationUtils.isExValue("10 ex")); - Assert.assertFalse(CssTypesValidationUtils.isRelativeValue("10 %")); - Assert.assertFalse(CssTypesValidationUtils.isRemValue("10 rem")); - Assert.assertFalse(CssTypesValidationUtils.isMetricValue("10 px")); - Assert.assertFalse(CssTypesValidationUtils.isPercentageValue("10 %")); + Assertions.assertFalse(CssTypesValidationUtils.isAngleValue("10 deg")); + Assertions.assertFalse(CssTypesValidationUtils.isEmValue("10 em")); + Assertions.assertFalse(CssTypesValidationUtils.isExValue("10 ex")); + Assertions.assertFalse(CssTypesValidationUtils.isRelativeValue("10 %")); + Assertions.assertFalse(CssTypesValidationUtils.isRemValue("10 rem")); + Assertions.assertFalse(CssTypesValidationUtils.isMetricValue("10 px")); + Assertions.assertFalse(CssTypesValidationUtils.isPercentageValue("10 %")); } @Test public void testSpacesAfterUnitTypes() { - Assert.assertTrue(CssTypesValidationUtils.isAngleValue("10deg ")); - Assert.assertTrue(CssTypesValidationUtils.isEmValue("10em ")); - Assert.assertTrue(CssTypesValidationUtils.isExValue("10ex ")); - Assert.assertTrue(CssTypesValidationUtils.isRelativeValue("10% ")); - Assert.assertTrue(CssTypesValidationUtils.isRemValue("10rem ")); - Assert.assertTrue(CssTypesValidationUtils.isMetricValue("10px ")); - Assert.assertTrue(CssTypesValidationUtils.isPercentageValue("10% ")); + Assertions.assertTrue(CssTypesValidationUtils.isAngleValue("10deg ")); + Assertions.assertTrue(CssTypesValidationUtils.isEmValue("10em ")); + Assertions.assertTrue(CssTypesValidationUtils.isExValue("10ex ")); + Assertions.assertTrue(CssTypesValidationUtils.isRelativeValue("10% ")); + Assertions.assertTrue(CssTypesValidationUtils.isRemValue("10rem ")); + Assertions.assertTrue(CssTypesValidationUtils.isMetricValue("10px ")); + Assertions.assertTrue(CssTypesValidationUtils.isPercentageValue("10% ")); } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/util/CssUtilsTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/util/CssUtilsTest.java index dca2767bfd..f38945c23d 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/util/CssUtilsTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/util/CssUtilsTest.java @@ -34,17 +34,15 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.UnitTest; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; -@Category(UnitTest.class) +@org.junit.jupiter.api.Tag("UnitTest") public class CssUtilsTest extends ExtendedITextTest { private static float EPS = 0.0001f; @@ -53,7 +51,7 @@ public void convertFloatMaximumToPdfTest() { float expected = Float.POSITIVE_INFINITY; float actual = CssUtils.convertPtsToPx(Float.MAX_VALUE); - Assert.assertEquals(expected, actual, 0f); + Assertions.assertEquals(expected, actual, 0f); } @Test @@ -61,7 +59,7 @@ public void convertFloatMinimumToPdfTest() { float expected = 1.4E-45f; float actual = CssUtils.convertPtsToPx(Float.MIN_VALUE); - Assert.assertEquals(expected, actual, 0f); + Assertions.assertEquals(expected, actual, 0f); } @Test @@ -70,7 +68,7 @@ public void extractShorthandPropertiesFromEmptyStringTest() { List> expected = new ArrayList<>(); expected.add(new ArrayList()); - Assert.assertEquals(expected, CssUtils.extractShorthandProperties(sourceString)); + Assertions.assertEquals(expected, CssUtils.extractShorthandProperties(sourceString)); } @Test @@ -83,7 +81,7 @@ public void extractShorthandPropertiesFromStringWithOnePropertyTest() { layer.add("url('sqpurple.gif')"); expected.add(layer); - Assert.assertEquals(expected, CssUtils.extractShorthandProperties(sourceString)); + Assertions.assertEquals(expected, CssUtils.extractShorthandProperties(sourceString)); } @Test @@ -102,7 +100,7 @@ public void extractShorthandPropertiesFromStringWithMultiplyPropertiesTest() { layer.add("url('sqpurple.gif')"); expected.add(layer); - Assert.assertEquals(expected, CssUtils.extractShorthandProperties(sourceString)); + Assertions.assertEquals(expected, CssUtils.extractShorthandProperties(sourceString)); } @Test @@ -112,45 +110,45 @@ public void normalConvertPtsToPxTest() { for (int i = 0; i < input.length; i++) { float actual = CssUtils.convertPtsToPx(input[i]); - Assert.assertEquals(expected[i], actual, 0f); + Assertions.assertEquals(expected[i], actual, 0f); } } @Test public void normalizeProperty() { - Assert.assertEquals("part1 part2", CssUtils.normalizeCssProperty(" part1 part2 ")); - Assert.assertEquals("\" the next quote is ESCAPED \\\\\\\" still IN string \"", CssUtils.normalizeCssProperty("\" the next quote is ESCAPED \\\\\\\" still IN string \"")); - Assert.assertEquals("\" the next quote is NOT ESCAPED \\\\\" not in the string", CssUtils.normalizeCssProperty("\" the next quote is NOT ESCAPED \\\\\" NOT in THE string")); - Assert.assertEquals("\" You CAN put 'Single Quotes' in double quotes WITHOUT escaping\"", CssUtils.normalizeCssProperty("\" You CAN put 'Single Quotes' in double quotes WITHOUT escaping\"")); - Assert.assertEquals("' You CAN put \"DOUBLE Quotes\" in double quotes WITHOUT escaping'", CssUtils.normalizeCssProperty("' You CAN put \"DOUBLE Quotes\" in double quotes WITHOUT escaping'")); - Assert.assertEquals("\" ( BLA \" attr(href)\" BLA ) \"", CssUtils.normalizeCssProperty("\" ( BLA \" AttR( Href )\" BLA ) \"")); - Assert.assertEquals("\" ( \"attr(href) \" ) \"", CssUtils.normalizeCssProperty("\" ( \"aTTr( hREf ) \" ) \"")); - Assert.assertEquals("rgba(255,255,255,0.2)", CssUtils.normalizeCssProperty("rgba( 255, 255 , 255 ,0.2 )")); + Assertions.assertEquals("part1 part2", CssUtils.normalizeCssProperty(" part1 part2 ")); + Assertions.assertEquals("\" the next quote is ESCAPED \\\\\\\" still IN string \"", CssUtils.normalizeCssProperty("\" the next quote is ESCAPED \\\\\\\" still IN string \"")); + Assertions.assertEquals("\" the next quote is NOT ESCAPED \\\\\" not in the string", CssUtils.normalizeCssProperty("\" the next quote is NOT ESCAPED \\\\\" NOT in THE string")); + Assertions.assertEquals("\" You CAN put 'Single Quotes' in double quotes WITHOUT escaping\"", CssUtils.normalizeCssProperty("\" You CAN put 'Single Quotes' in double quotes WITHOUT escaping\"")); + Assertions.assertEquals("' You CAN put \"DOUBLE Quotes\" in double quotes WITHOUT escaping'", CssUtils.normalizeCssProperty("' You CAN put \"DOUBLE Quotes\" in double quotes WITHOUT escaping'")); + Assertions.assertEquals("\" ( BLA \" attr(href)\" BLA ) \"", CssUtils.normalizeCssProperty("\" ( BLA \" AttR( Href )\" BLA ) \"")); + Assertions.assertEquals("\" ( \"attr(href) \" ) \"", CssUtils.normalizeCssProperty("\" ( \"aTTr( hREf ) \" ) \"")); + Assertions.assertEquals("rgba(255,255,255,0.2)", CssUtils.normalizeCssProperty("rgba( 255, 255 , 255 ,0.2 )")); } @Test public void normalizeUrlTest() { - Assert.assertEquals("url(data:application/font-woff;base64,2CBPCRXmgywtV1t4oWwjBju0kqkvfhPs0cYdMgFtDSY5uL7MIGT5wiGs078HrvBHekp0Yf=)", + Assertions.assertEquals("url(data:application/font-woff;base64,2CBPCRXmgywtV1t4oWwjBju0kqkvfhPs0cYdMgFtDSY5uL7MIGT5wiGs078HrvBHekp0Yf=)", CssUtils.normalizeCssProperty("url(data:application/font-woff;base64,2CBPCRXmgywtV1t4oWwjBju0kqkvfhPs0cYdMgFtDSY5uL7MIGT5wiGs078HrvBHekp0Yf=)")); - Assert.assertEquals("url(\"quoted Url\")", CssUtils.normalizeCssProperty(" url( \"quoted Url\")")); - Assert.assertEquals("url('quoted Url')", CssUtils.normalizeCssProperty(" url( 'quoted Url')")); - Assert.assertEquals("url(haveEscapedEndBracket\\))", CssUtils.normalizeCssProperty("url( haveEscapedEndBracket\\) )")); + Assertions.assertEquals("url(\"quoted Url\")", CssUtils.normalizeCssProperty(" url( \"quoted Url\")")); + Assertions.assertEquals("url('quoted Url')", CssUtils.normalizeCssProperty(" url( 'quoted Url')")); + Assertions.assertEquals("url(haveEscapedEndBracket\\))", CssUtils.normalizeCssProperty("url( haveEscapedEndBracket\\) )")); } @Test public void parseUnicodeRangeTest() { - Assert.assertEquals("[(0; 1048575)]", CssUtils.parseUnicodeRange("U+?????").toString()); - Assert.assertEquals("[(38; 38)]", CssUtils.parseUnicodeRange("U+26").toString()); - Assert.assertEquals("[(0; 127)]", CssUtils.parseUnicodeRange(" U+0-7F").toString()); - Assert.assertEquals("[(37; 255)]", CssUtils.parseUnicodeRange("U+0025-00FF").toString()); - Assert.assertEquals("[(1024; 1279)]", CssUtils.parseUnicodeRange("U+4??").toString()); - Assert.assertEquals("[(262224; 327519)]", CssUtils.parseUnicodeRange("U+4??5?").toString()); - Assert.assertEquals("[(37; 255), (1024; 1279)]", CssUtils.parseUnicodeRange("U+0025-00FF, U+4??").toString()); - - Assert.assertNull(CssUtils.parseUnicodeRange("U+??????")); // more than 5 question marks are not allowed - Assert.assertNull(CssUtils.parseUnicodeRange("UU+7-10")); // wrong syntax - Assert.assertNull(CssUtils.parseUnicodeRange("U+7?-9?")); // wrong syntax - Assert.assertNull(CssUtils.parseUnicodeRange("U+7-")); // wrong syntax + Assertions.assertEquals("[(0; 1048575)]", CssUtils.parseUnicodeRange("U+?????").toString()); + Assertions.assertEquals("[(38; 38)]", CssUtils.parseUnicodeRange("U+26").toString()); + Assertions.assertEquals("[(0; 127)]", CssUtils.parseUnicodeRange(" U+0-7F").toString()); + Assertions.assertEquals("[(37; 255)]", CssUtils.parseUnicodeRange("U+0025-00FF").toString()); + Assertions.assertEquals("[(1024; 1279)]", CssUtils.parseUnicodeRange("U+4??").toString()); + Assertions.assertEquals("[(262224; 327519)]", CssUtils.parseUnicodeRange("U+4??5?").toString()); + Assertions.assertEquals("[(37; 255), (1024; 1279)]", CssUtils.parseUnicodeRange("U+0025-00FF, U+4??").toString()); + + Assertions.assertNull(CssUtils.parseUnicodeRange("U+??????")); // more than 5 question marks are not allowed + Assertions.assertNull(CssUtils.parseUnicodeRange("UU+7-10")); // wrong syntax + Assertions.assertNull(CssUtils.parseUnicodeRange("U+7?-9?")); // wrong syntax + Assertions.assertNull(CssUtils.parseUnicodeRange("U+7-")); // wrong syntax } @Test @@ -159,7 +157,7 @@ public void elementNodeIsStyleSheetLink() { element.attr(CommonAttributeConstants.REL, CommonAttributeConstants.STYLESHEET); JsoupElementNode elementNode = new JsoupElementNode(element); - Assert.assertTrue(CssUtils.isStyleSheetLink(elementNode)); + Assertions.assertTrue(CssUtils.isStyleSheetLink(elementNode)); } @Test @@ -168,7 +166,7 @@ public void elementNodeIsNotLink() { element.attr(CommonAttributeConstants.REL, CommonAttributeConstants.STYLESHEET); JsoupElementNode elementNode = new JsoupElementNode(element); - Assert.assertFalse(CssUtils.isStyleSheetLink(elementNode)); + Assertions.assertFalse(CssUtils.isStyleSheetLink(elementNode)); } @Test @@ -177,90 +175,90 @@ public void elementNodeAttributeIsNotStylesheet() { element.attr(CommonAttributeConstants.REL, ""); JsoupElementNode elementNode = new JsoupElementNode(element); - Assert.assertFalse(CssUtils.isStyleSheetLink(elementNode)); + Assertions.assertFalse(CssUtils.isStyleSheetLink(elementNode)); } @Test @LogMessages(messages = @LogMessage(messageTemplate = StyledXmlParserLogMessageConstant.INCORRECT_CHARACTER_SEQUENCE)) public void splitStringWithCommaTest() { - Assert.assertEquals(new ArrayList(), CssUtils.splitStringWithComma(null)); - Assert.assertEquals(Arrays.asList("value1", "value2", "value3"), + Assertions.assertEquals(new ArrayList(), CssUtils.splitStringWithComma(null)); + Assertions.assertEquals(Arrays.asList("value1", "value2", "value3"), CssUtils.splitStringWithComma("value1,value2,value3")); - Assert.assertEquals(Arrays.asList("value1", " value2", " value3"), + Assertions.assertEquals(Arrays.asList("value1", " value2", " value3"), CssUtils.splitStringWithComma("value1, value2, value3")); - Assert.assertEquals(Arrays.asList("value1", "(value,with,comma)", "value3"), + Assertions.assertEquals(Arrays.asList("value1", "(value,with,comma)", "value3"), CssUtils.splitStringWithComma("value1,(value,with,comma),value3")); - Assert.assertEquals(Arrays.asList("value1", "(val(ue,with,comma),value3"), + Assertions.assertEquals(Arrays.asList("value1", "(val(ue,with,comma),value3"), CssUtils.splitStringWithComma("value1,(val(ue,with,comma),value3")); - Assert.assertEquals(Arrays.asList("value1", "(value,with)", "comma)", "value3"), + Assertions.assertEquals(Arrays.asList("value1", "(value,with)", "comma)", "value3"), CssUtils.splitStringWithComma("value1,(value,with),comma),value3")); - Assert.assertEquals(Arrays.asList("value1", "( v2,v3)", "(v4, v5)", "value3"), + Assertions.assertEquals(Arrays.asList("value1", "( v2,v3)", "(v4, v5)", "value3"), CssUtils.splitStringWithComma("value1,( v2,v3),(v4, v5),value3")); - Assert.assertEquals(Arrays.asList("v.al*ue1\"", "( v2,v3)", "\"(v4,v5;);", "value3"), + Assertions.assertEquals(Arrays.asList("v.al*ue1\"", "( v2,v3)", "\"(v4,v5;);", "value3"), CssUtils.splitStringWithComma("v.al*ue1\",( v2,v3),\"(v4,v5;);,value3")); } @Test public void splitStringTest() { - Assert.assertEquals(new ArrayList(), CssUtils.splitString(null, ',')); - Assert.assertEquals(Arrays.asList("value1", "(value,with,comma)", "value3"), + Assertions.assertEquals(new ArrayList(), CssUtils.splitString(null, ',')); + Assertions.assertEquals(Arrays.asList("value1", "(value,with,comma)", "value3"), CssUtils.splitString("value1,(value,with,comma),value3", ',', new EscapeGroup('(', ')'))); - Assert.assertEquals(Arrays.asList("value1 ", " (val(ue,with,comma),value3"), + Assertions.assertEquals(Arrays.asList("value1 ", " (val(ue,with,comma),value3"), CssUtils.splitString("value1 , (val(ue,with,comma),value3", ',', new EscapeGroup('(', ')'))); - Assert.assertEquals(Arrays.asList("some text", " (some", " text in", " brackets)", " \"some, text, in quotes,\""), + Assertions.assertEquals(Arrays.asList("some text", " (some", " text in", " brackets)", " \"some, text, in quotes,\""), CssUtils.splitString("some text, (some, text in, brackets), \"some, text, in quotes,\"", ',', new EscapeGroup('\"'))); - Assert.assertEquals(Arrays.asList("some text", " (some. text in. brackets)", " \"some. text. in quotes.\""), + Assertions.assertEquals(Arrays.asList("some text", " (some. text in. brackets)", " \"some. text. in quotes.\""), CssUtils.splitString("some text. (some. text in. brackets). \"some. text. in quotes.\"", '.', new EscapeGroup('\"'), new EscapeGroup('(', ')'))); - Assert.assertEquals(Arrays.asList("value1", "(value", "with" ,"comma)", "value3"), + Assertions.assertEquals(Arrays.asList("value1", "(value", "with" ,"comma)", "value3"), CssUtils.splitString("value1,(value,with,comma),value3", ',')); - Assert.assertEquals(Arrays.asList("value1", "value", "with" ,"comma", "value3"), + Assertions.assertEquals(Arrays.asList("value1", "value", "with" ,"comma", "value3"), CssUtils.splitString("value1,value,with,comma,value3", ',', new EscapeGroup(','))); } @Test public void parseBlendModeTest() { - Assert.assertEquals(BlendMode.NORMAL, CssUtils.parseBlendMode(null)); - Assert.assertEquals(BlendMode.NORMAL, CssUtils.parseBlendMode(CommonCssConstants.NORMAL)); - Assert.assertEquals(BlendMode.MULTIPLY, CssUtils.parseBlendMode(CommonCssConstants.MULTIPLY)); - Assert.assertEquals(BlendMode.SCREEN, CssUtils.parseBlendMode(CommonCssConstants.SCREEN)); - Assert.assertEquals(BlendMode.OVERLAY, CssUtils.parseBlendMode(CommonCssConstants.OVERLAY)); - Assert.assertEquals(BlendMode.DARKEN, CssUtils.parseBlendMode(CommonCssConstants.DARKEN)); - Assert.assertEquals(BlendMode.LIGHTEN, CssUtils.parseBlendMode(CommonCssConstants.LIGHTEN)); - Assert.assertEquals(BlendMode.COLOR_DODGE, CssUtils.parseBlendMode(CommonCssConstants.COLOR_DODGE)); - Assert.assertEquals(BlendMode.COLOR_BURN, CssUtils.parseBlendMode(CommonCssConstants.COLOR_BURN)); - Assert.assertEquals(BlendMode.HARD_LIGHT, CssUtils.parseBlendMode(CommonCssConstants.HARD_LIGHT)); - Assert.assertEquals(BlendMode.SOFT_LIGHT, CssUtils.parseBlendMode(CommonCssConstants.SOFT_LIGHT)); - Assert.assertEquals(BlendMode.DIFFERENCE, CssUtils.parseBlendMode(CommonCssConstants.DIFFERENCE)); - Assert.assertEquals(BlendMode.EXCLUSION, CssUtils.parseBlendMode(CommonCssConstants.EXCLUSION)); - Assert.assertEquals(BlendMode.HUE, CssUtils.parseBlendMode(CommonCssConstants.HUE)); - Assert.assertEquals(BlendMode.SATURATION, CssUtils.parseBlendMode(CommonCssConstants.SATURATION)); - Assert.assertEquals(BlendMode.COLOR, CssUtils.parseBlendMode(CommonCssConstants.COLOR)); - Assert.assertEquals(BlendMode.LUMINOSITY, CssUtils.parseBlendMode(CommonCssConstants.LUMINOSITY)); - Assert.assertEquals(BlendMode.NORMAL, CssUtils.parseBlendMode("invalid")); - Assert.assertEquals(BlendMode.NORMAL, CssUtils.parseBlendMode("SCREEN")); + Assertions.assertEquals(BlendMode.NORMAL, CssUtils.parseBlendMode(null)); + Assertions.assertEquals(BlendMode.NORMAL, CssUtils.parseBlendMode(CommonCssConstants.NORMAL)); + Assertions.assertEquals(BlendMode.MULTIPLY, CssUtils.parseBlendMode(CommonCssConstants.MULTIPLY)); + Assertions.assertEquals(BlendMode.SCREEN, CssUtils.parseBlendMode(CommonCssConstants.SCREEN)); + Assertions.assertEquals(BlendMode.OVERLAY, CssUtils.parseBlendMode(CommonCssConstants.OVERLAY)); + Assertions.assertEquals(BlendMode.DARKEN, CssUtils.parseBlendMode(CommonCssConstants.DARKEN)); + Assertions.assertEquals(BlendMode.LIGHTEN, CssUtils.parseBlendMode(CommonCssConstants.LIGHTEN)); + Assertions.assertEquals(BlendMode.COLOR_DODGE, CssUtils.parseBlendMode(CommonCssConstants.COLOR_DODGE)); + Assertions.assertEquals(BlendMode.COLOR_BURN, CssUtils.parseBlendMode(CommonCssConstants.COLOR_BURN)); + Assertions.assertEquals(BlendMode.HARD_LIGHT, CssUtils.parseBlendMode(CommonCssConstants.HARD_LIGHT)); + Assertions.assertEquals(BlendMode.SOFT_LIGHT, CssUtils.parseBlendMode(CommonCssConstants.SOFT_LIGHT)); + Assertions.assertEquals(BlendMode.DIFFERENCE, CssUtils.parseBlendMode(CommonCssConstants.DIFFERENCE)); + Assertions.assertEquals(BlendMode.EXCLUSION, CssUtils.parseBlendMode(CommonCssConstants.EXCLUSION)); + Assertions.assertEquals(BlendMode.HUE, CssUtils.parseBlendMode(CommonCssConstants.HUE)); + Assertions.assertEquals(BlendMode.SATURATION, CssUtils.parseBlendMode(CommonCssConstants.SATURATION)); + Assertions.assertEquals(BlendMode.COLOR, CssUtils.parseBlendMode(CommonCssConstants.COLOR)); + Assertions.assertEquals(BlendMode.LUMINOSITY, CssUtils.parseBlendMode(CommonCssConstants.LUMINOSITY)); + Assertions.assertEquals(BlendMode.NORMAL, CssUtils.parseBlendMode("invalid")); + Assertions.assertEquals(BlendMode.NORMAL, CssUtils.parseBlendMode("SCREEN")); } @Test public void testWrongAttrTest01() { String strToParse = "attr((href))"; String result = CssUtils.extractAttributeValue(strToParse, null); - Assert.assertNull(result); + Assertions.assertNull(result); } @Test public void testWrongAttrTest02() { String strToParse = "attr('href')"; String result = CssUtils.extractAttributeValue(strToParse, null); - Assert.assertNull(result); + Assertions.assertNull(result); } @Test public void testWrongAttrTest03() { String strToParse = "attrrname)"; String result = CssUtils.extractAttributeValue(strToParse, null); - Assert.assertNull(result); + Assertions.assertNull(result); } @Test @@ -268,7 +266,7 @@ public void testExtractingAttrTest01() { IElementNode iNode = new CssPseudoElementNode(null, "url"); String strToParse = "attr(url)"; String result = CssUtils.extractAttributeValue(strToParse, iNode); - Assert.assertEquals("", result); + Assertions.assertEquals("", result); } @Test @@ -276,7 +274,7 @@ public void testExtractingAttrTest02() { IElementNode iNode = new CssPseudoElementNode(null, "test"); String strToParse = "attr(url url)"; String result = CssUtils.extractAttributeValue(strToParse, iNode); - Assert.assertNull(result); + Assertions.assertNull(result); } @Test @@ -284,7 +282,7 @@ public void testExtractingAttrTest03() { IElementNode iNode = new CssPseudoElementNode(null, "test"); String strToParse = "attr(url url,#one)"; String result = CssUtils.extractAttributeValue(strToParse, iNode); - Assert.assertEquals("#one", result); + Assertions.assertEquals("#one", result); } @Test @@ -292,7 +290,7 @@ public void testExtractingAttrTest04() { IElementNode iNode = new CssPseudoElementNode(null, "test"); String strToParse = "attr()"; String result = CssUtils.extractAttributeValue(strToParse, iNode); - Assert.assertNull(result); + Assertions.assertNull(result); } @Test @@ -300,7 +298,7 @@ public void testExtractingAttrTest05() { IElementNode iNode = new CssPseudoElementNode(null, "test"); String strToParse = "attr('\')"; String result = CssUtils.extractAttributeValue(strToParse, iNode); - Assert.assertNull(result); + Assertions.assertNull(result); } @Test @@ -308,7 +306,7 @@ public void testExtractingAttrTest06() { IElementNode iNode = new CssPseudoElementNode(null, "test"); String strToParse = "attr(str,\"hey\")"; String result = CssUtils.extractAttributeValue(strToParse, iNode); - Assert.assertEquals("hey", result); + Assertions.assertEquals("hey", result); } @Test @@ -316,7 +314,7 @@ public void testExtractingAttrTest07() { IElementNode iNode = new CssPseudoElementNode(null, "test"); String strToParse = "attr(str string)"; String result = CssUtils.extractAttributeValue(strToParse, iNode); - Assert.assertEquals("", result); + Assertions.assertEquals("", result); } @Test @@ -324,7 +322,7 @@ public void testExtractingAttrTest08() { IElementNode iNode = new CssPseudoElementNode(null, "test"); String strToParse = "attr(str string,\"value\")"; String result = CssUtils.extractAttributeValue(strToParse, iNode); - Assert.assertEquals("value", result); + Assertions.assertEquals("value", result); } @Test @@ -332,7 +330,7 @@ public void testExtractingAttrTest09() { IElementNode iNode = new CssPseudoElementNode(null, "test"); String strToParse = "attr(str string,\"val,ue\")"; String result = CssUtils.extractAttributeValue(strToParse, iNode); - Assert.assertEquals("val,ue", result); + Assertions.assertEquals("val,ue", result); } @Test @@ -340,7 +338,7 @@ public void testExtractingAttrTest10() { IElementNode iNode = new CssPseudoElementNode(null, "test"); String strToParse = "attr(str string,'val,ue')"; String result = CssUtils.extractAttributeValue(strToParse, iNode); - Assert.assertEquals("val,ue", result); + Assertions.assertEquals("val,ue", result); } @Test @@ -348,7 +346,7 @@ public void testExtractingAttrTest11() { IElementNode iNode = new CssPseudoElementNode(null, "test"); String strToParse = "attr(name, \"value\", \"value\", \"value\")"; String result = CssUtils.extractAttributeValue(strToParse, iNode); - Assert.assertNull(result); + Assertions.assertNull(result); } @Test @@ -356,7 +354,7 @@ public void wrongAttributeTypeTest() { IElementNode iNode = new CssPseudoElementNode(null, "test"); String strToParse = "attr(str mem)"; String result = CssUtils.extractAttributeValue(strToParse, iNode); - Assert.assertNull(result); + Assertions.assertNull(result); } @Test @@ -364,6 +362,6 @@ public void wrongParamsInAttrFunctionTest() { IElementNode iNode = new CssPseudoElementNode(null, "test"); String strToParse = "attr(str mem lol)"; String result = CssUtils.extractAttributeValue(strToParse, iNode); - Assert.assertNull(result); + Assertions.assertNull(result); } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/validate/ArrayDataTypeValidatorTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/validate/ArrayDataTypeValidatorTest.java index 1a6006f6a5..807387b5a1 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/validate/ArrayDataTypeValidatorTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/validate/ArrayDataTypeValidatorTest.java @@ -25,37 +25,36 @@ This file is part of the iText (R) project. import com.itextpdf.styledxmlparser.css.validate.impl.datatype.ArrayDataTypeValidator; import com.itextpdf.styledxmlparser.css.validate.impl.datatype.CssBlendModeValidator; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class ArrayDataTypeValidatorTest extends ExtendedITextTest { @Test public void nullValueTest() { final ICssDataTypeValidator validator = new ArrayDataTypeValidator(new TestValidator()); - Assert.assertFalse(validator.isValid(null)); + Assertions.assertFalse(validator.isValid(null)); } @Test public void normalValueTest() { final ICssDataTypeValidator validator = new ArrayDataTypeValidator(new TestValidator()); - Assert.assertTrue(validator.isValid("")); - Assert.assertTrue(validator.isValid("test")); - Assert.assertTrue(validator.isValid("test is, test, ttest")); - Assert.assertTrue(validator.isValid("(te,st)")); - Assert.assertTrue(validator.isValid("(te,st), test,")); + Assertions.assertTrue(validator.isValid("")); + Assertions.assertTrue(validator.isValid("test")); + Assertions.assertTrue(validator.isValid("test is, test, ttest")); + Assertions.assertTrue(validator.isValid("(te,st)")); + Assertions.assertTrue(validator.isValid("(te,st), test,")); } @Test public void invalidValuesTest() { final ICssDataTypeValidator validator = new ArrayDataTypeValidator(new TestValidator()); - Assert.assertFalse(validator.isValid("norma")); - Assert.assertFalse(validator.isValid("te,st")); - Assert.assertFalse(validator.isValid("(te,st),, test,")); + Assertions.assertFalse(validator.isValid("norma")); + Assertions.assertFalse(validator.isValid("te,st")); + Assertions.assertFalse(validator.isValid("(te,st),, test,")); } private static class TestValidator implements ICssDataTypeValidator { diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/validate/CssBackgroundValidatorTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/validate/CssBackgroundValidatorTest.java index 16a76167cd..2c3bd1f92e 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/validate/CssBackgroundValidatorTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/validate/CssBackgroundValidatorTest.java @@ -24,159 +24,158 @@ This file is part of the iText (R) project. import com.itextpdf.styledxmlparser.css.validate.impl.datatype.CssBackgroundValidator; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class CssBackgroundValidatorTest extends ExtendedITextTest { @Test public void nullValueTest() { final ICssDataTypeValidator validator = new CssBackgroundValidator("any property"); - Assert.assertFalse(validator.isValid(null)); + Assertions.assertFalse(validator.isValid(null)); } @Test public void undefinedValueTest() { final ICssDataTypeValidator validator = new CssBackgroundValidator("undefined"); - Assert.assertFalse(validator.isValid("ja")); + Assertions.assertFalse(validator.isValid("ja")); } @Test public void initialInheritUnsetValueTest() { final ICssDataTypeValidator validator = new CssBackgroundValidator("any property"); - Assert.assertTrue(validator.isValid("initial")); - Assert.assertTrue(validator.isValid("inherit")); - Assert.assertTrue(validator.isValid("unset")); + Assertions.assertTrue(validator.isValid("initial")); + Assertions.assertTrue(validator.isValid("inherit")); + Assertions.assertTrue(validator.isValid("unset")); } @Test public void emptyValueTest() { final ICssDataTypeValidator validator = new CssBackgroundValidator("any property"); - Assert.assertFalse(validator.isValid("")); + Assertions.assertFalse(validator.isValid("")); } @Test public void propertyValueCorrespondsPropertyTypeTest() { ICssDataTypeValidator validator = new CssBackgroundValidator("background-repeat"); - Assert.assertTrue(validator.isValid("repeat-x")); - Assert.assertFalse(validator.isValid("cover")); + Assertions.assertTrue(validator.isValid("repeat-x")); + Assertions.assertFalse(validator.isValid("cover")); validator = new CssBackgroundValidator("background-image"); - Assert.assertTrue(validator.isValid("url(something.png)")); - Assert.assertFalse(validator.isValid("5px")); + Assertions.assertTrue(validator.isValid("url(something.png)")); + Assertions.assertFalse(validator.isValid("5px")); validator = new CssBackgroundValidator("background-attachment"); - Assert.assertTrue(validator.isValid("fixed")); - Assert.assertFalse(validator.isValid("5px")); + Assertions.assertTrue(validator.isValid("fixed")); + Assertions.assertFalse(validator.isValid("5px")); } @Test public void propertyValueWithMultiTypesCorrespondsPropertyTypeTest() { final ICssDataTypeValidator positionValidator = new CssBackgroundValidator("background-position-x"); final ICssDataTypeValidator sizeValidator = new CssBackgroundValidator("background-size"); - Assert.assertTrue(positionValidator.isValid("5px")); - Assert.assertTrue(sizeValidator.isValid("5px")); - Assert.assertTrue(positionValidator.isValid("5%")); - Assert.assertTrue(sizeValidator.isValid("5%")); - Assert.assertTrue(positionValidator.isValid("left")); - Assert.assertFalse(sizeValidator.isValid("left")); - Assert.assertFalse(positionValidator.isValid("contain")); - Assert.assertTrue(sizeValidator.isValid("contain")); + Assertions.assertTrue(positionValidator.isValid("5px")); + Assertions.assertTrue(sizeValidator.isValid("5px")); + Assertions.assertTrue(positionValidator.isValid("5%")); + Assertions.assertTrue(sizeValidator.isValid("5%")); + Assertions.assertTrue(positionValidator.isValid("left")); + Assertions.assertFalse(sizeValidator.isValid("left")); + Assertions.assertFalse(positionValidator.isValid("contain")); + Assertions.assertTrue(sizeValidator.isValid("contain")); final ICssDataTypeValidator originValidator = new CssBackgroundValidator("background-origin"); final ICssDataTypeValidator clipValidator = new CssBackgroundValidator("background-clip"); - Assert.assertTrue(originValidator.isValid("border-box")); - Assert.assertTrue(clipValidator.isValid("border-box")); - Assert.assertTrue(originValidator.isValid("padding-box")); - Assert.assertTrue(clipValidator.isValid("padding-box")); - Assert.assertTrue(originValidator.isValid("content-box")); - Assert.assertTrue(clipValidator.isValid("content-box")); + Assertions.assertTrue(originValidator.isValid("border-box")); + Assertions.assertTrue(clipValidator.isValid("border-box")); + Assertions.assertTrue(originValidator.isValid("padding-box")); + Assertions.assertTrue(clipValidator.isValid("padding-box")); + Assertions.assertTrue(originValidator.isValid("content-box")); + Assertions.assertTrue(clipValidator.isValid("content-box")); } @Test public void checkMultiValuePositionXYTest() { ICssDataTypeValidator positionValidator = new CssBackgroundValidator("background-position-x"); - Assert.assertFalse(positionValidator.isValid("50px left")); - Assert.assertFalse(positionValidator.isValid("50px bottom")); - Assert.assertFalse(positionValidator.isValid("center 50pt")); - Assert.assertFalse(positionValidator.isValid("50px 50pt")); - Assert.assertFalse(positionValidator.isValid("left right")); - Assert.assertFalse(positionValidator.isValid("bottom")); + Assertions.assertFalse(positionValidator.isValid("50px left")); + Assertions.assertFalse(positionValidator.isValid("50px bottom")); + Assertions.assertFalse(positionValidator.isValid("center 50pt")); + Assertions.assertFalse(positionValidator.isValid("50px 50pt")); + Assertions.assertFalse(positionValidator.isValid("left right")); + Assertions.assertFalse(positionValidator.isValid("bottom")); - Assert.assertTrue(positionValidator.isValid("left 10pt")); - Assert.assertTrue(positionValidator.isValid("center")); + Assertions.assertTrue(positionValidator.isValid("left 10pt")); + Assertions.assertTrue(positionValidator.isValid("center")); positionValidator = new CssBackgroundValidator("background-position-y"); - Assert.assertTrue(positionValidator.isValid("bottom 10pt")); - Assert.assertTrue(positionValidator.isValid("10pt")); + Assertions.assertTrue(positionValidator.isValid("bottom 10pt")); + Assertions.assertTrue(positionValidator.isValid("10pt")); - Assert.assertFalse(positionValidator.isValid("right")); + Assertions.assertFalse(positionValidator.isValid("right")); final ICssDataTypeValidator notPositionValidator = new CssBackgroundValidator("background-size"); - Assert.assertTrue(notPositionValidator.isValid("10px 15pt")); + Assertions.assertTrue(notPositionValidator.isValid("10px 15pt")); } @Test public void multiValuesAllowedForThisTypeTest() { ICssDataTypeValidator validator = new CssBackgroundValidator("background-size"); - Assert.assertTrue(validator.isValid("5px 10%")); + Assertions.assertTrue(validator.isValid("5px 10%")); validator = new CssBackgroundValidator("background-position-x"); - Assert.assertTrue(validator.isValid("left 10px")); - Assert.assertFalse(validator.isValid("5px 10%")); - Assert.assertFalse(validator.isValid("left left left left left")); + Assertions.assertTrue(validator.isValid("left 10px")); + Assertions.assertFalse(validator.isValid("5px 10%")); + Assertions.assertFalse(validator.isValid("left left left left left")); validator = new CssBackgroundValidator("background-position-y"); - Assert.assertTrue(validator.isValid("bottom 10px")); - Assert.assertFalse(validator.isValid("5px 10%")); - Assert.assertFalse(validator.isValid("bottom bottom bottom bottom")); + Assertions.assertTrue(validator.isValid("bottom 10px")); + Assertions.assertFalse(validator.isValid("5px 10%")); + Assertions.assertFalse(validator.isValid("bottom bottom bottom bottom")); validator = new CssBackgroundValidator("background-repeat"); - Assert.assertTrue(validator.isValid("repeat round")); - Assert.assertFalse(validator.isValid("repeat-x repeat")); + Assertions.assertTrue(validator.isValid("repeat round")); + Assertions.assertFalse(validator.isValid("repeat-x repeat")); validator = new CssBackgroundValidator("background-image"); - Assert.assertFalse(validator.isValid("url(something.png) url(something2.png)")); + Assertions.assertFalse(validator.isValid("url(something.png) url(something2.png)")); validator = new CssBackgroundValidator("background-clip"); - Assert.assertFalse(validator.isValid("content-box padding-box")); + Assertions.assertFalse(validator.isValid("content-box padding-box")); validator = new CssBackgroundValidator("background-origin"); - Assert.assertFalse(validator.isValid("content-box padding-box")); + Assertions.assertFalse(validator.isValid("content-box padding-box")); validator = new CssBackgroundValidator("background-attachment"); - Assert.assertFalse(validator.isValid("fixed scroll")); + Assertions.assertFalse(validator.isValid("fixed scroll")); } @Test public void multiValuesAllowedForThisValueTest() { ICssDataTypeValidator validator = new CssBackgroundValidator("background-repeat"); - Assert.assertTrue(validator.isValid("repeat no-repeat")); - Assert.assertTrue(validator.isValid("round space")); - Assert.assertTrue(validator.isValid("no-repeat space")); - Assert.assertTrue(validator.isValid("round repeat")); - Assert.assertTrue(validator.isValid("space repeat")); + Assertions.assertTrue(validator.isValid("repeat no-repeat")); + Assertions.assertTrue(validator.isValid("round space")); + Assertions.assertTrue(validator.isValid("no-repeat space")); + Assertions.assertTrue(validator.isValid("round repeat")); + Assertions.assertTrue(validator.isValid("space repeat")); - Assert.assertFalse(validator.isValid("repeat-x repeat")); - Assert.assertFalse(validator.isValid("repeat-y no-repeat")); - Assert.assertFalse(validator.isValid("round repeat-x")); - Assert.assertFalse(validator.isValid("space repeat-x")); + Assertions.assertFalse(validator.isValid("repeat-x repeat")); + Assertions.assertFalse(validator.isValid("repeat-y no-repeat")); + Assertions.assertFalse(validator.isValid("round repeat-x")); + Assertions.assertFalse(validator.isValid("space repeat-x")); validator = new CssBackgroundValidator("background-size"); - Assert.assertTrue(validator.isValid("5px 5px")); + Assertions.assertTrue(validator.isValid("5px 5px")); - Assert.assertFalse(validator.isValid("contain 5px")); - Assert.assertFalse(validator.isValid("cover 10%")); + Assertions.assertFalse(validator.isValid("contain 5px")); + Assertions.assertFalse(validator.isValid("cover 10%")); } @Test public void severalValuesTest() { final ICssDataTypeValidator validator = new CssBackgroundValidator("background-image"); - Assert.assertTrue(validator.isValid("url(img.png),url(img2.png),url(img3.jpg)")); - Assert.assertTrue(validator.isValid("url(img.png),none,url(img3.jpg)")); - Assert.assertTrue(validator.isValid("linear-gradient(red, red, red),url(img2.png),url(img3.jpg)")); + Assertions.assertTrue(validator.isValid("url(img.png),url(img2.png),url(img3.jpg)")); + Assertions.assertTrue(validator.isValid("url(img.png),none,url(img3.jpg)")); + Assertions.assertTrue(validator.isValid("linear-gradient(red, red, red),url(img2.png),url(img3.jpg)")); } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/validate/CssBlendModeValidatorTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/validate/CssBlendModeValidatorTest.java index c3112f84ee..c606aef5b9 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/validate/CssBlendModeValidatorTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/validate/CssBlendModeValidatorTest.java @@ -24,47 +24,46 @@ This file is part of the iText (R) project. import com.itextpdf.styledxmlparser.css.validate.impl.datatype.CssBlendModeValidator; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class CssBlendModeValidatorTest extends ExtendedITextTest { @Test public void nullValueTest() { final ICssDataTypeValidator validator = new CssBlendModeValidator(); - Assert.assertFalse(validator.isValid(null)); + Assertions.assertFalse(validator.isValid(null)); } @Test public void normalValueTest() { final ICssDataTypeValidator validator = new CssBlendModeValidator(); - Assert.assertTrue(validator.isValid("normal")); - Assert.assertTrue(validator.isValid("multiply")); - Assert.assertTrue(validator.isValid("screen")); - Assert.assertTrue(validator.isValid("overlay")); - Assert.assertTrue(validator.isValid("darken")); - Assert.assertTrue(validator.isValid("lighten")); - Assert.assertTrue(validator.isValid("color-dodge")); - Assert.assertTrue(validator.isValid("color-burn")); - Assert.assertTrue(validator.isValid("hard-light")); - Assert.assertTrue(validator.isValid("soft-light")); - Assert.assertTrue(validator.isValid("difference")); - Assert.assertTrue(validator.isValid("exclusion")); - Assert.assertTrue(validator.isValid("hue")); - Assert.assertTrue(validator.isValid("saturation")); - Assert.assertTrue(validator.isValid("color")); - Assert.assertTrue(validator.isValid("luminosity")); + Assertions.assertTrue(validator.isValid("normal")); + Assertions.assertTrue(validator.isValid("multiply")); + Assertions.assertTrue(validator.isValid("screen")); + Assertions.assertTrue(validator.isValid("overlay")); + Assertions.assertTrue(validator.isValid("darken")); + Assertions.assertTrue(validator.isValid("lighten")); + Assertions.assertTrue(validator.isValid("color-dodge")); + Assertions.assertTrue(validator.isValid("color-burn")); + Assertions.assertTrue(validator.isValid("hard-light")); + Assertions.assertTrue(validator.isValid("soft-light")); + Assertions.assertTrue(validator.isValid("difference")); + Assertions.assertTrue(validator.isValid("exclusion")); + Assertions.assertTrue(validator.isValid("hue")); + Assertions.assertTrue(validator.isValid("saturation")); + Assertions.assertTrue(validator.isValid("color")); + Assertions.assertTrue(validator.isValid("luminosity")); } @Test public void invalidValuesTest() { final ICssDataTypeValidator validator = new CssBlendModeValidator(); - Assert.assertFalse(validator.isValid("")); - Assert.assertFalse(validator.isValid("norma")); - Assert.assertFalse(validator.isValid("NORMAL")); + Assertions.assertFalse(validator.isValid("")); + Assertions.assertFalse(validator.isValid("norma")); + Assertions.assertFalse(validator.isValid("NORMAL")); } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/validate/CssDeclarationValidationMasterTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/validate/CssDeclarationValidationMasterTest.java index 019ce76d79..31fb115a43 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/validate/CssDeclarationValidationMasterTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/validate/CssDeclarationValidationMasterTest.java @@ -27,262 +27,260 @@ This file is part of the iText (R) project. import com.itextpdf.styledxmlparser.css.validate.impl.CssDefaultValidator; import com.itextpdf.styledxmlparser.css.validate.impl.CssDeviceCmykAwareValidator; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -@Category(UnitTest.class) +@Tag("UnitTest") public class CssDeclarationValidationMasterTest extends ExtendedITextTest { @Test public void fontSizeEnumValidationTest() { - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.FONT_SIZE, "larger"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.FONT_SIZE, "smaller"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.FONT_SIZE, "xx-small"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.FONT_SIZE, "x-small"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.FONT_SIZE, "small"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.FONT_SIZE, "medium"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.FONT_SIZE, "large"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.FONT_SIZE, "x-large"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.FONT_SIZE, "xx-large"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.FONT_SIZE, "smaler"))); + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.FONT_SIZE, "larger"))); + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.FONT_SIZE, "smaller"))); + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.FONT_SIZE, "xx-small"))); + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.FONT_SIZE, "x-small"))); + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.FONT_SIZE, "small"))); + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.FONT_SIZE, "medium"))); + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.FONT_SIZE, "large"))); + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.FONT_SIZE, "x-large"))); + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.FONT_SIZE, "xx-large"))); + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.FONT_SIZE, "smaler"))); } @Test public void fontSizeNumericValidationTest() { - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.FONT_SIZE, "5px"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.FONT_SIZE, "5jaja"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.FONT_SIZE, "normal"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.FONT_SIZE, "5%"))); + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.FONT_SIZE, "5px"))); + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.FONT_SIZE, "5jaja"))); + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.FONT_SIZE, "normal"))); + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.FONT_SIZE, "5%"))); } @Test public void wordSpacingValidationTest() { - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.WORD_SPACING, "5px"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.WORD_SPACING, "5jaja"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.WORD_SPACING, "normal"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.WORD_SPACING, "5%"))); + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.WORD_SPACING, "5px"))); + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.WORD_SPACING, "5jaja"))); + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.WORD_SPACING, "normal"))); + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.WORD_SPACING, "5%"))); } @Test public void letterSpacingValidationTest() { - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.LETTER_SPACING, "5px"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.LETTER_SPACING, "5jaja"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.LETTER_SPACING, "normal"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.LETTER_SPACING, "5%"))); + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.LETTER_SPACING, "5px"))); + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.LETTER_SPACING, "5jaja"))); + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.LETTER_SPACING, "normal"))); + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.LETTER_SPACING, "5%"))); } @Test public void textIndentValidationTest() { - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.TEXT_INDENT, "5px"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.TEXT_INDENT, "5jaja"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.TEXT_INDENT, "normal"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.TEXT_INDENT, "5%"))); + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.TEXT_INDENT, "5px"))); + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.TEXT_INDENT, "5jaja"))); + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.TEXT_INDENT, "normal"))); + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.TEXT_INDENT, "5%"))); } @Test public void lineHeightValidationTest() { - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.LINE_HEIGHT, "5px"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.LINE_HEIGHT, "5jaja"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.LINE_HEIGHT, "normal"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.LINE_HEIGHT, "5%"))); + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.LINE_HEIGHT, "5px"))); + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.LINE_HEIGHT, "5jaja"))); + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.LINE_HEIGHT, "normal"))); + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.LINE_HEIGHT, "5%"))); } @Test public void backgroundRepeatValidationTest() { - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_REPEAT, "initial"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_REPEAT, "no-repeat"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_REPEAT, "repeat no-repeat"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_REPEAT, "space"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_REPEAT, "round"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_REPEAT, "space repeat"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_REPEAT, "no-repeat round"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_REPEAT, "no-repeat,repeat"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_REPEAT, "no-repeat repeat,repeat"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_REPEAT, "repeat-x, repeat no-repeat"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_REPEAT, "5px"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_REPEAT, "ja"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_REPEAT, "repeat-x repeat"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_REPEAT, "initial repeat"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_REPEAT, "repeat, repeat-x repeat"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_REPEAT, "ja, repeat"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_REPEAT, "initial, repeat"))); } @Test public void backgroundPositionValidationTest() { - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_POSITION_X, "initial"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_POSITION_Y, "-0"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_POSITION_Y, "5px"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_POSITION_X, "5em"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_POSITION_Y, "5px, 5%, bottom"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_POSITION_X, "left 5%, right"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_POSITION_X, "5"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_POSITION_Y, "ja"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_POSITION_X, "initial 5px"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_POSITION_Y, "ja, 5px"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_POSITION_X, "initial, 5px"))); } @Test public void backgroundSizeTest() { - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_SIZE, "initial"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_SIZE, "0"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_SIZE, "10px"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_SIZE, "10%"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_SIZE, "10% 10px"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_SIZE, "10px 10em"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_SIZE, "auto"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_SIZE, "auto 10px"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_SIZE, "10px auto"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_SIZE, "cover"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_SIZE, "contain"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_SIZE, "5px, 10%, auto"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_SIZE, "5px 10%, 20em"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_SIZE, "ja"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_SIZE, "10"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_SIZE, "cover 10px"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_SIZE, "initial 10px"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_SIZE, "10px contain"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_SIZE, "ja, 5px"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_SIZE, "5px, ja"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_SIZE, "initial, 10px"))); } @Test public void backgroundOriginTest() { - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_ORIGIN, "initial"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_ORIGIN, "border-box"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_ORIGIN, "padding-box"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_ORIGIN, "content-box"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_ORIGIN, "content-box, border-box"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_ORIGIN, "5px"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_ORIGIN, "ja"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_ORIGIN, "border-box border-box"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_ORIGIN, "content-box padding-box"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_ORIGIN, "ja, padding-box"))); } @Test public void backgroundClipTest() { - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_CLIP, "initial"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_CLIP, "border-box"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_CLIP, "padding-box"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_CLIP, "content-box"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_CLIP, "content-box, border-box"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_CLIP, "5px"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_CLIP, "ja"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_CLIP, "border-box border-box"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_CLIP, "content-box padding-box"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_CLIP, "ja, padding-box"))); } @Test public void backgroundImageTest() { - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_IMAGE, "initial"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_IMAGE, "url(rock_texture.jpg)"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_IMAGE, "linear-gradient(red,green,blue)"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_IMAGE, "url()"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_IMAGE, "none"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_IMAGE, "url(img.jpg),url(img2.jpg)"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_IMAGE, "none,url(img2.jpg)"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_IMAGE, "linear-gradient(red,green,blue),url(img2.jpg)"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_IMAGE, "ja"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_IMAGE, "5px"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_IMAGE, "url(url(rock_texture.jpg)"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_IMAGE, "true-linear-gradient(red,green,blue)"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_IMAGE, "url(img.jpg) url(img2.jpg)"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.BACKGROUND_IMAGE, "initial,url(img.jpg)"))); } @@ -291,142 +289,142 @@ public void overflowWrapTest() { String[] overflowWrapOrWordWrap = new String[] {CommonCssConstants.OVERFLOW_WRAP, CommonCssConstants.WORDWRAP}; for (String overflowWrap : overflowWrapOrWordWrap) { - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(overflowWrap, "normal"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(overflowWrap, "anywhere"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(overflowWrap, "break-word"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(overflowWrap, "inherit"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(overflowWrap, "unset"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(overflowWrap, "initial"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(overflowWrap, "auto"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(overflowWrap, "norm"))); } } @Test public void wordWrapTest() { - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.WORD_BREAK, "normal"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.WORD_BREAK, "break-all"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.WORD_BREAK, "keep-all"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.WORD_BREAK, "break-word"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.WORD_BREAK, "inherit"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.WORD_BREAK, "unset"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.WORD_BREAK, "initial"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.WORD_BREAK, "auto"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.WORD_BREAK, "norm"))); } @Test public void justifyContentTest() { - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.JUSTIFY_CONTENT, "inherit"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.JUSTIFY_CONTENT, "right"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.JUSTIFY_CONTENT, "normal"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.JUSTIFY_CONTENT, "space-between"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.JUSTIFY_CONTENT, "self-end"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.JUSTIFY_CONTENT, "unsafe self-end"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.JUSTIFY_CONTENT, "stretch"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.JUSTIFY_CONTENT, "space-evenly"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.JUSTIFY_CONTENT, "flex-start"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.JUSTIFY_CONTENT, "baseline"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.JUSTIFY_CONTENT, "safe right"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.JUSTIFY_CONTENT, "unsafe normal"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.JUSTIFY_CONTENT, "unsafe space-between"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.JUSTIFY_CONTENT, "self-center"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.JUSTIFY_CONTENT, "self-end unsafe"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.JUSTIFY_CONTENT, "safe stretch"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.JUSTIFY_CONTENT, "space_evenly"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.JUSTIFY_CONTENT, "flex-start left"))); } @Test public void multicolValidationTest() { - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.COLUMN_COUNT, "auto"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.COLUMN_COUNT, "3"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.COLUMN_COUNT, "-3"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.COLUMN_WIDTH, "auto"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.COLUMN_WIDTH, "30px"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.COLUMN_WIDTH, "20%"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.COLUMN_WIDTH, "5em"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.COLUMN_WIDTH, "5rem"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.COLUMN_WIDTH, "-5rem"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.COLUMN_WIDTH, "10"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.COLUMN_GAP, "normal"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.COLUMN_GAP, "30px"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.COLUMN_GAP, "15%"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.COLUMN_GAP, "2em"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.COLUMN_GAP, "3rem"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.COLUMN_GAP, "-5em"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.COLUMN_GAP, "10"))); } @Test public void gridRowColumnGapTest() { - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.GRID_ROW_GAP, "normal"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.GRID_COLUMN_GAP, "30px"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.GRID_ROW_GAP, "15%"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.GRID_ROW_GAP, "2em"))); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.GRID_COLUMN_GAP, "3rem"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.GRID_COLUMN_GAP, "-5em"))); - Assert.assertFalse(CssDeclarationValidationMaster.checkDeclaration( + Assertions.assertFalse(CssDeclarationValidationMaster.checkDeclaration( new CssDeclaration(CommonCssConstants.GRID_ROW_GAP, "10"))); } @@ -434,7 +432,7 @@ public void gridRowColumnGapTest() { public void changeValidatorTest() { try { CssDeclarationValidationMaster.setValidator(new CssDeviceCmykAwareValidator()); - Assert.assertTrue(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.COLOR, "device-cmyk(0, 100%, 70%, 0)"))); + Assertions.assertTrue(CssDeclarationValidationMaster.checkDeclaration(new CssDeclaration(CommonCssConstants.COLOR, "device-cmyk(0, 100%, 70%, 0)"))); } finally { CssDeclarationValidationMaster.setValidator(new CssDefaultValidator()); } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/validate/CssIntegerNumberValueValidatorTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/validate/CssIntegerNumberValueValidatorTest.java index d105cab77f..f975faac44 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/validate/CssIntegerNumberValueValidatorTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/validate/CssIntegerNumberValueValidatorTest.java @@ -24,164 +24,163 @@ This file is part of the iText (R) project. import com.itextpdf.styledxmlparser.css.validate.impl.datatype.CssIntegerNumberValueValidator; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class CssIntegerNumberValueValidatorTest extends ExtendedITextTest { @Test public void zeroValueTest() { final ICssDataTypeValidator validator1 = new CssIntegerNumberValueValidator(false, true); - Assert.assertTrue(validator1.isValid("0")); - Assert.assertTrue(validator1.isValid("+0")); + Assertions.assertTrue(validator1.isValid("0")); + Assertions.assertTrue(validator1.isValid("+0")); final ICssDataTypeValidator validator2 = new CssIntegerNumberValueValidator(false, false); - Assert.assertFalse(validator2.isValid("0")); + Assertions.assertFalse(validator2.isValid("0")); final ICssDataTypeValidator validator3 = new CssIntegerNumberValueValidator(true, true); - Assert.assertTrue(validator3.isValid("0")); - Assert.assertTrue(validator3.isValid("-0")); + Assertions.assertTrue(validator3.isValid("0")); + Assertions.assertTrue(validator3.isValid("-0")); final ICssDataTypeValidator validator4 = new CssIntegerNumberValueValidator(true, false); - Assert.assertFalse(validator4.isValid("0")); + Assertions.assertFalse(validator4.isValid("0")); } @Test public void correctValueTest() { final ICssDataTypeValidator validator1 = new CssIntegerNumberValueValidator(false, true); - Assert.assertTrue(validator1.isValid("123")); - Assert.assertTrue(validator1.isValid("+123")); - Assert.assertFalse(validator1.isValid("1.23")); + Assertions.assertTrue(validator1.isValid("123")); + Assertions.assertTrue(validator1.isValid("+123")); + Assertions.assertFalse(validator1.isValid("1.23")); final ICssDataTypeValidator validator2 = new CssIntegerNumberValueValidator(false, false); - Assert.assertFalse(validator2.isValid("-123")); - Assert.assertFalse(validator2.isValid("-1.23")); + Assertions.assertFalse(validator2.isValid("-123")); + Assertions.assertFalse(validator2.isValid("-1.23")); final ICssDataTypeValidator validator3 = new CssIntegerNumberValueValidator(true, true); - Assert.assertTrue(validator3.isValid("-123")); - Assert.assertTrue(validator3.isValid("-123")); - Assert.assertFalse(validator3.isValid("-1.23")); + Assertions.assertTrue(validator3.isValid("-123")); + Assertions.assertTrue(validator3.isValid("-123")); + Assertions.assertFalse(validator3.isValid("-1.23")); final ICssDataTypeValidator validator4 = new CssIntegerNumberValueValidator(true, false); - Assert.assertFalse(validator4.isValid("0")); + Assertions.assertFalse(validator4.isValid("0")); } @Test public void nullValueTest() { final ICssDataTypeValidator validator1 = new CssIntegerNumberValueValidator(false, false); - Assert.assertFalse(validator1.isValid(null)); + Assertions.assertFalse(validator1.isValid(null)); final ICssDataTypeValidator validator2 = new CssIntegerNumberValueValidator(true, true); - Assert.assertFalse(validator2.isValid(null)); + Assertions.assertFalse(validator2.isValid(null)); final ICssDataTypeValidator validator3 = new CssIntegerNumberValueValidator(false, true); - Assert.assertFalse(validator3.isValid(null)); + Assertions.assertFalse(validator3.isValid(null)); final ICssDataTypeValidator validator4 = new CssIntegerNumberValueValidator(false, true); - Assert.assertFalse(validator4.isValid(null)); + Assertions.assertFalse(validator4.isValid(null)); } @Test public void initialInheritUnsetValuesTest() { final ICssDataTypeValidator validator1 = new CssIntegerNumberValueValidator(false, true); - Assert.assertTrue(validator1.isValid("initial")); - Assert.assertTrue(validator1.isValid("inherit")); - Assert.assertTrue(validator1.isValid("unset")); + Assertions.assertTrue(validator1.isValid("initial")); + Assertions.assertTrue(validator1.isValid("inherit")); + Assertions.assertTrue(validator1.isValid("unset")); final ICssDataTypeValidator validator2 = new CssIntegerNumberValueValidator(true, false); - Assert.assertTrue(validator2.isValid("initial")); - Assert.assertTrue(validator2.isValid("inherit")); - Assert.assertTrue(validator2.isValid("unset")); + Assertions.assertTrue(validator2.isValid("initial")); + Assertions.assertTrue(validator2.isValid("inherit")); + Assertions.assertTrue(validator2.isValid("unset")); } @Test public void normalValueTest() { final ICssDataTypeValidator validator1 = new CssIntegerNumberValueValidator(false, true); - Assert.assertFalse(validator1.isValid("normal")); + Assertions.assertFalse(validator1.isValid("normal")); final ICssDataTypeValidator validator2 = new CssIntegerNumberValueValidator(true, false); - Assert.assertFalse(validator2.isValid("normal")); + Assertions.assertFalse(validator2.isValid("normal")); } @Test public void invalidValuesTest() { final ICssDataTypeValidator validator1 = new CssIntegerNumberValueValidator(false, true); - Assert.assertFalse(validator1.isValid("")); - Assert.assertFalse(validator1.isValid("dja")); - Assert.assertFalse(validator1.isValid("5pixels")); + Assertions.assertFalse(validator1.isValid("")); + Assertions.assertFalse(validator1.isValid("dja")); + Assertions.assertFalse(validator1.isValid("5pixels")); final ICssDataTypeValidator validator2 = new CssIntegerNumberValueValidator(true, false); - Assert.assertFalse(validator2.isValid("")); - Assert.assertFalse(validator2.isValid("dja")); - Assert.assertFalse(validator2.isValid("5pixels")); + Assertions.assertFalse(validator2.isValid("")); + Assertions.assertFalse(validator2.isValid("dja")); + Assertions.assertFalse(validator2.isValid("5pixels")); } @Test public void absoluteValuesTest() { final ICssDataTypeValidator validator1 = new CssIntegerNumberValueValidator(false, true); - Assert.assertTrue(validator1.isValid("12")); - Assert.assertFalse(validator1.isValid("12pt")); - Assert.assertFalse(validator1.isValid("-12pt")); - Assert.assertFalse(validator1.isValid("12px")); - Assert.assertFalse(validator1.isValid("12in")); - Assert.assertFalse(validator1.isValid("12cm")); - Assert.assertFalse(validator1.isValid("12mm")); - Assert.assertFalse(validator1.isValid("12pc")); - Assert.assertFalse(validator1.isValid("12q")); - Assert.assertFalse(validator1.isValid("12 pt")); + Assertions.assertTrue(validator1.isValid("12")); + Assertions.assertFalse(validator1.isValid("12pt")); + Assertions.assertFalse(validator1.isValid("-12pt")); + Assertions.assertFalse(validator1.isValid("12px")); + Assertions.assertFalse(validator1.isValid("12in")); + Assertions.assertFalse(validator1.isValid("12cm")); + Assertions.assertFalse(validator1.isValid("12mm")); + Assertions.assertFalse(validator1.isValid("12pc")); + Assertions.assertFalse(validator1.isValid("12q")); + Assertions.assertFalse(validator1.isValid("12 pt")); final ICssDataTypeValidator validator2 = new CssIntegerNumberValueValidator(true, false); - Assert.assertTrue(validator2.isValid("12")); - Assert.assertFalse(validator2.isValid("12pt")); - Assert.assertFalse(validator2.isValid("-12pt")); - Assert.assertFalse(validator2.isValid("12px")); - Assert.assertFalse(validator2.isValid("12in")); - Assert.assertFalse(validator2.isValid("12cm")); - Assert.assertFalse(validator2.isValid("12mm")); - Assert.assertFalse(validator2.isValid("12pc")); - Assert.assertFalse(validator2.isValid("12q")); - Assert.assertFalse(validator2.isValid("12 pt")); + Assertions.assertTrue(validator2.isValid("12")); + Assertions.assertFalse(validator2.isValid("12pt")); + Assertions.assertFalse(validator2.isValid("-12pt")); + Assertions.assertFalse(validator2.isValid("12px")); + Assertions.assertFalse(validator2.isValid("12in")); + Assertions.assertFalse(validator2.isValid("12cm")); + Assertions.assertFalse(validator2.isValid("12mm")); + Assertions.assertFalse(validator2.isValid("12pc")); + Assertions.assertFalse(validator2.isValid("12q")); + Assertions.assertFalse(validator2.isValid("12 pt")); final ICssDataTypeValidator validator3 = new CssIntegerNumberValueValidator(true, true); - Assert.assertTrue(validator3.isValid("12")); - Assert.assertFalse(validator3.isValid("12pt")); - Assert.assertFalse(validator3.isValid("-12pt")); - Assert.assertFalse(validator3.isValid("12px")); - Assert.assertFalse(validator3.isValid("12in")); - Assert.assertFalse(validator3.isValid("12cm")); - Assert.assertFalse(validator3.isValid("12mm")); - Assert.assertFalse(validator3.isValid("12pc")); - Assert.assertFalse(validator3.isValid("12q")); - Assert.assertFalse(validator3.isValid("12 pt")); + Assertions.assertTrue(validator3.isValid("12")); + Assertions.assertFalse(validator3.isValid("12pt")); + Assertions.assertFalse(validator3.isValid("-12pt")); + Assertions.assertFalse(validator3.isValid("12px")); + Assertions.assertFalse(validator3.isValid("12in")); + Assertions.assertFalse(validator3.isValid("12cm")); + Assertions.assertFalse(validator3.isValid("12mm")); + Assertions.assertFalse(validator3.isValid("12pc")); + Assertions.assertFalse(validator3.isValid("12q")); + Assertions.assertFalse(validator3.isValid("12 pt")); } @Test public void relativeValuesTest() { final ICssDataTypeValidator validator1 = new CssIntegerNumberValueValidator(false, true); - Assert.assertFalse(validator1.isValid("12em")); - Assert.assertFalse(validator1.isValid("-12em")); - Assert.assertFalse(validator1.isValid("12rem")); - Assert.assertFalse(validator1.isValid("12ex")); - Assert.assertFalse(validator1.isValid("12 em")); + Assertions.assertFalse(validator1.isValid("12em")); + Assertions.assertFalse(validator1.isValid("-12em")); + Assertions.assertFalse(validator1.isValid("12rem")); + Assertions.assertFalse(validator1.isValid("12ex")); + Assertions.assertFalse(validator1.isValid("12 em")); final ICssDataTypeValidator validator2 = new CssIntegerNumberValueValidator(true, false); - Assert.assertFalse(validator2.isValid("12em")); - Assert.assertFalse(validator2.isValid("-12em")); - Assert.assertFalse(validator2.isValid("12rem")); - Assert.assertFalse(validator2.isValid("12ex")); - Assert.assertFalse(validator2.isValid("12 em")); + Assertions.assertFalse(validator2.isValid("12em")); + Assertions.assertFalse(validator2.isValid("-12em")); + Assertions.assertFalse(validator2.isValid("12rem")); + Assertions.assertFalse(validator2.isValid("12ex")); + Assertions.assertFalse(validator2.isValid("12 em")); } @Test public void percentValueTest() { final ICssDataTypeValidator validator1 = new CssIntegerNumberValueValidator(false, true); - Assert.assertFalse(validator1.isValid("12%")); - Assert.assertFalse(validator1.isValid("-12%")); + Assertions.assertFalse(validator1.isValid("12%")); + Assertions.assertFalse(validator1.isValid("-12%")); final ICssDataTypeValidator validator2 = new CssIntegerNumberValueValidator(true, false); - Assert.assertFalse(validator2.isValid("12%")); - Assert.assertFalse(validator2.isValid("-12%")); + Assertions.assertFalse(validator2.isValid("12%")); + Assertions.assertFalse(validator2.isValid("-12%")); } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/validate/CssLengthValueValidatorTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/validate/CssLengthValueValidatorTest.java index 03121f4177..97d3edb4a0 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/validate/CssLengthValueValidatorTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/validate/CssLengthValueValidatorTest.java @@ -24,125 +24,124 @@ This file is part of the iText (R) project. import com.itextpdf.styledxmlparser.css.validate.impl.datatype.CssLengthValueValidator; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class CssLengthValueValidatorTest extends ExtendedITextTest { @Test public void zeroValueTest() { final ICssDataTypeValidator validator1 = new CssLengthValueValidator(false); - Assert.assertTrue(validator1.isValid("0")); - Assert.assertTrue(validator1.isValid("0px")); - Assert.assertTrue(validator1.isValid("-0px")); + Assertions.assertTrue(validator1.isValid("0")); + Assertions.assertTrue(validator1.isValid("0px")); + Assertions.assertTrue(validator1.isValid("-0px")); final ICssDataTypeValidator validator2 = new CssLengthValueValidator(true); - Assert.assertTrue(validator2.isValid("0")); - Assert.assertTrue(validator2.isValid("0px")); - Assert.assertTrue(validator2.isValid("-0")); + Assertions.assertTrue(validator2.isValid("0")); + Assertions.assertTrue(validator2.isValid("0px")); + Assertions.assertTrue(validator2.isValid("-0")); } @Test public void nullValueTest() { final ICssDataTypeValidator validator1 = new CssLengthValueValidator(false); - Assert.assertFalse(validator1.isValid(null)); + Assertions.assertFalse(validator1.isValid(null)); final ICssDataTypeValidator validator2 = new CssLengthValueValidator(true); - Assert.assertFalse(validator2.isValid(null)); + Assertions.assertFalse(validator2.isValid(null)); } @Test public void initialInheritUnsetValuesTest() { final ICssDataTypeValidator validator1 = new CssLengthValueValidator(false); - Assert.assertTrue(validator1.isValid("initial")); - Assert.assertTrue(validator1.isValid("inherit")); - Assert.assertTrue(validator1.isValid("unset")); + Assertions.assertTrue(validator1.isValid("initial")); + Assertions.assertTrue(validator1.isValid("inherit")); + Assertions.assertTrue(validator1.isValid("unset")); final ICssDataTypeValidator validator2 = new CssLengthValueValidator(true); - Assert.assertTrue(validator2.isValid("initial")); - Assert.assertTrue(validator2.isValid("inherit")); - Assert.assertTrue(validator2.isValid("unset")); + Assertions.assertTrue(validator2.isValid("initial")); + Assertions.assertTrue(validator2.isValid("inherit")); + Assertions.assertTrue(validator2.isValid("unset")); } @Test public void normalValueTest() { final ICssDataTypeValidator validator1 = new CssLengthValueValidator(false); - Assert.assertFalse(validator1.isValid("normal")); + Assertions.assertFalse(validator1.isValid("normal")); final ICssDataTypeValidator validator2 = new CssLengthValueValidator(true); - Assert.assertFalse(validator2.isValid("normal")); + Assertions.assertFalse(validator2.isValid("normal")); } @Test public void invalidValuesTest() { final ICssDataTypeValidator validator1 = new CssLengthValueValidator(false); - Assert.assertFalse(validator1.isValid("")); - Assert.assertFalse(validator1.isValid("dja")); - Assert.assertFalse(validator1.isValid("5pixels")); + Assertions.assertFalse(validator1.isValid("")); + Assertions.assertFalse(validator1.isValid("dja")); + Assertions.assertFalse(validator1.isValid("5pixels")); final ICssDataTypeValidator validator2 = new CssLengthValueValidator(true); - Assert.assertFalse(validator2.isValid("")); - Assert.assertFalse(validator2.isValid("dja")); - Assert.assertFalse(validator2.isValid("5pixels")); + Assertions.assertFalse(validator2.isValid("")); + Assertions.assertFalse(validator2.isValid("dja")); + Assertions.assertFalse(validator2.isValid("5pixels")); } @Test public void absoluteValuesTest() { final ICssDataTypeValidator validator1 = new CssLengthValueValidator(false); - Assert.assertFalse(validator1.isValid("12")); - Assert.assertTrue(validator1.isValid("12pt")); - Assert.assertFalse(validator1.isValid("-12pt")); - Assert.assertTrue(validator1.isValid("12px")); - Assert.assertTrue(validator1.isValid("12in")); - Assert.assertTrue(validator1.isValid("12cm")); - Assert.assertTrue(validator1.isValid("12mm")); - Assert.assertTrue(validator1.isValid("12pc")); - Assert.assertTrue(validator1.isValid("12q")); - Assert.assertFalse(validator1.isValid("12 pt")); + Assertions.assertFalse(validator1.isValid("12")); + Assertions.assertTrue(validator1.isValid("12pt")); + Assertions.assertFalse(validator1.isValid("-12pt")); + Assertions.assertTrue(validator1.isValid("12px")); + Assertions.assertTrue(validator1.isValid("12in")); + Assertions.assertTrue(validator1.isValid("12cm")); + Assertions.assertTrue(validator1.isValid("12mm")); + Assertions.assertTrue(validator1.isValid("12pc")); + Assertions.assertTrue(validator1.isValid("12q")); + Assertions.assertFalse(validator1.isValid("12 pt")); final ICssDataTypeValidator validator2 = new CssLengthValueValidator(true); - Assert.assertFalse(validator2.isValid("12")); - Assert.assertTrue(validator2.isValid("12pt")); - Assert.assertTrue(validator2.isValid("-12pt")); - Assert.assertTrue(validator2.isValid("12px")); - Assert.assertTrue(validator2.isValid("12in")); - Assert.assertTrue(validator2.isValid("12cm")); - Assert.assertTrue(validator2.isValid("12mm")); - Assert.assertTrue(validator2.isValid("12pc")); - Assert.assertTrue(validator2.isValid("12q")); - Assert.assertFalse(validator2.isValid("12 pt")); + Assertions.assertFalse(validator2.isValid("12")); + Assertions.assertTrue(validator2.isValid("12pt")); + Assertions.assertTrue(validator2.isValid("-12pt")); + Assertions.assertTrue(validator2.isValid("12px")); + Assertions.assertTrue(validator2.isValid("12in")); + Assertions.assertTrue(validator2.isValid("12cm")); + Assertions.assertTrue(validator2.isValid("12mm")); + Assertions.assertTrue(validator2.isValid("12pc")); + Assertions.assertTrue(validator2.isValid("12q")); + Assertions.assertFalse(validator2.isValid("12 pt")); } @Test public void relativeValuesTest() { final ICssDataTypeValidator validator1 = new CssLengthValueValidator(false); - Assert.assertTrue(validator1.isValid("12em")); - Assert.assertFalse(validator1.isValid("-12em")); - Assert.assertTrue(validator1.isValid("12rem")); - Assert.assertTrue(validator1.isValid("12ex")); - Assert.assertFalse(validator1.isValid("12 em")); + Assertions.assertTrue(validator1.isValid("12em")); + Assertions.assertFalse(validator1.isValid("-12em")); + Assertions.assertTrue(validator1.isValid("12rem")); + Assertions.assertTrue(validator1.isValid("12ex")); + Assertions.assertFalse(validator1.isValid("12 em")); final ICssDataTypeValidator validator2 = new CssLengthValueValidator(true); - Assert.assertTrue(validator2.isValid("12em")); - Assert.assertTrue(validator2.isValid("-12em")); - Assert.assertTrue(validator2.isValid("12rem")); - Assert.assertTrue(validator2.isValid("12ex")); - Assert.assertFalse(validator2.isValid("12 em")); + Assertions.assertTrue(validator2.isValid("12em")); + Assertions.assertTrue(validator2.isValid("-12em")); + Assertions.assertTrue(validator2.isValid("12rem")); + Assertions.assertTrue(validator2.isValid("12ex")); + Assertions.assertFalse(validator2.isValid("12 em")); } @Test public void percentValueTest() { final ICssDataTypeValidator validator1 = new CssLengthValueValidator(false); - Assert.assertFalse(validator1.isValid("12%")); - Assert.assertFalse(validator1.isValid("-12%")); + Assertions.assertFalse(validator1.isValid("12%")); + Assertions.assertFalse(validator1.isValid("-12%")); final ICssDataTypeValidator validator2 = new CssLengthValueValidator(true); - Assert.assertFalse(validator2.isValid("12%")); - Assert.assertFalse(validator2.isValid("-12%")); + Assertions.assertFalse(validator2.isValid("12%")); + Assertions.assertFalse(validator2.isValid("-12%")); } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/validate/CssNumberValueValidatorTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/validate/CssNumberValueValidatorTest.java index 35ef5ec738..b88872550e 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/validate/CssNumberValueValidatorTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/validate/CssNumberValueValidatorTest.java @@ -24,121 +24,120 @@ This file is part of the iText (R) project. import com.itextpdf.styledxmlparser.css.validate.impl.datatype.CssNumberValueValidator; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class CssNumberValueValidatorTest extends ExtendedITextTest { @Test public void zeroValueTest() { final ICssDataTypeValidator validator1 = new CssNumberValueValidator(false); - Assert.assertTrue(validator1.isValid("0")); + Assertions.assertTrue(validator1.isValid("0")); final ICssDataTypeValidator validator2 = new CssNumberValueValidator(true); - Assert.assertTrue(validator2.isValid("0")); + Assertions.assertTrue(validator2.isValid("0")); } @Test public void nullValueTest() { final ICssDataTypeValidator validator1 = new CssNumberValueValidator(false); - Assert.assertFalse(validator1.isValid(null)); + Assertions.assertFalse(validator1.isValid(null)); final ICssDataTypeValidator validator2 = new CssNumberValueValidator(true); - Assert.assertFalse(validator2.isValid(null)); + Assertions.assertFalse(validator2.isValid(null)); } @Test public void initialInheritUnsetValuesTest() { final ICssDataTypeValidator validator1 = new CssNumberValueValidator(false); - Assert.assertTrue(validator1.isValid("initial")); - Assert.assertTrue(validator1.isValid("inherit")); - Assert.assertTrue(validator1.isValid("unset")); + Assertions.assertTrue(validator1.isValid("initial")); + Assertions.assertTrue(validator1.isValid("inherit")); + Assertions.assertTrue(validator1.isValid("unset")); final ICssDataTypeValidator validator2 = new CssNumberValueValidator(true); - Assert.assertTrue(validator2.isValid("initial")); - Assert.assertTrue(validator2.isValid("inherit")); - Assert.assertTrue(validator2.isValid("unset")); + Assertions.assertTrue(validator2.isValid("initial")); + Assertions.assertTrue(validator2.isValid("inherit")); + Assertions.assertTrue(validator2.isValid("unset")); } @Test public void normalValueTest() { final ICssDataTypeValidator validator1 = new CssNumberValueValidator(false); - Assert.assertFalse(validator1.isValid("normal")); + Assertions.assertFalse(validator1.isValid("normal")); final ICssDataTypeValidator validator2 = new CssNumberValueValidator(true); - Assert.assertFalse(validator2.isValid("normal")); + Assertions.assertFalse(validator2.isValid("normal")); } @Test public void invalidValuesTest() { final ICssDataTypeValidator validator1 = new CssNumberValueValidator(false); - Assert.assertFalse(validator1.isValid("")); - Assert.assertFalse(validator1.isValid("dja")); - Assert.assertFalse(validator1.isValid("5pixels")); + Assertions.assertFalse(validator1.isValid("")); + Assertions.assertFalse(validator1.isValid("dja")); + Assertions.assertFalse(validator1.isValid("5pixels")); final ICssDataTypeValidator validator2 = new CssNumberValueValidator(true); - Assert.assertFalse(validator2.isValid("")); - Assert.assertFalse(validator2.isValid("dja")); - Assert.assertFalse(validator2.isValid("5pixels")); + Assertions.assertFalse(validator2.isValid("")); + Assertions.assertFalse(validator2.isValid("dja")); + Assertions.assertFalse(validator2.isValid("5pixels")); } @Test public void absoluteValuesTest() { final ICssDataTypeValidator validator1 = new CssNumberValueValidator(false); - Assert.assertTrue(validator1.isValid("12")); - Assert.assertFalse(validator1.isValid("12pt")); - Assert.assertFalse(validator1.isValid("-12pt")); - Assert.assertFalse(validator1.isValid("12px")); - Assert.assertFalse(validator1.isValid("12in")); - Assert.assertFalse(validator1.isValid("12cm")); - Assert.assertFalse(validator1.isValid("12mm")); - Assert.assertFalse(validator1.isValid("12pc")); - Assert.assertFalse(validator1.isValid("12q")); - Assert.assertFalse(validator1.isValid("12 pt")); + Assertions.assertTrue(validator1.isValid("12")); + Assertions.assertFalse(validator1.isValid("12pt")); + Assertions.assertFalse(validator1.isValid("-12pt")); + Assertions.assertFalse(validator1.isValid("12px")); + Assertions.assertFalse(validator1.isValid("12in")); + Assertions.assertFalse(validator1.isValid("12cm")); + Assertions.assertFalse(validator1.isValid("12mm")); + Assertions.assertFalse(validator1.isValid("12pc")); + Assertions.assertFalse(validator1.isValid("12q")); + Assertions.assertFalse(validator1.isValid("12 pt")); final ICssDataTypeValidator validator2 = new CssNumberValueValidator(true); - Assert.assertTrue(validator2.isValid("12")); - Assert.assertFalse(validator2.isValid("12pt")); - Assert.assertFalse(validator2.isValid("-12pt")); - Assert.assertFalse(validator2.isValid("12px")); - Assert.assertFalse(validator2.isValid("12in")); - Assert.assertFalse(validator2.isValid("12cm")); - Assert.assertFalse(validator2.isValid("12mm")); - Assert.assertFalse(validator2.isValid("12pc")); - Assert.assertFalse(validator2.isValid("12q")); - Assert.assertFalse(validator2.isValid("12 pt")); + Assertions.assertTrue(validator2.isValid("12")); + Assertions.assertFalse(validator2.isValid("12pt")); + Assertions.assertFalse(validator2.isValid("-12pt")); + Assertions.assertFalse(validator2.isValid("12px")); + Assertions.assertFalse(validator2.isValid("12in")); + Assertions.assertFalse(validator2.isValid("12cm")); + Assertions.assertFalse(validator2.isValid("12mm")); + Assertions.assertFalse(validator2.isValid("12pc")); + Assertions.assertFalse(validator2.isValid("12q")); + Assertions.assertFalse(validator2.isValid("12 pt")); } @Test public void relativeValuesTest() { final ICssDataTypeValidator validator1 = new CssNumberValueValidator(false); - Assert.assertFalse(validator1.isValid("12em")); - Assert.assertFalse(validator1.isValid("-12em")); - Assert.assertFalse(validator1.isValid("12rem")); - Assert.assertFalse(validator1.isValid("12ex")); - Assert.assertFalse(validator1.isValid("12 em")); + Assertions.assertFalse(validator1.isValid("12em")); + Assertions.assertFalse(validator1.isValid("-12em")); + Assertions.assertFalse(validator1.isValid("12rem")); + Assertions.assertFalse(validator1.isValid("12ex")); + Assertions.assertFalse(validator1.isValid("12 em")); final ICssDataTypeValidator validator2 = new CssNumberValueValidator(true); - Assert.assertFalse(validator2.isValid("12em")); - Assert.assertFalse(validator2.isValid("-12em")); - Assert.assertFalse(validator2.isValid("12rem")); - Assert.assertFalse(validator2.isValid("12ex")); - Assert.assertFalse(validator2.isValid("12 em")); + Assertions.assertFalse(validator2.isValid("12em")); + Assertions.assertFalse(validator2.isValid("-12em")); + Assertions.assertFalse(validator2.isValid("12rem")); + Assertions.assertFalse(validator2.isValid("12ex")); + Assertions.assertFalse(validator2.isValid("12 em")); } @Test public void percentValueTest() { final ICssDataTypeValidator validator1 = new CssNumberValueValidator(false); - Assert.assertFalse(validator1.isValid("12%")); - Assert.assertFalse(validator1.isValid("-12%")); + Assertions.assertFalse(validator1.isValid("12%")); + Assertions.assertFalse(validator1.isValid("-12%")); final ICssDataTypeValidator validator2 = new CssNumberValueValidator(true); - Assert.assertFalse(validator2.isValid("12%")); - Assert.assertFalse(validator2.isValid("-12%")); + Assertions.assertFalse(validator2.isValid("12%")); + Assertions.assertFalse(validator2.isValid("-12%")); } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/validate/CssPercentageValueValidatorTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/validate/CssPercentageValueValidatorTest.java index c2955609b2..c2ec9232df 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/validate/CssPercentageValueValidatorTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/validate/CssPercentageValueValidatorTest.java @@ -24,121 +24,120 @@ This file is part of the iText (R) project. import com.itextpdf.styledxmlparser.css.validate.impl.datatype.CssPercentageValueValidator; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class CssPercentageValueValidatorTest extends ExtendedITextTest { @Test public void zeroValueTest() { final ICssDataTypeValidator validator1 = new CssPercentageValueValidator(false); - Assert.assertFalse(validator1.isValid("0")); + Assertions.assertFalse(validator1.isValid("0")); final ICssDataTypeValidator validator2 = new CssPercentageValueValidator(true); - Assert.assertFalse(validator2.isValid("0")); + Assertions.assertFalse(validator2.isValid("0")); } @Test public void nullValueTest() { final ICssDataTypeValidator validator1 = new CssPercentageValueValidator(false); - Assert.assertFalse(validator1.isValid(null)); + Assertions.assertFalse(validator1.isValid(null)); final ICssDataTypeValidator validator2 = new CssPercentageValueValidator(true); - Assert.assertFalse(validator2.isValid(null)); + Assertions.assertFalse(validator2.isValid(null)); } @Test public void initialInheritUnsetValuesTest() { final ICssDataTypeValidator validator1 = new CssPercentageValueValidator(false); - Assert.assertTrue(validator1.isValid("initial")); - Assert.assertTrue(validator1.isValid("inherit")); - Assert.assertTrue(validator1.isValid("unset")); + Assertions.assertTrue(validator1.isValid("initial")); + Assertions.assertTrue(validator1.isValid("inherit")); + Assertions.assertTrue(validator1.isValid("unset")); final ICssDataTypeValidator validator2 = new CssPercentageValueValidator(true); - Assert.assertTrue(validator2.isValid("initial")); - Assert.assertTrue(validator2.isValid("inherit")); - Assert.assertTrue(validator2.isValid("unset")); + Assertions.assertTrue(validator2.isValid("initial")); + Assertions.assertTrue(validator2.isValid("inherit")); + Assertions.assertTrue(validator2.isValid("unset")); } @Test public void normalValueTest() { final ICssDataTypeValidator validator1 = new CssPercentageValueValidator(false); - Assert.assertFalse(validator1.isValid("normal")); + Assertions.assertFalse(validator1.isValid("normal")); final ICssDataTypeValidator validator2 = new CssPercentageValueValidator(true); - Assert.assertFalse(validator2.isValid("normal")); + Assertions.assertFalse(validator2.isValid("normal")); } @Test public void invalidValuesTest() { final ICssDataTypeValidator validator1 = new CssPercentageValueValidator(false); - Assert.assertFalse(validator1.isValid("")); - Assert.assertFalse(validator1.isValid("dja")); - Assert.assertFalse(validator1.isValid("5pixels")); + Assertions.assertFalse(validator1.isValid("")); + Assertions.assertFalse(validator1.isValid("dja")); + Assertions.assertFalse(validator1.isValid("5pixels")); final ICssDataTypeValidator validator2 = new CssPercentageValueValidator(true); - Assert.assertFalse(validator2.isValid("")); - Assert.assertFalse(validator2.isValid("dja")); - Assert.assertFalse(validator2.isValid("5pixels")); + Assertions.assertFalse(validator2.isValid("")); + Assertions.assertFalse(validator2.isValid("dja")); + Assertions.assertFalse(validator2.isValid("5pixels")); } @Test public void absoluteValuesTest() { final ICssDataTypeValidator validator1 = new CssPercentageValueValidator(false); - Assert.assertFalse(validator1.isValid("12")); - Assert.assertFalse(validator1.isValid("12pt")); - Assert.assertFalse(validator1.isValid("-12pt")); - Assert.assertFalse(validator1.isValid("12px")); - Assert.assertFalse(validator1.isValid("12in")); - Assert.assertFalse(validator1.isValid("12cm")); - Assert.assertFalse(validator1.isValid("12mm")); - Assert.assertFalse(validator1.isValid("12pc")); - Assert.assertFalse(validator1.isValid("12q")); - Assert.assertFalse(validator1.isValid("12 pt")); + Assertions.assertFalse(validator1.isValid("12")); + Assertions.assertFalse(validator1.isValid("12pt")); + Assertions.assertFalse(validator1.isValid("-12pt")); + Assertions.assertFalse(validator1.isValid("12px")); + Assertions.assertFalse(validator1.isValid("12in")); + Assertions.assertFalse(validator1.isValid("12cm")); + Assertions.assertFalse(validator1.isValid("12mm")); + Assertions.assertFalse(validator1.isValid("12pc")); + Assertions.assertFalse(validator1.isValid("12q")); + Assertions.assertFalse(validator1.isValid("12 pt")); final ICssDataTypeValidator validator2 = new CssPercentageValueValidator(true); - Assert.assertFalse(validator2.isValid("12")); - Assert.assertFalse(validator2.isValid("12pt")); - Assert.assertFalse(validator2.isValid("-12pt")); - Assert.assertFalse(validator2.isValid("12px")); - Assert.assertFalse(validator2.isValid("12in")); - Assert.assertFalse(validator2.isValid("12cm")); - Assert.assertFalse(validator2.isValid("12mm")); - Assert.assertFalse(validator2.isValid("12pc")); - Assert.assertFalse(validator2.isValid("12q")); - Assert.assertFalse(validator2.isValid("12 pt")); + Assertions.assertFalse(validator2.isValid("12")); + Assertions.assertFalse(validator2.isValid("12pt")); + Assertions.assertFalse(validator2.isValid("-12pt")); + Assertions.assertFalse(validator2.isValid("12px")); + Assertions.assertFalse(validator2.isValid("12in")); + Assertions.assertFalse(validator2.isValid("12cm")); + Assertions.assertFalse(validator2.isValid("12mm")); + Assertions.assertFalse(validator2.isValid("12pc")); + Assertions.assertFalse(validator2.isValid("12q")); + Assertions.assertFalse(validator2.isValid("12 pt")); } @Test public void relativeValuesTest() { final ICssDataTypeValidator validator1 = new CssPercentageValueValidator(false); - Assert.assertFalse(validator1.isValid("12em")); - Assert.assertFalse(validator1.isValid("-12em")); - Assert.assertFalse(validator1.isValid("12rem")); - Assert.assertFalse(validator1.isValid("12ex")); - Assert.assertFalse(validator1.isValid("12 em")); + Assertions.assertFalse(validator1.isValid("12em")); + Assertions.assertFalse(validator1.isValid("-12em")); + Assertions.assertFalse(validator1.isValid("12rem")); + Assertions.assertFalse(validator1.isValid("12ex")); + Assertions.assertFalse(validator1.isValid("12 em")); final ICssDataTypeValidator validator2 = new CssPercentageValueValidator(true); - Assert.assertFalse(validator2.isValid("12em")); - Assert.assertFalse(validator2.isValid("-12em")); - Assert.assertFalse(validator2.isValid("12rem")); - Assert.assertFalse(validator2.isValid("12ex")); - Assert.assertFalse(validator2.isValid("12 em")); + Assertions.assertFalse(validator2.isValid("12em")); + Assertions.assertFalse(validator2.isValid("-12em")); + Assertions.assertFalse(validator2.isValid("12rem")); + Assertions.assertFalse(validator2.isValid("12ex")); + Assertions.assertFalse(validator2.isValid("12 em")); } @Test public void percentValueTest() { final ICssDataTypeValidator validator1 = new CssPercentageValueValidator(false); - Assert.assertTrue(validator1.isValid("12%")); - Assert.assertFalse(validator1.isValid("-12%")); + Assertions.assertTrue(validator1.isValid("12%")); + Assertions.assertFalse(validator1.isValid("-12%")); final ICssDataTypeValidator validator2 = new CssPercentageValueValidator(true); - Assert.assertTrue(validator2.isValid("12%")); - Assert.assertTrue(validator2.isValid("-12%")); + Assertions.assertTrue(validator2.isValid("12%")); + Assertions.assertTrue(validator2.isValid("-12%")); } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/JsoupXmlParserTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/JsoupXmlParserTest.java index 8eb80c6573..344425e455 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/JsoupXmlParserTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/JsoupXmlParserTest.java @@ -32,16 +32,14 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; -@Category(UnitTest.class) +@org.junit.jupiter.api.Tag("UnitTest") public class JsoupXmlParserTest extends ExtendedITextTest { @Test public void testXmlDeclarationAndComment() throws IOException { @@ -50,7 +48,7 @@ public void testXmlDeclarationAndComment() throws IOException { InputStream stream = new ByteArrayInputStream(xml.getBytes()); IDocumentNode node = new JsoupXmlParser().parse(stream, "UTF-8"); // only text (whitespace) child node shall be fetched. - Assert.assertEquals(1, node.childNodes().size()); + Assertions.assertEquals(1, node.childNodes().size()); } @Test @@ -61,6 +59,6 @@ public void testMessageAddingChild() { Element jsoupSVGRoot = new Element(Tag.valueOf("svg"), ""); INode root = new JsoupElementNode(jsoupSVGRoot); root.addChild(null); - Assert.assertEquals(0, root.childNodes().size()); + Assertions.assertEquals(0, root.childNodes().size()); } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/PortUtilTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/PortUtilTest.java index 6cb605fe57..66188b30d2 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/PortUtilTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/PortUtilTest.java @@ -23,18 +23,17 @@ This file is part of the iText (R) project. package com.itextpdf.styledxmlparser.jsoup; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PortUtilTest extends ExtendedITextTest { @Test public void trimControlCodesTest() { for (int i = 0; i < ' ' + 1; ++i) { String str = new String(new char[]{(char) i}); - Assert.assertTrue(PortUtil.trimControlCodes(str).isEmpty()); + Assertions.assertTrue(PortUtil.trimControlCodes(str).isEmpty()); } } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/helper/DataUtilTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/helper/DataUtilTest.java index c380486563..a33fe62aa2 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/helper/DataUtilTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/helper/DataUtilTest.java @@ -27,10 +27,9 @@ This file is part of the iText (R) project. import com.itextpdf.styledxmlparser.jsoup.nodes.Document; import com.itextpdf.styledxmlparser.jsoup.parser.Parser; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.ByteArrayInputStream; import java.io.File; @@ -39,25 +38,25 @@ This file is part of the iText (R) project. import java.io.UnsupportedEncodingException; import java.nio.charset.StandardCharsets; -@Category(UnitTest.class) +@Tag("UnitTest") public class DataUtilTest extends ExtendedITextTest { @Test public void testCharset() { - Assert.assertEquals("utf-8", DataUtil.getCharsetFromContentType("text/html;charset=utf-8 ")); - Assert.assertEquals("UTF-8", DataUtil.getCharsetFromContentType("text/html; charset=UTF-8")); - Assert.assertEquals("ISO-8859-1", DataUtil.getCharsetFromContentType("text/html; charset=ISO-8859-1")); - Assert.assertNull(DataUtil.getCharsetFromContentType("text/html")); - Assert.assertNull(DataUtil.getCharsetFromContentType(null)); - Assert.assertNull(DataUtil.getCharsetFromContentType("text/html;charset=Unknown")); + Assertions.assertEquals("utf-8", DataUtil.getCharsetFromContentType("text/html;charset=utf-8 ")); + Assertions.assertEquals("UTF-8", DataUtil.getCharsetFromContentType("text/html; charset=UTF-8")); + Assertions.assertEquals("ISO-8859-1", DataUtil.getCharsetFromContentType("text/html; charset=ISO-8859-1")); + Assertions.assertNull(DataUtil.getCharsetFromContentType("text/html")); + Assertions.assertNull(DataUtil.getCharsetFromContentType(null)); + Assertions.assertNull(DataUtil.getCharsetFromContentType("text/html;charset=Unknown")); } @Test public void testQuotedCharset() { - Assert.assertEquals("utf-8", DataUtil.getCharsetFromContentType("text/html; charset=\"utf-8\"")); - Assert.assertEquals("UTF-8", DataUtil.getCharsetFromContentType("text/html;charset=\"UTF-8\"")); - Assert.assertEquals("ISO-8859-1", DataUtil.getCharsetFromContentType("text/html; charset=\"ISO-8859-1\"")); - Assert.assertNull(DataUtil.getCharsetFromContentType("text/html; charset=\"Unsupported\"")); - Assert.assertEquals("UTF-8", DataUtil.getCharsetFromContentType("text/html; charset='UTF-8'")); + Assertions.assertEquals("utf-8", DataUtil.getCharsetFromContentType("text/html; charset=\"utf-8\"")); + Assertions.assertEquals("UTF-8", DataUtil.getCharsetFromContentType("text/html;charset=\"UTF-8\"")); + Assertions.assertEquals("ISO-8859-1", DataUtil.getCharsetFromContentType("text/html; charset=\"ISO-8859-1\"")); + Assertions.assertNull(DataUtil.getCharsetFromContentType("text/html; charset=\"Unsupported\"")); + Assertions.assertEquals("UTF-8", DataUtil.getCharsetFromContentType("text/html; charset='UTF-8'")); } private InputStream stream(String data) { @@ -68,7 +67,7 @@ private InputStream stream(String data, String charset) { try { return new ByteArrayInputStream(data.getBytes(charset)); } catch (UnsupportedEncodingException e) { - Assert.fail(); + Assertions.fail(); } return null; } @@ -77,36 +76,36 @@ private InputStream stream(String data, String charset) { public void discardsSpuriousByteOrderMark() throws IOException { String html = "\uFEFFOneTwo"; Document doc = DataUtil.parseInputStream(stream(html), "UTF-8", "http://foo.com/", Parser.htmlParser()); - Assert.assertEquals("One", doc.head().text()); + Assertions.assertEquals("One", doc.head().text()); } @Test public void discardsSpuriousByteOrderMarkWhenNoCharsetSet() throws IOException { String html = "\uFEFFOneTwo"; Document doc = DataUtil.parseInputStream(stream(html), null, "http://foo.com/", Parser.htmlParser()); - Assert.assertEquals("One", doc.head().text()); - Assert.assertEquals("UTF-8", doc.outputSettings().charset().displayName()); + Assertions.assertEquals("One", doc.head().text()); + Assertions.assertEquals("UTF-8", doc.outputSettings().charset().displayName()); } @Test public void shouldNotThrowExceptionOnEmptyCharset() { - Assert.assertNull(DataUtil.getCharsetFromContentType("text/html; charset=")); - Assert.assertNull(DataUtil.getCharsetFromContentType("text/html; charset=;")); + Assertions.assertNull(DataUtil.getCharsetFromContentType("text/html; charset=")); + Assertions.assertNull(DataUtil.getCharsetFromContentType("text/html; charset=;")); } @Test public void shouldSelectFirstCharsetOnWeirdMultileCharsetsInMetaTags() { - Assert.assertEquals("ISO-8859-1", DataUtil.getCharsetFromContentType("text/html; charset=ISO-8859-1, charset=1251")); + Assertions.assertEquals("ISO-8859-1", DataUtil.getCharsetFromContentType("text/html; charset=ISO-8859-1, charset=1251")); } @Test public void shouldCorrectCharsetForDuplicateCharsetString() { - Assert.assertEquals("iso-8859-1", DataUtil.getCharsetFromContentType("text/html; charset=charset=iso-8859-1")); + Assertions.assertEquals("iso-8859-1", DataUtil.getCharsetFromContentType("text/html; charset=charset=iso-8859-1")); } @Test public void shouldReturnNullForIllegalCharsetNames() { - Assert.assertNull(DataUtil.getCharsetFromContentType("text/html; charset=$HJKDF§$/(")); + Assertions.assertNull(DataUtil.getCharsetFromContentType("text/html; charset=$HJKDF§$/(")); } @Test @@ -122,7 +121,7 @@ public void wrongMetaCharsetFallback() throws IOException { " \n" + ""; - Assert.assertEquals(expected, doc.toString()); + Assertions.assertEquals(expected, doc.toString()); } @Test @@ -134,7 +133,7 @@ public void secondMetaElementWithContentTypeContainsCharsetParameter() throws Ex Document doc = DataUtil.parseInputStream(stream(html, "euc-kr"), null, "http://example.com", Parser.htmlParser()); - Assert.assertEquals("한국어", doc.body().text()); + Assertions.assertEquals("한국어", doc.body().text()); } @Test @@ -146,7 +145,7 @@ public void firstMetaElementWithCharsetShouldBeUsedForDecoding() throws Exceptio Document doc = DataUtil.parseInputStream(stream(html, "iso-8859-1"), null, "http://example.com", Parser.htmlParser()); - Assert.assertEquals("Übergrößenträger", doc.body().text()); + Assertions.assertEquals("Übergrößenträger", doc.body().text()); } @Test @@ -154,30 +153,30 @@ public void supportsBOMinFiles() throws IOException { // test files from http://www.i18nl10n.com/korean/utftest/ File in = ParseTest.getFile("/bomtests/bom_utf16be.html"); Document doc = Jsoup.parse(in, null, "http://example.com"); - Assert.assertTrue(doc.title().contains("UTF-16BE")); - Assert.assertTrue(doc.text().contains("가각갂갃간갅")); + Assertions.assertTrue(doc.title().contains("UTF-16BE")); + Assertions.assertTrue(doc.text().contains("가각갂갃간갅")); in = ParseTest.getFile("/bomtests/bom_utf16le.html"); doc = Jsoup.parse(in, null, "http://example.com"); - Assert.assertTrue(doc.title().contains("UTF-16LE")); - Assert.assertTrue(doc.text().contains("가각갂갃간갅")); + Assertions.assertTrue(doc.title().contains("UTF-16LE")); + Assertions.assertTrue(doc.text().contains("가각갂갃간갅")); in = ParseTest.getFile("/bomtests/bom_utf32be.html"); doc = Jsoup.parse(in, null, "http://example.com"); - Assert.assertTrue(doc.title().contains("UTF-32BE")); - Assert.assertTrue(doc.text().contains("가각갂갃간갅")); + Assertions.assertTrue(doc.title().contains("UTF-32BE")); + Assertions.assertTrue(doc.text().contains("가각갂갃간갅")); in = ParseTest.getFile("/bomtests/bom_utf32le.html"); doc = Jsoup.parse(in, null, "http://example.com"); - Assert.assertTrue(doc.title().contains("UTF-32LE")); - Assert.assertTrue(doc.text().contains("가각갂갃간갅")); + Assertions.assertTrue(doc.title().contains("UTF-32LE")); + Assertions.assertTrue(doc.text().contains("가각갂갃간갅")); } @Test public void supportsUTF8BOM() throws IOException { File in = ParseTest.getFile("/bomtests/bom_utf8.html"); Document doc = Jsoup.parse(in, null, "http://example.com"); - Assert.assertEquals("OK", doc.head().select("title").text()); + Assertions.assertEquals("OK", doc.head().select("title").text()); } @Test @@ -185,15 +184,15 @@ public void noExtraNULLBytes() throws IOException { final byte[] b = "

    ".getBytes("UTF-8"); Document doc = Jsoup.parse(new ByteArrayInputStream(b), null, ""); - Assert.assertFalse( doc.outerHtml().contains("\u0000") ); + Assertions.assertFalse( doc.outerHtml().contains("\u0000") ); } @Test public void supportsZippedUTF8BOM() throws IOException { File in = ParseTest.getFile("/bomtests/bom_utf8.html.gz"); Document doc = Jsoup.parse(in, null, "http://example.com"); - Assert.assertEquals("OK", doc.head().select("title").text()); - Assert.assertEquals("There is a UTF8 BOM at the top (before the XML decl). If not read correctly, will look like a non-joining space.", doc.body().text()); + Assertions.assertEquals("OK", doc.head().select("title").text()); + Assertions.assertEquals("There is a UTF8 BOM at the top (before the XML decl). If not read correctly, will look like a non-joining space.", doc.body().text()); } @Test @@ -206,7 +205,7 @@ public void supportsXmlCharsetDeclaration() throws IOException { ).getBytes(encoding)); Document doc = Jsoup.parse(soup, null, ""); - Assert.assertEquals("Hellö Wörld!", doc.body().text()); + Assertions.assertEquals("Hellö Wörld!", doc.body().text()); } @@ -214,8 +213,8 @@ public void supportsXmlCharsetDeclaration() throws IOException { public void lLoadsGzipFile() throws IOException { File in = ParseTest.getFile("/htmltests/gzip.html.gz"); Document doc = Jsoup.parse(in, null); - Assert.assertEquals("Gzip test", doc.title()); - Assert.assertEquals("This is a gzipped HTML file.", doc.selectFirst("p").text()); + Assertions.assertEquals("Gzip test", doc.title()); + Assertions.assertEquals("This is a gzipped HTML file.", doc.selectFirst("p").text()); } @Test @@ -223,15 +222,15 @@ public void loadsZGzipFile() throws IOException { // compressed on win, with z suffix File in = ParseTest.getFile("/htmltests/gzip.html.z"); Document doc = Jsoup.parse(in, null); - Assert.assertEquals("Gzip test", doc.title()); - Assert.assertEquals("This is a gzipped HTML file.", doc.selectFirst("p").text()); + Assertions.assertEquals("Gzip test", doc.title()); + Assertions.assertEquals("This is a gzipped HTML file.", doc.selectFirst("p").text()); } @Test public void handlesFakeGzipFile() throws IOException { File in = ParseTest.getFile("/htmltests/fake-gzip.html.gz"); Document doc = Jsoup.parse(in, null); - Assert.assertEquals("This is not gzipped", doc.title()); - Assert.assertEquals("And should still be readable.", doc.selectFirst("p").text()); + Assertions.assertEquals("This is not gzipped", doc.title()); + Assertions.assertEquals("And should still be readable.", doc.selectFirst("p").text()); } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/helper/ValidateTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/helper/ValidateTest.java index 6a14e4ea3d..a465e413b6 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/helper/ValidateTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/helper/ValidateTest.java @@ -23,12 +23,11 @@ This file is part of the iText (R) project. package com.itextpdf.styledxmlparser.jsoup.helper; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class ValidateTest extends ExtendedITextTest { @Test @@ -40,6 +39,6 @@ public void testNotNull() { } catch (IllegalArgumentException e) { threw = true; } - Assert.assertTrue(threw); + Assertions.assertTrue(threw); } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/integration/FuzzFixesTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/integration/FuzzFixesTest.java index 6a5246d8b0..b3e8c42bee 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/integration/FuzzFixesTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/integration/FuzzFixesTest.java @@ -27,10 +27,9 @@ This file is part of the iText (R) project. import com.itextpdf.styledxmlparser.jsoup.nodes.Document; import com.itextpdf.styledxmlparser.jsoup.parser.Parser; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.File; import java.io.FileInputStream; @@ -39,7 +38,7 @@ This file is part of the iText (R) project. /** Tests fixes for issues raised by the OSS Fuzz project @ https://oss-fuzz.com/testcases?project=jsoup */ -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class FuzzFixesTest extends ExtendedITextTest { @Test @@ -47,7 +46,7 @@ public void blankAbsAttr() { // https://github.com/jhy/jsoup/issues/1541 String html = "b"; Document doc = Jsoup.parse(html); - Assert.assertNotNull(doc); + Assertions.assertNotNull(doc); } @Test @@ -55,7 +54,7 @@ public void resetInsertionMode() throws IOException { // https://github.com/jhy/jsoup/issues/1538 File in = ParseTest.getFile("/fuzztests/1538.html"); // lots of escape chars etc. Document doc = Jsoup.parse(in, "UTF-8"); - Assert.assertNotNull(doc); + Assertions.assertNotNull(doc); } @Test @@ -63,10 +62,10 @@ public void xmlDeclOverflow() throws IOException { // https://github.com/jhy/jsoup/issues/1539 File in = ParseTest.getFile("/fuzztests/1539.html"); // lots of escape chars etc. Document doc = Jsoup.parse(in, "UTF-8"); - Assert.assertNotNull(doc); + Assertions.assertNotNull(doc); Document docXml = Jsoup.parse(FileUtil.getInputStreamForFile(in), "UTF-8", "https://example.com", Parser.xmlParser()); - Assert.assertNotNull(docXml); + Assertions.assertNotNull(docXml); } @Test @@ -74,10 +73,10 @@ public void xmlDeclOverflowOOM() throws IOException { // https://github.com/jhy/jsoup/issues/1569 File in = ParseTest.getFile("/fuzztests/1569.html"); Document doc = Jsoup.parse(in, "UTF-8"); - Assert.assertNotNull(doc); + Assertions.assertNotNull(doc); Document docXml = Jsoup.parse(FileUtil.getInputStreamForFile(in), "UTF-8", "https://example.com", Parser.xmlParser()); - Assert.assertNotNull(docXml); + Assertions.assertNotNull(docXml); } @Test @@ -85,7 +84,7 @@ public void stackOverflowState14() throws IOException { // https://github.com/jhy/jsoup/issues/1543 File in = ParseTest.getFile("/fuzztests/1543.html"); Document doc = Jsoup.parse(in, "UTF-8"); - Assert.assertNotNull(doc); + Assertions.assertNotNull(doc); } @Test @@ -93,6 +92,6 @@ public void parseTimeout() throws IOException { // https://github.com/jhy/jsoup/issues/1544 File in = ParseTest.getFile("/fuzztests/1544.html"); Document doc = Jsoup.parse(in, "UTF-8"); - Assert.assertNotNull(doc); + Assertions.assertNotNull(doc); } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/integration/ParseTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/integration/ParseTest.java index 6e29a8f378..7d8e1f406a 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/integration/ParseTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/integration/ParseTest.java @@ -31,7 +31,6 @@ This file is part of the iText (R) project. import com.itextpdf.styledxmlparser.jsoup.parser.Parser; import com.itextpdf.styledxmlparser.jsoup.select.Elements; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.ByteArrayInputStream; import java.io.File; @@ -41,14 +40,14 @@ This file is part of the iText (R) project. import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.util.zip.GZIPInputStream; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; /** * Integration test: parses from real-world example HTML. */ -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class ParseTest extends ExtendedITextTest { public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/styledxmlparser/jsoup"; @@ -58,43 +57,43 @@ public void testSmhBizArticle() throws IOException { File in = getFile("/htmltests/smh-biz-article-1.html.gz"); Document doc = Jsoup.parse(in, "UTF-8", "http://www.smh.com.au/business/the-boards-next-fear-the-female-quota-20100106-lteq.html"); - Assert.assertEquals("The board’s next fear: the female quota", + Assertions.assertEquals("The board’s next fear: the female quota", doc.title()); // note that the apos in the source is a literal ’ (8217), not escaped or ' - Assert.assertEquals("en", doc.select("html").attr("xml:lang")); + Assertions.assertEquals("en", doc.select("html").attr("xml:lang")); Elements articleBody = doc.select(".articleBody > *"); - Assert.assertEquals(17, articleBody.size()); + Assertions.assertEquals(17, articleBody.size()); } @Test public void testNewsHomepage() throws IOException { File in = getFile("/htmltests/news-com-au-home.html.gz"); Document doc = Jsoup.parse(in, "UTF-8", "http://www.news.com.au/"); - Assert.assertEquals("News.com.au | News from Australia and around the world online | NewsComAu", doc.title()); - Assert.assertEquals("Brace yourself for Metro meltdown", doc.select(".id1225817868581 h4").text().trim()); + Assertions.assertEquals("News.com.au | News from Australia and around the world online | NewsComAu", doc.title()); + Assertions.assertEquals("Brace yourself for Metro meltdown", doc.select(".id1225817868581 h4").text().trim()); Element a = doc.select("a[href=/entertainment/horoscopes]").first(); - Assert.assertEquals("/entertainment/horoscopes", a.attr("href")); - Assert.assertEquals("http://www.news.com.au/entertainment/horoscopes", a.attr("abs:href")); + Assertions.assertEquals("/entertainment/horoscopes", a.attr("href")); + Assertions.assertEquals("http://www.news.com.au/entertainment/horoscopes", a.attr("abs:href")); Element hs = doc.select("a[href*=naughty-corners-are-a-bad-idea]").first(); - Assert.assertEquals( + Assertions.assertEquals( "http://www.heraldsun.com.au/news/naughty-corners-are-a-bad-idea-for-kids/story-e6frf7jo-1225817899003", hs.attr("href")); - Assert.assertEquals(hs.attr("href"), hs.attr("abs:href")); + Assertions.assertEquals(hs.attr("href"), hs.attr("abs:href")); } @Test public void testGoogleSearchIpod() throws IOException { File in = getFile("/htmltests/google-ipod.html.gz"); Document doc = Jsoup.parse(in, "UTF-8", "http://www.google.com/search?hl=en&q=ipod&aq=f&oq=&aqi=g10"); - Assert.assertEquals("ipod - Google Search", doc.title()); + Assertions.assertEquals("ipod - Google Search", doc.title()); Elements results = doc.select("h3.r > a"); - Assert.assertEquals(12, results.size()); - Assert.assertEquals( + Assertions.assertEquals(12, results.size()); + Assertions.assertEquals( "http://news.google.com/news?hl=en&q=ipod&um=1&ie=UTF-8&ei=uYlKS4SbBoGg6gPf-5XXCw&sa=X&oi=news_group&ct=title&resnum=1&ved=0CCIQsQQwAA", results.get(0).attr("href")); - Assert.assertEquals("http://www.apple.com/itunes/", + Assertions.assertEquals("http://www.apple.com/itunes/", results.get(1).attr("href")); } @@ -102,11 +101,11 @@ public void testGoogleSearchIpod() throws IOException { public void testYahooJp() throws IOException { File in = getFile("/htmltests/yahoo-jp.html.gz"); Document doc = Jsoup.parse(in, "UTF-8", "http://www.yahoo.co.jp/index.html"); // http charset is utf-8. - Assert.assertEquals("Yahoo! JAPAN", doc.title()); + Assertions.assertEquals("Yahoo! JAPAN", doc.title()); Element a = doc.select("a[href=t/2322m2]").first(); - Assert.assertEquals("http://www.yahoo.co.jp/_ylh=X3oDMTB0NWxnaGxsBF9TAzIwNzcyOTYyNjUEdGlkAzEyBHRtcGwDZ2Ex/t/2322m2", + Assertions.assertEquals("http://www.yahoo.co.jp/_ylh=X3oDMTB0NWxnaGxsBF9TAzIwNzcyOTYyNjUEdGlkAzEyBHRtcGwDZ2Ex/t/2322m2", a.attr("abs:href")); // session put into - Assert.assertEquals("全国、人気の駅ランキング", a.text()); + Assertions.assertEquals("全国、人気の駅ランキング", a.text()); } @Test @@ -117,21 +116,21 @@ public void testBaidu() throws IOException { Document doc = Jsoup.parse(in, null, "http://www.baidu.com"); // http charset is gb2312, but NOT specifying it, to test http-equiv parse Element submit = doc.select("#su").first(); - Assert.assertEquals("百度一下", submit.attr("value")); + Assertions.assertEquals("百度一下", submit.attr("value")); // test from attribute match submit = doc.select("input[value=百度一下]").first(); - Assert.assertEquals("su", submit.id()); + Assertions.assertEquals("su", submit.id()); Element newsLink = doc.select("a:contains(新)").first(); - Assert.assertEquals("http://news.baidu.com", newsLink.absUrl("href")); + Assertions.assertEquals("http://news.baidu.com", newsLink.absUrl("href")); // check auto-detect from meta // Android-Conversion-Skip-Line (TODO DEVSIX-7371 investigate different behavior of a few iTextCore tests on Java and Android) - Assert.assertEquals("GB2312", doc.outputSettings().charset().name()); // Android-Conversion-Replace Assert.assertEquals("GBK", doc.outputSettings().charset().name()); - Assert.assertEquals("百度一下,你就知道 ", doc.select("title").outerHtml()); + Assertions.assertEquals("GB2312", doc.outputSettings().charset().name()); // Android-Conversion-Replace Assertions.assertEquals("GBK", doc.outputSettings().charset().name()); + Assertions.assertEquals("百度一下,你就知道 ", doc.select("title").outerHtml()); doc.outputSettings().charset("ascii"); - Assert.assertEquals("百度一下,你就知道 ", + Assertions.assertEquals("百度一下,你就知道 ", doc.select("title").outerHtml()); } @@ -144,8 +143,8 @@ public void testBaiduVariant() throws IOException { "http://www.baidu.com/"); // http charset is gb2312, but NOT specifying it, to test http-equiv parse // check auto-detect from meta // Android-Conversion-Skip-Line (TODO DEVSIX-7371 investigate different behavior of a few iTextCore tests on Java and Android) - Assert.assertEquals("GB2312", doc.outputSettings().charset().name()); // Android-Conversion-Replace Assert.assertEquals("GBK", doc.outputSettings().charset().name()); - Assert.assertEquals("百度一下,你就知道", doc.select("title").outerHtml()); + Assertions.assertEquals("GB2312", doc.outputSettings().charset().name()); // Android-Conversion-Replace Assertions.assertEquals("GBK", doc.outputSettings().charset().name()); + Assertions.assertEquals("百度一下,你就知道", doc.select("title").outerHtml()); } @Test @@ -154,21 +153,21 @@ public void testHtml5Charset() throws IOException { // test that works File in = getFile("/htmltests/meta-charset-1.html"); Document doc = Jsoup.parse(in, null, "http://example.com/"); //gb2312, has html5 - Assert.assertEquals("新", doc.text()); + Assertions.assertEquals("新", doc.text()); // Android-Conversion-Skip-Line (TODO DEVSIX-7371 investigate different behavior of a few iTextCore tests on Java and Android) - Assert.assertEquals("GB2312", doc.outputSettings().charset().name()); // Android-Conversion-Replace Assert.assertEquals("GBK", doc.outputSettings().charset().name()); + Assertions.assertEquals("GB2312", doc.outputSettings().charset().name()); // Android-Conversion-Replace Assertions.assertEquals("GBK", doc.outputSettings().charset().name()); // double check, no charset, falls back to utf8 which is incorrect in = getFile("/htmltests/meta-charset-2.html"); // doc = Jsoup.parse(in, null, "http://example.com"); // gb2312, no charset - Assert.assertEquals("UTF-8", doc.outputSettings().charset().name()); - Assert.assertNotEquals("新", doc.text()); + Assertions.assertEquals("UTF-8", doc.outputSettings().charset().name()); + Assertions.assertNotEquals("新", doc.text()); // confirm fallback to utf8 in = getFile("/htmltests/meta-charset-3.html"); doc = Jsoup.parse(in, null, "http://example.com/"); // utf8, no charset - Assert.assertEquals("UTF-8", doc.outputSettings().charset().name()); - Assert.assertEquals("新", doc.text()); + Assertions.assertEquals("UTF-8", doc.outputSettings().charset().name()); + Assertions.assertEquals("新", doc.text()); } @Test @@ -178,7 +177,7 @@ public void testBrokenHtml5CharsetWithASingleDoubleQuote() throws IOException { "\n" + ""); Document doc = Jsoup.parse(in, null, "http://example.com/"); - Assert.assertEquals("UTF-8", doc.outputSettings().charset().name()); + Assertions.assertEquals("UTF-8", doc.outputSettings().charset().name()); } @Test @@ -188,7 +187,7 @@ public void testNytArticle() throws IOException { Document doc = Jsoup.parse(in, null, "http://www.nytimes.com/2010/07/26/business/global/26bp.html?hp"); Element headline = doc.select("nyt_headline[version=1.0]").first(); - Assert.assertEquals("As BP Lays Out Future, It Will Not Include Hayward", headline.text()); + Assertions.assertEquals("As BP Lays Out Future, It Will Not Include Hayward", headline.text()); } @Test @@ -196,7 +195,7 @@ public void testYahooArticle() throws IOException { File in = getFile("/htmltests/yahoo-article-1.html.gz"); Document doc = Jsoup.parse(in, "UTF-8", "http://news.yahoo.com/s/nm/20100831/bs_nm/us_gm_china"); Element p = doc.select("p:contains(Volt will be sold in the United States)").first(); - Assert.assertEquals("In July, GM said its electric Chevrolet Volt will be sold in the United States at $41,000 -- $8,000 more than its nearest competitor, the Nissan Leaf.", p.text()); + Assertions.assertEquals("In July, GM said its electric Chevrolet Volt will be sold in the United States at $41,000 -- $8,000 more than its nearest competitor, the Nissan Leaf.", p.text()); } @Test @@ -205,8 +204,8 @@ public void testLowercaseUtf8Charset() throws IOException { Document doc = Jsoup.parse(in, null); Element form = doc.select("#form").first(); - Assert.assertEquals(2, form.children().size()); - Assert.assertEquals("UTF-8", doc.outputSettings().charset().name()); + Assertions.assertEquals(2, form.children().size()); + Assertions.assertEquals("UTF-8", doc.outputSettings().charset().name()); } @Test @@ -215,8 +214,8 @@ public void usualHtmlButWithGzExtensionTest() throws IOException { Document doc = Jsoup.parse(in, null); Element form = doc.select("#form").first(); - Assert.assertEquals(2, form.children().size()); - Assert.assertEquals("UTF-8", doc.outputSettings().charset().name()); + Assertions.assertEquals(2, form.children().size()); + Assertions.assertEquals("UTF-8", doc.outputSettings().charset().name()); } @Test @@ -225,12 +224,12 @@ public void testXwiki() throws IOException { // this tests that when in CharacterReader we hit a buffer while marked, we preserve the mark when buffered up and can rewind File in = getFile("/htmltests/xwiki-1324.html.gz"); Document doc = Jsoup.parse(in, null, "https://localhost/"); - Assert.assertEquals("XWiki Jetty HSQLDB 12.1-SNAPSHOT", doc.select("#xwikiplatformversion").text()); + Assertions.assertEquals("XWiki Jetty HSQLDB 12.1-SNAPSHOT", doc.select("#xwikiplatformversion").text()); // was getting busted at =userdirectory, because it hit the bufferup point but the mark was then lost. so // updated to preserve the mark. String wantHtml = "User Directory"; - Assert.assertEquals(wantHtml, doc.select("[data-id=userdirectory]").outerHtml()); + Assertions.assertEquals(wantHtml, doc.select("[data-id=userdirectory]").outerHtml()); } @Test @@ -243,31 +242,31 @@ public void testXwikiExpanded() throws IOException { Document doc = Jsoup.parse(new GZIPInputStream(FileUtil.getInputStreamForFile(in)), "UTF-8", "https://localhost/", parser.setTrackErrors(100)); ParseErrorList errors = parser.getErrors(); - Assert.assertEquals("XWiki Jetty HSQLDB 12.1-SNAPSHOT", doc.select("#xwikiplatformversion").text()); - Assert.assertEquals(0, errors.size()); // not an invalid reference because did not look legit + Assertions.assertEquals("XWiki Jetty HSQLDB 12.1-SNAPSHOT", doc.select("#xwikiplatformversion").text()); + Assertions.assertEquals(0, errors.size()); // not an invalid reference because did not look legit // was getting busted at =userdirectory, because it hit the bufferup point but the mark was then lost. so // updated to preserve the mark. String wantHtml = "User Directory"; - Assert.assertEquals(wantHtml, doc.select("[data-id=userdirectory]").outerHtml()); + Assertions.assertEquals(wantHtml, doc.select("[data-id=userdirectory]").outerHtml()); } public static File getFile(String resourceName) { diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/integration/SafelistExtensionTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/integration/SafelistExtensionTest.java index 188b8550b2..00ddd271a4 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/integration/SafelistExtensionTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/integration/SafelistExtensionTest.java @@ -28,15 +28,14 @@ This file is part of the iText (R) project. import com.itextpdf.styledxmlparser.jsoup.nodes.Element; import com.itextpdf.styledxmlparser.jsoup.safety.Safelist; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; /** Check that we can extend Safelist methods */ -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class SafelistExtensionTest extends ExtendedITextTest { @Test public void canCustomizeSafeTests() { OpenSafelist openSafelist = new OpenSafelist(Safelist.relaxed()); @@ -47,8 +46,8 @@ public class SafelistExtensionTest extends ExtendedITextTest { String openClean = Jsoup.clean(html, openSafelist); String clean = Jsoup.clean(html, safelist); - Assert.assertEquals("

    Hello

    ", TextUtil.stripNewlines(openClean)); - Assert.assertEquals("

    Hello

    ", clean); + Assertions.assertEquals("

    Hello

    ", TextUtil.stripNewlines(openClean)); + Assertions.assertEquals("

    Hello

    ", clean); } // passes tags and attributes starting with "open" diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/internal/StringUtilTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/internal/StringUtilTest.java index 4d702b211d..ccf71beee2 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/internal/StringUtilTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/internal/StringUtilTest.java @@ -24,10 +24,9 @@ This file is part of the iText (R) project. import com.itextpdf.styledxmlparser.jsoup.Jsoup; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.util.Arrays; import java.util.Collections; @@ -35,124 +34,124 @@ This file is part of the iText (R) project. import static com.itextpdf.styledxmlparser.jsoup.internal.StringUtil.normaliseWhitespace; import static com.itextpdf.styledxmlparser.jsoup.internal.StringUtil.resolve; -@Category(UnitTest.class) +@Tag("UnitTest") public class StringUtilTest extends ExtendedITextTest { @Test public void join() { - Assert.assertEquals("", StringUtil.join(Collections.singletonList(""), " ")); - Assert.assertEquals("one", StringUtil.join(Collections.singletonList("one"), " ")); - Assert.assertEquals("one two three", StringUtil.join(Arrays.asList("one", "two", "three"), " ")); + Assertions.assertEquals("", StringUtil.join(Collections.singletonList(""), " ")); + Assertions.assertEquals("one", StringUtil.join(Collections.singletonList("one"), " ")); + Assertions.assertEquals("one two three", StringUtil.join(Arrays.asList("one", "two", "three"), " ")); } @Test public void padding() { - Assert.assertEquals("", StringUtil.padding(0)); - Assert.assertEquals(" ", StringUtil.padding(1)); - Assert.assertEquals(" ", StringUtil.padding(2)); - Assert.assertEquals(" ", StringUtil.padding(15)); - Assert.assertEquals(" ", StringUtil.padding(45)); // we tap out at 30 + Assertions.assertEquals("", StringUtil.padding(0)); + Assertions.assertEquals(" ", StringUtil.padding(1)); + Assertions.assertEquals(" ", StringUtil.padding(2)); + Assertions.assertEquals(" ", StringUtil.padding(15)); + Assertions.assertEquals(" ", StringUtil.padding(45)); // we tap out at 30 } @Test public void paddingInACan() { String[] padding = StringUtil.padding; - Assert.assertEquals(21, padding.length); + Assertions.assertEquals(21, padding.length); for (int i = 0; i < padding.length; i++) { - Assert.assertEquals(i, padding[i].length()); + Assertions.assertEquals(i, padding[i].length()); } } @Test public void isBlank() { - Assert.assertTrue(StringUtil.isBlank(null)); - Assert.assertTrue(StringUtil.isBlank("")); - Assert.assertTrue(StringUtil.isBlank(" ")); - Assert.assertTrue(StringUtil.isBlank(" \r\n ")); + Assertions.assertTrue(StringUtil.isBlank(null)); + Assertions.assertTrue(StringUtil.isBlank("")); + Assertions.assertTrue(StringUtil.isBlank(" ")); + Assertions.assertTrue(StringUtil.isBlank(" \r\n ")); - Assert.assertFalse(StringUtil.isBlank("hello")); - Assert.assertFalse(StringUtil.isBlank(" hello ")); + Assertions.assertFalse(StringUtil.isBlank("hello")); + Assertions.assertFalse(StringUtil.isBlank(" hello ")); } @Test public void isNumeric() { - Assert.assertFalse(StringUtil.isNumeric(null)); - Assert.assertFalse(StringUtil.isNumeric(" ")); - Assert.assertFalse(StringUtil.isNumeric("123 546")); - Assert.assertFalse(StringUtil.isNumeric("hello")); - Assert.assertFalse(StringUtil.isNumeric("123.334")); - - Assert.assertTrue(StringUtil.isNumeric("1")); - Assert.assertTrue(StringUtil.isNumeric("1234")); + Assertions.assertFalse(StringUtil.isNumeric(null)); + Assertions.assertFalse(StringUtil.isNumeric(" ")); + Assertions.assertFalse(StringUtil.isNumeric("123 546")); + Assertions.assertFalse(StringUtil.isNumeric("hello")); + Assertions.assertFalse(StringUtil.isNumeric("123.334")); + + Assertions.assertTrue(StringUtil.isNumeric("1")); + Assertions.assertTrue(StringUtil.isNumeric("1234")); } @Test public void isWhitespace() { - Assert.assertTrue(StringUtil.isWhitespace('\t')); - Assert.assertTrue(StringUtil.isWhitespace('\n')); - Assert.assertTrue(StringUtil.isWhitespace('\r')); - Assert.assertTrue(StringUtil.isWhitespace('\f')); - Assert.assertTrue(StringUtil.isWhitespace(' ')); - - Assert.assertFalse(StringUtil.isWhitespace('\u00a0')); - Assert.assertFalse(StringUtil.isWhitespace('\u2000')); - Assert.assertFalse(StringUtil.isWhitespace('\u3000')); + Assertions.assertTrue(StringUtil.isWhitespace('\t')); + Assertions.assertTrue(StringUtil.isWhitespace('\n')); + Assertions.assertTrue(StringUtil.isWhitespace('\r')); + Assertions.assertTrue(StringUtil.isWhitespace('\f')); + Assertions.assertTrue(StringUtil.isWhitespace(' ')); + + Assertions.assertFalse(StringUtil.isWhitespace('\u00a0')); + Assertions.assertFalse(StringUtil.isWhitespace('\u2000')); + Assertions.assertFalse(StringUtil.isWhitespace('\u3000')); } @Test public void normaliseWhiteSpace() { - Assert.assertEquals(" ", normaliseWhitespace(" \r \n \r\n")); - Assert.assertEquals(" hello there ", normaliseWhitespace(" hello \r \n there \n")); - Assert.assertEquals("hello", normaliseWhitespace("hello")); - Assert.assertEquals("hello there", normaliseWhitespace("hello\nthere")); + Assertions.assertEquals(" ", normaliseWhitespace(" \r \n \r\n")); + Assertions.assertEquals(" hello there ", normaliseWhitespace(" hello \r \n there \n")); + Assertions.assertEquals("hello", normaliseWhitespace("hello")); + Assertions.assertEquals("hello there", normaliseWhitespace("hello\nthere")); } @Test public void normaliseWhiteSpaceHandlesHighSurrogates() { String test71540chars = "\ud869\udeb2\u304b\u309a 1"; String test71540charsExpectedSingleWhitespace = "\ud869\udeb2\u304b\u309a 1"; - Assert.assertEquals(test71540charsExpectedSingleWhitespace, normaliseWhitespace(test71540chars)); + Assertions.assertEquals(test71540charsExpectedSingleWhitespace, normaliseWhitespace(test71540chars)); String extractedText = Jsoup.parse(test71540chars).text(); - Assert.assertEquals(test71540charsExpectedSingleWhitespace, extractedText); + Assertions.assertEquals(test71540charsExpectedSingleWhitespace, extractedText); } @Test public void resolvesRelativeUrls() { - Assert.assertEquals("http://example.com/one/two?three", resolve("http://example.com", "./one/two?three")); - Assert.assertEquals("http://example.com/one/two?three", resolve("http://example.com?one", "./one/two?three")); - Assert.assertEquals("http://example.com/one/two?three#four", resolve("http://example.com", "./one/two?three#four")); - Assert.assertEquals("https://example.com/one", resolve("http://example.com/", "https://example.com/one")); - Assert.assertEquals("http://example.com/one/two.html", resolve("http://example.com/two/", "../one/two.html")); - Assert.assertEquals("https://example2.com/one", resolve("https://example.com/", "//example2.com/one")); - Assert.assertEquals("https://example.com:8080/one", resolve("https://example.com:8080", "./one")); - Assert.assertEquals("https://example2.com/one", resolve("http://example.com/", "https://example2.com/one")); - Assert.assertEquals("https://example.com/one", resolve("wrong", "https://example.com/one")); - Assert.assertEquals("https://example.com/one", resolve("https://example.com/one", "")); - Assert.assertEquals("", resolve("wrong", "also wrong")); - Assert.assertEquals("ftp://example.com/one", resolve("ftp://example.com/two/", "../one")); - Assert.assertEquals("ftp://example.com/one/two.c", resolve("ftp://example.com/one/", "./two.c")); - Assert.assertEquals("ftp://example.com/one/two.c", resolve("ftp://example.com/one/", "two.c")); + Assertions.assertEquals("http://example.com/one/two?three", resolve("http://example.com", "./one/two?three")); + Assertions.assertEquals("http://example.com/one/two?three", resolve("http://example.com?one", "./one/two?three")); + Assertions.assertEquals("http://example.com/one/two?three#four", resolve("http://example.com", "./one/two?three#four")); + Assertions.assertEquals("https://example.com/one", resolve("http://example.com/", "https://example.com/one")); + Assertions.assertEquals("http://example.com/one/two.html", resolve("http://example.com/two/", "../one/two.html")); + Assertions.assertEquals("https://example2.com/one", resolve("https://example.com/", "//example2.com/one")); + Assertions.assertEquals("https://example.com:8080/one", resolve("https://example.com:8080", "./one")); + Assertions.assertEquals("https://example2.com/one", resolve("http://example.com/", "https://example2.com/one")); + Assertions.assertEquals("https://example.com/one", resolve("wrong", "https://example.com/one")); + Assertions.assertEquals("https://example.com/one", resolve("https://example.com/one", "")); + Assertions.assertEquals("", resolve("wrong", "also wrong")); + Assertions.assertEquals("ftp://example.com/one", resolve("ftp://example.com/two/", "../one")); + Assertions.assertEquals("ftp://example.com/one/two.c", resolve("ftp://example.com/one/", "./two.c")); + Assertions.assertEquals("ftp://example.com/one/two.c", resolve("ftp://example.com/one/", "two.c")); // examples taken from rfc3986 section 5.4.2 - Assert.assertEquals("http://example.com/g", resolve("http://example.com/b/c/d;p?q", "../../../g")); - Assert.assertEquals("http://example.com/g", resolve("http://example.com/b/c/d;p?q", "../../../../g")); - Assert.assertEquals("http://example.com/g", resolve("http://example.com/b/c/d;p?q", "/./g")); - Assert.assertEquals("http://example.com/g", resolve("http://example.com/b/c/d;p?q", "/../g")); - Assert.assertEquals("http://example.com/b/c/g.", resolve("http://example.com/b/c/d;p?q", "g.")); - Assert.assertEquals("http://example.com/b/c/.g", resolve("http://example.com/b/c/d;p?q", ".g")); - Assert.assertEquals("http://example.com/b/c/g..", resolve("http://example.com/b/c/d;p?q", "g..")); - Assert.assertEquals("http://example.com/b/c/..g", resolve("http://example.com/b/c/d;p?q", "..g")); - Assert.assertEquals("http://example.com/b/g", resolve("http://example.com/b/c/d;p?q", "./../g")); - Assert.assertEquals("http://example.com/b/c/g/", resolve("http://example.com/b/c/d;p?q", "./g/.")); - Assert.assertEquals("http://example.com/b/c/g/h", resolve("http://example.com/b/c/d;p?q", "g/./h")); - Assert.assertEquals("http://example.com/b/c/h", resolve("http://example.com/b/c/d;p?q", "g/../h")); - Assert.assertEquals("http://example.com/b/c/g;x=1/y", resolve("http://example.com/b/c/d;p?q", "g;x=1/./y")); - Assert.assertEquals("http://example.com/b/c/y", resolve("http://example.com/b/c/d;p?q", "g;x=1/../y")); - Assert.assertEquals("http://example.com/b/c/g?y/./x", resolve("http://example.com/b/c/d;p?q", "g?y/./x")); - Assert.assertEquals("http://example.com/b/c/g?y/../x", resolve("http://example.com/b/c/d;p?q", "g?y/../x")); - Assert.assertEquals("http://example.com/b/c/g#s/./x", resolve("http://example.com/b/c/d;p?q", "g#s/./x")); - Assert.assertEquals("http://example.com/b/c/g#s/../x", resolve("http://example.com/b/c/d;p?q", "g#s/../x")); + Assertions.assertEquals("http://example.com/g", resolve("http://example.com/b/c/d;p?q", "../../../g")); + Assertions.assertEquals("http://example.com/g", resolve("http://example.com/b/c/d;p?q", "../../../../g")); + Assertions.assertEquals("http://example.com/g", resolve("http://example.com/b/c/d;p?q", "/./g")); + Assertions.assertEquals("http://example.com/g", resolve("http://example.com/b/c/d;p?q", "/../g")); + Assertions.assertEquals("http://example.com/b/c/g.", resolve("http://example.com/b/c/d;p?q", "g.")); + Assertions.assertEquals("http://example.com/b/c/.g", resolve("http://example.com/b/c/d;p?q", ".g")); + Assertions.assertEquals("http://example.com/b/c/g..", resolve("http://example.com/b/c/d;p?q", "g..")); + Assertions.assertEquals("http://example.com/b/c/..g", resolve("http://example.com/b/c/d;p?q", "..g")); + Assertions.assertEquals("http://example.com/b/g", resolve("http://example.com/b/c/d;p?q", "./../g")); + Assertions.assertEquals("http://example.com/b/c/g/", resolve("http://example.com/b/c/d;p?q", "./g/.")); + Assertions.assertEquals("http://example.com/b/c/g/h", resolve("http://example.com/b/c/d;p?q", "g/./h")); + Assertions.assertEquals("http://example.com/b/c/h", resolve("http://example.com/b/c/d;p?q", "g/../h")); + Assertions.assertEquals("http://example.com/b/c/g;x=1/y", resolve("http://example.com/b/c/d;p?q", "g;x=1/./y")); + Assertions.assertEquals("http://example.com/b/c/y", resolve("http://example.com/b/c/d;p?q", "g;x=1/../y")); + Assertions.assertEquals("http://example.com/b/c/g?y/./x", resolve("http://example.com/b/c/d;p?q", "g?y/./x")); + Assertions.assertEquals("http://example.com/b/c/g?y/../x", resolve("http://example.com/b/c/d;p?q", "g?y/../x")); + Assertions.assertEquals("http://example.com/b/c/g#s/./x", resolve("http://example.com/b/c/d;p?q", "g#s/./x")); + Assertions.assertEquals("http://example.com/b/c/g#s/../x", resolve("http://example.com/b/c/d;p?q", "g#s/../x")); } @Test public void isAscii() { - Assert.assertTrue(StringUtil.isAscii("")); - Assert.assertTrue(StringUtil.isAscii("example.com")); - Assert.assertTrue(StringUtil.isAscii("One Two")); - Assert.assertFalse(StringUtil.isAscii("🧔")); - Assert.assertFalse(StringUtil.isAscii("测试")); - Assert.assertFalse(StringUtil.isAscii("测试.com")); + Assertions.assertTrue(StringUtil.isAscii("")); + Assertions.assertTrue(StringUtil.isAscii("example.com")); + Assertions.assertTrue(StringUtil.isAscii("One Two")); + Assertions.assertFalse(StringUtil.isAscii("🧔")); + Assertions.assertFalse(StringUtil.isAscii("测试")); + Assertions.assertFalse(StringUtil.isAscii("测试.com")); } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/nodes/AttributeTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/nodes/AttributeTest.java index 7ff085e2bf..4bae469eba 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/nodes/AttributeTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/nodes/AttributeTest.java @@ -24,33 +24,32 @@ This file is part of the iText (R) project. import com.itextpdf.styledxmlparser.jsoup.Jsoup; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class AttributeTest extends ExtendedITextTest { @Test public void html() { Attribute attr = new Attribute("key", "value &"); - Assert.assertEquals("key=\"value &\"", attr.html()); - Assert.assertEquals(attr.html(), attr.toString()); + Assertions.assertEquals("key=\"value &\"", attr.html()); + Assertions.assertEquals(attr.html(), attr.toString()); } @Test public void testWithSupplementaryCharacterInAttributeKeyAndValue() { String s = new String(Character.toChars(135361)); Attribute attr = new Attribute(s, "A" + s + "B"); - Assert.assertEquals(s + "=\"A" + s + "B\"", attr.html()); - Assert.assertEquals(attr.html(), attr.toString()); + Assertions.assertEquals(s + "=\"A" + s + "B\"", attr.html()); + Assertions.assertEquals(attr.html(), attr.toString()); } @Test public void validatesKeysNotEmpty() { - Assert.assertThrows(IllegalArgumentException.class, () -> new Attribute(" ", "Check")); + Assertions.assertThrows(IllegalArgumentException.class, () -> new Attribute(" ", "Check")); } @Test public void validatesKeysNotEmptyViaSet() { - Assert.assertThrows(IllegalArgumentException.class, () -> { + Assertions.assertThrows(IllegalArgumentException.class, () -> { Attribute attr = new Attribute("One", "Check"); attr.setKey(" "); }); @@ -59,23 +58,23 @@ public void html() { @Test public void booleanAttributesAreEmptyStringValues() { Document doc = Jsoup.parse("
    "); - Assert.assertEquals("

    Hello
    There
    now

    More

    Content

    ", TextUtil.stripNewlines(doc.body().html())); + Assertions.assertEquals("

    Hello
    There
    now

    More

    Content

    ", TextUtil.stripNewlines(doc.body().html())); } @Test public void testSpanContents() { // like h1 tags, the spec says SPAN is phrasing only, but browsers and publisher treat span as a block tag Document doc = Jsoup.parse("Hello
    there
    now
    "); - Assert.assertEquals("Hello
    there
    now
    ", TextUtil.stripNewlines(doc.body().html())); + Assertions.assertEquals("Hello
    there
    now
    ", TextUtil.stripNewlines(doc.body().html())); } @Test public void testNoImagesInNoScriptInHead() { // jsoup used to allow, but against spec if parsing with noscript Document doc = Jsoup.parse("

    Hello

    "); - Assert.assertEquals("

    Hello

    ", TextUtil.stripNewlines(doc.html())); + Assertions.assertEquals("

    Hello

    ", TextUtil.stripNewlines(doc.html())); } @Test public void testUnclosedNoscriptInHead() { @@ -650,27 +649,27 @@ public class HtmlParserTest extends ExtendedITextTest { String[] strings = {"", TextUtil.stripNewlines(doc.head().html())); } } @Test public void testAFlowContents() { // html5 has as either phrasing or block Document doc = Jsoup.parse("Hello
    there
    now
    "); - Assert.assertEquals("Hello
    there
    now
    ", TextUtil.stripNewlines(doc.body().html())); + Assertions.assertEquals("Hello
    there
    now
    ", TextUtil.stripNewlines(doc.body().html())); } @Test public void testFontFlowContents() { // html5 has no definition of ; often used as flow Document doc = Jsoup.parse("Hello
    there
    now
    "); - Assert.assertEquals("Hello
    there
    now
    ", TextUtil.stripNewlines(doc.body().html())); + Assertions.assertEquals("Hello
    there
    now
    ", TextUtil.stripNewlines(doc.body().html())); } @Test public void handlesMisnestedTagsBI() { // whatwg: String h = "

    12345

    "; Document doc = Jsoup.parse(h); - Assert.assertEquals("

    12345

    ", doc.body().html()); + Assertions.assertEquals("

    12345

    ", doc.body().html()); // adoption agency on
    , reconstruction of formatters on 4. } @@ -678,7 +677,7 @@ public class HtmlParserTest extends ExtendedITextTest { // whatwg:

    String h = "1

    23

    "; Document doc = Jsoup.parse(h); - Assert.assertEquals("1\n

    23

    ", doc.body().html()); + Assertions.assertEquals("1\n

    23

    ", doc.body().html()); } @Test public void handlesUnexpectedMarkupInTables() { @@ -686,7 +685,7 @@ public class HtmlParserTest extends ExtendedITextTest { // also tests foster parenting String h = "bbb
    aaa
    ccc"; Document doc = Jsoup.parse(h); - Assert.assertEquals("bbb
    aaa
    ccc", TextUtil.stripNewlines(doc.body().html())); + Assertions.assertEquals("bbb
    aaa
    ccc", TextUtil.stripNewlines(doc.body().html())); } @Test public void handlesUnclosedFormattingElements() { @@ -708,21 +707,21 @@ public class HtmlParserTest extends ExtendedITextTest { "

    X

    \n" + "\n" + ""; - Assert.assertEquals(want, doc.html()); + Assertions.assertEquals(want, doc.html()); } @Test public void handlesUnclosedAnchors() { String h = "Link

    Error link"; Document doc = Jsoup.parse(h); String want = "Link\n

    Error link

    "; - Assert.assertEquals(want, doc.body().html()); + Assertions.assertEquals(want, doc.body().html()); } @Test public void reconstructFormattingElements() { // tests attributes and multi b String h = "

    One Two Three

    Hello

    "; Document doc = Jsoup.parse(h); - Assert.assertEquals("

    One Two Three

    \n

    Hello

    ", doc.body().html()); + Assertions.assertEquals("

    One Two Three

    \n

    Hello

    ", doc.body().html()); } @Test public void reconstructFormattingElementsInTable() { @@ -738,19 +737,19 @@ public class HtmlParserTest extends ExtendedITextTest { " \n" + " \n" + "

    Five

    "; - Assert.assertEquals(want, doc.body().html()); + Assertions.assertEquals(want, doc.body().html()); } @Test public void commentBeforeHtml() { String h = "

    One

    "; Document doc = Jsoup.parse(h); - Assert.assertEquals("

    One

    ", TextUtil.stripNewlines(doc.html())); + Assertions.assertEquals("

    One

    ", TextUtil.stripNewlines(doc.html())); } @Test public void emptyTdTag() { String h = "
    One
    "; Document doc = Jsoup.parse(h); - Assert.assertEquals("One\n", doc.select("tr").first().html()); + Assertions.assertEquals("One\n", doc.select("tr").first().html()); } @Test public void handlesSolidusInA() { @@ -758,93 +757,93 @@ public class HtmlParserTest extends ExtendedITextTest { String h = "link text"; Document doc = Jsoup.parse(h); Element a = doc.select("a").first(); - Assert.assertEquals("link text", a.text()); - Assert.assertEquals("/lib/14160711/", a.attr("href")); + Assertions.assertEquals("link text", a.text()); + Assertions.assertEquals("/lib/14160711/", a.attr("href")); } @Test public void handlesSpanInTbody() { // test for bug 64 String h = "
    One
    Two
    "; Document doc = Jsoup.parse(h); - Assert.assertEquals(doc.select("span").first().children().size(), 0); // the span gets closed - Assert.assertEquals(doc.select("table").size(), 1); // only one table + Assertions.assertEquals(doc.select("span").first().children().size(), 0); // the span gets closed + Assertions.assertEquals(doc.select("table").size(), 1); // only one table } @Test public void handlesUnclosedTitleAtEof() { - Assert.assertEquals("Data", Jsoup.parse("Data").title()); - Assert.assertEquals("Data<", Jsoup.parse("<title>Data<").title()); - Assert.assertEquals("Data</", Jsoup.parse("<title>Data</").title()); - Assert.assertEquals("Data</t", Jsoup.parse("<title>Data</t").title()); - Assert.assertEquals("Data</ti", Jsoup.parse("<title>Data</ti").title()); - Assert.assertEquals("Data", Jsoup.parse("<title>Data").title()); - Assert.assertEquals("Data", Jsoup.parse("Data").title()); + Assertions.assertEquals("Data", Jsoup.parse("Data").title()); + Assertions.assertEquals("Data<", Jsoup.parse("<title>Data<").title()); + Assertions.assertEquals("Data</", Jsoup.parse("<title>Data</").title()); + Assertions.assertEquals("Data</t", Jsoup.parse("<title>Data</t").title()); + Assertions.assertEquals("Data</ti", Jsoup.parse("<title>Data</ti").title()); + Assertions.assertEquals("Data", Jsoup.parse("<title>Data").title()); + Assertions.assertEquals("Data", Jsoup.parse("Data").title()); } @Test public void handlesUnclosedTitle() { Document one = Jsoup.parse("One <b>Two <b>Three

    Test

    "); // has title, so is plain text - Assert.assertEquals("One Two Three", one.title()); - Assert.assertEquals("Test", one.select("p").first().text()); + Assertions.assertEquals("One Two Three", one.title()); + Assertions.assertEquals("Test", one.select("p").first().text()); Document two = Jsoup.parse("One<b>Two <p>Test</p>"); // no title, so <b> causes breakout - Assert.assertEquals("One", two.title()); - Assert.assertEquals("Two

    Test

    ", two.body().html()); + Assertions.assertEquals("One", two.title()); + Assertions.assertEquals("Two

    Test

    ", two.body().html()); } @Test public void handlesUnclosedScriptAtEof() { - Assert.assertEquals("Data", Jsoup.parse("").select("script").first().data()); - Assert.assertEquals("DataDataDataDataDataDataDataData").select("script").first().data()); + Assertions.assertEquals("Data<", Jsoup.parse("").select("script").first().data()); + Assertions.assertEquals("DataDataDataDataDataDataDataData").select("style").first().data()); - Assert.assertEquals("DataDataData").select("style").first().data()); - Assert.assertEquals("DataDataDataDataDataData").select("style").first().data()); + Assertions.assertEquals("DataDataData").select("style").first().data()); + Assertions.assertEquals("DataDataDataDataData, but no more Document doc = Jsoup.parse(""); - Assert.assertEquals("", doc.body().html()); + Assertions.assertEquals("", doc.body().html()); } @Test public void handlesEscapedScript() { Document doc = Jsoup.parse(""); - Assert.assertEquals("", doc.select("script").first().data()); + Assertions.assertEquals("", doc.select("script").first().data()); } @Test public void handles0CharacterAsText() { Document doc = Jsoup.parse("0

    0

    "); - Assert.assertEquals("0\n

    0

    ", doc.body().html()); + Assertions.assertEquals("0\n

    0

    ", doc.body().html()); } @Test public void handlesNullInData() { Document doc = Jsoup.parse("

    Blah \u0000

    "); - Assert.assertEquals("

    Blah \u0000

    ", doc.body().html()); // replaced in attr, NOT replaced in data + Assertions.assertEquals("

    Blah \u0000

    ", doc.body().html()); // replaced in attr, NOT replaced in data } @Test public void handlesNullInComments() { Document doc = Jsoup.parse(""); - Assert.assertEquals("", doc.body().html()); + Assertions.assertEquals("", doc.body().html()); } @Test public void handlesNewlinesAndWhitespaceInTag() { Document doc = Jsoup.parse(""); - Assert.assertEquals("", doc.body().html()); + Assertions.assertEquals("", doc.body().html()); } @Test public void handlesWhitespaceInoDocType() { @@ -852,7 +851,7 @@ public class HtmlParserTest extends ExtendedITextTest { " PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\r\n" + " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"; Document doc = Jsoup.parse(html); - Assert.assertEquals("", doc.childNode(0).outerHtml()); + Assertions.assertEquals("", doc.childNode(0).outerHtml()); } @Test public void tracksErrorsWhenRequested() { @@ -861,12 +860,12 @@ public class HtmlParserTest extends ExtendedITextTest { Document doc = Jsoup.parse(html, "http://example.com", parser); List errors = parser.getErrors(); - Assert.assertEquals(5, errors.size()); - Assert.assertEquals("20: Attributes incorrectly present on end tag", errors.get(0).toString()); - Assert.assertEquals("35: Unexpected token [Doctype] when in state [InBody]", errors.get(1).toString()); - Assert.assertEquals("36: Invalid character reference: invalid named reference", errors.get(2).toString()); - Assert.assertEquals("50: Tag cannot be self closing; not a void tag", errors.get(3).toString()); - Assert.assertEquals("61: Unexpectedly reached end of file (EOF) in input state [TagName]", errors.get(4).toString()); + Assertions.assertEquals(5, errors.size()); + Assertions.assertEquals("20: Attributes incorrectly present on end tag", errors.get(0).toString()); + Assertions.assertEquals("35: Unexpected token [Doctype] when in state [InBody]", errors.get(1).toString()); + Assertions.assertEquals("36: Invalid character reference: invalid named reference", errors.get(2).toString()); + Assertions.assertEquals("50: Tag cannot be self closing; not a void tag", errors.get(3).toString()); + Assertions.assertEquals("61: Unexpectedly reached end of file (EOF) in input state [TagName]", errors.get(4).toString()); } @Test public void tracksLimitedErrorsWhenRequested() { @@ -875,10 +874,10 @@ public class HtmlParserTest extends ExtendedITextTest { Document doc = parser.parseInput(html, "http://example.com"); List errors = parser.getErrors(); - Assert.assertEquals(3, errors.size()); - Assert.assertEquals("20: Attributes incorrectly present on end tag", errors.get(0).toString()); - Assert.assertEquals("35: Unexpected token [Doctype] when in state [InBody]", errors.get(1).toString()); - Assert.assertEquals("36: Invalid character reference: invalid named reference", errors.get(2).toString()); + Assertions.assertEquals(3, errors.size()); + Assertions.assertEquals("20: Attributes incorrectly present on end tag", errors.get(0).toString()); + Assertions.assertEquals("35: Unexpected token [Doctype] when in state [InBody]", errors.get(1).toString()); + Assertions.assertEquals("36: Invalid character reference: invalid named reference", errors.get(2).toString()); } @Test public void noErrorsByDefault() { @@ -887,13 +886,13 @@ public class HtmlParserTest extends ExtendedITextTest { Document doc = Jsoup.parse(html, "http://example.com", parser); List errors = parser.getErrors(); - Assert.assertEquals(0, errors.size()); + Assertions.assertEquals(0, errors.size()); } @Test public void handlesCommentsInTable() { String html = "
    text
    "; Document node = Jsoup.parseBodyFragment(html); - Assert.assertEquals("
    text
    ", TextUtil.stripNewlines(node.outerHtml())); + Assertions.assertEquals("
    text
    ", TextUtil.stripNewlines(node.outerHtml())); } @Test public void handlesQuotesInCommentsInScripts() { @@ -903,7 +902,7 @@ public class HtmlParserTest extends ExtendedITextTest { " // -->\n" + ""; Document node = Jsoup.parseBodyFragment(html); - Assert.assertEquals(""; Document body = Jsoup.parseBodyFragment(html); - Assert.assertEquals(" \n" + + Assertions.assertEquals(" \n" + "
    \n" + " some content\n" + "
    \n" + @@ -1096,61 +1095,61 @@ public void testInvalidTableContents() throws IOException { @Test public void testHtmlLowerCase() { String html = "
    One
    "; Document doc = Jsoup.parse(html); - Assert.assertEquals("
    One
    ", StringUtil.normaliseWhitespace(doc.outerHtml())); + Assertions.assertEquals("
    One
    ", StringUtil.normaliseWhitespace(doc.outerHtml())); Element div = doc.selectFirst("#1"); div.after("One"); - Assert.assertEquals("One", TextUtil.stripNewlines(div.nextElementSibling().outerHtml())); + Assertions.assertEquals("One", TextUtil.stripNewlines(div.nextElementSibling().outerHtml())); } @Test public void testHtmlLowerCaseAttributesOfVoidTags() { String html = "One"; Document doc = Jsoup.parse(html); - Assert.assertEquals(" \"One\" ", StringUtil.normaliseWhitespace(doc.outerHtml())); + Assertions.assertEquals(" \"One\" ", StringUtil.normaliseWhitespace(doc.outerHtml())); } @Test public void testHtmlLowerCaseAttributesForm() { String html = "
    "; Document doc = Jsoup.parse(html); - Assert.assertEquals("
    ", StringUtil.normaliseWhitespace(doc.body().html())); + Assertions.assertEquals("
    ", StringUtil.normaliseWhitespace(doc.body().html())); } @Test public void canPreserveTagCase() { Parser parser = Parser.htmlParser(); parser.settings(new ParseSettings(true, false)); Document doc = parser.parseInput("
    ", ""); - Assert.assertEquals("
    ", StringUtil.normaliseWhitespace(doc.outerHtml())); + Assertions.assertEquals("
    ", StringUtil.normaliseWhitespace(doc.outerHtml())); Element div = doc.selectFirst("#1"); div.after("One"); - Assert.assertEquals("One", TextUtil.stripNewlines(div.nextElementSibling().outerHtml())); + Assertions.assertEquals("One", TextUtil.stripNewlines(div.nextElementSibling().outerHtml())); } @Test public void canPreserveAttributeCase() { Parser parser = Parser.htmlParser(); parser.settings(new ParseSettings(false, true)); Document doc = parser.parseInput("
    ", ""); - Assert.assertEquals("
    ", StringUtil.normaliseWhitespace(doc.outerHtml())); + Assertions.assertEquals("
    ", StringUtil.normaliseWhitespace(doc.outerHtml())); Element div = doc.selectFirst("#1"); div.after("One"); - Assert.assertEquals("One", TextUtil.stripNewlines(div.nextElementSibling().outerHtml())); + Assertions.assertEquals("One", TextUtil.stripNewlines(div.nextElementSibling().outerHtml())); } @Test public void canPreserveBothCase() { Parser parser = Parser.htmlParser(); parser.settings(new ParseSettings(true, true)); Document doc = parser.parseInput("
    ", ""); - Assert.assertEquals("
    ", StringUtil.normaliseWhitespace(doc.outerHtml())); + Assertions.assertEquals("
    ", StringUtil.normaliseWhitespace(doc.outerHtml())); Element div = doc.selectFirst("#1"); div.after("One"); - Assert.assertEquals("One", TextUtil.stripNewlines(div.nextElementSibling().outerHtml())); + Assertions.assertEquals("One", TextUtil.stripNewlines(div.nextElementSibling().outerHtml())); } @Test public void handlesControlCodeInAttributeName() { Document doc = Jsoup.parse("

    OneTwo

    "); - Assert.assertEquals("

    OneTwo

    ", doc.body().html()); + Assertions.assertEquals("

    OneTwo

    ", doc.body().html()); } @Test public void caseSensitiveParseTree() { @@ -1158,14 +1157,14 @@ public void testInvalidTableContents() throws IOException { Parser parser = Parser.htmlParser(); parser.settings(preserveCase); Document doc = parser.parseInput(html, ""); - Assert.assertEquals(" A B ", StringUtil.normaliseWhitespace(doc.body().html())); + Assertions.assertEquals(" A B ", StringUtil.normaliseWhitespace(doc.body().html())); } @Test public void caseInsensitiveParseTree() { String html = "AB"; Parser parser = Parser.htmlParser(); Document doc = parser.parseInput(html, ""); - Assert.assertEquals(" A B ", StringUtil.normaliseWhitespace(doc.body().html())); + Assertions.assertEquals(" A B ", StringUtil.normaliseWhitespace(doc.body().html())); } @Test public void preservedCaseLinksCantNest() { @@ -1173,35 +1172,35 @@ public void testInvalidTableContents() throws IOException { Document doc = Parser.htmlParser() .settings(preserveCase) .parseInput(html, ""); - Assert.assertEquals("ONE Two", StringUtil.normaliseWhitespace(doc.body().html())); + Assertions.assertEquals("ONE Two", StringUtil.normaliseWhitespace(doc.body().html())); } @Test public void normalizesDiscordantTags() { Document document = Jsoup.parse("
    test

    "); - Assert.assertEquals("
    \n test\n
    \n

    ", document.body().html()); + Assertions.assertEquals("
    \n test\n
    \n

    ", document.body().html()); } @Test public void selfClosingVoidIsNotAnError() { String html = "

    test
    test

    "; Parser parser = Parser.htmlParser().setTrackErrors(5); parser.parseInput(html, ""); - Assert.assertEquals(0, parser.getErrors().size()); + Assertions.assertEquals(0, parser.getErrors().size()); - Assert.assertTrue(Jsoup.isValid(html, Safelist.basic())); + Assertions.assertTrue(Jsoup.isValid(html, Safelist.basic())); String clean = Jsoup.clean(html, Safelist.basic()); - Assert.assertEquals("

    test
    test

    ", clean); + Assertions.assertEquals("

    test
    test

    ", clean); } @Test public void selfClosingOnNonvoidIsError() { String html = "

    test

    Two
    "; Parser parser = Parser.htmlParser().setTrackErrors(5); parser.parseInput(html, ""); - Assert.assertEquals(1, parser.getErrors().size()); - Assert.assertEquals("18: Tag cannot be self closing; not a void tag", parser.getErrors().get(0).toString()); + Assertions.assertEquals(1, parser.getErrors().size()); + Assertions.assertEquals("18: Tag cannot be self closing; not a void tag", parser.getErrors().get(0).toString()); - Assert.assertFalse(Jsoup.isValid(html, Safelist.relaxed())); + Assertions.assertFalse(Jsoup.isValid(html, Safelist.relaxed())); String clean = Jsoup.clean(html, Safelist.relaxed()); - Assert.assertEquals("

    test

    Two
    ", StringUtil.normaliseWhitespace(clean)); + Assertions.assertEquals("

    test

    Two
    ", StringUtil.normaliseWhitespace(clean)); } @Test public void testTemplateInsideTable() throws IOException { @@ -1211,7 +1210,7 @@ public void testInvalidTableContents() throws IOException { Elements templates = doc.body().getElementsByTag("template"); for (Element template : templates) { - Assert.assertTrue(template.childNodes().size() > 1); + Assertions.assertTrue(template.childNodes().size() > 1); } } @@ -1224,53 +1223,53 @@ public void testInvalidTableContents() throws IOException { sb.append("

    One

    "); Document doc = Jsoup.parse(sb.toString()); - Assert.assertEquals(200, doc.select("span").size()); - Assert.assertEquals(1, doc.select("p").size()); + Assertions.assertEquals(200, doc.select("span").size()); + Assertions.assertEquals(1, doc.select("p").size()); } @Test public void commentAtEnd() { Document doc = Jsoup.parse("\n\nOne\nTwo\n"); Element pre = doc.selectFirst("pre"); - Assert.assertEquals("One\nTwo", pre.text()); - Assert.assertEquals("\nOne\nTwo\n", pre.wholeText()); + Assertions.assertEquals("One\nTwo", pre.text()); + Assertions.assertEquals("\nOne\nTwo\n", pre.wholeText()); } @Test public void handlesXmlDeclAndCommentsBeforeDoctype() throws IOException { File in = ParseTest.getFile("/htmltests/comments.html"); Document doc = Jsoup.parse(in, "UTF-8"); - Assert.assertEquals(" A Certain Kind of Test

    Hello

    h1> (There is a UTF8 hidden BOM at the top of this file.) ", + Assertions.assertEquals(" A Certain Kind of Test

    Hello

    h1> (There is a UTF8 hidden BOM at the top of this file.) ", StringUtil.normaliseWhitespace(doc.html())); - Assert.assertEquals("A Certain Kind of Test", doc.head().select("title").text()); + Assertions.assertEquals("A Certain Kind of Test", doc.head().select("title").text()); } @Test public void selfClosingTextAreaDoesntLeaveDroppings() { // https://github.com/jhy/jsoup/issues/1220 Document doc = Jsoup.parse("
    ", TextUtil.stripNewlines(doc.body().html())); + Assertions.assertFalse(doc.body().html().contains("<")); + Assertions.assertFalse(doc.body().html().contains(">")); + Assertions.assertEquals("
    ", TextUtil.stripNewlines(doc.body().html())); } @Test public void testNoSpuriousSpace() { Document doc = Jsoup.parse("JustOneTwo"); - Assert.assertEquals("JustOneTwo", doc.body().html()); - Assert.assertEquals("JustOneTwo", doc.body().text()); + Assertions.assertEquals("JustOneTwo", doc.body().html()); + Assertions.assertEquals("JustOneTwo", doc.body().text()); } @Test public void pTagsGetIndented() { String html = ""; Document doc = Jsoup.parse(html); - Assert.assertEquals("
    \n" + + Assertions.assertEquals("
    \n" + "

    One

    \n" + "

    Two

    \n" + "
    ", doc.body().html()); @@ -1280,14 +1279,14 @@ public void pTagsGetIndented() { public void indentRegardlessOfCase() { String html = "

    1

    2

    "; Document doc = Jsoup.parse(html); - Assert.assertEquals( + Assertions.assertEquals( "\n" + "

    1

    \n" + "

    2

    \n" + "", doc.body().outerHtml()); Document caseDoc = Jsoup.parse(html, "", Parser.htmlParser().settings(preserveCase)); - Assert.assertEquals( + Assertions.assertEquals( "\n" + "

    1

    \n" + "

    2

    \n" + @@ -1299,10 +1298,10 @@ public void testH20() { // https://github.com/jhy/jsoup/issues/731 String html = "H2O"; String clean = Jsoup.clean(html, Safelist.basic()); - Assert.assertEquals("H2O", clean); + Assertions.assertEquals("H2O", clean); Document doc = Jsoup.parse(html); - Assert.assertEquals("H2O", doc.text()); + Assertions.assertEquals("H2O", doc.text()); } @Test @@ -1310,17 +1309,17 @@ public void testUNewlines() { // https://github.com/jhy/jsoup/issues/851 String html = "test on fire"; String clean = Jsoup.clean(html, Safelist.basic()); - Assert.assertEquals("test on fire", clean); + Assertions.assertEquals("test on fire", clean); Document doc = Jsoup.parse(html); - Assert.assertEquals("test on fire", doc.text()); + Assertions.assertEquals("test on fire", doc.text()); } @Test public void testFarsi() { // https://github.com/jhy/jsoup/issues/1227 String text = "نیمه\u200Cشب"; Document doc = Jsoup.parse("

    " + text); - Assert.assertEquals(text, doc.text()); + Assertions.assertEquals(text, doc.text()); } @Test public void testStartOptGroup() { @@ -1337,49 +1336,49 @@ public void testUNewlines() { ""; Document doc = Jsoup.parse(html); Element select = doc.selectFirst("select"); - Assert.assertEquals(2, select.childrenSize()); + Assertions.assertEquals(2, select.childrenSize()); - Assert.assertEquals(" ", select.html()); + Assertions.assertEquals(" ", select.html()); } @Test public void readerClosedAfterParse() { Document doc = Jsoup.parse("Hello"); TreeBuilder treeBuilder = doc.parser().getTreeBuilder(); - Assert.assertNull(treeBuilder.reader); - Assert.assertNull(treeBuilder.tokeniser); + Assertions.assertNull(treeBuilder.reader); + Assertions.assertNull(treeBuilder.tokeniser); } @Test public void scriptInDataNode() { Document doc = Jsoup.parse(""); - Assert.assertTrue(doc.selectFirst("script").childNode(0) instanceof DataNode); - Assert.assertTrue(doc.selectFirst("style").childNode(0) instanceof DataNode); + Assertions.assertTrue(doc.selectFirst("script").childNode(0) instanceof DataNode); + Assertions.assertTrue(doc.selectFirst("style").childNode(0) instanceof DataNode); doc = Jsoup.parse("", "", Parser.htmlParser().settings(preserveCase)); - Assert.assertTrue(doc.selectFirst("script").childNode(0) instanceof DataNode); - Assert.assertTrue(doc.selectFirst("style").childNode(0) instanceof DataNode); + Assertions.assertTrue(doc.selectFirst("script").childNode(0) instanceof DataNode); + Assertions.assertTrue(doc.selectFirst("style").childNode(0) instanceof DataNode); } @Test public void textareaValue() { String html = ""; Document doc = Jsoup.parse(html); - Assert.assertEquals("YES YES", doc.selectFirst("textarea").val()); + Assertions.assertEquals("YES YES", doc.selectFirst("textarea").val()); doc = Jsoup.parse(html, "", Parser.htmlParser().settings(preserveCase)); - Assert.assertEquals("YES YES", doc.selectFirst("textarea").val()); + Assertions.assertEquals("YES YES", doc.selectFirst("textarea").val()); } @Test public void preserveWhitespaceInHead() { String html = "\n\n\n\nHello\n\n\n

    One

    \n\n\n"; Document doc = Jsoup.parse(html); doc.outputSettings().prettyPrint(false); - Assert.assertEquals("\n\n\nHello\n\n\n

    One

    \n\n\n", doc.outerHtml()); + Assertions.assertEquals("\n\n\nHello\n\n\n

    One

    \n\n\n", doc.outerHtml()); } @Test public void handleContentAfterBody() { String html = "One

    Hello!

    There

    "; Document doc = Jsoup.parse(html); doc.outputSettings().prettyPrint(false); - Assert.assertEquals("One

    Hello!

    There

    ", doc.outerHtml()); + Assertions.assertEquals("One

    Hello!

    There

    ", doc.outerHtml()); } @Test public void preservesTabs() { @@ -1390,23 +1389,23 @@ public void testUNewlines() { Element pre = doc.selectFirst("pre"); Element span = doc.selectFirst("span"); - Assert.assertEquals("One\tTwo", pre.text()); - Assert.assertEquals("Three Four", span.text()); // normalized, including overall trim - Assert.assertEquals("\tThree\tFour", span.wholeText()); // text normalizes, wholeText retains original spaces incl tabs - Assert.assertEquals("One\tTwo Three Four", doc.body().text()); + Assertions.assertEquals("One\tTwo", pre.text()); + Assertions.assertEquals("Three Four", span.text()); // normalized, including overall trim + Assertions.assertEquals("\tThree\tFour", span.wholeText()); // text normalizes, wholeText retains original spaces incl tabs + Assertions.assertEquals("One\tTwo Three Four", doc.body().text()); - Assert.assertEquals("
    One\tTwo
    Three Four", doc.body().html()); // html output provides normalized space, incl tab in pre but not in span + Assertions.assertEquals("
    One\tTwo
    Three Four", doc.body().html()); // html output provides normalized space, incl tab in pre but not in span doc.outputSettings().prettyPrint(false); - Assert.assertEquals(html, doc.body().html()); // disabling pretty-printing - round-trips the tab throughout, as no normalization occurs + Assertions.assertEquals(html, doc.body().html()); // disabling pretty-printing - round-trips the tab throughout, as no normalization occurs } @Test public void canDetectAutomaticallyAddedElements() { String bare = ""; String full = "Check

    One

    "; - Assert.assertTrue(didAddElements(bare)); - Assert.assertFalse(didAddElements(full)); + Assertions.assertTrue(didAddElements(bare)); + Assertions.assertFalse(didAddElements(full)); } private boolean didAddElements(String input) { diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/parser/HtmlTreeBuilderStateTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/parser/HtmlTreeBuilderStateTest.java index 8508d0f4f3..6386a635a8 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/parser/HtmlTreeBuilderStateTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/parser/HtmlTreeBuilderStateTest.java @@ -25,10 +25,9 @@ This file is part of the iText (R) project. import com.itextpdf.styledxmlparser.jsoup.Jsoup; import com.itextpdf.styledxmlparser.jsoup.parser.HtmlTreeBuilderState.Constants; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.lang.reflect.Field; import java.lang.reflect.Modifier; @@ -36,7 +35,7 @@ This file is part of the iText (R) project. import java.util.Arrays; import java.util.List; -@Category(UnitTest.class) +@Tag("UnitTest") public class HtmlTreeBuilderStateTest extends ExtendedITextTest { static List findConstantArrays(Class aClass) throws IllegalAccessException { ArrayList array = new ArrayList<>(); @@ -56,7 +55,7 @@ static void ensureSorted(List constants) { for (Object[] array : constants) { Object[] copy = Arrays.copyOf(array, array.length); Arrays.sort(array); - Assert.assertArrayEquals(array, copy); + Assertions.assertArrayEquals(array, copy); } } @@ -64,7 +63,7 @@ static void ensureSorted(List constants) { public void ensureArraysAreSorted() throws IllegalAccessException { List constants = findConstantArrays(Constants.class); ensureSorted(constants); - Assert.assertEquals(38, constants.size()); + Assertions.assertEquals(38, constants.size()); } @@ -80,7 +79,7 @@ public void nestedAnchorElements01() { " \n" + ""; String s = Jsoup.parse(html).toString(); - Assert.assertEquals(" \n" + + Assertions.assertEquals(" \n" + " \n" + " \n" + "
    \n" + @@ -104,7 +103,7 @@ public void nestedAnchorElements02() { " \n" + ""; String s = Jsoup.parse(html).toString(); - Assert.assertEquals(" \n" + + Assertions.assertEquals(" \n" + " \n" + " \n" + "
    \n" + diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/parser/MultiLocaleTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/parser/MultiLocaleTest.java index 46fd82dece..49cc9f92bb 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/parser/MultiLocaleTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/parser/MultiLocaleTest.java @@ -24,42 +24,33 @@ This file is part of the iText (R) project. import com.itextpdf.styledxmlparser.jsoup.nodes.Attributes; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.After; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + import java.util.Arrays; import java.util.Collection; import java.util.Locale; -@RunWith(Parameterized.class) -@Category(UnitTest.class) +@org.junit.jupiter.api.Tag("UnitTest") public class MultiLocaleTest extends ExtendedITextTest { private final Locale defaultLocale = Locale.getDefault(); - @Parameterized.Parameters public static Collection locales() { return Arrays.asList(Locale.ENGLISH, new Locale("tr")); } - @After + @AfterEach public void setDefaultLocale() { Locale.setDefault(defaultLocale); } - private Locale locale; - - public MultiLocaleTest(Locale locale) { - this.locale = locale; - } - - @Test - public void caseSupport() { + @ParameterizedTest + @MethodSource("locales") + public void caseSupport(Locale locale) { Locale.setDefault(locale); ParseSettings bothOn = new ParseSettings(true, true); @@ -67,31 +58,33 @@ public void caseSupport() { ParseSettings tagOn = new ParseSettings(true, false); ParseSettings attrOn = new ParseSettings(false, true); - Assert.assertEquals("IMG", bothOn.normalizeTag("IMG")); - Assert.assertEquals("ID", bothOn.normalizeAttribute("ID")); + Assertions.assertEquals("IMG", bothOn.normalizeTag("IMG")); + Assertions.assertEquals("ID", bothOn.normalizeAttribute("ID")); - Assert.assertEquals("img", bothOff.normalizeTag("IMG")); - Assert.assertEquals("id", bothOff.normalizeAttribute("ID")); + Assertions.assertEquals("img", bothOff.normalizeTag("IMG")); + Assertions.assertEquals("id", bothOff.normalizeAttribute("ID")); - Assert.assertEquals("IMG", tagOn.normalizeTag("IMG")); - Assert.assertEquals("id", tagOn.normalizeAttribute("ID")); + Assertions.assertEquals("IMG", tagOn.normalizeTag("IMG")); + Assertions.assertEquals("id", tagOn.normalizeAttribute("ID")); - Assert.assertEquals("img", attrOn.normalizeTag("IMG")); - Assert.assertEquals("ID", attrOn.normalizeAttribute("ID")); + Assertions.assertEquals("img", attrOn.normalizeTag("IMG")); + Assertions.assertEquals("ID", attrOn.normalizeAttribute("ID")); } - @Test - public void attributeCaseNormalization() { + @ParameterizedTest + @MethodSource("locales") + public void attributeCaseNormalization(Locale locale) { Locale.setDefault(locale); ParseSettings parseSettings = new ParseSettings(false, false); String normalizedAttribute = parseSettings.normalizeAttribute("HIDDEN"); - Assert.assertEquals("hidden", normalizedAttribute); + Assertions.assertEquals("hidden", normalizedAttribute); } - @Test - public void attributesCaseNormalization() { + @ParameterizedTest + @MethodSource("locales") + public void attributesCaseNormalization(Locale locale) { Locale.setDefault(locale); ParseSettings parseSettings = new ParseSettings(false, false); @@ -100,15 +93,16 @@ public void attributesCaseNormalization() { Attributes normalizedAttributes = parseSettings.normalizeAttributes(attributes); - Assert.assertEquals("item", normalizedAttributes.asList().get(0).getKey()); + Assertions.assertEquals("item", normalizedAttributes.asList().get(0).getKey()); } - @Test - public void canBeInsensitive() { + @ParameterizedTest + @MethodSource("locales") + public void canBeInsensitive(Locale locale) { Locale.setDefault(locale); Tag script1 = Tag.valueOf("script", ParseSettings.htmlDefault); Tag script2 = Tag.valueOf("SCRIPT", ParseSettings.htmlDefault); - Assert.assertSame(script1, script2); + Assertions.assertSame(script1, script2); } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/parser/ParserItTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/parser/ParserItTest.java index 6383bfe7b8..5ea842ca52 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/parser/ParserItTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/parser/ParserItTest.java @@ -24,16 +24,15 @@ This file is part of the iText (R) project. import com.itextpdf.styledxmlparser.jsoup.nodes.Document; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; /** * Longer running Parser tests. */ -@Category(UnitTest.class) +@Tag("UnitTest") public class ParserItTest extends ExtendedITextTest { @Test @@ -75,9 +74,9 @@ public void handlesDeepStack() { Document doc = Parser.parseBodyFragment(longBody.toString(), ""); // Assert - Assert.assertEquals(2, doc.body().childNodeSize()); - Assert.assertEquals(25000, doc.select("dd").size()); - Assert.assertTrue((System.nanoTime() - start) / 1000000 < 20000); // I get ~ 1.5 seconds, but others have reported slower + Assertions.assertEquals(2, doc.body().childNodeSize()); + Assertions.assertEquals(25000, doc.select("dd").size()); + Assertions.assertTrue((System.nanoTime() - start) / 1000000 < 20000); // I get ~ 1.5 seconds, but others have reported slower // was originally much longer, or stack overflow. } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/parser/ParserTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/parser/ParserTest.java index 00cb914dd3..84942ec68e 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/parser/ParserTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/parser/ParserTest.java @@ -23,18 +23,17 @@ This file is part of the iText (R) project. package com.itextpdf.styledxmlparser.jsoup.parser; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class ParserTest extends ExtendedITextTest { @Test public void unescapeEntities() { String s = Parser.unescapeEntities("One & Two", false); - Assert.assertEquals("One & Two", s); + Assertions.assertEquals("One & Two", s); } @Test @@ -45,6 +44,6 @@ public void unescapeEntitiesHandlesLargeInput() { } while (longBody.length() < 64 * 1024); String body = longBody.toString(); - Assert.assertEquals(body, Parser.unescapeEntities(body, false)); + Assertions.assertEquals(body, Parser.unescapeEntities(body, false)); } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/parser/TagTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/parser/TagTest.java index 0d5671b95c..a5e7b21dd8 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/parser/TagTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/parser/TagTest.java @@ -23,75 +23,73 @@ This file is part of the iText (R) project. package com.itextpdf.styledxmlparser.jsoup.parser; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** Tag tests. */ -@Category(UnitTest.class) +@org.junit.jupiter.api.Tag("UnitTest") public class TagTest extends ExtendedITextTest { @Test public void isCaseSensitive() { Tag p1 = Tag.valueOf("P"); Tag p2 = Tag.valueOf("p"); - Assert.assertNotEquals(p1, p2); + Assertions.assertNotEquals(p1, p2); } @Test public void trims() { Tag p1 = Tag.valueOf("p"); Tag p2 = Tag.valueOf(" p "); - Assert.assertEquals(p1, p2); + Assertions.assertEquals(p1, p2); } @Test public void equality() { Tag p1 = Tag.valueOf("p"); Tag p2 = Tag.valueOf("p"); - Assert.assertEquals(p1, p2); - Assert.assertSame(p1, p2); + Assertions.assertEquals(p1, p2); + Assertions.assertSame(p1, p2); } @Test public void divSemantics() { Tag div = Tag.valueOf("div"); - Assert.assertTrue(div.isBlock()); - Assert.assertTrue(div.formatAsBlock()); + Assertions.assertTrue(div.isBlock()); + Assertions.assertTrue(div.formatAsBlock()); } @Test public void pSemantics() { Tag p = Tag.valueOf("p"); - Assert.assertTrue(p.isBlock()); - Assert.assertFalse(p.formatAsBlock()); + Assertions.assertTrue(p.isBlock()); + Assertions.assertFalse(p.formatAsBlock()); } @Test public void imgSemantics() { Tag img = Tag.valueOf("img"); - Assert.assertTrue(img.isInline()); - Assert.assertTrue(img.isSelfClosing()); - Assert.assertFalse(img.isBlock()); + Assertions.assertTrue(img.isInline()); + Assertions.assertTrue(img.isSelfClosing()); + Assertions.assertFalse(img.isBlock()); } @Test public void defaultSemantics() { Tag foo = Tag.valueOf("FOO"); // not defined Tag foo2 = Tag.valueOf("FOO"); - Assert.assertEquals(foo, foo2); - Assert.assertTrue(foo.isInline()); - Assert.assertTrue(foo.formatAsBlock()); + Assertions.assertEquals(foo, foo2); + Assertions.assertTrue(foo.isInline()); + Assertions.assertTrue(foo.formatAsBlock()); } @Test public void valueOfChecksNotNull() { - Assert.assertThrows(IllegalArgumentException.class, () -> Tag.valueOf(null)); + Assertions.assertThrows(IllegalArgumentException.class, () -> Tag.valueOf(null)); } @Test public void valueOfChecksNotEmpty() { - Assert.assertThrows(IllegalArgumentException.class, () -> Tag.valueOf(" ")); + Assertions.assertThrows(IllegalArgumentException.class, () -> Tag.valueOf(" ")); } @Test public void knownTags() { - Assert.assertTrue(Tag.isKnownTag("div")); - Assert.assertFalse(Tag.isKnownTag("explain")); + Assertions.assertTrue(Tag.isKnownTag("div")); + Assertions.assertFalse(Tag.isKnownTag("explain")); } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/parser/TokenQueueTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/parser/TokenQueueTest.java index f36b502c0d..75a0bc8855 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/parser/TokenQueueTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/parser/TokenQueueTest.java @@ -24,15 +24,14 @@ This file is part of the iText (R) project. import com.itextpdf.styledxmlparser.jsoup.Jsoup; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; /** * Token queue tests. */ -@Category(UnitTest.class) +@Tag("UnitTest") public class TokenQueueTest extends ExtendedITextTest { @Test public void chompBalanced() { @@ -41,9 +40,9 @@ public void chompBalanced() { String guts = tq.chompBalanced('(', ')'); String remainder = tq.remainder(); - Assert.assertEquals(":contains", pre); - Assert.assertEquals("one (two) three", guts); - Assert.assertEquals(" four", remainder); + Assertions.assertEquals(":contains", pre); + Assertions.assertEquals("one (two) three", guts); + Assertions.assertEquals(" four", remainder); } @Test public void chompEscapedBalanced() { @@ -52,39 +51,39 @@ public void chompBalanced() { String guts = tq.chompBalanced('(', ')'); String remainder = tq.remainder(); - Assert.assertEquals(":contains", pre); - Assert.assertEquals("one (two) \\( \\) \\) three", guts); - Assert.assertEquals("one (two) ( ) ) three", TokenQueue.unescape(guts)); - Assert.assertEquals(" four", remainder); + Assertions.assertEquals(":contains", pre); + Assertions.assertEquals("one (two) \\( \\) \\) three", guts); + Assertions.assertEquals("one (two) ( ) ) three", TokenQueue.unescape(guts)); + Assertions.assertEquals(" four", remainder); } @Test public void chompBalancedMatchesAsMuchAsPossible() { TokenQueue tq = new TokenQueue("unbalanced(something(or another)) else"); tq.consumeTo("("); String match = tq.chompBalanced('(', ')'); - Assert.assertEquals("something(or another)", match); + Assertions.assertEquals("something(or another)", match); } @Test public void unescape() { - Assert.assertEquals("one ( ) \\", TokenQueue.unescape("one \\( \\) \\\\")); + Assertions.assertEquals("one ( ) \\", TokenQueue.unescape("one \\( \\) \\\\")); } @Test public void chompToIgnoreCase() { String t = ""; TokenQueue tq = new TokenQueue(t); String data = tq.chompToIgnoreCase("one < two ", data); + Assertions.assertEquals(" third "; TokenQueue tq = new TokenQueue(t); String data = tq.chompToIgnoreCase(""); - Assert.assertEquals(""); - Assert.assertEquals(" third ", data); + Assertions.assertEquals(" third ", data); } @Test public void testNestedQuotes() { @@ -106,7 +105,7 @@ public void chompBalanced() { } private static void validateNestedQuotes(String html, String selector) { - Assert.assertEquals("#identifier", Jsoup.parse(html).select(selector).first().cssSelector()); + Assertions.assertEquals("#identifier", Jsoup.parse(html).select(selector).first().cssSelector()); } @Test @@ -115,9 +114,9 @@ public void chompBalancedThrowIllegalArgumentException() { TokenQueue tq = new TokenQueue("unbalanced(something(or another)) else"); tq.consumeTo("("); tq.chompBalanced('(', '+'); - Assert.fail("should have thrown IllegalArgumentException"); + Assertions.fail("should have thrown IllegalArgumentException"); } catch (IllegalArgumentException expected) { - Assert.assertEquals("Did not find balanced marker at 'something(or another)) else'", expected.getMessage()); + Assertions.assertEquals("Did not find balanced marker at 'something(or another)) else'", expected.getMessage()); } } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/parser/TokeniserStateTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/parser/TokeniserStateTest.java index 156981f6d6..e6ced1ca60 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/parser/TokeniserStateTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/parser/TokeniserStateTest.java @@ -31,14 +31,13 @@ This file is part of the iText (R) project. import com.itextpdf.styledxmlparser.jsoup.nodes.TextNode; import com.itextpdf.styledxmlparser.jsoup.select.Elements; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.util.Arrays; -@Category(UnitTest.class) +@Tag("UnitTest") public class TokeniserStateTest extends ExtendedITextTest { final char[] whiteSpace = { '\t', '\n', '\r', '\f', ' ' }; @@ -54,7 +53,7 @@ public void ensureSearchArraysAreSorted() { for (char[] array : arrays) { char[] copy = Arrays.copyOf(array, array.length); Arrays.sort(array); - Assert.assertArrayEquals(array, copy); + Assertions.assertArrayEquals(array, copy); } } @@ -63,7 +62,7 @@ public void testCharacterReferenceInRcdata() { String body = ""; Document doc = Jsoup.parse(body); Elements els = doc.select("textarea"); - Assert.assertEquals("You&I", els.text()); + Assertions.assertEquals("You&I", els.text()); } @Test @@ -72,7 +71,7 @@ public void testBeforeTagName() { String body = MessageFormatUtil.format("test
    ", c); Document doc = Jsoup.parse(body); Elements els = doc.select("div"); - Assert.assertEquals("test", els.text()); + Assertions.assertEquals("test", els.text()); } } @@ -85,22 +84,22 @@ public void testEndTagOpen() { body = "
    hello worldhello world
    "; doc = Jsoup.parse(body); els = doc.select("div"); - Assert.assertEquals("hello world", els.text()); + Assertions.assertEquals("hello world", els.text()); body = "
    fake
    "; doc = Jsoup.parse(body); els = doc.select("div"); - Assert.assertEquals("fake", els.text()); + Assertions.assertEquals("fake", els.text()); body = "
    fake"; doc = Jsoup.parse(body); els = doc.select("div"); - Assert.assertEquals("fake", els.text()); + Assertions.assertEquals("fake", els.text()); } @Test @@ -112,17 +111,17 @@ public void testRcdataLessthanSign() { body = ""; doc = Jsoup.parse(body); els = doc.select("textarea"); - Assert.assertEquals("", els.text()); + Assertions.assertEquals("", els.text()); body = ""; doc = Jsoup.parse(body); els = doc.select("textarea"); - Assert.assertEquals("hello worlddata", c); Document doc = Jsoup.parse(body); Elements els = doc.select("textarea"); - Assert.assertEquals("data", els.text()); + Assertions.assertEquals("data", els.text()); } } @@ -142,10 +141,10 @@ public void testCommentEndCoverage() { Element body = doc.body(); Comment comment = (Comment) body.childNode(1); - Assert.assertEquals("
    --! --- ", comment.getData()); + Assertions.assertEquals("
    --! --- ", comment.getData()); Element p = body.child(1); TextNode text = (TextNode) p.childNode(0); - Assert.assertEquals("Hello", text.getWholeText()); + Assertions.assertEquals("Hello", text.getWholeText()); } @Test @@ -155,10 +154,10 @@ public void testCommentEndBangCoverage() { Element body = doc.body(); Comment comment = (Comment) body.childNode(1); - Assert.assertEquals("
    --!-", comment.getData()); + Assertions.assertEquals("
    --!-", comment.getData()); Element p = body.child(1); TextNode text = (TextNode) p.childNode(0); - Assert.assertEquals("Hello", text.getWholeText()); + Assertions.assertEquals("Hello", text.getWholeText()); } @Test @@ -176,7 +175,7 @@ public void testPublicIdentifiersWithWhitespace() { }; for (String html : htmls) { Document doc = Jsoup.parse(html); - Assert.assertEquals(expectedOutput, doc.childNode(0).outerHtml()); + Assertions.assertEquals(expectedOutput, doc.childNode(0).outerHtml()); } } } @@ -197,7 +196,7 @@ public void testSystemIdentifiersWithWhitespace() { }; for (String html : htmls) { Document doc = Jsoup.parse(html); - Assert.assertEquals(expectedOutput, doc.childNode(0).outerHtml()); + Assertions.assertEquals(expectedOutput, doc.childNode(0).outerHtml()); } } } @@ -217,7 +216,7 @@ public void testPublicAndSystemIdentifiersWithWhitespace() { }; for (String html : htmls) { Document doc = Jsoup.parse(html); - Assert.assertEquals(expectedOutput, doc.childNode(0).outerHtml()); + Assertions.assertEquals(expectedOutput, doc.childNode(0).outerHtml()); } } } @@ -227,7 +226,7 @@ public void testPublicAndSystemIdentifiersWithWhitespace() { // out of spec, but clear author intent String html = "Two"; Document doc = Jsoup.parse(html); - Assert.assertEquals("

    Two
    ", TextUtil.stripNewlines(doc.body().html())); + Assertions.assertEquals("

    Two
    ", TextUtil.stripNewlines(doc.body().html())); } @Test @@ -240,7 +239,7 @@ public void testUnconsumeAtBufferBoundary() { Parser.parseFragment(paddedSnippet, null, "", errorList); - Assert.assertEquals(CharacterReader.readAheadLimit - 1, errorList.get(0).getPosition()); + Assertions.assertEquals(CharacterReader.readAheadLimit - 1, errorList.get(0).getPosition()); } @Test @@ -261,7 +260,7 @@ public void testOpeningAngleBracketInsteadOfAttribute() { Parser.parseFragment(triggeringSnippet, null, "", errorList); - Assert.assertEquals(6, errorList.get(0).getPosition()); + Assertions.assertEquals(6, errorList.get(0).getPosition()); } @Test @@ -271,7 +270,7 @@ public void testMalformedSelfClosingTag() { Parser.parseFragment(triggeringSnippet, null, "", errorList); - Assert.assertEquals(7, errorList.get(0).getPosition()); + Assertions.assertEquals(7, errorList.get(0).getPosition()); } @Test @@ -281,35 +280,35 @@ public void testOpeningAngleBracketInTagName() { Parser.parseFragment(triggeringSnippet, null, "", errorList); - Assert.assertEquals(5, errorList.get(0).getPosition()); + Assertions.assertEquals(5, errorList.get(0).getPosition()); } @Test public void rcData() { Document doc = Jsoup.parse("One \0Two"); - Assert.assertEquals("One �Two", doc.title()); + Assertions.assertEquals("One �Two", doc.title()); } @Test public void plaintext() { Document doc = Jsoup.parse("
    One<div>Two</plaintext>\0no < Return"); - Assert.assertEquals("<html><head></head><body><div>One<plaintext>&lt;div&gt;Two&lt;/plaintext&gt;�no &lt; Return</plaintext></div></body></html>", TextUtil.stripNewlines(doc.html())); + Assertions.assertEquals("<html><head></head><body><div>One<plaintext>&lt;div&gt;Two&lt;/plaintext&gt;�no &lt; Return</plaintext></div></body></html>", TextUtil.stripNewlines(doc.html())); } @Test public void nullInTag() { Document doc = Jsoup.parse("<di\0v>One</di\0v>Two"); - Assert.assertEquals("<di�v>\n One\n</di�v>Two", doc.body().html()); + Assertions.assertEquals("<di�v>\n One\n</di�v>Two", doc.body().html()); } @Test public void attributeValUnquoted() { Document doc = Jsoup.parse("<p name=foo&lt;bar>"); Element p = doc.selectFirst("p"); - Assert.assertEquals("foo<bar", p.attr("name")); + Assertions.assertEquals("foo<bar", p.attr("name")); doc = Jsoup.parse("<p foo="); - Assert.assertEquals("<p foo></p>", doc.body().html()); + Assertions.assertEquals("<p foo></p>", doc.body().html()); } @Test @@ -317,8 +316,8 @@ public void testRCDATAEndTagNameDiffTag() { String body = "<textarea>data</textare >"; ParseErrorList errorList = ParseErrorList.tracking(1); Parser.parseFragment(body, null, "", errorList); - Assert.assertEquals(1, errorList.size()); - Assert.assertTrue(errorList.get(0).getErrorMessage() + Assertions.assertEquals(1, errorList.size()); + Assertions.assertTrue(errorList.get(0).getErrorMessage() .contains("Unexpected token")); } @@ -327,7 +326,7 @@ public void testRCDATAEndTagNameValidSlash() { String body = "<textarea>data</textarea/>"; Document doc = Jsoup.parse(body); Elements els = doc.select("textarea"); - Assert.assertEquals("data", els.text()); + Assertions.assertEquals("data", els.text()); } @Test @@ -335,8 +334,8 @@ public void testRCDATAEndTagNameInvalidSlash() { String body = "<textarea>data</textare/>"; ParseErrorList errorList = ParseErrorList.tracking(1); Parser.parseFragment(body, null, "", errorList); - Assert.assertEquals(1, errorList.size()); - Assert.assertTrue(errorList.get(0).getErrorMessage() + Assertions.assertEquals(1, errorList.size()); + Assertions.assertTrue(errorList.get(0).getErrorMessage() .contains("Unexpected token")); } @@ -345,7 +344,7 @@ public void scriptDataEscapeStartDashValid() { String body = "<script><!-- text --></script>"; ParseErrorList errorList = ParseErrorList.tracking(1); Parser.parseFragment(body, null, "", errorList); - Assert.assertEquals(0, errorList.size()); + Assertions.assertEquals(0, errorList.size()); } @Test @@ -353,7 +352,7 @@ public void scriptDataEscapeStartDashInvalid() { String body = "<script><!- text --></script>"; ParseErrorList errorList = ParseErrorList.tracking(1); Parser.parseFragment(body, null, "", errorList); - Assert.assertEquals(0, errorList.size()); + Assertions.assertEquals(0, errorList.size()); } @Test @@ -361,8 +360,8 @@ public void scriptDataEscapedEmpty() { String body = "<script><!-- "; ParseErrorList errorList = ParseErrorList.tracking(1); Parser.parseFragment(body, null, "", errorList); - Assert.assertEquals(1, errorList.size()); - Assert.assertTrue(errorList.get(0).getErrorMessage() + Assertions.assertEquals(1, errorList.size()); + Assertions.assertTrue(errorList.get(0).getErrorMessage() .contains("Unexpectedly reached end of file (EOF) in input state")); } @@ -371,7 +370,7 @@ public void scriptDataEscapedStartTag() { String body = "<script><!--<</script>"; ParseErrorList errorList = ParseErrorList.tracking(1); Parser.parseFragment(body, null, "", errorList); - Assert.assertEquals(0, errorList.size()); + Assertions.assertEquals(0, errorList.size()); } @Test @@ -379,8 +378,8 @@ public void scriptDataEscapedNullChar() { String body = "<script><!--a\0"; ParseErrorList errorList = ParseErrorList.tracking(1); Parser.parseFragment(body, null, "", errorList); - Assert.assertEquals(1, errorList.size()); - Assert.assertTrue(errorList.get(0).getErrorMessage() + Assertions.assertEquals(1, errorList.size()); + Assertions.assertTrue(errorList.get(0).getErrorMessage() .contains("Unexpected character")); } @@ -389,8 +388,8 @@ public void scriptDataEscapedDashEmpty() { String body = "<script><!-- -"; ParseErrorList errorList = ParseErrorList.tracking(1); Parser.parseFragment(body, null, "", errorList); - Assert.assertEquals(1, errorList.size()); - Assert.assertTrue(errorList.get(0).getErrorMessage() + Assertions.assertEquals(1, errorList.size()); + Assertions.assertTrue(errorList.get(0).getErrorMessage() .contains("Unexpectedly reached end of file (EOF) in input state")); } @@ -399,7 +398,7 @@ public void scriptDataEscapedDashStTag() { String body = "<script><!-- -<</script>"; ParseErrorList errorList = ParseErrorList.tracking(1); Parser.parseFragment(body, null, "", errorList); - Assert.assertEquals(0, errorList.size()); + Assertions.assertEquals(0, errorList.size()); } @Test @@ -407,8 +406,8 @@ public void scriptDataEscapedDashNullChar() { String body = "<script><!-- -\0"; ParseErrorList errorList = ParseErrorList.tracking(1); Parser.parseFragment(body, null, "", errorList); - Assert.assertEquals(1, errorList.size()); - Assert.assertTrue(errorList.get(0).getErrorMessage() + Assertions.assertEquals(1, errorList.size()); + Assertions.assertTrue(errorList.get(0).getErrorMessage() .contains("Unexpected character")); } @@ -417,8 +416,8 @@ public void scriptDataEscapedDashDashEmpty() { String body = "<script><!-- --"; ParseErrorList errorList = ParseErrorList.tracking(1); Parser.parseFragment(body, null, "", errorList); - Assert.assertEquals(1, errorList.size()); - Assert.assertTrue(errorList.get(0).getErrorMessage() + Assertions.assertEquals(1, errorList.size()); + Assertions.assertTrue(errorList.get(0).getErrorMessage() .contains("Unexpectedly reached end of file (EOF) in input state")); } @@ -427,7 +426,7 @@ public void scriptDataEscapedDashDashStTag() { String body = "<script><!-- --<</script>"; ParseErrorList errorList = ParseErrorList.tracking(1); Parser.parseFragment(body, null, "", errorList); - Assert.assertEquals(0, errorList.size()); + Assertions.assertEquals(0, errorList.size()); } @Test @@ -435,8 +434,8 @@ public void scriptDataEscapedDashDashNullChar() { String body = "<script><!-- --\0"; ParseErrorList errorList = ParseErrorList.tracking(1); Parser.parseFragment(body, null, "", errorList); - Assert.assertEquals(1, errorList.size()); - Assert.assertTrue(errorList.get(0).getErrorMessage() + Assertions.assertEquals(1, errorList.size()); + Assertions.assertTrue(errorList.get(0).getErrorMessage() .contains("Unexpected character")); } @@ -445,7 +444,7 @@ public void scriptDataEscapedEndTagOpen() { String body = "<script><!-- --</---></script>"; ParseErrorList errorList = ParseErrorList.tracking(1); Parser.parseFragment(body, null, "", errorList); - Assert.assertEquals(0, errorList.size()); + Assertions.assertEquals(0, errorList.size()); } @Test @@ -453,8 +452,8 @@ public void scriptDataDoubleEscapedNullChar() { String body = "<script><!--<script><\0!-"; ParseErrorList errorList = ParseErrorList.tracking(1); Parser.parseFragment(body, null, "", errorList); - Assert.assertEquals(1, errorList.size()); - Assert.assertTrue(errorList.get(0).getErrorMessage() + Assertions.assertEquals(1, errorList.size()); + Assertions.assertTrue(errorList.get(0).getErrorMessage() .contains("Unexpected character")); } @@ -463,8 +462,8 @@ public void scriptDataDoubleEscapedEof() { String body = "<script><!--<script><!-"; ParseErrorList errorList = ParseErrorList.tracking(1); Parser.parseFragment(body, null, "", errorList); - Assert.assertEquals(1, errorList.size()); - Assert.assertTrue(errorList.get(0).getErrorMessage() + Assertions.assertEquals(1, errorList.size()); + Assertions.assertTrue(errorList.get(0).getErrorMessage() .contains("Unexpectedly reached end of file (EOF) in input state")); } @@ -473,7 +472,7 @@ public void scriptDataDoubleEscapedDash() { String body = "<script><!--<script><!-- --></script>"; ParseErrorList errorList = ParseErrorList.tracking(1); Parser.parseFragment(body, null, "", errorList); - Assert.assertEquals(0, errorList.size()); + Assertions.assertEquals(0, errorList.size()); } @Test @@ -481,7 +480,7 @@ public void scriptDataDoubleEscapedDashStTag() { String body = "<script><!--<script><!-< --></script>"; ParseErrorList errorList = ParseErrorList.tracking(1); Parser.parseFragment(body, null, "", errorList); - Assert.assertEquals(0, errorList.size()); + Assertions.assertEquals(0, errorList.size()); } @Test @@ -489,8 +488,8 @@ public void scriptDataDoubleEscapedDashNull() { String body = "<script><!--<script><!-\0 --></script>"; ParseErrorList errorList = ParseErrorList.tracking(1); Parser.parseFragment(body, null, "", errorList); - Assert.assertEquals(1, errorList.size()); - Assert.assertTrue(errorList.get(0).getErrorMessage() + Assertions.assertEquals(1, errorList.size()); + Assertions.assertTrue(errorList.get(0).getErrorMessage() .contains("Unexpected character")); } @@ -499,8 +498,8 @@ public void scriptDataDoubleEscapedDashEof() { String body = "<script><!--<script><!-"; ParseErrorList errorList = ParseErrorList.tracking(1); Parser.parseFragment(body, null, "", errorList); - Assert.assertEquals(1, errorList.size()); - Assert.assertTrue(errorList.get(0).getErrorMessage() + Assertions.assertEquals(1, errorList.size()); + Assertions.assertTrue(errorList.get(0).getErrorMessage() .contains("Unexpectedly reached end of file (EOF) in input state")); } @@ -509,7 +508,7 @@ public void scriptDataDoubleEscapedDashDefault() { String body = "<script><!--<script><!-aaa --></script>"; ParseErrorList errorList = ParseErrorList.tracking(1); Parser.parseFragment(body, null, "", errorList); - Assert.assertEquals(0, errorList.size()); + Assertions.assertEquals(0, errorList.size()); } @Test @@ -517,7 +516,7 @@ public void scriptDataDoubleEscapedDashDash() { String body = "<script><!--<script><!--- --></script>"; ParseErrorList errorList = ParseErrorList.tracking(1); Parser.parseFragment(body, null, "", errorList); - Assert.assertEquals(0, errorList.size()); + Assertions.assertEquals(0, errorList.size()); } @Test @@ -525,7 +524,7 @@ public void scriptDataDoubleEscapedDashDashStTag() { String body = "<script><!--<script><!--< --></script>"; ParseErrorList errorList = ParseErrorList.tracking(1); Parser.parseFragment(body, null, "", errorList); - Assert.assertEquals(0, errorList.size()); + Assertions.assertEquals(0, errorList.size()); } @Test @@ -533,8 +532,8 @@ public void scriptDataDoubleEscapedDashDashNull() { String body = "<script><!--<script><!--\0 --></script>"; ParseErrorList errorList = ParseErrorList.tracking(1); Parser.parseFragment(body, null, "", errorList); - Assert.assertEquals(1, errorList.size()); - Assert.assertTrue(errorList.get(0).getErrorMessage() + Assertions.assertEquals(1, errorList.size()); + Assertions.assertTrue(errorList.get(0).getErrorMessage() .contains("Unexpected character")); } @@ -543,8 +542,8 @@ public void scriptDataDoubleEscapedDashDashEof() { String body = "<script><!--<script><!--"; ParseErrorList errorList = ParseErrorList.tracking(1); Parser.parseFragment(body, null, "", errorList); - Assert.assertEquals(1, errorList.size()); - Assert.assertTrue(errorList.get(0).getErrorMessage() + Assertions.assertEquals(1, errorList.size()); + Assertions.assertTrue(errorList.get(0).getErrorMessage() .contains("Unexpectedly reached end of file (EOF) in input state")); } @@ -553,7 +552,7 @@ public void scriptDataDoubleEscapedDashDashDefault() { String body = "<script><!--<script><!--aaa --></script>"; ParseErrorList errorList = ParseErrorList.tracking(1); Parser.parseFragment(body, null, "", errorList); - Assert.assertEquals(0, errorList.size()); + Assertions.assertEquals(0, errorList.size()); } @Test @@ -561,8 +560,8 @@ public void attributeNameStTag() { String body = "<p name< />"; ParseErrorList errorList = ParseErrorList.tracking(1); Parser.parseFragment(body, null, "", errorList); - Assert.assertEquals(1, errorList.size()); - Assert.assertTrue(errorList.get(0).getErrorMessage() + Assertions.assertEquals(1, errorList.size()); + Assertions.assertTrue(errorList.get(0).getErrorMessage() .contains("Unexpected character")); } @@ -571,7 +570,7 @@ public void afterAttributeNameEndTag() { String body = "<p name > />"; ParseErrorList errorList = ParseErrorList.tracking(1); Parser.parseFragment(body, null, "", errorList); - Assert.assertEquals(0, errorList.size()); + Assertions.assertEquals(0, errorList.size()); } @Test @@ -579,8 +578,8 @@ public void afterAttributeNameNull() { String body = "<p name \0 />"; ParseErrorList errorList = ParseErrorList.tracking(1); Parser.parseFragment(body, null, "", errorList); - Assert.assertEquals(1, errorList.size()); - Assert.assertTrue(errorList.get(0).getErrorMessage() + Assertions.assertEquals(1, errorList.size()); + Assertions.assertTrue(errorList.get(0).getErrorMessage() .contains("Unexpected character")); } @@ -589,8 +588,8 @@ public void afterAttributeNameEof() { String body = "<p name "; ParseErrorList errorList = ParseErrorList.tracking(1); Parser.parseFragment(body, null, "", errorList); - Assert.assertEquals(1, errorList.size()); - Assert.assertTrue(errorList.get(0).getErrorMessage() + Assertions.assertEquals(1, errorList.size()); + Assertions.assertTrue(errorList.get(0).getErrorMessage() .contains("Unexpectedly reached end of file (EOF) in input state")); } @@ -599,8 +598,8 @@ public void afterAttributeNameStTag() { String body = "<p name <"; ParseErrorList errorList = ParseErrorList.tracking(1); Parser.parseFragment(body, null, "", errorList); - Assert.assertEquals(1, errorList.size()); - Assert.assertTrue(errorList.get(0).getErrorMessage() + Assertions.assertEquals(1, errorList.size()); + Assertions.assertTrue(errorList.get(0).getErrorMessage() .contains("Unexpected character")); } @@ -609,8 +608,8 @@ public void beforeAttributeNameClTag() { String body = "<p name=></p>"; ParseErrorList errorList = ParseErrorList.tracking(1); Parser.parseFragment(body, null, "", errorList); - Assert.assertEquals(1, errorList.size()); - Assert.assertTrue(errorList.get(0).getErrorMessage() + Assertions.assertEquals(1, errorList.size()); + Assertions.assertTrue(errorList.get(0).getErrorMessage() .contains("Unexpected character")); } @@ -619,8 +618,8 @@ public void beforeAttributeNameStTag() { String body = "<p name=<</p>"; ParseErrorList errorList = ParseErrorList.tracking(1); Parser.parseFragment(body, null, "", errorList); - Assert.assertEquals(1, errorList.size()); - Assert.assertTrue(errorList.get(0).getErrorMessage() + Assertions.assertEquals(1, errorList.size()); + Assertions.assertTrue(errorList.get(0).getErrorMessage() .contains("Unexpected character")); } @@ -629,8 +628,8 @@ public void attributeValueDoubleQuotedNull() { String body = "<p name=\"\0\"></p>"; ParseErrorList errorList = ParseErrorList.tracking(1); Parser.parseFragment(body, null, "", errorList); - Assert.assertEquals(1, errorList.size()); - Assert.assertTrue(errorList.get(0).getErrorMessage() + Assertions.assertEquals(1, errorList.size()); + Assertions.assertTrue(errorList.get(0).getErrorMessage() .contains("Unexpected character")); } @@ -639,8 +638,8 @@ public void attributeValueSingleQuotedNull() { String body = "<p name='\0'></p>"; ParseErrorList errorList = ParseErrorList.tracking(1); Parser.parseFragment(body, null, "", errorList); - Assert.assertEquals(1, errorList.size()); - Assert.assertTrue(errorList.get(0).getErrorMessage() + Assertions.assertEquals(1, errorList.size()); + Assertions.assertTrue(errorList.get(0).getErrorMessage() .contains("Unexpected character")); } @@ -649,7 +648,7 @@ public void attributeValueSingleUnquotedAmp() { String body = "<p name=&a></p>"; ParseErrorList errorList = ParseErrorList.tracking(1); Parser.parseFragment(body, null, "", errorList); - Assert.assertEquals(0, errorList.size()); + Assertions.assertEquals(0, errorList.size()); } @Test @@ -657,8 +656,8 @@ public void attributeValueSingleUnquotedNull() { String body = "<p name=a\0></p>"; ParseErrorList errorList = ParseErrorList.tracking(1); Parser.parseFragment(body, null, "", errorList); - Assert.assertEquals(1, errorList.size()); - Assert.assertTrue(errorList.get(0).getErrorMessage() + Assertions.assertEquals(1, errorList.size()); + Assertions.assertTrue(errorList.get(0).getErrorMessage() .contains("Unexpected character")); } @@ -667,79 +666,79 @@ public void attributeValueSingleUnquotedEof() { String body = "<p name=a"; ParseErrorList errorList = ParseErrorList.tracking(1); Parser.parseFragment(body, null, "", errorList); - Assert.assertEquals(1, errorList.size()); - Assert.assertTrue(errorList.get(0).getErrorMessage() + Assertions.assertEquals(1, errorList.size()); + Assertions.assertTrue(errorList.get(0).getErrorMessage() .contains("Unexpectedly reached end of file (EOF) in input state")); } @Test public void tokeniserStateToStringTest() { - Assert.assertEquals("Data", TokeniserState.Data.toString()); - Assert.assertEquals("CharacterReferenceInData", TokeniserState.CharacterReferenceInData.toString()); - Assert.assertEquals("Rcdata", TokeniserState.Rcdata.toString()); - Assert.assertEquals("CharacterReferenceInRcdata", TokeniserState.CharacterReferenceInRcdata.toString()); - Assert.assertEquals("Rawtext", TokeniserState.Rawtext.toString()); - Assert.assertEquals("ScriptData", TokeniserState.ScriptData.toString()); - Assert.assertEquals("PLAINTEXT", TokeniserState.PLAINTEXT.toString()); - Assert.assertEquals("TagOpen", TokeniserState.TagOpen.toString()); - Assert.assertEquals("EndTagOpen", TokeniserState.EndTagOpen.toString()); - Assert.assertEquals("TagName", TokeniserState.TagName.toString()); - Assert.assertEquals("RcdataLessthanSign", TokeniserState.RcdataLessthanSign.toString()); - Assert.assertEquals("RCDATAEndTagOpen", TokeniserState.RCDATAEndTagOpen.toString()); - Assert.assertEquals("RCDATAEndTagName", TokeniserState.RCDATAEndTagName.toString()); - Assert.assertEquals("RawtextLessthanSign", TokeniserState.RawtextLessthanSign.toString()); - Assert.assertEquals("RawtextEndTagOpen", TokeniserState.RawtextEndTagOpen.toString()); - Assert.assertEquals("RawtextEndTagName", TokeniserState.RawtextEndTagName.toString()); - Assert.assertEquals("ScriptDataLessthanSign", TokeniserState.ScriptDataLessthanSign.toString()); - Assert.assertEquals("ScriptDataEndTagOpen", TokeniserState.ScriptDataEndTagOpen.toString()); - Assert.assertEquals("ScriptDataEndTagName", TokeniserState.ScriptDataEndTagName.toString()); - Assert.assertEquals("ScriptDataEscapeStart", TokeniserState.ScriptDataEscapeStart.toString()); - Assert.assertEquals("ScriptDataEscapeStartDash", TokeniserState.ScriptDataEscapeStartDash.toString()); - Assert.assertEquals("ScriptDataEscaped", TokeniserState.ScriptDataEscaped.toString()); - Assert.assertEquals("ScriptDataEscapedDash", TokeniserState.ScriptDataEscapedDash.toString()); - Assert.assertEquals("ScriptDataEscapedDashDash", TokeniserState.ScriptDataEscapedDashDash.toString()); - Assert.assertEquals("ScriptDataEscapedLessthanSign", TokeniserState.ScriptDataEscapedLessthanSign.toString()); - Assert.assertEquals("ScriptDataEscapedEndTagOpen", TokeniserState.ScriptDataEscapedEndTagOpen.toString()); - Assert.assertEquals("ScriptDataEscapedEndTagName", TokeniserState.ScriptDataEscapedEndTagName.toString()); - Assert.assertEquals("ScriptDataDoubleEscapeStart", TokeniserState.ScriptDataDoubleEscapeStart.toString()); - Assert.assertEquals("ScriptDataDoubleEscaped", TokeniserState.ScriptDataDoubleEscaped.toString()); - Assert.assertEquals("ScriptDataDoubleEscapedDash", TokeniserState.ScriptDataDoubleEscapedDash.toString()); - Assert.assertEquals("ScriptDataDoubleEscapedDashDash", TokeniserState.ScriptDataDoubleEscapedDashDash.toString()); - Assert.assertEquals("ScriptDataDoubleEscapedLessthanSign", TokeniserState.ScriptDataDoubleEscapedLessthanSign.toString()); - Assert.assertEquals("ScriptDataDoubleEscapeEnd", TokeniserState.ScriptDataDoubleEscapeEnd.toString()); - Assert.assertEquals("BeforeAttributeName", TokeniserState.BeforeAttributeName.toString()); - Assert.assertEquals("AttributeName", TokeniserState.AttributeName.toString()); - Assert.assertEquals("AfterAttributeName", TokeniserState.AfterAttributeName.toString()); - Assert.assertEquals("BeforeAttributeValue", TokeniserState.BeforeAttributeValue.toString()); - Assert.assertEquals("AttributeValue_doubleQuoted", TokeniserState.AttributeValue_doubleQuoted.toString()); - Assert.assertEquals("AttributeValue_singleQuoted", TokeniserState.AttributeValue_singleQuoted.toString()); - Assert.assertEquals("AttributeValue_unquoted", TokeniserState.AttributeValue_unquoted.toString()); - Assert.assertEquals("AfterAttributeValue_quoted", TokeniserState.AfterAttributeValue_quoted.toString()); - Assert.assertEquals("SelfClosingStartTag", TokeniserState.SelfClosingStartTag.toString()); - Assert.assertEquals("BogusComment", TokeniserState.BogusComment.toString()); - Assert.assertEquals("MarkupDeclarationOpen", TokeniserState.MarkupDeclarationOpen.toString()); - Assert.assertEquals("CommentStart", TokeniserState.CommentStart.toString()); - Assert.assertEquals("CommentStartDash", TokeniserState.CommentStartDash.toString()); - Assert.assertEquals("Comment", TokeniserState.Comment.toString()); - Assert.assertEquals("CommentEndDash", TokeniserState.CommentEndDash.toString()); - Assert.assertEquals("CommentEnd", TokeniserState.CommentEnd.toString()); - Assert.assertEquals("CommentEndBang", TokeniserState.CommentEndBang.toString()); - Assert.assertEquals("Doctype", TokeniserState.Doctype.toString()); - Assert.assertEquals("BeforeDoctypeName", TokeniserState.BeforeDoctypeName.toString()); - Assert.assertEquals("DoctypeName", TokeniserState.DoctypeName.toString()); - Assert.assertEquals("AfterDoctypeName", TokeniserState.AfterDoctypeName.toString()); - Assert.assertEquals("AfterDoctypePublicKeyword", TokeniserState.AfterDoctypePublicKeyword.toString()); - Assert.assertEquals("BeforeDoctypePublicIdentifier", TokeniserState.BeforeDoctypePublicIdentifier.toString()); - Assert.assertEquals("DoctypePublicIdentifier_doubleQuoted", TokeniserState.DoctypePublicIdentifier_doubleQuoted.toString()); - Assert.assertEquals("DoctypePublicIdentifier_singleQuoted", TokeniserState.DoctypePublicIdentifier_singleQuoted.toString()); - Assert.assertEquals("AfterDoctypePublicIdentifier", TokeniserState.AfterDoctypePublicIdentifier.toString()); - Assert.assertEquals("BetweenDoctypePublicAndSystemIdentifiers", TokeniserState.BetweenDoctypePublicAndSystemIdentifiers.toString()); - Assert.assertEquals("AfterDoctypeSystemKeyword", TokeniserState.AfterDoctypeSystemKeyword.toString()); - Assert.assertEquals("BeforeDoctypeSystemIdentifier", TokeniserState.BeforeDoctypeSystemIdentifier.toString()); - Assert.assertEquals("DoctypeSystemIdentifier_doubleQuoted", TokeniserState.DoctypeSystemIdentifier_doubleQuoted.toString()); - Assert.assertEquals("DoctypeSystemIdentifier_singleQuoted", TokeniserState.DoctypeSystemIdentifier_singleQuoted.toString()); - Assert.assertEquals("AfterDoctypeSystemIdentifier", TokeniserState.AfterDoctypeSystemIdentifier.toString()); - Assert.assertEquals("BogusDoctype", TokeniserState.BogusDoctype.toString()); - Assert.assertEquals("CdataSection", TokeniserState.CdataSection.toString()); + Assertions.assertEquals("Data", TokeniserState.Data.toString()); + Assertions.assertEquals("CharacterReferenceInData", TokeniserState.CharacterReferenceInData.toString()); + Assertions.assertEquals("Rcdata", TokeniserState.Rcdata.toString()); + Assertions.assertEquals("CharacterReferenceInRcdata", TokeniserState.CharacterReferenceInRcdata.toString()); + Assertions.assertEquals("Rawtext", TokeniserState.Rawtext.toString()); + Assertions.assertEquals("ScriptData", TokeniserState.ScriptData.toString()); + Assertions.assertEquals("PLAINTEXT", TokeniserState.PLAINTEXT.toString()); + Assertions.assertEquals("TagOpen", TokeniserState.TagOpen.toString()); + Assertions.assertEquals("EndTagOpen", TokeniserState.EndTagOpen.toString()); + Assertions.assertEquals("TagName", TokeniserState.TagName.toString()); + Assertions.assertEquals("RcdataLessthanSign", TokeniserState.RcdataLessthanSign.toString()); + Assertions.assertEquals("RCDATAEndTagOpen", TokeniserState.RCDATAEndTagOpen.toString()); + Assertions.assertEquals("RCDATAEndTagName", TokeniserState.RCDATAEndTagName.toString()); + Assertions.assertEquals("RawtextLessthanSign", TokeniserState.RawtextLessthanSign.toString()); + Assertions.assertEquals("RawtextEndTagOpen", TokeniserState.RawtextEndTagOpen.toString()); + Assertions.assertEquals("RawtextEndTagName", TokeniserState.RawtextEndTagName.toString()); + Assertions.assertEquals("ScriptDataLessthanSign", TokeniserState.ScriptDataLessthanSign.toString()); + Assertions.assertEquals("ScriptDataEndTagOpen", TokeniserState.ScriptDataEndTagOpen.toString()); + Assertions.assertEquals("ScriptDataEndTagName", TokeniserState.ScriptDataEndTagName.toString()); + Assertions.assertEquals("ScriptDataEscapeStart", TokeniserState.ScriptDataEscapeStart.toString()); + Assertions.assertEquals("ScriptDataEscapeStartDash", TokeniserState.ScriptDataEscapeStartDash.toString()); + Assertions.assertEquals("ScriptDataEscaped", TokeniserState.ScriptDataEscaped.toString()); + Assertions.assertEquals("ScriptDataEscapedDash", TokeniserState.ScriptDataEscapedDash.toString()); + Assertions.assertEquals("ScriptDataEscapedDashDash", TokeniserState.ScriptDataEscapedDashDash.toString()); + Assertions.assertEquals("ScriptDataEscapedLessthanSign", TokeniserState.ScriptDataEscapedLessthanSign.toString()); + Assertions.assertEquals("ScriptDataEscapedEndTagOpen", TokeniserState.ScriptDataEscapedEndTagOpen.toString()); + Assertions.assertEquals("ScriptDataEscapedEndTagName", TokeniserState.ScriptDataEscapedEndTagName.toString()); + Assertions.assertEquals("ScriptDataDoubleEscapeStart", TokeniserState.ScriptDataDoubleEscapeStart.toString()); + Assertions.assertEquals("ScriptDataDoubleEscaped", TokeniserState.ScriptDataDoubleEscaped.toString()); + Assertions.assertEquals("ScriptDataDoubleEscapedDash", TokeniserState.ScriptDataDoubleEscapedDash.toString()); + Assertions.assertEquals("ScriptDataDoubleEscapedDashDash", TokeniserState.ScriptDataDoubleEscapedDashDash.toString()); + Assertions.assertEquals("ScriptDataDoubleEscapedLessthanSign", TokeniserState.ScriptDataDoubleEscapedLessthanSign.toString()); + Assertions.assertEquals("ScriptDataDoubleEscapeEnd", TokeniserState.ScriptDataDoubleEscapeEnd.toString()); + Assertions.assertEquals("BeforeAttributeName", TokeniserState.BeforeAttributeName.toString()); + Assertions.assertEquals("AttributeName", TokeniserState.AttributeName.toString()); + Assertions.assertEquals("AfterAttributeName", TokeniserState.AfterAttributeName.toString()); + Assertions.assertEquals("BeforeAttributeValue", TokeniserState.BeforeAttributeValue.toString()); + Assertions.assertEquals("AttributeValue_doubleQuoted", TokeniserState.AttributeValue_doubleQuoted.toString()); + Assertions.assertEquals("AttributeValue_singleQuoted", TokeniserState.AttributeValue_singleQuoted.toString()); + Assertions.assertEquals("AttributeValue_unquoted", TokeniserState.AttributeValue_unquoted.toString()); + Assertions.assertEquals("AfterAttributeValue_quoted", TokeniserState.AfterAttributeValue_quoted.toString()); + Assertions.assertEquals("SelfClosingStartTag", TokeniserState.SelfClosingStartTag.toString()); + Assertions.assertEquals("BogusComment", TokeniserState.BogusComment.toString()); + Assertions.assertEquals("MarkupDeclarationOpen", TokeniserState.MarkupDeclarationOpen.toString()); + Assertions.assertEquals("CommentStart", TokeniserState.CommentStart.toString()); + Assertions.assertEquals("CommentStartDash", TokeniserState.CommentStartDash.toString()); + Assertions.assertEquals("Comment", TokeniserState.Comment.toString()); + Assertions.assertEquals("CommentEndDash", TokeniserState.CommentEndDash.toString()); + Assertions.assertEquals("CommentEnd", TokeniserState.CommentEnd.toString()); + Assertions.assertEquals("CommentEndBang", TokeniserState.CommentEndBang.toString()); + Assertions.assertEquals("Doctype", TokeniserState.Doctype.toString()); + Assertions.assertEquals("BeforeDoctypeName", TokeniserState.BeforeDoctypeName.toString()); + Assertions.assertEquals("DoctypeName", TokeniserState.DoctypeName.toString()); + Assertions.assertEquals("AfterDoctypeName", TokeniserState.AfterDoctypeName.toString()); + Assertions.assertEquals("AfterDoctypePublicKeyword", TokeniserState.AfterDoctypePublicKeyword.toString()); + Assertions.assertEquals("BeforeDoctypePublicIdentifier", TokeniserState.BeforeDoctypePublicIdentifier.toString()); + Assertions.assertEquals("DoctypePublicIdentifier_doubleQuoted", TokeniserState.DoctypePublicIdentifier_doubleQuoted.toString()); + Assertions.assertEquals("DoctypePublicIdentifier_singleQuoted", TokeniserState.DoctypePublicIdentifier_singleQuoted.toString()); + Assertions.assertEquals("AfterDoctypePublicIdentifier", TokeniserState.AfterDoctypePublicIdentifier.toString()); + Assertions.assertEquals("BetweenDoctypePublicAndSystemIdentifiers", TokeniserState.BetweenDoctypePublicAndSystemIdentifiers.toString()); + Assertions.assertEquals("AfterDoctypeSystemKeyword", TokeniserState.AfterDoctypeSystemKeyword.toString()); + Assertions.assertEquals("BeforeDoctypeSystemIdentifier", TokeniserState.BeforeDoctypeSystemIdentifier.toString()); + Assertions.assertEquals("DoctypeSystemIdentifier_doubleQuoted", TokeniserState.DoctypeSystemIdentifier_doubleQuoted.toString()); + Assertions.assertEquals("DoctypeSystemIdentifier_singleQuoted", TokeniserState.DoctypeSystemIdentifier_singleQuoted.toString()); + Assertions.assertEquals("AfterDoctypeSystemIdentifier", TokeniserState.AfterDoctypeSystemIdentifier.toString()); + Assertions.assertEquals("BogusDoctype", TokeniserState.BogusDoctype.toString()); + Assertions.assertEquals("CdataSection", TokeniserState.CdataSection.toString()); } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/parser/TokeniserTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/parser/TokeniserTest.java index 6b869f8aec..d1079204d6 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/parser/TokeniserTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/parser/TokeniserTest.java @@ -32,15 +32,14 @@ This file is part of the iText (R) project. import com.itextpdf.styledxmlparser.jsoup.nodes.TextNode; import com.itextpdf.styledxmlparser.jsoup.select.Elements; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.UnsupportedEncodingException; import java.util.Arrays; -@Category(UnitTest.class) +@Tag("UnitTest") public class TokeniserTest extends ExtendedITextTest { @Test public void bufferUpInAttributeVal() { @@ -65,8 +64,8 @@ public void bufferUpInAttributeVal() { Document doc = Jsoup.parse(html); String src = doc.select("img").attr("src"); - Assert.assertTrue(src.contains("X")); - Assert.assertTrue(src.contains(tail)); + Assertions.assertTrue(src.contains("X")); + Assertions.assertTrue(src.contains(tail)); } } @@ -82,11 +81,11 @@ public void bufferUpInAttributeVal() { Document doc = Parser.htmlParser().settings(ParseSettings.preserveCase).parseInput(html, ""); Elements els = doc.select(tag); - Assert.assertEquals(1, els.size()); + Assertions.assertEquals(1, els.size()); Element el = els.first(); - Assert.assertNotNull(el); - Assert.assertEquals("One", el.text()); - Assert.assertEquals(tag, el.tagName()); + Assertions.assertNotNull(el); + Assertions.assertEquals("One", el.text()); + Assertions.assertEquals(tag, el.tagName()); } @Test public void handleSuperLargeAttributeName() { @@ -99,13 +98,13 @@ public void bufferUpInAttributeVal() { Document doc = Jsoup.parse(html); Elements els = doc.getElementsByAttribute(attrName); - Assert.assertEquals(1, els.size()); + Assertions.assertEquals(1, els.size()); Element el = els.first(); - Assert.assertNotNull(el); - Assert.assertEquals("One", el.text()); + Assertions.assertNotNull(el); + Assertions.assertEquals("One", el.text()); Attribute attribute = el.attributes().asList().get(0); - Assert.assertEquals(attrName.toLowerCase(), attribute.getKey()); - Assert.assertEquals("foo", attribute.getValue()); + Assertions.assertEquals(attrName.toLowerCase(), attribute.getKey()); + Assertions.assertEquals("foo", attribute.getValue()); } @Test public void handleLargeText() { @@ -118,11 +117,11 @@ public void bufferUpInAttributeVal() { Document doc = Jsoup.parse(html); Elements els = doc.select("p"); - Assert.assertEquals(1, els.size()); + Assertions.assertEquals(1, els.size()); Element el = els.first(); - Assert.assertNotNull(el); - Assert.assertEquals(text, el.text()); + Assertions.assertNotNull(el); + Assertions.assertEquals(text, el.text()); } @Test public void handleLargeComment() { @@ -135,12 +134,12 @@ public void bufferUpInAttributeVal() { Document doc = Jsoup.parse(html); Elements els = doc.select("p"); - Assert.assertEquals(1, els.size()); + Assertions.assertEquals(1, els.size()); Element el = els.first(); - Assert.assertNotNull(el); + Assertions.assertNotNull(el); Comment child = (Comment) el.childNode(0); - Assert.assertEquals(" " + comment + " ", child.getData()); + Assertions.assertEquals(" " + comment + " ", child.getData()); } @Test public void handleLargeCdata() { @@ -153,13 +152,13 @@ public void bufferUpInAttributeVal() { Document doc = Jsoup.parse(html); Elements els = doc.select("p"); - Assert.assertEquals(1, els.size()); + Assertions.assertEquals(1, els.size()); Element el = els.first(); - Assert.assertNotNull(el); + Assertions.assertNotNull(el); TextNode child = (TextNode) el.childNode(0); - Assert.assertEquals(cdata, el.text()); - Assert.assertEquals(cdata, child.getWholeText()); + Assertions.assertEquals(cdata, el.text()); + Assertions.assertEquals(cdata, child.getWholeText()); } @Test public void handleLargeTitle() { @@ -172,38 +171,38 @@ public void bufferUpInAttributeVal() { Document doc = Jsoup.parse(html); Elements els = doc.select("title"); - Assert.assertEquals(1, els.size()); + Assertions.assertEquals(1, els.size()); Element el = els.first(); - Assert.assertNotNull(el); + Assertions.assertNotNull(el); TextNode child = (TextNode) el.childNode(0); - Assert.assertEquals(title, el.text()); - Assert.assertEquals(title, child.getWholeText()); - Assert.assertEquals(title, doc.title()); + Assertions.assertEquals(title, el.text()); + Assertions.assertEquals(title, child.getWholeText()); + Assertions.assertEquals(title, doc.title()); } @Test public void cp1252Entities() { - Assert.assertEquals("\u20ac", Jsoup.parse("&#0128;").text()); - Assert.assertEquals("\u201a", Jsoup.parse("&#0130;").text()); - Assert.assertEquals("\u20ac", Jsoup.parse("&#x80;").text()); + Assertions.assertEquals("\u20ac", Jsoup.parse("&#0128;").text()); + Assertions.assertEquals("\u201a", Jsoup.parse("&#0130;").text()); + Assertions.assertEquals("\u20ac", Jsoup.parse("&#x80;").text()); } @Test public void cp1252EntitiesProduceError() { Parser parser = new Parser(new HtmlTreeBuilder()); parser.setTrackErrors(10); - Assert.assertEquals("\u20ac", parser.parseInput("<html><body>&#0128;</body></html>", "").text()); - Assert.assertEquals(1, parser.getErrors().size()); + Assertions.assertEquals("\u20ac", parser.parseInput("<html><body>&#0128;</body></html>", "").text()); + Assertions.assertEquals(1, parser.getErrors().size()); } @Test public void cp1252SubstitutionTable() throws UnsupportedEncodingException { for (int i = 0; i < Tokeniser.win1252Extensions.length; i++) { String s = new String(new byte[]{ (byte) (i + Tokeniser.win1252ExtensionsStart) }, "Windows-1252"); - Assert.assertEquals(1, s.length()); + Assertions.assertEquals(1, s.length()); // some of these characters are illegal if (s.charAt(0) == '\ufffd') { continue; } - Assert.assertEquals(s.charAt(0), Tokeniser.win1252Extensions[i]); + Assertions.assertEquals(s.charAt(0), Tokeniser.win1252Extensions[i]); } } @@ -219,8 +218,8 @@ public void bufferUpInAttributeVal() { Document doc = parser.parseInput(testMarkup, ""); Node commentNode = doc.body().childNode(0); - Assert.assertTrue(commentNode instanceof Comment); - Assert.assertEquals(expectedCommentData, ((Comment)commentNode).getData()); + Assertions.assertTrue(commentNode instanceof Comment); + Assertions.assertEquals(expectedCommentData, ((Comment)commentNode).getData()); } @Test public void canParseCdataEndingAtEdgeOfBuffer() { @@ -236,7 +235,7 @@ public void bufferUpInAttributeVal() { Document doc = parser.parseInput(testMarkup, ""); Node cdataNode = doc.body().childNode(0); - Assert.assertTrue(cdataNode instanceof CDataNode); - Assert.assertEquals(cdataContents, ((CDataNode)cdataNode).text()); + Assertions.assertTrue(cdataNode instanceof CDataNode); + Assertions.assertEquals(cdataContents, ((CDataNode)cdataNode).text()); } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/parser/XmlTreeBuilderTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/parser/XmlTreeBuilderTest.java index ebf11a98f7..840f43bb4c 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/parser/XmlTreeBuilderTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/parser/XmlTreeBuilderTest.java @@ -35,7 +35,6 @@ This file is part of the iText (R) project. import com.itextpdf.styledxmlparser.jsoup.nodes.XmlDeclaration; import com.itextpdf.styledxmlparser.jsoup.select.Elements; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.File; import java.io.IOException; @@ -43,23 +42,23 @@ This file is part of the iText (R) project. import java.net.URISyntaxException; import java.nio.charset.StandardCharsets; import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; /** * Tests XmlTreeBuilder. */ -@Category(UnitTest.class) +@Tag("UnitTest") public class XmlTreeBuilderTest extends ExtendedITextTest { @Test public void testSimpleXmlParse() { String xml = "<doc id=2 href='/bar'>Foo <br /><link>One</link><link>Two</link></doc>"; XmlTreeBuilder tb = new XmlTreeBuilder(); Document doc = tb.parse(xml, "http://foo.com/"); - Assert.assertEquals("<doc id=\"2\" href=\"/bar\">Foo <br /><link>One</link><link>Two</link></doc>", + Assertions.assertEquals("<doc id=\"2\" href=\"/bar\">Foo <br /><link>One</link><link>Two</link></doc>", TextUtil.stripNewlines(doc.html())); - Assert.assertEquals(doc.getElementById("2").absUrl("href"), "http://foo.com/bar"); + Assertions.assertEquals(doc.getElementById("2").absUrl("href"), "http://foo.com/bar"); } @Test @@ -68,7 +67,7 @@ public void testPopToClose() { String xml = "<doc><val>One<val>Two</val></bar>Three</doc>"; XmlTreeBuilder tb = new XmlTreeBuilder(); Document doc = tb.parse(xml, "http://foo.com/"); - Assert.assertEquals("<doc><val>One<val>Two</val>Three</val></doc>", + Assertions.assertEquals("<doc><val>One<val>Two</val>Three</val></doc>", TextUtil.stripNewlines(doc.html())); } @@ -77,7 +76,7 @@ public void testCommentAndDocType() { String xml = "<!DOCTYPE HTML><!-- a comment -->One <qux />Two"; XmlTreeBuilder tb = new XmlTreeBuilder(); Document doc = tb.parse(xml, "http://foo.com/"); - Assert.assertEquals("<!DOCTYPE HTML><!-- a comment -->One <qux />Two", + Assertions.assertEquals("<!DOCTYPE HTML><!-- a comment -->One <qux />Two", TextUtil.stripNewlines(doc.html())); } @@ -85,7 +84,7 @@ public void testCommentAndDocType() { public void testSupplyParserToJsoupClass() { String xml = "<doc><val>One<val>Two</val></bar>Three</doc>"; Document doc = Jsoup.parse(xml, "http://foo.com/", Parser.xmlParser()); - Assert.assertEquals("<doc><val>One<val>Two</val>Three</val></doc>", + Assertions.assertEquals("<doc><val>One<val>Two</val>Three</val></doc>", TextUtil.stripNewlines(doc.html())); } @@ -94,7 +93,7 @@ public void testSupplyParserToDataStream() throws IOException { File xmlFile = ParseTest.getFile("/htmltests/xml-test.xml"); InputStream inStream = FileUtil.getInputStreamForFile(xmlFile); Document doc = Jsoup.parse(inStream, null, "http://foo.com", Parser.xmlParser()); - Assert.assertEquals("<doc><val>One<val>Two</val>Three</val></doc>", + Assertions.assertEquals("<doc><val>One<val>Two</val>Three</val></doc>", TextUtil.stripNewlines(doc.html())); } @@ -102,40 +101,40 @@ public void testSupplyParserToDataStream() throws IOException { public void testDoesNotForceSelfClosingKnownTags() { // html will force "<br>one</br>" to logically "<br />One<br />". XML should be stay "<br>one</br> -- don't recognise tag. Document htmlDoc = Jsoup.parse("<br>one</br>"); - Assert.assertEquals("<br>one\n<br>", htmlDoc.body().html()); + Assertions.assertEquals("<br>one\n<br>", htmlDoc.body().html()); Document xmlDoc = Jsoup.parse("<br>one</br>", "", Parser.xmlParser()); - Assert.assertEquals("<br>one</br>", xmlDoc.html()); + Assertions.assertEquals("<br>one</br>", xmlDoc.html()); } @Test public void handlesXmlDeclarationAsDeclaration() { String html = "<?xml encoding='UTF-8' ?><body>One</body><!-- comment -->"; Document doc = Jsoup.parse(html, "", Parser.xmlParser()); - Assert.assertEquals("<?xml encoding=\"UTF-8\"?><body>One</body><!-- comment -->",doc.outerHtml()); - Assert.assertEquals("#declaration", doc.childNode(0).nodeName()); - Assert.assertEquals("#comment", doc.childNode(2).nodeName()); + Assertions.assertEquals("<?xml encoding=\"UTF-8\"?><body>One</body><!-- comment -->",doc.outerHtml()); + Assertions.assertEquals("#declaration", doc.childNode(0).nodeName()); + Assertions.assertEquals("#comment", doc.childNode(2).nodeName()); } @Test public void xmlFragment() { String xml = "<one src='/foo/' />Two<three><four /></three>"; List<Node> nodes = Parser.parseXmlFragment(xml, "http://example.com/"); - Assert.assertEquals(3, nodes.size()); + Assertions.assertEquals(3, nodes.size()); - Assert.assertEquals("http://example.com/foo/", nodes.get(0).absUrl("src")); - Assert.assertEquals("one", nodes.get(0).nodeName()); - Assert.assertEquals("Two", ((TextNode)nodes.get(1)).text()); + Assertions.assertEquals("http://example.com/foo/", nodes.get(0).absUrl("src")); + Assertions.assertEquals("one", nodes.get(0).nodeName()); + Assertions.assertEquals("Two", ((TextNode)nodes.get(1)).text()); } @Test public void xmlParseDefaultsToHtmlOutputSyntax() { Document doc = Jsoup.parse("x", "", Parser.xmlParser()); - Assert.assertEquals(Document.OutputSettings.Syntax.xml, doc.outputSettings().syntax()); + Assertions.assertEquals(Document.OutputSettings.Syntax.xml, doc.outputSettings().syntax()); } @Test public void testDoesHandleEOFInTag() { String html = "<img src=asdf onerror=\"alert(1)\" x="; Document xmlDoc = Jsoup.parse(html, "", Parser.xmlParser()); - Assert.assertEquals("<img src=\"asdf\" onerror=\"alert(1)\" x=\"\" />", xmlDoc.html()); + Assertions.assertEquals("<img src=\"asdf\" onerror=\"alert(1)\" x=\"\" />", xmlDoc.html()); } @Test @@ -143,8 +142,8 @@ public void testDetectCharsetEncodingDeclaration() throws IOException, URISyntax File xmlFile = ParseTest.getFile("/htmltests/xml-charset.xml"); InputStream inStream = FileUtil.getInputStreamForFile(xmlFile); Document doc = Jsoup.parse(inStream, null, "http://example.com/", Parser.xmlParser()); - Assert.assertEquals("ISO-8859-1", doc.charset().name()); - Assert.assertEquals("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><data>äöåéü</data>", + Assertions.assertEquals("ISO-8859-1", doc.charset().name()); + Assertions.assertEquals("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><data>äöåéü</data>", TextUtil.stripNewlines(doc.html())); } @@ -153,18 +152,18 @@ public void testParseDeclarationAttributes() { String xml = "<?xml version='1' encoding='UTF-8' something='else'?><val>One</val>"; Document doc = Jsoup.parse(xml, "", Parser.xmlParser()); XmlDeclaration decl = (XmlDeclaration) doc.childNode(0); - Assert.assertEquals("1", decl.attr("version")); - Assert.assertEquals("UTF-8", decl.attr("encoding")); - Assert.assertEquals("else", decl.attr("something")); - Assert.assertEquals("version=\"1\" encoding=\"UTF-8\" something=\"else\"", decl.getWholeDeclaration()); - Assert.assertEquals("<?xml version=\"1\" encoding=\"UTF-8\" something=\"else\"?>", decl.outerHtml()); + Assertions.assertEquals("1", decl.attr("version")); + Assertions.assertEquals("UTF-8", decl.attr("encoding")); + Assertions.assertEquals("else", decl.attr("something")); + Assertions.assertEquals("version=\"1\" encoding=\"UTF-8\" something=\"else\"", decl.getWholeDeclaration()); + Assertions.assertEquals("<?xml version=\"1\" encoding=\"UTF-8\" something=\"else\"?>", decl.outerHtml()); } @Test public void caseSensitiveDeclaration() { String xml = "<?XML version='1' encoding='UTF-8' something='else'?>"; Document doc = Jsoup.parse(xml, "", Parser.xmlParser()); - Assert.assertEquals("<?XML version=\"1\" encoding=\"UTF-8\" something=\"else\"?>", doc.outerHtml()); + Assertions.assertEquals("<?XML version=\"1\" encoding=\"UTF-8\" something=\"else\"?>", doc.outerHtml()); } @Test @@ -172,7 +171,7 @@ public void testCreatesValidProlog() { Document document = Document.createShell(""); document.outputSettings().syntax(Document.OutputSettings.Syntax.xml); document.charset(StandardCharsets.UTF_8); - Assert.assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + + Assertions.assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<html>\n" + " <head></head>\n" + " <body></body>\n" + @@ -183,7 +182,7 @@ public void testCreatesValidProlog() { public void preservesCaseByDefault() { String xml = "<CHECK>One</CHECK><TEST ID=1>Check</TEST>"; Document doc = Jsoup.parse(xml, "", Parser.xmlParser()); - Assert.assertEquals("<CHECK>One</CHECK><TEST ID=\"1\">Check</TEST>", TextUtil.stripNewlines(doc.html())); + Assertions.assertEquals("<CHECK>One</CHECK><TEST ID=\"1\">Check</TEST>", TextUtil.stripNewlines(doc.html())); } @Test @@ -192,27 +191,27 @@ public void appendPreservesCaseByDefault() { Document doc = Jsoup.parse(xml, "", Parser.xmlParser()); Elements one = doc.select("One"); one.append("<Two ID=2>Two</Two>"); - Assert.assertEquals("<One>One<Two ID=\"2\">Two</Two></One>", TextUtil.stripNewlines(doc.html())); + Assertions.assertEquals("<One>One<Two ID=\"2\">Two</Two></One>", TextUtil.stripNewlines(doc.html())); } @Test public void disablesPrettyPrintingByDefault() { String xml = "\n\n<div><one>One</one><one>\n Two</one>\n</div>\n "; Document doc = Jsoup.parse(xml, "", Parser.xmlParser()); - Assert.assertEquals(xml, doc.html()); + Assertions.assertEquals(xml, doc.html()); } @Test public void canNormalizeCase() { String xml = "<TEST ID=1>Check</TEST>"; Document doc = Jsoup.parse(xml, "", Parser.xmlParser().settings(ParseSettings.htmlDefault)); - Assert.assertEquals("<test id=\"1\">Check</test>", TextUtil.stripNewlines(doc.html())); + Assertions.assertEquals("<test id=\"1\">Check</test>", TextUtil.stripNewlines(doc.html())); } @Test public void normalizesDiscordantTags() { Parser parser = Parser.xmlParser().settings(ParseSettings.htmlDefault); Document document = Jsoup.parse("<div>test</DIV><p></p>", "", parser); - Assert.assertEquals("<div>test</div><p></p>", document.html()); + Assertions.assertEquals("<div>test</div><p></p>", document.html()); // was failing -> toString() = "<div>\n test\n <p></p>\n</div>" } @@ -221,29 +220,29 @@ public void canNormalizeCase() { Document doc = Jsoup.parse(xml, "", Parser.xmlParser()); Element div = doc.getElementById("1"); - Assert.assertEquals("<html>\n <foo><&amp;", div.text()); - Assert.assertEquals(0, div.children().size()); - Assert.assertEquals(1, div.childNodeSize()); // no elements, one text node + Assertions.assertEquals("<html>\n <foo><&amp;", div.text()); + Assertions.assertEquals(0, div.children().size()); + Assertions.assertEquals(1, div.childNodeSize()); // no elements, one text node - Assert.assertEquals("<div id=\"1\"><![CDATA[\n<html>\n <foo><&amp;]]></div>", div.outerHtml()); + Assertions.assertEquals("<div id=\"1\"><![CDATA[\n<html>\n <foo><&amp;]]></div>", div.outerHtml()); CDataNode cdata = (CDataNode) div.textNodes().get(0); - Assert.assertEquals("\n<html>\n <foo><&amp;", cdata.text()); + Assertions.assertEquals("\n<html>\n <foo><&amp;", cdata.text()); } @Test public void cdataPreservesWhiteSpace() { String xml = "<script type=\"text/javascript\">//<![CDATA[\n\n foo();\n//]]></script>"; Document doc = Jsoup.parse(xml, "", Parser.xmlParser()); - Assert.assertEquals(xml, doc.outerHtml()); + Assertions.assertEquals(xml, doc.outerHtml()); - Assert.assertEquals("//\n\n foo();\n//", doc.selectFirst("script").text()); + Assertions.assertEquals("//\n\n foo();\n//", doc.selectFirst("script").text()); } @Test public void handlesDodgyXmlDecl() { String xml = "<?xml version='1.0'><val>One</val>"; Document doc = Jsoup.parse(xml, "", Parser.xmlParser()); - Assert.assertEquals("One", doc.select("val").text()); + Assertions.assertEquals("One", doc.select("val").text()); } @Test @@ -251,7 +250,7 @@ public void handlesLTinScript() { // https://github.com/jhy/jsoup/issues/1139 String html = "<script> var a=\"<?\"; var b=\"?>\"; </script>"; Document doc = Jsoup.parse(html, "", Parser.xmlParser()); - Assert.assertEquals("<script> var a=\"<!--?\"; var b=\"?-->\"; </script>", doc.html()); // converted from pseudo xmldecl to comment + Assertions.assertEquals("<script> var a=\"<!--?\"; var b=\"?-->\"; </script>", doc.html()); // converted from pseudo xmldecl to comment } @Test public void dropsDuplicateAttributes() { @@ -260,23 +259,23 @@ public void handlesLTinScript() { Parser parser = Parser.xmlParser().setTrackErrors(10); Document doc = parser.parseInput(html, ""); - Assert.assertEquals("<p One=\"One\" ONE=\"Two\" one=\"Three\" two=\"Six\" Two=\"Eight\">Text</p>", doc.selectFirst("p").outerHtml()); + Assertions.assertEquals("<p One=\"One\" ONE=\"Two\" one=\"Three\" two=\"Six\" Two=\"Eight\">Text</p>", doc.selectFirst("p").outerHtml()); } @Test public void readerClosedAfterParse() { Document doc = Jsoup.parse("Hello", "", Parser.xmlParser()); TreeBuilder treeBuilder = doc.parser().getTreeBuilder(); - Assert.assertNull(treeBuilder.reader); - Assert.assertNull(treeBuilder.tokeniser); + Assertions.assertNull(treeBuilder.reader); + Assertions.assertNull(treeBuilder.tokeniser); } @Test public void xmlParserEnablesXmlOutputAndEscapes() { // Test that when using the XML parser, the output mode and escape mode default to XHTML entities // https://github.com/jhy/jsoup/issues/1420 Document doc = Jsoup.parse("<p one='&lt;two&gt;&copy'>Three</p>", "", Parser.xmlParser()); - Assert.assertEquals(doc.outputSettings().syntax(), Document.OutputSettings.Syntax.xml); - Assert.assertEquals(doc.outputSettings().escapeMode(), Entities.EscapeMode.xhtml); - Assert.assertEquals("<p one=\"&lt;two>©\">Three</p>", doc.html()); // only the < should be escaped + Assertions.assertEquals(doc.outputSettings().syntax(), Document.OutputSettings.Syntax.xml); + Assertions.assertEquals(doc.outputSettings().escapeMode(), Entities.EscapeMode.xhtml); + Assertions.assertEquals("<p one=\"&lt;two>©\">Three</p>", doc.html()); // only the < should be escaped } @Test public void xmlSyntaxEscapesLtInAttributes() { @@ -284,8 +283,8 @@ public void handlesLTinScript() { Document doc = Jsoup.parse("<p one='&lt;two&gt;&copy'>Three</p>", "", Parser.xmlParser()); doc.outputSettings().escapeMode(Entities.EscapeMode.extended); doc.outputSettings().charset("ascii"); // to make sure &copy; is output - Assert.assertEquals(doc.outputSettings().syntax(), Document.OutputSettings.Syntax.xml); - Assert.assertEquals("<p one=\"&lt;two>&copy;\">Three</p>", doc.html()); + Assertions.assertEquals(doc.outputSettings().syntax(), Document.OutputSettings.Syntax.xml); + Assertions.assertEquals("<p one=\"&lt;two>&copy;\">Three</p>", doc.html()); } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/safety/CleanerTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/safety/CleanerTest.java index 9a62f2261a..9017ef8683 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/safety/CleanerTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/safety/CleanerTest.java @@ -27,69 +27,68 @@ This file is part of the iText (R) project. import com.itextpdf.styledxmlparser.jsoup.nodes.Document; import com.itextpdf.styledxmlparser.jsoup.nodes.Entities; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; /** Tests for the cleaner. */ -@Category(UnitTest.class) +@Tag("UnitTest") public class CleanerTest extends ExtendedITextTest { @Test public void simpleBehaviourTest() { String h = "<div><p class=foo><a href='http://evil.com'>Hello <b id=bar>there</b>!</a></div>"; String cleanHtml = Jsoup.clean(h, Safelist.simpleText()); - Assert.assertEquals("Hello <b>there</b>!", TextUtil.stripNewlines(cleanHtml)); + Assertions.assertEquals("Hello <b>there</b>!", TextUtil.stripNewlines(cleanHtml)); } @Test public void simpleBehaviourTest2() { String h = "Hello <b>there</b>!"; String cleanHtml = Jsoup.clean(h, Safelist.simpleText()); - Assert.assertEquals("Hello <b>there</b>!", TextUtil.stripNewlines(cleanHtml)); + Assertions.assertEquals("Hello <b>there</b>!", TextUtil.stripNewlines(cleanHtml)); } @Test public void basicBehaviourTest() { String h = "<div><p><a href='javascript:sendAllMoney()'>Dodgy</a> <A HREF='HTTP://nice.com/'>Nice</a></p><blockquote>Hello</blockquote>"; String cleanHtml = Jsoup.clean(h, Safelist.basic()); - Assert.assertEquals("<p><a rel=\"nofollow\">Dodgy</a> <a href=\"http://nice.com/\" rel=\"nofollow\">Nice</a></p><blockquote>Hello</blockquote>", + Assertions.assertEquals("<p><a rel=\"nofollow\">Dodgy</a> <a href=\"http://nice.com/\" rel=\"nofollow\">Nice</a></p><blockquote>Hello</blockquote>", TextUtil.stripNewlines(cleanHtml)); } @Test public void basicWithImagesTest() { String h = "<div><p><img src='http://example.com/' alt=Image></p><p><img src='ftp://ftp.example.com'></p></div>"; String cleanHtml = Jsoup.clean(h, Safelist.basicWithImages()); - Assert.assertEquals("<p><img src=\"http://example.com/\" alt=\"Image\"></p><p><img></p>", TextUtil.stripNewlines(cleanHtml)); + Assertions.assertEquals("<p><img src=\"http://example.com/\" alt=\"Image\"></p><p><img></p>", TextUtil.stripNewlines(cleanHtml)); } @Test public void testRelaxed() { String h = "<h1>Head</h1><table><tr><td>One<td>Two</td></tr></table>"; String cleanHtml = Jsoup.clean(h, Safelist.relaxed()); - Assert.assertEquals("<h1>Head</h1><table><tbody><tr><td>One</td><td>Two</td></tr></tbody></table>", TextUtil.stripNewlines(cleanHtml)); + Assertions.assertEquals("<h1>Head</h1><table><tbody><tr><td>One</td><td>Two</td></tr></tbody></table>", TextUtil.stripNewlines(cleanHtml)); } @Test public void testRemoveTags() { String h = "<div><p><A HREF='HTTP://nice.com'>Nice</a></p><blockquote>Hello</blockquote>"; String cleanHtml = Jsoup.clean(h, Safelist.basic().removeTags("a")); - Assert.assertEquals("<p>Nice</p><blockquote>Hello</blockquote>", TextUtil.stripNewlines(cleanHtml)); + Assertions.assertEquals("<p>Nice</p><blockquote>Hello</blockquote>", TextUtil.stripNewlines(cleanHtml)); } @Test public void testRemoveAttributes() { String h = "<div><p>Nice</p><blockquote cite='http://example.com/quotations'>Hello</blockquote>"; String cleanHtml = Jsoup.clean(h, Safelist.basic().removeAttributes("blockquote", "cite")); - Assert.assertEquals("<p>Nice</p><blockquote>Hello</blockquote>", TextUtil.stripNewlines(cleanHtml)); + Assertions.assertEquals("<p>Nice</p><blockquote>Hello</blockquote>", TextUtil.stripNewlines(cleanHtml)); } @Test public void testRemoveEnforcedAttributes() { String h = "<div><p><A HREF='HTTP://nice.com/'>Nice</a></p><blockquote>Hello</blockquote>"; String cleanHtml = Jsoup.clean(h, Safelist.basic().removeEnforcedAttribute("a", "rel")); - Assert.assertEquals("<p><a href=\"http://nice.com/\">Nice</a></p><blockquote>Hello</blockquote>", + Assertions.assertEquals("<p><a href=\"http://nice.com/\">Nice</a></p><blockquote>Hello</blockquote>", TextUtil.stripNewlines(cleanHtml)); } @@ -97,38 +96,38 @@ public class CleanerTest extends ExtendedITextTest { String h = "<p>Contact me <a href='mailto:info@example.com'>here</a></p>"; String cleanHtml = Jsoup.clean(h, Safelist.basic().removeProtocols("a", "href", "ftp", "mailto")); - Assert.assertEquals("<p>Contact me <a rel=\"nofollow\">here</a></p>", + Assertions.assertEquals("<p>Contact me <a rel=\"nofollow\">here</a></p>", TextUtil.stripNewlines(cleanHtml)); } @Test public void testDropComments() { String h = "<p>Hello<!-- no --></p>"; String cleanHtml = Jsoup.clean(h, Safelist.relaxed()); - Assert.assertEquals("<p>Hello</p>", cleanHtml); + Assertions.assertEquals("<p>Hello</p>", cleanHtml); } @Test public void testDropXmlProc() { String h = "<?import namespace=\"xss\"><p>Hello</p>"; String cleanHtml = Jsoup.clean(h, Safelist.relaxed()); - Assert.assertEquals("<p>Hello</p>", cleanHtml); + Assertions.assertEquals("<p>Hello</p>", cleanHtml); } @Test public void testDropScript() { String h = "<SCRIPT SRC=//ha.ckers.org/.j><SCRIPT>alert(/XSS/.source)</SCRIPT>"; String cleanHtml = Jsoup.clean(h, Safelist.relaxed()); - Assert.assertEquals("", cleanHtml); + Assertions.assertEquals("", cleanHtml); } @Test public void testDropImageScript() { String h = "<IMG SRC=\"javascript:alert('XSS')\">"; String cleanHtml = Jsoup.clean(h, Safelist.relaxed()); - Assert.assertEquals("<img>", cleanHtml); + Assertions.assertEquals("<img>", cleanHtml); } @Test public void testCleanJavascriptHref() { String h = "<A HREF=\"javascript:document.location='http://www.google.com/'\">XSS</A>"; String cleanHtml = Jsoup.clean(h, Safelist.relaxed()); - Assert.assertEquals("<a>XSS</a>", cleanHtml); + Assertions.assertEquals("<a>XSS</a>", cleanHtml); } @Test public void testCleanAnchorProtocol() { @@ -137,32 +136,32 @@ public class CleanerTest extends ExtendedITextTest { // A Safelist that does not allow anchors will strip them out. String cleanHtml = Jsoup.clean(validAnchor, Safelist.relaxed()); - Assert.assertEquals("<a>Valid anchor</a>", cleanHtml); + Assertions.assertEquals("<a>Valid anchor</a>", cleanHtml); cleanHtml = Jsoup.clean(invalidAnchor, Safelist.relaxed()); - Assert.assertEquals("<a>Invalid anchor</a>", cleanHtml); + Assertions.assertEquals("<a>Invalid anchor</a>", cleanHtml); // A Safelist that allows them will keep them. Safelist relaxedWithAnchor = Safelist.relaxed().addProtocols("a", "href", "#"); cleanHtml = Jsoup.clean(validAnchor, relaxedWithAnchor); - Assert.assertEquals(validAnchor, cleanHtml); + Assertions.assertEquals(validAnchor, cleanHtml); // An invalid anchor is never valid. cleanHtml = Jsoup.clean(invalidAnchor, relaxedWithAnchor); - Assert.assertEquals("<a>Invalid anchor</a>", cleanHtml); + Assertions.assertEquals("<a>Invalid anchor</a>", cleanHtml); } @Test public void testDropsUnknownTags() { String h = "<p><custom foo=true>Test</custom></p>"; String cleanHtml = Jsoup.clean(h, Safelist.relaxed()); - Assert.assertEquals("<p>Test</p>", cleanHtml); + Assertions.assertEquals("<p>Test</p>", cleanHtml); } @Test public void testHandlesEmptyAttributes() { String h = "<img alt=\"\" src= unknown=''>"; String cleanHtml = Jsoup.clean(h, Safelist.basicWithImages()); - Assert.assertEquals("<img alt=\"\">", cleanHtml); + Assertions.assertEquals("<img alt=\"\">", cleanHtml); } @Test public void testIsValidBodyHtml() { @@ -175,16 +174,16 @@ public class CleanerTest extends ExtendedITextTest { String nok5 = "<p>Test <b><a href='http://example.com/' rel='nofollowme'>OK</a></b></p>"; String nok6 = "<p>Test <b><a href='http://example.com/'>OK</b></p>"; // missing close tag String nok7 = "</div>What"; - Assert.assertTrue(Jsoup.isValid(ok, Safelist.basic())); - Assert.assertTrue(Jsoup.isValid(ok1, Safelist.basic())); - Assert.assertFalse(Jsoup.isValid(nok1, Safelist.basic())); - Assert.assertFalse(Jsoup.isValid(nok2, Safelist.basic())); - Assert.assertFalse(Jsoup.isValid(nok3, Safelist.basic())); - Assert.assertFalse(Jsoup.isValid(nok4, Safelist.basic())); - Assert.assertFalse(Jsoup.isValid(nok5, Safelist.basic())); - Assert.assertFalse(Jsoup.isValid(nok6, Safelist.basic())); - Assert.assertFalse(Jsoup.isValid(ok, Safelist.none())); - Assert.assertFalse(Jsoup.isValid(nok7, Safelist.basic())); + Assertions.assertTrue(Jsoup.isValid(ok, Safelist.basic())); + Assertions.assertTrue(Jsoup.isValid(ok1, Safelist.basic())); + Assertions.assertFalse(Jsoup.isValid(nok1, Safelist.basic())); + Assertions.assertFalse(Jsoup.isValid(nok2, Safelist.basic())); + Assertions.assertFalse(Jsoup.isValid(nok3, Safelist.basic())); + Assertions.assertFalse(Jsoup.isValid(nok4, Safelist.basic())); + Assertions.assertFalse(Jsoup.isValid(nok5, Safelist.basic())); + Assertions.assertFalse(Jsoup.isValid(nok6, Safelist.basic())); + Assertions.assertFalse(Jsoup.isValid(ok, Safelist.none())); + Assertions.assertFalse(Jsoup.isValid(nok7, Safelist.basic())); } @Test public void testIsValidDocument() { @@ -194,36 +193,36 @@ public class CleanerTest extends ExtendedITextTest { Safelist relaxed = Safelist.relaxed(); Cleaner cleaner = new Cleaner(relaxed); Document okDoc = Jsoup.parse(ok); - Assert.assertTrue(cleaner.isValid(okDoc)); - Assert.assertFalse(cleaner.isValid(Jsoup.parse(nok))); - Assert.assertFalse(new Cleaner(Safelist.none()).isValid(okDoc)); + Assertions.assertTrue(cleaner.isValid(okDoc)); + Assertions.assertFalse(cleaner.isValid(Jsoup.parse(nok))); + Assertions.assertFalse(new Cleaner(Safelist.none()).isValid(okDoc)); } @Test public void resolvesRelativeLinks() { String html = "<a href='/foo'>Link</a><img src='/bar'>"; String clean = Jsoup.clean(html, "http://example.com/", Safelist.basicWithImages()); - Assert.assertEquals("<a href=\"http://example.com/foo\" rel=\"nofollow\">Link</a>\n<img src=\"http://example.com/bar\">", clean); + Assertions.assertEquals("<a href=\"http://example.com/foo\" rel=\"nofollow\">Link</a>\n<img src=\"http://example.com/bar\">", clean); } @Test public void preservesRelativeLinksIfConfigured() { String html = "<a href='/foo'>Link</a><img src='/bar'> <img src='javascript:alert()'>"; String clean = Jsoup.clean(html, "http://example.com/", Safelist.basicWithImages().preserveRelativeLinks(true)); - Assert.assertEquals("<a href=\"/foo\" rel=\"nofollow\">Link</a>\n<img src=\"/bar\"> \n<img>", clean); + Assertions.assertEquals("<a href=\"/foo\" rel=\"nofollow\">Link</a>\n<img src=\"/bar\"> \n<img>", clean); } @Test public void dropsUnresolvableRelativeLinks() { String html = "<a href='/foo'>Link</a>"; String clean = Jsoup.clean(html, Safelist.basic()); - Assert.assertEquals("<a rel=\"nofollow\">Link</a>", clean); + Assertions.assertEquals("<a rel=\"nofollow\">Link</a>", clean); } @Test public void handlesCustomProtocols() { String html = "<img src='cid:12345' /> <img src='data:gzzt' />"; String dropped = Jsoup.clean(html, Safelist.basicWithImages()); - Assert.assertEquals("<img> \n<img>", dropped); + Assertions.assertEquals("<img> \n<img>", dropped); String preserved = Jsoup.clean(html, Safelist.basicWithImages().addProtocols("img", "src", "cid", "data")); - Assert.assertEquals("<img src=\"cid:12345\"> \n<img src=\"data:gzzt\">", preserved); + Assertions.assertEquals("<img src=\"cid:12345\"> \n<img src=\"data:gzzt\">", preserved); } @Test public void handlesAllPseudoTag() { @@ -234,7 +233,7 @@ public class CleanerTest extends ExtendedITextTest { .addTags("p", "a"); String clean = Jsoup.clean(html, safelist); - Assert.assertEquals("<p class=\"foo\"><a class=\"qux\">link</a></p>", clean); + Assertions.assertEquals("<p class=\"foo\"><a class=\"qux\">link</a></p>", clean); } @Test public void addsTagOnAttributesIfNotSet() { @@ -243,7 +242,7 @@ public class CleanerTest extends ExtendedITextTest { .addAttributes("p", "class"); // ^^ safelist does not have explicit tag add for p, inferred from add attributes. String clean = Jsoup.clean(html, safelist); - Assert.assertEquals("<p class=\"foo\">One</p>", clean); + Assertions.assertEquals("<p class=\"foo\">One</p>", clean); } @Test public void supplyOutputSettings() { @@ -256,44 +255,44 @@ public class CleanerTest extends ExtendedITextTest { String html = "<div><p>&bernou;</p></div>"; String customOut = Jsoup.clean(html, "http://foo.com/", Safelist.relaxed(), os); String defaultOut = Jsoup.clean(html, "http://foo.com/", Safelist.relaxed()); - Assert.assertNotSame(defaultOut, customOut); + Assertions.assertNotSame(defaultOut, customOut); - Assert.assertEquals("<div><p>&Bscr;</p></div>", customOut); // entities now prefers shorted names if aliased - Assert.assertEquals("<div>\n" + + Assertions.assertEquals("<div><p>&Bscr;</p></div>", customOut); // entities now prefers shorted names if aliased + Assertions.assertEquals("<div>\n" + " <p>ℬ</p>\n" + "</div>", defaultOut); os.charset("ASCII"); os.escapeMode(Entities.EscapeMode.base); String customOut2 = Jsoup.clean(html, "http://foo.com/", Safelist.relaxed(), os); - Assert.assertEquals("<div><p>&#x212c;</p></div>", customOut2); + Assertions.assertEquals("<div><p>&#x212c;</p></div>", customOut2); } @Test public void handlesFramesets() { String dirty = "<html><head><script></script><noscript></noscript></head><frameset><frame src=\"foo\" /><frame src=\"foo\" /></frameset></html>"; String clean = Jsoup.clean(dirty, Safelist.basic()); - Assert.assertEquals("", clean); // nothing good can come out of that + Assertions.assertEquals("", clean); // nothing good can come out of that Document dirtyDoc = Jsoup.parse(dirty); Document cleanDoc = new Cleaner(Safelist.basic()).clean(dirtyDoc); - Assert.assertNotNull(cleanDoc); - Assert.assertEquals(0, cleanDoc.body().childNodeSize()); + Assertions.assertNotNull(cleanDoc); + Assertions.assertEquals(0, cleanDoc.body().childNodeSize()); } @Test public void cleansInternationalText() { - Assert.assertEquals("привет", Jsoup.clean("привет", Safelist.none())); + Assertions.assertEquals("привет", Jsoup.clean("привет", Safelist.none())); } @Test public void testScriptTagInSafeList() { Safelist safelist = Safelist.relaxed(); safelist.addTags( "script" ); - Assert.assertTrue( Jsoup.isValid("Hello<script>alert('Doh')</script>World !", safelist) ); + Assertions.assertTrue( Jsoup.isValid("Hello<script>alert('Doh')</script>World !", safelist) ); } @Test public void bailsIfRemovingProtocolThatsNotSet() { - Assert.assertThrows(IllegalArgumentException.class, () -> { + Assertions.assertThrows(IllegalArgumentException.class, () -> { // a case that came up on the email list Safelist w = Safelist.none(); @@ -306,21 +305,21 @@ public void bailsIfRemovingProtocolThatsNotSet() { @Test public void handlesControlCharactersAfterTagName() { String html = "<a/\06>"; String clean = Jsoup.clean(html, Safelist.basic()); - Assert.assertEquals("<a rel=\"nofollow\"></a>", clean); + Assertions.assertEquals("<a rel=\"nofollow\"></a>", clean); } @Test public void handlesAttributesWithNoValue() { // https://github.com/jhy/jsoup/issues/973 String clean = Jsoup.clean("<a href>Clean</a>", Safelist.basic()); - Assert.assertEquals("<a rel=\"nofollow\">Clean</a>", clean); + Assertions.assertEquals("<a rel=\"nofollow\">Clean</a>", clean); } @Test public void handlesNoHrefAttribute() { String dirty = "<a>One</a> <a href>Two</a>"; Safelist relaxedWithAnchor = Safelist.relaxed().addProtocols("a", "href", "#"); String clean = Jsoup.clean(dirty, relaxedWithAnchor); - Assert.assertEquals("<a>One</a> <a>Two</a>", clean); + Assertions.assertEquals("<a>One</a> <a>Two</a>", clean); } @Test public void handlesNestedQuotesInAttribute() { @@ -332,8 +331,8 @@ public void bailsIfRemovingProtocolThatsNotSet() { String clean = Jsoup.clean(orig, allow); boolean isValid = Jsoup.isValid(orig, allow); - Assert.assertEquals(orig, TextUtil.stripNewlines(clean)); // only difference is pretty print wrap & indent - Assert.assertTrue(isValid); + Assertions.assertEquals(orig, TextUtil.stripNewlines(clean)); // only difference is pretty print wrap & indent + Assertions.assertTrue(isValid); } @Test public void copiesOutputSettings() { @@ -343,7 +342,7 @@ public void bailsIfRemovingProtocolThatsNotSet() { Safelist whitelist = Safelist.none().addTags("p", "br"); Document result = new Cleaner(whitelist).clean(orig); - Assert.assertEquals(Document.OutputSettings.Syntax.xml, result.outputSettings().syntax()); - Assert.assertEquals("<p>test<br /></p>", result.body().html()); + Assertions.assertEquals(Document.OutputSettings.Syntax.xml, result.outputSettings().syntax()); + Assertions.assertEquals("<p>test<br /></p>", result.body().html()); } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/safety/CompatibilityTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/safety/CompatibilityTest.java index 6f07c07faa..ac95559294 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/safety/CompatibilityTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/safety/CompatibilityTest.java @@ -26,65 +26,64 @@ This file is part of the iText (R) project. import com.itextpdf.styledxmlparser.jsoup.nodes.Document; import com.itextpdf.styledxmlparser.jsoup.nodes.Entities; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; /** Tests for the deprecated {@link com.itextpdf.styledxmlparser.jsoup.safety.Whitelist} class source compatibility. Will be removed in <code>v.1.15.1</code>. No net new tests here so safe to blow up. */ -@Category(UnitTest.class) +@Tag("UnitTest") public class CompatibilityTest extends ExtendedITextTest { @Test public void resolvesRelativeLinks() { String html = "<a href='/foo'>Link</a><img src='/bar'>"; String clean = Jsoup.clean(html, "http://example.com/", Whitelist.basicWithImages()); - Assert.assertEquals("<a href=\"http://example.com/foo\" rel=\"nofollow\">Link</a>\n<img src=\"http://example.com/bar\">", clean); + Assertions.assertEquals("<a href=\"http://example.com/foo\" rel=\"nofollow\">Link</a>\n<img src=\"http://example.com/bar\">", clean); } @Test public void testDropsUnknownTags() { String h = "<p><custom foo=true>Test</custom></p>"; String cleanHtml = Jsoup.clean(h, Whitelist.relaxed()); - Assert.assertEquals("<p>Test</p>", cleanHtml); + Assertions.assertEquals("<p>Test</p>", cleanHtml); } @Test public void preservesRelativeLinksIfConfigured() { String html = "<a href='/foo'>Link</a><img src='/bar'> <img src='javascript:alert()'>"; String clean = Jsoup.clean(html, "http://example.com/", Whitelist.basicWithImages().preserveRelativeLinks(true)); - Assert.assertEquals("<a href=\"/foo\" rel=\"nofollow\">Link</a>\n<img src=\"/bar\"> \n<img>", clean); + Assertions.assertEquals("<a href=\"/foo\" rel=\"nofollow\">Link</a>\n<img src=\"/bar\"> \n<img>", clean); } @Test public void handlesCustomProtocols() { String html = "<img src='cid:12345' /> <img src='data:gzzt' />"; String dropped = Jsoup.clean(html, Whitelist.basicWithImages()); - Assert.assertEquals("<img> \n<img>", dropped); + Assertions.assertEquals("<img> \n<img>", dropped); String preserved = Jsoup.clean(html, Whitelist.basicWithImages().addProtocols("img", "src", "cid", "data")); - Assert.assertEquals("<img src=\"cid:12345\"> \n<img src=\"data:gzzt\">", preserved); + Assertions.assertEquals("<img src=\"cid:12345\"> \n<img src=\"data:gzzt\">", preserved); } @Test public void handlesFramesets() { String dirty = "<html><head><script></script><noscript></noscript></head><frameset><frame src=\"foo\" /><frame src=\"foo\" /></frameset></html>"; String clean = Jsoup.clean(dirty, Whitelist.basic()); - Assert.assertEquals("", clean); // nothing good can come out of that + Assertions.assertEquals("", clean); // nothing good can come out of that Document dirtyDoc = Jsoup.parse(dirty); Document cleanDoc = new Cleaner(Whitelist.basic()).clean(dirtyDoc); - Assert.assertNotNull(cleanDoc); - Assert.assertEquals(0, cleanDoc.body().childNodeSize()); + Assertions.assertNotNull(cleanDoc); + Assertions.assertEquals(0, cleanDoc.body().childNodeSize()); } @Test public void handlesCleanerFromWhitelist() { Cleaner cleaner = new Cleaner(Whitelist.basic()); Document doc = Jsoup.parse("<script>Script</script><p>Text</p>"); Document clean = cleaner.clean(doc); - Assert.assertEquals("<p>Text</p>", clean.body().html()); + Assertions.assertEquals("<p>Text</p>", clean.body().html()); } @Test @@ -98,16 +97,16 @@ public void supplyOutputSettings() { String html = "<div><p>&bernou;</p></div>"; String customOut = Jsoup.clean(html, "http://foo.com/", Whitelist.relaxed(), os); String defaultOut = Jsoup.clean(html, "http://foo.com/", Whitelist.relaxed()); - Assert.assertNotSame(defaultOut, customOut); + Assertions.assertNotSame(defaultOut, customOut); - Assert.assertEquals("<div><p>&Bscr;</p></div>", customOut); // entities now prefers shorted names if aliased - Assert.assertEquals("<div>\n" + + Assertions.assertEquals("<div><p>&Bscr;</p></div>", customOut); // entities now prefers shorted names if aliased + Assertions.assertEquals("<div>\n" + " <p>ℬ</p>\n" + "</div>", defaultOut); os.charset("ASCII"); os.escapeMode(Entities.EscapeMode.base); String customOut2 = Jsoup.clean(html, "http://foo.com/", Whitelist.relaxed(), os); - Assert.assertEquals("<div><p>&#x212c;</p></div>", customOut2); + Assertions.assertEquals("<div><p>&#x212c;</p></div>", customOut2); } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/safety/MultiLocaleTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/safety/MultiLocaleTest.java index bbcb6c4b2f..af0a4a0aba 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/safety/MultiLocaleTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/safety/MultiLocaleTest.java @@ -25,42 +25,33 @@ This file is part of the iText (R) project. import com.itextpdf.styledxmlparser.jsoup.Jsoup; import com.itextpdf.styledxmlparser.jsoup.TextUtil; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.After; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; import java.util.Arrays; import java.util.Collection; import java.util.Locale; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(Parameterized.class) -@Category(UnitTest.class) +@Tag("UnitTest") public class MultiLocaleTest extends ExtendedITextTest { private final Locale defaultLocale = Locale.getDefault(); - @Parameterized.Parameters public static Collection<Locale> locales() { return Arrays.asList(Locale.ENGLISH, new Locale("tr")); } - @After + @AfterEach public void setDefaultLocale() { Locale.setDefault(defaultLocale); } - private Locale locale; - - public MultiLocaleTest(Locale locale) { - this.locale = locale; - } - - @Test - public void safeListedProtocolShouldBeRetained() { + @ParameterizedTest + @MethodSource("locales") + public void safeListedProtocolShouldBeRetained(Locale locale) { Locale.setDefault(locale); Whitelist safelist = (Whitelist) Whitelist.none() @@ -70,11 +61,12 @@ public void safeListedProtocolShouldBeRetained() { String cleanHtml = Jsoup.clean("<a href=\"SOMETHING://x\"></a>", safelist); - Assert.assertEquals("<a href=\"SOMETHING://x\"></a>", TextUtil.stripNewlines(cleanHtml)); + Assertions.assertEquals("<a href=\"SOMETHING://x\"></a>", TextUtil.stripNewlines(cleanHtml)); } - @Test - public void cleanerSafeListedProtocolShouldBeRetained() { + @ParameterizedTest + @MethodSource("locales") + public void cleanerSafeListedProtocolShouldBeRetained(Locale locale) { Locale.setDefault(locale); Safelist safelist = Safelist.none() @@ -84,11 +76,12 @@ public void cleanerSafeListedProtocolShouldBeRetained() { String cleanHtml = Jsoup.clean("<a href=\"SOMETHING://x\"></a>", safelist); - Assert.assertEquals("<a href=\"SOMETHING://x\"></a>", TextUtil.stripNewlines(cleanHtml)); + Assertions.assertEquals("<a href=\"SOMETHING://x\"></a>", TextUtil.stripNewlines(cleanHtml)); } - @Test - public void compatibilitySafeListedProtocolShouldBeRetained() { + @ParameterizedTest + @MethodSource("locales") + public void compatibilitySafeListedProtocolShouldBeRetained(Locale locale) { Locale.setDefault(locale); Whitelist safelist = (Whitelist) Whitelist.none() @@ -98,6 +91,6 @@ public void compatibilitySafeListedProtocolShouldBeRetained() { String cleanHtml = Jsoup.clean("<a href=\"SOMETHING://x\"></a>", safelist); - Assert.assertEquals("<a href=\"SOMETHING://x\"></a>", TextUtil.stripNewlines(cleanHtml)); + Assertions.assertEquals("<a href=\"SOMETHING://x\"></a>", TextUtil.stripNewlines(cleanHtml)); } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/select/CssTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/select/CssTest.java index 2009670048..dd5f60bec4 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/select/CssTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/select/CssTest.java @@ -27,21 +27,19 @@ This file is part of the iText (R) project. import com.itextpdf.styledxmlparser.jsoup.nodes.Document; import com.itextpdf.styledxmlparser.jsoup.parser.Tag; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -@Category(UnitTest.class) +@org.junit.jupiter.api.Tag("UnitTest") public class CssTest extends ExtendedITextTest { private Document html = null; private static String htmlString; - @BeforeClass + @BeforeAll public static void initClass() { StringBuilder sb = new StringBuilder("<html><head></head><body>"); @@ -71,7 +69,7 @@ public static void initClass() { htmlString = sb.toString(); } - @Before + @BeforeEach public void init() { html = Jsoup.parse(htmlString); } @@ -195,17 +193,17 @@ public void lastOfType() { @Test public void empty() { final Elements sel = html.select(":empty"); - Assert.assertEquals(3, sel.size()); - Assert.assertEquals("head", sel.get(0).tagName()); - Assert.assertEquals("br", sel.get(1).tagName()); - Assert.assertEquals("p", sel.get(2).tagName()); + Assertions.assertEquals(3, sel.size()); + Assertions.assertEquals("head", sel.get(0).tagName()); + Assertions.assertEquals("br", sel.get(1).tagName()); + Assertions.assertEquals("p", sel.get(2).tagName()); } @Test public void onlyChild() { final Elements sel = html.select("span :only-child"); - Assert.assertEquals(1, sel.size()); - Assert.assertEquals("br", sel.get(0).tagName()); + Assertions.assertEquals(1, sel.size()); + Assertions.assertEquals("br", sel.get(0).tagName()); check(html.select("#only :only-child"), "only"); } @@ -213,35 +211,35 @@ public void onlyChild() { @Test public void onlyOfType() { final Elements sel = html.select(":only-of-type"); - Assert.assertEquals(6, sel.size()); - Assert.assertEquals("head", sel.get(0).tagName()); - Assert.assertEquals("body", sel.get(1).tagName()); - Assert.assertEquals("span", sel.get(2).tagName()); - Assert.assertEquals("br", sel.get(3).tagName()); - Assert.assertEquals("p", sel.get(4).tagName()); - Assert.assertTrue(sel.get(4).hasClass("empty")); - Assert.assertEquals("em", sel.get(5).tagName()); + Assertions.assertEquals(6, sel.size()); + Assertions.assertEquals("head", sel.get(0).tagName()); + Assertions.assertEquals("body", sel.get(1).tagName()); + Assertions.assertEquals("span", sel.get(2).tagName()); + Assertions.assertEquals("br", sel.get(3).tagName()); + Assertions.assertEquals("p", sel.get(4).tagName()); + Assertions.assertTrue(sel.get(4).hasClass("empty")); + Assertions.assertEquals("em", sel.get(5).tagName()); } protected void check(Elements result, String...expectedContent ) { - Assert.assertEquals(expectedContent.length, result.size()); + Assertions.assertEquals(expectedContent.length, result.size()); for (int i = 0; i < expectedContent.length; i++) { - Assert.assertNotNull(result.get(i)); - Assert.assertEquals(expectedContent[i], result.get(i).ownText()); + Assertions.assertNotNull(result.get(i)); + Assertions.assertEquals(expectedContent[i], result.get(i).ownText()); } } @Test public void root() { Elements sel = html.select(":root"); - Assert.assertEquals(1, sel.size()); - Assert.assertNotNull(sel.get(0)); - Assert.assertEquals(Tag.valueOf("html"), sel.get(0).tag()); + Assertions.assertEquals(1, sel.size()); + Assertions.assertNotNull(sel.get(0)); + Assertions.assertEquals(Tag.valueOf("html"), sel.get(0).tag()); Elements sel2 = html.select("body").select(":root"); - Assert.assertEquals(1, sel2.size()); - Assert.assertNotNull(sel2.get(0)); - Assert.assertEquals(Tag.valueOf("body"), sel2.get(0).tag()); + Assertions.assertEquals(1, sel2.size()); + Assertions.assertNotNull(sel2.get(0)); + Assertions.assertEquals(Tag.valueOf("body"), sel2.get(0).tag()); } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/select/ElementsTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/select/ElementsTest.java index 90023c021a..d8c0b3cd82 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/select/ElementsTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/select/ElementsTest.java @@ -32,51 +32,50 @@ This file is part of the iText (R) project. import com.itextpdf.styledxmlparser.jsoup.nodes.Node; import com.itextpdf.styledxmlparser.jsoup.nodes.TextNode; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.util.List; /** Tests for ElementList. */ -@Category(UnitTest.class) +@Tag("UnitTest") public class ElementsTest extends ExtendedITextTest { @Test public void filter() { String h = "<p>Excl</p><div class=headline><p>Hello</p><p>There</p></div><div class=headline><h1>Headline</h1></div>"; Document doc = Jsoup.parse(h); Elements els = doc.select(".headline").select("p"); - Assert.assertEquals(2, els.size()); - Assert.assertEquals("Hello", els.get(0).text()); - Assert.assertEquals("There", els.get(1).text()); + Assertions.assertEquals(2, els.size()); + Assertions.assertEquals("Hello", els.get(0).text()); + Assertions.assertEquals("There", els.get(1).text()); } @Test public void attributes() { String h = "<p title=foo><p title=bar><p class=foo><p class=bar>"; Document doc = Jsoup.parse(h); Elements withTitle = doc.select("p[title]"); - Assert.assertEquals(2, withTitle.size()); - Assert.assertTrue(withTitle.hasAttr("title")); - Assert.assertFalse(withTitle.hasAttr("class")); - Assert.assertEquals("foo", withTitle.attr("title")); + Assertions.assertEquals(2, withTitle.size()); + Assertions.assertTrue(withTitle.hasAttr("title")); + Assertions.assertFalse(withTitle.hasAttr("class")); + Assertions.assertEquals("foo", withTitle.attr("title")); withTitle.removeAttr("title"); - Assert.assertEquals(2, withTitle.size()); // existing Elements are not reevaluated - Assert.assertEquals(0, doc.select("p[title]").size()); + Assertions.assertEquals(2, withTitle.size()); // existing Elements are not reevaluated + Assertions.assertEquals(0, doc.select("p[title]").size()); Elements ps = doc.select("p").attr("style", "classy"); - Assert.assertEquals(4, ps.size()); - Assert.assertEquals("classy", ps.last().attr("style")); - Assert.assertEquals("bar", ps.last().attr("class")); + Assertions.assertEquals(4, ps.size()); + Assertions.assertEquals("classy", ps.last().attr("style")); + Assertions.assertEquals("bar", ps.last().attr("class")); } @Test public void hasAttr() { Document doc = Jsoup.parse("<p title=foo><p title=bar><p class=foo><p class=bar>"); Elements ps = doc.select("p"); - Assert.assertTrue(ps.hasAttr("class")); - Assert.assertFalse(ps.hasAttr("style")); + Assertions.assertTrue(ps.hasAttr("class")); + Assertions.assertFalse(ps.hasAttr("style")); } @Test public void hasAbsAttr() { @@ -84,15 +83,15 @@ public class ElementsTest extends ExtendedITextTest { Elements one = doc.select("#1"); Elements two = doc.select("#2"); Elements both = doc.select("a"); - Assert.assertFalse(one.hasAttr("abs:href")); - Assert.assertTrue(two.hasAttr("abs:href")); - Assert.assertTrue(both.hasAttr("abs:href")); // hits on #2 + Assertions.assertFalse(one.hasAttr("abs:href")); + Assertions.assertTrue(two.hasAttr("abs:href")); + Assertions.assertTrue(both.hasAttr("abs:href")); // hits on #2 } @Test public void attr() { Document doc = Jsoup.parse("<p title=foo><p title=bar><p class=foo><p class=bar>"); String classVal = doc.select("p").attr("class"); - Assert.assertEquals("foo", classVal); + Assertions.assertEquals("foo", classVal); } @Test public void absAttr() { @@ -101,23 +100,23 @@ public class ElementsTest extends ExtendedITextTest { Elements two = doc.select("#2"); Elements both = doc.select("a"); - Assert.assertEquals("", one.attr("abs:href")); - Assert.assertEquals("https://jsoup.org/", two.attr("abs:href")); - Assert.assertEquals("https://jsoup.org/", both.attr("abs:href")); + Assertions.assertEquals("", one.attr("abs:href")); + Assertions.assertEquals("https://jsoup.org/", two.attr("abs:href")); + Assertions.assertEquals("https://jsoup.org/", both.attr("abs:href")); } @Test public void classes() { Document doc = Jsoup.parse("<div><p class='mellow yellow'></p><p class='red green'></p>"); Elements els = doc.select("p"); - Assert.assertTrue(els.hasClass("red")); - Assert.assertFalse(els.hasClass("blue")); + Assertions.assertTrue(els.hasClass("red")); + Assertions.assertFalse(els.hasClass("blue")); els.addClass("blue"); els.removeClass("yellow"); els.toggleClass("mellow"); - Assert.assertEquals("blue", els.get(0).className()); - Assert.assertEquals("red green blue mellow", els.get(1).className()); + Assertions.assertEquals("blue", els.get(0).className()); + Assertions.assertEquals("red green blue mellow", els.get(1).className()); } @Test public void hasClassCaseInsensitive() { @@ -126,39 +125,39 @@ public class ElementsTest extends ExtendedITextTest { Element two = els.get(1); Element thr = els.get(2); - Assert.assertTrue(one.hasClass("One")); - Assert.assertTrue(one.hasClass("ONE")); + Assertions.assertTrue(one.hasClass("One")); + Assertions.assertTrue(one.hasClass("ONE")); - Assert.assertTrue(two.hasClass("TWO")); - Assert.assertTrue(two.hasClass("Two")); + Assertions.assertTrue(two.hasClass("TWO")); + Assertions.assertTrue(two.hasClass("Two")); - Assert.assertTrue(thr.hasClass("ThreE")); - Assert.assertTrue(thr.hasClass("three")); + Assertions.assertTrue(thr.hasClass("ThreE")); + Assertions.assertTrue(thr.hasClass("three")); } @Test public void text() { String h = "<div><p>Hello<p>there<p>world</div>"; Document doc = Jsoup.parse(h); - Assert.assertEquals("Hello there world", doc.select("div > *").text()); + Assertions.assertEquals("Hello there world", doc.select("div > *").text()); } @Test public void hasText() { Document doc = Jsoup.parse("<div><p>Hello</p></div><div><p></p></div>"); Elements divs = doc.select("div"); - Assert.assertTrue(divs.hasText()); - Assert.assertFalse(doc.select("div + div").hasText()); + Assertions.assertTrue(divs.hasText()); + Assertions.assertFalse(doc.select("div + div").hasText()); } @Test public void html() { Document doc = Jsoup.parse("<div><p>Hello</p></div><div><p>There</p></div>"); Elements divs = doc.select("div"); - Assert.assertEquals("<p>Hello</p>\n<p>There</p>", divs.html()); + Assertions.assertEquals("<p>Hello</p>\n<p>There</p>", divs.html()); } @Test public void outerHtml() { Document doc = Jsoup.parse("<div><p>Hello</p></div><div><p>There</p></div>"); Elements divs = doc.select("div"); - Assert.assertEquals("<div><p>Hello</p></div><div><p>There</p></div>", TextUtil.stripNewlines(divs.outerHtml())); + Assertions.assertEquals("<div><p>Hello</p></div><div><p>There</p></div>", TextUtil.stripNewlines(divs.outerHtml())); } @Test public void setHtml() { @@ -166,49 +165,49 @@ public class ElementsTest extends ExtendedITextTest { Elements ps = doc.select("p"); ps.prepend("<b>Bold</b>").append("<i>Ital</i>"); - Assert.assertEquals("<p><b>Bold</b>Two<i>Ital</i></p>", TextUtil.stripNewlines(ps.get(1).outerHtml())); + Assertions.assertEquals("<p><b>Bold</b>Two<i>Ital</i></p>", TextUtil.stripNewlines(ps.get(1).outerHtml())); ps.html("<span>Gone</span>"); - Assert.assertEquals("<p><span>Gone</span></p>", TextUtil.stripNewlines(ps.get(1).outerHtml())); + Assertions.assertEquals("<p><span>Gone</span></p>", TextUtil.stripNewlines(ps.get(1).outerHtml())); } @Test public void val() { Document doc = Jsoup.parse("<input value='one' /><textarea>two</textarea>"); Elements els = doc.select("input, textarea"); - Assert.assertEquals(2, els.size()); - Assert.assertEquals("one", els.val()); - Assert.assertEquals("two", els.last().val()); + Assertions.assertEquals(2, els.size()); + Assertions.assertEquals("one", els.val()); + Assertions.assertEquals("two", els.last().val()); els.val("three"); - Assert.assertEquals("three", els.first().val()); - Assert.assertEquals("three", els.last().val()); - Assert.assertEquals("<textarea>three</textarea>", els.last().outerHtml()); + Assertions.assertEquals("three", els.first().val()); + Assertions.assertEquals("three", els.last().val()); + Assertions.assertEquals("<textarea>three</textarea>", els.last().outerHtml()); } @Test public void before() { Document doc = Jsoup.parse("<p>This <a>is</a> <a>jsoup</a>.</p>"); doc.select("a").before("<span>foo</span>"); - Assert.assertEquals("<p>This <span>foo</span><a>is</a> <span>foo</span><a>jsoup</a>.</p>", TextUtil.stripNewlines(doc.body().html())); + Assertions.assertEquals("<p>This <span>foo</span><a>is</a> <span>foo</span><a>jsoup</a>.</p>", TextUtil.stripNewlines(doc.body().html())); } @Test public void after() { Document doc = Jsoup.parse("<p>This <a>is</a> <a>jsoup</a>.</p>"); doc.select("a").after("<span>foo</span>"); - Assert.assertEquals("<p>This <a>is</a><span>foo</span> <a>jsoup</a><span>foo</span>.</p>", TextUtil.stripNewlines(doc.body().html())); + Assertions.assertEquals("<p>This <a>is</a><span>foo</span> <a>jsoup</a><span>foo</span>.</p>", TextUtil.stripNewlines(doc.body().html())); } @Test public void wrap() { String h = "<p><b>This</b> is <b>jsoup</b></p>"; Document doc = Jsoup.parse(h); doc.select("b").wrap("<i></i>"); - Assert.assertEquals("<p><i><b>This</b></i> is <i><b>jsoup</b></i></p>", doc.body().html()); + Assertions.assertEquals("<p><i><b>This</b></i> is <i><b>jsoup</b></i></p>", doc.body().html()); } @Test public void wrapDiv() { String h = "<p><b>This</b> is <b>jsoup</b>.</p> <p>How do you like it?</p>"; Document doc = Jsoup.parse(h); doc.select("p").wrap("<div></div>"); - Assert.assertEquals("<div><p><b>This</b> is <b>jsoup</b>.</p></div> <div><p>How do you like it?</p></div>", + Assertions.assertEquals("<div><p><b>This</b> is <b>jsoup</b>.</p></div> <div><p>How do you like it?</p></div>", TextUtil.stripNewlines(doc.body().html())); } @@ -216,21 +215,21 @@ public class ElementsTest extends ExtendedITextTest { String h = "<div><font>One</font> <font><a href=\"/\">Two</a></font></div"; Document doc = Jsoup.parse(h); doc.select("font").unwrap(); - Assert.assertEquals("<div>One <a href=\"/\">Two</a></div>", TextUtil.stripNewlines(doc.body().html())); + Assertions.assertEquals("<div>One <a href=\"/\">Two</a></div>", TextUtil.stripNewlines(doc.body().html())); } @Test public void unwrapP() { String h = "<p><a>One</a> Two</p> Three <i>Four</i> <p>Fix <i>Six</i></p>"; Document doc = Jsoup.parse(h); doc.select("p").unwrap(); - Assert.assertEquals("<a>One</a> Two Three <i>Four</i> Fix <i>Six</i>", TextUtil.stripNewlines(doc.body().html())); + Assertions.assertEquals("<a>One</a> Two Three <i>Four</i> Fix <i>Six</i>", TextUtil.stripNewlines(doc.body().html())); } @Test public void unwrapKeepsSpace() { String h = "<p>One <span>two</span> <span>three</span> four</p>"; Document doc = Jsoup.parse(h); doc.select("span").unwrap(); - Assert.assertEquals("<p>One two three four</p>", doc.body().html()); + Assertions.assertEquals("<p>One two three four</p>", doc.body().html()); } @Test public void empty() { @@ -238,7 +237,7 @@ public class ElementsTest extends ExtendedITextTest { doc.outputSettings().prettyPrint(false); doc.select("p").empty(); - Assert.assertEquals("<div><p></p> <p></p></div>", doc.body().html()); + Assertions.assertEquals("<div><p></p> <p></p></div>", doc.body().html()); } @Test public void remove() { @@ -246,51 +245,51 @@ public class ElementsTest extends ExtendedITextTest { doc.outputSettings().prettyPrint(false); doc.select("p").remove(); - Assert.assertEquals("<div> jsoup </div>", doc.body().html()); + Assertions.assertEquals("<div> jsoup </div>", doc.body().html()); } @Test public void eq() { String h = "<p>Hello<p>there<p>world"; Document doc = Jsoup.parse(h); - Assert.assertEquals("there", doc.select("p").eq(1).text()); - Assert.assertEquals("there", doc.select("p").get(1).text()); + Assertions.assertEquals("there", doc.select("p").eq(1).text()); + Assertions.assertEquals("there", doc.select("p").get(1).text()); } @Test public void is() { String h = "<p>Hello<p title=foo>there<p>world"; Document doc = Jsoup.parse(h); Elements ps = doc.select("p"); - Assert.assertTrue(ps.is("[title=foo]")); - Assert.assertFalse(ps.is("[title=bar]")); + Assertions.assertTrue(ps.is("[title=foo]")); + Assertions.assertFalse(ps.is("[title=bar]")); } @Test public void parents() { Document doc = Jsoup.parse("<div><p>Hello</p></div><p>There</p>"); Elements parents = doc.select("p").parents(); - Assert.assertEquals(3, parents.size()); - Assert.assertEquals("div", parents.get(0).tagName()); - Assert.assertEquals("body", parents.get(1).tagName()); - Assert.assertEquals("html", parents.get(2).tagName()); + Assertions.assertEquals(3, parents.size()); + Assertions.assertEquals("div", parents.get(0).tagName()); + Assertions.assertEquals("body", parents.get(1).tagName()); + Assertions.assertEquals("html", parents.get(2).tagName()); } @Test public void not() { Document doc = Jsoup.parse("<div id=1><p>One</p></div> <div id=2><p><span>Two</span></p></div>"); Elements div1 = doc.select("div").not(":has(p > span)"); - Assert.assertEquals(1, div1.size()); - Assert.assertEquals("1", div1.first().id()); + Assertions.assertEquals(1, div1.size()); + Assertions.assertEquals("1", div1.first().id()); Elements div2 = doc.select("div").not("#1"); - Assert.assertEquals(1, div2.size()); - Assert.assertEquals("2", div2.first().id()); + Assertions.assertEquals(1, div2.size()); + Assertions.assertEquals("2", div2.first().id()); } @Test public void tagNameSet() { Document doc = Jsoup.parse("<p>Hello <i>there</i> <i>now</i></p>"); doc.select("i").tagName("em"); - Assert.assertEquals("<p>Hello <em>there</em> <em>now</em></p>", doc.body().html()); + Assertions.assertEquals("<p>Hello <em>there</em> <em>now</em></p>", doc.body().html()); } @Test public void traverse() { @@ -307,134 +306,134 @@ public void tail(Node node, int depth) { accum.append("</").append(node.nodeName()).append(">"); } }); - Assert.assertEquals("<div><p><#text></#text></p></div><div><#text></#text></div>", accum.toString()); + Assertions.assertEquals("<div><p><#text></#text></p></div><div><#text></#text></div>", accum.toString()); } @Test public void forms() { Document doc = Jsoup.parse("<form id=1><input name=q></form><div /><form id=2><input name=f></form>"); Elements els = doc.select("form, div"); - Assert.assertEquals(3, els.size()); + Assertions.assertEquals(3, els.size()); List<FormElement> forms = els.forms(); - Assert.assertEquals(2, forms.size()); - Assert.assertNotNull(forms.get(0)); - Assert.assertNotNull(forms.get(1)); - Assert.assertEquals("1", forms.get(0).id()); - Assert.assertEquals("2", forms.get(1).id()); + Assertions.assertEquals(2, forms.size()); + Assertions.assertNotNull(forms.get(0)); + Assertions.assertNotNull(forms.get(1)); + Assertions.assertEquals("1", forms.get(0).id()); + Assertions.assertEquals("2", forms.get(1).id()); } @Test public void comments() { Document doc = Jsoup.parse("<!-- comment1 --><p><!-- comment2 --><p class=two><!-- comment3 -->"); List<Comment> comments = doc.select("p").comments(); - Assert.assertEquals(2, comments.size()); - Assert.assertEquals(" comment2 ", comments.get(0).getData()); - Assert.assertEquals(" comment3 ", comments.get(1).getData()); + Assertions.assertEquals(2, comments.size()); + Assertions.assertEquals(" comment2 ", comments.get(0).getData()); + Assertions.assertEquals(" comment3 ", comments.get(1).getData()); List<Comment> comments1 = doc.select("p.two").comments(); - Assert.assertEquals(1, comments1.size()); - Assert.assertEquals(" comment3 ", comments1.get(0).getData()); + Assertions.assertEquals(1, comments1.size()); + Assertions.assertEquals(" comment3 ", comments1.get(0).getData()); } @Test public void textNodes() { Document doc = Jsoup.parse("One<p>Two<a>Three</a><p>Four</p>Five"); List<TextNode> textNodes = doc.select("p").textNodes(); - Assert.assertEquals(2, textNodes.size()); - Assert.assertEquals("Two", textNodes.get(0).text()); - Assert.assertEquals("Four", textNodes.get(1).text()); + Assertions.assertEquals(2, textNodes.size()); + Assertions.assertEquals("Two", textNodes.get(0).text()); + Assertions.assertEquals("Four", textNodes.get(1).text()); } @Test public void dataNodes() { Document doc = Jsoup.parse("<p>One</p><script>Two</script><style>Three</style>"); List<DataNode> dataNodes = doc.select("p, script, style").dataNodes(); - Assert.assertEquals(2, dataNodes.size()); - Assert.assertEquals("Two", dataNodes.get(0).getWholeData()); - Assert.assertEquals("Three", dataNodes.get(1).getWholeData()); + Assertions.assertEquals(2, dataNodes.size()); + Assertions.assertEquals("Two", dataNodes.get(0).getWholeData()); + Assertions.assertEquals("Three", dataNodes.get(1).getWholeData()); doc = Jsoup.parse("<head><script type=application/json><crux></script><script src=foo>Blah</script>"); Elements script = doc.select("script[type=application/json]"); List<DataNode> scriptNode = script.dataNodes(); - Assert.assertEquals(1, scriptNode.size()); + Assertions.assertEquals(1, scriptNode.size()); DataNode dataNode = scriptNode.get(0); - Assert.assertEquals("<crux>", dataNode.getWholeData()); + Assertions.assertEquals("<crux>", dataNode.getWholeData()); // check if they're live dataNode.setWholeData("<cromulent>"); - Assert.assertEquals("<script type=\"application/json\"><cromulent></script>", script.outerHtml()); + Assertions.assertEquals("<script type=\"application/json\"><cromulent></script>", script.outerHtml()); } @Test public void nodesEmpty() { Document doc = Jsoup.parse("<p>"); - Assert.assertEquals(0, doc.select("form").textNodes().size()); + Assertions.assertEquals(0, doc.select("form").textNodes().size()); } @Test public void classWithHyphen() { Document doc = Jsoup.parse("<p class='tab-nav'>Check</p>"); Elements els = doc.getElementsByClass("tab-nav"); - Assert.assertEquals(1, els.size()); - Assert.assertEquals("Check", els.text()); + Assertions.assertEquals(1, els.size()); + Assertions.assertEquals("Check", els.text()); } @Test public void siblings() { Document doc = Jsoup.parse("<div><p>1<p>2<p>3<p>4<p>5<p>6</div><div><p>7<p>8<p>9<p>10<p>11<p>12</div>"); Elements els = doc.select("p:eq(3)"); // gets p4 and p10 - Assert.assertEquals(2, els.size()); + Assertions.assertEquals(2, els.size()); Elements next = els.next(); - Assert.assertEquals(2, next.size()); - Assert.assertEquals("5", next.first().text()); - Assert.assertEquals("11", next.last().text()); + Assertions.assertEquals(2, next.size()); + Assertions.assertEquals("5", next.first().text()); + Assertions.assertEquals("11", next.last().text()); - Assert.assertEquals(0, els.next("p:contains(6)").size()); + Assertions.assertEquals(0, els.next("p:contains(6)").size()); final Elements nextF = els.next("p:contains(5)"); - Assert.assertEquals(1, nextF.size()); - Assert.assertEquals("5", nextF.first().text()); + Assertions.assertEquals(1, nextF.size()); + Assertions.assertEquals("5", nextF.first().text()); Elements nextA = els.nextAll(); - Assert.assertEquals(4, nextA.size()); - Assert.assertEquals("5", nextA.first().text()); - Assert.assertEquals("12", nextA.last().text()); + Assertions.assertEquals(4, nextA.size()); + Assertions.assertEquals("5", nextA.first().text()); + Assertions.assertEquals("12", nextA.last().text()); Elements nextAF = els.nextAll("p:contains(6)"); - Assert.assertEquals(1, nextAF.size()); - Assert.assertEquals("6", nextAF.first().text()); + Assertions.assertEquals(1, nextAF.size()); + Assertions.assertEquals("6", nextAF.first().text()); Elements prev = els.prev(); - Assert.assertEquals(2, prev.size()); - Assert.assertEquals("3", prev.first().text()); - Assert.assertEquals("9", prev.last().text()); + Assertions.assertEquals(2, prev.size()); + Assertions.assertEquals("3", prev.first().text()); + Assertions.assertEquals("9", prev.last().text()); - Assert.assertEquals(0, els.prev("p:contains(1)").size()); + Assertions.assertEquals(0, els.prev("p:contains(1)").size()); final Elements prevF = els.prev("p:contains(3)"); - Assert.assertEquals(1, prevF.size()); - Assert.assertEquals("3", prevF.first().text()); + Assertions.assertEquals(1, prevF.size()); + Assertions.assertEquals("3", prevF.first().text()); Elements prevA = els.prevAll(); - Assert.assertEquals(6, prevA.size()); - Assert.assertEquals("3", prevA.first().text()); - Assert.assertEquals("7", prevA.last().text()); + Assertions.assertEquals(6, prevA.size()); + Assertions.assertEquals("3", prevA.first().text()); + Assertions.assertEquals("7", prevA.last().text()); Elements prevAF = els.prevAll("p:contains(1)"); - Assert.assertEquals(1, prevAF.size()); - Assert.assertEquals("1", prevAF.first().text()); + Assertions.assertEquals(1, prevAF.size()); + Assertions.assertEquals("1", prevAF.first().text()); } @Test public void eachText() { Document doc = Jsoup.parse("<div><p>1<p>2<p>3<p>4<p>5<p>6</div><div><p>7<p>8<p>9<p>10<p>11<p>12<p></p></div>"); List<String> divText = doc.select("div").eachText(); - Assert.assertEquals(2, divText.size()); - Assert.assertEquals("1 2 3 4 5 6", divText.get(0)); - Assert.assertEquals("7 8 9 10 11 12", divText.get(1)); + Assertions.assertEquals(2, divText.size()); + Assertions.assertEquals("1 2 3 4 5 6", divText.get(0)); + Assertions.assertEquals("7 8 9 10 11 12", divText.get(1)); List<String> pText = doc.select("p").eachText(); Elements ps = doc.select("p"); - Assert.assertEquals(13, ps.size()); - Assert.assertEquals(12, pText.size()); // not 13, as last doesn't have text - Assert.assertEquals("1", pText.get(0)); - Assert.assertEquals("2", pText.get(1)); - Assert.assertEquals("5", pText.get(4)); - Assert.assertEquals("7", pText.get(6)); - Assert.assertEquals("12", pText.get(11)); + Assertions.assertEquals(13, ps.size()); + Assertions.assertEquals(12, pText.size()); // not 13, as last doesn't have text + Assertions.assertEquals("1", pText.get(0)); + Assertions.assertEquals("2", pText.get(1)); + Assertions.assertEquals("5", pText.get(4)); + Assertions.assertEquals("7", pText.get(6)); + Assertions.assertEquals("12", pText.get(11)); } @Test public void eachAttr() { @@ -443,17 +442,17 @@ public void tail(Node node, int depth) { "http://example.com"); List<String> hrefAttrs = doc.select("a").eachAttr("href"); - Assert.assertEquals(3, hrefAttrs.size()); - Assert.assertEquals("/foo", hrefAttrs.get(0)); - Assert.assertEquals("http://example.com/bar", hrefAttrs.get(1)); - Assert.assertEquals("", hrefAttrs.get(2)); - Assert.assertEquals(4, doc.select("a").size()); + Assertions.assertEquals(3, hrefAttrs.size()); + Assertions.assertEquals("/foo", hrefAttrs.get(0)); + Assertions.assertEquals("http://example.com/bar", hrefAttrs.get(1)); + Assertions.assertEquals("", hrefAttrs.get(2)); + Assertions.assertEquals(4, doc.select("a").size()); List<String> absAttrs = doc.select("a").eachAttr("abs:href"); - Assert.assertEquals(3, absAttrs.size()); - Assert.assertEquals(3, absAttrs.size()); - Assert.assertEquals("http://example.com/foo", absAttrs.get(0)); - Assert.assertEquals("http://example.com/bar", absAttrs.get(1)); - Assert.assertEquals("http://example.com", absAttrs.get(2)); + Assertions.assertEquals(3, absAttrs.size()); + Assertions.assertEquals(3, absAttrs.size()); + Assertions.assertEquals("http://example.com/foo", absAttrs.get(0)); + Assertions.assertEquals("http://example.com/bar", absAttrs.get(1)); + Assertions.assertEquals("http://example.com", absAttrs.get(2)); } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/select/MultiLocaleTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/select/MultiLocaleTest.java index e8af3c3160..6f2034d727 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/select/MultiLocaleTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/select/MultiLocaleTest.java @@ -26,42 +26,33 @@ This file is part of the iText (R) project. import com.itextpdf.styledxmlparser.jsoup.nodes.Document; import com.itextpdf.styledxmlparser.jsoup.nodes.Element; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.After; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import java.util.Arrays; import java.util.Collection; import java.util.Locale; -@RunWith(Parameterized.class) -@Category(UnitTest.class) +@Tag("UnitTest") public class MultiLocaleTest extends ExtendedITextTest { private final Locale defaultLocale = Locale.getDefault(); - @Parameterized.Parameters public static Collection<Locale> locales() { return Arrays.asList(Locale.ENGLISH, new Locale("tr")); } - @After + @AfterEach public void setDefaultLocale() { Locale.setDefault(defaultLocale); } - private Locale locale; - - public MultiLocaleTest(Locale locale) { - this.locale = locale; - } - - @Test - public void testByAttribute() { + @ParameterizedTest + @MethodSource("locales") + public void testByAttribute(Locale locale) { Locale.setDefault(locale); String h = "<div Title=Foo /><div Title=Bar /><div Style=Qux /><div title=Balim /><div title=SLIM />" + @@ -69,88 +60,91 @@ public void testByAttribute() { Document doc = Jsoup.parse(h); Elements withTitle = doc.select("[title]"); - Assert.assertEquals(4, withTitle.size()); + Assertions.assertEquals(4, withTitle.size()); Elements foo = doc.select("[TITLE=foo]"); - Assert.assertEquals(1, foo.size()); + Assertions.assertEquals(1, foo.size()); Elements foo2 = doc.select("[title=\"foo\"]"); - Assert.assertEquals(1, foo2.size()); + Assertions.assertEquals(1, foo2.size()); Elements foo3 = doc.select("[title=\"Foo\"]"); - Assert.assertEquals(1, foo3.size()); + Assertions.assertEquals(1, foo3.size()); Elements dataName = doc.select("[data-name=\"with spaces\"]"); - Assert.assertEquals(1, dataName.size()); - Assert.assertEquals("with spaces", dataName.first().attr("data-name")); + Assertions.assertEquals(1, dataName.size()); + Assertions.assertEquals("with spaces", dataName.first().attr("data-name")); Elements not = doc.select("div[title!=bar]"); - Assert.assertEquals(5, not.size()); - Assert.assertEquals("Foo", not.first().attr("title")); + Assertions.assertEquals(5, not.size()); + Assertions.assertEquals("Foo", not.first().attr("title")); Elements starts = doc.select("[title^=ba]"); - Assert.assertEquals(2, starts.size()); - Assert.assertEquals("Bar", starts.first().attr("title")); - Assert.assertEquals("Balim", starts.last().attr("title")); + Assertions.assertEquals(2, starts.size()); + Assertions.assertEquals("Bar", starts.first().attr("title")); + Assertions.assertEquals("Balim", starts.last().attr("title")); Elements ends = doc.select("[title$=im]"); - Assert.assertEquals(2, ends.size()); - Assert.assertEquals("Balim", ends.first().attr("title")); - Assert.assertEquals("SLIM", ends.last().attr("title")); + Assertions.assertEquals(2, ends.size()); + Assertions.assertEquals("Balim", ends.first().attr("title")); + Assertions.assertEquals("SLIM", ends.last().attr("title")); Elements contains = doc.select("[title*=i]"); - Assert.assertEquals(2, contains.size()); - Assert.assertEquals("Balim", contains.first().attr("title")); - Assert.assertEquals("SLIM", contains.last().attr("title")); + Assertions.assertEquals(2, contains.size()); + Assertions.assertEquals("Balim", contains.first().attr("title")); + Assertions.assertEquals("SLIM", contains.last().attr("title")); } - @Test - public void testPseudoContains() { + @ParameterizedTest + @MethodSource("locales") + public void testPseudoContains(Locale locale) { Locale.setDefault(locale); Document doc = Jsoup.parse("<div><p>The Rain.</p> <p class=light>The <i>RAIN</i>.</p> <p>Rain, the.</p></div>"); Elements ps1 = doc.select("p:contains(Rain)"); - Assert.assertEquals(3, ps1.size()); + Assertions.assertEquals(3, ps1.size()); Elements ps2 = doc.select("p:contains(the rain)"); - Assert.assertEquals(2, ps2.size()); - Assert.assertEquals("The Rain.", ps2.first().html()); - Assert.assertEquals("The <i>RAIN</i>.", ps2.last().html()); + Assertions.assertEquals(2, ps2.size()); + Assertions.assertEquals("The Rain.", ps2.first().html()); + Assertions.assertEquals("The <i>RAIN</i>.", ps2.last().html()); Elements ps3 = doc.select("p:contains(the Rain):has(i)"); - Assert.assertEquals(1, ps3.size()); - Assert.assertEquals("light", ps3.first().className()); + Assertions.assertEquals(1, ps3.size()); + Assertions.assertEquals("light", ps3.first().className()); Elements ps4 = doc.select(".light:contains(rain)"); - Assert.assertEquals(1, ps4.size()); - Assert.assertEquals("light", ps3.first().className()); + Assertions.assertEquals(1, ps4.size()); + Assertions.assertEquals("light", ps3.first().className()); Elements ps5 = doc.select(":contains(rain)"); - Assert.assertEquals(8, ps5.size()); // html, body, div,... + Assertions.assertEquals(8, ps5.size()); // html, body, div,... Elements ps6 = doc.select(":contains(RAIN)"); - Assert.assertEquals(8, ps6.size()); + Assertions.assertEquals(8, ps6.size()); } - @Test - public void containsOwn() { + @ParameterizedTest + @MethodSource("locales") + public void containsOwn(Locale locale) { Locale.setDefault(locale); Document doc = Jsoup.parse("<p id=1>Hello <b>there</b> igor</p>"); Elements ps = doc.select("p:containsOwn(Hello IGOR)"); - Assert.assertEquals(1, ps.size()); - Assert.assertEquals("1", ps.first().id()); + Assertions.assertEquals(1, ps.size()); + Assertions.assertEquals("1", ps.first().id()); - Assert.assertEquals(0, doc.select("p:containsOwn(there)").size()); + Assertions.assertEquals(0, doc.select("p:containsOwn(there)").size()); Document doc2 = Jsoup.parse("<p>Hello <b>there</b> IGOR</p>"); - Assert.assertEquals(1, doc2.select("p:containsOwn(igor)").size()); + Assertions.assertEquals(1, doc2.select("p:containsOwn(igor)").size()); } - @Test - public void containsData() { + @ParameterizedTest + @MethodSource("locales") + public void containsData(Locale locale) { Locale.setDefault(locale); String html = "<p>function</p><script>FUNCTION</script><style>item</style><span><!-- comments --></span>"; @@ -163,33 +157,34 @@ public void containsData() { Elements dataEls4 = body.select(":containsData(o)"); Elements dataEls5 = body.select("style:containsData(ITEM)"); - Assert.assertEquals(2, dataEls1.size()); // body and script - Assert.assertEquals(1, dataEls2.size()); - Assert.assertEquals(dataEls1.last(), dataEls2.first()); - Assert.assertEquals("<script>FUNCTION</script>", dataEls2.outerHtml()); - Assert.assertEquals(1, dataEls3.size()); - Assert.assertEquals("span", dataEls3.first().tagName()); - Assert.assertEquals(3, dataEls4.size()); - Assert.assertEquals("body", dataEls4.first().tagName()); - Assert.assertEquals("script", dataEls4.get(1).tagName()); - Assert.assertEquals("span", dataEls4.get(2).tagName()); - Assert.assertEquals(1, dataEls5.size()); + Assertions.assertEquals(2, dataEls1.size()); // body and script + Assertions.assertEquals(1, dataEls2.size()); + Assertions.assertEquals(dataEls1.last(), dataEls2.first()); + Assertions.assertEquals("<script>FUNCTION</script>", dataEls2.outerHtml()); + Assertions.assertEquals(1, dataEls3.size()); + Assertions.assertEquals("span", dataEls3.first().tagName()); + Assertions.assertEquals(3, dataEls4.size()); + Assertions.assertEquals("body", dataEls4.first().tagName()); + Assertions.assertEquals("script", dataEls4.get(1).tagName()); + Assertions.assertEquals("span", dataEls4.get(2).tagName()); + Assertions.assertEquals(1, dataEls5.size()); } - @Test - public void testByAttributeStarting() { + @ParameterizedTest + @MethodSource("locales") + public void testByAttributeStarting(Locale locale) { Locale.setDefault(locale); Document doc = Jsoup.parse("<div id=1 ATTRIBUTE data-name=jsoup>Hello</div><p data-val=5 id=2>There</p><p id=3>No</p>"); Elements withData = doc.select("[^data-]"); - Assert.assertEquals(2, withData.size()); - Assert.assertEquals("1", withData.first().id()); - Assert.assertEquals("2", withData.last().id()); + Assertions.assertEquals(2, withData.size()); + Assertions.assertEquals("1", withData.first().id()); + Assertions.assertEquals("2", withData.last().id()); withData = doc.select("p[^data-]"); - Assert.assertEquals(1, withData.size()); - Assert.assertEquals("2", withData.first().id()); + Assertions.assertEquals(1, withData.size()); + Assertions.assertEquals("2", withData.first().id()); - Assert.assertEquals(1, doc.select("[^attrib]").size()); + Assertions.assertEquals(1, doc.select("[^attrib]").size()); } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/select/QueryParserTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/select/QueryParserTest.java index 131b26e32d..2bd1251f50 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/select/QueryParserTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/select/QueryParserTest.java @@ -23,74 +23,73 @@ This file is part of the iText (R) project. package com.itextpdf.styledxmlparser.jsoup.select; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; /** * Tests for the Selector Query Parser. */ -@Category(UnitTest.class) +@Tag("UnitTest") public class QueryParserTest extends ExtendedITextTest { @Test public void testOrGetsCorrectPrecedence() { // tests that a selector "a b, c d, e f" evals to (a AND b) OR (c AND d) OR (e AND f)" // top level or, three child ands Evaluator eval = QueryParser.parse("a b, c d, e f"); - Assert.assertTrue(eval instanceof CombiningEvaluator.Or); + Assertions.assertTrue(eval instanceof CombiningEvaluator.Or); CombiningEvaluator.Or or = (CombiningEvaluator.Or) eval; - Assert.assertEquals(3, or.evaluators.size()); + Assertions.assertEquals(3, or.evaluators.size()); for (Evaluator innerEval: or.evaluators) { - Assert.assertTrue(innerEval instanceof CombiningEvaluator.And); + Assertions.assertTrue(innerEval instanceof CombiningEvaluator.And); CombiningEvaluator.And and = (CombiningEvaluator.And) innerEval; - Assert.assertEquals(2, and.evaluators.size()); - Assert.assertTrue(and.evaluators.get(0) instanceof StructuralEvaluator.Parent); - Assert.assertTrue(and.evaluators.get(1) instanceof Evaluator.Tag); + Assertions.assertEquals(2, and.evaluators.size()); + Assertions.assertTrue(and.evaluators.get(0) instanceof StructuralEvaluator.Parent); + Assertions.assertTrue(and.evaluators.get(1) instanceof Evaluator.Tag); } } @Test public void testParsesMultiCorrectly() { String query = ".foo > ol, ol > li + li"; Evaluator eval = QueryParser.parse(query); - Assert.assertTrue(eval instanceof CombiningEvaluator.Or); + Assertions.assertTrue(eval instanceof CombiningEvaluator.Or); CombiningEvaluator.Or or = (CombiningEvaluator.Or) eval; - Assert.assertEquals(2, or.evaluators.size()); + Assertions.assertEquals(2, or.evaluators.size()); CombiningEvaluator.And andLeft = (CombiningEvaluator.And) or.evaluators.get(0); CombiningEvaluator.And andRight = (CombiningEvaluator.And) or.evaluators.get(1); - Assert.assertEquals(".foo > ol", andLeft.toString()); - Assert.assertEquals(2, andLeft.evaluators.size()); - Assert.assertEquals("ol > li + li", andRight.toString()); - Assert.assertEquals(2, andRight.evaluators.size()); - Assert.assertEquals(query, eval.toString()); + Assertions.assertEquals(".foo > ol", andLeft.toString()); + Assertions.assertEquals(2, andLeft.evaluators.size()); + Assertions.assertEquals("ol > li + li", andRight.toString()); + Assertions.assertEquals(2, andRight.evaluators.size()); + Assertions.assertEquals(query, eval.toString()); } @Test public void exceptionOnUncloseAttribute() { - Assert.assertThrows(Selector.SelectorParseException.class, () -> QueryParser.parse("section > a[href=\"]")); + Assertions.assertThrows(Selector.SelectorParseException.class, () -> QueryParser.parse("section > a[href=\"]")); } @Test public void testParsesSingleQuoteInContains() { - Assert.assertThrows(Selector.SelectorParseException.class, () -> QueryParser.parse("p:contains(One \" One)")); + Assertions.assertThrows(Selector.SelectorParseException.class, () -> QueryParser.parse("p:contains(One \" One)")); } @Test public void exceptOnEmptySelector() { - Assert.assertThrows(Selector.SelectorParseException.class, () -> QueryParser.parse("")); + Assertions.assertThrows(Selector.SelectorParseException.class, () -> QueryParser.parse("")); } @Test public void exceptOnNullSelector() { - Assert.assertThrows(Selector.SelectorParseException.class, () -> QueryParser.parse(null)); + Assertions.assertThrows(Selector.SelectorParseException.class, () -> QueryParser.parse(null)); } @Test public void okOnSpacesForeAndAft() { Evaluator parse = QueryParser.parse(" span div "); - Assert.assertEquals("span div", parse.toString()); + Assertions.assertEquals("span div", parse.toString()); } @Test public void structuralEvaluatorsToString() { String q = "a:not(:has(span.foo)) b d > e + f ~ g"; Evaluator parse = QueryParser.parse(q); - Assert.assertEquals(q, parse.toString()); + Assertions.assertEquals(q, parse.toString()); } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/select/SelectorTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/select/SelectorTest.java index e32a0c37e3..2b23c5a034 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/select/SelectorTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/select/SelectorTest.java @@ -27,49 +27,48 @@ This file is part of the iText (R) project. import com.itextpdf.styledxmlparser.jsoup.nodes.Element; import com.itextpdf.styledxmlparser.jsoup.parser.Parser; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; /** * Tests that the selector selects correctly. */ -@Category(UnitTest.class) +@Tag("UnitTest") public class SelectorTest extends ExtendedITextTest { @Test public void testByTag() { // should be case insensitive Elements els = Jsoup.parse("<div id=1><div id=2><p>Hello</p></div></div><DIV id=3>").select("DIV"); - Assert.assertEquals(3, els.size()); - Assert.assertEquals("1", els.get(0).id()); - Assert.assertEquals("2", els.get(1).id()); - Assert.assertEquals("3", els.get(2).id()); + Assertions.assertEquals(3, els.size()); + Assertions.assertEquals("1", els.get(0).id()); + Assertions.assertEquals("2", els.get(1).id()); + Assertions.assertEquals("3", els.get(2).id()); Elements none = Jsoup.parse("<div id=1><div id=2><p>Hello</p></div></div><div id=3>").select("span"); - Assert.assertEquals(0, none.size()); + Assertions.assertEquals(0, none.size()); } @Test public void testById() { Elements els = Jsoup.parse("<div><p id=foo>Hello</p><p id=foo>Foo two!</p></div>").select("#foo"); - Assert.assertEquals(2, els.size()); - Assert.assertEquals("Hello", els.get(0).text()); - Assert.assertEquals("Foo two!", els.get(1).text()); + Assertions.assertEquals(2, els.size()); + Assertions.assertEquals("Hello", els.get(0).text()); + Assertions.assertEquals("Foo two!", els.get(1).text()); Elements none = Jsoup.parse("<div id=1></div>").select("#foo"); - Assert.assertEquals(0, none.size()); + Assertions.assertEquals(0, none.size()); } @Test public void testByClass() { Elements els = Jsoup.parse("<p id=0 class='ONE two'><p id=1 class='one'><p id=2 class='two'>").select("P.One"); - Assert.assertEquals(2, els.size()); - Assert.assertEquals("0", els.get(0).id()); - Assert.assertEquals("1", els.get(1).id()); + Assertions.assertEquals(2, els.size()); + Assertions.assertEquals("0", els.get(0).id()); + Assertions.assertEquals("1", els.get(1).id()); Elements none = Jsoup.parse("<div class='one'></div>").select(".foo"); - Assert.assertEquals(0, none.size()); + Assertions.assertEquals(0, none.size()); Elements els2 = Jsoup.parse("<div class='One-Two'></div>").select(".one-two"); - Assert.assertEquals(1, els2.size()); + Assertions.assertEquals(1, els2.size()); } @Test public void testByClassCaseInsensitive() { @@ -77,51 +76,51 @@ public class SelectorTest extends ExtendedITextTest { Elements elsFromClass = Jsoup.parse(html).select("P.Foo"); Elements elsFromAttr = Jsoup.parse(html).select("p[class=foo]"); - Assert.assertEquals(elsFromAttr.size(), elsFromClass.size()); - Assert.assertEquals(3, elsFromClass.size()); - Assert.assertEquals("Two", elsFromClass.get(1).text()); + Assertions.assertEquals(elsFromAttr.size(), elsFromClass.size()); + Assertions.assertEquals(3, elsFromClass.size()); + Assertions.assertEquals("Two", elsFromClass.get(1).text()); } @Test public void testNamespacedTag() { Document doc = Jsoup.parse("<div><abc:def id=1>Hello</abc:def></div> <abc:def class=bold id=2>There</abc:def>"); Elements byTag = doc.select("abc|def"); - Assert.assertEquals(2, byTag.size()); - Assert.assertEquals("1", byTag.first().id()); - Assert.assertEquals("2", byTag.last().id()); + Assertions.assertEquals(2, byTag.size()); + Assertions.assertEquals("1", byTag.first().id()); + Assertions.assertEquals("2", byTag.last().id()); Elements byAttr = doc.select(".bold"); - Assert.assertEquals(1, byAttr.size()); - Assert.assertEquals("2", byAttr.last().id()); + Assertions.assertEquals(1, byAttr.size()); + Assertions.assertEquals("2", byAttr.last().id()); Elements byTagAttr = doc.select("abc|def.bold"); - Assert.assertEquals(1, byTagAttr.size()); - Assert.assertEquals("2", byTagAttr.last().id()); + Assertions.assertEquals(1, byTagAttr.size()); + Assertions.assertEquals("2", byTagAttr.last().id()); Elements byContains = doc.select("abc|def:contains(e)"); - Assert.assertEquals(2, byContains.size()); - Assert.assertEquals("1", byContains.first().id()); - Assert.assertEquals("2", byContains.last().id()); + Assertions.assertEquals(2, byContains.size()); + Assertions.assertEquals("1", byContains.first().id()); + Assertions.assertEquals("2", byContains.last().id()); } @Test public void testWildcardNamespacedTag() { Document doc = Jsoup.parse("<div><abc:def id=1>Hello</abc:def></div> <abc:def class=bold id=2>There</abc:def>"); Elements byTag = doc.select("*|def"); - Assert.assertEquals(2, byTag.size()); - Assert.assertEquals("1", byTag.first().id()); - Assert.assertEquals("2", byTag.last().id()); + Assertions.assertEquals(2, byTag.size()); + Assertions.assertEquals("1", byTag.first().id()); + Assertions.assertEquals("2", byTag.last().id()); Elements byAttr = doc.select(".bold"); - Assert.assertEquals(1, byAttr.size()); - Assert.assertEquals("2", byAttr.last().id()); + Assertions.assertEquals(1, byAttr.size()); + Assertions.assertEquals("2", byAttr.last().id()); Elements byTagAttr = doc.select("*|def.bold"); - Assert.assertEquals(1, byTagAttr.size()); - Assert.assertEquals("2", byTagAttr.last().id()); + Assertions.assertEquals(1, byTagAttr.size()); + Assertions.assertEquals("2", byTagAttr.last().id()); Elements byContains = doc.select("*|def:contains(e)"); - Assert.assertEquals(2, byContains.size()); - Assert.assertEquals("1", byContains.first().id()); - Assert.assertEquals("2", byContains.last().id()); + Assertions.assertEquals(2, byContains.size()); + Assertions.assertEquals("1", byContains.first().id()); + Assertions.assertEquals("2", byContains.last().id()); } @Test public void testWildcardNamespacedXmlTag() { @@ -131,22 +130,22 @@ public class SelectorTest extends ExtendedITextTest { ); Elements byTag = doc.select("*|Def"); - Assert.assertEquals(2, byTag.size()); - Assert.assertEquals("1", byTag.first().id()); - Assert.assertEquals("2", byTag.last().id()); + Assertions.assertEquals(2, byTag.size()); + Assertions.assertEquals("1", byTag.first().id()); + Assertions.assertEquals("2", byTag.last().id()); Elements byAttr = doc.select(".bold"); - Assert.assertEquals(1, byAttr.size()); - Assert.assertEquals("2", byAttr.last().id()); + Assertions.assertEquals(1, byAttr.size()); + Assertions.assertEquals("2", byAttr.last().id()); Elements byTagAttr = doc.select("*|Def.bold"); - Assert.assertEquals(1, byTagAttr.size()); - Assert.assertEquals("2", byTagAttr.last().id()); + Assertions.assertEquals(1, byTagAttr.size()); + Assertions.assertEquals("2", byTagAttr.last().id()); Elements byContains = doc.select("*|Def:contains(e)"); - Assert.assertEquals(2, byContains.size()); - Assert.assertEquals("1", byContains.first().id()); - Assert.assertEquals("2", byContains.last().id()); + Assertions.assertEquals(2, byContains.size()); + Assertions.assertEquals("1", byContains.first().id()); + Assertions.assertEquals("2", byContains.last().id()); } @Test public void testWildCardNamespacedCaseVariations() { @@ -156,44 +155,44 @@ public class SelectorTest extends ExtendedITextTest { Elements els3 = doc.select("Three|Four"); Elements els4 = doc.select("three|Four"); - Assert.assertEquals(els1, els2); - Assert.assertEquals(els3, els4); - Assert.assertEquals("One", els1.text()); - Assert.assertEquals(1, els1.size()); - Assert.assertEquals("Two", els3.text()); - Assert.assertEquals(1, els2.size()); + Assertions.assertEquals(els1, els2); + Assertions.assertEquals(els3, els4); + Assertions.assertEquals("One", els1.text()); + Assertions.assertEquals(1, els1.size()); + Assertions.assertEquals("Two", els3.text()); + Assertions.assertEquals(1, els2.size()); } @Test public void testByAttributeRegex() { Document doc = Jsoup.parse("<p><img src=foo.png id=1><img src=bar.jpg id=2><img src=qux.JPEG id=3><img src=old.gif><img></p>"); Elements imgs = doc.select("img[src~=(?i)\\.(png|jpe?g)]"); - Assert.assertEquals(3, imgs.size()); - Assert.assertEquals("1", imgs.get(0).id()); - Assert.assertEquals("2", imgs.get(1).id()); - Assert.assertEquals("3", imgs.get(2).id()); + Assertions.assertEquals(3, imgs.size()); + Assertions.assertEquals("1", imgs.get(0).id()); + Assertions.assertEquals("2", imgs.get(1).id()); + Assertions.assertEquals("3", imgs.get(2).id()); } @Test public void testByAttributeRegexCharacterClass() { Document doc = Jsoup.parse("<p><img src=foo.png id=1><img src=bar.jpg id=2><img src=qux.JPEG id=3><img src=old.gif id=4></p>"); Elements imgs = doc.select("img[src~=[o]]"); - Assert.assertEquals(2, imgs.size()); - Assert.assertEquals("1", imgs.get(0).id()); - Assert.assertEquals("4", imgs.get(1).id()); + Assertions.assertEquals(2, imgs.size()); + Assertions.assertEquals("1", imgs.get(0).id()); + Assertions.assertEquals("4", imgs.get(1).id()); } @Test public void testByAttributeRegexCombined() { Document doc = Jsoup.parse("<div><table class=x><td>Hello</td></table></div>"); Elements els = doc.select("div table[class~=x|y]"); - Assert.assertEquals(1, els.size()); - Assert.assertEquals("Hello", els.text()); + Assertions.assertEquals(1, els.size()); + Assertions.assertEquals("Hello", els.text()); } @Test public void testCombinedWithContains() { Document doc = Jsoup.parse("<p id=1>One</p><p>Two +</p><p>Three +</p>"); Elements els = doc.select("p#1 + :contains(+)"); - Assert.assertEquals(1, els.size()); - Assert.assertEquals("Two +", els.text()); - Assert.assertEquals("p", els.first().tagName()); + Assertions.assertEquals(1, els.size()); + Assertions.assertEquals("Two +", els.text()); + Assertions.assertEquals("p", els.first().tagName()); } @Test public void testAllElements() { @@ -201,16 +200,16 @@ public class SelectorTest extends ExtendedITextTest { Document doc = Jsoup.parse(h); Elements allDoc = doc.select("*"); Elements allUnderDiv = doc.select("div *"); - Assert.assertEquals(8, allDoc.size()); - Assert.assertEquals(3, allUnderDiv.size()); - Assert.assertEquals("p", allUnderDiv.first().tagName()); + Assertions.assertEquals(8, allDoc.size()); + Assertions.assertEquals(3, allUnderDiv.size()); + Assertions.assertEquals("p", allUnderDiv.first().tagName()); } @Test public void testAllWithClass() { String h = "<p class=first>One<p class=first>Two<p>Three"; Document doc = Jsoup.parse(h); Elements ps = doc.select("*.first"); - Assert.assertEquals(2, ps.size()); + Assertions.assertEquals(2, ps.size()); } @Test public void testGroupOr() { @@ -218,26 +217,26 @@ public class SelectorTest extends ExtendedITextTest { Document doc = Jsoup.parse(h); Elements els = doc.select("p,div,[title]"); - Assert.assertEquals(5, els.size()); - Assert.assertEquals("div", els.get(0).tagName()); - Assert.assertEquals("foo", els.get(0).attr("title")); - Assert.assertEquals("div", els.get(1).tagName()); - Assert.assertEquals("bar", els.get(1).attr("title")); - Assert.assertEquals("div", els.get(2).tagName()); - Assert.assertEquals(0, els.get(2).attr("title").length()); // missing attributes come back as empty string - Assert.assertFalse(els.get(2).hasAttr("title")); - Assert.assertEquals("p", els.get(3).tagName()); - Assert.assertEquals("span", els.get(4).tagName()); + Assertions.assertEquals(5, els.size()); + Assertions.assertEquals("div", els.get(0).tagName()); + Assertions.assertEquals("foo", els.get(0).attr("title")); + Assertions.assertEquals("div", els.get(1).tagName()); + Assertions.assertEquals("bar", els.get(1).attr("title")); + Assertions.assertEquals("div", els.get(2).tagName()); + Assertions.assertEquals(0, els.get(2).attr("title").length()); // missing attributes come back as empty string + Assertions.assertFalse(els.get(2).hasAttr("title")); + Assertions.assertEquals("p", els.get(3).tagName()); + Assertions.assertEquals("span", els.get(4).tagName()); } @Test public void testGroupOrAttribute() { String h = "<div id=1 /><div id=2 /><div title=foo /><div title=bar />"; Elements els = Jsoup.parse(h).select("[id],[title=foo]"); - Assert.assertEquals(3, els.size()); - Assert.assertEquals("1", els.get(0).id()); - Assert.assertEquals("2", els.get(1).id()); - Assert.assertEquals("foo", els.get(2).attr("title")); + Assertions.assertEquals(3, els.size()); + Assertions.assertEquals("1", els.get(0).id()); + Assertions.assertEquals("2", els.get(1).id()); + Assertions.assertEquals("foo", els.get(2).attr("title")); } @Test public void descendant() { @@ -246,19 +245,19 @@ public class SelectorTest extends ExtendedITextTest { Element root = doc.getElementsByClass("HEAD").first(); Elements els = root.select(".head p"); - Assert.assertEquals(2, els.size()); - Assert.assertEquals("Hello", els.get(0).text()); - Assert.assertEquals("There", els.get(1).text()); + Assertions.assertEquals(2, els.size()); + Assertions.assertEquals("Hello", els.get(0).text()); + Assertions.assertEquals("There", els.get(1).text()); Elements p = root.select("p.first"); - Assert.assertEquals(1, p.size()); - Assert.assertEquals("Hello", p.get(0).text()); + Assertions.assertEquals(1, p.size()); + Assertions.assertEquals("Hello", p.get(0).text()); Elements empty = root.select("p .first"); // self, not descend, should not match - Assert.assertEquals(0, empty.size()); + Assertions.assertEquals(0, empty.size()); Elements aboveRoot = root.select("body div.head"); - Assert.assertEquals(0, aboveRoot.size()); + Assertions.assertEquals(0, aboveRoot.size()); } @Test public void and() { @@ -266,20 +265,20 @@ public class SelectorTest extends ExtendedITextTest { Document doc = Jsoup.parse(h); Elements div = doc.select("div.foo"); - Assert.assertEquals(1, div.size()); - Assert.assertEquals("div", div.first().tagName()); + Assertions.assertEquals(1, div.size()); + Assertions.assertEquals("div", div.first().tagName()); Elements p = doc.select("div .foo"); // space indicates like "div *.foo" - Assert.assertEquals(1, p.size()); - Assert.assertEquals("p", p.first().tagName()); + Assertions.assertEquals(1, p.size()); + Assertions.assertEquals("p", p.first().tagName()); Elements div2 = doc.select("div#1.foo.bar[title=bar][name=qux]"); // very specific! - Assert.assertEquals(1, div2.size()); - Assert.assertEquals("div", div2.first().tagName()); + Assertions.assertEquals(1, div2.size()); + Assertions.assertEquals("div", div2.first().tagName()); Elements p2 = doc.select("div *.foo"); // space indicates like "div *.foo" - Assert.assertEquals(1, p2.size()); - Assert.assertEquals("p", p2.first().tagName()); + Assertions.assertEquals(1, p2.size()); + Assertions.assertEquals("p", p2.first().tagName()); } @Test public void deeperDescendant() { @@ -288,12 +287,12 @@ public class SelectorTest extends ExtendedITextTest { Element root = doc.getElementsByClass("head").first(); Elements els = root.select("div p .first"); - Assert.assertEquals(1, els.size()); - Assert.assertEquals("Hello", els.first().text()); - Assert.assertEquals("span", els.first().tagName()); + Assertions.assertEquals(1, els.size()); + Assertions.assertEquals("Hello", els.first().text()); + Assertions.assertEquals("span", els.first().tagName()); Elements aboveRoot = root.select("body p .first"); - Assert.assertEquals(0, aboveRoot.size()); + Assertions.assertEquals(0, aboveRoot.size()); } @Test public void parentChildElement() { @@ -301,13 +300,13 @@ public class SelectorTest extends ExtendedITextTest { Document doc = Jsoup.parse(h); Elements divs = doc.select("div > div"); - Assert.assertEquals(2, divs.size()); - Assert.assertEquals("2", divs.get(0).id()); // 2 is child of 1 - Assert.assertEquals("3", divs.get(1).id()); // 3 is child of 2 + Assertions.assertEquals(2, divs.size()); + Assertions.assertEquals("2", divs.get(0).id()); // 2 is child of 1 + Assertions.assertEquals("3", divs.get(1).id()); // 3 is child of 2 Elements div2 = doc.select("div#1 > div"); - Assert.assertEquals(1, div2.size()); - Assert.assertEquals("2", div2.get(0).id()); + Assertions.assertEquals(1, div2.size()); + Assertions.assertEquals("2", div2.get(0).id()); } @Test public void parentWithClassChild() { @@ -315,67 +314,67 @@ public class SelectorTest extends ExtendedITextTest { Document doc = Jsoup.parse(h); Elements allAs = doc.select("h1 > a"); - Assert.assertEquals(3, allAs.size()); - Assert.assertEquals("a", allAs.first().tagName()); + Assertions.assertEquals(3, allAs.size()); + Assertions.assertEquals("a", allAs.first().tagName()); Elements fooAs = doc.select("h1.foo > a"); - Assert.assertEquals(2, fooAs.size()); - Assert.assertEquals("a", fooAs.first().tagName()); + Assertions.assertEquals(2, fooAs.size()); + Assertions.assertEquals("a", fooAs.first().tagName()); Elements barAs = doc.select("h1.foo > a.bar"); - Assert.assertEquals(1, barAs.size()); + Assertions.assertEquals(1, barAs.size()); } @Test public void parentChildStar() { String h = "<div id=1><p>Hello<p><b>there</b></p></div><div id=2><span>Hi</span></div>"; Document doc = Jsoup.parse(h); Elements divChilds = doc.select("div > *"); - Assert.assertEquals(3, divChilds.size()); - Assert.assertEquals("p", divChilds.get(0).tagName()); - Assert.assertEquals("p", divChilds.get(1).tagName()); - Assert.assertEquals("span", divChilds.get(2).tagName()); + Assertions.assertEquals(3, divChilds.size()); + Assertions.assertEquals("p", divChilds.get(0).tagName()); + Assertions.assertEquals("p", divChilds.get(1).tagName()); + Assertions.assertEquals("span", divChilds.get(2).tagName()); } @Test public void multiChildDescent() { String h = "<div id=foo><h1 class=bar><a href=http://example.com/>One</a></h1></div>"; Document doc = Jsoup.parse(h); Elements els = doc.select("div#foo > h1.bar > a[href*=example]"); - Assert.assertEquals(1, els.size()); - Assert.assertEquals("a", els.first().tagName()); + Assertions.assertEquals(1, els.size()); + Assertions.assertEquals("a", els.first().tagName()); } @Test public void caseInsensitive() { String h = "<dIv tItle=bAr><div>"; // mixed case so a simple toLowerCase() on value doesn't catch Document doc = Jsoup.parse(h); - Assert.assertEquals(2, doc.select("DiV").size()); - Assert.assertEquals(1, doc.select("DiV[TiTLE]").size()); - Assert.assertEquals(1, doc.select("DiV[TiTLE=BAR]").size()); - Assert.assertEquals(0, doc.select("DiV[TiTLE=BARBARELLA]").size()); + Assertions.assertEquals(2, doc.select("DiV").size()); + Assertions.assertEquals(1, doc.select("DiV[TiTLE]").size()); + Assertions.assertEquals(1, doc.select("DiV[TiTLE=BAR]").size()); + Assertions.assertEquals(0, doc.select("DiV[TiTLE=BARBARELLA]").size()); } @Test public void adjacentSiblings() { String h = "<ol><li>One<li>Two<li>Three</ol>"; Document doc = Jsoup.parse(h); Elements sibs = doc.select("li + li"); - Assert.assertEquals(2, sibs.size()); - Assert.assertEquals("Two", sibs.get(0).text()); - Assert.assertEquals("Three", sibs.get(1).text()); + Assertions.assertEquals(2, sibs.size()); + Assertions.assertEquals("Two", sibs.get(0).text()); + Assertions.assertEquals("Three", sibs.get(1).text()); } @Test public void adjacentSiblingsWithId() { String h = "<ol><li id=1>One<li id=2>Two<li id=3>Three</ol>"; Document doc = Jsoup.parse(h); Elements sibs = doc.select("li#1 + li#2"); - Assert.assertEquals(1, sibs.size()); - Assert.assertEquals("Two", sibs.get(0).text()); + Assertions.assertEquals(1, sibs.size()); + Assertions.assertEquals("Two", sibs.get(0).text()); } @Test public void notAdjacent() { String h = "<ol><li id=1>One<li id=2>Two<li id=3>Three</ol>"; Document doc = Jsoup.parse(h); Elements sibs = doc.select("li#1 + li#3"); - Assert.assertEquals(0, sibs.size()); + Assertions.assertEquals(0, sibs.size()); } @Test public void mixCombinator() { @@ -383,9 +382,9 @@ public class SelectorTest extends ExtendedITextTest { Document doc = Jsoup.parse(h); Elements sibs = doc.select("body > div.foo li + li"); - Assert.assertEquals(2, sibs.size()); - Assert.assertEquals("Two", sibs.get(0).text()); - Assert.assertEquals("Three", sibs.get(1).text()); + Assertions.assertEquals(2, sibs.size()); + Assertions.assertEquals("Two", sibs.get(0).text()); + Assertions.assertEquals("Three", sibs.get(1).text()); } @Test public void mixCombinatorGroup() { @@ -393,18 +392,18 @@ public class SelectorTest extends ExtendedITextTest { Document doc = Jsoup.parse(h); Elements els = doc.select(".foo > ol, ol > li + li"); - Assert.assertEquals(3, els.size()); - Assert.assertEquals("ol", els.get(0).tagName()); - Assert.assertEquals("Two", els.get(1).text()); - Assert.assertEquals("Three", els.get(2).text()); + Assertions.assertEquals(3, els.size()); + Assertions.assertEquals("ol", els.get(0).tagName()); + Assertions.assertEquals("Two", els.get(1).text()); + Assertions.assertEquals("Three", els.get(2).text()); } @Test public void generalSiblings() { String h = "<ol><li id=1>One<li id=2>Two<li id=3>Three</ol>"; Document doc = Jsoup.parse(h); Elements els = doc.select("#1 ~ #3"); - Assert.assertEquals(1, els.size()); - Assert.assertEquals("Three", els.first().text()); + Assertions.assertEquals(1, els.size()); + Assertions.assertEquals("Three", els.first().text()); } // for http://github.com/jhy/jsoup/issues#issue/10 @@ -414,14 +413,14 @@ public class SelectorTest extends ExtendedITextTest { Document doc = Jsoup.parse(h); Element el1 = doc.getElementById("a1-foo_bar"); - Assert.assertEquals("One", el1.text()); + Assertions.assertEquals("One", el1.text()); Element el2 = doc.getElementsByClass("b2-qux_bif").first(); - Assert.assertEquals("Two", el2.text()); + Assertions.assertEquals("Two", el2.text()); Element el3 = doc.select("#a1-foo_bar").first(); - Assert.assertEquals("One", el3.text()); + Assertions.assertEquals("One", el3.text()); Element el4 = doc.select(".b2-qux_bif").first(); - Assert.assertEquals("Two", el4.text()); + Assertions.assertEquals("Two", el4.text()); } // for http://github.com/jhy/jsoup/issues#issue/13 @@ -431,219 +430,219 @@ public class SelectorTest extends ExtendedITextTest { Element p = doc.select("div > p").first(); Elements spans = p.select("> span"); - Assert.assertEquals(2, spans.size()); - Assert.assertEquals("One", spans.first().text()); + Assertions.assertEquals(2, spans.size()); + Assertions.assertEquals("One", spans.first().text()); // make sure doesn't get nested h = "<div id=1><div id=2><div id=3></div></div></div>"; doc = Jsoup.parse(h); Element div = doc.select("div").select(" > div").first(); - Assert.assertEquals("2", div.id()); + Assertions.assertEquals("2", div.id()); } @Test public void testPseudoLessThan() { Document doc = Jsoup.parse("<div><p>One</p><p>Two</p><p>Three</>p></div><div><p>Four</p>"); Elements ps = doc.select("div p:lt(2)"); - Assert.assertEquals(3, ps.size()); - Assert.assertEquals("One", ps.get(0).text()); - Assert.assertEquals("Two", ps.get(1).text()); - Assert.assertEquals("Four", ps.get(2).text()); + Assertions.assertEquals(3, ps.size()); + Assertions.assertEquals("One", ps.get(0).text()); + Assertions.assertEquals("Two", ps.get(1).text()); + Assertions.assertEquals("Four", ps.get(2).text()); } @Test public void testPseudoGreaterThan() { Document doc = Jsoup.parse("<div><p>One</p><p>Two</p><p>Three</p></div><div><p>Four</p>"); Elements ps = doc.select("div p:gt(0)"); - Assert.assertEquals(2, ps.size()); - Assert.assertEquals("Two", ps.get(0).text()); - Assert.assertEquals("Three", ps.get(1).text()); + Assertions.assertEquals(2, ps.size()); + Assertions.assertEquals("Two", ps.get(0).text()); + Assertions.assertEquals("Three", ps.get(1).text()); } @Test public void testPseudoEquals() { Document doc = Jsoup.parse("<div><p>One</p><p>Two</p><p>Three</>p></div><div><p>Four</p>"); Elements ps = doc.select("div p:eq(0)"); - Assert.assertEquals(2, ps.size()); - Assert.assertEquals("One", ps.get(0).text()); - Assert.assertEquals("Four", ps.get(1).text()); + Assertions.assertEquals(2, ps.size()); + Assertions.assertEquals("One", ps.get(0).text()); + Assertions.assertEquals("Four", ps.get(1).text()); Elements ps2 = doc.select("div:eq(0) p:eq(0)"); - Assert.assertEquals(1, ps2.size()); - Assert.assertEquals("One", ps2.get(0).text()); - Assert.assertEquals("p", ps2.get(0).tagName()); + Assertions.assertEquals(1, ps2.size()); + Assertions.assertEquals("One", ps2.get(0).text()); + Assertions.assertEquals("p", ps2.get(0).tagName()); } @Test public void testPseudoBetween() { Document doc = Jsoup.parse("<div><p>One</p><p>Two</p><p>Three</>p></div><div><p>Four</p>"); Elements ps = doc.select("div p:gt(0):lt(2)"); - Assert.assertEquals(1, ps.size()); - Assert.assertEquals("Two", ps.get(0).text()); + Assertions.assertEquals(1, ps.size()); + Assertions.assertEquals("Two", ps.get(0).text()); } @Test public void testPseudoCombined() { Document doc = Jsoup.parse("<div class='foo'><p>One</p><p>Two</p></div><div><p>Three</p><p>Four</p></div>"); Elements ps = doc.select("div.foo p:gt(0)"); - Assert.assertEquals(1, ps.size()); - Assert.assertEquals("Two", ps.get(0).text()); + Assertions.assertEquals(1, ps.size()); + Assertions.assertEquals("Two", ps.get(0).text()); } @Test public void testPseudoHas() { Document doc = Jsoup.parse("<div id=0><p><span>Hello</span></p></div> <div id=1><span class=foo>There</span></div> <div id=2><p>Not</p></div>"); Elements divs1 = doc.select("div:has(span)"); - Assert.assertEquals(2, divs1.size()); - Assert.assertEquals("0", divs1.get(0).id()); - Assert.assertEquals("1", divs1.get(1).id()); + Assertions.assertEquals(2, divs1.size()); + Assertions.assertEquals("0", divs1.get(0).id()); + Assertions.assertEquals("1", divs1.get(1).id()); Elements divs2 = doc.select("div:has([class])"); - Assert.assertEquals(1, divs2.size()); - Assert.assertEquals("1", divs2.get(0).id()); + Assertions.assertEquals(1, divs2.size()); + Assertions.assertEquals("1", divs2.get(0).id()); Elements divs3 = doc.select("div:has(span, p)"); - Assert.assertEquals(3, divs3.size()); - Assert.assertEquals("0", divs3.get(0).id()); - Assert.assertEquals("1", divs3.get(1).id()); - Assert.assertEquals("2", divs3.get(2).id()); + Assertions.assertEquals(3, divs3.size()); + Assertions.assertEquals("0", divs3.get(0).id()); + Assertions.assertEquals("1", divs3.get(1).id()); + Assertions.assertEquals("2", divs3.get(2).id()); Elements els1 = doc.body().select(":has(p)"); - Assert.assertEquals(3, els1.size()); // body, div, dib - Assert.assertEquals("body", els1.first().tagName()); - Assert.assertEquals("0", els1.get(1).id()); - Assert.assertEquals("2", els1.get(2).id()); + Assertions.assertEquals(3, els1.size()); // body, div, dib + Assertions.assertEquals("body", els1.first().tagName()); + Assertions.assertEquals("0", els1.get(1).id()); + Assertions.assertEquals("2", els1.get(2).id()); Elements els2 = doc.body().select(":has(> span)"); - Assert.assertEquals(2,els2.size()); // p, div - Assert.assertEquals("p",els2.first().tagName()); - Assert.assertEquals("1", els2.get(1).id()); + Assertions.assertEquals(2,els2.size()); // p, div + Assertions.assertEquals("p",els2.first().tagName()); + Assertions.assertEquals("1", els2.get(1).id()); } @Test public void testNestedHas() { Document doc = Jsoup.parse("<div><p><span>One</span></p></div> <div><p>Two</p></div>"); Elements divs = doc.select("div:has(p:has(span))"); - Assert.assertEquals(1, divs.size()); - Assert.assertEquals("One", divs.first().text()); + Assertions.assertEquals(1, divs.size()); + Assertions.assertEquals("One", divs.first().text()); // test matches in has divs = doc.select("div:has(p:matches((?i)two))"); - Assert.assertEquals(1, divs.size()); - Assert.assertEquals("div", divs.first().tagName()); - Assert.assertEquals("Two", divs.first().text()); + Assertions.assertEquals(1, divs.size()); + Assertions.assertEquals("div", divs.first().tagName()); + Assertions.assertEquals("Two", divs.first().text()); // test contains in has divs = doc.select("div:has(p:contains(two))"); - Assert.assertEquals(1, divs.size()); - Assert.assertEquals("div", divs.first().tagName()); - Assert.assertEquals("Two", divs.first().text()); + Assertions.assertEquals(1, divs.size()); + Assertions.assertEquals("div", divs.first().tagName()); + Assertions.assertEquals("Two", divs.first().text()); } @Test public void testPsuedoContainsWithParentheses() { Document doc = Jsoup.parse("<div><p id=1>This (is good)</p><p id=2>This is bad)</p>"); Elements ps1 = doc.select("p:contains(this (is good))"); - Assert.assertEquals(1, ps1.size()); - Assert.assertEquals("1", ps1.first().id()); + Assertions.assertEquals(1, ps1.size()); + Assertions.assertEquals("1", ps1.first().id()); Elements ps2 = doc.select("p:contains(this is bad\\))"); - Assert.assertEquals(1, ps2.size()); - Assert.assertEquals("2", ps2.first().id()); + Assertions.assertEquals(1, ps2.size()); + Assertions.assertEquals("2", ps2.first().id()); } @Test public void testMatches() { Document doc = Jsoup.parse("<p id=1>The <i>Rain</i></p> <p id=2>There are 99 bottles.</p> <p id=3>Harder (this)</p> <p id=4>Rain</p>"); Elements p1 = doc.select("p:matches(The rain)"); // no match, case sensitive - Assert.assertEquals(0, p1.size()); + Assertions.assertEquals(0, p1.size()); Elements p2 = doc.select("p:matches((?i)the rain)"); // case insense. should include root, html, body - Assert.assertEquals(1, p2.size()); - Assert.assertEquals("1", p2.first().id()); + Assertions.assertEquals(1, p2.size()); + Assertions.assertEquals("1", p2.first().id()); Elements p4 = doc.select("p:matches((?i)^rain$)"); // bounding - Assert.assertEquals(1, p4.size()); - Assert.assertEquals("4", p4.first().id()); + Assertions.assertEquals(1, p4.size()); + Assertions.assertEquals("4", p4.first().id()); Elements p5 = doc.select("p:matches(\\d+)"); - Assert.assertEquals(1, p5.size()); - Assert.assertEquals("2", p5.first().id()); + Assertions.assertEquals(1, p5.size()); + Assertions.assertEquals("2", p5.first().id()); Elements p6 = doc.select("p:matches(\\w+\\s+\\(\\w+\\))"); // test bracket matching - Assert.assertEquals(1, p6.size()); - Assert.assertEquals("3", p6.first().id()); + Assertions.assertEquals(1, p6.size()); + Assertions.assertEquals("3", p6.first().id()); Elements p7 = doc.select("p:matches((?i)the):has(i)"); // multi - Assert.assertEquals(1, p7.size()); - Assert.assertEquals("1", p7.first().id()); + Assertions.assertEquals(1, p7.size()); + Assertions.assertEquals("1", p7.first().id()); } @Test public void matchesOwn() { Document doc = Jsoup.parse("<p id=1>Hello <b>there</b> now</p>"); Elements p1 = doc.select("p:matchesOwn((?i)hello now)"); - Assert.assertEquals(1, p1.size()); - Assert.assertEquals("1", p1.first().id()); + Assertions.assertEquals(1, p1.size()); + Assertions.assertEquals("1", p1.first().id()); - Assert.assertEquals(0, doc.select("p:matchesOwn(there)").size()); + Assertions.assertEquals(0, doc.select("p:matchesOwn(there)").size()); } @Test public void testRelaxedTags() { Document doc = Jsoup.parse("<abc_def id=1>Hello</abc_def> <abc-def id=2>There</abc-def>"); Elements el1 = doc.select("abc_def"); - Assert.assertEquals(1, el1.size()); - Assert.assertEquals("1", el1.first().id()); + Assertions.assertEquals(1, el1.size()); + Assertions.assertEquals("1", el1.first().id()); Elements el2 = doc.select("abc-def"); - Assert.assertEquals(1, el2.size()); - Assert.assertEquals("2", el2.first().id()); + Assertions.assertEquals(1, el2.size()); + Assertions.assertEquals("2", el2.first().id()); } @Test public void notParas() { Document doc = Jsoup.parse("<p id=1>One</p> <p>Two</p> <p><span>Three</span></p>"); Elements el1 = doc.select("p:not([id=1])"); - Assert.assertEquals(2, el1.size()); - Assert.assertEquals("Two", el1.first().text()); - Assert.assertEquals("Three", el1.last().text()); + Assertions.assertEquals(2, el1.size()); + Assertions.assertEquals("Two", el1.first().text()); + Assertions.assertEquals("Three", el1.last().text()); Elements el2 = doc.select("p:not(:has(span))"); - Assert.assertEquals(2, el2.size()); - Assert.assertEquals("One", el2.first().text()); - Assert.assertEquals("Two", el2.last().text()); + Assertions.assertEquals(2, el2.size()); + Assertions.assertEquals("One", el2.first().text()); + Assertions.assertEquals("Two", el2.last().text()); } @Test public void notAll() { Document doc = Jsoup.parse("<p>Two</p> <p><span>Three</span></p>"); Elements el1 = doc.body().select(":not(p)"); // should just be the span - Assert.assertEquals(2, el1.size()); - Assert.assertEquals("body", el1.first().tagName()); - Assert.assertEquals("span", el1.last().tagName()); + Assertions.assertEquals(2, el1.size()); + Assertions.assertEquals("body", el1.first().tagName()); + Assertions.assertEquals("span", el1.last().tagName()); } @Test public void notClass() { Document doc = Jsoup.parse("<div class=left>One</div><div class=right id=1><p>Two</p></div>"); Elements el1 = doc.select("div:not(.left)"); - Assert.assertEquals(1, el1.size()); - Assert.assertEquals("1", el1.first().id()); + Assertions.assertEquals(1, el1.size()); + Assertions.assertEquals("1", el1.first().id()); } @Test public void handlesCommasInSelector() { Document doc = Jsoup.parse("<p name='1,2'>One</p><div>Two</div><ol><li>123</li><li>Text</li></ol>"); Elements ps = doc.select("[name=1,2]"); - Assert.assertEquals(1, ps.size()); + Assertions.assertEquals(1, ps.size()); Elements containers = doc.select("div, li:matches([0-9,]+)"); - Assert.assertEquals(2, containers.size()); - Assert.assertEquals("div", containers.get(0).tagName()); - Assert.assertEquals("li", containers.get(1).tagName()); - Assert.assertEquals("123", containers.get(1).text()); + Assertions.assertEquals(2, containers.size()); + Assertions.assertEquals("div", containers.get(0).tagName()); + Assertions.assertEquals("li", containers.get(1).tagName()); + Assertions.assertEquals("123", containers.get(1).text()); } @Test public void selectSupplementaryCharacter() { String s = new String(Character.toChars(135361)); Document doc = Jsoup.parse("<div k" + s + "='" + s + "'>^" + s +"$/div>"); - Assert.assertEquals("div", doc.select("div[k" + s + "]").first().tagName()); - Assert.assertEquals("div", doc.select("div:containsOwn(" + s + ")").first().tagName()); + Assertions.assertEquals("div", doc.select("div[k" + s + "]").first().tagName()); + Assertions.assertEquals("div", doc.select("div:containsOwn(" + s + ")").first().tagName()); } @Test @@ -654,17 +653,17 @@ public void selectClassWithSpace() { Document doc = Jsoup.parse(html); Elements found = doc.select("div[class=value ]"); - Assert.assertEquals(2, found.size()); - Assert.assertEquals("class without space", found.get(0).text()); - Assert.assertEquals("class with space", found.get(1).text()); + Assertions.assertEquals(2, found.size()); + Assertions.assertEquals("class without space", found.get(0).text()); + Assertions.assertEquals("class with space", found.get(1).text()); found = doc.select("div[class=\"value \"]"); - Assert.assertEquals(2, found.size()); - Assert.assertEquals("class without space", found.get(0).text()); - Assert.assertEquals("class with space", found.get(1).text()); + Assertions.assertEquals(2, found.size()); + Assertions.assertEquals("class without space", found.get(0).text()); + Assertions.assertEquals("class with space", found.get(1).text()); found = doc.select("div[class=\"value\\ \"]"); - Assert.assertEquals(0, found.size()); + Assertions.assertEquals(0, found.size()); } @Test public void selectSameElements() { @@ -672,45 +671,45 @@ public void selectClassWithSpace() { Document doc = Jsoup.parse(html); Elements els = doc.select("div"); - Assert.assertEquals(2, els.size()); + Assertions.assertEquals(2, els.size()); Elements subSelect = els.select(":contains(one)"); - Assert.assertEquals(2, subSelect.size()); + Assertions.assertEquals(2, subSelect.size()); } @Test public void attributeWithBrackets() { String html = "<div data='End]'>One</div> <div data='[Another)]]'>Two</div>"; Document doc = Jsoup.parse(html); - Assert.assertEquals("One", doc.select("div[data='End]']").first().text()); - Assert.assertEquals("Two", doc.select("div[data='[Another)]]']").first().text()); - Assert.assertEquals("One", doc.select("div[data=\"End]\"]").first().text()); - Assert.assertEquals("Two", doc.select("div[data=\"[Another)]]\"]").first().text()); + Assertions.assertEquals("One", doc.select("div[data='End]']").first().text()); + Assertions.assertEquals("Two", doc.select("div[data='[Another)]]']").first().text()); + Assertions.assertEquals("One", doc.select("div[data=\"End]\"]").first().text()); + Assertions.assertEquals("Two", doc.select("div[data=\"[Another)]]\"]").first().text()); } @Test public void containsWithQuote() { String html = "<p>One'One</p><p>One'Two</p>"; Document doc = Jsoup.parse(html); Elements els = doc.select("p:contains(One\\'One)"); - Assert.assertEquals(1, els.size()); - Assert.assertEquals("One'One", els.text()); + Assertions.assertEquals(1, els.size()); + Assertions.assertEquals("One'One", els.text()); } @Test public void selectFirst() { String html = "<p>One<p>Two<p>Three"; Document doc = Jsoup.parse(html); - Assert.assertEquals("One", doc.selectFirst("p").text()); + Assertions.assertEquals("One", doc.selectFirst("p").text()); } @Test public void selectFirstWithAnd() { String html = "<p>One<p class=foo>Two<p>Three"; Document doc = Jsoup.parse(html); - Assert.assertEquals("Two", doc.selectFirst("p.foo").text()); + Assertions.assertEquals("Two", doc.selectFirst("p.foo").text()); } @Test public void selectFirstWithOr() { String html = "<p>One<p>Two<p>Three<div>Four"; Document doc = Jsoup.parse(html); - Assert.assertEquals("One", doc.selectFirst("p, div").text()); + Assertions.assertEquals("One", doc.selectFirst("p, div").text()); } @Test public void matchText() { @@ -719,20 +718,20 @@ public void selectClassWithSpace() { String origHtml = doc.html(); Elements one = doc.select("p:matchText:first-child"); - Assert.assertEquals("One", one.first().text()); + Assertions.assertEquals("One", one.first().text()); Elements two = doc.select("p:matchText:last-child"); - Assert.assertEquals("Two", two.first().text()); + Assertions.assertEquals("Two", two.first().text()); - Assert.assertEquals(origHtml, doc.html()); + Assertions.assertEquals(origHtml, doc.html()); - Assert.assertEquals("Two", doc.select("p:matchText + br + *").text()); + Assertions.assertEquals("Two", doc.select("p:matchText + br + *").text()); } @Test public void nthLastChildWithNoParent() { Element el = new Element("p").text("Orphan"); Elements els = el.select("p:nth-last-child(1)"); - Assert.assertEquals(0, els.size()); + Assertions.assertEquals(0, els.size()); } @Test public void splitOnBr() { @@ -740,39 +739,39 @@ public void selectClassWithSpace() { Document doc = Jsoup.parse(html); Elements els = doc.select("p:matchText"); - Assert.assertEquals(3, els.size()); - Assert.assertEquals("One", els.get(0).text()); - Assert.assertEquals("Two", els.get(1).text()); - Assert.assertEquals("Three", els.get(2).toString()); + Assertions.assertEquals(3, els.size()); + Assertions.assertEquals("One", els.get(0).text()); + Assertions.assertEquals("Two", els.get(1).text()); + Assertions.assertEquals("Three", els.get(2).toString()); } @Test public void matchTextAttributes() { Document doc = Jsoup.parse("<div><p class=one>One<br>Two<p class=two>Three<br>Four"); Elements els = doc.select("p.two:matchText:last-child"); - Assert.assertEquals(1, els.size()); - Assert.assertEquals("Four", els.text()); + Assertions.assertEquals(1, els.size()); + Assertions.assertEquals("Four", els.text()); } @Test public void findBetweenSpan() { Document doc = Jsoup.parse("<p><span>One</span> Two <span>Three</span>"); Elements els = doc.select("span ~ p:matchText"); // the Two becomes its own p, sibling of the span - Assert.assertEquals(1, els.size()); - Assert.assertEquals("Two", els.text()); + Assertions.assertEquals(1, els.size()); + Assertions.assertEquals("Two", els.text()); } @Test public void startsWithBeginsWithSpace() { Document doc = Jsoup.parse("<small><a href=\" mailto:abc@def.net\">(abc@def.net)</a></small>"); Elements els = doc.select("a[href^=' mailto']"); - Assert.assertEquals(1, els.size()); + Assertions.assertEquals(1, els.size()); } @Test public void endsWithEndsWithSpaces() { Document doc = Jsoup.parse("<small><a href=\" mailto:abc@def.net \">(abc@def.net)</a></small>"); Elements els = doc.select("a[href$='.net ']"); - Assert.assertEquals(1, els.size()); + Assertions.assertEquals(1, els.size()); } // https://github.com/jhy/jsoup/issues/1257 @@ -784,49 +783,49 @@ public void selectClassWithSpace() { @Test public void html_mixed_case_simple_name() { Document doc = Jsoup.parse(mixedCase, "", Parser.htmlParser()); - Assert.assertEquals(0, doc.select("mixedCase").size()); + Assertions.assertEquals(0, doc.select("mixedCase").size()); } @Test public void html_mixed_case_wildcard_name() { Document doc = Jsoup.parse(mixedCase, "", Parser.htmlParser()); - Assert.assertEquals(1, doc.select("*|mixedCase").size()); + Assertions.assertEquals(1, doc.select("*|mixedCase").size()); } @Test public void html_lowercase_simple_name() { Document doc = Jsoup.parse(lowercase, "", Parser.htmlParser()); - Assert.assertEquals(0, doc.select("lowercase").size()); + Assertions.assertEquals(0, doc.select("lowercase").size()); } @Test public void html_lowercase_wildcard_name() { Document doc = Jsoup.parse(lowercase, "", Parser.htmlParser()); - Assert.assertEquals(1, doc.select("*|lowercase").size()); + Assertions.assertEquals(1, doc.select("*|lowercase").size()); } @Test public void xml_mixed_case_simple_name() { Document doc = Jsoup.parse(mixedCase, "", Parser.xmlParser()); - Assert.assertEquals(0, doc.select("mixedCase").size()); + Assertions.assertEquals(0, doc.select("mixedCase").size()); } @Test public void xml_mixed_case_wildcard_name() { Document doc = Jsoup.parse(mixedCase, "", Parser.xmlParser()); - Assert.assertEquals(1, doc.select("*|mixedCase").size()); + Assertions.assertEquals(1, doc.select("*|mixedCase").size()); } @Test public void xml_lowercase_simple_name() { Document doc = Jsoup.parse(lowercase, "", Parser.xmlParser()); - Assert.assertEquals(0, doc.select("lowercase").size()); + Assertions.assertEquals(0, doc.select("lowercase").size()); } @Test public void xml_lowercase_wildcard_name() { Document doc = Jsoup.parse(lowercase, "", Parser.xmlParser()); - Assert.assertEquals(1, doc.select("*|lowercase").size()); + Assertions.assertEquals(1, doc.select("*|lowercase").size()); } @Test @@ -834,8 +833,8 @@ public void trimSelector() { // https://github.com/jhy/jsoup/issues/1274 Document doc = Jsoup.parse("<p><span>Hello"); Elements els = doc.select(" p span "); - Assert.assertEquals(1, els.size()); - Assert.assertEquals("Hello", els.first().text()); + Assertions.assertEquals(1, els.size()); + Assertions.assertEquals("Hello", els.first().text()); } @Test @@ -843,9 +842,9 @@ public void xmlWildcardNamespaceTest() { // https://github.com/jhy/jsoup/issues/1208 Document doc = Jsoup.parse("<ns1:MyXmlTag>1111</ns1:MyXmlTag><ns2:MyXmlTag>2222</ns2:MyXmlTag>", "", Parser.xmlParser()); Elements select = doc.select("*|MyXmlTag"); - Assert.assertEquals(2, select.size()); - Assert.assertEquals("1111", select.get(0).text()); - Assert.assertEquals("2222", select.get(1).text()); + Assertions.assertEquals(2, select.size()); + Assertions.assertEquals("1111", select.get(0).text()); + Assertions.assertEquals("2222", select.get(1).text()); } @Test @@ -858,11 +857,11 @@ public void childElements() { Element span = outer.selectFirst("span"); Element inner = outer.selectFirst("* span"); - Assert.assertEquals("1", outer.id()); - Assert.assertEquals("1", span.id()); - Assert.assertEquals("2", inner.id()); - Assert.assertEquals(outer, span); - Assert.assertNotEquals(outer, inner); + Assertions.assertEquals("1", outer.id()); + Assertions.assertEquals("1", span.id()); + Assertions.assertEquals("2", inner.id()); + Assertions.assertEquals(outer, span); + Assertions.assertNotEquals(outer, inner); } @Test @@ -872,12 +871,12 @@ public void selectFirstLevelChildrenOnly() { Document doc = Jsoup.parse(html); Element div = doc.selectFirst("div"); - Assert.assertNotNull(div); + Assertions.assertNotNull(div); // want to select One and Three only - the first level children Elements spans = div.select(":root > span"); - Assert.assertEquals(2, spans.size()); - Assert.assertEquals("One Two", spans.get(0).text()); - Assert.assertEquals("Three Four", spans.get(1).text()); + Assertions.assertEquals(2, spans.size()); + Assertions.assertEquals("One Two", spans.get(0).text()); + Assertions.assertEquals("Three Four", spans.get(1).text()); } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/select/TraversorTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/select/TraversorTest.java index e34923752b..66260903da 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/select/TraversorTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/jsoup/select/TraversorTest.java @@ -27,12 +27,11 @@ This file is part of the iText (R) project. import com.itextpdf.styledxmlparser.jsoup.nodes.Element; import com.itextpdf.styledxmlparser.jsoup.nodes.Node; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class TraversorTest extends ExtendedITextTest { // Note: NodeTraversor.traverse(new NodeVisitor) is tested in // ElementsTest#traverse() @@ -54,7 +53,7 @@ public FilterResult tail(Node node, int depth) { return FilterResult.CONTINUE; } }, doc.select("div")); - Assert.assertEquals("<div><p><#text></#text></p></div><div><#text></#text></div>", accum.toString()); + Assertions.assertEquals("<div><p><#text></#text></p></div><div><#text></#text></div>", accum.toString()); } @Test @@ -75,7 +74,7 @@ public FilterResult tail(Node node, int depth) { return FilterResult.CONTINUE; } }, doc.select("div")); - Assert.assertEquals("<div><p></p></div><div><#text></#text></div>", accum.toString()); + Assertions.assertEquals("<div><p></p></div><div><#text></#text></div>", accum.toString()); } @Test @@ -98,7 +97,7 @@ public FilterResult tail(Node node, int depth) { return FilterResult.CONTINUE; } }, doc.select("div")); - Assert.assertEquals("<div></div><div><#text></#text></div>", accum.toString()); + Assertions.assertEquals("<div></div><div><#text></#text></div>", accum.toString()); } @Test @@ -117,7 +116,7 @@ public FilterResult tail(Node node, int depth) { return ("b".equals(node.nodeName())) ? FilterResult.REMOVE : FilterResult.CONTINUE; } }, doc.select("div")); - Assert.assertEquals("<div></div>\n<div>\n There be \n</div>", doc.select("body").html()); + Assertions.assertEquals("<div></div>\n<div>\n There be \n</div>", doc.select("body").html()); } @Test @@ -138,7 +137,7 @@ public FilterResult tail(Node node, int depth) { return ("p".equals(node.nodeName())) ? FilterResult.STOP : FilterResult.CONTINUE; } }, doc.select("div")); - Assert.assertEquals("<div><p><#text></#text></p>", accum.toString()); + Assertions.assertEquals("<div><p><#text></#text></p>", accum.toString()); } @Test public void replaceElement() { @@ -164,8 +163,8 @@ public void tail(Node node, int depth) {} }, doc); Element p = doc.selectFirst("p"); - Assert.assertNotNull(p); - Assert.assertEquals("<p>One <u>two</u> <u>three</u> four.</p>", p.outerHtml()); + Assertions.assertNotNull(p); + Assertions.assertEquals("<p>One <u>two</u> <u>three</u> four.</p>", p.outerHtml()); } @Test public void canAddChildren() { @@ -190,7 +189,7 @@ public void tail(Node node, int depth) { } }, doc); - Assert.assertEquals("<div>\n" + + Assertions.assertEquals("<div>\n" + " <p><span>0</span><span>1</span></p>\n" + " <p><span>2</span><span>3</span></p>\n" + "</div>", doc.body().html()); diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/resolver/resource/LimitedInputStreamTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/resolver/resource/LimitedInputStreamTest.java index f5ad3f2019..d70794a261 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/resolver/resource/LimitedInputStreamTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/resolver/resource/LimitedInputStreamTest.java @@ -25,7 +25,6 @@ This file is part of the iText (R) project. import com.itextpdf.styledxmlparser.exceptions.StyledXmlParserExceptionMessage; import com.itextpdf.styledxmlparser.exceptions.ReadingByteLimitException; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -34,11 +33,11 @@ This file is part of the iText (R) project. import java.net.URL; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class LimitedInputStreamTest extends ExtendedITextTest { private final String baseUri = "./src/test/resources/com/itextpdf/styledxmlparser/resolver/retrieveStreamTest/"; @@ -86,10 +85,10 @@ public void readingByteWithLimitOfOneLessThenFileSizeTest() throws IOException { // retrieveStyleSheetTest.css.dat size is 89 bytes InputStream stream = new LimitedInputStream(url.openStream(), 88); for (int i = 0; i < 88; i++) { - Assert.assertNotEquals(-1, stream.read()); + Assertions.assertNotEquals(-1, stream.read()); } - Assert.assertThrows(ReadingByteLimitException.class, () -> stream.read()); + Assertions.assertThrows(ReadingByteLimitException.class, () -> stream.read()); } @Test @@ -100,10 +99,10 @@ public void readingByteArrayWithLimitOfOneLessThenFileSizeTest() throws IOExcept InputStream stream = new LimitedInputStream(url.openStream(), 88); byte[] bytes = new byte[100]; int numOfReadBytes = stream.read(bytes); - Assert.assertEquals(88, numOfReadBytes); - Assert.assertEquals(10, bytes[87]); - Assert.assertEquals(0, bytes[88]); - Assert.assertThrows(ReadingByteLimitException.class, () -> stream.read(new byte[1])); + Assertions.assertEquals(88, numOfReadBytes); + Assertions.assertEquals(10, bytes[87]); + Assertions.assertEquals(0, bytes[88]); + Assertions.assertThrows(ReadingByteLimitException.class, () -> stream.read(new byte[1])); } @Test @@ -114,10 +113,10 @@ public void readingByteArrayWithOffsetAndLimitOfOneLessThenFileSizeTest() throws InputStream stream = new LimitedInputStream(url.openStream(), 88); byte[] bytes = new byte[100]; int numOfReadBytes = stream.read(bytes, 0, 88); - Assert.assertEquals(88, numOfReadBytes); - Assert.assertEquals(10, bytes[87]); - Assert.assertEquals(0, bytes[88]); - Assert.assertThrows(ReadingByteLimitException.class, () -> stream.read(bytes, 88, 1)); + Assertions.assertEquals(88, numOfReadBytes); + Assertions.assertEquals(10, bytes[87]); + Assertions.assertEquals(0, bytes[88]); + Assertions.assertThrows(ReadingByteLimitException.class, () -> stream.read(bytes, 88, 1)); } @Test @@ -135,7 +134,7 @@ public void readingByteArrayWithSmallBufferTest() throws IOException { } output.write(bytes, 0, read); } - Assert.assertEquals(89, output.size()); + Assertions.assertEquals(89, output.size()); output.close(); } @@ -147,11 +146,11 @@ public void readingByteArrayWithBigBufferTest() throws IOException { InputStream stream = new LimitedInputStream(url.openStream(), 89); byte[] bytes = new byte[100]; - Assert.assertEquals(89, stream.read(bytes)); + Assertions.assertEquals(89, stream.read(bytes)); byte[] tempBytes = (byte[]) bytes.clone(); - Assert.assertEquals(-1, stream.read(bytes)); + Assertions.assertEquals(-1, stream.read(bytes)); // Check that the array has not changed when we have read the entire LimitedInputStream - Assert.assertArrayEquals(tempBytes, bytes); + Assertions.assertArrayEquals(tempBytes, bytes); } @Test @@ -162,11 +161,11 @@ public void readingByteArrayWithOffsetAndBigBufferTest() throws IOException { InputStream stream = new LimitedInputStream(url.openStream(), 89); byte[] bytes = new byte[100]; - Assert.assertEquals(89, stream.read(bytes, 0, 100)); + Assertions.assertEquals(89, stream.read(bytes, 0, 100)); byte[] tempBytes = (byte[]) bytes.clone(); - Assert.assertEquals(-1, stream.read(bytes, 0, 100)); + Assertions.assertEquals(-1, stream.read(bytes, 0, 100)); // Check that the array has not changed when we have read the entire LimitedInputStream - Assert.assertArrayEquals(tempBytes, bytes); + Assertions.assertArrayEquals(tempBytes, bytes); } @Test @@ -178,17 +177,17 @@ public void byteArrayOverwritingTest() throws IOException { byte[] bytes = new byte[100]; bytes[89] = 13; - Assert.assertEquals(89, stream.read(bytes)); + Assertions.assertEquals(89, stream.read(bytes)); // Check that when calling the read(byte[]) method, as many bytes were copied into // the original array as were read, and not all bytes from the auxiliary array. - Assert.assertEquals(13, bytes[89]); + Assertions.assertEquals(13, bytes[89]); } @Test public void readingByteWithZeroLimitTest() throws IOException { LimitedInputStream stream = new LimitedInputStream(new ByteArrayInputStream(new byte[1]), 0); - Assert.assertThrows(ReadingByteLimitException.class, () -> stream.read()); + Assertions.assertThrows(ReadingByteLimitException.class, () -> stream.read()); } @Test @@ -196,7 +195,7 @@ public void readingByteArrayWithZeroLimitTest() throws IOException { LimitedInputStream stream = new LimitedInputStream(new ByteArrayInputStream(new byte[1]), 0); byte[] bytes = new byte[100]; - Assert.assertThrows(ReadingByteLimitException.class, () -> stream.read(bytes)); + Assertions.assertThrows(ReadingByteLimitException.class, () -> stream.read(bytes)); } @Test @@ -204,34 +203,34 @@ public void readingByteArrayWithOffsetAndZeroLimitTest() throws IOException { LimitedInputStream stream = new LimitedInputStream(new ByteArrayInputStream(new byte[1]), 0); byte[] bytes = new byte[100]; - Assert.assertThrows(ReadingByteLimitException.class, () -> stream.read(bytes, 0, 100)); + Assertions.assertThrows(ReadingByteLimitException.class, () -> stream.read(bytes, 0, 100)); } @Test public void readingEmptyByteWithZeroLimitTest() throws IOException { LimitedInputStream stream = new LimitedInputStream(new ByteArrayInputStream(new byte[0]), 0); - Assert.assertEquals(-1, stream.read()); + Assertions.assertEquals(-1, stream.read()); } @Test public void readingEmptyByteArrayWithZeroLimitTest() throws IOException { LimitedInputStream stream = new LimitedInputStream(new ByteArrayInputStream(new byte[0]), 0); byte[] bytes = new byte[100]; - Assert.assertEquals(-1, stream.read(bytes)); + Assertions.assertEquals(-1, stream.read(bytes)); } @Test public void readingEmptyByteArrayWithOffsetAndZeroLimitTest() throws IOException { LimitedInputStream stream = new LimitedInputStream(new ByteArrayInputStream(new byte[0]), 0); byte[] bytes = new byte[100]; - Assert.assertEquals(-1, stream.read(bytes, 0, 100)); + Assertions.assertEquals(-1, stream.read(bytes, 0, 100)); } @Test public void illegalReadingByteLimitValueTest() { - Exception e = Assert.assertThrows(IllegalArgumentException.class, + Exception e = Assertions.assertThrows(IllegalArgumentException.class, () -> new LimitedInputStream(new ByteArrayInputStream(new byte[0]), -1) ); - Assert.assertEquals(StyledXmlParserExceptionMessage.READING_BYTE_LIMIT_MUST_NOT_BE_LESS_ZERO, e.getMessage()); + Assertions.assertEquals(StyledXmlParserExceptionMessage.READING_BYTE_LIMIT_MUST_NOT_BE_LESS_ZERO, e.getMessage()); } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/resolver/resource/ResourceResolverTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/resolver/resource/ResourceResolverTest.java index eea1a2e733..c1cc375482 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/resolver/resource/ResourceResolverTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/resolver/resource/ResourceResolverTest.java @@ -30,7 +30,6 @@ This file is part of the iText (R) project. import com.itextpdf.test.LogLevelConstants; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.File; import java.io.FileInputStream; @@ -40,11 +39,11 @@ This file is part of the iText (R) project. import java.net.URL; import java.nio.file.Files; import java.nio.file.Paths; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class ResourceResolverTest extends ExtendedITextTest { private final String baseUri = "./src/test/resources/com/itextpdf/styledxmlparser/resolver/retrieveStreamTest/"; @@ -65,8 +64,8 @@ public void constructorWithBaseUriTest() throws MalformedURLException { String resolveUrl = resolver.resolveAgainstBaseUri("").toString(); String expectedUrl = uriResolver.resolveAgainstBaseUri("").toString(); - Assert.assertEquals(resolveUrl, expectedUrl); - Assert.assertEquals(DefaultResourceRetriever.class, resolver.getRetriever().getClass()); + Assertions.assertEquals(resolveUrl, expectedUrl); + Assertions.assertEquals(DefaultResourceRetriever.class, resolver.getRetriever().getClass()); } @Test @@ -77,8 +76,8 @@ public void constructorWithBaseUriAndResourceRetrieverTest() throws MalformedURL String resolveUrl = resolver.resolveAgainstBaseUri("").toString(); String expectedUrl = uriResolver.resolveAgainstBaseUri("").toString(); - Assert.assertEquals(resolveUrl, expectedUrl); - Assert.assertEquals(CustomResourceRetriever.class, resolver.getRetriever().getClass()); + Assertions.assertEquals(resolveUrl, expectedUrl); + Assertions.assertEquals(CustomResourceRetriever.class, resolver.getRetriever().getClass()); } private static class CustomResourceRetriever extends DefaultResourceRetriever { @@ -93,7 +92,7 @@ public void retrieveStreamByMalformedResourceNameTest() { String fileName = "resourceResolverTest .png"; ResourceResolver resourceResolver = new ResourceResolver(baseUri); byte[] bytes = resourceResolver.retrieveBytesFromResource(fileName); - Assert.assertNull(bytes); + Assertions.assertNull(bytes); } @Test @@ -110,7 +109,7 @@ public void retrieveResourceAsInputStreamByMalformedResourceNameTest() { String fileName = "retrieveStyl eSheetTest.css"; ResourceResolver resourceResolver = new ResourceResolver(baseUri); InputStream stream = resourceResolver.retrieveResourceAsInputStream(fileName); - Assert.assertNull(stream); + Assertions.assertNull(stream); } @Test @@ -119,7 +118,7 @@ public void retrieveBytesFromResourceByMalformedResourceNameTest() { String fileName = "retrieveStyl eSheetTest.css"; ResourceResolver resourceResolver = new ResourceResolver(baseUri); byte[] bytes = resourceResolver.retrieveBytesFromResource(fileName); - Assert.assertNull(bytes); + Assertions.assertNull(bytes); } @Test @@ -129,7 +128,7 @@ public void retrieveImageByMalformedResourceNameTest() { ResourceResolver resourceResolver = new ResourceResolver(baseUri); PdfXObject pdfXObject = resourceResolver.retrieveImage(fileName); - Assert.assertNull(pdfXObject); + Assertions.assertNull(pdfXObject); } @Test @@ -141,8 +140,8 @@ public void malformedResourceNameWithoutSharpSymbolTest07() throws IOException { ResourceResolver resourceResolver = new ResourceResolver(baseUri); InputStream stream = resourceResolver.retrieveResourceAsInputStream(fileName); - Assert.assertNotNull(stream); - Assert.assertEquals(expected.read(), stream.read()); + Assertions.assertNotNull(stream); + Assertions.assertEquals(expected.read(), stream.read()); } @Test @@ -155,18 +154,18 @@ public void malformedResourceNameTest07() throws IOException { ResourceResolver resourceResolver = new ResourceResolver(baseUri); InputStream stream = resourceResolver.retrieveResourceAsInputStream(fileName); - Assert.assertNotNull(stream); - Assert.assertEquals(expected.read(), stream.read()); + Assertions.assertNotNull(stream); + Assertions.assertEquals(expected.read(), stream.read()); } // Boolean method tests block @Test public void isDataSrcTest() { - Assert.assertTrue(ResourceResolver.isDataSrc(bLogo)); - Assert.assertTrue(ResourceResolver.isDataSrc(bLogoCorruptedData)); - Assert.assertTrue(ResourceResolver.isDataSrc(bLogoIncorrect)); - Assert.assertFalse(ResourceResolver.isDataSrc("https://data.com/data")); + Assertions.assertTrue(ResourceResolver.isDataSrc(bLogo)); + Assertions.assertTrue(ResourceResolver.isDataSrc(bLogoCorruptedData)); + Assertions.assertTrue(ResourceResolver.isDataSrc(bLogoIncorrect)); + Assertions.assertFalse(ResourceResolver.isDataSrc("https://data.com/data")); } // Retrieve pdfXObject tests block @@ -175,7 +174,7 @@ public void isDataSrcTest() { public void retrieveImageBase64Test() { ResourceResolver resourceResolver = new ResourceResolver(baseUri); PdfXObject image = resourceResolver.retrieveImage(bLogo); - Assert.assertNotNull(image); + Assertions.assertNotNull(image); } @Test @@ -183,7 +182,7 @@ public void retrieveImageBase64Test() { public void retrieveImageIncorrectBase64Test() { ResourceResolver resourceResolver = new ResourceResolver(baseUri); PdfXObject image = resourceResolver.retrieveImage(bLogoCorruptedData); - Assert.assertNull(image); + Assertions.assertNull(image); } @Test @@ -191,7 +190,7 @@ public void retrieveImageIncorrectBase64Test() { public void retrieveImageCorruptedDataBase64Test() { ResourceResolver resourceResolver = new ResourceResolver(baseUri); PdfXObject image = resourceResolver.retrieveImage(bLogoCorruptedData); - Assert.assertNull(image); + Assertions.assertNull(image); } @Test @@ -199,7 +198,7 @@ public void retrieveImageCorruptedDataBase64Test() { public void retrieveImageNullTest() { ResourceResolver resourceResolver = new ResourceResolver(baseUri); PdfXObject image = resourceResolver.retrieveImage(null); - Assert.assertNull(image); + Assertions.assertNull(image); } @Test @@ -207,7 +206,7 @@ public void retrieveImageTest() { String fileName = "resourceResolverTest.png"; ResourceResolver resourceResolver = new ResourceResolver(baseUri); PdfXObject image = resourceResolver.retrieveImage(fileName); - Assert.assertNotNull(image); + Assertions.assertNotNull(image); } // Retrieve byte array tests block @@ -216,7 +215,7 @@ public void retrieveImageTest() { public void retrieveBytesFromResourceBase64Test() { ResourceResolver resourceResolver = new ResourceResolver(baseUri); byte[] bytes = resourceResolver.retrieveBytesFromResource(bLogo); - Assert.assertNotNull(bytes); + Assertions.assertNotNull(bytes); } @Test @@ -224,7 +223,7 @@ public void retrieveBytesFromResourceBase64Test() { public void retrieveBytesFromResourceIncorrectBase64Test() { ResourceResolver resourceResolver = new ResourceResolver(baseUri); byte[] bytes = resourceResolver.retrieveBytesFromResource(bLogoIncorrect); - Assert.assertNull(bytes); + Assertions.assertNull(bytes); } @Test @@ -232,7 +231,7 @@ public void retrieveBytesFromResourceIncorrectBase64Test() { public void retrieveBytesFromResourceCorruptedDataBase64Test() { ResourceResolver resourceResolver = new ResourceResolver(baseUri); byte[] bytes = resourceResolver.retrieveBytesFromResource(bLogoCorruptedData); - Assert.assertNull(bytes); + Assertions.assertNull(bytes); } @Test @@ -241,8 +240,8 @@ public void retrieveBytesFromResourcePngImageTest() throws IOException { ResourceResolver resourceResolver = new ResourceResolver(baseUri); byte[] expected = Files.readAllBytes(new File(baseUri + fileName).toPath()); byte[] bytes = resourceResolver.retrieveBytesFromResource(fileName); - Assert.assertNotNull(bytes); - Assert.assertEquals(expected.length, bytes.length); + Assertions.assertNotNull(bytes); + Assertions.assertEquals(expected.length, bytes.length); } @Test @@ -251,8 +250,8 @@ public void retrieveStreamPngImageTest() throws IOException { ResourceResolver resourceResolver = new ResourceResolver(baseUri); byte[] expected = Files.readAllBytes(new File(baseUri + fileName).toPath()); byte[] stream = resourceResolver.retrieveBytesFromResource(fileName); - Assert.assertNotNull(resourceResolver.retrieveBytesFromResource(fileName)); - Assert.assertEquals(expected.length, stream.length); + Assertions.assertNotNull(resourceResolver.retrieveBytesFromResource(fileName)); + Assertions.assertEquals(expected.length, stream.length); } @Test @@ -261,8 +260,8 @@ public void retrieveBytesFromResourceStyleSheetTest() throws IOException { ResourceResolver resourceResolver = new ResourceResolver(baseUri); byte[] expected = Files.readAllBytes(new File(baseUri + fileName).toPath()); byte[] bytes = resourceResolver.retrieveBytesFromResource(fileName); - Assert.assertNotNull(bytes); - Assert.assertEquals(expected.length, bytes.length); + Assertions.assertNotNull(bytes); + Assertions.assertEquals(expected.length, bytes.length); } @Test @@ -272,7 +271,7 @@ public void attemptToRetrieveBytesFromResourceStyleSheetWithFilterRetrieverTest( ResourceResolver resourceResolver = new ResourceResolver(baseUri); resourceResolver.setRetriever(new FilterResourceRetriever()); byte[] bytes = resourceResolver.retrieveBytesFromResource(fileName); - Assert.assertNull(bytes); + Assertions.assertNull(bytes); } @Test @@ -281,7 +280,7 @@ public void retrieveImageWrongPathTest() { String fileName = "/itextpdf.com/itis.jpg"; ResourceResolver resourceResolver = new ResourceResolver(baseUri); PdfXObject image = resourceResolver.retrieveImage(fileName); - Assert.assertNull(image); + Assertions.assertNull(image); } @Test @@ -289,7 +288,7 @@ public void retrieveImageRightPathTest() { String fileName = "itextpdf.com/itis.jpg"; ResourceResolver resourceResolver = new ResourceResolver(baseUri); PdfXObject image = resourceResolver.retrieveImage(fileName); - Assert.assertNotNull(image); + Assertions.assertNotNull(image); } @Test @@ -297,7 +296,7 @@ public void retrieveImagePathWithSpacesTest() { String fileName = "retrieveImagePathWithSpaces.jpg"; ResourceResolver resourceResolver = new ResourceResolver(baseUri + "path with spaces/"); PdfXObject image = resourceResolver.retrieveImage(fileName); - Assert.assertNotNull(image); + Assertions.assertNotNull(image); } @Test @@ -306,7 +305,7 @@ public void retrieveBytesMalformedResourceNameTest() { String fileName = "resourceResolverTest .png"; ResourceResolver resourceResolver = new ResourceResolver(baseUri); byte[] bytes =resourceResolver.retrieveBytesFromResource(fileName); - Assert.assertNull(bytes); + Assertions.assertNull(bytes); } @Test @@ -315,8 +314,8 @@ public void retrieveBytesFromResourceWithRetryRetrieverTest() throws IOException ResourceResolver resourceResolver = new ResourceResolver(baseUri, new RetryResourceRetriever(baseUri)); byte[] expected = Files.readAllBytes(new File(baseUri + "retrieveStyleSheetTest.css").toPath()); byte[] bytes = resourceResolver.retrieveBytesFromResource(fileName); - Assert.assertNotNull(bytes); - Assert.assertEquals(expected.length, bytes.length); + Assertions.assertNotNull(bytes); + Assertions.assertEquals(expected.length, bytes.length); } @Test @@ -327,7 +326,7 @@ public void attemptToRetrieveBytesFromLocalWithResourceSizeByteLimitTest() { IResourceRetriever retriever = new DefaultResourceRetriever().setResourceSizeByteLimit(88); ResourceResolver resourceResolver = new ResourceResolver(baseUri, retriever); byte[] bytes = resourceResolver.retrieveBytesFromResource(fileName); - Assert.assertNull(bytes); + Assertions.assertNull(bytes); } @Test @@ -337,8 +336,8 @@ public void retrieveBytesFromLocalWithResourceSizeByteLimitTest() { IResourceRetriever retriever = new DefaultResourceRetriever().setResourceSizeByteLimit(89); ResourceResolver resourceResolver = new ResourceResolver(baseUri, retriever); byte[] bytes = resourceResolver.retrieveBytesFromResource(fileName); - Assert.assertNotNull(bytes); - Assert.assertEquals(((DefaultResourceRetriever) retriever).getResourceSizeByteLimit(), bytes.length); + Assertions.assertNotNull(bytes); + Assertions.assertEquals(((DefaultResourceRetriever) retriever).getResourceSizeByteLimit(), bytes.length); } // Retrieve input stream tests block @@ -355,14 +354,14 @@ public void attemptToReadBytesFromLimitedInputStreamTest() throws IOException { stream.read(); } - Assert.assertThrows(ReadingByteLimitException.class, () -> stream.read()); + Assertions.assertThrows(ReadingByteLimitException.class, () -> stream.read()); } @Test public void retrieveResourceAsInputStreamBase64Test() { ResourceResolver resourceResolver = new ResourceResolver(baseUri); InputStream stream = resourceResolver.retrieveResourceAsInputStream(bLogo); - Assert.assertNotNull(stream); + Assertions.assertNotNull(stream); } @Test @@ -371,8 +370,8 @@ public void retrieveStyleSheetTest() throws IOException { InputStream expected = FileUtil.getInputStreamForFile(baseUri + fileName); ResourceResolver resourceResolver = new ResourceResolver(baseUri); InputStream stream = resourceResolver.retrieveResourceAsInputStream(fileName); - Assert.assertNotNull(stream); - Assert.assertEquals(expected.read(), stream.read()); + Assertions.assertNotNull(stream); + Assertions.assertEquals(expected.read(), stream.read()); } @Test @@ -381,8 +380,8 @@ public void retrieveResourceAsInputStreamStyleSheetTest() throws IOException { InputStream expected = FileUtil.getInputStreamForFile(baseUri + fileName); ResourceResolver resourceResolver = new ResourceResolver(baseUri); InputStream stream = resourceResolver.retrieveResourceAsInputStream(fileName); - Assert.assertNotNull(stream); - Assert.assertEquals(expected.read(), stream.read()); + Assertions.assertNotNull(stream); + Assertions.assertEquals(expected.read(), stream.read()); } @Test @@ -392,7 +391,7 @@ public void attemptToRetrieveInputStreamWithFilterRetrieverTest() { ResourceResolver resourceResolver = new ResourceResolver(baseUri); resourceResolver.setRetriever(new FilterResourceRetriever()); InputStream stream = resourceResolver.retrieveResourceAsInputStream(fileName); - Assert.assertNull(stream); + Assertions.assertNull(stream); } private static class FilterResourceRetriever extends DefaultResourceRetriever { @@ -408,8 +407,8 @@ public void retrieveInputStreamWithRetryRetrieverTest() throws IOException { ResourceResolver resourceResolver = new ResourceResolver(baseUri, new RetryResourceRetriever(baseUri)); InputStream expected = FileUtil.getInputStreamForFile(baseUri + "retrieveStyleSheetTest.css"); InputStream stream = resourceResolver.retrieveResourceAsInputStream(fileName); - Assert.assertNotNull(stream); - Assert.assertEquals(expected.read(), stream.read()); + Assertions.assertNotNull(stream); + Assertions.assertEquals(expected.read(), stream.read()); } private static class RetryResourceRetriever extends DefaultResourceRetriever { @@ -445,8 +444,8 @@ public void retrieveStyleSheetAbsolutePathTest() throws IOException { ResourceResolver resourceResolver = new ResourceResolver(baseUri); try (InputStream stream = resourceResolver.retrieveResourceAsInputStream(absolutePath); InputStream expected = FileUtil.getInputStreamForFile(absolutePath);) { - Assert.assertNotNull(stream); - Assert.assertEquals(expected.read(), stream.read()); + Assertions.assertNotNull(stream); + Assertions.assertEquals(expected.read(), stream.read()); } } @@ -458,8 +457,8 @@ public void retrieveResourceAsInputStreamAbsolutePathTest() throws IOException { ResourceResolver resourceResolver = new ResourceResolver(baseUri); try (InputStream stream = resourceResolver.retrieveResourceAsInputStream(absolutePath); InputStream expected = FileUtil.getInputStreamForFile(absolutePath);) { - Assert.assertNotNull(stream); - Assert.assertEquals(expected.read(), stream.read()); + Assertions.assertNotNull(stream); + Assertions.assertEquals(expected.read(), stream.read()); } } @@ -472,8 +471,8 @@ public void retrieveStyleSheetFileUrlTest() throws IOException { ResourceResolver resourceResolver = new ResourceResolver(baseUri); try (InputStream stream = resourceResolver.retrieveResourceAsInputStream(fileUrlString); InputStream expected = url.openStream()) { - Assert.assertNotNull(stream); - Assert.assertEquals(expected.read(), stream.read()); + Assertions.assertNotNull(stream); + Assertions.assertEquals(expected.read(), stream.read()); } } @@ -486,8 +485,8 @@ public void retrieveResourceAsInputStreamFileUrlTest() throws IOException { ResourceResolver resourceResolver = new ResourceResolver(baseUri); try (InputStream stream = resourceResolver.retrieveResourceAsInputStream(fileUrlString); InputStream expected = url.openStream()) { - Assert.assertNotNull(stream); - Assert.assertEquals(expected.read(), stream.read()); + Assertions.assertNotNull(stream); + Assertions.assertEquals(expected.read(), stream.read()); } } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/resolver/resource/SimpleImageCacheTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/resolver/resource/SimpleImageCacheTest.java index 34ccb80110..50cfff92d0 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/resolver/resource/SimpleImageCacheTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/resolver/resource/SimpleImageCacheTest.java @@ -25,16 +25,15 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.PdfStream; import com.itextpdf.kernel.pdf.xobject.PdfImageXObject; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class SimpleImageCacheTest extends ExtendedITextTest { - @Before + @BeforeEach public void before() { ImageXObjectStub.resetNumbering(); } @@ -44,10 +43,10 @@ public void simpleImageCacheTest01() { SimpleImageCache cache = new SimpleImageCache(); String imgSrc = "src1.jpg"; ImageXObjectStub imageData = new ImageXObjectStub(); - Assert.assertEquals(0, cache.size()); + Assertions.assertEquals(0, cache.size()); cache.putImage(imgSrc, imageData); - Assert.assertEquals(1, cache.size()); - Assert.assertEquals(imageData, cache.getImage(imgSrc)); + Assertions.assertEquals(1, cache.size()); + Assertions.assertEquals(imageData, cache.getImage(imgSrc)); } @Test @@ -65,22 +64,22 @@ public void simpleImageCacheTest02() { cache.putImage(imgSrc[0], imgData[0]); cache.putImage(imgSrc[1], imgData[1]); cache.putImage(imgSrc[2], imgData[2]); - Assert.assertEquals(3, cache.size()); + Assertions.assertEquals(3, cache.size()); cache.getImage(imgSrc[0]); cache.getImage(imgSrc[1]); cache.getImage(imgSrc[2]); cache.putImage(imgSrc[3], imgData[3]); - Assert.assertEquals(4, cache.size()); + Assertions.assertEquals(4, cache.size()); cache.putImage(imgSrc[4], imgData[4]); - Assert.assertEquals(4, cache.size()); - Assert.assertNull(cache.getImage(imgSrc[3])); - Assert.assertEquals(imgData[0], cache.getImage(imgSrc[0])); - Assert.assertEquals(imgData[1], cache.getImage(imgSrc[1])); - Assert.assertEquals(imgData[2], cache.getImage(imgSrc[2])); - Assert.assertEquals(imgData[4], cache.getImage(imgSrc[4])); + Assertions.assertEquals(4, cache.size()); + Assertions.assertNull(cache.getImage(imgSrc[3])); + Assertions.assertEquals(imgData[0], cache.getImage(imgSrc[0])); + Assertions.assertEquals(imgData[1], cache.getImage(imgSrc[1])); + Assertions.assertEquals(imgData[2], cache.getImage(imgSrc[2])); + Assertions.assertEquals(imgData[4], cache.getImage(imgSrc[4])); cache.getImage(imgSrc[0]); cache.getImage(imgSrc[1]); @@ -88,39 +87,39 @@ public void simpleImageCacheTest02() { cache.getImage(imgSrc[4]); cache.putImage(imgSrc[5], imgData[5]); - Assert.assertEquals(4, cache.size()); - Assert.assertNull(cache.getImage(imgSrc[4])); - Assert.assertEquals(imgData[0], cache.getImage(imgSrc[0])); - Assert.assertEquals(imgData[1], cache.getImage(imgSrc[1])); - Assert.assertEquals(imgData[2], cache.getImage(imgSrc[2])); - Assert.assertEquals(imgData[5], cache.getImage(imgSrc[5])); + Assertions.assertEquals(4, cache.size()); + Assertions.assertNull(cache.getImage(imgSrc[4])); + Assertions.assertEquals(imgData[0], cache.getImage(imgSrc[0])); + Assertions.assertEquals(imgData[1], cache.getImage(imgSrc[1])); + Assertions.assertEquals(imgData[2], cache.getImage(imgSrc[2])); + Assertions.assertEquals(imgData[5], cache.getImage(imgSrc[5])); cache.putImage(imgSrc[3], imgData[3]); - Assert.assertEquals(4, cache.size()); - Assert.assertEquals(imgData[3], cache.getImage(imgSrc[3])); - Assert.assertNull(cache.getImage(imgSrc[5])); + Assertions.assertEquals(4, cache.size()); + Assertions.assertEquals(imgData[3], cache.getImage(imgSrc[3])); + Assertions.assertNull(cache.getImage(imgSrc[5])); cache.putImage(imgSrc[5], imgData[5]); - Assert.assertEquals(4, cache.size()); - Assert.assertEquals(imgData[5], cache.getImage(imgSrc[5])); - Assert.assertNull(cache.getImage(imgSrc[3])); + Assertions.assertEquals(4, cache.size()); + Assertions.assertEquals(imgData[5], cache.getImage(imgSrc[5])); + Assertions.assertNull(cache.getImage(imgSrc[3])); cache.putImage(imgSrc[3], imgData[3]); - Assert.assertEquals(4, cache.size()); - Assert.assertEquals(imgData[3], cache.getImage(imgSrc[3])); - Assert.assertNull(cache.getImage(imgSrc[5])); + Assertions.assertEquals(4, cache.size()); + Assertions.assertEquals(imgData[3], cache.getImage(imgSrc[3])); + Assertions.assertNull(cache.getImage(imgSrc[5])); cache.putImage(imgSrc[5], imgData[5]); - Assert.assertEquals(4, cache.size()); - Assert.assertEquals(imgData[5], cache.getImage(imgSrc[5])); - Assert.assertEquals(imgData[3], cache.getImage(imgSrc[3])); + Assertions.assertEquals(4, cache.size()); + Assertions.assertEquals(imgData[5], cache.getImage(imgSrc[5])); + Assertions.assertEquals(imgData[3], cache.getImage(imgSrc[3])); - Assert.assertEquals(imgData[1], cache.getImage(imgSrc[1])); - Assert.assertEquals(imgData[2], cache.getImage(imgSrc[2])); - Assert.assertNull(cache.getImage(imgSrc[0])); - Assert.assertNull(cache.getImage(imgSrc[4])); + Assertions.assertEquals(imgData[1], cache.getImage(imgSrc[1])); + Assertions.assertEquals(imgData[2], cache.getImage(imgSrc[2])); + Assertions.assertNull(cache.getImage(imgSrc[0])); + Assertions.assertNull(cache.getImage(imgSrc[4])); } @@ -134,7 +133,7 @@ public void orderRemovingFromCacheTest() { for (int i = 0; i <= 9; i++) { cache.putImage("src" + i + 10 + ".jpg", new ImageXObjectStub()); - Assert.assertNull(cache.getImage("src" + i + ".jpg")); + Assertions.assertNull(cache.getImage("src" + i + ".jpg")); } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/resolver/resource/UriResolverTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/resolver/resource/UriResolverTest.java index 58678f76e7..7d036db8ee 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/resolver/resource/UriResolverTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/resolver/resource/UriResolverTest.java @@ -23,16 +23,15 @@ This file is part of the iText (R) project. package com.itextpdf.styledxmlparser.resolver.resource; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.net.MalformedURLException; import java.nio.file.Paths; -import org.junit.Assert; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class UriResolverTest extends ExtendedITextTest { private static final String SOURCE_FOLDER = @@ -72,12 +71,12 @@ public void uriResolverTest03() throws MalformedURLException { public void uriResolverTest04() throws MalformedURLException { UriResolver resolver = new UriResolver("index.html"); String runFolder = Paths.get("").toUri().toURL().toExternalForm(); - Assert.assertEquals(runFolder + "index.html", resolver.getBaseUri()); - Assert.assertEquals(runFolder + "innerTest", resolver.resolveAgainstBaseUri("innerTest").toExternalForm()); + Assertions.assertEquals(runFolder + "index.html", resolver.getBaseUri()); + Assertions.assertEquals(runFolder + "innerTest", resolver.resolveAgainstBaseUri("innerTest").toExternalForm()); // Look to commentary in testPaths() method. -// Assert.assertEquals("file:/folder2/innerTest2", resolver.resolveAgainstBaseUri("/folder2/innerTest2").toExternalForm()); -// Assert.assertEquals("file://folder2/innerTest2/", resolver.resolveAgainstBaseUri("//folder2/innerTest2").toExternalForm()); +// Assertions.assertEquals("file:/folder2/innerTest2", resolver.resolveAgainstBaseUri("/folder2/innerTest2").toExternalForm()); +// Assertions.assertEquals("file://folder2/innerTest2/", resolver.resolveAgainstBaseUri("//folder2/innerTest2").toExternalForm()); } @Test @@ -100,17 +99,17 @@ public void resolveAgainstBaseUriTest() throws MalformedURLException { String baseUrl = "https://test"; UriResolver resolver = new UriResolver(SOURCE_FOLDER); resolver.resolveAgainstBaseUri(baseUrl); - Assert.assertTrue(resolver.isLocalBaseUri()); - Assert.assertTrue(resolver.getBaseUri().startsWith("file:")); + Assertions.assertTrue(resolver.isLocalBaseUri()); + Assertions.assertTrue(resolver.getBaseUri().startsWith("file:")); } @Test public void uriResolverTest07() throws MalformedURLException { UriResolver resolver = new UriResolver("http://itextpdf.com/itext7"); - Assert.assertEquals("http://itextpdf.com/itext7", resolver.getBaseUri()); - Assert.assertEquals("http://itextpdf.com/innerTest", resolver.resolveAgainstBaseUri("innerTest").toExternalForm()); - Assert.assertEquals("http://itextpdf.com/folder2/innerTest2", resolver.resolveAgainstBaseUri("/folder2/innerTest2").toExternalForm()); - Assert.assertEquals("http://folder2.com/innerTest2", resolver.resolveAgainstBaseUri("//folder2.com/innerTest2").toExternalForm()); + Assertions.assertEquals("http://itextpdf.com/itext7", resolver.getBaseUri()); + Assertions.assertEquals("http://itextpdf.com/innerTest", resolver.resolveAgainstBaseUri("innerTest").toExternalForm()); + Assertions.assertEquals("http://itextpdf.com/folder2/innerTest2", resolver.resolveAgainstBaseUri("/folder2/innerTest2").toExternalForm()); + Assertions.assertEquals("http://folder2.com/innerTest2", resolver.resolveAgainstBaseUri("//folder2.com/innerTest2").toExternalForm()); } @Test @@ -126,21 +125,21 @@ public void uriResolverTest07B() throws MalformedURLException { String absolutePathRoot = Paths.get("").toAbsolutePath().getRoot().toUri().toURL().toString(); UriResolver resolver = new UriResolver(absolutePathRoot + "#r%e%25s@o%urces/folder/index.html"); String malformedPath = absolutePathRoot; - Assert.assertEquals(malformedPath + "#r%25e%25s@o%25urces/folder/index.html", resolver.getBaseUri()); - Assert.assertEquals(malformedPath + "test/folder/innerTest", resolver.resolveAgainstBaseUri("test/folder/innerTest").toExternalForm()); + Assertions.assertEquals(malformedPath + "#r%25e%25s@o%25urces/folder/index.html", resolver.getBaseUri()); + Assertions.assertEquals(malformedPath + "test/folder/innerTest", resolver.resolveAgainstBaseUri("test/folder/innerTest").toExternalForm()); // Look to commentary in testPaths() method. -// Assert.assertEquals("file:/folder2/innerTest2", resolver.resolveAgainstBaseUri("/folder2/innerTest2").toExternalForm()); -// Assert.assertEquals("file://folder/folder2/innerTest2", resolver.resolveAgainstBaseUri("//folder/folder2/innerTest2").toExternalForm()); +// Assertions.assertEquals("file:/folder2/innerTest2", resolver.resolveAgainstBaseUri("/folder2/innerTest2").toExternalForm()); +// Assertions.assertEquals("file://folder/folder2/innerTest2", resolver.resolveAgainstBaseUri("//folder/folder2/innerTest2").toExternalForm()); } @Test public void uriResolverTest08() throws MalformedURLException { UriResolver resolver = new UriResolver("http://itextpdf.com/itext7/"); - Assert.assertEquals("http://itextpdf.com/itext7/", resolver.getBaseUri()); - Assert.assertEquals("http://itextpdf.com/itext7/innerTest", resolver.resolveAgainstBaseUri("innerTest").toExternalForm()); - Assert.assertEquals("http://itextpdf.com/folder2/innerTest2", resolver.resolveAgainstBaseUri("/folder2/innerTest2").toExternalForm()); - Assert.assertEquals("http://folder2.com/innerTest2", resolver.resolveAgainstBaseUri("//folder2.com/innerTest2").toExternalForm()); + Assertions.assertEquals("http://itextpdf.com/itext7/", resolver.getBaseUri()); + Assertions.assertEquals("http://itextpdf.com/itext7/innerTest", resolver.resolveAgainstBaseUri("innerTest").toExternalForm()); + Assertions.assertEquals("http://itextpdf.com/folder2/innerTest2", resolver.resolveAgainstBaseUri("/folder2/innerTest2").toExternalForm()); + Assertions.assertEquals("http://folder2.com/innerTest2", resolver.resolveAgainstBaseUri("//folder2.com/innerTest2").toExternalForm()); } @Test @@ -204,21 +203,21 @@ public void uriResolverTest10F() throws MalformedURLException { public void uriResolverTest13() throws MalformedURLException { UriResolver resolver = new UriResolver(""); String runFolder = Paths.get("").toUri().toURL().toExternalForm(); - Assert.assertEquals(runFolder, resolver.getBaseUri()); - Assert.assertEquals(runFolder + "innerTest", resolver.resolveAgainstBaseUri("innerTest").toExternalForm()); + Assertions.assertEquals(runFolder, resolver.getBaseUri()); + Assertions.assertEquals(runFolder + "innerTest", resolver.resolveAgainstBaseUri("innerTest").toExternalForm()); String parentToRunFolder = Paths.get("").toAbsolutePath().getParent().toUri().toURL().toExternalForm(); - Assert.assertEquals(parentToRunFolder + "folder2/innerTest2", resolver.resolveAgainstBaseUri("../folder2/innerTest2").toExternalForm()); + Assertions.assertEquals(parentToRunFolder + "folder2/innerTest2", resolver.resolveAgainstBaseUri("../folder2/innerTest2").toExternalForm()); // Look to commentary in testPaths() method. -// Assert.assertEquals("file:/folder2/innerTest2", resolver.resolveAgainstBaseUri("/folder2/innerTest2").toExternalForm()); -// Assert.assertEquals("file://folder2/innerTest2/", resolver.resolveAgainstBaseUri("//folder2/innerTest2").toExternalForm()); +// Assertions.assertEquals("file:/folder2/innerTest2", resolver.resolveAgainstBaseUri("/folder2/innerTest2").toExternalForm()); +// Assertions.assertEquals("file://folder2/innerTest2/", resolver.resolveAgainstBaseUri("//folder2/innerTest2").toExternalForm()); } @Test public void uriResolverTest14() throws MalformedURLException { UriResolver resolver = new UriResolver("base/uri/index.html"); String runFolder = Paths.get("").toUri().toURL().toExternalForm(); - Assert.assertEquals(runFolder + "base/uri/index.html", resolver.getBaseUri()); + Assertions.assertEquals(runFolder + "base/uri/index.html", resolver.getBaseUri()); final String firstUriResolvingResult = resolver.resolveAgainstBaseUri("file:/c:/test/folder/img.txt") .toExternalForm(); @@ -226,20 +225,20 @@ public void uriResolverTest14() throws MalformedURLException { final String expectedUriWithTripleSlash = "file:///c:/test/folder/img.txt"; // Both variants(namely with triple and single slashes) are valid. - Assert.assertTrue(expectedUriWithSingleSlash.equals(firstUriResolvingResult) + Assertions.assertTrue(expectedUriWithSingleSlash.equals(firstUriResolvingResult) || expectedUriWithTripleSlash.equals(firstUriResolvingResult)); - Assert.assertEquals("file://c:/test/folder/img.txt", + Assertions.assertEquals("file://c:/test/folder/img.txt", resolver.resolveAgainstBaseUri("file://c:/test/folder/img.txt").toExternalForm()); final String thirdUriResolvingResult = resolver.resolveAgainstBaseUri("file:///c:/test/folder/img.txt") .toExternalForm(); // Result of resolving uri with triple slash should be the same as if it contained single slash. - Assert.assertEquals(firstUriResolvingResult, thirdUriResolvingResult); + Assertions.assertEquals(firstUriResolvingResult, thirdUriResolvingResult); // It is windows specific to assume this to work. On unix it shall fail, as it will assume that it is // an absolute URI with scheme 'c', and will not recognize this scheme. - // Assert.assertEquals("file:/c:/test/folder/data.jpg", resolver.resolveAgainstBaseUri("c:/test/folder/data + // Assertions.assertEquals("file:/c:/test/folder/data.jpg", resolver.resolveAgainstBaseUri("c:/test/folder/data // .jpg").toExternalForm()); } @@ -302,10 +301,10 @@ public void uriResolverTest17() throws MalformedURLException { String absoluteBaseUri = absolutePathRoot + "test/fol ders/wi@th/diffe#rent/$characters/test/folder/index.html\t\t\t\t\t\t"; UriResolver resolver = new UriResolver(absoluteBaseUri); String malformedPath = absolutePathRoot + "test/fol%20ders/wi@th/diffe#rent/$characters/"; - Assert.assertNotNull(malformedPath + "test/folder/innerTest", resolver.resolveAgainstBaseUri("innerTest").toExternalForm()); - Assert.assertNotNull(malformedPath + "test/folder2/innerTest2", resolver.resolveAgainstBaseUri("../folder2/innerTest2").toExternalForm()); - Assert.assertNotNull(malformedPath + "test/folder/folder2/innerTest2", resolver.resolveAgainstBaseUri("/folder2/innerTest2").toExternalForm()); - Assert.assertNotNull(malformedPath + "test/folder/folder2/innerTest2", resolver.resolveAgainstBaseUri("//folder2/innerTest2").toExternalForm()); + Assertions.assertNotNull(malformedPath + "test/folder/innerTest", resolver.resolveAgainstBaseUri("innerTest").toExternalForm()); + Assertions.assertNotNull(malformedPath + "test/folder2/innerTest2", resolver.resolveAgainstBaseUri("../folder2/innerTest2").toExternalForm()); + Assertions.assertNotNull(malformedPath + "test/folder/folder2/innerTest2", resolver.resolveAgainstBaseUri("/folder2/innerTest2").toExternalForm()); + Assertions.assertNotNull(malformedPath + "test/folder/folder2/innerTest2", resolver.resolveAgainstBaseUri("//folder2/innerTest2").toExternalForm()); } @Test @@ -313,7 +312,7 @@ public void uriResolverTest18() { String absolutePathRoot ="http://"; String absoluteBaseUri = absolutePathRoot + "test/folders/index.html"; UriResolver resolver = new UriResolver(absoluteBaseUri); - Assert.assertFalse(resolver.isLocalBaseUri()); + Assertions.assertFalse(resolver.isLocalBaseUri()); } @Test @@ -323,11 +322,11 @@ public void singleQuoteRelativePath() throws MalformedURLException { String relativePath = "%D7%90%D7%91%D7%92'%D7%93"; UriResolver resolver = new UriResolver(baseUri); - Assert.assertEquals(expectedUrl, resolver.resolveAgainstBaseUri(relativePath).toExternalForm()); + Assertions.assertEquals(expectedUrl, resolver.resolveAgainstBaseUri(relativePath).toExternalForm()); } @Test - @Ignore("DEVSIX-2880: single quote character isn't encoded in Java and .NET 4.0, but it's encoded in .NETCoreApp 1.0" + + @Disabled("DEVSIX-2880: single quote character isn't encoded in Java and .NET 4.0, but it's encoded in .NETCoreApp 1.0" + " from single quote to %27") public void quoteInPercentsRelativePath() throws MalformedURLException { String expectedUrl = "https://he.wikipedia.org/wiki/%D7%90%D7%91%D7%92%27%D7%93"; @@ -335,7 +334,7 @@ public void quoteInPercentsRelativePath() throws MalformedURLException { String relativePath = "%D7%90%D7%91%D7%92%27%D7%93"; UriResolver resolver = new UriResolver(baseUri); - Assert.assertEquals(expectedUrl, resolver.resolveAgainstBaseUri(relativePath).toExternalForm()); + Assertions.assertEquals(expectedUrl, resolver.resolveAgainstBaseUri(relativePath).toExternalForm()); } @Test @@ -345,11 +344,11 @@ public void singleQuoteBasePath() throws MalformedURLException { String relativePath = "%D7%90%D7%91%D7%92%D7%93"; UriResolver resolver = new UriResolver(baseUri); - Assert.assertEquals(expectedUrl, resolver.resolveAgainstBaseUri(relativePath).toExternalForm()); + Assertions.assertEquals(expectedUrl, resolver.resolveAgainstBaseUri(relativePath).toExternalForm()); } @Test - @Ignore("DEVSIX-2880: single quote character isn't encoded in Java and .NET 4.0, but it's encoded in .NETCoreApp 1.0" + + @Disabled("DEVSIX-2880: single quote character isn't encoded in Java and .NET 4.0, but it's encoded in .NETCoreApp 1.0" + " from single quote to %27") public void quoteInPercentsBasePath() throws MalformedURLException { String expectedUrl = "https://he.wikipedia.org/wiki%27/%D7%90%D7%91%D7%92%D7%93"; @@ -357,7 +356,7 @@ public void quoteInPercentsBasePath() throws MalformedURLException { String relativePath = "%D7%90%D7%91%D7%92%D7%93"; UriResolver resolver = new UriResolver(baseUri); - Assert.assertEquals(expectedUrl, resolver.resolveAgainstBaseUri(relativePath).toExternalForm()); + Assertions.assertEquals(expectedUrl, resolver.resolveAgainstBaseUri(relativePath).toExternalForm()); } @Test @@ -366,13 +365,13 @@ public void uriResolverPercentSignTest() throws MalformedURLException { UriResolver resolver = new UriResolver(absolutePathRoot + "%homepath%"); - Assert.assertEquals(absolutePathRoot + "%25homepath%25", resolver.getBaseUri()); + Assertions.assertEquals(absolutePathRoot + "%25homepath%25", resolver.getBaseUri()); } private void testPaths(UriResolver resolver, String path) throws MalformedURLException { - Assert.assertEquals(path + "test/folder/index.html", resolver.getBaseUri()); - Assert.assertEquals(path + "test/folder/innerTest", resolver.resolveAgainstBaseUri("innerTest").toExternalForm()); - Assert.assertEquals(path + "test/folder2/innerTest2", resolver.resolveAgainstBaseUri("../folder2/innerTest2").toExternalForm()); + Assertions.assertEquals(path + "test/folder/index.html", resolver.getBaseUri()); + Assertions.assertEquals(path + "test/folder/innerTest", resolver.resolveAgainstBaseUri("innerTest").toExternalForm()); + Assertions.assertEquals(path + "test/folder2/innerTest2", resolver.resolveAgainstBaseUri("../folder2/innerTest2").toExternalForm()); /* Resolving relative paths like "/folder" works correct on Linux and .NET, but fails on Java because of strong corresponding with URI standard RFC3986. @@ -385,7 +384,7 @@ private void testPaths(UriResolver resolver, String path) throws MalformedURLExc - Java (Windows): "file:/folder2/innerTest2" - incorrect - Java (Linux): "file:/folder2/innerTest2" - correct */ -// Assert.assertEquals("file:/folder2/innerTest2", resolver.resolveAgainstBaseUri("/folder2/innerTest2").toExternalForm()); -// Assert.assertEquals("file://folder2/innerTest2/", resolver.resolveAgainstBaseUri("//folder2/innerTest2").toExternalForm()); +// Assertions.assertEquals("file:/folder2/innerTest2", resolver.resolveAgainstBaseUri("/folder2/innerTest2").toExternalForm()); +// Assertions.assertEquals("file://folder2/innerTest2/", resolver.resolveAgainstBaseUri("//folder2/innerTest2").toExternalForm()); } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/util/FontFamilySplitterTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/util/FontFamilySplitterTest.java index 9618fdeb95..5eee601ed1 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/util/FontFamilySplitterTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/util/FontFamilySplitterTest.java @@ -23,15 +23,14 @@ This file is part of the iText (R) project. package com.itextpdf.styledxmlparser.util; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.util.List; -@Category(UnitTest.class) +@Tag("UnitTest") public class FontFamilySplitterTest extends ExtendedITextTest { @Test //TODO DEVSIX-1130: Adapt after fix @@ -131,7 +130,7 @@ public void fontFamilySplitter() { for (String ff: fontFamily) { result.append(ff).append("; "); } - Assert.assertEquals(splitFontFamilies[i+1], + Assertions.assertEquals(splitFontFamilies[i+1], result.length() > 2 ? result.substring(0, result.length() - 2) : "-"); } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/util/StyleUtilUnitTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/util/StyleUtilUnitTest.java index 4bc988c5ab..864fd540b0 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/util/StyleUtilUnitTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/util/StyleUtilUnitTest.java @@ -25,23 +25,22 @@ This file is part of the iText (R) project. import com.itextpdf.styledxmlparser.css.resolve.CssInheritance; import com.itextpdf.styledxmlparser.css.resolve.IStyleInheritance; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class StyleUtilUnitTest extends ExtendedITextTest { private static Set<IStyleInheritance> inheritanceRules; - @BeforeClass + @BeforeAll public static void before() { inheritanceRules = new HashSet<>(); inheritanceRules.add(new CssInheritance()); @@ -66,7 +65,7 @@ public void mergeParentDeclarationsMeasurementDoNotInheritTest(){ for (Map.Entry<String, String> kvp : expectedStyles.entrySet()) { equal &= kvp.getValue().equals(styles.get(kvp.getKey())); } - Assert.assertTrue(equal); + Assertions.assertTrue(equal); } @@ -88,7 +87,7 @@ public void mergeParentDeclarationsMeasurementInheritTest(){ for (Map.Entry<String, String> kvp : expectedStyles.entrySet()) { equal &= kvp.getValue().equals(styles.get(kvp.getKey())); } - Assert.assertTrue(equal); + Assertions.assertTrue(equal); } @@ -110,7 +109,7 @@ public void mergeParentDeclarationsRelativeMeasurementInheritTest(){ for (Map.Entry<String, String> kvp : expectedStyles.entrySet()) { equal &= kvp.getValue().equals(styles.get(kvp.getKey())); } - Assert.assertTrue(equal); + Assertions.assertTrue(equal); } } diff --git a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/util/WhiteSpaceUtilUnitTest.java b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/util/WhiteSpaceUtilUnitTest.java index b39c3aa3c4..97659a42df 100644 --- a/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/util/WhiteSpaceUtilUnitTest.java +++ b/styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/util/WhiteSpaceUtilUnitTest.java @@ -23,12 +23,11 @@ This file is part of the iText (R) project. package com.itextpdf.styledxmlparser.util; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class WhiteSpaceUtilUnitTest extends ExtendedITextTest { @Test @@ -36,7 +35,7 @@ public void collapseConsecutiveWhiteSpacesTest() { String toCollapse = "A B"; String actual = WhiteSpaceUtil.collapseConsecutiveSpaces(toCollapse); String expected = "A B"; - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test @@ -44,7 +43,7 @@ public void collapseConsecutiveWhiteSpacesTrailingWhiteSpaceTest() { String toCollapse = "A B "; String actual = WhiteSpaceUtil.collapseConsecutiveSpaces(toCollapse); String expected = "A B "; - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test @@ -52,7 +51,7 @@ public void collapseConsecutiveWhiteSpacesPrecedingWhiteSpaceTest() { String toCollapse = " A B"; String actual = WhiteSpaceUtil.collapseConsecutiveSpaces(toCollapse); String expected = " A B"; - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test @@ -60,7 +59,7 @@ public void collapseConsecutiveWhiteSpacesPrecedingAndTrailingWhiteSpaceTest() { String toCollapse = " A B "; String actual = WhiteSpaceUtil.collapseConsecutiveSpaces(toCollapse); String expected = " A B "; - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test @@ -68,7 +67,7 @@ public void collapseConsecutiveWhiteSpacesNewLineWhiteSpaceTest() { String toCollapse = "\n A B \n"; String actual = WhiteSpaceUtil.collapseConsecutiveSpaces(toCollapse); String expected = " A B "; - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test @@ -76,6 +75,6 @@ public void collapseConsecutiveWhiteSpacesTabWhiteSpaceTest() { String toCollapse = "\t A B \t"; String actual = WhiteSpaceUtil.collapseConsecutiveSpaces(toCollapse); String expected = " A B "; - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } } diff --git a/styled-xml-parser/src/test/resources/com/itextpdf/styledxmlparser/jsoup/htmltests/test-rss.xml b/styled-xml-parser/src/test/resources/com/itextpdf/styledxmlparser/jsoup/htmltests/test-rss.xml deleted file mode 100644 index 966ccafa22..0000000000 --- a/styled-xml-parser/src/test/resources/com/itextpdf/styledxmlparser/jsoup/htmltests/test-rss.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<rss version="2.0"> - - <channel> - <title>jsoup RSS news</title> - <link>https://jsoup.org/</link> - <description>jsoup HTML Parser News</description> - <item> - <title>jsoup Java HTML Parser release 1.12.2</title> - <link>https://jsoup.org/news/release-1.12.2</link> - <description>jsoup 1.12.2 is out now, with a great set of improvements to connections, W3C interoperability, speed, and many bug fixes.</description> - </item> - <item> - <title>jsoup Java HTML Parser release 1.12.1</title> - <link>https://jsoup.org/news/release-1.12.1</link> - <description>jsoup 1.12.1 is out now, with a great set of improvements to connections, W3C interoperability, speed, and many bug fixes.</description> - </item> - </channel> - -</rss> diff --git a/styled-xml-parser/src/test/resources/com/itextpdf/styledxmlparser/jsoup/htmltests/thumb.jpg b/styled-xml-parser/src/test/resources/com/itextpdf/styledxmlparser/jsoup/htmltests/thumb.jpg deleted file mode 100644 index c3e3762c33..0000000000 Binary files a/styled-xml-parser/src/test/resources/com/itextpdf/styledxmlparser/jsoup/htmltests/thumb.jpg and /dev/null differ diff --git a/svg/pom.xml b/svg/pom.xml index c81fb9391f..ae9766a3a3 100644 --- a/svg/pom.xml +++ b/svg/pom.xml @@ -5,7 +5,7 @@ <parent> <groupId>com.itextpdf</groupId> <artifactId>root</artifactId> - <version>8.0.5</version> + <version>9.0.0</version> </parent> <artifactId>svg</artifactId> diff --git a/svg/src/main/java/com/itextpdf/svg/renderers/SvgDrawContext.java b/svg/src/main/java/com/itextpdf/svg/renderers/SvgDrawContext.java index eddd5a2b98..9007b094c6 100644 --- a/svg/src/main/java/com/itextpdf/svg/renderers/SvgDrawContext.java +++ b/svg/src/main/java/com/itextpdf/svg/renderers/SvgDrawContext.java @@ -56,7 +56,8 @@ public class SvgDrawContext { private FontSet tempFonts; private SvgCssContext cssContext; - private AffineTransform lastTextTransform = new AffineTransform(); + private AffineTransform lastTextTransform; + private AffineTransform rootTransform; private float[] textMove = new float[]{0.0f, 0.0f}; private float[] previousElementTextMove; @@ -278,6 +279,27 @@ public void setLastTextTransform(AffineTransform newTransform) { this.lastTextTransform = newTransform; } + /** + * Get the current root transformation that was last applied. + * + * @return {@link AffineTransform} representing the root transformation. + */ + public AffineTransform getRootTransform() { + if (rootTransform == null) { + rootTransform = new AffineTransform(); + } + return this.rootTransform; + } + + /** + * Set the current root transformation. + * + * @param newTransform root transformation. + */ + public void setRootTransform(AffineTransform newTransform) { + this.rootTransform = newTransform; + } + /** * Get the stored current text move * @return [horizontal text move, vertical text move] diff --git a/svg/src/main/java/com/itextpdf/svg/renderers/impl/PathSvgNodeRenderer.java b/svg/src/main/java/com/itextpdf/svg/renderers/impl/PathSvgNodeRenderer.java index 7a58ffe078..f4d549c263 100644 --- a/svg/src/main/java/com/itextpdf/svg/renderers/impl/PathSvgNodeRenderer.java +++ b/svg/src/main/java/com/itextpdf/svg/renderers/impl/PathSvgNodeRenderer.java @@ -360,8 +360,8 @@ public void drawMarker(SvgDrawContext context, final MarkerVertexType markerVert .getEndingPoint(); } if (point != null) { - String moveX = SvgCssUtils.convertDoubleToString(point.x); - String moveY = SvgCssUtils.convertDoubleToString(point.y); + String moveX = SvgCssUtils.convertDoubleToString(point.getX()); + String moveY = SvgCssUtils.convertDoubleToString(point.getY()); MarkerSvgNodeRenderer.drawMarker(context, moveX, moveY, markerVertexType, this); } } diff --git a/svg/src/main/java/com/itextpdf/svg/renderers/impl/PolygonSvgNodeRenderer.java b/svg/src/main/java/com/itextpdf/svg/renderers/impl/PolygonSvgNodeRenderer.java index c4c0775e78..99ee339999 100644 --- a/svg/src/main/java/com/itextpdf/svg/renderers/impl/PolygonSvgNodeRenderer.java +++ b/svg/src/main/java/com/itextpdf/svg/renderers/impl/PolygonSvgNodeRenderer.java @@ -51,8 +51,8 @@ private void connectPoints() { Point start = points.get(0); Point end = points.get(points.size() - 1); - if (Double.compare(start.x, end.x) != 0 || Double.compare(start.y, end.y) != 0) { - points.add(new Point(start.x, start.y)); + if (Double.compare(start.getX(), end.getX()) != 0 || Double.compare(start.getY(), end.getY()) != 0) { + points.add(new Point(start.getX(), start.getY())); } } diff --git a/svg/src/main/java/com/itextpdf/svg/renderers/impl/PolylineSvgNodeRenderer.java b/svg/src/main/java/com/itextpdf/svg/renderers/impl/PolylineSvgNodeRenderer.java index bc99aaed8e..87cad2a26f 100644 --- a/svg/src/main/java/com/itextpdf/svg/renderers/impl/PolylineSvgNodeRenderer.java +++ b/svg/src/main/java/com/itextpdf/svg/renderers/impl/PolylineSvgNodeRenderer.java @@ -38,7 +38,6 @@ This file is part of the iText (R) project. import com.itextpdf.svg.utils.SvgCoordinateUtils; import com.itextpdf.svg.utils.SvgCssUtils; - import java.util.ArrayList; import java.util.List; @@ -153,8 +152,8 @@ public void drawMarker(SvgDrawContext context, final MarkerVertexType markerVert point = points.get(points.size() - 1); } if (point != null) { - String moveX = SvgCssUtils.convertDoubleToString(CssUtils.convertPtsToPx(point.x)); - String moveY = SvgCssUtils.convertDoubleToString(CssUtils.convertPtsToPx(point.y)); + String moveX = SvgCssUtils.convertDoubleToString(CssUtils.convertPtsToPx(point.getX())); + String moveY = SvgCssUtils.convertDoubleToString(CssUtils.convertPtsToPx(point.getY())); MarkerSvgNodeRenderer.drawMarker(context, moveX, moveY, markerVertexType, this); } } diff --git a/svg/src/main/java/com/itextpdf/svg/renderers/impl/TextSvgBranchRenderer.java b/svg/src/main/java/com/itextpdf/svg/renderers/impl/TextSvgBranchRenderer.java index dea78a8c18..0fa05cb68a 100644 --- a/svg/src/main/java/com/itextpdf/svg/renderers/impl/TextSvgBranchRenderer.java +++ b/svg/src/main/java/com/itextpdf/svg/renderers/impl/TextSvgBranchRenderer.java @@ -45,7 +45,6 @@ This file is part of the iText (R) project. import com.itextpdf.svg.utils.TextRectangle; import java.io.IOException; - import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -154,7 +153,7 @@ public TextRectangle getTextRectangle(SvgDrawContext context, Point basePoint) { y = basePoint.getY(); } basePoint = new Point(x, y); - basePoint.translate(getRelativeTranslation()[0], getRelativeTranslation()[1]); + basePoint.move(getRelativeTranslation()[0], getRelativeTranslation()[1]); Rectangle commonRect = null; for (ISvgTextNodeRenderer child : getChildren()) { if (child != null) { @@ -190,6 +189,7 @@ protected void doDraw(SvgDrawContext context) { PdfCanvas currentCanvas = context.getCurrentCanvas(); context.resetTextMove(); context.setLastTextTransform(null); + context.setRootTransform(null); if (this.attributesAndStyles != null) { for (ISvgTextNodeRenderer c : children) { currentCanvas.saveState(); @@ -215,6 +215,9 @@ protected void doDraw(SvgDrawContext context) { } else if (c instanceof TextLeafSvgNodeRenderer && !context.getLastTextTransform().isIdentity()) { currentCanvas.setTextMatrix(context.getLastTextTransform()); + } else { + // If we don't update the matrix, we should set root matrix as the last text matrix + context.setLastTextTransform(context.getRootTransform()); } // Handle Text-Anchor declarations @@ -249,6 +252,7 @@ void performRootTransformations(PdfCanvas currentCanvas, SvgDrawContext context) } else { rootTf = new AffineTransform(TEXTFLIP); } + context.setRootTransform(rootTf); currentCanvas.setTextMatrix(rootTf); // Apply relative move if (this.containsRelativeMove()) { @@ -362,11 +366,12 @@ static AffineTransform getTextTransform(float[][] absolutePositions, SvgDrawCont AffineTransform tf = new AffineTransform(); // If x is not specified, but y is, we need to correct for preceding text. if (absolutePositions[0] == null && absolutePositions[1] != null) { - absolutePositions[0] = new float[]{context.getTextMove()[0]}; + absolutePositions[0] = + new float[]{context.getTextMove()[0] + (float)context.getLastTextTransform().getTranslateX()}; } - // If y is not present, we can replace it with a neutral transformation (0.0f) + // If y is not present, we should take the last text y if (absolutePositions[1] == null) { - absolutePositions[1] = new float[]{0.0f}; + absolutePositions[1] = new float[]{(float)context.getLastTextTransform().getTranslateY()}; } tf.concatenate(TEXTFLIP); tf.concatenate(AffineTransform.getTranslateInstance(absolutePositions[0][0], -absolutePositions[1][0])); diff --git a/svg/src/main/java/com/itextpdf/svg/renderers/path/impl/EllipticalCurveTo.java b/svg/src/main/java/com/itextpdf/svg/renderers/path/impl/EllipticalCurveTo.java index 175714c0c8..c60f4ffe7c 100644 --- a/svg/src/main/java/com/itextpdf/svg/renderers/path/impl/EllipticalCurveTo.java +++ b/svg/src/main/java/com/itextpdf/svg/renderers/path/impl/EllipticalCurveTo.java @@ -89,7 +89,7 @@ public void setCoordinates(String[] inputCoordinates, Point previous) { @Override public void draw(PdfCanvas canvas) { - Point start = new Point(startPoint.x * .75, startPoint.y * .75); // pixels to points + Point start = new Point(startPoint.getX() * .75, startPoint.getY() * .75); // pixels to points double rx = Math.abs(CssDimensionParsingUtils.parseAbsoluteLength(coordinates[0])); double ry = Math.abs(CssDimensionParsingUtils.parseAbsoluteLength(coordinates[1])); @@ -104,7 +104,7 @@ public void draw(PdfCanvas canvas) { Point end = new Point(CssDimensionParsingUtils.parseAbsoluteLength(coordinates[5]), CssDimensionParsingUtils.parseAbsoluteLength(coordinates[6])); - if (CssUtils.compareFloats(start.x, end.x) && CssUtils.compareFloats(start.y, end.y)) { + if (CssUtils.compareFloats(start.getX(), end.getX()) && CssUtils.compareFloats(start.getY(), end.getY())) { /* edge case: If the endpoints (x1, y1) and (x2, y2) are identical, * then this is equivalent to omitting the elliptical arc segment entirely. */ @@ -114,7 +114,7 @@ public void draw(PdfCanvas canvas) { /* edge case: If rx = 0 or ry = 0 then this arc is treated as a straight line segment (a "lineto") * joining the endpoints. */ - canvas.lineTo(end.x, end.y); + canvas.lineTo(end.getX(), end.getY()); } else { /* This is the first step of calculating a rotated elliptical path. We must simulate a transformation on the end-point in order to calculate appropriate EllipseArc angles; @@ -126,12 +126,12 @@ public void draw(PdfCanvas canvas) { arc = EllipseArc.getEllipse(start, end, rx, ry, sweep, largeArc); } else { AffineTransform normalizer = AffineTransform.getRotateInstance(-rotation); - normalizer.translate(-start.x, -start.y); + normalizer.translate(-start.getX(), -start.getY()); Point newArcEnd = normalizer.transform(end, null); - newArcEnd.translate(start.x, start.y); + newArcEnd.move(start.getX(), start.getY()); arc = EllipseArc.getEllipse(start, newArcEnd, rx, ry, sweep, largeArc); } - Point[][] points = makePoints(PdfCanvas.bezierArc(arc.ll.x, arc.ll.y, arc.ur.x, arc.ur.y, arc.startAng, arc.extent)); + Point[][] points = makePoints(PdfCanvas.bezierArc(arc.ll.getX(), arc.ll.getY(), arc.ur.getX(), arc.ur.getY(), arc.startAng, arc.extent)); /** This is the second step of calculating a rotated elliptical path. We must rotate all points returned by {@link PdfCanvas#bezierArc} around the starting point of the arc. An added bit of complexity is that {@link PdfCanvas#bezierArc} will force a clockwise order of the @@ -165,7 +165,7 @@ control points, whereas we need counterclockwise if sweep is false (*). static Point[][] rotate(Point[][] list, double rotation, Point rotator) { if (!CssUtils.compareFloats(rotation, 0)) { Point[][] result = new Point[list.length][]; - AffineTransform transRotTrans = AffineTransform.getRotateInstance(rotation, rotator.x, rotator.y); + AffineTransform transRotTrans = AffineTransform.getRotateInstance(rotation, rotator.getX(), rotator.getY()); for (int i = 0; i < list.length; i++) { Point[] input = list[i]; @@ -186,7 +186,7 @@ String[] getCoordinates() { } private static void drawCurve(PdfCanvas canvas, Point cp1, Point cp2, Point end) { - canvas.curveTo(cp1.x, cp1.y, cp2.x, cp2.y, end.x, end.y); + canvas.curveTo(cp1.getX(), cp1.getY(), cp2.getX(), cp2.getY(), end.getX(), end.getY()); } private Point[][] makePoints(List<double[]> input) { @@ -214,15 +214,15 @@ static class EllipseArc { final double startAng, extent; EllipseArc(Point center, final double a, final double b, final double startAng, final double extent) { - ll = new Point(center.x - a, center.y - b); - ur = new Point(center.x + a, center.y + b); + ll = new Point(center.getX() - a, center.getY() - b); + ur = new Point(center.getX() + a, center.getY() + b); this.startAng = startAng; this.extent = extent; } static EllipseArc getEllipse(Point start, Point end, double a, double b, boolean sweep, boolean largeArc) { - double r1 = (start.x - end.x) / (-2.0 * a); - double r2 = (start.y - end.y) / (2.0 * b); + double r1 = (start.getX() - end.getX()) / (-2.0 * a); + double r2 = (start.getY() - end.getY()) / (2.0 * b); double factor = Math.sqrt(r1 * r1 + r2 * r2); if (factor > 1) { @@ -257,11 +257,11 @@ static EllipseArc getEllipse(Point start, Point end, double a, double b, boolean static EllipseArc calculatePossibleMiddle(Point start, Point end, double a, double b, double startToCenterAngle, boolean sweep, boolean largeArc) { - double x0 = start.x - a * Math.cos(startToCenterAngle); - double y0 = start.y - b * Math.sin(startToCenterAngle); + double x0 = start.getX() - a * Math.cos(startToCenterAngle); + double y0 = start.getY() - b * Math.sin(startToCenterAngle); Point center = new Point(x0, y0); - double check = Math.pow(((end.x - center.x) / a), 2) + Math.pow(((end.y - center.y) / b), 2); + double check = Math.pow(((end.getX() - center.getX()) / a), 2) + Math.pow(((end.getY() - center.getY()) / b), 2); /* If center is an actual candidate for a middle point, then the value of check will be very close to 1.0. * Otherwise it is always larger than 1. @@ -329,10 +329,10 @@ static EllipseArc calculatePossibleMiddle(Point start, Point end, double a, doub } static double calculateAngle(Point pt, Point center, double a, double b) { - double result = Math.pow(((pt.x - center.x) / a), 2.0) + Math.pow(((pt.y - center.y) / b), 2.0); + double result = Math.pow(((pt.getX() - center.getX()) / a), 2.0) + Math.pow(((pt.getY() - center.getY()) / b), 2.0); - double cos = (pt.x - center.x) / a; - double sin = (pt.y - center.y) / b; + double cos = (pt.getX() - center.getX()) / a; + double sin = (pt.getY() - center.getY()) / b; // catch very small floating point errors and keep cos between [-1, 1], so we can calculate the arc cosine cos = Math.max(Math.min(cos, 1.0), -1.0); diff --git a/svg/src/main/java/com/itextpdf/svg/renderers/path/impl/LineTo.java b/svg/src/main/java/com/itextpdf/svg/renderers/path/impl/LineTo.java index 3f037e1521..ee4ddc96f6 100644 --- a/svg/src/main/java/com/itextpdf/svg/renderers/path/impl/LineTo.java +++ b/svg/src/main/java/com/itextpdf/svg/renderers/path/impl/LineTo.java @@ -59,7 +59,7 @@ public void setCoordinates(String[] inputCoordinates, Point startPoint) { } this.coordinates = new String[] {inputCoordinates[0], inputCoordinates[1]}; if (isRelative()) { - this.coordinates = copier.makeCoordinatesAbsolute(coordinates, new double[]{startPoint.x, startPoint.y}); + this.coordinates = copier.makeCoordinatesAbsolute(coordinates, new double[]{startPoint.getX(), startPoint.getY()}); } } diff --git a/svg/src/main/java/com/itextpdf/svg/renderers/path/impl/MoveTo.java b/svg/src/main/java/com/itextpdf/svg/renderers/path/impl/MoveTo.java index fa731864c1..d12257d6b7 100644 --- a/svg/src/main/java/com/itextpdf/svg/renderers/path/impl/MoveTo.java +++ b/svg/src/main/java/com/itextpdf/svg/renderers/path/impl/MoveTo.java @@ -59,7 +59,7 @@ public void setCoordinates(String[] inputCoordinates, Point startPoint) { } this.coordinates = new String[] {inputCoordinates[0], inputCoordinates[1]}; if (isRelative()) { - this.coordinates = copier.makeCoordinatesAbsolute(coordinates, new double[]{startPoint.x, startPoint.y}); + this.coordinates = copier.makeCoordinatesAbsolute(coordinates, new double[]{startPoint.getX(), startPoint.getY()}); } } } diff --git a/svg/src/main/java/com/itextpdf/svg/utils/TransformUtils.java b/svg/src/main/java/com/itextpdf/svg/utils/TransformUtils.java index 2e8afa973a..34ad7bd969 100644 --- a/svg/src/main/java/com/itextpdf/svg/utils/TransformUtils.java +++ b/svg/src/main/java/com/itextpdf/svg/utils/TransformUtils.java @@ -149,6 +149,9 @@ private static List<String> splitString(String transform) { String trim = tokenizer.nextToken().trim(); if (trim != null && !trim.isEmpty()) { + if (trim.startsWith(",")) { + trim = trim.substring(1).trim(); + } list.add(trim + ")"); } } diff --git a/svg/src/test/java/com/itextpdf/svg/converter/SvgConverterIntegrationTest.java b/svg/src/test/java/com/itextpdf/svg/converter/SvgConverterIntegrationTest.java index f575c3e4c4..193221b62d 100644 --- a/svg/src/test/java/com/itextpdf/svg/converter/SvgConverterIntegrationTest.java +++ b/svg/src/test/java/com/itextpdf/svg/converter/SvgConverterIntegrationTest.java @@ -51,7 +51,6 @@ This file is part of the iText (R) project. import com.itextpdf.test.ITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -59,13 +58,13 @@ This file is part of the iText (R) project. import java.io.OutputStream; import java.util.HashMap; import java.util.Map; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class SvgConverterIntegrationTest extends SvgIntegrationTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/svg/converter/SvgConverterTest/"; @@ -91,7 +90,7 @@ public class SvgConverterIntegrationTest extends SvgIntegrationTest { " r=\"16.928001\" />\n" + "</svg>\n"; - @BeforeClass + @BeforeAll public static void beforeClass() { ITextTest.createDestinationFolder(destinationFolder); } @@ -108,7 +107,7 @@ public void unusedXObjectIntegrationTest() throws IOException, InterruptedExcept doc1.close(); doc2.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "unusedXObjectIntegrationTest1.pdf", destinationFolder + "unusedXObjectIntegrationTest2.pdf", destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "unusedXObjectIntegrationTest1.pdf", destinationFolder + "unusedXObjectIntegrationTest2.pdf", destinationFolder, "diff_")); } @Test @@ -120,7 +119,7 @@ public void basicIntegrationTest() throws IOException, InterruptedException { PdfFormXObject form = SvgConverter.convertToXObject(ECLIPSESVGSTRING, doc); new PdfCanvas(doc.getPage(1)).addXObjectFittedIntoRectangle(form, new Rectangle(100, 100, 100, 100)); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_")); } @Test @@ -201,7 +200,7 @@ public void pdfFromSvgString() throws IOException, InterruptedException { String cmp_file = sourceFolder + "cmp_pdfFromSvgString.pdf"; pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(output, cmp_file, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(output, cmp_file, destinationFolder, "diff_")); } @Test @@ -219,7 +218,7 @@ public void fromFile() throws IOException, InterruptedException { SvgConverter.drawOnDocument(fis,pdfDoc,pagenr); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(output, cmp_file, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(output, cmp_file, destinationFolder, "diff_")); } @Test @@ -237,7 +236,7 @@ public void addToExistingDoc() throws IOException, InterruptedException { SvgConverter.drawOnDocument(fis,pdfDoc,pagenr); pdfDoc.close(); - Assert.assertNull(new CompareTool().compareByContent(output, cmp_file, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(output, cmp_file, destinationFolder, "diff_")); } @Test @@ -251,7 +250,7 @@ public void twoArgTest() throws IOException, InterruptedException { InputStream fis = FileUtil.getInputStreamForFile(sourceFolder + name + ".svg"); OutputStream fos = FileUtil.getFileOutputStream(destinationFolder + name + ".pdf"); SvgConverter.createPdf(fis, fos); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + name + ".pdf", sourceFolder + "cmp_" + name + ".pdf", destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + name + ".pdf", sourceFolder + "cmp_" + name + ".pdf", destinationFolder, "diff_")); } @Test @@ -263,7 +262,7 @@ public void drawOnSpecifiedPositionX() throws IOException, InterruptedException InputStream fis = FileUtil.getInputStreamForFile(sourceFolder + name + ".svg"); drawOnSpecifiedPositionDocument(fis, destinationFolder + destName + ".pdf", x, y); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + destName + ".pdf", sourceFolder + "cmp_" + destName + ".pdf", destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + destName + ".pdf", sourceFolder + "cmp_" + destName + ".pdf", destinationFolder, "diff_")); } @Test @@ -275,7 +274,7 @@ public void drawOnSpecifiedPositionY() throws IOException, InterruptedException InputStream fis = FileUtil.getInputStreamForFile(sourceFolder + name + ".svg"); drawOnSpecifiedPositionDocument(fis, destinationFolder + destName + ".pdf", x, y); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + destName + ".pdf", sourceFolder + "cmp_" + destName + ".pdf", destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + destName + ".pdf", sourceFolder + "cmp_" + destName + ".pdf", destinationFolder, "diff_")); } @Test @@ -287,7 +286,7 @@ public void drawOnSpecifiedPositionXY() throws IOException, InterruptedException InputStream fis = FileUtil.getInputStreamForFile(sourceFolder + name + ".svg"); drawOnSpecifiedPositionDocument(fis, destinationFolder + destName + ".pdf", x, y); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + destName + ".pdf", sourceFolder + "cmp_" + destName + ".pdf", destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + destName + ".pdf", sourceFolder + "cmp_" + destName + ".pdf", destinationFolder, "diff_")); } @@ -300,7 +299,7 @@ public void drawOnSpecifiedPositionNegativeX() throws IOException, InterruptedEx InputStream fis = FileUtil.getInputStreamForFile(sourceFolder + name + ".svg"); drawOnSpecifiedPositionDocument(fis, destinationFolder + destName + ".pdf", x, y); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + destName + ".pdf", sourceFolder + "cmp_" + destName + ".pdf", destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + destName + ".pdf", sourceFolder + "cmp_" + destName + ".pdf", destinationFolder, "diff_")); } @Test @@ -312,7 +311,7 @@ public void drawOnSpecifiedPositionNegativeY() throws IOException, InterruptedEx InputStream fis = FileUtil.getInputStreamForFile(sourceFolder + name + ".svg"); drawOnSpecifiedPositionDocument(fis, destinationFolder + destName + ".pdf", x, y); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + destName + ".pdf", sourceFolder + "cmp_" + destName + ".pdf", destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + destName + ".pdf", sourceFolder + "cmp_" + destName + ".pdf", destinationFolder, "diff_")); } @@ -325,7 +324,7 @@ public void drawOnSpecifiedPositionNegativeXY() throws IOException, InterruptedE InputStream fis = FileUtil.getInputStreamForFile(sourceFolder + name + ".svg"); drawOnSpecifiedPositionDocument(fis, destinationFolder + destName + ".pdf", x, y); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + destName + ".pdf", sourceFolder + "cmp_" + destName + ".pdf", destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + destName + ".pdf", sourceFolder + "cmp_" + destName + ".pdf", destinationFolder, "diff_")); } @@ -338,7 +337,7 @@ public void drawOnSpecifiedPositionPartialOnPage() throws IOException, Interrupt InputStream fis = FileUtil.getInputStreamForFile(sourceFolder + name + ".svg"); drawOnSpecifiedPositionDocument(fis, destinationFolder + destName + ".pdf", x, y); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + destName + ".pdf", sourceFolder + "cmp_" + destName + ".pdf", destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + destName + ".pdf", sourceFolder + "cmp_" + destName + ".pdf", destinationFolder, "diff_")); } @@ -359,7 +358,7 @@ public void convertToXObjectStringPdfDocumentConverterProps() throws IOException doc.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + destName + ".pdf", sourceFolder + "cmp_" + destName + ".pdf", destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + destName + ".pdf", sourceFolder + "cmp_" + destName + ".pdf", destinationFolder, "diff_")); } @Test @@ -379,7 +378,7 @@ public void convertToXObjectStreamPdfDocumentConverterProps() throws IOException doc.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + destName + ".pdf", sourceFolder + "cmp_" + destName + ".pdf", destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + destName + ".pdf", sourceFolder + "cmp_" + destName + ".pdf", destinationFolder, "diff_")); } @Test @@ -394,7 +393,7 @@ public void convertToImageStreamDocument() throws IOException, InterruptedExcept Document doc = new Document(pdfDocument); doc.add(image); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + destName + ".pdf", sourceFolder + "cmp_" + name + ".pdf", destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + destName + ".pdf", sourceFolder + "cmp_" + name + ".pdf", destinationFolder, "diff_")); } @Test @@ -411,7 +410,7 @@ public void convertToImageStreamDocumentConverterProperties() throws IOException Document doc = new Document(pdfDocument); doc.add(image); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + destName + ".pdf", sourceFolder + "cmp_" + name + ".pdf", destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + destName + ".pdf", sourceFolder + "cmp_" + name + ".pdf", destinationFolder, "diff_")); } @@ -427,7 +426,7 @@ public void drawOnPageStringPage() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + destName + ".pdf", sourceFolder + "cmp_" + destName + ".pdf", destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + destName + ".pdf", sourceFolder + "cmp_" + destName + ".pdf", destinationFolder, "diff_")); } @Test @@ -444,7 +443,7 @@ public void drawOnPageStringPageConverterProps() throws IOException, Interrupted doc.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + destName + ".pdf", sourceFolder + "cmp_" + destName + ".pdf", destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + destName + ".pdf", sourceFolder + "cmp_" + destName + ".pdf", destinationFolder, "diff_")); } @Test @@ -459,7 +458,7 @@ public void drawOnPageStreamPage() throws IOException, InterruptedException { doc.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + destName + ".pdf", sourceFolder + "cmp_" + destName + ".pdf", destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + destName + ".pdf", sourceFolder + "cmp_" + destName + ".pdf", destinationFolder, "diff_")); } @Test @@ -476,7 +475,7 @@ public void drawOnPageStreamPageConverterProperties() throws IOException, Interr doc.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + destName + ".pdf", sourceFolder + "cmp_" + destName + ".pdf", destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + destName + ".pdf", sourceFolder + "cmp_" + destName + ".pdf", destinationFolder, "diff_")); } @Test @@ -490,7 +489,7 @@ public void drawOnDocumentStringPdfDocumentInt() throws IOException, Interrupted doc.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + destName + ".pdf", sourceFolder + "cmp_" + destName + ".pdf", destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + destName + ".pdf", sourceFolder + "cmp_" + destName + ".pdf", destinationFolder, "diff_")); } @Test @@ -507,7 +506,7 @@ public void drawOnDocumentStringPdfDocumentIntConverterProperties() throws IOExc doc.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + destName + ".pdf", sourceFolder + "cmp_" + destName + ".pdf", destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + destName + ".pdf", sourceFolder + "cmp_" + destName + ".pdf", destinationFolder, "diff_")); } @Test @@ -523,7 +522,7 @@ public void drawOnDocumentStreamPdfDocumentIntConverterProperties() throws IOExc doc.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + destName + ".pdf", sourceFolder + "cmp_" + destName + ".pdf", destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + destName + ".pdf", sourceFolder + "cmp_" + destName + ".pdf", destinationFolder, "diff_")); } @Test @@ -537,7 +536,7 @@ public void drawOnCanvasStringPdfCanvasConverter() throws IOException, Interrupt doc.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + destName + ".pdf", sourceFolder + "cmp_" + destName + ".pdf", destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + destName + ".pdf", sourceFolder + "cmp_" + destName + ".pdf", destinationFolder, "diff_")); } @@ -554,7 +553,7 @@ public void drawOnCanvasStringPdfCanvasConverterProps() throws IOException, Inte doc.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + destName + ".pdf", sourceFolder + "cmp_" + destName + ".pdf", destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + destName + ".pdf", sourceFolder + "cmp_" + destName + ".pdf", destinationFolder, "diff_")); } @Test @@ -569,7 +568,7 @@ public void drawOnCanvasStreamPdfCanvas() throws IOException, InterruptedExcepti doc.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + destName + ".pdf", sourceFolder + "cmp_" + destName + ".pdf", destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + destName + ".pdf", sourceFolder + "cmp_" + destName + ".pdf", destinationFolder, "diff_")); } @Test @@ -586,7 +585,7 @@ public void drawOnCanvasStreamPdfCanvasConverterProps() throws IOException, Inte doc.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + destName + ".pdf", sourceFolder + "cmp_" + destName + ".pdf", destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + destName + ".pdf", sourceFolder + "cmp_" + destName + ".pdf", destinationFolder, "diff_")); } private static void drawOnSpecifiedPositionDocument(InputStream svg, String dest, int x, int y) throws IOException { @@ -619,7 +618,7 @@ public void parseAndProcessSuccessTest() throws IOException { ISvgProcessorResult actual = SvgConverter.parseAndProcess(fis); - Assert.assertEquals(expected.getRootRenderer().getAttributeMapCopy(), actual.getRootRenderer().getAttributeMapCopy()); + Assertions.assertEquals(expected.getRootRenderer().getAttributeMapCopy(), actual.getRootRenderer().getAttributeMapCopy()); } } @@ -627,7 +626,7 @@ public void parseAndProcessSuccessTest() throws IOException { public void parseAndProcessIOExceptionTest() { InputStream fis = new ExceptionInputStream(); - Assert.assertThrows(SvgProcessingException.class, () -> SvgConverter.parseAndProcess(fis)); + Assertions.assertThrows(SvgProcessingException.class, () -> SvgConverter.parseAndProcess(fis)); } @Test diff --git a/svg/src/test/java/com/itextpdf/svg/converter/SvgConverterUnitNullTest.java b/svg/src/test/java/com/itextpdf/svg/converter/SvgConverterUnitNullTest.java index ae1d18906b..601c3e12a1 100644 --- a/svg/src/test/java/com/itextpdf/svg/converter/SvgConverterUnitNullTest.java +++ b/svg/src/test/java/com/itextpdf/svg/converter/SvgConverterUnitNullTest.java @@ -34,18 +34,16 @@ This file is part of the iText (R) project. import com.itextpdf.svg.processors.ISvgConverterProperties; import com.itextpdf.svg.renderers.ISvgNodeRenderer; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.nio.charset.StandardCharsets; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * These tests will make sure that a NullPointerException is never thrown: if a @@ -55,7 +53,7 @@ This file is part of the iText (R) project. * If the (optional) {@link ISvgConverterProperties} parameter is null, this * should NOT throw an exception as this is caught in the library. */ -@Category(UnitTest.class) +@org.junit.jupiter.api.Tag("UnitTest") public class SvgConverterUnitNullTest extends ExtendedITextTest { // we cannot easily mock the PdfDocument, so we make do with as close to unit testing as we can @@ -63,43 +61,43 @@ public class SvgConverterUnitNullTest extends ExtendedITextTest { private final String content = "<svg width=\"10\" height=\"10\"/>"; private InputStream is; - @Before + @BeforeEach public void setup() { doc = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); doc.addNewPage(); is = new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8)); } - @After + @AfterEach public void teardown() { doc.close(); } @Test public void drawOnDocumentStringNullTest() { - Assert.assertThrows(SvgProcessingException.class, () -> SvgConverter.drawOnDocument((String) null, doc, 1)); + Assertions.assertThrows(SvgProcessingException.class, () -> SvgConverter.drawOnDocument((String) null, doc, 1)); } @Test public void drawOnDocumentInputStreamNullTest() throws IOException { - Assert.assertThrows(SvgProcessingException.class, + Assertions.assertThrows(SvgProcessingException.class, () -> SvgConverter.drawOnDocument((InputStream) null, doc, 1) ); } @Test public void drawOnDocumentDocNullTest() throws IOException { - Assert.assertThrows(SvgProcessingException.class, () -> SvgConverter.drawOnDocument(is, null, 1)); + Assertions.assertThrows(SvgProcessingException.class, () -> SvgConverter.drawOnDocument(is, null, 1)); } @Test public void drawOnDocumentAllNullTest() { - Assert.assertThrows(SvgProcessingException.class, () -> SvgConverter.drawOnDocument((String) null, null, 1)); + Assertions.assertThrows(SvgProcessingException.class, () -> SvgConverter.drawOnDocument((String) null, null, 1)); } @Test public void drawOnDocumentAllNullTest2() throws IOException { - Assert.assertThrows(SvgProcessingException.class, + Assertions.assertThrows(SvgProcessingException.class, () -> SvgConverter.drawOnDocument((InputStream) null, null, 1) ); } @@ -117,28 +115,28 @@ public void drawOnDocumentInputStreamPropsNullTest() throws IOException { @Test public void drawOnPageStringNullTest() { PdfPage page = doc.getFirstPage(); - Assert.assertThrows(SvgProcessingException.class, () -> SvgConverter.drawOnPage((String) null, page)); + Assertions.assertThrows(SvgProcessingException.class, () -> SvgConverter.drawOnPage((String) null, page)); } @Test public void drawOnPageInputStreamNullTest() throws IOException { PdfPage page = doc.getFirstPage(); - Assert.assertThrows(SvgProcessingException.class, () -> SvgConverter.drawOnPage((InputStream) null, page)); + Assertions.assertThrows(SvgProcessingException.class, () -> SvgConverter.drawOnPage((InputStream) null, page)); } @Test public void drawOnPageDocNullTest() throws IOException { - Assert.assertThrows(SvgProcessingException.class, () -> SvgConverter.drawOnPage(is, null)); + Assertions.assertThrows(SvgProcessingException.class, () -> SvgConverter.drawOnPage(is, null)); } @Test public void drawOnPageAllNullTest() { - Assert.assertThrows(SvgProcessingException.class, () -> SvgConverter.drawOnPage((String) null, null)); + Assertions.assertThrows(SvgProcessingException.class, () -> SvgConverter.drawOnPage((String) null, null)); } @Test public void drawOnPageAllNullTest2() throws IOException { - Assert.assertThrows(SvgProcessingException.class, () -> SvgConverter.drawOnPage((InputStream) null, null)); + Assertions.assertThrows(SvgProcessingException.class, () -> SvgConverter.drawOnPage((InputStream) null, null)); } @Test @@ -156,28 +154,28 @@ public void drawOnPageInputStreamPropsNullTest() throws IOException { @Test public void drawOnCanvasStringNullTest() { PdfCanvas canvas = new PdfCanvas(doc.getLastPage()); - Assert.assertThrows(SvgProcessingException.class, () -> SvgConverter.drawOnDocument((String) null, doc, 1)); + Assertions.assertThrows(SvgProcessingException.class, () -> SvgConverter.drawOnDocument((String) null, doc, 1)); } @Test public void drawOnCanvasInputStreamNullTest() throws IOException { PdfCanvas canvas = new PdfCanvas(doc.getLastPage()); - Assert.assertThrows(SvgProcessingException.class, () -> SvgConverter.drawOnCanvas((InputStream) null, canvas)); + Assertions.assertThrows(SvgProcessingException.class, () -> SvgConverter.drawOnCanvas((InputStream) null, canvas)); } @Test public void drawOnCanvasDocNullTest() throws IOException { - Assert.assertThrows(SvgProcessingException.class, () -> SvgConverter.drawOnCanvas(is, null)); + Assertions.assertThrows(SvgProcessingException.class, () -> SvgConverter.drawOnCanvas(is, null)); } @Test public void drawOnCanvasAllNullTest() { - Assert.assertThrows(SvgProcessingException.class, () -> SvgConverter.drawOnCanvas((String) null, null)); + Assertions.assertThrows(SvgProcessingException.class, () -> SvgConverter.drawOnCanvas((String) null, null)); } @Test public void drawOnCanvasAllNullTest2() throws IOException { - Assert.assertThrows(SvgProcessingException.class, () -> SvgConverter.drawOnCanvas((InputStream) null, null)); + Assertions.assertThrows(SvgProcessingException.class, () -> SvgConverter.drawOnCanvas((InputStream) null, null)); } @Test @@ -194,48 +192,48 @@ public void drawOnCanvasInputStreamPropsNullTest() throws IOException { @Test public void convertToXObjectStringNullTest() { - Assert.assertThrows(SvgProcessingException.class, () -> SvgConverter.convertToXObject((String) null, doc)); + Assertions.assertThrows(SvgProcessingException.class, () -> SvgConverter.convertToXObject((String) null, doc)); } @Test public void convertToXObjectInputStreamNullTest() throws IOException { - Assert.assertThrows(SvgProcessingException.class, () -> SvgConverter.convertToXObject((InputStream) null, doc)); + Assertions.assertThrows(SvgProcessingException.class, () -> SvgConverter.convertToXObject((InputStream) null, doc)); } @Test public void convertToXObjectRendererNullTest() { - Assert.assertThrows(SvgProcessingException.class, () -> SvgConverter.convertToXObject((ISvgNodeRenderer) null, doc)); + Assertions.assertThrows(SvgProcessingException.class, () -> SvgConverter.convertToXObject((ISvgNodeRenderer) null, doc)); } @Test public void convertToXObjectDocWithStringNullTest() throws IOException { - Assert.assertThrows(SvgProcessingException.class, () -> SvgConverter.convertToXObject(is, null)); + Assertions.assertThrows(SvgProcessingException.class, () -> SvgConverter.convertToXObject(is, null)); } @Test public void convertToXObjectDocWithStreamNullTest() throws IOException { - Assert.assertThrows(SvgProcessingException.class, () -> SvgConverter.convertToXObject(is, null)); + Assertions.assertThrows(SvgProcessingException.class, () -> SvgConverter.convertToXObject(is, null)); } @Test public void convertToXObjectDocWithRendererNullTest() throws IOException { ISvgNodeRenderer renderer = SvgConverter.process(SvgConverter.parse(is), null).getRootRenderer(); - Assert.assertThrows(SvgProcessingException.class, () -> SvgConverter.convertToXObject(renderer, null)); + Assertions.assertThrows(SvgProcessingException.class, () -> SvgConverter.convertToXObject(renderer, null)); } @Test public void convertToXObjectAllWithStringNullTest() { - Assert.assertThrows(SvgProcessingException.class, () -> SvgConverter.convertToXObject((String) null, null)); + Assertions.assertThrows(SvgProcessingException.class, () -> SvgConverter.convertToXObject((String) null, null)); } @Test public void convertToXObjectAllWithStreamNullTest() throws IOException { - Assert.assertThrows(SvgProcessingException.class, () -> SvgConverter.convertToXObject((InputStream) null, null)); + Assertions.assertThrows(SvgProcessingException.class, () -> SvgConverter.convertToXObject((InputStream) null, null)); } @Test public void convertToXObjectAllWithRendererNullTest() { - Assert.assertThrows(SvgProcessingException.class, () -> SvgConverter.convertToXObject((ISvgNodeRenderer) null, null)); + Assertions.assertThrows(SvgProcessingException.class, () -> SvgConverter.convertToXObject((ISvgNodeRenderer) null, null)); } @Test @@ -250,12 +248,12 @@ public void convertToXObjectInputStreamPropsNullTest() throws IOException { @Test public void parseStringNullTest() { - Assert.assertThrows(SvgProcessingException.class, () -> SvgConverter.parse((String) null)); + Assertions.assertThrows(SvgProcessingException.class, () -> SvgConverter.parse((String) null)); } @Test public void parseStreamNullTest() throws IOException { - Assert.assertThrows(SvgProcessingException.class, () -> SvgConverter.parse((InputStream) null)); + Assertions.assertThrows(SvgProcessingException.class, () -> SvgConverter.parse((InputStream) null)); } @Test @@ -265,12 +263,12 @@ public void parseStreamPropsNullTest() throws IOException { @Test public void parseStringPropsNullTest() throws IOException { - Assert.assertThrows(SvgProcessingException.class, () -> SvgConverter.parse(null, null)); + Assertions.assertThrows(SvgProcessingException.class, () -> SvgConverter.parse(null, null)); } @Test public void processAllNullTest() { - Assert.assertThrows(SvgProcessingException.class, () -> SvgConverter.process(null, null)); + Assertions.assertThrows(SvgProcessingException.class, () -> SvgConverter.process(null, null)); } @Test diff --git a/svg/src/test/java/com/itextpdf/svg/converter/SvgConverterUnitTest.java b/svg/src/test/java/com/itextpdf/svg/converter/SvgConverterUnitTest.java index d3cb0ae489..f67fc9fb71 100644 --- a/svg/src/test/java/com/itextpdf/svg/converter/SvgConverterUnitTest.java +++ b/svg/src/test/java/com/itextpdf/svg/converter/SvgConverterUnitTest.java @@ -53,7 +53,6 @@ This file is part of the iText (R) project. import com.itextpdf.svg.renderers.ISvgNodeRenderer; import com.itextpdf.svg.renderers.impl.SvgTagSvgNodeRenderer; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -63,13 +62,12 @@ This file is part of the iText (R) project. import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -@Category(UnitTest.class) +@org.junit.jupiter.api.Tag("UnitTest") public class SvgConverterUnitTest extends ExtendedITextTest { // we cannot easily mock the PdfDocument, so we make do with as close to unit testing as we can @@ -77,24 +75,24 @@ public class SvgConverterUnitTest extends ExtendedITextTest { private final String content = "<svg width=\"10\" height=\"10\"/>"; private InputStream is; - @Before + @BeforeEach public void setup() { doc = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); doc.addNewPage(); is = new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8)); } - @After + @AfterEach public void teardown() { doc.close(); } private void testResourceCreated(PdfDocument doc, int pageNo) { PdfResources res = doc.getPage(pageNo).getResources(); - Assert.assertEquals(1, res.getPdfObject().size()); + Assertions.assertEquals(1, res.getPdfObject().size()); for (PdfName name : res.getResourceNames()) { PdfObject obj = res.getResourceObject(PdfName.XObject, name); - Assert.assertTrue(obj.isStream()); + Assertions.assertTrue(obj.isStream()); } } @@ -126,7 +124,7 @@ public void drawStreamOnDocumentWithPropsCreatesResourceTest() throws IOExceptio public void drawStringOnPageCreatesResourceTest() { PdfPage page = doc.addNewPage(); SvgConverter.drawOnPage(content, page); - Assert.assertEquals(0, doc.getFirstPage().getResources().getPdfObject().size()); + Assertions.assertEquals(0, doc.getFirstPage().getResources().getPdfObject().size()); testResourceCreated(doc, 2); } @@ -134,7 +132,7 @@ public void drawStringOnPageCreatesResourceTest() { public void drawStringOnPageWithPropsCreatesResourceTest() { PdfPage page = doc.addNewPage(); SvgConverter.drawOnPage(content, page, new DummySvgConverterProperties()); - Assert.assertEquals(0, doc.getFirstPage().getResources().getPdfObject().size()); + Assertions.assertEquals(0, doc.getFirstPage().getResources().getPdfObject().size()); testResourceCreated(doc, 2); } @@ -142,7 +140,7 @@ public void drawStringOnPageWithPropsCreatesResourceTest() { public void drawStreamOnPageCreatesResourceTest() throws IOException { PdfPage page = doc.addNewPage(); SvgConverter.drawOnPage(is, page); - Assert.assertEquals(0, doc.getFirstPage().getResources().getPdfObject().size()); + Assertions.assertEquals(0, doc.getFirstPage().getResources().getPdfObject().size()); testResourceCreated(doc, 2); } @@ -150,7 +148,7 @@ public void drawStreamOnPageCreatesResourceTest() throws IOException { public void drawStreamOnPageWithPropsCreatesResourceTest() throws IOException { PdfPage page = doc.addNewPage(); SvgConverter.drawOnPage(is, page, new DummySvgConverterProperties()); - Assert.assertEquals(0, doc.getFirstPage().getResources().getPdfObject().size()); + Assertions.assertEquals(0, doc.getFirstPage().getResources().getPdfObject().size()); testResourceCreated(doc, 2); } @@ -159,7 +157,7 @@ public void drawStringOnCanvasCreatesResourceTest() { PdfPage page = doc.addNewPage(); PdfCanvas canvas = new PdfCanvas(page); SvgConverter.drawOnCanvas(content, canvas); - Assert.assertEquals(0, doc.getFirstPage().getResources().getPdfObject().size()); + Assertions.assertEquals(0, doc.getFirstPage().getResources().getPdfObject().size()); testResourceCreated(doc, 2); } @@ -168,7 +166,7 @@ public void drawStringOnCanvasWithPropsCreatesResourceTest() { PdfPage page = doc.addNewPage(); PdfCanvas canvas = new PdfCanvas(page); SvgConverter.drawOnCanvas(content, canvas, new DummySvgConverterProperties()); - Assert.assertEquals(0, doc.getFirstPage().getResources().getPdfObject().size()); + Assertions.assertEquals(0, doc.getFirstPage().getResources().getPdfObject().size()); testResourceCreated(doc, 2); } @@ -177,7 +175,7 @@ public void drawStreamOnCanvasCreatesResourceTest() throws IOException { PdfPage page = doc.addNewPage(); PdfCanvas canvas = new PdfCanvas(page); SvgConverter.drawOnCanvas(is, canvas); - Assert.assertEquals(0, doc.getFirstPage().getResources().getPdfObject().size()); + Assertions.assertEquals(0, doc.getFirstPage().getResources().getPdfObject().size()); testResourceCreated(doc, 2); } @@ -186,32 +184,32 @@ public void drawStreamOnCanvasWithPropsCreatesResourceTest() throws IOException PdfPage page = doc.addNewPage(); PdfCanvas canvas = new PdfCanvas(page); SvgConverter.drawOnCanvas(is, canvas, new DummySvgConverterProperties()); - Assert.assertEquals(0, doc.getFirstPage().getResources().getPdfObject().size()); + Assertions.assertEquals(0, doc.getFirstPage().getResources().getPdfObject().size()); testResourceCreated(doc, 2); } @Test public void convertStringToXObjectCreatesNoResourceTest() { SvgConverter.convertToXObject(content, doc); - Assert.assertEquals(0, doc.getLastPage().getResources().getPdfObject().size()); + Assertions.assertEquals(0, doc.getLastPage().getResources().getPdfObject().size()); } @Test public void convertStringToXObjectWithPropsCreatesNoResourceTest() { SvgConverter.convertToXObject(content, doc, new DummySvgConverterProperties()); - Assert.assertEquals(0, doc.getLastPage().getResources().getPdfObject().size()); + Assertions.assertEquals(0, doc.getLastPage().getResources().getPdfObject().size()); } @Test public void convertStreamToXObjectCreatesNoResourceTest() throws IOException { SvgConverter.convertToXObject(is, doc); - Assert.assertEquals(0, doc.getLastPage().getResources().getPdfObject().size()); + Assertions.assertEquals(0, doc.getLastPage().getResources().getPdfObject().size()); } @Test public void convertStreamToXObjectWithPropsCreatesNoResourceTest() throws IOException { SvgConverter.convertToXObject(is, doc, new DummySvgConverterProperties()); - Assert.assertEquals(0, doc.getLastPage().getResources().getPdfObject().size()); + Assertions.assertEquals(0, doc.getLastPage().getResources().getPdfObject().size()); } @Test @@ -219,48 +217,48 @@ public void processNodeWithCustomFactory() { INode svg = new JsoupElementNode(new Element(Tag.valueOf("svg"), "")); DummySvgConverterProperties props = new DummySvgConverterProperties(); IBranchSvgNodeRenderer node = (IBranchSvgNodeRenderer) SvgConverter.process(svg, props).getRootRenderer(); - Assert.assertTrue(node instanceof DummySvgNodeRenderer); - Assert.assertEquals(0, node.getChildren().size()); - Assert.assertNull(node.getParent()); + Assertions.assertTrue(node instanceof DummySvgNodeRenderer); + Assertions.assertEquals(0, node.getChildren().size()); + Assertions.assertNull(node.getParent()); } @Test public void processNode() { INode svg = new JsoupElementNode(new Element(Tag.valueOf("svg"), "")); IBranchSvgNodeRenderer node = (IBranchSvgNodeRenderer) SvgConverter.process(svg, null).getRootRenderer(); - Assert.assertTrue(node instanceof SvgTagSvgNodeRenderer); - Assert.assertEquals(0, node.getChildren().size()); - Assert.assertNull(node.getParent()); + Assertions.assertTrue(node instanceof SvgTagSvgNodeRenderer); + Assertions.assertEquals(0, node.getChildren().size()); + Assertions.assertNull(node.getParent()); } @Test public void parseString() { INode actual = SvgConverter.parse(content); - Assert.assertEquals(1, actual.childNodes().size()); + Assertions.assertEquals(1, actual.childNodes().size()); JsoupElementNode node = (JsoupElementNode) actual.childNodes().get(0); - Assert.assertEquals("svg", node.name()); - Assert.assertEquals(0, node.childNodes().size()); + Assertions.assertEquals("svg", node.name()); + Assertions.assertEquals(0, node.childNodes().size()); } @Test public void parseStream() throws IOException { INode actual = SvgConverter.parse(is); - Assert.assertEquals(1, actual.childNodes().size()); + Assertions.assertEquals(1, actual.childNodes().size()); JsoupElementNode node = (JsoupElementNode) actual.childNodes().get(0); - Assert.assertEquals("svg", node.name()); - Assert.assertEquals(0, node.childNodes().size()); + Assertions.assertEquals("svg", node.name()); + Assertions.assertEquals(0, node.childNodes().size()); } @Test public void parseStreamWithProps() throws IOException { INode actual = SvgConverter.parse(is, new DummySvgConverterProperties()); - Assert.assertEquals(1, actual.childNodes().size()); + Assertions.assertEquals(1, actual.childNodes().size()); JsoupElementNode node = (JsoupElementNode) actual.childNodes().get(0); - Assert.assertEquals("svg", node.name()); - Assert.assertEquals(0, node.childNodes().size()); + Assertions.assertEquals("svg", node.name()); + Assertions.assertEquals(0, node.childNodes().size()); } @Test @@ -268,9 +266,9 @@ public void parseStreamErrorEncodingTooBig() throws IOException { is = new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_16LE)); INode actual = SvgConverter.parse(is, new DummySvgConverterProperties()); // defaults to UTF-8 - Assert.assertEquals(1, actual.childNodes().size()); + Assertions.assertEquals(1, actual.childNodes().size()); // Does not throw an exception, but produces gibberish output that gets fed into a Text element, which is not a JsoupElementNode - Assert.assertFalse(actual.childNodes().get(0) instanceof JsoupElementNode); + Assertions.assertFalse(actual.childNodes().get(0) instanceof JsoupElementNode); } private static class OtherCharsetDummySvgConverterProperties extends DummySvgConverterProperties { @@ -286,27 +284,27 @@ public void parseStreamWithOtherEncoding() throws IOException { is = new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_16LE)); INode actual = SvgConverter.parse(is, new OtherCharsetDummySvgConverterProperties()); - Assert.assertEquals(1, actual.childNodes().size()); + Assertions.assertEquals(1, actual.childNodes().size()); JsoupElementNode node = (JsoupElementNode) actual.childNodes().get(0); - Assert.assertEquals("svg", node.name()); - Assert.assertEquals(0, node.childNodes().size()); + Assertions.assertEquals("svg", node.name()); + Assertions.assertEquals(0, node.childNodes().size()); } @Test public void parseStreamErrorOtherCharset() throws IOException { INode actual = SvgConverter.parse(is, new OtherCharsetDummySvgConverterProperties()); - Assert.assertEquals(1, actual.childNodes().size()); + Assertions.assertEquals(1, actual.childNodes().size()); // Does not throw an exception, but produces gibberish output that gets fed into a Text element, which is not a JsoupElementNode - Assert.assertFalse(actual.childNodes().get(0) instanceof JsoupElementNode); + Assertions.assertFalse(actual.childNodes().get(0) instanceof JsoupElementNode); } @Test public void checkNullTest(){ - Exception e = Assert.assertThrows(SvgProcessingException.class, + Exception e = Assertions.assertThrows(SvgProcessingException.class, () -> SvgConverter.drawOnDocument("test",null,1) ); - Assert.assertEquals(SvgExceptionMessageConstant.PARAMETER_CANNOT_BE_NULL, e.getMessage()); + Assertions.assertEquals(SvgExceptionMessageConstant.PARAMETER_CANNOT_BE_NULL, e.getMessage()); } @Test @@ -318,13 +316,13 @@ public void resourceResolverInstanceTest() { new SvgTagSvgNodeRenderer(), context); ResourceResolver currentResolver = SvgConverter.getResourceResolver(svgProcessorResult, properties); - Assert.assertEquals(initialResolver, currentResolver); + Assertions.assertEquals(initialResolver, currentResolver); } @Test public void createResourceResolverWithoutProcessorResultTest() { ISvgConverterProperties props = new SvgConverterProperties(); - Assert.assertNotNull(SvgConverter.getResourceResolver(null, props)); + Assertions.assertNotNull(SvgConverter.getResourceResolver(null, props)); } @Test @@ -333,7 +331,7 @@ public void resourceResolverInstanceCustomResolverTest() { TestSvgProcessorResult testSvgProcessorResult = new TestSvgProcessorResult(); ResourceResolver currentResolver = SvgConverter.getResourceResolver(testSvgProcessorResult, properties); - Assert.assertNotNull(currentResolver); + Assertions.assertNotNull(currentResolver); } @Test @@ -341,12 +339,12 @@ public void resourceResolverInstanceCustomResolverNullPropsTest() { TestSvgProcessorResult testSvgProcessorResult = new TestSvgProcessorResult(); ResourceResolver currentResolver = SvgConverter.getResourceResolver(testSvgProcessorResult, null); - Assert.assertNotNull(currentResolver); + Assertions.assertNotNull(currentResolver); } @Test public void nullBBoxInDrawTest() throws Exception { - Assert.assertThrows(PdfException.class, () -> { + Assertions.assertThrows(PdfException.class, () -> { PdfFormXObject object = SvgConverter.convertToXObject(content, doc); ((PdfDictionary)object.getPdfObject()).remove(PdfName.BBox); SvgConverter.draw(object, new PdfCanvas(doc, 1), 0, 0); diff --git a/svg/src/test/java/com/itextpdf/svg/css/AttributesRelativeUnitTest.java b/svg/src/test/java/com/itextpdf/svg/css/AttributesRelativeUnitTest.java index 15dc00f9f2..1cb8ccd00c 100644 --- a/svg/src/test/java/com/itextpdf/svg/css/AttributesRelativeUnitTest.java +++ b/svg/src/test/java/com/itextpdf/svg/css/AttributesRelativeUnitTest.java @@ -29,14 +29,14 @@ This file is part of the iText (R) project. import com.itextpdf.test.annotations.LogMessages; import java.io.IOException; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; public class AttributesRelativeUnitTest extends SvgIntegrationTest { public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/svg/css/AttributesRelativeUnitTest/"; public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/svg/css/AttributesRelativeUnitTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { ITextTest.createDestinationFolder(DESTINATION_FOLDER); } diff --git a/svg/src/test/java/com/itextpdf/svg/css/DefaultStyleInheritanceIntegrationTest.java b/svg/src/test/java/com/itextpdf/svg/css/DefaultStyleInheritanceIntegrationTest.java index 54dd4a694f..6bce880831 100644 --- a/svg/src/test/java/com/itextpdf/svg/css/DefaultStyleInheritanceIntegrationTest.java +++ b/svg/src/test/java/com/itextpdf/svg/css/DefaultStyleInheritanceIntegrationTest.java @@ -24,20 +24,19 @@ This file is part of the iText (R) project. import com.itextpdf.svg.renderers.SvgIntegrationTest; import com.itextpdf.test.ITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class DefaultStyleInheritanceIntegrationTest extends SvgIntegrationTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/svg/css/DefaultInheritance/"; public static final String destinationFolder = "./target/test/com/itextpdf/svg/css/DefaultInheritance/"; - @BeforeClass + @BeforeAll public static void beforeClass() { ITextTest.createDestinationFolder(destinationFolder); } diff --git a/svg/src/test/java/com/itextpdf/svg/css/DefaultStylesTest.java b/svg/src/test/java/com/itextpdf/svg/css/DefaultStylesTest.java index 5da0e249ba..240d5c3849 100644 --- a/svg/src/test/java/com/itextpdf/svg/css/DefaultStylesTest.java +++ b/svg/src/test/java/com/itextpdf/svg/css/DefaultStylesTest.java @@ -34,17 +34,15 @@ This file is part of the iText (R) project. import com.itextpdf.svg.processors.impl.SvgConverterProperties; import com.itextpdf.svg.processors.impl.SvgProcessorContext; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.ByteArrayInputStream; import java.io.IOException; import java.util.Map; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; -@Category(UnitTest.class) +@org.junit.jupiter.api.Tag("UnitTest") public class DefaultStylesTest extends ExtendedITextTest { @Test @@ -54,13 +52,13 @@ public void checkDefaultStrokeValuesTest() { INode svgNode = new JsoupElementNode(svg); Map<String, String> resolvedStyles = styleResolver.resolveStyles(svgNode, new SvgCssContext()); - Assert.assertEquals("1", resolvedStyles.get(SvgConstants.Attributes.STROKE_OPACITY)); - Assert.assertEquals("1px", resolvedStyles.get(SvgConstants.Attributes.STROKE_WIDTH)); - Assert.assertEquals(SvgConstants.Values.NONE, resolvedStyles.get(SvgConstants.Attributes.STROKE)); - Assert.assertEquals(SvgConstants.Values.BUTT, resolvedStyles.get(SvgConstants.Attributes.STROKE_LINECAP)); - Assert.assertEquals("0", resolvedStyles.get(SvgConstants.Attributes.STROKE_DASHOFFSET)); - Assert.assertEquals(SvgConstants.Values.NONE, resolvedStyles.get(SvgConstants.Attributes.STROKE_DASHARRAY)); - Assert.assertEquals("4", resolvedStyles.get(SvgConstants.Attributes.STROKE_MITERLIMIT)); + Assertions.assertEquals("1", resolvedStyles.get(SvgConstants.Attributes.STROKE_OPACITY)); + Assertions.assertEquals("1px", resolvedStyles.get(SvgConstants.Attributes.STROKE_WIDTH)); + Assertions.assertEquals(SvgConstants.Values.NONE, resolvedStyles.get(SvgConstants.Attributes.STROKE)); + Assertions.assertEquals(SvgConstants.Values.BUTT, resolvedStyles.get(SvgConstants.Attributes.STROKE_LINECAP)); + Assertions.assertEquals("0", resolvedStyles.get(SvgConstants.Attributes.STROKE_DASHOFFSET)); + Assertions.assertEquals(SvgConstants.Values.NONE, resolvedStyles.get(SvgConstants.Attributes.STROKE_DASHARRAY)); + Assertions.assertEquals("4", resolvedStyles.get(SvgConstants.Attributes.STROKE_MITERLIMIT)); } @Test @@ -70,9 +68,9 @@ public void checkDefaultFillValuesTest() { INode svgNode = new JsoupElementNode(svg); Map<String, String> resolvedStyles = styleResolver.resolveStyles(svgNode, new SvgCssContext()); - Assert.assertEquals("black", resolvedStyles.get(SvgConstants.Attributes.FILL)); - Assert.assertEquals(SvgConstants.Values.FILL_RULE_NONZERO, resolvedStyles.get(SvgConstants.Attributes.FILL_RULE)); - Assert.assertEquals("1", resolvedStyles.get(SvgConstants.Attributes.FILL_OPACITY)); + Assertions.assertEquals("black", resolvedStyles.get(SvgConstants.Attributes.FILL)); + Assertions.assertEquals(SvgConstants.Values.FILL_RULE_NONZERO, resolvedStyles.get(SvgConstants.Attributes.FILL_RULE)); + Assertions.assertEquals("1", resolvedStyles.get(SvgConstants.Attributes.FILL_OPACITY)); } @Test @@ -82,8 +80,8 @@ public void checkDefaultFontValuesTest() { INode svgNode = new JsoupElementNode(svg); Map<String, String> resolvedStyles = styleResolver.resolveStyles(svgNode, new SvgCssContext()); - Assert.assertEquals("helvetica", resolvedStyles.get(SvgConstants.Attributes.FONT_FAMILY)); - Assert.assertEquals("9pt", resolvedStyles.get(SvgConstants.Attributes.FONT_SIZE)); + Assertions.assertEquals("helvetica", resolvedStyles.get(SvgConstants.Attributes.FONT_FAMILY)); + Assertions.assertEquals("9pt", resolvedStyles.get(SvgConstants.Attributes.FONT_SIZE)); } @Test @@ -94,13 +92,13 @@ public void emptyStreamTest() throws IOException { INode svgNode = new JsoupElementNode(svg); Map<String, String> resolvedStyles = styleResolver.resolveStyles(svgNode, new SvgCssContext()); - Assert.assertEquals(1, resolvedStyles.size()); - Assert.assertEquals("12pt", resolvedStyles.get(Attributes.FONT_SIZE)); + Assertions.assertEquals(1, resolvedStyles.size()); + Assertions.assertEquals("12pt", resolvedStyles.get(Attributes.FONT_SIZE)); } @Test public void emptyStylesFallbackTest() throws IOException { - Assert.assertThrows(IOException.class, () -> new SvgStyleResolver(new ExceptionInputStream(), + Assertions.assertThrows(IOException.class, () -> new SvgStyleResolver(new ExceptionInputStream(), new SvgProcessorContext(new SvgConverterProperties()))); } } diff --git a/svg/src/test/java/com/itextpdf/svg/css/FontRelativeUnitTest.java b/svg/src/test/java/com/itextpdf/svg/css/FontRelativeUnitTest.java index eab8efcb6f..3b868f1746 100644 --- a/svg/src/test/java/com/itextpdf/svg/css/FontRelativeUnitTest.java +++ b/svg/src/test/java/com/itextpdf/svg/css/FontRelativeUnitTest.java @@ -27,20 +27,19 @@ This file is part of the iText (R) project. import com.itextpdf.test.ITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class FontRelativeUnitTest extends SvgIntegrationTest { public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/svg/css/FontRelativeUnitTest/"; public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/svg/css/FontRelativeUnitTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { ITextTest.createDestinationFolder(DESTINATION_FOLDER); } diff --git a/svg/src/test/java/com/itextpdf/svg/css/SvgStrokeParameterConverterUnitTest.java b/svg/src/test/java/com/itextpdf/svg/css/SvgStrokeParameterConverterUnitTest.java index bf8ac31c8e..b9f54d7582 100644 --- a/svg/src/test/java/com/itextpdf/svg/css/SvgStrokeParameterConverterUnitTest.java +++ b/svg/src/test/java/com/itextpdf/svg/css/SvgStrokeParameterConverterUnitTest.java @@ -26,69 +26,68 @@ This file is part of the iText (R) project. import com.itextpdf.svg.css.SvgStrokeParameterConverter.PdfLineDashParameters; import com.itextpdf.svg.renderers.SvgDrawContext; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class SvgStrokeParameterConverterUnitTest extends ExtendedITextTest { @Test public void testStrokeDashArrayPercents() { PdfLineDashParameters result = SvgStrokeParameterConverter.convertStrokeDashParameters("10pt,3%", null, 12f, createTextSvgContext()); - Assert.assertEquals(new PdfLineDashParameters(new float[]{10, 30}, 0), result); + Assertions.assertEquals(new PdfLineDashParameters(new float[]{10, 30}, 0), result); } @Test public void testStrokeDashArrayOddNumberOfValues() { PdfLineDashParameters result = SvgStrokeParameterConverter.convertStrokeDashParameters("5pt", null, 12f, createTextSvgContext()); - Assert.assertEquals(new PdfLineDashParameters(new float[]{5, 5}, 0), result); + Assertions.assertEquals(new PdfLineDashParameters(new float[]{5, 5}, 0), result); } @Test public void testEmptyStrokeDashArray() { PdfLineDashParameters result = SvgStrokeParameterConverter.convertStrokeDashParameters("", null, 12f, createTextSvgContext()); - Assert.assertNull(result); + Assertions.assertNull(result); } @Test public void testStrokeDashOffsetPercents() { PdfLineDashParameters result = SvgStrokeParameterConverter.convertStrokeDashParameters("5pt,3pt", "10%", 12f, createTextSvgContext()); - Assert.assertEquals(new PdfLineDashParameters(new float[]{5, 3}, 100), result); + Assertions.assertEquals(new PdfLineDashParameters(new float[]{5, 3}, 100), result); } @Test public void testEmptyStrokeDashOffset() { PdfLineDashParameters result = SvgStrokeParameterConverter.convertStrokeDashParameters("5pt,3pt", "", 12f, createTextSvgContext()); - Assert.assertEquals(new PdfLineDashParameters(new float[]{5, 3}, 0), result); + Assertions.assertEquals(new PdfLineDashParameters(new float[]{5, 3}, 0), result); } @Test public void testStrokeDashOffset() { PdfLineDashParameters result = SvgStrokeParameterConverter.convertStrokeDashParameters("5pt,3pt", "10", 12f, createTextSvgContext()); - Assert.assertEquals(new PdfLineDashParameters(new float[]{5, 3}, 7.5f), result); + Assertions.assertEquals(new PdfLineDashParameters(new float[]{5, 3}, 7.5f), result); } @Test public void testStrokeEm() { PdfLineDashParameters result = SvgStrokeParameterConverter.convertStrokeDashParameters("1em,2em", "0.5em", 8f, createTextSvgContext()); - Assert.assertEquals(new PdfLineDashParameters(new float[]{8, 16}, 4), result); + Assertions.assertEquals(new PdfLineDashParameters(new float[]{8, 16}, 4), result); } @Test public void testStrokeRem() { PdfLineDashParameters result = SvgStrokeParameterConverter.convertStrokeDashParameters("1rem,2rem", "0.5rem", 12f, createTextSvgContext()); - Assert.assertEquals(new PdfLineDashParameters(new float[]{12, 24}, 6), result); + Assertions.assertEquals(new PdfLineDashParameters(new float[]{12, 24}, 6), result); } private SvgDrawContext createTextSvgContext() { diff --git a/svg/src/test/java/com/itextpdf/svg/css/SvgStyleResolverIntegrationTest.java b/svg/src/test/java/com/itextpdf/svg/css/SvgStyleResolverIntegrationTest.java index 7e41ba3740..e7f18209c1 100644 --- a/svg/src/test/java/com/itextpdf/svg/css/SvgStyleResolverIntegrationTest.java +++ b/svg/src/test/java/com/itextpdf/svg/css/SvgStyleResolverIntegrationTest.java @@ -36,25 +36,24 @@ This file is part of the iText (R) project. import com.itextpdf.test.LogLevelConstants; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; import java.util.HashMap; import java.util.Map; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class SvgStyleResolverIntegrationTest extends SvgIntegrationTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/svg/css/SvgStyleResolver/"; public static final String destinationFolder = "./target/test/com/itextpdf/svg/css/SvgStyleResolver/"; - @BeforeClass + @BeforeAll public static void beforeClass() { ITextTest.createDestinationFolder(destinationFolder); } @@ -92,7 +91,7 @@ public void RedCirleTest() { expected.put("stroke", "#da0000"); expected.put("stroke-opacity", "1"); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test @@ -135,7 +134,7 @@ public void styleTagProcessingTest() { expected.put("stroke", "#da0000"); expected.put("stroke-opacity", "1"); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test @@ -172,7 +171,7 @@ public void stylesOfSvgTagProcessingTest() { expected.put("fill", "none"); expected.put("d", "M0 100 L0 50 L70 50"); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test diff --git a/svg/src/test/java/com/itextpdf/svg/css/SvgStyleResolverTest.java b/svg/src/test/java/com/itextpdf/svg/css/SvgStyleResolverTest.java index 6fc1ba23b6..06e9d7c592 100644 --- a/svg/src/test/java/com/itextpdf/svg/css/SvgStyleResolverTest.java +++ b/svg/src/test/java/com/itextpdf/svg/css/SvgStyleResolverTest.java @@ -43,17 +43,15 @@ This file is part of the iText (R) project. import com.itextpdf.test.LogLevelConstants; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.UnitTest; import java.util.HashMap; import java.util.List; import java.util.Map; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; -@Category(UnitTest.class) +@org.junit.jupiter.api.Tag("UnitTest") public class SvgStyleResolverTest extends ExtendedITextTest{ private static final String baseUri = "./src/test/resources/com/itextpdf/svg/css/SvgStyleResolver/"; @@ -89,7 +87,7 @@ public void SvgCssResolverBasicAttributeTest() { expected.put("font-size", "12pt"); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test @@ -118,7 +116,7 @@ public void svgCssResolverStylesheetTest() { // Attribute from external stylesheet expectedAttr.put(SvgConstants.Attributes.FILL, "black"); - Assert.assertEquals(expectedAttr, attr); + Assertions.assertEquals(expectedAttr, attr); } @Test @@ -148,7 +146,7 @@ public void svgCssResolverInvalidNameStylesheetTest() { expectedAttr.put(SvgConstants.Attributes.FONT_SIZE, "12pt"); expectedAttr.put("type", "text/css"); - Assert.assertEquals(expectedAttr, attr); + Assertions.assertEquals(expectedAttr, attr); } @Test @@ -180,7 +178,7 @@ public void svgCssResolverXlinkTest() { final String url = attr.get("xlink:href"); // Both variants(namely with triple and single slashes) are valid. - Assert.assertTrue(expectedUrl.equals(url) || expectedUrlAnotherValidVersion.equals(url)); + Assertions.assertTrue(expectedUrl.equals(url) || expectedUrlAnotherValidVersion.equals(url)); } @Test @@ -197,7 +195,7 @@ public void svgCssResolveHashXlinkTest() { SvgStyleResolver sr = new SvgStyleResolver(node, processorContext); Map<String, String> attr = sr.resolveStyles(node, new SvgCssContext()); - Assert.assertEquals("#testid", attr.get("xlink:href")); + Assertions.assertEquals("#testid", attr.get("xlink:href")); } @Test @@ -208,7 +206,7 @@ public void overrideDefaultStyleTest() { INode svgNode = new JsoupElementNode(svg); Map<String, String> resolvedStyles = styleResolver.resolveStyles(svgNode, new SvgCssContext()); - Assert.assertEquals("white", resolvedStyles.get(SvgConstants.Attributes.STROKE)); + Assertions.assertEquals("white", resolvedStyles.get(SvgConstants.Attributes.STROKE)); } @Test @@ -237,7 +235,7 @@ public void SvgCssResolverStyleTagTest() { expected.put("stroke-opacity", "1"); expected.put("font-size", "12pt"); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test @@ -254,7 +252,7 @@ public void fontsResolverTagTest() { SvgProcessorContext context = new SvgProcessorContext(new SvgConverterProperties()); SvgStyleResolver resolver = new SvgStyleResolver(jSoupStyle, context); List<CssFontFaceRule> fontFaceRuleList = resolver.getFonts(); - Assert.assertEquals(1, fontFaceRuleList.size()); - Assert.assertEquals(2, fontFaceRuleList.get(0).getProperties().size()); + Assertions.assertEquals(1, fontFaceRuleList.size()); + Assertions.assertEquals(2, fontFaceRuleList.get(0).getProperties().size()); } } diff --git a/svg/src/test/java/com/itextpdf/svg/css/XLinkTest.java b/svg/src/test/java/com/itextpdf/svg/css/XLinkTest.java index 3c7737177f..fdb53ec515 100644 --- a/svg/src/test/java/com/itextpdf/svg/css/XLinkTest.java +++ b/svg/src/test/java/com/itextpdf/svg/css/XLinkTest.java @@ -35,14 +35,12 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import java.util.Map; -@Category(UnitTest.class) +@org.junit.jupiter.api.Tag("UnitTest") public class XLinkTest extends ExtendedITextTest { @Test @@ -57,7 +55,7 @@ public void svgCssResolveMalformedXlinkTest() { SvgStyleResolver sr = new SvgStyleResolver(new SvgProcessorContext(new SvgConverterProperties())); Map<String, String> attr = sr.resolveStyles(node, new SvgCssContext()); - Assert.assertEquals(value, attr.get("xlink:href")); + Assertions.assertEquals(value, attr.get("xlink:href")); } @Test @@ -71,20 +69,20 @@ public void svgCssResolveDataXlinkTest() { SvgStyleResolver sr = new SvgStyleResolver(new SvgProcessorContext(new SvgConverterProperties())); Map<String, String> attr = sr.resolveStyles(node, new SvgCssContext()); - Assert.assertEquals(value1, attr.get("xlink:href")); + Assertions.assertEquals(value1, attr.get("xlink:href")); String value2 = "data:...,."; imageAttributes.put(new Attribute("xlink:href", value2)); sr = new SvgStyleResolver(new SvgProcessorContext(new SvgConverterProperties())); attr = sr.resolveStyles(node, new SvgCssContext()); - Assert.assertEquals(value2, attr.get("xlink:href")); + Assertions.assertEquals(value2, attr.get("xlink:href")); String value3 = "dAtA:...,."; imageAttributes.put(new Attribute("xlink:href", value3)); sr = new SvgStyleResolver(new SvgProcessorContext(new SvgConverterProperties())); attr = sr.resolveStyles(node, new SvgCssContext()); - Assert.assertEquals(value3, attr.get("xlink:href")); + Assertions.assertEquals(value3, attr.get("xlink:href")); } } diff --git a/svg/src/test/java/com/itextpdf/svg/css/impl/SvgNodeRendererInheritanceResolverUnitTest.java b/svg/src/test/java/com/itextpdf/svg/css/impl/SvgNodeRendererInheritanceResolverUnitTest.java index 0c9721419f..61c532976c 100644 --- a/svg/src/test/java/com/itextpdf/svg/css/impl/SvgNodeRendererInheritanceResolverUnitTest.java +++ b/svg/src/test/java/com/itextpdf/svg/css/impl/SvgNodeRendererInheritanceResolverUnitTest.java @@ -28,13 +28,12 @@ This file is part of the iText (R) project. import com.itextpdf.svg.renderers.impl.RectangleSvgNodeRenderer; import com.itextpdf.svg.renderers.impl.UseSvgNodeRenderer; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class SvgNodeRendererInheritanceResolverUnitTest extends ExtendedITextTest{ @Test @@ -54,8 +53,8 @@ public void applyInheritanceToSubTreeFillTest(){ SvgNodeRendererInheritanceResolver.applyInheritanceToSubTree(newRoot,subTree, null); - Assert.assertEquals(expectedFillAttribute,subTree.getAttribute(SvgConstants.Attributes.FILL)); - Assert.assertEquals(expectedFillAttribute,rect.getAttribute(SvgConstants.Attributes.FILL)); - Assert.assertEquals(expectedFillAttribute,circle.getAttribute(SvgConstants.Attributes.FILL)); + Assertions.assertEquals(expectedFillAttribute,subTree.getAttribute(SvgConstants.Attributes.FILL)); + Assertions.assertEquals(expectedFillAttribute,rect.getAttribute(SvgConstants.Attributes.FILL)); + Assertions.assertEquals(expectedFillAttribute,circle.getAttribute(SvgConstants.Attributes.FILL)); } } diff --git a/svg/src/test/java/com/itextpdf/svg/customization/CustomizeTextLeafSvgNodeRendererTest.java b/svg/src/test/java/com/itextpdf/svg/customization/CustomizeTextLeafSvgNodeRendererTest.java index 462272bf56..03b54fcde4 100644 --- a/svg/src/test/java/com/itextpdf/svg/customization/CustomizeTextLeafSvgNodeRendererTest.java +++ b/svg/src/test/java/com/itextpdf/svg/customization/CustomizeTextLeafSvgNodeRendererTest.java @@ -42,16 +42,16 @@ This file is part of the iText (R) project. import com.itextpdf.test.ITextTest; import java.io.IOException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; public class CustomizeTextLeafSvgNodeRendererTest extends SvgIntegrationTest { public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/svg/customization/CustomizeTextLeafSvgNodeRendererTest/"; public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/svg/customization/CustomizeTextLeafSvgNodeRendererTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { ITextTest.createDestinationFolder(DESTINATION_FOLDER); } @@ -73,7 +73,7 @@ public void testCustomizeTextLeafSvgNodeRenderer() throws IOException, Interrupt new PdfCanvas(doc.getPage(1)).addXObjectFittedIntoRectangle(form, new Rectangle(100, 100, 240, 80)); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + pdfFilename, SOURCE_FOLDER + "cmp_" + pdfFilename, DESTINATION_FOLDER, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(DESTINATION_FOLDER + pdfFilename, SOURCE_FOLDER + "cmp_" + pdfFilename, DESTINATION_FOLDER, "diff_")); } private static class CustomTextLeafOverridingSvgNodeRendererFactory extends DefaultSvgNodeRendererFactory { diff --git a/svg/src/test/java/com/itextpdf/svg/googlecharts/ColumnChartsTest.java b/svg/src/test/java/com/itextpdf/svg/googlecharts/ColumnChartsTest.java index e45050290e..cf0f98219d 100644 --- a/svg/src/test/java/com/itextpdf/svg/googlecharts/ColumnChartsTest.java +++ b/svg/src/test/java/com/itextpdf/svg/googlecharts/ColumnChartsTest.java @@ -25,18 +25,17 @@ This file is part of the iText (R) project. import com.itextpdf.io.exceptions.IOException; import com.itextpdf.svg.renderers.SvgIntegrationTest; import com.itextpdf.test.ITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class ColumnChartsTest extends SvgIntegrationTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/svg/googlecharts/ColumnChartsTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/svg/googlecharts/ColumnChartsTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { ITextTest.createDestinationFolder(destinationFolder); } diff --git a/svg/src/test/java/com/itextpdf/svg/googlecharts/GanttChartsTest.java b/svg/src/test/java/com/itextpdf/svg/googlecharts/GanttChartsTest.java index 1999f23346..9fa755de83 100644 --- a/svg/src/test/java/com/itextpdf/svg/googlecharts/GanttChartsTest.java +++ b/svg/src/test/java/com/itextpdf/svg/googlecharts/GanttChartsTest.java @@ -28,19 +28,18 @@ This file is part of the iText (R) project. import com.itextpdf.svg.renderers.SvgIntegrationTest; import com.itextpdf.svg.utils.TestUtils; import com.itextpdf.test.ITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class GanttChartsTest extends SvgIntegrationTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/svg/googlecharts/GanttChartsTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/svg/googlecharts/GanttChartsTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { ITextTest.createDestinationFolder(destinationFolder); } @@ -51,7 +50,7 @@ public void ganttChart() throws IOException, InterruptedException, java.io.IOExc TestUtils.convertSVGtoPDF(destinationFolder + "ganttChart.pdf", sourceFolder + "ganttChart.svg", 1, pageSize); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "ganttChart.pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "ganttChart.pdf", sourceFolder + "cmp_ganttChart.pdf", destinationFolder, "diff_")); } @@ -61,7 +60,7 @@ public void gantt2Chart() throws IOException, InterruptedException, java.io.IOEx TestUtils.convertSVGtoPDF(destinationFolder + "gantt2Chart.pdf", sourceFolder + "gantt2Chart.svg", 1, pageSize); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "gantt2Chart.pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "gantt2Chart.pdf", sourceFolder + "cmp_gantt2Chart.pdf", destinationFolder, "diff_")); } @@ -71,7 +70,7 @@ public void gantt3Chart() throws IOException, InterruptedException, java.io.IOEx TestUtils.convertSVGtoPDF(destinationFolder + "gantt3Chart.pdf", sourceFolder + "gantt3Chart.svg", 1, pageSize); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "gantt3Chart.pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "gantt3Chart.pdf", sourceFolder + "cmp_gantt3Chart.pdf", destinationFolder, "diff_")); } @@ -81,7 +80,7 @@ public void gantt4Chart() throws IOException, InterruptedException, java.io.IOEx TestUtils.convertSVGtoPDF(destinationFolder + "gantt4Chart.pdf", sourceFolder + "gantt4Chart.svg", 1, pageSize); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "gantt4Chart.pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "gantt4Chart.pdf", sourceFolder + "cmp_gantt4Chart.pdf", destinationFolder, "diff_")); } } diff --git a/svg/src/test/java/com/itextpdf/svg/googlecharts/GaugeChartsTest.java b/svg/src/test/java/com/itextpdf/svg/googlecharts/GaugeChartsTest.java index 2eb0eacbcb..5475bbe60b 100644 --- a/svg/src/test/java/com/itextpdf/svg/googlecharts/GaugeChartsTest.java +++ b/svg/src/test/java/com/itextpdf/svg/googlecharts/GaugeChartsTest.java @@ -25,18 +25,17 @@ This file is part of the iText (R) project. import com.itextpdf.io.exceptions.IOException; import com.itextpdf.svg.renderers.SvgIntegrationTest; import com.itextpdf.test.ITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class GaugeChartsTest extends SvgIntegrationTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/svg/googlecharts/GaugeChartsTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/svg/googlecharts/GaugeChartsTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { ITextTest.createDestinationFolder(destinationFolder); } diff --git a/svg/src/test/java/com/itextpdf/svg/googlecharts/GeoChartsTest.java b/svg/src/test/java/com/itextpdf/svg/googlecharts/GeoChartsTest.java index 9c7c36e9ca..8ab1e3137a 100644 --- a/svg/src/test/java/com/itextpdf/svg/googlecharts/GeoChartsTest.java +++ b/svg/src/test/java/com/itextpdf/svg/googlecharts/GeoChartsTest.java @@ -25,18 +25,17 @@ This file is part of the iText (R) project. import com.itextpdf.io.exceptions.IOException; import com.itextpdf.svg.renderers.SvgIntegrationTest; import com.itextpdf.test.ITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class GeoChartsTest extends SvgIntegrationTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/svg/googlecharts/GeoChartsTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/svg/googlecharts/GeoChartsTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { ITextTest.createDestinationFolder(destinationFolder); } diff --git a/svg/src/test/java/com/itextpdf/svg/googlecharts/GoogleChartsTest.java b/svg/src/test/java/com/itextpdf/svg/googlecharts/GoogleChartsTest.java index 5fed8832f2..c0fe850e8a 100644 --- a/svg/src/test/java/com/itextpdf/svg/googlecharts/GoogleChartsTest.java +++ b/svg/src/test/java/com/itextpdf/svg/googlecharts/GoogleChartsTest.java @@ -28,20 +28,19 @@ This file is part of the iText (R) project. import com.itextpdf.svg.renderers.SvgIntegrationTest; import com.itextpdf.svg.utils.TestUtils; import com.itextpdf.test.ITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class GoogleChartsTest extends SvgIntegrationTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/svg/googlecharts/GoogleChartsTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/svg/googlecharts/GoogleChartsTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { ITextTest.createDestinationFolder(destinationFolder); } @@ -62,7 +61,7 @@ public void areaChart() throws IOException, InterruptedException, java.io.IOExce TestUtils.convertSVGtoPDF(destinationFolder + "areaChart.pdf", sourceFolder + "areaChart.svg", 1, pageSize); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "areaChart.pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "areaChart.pdf", sourceFolder + "cmp_areaChart.pdf", destinationFolder, "diff_")); } @@ -72,7 +71,7 @@ public void bubbleChart() throws IOException, InterruptedException, java.io.IOEx TestUtils.convertSVGtoPDF(destinationFolder + "bubbleChart.pdf", sourceFolder + "bubbleChart.svg", 1, pageSize); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "bubbleChart.pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "bubbleChart.pdf", sourceFolder + "cmp_bubbleChart.pdf", destinationFolder, "diff_")); } @@ -83,7 +82,7 @@ public void calendarChart() throws IOException, java.io.IOException, Interrupted TestUtils.convertSVGtoPDF(destinationFolder + "calendarChart.pdf", sourceFolder + "calendarChart.svg", 1, pageSize); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "calendarChart.pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "calendarChart.pdf", sourceFolder + "cmp_calendarChart.pdf", destinationFolder, "diff_")); } @@ -98,7 +97,7 @@ public void comboChart() throws IOException, InterruptedException, java.io.IOExc TestUtils.convertSVGtoPDF(destinationFolder + "comboChart.pdf", sourceFolder + "comboChart.svg", 1, pageSize); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "comboChart.pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "comboChart.pdf", sourceFolder + "cmp_comboChart.pdf", destinationFolder, "diff_")); } diff --git a/svg/src/test/java/com/itextpdf/svg/googlecharts/IntervalsChartsTest.java b/svg/src/test/java/com/itextpdf/svg/googlecharts/IntervalsChartsTest.java index c62869e768..bf214e1175 100644 --- a/svg/src/test/java/com/itextpdf/svg/googlecharts/IntervalsChartsTest.java +++ b/svg/src/test/java/com/itextpdf/svg/googlecharts/IntervalsChartsTest.java @@ -25,18 +25,17 @@ This file is part of the iText (R) project. import com.itextpdf.io.exceptions.IOException; import com.itextpdf.svg.renderers.SvgIntegrationTest; import com.itextpdf.test.ITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class IntervalsChartsTest extends SvgIntegrationTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/svg/googlecharts/IntervalsChartsTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/svg/googlecharts/IntervalsChartsTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { ITextTest.createDestinationFolder(destinationFolder); } diff --git a/svg/src/test/java/com/itextpdf/svg/googlecharts/LineChartsTest.java b/svg/src/test/java/com/itextpdf/svg/googlecharts/LineChartsTest.java index 494fa0a69f..f99759d466 100644 --- a/svg/src/test/java/com/itextpdf/svg/googlecharts/LineChartsTest.java +++ b/svg/src/test/java/com/itextpdf/svg/googlecharts/LineChartsTest.java @@ -25,18 +25,17 @@ This file is part of the iText (R) project. import com.itextpdf.io.exceptions.IOException; import com.itextpdf.svg.renderers.SvgIntegrationTest; import com.itextpdf.test.ITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class LineChartsTest extends SvgIntegrationTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/svg/googlecharts/LineChartsTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/svg/googlecharts/LineChartsTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { ITextTest.createDestinationFolder(destinationFolder); } diff --git a/svg/src/test/java/com/itextpdf/svg/googlecharts/PieChartsTest.java b/svg/src/test/java/com/itextpdf/svg/googlecharts/PieChartsTest.java index 4192c677c9..bce7c88f59 100644 --- a/svg/src/test/java/com/itextpdf/svg/googlecharts/PieChartsTest.java +++ b/svg/src/test/java/com/itextpdf/svg/googlecharts/PieChartsTest.java @@ -25,18 +25,17 @@ This file is part of the iText (R) project. import com.itextpdf.io.exceptions.IOException; import com.itextpdf.svg.renderers.SvgIntegrationTest; import com.itextpdf.test.ITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PieChartsTest extends SvgIntegrationTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/svg/googlecharts/PieChartsTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/svg/googlecharts/PieChartsTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { ITextTest.createDestinationFolder(destinationFolder); } diff --git a/svg/src/test/java/com/itextpdf/svg/googlecharts/SankeyChartsTest.java b/svg/src/test/java/com/itextpdf/svg/googlecharts/SankeyChartsTest.java index 0b7b61907a..8898ae115b 100644 --- a/svg/src/test/java/com/itextpdf/svg/googlecharts/SankeyChartsTest.java +++ b/svg/src/test/java/com/itextpdf/svg/googlecharts/SankeyChartsTest.java @@ -25,18 +25,17 @@ This file is part of the iText (R) project. import com.itextpdf.io.exceptions.IOException; import com.itextpdf.svg.renderers.SvgIntegrationTest; import com.itextpdf.test.ITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class SankeyChartsTest extends SvgIntegrationTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/svg/googlecharts/SankeyChartsTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/svg/googlecharts/SankeyChartsTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { ITextTest.createDestinationFolder(destinationFolder); } diff --git a/svg/src/test/java/com/itextpdf/svg/googlecharts/ScatterChartsTest.java b/svg/src/test/java/com/itextpdf/svg/googlecharts/ScatterChartsTest.java index 8528b49dbe..6087d5f97a 100644 --- a/svg/src/test/java/com/itextpdf/svg/googlecharts/ScatterChartsTest.java +++ b/svg/src/test/java/com/itextpdf/svg/googlecharts/ScatterChartsTest.java @@ -25,18 +25,17 @@ This file is part of the iText (R) project. import com.itextpdf.io.exceptions.IOException; import com.itextpdf.svg.renderers.SvgIntegrationTest; import com.itextpdf.test.ITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class ScatterChartsTest extends SvgIntegrationTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/svg/googlecharts/ScatterChartsTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/svg/googlecharts/ScatterChartsTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { ITextTest.createDestinationFolder(destinationFolder); } diff --git a/svg/src/test/java/com/itextpdf/svg/googlecharts/SliceChartsTest.java b/svg/src/test/java/com/itextpdf/svg/googlecharts/SliceChartsTest.java index 561abeb037..76871b1f7d 100644 --- a/svg/src/test/java/com/itextpdf/svg/googlecharts/SliceChartsTest.java +++ b/svg/src/test/java/com/itextpdf/svg/googlecharts/SliceChartsTest.java @@ -25,18 +25,17 @@ This file is part of the iText (R) project. import com.itextpdf.io.exceptions.IOException; import com.itextpdf.svg.renderers.SvgIntegrationTest; import com.itextpdf.test.ITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class SliceChartsTest extends SvgIntegrationTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/svg/googlecharts/SliceChartsTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/svg/googlecharts/SliceChartsTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { ITextTest.createDestinationFolder(destinationFolder); } diff --git a/svg/src/test/java/com/itextpdf/svg/googlecharts/SteppedAreaChartTest.java b/svg/src/test/java/com/itextpdf/svg/googlecharts/SteppedAreaChartTest.java index a65b9cf2d1..e3803db36e 100644 --- a/svg/src/test/java/com/itextpdf/svg/googlecharts/SteppedAreaChartTest.java +++ b/svg/src/test/java/com/itextpdf/svg/googlecharts/SteppedAreaChartTest.java @@ -25,18 +25,17 @@ This file is part of the iText (R) project. import com.itextpdf.io.exceptions.IOException; import com.itextpdf.svg.renderers.SvgIntegrationTest; import com.itextpdf.test.ITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class SteppedAreaChartTest extends SvgIntegrationTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/svg/googlecharts/SteppedAreaChartsTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/svg/googlecharts/SteppedAreaChartsTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { ITextTest.createDestinationFolder(destinationFolder); } diff --git a/svg/src/test/java/com/itextpdf/svg/googlecharts/TimelineChartsTest.java b/svg/src/test/java/com/itextpdf/svg/googlecharts/TimelineChartsTest.java index f670bb9dce..1568c6f7f9 100644 --- a/svg/src/test/java/com/itextpdf/svg/googlecharts/TimelineChartsTest.java +++ b/svg/src/test/java/com/itextpdf/svg/googlecharts/TimelineChartsTest.java @@ -28,19 +28,18 @@ This file is part of the iText (R) project. import com.itextpdf.svg.renderers.SvgIntegrationTest; import com.itextpdf.svg.utils.TestUtils; import com.itextpdf.test.ITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class TimelineChartsTest extends SvgIntegrationTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/svg/googlecharts/TimelineChartsTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/svg/googlecharts/TimelineChartsTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { ITextTest.createDestinationFolder(destinationFolder); } @@ -56,7 +55,7 @@ public void timelineChart() throws IOException, InterruptedException, java.io.IO TestUtils.convertSVGtoPDF(destinationFolder + "timelineChart.pdf", sourceFolder + "timelineChart.svg", 1, pageSize); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "timelineChart.pdf", + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + "timelineChart.pdf", sourceFolder + "cmp_timelineChart.pdf", destinationFolder, "diff_")); } diff --git a/svg/src/test/java/com/itextpdf/svg/googlecharts/TreemapsChartsTest.java b/svg/src/test/java/com/itextpdf/svg/googlecharts/TreemapsChartsTest.java index 770d2584ae..db572b1e11 100644 --- a/svg/src/test/java/com/itextpdf/svg/googlecharts/TreemapsChartsTest.java +++ b/svg/src/test/java/com/itextpdf/svg/googlecharts/TreemapsChartsTest.java @@ -25,18 +25,17 @@ This file is part of the iText (R) project. import com.itextpdf.io.exceptions.IOException; import com.itextpdf.svg.renderers.SvgIntegrationTest; import com.itextpdf.test.ITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class TreemapsChartsTest extends SvgIntegrationTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/svg/googlecharts/TreemapsChartsTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/svg/googlecharts/TreemapsChartsTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { ITextTest.createDestinationFolder(destinationFolder); } diff --git a/svg/src/test/java/com/itextpdf/svg/googlecharts/TrendlinesChartsTest.java b/svg/src/test/java/com/itextpdf/svg/googlecharts/TrendlinesChartsTest.java index c2de6633f3..1997598b38 100644 --- a/svg/src/test/java/com/itextpdf/svg/googlecharts/TrendlinesChartsTest.java +++ b/svg/src/test/java/com/itextpdf/svg/googlecharts/TrendlinesChartsTest.java @@ -25,18 +25,17 @@ This file is part of the iText (R) project. import com.itextpdf.io.exceptions.IOException; import com.itextpdf.svg.renderers.SvgIntegrationTest; import com.itextpdf.test.ITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class TrendlinesChartsTest extends SvgIntegrationTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/svg/googlecharts/TrendlinesChartsTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/svg/googlecharts/TrendlinesChartsTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { ITextTest.createDestinationFolder(destinationFolder); } diff --git a/svg/src/test/java/com/itextpdf/svg/googlecharts/WordTreesChartsTest.java b/svg/src/test/java/com/itextpdf/svg/googlecharts/WordTreesChartsTest.java index a3383d2fd2..71b463bf85 100644 --- a/svg/src/test/java/com/itextpdf/svg/googlecharts/WordTreesChartsTest.java +++ b/svg/src/test/java/com/itextpdf/svg/googlecharts/WordTreesChartsTest.java @@ -26,18 +26,17 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.geom.PageSize; import com.itextpdf.svg.renderers.SvgIntegrationTest; import com.itextpdf.test.ITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class WordTreesChartsTest extends SvgIntegrationTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/svg/googlecharts/WordTreesChartsTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/svg/googlecharts/WordTreesChartsTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { ITextTest.createDestinationFolder(destinationFolder); } diff --git a/svg/src/test/java/com/itextpdf/svg/jfreesvg/JFreeSvgTest.java b/svg/src/test/java/com/itextpdf/svg/jfreesvg/JFreeSvgTest.java index 9a991f31f4..8096c5ac45 100644 --- a/svg/src/test/java/com/itextpdf/svg/jfreesvg/JFreeSvgTest.java +++ b/svg/src/test/java/com/itextpdf/svg/jfreesvg/JFreeSvgTest.java @@ -24,21 +24,20 @@ This file is part of the iText (R) project. import com.itextpdf.svg.renderers.SvgIntegrationTest; import com.itextpdf.test.ITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class JFreeSvgTest extends SvgIntegrationTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/svg/JFreeSvgTest/"; private static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/svg/JFreeSvgTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { ITextTest.createDestinationFolder(DESTINATION_FOLDER); } diff --git a/svg/src/test/java/com/itextpdf/svg/processors/DefaultSvgProcessorIntegrationTest.java b/svg/src/test/java/com/itextpdf/svg/processors/DefaultSvgProcessorIntegrationTest.java index 6d3931b9e3..b563e1df8f 100644 --- a/svg/src/test/java/com/itextpdf/svg/processors/DefaultSvgProcessorIntegrationTest.java +++ b/svg/src/test/java/com/itextpdf/svg/processors/DefaultSvgProcessorIntegrationTest.java @@ -29,17 +29,16 @@ This file is part of the iText (R) project. import com.itextpdf.svg.renderers.IBranchSvgNodeRenderer; import com.itextpdf.svg.renderers.ISvgNodeRenderer; import com.itextpdf.svg.renderers.SvgIntegrationTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.util.Map; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class DefaultSvgProcessorIntegrationTest extends SvgIntegrationTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/svg/processors/impl/DefaultSvgProcessorIntegrationTest/"; @@ -56,13 +55,13 @@ public void DefaultBehaviourTest() throws IOException { //Attribute comparison from the known RedCircle.svg Map<String, String> attrs = actual.getChildren().get(0).getAttributeMapCopy(); - Assert.assertEquals("Number of parsed attributes is wrong", 12, attrs.keySet().size()); + Assertions.assertEquals(12, attrs.keySet().size(), "Number of parsed attributes is wrong"); - Assert.assertEquals("The stroke-opacity attribute doesn't correspond it's value", "1", attrs.get("stroke-opacity")); - Assert.assertEquals("The stroke-width attribute doesn't correspond it's value", "1.76388889", attrs.get("stroke-width")); + Assertions.assertEquals("1", attrs.get("stroke-opacity"), "The stroke-opacity attribute doesn't correspond it's value"); + Assertions.assertEquals("1.76388889", attrs.get("stroke-width"), "The stroke-width attribute doesn't correspond it's value"); - Assert.assertEquals("The id attribute doesn't correspond it's value", "path3699", attrs.get("id")); - Assert.assertEquals("The stroke-dasharray attribute doesn't correspond it's value", "none", attrs.get("stroke-dasharray")); + Assertions.assertEquals("path3699", attrs.get("id"), "The id attribute doesn't correspond it's value"); + Assertions.assertEquals("none", attrs.get("stroke-dasharray"), "The stroke-dasharray attribute doesn't correspond it's value"); } @Test @@ -73,7 +72,7 @@ public void namedObjectRectangleTest() throws IOException { IDocumentNode root = xmlParser.parse(svg, null); ISvgProcessorResult processorResult = new DefaultSvgProcessor().process(root, null); Map<String, ISvgNodeRenderer> actual = processorResult.getNamedObjects(); - Assert.assertEquals(1, actual.size()); - Assert.assertTrue(actual.containsKey("MyRect")); + Assertions.assertEquals(1, actual.size()); + Assertions.assertTrue(actual.containsKey("MyRect")); } } diff --git a/svg/src/test/java/com/itextpdf/svg/processors/ProcessorStateTest.java b/svg/src/test/java/com/itextpdf/svg/processors/ProcessorStateTest.java index 7124461004..d67090df8e 100644 --- a/svg/src/test/java/com/itextpdf/svg/processors/ProcessorStateTest.java +++ b/svg/src/test/java/com/itextpdf/svg/processors/ProcessorStateTest.java @@ -26,15 +26,14 @@ This file is part of the iText (R) project. import com.itextpdf.svg.processors.impl.ProcessorState; import com.itextpdf.svg.renderers.ISvgNodeRenderer; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.util.EmptyStackException; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category( UnitTest.class ) +@Tag("UnitTest") public class ProcessorStateTest extends ExtendedITextTest{ /** @@ -46,7 +45,7 @@ public void processorStateTestPush() { ISvgNodeRenderer renderer = new DummySvgNodeRenderer("test"); testProcessorState.push(renderer); - Assert.assertTrue(testProcessorState.size() == 1); + Assertions.assertTrue(testProcessorState.size() == 1); } /** @@ -59,7 +58,7 @@ public void processorStateTestPop() { testProcessorState.push(renderer); ISvgNodeRenderer popped = testProcessorState.pop(); - Assert.assertTrue(popped.toString().equals("test") && testProcessorState.empty()); + Assertions.assertTrue(popped.toString().equals("test") && testProcessorState.empty()); } /** @@ -72,7 +71,7 @@ public void processorStateTestPeek() { testProcessorState.push(renderer); ISvgNodeRenderer viewed = testProcessorState.top(); - Assert.assertTrue(viewed.toString().equals("test") && ! testProcessorState.empty()); + Assertions.assertTrue(viewed.toString().equals("test") && ! testProcessorState.empty()); } @@ -90,14 +89,14 @@ public void processorStateTestMultiplePushesPopAndPeek() { ISvgNodeRenderer popped = testProcessorState.pop(); boolean result = popped.toString().equals("test02"); result = result && testProcessorState.top().toString().equals("test01"); - Assert.assertTrue(result); + Assertions.assertTrue(result); } @Test public void processorStateTestPopEmpty() { ProcessorState testProcessorState = new ProcessorState(); - Assert.assertThrows(EmptyStackException.class, () -> testProcessorState.pop()); + Assertions.assertThrows(EmptyStackException.class, () -> testProcessorState.pop()); } @Test @@ -110,7 +109,7 @@ public void processorStateTestPushSameElementTwice() { ISvgNodeRenderer popped = testProcessorState.pop(); boolean result = popped.toString().equals("test01"); result = result && testProcessorState.top().toString().equals("test01"); - Assert.assertTrue(result); + Assertions.assertTrue(result); } @@ -118,7 +117,7 @@ public void processorStateTestPushSameElementTwice() { public void processorStateTestPeekEmpty() { ProcessorState testProcessorState = new ProcessorState(); - Assert.assertThrows(EmptyStackException.class, () -> testProcessorState.pop()); + Assertions.assertThrows(EmptyStackException.class, () -> testProcessorState.pop()); } diff --git a/svg/src/test/java/com/itextpdf/svg/processors/SvgConverterPropertiesTest.java b/svg/src/test/java/com/itextpdf/svg/processors/SvgConverterPropertiesTest.java index 41388a64de..195a38b709 100644 --- a/svg/src/test/java/com/itextpdf/svg/processors/SvgConverterPropertiesTest.java +++ b/svg/src/test/java/com/itextpdf/svg/processors/SvgConverterPropertiesTest.java @@ -24,20 +24,19 @@ This file is part of the iText (R) project. import com.itextpdf.svg.processors.impl.SvgConverterProperties; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.nio.charset.StandardCharsets; -@Category(UnitTest.class) +@Tag("UnitTest") public class SvgConverterPropertiesTest extends ExtendedITextTest{ @Test public void getCharsetNameRegressionTest() { String expected = StandardCharsets.UTF_8.name(); String actual = new SvgConverterProperties().getCharset(); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } } diff --git a/svg/src/test/java/com/itextpdf/svg/processors/impl/DefaultSvgProcessorUnitTest.java b/svg/src/test/java/com/itextpdf/svg/processors/impl/DefaultSvgProcessorUnitTest.java index 124a0c5a72..7b624e5955 100644 --- a/svg/src/test/java/com/itextpdf/svg/processors/impl/DefaultSvgProcessorUnitTest.java +++ b/svg/src/test/java/com/itextpdf/svg/processors/impl/DefaultSvgProcessorUnitTest.java @@ -48,14 +48,12 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.UnitTest; import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; -@Category(UnitTest.class) +@org.junit.jupiter.api.Tag("UnitTest") public class DefaultSvgProcessorUnitTest extends ExtendedITextTest { //Main success scenario @@ -81,7 +79,7 @@ public void dummyProcessingTestCorrectSimple() { rootExpected.addChild(new DummySvgNodeRenderer("circle")); rootExpected.addChild(new DummySvgNodeRenderer("path")); //Compare - Assert.assertEquals(rootActual, rootExpected); + Assertions.assertEquals(rootActual, rootExpected); } @Test() @@ -113,7 +111,7 @@ public void dummyProcessingTestCorrectNested() { rootExpected.addChild(nestedSvgRend); //Compare - Assert.assertEquals(rootActual, rootExpected); + Assertions.assertEquals(rootActual, rootExpected); } //Edge cases @@ -137,7 +135,7 @@ public void dummyProcessingTestNodeHasNullChild() { ISvgNodeRenderer rootActual = processor.process(root, props).getRootRenderer(); //setup expected ISvgNodeRenderer rootExpected = new DummySvgNodeRenderer("svg"); - Assert.assertEquals(rootExpected, rootActual); + Assertions.assertEquals(rootExpected, rootActual); } @Test @@ -156,7 +154,7 @@ public void dummyProcessingSvgTagIsNotRootOfInput() { //setup expected IBranchSvgNodeRenderer rootExpected = new DummyBranchSvgNodeRenderer("svg"); rootExpected.addChild(new DummySvgNodeRenderer("circle")); - Assert.assertEquals(rootActual, rootExpected); + Assertions.assertEquals(rootActual, rootExpected); } @Test @@ -169,17 +167,17 @@ public void dummyProcessingNoSvgTagInInput() { DefaultSvgProcessor processor = new DefaultSvgProcessor(); ISvgConverterProperties props = new DummySvgConverterProperties(); - Exception e = Assert.assertThrows(SvgProcessingException.class, + Exception e = Assertions.assertThrows(SvgProcessingException.class, () -> processor.process(root, props).getRootRenderer() ); - Assert.assertEquals(SvgExceptionMessageConstant.NO_ROOT, e.getMessage()); + Assertions.assertEquals(SvgExceptionMessageConstant.NO_ROOT, e.getMessage()); } @Test public void dummyProcessingTestNullInput() { DefaultSvgProcessor processor = new DefaultSvgProcessor(); - Assert.assertThrows(SvgProcessingException.class, () -> processor.process(null, null)); + Assertions.assertThrows(SvgProcessingException.class, () -> processor.process(null, null)); } @Test @@ -195,8 +193,8 @@ public void processWithNullPropertiesTest() { ISvgNodeRenderer rootRenderer = processor.process(root, convProps).getRootRenderer(); - Assert.assertTrue(rootRenderer instanceof SvgTagSvgNodeRenderer); - Assert.assertEquals(0, ((SvgTagSvgNodeRenderer) rootRenderer).getChildren().size()); + Assertions.assertTrue(rootRenderer instanceof SvgTagSvgNodeRenderer); + Assertions.assertEquals(0, ((SvgTagSvgNodeRenderer) rootRenderer).getChildren().size()); } @Test @@ -216,20 +214,20 @@ public void defaultProcessingCorrectlyNestedRenderersTest() { ISvgNodeRenderer rootRenderer = processor.process(root, convProps).getRootRenderer(); - Assert.assertTrue(rootRenderer instanceof SvgTagSvgNodeRenderer); + Assertions.assertTrue(rootRenderer instanceof SvgTagSvgNodeRenderer); List<ISvgNodeRenderer> children = ((SvgTagSvgNodeRenderer) rootRenderer).getChildren(); - Assert.assertEquals(2, children.size()); - Assert.assertTrue(children.get(0) instanceof CircleSvgNodeRenderer); - Assert.assertTrue(children.get(1) instanceof PathSvgNodeRenderer); + Assertions.assertEquals(2, children.size()); + Assertions.assertTrue(children.get(0) instanceof CircleSvgNodeRenderer); + Assertions.assertTrue(children.get(1) instanceof PathSvgNodeRenderer); } @Test public void findFirstElementNullTest() { DefaultSvgProcessor processor = new DefaultSvgProcessor(); IElementNode actual = processor.findFirstElement(null, "name"); - Assert.assertNull(actual); + Assertions.assertNull(actual); } @Test @@ -262,7 +260,7 @@ public void xLinkAttributeBaseDirDoesNotExistTest() { String url = imageRendered.getAttribute(SvgConstants.Attributes.XLINK_HREF); // Both variants(namely with triple and single slashes) are valid. - Assert.assertTrue(expectedURL.equals(url) || expectedURLAnotherValidVersion.equals(url)); + Assertions.assertTrue(expectedURL.equals(url) || expectedURLAnotherValidVersion.equals(url)); } @Test @@ -280,7 +278,7 @@ public void xLinkAttributeResolveNonEmptyBaseUrlTest() { String url = imageRendered.getAttribute(SvgConstants.Attributes.XLINK_HREF); // Both variants(namely with triple and single slashes) are valid. - Assert.assertTrue(expectedURL.equals(url) || expectedURLAnotherValidVersion.equals(url)); + Assertions.assertTrue(expectedURL.equals(url) || expectedURLAnotherValidVersion.equals(url)); } private INode createSvgContainingImage() { diff --git a/svg/src/test/java/com/itextpdf/svg/processors/impl/SvgProcessorResultUnitTest.java b/svg/src/test/java/com/itextpdf/svg/processors/impl/SvgProcessorResultUnitTest.java index 296704abe9..e54f21de2b 100644 --- a/svg/src/test/java/com/itextpdf/svg/processors/impl/SvgProcessorResultUnitTest.java +++ b/svg/src/test/java/com/itextpdf/svg/processors/impl/SvgProcessorResultUnitTest.java @@ -32,25 +32,24 @@ This file is part of the iText (R) project. import com.itextpdf.svg.renderers.ISvgNodeRenderer; import com.itextpdf.svg.renderers.impl.SvgTagSvgNodeRenderer; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.IOException; import java.util.HashMap; import java.util.Map; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class SvgProcessorResultUnitTest extends ExtendedITextTest { @Test public void contextParameterCannotBeNullTest() { Map<String, ISvgNodeRenderer> namedObjects = new HashMap<>(); ISvgNodeRenderer root = new SvgTagSvgNodeRenderer(); - Exception exception = Assert.assertThrows(IllegalArgumentException.class, + Exception exception = Assertions.assertThrows(IllegalArgumentException.class, () -> new SvgProcessorResult(namedObjects, root, null)); - Assert.assertEquals(SvgExceptionMessageConstant.PARAMETER_CANNOT_BE_NULL, exception.getMessage()); + Assertions.assertEquals(SvgExceptionMessageConstant.PARAMETER_CANNOT_BE_NULL, exception.getMessage()); } @Test @@ -60,8 +59,8 @@ public void getFontProviderTest() { SvgProcessorContext context = new SvgProcessorContext(new SvgConverterProperties()); SvgProcessorResult result = new SvgProcessorResult(namedObjects, root, context); FontProvider fontProviderFromResult = result.getFontProvider(); - Assert.assertNotNull(fontProviderFromResult); - Assert.assertSame(context.getFontProvider(), fontProviderFromResult); + Assertions.assertNotNull(fontProviderFromResult); + Assertions.assertSame(context.getFontProvider(), fontProviderFromResult); } @Test @@ -73,7 +72,7 @@ public void getTempFontsTest() throws IOException { context.addTemporaryFont(fp, PdfEncodings.IDENTITY_H, ""); SvgProcessorResult result = new SvgProcessorResult(namedObjects, root, context); FontSet tempFontsFromResult = result.getTempFonts(); - Assert.assertNotNull(tempFontsFromResult); - Assert.assertSame(context.getTempFonts(), tempFontsFromResult); + Assertions.assertNotNull(tempFontsFromResult); + Assertions.assertSame(context.getTempFonts(), tempFontsFromResult); } } diff --git a/svg/src/test/java/com/itextpdf/svg/processors/impl/font/FontFaceTest.java b/svg/src/test/java/com/itextpdf/svg/processors/impl/font/FontFaceTest.java index 7a0195b0cb..8234931890 100644 --- a/svg/src/test/java/com/itextpdf/svg/processors/impl/font/FontFaceTest.java +++ b/svg/src/test/java/com/itextpdf/svg/processors/impl/font/FontFaceTest.java @@ -36,23 +36,22 @@ This file is part of the iText (R) project. import com.itextpdf.test.ITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.File; import java.io.IOException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class FontFaceTest extends SvgIntegrationTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/svg/processors/impl/font/FontFaceTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/svg/processors/impl/font/FontFaceTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { ITextTest.createDestinationFolder(destinationFolder); } @@ -155,7 +154,7 @@ public void w3cProblemTest02() throws IOException, InterruptedException { return; } - Assert.fail("In w3c test suite this font is labeled as invalid, " + Assertions.fail("In w3c test suite this font is labeled as invalid, " + "so the invalid negative value is expected while creating a glyph."); } @@ -197,7 +196,7 @@ public void w3cProblemTest07() throws IOException, InterruptedException { return; } - Assert.fail("In w3c test suite this font is labeled as invalid, " + Assertions.fail("In w3c test suite this font is labeled as invalid, " + "so the invalid negative value is expected while creating a glyph."); } @@ -226,7 +225,7 @@ public void incorrectFontNameTest04() throws IOException, InterruptedException { } @Test - @Ignore("DEVSIX-1759 - unicode in font family and different result in dotnet") + @Disabled("DEVSIX-1759 - unicode in font family and different result in dotnet") public void fontFamilyTest01() throws IOException, InterruptedException { runTest("fontFamilyTest01"); } diff --git a/svg/src/test/java/com/itextpdf/svg/processors/impl/font/FontSizeTest.java b/svg/src/test/java/com/itextpdf/svg/processors/impl/font/FontSizeTest.java index 2b860e700d..64a5657fd8 100644 --- a/svg/src/test/java/com/itextpdf/svg/processors/impl/font/FontSizeTest.java +++ b/svg/src/test/java/com/itextpdf/svg/processors/impl/font/FontSizeTest.java @@ -27,20 +27,19 @@ This file is part of the iText (R) project. import com.itextpdf.test.ITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class FontSizeTest extends SvgIntegrationTest { public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/svg/processors/impl/font/FontSizeTest/"; public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/svg/processors/impl/font/FontSizeTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { ITextTest.createDestinationFolder(DESTINATION_FOLDER); } diff --git a/svg/src/test/java/com/itextpdf/svg/processors/impl/font/SvgFontProcessorTest.java b/svg/src/test/java/com/itextpdf/svg/processors/impl/font/SvgFontProcessorTest.java index 99b51abbc8..cf2ef4c1fa 100644 --- a/svg/src/test/java/com/itextpdf/svg/processors/impl/font/SvgFontProcessorTest.java +++ b/svg/src/test/java/com/itextpdf/svg/processors/impl/font/SvgFontProcessorTest.java @@ -33,12 +33,10 @@ This file is part of the iText (R) project. import com.itextpdf.svg.processors.impl.SvgConverterProperties; import com.itextpdf.svg.processors.impl.SvgProcessorContext; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; -@Category(UnitTest.class) +@org.junit.jupiter.api.Tag("UnitTest") public class SvgFontProcessorTest extends ExtendedITextTest { @Test @@ -57,6 +55,6 @@ public void addFontFaceFontsTest() { SvgFontProcessor svgFontProcessor = new SvgFontProcessor(context); svgFontProcessor.addFontFaceFonts(cssResolver); FontInfo info = (FontInfo) context.getTempFonts().getFonts().toArray()[0]; - Assert.assertEquals("Courier", info.getFontName()); + Assertions.assertEquals("Courier", info.getFontName()); } } diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/DefaultSvgNodeRendererFactoryDrawTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/DefaultSvgNodeRendererFactoryDrawTest.java index a0ae405cca..77868aeb1d 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/DefaultSvgNodeRendererFactoryDrawTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/DefaultSvgNodeRendererFactoryDrawTest.java @@ -30,12 +30,10 @@ This file is part of the iText (R) project. import com.itextpdf.svg.dummy.renderers.impl.DummyProcessableSvgNodeRenderer; import com.itextpdf.svg.renderers.factories.ISvgNodeRendererFactory; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; -@Category(UnitTest.class) +@org.junit.jupiter.api.Tag("UnitTest") public class DefaultSvgNodeRendererFactoryDrawTest extends ExtendedITextTest { private final ISvgNodeRendererFactory fact = new DummySvgNodeFactory(); @@ -45,10 +43,10 @@ public void basicProcessedRendererTest() { Element element = new Element(Tag.valueOf("processable"), ""); IElementNode tag = new JsoupElementNode(element); ISvgNodeRenderer renderer = fact.createSvgNodeRendererForTag(tag, null); - Assert.assertTrue(renderer instanceof DummyProcessableSvgNodeRenderer); + Assertions.assertTrue(renderer instanceof DummyProcessableSvgNodeRenderer); renderer.draw(new SvgDrawContext(null, null)); DummyProcessableSvgNodeRenderer processed = (DummyProcessableSvgNodeRenderer) renderer; - Assert.assertTrue(processed.isProcessed()); + Assertions.assertTrue(processed.isProcessed()); } @Test @@ -63,9 +61,9 @@ public void nestedProcessedRendererTest() { parentRenderer.draw(new SvgDrawContext(null, null)); DummyProcessableSvgNodeRenderer parentProcessed = (DummyProcessableSvgNodeRenderer) parentRenderer; - Assert.assertTrue(parentProcessed.isProcessed()); + Assertions.assertTrue(parentProcessed.isProcessed()); DummyProcessableSvgNodeRenderer childProcessed = (DummyProcessableSvgNodeRenderer) childRenderer; // child is not processed unless instructed thus in its parent - Assert.assertFalse(childProcessed.isProcessed()); + Assertions.assertFalse(childProcessed.isProcessed()); } } diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/DefaultSvgNodeRendererFactoryTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/DefaultSvgNodeRendererFactoryTest.java index d8005ab4b1..86b47b2364 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/DefaultSvgNodeRendererFactoryTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/DefaultSvgNodeRendererFactoryTest.java @@ -36,12 +36,10 @@ This file is part of the iText (R) project. import com.itextpdf.test.ExtendedITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; -@Category(UnitTest.class) +@org.junit.jupiter.api.Tag("UnitTest") public class DefaultSvgNodeRendererFactoryTest extends ExtendedITextTest { private final ISvgNodeRendererFactory fact = new DummySvgNodeFactory(); @@ -62,8 +60,8 @@ public void argumentedConstructorTest() { Element protectedElement = new Element(Tag.valueOf("argumented"), ""); IElementNode tag = new JsoupElementNode(protectedElement); ISvgNodeRenderer renderer = fact.createSvgNodeRendererForTag(tag, null); - Assert.assertTrue(renderer instanceof DummyArgumentedConstructorSvgNodeRenderer); - Assert.assertEquals(15, ((DummyArgumentedConstructorSvgNodeRenderer) renderer).number); + Assertions.assertTrue(renderer instanceof DummyArgumentedConstructorSvgNodeRenderer); + Assertions.assertEquals(15, ((DummyArgumentedConstructorSvgNodeRenderer) renderer).number); } @Test @@ -71,7 +69,7 @@ public void rootTagTest() { Element element = new Element(Tag.valueOf("dummy"), ""); IElementNode tag = new JsoupElementNode(element); ISvgNodeRenderer childRenderer = fact.createSvgNodeRendererForTag(tag, null); - Assert.assertTrue(childRenderer instanceof DummySvgNodeRenderer); + Assertions.assertTrue(childRenderer instanceof DummySvgNodeRenderer); } private static class LocalSvgNodeRendererFactory extends DefaultSvgNodeRendererFactory { @@ -94,7 +92,7 @@ public void customMapperTest() { Element element = new Element(Tag.valueOf("test"), ""); IElementNode tag = new JsoupElementNode(element); ISvgNodeRenderer rend = factory.createSvgNodeRendererForTag(tag, null); - Assert.assertTrue(rend instanceof DummyProcessableSvgNodeRenderer); + Assertions.assertTrue(rend instanceof DummyProcessableSvgNodeRenderer); } @Test @@ -106,6 +104,6 @@ public void hierarchyTagTest() { ISvgNodeRenderer parentRenderer = fact.createSvgNodeRendererForTag(parentTag, null); ISvgNodeRenderer childRenderer = fact.createSvgNodeRendererForTag(childTag, parentRenderer); - Assert.assertEquals(parentRenderer, childRenderer.getParent()); + Assertions.assertEquals(parentRenderer, childRenderer.getParent()); } } diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/FillTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/FillTest.java index 47a0f3e31e..daa69edccd 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/FillTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/FillTest.java @@ -24,22 +24,21 @@ This file is part of the iText (R) project. import com.itextpdf.svg.exceptions.SvgProcessingException; import com.itextpdf.test.ITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class FillTest extends SvgIntegrationTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/svg/renderers/impl/FillTest/"; private static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/svg/renderers/impl/FillTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { ITextTest.createDestinationFolder(DESTINATION_FOLDER); } @@ -103,7 +102,7 @@ public void opacityFillTest() throws IOException, InterruptedException { @Test public void eofillUnsuportedAtributeTest() throws IOException, InterruptedException { - Assert.assertThrows(SvgProcessingException.class, + Assertions.assertThrows(SvgProcessingException.class, () -> convertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "eofillUnsuportedAtributeTest") ); } diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/GUnitTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/GUnitTest.java index 58414c7abb..9c76b8550e 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/GUnitTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/GUnitTest.java @@ -23,23 +23,22 @@ This file is part of the iText (R) project. package com.itextpdf.svg.renderers; import com.itextpdf.test.ITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; import java.util.ArrayList; import java.util.List; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class GUnitTest extends SvgIntegrationTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/svg/renderers/impl/gunit/"; private static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/svg/renderers/impl/gunit/"; - @BeforeClass + @BeforeAll public static void beforeClass() { ITextTest.createDestinationFolder(DESTINATION_FOLDER); } @@ -57,7 +56,7 @@ public void meetTheTeam() { } } } - if(assertionErrorsThrown.size() != 0) Assert.fail("At least one compare file was not identical with the result"); + if(assertionErrorsThrown.size() != 0) Assertions.fail("At least one compare file was not identical with the result"); } @Test diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/OpacityTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/OpacityTest.java index 96aeda85b1..d3a7b0dbce 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/OpacityTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/OpacityTest.java @@ -23,21 +23,20 @@ This file is part of the iText (R) project. package com.itextpdf.svg.renderers; import com.itextpdf.test.ITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class OpacityTest extends SvgIntegrationTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/svg/renderers/impl/OpacityTest/"; private static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/svg/renderers/impl/OpacityTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { ITextTest.createDestinationFolder(DESTINATION_FOLDER); } @@ -66,7 +65,7 @@ public void testRGBA() throws IOException, InterruptedException { @Test //TODO DEVSIX-2678 public void testFillOpacityWithComma() throws IOException, InterruptedException { - Assert.assertThrows(NumberFormatException.class, + Assertions.assertThrows(NumberFormatException.class, () -> convertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "testFillOpacityWithComma") ); } @@ -74,7 +73,7 @@ public void testFillOpacityWithComma() throws IOException, InterruptedException @Test //TODO DEVSIX-2678 public void testFillOpacityWithPercents() throws IOException, InterruptedException { - Assert.assertThrows(NumberFormatException.class, + Assertions.assertThrows(NumberFormatException.class, () -> convertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "testFillOpacityWithPercents") ); } @@ -88,7 +87,7 @@ public void testFillOpacity() throws IOException, InterruptedException { @Test //TODO DEVSIX-2679 public void testStrokeOpacityWithComma() throws IOException, InterruptedException { - Assert.assertThrows(Exception.class, + Assertions.assertThrows(Exception.class, () -> convertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "testStrokeOpacityWithComma") ); } @@ -96,7 +95,7 @@ public void testStrokeOpacityWithComma() throws IOException, InterruptedExceptio @Test //TODO DEVSIX-2679 public void testStrokeOpacityWithPercents() throws IOException, InterruptedException { - Assert.assertThrows(NumberFormatException.class, + Assertions.assertThrows(NumberFormatException.class, () -> convertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "testStrokeOpacityWithPercents") ); } diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/StrokeTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/StrokeTest.java index c865a0a30e..7985d00bbf 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/StrokeTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/StrokeTest.java @@ -26,21 +26,20 @@ This file is part of the iText (R) project. import com.itextpdf.test.ITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class StrokeTest extends SvgIntegrationTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/svg/renderers/impl/StrokeTest/"; private static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/svg/renderers/impl/StrokeTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { ITextTest.createDestinationFolder(DESTINATION_FOLDER); } diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/SvgDrawContextTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/SvgDrawContextTest.java index bb459cff18..2a8cdf308e 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/SvgDrawContextTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/SvgDrawContextTest.java @@ -22,6 +22,7 @@ This file is part of the iText (R) project. */ package com.itextpdf.svg.renderers; +import com.itextpdf.kernel.geom.AffineTransform; import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfWriter; import com.itextpdf.kernel.pdf.canvas.PdfCanvas; @@ -30,27 +31,26 @@ This file is part of the iText (R) project. import com.itextpdf.svg.exceptions.SvgProcessingException; import com.itextpdf.svg.renderers.impl.GroupSvgNodeRenderer; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.ByteArrayOutputStream; import java.util.HashMap; import java.util.Map; import java.util.NoSuchElementException; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class SvgDrawContextTest extends ExtendedITextTest { private PdfDocument tokenDoc; private PdfCanvas page1, page2; private SvgDrawContext context; - @Before + @BeforeEach public void setUp() { tokenDoc = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); page1 = new PdfCanvas(tokenDoc.addNewPage()); @@ -58,7 +58,7 @@ public void setUp() { context = new SvgDrawContext(null, null); } - @After + @AfterEach public void tearDown() { // release all resources tokenDoc.close(); @@ -66,66 +66,66 @@ public void tearDown() { @Test public void drawContextEmptyDequeGetFirstTest() { - Assert.assertThrows(NoSuchElementException.class, () -> context.getCurrentCanvas()); + Assertions.assertThrows(NoSuchElementException.class, () -> context.getCurrentCanvas()); } @Test public void drawContextEmptyDequePopTest() { - Assert.assertThrows(NoSuchElementException.class, () -> context.popCanvas()); + Assertions.assertThrows(NoSuchElementException.class, () -> context.popCanvas()); } @Test public void drawContextEmptyStackCountTest() { - Assert.assertEquals(0, context.size()); + Assertions.assertEquals(0, context.size()); } @Test public void drawContextPushCountTest() { context.pushCanvas(page1); - Assert.assertEquals(1, context.size()); + Assertions.assertEquals(1, context.size()); } @Test public void drawContextPushPeekTest() { context.pushCanvas(page1); - Assert.assertEquals(page1, context.getCurrentCanvas()); + Assertions.assertEquals(page1, context.getCurrentCanvas()); } @Test public void drawContextPushPopCountTest() { context.pushCanvas(page1); context.popCanvas(); - Assert.assertEquals(0, context.size()); + Assertions.assertEquals(0, context.size()); } @Test public void drawContextPushPopTest() { context.pushCanvas(page1); - Assert.assertEquals(page1, context.popCanvas()); + Assertions.assertEquals(page1, context.popCanvas()); } @Test public void drawContextPushTwiceCountTest() { context.pushCanvas(page1); context.pushCanvas(page2); - Assert.assertEquals(2, context.size()); + Assertions.assertEquals(2, context.size()); } @Test public void drawContextPushTwicePeekTest() { context.pushCanvas(page1); context.pushCanvas(page2); - Assert.assertEquals(page2, context.getCurrentCanvas()); - Assert.assertEquals(2, context.size()); + Assertions.assertEquals(page2, context.getCurrentCanvas()); + Assertions.assertEquals(2, context.size()); } @Test public void drawContextPushTwicePopTest() { context.pushCanvas(page1); context.pushCanvas(page2); - Assert.assertEquals(page2, context.popCanvas()); - Assert.assertEquals(1, context.size()); - Assert.assertEquals(page1, context.popCanvas()); + Assertions.assertEquals(page2, context.popCanvas()); + Assertions.assertEquals(1, context.size()); + Assertions.assertEquals(page1, context.popCanvas()); } @Test @@ -135,37 +135,37 @@ public void addISvgNodeRender() { this.context.addNamedObject(name, expected); Object actual = this.context.getNamedObject(name); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test public void addNullToNamedObjects() { String name = "expected"; - Exception e = Assert.assertThrows(SvgProcessingException.class, + Exception e = Assertions.assertThrows(SvgProcessingException.class, () -> this.context.addNamedObject(name, null) ); - Assert.assertEquals(SvgExceptionMessageConstant.NAMED_OBJECT_NULL, e.getMessage()); + Assertions.assertEquals(SvgExceptionMessageConstant.NAMED_OBJECT_NULL, e.getMessage()); } @Test public void addNamedObjectWithNullName() { ISvgNodeRenderer expected = new DummySvgNodeRenderer(); - Exception e = Assert.assertThrows(SvgProcessingException.class, + Exception e = Assertions.assertThrows(SvgProcessingException.class, () -> this.context.addNamedObject(null, expected) ); - Assert.assertEquals(SvgExceptionMessageConstant.NAMED_OBJECT_NAME_NULL_OR_EMPTY, e.getMessage()); + Assertions.assertEquals(SvgExceptionMessageConstant.NAMED_OBJECT_NAME_NULL_OR_EMPTY, e.getMessage()); } @Test public void addNamedObjectWithEmptyName() { ISvgNodeRenderer expected = new DummySvgNodeRenderer(); - Exception e = Assert.assertThrows(SvgProcessingException.class, + Exception e = Assertions.assertThrows(SvgProcessingException.class, () -> this.context.addNamedObject("", expected) ); - Assert.assertEquals(SvgExceptionMessageConstant.NAMED_OBJECT_NAME_NULL_OR_EMPTY, e.getMessage()); + Assertions.assertEquals(SvgExceptionMessageConstant.NAMED_OBJECT_NAME_NULL_OR_EMPTY, e.getMessage()); } @Test @@ -174,7 +174,7 @@ public void addNamedRenderer() { String dummyName = "dummy"; this.context.addNamedObject(dummyName, expected); Object actual = this.context.getNamedObject(dummyName); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test @@ -193,9 +193,9 @@ public void addNamedObjects(){ Object actualThree = this.context.getNamedObject(dummyNameThree); Object actualTwo = this.context.getNamedObject(dummyNameTwo); Object actualOne = this.context.getNamedObject(dummyNameOne); - Assert.assertEquals(expectedOne, actualOne); - Assert.assertEquals(expectedTwo, actualTwo); - Assert.assertEquals(expectedThree, actualThree); + Assertions.assertEquals(expectedOne, actualOne); + Assertions.assertEquals(expectedTwo, actualTwo); + Assertions.assertEquals(expectedThree, actualThree); } @Test @@ -207,7 +207,17 @@ public void addNamedObjectAndTryToAddDuplicate(){ context.addNamedObject(dummyName,expectedOne); context.addNamedObject(dummyName,expectedTwo); Object actual = context.getNamedObject(dummyName); - Assert.assertEquals(expectedOne,actual); + Assertions.assertEquals(expectedOne,actual); } + + @Test + public void rootTransformText(){ + AffineTransform at = new AffineTransform(); + Assertions.assertEquals(at, context.getRootTransform()); + + at.setToRotation(Math.toRadians(45)); + context.setRootTransform(at); + Assertions.assertEquals(at, context.getRootTransform()); + } } diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/SvgImageRendererTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/SvgImageRendererTest.java index 5784710c73..67611f77c5 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/SvgImageRendererTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/SvgImageRendererTest.java @@ -36,21 +36,20 @@ This file is part of the iText (R) project. import com.itextpdf.svg.processors.ISvgProcessorResult; import com.itextpdf.svg.processors.impl.DefaultSvgProcessor; import com.itextpdf.svg.xobject.SvgImageXObject; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.FileInputStream; import java.io.IOException; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class SvgImageRendererTest extends SvgIntegrationTest { public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/svg/renderers/SvgImageRendererTest/"; public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/svg/SvgImageRendererTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { createDestinationFolder(DESTINATION_FOLDER); } @@ -72,7 +71,7 @@ public void svgWithSvgTest() throws IOException, InterruptedException { document.add(svgImage); document.add(svgImage); } - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } @Test @@ -92,6 +91,6 @@ public void customSvgImageTest() throws IOException, InterruptedException { document.add(svgImage); document.add(svgImage); } - Assert.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); + Assertions.assertNull(new CompareTool().compareByContent(outFileName, cmpFileName, DESTINATION_FOLDER, "diff")); } } diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/SvgIntegrationTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/SvgIntegrationTest.java index ff8f036d1f..c5da9d5a8a 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/SvgIntegrationTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/SvgIntegrationTest.java @@ -32,16 +32,15 @@ This file is part of the iText (R) project. import com.itextpdf.svg.processors.ISvgConverterProperties; import com.itextpdf.svg.processors.impl.SvgConverterProperties; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import org.junit.Assert; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class SvgIntegrationTest extends ExtendedITextTest { public void convert(InputStream svg, OutputStream pdfOutputStream) throws IOException { @@ -124,7 +123,7 @@ public void convertAndCompareSinglePage(String src, String dest, String fileName } protected void compare(String filename, String sourceFolder, String destinationFolder) throws IOException, InterruptedException { - Assert.assertNull(new CompareTool() + Assertions.assertNull(new CompareTool() .compareByContent(destinationFolder + filename + ".pdf", sourceFolder + "cmp_" + filename + ".pdf", destinationFolder, "diff_")); diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/TransformationApplicationTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/TransformationApplicationTest.java index 01c96d807d..38b93c3f18 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/TransformationApplicationTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/TransformationApplicationTest.java @@ -30,18 +30,17 @@ This file is part of the iText (R) project. import com.itextpdf.svg.exceptions.SvgExceptionMessageConstant; import com.itextpdf.svg.renderers.impl.AbstractSvgNodeRenderer; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.ByteArrayOutputStream; import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class TransformationApplicationTest extends ExtendedITextTest { @Test @@ -80,6 +79,6 @@ protected void doDraw(SvgDrawContext context) { byte[] actual = canvas.getContentStream().getBytes(true); - Assert.assertArrayEquals(expected, actual); + Assertions.assertArrayEquals(expected, actual); } } diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/TransparencyTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/TransparencyTest.java index 497fc220f6..b5c94021f5 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/TransparencyTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/TransparencyTest.java @@ -36,17 +36,16 @@ This file is part of the iText (R) project. import com.itextpdf.svg.renderers.impl.AbstractSvgNodeRenderer; import com.itextpdf.svg.renderers.impl.CircleSvgNodeRenderer; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.ByteArrayOutputStream; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class TransparencyTest extends ExtendedITextTest { private static final PdfName DEFAULT_RESOURCE_NAME = new PdfName("Gs1"); @@ -56,7 +55,7 @@ public class TransparencyTest extends ExtendedITextTest { private PdfCanvas cv; private SvgDrawContext sdc; - @Before + @BeforeEach public void setupDrawContextAndCanvas() { sdc = new SvgDrawContext(new ResourceResolver(""), new FontProvider()); @@ -68,7 +67,7 @@ public void setupDrawContextAndCanvas() { sdc.pushCanvas(cv); } - @After + @AfterEach public void close() { cv.getDocument().close(); } @@ -80,7 +79,7 @@ public void noOpacitySet() { renderer.draw(sdc); PdfResources resources = cv.getResources(); - Assert.assertTrue(resources.getResourceNames().isEmpty()); + Assertions.assertTrue(resources.getResourceNames().isEmpty()); } @Test @@ -92,10 +91,10 @@ public void strokeOpacitySetWithStroke() { renderer.draw(sdc); PdfResources resources = cv.getResources(); - Assert.assertEquals(1, resources.getResourceNames().size()); + Assertions.assertEquals(1, resources.getResourceNames().size()); PdfDictionary resDic = (PdfDictionary) resources.getResourceObject(PdfName.ExtGState, DEFAULT_RESOURCE_NAME); - Assert.assertEquals(1, resDic.size()); - Assert.assertEquals(resDic.get(STROKE_OPAC), new PdfNumber(0.75)); + Assertions.assertEquals(1, resDic.size()); + Assertions.assertEquals(resDic.get(STROKE_OPAC), new PdfNumber(0.75)); } @Test @@ -106,7 +105,7 @@ public void strokeOpacitySetWithoutStroke() { renderer.draw(sdc); PdfResources resources = cv.getResources(); - Assert.assertTrue(resources.getResourceNames().isEmpty()); + Assertions.assertTrue(resources.getResourceNames().isEmpty()); } @Test @@ -118,7 +117,7 @@ public void strokeOpacitySetWithFill() { renderer.draw(sdc); PdfResources resources = cv.getResources(); - Assert.assertTrue(resources.getResourceNames().isEmpty()); + Assertions.assertTrue(resources.getResourceNames().isEmpty()); } @Test @@ -130,7 +129,7 @@ public void strokeOpacitySetWithNoneStroke() { renderer.draw(sdc); PdfResources resources = cv.getResources(); - Assert.assertTrue(resources.getResourceNames().isEmpty()); + Assertions.assertTrue(resources.getResourceNames().isEmpty()); } @@ -143,10 +142,10 @@ public void fillOpacitySetWithFill() { renderer.draw(sdc); PdfResources resources = cv.getResources(); - Assert.assertEquals(1, resources.getResourceNames().size()); + Assertions.assertEquals(1, resources.getResourceNames().size()); PdfDictionary resDic = (PdfDictionary) resources.getResourceObject(PdfName.ExtGState, DEFAULT_RESOURCE_NAME); - Assert.assertEquals(1, resDic.size()); - Assert.assertEquals(resDic.get(FILL_OPAC), new PdfNumber(0.75)); + Assertions.assertEquals(1, resDic.size()); + Assertions.assertEquals(resDic.get(FILL_OPAC), new PdfNumber(0.75)); } @Test @@ -157,10 +156,10 @@ public void fillOpacitySetWithoutFill() { renderer.draw(sdc); PdfResources resources = cv.getResources(); - Assert.assertEquals(1, resources.getResourceNames().size()); + Assertions.assertEquals(1, resources.getResourceNames().size()); PdfDictionary resDic = (PdfDictionary) resources.getResourceObject(PdfName.ExtGState, DEFAULT_RESOURCE_NAME); - Assert.assertEquals(1, resDic.size()); - Assert.assertEquals(resDic.get(FILL_OPAC), new PdfNumber(0.75)); + Assertions.assertEquals(1, resDic.size()); + Assertions.assertEquals(resDic.get(FILL_OPAC), new PdfNumber(0.75)); } @Test @@ -172,7 +171,7 @@ public void fillOpacitySetWithNoneFill() { renderer.draw(sdc); PdfResources resources = cv.getResources(); - Assert.assertTrue(resources.getResourceNames().isEmpty()); + Assertions.assertTrue(resources.getResourceNames().isEmpty()); } @Test @@ -184,10 +183,10 @@ public void fillOpacitySetWithStroke() { renderer.draw(sdc); PdfResources resources = cv.getResources(); - Assert.assertEquals(1, resources.getResourceNames().size()); + Assertions.assertEquals(1, resources.getResourceNames().size()); PdfDictionary resDic = (PdfDictionary) resources.getResourceObject(PdfName.ExtGState, DEFAULT_RESOURCE_NAME); - Assert.assertEquals(1, resDic.size()); - Assert.assertEquals(resDic.get(FILL_OPAC), new PdfNumber(0.75)); + Assertions.assertEquals(1, resDic.size()); + Assertions.assertEquals(resDic.get(FILL_OPAC), new PdfNumber(0.75)); } @Test @@ -201,11 +200,11 @@ public void fillAndStrokeOpacitySetWithStrokeAndFill() { renderer.draw(sdc); PdfResources resources = cv.getResources(); - Assert.assertEquals(1, resources.getResourceNames().size()); + Assertions.assertEquals(1, resources.getResourceNames().size()); PdfDictionary resDic = (PdfDictionary) resources.getResourceObject(PdfName.ExtGState, DEFAULT_RESOURCE_NAME); - Assert.assertEquals(2, resDic.size()); - Assert.assertEquals(resDic.get(FILL_OPAC), new PdfNumber(0.75)); - Assert.assertEquals(resDic.get(STROKE_OPAC), new PdfNumber(0.75)); + Assertions.assertEquals(2, resDic.size()); + Assertions.assertEquals(resDic.get(FILL_OPAC), new PdfNumber(0.75)); + Assertions.assertEquals(resDic.get(STROKE_OPAC), new PdfNumber(0.75)); } @@ -216,7 +215,7 @@ public void noOpacitySetRGB() { renderer.draw(sdc); PdfResources resources = cv.getResources(); - Assert.assertTrue(resources.getResourceNames().isEmpty()); + Assertions.assertTrue(resources.getResourceNames().isEmpty()); } @Test @@ -228,10 +227,10 @@ public void strokeOpacitySetWithStrokeRGB() { renderer.draw(sdc); PdfResources resources = cv.getResources(); - Assert.assertEquals(1, resources.getResourceNames().size()); + Assertions.assertEquals(1, resources.getResourceNames().size()); PdfDictionary resDic = (PdfDictionary) resources.getResourceObject(PdfName.ExtGState, DEFAULT_RESOURCE_NAME); - Assert.assertEquals(1, resDic.size()); - Assert.assertEquals(resDic.get(STROKE_OPAC), new PdfNumber(0.75)); + Assertions.assertEquals(1, resDic.size()); + Assertions.assertEquals(resDic.get(STROKE_OPAC), new PdfNumber(0.75)); } @Test @@ -242,7 +241,7 @@ public void strokeOpacitySetWithoutStrokeRGB() { renderer.draw(sdc); PdfResources resources = cv.getResources(); - Assert.assertTrue(resources.getResourceNames().isEmpty()); + Assertions.assertTrue(resources.getResourceNames().isEmpty()); } @Test @@ -254,7 +253,7 @@ public void strokeOpacitySetWithFillRGB() { renderer.draw(sdc); PdfResources resources = cv.getResources(); - Assert.assertTrue(resources.getResourceNames().isEmpty()); + Assertions.assertTrue(resources.getResourceNames().isEmpty()); } @Test @@ -266,7 +265,7 @@ public void strokeOpacitySetWithNoneStrokeRGB() { renderer.draw(sdc); PdfResources resources = cv.getResources(); - Assert.assertTrue(resources.getResourceNames().isEmpty()); + Assertions.assertTrue(resources.getResourceNames().isEmpty()); } @@ -279,10 +278,10 @@ public void fillOpacitySetWithFillRGB() { renderer.draw(sdc); PdfResources resources = cv.getResources(); - Assert.assertEquals(1, resources.getResourceNames().size()); + Assertions.assertEquals(1, resources.getResourceNames().size()); PdfDictionary resDic = (PdfDictionary) resources.getResourceObject(PdfName.ExtGState, DEFAULT_RESOURCE_NAME); - Assert.assertEquals(1, resDic.size()); - Assert.assertEquals(resDic.get(FILL_OPAC), new PdfNumber(0.75)); + Assertions.assertEquals(1, resDic.size()); + Assertions.assertEquals(resDic.get(FILL_OPAC), new PdfNumber(0.75)); } @Test @@ -293,10 +292,10 @@ public void fillOpacitySetWithoutFillRGB() { renderer.draw(sdc); PdfResources resources = cv.getResources(); - Assert.assertEquals(1, resources.getResourceNames().size()); + Assertions.assertEquals(1, resources.getResourceNames().size()); PdfDictionary resDic = (PdfDictionary) resources.getResourceObject(PdfName.ExtGState, DEFAULT_RESOURCE_NAME); - Assert.assertEquals(1, resDic.size()); - Assert.assertEquals(resDic.get(FILL_OPAC), new PdfNumber(0.75)); + Assertions.assertEquals(1, resDic.size()); + Assertions.assertEquals(resDic.get(FILL_OPAC), new PdfNumber(0.75)); } @Test @@ -308,7 +307,7 @@ public void fillOpacitySetWithNoneFillRGB() { renderer.draw(sdc); PdfResources resources = cv.getResources(); - Assert.assertTrue(resources.getResourceNames().isEmpty()); + Assertions.assertTrue(resources.getResourceNames().isEmpty()); } @Test @@ -320,10 +319,10 @@ public void fillOpacitySetWithStrokeRGB() { renderer.draw(sdc); PdfResources resources = cv.getResources(); - Assert.assertEquals(1, resources.getResourceNames().size()); + Assertions.assertEquals(1, resources.getResourceNames().size()); PdfDictionary resDic = (PdfDictionary) resources.getResourceObject(PdfName.ExtGState, DEFAULT_RESOURCE_NAME); - Assert.assertEquals(1, resDic.size()); - Assert.assertEquals(resDic.get(FILL_OPAC), new PdfNumber(0.75)); + Assertions.assertEquals(1, resDic.size()); + Assertions.assertEquals(resDic.get(FILL_OPAC), new PdfNumber(0.75)); } @Test @@ -337,11 +336,11 @@ public void fillAndStrokeOpacitySetWithStrokeAndFillRGB() { renderer.draw(sdc); PdfResources resources = cv.getResources(); - Assert.assertEquals(1, resources.getResourceNames().size()); + Assertions.assertEquals(1, resources.getResourceNames().size()); PdfDictionary resDic = (PdfDictionary) resources.getResourceObject(PdfName.ExtGState, DEFAULT_RESOURCE_NAME); - Assert.assertEquals(2, resDic.size()); - Assert.assertEquals(resDic.get(FILL_OPAC), new PdfNumber(0.75)); - Assert.assertEquals(resDic.get(STROKE_OPAC), new PdfNumber(0.75)); + Assertions.assertEquals(2, resDic.size()); + Assertions.assertEquals(resDic.get(FILL_OPAC), new PdfNumber(0.75)); + Assertions.assertEquals(resDic.get(STROKE_OPAC), new PdfNumber(0.75)); } @Test @@ -351,10 +350,10 @@ public void noOpacitySetRGBA() { renderer.draw(sdc); PdfResources resources = cv.getResources(); - Assert.assertEquals(1, resources.getResourceNames().size()); + Assertions.assertEquals(1, resources.getResourceNames().size()); PdfDictionary resDic = (PdfDictionary) resources.getResourceObject(PdfName.ExtGState, DEFAULT_RESOURCE_NAME); - Assert.assertEquals(1, resDic.size()); - Assert.assertEquals(resDic.get(STROKE_OPAC), new PdfNumber(0.75)); + Assertions.assertEquals(1, resDic.size()); + Assertions.assertEquals(resDic.get(STROKE_OPAC), new PdfNumber(0.75)); } @Test @@ -366,10 +365,10 @@ public void strokeOpacitySetWithStrokeRGBA() { renderer.draw(sdc); PdfResources resources = cv.getResources(); - Assert.assertEquals(1, resources.getResourceNames().size()); + Assertions.assertEquals(1, resources.getResourceNames().size()); PdfDictionary resDic = (PdfDictionary) resources.getResourceObject(PdfName.ExtGState, DEFAULT_RESOURCE_NAME); - Assert.assertEquals(1, resDic.size()); - Assert.assertEquals(resDic.get(STROKE_OPAC), new PdfNumber(0.5625)); + Assertions.assertEquals(1, resDic.size()); + Assertions.assertEquals(resDic.get(STROKE_OPAC), new PdfNumber(0.5625)); } @Test @@ -380,7 +379,7 @@ public void strokeOpacitySetWithoutStrokeRGBA() { renderer.draw(sdc); PdfResources resources = cv.getResources(); - Assert.assertTrue(resources.getResourceNames().isEmpty()); + Assertions.assertTrue(resources.getResourceNames().isEmpty()); } @Test @@ -392,10 +391,10 @@ public void strokeOpacitySetWithFillRGBA() { renderer.draw(sdc); PdfResources resources = cv.getResources(); - Assert.assertEquals(1, resources.getResourceNames().size()); + Assertions.assertEquals(1, resources.getResourceNames().size()); PdfDictionary resDic = (PdfDictionary) resources.getResourceObject(PdfName.ExtGState, DEFAULT_RESOURCE_NAME); - Assert.assertEquals(1, resDic.size()); - Assert.assertEquals(resDic.get(FILL_OPAC), new PdfNumber(0.75)); + Assertions.assertEquals(1, resDic.size()); + Assertions.assertEquals(resDic.get(FILL_OPAC), new PdfNumber(0.75)); } @Test @@ -407,7 +406,7 @@ public void strokeOpacitySetWithNoneStrokeRGBA() { renderer.draw(sdc); PdfResources resources = cv.getResources(); - Assert.assertTrue(resources.getResourceNames().isEmpty()); + Assertions.assertTrue(resources.getResourceNames().isEmpty()); } @@ -420,10 +419,10 @@ public void fillOpacitySetWithFillRGBA() { renderer.draw(sdc); PdfResources resources = cv.getResources(); - Assert.assertEquals(1, resources.getResourceNames().size()); + Assertions.assertEquals(1, resources.getResourceNames().size()); PdfDictionary resDic = (PdfDictionary) resources.getResourceObject(PdfName.ExtGState, DEFAULT_RESOURCE_NAME); - Assert.assertEquals(1, resDic.size()); - Assert.assertEquals(resDic.get(FILL_OPAC), new PdfNumber(0.5625)); + Assertions.assertEquals(1, resDic.size()); + Assertions.assertEquals(resDic.get(FILL_OPAC), new PdfNumber(0.5625)); } @Test @@ -434,10 +433,10 @@ public void fillOpacitySetWithoutFillRGBA() { renderer.draw(sdc); PdfResources resources = cv.getResources(); - Assert.assertEquals(1, resources.getResourceNames().size()); + Assertions.assertEquals(1, resources.getResourceNames().size()); PdfDictionary resDic = (PdfDictionary) resources.getResourceObject(PdfName.ExtGState, DEFAULT_RESOURCE_NAME); - Assert.assertEquals(1, resDic.size()); - Assert.assertEquals(resDic.get(FILL_OPAC), new PdfNumber(0.75)); + Assertions.assertEquals(1, resDic.size()); + Assertions.assertEquals(resDic.get(FILL_OPAC), new PdfNumber(0.75)); } @Test @@ -449,7 +448,7 @@ public void fillOpacitySetWithNoneFillRGBA() { renderer.draw(sdc); PdfResources resources = cv.getResources(); - Assert.assertTrue(resources.getResourceNames().isEmpty()); + Assertions.assertTrue(resources.getResourceNames().isEmpty()); } @Test @@ -461,11 +460,11 @@ public void fillOpacitySetWithStrokeRGBA() { renderer.draw(sdc); PdfResources resources = cv.getResources(); - Assert.assertEquals(1, resources.getResourceNames().size()); + Assertions.assertEquals(1, resources.getResourceNames().size()); PdfDictionary resDic = (PdfDictionary) resources.getResourceObject(PdfName.ExtGState, DEFAULT_RESOURCE_NAME); - Assert.assertEquals(2, resDic.size()); - Assert.assertEquals(resDic.get(STROKE_OPAC), new PdfNumber(0.75)); - Assert.assertEquals(resDic.get(FILL_OPAC), new PdfNumber(0.75)); + Assertions.assertEquals(2, resDic.size()); + Assertions.assertEquals(resDic.get(STROKE_OPAC), new PdfNumber(0.75)); + Assertions.assertEquals(resDic.get(FILL_OPAC), new PdfNumber(0.75)); } @Test @@ -479,11 +478,11 @@ public void fillAndStrokeOpacitySetWithStrokeAndFillRGBA() { renderer.draw(sdc); PdfResources resources = cv.getResources(); - Assert.assertEquals(1, resources.getResourceNames().size()); + Assertions.assertEquals(1, resources.getResourceNames().size()); PdfDictionary resDic = (PdfDictionary) resources.getResourceObject(PdfName.ExtGState, DEFAULT_RESOURCE_NAME); - Assert.assertEquals(2, resDic.size()); - Assert.assertEquals(resDic.get(FILL_OPAC), new PdfNumber(0.5625)); - Assert.assertEquals(resDic.get(STROKE_OPAC), new PdfNumber(0.5625)); + Assertions.assertEquals(2, resDic.size()); + Assertions.assertEquals(resDic.get(FILL_OPAC), new PdfNumber(0.5625)); + Assertions.assertEquals(resDic.get(STROKE_OPAC), new PdfNumber(0.5625)); } @Test @@ -494,10 +493,10 @@ public void noOpacitySetWithStrokeRGBA() { renderer.draw(sdc); PdfResources resources = cv.getResources(); - Assert.assertEquals(1, resources.getResourceNames().size()); + Assertions.assertEquals(1, resources.getResourceNames().size()); PdfDictionary resDic = (PdfDictionary) resources.getResourceObject(PdfName.ExtGState, DEFAULT_RESOURCE_NAME); - Assert.assertEquals(1, resDic.size()); - Assert.assertEquals(resDic.get(STROKE_OPAC), new PdfNumber(0.75)); + Assertions.assertEquals(1, resDic.size()); + Assertions.assertEquals(resDic.get(STROKE_OPAC), new PdfNumber(0.75)); } @Test @@ -508,7 +507,7 @@ public void noOpacitySetWithoutStrokeRGBA() { renderer.draw(sdc); PdfResources resources = cv.getResources(); - Assert.assertTrue(resources.getResourceNames().isEmpty()); + Assertions.assertTrue(resources.getResourceNames().isEmpty()); } @Test @@ -519,10 +518,10 @@ public void noOpacitySetWithFillRGBA() { renderer.draw(sdc); PdfResources resources = cv.getResources(); - Assert.assertEquals(1, resources.getResourceNames().size()); + Assertions.assertEquals(1, resources.getResourceNames().size()); PdfDictionary resDic = (PdfDictionary) resources.getResourceObject(PdfName.ExtGState, DEFAULT_RESOURCE_NAME); - Assert.assertEquals(1, resDic.size()); - Assert.assertEquals(resDic.get(FILL_OPAC), new PdfNumber(0.75)); + Assertions.assertEquals(1, resDic.size()); + Assertions.assertEquals(resDic.get(FILL_OPAC), new PdfNumber(0.75)); } @Test @@ -534,7 +533,7 @@ public void noOpacitySetWithNoneStrokeRGBA() { renderer.draw(sdc); PdfResources resources = cv.getResources(); - Assert.assertTrue(resources.getResourceNames().isEmpty()); + Assertions.assertTrue(resources.getResourceNames().isEmpty()); } @Test @@ -545,7 +544,7 @@ public void noOpacitySetWithNoneFillRGBA() { renderer.draw(sdc); PdfResources resources = cv.getResources(); - Assert.assertTrue(resources.getResourceNames().isEmpty()); + Assertions.assertTrue(resources.getResourceNames().isEmpty()); } @Test @@ -557,10 +556,10 @@ public void noAndStrokeOpacitySetWithStrokeAndFillRGBA() { renderer.draw(sdc); PdfResources resources = cv.getResources(); - Assert.assertEquals(1, resources.getResourceNames().size()); + Assertions.assertEquals(1, resources.getResourceNames().size()); PdfDictionary resDic = (PdfDictionary) resources.getResourceObject(PdfName.ExtGState, DEFAULT_RESOURCE_NAME); - Assert.assertEquals(2, resDic.size()); - Assert.assertEquals(resDic.get(FILL_OPAC), new PdfNumber(0.75)); - Assert.assertEquals(resDic.get(STROKE_OPAC), new PdfNumber(0.75)); + Assertions.assertEquals(2, resDic.size()); + Assertions.assertEquals(resDic.get(FILL_OPAC), new PdfNumber(0.75)); + Assertions.assertEquals(resDic.get(STROKE_OPAC), new PdfNumber(0.75)); } } diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/factories/DefaultSvgNodeRendererFactoryTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/factories/DefaultSvgNodeRendererFactoryTest.java index 7990e825f0..56bae8a002 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/factories/DefaultSvgNodeRendererFactoryTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/factories/DefaultSvgNodeRendererFactoryTest.java @@ -25,22 +25,21 @@ This file is part of the iText (R) project. import com.itextpdf.svg.exceptions.SvgExceptionMessageConstant; import com.itextpdf.svg.exceptions.SvgProcessingException; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class DefaultSvgNodeRendererFactoryTest extends ExtendedITextTest { @Test public void createSvgNodeRenderer() { ISvgNodeRendererFactory nodeRendererFactory = new DefaultSvgNodeRendererFactory(); - Exception e = Assert.assertThrows(SvgProcessingException.class, + Exception e = Assertions.assertThrows(SvgProcessingException.class, () -> nodeRendererFactory.createSvgNodeRendererForTag(null, null) ); - Assert.assertEquals(SvgExceptionMessageConstant.TAG_PARAMETER_NULL, e.getMessage()); + Assertions.assertEquals(SvgExceptionMessageConstant.TAG_PARAMETER_NULL, e.getMessage()); } } diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/factories/DefaultSvgNodeRendererMapperTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/factories/DefaultSvgNodeRendererMapperTest.java index 8e818dd142..f2d89bb757 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/factories/DefaultSvgNodeRendererMapperTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/factories/DefaultSvgNodeRendererMapperTest.java @@ -23,13 +23,12 @@ This file is part of the iText (R) project. package com.itextpdf.svg.renderers.factories; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class DefaultSvgNodeRendererMapperTest extends ExtendedITextTest { private DefaultSvgNodeRendererMapper mapper = new DefaultSvgNodeRendererMapper(); @@ -37,12 +36,12 @@ public class DefaultSvgNodeRendererMapperTest extends ExtendedITextTest { @Test public void mapperNotEmptyTest() { boolean result = mapper.getMapping().isEmpty(); - Assert.assertFalse(result); + Assertions.assertFalse(result); } @Test public void ignoredTagsNotEmptyTest() { boolean result = mapper.getIgnoredTags().isEmpty(); - Assert.assertFalse(result); + Assertions.assertFalse(result); } } diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/impl/AnimationSvgTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/impl/AnimationSvgTest.java index 8eb8e37b27..306f4d119a 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/impl/AnimationSvgTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/impl/AnimationSvgTest.java @@ -29,16 +29,15 @@ This file is part of the iText (R) project. import com.itextpdf.test.ITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class AnimationSvgTest extends SvgIntegrationTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/svg/renderers/impl/AnimationSvgTest/"; @@ -46,12 +45,12 @@ public class AnimationSvgTest extends SvgIntegrationTest { private ISvgConverterProperties properties; - @BeforeClass + @BeforeAll public static void beforeClass() { ITextTest.createDestinationFolder(DESTINATION_FOLDER); } - @Before + @BeforeEach public void before() { properties = new SvgConverterProperties().setBaseUri(SOURCE_FOLDER); } diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/impl/CircleNodeRendererIntegrationTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/impl/CircleNodeRendererIntegrationTest.java index c1f8047795..995984bb24 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/impl/CircleNodeRendererIntegrationTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/impl/CircleNodeRendererIntegrationTest.java @@ -25,19 +25,18 @@ This file is part of the iText (R) project. import com.itextpdf.io.exceptions.IOException; import com.itextpdf.svg.renderers.SvgIntegrationTest; import com.itextpdf.test.ITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class CircleNodeRendererIntegrationTest extends SvgIntegrationTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/svg/renderers/impl/CircleSvgNodeRendererTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/svg/renderers/impl/CircleSvgNodeRendererTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { ITextTest.createDestinationFolder(destinationFolder); } diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/impl/ClipPathSvgNodeRendererIntegrationTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/impl/ClipPathSvgNodeRendererIntegrationTest.java index 2b4ed8d982..2cfd0d9bdf 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/impl/ClipPathSvgNodeRendererIntegrationTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/impl/ClipPathSvgNodeRendererIntegrationTest.java @@ -25,15 +25,14 @@ This file is part of the iText (R) project. import com.itextpdf.svg.processors.impl.SvgConverterProperties; import com.itextpdf.svg.renderers.SvgIntegrationTest; import com.itextpdf.test.ITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class ClipPathSvgNodeRendererIntegrationTest extends SvgIntegrationTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/svg/renderers/impl/ClipPathTest/"; @@ -41,7 +40,7 @@ public class ClipPathSvgNodeRendererIntegrationTest extends SvgIntegrationTest { private SvgConverterProperties properties; - @BeforeClass + @BeforeAll public static void beforeClass() { ITextTest.createDestinationFolder(destinationFolder); } diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/impl/ClipPathSvgNodeRendererLowLevelIntegrationTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/impl/ClipPathSvgNodeRendererLowLevelIntegrationTest.java index badf8f311f..5df185ef5a 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/impl/ClipPathSvgNodeRendererLowLevelIntegrationTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/impl/ClipPathSvgNodeRendererLowLevelIntegrationTest.java @@ -32,23 +32,22 @@ This file is part of the iText (R) project. import com.itextpdf.svg.renderers.ISvgNodeRenderer; import com.itextpdf.svg.renderers.SvgDrawContext; import com.itextpdf.svg.renderers.SvgIntegrationTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.ByteArrayOutputStream; import java.util.HashMap; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class ClipPathSvgNodeRendererLowLevelIntegrationTest extends SvgIntegrationTest { private PdfCanvas cv; private SvgDrawContext sdc; - @Before + @BeforeEach public void setupDrawContextAndCanvas() { sdc = new SvgDrawContext(new ResourceResolver(""), new FontProvider()); @@ -60,7 +59,7 @@ public void setupDrawContextAndCanvas() { sdc.pushCanvas(cv); } - @After + @AfterEach public void close() { cv.getDocument().close(); } @@ -70,7 +69,7 @@ public void testEmptyClipPathRendererNotDrawn() { ClipPathSvgNodeRenderer clipRenderer = new ClipPathSvgNodeRenderer(); clipRenderer.setAttributesAndStyles(new HashMap<String, String>()); clipRenderer.draw(sdc); - Assert.assertEquals(0, cv.getContentStream().getBytes().length); + Assertions.assertEquals(0, cv.getContentStream().getBytes().length); } @Test @@ -78,7 +77,7 @@ public void testEmptyEoClipPathRendererNotDrawn() { ClipPathSvgNodeRenderer clipRenderer = new ClipPathSvgNodeRenderer(); clipRenderer.setAttribute(SvgConstants.Attributes.CLIP_RULE, SvgConstants.Values.FILL_RULE_EVEN_ODD); clipRenderer.draw(sdc); - Assert.assertEquals(0, cv.getContentStream().getBytes().length); + Assertions.assertEquals(0, cv.getContentStream().getBytes().length); } @Test @@ -91,7 +90,7 @@ public void testRectClipPathRenderer() { clipRenderer.addChild(rectRenderer); clipRenderer.draw(sdc); - Assert.assertEquals("q\n% rect\n0 0 300 300 re\nW\nn\nQ\n", new String(cv.getContentStream().getBytes())); + Assertions.assertEquals("q\n% rect\n0 0 300 300 re\nW\nn\nQ\n", new String(cv.getContentStream().getBytes())); } @Test @@ -105,7 +104,7 @@ public void testRectClipPathEoRendererNoChange() { clipRenderer.addChild(rectRenderer); clipRenderer.draw(sdc); - Assert.assertEquals("q\n% rect\n0 0 300 300 re\nW\nn\nQ\n", new String(cv.getContentStream().getBytes())); + Assertions.assertEquals("q\n% rect\n0 0 300 300 re\nW\nn\nQ\n", new String(cv.getContentStream().getBytes())); } @Test @@ -119,7 +118,7 @@ public void testRectEoClipPathRenderer() { clipRenderer.addChild(rectRenderer); clipRenderer.draw(sdc); - Assert.assertEquals("q\n% rect\n0 0 300 300 re\nW*\nn\nQ\n", new String(cv.getContentStream().getBytes())); + Assertions.assertEquals("q\n% rect\n0 0 300 300 re\nW*\nn\nQ\n", new String(cv.getContentStream().getBytes())); } @Test @@ -153,7 +152,7 @@ public void testAppliedClipPathRenderer() { "34.79 -63 63 -34.79 63 0 c\n" + "f\n" + "Q\n"; - Assert.assertEquals(expected, new String(cv.getContentStream().getBytes())); + Assertions.assertEquals(expected, new String(cv.getContentStream().getBytes())); } @Test @@ -192,7 +191,7 @@ public void testAppliedGroupClipPathRenderer() { "f\n" + "Q\n" + "Q\n"; - Assert.assertEquals(expected, new String(cv.getContentStream().getBytes())); + Assertions.assertEquals(expected, new String(cv.getContentStream().getBytes())); } @Test @@ -251,6 +250,6 @@ public void testEoAppliedGroupClipPathRenderer() { "f\n" + "Q\n" + "Q\n"; - Assert.assertEquals(expected, new String(cv.getContentStream().getBytes())); + Assertions.assertEquals(expected, new String(cv.getContentStream().getBytes())); } } diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/impl/ClipPathSvgNodeRendererUnitTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/impl/ClipPathSvgNodeRendererUnitTest.java index 804f6efc1f..ea9ec5871e 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/impl/ClipPathSvgNodeRendererUnitTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/impl/ClipPathSvgNodeRendererUnitTest.java @@ -23,19 +23,18 @@ This file is part of the iText (R) project. package com.itextpdf.svg.renderers.impl; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class ClipPathSvgNodeRendererUnitTest extends ExtendedITextTest { @Test public void noObjectBoundingBoxTest() { ClipPathSvgNodeRenderer renderer = new ClipPathSvgNodeRenderer(); - Assert.assertNull(renderer.getObjectBoundingBox(null)); + Assertions.assertNull(renderer.getObjectBoundingBox(null)); } } diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/impl/DefsSvgNodeRendererIntegrationTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/impl/DefsSvgNodeRendererIntegrationTest.java index bdee7e9f7b..0218fb16fe 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/impl/DefsSvgNodeRendererIntegrationTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/impl/DefsSvgNodeRendererIntegrationTest.java @@ -24,21 +24,20 @@ This file is part of the iText (R) project. import com.itextpdf.svg.renderers.SvgIntegrationTest; import com.itextpdf.test.ITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class DefsSvgNodeRendererIntegrationTest extends SvgIntegrationTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/svg/renderers/impl/DefsSvgNodeRendererTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/svg/renderers/impl/DefsSvgNodeRendererTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { ITextTest.createDestinationFolder(destinationFolder); } diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/impl/DefsSvgNodeRendererUnitTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/impl/DefsSvgNodeRendererUnitTest.java index 751c1c2b9a..83e4ccaf62 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/impl/DefsSvgNodeRendererUnitTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/impl/DefsSvgNodeRendererUnitTest.java @@ -28,15 +28,14 @@ This file is part of the iText (R) project. import com.itextpdf.svg.processors.ISvgProcessorResult; import com.itextpdf.svg.processors.impl.DefaultSvgProcessor; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.FileInputStream; import java.io.IOException; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class DefsSvgNodeRendererUnitTest extends ExtendedITextTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/svg/renderers/impl/DefsSvgNodeRendererTest/"; @@ -46,7 +45,7 @@ public void processDefsNoChildrenTest() throws IOException { INode parsedSvg = SvgConverter.parse(FileUtil.getInputStreamForFile(sourceFolder + "onlyDefsWithNoChildren.svg")); ISvgProcessorResult result = new DefaultSvgProcessor().process(parsedSvg, null); - Assert.assertTrue(result.getNamedObjects().isEmpty()); + Assertions.assertTrue(result.getNamedObjects().isEmpty()); } @Test @@ -54,7 +53,7 @@ public void processDefsOneChildTest() throws IOException { INode parsedSvg = SvgConverter.parse(FileUtil.getInputStreamForFile(sourceFolder + "onlyDefsWithOneChild.svg")); ISvgProcessorResult result = new DefaultSvgProcessor().process(parsedSvg, null); - Assert.assertTrue(result.getNamedObjects().get("circle1") instanceof CircleSvgNodeRenderer); + Assertions.assertTrue(result.getNamedObjects().get("circle1") instanceof CircleSvgNodeRenderer); } @Test @@ -62,9 +61,9 @@ public void processDefsMultipleChildrenTest() throws IOException { INode parsedSvg = SvgConverter.parse(FileUtil.getInputStreamForFile(sourceFolder + "onlyDefsWithMultipleChildren.svg")); ISvgProcessorResult result = new DefaultSvgProcessor().process(parsedSvg, null); - Assert.assertTrue(result.getNamedObjects().get("circle1") instanceof CircleSvgNodeRenderer); - Assert.assertTrue(result.getNamedObjects().get("line1") instanceof LineSvgNodeRenderer); - Assert.assertTrue(result.getNamedObjects().get("rect1") instanceof RectangleSvgNodeRenderer); + Assertions.assertTrue(result.getNamedObjects().get("circle1") instanceof CircleSvgNodeRenderer); + Assertions.assertTrue(result.getNamedObjects().get("line1") instanceof LineSvgNodeRenderer); + Assertions.assertTrue(result.getNamedObjects().get("rect1") instanceof RectangleSvgNodeRenderer); } @Test @@ -72,12 +71,12 @@ public void processDefsParentShouldBeNullTest() throws IOException { INode parsedSvg = SvgConverter.parse(FileUtil.getInputStreamForFile(sourceFolder + "onlyDefsWithOneChild.svg")); ISvgProcessorResult result = new DefaultSvgProcessor().process(parsedSvg, null); - Assert.assertNull(result.getNamedObjects().get("circle1").getParent()); + Assertions.assertNull(result.getNamedObjects().get("circle1").getParent()); } @Test public void noObjectBoundingBoxTest() { DefsSvgNodeRenderer renderer = new DefsSvgNodeRenderer(); - Assert.assertNull(renderer.getObjectBoundingBox(null)); + Assertions.assertNull(renderer.getObjectBoundingBox(null)); } } diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/impl/DeviceCmykSvgTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/impl/DeviceCmykSvgTest.java index 77002ca405..5c2cdad7db 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/impl/DeviceCmykSvgTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/impl/DeviceCmykSvgTest.java @@ -35,10 +35,10 @@ This file is part of the iText (R) project. import com.itextpdf.test.annotations.LogMessages; import java.io.IOException; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class DeviceCmykSvgTest extends SvgIntegrationTest { @@ -47,18 +47,18 @@ public class DeviceCmykSvgTest extends SvgIntegrationTest { private ISvgConverterProperties properties; - @BeforeClass + @BeforeAll public static void beforeClass() { ITextTest.createDestinationFolder(DESTINATION_FOLDER); CssDeclarationValidationMaster.setValidator(new CssDeviceCmykAwareValidator()); } - @Before + @BeforeEach public void before() { properties = new SvgConverterProperties().setBaseUri(SOURCE_FOLDER); } - @AfterClass + @AfterAll public static void afterClass() { CssDeclarationValidationMaster.setValidator(new CssDefaultValidator()); } diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/impl/EllipseSvgNodeRendererIntegrationTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/impl/EllipseSvgNodeRendererIntegrationTest.java index 2284ec6ebe..e655afde6d 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/impl/EllipseSvgNodeRendererIntegrationTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/impl/EllipseSvgNodeRendererIntegrationTest.java @@ -30,21 +30,20 @@ This file is part of the iText (R) project. import com.itextpdf.svg.renderers.SvgDrawContext; import com.itextpdf.svg.renderers.SvgIntegrationTest; import com.itextpdf.test.ITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.nio.charset.StandardCharsets; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class EllipseSvgNodeRendererIntegrationTest extends SvgIntegrationTest { public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/svg/renderers/impl/EllipseSvgNodeRendererIntegrationTest/"; public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/svg/renderers/impl/EllipseSvgNodeRendererIntegrationTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { ITextTest.createDestinationFolder(DESTINATION_FOLDER); } @@ -165,7 +164,7 @@ public void parseParametersAndCalculateCoordinatesWithBetterPrecisionEllipseTest + "125.24 259.13 123.22 257.11 123.22 254.63 c\n" + "123.22 252.14 125.24 250.13 127.72 250.13 c\n" + "130.21 250.13 132.22 252.14 132.22 254.63 c"; - Assert.assertTrue(pageContentBytes.contains(expectedResult)); + Assertions.assertTrue(pageContentBytes.contains(expectedResult)); } @Test diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/impl/EllipseSvgNodeRendererUnitTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/impl/EllipseSvgNodeRendererUnitTest.java index 3554425564..f8008813ca 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/impl/EllipseSvgNodeRendererUnitTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/impl/EllipseSvgNodeRendererUnitTest.java @@ -26,14 +26,13 @@ This file is part of the iText (R) project. import com.itextpdf.styledxmlparser.resolver.resource.ResourceResolver; import com.itextpdf.svg.renderers.SvgDrawContext; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.util.HashMap; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class EllipseSvgNodeRendererUnitTest extends ExtendedITextTest { @Test @@ -41,6 +40,6 @@ public void getObjectBoundingBoxTest() { EllipseSvgNodeRenderer renderer = new EllipseSvgNodeRenderer(); SvgDrawContext context = new SvgDrawContext(new ResourceResolver(""), new FontProvider()); renderer.setAttributesAndStyles(new HashMap<>()); - Assert.assertNull(renderer.getObjectBoundingBox(context)); + Assertions.assertNull(renderer.getObjectBoundingBox(context)); } } diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/impl/GroupSvgNodeRendererIntegrationTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/impl/GroupSvgNodeRendererIntegrationTest.java index 8c2f3dcf05..cf8a4528c3 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/impl/GroupSvgNodeRendererIntegrationTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/impl/GroupSvgNodeRendererIntegrationTest.java @@ -25,15 +25,14 @@ This file is part of the iText (R) project. import com.itextpdf.svg.processors.impl.SvgConverterProperties; import com.itextpdf.svg.renderers.SvgIntegrationTest; import com.itextpdf.test.ITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class GroupSvgNodeRendererIntegrationTest extends SvgIntegrationTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/svg/renderers/impl/GroupRendererTest/"; @@ -41,7 +40,7 @@ public class GroupSvgNodeRendererIntegrationTest extends SvgIntegrationTest { private SvgConverterProperties properties; - @BeforeClass + @BeforeAll public static void beforeClass() { ITextTest.createDestinationFolder(DESTINATION_FOLDER); } diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/impl/GroupSvgNodeRendererUnitTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/impl/GroupSvgNodeRendererUnitTest.java index bb95059ff7..13337a9008 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/impl/GroupSvgNodeRendererUnitTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/impl/GroupSvgNodeRendererUnitTest.java @@ -23,17 +23,16 @@ This file is part of the iText (R) project. package com.itextpdf.svg.renderers.impl; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class GroupSvgNodeRendererUnitTest extends ExtendedITextTest { @Test public void noObjectBoundingBoxTest() { GroupSvgNodeRenderer renderer = new GroupSvgNodeRenderer(); - Assert.assertNull(renderer.getObjectBoundingBox(null)); + Assertions.assertNull(renderer.getObjectBoundingBox(null)); } } diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/impl/ImageSvgNodeRendererIntegrationTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/impl/ImageSvgNodeRendererIntegrationTest.java index 2269c5cd35..836344a2f8 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/impl/ImageSvgNodeRendererIntegrationTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/impl/ImageSvgNodeRendererIntegrationTest.java @@ -26,16 +26,14 @@ This file is part of the iText (R) project. import com.itextpdf.svg.processors.impl.SvgConverterProperties; import com.itextpdf.svg.renderers.SvgIntegrationTest; import com.itextpdf.test.ITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class ImageSvgNodeRendererIntegrationTest extends SvgIntegrationTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/svg/renderers/impl/ImageSvgNodeRendererTest/"; @@ -43,12 +41,12 @@ public class ImageSvgNodeRendererIntegrationTest extends SvgIntegrationTest { private ISvgConverterProperties properties; - @BeforeClass + @BeforeAll public static void beforeClass() { ITextTest.createDestinationFolder(destinationFolder); } - @Before + @BeforeEach public void before() { properties = new SvgConverterProperties() .setBaseUri(sourceFolder); diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/impl/ImageSvgNodeRendererUnitTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/impl/ImageSvgNodeRendererUnitTest.java index 0d11c754e8..aa5543ebd6 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/impl/ImageSvgNodeRendererUnitTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/impl/ImageSvgNodeRendererUnitTest.java @@ -23,18 +23,17 @@ This file is part of the iText (R) project. package com.itextpdf.svg.renderers.impl; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class ImageSvgNodeRendererUnitTest extends ExtendedITextTest { @Test public void noObjectBoundingBoxTest() { ImageSvgNodeRenderer renderer = new ImageSvgNodeRenderer(); - Assert.assertNull(renderer.getObjectBoundingBox(null)); + Assertions.assertNull(renderer.getObjectBoundingBox(null)); } } diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/impl/LineSvgNodeRendererTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/impl/LineSvgNodeRendererTest.java index 5bb3c17107..cb3f76d494 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/impl/LineSvgNodeRendererTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/impl/LineSvgNodeRendererTest.java @@ -35,26 +35,25 @@ This file is part of the iText (R) project. import com.itextpdf.test.ITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.HashMap; import java.util.Map; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class LineSvgNodeRendererTest extends SvgIntegrationTest{ public static final String sourceFolder = "./src/test/resources/com/itextpdf/svg/renderers/impl/LineSvgNodeRendererTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/svg/renderers/impl/LineSvgNodeRendererTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { ITextTest.createDestinationFolder(destinationFolder); } @@ -83,7 +82,7 @@ public void lineRendererTest() throws IOException, InterruptedException { root.draw(context); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_")); } @Test @@ -103,7 +102,7 @@ public void lineWithEmpyAttributesTest() throws IOException, InterruptedExceptio root.draw(context); doc.close(); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_")); } @Test @@ -121,10 +120,10 @@ public void invalidAttributeTest01() { PdfCanvas cv = new PdfCanvas(doc, 1); context.pushCanvas(cv); - Exception e = Assert.assertThrows(StyledXMLParserException.class, + Exception e = Assertions.assertThrows(StyledXMLParserException.class, () -> root.draw(context) ); - Assert.assertEquals(MessageFormatUtil.format(StyledXMLParserException.NAN, "notAnum"), e.getMessage()); + Assertions.assertEquals(MessageFormatUtil.format(StyledXMLParserException.NAN, "notAnum"), e.getMessage()); } @@ -172,8 +171,8 @@ public void emptyPointsListTest() throws IOException, InterruptedException { doc.close(); int numPoints = ((LineSvgNodeRenderer) root).attributesAndStyles.size(); - Assert.assertEquals(numPoints, 0); - Assert.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_")); + Assertions.assertEquals(numPoints, 0); + Assertions.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_")); } @Test @@ -186,7 +185,7 @@ public void getAttributeTest() { float actual = lineSvgNodeRenderer.getAttribute(attributes, "key"); - Assert.assertEquals(expected, actual, 0f); + Assertions.assertEquals(expected, actual, 0f); } @Test @@ -199,7 +198,7 @@ public void getNotPresentAttributeTest() { float actual = lineSvgNodeRenderer.getAttribute(attributes, "notHere"); - Assert.assertEquals(expected, actual, 0f); + Assertions.assertEquals(expected, actual, 0f); } } diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/impl/LinearGradientSvgNodeRendererTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/impl/LinearGradientSvgNodeRendererTest.java index ee216d723f..6cfd64dad1 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/impl/LinearGradientSvgNodeRendererTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/impl/LinearGradientSvgNodeRendererTest.java @@ -31,19 +31,18 @@ This file is part of the iText (R) project. import com.itextpdf.test.LogLevelConstants; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class LinearGradientSvgNodeRendererTest extends SvgIntegrationTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/svg/renderers/impl/LinearGradientSvgNodeRendererTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/svg/renderers/impl/LinearGradientSvgNodeRendererTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { ITextTest.createOrClearDestinationFolder(destinationFolder); } @@ -361,7 +360,6 @@ public void textXYOffset() throws IOException, InterruptedException, java.io.IOE } @Test - // TODO DEVSIX-4143 change cmp file after fixing public void textXOffset() throws IOException, InterruptedException, java.io.IOException { convertAndCompare(sourceFolder, destinationFolder, "textXOffset"); } @@ -532,7 +530,6 @@ public void translateTransformInGradientWithObjectBoundingBoxUnitsTest() throws } @Test - //TODO change cmp after DEVSIX-4143 is fixed (bug with only one absolute coordinate in tspan) public void matrixTransformInGradientWithObjectBoundingBoxUnitsTest() throws IOException, InterruptedException, java.io.IOException { convertAndCompare(sourceFolder, destinationFolder, "matrixTransformInGradientWithObjectBoundingBoxUnits"); } diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/impl/LinearGradientSvgNodeRendererUnitTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/impl/LinearGradientSvgNodeRendererUnitTest.java index c40158f78e..c33263d90b 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/impl/LinearGradientSvgNodeRendererUnitTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/impl/LinearGradientSvgNodeRendererUnitTest.java @@ -23,18 +23,17 @@ This file is part of the iText (R) project. package com.itextpdf.svg.renderers.impl; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class LinearGradientSvgNodeRendererUnitTest extends ExtendedITextTest { @Test public void noObjectBoundingBoxTest() { LinearGradientSvgNodeRenderer renderer = new LinearGradientSvgNodeRenderer(); - Assert.assertNull(renderer.getObjectBoundingBox(null)); + Assertions.assertNull(renderer.getObjectBoundingBox(null)); } } diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/impl/MarkerSvgNodeRendererIntegrationTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/impl/MarkerSvgNodeRendererIntegrationTest.java index 00bc4e11b3..2d9ef7cc8a 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/impl/MarkerSvgNodeRendererIntegrationTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/impl/MarkerSvgNodeRendererIntegrationTest.java @@ -29,15 +29,14 @@ This file is part of the iText (R) project. import com.itextpdf.test.ITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class MarkerSvgNodeRendererIntegrationTest extends SvgIntegrationTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/svg/renderers/impl/MarkerSvgNodeRendererIntegrationTest/"; @@ -45,12 +44,12 @@ public class MarkerSvgNodeRendererIntegrationTest extends SvgIntegrationTest { private ISvgConverterProperties properties; - @BeforeClass + @BeforeAll public static void beforeClass() { ITextTest.createDestinationFolder(DESTINATION_FOLDER); } - @Before + @BeforeEach public void before() { properties = new SvgConverterProperties().setBaseUri(SOURCE_FOLDER); } diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/impl/MarkerSvgNodeRendererUnitTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/impl/MarkerSvgNodeRendererUnitTest.java index 3e01429cc2..dff2571646 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/impl/MarkerSvgNodeRendererUnitTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/impl/MarkerSvgNodeRendererUnitTest.java @@ -23,18 +23,17 @@ This file is part of the iText (R) project. package com.itextpdf.svg.renderers.impl; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class MarkerSvgNodeRendererUnitTest extends ExtendedITextTest { @Test public void noObjectBoundingBoxTest() { MarkerSvgNodeRenderer renderer = new MarkerSvgNodeRenderer(); - Assert.assertNull(renderer.getObjectBoundingBox(null)); + Assertions.assertNull(renderer.getObjectBoundingBox(null)); } } diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/impl/MaskTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/impl/MaskTest.java index 249e1dfc72..b2db7deac1 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/impl/MaskTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/impl/MaskTest.java @@ -26,15 +26,14 @@ This file is part of the iText (R) project. import com.itextpdf.svg.processors.impl.SvgConverterProperties; import com.itextpdf.svg.renderers.SvgIntegrationTest; import com.itextpdf.test.ITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class MaskTest extends SvgIntegrationTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/svg/renderers/impl/MaskTest/"; @@ -42,12 +41,12 @@ public class MaskTest extends SvgIntegrationTest { private ISvgConverterProperties properties; - @BeforeClass + @BeforeAll public static void beforeClass() { ITextTest.createDestinationFolder(DESTINATION_FOLDER); } - @Before + @BeforeEach public void before() { properties = new SvgConverterProperties().setBaseUri(SOURCE_FOLDER); } diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/impl/NamedObjectsTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/impl/NamedObjectsTest.java index d7721c14c8..31a8ce5a45 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/impl/NamedObjectsTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/impl/NamedObjectsTest.java @@ -31,16 +31,15 @@ This file is part of the iText (R) project. import com.itextpdf.svg.renderers.SvgIntegrationTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.FileInputStream; import java.io.IOException; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class NamedObjectsTest extends SvgIntegrationTest { @Test @@ -51,7 +50,7 @@ public void addNamedObject() throws IOException { INode parsedSvg = SvgConverter.parse(FileUtil.getInputStreamForFile("./src/test/resources/com/itextpdf/svg/renderers/impl/NamedObjectsTest/names.svg")); ISvgProcessorResult result = new DefaultSvgProcessor().process(parsedSvg, null); - Assert.assertTrue(result.getNamedObjects().get("name_svg") instanceof SvgTagSvgNodeRenderer); - Assert.assertTrue(result.getNamedObjects().get("name_rect") instanceof RectangleSvgNodeRenderer); + Assertions.assertTrue(result.getNamedObjects().get("name_svg") instanceof SvgTagSvgNodeRenderer); + Assertions.assertTrue(result.getNamedObjects().get("name_rect") instanceof RectangleSvgNodeRenderer); } } diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/impl/NestedSvgTagSvgNodeRendererIntegrationTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/impl/NestedSvgTagSvgNodeRendererIntegrationTest.java index 4c3af0ba46..df2f3cfb2f 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/impl/NestedSvgTagSvgNodeRendererIntegrationTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/impl/NestedSvgTagSvgNodeRendererIntegrationTest.java @@ -24,22 +24,21 @@ This file is part of the iText (R) project. import com.itextpdf.svg.renderers.SvgIntegrationTest; import com.itextpdf.test.ITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class NestedSvgTagSvgNodeRendererIntegrationTest extends SvgIntegrationTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/svg/renderers/impl/RootSvgNodeRendererTest/nested/"; private static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/svg/renderers/impl/RootSvgNodeRendererTest/nested/"; - @BeforeClass + @BeforeAll public static void beforeClass() { ITextTest.createDestinationFolder(DESTINATION_FOLDER); } diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/impl/OverflowAttributeTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/impl/OverflowAttributeTest.java index 6f42a45492..f1c1e28b91 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/impl/OverflowAttributeTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/impl/OverflowAttributeTest.java @@ -26,17 +26,16 @@ This file is part of the iText (R) project. import com.itextpdf.svg.processors.impl.SvgConverterProperties; import com.itextpdf.svg.renderers.SvgIntegrationTest; import com.itextpdf.test.ITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class OverflowAttributeTest extends SvgIntegrationTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/svg/renderers/impl/OverflowAttributeTest/"; @@ -44,12 +43,12 @@ public class OverflowAttributeTest extends SvgIntegrationTest { private ISvgConverterProperties properties; - @BeforeClass + @BeforeAll public static void beforeClass() { ITextTest.createDestinationFolder(DESTINATION_FOLDER); } - @Before + @BeforeEach public void before() { properties = new SvgConverterProperties().setBaseUri(SOURCE_FOLDER); } diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/impl/PathOperatorSplitTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/impl/PathOperatorSplitTest.java index 74426c3af9..c46ae199f9 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/impl/PathOperatorSplitTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/impl/PathOperatorSplitTest.java @@ -23,13 +23,12 @@ This file is part of the iText (R) project. package com.itextpdf.svg.renderers.impl; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PathOperatorSplitTest extends ExtendedITextTest { @Test @@ -48,7 +47,7 @@ public void testNumbersContainingExponent01() { private void testSplitting(String originalStr, String[] expectedSplitting) { String[] result = PathSvgNodeRenderer.splitPathStringIntoOperators(originalStr); - Assert.assertArrayEquals(expectedSplitting, result); + Assertions.assertArrayEquals(expectedSplitting, result); } } diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/impl/PathParsingIntegrationTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/impl/PathParsingIntegrationTest.java index a28595cbe9..3b824222b7 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/impl/PathParsingIntegrationTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/impl/PathParsingIntegrationTest.java @@ -28,22 +28,21 @@ This file is part of the iText (R) project. import com.itextpdf.test.ITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PathParsingIntegrationTest extends SvgIntegrationTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/svg/renderers/impl/PathParsingIntegrationTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/svg/renderers/impl/PathParsingIntegrationTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { ITextTest.createDestinationFolder(destinationFolder); } @@ -80,14 +79,14 @@ public void decimalPointHandlingTest() throws IOException, InterruptedException @Test public void invalidOperatorTest() throws IOException, InterruptedException { - Assert.assertThrows(SvgProcessingException.class, + Assertions.assertThrows(SvgProcessingException.class, () -> convertAndCompare(sourceFolder, destinationFolder, "invalidOperator") ); } @Test public void invalidOperatorCSensTest() throws IOException, InterruptedException { - Assert.assertThrows(SvgProcessingException.class, + Assertions.assertThrows(SvgProcessingException.class, () -> convertAndCompare(sourceFolder, destinationFolder, "invalidOperatorCSens") ); } diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/impl/PathParsingTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/impl/PathParsingTest.java index 93a65bfbdf..eccb825726 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/impl/PathParsingTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/impl/PathParsingTest.java @@ -25,16 +25,15 @@ This file is part of the iText (R) project. import com.itextpdf.svg.SvgConstants; import com.itextpdf.svg.exceptions.SvgProcessingException; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.util.HashMap; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.util.Collection; -@Category(UnitTest.class) +@Tag("UnitTest") public class PathParsingTest extends ExtendedITextTest { @Test @@ -42,7 +41,7 @@ public void pathParsingOperatorEmptyTest() { PathSvgNodeRenderer path = new PathSvgNodeRenderer(); path.setAttribute(SvgConstants.Attributes.D, ""); Collection<String> ops = path.parsePathOperations(); - Assert.assertTrue(ops.isEmpty()); + Assertions.assertTrue(ops.isEmpty()); } @Test @@ -50,7 +49,7 @@ public void pathParsingOperatorDefaultValueTest() { PathSvgNodeRenderer path = new PathSvgNodeRenderer(); path.setAttributesAndStyles(new HashMap<>()); Collection<String> ops = path.parsePathOperations(); - Assert.assertTrue(ops.isEmpty()); + Assertions.assertTrue(ops.isEmpty()); } @Test @@ -58,7 +57,7 @@ public void pathParsingOperatorOnlySpacesTest() { PathSvgNodeRenderer path = new PathSvgNodeRenderer(); path.setAttribute(SvgConstants.Attributes.D, " "); Collection<String> ops = path.parsePathOperations(); - Assert.assertTrue(ops.isEmpty()); + Assertions.assertTrue(ops.isEmpty()); } @Test @@ -66,7 +65,7 @@ public void pathParsingOperatorBadOperatorTest() { PathSvgNodeRenderer path = new PathSvgNodeRenderer(); path.setAttribute(SvgConstants.Attributes.D, "b 1 1"); - Assert.assertThrows(SvgProcessingException.class, () -> path.parsePathOperations()); + Assertions.assertThrows(SvgProcessingException.class, () -> path.parsePathOperations()); } @Test @@ -74,7 +73,7 @@ public void pathParsingOperatorLaterBadOperatorTest() { PathSvgNodeRenderer path = new PathSvgNodeRenderer(); path.setAttribute(SvgConstants.Attributes.D, "m 200 100 l 50 50 x"); - Assert.assertThrows(SvgProcessingException.class, () -> path.parsePathOperations()); + Assertions.assertThrows(SvgProcessingException.class, () -> path.parsePathOperations()); } @Test @@ -82,7 +81,7 @@ public void pathParsingOperatorStartWithSpacesTest() { PathSvgNodeRenderer path = new PathSvgNodeRenderer(); path.setAttribute(SvgConstants.Attributes.D, " \t\n m 200 100 l 50 50"); Collection<String> ops = path.parsePathOperations(); - Assert.assertEquals(2, ops.size()); + Assertions.assertEquals(2, ops.size()); } @Test @@ -90,7 +89,7 @@ public void pathParsingOperatorEndWithSpacesTest() { PathSvgNodeRenderer path = new PathSvgNodeRenderer(); path.setAttribute(SvgConstants.Attributes.D, "m 200 100 l 50 50 m 200 100 l 50 50 \t\n "); Collection<String> ops = path.parsePathOperations(); - Assert.assertEquals(4, ops.size()); + Assertions.assertEquals(4, ops.size()); } @Test @@ -98,7 +97,7 @@ public void pathParsingNoOperatorSpacesNoExceptionTest() { PathSvgNodeRenderer path = new PathSvgNodeRenderer(); path.setAttribute(SvgConstants.Attributes.D, "m200,100L50,50L200,100"); Collection<String> ops = path.parsePathOperations(); - Assert.assertEquals(3, ops.size()); + Assertions.assertEquals(3, ops.size()); } @Test @@ -107,7 +106,7 @@ public void pathParsingLoseCommasTest() { path.setAttribute(SvgConstants.Attributes.D, "m200,100L50,50L200,100"); Collection<String> ops = path.parsePathOperations(); for (String op : ops) { - Assert.assertFalse(op.contains(",")); + Assertions.assertFalse(op.contains(",")); } } @@ -116,7 +115,7 @@ public void pathParsingBadOperatorArgsNoExceptionTest() { PathSvgNodeRenderer path = new PathSvgNodeRenderer(); path.setAttribute(SvgConstants.Attributes.D, "m 200 l m"); Collection<String> ops = path.parsePathOperations(); - Assert.assertEquals(3, ops.size()); + Assertions.assertEquals(3, ops.size()); } @Test @@ -124,8 +123,8 @@ public void pathParsingHandlesDecPointsTest() { PathSvgNodeRenderer path = new PathSvgNodeRenderer(); path.setAttribute(SvgConstants.Attributes.D, "m2.35.96"); Collection<String> ops = path.parsePathOperations(); - Assert.assertEquals(1, ops.size()); - Assert.assertTrue(ops.contains("m 2.35 .96")); + Assertions.assertEquals(1, ops.size()); + Assertions.assertTrue(ops.contains("m 2.35 .96")); } @Test @@ -133,8 +132,8 @@ public void pathParsingHandlesMinusTest() { PathSvgNodeRenderer path = new PathSvgNodeRenderer(); path.setAttribute(SvgConstants.Attributes.D, "m40-50"); Collection<String> ops = path.parsePathOperations(); - Assert.assertEquals(1, ops.size()); - Assert.assertTrue(ops.contains("m 40 -50")); + Assertions.assertEquals(1, ops.size()); + Assertions.assertTrue(ops.contains("m 40 -50")); } @Test @@ -144,7 +143,7 @@ public void decimalPointParsingTest() { String expected = "2.35 .96"; String actual = path.separateDecimalPoints(input); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test @@ -154,7 +153,7 @@ public void decimalPointParsingSpaceTest() { String expected = "2.35 .96 3.25 .25"; String actual = path.separateDecimalPoints(input); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test @@ -164,7 +163,7 @@ public void decimalPointParsingTabTest() { String expected = "2.35 .96 3.25\t.25"; String actual = path.separateDecimalPoints(input); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test @@ -174,7 +173,7 @@ public void decimalPointParsingMinusTest() { String expected = "2.35 .96 3.25 -.25"; String actual = path.separateDecimalPoints(input); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test @@ -184,7 +183,7 @@ public void negativeAfterPositiveTest() { String expected = "40 -50"; String actual = path.separateDecimalPoints(input); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test @@ -194,7 +193,7 @@ public void exponentInNumberTest01() { String expected = "C 268.88888888888886 67.97916666666663e+10 331.1111111111111 -2.842170943040401e-14 393.3333333333333 -2.842170943040401e-14"; String actual = path.separateDecimalPoints(input); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test @@ -204,6 +203,6 @@ public void exponentInNumberTest02() { String expected = "C 268.88888888888886 67.97916666666663e+10 331.1111111111111 -2.842170943040401E-14 393.3333333333333 -2.842170943040401E-14"; String actual = path.separateDecimalPoints(input); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } } diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/impl/PathSvgNodeRendererLowLevelIntegrationTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/impl/PathSvgNodeRendererLowLevelIntegrationTest.java index bb7f729c51..4877ceef36 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/impl/PathSvgNodeRendererLowLevelIntegrationTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/impl/PathSvgNodeRendererLowLevelIntegrationTest.java @@ -32,15 +32,14 @@ This file is part of the iText (R) project. import com.itextpdf.svg.renderers.path.impl.EllipticalCurveTo; import com.itextpdf.svg.renderers.path.impl.MoveTo; import com.itextpdf.svg.renderers.path.impl.SmoothSCurveTo; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.util.List; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PathSvgNodeRendererLowLevelIntegrationTest extends SvgIntegrationTest { @Test @@ -49,9 +48,9 @@ public void testRelativeArcOperatorShapes() { String instructions = "M 200,300 a 10 10 0 0 0 10 10"; path.setAttribute(SvgConstants.Attributes.D, instructions); List<IPathShape> segments = (List<IPathShape>) path.getShapes(); - Assert.assertEquals(2, segments.size()); - Assert.assertTrue(segments.get(0) instanceof MoveTo); - Assert.assertTrue(segments.get(1) instanceof EllipticalCurveTo); + Assertions.assertEquals(2, segments.size()); + Assertions.assertTrue(segments.get(0) instanceof MoveTo); + Assertions.assertTrue(segments.get(1) instanceof EllipticalCurveTo); } @Test @@ -61,7 +60,7 @@ public void testRelativeArcOperatorCoordinates() { path.setAttribute(SvgConstants.Attributes.D, instructions); IPathShape arc = ((List<IPathShape>) path.getShapes()).get(1); Point end = arc.getEndingPoint(); - Assert.assertEquals(new Point(210, 310), end); + Assertions.assertEquals(new Point(210, 310), end); } @Test @@ -71,7 +70,7 @@ public void testMultipleRelativeArcOperatorCoordinates() { path.setAttribute(SvgConstants.Attributes.D, instructions); IPathShape arc = ((List<IPathShape>) path.getShapes()).get(2); Point end = arc.getEndingPoint(); - Assert.assertEquals(new Point(220, 320), end); + Assertions.assertEquals(new Point(220, 320), end); } @Test @@ -81,7 +80,7 @@ public void testAbsoluteArcOperatorCoordinates() { path.setAttribute(SvgConstants.Attributes.D, instructions); IPathShape arc = ((List<IPathShape>) path.getShapes()).get(1); Point end = arc.getEndingPoint(); - Assert.assertEquals(new Point(210, 310), end); + Assertions.assertEquals(new Point(210, 310), end); } @Test @@ -91,7 +90,7 @@ public void testMultipleAbsoluteArcOperatorCoordinates() { path.setAttribute(SvgConstants.Attributes.D, instructions); IPathShape arc = ((List<IPathShape>) path.getShapes()).get(2); Point end = arc.getEndingPoint(); - Assert.assertEquals(new Point(220, 320), end); + Assertions.assertEquals(new Point(220, 320), end); } // tests resulting in empty path @@ -100,7 +99,7 @@ public void testEmptyPath() { PathSvgNodeRenderer path = new PathSvgNodeRenderer(); String instructions = ""; path.setAttribute(SvgConstants.Attributes.D, instructions); - Assert.assertTrue(path.getShapes().isEmpty()); + Assertions.assertTrue(path.getShapes().isEmpty()); } @Test @@ -108,7 +107,7 @@ public void testNonsensePathNoOperators() { PathSvgNodeRenderer path = new PathSvgNodeRenderer(); String instructions = "200"; path.setAttribute(SvgConstants.Attributes.D, instructions); - Assert.assertTrue(path.getShapes().isEmpty()); + Assertions.assertTrue(path.getShapes().isEmpty()); } @Test @@ -117,7 +116,7 @@ public void testNonsensePathNotExistingOperator() { String instructions = "F"; path.setAttribute(SvgConstants.Attributes.D, instructions); - Assert.assertThrows(SvgProcessingException.class, () -> path.getShapes()); + Assertions.assertThrows(SvgProcessingException.class, () -> path.getShapes()); } @Test @@ -126,7 +125,7 @@ public void testClosePathNoPrecedingPathsOperator() { String instructions = "z"; path.setAttribute(SvgConstants.Attributes.D, instructions); - Assert.assertThrows(SvgProcessingException.class, () -> path.getShapes()); + Assertions.assertThrows(SvgProcessingException.class, () -> path.getShapes()); } @Test @@ -134,7 +133,7 @@ public void testMoveNoArgsOperator() { PathSvgNodeRenderer path = new PathSvgNodeRenderer(); String instructions = "M"; path.setAttribute(SvgConstants.Attributes.D, instructions); - Assert.assertTrue(path.getShapes().isEmpty()); + Assertions.assertTrue(path.getShapes().isEmpty()); } @Test @@ -142,7 +141,7 @@ public void testMoveOddArgsOperator() { PathSvgNodeRenderer path = new PathSvgNodeRenderer(); String instructions = "M 500"; path.setAttribute(SvgConstants.Attributes.D, instructions); - Assert.assertTrue(path.getShapes().isEmpty()); + Assertions.assertTrue(path.getShapes().isEmpty()); } @Test @@ -150,7 +149,7 @@ public void testAddMultipleArgsOperator() { PathSvgNodeRenderer path = new PathSvgNodeRenderer(); String instructions = "M 500 500 200 200 300 300"; path.setAttribute(SvgConstants.Attributes.D, instructions); - Assert.assertEquals(3, path.getShapes().size()); + Assertions.assertEquals(3, path.getShapes().size()); } @Test @@ -158,7 +157,7 @@ public void testAddMultipleOddArgsOperator() { PathSvgNodeRenderer path = new PathSvgNodeRenderer(); String instructions = "L 500 500 200 200 300"; path.setAttribute(SvgConstants.Attributes.D, instructions); - Assert.assertEquals(2, path.getShapes().size()); + Assertions.assertEquals(2, path.getShapes().size()); } @Test @@ -166,8 +165,8 @@ public void testAddMultipleOddArgsOperatorThenOtherStuff() { PathSvgNodeRenderer path = new PathSvgNodeRenderer(); String instructions = "M 500 500 200 200 300 z"; path.setAttribute(SvgConstants.Attributes.D, instructions); - Assert.assertEquals(3, path.getShapes().size()); - Assert.assertTrue(((List<IPathShape>) path.getShapes()).get(2) instanceof ClosePath); + Assertions.assertEquals(3, path.getShapes().size()); + Assertions.assertTrue(((List<IPathShape>) path.getShapes()).get(2) instanceof ClosePath); } @Test @@ -175,8 +174,8 @@ public void testAddDoubleArgsOperator() { PathSvgNodeRenderer path = new PathSvgNodeRenderer(); String instructions = "M 500 500 S 200 100 100 200 300 300 400 400"; path.setAttribute(SvgConstants.Attributes.D, instructions); - Assert.assertEquals(3, path.getShapes().size()); - Assert.assertTrue(((List<IPathShape>) path.getShapes()).get(2) instanceof SmoothSCurveTo); + Assertions.assertEquals(3, path.getShapes().size()); + Assertions.assertTrue(((List<IPathShape>) path.getShapes()).get(2) instanceof SmoothSCurveTo); } @Test @@ -185,8 +184,8 @@ public void smoothCurveAsFirstShapeTest1() { PathSvgNodeRenderer path = new PathSvgNodeRenderer(); path.setAttribute(SvgConstants.Attributes.D, instructions); - Exception e = Assert.assertThrows(SvgProcessingException.class, () -> path.getShapes()); - Assert.assertEquals(SvgExceptionMessageConstant.INVALID_SMOOTH_CURVE_USE, e.getMessage()); + Exception e = Assertions.assertThrows(SvgProcessingException.class, () -> path.getShapes()); + Assertions.assertEquals(SvgExceptionMessageConstant.INVALID_SMOOTH_CURVE_USE, e.getMessage()); } @Test @@ -195,7 +194,7 @@ public void smoothCurveAsFirstShapeTest2() { PathSvgNodeRenderer path = new PathSvgNodeRenderer(); path.setAttribute(SvgConstants.Attributes.D, instructions); - Exception e = Assert.assertThrows(SvgProcessingException.class, () -> path.getShapes()); - Assert.assertEquals(SvgExceptionMessageConstant.INVALID_SMOOTH_CURVE_USE, e.getMessage()); + Exception e = Assertions.assertThrows(SvgProcessingException.class, () -> path.getShapes()); + Assertions.assertEquals(SvgExceptionMessageConstant.INVALID_SMOOTH_CURVE_USE, e.getMessage()); } } diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/impl/PathSvgNodeRendererTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/impl/PathSvgNodeRendererTest.java index 6613427612..22dca43468 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/impl/PathSvgNodeRendererTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/impl/PathSvgNodeRendererTest.java @@ -36,24 +36,23 @@ This file is part of the iText (R) project. import com.itextpdf.svg.renderers.SvgDrawContext; import com.itextpdf.svg.renderers.SvgIntegrationTest; import com.itextpdf.test.ITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; import java.io.InputStream; import java.util.HashMap; import java.util.Map; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PathSvgNodeRendererTest extends SvgIntegrationTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/svg/renderers/impl/PathSvgNodeRendererTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/svg/renderers/impl/PathSvgNodeRendererTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { ITextTest.createDestinationFolder(destinationFolder); } @@ -80,7 +79,7 @@ public void pathNodeRendererMoveToTest() throws IOException, InterruptedExceptio String result = new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_"); if (result != null && ! result.contains("No visual differences")) { - Assert.fail(result); + Assertions.fail(result); } } @@ -105,7 +104,7 @@ public void pathNodeRendererMoveToTest1() throws IOException, InterruptedExcepti String result = new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_"); if (result != null && ! result.contains("No visual differences")) { - Assert.fail(result); + Assertions.fail(result); } } @@ -130,7 +129,7 @@ public void pathNodeRendererCurveToTest() throws IOException, InterruptedExcepti String result = new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_"); if (result != null && ! result.contains("No visual differences")) { - Assert.fail(result); + Assertions.fail(result); } } @@ -155,7 +154,7 @@ public void pathNodeRendererCurveToTest1() throws IOException, InterruptedExcept String result = new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_"); if (result != null && ! result.contains("No visual differences")) { - Assert.fail(result); + Assertions.fail(result); } } @@ -179,7 +178,7 @@ public void pathNodeRendererQCurveToCurveToTest() throws IOException, Interrupte String result = new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_"); if (result != null && ! result.contains("No visual differences")) { - Assert.fail(result); + Assertions.fail(result); } } @@ -203,7 +202,7 @@ public void pathNodeRendererQCurveToCurveToTest1() throws IOException, Interrupt String result = new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_"); if (result != null && ! result.contains("No visual differences")) { - Assert.fail(result); + Assertions.fail(result); } } @@ -223,7 +222,7 @@ public void smoothCurveTest1() throws IOException { SvgDrawContext context = new SvgDrawContext(null, null); PdfCanvas cv = new PdfCanvas(doc, 1); context.pushCanvas(cv); - Assert.assertTrue(root.getChildren().get(0) instanceof PathSvgNodeRenderer); + Assertions.assertTrue(root.getChildren().get(0) instanceof PathSvgNodeRenderer); root.getChildren().get(0).draw(context); doc.close(); } @@ -244,7 +243,7 @@ public void smoothCurveTest2() throws IOException { SvgDrawContext context = new SvgDrawContext(null, null); PdfCanvas cv = new PdfCanvas(doc, 1); context.pushCanvas(cv); - Assert.assertTrue(root.getChildren().get(0) instanceof PathSvgNodeRenderer); + Assertions.assertTrue(root.getChildren().get(0) instanceof PathSvgNodeRenderer); root.getChildren().get(0).draw(context); doc.close(); } @@ -265,7 +264,7 @@ public void smoothCurveTest3() throws IOException { SvgDrawContext context = new SvgDrawContext(null, null); PdfCanvas cv = new PdfCanvas(doc, 1); context.pushCanvas(cv); - Assert.assertTrue(root.getChildren().get(0) instanceof PathSvgNodeRenderer); + Assertions.assertTrue(root.getChildren().get(0) instanceof PathSvgNodeRenderer); root.getChildren().get(0).draw(context); doc.close(); } @@ -292,14 +291,14 @@ public void pathZOperatorSingleZInstructionsAfterTest() throws IOException, Inte @Test public void invalidZOperatorTest() throws IOException, InterruptedException { - Assert.assertThrows(SvgProcessingException.class, + Assertions.assertThrows(SvgProcessingException.class, () -> convertAndCompare(sourceFolder, destinationFolder, "invalidZOperatorTest01") ); } @Test public void invalidOperatorTest() throws IOException, InterruptedException { - Assert.assertThrows(SvgProcessingException.class, + Assertions.assertThrows(SvgProcessingException.class, () -> convertAndCompare(sourceFolder, destinationFolder, "invalidOperatorTest01") ); } @@ -383,7 +382,7 @@ public void iTextLogoTest() throws IOException, InterruptedException { @Test public void eofillUnsuportedPathTest() throws IOException, InterruptedException { - Assert.assertThrows(SvgProcessingException.class, + Assertions.assertThrows(SvgProcessingException.class, () -> convertAndCompare(sourceFolder, destinationFolder, "eofillUnsuportedPathTest") ); } diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/impl/PatternSvgNodeRendererUnitTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/impl/PatternSvgNodeRendererUnitTest.java index a7579ae0a8..073f87b7e4 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/impl/PatternSvgNodeRendererUnitTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/impl/PatternSvgNodeRendererUnitTest.java @@ -23,18 +23,17 @@ This file is part of the iText (R) project. package com.itextpdf.svg.renderers.impl; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PatternSvgNodeRendererUnitTest extends ExtendedITextTest { @Test public void noObjectBoundingBoxTest() { PatternSvgNodeRenderer renderer = new PatternSvgNodeRenderer(); - Assert.assertNull(renderer.getObjectBoundingBox(null)); + Assertions.assertNull(renderer.getObjectBoundingBox(null)); } } diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/impl/PatternTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/impl/PatternTest.java index b4e66d4a5c..9fa88fcd53 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/impl/PatternTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/impl/PatternTest.java @@ -29,19 +29,18 @@ This file is part of the iText (R) project. import com.itextpdf.test.ITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PatternTest extends SvgIntegrationTest { public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/svg/renderers/impl/PatternTest/"; public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/svg/renderers/impl/PatternTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { ITextTest.createDestinationFolder(DESTINATION_FOLDER); } diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/impl/PdfRootSvgNodeRendererIntegrationTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/impl/PdfRootSvgNodeRendererIntegrationTest.java index ef0e857311..eaec33d065 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/impl/PdfRootSvgNodeRendererIntegrationTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/impl/PdfRootSvgNodeRendererIntegrationTest.java @@ -36,17 +36,16 @@ This file is part of the iText (R) project. import com.itextpdf.svg.renderers.ISvgNodeRenderer; import com.itextpdf.svg.renderers.SvgDrawContext; import com.itextpdf.svg.renderers.SvgIntegrationTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.ByteArrayOutputStream; import java.util.HashMap; import java.util.Map; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PdfRootSvgNodeRendererIntegrationTest extends SvgIntegrationTest { @Test @@ -67,7 +66,7 @@ public void calculateOutermostViewportTest() { PdfRootSvgNodeRenderer root = new PdfRootSvgNodeRenderer(renderer); Rectangle actual = root.calculateViewPort(context); - Assert.assertTrue(expected.equalsWithEpsilon(actual)); + Assertions.assertTrue(expected.equalsWithEpsilon(actual)); } @Test @@ -88,7 +87,7 @@ public void calculateOutermostViewportWithDifferentXYTest() { PdfRootSvgNodeRenderer root = new PdfRootSvgNodeRenderer(renderer); Rectangle actual = root.calculateViewPort(context); - Assert.assertTrue(expected.equalsWithEpsilon(actual)); + Assertions.assertTrue(expected.equalsWithEpsilon(actual)); } @@ -119,7 +118,7 @@ public void calculateNestedViewportDifferentFromParentTest() { renderer.setParent(parent); Rectangle actual = root.calculateViewPort(context); - Assert.assertTrue(expected.equalsWithEpsilon(actual)); + Assertions.assertTrue(expected.equalsWithEpsilon(actual)); } @Test @@ -135,10 +134,10 @@ public void noBoundingBoxOnXObjectTest() { SvgDrawContext context = new SvgDrawContext(null, null); context.pushCanvas(canvas); - Exception e = Assert.assertThrows(SvgProcessingException.class, + Exception e = Assertions.assertThrows(SvgProcessingException.class, () -> root.draw(context) ); - Assert.assertEquals(SvgExceptionMessageConstant.ROOT_SVG_NO_BBOX, e.getMessage()); + Assertions.assertEquals(SvgExceptionMessageConstant.ROOT_SVG_NO_BBOX, e.getMessage()); } @Test @@ -160,6 +159,6 @@ public void calculateOutermostTransformation() { AffineTransform actual = root.calculateTransformation(context); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } } diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/impl/PdfRootSvgNodeRendererUnitTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/impl/PdfRootSvgNodeRendererUnitTest.java index 748ad3ee39..08dd580090 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/impl/PdfRootSvgNodeRendererUnitTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/impl/PdfRootSvgNodeRendererUnitTest.java @@ -24,19 +24,18 @@ This file is part of the iText (R) project. import com.itextpdf.svg.renderers.ISvgNodeRenderer; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PdfRootSvgNodeRendererUnitTest extends ExtendedITextTest { @Test public void noObjectBoundingBoxTest() { ISvgNodeRenderer subTreeRoot = new SvgTagSvgNodeRenderer(); PdfRootSvgNodeRenderer renderer = new PdfRootSvgNodeRenderer(subTreeRoot); - Assert.assertNull(renderer.getObjectBoundingBox(null)); + Assertions.assertNull(renderer.getObjectBoundingBox(null)); } } diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/impl/PolygonSvgNodeRendererTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/impl/PolygonSvgNodeRendererTest.java index 6287186415..59bba9ae50 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/impl/PolygonSvgNodeRendererTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/impl/PolygonSvgNodeRendererTest.java @@ -33,7 +33,6 @@ This file is part of the iText (R) project. import com.itextpdf.svg.renderers.SvgDrawContext; import com.itextpdf.svg.renderers.SvgIntegrationTest; import com.itextpdf.test.ITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -42,17 +41,17 @@ This file is part of the iText (R) project. import java.util.List; import java.util.Map; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PolygonSvgNodeRendererTest extends SvgIntegrationTest { private static final String sourceFolder = "./src/test/resources/com/itextpdf/svg/renderers/impl/PolygonSvgNoderendererTest/"; private static final String destinationFolder = "./target/test/com/itextpdf/svg/renderers/impl/PolygonSvgNoderendererTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { ITextTest.createDestinationFolder(destinationFolder); } @@ -73,7 +72,7 @@ public void polygonLineRendererTest() throws IOException, InterruptedException { root.draw(context); doc.close(); - Assert.assertNull(new CompareTool().compareVisually(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareVisually(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_")); } @Test @@ -97,9 +96,9 @@ public void polygonLinkedPointCheckerImplicit() { expectedPoints.add(new Point(0, 0)); List<Point> attributePoints = ((PolygonSvgNodeRenderer) root).getPoints(); - Assert.assertEquals(expectedPoints.size(), attributePoints.size()); + Assertions.assertEquals(expectedPoints.size(), attributePoints.size()); for (int x = 0; x < attributePoints.size(); x++) { - Assert.assertEquals(expectedPoints.get(x), attributePoints.get(x)); + Assertions.assertEquals(expectedPoints.get(x), attributePoints.get(x)); } } @@ -125,9 +124,9 @@ public void polygonLinkedPointCheckerExplicit() { expectedPoints.add(new Point(0, 0)); List<Point> attributePoints = ((PolygonSvgNodeRenderer) root).getPoints(); - Assert.assertEquals(expectedPoints.size(), attributePoints.size()); + Assertions.assertEquals(expectedPoints.size(), attributePoints.size()); for (int x = 0; x < attributePoints.size(); x++) { - Assert.assertEquals(expectedPoints.get(x), attributePoints.get(x)); + Assertions.assertEquals(expectedPoints.get(x), attributePoints.get(x)); } } @@ -149,8 +148,8 @@ public void polygonEmptyPointCheckerTest() throws IOException, InterruptedExcept doc.close(); int numPoints = ((PolygonSvgNodeRenderer) root).getPoints().size(); - Assert.assertEquals(numPoints, 0); - Assert.assertNull(new CompareTool().compareVisually(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_")); + Assertions.assertEquals(numPoints, 0); + Assertions.assertNull(new CompareTool().compareVisually(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_")); } @@ -178,9 +177,9 @@ public void connectPointsWithSameYCoordinateTest() { expectedPoints.add(new Point(75, 75)); List<Point> attributePoints = ((PolygonSvgNodeRenderer) root).getPoints(); - Assert.assertEquals(expectedPoints.size(), attributePoints.size()); + Assertions.assertEquals(expectedPoints.size(), attributePoints.size()); for (int x = 0; x < attributePoints.size(); x++) { - Assert.assertEquals(expectedPoints.get(x), attributePoints.get(x)); + Assertions.assertEquals(expectedPoints.get(x), attributePoints.get(x)); } } } diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/impl/PolylineSvgNodeRendererTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/impl/PolylineSvgNodeRendererTest.java index 90e5a05c31..cf201c2734 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/impl/PolylineSvgNodeRendererTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/impl/PolylineSvgNodeRendererTest.java @@ -34,7 +34,6 @@ This file is part of the iText (R) project. import com.itextpdf.svg.renderers.SvgDrawContext; import com.itextpdf.svg.renderers.SvgIntegrationTest; import com.itextpdf.test.ITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -43,17 +42,17 @@ This file is part of the iText (R) project. import java.util.List; import java.util.Map; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PolylineSvgNodeRendererTest extends SvgIntegrationTest { private static final String sourceFolder = "./src/test/resources/com/itextpdf/svg/renderers/impl/PolylineSvgNodeRendererTest/"; private static final String destinationFolder = "./target/test/com/itextpdf/svg/renderers/impl/PolylineSvgNodeRendererTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { ITextTest.createDestinationFolder(destinationFolder); } @@ -74,7 +73,7 @@ public void polylineRendererTest() throws IOException, InterruptedException { root.draw(context); doc.close(); - Assert.assertNull(new CompareTool().compareVisually(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_")); + Assertions.assertNull(new CompareTool().compareVisually(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_")); } @Test @@ -89,7 +88,7 @@ public void polyLineInvalidAttributeTest01() { PdfCanvas cv = new PdfCanvas(doc, 1); context.pushCanvas(cv); - Assert.assertThrows(StyledXMLParserException.class, () -> root.draw(context)); + Assertions.assertThrows(StyledXMLParserException.class, () -> root.draw(context)); } @Test @@ -104,7 +103,7 @@ public void polyLineInvalidAttributeTest02() { PdfCanvas cv = new PdfCanvas(doc, 1); context.pushCanvas(cv); - Assert.assertThrows(SvgProcessingException.class, () -> root.draw(context)); + Assertions.assertThrows(SvgProcessingException.class, () -> root.draw(context)); } @Test @@ -124,8 +123,8 @@ public void polyLineEmptyPointsListTest() throws IOException, InterruptedExcepti doc.close(); int numPoints = ((PolylineSvgNodeRenderer) root).getPoints().size(); - Assert.assertEquals(numPoints, 0); - Assert.assertNull(new CompareTool().compareVisually(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_")); + Assertions.assertEquals(numPoints, 0); + Assertions.assertNull(new CompareTool().compareVisually(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_")); } @Test @@ -148,9 +147,9 @@ public void polyPointCheckerTest() { expectedPoints.add(new Point(225, 225)); List<Point> attributePoints = ((PolylineSvgNodeRenderer) root).getPoints(); - Assert.assertEquals(expectedPoints.size(), attributePoints.size()); + Assertions.assertEquals(expectedPoints.size(), attributePoints.size()); for (int x = 0; x < attributePoints.size(); x++) { - Assert.assertEquals(expectedPoints.get(x), attributePoints.get(x)); + Assertions.assertEquals(expectedPoints.get(x), attributePoints.get(x)); } } diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/impl/PolylineSvgNodeRendererUnitTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/impl/PolylineSvgNodeRendererUnitTest.java index 6aa8b46ea2..d6ece7cb91 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/impl/PolylineSvgNodeRendererUnitTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/impl/PolylineSvgNodeRendererUnitTest.java @@ -26,14 +26,13 @@ This file is part of the iText (R) project. import com.itextpdf.styledxmlparser.resolver.resource.ResourceResolver; import com.itextpdf.svg.renderers.SvgDrawContext; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.util.HashMap; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PolylineSvgNodeRendererUnitTest extends ExtendedITextTest { @Test @@ -41,6 +40,6 @@ public void getObjectBoundingBoxTest() { PolylineSvgNodeRenderer renderer = new PolygonSvgNodeRenderer(); SvgDrawContext context = new SvgDrawContext(new ResourceResolver(""), new FontProvider()); renderer.setAttributesAndStyles(new HashMap<>()); - Assert.assertNull(renderer.getObjectBoundingBox(context)); + Assertions.assertNull(renderer.getObjectBoundingBox(context)); } } diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/impl/PreserveAspectRatioSvgNodeRendererIntegrationTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/impl/PreserveAspectRatioSvgNodeRendererIntegrationTest.java index 8cc6227090..d7f04fbcb9 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/impl/PreserveAspectRatioSvgNodeRendererIntegrationTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/impl/PreserveAspectRatioSvgNodeRendererIntegrationTest.java @@ -28,20 +28,19 @@ This file is part of the iText (R) project. import com.itextpdf.test.ITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class PreserveAspectRatioSvgNodeRendererIntegrationTest extends SvgIntegrationTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/svg/renderers/impl/PreserveAspectRatioSvgNodeRendererIntegrationTest/"; private static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/svg/renderers/impl/PreserveAspectRatioSvgNodeRendererIntegrationTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { ITextTest.createDestinationFolder(DESTINATION_FOLDER); } diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/impl/PreserveAspectRatioSvgNodeRendererUnitTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/impl/PreserveAspectRatioSvgNodeRendererUnitTest.java index d0461f6f5d..598cbd8b04 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/impl/PreserveAspectRatioSvgNodeRendererUnitTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/impl/PreserveAspectRatioSvgNodeRendererUnitTest.java @@ -28,16 +28,15 @@ This file is part of the iText (R) project. import com.itextpdf.svg.SvgConstants; import com.itextpdf.svg.renderers.SvgDrawContext; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.util.Arrays; import java.util.HashMap; import java.util.Map; -@Category(UnitTest.class) +@Tag("UnitTest") public class PreserveAspectRatioSvgNodeRendererUnitTest extends ExtendedITextTest { private static final Rectangle VIEWPORT_VALUE = PageSize.DEFAULT; @@ -141,7 +140,7 @@ public void retrieveAlignAndMeetXMinYMinMeet() { String[] cmpAlignAndMeet = new String[]{align, meet}; String[] outAlignAndMeet = retrieveAlignAndMeet(align, meet); - Assert.assertArrayEquals(cmpAlignAndMeet, outAlignAndMeet); + Assertions.assertArrayEquals(cmpAlignAndMeet, outAlignAndMeet); } @Test @@ -151,7 +150,7 @@ public void retrieveAlignAndMeetXMinYMinSlice() { String[] cmpAlignAndMeet = new String[]{align, meet}; String[] outAlignAndMeet = retrieveAlignAndMeet(align, meet); - Assert.assertArrayEquals(cmpAlignAndMeet, outAlignAndMeet); + Assertions.assertArrayEquals(cmpAlignAndMeet, outAlignAndMeet); } @Test @@ -161,7 +160,7 @@ public void retrieveAlignAndMeetXMinYMinNone() { String[] cmpAlignAndMeet = new String[]{align, meet}; String[] outAlignAndMeet = retrieveAlignAndMeet(align, ""); - Assert.assertArrayEquals(cmpAlignAndMeet, outAlignAndMeet); + Assertions.assertArrayEquals(cmpAlignAndMeet, outAlignAndMeet); } @Test @@ -172,7 +171,7 @@ public void retrieveAlignAndMeetEmptyMeet() { String[] outAlignAndMeet = retrieveAlignAndMeet("", meet); //should fail, because align attribute must be present - Assert.assertFalse(Arrays.equals(cmpAlignAndMeet, outAlignAndMeet)); + Assertions.assertFalse(Arrays.equals(cmpAlignAndMeet, outAlignAndMeet)); } @Test @@ -183,7 +182,7 @@ public void retrieveAlignAndMeetEmptySlice() { String[] outAlignAndMeet = retrieveAlignAndMeet("", meet); //should fail, because align attribute must be present - Assert.assertFalse(Arrays.equals(cmpAlignAndMeet, outAlignAndMeet)); + Assertions.assertFalse(Arrays.equals(cmpAlignAndMeet, outAlignAndMeet)); } @Test @@ -193,7 +192,7 @@ public void retrieveAlignAndMeetNoneMeet() { String[] cmpAlignAndMeet = new String[]{align, meet}; String[] outAlignAndMeet = retrieveAlignAndMeet(align, meet); - Assert.assertArrayEquals(cmpAlignAndMeet, outAlignAndMeet); + Assertions.assertArrayEquals(cmpAlignAndMeet, outAlignAndMeet); } @Test @@ -203,7 +202,7 @@ public void retrieveAlignAndMeetNoneSlice() { String[] cmpAlignAndMeet = new String[]{align, meet}; String[] outAlignAndMeet = retrieveAlignAndMeet(align, meet); - Assert.assertArrayEquals(cmpAlignAndMeet, outAlignAndMeet); + Assertions.assertArrayEquals(cmpAlignAndMeet, outAlignAndMeet); } @Test @@ -213,7 +212,7 @@ public void retrieveAlignAndMeetAllDefault() { String[] cmpAlignAndMeet = new String[]{align, meet}; String[] outAlignAndMeet = retrieveAlignAndMeet("", ""); - Assert.assertArrayEquals(cmpAlignAndMeet, outAlignAndMeet); + Assertions.assertArrayEquals(cmpAlignAndMeet, outAlignAndMeet); } private void processAspectRatioPositionAndCompare(String alignValue, AffineTransform cmpTransform) { @@ -232,7 +231,7 @@ private void processAspectRatioPositionAndCompare(String alignValue, AffineTrans AffineTransform outTransform = renderer.processAspectRatioPosition(context, viewboxValues, alignValue, scaleWidth, scaleHeight); - Assert.assertTrue(cmpTransform.equals(outTransform)); + Assertions.assertTrue(cmpTransform.equals(outTransform)); } private String[] retrieveAlignAndMeet(String align, String meet) { diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/impl/RectangleSvgNodeRendererIntegrationTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/impl/RectangleSvgNodeRendererIntegrationTest.java index 413bf1a5cc..876b621805 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/impl/RectangleSvgNodeRendererIntegrationTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/impl/RectangleSvgNodeRendererIntegrationTest.java @@ -27,21 +27,20 @@ This file is part of the iText (R) project. import com.itextpdf.test.ITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class RectangleSvgNodeRendererIntegrationTest extends SvgIntegrationTest { public static final String sourceFolder = "./src/test/resources/com/itextpdf/svg/renderers/impl/RectangleSvgNodeRendererTest/"; public static final String destinationFolder = "./target/test/com/itextpdf/svg/renderers/impl/RectangleSvgNodeRendererTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { ITextTest.createDestinationFolder(destinationFolder); } diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/impl/RectangleSvgNodeRendererUnitTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/impl/RectangleSvgNodeRendererUnitTest.java index d25a8a8bfd..2c0d2b4972 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/impl/RectangleSvgNodeRendererUnitTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/impl/RectangleSvgNodeRendererUnitTest.java @@ -23,19 +23,18 @@ This file is part of the iText (R) project. package com.itextpdf.svg.renderers.impl; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class RectangleSvgNodeRendererUnitTest extends ExtendedITextTest { private static final float EPSILON = 0.00001f; RectangleSvgNodeRenderer renderer; - @Before + @BeforeEach public void setup() { renderer = new RectangleSvgNodeRenderer(); } @@ -43,48 +42,48 @@ public void setup() { @Test public void checkRadiusTest() { float rad = renderer.checkRadius(0f, 20f); - Assert.assertEquals(0f, rad, EPSILON); + Assertions.assertEquals(0f, rad, EPSILON); } @Test public void checkRadiusNegativeTest() { float rad = renderer.checkRadius(-1f, 20f); - Assert.assertEquals(0f, rad, EPSILON); + Assertions.assertEquals(0f, rad, EPSILON); } @Test public void checkRadiusTooLargeTest() { float rad = renderer.checkRadius(30f, 20f); - Assert.assertEquals(10f, rad, EPSILON); + Assertions.assertEquals(10f, rad, EPSILON); } @Test public void checkRadiusTooLargeNegativeTest() { float rad = renderer.checkRadius(-100f, 20f); - Assert.assertEquals(0f, rad, EPSILON); + Assertions.assertEquals(0f, rad, EPSILON); } @Test public void checkRadiusHalfLengthTest() { float rad = renderer.checkRadius(10f, 20f); - Assert.assertEquals(10f, rad, EPSILON); + Assertions.assertEquals(10f, rad, EPSILON); } @Test public void findCircularRadiusTest() { float rad = renderer.findCircularRadius(0f, 20f, 100f, 200f); - Assert.assertEquals(20f, rad, EPSILON); + Assertions.assertEquals(20f, rad, EPSILON); } @Test public void findCircularRadiusHalfLengthTest() { float rad = renderer.findCircularRadius(0f, 200f, 100f, 200f); - Assert.assertEquals(50f, rad, EPSILON); + Assertions.assertEquals(50f, rad, EPSILON); } @Test public void findCircularRadiusSmallWidthTest() { float rad = renderer.findCircularRadius(0f, 20f, 5f, 200f); - Assert.assertEquals(2.5f, rad, EPSILON); + Assertions.assertEquals(2.5f, rad, EPSILON); } } diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/impl/SimpleSvgTagSvgNodeRendererIntegrationTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/impl/SimpleSvgTagSvgNodeRendererIntegrationTest.java index ed00397b9b..fef9cd3347 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/impl/SimpleSvgTagSvgNodeRendererIntegrationTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/impl/SimpleSvgTagSvgNodeRendererIntegrationTest.java @@ -30,23 +30,22 @@ This file is part of the iText (R) project. import com.itextpdf.test.ITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class SimpleSvgTagSvgNodeRendererIntegrationTest extends SvgIntegrationTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/svg/renderers/impl/RootSvgNodeRendererTest/svg/"; private static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/svg/renderers/impl/RootSvgNodeRendererTest/svg/"; - @BeforeClass + @BeforeAll public static void beforeClass() { ITextTest.createDestinationFolder(DESTINATION_FOLDER); } @@ -102,30 +101,30 @@ public void absentY() throws IOException, InterruptedException { @Test public void invalidHeight() throws IOException, InterruptedException { - Exception e = Assert.assertThrows(StyledXMLParserException.class, + Exception e = Assertions.assertThrows(StyledXMLParserException.class, () -> convertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER,"invalidHeight") ); - Assert.assertEquals(MessageFormatUtil.format(StyledXMLParserException.NAN, "abc"), e.getMessage()); + Assertions.assertEquals(MessageFormatUtil.format(StyledXMLParserException.NAN, "abc"), e.getMessage()); } @Test public void invalidWidth() throws IOException, InterruptedException { - Exception e = Assert.assertThrows(StyledXMLParserException.class, + Exception e = Assertions.assertThrows(StyledXMLParserException.class, () -> convertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER,"invalidWidth") ); - Assert.assertEquals(MessageFormatUtil.format(StyledXMLParserException.NAN, "abc"), e.getMessage()); + Assertions.assertEquals(MessageFormatUtil.format(StyledXMLParserException.NAN, "abc"), e.getMessage()); } @Test public void invalidX() throws IOException, InterruptedException { - Assert.assertThrows(StyledXMLParserException.class, + Assertions.assertThrows(StyledXMLParserException.class, () -> convertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER,"invalidX") ); } @Test public void invalidY() throws IOException, InterruptedException { - Assert.assertThrows(StyledXMLParserException.class, + Assertions.assertThrows(StyledXMLParserException.class, () -> convertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER,"invalidY") ); } diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/impl/StopSvgNodeRendererUnitTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/impl/StopSvgNodeRendererUnitTest.java index 7f324daadc..9a3dd7c144 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/impl/StopSvgNodeRendererUnitTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/impl/StopSvgNodeRendererUnitTest.java @@ -28,15 +28,14 @@ This file is part of the iText (R) project. import com.itextpdf.svg.renderers.ISvgNodeRenderer; import com.itextpdf.svg.renderers.SvgDrawContext; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.util.HashMap; import java.util.Map; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class StopSvgNodeRendererUnitTest extends ExtendedITextTest { private static final float DELTA = 0; @@ -50,7 +49,7 @@ public void getOffsetPercentageValueTest() { double expected = 0.5; - Assert.assertEquals(expected, renderer.getOffset(), DELTA); + Assertions.assertEquals(expected, renderer.getOffset(), DELTA); } @Test @@ -63,7 +62,7 @@ public void getOffsetNumericValueTest() { double expected = 0.5; - Assert.assertEquals(expected, renderer.getOffset(), DELTA); + Assertions.assertEquals(expected, renderer.getOffset(), DELTA); } @Test @@ -76,7 +75,7 @@ public void getOffsetMoreThanOneValueTest() { double expected = 1; - Assert.assertEquals(expected, renderer.getOffset(), DELTA); + Assertions.assertEquals(expected, renderer.getOffset(), DELTA); } @Test @@ -89,7 +88,7 @@ public void getOffsetLessThanZeroValueTest() { double expected = 0; - Assert.assertEquals(expected, renderer.getOffset(), DELTA); + Assertions.assertEquals(expected, renderer.getOffset(), DELTA); } @Test @@ -102,7 +101,7 @@ public void getOffsetNoneValueTest() { double expected = 0; - Assert.assertEquals(expected, renderer.getOffset(), DELTA); + Assertions.assertEquals(expected, renderer.getOffset(), DELTA); } @Test @@ -115,7 +114,7 @@ public void getOffsetRandomStringValueTest() { double expected = 0; - Assert.assertEquals(expected, renderer.getOffset(), DELTA); + Assertions.assertEquals(expected, renderer.getOffset(), DELTA); } @Test @@ -128,7 +127,7 @@ public void getOffsetEmptyStringValueTest() { double expected = 0; - Assert.assertEquals(expected, renderer.getOffset(), DELTA); + Assertions.assertEquals(expected, renderer.getOffset(), DELTA); } @Test @@ -142,7 +141,7 @@ public void getStopColorTest() { float[] expected = {1, 0, 0, 1}; float[] actual = renderer.getStopColor(); - Assert.assertArrayEquals(expected, actual, DELTA); + Assertions.assertArrayEquals(expected, actual, DELTA); } @Test @@ -156,7 +155,7 @@ public void getStopColorNoneValueTest() { float[] expected = {0, 0, 0, 1}; float[] actual = renderer.getStopColor(); - Assert.assertArrayEquals(expected, actual, DELTA); + Assertions.assertArrayEquals(expected, actual, DELTA); } @Test @@ -170,7 +169,7 @@ public void getStopColorRandomStringValueTest() { float[] expected = {0, 0, 0, 1}; float[] actual = renderer.getStopColor(); - Assert.assertArrayEquals(expected, actual, DELTA); + Assertions.assertArrayEquals(expected, actual, DELTA); } @Test @@ -184,7 +183,7 @@ public void getStopColorEmptyStringTest() { float[] expected = {0, 0, 0, 1}; float[] actual = renderer.getStopColor(); - Assert.assertArrayEquals(expected, actual, DELTA); + Assertions.assertArrayEquals(expected, actual, DELTA); } @Test @@ -198,7 +197,7 @@ public void getStopColorOpacityTest() { float[] expected = {0, 0, 0, 1}; float[] actual = renderer.getStopColor(); - Assert.assertArrayEquals(expected, actual, DELTA); + Assertions.assertArrayEquals(expected, actual, DELTA); } @Test @@ -211,7 +210,7 @@ public void getStopOpacityTest() { float expected = 1; - Assert.assertEquals(expected, renderer.getStopOpacity(), DELTA); + Assertions.assertEquals(expected, renderer.getStopOpacity(), DELTA); } @Test @@ -224,7 +223,7 @@ public void getStopOpacityNoneValueTest() { float expected = 1; - Assert.assertEquals(expected, renderer.getStopOpacity(), DELTA); + Assertions.assertEquals(expected, renderer.getStopOpacity(), DELTA); } @Test @@ -237,7 +236,7 @@ public void getStopOpacityRandomStringValueTest() { float expected = 1; - Assert.assertEquals(expected, renderer.getStopOpacity(), DELTA); + Assertions.assertEquals(expected, renderer.getStopOpacity(), DELTA); } @Test @@ -250,7 +249,7 @@ public void getStopOpacityEmptyStringTest() { float expected = 1; - Assert.assertEquals(expected, renderer.getStopOpacity(), DELTA); + Assertions.assertEquals(expected, renderer.getStopOpacity(), DELTA); } @Test @@ -263,24 +262,24 @@ public void createDeepCopyTest() { ISvgNodeRenderer copy = renderer.createDeepCopy(); - Assert.assertNotSame(renderer, copy); - Assert.assertEquals(renderer.getClass(), copy.getClass()); - Assert.assertEquals(renderer.getAttributeMapCopy(), copy.getAttributeMapCopy()); + Assertions.assertNotSame(renderer, copy); + Assertions.assertEquals(renderer.getClass(), copy.getClass()); + Assertions.assertEquals(renderer.getAttributeMapCopy(), copy.getAttributeMapCopy()); } @Test public void doDrawTest() { StopSvgNodeRenderer renderer = new StopSvgNodeRenderer(); - Exception e = Assert.assertThrows(UnsupportedOperationException.class, + Exception e = Assertions.assertThrows(UnsupportedOperationException.class, () -> renderer.doDraw(new SvgDrawContext(null, null)) ); - Assert.assertEquals(SvgExceptionMessageConstant.DRAW_NO_DRAW, e.getMessage()); + Assertions.assertEquals(SvgExceptionMessageConstant.DRAW_NO_DRAW, e.getMessage()); } @Test public void noObjectBoundingBoxTest() { StopSvgNodeRenderer renderer = new StopSvgNodeRenderer(); - Assert.assertNull(renderer.getObjectBoundingBox(null)); + Assertions.assertNull(renderer.getObjectBoundingBox(null)); } } diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/impl/SvgTagSvgNodeRendererUnitTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/impl/SvgTagSvgNodeRendererUnitTest.java index b9019c30cd..ebb5f649ff 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/impl/SvgTagSvgNodeRendererUnitTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/impl/SvgTagSvgNodeRendererUnitTest.java @@ -30,14 +30,13 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.pdf.xobject.PdfFormXObject; import com.itextpdf.svg.renderers.SvgDrawContext; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.io.ByteArrayOutputStream; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class SvgTagSvgNodeRendererUnitTest extends ExtendedITextTest { @Test @@ -60,19 +59,19 @@ public void calculateNestedViewportSameAsParentTest() { renderer.setParent(parent); Rectangle actual = renderer.calculateViewPort(context); - Assert.assertTrue(expected.equalsWithEpsilon(actual)); + Assertions.assertTrue(expected.equalsWithEpsilon(actual)); } @Test public void equalsOtherObjectNegativeTest() { SvgTagSvgNodeRenderer one = new SvgTagSvgNodeRenderer(); CircleSvgNodeRenderer two = new CircleSvgNodeRenderer(); - Assert.assertFalse(one.equals(two)); + Assertions.assertFalse(one.equals(two)); } @Test public void noObjectBoundingBoxTest() { SvgTagSvgNodeRenderer renderer = new SvgTagSvgNodeRenderer(); - Assert.assertNull(renderer.getObjectBoundingBox(null)); + Assertions.assertNull(renderer.getObjectBoundingBox(null)); } } diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/impl/SymbolSvgNodeRendererUnitTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/impl/SymbolSvgNodeRendererUnitTest.java index 90980d2ba8..0a0a28232f 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/impl/SymbolSvgNodeRendererUnitTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/impl/SymbolSvgNodeRendererUnitTest.java @@ -23,18 +23,17 @@ This file is part of the iText (R) project. package com.itextpdf.svg.renderers.impl; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class SymbolSvgNodeRendererUnitTest extends ExtendedITextTest { @Test public void noObjectBoundingBoxTest() { SymbolSvgNodeRenderer renderer = new SymbolSvgNodeRenderer(); - Assert.assertNull(renderer.getObjectBoundingBox(null)); + Assertions.assertNull(renderer.getObjectBoundingBox(null)); } } diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/impl/SymbolTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/impl/SymbolTest.java index 56da028f79..4d4a614171 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/impl/SymbolTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/impl/SymbolTest.java @@ -29,28 +29,27 @@ This file is part of the iText (R) project. import com.itextpdf.test.ITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class SymbolTest extends SvgIntegrationTest { public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/svg/renderers/impl/SymbolTest/"; public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/svg/renderers/impl/SymbolTest/"; private ISvgConverterProperties properties; - @BeforeClass + @BeforeAll public static void beforeClass() { ITextTest.createDestinationFolder(DESTINATION_FOLDER); } - @Before + @BeforeEach public void before() { properties = new SvgConverterProperties().setBaseUri(SOURCE_FOLDER); } diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest.java index 1f736c6e88..aafe460b88 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest.java @@ -28,22 +28,21 @@ This file is part of the iText (R) project. import com.itextpdf.test.ITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class TSpanNodeRendererIntegrationTest extends SvgIntegrationTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/"; private static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { ITextTest.createDestinationFolder(DESTINATION_FOLDER); } @@ -66,7 +65,7 @@ public void TSpanRelativeMoveZeroXTest() throws IOException, InterruptedExceptio @Test public void TSpanRelativeMoveInvalidXTest() throws IOException, InterruptedException { - Assert.assertThrows(StyledXMLParserException.class, + Assertions.assertThrows(StyledXMLParserException.class, () -> convertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "textspan-relativeMove-invalidX") ); } @@ -88,7 +87,7 @@ public void TSpanRelativeMoveZeroYTest() throws IOException, InterruptedExceptio @Test public void TSpanRelativeMoveInvalidYTest() throws IOException, InterruptedException { - Assert.assertThrows(StyledXMLParserException.class, + Assertions.assertThrows(StyledXMLParserException.class, () -> convertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "textspan-relativeMove-invalidY") ); } @@ -116,7 +115,7 @@ public void TSpanAbsolutePositionZeroXTest() throws IOException, InterruptedExce @Test public void TSpanAbsolutePositionInvalidXTest() throws IOException, InterruptedException { - Assert.assertThrows(StyledXMLParserException.class, + Assertions.assertThrows(StyledXMLParserException.class, () -> convertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "textspan-absolutePosition-invalidX") ); } @@ -138,7 +137,7 @@ public void TSpanAbsolutePositionZeroYTest() throws IOException, InterruptedExce @Test public void TSpanAbsolutePositionInvalidYTest() throws IOException, InterruptedException { - Assert.assertThrows(StyledXMLParserException.class, + Assertions.assertThrows(StyledXMLParserException.class, () -> convertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "textspan-absolutePosition-invalidY") ); } @@ -224,4 +223,19 @@ public void tspanNestedRelativeOffsets() throws IOException, InterruptedExceptio public void simpleNestedTspanTest() throws IOException, InterruptedException { convertAndCompareSinglePage(SOURCE_FOLDER, DESTINATION_FOLDER, "simpleNestedTspan"); } + + @Test + public void xWithoutYTest() throws IOException, InterruptedException { + convertAndCompareSinglePage(SOURCE_FOLDER, DESTINATION_FOLDER, "xWithoutY"); + } + + @Test + public void noXNoYTest() throws IOException, InterruptedException { + convertAndCompareSinglePage(SOURCE_FOLDER, DESTINATION_FOLDER, "noXNoY"); + } + + @Test + public void yWithoutXTest() throws IOException, InterruptedException { + convertAndCompareSinglePage(SOURCE_FOLDER, DESTINATION_FOLDER, "yWithoutX"); + } } diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/impl/TextLeafSvgNodeRendererIntegrationTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/impl/TextLeafSvgNodeRendererIntegrationTest.java index 9ae1edccd5..8b423b6ab6 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/impl/TextLeafSvgNodeRendererIntegrationTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/impl/TextLeafSvgNodeRendererIntegrationTest.java @@ -26,13 +26,12 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.font.PdfFontFactory; import com.itextpdf.svg.SvgConstants; import com.itextpdf.svg.renderers.SvgIntegrationTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class TextLeafSvgNodeRendererIntegrationTest extends SvgIntegrationTest { @Test @@ -43,7 +42,7 @@ public void getContentLengthBaseTest() throws Exception { PdfFont font = PdfFontFactory.createFont(); float actual = toTest.getTextContentLength(12, font); float expected = 17.085f; - Assert.assertEquals(expected, actual, 1e-6f); + Assertions.assertEquals(expected, actual, 1e-6f); } @Test @@ -53,7 +52,7 @@ public void getContentLengthNoValueTest() throws Exception { PdfFont font = PdfFontFactory.createFont(); float actual = toTest.getTextContentLength(12, font); float expected = 27.336f; - Assert.assertEquals(expected, actual,1e-6f); + Assertions.assertEquals(expected, actual,1e-6f); } @Test @@ -64,7 +63,7 @@ public void getContentLengthNaNTest() throws Exception { PdfFont font = PdfFontFactory.createFont(); float actual = toTest.getTextContentLength(12, font); float expected = 0.0f; - Assert.assertEquals(expected, actual, 1e-6f); + Assertions.assertEquals(expected, actual, 1e-6f); } @Test @@ -75,6 +74,6 @@ public void getContentLengthNegativeTest() throws Exception { PdfFont font = PdfFontFactory.createFont(); float actual = toTest.getTextContentLength(12, font); float expected = 27.336f; - Assert.assertEquals(expected, actual,1e-6f); + Assertions.assertEquals(expected, actual,1e-6f); } } diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/impl/TextLeafSvgNodeRendererUnitTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/impl/TextLeafSvgNodeRendererUnitTest.java index 32adf295e3..e28e023248 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/impl/TextLeafSvgNodeRendererUnitTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/impl/TextLeafSvgNodeRendererUnitTest.java @@ -23,18 +23,17 @@ This file is part of the iText (R) project. package com.itextpdf.svg.renderers.impl; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class TextLeafSvgNodeRendererUnitTest extends ExtendedITextTest { @Test public void noObjectBoundingBoxTest() { TextLeafSvgNodeRenderer renderer = new TextLeafSvgNodeRenderer(); - Assert.assertNull(renderer.getObjectBoundingBox(null)); + Assertions.assertNull(renderer.getObjectBoundingBox(null)); } } diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/impl/TextSvgBranchRendererIntegrationTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/impl/TextSvgBranchRendererIntegrationTest.java index 0da0f2d6e9..4b950a79d8 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/impl/TextSvgBranchRendererIntegrationTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/impl/TextSvgBranchRendererIntegrationTest.java @@ -25,22 +25,21 @@ This file is part of the iText (R) project. import com.itextpdf.styledxmlparser.exceptions.StyledXMLParserException; import com.itextpdf.svg.renderers.SvgIntegrationTest; import com.itextpdf.test.ITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class TextSvgBranchRendererIntegrationTest extends SvgIntegrationTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/svg/renderers/impl/TextSvgBranchRendererIntegrationTest/"; private static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/svg/renderers/impl/TextSvgBranchRendererIntegrationTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { ITextTest.createDestinationFolder(DESTINATION_FOLDER); } @@ -134,7 +133,7 @@ public void textAbsolutePositionzeroXTest() throws IOException, InterruptedExcep @Test public void textAbsolutePositionInvalidXTest() throws IOException, InterruptedException { - Assert.assertThrows(StyledXMLParserException.class, + Assertions.assertThrows(StyledXMLParserException.class, () -> convertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "text-absolutePosition-invalidX") ); } @@ -157,7 +156,7 @@ public void textAbsolutePositionZeroYTest() throws IOException, InterruptedExcep @Test public void textAbsolutePositionInvalidYTest() throws IOException, InterruptedException { - Assert.assertThrows(StyledXMLParserException.class, + Assertions.assertThrows(StyledXMLParserException.class, () -> convertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "text-absolutePosition-invalidY") ); } @@ -181,7 +180,7 @@ public void textRelativeMoveZeroXTest() throws IOException, InterruptedException @Test public void textRelativeMoveInvalidXTest() throws IOException, InterruptedException { - Assert.assertThrows(StyledXMLParserException.class, + Assertions.assertThrows(StyledXMLParserException.class, () -> convertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "text-relativeMove-invalidX") ); } @@ -204,7 +203,7 @@ public void textRelativeMoveZeroYTest() throws IOException, InterruptedException @Test public void textRelativeMoveInvalidYTest() throws IOException, InterruptedException { - Assert.assertThrows(StyledXMLParserException.class, + Assertions.assertThrows(StyledXMLParserException.class, () -> convertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "text-relativeMove-invalidY") ); } @@ -225,7 +224,6 @@ public void textFontSizeExUnitsTest() throws IOException, InterruptedException { } @Test - // TODO change cmp after DEVSIX-4143 is fixed public void tspanWithOneAbsoluteCoordinateTest() throws IOException, InterruptedException { convertAndCompareSinglePage(SOURCE_FOLDER, DESTINATION_FOLDER, "tspanWithOneAbsoluteCoordinateTest"); } diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/impl/UseIntegrationTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/impl/UseIntegrationTest.java index 3d1ce3f163..9f3f6af281 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/impl/UseIntegrationTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/impl/UseIntegrationTest.java @@ -26,15 +26,14 @@ This file is part of the iText (R) project. import com.itextpdf.svg.processors.impl.SvgConverterProperties; import com.itextpdf.svg.renderers.SvgIntegrationTest; import com.itextpdf.test.ITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class UseIntegrationTest extends SvgIntegrationTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/svg/renderers/impl/UseIntegrationTest/"; @@ -42,12 +41,12 @@ public class UseIntegrationTest extends SvgIntegrationTest { private ISvgConverterProperties properties; - @BeforeClass + @BeforeAll public static void beforeClass() { ITextTest.createDestinationFolder(DESTINATION_FOLDER); } - @Before + @BeforeEach public void before() { properties = new SvgConverterProperties().setBaseUri(SOURCE_FOLDER); } diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/impl/UseSvgNodeRendererUnitTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/impl/UseSvgNodeRendererUnitTest.java index d5705c68d8..9c6f691385 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/impl/UseSvgNodeRendererUnitTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/impl/UseSvgNodeRendererUnitTest.java @@ -23,18 +23,17 @@ This file is part of the iText (R) project. package com.itextpdf.svg.renderers.impl; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class UseSvgNodeRendererUnitTest extends ExtendedITextTest { @Test public void noObjectBoundingBoxTest() { UseSvgNodeRenderer renderer = new UseSvgNodeRenderer(); - Assert.assertNull(renderer.getObjectBoundingBox(null)); + Assertions.assertNull(renderer.getObjectBoundingBox(null)); } } diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/impl/UseUnitTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/impl/UseUnitTest.java index 8213177690..4915e679d3 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/impl/UseUnitTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/impl/UseUnitTest.java @@ -32,13 +32,12 @@ This file is part of the iText (R) project. import com.itextpdf.svg.renderers.ISvgNodeRenderer; import com.itextpdf.svg.renderers.SvgDrawContext; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class UseUnitTest extends ExtendedITextTest { @Test @@ -56,6 +55,6 @@ public void referenceNotFoundTest() { pdfDocument.close(); - Assert.assertFalse(renderer.isDrawn()); + Assertions.assertFalse(renderer.isDrawn()); } } diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/impl/ViewBoxSvgTagSvgNodeRendererIntegrationTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/impl/ViewBoxSvgTagSvgNodeRendererIntegrationTest.java index 2f4eeaa9e9..2532211562 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/impl/ViewBoxSvgTagSvgNodeRendererIntegrationTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/impl/ViewBoxSvgTagSvgNodeRendererIntegrationTest.java @@ -24,21 +24,20 @@ This file is part of the iText (R) project. import com.itextpdf.svg.renderers.SvgIntegrationTest; import com.itextpdf.test.ITextTest; -import com.itextpdf.test.annotations.type.IntegrationTest; import java.io.IOException; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class ViewBoxSvgTagSvgNodeRendererIntegrationTest extends SvgIntegrationTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/svg/renderers/impl/RootSvgNodeRendererTest/viewbox/"; private static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/svg/renderers/impl/RootSvgNodeRendererTest/viewbox/"; - @BeforeClass + @BeforeAll public static void beforeClass() { ITextTest.createDestinationFolder(DESTINATION_FOLDER); } diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/impl/XLinkDataTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/impl/XLinkDataTest.java index 0cf3971aeb..0e26b868ad 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/impl/XLinkDataTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/impl/XLinkDataTest.java @@ -27,21 +27,20 @@ This file is part of the iText (R) project. import com.itextpdf.test.ITextTest; import com.itextpdf.test.annotations.LogMessage; import com.itextpdf.test.annotations.LogMessages; -import com.itextpdf.test.annotations.type.IntegrationTest; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; import java.io.IOException; -@Category(IntegrationTest.class) +@Tag("IntegrationTest") public class XLinkDataTest extends SvgIntegrationTest { private static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/svg/renderers/impl/XLinkDataTest/"; private static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/svg/renderers/impl/XLinkDataTest/"; - @BeforeClass + @BeforeAll public static void beforeClass() { ITextTest.createDestinationFolder(DESTINATION_FOLDER); } diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/path/PathShapeMapperTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/path/PathShapeMapperTest.java index 3ce8cb3ca1..8e5a100743 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/path/PathShapeMapperTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/path/PathShapeMapperTest.java @@ -24,121 +24,120 @@ This file is part of the iText (R) project. import com.itextpdf.svg.renderers.path.impl.PathShapeMapper; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class PathShapeMapperTest extends ExtendedITextTest { private static IPathShapeMapper mapper; - @BeforeClass + @BeforeAll public static void setUpClass() { mapper = new PathShapeMapper(); } @Test public void testExistsEllipseRel() { - Assert.assertNotNull(mapper.getMapping().get("a")); + Assertions.assertNotNull(mapper.getMapping().get("a")); } @Test public void testExistsEllipseAbs() { - Assert.assertNotNull(mapper.getMapping().get("A")); + Assertions.assertNotNull(mapper.getMapping().get("A")); } @Test public void testExistsCubicRel() { - Assert.assertNotNull(mapper.getMapping().get("c")); + Assertions.assertNotNull(mapper.getMapping().get("c")); } @Test public void testExistsCubicAbs() { - Assert.assertNotNull(mapper.getMapping().get("C")); + Assertions.assertNotNull(mapper.getMapping().get("C")); } @Test public void testExistsHorizontalLineRel() { - Assert.assertNotNull(mapper.getMapping().get("h")); + Assertions.assertNotNull(mapper.getMapping().get("h")); } @Test public void testExistsHorizontalLineAbs() { - Assert.assertNotNull(mapper.getMapping().get("H")); + Assertions.assertNotNull(mapper.getMapping().get("H")); } @Test public void testExistsLineRel() { - Assert.assertNotNull(mapper.getMapping().get("l")); + Assertions.assertNotNull(mapper.getMapping().get("l")); } @Test public void testExistsLineAbs() { - Assert.assertNotNull(mapper.getMapping().get("L")); + Assertions.assertNotNull(mapper.getMapping().get("L")); } @Test public void testExistsMoveRel() { - Assert.assertNotNull(mapper.getMapping().get("m")); + Assertions.assertNotNull(mapper.getMapping().get("m")); } @Test public void testExistsMoveAbs() { - Assert.assertNotNull(mapper.getMapping().get("M")); + Assertions.assertNotNull(mapper.getMapping().get("M")); } @Test public void testExistsQuadAbs() { - Assert.assertNotNull(mapper.getMapping().get("Q")); + Assertions.assertNotNull(mapper.getMapping().get("Q")); } @Test public void testExistsQuadRel() { - Assert.assertNotNull(mapper.getMapping().get("q")); + Assertions.assertNotNull(mapper.getMapping().get("q")); } @Test public void testExistsSmoothCubicAbs() { - Assert.assertNotNull(mapper.getMapping().get("S")); + Assertions.assertNotNull(mapper.getMapping().get("S")); } @Test public void testExistsSmoothCubicRel() { - Assert.assertNotNull(mapper.getMapping().get("s")); + Assertions.assertNotNull(mapper.getMapping().get("s")); } @Test public void testExistsVerticalLineRel() { - Assert.assertNotNull(mapper.getMapping().get("v")); + Assertions.assertNotNull(mapper.getMapping().get("v")); } @Test public void testExistsVerticalLineAbs() { - Assert.assertNotNull(mapper.getMapping().get("V")); + Assertions.assertNotNull(mapper.getMapping().get("V")); } @Test public void testExistsClosePathRel() { - Assert.assertNotNull(mapper.getMapping().get("z")); + Assertions.assertNotNull(mapper.getMapping().get("z")); } @Test public void testExistsClosePathAbs() { - Assert.assertNotNull(mapper.getMapping().get("Z")); + Assertions.assertNotNull(mapper.getMapping().get("Z")); } @Test public void testExistsSmoothQuadAbs() { - Assert.assertNotNull(mapper.getMapping().get("T")); + Assertions.assertNotNull(mapper.getMapping().get("T")); } @Test public void testExistsSmoothQuadRel() { - Assert.assertNotNull(mapper.getMapping().get("t")); + Assertions.assertNotNull(mapper.getMapping().get("t")); } // nonsensical operators @Test public void testNotExistsNonExistingOperator1() { - Assert.assertNull(mapper.getMapping().get("e")); + Assertions.assertNull(mapper.getMapping().get("e")); } @Test public void testNotExistsNonExistingOperator2() { - Assert.assertNull(mapper.getMapping().get("Y")); + Assertions.assertNull(mapper.getMapping().get("Y")); } @Test public void testNotExistsNonExistingOperator3() { - Assert.assertNull(mapper.getMapping().get("3")); + Assertions.assertNull(mapper.getMapping().get("3")); } @Test public void testNotExistsNonExistingOperator4() { - Assert.assertNull(mapper.getMapping().get("am")); + Assertions.assertNull(mapper.getMapping().get("am")); } @Test public void testNotExistsNonExistingOperator5() { - Assert.assertNull(mapper.getMapping().get("Pos")); + Assertions.assertNull(mapper.getMapping().get("Pos")); } } diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/path/impl/EllipseArcTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/path/impl/EllipseArcTest.java index 4a74771e27..8dfb5d61c3 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/path/impl/EllipseArcTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/path/impl/EllipseArcTest.java @@ -24,21 +24,20 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.geom.Point; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import static com.itextpdf.svg.renderers.path.impl.EllipticalCurveTo.EllipseArc; -@Category(UnitTest.class) +@Tag("UnitTest") public class EllipseArcTest extends ExtendedITextTest { private static final double DELTA = 0.00001; private void assertPointEqual(Point expected, Point actual) { - Assert.assertEquals(expected.x, actual.x, DELTA); - Assert.assertEquals(expected.y, actual.y, DELTA); + Assertions.assertEquals(expected.getX(), actual.getX(), DELTA); + Assertions.assertEquals(expected.getY(), actual.getY(), DELTA); } @Test @@ -46,8 +45,8 @@ public void testCircleSweepLarge() { EllipseArc arc = EllipseArc.getEllipse(new Point(0, 0), new Point(20, 0), 10, 10, true, true); assertPointEqual(new Point(0, -10), arc.ll); assertPointEqual(new Point(20, 10), arc.ur); - Assert.assertEquals(180, arc.extent, DELTA); - Assert.assertEquals(180, arc.startAng, DELTA); + Assertions.assertEquals(180, arc.extent, DELTA); + Assertions.assertEquals(180, arc.startAng, DELTA); } @Test @@ -55,8 +54,8 @@ public void testCircleSweepNotLarge() { EllipseArc arc = EllipseArc.getEllipse(new Point(0, 0), new Point(20, 0), 10, 10, true, false); assertPointEqual(new Point(0, -10), arc.ll); assertPointEqual(new Point(20, 10), arc.ur); - Assert.assertEquals(180, arc.extent, DELTA); - Assert.assertEquals(180, arc.startAng, DELTA); + Assertions.assertEquals(180, arc.extent, DELTA); + Assertions.assertEquals(180, arc.startAng, DELTA); } @Test @@ -64,8 +63,8 @@ public void testCircleNotSweepLarge() { EllipseArc arc = EllipseArc.getEllipse(new Point(0, 0), new Point(20, 0), 10, 10, false, true); assertPointEqual(new Point(0, -10), arc.ll); assertPointEqual(new Point(20, 10), arc.ur); - Assert.assertEquals(180, arc.extent, DELTA); - Assert.assertEquals(0, arc.startAng, DELTA); + Assertions.assertEquals(180, arc.extent, DELTA); + Assertions.assertEquals(0, arc.startAng, DELTA); } @Test @@ -73,8 +72,8 @@ public void testCircleNotSweepNotLarge() { EllipseArc arc = EllipseArc.getEllipse(new Point(0, 0), new Point(20, 0), 10, 10, false, false); assertPointEqual(new Point(0, -10), arc.ll); assertPointEqual(new Point(20, 10), arc.ur); - Assert.assertEquals(180, arc.extent, DELTA); - Assert.assertEquals(0, arc.startAng, DELTA); + Assertions.assertEquals(180, arc.extent, DELTA); + Assertions.assertEquals(0, arc.startAng, DELTA); } @Test @@ -82,8 +81,8 @@ public void testEllipseSweepLarge() { EllipseArc arc = EllipseArc.getEllipse(new Point(0, 0), new Point(20, 0), 30, 10, true, true); assertPointEqual(new Point(-20, -19.428090), arc.ll); assertPointEqual(new Point(40, 0.571909), arc.ur); - Assert.assertEquals(321.057558, arc.extent, DELTA); - Assert.assertEquals(109.471220, arc.startAng, DELTA); + Assertions.assertEquals(321.057558, arc.extent, DELTA); + Assertions.assertEquals(109.471220, arc.startAng, DELTA); } @Test @@ -91,8 +90,8 @@ public void testEllipseSweepNotLarge() { EllipseArc arc = EllipseArc.getEllipse(new Point(0, 0), new Point(20, 0), 30, 10, true, false); assertPointEqual(new Point(-20, -0.571909), arc.ll); assertPointEqual(new Point(40, 19.428090), arc.ur); - Assert.assertEquals(38.942441, arc.extent, DELTA); - Assert.assertEquals(250.528779, arc.startAng, DELTA); + Assertions.assertEquals(38.942441, arc.extent, DELTA); + Assertions.assertEquals(250.528779, arc.startAng, DELTA); } @Test @@ -100,8 +99,8 @@ public void testEllipseNotSweepLarge() { EllipseArc arc = EllipseArc.getEllipse(new Point(0, 0), new Point(20, 0), 30, 10, false, true); assertPointEqual(new Point(-20, -0.571909), arc.ll); assertPointEqual(new Point(40, 19.428090), arc.ur); - Assert.assertEquals(321.057558, arc.extent, DELTA); - Assert.assertEquals(289.4712206344907, arc.startAng, DELTA); + Assertions.assertEquals(321.057558, arc.extent, DELTA); + Assertions.assertEquals(289.4712206344907, arc.startAng, DELTA); } @Test @@ -109,7 +108,7 @@ public void testEllipseNotSweepNotLarge() { EllipseArc arc = EllipseArc.getEllipse(new Point(0, 0), new Point(20, 0), 30, 10, false, false); assertPointEqual(new Point(-20, -19.428090), arc.ll); assertPointEqual(new Point(40, 0.5719095), arc.ur); - Assert.assertEquals(38.942441, arc.extent, DELTA); - Assert.assertEquals(70.528779, arc.startAng, DELTA); + Assertions.assertEquals(38.942441, arc.extent, DELTA); + Assertions.assertEquals(70.528779, arc.startAng, DELTA); } } diff --git a/svg/src/test/java/com/itextpdf/svg/renderers/path/impl/EllipticalPathOperatorTest.java b/svg/src/test/java/com/itextpdf/svg/renderers/path/impl/EllipticalPathOperatorTest.java index daa5254afd..a71c52b83e 100644 --- a/svg/src/test/java/com/itextpdf/svg/renderers/path/impl/EllipticalPathOperatorTest.java +++ b/svg/src/test/java/com/itextpdf/svg/renderers/path/impl/EllipticalPathOperatorTest.java @@ -24,13 +24,12 @@ This file is part of the iText (R) project. import com.itextpdf.kernel.geom.Point; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; -@Category(UnitTest.class) +@Tag("UnitTest") public class EllipticalPathOperatorTest extends ExtendedITextTest { // tests for coordinates @Test @@ -39,7 +38,7 @@ public void testBasicParameterSet() { // String array length = 7 absoluteElliptic.setCoordinates(new String[]{"40", "40", "0", "0", "0", "20", "20"}, new Point()); String[] result = absoluteElliptic.getCoordinates(); - Assert.assertEquals(7, result.length); + Assertions.assertEquals(7, result.length); } @Test @@ -48,7 +47,7 @@ public void testTooManyParameterSet() { // String array length = 8 absoluteElliptic.setCoordinates(new String[]{"40", "40", "0", "0", "0", "20", "20", "1"}, new Point()); String[] result = absoluteElliptic.getCoordinates(); - Assert.assertEquals(7, result.length); + Assertions.assertEquals(7, result.length); } @Test @@ -57,7 +56,7 @@ public void testIncorrectMultipleParameterSets() { // String array length = 13 absoluteElliptic.setCoordinates(new String[]{"40", "40", "0", "0", "0", "20", "20", "40", "40", "0", "0", "0", "20"}, new Point()); String[] result = absoluteElliptic.getCoordinates(); - Assert.assertEquals(7, result.length); + Assertions.assertEquals(7, result.length); } @Test @@ -66,7 +65,7 @@ public void testMultipleParameterSet() { // String array length = 14 absoluteElliptic.setCoordinates(new String[]{"40", "40", "0", "0", "0", "20", "20", "40", "40", "0", "0", "0", "20", "20"}, new Point()); String[] result = absoluteElliptic.getCoordinates(); - Assert.assertEquals(7, result.length); + Assertions.assertEquals(7, result.length); } @Test @@ -75,7 +74,7 @@ public void testRandomParameterAmountSet() { // String array length = 17 absoluteElliptic.setCoordinates(new String[]{"40", "40", "0", "0", "0", "20", "20", "40", "40", "0", "0", "0", "20", "20", "0", "1", "2"}, new Point()); String[] result = absoluteElliptic.getCoordinates(); - Assert.assertEquals(7, result.length); + Assertions.assertEquals(7, result.length); } @Test @@ -83,7 +82,7 @@ public void testNotEnoughParameterSet() { EllipticalCurveTo absoluteElliptic = new EllipticalCurveTo(); // String array length = 6 - Assert.assertThrows(IllegalArgumentException.class, + Assertions.assertThrows(IllegalArgumentException.class, () -> absoluteElliptic.setCoordinates(new String[]{"40", "0", "0", "0", "20", "20"}, new Point()) ); } @@ -93,24 +92,24 @@ public void testNoParameterSet() { EllipticalCurveTo absoluteElliptic = new EllipticalCurveTo(); // String array length = 0 - Assert.assertThrows(IllegalArgumentException.class, + Assertions.assertThrows(IllegalArgumentException.class, () -> absoluteElliptic.setCoordinates(new String[]{}, new Point()) ); } // rotate tests private void assertPointArrayArrayEquals(Point[][] expected, Point[][] actual) { - Assert.assertEquals(expected.length, actual.length); + Assertions.assertEquals(expected.length, actual.length); for (int i = 0; i < expected.length; i++) { assertPointArrayEquals(expected[i], actual[i]); } } private void assertPointArrayEquals(Point[] expected, Point[] actual) { - Assert.assertEquals(expected.length, actual.length); + Assertions.assertEquals(expected.length, actual.length); for (int i = 0; i < expected.length; i++) { - Assert.assertEquals(expected[i].x, actual[i].x, 0.00001); - Assert.assertEquals(expected[i].y, actual[i].y, 0.00001); + Assertions.assertEquals(expected[i].getX(), actual[i].getX(), 0.00001); + Assertions.assertEquals(expected[i].getY(), actual[i].getY(), 0.00001); } } diff --git a/svg/src/test/java/com/itextpdf/svg/utils/MatrixTransformationTest.java b/svg/src/test/java/com/itextpdf/svg/utils/MatrixTransformationTest.java index 647603dc74..2b695c8f64 100644 --- a/svg/src/test/java/com/itextpdf/svg/utils/MatrixTransformationTest.java +++ b/svg/src/test/java/com/itextpdf/svg/utils/MatrixTransformationTest.java @@ -26,13 +26,12 @@ This file is part of the iText (R) project. import com.itextpdf.svg.exceptions.SvgExceptionMessageConstant; import com.itextpdf.svg.exceptions.SvgProcessingException; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class MatrixTransformationTest extends ExtendedITextTest { @Test @@ -40,30 +39,30 @@ public void normalMatrixTest() { AffineTransform expected = new AffineTransform(10d, 20d, 30d, 40d, 37.5d, 45d); AffineTransform actual = TransformUtils.parseTransform("matrix(10 20 30 40 50 60)"); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test public void noMatrixValuesTest() { - Exception e = Assert.assertThrows(SvgProcessingException.class, + Exception e = Assertions.assertThrows(SvgProcessingException.class, () -> TransformUtils.parseTransform("matrix()") ); - Assert.assertEquals(SvgExceptionMessageConstant.TRANSFORM_INCORRECT_NUMBER_OF_VALUES, e.getMessage()); + Assertions.assertEquals(SvgExceptionMessageConstant.TRANSFORM_INCORRECT_NUMBER_OF_VALUES, e.getMessage()); } @Test public void notEnoughMatrixValuesTest() { - Exception e = Assert.assertThrows(SvgProcessingException.class, + Exception e = Assertions.assertThrows(SvgProcessingException.class, () -> TransformUtils.parseTransform("matrix(0)") ); - Assert.assertEquals(SvgExceptionMessageConstant.TRANSFORM_INCORRECT_NUMBER_OF_VALUES, e.getMessage()); + Assertions.assertEquals(SvgExceptionMessageConstant.TRANSFORM_INCORRECT_NUMBER_OF_VALUES, e.getMessage()); } @Test public void tooManyMatrixValuesTest() { - Exception e = Assert.assertThrows(SvgProcessingException.class, + Exception e = Assertions.assertThrows(SvgProcessingException.class, () -> TransformUtils.parseTransform("matrix(1 2 3 4 5 6 7 8)") ); - Assert.assertEquals(SvgExceptionMessageConstant.TRANSFORM_INCORRECT_NUMBER_OF_VALUES, e.getMessage()); + Assertions.assertEquals(SvgExceptionMessageConstant.TRANSFORM_INCORRECT_NUMBER_OF_VALUES, e.getMessage()); } } diff --git a/svg/src/test/java/com/itextpdf/svg/utils/RotateTransformationTest.java b/svg/src/test/java/com/itextpdf/svg/utils/RotateTransformationTest.java index a6ebc573ad..2072c8cb16 100644 --- a/svg/src/test/java/com/itextpdf/svg/utils/RotateTransformationTest.java +++ b/svg/src/test/java/com/itextpdf/svg/utils/RotateTransformationTest.java @@ -28,13 +28,12 @@ This file is part of the iText (R) project. import com.itextpdf.svg.exceptions.SvgExceptionMessageConstant; import com.itextpdf.svg.exceptions.SvgProcessingException; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class RotateTransformationTest extends ExtendedITextTest { @Test @@ -43,15 +42,15 @@ public void normalRotateTest() { .parseAbsoluteLength("10")); AffineTransform actual = TransformUtils.parseTransform("rotate(10, 5, 10)"); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test public void noRotateValuesTest() { - Exception e = Assert.assertThrows(SvgProcessingException.class, + Exception e = Assertions.assertThrows(SvgProcessingException.class, () -> TransformUtils.parseTransform("rotate()") ); - Assert.assertEquals(SvgExceptionMessageConstant.TRANSFORM_INCORRECT_NUMBER_OF_VALUES, e.getMessage()); + Assertions.assertEquals(SvgExceptionMessageConstant.TRANSFORM_INCORRECT_NUMBER_OF_VALUES, e.getMessage()); } @Test @@ -59,15 +58,15 @@ public void oneRotateValuesTest() { AffineTransform expected = AffineTransform.getRotateInstance(Math.toRadians(10)); AffineTransform actual = TransformUtils.parseTransform("rotate(10)"); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test public void twoRotateValuesTest() { - Exception e = Assert.assertThrows(SvgProcessingException.class, + Exception e = Assertions.assertThrows(SvgProcessingException.class, () -> TransformUtils.parseTransform("rotate(23,58)") ); - Assert.assertEquals(SvgExceptionMessageConstant.TRANSFORM_INCORRECT_NUMBER_OF_VALUES, e.getMessage()); + Assertions.assertEquals(SvgExceptionMessageConstant.TRANSFORM_INCORRECT_NUMBER_OF_VALUES, e.getMessage()); } @Test @@ -76,15 +75,15 @@ public void threeRotateValuesTest() { .parseAbsoluteLength("57")); AffineTransform actual = TransformUtils.parseTransform("rotate(23, 58, 57)"); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test public void tooManyRotateValuesTest() { - Exception e = Assert.assertThrows(SvgProcessingException.class, + Exception e = Assertions.assertThrows(SvgProcessingException.class, () -> TransformUtils.parseTransform("rotate(1 2 3 4)") ); - Assert.assertEquals(SvgExceptionMessageConstant.TRANSFORM_INCORRECT_NUMBER_OF_VALUES, e.getMessage()); + Assertions.assertEquals(SvgExceptionMessageConstant.TRANSFORM_INCORRECT_NUMBER_OF_VALUES, e.getMessage()); } @Test @@ -93,7 +92,7 @@ public void negativeRotateValuesTest() { .parseAbsoluteLength("-1")); AffineTransform actual = TransformUtils.parseTransform("rotate(-23,-58,-1)"); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test @@ -101,6 +100,6 @@ public void ninetyDegreesTest() { AffineTransform expected = AffineTransform.getRotateInstance(Math.toRadians(90)); AffineTransform actual = TransformUtils.parseTransform("rotate(90)"); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } } diff --git a/svg/src/test/java/com/itextpdf/svg/utils/ScaleTransformationTest.java b/svg/src/test/java/com/itextpdf/svg/utils/ScaleTransformationTest.java index 55855f801a..4db2b2cce9 100644 --- a/svg/src/test/java/com/itextpdf/svg/utils/ScaleTransformationTest.java +++ b/svg/src/test/java/com/itextpdf/svg/utils/ScaleTransformationTest.java @@ -26,13 +26,12 @@ This file is part of the iText (R) project. import com.itextpdf.svg.exceptions.SvgExceptionMessageConstant; import com.itextpdf.svg.exceptions.SvgProcessingException; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class ScaleTransformationTest extends ExtendedITextTest { @Test @@ -40,15 +39,15 @@ public void normalScaleTest() { AffineTransform expected = AffineTransform.getScaleInstance(10d, 20d); AffineTransform actual = TransformUtils.parseTransform("scale(10, 20)"); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test public void noScaleValuesTest() { - Exception e = Assert.assertThrows(SvgProcessingException.class, + Exception e = Assertions.assertThrows(SvgProcessingException.class, () -> TransformUtils.parseTransform("scale()") ); - Assert.assertEquals(SvgExceptionMessageConstant.TRANSFORM_INCORRECT_NUMBER_OF_VALUES, e.getMessage()); + Assertions.assertEquals(SvgExceptionMessageConstant.TRANSFORM_INCORRECT_NUMBER_OF_VALUES, e.getMessage()); } @Test @@ -56,7 +55,7 @@ public void oneScaleValuesTest() { AffineTransform expected = AffineTransform.getScaleInstance(10d, 10d); AffineTransform actual = TransformUtils.parseTransform("scale(10)"); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test @@ -64,7 +63,7 @@ public void twoScaleValuesTest() { AffineTransform expected = AffineTransform.getScaleInstance(2, 3); AffineTransform actual = TransformUtils.parseTransform("scale(2,3)"); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test @@ -72,15 +71,15 @@ public void negativeScaleValuesTest() { AffineTransform expected = AffineTransform.getScaleInstance(-2, -3); AffineTransform actual = TransformUtils.parseTransform("scale(-2, -3)"); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test public void tooManyScaleValuesTest() { - Exception e = Assert.assertThrows(SvgProcessingException.class, + Exception e = Assertions.assertThrows(SvgProcessingException.class, () -> TransformUtils.parseTransform("scale(1 2 3)") ); - Assert.assertEquals(SvgExceptionMessageConstant.TRANSFORM_INCORRECT_NUMBER_OF_VALUES, e.getMessage()); + Assertions.assertEquals(SvgExceptionMessageConstant.TRANSFORM_INCORRECT_NUMBER_OF_VALUES, e.getMessage()); } } diff --git a/svg/src/test/java/com/itextpdf/svg/utils/SkewXTransformationTest.java b/svg/src/test/java/com/itextpdf/svg/utils/SkewXTransformationTest.java index 927f70fcfa..d930789e96 100644 --- a/svg/src/test/java/com/itextpdf/svg/utils/SkewXTransformationTest.java +++ b/svg/src/test/java/com/itextpdf/svg/utils/SkewXTransformationTest.java @@ -28,13 +28,12 @@ This file is part of the iText (R) project. import com.itextpdf.svg.exceptions.SvgExceptionMessageConstant; import com.itextpdf.svg.exceptions.SvgProcessingException; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class SkewXTransformationTest extends ExtendedITextTest { @Test @@ -42,23 +41,23 @@ public void normalSkewXTest() { AffineTransform expected = new AffineTransform(1d, 0d, Math.tan(Math.toRadians((float) CssDimensionParsingUtils.parseFloat("143"))), 1d, 0d, 0d); AffineTransform actual = TransformUtils.parseTransform("skewX(143)"); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test public void noSkewXValuesTest() { - Exception e = Assert.assertThrows(SvgProcessingException.class, + Exception e = Assertions.assertThrows(SvgProcessingException.class, () -> TransformUtils.parseTransform("skewX()") ); - Assert.assertEquals(SvgExceptionMessageConstant.TRANSFORM_INCORRECT_NUMBER_OF_VALUES, e.getMessage()); + Assertions.assertEquals(SvgExceptionMessageConstant.TRANSFORM_INCORRECT_NUMBER_OF_VALUES, e.getMessage()); } @Test public void twoSkewXValuesTest() { - Exception e = Assert.assertThrows(SvgProcessingException.class, + Exception e = Assertions.assertThrows(SvgProcessingException.class, () -> TransformUtils.parseTransform("skewX(1 2)") ); - Assert.assertEquals(SvgExceptionMessageConstant.TRANSFORM_INCORRECT_NUMBER_OF_VALUES, e.getMessage()); + Assertions.assertEquals(SvgExceptionMessageConstant.TRANSFORM_INCORRECT_NUMBER_OF_VALUES, e.getMessage()); } @Test @@ -66,14 +65,14 @@ public void negativeSkewXTest() { AffineTransform expected = new AffineTransform(1d, 0d, Math.tan(Math.toRadians((float) CssDimensionParsingUtils.parseFloat("-26"))), 1d, 0d, 0d); AffineTransform actual = TransformUtils.parseTransform("skewX(-26)"); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test public void ninetyDegreesTest() { AffineTransform expected = new AffineTransform(1d, 0d, Math.tan(Math.toRadians((float) CssDimensionParsingUtils.parseFloat("90"))), 1d, 0d, 0d); AffineTransform actual = TransformUtils.parseTransform("skewX(90)"); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } } diff --git a/svg/src/test/java/com/itextpdf/svg/utils/SkewYTransformationTest.java b/svg/src/test/java/com/itextpdf/svg/utils/SkewYTransformationTest.java index 60a0aaec55..0d01a7a754 100644 --- a/svg/src/test/java/com/itextpdf/svg/utils/SkewYTransformationTest.java +++ b/svg/src/test/java/com/itextpdf/svg/utils/SkewYTransformationTest.java @@ -26,13 +26,12 @@ This file is part of the iText (R) project. import com.itextpdf.svg.exceptions.SvgExceptionMessageConstant; import com.itextpdf.svg.exceptions.SvgProcessingException; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class SkewYTransformationTest extends ExtendedITextTest { @Test @@ -40,23 +39,23 @@ public void normalSkewYTest() { AffineTransform expected = new AffineTransform(1d, Math.tan(Math.toRadians(143)), 0d, 1d, 0d, 0d); AffineTransform actual = TransformUtils.parseTransform("skewY(143)"); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test public void noSkewYValuesTest() { - Exception e = Assert.assertThrows(SvgProcessingException.class, + Exception e = Assertions.assertThrows(SvgProcessingException.class, () -> TransformUtils.parseTransform("skewY()") ); - Assert.assertEquals(SvgExceptionMessageConstant.TRANSFORM_INCORRECT_NUMBER_OF_VALUES, e.getMessage()); + Assertions.assertEquals(SvgExceptionMessageConstant.TRANSFORM_INCORRECT_NUMBER_OF_VALUES, e.getMessage()); } @Test public void twoSkewYValuesTest() { - Exception e = Assert.assertThrows(SvgProcessingException.class, + Exception e = Assertions.assertThrows(SvgProcessingException.class, () -> TransformUtils.parseTransform("skewY(1 2)") ); - Assert.assertEquals(SvgExceptionMessageConstant.TRANSFORM_INCORRECT_NUMBER_OF_VALUES, e.getMessage()); + Assertions.assertEquals(SvgExceptionMessageConstant.TRANSFORM_INCORRECT_NUMBER_OF_VALUES, e.getMessage()); } @Test @@ -64,7 +63,7 @@ public void negativeSkewYTest() { AffineTransform expected = new AffineTransform(1d, Math.tan(Math.toRadians(-26)), 0d, 1d, 0d, 0d); AffineTransform actual = TransformUtils.parseTransform("skewY(-26)"); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test @@ -72,6 +71,6 @@ public void ninetyDegreesTest() { AffineTransform expected = new AffineTransform(1d, Math.tan(Math.toRadians(90)), 0d, 1d, 0d, 0d); AffineTransform actual = TransformUtils.parseTransform("skewY(90)"); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } } diff --git a/svg/src/test/java/com/itextpdf/svg/utils/SvgCoordinateUtilsTest.java b/svg/src/test/java/com/itextpdf/svg/utils/SvgCoordinateUtilsTest.java index de4eeb8198..e6a45e8234 100644 --- a/svg/src/test/java/com/itextpdf/svg/utils/SvgCoordinateUtilsTest.java +++ b/svg/src/test/java/com/itextpdf/svg/utils/SvgCoordinateUtilsTest.java @@ -27,13 +27,12 @@ This file is part of the iText (R) project. import com.itextpdf.svg.SvgConstants.Values; import com.itextpdf.svg.exceptions.SvgExceptionMessageConstant; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class SvgCoordinateUtilsTest extends ExtendedITextTest { private final static double DELTA = 0.0000001; @@ -48,7 +47,7 @@ public void calculateAngleBetweenTwoVectors45degTest() { Vector vectorB = new Vector(1, 1, 0); double expected = Math.PI / 4; double actual = SvgCoordinateUtils.calculateAngleBetweenTwoVectors(vectorA, vectorB); - Assert.assertEquals(expected, actual, DELTA); + Assertions.assertEquals(expected, actual, DELTA); } @Test @@ -57,7 +56,7 @@ public void calculateAngleBetweenTwoVectors45degInverseTest() { Vector vectorB = new Vector(1, -1, 0); double expected = Math.PI / 4; double actual = SvgCoordinateUtils.calculateAngleBetweenTwoVectors(vectorA, vectorB); - Assert.assertEquals(expected, actual, DELTA); + Assertions.assertEquals(expected, actual, DELTA); } @Test @@ -66,7 +65,7 @@ public void calculateAngleBetweenTwoVectors135degTest() { Vector vectorB = new Vector(-1, 1, 0); double expected = (Math.PI - Math.PI / 4); double actual = SvgCoordinateUtils.calculateAngleBetweenTwoVectors(vectorA, vectorB); - Assert.assertEquals(expected, actual, DELTA); + Assertions.assertEquals(expected, actual, DELTA); } @Test @@ -75,7 +74,7 @@ public void calculateAngleBetweenTwoVectors135degInverseTest() { Vector vectorB = new Vector(-1, -1, 0); double expected = (Math.PI - Math.PI / 4); double actual = SvgCoordinateUtils.calculateAngleBetweenTwoVectors(vectorA, vectorB); - Assert.assertEquals(expected, actual, DELTA); + Assertions.assertEquals(expected, actual, DELTA); } @@ -85,7 +84,7 @@ public void calculateAngleBetweenTwoVectors90degTest() { Vector vectorB = new Vector(0, 1, 0); double expected = Math.PI / 2; double actual = SvgCoordinateUtils.calculateAngleBetweenTwoVectors(vectorA, vectorB); - Assert.assertEquals(expected, actual, DELTA); + Assertions.assertEquals(expected, actual, DELTA); } @Test @@ -94,7 +93,7 @@ public void calculateAngleBetweenTwoVectors180degTest() { Vector vectorB = new Vector(-1, 0, 0); double expected = Math.PI; double actual = SvgCoordinateUtils.calculateAngleBetweenTwoVectors(vectorA, vectorB); - Assert.assertEquals(expected, actual, DELTA); + Assertions.assertEquals(expected, actual, DELTA); } @Test @@ -102,134 +101,134 @@ public void getCoordinateForUserSpaceOnUseDefaultTest() { double defaultValue = 244.0; double result = SvgCoordinateUtils.getCoordinateForUserSpaceOnUse( "random", defaultValue, 0, 0, 0, 0); - Assert.assertEquals(defaultValue, result, DELTA); + Assertions.assertEquals(defaultValue, result, DELTA); } @Test public void getCoordinateForUserSpaceOnUsePercentTest() { double result = SvgCoordinateUtils.getCoordinateForUserSpaceOnUse( "20%", 0, 10, 20, 0, 0); - Assert.assertEquals(14.0, result, DELTA); + Assertions.assertEquals(14.0, result, DELTA); } @Test public void getCoordinateForUserSpaceOnUsePxTest() { double result = SvgCoordinateUtils.getCoordinateForUserSpaceOnUse( "20px", 0, 0, 0, 0, 0); - Assert.assertEquals(15.0, result, DELTA); + Assertions.assertEquals(15.0, result, DELTA); } @Test public void getCoordinateForUserSpaceOnUseEmTest() { double result = SvgCoordinateUtils.getCoordinateForUserSpaceOnUse( "14em", 0, 0, 0, 10, 18); - Assert.assertEquals(140.0, result, DELTA); + Assertions.assertEquals(140.0, result, DELTA); } @Test public void getCoordinateForUserSpaceOnUseRemTest() { double result = SvgCoordinateUtils.getCoordinateForUserSpaceOnUse( "14rem", 0, 0, 0, 10, 18); - Assert.assertEquals(252.0, result, DELTA); + Assertions.assertEquals(252.0, result, DELTA); } @Test public void getCoordinateForObjectBoundingBoxPercentTest() { double result = SvgCoordinateUtils.getCoordinateForObjectBoundingBox("20%", 0); - Assert.assertEquals(0.2, result, DELTA); + Assertions.assertEquals(0.2, result, DELTA); } @Test public void getCoordinateForObjectBoundingBoxNumericFloatingValueTest() { double result = SvgCoordinateUtils.getCoordinateForObjectBoundingBox("1234.3", 0); - Assert.assertEquals(1234.3, result, DELTA); + Assertions.assertEquals(1234.3, result, DELTA); } @Test public void getCoordinateForObjectBoundingBoxNumericIntegerValueTest() { double result = SvgCoordinateUtils.getCoordinateForObjectBoundingBox("1234", 0); - Assert.assertEquals(1234.0, result, DELTA); + Assertions.assertEquals(1234.0, result, DELTA); } @Test public void getCoordinateForObjectBoundingBoxMetricFloatingValueTest() { double result = SvgCoordinateUtils.getCoordinateForObjectBoundingBox("12.3px", 0); - Assert.assertEquals(12.3, result, DELTA); + Assertions.assertEquals(12.3, result, DELTA); } @Test public void getCoordinateForObjectBoundingBoxMetricIntegerValueTest() { double result = SvgCoordinateUtils.getCoordinateForObjectBoundingBox("12px", 0); - Assert.assertEquals(12.0, result, DELTA); + Assertions.assertEquals(12.0, result, DELTA); } @Test public void getCoordinateForObjectBoundingBoxRelativeValueTest() { double result = SvgCoordinateUtils.getCoordinateForObjectBoundingBox("12.3em", 0); - Assert.assertEquals(12.3, result, DELTA); + Assertions.assertEquals(12.3, result, DELTA); } @Test public void getCoordinateForObjectBoundingBoxDefaultTest() { double defaultValue = 20.0; double result = SvgCoordinateUtils.getCoordinateForObjectBoundingBox("random", defaultValue); - Assert.assertEquals(defaultValue, result, DELTA); + Assertions.assertEquals(defaultValue, result, DELTA); } @Test public void applyViewBoxViewBoxIsNullTest() { - Exception e = Assert.assertThrows(IllegalArgumentException.class, + Exception e = Assertions.assertThrows(IllegalArgumentException.class, () -> SvgCoordinateUtils.applyViewBox(null, new Rectangle(10F, 10F), null, null) ); - Assert.assertEquals(SvgExceptionMessageConstant.VIEWBOX_IS_INCORRECT, e.getMessage()); + Assertions.assertEquals(SvgExceptionMessageConstant.VIEWBOX_IS_INCORRECT, e.getMessage()); } @Test public void applyViewBoxViewBoxWidthIsZeroTest() { - Exception e = Assert.assertThrows(IllegalArgumentException.class, + Exception e = Assertions.assertThrows(IllegalArgumentException.class, () -> SvgCoordinateUtils.applyViewBox(new Rectangle(0F, 10F), new Rectangle(10F, 10F), null, null) ); - Assert.assertEquals(SvgExceptionMessageConstant.VIEWBOX_IS_INCORRECT, e.getMessage()); + Assertions.assertEquals(SvgExceptionMessageConstant.VIEWBOX_IS_INCORRECT, e.getMessage()); } @Test public void applyViewBoxViewBoxHeightIsZeroTest() { - Exception e = Assert.assertThrows(IllegalArgumentException.class, + Exception e = Assertions.assertThrows(IllegalArgumentException.class, () -> SvgCoordinateUtils.applyViewBox(new Rectangle(10F, 0F), new Rectangle(10F, 10F), null, null) ); - Assert.assertEquals(SvgExceptionMessageConstant.VIEWBOX_IS_INCORRECT, e.getMessage()); + Assertions.assertEquals(SvgExceptionMessageConstant.VIEWBOX_IS_INCORRECT, e.getMessage()); } @Test public void applyViewBoxViewBoxWidthIsNegativeTest() { - Exception e = Assert.assertThrows(IllegalArgumentException.class, + Exception e = Assertions.assertThrows(IllegalArgumentException.class, () -> SvgCoordinateUtils.applyViewBox(new Rectangle(-10F, 10F), new Rectangle(10F, 10F), null, null) ); - Assert.assertEquals(SvgExceptionMessageConstant.VIEWBOX_IS_INCORRECT, e.getMessage()); + Assertions.assertEquals(SvgExceptionMessageConstant.VIEWBOX_IS_INCORRECT, e.getMessage()); } @Test public void applyViewBoxViewBoxHeightIsNegativeTest() { - Exception e = Assert.assertThrows(IllegalArgumentException.class, + Exception e = Assertions.assertThrows(IllegalArgumentException.class, () -> SvgCoordinateUtils.applyViewBox(new Rectangle(10F, -10F), new Rectangle(10F, 10F), null, null) ); - Assert.assertEquals(SvgExceptionMessageConstant.VIEWBOX_IS_INCORRECT, e.getMessage()); + Assertions.assertEquals(SvgExceptionMessageConstant.VIEWBOX_IS_INCORRECT, e.getMessage()); } @Test public void applyViewBoxCurrentViewPortIsNullTest() { - Exception e = Assert.assertThrows(IllegalArgumentException.class, + Exception e = Assertions.assertThrows(IllegalArgumentException.class, () -> SvgCoordinateUtils.applyViewBox(new Rectangle(10F, 10F), null, null, null) ); - Assert.assertEquals(SvgExceptionMessageConstant.CURRENT_VIEWPORT_IS_NULL, e.getMessage()); + Assertions.assertEquals(SvgExceptionMessageConstant.CURRENT_VIEWPORT_IS_NULL, e.getMessage()); } @Test public void applyViewBoxAllNullTest() { - Exception e = Assert.assertThrows(IllegalArgumentException.class, + Exception e = Assertions.assertThrows(IllegalArgumentException.class, () -> SvgCoordinateUtils.applyViewBox(null, null, null, null) ); - Assert.assertEquals(SvgExceptionMessageConstant.CURRENT_VIEWPORT_IS_NULL, e.getMessage()); + Assertions.assertEquals(SvgExceptionMessageConstant.CURRENT_VIEWPORT_IS_NULL, e.getMessage()); } @Test @@ -237,7 +236,7 @@ public void applyViewBoxCurrentViewPortZeroWidthHeightTest() { Rectangle currentViewPort = new Rectangle(50F, 50F, 0F, 0F); Rectangle appliedViewBox = SvgCoordinateUtils .applyViewBox(VIEW_BOX, currentViewPort, null, null); - Assert.assertTrue(currentViewPort.equalsWithEpsilon(appliedViewBox)); + Assertions.assertTrue(currentViewPort.equalsWithEpsilon(appliedViewBox)); } @Test @@ -245,28 +244,28 @@ public void applyViewBoxCurrentViewPortNegativeWidthHeightTest() { Rectangle currentViewPort = new Rectangle(50F, 50F, -100F, -60F); Rectangle appliedViewBox = SvgCoordinateUtils .applyViewBox(VIEW_BOX, currentViewPort, null, null); - Assert.assertTrue(new Rectangle(50F, 70F, -100F, -100F).equalsWithEpsilon(appliedViewBox)); + Assertions.assertTrue(new Rectangle(50F, 70F, -100F, -100F).equalsWithEpsilon(appliedViewBox)); } @Test public void applyViewBoxAlignIsNullSliceTest() { Rectangle assertRect = new Rectangle(80F, 40F, 60F, 60F); Rectangle appliedViewBox = SvgCoordinateUtils.applyViewBox(VIEW_BOX, VIEW_PORT_HORIZONTAL, null, Values.SLICE); - Assert.assertTrue(assertRect.equalsWithEpsilon(appliedViewBox)); + Assertions.assertTrue(assertRect.equalsWithEpsilon(appliedViewBox)); } @Test public void applyViewBoxAlignIsNullMeetTest() { Rectangle assertRect = new Rectangle(80F, 40F, 60F, 60F); Rectangle appliedViewBox = SvgCoordinateUtils.applyViewBox(VIEW_BOX, VIEW_PORT_HORIZONTAL, null, Values.MEET); - Assert.assertTrue(assertRect.equalsWithEpsilon(appliedViewBox)); + Assertions.assertTrue(assertRect.equalsWithEpsilon(appliedViewBox)); } @Test public void applyViewBoxAlignIsNullIncorrectMeetOrSliceTest() { Rectangle assertRect = new Rectangle(80F, 40F, 60F, 60F); Rectangle appliedViewBox = SvgCoordinateUtils.applyViewBox(VIEW_BOX, VIEW_PORT_HORIZONTAL, null, "jklsdj"); - Assert.assertTrue(assertRect.equalsWithEpsilon(appliedViewBox)); + Assertions.assertTrue(assertRect.equalsWithEpsilon(appliedViewBox)); } @Test @@ -274,7 +273,7 @@ public void applyViewBoxMeetOrSliceIsNullXMaxYMaxTest() { Rectangle assertRect = new Rectangle(100F, 40F, 60F, 60F); Rectangle appliedViewBox = SvgCoordinateUtils .applyViewBox(VIEW_BOX, VIEW_PORT_HORIZONTAL, Values.XMAX_YMAX, null); - Assert.assertTrue(assertRect.equalsWithEpsilon(appliedViewBox)); + Assertions.assertTrue(assertRect.equalsWithEpsilon(appliedViewBox)); } @Test @@ -282,7 +281,7 @@ public void applyViewBoxMeetOrSliceIsNullXMinYMinTest() { Rectangle assertRect = new Rectangle(60F, 40F, 60F, 60F); Rectangle appliedViewBox = SvgCoordinateUtils .applyViewBox(VIEW_BOX, VIEW_PORT_HORIZONTAL, Values.XMIN_YMIN, null); - Assert.assertTrue(assertRect.equalsWithEpsilon(appliedViewBox)); + Assertions.assertTrue(assertRect.equalsWithEpsilon(appliedViewBox)); } @Test @@ -290,7 +289,7 @@ public void applyViewBoxMeetOrSliceIsNullIncorrectAlignTest() { Rectangle assertRect = new Rectangle(80F, 40F, 60F, 60F); Rectangle appliedViewBox = SvgCoordinateUtils .applyViewBox(VIEW_BOX, VIEW_PORT_HORIZONTAL, "ahfdfs", null); - Assert.assertTrue(assertRect.equalsWithEpsilon(appliedViewBox)); + Assertions.assertTrue(assertRect.equalsWithEpsilon(appliedViewBox)); } @Test @@ -298,7 +297,7 @@ public void applyViewBoxIncorrectAlignMeetTest() { Rectangle assertRect = new Rectangle(80F, 40F, 60F, 60F); Rectangle appliedViewBox = SvgCoordinateUtils .applyViewBox(VIEW_BOX, VIEW_PORT_HORIZONTAL, "ahfdfs", Values.MEET); - Assert.assertTrue(assertRect.equalsWithEpsilon(appliedViewBox)); + Assertions.assertTrue(assertRect.equalsWithEpsilon(appliedViewBox)); } @Test @@ -306,31 +305,31 @@ public void applyViewBoxIncorrectAlignSliceTest() { Rectangle assertRect = new Rectangle(80F, 40F, 60F, 60F); Rectangle appliedViewBox = SvgCoordinateUtils .applyViewBox(VIEW_BOX, VIEW_PORT_HORIZONTAL, "ahfdfs", Values.SLICE); - Assert.assertTrue(assertRect.equalsWithEpsilon(appliedViewBox)); + Assertions.assertTrue(assertRect.equalsWithEpsilon(appliedViewBox)); } @Test public void applyViewBoxNoneNullTest() { Rectangle appliedViewBox = SvgCoordinateUtils .applyViewBox(VIEW_BOX, VIEW_PORT_HORIZONTAL, Values.NONE, null); - Assert.assertNotSame(VIEW_PORT_HORIZONTAL, appliedViewBox); - Assert.assertTrue(VIEW_PORT_HORIZONTAL.equalsWithEpsilon(appliedViewBox)); + Assertions.assertNotSame(VIEW_PORT_HORIZONTAL, appliedViewBox); + Assertions.assertTrue(VIEW_PORT_HORIZONTAL.equalsWithEpsilon(appliedViewBox)); } @Test public void applyViewBoxNoneMeetTest() { Rectangle appliedViewBox = SvgCoordinateUtils .applyViewBox(VIEW_BOX, VIEW_PORT_HORIZONTAL, Values.NONE, Values.MEET); - Assert.assertNotSame(VIEW_PORT_HORIZONTAL, appliedViewBox); - Assert.assertTrue(VIEW_PORT_HORIZONTAL.equalsWithEpsilon(appliedViewBox)); + Assertions.assertNotSame(VIEW_PORT_HORIZONTAL, appliedViewBox); + Assertions.assertTrue(VIEW_PORT_HORIZONTAL.equalsWithEpsilon(appliedViewBox)); } @Test public void applyViewBoxNoneSliceTest() { Rectangle appliedViewBox = SvgCoordinateUtils .applyViewBox(VIEW_BOX, VIEW_PORT_HORIZONTAL, Values.NONE, Values.SLICE); - Assert.assertNotSame(VIEW_PORT_HORIZONTAL, appliedViewBox); - Assert.assertTrue(VIEW_PORT_HORIZONTAL.equalsWithEpsilon(appliedViewBox)); + Assertions.assertNotSame(VIEW_PORT_HORIZONTAL, appliedViewBox); + Assertions.assertTrue(VIEW_PORT_HORIZONTAL.equalsWithEpsilon(appliedViewBox)); } @Test @@ -339,63 +338,63 @@ public void applyViewBoxNoneMeetOrSliceIsIncorrectTest() { Rectangle assertRect = new Rectangle(80F, 40F, 60F, 60F); Rectangle appliedViewBox = SvgCoordinateUtils .applyViewBox(VIEW_BOX, VIEW_PORT_HORIZONTAL, Values.NONE, "fhakljs"); - Assert.assertTrue(assertRect.equalsWithEpsilon(appliedViewBox)); + Assertions.assertTrue(assertRect.equalsWithEpsilon(appliedViewBox)); } @Test public void applyViewBoxXMinYMinMeetHorizontalViewPortTest() { Rectangle appliedViewBox = SvgCoordinateUtils .applyViewBox(VIEW_BOX, VIEW_PORT_HORIZONTAL, Values.XMIN_YMIN, Values.MEET); - Assert.assertTrue(new Rectangle(60F, 40F, 60F, 60F).equalsWithEpsilon(appliedViewBox)); + Assertions.assertTrue(new Rectangle(60F, 40F, 60F, 60F).equalsWithEpsilon(appliedViewBox)); } @Test public void applyViewBoxXMinYMinSliceHorizontalViewPortTest() { Rectangle appliedViewBox = SvgCoordinateUtils .applyViewBox(VIEW_BOX, VIEW_PORT_HORIZONTAL, Values.XMIN_YMIN, Values.SLICE); - Assert.assertTrue(new Rectangle(60F, 40F, 100F, 100F).equalsWithEpsilon(appliedViewBox)); + Assertions.assertTrue(new Rectangle(60F, 40F, 100F, 100F).equalsWithEpsilon(appliedViewBox)); } @Test public void applyViewBoxXMinYMinMeetVerticalViewPortTest() { Rectangle appliedViewBox = SvgCoordinateUtils .applyViewBox(VIEW_BOX, VIEW_PORT_VERTICAL, Values.XMIN_YMIN, Values.MEET); - Assert.assertTrue(new Rectangle(60F, 40F, 60F, 60F).equalsWithEpsilon(appliedViewBox)); + Assertions.assertTrue(new Rectangle(60F, 40F, 60F, 60F).equalsWithEpsilon(appliedViewBox)); } @Test public void applyViewBoxXMinYMinSliceVerticalViewPortTest() { Rectangle appliedViewBox = SvgCoordinateUtils .applyViewBox(VIEW_BOX, VIEW_PORT_VERTICAL, Values.XMIN_YMIN, Values.SLICE); - Assert.assertTrue(new Rectangle(60F, 40F, 100F, 100F).equalsWithEpsilon(appliedViewBox)); + Assertions.assertTrue(new Rectangle(60F, 40F, 100F, 100F).equalsWithEpsilon(appliedViewBox)); } @Test public void applyViewBoxXMinYMidMeetHorizontalTest() { Rectangle appliedViewBox = SvgCoordinateUtils .applyViewBox(VIEW_BOX, VIEW_PORT_HORIZONTAL, Values.XMIN_YMID, Values.MEET); - Assert.assertTrue(new Rectangle(60F, 40F, 60F, 60F).equalsWithEpsilon(appliedViewBox)); + Assertions.assertTrue(new Rectangle(60F, 40F, 60F, 60F).equalsWithEpsilon(appliedViewBox)); } @Test public void applyViewBoxXMinYMidSliceHorizontalTest() { Rectangle appliedViewBox = SvgCoordinateUtils .applyViewBox(VIEW_BOX, VIEW_PORT_HORIZONTAL, Values.XMIN_YMID, Values.SLICE); - Assert.assertTrue(new Rectangle(60F, 20F, 100F, 100F).equalsWithEpsilon(appliedViewBox)); + Assertions.assertTrue(new Rectangle(60F, 20F, 100F, 100F).equalsWithEpsilon(appliedViewBox)); } @Test public void applyViewBoxXMinYMidMeetVerticalTest() { Rectangle appliedViewBox = SvgCoordinateUtils .applyViewBox(VIEW_BOX, VIEW_PORT_VERTICAL, Values.XMIN_YMID, Values.MEET); - Assert.assertTrue(new Rectangle(60F, 60F, 60F, 60F).equalsWithEpsilon(appliedViewBox)); + Assertions.assertTrue(new Rectangle(60F, 60F, 60F, 60F).equalsWithEpsilon(appliedViewBox)); } @Test public void applyViewBoxXMinYMidSliceVerticalTest() { Rectangle appliedViewBox = SvgCoordinateUtils .applyViewBox(VIEW_BOX, VIEW_PORT_VERTICAL, Values.XMIN_YMID, Values.SLICE); - Assert.assertTrue(new Rectangle(60F, 40F, 100F, 100F).equalsWithEpsilon(appliedViewBox)); + Assertions.assertTrue(new Rectangle(60F, 40F, 100F, 100F).equalsWithEpsilon(appliedViewBox)); } @@ -403,195 +402,195 @@ public void applyViewBoxXMinYMidSliceVerticalTest() { public void applyViewBoxXMinYMaxMeetHorizontalTest() { Rectangle appliedViewBox = SvgCoordinateUtils .applyViewBox(VIEW_BOX, VIEW_PORT_HORIZONTAL, Values.XMIN_YMAX, Values.MEET); - Assert.assertTrue(new Rectangle(60F, 40F, 60F, 60F).equalsWithEpsilon(appliedViewBox)); + Assertions.assertTrue(new Rectangle(60F, 40F, 60F, 60F).equalsWithEpsilon(appliedViewBox)); } @Test public void applyViewBoxXMinYMaxSliceHorizontalTest() { Rectangle appliedViewBox = SvgCoordinateUtils .applyViewBox(VIEW_BOX, VIEW_PORT_HORIZONTAL, Values.XMIN_YMAX, Values.SLICE); - Assert.assertTrue(new Rectangle(60F, 0F, 100F, 100F).equalsWithEpsilon(appliedViewBox)); + Assertions.assertTrue(new Rectangle(60F, 0F, 100F, 100F).equalsWithEpsilon(appliedViewBox)); } @Test public void applyViewBoxXMinYMaxMeetVerticalTest() { Rectangle appliedViewBox = SvgCoordinateUtils .applyViewBox(VIEW_BOX, VIEW_PORT_VERTICAL, Values.XMIN_YMAX, Values.MEET); - Assert.assertTrue(new Rectangle(60F, 80F, 60F, 60F).equalsWithEpsilon(appliedViewBox)); + Assertions.assertTrue(new Rectangle(60F, 80F, 60F, 60F).equalsWithEpsilon(appliedViewBox)); } @Test public void applyViewBoxXMinYMaxSliceVerticalTest() { Rectangle appliedViewBox = SvgCoordinateUtils .applyViewBox(VIEW_BOX, VIEW_PORT_VERTICAL, Values.XMIN_YMAX, Values.SLICE); - Assert.assertTrue(new Rectangle(60F, 40F, 100F, 100F).equalsWithEpsilon(appliedViewBox)); + Assertions.assertTrue(new Rectangle(60F, 40F, 100F, 100F).equalsWithEpsilon(appliedViewBox)); } @Test public void applyViewBoxXMidYMinMeetHorizontalTest() { Rectangle appliedViewBox = SvgCoordinateUtils .applyViewBox(VIEW_BOX, VIEW_PORT_HORIZONTAL, Values.XMID_YMIN, Values.MEET); - Assert.assertTrue(new Rectangle(80F, 40F, 60F, 60F).equalsWithEpsilon(appliedViewBox)); + Assertions.assertTrue(new Rectangle(80F, 40F, 60F, 60F).equalsWithEpsilon(appliedViewBox)); } @Test public void applyViewBoxXMidYMinSliceHorizontalTest() { Rectangle appliedViewBox = SvgCoordinateUtils .applyViewBox(VIEW_BOX, VIEW_PORT_HORIZONTAL, Values.XMID_YMIN, Values.SLICE); - Assert.assertTrue(new Rectangle(60F, 40F, 100F, 100F).equalsWithEpsilon(appliedViewBox)); + Assertions.assertTrue(new Rectangle(60F, 40F, 100F, 100F).equalsWithEpsilon(appliedViewBox)); } @Test public void applyViewBoxXMidYMinMeetVerticalTest() { Rectangle appliedViewBox = SvgCoordinateUtils .applyViewBox(VIEW_BOX, VIEW_PORT_VERTICAL, Values.XMID_YMIN, Values.MEET); - Assert.assertTrue(new Rectangle(60F, 40F, 60F, 60F).equalsWithEpsilon(appliedViewBox)); + Assertions.assertTrue(new Rectangle(60F, 40F, 60F, 60F).equalsWithEpsilon(appliedViewBox)); } @Test public void applyViewBoxXMidYMinSliceVerticalTest() { Rectangle appliedViewBox = SvgCoordinateUtils .applyViewBox(VIEW_BOX, VIEW_PORT_VERTICAL, Values.XMID_YMIN, Values.SLICE); - Assert.assertTrue(new Rectangle(40F, 40F, 100F, 100F).equalsWithEpsilon(appliedViewBox)); + Assertions.assertTrue(new Rectangle(40F, 40F, 100F, 100F).equalsWithEpsilon(appliedViewBox)); } @Test public void applyViewBoxXMidYMidMeetHorizontalTest() { Rectangle appliedViewBox = SvgCoordinateUtils .applyViewBox(VIEW_BOX, VIEW_PORT_HORIZONTAL, Values.XMID_YMID, Values.MEET); - Assert.assertTrue(new Rectangle(80F, 40F, 60F, 60F).equalsWithEpsilon(appliedViewBox)); + Assertions.assertTrue(new Rectangle(80F, 40F, 60F, 60F).equalsWithEpsilon(appliedViewBox)); } @Test public void applyViewBoxXMidYMidSliceHorizontalTest() { Rectangle appliedViewBox = SvgCoordinateUtils .applyViewBox(VIEW_BOX, VIEW_PORT_HORIZONTAL, Values.XMID_YMID, Values.SLICE); - Assert.assertTrue(new Rectangle(60F, 20F, 100F, 100F).equalsWithEpsilon(appliedViewBox)); + Assertions.assertTrue(new Rectangle(60F, 20F, 100F, 100F).equalsWithEpsilon(appliedViewBox)); } @Test public void applyViewBoxXMidYMidMeetVerticalTest() { Rectangle appliedViewBox = SvgCoordinateUtils .applyViewBox(VIEW_BOX, VIEW_PORT_VERTICAL, Values.XMID_YMID, Values.MEET); - Assert.assertTrue(new Rectangle(60F, 60F, 60F, 60F).equalsWithEpsilon(appliedViewBox)); + Assertions.assertTrue(new Rectangle(60F, 60F, 60F, 60F).equalsWithEpsilon(appliedViewBox)); } @Test public void applyViewBoxXMidYMidSliceVerticalTest() { Rectangle appliedViewBox = SvgCoordinateUtils .applyViewBox(VIEW_BOX, VIEW_PORT_VERTICAL, Values.XMID_YMID, Values.SLICE); - Assert.assertTrue(new Rectangle(40F, 40F, 100F, 100F).equalsWithEpsilon(appliedViewBox)); + Assertions.assertTrue(new Rectangle(40F, 40F, 100F, 100F).equalsWithEpsilon(appliedViewBox)); } @Test public void applyViewBoxXMidYMaxMeetHorizontalTest() { Rectangle appliedViewBox = SvgCoordinateUtils .applyViewBox(VIEW_BOX, VIEW_PORT_HORIZONTAL, Values.XMID_YMAX, Values.MEET); - Assert.assertTrue(new Rectangle(80F, 40F, 60F, 60F).equalsWithEpsilon(appliedViewBox)); + Assertions.assertTrue(new Rectangle(80F, 40F, 60F, 60F).equalsWithEpsilon(appliedViewBox)); } @Test public void applyViewBoxXMidYMaxSliceHorizontalTest() { Rectangle appliedViewBox = SvgCoordinateUtils .applyViewBox(VIEW_BOX, VIEW_PORT_HORIZONTAL, Values.XMID_YMAX, Values.SLICE); - Assert.assertTrue(new Rectangle(60F, 0F, 100F, 100F).equalsWithEpsilon(appliedViewBox)); + Assertions.assertTrue(new Rectangle(60F, 0F, 100F, 100F).equalsWithEpsilon(appliedViewBox)); } @Test public void applyViewBoxXMidYMaxMeetVerticalTest() { Rectangle appliedViewBox = SvgCoordinateUtils .applyViewBox(VIEW_BOX, VIEW_PORT_VERTICAL, Values.XMID_YMAX, Values.MEET); - Assert.assertTrue(new Rectangle(60F, 80F, 60F, 60F).equalsWithEpsilon(appliedViewBox)); + Assertions.assertTrue(new Rectangle(60F, 80F, 60F, 60F).equalsWithEpsilon(appliedViewBox)); } @Test public void applyViewBoxXMidYMaxSliceVerticalTest() { Rectangle appliedViewBox = SvgCoordinateUtils .applyViewBox(VIEW_BOX, VIEW_PORT_VERTICAL, Values.XMID_YMAX, Values.SLICE); - Assert.assertTrue(new Rectangle(40F, 40F, 100F, 100F).equalsWithEpsilon(appliedViewBox)); + Assertions.assertTrue(new Rectangle(40F, 40F, 100F, 100F).equalsWithEpsilon(appliedViewBox)); } @Test public void applyViewBoxXMaxYMinMeetHorizontalTest() { Rectangle appliedViewBox = SvgCoordinateUtils .applyViewBox(VIEW_BOX, VIEW_PORT_HORIZONTAL, Values.XMAX_YMIN, Values.MEET); - Assert.assertTrue(new Rectangle(100F, 40F, 60F, 60F).equalsWithEpsilon(appliedViewBox)); + Assertions.assertTrue(new Rectangle(100F, 40F, 60F, 60F).equalsWithEpsilon(appliedViewBox)); } @Test public void applyViewBoxXMaxYMinSliceHorizontalTest() { Rectangle appliedViewBox = SvgCoordinateUtils .applyViewBox(VIEW_BOX, VIEW_PORT_HORIZONTAL, Values.XMAX_YMIN, Values.SLICE); - Assert.assertTrue(new Rectangle(60F, 40F, 100F, 100F).equalsWithEpsilon(appliedViewBox)); + Assertions.assertTrue(new Rectangle(60F, 40F, 100F, 100F).equalsWithEpsilon(appliedViewBox)); } @Test public void applyViewBoxXMaxYMinMeetVerticalTest() { Rectangle appliedViewBox = SvgCoordinateUtils .applyViewBox(VIEW_BOX, VIEW_PORT_VERTICAL, Values.XMAX_YMIN, Values.MEET); - Assert.assertTrue(new Rectangle(60F, 40F, 60F, 60F).equalsWithEpsilon(appliedViewBox)); + Assertions.assertTrue(new Rectangle(60F, 40F, 60F, 60F).equalsWithEpsilon(appliedViewBox)); } @Test public void applyViewBoxXMaxYMinSliceVerticalTest() { Rectangle appliedViewBox = SvgCoordinateUtils .applyViewBox(VIEW_BOX, VIEW_PORT_VERTICAL, Values.XMAX_YMIN, Values.SLICE); - Assert.assertTrue(new Rectangle(20F, 40F, 100F, 100F).equalsWithEpsilon(appliedViewBox)); + Assertions.assertTrue(new Rectangle(20F, 40F, 100F, 100F).equalsWithEpsilon(appliedViewBox)); } @Test public void applyViewBoxXMaxYMidMeetHorizontalTest() { Rectangle appliedViewBox = SvgCoordinateUtils .applyViewBox(VIEW_BOX, VIEW_PORT_HORIZONTAL, Values.XMAX_YMID, Values.MEET); - Assert.assertTrue(new Rectangle(100F, 40F, 60F, 60F).equalsWithEpsilon(appliedViewBox)); + Assertions.assertTrue(new Rectangle(100F, 40F, 60F, 60F).equalsWithEpsilon(appliedViewBox)); } @Test public void applyViewBoxXMaxYMidSliceHorizontalTest() { Rectangle appliedViewBox = SvgCoordinateUtils .applyViewBox(VIEW_BOX, VIEW_PORT_HORIZONTAL, Values.XMAX_YMID, Values.SLICE); - Assert.assertTrue(new Rectangle(60F, 20F, 100F, 100F).equalsWithEpsilon(appliedViewBox)); + Assertions.assertTrue(new Rectangle(60F, 20F, 100F, 100F).equalsWithEpsilon(appliedViewBox)); } @Test public void applyViewBoxXMaxYMidMeetVerticalTest() { Rectangle appliedViewBox = SvgCoordinateUtils .applyViewBox(VIEW_BOX, VIEW_PORT_VERTICAL, Values.XMAX_YMID, Values.MEET); - Assert.assertTrue(new Rectangle(60F, 60F, 60F, 60F).equalsWithEpsilon(appliedViewBox)); + Assertions.assertTrue(new Rectangle(60F, 60F, 60F, 60F).equalsWithEpsilon(appliedViewBox)); } @Test public void applyViewBoxXMaxYMidSliceVerticalTest() { Rectangle appliedViewBox = SvgCoordinateUtils .applyViewBox(VIEW_BOX, VIEW_PORT_VERTICAL, Values.XMAX_YMID, Values.SLICE); - Assert.assertTrue(new Rectangle(20F, 40F, 100F, 100F).equalsWithEpsilon(appliedViewBox)); + Assertions.assertTrue(new Rectangle(20F, 40F, 100F, 100F).equalsWithEpsilon(appliedViewBox)); } @Test public void applyViewBoxXMaxYMaxMeetHorizontalTest() { Rectangle appliedViewBox = SvgCoordinateUtils .applyViewBox(VIEW_BOX, VIEW_PORT_HORIZONTAL, Values.XMAX_YMAX, Values.MEET); - Assert.assertTrue(new Rectangle(100F, 40F, 60F, 60F).equalsWithEpsilon(appliedViewBox)); + Assertions.assertTrue(new Rectangle(100F, 40F, 60F, 60F).equalsWithEpsilon(appliedViewBox)); } @Test public void applyViewBoxXMaxYMaxSliceHorizontalTest() { Rectangle appliedViewBox = SvgCoordinateUtils .applyViewBox(VIEW_BOX, VIEW_PORT_HORIZONTAL, Values.XMAX_YMAX, Values.SLICE); - Assert.assertTrue(new Rectangle(60F, 0F, 100F, 100F).equalsWithEpsilon(appliedViewBox)); + Assertions.assertTrue(new Rectangle(60F, 0F, 100F, 100F).equalsWithEpsilon(appliedViewBox)); } @Test public void applyViewBoxXMaxYMaxMeetVerticalTest() { Rectangle appliedViewBox = SvgCoordinateUtils .applyViewBox(VIEW_BOX, VIEW_PORT_VERTICAL, Values.XMAX_YMAX, Values.MEET); - Assert.assertTrue(new Rectangle(60F, 80F, 60F, 60F).equalsWithEpsilon(appliedViewBox)); + Assertions.assertTrue(new Rectangle(60F, 80F, 60F, 60F).equalsWithEpsilon(appliedViewBox)); } @Test public void applyViewBoxXMaxYMaxSliceVerticalTest() { Rectangle appliedViewBox = SvgCoordinateUtils .applyViewBox(VIEW_BOX, VIEW_PORT_VERTICAL, Values.XMAX_YMAX, Values.SLICE); - Assert.assertTrue(new Rectangle(20F, 40F, 100F, 100F).equalsWithEpsilon(appliedViewBox)); + Assertions.assertTrue(new Rectangle(20F, 40F, 100F, 100F).equalsWithEpsilon(appliedViewBox)); } } diff --git a/svg/src/test/java/com/itextpdf/svg/utils/SvgCssUtilsTest.java b/svg/src/test/java/com/itextpdf/svg/utils/SvgCssUtilsTest.java index e1c0a037f5..07279dac40 100644 --- a/svg/src/test/java/com/itextpdf/svg/utils/SvgCssUtilsTest.java +++ b/svg/src/test/java/com/itextpdf/svg/utils/SvgCssUtilsTest.java @@ -28,16 +28,14 @@ This file is part of the iText (R) project. import com.itextpdf.styledxmlparser.jsoup.parser.Tag; import com.itextpdf.styledxmlparser.node.impl.jsoup.node.JsoupElementNode; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; import java.util.ArrayList; import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; -@Category(UnitTest.class) +@org.junit.jupiter.api.Tag("UnitTest") public class SvgCssUtilsTest extends ExtendedITextTest { @Test @@ -51,7 +49,7 @@ public void commaSplitValueTest() { List<String> actual = SvgCssUtils.splitValueList(input); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test @@ -68,7 +66,7 @@ public void leadingAndTrailingWhiteSpaceTest() { List<String> actual = SvgCssUtils.splitValueList(input); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test @@ -82,7 +80,7 @@ public void whitespaceSplitValueTest() { List<String> actual = SvgCssUtils.splitValueList(input); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test @@ -96,7 +94,7 @@ public void newLineSplitValueTest() { List<String> actual = SvgCssUtils.splitValueList(input); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test @@ -110,7 +108,7 @@ public void tabSplitValueTest() { List<String> actual = SvgCssUtils.splitValueList(input); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test @@ -124,7 +122,7 @@ public void mixedCommaWhitespaceSplitValueTest() { List<String> actual = SvgCssUtils.splitValueList(input); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test @@ -138,21 +136,21 @@ public void emptyStringsSplitValueTest() { List<String> actual = SvgCssUtils.splitValueList(input); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test public void nullSplitValueTest() { List<String> actual = SvgCssUtils.splitValueList(null); - Assert.assertTrue(actual.isEmpty()); + Assertions.assertTrue(actual.isEmpty()); } @Test public void emptySplitValueTest() { List<String> actual = SvgCssUtils.splitValueList(""); - Assert.assertTrue(actual.isEmpty()); + Assertions.assertTrue(actual.isEmpty()); } @Test @@ -160,7 +158,7 @@ public void convertFloatToStringTest() { String expected = "0.5"; String actual = SvgCssUtils.convertFloatToString(0.5f); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test @@ -168,6 +166,6 @@ public void convertLongerFloatToStringTest() { String expected = "0.1234567"; String actual = SvgCssUtils.convertFloatToString(0.1234567f); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } } diff --git a/svg/src/test/java/com/itextpdf/svg/utils/SvgTextUtilTest.java b/svg/src/test/java/com/itextpdf/svg/utils/SvgTextUtilTest.java index eb58f464c8..6d65d46199 100644 --- a/svg/src/test/java/com/itextpdf/svg/utils/SvgTextUtilTest.java +++ b/svg/src/test/java/com/itextpdf/svg/utils/SvgTextUtilTest.java @@ -26,12 +26,11 @@ This file is part of the iText (R) project. import com.itextpdf.svg.renderers.impl.TextLeafSvgNodeRenderer; import com.itextpdf.svg.renderers.impl.TextSvgBranchRenderer; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class SvgTextUtilTest extends ExtendedITextTest { public static float EPS = 0.0001f; @@ -43,7 +42,7 @@ public void trimLeadingTest() { String actual = SvgTextUtil.trimLeadingWhitespace(toTrim); String expected = "to trim \t"; - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test @@ -52,7 +51,7 @@ public void trimLeadingEmptyTest() { String actual = SvgTextUtil.trimLeadingWhitespace(toTrim); String expected = ""; - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test @@ -61,7 +60,7 @@ public void trimLeadingNoLeadingTest() { String actual = SvgTextUtil.trimLeadingWhitespace(toTrim); String expected = "to Test "; - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test @@ -70,7 +69,7 @@ public void trimLeadingSingleWhiteSpaceTest() { String actual = SvgTextUtil.trimLeadingWhitespace(toTrim); String expected = "to Test "; - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test @@ -79,7 +78,7 @@ public void trimLeadingNonBreakingSpaceTest() { String actual = SvgTextUtil.trimLeadingWhitespace(toTrim); String expected = "\u00A0to Test "; - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test @@ -88,7 +87,7 @@ public void trimLeadingOnlyWhitespaceTest() { String actual = SvgTextUtil.trimLeadingWhitespace(toTrim); String expected = ""; - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test @@ -97,7 +96,7 @@ public void trimLeadingLineBreakTest() { String actual = SvgTextUtil.trimLeadingWhitespace(toTrim); String expected = "\n Test "; - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } //Trim trailing tests @@ -107,7 +106,7 @@ public void trimTrailingTest() { String actual = SvgTextUtil.trimTrailingWhitespace(toTrim); String expected = "\t \t to trim"; - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test @@ -116,7 +115,7 @@ public void trimTrailingEmptyTest() { String actual = SvgTextUtil.trimTrailingWhitespace(toTrim); String expected = ""; - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test @@ -125,7 +124,7 @@ public void trimTrailingNoTrailingTest() { String actual = SvgTextUtil.trimTrailingWhitespace(toTrim); String expected = " to Test"; - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test @@ -134,7 +133,7 @@ public void trimTrailingSingleWhiteSpaceTest() { String actual = SvgTextUtil.trimTrailingWhitespace(toTrim); String expected = " to Test"; - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test @@ -143,7 +142,7 @@ public void trimTrailingNonBreakingSpaceTest() { String actual = SvgTextUtil.trimTrailingWhitespace(toTrim); String expected = " to Test\u00A0"; - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test @@ -152,7 +151,7 @@ public void trimTrailingOnlyWhitespaceTest() { String actual = SvgTextUtil.trimTrailingWhitespace(toTrim); String expected = ""; - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test @@ -161,7 +160,7 @@ public void trimTrailingLineBreakTest() { String actual = SvgTextUtil.trimTrailingWhitespace(toTrim); String expected = " to trim \n"; - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test @@ -169,7 +168,7 @@ public void trimNullLeadingTest() { String expected = ""; String actual = SvgTextUtil.trimLeadingWhitespace(null); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test @@ -177,7 +176,7 @@ public void trimNullTrailingTest() { String expected = ""; String actual = SvgTextUtil.trimTrailingWhitespace(null); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test @@ -185,7 +184,7 @@ public void trimTrailingOfStringWithLength1Test() { String toTrim = "A"; String actual = SvgTextUtil.trimTrailingWhitespace(toTrim); String expected = "A"; - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test @@ -227,7 +226,7 @@ public void processWhiteSpaceBreakLine() { }; //Create expected String[] expected = new String[]{"text", " tspan text", " after text"}; - Assert.assertArrayEquals(expected, actual); + Assertions.assertArrayEquals(expected, actual); } @Test @@ -271,7 +270,7 @@ public void processWhiteSpaceAbsPositionChange() { }; //Create expected String[] expected = new String[]{"text", "tspan text", " after text"};//No preceding whitespace on the second element - Assert.assertArrayEquals(expected, actual); + Assertions.assertArrayEquals(expected, actual); } @Test @@ -285,7 +284,7 @@ public void processFontSizeInEM() { //Run float actual = SvgTextUtil.resolveFontSize(root, 10); - Assert.assertEquals(expected, actual, EPS); + Assertions.assertEquals(expected, actual, EPS); } @Test @@ -299,7 +298,7 @@ public void processFontSizeInPX() { //Run float actual = SvgTextUtil.resolveFontSize(root, 10); - Assert.assertEquals(expected, actual, EPS); + Assertions.assertEquals(expected, actual, EPS); } @Test @@ -313,7 +312,7 @@ public void processFontSizeInPT() { //Run float actual = SvgTextUtil.resolveFontSize(root, 10); - Assert.assertEquals(expected, actual, EPS); + Assertions.assertEquals(expected, actual, EPS); } @Test @@ -328,47 +327,47 @@ public void processKeywordedFontSize() { // Parent's font-size doesn't impact the result in this test float actual = SvgTextUtil.resolveFontSize(root, 10); - Assert.assertEquals(expected, actual, EPS); + Assertions.assertEquals(expected, actual, EPS); } @Test public void testFilterReferenceValueMarkerReference() { - Assert.assertEquals("MarkerCircle", SvgTextUtil.filterReferenceValue("url(#MarkerCircle)")); + Assertions.assertEquals("MarkerCircle", SvgTextUtil.filterReferenceValue("url(#MarkerCircle)")); } @Test public void testFilterReferenceValueMarkerFullEntry() { - Assert.assertEquals("marker-end: MarkerArrow;", + Assertions.assertEquals("marker-end: MarkerArrow;", SvgTextUtil.filterReferenceValue("marker-end: url(#MarkerArrow);")); } @Test public void testFilterReferenceValueSimpleReference() { - Assert.assertEquals("figure11", + Assertions.assertEquals("figure11", SvgTextUtil.filterReferenceValue("#figure11")); } @Test public void testFilterReferenceValueNoFilter() { - Assert.assertEquals("circle", + Assertions.assertEquals("circle", SvgTextUtil.filterReferenceValue("circle")); } @Test public void testFilterReferenceValueEmptyString() { - Assert.assertEquals("", + Assertions.assertEquals("", SvgTextUtil.filterReferenceValue("")); } @Test public void testFilterReferenceValueNumberString() { - Assert.assertEquals("16554245", + Assertions.assertEquals("16554245", SvgTextUtil.filterReferenceValue("16554245")); } @Test public void testFilterReferenceValueFilteredValues() { - Assert.assertEquals("", + Assertions.assertEquals("", SvgTextUtil.filterReferenceValue("))url(####)")); } } diff --git a/svg/src/test/java/com/itextpdf/svg/utils/TransformUtilsTest.java b/svg/src/test/java/com/itextpdf/svg/utils/TransformUtilsTest.java index dd03d1e76b..27b730cdb6 100644 --- a/svg/src/test/java/com/itextpdf/svg/utils/TransformUtilsTest.java +++ b/svg/src/test/java/com/itextpdf/svg/utils/TransformUtilsTest.java @@ -26,50 +26,49 @@ This file is part of the iText (R) project. import com.itextpdf.svg.exceptions.SvgExceptionMessageConstant; import com.itextpdf.svg.exceptions.SvgProcessingException; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class TransformUtilsTest extends ExtendedITextTest { @Test public void nullStringTest() { - Exception e = Assert.assertThrows(SvgProcessingException.class, + Exception e = Assertions.assertThrows(SvgProcessingException.class, () -> TransformUtils.parseTransform(null) ); - Assert.assertEquals(SvgExceptionMessageConstant.TRANSFORM_NULL, e.getMessage()); + Assertions.assertEquals(SvgExceptionMessageConstant.TRANSFORM_NULL, e.getMessage()); } @Test public void emptyTest() { - Exception e = Assert.assertThrows(SvgProcessingException.class, + Exception e = Assertions.assertThrows(SvgProcessingException.class, () -> TransformUtils.parseTransform("") ); - Assert.assertEquals(SvgExceptionMessageConstant.TRANSFORM_EMPTY, e.getMessage()); + Assertions.assertEquals(SvgExceptionMessageConstant.TRANSFORM_EMPTY, e.getMessage()); } @Test public void noTransformationTest() { - Exception e = Assert.assertThrows(SvgProcessingException.class, + Exception e = Assertions.assertThrows(SvgProcessingException.class, () -> TransformUtils.parseTransform("Lorem ipsum") ); - Assert.assertEquals(SvgExceptionMessageConstant.INVALID_TRANSFORM_DECLARATION, e.getMessage()); + Assertions.assertEquals(SvgExceptionMessageConstant.INVALID_TRANSFORM_DECLARATION, e.getMessage()); } @Test public void wrongTypeOfValuesTest() { - Assert.assertThrows(NumberFormatException.class, () -> TransformUtils.parseTransform("matrix(a b c d e f)")); + Assertions.assertThrows(NumberFormatException.class, () -> TransformUtils.parseTransform("matrix(a b c d e f)")); } @Test public void tooManyParenthesesTest() { - Exception e = Assert.assertThrows(SvgProcessingException.class, + Exception e = Assertions.assertThrows(SvgProcessingException.class, () -> TransformUtils.parseTransform("(((())))") ); - Assert.assertEquals(SvgExceptionMessageConstant.INVALID_TRANSFORM_DECLARATION, e.getMessage()); + Assertions.assertEquals(SvgExceptionMessageConstant.INVALID_TRANSFORM_DECLARATION, e.getMessage()); } @Test @@ -77,7 +76,7 @@ public void noClosingParenthesisTest() { AffineTransform expected = new AffineTransform(0d, 0d, 0d, 0d, 0d, 0d); AffineTransform actual = TransformUtils.parseTransform("matrix(0 0 0 0 0 0"); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test @@ -85,7 +84,7 @@ public void mixedCaseTest() { AffineTransform expected = new AffineTransform(0d, 0d, 0d, 0d, 0d, 0d); AffineTransform actual = TransformUtils.parseTransform("maTRix(0 0 0 0 0 0)"); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test @@ -93,7 +92,7 @@ public void upperCaseTest() { AffineTransform expected = new AffineTransform(0d, 0d, 0d, 0d, 0d, 0d); AffineTransform actual = TransformUtils.parseTransform("MATRIX(0 0 0 0 0 0)"); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test @@ -101,7 +100,7 @@ public void whitespaceTest() { AffineTransform expected = new AffineTransform(0d, 0d, 0d, 0d, 0d, 0d); AffineTransform actual = TransformUtils.parseTransform("matrix(0 0 0 0 0 0)"); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test @@ -109,7 +108,7 @@ public void commasWithWhitespaceTest() { AffineTransform expected = new AffineTransform(10d,20d,30d,40d,37.5d, 45d); AffineTransform actual = TransformUtils.parseTransform("matrix(10, 20, 30, 40, 50, 60)"); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test @@ -117,7 +116,7 @@ public void commasTest() { AffineTransform expected = new AffineTransform(10d,20d,30d,40d,37.5d, 45d); AffineTransform actual = TransformUtils.parseTransform("matrix(10,20,30,40,50,60)"); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test @@ -125,7 +124,7 @@ public void combinedTransformTest() { AffineTransform actual = TransformUtils.parseTransform("translate(40,20) scale(3)"); AffineTransform expected = new AffineTransform(3.0,0d,0d,3.0d,30d,15d); - Assert.assertEquals(actual, expected); + Assertions.assertEquals(actual, expected); } @Test @@ -133,7 +132,15 @@ public void combinedReverseTransformTest() { AffineTransform actual = TransformUtils.parseTransform("scale(3) translate(40,20)"); AffineTransform expected = new AffineTransform(3d,0d,0d,3d,90d,45d); - Assert.assertEquals(actual, expected); + Assertions.assertEquals(actual, expected); + } + + @Test + public void combinedReverseTransformWithCommaTest() { + AffineTransform actual = TransformUtils.parseTransform("scale(3),translate(40,20)"); + AffineTransform expected = new AffineTransform(3d,0d,0d,3d,90d,45d); + + Assertions.assertEquals(actual, expected); } @Test @@ -141,7 +148,7 @@ public void doubleTransformationTest() { AffineTransform expected = new AffineTransform(9d, 0d, 0d, 9d, 0d, 0d); AffineTransform actual = TransformUtils.parseTransform("scale(3) scale(3)"); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test @@ -149,15 +156,15 @@ public void oppositeTransformationSequenceTest() { AffineTransform expected = new AffineTransform(1,0,0,1,0,0); AffineTransform actual = TransformUtils.parseTransform("translate(10 10) translate(-10 -10)"); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test public void unknownTransformationTest() { - Exception e = Assert.assertThrows(SvgProcessingException.class, + Exception e = Assertions.assertThrows(SvgProcessingException.class, () -> TransformUtils.parseTransform("unknown(1 2 3)") ); - Assert.assertEquals(SvgExceptionMessageConstant.UNKNOWN_TRANSFORMATION_TYPE, e.getMessage()); + Assertions.assertEquals(SvgExceptionMessageConstant.UNKNOWN_TRANSFORMATION_TYPE, e.getMessage()); } @Test @@ -165,7 +172,7 @@ public void trailingWhiteSpace() { AffineTransform actual = TransformUtils.parseTransform("translate(1) translate(2) "); AffineTransform expected = AffineTransform.getTranslateInstance(2.25, 0); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test @@ -173,7 +180,7 @@ public void leadingWhiteSpace() { AffineTransform actual = TransformUtils.parseTransform(" translate(1) translate(2)"); AffineTransform expected = AffineTransform.getTranslateInstance(2.25, 0); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test @@ -181,7 +188,7 @@ public void middleWhiteSpace() { AffineTransform actual = TransformUtils.parseTransform("translate(1) translate(2)"); AffineTransform expected = AffineTransform.getTranslateInstance(2.25, 0); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test @@ -189,6 +196,6 @@ public void mixedWhiteSpace() { AffineTransform actual = TransformUtils.parseTransform(" translate(1) translate(2) "); AffineTransform expected = AffineTransform.getTranslateInstance(2.25, 0); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } } diff --git a/svg/src/test/java/com/itextpdf/svg/utils/TranslateTransformationTest.java b/svg/src/test/java/com/itextpdf/svg/utils/TranslateTransformationTest.java index 5ce586d97f..20e77d6b8a 100644 --- a/svg/src/test/java/com/itextpdf/svg/utils/TranslateTransformationTest.java +++ b/svg/src/test/java/com/itextpdf/svg/utils/TranslateTransformationTest.java @@ -26,13 +26,12 @@ This file is part of the iText (R) project. import com.itextpdf.svg.exceptions.SvgExceptionMessageConstant; import com.itextpdf.svg.exceptions.SvgProcessingException; import com.itextpdf.test.ExtendedITextTest; -import com.itextpdf.test.annotations.type.UnitTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; -@Category(UnitTest.class) +@Tag("UnitTest") public class TranslateTransformationTest extends ExtendedITextTest { @Test @@ -40,15 +39,15 @@ public void normalTranslateTest() { AffineTransform expected = new AffineTransform(1d, 0d, 0d, 1d, 15d, 37.5d); AffineTransform actual = TransformUtils.parseTransform("translate(20, 50)"); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test public void noTranslateValuesTest() { - Exception e = Assert.assertThrows(SvgProcessingException.class, + Exception e = Assertions.assertThrows(SvgProcessingException.class, () -> TransformUtils.parseTransform("translate()") ); - Assert.assertEquals(SvgExceptionMessageConstant.TRANSFORM_INCORRECT_NUMBER_OF_VALUES, e.getMessage()); + Assertions.assertEquals(SvgExceptionMessageConstant.TRANSFORM_INCORRECT_NUMBER_OF_VALUES, e.getMessage()); } @Test @@ -56,7 +55,7 @@ public void oneTranslateValuesTest() { AffineTransform expected = new AffineTransform(1d, 0d, 0d, 1d, 7.5d, 0d); AffineTransform actual = TransformUtils.parseTransform("translate(10)"); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test @@ -64,7 +63,7 @@ public void twoTranslateValuesTest() { AffineTransform expected = new AffineTransform(1d, 0d, 0d, 1d, 17.25d, 43.5d); AffineTransform actual = TransformUtils.parseTransform("translate(23,58)"); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test @@ -72,14 +71,14 @@ public void negativeTranslateValuesTest() { AffineTransform expected = new AffineTransform(1d, 0d, 0d, 1d, -17.25d, -43.5d); AffineTransform actual = TransformUtils.parseTransform("translate(-23,-58)"); - Assert.assertEquals(expected, actual); + Assertions.assertEquals(expected, actual); } @Test public void tooManyTranslateValuesTest() { - Exception e = Assert.assertThrows(SvgProcessingException.class, + Exception e = Assertions.assertThrows(SvgProcessingException.class, () -> TransformUtils.parseTransform("translate(1 2 3)") ); - Assert.assertEquals(SvgExceptionMessageConstant.TRANSFORM_INCORRECT_NUMBER_OF_VALUES, e.getMessage()); + Assertions.assertEquals(SvgExceptionMessageConstant.TRANSFORM_INCORRECT_NUMBER_OF_VALUES, e.getMessage()); } } diff --git a/svg/src/test/resources/com/itextpdf/svg/converter/SvgConverterTest/cmp_CTI_eclipse_StreamDocument.pdf b/svg/src/test/resources/com/itextpdf/svg/converter/SvgConverterTest/cmp_CTI_eclipse_StreamDocument.pdf deleted file mode 100644 index 61838b64df..0000000000 Binary files a/svg/src/test/resources/com/itextpdf/svg/converter/SvgConverterTest/cmp_CTI_eclipse_StreamDocument.pdf and /dev/null differ diff --git a/svg/src/test/resources/com/itextpdf/svg/converter/SvgConverterTest/cmp_CTI_eclipse_StreamDocumentProps.pdf b/svg/src/test/resources/com/itextpdf/svg/converter/SvgConverterTest/cmp_CTI_eclipse_StreamDocumentProps.pdf deleted file mode 100644 index 78744674ef..0000000000 Binary files a/svg/src/test/resources/com/itextpdf/svg/converter/SvgConverterTest/cmp_CTI_eclipse_StreamDocumentProps.pdf and /dev/null differ diff --git a/svg/src/test/resources/com/itextpdf/svg/converter/SvgConverterTest/cmp_CTI_eclipse_StreamDocument_props.pdf b/svg/src/test/resources/com/itextpdf/svg/converter/SvgConverterTest/cmp_CTI_eclipse_StreamDocument_props.pdf deleted file mode 100644 index ea0d5a8b63..0000000000 Binary files a/svg/src/test/resources/com/itextpdf/svg/converter/SvgConverterTest/cmp_CTI_eclipse_StreamDocument_props.pdf and /dev/null differ diff --git a/svg/src/test/resources/com/itextpdf/svg/css/DefaultInheritance/useGroupInheritance.svg b/svg/src/test/resources/com/itextpdf/svg/css/DefaultInheritance/useGroupInheritance.svg deleted file mode 100644 index 65a3764d67..0000000000 --- a/svg/src/test/resources/com/itextpdf/svg/css/DefaultInheritance/useGroupInheritance.svg +++ /dev/null @@ -1,23 +0,0 @@ -<?xml version="1.0" standalone="no"?> -<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" - "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> -<svg width="300" height="200" - xmlns="http://www.w3.org/2000/svg" version="1.1"> - <style> - .blue{ - fill:blue; - } - - </style> - <defs> - <g id="g1"> - <rect width="50" height="50"/> - <circle cx="75" cy="25" r="25"/> - <rect x="100" width="50" height="50"/> - </g> - </defs> - - <rect x="0" y="0" width="300" height="200" fill="gray" /> - <use x="20" y="25" href="#g1" /> - <use x="20" y="100" href="#g1" stroke="green" class="blue" /> -</svg> \ No newline at end of file diff --git a/svg/src/test/resources/com/itextpdf/svg/css/SvgStyleResolver/web-fonts/NotoSansCJK-Regular.woff2 b/svg/src/test/resources/com/itextpdf/svg/css/SvgStyleResolver/web-fonts/NotoSansCJK-Regular.woff2 deleted file mode 100644 index 77e3b2613c..0000000000 Binary files a/svg/src/test/resources/com/itextpdf/svg/css/SvgStyleResolver/web-fonts/NotoSansCJK-Regular.woff2 and /dev/null differ diff --git a/svg/src/test/resources/com/itextpdf/svg/css/SvgStyleResolver/web-fonts/open-sans-v15-latin-regular.ttf b/svg/src/test/resources/com/itextpdf/svg/css/SvgStyleResolver/web-fonts/open-sans-v15-latin-regular.ttf deleted file mode 100644 index 9d4e8e526d..0000000000 Binary files a/svg/src/test/resources/com/itextpdf/svg/css/SvgStyleResolver/web-fonts/open-sans-v15-latin-regular.ttf and /dev/null differ diff --git a/svg/src/test/resources/com/itextpdf/svg/processors/impl/font/FontFaceTest/w3c-test-fonts/cmp_droidSerifLocalWithMediaFontTest.pdf b/svg/src/test/resources/com/itextpdf/svg/processors/impl/font/FontFaceTest/w3c-test-fonts/cmp_droidSerifLocalWithMediaFontTest.pdf deleted file mode 100644 index bb5fb7d088..0000000000 Binary files a/svg/src/test/resources/com/itextpdf/svg/processors/impl/font/FontFaceTest/w3c-test-fonts/cmp_droidSerifLocalWithMediaFontTest.pdf and /dev/null differ diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/DeepCopyTest/deepCopyExample.svg b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/DeepCopyTest/deepCopyExample.svg deleted file mode 100644 index d40c7b4266..0000000000 --- a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/DeepCopyTest/deepCopyExample.svg +++ /dev/null @@ -1,15 +0,0 @@ -<svg width='800' height='800' xmlns="http://www.w3.org/2000/svg" version="1.1"> - <defs> - <circle id="c1" r="50" /> - </defs> - <circle cx='100' cy='100' r='80' stroke='red' fill='green'/> - <g fill="red"> - <rect width="100" height="50"/> - </g> - <svg x="200" y="200" xmlns="http://www.w3.org/2000/svg" version="1.1"> - <circle r="100" /> - <g fill="blue"> - <use href="#c1"/> - </g> - </svg> -</svg> \ No newline at end of file diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/EllipseSvgNodeRendererIntegrationTest/Ellipse.svg b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/EllipseSvgNodeRendererIntegrationTest/Ellipse.svg deleted file mode 100644 index eb61d28293..0000000000 --- a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/EllipseSvgNodeRendererIntegrationTest/Ellipse.svg +++ /dev/null @@ -1,8 +0,0 @@ -<svg x='100' y='100' width='800' height='800' - xmlns="http://www.w3.org/2000/svg" version="1.1"> - - <ellipse rx='80' ry='40' stroke='green' fill ='cyan'/> - <ellipse rx='80' ry='40' transform='skewX(40)' stroke='red' fill ='green'/> - <line x1='100' y1='100' x2='200' y2='100' stroke='black'/> - <line x1='100' y1='100' x2='100' y2='200' stroke='black'/> -</svg> \ No newline at end of file diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/FillTest/cmp_eofillUnsuportedAtributeTest.pdf b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/FillTest/cmp_eofillUnsuportedAtributeTest.pdf deleted file mode 100644 index 732e4b8bb1..0000000000 Binary files a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/FillTest/cmp_eofillUnsuportedAtributeTest.pdf and /dev/null differ diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/GroupRendererTest/doubleOccurrenceNestedGroup.svg b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/GroupRendererTest/doubleOccurrenceNestedGroup.svg deleted file mode 100644 index 493e106266..0000000000 --- a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/GroupRendererTest/doubleOccurrenceNestedGroup.svg +++ /dev/null @@ -1,21 +0,0 @@ -<svg version="1.1" baseProfile="full" width="500" height="500" xmlns="http://www.w3.org/2000/svg"> - <g id="unit"> - <rect x="0" y="0" width="200" height="200" fill="none" stroke="green" stroke-width="10"/> - <g id="fiddy"> - <rect x="100" y="100" width="200" height="200" fill="orange" stroke="blue" stroke-width="20"/> - </g> - </g> - - - <use href="#fiddy" x="100" y="100" /> - - <use href="#unit" x="0" y="200" /> - - - <g id="unit2"> - <rect x="200" y="0" width="200" height="200" fill="none" stroke="green" stroke-width="10"/> - <g id="fiddy"> - <rect x="300" y="100" width="200" height="200" fill="orange" stroke="blue" stroke-width="20"/> - </g> - </g> -</svg> \ No newline at end of file diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/GroupRendererTest/simpleG.svg b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/GroupRendererTest/simpleG.svg deleted file mode 100644 index db983ce5f0..0000000000 --- a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/GroupRendererTest/simpleG.svg +++ /dev/null @@ -1,3 +0,0 @@ -<svg version="1.1" baseProfile="full" width="250" height="250" xmlns="http://www.w3.org/2000/svg"> - <g id="unit" /> -</svg> \ No newline at end of file diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/ImageSvgNodeRendererTest/random.svg b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/ImageSvgNodeRendererTest/random.svg deleted file mode 100644 index cffd6aab1b..0000000000 --- a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/ImageSvgNodeRendererTest/random.svg +++ /dev/null @@ -1,20 +0,0 @@ -<svg xmlns="http://www.w3.org/2000/svg" - xmlns:xlink="http://www.w3.org/1999/xlink" width="500" height="500"> - <line x1="0" y1="100" x2="500" y2="100" stroke="black" stroke-width="2" /> - <line x1="0" y1="200" x2="500" y2="200" stroke="black" stroke-width="2" /> - <line x1="0" y1="300" x2="500" y2="300" stroke="black" stroke-width="2" /> - <line x1="0" y1="400" x2="500" y2="400" stroke="black" stroke-width="2" /> - <line x1="100" y1="0" x2="100" y2="500" stroke="black" stroke-width="2" /> - <line x1="200" y1="0" x2="200" y2="500" stroke="black" stroke-width="2" /> - <line x1="300" y1="0" x2="300" y2="500" stroke="black" stroke-width="2" /> - <line x1="400" y1="0" x2="400" y2="500" stroke="black" stroke-width="2" /> - <rect x="0" y="0" height="150" width="500" style="fill: #000000"/> - <rect x="50" y="400" height="130" width="500" style="fill: #0000ff"/> - <image x="0" y="0" width="350" height="80.98" - xlink:href="https://www.google.by/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png" /> - <image transform="translate(150, 0) rotate(45.5) skewY(-20.5)" - x="50" y="200" width="350.5" height="80" - xlink:href="https://www.google.by/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png" /> - <line x1="25" y1="80" x2="350" y2="80" - style="stroke: #ffffff; stroke-width: 3;"/> -</svg> \ No newline at end of file diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/LineSvgNodeRendererTest/cmp_invalidAttributes02.pdf b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/LineSvgNodeRendererTest/cmp_invalidAttributes02.pdf deleted file mode 100644 index 513347240b..0000000000 Binary files a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/LineSvgNodeRendererTest/cmp_invalidAttributes02.pdf and /dev/null differ diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/LineSvgNodeRendererTest/lineBlue.svg b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/LineSvgNodeRendererTest/lineBlue.svg deleted file mode 100644 index badf0a0258..0000000000 --- a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/LineSvgNodeRendererTest/lineBlue.svg +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0" standalone="no"?> -<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" - "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> -<svg width="12cm" height="4cm" viewBox="0 0 1200 400" - xmlns="http://www.w3.org/2000/svg" version="1.1"> - -<style> - /* <![CDATA[ */ - line { - stroke: blue; - stroke-width: 10px; /* Note: The value of a pixel depends - on the view box */ - } - /* ]]> */ -</style> - <rect x="100" y="100" width="200" height="200" fill="none" stroke="green" stroke-width="10"/> - <line x1="100" y1="300" x2="300" y2="100" - stroke-width="25" /> - -</svg> \ No newline at end of file diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/LineSvgNodeRendererTest/lineRendererTest.svg b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/LineSvgNodeRendererTest/lineRendererTest.svg deleted file mode 100644 index cd4aae1888..0000000000 --- a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/LineSvgNodeRendererTest/lineRendererTest.svg +++ /dev/null @@ -1,19 +0,0 @@ -<?xml version="1.0" standalone="no"?> -<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" - "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> -<svg width="12cm" height="4cm" viewBox="0 0 1200 400" - xmlns="http://www.w3.org/2000/svg" version="1.1"> - -<style> - /* <![CDATA[ */ - line { - stroke: green; - stroke-width: 10px; /* Note: The value of a pixel depends - on the view box */ - } - /* ]]> */ - </style> - <line x1="900" y1="300" x2="1100" y2="100" - stroke-width="25" /> - -</svg> \ No newline at end of file diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/LinearGradientSvgNodeRendererTest/cmp_text.pdf b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/LinearGradientSvgNodeRendererTest/cmp_text.pdf index 18388ac11d..2bd40bef4e 100644 Binary files a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/LinearGradientSvgNodeRendererTest/cmp_text.pdf and b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/LinearGradientSvgNodeRendererTest/cmp_text.pdf differ diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/LinearGradientSvgNodeRendererTest/cmp_textXOffset.pdf b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/LinearGradientSvgNodeRendererTest/cmp_textXOffset.pdf index 8b180cdf7d..0002429049 100644 Binary files a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/LinearGradientSvgNodeRendererTest/cmp_textXOffset.pdf and b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/LinearGradientSvgNodeRendererTest/cmp_textXOffset.pdf differ diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/MarkerSvgNodeRendererIntegrationTest/markerSimple.svg b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/MarkerSvgNodeRendererIntegrationTest/markerSimple.svg deleted file mode 100644 index 672ed2dad6..0000000000 --- a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/MarkerSvgNodeRendererIntegrationTest/markerSimple.svg +++ /dev/null @@ -1,25 +0,0 @@ -<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100" - xmlns:xlink="http://www.w3.org/1999/xlink" - preserveAspectRatio="none"> - <defs> - <path id="triangle" d="M0,0 L0,5 L5,2.5 L0,0" style="fill: blue;" /> - </defs> - <marker id="markerArrow" markerHeight="10" markerWidth="10" viewBox="0 0 10 10" - preserveAspectRatio="none" markerUnits="userSpaceOnUse" - overflow="hidden"> - <use xlink:href="#triangle"/> - </marker> - - <line x1="10" y1="10" x2="50" y2="10" stroke="black" - style="marker-end: url(#markerArrow);"/> - - <svg x="50" y="20" width="10" height="10" viewBox="0 0 10 10" overflow="hidden" - preserveAspectRatio="none"> - <use xlink:href="#triangle"/> - </svg> - - <rect x="50" y="10" width="10" height="10" - fill="none" stroke="teal" stroke-width="0.3"/> - <rect x="50" y="20" width="10" height="10" - fill="none" stroke="teal" stroke-width="0.3"/> -</svg> \ No newline at end of file diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/MarkerSvgNodeRendererIntegrationTest/oneShapePath.svg b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/MarkerSvgNodeRendererIntegrationTest/oneShapePath.svg deleted file mode 100644 index 013e9f8421..0000000000 --- a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/MarkerSvgNodeRendererIntegrationTest/oneShapePath.svg +++ /dev/null @@ -1,21 +0,0 @@ -<svg xmlns="http://www.w3.org/2000/svg" width="255" height="240" viewBox="0 0 200 200" > - - <marker id="markerCircle" markerWidth="8" markerHeight="8" refX="5" refY="5"> - <circle cx="5" cy="5" r="3" style="stroke: none; fill:#000000;"/> - </marker> - - <marker id="markerCross" markerWidth="13" markerHeight="13" refX="3" refY="3" > - <rect x="0" y="0" width="5" height="5" style="stroke: none; fill:#000000;"/> - </marker> - - <marker id="markerArrow" markerWidth="13" markerHeight="13" refX="2" refY="6" - orient="auto"> - <path d="M2,2 L2,11 L10,6 L2,2" style="fill: #000000;" /> - </marker> - - <path d="M100,10 L150,10 L150,60" - style="stroke: #6666ff; stroke-width: 1px; fill: none; - marker-start: url(#markerCircle); - marker-mid: url(#markerCross); - marker-end: url(#markerArrow);"/> -</svg> \ No newline at end of file diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/OpacityTest/testStrokeOpacityWithComma.svg b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/OpacityTest/testStrokeOpacityWithComma.svg deleted file mode 100644 index 42a3f17867..0000000000 --- a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/OpacityTest/testStrokeOpacityWithComma.svg +++ /dev/null @@ -1,12 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<svg xmlns="http://www.w3.org/2000/svg" width="595pt" height="842pt" version="1.1"> - <circle cx="50" cy="350" r="30" fill="salmon" stroke="black" stroke-width="15" stroke-opacity="0,5"/> - <circle cx="130" cy="350" r="30" fill="salmon" stroke="black" stroke-width="15" stroke-opacity="0"/> - <circle cx="210" cy="350" r="30" fill="salmon" stroke="black" stroke-width="15" stroke-opacity=".25"/> - <circle cx="290" cy="450" r="30" fill="salmon" stroke="black" stroke-width="15" stroke-opacity="0,25"/> - <circle cx="370" cy="450" r="30" fill="salmon" stroke="black" stroke-width="15" stroke-opacity="0.5"/> - <circle cx="450" cy="450" r="30" fill="salmon" stroke="black" stroke-width="15" stroke-opacity="1"/> - <circle cx="50" cy="550" r="30" fill="salmon" stroke="black" stroke-width="15" stroke-opacity="-1"/> - <circle cx="130" cy="550" r="30" fill="salmon" stroke="black" stroke-width="15" stroke-opacity="100"/> - <circle cx="210" cy="550" r="30" fill="salmon" stroke="black" stroke-width="15" stroke-opacity="0.276"/> -</svg> diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/PathSvgNodeRendererTest/CurveToTest1.svg b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/PathSvgNodeRendererTest/CurveToTest1.svg deleted file mode 100644 index 2484cbd5af..0000000000 --- a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/PathSvgNodeRendererTest/CurveToTest1.svg +++ /dev/null @@ -1,8 +0,0 @@ -<?xml version="1.0" standalone="no"?> -<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" - "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> -<svg width="4cm" height="4cm" viewBox="0 0 400 400" - xmlns="http://www.w3.org/2000/svg" version="1.1"> - <path d="M100 200 C100 300 250 300 250 200 S400 100 400 200 z" /> -</svg> - diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/PathSvgNodeRendererTest/cmp_eofillUnsuportedPathTest.pdf b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/PathSvgNodeRendererTest/cmp_eofillUnsuportedPathTest.pdf deleted file mode 100644 index d3339fd3d1..0000000000 Binary files a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/PathSvgNodeRendererTest/cmp_eofillUnsuportedPathTest.pdf and /dev/null differ diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/PathSvgNodeRendererTest/cmp_pathZOperatorTest01.pdf b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/PathSvgNodeRendererTest/cmp_pathZOperatorTest01.pdf deleted file mode 100644 index af2ba45dd1..0000000000 Binary files a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/PathSvgNodeRendererTest/cmp_pathZOperatorTest01.pdf and /dev/null differ diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/PathSvgNodeRendererTest/cmp_pathZOperatorTest03.pdf b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/PathSvgNodeRendererTest/cmp_pathZOperatorTest03.pdf deleted file mode 100644 index f1ae897843..0000000000 Binary files a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/PathSvgNodeRendererTest/cmp_pathZOperatorTest03.pdf and /dev/null differ diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/PathSvgNodeRendererTest/pathMultipleSuccessiveVOperatorsTest.svg b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/PathSvgNodeRendererTest/pathMultipleSuccessiveVOperatorsTest.svg deleted file mode 100644 index 6f1d28404f..0000000000 --- a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/PathSvgNodeRendererTest/pathMultipleSuccessiveVOperatorsTest.svg +++ /dev/null @@ -1,9 +0,0 @@ -<?xml version="1.0" standalone="no"?> -<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" - "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> -<svg width="5cm" height="4cm" viewBox="0 0 700 700" - xmlns="http://www.w3.org/2000/svg" version="1.1"> - - <path d="M 100 100 L 200 100 V 600 V 300 V 200 V 0 z" stroke-width="7" fill="red" stroke="black" /> - -</svg> \ No newline at end of file diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/PathSvgNodeRendererTest/simple.svg b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/PathSvgNodeRendererTest/simple.svg deleted file mode 100644 index 74dea5734d..0000000000 --- a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/PathSvgNodeRendererTest/simple.svg +++ /dev/null @@ -1,5 +0,0 @@ -<svg version="1.1" - baseProfile="full" - width="250" height="250" - xmlns="http://www.w3.org/2000/svg"> -</svg> \ No newline at end of file diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/PatternTest/cmp_patternInsideOtherOne.pdf b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/PatternTest/cmp_patternInsideOtherOne.pdf deleted file mode 100644 index 9e0c350fdb..0000000000 Binary files a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/PatternTest/cmp_patternInsideOtherOne.pdf and /dev/null differ diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/PatternTest/cmp_widthHeighXYNoMeasureUnit.pdf b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/PatternTest/cmp_widthHeighXYNoMeasureUnit.pdf deleted file mode 100644 index f90bd2052c..0000000000 Binary files a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/PatternTest/cmp_widthHeighXYNoMeasureUnit.pdf and /dev/null differ diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/PreserveAspectRatioSvgNodeRendererIntegrationTest/ITSC-Logo-Horizontal-PMS-72dpi-compressor.png b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/PreserveAspectRatioSvgNodeRendererIntegrationTest/ITSC-Logo-Horizontal-PMS-72dpi-compressor.png deleted file mode 100644 index 8dd982690b..0000000000 Binary files a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/PreserveAspectRatioSvgNodeRendererIntegrationTest/ITSC-Logo-Horizontal-PMS-72dpi-compressor.png and /dev/null differ diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/RectangleSvgNodeRendererTest/rectangleTesting.svg b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/RectangleSvgNodeRendererTest/rectangleTesting.svg deleted file mode 100644 index 0217924bd6..0000000000 --- a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/RectangleSvgNodeRendererTest/rectangleTesting.svg +++ /dev/null @@ -1,9 +0,0 @@ -<?xml version="1.0" standalone="no"?> -<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width='800' height='800'> - <rect x='0' y='0' width='800' height='800' stroke= 'red' fill='white'/> - <line x1='0' y1='0' x2='100' y2='100' stroke-width='5' stroke='black' /> - <line x1='100' y1='100' x2='200' y2='100' stroke-width='5' stroke='black' /> - <line x1='100' y1='100' x2='100' y2='200' stroke-width='5' stroke='black' /> - <rect x='100' y='100' width='80' height='80' rx='50' ry ='-10' - stroke='green' fill ='cyan'/> -</svg> \ No newline at end of file diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/RootSvgNodeRendererTest/cmp_viewbox_scaling_DoNotPreserveAspectRatio_all.pdf b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/RootSvgNodeRendererTest/cmp_viewbox_scaling_DoNotPreserveAspectRatio_all.pdf deleted file mode 100644 index 55fa76ab34..0000000000 Binary files a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/RootSvgNodeRendererTest/cmp_viewbox_scaling_DoNotPreserveAspectRatio_all.pdf and /dev/null differ diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/RootSvgNodeRendererTest/svg/absentEverything.svg b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/RootSvgNodeRendererTest/svg/absentEverything.svg deleted file mode 100644 index 3735aec84c..0000000000 --- a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/RootSvgNodeRendererTest/svg/absentEverything.svg +++ /dev/null @@ -1,5 +0,0 @@ -<svg version="1.1" baseProfile="full" xmlns="http://www.w3.org/2000/svg" > - <rect width="600px" height="300px" fill="green" color="green"></rect> - <rect width="300px" height="150px" fill="blue" color="green"></rect> - <circle cx="150px" cy="75px" r="75px" color="red"></circle> -</svg> \ No newline at end of file diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/RootSvgNodeRendererTest/svg/absentXY.svg b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/RootSvgNodeRendererTest/svg/absentXY.svg deleted file mode 100644 index 1be98d94a4..0000000000 --- a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/RootSvgNodeRendererTest/svg/absentXY.svg +++ /dev/null @@ -1,2 +0,0 @@ -<svg version="1.1" baseProfile="full" width="250" height="250" xmlns="http://www.w3.org/2000/svg"> -</svg> \ No newline at end of file diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/RootSvgNodeRendererTest/svg/cmp_absentEverything.pdf b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/RootSvgNodeRendererTest/svg/cmp_absentEverything.pdf deleted file mode 100644 index 8e2476480c..0000000000 Binary files a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/RootSvgNodeRendererTest/svg/cmp_absentEverything.pdf and /dev/null differ diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/RootSvgNodeRendererTest/svg/cmp_invalidWidth.pdf b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/RootSvgNodeRendererTest/svg/cmp_invalidWidth.pdf deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/RootSvgNodeRendererTest/viewbox/cmp_viewbox_100.pdf b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/RootSvgNodeRendererTest/viewbox/cmp_viewbox_100.pdf deleted file mode 100644 index ba49522be1..0000000000 Binary files a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/RootSvgNodeRendererTest/viewbox/cmp_viewbox_100.pdf and /dev/null differ diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/RootSvgNodeRendererTest/viewbox/cmp_viewbox_400.pdf b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/RootSvgNodeRendererTest/viewbox/cmp_viewbox_400.pdf deleted file mode 100644 index 35df52551d..0000000000 Binary files a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/RootSvgNodeRendererTest/viewbox/cmp_viewbox_400.pdf and /dev/null differ diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/RootSvgNodeRendererTest/viewbox/cmp_viewbox_50.pdf b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/RootSvgNodeRendererTest/viewbox/cmp_viewbox_50.pdf deleted file mode 100644 index 0b5383ef4c..0000000000 Binary files a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/RootSvgNodeRendererTest/viewbox/cmp_viewbox_50.pdf and /dev/null differ diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/SymbolTest/cmp_interactionOfCoordinatesUsingSymbolTag.pdf b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/SymbolTest/cmp_interactionOfCoordinatesUsingSymbolTag.pdf deleted file mode 100644 index 1ac038f72a..0000000000 Binary files a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/SymbolTest/cmp_interactionOfCoordinatesUsingSymbolTag.pdf and /dev/null differ diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/SymbolTest/cmp_widthHeightAttrTest.pdf b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/SymbolTest/cmp_widthHeightAttrTest.pdf deleted file mode 100644 index 569c39c84e..0000000000 Binary files a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/SymbolTest/cmp_widthHeightAttrTest.pdf and /dev/null differ diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/SymbolTest/cmp_xYInUseTest.pdf b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/SymbolTest/cmp_xYInUseTest.pdf deleted file mode 100644 index 38bdfcaba0..0000000000 Binary files a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/SymbolTest/cmp_xYInUseTest.pdf and /dev/null differ diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/cmp_noXNoY.pdf b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/cmp_noXNoY.pdf new file mode 100644 index 0000000000..43cd7c134b Binary files /dev/null and b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/cmp_noXNoY.pdf differ diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/cmp_simpleNestedTspan.pdf b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/cmp_simpleNestedTspan.pdf index 728e35402c..372c8e819e 100644 Binary files a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/cmp_simpleNestedTspan.pdf and b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/cmp_simpleNestedTspan.pdf differ diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/cmp_textspan-relativeMove-XandY.pdf b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/cmp_textspan-relativeMove-XandY.pdf index cf55eb70d0..0b86e313b5 100644 Binary files a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/cmp_textspan-relativeMove-XandY.pdf and b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/cmp_textspan-relativeMove-XandY.pdf differ diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/cmp_textspan-relativeMove-negativeX.pdf b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/cmp_textspan-relativeMove-negativeX.pdf index 3fa336afc9..63e3ecb6bc 100644 Binary files a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/cmp_textspan-relativeMove-negativeX.pdf and b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/cmp_textspan-relativeMove-negativeX.pdf differ diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/cmp_textspan-relativeMove-negativeY.pdf b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/cmp_textspan-relativeMove-negativeY.pdf index c5110239d9..31cff5ad72 100644 Binary files a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/cmp_textspan-relativeMove-negativeY.pdf and b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/cmp_textspan-relativeMove-negativeY.pdf differ diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/cmp_textspan-relativeMove-positiveX.pdf b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/cmp_textspan-relativeMove-positiveX.pdf index 6e57b6a0a5..599032a8d6 100644 Binary files a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/cmp_textspan-relativeMove-positiveX.pdf and b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/cmp_textspan-relativeMove-positiveX.pdf differ diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/cmp_textspan-relativeMove-positiveY.pdf b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/cmp_textspan-relativeMove-positiveY.pdf index 966ae9041b..5464920f8e 100644 Binary files a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/cmp_textspan-relativeMove-positiveY.pdf and b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/cmp_textspan-relativeMove-positiveY.pdf differ diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/cmp_textspan-relativeMove-zeroX.pdf b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/cmp_textspan-relativeMove-zeroX.pdf index f42fec5336..c625e22eb8 100644 Binary files a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/cmp_textspan-relativeMove-zeroX.pdf and b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/cmp_textspan-relativeMove-zeroX.pdf differ diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/cmp_textspan-relativeMove-zeroY.pdf b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/cmp_textspan-relativeMove-zeroY.pdf index dafc4b209e..aafdf7a75e 100644 Binary files a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/cmp_textspan-relativeMove-zeroY.pdf and b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/cmp_textspan-relativeMove-zeroY.pdf differ diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/cmp_textspan-whitespace.pdf b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/cmp_textspan-whitespace.pdf index 2a0e17ab75..b84fec838b 100644 Binary files a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/cmp_textspan-whitespace.pdf and b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/cmp_textspan-whitespace.pdf differ diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/cmp_tspanBasicExample.pdf b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/cmp_tspanBasicExample.pdf index 316e85de0d..d52f7006f8 100644 Binary files a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/cmp_tspanBasicExample.pdf and b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/cmp_tspanBasicExample.pdf differ diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/cmp_tspanNestedExample.pdf b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/cmp_tspanNestedExample.pdf index 2c4de10513..5f5ae59a31 100644 Binary files a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/cmp_tspanNestedExample.pdf and b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/cmp_tspanNestedExample.pdf differ diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/cmp_tspanNestedRelativeOffsets.pdf b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/cmp_tspanNestedRelativeOffsets.pdf index 1c197f79fa..2688f55896 100644 Binary files a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/cmp_tspanNestedRelativeOffsets.pdf and b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/cmp_tspanNestedRelativeOffsets.pdf differ diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/cmp_xWithoutY.pdf b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/cmp_xWithoutY.pdf new file mode 100644 index 0000000000..32a01f48bf Binary files /dev/null and b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/cmp_xWithoutY.pdf differ diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/cmp_yWithoutX.pdf b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/cmp_yWithoutX.pdf new file mode 100644 index 0000000000..39e3ef8c19 Binary files /dev/null and b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/cmp_yWithoutX.pdf differ diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/noXNoY.svg b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/noXNoY.svg new file mode 100644 index 0000000000..edf2d126d2 --- /dev/null +++ b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/noXNoY.svg @@ -0,0 +1,7 @@ +<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> +<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"> + <text> + <tspan>Line1 </tspan> + <tspan dx="25" dy="14" fill="red">Line2</tspan> + </text> +</svg> diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/xWithoutY.svg b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/xWithoutY.svg new file mode 100644 index 0000000000..d7d851f750 --- /dev/null +++ b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/xWithoutY.svg @@ -0,0 +1,11 @@ +<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> +<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"> + <text x="5" y="40"> + <tspan x="5" y="60">Line1 </tspan> + <tspan x="5" dy="14" fill="red">Line2 </tspan> + </text> + <text x="55" y="60"> + <tspan x="55" y="60">Line1 </tspan> + <tspan x="55" dy="14" y="60" fill="red">Line2 </tspan> + </text> +</svg> diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/yWithoutX.svg b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/yWithoutX.svg new file mode 100644 index 0000000000..3e196d15a0 --- /dev/null +++ b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TSpanNodeRendererIntegrationTest/yWithoutX.svg @@ -0,0 +1,7 @@ +<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> +<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"> + <text x="5" y="60"> + <tspan x="15" y="60">Line1</tspan> + <tspan y="60" dy="14" fill="red">Line2</tspan> + </text> +</svg> diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TextSvgBranchRendererIntegrationTest/cmp_tspanWithOneAbsoluteCoordinateTest.pdf b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TextSvgBranchRendererIntegrationTest/cmp_tspanWithOneAbsoluteCoordinateTest.pdf index bdd3417fee..bbf927bea2 100644 Binary files a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TextSvgBranchRendererIntegrationTest/cmp_tspanWithOneAbsoluteCoordinateTest.pdf and b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/TextSvgBranchRendererIntegrationTest/cmp_tspanWithOneAbsoluteCoordinateTest.pdf differ diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/gunit/cmp_test_001.pdf b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/gunit/cmp_test_001.pdf deleted file mode 100644 index 331c69e31f..0000000000 Binary files a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/gunit/cmp_test_001.pdf and /dev/null differ diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/gunit/cmp_test_002.pdf b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/gunit/cmp_test_002.pdf deleted file mode 100644 index 473d2bc561..0000000000 Binary files a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/gunit/cmp_test_002.pdf and /dev/null differ diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/gunit/cmp_test_003.pdf b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/gunit/cmp_test_003.pdf deleted file mode 100644 index ecec412586..0000000000 Binary files a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/gunit/cmp_test_003.pdf and /dev/null differ diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/gunit/cmp_test_004.pdf b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/gunit/cmp_test_004.pdf deleted file mode 100644 index e60da6f349..0000000000 Binary files a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/gunit/cmp_test_004.pdf and /dev/null differ diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/gunit/cmp_test_005.pdf b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/gunit/cmp_test_005.pdf deleted file mode 100644 index 50f4f04a7c..0000000000 Binary files a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/gunit/cmp_test_005.pdf and /dev/null differ diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/gunit/test_001.svg b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/gunit/test_001.svg deleted file mode 100644 index 4d1a3c20a8..0000000000 --- a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/gunit/test_001.svg +++ /dev/null @@ -1,1026 +0,0 @@ -<svg xmlns="http://www.w3.org/2000/svg" width="400" height="400" version="1.1" baseProfile="full"> - <polygon points="256,95 263,95 268,96 268,104 263,109 261,108 259,106 257,103" style="fill: rgb(11,11,11)" /> - <polygon points="39,223 40,213 45,211 47,211 48,212 54,220 54,222 50,226 49,226 40,225" style="fill: rgb(207,207,207)" /> - <polygon points="292,224 293,222 296,221 303,220 311,222 303,229 300,230 299,230 298,230 296,230" style="fill: rgb(142,108,106)" /> - <polygon points="20,183 20,175 20,182 20,185 20,177 20,184 20,176 20,187 20,179 20,186 20,178 20,181 20,180" style="fill: rgb(207,207,207)" /> - <polygon points="140,7 140,6 140,5 140,2 141,1 145,0 147,0 150,2 150,5 146,9 144,10 141,8" style="fill: rgb(215,217,216)" /> - <polygon points="137,163 138,158 140,157 141,163 140,167 139,168" style="fill: rgb(68,83,90)" /> - <polygon points="20,102 20,101 22,99 23,99 22,108 21,108 20,108" style="fill: rgb(229,235,235)" /> - <polygon points="282,376 283,377 284,378 285,379 286,380 287,381 287,382 285,383" style="fill: rgb(46,48,47)" /> - <polygon points="252,304 253,304 254,304 255,304 268,309 279,314 276,315 275,315 267,313 265,312 253,305" style="fill: rgb(126,89,83)" /> - <polygon points="179,134 179,133 181,134 183,138 183,140 183,141 179,136" style="fill: rgb(31,26,23)" /> - <polygon points="49,152 50,154 51,158 51,163 49,153" style="fill: rgb(225,227,224)" /> - <polygon points="23,48 23,47 23,46 23,45 25,21 26,15 29,12 32,13 32,20 32,21 32,22 32,23 32,62 32,63 32,64 32,65 32,66 30,90 28,106 26,108 25,98 23,55" style="fill: rgb(185,189,190)" /> - <polygon points="268,40 280,37 281,37 282,37 279,42 277,44 273,45 272,44" style="fill: rgb(157,161,164)" /> - <polygon points="375,304 380,303 381,303 382,303 383,303 384,303 385,303 383,304 380,305" style="fill: rgb(48,32,32)" /> - <polygon points="64,127 64,119 65,119 66,119 67,120 67,122 67,123 66,126 65,128" style="fill: rgb(225,227,224)" /> - <polygon points="84,251 84,250 87,252 87,256 84,253 84,252" style="fill: rgb(157,161,164)" /> - <polygon points="321,250 326,242 328,241 329,241 332,241 354,248 354,249 354,250 350,255 349,255 348,255 347,255 334,254" style="fill: rgb(157,161,164)" /> - <polygon points="333,150 333,149 333,146 333,145 333,142 333,141 333,140 333,139 333,134 333,133 333,132 336,131 336,150 336,152 336,157 335,159 333,155" style="fill: rgb(185,189,190)" /> - <polygon points="176,71 208,48 209,48 233,52 260,67 261,68 272,88 273,104 273,106 273,107 273,110 273,111 263,113 178,84 176,73" style="fill: rgb(11,11,11)" /> - <polygon points="342,12 345,6 348,2 352,0 357,0 358,0 360,0 361,0 361,1" style="fill: rgb(207,207,207)" /> - <polygon points="387,235 387,232 393,234 387,240 387,232 393,234 387,240 387,232 393,234 387,240 387,232 393,234 387,240 387,232 393,234 387,240 387,232 393,234" style="fill: rgb(157,129,125)" /> - <polygon points="54,137 54,136 55,133 56,138 57,143 58,148 58,155 55,143 54,138" style="fill: rgb(157,161,164)" /> - <polygon points="233,173 236,171 238,170 241,171 249,175 240,176 234,176 233,174" style="fill: rgb(31,26,23)" /> - <polygon points="108,126 109,125 112,124 113,124 114,124 115,125 114,127 113,128 112,128" style="fill: rgb(46,48,47)" /> - <polygon points="242,399 251,384 254,380 256,396 256,397 256,398 256,399 248,399 243,398 251,384 254,380 256,396 256,397 256,398 256,399 248,399 243,398 251,384 254,380 256,396 256,397 256,398 256,399 248,399 243,398 251,384 254,380 256,396 256,397 256,398 256,399 248,399 243,398 251,384 254,380 256,396 256,397 256,398 256,399 248,399 243,398 251,384 254,380 256,396 256,397 256,398 256,399 248,399 243,398 251,384 254,380 256,396 256,397 256,398 256,399 248,399 243,398 251,384 254,380 256,396 256,397 256,398 256,399 248,399 243,398 251,384 254,380 256,396 256,397 256,398 256,399 248,399 243,398 251,384 254,380 256,396 256,397 256,398 256,399 248,399 243,398 251,384 254,380 256,396 256,397 256,398 256,399 248,399 243,398 251,384 254,380 256,396 256,397 256,398 256,399 248,399 243,398 251,384 254,380 256,396 256,397 256,398 256,399 248,399 243,398 251,384 254,380 256,396 256,397 256,398 256,399 248,399 243,398 251,384 254,380 256,396 256,397 256,398 256,399 248,399 243,398 251,384 254,380 256,396 256,397 256,398 256,399 248,399 243,398 251,384 254,380 256,396 256,397 256,398 256,399 248,399 243,398 251,384 254,380 256,396 256,397" style="fill: rgb(46,48,47)" /> - <polygon points="36,168 38,162 41,173 41,174 40,176 37,174 36,169" style="fill: rgb(227,233,231)" /> - <polygon points="7,18 7,16 9,3 10,0 11,0 12,0 13,0 17,16 18,31 18,39 16,39 7,34" style="fill: rgb(229,235,235)" /> - <polygon points="240,157 241,156 243,154 263,140 264,140 273,142 276,146 276,147 276,148 275,151 274,153 271,157 270,158 269,158 245,158 244,158 243,158" style="fill: rgb(31,26,23)" /> - <polygon points="387,118 391,114 394,116 393,117 390,119" style="fill: rgb(207,207,207)" /> - <polygon points="70,122 70,126 70,123 70,127 70,119 70,124 70,128 70,129 70,120 70,130 70,121 70,125 70,131" style="fill: rgb(157,161,164)" /> - <polygon points="338,118 338,117 339,116 344,115 346,115 351,115 351,116 350,119 346,122 343,122 342,122" style="fill: rgb(195,153,154)" /> - <polygon points="0,125 2,114 3,113 4,120 1,144 0,146" style="fill: rgb(243,243,243)" /> - <polygon points="87,171 87,170 89,168 95,172 99,182 96,185 87,173" style="fill: rgb(157,129,125)" /> - <polygon points="175,20 175,19 176,16 186,13 187,13 186,16 183,20 177,22 176,22" style="fill: rgb(207,207,207)" /> - <polygon points="16,122 16,120 16,118 16,117 17,117 21,118 22,130 22,158 21,156 19,146 16,128" style="fill: rgb(236,241,237)" /> - <polygon points="55,92 56,92 57,93 56,97 55,98" style="fill: rgb(207,207,207)" /> - <polygon points="138,155 139,153 142,150 140,156 139,157 138,157" style="fill: rgb(68,83,90)" /> - <polygon points="243,380 243,379 243,378 244,377 245,377 246,379 245,381 244,381" style="fill: rgb(142,108,106)" /> - <polygon points="296,81 297,82 300,85 301,89 301,90 297,90 296,86" style="fill: rgb(22,18,17)" /> - <polygon points="233,195 233,194 233,192 235,193 241,197 237,197 235,196" style="fill: rgb(14,10,9)" /> - <polygon points="229,173 229,172 229,171 229,170 229,169 229,168 237,161 243,162 248,163 255,166 259,169 260,173 258,178 253,184 247,185 246,185 239,184 236,183 234,182 233,181 232,180 231,179 230,178 229,174" style="fill: rgb(31,26,23)" /> - <polygon points="184,228 190,225 191,225 192,225 194,226 191,228 189,229 185,231" style="fill: rgb(79,45,44)" /> - <polygon points="193,399 215,366 221,360 222,360 225,361 225,362 203,394 200,398 199,399" style="fill: rgb(126,89,83)" /> - <polygon points="223,213 223,212 224,212 225,212 226,212 228,214 225,214" style="fill: rgb(48,32,32)" /> - <polygon points="280,120 280,118 281,113 282,113 289,115 289,116 288,117 283,121" style="fill: rgb(13,13,13)" /> - <polygon points="327,250 330,249 340,248 341,248 340,249 338,251 337,252 335,253 333,254 332,254 331,254" style="fill: rgb(157,161,164)" /> - <polygon points="380,98 383,98 384,98 386,98 382,102 380,104" style="fill: rgb(142,108,106)" /> - <polygon points="387,193 389,188 390,188 397,192 397,193 388,195" style="fill: rgb(142,108,106)" /> - <polygon points="194,3 194,0 199,0 202,0 203,0 203,3 197,3 195,3" style="fill: rgb(46,48,47)" /> - <polygon points="306,125 308,119 312,118 312,119 308,124 307,125" style="fill: rgb(126,89,83)" /> - <polygon points="21,167 21,166 22,173 22,175 22,177 22,179 22,181 21,174 21,169" style="fill: rgb(225,227,224)" /> - <polygon points="289,169 290,166 292,166 293,166 295,171 295,172 292,173 290,171" style="fill: rgb(185,189,190)" /> - <polygon points="256,219 257,206 258,201 260,201 260,202 260,203 260,204 260,205 259,215 258,219 256,220" style="fill: rgb(142,108,106)" /> - <polygon points="240,185 241,185 242,185 243,185 245,185 251,185 252,185 253,185 254,185 250,186 244,186" style="fill: rgb(48,32,32)" /> - <polygon points="189,112 194,108 195,108 217,122 216,131 215,131 214,131 213,131 212,131 211,131 208,130 204,128 202,127 197,123 193,118 190,114" style="fill: rgb(142,108,106)" /> - <polygon points="284,224 285,223 286,222 287,222 290,223 291,226 288,227 285,228" style="fill: rgb(142,108,106)" /> - <polygon points="0,53 0,43 1,43 2,44 3,48 3,56 3,57 3,58 3,59 3,60 3,61 3,62 2,79 1,90 0,91" style="fill: rgb(243,243,243)" /> - <polygon points="17,182 17,180 18,182 18,186 17,186" style="fill: rgb(229,235,235)" /> - <polygon points="70,208 70,201 71,200 71,208 71,209 71,210 71,211 71,212 70,214" style="fill: rgb(185,189,190)" /> - <polygon points="170,158 175,158 176,158 180,159 180,161 179,162 178,162 177,162 171,161 170,160" style="fill: rgb(142,108,106)" /> - <polygon points="298,258 298,256 298,254 299,253 305,258 303,259 300,260 299,260 298,259" style="fill: rgb(157,161,164)" /> - <polygon points="244,149 247,147 250,146 251,146 252,146 245,151" style="fill: rgb(48,32,32)" /> - <polygon points="70,69 70,67 70,54 70,53 72,53 73,62 73,69 73,70 73,83 72,84 71,80 70,70" style="fill: rgb(229,235,235)" /> - <polygon points="6,188 6,186 7,181 7,185 6,192" style="fill: rgb(225,227,224)" /> - <polygon points="124,156 125,156 129,157 132,158 134,159 135,160 136,162 127,158" style="fill: rgb(126,89,83)" /> - <polygon points="139,16 140,14 148,19 150,28 150,29 150,31" style="fill: rgb(142,108,106)" /> - <polygon points="47,154 47,153 47,152 48,152 50,160 51,166 51,167 50,170" style="fill: rgb(207,207,207)" /> - <polygon points="0,238 2,239 7,242 8,243 8,245 2,247 1,247 0,241" style="fill: rgb(157,161,164)" /> - <polygon points="14,95 14,90 14,89 15,85 17,80 17,81 17,82 17,95 17,96 16,101 15,102" style="fill: rgb(243,243,243)" /> - <polygon points="73,351 75,323 76,326 78,332 80,340 82,350 88,397 88,399 84,399 80,399 79,399 78,399 77,399 76,399 75,397" style="fill: rgb(46,48,47)" /> - <polygon points="178,276 179,275 181,274 183,273 184,274 188,279 184,279 183,279 182,279 179,279 178,278" style="fill: rgb(185,189,190)" /> - <polygon points="0,376 2,379 11,397 12,399 10,399 8,399 3,399 0,395" style="fill: rgb(12,23,29)" /> - <polygon points="209,16 211,13 213,12 214,12 218,12 216,15" style="fill: rgb(142,108,106)" /> - <polygon points="218,18 220,11 228,6 236,12 222,27" style="fill: rgb(68,83,90)" /> - <polygon points="363,103 364,96 365,96 386,99 393,104 384,147 381,155 380,155 379,155 364,146" style="fill: rgb(142,108,106)" /> - <polygon points="45,140 46,140 47,148 47,150 46,148 45,143" style="fill: rgb(207,207,207)" /> - <polygon points="284,52 284,51 285,50 321,31 327,28 340,27 343,27 355,32 354,35 346,41 307,68 306,68 302,68 301,68 285,53" style="fill: rgb(157,161,164)" /> - <polygon points="170,275 170,274 175,272 179,273 178,274 176,275 174,276 172,277 171,277 170,276" style="fill: rgb(79,45,44)" /> - <polygon points="54,84 55,70 55,74 55,78 55,81 55,85 54,85" style="fill: rgb(185,189,190)" /> - <polygon points="364,199 364,196 364,195 364,194 364,193 367,194 375,203 384,222 385,227 387,243 383,244 382,244 381,244" style="fill: rgb(68,83,90)" /> - <polygon points="317,133 317,131 318,129 322,128 327,128 327,130 326,132 318,133" style="fill: rgb(68,83,90)" /> - <polygon points="57,80 57,76 57,75 58,72 58,75 58,76 58,78" style="fill: rgb(225,227,224)" /> - <polygon points="20,71 20,70 21,62 26,63 24,97" style="fill: rgb(215,217,216)" /> - <polygon points="163,322 163,321 169,247 170,239 172,236 174,235 199,231 229,230 274,274 275,275 277,277 278,278 279,279 280,280 289,296 290,298 313,361 313,365 310,369 308,369 304,369 167,325 164,323" style="fill: rgb(157,129,125)" /> - <polygon points="168,10 169,9 170,8 173,6 184,5 185,8" style="fill: rgb(68,83,90)" /> - <polygon points="243,72 244,72 245,72 245,76 245,78 243,73" style="fill: rgb(12,10,11)" /> - <polygon points="279,46 282,44 285,47 283,48 280,48 279,47" style="fill: rgb(251,251,251)" /> - <polygon points="173,17 173,14 173,12 173,11 174,11 175,11 176,11 184,12 185,13 181,21 177,23 175,23 174,23 173,22" style="fill: rgb(207,207,207)" /> - <polygon points="168,179 169,179 170,179 171,179 172,179 173,179 174,179 175,179 176,179 177,179 178,179 179,179 180,179 181,179" style="fill: rgb(86,66,68)" /> - <polygon points="89,233 89,225 89,224 89,232 89,235 89,227 89,234 89,226 89,229 89,236 89,228 89,231 89,230" style="fill: rgb(46,48,47)" /> - <polygon points="256,48 256,47 259,46 262,47 267,49 269,51 269,52 265,60 264,60 260,58" style="fill: rgb(22,18,17)" /> - <polygon points="210,74 212,64 217,64 228,72 228,73 227,74 211,75 210,75" style="fill: rgb(14,10,9)" /> - <polygon points="380,208 382,207 383,209 382,215 381,213 380,210" style="fill: rgb(86,66,68)" /> - <polygon points="26,6 32,8 32,12 31,19 27,19 26,14" style="fill: rgb(207,207,207)" /> - <polygon points="150,178 151,178 157,180 177,188 176,189 175,190 172,190 171,190 170,190 169,190 168,190 163,189 156,185" style="fill: rgb(157,129,125)" /> - <polygon points="44,20 44,18 44,17 45,14 46,17 48,23 49,30 50,40 50,41 50,42 50,43 50,44 50,45 50,46 48,60 45,51 44,21" style="fill: rgb(225,227,224)" /> - <polygon points="149,308 163,301 179,296 189,293 189,295 187,296 156,308 152,309 151,309" style="fill: rgb(142,108,106)" /> - <polygon points="254,336 255,336 256,336 258,337 268,344 271,347 279,363 282,375 281,375 258,367" style="fill: rgb(79,45,44)" /> - <polygon points="0,186 0,182 3,181 5,181 5,183 5,184 3,192 2,196 1,198 0,198" style="fill: rgb(243,243,243)" /> - <polygon points="15,198 15,197 15,196 15,195 15,189 15,188 15,187 15,186 15,185 18,187 19,199 19,200 19,202 19,207 18,211 17,210 16,207 15,202" style="fill: rgb(227,233,231)" /> - <polygon points="226,224 229,224 233,226 237,229 238,230 239,232 239,233 237,235 236,235" style="fill: rgb(79,45,44)" /> - <polygon points="333,4 334,2 336,2 340,4 336,5 335,5" style="fill: rgb(157,161,164)" /> - <polygon points="181,191 185,187 196,182 196,183 195,186 194,188 193,189 192,190 190,191 184,191" style="fill: rgb(126,89,83)" /> - <polygon points="120,110 120,109 121,107 132,94 136,90 142,84 146,80 149,77 170,59 183,50 199,42 206,40 215,38 220,37 233,37 241,38 246,39 259,43 266,46 268,47 273,50 276,52 279,54 290,63 299,76 301,80 302,86 302,89 302,90 302,93 302,94" style="fill: rgb(12,10,11)" /> - <polygon points="280,199 280,198 285,192 286,192 287,193 289,197 289,198 281,200" style="fill: rgb(157,161,164)" /> - <polygon points="144,128 146,127 147,127 148,127 159,128 159,129 150,132 147,131 145,130" style="fill: rgb(48,32,32)" /> - <polygon points="261,73 261,72 262,72 263,72 264,72 265,72 266,72 267,72 263,75 262,75 261,74" style="fill: rgb(11,11,11)" /> - <polygon points="275,124 277,121 278,120 280,122 280,123 276,125 275,125" style="fill: rgb(22,18,17)" /> - <polygon points="80,212 81,212 82,212 83,213 84,216 83,216 81,215 80,213" style="fill: rgb(46,48,47)" /> - <polygon points="299,126 299,125 302,119 303,121 303,122 303,123 303,124 302,125" style="fill: rgb(126,89,83)" /> - <polygon points="158,160 161,158 165,158 167,159 167,160 166,161 161,162 159,162" style="fill: rgb(157,129,125)" /> - <polygon points="312,106 315,101 316,100 320,99 322,99 322,104 321,105 316,106 315,106 314,106 313,106" style="fill: rgb(185,189,190)" /> - <polygon points="196,294 198,292 202,290 203,290 205,294 203,295 202,295 201,295 200,295 199,295" style="fill: rgb(185,189,190)" /> - <polygon points="233,282 234,282 235,282 238,284 240,286 240,287 238,289 237,289 236,288 234,284" style="fill: rgb(142,108,106)" /> - <polygon points="220,66 220,64 222,64 223,65 223,68 223,70 222,71" style="fill: rgb(13,13,13)" /> - <polygon points="26,245 31,238 32,237 32,238 31,241 29,243 28,244" style="fill: rgb(207,207,207)" /> - <polygon points="273,218 275,217 285,213 288,212 296,212 296,213 294,215 293,216 292,217 282,218" style="fill: rgb(142,108,106)" /> - <polygon points="0,332 4,298 6,291 7,288 41,252 43,252 44,252 45,252 57,285 66,312 66,324 66,326 66,328 66,329 65,359 64,388 63,399 21,399 20,399 19,399 16,393 15,391 3,359 0,337" style="fill: rgb(46,48,47)" /> - <polygon points="113,202 113,201 113,199 113,198 113,197 114,196 116,196 120,209 120,210 120,218 120,219 116,227 114,229" style="fill: rgb(142,108,106)" /> - <polygon points="131,24 135,19 137,18 137,21 136,22" style="fill: rgb(86,66,68)" /> - <polygon points="278,376 279,376 281,377 283,379 284,380 285,381 286,383 284,382" style="fill: rgb(31,26,23)" /> - <polygon points="388,111 391,103 398,103 399,103 399,106 394,113" style="fill: rgb(157,161,164)" /> - <polygon points="348,200 348,199 350,198 361,199 366,205 366,207 364,216 363,220 362,223 361,224 358,224 354,223 353,222 348,201" style="fill: rgb(157,129,125)" /> - <polygon points="324,375 326,367 328,364 329,363 331,363 337,365 349,371 350,372 356,381 356,389 354,396 353,397 351,398 347,399 343,399 342,399 336,398 327,390 324,385" style="fill: rgb(157,129,125)" /> - <polygon points="81,191 81,190 81,189 81,188 81,187 82,185 84,183 86,182 89,181 82,196 81,195" style="fill: rgb(157,129,125)" /> - <polygon points="35,162 35,161 36,156 37,158 37,159 36,163" style="fill: rgb(227,233,231)" /> - <polygon points="90,237 90,236 90,225 90,224 90,223 91,223 94,231 95,236 96,256 96,257 95,256 93,250 91,242" style="fill: rgb(12,23,29)" /> - <polygon points="255,165 256,163 266,163 267,165 268,169 260,172 259,172 256,169 255,167" style="fill: rgb(22,18,17)" /> - <polygon points="163,80 165,79 169,77 172,78 173,79 174,88 174,89 172,88 164,82 163,81" style="fill: rgb(19,13,13)" /> - <polygon points="27,3 27,1 27,0 32,0 32,2 32,7 31,9 28,10 27,9" style="fill: rgb(157,161,164)" /> - <polygon points="159,25 159,23 160,22 163,24 163,26 161,27 159,28 159,23 160,22 163,24 163,26 161,27 159,28 159,23 160,22 163,24 163,26 161,27 159,28" style="fill: rgb(207,207,207)" /> - <polygon points="262,216 262,213 264,210 266,210 267,211 263,218 262,218" style="fill: rgb(243,243,243)" /> - <polygon points="152,3 154,0 156,0 159,1 160,2 154,3" style="fill: rgb(215,217,216)" /> - <polygon points="365,245 369,236 373,232 376,230 376,232 375,236 373,240 369,245 368,245" style="fill: rgb(142,108,106)" /> - <polygon points="48,231 50,230 51,230 52,230 53,230 53,231 52,232 50,232 49,232" style="fill: rgb(225,227,224)" /> - <polygon points="185,326 185,325 185,324 186,323 188,322 190,321 196,319 209,315 213,314 224,312 235,310 236,310 237,310 241,311 242,316 242,317 241,322 238,324 207,331 192,333 190,332 188,331 187,330 186,329 185,327" style="fill: rgb(195,153,154)" /> - <polygon points="376,167 379,156 386,131 389,130 397,129 399,129 399,170 388,173 386,173 385,173" style="fill: rgb(157,161,164)" /> - <polygon points="74,63 74,64 74,62 74,69 74,71 74,65 74,67 74,73 74,70 74,72 74,66 74,68" style="fill: rgb(215,217,216)" /> - <polygon points="241,125 241,124 246,121 255,129 255,130 254,130 251,130 244,128" style="fill: rgb(19,13,13)" /> - <polygon points="335,306 336,305 343,304 344,304 346,305 344,306 338,307 337,307 335,307" style="fill: rgb(86,66,68)" /> - <polygon points="303,235 307,232 309,231 310,231 310,232 310,233 310,234 310,235 310,236 310,237 310,238 310,239 304,236" style="fill: rgb(68,83,90)" /> - <polygon points="167,324 200,309 237,298 238,298 250,304 183,327 180,327 170,325" style="fill: rgb(86,66,68)" /> - <polygon points="150,159 151,156 152,156 153,156 154,156 155,156 156,156 157,156 158,156 159,156 160,156 161,156 156,160 151,161" style="fill: rgb(48,32,32)" /> - <polygon points="25,168 25,166 25,164 25,162 25,159 25,157 25,155 25,153 27,152 28,179 28,181 27,199 26,203 25,200" style="fill: rgb(185,189,190)" /> - <polygon points="344,294 363,291 364,296 364,301 345,296 344,295" style="fill: rgb(157,129,125)" /> - <polygon points="24,159 24,160 24,161 24,157 24,166 24,158 24,155 24,164 24,156 24,165 24,153 24,162 24,154 24,163" style="fill: rgb(215,217,216)" /> - <polygon points="157,329 158,327 161,326 161,329 161,330 159,332" style="fill: rgb(185,189,190)" /> - <polygon points="88,359 89,355 90,353 93,353 95,354 104,360 116,395 113,399 112,399 111,399 110,399 88,360" style="fill: rgb(68,83,90)" /> - <polygon points="176,164 185,160 189,162 189,163 181,165" style="fill: rgb(46,48,47)" /> - <polygon points="257,286 281,284 282,284 285,289 286,291 287,293 287,294 267,290 262,289 258,287" style="fill: rgb(157,129,125)" /> - <polygon points="98,178 103,169 104,169 105,170 105,173 105,181 104,186 102,187 99,181 98,179" style="fill: rgb(126,89,83)" /> - <polygon points="7,144 8,141 9,139 11,138 11,139 9,143 7,145" style="fill: rgb(236,241,237)" /> - <polygon points="124,261 124,260 124,259 125,260 128,265 127,265 125,264" style="fill: rgb(142,108,106)" /> - <polygon points="71,273 71,271 72,262 74,253 76,246 76,248 76,249 72,278 71,279" style="fill: rgb(46,48,47)" /> - <polygon points="384,306 390,305 391,305 394,306 391,307 386,308" style="fill: rgb(157,161,164)" /> - <polygon points="319,118 319,117 322,117 323,117 324,117 325,117 325,122 325,123 323,124 319,123" style="fill: rgb(142,108,106)" /> - <polygon points="15,148 15,147 15,146 15,145 15,144 17,151 16,156 15,151" style="fill: rgb(225,227,224)" /> - <polygon points="130,132 137,136 138,137 139,138 139,139 139,140 138,143 137,145 135,146 134,146 133,145 132,143 131,139 130,134" style="fill: rgb(157,161,164)" /> - <polygon points="74,0 75,0 79,0 83,0 87,0 91,0 93,0 95,0 97,0 99,0 101,0 103,0 105,0 107,0 109,0 111,0 115,0 119,0 123,0 125,0 127,0 131,0 188,19 86,159 85,159 78,156 74,14" style="fill: rgb(157,161,164)" /> - <polygon points="53,201 53,199 54,199 55,203 55,205 55,206 54,205 53,202" style="fill: rgb(227,233,231)" /> - <polygon points="392,256 392,254 392,253 393,247 394,246 396,244 397,244 399,245 399,248 395,257 393,258 392,258" style="fill: rgb(195,153,154)" /> - <polygon points="261,216 262,214 266,216 266,217 263,221 262,221 261,221" style="fill: rgb(243,243,243)" /> - <polygon points="194,84 194,83 194,80 197,80 204,83 205,90 204,91 203,91 199,91 198,91 195,86" style="fill: rgb(14,10,9)" /> - <polygon points="228,21 229,19 231,18 234,17 235,20 234,21 233,22 231,22 230,22 229,22 228,22" style="fill: rgb(157,161,164)" /> - <polygon points="208,21 208,19 209,18 211,17 213,17 214,20 212,21 209,22 208,22" style="fill: rgb(142,108,106)" /> - <polygon points="355,216 355,215 355,214 355,213 356,211 357,211 358,213 358,215 356,219 355,220" style="fill: rgb(157,129,125)" /> - <polygon points="193,6 193,5 193,4 198,7 199,8 199,9 193,10" style="fill: rgb(126,89,83)" /> - <polygon points="288,235 289,235 291,236 291,237 291,240 291,241 290,241 289,241" style="fill: rgb(126,89,83)" /> - <polygon points="204,19 210,12 214,10 216,9 218,8 225,5 228,4 228,5 225,15 224,17 222,19 207,23" style="fill: rgb(142,108,106)" /> - <polygon points="368,315 369,313 370,311 373,311 383,313 378,314 372,315 370,315 369,315" style="fill: rgb(185,189,190)" /> - <polygon points="202,134 204,132 205,132 206,132 211,134 211,135 211,137 210,137 206,136 204,135" style="fill: rgb(157,129,125)" /> - <polygon points="227,159 227,158 229,154 231,154 231,155 231,161 230,161 228,160" style="fill: rgb(31,26,23)" /> - <polygon points="184,43 184,40 185,39 186,38 189,37 190,37 195,38 195,39 185,44" style="fill: rgb(12,23,29)" /> - <polygon points="142,355 143,352 147,343 148,341 148,344 148,345 147,348 146,350 143,355 142,356" style="fill: rgb(157,161,164)" /> - <polygon points="301,210 302,205 303,205 303,207 303,208 303,209 303,210 303,211 303,212 303,213 301,211" style="fill: rgb(68,83,90)" /> - <polygon points="365,134 365,133 365,130 369,131 369,132 368,143 367,143 366,143 365,143" style="fill: rgb(157,161,164)" /> - <polygon points="2,165 4,160 5,159 5,163 3,168 2,169" style="fill: rgb(254,254,254)" /> - <polygon points="165,237 165,236 165,231 166,227 174,196 219,168 221,168 257,185 258,186 260,200 258,221 257,231 255,237 252,241 251,241 250,241 241,241 240,241 168,240" style="fill: rgb(142,108,106)" /> - <polygon points="108,120 115,109 136,87 140,83 144,79 146,77 157,67 163,62 168,58 175,53 181,49 186,46 190,44 197,41 207,37 217,35 231,35 239,35 249,37 257,39 263,41 268,43 275,47 281,51 285,54 289,58 295,64 298,68 300,71 301,73 303,77 304,80 303,84" style="fill: rgb(11,11,11)" /> - <polygon points="193,76 194,75 195,75 196,75 197,75 206,75 207,75 212,76 205,83 200,81" style="fill: rgb(13,13,13)" /> - <polygon points="365,288 366,288 396,294 397,295 398,296 399,300 399,302 399,303 394,304 386,305 385,305 384,305 366,291" style="fill: rgb(48,32,32)" /> - <polygon points="126,146 127,146 128,146 137,148 138,150 138,151 138,152 133,152 127,147" style="fill: rgb(157,129,125)" /> - <polygon points="189,264 192,260 204,249 204,250 204,251 203,253 201,255 200,256 195,260" style="fill: rgb(157,129,125)" /> - <polygon points="376,291 383,288 399,290 399,291 399,292 399,293 398,295 394,295 392,295" style="fill: rgb(86,66,68)" /> - <polygon points="97,261 97,256 97,253 98,254 99,263 99,264 98,263" style="fill: rgb(31,26,23)" /> - <polygon points="142,257 150,248 156,245 163,245 163,247 163,249 158,256 152,262 149,262 148,262" style="fill: rgb(126,89,83)" /> - <polygon points="60,33 60,30 62,29 62,31 62,33 62,37 62,38 62,39 62,40 61,40 60,40" style="fill: rgb(185,189,190)" /> - <polygon points="36,26 36,25 36,16 37,15 36,28 36,27 36,22 36,21 36,16 37,15 36,28 36,27 36,22 36,21" style="fill: rgb(229,235,235)" /> - <polygon points="0,128 0,127 1,129 1,130 1,131 1,135 0,135" style="fill: rgb(254,254,254)" /> - <polygon points="300,4 300,1 300,0 301,0 301,7 300,7" style="fill: rgb(157,161,164)" /> - <polygon points="111,140 112,137 117,127 121,123 133,116 165,100 171,97 180,104 187,111 199,126 199,127 197,132" style="fill: rgb(157,129,125)" /> - <polygon points="307,261 308,261 309,261 310,261 311,261 319,262 320,263 319,263 309,262" style="fill: rgb(86,66,68)" /> - <polygon points="101,242 101,236 101,234 101,233 102,226 103,225 104,225 105,226 107,228 117,252 117,253 116,260 115,261 114,262 111,263 110,263 109,263 106,261 104,257 103,254 102,250 101,245" style="fill: rgb(195,153,154)" /> - <polygon points="250,336 252,335 256,338 257,339 258,343 259,352 259,353 259,354 259,355 259,356 259,357 259,358 259,359 259,360 259,361 258,365" style="fill: rgb(126,89,83)" /> - <polygon points="13,56 14,47 17,41 19,48 17,55 15,57" style="fill: rgb(236,241,237)" /> - <polygon points="232,370 232,368 235,370 234,372 233,372 232,372" style="fill: rgb(48,32,32)" /> - <polygon points="129,7 134,4 138,2 142,0 143,0 144,0 145,10 131,17" style="fill: rgb(215,217,216)" /> - <polygon points="380,122 380,120 380,119 383,120 384,122 383,130 381,135 380,130" style="fill: rgb(126,89,83)" /> - <polygon points="190,23 193,21 196,22 199,24 198,25 196,25 192,24" style="fill: rgb(142,108,106)" /> - <polygon points="25,12 25,11 25,10 25,9 25,16 25,15 25,14 25,13 25,19 25,20 25,17 25,18 25,8 25,7" style="fill: rgb(215,217,216)" /> - <polygon points="227,170 227,169 227,168 229,164 230,166 229,177 228,176" style="fill: rgb(86,66,68)" /> - <polygon points="33,26 33,25 33,24 33,23 33,22 33,21 33,20 33,19 33,18 33,17 33,16 33,15 33,14 33,13 33,12 33,11 33,10" style="fill: rgb(225,227,224)" /> - <polygon points="99,147 101,142 102,141 103,141 108,142 108,147 107,149 106,149 105,149 104,149 103,149" style="fill: rgb(157,161,164)" /> - <polygon points="390,195 396,194 399,195 399,201 398,201 397,201 396,201 390,196" style="fill: rgb(157,129,125)" /> - <polygon points="92,138 95,102 96,97 97,93 105,63 110,55 111,54 112,53 159,30 175,25 181,24 203,23 204,23 216,35 94,139 93,139" style="fill: rgb(68,83,90)" /> - <polygon points="195,153 199,152 200,152 203,154 204,155 204,156 198,155 195,154" style="fill: rgb(31,26,23)" /> - <polygon points="65,162 67,152 70,152 70,157 70,158 70,159 70,160 70,166 70,167 69,169" style="fill: rgb(225,227,224)" /> - <polygon points="347,165 347,164 350,155 352,154 354,153 357,152 359,154 360,156 360,157 359,158" style="fill: rgb(207,207,207)" /> - <polygon points="195,20 198,20 204,21 205,22 198,24 197,23" style="fill: rgb(157,129,125)" /> - <polygon points="288,194 290,193 291,194 292,195 293,201 293,202 293,203 292,203 291,203 290,203 288,195" style="fill: rgb(185,189,190)" /> - <polygon points="349,243 351,241 352,240 354,239 356,241 356,242 355,244 354,245" style="fill: rgb(86,66,68)" /> - <polygon points="160,125 161,124 165,123 166,123 167,123 171,124 161,125" style="fill: rgb(126,89,83)" /> - <polygon points="117,42 117,41 117,40 118,37 131,32 132,40 131,41 126,44 119,48 117,48" style="fill: rgb(185,189,190)" /> - <polygon points="208,124 211,124 219,127 227,131 226,133 224,135 220,137 216,138 215,138 214,138" style="fill: rgb(126,89,83)" /> - <polygon points="90,194 90,193 90,192 91,190 92,188 95,187 97,204 97,205 96,205 95,205 94,204 93,203 91,200 90,198 90,197" style="fill: rgb(195,153,154)" /> - <polygon points="346,292 346,290 353,289 354,289 355,289 356,289 357,289 358,289 361,290 361,291 348,292 347,292" style="fill: rgb(46,48,47)" /> - <polygon points="14,132 14,131 14,130 14,128 15,123 18,144 18,149 14,138" style="fill: rgb(225,227,224)" /> - <polygon points="17,99 18,78 23,98 20,106 17,101" style="fill: rgb(227,233,231)" /> - <polygon points="115,137 119,130 120,129 124,126 126,125 129,124 130,124 131,124 132,124 142,126" style="fill: rgb(195,153,154)" /> - <polygon points="169,134 170,132 172,131 173,131 174,131 175,131 175,132 175,133 170,135" style="fill: rgb(31,26,23)" /> - <polygon points="184,71 184,69 187,67 187,71 186,71 185,71" style="fill: rgb(16,16,16)" /> - <polygon points="399,143 399,135 399,144 399,136 399,149 399,141 399,133 399,150 399,142 399,134 399,147 399,139 399,148 399,140 399,145 399,137 399,146 399,138" style="fill: rgb(185,189,190)" /> - <polygon points="35,46 36,37 36,44 36,46 35,47" style="fill: rgb(229,235,235)" /> - <polygon points="58,98 61,95 62,95 64,96 64,98 63,99 61,100" style="fill: rgb(251,251,251)" /> - <polygon points="13,197 13,195 14,164 15,167 21,203 21,216 21,218 19,235 16,241 15,241 13,211" style="fill: rgb(225,227,224)" /> - <polygon points="89,187 89,186 89,185 89,184 90,182 93,180 94,180 95,182 95,183 91,187" style="fill: rgb(126,89,83)" /> - <polygon points="194,8 194,7 195,6 198,6 203,7 201,8 200,8" style="fill: rgb(68,83,90)" /> - <polygon points="160,181 203,167 204,167 206,168 195,183 194,184 180,191 176,191 175,191 174,191 173,191 166,188 160,182" style="fill: rgb(126,89,83)" /> - <polygon points="60,151 60,150 60,149 61,152 63,159 65,166 65,167 64,167 62,165 61,164" style="fill: rgb(207,207,207)" /> - <polygon points="364,260 364,259 365,255 379,258 380,260 380,261 378,263 376,263 364,261" style="fill: rgb(142,108,106)" /> - <polygon points="374,311 378,310 397,307 399,307 399,308 397,309 394,310 391,311 378,313 377,313 376,313 375,313" style="fill: rgb(207,207,207)" /> - <polygon points="150,295 150,294 151,293 152,292 163,284 166,282 164,286 163,287 162,288 159,291 154,294 152,295 151,295" style="fill: rgb(185,189,190)" /> - <polygon points="310,125 311,121 313,118 314,117 315,117 321,123 322,124 318,125 316,125 313,125" style="fill: rgb(157,129,125)" /> - <polygon points="0,97 13,97 13,99 13,101 13,102 11,104 8,105 3,105 0,98" style="fill: rgb(229,235,235)" /> - <polygon points="68,62 68,60 68,59 69,53 69,55 69,58 69,59 68,68" style="fill: rgb(185,189,190)" /> - <polygon points="208,154 209,152 210,151 211,151 213,151 213,152 210,155 209,155" style="fill: rgb(142,108,106)" /> - <polygon points="233,148 243,146 244,146 243,147 240,149 236,151 233,149" style="fill: rgb(19,13,13)" /> - <polygon points="11,212 11,211 11,208 13,165 15,212 15,231 14,229 11,213" style="fill: rgb(215,217,216)" /> - <polygon points="72,1 72,4 72,11 72,3 72,12 72,9 72,10 72,0 72,2 72,8 72,7 72,6 72,5" style="fill: rgb(215,217,216)" /> - <polygon points="372,144 372,143 374,121 375,120 380,115 384,115 386,116 386,120 383,143 382,146 378,150 377,150 376,149" style="fill: rgb(142,108,106)" /> - <polygon points="36,67 36,60 39,12 40,47 39,55 36,69" style="fill: rgb(215,217,216)" /> - <polygon points="218,33 218,32 220,31 225,29 225,31 219,33" style="fill: rgb(142,108,106)" /> - <polygon points="198,21 199,19 207,16 207,17 206,23 204,25 203,26" style="fill: rgb(157,129,125)" /> - <polygon points="106,174 108,166 112,158 113,157 114,157 118,158 130,166 166,198 169,217 168,220 162,237 134,228 128,226 127,225 126,223 123,216" style="fill: rgb(195,153,154)" /> - <polygon points="0,219 0,216 9,188 10,185 10,187 10,189 9,231 8,231 3,230 0,227" style="fill: rgb(207,207,207)" /> - <polygon points="240,238 243,229 244,231 244,238 243,239 242,239" style="fill: rgb(126,89,83)" /> - <polygon points="307,130 310,130 310,131 310,132 309,137 308,137" style="fill: rgb(46,48,47)" /> - <polygon points="223,135 224,126 227,126 229,127 234,130 236,132 234,133 224,136 223,136" style="fill: rgb(86,66,68)" /> - <polygon points="249,163 252,161 253,161 253,165 253,168 251,168" style="fill: rgb(31,26,23)" /> - <polygon points="272,215 272,214 273,214 274,214 275,214 276,214 278,214 279,214 280,214 281,214 282,214 283,214 279,216 274,217 273,217 272,217" style="fill: rgb(157,129,125)" /> - <polygon points="67,264 71,236 82,228 82,229 69,294 67,269" style="fill: rgb(12,23,29)" /> - <polygon points="329,295 336,291 341,291 342,291 343,292 339,296 332,301" style="fill: rgb(46,48,47)" /> - <polygon points="285,182 287,182 289,182 293,190 293,191 293,193 293,194 292,193 291,192 285,183" style="fill: rgb(157,129,125)" /> - <polygon points="204,230 207,230 224,230 225,230 226,230 227,230 224,231 216,231 208,231 205,231 204,231" style="fill: rgb(157,129,125)" /> - <polygon points="110,143 112,142 122,137 123,137 125,139 124,140 119,144 115,144" style="fill: rgb(185,189,190)" /> - <polygon points="395,241 395,239 396,238 398,236 399,237 399,244 398,244 396,242" style="fill: rgb(185,189,190)" /> - <polygon points="299,308 301,307 303,310 303,313 301,311" style="fill: rgb(46,48,47)" /> - <polygon points="187,107 190,102 192,100 197,102 218,117 223,121 224,122 219,122 218,122 196,120 193,117 192,116 189,111" style="fill: rgb(48,32,32)" /> - <polygon points="162,118 168,116 172,115 175,115 177,117 177,118 175,121 174,121 169,121 168,121 166,120" style="fill: rgb(157,129,125)" /> - <polygon points="366,186 367,186 368,186 369,186 370,186 371,186 374,187 371,187 369,187 368,187 367,187" style="fill: rgb(86,66,68)" /> - <polygon points="3,159 3,158 4,154 7,146 8,144 9,144 10,149 10,150 10,152 10,153 9,155" style="fill: rgb(254,254,254)" /> - <polygon points="230,380 231,378 233,378 233,382 232,382 231,382" style="fill: rgb(48,32,32)" /> - <polygon points="271,211 272,211 275,211 276,211 277,211 278,211 279,211 282,212 279,213 274,213" style="fill: rgb(157,161,164)" /> - <polygon points="322,170 322,167 322,166 322,163 322,162 322,158 323,157 333,163 333,175 324,177 323,176" style="fill: rgb(185,189,190)" /> - <polygon points="270,118 280,113 281,114 281,116 279,119 274,124 270,119" style="fill: rgb(13,13,13)" /> - <polygon points="73,159 75,144 76,158 75,159" style="fill: rgb(225,227,224)" /> - <polygon points="108,198 109,198 110,201 111,204 110,205 108,199" style="fill: rgb(86,66,68)" /> - <polygon points="193,225 196,224 225,224 233,227 237,231 238,232 238,233 237,234 236,234 235,234" style="fill: rgb(142,108,106)" /> - <polygon points="260,347 260,345 261,344 265,342 266,343 267,345 267,346 266,349 264,351 263,352 262,353 261,353 260,349" style="fill: rgb(48,32,32)" /> - <polygon points="59,37 59,39 59,33 59,35 59,27 59,28 59,26 59,31 59,32 59,29 59,30 59,38 59,34 59,36" style="fill: rgb(207,207,207)" /> - <polygon points="179,303 181,301 184,299 186,301 186,303 182,304" style="fill: rgb(195,153,154)" /> - <polygon points="249,251 250,248 254,245 255,246 255,248 252,257 251,256 250,254 249,252" style="fill: rgb(48,32,32)" /> - <polygon points="336,204 336,203 339,203 339,207 339,210 339,211 338,209" style="fill: rgb(86,66,68)" /> - <polygon points="340,321 344,320 349,319 350,319 351,319 352,319 353,319 350,345 346,338 343,331 342,328" style="fill: rgb(157,129,125)" /> - <polygon points="68,58 68,54 68,50 68,46 68,42 68,38 68,34 68,32 68,57 68,30 68,53 68,28 68,49 68,45 68,41 68,37 68,33 68,56 68,52 68,48 68,44 68,40 68,36 68,31 68,29 68,55 68,51 68,47 68,43 68,39 68,35" style="fill: rgb(157,161,164)" /> - <polygon points="8,390 9,390 12,392 13,397 13,398 13,399 12,398 9,393 8,391" style="fill: rgb(46,48,47)" /> - <polygon points="50,147 50,145 51,146 52,149 52,151 50,149" style="fill: rgb(243,243,243)" /> - <polygon points="76,190 76,188 77,188 82,201 83,204 83,205 78,201 76,192" style="fill: rgb(157,129,125)" /> - <polygon points="136,334 137,331 138,331 141,333 141,334 141,335 141,336 141,337 141,338" style="fill: rgb(68,83,90)" /> - <polygon points="73,44 73,42 73,46 73,36 73,34 73,40 73,38 73,32 73,43 73,41 73,45 73,35 73,33 73,39 73,37" style="fill: rgb(215,217,216)" /> - <polygon points="291,64 292,65 298,72 299,75 297,73 293,68 291,65" style="fill: rgb(31,26,23)" /> - <polygon points="210,6 210,5 210,4 211,4 214,7 215,9 210,9" style="fill: rgb(142,108,106)" /> - <polygon points="56,82 58,81 58,84 58,86 56,85" style="fill: rgb(207,207,207)" /> - <polygon points="167,71 167,70 168,68 169,67 170,67 171,68 171,69 169,71 168,71" style="fill: rgb(19,13,13)" /> - <polygon points="23,163 23,167 23,158 23,162 23,166 23,161 23,165 23,169 23,160 23,164 23,168 23,159" style="fill: rgb(225,227,224)" /> - <polygon points="246,131 246,130 247,130 255,134 255,135 254,135 247,133" style="fill: rgb(22,18,17)" /> - <polygon points="246,267 250,258 253,260 258,265 259,266 260,267 261,268 262,269 262,270 262,271 257,271 251,270 249,269" style="fill: rgb(142,108,106)" /> - <polygon points="32,210 33,199 34,198 35,198 36,199 37,206 37,207 37,208 37,209 37,210 37,211 37,212 37,213 37,214 37,215 34,213 32,211" style="fill: rgb(225,227,224)" /> - <polygon points="347,294 352,293 359,293 354,294" style="fill: rgb(157,161,164)" /> - <polygon points="247,90 248,88 249,88 255,90 255,101 250,97 247,92" style="fill: rgb(14,10,9)" /> - <polygon points="254,386 254,385 255,381 257,375 259,372 261,369 275,375 277,376 279,377 302,394 306,398 307,399 301,399 285,399 273,399 272,399 269,399 257,399 256,395" style="fill: rgb(12,23,29)" /> - <polygon points="210,176 212,172 214,169 215,168 218,168 220,169 221,170 228,188 229,191 229,192 229,193 227,196 215,204 210,198" style="fill: rgb(157,129,125)" /> - <polygon points="54,144 57,139 58,142 64,168 64,170 64,171 63,172 62,172 61,172 60,172 57,160 54,146" style="fill: rgb(185,189,190)" /> - <polygon points="49,24 50,27 51,38 51,39 50,39 49,29" style="fill: rgb(215,217,216)" /> - <polygon points="117,399 118,397 155,326 162,313 166,307 167,306 202,289 211,286 223,282 228,282 232,287 233,290 233,292 211,361 210,364 193,386 191,388 185,393 177,399 175,399 168,399 166,399 165,399 164,399 163,399 162,399 161,399 160,399 142,399 136,399 134,399 128,399" style="fill: rgb(195,153,154)" /> - <polygon points="49,149 53,152 56,163 57,167 60,181 60,183 59,183 52,163 49,150" style="fill: rgb(243,243,243)" /> - <polygon points="140,164 142,164 143,169 142,169 141,168" style="fill: rgb(68,83,90)" /> - <polygon points="359,391 359,384 360,384 372,399 367,399 366,399 365,399 359,394" style="fill: rgb(126,89,83)" /> - <polygon points="0,252 0,249 8,246 9,246 12,247 14,248 15,249 15,250 9,252 2,254 0,253" style="fill: rgb(207,207,207)" /> - <polygon points="133,131 134,129 135,130 136,131 136,132 135,133 134,133 133,132" style="fill: rgb(48,32,32)" /> - <polygon points="19,195 19,190 19,188 20,199 19,198 19,189 19,188 20,199 19,198 19,189 19,188 20,199" style="fill: rgb(225,227,224)" /> - <polygon points="78,218 87,220 83,222 82,222 80,222 78,219" style="fill: rgb(142,108,106)" /> - <polygon points="247,17 258,7 261,8 261,10 257,14 253,17 252,17 251,17" style="fill: rgb(142,108,106)" /> - <polygon points="367,25 368,24 371,24 372,24 374,25 374,26 374,27 368,26" style="fill: rgb(251,251,251)" /> - <polygon points="143,88 149,86 150,86 149,90 144,89" style="fill: rgb(16,16,16)" /> - <polygon points="330,167 330,166 330,165 330,164 331,164 332,166 332,167 331,169 330,169" style="fill: rgb(207,207,207)" /> - <polygon points="313,137 313,135 314,134 328,129 333,129 333,130 328,143 327,144 316,141 313,139" style="fill: rgb(157,129,125)" /> - <polygon points="388,103 388,101 388,99 388,98 388,96 388,95 393,94 398,93 399,97 399,100 394,102 390,103 389,103" style="fill: rgb(185,189,190)" /> - <polygon points="278,160 280,158 287,160 289,162 287,171 284,171" style="fill: rgb(31,26,23)" /> - <polygon points="20,126 20,122 20,119 22,119 21,129 20,127" style="fill: rgb(227,233,231)" /> - <polygon points="22,52 22,50 22,49 25,54 26,56 26,60 22,55 22,53" style="fill: rgb(207,207,207)" /> - <polygon points="250,253 252,251 255,253 255,254 254,255 252,256 251,255" style="fill: rgb(48,32,32)" /> - <polygon points="138,341 139,340 141,340 142,340 144,341 144,342 144,344 139,342" style="fill: rgb(68,83,90)" /> - <polygon points="308,126 309,122 313,124 314,126 311,126 309,126" style="fill: rgb(142,108,106)" /> - <polygon points="380,106 387,97 396,99 395,100 381,106" style="fill: rgb(157,161,164)" /> - <polygon points="288,73 288,72 290,70 292,69 293,70 294,72 298,81 301,91 301,95 296,96 294,95" style="fill: rgb(22,18,17)" /> - <polygon points="260,342 261,341 263,341 264,341 265,343 260,344" style="fill: rgb(31,26,23)" /> - <polygon points="38,156 39,154 40,152 41,152 46,156 47,160 48,164 52,185 53,193 53,194 53,195 50,194 41,185 40,184 39,182 38,159" style="fill: rgb(236,241,237)" /> - <polygon points="16,81 16,79 17,72 18,67 18,69 18,70 18,71 18,72 17,79 16,82" style="fill: rgb(243,243,243)" /> - <polygon points="242,242 242,241 246,236 249,233 257,232 257,233 257,234 257,235 256,238 255,240 253,243 252,244 247,246 244,245" style="fill: rgb(126,89,83)" /> - <polygon points="90,154 93,149 96,149 99,149 92,162 91,162 90,156" style="fill: rgb(86,66,68)" /> - <polygon points="207,80 212,78 215,77 219,78 220,79 211,81 208,81" style="fill: rgb(22,18,17)" /> - <polygon points="117,33 125,29 125,30 122,32 117,34" style="fill: rgb(68,83,90)" /> - <polygon points="75,118 75,114 75,122 75,110 75,119 75,115 75,123 75,111 75,107 75,120 75,116 75,124 75,112 75,108 75,117 75,113 75,121 75,109" style="fill: rgb(225,227,224)" /> - <polygon points="74,93 74,102 74,98 74,94 74,103 74,99 74,95 74,91 74,100 74,96 74,92 74,101 74,97" style="fill: rgb(229,235,235)" /> - <polygon points="339,113 343,111 352,110 352,114 352,115 352,116 351,118 341,117 340,115" style="fill: rgb(207,207,207)" /> - <polygon points="117,14 120,12 131,6 138,3 139,9 139,10 137,13 136,14 129,18 127,19 117,24" style="fill: rgb(215,217,216)" /> - <polygon points="83,194 83,192 84,190 86,190 88,199 88,200 87,200 86,199 85,198 84,197" style="fill: rgb(126,89,83)" /> - <polygon points="334,129 335,127 344,127 353,127 353,130 352,131 351,131 350,131 349,131 348,131 347,131" style="fill: rgb(68,83,90)" /> - <polygon points="137,272 148,281 149,282 151,284 150,284 146,282 137,274" style="fill: rgb(86,66,68)" /> - <polygon points="369,142 369,141 369,138 370,133 370,134 370,136 370,138 370,139 369,143 369,138 370,133 370,134 370,136" style="fill: rgb(157,129,125)" /> - <polygon points="166,195 169,194 176,195 189,199 202,204 205,206 199,221 175,229 173,229" style="fill: rgb(157,129,125)" /> - <polygon points="201,399 211,382 214,377 229,378 231,383 226,399 225,399 224,399" style="fill: rgb(46,48,47)" /> - <polygon points="230,3 232,2 237,0 238,0 239,0 255,0 258,0 262,1 278,18 278,19 274,22 260,20 246,17 243,16 235,11" style="fill: rgb(142,108,106)" /> - <polygon points="55,0 56,0 57,6 58,15 58,20 58,22 58,23 57,23 56,15 55,3" style="fill: rgb(215,217,216)" /> - <polygon points="30,95 30,94 30,93 30,92 30,91 31,68 32,67 33,71 32,83 31,90" style="fill: rgb(207,207,207)" /> - <polygon points="224,68 224,67 224,66 232,64 233,64 234,64 234,71 232,71 224,69" style="fill: rgb(12,10,11)" /> - <polygon points="20,117 22,109 25,108 25,115 25,116 23,119" style="fill: rgb(227,233,231)" /> - <polygon points="112,119 112,118 112,117 118,110 118,111 118,115 115,118" style="fill: rgb(12,23,29)" /> - <polygon points="156,125 158,122 160,120 164,121 164,122 164,123 159,125" style="fill: rgb(126,89,83)" /> - <polygon points="384,200 386,197 387,196 389,196 397,196 398,197 398,200 395,201 394,201" style="fill: rgb(157,129,125)" /> - <polygon points="96,72 97,70 99,66 102,64 102,66 102,67 98,76" style="fill: rgb(185,189,190)" /> - <polygon points="260,182 260,181 263,177 265,175 266,176 266,177 264,180 263,181 260,183" style="fill: rgb(86,66,68)" /> - <polygon points="368,190 369,189 370,188 371,188 388,189 390,190 390,191 384,206 377,202 374,200 373,199" style="fill: rgb(157,161,164)" /> - <polygon points="13,131 13,125 13,121 13,132 13,120 13,129 13,128 13,124 13,130 13,135 13,127 13,123 13,133 13,126 13,122 13,134" style="fill: rgb(236,241,237)" /> - <polygon points="190,95 190,92 191,91 194,90 217,83 225,82 228,82 229,82 233,84 237,86 244,90 275,120 273,125 262,140 260,141 250,145 247,145 242,144 231,139 191,100 190,99" style="fill: rgb(31,26,23)" /> - <polygon points="146,364 147,362 149,359 150,359 150,364 148,364 147,364" style="fill: rgb(185,189,190)" /> - <polygon points="365,254 366,253 367,253 368,253 380,257 379,260 377,260 376,260 375,260 374,260 373,260 369,259 366,257" style="fill: rgb(157,129,125)" /> - <polygon points="260,232 260,228 272,218 293,214 296,214 297,215 297,216 297,217 297,218 270,230 263,233 260,233 260,228 272,218 293,214 296,214 297,215 297,216 297,217 297,218 270,230 263,233 260,233 260,228 272,218 293,214 296,214 297,215 297,216 297,217 297,218 270,230 263,233 260,233 260,228 272,218 293,214 296,214 297,215 297,216 297,217 297,218 270,230 263,233 260,233 260,228 272,218 293,214 296,214 297,215 297,216 297,217 297,218 270,230 263,233 260,233 260,228 272,218 293,214 296,214 297,215 297,216 297,217 297,218 270,230 263,233 260,233 260,228 272,218 293,214 296,214 297,215 297,216 297,217 297,218 270,230 263,233 260,233 260,228 272,218 293,214 296,214 297,215 297,216 297,217 297,218 270,230 263,233 260,233 260,228 272,218 293,214 296,214 297,215 297,216 297,217 297,218 270,230 263,233 260,233 260,228 272,218 293,214 296,214 297,215 297,216 297,217 297,218 270,230 263,233 260,233 260,228 272,218 293,214 296,214 297,215 297,216 297,217 297,218 270,230 263,233 260,233 260,228 272,218 293,214 296,214 297,215 297,216 297,217 297,218" style="fill: rgb(157,161,164)" /> - <polygon points="103,208 106,195 107,191 108,190 111,191 217,247 218,250 186,268 177,273 168,275 156,273 145,270 143,269 123,255 119,251 112,238 109,230" style="fill: rgb(142,108,106)" /> - <polygon points="0,169 1,165 3,160 5,155 6,153 7,152 8,154 9,156 9,157 9,158 9,159 5,180 4,181 2,182 1,182 0,181" style="fill: rgb(251,251,251)" /> - <polygon points="51,139 51,138 53,136 54,143 55,151 55,153 55,154 54,151" style="fill: rgb(207,207,207)" /> - <polygon points="6,85 6,84 6,83 7,82 15,82 15,83 12,102 11,102 9,102 7,97 6,88" style="fill: rgb(227,233,231)" /> - <polygon points="358,379 359,380 363,384 375,399 373,399 372,398 371,397 370,396 369,395 368,394 361,385" style="fill: rgb(86,66,68)" /> - <polygon points="0,203 0,199 4,187 5,185 5,187 4,193 3,198 1,205 0,206" style="fill: rgb(243,243,243)" /> - <polygon points="43,243 44,240 48,237 50,236 50,237 49,239 48,240 46,242 44,243" style="fill: rgb(157,129,125)" /> - <polygon points="266,40 267,40 273,41 273,42 269,42 267,41" style="fill: rgb(142,108,106)" /> - <polygon points="310,190 310,189 313,187 316,187 315,188 312,190" style="fill: rgb(142,108,106)" /> - <polygon points="220,76 221,76 223,76 230,76 237,80 246,88 247,89 245,89 242,88 224,80" style="fill: rgb(13,13,13)" /> - <polygon points="298,65 300,62 302,61 311,62 311,63 304,69 300,69 299,68 298,66" style="fill: rgb(195,153,154)" /> - <polygon points="159,130 160,129 161,129 162,129 163,129 164,129 165,129 166,129 167,129 169,130 167,130 166,130 165,130 164,130 163,130 162,130 161,130 160,130" style="fill: rgb(46,48,47)" /> - <polygon points="151,191 153,190 168,194 198,205 164,231 161,229 160,228 155,220 151,193" style="fill: rgb(195,153,154)" /> - <polygon points="348,38 349,37 353,33 356,32 357,32 355,34 351,37 349,38" style="fill: rgb(157,161,164)" /> - <polygon points="356,248 362,247 363,247 364,247 365,247 366,247 367,247 368,247 366,248 360,249 358,249" style="fill: rgb(46,48,47)" /> - <polygon points="133,266 134,265 166,271 169,278 168,279 164,282 158,286 157,286 155,286 152,284 146,280 141,276 133,268" style="fill: rgb(79,45,44)" /> - <polygon points="53,227 58,221 59,220 60,220 62,221 64,223" style="fill: rgb(157,129,125)" /> - <polygon points="100,242 100,240 101,238 109,232 110,233 128,266 129,269 129,273 129,274 126,279 125,279 124,279 123,279 122,279 121,279 120,279 117,278 112,274 111,273 110,272 105,264 104,262 103,260 102,257 101,254 100,250" style="fill: rgb(157,129,125)" /> - <polygon points="6,70 7,67 11,64 12,64 13,64 13,66 12,71 8,74 7,74 6,74" style="fill: rgb(251,251,251)" /> - <polygon points="143,102 145,95 146,94 156,88 159,88 168,89 171,90 176,93 178,95 179,96 180,98 180,100 150,109 148,109 146,108 145,107 143,103" style="fill: rgb(79,45,44)" /> - <polygon points="305,79 305,77 306,76 371,28 372,28 396,29 399,30 399,36 399,44 399,52 399,60 396,63 395,64 387,71 380,77 358,93 320,96 318,96 311,95 307,90 306,85 305,80" style="fill: rgb(157,161,164)" /> - <polygon points="26,135 26,133 26,131 26,129 26,128 26,127 27,128 27,130 27,135 27,136 27,151 26,167" style="fill: rgb(157,161,164)" /> - <polygon points="199,168 203,160 204,159 205,159 206,160 207,161 208,163 208,164 207,167 204,168 200,169" style="fill: rgb(126,89,83)" /> - <polygon points="219,34 220,34 221,34 222,34 223,34 232,34 233,34 234,34 224,34 225,34 226,34 227,34 228,34 229,34 230,34 231,34" style="fill: rgb(68,83,90)" /> - <polygon points="252,8 253,5 254,5 256,5 257,6 258,10 257,12 253,14 252,14" style="fill: rgb(157,129,125)" /> - <polygon points="296,245 303,233 306,232 311,239 311,244 311,245 311,246 304,247 302,247 297,246" style="fill: rgb(126,89,83)" /> - <polygon points="49,68 49,67 49,64 50,64 50,73 50,74 49,69" style="fill: rgb(227,233,231)" /> - <polygon points="369,103 369,100 369,97 369,96 374,88 380,87 385,87 386,87 388,90 386,97 384,99 370,111" style="fill: rgb(126,89,83)" /> - <polygon points="266,202 291,199 295,199 296,199 297,199 298,199 299,199 299,215 299,216 299,217 299,218 298,218 272,209 270,208 269,207" style="fill: rgb(207,207,207)" /> - <polygon points="95,223 95,222 104,213 105,215 108,224 108,225 107,227 106,227" style="fill: rgb(142,108,106)" /> - <polygon points="371,392 371,391 371,390 371,389 371,388 383,398 380,398 379,398 376,397 372,394" style="fill: rgb(142,108,106)" /> - <polygon points="0,124 0,117 0,114 0,110 3,111 3,112 1,122" style="fill: rgb(254,254,254)" /> - <polygon points="188,150 190,146 191,144 193,144 193,147 193,153 192,153" style="fill: rgb(31,26,23)" /> - <polygon points="310,229 310,204 320,195 326,193 326,194 313,228 312,229 311,229" style="fill: rgb(215,217,216)" /> - <polygon points="299,27 300,25 301,23 302,23 307,24 311,25 307,28 305,29 304,29 300,29 299,28" style="fill: rgb(207,207,207)" /> - <polygon points="62,1 64,0 65,0 66,10 66,14 66,15 65,31 63,28" style="fill: rgb(225,227,224)" /> - <polygon points="305,166 305,162 305,158 306,157 308,155 310,154 311,154 312,166 312,167 306,167 305,167" style="fill: rgb(142,108,106)" /> - <polygon points="62,131 62,130 63,130 64,130 65,136 64,137" style="fill: rgb(157,161,164)" /> - <polygon points="60,204 60,203 60,202 60,201 60,200 61,203 64,214 61,216 60,216" style="fill: rgb(185,189,190)" /> - <polygon points="69,62 69,61 69,60 70,94 70,95 69,95 69,87 69,79 69,71 69,70 69,61 69,60 70,94 70,95 69,95 69,87 69,79 69,71 69,70 69,61 69,60 70,94 70,95 69,95 69,87 69,79 69,71 69,70 69,61 69,60 70,94 70,95 69,95 69,87 69,79 69,71 69,70 69,61" style="fill: rgb(157,161,164)" /> - <polygon points="17,166 17,158 18,168 18,169 18,174 18,175 18,176 18,177 18,178 18,179 17,171" style="fill: rgb(225,227,224)" /> - <polygon points="101,257 101,256 101,255 130,267 131,268 132,269 135,272 138,276 140,284 140,285 136,290 128,289 126,288 122,286 118,283 112,278 111,277 106,269 103,263" style="fill: rgb(157,129,125)" /> - <polygon points="64,90 65,86 67,86 68,88 68,93 68,99 66,99 65,97" style="fill: rgb(227,233,233)" /> - <polygon points="205,31 206,25 208,24 210,23 213,22 217,22 217,25 217,27 216,28 212,30 207,32 206,32" style="fill: rgb(157,161,164)" /> - <polygon points="13,9 13,8 13,3 14,0 15,0 16,0 17,0 17,1 17,15 16,15 14,13" style="fill: rgb(225,227,224)" /> - <polygon points="58,0 59,0 61,6 61,7 61,8 58,10 58,9" style="fill: rgb(207,207,207)" /> - <polygon points="328,21 346,11 360,4 367,2 371,1 375,1 396,5 399,6 399,8 399,10 399,11 395,26 391,27 388,27 380,27 375,27 331,25 329,24" style="fill: rgb(254,254,254)" /> - <polygon points="331,28 334,27 335,27 339,27 338,28" style="fill: rgb(157,129,125)" /> - <polygon points="269,200 269,198 283,183 284,183 285,185 287,189 287,190 287,192 280,200 278,202 277,202 271,202 270,202 269,202" style="fill: rgb(185,189,190)" /> - <polygon points="175,82 175,77 176,77 185,78 184,79 180,82 178,83 177,83" style="fill: rgb(19,13,13)" /> - <polygon points="42,112 43,106 44,101 45,103 43,111 42,113" style="fill: rgb(225,227,224)" /> - <polygon points="251,8 252,4 253,3 257,2 257,4 257,5 255,6" style="fill: rgb(142,108,106)" /> - <polygon points="347,185 349,185 354,191 353,191 352,191 351,191 350,191 348,190 347,187" style="fill: rgb(195,153,154)" /> - <polygon points="318,284 330,282 354,279 355,279 356,279 357,279 358,279 351,282 325,291 322,291 321,290 320,289 318,285" style="fill: rgb(157,129,125)" /> - <polygon points="42,98 42,93 42,92 43,92 43,93 43,95 43,96 42,100" style="fill: rgb(215,217,216)" /> - <polygon points="140,141 141,138 143,136 147,133 157,132 168,132 169,132 178,134 179,135 181,138 182,140 183,142 183,143 182,144 161,148 160,148 159,148" style="fill: rgb(48,32,32)" /> - <polygon points="372,288 372,286 379,285 399,283 399,285 399,286 399,287 399,288 399,289 395,292 394,292 380,291 375,290 373,289" style="fill: rgb(68,83,90)" /> - <polygon points="176,89 177,88 180,88 181,95 177,91 176,90" style="fill: rgb(19,13,13)" /> - <polygon points="281,73 281,72 282,72 283,72 284,72 285,73 286,74 287,75 286,76 284,76 282,75 281,74" style="fill: rgb(22,18,17)" /> - <polygon points="149,178 151,179 160,185 162,188 161,188 156,187 154,186 151,184 150,182 149,179" style="fill: rgb(195,153,154)" /> - <polygon points="74,144 74,138 75,125 75,140 75,141 75,152 74,151" style="fill: rgb(227,233,233)" /> - <polygon points="110,122 110,121 119,110 130,103 136,103 137,103 140,104 141,105 116,121 114,122 111,123" style="fill: rgb(31,26,23)" /> - <polygon points="44,122 45,120 47,118 48,118 49,119 50,123 52,132 52,137 52,138 51,142 48,135 44,123" style="fill: rgb(215,217,216)" /> - <polygon points="62,49 62,48 63,48 64,48 66,48 66,62 66,64 65,63 62,51" style="fill: rgb(229,235,235)" /> - <polygon points="193,254 193,253 200,248 201,248 200,250 198,252 197,253 195,254 194,254" style="fill: rgb(79,45,44)" /> - <polygon points="127,251 127,250 128,250 132,250 134,251 133,252" style="fill: rgb(126,89,83)" /> - <polygon points="284,182 287,179 288,179 293,181 294,182 295,183 295,185 295,190 295,191 295,193 295,194 294,194 292,194 291,193 290,192 286,187" style="fill: rgb(195,153,154)" /> - <polygon points="257,164 258,163 259,163 262,164 263,165 258,165" style="fill: rgb(22,18,17)" /> - <polygon points="58,68 58,67 58,66 58,65 58,62 59,61 59,63 59,66 58,71" style="fill: rgb(215,217,216)" /> - <polygon points="337,115 338,113 339,112 344,111 345,111 346,111 347,111 348,111 348,112 342,115 338,116" style="fill: rgb(225,227,224)" /> - <polygon points="253,181 253,180 253,179 254,177 258,175 259,176 257,181 254,181 253,180 253,179 254,177 258,175 259,176 257,181 254,181 253,180 253,179 254,177 258,175 259,176" style="fill: rgb(79,45,44)" /> - <polygon points="159,127 162,126 168,126 167,128 162,128 161,128 160,128" style="fill: rgb(31,26,23)" /> - <polygon points="95,143 96,142 98,141 101,141 100,144 99,146 98,146 96,144" style="fill: rgb(185,189,190)" /> - <polygon points="389,97 390,94 392,94 395,95 395,96 392,97" style="fill: rgb(207,207,207)" /> - <polygon points="32,121 32,119 33,119 37,120 34,126 33,126" style="fill: rgb(215,217,216)" /> - <polygon points="386,107 386,106 386,105 386,104 390,105 390,106 389,107 387,108 386,108 386,104 390,105 390,106 389,107 387,108 386,108 386,104" style="fill: rgb(142,108,106)" /> - <polygon points="331,194 331,192 332,191 333,191 335,196 335,197" style="fill: rgb(142,108,106)" /> - <polygon points="145,299 147,297 148,296 150,297 147,303 146,302 145,300" style="fill: rgb(185,189,190)" /> - <polygon points="26,48 26,47 26,46 26,45 26,44 26,43 27,38 28,35 29,33 29,41 29,47 28,52 27,53 26,53 26,44 26,43 27,38 28,35 29,33 29,41 29,47 28,52 27,53 26,53 26,44 26,43 27,38 28,35 29,33 29,41 29,47 28,52 27,53 26,53 26,44 26,43 27,38 28,35 29,33 29,41 29,47 28,52 27,53 26,53 26,44 26,43 27,38 28,35 29,33 29,41 29,47 28,52 27,53 26,53 26,44 26,43 27,38 28,35 29,33" style="fill: rgb(185,189,190)" /> - <polygon points="310,251 311,251 312,251 315,251 324,251 325,251 326,251 327,251 329,251 333,252 332,253 330,254 329,254 328,254 327,254 326,254 316,253" style="fill: rgb(157,129,125)" /> - <polygon points="169,224 170,222 171,221 176,218 177,218 175,224 174,225 172,225" style="fill: rgb(126,89,83)" /> - <polygon points="103,166 103,164 104,161 107,157 108,156 105,166 104,167" style="fill: rgb(126,89,83)" /> - <polygon points="92,160 92,159 95,151 97,148 98,148 101,149 109,152 111,153 100,166 99,166 94,163" style="fill: rgb(46,48,47)" /> - <polygon points="67,34 67,32 67,31 67,30 67,29 67,28 67,27 67,26 67,25 67,24 67,23 67,22 67,21 67,20 68,19 68,20 68,27" style="fill: rgb(185,189,190)" /> - <polygon points="76,174 76,172 77,167 78,162 79,163 81,165 79,175 78,177 77,178 76,176" style="fill: rgb(157,129,125)" /> - <polygon points="152,154 154,153 158,152 160,152 162,154 161,154 160,154" style="fill: rgb(157,129,125)" /> - <polygon points="170,76 171,76 172,76 173,76 174,76 175,76 176,76 177,76 178,76 179,76 179,77 178,77 177,77" style="fill: rgb(12,10,11)" /> - <polygon points="253,163 254,161 256,159 262,159 263,159 264,159 265,159 266,160 267,161 267,162 263,163" style="fill: rgb(48,32,32)" /> - <polygon points="14,125 14,124 14,123 14,119 14,118 15,117 15,121 15,122 14,127" style="fill: rgb(229,235,235)" /> - <polygon points="318,174 319,173 320,172 321,172 322,173 322,174 321,183 320,184 319,180 318,175" style="fill: rgb(86,66,68)" /> - <polygon points="204,123 204,122 205,122 212,127 213,128 212,128 209,127 206,125 205,124" style="fill: rgb(142,108,106)" /> - <polygon points="328,297 330,296 333,297 333,298 331,302 329,300 328,299" style="fill: rgb(86,66,68)" /> - <polygon points="390,216 396,215 399,215 399,217 399,218 399,223 399,224 396,224 392,223 391,221" style="fill: rgb(31,26,23)" /> - <polygon points="283,29 284,28 292,27 293,27 294,27 295,27 296,27 298,30 294,31 293,31" style="fill: rgb(207,207,207)" /> - <polygon points="16,242 21,219 21,223 20,236 19,239 18,241 17,243 16,243" style="fill: rgb(225,227,224)" /> - <polygon points="173,7 184,6 186,6 187,6 188,8 188,10 185,11 184,11 176,10 173,9" style="fill: rgb(68,83,90)" /> - <polygon points="313,261 325,257 329,256 330,256 331,256 332,256 333,256 335,256 339,256 336,260 332,262 325,263 324,263 323,263 322,263" style="fill: rgb(142,108,106)" /> - <polygon points="226,393 226,392 233,368 237,369 238,370 237,385 233,393 232,394 231,394 230,394 229,394" style="fill: rgb(79,45,44)" /> - <polygon points="334,307 352,306 353,309 351,311 343,312 341,312 340,312 339,312 338,312 337,312" style="fill: rgb(86,66,68)" /> - <polygon points="19,81 19,79 19,77 19,76 20,72 23,85 24,98 24,99 24,101 21,95 20,90 19,85" style="fill: rgb(225,227,224)" /> - <polygon points="192,228 193,227 195,226 199,225 208,225 220,226 218,229 208,229 207,229 206,229 205,229 204,229" style="fill: rgb(126,89,83)" /> - <polygon points="97,224 106,216 108,216 110,221 110,226 108,229" style="fill: rgb(157,129,125)" /> - <polygon points="24,111 24,110 25,109 29,115 29,116 28,116 27,116 26,116 25,114" style="fill: rgb(185,189,190)" /> - <polygon points="205,202 206,202 207,202 211,202 214,207 214,208 211,209 208,208 205,204" style="fill: rgb(142,108,106)" /> - <polygon points="302,130 303,129 304,129 305,129 306,129 312,141 321,167 320,170 316,174 314,174 313,174 312,174 304,172" style="fill: rgb(157,129,125)" /> - <polygon points="33,58 34,49 35,51 35,58 34,59" style="fill: rgb(251,251,251)" /> - <polygon points="80,93 80,89 80,88 81,90 81,93 81,94 80,95" style="fill: rgb(157,161,164)" /> - <polygon points="306,95 306,93 306,92 308,90 391,63 399,61 399,74 399,90 353,101 347,102 325,104 324,104 307,99" style="fill: rgb(157,161,164)" /> - <polygon points="172,168 175,167 178,166 179,166 180,167 180,168" style="fill: rgb(79,45,44)" /> - <polygon points="69,16 69,27 69,25 69,26 69,23 69,24 69,21 69,22 69,19 69,20 69,17 69,18" style="fill: rgb(236,241,237)" /> - <polygon points="361,147 366,145 368,145 368,146 368,147" style="fill: rgb(157,161,164)" /> - <polygon points="42,67 42,66 43,66 43,82 43,83 43,84 43,85 42,85" style="fill: rgb(185,189,190)" /> - <polygon points="348,296 362,295 363,298 363,299 350,298" style="fill: rgb(157,129,125)" /> - <polygon points="48,49 48,48 49,47 50,47 51,48 51,49 50,52 48,50" style="fill: rgb(236,241,237)" /> - <polygon points="114,237 116,238 118,240 118,243 116,243" style="fill: rgb(126,89,83)" /> - <polygon points="88,150 88,149 89,144 90,142 90,143 88,154" style="fill: rgb(157,161,164)" /> - <polygon points="147,104 157,92 159,91 167,91 171,92 173,93 176,95 177,96 179,98 180,101 180,102 157,112 149,110 147,106" style="fill: rgb(86,66,68)" /> - <polygon points="309,207 309,206 310,205 313,205 313,206 312,209 310,210 309,210" style="fill: rgb(157,161,164)" /> - <polygon points="339,52 340,51 344,48 352,42 355,40 352,45 342,52" style="fill: rgb(157,129,125)" /> - <polygon points="344,303 347,300 357,301 360,302 361,304 361,305 360,307 358,307 357,307 345,304" style="fill: rgb(46,48,47)" /> - <polygon points="345,108 349,102 352,99 352,107 352,108" style="fill: rgb(157,161,164)" /> - <polygon points="70,133 70,132 71,125 71,131 71,132 70,139 70,132 71,125 71,131 71,132 70,139 70,132 71,125 71,131 71,132 70,139" style="fill: rgb(157,161,164)" /> - <polygon points="57,103 61,102 63,102 63,104 59,104" style="fill: rgb(157,161,164)" /> - <polygon points="139,248 142,245 144,244 145,244 147,244 147,245 147,247 147,248 147,249 146,250 145,250 139,249" style="fill: rgb(142,108,106)" /> - <polygon points="185,158 187,158 200,161 199,164 194,167" style="fill: rgb(31,26,23)" /> - <polygon points="61,131 61,130 61,129 62,129 63,129 64,129 65,130 65,133 65,134 65,135 63,137 62,135" style="fill: rgb(157,161,164)" /> - <polygon points="43,113 54,86 55,86 64,102 64,103 64,106 64,110 64,111 44,113" style="fill: rgb(157,161,164)" /> - <polygon points="340,254 343,253 346,253 347,253 345,254 342,255 341,255" style="fill: rgb(157,129,125)" /> - <polygon points="392,259 396,251 398,249 399,249 399,250 399,251 399,261 398,262 396,263 393,262 392,260" style="fill: rgb(157,129,125)" /> - <polygon points="331,209 331,204 331,203 331,202 331,201 335,205 336,210 336,215 333,215 332,212" style="fill: rgb(157,161,164)" /> - <polygon points="148,170 148,162 149,158 150,158 163,163 165,178 163,180 161,180 155,178 152,177 148,175" style="fill: rgb(79,45,44)" /> - <polygon points="271,60 271,59 271,58 271,57 271,56 271,54 274,54 275,54 284,61 287,64 287,65 286,69 285,69 284,69 283,69 282,69 281,69 280,69 272,63" style="fill: rgb(22,18,17)" /> - <polygon points="371,302 381,296 383,297 384,298 384,299 384,301 382,302" style="fill: rgb(86,66,68)" /> - <polygon points="94,106 94,104 99,107 100,108 98,110 97,110 95,110" style="fill: rgb(68,83,90)" /> - <polygon points="29,56 29,55 29,54 29,53 30,52 32,51 32,57 32,59 31,60 29,60 29,55 29,54 29,53 30,52 32,51 32,57 32,59 31,60 29,60 29,55 29,54 29,53 30,52 32,51 32,57 32,59 31,60 29,60" style="fill: rgb(225,227,224)" /> - <polygon points="149,164 150,160 152,157 155,157 156,157 157,157 158,157 159,171 159,172 159,173 159,174 158,175 154,171 150,167 149,165" style="fill: rgb(79,45,44)" /> - <polygon points="138,22 139,17 140,16 141,16 148,24 149,30 149,31 143,33 142,32" style="fill: rgb(157,129,125)" /> - <polygon points="272,347 273,348 274,349 275,350 276,351 315,396 315,399 313,399 308,397 292,385 283,376 281,372 280,370 273,352 272,348" style="fill: rgb(86,66,68)" /> - <polygon points="343,255 346,252 350,250 351,250 350,252 349,253 348,254 346,255" style="fill: rgb(157,161,164)" /> - <polygon points="186,11 187,9 188,9 190,10 191,13 191,14 191,15 191,16" style="fill: rgb(68,83,90)" /> - <polygon points="342,322 344,321 349,320 354,319 359,318 397,312 398,312 399,312 399,377 399,379 399,393 388,396 384,397 383,397 381,397 379,396 374,392 372,390 363,377 362,375 351,352 346,339" style="fill: rgb(157,129,125)" /> - <polygon points="100,261 100,258 161,312 160,315 159,317 158,319 157,321 154,324 152,323 124,300 116,292 115,291 111,287 107,279 105,275 102,267" style="fill: rgb(126,89,83)" /> - <polygon points="341,317 342,316 346,315 366,312 367,312 368,312 369,312 370,312 371,312 372,314 367,315 351,318 344,319 342,319 341,318" style="fill: rgb(207,207,207)" /> - <polygon points="64,69 64,67 64,66 65,64 67,68 68,80 68,85 68,86 68,87 67,94 66,93 64,73" style="fill: rgb(227,233,233)" /> - <polygon points="6,176 6,168 7,165 7,169 7,171 6,177 6,169 6,168 7,165 7,169 7,171 6,177 6,169 6,168 7,165 7,169 7,171" style="fill: rgb(243,243,243)" /> - <polygon points="6,254 22,243 78,220 87,221 86,222 53,245 51,246 21,255 10,258 9,258 7,257" style="fill: rgb(68,83,90)" /> - <polygon points="53,6 53,5 53,4 54,8 55,20 56,32 56,33 56,41 56,42 56,43 56,44 56,45 56,46 55,38 53,7" style="fill: rgb(185,189,190)" /> - <polygon points="114,136 114,135 115,133 116,131 117,129 119,126 120,125 123,123 129,120 131,119 140,116 149,114 181,109 182,109 218,135 219,137 213,137 212,137" style="fill: rgb(126,89,83)" /> - <polygon points="334,240 334,239 337,206 339,208 342,244 335,241" style="fill: rgb(46,48,47)" /> - <polygon points="122,150 123,147 137,147 138,148 137,151 135,154 134,155 133,155 132,155 131,155 130,155 127,154" style="fill: rgb(142,108,106)" /> - <polygon points="232,136 238,135 239,135 248,135 249,135 253,136 233,138 232,138" style="fill: rgb(31,26,23)" /> - <polygon points="0,156 0,147 4,111 8,116 8,117 6,149 2,160 1,162 0,162" style="fill: rgb(236,241,237)" /> - <polygon points="234,6 235,4 239,5 240,6 240,7 240,8 240,9 240,10 240,11 238,12 234,7" style="fill: rgb(157,129,125)" /> - <polygon points="269,142 276,142 278,146 278,147 275,147 274,147" style="fill: rgb(48,32,32)" /> - <polygon points="309,1 313,0 315,0 315,1 314,2 310,4" style="fill: rgb(157,129,125)" /> - <polygon points="229,10 231,7 234,8 234,10 234,11 230,12 229,12" style="fill: rgb(157,129,125)" /> - <polygon points="73,10 73,9 73,0 86,70 86,71 86,94 84,158 82,162 81,162 80,162 78,161 76,160 73,17" style="fill: rgb(185,189,190)" /> - <polygon points="119,396 135,367 136,367 136,368 132,382 123,394 122,395" style="fill: rgb(157,161,164)" /> - <polygon points="97,190 97,188 97,187 99,192 99,193 99,194 99,195 98,194" style="fill: rgb(185,189,190)" /> - <polygon points="73,126 73,122 74,126 74,127 73,132" style="fill: rgb(236,241,237)" /> - <polygon points="31,136 31,135 31,134 31,133 31,132 38,134 35,137 33,137 31,137" style="fill: rgb(227,233,231)" /> - <polygon points="366,254 369,253 370,253 377,254 380,255 381,256 380,256 379,256 378,256 376,256 367,255" style="fill: rgb(195,153,154)" /> - <polygon points="341,136 342,131 343,131 353,132 353,134 353,136 353,137 341,138" style="fill: rgb(157,129,125)" /> - <polygon points="312,4 318,1 319,2 320,4" style="fill: rgb(185,189,190)" /> - <polygon points="269,144 270,145 272,150 273,153 271,153 270,151 269,147" style="fill: rgb(22,18,17)" /> - <polygon points="46,101 50,85 50,92 50,95 49,98 47,100" style="fill: rgb(225,227,224)" /> - <polygon points="320,3 320,2 324,1 325,1 325,4 325,8 320,10" style="fill: rgb(157,129,125)" /> - <polygon points="389,17 389,16 398,12 399,12 399,17 398,18 395,19 393,19 392,19" style="fill: rgb(251,251,251)" /> - <polygon points="302,111 305,107 333,107 334,107 335,107 332,108 327,109 305,112 303,112" style="fill: rgb(157,161,164)" /> - <polygon points="11,163 11,162 11,161 12,149 13,152 13,155 13,156 12,161 11,165" style="fill: rgb(225,227,224)" /> - <polygon points="176,227 185,217 188,217 194,219 195,220 191,222 178,227 177,227" style="fill: rgb(157,129,125)" /> - <polygon points="360,318 361,317 384,313 396,311 397,311 398,311 399,311 396,312 367,317 361,318" style="fill: rgb(185,189,190)" /> - <polygon points="145,303 145,302 205,283 207,283 208,284 193,291 186,294 156,306 151,308 148,307 146,305" style="fill: rgb(195,153,154)" /> - <polygon points="102,180 102,178 104,175 106,176 112,185 113,191 113,194 105,211 104,212 103,209 102,202" style="fill: rgb(142,108,106)" /> - <polygon points="312,196 312,194 313,193 319,193 320,193 321,193 322,193 323,193 324,193 325,193 325,194 316,199 312,197" style="fill: rgb(225,227,224)" /> - <polygon points="25,151 25,143 25,152 25,144 25,149 25,141 25,150 25,142 25,147 25,148 25,140 25,145 25,146" style="fill: rgb(207,207,207)" /> - <polygon points="321,25 321,24 323,23 327,21 332,20 334,20 335,22 334,24 330,26 322,26" style="fill: rgb(254,254,254)" /> - <polygon points="214,6 214,5 215,2 216,0 217,2 217,6 215,6" style="fill: rgb(68,83,90)" /> - <polygon points="0,242 5,243 7,245 7,247 6,248 1,248 0,248" style="fill: rgb(185,189,190)" /> - <polygon points="100,257 100,256 100,254 136,272 152,285 153,286 154,287 154,289 144,304 143,305 142,306 141,306 138,304 120,291 119,290 116,287 115,286 111,281 108,276 104,269 102,264" style="fill: rgb(142,108,106)" /> - <polygon points="335,299 336,296 340,293 341,293 362,300 339,305 335,305" style="fill: rgb(86,66,68)" /> - <polygon points="0,212 5,194 5,199 4,203 3,207 2,210 1,212" style="fill: rgb(227,233,231)" /> - <polygon points="341,294 362,299 363,300 344,299 342,298 341,295" style="fill: rgb(126,89,83)" /> - <polygon points="283,82 284,80 285,80 285,81 285,85 284,85 283,84" style="fill: rgb(13,13,13)" /> - <polygon points="353,257 354,253 356,250 359,252 360,254 359,258 355,263 354,262" style="fill: rgb(46,48,47)" /> - <polygon points="355,306 361,303 362,303 363,304 363,308 362,309 359,309 357,309 356,309" style="fill: rgb(79,45,44)" /> - <polygon points="317,264 330,263 336,263 336,264 333,265 319,265" style="fill: rgb(157,161,164)" /> - <polygon points="200,218 203,214 204,213 223,218 222,220 220,221 219,221 218,221 217,221 216,221 215,221 214,221 213,221 212,221 211,221 210,221 209,221 201,220" style="fill: rgb(142,108,106)" /> - <polygon points="0,256 1,255 3,254 6,253 7,253 8,253 8,255 8,258 3,260 0,261" style="fill: rgb(185,189,190)" /> - <polygon points="52,165 54,168 55,172 55,173 55,176 52,166" style="fill: rgb(215,217,216)" /> - <polygon points="75,85 75,81 75,93 75,89 75,77 75,86 75,82 75,90 75,78 75,87 75,83 75,91 75,79 75,88 75,84 75,92 75,80" style="fill: rgb(207,207,207)" /> - <polygon points="271,186 271,181 272,179 274,178 275,178 275,179 275,180 275,181 274,184 272,186" style="fill: rgb(157,161,164)" /> - <polygon points="197,197 197,195 210,177 214,173 216,175 223,185 224,192 224,194 223,195 215,200" style="fill: rgb(195,153,154)" /> - <polygon points="313,229 318,212 321,205 327,197 328,196 330,196 331,196 333,200 334,203 334,204 334,205 333,228 330,232 319,232 318,232 317,232 316,232 313,231" style="fill: rgb(185,189,190)" /> - <polygon points="0,26 0,18 0,17 2,4 4,0 5,0 6,0 3,35 2,39 0,39" style="fill: rgb(243,243,243)" /> - <polygon points="100,139 101,135 102,134 105,132 105,133 104,137 103,139" style="fill: rgb(126,89,83)" /> - <polygon points="352,167 352,166 363,148 370,148 373,149 377,153 381,159 383,168 384,173 379,177 378,177 355,170 353,169" style="fill: rgb(157,129,125)" /> - <polygon points="70,296 73,264 75,254 77,245 78,242 80,236 81,233 82,230 83,228 88,221 89,221 119,314 119,315 109,399 104,399 95,399 94,399 93,399 92,399 91,399 90,399 89,399 87,396 86,394 81,382 70,304" style="fill: rgb(68,83,90)" /> - <polygon points="214,378 215,376 217,372 219,371 217,376 216,378" style="fill: rgb(46,48,47)" /> - <polygon points="239,399 246,391 247,391 246,393 244,396 242,398 240,399" style="fill: rgb(126,89,83)" /> - <polygon points="262,368 263,368 265,368 276,373 278,374 280,375 277,375 264,369" style="fill: rgb(46,48,47)" /> - <polygon points="128,156 129,156 130,156 135,157 137,158 138,160 138,163" style="fill: rgb(68,83,90)" /> - <polygon points="71,50 71,46 71,44 71,43 72,40 72,52 71,53 71,49 71,46 71,44 71,43 72,40 72,52 71,53 71,49 71,46" style="fill: rgb(227,233,233)" /> - <polygon points="281,48 285,42 297,36 299,35 301,34 306,32 311,34 311,35 308,37 296,43 284,49 282,49" style="fill: rgb(254,254,254)" /> - <polygon points="0,40 2,22 3,14 4,9 6,1 7,0 8,0 9,0 18,0 19,0 20,0 21,0 22,0 23,0 24,1 23,20 21,52 16,78 12,87 11,88 5,93 0,92" style="fill: rgb(229,235,235)" /> - <polygon points="216,212 218,207 230,200 231,200 233,202 233,203 230,206 227,209 216,215" style="fill: rgb(86,66,68)" /> - <polygon points="199,232 203,231 228,230 242,248 246,258 246,262 245,263 244,263 243,263 204,242 200,234" style="fill: rgb(157,129,125)" /> - <polygon points="116,236 116,230 118,224 119,223 120,222 121,222 122,222 203,227 206,244 187,262 181,267 179,268 162,265 157,264 124,247 120,243" style="fill: rgb(86,66,68)" /> - <polygon points="338,185 343,184 344,185 344,186 343,187 341,187 339,187" style="fill: rgb(185,189,190)" /> - <polygon points="344,12 349,9 351,13 351,14 348,14 346,13" style="fill: rgb(251,251,251)" /> - <polygon points="234,259 235,259 239,263 239,264 237,263 236,262" style="fill: rgb(126,89,83)" /> - <polygon points="258,63 262,60 263,60 264,62 263,63 262,63" style="fill: rgb(19,13,13)" /> - <polygon points="391,310 392,309 398,309 399,309 399,310 395,311 392,311" style="fill: rgb(207,207,207)" /> - <polygon points="161,166 165,163 186,154 190,155 193,156 198,160 198,163 197,169 195,172 194,173 193,174 191,176 188,178 185,179 184,179 169,175" style="fill: rgb(48,32,32)" /> - <polygon points="16,65 16,63 16,62 16,54 18,49 19,49 19,51 18,61 16,72" style="fill: rgb(227,233,231)" /> - <polygon points="47,71 47,70 48,68 48,70 47,81" style="fill: rgb(225,227,224)" /> - <polygon points="60,173 65,169 71,171 71,174 71,175 71,176 71,177 71,182 71,183 71,184 71,185 71,215 71,216 71,217 71,218 71,224 71,225 69,227 68,227 66,218 60,175" style="fill: rgb(215,217,216)" /> - <polygon points="355,6 360,3 364,1 366,0 367,0 369,0 387,3 390,6 362,7 356,7" style="fill: rgb(251,251,251)" /> - <polygon points="370,392 381,399 378,399 377,399 376,399 373,396 372,395 371,394 370,393" style="fill: rgb(126,89,83)" /> - <polygon points="270,133 270,130 272,129 274,130 274,131 272,133 270,135" style="fill: rgb(185,189,190)" /> - <polygon points="349,174 349,173 350,172 351,172 367,172 383,177 385,179 385,180 384,182 383,183 379,186 377,187 361,194 360,194 357,192 354,188 350,179" style="fill: rgb(126,89,83)" /> - <polygon points="121,110 126,104 143,87 155,83 162,81 175,86 181,89 182,90 186,98 186,99 123,111 122,111" style="fill: rgb(79,45,44)" /> - <polygon points="71,85 73,84 74,104 74,117 73,119 72,114 71,108" style="fill: rgb(229,235,235)" /> - <polygon points="35,81 35,73 35,75 35,77 35,79 35,71 35,82 35,74 35,76 35,78 35,80 35,72" style="fill: rgb(215,217,216)" /> - <polygon points="354,373 354,372 354,363 354,362 355,364 355,367 355,371" style="fill: rgb(46,48,47)" /> - <polygon points="194,6 194,5 194,4 199,1 204,0 205,0 205,3 204,5 203,6" style="fill: rgb(86,66,68)" /> - <polygon points="386,0 387,0 392,0 399,0 399,1 391,1 388,1" style="fill: rgb(251,251,251)" /> - <polygon points="106,171 106,161 109,157 110,156 112,155 113,155 114,155 115,155 119,156 127,160 132,163 137,167 143,175 144,177 144,178 144,179 143,179 142,179 107,172" style="fill: rgb(195,153,154)" /> - <polygon points="0,220 3,217 4,218 4,225 2,226 0,225" style="fill: rgb(207,207,207)" /> - <polygon points="303,33 311,29 313,28 314,29 314,31 314,34 309,34 304,34" style="fill: rgb(251,251,251)" /> - <polygon points="66,136 67,130 68,130 68,141 67,141 66,137" style="fill: rgb(225,227,224)" /> - <polygon points="307,223 311,223 309,226 307,227" style="fill: rgb(86,66,68)" /> - <polygon points="163,75 164,74 176,65 204,46 210,44 211,44 242,45 279,77 281,79 287,88 287,89 287,90 287,91 283,107 280,114 276,118 275,118 274,118 273,118 272,118 268,117 164,79 163,78" style="fill: rgb(11,11,11)" /> - <polygon points="2,99 5,83 8,80 9,80 15,80 15,81 8,104 7,104 5,103" style="fill: rgb(229,235,235)" /> - <polygon points="360,279 360,278 381,276 398,275 399,275 399,276 396,278 375,279 361,279" style="fill: rgb(157,129,125)" /> - <polygon points="392,192 393,190 396,188 397,188 398,189 396,192 393,193 392,193" style="fill: rgb(46,48,47)" /> - <polygon points="328,248 331,245 334,243 335,243 334,246 330,248" style="fill: rgb(207,207,207)" /> - <polygon points="252,36 252,33 252,32 253,26 254,26 256,30 256,31 255,33 253,36" style="fill: rgb(215,217,216)" /> - <polygon points="23,389 23,388 23,387 23,386 23,385 27,354 36,340 37,341 39,350 48,398 48,399 29,399 28,399 25,399 24,398" style="fill: rgb(12,23,29)" /> - <polygon points="188,154 189,154 190,154 191,154 195,155 198,156 201,158 197,159 196,159 195,159 191,158 189,157 188,156" style="fill: rgb(48,32,32)" /> - <polygon points="34,131 40,123 41,125 42,130 42,138 42,140 42,142 42,144 41,145 34,132" style="fill: rgb(243,243,243)" /> - <polygon points="329,54 330,53 337,48 339,49 339,51 333,55 330,55" style="fill: rgb(86,66,68)" /> - <polygon points="112,136 112,135 115,126 118,123 128,117 133,114 137,112 141,110 146,109 152,111" style="fill: rgb(126,89,83)" /> - <polygon points="47,140 47,139 49,140 51,145 49,147 48,146 47,142" style="fill: rgb(236,241,237)" /> - <polygon points="300,207 300,204 301,203 302,203 303,203 304,204 304,207 304,208 304,209 300,210" style="fill: rgb(68,83,90)" /> - <polygon points="227,151 235,147 243,151 243,152 243,153 242,154 236,155 228,156 227,155" style="fill: rgb(31,26,23)" /> - <polygon points="0,93 2,93 3,93 4,94 5,97 5,98 5,99 5,100 5,101 4,100 3,99 2,98 1,97" style="fill: rgb(225,227,224)" /> - <polygon points="221,138 224,138 225,143 223,149 222,147" style="fill: rgb(48,32,32)" /> - <polygon points="54,121 54,120 68,151 70,168 70,174 70,175 70,176 70,177 70,182 70,183 70,185 69,186 68,186 55,129 54,124" style="fill: rgb(225,227,224)" /> - <polygon points="9,241 11,236 23,221 24,226 25,234 25,235 25,244 24,247 18,248 17,248 16,248 15,248 10,246 9,243" style="fill: rgb(215,217,216)" /> - <polygon points="371,244 374,241 375,240 376,241 378,244 376,244 375,244 374,244" style="fill: rgb(46,48,47)" /> - <polygon points="0,214 13,157 29,119 30,118 31,118 41,196 41,233 41,234 34,242 25,246 16,247 12,245 8,242 2,237 1,236 0,232" style="fill: rgb(225,227,224)" /> - <polygon points="304,75 304,73 304,72 308,69 312,66 339,47 344,44 346,45 344,47 340,50 319,65 309,72 306,74" style="fill: rgb(86,66,68)" /> - <polygon points="5,127 6,122 7,121 7,125 7,126 6,128" style="fill: rgb(227,233,231)" /> - <polygon points="66,141 66,140 69,142 69,149 69,150 69,151 66,142" style="fill: rgb(225,227,224)" /> - <polygon points="58,112 58,111 59,110 60,110 62,112 63,114 59,113" style="fill: rgb(157,161,164)" /> - <polygon points="313,356 313,355 314,352 315,350 319,344 321,342 328,349 330,353 325,360 323,362 321,362" style="fill: rgb(126,89,83)" /> - <polygon points="257,137 257,136 262,126 264,124 268,122 270,122 274,125 275,126 266,138 259,141" style="fill: rgb(31,26,23)" /> - <polygon points="208,283 218,280 224,280 223,281 210,284 209,284" style="fill: rgb(126,89,83)" /> - <polygon points="295,114 295,113 300,107 302,108 304,110 297,114" style="fill: rgb(157,161,164)" /> - <polygon points="64,389 66,330 67,311 68,300 69,299 76,331 76,348 75,399 71,399 70,399 69,399 68,399 67,399 66,399 65,399 64,399" style="fill: rgb(12,23,29)" /> - <polygon points="339,196 341,194 342,195 345,199 348,204 349,206 349,208 349,209 345,209 344,207" style="fill: rgb(48,32,32)" /> - <polygon points="160,16 161,11 163,10 168,8 170,9 171,10 171,11 170,13 161,16" style="fill: rgb(68,83,90)" /> - <polygon points="0,0 2,0 3,0 3,2 2,10 1,15 0,16 0,15" style="fill: rgb(236,241,237)" /> - <polygon points="301,79 303,79 304,82 305,88 305,89 304,94 303,97 302,97 301,96" style="fill: rgb(31,26,23)" /> - <polygon points="228,32 235,29 252,23 258,21 262,22 267,27 261,36 260,37 256,37 255,37" style="fill: rgb(215,217,216)" /> - <polygon points="192,6 192,5 192,0 193,2 193,3 192,14 192,13" style="fill: rgb(68,83,90)" /> - <polygon points="329,111 330,111 331,111 332,111 333,111 334,111 335,111 335,112 334,112 333,112 332,112 331,112 330,112 329,112" style="fill: rgb(157,129,125)" /> - <polygon points="388,112 389,111 390,111 391,111 393,111 394,114 394,115 393,116" style="fill: rgb(215,217,216)" /> - <polygon points="353,122 353,121 356,108 357,104 360,97 362,97 362,98 357,133 353,125" style="fill: rgb(185,189,190)" /> - <polygon points="312,240 312,236 312,234 320,234 321,234 330,239 324,243 320,244 313,245 312,241" style="fill: rgb(185,189,190)" /> - <polygon points="12,143 12,142 14,141 14,148 14,149 13,146" style="fill: rgb(243,243,243)" /> - <polygon points="117,28 117,27 120,25 122,24 138,16 138,21 130,25 117,31" style="fill: rgb(86,66,68)" /> - <polygon points="340,235 340,234 344,220 344,224 344,225 344,226 343,234 340,237 340,236" style="fill: rgb(86,66,68)" /> - <polygon points="141,158 144,151 146,151 147,151 151,151 152,152 146,171 145,172 144,169 141,160" style="fill: rgb(31,26,23)" /> - <polygon points="292,219 300,214 302,214 303,215 304,216 304,217 304,218 301,219" style="fill: rgb(157,161,164)" /> - <polygon points="321,10 327,5 329,7 329,8 327,10 326,10" style="fill: rgb(185,189,190)" /> - <polygon points="169,75 171,71 174,75 172,75 171,75" style="fill: rgb(11,11,11)" /> - <polygon points="306,317 306,316 309,315 337,323 338,356 338,357 331,351 326,345 308,320" style="fill: rgb(68,83,90)" /> - <polygon points="104,120 107,116 113,109 113,110 107,117 105,119" style="fill: rgb(157,161,164)" /> - <polygon points="312,244 312,242 327,213 329,213 334,218 335,222 335,229 335,231 332,243 325,250 323,251 320,252 319,252 318,252 317,252 316,252 313,251 312,245" style="fill: rgb(157,161,164)" /> - <polygon points="146,8 147,4 148,0 151,0 153,0 159,2 159,3 149,8 147,9" style="fill: rgb(207,207,207)" /> - <polygon points="290,245 291,245 292,245 294,245 310,246 326,252 332,255 328,259 325,260 324,260 320,260 315,260 310,260 305,259" style="fill: rgb(142,108,106)" /> - <polygon points="125,383 125,382 125,381 125,380 126,374 127,368 128,366 131,368 132,371 131,374 130,376 127,382 126,383" style="fill: rgb(46,48,47)" /> - <polygon points="26,82 26,81 26,80 26,79 26,78 26,77 26,76 26,75 26,74 26,73 27,72 29,73 29,82 29,95 28,97 27,97 26,97 26,80 26,79 26,78 26,77 26,76 26,75 26,74 26,73 27,72 29,73 29,82 29,95 28,97 27,97 26,97 26,80 26,79 26,78 26,77 26,76 26,75 26,74 26,73 27,72 29,73 29,82 29,95 28,97 27,97 26,97 26,80 26,79 26,78 26,77 26,76 26,75 26,74 26,73 27,72 29,73 29,82 29,95 28,97 27,97 26,97 26,80 26,79 26,78 26,77 26,76 26,75 26,74 26,73 27,72 29,73 29,82 29,95 28,97 27,97 26,97 26,80 26,79 26,78 26,77 26,76 26,75 26,74 26,73 27,72 29,73 29,82 29,95 28,97 27,97 26,97" style="fill: rgb(185,189,190)" /> - <polygon points="333,261 343,258 345,258 346,259 346,263 345,265 342,265 339,264" style="fill: rgb(86,66,68)" /> - <polygon points="144,268 144,267 146,266 149,266 148,267 146,268 145,268" style="fill: rgb(142,108,106)" /> - <polygon points="97,157 97,156 99,151 101,152 101,153 100,156 99,157 98,158" style="fill: rgb(48,32,32)" /> - <polygon points="200,336 219,333 244,330 250,330 272,338 317,380 319,383 326,396 326,397 325,398 322,399 236,399 235,399 234,399 200,337" style="fill: rgb(46,48,47)" /> - <polygon points="124,256 124,255 124,254 142,252 144,253 173,268 176,274 170,278 159,281 158,281 132,267 129,265 125,258" style="fill: rgb(142,108,106)" /> - <polygon points="342,232 345,215 346,211 346,216 346,218 346,244 345,245 344,245" style="fill: rgb(46,48,47)" /> - <polygon points="184,44 186,40 191,39 194,39 193,40 191,41 187,43" style="fill: rgb(12,23,29)" /> - <polygon points="21,56 22,56 24,56 25,56 25,60 25,63 24,64 22,64 21,61" style="fill: rgb(225,227,224)" /> - <polygon points="266,38 266,36 269,34 271,34 272,35 272,36 271,37 269,38 268,38 267,38" style="fill: rgb(195,153,154)" /> - <polygon points="270,211 271,210 274,209 291,208 292,208 293,210 293,211 270,214" style="fill: rgb(185,189,190)" /> - <polygon points="197,180 197,179 198,177 199,175 202,172 204,170 203,174 201,178 199,180 198,181" style="fill: rgb(86,66,68)" /> - <polygon points="146,211 147,208 148,207 149,207 155,208 155,209 153,213 152,214 151,214 147,212" style="fill: rgb(157,129,125)" /> - <polygon points="345,198 347,193 348,192 358,201 359,202 358,202" style="fill: rgb(157,129,125)" /> - <polygon points="286,18 286,17 287,2 289,0 291,0 298,0 298,5 298,8 298,17 297,18 293,19 292,19 291,19" style="fill: rgb(157,161,164)" /> - <polygon points="254,244 255,241 257,236 282,266 295,297 296,300 296,302 295,302 265,268 254,248" style="fill: rgb(46,48,47)" /> - <polygon points="34,155 35,152 39,149 40,150 41,151 37,157" style="fill: rgb(236,241,237)" /> - <polygon points="60,68 60,67 60,57 60,55 63,72 63,76 62,78 60,77" style="fill: rgb(157,129,125)" /> - <polygon points="105,128 106,126 110,123 133,106 135,105 139,105 143,106 115,124" style="fill: rgb(31,26,23)" /> - <polygon points="349,193 352,195 359,200 359,201 357,200 353,198 351,196 350,195" style="fill: rgb(157,161,164)" /> - <polygon points="151,21 151,20 152,18 157,14 159,13 160,13 161,14 161,15 152,22 151,22" style="fill: rgb(126,89,83)" /> - <polygon points="217,120 218,120 221,121 225,123 237,130 238,131 238,132 236,133 235,133 221,125 219,123" style="fill: rgb(86,66,68)" /> - <polygon points="367,293 380,296 380,297 375,299 372,300 369,300 368,298" style="fill: rgb(157,129,125)" /> - <polygon points="277,126 299,108 335,113 337,114 335,125 316,181 296,189 278,132" style="fill: rgb(86,66,68)" /> - <polygon points="292,240 296,239 297,240 298,241 298,244 295,244 292,242" style="fill: rgb(86,66,68)" /> - <polygon points="369,295 369,294 370,293 377,295 379,296 373,297 370,297" style="fill: rgb(157,129,125)" /> - <polygon points="381,263 382,259 383,259 385,259 386,259 387,259 388,259 389,259 390,259 391,261 388,262" style="fill: rgb(79,45,44)" /> - <polygon points="370,301 374,299 377,298 381,297 379,300 376,301 375,301 373,301" style="fill: rgb(142,108,106)" /> - <polygon points="289,384 290,384 293,386 298,390 299,391 298,391 296,390 290,386" style="fill: rgb(46,48,47)" /> - <polygon points="43,112 47,0 48,0 50,6 51,15 55,54 55,57 55,58 53,90 52,97 45,111" style="fill: rgb(229,235,235)" /> - <polygon points="52,226 55,223 57,222 59,221 60,221 59,222 52,227" style="fill: rgb(157,129,125)" /> - <polygon points="327,158 327,157 328,158 328,160 327,169 327,161" style="fill: rgb(185,189,190)" /> - <polygon points="62,177 62,175 63,175 64,176 65,177 66,182 66,183 66,184 66,185 66,190 66,191 66,192 66,195 66,196 65,196 64,194 62,183" style="fill: rgb(185,189,190)" /> - <polygon points="189,239 189,238 191,235 192,234 194,237 195,239 194,240 192,241 189,240" style="fill: rgb(195,153,154)" /> - <polygon points="142,14 143,13 159,5 165,2 169,0 180,0 183,1 150,19 143,16" style="fill: rgb(86,66,68)" /> - <polygon points="55,9 55,6 55,5 55,4 57,0 58,2 59,5 59,6 59,7 56,10 55,10" style="fill: rgb(215,217,216)" /> - <polygon points="214,140 215,140 217,140 218,140 219,140 220,140 214,145" style="fill: rgb(48,32,32)" /> - <polygon points="101,139 104,130 106,128 108,127 111,126 112,126 113,127 108,135 106,138 105,139 103,140" style="fill: rgb(86,66,68)" /> - <polygon points="152,106 155,102 159,99 168,94 170,94 177,100 178,101 180,103 176,108 160,113 159,113 158,113 154,109 152,107" style="fill: rgb(86,66,68)" /> - <polygon points="0,236 0,233 5,236 6,240 6,241 4,240 1,238 0,237" style="fill: rgb(207,207,207)" /> - <polygon points="161,171 161,170 161,165 164,163 192,166 196,167 194,171 187,179 184,180 179,181 176,181 175,181 174,181 173,181 172,181 171,181 170,181 164,180 161,176" style="fill: rgb(79,45,44)" /> - <polygon points="325,110 339,108 341,108 342,108 343,108 340,109 332,110" style="fill: rgb(157,161,164)" /> - <polygon points="42,236 42,234 43,233 48,229 67,218 67,223 67,224 67,225 67,226 67,227 67,228 65,229" style="fill: rgb(207,207,207)" /> - <polygon points="71,157 71,155 72,163 72,164 72,165 71,167 71,159 71,155 72,163 72,164 72,165 71,167 71,159 71,155 72,163 72,164" style="fill: rgb(157,161,164)" /> - <polygon points="182,89 189,83 214,80 216,80 217,82 223,94 214,96 189,98 187,98 184,96 183,93" style="fill: rgb(14,10,9)" /> - <polygon points="245,187 255,185 256,185 252,187 251,187" style="fill: rgb(86,66,68)" /> - <polygon points="262,207 263,204 265,204 266,205 266,207 266,211 263,209 262,208" style="fill: rgb(251,251,251)" /> - <polygon points="17,89 17,88 19,94 19,95 17,98 17,90" style="fill: rgb(229,235,235)" /> - <polygon points="357,179 357,178 358,178 359,178 360,178 361,178 362,178 373,185 375,187 363,195 362,194 361,193 360,190 357,180" style="fill: rgb(142,108,106)" /> - <polygon points="305,137 305,133 306,130 312,129 313,129 314,129 315,129 315,133 311,140 308,140 305,138" style="fill: rgb(86,66,68)" /> - <polygon points="117,35 118,31 122,29 128,26 132,26 132,29 129,31 123,34 120,35" style="fill: rgb(86,66,68)" /> - <polygon points="76,133 76,118 76,122 76,126 76,134 76,135 76,119 76,123 76,127 76,129 76,120 76,124 76,128 76,130 76,131 76,117 76,121 76,125 76,132" style="fill: rgb(207,207,207)" /> - <polygon points="189,399 208,338 210,337 217,337 220,338 223,339 225,340 228,342 233,346 238,351 240,355 242,359 241,361 200,394 194,398 192,399" style="fill: rgb(157,129,125)" /> - <polygon points="201,141 203,141 204,146 204,147 204,148 204,149 203,148" style="fill: rgb(157,161,164)" /> - <polygon points="17,122 17,120 18,117 19,118 18,122 17,125" style="fill: rgb(243,243,243)" /> - <polygon points="263,20 264,19 265,19 266,19 269,19 270,19 270,21 269,21 268,21" style="fill: rgb(68,83,90)" /> - <polygon points="90,241 90,240 90,239 90,238 92,246 92,249 90,242" style="fill: rgb(46,48,47)" /> - <polygon points="258,372 259,367 272,373 273,374 258,374" style="fill: rgb(12,23,29)" /> - <polygon points="304,266 305,263 310,263 311,263 312,264 305,268 304,267" style="fill: rgb(157,129,125)" /> - <polygon points="104,140 108,136 109,138 109,141 107,141" style="fill: rgb(31,26,23)" /> - <polygon points="226,397 226,395 226,394 238,369 240,369 240,370 239,386 234,398 233,399 231,399 230,399 229,399 228,399" style="fill: rgb(79,45,44)" /> - <polygon points="4,70 5,67 6,66 7,65 11,62 12,62 13,62 14,63 14,66 14,68 14,69 13,72 12,73 7,76 6,76 5,76 4,71" style="fill: rgb(251,251,251)" /> - <polygon points="257,244 257,240 257,239 258,232 291,242 293,243 294,244 295,245 334,300 370,387 370,390 370,391 369,392 364,389 363,388 337,358 316,332 312,327 309,323 289,295 287,292 257,245" style="fill: rgb(68,83,90)" /> - <polygon points="387,127 387,126 387,125 387,124 395,123 396,123 397,123 399,123 399,126 388,127" style="fill: rgb(142,108,106)" /> - <polygon points="73,30 73,29 73,31 73,26 73,25 73,28 73,27 73,22 73,21 73,24 73,23 73,18 73,20 73,19" style="fill: rgb(207,207,207)" /> - <polygon points="274,40 275,38 280,36 290,33 290,34 278,41 277,41" style="fill: rgb(157,129,125)" /> - <polygon points="171,128 171,127 173,127 174,127 176,127 183,129 181,130 180,130 174,129" style="fill: rgb(22,18,17)" /> - <polygon points="192,16 192,15 193,11 194,10 195,9 206,4 206,6 206,8 205,9" style="fill: rgb(142,108,106)" /> - <polygon points="296,299 296,298 296,297 296,296 297,292 298,295 300,305 300,307 300,308 299,307 297,303" style="fill: rgb(12,23,29)" /> - <polygon points="317,27 319,25 322,24 329,26 321,29" style="fill: rgb(254,254,254)" /> - <polygon points="165,152 167,149 168,148 174,149 180,152 166,154 165,153" style="fill: rgb(86,66,68)" /> - <polygon points="187,21 187,20 194,12 209,2 213,9 201,16" style="fill: rgb(157,129,125)" /> - <polygon points="291,197 296,191 297,192 298,198 292,198" style="fill: rgb(157,161,164)" /> - <polygon points="82,237 82,236 82,235 83,230 85,226 86,225 87,250 87,251 85,252 84,249 83,244" style="fill: rgb(157,161,164)" /> - <polygon points="91,222 92,222 99,226 99,227 99,232 99,233 98,236 97,237" style="fill: rgb(46,48,47)" /> - <polygon points="8,109 9,106 14,103 14,105 13,110 12,111 11,111 8,111" style="fill: rgb(251,251,251)" /> - <polygon points="343,275 344,270 346,268 357,261 371,263 391,266 394,267 399,270 399,273 399,274 397,275 386,276 359,278 358,278 357,278 346,278 343,276" style="fill: rgb(185,189,190)" /> - <polygon points="280,215 287,215 289,216 281,216 280,216" style="fill: rgb(142,108,106)" /> - <polygon points="139,148 140,145 141,143 143,143 154,144 154,145 154,147 140,149" style="fill: rgb(142,108,106)" /> - <polygon points="23,129 23,128 23,124 23,122 23,120 23,118 23,117 24,116 25,119 25,135 25,136 25,139 24,137" style="fill: rgb(225,227,224)" /> - <polygon points="206,213 209,211 212,211 212,213 212,214 212,215 212,216 207,214" style="fill: rgb(79,45,44)" /> - <polygon points="95,139 96,136 100,129 104,123 105,122 106,122 107,122 107,123 105,129 98,138 96,139" style="fill: rgb(46,48,47)" /> - <polygon points="238,210 238,209 238,208 240,205 244,207 245,209 249,219 249,221 248,222 242,217 241,216 240,215" style="fill: rgb(142,108,106)" /> - <polygon points="201,316 202,315 204,314 207,313 226,307 233,307 239,308 235,309 202,316" style="fill: rgb(79,45,44)" /> - <polygon points="71,201 72,196 74,200 75,202 71,202" style="fill: rgb(157,161,164)" /> - <polygon points="0,338 1,339 10,368 15,386 18,397 18,398 18,399 14,399 12,396 8,389 0,373" style="fill: rgb(68,83,90)" /> - <polygon points="390,184 391,183 392,183 393,183 395,183 396,183 397,183 397,184 395,187 393,187 390,186" style="fill: rgb(185,189,190)" /> - <polygon points="31,117 31,116 36,115 40,117 40,118 40,119 37,119 36,119 35,119 32,118" style="fill: rgb(185,189,190)" /> - <polygon points="119,122 120,121 123,118 130,112 135,108 138,107 144,107 145,108 145,109 144,110" style="fill: rgb(79,45,44)" /> - <polygon points="74,206 75,206 79,207 80,208 82,210 86,218 84,218 83,218 77,216" style="fill: rgb(86,66,68)" /> - <polygon points="193,259 203,249 204,248 206,247 198,255 196,257" style="fill: rgb(142,108,106)" /> - <polygon points="144,149 145,148 146,148 147,148 148,148 149,148 150,148 152,148 157,149 153,150 147,150 146,150 145,150 144,150" style="fill: rgb(46,48,47)" /> - <polygon points="345,260 346,258 351,258 353,265 347,265 346,264 345,262" style="fill: rgb(46,48,47)" /> - <polygon points="24,24 24,23 24,22 24,21 24,20 24,19 24,18 24,17 24,16 24,27 24,26 24,25" style="fill: rgb(225,227,224)" /> - <polygon points="51,239 56,235 62,232 64,231 70,229 71,229 65,234 52,239" style="fill: rgb(185,189,190)" /> - <polygon points="198,289 204,286 215,282 220,281 221,281 222,281 220,282 215,284 199,290 198,290" style="fill: rgb(126,89,83)" /> - <polygon points="323,290 323,289 324,288 330,285 359,279 382,277 392,277 399,277 399,281 399,282 364,295 331,294 325,292" style="fill: rgb(142,108,106)" /> - <polygon points="205,80 205,79 206,78 207,77 211,77 211,78 208,82 207,82 206,82" style="fill: rgb(16,16,16)" /> - <polygon points="282,223 282,222 283,220 307,215 311,217 311,218 311,219 311,220 311,221 284,225 282,224" style="fill: rgb(157,129,125)" /> - <polygon points="323,236 333,233 334,235 333,239 332,240" style="fill: rgb(157,161,164)" /> - <polygon points="151,18 152,16 156,14 156,15 155,17 154,18 151,19" style="fill: rgb(126,89,83)" /> - <polygon points="49,86 49,85 51,61 52,57 52,58 52,59 52,60 51,74 50,84 49,90" style="fill: rgb(227,233,231)" /> - <polygon points="169,249 169,248 170,247 174,244 181,240 182,240 183,240 184,240 185,241 185,245 182,248 177,250 174,251 171,251" style="fill: rgb(195,153,154)" /> - <polygon points="314,207 314,206 322,197 327,193 330,195 329,199 324,205 319,209 315,210 314,210" style="fill: rgb(207,207,207)" /> - <polygon points="0,99 15,89 15,97 15,99 15,109 15,110 14,112 11,112 0,107" style="fill: rgb(236,241,237)" /> - <polygon points="155,29 156,26 159,20 160,19 162,18 163,18 164,22 164,25 164,26 163,27 157,29 156,29" style="fill: rgb(207,207,207)" /> - <polygon points="61,68 61,67 61,66 63,64 63,68 63,71 62,71 61,69" style="fill: rgb(157,129,125)" /> - <polygon points="297,102 297,101 301,100 302,100 302,101 300,104 298,104 297,103" style="fill: rgb(22,18,17)" /> - <polygon points="30,97 30,96 33,66 35,62 35,67 35,68 35,69 35,70 34,83 33,94" style="fill: rgb(225,227,224)" /> - <polygon points="337,259 337,258 343,257 341,262 337,261" style="fill: rgb(46,48,47)" /> - <polygon points="51,172 51,170 51,168 52,171 53,174 57,187 62,212 62,213 61,215 60,213 58,205 56,197" style="fill: rgb(157,161,164)" /> - <polygon points="197,71 197,68 197,67 197,66 198,66 199,66 200,66 201,66 202,66 203,66 204,66 205,66 205,71 199,71 198,71" style="fill: rgb(13,13,13)" /> - <polygon points="136,130 141,129 142,129 143,129 144,129 146,131 147,132 146,133 145,134 144,135 138,134 137,133" style="fill: rgb(79,45,44)" /> - <polygon points="32,106 34,95 35,96 36,97 36,100 36,101 35,104 33,106" style="fill: rgb(215,217,216)" /> - <polygon points="232,75 232,74 232,73 233,73 234,73 235,73 237,74 234,75 233,75" style="fill: rgb(13,13,13)" /> - <polygon points="91,167 91,166 91,165 91,164 107,156 103,171 100,178 99,179 92,170 91,168" style="fill: rgb(86,66,68)" /> - <polygon points="91,225 91,224 92,224 93,224 94,225 95,226 96,228 97,232 98,237 98,242 97,255 96,254 95,252 91,226" style="fill: rgb(12,23,29)" /> - <polygon points="87,110 87,109 89,93 90,88 91,86 97,78 97,79 96,83 95,87 88,111 87,111" style="fill: rgb(185,189,190)" /> - <polygon points="376,204 377,203 380,204 382,205 383,207 383,208 382,226" style="fill: rgb(86,66,68)" /> - <polygon points="300,201 301,200 305,200 305,201 305,203 305,204 300,202" style="fill: rgb(207,207,207)" /> - <polygon points="189,72 190,72 191,72 194,73 191,77 190,76 189,74" style="fill: rgb(12,10,11)" /> - <polygon points="189,21 190,20 195,18 196,18 198,19 192,22 190,22" style="fill: rgb(86,66,68)" /> - <polygon points="173,326 239,309 245,309 249,311 251,316 251,318 249,322 247,325 229,351 199,390 196,393 193,396 188,399 187,399 184,399 183,399 182,399 181,399 180,399 179,399 178,399" style="fill: rgb(195,153,154)" /> - <polygon points="116,140 117,138 123,133 125,132 125,138 123,140 117,141" style="fill: rgb(185,189,190)" /> - <polygon points="51,76 51,75 52,61 53,58 53,59 53,60 52,76 51,80" style="fill: rgb(215,217,216)" /> - <polygon points="390,399 391,398 395,397 396,397 399,397 399,398 396,399" style="fill: rgb(157,129,125)" /> - <polygon points="243,43 245,42 247,42 252,43 255,45 247,47 246,47" style="fill: rgb(22,18,17)" /> - <polygon points="33,41 33,40 34,24 35,15 36,13 36,14 36,15 35,36 34,46 33,42" style="fill: rgb(236,241,237)" /> - <polygon points="67,1 67,4 67,16 67,15 67,14 67,13 67,3 67,12 67,11 67,10 67,9 67,0 67,2 67,8 67,7 67,6 67,5 67,19 67,18 67,17" style="fill: rgb(157,161,164)" /> - <polygon points="296,234 306,231 307,231 300,242 296,238" style="fill: rgb(142,108,106)" /> - <polygon points="387,303 391,298 393,300 393,301 392,304 387,304" style="fill: rgb(48,32,32)" /> - <polygon points="144,87 144,86 158,72 174,60 189,50 191,49 218,39 233,40 239,41 244,42 253,45 261,49 262,50 263,59 261,62 257,63 158,85 148,87 147,87 146,87 145,87" style="fill: rgb(13,13,13)" /> - <polygon points="212,248 220,251 222,252 221,253 220,253 218,252 216,251 213,249" style="fill: rgb(157,129,125)" /> - <polygon points="144,293 144,292 150,289 151,289 151,290 151,292 148,294 144,295" style="fill: rgb(126,89,83)" /> - <polygon points="175,83 177,80 182,80 189,81 187,82 181,83" style="fill: rgb(12,7,11)" /> - <polygon points="174,80 185,86 185,87 185,88 183,88 178,87 174,83" style="fill: rgb(13,13,13)" /> - <polygon points="300,224 302,223 304,223 305,223 306,223 306,224 304,227 301,228 300,226" style="fill: rgb(86,66,68)" /> - <polygon points="104,172 104,168 104,164 105,161 108,157 110,155 112,154 113,154 114,154 115,154 118,155 106,173" style="fill: rgb(157,129,125)" /> - <polygon points="217,262 218,262 219,262 220,262 221,262 222,263 223,267 221,268 220,268 219,268 218,267 217,263" style="fill: rgb(142,108,106)" /> - <polygon points="93,251 143,330 144,332 147,341 128,379 124,386 122,389 120,391 93,252" style="fill: rgb(46,48,47)" /> - <polygon points="210,156 210,154 211,150 213,150 214,151 215,152 217,157 215,157 214,157" style="fill: rgb(126,89,83)" /> - <polygon points="97,210 98,209 99,208 100,208 100,211 100,212 99,212 98,212 97,211" style="fill: rgb(157,129,125)" /> - <polygon points="332,195 332,187 340,193 345,211 345,212 343,243 342,243 341,239" style="fill: rgb(68,83,90)" /> - <polygon points="29,51 32,44 32,50 31,51 29,52" style="fill: rgb(207,207,207)" /> - <polygon points="256,65 266,50 268,51 288,66 291,69 300,95 300,96 300,97 294,107 289,114 287,115 280,111" style="fill: rgb(16,16,16)" /> - <polygon points="279,190 282,183 283,182 284,185 284,186 284,187 282,189" style="fill: rgb(207,207,207)" /> - <polygon points="285,232 286,230 287,229 290,228 291,229 288,232" style="fill: rgb(142,108,106)" /> - <polygon points="70,106 70,110 70,98 70,102 70,107 70,111 70,99 70,103 70,108 70,100 70,104 70,105 70,109 70,101" style="fill: rgb(157,161,164)" /> - <polygon points="370,249 370,248 370,247 384,208 387,207 392,207 393,208 398,233 398,238 396,243 392,252 370,251" style="fill: rgb(46,48,47)" /> - <polygon points="248,389 249,385 251,378 255,372 256,373 256,374 254,379 253,381 249,388" style="fill: rgb(86,66,68)" /> - <polygon points="310,276 340,280 339,281 324,283 323,283 322,283 321,283 320,283 317,283" style="fill: rgb(185,189,190)" /> - <polygon points="226,336 227,336 228,336 229,336 233,336 243,343 247,346 251,352 252,354 253,357 253,359" style="fill: rgb(86,66,68)" /> - <polygon points="253,249 253,248 256,249 258,250 258,251 256,251 255,251" style="fill: rgb(31,26,23)" /> - <polygon points="288,44 288,43 288,41 289,40 295,37 298,37 300,40 299,41 294,44 292,45 290,45" style="fill: rgb(254,254,254)" /> - <polygon points="212,245 220,244 224,244 240,263 240,265 234,263" style="fill: rgb(126,89,83)" /> - <polygon points="0,213 7,186 7,192 6,199 4,207 3,210 2,212 1,213" style="fill: rgb(225,227,224)" /> - <polygon points="394,186 396,182 399,182 399,184 399,185 399,186 399,187 396,187" style="fill: rgb(157,161,164)" /> - <polygon points="34,12 34,11 34,10 34,9 36,6 36,8 36,11 36,12 35,14" style="fill: rgb(229,235,235)" /> - <polygon points="388,120 391,118 395,116 395,117 394,121 391,122 389,121" style="fill: rgb(215,217,216)" /> - <polygon points="146,14 146,13 168,2 170,1 181,0 182,0 183,0 190,0 191,1 191,7 191,10 191,12 150,17" style="fill: rgb(46,48,47)" /> - <polygon points="179,272 179,270 182,268 187,265 187,266 184,271 182,272 180,272" style="fill: rgb(86,66,68)" /> - <polygon points="337,183 349,149 350,148 356,147 362,148 367,150 368,151 369,153 369,154 346,194 345,194 344,194 342,192 341,191 340,190 338,186" style="fill: rgb(157,129,125)" /> - <polygon points="274,166 274,164 277,160 278,161 279,163 279,168 279,169 278,169 277,169" style="fill: rgb(46,48,47)" /> - <polygon points="116,34 116,33 116,27 117,26 124,29 117,36 116,35 116,27 117,26 124,29 117,36 116,35 116,27 117,26 124,29 117,36 116,35 116,27" style="fill: rgb(86,66,68)" /> - <polygon points="382,227 383,220 384,221 384,230 384,234 383,233 382,229" style="fill: rgb(86,66,68)" /> - <polygon points="347,175 347,174 347,171 348,167 351,165 352,165 351,168" style="fill: rgb(157,161,164)" /> - <polygon points="222,6 223,4 224,3 232,0 234,0 234,1 229,4" style="fill: rgb(142,108,106)" /> - <polygon points="58,88 58,87 59,80 60,78 63,77 63,84 63,86 62,87 58,89" style="fill: rgb(185,189,190)" /> - <polygon points="383,202 383,201 392,202 396,204 399,207 399,209 399,210 395,213 384,204" style="fill: rgb(31,26,23)" /> - <polygon points="36,128 37,124 38,122 41,122 43,123 44,126 42,129" style="fill: rgb(251,251,251)" /> - <polygon points="281,42 281,38 283,37 286,36 287,36 287,39" style="fill: rgb(142,108,106)" /> - <polygon points="381,28 382,28 383,28 387,28 384,28 385,28 386,28 388,28 389,28 390,28 391,28 392,28 393,28 394,28" style="fill: rgb(207,207,207)" /> - <polygon points="76,149 76,157 76,142 76,150 76,143 76,151 76,144 76,152 76,145 76,153 76,146 76,154 76,147 76,155 76,148 76,156" style="fill: rgb(215,217,216)" /> - <polygon points="70,34 71,30 72,27 72,35 72,38 72,39 70,35" style="fill: rgb(227,233,231)" /> - <polygon points="125,140 129,131 130,131 130,137 130,138 130,139 126,140" style="fill: rgb(142,108,106)" /> - <polygon points="167,146 177,146 177,147 169,147" style="fill: rgb(157,161,164)" /> - <polygon points="201,29 202,27 205,24 217,19 234,13 237,12 240,12 255,17 251,22 244,25 233,29 218,34 217,34 216,34 208,34 204,32 201,30" style="fill: rgb(142,108,106)" /> - <polygon points="389,80 395,78 396,78 398,79 399,80 399,81 398,84" style="fill: rgb(142,108,106)" /> - <polygon points="367,272 368,271 369,271 370,271 375,271 375,273 374,273 373,273 372,273 371,273 369,273" style="fill: rgb(185,189,190)" /> - <polygon points="105,174 107,174 108,174 110,176 112,178 164,234 164,235 163,239 161,241 158,241 123,235 117,229 105,175" style="fill: rgb(195,153,154)" /> - <polygon points="268,278 273,277 275,279 276,280 277,282 277,283 277,284 276,284 274,283 270,280" style="fill: rgb(195,153,154)" /> - <polygon points="218,213 228,201 230,201 231,201 244,221 254,241 254,243 253,245 250,251 248,251 247,250 218,214" style="fill: rgb(126,89,83)" /> - <polygon points="312,149 312,145 312,142 313,140 314,139 359,96 363,96 364,97 364,100 363,144 341,174 333,183 324,180 323,179 313,163 312,152" style="fill: rgb(157,161,164)" /> - <polygon points="349,108 354,99 355,99 355,122 355,123 354,123 353,120" style="fill: rgb(157,161,164)" /> - <polygon points="364,288 365,287 366,287 367,287 368,287 369,287 370,287 371,287 372,287 373,287 374,290 366,292 365,291" style="fill: rgb(86,66,68)" /> - <polygon points="221,161 222,160 223,160 224,161 224,165 223,165" style="fill: rgb(22,18,17)" /> - <polygon points="277,234 279,233 285,233 287,233 290,234 284,234" style="fill: rgb(185,189,190)" /> - <polygon points="362,95 365,88 380,82 385,81 393,84 395,85 395,86 392,90 379,106 368,119 367,120" style="fill: rgb(126,89,83)" /> - <polygon points="300,261 301,260 302,260 307,264 305,265 304,265 303,265 301,263" style="fill: rgb(157,129,125)" /> - <polygon points="90,355 91,352 98,336 99,334 103,329 104,328 105,327 108,324 109,323 110,322 113,320 116,318 119,316 121,316 133,329 133,331 133,332 133,333 124,379 121,387 119,391 115,395 113,396 112,396" style="fill: rgb(12,23,29)" /> - <polygon points="0,95 0,94 1,94 2,94 3,95 3,96 3,97 3,98" style="fill: rgb(225,227,224)" /> - <polygon points="316,188 318,176 330,183 329,184 324,188 320,189 317,189 316,189" style="fill: rgb(46,48,47)" /> - <polygon points="151,25 151,23 157,17 159,15 160,17 154,25 153,26 151,27" style="fill: rgb(157,129,125)" /> - <polygon points="243,150 245,149 259,144 258,153 257,153 255,153 254,153 246,151" style="fill: rgb(48,32,32)" /> - <polygon points="113,141 113,140 113,139 113,138 117,131 120,127 121,126 122,125 125,123 130,121 136,120 143,119 152,120 155,124 154,125" style="fill: rgb(195,153,154)" /> - <polygon points="351,260 352,259 353,258 354,261 354,264 352,264 351,263" style="fill: rgb(48,32,32)" /> - <polygon points="185,181 186,180 195,174 196,175 195,176 187,181" style="fill: rgb(79,45,44)" /> - <polygon points="232,233 239,240 241,242 243,245 236,238 235,237 234,236" style="fill: rgb(142,108,106)" /> - <polygon points="346,176 348,172 349,171 350,170 351,169 352,168 390,163 395,164 397,165 398,166 399,171 399,176 393,188 392,189 359,194 354,192 351,189 347,184" style="fill: rgb(157,129,125)" /> - <polygon points="15,140 15,139 15,138 16,141 24,173 24,174 24,175 23,204 22,216 20,202 15,143 15,142 15,141" style="fill: rgb(215,217,216)" /> - <polygon points="233,162 236,161 241,161 242,161 243,161 244,161 244,162 235,167" style="fill: rgb(48,32,32)" /> - <polygon points="119,246 119,245 122,247 123,248 123,249 123,252 121,251" style="fill: rgb(86,66,68)" /> - <polygon points="260,227 269,220 272,219 269,226 267,228 261,231" style="fill: rgb(215,217,216)" /> - <polygon points="44,130 44,129 44,128 46,132 47,136 47,137 46,136" style="fill: rgb(236,241,237)" /> - <polygon points="58,45 59,45 60,45 62,46 59,60 58,61" style="fill: rgb(207,207,207)" /> - <polygon points="382,160 385,157 387,163 387,164 387,165 384,162 383,161" style="fill: rgb(157,129,125)" /> - <polygon points="224,155 226,156 228,157 227,161 226,160 225,159" style="fill: rgb(22,18,17)" /> - <polygon points="48,51 50,53 50,61 50,63 49,63" style="fill: rgb(229,235,235)" /> - <polygon points="344,216 344,208 347,206 348,207 349,210 349,211 347,220" style="fill: rgb(46,48,47)" /> - <polygon points="260,222 265,218 267,217 267,218 267,219 263,223" style="fill: rgb(236,241,237)" /> - <polygon points="224,33 226,32 229,31 230,31 233,33" style="fill: rgb(207,207,207)" /> - <polygon points="74,217 75,218 76,219 77,221 76,223 74,220" style="fill: rgb(207,207,207)" /> - <polygon points="52,251 53,250 72,233 77,229 80,227 82,226 83,226 83,227 70,295 67,310 66,307 52,253" style="fill: rgb(46,48,47)" /> - <polygon points="308,106 311,101 314,100 329,97 351,95 352,95 353,96 353,97 351,106 345,107 338,108 314,109 313,109 312,109" style="fill: rgb(185,189,190)" /> - <polygon points="199,116 200,116 213,121 218,123 222,126 222,129 214,127 200,120 199,119" style="fill: rgb(86,66,68)" /> - <polygon points="284,178 286,174 288,172 289,173 290,175 288,178 286,179 285,179" style="fill: rgb(157,161,164)" /> - <polygon points="147,278 147,277 148,277 149,277 154,279 160,282 161,283 158,285 153,283" style="fill: rgb(48,32,32)" /> - <polygon points="29,169 29,168 29,167 29,166 29,165 29,159 29,156 29,155 29,154 29,153 29,151 29,150 64,211 64,212 64,213 63,215 61,218 37,237 36,237 34,236 31,231 29,212" style="fill: rgb(207,207,207)" /> - <polygon points="43,114 46,112 50,110 55,109 56,110 54,113 50,114 44,114" style="fill: rgb(157,161,164)" /> - <polygon points="111,231 112,229 113,229 115,231 114,232 112,232" style="fill: rgb(86,66,68)" /> - <polygon points="263,182 264,181 267,179 269,178 270,179 270,180 267,184 265,185 264,185 263,183" style="fill: rgb(142,108,106)" /> - <polygon points="72,141 73,133 74,128 74,133 74,134 74,135 73,140" style="fill: rgb(229,235,235)" /> - <polygon points="235,76 240,72 241,76 242,82 240,82 236,79 235,78" style="fill: rgb(12,7,11)" /> - <polygon points="260,225 268,213 270,212 271,218 271,219 268,225 267,227 262,227 261,227 260,226" style="fill: rgb(227,233,233)" /> - <polygon points="353,352 354,351 363,349 368,348 389,344 395,343 396,343 397,343 398,343 399,343 399,344 399,345 397,347 362,362 361,362 358,360 355,356 353,353" style="fill: rgb(142,108,106)" /> - <polygon points="32,137 32,136 40,132 41,148 41,150 37,153 34,154 32,143" style="fill: rgb(251,251,251)" /> - <polygon points="178,232 179,231 183,229 186,229 184,231 181,232" style="fill: rgb(79,45,44)" /> - <polygon points="14,181 14,180 14,179 17,172 18,180 18,181 16,183 15,183" style="fill: rgb(225,227,224)" /> - <polygon points="74,174 74,170 75,164 77,162 78,163 78,178 78,179 78,180 77,187 76,187 74,175" style="fill: rgb(157,129,125)" /> - <polygon points="368,216 369,215 370,215 373,215 374,216 374,218 374,220 374,221 370,224 369,224 368,224" style="fill: rgb(142,108,106)" /> - <polygon points="239,1 240,0 244,0 245,0 246,0 241,2 240,2" style="fill: rgb(157,161,164)" /> - <polygon points="169,319 172,316 174,316 172,319" style="fill: rgb(195,153,154)" /> - <polygon points="318,13 319,11 330,6 332,7 332,8 332,9 330,16 329,16 328,16" style="fill: rgb(207,207,207)" /> - <polygon points="324,191 324,190 324,189 327,188 331,189 332,190 331,191 330,192 328,192" style="fill: rgb(157,129,125)" /> - <polygon points="170,19 170,17 170,14 171,12 172,11 171,21 170,21 170,14 171,12 172,11 171,21 170,21 170,14 171,12 172,11 171,21 170,21 170,14" style="fill: rgb(68,83,90)" /> - <polygon points="72,174 72,172 79,162 84,159 86,160 88,162 99,183 100,186 101,191 104,215 104,216 103,218 102,220 100,221 94,222 88,217 87,216 77,205 76,203 75,201 72,183" style="fill: rgb(142,108,106)" /> - <polygon points="181,104 183,104 185,105 186,106 187,108 188,110 184,109 183,108" style="fill: rgb(79,45,44)" /> - <polygon points="106,150 107,144 108,143 109,142 110,142 115,143 120,145 121,147 120,150 119,152" style="fill: rgb(157,129,125)" /> - <polygon points="290,111 295,105 296,107 295,109 293,112 290,113" style="fill: rgb(22,18,17)" /> - <polygon points="21,163 21,162 21,161 22,166 22,171 22,172 21,165" style="fill: rgb(227,233,231)" /> - <polygon points="183,144 186,133 192,134 194,140 188,143" style="fill: rgb(31,26,23)" /> - <polygon points="70,31 70,29 70,27 70,25 71,25 71,26 71,32 71,33 70,33" style="fill: rgb(227,233,233)" /> - <polygon points="204,199 206,199 210,199 212,200 213,201 204,200" style="fill: rgb(79,45,44)" /> - <polygon points="240,334 241,333 242,333 243,333 244,333 245,333 246,333 247,333 248,333 250,334 248,335 247,335 246,335" style="fill: rgb(86,66,68)" /> - <polygon points="31,119 32,120 35,124 35,125 35,126 34,128 33,128 32,128 31,122" style="fill: rgb(215,217,216)" /> - <polygon points="206,156 215,139 229,135 255,140 255,146 225,170 212,168 211,167" style="fill: rgb(22,18,17)" /> - <polygon points="367,306 367,301 379,302 380,306 374,307 368,307" style="fill: rgb(46,48,47)" /> - <polygon points="120,153 120,152 120,151 121,148 122,146 123,146 124,147 129,155 127,155 123,154" style="fill: rgb(142,108,106)" /> - <polygon points="346,200 347,196 363,196 366,198 370,201 372,203 373,206 375,215 376,222 376,236 375,239 369,247 361,247 360,247 359,247 356,247 355,247 352,247 347,245 346,240" style="fill: rgb(68,83,90)" /> - <polygon points="27,115 39,0 41,0 45,36 47,55 47,58 47,59 47,60 47,61 47,62 47,63 47,65 47,66 47,117 44,117 41,117 30,116" style="fill: rgb(185,189,190)" /> - <polygon points="4,144 5,135 7,122 8,120 10,120 10,130 10,132 10,133 7,141 5,146" style="fill: rgb(225,227,224)" /> - <polygon points="208,192 208,190 211,188 215,187 217,188 221,192 218,194 217,194 216,194 214,194 213,194 212,194" style="fill: rgb(195,153,154)" /> - <polygon points="186,101 187,101 190,107 189,107 187,105 186,103" style="fill: rgb(22,18,17)" /> - <polygon points="271,134 272,132 273,132 276,134 276,137 275,138 272,136" style="fill: rgb(215,217,216)" /> - <polygon points="260,234 271,223 273,221 282,220 284,226 284,232 274,239 273,239 270,238 265,236" style="fill: rgb(157,161,164)" /> - <polygon points="82,191 82,190 82,189 82,188 83,186 84,185 90,181 92,180 95,184 95,185 95,186 90,200 89,200 86,200 85,199 84,198 83,197 82,195" style="fill: rgb(126,89,83)" /> - <polygon points="70,42 70,40 71,36 71,42 70,45" style="fill: rgb(229,235,235)" /> - <polygon points="138,97 144,92 153,86 167,85 169,87 171,89 172,90 173,91 142,103 139,100 138,99" style="fill: rgb(48,32,32)" /> - <polygon points="34,229 36,225 37,224 48,225 47,226 43,229 40,231 35,234 34,231" style="fill: rgb(225,227,224)" /> - <polygon points="296,105 300,99 301,101 301,102 301,103 297,107" style="fill: rgb(16,16,16)" /> - <polygon points="11,130 11,129 11,128 11,124 11,132 11,131 11,125 11,134 11,133 11,126 11,122 11,135 11,127 11,123" style="fill: rgb(236,241,237)" /> - <polygon points="116,150 117,148 118,146 120,146 120,147 119,150 118,150" style="fill: rgb(142,108,106)" /> - <polygon points="179,261 180,258 184,258 186,260 184,263 183,264 182,264 181,264" style="fill: rgb(157,129,125)" /> - <polygon points="209,394 209,392 218,370 220,368 224,366 225,366 229,369 230,371 230,374 230,375 227,382 226,384 225,385 219,391 215,394 213,394 212,394 211,394 210,394" style="fill: rgb(12,23,29)" /> - <polygon points="100,262 152,319 154,322 155,324 153,328 152,330 124,309 119,305 118,304 117,303 112,295 107,286 104,280 100,264" style="fill: rgb(79,45,44)" /> - <polygon points="66,110 66,106 66,103 68,108 67,112 66,111" style="fill: rgb(229,235,235)" /> - <polygon points="108,139 108,137 110,132 111,131 111,132 111,133 111,134 110,136" style="fill: rgb(31,26,23)" /> - <polygon points="222,216 223,216 224,216 225,216 228,216 232,218 235,220 239,223 241,225 241,228" style="fill: rgb(126,89,83)" /> - <polygon points="50,188 50,181 51,179 52,184 51,188 50,189" style="fill: rgb(236,241,237)" /> - <polygon points="268,177 269,174 273,170 274,170 275,175 271,180" style="fill: rgb(68,83,90)" /> - <polygon points="48,122 49,118 51,120 51,123 51,127" style="fill: rgb(207,207,207)" /> - <polygon points="201,190 207,181 208,180 209,179 211,182 211,183 205,190" style="fill: rgb(142,108,106)" /> - <polygon points="72,207 72,206 74,211 75,214 75,215 73,221 72,217" style="fill: rgb(157,161,164)" /> - <polygon points="231,181 243,186 238,186 236,185 233,183" style="fill: rgb(79,45,44)" /> - <polygon points="386,229 387,228 393,228 390,232 387,230" style="fill: rgb(157,129,125)" /> - <polygon points="120,156 121,156 123,156 132,160 135,162 136,163 137,165 137,166 136,167 135,167 122,158" style="fill: rgb(142,108,106)" /> - <polygon points="126,136 126,135 126,134 126,133 126,132 129,130 128,134 127,136 126,137" style="fill: rgb(157,129,125)" /> - <polygon points="283,122 286,120 287,120 288,121 287,131 285,135 284,135" style="fill: rgb(142,108,106)" /> - <polygon points="145,301 153,291 205,249 208,249 209,249 210,249 215,253 217,260 218,275 218,276 217,277 214,279 208,282 188,291 157,304 152,306 151,306 147,305" style="fill: rgb(195,153,154)" /> - <polygon points="180,97 181,96 194,93 229,90 230,90 231,90 239,92 244,96 251,112 241,118 226,123 190,106 181,100" style="fill: rgb(31,26,23)" /> - <polygon points="314,232 315,232 325,233 326,234 318,235" style="fill: rgb(207,207,207)" /> - <polygon points="222,249 223,248 228,254 226,254 223,252" style="fill: rgb(126,89,83)" /> - <polygon points="143,328 145,331 147,334 148,337 148,338 147,340 145,335 143,329" style="fill: rgb(31,26,23)" /> - <polygon points="228,123 231,121 244,131 244,132 241,133 240,133 230,125" style="fill: rgb(31,26,23)" /> - <polygon points="42,186 43,186 47,188 48,189 49,192 46,191" style="fill: rgb(229,235,235)" /> - <polygon points="296,190 299,183 300,181 301,180 317,177 317,182 316,186 306,197 305,198 301,198 300,198 299,198 297,196" style="fill: rgb(142,108,106)" /> - <polygon points="53,119 53,118 54,118 55,118 62,119 65,138 65,153 64,152 54,125 53,121" style="fill: rgb(207,207,207)" /> - <polygon points="72,118 72,126 72,122 72,119 72,115 72,127 72,123 72,120 72,116 72,128 72,124 72,117 72,125 72,121" style="fill: rgb(243,243,243)" /> - <polygon points="290,127 292,122 293,121 296,119 297,120 298,128 297,130 295,131 293,131 292,130" style="fill: rgb(185,189,190)" /> - <polygon points="256,90 257,90 258,90 259,90 260,90 261,90 262,90 263,90 263,91 262,91 261,91 260,91 259,91 258,91 257,91 256,91" style="fill: rgb(12,10,11)" /> - <polygon points="274,240 275,237 279,236 280,236 281,236 282,236 283,236 284,236 285,236 277,241" style="fill: rgb(157,161,164)" /> - <polygon points="42,14 42,10 42,7 42,5 42,0 43,0 45,0 46,0 47,4 48,9 49,16 49,18 48,45 47,54 46,54 42,53" style="fill: rgb(225,227,224)" /> - <polygon points="266,186 268,182 277,174 278,174 279,174 280,176 280,178 280,179 279,182 278,185 277,187 276,189 271,192 270,192 269,192" style="fill: rgb(157,161,164)" /> - <polygon points="299,297 299,296 300,299 301,304 299,305" style="fill: rgb(46,48,47)" /> - <polygon points="355,250 356,249 363,248 366,249 364,251 361,252 358,251" style="fill: rgb(68,83,90)" /> - <polygon points="0,262 28,249 78,226 83,224 85,224 85,225 63,370 61,377 60,378 59,378 58,378 0,331" style="fill: rgb(68,83,90)" /> - <polygon points="277,179 278,170 281,170 281,171 281,174 281,175 278,181 277,180" style="fill: rgb(157,129,125)" /> - <polygon points="21,107 21,104 22,101 23,100 23,108" style="fill: rgb(236,241,237)" /> - <polygon points="259,0 260,0 261,0 262,0 263,0 275,8 277,10 275,18 273,18 264,16 262,14 261,13" style="fill: rgb(68,83,90)" /> - <polygon points="276,138 277,127 301,132 303,140 309,176 308,178 297,182 296,182 290,180 289,179 288,177 279,155 276,139" style="fill: rgb(185,189,190)" /> - <polygon points="264,199 265,198 272,197 276,198 277,200 277,201 276,202 274,202 266,201 264,200" style="fill: rgb(185,189,190)" /> - <polygon points="194,197 194,196 195,195 199,192 204,198 199,199 197,199 196,199 195,199 194,198" style="fill: rgb(142,108,106)" /> - <polygon points="259,24 260,23 263,22 301,12 344,1 351,1 343,10 341,12 338,14 336,15 324,21 316,25 310,28 274,39 273,39 271,39 263,38 261,37" style="fill: rgb(185,189,190)" /> - <polygon points="217,80 218,77 221,77 232,80 237,85 234,85 227,85 226,85 222,84 219,83 218,82" style="fill: rgb(16,16,16)" /> - <polygon points="337,107 343,103 344,103 345,104 346,105 345,106 341,107" style="fill: rgb(157,161,164)" /> - <polygon points="314,225 314,222 316,215 318,211 319,212 328,226 328,227 314,226" style="fill: rgb(185,189,190)" /> - <polygon points="288,81 289,81 292,82 293,83 293,84 292,85 291,85 288,83" style="fill: rgb(19,13,13)" /> - <polygon points="369,251 369,250 371,249 384,250 389,251 391,252 391,256 382,256 371,253" style="fill: rgb(157,129,125)" /> - <polygon points="210,0 213,0 215,1 214,4 213,6 212,6 210,3" style="fill: rgb(126,89,83)" /> - <polygon points="118,305 122,306 129,310 132,312 142,319 151,327 152,329 149,336 148,336 128,318 127,317 126,316 125,315 124,314 123,313" style="fill: rgb(48,32,32)" /> - <polygon points="40,186 41,186 43,187 45,189 48,192 49,193 50,195 49,195 48,195 45,194" style="fill: rgb(227,233,231)" /> - <polygon points="261,112 265,114 267,117 267,118 264,117 262,115 261,113" style="fill: rgb(19,13,13)" /> - <polygon points="284,126 284,123 285,122 285,126 285,127 285,128 285,129 284,130" style="fill: rgb(142,108,106)" /> - <polygon points="20,27 23,21 23,23 23,25 23,26 21,46 20,29" style="fill: rgb(243,243,243)" /> - <polygon points="376,24 397,21 398,21 399,25 398,26 396,27 395,27 394,27 393,27 392,27 379,27 378,27 377,27 376,26" style="fill: rgb(251,251,251)" /> - <polygon points="231,162 232,161 235,160 240,159 250,158 251,158 252,158 253,158 254,158 255,158 261,158 267,158 268,160 256,162 255,162 232,162" style="fill: rgb(46,48,47)" /> - <polygon points="227,124 228,124 229,124 240,130 241,131 241,132 239,133 238,133 237,133" style="fill: rgb(48,32,32)" /> - <polygon points="297,248 299,249 305,252 301,254 298,253 297,249" style="fill: rgb(142,108,106)" /> - <polygon points="225,365 226,365 231,368 231,370 231,371 231,372 231,373" style="fill: rgb(12,23,29)" /> - <polygon points="26,111 26,110 26,109 27,107 28,107 28,111 28,114 26,114 26,110 26,109 27,107 28,107 28,111 28,114 26,114 26,110" style="fill: rgb(185,189,190)" /> - <polygon points="342,45 343,44 357,34 362,31 364,30 367,29 368,29 365,32 364,33 346,46 344,46" style="fill: rgb(126,89,83)" /> - <polygon points="55,68 55,59 56,65 56,76 56,77 55,69" style="fill: rgb(185,189,190)" /> - <polygon points="315,27 317,26 319,27 320,29 320,30 318,31 317,31 316,30" style="fill: rgb(251,251,251)" /> - <polygon points="261,223 265,220 267,220 267,221 267,222 263,225 261,224" style="fill: rgb(229,235,235)" /> - <polygon points="49,0 51,0 53,0 54,1 57,36 57,41 57,57 57,58 57,59 57,60 57,61 57,62 57,63 55,53 53,40 52,31 49,2" style="fill: rgb(185,189,190)" /> - <polygon points="175,151 188,136 189,136 196,138 198,139 199,144 198,153 189,153 181,152" style="fill: rgb(48,32,32)" /> - <polygon points="364,293 364,292 364,291 367,292 368,299 365,300" style="fill: rgb(126,89,83)" /> - <polygon points="56,20 56,19 56,18 56,17 56,16 57,12 58,11 58,14 58,16 56,21" style="fill: rgb(207,207,207)" /> - <polygon points="115,140 115,139 115,138 116,137 121,133 123,132 124,132 121,135" style="fill: rgb(195,153,154)" /> - <polygon points="144,307 145,306 193,292 194,292 191,294 158,315 147,310 145,309 144,308" style="fill: rgb(142,108,106)" /> - <polygon points="194,290 202,286 203,286 201,289 197,291 195,292 194,291" style="fill: rgb(126,89,83)" /> - <polygon points="182,134 185,133 186,135 186,140 185,142 184,142 182,136" style="fill: rgb(22,18,17)" /> - <polygon points="265,5 265,1 265,0 267,0 269,0 271,0 275,0 278,5 278,10 275,12 271,12 270,12 265,9" style="fill: rgb(68,83,90)" /> - <polygon points="40,187 55,196 57,204 58,216 57,216 54,213 43,199" style="fill: rgb(225,227,224)" /> - <polygon points="218,2 218,1 219,0 220,0 220,2 220,3 219,4 218,4" style="fill: rgb(46,48,47)" /> - <polygon points="74,223 74,221 75,221 77,222 77,223 77,224 75,224 74,224" style="fill: rgb(215,217,216)" /> - <polygon points="372,244 377,234 379,234 379,235 379,244 373,244" style="fill: rgb(46,48,47)" /> - <polygon points="36,57 36,49 36,47 37,17 38,9 38,38 38,39 36,59" style="fill: rgb(227,233,231)" /> - <polygon points="10,140 12,130 13,136 13,139 13,140 13,141 13,142 11,144 10,141" style="fill: rgb(243,243,243)" /> - <polygon points="17,106 17,104 17,102 18,99 19,97 20,112 17,112" style="fill: rgb(225,227,224)" /> - <polygon points="305,168 307,158 308,158 309,159 310,160 311,166 311,174 310,174 309,174 308,174 306,174 305,169" style="fill: rgb(68,83,90)" /> - <polygon points="170,23 170,22 172,12 172,19 172,20 172,21 172,22 171,24 170,24" style="fill: rgb(142,108,106)" /> - <polygon points="60,18 60,17 60,10 61,11 61,18 61,20" style="fill: rgb(68,83,90)" /> - <polygon points="305,267 309,265 311,264 313,264 314,264 315,264 316,264 337,265 350,267 350,273 349,278 348,279 339,280 319,282 317,282 316,281 311,276 310,275 306,269" style="fill: rgb(185,189,190)" /> - <polygon points="289,123 289,119 292,116 298,116 299,117 297,122 295,124 294,125 289,127" style="fill: rgb(195,153,154)" /> - <polygon points="282,201 285,200 286,200 288,200 288,201 288,202 283,202 282,202" style="fill: rgb(68,83,90)" /> - <polygon points="278,240 279,237 281,237 282,237 283,237 284,237 284,238 284,239 282,240 280,241 279,241 278,241" style="fill: rgb(157,161,164)" /> - <polygon points="36,240 39,238 40,238 40,241 40,243 38,243 36,241" style="fill: rgb(126,89,83)" /> - <polygon points="299,258 299,256 299,254 305,256 305,257 300,259 299,259 299,254 305,256 305,257 300,259 299,259 299,254 305,256 305,257 300,259 299,259 299,254 305,256" style="fill: rgb(157,161,164)" /> - <polygon points="228,362 228,361 235,368 234,368 232,367 229,364 228,363 228,361 235,368 234,368 232,367 229,364 228,363 228,361 235,368" style="fill: rgb(86,66,68)" /> - <polygon points="64,100 67,99 67,100 65,108" style="fill: rgb(227,233,231)" /> - <polygon points="209,158 210,158 211,158 212,158 213,158 214,158 216,158 220,159 220,160 215,167 211,171 210,171" style="fill: rgb(48,32,32)" /> - <polygon points="35,45 35,41 35,37 36,32 36,35 36,36" style="fill: rgb(229,235,235)" /> - <polygon points="93,126 93,125 94,120 95,118 98,119 98,122 97,123 93,127" style="fill: rgb(157,129,125)" /> - <polygon points="384,139 384,137 384,136 385,128 386,121 399,127 399,128" style="fill: rgb(157,129,125)" /> - <polygon points="45,117 46,114 51,113 54,114 54,117 53,124 52,128" style="fill: rgb(185,189,190)" /> - <polygon points="36,5 37,4 37,13" style="fill: rgb(229,235,235)" /> - <polygon points="94,241 95,240 96,242 96,243 96,244 94,245" style="fill: rgb(22,18,17)" /> - <polygon points="379,282 381,280 382,280 383,280 384,281 384,282" style="fill: rgb(126,89,83)" /> - <polygon points="23,134 23,133 23,130 24,138 24,143 23,143" style="fill: rgb(225,227,224)" /> - <polygon points="175,324 177,323 179,322 181,321 201,312 218,306 224,304 227,303 232,302 234,302 252,305 258,307 261,308 263,309 265,310 265,311 183,325 182,325 181,325 180,325 178,325" style="fill: rgb(195,153,154)" /> - <polygon points="334,216 334,215 334,212 336,216 336,218 336,219 335,221 334,217" style="fill: rgb(157,129,125)" /> - <polygon points="337,26 338,26 339,26 340,26 341,26 342,26 343,26 344,26 359,27 364,28 362,29 360,30 349,33 345,34" style="fill: rgb(185,189,190)" /> - <polygon points="311,202 312,198 316,195 317,195 316,198 314,203 313,203" style="fill: rgb(227,233,233)" /> - <polygon points="191,335 193,334 246,309 290,297 291,298 352,373 356,378 359,383 363,392 364,397 364,399 363,399 361,399 336,399 335,399 327,399 326,399 325,399 324,399 323,399 193,336" style="fill: rgb(142,108,106)" /> - <polygon points="298,126 298,122 298,119 301,124 301,126 299,127" style="fill: rgb(142,108,106)" /> - <polygon points="36,170 37,170 39,175 39,176 39,177 39,178 38,179 37,179 36,175" style="fill: rgb(225,227,224)" /> - <polygon points="304,122 304,121 305,120 306,120 306,122 306,123 305,124 304,124 304,121 305,120 306,120 306,122 306,123" style="fill: rgb(157,161,164)" /> - <polygon points="168,226 170,224 173,223 174,223 170,227" style="fill: rgb(86,66,68)" /> - <polygon points="317,150 318,147 327,148 327,150 327,152 327,154 327,155 324,156 321,156 320,156 317,153" style="fill: rgb(157,129,125)" /> - <polygon points="245,90 246,91 249,94 255,102 256,104 256,106 256,107 256,108 250,103 248,99" style="fill: rgb(22,18,17)" /> - <polygon points="328,104 328,102 328,100 328,99 329,98 334,97 341,96 342,98 342,100 342,101 341,102 338,103 331,104" style="fill: rgb(185,189,190)" /> - <polygon points="66,149 66,143 67,143 68,144 68,145 68,149 68,150 66,150 66,143 67,143 68,144 68,145 68,149 68,150 66,150 66,143 67,143 68,144 68,145 68,149 68,150 66,150" style="fill: rgb(225,227,224)" /> - <polygon points="181,103 182,98 183,99 186,105" style="fill: rgb(48,32,32)" /> - <polygon points="70,16 70,15 70,14 70,13 70,12 70,11 70,9 70,4 71,7 71,16 71,24 70,24" style="fill: rgb(227,233,231)" /> - <polygon points="196,218 197,217 200,217 200,219 200,220 199,220 197,219" style="fill: rgb(157,129,125)" /> - <polygon points="223,274 232,270 240,272 244,274 247,277 245,279 244,279 232,277" style="fill: rgb(195,153,154)" /> - <polygon points="262,170 263,169 265,169 268,172 264,175 263,174" style="fill: rgb(126,89,83)" /> - <polygon points="132,156 135,152 137,152 137,153 136,157" style="fill: rgb(142,108,106)" /> - <polygon points="359,166 368,162 370,162 379,166 378,170 376,170 375,170 373,170 368,169 364,168 361,167" style="fill: rgb(126,89,83)" /> - <polygon points="180,126 181,126 182,126 183,126 184,126 185,126 186,126 191,126 194,128 196,132 193,131" style="fill: rgb(79,45,44)" /> - <polygon points="337,174 337,171 337,167 337,163 337,162 337,158 337,157 337,156 337,146 339,145 341,145 341,171 340,174 339,174 338,174" style="fill: rgb(157,129,125)" /> - <polygon points="371,116 373,113 376,110 378,108 378,112 376,117 373,118" style="fill: rgb(157,161,164)" /> - <polygon points="34,144 36,138 40,135 43,133 47,164 47,165 46,165 45,164 34,145" style="fill: rgb(236,241,237)" /> - <polygon points="283,154 284,144 287,149 287,150 287,153 287,155 287,156 286,157 284,158 283,156" style="fill: rgb(157,161,164)" /> - <polygon points="166,183 166,182 167,182 168,182 169,182 170,182 171,182 172,182 173,182 174,182 175,183 170,183 169,183 168,183 167,183" style="fill: rgb(126,89,83)" /> - <polygon points="305,114 312,113 313,113 314,113 317,114 313,115 308,115" style="fill: rgb(157,161,164)" /> - <polygon points="0,374 1,375 3,378 8,386 8,387 7,388 5,385 1,377 0,375" style="fill: rgb(46,48,47)" /> - <polygon points="74,60 74,58 74,52 74,50 74,56 74,54 74,48 74,59 74,57 74,61 74,51 74,49 74,55 74,53" style="fill: rgb(207,207,207)" /> - <polygon points="254,252 255,252 258,252 261,254 263,256 265,258 266,259 270,265 270,266 267,267 266,267 264,266 263,265 256,258 255,257 254,256" style="fill: rgb(12,23,29)" /> - <polygon points="60,24 61,26 62,28 61,31 60,29" style="fill: rgb(185,189,190)" /> -</svg> \ No newline at end of file diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/gunit/test_002.svg b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/gunit/test_002.svg deleted file mode 100644 index 9f84bffb62..0000000000 --- a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/gunit/test_002.svg +++ /dev/null @@ -1,1027 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<svg xmlns="http://www.w3.org/2000/svg" width="460" height="460" version="1.1" baseProfile="full"> - <polygon points="154,273 165,246 166,245 225,200 228,203 257,241 257,242 257,243 256,244 204,278 178,287 177,287 175,286 166,281" style="fill: rgb(138,98,90)" /> - <polygon points="102,268 103,267 104,267 105,269 106,271 107,275 108,295 110,426 110,427 110,459 109,459" style="fill: rgb(115,119,120)" /> - <polygon points="224,349 225,348 256,357 257,358 257,359 244,366 232,362 229,361 224,358" style="fill: rgb(117,80,74)" /> - <polygon points="121,243 121,242 124,248 125,252 125,255 124,260 123,261 122,261 121,261" style="fill: rgb(117,80,74)" /> - <polygon points="123,144 123,142 123,141 125,139 125,147 125,148 124,151 123,145" style="fill: rgb(181,146,144)" /> - <polygon points="14,178 19,177 20,177 23,180 22,180 19,180 16,179" style="fill: rgb(62,70,73)" /> - <polygon points="157,42 158,42 165,43 167,45 167,47 166,47 165,47 163,46" style="fill: rgb(101,90,86)" /> - <polygon points="159,186 162,185 163,185 164,185 165,185 166,185 167,185 168,185 164,187 162,187 161,187 160,187" style="fill: rgb(167,117,106)" /> - <polygon points="77,179 78,179 84,179 85,179 89,181 89,182 88,183 87,184 86,184 85,184 84,184 78,180" style="fill: rgb(61,75,78)" /> - <polygon points="275,188 280,185 280,186 280,187 279,189 275,189" style="fill: rgb(17,16,12)" /> - <polygon points="221,41 221,40 222,40 223,40 226,41 228,45 226,45" style="fill: rgb(101,90,86)" /> - <polygon points="353,94 355,93 359,93 359,94 359,95 358,95 354,95 353,95" style="fill: rgb(92,76,76)" /> - <polygon points="286,334 287,334 289,334 290,335 292,339 290,340 289,339 286,336" style="fill: rgb(87,67,66)" /> - <polygon points="174,172 175,172 176,172 177,172 178,172 179,172 180,172 181,172 193,175 198,177 201,180 202,181 204,183 204,184 204,185 203,185 202,185 201,185" style="fill: rgb(101,73,69)" /> - <polygon points="320,89 326,88 327,88 329,95 328,96 323,93 320,90" style="fill: rgb(17,16,12)" /> - <polygon points="0,157 2,157 4,157 5,157 6,157 7,157 8,157 9,157 10,157 11,157 84,159 84,160 84,161 84,162 83,163 81,163 80,163 76,163 15,159 0,158" style="fill: rgb(171,169,170)" /> - <polygon points="187,459 188,457 189,455 191,452 195,447 200,442 201,441 200,443 188,459" style="fill: rgb(138,98,90)" /> - <polygon points="352,216 352,215 352,210 352,209 357,206 357,212 357,214 355,216 354,216 353,216" style="fill: rgb(117,80,74)" /> - <polygon points="96,442 96,438 96,437 98,447 99,455 98,459 97,452 96,443" style="fill: rgb(202,203,205)" /> - <polygon points="46,392 46,375 46,374 47,374 47,379 47,391 47,396 46,394" style="fill: rgb(250,251,253)" /> - <polygon points="153,116 153,115 156,116 155,119 154,119 153,119" style="fill: rgb(147,118,114)" /> - <polygon points="0,431 8,439 8,440 8,441 6,440 1,437 0,436" style="fill: rgb(189,185,182)" /> - <polygon points="191,458 191,457 192,455 204,439 205,438 202,453 200,459 192,459 191,459" style="fill: rgb(114,33,39)" /> - <polygon points="231,417 232,417 233,417 234,417 235,417 236,418 235,419 234,419 233,419 232,418" style="fill: rgb(87,67,66)" /> - <polygon points="288,432 291,427 299,416 300,415 298,420 293,430 289,434" style="fill: rgb(138,98,90)" /> - <polygon points="104,278 104,277 104,275 104,274 105,275 105,276 105,286 105,288 104,281" style="fill: rgb(99,97,98)" /> - <polygon points="443,271 444,270 444,286" style="fill: rgb(99,97,98)" /> - <polygon points="132,347 132,348 132,349 132,350 132,351 132,352 132,336 132,353 132,337 132,354 132,338 132,339 132,340 132,341 132,342 132,343 132,344 132,345 132,346" style="fill: rgb(119,111,108)" /> - <polygon points="0,88 2,88 30,88 31,88 57,89 87,94 87,95 83,96 82,96 81,96 5,90 0,89" style="fill: rgb(201,196,193)" /> - <polygon points="234,43 236,42 243,42 243,43 243,46 239,45 236,44" style="fill: rgb(120,102,98)" /> - <polygon points="189,23 190,19 193,19 195,20 196,21 192,24 190,24" style="fill: rgb(189,185,182)" /> - <polygon points="326,163 329,159 331,158 333,157 334,158 335,159 330,163 328,164" style="fill: rgb(92,76,76)" /> - <polygon points="0,97 2,97 10,97 44,97 51,98 95,105 95,106 95,107 92,111 91,111 90,111 10,101 0,99" style="fill: rgb(173,164,159)" /> - <polygon points="162,128 162,126 171,119 176,118 197,122 197,123 194,127 193,128 189,129 166,132" style="fill: rgb(200,157,150)" /> - <polygon points="187,104 187,103 188,100 189,98 190,97 194,96 196,99 194,102 193,103" style="fill: rgb(117,80,74)" /> - <polygon points="308,265 308,264 309,262 340,248 342,259 343,287 343,288 341,295 328,303 326,301 315,283 311,274" style="fill: rgb(101,73,69)" /> - <polygon points="203,45 203,44 206,40 208,40 208,41 208,42 207,43 206,44 204,45" style="fill: rgb(92,76,76)" /> - <polygon points="145,454 145,453 146,446 147,440 149,431 151,426 152,424 155,421 146,459 145,455" style="fill: rgb(171,169,170)" /> - <polygon points="233,191 238,189 250,192 250,194 244,194 243,194 242,194 234,193" style="fill: rgb(117,80,74)" /> - <polygon points="304,423 304,422 305,417 333,367 334,366 335,366 347,430 347,431 346,437 345,439 343,443 312,438 308,437" style="fill: rgb(181,146,144)" /> - <polygon points="432,377 432,376 436,379 441,383 439,384 437,384 436,384 435,384 432,380" style="fill: rgb(117,80,74)" /> - <polygon points="0,174 2,174 5,174 6,174 7,174 18,174 19,174 20,174 21,174 72,177 75,180 72,180 14,176 1,175" style="fill: rgb(68,83,86)" /> - <polygon points="94,237 94,236 94,225 94,224 94,223 94,220 106,219 114,231 111,237 103,252 102,252 100,251 95,241 94,239" style="fill: rgb(117,80,74)" /> - <polygon points="196,376 199,378 207,385 207,386 206,386 205,385 204,384 200,380" style="fill: rgb(77,59,57)" /> - <polygon points="181,136 184,132 196,128 199,131 202,135 202,136 199,138 198,138 197,138 196,138 195,138 194,138 193,138 192,138 184,137" style="fill: rgb(200,157,150)" /> - <polygon points="223,319 223,318 223,317 224,316 226,314 229,312 237,309 257,305 263,304 269,306 270,307 271,310 271,312 261,323 257,326 253,329 239,332 224,328" style="fill: rgb(117,80,74)" /> - <polygon points="452,238 452,237 452,236 452,235 452,234 452,233 452,232 452,231 456,219 457,218 458,218 459,218 459,229 458,238 457,239 453,239" style="fill: rgb(146,125,120)" /> - <polygon points="453,290 453,288 453,285 453,283 454,279 456,272 459,265 459,266 459,362 457,361 456,359 455,352 453,291" style="fill: rgb(164,160,161)" /> - <polygon points="0,80 32,80 33,80 34,80 35,80 36,80 37,80 38,80 39,80 60,82 87,88 96,91 92,91 91,91 90,91 16,85 8,84 2,83 0,82" style="fill: rgb(217,216,214)" /> - <polygon points="343,183 343,182 343,181 344,178 350,171 368,170 369,171 369,174 368,175 345,187 343,188" style="fill: rgb(190,139,135)" /> - <polygon points="155,130 159,121 163,120 175,117 176,117 177,117 165,132 162,133 161,133 160,133 155,131" style="fill: rgb(196,156,148)" /> - <polygon points="184,90 186,86 188,84 188,85 187,89 186,93" style="fill: rgb(147,118,114)" /> - <polygon points="0,120 1,119 59,118 75,118 79,118 88,120 88,121 84,126 32,126 0,125" style="fill: rgb(189,185,182)" /> - <polygon points="277,286 278,285 280,284 281,284 282,284 283,284 284,284 285,284 286,284 287,284 287,285 287,286 287,287 285,289 277,287" style="fill: rgb(60,46,43)" /> - <polygon points="219,71 219,70 227,67 229,71 228,83 223,83" style="fill: rgb(138,98,90)" /> - <polygon points="5,425 6,426 7,427 8,428 9,430 6,429 5,428 5,427" style="fill: rgb(219,219,219)" /> - <polygon points="164,333 164,331 164,329 164,328 165,326 170,318 175,317 190,315 191,315 194,315 195,315 210,333 211,340 210,341 165,335 164,334" style="fill: rgb(117,80,74)" /> - <polygon points="230,29 230,28 231,28 234,28 240,29 237,30 231,30" style="fill: rgb(60,46,43)" /> - <polygon points="209,256 210,255 211,255 212,256 213,257 211,258 210,258 209,257" style="fill: rgb(75,14,19)" /> - <polygon points="322,60 323,60 330,67 341,80 346,87 351,94 351,95 351,96 350,95 333,77" style="fill: rgb(60,46,43)" /> - <polygon points="310,90 311,88 312,87 313,87 317,87 318,87 312,90" style="fill: rgb(37,29,27)" /> - <polygon points="156,179 157,177 158,176 178,181 183,183 186,185 186,186 185,186 184,186 173,185 157,183 156,181" style="fill: rgb(117,80,74)" /> - <polygon points="176,93 177,84 178,82 182,80 183,80 189,86 190,88 187,92 176,94" style="fill: rgb(138,98,90)" /> - <polygon points="347,245 347,244 347,240 350,239 351,239 353,241 352,243 350,245" style="fill: rgb(200,157,150)" /> - <polygon points="161,176 162,175 163,174 167,172 168,172 169,172 170,172 171,172 172,172" style="fill: rgb(87,67,66)" /> - <polygon points="143,47 145,45 156,42 155,43 154,44 147,47 144,48" style="fill: rgb(146,125,120)" /> - <polygon points="127,158 128,156 133,166 132,166 128,165" style="fill: rgb(181,146,144)" /> - <polygon points="108,174 108,172 108,170 110,169 111,170 110,174 109,174" style="fill: rgb(77,59,57)" /> - <polygon points="368,340 373,338 380,342 391,349 401,357 401,358 397,357 394,356 388,354 383,352 379,350 370,344" style="fill: rgb(127,112,107)" /> - <polygon points="379,208 379,207 380,207 383,207 449,213 447,215 429,215 419,215 418,215 402,214 396,213 387,211 379,209" style="fill: rgb(92,76,76)" /> - <polygon points="214,260 215,259 216,259 217,259 223,261 226,262 223,263 220,263 218,262" style="fill: rgb(101,73,69)" /> - <polygon points="343,249 343,248 343,239 343,232 343,231 344,229 347,227 357,246 357,247 355,249 353,251 352,252 350,254 346,253 345,252" style="fill: rgb(200,157,150)" /> - <polygon points="195,63 197,60 198,60 199,63 199,66 198,66 195,65" style="fill: rgb(87,67,66)" /> - <polygon points="210,392 210,391 213,392 220,397 221,400 220,400 219,400 213,395 212,394 211,393" style="fill: rgb(87,67,66)" /> - <polygon points="37,246 46,236 55,232 47,242 41,245 39,246" style="fill: rgb(83,97,100)" /> - <polygon points="162,259 162,256 163,255 164,254 165,254 166,254 167,254 167,260 167,261 165,263 163,263 162,260" style="fill: rgb(196,156,148)" /> - <polygon points="0,100 45,100 97,104 96,108 95,111 91,119 90,121 86,127 0,114" style="fill: rgb(173,164,159)" /> - <polygon points="202,357 205,354 207,356 205,359 204,360 202,358" style="fill: rgb(77,59,57)" /> - <polygon points="328,170 328,167 329,166 330,165 347,161 348,161 337,189 336,191 335,191 333,185" style="fill: rgb(37,29,27)" /> - <polygon points="0,142 82,138 83,140 85,149 83,155 80,156 20,150 0,147" style="fill: rgb(209,203,203)" /> - <polygon points="247,39 247,38 249,36 254,39 255,40 255,48 249,53 248,52 247,44" style="fill: rgb(87,67,66)" /> - <polygon points="169,255 170,255 171,255 172,255 173,255 174,256 173,257 171,258 170,257 169,256" style="fill: rgb(196,156,148)" /> - <polygon points="289,266 290,264 293,264 294,266 294,268 294,270 294,271 293,271 290,269 289,267" style="fill: rgb(114,33,39)" /> - <polygon points="155,334 155,333 156,333 162,335 161,338 159,342 158,341 155,336" style="fill: rgb(120,102,98)" /> - <polygon points="334,229 334,228 334,227 335,215 338,210 339,211 341,220 341,245 340,246 339,245 338,244 337,242" style="fill: rgb(101,73,69)" /> - <polygon points="244,102 245,100 249,93 254,96 253,97 250,99 245,102" style="fill: rgb(117,80,74)" /> - <polygon points="340,39 340,38 344,31 349,24 350,23 351,22 355,21 356,21 357,21 367,23 451,80 452,101 453,130 453,141 452,164 448,206 447,210 440,211 420,211 419,211 406,210 392,205 358,154 341,79" style="fill: rgb(60,46,43)" /> - <polygon points="270,182 270,181 271,180 274,182 274,183 273,186 271,185 270,184" style="fill: rgb(37,29,27)" /> - <polygon points="276,323 278,281 282,272 283,270 289,264 312,280 313,292 313,293 309,306 282,332 277,330 276,328" style="fill: rgb(114,33,39)" /> - <polygon points="130,282 132,276 135,276 144,289 144,290 141,291 136,290 132,287 130,284" style="fill: rgb(127,105,107)" /> - <polygon points="96,152 96,149 98,146 99,147 97,156 96,154" style="fill: rgb(92,76,76)" /> - <polygon points="0,192 7,189 91,189 92,189 93,208 89,229 32,245 21,247 14,247 10,247 0,245" style="fill: rgb(68,83,86)" /> - <polygon points="200,156 211,153 218,153 218,155 207,160 206,160" style="fill: rgb(200,157,150)" /> - <polygon points="354,308 354,307 354,306 354,305 357,304 358,304 358,309 355,309" style="fill: rgb(101,90,86)" /> - <polygon points="118,177 118,176 119,177 119,191 118,191 118,182" style="fill: rgb(120,102,98)" /> - <polygon points="202,388 204,386 205,387 208,390 245,429 243,436 241,437 239,438 238,438 230,434 226,429 219,419 217,416 202,391" style="fill: rgb(101,73,69)" /> - <polygon points="244,253 251,248 252,248 254,249 255,250 255,252 254,253 247,255" style="fill: rgb(93,24,29)" /> - <polygon points="225,251 229,250 235,250 236,250 237,250 238,250 239,250 239,254 238,258 225,252" style="fill: rgb(114,33,39)" /> - <polygon points="358,408 361,345 371,360 385,390 385,391 384,393 375,409 369,419 362,415" style="fill: rgb(209,162,152)" /> - <polygon points="226,428 226,426 228,427 229,428 231,431 230,431 229,431" style="fill: rgb(101,73,69)" /> - <polygon points="96,193 96,190 96,189 99,150 102,146 116,137 121,134 117,200 103,207 101,205 99,203 97,198 96,194 96,190 96,189 99,150 102,146 116,137 121,134 117,200 103,207 101,205 99,203 97,198 96,194 96,190 96,189 99,150 102,146 116,137 121,134 117,200 103,207 101,205 99,203 97,198 96,194 96,190 96,189 99,150 102,146 116,137 121,134 117,200 103,207 101,205 99,203 97,198 96,194 96,190 96,189 99,150 102,146 116,137 121,134 117,200 103,207 101,205 99,203 97,198 96,194 96,190 96,189 99,150 102,146 116,137 121,134 117,200 103,207 101,205 99,203 97,198 96,194 96,190 96,189 99,150 102,146 116,137 121,134 117,200 103,207 101,205 99,203 97,198 96,194 96,190 96,189 99,150 102,146 116,137 121,134 117,200 103,207 101,205 99,203 97,198 96,194 96,190 96,189 99,150 102,146 116,137 121,134 117,200 103,207 101,205 99,203 97,198 96,194 96,190 96,189 99,150 102,146 116,137 121,134 117,200 103,207 101,205 99,203 97,198 96,194 96,190 96,189 99,150 102,146 116,137 121,134 117,200 103,207 101,205 99,203 97,198 96,194 96,190 96,189 99,150 102,146 116,137 121,134 117,200 103,207 101,205 99,203 97,198 96,194 96,190 96,189 99,150 102,146 116,137 121,134 117,200 103,207 101,205 99,203 97,198 96,194 96,190 96,189 99,150 102,146 116,137 121,134 117,200 103,207 101,205 99,203 97,198 96,194 96,190 96,189 99,150 102,146 116,137 121,134 117,200 103,207 101,205 99,203 97,198 96,194 96,190 96,189 99,150 102,146 116,137 121,134 117,200 103,207 101,205 99,203 97,198 96,194 96,190 96,189 99,150 102,146 116,137 121,134 117,200 103,207 101,205 99,203 97,198 96,194 96,190 96,189 99,150 102,146 116,137 121,134 117,200 103,207 101,205 99,203 97,198 96,194 96,190 96,189 99,150 102,146 116,137 121,134 117,200 103,207 101,205 99,203 97,198 96,194 96,190 96,189 99,150 102,146 116,137 121,134 117,200 103,207 101,205 99,203 97,198 96,194 96,190 96,189 99,150 102,146 116,137 121,134 117,200 103,207 101,205 99,203 97,198 96,194 96,190 96,189 99,150 102,146 116,137 121,134 117,200 103,207 101,205 99,203 97,198 96,194 96,190 96,189 99,150 102,146 116,137 121,134 117,200 103,207 101,205 99,203 97,198 96,194 96,190 96,189 99,150 102,146 116,137 121,134 117,200 103,207 101,205 99,203 97,198 96,194 96,190 96,189 99,150 102,146 116,137 121,134 117,200 103,207 101,205 99,203 97,198 96,194 96,190 96,189 99,150 102,146 116,137 121,134 117,200 103,207 101,205 99,203 97,198 96,194 96,190 96,189 99,150 102,146 116,137 121,134 117,200 103,207 101,205 99,203 97,198 96,194 96,190 96,189 99,150 102,146 116,137 121,134 117,200 103,207 101,205 99,203 97,198 96,194 96,190 96,189 99,150 102,146 116,137 121,134 117,200 103,207 101,205 99,203 97,198 96,194 96,190 96,189 99,150 102,146 116,137 121,134 117,200 103,207 101,205 99,203 97,198 96,194 96,190 96,189 99,150 102,146 116,137 121,134 117,200 103,207 101,205 99,203 97,198 96,194 96,190 96,189 99,150 102,146 116,137 121,134 117,200 103,207 101,205 99,203 97,198 96,194 96,190 96,189 99,150 102,146 116,137 121,134 117,200 103,207 101,205 99,203 97,198 96,194 96,190 96,189 99,150 102,146 116,137 121,134 117,200 103,207 101,205 99,203 97,198 96,194 96,190 96,189 99,150 102,146 116,137 121,134 117,200 103,207 101,205 99,203 97,198 96,194 96,190 96,189 99,150 102,146 116,137 121,134 117,200 103,207 101,205 99,203 97,198 96,194 96,190 96,189 99,150 102,146 116,137 121,134 117,200 103,207 101,205 99,203 97,198" style="fill: rgb(87,67,66)" /> - <polygon points="229,53 229,52 231,49 232,49 234,50 235,51 236,52 236,53 232,54" style="fill: rgb(101,90,86)" /> - <polygon points="0,252 67,241 72,241 85,252 92,259 96,266 99,274 100,277 101,281 102,294 103,310 105,374 105,377 105,379 105,394 105,396 105,398 105,399 103,399 0,255" style="fill: rgb(215,217,216)" /> - <polygon points="302,383 303,378 309,372 313,369 313,371 310,381 303,384" style="fill: rgb(101,73,69)" /> - <polygon points="421,11 421,10 424,6 426,8 426,9 423,12 422,12" style="fill: rgb(60,46,43)" /> - <polygon points="317,291 318,291 319,291 322,296 322,298 322,299 321,299 320,299 319,298 317,292" style="fill: rgb(101,73,69)" /> - <polygon points="143,130 144,128 145,126 148,123 150,122 151,124 151,125 148,130 146,132 144,132 143,131" style="fill: rgb(204,173,168)" /> - <polygon points="353,342 353,341 354,336 357,336 358,338 356,341 354,343" style="fill: rgb(167,117,106)" /> - <polygon points="159,53 162,50 171,46 172,52 171,55 168,56" style="fill: rgb(87,67,66)" /> - <polygon points="291,176 292,176 305,181 305,182 305,183 305,184 305,185 303,191 302,191" style="fill: rgb(117,80,74)" /> - <polygon points="0,5 0,4 0,3 27,0 28,0 29,0 30,0 31,0 31,1 23,4 15,5 1,5" style="fill: rgb(219,219,219)" /> - <polygon points="113,92 117,86 122,79 123,78 138,70 176,51 182,51 183,51 184,61 156,99 154,101 153,102 144,105 141,105 118,96 116,95 114,93" style="fill: rgb(37,29,27)" /> - <polygon points="104,103 105,98 114,84 118,78 123,77 124,77 125,77 118,98 107,102" style="fill: rgb(77,59,57)" /> - <polygon points="180,450 180,449 181,448 183,448 185,449 184,450 182,452 180,452" style="fill: rgb(222,223,225)" /> - <polygon points="446,293 447,294 448,304 448,306 448,307 447,306" style="fill: rgb(130,121,116)" /> - <polygon points="138,211 138,208 148,216 144,218" style="fill: rgb(101,73,69)" /> - <polygon points="109,268 110,264 112,261 113,261 123,264 124,265 124,272 121,276 120,277 119,277 118,277 116,275 114,273 111,270 110,269" style="fill: rgb(147,118,114)" /> - <polygon points="376,0 380,0 388,0 396,0 408,0 412,0 424,0 428,0 432,0 444,0 448,0 448,2 448,3 448,8 448,10 448,14 448,15 448,21 448,25 448,29 446,130 445,151 443,161 442,162 441,163 438,165 434,167 415,168 406,167 397,162 392,158 389,153 388,146 376,8" style="fill: rgb(60,46,43)" /> - <polygon points="244,418 244,416 249,410 251,408 252,407 253,407 254,407 255,407 265,408 264,410 260,415 252,418 249,418 248,418 247,418 246,418 245,418" style="fill: rgb(87,67,66)" /> - <polygon points="247,237 248,236 249,236 250,236 252,237 253,239 253,241 252,242" style="fill: rgb(190,139,135)" /> - <polygon points="238,88 244,76 245,75 249,80 249,84 249,86 248,88 240,96 238,95" style="fill: rgb(138,98,90)" /> - <polygon points="177,204 188,205 190,206 188,207 183,209 180,208" style="fill: rgb(114,33,39)" /> - <polygon points="79,357 79,356 79,353 79,352 79,283 80,282 84,289 85,292 87,304 87,305 87,308 87,309 87,310 87,311 86,409 85,415 79,387" style="fill: rgb(222,223,225)" /> - <polygon points="101,368 101,321 102,320 103,378 103,379 103,427 103,428 103,429 103,434 102,430 101,412" style="fill: rgb(164,160,161)" /> - <polygon points="103,426 103,424 103,419 104,419 105,421 105,439 104,437" style="fill: rgb(136,138,137)" /> - <polygon points="0,266 1,265 3,264 12,264 13,264 1,266" style="fill: rgb(197,193,192)" /> - <polygon points="207,161 208,158 209,157 216,151 224,149 224,150 223,154 221,155 211,160" style="fill: rgb(200,157,150)" /> - <polygon points="160,109 162,104 164,102 164,104 164,105 164,106" style="fill: rgb(167,117,106)" /> - <polygon points="342,415 342,409 351,402 351,408 350,413 349,415 348,417 343,417 342,417" style="fill: rgb(196,156,148)" /> - <polygon points="167,100 167,99 168,96 173,93 183,93 185,96 184,100 175,101" style="fill: rgb(167,117,106)" /> - <polygon points="172,293 172,290 173,289 174,289 176,289 176,290 175,292 174,293 173,294" style="fill: rgb(147,118,114)" /> - <polygon points="108,427 108,426 108,429 108,428 108,423 108,439 108,422 108,438 108,425 108,424 108,435 108,434 108,437 108,436 108,431 108,430 108,433 108,432" style="fill: rgb(99,97,98)" /> - <polygon points="172,162 173,159 174,158 175,157 253,128 267,123 268,123 285,131 287,133 288,134 289,136 289,145 288,146 221,163 208,165 206,165 205,165 204,165 203,165 202,165 176,164" style="fill: rgb(200,157,150)" /> - <polygon points="230,177 230,176 235,171 240,167 248,167 250,168 250,169 234,177 231,178" style="fill: rgb(114,33,39)" /> - <polygon points="103,413 103,409 103,406 104,401 105,403 105,404 104,417 103,416" style="fill: rgb(136,138,137)" /> - <polygon points="0,408 2,408 25,428 26,430 26,431 25,432 23,432 19,430 16,428 8,421 2,415 0,412" style="fill: rgb(242,236,240)" /> - <polygon points="0,83 39,83 69,86 97,92 96,93 91,93 90,93 4,87 1,85 0,84" style="fill: rgb(209,203,203)" /> - <polygon points="242,246 242,245 243,245 244,245 256,247 257,248 258,249 258,250 258,251 258,252 258,253 257,254 253,257 248,260 247,260 243,259" style="fill: rgb(93,24,29)" /> - <polygon points="214,459 214,458 214,457 218,440 219,451 219,452 218,455 217,457 215,459" style="fill: rgb(182,153,145)" /> - <polygon points="375,210 394,214 397,215 399,216 398,216 389,215 380,213 376,212" style="fill: rgb(108,98,97)" /> - <polygon points="195,261 195,258 198,251 200,248 240,241 241,241 242,241 243,241 244,241 245,241 246,241 263,247 266,249 279,260 279,265 279,266 279,268 279,269 276,278 274,281 203,297 202,297" style="fill: rgb(77,59,57)" /> - <polygon points="179,120 188,116 193,115 199,114 200,114 204,115 204,116 200,131 180,121" style="fill: rgb(190,139,135)" /> - <polygon points="113,161 114,161 115,161 116,161 116,171 115,182" style="fill: rgb(77,59,57)" /> - <polygon points="218,255 220,253 221,253 222,253 227,261 222,262 221,262 220,262 219,261 218,259" style="fill: rgb(101,73,69)" /> - <polygon points="210,17 210,16 216,12 217,12 216,14 215,15 214,16 211,17" style="fill: rgb(197,193,192)" /> - <polygon points="160,140 160,136 167,130 175,126 180,126 195,128 215,146 215,153 215,154 207,157 169,159 168,159 167,159 166,159 160,142" style="fill: rgb(216,173,167)" /> - <polygon points="196,165 199,162 207,165 207,166 202,166" style="fill: rgb(190,139,135)" /> - <polygon points="450,213 450,212 453,41 454,0 459,0 459,44 459,52 459,59 459,74 459,90 459,107 459,123 459,152 459,162 457,209 455,212 454,213 451,213" style="fill: rgb(117,80,74)" /> - <polygon points="357,249 375,216 380,216 383,216 455,219 455,224 449,266 448,271 447,273 359,250" style="fill: rgb(130,121,116)" /> - <polygon points="181,301 182,301 188,307 186,307 184,306 182,305 181,304" style="fill: rgb(77,59,57)" /> - <polygon points="15,172 26,172 49,173 63,174 70,175 64,175 60,175 56,175 29,174" style="fill: rgb(99,97,98)" /> - <polygon points="333,130 333,128 334,128 336,129 337,130 339,132 339,134 339,136 339,138 339,140 338,140 337,139 336,137" style="fill: rgb(77,59,57)" /> - <polygon points="113,248 113,247 113,246 113,245 114,239 115,237 116,235 117,235 118,235 119,237 122,258 121,259 120,259 119,259 117,258 116,257 115,256 114,254" style="fill: rgb(114,33,39)" /> - <polygon points="308,417 311,414 317,408 318,407 328,404 332,404 333,405 334,406 327,416 321,420 320,420 312,420 310,419 308,418" style="fill: rgb(181,146,144)" /> - <polygon points="288,172 289,171 291,171 294,172 293,174 292,174 291,174" style="fill: rgb(167,117,106)" /> - <polygon points="420,407 422,405 424,405 448,416 457,422 459,424 459,430 426,415 424,413" style="fill: rgb(93,24,29)" /> - <polygon points="151,91 151,89 152,86 154,83 154,87 151,92" style="fill: rgb(77,59,57)" /> - <polygon points="0,249 60,231 63,231 77,231 81,232 88,237 99,262 102,270 103,275 104,282 105,290 106,328 106,361 106,363 106,365 0,250" style="fill: rgb(216,211,208)" /> - <polygon points="205,257 206,256 223,253 224,253 239,266 241,272 241,273 237,276 233,277 223,277 222,277 218,274 207,261 205,258" style="fill: rgb(77,59,57)" /> - <polygon points="279,4 279,3 279,1 279,0 280,0 285,16 284,17 283,17 279,8" style="fill: rgb(197,193,192)" /> - <polygon points="318,299 318,298 319,297 322,300 327,309 324,311 323,311 322,310 320,306" style="fill: rgb(77,59,57)" /> - <polygon points="95,174 95,171 101,170 104,173 103,181 96,185" style="fill: rgb(87,67,66)" /> - <polygon points="314,286 314,285 315,285 316,285 319,289 315,290 314,287" style="fill: rgb(93,24,29)" /> - <polygon points="94,190 94,189 94,188 95,179 98,176 99,179 99,180 95,194" style="fill: rgb(87,67,66)" /> - <polygon points="138,64 139,62 140,61 175,51 177,56 168,63 158,67 153,69 149,69 143,68" style="fill: rgb(87,67,66)" /> - <polygon points="256,159 258,158 260,158 261,158 265,159 267,160 256,160" style="fill: rgb(77,59,57)" /> - <polygon points="222,346 239,295 246,293 254,291 272,289 276,289 281,289 289,295 292,301 293,303 292,311 284,334 279,348 268,356 258,359 248,359 247,359 246,359 245,359 244,359 235,359 234,359 229,358" style="fill: rgb(138,98,90)" /> - <polygon points="220,293 222,292 227,291 228,292 228,293 223,294 222,294" style="fill: rgb(114,33,39)" /> - <polygon points="0,148 8,147 9,147 10,147 41,149 81,153 83,156 80,157 79,157 21,152 0,150" style="fill: rgb(197,193,192)" /> - <polygon points="124,76 124,75 124,74 124,73 129,68 130,68 132,72 130,75 127,78 126,78" style="fill: rgb(87,67,66)" /> - <polygon points="268,352 268,344 269,343 280,345 283,346 283,347 281,353 276,356 271,356 268,354" style="fill: rgb(101,73,69)" /> - <polygon points="442,273 442,272 443,272 443,282 443,285" style="fill: rgb(101,90,86)" /> - <polygon points="175,199 179,196 184,199 179,200" style="fill: rgb(117,80,74)" /> - <polygon points="429,459 430,456 431,455 433,456 437,459" style="fill: rgb(93,24,29)" /> - <polygon points="188,112 190,109 192,110 193,111 193,113 193,114 192,116 191,116 190,116" style="fill: rgb(179,139,137)" /> - <polygon points="346,248 346,245 346,244 346,241 346,240 346,239 346,238 346,233 346,232 349,221 368,189 370,189 374,196 374,199 371,210 370,213 364,230 361,235 359,238 356,242 353,245 351,247 349,248" style="fill: rgb(190,139,135)" /> - <polygon points="219,113 219,112 219,111 220,109 221,110 222,113 224,124 224,125 222,127 220,120 219,115" style="fill: rgb(167,117,106)" /> - <polygon points="105,207 108,208 114,211 114,213 111,216 105,208" style="fill: rgb(60,46,43)" /> - <polygon points="240,215 242,215 245,218 244,220 242,219 241,218" style="fill: rgb(37,29,27)" /> - <polygon points="188,368 192,369 195,371 196,372 196,373 195,374 193,374" style="fill: rgb(60,46,43)" /> - <polygon points="457,185 457,184 457,181 457,180 457,179 457,178 457,174 457,173 459,163 459,207 458,207 457,199" style="fill: rgb(138,98,90)" /> - <polygon points="304,65 306,65 307,65 308,65 309,65 310,65 311,65 312,65 321,70 322,71 315,75" style="fill: rgb(37,29,27)" /> - <polygon points="378,408 379,406 381,403 382,402 383,405 383,406 381,409 378,410 378,409" style="fill: rgb(75,14,19)" /> - <polygon points="387,390 394,376 398,369 401,365 422,362 423,362 455,371 457,375 458,381 459,394 459,422 459,423" style="fill: rgb(114,33,39)" /> - <polygon points="167,96 168,95 172,92 177,90 175,97" style="fill: rgb(167,117,106)" /> - <polygon points="165,112 166,112 167,112 169,114 170,115 170,116 169,117 167,117 166,117 165,116" style="fill: rgb(196,156,148)" /> - <polygon points="81,141 81,140 83,135 85,143 84,144" style="fill: rgb(197,193,192)" /> - <polygon points="151,228 151,226 152,224 154,224 155,225 156,227 152,228" style="fill: rgb(127,112,107)" /> - <polygon points="225,436 225,434 225,433 225,431 227,432 228,435 226,439 225,437" style="fill: rgb(127,105,107)" /> - <polygon points="159,109 160,105 162,102 166,98 166,100 163,105 159,110" style="fill: rgb(168,137,134)" /> - <polygon points="351,145 351,144 355,121 356,121 357,144 357,146 357,147 356,155 355,155 353,151" style="fill: rgb(60,46,43)" /> - <polygon points="147,289 148,284 149,280 150,279 186,272 188,272 199,278 200,280 200,281 200,282 200,283 198,297 186,322 185,323 183,323 154,310 153,309 150,305 148,297 147,292" style="fill: rgb(147,118,114)" /> - <polygon points="132,187 133,185 140,178 143,175 148,172 152,171 153,171 154,171 132,191" style="fill: rgb(146,125,120)" /> - <polygon points="206,388 207,388 223,401 218,409 216,406 206,389" style="fill: rgb(101,90,86)" /> - <polygon points="201,126 203,123 231,120 247,128 223,134 205,137 204,137 203,137" style="fill: rgb(179,139,137)" /> - <polygon points="181,238 186,236 192,234 193,234 192,235 187,237 184,238" style="fill: rgb(37,29,27)" /> - <polygon points="0,264 2,263 40,257 41,257 46,257 47,257 64,257 72,258 75,259 80,262 84,265 85,266 92,278 93,280 95,286 96,293 97,316 101,443 101,444 101,445 101,459 0,265" style="fill: rgb(243,244,246)" /> - <polygon points="142,252 144,250 145,254 145,255 145,256 143,258 142,255" style="fill: rgb(147,118,114)" /> - <polygon points="160,203 161,202 163,201 170,199 171,199 172,199 173,199 174,199 167,203 166,203" style="fill: rgb(60,46,43)" /> - <polygon points="251,36 259,32 261,38 256,39" style="fill: rgb(109,97,97)" /> - <polygon points="266,87 267,86 272,84 274,89 274,90 274,91 273,91 267,91" style="fill: rgb(101,73,69)" /> - <polygon points="373,211 373,210 373,209 376,175 377,176 378,178 379,182 380,187 380,190 380,192 375,209 374,212" style="fill: rgb(167,117,106)" /> - <polygon points="5,88 6,87 29,86 37,86 61,87 94,94 96,95 97,96 95,97 93,97" style="fill: rgb(202,203,205)" /> - <polygon points="190,203 190,202 199,198 199,199 198,200 192,205" style="fill: rgb(101,73,69)" /> - <polygon points="450,312 450,308 450,306 450,304 450,302 450,300 450,298 450,296 450,294 450,292 450,290 452,322 452,323 451,336 450,319 450,316" style="fill: rgb(136,138,137)" /> - <polygon points="259,188 264,185 265,185 263,188 261,190" style="fill: rgb(60,46,43)" /> - <polygon points="450,345 450,346 450,343 450,344 450,341 450,342 450,339 450,340 450,337 450,338 450,335 450,336 450,334 450,347" style="fill: rgb(134,126,124)" /> - <polygon points="107,260 107,259 110,257 112,260 110,267 108,265" style="fill: rgb(179,139,137)" /> - <polygon points="0,417 2,418 6,422 6,423 5,423 0,421" style="fill: rgb(230,230,230)" /> - <polygon points="200,343 200,341 201,339 205,337 206,337 206,338 204,341" style="fill: rgb(87,67,66)" /> - <polygon points="408,138 410,135 411,134 413,134 415,138" style="fill: rgb(37,29,27)" /> - <polygon points="14,442 14,440 15,440 21,446 24,450 25,453 25,456 25,457 25,458 24,459 21,459 20,459 16,448" style="fill: rgb(235,198,192)" /> - <polygon points="255,107 255,106 255,94 277,72 278,72 283,75 291,80 313,126 321,149 323,155 323,158 323,160 263,117 255,108" style="fill: rgb(167,117,106)" /> - <polygon points="368,162 371,163 378,168 382,172 384,175 386,183 387,193 386,195 380,206 378,207 377,207 376,207" style="fill: rgb(138,98,90)" /> - <polygon points="56,267 57,267 62,267 63,267 67,268 68,269" style="fill: rgb(219,219,219)" /> - <polygon points="158,76 160,72 177,50 214,33 218,34 223,43 200,65 162,84 158,77" style="fill: rgb(77,59,57)" /> - <polygon points="315,106 316,107 320,112 319,112 318,112 317,112 316,111 315,109" style="fill: rgb(60,46,43)" /> - <polygon points="110,96 110,95 111,93 117,98 116,99 112,97" style="fill: rgb(60,46,43)" /> - <polygon points="165,101 176,98 178,99 177,100 176,101 175,102 174,102 173,102" style="fill: rgb(179,139,137)" /> - <polygon points="111,224 112,223 113,223 118,226 119,227 121,231 124,253 124,254 123,260 118,260 116,259 114,257 113,255 112,248" style="fill: rgb(114,33,39)" /> - <polygon points="0,286 0,285 7,281 11,280 30,278 31,278 36,278 37,278 38,278 39,278 44,278 45,278 46,278 47,278 53,279 58,280 66,285 68,288 71,293 75,302 75,306 75,308 75,310 75,311 74,336 71,409 69,415 65,420 60,425 47,434 35,435 30,434 26,432 15,424 9,418 6,415 0,407" style="fill: rgb(250,251,253)" /> - <polygon points="233,72 233,70 233,69 234,69 235,74 235,75 234,76" style="fill: rgb(60,46,43)" /> - <polygon points="133,63 136,59 139,56 139,65 134,65 133,65" style="fill: rgb(77,59,57)" /> - <polygon points="126,241 130,237 132,239 135,242 136,245 136,250 136,251 136,252 136,253 136,254 135,256 134,257 133,256" style="fill: rgb(182,153,145)" /> - <polygon points="233,103 233,97 233,96 234,88 237,88 245,94 237,113" style="fill: rgb(138,98,90)" /> - <polygon points="212,18 226,16 227,16 229,19 221,21 213,21 212,20" style="fill: rgb(189,185,182)" /> - <polygon points="352,208 352,207 356,205 356,212 356,214 354,214" style="fill: rgb(117,80,74)" /> - <polygon points="216,213 216,211 216,205 217,209 218,214 218,215 218,222 218,223 218,224 217,221 216,215" style="fill: rgb(204,173,168)" /> - <polygon points="147,101 148,98 153,92 154,92 154,93 154,94 153,99 151,103 148,104" style="fill: rgb(77,59,57)" /> - <polygon points="153,183 154,178 157,176 179,186 172,187 171,187 170,187 168,187 155,185 153,184" style="fill: rgb(138,98,90)" /> - <polygon points="288,19 291,16 301,24 301,27 293,24 290,21" style="fill: rgb(171,169,170)" /> - <polygon points="112,155 112,154 115,145 115,159 114,159 113,159" style="fill: rgb(87,67,66)" /> - <polygon points="0,128 80,125 83,127 83,134 82,135 81,135 22,133 0,131" style="fill: rgb(209,203,203)" /> - <polygon points="255,51 255,49 256,43 257,43 259,44 259,52 259,54 255,53" style="fill: rgb(60,46,43)" /> - <polygon points="306,313 306,312 310,303 312,303 314,304 318,317 315,319 313,320 312,320 306,314" style="fill: rgb(60,46,43)" /> - <polygon points="287,77 292,79 292,85 291,85 288,82" style="fill: rgb(101,73,69)" /> - <polygon points="96,188 96,186 97,181 104,179 104,186" style="fill: rgb(77,59,57)" /> - <polygon points="204,373 206,372 207,372 207,376 207,377 206,379 205,379 204,374" style="fill: rgb(37,29,27)" /> - <polygon points="344,194 344,192 345,190 346,190 349,196 349,197 347,196 345,195" style="fill: rgb(93,24,29)" /> - <polygon points="240,115 243,113 252,113 249,118 246,118 240,117" style="fill: rgb(167,117,106)" /> - <polygon points="128,254 141,247 143,246 145,246 158,268 156,271 147,277 141,280 140,280 137,278 136,277 128,258" style="fill: rgb(168,137,134)" /> - <polygon points="9,456 11,454 12,454 13,455 14,456 15,458 15,459 12,459 11,459 10,458" style="fill: rgb(200,157,150)" /> - <polygon points="0,241 3,238 4,237 5,236 9,238 10,239 7,242 6,242 4,242" style="fill: rgb(62,70,73)" /> - <polygon points="303,69 304,69 305,69 306,69 309,71 305,73 304,73 303,72" style="fill: rgb(37,29,27)" /> - <polygon points="157,35 161,28 166,28 171,29 172,30 171,31 170,32" style="fill: rgb(146,125,120)" /> - <polygon points="445,291 445,290 445,286 445,285 445,282 445,281 445,278 445,277 445,274 445,273 445,270 445,269 445,268 446,256 448,264 448,335 448,336 447,343 445,293 445,292 445,286 445,285 445,282 445,281 445,278 445,277 445,274 445,273 445,270 445,269 445,268 446,256 448,264 448,335 448,336 447,343 445,293 445,292 445,286 445,285 445,282 445,281 445,278 445,277 445,274 445,273 445,270 445,269 445,268 446,256 448,264 448,335 448,336 447,343 445,293 445,292 445,286 445,285 445,282 445,281 445,278 445,277 445,274 445,273 445,270 445,269 445,268 446,256 448,264 448,335 448,336 447,343 445,293 445,292 445,286 445,285 445,282 445,281 445,278 445,277 445,274 445,273 445,270 445,269 445,268 446,256 448,264 448,335 448,336 447,343 445,293 445,292 445,286 445,285 445,282 445,281 445,278 445,277 445,274 445,273 445,270 445,269 445,268 446,256 448,264 448,335 448,336 447,343 445,293 445,292" style="fill: rgb(119,111,108)" /> - <polygon points="315,367 315,366 316,364 321,357 327,349 327,350 327,351 327,352 327,353 321,364" style="fill: rgb(101,73,69)" /> - <polygon points="436,365 446,364 447,364 450,364 459,367 459,368 450,367 441,366" style="fill: rgb(167,117,106)" /> - <polygon points="272,166 275,165 278,165 279,165 280,165 281,165 281,166 272,167" style="fill: rgb(167,117,106)" /> - <polygon points="16,108 19,107 20,107 31,109 31,111 24,111 20,111 19,111 18,110" style="fill: rgb(164,160,161)" /> - <polygon points="246,44 247,43 249,43 252,44 255,47 252,52 250,52 248,49 247,47 246,45" style="fill: rgb(77,59,57)" /> - <polygon points="112,218 113,216 117,217 119,218 120,223 120,224 119,224 118,224 117,224 116,224" style="fill: rgb(87,67,66)" /> - <polygon points="91,129 91,128 93,123 99,115 100,115 111,127 113,136 113,137 109,139 107,140 98,140 96,139 95,138 94,137 92,135" style="fill: rgb(37,29,27)" /> - <polygon points="214,431 214,430 215,429 218,427 221,431 223,440 223,442 223,447 223,449 223,459 222,459 221,459" style="fill: rgb(146,125,120)" /> - <polygon points="208,333 210,330 211,330 227,339 227,340 225,344 217,347 210,345" style="fill: rgb(117,80,74)" /> - <polygon points="197,294 197,292 198,288 207,285 207,286 205,290 204,291 203,292 197,295" style="fill: rgb(127,112,107)" /> - <polygon points="170,197 174,195 175,195 178,196 180,198 179,198 178,198 177,198 176,198 175,198 174,198" style="fill: rgb(117,80,74)" /> - <polygon points="200,81 201,80 204,81 205,82 206,85 205,85 202,84" style="fill: rgb(77,59,57)" /> - <polygon points="89,156 91,154 92,154 92,162" style="fill: rgb(92,76,76)" /> - <polygon points="135,413 135,412 136,400 136,401 136,402 136,403 136,404 136,405 136,406 136,407 136,408 136,409 136,410 136,411 136,412" style="fill: rgb(83,97,100)" /> - <polygon points="188,202 189,201 192,199 198,198 197,199 196,200 194,201 189,203" style="fill: rgb(101,73,69)" /> - <polygon points="109,84 111,80 113,77 114,77 117,78 114,82 113,83" style="fill: rgb(101,90,86)" /> - <polygon points="170,364 170,363 171,363 179,368 182,370 183,371 183,373 181,375 180,375 179,375 178,375 177,375 176,375 175,375 174,375 172,371 171,368" style="fill: rgb(219,219,219)" /> - <polygon points="354,313 354,312 375,317 380,321 383,324 392,334 409,354 403,356 400,356 396,355 392,353 381,347 366,338 365,337 357,323 355,317" style="fill: rgb(120,102,98)" /> - <polygon points="191,242 192,239 193,236 204,232 208,233 208,236 208,237 204,243 200,246 192,243" style="fill: rgb(117,80,74)" /> - <polygon points="420,307 424,295 432,291 437,291 439,299 440,307 440,311 440,313 440,327 438,335 437,335 432,331 427,327 422,322 421,321 420,308" style="fill: rgb(60,46,43)" /> - <polygon points="274,185 275,185 279,186 279,187 274,188" style="fill: rgb(17,16,12)" /> - <polygon points="112,264 113,264 114,264 117,265 118,266 118,269 117,270 116,270 114,269 112,266" style="fill: rgb(127,105,107)" /> - <polygon points="378,341 378,340 379,339 380,339 381,340 382,342 382,343 381,343" style="fill: rgb(119,111,108)" /> - <polygon points="165,366 165,364 165,362 168,360 172,362 189,378 189,379 188,380 175,381 171,379 168,375 165,367" style="fill: rgb(219,219,219)" /> - <polygon points="191,104 198,96 199,95 200,94 201,94 207,100 206,112 204,113 197,114 196,114 195,114 194,114" style="fill: rgb(167,117,106)" /> - <polygon points="135,55 137,48 140,46 147,42 156,37 156,39 155,42 139,54 136,56" style="fill: rgb(127,112,107)" /> - <polygon points="100,157 101,153 102,152 103,153 104,154 105,156 105,161 105,162 101,159" style="fill: rgb(62,70,73)" /> - <polygon points="0,73 56,72 58,72 102,80 102,82 101,85 100,86 97,89 3,78 0,77" style="fill: rgb(222,223,225)" /> - <polygon points="152,456 154,446 157,437 160,430 161,428 166,423 168,422 173,421 192,420 200,420 201,420 209,421 210,422 212,425 211,427 153,459 152,459" style="fill: rgb(216,211,208)" /> - <polygon points="180,341 184,331 187,324 189,324 193,324 194,325 195,326 195,327 193,336 192,338 181,342" style="fill: rgb(77,59,57)" /> - <polygon points="420,369 420,368 423,361 425,361 459,370 459,378 459,379 459,393 453,395 452,395 420,370" style="fill: rgb(114,33,39)" /> - <polygon points="450,271 450,269 450,267 451,255 454,243 457,232 459,230 459,245 455,261 454,264 453,266" style="fill: rgb(140,136,133)" /> - <polygon points="207,351 207,350 210,346 212,346 209,355 208,354 207,352" style="fill: rgb(101,90,86)" /> - <polygon points="177,112 181,107 182,106 183,109 183,112 182,113 181,113 180,113" style="fill: rgb(147,118,114)" /> - <polygon points="456,213 459,210 459,216 458,216" style="fill: rgb(138,98,90)" /> - <polygon points="104,357 104,356 104,347 104,328 104,327 104,324 104,323 104,322 104,321 105,330 106,366 106,377 106,379 106,427 106,439 106,441 105,431 104,418" style="fill: rgb(136,138,137)" /> - <polygon points="354,190 355,184 357,183 357,185 357,186 355,190" style="fill: rgb(200,157,150)" /> - <polygon points="151,454 151,453 153,444 154,440 158,430 160,427 163,423 172,416 201,414 208,418 211,422 212,424 151,459" style="fill: rgb(216,211,208)" /> - <polygon points="232,120 232,119 232,118 233,117 243,119 244,121 240,122 234,122 233,121" style="fill: rgb(167,117,106)" /> - <polygon points="83,132 83,131 84,131 85,133 86,140 84,138" style="fill: rgb(189,185,182)" /> - <polygon points="249,181 249,180 251,179 260,176 262,176 263,176 253,183 249,183" style="fill: rgb(117,80,74)" /> - <polygon points="97,193 98,194 101,198 103,201 103,205 102,205 100,203 99,202 98,200 97,194" style="fill: rgb(37,29,27)" /> - <polygon points="138,60 139,59 146,57 150,57 149,58 140,60" style="fill: rgb(92,76,76)" /> - <polygon points="162,42 163,41 165,40 177,37 179,37 177,40 174,43 172,43" style="fill: rgb(120,102,98)" /> - <polygon points="290,456 290,455 290,452 291,452 292,452 293,452 294,452 295,452 296,452 297,452 312,455 312,459 299,459 298,459 293,459 292,459 291,459" style="fill: rgb(146,125,120)" /> - <polygon points="200,59 200,58 202,61 203,65 203,66 202,66 201,66 200,60" style="fill: rgb(87,67,66)" /> - <polygon points="204,352 206,349 207,349 208,356 206,356 204,354" style="fill: rgb(92,76,76)" /> - <polygon points="92,237 92,236 94,240 95,246 94,245 92,239 92,238" style="fill: rgb(168,137,134)" /> - <polygon points="218,244 224,200 226,203 229,208 237,225 239,231 238,237 237,239 231,242 226,243 219,244" style="fill: rgb(200,157,150)" /> - <polygon points="160,175 161,174 167,171 168,171 169,171 170,171 171,171 172,171 173,171 174,171 175,171 176,171 177,171 178,171 179,171 180,171 181,171 182,171 191,172 194,173 206,177 207,178 206,184 205,185 160,176" style="fill: rgb(87,67,66)" /> - <polygon points="352,253 354,251 355,250 356,250 357,250 358,250 358,251 354,253 353,253" style="fill: rgb(127,112,107)" /> - <polygon points="118,116 119,112 122,112 121,115 119,117" style="fill: rgb(60,46,43)" /> - <polygon points="197,80 199,80 201,81 206,90 206,91 206,93 205,94 198,88 197,81" style="fill: rgb(117,80,74)" /> - <polygon points="280,4 281,0 282,0 287,16 287,17 287,18 286,20 285,20 280,19" style="fill: rgb(189,185,182)" /> - <polygon points="289,190 289,188 298,190 293,191 292,191" style="fill: rgb(101,73,69)" /> - <polygon points="294,85 294,84 295,84 296,84 297,84 298,84 319,122 327,153 328,158 327,158 325,154" style="fill: rgb(60,46,43)" /> - <polygon points="285,34 289,30 290,30 292,31 293,33 287,37 286,36 285,35" style="fill: rgb(101,73,69)" /> - <polygon points="167,337 170,334 189,329 190,329 208,335 210,358 210,360 206,364 203,365 202,365 172,355 170,349 167,338" style="fill: rgb(60,46,43)" /> - <polygon points="354,159 355,158 358,158 364,161 370,167 375,176 376,178 377,184 377,185 377,186 376,187" style="fill: rgb(138,98,90)" /> - <polygon points="152,107 153,104 159,100 160,100 160,101 160,102 160,103 159,107 157,113" style="fill: rgb(138,98,90)" /> - <polygon points="367,258 368,257 369,256 370,255 389,254 390,254 391,254 392,254 393,254 394,254 395,254 396,254 391,256 385,257 369,258 368,258" style="fill: rgb(108,98,97)" /> - <polygon points="362,256 362,255 368,254 400,251 411,250 420,250 427,251 427,252 367,257 366,257" style="fill: rgb(120,102,98)" /> - <polygon points="325,397 325,396 334,367 341,345 346,333 347,331 348,331 349,331 350,331 358,342 360,346 364,357 366,365 366,367 365,374 364,378 349,399 346,403 340,410 334,407 330,403" style="fill: rgb(190,139,135)" /> - <polygon points="369,458 370,455 401,401 403,399 404,399 418,406 423,459 403,459 402,459 400,459 388,459 384,459 372,459 370,459 369,459" style="fill: rgb(93,24,29)" /> - <polygon points="344,136 344,135 346,136 347,138 347,140 346,141 345,140" style="fill: rgb(60,46,43)" /> - <polygon points="138,282 146,272 149,269 151,270 159,274 160,276 160,277 159,278 145,291 144,291 140,286" style="fill: rgb(127,112,107)" /> - <polygon points="111,407 112,404 116,404 117,404 123,405 127,408 128,446 128,447 128,455 128,456 128,457 128,458 128,459 119,459 118,459 117,459 116,459 114,459 113,459 112,455" style="fill: rgb(68,83,86)" /> - <polygon points="234,51 235,48 237,43 243,47 246,55 244,66 240,66 238,62 235,55 234,52" style="fill: rgb(60,46,43)" /> - <polygon points="0,413 1,413 13,424 14,426 14,427 10,428 7,425 6,424 3,420 0,416" style="fill: rgb(230,230,230)" /> - <polygon points="137,291 138,288 139,288 142,296 142,297 141,297 138,295 137,294" style="fill: rgb(109,97,97)" /> - <polygon points="156,122 157,120 159,120 164,130 164,131 162,132 161,132 160,132 159,131 156,123" style="fill: rgb(196,156,148)" /> - <polygon points="252,84 255,82 263,84 262,86 256,92 254,92 252,91" style="fill: rgb(77,59,57)" /> - <polygon points="252,195 255,193 264,191 289,186 295,191 298,202 298,203 296,208 294,209 287,211 283,212 279,213 269,211 266,210 261,207 255,203 254,202 253,201 252,200" style="fill: rgb(138,98,90)" /> - <polygon points="3,426 12,436 13,438 13,439 6,435 5,434 3,430" style="fill: rgb(216,211,208)" /> - <polygon points="270,23 270,22 270,20 271,20 272,20 273,20 274,20 275,20 280,21 271,23" style="fill: rgb(197,193,192)" /> - <polygon points="148,318 151,317 152,320 150,322" style="fill: rgb(127,112,107)" /> - <polygon points="0,79 32,78 33,78 34,78 35,78 36,78 37,78 38,78 39,78 40,78 41,78 42,78 43,78 44,78 45,78 46,78 47,78 70,80 96,88 97,90 3,81" style="fill: rgb(219,219,219)" /> - <polygon points="89,152 89,148 96,147 96,148 95,150 92,152 90,153 89,153 89,148 96,147 96,148 95,150 92,152 90,153 89,153 89,148 96,147 96,148 95,150 92,152" style="fill: rgb(77,59,57)" /> - <polygon points="160,134 163,133 164,133 167,134 167,135 165,137 163,137 160,135" style="fill: rgb(200,157,150)" /> - <polygon points="0,115 1,114 4,114 5,114 6,114 88,115 88,118 88,119 85,120 83,120 82,120 19,120 0,119" style="fill: rgb(180,176,175)" /> - <polygon points="117,234 117,233 120,228 120,234 119,236" style="fill: rgb(101,73,69)" /> - <polygon points="119,155 119,154 120,149 121,145 125,172 125,177 125,178 124,198 123,197 122,194" style="fill: rgb(147,118,114)" /> - <polygon points="0,426 2,426 2,430 0,429" style="fill: rgb(202,203,205)" /> - <polygon points="171,234 184,211 185,210 189,208 191,207 192,207 196,211 196,227 191,230 179,234 175,235 174,235" style="fill: rgb(138,98,90)" /> - <polygon points="324,170 325,170 326,171 328,173 331,182 332,186 332,187 332,189" style="fill: rgb(117,80,74)" /> - <polygon points="134,127 138,123 146,119 145,121 139,127 138,127" style="fill: rgb(147,118,114)" /> - <polygon points="418,357 418,356 419,356 443,362 441,363 440,363 438,363 432,362" style="fill: rgb(117,80,74)" /> - <polygon points="224,424 224,422 225,422 229,424 229,426 229,427 225,426" style="fill: rgb(101,90,86)" /> - <polygon points="229,76 229,72 230,64 231,69 231,71 229,78 229,74 229,72 230,64 231,69 231,71 229,78 229,74 229,72 230,64 231,69 231,71 229,78 229,74 229,72" style="fill: rgb(138,98,90)" /> - <polygon points="446,280 446,279 447,274 448,273 448,274 448,279 448,280 448,287 448,288" style="fill: rgb(134,126,124)" /> - <polygon points="292,309 293,306 313,280 314,280 336,294 339,297 342,305 342,308 340,315 317,333 312,330 298,316" style="fill: rgb(77,59,57)" /> - <polygon points="285,328 287,324 288,325 288,326 288,328 288,330 287,330" style="fill: rgb(60,46,43)" /> - <polygon points="336,395 337,389 339,389 339,392 339,395 339,396" style="fill: rgb(190,139,135)" /> - <polygon points="225,121 225,120 226,113 229,96 230,96 232,111 225,122" style="fill: rgb(138,98,90)" /> - <polygon points="247,76 249,73 250,72 252,73 254,75 254,76 254,77 247,79" style="fill: rgb(117,80,74)" /> - <polygon points="113,127 114,126 116,125 118,124 121,123 122,123 125,123 125,124 119,129 118,129 117,129 116,129" style="fill: rgb(60,46,43)" /> - <polygon points="288,397 288,394 288,393 292,390 295,391 293,395 292,396 289,397" style="fill: rgb(87,67,66)" /> - <polygon points="222,139 224,135 232,132 240,130 241,130 242,130 243,130 244,130 245,130 246,130 247,130 249,130 250,130 251,130 252,130 253,130 256,133 257,134 258,136 258,137 255,141 239,146 228,149 227,149 223,145 222,144" style="fill: rgb(216,173,167)" /> - <polygon points="216,459 219,440 220,446 220,452 220,454 220,459 218,459 217,459" style="fill: rgb(182,153,145)" /> - <polygon points="280,325 286,317 287,317 297,321 301,323 302,325 302,332 302,333 299,344 296,345 294,344 282,331" style="fill: rgb(77,59,57)" /> - <polygon points="152,238 160,237 168,236 169,236 170,236 171,236 173,237 166,238" style="fill: rgb(147,118,114)" /> - <polygon points="294,367 294,366 295,366 298,367 297,370 295,370" style="fill: rgb(17,16,12)" /> - <polygon points="349,118 349,117 353,120 352,123 351,123 350,122 349,120" style="fill: rgb(17,16,12)" /> - <polygon points="352,453 352,452 363,432 387,391 389,388 390,387 407,387 392,415 381,433 377,439 375,442 371,448 363,459 362,459 361,459 360,459" style="fill: rgb(93,24,29)" /> - <polygon points="166,457 166,456 167,452 173,440 179,440 180,440 181,440 182,440 183,440 184,440 185,440 194,442 193,444 188,452 185,456 183,458 181,459 176,459 175,459 174,459 173,459 172,459 171,459 170,459 169,459 168,459 167,459 166,459" style="fill: rgb(230,218,220)" /> - <polygon points="138,204 145,200 141,209 140,209 139,208 138,205" style="fill: rgb(138,98,90)" /> - <polygon points="287,5 287,0 288,0 311,27 315,32 317,35 319,39 319,44 319,46 318,46 316,44 315,43 314,42 290,12 288,9" style="fill: rgb(164,160,161)" /> - <polygon points="89,130 89,129 90,127 92,123 98,113 99,113 101,114 92,134" style="fill: rgb(77,59,57)" /> - <polygon points="292,4 292,3 292,1 292,0 316,27 320,32 322,35 322,36 322,39 293,9 292,7" style="fill: rgb(120,102,98)" /> - <polygon points="337,162 338,159 339,159 341,160 342,162 338,163" style="fill: rgb(16,6,5)" /> - <polygon points="96,125 99,123 103,121 103,123 103,125 102,125 101,125" style="fill: rgb(17,16,12)" /> - <polygon points="150,255 154,252 159,250 163,249 164,249 165,249 175,251 177,255 162,265" style="fill: rgb(182,153,145)" /> - <polygon points="331,387 331,384 339,372 340,371 344,371 345,372 355,384 359,394 359,396 354,403 346,407 344,407 343,407 332,389" style="fill: rgb(196,156,148)" /> - <polygon points="0,154 2,154 3,154 5,154 7,154 10,154 11,154 42,156 67,158 83,160 83,161 80,161 79,161 78,161 77,161 76,161 75,161 74,161 73,161 12,157 0,156" style="fill: rgb(180,176,175)" /> - <polygon points="275,4 275,3 275,1 275,0 277,0 281,15 281,17 280,17 279,16 278,15 275,9 275,0 277,0 281,15 281,17 280,17 279,16 278,15 275,9 275,0 277,0 281,15 281,17 280,17 279,16 278,15 275,9 275,0 277,0 281,15 281,17 280,17 279,16 278,15 275,9 275,0 277,0 281,15 281,17 280,17 279,16 278,15 275,9 275,0 277,0 281,15 281,17 280,17" style="fill: rgb(202,203,205)" /> - <polygon points="176,355 176,354 177,354 178,355 180,359 180,360 179,361 176,357" style="fill: rgb(77,59,57)" /> - <polygon points="225,254 225,253 226,253 227,253 228,253 229,253 230,253 230,254 226,255" style="fill: rgb(93,24,29)" /> - <polygon points="307,76 308,75 312,73 313,73 313,74 313,75 313,76" style="fill: rgb(37,29,27)" /> - <polygon points="129,131 132,128 136,127 137,127 138,128 130,131" style="fill: rgb(146,125,120)" /> - <polygon points="219,410 220,407 222,407 223,408 227,414 223,421 222,420 221,419 220,418 219,411" style="fill: rgb(101,73,69)" /> - <polygon points="177,457 177,456 178,456 179,456 180,456 181,456 180,459 178,459" style="fill: rgb(230,230,230)" /> - <polygon points="127,57 128,56 129,56 130,56 134,58 132,61 130,64 129,63" style="fill: rgb(127,105,107)" /> - <polygon points="270,4 270,3 270,1 270,0 271,0 273,13 273,15 272,13 271,11 270,9" style="fill: rgb(215,217,216)" /> - <polygon points="169,175 173,175 174,176 172,177 170,177 169,176" style="fill: rgb(60,46,43)" /> - <polygon points="218,364 218,361 219,361 223,364 223,366" style="fill: rgb(77,59,57)" /> - <polygon points="361,344 362,343 364,344 395,369 388,384 387,386 382,394 381,395 375,381" style="fill: rgb(216,173,167)" /> - <polygon points="195,378 199,384 201,387 207,396 211,403 212,405 214,410 214,411 207,401 201,391 195,380" style="fill: rgb(127,105,107)" /> - <polygon points="119,185 119,184 119,183 119,182 119,181 119,180 120,176 121,177 121,180 120,184" style="fill: rgb(127,112,107)" /> - <polygon points="193,79 193,78 195,75 196,76 196,79 195,80 194,81" style="fill: rgb(117,80,74)" /> - <polygon points="123,243 123,242 123,241 123,240 123,239 123,238 123,237 123,236 123,235 123,234 123,233 123,232 123,231 123,230 123,229 123,228 127,247 127,252" style="fill: rgb(146,125,120)" /> - <polygon points="269,286 271,285 272,285 273,285 274,285 275,285 276,285 277,285 276,286 275,287 270,287" style="fill: rgb(75,14,19)" /> - <polygon points="306,108 311,117 312,119 314,125 314,126 308,114 307,112 306,109" style="fill: rgb(77,59,57)" /> - <polygon points="150,427 150,426 152,395 154,397 157,402 159,413 159,414 157,420 150,429 150,428" style="fill: rgb(164,160,161)" /> - <polygon points="273,180 274,179 276,178 279,178 283,178 292,180 296,181 297,182 298,184 298,185 292,189 281,193 277,194 276,194 274,192" style="fill: rgb(60,46,43)" /> - <polygon points="361,247 361,246 375,220 376,219 377,219 378,219 415,228 416,230 416,231 412,239 393,247 373,249 372,249 371,249 370,249 365,249 364,249 363,249 362,249" style="fill: rgb(140,136,133)" /> - <polygon points="137,142 170,138 174,138 175,138 167,157 163,161 159,164 145,170 143,168 142,164" style="fill: rgb(204,173,168)" /> - <polygon points="218,404 218,403 219,402 224,401 242,405 242,406 241,411 237,414 222,413 221,412 219,409 218,407" style="fill: rgb(77,59,57)" /> - <polygon points="104,6 104,5 105,5 106,5 107,5 108,5 109,5 110,5 111,5 111,6 111,8 105,8 104,8" style="fill: rgb(216,220,221)" /> - <polygon points="227,70 227,69 228,65 229,64 229,68 229,70 228,70" style="fill: rgb(117,80,74)" /> - <polygon points="293,189 295,187 296,187 299,188 300,189" style="fill: rgb(93,24,29)" /> - <polygon points="313,56 316,53 317,54 318,57 316,57 315,57 314,57" style="fill: rgb(77,59,57)" /> - <polygon points="131,305 132,289 134,289 135,292 136,297 141,403 141,413 141,414 141,415 141,417 141,418 141,419 137,455 136,459 135,459" style="fill: rgb(124,128,129)" /> - <polygon points="453,443 455,442 458,443 458,444 455,448 454,448 453,446" style="fill: rgb(93,24,29)" /> - <polygon points="95,225 95,233 95,224 95,232 95,223 95,227 95,235 95,226 95,234 95,229 95,237 95,220 95,228 95,236 95,219 95,231 95,222 95,230 95,238 95,221" style="fill: rgb(138,98,90)" /> - <polygon points="289,4 289,3 289,1 289,0 316,31 318,34 316,33 299,18 298,17 295,14 293,12 292,11 291,9 290,7 289,5" style="fill: rgb(134,126,124)" /> - <polygon points="113,65 113,64 113,62 113,61 117,56 120,55 120,56 117,61 114,65" style="fill: rgb(222,223,225)" /> - <polygon points="360,154 360,153 372,157 379,162 380,165 378,165 374,163 360,155" style="fill: rgb(101,73,69)" /> - <polygon points="285,182 288,184 288,185 288,186 288,187 287,188 286,188" style="fill: rgb(101,90,86)" /> - <polygon points="308,116 309,117 310,119 312,123 313,125 311,123 309,119 308,117" style="fill: rgb(101,73,69)" /> - <polygon points="202,17 204,14 208,14 209,14 210,14 211,14 212,14 203,18 202,18" style="fill: rgb(180,176,175)" /> - <polygon points="254,194 254,193 254,191 255,190 260,192 261,193 260,194" style="fill: rgb(114,33,39)" /> - <polygon points="0,259 1,258 40,253 52,252 67,251 68,251 73,252 76,253 80,255 85,258 86,259 87,260 91,265 93,269 96,276 98,282 99,288 101,312 102,385 102,423 101,429 0,260" style="fill: rgb(230,230,230)" /> - <polygon points="225,256 228,255 229,255 230,255 236,260 236,261 235,262 228,259" style="fill: rgb(114,33,39)" /> - <polygon points="100,252 104,241 105,243 106,248 106,250 105,255 104,255 103,255 102,255 101,255 100,253" style="fill: rgb(167,117,106)" /> - <polygon points="335,148 336,147 337,146 338,146 339,147 339,149 337,151 336,151" style="fill: rgb(17,16,12)" /> - <polygon points="424,193 424,191 428,193 430,194 426,195 425,195 424,195" style="fill: rgb(87,67,66)" /> - <polygon points="188,156 189,156 190,156 191,156 202,157 204,158 205,159 205,160 192,157" style="fill: rgb(196,156,148)" /> - <polygon points="219,213 219,212 220,211 221,216 221,217 221,218 221,221 221,222 220,221 219,218" style="fill: rgb(220,192,191)" /> - <polygon points="324,328 330,318 337,312 338,314 338,315 337,319 334,327 333,329 332,329 326,329" style="fill: rgb(60,46,43)" /> - <polygon points="150,258 151,256 153,256 154,256 155,256 185,257 185,258 184,262 183,263 180,265 171,271 170,271 161,266 151,259" style="fill: rgb(182,153,145)" /> - <polygon points="262,357 263,357 265,358 265,359 263,363 262,360" style="fill: rgb(101,73,69)" /> - <polygon points="110,386 112,370 122,370 124,372 124,376 124,383 122,400 121,402 112,401 111,400" style="fill: rgb(61,75,78)" /> - <polygon points="341,363 342,360 344,358 347,360 347,365 344,365 343,365 342,365" style="fill: rgb(200,157,150)" /> - <polygon points="277,349 281,345 284,343 286,347 282,353 281,354 279,354 278,352" style="fill: rgb(101,73,69)" /> - <polygon points="348,189 350,191 351,192 356,200 356,202 356,204" style="fill: rgb(117,80,74)" /> - <polygon points="262,158 263,158 264,158 265,158 266,158 267,158 268,158 269,158 270,158 271,158 272,158 274,159 273,161 270,163" style="fill: rgb(101,73,69)" /> - <polygon points="271,182 271,181 272,180 276,179 279,179 281,180 280,181 271,183" style="fill: rgb(37,29,27)" /> - <polygon points="282,89 282,87 282,86 283,85 296,101 302,116 303,128 303,129 300,129 286,106 282,96" style="fill: rgb(167,117,106)" /> - <polygon points="268,87 269,84 271,82 272,87" style="fill: rgb(77,59,57)" /> - <polygon points="174,168 175,167 176,166 275,94 304,121 305,122 306,123 317,150 319,156 319,157 319,158 319,159 318,160 314,162 212,172 201,172" style="fill: rgb(190,139,135)" /> - <polygon points="204,258 246,260 244,275 241,281 240,281 227,281 221,279 216,277 211,272 206,262" style="fill: rgb(77,59,57)" /> - <polygon points="282,283 288,279 289,280 290,282 291,287 291,288 291,289" style="fill: rgb(77,59,57)" /> - <polygon points="163,85 165,82 174,75 181,72 184,71 189,72 189,73 186,77 165,87 163,86" style="fill: rgb(117,80,74)" /> - <polygon points="228,92 228,91 230,88 231,87 230,93 229,95 228,95 228,91 230,88 231,87 230,93 229,95 228,95 228,91" style="fill: rgb(138,98,90)" /> - <polygon points="338,207 338,206 339,205 346,201 349,204 351,206 351,207 343,221" style="fill: rgb(167,117,106)" /> - <polygon points="101,160 105,155 106,156 106,168 106,174 105,175 103,177 102,173 101,169" style="fill: rgb(77,59,57)" /> - <polygon points="377,357 381,359 383,360 393,369 392,370 391,370 390,370 389,370 378,359" style="fill: rgb(220,192,191)" /> - <polygon points="0,178 8,177 9,177 75,181 73,187 72,188 0,188" style="fill: rgb(52,67,70)" /> - <polygon points="151,322 151,321 153,325 153,326 152,328 151,328" style="fill: rgb(130,121,116)" /> - <polygon points="361,149 362,147 365,147 366,147 368,149 368,150 367,151" style="fill: rgb(101,73,69)" /> - <polygon points="223,96 223,95 223,94 226,92 226,95 225,99 224,99" style="fill: rgb(138,98,90)" /> - <polygon points="148,455 149,333 150,334 201,402 209,418 210,420 150,459 149,459 148,459" style="fill: rgb(189,185,182)" /> - <polygon points="152,330 152,329 153,327 154,326 154,328 154,332 154,334 154,335" style="fill: rgb(120,102,98)" /> - <polygon points="225,430 225,429 256,443 258,444 259,445 259,446 259,447 238,459 237,459 231,459 229,455" style="fill: rgb(120,102,98)" /> - <polygon points="143,417 143,416 144,401 145,402 145,403 145,406 145,408 145,410 145,412 145,414 145,416 145,417 144,420 143,423" style="fill: rgb(124,128,129)" /> - <polygon points="127,268 127,266 127,265 129,266 130,267 131,268 132,270 132,271 132,272 132,273 131,273 128,271" style="fill: rgb(101,90,86)" /> - <polygon points="159,178 166,174 175,174 182,174 194,177 197,180 198,181 198,184 197,186 193,186 192,186 159,179" style="fill: rgb(77,59,57)" /> - <polygon points="126,153 126,152 127,149 131,151 135,168 135,183 132,185 131,185 130,183 127,173 126,167" style="fill: rgb(168,137,134)" /> - <polygon points="285,4 286,0 287,1 311,30 311,32 310,32 301,26 300,25 288,12 286,9 285,5" style="fill: rgb(150,149,144)" /> - <polygon points="204,86 204,85 204,80 204,76 204,75 212,69 214,69 218,74 220,84 220,87 217,94 211,92" style="fill: rgb(167,117,106)" /> - <polygon points="166,50 172,46 175,45 175,47 172,49 169,50" style="fill: rgb(77,59,57)" /> - <polygon points="368,229 368,228 368,227 371,218 372,216 373,216 374,216 374,217 374,223 371,228 370,229 368,230" style="fill: rgb(167,117,106)" /> - <polygon points="11,428 11,427 12,427 15,427 16,431 16,432 12,429" style="fill: rgb(238,226,230)" /> - <polygon points="215,421 215,420 216,419 218,421 219,422 223,427 228,436 229,456 229,459 227,459 226,459" style="fill: rgb(130,121,116)" /> - <polygon points="321,352 327,347 326,349 325,351 324,352 323,353 321,353" style="fill: rgb(77,59,57)" /> - <polygon points="315,134 315,129 315,128 316,129 322,145 324,152 324,153 315,135" style="fill: rgb(77,59,57)" /> - <polygon points="402,360 402,358 404,356 406,355 409,355 410,355 446,363 449,367 446,368 432,366 402,361" style="fill: rgb(167,117,106)" /> - <polygon points="144,334 145,334 146,336 157,400 157,401 156,400 151,393 150,391 149,388 147,380 146,375 145,363 144,335" style="fill: rgb(180,176,175)" /> - <polygon points="212,234 212,232 214,229 214,230 213,239 212,235 212,232 214,229 214,230 213,239 212,235 212,232 214,229 214,230 213,239" style="fill: rgb(200,157,150)" /> - <polygon points="316,136 321,146 321,148 317,140 316,138" style="fill: rgb(101,73,69)" /> - <polygon points="228,240 229,235 230,232 231,231 232,234 233,238 232,239 229,240" style="fill: rgb(200,157,150)" /> - <polygon points="240,118 242,117 255,117 255,120 253,122 248,123 245,123 244,123" style="fill: rgb(190,139,135)" /> - <polygon points="305,205 309,193 310,194 311,196 311,197 311,198 308,203 307,204 306,205" style="fill: rgb(167,117,106)" /> - <polygon points="125,144 125,143 125,142 125,141 126,138 127,135 129,133 130,133 131,133 135,138 134,156 133,159 132,159 125,151" style="fill: rgb(182,153,145)" /> - <polygon points="131,108 133,104 136,102 136,103 134,107 133,108 132,109 131,109" style="fill: rgb(60,46,43)" /> - <polygon points="352,256 353,255 354,255 355,255 356,255 360,255 365,257 365,258 352,257" style="fill: rgb(108,98,97)" /> - <polygon points="6,269 8,268 12,267 35,264 36,264 37,264 35,265 31,266 24,267 7,269" style="fill: rgb(216,211,208)" /> - <polygon points="361,144 361,143 362,143 365,143 368,144 366,146 364,147 362,146 361,145" style="fill: rgb(92,76,76)" /> - <polygon points="194,304 196,302 198,300 199,300 200,301 201,304 200,305 196,307 195,306" style="fill: rgb(60,46,43)" /> - <polygon points="212,418 212,416 212,415 213,415 214,416 215,418 215,419 214,420" style="fill: rgb(147,118,114)" /> - <polygon points="231,255 231,254 235,251 236,251 242,253 245,257 241,263 240,264 236,264 235,264 234,264 233,264" style="fill: rgb(77,59,57)" /> - <polygon points="293,4 293,3 293,1 293,0 318,27 321,31 323,34 325,42 325,44 325,47 324,47 294,9 293,6" style="fill: rgb(130,121,116)" /> - <polygon points="401,261 415,261 429,262 436,263 439,279 441,298 442,312 442,313 442,335 441,348 439,350 436,349 416,331 413,327 411,324 408,314 407,309" style="fill: rgb(60,46,43)" /> - <polygon points="235,88 235,87 235,84 235,83 237,73 238,72 240,74 240,83 236,89" style="fill: rgb(138,98,90)" /> - <polygon points="449,279 450,272 451,269 454,265 455,264 449,286 449,283 449,282" style="fill: rgb(136,138,137)" /> - <polygon points="169,112 173,111 176,111 175,114 173,116 170,113" style="fill: rgb(182,153,145)" /> - <polygon points="244,176 250,173 251,173 252,174 250,175 245,176" style="fill: rgb(101,90,86)" /> - <polygon points="47,110 48,108 52,108 55,109 57,110 56,111 54,112 50,112 47,111" style="fill: rgb(182,153,145)" /> - <polygon points="7,434 7,433 8,431 15,433 24,447 27,453 27,454 26,457" style="fill: rgb(235,198,192)" /> - <polygon points="137,118 141,110 142,111 142,112 142,113 140,116 137,119" style="fill: rgb(77,59,57)" /> - <polygon points="243,221 251,223 252,225 252,226 251,226 250,226 248,225 246,224 244,222" style="fill: rgb(117,80,74)" /> - <polygon points="288,293 289,293 290,293 291,295 291,297 291,299 290,298" style="fill: rgb(114,33,39)" /> - <polygon points="0,447 0,445 2,446 7,454 4,455 2,454 1,453 0,450" style="fill: rgb(179,139,137)" /> - <polygon points="148,170 152,167 166,161 167,161 165,164 159,168 150,170" style="fill: rgb(191,165,164)" /> - <polygon points="400,364 402,362 404,361 408,361 409,361 410,361 421,362 418,365 415,367 414,367 400,366" style="fill: rgb(117,80,74)" /> - <polygon points="426,217 426,216 443,215 444,215 445,216 439,217 431,218 430,218 429,218 428,218" style="fill: rgb(108,98,97)" /> - <polygon points="211,357 214,358 216,361 215,362 212,361" style="fill: rgb(101,90,86)" /> - <polygon points="262,39 263,38 274,36 281,40 283,42 282,43 279,43 269,42 266,41 264,40" style="fill: rgb(101,73,69)" /> - <polygon points="211,36 212,35 215,33 218,31 221,30 224,30 225,30 226,30 227,30 228,32 228,33 220,39 216,39 215,39 211,38" style="fill: rgb(60,46,43)" /> - <polygon points="146,28 146,27 147,26 149,24 150,28 148,30 147,31" style="fill: rgb(222,223,225)" /> - <polygon points="239,252 240,250 241,249 244,248 250,248 251,249 251,250 250,251 246,252" style="fill: rgb(16,6,5)" /> - <polygon points="215,423 215,422 216,422 217,423 219,425 222,430 222,431 219,430 216,428" style="fill: rgb(147,118,114)" /> - <polygon points="209,165 211,163 212,163 213,163 220,164" style="fill: rgb(179,139,137)" /> - <polygon points="263,182 265,180 271,177 274,176 274,177 272,178" style="fill: rgb(117,80,74)" /> - <polygon points="162,233 164,231 168,229 174,226 180,224 182,224 183,224 179,228 174,231 170,233 167,234 166,234 165,234" style="fill: rgb(117,80,74)" /> - <polygon points="181,120 181,118 185,116 187,116 188,117 189,118 187,120 183,120 182,120" style="fill: rgb(181,146,144)" /> - <polygon points="157,210 171,203 172,205 172,206 172,207 171,210 170,212 169,213 166,214 165,214 162,214 158,212" style="fill: rgb(52,67,70)" /> - <polygon points="400,343 407,348 409,352 408,353 404,351 402,348 400,344" style="fill: rgb(109,97,97)" /> - <polygon points="271,358 273,356 283,350 284,350 286,353 286,354 285,357 282,359 274,363 271,359" style="fill: rgb(101,73,69)" /> - <polygon points="181,308 181,307 181,306 202,304 203,304 202,305 197,309 194,311 192,311 191,311 190,311 189,311 188,311 183,309" style="fill: rgb(101,73,69)" /> - <polygon points="180,193 188,192 192,193 193,196 192,197 191,197 188,197 187,197" style="fill: rgb(101,73,69)" /> - <polygon points="131,298 131,292 131,288 132,290 132,291 132,292 132,293 132,294 132,295 131,304 131,288 132,290 132,291 132,292 132,293 132,294 132,295 131,304 131,288" style="fill: rgb(119,111,108)" /> - <polygon points="208,63 208,61 209,58 210,56 211,57 212,59 212,60" style="fill: rgb(101,90,86)" /> - <polygon points="212,111 215,104 219,104 221,105 222,108 222,109 222,110 218,117 217,118 214,118" style="fill: rgb(117,80,74)" /> - <polygon points="365,313 366,305 367,304 367,317 367,318 366,318 365,314" style="fill: rgb(99,97,98)" /> - <polygon points="0,263 1,262 4,262 6,262 7,262 13,262 15,262 1,263" style="fill: rgb(180,176,175)" /> - <polygon points="277,170 280,169 284,168 290,167 302,166 303,166 310,166 314,166 315,166 322,167 322,169 315,199 313,199" style="fill: rgb(138,98,90)" /> - <polygon points="141,173 143,172 147,171 148,171 149,171 141,176" style="fill: rgb(182,153,145)" /> - <polygon points="106,117 110,116 111,116 118,120 117,121 116,121 115,121 114,121 113,121 112,121 110,121 109,121" style="fill: rgb(60,46,43)" /> - <polygon points="0,90 2,90 34,90 35,90 60,91 96,97 96,98 95,99 92,99 7,92 0,91" style="fill: rgb(197,193,192)" /> - <polygon points="248,90 249,88 250,86 254,88 258,92 257,93 253,96 251,96 250,95 248,93" style="fill: rgb(101,73,69)" /> - <polygon points="0,282 1,281 3,279 12,275 22,274 23,274 27,274 30,274 31,274 37,274 39,274 44,274 45,274 46,274 47,274 52,274 61,277 63,278 66,280 71,284 72,285 74,288 75,291 76,294 78,304 79,312 87,456 87,457 87,458 87,459 78,459 76,459 75,459 50,459 48,459 39,459 38,459 37,459 36,459 26,435 0,284" style="fill: rgb(250,251,253)" /> - <polygon points="311,38 312,34 314,36 316,38 317,40 316,42 314,41" style="fill: rgb(164,160,161)" /> - <polygon points="354,322 354,320 354,319 354,318 357,327 358,331 358,332 357,331 355,325" style="fill: rgb(147,118,114)" /> - <polygon points="165,457 165,456 166,452 167,449 169,448 170,449 169,451 165,459" style="fill: rgb(230,218,220)" /> - <polygon points="0,256 34,252 60,249 61,249 67,249 68,249 74,250 77,251 81,253 85,255 89,259 92,263 93,265 95,269 97,274 100,283 101,296 101,297 101,310 101,311 0,258" style="fill: rgb(202,203,205)" /> - <polygon points="297,0 298,0 320,21 324,27 325,29 327,33 329,40 331,59 331,65 328,64 298,8" style="fill: rgb(130,121,116)" /> - <polygon points="332,395 332,394 335,392 335,393 333,400 332,400" style="fill: rgb(182,153,145)" /> - <polygon points="209,452 209,451 209,450 209,449 217,437 217,443 217,444 216,449 213,458 212,459 210,459 209,455" style="fill: rgb(191,165,164)" /> - <polygon points="223,64 224,63 225,64 225,68 224,70 223,65" style="fill: rgb(117,80,74)" /> - <polygon points="109,242 120,261 118,264 116,265 114,263 111,257 110,253 109,247 109,244" style="fill: rgb(138,98,90)" /> - <polygon points="252,124 258,105 275,78 279,75 283,78 293,90 297,97 300,103 312,127 319,147 321,153 322,159 322,160 319,161 255,126" style="fill: rgb(167,117,106)" /> - <polygon points="333,167 333,166 333,165 338,158 341,158 344,160 344,163 343,165 342,166 340,167 335,169" style="fill: rgb(17,16,12)" /> - <polygon points="204,298 206,296 211,294 216,293 215,294 210,296" style="fill: rgb(77,59,57)" /> - <polygon points="242,99 242,98 245,95 246,95 246,97 246,98 244,99 243,99" style="fill: rgb(138,98,90)" /> - <polygon points="135,216 136,215 143,233 143,236 141,236 139,235 135,224" style="fill: rgb(196,156,148)" /> - <polygon points="416,212 417,211 418,211 426,212 426,213 425,213 424,213 418,213" style="fill: rgb(92,76,76)" /> - <polygon points="153,46 156,44 160,45 161,49 159,51 158,51" style="fill: rgb(101,90,86)" /> - <polygon points="0,189 1,188 7,186 76,180 84,180 91,188 89,191 87,193 57,195 56,195 3,193 0,191" style="fill: rgb(61,75,78)" /> - <polygon points="284,289 288,286 290,288 290,290 289,290 288,290 285,290" style="fill: rgb(93,24,29)" /> - <polygon points="295,34 295,33 301,35 303,38 296,37" style="fill: rgb(87,67,66)" /> - <polygon points="0,132 48,131 55,131 63,131 78,131 79,131 80,132 82,136 82,137 82,145 82,147 80,150 76,151 72,151 22,145 0,141" style="fill: rgb(209,203,203)" /> - <polygon points="290,1 290,0 291,0 298,15 294,12 292,9 291,7" style="fill: rgb(130,121,116)" /> - <polygon points="401,216 458,208 459,208 459,209 454,215 450,218 439,219 427,219 413,218 402,217" style="fill: rgb(101,90,86)" /> - <polygon points="209,369 210,367 211,366 213,365 210,371 209,371" style="fill: rgb(77,59,57)" /> - <polygon points="225,80 225,72 229,79 229,80 229,82 229,84 229,85 226,90 225,87 225,74 225,72 229,79 229,80 229,82 229,84 229,85 226,90 225,87 225,74 225,72 229,79 229,80 229,82 229,84 229,85 226,90 225,87 225,74 225,72 229,79 229,80 229,82 229,84 229,85 226,90" style="fill: rgb(138,98,90)" /> - <polygon points="133,211 135,209 136,212 136,213 134,219 133,214" style="fill: rgb(181,146,144)" /> - <polygon points="146,441 146,440 148,431 149,432 146,445 146,444" style="fill: rgb(164,160,161)" /> - <polygon points="163,259 163,256 164,255 165,255 166,255 167,255 167,259 166,260 164,260" style="fill: rgb(196,156,148)" /> - <polygon points="224,370 225,365 228,362 231,362 231,364 229,373 228,375 227,374" style="fill: rgb(92,76,76)" /> - <polygon points="163,18 163,17 166,16 167,16 168,18 168,19" style="fill: rgb(242,236,240)" /> - <polygon points="204,104 207,101 213,97 218,104 218,105 218,107 218,108 217,109 214,111 211,111 207,110" style="fill: rgb(117,80,74)" /> - <polygon points="146,313 150,313 151,313 152,313 156,316 155,321 154,322 153,322 147,320 146,314" style="fill: rgb(120,102,98)" /> - <polygon points="129,122 130,120 132,116 134,114 137,112 138,112 137,114 135,117 130,123" style="fill: rgb(17,16,12)" /> - <polygon points="284,4 284,3 284,1 284,0 285,0 289,14 289,15 288,16 286,12 285,10 284,6 284,5" style="fill: rgb(171,169,170)" /> - <polygon points="185,240 188,238 192,237 193,238 191,240 188,240" style="fill: rgb(147,118,114)" /> - <polygon points="344,124 346,125 351,133 351,134 350,136 349,136 347,134 346,133 345,132 344,125" style="fill: rgb(60,46,43)" /> - <polygon points="232,409 232,408 235,407 236,407 237,410 236,410 232,410" style="fill: rgb(92,76,76)" /> - <polygon points="357,252 359,251 360,251 361,251 392,251 393,251 394,251 395,251 396,251 397,251 398,251 399,251 385,253 365,255 364,255 359,254 358,253" style="fill: rgb(127,112,107)" /> - <polygon points="294,276 294,275 296,274 298,276 299,280 299,282 297,284 295,286 294,283" style="fill: rgb(75,14,19)" /> - <polygon points="255,189 259,183 262,181 270,180 269,182 268,183 264,186 256,189" style="fill: rgb(77,59,57)" /> - <polygon points="137,219 137,216 147,222 148,223 147,236 146,238 144,238 143,237 142,235" style="fill: rgb(168,137,134)" /> - <polygon points="224,57 224,56 227,55 228,57 228,59 228,60 226,60 224,58" style="fill: rgb(101,90,86)" /> - <polygon points="200,125 200,124 202,120 204,117 210,111 252,99 253,99 262,103 262,106 262,107 262,110 261,116 257,121 252,127 224,131 220,131 216,130" style="fill: rgb(138,98,90)" /> - <polygon points="295,3 296,0 317,21 318,22 322,27 324,31 326,35 327,41 327,52 327,53 297,9" style="fill: rgb(119,111,108)" /> - <polygon points="64,139 74,137 75,137 80,137 80,138 78,143 77,143 76,143 75,143 74,143 73,143 72,143 64,140" style="fill: rgb(216,211,208)" /> - <polygon points="234,209 234,208 240,213 242,216 240,217 239,216" style="fill: rgb(17,16,12)" /> - <polygon points="324,275 324,274 324,267 324,265 325,263 326,263 327,264 330,268 333,276 333,277 331,280 329,279 325,277 324,276" style="fill: rgb(101,73,69)" /> - <polygon points="313,81 313,80 317,74 319,73 320,73 323,74 325,80 325,85 324,85 323,85 322,85 319,85 314,82" style="fill: rgb(37,29,27)" /> - <polygon points="436,250 436,249 444,248 445,250 447,254 448,258 448,263" style="fill: rgb(120,102,98)" /> - <polygon points="330,298 333,292 334,292 335,292 335,293 335,296 335,297 332,299 330,299" style="fill: rgb(87,67,66)" /> - <polygon points="232,109 232,108 233,104 234,103 236,102 238,111 238,113 238,114 236,116 235,116" style="fill: rgb(138,98,90)" /> - <polygon points="267,29 269,27 273,27 274,29 269,30 268,30" style="fill: rgb(127,112,107)" /> - <polygon points="195,146 197,142 207,137 211,136 216,136 217,136 218,136 223,136 253,141 252,142 246,145 229,151 228,151 227,151 226,151 225,151 219,151 218,151 211,151 196,147" style="fill: rgb(200,157,150)" /> - <polygon points="364,458 368,448 404,391 412,380 426,407 373,455 368,459 365,459 364,459" style="fill: rgb(75,14,19)" /> - <polygon points="187,80 188,79 190,77 195,83 194,86 191,84 187,81" style="fill: rgb(87,67,66)" /> - <polygon points="343,212 343,211 343,208 343,207 343,206 344,185 352,160 353,158 367,162 371,167 373,170 377,178 378,183 378,185 378,191 371,222 367,231 363,238 355,247 351,250 350,250 349,250 348,250 347,250 346,250 345,249 343,213" style="fill: rgb(117,80,74)" /> - <polygon points="262,21 262,16 264,0 267,0 270,16 270,18 264,21 263,21" style="fill: rgb(222,223,225)" /> - <polygon points="302,199 302,196 303,195 307,191 308,192 309,194 309,195 309,196 309,197 309,198 306,204 304,206 303,204" style="fill: rgb(167,117,106)" /> - <polygon points="152,113 153,113 154,113 156,114 157,115 158,117 158,118 155,116" style="fill: rgb(167,117,106)" /> - <polygon points="0,451 3,452 6,459 4,459 3,459 2,458 0,453" style="fill: rgb(168,137,134)" /> - <polygon points="0,273 2,271 8,269 9,269 12,269 2,273 1,273" style="fill: rgb(215,217,216)" /> - <polygon points="152,206 153,205 155,208 157,212 156,212 155,212 154,211 152,208" style="fill: rgb(92,76,76)" /> - <polygon points="83,174 84,173 85,172 86,172 88,173 89,174 89,175" style="fill: rgb(115,119,120)" /> - <polygon points="0,7 0,6 16,5 17,5 18,5 19,5 20,5 21,5 22,5 23,5 15,7 10,7 8,7 1,7" style="fill: rgb(219,219,219)" /> - <polygon points="204,59 208,49 209,47 210,46 214,44 213,49 205,59" style="fill: rgb(87,67,66)" /> - <polygon points="227,89 230,77 231,75 231,80 231,81 229,92" style="fill: rgb(117,80,74)" /> - <polygon points="202,324 210,323 211,323 210,326 209,327 208,327 204,327 203,327" style="fill: rgb(167,117,106)" /> - <polygon points="275,60 275,59 275,58 276,55 279,53 297,52 299,52 304,53 310,57 316,61 319,64 320,65 350,98 352,101 353,107 355,120 355,152 355,154 337,177 336,178 334,177" style="fill: rgb(37,29,27)" /> - <polygon points="171,345 171,343 172,340 334,300 338,300 339,314 339,316 339,317 339,321 335,330 329,343 327,346 320,356 310,370 287,398 286,399 268,405 245,409 244,409 211,389 208,387 180,362 173,353 171,346" style="fill: rgb(101,73,69)" /> - <polygon points="202,248 203,246 204,245 206,244 208,246 204,249 202,249" style="fill: rgb(179,139,137)" /> - <polygon points="0,172 2,172 12,172 14,172 61,175 71,176 71,177 68,177 37,176 3,174 0,173" style="fill: rgb(99,97,98)" /> - <polygon points="129,53 130,51 135,47 139,45 140,45 142,46 130,54" style="fill: rgb(134,126,124)" /> - <polygon points="325,413 325,412 328,407 336,406 345,408 345,413 345,414 335,417 331,418 330,418 327,415" style="fill: rgb(182,153,145)" /> - <polygon points="312,112 313,112 315,114 316,115 317,117 314,116 313,115" style="fill: rgb(60,46,43)" /> - <polygon points="240,185 253,184 253,185 246,191 245,191 243,191 240,188" style="fill: rgb(77,59,57)" /> - <polygon points="269,1 269,0 272,14 272,16 272,18 271,17 269,10 269,9 269,0 272,14 272,16 272,18 271,17 269,10 269,9 269,0 272,14 272,16 272,18 271,17 269,10 269,9 269,0 272,14" style="fill: rgb(219,219,219)" /> - <polygon points="235,82 235,81 236,67 239,66 247,74 247,75 246,80 245,82 241,84" style="fill: rgb(117,80,74)" /> - <polygon points="344,196 344,195 344,191 344,190 344,189 345,189 346,189 348,191 349,192 355,204 355,208 355,209 354,208 353,207 352,206" style="fill: rgb(114,33,39)" /> - <polygon points="234,195 234,194 237,192 238,192 255,195 258,196 291,209 293,210 290,212 281,215 261,217 260,217 256,217 252,217 239,207 238,206 237,204" style="fill: rgb(138,98,90)" /> - <polygon points="247,174 248,170 254,168 258,168 259,169 257,170" style="fill: rgb(101,73,69)" /> - <polygon points="194,131 197,128 202,126 213,137 214,138 208,138 203,138 202,138 201,138 200,138 194,132" style="fill: rgb(196,156,148)" /> - <polygon points="88,204 88,203 93,197 94,200 95,207 93,207 89,205" style="fill: rgb(83,97,100)" /> - <polygon points="207,244 207,242 210,241 211,245 208,245 207,245" style="fill: rgb(168,137,134)" /> - <polygon points="230,432 230,429 237,431 241,435 239,437 238,437 231,433" style="fill: rgb(117,80,74)" /> - <polygon points="212,47 214,45 215,44 217,45 218,46 213,48 212,48" style="fill: rgb(77,59,57)" /> - <polygon points="226,173 234,165 251,158 254,157 275,155 276,155 278,156 280,160 280,161 279,163 230,181 227,182 226,174" style="fill: rgb(60,46,43)" /> - <polygon points="103,208 104,207 105,206 107,205 117,213 116,217 115,219 114,219 104,209" style="fill: rgb(77,59,57)" /> - <polygon points="419,212 424,211 443,210 445,210 447,211 439,213 437,213 431,213 430,213 427,213" style="fill: rgb(87,67,66)" /> - <polygon points="286,217 288,216 299,213 300,213 301,213 295,215 288,217" style="fill: rgb(127,112,107)" /> - <polygon points="367,160 367,159 368,158 371,159 385,166 395,176 399,187 399,188 399,189 398,195 394,201 391,205 388,207 382,207 381,207 380,205" style="fill: rgb(101,73,69)" /> - <polygon points="239,426 243,420 341,318 341,319 341,321 329,361 323,379 313,393 294,418 287,427 251,430 250,430 246,429" style="fill: rgb(87,67,66)" /> - <polygon points="143,112 143,108 147,102 150,104 150,105 149,107 147,111 146,112 144,112" style="fill: rgb(87,67,66)" /> - <polygon points="234,366 234,364 234,363 237,360 269,352 270,354 270,356 269,359 264,364 234,375" style="fill: rgb(87,67,66)" /> - <polygon points="284,396 285,391 295,384 301,384 295,390 293,392 292,393 289,396 288,396" style="fill: rgb(87,67,66)" /> - <polygon points="289,324 294,318 298,324 297,326 291,327 290,327" style="fill: rgb(77,59,57)" /> - <polygon points="318,48 320,39 321,40 322,46 322,52 321,52 319,51 318,49" style="fill: rgb(136,138,137)" /> - <polygon points="383,322 383,321 387,320 391,320 391,324 387,324 384,323" style="fill: rgb(109,97,97)" /> - <polygon points="118,161 118,169 118,168 118,167 118,166 118,165 118,173 118,164 118,172 118,163 118,171 118,162 118,170" style="fill: rgb(120,102,98)" /> - <polygon points="154,327 156,324 157,323 159,325 157,330 155,331" style="fill: rgb(120,102,98)" /> - <polygon points="118,370 120,366 121,366 123,367 119,372 118,371" style="fill: rgb(68,83,86)" /> - <polygon points="278,4 278,3 278,1 278,0 284,16 282,17 281,16 280,14 278,9 278,0 284,16 282,17 281,16 280,14 278,9 278,0 284,16 282,17 281,16 280,14 278,9 278,0 284,16 282,17 281,16 280,14 278,9" style="fill: rgb(197,193,192)" /> - <polygon points="343,300 343,298 343,292 343,291 343,283 343,281 343,272 345,271 346,273 348,288 348,289 346,306 344,307 343,303" style="fill: rgb(117,80,74)" /> - <polygon points="223,11 235,14 229,14 224,12" style="fill: rgb(230,230,230)" /> - <polygon points="318,426 320,425 322,426 323,427 322,428 320,428 319,427" style="fill: rgb(181,146,144)" /> - <polygon points="121,280 121,279 122,277 126,269 127,271 127,275 123,282 122,281" style="fill: rgb(167,117,106)" /> - <polygon points="302,0 303,0 310,0 311,0 319,0 326,0 335,0 342,0 351,0 359,0 360,0 361,1 361,2 361,3 360,4 333,23 332,23 331,23 330,23 329,23 328,23 327,23 303,9 302,8" style="fill: rgb(60,46,43)" /> - <polygon points="199,286 201,279 206,276 207,283 207,284 204,290 203,291 202,291 199,287" style="fill: rgb(147,118,114)" /> - <polygon points="442,361 442,360 445,310 445,313 445,347 444,362" style="fill: rgb(92,76,76)" /> - <polygon points="49,238 51,236 52,235 56,232 58,231 59,231 58,232 49,239" style="fill: rgb(119,111,108)" /> - <polygon points="88,3 90,1 91,0 92,0 99,0 103,0 107,0 111,0 115,0 119,0 123,0 124,0 124,1 119,8 115,8 114,8 113,8 112,8 101,7 91,5 89,4" style="fill: rgb(219,219,219)" /> - <polygon points="266,22 270,21 271,21 276,22 276,23 276,24 272,24 269,23" style="fill: rgb(197,193,192)" /> - <polygon points="103,257 103,256 105,242 106,235 107,235 108,251 108,262 108,264 107,264 106,263 103,258" style="fill: rgb(179,139,137)" /> - <polygon points="325,424 325,422 325,421 326,420 327,420 332,422 333,423 331,424 327,426 326,426 325,426" style="fill: rgb(182,153,145)" /> - <polygon points="311,367 311,366 315,360 316,359 317,358 321,355 321,356 318,361 312,369 311,370" style="fill: rgb(77,59,57)" /> - <polygon points="96,240 100,226 101,223 102,221 104,218 107,214 117,228 117,231 117,260 116,260 113,258 101,247 100,246 98,244" style="fill: rgb(181,146,144)" /> - <polygon points="435,236 435,235 436,232 455,223 456,224 456,242 449,274 448,272 436,239" style="fill: rgb(134,126,124)" /> - <polygon points="84,424 85,423 86,425 87,427 89,436 91,447 91,448 91,449 88,448 86,442 84,429" style="fill: rgb(230,218,220)" /> - <polygon points="251,206 252,205 254,206 258,208 259,211 255,210 251,207" style="fill: rgb(167,117,106)" /> - <polygon points="40,263 41,263 46,263 47,263 51,263 68,264 74,267 79,271 85,280 87,285 89,291 90,294 90,297 90,301 90,303 89,325 88,326" style="fill: rgb(230,230,230)" /> - <polygon points="0,159 2,159 6,159 7,159 8,159 31,160 86,163 87,166 87,167 83,167 6,162 0,161" style="fill: rgb(164,160,161)" /> - <polygon points="163,95 163,94 165,90 167,88 169,87 171,93 170,94 166,95 164,95" style="fill: rgb(147,118,114)" /> - <polygon points="0,269 1,268 2,267 9,265 40,260 41,260 46,260 47,260 67,261 70,262 73,263 79,266 83,272 91,286 92,288 93,296 93,297 93,309 93,311 93,425 91,423 0,270" style="fill: rgb(243,244,246)" /> - <polygon points="92,191 92,190 92,187 92,186 94,186 95,195 95,196 93,196 92,193" style="fill: rgb(101,90,86)" /> - <polygon points="165,88 165,86 174,76 175,76 182,79 181,81 176,87" style="fill: rgb(117,80,74)" /> - <polygon points="328,73 328,72 330,73 331,74 331,75 331,76 330,76 329,76 328,76 328,72 330,73 331,74 331,75 331,76" style="fill: rgb(37,29,27)" /> - <polygon points="140,59 140,58 140,55 142,52 143,51 145,49 151,47 152,48 154,53 153,55 151,56" style="fill: rgb(109,97,97)" /> - <polygon points="350,166 350,165 352,164 353,164 354,164 355,164 356,164 357,164 358,164 359,164 364,166 365,167 365,168 359,169 352,167" style="fill: rgb(114,33,39)" /> - <polygon points="248,80 248,79 248,78 248,77 249,76 250,75 252,75 253,76 253,79 251,83 250,85" style="fill: rgb(117,80,74)" /> - <polygon points="0,251 62,234 63,234 67,234 71,234 75,235 82,242 93,257 97,264 100,271 101,274 102,280 103,290 103,294 103,295 103,296 103,297 103,306 103,307 103,308 103,309 1,252" style="fill: rgb(201,196,193)" /> - <polygon points="16,263 40,258 41,258 64,258 70,259 73,260 75,261 81,265 83,267 84,268 86,271 91,280 93,285 93,289" style="fill: rgb(217,216,214)" /> - <polygon points="185,47 185,46 187,40 191,38 194,40 194,41 193,43 186,47" style="fill: rgb(77,59,57)" /> - <polygon points="288,150 292,149 293,149 295,150 290,151 288,151" style="fill: rgb(179,139,137)" /> - <polygon points="119,48 119,47 121,48 123,49 123,52 122,53 120,51" style="fill: rgb(230,230,230)" /> - <polygon points="83,233 90,234 97,255 96,256 95,256 88,248" style="fill: rgb(119,111,108)" /> - <polygon points="106,429 106,428 106,424 106,418 106,413 106,412 106,411 107,373 108,449 108,456 107,459 106,430" style="fill: rgb(124,128,129)" /> - <polygon points="92,449 92,448 95,452 95,458 95,459" style="fill: rgb(222,223,225)" /> - <polygon points="198,316 199,312 202,310 203,310 212,319 215,323 204,324 203,324 200,323 198,317" style="fill: rgb(167,117,106)" /> - <polygon points="1,442 2,440 3,440 4,441 6,445 6,446 2,443" style="fill: rgb(191,165,164)" /> - <polygon points="22,249 32,247 33,247 34,247 35,247 28,249 24,249" style="fill: rgb(83,97,100)" /> - <polygon points="254,222 256,221 257,221 259,221 265,221 266,221 267,221 268,221 263,222" style="fill: rgb(37,29,27)" /> - <polygon points="164,90 168,85 173,81 175,87 175,88 175,89 174,90 166,96 165,96" style="fill: rgb(138,98,90)" /> - <polygon points="147,63 149,63 154,64 151,65 149,65" style="fill: rgb(87,67,66)" /> - <polygon points="254,162 255,162 257,162 258,162 259,162 264,162 265,162 263,163 255,163" style="fill: rgb(75,14,19)" /> - <polygon points="300,16 307,21 312,25 316,29 321,35 322,40 322,44 322,45 303,20" style="fill: rgb(150,149,144)" /> - <polygon points="430,358 436,359 440,360 441,361 439,362 434,361 432,360 431,359" style="fill: rgb(101,73,69)" /> - <polygon points="230,59 231,57 234,53 238,53 239,54 239,55 239,56 238,63 233,71 232,71 231,67 230,63" style="fill: rgb(60,46,43)" /> - <polygon points="213,135 214,135 215,135 216,135 217,135 218,135 221,135 222,135 223,135 221,138 220,138 219,138 218,138" style="fill: rgb(196,156,148)" /> - <polygon points="127,76 131,73 136,70 137,70 141,71 130,77 129,77 128,77" style="fill: rgb(77,59,57)" /> - <polygon points="159,200 163,199 164,199 168,205 168,206 168,207 167,208 165,209 164,209 163,209 160,208" style="fill: rgb(37,29,27)" /> - <polygon points="0,92 2,92 3,92 6,92 29,92 31,92 34,92 35,92 38,92 39,92 42,92 43,92 59,93 96,99 96,100 92,103 91,103 90,103 3,94 0,93" style="fill: rgb(189,185,182)" /> - <polygon points="87,452 88,450 91,453 92,456 92,458 92,459 91,459 90,459 89,459 88,459" style="fill: rgb(230,230,230)" /> - <polygon points="300,353 302,348 304,348 305,348 307,350 307,351 305,353 301,355 300,355" style="fill: rgb(60,46,43)" /> - <polygon points="91,359 91,358 91,357 91,356 91,350 91,349 91,348 91,347 91,342 91,341 91,340 91,339 91,338 94,291 95,299 100,446 100,459 94,425 93,415 91,375" style="fill: rgb(197,193,192)" /> - <polygon points="210,230 210,226 210,225 211,224 211,226 211,227 210,235" style="fill: rgb(146,125,120)" /> - <polygon points="219,353 219,352 220,351 221,350 222,350 223,350 224,351 224,354 224,355 223,355 221,355 219,354" style="fill: rgb(117,80,74)" /> - <polygon points="88,449 89,448 91,450 92,451 93,453 94,456 94,458 94,459 93,459" style="fill: rgb(222,223,225)" /> - <polygon points="154,456 155,452 160,437 166,428 168,426 184,424 188,424 191,424 196,424 199,424 208,426 209,427 202,434 201,435 200,436 157,459 156,459 155,459 154,459" style="fill: rgb(216,211,208)" /> - <polygon points="162,457 162,455 163,453 171,438 172,437 175,437 187,438 191,439 194,440 194,441 192,443 164,459 163,459 162,459" style="fill: rgb(230,218,220)" /> - <polygon points="358,248 364,234 365,233 367,232 368,232 368,233 364,244" style="fill: rgb(146,125,120)" /> - <polygon points="197,188 205,187 209,188" style="fill: rgb(101,90,86)" /> - <polygon points="150,250 152,247 161,246 162,246 163,246 187,247 187,248 185,249 173,251 151,254 150,254" style="fill: rgb(179,139,137)" /> - <polygon points="55,459 56,456 63,453 64,453 74,456 74,458 74,459" style="fill: rgb(243,244,246)" /> - <polygon points="315,101 316,98 320,98 325,107 326,109 326,112 325,112 324,112 322,110 316,103" style="fill: rgb(16,6,5)" /> - <polygon points="23,171 32,171 33,171 35,171 48,172 47,173 46,173 44,173 41,173 40,173 37,173 29,172" style="fill: rgb(119,111,108)" /> - <polygon points="160,48 160,46 160,44 163,43 163,47 162,48 161,48" style="fill: rgb(101,73,69)" /> - <polygon points="348,420 348,419 350,410 351,409 360,416 363,422 363,423 363,426 362,429 361,430 359,429 350,424" style="fill: rgb(196,156,148)" /> - <polygon points="144,120 144,119 154,105 157,101 158,100 158,101 158,102 157,114" style="fill: rgb(138,98,90)" /> - <polygon points="178,30 178,29 179,29 184,29 185,31 181,31 180,31 179,31" style="fill: rgb(120,102,98)" /> - <polygon points="240,51 240,50 244,52 244,53 243,54 242,54 241,54 240,52 240,50 244,52 244,53 243,54 242,54" style="fill: rgb(77,59,57)" /> - <polygon points="291,332 295,335 295,336 295,337 294,337 293,337 291,334" style="fill: rgb(60,46,43)" /> - <polygon points="392,262 403,258 406,258 407,258 409,258 410,258 411,258 425,258 433,259 439,262 440,264 443,312 443,313 443,336 443,337 442,351 441,354 440,356 439,356 438,356 437,356 436,356 424,348 410,333 405,327 402,319 401,314 392,263" style="fill: rgb(60,46,43)" /> - <polygon points="212,57 212,56 213,52 215,50 217,52 215,57 213,59 212,58" style="fill: rgb(101,90,86)" /> - <polygon points="127,297 127,296 127,295 127,294 127,293 127,292 127,291 127,290 127,289 127,288 129,289 130,292 131,295 135,396 135,397 135,398 135,399 135,400 135,401 135,402 135,403 135,404 135,405 135,406 135,407 135,408 135,409 135,410 135,411 133,459 132,459 131,445 128,375 127,313 127,312" style="fill: rgb(83,97,100)" /> - <polygon points="216,92 218,88 219,92 219,95 218,95" style="fill: rgb(101,73,69)" /> - <polygon points="149,216 156,213 157,213 176,216 175,218 173,220 172,221 167,225 166,225 153,219" style="fill: rgb(117,80,74)" /> - <polygon points="446,343 446,340 447,344 447,345 446,357 446,340 447,344 447,345 446,357 446,340 447,344 447,345 446,357 446,340 447,344 447,345 446,357 446,340 447,344" style="fill: rgb(120,102,98)" /> - <polygon points="160,112 161,110 167,102 180,101 181,101 178,117 167,119 166,119 165,119 161,116" style="fill: rgb(168,137,134)" /> - <polygon points="150,204 151,203 152,202 156,200 159,199 168,199 169,199 171,205 171,206 171,207 165,211 159,212 150,205" style="fill: rgb(60,46,43)" /> - <polygon points="235,25 235,24 236,23 240,23 243,25 243,26 242,28 240,28 235,26" style="fill: rgb(101,73,69)" /> - <polygon points="0,438 2,438 4,438 5,439 7,441 7,445 7,446 7,447 0,439" style="fill: rgb(191,165,164)" /> - <polygon points="217,31 218,30 221,29 224,28 227,28 227,29 220,32" style="fill: rgb(77,59,57)" /> - <polygon points="364,241 365,238 369,230 372,226 379,226 384,229 387,232 387,233 386,235 385,236 375,244 367,245 364,243" style="fill: rgb(140,136,133)" /> - <polygon points="167,38 168,35 171,33 174,34 170,37" style="fill: rgb(101,90,86)" /> - <polygon points="121,144 122,138 126,133 127,132 151,115 152,117 153,120 128,197 126,197 125,196 124,191" style="fill: rgb(182,153,145)" /> - <polygon points="211,299 213,298 216,297 219,297 220,297 221,297 213,300 211,300" style="fill: rgb(93,24,29)" /> - <polygon points="113,160 115,152 116,152 116,160" style="fill: rgb(92,76,76)" /> - <polygon points="300,89 301,88 302,88 303,88 305,89 321,97 330,104 336,125 334,146 333,146 328,144 303,96 302,94" style="fill: rgb(60,46,43)" /> - <polygon points="98,223 98,221 98,219 98,217 98,215 99,214 100,214 101,214 102,214 103,215 103,216 102,218 98,225" style="fill: rgb(114,33,39)" /> - <polygon points="296,389 296,383 302,379 303,381 303,386 302,387" style="fill: rgb(77,59,57)" /> - <polygon points="286,35 286,34 288,33 293,31 294,31 298,32 298,33 296,36 288,38 287,38 286,38" style="fill: rgb(87,67,66)" /> - <polygon points="143,177 148,174 152,172 155,171 156,171 157,171 158,171 160,171 159,172 151,177" style="fill: rgb(146,125,120)" /> - <polygon points="143,281 144,280 150,278 151,278 152,278 153,278 148,283 144,282" style="fill: rgb(147,118,114)" /> - <polygon points="209,308 210,306 212,305 235,298 246,295 270,293 272,293 273,293 274,293 275,293 276,293 281,294 284,297 284,298 283,301 223,312 222,312 216,311" style="fill: rgb(167,117,106)" /> - <polygon points="107,361 107,360 107,363 107,362 107,372 107,369 107,368 107,371 107,370 107,365 107,364 107,367 107,366" style="fill: rgb(119,111,108)" /> - <polygon points="168,51 175,48 175,49 173,51 168,52" style="fill: rgb(92,76,76)" /> - <polygon points="432,256 432,255 439,255 442,258 443,259 444,263 442,281" style="fill: rgb(92,76,76)" /> - <polygon points="261,35 263,35 272,36 272,37 266,37 265,37 263,37" style="fill: rgb(92,76,76)" /> - <polygon points="245,166 251,161 254,160 261,166 259,167 252,169 251,169" style="fill: rgb(60,46,43)" /> - <polygon points="390,207 393,206 394,206 395,206 396,206 397,209 396,209 395,209 394,209 390,208" style="fill: rgb(101,73,69)" /> - <polygon points="303,82 304,81 309,80 311,80 311,81 311,82 310,83 309,83 308,83 307,83 306,83 305,83" style="fill: rgb(60,46,43)" /> - <polygon points="156,96 157,92 159,88 160,87 161,86 159,93 156,98" style="fill: rgb(77,59,57)" /> - <polygon points="0,277 1,276 3,275 6,274 10,273 16,272 41,269 43,269 46,269 65,271 72,278 77,285 80,291 81,294 82,298 82,308 82,309 82,312 82,313 82,323 82,324 82,329 82,330 82,331 82,415 81,421 80,423 79,423 78,423 0,281" style="fill: rgb(250,251,253)" /> - <polygon points="279,177 285,176 288,176 291,179 291,180 290,180" style="fill: rgb(77,59,57)" /> - <polygon points="159,36 160,35 164,33 168,33 163,36" style="fill: rgb(127,112,107)" /> - <polygon points="382,272 382,271 382,270 383,264 384,259 400,256 407,256 410,256 411,256 415,256 431,256 439,258 441,259 442,264 444,304 444,311 444,313 444,344 444,345 443,357 442,359 441,360 439,360 431,358 427,356 413,345 412,344 397,324 394,318 389,303" style="fill: rgb(77,59,57)" /> - <polygon points="275,176 276,175 280,174 281,174 283,176 276,177 275,177" style="fill: rgb(101,73,69)" /> - <polygon points="185,111 187,105 196,91 197,92 195,101 188,110" style="fill: rgb(138,98,90)" /> - <polygon points="164,167 167,163 168,162 184,159 191,160 193,161 194,162 194,164 188,165 173,167" style="fill: rgb(190,139,135)" /> - <polygon points="187,36 192,34 193,34 197,34 198,34 199,34 200,38 200,39 197,41 196,41 195,41" style="fill: rgb(77,59,57)" /> - <polygon points="287,176 289,176 293,178 295,180 293,180 289,178" style="fill: rgb(93,24,29)" /> - <polygon points="432,252 433,252 434,252 435,252 436,252 437,252 438,252 439,252 443,253 444,254 445,255 445,258 445,260" style="fill: rgb(108,98,97)" /> - <polygon points="208,388 209,388 274,397 284,400 284,401 274,405 271,406 262,409 245,410 240,410 226,410 225,410" style="fill: rgb(60,46,43)" /> - <polygon points="226,35 226,34 230,30 232,32 232,34 229,35 227,35" style="fill: rgb(60,46,43)" /> - <polygon points="271,31 272,30 273,30 274,30 275,30 276,30 279,31 279,32 273,32" style="fill: rgb(120,102,98)" /> - <polygon points="245,61 250,54 261,47 290,40 291,40 309,40 340,81 346,89 349,93 354,103 355,107 355,118 355,119 344,121 343,121 255,91 246,67 245,62" style="fill: rgb(37,29,27)" /> - <polygon points="258,288 259,286 263,285 269,285 270,285 274,288 259,288" style="fill: rgb(93,24,29)" /> - <polygon points="0,32 29,8 48,5 147,0 150,0 158,0 166,0 174,0 182,0 190,0 198,0 206,0 214,0 222,0 230,0 238,0 246,0 254,0 260,0 261,0 262,0 263,0 264,8 265,18 265,19 264,20 101,82 100,82 99,82 98,82 97,82 96,82 20,76 5,73 0,72" style="fill: rgb(222,223,225)" /> - <polygon points="246,102 247,101 248,100 255,95 259,94 260,94 260,95 260,96 259,99 257,103 254,109 252,111 248,112" style="fill: rgb(138,98,90)" /> - <polygon points="191,47 192,46 197,42 197,45 195,47 193,49 192,49 191,48" style="fill: rgb(101,90,86)" /> - <polygon points="133,366 138,402 138,403 138,404 138,405 138,406 138,407 138,408 138,409 138,410 138,411 135,457 134,459 133,385" style="fill: rgb(99,97,98)" /> - <polygon points="169,333 169,329 169,328 173,327 174,327 182,333 181,334 177,338 176,339 169,335" style="fill: rgb(87,67,66)" /> - <polygon points="135,291 137,290 138,296 138,298 136,296" style="fill: rgb(119,111,108)" /> - <polygon points="392,332 393,332 394,332 395,333 399,339 399,340 398,340 397,339 396,338" style="fill: rgb(108,98,97)" /> - <polygon points="176,43 181,42 185,43 185,44 184,45 179,47 178,47 177,47 176,44" style="fill: rgb(101,73,69)" /> - <polygon points="443,295 443,294 443,291 443,290 443,286 444,296 444,297 444,303" style="fill: rgb(101,90,86)" /> - <polygon points="212,298 212,296 214,295 216,294 252,284 255,284 268,284 269,284 270,289 237,295 220,298" style="fill: rgb(114,33,39)" /> - <polygon points="370,337 371,335 374,335 375,335 375,339 371,341" style="fill: rgb(119,111,108)" /> - <polygon points="256,190 257,189 258,189 259,189 260,190 260,191 259,192 256,191" style="fill: rgb(93,24,29)" /> - <polygon points="218,37 223,30 227,33 224,36 219,37" style="fill: rgb(37,29,27)" /> - <polygon points="330,160 334,157 335,157 335,158 334,160 333,161 331,163 330,162" style="fill: rgb(101,90,86)" /> - <polygon points="20,268 40,264 41,264 46,264 47,264 68,266 75,270 76,271 85,285 86,288 87,292 88,296 89,423 87,422" style="fill: rgb(243,244,246)" /> - <polygon points="450,3 450,1 450,0 451,5 452,24 451,38 450,31" style="fill: rgb(77,59,57)" /> - <polygon points="296,382 303,375 309,371 308,374 307,375 300,381 298,382" style="fill: rgb(87,67,66)" /> - <polygon points="138,217 148,220 149,223 150,238 149,238 148,238 147,238 139,221 138,218" style="fill: rgb(168,137,134)" /> - <polygon points="334,399 334,397 334,396 335,394 338,396 339,397 339,399 338,400 337,401 336,401 334,400" style="fill: rgb(196,156,148)" /> - <polygon points="0,168 2,168 6,168 7,168 31,169 71,171 79,172 79,176 76,177 75,177 6,170 0,169" style="fill: rgb(115,119,120)" /> - <polygon points="415,219 446,218 446,219 444,221 439,222 425,224 424,224" style="fill: rgb(119,111,108)" /> - <polygon points="127,55 132,54 134,55 135,58 131,60 130,60" style="fill: rgb(127,112,107)" /> - <polygon points="195,240 198,236 199,235 203,234 201,238 199,239 197,240" style="fill: rgb(117,80,74)" /> - <polygon points="232,212 232,211 234,213 240,220 239,220 236,219" style="fill: rgb(138,98,90)" /> - <polygon points="147,218 149,217 176,204 200,199 202,200 203,202 203,213 203,214 203,215 203,216 202,220 200,223 199,224 197,225 176,233 170,235 169,235 168,235 155,235 154,235 152,234 151,232" style="fill: rgb(138,98,90)" /> - <polygon points="229,321 234,316 235,315 257,310 259,315 259,316 258,317 242,326 241,326 229,322" style="fill: rgb(101,73,69)" /> - <polygon points="144,242 145,242 151,242 155,243 146,243" style="fill: rgb(60,46,43)" /> - <polygon points="160,104 161,98 162,94 163,92 163,96 161,103" style="fill: rgb(117,80,74)" /> - <polygon points="0,94 2,94 41,94 42,94 60,96 89,100 96,101 95,104 94,105 91,106 90,106 16,98 0,96" style="fill: rgb(180,176,175)" /> - <polygon points="429,6 429,5 430,2 431,0 431,3 431,4 431,6 431,7 430,7 429,7" style="fill: rgb(37,29,27)" /> - <polygon points="88,416 88,415 88,414 88,413 88,412 88,411 88,410 89,405 96,447 96,448 96,449 96,450 94,447 93,445 91,439 90,435 88,419 88,418" style="fill: rgb(216,211,208)" /> - <polygon points="440,213 440,188 451,0 453,0 454,4 455,14 456,111 454,205 453,210 449,212 444,213 443,213 442,213 441,213" style="fill: rgb(60,46,43)" /> - <polygon points="0,153 0,151 2,151 85,151 84,156 83,159 80,160 79,160 18,155" style="fill: rgb(189,185,182)" /> - <polygon points="254,232 256,224 318,195 319,196 325,208 326,218 326,223 321,239 320,241 316,245 313,247 301,251 299,251 282,250 278,248 260,238 259,237 256,234 255,233" style="fill: rgb(190,139,135)" /> - <polygon points="9,429 11,429 14,430 19,432 21,433 23,434 27,437 28,438 36,447 36,450 36,452 36,453 35,455 34,457 28,459 27,459 26,459" style="fill: rgb(238,226,230)" /> - <polygon points="143,211 143,209 144,208 151,207 151,212 151,213 150,214 147,215 144,213" style="fill: rgb(60,46,43)" /> - <polygon points="168,261 176,251 178,250 186,249 189,249 192,249 192,252 191,253 187,257 181,262 175,263 170,263 169,263" style="fill: rgb(190,139,135)" /> - <polygon points="257,80 258,72 262,69 263,69 264,70 266,76 266,77 264,81" style="fill: rgb(37,29,27)" /> - <polygon points="146,332 146,331 146,330 147,330 149,332 151,334 152,335 167,414 167,415 148,458 147,459 146,335" style="fill: rgb(189,185,182)" /> - <polygon points="449,358 449,356 449,351 449,349 450,352 450,353 450,360 450,361 449,359" style="fill: rgb(130,121,116)" /> - <polygon points="182,299 183,298 190,299 195,302 194,303 193,303 191,303 190,303 189,303 186,303 185,303" style="fill: rgb(117,80,74)" /> - <polygon points="174,193 190,192 194,192 195,192 198,195 197,198 191,200 188,201 184,200" style="fill: rgb(101,73,69)" /> - <polygon points="450,351 450,349 450,348 451,342 453,361 453,362 451,361" style="fill: rgb(140,136,133)" /> - <polygon points="201,302 201,300 202,299 211,295 212,295 213,295 211,301 208,302 203,303 201,303" style="fill: rgb(60,46,43)" /> - <polygon points="232,128 237,127 252,128 256,131 258,133 259,136 259,137 259,138 259,140 258,141 256,141 234,131" style="fill: rgb(209,162,152)" /> - <polygon points="202,193 203,193 208,194 209,195 210,196 210,197 210,198 210,201 210,202 209,202" style="fill: rgb(37,29,27)" /> - <polygon points="204,446 204,445 205,440 206,437 207,436 208,436 208,437 208,438 205,446" style="fill: rgb(75,14,19)" /> - <polygon points="269,188 272,188 273,189 275,194 272,192 270,190" style="fill: rgb(60,46,43)" /> - <polygon points="294,445 296,436 303,418 305,413 309,408 317,399 320,400 354,442 353,446 349,453 347,456 345,459 344,459 342,459 341,459 339,459 338,459 337,459 336,459 331,459 314,459 313,459 311,459 310,459 309,459 301,455 296,451 294,447" style="fill: rgb(168,137,134)" /> - <polygon points="355,112 355,102 355,101 359,103 358,108 356,117" style="fill: rgb(77,59,57)" /> - <polygon points="240,124 241,124 242,124 243,124 253,125 254,126 246,126 243,125" style="fill: rgb(138,98,90)" /> - <polygon points="119,144 120,142 120,144 120,148 119,150" style="fill: rgb(127,112,107)" /> - <polygon points="111,353 111,352 112,346 113,347 116,352" style="fill: rgb(61,75,78)" /> - <polygon points="329,27 329,26 331,25 332,26 332,28 332,30 331,29 330,28" style="fill: rgb(60,46,43)" /> - <polygon points="168,160 172,156 173,155 175,154 181,152 182,152 183,152 189,152 194,153 197,156 169,160" style="fill: rgb(200,157,150)" /> - <polygon points="262,255 263,255 266,256 267,257 267,258 263,260" style="fill: rgb(167,117,106)" /> - <polygon points="212,230 212,229 213,225 215,225 215,226 213,230 212,231" style="fill: rgb(196,156,148)" /> - <polygon points="234,15 235,15 236,15 237,15 238,15 239,15 240,15 241,15 244,17 245,18 239,19 237,18 236,17" style="fill: rgb(209,203,203)" /> - <polygon points="235,33 235,31 236,31 237,31 238,32 238,34 238,35 236,35" style="fill: rgb(77,59,57)" /> - <polygon points="244,26 246,25 248,25 248,26 248,27 245,27 244,27" style="fill: rgb(120,102,98)" /> - <polygon points="352,301 352,300 352,299 352,298 352,297 352,296 357,288 361,284 362,283 364,282 371,282 372,282 373,283 376,288 367,298 362,303 361,303 359,303 356,303 352,302" style="fill: rgb(109,97,97)" /> - <polygon points="144,304 147,297 149,298 154,311 153,311 149,310 145,309" style="fill: rgb(120,102,98)" /> - <polygon points="210,443 210,442 210,441 211,438 213,435 214,434 216,435 216,437 216,443 214,450 211,455 210,455" style="fill: rgb(204,173,168)" /> - <polygon points="161,51 161,50 163,48 164,48 165,48 166,48 165,51" style="fill: rgb(92,76,76)" /> - <polygon points="78,177 80,176 81,176 82,176 83,176 84,176 85,176 86,176 87,176 92,181 91,181 80,178" style="fill: rgb(83,97,100)" /> - <polygon points="234,97 234,96 234,95 234,94 234,93 235,92 236,92 236,97 236,98 235,99 234,99" style="fill: rgb(138,98,90)" /> - <polygon points="125,110 125,109 126,102 128,99 129,98 131,97 132,97 132,98 132,99 130,106 127,111" style="fill: rgb(17,16,12)" /> - <polygon points="131,183 132,173 135,169 135,170 135,171 135,172 135,181 135,182" style="fill: rgb(182,153,145)" /> - <polygon points="95,216 97,213 99,211 102,209 103,210 95,218 95,217" style="fill: rgb(138,98,90)" /> - <polygon points="106,311 106,295 106,310 106,297 106,296 106,307 106,306 106,309 106,308 106,303 106,302 106,305 106,304 106,299 106,298 106,301 106,300" style="fill: rgb(99,97,98)" /> - <polygon points="398,253 408,252 428,252 439,253 442,255 443,256 444,258 444,259" style="fill: rgb(105,99,101)" /> - <polygon points="216,55 220,51 221,50 223,52 223,55 223,56 223,57 223,58 222,59 217,56" style="fill: rgb(60,46,43)" /> - <polygon points="348,459 351,454 356,446 358,444 363,443 364,443 366,446 366,449 362,457 361,458 359,459" style="fill: rgb(75,14,19)" /> - <polygon points="106,184 106,182 107,182 111,189 114,199 114,201 113,201 110,200 109,199 106,192" style="fill: rgb(37,29,27)" /> - <polygon points="358,132 358,131 359,128 366,129 367,130 367,132 366,133 363,134 362,134 361,134 360,134 359,133" style="fill: rgb(92,76,76)" /> - <polygon points="24,144 25,144 30,144 31,144 31,146 29,146 28,146 25,146 24,146" style="fill: rgb(202,203,205)" /> - <polygon points="250,165 251,163 252,162 254,161 257,160 269,160 268,162 258,166 256,166 251,166" style="fill: rgb(60,46,43)" /> - <polygon points="280,458 281,446 285,440 287,438 289,436 290,457 290,458 290,459 281,459 280,459" style="fill: rgb(147,118,114)" /> - <polygon points="320,165 326,164 327,164 328,165 327,171 323,170" style="fill: rgb(77,59,57)" /> - <polygon points="189,458 190,455 192,452 201,442 201,443 201,444 200,446 195,454 190,459 189,459" style="fill: rgb(117,80,74)" /> - <polygon points="351,317 352,317 357,334 357,335 356,336 355,336 352,325 351,319" style="fill: rgb(168,137,134)" /> - <polygon points="118,156 118,155 118,154 119,152 121,158 123,171 123,177 123,179 122,197 121,195 120,186 119,172" style="fill: rgb(147,118,114)" /> - <polygon points="18,261 21,260 36,256 53,255 55,255 56,255 57,255 59,255 61,255 63,255 67,255 68,255 74,257 79,259 83,262 84,263 85,264 86,265 87,266 89,269 92,275 96,284 97,292 98,312 101,437 101,442" style="fill: rgb(222,223,225)" /> - <polygon points="192,69 193,68 194,67 195,66 200,70 200,71 198,71 197,71" style="fill: rgb(87,67,66)" /> - <polygon points="222,443 223,443 224,443 226,456 226,457 226,458 225,459 224,459 223,457 222,445" style="fill: rgb(147,118,114)" /> - <polygon points="106,270 106,269 124,286 126,288 127,299 131,398 131,440 131,441 131,446 131,447 131,448 131,449 131,450 131,451 131,452 131,453 131,454 131,455 131,456 131,457 131,458 131,459 130,459 129,459 111,459 110,455" style="fill: rgb(68,83,86)" /> - <polygon points="248,435 249,430 256,434 256,435" style="fill: rgb(117,80,74)" /> - <polygon points="302,10 313,15 316,17 319,19 321,21 324,24 328,31 330,40 330,44 330,47 329,48" style="fill: rgb(101,90,86)" /> - <polygon points="170,160 175,156 178,155 179,155 180,155 181,155 182,155 183,155 184,155 171,160" style="fill: rgb(190,139,135)" /> - <polygon points="180,92 183,89 185,91 185,95 185,97 184,99 183,99 181,97" style="fill: rgb(168,137,134)" /> - <polygon points="164,342 165,338 167,334 168,337 166,349 165,347 164,343" style="fill: rgb(87,67,66)" /> - <polygon points="7,444 11,446 15,449 19,454 19,456 19,458 19,459 17,459 16,459 11,453 9,450 8,447" style="fill: rgb(216,173,167)" /> - <polygon points="408,219 414,219 424,221 423,223 420,223 419,223 417,223 416,223 415,223 414,223 413,223 412,223 411,223 409,222 408,220" style="fill: rgb(127,112,107)" /> - <polygon points="244,337 245,334 246,334 253,337 253,338 253,340 252,343 251,344 250,344 248,342 246,340 245,339" style="fill: rgb(167,117,106)" /> - <polygon points="426,224 456,214 457,214 457,216 455,218 452,220 443,225 442,225 441,225 435,225 434,225 433,225 432,225 428,225" style="fill: rgb(119,111,108)" /> - <polygon points="104,459 104,456 104,452 104,451 104,447 104,446 104,443 104,442 104,439 104,438 105,440 105,459" style="fill: rgb(150,149,144)" /> - <polygon points="242,88 245,84 246,84 247,84 248,85 248,86 247,89 245,91 243,91 242,91" style="fill: rgb(167,117,106)" /> - <polygon points="219,365 219,364 219,363 223,358 231,361 230,362 221,370" style="fill: rgb(87,67,66)" /> - <polygon points="403,360 404,358 406,357 407,357 413,358 416,359 418,360 419,361 418,361 417,361 416,361" style="fill: rgb(167,117,106)" /> - <polygon points="184,189 185,189 186,189 187,189 188,189 189,189 190,189 191,189 192,189 193,189 194,189 195,189 196,189 197,189 198,189" style="fill: rgb(62,70,73)" /> - <polygon points="95,123 99,117 110,102 122,90 143,71 156,70 158,70 158,71 158,72 158,73 145,103 141,112 136,119 110,155 108,157 103,147 102,145 95,128" style="fill: rgb(37,29,27)" /> - <polygon points="282,4 283,0 293,19 293,20 289,21 287,20 286,19 282,5" style="fill: rgb(180,176,175)" /> - <polygon points="177,114 178,113 186,112 186,113 186,114 186,115 182,119 180,119 178,118 177,115" style="fill: rgb(196,156,148)" /> - <polygon points="0,126 8,125 60,123 61,123 80,124 83,126 84,127 84,128 84,129 83,133 22,129 0,127" style="fill: rgb(197,193,192)" /> - <polygon points="139,298 139,296 142,293 144,292 145,294 146,296 146,298 144,309 143,309" style="fill: rgb(147,118,114)" /> - <polygon points="90,359 90,358 90,357 90,356 90,350 90,349 90,348 90,347 90,342 90,341 90,340 90,339 90,338 92,326 92,330 92,334 92,335 90,367" style="fill: rgb(201,196,193)" /> - <polygon points="30,263 31,262 40,259 41,259 46,259 47,259 67,260 70,261 73,262 77,264 79,265 77,265" style="fill: rgb(202,203,205)" /> - <polygon points="92,233 92,232 93,218 94,217 94,219 93,238" style="fill: rgb(190,139,135)" /> - <polygon points="201,75 201,74 202,62 203,60 208,56 219,57 221,59 221,60 219,67 204,83 202,80" style="fill: rgb(101,73,69)" /> - <polygon points="376,215 376,214 376,213 377,213 378,213 379,213 400,216 412,218 407,222 406,222 404,222" style="fill: rgb(119,111,108)" /> - <polygon points="158,456 158,455 163,440 165,437 166,436 167,435 171,432 173,431 181,430 182,430 183,430 195,432 201,433 201,434 200,437 195,442 194,443 161,459 159,459 158,459" style="fill: rgb(230,218,220)" /> - <polygon points="352,184 354,182 356,182 356,183 355,187 354,189" style="fill: rgb(209,162,152)" /> - <polygon points="136,314 136,303 138,303 139,305 140,307 141,309 148,410 148,413 140,459 139,459 136,326" style="fill: rgb(150,149,144)" /> - <polygon points="133,191 134,189 138,185 139,185 141,188 140,189 139,190 133,192" style="fill: rgb(127,112,107)" /> - <polygon points="153,348 154,346 155,346 158,348 194,388 197,396 197,397 197,398 194,399 193,399 170,394 168,393 165,391 159,382 156,376 155,373 153,349" style="fill: rgb(217,216,214)" /> - <polygon points="448,312 449,321 449,360 449,361 448,359 448,356 448,354" style="fill: rgb(119,111,108)" /> - <polygon points="129,138 130,137 154,127 158,128 165,158 165,160 165,161 164,162 159,165 136,178" style="fill: rgb(204,173,168)" /> - <polygon points="287,440 290,432 345,294 347,291 349,297 351,307 351,308 351,309 351,312 351,313 351,325 351,326 351,329 340,356 327,386 296,449 295,451 290,451 289,451 288,451 287,443" style="fill: rgb(138,98,90)" /> - <polygon points="446,406 446,405 450,401 450,402 450,403 448,407 447,407" style="fill: rgb(117,80,74)" /> - <polygon points="103,107 103,106 104,104 107,107 107,108 106,108 105,108 103,108" style="fill: rgb(37,29,27)" /> - <polygon points="289,273 289,268 296,273 297,274 298,275 293,282" style="fill: rgb(77,59,57)" /> - <polygon points="158,95 160,88 163,81 171,70 191,64 192,64 193,65 193,67 190,71 188,73 187,74 158,96" style="fill: rgb(101,73,69)" /> - <polygon points="6,272 8,270 13,269 41,265 42,265 43,265 46,265 47,266 47,267 31,269" style="fill: rgb(215,217,216)" /> - <polygon points="354,311 368,290 371,289 372,289 375,290 378,293 405,352 404,352 363,322 358,318 357,317" style="fill: rgb(108,98,97)" /> - <polygon points="124,280 124,278 124,277 129,274 130,275 131,276 132,279 131,281 129,285 127,283 126,282 125,281" style="fill: rgb(138,98,90)" /> - <polygon points="200,311 201,310 204,307 209,306 217,312 215,322 214,322 210,319" style="fill: rgb(147,118,114)" /> - <polygon points="0,8 35,0 37,0 39,0 41,0 43,0 45,0 47,0 49,0 51,0 53,0 55,0 57,0 59,0 61,0 63,0 67,0 71,0 75,0 79,0 83,0 87,0 88,0 135,0 143,0 146,0 143,4 127,18 119,23 103,26 15,31 8,31 2,31 0,31" style="fill: rgb(222,223,225)" /> - <polygon points="140,197 144,196 158,193 245,178 246,178 247,178 239,212 238,215 202,231 199,232 141,199 140,198" style="fill: rgb(101,73,69)" /> - <polygon points="296,233 296,231 297,231 298,231 299,231 300,233 300,234 299,234 298,234 297,234 296,234 296,231 297,231 298,231 299,231 300,233" style="fill: rgb(190,139,135)" /> - <polygon points="0,227 2,225 4,224 16,224 17,224 33,227 34,228 35,229 36,230 36,231 35,234 33,239 32,241 30,243 28,244 21,245 10,245 8,245 0,243" style="fill: rgb(61,75,78)" /> - <polygon points="11,176 24,176 25,176 53,178 63,179 71,180 72,181 65,181 64,181 17,178 13,177" style="fill: rgb(61,75,78)" /> - <polygon points="209,55 210,51 211,50 216,46 217,46 218,51 218,52 218,53 218,54 212,55 211,55" style="fill: rgb(101,90,86)" /> - <polygon points="280,343 283,340 291,341 292,346 292,347 291,349 288,351 280,344" style="fill: rgb(77,59,57)" /> - <polygon points="97,256 98,256 100,259 101,264 101,265 100,263 97,257" style="fill: rgb(105,99,101)" /> - <polygon points="215,43 215,41 223,44 224,46 224,47 224,48 224,49 220,50 219,50" style="fill: rgb(60,46,43)" /> - <polygon points="240,68 240,67 243,66 244,67 247,73 242,71" style="fill: rgb(101,73,69)" /> - <polygon points="346,185 350,180 351,179 352,178 353,177 355,176 356,176 358,177 360,179 364,192 364,204 364,206 362,214 361,215 360,214" style="fill: rgb(190,139,135)" /> - <polygon points="2,447 3,445 4,445 6,448 6,449 5,451" style="fill: rgb(182,153,145)" /> - <polygon points="0,296 3,294 5,293 14,290 30,286 31,286 36,286 37,286 38,286 39,286 55,291 58,293 63,302 66,309 66,312 66,316 66,319 65,327 50,407 44,417 41,420 36,423 34,423 32,423 31,423 30,423 29,423 23,419 16,412 8,402 6,399 0,380" style="fill: rgb(250,251,253)" /> - <polygon points="158,332 158,331 158,330 158,329 159,321 160,316 163,301 165,299 166,299 167,300 170,306 170,308 170,309 170,310 162,332 160,335 158,334" style="fill: rgb(101,73,69)" /> - <polygon points="406,393 406,392 408,384 414,374 417,369 418,368 419,367 423,384 423,385 423,386 423,388 420,404 419,404 415,402 409,398 406,396" style="fill: rgb(93,24,29)" /> - <polygon points="94,199 94,196 95,197 96,202 96,205 95,206 94,202" style="fill: rgb(99,97,98)" /> - <polygon points="328,171 329,171 330,172 338,186 338,191 338,192 338,193 336,200 335,200 334,197 333,194 328,172" style="fill: rgb(77,59,57)" /> - <polygon points="271,81 273,76 274,74 277,70 283,74 284,75 285,76 272,81" style="fill: rgb(101,73,69)" /> - <polygon points="184,79 184,78 190,72 191,73 191,74 190,75 186,79 185,79" style="fill: rgb(117,80,74)" /> - <polygon points="352,95 352,93 355,89 356,89 367,91 371,94 372,95 373,102 373,103 372,111 369,115 368,115 355,100 352,96" style="fill: rgb(92,76,76)" /> - <polygon points="324,60 331,57 332,58 337,68 340,75 339,78 334,73 326,63" style="fill: rgb(101,73,69)" /> - <polygon points="298,291 298,290 300,285 302,280 306,280 307,287 307,291 307,293 305,296 302,296 300,295 299,294" style="fill: rgb(138,98,90)" /> - <polygon points="284,333 285,332 287,332 289,340 289,341 288,342 287,341 286,340" style="fill: rgb(101,73,69)" /> - <polygon points="210,350 213,343 215,342 220,349 220,350 217,353 210,356" style="fill: rgb(101,73,69)" /> - <polygon points="241,227 241,226 241,223 242,221 322,179 324,178 325,178 327,180 331,194 332,200 335,236 335,241 329,254 327,256 304,271 303,271 302,271 256,245 242,230" style="fill: rgb(167,117,106)" /> - <polygon points="273,33 275,32 276,32 279,33 281,34 282,36 280,36 278,36 275,35" style="fill: rgb(101,90,86)" /> - <polygon points="264,192 265,192 287,192 288,193 287,194 284,195 281,196 274,198 272,198 268,197 265,195" style="fill: rgb(77,59,57)" /> - <polygon points="154,301 156,297 158,294 160,292 162,291 179,290 237,296 205,334 202,335 201,335 196,335 195,335 194,335 163,335 160,332 158,328 154,315" style="fill: rgb(138,98,90)" /> - <polygon points="84,146 84,145 84,139 85,140 86,143 86,144 86,145 85,148 84,147 84,139 85,140 86,143 86,144 86,145" style="fill: rgb(197,193,192)" /> - <polygon points="104,99 104,98 104,97 104,95 107,90 108,89 109,89 110,89 111,89 107,95" style="fill: rgb(101,90,86)" /> - <polygon points="139,132 140,132 146,133 145,134 142,134 141,134 139,133" style="fill: rgb(168,137,134)" /> - <polygon points="206,230 206,229 208,226 209,225 209,230 209,231 209,234 209,235 206,231" style="fill: rgb(147,118,114)" /> - <polygon points="261,164 264,163 268,163 267,164 264,165 261,165" style="fill: rgb(93,24,29)" /> - <polygon points="140,130 141,128 144,125 145,125 146,125 147,125 147,126 141,131" style="fill: rgb(182,153,145)" /> - <polygon points="240,61 241,59 253,39 289,35 291,35 292,35 300,36 308,38 310,40 311,42 308,49 253,81 241,65" style="fill: rgb(60,46,43)" /> - <polygon points="332,90 333,90 334,90 335,91 336,92 337,94 338,96 338,97 337,97 336,97" style="fill: rgb(77,59,57)" /> - <polygon points="249,178 249,177 250,176 264,172 274,170 275,170 274,171" style="fill: rgb(37,29,27)" /> - <polygon points="144,116 144,115 151,104 152,104 151,107 149,110 146,114" style="fill: rgb(60,46,43)" /> - <polygon points="157,365 157,364 157,355 159,349 164,353 190,379 193,387 194,392 194,393 193,393 189,393 188,393 187,393 186,393 171,391 168,389 166,387 165,386 159,378 158,375 157,367" style="fill: rgb(217,216,214)" /> - <polygon points="3,167 23,167 31,167 63,169 75,170 80,171 81,172 74,172 52,171 8,169" style="fill: rgb(124,128,129)" /> - <polygon points="333,199 333,196 333,195 339,183 340,181 341,181 341,183 339,198 338,202 336,209 335,208 334,207" style="fill: rgb(101,73,69)" /> - <polygon points="334,415 335,415 337,415 338,415 343,415 344,415 358,432 358,434 351,444 347,442 345,440 340,431 334,418" style="fill: rgb(181,146,144)" /> - <polygon points="446,459 449,452 452,451 456,450 459,450 459,459 458,459 457,459 456,459 455,459 454,459 453,459 452,459 451,459 450,459" style="fill: rgb(93,24,29)" /> - <polygon points="339,382 346,363 349,357 350,356 351,355 352,354 353,354 354,354 355,354 367,369 368,418 368,419 365,425 364,426 363,425 362,424 354,414 352,411 339,383" style="fill: rgb(200,157,150)" /> - <polygon points="263,215 264,215 267,215 268,215 269,216 270,217 267,218 266,218 264,217" style="fill: rgb(167,117,106)" /> - <polygon points="356,140 356,139 357,133 358,144 358,149 357,155" style="fill: rgb(77,59,57)" /> - <polygon points="148,207 149,205 151,205 151,211 148,208" style="fill: rgb(77,59,57)" /> - <polygon points="176,201 177,201 178,201 179,201 185,204 185,205 184,205 181,204 179,203 177,202" style="fill: rgb(93,24,29)" /> - <polygon points="356,100 356,98 368,96 369,96 369,97 368,113 365,119 362,122 359,123 358,122 357,120 356,101" style="fill: rgb(92,76,76)" /> - <polygon points="245,198 246,195 251,196 250,199 248,201 247,201 246,200 245,199" style="fill: rgb(167,117,106)" /> - <polygon points="346,267 346,265 346,257 347,256 398,254 399,254 410,254 414,254 415,254 421,254 426,254 427,254 428,254 430,255 426,354 424,357 417,357 411,355 353,300 350,289" style="fill: rgb(92,76,76)" /> - <polygon points="266,72 267,70 275,64 276,64 286,70 287,71 289,75 289,78 270,80 268,77" style="fill: rgb(117,80,74)" /> - <polygon points="76,423 76,422 77,420 81,422 83,424 88,447 89,452 88,457 81,447 77,439 76,426" style="fill: rgb(230,230,230)" /> - <polygon points="138,118 140,114 143,113 145,116 144,117" style="fill: rgb(87,67,66)" /> - <polygon points="300,0 364,0 368,0 369,0 449,0 450,14 452,130 452,132 451,156 443,208 439,209 431,210 430,210 419,209 412,208 407,207 400,205 301,9 300,7" style="fill: rgb(60,46,43)" /> - <polygon points="138,310 139,309 140,309 141,310 142,312 143,314 144,317 151,401 151,414 151,416 151,417 151,418 142,459 141,459 140,457 138,325" style="fill: rgb(164,160,161)" /> - <polygon points="373,258 376,257 380,256 381,256 382,256 383,256 383,257 375,258" style="fill: rgb(108,98,97)" /> - <polygon points="385,212 386,212 395,213 415,216 411,216 402,216 387,213" style="fill: rgb(108,98,97)" /> - <polygon points="194,378 199,386 209,403 213,410 213,411 211,413 210,412 208,409 203,400 200,394 199,392 196,385 194,380" style="fill: rgb(127,112,107)" /> - <polygon points="201,451 201,449 201,448 204,441 205,447 205,449 204,459 201,459" style="fill: rgb(93,24,29)" /> - <polygon points="92,158 92,157 92,156 93,155 95,154 100,155 100,156 97,172 96,172 95,170 93,166 92,159" style="fill: rgb(60,46,43)" /> - <polygon points="91,425 91,424 92,424 93,426 94,429 95,436 96,444 96,446 94,441 92,433" style="fill: rgb(209,203,203)" /> - <polygon points="118,76 119,74 120,73 123,72 123,73 121,77 120,77" style="fill: rgb(101,90,86)" /> - <polygon points="363,253 363,252 366,251 409,245 412,245 427,246 427,248 426,249 385,252 367,253 366,253 365,253 364,253" style="fill: rgb(127,112,107)" /> - <polygon points="266,235 267,233 269,232 276,230 303,223 306,224 310,231 310,234 310,235 308,240 303,241 296,242 288,241 275,238 272,237" style="fill: rgb(190,139,135)" /> - <polygon points="232,87 232,86 233,78 234,78 234,80 234,81 233,90" style="fill: rgb(60,46,43)" /> - <polygon points="151,139 154,135 159,135 163,139 155,140 151,140" style="fill: rgb(204,173,168)" /> - <polygon points="332,81 332,79 333,79 334,80 335,82 339,91 338,91 333,87" style="fill: rgb(37,29,27)" /> - <polygon points="213,240 214,231 218,201 220,200 221,200 225,204 232,223 233,226 234,234 234,237 228,239 218,242 217,242 216,242" style="fill: rgb(216,173,167)" /> - <polygon points="119,210 119,209 119,208 119,207 119,206 121,205 123,204 125,203 135,199 138,199 136,237 135,237 134,236 119,211" style="fill: rgb(37,29,27)" /> - <polygon points="120,5 125,0 127,0 127,1 127,2 122,7 121,7 120,7" style="fill: rgb(216,220,221)" /> - <polygon points="246,182 247,181 248,180 252,184 251,184 250,184 249,184 248,184 247,183" style="fill: rgb(101,73,69)" /> - <polygon points="12,239 14,239 22,240 23,241 22,242 15,243 14,243 12,243" style="fill: rgb(62,70,73)" /> - <polygon points="136,228 136,225 137,225 138,228 138,229 138,230 137,230 136,229" style="fill: rgb(191,165,164)" /> - <polygon points="181,43 182,42 186,40 204,41 204,51 203,52 191,53 187,53 186,53" style="fill: rgb(101,90,86)" /> - <polygon points="104,234 106,232 107,232 108,235 108,236 105,241 104,240" style="fill: rgb(181,146,144)" /> - <polygon points="90,181 94,172 95,178 94,184 92,184" style="fill: rgb(108,98,97)" /> - <polygon points="447,291 447,286 447,285 447,284 448,289 449,299 450,321 449,320 447,293" style="fill: rgb(130,121,116)" /> - <polygon points="125,82 128,79 129,79 131,84 131,85 130,85 129,85 126,83" style="fill: rgb(60,46,43)" /> - <polygon points="143,205 146,200 148,200 149,204 148,205 147,206 143,206" style="fill: rgb(101,73,69)" /> - <polygon points="239,100 240,99 241,98 245,99 244,101 243,103 241,105 240,105" style="fill: rgb(138,98,90)" /> - <polygon points="180,201 181,200 187,200 190,204 190,205 185,206 184,206 183,206 181,205" style="fill: rgb(114,33,39)" /> - <polygon points="368,237 369,236 370,236 371,236 371,237 371,239 370,239 369,239 368,239" style="fill: rgb(136,138,137)" /> - <polygon points="272,3 272,1 272,0 273,0 277,13 278,17 277,17 275,16 274,13 273,9" style="fill: rgb(216,211,208)" /> - <polygon points="134,430 134,423 135,416 136,416 136,418 134,442" style="fill: rgb(99,97,98)" /> - <polygon points="330,341 331,335 333,333 335,331 330,343" style="fill: rgb(77,59,57)" /> - <polygon points="274,402 275,400 276,400 277,400 279,402 279,403 279,404 275,405 274,403" style="fill: rgb(101,73,69)" /> - <polygon points="0,275 1,274 4,273 7,272 14,270 42,266 44,266 45,266 53,267 66,269 69,270 72,271 76,278 78,282 79,284 81,288 84,295 85,304 85,308 85,309 85,312 85,313 85,316 85,317 85,321 85,322 85,421 84,423 83,423 82,422 0,276" style="fill: rgb(250,251,253)" /> - <polygon points="167,173 173,172 180,173" style="fill: rgb(87,67,66)" /> - <polygon points="208,120 208,119 209,116 218,118 220,123 220,125 215,124" style="fill: rgb(138,98,90)" /> - <polygon points="215,236 215,231 216,203 217,202 220,202 223,206 229,226 228,232 224,237 222,238 220,239 218,240 217,240 216,238" style="fill: rgb(216,173,167)" /> - <polygon points="221,418 222,417 226,413 230,412 231,412 234,413 237,415 238,416 238,417 235,422 234,423 224,421 222,419" style="fill: rgb(101,73,69)" /> - <polygon points="401,406 402,405 407,403 411,404 409,405 407,406 405,407 401,407" style="fill: rgb(114,33,39)" /> - <polygon points="354,317 354,316 354,315 354,314 370,330 370,331 366,339 365,340 364,340 363,340 362,339 360,336 356,324 355,321" style="fill: rgb(127,112,107)" /> - <polygon points="113,185 113,184 113,181 113,180 113,179 113,164 113,163 113,162 114,162 115,162 120,201 119,202 118,202 116,201 115,197 113,187" style="fill: rgb(77,59,57)" /> - <polygon points="80,267 84,271 87,276 91,284 92,286 92,287 90,284 88,281 80,268" style="fill: rgb(201,196,193)" /> - <polygon points="293,81 297,82 303,85 303,86 297,91 296,90 294,87 293,85" style="fill: rgb(37,29,27)" /> - <polygon points="254,335 257,330 263,327 268,327 271,328 268,333 260,340 259,340 255,336" style="fill: rgb(167,117,106)" /> - <polygon points="199,254 321,172 323,171 351,159 365,166 366,167 367,168 367,171 343,305 303,306 204,297 199,256" style="fill: rgb(167,117,106)" /> - <polygon points="146,246 148,245 158,244 160,244 161,244 169,266 169,268 166,269 162,269 161,269 157,267 147,262 146,261" style="fill: rgb(181,146,144)" /> - <polygon points="435,413 436,413 443,416 455,422 457,423 459,425 459,426 458,426 450,422 444,419" style="fill: rgb(75,14,19)" /> - <polygon points="0,246 49,228 56,227 64,227 81,228 89,230 89,231 88,233 87,234 28,248 21,249 20,249 16,249 10,249 8,249 5,248" style="fill: rgb(83,97,100)" /> - <polygon points="96,248 98,250 102,257 103,259 102,258 98,253 96,249" style="fill: rgb(179,139,137)" /> - <polygon points="353,324 353,323 353,322 353,321 355,326 356,330 356,331 355,330" style="fill: rgb(167,117,106)" /> - <polygon points="133,189 134,187 139,181 142,178 148,175 155,172 169,168 171,168 171,169 160,188 150,191 138,194 136,193 133,190" style="fill: rgb(147,118,114)" /> - <polygon points="159,359 159,358 161,354 164,354 169,359 189,380 189,383 187,386 185,387 182,387 176,386 168,382 165,378 164,376 163,373" style="fill: rgb(217,216,214)" /> - <polygon points="250,188 251,187 252,186 254,185 256,185 256,186 256,187 254,189 253,189 252,189" style="fill: rgb(60,46,43)" /> - <polygon points="236,438 342,317 342,321 342,322 336,348 332,364 331,367 330,369 323,382 281,457 279,459 273,459 272,459 265,459 258,459 257,459 256,459 239,459 238,455 236,439" style="fill: rgb(117,80,74)" /> - <polygon points="93,72 96,69 104,67 105,68 106,71 106,73 103,75 101,76 100,76 98,76 96,75 94,73" style="fill: rgb(242,236,240)" /> - <polygon points="99,192 100,189 101,190 102,192 103,194 103,195 103,196 102,196 99,193" style="fill: rgb(77,59,57)" /> - <polygon points="196,313 199,309 200,308 204,305 218,300 221,299 246,294 251,293 274,290 278,290 279,290 280,290 281,290 284,293 285,294 286,295 287,296 288,302 288,306 276,346 254,352 249,353 243,354 242,354 222,349 218,347 212,341 201,330 199,327 196,321" style="fill: rgb(138,98,90)" /> - <polygon points="395,207 396,207 397,207 416,211 415,212 407,212 404,212 400,211 397,210" style="fill: rgb(92,76,76)" /> - <polygon points="203,79 203,76 203,75 204,72 212,63 214,63 217,63 219,64 223,76 223,88 223,90 221,96" style="fill: rgb(138,98,90)" /> - <polygon points="296,27 297,26 299,27 302,29 305,31 305,32 304,32 300,31" style="fill: rgb(150,149,144)" /> - <polygon points="402,250 405,248 428,246 443,252 444,253 445,254" style="fill: rgb(119,111,108)" /> - <polygon points="378,297 378,296 379,296 380,296 381,301 381,303 378,299" style="fill: rgb(108,98,97)" /> - <polygon points="352,98 353,98 354,100 356,106 356,107 356,110 355,116 354,112 352,99" style="fill: rgb(60,46,43)" /> - <polygon points="259,42 259,40 259,38 260,37 261,37 262,37 262,38 261,42" style="fill: rgb(101,90,86)" /> - <polygon points="7,165 15,165 31,165 89,167 87,171 83,171 82,171 11,166" style="fill: rgb(136,138,137)" /> - <polygon points="226,133 228,127 232,127 233,127 234,127 235,130 233,131 227,133" style="fill: rgb(196,156,148)" /> - <polygon points="160,146 160,145 176,138 188,138 190,140 191,141 193,147 192,148 169,154 168,154 160,152" style="fill: rgb(216,173,167)" /> - <polygon points="192,108 192,107 192,106 194,105 199,109 197,111 195,112" style="fill: rgb(179,139,137)" /> - <polygon points="62,173 63,173 72,174 76,175 71,175 64,174" style="fill: rgb(105,99,101)" /> - <polygon points="245,189 245,188 246,188 247,188 248,188 249,188 254,190 254,192 253,194 252,194" style="fill: rgb(93,24,29)" /> - <polygon points="333,267 333,266 336,264 337,267 337,268 335,269" style="fill: rgb(77,59,57)" /> - <polygon points="96,238 96,236 96,226 96,223 96,221 96,219 96,218 97,215 99,213 105,211 108,213 112,220 100,243 99,243 96,239" style="fill: rgb(117,80,74)" /> - <polygon points="263,202 277,173 298,170 300,170 302,170 303,171 307,175 308,178 309,182 310,193 303,207 296,209 295,209 272,206 268,205 264,203" style="fill: rgb(75,14,19)" /> - <polygon points="6,443 7,437 8,436 9,436 11,438 12,439 13,440 18,450 19,453" style="fill: rgb(220,192,191)" /> - <polygon points="368,349 368,348 369,348 397,360 399,361 399,362 399,363 396,367 395,368 394,369 392,369 376,356 370,351" style="fill: rgb(235,198,192)" /> - <polygon points="0,0 2,0 3,0 4,0 5,0 6,0 7,0 8,0 9,0 10,0 11,0 12,0 13,0 14,0 15,0 16,0 17,0 18,0 19,0 20,0 21,0 22,0 23,0 24,0 25,0 26,0 25,1 15,2 2,2 0,2" style="fill: rgb(215,217,216)" /> - <polygon points="217,377 217,376 217,373 322,332 326,331 327,331 329,331 330,331 331,331 331,332 327,340 322,349 319,354 308,369 306,371 293,384 286,389 280,392 269,397 263,399 256,400 247,400 246,400 229,394 227,393 224,391 221,388 218,384" style="fill: rgb(60,46,43)" /> - <polygon points="174,122 176,120 177,119 178,119 190,122 191,123 183,125 176,125 174,123" style="fill: rgb(196,156,148)" /> - <polygon points="142,192 146,188 148,187 149,190 149,191 142,193" style="fill: rgb(168,137,134)" /> - <polygon points="97,164 98,163 99,164 100,165 102,175 101,175 98,174 97,165" style="fill: rgb(101,90,86)" /> - <polygon points="240,207 242,208 243,209 244,212 244,214 243,213 242,212" style="fill: rgb(127,112,107)" /> - <polygon points="404,434 404,430 404,427 408,410 410,407 413,406 416,406 419,407 430,412 434,414 436,415 456,426 457,427 459,431 459,444 459,445 459,448 459,449 449,459 448,459 442,459 439,459 438,459 424,459 408,453" style="fill: rgb(114,33,39)" /> - <polygon points="90,147 93,142 94,141 95,141 96,141 97,142 97,143 96,146 95,148 93,149" style="fill: rgb(60,46,43)" /> - <polygon points="105,232 105,231 106,230 109,231 112,232 108,244" style="fill: rgb(179,139,137)" /> - <polygon points="161,170 162,169 163,168 168,166 169,166 170,166 174,167 173,168" style="fill: rgb(168,137,134)" /> - <polygon points="232,267 232,265 233,265 238,266 238,267 237,268 233,268 232,268 232,265 233,265 238,266 238,267 237,268 233,268 232,268 232,265 233,265" style="fill: rgb(101,73,69)" /> - <polygon points="236,419 236,417 239,412 305,384 306,387 306,390 306,391 305,394 292,406 264,419 245,425 239,425 238,425 237,424" style="fill: rgb(87,67,66)" /> - <polygon points="88,429 88,428 88,427 88,426 89,425 94,448 94,450 94,451 91,446 90,443 88,431" style="fill: rgb(217,216,214)" /> - <polygon points="145,220 147,219 148,219 149,219 154,221 170,237 151,238 150,237 148,234" style="fill: rgb(127,112,107)" /> - <polygon points="210,180 217,176 222,176 223,177 225,181 224,183 211,183 210,183" style="fill: rgb(167,117,106)" /> - <polygon points="238,169 238,168 239,166 240,165 250,160 252,159 254,158 255,158 256,158 257,158 248,164 246,165" style="fill: rgb(117,80,74)" /> - <polygon points="235,190 236,186 239,186 249,192 242,192" style="fill: rgb(87,67,66)" /> - <polygon points="251,412 255,409 257,412 258,414 258,415 252,413" style="fill: rgb(77,59,57)" /> - <polygon points="450,287 450,285 450,283 450,282 451,274 456,247 458,246 459,246 459,250 459,264 459,363 455,363 454,362 453,359 452,354 450,289" style="fill: rgb(164,160,161)" /> - <polygon points="141,321 141,320 143,318 144,320 145,323 146,326 154,408 154,414 154,415 144,459 143,459 141,326" style="fill: rgb(164,160,161)" /> - <polygon points="159,174 162,172 164,171 167,170 176,168 248,156 278,152 279,152 290,154 301,158 303,159 308,162 227,183 207,185 159,175" style="fill: rgb(167,117,106)" /> - <polygon points="124,240 124,239 124,238 124,237 124,236 144,245 141,265 139,272 138,274 137,273 135,269 128,253" style="fill: rgb(168,137,134)" /> - <polygon points="146,61 154,57 160,56 161,56 162,56 163,56 164,56 165,56 155,62 151,63" style="fill: rgb(60,46,43)" /> - <polygon points="181,300 182,300 183,300 192,303 193,304 194,305 195,307 193,309 192,309 186,308 184,307 182,306 181,305" style="fill: rgb(87,67,66)" /> - <polygon points="225,105 225,98 228,98 228,99 228,101 228,103 226,111 225,111" style="fill: rgb(101,73,69)" /> - <polygon points="216,417 217,417 222,423 224,427 222,426" style="fill: rgb(120,102,98)" /> - <polygon points="316,455 325,447 327,446 330,446 331,447 330,456 328,457 321,459 320,459 319,459 318,459 317,459 316,459" style="fill: rgb(168,137,134)" /> - <polygon points="160,341 160,340 162,338 164,336 164,337 164,338 164,339 164,340 163,347 162,346" style="fill: rgb(101,90,86)" /> - <polygon points="102,107 102,106 103,104 106,98 107,98 114,100 112,108 106,113 103,114 102,114" style="fill: rgb(37,29,27)" /> - <polygon points="85,422 85,417 85,416 88,424 88,425 87,426 86,424" style="fill: rgb(219,219,219)" /> - <polygon points="342,428 342,427 342,418 348,416 350,416 351,416 361,431 359,432 343,429" style="fill: rgb(182,153,145)" /> - <polygon points="206,131 206,130 207,129 208,128 209,128 210,128 214,128 215,130 209,131 207,131" style="fill: rgb(167,117,106)" /> - <polygon points="240,111 242,109 243,109 244,110 244,111 242,113 241,114 240,114" style="fill: rgb(190,139,135)" /> - <polygon points="134,314 134,303 135,299 136,298 137,299 138,300 144,407 144,414 138,459 137,459 134,315" style="fill: rgb(124,128,129)" /> - <polygon points="234,178 235,177 241,173 246,171 247,171 247,173 244,175 239,177 236,178" style="fill: rgb(77,59,57)" /> - <polygon points="172,91 179,85 180,85 181,86 181,87 177,91 176,92" style="fill: rgb(167,117,106)" /> - <polygon points="255,184 256,182 260,179 262,178 264,177 265,177 266,177 257,187" style="fill: rgb(93,24,29)" /> - <polygon points="394,218 397,218 398,219 399,220 399,221 398,221 396,220" style="fill: rgb(127,112,107)" /> - <polygon points="399,328 400,326 401,326 430,352 427,357 425,357 416,351 412,348 411,347 410,346 399,330" style="fill: rgb(101,73,69)" /> - <polygon points="192,74 192,73 194,72 197,72 198,72 199,72 200,72 202,75 200,80 193,77 192,75" style="fill: rgb(87,67,66)" /> - <polygon points="237,185 247,180 248,185" style="fill: rgb(87,67,66)" /> - <polygon points="214,266 218,269 219,270 219,271 217,273 215,270" style="fill: rgb(87,67,66)" /> - <polygon points="416,237 428,232 429,232 432,233 433,235 433,236 432,238 431,239 424,242" style="fill: rgb(134,126,124)" /> - <polygon points="118,101 118,100 120,95 131,92 132,92 129,96 119,101" style="fill: rgb(37,29,27)" /> - <polygon points="152,365 152,364 152,348 152,347 152,343 155,343 199,401 200,403 192,405 174,404 170,403 168,402 159,389 154,378 153,373 152,367" style="fill: rgb(209,203,203)" /> - <polygon points="244,211 244,210 244,209 247,211 250,214 250,215 248,215 246,214 245,213" style="fill: rgb(167,117,106)" /> - <polygon points="173,181 175,180 179,179 185,180 191,182 191,183 190,186 189,186 188,186" style="fill: rgb(101,73,69)" /> - <polygon points="218,131 229,120 230,120 225,131 224,132 219,132" style="fill: rgb(167,117,106)" /> - <polygon points="127,139 128,137 130,136 131,136 140,157 144,171 140,176 138,178 137,179 136,180 134,181 133,181" style="fill: rgb(196,156,148)" /> - <polygon points="19,431 22,431 26,433 38,440 42,447 42,449 42,450 42,451 41,455 39,457 35,459 34,459 33,459 32,459 29,459 19,437" style="fill: rgb(238,226,230)" /> - <polygon points="211,96 212,93 213,92 214,91 217,95 217,96 214,103 212,101 211,100" style="fill: rgb(167,117,106)" /> - <polygon points="153,52 156,48 157,49 157,51 157,53 155,53" style="fill: rgb(101,73,69)" /> - <polygon points="99,111 101,107 104,112 103,113" style="fill: rgb(77,59,57)" /> - <polygon points="0,162 87,156 88,163 88,167 87,168 85,169 84,169 83,169 4,164 0,163" style="fill: rgb(150,149,144)" /> - <polygon points="30,179 31,178 33,178 51,179 60,180 51,180 50,180 49,180 48,180 38,180 36,180" style="fill: rgb(61,75,78)" /> - <polygon points="0,261 2,260 40,254 41,254 49,254 51,254 53,254 54,254 55,254 56,254 57,254 58,254 59,254 60,254 61,254 62,254 63,254 67,254 68,254 71,254 72,254 75,255 84,260 87,263 89,266 91,269 96,280 97,283 98,291 99,304 100,328 103,440 103,442 103,443 103,444 103,445 103,459 0,262" style="fill: rgb(243,244,246)" /> -</svg> diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/gunit/test_003.svg b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/gunit/test_003.svg deleted file mode 100644 index f5e35481ef..0000000000 --- a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/gunit/test_003.svg +++ /dev/null @@ -1,1027 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<svg xmlns="http://www.w3.org/2000/svg" width="400" height="400" version="1.1" baseProfile="full"> - <polygon points="367,69 367,67 369,63 376,67 385,73 399,92 399,107 399,113 396,113 387,109 382,102 367,70" style="fill: rgb(94,71,72)" /> - <polygon points="236,53 238,51 242,51 242,53" style="fill: rgb(67,68,70)" /> - <polygon points="77,55 81,43 86,41 95,41 98,66 97,67 94,68 85,68 84,68 83,68 82,68 81,68" style="fill: rgb(189,187,190)" /> - <polygon points="188,159 189,158 190,158 190,159 189,160" style="fill: rgb(74,84,85)" /> - <polygon points="385,140 385,138 391,134 393,134 399,135 399,141 396,142 395,142" style="fill: rgb(113,83,83)" /> - <polygon points="71,70 72,68 76,64 77,67 77,68 75,69" style="fill: rgb(221,221,223)" /> - <polygon points="242,36 244,35 246,34 248,37 248,38 247,39 243,37" style="fill: rgb(81,62,57)" /> - <polygon points="366,330 367,330 368,330 369,330 370,330 371,330 372,330" style="fill: rgb(189,187,190)" /> - <polygon points="72,144 74,142 75,142 76,142 77,142 78,142 83,144 87,148 89,152 87,154 82,156 79,157 78,157 74,154 73,151 72,147" style="fill: rgb(221,221,223)" /> - <polygon points="377,32 378,0 383,0 389,0 391,2 393,5 397,32 394,32 393,32 392,32 391,32 385,32 384,32" style="fill: rgb(172,146,145)" /> - <polygon points="172,37 173,38 173,39 173,40 172,40 172,39" style="fill: rgb(74,84,85)" /> - <polygon points="229,185 229,181 229,180 230,183 230,185 230,187" style="fill: rgb(118,97,99)" /> - <polygon points="195,17 195,16 195,15 197,16 197,17 196,20" style="fill: rgb(67,68,70)" /> - <polygon points="263,152 264,152 265,152 266,152 267,152 268,152" style="fill: rgb(67,53,52)" /> - <polygon points="204,251 206,248 219,230 221,228 227,237 232,259 232,260 213,262 210,262 207,260 206,259" style="fill: rgb(119,98,95)" /> - <polygon points="324,146 325,138 326,141 325,145" style="fill: rgb(81,62,57)" /> - <polygon points="275,27 277,27 278,28 275,28" style="fill: rgb(67,53,52)" /> - <polygon points="262,57 263,57 264,57 265,57 266,57 267,57 268,57 269,57 270,57 271,57 272,57" style="fill: rgb(142,122,123)" /> - <polygon points="323,20 323,19 323,18 327,16 327,18" style="fill: rgb(175,169,168)" /> - <polygon points="265,163 268,162 278,166 280,167 284,170 284,171 282,171 275,170 269,166" style="fill: rgb(67,53,52)" /> - <polygon points="178,363 178,362 180,360 182,361 181,363 179,364" style="fill: rgb(118,97,99)" /> - <polygon points="109,317 111,315 112,314 114,314 147,320 153,325 154,327 156,335 151,339 124,345 123,344 115,332 110,324" style="fill: rgb(146,140,144)" /> - <polygon points="232,375 233,374 235,373 236,373 237,373 238,374 239,375 236,375" style="fill: rgb(94,71,72)" /> - <polygon points="275,57 276,57 277,57 279,57 280,57 281,57 282,57 283,57 284,57 285,57 286,57 278,57" style="fill: rgb(142,122,123)" /> - <polygon points="168,346 170,344 171,344 176,347 176,350 171,354 170,354" style="fill: rgb(125,127,122)" /> - <polygon points="368,350 371,350 373,350 376,353 376,359 375,361" style="fill: rgb(114,114,116)" /> - <polygon points="318,389 318,388 325,393 326,394 326,395 324,395 319,390" style="fill: rgb(46,41,40)" /> - <polygon points="190,59 191,59 192,59 193,59 194,59 195,59 196,59 197,59" style="fill: rgb(85,92,100)" /> - <polygon points="183,211 183,210 186,199 187,200 187,202 186,206 185,209" style="fill: rgb(152,137,134)" /> - <polygon points="316,350 316,349 317,347 317,348 317,349 316,352 316,351" style="fill: rgb(119,98,95)" /> - <polygon points="196,37 196,36 197,35 199,34 199,36" style="fill: rgb(67,68,70)" /> - <polygon points="277,50 278,50 280,52 280,53 278,54 277,51" style="fill: rgb(81,62,57)" /> - <polygon points="331,223 331,222 331,221 361,173 363,176 368,193 368,216 368,217 367,218 366,219 362,222 360,223 348,226 347,226 336,225" style="fill: rgb(125,127,122)" /> - <polygon points="199,296 202,289 203,287 208,281 211,283 211,286 209,298 206,305 205,306 204,306 203,305" style="fill: rgb(137,94,99)" /> - <polygon points="320,367 320,362 320,360 324,362 327,385 326,389 322,382" style="fill: rgb(53,44,45)" /> - <polygon points="326,327 327,312 328,301 329,290 397,312 399,313 399,351 399,352 399,353 399,354 399,355 396,355 395,355 389,353" style="fill: rgb(142,122,123)" /> - <polygon points="179,222 188,212 189,211 190,210 192,208 198,207 201,210 201,211 199,213 183,223 180,223" style="fill: rgb(189,187,190)" /> - <polygon points="157,301 159,296 160,294 163,289 171,285 181,281 189,281 194,283 195,320 194,324 192,329 191,331 190,332 172,337 161,334 160,330 157,308" style="fill: rgb(172,157,154)" /> - <polygon points="196,54 202,52 208,50 209,50 211,51 212,53 210,54 197,56" style="fill: rgb(67,68,70)" /> - <polygon points="131,175 133,173 135,172 136,173 137,174 138,176 132,176" style="fill: rgb(135,162,171)" /> - <polygon points="394,192 398,188 399,188 399,192 399,193 398,193" style="fill: rgb(124,110,110)" /> - <polygon points="112,370 115,374 115,378 115,379 113,375 112,372" style="fill: rgb(126,142,150)" /> - <polygon points="369,386 374,391 375,393 374,392 373,391 372,390 371,389 370,388" style="fill: rgb(152,137,134)" /> - <polygon points="76,34 78,32 79,33 79,34 79,37 78,39 77,40 76,40" style="fill: rgb(249,247,254)" /> - <polygon points="312,398 312,397 316,380 317,389 316,396 314,399 313,399" style="fill: rgb(94,71,72)" /> - <polygon points="168,59 169,59 174,59 175,59 173,60 170,60" style="fill: rgb(114,114,116)" /> - <polygon points="93,183 93,187 93,182 93,186 93,185 93,184" style="fill: rgb(189,187,190)" /> - <polygon points="212,10 213,9 216,11 217,12 215,12 213,12" style="fill: rgb(74,78,77)" /> - <polygon points="191,260 201,168 203,165 205,165 211,178 221,213 220,222 211,263 192,263 191,263" style="fill: rgb(172,146,145)" /> - <polygon points="225,387 226,385 228,385 229,386 228,387 227,387 226,387" style="fill: rgb(94,71,72)" /> - <polygon points="75,150 76,151 77,152 77,157 75,156" style="fill: rgb(249,247,254)" /> - <polygon points="228,250 229,247 230,245 237,244 240,254 240,255 240,256 239,257 238,258 236,258 234,257" style="fill: rgb(94,71,72)" /> - <polygon points="95,359 95,358 95,357 95,356 95,350 103,326 114,382 114,384 113,386 112,386 108,383 107,382 95,366" style="fill: rgb(189,187,190)" /> - <polygon points="112,325 113,324 114,325 115,327 113,327" style="fill: rgb(126,142,150)" /> - <polygon points="364,138 372,121 373,120 399,132 399,133 399,134 394,141 382,142 367,143 365,142" style="fill: rgb(81,62,57)" /> - <polygon points="176,379 177,379 179,379 180,379 181,379 181,380 180,380 178,380" style="fill: rgb(94,71,72)" /> - <polygon points="93,179 93,178 94,174 95,171 96,170 102,164 106,162 109,161 113,160 117,159 121,159 124,160 139,194 140,202 138,215 137,221 134,225 130,225 129,225 128,225 127,225 126,225 93,181" style="fill: rgb(175,169,168)" /> - <polygon points="227,331 228,331 229,331 228,333 227,332" style="fill: rgb(137,94,99)" /> - <polygon points="376,207 376,206 377,188 389,143 390,143 399,143 399,184 399,185 399,186 399,187 396,193 394,196 393,197 379,207" style="fill: rgb(124,110,110)" /> - <polygon points="255,222 256,222 257,222 258,222 259,222 260,223 259,223 258,223 257,223 256,223 255,223" style="fill: rgb(51,52,54)" /> - <polygon points="343,332 345,331 346,331 351,331 352,331 355,332 359,351 359,352 358,351 344,336" style="fill: rgb(172,157,154)" /> - <polygon points="284,64 285,64 286,67 285,67 284,65" style="fill: rgb(67,53,52)" /> - <polygon points="171,76 174,69 189,60 203,59 204,59 213,61 215,62 215,63 203,108 202,109 201,109 182,108 180,106 171,77" style="fill: rgb(67,68,70)" /> - <polygon points="142,333 143,333 144,333 145,334 147,336 147,338 144,338" style="fill: rgb(125,127,122)" /> - <polygon points="209,238 211,179 213,181 214,182 237,221 237,222 237,224 236,228 233,231 214,243 211,243 210,243" style="fill: rgb(137,94,99)" /> - <polygon points="31,0 33,0 35,0 37,0 39,0 41,0 43,0 45,0 47,0 49,0 71,41 71,42 71,44 71,45 70,45 69,44 68,43 36,6" style="fill: rgb(126,142,150)" /> - <polygon points="280,335 286,333 286,334 286,335 284,337 282,338 280,337" style="fill: rgb(53,44,45)" /> - <polygon points="329,273 329,267 329,265 329,263 329,262 331,260 336,259 337,259 359,262 371,264 385,267 398,271 399,272 399,285 399,286 398,286 397,286 387,285 367,281" style="fill: rgb(175,169,168)" /> - <polygon points="96,300 101,269 104,257 105,254 109,243 114,231 116,230 120,231 110,303 106,305 97,301" style="fill: rgb(188,205,213)" /> - <polygon points="156,357 156,356 156,355 157,355 158,355 159,355 159,357 157,358 156,358 156,355 157,355 158,355" style="fill: rgb(124,110,110)" /> - <polygon points="218,250 218,249 220,230 222,228 223,227 224,226 226,225 238,221 290,224 310,301 306,310 304,311 281,309 277,307 229,274" style="fill: rgb(113,83,83)" /> - <polygon points="186,366 186,365 186,362 186,361 260,260 263,257 268,256 305,306 305,307 305,308 304,312 303,315 221,361 195,367 189,368" style="fill: rgb(113,83,83)" /> - <polygon points="217,373 229,372 235,372 236,372 237,372 239,372 240,374 240,375 239,376 238,377 235,378 224,380 223,380 217,375" style="fill: rgb(81,62,57)" /> - <polygon points="222,201 224,197 237,218 237,219 236,218 223,204 222,202" style="fill: rgb(113,83,83)" /> - <polygon points="331,203 331,201 333,195 333,200 333,201" style="fill: rgb(53,44,45)" /> - <polygon points="141,388 142,388 143,389 148,394 148,395 145,393" style="fill: rgb(114,114,116)" /> - <polygon points="355,220 358,214 360,214 361,215 361,216 356,220" style="fill: rgb(124,110,110)" /> - <polygon points="148,162 149,161 150,161 151,161 152,161 153,161 153,163 152,164 151,164 150,164" style="fill: rgb(114,114,116)" /> - <polygon points="228,276 229,275 232,273 236,272 261,266 262,266 267,267 271,272 271,273 231,276" style="fill: rgb(94,71,72)" /> - <polygon points="349,53 351,53 352,54 353,57" style="fill: rgb(142,122,123)" /> - <polygon points="299,324 299,323 301,321 301,323 300,324" style="fill: rgb(113,83,83)" /> - <polygon points="143,358 144,359 145,360 143,360" style="fill: rgb(118,97,99)" /> - <polygon points="242,37 243,36 246,39 246,40 245,40 243,39" style="fill: rgb(67,53,52)" /> - <polygon points="370,171 371,170 372,173 372,174 371,173" style="fill: rgb(113,83,83)" /> - <polygon points="378,66 379,66 382,68 383,69 379,67" style="fill: rgb(221,221,223)" /> - <polygon points="211,383 212,382 213,382 213,384 212,384" style="fill: rgb(67,53,52)" /> - <polygon points="254,3 257,0 260,1 261,2 261,3 260,4 258,5 256,5" style="fill: rgb(67,53,52)" /> - <polygon points="246,58 247,58 248,58 249,58 250,58 251,58 252,58 253,58" style="fill: rgb(119,98,95)" /> - <polygon points="105,322 106,325 106,327 105,324 105,323" style="fill: rgb(249,247,254)" /> - <polygon points="128,175 130,174 131,174 177,180 177,181 177,183 177,185 159,193 152,195 151,195 134,189" style="fill: rgb(125,127,122)" /> - <polygon points="187,187 187,186 187,185 188,180 190,179 193,179 194,180" style="fill: rgb(152,137,134)" /> - <polygon points="98,4 99,0 101,0 101,5 100,6 98,5" style="fill: rgb(189,187,190)" /> - <polygon points="188,381 189,381 190,381 194,382 191,382" style="fill: rgb(81,62,57)" /> - <polygon points="196,382 210,379 215,381 216,384 215,385 214,385 213,385 201,385 196,383" style="fill: rgb(81,62,57)" /> - <polygon points="324,175 325,174 326,174 327,177 326,178" style="fill: rgb(113,83,83)" /> - <polygon points="111,187 112,186 113,186 114,186 116,187 115,187 114,187 113,187 112,187" style="fill: rgb(135,162,171)" /> - <polygon points="326,292 326,287 326,286 327,282 327,287 327,290 327,291" style="fill: rgb(51,52,54)" /> - <polygon points="156,138 159,138 159,139 156,139" style="fill: rgb(114,114,116)" /> - <polygon points="141,314 142,315 142,316 142,317 141,316" style="fill: rgb(175,169,168)" /> - <polygon points="369,163 369,162 370,163 371,164 371,165 370,165 369,164" style="fill: rgb(113,83,83)" /> - <polygon points="224,227 225,226 227,226 227,227 227,230 225,229 224,228" style="fill: rgb(53,44,45)" /> - <polygon points="203,257 204,260 204,261 203,260" style="fill: rgb(142,122,123)" /> - <polygon points="235,255 236,253 237,252 238,255 237,256 236,256" style="fill: rgb(113,83,83)" /> - <polygon points="271,54 272,52 275,49 275,50 275,52 275,53 274,55" style="fill: rgb(67,53,52)" /> - <polygon points="120,337 120,334 120,333 120,331 121,329 123,329 139,332 144,334 166,345 168,349 168,350 168,354 168,355 167,355 149,355 143,354 138,353 131,350 129,348 127,346 126,345 122,340" style="fill: rgb(125,127,122)" /> - <polygon points="269,303 270,303 271,305 270,305 269,305" style="fill: rgb(94,71,72)" /> - <polygon points="7,103 8,98 9,97 11,96 18,127 18,128 17,127 14,122 9,111 8,108 7,105" style="fill: rgb(221,221,223)" /> - <polygon points="326,180 327,180 330,180 330,181 329,186 327,186" style="fill: rgb(81,62,57)" /> - <polygon points="173,355 173,351 212,314 216,321 217,325 217,328 217,329 204,347 182,360 179,361 177,361" style="fill: rgb(124,110,110)" /> - <polygon points="313,329 314,329 319,330 320,331 319,331 315,330" style="fill: rgb(114,114,116)" /> - <polygon points="327,204 327,208 327,203 327,207 327,202 327,206 327,201 327,205" style="fill: rgb(119,98,95)" /> - <polygon points="199,42 201,41 202,41 204,44 202,45 201,45 200,45" style="fill: rgb(67,68,70)" /> - <polygon points="398,3 398,1 398,0 399,0 399,8 399,11 398,8" style="fill: rgb(221,221,223)" /> - <polygon points="359,206 367,199 367,200 365,204 363,207 362,208 361,209" style="fill: rgb(124,110,110)" /> - <polygon points="137,137 161,123 162,123 173,129 186,154 185,155 184,155 179,155 178,155 137,143" style="fill: rgb(114,114,116)" /> - <polygon points="132,350 154,348 158,363 158,365 156,367 154,367 138,356 133,352 132,351" style="fill: rgb(114,114,116)" /> - <polygon points="304,317 307,313 308,313 309,314 307,317 304,318" style="fill: rgb(172,157,154)" /> - <polygon points="211,59 212,59 213,59 214,59 215,59 216,59 217,59 218,59 219,59 220,59 221,59 222,59 223,59" style="fill: rgb(74,78,77)" /> - <polygon points="382,396 384,397 386,398 387,399 385,399 383,397" style="fill: rgb(172,157,154)" /> - <polygon points="310,174 310,172 312,175 312,176 310,176 310,173 310,172 312,175" style="fill: rgb(94,71,72)" /> - <polygon points="149,337 155,335 155,336 155,337 151,347 149,345" style="fill: rgb(152,137,134)" /> - <polygon points="197,255 198,255 198,256 198,257 197,258" style="fill: rgb(142,122,123)" /> - <polygon points="363,171 363,170 363,169 363,168 364,167 364,173 363,172 363,168" style="fill: rgb(114,114,116)" /> - <polygon points="154,232 155,231 157,230 169,224 173,228 175,231 177,234 178,236 160,239 158,237" style="fill: rgb(142,122,123)" /> - <polygon points="175,160 176,160 177,160 178,160 178,161 177,161" style="fill: rgb(74,84,85)" /> - <polygon points="180,214 183,205 184,203 186,207 186,208 186,209 183,213 180,216 180,215" style="fill: rgb(152,137,134)" /> - <polygon points="266,343 267,342 269,347 267,346 266,345" style="fill: rgb(67,53,52)" /> - <polygon points="183,10 184,10 188,13 184,13" style="fill: rgb(74,78,77)" /> - <polygon points="125,176 126,176 127,176 128,176 129,177 129,178 128,178" style="fill: rgb(135,162,171)" /> - <polygon points="152,153 152,151 153,151 154,151 155,151 156,151 161,152 193,159 205,164 185,188 181,191" style="fill: rgb(85,92,100)" /> - <polygon points="150,44 150,43 150,41 151,42 151,43" style="fill: rgb(85,92,100)" /> - <polygon points="222,181 223,174 225,166 229,158 230,157 237,152 246,148 255,148 261,148 243,218 242,218 240,217 237,215 231,208 230,206 227,198 222,183" style="fill: rgb(113,83,83)" /> - <polygon points="283,399 301,332 304,330 307,345 308,351 308,352 307,359 296,393 293,399" style="fill: rgb(31,24,23)" /> - <polygon points="124,156 125,150 131,149 132,149 133,149 134,149 135,149 144,149 145,149 146,149 147,149 148,149 149,149 150,149 151,149 156,150 160,151 172,167 153,177 148,178 145,178 143,176" style="fill: rgb(95,115,124)" /> - <polygon points="242,374 243,371 244,370 245,371 245,372 243,374" style="fill: rgb(81,62,57)" /> - <polygon points="132,384 136,387 143,393 148,399 145,399 144,398 138,392" style="fill: rgb(118,97,99)" /> - <polygon points="249,335 249,334 249,333 250,333 250,335" style="fill: rgb(67,53,52)" /> - <polygon points="189,10 190,9 192,10 190,12" style="fill: rgb(74,84,85)" /> - <polygon points="294,398 294,397 294,390 294,389 296,385 300,378 301,377 303,378 304,379 304,381 303,384 298,397 297,398 296,399 295,399 294,399" style="fill: rgb(31,24,23)" /> - <polygon points="189,284 189,283 190,282 191,283 190,284" style="fill: rgb(175,169,168)" /> - <polygon points="376,337 379,334 380,333 377,338" style="fill: rgb(114,114,116)" /> - <polygon points="179,316 179,315 179,314 180,314 181,314 183,315 181,317 180,317" style="fill: rgb(172,146,145)" /> - <polygon points="202,368 202,366 204,367 203,368 202,369 202,366" style="fill: rgb(69,65,62)" /> - <polygon points="315,357 315,356 315,350 315,349 316,356 316,357 316,359 315,358 315,350 315,349 316,356 316,357 316,359 315,358" style="fill: rgb(94,71,72)" /> - <polygon points="242,366 245,363 246,362 246,363 246,364 245,367 244,367" style="fill: rgb(53,44,45)" /> - <polygon points="191,229 193,228 196,228 195,229 192,231" style="fill: rgb(94,71,72)" /> - <polygon points="231,180 231,179 231,178 231,176 232,172 233,170 253,155 271,152 284,152 287,152 300,154 305,156 308,158 309,159 310,160 309,170 296,188 290,192 285,193 284,193 252,187 242,185 232,181" style="fill: rgb(74,78,77)" /> - <polygon points="170,182 173,180 174,180 175,180 176,181 175,182" style="fill: rgb(152,137,134)" /> - <polygon points="174,219 176,215 181,205 195,186 197,184 199,183 200,183 201,185 202,192 202,206 202,207 202,208 177,223 176,223" style="fill: rgb(175,169,168)" /> - <polygon points="137,158 138,158 139,158 140,158 141,158 143,158 147,159 143,160" style="fill: rgb(126,142,150)" /> - <polygon points="310,298 310,297 312,296 313,297 312,298 311,298" style="fill: rgb(142,122,123)" /> - <polygon points="111,176 115,170 116,169 123,162 127,159 130,158 131,158 121,177 112,178 111,177" style="fill: rgb(146,140,144)" /> - <polygon points="115,316 116,316 118,317 117,318 115,317" style="fill: rgb(175,169,168)" /> - <polygon points="117,397 118,397 119,399 118,399 117,398" style="fill: rgb(175,169,168)" /> - <polygon points="82,32 87,8 109,5 110,5 110,6 105,23 94,37 93,38 91,40 89,40 83,38 82,33" style="fill: rgb(189,187,190)" /> - <polygon points="251,165 251,164 253,163 255,163 262,163 267,164 269,165 268,168 263,173 258,173 252,171 251,169" style="fill: rgb(51,52,54)" /> - <polygon points="357,395 357,394 360,397 360,399" style="fill: rgb(53,44,45)" /> - <polygon points="99,129 102,128 113,131 114,134 114,137 99,130" style="fill: rgb(172,157,154)" /> - <polygon points="262,157 263,157 264,157 265,157 269,157 270,157 271,157 278,159 279,160 278,161 277,161 268,159" style="fill: rgb(81,62,57)" /> - <polygon points="186,2 186,1 187,0 188,0 191,0 191,2 187,2" style="fill: rgb(74,78,77)" /> - <polygon points="219,161 219,160 220,157 230,155 231,155 229,165 227,174 221,182 220,178" style="fill: rgb(67,68,70)" /> - <polygon points="250,59 251,59 252,59 253,59 254,59 255,59 256,59 257,59 258,59" style="fill: rgb(81,62,57)" /> - <polygon points="310,326 311,326 312,326 314,326 319,327 320,328 321,329 313,327" style="fill: rgb(172,157,154)" /> - <polygon points="119,314 120,314 121,314 123,315 124,316 123,318 121,317" style="fill: rgb(172,157,154)" /> - <polygon points="142,277 144,275 146,275 147,275 148,275 148,276 142,285" style="fill: rgb(172,146,145)" /> - <polygon points="359,189 362,186 363,188 363,189 362,191" style="fill: rgb(124,110,110)" /> - <polygon points="333,333 334,334 339,339 343,344 378,396 378,399 376,399 374,398 364,387 353,374 333,336" style="fill: rgb(172,146,145)" /> - <polygon points="176,264 176,263 177,259 178,260 178,262" style="fill: rgb(172,157,154)" /> - <polygon points="175,375 177,369 179,367 185,362 185,366 184,370 182,376" style="fill: rgb(85,92,100)" /> - <polygon points="317,394 318,392 320,392 322,393 323,394 323,399 319,399 317,396" style="fill: rgb(67,53,52)" /> - <polygon points="321,13 321,12 322,10 325,12 325,13 322,15" style="fill: rgb(172,157,154)" /> - <polygon points="132,375 147,366 149,367 152,369 173,384 174,385 161,391 160,391 159,391 151,390 149,389 144,386 132,377" style="fill: rgb(152,137,134)" /> - <polygon points="304,139 306,133 307,131 309,129 320,128 321,128 322,129 324,137 324,142 323,145 322,145 321,145 320,145 313,144 305,142" style="fill: rgb(113,83,83)" /> - <polygon points="245,142 246,142 247,142 248,142 249,143 248,143 247,143 246,143" style="fill: rgb(69,65,62)" /> - <polygon points="360,11 361,0 363,0 367,0 377,0 399,33 399,44 399,52 399,60 399,62 398,62 394,61 384,54 380,50 364,34 363,33 361,30" style="fill: rgb(142,122,123)" /> - <polygon points="325,173 327,172 331,171 333,174 332,175 331,176 328,176 327,175" style="fill: rgb(67,53,52)" /> - <polygon points="360,158 361,144 363,141 364,140 388,143 392,144 393,145 393,152 393,164 393,165 390,177 389,180 375,208 373,211 371,214 369,216 366,218" style="fill: rgb(119,98,95)" /> - <polygon points="108,357 108,356 108,353 108,352 108,351 108,350 109,355 111,365 111,368 110,366 108,359" style="fill: rgb(126,142,150)" /> - <polygon points="173,220 195,183 198,180 199,180 201,180 202,182 204,186 206,196 207,202 206,214 202,228 181,235 179,234 178,233 176,229 174,224" style="fill: rgb(175,169,168)" /> - <polygon points="142,286 146,274 189,181 197,165 199,166 205,180 212,207 212,211 212,212 206,235 192,268 175,282 150,302 146,303 142,288" style="fill: rgb(152,137,134)" /> - <polygon points="133,113 146,112 164,111 165,114 159,121 148,121 144,120 133,114" style="fill: rgb(114,114,116)" /> - <polygon points="170,356 170,355 173,353 173,354 171,356" style="fill: rgb(125,127,122)" /> - <polygon points="355,328 355,327 356,326 357,325 359,324 361,323 362,323 363,323 364,323 365,323 366,323 367,323 368,323 369,323" style="fill: rgb(146,140,144)" /> - <polygon points="302,324 302,323 303,323 304,324 307,329 308,331 309,333 310,335 312,342 313,348 315,370 315,373 315,374 315,379 314,385 311,399 310,399 302,328" style="fill: rgb(46,41,40)" /> - <polygon points="198,111 199,111 200,111 201,111 202,111 203,111 204,111 205,111 199,112 198,112" style="fill: rgb(94,71,72)" /> - <polygon points="305,38 305,37 305,36 306,0 309,0 310,2 311,6 313,16 319,53 319,56 318,57 317,57" style="fill: rgb(113,83,83)" /> - <polygon points="363,352 363,351 365,351 366,351 368,351 371,351 375,357 375,359 374,360 372,359 368,356" style="fill: rgb(95,115,124)" /> - <polygon points="131,374 132,373 138,376 139,377 139,378 135,378" style="fill: rgb(146,140,144)" /> - <polygon points="301,348 301,347 301,350 301,349 301,351 301,346" style="fill: rgb(30,25,21)" /> - <polygon points="208,311 209,311 213,313 219,319 220,320 221,332 219,331 218,330 212,323 208,312" style="fill: rgb(124,110,110)" /> - <polygon points="255,38 256,33 257,32 261,31 261,32 259,38 256,40" style="fill: rgb(67,53,52)" /> - <polygon points="172,346 176,338 177,336 204,324 205,325 206,331 203,342 194,345 179,348 173,347" style="fill: rgb(152,137,134)" /> - <polygon points="11,91 18,85 20,84 28,82 34,81 35,81 36,81 37,81 23,93 20,94 18,94" style="fill: rgb(188,205,213)" /> - <polygon points="135,225 144,225 145,225 146,225 147,225 148,225 136,225 137,225 138,225 139,225 140,225 141,225 142,225 143,225" style="fill: rgb(135,162,171)" /> - <polygon points="108,327 108,324 110,329 110,330" style="fill: rgb(189,187,190)" /> - <polygon points="189,229 190,228 191,228 197,228 195,230 193,232 192,233 190,231" style="fill: rgb(94,71,72)" /> - <polygon points="188,200 188,199 190,195 190,196 188,201" style="fill: rgb(152,137,134)" /> - <polygon points="185,375 187,374 188,375 188,378 187,378 186,378 185,377" style="fill: rgb(113,83,83)" /> - <polygon points="337,59 338,59 339,59 340,59 341,59 342,59 343,60" style="fill: rgb(119,98,95)" /> - <polygon points="145,329 149,330 150,331 146,330" style="fill: rgb(172,146,145)" /> - <polygon points="279,351 281,348 282,347 283,346 283,347 281,349 280,350" style="fill: rgb(94,71,72)" /> - <polygon points="288,388 288,387 291,381 292,379 293,380 290,385" style="fill: rgb(46,41,40)" /> - <polygon points="354,342 354,341 354,340 355,339 362,332 368,332 370,332 371,332 372,332 373,332 374,332 372,337 371,339 370,340 367,341 356,344" style="fill: rgb(152,137,134)" /> - <polygon points="17,0 18,0 19,0 20,0 82,58 84,60 92,68 90,69 86,70 69,74 68,74 67,74 58,73" style="fill: rgb(188,205,213)" /> - <polygon points="325,259 325,258 325,255 326,254 327,259" style="fill: rgb(137,94,99)" /> - <polygon points="177,229 178,228 179,227 203,210 203,213 203,214 200,217 182,228 179,229 178,229" style="fill: rgb(172,157,154)" /> - <polygon points="178,187 178,183 178,186 178,182 178,185 178,181 178,184" style="fill: rgb(175,169,168)" /> - <polygon points="216,5 216,4 217,4 218,5 218,6 217,6" style="fill: rgb(94,71,72)" /> - <polygon points="288,152 289,152 290,152 291,152 292,152 298,153 297,155 295,155" style="fill: rgb(81,62,57)" /> - <polygon points="180,29 180,28 183,0 186,0 196,0 206,7 216,15 232,29 231,31 217,48 192,49 191,49 188,47 187,46" style="fill: rgb(67,68,70)" /> - <polygon points="307,312 309,309 310,308 314,305 310,314 309,315 308,315" style="fill: rgb(188,205,213)" /> - <polygon points="263,58 264,58 275,59 265,59" style="fill: rgb(94,71,72)" /> - <polygon points="229,176 230,173 232,168 235,165 236,164 237,164 236,169 231,177" style="fill: rgb(74,78,77)" /> - <polygon points="58,160 59,159 60,159 61,160 63,170 60,168 58,165" style="fill: rgb(221,221,223)" /> - <polygon points="202,76 203,76 204,77 202,79 202,77" style="fill: rgb(67,68,70)" /> - <polygon points="106,87 111,70 116,67 118,66 140,60 163,59 164,59 169,60 163,111 130,113 128,113 127,113 124,113 120,113 118,113 117,113 116,113 112,111 107,102" style="fill: rgb(95,115,124)" /> - <polygon points="317,365 317,359 318,364 318,365 317,367 317,366 317,361 317,360 317,359 318,364" style="fill: rgb(113,83,83)" /> - <polygon points="377,68 378,68 380,69 382,70 381,70 378,69" style="fill: rgb(119,98,95)" /> - <polygon points="314,333 315,333 319,336 318,336 316,335 315,334" style="fill: rgb(74,84,85)" /> - <polygon points="327,196 328,195 329,201 329,210 329,211 328,209 327,198" style="fill: rgb(113,83,83)" /> - <polygon points="97,210 145,226 116,229 115,229 112,228 108,226 106,225 104,224 100,221 97,217" style="fill: rgb(126,142,150)" /> - <polygon points="192,109 193,109 198,109 199,109 208,110 196,111 194,110" style="fill: rgb(74,84,85)" /> - <polygon points="313,4 313,3 315,1 316,0 319,0 320,1 321,2 315,7 314,7 313,5" style="fill: rgb(152,137,134)" /> - <polygon points="308,157 311,157 316,160 317,161 317,162 315,167 314,166" style="fill: rgb(53,44,45)" /> - <polygon points="360,348 361,346 367,344 367,345 363,347" style="fill: rgb(152,137,134)" /> - <polygon points="209,31 211,31 212,31 212,32 211,32 210,32" style="fill: rgb(67,68,70)" /> - <polygon points="24,6 24,5 25,6 61,46 68,54 70,57 69,57 66,54 49,35 28,11" style="fill: rgb(189,187,190)" /> - <polygon points="367,61 368,61 371,62 370,63 368,62" style="fill: rgb(152,137,134)" /> - <polygon points="187,233 187,232 187,231 187,230 191,235 190,235 187,234" style="fill: rgb(137,94,99)" /> - <polygon points="293,95 293,93 293,91 295,88 300,90 302,91 304,93 304,95 299,98" style="fill: rgb(46,41,40)" /> - <polygon points="319,385 323,383 326,385 326,390 324,390 323,389" style="fill: rgb(46,41,40)" /> - <polygon points="186,155 187,154 188,153 189,154 188,155" style="fill: rgb(125,127,122)" /> - <polygon points="316,149 317,148 331,142 336,152 336,173 335,174 329,173" style="fill: rgb(53,44,45)" /> - <polygon points="154,230 165,226 165,227 163,228 158,230" style="fill: rgb(125,127,122)" /> - <polygon points="278,351 280,348 281,347 283,345 280,349 279,350" style="fill: rgb(81,62,57)" /> - <polygon points="261,69 261,68 262,67 265,67 267,68 266,70" style="fill: rgb(53,44,45)" /> - <polygon points="233,198 233,197 234,199 235,202 234,201" style="fill: rgb(118,97,99)" /> - <polygon points="62,184 68,179 72,177 73,182 74,193 74,194 74,195 74,196 73,198 72,198" style="fill: rgb(221,221,223)" /> - <polygon points="329,40 330,40 332,41 331,42 330,42 329,42 329,41" style="fill: rgb(175,169,168)" /> - <polygon points="354,148 354,147 355,146 357,146 358,147 356,148" style="fill: rgb(53,44,45)" /> - <polygon points="374,120 375,119 376,120 377,121 375,123 374,123" style="fill: rgb(119,98,95)" /> - <polygon points="231,209 234,212 233,211 232,210 236,214 235,213" style="fill: rgb(67,53,52)" /> - <polygon points="301,149 301,148 302,148 303,148 304,148 305,149 305,150 304,151" style="fill: rgb(53,44,45)" /> - <polygon points="329,158 329,157 329,156 330,158 329,161 329,159" style="fill: rgb(51,52,54)" /> - <polygon points="165,364 165,362 165,361 166,362 166,363" style="fill: rgb(114,114,116)" /> - <polygon points="148,305 154,303 158,313 159,317 159,318 157,319 153,317 149,310 148,308" style="fill: rgb(152,137,134)" /> - <polygon points="249,376 251,374 254,372 255,372 254,374 250,376" style="fill: rgb(94,71,72)" /> - <polygon points="140,398 140,396 141,397 142,398 143,399" style="fill: rgb(74,84,85)" /> - <polygon points="180,43 181,42 184,41 184,42 184,43 183,44 182,44 181,44" style="fill: rgb(74,78,77)" /> - <polygon points="27,0 28,0 29,0 33,4 52,26 58,33 66,43 66,44 63,41 61,39 36,11 28,2" style="fill: rgb(221,221,223)" /> - <polygon points="0,361 4,346 6,340 52,310 56,308 93,302 94,302 96,303 98,305 101,309 102,315 102,316 102,317 70,337 18,369 8,371 1,371 0,371" style="fill: rgb(135,162,171)" /> - <polygon points="217,370 218,369 221,369 221,370" style="fill: rgb(53,44,45)" /> - <polygon points="352,174 355,153 360,146 361,145 362,144 363,145 363,150 363,152 362,181 360,182 355,181" style="fill: rgb(124,110,110)" /> - <polygon points="320,349 321,348 323,349 323,350 321,351" style="fill: rgb(40,30,30)" /> - <polygon points="251,369 254,364 255,364 255,366 252,369" style="fill: rgb(67,53,52)" /> - <polygon points="104,336 104,335 104,332 104,331 105,329 104,338 104,330 105,329 104,338 104,330" style="fill: rgb(175,169,168)" /> - <polygon points="297,308 298,308 299,308 300,310 300,311 300,312 299,312 298,312" style="fill: rgb(113,83,83)" /> - <polygon points="90,51 91,50 93,49 94,50 92,51" style="fill: rgb(189,187,190)" /> - <polygon points="122,123 125,117 132,115 136,115 149,119 157,122 159,123 165,130 164,132 137,140 130,142 129,141" style="fill: rgb(125,127,122)" /> - <polygon points="324,7 325,4 330,9 329,12 327,14 325,16 324,8" style="fill: rgb(189,187,190)" /> - <polygon points="317,357 317,356 317,355 317,354 318,354 318,357 318,359 318,361 318,363 317,358" style="fill: rgb(119,98,95)" /> - <polygon points="305,390 307,386 307,388 307,389 306,391" style="fill: rgb(40,30,30)" /> - <polygon points="89,30 90,27 91,27 91,28 90,31 89,31" style="fill: rgb(188,205,213)" /> - <polygon points="386,197 389,195 389,199" style="fill: rgb(142,122,123)" /> - <polygon points="294,331 294,330 295,328 296,328 296,329" style="fill: rgb(81,62,57)" /> - <polygon points="103,313 105,315 106,316 103,316" style="fill: rgb(188,205,213)" /> - <polygon points="96,16 97,16 98,21 97,21" style="fill: rgb(135,162,171)" /> - <polygon points="281,183 290,174 291,174 294,174 295,174 297,176 297,177 295,182 293,185 290,187 289,187 281,186" style="fill: rgb(81,62,57)" /> - <polygon points="355,377 355,376 356,376 358,378 360,381 361,383 360,383 357,381 356,380" style="fill: rgb(137,94,99)" /> - <polygon points="69,55 69,51 71,51 71,53 71,54 70,56" style="fill: rgb(188,205,213)" /> - <polygon points="180,383 180,382 182,381 218,392 217,395 214,395 207,395 201,393 181,384" style="fill: rgb(119,98,95)" /> - <polygon points="287,104 287,103 288,101 289,100 289,104 288,104" style="fill: rgb(46,41,40)" /> - <polygon points="177,58 179,57 181,57 182,57 180,58" style="fill: rgb(146,140,144)" /> - <polygon points="116,380 116,378 117,379 119,382 124,392 127,399 126,399 123,395 118,385 117,383" style="fill: rgb(113,133,143)" /> - <polygon points="45,24 47,24 48,25 53,30 54,31 50,29 46,25" style="fill: rgb(188,205,213)" /> - <polygon points="74,157 74,155 77,158 74,159 74,156 74,155 77,158" style="fill: rgb(188,205,213)" /> - <polygon points="76,1 78,1 78,2 77,3" style="fill: rgb(135,162,171)" /> - <polygon points="313,21 313,20 314,22 315,25 325,58 320,58 319,58 318,58 317,58 316,58 314,45 313,27" style="fill: rgb(113,83,83)" /> - <polygon points="57,160 58,159 59,158 60,158 61,158 62,158 71,161 72,166 72,174 72,175 72,176 71,178 70,180 66,182 57,163" style="fill: rgb(189,187,190)" /> - <polygon points="189,58 194,57 195,57 194,58" style="fill: rgb(172,157,154)" /> - <polygon points="271,110 286,112 274,112 272,111" style="fill: rgb(46,41,40)" /> - <polygon points="395,164 395,160 396,160 396,161 396,165 395,165" style="fill: rgb(119,98,95)" /> - <polygon points="118,14 119,0 122,0 126,0 126,10 126,12 121,20 120,19 118,17" style="fill: rgb(135,162,171)" /> - <polygon points="231,381 235,380 233,382 232,382" style="fill: rgb(81,62,57)" /> - <polygon points="356,328 356,327 357,326 359,325 362,324 363,324 364,324 365,324 366,324 367,324 360,329" style="fill: rgb(135,162,171)" /> - <polygon points="109,324 110,323 112,326 113,328 113,329" style="fill: rgb(175,169,168)" /> - <polygon points="37,8 42,13 41,12 38,9 40,11 39,10 43,14" style="fill: rgb(189,187,190)" /> - <polygon points="314,284 317,285 317,289 316,288 315,287" style="fill: rgb(142,122,123)" /> - <polygon points="135,0 137,0 137,2 136,3 135,2" style="fill: rgb(95,115,124)" /> - <polygon points="269,170 269,169 270,167 271,167 269,171" style="fill: rgb(69,65,62)" /> - <polygon points="250,7 251,6 252,6 253,6 254,7 255,8 253,11 250,8" style="fill: rgb(67,53,52)" /> - <polygon points="172,329 182,280 191,280 195,281 198,283 200,320 200,321 197,333 187,336 173,334 172,330" style="fill: rgb(172,146,145)" /> - <polygon points="237,171 237,170 245,170 246,171 246,173 245,173 244,173 240,172" style="fill: rgb(67,53,52)" /> - <polygon points="245,169 245,168 245,167 250,172 250,173 250,174 249,174 248,174 247,174" style="fill: rgb(67,68,70)" /> - <polygon points="225,181 226,180 226,183 225,183" style="fill: rgb(67,68,70)" /> - <polygon points="310,305 311,302 312,302 312,305 311,306" style="fill: rgb(125,127,122)" /> - <polygon points="189,165 192,158 195,157 199,157 201,158 201,159 201,160 200,163" style="fill: rgb(74,84,85)" /> - <polygon points="208,14 209,12 211,16 209,15" style="fill: rgb(67,68,70)" /> - <polygon points="327,386 330,385 333,386" style="fill: rgb(81,62,57)" /> - <polygon points="268,174 268,173 269,172 273,170 281,166 282,166 289,171 289,172 270,176 269,176 268,176" style="fill: rgb(81,62,57)" /> - <polygon points="251,142 264,140 265,140 263,141 258,142" style="fill: rgb(69,65,62)" /> - <polygon points="217,60 218,60 223,60 222,61 219,61" style="fill: rgb(51,52,54)" /> - <polygon points="184,355 185,349 208,302 210,300 215,298 218,297 219,297 221,297 224,298 226,300 227,301 239,325 234,333 192,363 184,358" style="fill: rgb(142,122,123)" /> - <polygon points="325,32 325,31 326,29 328,31 329,35 328,36 327,37" style="fill: rgb(172,146,145)" /> - <polygon points="199,368 201,368 201,369 201,370 201,371 199,369" style="fill: rgb(67,53,52)" /> - <polygon points="134,337 135,336 136,336 137,338" style="fill: rgb(113,133,143)" /> - <polygon points="167,85 168,75 169,74 175,72 176,72 182,88 184,109 177,109 170,108" style="fill: rgb(74,78,77)" /> - <polygon points="334,333 334,332 339,337 343,341 346,346 367,384 367,385 365,383 354,371 350,364" style="fill: rgb(152,137,134)" /> - <polygon points="162,366 162,362 162,360 163,359 166,364 165,367 164,367" style="fill: rgb(118,97,99)" /> - <polygon points="78,17 80,15 83,15 82,20 78,20" style="fill: rgb(221,221,223)" /> - <polygon points="291,203 292,203 293,203 294,203 296,205 296,207 295,207 292,205 291,204" style="fill: rgb(113,83,83)" /> - <polygon points="164,356 165,356 168,360 167,361 166,361 165,360" style="fill: rgb(124,110,110)" /> - <polygon points="164,5 167,0 172,0 173,0 174,0 175,0 182,0 184,2 185,3 186,4 188,6 195,22 196,51 196,52 195,55 184,56 183,56 182,56 180,56 171,51 170,50 169,46" style="fill: rgb(74,84,85)" /> - <polygon points="147,38 149,35 150,35 151,38" style="fill: rgb(95,115,124)" /> - <polygon points="365,390 365,389 370,392 372,394 373,396 373,397 371,396" style="fill: rgb(137,94,99)" /> - <polygon points="163,362 163,360 164,357 164,358 164,359 164,360 164,361 163,363 163,360" style="fill: rgb(118,97,99)" /> - <polygon points="243,96 244,96 245,96 246,96 246,97 245,97" style="fill: rgb(51,52,54)" /> - <polygon points="114,316 114,315 130,233 131,232 133,232 134,232 135,232 187,241 188,242 188,245 158,325 157,326 156,326 128,325 117,321 116,320 115,318" style="fill: rgb(172,157,154)" /> - <polygon points="110,342 113,332 116,335 117,336 121,342 129,355 130,358 130,359 130,361 130,362 126,361 121,357 120,356 118,354 117,353 114,349 112,346 111,344" style="fill: rgb(189,187,190)" /> - <polygon points="223,228 228,226 229,231 228,231 227,231 225,230 223,229" style="fill: rgb(81,62,57)" /> - <polygon points="205,162 207,158 215,158 217,159 212,163" style="fill: rgb(74,78,77)" /> - <polygon points="175,8 179,4 178,6" style="fill: rgb(74,78,77)" /> - <polygon points="192,4 193,4 198,6 196,7 193,5" style="fill: rgb(74,84,85)" /> - <polygon points="0,374 2,374 8,374 9,374 12,376 13,377 12,382 7,383 5,383 0,379" style="fill: rgb(135,162,171)" /> - <polygon points="321,382 321,381 322,374 323,369 324,369 324,375 324,378 324,379 324,380 323,381" style="fill: rgb(46,41,40)" /> - <polygon points="369,327 372,325 373,325 373,326 372,327 370,328" style="fill: rgb(125,127,122)" /> - <polygon points="174,58 175,57 177,57 176,58" style="fill: rgb(125,127,122)" /> - <polygon points="358,345 358,344 360,343 361,343 362,343 363,343" style="fill: rgb(135,162,171)" /> - <polygon points="329,191 329,190 329,189 330,186 331,186 332,191 332,195 331,200 330,200 329,193" style="fill: rgb(94,71,72)" /> - <polygon points="250,35 253,34 254,34 253,36 252,36" style="fill: rgb(81,62,57)" /> - <polygon points="214,324 214,323 215,323 216,323 216,324 216,325 215,325 214,325" style="fill: rgb(119,98,95)" /> - <polygon points="70,134 71,132 74,129 75,128 83,127 107,132 109,133 111,134 113,145 112,146 108,149 106,150 103,151 99,152 98,152" style="fill: rgb(189,187,190)" /> - <polygon points="295,381 296,381 299,383 299,386 297,384 296,383 295,382" style="fill: rgb(31,24,23)" /> - <polygon points="224,154 232,148 234,151 231,154 229,155" style="fill: rgb(94,71,72)" /> - <polygon points="158,369 160,364 162,364 163,365 161,367" style="fill: rgb(114,114,116)" /> - <polygon points="349,339 350,339 352,341 354,344 354,345 353,344" style="fill: rgb(189,187,190)" /> - <polygon points="314,342 314,341 315,342 316,344 316,345 315,347 314,343" style="fill: rgb(119,98,95)" /> - <polygon points="347,372 348,373 351,378 360,394 362,399 361,399 356,391 348,376" style="fill: rgb(94,71,72)" /> - <polygon points="396,0 397,0 399,12 399,23 399,25" style="fill: rgb(189,187,190)" /> - <polygon points="105,153 105,152 109,151 124,149 128,149 129,149 130,149 138,157 112,159 111,159 110,159 109,158" style="fill: rgb(113,133,143)" /> - <polygon points="214,181 215,181 223,196 224,200 222,203 221,203 220,203 219,202 218,200 215,194 214,187" style="fill: rgb(119,98,95)" /> - <polygon points="182,48 182,47 182,45 183,46 183,47 183,48" style="fill: rgb(85,92,100)" /> - <polygon points="279,72 282,71 283,71 283,72" style="fill: rgb(53,44,45)" /> - <polygon points="99,339 99,335 100,329 101,324 102,320 103,318 104,317 105,317 106,319 115,337 116,341 116,347 115,348" style="fill: rgb(221,221,223)" /> - <polygon points="327,399 327,397 327,396 328,392 329,393 329,394" style="fill: rgb(67,53,52)" /> - <polygon points="328,44 328,43 328,42 332,42 332,43 329,44" style="fill: rgb(172,157,154)" /> - <polygon points="273,150 276,150 277,150 278,150 288,151 285,151 274,151 273,151" style="fill: rgb(53,44,45)" /> - <polygon points="226,82 227,82 227,83 227,84 226,84" style="fill: rgb(43,43,45)" /> - <polygon points="79,182 80,182 83,185 83,186" style="fill: rgb(221,221,223)" /> - <polygon points="398,39 398,37 398,36 398,35 399,34 399,35 399,36" style="fill: rgb(172,146,145)" /> - <polygon points="346,53 347,57 347,58 346,57" style="fill: rgb(189,187,190)" /> - <polygon points="320,7 320,6 321,6 323,6 323,7 322,9" style="fill: rgb(172,146,145)" /> - <polygon points="306,205 309,195 311,195 312,197 307,204" style="fill: rgb(124,110,110)" /> - <polygon points="243,385 244,385 245,385 246,385 246,386 245,386" style="fill: rgb(137,94,99)" /> - <polygon points="146,273 149,267 150,266 151,266 152,269 151,270 149,272" style="fill: rgb(152,137,134)" /> - <polygon points="383,142 384,142 385,142 386,142 387,142 388,142 389,142 390,142 391,142 392,142" style="fill: rgb(113,83,83)" /> - <polygon points="227,97 227,96 227,95 229,96 228,97" style="fill: rgb(43,43,45)" /> - <polygon points="268,144 269,144 270,144 272,144 273,144 274,144 275,144 274,145 271,145 270,145" style="fill: rgb(53,44,45)" /> - <polygon points="327,3 327,1 327,0 330,0 330,3 329,8 328,10" style="fill: rgb(249,247,254)" /> - <polygon points="298,58 302,57 306,57 307,57 308,57 309,57 310,57 311,57 312,57 305,58" style="fill: rgb(113,83,83)" /> - <polygon points="232,5 237,2 237,5 237,6 237,7 234,8 233,8 232,8" style="fill: rgb(81,62,57)" /> - <polygon points="313,333 316,336 315,335 318,338 317,337 314,334" style="fill: rgb(69,65,62)" /> - <polygon points="97,169 98,168 100,166 101,165 105,163 106,163 107,163 101,168 98,170" style="fill: rgb(189,187,190)" /> - <polygon points="365,143 366,143 368,143 369,143 370,143 371,143 372,143 373,143 374,143 375,143 372,149 368,154 366,150" style="fill: rgb(119,98,95)" /> - <polygon points="251,267 251,266 251,265 252,265 255,265 256,266 256,267 255,267 253,267 252,267" style="fill: rgb(137,94,99)" /> - <polygon points="73,37 73,36 73,35 77,10 78,6 79,3 81,2 87,0 87,42 87,43 81,42 79,41" style="fill: rgb(221,221,223)" /> - <polygon points="328,378 328,377 332,378 335,379 340,387 339,388 336,387 328,381" style="fill: rgb(119,98,95)" /> - <polygon points="95,123 97,123 118,124 132,128 133,129 131,132 119,144 118,144 115,142 95,124" style="fill: rgb(146,140,144)" /> - <polygon points="246,351 246,350 246,349 246,346 246,345 247,345 248,345 249,346 248,349 247,351" style="fill: rgb(67,53,52)" /> - <polygon points="330,39 330,38 331,36 332,36 336,40 336,41 333,45" style="fill: rgb(189,187,190)" /> - <polygon points="153,187 162,188 161,189 160,189 155,189 154,189 153,189" style="fill: rgb(152,137,134)" /> - <polygon points="298,130 300,130 301,131 299,131" style="fill: rgb(81,62,57)" /> - <polygon points="341,391 341,390 342,392 342,395 342,396 342,397 341,399" style="fill: rgb(67,53,52)" /> - <polygon points="297,399 307,362 308,361 308,363 308,364 306,381 303,391 301,397 298,399" style="fill: rgb(31,24,23)" /> - <polygon points="248,162 248,161 253,159 256,159 257,161 251,162 249,162" style="fill: rgb(67,68,70)" /> - <polygon points="327,20 329,20 331,26 331,28 329,28 328,28 327,22" style="fill: rgb(172,157,154)" /> - <polygon points="361,196 362,195 365,193 366,195 365,196 364,197 362,197" style="fill: rgb(114,114,116)" /> - <polygon points="353,389 354,390 356,393 356,396 354,393" style="fill: rgb(46,41,40)" /> - <polygon points="176,267 176,266 178,264 179,264 179,265 178,268 177,268" style="fill: rgb(152,137,134)" /> - <polygon points="178,199 178,198 178,197 179,195 182,195 182,196 179,199" style="fill: rgb(74,84,85)" /> - <polygon points="375,194 376,191 376,195 376,196 376,198" style="fill: rgb(113,83,83)" /> - <polygon points="334,154 335,154 336,155 336,158 334,161 334,155" style="fill: rgb(113,83,83)" /> - <polygon points="115,362 116,363 117,364 143,397 144,399 131,399 130,399 129,397 118,373 116,368 115,365" style="fill: rgb(85,92,100)" /> - <polygon points="208,4 210,4 211,4 212,5 210,7 209,7" style="fill: rgb(67,68,70)" /> - <polygon points="177,278 224,260 230,259 243,262 247,263 248,264 263,283 263,284 263,287 263,288 262,291 257,302 252,312 250,315 245,320 240,324 225,327" style="fill: rgb(137,94,99)" /> - <polygon points="282,399 283,396 284,395 286,396 286,397 286,398" style="fill: rgb(46,41,40)" /> - <polygon points="346,324 352,323 353,323 354,323 354,324 352,327 351,327 348,326 347,325" style="fill: rgb(189,187,190)" /> - <polygon points="81,300 82,300 83,300 88,300 89,300 84,300 85,300 86,300 87,300" style="fill: rgb(221,221,223)" /> - <polygon points="136,235 138,233 139,233 198,234 199,235 189,266 188,267 186,268 182,270 176,273 173,273 172,273 171,273 154,268" style="fill: rgb(172,146,145)" /> - <polygon points="91,268 92,245 94,224 95,217 115,230 103,297 102,298 101,298 98,297 96,295 95,292 91,272" style="fill: rgb(221,221,223)" /> - <polygon points="117,229 118,226 119,226 139,227 139,228 139,229 129,231 122,230" style="fill: rgb(113,133,143)" /> - <polygon points="110,353 110,352 111,353 117,363 115,367 113,368 110,354" style="fill: rgb(114,114,116)" /> - <polygon points="117,357 120,360 127,368 130,372 129,372 128,371 127,370 126,369 124,367 120,362 118,359" style="fill: rgb(146,140,144)" /> - <polygon points="156,281 157,279 160,278 176,278 177,280 168,281" style="fill: rgb(124,110,110)" /> - <polygon points="291,100 293,98 294,98 294,100 293,101 292,101 291,101" style="fill: rgb(46,41,40)" /> - <polygon points="225,75 226,74 230,73 239,72 240,72 255,72 256,72 258,72 259,72 264,72 276,73 283,79 292,102 292,104 288,106 285,107 274,110 263,110 244,109 237,108 230,102" style="fill: rgb(43,43,45)" /> - <polygon points="163,329 169,323 169,324 169,325 166,329 165,330 163,330" style="fill: rgb(175,169,168)" /> - <polygon points="371,178 372,177 373,177 374,179 374,180 373,182 372,181" style="fill: rgb(119,98,95)" /> - <polygon points="137,335 138,334 139,335 139,336 139,337 138,338 137,337" style="fill: rgb(146,140,144)" /> - <polygon points="150,344 158,331 164,333 165,334 166,336 164,345 155,346 154,346" style="fill: rgb(146,140,144)" /> - <polygon points="292,113 293,113 294,113 295,113 296,113 297,113" style="fill: rgb(53,44,45)" /> - <polygon points="247,148 249,147 253,146 259,145 260,147 260,148 258,149" style="fill: rgb(53,44,45)" /> - <polygon points="357,397 357,396 358,396 359,398 359,399 358,398" style="fill: rgb(53,44,45)" /> - <polygon points="94,185 94,184 95,184 96,184 111,205 112,207 115,213 116,218 116,222 115,222 110,220 107,218 106,217 104,215 103,214 101,211 100,209 99,207 94,190" style="fill: rgb(221,221,223)" /> - <polygon points="271,66 275,64 277,63 279,63 281,64 281,65 281,66 281,67 280,68 271,67" style="fill: rgb(51,52,54)" /> - <polygon points="96,36 96,35 96,33 97,35 97,36" style="fill: rgb(189,187,190)" /> - <polygon points="376,322 377,322 381,325 382,326 383,328 381,329 380,329 379,329 378,329" style="fill: rgb(175,169,168)" /> - <polygon points="195,166 196,165 197,166 196,170 195,167" style="fill: rgb(146,140,144)" /> - <polygon points="330,223 330,222 360,224 358,225 354,226 348,227 346,227 345,227 344,227 343,227 341,227 340,227 336,226 333,225 331,224" style="fill: rgb(114,114,116)" /> - <polygon points="137,294 139,290 141,287 179,281 180,281 171,335 169,336 168,336 160,335 156,334 146,326 139,303 137,295" style="fill: rgb(172,146,145)" /> - <polygon points="61,301 72,301 73,301 68,301 69,301 70,301 71,301 64,301 65,301 66,301 67,301 62,301 63,301" style="fill: rgb(221,221,223)" /> - <polygon points="258,15 258,14 258,13 260,10 261,9 261,11 259,15" style="fill: rgb(81,62,57)" /> - <polygon points="260,137 261,135 262,135 265,136 266,137 267,138 263,139 262,139 261,139" style="fill: rgb(67,53,52)" /> - <polygon points="218,12 219,10 222,10 222,11 221,12 220,13" style="fill: rgb(94,71,72)" /> - <polygon points="170,223 171,222 172,221 173,221 173,222 171,223" style="fill: rgb(146,140,144)" /> - <polygon points="119,174 119,173 126,170 136,170 137,171 143,179 143,180 141,180 140,180 120,176" style="fill: rgb(135,162,171)" /> - <polygon points="212,51 212,49 213,50 213,52 212,52 212,49" style="fill: rgb(69,65,62)" /> - <polygon points="306,398 309,356 311,352 312,355 313,366 313,373 312,385 311,391 309,399 306,399" style="fill: rgb(46,41,40)" /> - <polygon points="353,382 354,383 365,398 363,399 362,398 358,392 355,387 354,385" style="fill: rgb(94,71,72)" /> - <polygon points="145,181 150,179 153,178 174,171 175,172 176,174 176,179 176,180 159,188 158,188 147,186 145,182" style="fill: rgb(114,114,116)" /> - <polygon points="315,301 315,296 322,279 324,275 324,276 324,279 324,283 324,284 324,285 319,303 317,303 316,303" style="fill: rgb(189,187,190)" /> - <polygon points="11,338 12,336 21,330 30,326 33,325 34,325 28,330 23,333 16,337 12,338" style="fill: rgb(175,169,168)" /> - <polygon points="320,279 320,278 321,274 323,276 320,280" style="fill: rgb(142,122,123)" /> - <polygon points="271,163 272,163 273,163 278,165 279,166 276,165" style="fill: rgb(81,62,57)" /> - <polygon points="101,387 103,386 104,386 104,390 103,392" style="fill: rgb(126,142,150)" /> - <polygon points="337,167 339,166 341,168 339,170 337,169" style="fill: rgb(53,44,45)" /> - <polygon points="167,364 167,363 170,362 171,362 176,362 177,362 181,364 182,365 182,366 171,375 169,376 168,376" style="fill: rgb(85,92,100)" /> - <polygon points="196,172 197,173 198,174 198,175 197,176 196,173" style="fill: rgb(146,140,144)" /> - <polygon points="277,59 278,59 279,59 281,59 282,59 283,59 284,59 286,59 296,59 299,59 312,60 332,62 335,63 360,78 364,81 366,83 376,94 378,102 378,104 376,111 373,119 370,127 367,131" style="fill: rgb(67,53,52)" /> - <polygon points="160,203 160,202 164,192 165,191 166,190 170,188 176,186 177,186 177,187 177,189 177,191 176,195 175,199 171,208 170,210 169,211 167,212 164,210 160,206" style="fill: rgb(172,157,154)" /> - <polygon points="185,145 185,138 186,138 188,142 188,146 186,147" style="fill: rgb(118,97,99)" /> - <polygon points="166,57 167,57 168,57 169,57 170,57 171,57 172,57 173,57 174,57" style="fill: rgb(114,114,116)" /> - <polygon points="253,153 255,152 260,151 269,150 270,150 271,151 256,153" style="fill: rgb(53,44,45)" /> - <polygon points="171,376 173,370 175,368 176,369 178,372 177,373 172,377" style="fill: rgb(74,84,85)" /> - <polygon points="207,53 208,53 209,53 210,53 211,54 207,54" style="fill: rgb(74,84,85)" /> - <polygon points="375,329 376,328 377,328 378,328 379,328 377,329 376,329" style="fill: rgb(221,221,223)" /> - <polygon points="254,151 255,151 256,151 257,151 258,151 259,151" style="fill: rgb(43,43,45)" /> - <polygon points="117,385 117,384 119,387 125,398 125,399 124,399 122,395 121,393 120,391 119,389 118,387" style="fill: rgb(126,142,150)" /> - <polygon points="328,333 328,332 331,334 331,335 329,336" style="fill: rgb(124,110,110)" /> - <polygon points="225,3 228,0 228,2 227,3" style="fill: rgb(94,71,72)" /> - <polygon points="0,372 5,367 91,309 96,306 98,309 99,311 101,316 101,318 101,319 84,399 1,399 0,399" style="fill: rgb(126,142,150)" /> - <polygon points="316,295 316,294 317,292 318,291 317,296" style="fill: rgb(172,157,154)" /> - <polygon points="130,231 134,230 145,231 136,231" style="fill: rgb(95,115,124)" /> - <polygon points="316,116 322,118 323,119 326,125 326,134 326,136 326,138" style="fill: rgb(81,62,57)" /> - <polygon points="166,360 172,355 183,356 184,357 183,359 173,365 171,364 167,362" style="fill: rgb(118,97,99)" /> - <polygon points="320,300 320,298 320,295 321,294 322,294" style="fill: rgb(188,205,213)" /> - <polygon points="192,378 193,377 194,377 193,380 192,380" style="fill: rgb(113,83,83)" /> - <polygon points="17,377 56,360 59,360 75,367 75,399 21,399 20,399 19,399 18,399 17,398" style="fill: rgb(113,133,143)" /> - <polygon points="352,356 352,355 352,354 353,346 399,378 399,379 399,380 399,381 396,381 364,378 362,377 360,375 359,374 357,371 355,365 353,359" style="fill: rgb(172,157,154)" /> - <polygon points="390,1 390,0 395,0 396,5 398,21 399,31 395,31 393,24" style="fill: rgb(172,157,154)" /> - <polygon points="346,367 347,368 370,398 370,399 369,399 368,399 367,399 366,399 365,399 364,399 356,387 349,373" style="fill: rgb(119,98,95)" /> - <polygon points="200,373 203,366 243,336 290,311 301,317 301,318 299,325 289,337 283,344 275,353 274,354 273,355 259,368 248,375 239,379 226,382 224,382 223,382 222,382" style="fill: rgb(67,53,52)" /> - <polygon points="210,56 211,56 212,56 213,56 214,56 215,56 216,56 217,56 218,56 219,56 220,56 221,56 222,56 223,56 226,56 229,56 230,56 231,56 240,57 232,57 223,57 222,57 221,57" style="fill: rgb(152,137,134)" /> - <polygon points="162,58 163,58 164,58 165,58 166,58 167,58 168,58" style="fill: rgb(126,142,150)" /> - <polygon points="368,158 368,157 368,156 369,156 369,158 368,159" style="fill: rgb(113,83,83)" /> - <polygon points="104,151 112,137 113,137 114,138 123,148 119,149 106,151" style="fill: rgb(135,162,171)" /> - <polygon points="73,174 73,170 73,161 77,159 80,158 83,157 86,156 87,156 90,157 105,162 107,220 99,220 97,218 95,215 74,180 73,176" style="fill: rgb(135,162,171)" /> - <polygon points="345,44 346,37 350,36 355,36 362,36 371,61 366,62 358,60 354,59 347,52 345,45" style="fill: rgb(124,110,110)" /> - <polygon points="333,178 336,177 343,176 344,176 345,176 340,179 337,180 336,180 334,179" style="fill: rgb(146,140,144)" /> - <polygon points="260,356 262,355 262,357 262,358 262,359 260,357" style="fill: rgb(67,53,52)" /> - <polygon points="329,283 329,281 329,275 329,274 330,273 331,272 332,272 333,272 334,272 335,272 346,274 383,282 396,286 399,287 399,311 399,312 398,312 330,286" style="fill: rgb(189,187,190)" /> - <polygon points="158,149 159,149 160,149 161,149 169,150 181,154 188,157 182,158 180,158 177,157 159,150" style="fill: rgb(125,127,122)" /> - <polygon points="309,145 310,145 311,145 312,145 317,146 315,147 313,147" style="fill: rgb(53,44,45)" /> - <polygon points="116,176 116,175 117,170 118,169 119,168 130,159 132,158 135,158 136,158 143,159 142,160 130,169 127,171 119,176 117,176" style="fill: rgb(146,140,144)" /> - <polygon points="109,326 109,325 111,326 115,330 114,332 112,330 111,329" style="fill: rgb(175,169,168)" /> - <polygon points="310,154 311,152 312,151 314,150 315,152 310,155" style="fill: rgb(53,44,45)" /> - <polygon points="354,359 354,358 354,357 356,354 362,355 364,356 394,373 399,376 399,377 397,378 396,378 395,378 379,377 359,365 358,364" style="fill: rgb(175,169,168)" /> - <polygon points="70,49 72,44 72,48 71,50" style="fill: rgb(189,187,190)" /> - <polygon points="171,210 174,203 175,203 173,207 172,209" style="fill: rgb(189,187,190)" /> - <polygon points="327,382 327,380 327,379 330,383 329,383" style="fill: rgb(113,83,83)" /> - <polygon points="94,14 95,13 97,12 97,14 96,14" style="fill: rgb(188,205,213)" /> - <polygon points="237,380 241,378 243,377 251,373 253,372 250,375 241,381 240,381" style="fill: rgb(81,62,57)" /> - <polygon points="206,164 207,164 208,164 209,164 210,164 214,165 211,165" style="fill: rgb(74,84,85)" /> - <polygon points="337,334 340,336 351,344 399,382 399,397 399,398 399,399 383,399 378,395 375,392 373,390 372,389 368,385 358,374 356,371 354,368 353,366" style="fill: rgb(172,146,145)" /> - <polygon points="316,389 316,388 316,387 317,371 318,370 318,375 318,377 318,379 317,388" style="fill: rgb(113,83,83)" /> - <polygon points="120,158 121,158 122,158 123,158 124,158 125,158 126,158 127,158 128,158 129,158 125,160 123,160 122,160 121,160" style="fill: rgb(135,162,171)" /> - <polygon points="111,332 112,331 118,339 119,345 119,347 119,348 117,349 116,348 111,333" style="fill: rgb(221,221,223)" /> - <polygon points="376,116 376,115 381,99 382,96 399,114 399,123 399,128 396,129 383,125 376,117" style="fill: rgb(119,98,95)" /> - <polygon points="327,176 329,176 330,176 331,178 331,179 328,182 327,179" style="fill: rgb(81,62,57)" /> - <polygon points="335,332 337,333 339,334 345,337 349,341 350,342 352,344 350,349" style="fill: rgb(172,157,154)" /> - <polygon points="147,230 168,223 167,224 166,225 162,227 159,228 156,229 150,230" style="fill: rgb(85,92,100)" /> - <polygon points="246,355 249,352 249,353 248,356 247,356" style="fill: rgb(67,53,52)" /> - <polygon points="236,231 237,230 238,229 239,228 238,230 237,232 236,232" style="fill: rgb(81,62,57)" /> - <polygon points="44,100 44,97 44,96 45,92 88,0 91,0 95,0 98,0 103,0 107,0 108,0 111,0 115,0 118,0 120,0 122,7 122,8 122,10 114,64 101,128 100,131 55,159 53,158 50,147 44,118" style="fill: rgb(135,162,171)" /> - <polygon points="311,398 311,397 311,396 311,395 312,344 313,343 314,346 316,360 316,373 316,374 316,377 316,379 314,393 312,399" style="fill: rgb(67,53,52)" /> - <polygon points="205,168 205,166 206,165 207,165 214,180 212,180" style="fill: rgb(119,98,95)" /> - <polygon points="96,391 97,390 98,391 98,392 96,392" style="fill: rgb(126,142,150)" /> - <polygon points="211,310 211,309 213,303 214,301 215,301 219,302 222,303 222,305 222,310 221,312 219,313 218,313 217,313 216,313" style="fill: rgb(113,83,83)" /> - <polygon points="331,54 331,53 332,51 333,52 334,53 334,54 333,57" style="fill: rgb(175,169,168)" /> - <polygon points="323,342 324,335 325,335 325,340 325,343 324,345 323,343" style="fill: rgb(69,65,62)" /> - <polygon points="312,1 312,0 315,0 314,1 312,3 312,0 315,0 314,1 312,3 312,0" style="fill: rgb(142,122,123)" /> - <polygon points="63,173 65,174 66,176 65,177" style="fill: rgb(189,187,190)" /> - <polygon points="384,220 390,218 389,219 387,220" style="fill: rgb(152,137,134)" /> - <polygon points="307,164 308,160 310,163 311,166 310,168" style="fill: rgb(67,53,52)" /> - <polygon points="326,331 327,330 328,330 329,330 332,333 332,339 330,337" style="fill: rgb(125,127,122)" /> - <polygon points="322,201 323,201 324,201 324,203 323,203" style="fill: rgb(142,122,123)" /> - <polygon points="272,4 272,3 273,3 277,6 277,7 276,7 272,5" style="fill: rgb(67,53,52)" /> - <polygon points="122,142 124,141 125,141 127,142 125,142 124,142" style="fill: rgb(146,140,144)" /> - <polygon points="195,24 195,23 196,22 198,22 198,24" style="fill: rgb(85,92,100)" /> - <polygon points="171,85 171,84 172,84 173,85 172,86 171,86" style="fill: rgb(74,84,85)" /> - <polygon points="200,365 201,363 219,351 242,338 242,345 236,355 227,369 205,367" style="fill: rgb(81,62,57)" /> - <polygon points="71,60 72,50 73,40 74,39 77,47 77,49 75,56 71,64" style="fill: rgb(249,247,254)" /> - <polygon points="47,315 48,313 50,312 48,315" style="fill: rgb(175,169,168)" /> - <polygon points="165,152 171,154 179,158 176,158 166,153" style="fill: rgb(114,114,116)" /> - <polygon points="126,187 126,186 130,178 135,181 157,195 159,198 159,199 144,224 135,224" style="fill: rgb(172,157,154)" /> - <polygon points="188,229 189,228 190,234 188,233" style="fill: rgb(137,94,99)" /> - <polygon points="145,224 152,215 153,214 167,214 162,219 157,222 154,223 150,224" style="fill: rgb(146,140,144)" /> - <polygon points="260,267 262,267 263,268 264,269 265,270 265,271 264,271 260,268" style="fill: rgb(67,53,52)" /> - <polygon points="189,54 190,52 192,51 193,52 192,55 190,55" style="fill: rgb(74,78,77)" /> - <polygon points="329,259 329,256 329,255 329,254 331,249 349,249 370,250 399,256 399,269 399,270 399,271 397,271 396,271 395,271 329,261" style="fill: rgb(172,157,154)" /> - <polygon points="313,8 313,7 313,6 321,0 321,28 320,42 319,40 318,36 315,21 313,9" style="fill: rgb(152,137,134)" /> - <polygon points="200,29 200,28 201,27 204,27 205,28 201,29" style="fill: rgb(67,68,70)" /> - <polygon points="174,349 174,348 177,341 178,341 178,342 177,345" style="fill: rgb(124,110,110)" /> - <polygon points="325,372 325,370 325,368 326,374 326,375 326,378 326,379 325,373 325,370 325,368 326,374 326,375" style="fill: rgb(67,53,52)" /> - <polygon points="333,364 333,362 337,362 338,362 341,365 345,372 350,383 357,399 356,399 352,399 345,399 344,399" style="fill: rgb(40,30,30)" /> - <polygon points="249,48 252,46 261,44 260,48 256,51 251,50 249,49" style="fill: rgb(67,53,52)" /> - <polygon points="321,4 324,4 324,5 322,6 321,5" style="fill: rgb(172,157,154)" /> - <polygon points="278,223 279,223 281,223 282,224 280,224" style="fill: rgb(53,44,45)" /> - <polygon points="107,383 109,381 111,385 111,386 111,387 110,387 109,386" style="fill: rgb(175,169,168)" /> - <polygon points="195,379 196,377 197,377 197,378 197,379 196,380 195,380" style="fill: rgb(113,83,83)" /> - <polygon points="198,0 199,0 200,0 206,0 207,2 208,5 208,6 203,5 201,4 200,3" style="fill: rgb(67,68,70)" /> - <polygon points="170,56 173,55 178,56" style="fill: rgb(74,84,85)" /> - <polygon points="300,59 303,58 341,61 344,62 379,83 380,84 382,87 382,90 381,97 380,101 379,103" style="fill: rgb(81,62,57)" /> - <polygon points="0,0 2,0 3,0 4,0 5,0 6,0 7,0 8,0 9,0 10,0 11,0 12,0 13,0 14,0 15,0 16,0 18,2 19,3 20,4 21,5 40,27 72,72 69,73 66,74 62,75 61,75 57,74 13,26 4,16 0,11" style="fill: rgb(221,221,223)" /> - <polygon points="213,283 214,281 218,281 220,282 220,284 219,285 217,287 214,285" style="fill: rgb(124,110,110)" /> - <polygon points="184,284 184,283 185,282 186,283 185,285 184,285" style="fill: rgb(175,169,168)" /> - <polygon points="164,342 165,337 189,294 197,282 198,282 199,283 200,284 206,318 206,319 206,322 206,327 206,328 206,329 206,330 205,331 195,341 173,345 164,346" style="fill: rgb(172,146,145)" /> - <polygon points="244,55 245,54 247,53 248,55" style="fill: rgb(81,62,57)" /> - <polygon points="315,329 316,329 317,329 318,329 319,329 321,331" style="fill: rgb(125,127,122)" /> - <polygon points="219,234 220,233 223,232 223,236 222,236" style="fill: rgb(137,94,99)" /> - <polygon points="206,26 207,25 208,25 208,26 207,27" style="fill: rgb(74,84,85)" /> - <polygon points="206,277 227,275 228,275 235,276 233,277 231,278 224,278 215,278 214,278 213,278 212,278 211,278 210,278 209,278 208,278" style="fill: rgb(94,71,72)" /> - <polygon points="160,354 160,353 161,351 162,351 161,353" style="fill: rgb(125,127,122)" /> - <polygon points="311,13 311,12 311,9 312,8 313,13 313,14 313,15" style="fill: rgb(119,98,95)" /> - <polygon points="0,319 1,318 3,317 7,316 10,316 11,316 12,316 1,319" style="fill: rgb(221,221,223)" /> - <polygon points="268,141 268,140 269,140 274,141 274,142 271,142 270,142" style="fill: rgb(81,62,57)" /> - <polygon points="299,157 302,158 303,159 304,160 301,159" style="fill: rgb(113,83,83)" /> - <polygon points="281,89 281,88 290,89 291,93 287,96 286,96 281,90" style="fill: rgb(46,41,40)" /> - <polygon points="170,204 170,203 175,200 174,206 173,208 172,207 171,206 170,205" style="fill: rgb(175,169,168)" /> - <polygon points="320,48 320,46 324,43 325,43 325,44 321,49" style="fill: rgb(142,122,123)" /> - <polygon points="225,197 225,196 226,198 227,201 226,200" style="fill: rgb(94,71,72)" /> - <polygon points="298,33 299,33 300,35 299,35 298,34" style="fill: rgb(94,71,72)" /> - <polygon points="149,288 149,287 151,275 198,169 199,167 200,166 202,166 207,177 208,180 215,201 216,205 217,211 223,262 222,263 211,270 202,274 154,288 150,289" style="fill: rgb(94,71,72)" /> - <polygon points="9,98 26,84 38,81 43,80 44,80 45,80 46,80 47,80 61,183 60,182 54,176 52,174 40,159 34,151 22,134 19,129 15,121 11,109 9,102" style="fill: rgb(188,205,213)" /> - <polygon points="223,3 225,5 226,6 225,7 224,7 223,7" style="fill: rgb(74,78,77)" /> - <polygon points="247,110 248,110 249,110 250,110 291,113 299,114 307,115 313,116 312,117 283,119 282,119 256,116" style="fill: rgb(67,53,52)" /> - <polygon points="238,216 245,217 262,225 259,225 258,225 252,224 246,222 240,218 239,217" style="fill: rgb(67,53,52)" /> - <polygon points="325,53 326,45 327,43 331,44 331,52 328,53 327,53 326,53" style="fill: rgb(152,137,134)" /> - <polygon points="333,154 333,158 333,153 333,157 333,156 333,152 333,155 333,159 333,151" style="fill: rgb(67,53,52)" /> - <polygon points="322,267 323,265 324,264 324,267 324,268 323,271 322,268" style="fill: rgb(152,137,134)" /> - <polygon points="227,200 227,199 228,201 229,203 229,205" style="fill: rgb(67,53,52)" /> - <polygon points="261,143 263,142 265,142 264,143" style="fill: rgb(94,71,72)" /> - <polygon points="62,164 62,163 63,163 64,163 65,164 66,165 68,168 68,169 67,170 65,170 64,169 63,168" style="fill: rgb(189,187,190)" /> - <polygon points="52,36 60,44 60,45" style="fill: rgb(188,205,213)" /> - <polygon points="305,208 310,188 311,186 312,186 313,190 313,192 312,196 311,199 310,202 309,204 307,207 306,208" style="fill: rgb(124,110,110)" /> - <polygon points="258,398 297,358 297,359 297,360 296,366 292,376 291,378 283,393 280,397 279,398 278,399 266,399 259,399 258,399" style="fill: rgb(81,62,57)" /> - <polygon points="227,39 228,40 229,41 227,42" style="fill: rgb(67,53,52)" /> - <polygon points="65,358 67,351 70,346 85,330 93,325 96,324 98,324 98,325 97,328 74,363 72,364 71,364 69,363 66,361 65,360" style="fill: rgb(135,162,171)" /> - <polygon points="61,305 65,303 92,301 93,301 94,301 95,302 80,305 72,306 63,307 62,307 61,307" style="fill: rgb(175,169,168)" /> - <polygon points="228,395 228,393 228,392 229,391 233,390 235,390 230,396 229,396" style="fill: rgb(137,94,99)" /> - <polygon points="213,168 213,166 214,166 216,167 217,169 223,190 224,194 222,194 220,189 217,181 216,178" style="fill: rgb(113,83,83)" /> - <polygon points="158,336 162,337 162,338 162,341 162,342 162,345 162,347 162,348 161,348 160,348 158,348 158,347" style="fill: rgb(152,137,134)" /> - <polygon points="160,358 160,356 162,353 164,351 168,352 169,359 169,360 162,359" style="fill: rgb(124,110,110)" /> - <polygon points="328,387 331,387 335,388 338,391 340,395 340,399 338,399 336,399 333,399 332,398" style="fill: rgb(124,110,110)" /> - <polygon points="256,218 268,215 281,219 280,220 272,221 267,221 263,221 261,221" style="fill: rgb(94,71,72)" /> - <polygon points="304,322 304,321 306,324 307,326 308,328 309,330 308,329 305,324" style="fill: rgb(94,71,72)" /> - <polygon points="158,29 158,28 159,29 159,30 159,31 158,30" style="fill: rgb(95,115,124)" /> - <polygon points="316,332 317,332 318,332 319,334 318,334" style="fill: rgb(85,92,100)" /> - <polygon points="325,146 326,140 329,135 330,134 331,137 332,140 330,142 328,144" style="fill: rgb(67,53,52)" /> - <polygon points="31,357 36,357 34,358" style="fill: rgb(135,162,171)" /> - <polygon points="144,328 145,327 148,325 150,328 150,329 148,329 147,329 146,329" style="fill: rgb(172,157,154)" /> - <polygon points="303,55 304,51 305,51 305,54 303,56" style="fill: rgb(94,71,72)" /> - <polygon points="212,43 214,44 215,45 213,45 212,44" style="fill: rgb(69,65,62)" /> - <polygon points="93,359 93,358 93,357 93,356 93,355 93,354 93,361 93,360" style="fill: rgb(126,142,150)" /> - <polygon points="310,323 310,321 311,320 322,312 322,313 322,316 322,317 322,320 322,321 321,325 320,325 319,325 314,324" style="fill: rgb(249,247,254)" /> - <polygon points="103,31 103,30 104,30 104,32 103,32" style="fill: rgb(126,142,150)" /> - <polygon points="162,300 162,298 163,296 167,289 170,289 176,291 178,293 178,294 173,311 172,311 164,307 163,306 162,304" style="fill: rgb(175,169,168)" /> - <polygon points="325,300 325,299 326,299 326,302 326,303 325,302" style="fill: rgb(51,52,54)" /> - <polygon points="320,271 320,270 324,206 325,205 329,217 329,218 329,240 328,249 327,254 321,272" style="fill: rgb(137,94,99)" /> - <polygon points="318,352 318,351 319,351 321,353 321,356 320,356 319,355" style="fill: rgb(94,71,72)" /> - <polygon points="232,59 233,59 234,59 235,59 236,59 237,59 238,59" style="fill: rgb(81,62,57)" /> - <polygon points="0,346 5,325 7,321 51,305 57,303 61,302 79,301 88,301 89,301 90,301 91,301 0,360" style="fill: rgb(135,162,171)" /> - <polygon points="276,144 277,143 288,143 289,143 290,143 291,143 292,143 293,143 294,143 295,143 277,144" style="fill: rgb(53,44,45)" /> - <polygon points="125,346 128,349 129,350 131,352 130,352 129,351 127,349" style="fill: rgb(172,157,154)" /> - <polygon points="152,354 155,352 156,353 153,356" style="fill: rgb(124,110,110)" /> - <polygon points="203,55 204,55 205,55 206,55 207,55 208,55" style="fill: rgb(94,71,72)" /> - <polygon points="339,384 340,380 341,380 341,382 341,383 340,384" style="fill: rgb(113,83,83)" /> - <polygon points="259,59 260,59 261,59 262,59 263,59 264,59" style="fill: rgb(69,65,62)" /> - <polygon points="122,379 122,378 124,381 124,383" style="fill: rgb(74,84,85)" /> - <polygon points="217,165 219,166 219,168 219,169 218,169 217,166" style="fill: rgb(74,84,85)" /> - <polygon points="304,332 305,331 306,331 307,332 308,334 311,346 311,348 311,350 310,348" style="fill: rgb(53,44,45)" /> - <polygon points="33,102 34,93 39,84 42,82 44,81 51,79 53,79 105,138 105,141 104,147 66,187 55,176 54,175 50,167 42,148 41,145 35,122 33,103" style="fill: rgb(135,162,171)" /> - <polygon points="330,224 360,225 360,229 349,237 346,238 343,238 342,238 341,238 340,238 339,238 338,238 337,238 335,238 334,238 333,238 332,237 331,232" style="fill: rgb(146,140,144)" /> - <polygon points="328,399 328,397 328,396 329,395 329,397" style="fill: rgb(94,71,72)" /> - <polygon points="250,42 253,39 255,42 255,43 251,43 250,43" style="fill: rgb(81,62,57)" /> - <polygon points="125,318 126,317 127,317 127,320 126,319" style="fill: rgb(175,169,168)" /> - <polygon points="117,355 132,354 133,355 134,356 135,357 136,358 137,359 138,360 150,373 149,373 137,372 131,371 123,363 122,362 121,361 118,357" style="fill: rgb(175,169,168)" /> - <polygon points="310,331 311,330 312,330 313,330 314,331 312,332 311,332" style="fill: rgb(119,98,95)" /> - <polygon points="39,320 41,317 44,316 43,317 40,320" style="fill: rgb(175,169,168)" /> - <polygon points="290,336 292,332 295,330 296,330 294,333 293,334 292,335" style="fill: rgb(94,71,72)" /> - <polygon points="278,79 278,75 279,74 284,74 288,75 288,79 281,80 280,80" style="fill: rgb(46,41,40)" /> - <polygon points="178,369 181,367 180,372 179,373" style="fill: rgb(67,68,70)" /> - <polygon points="299,399 304,333 305,333 306,334 308,338 310,349 311,364 311,372 311,377 311,378 310,386 308,397 305,399" style="fill: rgb(40,30,30)" /> - <polygon points="300,8 300,7 300,6 300,5 301,6 301,8" style="fill: rgb(81,62,57)" /> - <polygon points="118,329 118,327 119,327 120,328 120,330" style="fill: rgb(125,127,122)" /> - <polygon points="329,284 398,307 399,308 399,310 398,311 385,311 353,303 332,297 330,296 329,289" style="fill: rgb(188,205,213)" /> - <polygon points="310,328 311,327 312,327 313,328 311,329" style="fill: rgb(125,127,122)" /> - <polygon points="298,293 299,293 300,293 302,294 303,295 303,299 303,300 301,299 298,296" style="fill: rgb(137,94,99)" /> - <polygon points="71,142 72,138 74,137 76,136 78,136 84,137 97,144 97,150 94,152 92,153 89,154 88,154 72,150 71,147" style="fill: rgb(221,221,223)" /> - <polygon points="216,30 217,29 219,29 220,30 221,32 218,32" style="fill: rgb(67,68,70)" /> - <polygon points="353,225 354,223 355,223 356,223 357,224 354,225" style="fill: rgb(124,110,110)" /> - <polygon points="300,114 307,112 308,112 311,114 312,115 311,116" style="fill: rgb(46,41,40)" /> - <polygon points="326,231 326,230 329,224 398,213 399,213 399,217 399,250 399,251 399,254 399,255 398,255 397,255 396,255 395,255 394,255 393,255 392,255 391,255 328,253 327,243" style="fill: rgb(152,137,134)" /> - <polygon points="95,191 95,190 95,189 95,188 98,193 101,198 102,204 101,207 100,207 99,206 98,204 97,201 96,198 95,194 95,193 95,192 95,189 95,188 98,193 101,198 102,204 101,207 100,207 99,206 98,204 97,201 96,198 95,194 95,193 95,192 95,189 95,188 98,193 101,198 102,204 101,207 100,207 99,206 98,204 97,201 96,198 95,194 95,193 95,192 95,189 95,188 98,193 101,198 102,204 101,207 100,207 99,206 98,204 97,201 96,198 95,194 95,193 95,192 95,189 95,188" style="fill: rgb(249,247,254)" /> - <polygon points="208,372 209,371 211,371 210,372" style="fill: rgb(81,62,57)" /> - <polygon points="22,135 24,136 37,155 39,158 36,155 33,151 24,138" style="fill: rgb(221,221,223)" /> - <polygon points="328,221 329,219 330,220 330,221 329,222" style="fill: rgb(124,110,110)" /> - <polygon points="157,120 158,117 159,116 160,115 168,115 169,115 172,115 173,115 180,118 186,121 188,122 194,129 202,149 203,154 203,155 202,155 178,153 175,152" style="fill: rgb(124,110,110)" /> - <polygon points="340,388 342,381 342,387 341,388" style="fill: rgb(94,71,72)" /> - <polygon points="300,190 300,189 302,184 306,175 308,172 309,173 309,178 309,179 305,192 301,193 300,193" style="fill: rgb(119,98,95)" /> - <polygon points="242,227 242,226 243,226 244,227 243,228" style="fill: rgb(81,62,57)" /> - <polygon points="168,70 175,62 177,61 183,60 186,60 187,60 188,60 188,63 188,64 177,70" style="fill: rgb(74,78,77)" /> - <polygon points="302,99 303,98 306,99" style="fill: rgb(46,41,40)" /> - <polygon points="305,319 321,292 322,292 323,292 323,308 323,309 323,310 320,324 309,324 307,323" style="fill: rgb(221,221,223)" /> - <polygon points="124,174 133,163 135,162 137,161 147,158 149,158 150,158 151,158 155,159 157,160 149,179 148,180 144,182" style="fill: rgb(113,133,143)" /> - <polygon points="116,357 117,358 130,375 135,382 136,384 133,382 122,368 117,359" style="fill: rgb(125,127,122)" /> - <polygon points="314,15 315,22 315,23 315,24 314,21" style="fill: rgb(124,110,110)" /> - <polygon points="233,27 233,26 235,24 236,25 236,26 234,29 233,28" style="fill: rgb(67,53,52)" /> - <polygon points="295,324 297,324 296,326 295,326" style="fill: rgb(53,44,45)" /> - <polygon points="165,112 168,111 176,111 181,112 185,113 197,121 211,148 211,149 208,153 207,154 205,155 204,155 190,142 165,115" style="fill: rgb(124,110,110)" /> - <polygon points="108,176 114,171 118,178 112,182 109,183 108,177" style="fill: rgb(172,157,154)" /> - <polygon points="115,372 115,371 116,369 130,394 130,395 129,399 128,399 127,398 126,397 116,377" style="fill: rgb(95,115,124)" /> - <polygon points="239,139 240,134 241,133 268,126 279,124 283,124 285,125 291,131 294,135 294,142 275,143 241,142" style="fill: rgb(67,53,52)" /> - <polygon points="292,377 293,373 294,371 294,372 293,376" style="fill: rgb(67,53,52)" /> - <polygon points="320,393 321,394 322,395 322,396 322,399 320,399" style="fill: rgb(67,53,52)" /> - <polygon points="231,2 233,0 234,0 239,0 240,0 250,0 252,3 248,6 244,8 236,9 235,9 232,4" style="fill: rgb(81,62,57)" /> - <polygon points="140,162 141,161 142,161 143,161 144,161 145,161 146,161 147,161 145,162 144,162" style="fill: rgb(125,127,122)" /> - <polygon points="208,386 210,385 217,384 221,384 221,386 215,390 214,390" style="fill: rgb(94,71,72)" /> - <polygon points="232,45 232,41 233,42 233,43" style="fill: rgb(67,68,70)" /> - <polygon points="312,37 314,40 314,41 312,40 312,39" style="fill: rgb(94,71,72)" /> - <polygon points="123,60 123,59 125,44 127,31 129,25 138,4 140,0 143,0 151,0 154,5 158,18 160,54 160,55 158,57 131,60" style="fill: rgb(95,115,124)" /> - <polygon points="198,263 199,264 200,265 200,266 199,266 198,265" style="fill: rgb(152,137,134)" /> - <polygon points="336,372 337,370 338,371 339,373 339,374" style="fill: rgb(113,83,83)" /> - <polygon points="207,111 209,110 216,110 217,110 218,110 219,110 220,110 221,110 222,110 224,110 227,110 228,110 229,110 230,110 231,110 249,116 263,123 246,147 243,148 227,149 226,149 224,148 223,147" style="fill: rgb(113,83,83)" /> - <polygon points="211,41 211,40 213,40 216,42 216,43 215,43 214,43 212,42" style="fill: rgb(74,78,77)" /> - <polygon points="185,36 186,34 191,33 193,36 191,41 186,39 185,37" style="fill: rgb(74,84,85)" /> - <polygon points="262,366 264,364 266,363 265,364 263,366" style="fill: rgb(81,62,57)" /> - <polygon points="252,60 253,60 254,60 255,60 290,60 315,62 341,78 360,98 368,107 370,113 369,125 368,128 366,132 363,138 359,145" style="fill: rgb(53,44,45)" /> - <polygon points="38,10 42,14 41,13 43,15 39,11 40,12" style="fill: rgb(188,205,213)" /> - <polygon points="319,389 319,387 321,386 323,386 326,391 326,392 324,392 322,391 320,390" style="fill: rgb(40,30,30)" /> - <polygon points="136,232 149,231 152,231 153,231 154,231 153,243 151,243 144,238" style="fill: rgb(152,137,134)" /> - <polygon points="239,3 239,2 241,0 243,0 247,0 248,0 248,1 245,4 242,5 241,5" style="fill: rgb(81,62,57)" /> - <polygon points="188,195 190,184 191,185 191,187 191,189 189,194" style="fill: rgb(142,122,123)" /> - <polygon points="238,354 238,353 239,353 241,353 242,353 242,354 241,354 239,354" style="fill: rgb(67,53,52)" /> - <polygon points="330,55 332,55 332,56 332,57 330,56" style="fill: rgb(172,157,154)" /> - <polygon points="261,155 262,154 266,153 277,153 282,153 284,153 296,159 301,165 300,167 299,168 294,170" style="fill: rgb(113,83,83)" /> - <polygon points="330,329 333,328 334,328 335,328 348,330 347,336 346,336 343,335 332,330" style="fill: rgb(189,187,190)" /> - <polygon points="302,17 304,19 305,22 304,21" style="fill: rgb(113,83,83)" /> - <polygon points="306,37 309,32 310,32 312,33 312,34 310,40 307,38" style="fill: rgb(113,83,83)" /> - <polygon points="326,4 326,3 326,1 326,0 331,0 331,4 330,10 327,13 326,7" style="fill: rgb(221,221,223)" /> - <polygon points="198,376 198,375 199,374 204,373 214,373 215,373 210,376 199,376" style="fill: rgb(81,62,57)" /> - <polygon points="290,0 295,0 303,0 305,0 307,3 308,5 309,8 317,55 316,57 314,57 313,57 310,55 291,21" style="fill: rgb(94,71,72)" /> - <polygon points="95,301 95,300 108,254 115,233 117,232 121,231 122,231 126,232 127,234 134,260 132,285 126,305 114,308 113,308 112,308 103,308 102,308" style="fill: rgb(189,187,190)" /> - <polygon points="189,179 189,171 189,170 189,167 194,166 195,168 196,171 197,174 197,175 195,180 192,180" style="fill: rgb(172,146,145)" /> - <polygon points="42,308 44,307 49,305 50,305 48,306 46,307 43,308" style="fill: rgb(221,221,223)" /> - <polygon points="106,311 107,311 109,312 109,313 107,315 106,312" style="fill: rgb(146,140,144)" /> - <polygon points="304,398 304,397 304,394 305,394 306,395" style="fill: rgb(40,30,30)" /> - <polygon points="218,62 219,62 220,62 222,62 221,63 219,63 218,63" style="fill: rgb(67,68,70)" /> - <polygon points="326,275 327,275 327,276 327,279 326,276" style="fill: rgb(69,65,62)" /> - <polygon points="102,214 106,218 103,215 107,219 104,216 105,217" style="fill: rgb(189,187,190)" /> - <polygon points="196,24 197,22 199,19 200,19 208,22 208,23 203,26 198,25" style="fill: rgb(74,78,77)" /> - <polygon points="282,211 282,209 283,207 308,182 309,183 310,185 309,194 308,199 307,202 303,208 302,209 291,215 290,215 289,215 288,215 286,215" style="fill: rgb(137,94,99)" /> - <polygon points="326,191 326,183 326,182 326,181 327,187 327,191 327,192 327,193 326,192 326,184 326,183 326,182 326,181 327,187 327,191 327,192" style="fill: rgb(113,83,83)" /> - <polygon points="86,30 87,28 93,33 93,34 93,35 92,37 87,32" style="fill: rgb(135,162,171)" /> - <polygon points="70,372 73,369 76,368 79,368 80,382 78,382 75,381" style="fill: rgb(135,162,171)" /> - <polygon points="279,399 281,394 290,379 291,379 288,386 282,398 280,399" style="fill: rgb(81,62,57)" /> - <polygon points="266,220 267,220 268,220 269,220 270,220 271,220 272,220 273,220 274,220" style="fill: rgb(113,83,83)" /> - <polygon points="189,172 190,170 191,170 192,170 193,171 190,174" style="fill: rgb(172,157,154)" /> - <polygon points="365,222 366,221 371,218 395,207 399,206 399,211 399,212 397,215 369,223" style="fill: rgb(142,122,123)" /> - <polygon points="330,50 330,49 330,47 331,45 333,49" style="fill: rgb(172,157,154)" /> - <polygon points="328,388 329,389 332,394 332,395 331,399 329,399" style="fill: rgb(113,83,83)" /> - <polygon points="316,21 316,10 319,6 320,5 322,8 326,19 328,38 329,52 329,55 328,57 325,57 324,57 323,57 322,55 321,50 320,45" style="fill: rgb(152,137,134)" /> - <polygon points="193,47 194,45 203,37 205,36 225,32 229,36 227,46 225,47 214,52 202,53 198,53 197,53" style="fill: rgb(74,78,77)" /> - <polygon points="342,358 343,357 347,364 348,366 350,371 349,370 348,369 346,366" style="fill: rgb(119,98,95)" /> - <polygon points="185,156 191,152 194,153 193,155 188,156" style="fill: rgb(142,122,123)" /> - <polygon points="258,224 260,222 263,222 268,222 269,222 276,223 269,225 263,225" style="fill: rgb(53,44,45)" /> - <polygon points="97,303 127,232 130,232 131,233 132,234 150,258 151,260 151,262 138,309 136,313 106,315 102,314 101,312 97,304" style="fill: rgb(189,187,190)" /> - <polygon points="245,147 246,145 250,144 251,144 251,145" style="fill: rgb(74,78,77)" /> - <polygon points="333,248 333,247 342,244 354,245 355,246 355,249 353,249 348,249 347,249 337,249" style="fill: rgb(146,140,144)" /> - <polygon points="194,233 196,231 201,229 202,230 203,231 203,232 202,233" style="fill: rgb(142,122,123)" /> - <polygon points="335,358 336,355 338,356 340,357 341,359 340,359" style="fill: rgb(51,52,54)" /> - <polygon points="322,167 322,166 323,166 324,166 325,166 325,168" style="fill: rgb(43,43,45)" /> - <polygon points="239,165 246,157 247,156 248,156 249,156 253,157 267,162 273,167 274,168 265,174 252,175 251,175 239,168" style="fill: rgb(51,52,54)" /> - <polygon points="38,16 39,15 43,19 44,20 45,21 43,22" style="fill: rgb(188,205,213)" /> - <polygon points="329,17 329,16 329,15 331,5 332,0 340,31 344,49 344,52 344,57 343,57 342,57 341,57 338,49" style="fill: rgb(221,221,223)" /> - <polygon points="302,367 306,368 306,369 305,375 303,373 302,369" style="fill: rgb(31,24,23)" /> - <polygon points="310,178 310,177 312,177 312,178 312,179 312,180 311,182 310,181" style="fill: rgb(94,71,72)" /> - <polygon points="319,381 320,369 321,368 323,378 323,379 322,383 321,384 320,384 319,382" style="fill: rgb(30,25,21)" /> - <polygon points="268,286 269,286 270,286 271,287 271,291 270,291 269,291 268,288" style="fill: rgb(81,62,57)" /> - <polygon points="158,80 158,75 163,66 167,62 175,61 176,61 178,63 180,67 181,72 176,109 167,109 166,109 165,109 164,109 163,108 161,105 160,102" style="fill: rgb(74,84,85)" /> - <polygon points="250,55 253,52 261,52 261,53 258,55 257,55 256,55" style="fill: rgb(67,53,52)" /> - <polygon points="304,357 305,356 306,355 306,362 304,358" style="fill: rgb(31,24,23)" /> - <polygon points="310,184 313,167 314,172 314,182 314,183 314,184 314,185 314,186 314,187 313,189 310,187" style="fill: rgb(124,110,110)" /> - <polygon points="326,362 326,360 327,361 330,364 336,370 337,371 339,375 340,379 340,385 340,386 337,387 335,386 334,385 329,379 328,376" style="fill: rgb(119,98,95)" /> - <polygon points="103,311 104,309 105,310 106,314" style="fill: rgb(135,162,171)" /> - <polygon points="250,274 256,272 257,272 258,272 259,272 260,272 266,273 267,274 266,275 265,276 262,277 261,277" style="fill: rgb(94,71,72)" /> - <polygon points="183,279 184,279 185,279 186,279 187,279 188,279 189,279 190,279 191,279 192,279 193,279 196,279 203,280 207,281 208,282 210,284 212,317 212,319 212,320 207,329 195,309" style="fill: rgb(152,137,134)" /> - <polygon points="279,9 281,7 282,7 283,8 283,9 282,10" style="fill: rgb(67,53,52)" /> - <polygon points="200,157 204,156 224,155 226,155 227,155 228,155 228,156 220,181 201,163" style="fill: rgb(74,84,85)" /> - <polygon points="229,35 237,33 238,33 237,37 231,36" style="fill: rgb(67,53,52)" /> - <polygon points="98,221 99,222 100,223 101,224 102,225 98,223" style="fill: rgb(221,221,223)" /> - <polygon points="48,41 50,41 50,42 49,42 48,42" style="fill: rgb(221,221,223)" /> - <polygon points="90,395 91,389 93,388 94,389 97,399 96,399 92,399 91,399" style="fill: rgb(85,92,100)" /> - <polygon points="69,69 70,66 75,59 76,62 76,63 75,66 73,68 70,70" style="fill: rgb(249,247,254)" /> - <polygon points="362,223 376,208 377,207 390,195 393,194 397,193 399,194 399,205 395,209 374,218" style="fill: rgb(125,127,122)" /> - <polygon points="136,144 137,144 138,144 139,144 140,144 142,144 143,144 145,145 145,146 144,146 143,146 138,145" style="fill: rgb(125,127,122)" /> - <polygon points="342,58 345,50 345,52 345,58" style="fill: rgb(249,247,254)" /> - <polygon points="117,354 117,335 118,336 131,353 134,357 140,366 140,367 140,368 139,368 131,367 126,364 125,363 124,362 123,361 122,360 121,359 120,358" style="fill: rgb(189,187,190)" /> - <polygon points="198,275 199,274 211,267 214,266 219,265 217,270 208,275" style="fill: rgb(124,110,110)" /> - <polygon points="328,123 328,118 328,117 329,117 337,118 339,120 351,147 351,154 344,160 342,161 341,161 329,150 328,149" style="fill: rgb(46,41,40)" /> - <polygon points="154,177 158,168 162,164 167,164 173,168 174,170 174,173 168,179 167,180 164,182 163,182 161,182 160,182 159,182 158,182 157,182 155,180" style="fill: rgb(114,114,116)" /> - <polygon points="284,42 284,41 284,40 285,40 286,40 287,40 287,41 284,43 284,40 285,40 286,40" style="fill: rgb(67,53,52)" /> - <polygon points="367,379 377,381 377,382 376,387 375,388 372,386 369,383 367,380" style="fill: rgb(152,137,134)" /> - <polygon points="354,326 355,325 356,324 361,322 362,322 363,322 364,322 365,322 366,322 367,322 368,322 354,327" style="fill: rgb(152,137,134)" /> - <polygon points="38,397 45,385 58,380 59,380 60,380 66,399 65,399 64,399 43,399 40,399 39,399" style="fill: rgb(95,115,124)" /> - <polygon points="242,381 242,380 242,379 243,378 247,377 247,379 245,380" style="fill: rgb(94,71,72)" /> - <polygon points="212,63 216,62 217,63 218,64 214,64" style="fill: rgb(67,68,70)" /> - <polygon points="316,399 317,397 318,397 318,398 318,399" style="fill: rgb(53,44,45)" /> - <polygon points="231,14 232,11 245,10 246,10 247,10 248,10 276,22 292,50 292,51 290,55 243,55 241,54 234,50" style="fill: rgb(67,53,52)" /> - <polygon points="234,382 236,380 239,381 239,382 238,383 237,383" style="fill: rgb(94,71,72)" /> - <polygon points="334,186 336,184 340,183 341,183 342,183 338,188 335,189 334,189" style="fill: rgb(172,157,154)" /> - <polygon points="207,41 208,41 209,41 210,41 207,43" style="fill: rgb(69,65,62)" /> - <polygon points="224,0 225,0 225,1 225,2 224,2 224,1" style="fill: rgb(67,53,52)" /> - <polygon points="62,41 63,39 64,39 70,46 71,48 71,49 65,46 64,45 62,43" style="fill: rgb(188,205,213)" /> - <polygon points="269,317 270,317 271,317 272,317 273,318 273,319 271,320 270,320 269,318" style="fill: rgb(94,71,72)" /> - <polygon points="204,310 206,308 208,309 209,314 208,314 206,313 205,312" style="fill: rgb(124,110,110)" /> - <polygon points="343,38 343,37 343,36 344,37 345,40 345,41 345,42 344,41" style="fill: rgb(124,110,110)" /> - <polygon points="225,376 225,375 228,378 226,378 225,377 225,375 228,378 226,378" style="fill: rgb(94,71,72)" /> - <polygon points="159,371 160,368 166,365 169,365 171,372 170,374 168,375 166,376" style="fill: rgb(118,97,99)" /> - <polygon points="163,372 169,371 169,372 168,373 166,374" style="fill: rgb(85,92,100)" /> - <polygon points="176,170 182,167 186,173 187,178 187,179 187,180 184,191 183,193 181,193 179,193" style="fill: rgb(74,84,85)" /> - <polygon points="368,358 373,360 376,362 375,362 369,359" style="fill: rgb(119,98,95)" /> - <polygon points="201,14 202,10 203,10 203,12 202,15" style="fill: rgb(74,78,77)" /> - <polygon points="318,114 318,113 319,113 320,113 321,113 321,115" style="fill: rgb(46,41,40)" /> - <polygon points="132,393 133,392 137,394 140,397 142,399 139,399 138,399 137,399 136,399 135,398" style="fill: rgb(74,78,77)" /> - <polygon points="182,159 183,159 184,159 185,159 185,160 184,160" style="fill: rgb(74,84,85)" /> - <polygon points="142,191 175,185 176,185 167,213 165,214 146,223 144,223" style="fill: rgb(172,146,145)" /> - <polygon points="135,230 140,227 165,222 164,224 158,227 150,229 146,230 136,230" style="fill: rgb(95,115,124)" /> - <polygon points="186,112 206,111 210,111 227,115 237,119 244,123 241,148 235,151 222,155 213,155 212,155 211,155 186,114" style="fill: rgb(119,98,95)" /> - <polygon points="286,85 286,84 287,83 288,84 288,85 287,87" style="fill: rgb(46,41,40)" /> - <polygon points="70,159 71,158 72,159 73,160 70,161" style="fill: rgb(175,169,168)" /> - <polygon points="278,149 278,144 279,144 280,144 281,144 282,144 283,144 284,144 285,144 286,144 287,144 291,144 300,144 301,144 308,145 315,146 319,147 325,149 327,154 328,165 328,170 319,195 317,200 316,202 312,209 310,212 308,214 305,216" style="fill: rgb(94,71,72)" /> - <polygon points="90,88 91,73 123,0 127,0 134,0 139,0 161,58 158,150 136,148 126,141 95,116 93,111" style="fill: rgb(95,115,124)" /> - <polygon points="157,41 158,40 159,41 159,42 159,43" style="fill: rgb(95,115,124)" /> - <polygon points="94,179 94,178 95,178 115,195 123,202 125,205 129,213 129,215 128,223 127,224 126,224 125,224 124,224 122,224 121,224 120,224 94,180" style="fill: rgb(188,205,213)" /> - <polygon points="188,117 189,116 192,116 213,118 218,120 220,126 220,127 218,134 213,150 211,154 210,154 209,154 208,154 202,147 201,145 188,118" style="fill: rgb(119,98,95)" /> - <polygon points="97,69 100,35 111,24 117,19 118,21 122,63 121,64 101,69" style="fill: rgb(126,142,150)" /> - <polygon points="255,371 257,369 258,369 258,370 256,371" style="fill: rgb(67,53,52)" /> - <polygon points="319,357 319,356 321,357 321,358 321,359 321,360 319,361 319,360" style="fill: rgb(81,62,57)" /> - <polygon points="66,0 76,8 76,9 73,29 72,35 71,39" style="fill: rgb(126,142,150)" /> - <polygon points="263,39 263,38 267,38 267,39 267,40" style="fill: rgb(67,53,52)" /> - <polygon points="232,110 233,110 288,114 298,115 316,117 318,118 322,122 323,123 324,125 325,129 325,134 325,135 301,142 242,144 241,144 240,144 239,144 238,144 235,144 232,143" style="fill: rgb(67,53,52)" /> - <polygon points="177,194 177,193 178,188 178,191 178,192" style="fill: rgb(172,157,154)" /> - <polygon points="81,0 82,0 83,0 84,0 85,0 83,1" style="fill: rgb(135,162,171)" /> - <polygon points="231,368 231,363 263,344 268,360 264,363 241,373 232,372 231,369" style="fill: rgb(46,41,40)" /> - <polygon points="192,391 193,389 206,391 224,395 226,397 227,398 227,399 226,399 225,399 224,399 200,399 199,399 198,399 197,399 196,398" style="fill: rgb(137,94,99)" /> - <polygon points="177,228 177,225 177,224 178,221 196,188 197,189 199,192 202,209 202,213 184,225" style="fill: rgb(175,169,168)" /> - <polygon points="151,357 154,356 155,356 158,357 159,358 159,359 155,359" style="fill: rgb(114,114,116)" /> - <polygon points="259,244 259,243 263,233 324,182 327,194 327,211 327,239 325,257 320,273 316,284 312,291 310,293 308,295 285,300 284,299" style="fill: rgb(137,94,99)" /> - <polygon points="176,216 182,203 183,202 183,203 180,212 179,214 176,217" style="fill: rgb(146,140,144)" /> - <polygon points="243,56 244,56 245,56 246,56 247,56 248,56 249,56 250,56 251,56 252,56 253,56 254,56 255,56 256,56 257,56 258,56" style="fill: rgb(142,122,123)" /> - <polygon points="316,365 317,364 317,369 317,370 316,367 316,366" style="fill: rgb(94,71,72)" /> - <polygon points="296,0 298,2 298,3 297,3 296,1" style="fill: rgb(94,71,72)" /> - <polygon points="70,62 73,38 77,26 78,23 79,23 80,23 81,24 81,25 80,43 77,61 71,66 70,65" style="fill: rgb(249,247,254)" /> - <polygon points="323,1 323,0 325,0 325,1 325,2 324,2 323,2" style="fill: rgb(189,187,190)" /> - <polygon points="112,344 113,344 114,346 114,347 113,346" style="fill: rgb(188,205,213)" /> - <polygon points="383,364 383,359 383,358 383,357 385,340 399,356 399,360 399,361 399,362 399,363 391,364" style="fill: rgb(249,247,254)" /> - <polygon points="321,287 322,286 323,286 324,286 324,292 324,293 321,288" style="fill: rgb(189,187,190)" /> - <polygon points="0,320 2,319 5,318 8,317 13,316 14,316 15,316 20,316 21,316 22,316 23,316 24,316 25,316 26,316 27,316 1,344 0,345" style="fill: rgb(188,205,213)" /> - <polygon points="289,216 297,210 299,209 300,209 301,209 303,209 303,212 301,213 299,214 292,216" style="fill: rgb(119,98,95)" /> - <polygon points="297,330 298,328 300,328 300,330 300,332 300,333" style="fill: rgb(119,98,95)" /> - <polygon points="201,34 204,33 204,34 204,35 201,35" style="fill: rgb(74,84,85)" /> - <polygon points="318,38 318,37 319,41 320,49 320,50 319,48 318,40" style="fill: rgb(119,98,95)" /> - <polygon points="203,58 204,58 205,58 206,58 207,58 208,58 209,58 210,58" style="fill: rgb(119,98,95)" /> - <polygon points="126,367 138,359 156,376 156,377 154,378 150,379 144,378 140,377 134,374 131,372 128,369" style="fill: rgb(172,146,145)" /> - <polygon points="190,156 195,153 198,154 199,155 195,156 192,156" style="fill: rgb(125,127,122)" /> - <polygon points="246,169 246,168 246,167 247,167 248,167 249,168 250,171 249,171" style="fill: rgb(74,84,85)" /> - <polygon points="200,9 200,7 201,6 202,6 203,6 204,7 203,8" style="fill: rgb(67,68,70)" /> - <polygon points="323,351 324,350 325,354 325,356 325,357 324,361" style="fill: rgb(67,53,52)" /> - <polygon points="73,34 73,32 73,30 75,12 78,0 80,0 86,0 86,1 85,4 84,7 75,31 74,33" style="fill: rgb(188,205,213)" /> - <polygon points="264,14 264,13 267,8 269,7 270,7 271,9 271,16 270,18 266,21 265,21 264,18" style="fill: rgb(67,53,52)" /> - <polygon points="292,129 297,124 300,123 306,122 317,122 319,123 322,125 324,129 325,136 325,137 308,143 305,143 302,142 301,141 295,133" style="fill: rgb(113,83,83)" /> - <polygon points="269,224 277,223 279,224" style="fill: rgb(53,44,45)" /> - <polygon points="266,356 266,351 274,342 275,341 278,340 281,340 281,341 272,352" style="fill: rgb(81,62,57)" /> - <polygon points="44,165 46,167 47,168 51,173 50,172 47,169 46,168" style="fill: rgb(221,221,223)" /> - <polygon points="94,359 94,358 94,357 94,356 94,350 95,345 105,336 123,397 123,399 116,399 115,399 114,399 113,399 112,399 111,399 110,399 98,396 97,395 95,387 94,372" style="fill: rgb(135,162,171)" /> - <polygon points="262,150 263,150 264,150 265,150 266,150 267,150 268,150" style="fill: rgb(51,52,54)" /> - <polygon points="333,183 334,177 335,176 339,172 350,168 351,181 351,196 350,199 349,201 344,203 341,204 333,205" style="fill: rgb(146,140,144)" /> - <polygon points="329,216 330,210 331,206 340,172 352,157 357,152 358,156 362,188 363,197 363,198 360,209 358,215 356,218 354,220 349,222 344,223 343,223 342,223 341,223 340,223 339,223 338,223 333,222 331,220 330,219" style="fill: rgb(146,140,144)" /> - <polygon points="349,181 349,180 350,179 353,180 351,182" style="fill: rgb(125,127,122)" /> - <polygon points="242,166 243,164 244,163 245,163 244,165 243,166" style="fill: rgb(67,68,70)" /> - <polygon points="309,311 310,310 311,309 313,309 312,310 309,312" style="fill: rgb(188,205,213)" /> - <polygon points="126,370 131,373 130,374 128,372 127,371" style="fill: rgb(152,137,134)" /> - <polygon points="248,247 248,246 248,245 250,244 252,244 256,245 260,247 262,249 262,250 261,250 260,250" style="fill: rgb(137,94,99)" /> - <polygon points="238,391 238,390 240,388 241,387 242,387 242,388 242,389 239,392" style="fill: rgb(137,94,99)" /> - <polygon points="302,350 302,349 304,348 305,349 306,351 306,352 305,355 303,353 302,351" style="fill: rgb(28,29,26)" /> - <polygon points="247,109 248,109 249,109 250,109 254,109 262,110 251,110" style="fill: rgb(53,44,45)" /> - <polygon points="326,25 326,24 326,23 326,22 328,23 328,25" style="fill: rgb(175,169,168)" /> - <polygon points="173,377 177,375 288,339 298,346 298,348 298,349 296,356 295,358 290,367 286,374 276,385 256,398 250,399 249,399 248,399 241,399 239,399 238,399 237,399 236,399 231,399 230,399 229,399 228,399 192,386 184,383 179,381 175,379 174,378" style="fill: rgb(81,62,57)" /> - <polygon points="235,149 236,148 237,148 240,149 239,150 237,151 236,151" style="fill: rgb(113,83,83)" /> - <polygon points="205,17 206,17 209,18 208,18 205,18" style="fill: rgb(67,68,70)" /> - <polygon points="213,263 218,260 222,258 223,259 224,261 224,262 222,264 221,264" style="fill: rgb(124,110,110)" /> - <polygon points="275,331 276,332 278,335 278,336 277,336 276,336 275,335" style="fill: rgb(81,62,57)" /> - <polygon points="21,0 22,0 23,0 24,1 25,2 28,5 29,6 61,42 68,50 69,52 69,54 32,13 23,3" style="fill: rgb(221,221,223)" /> - <polygon points="145,236 147,234 172,222 193,224 195,225 196,226 190,237 184,239 161,246 159,246 158,246 157,246 154,245" style="fill: rgb(152,137,134)" /> - <polygon points="14,315 42,307 43,307 31,314 29,315 15,315" style="fill: rgb(249,247,254)" /> - <polygon points="270,170 271,168 272,168 273,169" style="fill: rgb(113,83,83)" /> - <polygon points="194,11 197,8 198,7 199,12 198,13 197,13" style="fill: rgb(67,68,70)" /> - <polygon points="235,23 235,22 237,11 239,7 251,0 255,0 259,0 262,0 269,0 271,0 279,0 285,0 287,0 293,0 295,3 302,15 307,30 314,54 314,56 304,56 287,56 286,56 263,53" style="fill: rgb(81,62,57)" /> - <polygon points="265,308 266,308 268,308 267,310 266,310" style="fill: rgb(94,71,72)" /> - <polygon points="136,332 138,331 139,331 140,332 137,334 136,333" style="fill: rgb(152,137,134)" /> - <polygon points="330,366 330,365 332,366 333,367 334,368 335,369 335,370 333,370 332,370" style="fill: rgb(142,122,123)" /> - <polygon points="362,224 364,223 369,221 376,221 377,221 378,221 379,221 380,221 381,221 382,221 382,222 375,225 365,225" style="fill: rgb(146,140,144)" /> - <polygon points="327,28 330,28 330,30 329,34 328,35 327,30" style="fill: rgb(175,169,168)" /> - <polygon points="181,366 181,365 183,362 183,366 182,369 181,368" style="fill: rgb(74,84,85)" /> - <polygon points="104,310 105,309 106,308 107,308 113,313 109,319 108,318" style="fill: rgb(146,140,144)" /> - <polygon points="261,367 270,360 271,360 267,366 265,367 262,368 261,368" style="fill: rgb(94,71,72)" /> - <polygon points="238,170 238,169 242,168 244,168 244,172 241,171" style="fill: rgb(67,53,52)" /> - <polygon points="314,58 315,57 329,59 328,60 325,60 315,59" style="fill: rgb(119,98,95)" /> - <polygon points="379,399 379,398 379,397 379,396 382,398 382,399 381,399 380,399" style="fill: rgb(152,137,134)" /> - <polygon points="116,139 116,138 118,127 122,129 142,147 135,148 123,149 122,149 121,149 120,149" style="fill: rgb(146,140,144)" /> - <polygon points="128,47 128,45 129,44 131,42 132,42 132,43 131,48 130,48" style="fill: rgb(113,133,143)" /> - <polygon points="271,358 273,356 275,354 275,355 271,359" style="fill: rgb(81,62,57)" /> - <polygon points="272,296 274,296 274,297 272,297" style="fill: rgb(113,83,83)" /> - <polygon points="305,163 305,160 306,159 307,160 312,169 312,174 311,177 305,164" style="fill: rgb(81,62,57)" /> - <polygon points="232,167 237,161 238,160 240,159 244,158 245,158 246,158 240,167 235,171" style="fill: rgb(67,68,70)" /> - <polygon points="224,384 225,383 229,382 231,382 230,383" style="fill: rgb(81,62,57)" /> - <polygon points="132,378 160,375 168,378 179,385 182,387 183,388 186,391 188,395 189,398 189,399 188,399 174,399 173,399 172,399 171,399 170,399 169,399 160,399 152,398 140,388" style="fill: rgb(142,122,123)" /> - <polygon points="277,349 279,346 279,347 278,349 277,350" style="fill: rgb(46,41,40)" /> - <polygon points="334,394 335,393 337,393 337,399" style="fill: rgb(124,110,110)" /> - <polygon points="265,58 266,58 267,58 268,58 269,58 270,58 271,58 272,58 273,58 274,58" style="fill: rgb(94,71,72)" /> - <polygon points="234,234 234,233 238,219 239,219 253,225 251,229 243,235 238,236 237,236 235,235" style="fill: rgb(94,71,72)" /> - <polygon points="205,31 208,30 209,30 210,31 209,33 208,34 206,33" style="fill: rgb(74,78,77)" /> - <polygon points="306,299 306,298 306,297 312,287 314,288 315,290 313,299 309,301 306,300" style="fill: rgb(119,98,95)" /> - <polygon points="108,348 108,347 109,350 115,368 116,375 115,376 114,374 113,372 112,369 110,361 108,349" style="fill: rgb(113,133,143)" /> - <polygon points="251,399 297,353 297,355 297,357 292,367 291,369 286,377 282,383 273,393 268,396 260,399" style="fill: rgb(113,83,83)" /> - <polygon points="131,165 132,163 139,164 139,165 137,166 135,167 132,168" style="fill: rgb(126,142,150)" /> - <polygon points="217,381 218,381 219,381 220,381 221,381 224,383 220,385 218,384 217,382" style="fill: rgb(67,53,52)" /> - <polygon points="170,379 171,379 172,379 173,379 195,389 196,395 196,399 195,399 194,399 193,399 192,399 191,399 190,399 170,380" style="fill: rgb(124,110,110)" /> - <polygon points="181,58 183,57 185,57 187,58 184,58" style="fill: rgb(152,137,134)" /> - <polygon points="186,57 187,57 189,57 190,57 191,57 192,57 193,57 188,58" style="fill: rgb(172,157,154)" /> - <polygon points="224,3 229,0 230,1 231,3 230,6 225,4" style="fill: rgb(69,65,62)" /> - <polygon points="327,374 327,372 327,370 327,368 328,370 328,371" style="fill: rgb(113,83,83)" /> - <polygon points="323,27 324,25 326,26 328,37 325,40 323,34" style="fill: rgb(172,146,145)" /> - <polygon points="145,187 146,186 150,187" style="fill: rgb(125,127,122)" /> - <polygon points="278,13 278,12 281,13 280,14 279,14" style="fill: rgb(81,62,57)" /> - <polygon points="331,60 332,59 348,59 356,62 377,76 382,84 382,85 382,86 381,86 351,74" style="fill: rgb(113,83,83)" /> - <polygon points="333,50 334,48 335,49 337,55 336,57 335,57 334,57 333,51" style="fill: rgb(175,169,168)" /> - <polygon points="296,57 298,57 299,57 300,57 301,57 297,58 296,58" style="fill: rgb(119,98,95)" /> - <polygon points="316,340 316,339 321,343 319,343 318,343 317,342" style="fill: rgb(40,30,30)" /> - <polygon points="375,364 381,364 399,365 399,366 399,372 399,373 399,374 399,375 398,375 397,375 391,373 377,366 376,365" style="fill: rgb(189,187,190)" /> - <polygon points="334,1 335,0 342,0 351,0 360,0 361,1 391,34 399,63 399,74 399,90 399,91 398,91 397,91 396,91 385,90 352,51 343,35 342,33 341,30 339,23" style="fill: rgb(142,122,123)" /> - <polygon points="187,170 187,169 187,168 188,167 189,168 189,169 188,172" style="fill: rgb(146,140,144)" /> - <polygon points="103,314 106,317 108,320 108,321 107,322 103,317" style="fill: rgb(221,221,223)" /> - <polygon points="143,363 144,363 150,366 153,369 155,371 157,373 157,374" style="fill: rgb(142,122,123)" /> - <polygon points="322,358 322,356 323,352 323,353 323,358 323,359 323,360" style="fill: rgb(53,44,45)" /> - <polygon points="196,351 197,351 198,351 199,351 197,354 196,354" style="fill: rgb(113,83,83)" /> - <polygon points="324,399 324,397 324,396 325,394 325,399" style="fill: rgb(40,30,30)" /> - <polygon points="152,334 152,333 153,331 154,330 155,330 155,331 154,333 153,335 152,335" style="fill: rgb(172,157,154)" /> - <polygon points="282,223 282,221 283,221 285,223" style="fill: rgb(53,44,45)" /> - <polygon points="83,367 86,360 87,359 88,359 90,360 92,362 93,368 94,381 94,383 94,388 93,391 90,399 88,399 87,399 86,397 84,379" style="fill: rgb(95,115,124)" /> - <polygon points="229,50 230,46 231,46 232,47 230,50" style="fill: rgb(67,53,52)" /> - <polygon points="308,148 309,148 310,148 311,148 312,149 311,149" style="fill: rgb(53,44,45)" /> - <polygon points="94,183 94,182 94,181 95,181 96,182 107,194 114,202 118,207 122,214 121,219 120,223 119,223 118,223 117,222 116,221 115,220" style="fill: rgb(221,221,223)" /> - <polygon points="294,146 295,145 297,145 298,145 299,145 298,152 297,152 296,152 295,149" style="fill: rgb(53,44,45)" /> - <polygon points="252,381 252,380 253,379 254,380 254,381 253,381" style="fill: rgb(137,94,99)" /> - <polygon points="248,138 249,138 250,138 251,138 252,138 253,138" style="fill: rgb(51,52,54)" /> - <polygon points="318,274 319,273 320,274 320,275 320,276 320,277 319,279 318,280" style="fill: rgb(124,110,110)" /> - <polygon points="155,355 155,354 159,353 159,354" style="fill: rgb(114,114,116)" /> - <polygon points="242,213 242,212 246,216" style="fill: rgb(119,98,95)" /> - <polygon points="254,158 254,157 255,157 258,157 259,157 260,157 258,159 257,159" style="fill: rgb(81,62,57)" /> - <polygon points="255,68 256,67 257,67 258,68 258,69 257,69 256,69 255,69" style="fill: rgb(43,43,45)" /> - <polygon points="289,332 291,328 292,328 293,328 292,330 290,333 289,334" style="fill: rgb(67,53,52)" /> - <polygon points="349,378 350,379 352,383 352,384 350,381" style="fill: rgb(67,53,52)" /> - <polygon points="132,352 134,353 136,354 142,359 144,362 143,362 134,354" style="fill: rgb(125,127,122)" /> - <polygon points="302,342 304,341 304,342 304,344 304,346 303,346 302,343" style="fill: rgb(40,30,30)" /> - <polygon points="184,25 184,21 186,22 185,24" style="fill: rgb(85,92,100)" /> - <polygon points="54,34 55,33 59,37 60,38 57,38" style="fill: rgb(189,187,190)" /> - <polygon points="183,200 184,198 185,197 186,196 186,198 184,200" style="fill: rgb(146,140,144)" /> - <polygon points="323,10 323,9 324,9 325,11 324,12 323,11" style="fill: rgb(175,169,168)" /> - <polygon points="195,0 197,0 199,2 200,4 199,4 196,2" style="fill: rgb(67,68,70)" /> - <polygon points="182,373 182,372 196,372 216,374 223,377 223,378 222,380 197,386 186,382 184,381 183,380" style="fill: rgb(94,71,72)" /> - <polygon points="210,172 211,173 214,178 214,179 211,175" style="fill: rgb(113,83,83)" /> - <polygon points="76,385 78,384 79,385 79,386 78,387 76,388" style="fill: rgb(135,162,171)" /> - <polygon points="350,337 353,334 354,333 356,332 359,331 368,331 369,331 370,331 371,331 372,331 373,331 374,331 375,331 376,331 369,339 367,340 362,341 353,341" style="fill: rgb(152,137,134)" /> - <polygon points="258,170 258,169 259,169 260,169 260,170 259,170" style="fill: rgb(74,78,77)" /> - <polygon points="178,49 179,48 180,49 180,50 179,50 178,50" style="fill: rgb(85,92,100)" /> - <polygon points="252,371 253,370 255,368 255,370 253,371" style="fill: rgb(53,44,45)" /> - <polygon points="381,183 382,183 383,183 382,185 381,185" style="fill: rgb(119,98,95)" /> - <polygon points="331,195 331,194 331,193 332,196 332,200 332,201" style="fill: rgb(67,53,52)" /> - <polygon points="185,367 188,367 188,368 187,369 185,370" style="fill: rgb(67,68,70)" /> - <polygon points="130,307 131,306 131,307 131,308 131,309 130,309" style="fill: rgb(189,187,190)" /> - <polygon points="331,208 331,207 338,206 340,206 341,206 342,206 343,206 344,206 345,206 346,208 342,210 338,210 337,210 336,210 334,210 333,210 331,209" style="fill: rgb(146,140,144)" /> - <polygon points="328,19 328,18 331,17 334,25 334,27 334,28 330,26 328,20" style="fill: rgb(221,221,223)" /> - <polygon points="371,328 372,324 373,323 375,323 375,326 375,327 372,328" style="fill: rgb(135,162,171)" /> - <polygon points="230,181 230,180 307,169 308,169 309,171 309,172 300,214 295,216 292,217 288,218 283,219 260,220 257,220 252,219 247,217 243,214 240,211 237,207 232,193 231,189 230,182" style="fill: rgb(113,83,83)" /> - <polygon points="194,79 195,74 202,67 203,66 214,60 222,60 260,61 270,63 274,72 236,108 231,108 230,108 229,108 228,108 227,108 226,108 225,108 224,108 207,108 204,108 202,107 198,99" style="fill: rgb(51,52,54)" /> - <polygon points="218,276 226,274 226,275 223,276" style="fill: rgb(137,94,99)" /> - <polygon points="241,336 245,330 247,327 262,305 268,297 291,304 303,312 304,315 304,323 250,350 249,349" style="fill: rgb(67,53,52)" /> - <polygon points="174,316 174,314 175,313 177,312 184,320 186,323 186,326 186,329 184,329 177,326 175,323" style="fill: rgb(175,169,168)" /> - <polygon points="215,383 216,382 219,382 220,382 220,383 216,383" style="fill: rgb(81,62,57)" /> - <polygon points="270,222 271,222 272,222 273,222 274,222 275,222" style="fill: rgb(46,41,40)" /> - <polygon points="88,156 91,155 98,153 102,152 103,152 104,152 109,153 109,159 109,160 94,170 93,170" style="fill: rgb(126,142,150)" /> - <polygon points="208,168 208,167 209,166 212,166 215,170 222,193 221,192 220,191 208,169" style="fill: rgb(113,83,83)" /> - <polygon points="185,231 185,230 186,229 188,228 193,235 191,236 189,236 188,236 187,236 186,236 185,235" style="fill: rgb(124,110,110)" /> - <polygon points="147,331 148,331 149,331 150,332 149,334 148,334" style="fill: rgb(172,157,154)" /> - <polygon points="192,15 192,14 192,13 195,12 195,13 194,15 193,15" style="fill: rgb(85,92,100)" /> - <polygon points="269,366 288,340 289,339 297,331 298,331 299,332 299,334 299,336 298,342 296,352 292,359 284,367 283,368 277,372 274,373 272,372 269,367" style="fill: rgb(137,94,99)" /> - <polygon points="256,226 257,226 258,226 259,226 260,226 264,226 266,227 258,231" style="fill: rgb(94,71,72)" /> - <polygon points="137,386 159,399 149,399 146,397 137,388" style="fill: rgb(114,114,116)" /> - <polygon points="340,389 342,388 343,392 343,395 343,396 343,397 342,398" style="fill: rgb(81,62,57)" /> - <polygon points="139,357 140,354 141,355 140,358" style="fill: rgb(124,110,110)" /> - <polygon points="300,21 301,19 303,21 303,22 301,22" style="fill: rgb(81,62,57)" /> - <polygon points="326,71 332,71 332,74 329,73 327,72" style="fill: rgb(69,65,62)" /> - <polygon points="183,361 197,277 257,273 258,273 268,274 273,276 273,277 264,305 257,319 231,349 190,366 189,366 184,364" style="fill: rgb(137,94,99)" /> - <polygon points="96,356 96,351 96,349 97,342 98,337 103,322 104,323 105,359 103,361 102,362 101,363 100,362 96,358" style="fill: rgb(188,205,213)" /> - <polygon points="134,77 137,67 142,63 148,62 163,60 175,60 176,60 177,60 178,60 179,60 194,111 188,112 185,112 184,112 183,112 182,112 139,110 134,78" style="fill: rgb(74,84,85)" /> - <polygon points="229,173 230,170 231,169 230,172 229,175" style="fill: rgb(51,52,54)" /> - <polygon points="297,365 298,361 298,363 298,364 297,366" style="fill: rgb(67,53,52)" /> - <polygon points="228,54 230,53 238,53 240,53 242,55 240,55" style="fill: rgb(69,65,62)" /> - <polygon points="67,0 71,0 75,0 76,0 77,0 77,4 77,5 76,7 75,8 73,7 72,6 71,5" style="fill: rgb(175,169,168)" /> - <polygon points="279,345 282,343 282,344 280,346" style="fill: rgb(67,53,52)" /> - <polygon points="331,29 332,29 337,35 341,50 341,52 341,54 340,57 339,57 338,57 337,57 336,53 332,35 331,30" style="fill: rgb(221,221,223)" /> - <polygon points="78,50 79,45 80,44 80,46 79,49 78,52" style="fill: rgb(188,205,213)" /> - <polygon points="379,342 379,341 380,342 380,344 379,345" style="fill: rgb(114,114,116)" /> - <polygon points="370,323 372,322 373,322 374,322 375,322 376,323 377,326 376,327" style="fill: rgb(152,137,134)" /> - <polygon points="46,19 47,20 50,23 51,24 47,22" style="fill: rgb(188,205,213)" /> - <polygon points="324,18 324,17 328,14 328,15" style="fill: rgb(175,169,168)" /> - <polygon points="107,340 108,341 138,386 136,386 133,384 132,383 121,370 115,360 110,351 109,349 108,345" style="fill: rgb(114,114,116)" /> - <polygon points="78,363 84,349 85,347 87,344 91,338 93,335 98,330 98,331 98,332 93,367 86,399 85,399 84,398" style="fill: rgb(113,133,143)" /> - <polygon points="334,341 334,339 334,337 337,338 342,349 346,361 346,362 346,363 342,357 334,342" style="fill: rgb(124,110,110)" /> - <polygon points="334,387 335,387 337,388 340,390 339,390 337,389" style="fill: rgb(94,71,72)" /> - <polygon points="166,346 167,345 168,345 174,361 173,361 169,358" style="fill: rgb(124,110,110)" /> - <polygon points="237,275 245,272 247,273 247,274 243,275" style="fill: rgb(81,62,57)" /> - <polygon points="343,168 344,166 349,161 350,161 347,166 344,168" style="fill: rgb(172,146,145)" /> - <polygon points="205,108 206,108 216,108 217,108 218,108 219,108 220,108 221,109 220,109 219,109 218,109 216,109 207,109" style="fill: rgb(51,52,54)" /> - <polygon points="184,372 185,371 186,370 188,369 193,367 199,365 200,366 200,371 200,372 195,376 185,373" style="fill: rgb(69,65,62)" /> - <polygon points="283,222 291,219 294,218 300,217 301,217 302,218 298,220 295,221 286,223" style="fill: rgb(53,44,45)" /> - <polygon points="123,331 124,329 125,329 125,330 125,331" style="fill: rgb(113,133,143)" /> - <polygon points="324,177 325,176 325,179 325,186 324,178" style="fill: rgb(124,110,110)" /> - <polygon points="271,281 271,280 272,279 273,280 273,281 272,282" style="fill: rgb(81,62,57)" /> - <polygon points="87,55 88,56 88,58 87,61" style="fill: rgb(188,205,213)" /> - <polygon points="326,356 326,349 326,347 326,341 326,339 326,338 327,338 329,339 332,342 337,351 339,355 341,360 344,368 345,371 342,371 331,363 326,357" style="fill: rgb(46,41,40)" /> - <polygon points="260,146 261,145 277,145 278,145 279,145 280,146 277,149 274,150 261,150" style="fill: rgb(43,43,45)" /> - <polygon points="298,326 301,324 302,325 302,326 298,327" style="fill: rgb(81,62,57)" /> - <polygon points="145,280 146,278 147,278 147,280" style="fill: rgb(146,140,144)" /> - <polygon points="97,396 99,394 105,395 106,396 109,399 104,399 100,399 99,399 98,398" style="fill: rgb(126,142,150)" /> - <polygon points="366,138 368,137 370,139 367,139 366,139" style="fill: rgb(81,62,57)" /> - <polygon points="313,158 315,157 319,156 319,157 319,158 319,159 317,160" style="fill: rgb(43,43,45)" /> - <polygon points="13,398 13,397 14,397 15,397 15,399 14,399" style="fill: rgb(113,133,143)" /> - <polygon points="224,205 225,204 229,210 227,210 226,209" style="fill: rgb(119,98,95)" /> - <polygon points="315,332 317,333 319,335 318,335 316,334" style="fill: rgb(74,84,85)" /> - <polygon points="307,150 309,150 309,151 309,152 307,151" style="fill: rgb(53,44,45)" /> - <polygon points="234,110 235,110 236,110 237,110 238,110 239,110 240,110 241,110 250,111 250,112 247,112" style="fill: rgb(69,65,62)" /> - <polygon points="24,0 26,0 36,9 35,12 30,7" style="fill: rgb(188,205,213)" /> - <polygon points="238,76 241,75 242,75 243,76 245,78 245,79 243,88 242,89 241,89 240,89 239,89 238,77" style="fill: rgb(51,52,54)" /> - <polygon points="382,364 382,363 382,362 399,364 396,366 388,366 383,365" style="fill: rgb(249,247,254)" /> - <polygon points="215,39 218,38 220,39 220,40 219,41 218,42 216,41 215,40" style="fill: rgb(67,68,70)" /> - <polygon points="162,222 179,191 182,193 183,194 183,196 182,199 180,204 178,209 177,211 176,213 173,217 169,222 165,224" style="fill: rgb(85,92,100)" /> - <polygon points="226,202 226,201 233,212 231,210 230,209 229,208 228,207 227,205 226,203" style="fill: rgb(94,71,72)" /> - <polygon points="326,57 330,52 331,51 332,50 328,56 327,57" style="fill: rgb(152,137,134)" /> - <polygon points="140,360 141,361 142,362 144,364 143,364 142,364" style="fill: rgb(152,137,134)" /> - <polygon points="348,57 348,56 348,54 368,63 370,65 382,78 383,80 383,89 383,90 383,91 383,92 364,76 363,75 358,70 349,60" style="fill: rgb(113,83,83)" /> - <polygon points="100,15 100,14 102,12 104,12 104,13 102,15 101,15" style="fill: rgb(189,187,190)" /> - <polygon points="326,326 327,319 327,325 327,326" style="fill: rgb(221,221,223)" /> - <polygon points="296,377 298,369 301,362 303,358 305,358 306,363 306,365 303,375 302,377 300,377" style="fill: rgb(31,24,23)" /> - <polygon points="338,158 338,157 338,156 339,154 348,156 348,159 343,165 342,165 340,163 339,161 338,159" style="fill: rgb(53,44,45)" /> - <polygon points="337,348 338,347 340,349 342,355 341,356 338,350" style="fill: rgb(119,98,95)" /> - <polygon points="261,62 261,61 264,61 265,61 270,61 279,61 290,62 293,63 316,75 329,86 353,116 357,122 358,125 360,135 360,138 358,146 355,151 350,157 326,139 286,99" style="fill: rgb(53,44,45)" /> - <polygon points="49,3 50,0 51,0 53,0 55,0 57,0 59,0 61,0 63,0 65,0 67,2 68,3 72,8 73,10 73,12 73,14 72,28 71,40 70,40 68,38 59,28 53,14 49,4" style="fill: rgb(126,142,150)" /> - <polygon points="149,48 150,29 152,0 153,0 159,0 166,0 174,1 181,5 184,14 184,52 184,53 184,54 177,55 162,57 161,57 160,57 159,57 152,51" style="fill: rgb(85,92,100)" /> - <polygon points="268,227 269,226 270,226 271,226 272,226 273,226 274,226 275,226 276,226" style="fill: rgb(94,71,72)" /> - <polygon points="201,0 202,0 203,0 205,2 205,3 203,3 201,1" style="fill: rgb(69,65,62)" /> - <polygon points="276,168 277,168 278,168 280,168 280,169 279,169" style="fill: rgb(53,44,45)" /> - <polygon points="177,147 180,146 179,148 178,148" style="fill: rgb(118,97,99)" /> - <polygon points="222,21 230,22 231,23 231,24 225,25 224,25 223,24" style="fill: rgb(94,71,72)" /> - <polygon points="335,158 335,157 335,156 335,155 336,156 336,160 336,161 335,160" style="fill: rgb(119,98,95)" /> - <polygon points="356,359 357,358 360,357 363,357 365,358 366,359 363,361 361,361 357,360" style="fill: rgb(175,169,168)" /> - <polygon points="325,349 325,350 325,347 325,348 325,345 325,346 325,351 325,344 325,352 325,353" style="fill: rgb(53,44,45)" /> - <polygon points="138,324 139,323 146,321 144,324 142,325 140,326" style="fill: rgb(146,140,144)" /> - <polygon points="275,58 276,58 277,58 278,58 279,58 280,58 281,58" style="fill: rgb(113,83,83)" /> - <polygon points="206,10 208,0 215,0 222,0 240,8 245,43 245,44 245,45 234,52 219,54 218,54 217,54 216,54 215,54" style="fill: rgb(67,68,70)" /> - <polygon points="358,346 359,345 360,344 374,334 382,330 383,331 384,334 384,335 384,336 382,352 381,359 380,361 378,363 377,363 362,351 361,350 360,349" style="fill: rgb(125,127,122)" /> - <polygon points="350,373 351,373 352,374 361,384 373,399 372,399 371,399 368,397 364,394 363,393 360,389 352,377" style="fill: rgb(119,98,95)" /> - <polygon points="330,169 330,168 332,166 338,162 339,162 342,163 342,166 340,168 336,170 335,170 333,170 332,170" style="fill: rgb(53,44,45)" /> - <polygon points="232,58 233,58 234,58 235,58 236,58 237,58" style="fill: rgb(113,83,83)" /> - <polygon points="372,134 372,133 373,133 375,133 376,133 377,133 378,133 379,133 380,133 381,133 382,133 386,133 387,134 380,135 379,135 378,135 377,135 373,135 372,135" style="fill: rgb(81,62,57)" /> - <polygon points="306,194 307,194 308,195 308,196 307,196" style="fill: rgb(119,98,95)" /> - <polygon points="63,43 70,50 70,51 69,50 67,48 66,47" style="fill: rgb(189,187,190)" /> - <polygon points="212,35 216,32 217,32 218,33 218,34 214,36" style="fill: rgb(67,68,70)" /> - <polygon points="294,221 295,218 302,214 303,215 303,216 302,217 301,218 300,219 297,220" style="fill: rgb(46,41,40)" /> - <polygon points="272,12 273,12 279,16 279,19 276,17" style="fill: rgb(81,62,57)" /> - <polygon points="0,65 0,12 2,13 3,14 62,74 96,219 97,297 97,298 96,299 28,314 0,318" style="fill: rgb(249,247,254)" /> - <polygon points="236,172 236,171 255,175 256,184 254,184 253,184 245,181 243,180 242,179" style="fill: rgb(81,62,57)" /> - <polygon points="252,145 252,144 253,143 258,143 259,143 257,144" style="fill: rgb(94,71,72)" /> - <polygon points="329,204 330,201 330,204 330,206 329,207" style="fill: rgb(81,62,57)" /> - <polygon points="303,211 303,210 304,207 305,207" style="fill: rgb(137,94,99)" /> - <polygon points="372,124 374,118 375,116 378,117 399,129 399,131 389,132 384,132 383,132 373,130 372,125" style="fill: rgb(113,83,83)" /> - <polygon points="179,286 179,285 181,283 182,282 182,284 182,285 180,286" style="fill: rgb(172,157,154)" /> - <polygon points="275,286 277,290 277,291 276,290 275,289 275,288" style="fill: rgb(94,71,72)" /> - <polygon points="143,361 146,360 160,362 168,377 165,377 161,375 159,374 146,364" style="fill: rgb(124,110,110)" /> - <polygon points="162,367 166,367 166,368 166,369 164,369" style="fill: rgb(118,97,99)" /> - <polygon points="60,18 61,19 61,20 61,21 60,20" style="fill: rgb(135,162,171)" /> - <polygon points="360,326 362,325 368,324 371,325 371,326 368,329 361,329 360,328" style="fill: rgb(125,127,122)" /> - <polygon points="30,315 34,312 37,310 39,309 40,309 40,310 39,311 38,312 35,314 33,315 32,315" style="fill: rgb(188,205,213)" /> - <polygon points="277,56 278,56 279,56 280,56 281,56 282,56 283,56" style="fill: rgb(94,71,72)" /> - <polygon points="31,7 35,11 37,13 38,14 54,32 61,40 61,41 58,38 42,20 36,13" style="fill: rgb(189,187,190)" /> - <polygon points="126,385 126,384 126,383 127,383 128,383 135,391 136,393 135,393 134,393 131,392 129,390 127,387" style="fill: rgb(74,84,85)" /> - <polygon points="275,106 275,104 281,98 282,98 301,101 311,104 315,108 314,115 313,115 275,111" style="fill: rgb(46,41,40)" /> - <polygon points="131,315 134,315 139,317 141,318 138,321 134,318" style="fill: rgb(172,157,154)" /> - <polygon points="200,385 205,385 206,385 204,386 201,386" style="fill: rgb(81,62,57)" /> - <polygon points="76,89 77,78 79,75 81,73 84,72 92,70 93,70 94,70 95,70 114,118 115,121 115,122 108,125 107,125 101,124 80,120" style="fill: rgb(113,133,143)" /> - <polygon points="123,339 123,337 123,336 124,336 129,342 130,344 130,347 130,348 128,346" style="fill: rgb(114,114,116)" /> - <polygon points="317,339 323,331 323,332 323,337 323,339 322,348 318,344" style="fill: rgb(46,41,40)" /> -</svg> diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/gunit/test_004.svg b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/gunit/test_004.svg deleted file mode 100644 index 6a96621cfc..0000000000 --- a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/gunit/test_004.svg +++ /dev/null @@ -1,1027 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<svg xmlns="http://www.w3.org/2000/svg" width="400" height="400" version="1.1" baseProfile="full"> - <polygon points="185,150 186,148 187,149 189,153 186,155" style="fill: rgb(138,113,109)" /> - <polygon points="142,397 142,396 143,394 148,394 153,397 144,397 142,396 143,394 148,394 153,397 144,397 142,396 143,394 148,394 153,397 144,397 142,396 143,394 148,394 153,397 144,397 142,396 143,394 148,394 153,397 144,397" style="fill: rgb(123,89,88)" /> - <polygon points="186,129 190,126 191,127 191,129 191,133 188,136" style="fill: rgb(118,100,98)" /> - <polygon points="78,194 83,190 85,190 86,191 89,196 89,197 87,199 80,197" style="fill: rgb(165,109,110)" /> - <polygon points="114,267 115,266 119,265 121,266 121,270 120,270" style="fill: rgb(122,68,66)" /> - <polygon points="32,184 34,180 35,182 36,195 36,196 36,197 36,198 35,197 34,194 32,185" style="fill: rgb(64,40,36)" /> - <polygon points="62,211 63,209 64,208 67,207 68,207 69,207 71,207 73,208 74,209 74,210 74,211 71,214 70,214" style="fill: rgb(52,28,28)" /> - <polygon points="66,185 71,161 76,144 77,143 96,157 99,163 105,184 103,189 102,191 101,192 96,197 94,198 76,193 66,186" style="fill: rgb(163,103,105)" /> - <polygon points="123,158 124,157 125,157 127,158 130,162 130,163 129,165 128,165 127,165 123,162" style="fill: rgb(188,143,140)" /> - <polygon points="130,391 140,381 142,381 143,382 143,383 138,388 136,390 131,394" style="fill: rgb(103,91,91)" /> - <polygon points="290,230 299,223 300,224 304,251 304,257 304,259 304,261 299,261 298,261 297,261 295,258 294,255" style="fill: rgb(86,87,89)" /> - <polygon points="169,109 170,106 171,106 172,106 173,107 173,108 172,109 171,110" style="fill: rgb(103,72,70)" /> - <polygon points="14,350 15,349 22,354 23,362 23,364 17,356" style="fill: rgb(31,35,36)" /> - <polygon points="239,224 240,224 243,226 244,227 243,229 241,230" style="fill: rgb(168,139,141)" /> - <polygon points="186,399 186,398 188,395 193,390 197,393 197,394 195,397 192,399 188,399 186,398 188,395 193,390 197,393 197,394 195,397 192,399 188,399 186,398 188,395 193,390 197,393 197,394 195,397 192,399 188,399 186,398 188,395 193,390 197,393 197,394 195,397 192,399 188,399 186,398 188,395 193,390 197,393 197,394 195,397 192,399 188,399 186,398 188,395 193,390 197,393 197,394 195,397 192,399 188,399 186,398" style="fill: rgb(201,198,205)" /> - <polygon points="169,300 169,298 172,296 174,296 176,297 177,298 175,301 173,301 170,301 169,301 169,298 172,296 174,296 176,297 177,298 175,301 173,301 170,301 169,301 169,298 172,296 174,296 176,297 177,298" style="fill: rgb(151,95,96)" /> - <polygon points="144,265 145,264 152,260 153,260 154,261 154,266 153,267 147,266" style="fill: rgb(141,87,87)" /> - <polygon points="54,221 55,219 56,217 57,215 58,214 59,214 57,220 55,223 54,223" style="fill: rgb(18,18,18)" /> - <polygon points="239,257 242,249 245,254 245,258 244,260 242,259" style="fill: rgb(196,153,163)" /> - <polygon points="249,181 249,180 251,179 252,179 254,181 251,183" style="fill: rgb(147,129,125)" /> - <polygon points="166,198 175,196 176,196 175,200 172,202 167,202" style="fill: rgb(172,116,115)" /> - <polygon points="284,222 285,221 288,226 288,229 286,229 285,226" style="fill: rgb(136,135,140)" /> - <polygon points="287,279 288,278 290,280 290,282 290,283 289,284 288,284" style="fill: rgb(168,139,141)" /> - <polygon points="28,345 32,344 34,344 35,345 37,348" style="fill: rgb(35,39,40)" /> - <polygon points="70,396 75,392 75,394 75,396 74,398 73,399" style="fill: rgb(130,119,115)" /> - <polygon points="181,71 182,67 183,66 186,65 187,65 187,66 186,68 182,71" style="fill: rgb(74,50,46)" /> - <polygon points="260,201 266,201 270,207 272,213" style="fill: rgb(187,128,132)" /> - <polygon points="187,96 188,95 191,96 193,97 193,101 192,101 191,101 189,100" style="fill: rgb(103,72,70)" /> - <polygon points="235,279 235,273 236,274 238,279 237,281 235,280" style="fill: rgb(141,101,101)" /> - <polygon points="125,209 125,208 133,205 134,206 134,207 134,208 134,210 129,210" style="fill: rgb(159,108,107)" /> - <polygon points="155,162 156,162 157,162 158,162 160,163 163,165 163,166 162,166 155,163" style="fill: rgb(162,128,129)" /> - <polygon points="156,231 158,199 159,198 163,196 183,186 185,186 191,189 192,190 193,192 195,278 194,281 188,291 187,290 186,289 182,282" style="fill: rgb(188,143,140)" /> - <polygon points="161,398 164,394 166,392 167,393 167,394 167,397 167,398 166,399 163,399" style="fill: rgb(123,89,88)" /> - <polygon points="95,371 95,370 98,369 100,369 100,373 98,373 96,372" style="fill: rgb(41,53,53)" /> - <polygon points="92,245 102,246 102,247 96,247 95,247 93,246" style="fill: rgb(187,128,132)" /> - <polygon points="139,229 142,229 146,232 147,233 148,234 148,235 143,233 140,231" style="fill: rgb(169,103,107)" /> - <polygon points="230,212 230,211 230,210 230,209 230,208 231,196 232,196 236,203 236,205 236,208 234,211" style="fill: rgb(188,143,140)" /> - <polygon points="58,253 58,252 58,251 58,250 58,249 60,248 61,248 62,248 61,270" style="fill: rgb(121,87,86)" /> - <polygon points="139,271 143,274 144,275 144,276 144,277 141,277 140,277 139,276" style="fill: rgb(159,108,107)" /> - <polygon points="230,334 231,333 236,334 236,335 236,336 235,338 231,335" style="fill: rgb(147,129,125)" /> - <polygon points="71,356 71,354 75,350 85,345 87,344 89,345 90,350 88,374 87,374 71,373" style="fill: rgb(31,35,36)" /> - <polygon points="47,380 47,379 53,377 62,380 62,381 54,382 53,382 52,382 49,381" style="fill: rgb(13,13,13)" /> - <polygon points="180,144 183,142 184,142 186,144 187,146 188,148 187,148 181,145" style="fill: rgb(118,100,98)" /> - <polygon points="106,303 106,302 111,293 112,293 116,294 110,313 108,312 107,308 106,304" style="fill: rgb(141,87,87)" /> - <polygon points="119,309 120,306 121,305 122,305 126,307 129,313 126,317 123,319 122,318 120,316" style="fill: rgb(122,68,66)" /> - <polygon points="335,190 336,190 339,191 341,192 341,194 341,195 337,197" style="fill: rgb(201,198,205)" /> - <polygon points="103,297 105,295 106,294 109,291 110,292 105,298" style="fill: rgb(84,45,46)" /> - <polygon points="76,218 81,215 82,215 83,215 86,215 88,216 86,217 77,218" style="fill: rgb(52,28,28)" /> - <polygon points="117,119 117,118 117,117 129,120 131,122 129,122 126,122" style="fill: rgb(156,92,93)" /> - <polygon points="174,390 187,385 190,386 182,395 180,397 179,397 175,393" style="fill: rgb(172,116,115)" /> - <polygon points="219,108 220,107 224,105 225,107 224,109 220,109" style="fill: rgb(74,50,46)" /> - <polygon points="347,321 347,319 357,317 358,318 358,323 355,324 348,322" style="fill: rgb(72,86,87)" /> - <polygon points="136,314 140,314 140,315 139,317 138,317 137,317 136,317" style="fill: rgb(160,100,100)" /> - <polygon points="343,69 343,66 344,66 346,67 346,69 345,71 343,71" style="fill: rgb(36,47,51)" /> - <polygon points="333,315 334,315 340,315 341,315 342,315 343,315 344,315 345,315 346,315 355,316 355,317 337,320 335,318" style="fill: rgb(122,134,132)" /> - <polygon points="295,7 295,6 296,6 297,6 298,6 299,6 300,6 301,6 302,6 302,7 301,7 300,7 299,7 298,7 297,7 296,7" style="fill: rgb(71,77,75)" /> - <polygon points="55,127 56,124 63,115 64,114 76,106 87,100 94,100 95,100 123,106 127,108 62,137 61,137 58,135 57,134 55,128" style="fill: rgb(64,40,36)" /> - <polygon points="159,55 166,51 171,52 172,53 173,54 173,55 173,56 172,56 171,56 167,56 166,56 165,56 164,56" style="fill: rgb(41,53,53)" /> - <polygon points="242,213 245,200 252,208 268,249 288,301 277,309 269,313 260,315" style="fill: rgb(234,243,252)" /> - <polygon points="351,239 351,238 352,238 354,238 356,239 357,240 358,242 358,249 357,250 355,252 353,252 352,252 351,252" style="fill: rgb(201,198,205)" /> - <polygon points="397,301 399,301 399,310 398,310" style="fill: rgb(72,86,87)" /> - <polygon points="157,377 159,374 161,373 170,369 170,370 169,371 168,372 159,378 158,378" style="fill: rgb(84,45,46)" /> - <polygon points="96,101 96,100 97,99 98,98 100,96 102,95 103,95 108,95 109,95 108,98 97,103" style="fill: rgb(64,40,36)" /> - <polygon points="144,270 144,269 158,270 159,272 158,273 156,273 144,271" style="fill: rgb(122,68,66)" /> - <polygon points="193,54 219,53 232,53 233,53 234,53 235,53 236,53 237,53 238,53 239,53 248,53 249,53 250,53 251,53 252,53 253,53 254,53 256,54 255,56 237,76 235,78 234,78 211,72 199,64" style="fill: rgb(41,53,53)" /> - <polygon points="9,342 10,333 11,332 17,328 18,329 18,332 18,333 15,341 14,342 10,344 9,344" style="fill: rgb(72,86,87)" /> - <polygon points="135,128 135,126 156,128 158,129 157,130 156,131 153,132 148,132 139,132 138,132 136,130" style="fill: rgb(172,116,115)" /> - <polygon points="135,206 138,203 139,203 145,207 144,208 140,209 137,209 136,208" style="fill: rgb(141,93,93)" /> - <polygon points="24,398 27,397 31,396 32,396 33,396 35,397 27,399 25,399" style="fill: rgb(14,14,12)" /> - <polygon points="208,331 211,326 214,326 215,326 216,326 217,326 213,331 210,333 209,333 208,333" style="fill: rgb(103,72,70)" /> - <polygon points="87,235 89,227 91,227 91,229 87,237" style="fill: rgb(141,87,87)" /> - <polygon points="199,318 203,316 204,316 204,318 204,319 204,321 200,321" style="fill: rgb(121,87,86)" /> - <polygon points="125,89 127,87 134,86 134,87 133,88 130,90 127,90" style="fill: rgb(118,100,98)" /> - <polygon points="60,113 60,112 60,111 62,106 64,106 65,107" style="fill: rgb(91,63,60)" /> - <polygon points="273,399 273,398 274,395 275,393 289,366 291,363 294,359 331,333 337,330 375,363 377,366 378,368 360,397 358,399 354,399 337,399 335,399 321,399 275,399" style="fill: rgb(201,198,205)" /> - <polygon points="67,205 68,205 70,205 71,205 79,208 84,210 87,212 87,213 86,214 79,215 78,215 76,215 71,215" style="fill: rgb(84,45,46)" /> - <polygon points="239,152 239,151 240,151 241,151 242,151 246,153 249,156 243,157 240,155" style="fill: rgb(140,126,123)" /> - <polygon points="98,101 99,99 106,97 112,97 113,97 126,104 123,107 111,109 105,108 100,107 99,106" style="fill: rgb(52,28,28)" /> - <polygon points="389,215 389,214 390,210 390,215 390,217 390,218 390,221 390,222" style="fill: rgb(201,198,205)" /> - <polygon points="254,228 263,222 272,224 273,229 273,232 273,233 273,234 273,235 271,246 270,247 260,249 257,241" style="fill: rgb(196,153,163)" /> - <polygon points="396,270 397,267 399,266 399,269 399,270 398,273 396,272" style="fill: rgb(43,56,62)" /> - <polygon points="220,160 224,137 231,132 240,139 241,140 241,141 240,164 225,163" style="fill: rgb(141,101,101)" /> - <polygon points="244,331 244,330 246,328 249,330 249,331 246,333" style="fill: rgb(196,153,163)" /> - <polygon points="20,218 20,217 21,214 22,213 26,212 31,213 32,214 33,216 34,219 34,220 30,220 23,219" style="fill: rgb(153,174,175)" /> - <polygon points="91,311 91,310 95,309 101,309 101,313 101,314 101,315 99,319 98,319 97,319 94,317 92,313" style="fill: rgb(154,99,96)" /> - <polygon points="11,344 14,334 15,333 16,333 17,334 19,337 19,338 16,341 15,342" style="fill: rgb(53,70,77)" /> - <polygon points="78,143 79,142 83,138 84,139 84,140 82,144 80,146 79,145 78,144" style="fill: rgb(176,110,112)" /> - <polygon points="232,132 232,131 233,131 243,132 247,136 250,142 247,142 239,140 236,138 235,137 234,136 233,135 232,134" style="fill: rgb(105,95,93)" /> - <polygon points="169,391 171,388 172,387 173,386 182,383 183,383 184,383 185,383 186,383 187,384 186,385 175,394 174,394 173,394 172,394 170,393 169,392" style="fill: rgb(138,113,109)" /> - <polygon points="177,78 179,77 181,77 182,77 184,78 181,81 179,82 178,82" style="fill: rgb(64,40,36)" /> - <polygon points="107,199 108,198 109,198 110,199 111,202 111,203 109,202 108,201 107,200" style="fill: rgb(188,143,140)" /> - <polygon points="190,371 196,365 197,366 193,371 191,373 190,373" style="fill: rgb(110,74,74)" /> - <polygon points="74,133 74,132 76,129 77,128 79,126 80,125 80,126 75,133" style="fill: rgb(132,78,78)" /> - <polygon points="110,59 113,55 116,53 114,58 113,60 112,60" style="fill: rgb(184,119,123)" /> - <polygon points="279,236 280,234 281,234 287,243 289,248 286,253 284,252 279,237" style="fill: rgb(168,139,141)" /> - <polygon points="119,182 119,181 130,181 131,181 129,182 126,183 120,183" style="fill: rgb(64,40,36)" /> - <polygon points="65,372 71,368 73,368 72,370 70,373 69,373 68,373 67,373" style="fill: rgb(31,35,36)" /> - <polygon points="190,110 191,108 192,109 195,112 195,113 194,115 192,113 191,112" style="fill: rgb(138,113,109)" /> - <polygon points="135,393 136,392 142,387 146,385 152,390 150,392" style="fill: rgb(103,72,70)" /> - <polygon points="394,315 395,279 396,278 399,277 397,328 396,328 395,328 394,317" style="fill: rgb(122,134,132)" /> - <polygon points="67,86 71,83 76,84 77,85 78,86 78,89 74,89 72,89 70,89 69,89" style="fill: rgb(136,135,140)" /> - <polygon points="58,213 59,213 61,213 62,214 62,216 60,218 58,216" style="fill: rgb(24,24,24)" /> - <polygon points="49,284 50,283 51,283 52,283 53,283 54,285 51,285 50,285" style="fill: rgb(47,48,50)" /> - <polygon points="84,391 86,389 87,389 88,389 89,389 90,389 90,392 89,393 86,392" style="fill: rgb(136,135,140)" /> - <polygon points="141,85 142,85 143,85 144,85 147,86 147,87 142,91 141,90" style="fill: rgb(105,95,93)" /> - <polygon points="224,352 224,349 225,348 227,347 230,349 230,350 225,353" style="fill: rgb(172,116,115)" /> - <polygon points="115,370 117,370 123,371 124,373 116,374" style="fill: rgb(50,51,53)" /> - <polygon points="135,394 142,390 144,389 145,389 146,389 147,389 148,389 156,390 156,391 155,392 153,394 152,395 151,395 150,395" style="fill: rgb(115,74,72)" /> - <polygon points="26,170 28,169 29,169 30,169 30,176 28,175" style="fill: rgb(102,87,84)" /> - <polygon points="45,22 47,20 49,19 51,19 52,20 53,21 53,22 53,25 51,28 47,25" style="fill: rgb(208,174,188)" /> - <polygon points="243,245 243,244 244,244 245,244 246,247 247,252 247,253 246,254 243,249" style="fill: rgb(168,139,141)" /> - <polygon points="238,337 238,336 238,325 238,324 242,319 243,318 244,317 245,317 247,322 247,326 245,334 243,337 240,340 239,339" style="fill: rgb(168,139,141)" /> - <polygon points="68,157 68,156 75,150 75,153 70,172 68,158" style="fill: rgb(165,105,105)" /> - <polygon points="167,322 169,321 172,323 172,325 169,325 168,325 167,324" style="fill: rgb(115,74,72)" /> - <polygon points="26,374 27,374 40,374 41,374 42,374 43,374 38,377 37,377 36,377" style="fill: rgb(24,24,24)" /> - <polygon points="251,160 251,159 252,158 272,157 274,157 277,163 278,171 275,172 274,172 273,172 272,172 271,172 268,171 262,169 254,166 253,165" style="fill: rgb(168,139,141)" /> - <polygon points="244,229 244,228 245,228 247,231 248,234 249,238 247,238 246,236" style="fill: rgb(196,153,163)" /> - <polygon points="121,260 125,258 127,257 135,254 136,254 137,254 147,257 148,258 149,259 143,262 139,263 129,262 124,261" style="fill: rgb(184,119,123)" /> - <polygon points="256,182 260,180 261,180 262,180 264,181 265,182 266,190 256,183" style="fill: rgb(132,78,78)" /> - <polygon points="114,325 117,323 120,324 119,327 118,327 117,327 116,327" style="fill: rgb(122,68,66)" /> - <polygon points="155,386 166,374 168,373 177,370 178,370 179,370 180,370 180,373 177,376 158,388 157,388" style="fill: rgb(103,72,70)" /> - <polygon points="112,206 112,205 113,198 114,198 120,203 120,206 114,207 113,207" style="fill: rgb(162,128,129)" /> - <polygon points="138,254 140,252 146,253 146,254 146,255 146,258 143,259 141,259 140,259 139,259" style="fill: rgb(172,116,115)" /> - <polygon points="303,182 303,181 304,181 305,181 306,184 307,187 307,190 307,191 306,192 305,192 303,190" style="fill: rgb(140,154,155)" /> - <polygon points="129,319 130,316 135,311 136,311 134,320 129,320" style="fill: rgb(156,92,93)" /> - <polygon points="130,230 133,223 136,222 138,225 138,226 138,227 136,229" style="fill: rgb(172,116,115)" /> - <polygon points="238,105 239,104 244,110 246,113 239,108" style="fill: rgb(103,72,70)" /> - <polygon points="107,278 107,277 107,274 110,272 114,275 115,277 115,279 114,280 111,282 107,280" style="fill: rgb(122,68,66)" /> - <polygon points="225,168 226,167 228,166 237,168 236,169 235,169 226,169" style="fill: rgb(147,129,125)" /> - <polygon points="84,380 85,376 86,374 89,374 89,377 88,379" style="fill: rgb(31,35,36)" /> - <polygon points="190,230 190,225 201,181 206,178 210,178 211,178 213,181 237,220 237,222 237,224 230,270 229,272 216,270 215,269 195,241 191,233" style="fill: rgb(201,198,205)" /> - <polygon points="93,349 94,349 100,351 101,352 102,356 97,353 96,352" style="fill: rgb(64,40,36)" /> - <polygon points="118,308 118,306 119,305 120,304 121,303 122,303 123,304 124,307 119,308" style="fill: rgb(115,74,72)" /> - <polygon points="26,273 27,270 31,261 35,256 36,255 35,259 29,272 28,274" style="fill: rgb(122,134,132)" /> - <polygon points="58,335 59,333 62,329 63,328 65,328 78,333 77,335 76,337 75,338 73,339 71,340 69,341 63,340 61,339" style="fill: rgb(28,32,31)" /> - <polygon points="87,127 89,126 90,126 91,126 92,126 93,126 94,126 95,126 96,126 95,127 91,129 89,129 87,128" style="fill: rgb(163,107,106)" /> - <polygon points="69,86 73,76 82,75 83,75 83,77 83,78 82,81 78,84 75,86" style="fill: rgb(153,174,175)" /> - <polygon points="95,131 105,126 110,124 110,127 103,130 99,131 96,131" style="fill: rgb(163,107,106)" /> - <polygon points="344,104 344,102 344,100 344,98 350,107 350,123 350,126 349,126 348,126 347,126 344,105" style="fill: rgb(43,56,62)" /> - <polygon points="11,267 11,266 11,265 11,264 11,263 16,262 17,262 21,264 22,269 22,271 12,273" style="fill: rgb(153,174,175)" /> - <polygon points="0,142 10,149 9,150 8,150 0,147" style="fill: rgb(103,72,70)" /> - <polygon points="6,392 7,390 20,376 22,375 32,375 33,375 34,375 70,383 70,384 38,399 37,399 15,399 7,394" style="fill: rgb(14,14,12)" /> - <polygon points="31,195 31,194 31,193 31,192 31,191 31,190 33,190 36,199 36,200 36,201 36,202 34,203" style="fill: rgb(91,63,60)" /> - <polygon points="74,363 75,363 76,363 77,363 78,363 78,365 78,366 77,366" style="fill: rgb(28,32,31)" /> - <polygon points="200,299 203,297 206,297 208,299 208,300 204,301 203,301" style="fill: rgb(168,139,141)" /> - <polygon points="106,22 107,22 109,22 115,28 117,30 118,31 118,32 117,33 112,29 107,24" style="fill: rgb(53,70,77)" /> - <polygon points="165,143 169,145 171,148 171,150 170,150 168,148 167,147 166,145" style="fill: rgb(188,143,140)" /> - <polygon points="235,263 235,261 238,255 239,254 239,255 238,263 237,264 235,264 235,261 238,255 239,254 239,255 238,263 237,264 235,264 235,261 238,255 239,254 239,255 238,263" style="fill: rgb(162,128,129)" /> - <polygon points="89,340 90,339 93,340 93,342 93,344 90,341" style="fill: rgb(110,74,74)" /> - <polygon points="122,297 123,297 127,298 128,299 129,300 125,301 123,301" style="fill: rgb(151,95,96)" /> - <polygon points="100,174 101,170 121,135 135,129 145,130 146,131 147,132 135,149 109,179 106,181 102,179 101,178" style="fill: rgb(187,128,132)" /> - <polygon points="51,24 51,18 51,17 52,15 54,13 60,21 54,24 52,25" style="fill: rgb(201,198,205)" /> - <polygon points="125,341 125,340 125,339 125,338 125,337 126,336 131,333 132,334 133,335 136,338 136,339 128,347 127,347" style="fill: rgb(141,87,87)" /> - <polygon points="58,283 58,281 58,280 59,280 61,288 62,292 59,293 58,284" style="fill: rgb(47,48,50)" /> - <polygon points="23,116 25,116 27,117 28,118 28,119 27,121 26,121" style="fill: rgb(50,51,53)" /> - <polygon points="50,126 52,123 65,109 67,108 67,109 67,112 63,117 55,126" style="fill: rgb(91,63,60)" /> - <polygon points="197,108 202,110 205,113 205,114 203,114 197,110" style="fill: rgb(138,113,109)" /> - <polygon points="227,313 228,308 230,303 232,306 229,311 228,312" style="fill: rgb(110,74,74)" /> - <polygon points="84,309 85,308 87,308 88,309 90,311 91,313 90,316 89,316 88,316" style="fill: rgb(154,99,96)" /> - <polygon points="59,130 59,128 63,123 64,123 65,123 66,124 67,125 67,126 67,127 65,131 63,133 60,135" style="fill: rgb(52,28,28)" /> - <polygon points="258,162 258,160 267,158 268,158 271,161 271,169 270,169 264,166 260,164" style="fill: rgb(168,139,141)" /> - <polygon points="303,291 315,289 324,289 326,303 322,305 304,293" style="fill: rgb(71,77,75)" /> - <polygon points="65,159 65,155 66,154 67,154 67,157 67,159 67,160 67,161 67,163 67,164 67,165 66,164" style="fill: rgb(154,99,96)" /> - <polygon points="65,91 67,89 68,88 70,90 70,91 68,92 66,92" style="fill: rgb(130,119,115)" /> - <polygon points="148,378 154,349 161,345 164,346 167,348 168,353 164,371 154,382 153,382 151,381" style="fill: rgb(64,40,36)" /> - <polygon points="122,181 122,180 123,178 129,175 134,174 142,174 141,175 140,176 135,179 131,180 126,181 123,181" style="fill: rgb(52,28,28)" /> - <polygon points="0,110 1,107 3,104 5,103 6,104 6,109 5,111 0,114" style="fill: rgb(50,51,53)" /> - <polygon points="71,149 73,150 73,151 72,158 71,158" style="fill: rgb(163,103,105)" /> - <polygon points="97,125 99,124 103,123 104,123 104,124 103,125 102,125" style="fill: rgb(165,105,105)" /> - <polygon points="231,286 232,278 234,276 234,283 232,287" style="fill: rgb(147,129,125)" /> - <polygon points="129,347 134,346 135,350 134,351 133,352 130,355 129,354" style="fill: rgb(103,52,51)" /> - <polygon points="215,167 216,165 219,162 222,164 224,169 224,172 223,172" style="fill: rgb(147,129,125)" /> - <polygon points="172,305 173,303 178,298 180,298 181,300 177,303" style="fill: rgb(141,93,93)" /> - <polygon points="171,121 173,118 174,118 175,119 175,120 175,121 175,122 175,123 171,122" style="fill: rgb(168,139,141)" /> - <polygon points="295,262 302,262 303,262 305,263 299,264 298,264 296,263" style="fill: rgb(97,113,113)" /> - <polygon points="31,302 31,301 39,287 43,285 45,285 58,285 65,299 78,328 77,331 57,337 55,336" style="fill: rgb(35,39,40)" /> - <polygon points="305,215 305,211 305,207 305,205 306,212 306,215 306,216 306,217 306,218 306,223 305,222" style="fill: rgb(122,134,132)" /> - <polygon points="85,100 87,98 89,96 99,96 99,97 96,99 92,101 85,101" style="fill: rgb(74,50,46)" /> - <polygon points="71,342 78,334 83,338 82,340 71,343" style="fill: rgb(35,39,40)" /> - <polygon points="40,378 41,378 43,378 44,378 45,378 45,381 44,381 40,379" style="fill: rgb(13,13,13)" /> - <polygon points="96,133 99,133 102,133 102,134 101,135 99,136 98,136 97,136" style="fill: rgb(176,110,112)" /> - <polygon points="300,142 300,138 300,134 300,132 301,131 359,128 389,127 390,131 394,190 394,192 371,249 369,250 364,251 356,252 355,251 301,178 300,144" style="fill: rgb(234,243,252)" /> - <polygon points="318,208 320,206 327,206 335,210 335,211 334,211 333,211 329,211 319,210 318,209" style="fill: rgb(122,134,132)" /> - <polygon points="33,11 33,10 35,10 37,18 37,21 34,22" style="fill: rgb(122,134,132)" /> - <polygon points="200,74 203,72 204,72 205,73 204,80 203,80 201,79" style="fill: rgb(118,100,98)" /> - <polygon points="89,370 89,369 89,368 92,364 93,366 94,369 94,371 90,371" style="fill: rgb(50,51,53)" /> - <polygon points="71,389 72,388 80,384 78,387 73,389 72,389" style="fill: rgb(31,35,36)" /> - <polygon points="142,273 143,273 149,273 150,274 149,276 148,276 143,275" style="fill: rgb(141,101,101)" /> - <polygon points="87,163 88,162 93,158 93,161 93,162 92,163 89,165 88,164" style="fill: rgb(172,116,115)" /> - <polygon points="271,197 273,195 274,199 274,200 274,201 274,202 274,203 271,198" style="fill: rgb(156,92,93)" /> - <polygon points="398,131 398,128 399,128 399,145 399,146" style="fill: rgb(97,113,113)" /> - <polygon points="158,340 161,336 164,336 164,337 163,339 160,342" style="fill: rgb(103,72,70)" /> - <polygon points="33,170 33,166 35,162 39,162 39,163 39,164 39,165 39,166 39,167" style="fill: rgb(74,50,46)" /> - <polygon points="304,252 305,251 306,251 307,251 308,251 309,251 310,251 312,253 310,253 305,253 304,253" style="fill: rgb(72,86,87)" /> - <polygon points="61,280 61,275 62,275 63,278 63,282 62,282" style="fill: rgb(121,87,86)" /> - <polygon points="111,299 111,298 117,291 118,290 119,290 120,290 122,290 123,290 124,291 119,301 115,301 112,301 111,300" style="fill: rgb(156,92,93)" /> - <polygon points="80,124 80,123 81,122 83,120 87,118 92,116 96,115 100,114 101,114 99,116" style="fill: rgb(115,74,72)" /> - <polygon points="129,219 130,218 131,218 134,218 134,219 134,220 133,221 131,221 130,221 129,220" style="fill: rgb(176,110,112)" /> - <polygon points="1,381 3,378 5,377 6,377 6,381 6,382 4,383 1,383" style="fill: rgb(47,48,50)" /> - <polygon points="198,120 198,116 201,115 205,116 206,118 207,122 204,125 203,125" style="fill: rgb(168,139,141)" /> - <polygon points="345,0 347,0 351,0 367,0 372,0 374,0 375,8 384,115 384,123 382,124 381,124 380,124 379,124 378,124 349,82 346,31 345,13" style="fill: rgb(97,113,113)" /> - <polygon points="359,253 373,241 375,240 378,239 383,238 388,237 389,237 391,240 391,250 391,251 391,252 390,277 360,282" style="fill: rgb(140,154,155)" /> - <polygon points="93,399 93,398 94,395 101,391 103,390 109,391 107,393 103,397 101,399 99,399 94,399" style="fill: rgb(122,134,132)" /> - <polygon points="138,182 146,182 148,183 147,185 141,186 140,186 138,184" style="fill: rgb(141,101,101)" /> - <polygon points="39,244 39,242 40,235 42,235 43,237 43,238 42,241 40,244" style="fill: rgb(122,134,132)" /> - <polygon points="225,314 225,313 225,311 226,310 227,310 229,312 230,314 227,315 225,315" style="fill: rgb(121,87,86)" /> - <polygon points="134,329 137,325 139,323 141,327 141,328 141,329 137,331 134,330" style="fill: rgb(141,87,87)" /> - <polygon points="144,60 144,58 148,62 149,63 150,64 151,65 152,66 153,67 154,68 159,74 157,74 156,74 155,74 154,73" style="fill: rgb(201,198,205)" /> - <polygon points="372,204 372,203 372,202 377,201 383,200 384,200 385,200 388,201 388,202 383,222" style="fill: rgb(153,174,175)" /> - <polygon points="315,278 315,277 322,285 321,287 320,287 319,287 318,287 317,287 316,287 315,287" style="fill: rgb(140,154,155)" /> - <polygon points="155,115 157,112 159,110 161,110 161,114 160,119 157,119 156,119 155,119" style="fill: rgb(121,87,86)" /> - <polygon points="20,333 20,332 21,332 26,335 25,336 21,337" style="fill: rgb(28,32,31)" /> - <polygon points="90,373 91,372 92,372 93,372 94,372 95,372 97,373" style="fill: rgb(36,47,51)" /> - <polygon points="123,185 127,184 132,183 133,189 124,197" style="fill: rgb(115,74,72)" /> - <polygon points="339,296 341,290 349,289 351,289 351,300 351,301 339,297" style="fill: rgb(153,174,175)" /> - <polygon points="192,353 193,347 199,339 201,338 206,347 201,352 192,357" style="fill: rgb(121,87,86)" /> - <polygon points="17,99 18,97 20,95 21,95 22,95 23,95 24,95 37,99 38,100 37,105 21,109 20,109 18,106 17,104" style="fill: rgb(47,48,50)" /> - <polygon points="79,390 79,389 80,389 81,389 83,394 82,397 80,399 79,396" style="fill: rgb(122,134,132)" /> - <polygon points="192,380 199,379 198,381 195,384 194,385 193,385 192,381" style="fill: rgb(138,113,109)" /> - <polygon points="256,143 258,133 259,134 259,141 259,143 259,144 259,145 257,144" style="fill: rgb(138,113,109)" /> - <polygon points="141,211 141,209 143,208 146,207 147,207 149,207 149,211 149,212 142,212" style="fill: rgb(154,99,96)" /> - <polygon points="40,174 41,169 44,163 45,164 48,170 51,178 49,178 48,178 42,175" style="fill: rgb(103,72,70)" /> - <polygon points="87,114 90,111 112,109 113,109 115,110 91,114 90,114" style="fill: rgb(84,45,46)" /> - <polygon points="352,281 360,279 360,280 359,287" style="fill: rgb(97,113,113)" /> - <polygon points="107,236 118,228 119,229 126,238 124,239 118,240 115,240 114,240" style="fill: rgb(187,128,132)" /> - <polygon points="130,344 133,341 136,341 137,343 139,347 139,348 139,349 132,351 131,351 130,346" style="fill: rgb(91,63,60)" /> - <polygon points="62,234 62,233 63,231 67,227 68,227 69,227 69,228 66,234" style="fill: rgb(13,13,13)" /> - <polygon points="139,182 145,179 150,183 149,184 146,185 140,183" style="fill: rgb(159,108,107)" /> - <polygon points="163,103 166,100 168,98 169,98 169,102 168,106" style="fill: rgb(147,129,125)" /> - <polygon points="176,354 176,353 180,337 181,336 196,328 198,330 198,331 198,334 196,346 192,352 189,355" style="fill: rgb(103,72,70)" /> - <polygon points="296,356 299,351 302,350 302,352 302,353 299,356 298,356" style="fill: rgb(201,198,205)" /> - <polygon points="102,345 103,340 104,340 105,340 105,344 102,346" style="fill: rgb(64,40,36)" /> - <polygon points="13,353 13,350 14,349 15,350 22,363 23,365 22,365 21,365 17,362 13,355" style="fill: rgb(35,39,40)" /> - <polygon points="77,133 77,132 79,129 82,125 89,120 92,119 93,119 92,121" style="fill: rgb(154,99,96)" /> - <polygon points="82,391 82,389 82,388 83,387 85,387 86,387 92,387 93,387 91,389 83,393 82,393" style="fill: rgb(169,159,160)" /> - <polygon points="95,340 96,336 97,335 98,334 99,334 103,338 103,339 98,341" style="fill: rgb(84,45,46)" /> - <polygon points="131,173 134,172 139,171 144,171 147,172 146,173 145,174 135,174" style="fill: rgb(74,50,46)" /> - <polygon points="388,256 388,255 389,238 390,237 391,237 392,239 393,243 393,250 393,251 393,277 391,277" style="fill: rgb(140,154,155)" /> - <polygon points="41,214 43,214 43,219 42,220 41,216" style="fill: rgb(74,50,46)" /> - <polygon points="342,281 343,261 347,257 349,258 350,259 353,263 354,272 354,276 354,280 351,281 348,281 347,281" style="fill: rgb(97,113,113)" /> - <polygon points="56,388 57,387 61,386 62,386 63,386 66,388 59,389 57,389" style="fill: rgb(27,28,30)" /> - <polygon points="36,363 37,363 54,363 52,363 53,363 50,363 51,363 48,363 49,363 46,363 47,363 44,363 45,363 42,363 43,363 40,363 41,363 38,363 39,363" style="fill: rgb(24,24,24)" /> - <polygon points="46,237 46,236 46,235 46,234 47,235 49,240 49,242 47,240" style="fill: rgb(64,40,36)" /> - <polygon points="260,208 260,205 262,206 265,208 266,209 268,212 269,214 269,215 269,217 267,220 264,220 263,219" style="fill: rgb(156,92,93)" /> - <polygon points="239,120 239,119 241,115 243,116 244,117 245,118 245,119 244,122" style="fill: rgb(24,24,24)" /> - <polygon points="170,70 171,65 174,62 175,63 176,64 175,68 171,71" style="fill: rgb(71,77,75)" /> - <polygon points="99,375 100,374 103,374 104,374 105,374 106,374 110,377 110,378 105,380 104,380 100,376" style="fill: rgb(35,39,40)" /> - <polygon points="93,291 93,290 94,285 97,284 96,290" style="fill: rgb(84,45,46)" /> - <polygon points="59,181 67,158 69,159 69,174 67,177 64,181 60,184 59,183" style="fill: rgb(156,92,93)" /> - <polygon points="342,228 342,224 342,223 342,220 343,220 346,221 350,233 350,234 347,233 342,231" style="fill: rgb(234,243,252)" /> - <polygon points="5,388 10,381 11,380 12,379 15,376 22,374 18,381 11,389" style="fill: rgb(24,24,24)" /> - <polygon points="234,156 237,155 240,156 242,158 242,159 238,158 235,157" style="fill: rgb(102,87,84)" /> - <polygon points="117,383 120,382 122,382 126,384 126,385 123,387 118,384" style="fill: rgb(136,135,140)" /> - <polygon points="96,259 99,257 100,257 103,258 105,260 104,260" style="fill: rgb(103,52,51)" /> - <polygon points="382,58 382,57 382,56 383,49 389,37 390,37 398,52 399,55 399,56 399,67 398,75 389,85 387,83 384,77 383,73" style="fill: rgb(31,35,36)" /> - <polygon points="120,74 120,72 121,72 127,72 128,72 129,73 125,75 123,76 121,76" style="fill: rgb(130,119,115)" /> - <polygon points="357,315 359,314 360,314 361,314 361,316 360,324" style="fill: rgb(97,113,113)" /> - <polygon points="343,14 343,13 343,10 343,9 343,7 343,6 344,12 344,14 344,16 344,19 344,20 343,18 343,6 344,12 344,14 344,16 344,19 344,20 343,18 343,6 344,12 344,14" style="fill: rgb(36,47,51)" /> - <polygon points="379,10 379,9 379,0 383,0 399,0 399,10 399,12 399,14 399,17 399,21 399,25 399,29 399,30 398,31 390,32 389,32 388,32 387,32 382,32 381,31 380,29 379,13" style="fill: rgb(36,47,51)" /> - <polygon points="120,275 120,271 122,270 123,270 124,270 125,270 126,270 127,275 123,275 122,275 121,275" style="fill: rgb(122,68,66)" /> - <polygon points="15,305 15,304 17,307 19,310 18,314 16,310 15,307 15,306" style="fill: rgb(86,87,89)" /> - <polygon points="265,225 266,223 267,223 268,224 268,225 268,226 268,227 268,228 267,228 266,227" style="fill: rgb(201,198,205)" /> - <polygon points="223,189 224,188 225,188 229,189 228,192 223,191" style="fill: rgb(196,153,163)" /> - <polygon points="202,111 203,106 204,105 207,103 209,104 210,105 211,106 215,116 213,116 206,115 203,112" style="fill: rgb(118,100,98)" /> - <polygon points="41,183 43,174 44,174 55,176 44,200 42,189" style="fill: rgb(132,78,78)" /> - <polygon points="66,119 67,119 69,120 70,121 70,122 70,123 69,123 67,122 66,121" style="fill: rgb(18,18,18)" /> - <polygon points="34,190 35,188 37,187 39,191 39,193 39,194 38,200 37,201 34,191" style="fill: rgb(64,40,36)" /> - <polygon points="91,246 100,249 103,251 101,251 97,250 93,249" style="fill: rgb(165,109,110)" /> - <polygon points="375,5 375,1 375,0 376,0 377,3 384,105 384,107 384,114 383,109 381,96 376,39" style="fill: rgb(72,86,87)" /> - <polygon points="0,380 0,376 2,375 11,375 13,375 12,377 8,384 2,383 0,381" style="fill: rgb(47,48,50)" /> - <polygon points="119,91 122,90 126,90 131,91 132,92 133,93 132,93 131,93 130,93 122,93" style="fill: rgb(121,87,86)" /> - <polygon points="76,103 78,102 80,102 82,103 81,104 80,105 78,106" style="fill: rgb(103,72,70)" /> - <polygon points="28,19 28,17 28,14 29,13 30,13 31,18 29,29 28,21" style="fill: rgb(71,77,75)" /> - <polygon points="44,374 66,374 74,376 76,383 73,384 46,378 45,377" style="fill: rgb(14,14,12)" /> - <polygon points="40,206 41,201 42,201 43,206 43,208 43,210 42,212 41,212 40,212" style="fill: rgb(74,50,46)" /> - <polygon points="6,111 8,109 17,106 19,108 19,109 12,117 11,118 10,119 7,116 6,112" style="fill: rgb(43,56,62)" /> - <polygon points="76,207 78,203 81,205 84,209 83,209 82,209 81,209 78,208" style="fill: rgb(103,52,51)" /> - <polygon points="5,202 5,201 6,194 9,193 13,193 18,194 19,195 21,198 21,200 21,201 19,204 16,204 7,204 6,203" style="fill: rgb(153,174,175)" /> - <polygon points="3,239 4,238 6,241 6,242 6,243 6,244 6,245 3,245" style="fill: rgb(122,134,132)" /> - <polygon points="157,302 161,294 168,292 169,292 169,293 160,307 158,306" style="fill: rgb(165,109,110)" /> - <polygon points="55,186 55,185 55,183 57,181 58,180 60,179 58,185 57,186 56,186" style="fill: rgb(151,95,96)" /> - <polygon points="213,73 214,71 216,71 222,72 219,73 214,74" style="fill: rgb(36,47,51)" /> - <polygon points="43,20 43,18 45,0 47,0 49,0 51,0 53,0 55,0 57,0 59,0 60,0 62,1 64,4 108,74 56,101 54,98 53,93 43,32" style="fill: rgb(153,174,175)" /> - <polygon points="19,392 20,391 22,389 24,390 24,391 22,393 21,393 20,393" style="fill: rgb(24,24,24)" /> - <polygon points="278,134 279,131 287,131 286,135 279,138 278,137" style="fill: rgb(71,77,75)" /> - <polygon points="126,97 128,97 130,98 131,99 130,101 129,101 128,101 127,101" style="fill: rgb(84,45,46)" /> - <polygon points="78,149 78,148 86,139 92,135 106,130 113,128 114,128 115,128 123,128 134,130 134,131 134,132 127,140 126,141 122,144 91,162 86,164 83,165 82,165 79,156 78,151" style="fill: rgb(172,116,115)" /> - <polygon points="73,342 74,341 78,339 82,338 81,341 77,344" style="fill: rgb(31,35,36)" /> - <polygon points="134,364 134,363 142,362 145,362 151,366 150,372 140,375 139,375 135,369 134,365" style="fill: rgb(52,28,28)" /> - <polygon points="224,111 229,107 232,106 235,105 235,106 231,111 227,112" style="fill: rgb(74,50,46)" /> - <polygon points="45,161 45,160 45,159 51,152 58,144 60,143 61,143 61,144 55,158 50,169" style="fill: rgb(103,52,51)" /> - <polygon points="71,138 73,134 77,129 82,124 84,123 76,134" style="fill: rgb(141,87,87)" /> - <polygon points="98,201 98,199 100,202 101,204 102,207 101,211 100,211" style="fill: rgb(176,110,112)" /> - <polygon points="51,246 51,245 52,245 53,245 56,246 56,247 56,251 54,251" style="fill: rgb(64,40,36)" /> - <polygon points="47,344 57,340 65,339 66,339 67,340 68,341 68,342 68,343 67,344 62,345 48,345" style="fill: rgb(28,32,31)" /> - <polygon points="6,114 8,110 9,110 10,110 14,110 15,110 12,113 8,115 7,115" style="fill: rgb(43,56,62)" /> - <polygon points="61,0 62,0 63,0 67,0 71,0 75,0 77,0 81,3 140,55 144,59 145,60 152,67 159,75 145,79 141,80 137,81 135,81 134,81 133,81 86,72 85,71 71,42" style="fill: rgb(201,198,205)" /> - <polygon points="151,262 152,262 155,265 156,267 156,268 154,267 152,265" style="fill: rgb(132,78,78)" /> - <polygon points="34,170 34,168 35,167 38,165 38,166 38,170 38,171 38,172 37,172 35,171" style="fill: rgb(52,28,28)" /> - <polygon points="99,246 102,245 106,244 108,244 117,244 118,244 119,244 120,244 120,245 109,248 108,248" style="fill: rgb(187,128,132)" /> - <polygon points="126,191 129,190 135,189 136,189 130,195 128,194" style="fill: rgb(122,68,66)" /> - <polygon points="34,262 35,261 49,249 50,250 51,251 50,256 48,261 46,266 44,271 42,275 39,274 34,263" style="fill: rgb(97,113,113)" /> - <polygon points="74,270 75,268 76,268 81,269 82,271 82,272 81,277 79,278 77,277 74,271" style="fill: rgb(163,103,105)" /> - <polygon points="207,353 207,352 208,351 209,351 212,352 212,353 211,354 209,354 208,354 207,354" style="fill: rgb(123,89,88)" /> - <polygon points="37,369 37,368 39,368 43,368 44,368 49,370 51,373 44,373 40,373 39,372" style="fill: rgb(35,39,40)" /> - <polygon points="304,227 306,225 310,226 337,250 338,251 338,252 329,255 320,254 317,253 305,244" style="fill: rgb(122,134,132)" /> - <polygon points="230,185 231,183 232,183 234,185 234,188 233,192 232,193 231,189" style="fill: rgb(168,139,141)" /> - <polygon points="28,384 28,381 29,381 33,381 35,382 32,390 31,390" style="fill: rgb(14,14,12)" /> - <polygon points="3,227 5,221 6,221 12,221 13,221 14,221 15,221 16,221 17,221 18,221 27,222 31,223 34,224 37,228 38,232 38,233 32,233 30,233 29,233 17,232 9,231 4,230" style="fill: rgb(153,174,175)" /> - <polygon points="361,293 361,292 361,291 361,290 361,284 361,283 361,282 361,281 363,280 371,279 383,278 390,278 391,278 392,278 393,302 393,310 392,313 366,327 364,326 362,313 361,295" style="fill: rgb(153,174,175)" /> - <polygon points="126,234 126,233 129,234 131,236 132,237 133,238 134,239 134,240 128,237" style="fill: rgb(188,143,140)" /> - <polygon points="186,397 189,393 194,387 195,387 196,387 211,398 212,399 207,399 204,399 203,399 198,399 197,399 196,399 195,399 194,399 193,399" style="fill: rgb(201,198,205)" /> - <polygon points="97,201 97,200 98,202 100,206 100,209 100,210 97,205" style="fill: rgb(169,103,107)" /> - <polygon points="195,90 197,88 200,87 200,90 200,92 199,92 198,92" style="fill: rgb(85,74,68)" /> - <polygon points="143,230 144,230 148,231 150,232 151,233 152,234 151,236 149,236 144,232" style="fill: rgb(169,103,107)" /> - <polygon points="58,391 60,388 61,387 62,387 65,389 64,390 62,392 60,392 59,392" style="fill: rgb(28,32,31)" /> - <polygon points="148,390 151,387 183,368 196,362 196,363 196,364 195,366 192,371 190,374 151,394 149,392" style="fill: rgb(110,74,74)" /> - <polygon points="252,294 252,293 253,291 256,291 257,293 257,294 255,301" style="fill: rgb(196,153,163)" /> - <polygon points="299,265 301,264 302,264 305,264 306,264 307,264 307,265 306,265 305,265" style="fill: rgb(140,154,155)" /> - <polygon points="79,381 81,380 87,379 89,380 89,383 89,384 87,386 79,382" style="fill: rgb(35,39,40)" /> - <polygon points="3,304 5,296 7,296 7,297 7,300 7,301 6,310 5,309 4,308 3,307" style="fill: rgb(105,95,93)" /> - <polygon points="12,160 13,160 16,160 17,160 18,160 20,161 20,162 14,162" style="fill: rgb(97,113,113)" /> - <polygon points="278,195 281,195 284,195 285,201 285,202 285,203 285,204 282,203" style="fill: rgb(153,174,175)" /> - <polygon points="299,290 300,288 305,286 310,286 313,288" style="fill: rgb(122,134,132)" /> - <polygon points="254,198 261,193 263,192 264,193 262,195 255,198" style="fill: rgb(184,119,123)" /> - <polygon points="12,294 12,293 13,293 14,294 16,301 15,302 14,301 13,298" style="fill: rgb(111,107,106)" /> - <polygon points="75,120 79,117 85,114 84,117 77,121 75,121" style="fill: rgb(84,45,46)" /> - <polygon points="194,342 197,328 198,327 205,326 197,345 196,345" style="fill: rgb(74,50,46)" /> - <polygon points="2,116 2,115 6,115 11,120 10,123 9,124 5,125 4,125 3,124 2,119" style="fill: rgb(47,48,50)" /> - <polygon points="249,275 254,275 256,275 255,277 252,279 251,278" style="fill: rgb(196,153,163)" /> - <polygon points="4,319 6,311 7,309 8,313 8,316 5,320" style="fill: rgb(71,77,75)" /> - <polygon points="274,226 278,217 278,223 277,227" style="fill: rgb(187,128,132)" /> - <polygon points="254,199 263,194 266,194 267,195 272,206 272,211 255,200" style="fill: rgb(196,153,163)" /> - <polygon points="230,166 231,164 232,164 238,165 239,166 239,167 238,167 237,167 236,167" style="fill: rgb(138,113,109)" /> - <polygon points="206,304 207,302 208,302 212,305 213,306 213,307 207,309" style="fill: rgb(159,108,107)" /> - <polygon points="16,302 18,303 19,304 20,307 20,308 19,309 18,308 16,303" style="fill: rgb(97,113,113)" /> - <polygon points="14,346 17,342 19,340 21,339 23,340 26,342 25,343 19,348 18,348 16,348" style="fill: rgb(35,39,40)" /> - <polygon points="21,300 21,298 21,292 23,290 24,290 29,293 27,303 26,304 25,304 24,304 23,304" style="fill: rgb(53,70,77)" /> - <polygon points="228,188 229,187 230,186 232,194 232,195 231,195 229,194 228,193" style="fill: rgb(196,153,163)" /> - <polygon points="106,339 110,336 114,338 116,341 116,343 116,344 113,345 110,344 107,343 106,342" style="fill: rgb(103,52,51)" /> - <polygon points="95,121 110,118 115,118 125,123 126,124 125,124 97,123 96,122" style="fill: rgb(160,100,100)" /> - <polygon points="343,54 343,52 343,48 344,46 345,46 346,46 346,47 345,57 343,55" style="fill: rgb(35,39,40)" /> - <polygon points="85,175 85,171 86,170 87,171 88,172 89,174 89,176 86,177" style="fill: rgb(163,107,106)" /> - <polygon points="155,99 162,100 164,105 163,107 162,107 158,106 157,105 155,100" style="fill: rgb(147,129,125)" /> - <polygon points="63,182 64,179 69,173 71,174 71,175 70,181 66,189 64,186" style="fill: rgb(163,103,105)" /> - <polygon points="122,280 124,276 125,275 128,280 123,282 122,282 122,281" style="fill: rgb(141,87,87)" /> - <polygon points="0,59 5,59 6,59 18,60 26,61 31,65 33,70 36,78 38,95 38,96 37,98 35,100 34,101 16,107 12,108 7,108 0,103" style="fill: rgb(43,56,62)" /> - <polygon points="121,244 125,243 134,242 134,243 133,244 128,244 124,244" style="fill: rgb(196,153,163)" /> - <polygon points="55,346 69,344 68,347 67,349 64,350 59,350 56,348" style="fill: rgb(24,24,24)" /> - <polygon points="300,195 302,194 309,195 309,197 308,198 302,199 300,196" style="fill: rgb(72,86,87)" /> - <polygon points="66,356 67,356 68,356 69,356 70,356 72,357 75,362 71,362 67,362 66,361" style="fill: rgb(31,35,36)" /> - <polygon points="67,374 68,374 69,374 71,374 72,374 73,374 74,374 75,374 76,374 77,374 78,374 81,375 82,376 75,384 73,385 72,385 71,385" style="fill: rgb(18,18,18)" /> - <polygon points="243,188 249,185 251,187 251,188 250,190 246,190 244,189" style="fill: rgb(138,113,109)" /> - <polygon points="165,192 166,191 171,191 172,191 170,193 166,193" style="fill: rgb(159,108,107)" /> - <polygon points="111,86 111,85 111,84 115,80 128,75 134,76 136,77 136,82 115,86 114,86 112,86" style="fill: rgb(153,174,175)" /> - <polygon points="116,273 116,272 116,269 116,267 117,267 118,267 119,268 119,269 117,275" style="fill: rgb(103,52,51)" /> - <polygon points="27,368 29,365 30,366 33,371 34,373 33,373 29,372" style="fill: rgb(31,35,36)" /> - <polygon points="70,293 71,295 72,297 73,302 73,303 72,303 71,303 70,294" style="fill: rgb(122,68,66)" /> - <polygon points="45,225 45,224 57,212 60,210 63,208 67,208 69,208 72,209 72,210 53,244 52,244 51,244 50,244 46,233 45,230" style="fill: rgb(24,24,24)" /> - <polygon points="151,225 170,198 176,195 179,195 182,199 182,200 182,202 171,223 163,228 156,232 153,233 152,230 151,226" style="fill: rgb(176,110,112)" /> - <polygon points="89,233 90,230 92,230 92,233 92,234 90,237 89,236" style="fill: rgb(160,100,100)" /> - <polygon points="177,122 180,117 181,118 182,120 181,124" style="fill: rgb(74,50,46)" /> - <polygon points="93,229 96,222 97,222 98,222 99,222 99,223 96,233 95,234" style="fill: rgb(176,110,112)" /> - <polygon points="40,368 41,368 42,368 46,370 46,371 45,371 44,371 42,370" style="fill: rgb(35,39,40)" /> - <polygon points="246,245 247,244 249,245 250,246 251,248 251,249 250,249 247,247" style="fill: rgb(169,159,160)" /> - <polygon points="124,214 126,213 133,214 132,219 131,219" style="fill: rgb(176,110,112)" /> - <polygon points="131,354 132,353 137,349 144,349 145,349 144,351 134,355 131,355" style="fill: rgb(84,45,46)" /> - <polygon points="61,160 61,159 65,152 68,147 70,144 70,149 66,173 65,175 62,177" style="fill: rgb(154,99,96)" /> - <polygon points="392,238 392,237 393,237 396,239 397,242 397,250 397,251 397,252 395,276 394,276 393,275 392,260" style="fill: rgb(97,113,113)" /> - <polygon points="157,131 160,125 161,125 162,126 163,129 163,130 161,133 160,133 157,132" style="fill: rgb(168,139,141)" /> - <polygon points="112,174 112,171 118,166 118,169 118,172 113,174" style="fill: rgb(162,128,129)" /> - <polygon points="72,94 75,89 76,88 75,101 74,100 72,97" style="fill: rgb(136,135,140)" /> - <polygon points="263,130 264,130 278,133 277,135 274,137 271,138 269,137" style="fill: rgb(72,86,87)" /> - <polygon points="3,140 6,135 9,134 9,135 9,136 9,137 9,138 9,139 9,140 5,147 4,146 3,143" style="fill: rgb(103,72,70)" /> - <polygon points="105,159 105,158 107,154 108,153 109,153 111,154 106,159 105,160" style="fill: rgb(176,110,112)" /> - <polygon points="167,314 167,311 170,310 172,312 174,319 173,321" style="fill: rgb(141,101,101)" /> - <polygon points="202,90 204,88 205,87 208,88 206,92 203,93" style="fill: rgb(64,40,36)" /> - <polygon points="206,145 206,142 207,141 214,148 215,149 213,150 207,148" style="fill: rgb(102,87,84)" /> - <polygon points="104,320 112,310 117,306 119,310 118,318 117,321 111,330 109,330 108,330 107,329 105,325" style="fill: rgb(132,78,78)" /> - <polygon points="66,242 68,237 70,236 71,239 71,240 70,241 67,243 66,243" style="fill: rgb(141,87,87)" /> - <polygon points="343,81 343,79 343,77 343,75 343,73 343,72 344,68 346,70 347,83 348,97 348,106 347,107 345,105 344,97" style="fill: rgb(36,47,51)" /> - <polygon points="71,306 71,304 74,308 75,310 76,312 76,313 74,313 73,313 72,310" style="fill: rgb(121,87,86)" /> - <polygon points="215,357 217,333 219,331 226,327 228,328 231,330 232,331 232,333 229,345 224,354" style="fill: rgb(138,113,109)" /> - <polygon points="75,185 77,183 79,182 79,183 79,184 77,186 76,186" style="fill: rgb(184,119,123)" /> - <polygon points="11,360 14,360 22,371 18,373 16,373 13,373 12,373" style="fill: rgb(65,68,73)" /> - <polygon points="137,237 140,234 141,235 142,236 143,237 141,241 137,238" style="fill: rgb(141,87,87)" /> - <polygon points="82,129 83,128 86,126 86,127 86,128 85,131 84,131 83,130" style="fill: rgb(159,108,107)" /> - <polygon points="6,396 8,390 9,390 19,397 14,398" style="fill: rgb(18,18,18)" /> - <polygon points="231,55 231,54 238,54 238,55" style="fill: rgb(36,47,51)" /> - <polygon points="61,89 64,82 67,81 69,82 62,90" style="fill: rgb(140,154,155)" /> - <polygon points="89,260 89,259 89,258 89,257 90,257 110,261 110,262 110,264 110,265 99,270 96,270 95,270 89,264" style="fill: rgb(52,28,28)" /> - <polygon points="270,139 276,138 292,138 293,139 295,145 303,193 302,205 299,221 293,228 291,227 289,224 287,221" style="fill: rgb(86,87,89)" /> - <polygon points="249,201 249,200 251,192 252,202 252,206 252,207 251,206" style="fill: rgb(208,174,188)" /> - <polygon points="200,91 200,89 205,86 206,86 206,89 205,90 203,91 201,91" style="fill: rgb(74,50,46)" /> - <polygon points="19,316 20,312 21,314 21,316 21,317 21,318 20,319" style="fill: rgb(65,68,73)" /> - <polygon points="63,283 64,280 65,281 70,287 75,295 79,303 79,306 79,309 79,310 74,307 73,306 72,305 64,288" style="fill: rgb(132,78,78)" /> - <polygon points="49,63 60,58 65,58 70,66 70,67 63,75 59,76 54,77 53,77 51,75" style="fill: rgb(169,159,160)" /> - <polygon points="101,83 102,82 109,76 111,78 110,80 107,83 103,85 102,85" style="fill: rgb(138,113,109)" /> - <polygon points="79,85 85,78 86,78 93,79 97,80 98,82 92,89 90,90 82,87" style="fill: rgb(122,134,132)" /> - <polygon points="396,281 397,280 398,280 399,281 399,282 399,283 399,284 399,302 397,300" style="fill: rgb(72,86,87)" /> - <polygon points="205,302 205,300 206,299 212,298 213,299 213,303 213,304 206,305 205,305" style="fill: rgb(162,128,129)" /> - <polygon points="76,262 76,261 77,261 78,261 78,262 78,263 77,265 76,265" style="fill: rgb(160,100,100)" /> - <polygon points="114,112 115,112 116,112 117,112 118,112 119,112 120,112 121,112 133,114 135,115 128,116 127,116 123,115" style="fill: rgb(122,68,66)" /> - <polygon points="38,195 38,193 40,190 41,198 38,198" style="fill: rgb(64,40,36)" /> - <polygon points="93,243 105,198 106,197 107,197 126,217 132,225 132,226 130,229 96,246 95,246 93,245 93,244" style="fill: rgb(196,153,163)" /> - <polygon points="167,341 170,339 172,341 171,342 167,343" style="fill: rgb(74,50,46)" /> - <polygon points="86,102 86,101 87,99 93,97 94,99 86,103" style="fill: rgb(74,50,46)" /> - <polygon points="92,260 92,259 93,259 94,259 101,260 105,262 100,267 99,268 97,268 95,267 93,266 92,261" style="fill: rgb(52,28,28)" /> - <polygon points="30,112 33,107 35,106 36,106 37,107 38,110 36,112" style="fill: rgb(52,28,28)" /> - <polygon points="75,371 90,347 91,347 94,350 95,351 97,354 97,357 97,358 93,371 89,373 88,373 87,373" style="fill: rgb(47,48,50)" /> - <polygon points="68,296 69,293 70,295 71,297 71,298 71,299 71,300 70,301 69,300" style="fill: rgb(122,68,66)" /> - <polygon points="0,328 1,326 2,326 4,327 5,328 11,336 10,338 9,340 8,341 7,341 0,340" style="fill: rgb(86,87,89)" /> - <polygon points="43,126 53,115 61,109 66,106 69,108 54,125 45,129 44,129" style="fill: rgb(91,63,60)" /> - <polygon points="47,104 47,102 50,101 50,107 49,107 48,107 47,107" style="fill: rgb(136,135,140)" /> - <polygon points="143,351 147,348 153,357 153,359 147,360 144,355 143,352" style="fill: rgb(64,40,36)" /> - <polygon points="44,183 44,182 63,145 71,135 72,134 72,135 72,136 54,202 51,204 47,206 46,206 45,205 44,189" style="fill: rgb(122,68,66)" /> - <polygon points="58,200 58,199 59,197 61,197 65,197 68,198 72,200 71,201 61,201 60,201 59,201" style="fill: rgb(141,93,93)" /> - <polygon points="129,187 130,186 133,183 133,184 133,185 132,188 130,188" style="fill: rgb(132,78,78)" /> - <polygon points="342,65 342,62 342,60 342,59 343,58 343,65 342,67 342,61 342,60 342,59 343,58 343,65 342,67 342,61 342,60" style="fill: rgb(36,47,51)" /> - <polygon points="184,294 185,292 187,295 187,299 186,301 185,301" style="fill: rgb(132,78,78)" /> - <polygon points="327,259 327,257 328,257 330,260 330,261 329,262 328,262 327,262" style="fill: rgb(72,86,87)" /> - <polygon points="109,336 109,335 110,334 111,334 120,334 123,337 125,343 125,345 124,345 114,341" style="fill: rgb(122,68,66)" /> - <polygon points="37,122 40,119 44,119 48,120 48,121 44,122 38,123" style="fill: rgb(105,95,93)" /> - <polygon points="281,261 282,258 285,256 287,256 291,262 294,270 295,273 295,274 295,275 289,280 286,277 282,266 281,262" style="fill: rgb(169,159,160)" /> - <polygon points="50,151 50,150 55,142 57,145 57,147 56,149 53,152" style="fill: rgb(91,63,60)" /> - <polygon points="94,90 101,88 102,89 101,91 97,92 94,91" style="fill: rgb(118,100,98)" /> - <polygon points="383,65 383,60 383,59 383,58 383,57 385,58 385,64 385,65 384,67 383,67 383,57 385,58 385,64 385,65 384,67 383,67 383,57 385,58 385,64 385,65 384,67 383,67 383,57 385,58 385,64 385,65" style="fill: rgb(31,35,36)" /> - <polygon points="43,367 46,367 62,368 68,369 70,370 62,373 55,373 52,372" style="fill: rgb(27,28,30)" /> - <polygon points="278,163 282,165 282,166 281,169 280,170" style="fill: rgb(111,107,106)" /> - <polygon points="144,381 162,373 166,373 167,373 165,379 164,381 158,385 155,387 151,389 150,389 146,387" style="fill: rgb(91,63,60)" /> - <polygon points="157,238 159,237 166,244 166,245 165,247 158,241 157,239" style="fill: rgb(176,110,112)" /> - <polygon points="78,321 78,320 92,333 94,336 94,337 92,341 89,339 84,333 79,323" style="fill: rgb(115,74,72)" /> - <polygon points="38,59 38,58 40,61 40,63 40,64 39,68 38,71" style="fill: rgb(136,135,140)" /> - <polygon points="0,193 13,189 14,189 20,192 29,204 30,208 29,208 25,208 7,206 1,203 0,202" style="fill: rgb(153,174,175)" /> - <polygon points="166,67 166,62 169,63 170,64 170,65" style="fill: rgb(43,56,62)" /> - <polygon points="261,119 262,119 265,121 266,122 267,123 268,125 268,126 268,127 266,128 264,128 262,126" style="fill: rgb(72,86,87)" /> - <polygon points="262,232 262,231 263,224 264,222 272,220 274,220 269,231 263,232" style="fill: rgb(201,198,205)" /> - <polygon points="74,201 75,201 76,201 77,201 78,201 84,202 91,207 91,208 91,210 91,216 91,218" style="fill: rgb(122,68,66)" /> - <polygon points="197,311 199,312 203,315 203,319 199,319" style="fill: rgb(141,93,93)" /> - <polygon points="124,94 124,93 126,93 128,93 130,95 129,96 128,96 127,96" style="fill: rgb(103,72,70)" /> - <polygon points="103,237 103,230 103,229 108,220 109,220 120,223 121,224 133,239 134,241 133,243 114,243 111,243 110,243 109,243 108,243 107,243 105,242" style="fill: rgb(196,153,163)" /> - <polygon points="0,385 2,384 3,384 4,384 5,384 3,387 1,389 0,387" style="fill: rgb(50,51,53)" /> - <polygon points="33,136 34,134 37,129 40,128 44,131 42,136 41,137 35,140 34,140" style="fill: rgb(103,72,70)" /> - <polygon points="179,322 179,320 179,319 188,318 189,320 188,322 185,323 181,324 180,324 179,323" style="fill: rgb(123,89,88)" /> - <polygon points="97,124 99,123 109,120 110,120 112,124 103,128" style="fill: rgb(163,103,105)" /> - <polygon points="132,211 135,207 140,210 139,212 136,212" style="fill: rgb(163,103,105)" /> - <polygon points="204,155 204,153 205,153 212,156 216,163 214,163 212,162" style="fill: rgb(130,119,115)" /> - <polygon points="287,288 288,287 294,289 295,292 295,293 295,295 294,296 289,293" style="fill: rgb(111,107,106)" /> - <polygon points="0,344 1,343 3,342 4,342 7,342 8,342 9,343 8,345 7,345" style="fill: rgb(43,56,62)" /> - <polygon points="245,165 247,162 251,165 251,166 246,166" style="fill: rgb(147,129,125)" /> - <polygon points="91,91 91,89 94,86 96,85 99,85 100,88 100,89 99,90 93,92" style="fill: rgb(118,100,98)" /> - <polygon points="199,140 199,137 201,138 202,139 203,140 204,141 204,145 203,145 200,143 199,142" style="fill: rgb(118,100,98)" /> - <polygon points="241,97 241,96 246,101 247,105 247,106 245,105 243,102 242,100 241,98" style="fill: rgb(105,95,93)" /> - <polygon points="198,103 198,102 199,102 200,102 203,103 201,107 200,106" style="fill: rgb(103,91,91)" /> - <polygon points="121,375 123,370 125,370 129,373 130,374 131,375" style="fill: rgb(27,28,30)" /> - <polygon points="225,136 226,132 229,135 230,137 230,138 226,137" style="fill: rgb(118,100,98)" /> - <polygon points="206,150 208,149 215,148 218,151 218,152 212,154 211,154 207,151" style="fill: rgb(140,126,123)" /> - <polygon points="22,191 22,190 22,185 22,184 24,187 26,194" style="fill: rgb(111,107,106)" /> - <polygon points="39,286 42,279 46,270 47,269 51,272 57,284 57,285 56,286 55,287 51,287" style="fill: rgb(36,47,51)" /> - <polygon points="138,128 142,126 151,129 152,130 153,131 148,131 139,129" style="fill: rgb(165,109,110)" /> - <polygon points="314,261 318,256 319,256 323,256 323,259 323,260 319,262 316,262" style="fill: rgb(72,86,87)" /> - <polygon points="39,91 40,93 40,104 40,105 40,106 40,107 39,98" style="fill: rgb(86,87,89)" /> - <polygon points="239,261 239,259 239,258 246,257 249,258 249,261 244,264 240,263 239,262" style="fill: rgb(168,139,141)" /> - <polygon points="0,351 2,350 16,368 16,369 15,370 11,373 9,373 8,373 7,373 0,373" style="fill: rgb(65,68,73)" /> - <polygon points="242,271 245,270 246,270 246,271 245,278 244,277 243,276" style="fill: rgb(196,153,163)" /> - <polygon points="268,157 268,153 269,152 271,154 270,156 269,157" style="fill: rgb(208,174,188)" /> - <polygon points="43,93 44,83 45,84 47,96 47,97 47,98 47,99 46,99" style="fill: rgb(122,134,132)" /> - <polygon points="394,200 397,193 398,193 399,193 399,217" style="fill: rgb(97,113,113)" /> - <polygon points="259,146 260,136 261,140 262,146" style="fill: rgb(168,139,141)" /> - <polygon points="61,202 63,200 65,199 68,199 68,200 68,201 65,202" style="fill: rgb(141,87,87)" /> - <polygon points="353,301 353,300 353,299 353,298 353,293 353,292 353,291 353,290 353,288 353,287 353,286 354,291 354,301" style="fill: rgb(153,174,175)" /> - <polygon points="192,94 193,92 197,92 201,93 203,97 202,97 196,96 193,95" style="fill: rgb(105,95,93)" /> - <polygon points="116,122 120,123 124,124 126,125 126,126 125,126 121,125 117,124" style="fill: rgb(163,103,105)" /> - <polygon points="259,131 261,133 265,143 264,144 263,143 260,134" style="fill: rgb(208,174,188)" /> - <polygon points="58,148 61,141 62,142 62,145 60,148 58,150" style="fill: rgb(103,52,51)" /> - <polygon points="119,214 119,213 120,213 129,216 130,217 135,222 136,225 134,228 131,228" style="fill: rgb(184,119,123)" /> - <polygon points="120,169 120,168 121,167 134,164 134,165 134,167 134,168 126,171 125,171 124,171 123,171" style="fill: rgb(187,128,132)" /> - <polygon points="47,329 49,325 52,323 59,321 60,321 61,321 62,322 59,325 55,327 51,329 48,330" style="fill: rgb(35,39,40)" /> - <polygon points="59,92 59,90 59,89 64,83 70,79 71,81 62,92 61,93 59,93" style="fill: rgb(140,154,155)" /> - <polygon points="93,347 94,339 97,341 98,350 97,350" style="fill: rgb(74,50,46)" /> - <polygon points="76,104 84,101 84,102 81,106 78,107 77,106 76,105" style="fill: rgb(85,74,68)" /> - <polygon points="296,274 306,263 307,262 318,264 324,267 353,283 354,284 355,288 356,302 356,309 356,313 334,317 298,287 296,277" style="fill: rgb(153,174,175)" /> - <polygon points="119,259 119,257 126,253 128,253 124,257 122,258" style="fill: rgb(151,95,96)" /> - <polygon points="297,181 298,180 300,179 304,180 302,192 299,192 297,190" style="fill: rgb(122,134,132)" /> - <polygon points="348,275 348,273 348,271 349,270 350,278 350,279 350,281 349,281 348,280" style="fill: rgb(97,113,113)" /> - <polygon points="248,269 248,268 249,262 251,262 254,269 254,272 254,273 252,276" style="fill: rgb(168,139,141)" /> - <polygon points="206,132 207,131 212,135 214,138 214,139 214,140 210,138 209,137" style="fill: rgb(169,159,160)" /> - <polygon points="155,338 156,338 163,340 163,341 163,342 160,344 156,340" style="fill: rgb(91,63,60)" /> - <polygon points="66,141 66,139 70,134 71,134 69,140" style="fill: rgb(115,74,72)" /> - <polygon points="245,159 245,158 245,157 248,152 249,151 251,151 262,157 262,158 252,165 249,163 248,162 247,161" style="fill: rgb(168,139,141)" /> - <polygon points="342,301 346,302 348,304 350,307 352,311 351,311 348,310 347,309 343,304" style="fill: rgb(153,174,175)" /> - <polygon points="298,294 299,291 300,290 322,286 327,286 328,287 328,311" style="fill: rgb(72,86,87)" /> - <polygon points="277,159 281,158 282,158 287,162 286,164 278,162" style="fill: rgb(86,87,89)" /> - <polygon points="68,274 69,272 74,273 79,276 79,277 79,280 76,284 75,284 74,284 73,284 71,283 68,277" style="fill: rgb(156,92,93)" /> - <polygon points="89,144 91,142 95,139 102,142 102,143 102,144 102,145 101,149 93,155 92,155 91,155 90,155 89,151" style="fill: rgb(184,119,123)" /> - <polygon points="81,396 84,392 85,392 90,393 90,394 89,397 87,399 86,399 85,399 81,398" style="fill: rgb(136,135,140)" /> - <polygon points="66,354 71,353 72,353 73,353 78,354 76,355 75,355 74,355 73,355" style="fill: rgb(31,35,36)" /> - <polygon points="141,219 141,217 142,216 156,206 165,204 169,206 158,217 142,222 141,221" style="fill: rgb(165,105,105)" /> - <polygon points="187,141 190,140 191,140 195,144 194,146 193,146 190,146" style="fill: rgb(118,100,98)" /> - <polygon points="172,192 175,191 179,190 178,192 177,193 175,194 172,193" style="fill: rgb(188,143,140)" /> - <polygon points="258,181 259,181 263,181 266,183 267,184 268,185 272,192 272,193 272,195 272,196 271,196 270,195 261,185" style="fill: rgb(103,52,51)" /> - <polygon points="131,399 133,396 136,396 137,396 138,396 146,397 151,398 153,399 144,399 136,399" style="fill: rgb(132,78,78)" /> - <polygon points="0,391 2,389 4,389 5,389 5,390 4,391 3,392" style="fill: rgb(35,39,40)" /> - <polygon points="10,120 13,115 16,112 17,111 18,111 19,112 14,119 12,121 11,122" style="fill: rgb(43,56,62)" /> - <polygon points="220,273 221,272 224,271 224,272 224,277 223,277 222,276 221,275" style="fill: rgb(208,174,188)" /> - <polygon points="54,254 56,257 56,263 56,264 54,259" style="fill: rgb(65,68,73)" /> - <polygon points="27,311 27,307 29,304 32,313 32,314 31,314 28,313" style="fill: rgb(35,39,40)" /> - <polygon points="135,106 135,103 136,103 137,103 141,105 139,106 138,106 137,106 136,106" style="fill: rgb(91,63,60)" /> - <polygon points="133,290 137,288 143,286 151,284 152,284 156,285 156,286 156,289 154,296 151,302 150,303 143,305 136,296" style="fill: rgb(187,128,132)" /> - <polygon points="49,194 50,190 60,157 66,144 68,142 70,141 70,142 59,203 55,202 50,200 49,199" style="fill: rgb(132,78,78)" /> - <polygon points="298,281 298,275 306,267 311,267 315,270 315,271 306,283 305,283 304,283 299,282" style="fill: rgb(122,134,132)" /> - <polygon points="279,61 284,58 285,58 286,58 287,61 286,62" style="fill: rgb(41,53,53)" /> - <polygon points="393,238 394,237 395,237 396,237 397,237 399,238 399,244 399,245 398,252 397,253 396,253" style="fill: rgb(97,113,113)" /> - <polygon points="16,186 17,167 18,167 19,168 20,171 20,183 19,190 18,191 17,190 16,187" style="fill: rgb(97,113,113)" /> - <polygon points="385,81 385,80 385,79 385,78 388,74 391,70 394,66 399,68 399,77 395,91 394,93 386,100 385,98" style="fill: rgb(35,39,40)" /> - <polygon points="228,349 228,347 229,341 237,330 238,331 239,341 234,348 231,349 229,349" style="fill: rgb(162,128,129)" /> - <polygon points="130,100 135,100 135,101 133,103 131,102" style="fill: rgb(91,63,60)" /> - <polygon points="62,247 62,246 63,241 69,236 87,226 88,226 89,229 86,246 63,277 62,274 62,273" style="fill: rgb(132,78,78)" /> - <polygon points="250,261 253,255 254,254 255,255 259,267 259,268 258,272 257,273 256,273 255,271 253,267" style="fill: rgb(208,174,188)" /> - <polygon points="44,112 44,110 45,105 46,105 49,110 47,112 44,113 44,110 45,105 46,105 49,110 47,112 44,113 44,110 45,105 46,105 49,110 47,112 44,113 44,110 45,105 46,105" style="fill: rgb(153,174,175)" /> - <polygon points="143,245 150,247 152,248 151,248 150,248 149,248 144,248 143,248" style="fill: rgb(165,109,110)" /> - <polygon points="159,353 159,352 160,350 163,347 167,346 169,347 170,348 170,353 166,356 160,360" style="fill: rgb(64,40,36)" /> - <polygon points="139,51 141,47 339,0 340,0 341,0 342,0 343,19 343,25 343,29 343,32 343,33 343,89 343,90 343,93 338,102 329,106 323,107 269,114 162,73 140,53 139,52" style="fill: rgb(43,56,62)" /> - <polygon points="152,129 152,128 153,125 154,125 159,126 158,128 154,130 153,130" style="fill: rgb(159,108,107)" /> - <polygon points="110,286 111,284 116,281 117,281 115,286" style="fill: rgb(141,87,87)" /> - <polygon points="27,48 28,38 30,38 33,41 35,47 35,49 35,50 35,51 35,52 35,53 35,54 33,54 27,49" style="fill: rgb(71,77,75)" /> - <polygon points="247,249 247,248 249,249 250,250 253,256 253,259 251,259 250,259" style="fill: rgb(169,159,160)" /> - <polygon points="135,353 139,353 142,354 141,355 135,355" style="fill: rgb(64,40,36)" /> - <polygon points="261,240 273,227 278,224 278,225 278,226 278,227 277,240 276,242 274,244 272,245 266,244 261,243" style="fill: rgb(196,153,163)" /> - <polygon points="18,383 20,379 21,378 22,378 24,378 25,378 26,378 27,378 25,381 20,384 18,384" style="fill: rgb(13,13,13)" /> - <polygon points="102,330 104,328 106,333 106,334 104,335 103,335 102,332" style="fill: rgb(122,68,66)" /> - <polygon points="150,120 154,115 161,118 161,120 161,121 161,122 160,123 156,126 155,126 154,126 152,124" style="fill: rgb(141,93,93)" /> - <polygon points="156,265 156,264 157,264 160,267 161,268 161,269 161,270 160,271 159,270" style="fill: rgb(103,52,51)" /> - <polygon points="52,172 52,166 53,159 55,155 58,151 59,150 60,149 56,175 53,177 52,177" style="fill: rgb(122,68,66)" /> - <polygon points="108,307 110,302 112,302 113,303 116,309 115,311 114,312" style="fill: rgb(141,93,93)" /> - <polygon points="207,167 208,164 209,164 210,165 211,167 212,170 209,169 208,168" style="fill: rgb(121,87,86)" /> - <polygon points="385,105 385,104 385,103 385,101 385,100 385,99 392,78 397,78 399,98 399,107 399,121 397,122 386,115" style="fill: rgb(36,47,51)" /> - <polygon points="53,233 54,229 56,227 57,226 58,226 64,228 58,243 54,237" style="fill: rgb(115,74,72)" /> - <polygon points="82,107 83,106 90,101 89,107 83,108" style="fill: rgb(64,40,36)" /> - <polygon points="275,223 277,214 277,215 277,216 277,217 277,218 277,219 277,220 277,221 277,222 276,224 275,224" style="fill: rgb(176,110,112)" /> - <polygon points="382,392 382,391 382,390 382,387 382,386 384,389 385,391 386,394 386,397 386,398 386,399 384,396" style="fill: rgb(201,198,205)" /> - <polygon points="4,294 5,290 7,291 7,294 7,295 4,298" style="fill: rgb(110,74,74)" /> - <polygon points="5,146 6,146 12,147 23,149 23,157 21,158 15,157 13,155" style="fill: rgb(102,87,84)" /> - <polygon points="127,391 127,390 127,388 127,387 127,385 131,384 131,385 131,386 129,390" style="fill: rgb(111,107,106)" /> - <polygon points="36,246 37,238 39,238 39,239 38,243 37,245" style="fill: rgb(153,174,175)" /> - <polygon points="355,276 355,275 358,269 359,275 359,276 359,280 356,280 355,277" style="fill: rgb(43,56,62)" /> - <polygon points="128,371 150,352 152,353 153,354 156,357 158,367 158,368 157,374 156,375 150,377 147,378 146,378 141,377 137,376 132,374 130,373" style="fill: rgb(24,24,24)" /> - <polygon points="145,126 148,124 151,123 151,124 151,125 149,128 148,129 147,129 146,128 145,127" style="fill: rgb(165,109,110)" /> - <polygon points="47,266 48,263 52,253 53,253 55,260 57,272 57,279 56,279 55,279 50,275 49,274 48,270" style="fill: rgb(41,53,53)" /> - <polygon points="104,116 112,114 113,114 118,115 128,118 133,120 132,121 131,121 130,121 108,117" style="fill: rgb(141,87,87)" /> - <polygon points="165,175 167,173 172,172 172,173 171,175 169,176 167,176" style="fill: rgb(196,153,163)" /> - <polygon points="23,183 24,181 25,180 25,181 25,184 25,185 24,186 23,185" style="fill: rgb(118,100,98)" /> - <polygon points="165,142 166,134 167,132 168,131 169,133 176,152 176,153 170,147" style="fill: rgb(168,139,141)" /> - <polygon points="294,264 295,263 303,266 295,268" style="fill: rgb(140,154,155)" /> - <polygon points="179,97 180,97 181,97 184,97 187,99 193,105 187,106 179,102" style="fill: rgb(118,100,98)" /> - <polygon points="99,292 104,289 105,289 105,291 102,295 101,295 100,295 99,293" style="fill: rgb(115,74,72)" /> - <polygon points="191,360 192,358 195,355 202,350 206,348 206,349 206,351 194,361 193,361" style="fill: rgb(74,50,46)" /> - <polygon points="31,42 33,34 34,41 34,49 32,46" style="fill: rgb(72,86,87)" /> - <polygon points="149,201 151,200 154,199 155,199 156,199 161,199 162,199 163,199 164,200 155,201" style="fill: rgb(162,128,129)" /> - <polygon points="12,135 14,132 15,131 16,131 20,134 19,135 13,135" style="fill: rgb(102,87,84)" /> - <polygon points="266,187 268,186 269,186 271,190 271,191 271,192 266,188" style="fill: rgb(103,52,51)" /> - <polygon points="202,344 202,341 203,338 204,337 207,336 206,338 203,343" style="fill: rgb(110,74,74)" /> - <polygon points="0,132 1,130 4,130 5,131 5,132 4,134 3,135" style="fill: rgb(102,87,84)" /> - <polygon points="45,206 48,206 57,209 56,210 52,214 46,214 45,210" style="fill: rgb(141,87,87)" /> - <polygon points="35,213 36,211 39,209 39,210 37,219" style="fill: rgb(85,74,68)" /> - <polygon points="396,226 397,225 398,225 399,226 399,234 399,235 397,236 396,236" style="fill: rgb(122,134,132)" /> - <polygon points="236,271 236,270 237,267 238,267 239,268 238,275 237,276 236,272" style="fill: rgb(168,139,141)" /> - <polygon points="171,132 172,130 177,133 184,146 184,148 175,144 172,138 171,134" style="fill: rgb(138,113,109)" /> - <polygon points="299,182 299,181 300,181 301,181 302,181 304,192 303,192 300,191 299,189" style="fill: rgb(122,134,132)" /> - <polygon points="4,302 5,297 7,302 7,304 7,305 6,307 4,304" style="fill: rgb(102,87,84)" /> - <polygon points="178,156 179,155 207,171 208,172 207,173 197,169 186,164 185,163" style="fill: rgb(188,143,140)" /> - <polygon points="263,175 266,173 267,173 271,175 264,177" style="fill: rgb(147,129,125)" /> - <polygon points="81,0 82,0 83,0 87,0 91,0 95,0 99,0 103,0 107,0 111,0 115,0 119,0 123,0 127,0 134,0 142,0 144,0 150,0 152,0 158,0 160,0 166,0 168,0 174,0 176,0 182,0 184,0 190,0 192,0 194,0 196,0 198,0 204,0 206,0 212,0 214,0 220,0 222,0 228,0 230,0 236,0 238,0 244,0 246,0 252,0 254,0 268,0 284,0 300,0 316,0 332,0 336,0 338,0 339,5 340,22 340,25 340,29 340,34 339,42 337,45 182,56 144,57 94,13 84,4 82,2 81,1" style="fill: rgb(53,70,77)" /> - <polygon points="180,74 182,72 183,72 186,73 186,74 185,75 183,76" style="fill: rgb(138,113,109)" /> - <polygon points="105,352 105,351 105,349 106,348 115,345 134,357 134,358 120,360" style="fill: rgb(64,40,36)" /> - <polygon points="178,381 179,380 190,376 192,376 191,377 185,380 179,381" style="fill: rgb(121,87,86)" /> - <polygon points="95,176 100,165 103,161 106,158 107,158 114,174 110,180 108,182 106,182 103,182 102,182 101,182 96,177" style="fill: rgb(172,116,115)" /> - <polygon points="19,174 19,173 23,169 24,169 25,169 25,174 22,180 20,178 19,176" style="fill: rgb(77,83,83)" /> - <polygon points="47,367 62,367 63,367 60,367 61,367 58,367 59,367 56,367 57,367 54,367 55,367 52,367 53,367 50,367 51,367 48,367 49,367 64,367 65,367 66,367 67,367" style="fill: rgb(24,24,24)" /> - <polygon points="150,382 152,379 155,378 156,380 156,381 156,383 156,384 153,384 151,383" style="fill: rgb(84,45,46)" /> - <polygon points="259,175 261,173 264,173 264,176 262,177 259,176" style="fill: rgb(138,113,109)" /> - <polygon points="228,294 228,292 228,290 231,288 232,290 230,293" style="fill: rgb(172,116,115)" /> - <polygon points="205,118 206,117 208,118 217,123 219,125 217,125 207,121" style="fill: rgb(169,159,160)" /> - <polygon points="122,191 122,186 123,186 124,186 127,188 124,193 123,193" style="fill: rgb(123,89,88)" /> - <polygon points="8,333 9,333 12,334 13,335 14,336 13,338 12,340 11,341 10,341" style="fill: rgb(97,113,113)" /> - <polygon points="96,159 96,158 97,157 101,158 102,160 102,161 101,162 100,163 98,163 96,163" style="fill: rgb(165,105,105)" /> - <polygon points="33,307 34,306 35,306 36,306 40,307 47,313 52,318 52,319 51,320 50,320 49,320 43,320 42,320 36,317 35,316 34,312" style="fill: rgb(28,32,31)" /> - <polygon points="105,190 105,187 107,188 112,192 111,194 110,195 109,195 108,195" style="fill: rgb(141,87,87)" /> - <polygon points="341,40 341,39 344,22 345,28 345,31 345,32 345,33 344,45 341,43" style="fill: rgb(36,47,51)" /> - <polygon points="195,386 203,378 252,332 267,318 276,310 281,306 284,304 287,302 293,299 295,298 298,297 302,296 306,297 309,298 399,330 399,377 399,397 399,398 399,399 391,399 387,399 369,399 365,399 361,399 257,399 232,399 230,399 228,399 226,399 224,399 216,399 214,399 211,399 196,388" style="fill: rgb(234,243,252)" /> - <polygon points="14,125 28,123 29,123 35,127 27,130 22,131 17,131 16,130 14,126" style="fill: rgb(85,74,68)" /> - <polygon points="98,157 99,156 101,154 104,154 104,157" style="fill: rgb(163,107,106)" /> - <polygon points="185,347 186,341 188,341 191,342 192,343 192,345 187,348 186,348" style="fill: rgb(74,50,46)" /> - <polygon points="134,395 145,390 146,390 146,392 146,393 145,394 140,396 139,396" style="fill: rgb(122,68,66)" /> - <polygon points="149,397 149,395 203,355 206,359 206,360 200,368 193,375 162,395 156,398" style="fill: rgb(110,74,74)" /> - <polygon points="188,94 194,96 199,105 200,107 199,108 195,106 193,104 191,102" style="fill: rgb(103,72,70)" /> - <polygon points="27,278 31,278 33,278 34,278 35,278 33,281 27,279" style="fill: rgb(72,86,87)" /> - <polygon points="225,112 231,110 234,113 232,117 231,117 226,114" style="fill: rgb(91,63,60)" /> - <polygon points="43,220 44,215 49,220 49,221 49,222 49,223 44,227 43,221" style="fill: rgb(64,40,36)" /> - <polygon points="57,363 64,363 73,364 75,366 70,366 63,365" style="fill: rgb(24,24,24)" /> - <polygon points="120,328 120,327 120,326 121,325 127,327 125,330 124,331 120,333 120,332" style="fill: rgb(141,87,87)" /> - <polygon points="275,240 275,236 275,235 276,228 280,220 280,221 280,222 280,228 279,234 278,237 277,239" style="fill: rgb(201,198,205)" /> - <polygon points="263,170 267,170 275,173 276,174 274,184 270,181 263,172" style="fill: rgb(162,128,129)" /> - <polygon points="58,143 58,142 59,137 60,136 74,123 74,124 74,125 73,127 70,131 63,139 62,140 59,143" style="fill: rgb(84,45,46)" /> - <polygon points="161,90 167,80 168,81 169,86 164,89 162,90" style="fill: rgb(103,72,70)" /> - <polygon points="115,207 116,205 120,202 121,203 128,212 125,213 124,213 123,213 121,213 116,211" style="fill: rgb(172,116,115)" /> - <polygon points="294,278 294,277 295,277 296,279 297,282 297,284 297,285 294,280" style="fill: rgb(201,198,205)" /> - <polygon points="183,73 184,71 188,68 190,68 191,69 189,71" style="fill: rgb(147,129,125)" /> - <polygon points="70,98 70,95 71,93 73,91 72,96" style="fill: rgb(136,135,140)" /> - <polygon points="268,139 269,139 272,141 273,142 277,150 275,150 273,149 272,148" style="fill: rgb(97,113,113)" /> - <polygon points="75,125 76,122 82,117 85,115 88,115 89,115 90,116 75,128" style="fill: rgb(91,63,60)" /> - <polygon points="27,188 27,186 28,182 29,192 29,194 29,195 28,195 27,189" style="fill: rgb(118,100,98)" /> - <polygon points="28,303 29,296 31,296 32,296 32,298 29,302" style="fill: rgb(41,53,53)" /> - <polygon points="384,203 389,201 390,201 394,205 395,224 392,228 390,227" style="fill: rgb(153,174,175)" /> - <polygon points="391,35 393,34 395,33 398,32 399,32 399,34 398,35 397,35 396,35 395,35 394,35 393,35" style="fill: rgb(31,35,36)" /> - <polygon points="189,295 190,294 191,294 192,294 193,295 194,296 194,297 193,301" style="fill: rgb(172,116,115)" /> - <polygon points="91,379 91,378 94,375 95,375 97,376 97,377 93,382" style="fill: rgb(28,32,31)" /> - <polygon points="226,198 226,197 227,195 229,199 229,213 228,210 226,202" style="fill: rgb(162,128,129)" /> - <polygon points="92,206 93,204 95,200 96,200 96,210 95,216 93,217 92,214" style="fill: rgb(156,92,93)" /> - <polygon points="3,351 3,350 4,350 12,362 14,366 13,366 10,365 5,362 4,359 3,355" style="fill: rgb(50,51,53)" /> - <polygon points="30,183 30,182 31,181 32,181 33,184 33,188 32,188 30,187" style="fill: rgb(91,63,60)" /> - <polygon points="161,62 168,61 169,61 166,65 164,65 163,65" style="fill: rgb(41,53,53)" /> - <polygon points="186,119 188,108 189,107 190,107 194,111 194,112 192,118 187,120" style="fill: rgb(102,87,84)" /> - <polygon points="94,330 94,329 94,328 96,327 98,327 99,330 99,331 95,334" style="fill: rgb(84,45,46)" /> - <polygon points="330,195 330,192 334,192 336,192 336,193 336,196 335,199 333,198 331,196" style="fill: rgb(140,154,155)" /> - <polygon points="91,260 91,259 92,258 94,264 94,265 92,266 91,261" style="fill: rgb(52,28,28)" /> - <polygon points="173,130 173,124 175,127 176,131 176,132 176,133 174,132" style="fill: rgb(138,113,109)" /> - <polygon points="296,141 296,137 296,134 296,132 301,130 306,129 367,126 380,126 383,126 384,126 385,126 386,126 388,126 389,126 390,126 390,128 390,129 390,130 304,179 300,178 299,177 298,171 297,162" style="fill: rgb(234,243,252)" /> - <polygon points="162,120 162,115 165,112 168,118 167,122 166,122 162,122" style="fill: rgb(141,101,101)" /> - <polygon points="161,370 161,368 163,362 165,358 168,354 169,354 170,355 171,356 174,362 176,367 174,369 168,371 165,371" style="fill: rgb(74,50,46)" /> - <polygon points="213,166 217,164 218,165 219,168 219,169 218,169 216,168" style="fill: rgb(138,113,109)" /> - <polygon points="102,398 104,395 106,393 111,389 118,387 121,387 124,396 122,398 118,399 117,399 113,399 112,399 103,399 102,399" style="fill: rgb(111,107,106)" /> - <polygon points="37,381 37,380 39,378 41,380 41,381 41,384 40,385 39,385" style="fill: rgb(18,18,18)" /> - <polygon points="140,254 142,250 148,252 147,253 142,255" style="fill: rgb(184,119,123)" /> - <polygon points="25,299 32,291 34,291 35,291 31,299 28,302 26,301" style="fill: rgb(41,53,53)" /> - <polygon points="271,52 279,51 280,51 287,51 287,52 286,54 271,53" style="fill: rgb(43,56,62)" /> - <polygon points="42,128 42,126 44,123 45,122 51,117 50,120 44,127" style="fill: rgb(103,72,70)" /> - <polygon points="173,397 173,395 175,395 176,395 178,397 178,398 177,399 176,399 175,399 174,399" style="fill: rgb(172,116,115)" /> - <polygon points="39,154 39,148 41,150 42,151 42,155 41,156 39,156" style="fill: rgb(103,72,70)" /> - <polygon points="157,196 161,194 163,197 159,199 157,199" style="fill: rgb(172,116,115)" /> - <polygon points="23,373 24,367 32,367 35,372 35,373" style="fill: rgb(35,39,40)" /> - <polygon points="286,250 287,249 288,250 289,251 291,256 292,261 290,262" style="fill: rgb(201,198,205)" /> - <polygon points="328,308 328,306 328,300 328,298 328,292 328,290 328,289 328,286 329,286 330,286 332,287 331,313 330,313 329,312 328,310" style="fill: rgb(122,134,132)" /> - <polygon points="360,309 360,308 360,307 360,306 360,297 360,296 360,295 361,310 361,313 360,313 360,297 360,296 360,295 361,310 361,313 360,313 360,297 360,296 360,295 361,310" style="fill: rgb(97,113,113)" /> - <polygon points="228,325 229,324 233,322 234,322 234,323 234,324 231,326 230,326 228,326" style="fill: rgb(141,101,101)" /> - <polygon points="96,78 96,77 96,75 98,75 99,75 100,75 102,77 102,78 100,79 99,79 98,79 97,79 96,79 96,75 98,75 99,75 100,75 102,77 102,78 100,79" style="fill: rgb(140,154,155)" /> - <polygon points="143,249 167,243 168,243 169,244 171,246 174,252 174,257 174,263 149,258 148,257 143,250" style="fill: rgb(184,119,123)" /> - <polygon points="135,331 136,331 138,332 146,338 147,339 143,342 138,341 135,337" style="fill: rgb(132,78,78)" /> - <polygon points="188,149 197,148 200,151 201,152 201,153 201,154 201,159 200,159 195,156 190,152 189,151" style="fill: rgb(123,89,88)" /> - <polygon points="311,274 311,273 311,272 317,271 320,272 321,274 320,276 313,277 311,275" style="fill: rgb(140,154,155)" /> - <polygon points="48,133 49,131 51,129 55,129 56,129 58,133 57,135 54,137" style="fill: rgb(74,50,46)" /> - <polygon points="240,163 240,162 240,159 244,160 246,161 246,162 244,165 242,164" style="fill: rgb(140,126,123)" /> - <polygon points="154,325 156,320 157,320 160,322 160,323 159,324 155,326" style="fill: rgb(141,87,87)" /> - <polygon points="34,25 36,23 38,24 42,40 49,73 49,74 48,82 47,82 46,82 39,71 37,67 35,40 34,26" style="fill: rgb(122,134,132)" /> - <polygon points="52,141 54,138 55,137 56,136 58,138 58,140 57,144 56,145" style="fill: rgb(74,50,46)" /> - <polygon points="257,107 258,106 262,105 337,94 341,94 342,94 343,94 348,115 349,122 349,123 349,124 349,125 346,126 278,132 277,132 271,132 270,132 266,131 263,129 262,128 261,126 257,109" style="fill: rgb(53,70,77)" /> - <polygon points="83,300 83,299 84,293 87,289 95,279 102,277 104,284 104,286 103,289 100,298 95,305 86,304" style="fill: rgb(84,45,46)" /> - <polygon points="63,96 65,92 69,91 69,100 67,99" style="fill: rgb(138,113,109)" /> - <polygon points="18,110 23,99 31,100 38,101 39,107 30,119 28,121 22,116 21,115 19,113" style="fill: rgb(35,39,40)" /> - <polygon points="111,143 116,140 117,141 120,145 123,150 122,151 119,150 111,147" style="fill: rgb(176,110,112)" /> - <polygon points="131,253 132,251 139,243 139,244 139,246 138,248 134,252 132,253" style="fill: rgb(141,87,87)" /> - <polygon points="93,390 94,386 102,385 101,388" style="fill: rgb(136,135,140)" /> - <polygon points="267,199 267,196 268,196 270,198 273,203 274,205 273,212" style="fill: rgb(208,174,188)" /> - <polygon points="0,396 5,392 6,394 6,395 4,398 1,397" style="fill: rgb(28,32,31)" /> - <polygon points="62,328 63,323 67,323 73,326 78,329 80,331 80,332 80,335 77,336 75,336" style="fill: rgb(31,35,36)" /> - <polygon points="238,204 238,203 238,202 238,201 242,196 244,196 245,196 246,196 248,197 249,204 249,205 247,230 245,229 241,217 239,209" style="fill: rgb(208,174,188)" /> - <polygon points="162,91 165,87 168,87 169,87 172,89 173,90 173,91 172,93 171,93 170,93 169,93 167,93 166,93 163,93 162,93" style="fill: rgb(138,113,109)" /> - <polygon points="279,136 280,136 281,136 282,136 283,136 284,136 285,136 286,136 286,138 284,138 279,137" style="fill: rgb(65,68,73)" /> - <polygon points="25,109 25,108 26,107 32,106 32,108 32,117 30,117 28,115 26,112" style="fill: rgb(35,39,40)" /> - <polygon points="223,197 223,196 225,193 226,193 227,194 225,206 224,206 223,201" style="fill: rgb(168,139,141)" /> - <polygon points="75,393 76,392 78,391 78,394 78,399 77,399 76,399 75,399" style="fill: rgb(111,107,106)" /> - <polygon points="107,242 107,241 109,240 111,240 112,240 112,242 111,242 110,242 109,242 108,242" style="fill: rgb(208,174,188)" /> - <polygon points="190,258 190,257 193,253 197,257 198,258 200,261 199,263" style="fill: rgb(187,128,132)" /> - <polygon points="2,316 3,308 4,309 5,311 5,313 5,314 4,316 3,318 2,317" style="fill: rgb(85,74,68)" /> - <polygon points="251,309 251,308 253,280 258,280 259,281 260,282 262,288 264,300 264,310 263,312 261,315 259,318 253,326 252,326" style="fill: rgb(208,174,188)" /> - <polygon points="115,101 115,100 115,98 116,95 120,95 127,97 128,100 122,102" style="fill: rgb(52,28,28)" /> - <polygon points="33,363 56,363 62,364 68,365 69,366 64,366 43,366 42,366 41,366 40,366 35,366" style="fill: rgb(18,18,18)" /> - <polygon points="9,307 9,306 13,305 13,311 12,317 11,317 9,309" style="fill: rgb(85,74,68)" /> - <polygon points="100,116 101,115 102,114 111,113 118,113 134,116 135,118 134,120" style="fill: rgb(141,87,87)" /> - <polygon points="97,343 99,341 101,341 101,342 100,347 99,348 98,348 97,347" style="fill: rgb(64,40,36)" /> - <polygon points="109,157 111,148 112,147 113,146 115,145 116,145 118,150 116,154" style="fill: rgb(176,110,112)" /> - <polygon points="381,43 381,42 381,41 381,40 381,37 382,36 399,35 399,44 399,52 399,54 397,61 392,63 383,48" style="fill: rgb(28,32,31)" /> - <polygon points="313,194 314,194 315,194 316,194 319,200 314,199 313,196" style="fill: rgb(122,134,132)" /> - <polygon points="220,180 222,181 226,187 226,188 224,187" style="fill: rgb(162,128,129)" /> - <polygon points="370,203 370,202 372,201 373,201 374,201 375,201 376,201 388,205 389,206 390,223 390,224 390,225 388,231 371,242" style="fill: rgb(201,198,205)" /> - <polygon points="122,390 123,388 124,386 125,385 127,386 127,389 125,392 124,392" style="fill: rgb(130,119,115)" /> - <polygon points="61,101 63,98 65,98 68,101 67,102 66,103 64,103" style="fill: rgb(118,100,98)" /> - <polygon points="282,133 288,131 289,131 290,131 291,131 292,131 295,131 294,141 288,138" style="fill: rgb(72,86,87)" /> - <polygon points="5,323 5,321 8,312 9,311 10,313 11,321 10,323 9,325 8,326 6,325" style="fill: rgb(50,51,53)" /> - <polygon points="18,299 18,298 18,291 18,290 19,290 20,292 24,301 24,302 24,303 22,306 21,307 20,305 18,300" style="fill: rgb(72,86,87)" /> - <polygon points="252,303 252,301 252,300 253,299 254,298 256,302 256,303 256,304 256,305 253,304" style="fill: rgb(196,153,163)" /> - <polygon points="308,262 309,262 328,264 330,265 327,277 326,278" style="fill: rgb(140,154,155)" /> - <polygon points="395,256 395,254 399,253 399,261 399,262 397,263 396,262" style="fill: rgb(43,56,62)" /> - <polygon points="233,185 235,186 244,191 244,192 239,212 238,211 237,208 235,200 233,191" style="fill: rgb(169,159,160)" /> - <polygon points="0,155 3,153 4,153 5,153 6,153 6,154 3,159 0,160" style="fill: rgb(122,134,132)" /> - <polygon points="172,347 172,345 173,344 174,344 175,345 176,348 175,349" style="fill: rgb(91,63,60)" /> - <polygon points="194,376 214,343 223,347 223,348 209,370 200,374 195,376" style="fill: rgb(141,101,101)" /> - <polygon points="7,243 7,242 9,236 10,234 18,234 24,235 34,238 35,248 35,249 34,253 32,258 31,259 21,259 20,259 12,258 7,257" style="fill: rgb(153,174,175)" /> - <polygon points="59,264 60,262 61,271 60,272" style="fill: rgb(123,89,88)" /> - <polygon points="150,277 151,274 153,272 155,273 156,274 156,275 155,276 154,277" style="fill: rgb(141,93,93)" /> - <polygon points="1,159 2,155 6,155 8,156 4,158 2,159" style="fill: rgb(122,134,132)" /> - <polygon points="195,348 197,344 199,341 199,342 199,348 196,351 195,350" style="fill: rgb(103,72,70)" /> - <polygon points="311,193 332,190 336,191 336,199 335,201 334,201 324,200 319,199 317,198" style="fill: rgb(153,174,175)" /> - <polygon points="142,109 143,108 144,108 149,109 150,110 151,111 148,111 147,111 143,110" style="fill: rgb(141,101,101)" /> - <polygon points="190,150 190,149 191,148 195,148 196,149 196,151 196,152" style="fill: rgb(123,89,88)" /> - <polygon points="218,300 221,297 228,297 229,301 228,302 223,306 220,303 219,302" style="fill: rgb(141,93,93)" /> - <polygon points="61,158 62,156 64,152 67,147 69,144 70,143 67,150 63,158 62,158" style="fill: rgb(141,93,93)" /> - <polygon points="108,274 108,273 108,271 111,270 112,270 114,274 108,275" style="fill: rgb(132,78,78)" /> - <polygon points="241,148 242,145 246,145 248,148 249,150 248,151 247,151" style="fill: rgb(147,129,125)" /> - <polygon points="350,89 350,87 350,85 350,83 350,81 350,79 350,78 353,70 355,70 356,70 357,70 366,80 375,94 377,99 379,108 380,113 381,121 381,123 374,125 352,126 351,110 350,93" style="fill: rgb(122,134,132)" /> - <polygon points="232,82 245,93 241,93 233,90 232,86" style="fill: rgb(65,68,73)" /> - <polygon points="118,99 122,98 124,98 126,100 120,100 119,100" style="fill: rgb(64,40,36)" /> - <polygon points="93,363 94,362 97,360 99,359 103,361 108,364 112,368 115,372 115,373 111,373 98,372 95,369 94,368" style="fill: rgb(43,56,62)" /> - <polygon points="153,250 156,250 159,253 159,254 155,253 154,252 153,251" style="fill: rgb(184,119,123)" /> - <polygon points="255,165 256,165 257,165 258,166 259,167 260,168 261,169 260,169 259,169 255,167" style="fill: rgb(168,139,141)" /> - <polygon points="174,265 175,265 178,270 182,279 184,285 184,286 183,285 180,282 179,281 176,277" style="fill: rgb(172,116,115)" /> - <polygon points="215,183 218,182 220,183 221,184 223,187 223,188 222,189 218,186" style="fill: rgb(188,143,140)" /> - <polygon points="30,309 30,308 30,307 30,306 30,305 31,303 36,297 56,294 59,301 59,318 41,320 40,320 39,320 33,317 31,315" style="fill: rgb(28,32,31)" /> - <polygon points="0,162 4,159 9,159 10,159 19,163 20,164 16,178 15,181 10,189 7,189 6,189 0,183" style="fill: rgb(140,154,155)" /> - <polygon points="68,203 69,203 70,203 75,203 77,203 78,206 78,207 75,207" style="fill: rgb(103,72,70)" /> - <polygon points="146,222 147,222 150,222 153,223 153,224 152,233 148,228 146,224" style="fill: rgb(172,116,115)" /> - <polygon points="133,281 133,280 134,280 135,280 136,280 137,280 138,280 139,280 140,280 141,280 142,280 149,281 134,281" style="fill: rgb(122,68,66)" /> - <polygon points="118,352 119,350 125,348 128,353 129,355 127,355 120,354 119,353" style="fill: rgb(103,52,51)" /> - <polygon points="169,349 179,340 191,357 191,359 189,362 183,365 177,366 176,366 175,365 171,360 169,350" style="fill: rgb(52,28,28)" /> - <polygon points="106,380 107,379 112,378 112,379 110,382" style="fill: rgb(36,47,51)" /> - <polygon points="387,325 393,279 395,277 396,277 397,277 398,277 396,313 394,328 393,328 392,328 390,328 389,328 388,327" style="fill: rgb(153,174,175)" /> - <polygon points="244,322 246,316 248,312 250,310 251,310 256,312 256,313 256,314 255,318 252,327 251,328 246,330" style="fill: rgb(196,153,163)" /> - <polygon points="343,399 343,398 344,394 346,391 349,387 350,386 352,386 352,399 349,399 343,398 344,394 346,391 349,387 350,386 352,386 352,399 349,399 343,398 344,394 346,391 349,387 350,386 352,386 352,399 349,399 343,398 344,394 346,391 349,387 350,386 352,386 352,399 349,399 343,398 344,394 346,391 349,387 350,386 352,386 352,399 349,399 343,398 344,394 346,391 349,387 350,386 352,386 352,399 349,399 343,398 344,394 346,391 349,387 350,386 352,386 352,399 349,399 343,398 344,394 346,391 349,387 350,386 352,386 352,399 349,399 343,398 344,394 346,391 349,387 350,386 352,386 352,399 349,399 343,398 344,394 346,391 349,387 350,386 352,386 352,399 349,399 343,398 344,394 346,391 349,387 350,386 352,386 352,399 349,399 343,398 344,394 346,391 349,387 350,386 352,386 352,399 349,399 343,398" style="fill: rgb(234,243,252)" /> - <polygon points="104,172 106,165 119,152 134,137 141,133 146,132 156,132 158,133 159,134 159,135 149,162 119,170 110,172 109,172 108,172" style="fill: rgb(187,128,132)" /> - <polygon points="386,121 386,120 386,119 386,118 386,117 386,116 387,109 389,106 394,108 397,116 397,120 395,122 393,123 386,124" style="fill: rgb(43,56,62)" /> - <polygon points="249,177 251,174 253,173 255,176 253,178" style="fill: rgb(138,113,109)" /> - <polygon points="121,207 121,205 122,204 127,204 131,205 133,208 125,210 124,210 122,208" style="fill: rgb(159,108,107)" /> - <polygon points="162,275 163,270 165,269 166,269 168,272 167,273" style="fill: rgb(103,52,51)" /> - <polygon points="0,203 3,204 6,205 6,206 5,206 0,205" style="fill: rgb(122,134,132)" /> - <polygon points="374,240 374,229 375,228 391,225 391,236 387,237" style="fill: rgb(201,198,205)" /> - <polygon points="72,157 72,149 75,144 76,149" style="fill: rgb(165,109,110)" /> - <polygon points="232,141 235,139 238,141 240,143 238,149 237,150 236,149 235,148 233,146" style="fill: rgb(147,129,125)" /> - <polygon points="26,135 31,130 34,129 36,129 38,132 33,134 28,135 27,135" style="fill: rgb(91,63,60)" /> - <polygon points="210,365 212,361 213,360 217,359 218,360 216,364 214,365 212,366" style="fill: rgb(138,113,109)" /> - <polygon points="103,133 103,131 107,127 119,125 128,126 134,128 134,129 128,130" style="fill: rgb(176,110,112)" /> - <polygon points="102,297 104,294 109,288 113,287 116,287 117,287 118,287 119,288 102,298" style="fill: rgb(103,52,51)" /> - <polygon points="72,236 72,235 76,233 79,232 82,232 85,235 82,240 81,241 80,242 79,243 78,244 73,238" style="fill: rgb(132,78,78)" /> - <polygon points="166,205 167,203 171,203 170,206" style="fill: rgb(176,110,112)" /> - <polygon points="111,267 113,264 115,263 116,263 119,264 123,266 114,269" style="fill: rgb(141,87,87)" /> - <polygon points="95,374 115,374 117,375 118,376 118,377 106,382 96,382 95,381 95,380" style="fill: rgb(31,35,36)" /> - <polygon points="92,270 93,268 104,266 105,266 110,281 110,288 103,295 102,296" style="fill: rgb(91,63,60)" /> - <polygon points="110,253 113,251 115,250 117,249 123,249 124,249 125,249 126,249 125,250 123,251 120,252 112,253" style="fill: rgb(52,28,28)" /> - <polygon points="196,376 197,375 207,369 211,368 211,369 209,371 208,372 203,375 199,377 198,377" style="fill: rgb(138,113,109)" /> - <polygon points="159,283 171,286 172,287 172,289 170,291 165,294 160,288" style="fill: rgb(176,110,112)" /> - <polygon points="218,153 219,153 220,153 223,153 224,154 224,155 222,156 220,155 218,154" style="fill: rgb(103,91,91)" /> - <polygon points="186,317 189,313 190,312 191,314 191,316 189,319 187,318" style="fill: rgb(121,87,86)" /> - <polygon points="41,70 44,72 49,83 49,84 48,84 45,83 43,80 41,74" style="fill: rgb(122,134,132)" /> - <polygon points="362,316 362,315 362,314 364,319 364,325 363,325" style="fill: rgb(97,113,113)" /> - <polygon points="0,282 2,279 3,279 6,287 1,289 0,289" style="fill: rgb(84,45,46)" /> - <polygon points="169,372 171,370 179,366 184,364 193,362 194,362 191,365 187,367 171,374" style="fill: rgb(84,45,46)" /> - <polygon points="196,360 196,358 201,356 202,356 202,357 202,358 202,359 201,363 200,363 198,362" style="fill: rgb(103,72,70)" /> - <polygon points="29,112 29,111 29,110 30,109 35,108 37,114 37,115 35,116 34,116 33,116 32,116" style="fill: rgb(52,28,28)" /> - <polygon points="303,128 306,127 307,127 308,127 310,127 311,127 312,127 318,127 306,128" style="fill: rgb(53,70,77)" /> - <polygon points="342,237 344,237 347,238 347,240 346,241 345,241 344,241 343,241" style="fill: rgb(72,86,87)" /> - <polygon points="85,253 85,252 85,249 86,249 104,255 106,259 95,256" style="fill: rgb(141,93,93)" /> - <polygon points="165,263 166,262 171,266 172,267 173,270 171,272" style="fill: rgb(122,68,66)" /> - <polygon points="142,170 148,168 153,167 154,167 157,169 156,170 155,171 150,174 148,175 145,176" style="fill: rgb(91,63,60)" /> - <polygon points="0,314 0,312 1,310 3,310 3,311 3,312 3,313 1,318 0,317" style="fill: rgb(85,74,68)" /> - <polygon points="83,76 95,73 95,75 95,76 89,84 88,83" style="fill: rgb(122,134,132)" /> - <polygon points="31,0 33,0 37,22 37,24 35,38 34,39 33,32" style="fill: rgb(122,134,132)" /> - <polygon points="19,356 23,348 29,347 30,347 31,348 33,351 40,362 32,366 28,368 23,366" style="fill: rgb(28,32,31)" /> - <polygon points="305,182 311,182 328,191 327,196 325,196 307,192" style="fill: rgb(153,174,175)" /> - <polygon points="86,255 86,254 87,254 88,254 103,256 104,258 91,267 90,266 89,265 88,264 87,262" style="fill: rgb(103,52,51)" /> - <polygon points="234,255 235,254 237,252 238,252 240,253 236,260 235,260 234,257" style="fill: rgb(168,139,141)" /> - <polygon points="398,318 398,314 399,314 399,323 398,322 398,314 399,314 399,323 398,322 398,314 399,314 399,323 398,322 398,314 399,314 399,323" style="fill: rgb(43,56,62)" /> - <polygon points="11,355 24,368 26,370 26,371 22,373 19,373 11,359 11,358" style="fill: rgb(47,48,50)" /> - <polygon points="229,182 230,181 234,180 236,181 238,182 239,183 236,183 233,183" style="fill: rgb(168,139,141)" /> - <polygon points="94,206 96,205 97,206 97,209 97,210 96,213 95,214" style="fill: rgb(160,100,100)" /> - <polygon points="115,236 115,235 115,234 119,228 126,228 135,238 135,239 135,240 135,241 135,242 135,243 134,244 133,245 127,246 126,246 122,245" style="fill: rgb(196,153,163)" /> - <polygon points="134,214 136,213 137,213 140,214 140,219 140,220 140,221 135,216" style="fill: rgb(165,109,110)" /> - <polygon points="328,235 329,234 332,233 335,232 344,233 339,244 338,244 332,240 329,237" style="fill: rgb(72,86,87)" /> - <polygon points="108,184 114,183 115,183 119,186 120,190 122,198 122,199 108,185" style="fill: rgb(141,93,93)" /> - <polygon points="239,148 240,148 243,149 245,150 246,151 245,152 244,152 241,150" style="fill: rgb(168,139,141)" /> - <polygon points="150,208 153,206 158,208 158,209 156,212 155,212 154,212" style="fill: rgb(160,100,100)" /> - <polygon points="63,395 67,393 73,391 74,392 71,395 64,395" style="fill: rgb(136,135,140)" /> - <polygon points="54,190 56,190 58,193 58,194 56,196 55,195 54,191" style="fill: rgb(151,95,96)" /> - <polygon points="80,131 81,128 83,126 85,124 89,121 94,119 100,119 101,119 102,119 103,120" style="fill: rgb(154,99,96)" /> - <polygon points="88,378 89,375 93,374 94,374 94,377 90,379 89,379" style="fill: rgb(28,32,31)" /> - <polygon points="158,281 161,280 162,280 163,280 164,280 167,282 165,286 164,286" style="fill: rgb(163,103,105)" /> - <polygon points="223,176 228,176 235,181 234,181 226,180 225,179 224,178" style="fill: rgb(168,139,141)" /> - <polygon points="26,307 26,306 30,301 31,300 32,299 30,304 27,309 26,308" style="fill: rgb(36,47,51)" /> - <polygon points="163,179 165,177 168,179 169,180 169,181 166,181 163,180" style="fill: rgb(168,139,141)" /> - <polygon points="35,174 38,174 39,176 39,187 39,188 39,189 39,190 38,190 37,189 36,187 35,176" style="fill: rgb(52,28,28)" /> - <polygon points="71,387 74,385 78,383 79,384 78,385 75,386 72,387" style="fill: rgb(27,28,30)" /> - <polygon points="183,140 186,139 189,144 188,145 187,145" style="fill: rgb(138,113,109)" /> - <polygon points="100,82 101,80 103,78 107,77 107,78 106,80 101,82" style="fill: rgb(111,107,106)" /> - <polygon points="222,197 222,195 222,193 224,190 225,192 223,204 222,203" style="fill: rgb(188,143,140)" /> - <polygon points="340,316 347,315 356,314 357,314 358,314 360,316 359,322 346,318" style="fill: rgb(122,134,132)" /> - <polygon points="156,348 159,343 164,340 166,345 166,346 166,347 159,349 158,349" style="fill: rgb(64,40,36)" /> - <polygon points="47,205 49,203 50,202 51,202 53,203 55,205 55,206 55,207 49,211 47,211" style="fill: rgb(141,87,87)" /> - <polygon points="106,190 108,186 109,185 111,184 114,190 113,191 110,192 108,192" style="fill: rgb(121,87,86)" /> - <polygon points="353,260 353,259 353,258 353,256 353,255 353,254 354,254 357,254 358,255 358,259 358,263 357,274 356,276 355,274 354,270 353,262" style="fill: rgb(43,56,62)" /> - <polygon points="187,121 193,120 195,130 193,131 192,130" style="fill: rgb(147,129,125)" /> - <polygon points="95,240 95,237 95,236 95,235 95,230 100,199 101,197 102,197 104,198 109,205 100,240" style="fill: rgb(184,119,123)" /> - <polygon points="194,323 195,322 198,321 199,321 199,322 199,325 197,325 194,324" style="fill: rgb(121,87,86)" /> - <polygon points="140,72 141,72 142,72 143,72 149,73 152,75 150,76 144,75" style="fill: rgb(153,174,175)" /> - <polygon points="77,293 77,292 77,289 77,288 80,286 81,287 82,292 83,297 83,298 78,301 77,297" style="fill: rgb(132,78,78)" /> - <polygon points="181,111 182,110 187,109 188,115 188,116 188,117 183,119" style="fill: rgb(121,87,86)" /> - <polygon points="91,391 91,390 92,389 93,388 98,388 102,389 102,390 100,394 99,396 93,397 92,395" style="fill: rgb(122,134,132)" /> - <polygon points="231,263 232,263 234,264 235,265 234,275 232,277 231,264" style="fill: rgb(168,139,141)" /> - <polygon points="43,84 48,86 48,92 48,93 43,85" style="fill: rgb(140,154,155)" /> - <polygon points="7,144 8,142 9,141 23,132 28,131 30,131 32,131 33,132 42,146 52,164 53,174 52,176 51,177 50,177 40,173 27,164 7,146" style="fill: rgb(91,63,60)" /> - <polygon points="385,339 385,337 388,336 389,336 390,336 394,337 395,338 396,340 397,342 397,343 397,344 397,345 396,346 393,347 385,340" style="fill: rgb(201,198,205)" /> - <polygon points="0,0 2,0 3,0 4,0 5,0 6,0 7,0 8,0 9,0 10,0 11,0 12,0 13,0 14,0 15,0 16,0 17,0 18,0 19,0 20,0 21,0 22,0 23,0 24,0 25,0 26,0 27,0 28,0 29,0 30,0 35,55 35,62 35,63 35,64 35,75 34,77 32,81 1,59 0,58" style="fill: rgb(53,70,77)" /> - <polygon points="157,234 158,233 160,233 166,237 182,248 183,250 182,255 175,261 174,261 172,260 169,255" style="fill: rgb(172,116,115)" /> - <polygon points="207,351 208,346 209,346 212,347 212,348 211,353 210,353" style="fill: rgb(121,87,86)" /> - <polygon points="229,176 230,175 231,174 236,174 237,175 237,176 236,177 235,177 234,177 233,177" style="fill: rgb(168,139,141)" /> - <polygon points="230,213 231,211 233,210 232,217" style="fill: rgb(188,143,140)" /> - <polygon points="86,305 87,304 100,304 101,304 93,309 91,309 89,308" style="fill: rgb(122,68,66)" /> - <polygon points="169,142 171,140 178,143 182,149 188,160 185,159 178,154 173,148 169,143" style="fill: rgb(172,116,115)" /> - <polygon points="168,277 169,274 170,273 174,278 172,279 171,279 169,278" style="fill: rgb(84,45,46)" /> - <polygon points="172,75 172,73 176,72 177,72 178,75 177,76 176,77" style="fill: rgb(102,87,84)" /> - <polygon points="238,315 239,312 241,309 247,310 246,312 239,315" style="fill: rgb(147,129,125)" /> - <polygon points="28,160 28,159 29,157 30,157 31,157 33,157 33,160 33,161 32,162 29,161" style="fill: rgb(84,45,46)" /> - <polygon points="62,141 65,135 74,126 75,126 75,127 63,142" style="fill: rgb(103,52,51)" /> - <polygon points="210,139 210,132 211,132 221,135 223,139 224,141 222,146 221,146 220,146 211,141" style="fill: rgb(168,139,141)" /> - <polygon points="114,388 116,384 117,384 122,385 122,386 117,388" style="fill: rgb(122,134,132)" /> - <polygon points="390,125 396,124 396,126 392,143" style="fill: rgb(201,198,205)" /> - <polygon points="120,182 120,179 121,178 122,178 125,181 125,182 122,182 121,181 120,179 121,178 122,178 125,181 125,182 122,182 121,181" style="fill: rgb(52,28,28)" /> - <polygon points="91,245 92,241 93,239 95,239 94,248" style="fill: rgb(184,119,123)" /> - <polygon points="143,314 144,313 145,312 152,306 153,306 157,307 154,316 149,318 146,318 143,315" style="fill: rgb(176,110,112)" /> - <polygon points="93,326 93,325 94,322 95,322 100,324 102,325 100,336 95,338 93,331" style="fill: rgb(84,45,46)" /> - <polygon points="75,315 76,314 82,309 109,294 110,294 126,303 132,312 133,334 130,337 129,338 128,339 127,339 89,336 80,323" style="fill: rgb(132,78,78)" /> - <polygon points="81,286 83,284 89,284 91,286 83,296 82,291" style="fill: rgb(122,68,66)" /> - <polygon points="33,368 34,368 35,369 37,371 38,372 37,373 36,373" style="fill: rgb(47,48,50)" /> - <polygon points="121,285 124,283 126,282 129,281 130,281 131,282 122,285" style="fill: rgb(122,68,66)" /> - <polygon points="348,282 349,282 350,282 351,282 352,282 353,282 354,282 355,282 356,282 357,282 358,282 360,286 361,304 361,309 360,312 359,313 357,313" style="fill: rgb(140,154,155)" /> - <polygon points="89,327 93,319 101,322 102,323 103,325 102,327 92,329" style="fill: rgb(122,68,66)" /> - <polygon points="99,345 99,342 102,341 103,341 134,359 135,360 135,361 135,362 135,363 133,366 130,369 128,369 122,369 116,368 112,365 102,357 101,354 100,350" style="fill: rgb(64,40,36)" /> - <polygon points="280,258 283,251 284,250 286,262 286,265 281,266 280,263" style="fill: rgb(169,159,160)" /> - <polygon points="135,307 137,304 139,302 140,302 151,305 151,307 147,309 146,309 145,309 136,308" style="fill: rgb(184,119,123)" /> - <polygon points="398,90 398,89 399,86 399,94 399,96 399,97 398,93 398,89 399,86 399,94 399,96 399,97 398,93 398,89" style="fill: rgb(35,39,40)" /> - <polygon points="4,256 6,251 14,276 10,279 9,278 6,274 4,266" style="fill: rgb(97,113,113)" /> - <polygon points="143,212 143,210 146,208 152,206 156,209 156,210 155,211 153,212 147,214 146,214 145,214" style="fill: rgb(154,99,96)" /> - <polygon points="368,329 369,329 370,329 372,329 373,329 374,329 375,329 376,329 377,329 378,329 379,329 380,329 381,329 382,329 383,329 384,329 371,329" style="fill: rgb(201,198,205)" /> - <polygon points="389,197 389,195 389,194 391,133 393,129 395,126 396,125 397,137 399,164 399,184 399,185 399,190 398,192 395,196 394,197 391,198 390,198" style="fill: rgb(201,198,205)" /> - <polygon points="117,299 119,298 120,298 121,298 122,298 127,301 127,302 125,306 124,306 119,304" style="fill: rgb(141,93,93)" /> - <polygon points="63,368 71,367 72,367 73,367 74,367 71,369 69,369" style="fill: rgb(27,28,30)" /> - <polygon points="253,229 253,228 254,229 256,232 257,234 258,242 258,244 258,245 258,246 257,246 256,242" style="fill: rgb(208,174,188)" /> - <polygon points="327,200 331,199 336,200 337,203 337,205 330,202" style="fill: rgb(122,134,132)" /> - <polygon points="76,382 79,374 83,374 85,374 85,375 84,379 80,383 78,384 77,384" style="fill: rgb(24,24,24)" /> - <polygon points="56,399 57,398 61,395 65,396 65,397 65,398 65,399 64,399 59,399 58,399" style="fill: rgb(130,119,115)" /> - <polygon points="158,157 160,149 165,134 212,175 213,176 214,177 239,210 244,219 246,225 246,226 242,246 232,276 225,289 224,290 210,297 209,297 203,294 202,293 181,234 158,161" style="fill: rgb(208,174,188)" /> - <polygon points="96,265 103,260 109,262 107,264 100,268 97,266" style="fill: rgb(84,45,46)" /> - <polygon points="107,347 108,344 110,343 114,342 116,345 116,346 114,350 111,349" style="fill: rgb(84,45,46)" /> - <polygon points="150,108 151,105 152,102 154,104 155,105 155,108 152,110 151,110" style="fill: rgb(147,129,125)" /> - <polygon points="70,182 72,174 73,172 79,172 81,173 83,174 84,177 84,183 84,185 81,192 80,192 71,184" style="fill: rgb(172,116,115)" /> - <polygon points="16,346 17,344 20,342 27,341 31,346 28,349 27,349 20,348" style="fill: rgb(28,32,31)" /> - <polygon points="17,132 19,130 20,129 29,126 30,126 33,128 32,129 21,135" style="fill: rgb(85,74,68)" /> - <polygon points="17,339 17,335 18,334 19,333 20,334 21,335 20,338 19,339" style="fill: rgb(36,47,51)" /> - <polygon points="11,136 18,133 18,135 17,138 14,139 11,137" style="fill: rgb(103,72,70)" /> - <polygon points="365,317 390,280 391,279 394,277 394,310 394,311 394,312 394,313 388,328 384,328 380,328 379,328 378,328 377,328 374,328 373,328 372,328 371,328 370,328 369,328 368,328 367,328 366,324" style="fill: rgb(140,154,155)" /> - <polygon points="137,231 138,230 140,229 146,233 155,240 161,246 159,248 143,240 137,232" style="fill: rgb(156,92,93)" /> - <polygon points="212,319 212,318 212,315 214,314 215,314 215,319 215,322 214,323" style="fill: rgb(91,63,60)" /> - <polygon points="209,172 213,174 219,179 221,182 222,184 223,186 222,187 221,186" style="fill: rgb(168,139,141)" /> - <polygon points="165,397 165,394 166,391 167,389 169,387 170,386 172,385 174,384 189,378 192,377 193,378 193,379 171,399 167,399" style="fill: rgb(138,113,109)" /> - <polygon points="283,267 286,267 287,269 285,273 284,272 283,270" style="fill: rgb(168,139,141)" /> - <polygon points="62,251 62,250 62,249 63,248 71,244 87,239 88,240 91,277 90,280 78,303 77,302 67,285 64,279 63,273 62,257 62,256" style="fill: rgb(156,92,93)" /> - <polygon points="164,166 165,166 166,166 167,166 171,167 174,170 170,172 169,172 168,172" style="fill: rgb(159,108,107)" /> - <polygon points="94,225 94,224 94,223 94,221 96,221 96,224 95,228 94,227" style="fill: rgb(169,103,107)" /> - <polygon points="104,268 106,266 112,262 112,263 111,265 110,266 105,268" style="fill: rgb(115,74,72)" /> - <polygon points="142,327 145,324 147,324 149,325 152,329 152,330 149,332 147,332 144,330" style="fill: rgb(154,99,96)" /> - <polygon points="132,271 134,269 136,269 136,270 136,271 135,274 134,274 132,272" style="fill: rgb(115,74,72)" /> - <polygon points="37,204 41,190 43,198 44,206 44,208 44,210 44,211" style="fill: rgb(74,50,46)" /> - <polygon points="0,305 1,300 2,301 2,302 2,304 2,305 2,306 2,307 2,308 2,309 0,311" style="fill: rgb(74,50,46)" /> - <polygon points="187,301 190,299 191,300 194,303 192,303 188,303 187,302" style="fill: rgb(162,128,129)" /> - <polygon points="88,248 89,247 99,252 101,253 93,253 90,252 89,251" style="fill: rgb(160,100,100)" /> - <polygon points="234,237 234,236 234,235 234,234 235,234 236,234 236,236 235,243" style="fill: rgb(208,174,188)" /> - <polygon points="17,123 19,121 22,118 23,118 28,122 22,124 18,125 17,125" style="fill: rgb(43,56,62)" /> - <polygon points="96,194 98,192 99,191 100,191 103,194 103,195 103,196 101,202 96,198" style="fill: rgb(172,116,115)" /> - <polygon points="47,268 47,267 49,266 50,266 52,267 52,269 48,269" style="fill: rgb(36,47,51)" /> - <polygon points="275,189 276,190 278,196 279,202 279,208 279,209 278,208" style="fill: rgb(196,153,163)" /> - <polygon points="112,125 113,123 115,122 119,124 120,125 117,126 115,126 114,126 113,126" style="fill: rgb(163,107,106)" /> - <polygon points="295,226 295,222 296,222 297,222 298,222 298,223 298,225 298,226 298,227 298,228 298,229" style="fill: rgb(86,87,89)" /> - <polygon points="395,269 395,267 395,261 395,257 399,263 399,265 397,271" style="fill: rgb(53,70,77)" /> - <polygon points="104,390 104,389 107,386 108,386 111,386 111,388 110,390 107,392 104,391" style="fill: rgb(122,134,132)" /> - <polygon points="16,349 21,349 21,350 19,352 18,352 17,351" style="fill: rgb(28,32,31)" /> - <polygon points="45,368 46,368 50,369 54,370 54,373 52,373 50,372" style="fill: rgb(28,32,31)" /> - <polygon points="0,206 2,206 3,206 4,206 7,207 2,208 0,207" style="fill: rgb(97,113,113)" /> - <polygon points="122,377 124,376 125,376 126,376 127,376 130,376 131,378 129,378" style="fill: rgb(65,68,73)" /> - <polygon points="110,284 110,283 113,277 123,267 124,267 127,268 130,270 132,280 132,281 120,285 119,285 118,285" style="fill: rgb(122,68,66)" /> - <polygon points="139,332 142,333 144,335 144,336 144,337 141,338" style="fill: rgb(141,87,87)" /> - <polygon points="381,32 383,32 395,32 396,32 397,32 390,35 389,35 383,34" style="fill: rgb(35,39,40)" /> - <polygon points="265,177 267,175 270,176 271,178 271,179 271,181 269,181" style="fill: rgb(162,128,129)" /> - <polygon points="106,56 107,53 114,52 116,54 112,58 108,58 107,57" style="fill: rgb(184,119,123)" /> - <polygon points="270,313 274,308 278,305 279,305 277,308 275,310 274,311 273,312" style="fill: rgb(169,159,160)" /> - <polygon points="56,189 57,188 58,188 62,190 63,191 65,194 66,197 60,199 57,197" style="fill: rgb(154,99,96)" /> - <polygon points="18,187 20,181 22,182 21,187 20,190 18,189" style="fill: rgb(86,87,89)" /> - <polygon points="260,149 260,146 262,142 267,150 267,151 267,152 267,153 267,154 266,159 265,160 263,158 262,156 260,151" style="fill: rgb(168,139,141)" /> - <polygon points="86,301 87,296 90,294 91,294 98,296 101,298 102,299 100,303 97,303 92,303 91,303" style="fill: rgb(84,45,46)" /> - <polygon points="6,215 6,213 7,212 13,211 14,211 15,211 16,211 18,214 18,215 18,216 18,217 18,218 17,218 14,218 8,217" style="fill: rgb(140,154,155)" /> - <polygon points="210,97 212,96 213,96 214,103 214,105 214,107 213,106 210,100" style="fill: rgb(85,74,68)" /> - <polygon points="147,319 152,316 153,316 154,317 153,327 148,323" style="fill: rgb(163,103,105)" /> - <polygon points="50,278 51,276 53,276 54,276 57,280 57,283 51,281" style="fill: rgb(41,53,53)" /> - <polygon points="103,150 110,142 112,145 109,150 105,151 104,151" style="fill: rgb(176,110,112)" /> - <polygon points="162,130 164,128 164,129 164,132 164,136 162,136" style="fill: rgb(168,139,141)" /> - <polygon points="27,359 35,350 52,352 59,353 63,355 75,364 76,366 41,362 31,360" style="fill: rgb(27,28,30)" /> - <polygon points="257,327 272,281 273,279 275,280 276,281 276,282 273,296 271,304 268,314 266,318 261,323 260,324 259,325 258,326" style="fill: rgb(208,174,188)" /> - <polygon points="0,184 16,165 21,164 27,199 27,200 25,202 0,192" style="fill: rgb(97,113,113)" /> - <polygon points="293,168 296,160 296,170 294,171" style="fill: rgb(86,87,89)" /> - <polygon points="392,234 392,232 392,230 392,229 392,226 392,224 394,207 395,204 398,205 399,218 399,230 397,234 395,236 394,236 393,236" style="fill: rgb(122,134,132)" /> - <polygon points="154,399 159,390 167,385 175,381 176,382 165,396 162,399 160,399" style="fill: rgb(141,93,93)" /> - <polygon points="45,151 47,147 56,138 56,139 54,144 51,150 48,154 47,154" style="fill: rgb(91,63,60)" /> - <polygon points="170,232 171,182 173,181 175,180 176,180 191,184 193,185 194,186 198,194 221,290 220,293 218,295 209,299 199,302 196,302 194,301 189,294" style="fill: rgb(196,153,163)" /> - <polygon points="64,192 72,194 73,196 71,197 67,197 66,196" style="fill: rgb(154,99,96)" /> - <polygon points="46,381 53,376 59,377 62,378 70,381 72,382 62,383 49,384 48,384 47,383" style="fill: rgb(13,13,13)" /> - <polygon points="112,230 112,229 112,228 113,228 114,228 115,228 116,228 116,229 113,231" style="fill: rgb(208,174,188)" /> - <polygon points="79,301 84,301 84,307 83,308 81,307 79,302" style="fill: rgb(141,93,93)" /> - <polygon points="158,190 159,188 160,188 162,189 164,190 158,193" style="fill: rgb(64,40,36)" /> - <polygon points="79,200 89,200 92,201 92,208 92,212 92,213" style="fill: rgb(141,87,87)" /> - <polygon points="306,244 306,242 307,242 310,242 318,242 319,243 324,250 324,251 324,253 323,253 322,253 307,248 306,247" style="fill: rgb(140,154,155)" /> - <polygon points="133,158 153,137 161,134 164,137 163,149 161,158 157,161 151,162 150,162 135,161" style="fill: rgb(188,143,140)" /> - <polygon points="33,289 34,286 35,284 37,284 38,286 37,289" style="fill: rgb(72,86,87)" /> - <polygon points="35,67 35,65 36,74 36,75 36,76 35,74 35,66 35,65 36,74 36,75 36,76 35,74 35,66" style="fill: rgb(43,56,62)" /> - <polygon points="0,290 3,288 5,287 5,288 5,289 4,293 3,295 0,298" style="fill: rgb(103,52,51)" /> - <polygon points="108,196 110,194 115,192 118,192 119,193 126,203 125,205 124,206 123,206" style="fill: rgb(138,113,109)" /> - <polygon points="67,395 68,394 70,395 69,399 68,399 67,396" style="fill: rgb(122,134,132)" /> - <polygon points="260,250 262,248 265,247 266,247 267,247 268,247 269,247 270,252 270,253 270,254 262,252" style="fill: rgb(201,198,205)" /> - <polygon points="284,140 287,139 291,138 290,141 289,143 288,143 286,142 285,141" style="fill: rgb(86,87,89)" /> - <polygon points="257,213 259,208 260,209 262,216 262,217 260,217 258,215 257,214" style="fill: rgb(160,100,100)" /> - <polygon points="193,374 204,359 205,360 206,361 206,362 202,368 201,369 196,374 195,375 194,375" style="fill: rgb(121,87,86)" /> - <polygon points="205,97 206,95 207,94 212,93 211,96 209,97 205,99" style="fill: rgb(102,87,84)" /> - <polygon points="126,67 128,65 129,65 130,65 132,67 132,70 131,71 130,71 129,71 128,71 126,71" style="fill: rgb(153,174,175)" /> - <polygon points="34,205 36,204 38,205 38,207 37,210 34,206" style="fill: rgb(103,72,70)" /> - <polygon points="150,180 151,178 155,174 157,174 164,181 165,182 164,183 163,183 162,183 161,183 158,183 157,183 156,183 155,183 154,183" style="fill: rgb(162,128,129)" /> - <polygon points="381,34 381,33 383,33 384,33 385,33 386,33 388,35 381,36" style="fill: rgb(31,35,36)" /> - <polygon points="199,308 200,307 202,306 207,305 208,309 207,310 206,310" style="fill: rgb(141,101,101)" /> - <polygon points="0,220 0,208 8,207 22,206 29,211 0,222" style="fill: rgb(153,174,175)" /> - <polygon points="82,1 83,1 94,7 96,13 96,15 88,8 87,7 85,5" style="fill: rgb(72,86,87)" /> - <polygon points="338,212 338,211 338,208 338,207 338,204 338,203 338,202 338,201 339,200 342,203 342,212 342,213 341,214 339,214 338,213" style="fill: rgb(201,198,205)" /> - <polygon points="5,353 13,348 15,347 16,361 9,357 8,356 7,355" style="fill: rgb(36,47,51)" /> - <polygon points="265,61 266,61 267,62 267,69 266,69" style="fill: rgb(41,53,53)" /> - <polygon points="165,307 166,304 168,303 170,303 168,310 167,310" style="fill: rgb(165,109,110)" /> - <polygon points="215,298 215,297 227,287 228,288 226,299 216,302" style="fill: rgb(188,143,140)" /> - <polygon points="37,390 37,389 38,388 45,386 60,385 61,385 62,385 63,385 68,385 69,385 50,397 40,398" style="fill: rgb(27,28,30)" /> - <polygon points="55,269 55,266 55,265 55,262 57,266 57,271 56,271" style="fill: rgb(50,51,53)" /> - <polygon points="136,163 153,162 158,163 158,164 139,167 137,167 136,167" style="fill: rgb(162,128,129)" /> - <polygon points="117,273 117,272 117,269 117,268 118,268 120,272 120,278 119,278 118,276" style="fill: rgb(91,63,60)" /> - <polygon points="30,22 32,22 32,26 30,29" style="fill: rgb(53,70,77)" /> - <polygon points="124,348 125,347 129,348 128,352 127,351 126,350" style="fill: rgb(103,52,51)" /> - <polygon points="209,156 209,153 213,154 214,156 213,160" style="fill: rgb(140,126,123)" /> - <polygon points="135,175 136,173 142,172 145,173 144,175 143,176" style="fill: rgb(64,40,36)" /> - <polygon points="130,291 133,288 135,288 136,288 138,290 138,291 137,298 135,297 133,295" style="fill: rgb(172,116,115)" /> - <polygon points="181,139 182,135 183,134 186,135 187,138 187,139 185,140 181,141" style="fill: rgb(118,100,98)" /> - <polygon points="257,141 257,133 257,132 258,134 258,141" style="fill: rgb(121,87,86)" /> - <polygon points="319,229 324,229 327,230 324,231 323,231 322,231 321,231 319,230" style="fill: rgb(122,134,132)" /> - <polygon points="143,267 158,260 164,260 166,261 171,269 170,272 169,273 168,273 151,271 145,270 143,268" style="fill: rgb(103,52,51)" /> - <polygon points="333,259 333,258 334,257 341,258 341,275 341,276 335,271 334,269 333,261" style="fill: rgb(97,113,113)" /> - <polygon points="255,219 261,221 261,222 260,224 257,223" style="fill: rgb(184,119,123)" /> - <polygon points="199,139 199,138 200,134 204,134 205,135 209,139 210,145 204,143 200,140" style="fill: rgb(162,128,129)" /> - <polygon points="297,274 297,270 297,269 299,268 304,267 305,267 311,268 311,269 302,275 301,275" style="fill: rgb(72,86,87)" /> - <polygon points="171,283 174,283 180,288 178,294 177,296 176,296 173,293" style="fill: rgb(163,107,106)" /> - <polygon points="46,338 46,336 47,336 49,337 50,338 51,339 51,340 50,340 46,339" style="fill: rgb(31,35,36)" /> - <polygon points="137,306 153,283 156,283 158,284 161,286 163,288 164,294 164,295 159,304 158,305 157,306 148,307 147,307 146,307 145,307 143,307 139,307 138,307 137,307" style="fill: rgb(187,128,132)" /> - <polygon points="86,179 87,177 89,177 90,183 89,184 88,183 87,182 86,180" style="fill: rgb(163,107,106)" /> - <polygon points="140,89 141,86 142,86 147,91 148,93 147,93" style="fill: rgb(118,100,98)" /> - <polygon points="300,291 308,290 309,290 310,290 315,294 316,296 316,299 315,299 301,294 300,293" style="fill: rgb(86,87,89)" /> - <polygon points="58,189 60,186 63,183 64,183 65,183 65,188 65,189" style="fill: rgb(160,100,100)" /> - <polygon points="58,156 58,155 58,154 58,153 61,147 62,146 61,151 60,154" style="fill: rgb(115,74,72)" /> - <polygon points="31,276 31,275 33,273 36,273 37,273 36,275" style="fill: rgb(72,86,87)" /> - <polygon points="293,284 293,283 298,290 298,293 296,291 295,290 293,285" style="fill: rgb(136,135,140)" /> - <polygon points="40,224 42,222 43,222 44,228 42,229 40,225" style="fill: rgb(91,63,60)" /> - <polygon points="5,399 6,398 7,397 8,397 9,397 10,397 11,397 13,398 13,399" style="fill: rgb(18,18,18)" /> - <polygon points="11,289 43,239 44,238 48,247 48,250 46,257 33,288 32,289 17,293 16,293 14,293 12,292" style="fill: rgb(72,86,87)" /> - <polygon points="60,354 60,353 69,352 70,353 70,357 66,362 65,362 60,361" style="fill: rgb(28,32,31)" /> - <polygon points="207,201 210,201 216,208 226,222 225,227 223,235 215,238 212,238 209,233 208,221 207,202" style="fill: rgb(201,198,205)" /> - <polygon points="101,373 111,372 113,373 112,374 103,376 101,374" style="fill: rgb(36,47,51)" /> - <polygon points="217,357 217,356 218,355 220,354 222,354 223,356 223,357 220,359 217,358" style="fill: rgb(159,108,107)" /> - <polygon points="224,171 225,171 235,171 236,171 238,172 232,175 225,172" style="fill: rgb(138,113,109)" /> - <polygon points="164,279 171,281 171,282 170,283 168,284 166,285 165,284" style="fill: rgb(160,100,100)" /> - <polygon points="167,338 169,335 172,334 178,333 182,333 185,334 186,335 180,342 175,344 167,340" style="fill: rgb(91,63,60)" /> - <polygon points="299,215 299,211 299,207 299,204 299,199 299,197 304,193 305,193 307,193 312,194 336,203 351,241 352,249 352,267 347,282 337,283 335,283 332,282 305,261 303,258 301,249 300,243 299,217" style="fill: rgb(97,113,113)" /> - <polygon points="82,284 85,268 87,263 92,268 95,272 95,274 95,277 92,285 88,288 85,290 84,290 82,285" style="fill: rgb(141,87,87)" /> - <polygon points="46,343 47,340 48,339 53,339 54,339 54,341 53,343 48,343" style="fill: rgb(31,35,36)" /> - <polygon points="134,217 166,207 168,207 167,213 164,217 151,232 149,232 137,228 134,221" style="fill: rgb(172,116,115)" /> - <polygon points="208,318 209,317 211,319 211,320 211,321 210,323 209,322 208,320" style="fill: rgb(115,74,72)" /> - <polygon points="105,112 108,111 116,110 117,110 118,110 119,110 135,111 134,112 131,113 127,113 126,113" style="fill: rgb(103,52,51)" /> - <polygon points="80,263 83,262 84,263 84,264 84,265 84,266 83,266 82,266 80,264" style="fill: rgb(160,100,100)" /> - <polygon points="155,178 155,176 166,173 166,179 162,181 161,181 160,181 159,181 157,180" style="fill: rgb(162,128,129)" /> - <polygon points="92,20 92,15 93,14 94,14 103,22 106,25 107,26 108,27 107,27 106,27 102,27 93,21" style="fill: rgb(153,174,175)" /> - <polygon points="0,368 1,367 2,367 3,368 3,369 2,370 0,372" style="fill: rgb(71,77,75)" /> - <polygon points="137,340 141,340 142,341 142,347 140,348 137,341" style="fill: rgb(115,74,72)" /> - <polygon points="119,343 120,343 121,343 123,344 123,346 123,347 120,349 119,348" style="fill: rgb(115,74,72)" /> - <polygon points="0,128 5,128 6,128 7,128 10,130 10,131 8,138 4,139 3,139 0,138" style="fill: rgb(105,95,93)" /> - <polygon points="45,140 47,135 49,135 50,136 47,141 46,142 45,143" style="fill: rgb(91,63,60)" /> - <polygon points="221,144 223,142 226,146 226,148 225,148 222,147" style="fill: rgb(169,159,160)" /> - <polygon points="135,356 137,355 143,353 145,354 146,356 146,357 146,359 146,360 144,363 141,366 140,367 137,365 135,357" style="fill: rgb(52,28,28)" /> - <polygon points="125,394 128,387 132,384 140,380 139,383 135,390 126,397" style="fill: rgb(111,107,106)" /> - <polygon points="71,145 73,142 76,142 74,146 73,147 72,148 71,146" style="fill: rgb(160,100,100)" /> - <polygon points="49,141 50,139 52,138 55,139 56,140 57,141 52,143 51,143" style="fill: rgb(91,63,60)" /> - <polygon points="67,263 71,256 76,254 82,253 84,256 85,260 88,277 87,278 86,279 68,269 67,264" style="fill: rgb(156,92,93)" /> - <polygon points="204,308 211,311 211,312 207,314 205,311 204,309" style="fill: rgb(141,101,101)" /> - <polygon points="146,340 146,339 147,340 149,342 152,345 150,345 146,342" style="fill: rgb(132,78,78)" /> - <polygon points="94,243 104,218 106,213 108,212 113,214 120,218 127,225 126,227 105,245 95,245 94,244" style="fill: rgb(196,153,163)" /> - <polygon points="243,195 244,193 245,191 250,188 251,189 251,191 250,205 247,201" style="fill: rgb(196,153,163)" /> - <polygon points="34,0 35,0 37,0 39,0 41,0 43,0 44,0 50,37 53,61 54,78 55,99 55,100 55,103 52,109 49,113 43,111 41,92 34,3" style="fill: rgb(140,154,155)" /> - <polygon points="169,100 169,97 170,96 173,93 175,92 176,93 171,99 170,100 169,101" style="fill: rgb(168,139,141)" /> - <polygon points="147,107 150,88 151,88 156,89 160,96 160,100 156,105 155,106 151,109 150,109 147,108" style="fill: rgb(138,113,109)" /> - <polygon points="167,162 169,160 174,157 199,174 198,178 193,181 192,181 181,175 169,165" style="fill: rgb(196,153,163)" /> - <polygon points="158,60 159,56 176,52 179,53 180,54 180,55 179,59 172,62 162,65 161,65 160,64" style="fill: rgb(36,47,51)" /> - <polygon points="342,56 342,52 342,48 342,44 342,43 343,44 344,49 345,58 345,59 343,61 342,58" style="fill: rgb(35,39,40)" /> - <polygon points="137,314 137,313 141,312 142,313 143,316 142,317 141,317" style="fill: rgb(160,100,100)" /> - <polygon points="8,302 12,296 15,294 15,303 11,305 10,305 9,305 8,304" style="fill: rgb(111,107,106)" /> - <polygon points="288,124 290,123 293,122 343,112 344,112 345,121 345,122 345,123 345,124 345,125 331,127 295,128 294,128" style="fill: rgb(72,86,87)" /> - <polygon points="272,180 274,176 275,175 277,173 281,174 283,188 283,190 282,192 276,188" style="fill: rgb(140,154,155)" /> - <polygon points="21,142 22,141 34,136 35,136 42,142 34,146 33,146 32,146 26,145 23,144" style="fill: rgb(74,50,46)" /> - <polygon points="7,150 7,148 10,148 11,148 17,149 17,150 16,151 15,152 12,155 8,151" style="fill: rgb(102,87,84)" /> - <polygon points="185,101 189,101 194,107 188,106 186,104 185,103" style="fill: rgb(147,129,125)" /> - <polygon points="114,285 114,284 115,283 117,282 119,282 119,283 119,284 116,285 115,285" style="fill: rgb(156,92,93)" /> - <polygon points="76,141 76,140 80,133 89,127 92,125 95,124 101,125 102,126 100,129 94,135 84,142 83,142" style="fill: rgb(165,109,110)" /> - <polygon points="75,309 75,308 80,305 83,309 85,312 88,317 87,318 84,318 80,317 78,316 77,314" style="fill: rgb(132,78,78)" /> - <polygon points="379,34 379,36 379,38 379,40 379,25 379,26 379,27 379,28 379,29 379,30 379,31 379,32 379,33 379,35 379,37 379,39 379,22 379,23 379,24" style="fill: rgb(53,70,77)" /> - <polygon points="1,223 2,215 3,211 4,210 6,209 7,209 12,209 13,209 14,209 27,211 31,212 32,213 33,214 41,233 41,236 39,246 38,249 36,254 24,284 18,288 15,288 14,288 12,287 10,286 6,265 1,224 1,221 2,215 3,211 4,210 6,209 7,209 12,209 13,209 14,209 27,211 31,212 32,213 33,214 41,233 41,236 39,246 38,249 36,254 24,284 18,288 15,288 14,288 12,287 10,286 6,265 1,224 1,221 2,215 3,211 4,210 6,209 7,209 12,209 13,209 14,209 27,211 31,212 32,213 33,214 41,233 41,236 39,246 38,249 36,254 24,284 18,288 15,288 14,288 12,287 10,286 6,265 1,224 1,221 2,215 3,211 4,210 6,209 7,209 12,209 13,209 14,209 27,211 31,212 32,213 33,214 41,233 41,236 39,246 38,249 36,254 24,284 18,288 15,288 14,288 12,287 10,286 6,265 1,224 1,221 2,215 3,211 4,210 6,209 7,209 12,209 13,209 14,209 27,211 31,212 32,213 33,214 41,233 41,236 39,246 38,249 36,254 24,284 18,288 15,288 14,288 12,287 10,286 6,265 1,224 1,221 2,215 3,211 4,210 6,209 7,209 12,209 13,209 14,209 27,211 31,212 32,213 33,214 41,233 41,236 39,246 38,249 36,254 24,284 18,288 15,288 14,288 12,287 10,286 6,265 1,224 1,221 2,215 3,211 4,210 6,209 7,209 12,209 13,209 14,209 27,211 31,212 32,213 33,214 41,233 41,236 39,246 38,249 36,254 24,284 18,288 15,288 14,288 12,287 10,286 6,265 1,224 1,221 2,215 3,211 4,210 6,209 7,209 12,209 13,209 14,209 27,211 31,212 32,213 33,214 41,233 41,236 39,246 38,249 36,254 24,284 18,288 15,288 14,288 12,287 10,286 6,265 1,224 1,221 2,215 3,211 4,210 6,209 7,209 12,209 13,209 14,209 27,211 31,212 32,213 33,214 41,233 41,236 39,246 38,249 36,254 24,284 18,288 15,288 14,288 12,287 10,286 6,265 1,224 1,221 2,215 3,211 4,210 6,209 7,209 12,209 13,209 14,209 27,211 31,212 32,213 33,214 41,233 41,236 39,246 38,249 36,254 24,284 18,288 15,288 14,288 12,287 10,286 6,265 1,224 1,221 2,215 3,211 4,210 6,209 7,209 12,209 13,209 14,209 27,211 31,212 32,213 33,214 41,233 41,236 39,246 38,249 36,254 24,284 18,288 15,288 14,288 12,287 10,286 6,265 1,224 1,221 2,215 3,211 4,210 6,209 7,209 12,209 13,209 14,209 27,211 31,212 32,213 33,214 41,233 41,236 39,246 38,249 36,254 24,284 18,288 15,288 14,288 12,287 10,286 6,265 1,224 1,221 2,215 3,211 4,210 6,209 7,209 12,209 13,209 14,209 27,211 31,212 32,213 33,214 41,233 41,236 39,246 38,249 36,254 24,284 18,288 15,288 14,288 12,287 10,286 6,265 1,224 1,221 2,215 3,211 4,210 6,209 7,209 12,209 13,209 14,209 27,211 31,212 32,213 33,214 41,233 41,236 39,246 38,249 36,254 24,284 18,288 15,288 14,288 12,287 10,286 6,265 1,224 1,221 2,215 3,211 4,210 6,209 7,209 12,209 13,209 14,209 27,211 31,212 32,213 33,214 41,233 41,236 39,246 38,249 36,254 24,284 18,288 15,288 14,288 12,287 10,286 6,265 1,224 1,221 2,215 3,211 4,210 6,209 7,209 12,209 13,209 14,209 27,211 31,212 32,213 33,214 41,233 41,236 39,246 38,249 36,254 24,284 18,288 15,288 14,288 12,287 10,286 6,265 1,224 1,221 2,215 3,211 4,210 6,209 7,209 12,209 13,209 14,209 27,211 31,212 32,213 33,214 41,233 41,236 39,246 38,249 36,254 24,284 18,288 15,288 14,288 12,287 10,286 6,265 1,224 1,221 2,215 3,211 4,210 6,209 7,209 12,209 13,209 14,209 27,211 31,212 32,213 33,214 41,233 41,236 39,246 38,249 36,254 24,284 18,288 15,288 14,288 12,287 10,286 6,265 1,224 1,221 2,215 3,211 4,210 6,209 7,209 12,209 13,209 14,209 27,211 31,212 32,213 33,214 41,233 41,236 39,246 38,249 36,254 24,284 18,288 15,288 14,288 12,287 10,286 6,265 1,224 1,221 2,215 3,211 4,210 6,209 7,209 12,209 13,209 14,209 27,211 31,212 32,213 33,214 41,233 41,236 39,246 38,249 36,254 24,284 18,288 15,288 14,288 12,287 10,286 6,265 1,224 1,221 2,215 3,211 4,210 6,209 7,209 12,209 13,209 14,209 27,211 31,212 32,213 33,214 41,233 41,236 39,246 38,249 36,254 24,284 18,288 15,288 14,288 12,287 10,286 6,265 1,224 1,221 2,215 3,211 4,210 6,209 7,209 12,209 13,209 14,209 27,211 31,212 32,213 33,214 41,233 41,236 39,246 38,249 36,254 24,284 18,288 15,288 14,288 12,287 10,286 6,265 1,224 1,221 2,215 3,211 4,210 6,209 7,209 12,209 13,209 14,209 27,211 31,212 32,213 33,214 41,233 41,236 39,246 38,249 36,254 24,284 18,288 15,288 14,288 12,287 10,286 6,265 1,224 1,221 2,215 3,211 4,210 6,209 7,209 12,209 13,209 14,209 27,211 31,212 32,213 33,214 41,233 41,236 39,246 38,249 36,254 24,284 18,288 15,288 14,288 12,287 10,286 6,265 1,224 1,221 2,215 3,211 4,210 6,209 7,209 12,209 13,209 14,209 27,211 31,212 32,213 33,214 41,233 41,236 39,246 38,249 36,254 24,284 18,288 15,288 14,288 12,287 10,286 6,265 1,224 1,221 2,215 3,211 4,210 6,209 7,209 12,209 13,209 14,209 27,211 31,212 32,213 33,214 41,233 41,236 39,246 38,249 36,254 24,284 18,288 15,288 14,288 12,287 10,286 6,265 1,224 1,221 2,215 3,211 4,210 6,209 7,209 12,209 13,209 14,209 27,211 31,212 32,213 33,214 41,233 41,236 39,246 38,249 36,254 24,284 18,288 15,288 14,288 12,287 10,286 6,265 1,224 1,221 2,215 3,211 4,210 6,209 7,209 12,209 13,209 14,209 27,211 31,212 32,213 33,214 41,233 41,236 39,246 38,249 36,254 24,284 18,288 15,288 14,288 12,287 10,286 6,265 1,224 1,221 2,215 3,211 4,210 6,209 7,209 12,209 13,209 14,209 27,211 31,212 32,213 33,214 41,233 41,236 39,246 38,249 36,254 24,284 18,288 15,288 14,288 12,287 10,286 6,265 1,224 1,221 2,215 3,211 4,210 6,209 7,209 12,209 13,209 14,209 27,211 31,212 32,213 33,214 41,233 41,236 39,246 38,249 36,254 24,284 18,288 15,288 14,288 12,287 10,286 6,265 1,224 1,221 2,215 3,211 4,210 6,209 7,209 12,209 13,209 14,209 27,211 31,212 32,213 33,214 41,233 41,236 39,246 38,249 36,254 24,284 18,288 15,288 14,288 12,287 10,286 6,265 1,224 1,221 2,215 3,211 4,210 6,209 7,209 12,209 13,209 14,209 27,211 31,212 32,213 33,214 41,233 41,236 39,246 38,249 36,254 24,284 18,288 15,288 14,288 12,287 10,286 6,265 1,224 1,221 2,215 3,211 4,210 6,209 7,209 12,209 13,209 14,209 27,211 31,212 32,213 33,214 41,233 41,236 39,246 38,249 36,254 24,284 18,288 15,288 14,288 12,287 10,286 6,265 1,224 1,221 2,215 3,211 4,210 6,209 7,209 12,209 13,209 14,209 27,211 31,212 32,213 33,214 41,233 41,236 39,246 38,249 36,254 24,284 18,288 15,288 14,288 12,287 10,286 6,265 1,224 1,221 2,215 3,211 4,210 6,209 7,209 12,209 13,209" style="fill: rgb(153,174,175)" /> - <polygon points="33,172 36,173 37,179 37,180 37,182 36,185 35,186 34,184 33,181" style="fill: rgb(64,40,36)" /> - <polygon points="117,94 118,94 119,94 120,94 121,94 123,94 125,95 126,96 125,96 124,96 123,96 122,96 121,96" style="fill: rgb(84,45,46)" /> - <polygon points="120,390 121,386 125,387 125,389 123,391 122,391 121,391" style="fill: rgb(130,119,115)" /> - <polygon points="127,292 135,291 139,298 139,299 138,300 136,302 130,297" style="fill: rgb(172,116,115)" /> - <polygon points="41,100 41,94 42,102 43,114 43,116 42,116 41,111 41,103" style="fill: rgb(122,134,132)" /> - <polygon points="96,360 97,356 99,356 105,360 108,363 109,364 112,367 111,367" style="fill: rgb(50,51,53)" /> -</svg> diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/gunit/test_005.svg b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/gunit/test_005.svg deleted file mode 100644 index 6becae3b43..0000000000 --- a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/gunit/test_005.svg +++ /dev/null @@ -1,1027 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<svg xmlns="http://www.w3.org/2000/svg" width="400" height="400" version="1.1" baseProfile="full"> - <polygon points="370,219 374,220 384,224 396,229 399,239 399,243 396,246 394,246 393,246 379,237 376,235 370,221" style="fill: rgb(247,247,247)" /> - <polygon points="53,318 53,315 53,314 69,329 70,330 71,331 71,332 71,333 70,338 69,338" style="fill: rgb(245,254,253)" /> - <polygon points="358,371 367,348 368,346 369,345 370,344 375,348 374,350 373,352 365,366 362,370 361,371" style="fill: rgb(196,174,171)" /> - <polygon points="50,270 51,270 54,270 56,271 56,272 55,272 54,272 53,272 52,272 50,271" style="fill: rgb(119,107,108)" /> - <polygon points="54,2 54,1 55,1 57,1 59,1 61,1 62,1 70,8 72,15 74,23 75,27 74,30 73,32 72,33 66,38 65,36 59,21 55,8 54,4" style="fill: rgb(110,102,99)" /> - <polygon points="211,212 224,200 225,200 227,201 228,202 230,206 230,207 221,213 220,213" style="fill: rgb(53,44,47)" /> - <polygon points="159,135 162,126 163,126 172,129 174,130 174,131 171,136 169,137 168,137 164,137 161,136" style="fill: rgb(64,55,56)" /> - <polygon points="2,195 3,191 6,193 7,194 9,197 8,197 2,197" style="fill: rgb(96,86,84)" /> - <polygon points="213,280 215,279 264,278 268,281 268,282 267,288 252,350 247,354 246,354" style="fill: rgb(75,63,63)" /> - <polygon points="334,399 335,397 342,386 345,382 346,381 357,373 359,373 360,373 361,373 349,392 345,398 344,399 337,399 336,399" style="fill: rgb(214,193,190)" /> - <polygon points="350,351 355,346 355,347 353,352 351,354 350,352" style="fill: rgb(217,200,201)" /> - <polygon points="34,204 35,204 41,207 41,208 40,208 38,207" style="fill: rgb(154,134,136)" /> - <polygon points="80,243 80,229 80,228 81,225 83,235 83,236 83,238 83,251 83,256 83,257 83,258 82,258 80,251" style="fill: rgb(163,139,139)" /> - <polygon points="63,222 63,221 63,220 64,216 65,214 67,212 71,209 72,230 72,232 71,233 65,228" style="fill: rgb(75,63,63)" /> - <polygon points="59,366 66,358 67,357 68,358 69,359 60,367" style="fill: rgb(169,179,170)" /> - <polygon points="236,267 237,266 238,266 239,266 241,267 241,269 238,269 236,268" style="fill: rgb(45,44,50)" /> - <polygon points="80,154 81,146 82,147 83,151 82,155 80,155" style="fill: rgb(154,134,136)" /> - <polygon points="91,328 91,327 93,329 100,336 100,337 100,338 99,339 94,334 93,333" style="fill: rgb(122,110,114)" /> - <polygon points="126,151 136,98 137,95 145,93 153,92 154,92 155,92 156,92 157,92 165,94 185,100 186,101 190,125 190,130 188,141 186,145 181,149 176,152 154,159 149,160 148,160 147,160 146,160 130,154" style="fill: rgb(75,63,63)" /> - <polygon points="73,348 73,347 75,340 76,338 76,340 76,342 75,346 74,348 73,349" style="fill: rgb(253,250,250)" /> - <polygon points="74,186 75,180 76,180 75,185 74,188" style="fill: rgb(96,86,84)" /> - <polygon points="230,52 237,51 237,52 236,58 235,60 232,63 231,62" style="fill: rgb(252,251,252)" /> - <polygon points="231,50 232,48 234,44 235,44 236,45 237,47 233,50" style="fill: rgb(252,251,252)" /> - <polygon points="195,347 199,346 199,347 199,348 195,348" style="fill: rgb(35,34,40)" /> - <polygon points="154,62 155,61 158,63 158,64 158,65 154,63" style="fill: rgb(86,72,72)" /> - <polygon points="366,377 366,376 368,368 377,349 393,359 396,361 398,365 398,376 398,377 398,378 387,383 377,383 376,383 370,383 369,382" style="fill: rgb(163,139,139)" /> - <polygon points="254,147 254,145 258,146 262,151 264,155 259,156 258,156 254,150" style="fill: rgb(75,63,63)" /> - <polygon points="317,198 322,197 323,200 323,203 319,200 318,199" style="fill: rgb(240,239,240)" /> - <polygon points="107,177 108,176 109,175 112,175 113,175 114,175 115,175 118,175 119,175 119,176 114,180 107,184" style="fill: rgb(86,72,72)" /> - <polygon points="170,253 172,251 173,250 177,247 204,249 238,259 242,262 247,267 248,270 248,271 248,273 246,274 186,261" style="fill: rgb(59,49,50)" /> - <polygon points="152,100 152,99 153,99 154,99 155,99 156,99 157,99 164,99 165,100 167,110 167,111 166,111 162,109 155,105 152,101" style="fill: rgb(64,55,56)" /> - <polygon points="251,142 251,141 252,137 255,137 256,137 263,139 266,140 267,141 267,142 260,145 258,145 255,144" style="fill: rgb(96,86,84)" /> - <polygon points="90,143 94,136 96,136 97,137 92,146 91,146 90,146" style="fill: rgb(122,110,114)" /> - <polygon points="103,312 104,312 105,312 106,312 106,313 105,315 103,313" style="fill: rgb(96,86,84)" /> - <polygon points="292,219 293,217 296,222 295,223 294,224 293,224 292,221" style="fill: rgb(144,128,130)" /> - <polygon points="239,19 239,18 243,21 247,24 248,25 246,24 240,20" style="fill: rgb(205,205,210)" /> - <polygon points="61,58 62,58 63,58 74,64 75,65 63,59" style="fill: rgb(163,139,139)" /> - <polygon points="380,384 383,383 384,383 385,383 387,388 388,391 390,398 389,398" style="fill: rgb(167,158,154)" /> - <polygon points="213,44 215,43 216,44 215,48 214,48 213,46" style="fill: rgb(167,158,154)" /> - <polygon points="25,207 27,206 30,205 31,205 30,206 26,208" style="fill: rgb(196,174,171)" /> - <polygon points="209,68 209,67 209,66 209,62 210,63 212,65 211,69" style="fill: rgb(138,130,128)" /> - <polygon points="357,362 359,352 369,332 371,329 376,322 379,318 380,317 380,323 374,337 365,351 363,354 358,361" style="fill: rgb(196,174,171)" /> - <polygon points="97,263 97,249 97,246 98,247 99,248 100,249 102,252 104,265 102,267" style="fill: rgb(119,107,108)" /> - <polygon points="51,53 53,46 54,46 55,47 56,50 56,51 52,53" style="fill: rgb(214,193,190)" /> - <polygon points="248,184 248,183 251,185 253,187 252,187 251,187 250,186 249,185" style="fill: rgb(248,247,245)" /> - <polygon points="144,375 146,374 147,374 149,375 150,376 148,376 145,376 144,376" style="fill: rgb(64,55,56)" /> - <polygon points="146,299 147,298 148,297 150,296 152,296 152,298 148,300 146,300" style="fill: rgb(86,72,72)" /> - <polygon points="192,169 193,165 194,162 196,161 196,162 195,169" style="fill: rgb(163,139,139)" /> - <polygon points="277,284 279,276 281,274 284,273 285,273 286,273 285,281 284,287 283,290 282,291 281,291 280,291" style="fill: rgb(119,107,108)" /> - <polygon points="11,350 12,346 13,345 14,345 11,356" style="fill: rgb(252,251,252)" /> - <polygon points="273,191 274,191 276,192 277,194 277,195 276,196 275,195 274,194" style="fill: rgb(240,239,240)" /> - <polygon points="150,246 151,245 156,241 170,232 179,229 186,229 189,230 234,251 248,265 251,273 251,279 250,283 249,283 157,255 153,251 150,247" style="fill: rgb(64,55,56)" /> - <polygon points="165,146 172,145 175,146 168,148" style="fill: rgb(53,44,47)" /> - <polygon points="66,389 66,363 68,361 70,360 70,361 70,362 67,391 66,392" style="fill: rgb(248,247,245)" /> - <polygon points="362,379 362,378 364,374 365,372 370,363 371,364 375,383 371,384 368,384 366,383 363,381" style="fill: rgb(154,134,136)" /> - <polygon points="333,210 334,204 335,204 336,205 335,208 334,211" style="fill: rgb(226,226,230)" /> - <polygon points="196,331 196,330 198,328 200,329 200,331 200,332 196,333" style="fill: rgb(38,38,44)" /> - <polygon points="237,152 239,149 243,152 243,153 242,154 240,154" style="fill: rgb(96,86,84)" /> - <polygon points="25,223 25,221 26,219 36,211 38,212 40,213 41,214 41,216 41,217 40,220 36,229 35,231 31,236 29,236 28,234" style="fill: rgb(86,72,72)" /> - <polygon points="202,27 202,26 203,26 208,27 212,28 216,30 216,31 216,32 206,30 203,29" style="fill: rgb(169,179,170)" /> - <polygon points="63,165 65,166 67,167 69,168 74,171 75,172 76,173 76,174 76,175 76,176 76,177 73,177 66,174 65,172 64,169" style="fill: rgb(196,174,171)" /> - <polygon points="123,344 123,343 124,342 125,345 125,346 125,347 124,350 123,351" style="fill: rgb(59,49,50)" /> - <polygon points="223,396 223,395 224,393 228,388 247,372 248,372 248,379 248,380 246,386 244,388 240,391 225,397 224,397" style="fill: rgb(196,174,171)" /> - <polygon points="189,172 192,171 193,172 194,175 190,173" style="fill: rgb(144,128,130)" /> - <polygon points="258,250 263,249 264,250 265,252 265,253 264,253 258,252" style="fill: rgb(133,121,114)" /> - <polygon points="143,145 152,145 153,146 149,146" style="fill: rgb(45,44,50)" /> - <polygon points="179,241 179,240 180,240 181,240 182,240 183,242 179,242" style="fill: rgb(86,72,72)" /> - <polygon points="13,278 14,278 16,279 21,284 22,285 21,285 17,282 13,279" style="fill: rgb(202,194,191)" /> - <polygon points="336,397 339,392 362,357 366,351 367,350 367,351 366,355 351,378 337,397 336,398" style="fill: rgb(196,174,171)" /> - <polygon points="222,359 222,358 225,356 226,358 225,361" style="fill: rgb(38,38,44)" /> - <polygon points="270,397 272,393 274,390 275,389 282,396 282,397 282,398 271,399" style="fill: rgb(122,110,114)" /> - <polygon points="218,248 221,244 222,245 223,249 223,250 220,249" style="fill: rgb(110,102,99)" /> - <polygon points="332,273 338,271 352,267 354,268 365,274 376,280 374,284 370,291 368,294 366,293 364,292 362,291 353,286 346,282 332,274" style="fill: rgb(214,193,190)" /> - <polygon points="142,143 152,136 156,136 158,138 158,139 156,144 154,145 153,145 149,145 142,144" style="fill: rgb(45,44,50)" /> - <polygon points="259,220 260,220 261,220 263,220 265,221 263,222 261,223 260,223 259,221" style="fill: rgb(122,110,114)" /> - <polygon points="267,201 268,201 271,204 272,205 272,206 270,206 268,205 267,202" style="fill: rgb(207,194,195)" /> - <polygon points="302,102 302,101 308,98 308,99 305,103 303,104" style="fill: rgb(110,102,99)" /> - <polygon points="326,206 326,205 327,204 328,204 330,205 334,208 335,209 328,207" style="fill: rgb(219,220,224)" /> - <polygon points="350,399 359,383 360,382 362,382 375,385 376,386 376,399 362,399 356,399 351,398 352,396 353,394 359,383 360,382 362,382 375,385 376,386 376,399 362,399 356,399 351,398 352,396 353,394 359,383 360,382 362,382 375,385 376,386 376,399 362,399 356,399 351,398 352,396 353,394 359,383 360,382 362,382 375,385 376,386 376,399 362,399 356,399 351,398 352,396 353,394 359,383 360,382 362,382 375,385 376,386 376,399 362,399 356,399 351,398 352,396 353,394 359,383 360,382 362,382 375,385 376,386 376,399 362,399 356,399 351,398 352,396 353,394 359,383 360,382 362,382 375,385 376,386 376,399 362,399 356,399 351,398 352,396 353,394 359,383 360,382 362,382 375,385 376,386 376,399 362,399 356,399 351,398 352,396 353,394 359,383 360,382 362,382 375,385 376,386 376,399 362,399 356,399 351,398 352,396 353,394 359,383 360,382 362,382 375,385 376,386 376,399 362,399 356,399 351,398 352,396 353,394 359,383 360,382 362,382 375,385 376,386 376,399 362,399 356,399 351,398 352,396 353,394 359,383 360,382 362,382 375,385 376,386 376,399 362,399 356,399 351,398 352,396 353,394 359,383 360,382 362,382 375,385 376,386 376,399 362,399 356,399 351,398 352,396 353,394 359,383 360,382 362,382 375,385 376,386 376,399 362,399 356,399 351,398 352,396 353,394 359,383 360,382 362,382 375,385 376,386 376,399 362,399 356,399 351,398 352,396 353,394 359,383 360,382 362,382 375,385 376,386 376,399 362,399 356,399 351,398 352,396 353,394 359,383 360,382 362,382 375,385 376,386 376,399 362,399 356,399 351,398 352,396 353,394 359,383 360,382 362,382 375,385 376,386 376,399 362,399 356,399 351,398 352,396 353,394 359,383 360,382 362,382 375,385 376,386 376,399 362,399 356,399 351,398 352,396 353,394 359,383 360,382 362,382 375,385 376,386 376,399 362,399 356,399 351,398 352,396 353,394 359,383 360,382 362,382 375,385 376,386 376,399 362,399 356,399 351,398 352,396 353,394 359,383 360,382 362,382 375,385 376,386 376,399 362,399 356,399 351,398 352,396 353,394 359,383 360,382 362,382 375,385 376,386 376,399 362,399 356,399 351,398 352,396 353,394 359,383 360,382 362,382 375,385 376,386 376,399 362,399 356,399 351,398 352,396 353,394 359,383 360,382 362,382 375,385 376,386 376,399 362,399 356,399 351,398 352,396 353,394 359,383 360,382 362,382 375,385 376,386 376,399 362,399 356,399 351,398 352,396 353,394 359,383 360,382 362,382 375,385 376,386 376,399 362,399 356,399 351,398 352,396 353,394 359,383 360,382 362,382" style="fill: rgb(196,174,171)" /> - <polygon points="73,344 73,343 74,336 75,334 76,335 76,336 76,337 74,343 73,346 73,345" style="fill: rgb(252,253,253)" /> - <polygon points="72,207 72,204 74,200 74,201 74,202 74,203 74,207 74,208 73,208 72,208" style="fill: rgb(119,107,108)" /> - <polygon points="60,202 60,206 60,210 60,205 60,209 60,213 60,204 60,208 60,212 60,203 60,207 60,211" style="fill: rgb(96,86,84)" /> - <polygon points="166,51 167,51 168,51 170,51 171,51 172,51 173,51 175,51 176,51 177,51 178,51 187,56 195,79 194,80 191,81 186,80 171,67 170,66" style="fill: rgb(96,86,84)" /> - <polygon points="35,389 35,385 35,384 36,383 37,382 37,383 37,384 36,388" style="fill: rgb(253,250,250)" /> - <polygon points="63,269 65,265 66,265 68,269 64,269 64,268 65,265 66,265 68,269 64,269 64,268 65,265 66,265 68,269" style="fill: rgb(110,102,99)" /> - <polygon points="335,70 339,66 338,67 344,61 342,63 348,57 346,59 337,68 340,65 336,69 343,62 341,64 347,58 345,60" style="fill: rgb(122,110,114)" /> - <polygon points="13,373 13,372 14,372 17,374 17,375 17,376 16,376" style="fill: rgb(252,251,252)" /> - <polygon points="295,151 298,147 299,150 299,151 299,152 299,153 299,155" style="fill: rgb(154,145,148)" /> - <polygon points="99,38 100,36 104,32 109,30 120,35 128,39 131,41 132,42 131,43 130,44 115,56 113,56 100,49" style="fill: rgb(214,193,190)" /> - <polygon points="247,148 248,148 252,150 253,152 253,154 252,154 251,153 248,150 247,149" style="fill: rgb(75,63,63)" /> - <polygon points="88,274 88,273 88,272 88,271 90,272 91,277 91,279 91,281 89,280" style="fill: rgb(144,128,130)" /> - <polygon points="92,245 93,243 94,242 94,245 94,248 93,248 92,246" style="fill: rgb(122,110,114)" /> - <polygon points="338,399 339,397 343,391 346,387 347,389 347,390 343,399 341,399 340,399 339,399" style="fill: rgb(214,193,190)" /> - <polygon points="86,198 88,194 90,192 92,192 94,194 95,195 95,199 95,202 87,202" style="fill: rgb(119,107,108)" /> - <polygon points="112,28 112,27 113,26 131,17 133,16 134,16 135,16 137,16 140,17 159,26 159,27 159,30 136,40 135,40" style="fill: rgb(214,193,190)" /> - <polygon points="298,236 300,230 301,229 301,232 300,238 299,240 298,238" style="fill: rgb(171,148,150)" /> - <polygon points="284,133 284,131 285,131 287,134 288,136 288,137 287,139" style="fill: rgb(122,110,114)" /> - <polygon points="90,218 91,217 92,217 93,217 94,217 95,217 95,225 94,224 90,219" style="fill: rgb(122,110,114)" /> - <polygon points="74,215 74,213 75,210 76,215 76,216 75,216 74,216" style="fill: rgb(163,139,139)" /> - <polygon points="193,20 194,20 195,20 196,20 197,20 198,20 202,21 199,22 198,22 197,22 195,21" style="fill: rgb(224,208,205)" /> - <polygon points="305,124 305,123 307,119 308,120 307,122 306,124 305,126" style="fill: rgb(225,233,236)" /> - <polygon points="82,348 84,347 85,348 85,349 84,350 83,350" style="fill: rgb(119,107,108)" /> - <polygon points="162,178 163,177 165,176 171,177 169,178 168,178" style="fill: rgb(133,121,114)" /> - <polygon points="83,122 84,122 85,122 86,122 89,124 89,125 86,126" style="fill: rgb(154,145,148)" /> - <polygon points="205,54 205,52 207,49 210,51 208,56 207,56 206,55" style="fill: rgb(122,110,114)" /> - <polygon points="284,121 286,121 287,121 288,121 288,122 287,125 286,125" style="fill: rgb(154,145,148)" /> - <polygon points="95,259 95,258 95,257 99,260 103,268 103,269 102,269 101,269 100,269 98,269 96,265" style="fill: rgb(122,110,114)" /> - <polygon points="233,289 234,289 235,289 237,289 238,289 239,290 240,292 239,295 236,294 233,291" style="fill: rgb(110,102,99)" /> - <polygon points="258,392 259,392 261,393 270,398 268,398 262,398 261,398 260,398" style="fill: rgb(96,86,84)" /> - <polygon points="0,271 3,273 5,275 6,276 6,277 0,275" style="fill: rgb(252,251,252)" /> - <polygon points="40,360 41,355 42,361 42,362 41,362 40,361" style="fill: rgb(248,247,245)" /> - <polygon points="139,139 141,138 142,138 143,138 145,138 148,140 146,141 145,141 143,141 142,141 141,141 139,141" style="fill: rgb(64,55,56)" /> - <polygon points="231,354 231,353 235,350 232,359 231,357" style="fill: rgb(64,55,56)" /> - <polygon points="180,7 181,6 183,7 185,8 187,9 187,10 186,10" style="fill: rgb(167,158,154)" /> - <polygon points="295,112 296,111 297,111 298,111 299,111 299,112 297,114" style="fill: rgb(202,194,191)" /> - <polygon points="71,390 75,382 76,385 76,386 75,391 74,392 71,391" style="fill: rgb(119,107,108)" /> - <polygon points="283,118 283,116 285,114 287,120 284,120" style="fill: rgb(172,166,165)" /> - <polygon points="100,17 104,17 105,18 104,20 102,19" style="fill: rgb(144,128,130)" /> - <polygon points="274,306 276,306 277,306 278,306 276,310 274,308" style="fill: rgb(133,121,114)" /> - <polygon points="94,292 94,291 97,293 99,295 102,299 97,305 95,304 94,303" style="fill: rgb(122,110,114)" /> - <polygon points="328,57 334,61 335,62 337,64 336,65 331,60 329,58" style="fill: rgb(205,205,210)" /> - <polygon points="139,198 146,187 159,175 163,175 231,198 236,201 238,204 239,206 239,207 234,218 162,231 161,231 160,231 159,231 158,231 154,227 140,200" style="fill: rgb(45,44,50)" /> - <polygon points="140,258 141,257 143,257 144,258 144,260 143,261 141,261 140,259" style="fill: rgb(35,34,40)" /> - <polygon points="131,341 132,339 133,338 136,336 136,337 136,338 136,339 136,340 136,341 133,342 132,342" style="fill: rgb(38,38,44)" /> - <polygon points="298,122 300,122 301,125 301,126 300,127" style="fill: rgb(207,194,195)" /> - <polygon points="333,397 333,396 334,391 336,387 349,368 354,361 357,357 357,358 355,364 354,366 352,370 337,392 334,396" style="fill: rgb(224,208,205)" /> - <polygon points="284,95 285,94 288,93 292,93 291,96 285,96 284,96" style="fill: rgb(226,223,225)" /> - <polygon points="160,310 161,309 163,308 174,307 175,310 175,312 173,313 170,314 163,315 162,315" style="fill: rgb(75,63,63)" /> - <polygon points="58,0 59,0 60,0 61,0 62,0 63,0 64,0 65,0 66,0 67,0 68,0" style="fill: rgb(138,130,128)" /> - <polygon points="241,347 241,346 242,343 248,346 244,352" style="fill: rgb(96,86,84)" /> - <polygon points="196,236 197,235 198,235 199,235 199,236 199,237 197,238" style="fill: rgb(96,86,84)" /> - <polygon points="60,24 75,25 77,35 65,41 64,41 61,30" style="fill: rgb(110,102,99)" /> - <polygon points="264,326 265,323 268,317 272,313 272,314 272,315 272,316 268,328 267,330 264,327" style="fill: rgb(110,102,99)" /> - <polygon points="176,367 177,367 178,372 177,373 176,373" style="fill: rgb(45,44,50)" /> - <polygon points="229,322 230,322 232,325 232,326 231,327 229,326" style="fill: rgb(64,55,56)" /> - <polygon points="279,89 280,87 281,87 281,88 280,90 279,92" style="fill: rgb(252,251,252)" /> - <polygon points="381,230 382,228 383,227 384,227 387,234 385,233 382,231" style="fill: rgb(225,233,236)" /> - <polygon points="19,56 23,58 32,63 33,65 34,68 36,74 44,101 45,107 45,108 45,109 19,57" style="fill: rgb(154,134,136)" /> - <polygon points="206,178 210,180 216,184 217,185 217,186 213,185 206,179" style="fill: rgb(172,166,165)" /> - <polygon points="267,28 267,26 270,24 280,27 282,28 283,29 290,36 291,42 290,45 285,42 269,30 268,29" style="fill: rgb(225,233,236)" /> - <polygon points="78,150 80,149 84,150 84,151 83,152 81,152 80,152" style="fill: rgb(154,134,136)" /> - <polygon points="281,269 283,268 286,267 287,268 287,269 286,271 281,272" style="fill: rgb(119,107,108)" /> - <polygon points="278,267 281,263 282,264 282,265 281,268 280,269 279,269 278,269" style="fill: rgb(110,102,99)" /> - <polygon points="93,130 96,81 97,80 98,79 99,79 103,90 103,116 102,120 100,125 95,130" style="fill: rgb(122,110,114)" /> - <polygon points="258,20 259,20 262,22 263,23 261,25 260,24 259,23" style="fill: rgb(225,233,236)" /> - <polygon points="297,277 300,276 301,276 301,278 299,279 298,279 297,279" style="fill: rgb(214,193,190)" /> - <polygon points="378,29 385,21 394,12 395,11 396,10 397,9 398,8 387,20 382,25 381,26 380,27 379,28" style="fill: rgb(149,142,141)" /> - <polygon points="100,107 100,96 104,94 105,96 105,103 105,106 105,112 104,112" style="fill: rgb(110,102,99)" /> - <polygon points="145,246 147,244 152,239 158,235 166,231 167,231 165,234 150,244 146,246" style="fill: rgb(96,86,84)" /> - <polygon points="285,265 285,264 287,262 288,263 288,264 287,265 285,267" style="fill: rgb(138,130,128)" /> - <polygon points="36,365 36,364 36,359 37,358 37,361" style="fill: rgb(245,254,253)" /> - <polygon points="45,373 49,374 46,377 45,377" style="fill: rgb(252,251,252)" /> - <polygon points="186,169 186,168 187,163 195,158 195,159 189,170 188,171" style="fill: rgb(133,121,114)" /> - <polygon points="79,273 79,272 79,271 82,269 85,272 86,275 84,275 80,274" style="fill: rgb(149,142,141)" /> - <polygon points="63,236 63,235 65,229 70,229 72,233 72,237 72,238 66,245" style="fill: rgb(96,86,84)" /> - <polygon points="203,25 207,24 208,24 213,25 220,30 222,32 222,33 219,35 217,34 204,26" style="fill: rgb(202,194,191)" /> - <polygon points="298,164 302,159 302,161 302,162 302,163 302,164 300,166 299,166" style="fill: rgb(196,174,171)" /> - <polygon points="273,15 274,15 281,19 293,30 295,32 296,33 289,28 280,21 274,16" style="fill: rgb(169,179,170)" /> - <polygon points="218,333 221,327 222,325 223,326 222,332 219,333" style="fill: rgb(122,110,114)" /> - <polygon points="355,367 359,358 360,356 361,354 362,352 365,352 364,354 356,366" style="fill: rgb(196,174,171)" /> - <polygon points="173,397 173,395 173,394 174,394 186,398 184,398 180,398 178,398 175,398 174,398" style="fill: rgb(59,49,50)" /> - <polygon points="41,361 43,347 44,346 44,347 42,360" style="fill: rgb(248,247,245)" /> - <polygon points="79,315 79,314 79,313 79,312 80,311 81,313 79,317 79,316" style="fill: rgb(149,142,141)" /> - <polygon points="287,244 289,240 290,241 291,242 290,246" style="fill: rgb(144,128,130)" /> - <polygon points="133,5 133,1 135,1 139,1 143,2 135,6 134,6" style="fill: rgb(167,158,154)" /> - <polygon points="109,362 150,371 158,379 156,383 146,382 122,371 117,368 114,366 111,364 110,363" style="fill: rgb(64,55,56)" /> - <polygon points="276,388 287,395 290,397 291,398 290,398 285,396 278,391 277,390" style="fill: rgb(133,121,114)" /> - <polygon points="258,141 259,141 260,141 263,142 258,143" style="fill: rgb(110,102,99)" /> - <polygon points="228,12 230,12 231,13 229,15 228,15" style="fill: rgb(247,247,247)" /> - <polygon points="302,149 302,145 302,142 303,146 303,166 302,150" style="fill: rgb(205,205,210)" /> - <polygon points="290,151 291,150 292,151 292,160 291,160 290,155" style="fill: rgb(110,102,99)" /> - <polygon points="303,95 303,94 304,86 308,79 317,83 317,84 307,93 303,96" style="fill: rgb(205,205,210)" /> - <polygon points="9,179 11,180 16,183 17,184 16,184 13,182 10,180" style="fill: rgb(96,86,84)" /> - <polygon points="154,207 157,197 158,194 159,193 160,193 186,211 187,212 187,213 177,214 160,210 156,209" style="fill: rgb(53,44,47)" /> - <polygon points="74,240 74,239 76,238 76,240 76,243 76,244 74,246 74,239 76,238 76,240 76,243 76,244 74,246 74,239 76,238 76,240" style="fill: rgb(196,174,171)" /> - <polygon points="296,199 296,198 297,196 298,194 300,197 301,199 302,201 303,203 304,207 303,210 301,208 296,201" style="fill: rgb(196,174,171)" /> - <polygon points="13,24 13,23 16,15 17,16 16,19 14,24" style="fill: rgb(96,86,84)" /> - <polygon points="269,298 272,297 273,297 273,298 273,299 273,300 270,299" style="fill: rgb(96,86,84)" /> - <polygon points="88,167 91,166 91,169 90,172 89,172" style="fill: rgb(119,107,108)" /> - <polygon points="310,230 313,231 315,232 317,233 319,234 318,235 311,231" style="fill: rgb(217,200,201)" /> - <polygon points="210,277 211,276 214,276 215,276 218,278 213,279 212,279" style="fill: rgb(96,86,84)" /> - <polygon points="271,185 271,181 272,181 273,181 273,182 273,183 273,184 273,185 272,185" style="fill: rgb(240,239,240)" /> - <polygon points="268,347 270,348 275,351 277,353 274,352 269,349 268,348" style="fill: rgb(167,158,154)" /> - <polygon points="286,213 289,212 291,212 293,216 292,216 291,216 287,216" style="fill: rgb(144,128,130)" /> - <polygon points="342,202 343,201 345,202 347,203 347,206 346,206 343,205" style="fill: rgb(252,251,252)" /> - <polygon points="81,228 83,220 84,223 84,224 84,225 84,226 82,228" style="fill: rgb(154,145,148)" /> - <polygon points="74,228 74,225 74,224 75,229 75,230 75,231 74,231" style="fill: rgb(172,166,165)" /> - <polygon points="392,308 392,303 399,296 399,297 399,298 399,299 399,300 393,308 392,309" style="fill: rgb(226,223,225)" /> - <polygon points="145,254 146,254 157,257 156,258 152,260 151,260 148,258" style="fill: rgb(59,49,50)" /> - <polygon points="348,253 350,254 350,255 349,257 348,256" style="fill: rgb(172,166,165)" /> - <polygon points="307,200 309,199 310,199 319,203 320,204 319,205 318,206" style="fill: rgb(226,223,225)" /> - <polygon points="146,129 148,128 152,128 153,128 155,129 154,130 149,130" style="fill: rgb(86,72,72)" /> - <polygon points="181,39 181,38 185,33 186,33 191,36 194,39 194,40 191,42 190,42 189,42 186,42 185,42" style="fill: rgb(122,110,114)" /> - <polygon points="163,317 164,316 174,316 174,317 173,323 166,324 165,324 163,322 163,318" style="fill: rgb(53,44,47)" /> - <polygon points="301,233 302,227 303,232 301,237" style="fill: rgb(172,166,165)" /> - <polygon points="303,399 304,399 305,399 306,399 307,399 308,399 309,399 310,399 311,399 312,399" style="fill: rgb(214,193,190)" /> - <polygon points="377,384 380,383 381,383 382,383 386,384 386,385 385,387 378,385" style="fill: rgb(214,193,190)" /> - <polygon points="86,235 88,234 89,234 90,236 88,243 87,245" style="fill: rgb(133,121,114)" /> - <polygon points="245,27 246,26 247,27 248,29 248,30 246,32 245,30" style="fill: rgb(245,254,253)" /> - <polygon points="0,259 50,213 58,209 59,210 63,215 68,260 55,292 47,299 46,299 44,298 11,275 10,274 1,264 0,260" style="fill: rgb(110,102,99)" /> - <polygon points="387,306 387,303 389,297 399,275 399,276 399,291 397,297 396,299 395,301 388,307" style="fill: rgb(231,214,217)" /> - <polygon points="68,223 69,222 71,222 72,223 72,224 70,227 69,227 68,226" style="fill: rgb(64,55,56)" /> - <polygon points="286,126 288,125 290,125 290,126 288,128 287,129" style="fill: rgb(149,142,141)" /> - <polygon points="80,333 80,332 81,323 82,325 85,334 80,335" style="fill: rgb(154,134,136)" /> - <polygon points="267,11 273,16 276,19 272,16 271,15 270,14 269,13 268,12" style="fill: rgb(205,205,210)" /> - <polygon points="15,277 15,275 15,274 16,274 22,275 22,276 22,277" style="fill: rgb(119,107,108)" /> - <polygon points="58,387 58,395 58,388 58,385 58,393 58,386 58,394 58,391 58,392 58,389 58,390" style="fill: rgb(247,247,247)" /> - <polygon points="231,28 234,23 240,30 240,31 239,31 238,31" style="fill: rgb(240,239,240)" /> - <polygon points="229,31 229,30 231,31 233,32 235,36 235,37 234,38 230,33" style="fill: rgb(252,251,252)" /> - <polygon points="11,9 12,6 14,1 14,3 12,8 11,10" style="fill: rgb(96,86,84)" /> - <polygon points="74,256 74,252 74,251 75,248 76,249 77,250 78,253 77,261 76,260 74,257" style="fill: rgb(196,174,171)" /> - <polygon points="189,171 189,168 190,165 191,163 192,162 192,165 192,166 192,167 191,172" style="fill: rgb(133,121,114)" /> - <polygon points="77,170 78,169 80,168 82,169 83,170 83,171 81,181 80,181 79,180 77,171" style="fill: rgb(154,134,136)" /> - <polygon points="52,303 52,302 54,297 55,296 56,296 57,297 55,301 54,302" style="fill: rgb(110,102,99)" /> - <polygon points="4,270 8,269 9,270 9,271 8,273 5,271" style="fill: rgb(133,121,114)" /> - <polygon points="160,257 161,256 173,253 182,255 184,258 184,259" style="fill: rgb(53,44,47)" /> - <polygon points="126,344 126,343 128,344 129,345 130,347 130,348 129,349" style="fill: rgb(38,38,44)" /> - <polygon points="239,72 239,71 243,74 244,77 245,80 243,80" style="fill: rgb(252,251,252)" /> - <polygon points="73,116 81,119 80,121 76,119 73,117" style="fill: rgb(171,148,150)" /> - <polygon points="57,374 58,373 58,382 58,383 57,375" style="fill: rgb(252,253,253)" /> - <polygon points="301,38 302,36 333,60 335,64 328,59 308,44 304,41 303,40 302,39" style="fill: rgb(202,194,191)" /> - <polygon points="357,52 357,51 369,38 371,36 376,31 376,32 362,47" style="fill: rgb(122,110,114)" /> - <polygon points="30,199 32,199 38,203 38,204" style="fill: rgb(167,158,154)" /> - <polygon points="179,0 180,0 181,0 182,0 183,0 184,0 185,0 186,0 187,0 188,0 189,0 190,0 191,0 192,0 193,0 194,0 195,0 196,0 197,0 198,0 199,0 200,0 201,0 202,0 203,0 204,0 205,0 206,0 207,0 208,0 209,0 210,0 211,0 212,0 213,0" style="fill: rgb(235,221,221)" /> - <polygon points="308,87 308,85 309,80 312,74 313,72 314,70 317,72 317,73 317,74 317,75 315,79 312,84 309,87 308,88" style="fill: rgb(169,179,170)" /> - <polygon points="312,115 315,108 320,98 321,96 322,96 322,97 313,115" style="fill: rgb(205,205,210)" /> - <polygon points="199,34 201,33 204,33 203,36 200,36" style="fill: rgb(138,130,128)" /> - <polygon points="74,220 76,218 77,218 78,223 76,224 75,223" style="fill: rgb(167,158,154)" /> - <polygon points="171,300 171,299 172,297 193,289 196,288 201,288 214,288 215,295 206,323 204,324 178,321 174,319 171,303" style="fill: rgb(45,44,50)" /> - <polygon points="79,282 80,275 85,261 86,261 87,261 88,266 88,278 87,281 82,287 80,288" style="fill: rgb(154,134,136)" /> - <polygon points="378,396 380,392 381,395 381,397 380,398 379,398" style="fill: rgb(110,102,99)" /> - <polygon points="61,227 61,226 61,225 62,224 65,230 64,230" style="fill: rgb(122,110,114)" /> - <polygon points="85,11 90,1 91,1 93,1 103,11 105,19 105,20 105,21 104,22 100,24 96,26 93,27 92,27 91,25 86,14" style="fill: rgb(138,130,128)" /> - <polygon points="81,318 89,259 91,259 97,268 99,334 99,335 99,336 95,335 81,319" style="fill: rgb(133,121,114)" /> - <polygon points="21,339 21,334 22,332 23,331 24,331 30,334 32,335 33,336 34,337 34,338 34,339 34,340 34,341 34,342 33,343 32,344 30,344 28,344 23,341 22,340" style="fill: rgb(245,254,253)" /> - <polygon points="1,186 1,182 1,181 2,181 2,182 2,183 2,184 2,185" style="fill: rgb(96,86,84)" /> - <polygon points="216,127 219,122 222,120 224,119 243,110 246,110 250,110 251,110 252,110 253,110 254,110 255,115 257,163 251,164 250,164 249,164 248,164 245,164 238,162 236,161 226,153 223,148 217,138" style="fill: rgb(75,63,63)" /> - <polygon points="162,283 168,274 169,273 172,271 173,271 210,279 221,284 251,299 254,303 254,305 253,310 252,314 249,320 247,324 236,330 223,323" style="fill: rgb(64,55,56)" /> - <polygon points="199,92 199,90 204,88 207,89 206,90 201,94" style="fill: rgb(96,86,84)" /> - <polygon points="0,186 0,178 0,187 0,179 0,188 0,180 0,181 0,182 0,183 0,175 0,184 0,176 0,185 0,177" style="fill: rgb(133,121,114)" /> - <polygon points="354,339 355,338 358,336 359,336 360,339 357,340" style="fill: rgb(224,208,205)" /> - <polygon points="1,174 1,171 1,166 1,162 1,161 56,208 58,210 54,218 52,221 47,222 12,194 11,193 1,176 1,171 1,166 1,162 1,161 56,208 58,210 54,218 52,221 47,222 12,194 11,193 1,176 1,171 1,166 1,162 1,161 56,208 58,210 54,218 52,221 47,222 12,194 11,193 1,176 1,171 1,166 1,162 1,161 56,208 58,210 54,218 52,221 47,222 12,194 11,193 1,176 1,171 1,166 1,162 1,161 56,208 58,210 54,218 52,221 47,222 12,194 11,193 1,176 1,171 1,166 1,162 1,161 56,208 58,210 54,218 52,221 47,222 12,194 11,193 1,176 1,171 1,166 1,162 1,161 56,208 58,210 54,218 52,221 47,222 12,194 11,193 1,176 1,171 1,166 1,162 1,161 56,208 58,210 54,218 52,221 47,222 12,194 11,193 1,176 1,171 1,166 1,162 1,161 56,208 58,210 54,218 52,221 47,222 12,194 11,193 1,176 1,171 1,166 1,162 1,161 56,208 58,210 54,218 52,221 47,222 12,194 11,193 1,176 1,171 1,166 1,162 1,161 56,208 58,210 54,218 52,221 47,222 12,194 11,193 1,176 1,171 1,166 1,162 1,161 56,208 58,210 54,218 52,221 47,222 12,194 11,193 1,176 1,171 1,166 1,162 1,161 56,208 58,210 54,218 52,221 47,222 12,194 11,193 1,176 1,171 1,166 1,162 1,161 56,208 58,210 54,218 52,221 47,222 12,194 11,193 1,176 1,171 1,166 1,162 1,161 56,208 58,210 54,218 52,221 47,222 12,194 11,193 1,176 1,171 1,166 1,162 1,161 56,208 58,210 54,218 52,221 47,222 12,194 11,193 1,176 1,171 1,166 1,162 1,161 56,208 58,210 54,218 52,221 47,222 12,194 11,193 1,176 1,171 1,166 1,162 1,161 56,208 58,210 54,218 52,221 47,222 12,194 11,193 1,176 1,171 1,166 1,162 1,161 56,208 58,210 54,218 52,221 47,222 12,194 11,193 1,176 1,171 1,166 1,162 1,161 56,208 58,210 54,218 52,221 47,222 12,194 11,193 1,176 1,171 1,166 1,162 1,161 56,208 58,210 54,218 52,221 47,222 12,194 11,193 1,176 1,171 1,166 1,162 1,161 56,208 58,210 54,218 52,221 47,222 12,194 11,193 1,176 1,171 1,166 1,162 1,161 56,208 58,210 54,218 52,221 47,222 12,194 11,193 1,176 1,171 1,166 1,162 1,161 56,208 58,210 54,218 52,221 47,222 12,194 11,193 1,176 1,171 1,166 1,162 1,161 56,208 58,210 54,218 52,221 47,222 12,194 11,193 1,176 1,171 1,166 1,162 1,161 56,208 58,210 54,218 52,221 47,222 12,194 11,193 1,176 1,171 1,166 1,162 1,161 56,208 58,210 54,218 52,221 47,222 12,194 11,193 1,176 1,171 1,166 1,162 1,161 56,208" style="fill: rgb(96,86,84)" /> - <polygon points="137,254 140,251 150,249 151,249 160,256 159,258 158,258 157,258 149,257" style="fill: rgb(59,49,50)" /> - <polygon points="250,371 251,368 252,365 254,366 255,367 271,389 272,391 271,393 269,396 268,396 266,395 254,387 251,385 250,384" style="fill: rgb(144,128,130)" /> - <polygon points="239,368 249,362 251,362 251,363 250,365 242,371" style="fill: rgb(167,158,154)" /> - <polygon points="373,249 373,248 375,249 379,251 381,252 381,253 380,253 378,253 374,250" style="fill: rgb(224,208,205)" /> - <polygon points="310,253 312,256 317,264 319,268 319,270 318,271 317,271 315,270 314,269 313,266 311,259 310,255" style="fill: rgb(149,142,141)" /> - <polygon points="241,188 241,187 256,199 262,212 263,221 261,226 258,228 255,228 252,226 251,225 243,214" style="fill: rgb(96,86,84)" /> - <polygon points="118,258 122,243 149,231 154,232 156,234 140,269 136,275 124,284 123,284 121,283 118,267" style="fill: rgb(64,55,56)" /> - <polygon points="273,160 274,157 276,158 278,159 279,160 279,161 277,162 275,163 273,161" style="fill: rgb(110,102,99)" /> - <polygon points="26,313 29,304 29,305 29,308 28,310 27,312" style="fill: rgb(240,253,253)" /> - <polygon points="291,199 291,197 292,197 293,197 294,197 295,199 295,200 293,200" style="fill: rgb(167,158,154)" /> - <polygon points="261,33 262,31 266,30 269,32 276,37 291,48 283,59" style="fill: rgb(217,200,201)" /> - <polygon points="1,265 3,266 4,267 4,268 2,268 1,267" style="fill: rgb(119,107,108)" /> - <polygon points="152,191 153,188 154,186 156,184 157,184 157,185 156,188 152,193" style="fill: rgb(110,102,99)" /> - <polygon points="337,211 338,211 344,215 345,216 343,215 341,214" style="fill: rgb(247,247,247)" /> - <polygon points="243,222 247,225 245,227 244,227 243,226" style="fill: rgb(252,253,253)" /> - <polygon points="243,355 243,354 246,352 246,355 246,357 245,358 244,358 243,358" style="fill: rgb(138,130,128)" /> - <polygon points="218,264 218,263 220,263 221,263 225,265 226,266 225,266" style="fill: rgb(96,86,84)" /> - <polygon points="344,251 347,253 348,257 348,259 346,257 344,253" style="fill: rgb(167,158,154)" /> - <polygon points="118,1 119,1 123,1 127,1 131,2 132,3 132,5 131,6 128,8 120,12" style="fill: rgb(149,142,141)" /> - <polygon points="55,18 56,16 57,18 58,21 59,25 59,27 58,28 57,25" style="fill: rgb(133,121,114)" /> - <polygon points="196,302 196,298 196,297 197,297 198,300 197,302" style="fill: rgb(53,44,47)" /> - <polygon points="61,272 62,271 64,270 68,271 67,272 62,273" style="fill: rgb(122,110,114)" /> - <polygon points="46,103 48,104 70,116 79,121 80,122 77,143 76,143 72,141 70,140 56,132 53,130 51,124 49,117 46,106" style="fill: rgb(196,174,171)" /> - <polygon points="60,194 60,193 60,192 61,190 63,199 64,206 63,208 60,195" style="fill: rgb(59,49,50)" /> - <polygon points="304,322 304,321 304,320 307,319 315,323 324,328 338,336 343,339 343,341 338,350 337,351 333,349 331,348 323,343 320,341 317,339 308,333 306,329" style="fill: rgb(214,193,190)" /> - <polygon points="238,185 240,184 241,184 242,184 243,184 244,187 244,189 242,190" style="fill: rgb(119,107,108)" /> - <polygon points="344,216 348,211 351,210 349,218 348,219 344,218" style="fill: rgb(240,239,240)" /> - <polygon points="276,258 277,257 278,256 281,255 283,256 281,260" style="fill: rgb(110,102,99)" /> - <polygon points="96,66 96,64 96,63 104,57 108,57 110,58 111,59 106,65 105,66 102,67" style="fill: rgb(214,193,190)" /> - <polygon points="144,124 145,124 146,124 147,124 148,124 149,124 150,124 151,124 152,124 153,124 154,124 155,124 156,124 158,124 160,125 161,126" style="fill: rgb(64,55,56)" /> - <polygon points="278,251 279,251 281,252 281,256 280,256 279,256 278,253" style="fill: rgb(119,107,108)" /> - <polygon points="198,28 198,27 199,26 200,26 201,26 202,28 202,29 199,29" style="fill: rgb(172,166,165)" /> - <polygon points="202,313 205,310 208,310 213,311 216,313 221,319 221,320 220,321 215,320" style="fill: rgb(64,55,56)" /> - <polygon points="283,200 285,198 286,198 288,201 288,202" style="fill: rgb(202,194,191)" /> - <polygon points="187,33 191,32 192,32 197,33 193,39 192,40 191,41 187,38" style="fill: rgb(133,121,114)" /> - <polygon points="280,145 281,145 285,149 286,150 288,154 288,155 288,156 287,155" style="fill: rgb(144,128,130)" /> - <polygon points="294,106 296,106 299,107 301,108 300,109 296,110 295,110 294,107" style="fill: rgb(210,206,208)" /> - <polygon points="168,323 169,322 171,321 173,320 176,319 177,319 177,320 177,321 176,322 173,324" style="fill: rgb(59,49,50)" /> - <polygon points="0,219 0,220 0,212 0,221 0,213 0,222 0,214 0,223 0,215 0,224 0,216 0,225 0,217 0,226 0,218 0,227" style="fill: rgb(133,121,114)" /> - <polygon points="42,252 42,249 42,248 43,241 44,236 45,236 47,253 47,254" style="fill: rgb(110,102,99)" /> - <polygon points="237,336 241,331 242,330 243,331 244,333 244,334 241,336 239,337 238,337" style="fill: rgb(110,102,99)" /> - <polygon points="258,177 259,177 271,182 272,183 271,187 267,185 260,179" style="fill: rgb(240,239,240)" /> - <polygon points="27,211 28,210 30,209 32,209 31,210 30,211 28,212 27,212" style="fill: rgb(86,72,72)" /> - <polygon points="86,158 88,157 89,158 90,159 90,160 88,163" style="fill: rgb(133,121,114)" /> - <polygon points="302,268 305,270 304,275 303,275 302,269" style="fill: rgb(214,193,190)" /> - <polygon points="204,325 207,324 208,324 208,326 207,327 206,328 205,329" style="fill: rgb(64,55,56)" /> - <polygon points="375,390 375,389 376,389 377,389 379,391 380,395 380,396 378,398 377,397" style="fill: rgb(110,102,99)" /> - <polygon points="208,357 208,356 209,356 210,356 209,360 208,359" style="fill: rgb(35,34,40)" /> - <polygon points="236,23 237,22 238,22 239,23 240,24 240,25 237,27 236,26" style="fill: rgb(240,253,253)" /> - <polygon points="143,268 153,264 156,263 164,263 166,267 167,270 167,271 166,273 164,275 163,276 159,280 150,283 145,282 143,276" style="fill: rgb(96,86,84)" /> - <polygon points="247,136 247,135 248,135 249,135 250,135 251,135 252,135 253,135 254,135 260,136 263,137 260,137" style="fill: rgb(75,63,63)" /> - <polygon points="48,378 52,373 60,364 65,359 63,365 58,370 57,371 52,376 51,377 48,379" style="fill: rgb(169,179,170)" /> - <polygon points="81,182 81,179 82,178 84,182 83,183 81,184 81,179 82,178 84,182 83,183 81,184 81,179 82,178" style="fill: rgb(144,128,130)" /> - <polygon points="197,165 198,163 201,166 203,176 203,177 202,177 201,177 198,174 197,166" style="fill: rgb(214,193,190)" /> - <polygon points="306,228 308,226 320,232 331,238 338,242 338,243" style="fill: rgb(196,174,171)" /> - <polygon points="129,265 129,264 130,261 132,256 137,251 139,250 152,246 154,246 155,246 156,254 151,262 134,272 132,273 130,273 129,271" style="fill: rgb(38,38,44)" /> - <polygon points="371,31 377,25 378,24 376,27 375,28 374,29 373,30 372,31 371,32" style="fill: rgb(110,102,99)" /> - <polygon points="29,296 30,295 31,294 36,298 42,303 48,312 46,311 31,299 30,298" style="fill: rgb(225,233,236)" /> - <polygon points="287,225 288,221 289,220 295,218 298,219 298,223 298,225 298,226 298,227 296,229 295,230 294,230" style="fill: rgb(144,128,130)" /> - <polygon points="157,256 160,252 163,250 163,251 161,255 159,256" style="fill: rgb(64,55,56)" /> - <polygon points="291,98 292,98 294,99 292,105 291,106" style="fill: rgb(226,223,225)" /> - <polygon points="44,1 45,2 47,9 47,10 47,11 46,8 45,5" style="fill: rgb(167,158,154)" /> - <polygon points="386,350 387,350 388,350 390,350 391,350 392,350 393,350 395,351 397,352 398,353 398,356 398,357 398,358 397,359 394,357 389,353 387,351" style="fill: rgb(217,200,201)" /> - <polygon points="351,218 351,217 352,216 353,215 354,215 357,218 359,220 359,221 358,222 353,221" style="fill: rgb(225,233,236)" /> - <polygon points="89,248 89,243 90,241 92,239 93,239 93,241 93,242 90,248" style="fill: rgb(110,102,99)" /> - <polygon points="77,364 79,361 80,361 81,362 81,366 80,366" style="fill: rgb(122,110,114)" /> - <polygon points="394,255 396,250 399,250 399,254 399,255 396,256" style="fill: rgb(247,247,247)" /> - <polygon points="282,281 282,280 283,280 284,283 284,284 284,285 284,286 282,282" style="fill: rgb(119,107,108)" /> - <polygon points="7,48 7,47 10,39 18,18 23,5 25,0 26,0 27,0 28,0 29,0 30,0 31,0 33,0 35,0 37,0 40,0 43,0 45,7 47,14 49,21 51,28 53,35 57,49 57,50 57,51 45,57 34,62 33,62 29,60 27,59 25,58" style="fill: rgb(196,174,171)" /> - <polygon points="97,322 99,277 103,272 108,272 113,279 115,284 117,291 122,315 122,317 106,345 105,345 103,344 102,343 101,342 99,333 98,328" style="fill: rgb(96,86,84)" /> - <polygon points="72,195 72,193 73,194 74,196 74,197 73,199 72,198" style="fill: rgb(96,86,84)" /> - <polygon points="135,260 136,257 138,255 139,255 140,255 141,255 142,255 142,262 140,263 136,263 135,262" style="fill: rgb(38,38,44)" /> - <polygon points="55,249 56,248 57,248 59,249 60,250 59,251 56,250" style="fill: rgb(122,110,114)" /> - <polygon points="109,384 109,383 110,373 112,365 142,380 148,383 151,385 137,394 130,398 129,398 128,398 124,398 121,398 119,398 118,398 117,398 116,398 112,397" style="fill: rgb(59,49,50)" /> - <polygon points="199,164 199,163 202,162 203,162 205,165 205,168 205,169 205,170 205,171 204,172 199,166" style="fill: rgb(214,193,190)" /> - <polygon points="86,345 86,344 87,328 89,330 91,332 110,356 111,358 104,393 100,398 97,398 92,398 91,398 90,398 89,398 88,398 86,388" style="fill: rgb(86,72,72)" /> - <polygon points="54,315 54,314 55,313 56,313 70,324 71,325 70,327 69,327 62,322 58,319 57,318" style="fill: rgb(225,233,236)" /> - <polygon points="200,239 200,233 201,232 205,231 206,231 211,232 215,233 217,234 219,235 222,237 223,238 224,239 223,239" style="fill: rgb(96,86,84)" /> - <polygon points="320,262 321,257 322,255 327,255 328,255 329,255 338,258 342,261 343,263 326,268 325,268 324,268 321,265" style="fill: rgb(149,142,141)" /> - <polygon points="91,333 123,363 123,365 120,385 118,395 115,398 111,398 110,398 109,398 108,398 107,398 106,398 105,398 104,398 103,398 102,398 101,398 99,397" style="fill: rgb(75,63,63)" /> - <polygon points="45,280 55,263 60,262 64,264 72,269 72,274 68,287 67,288 56,292 52,290 51,289 50,288 46,283" style="fill: rgb(110,102,99)" /> - <polygon points="220,43 221,43 223,45 224,46 224,47 222,49 221,49 220,44" style="fill: rgb(210,206,208)" /> - <polygon points="76,190 79,187 80,190 79,191" style="fill: rgb(154,134,136)" /> - <polygon points="142,123 143,123 152,123 153,123 154,123 155,123 144,123 145,123 146,123 147,123 148,123 149,123 150,123 151,123" style="fill: rgb(75,63,63)" /> - <polygon points="306,340 308,339 314,341 327,348 334,352 336,354 335,356 330,365 328,364 326,363 318,358 315,356 312,354 310,352" style="fill: rgb(214,193,190)" /> - <polygon points="81,320 82,320 84,321 82,324 81,322" style="fill: rgb(122,110,114)" /> - <polygon points="376,237 377,236 378,235 391,244 392,245 389,245 386,244 380,240 377,238" style="fill: rgb(225,233,236)" /> - <polygon points="309,361 313,359 314,359 321,363 326,366 327,367 328,368 325,374 323,378 322,378 318,376 316,375 315,374 313,371 311,367 309,362" style="fill: rgb(214,193,190)" /> - <polygon points="231,362 231,360 232,360 233,360 234,360 234,361 232,364 231,364" style="fill: rgb(59,49,50)" /> - <polygon points="166,139 167,138 171,140 175,145 171,145 170,145 169,145 168,145" style="fill: rgb(45,44,50)" /> - <polygon points="14,316 19,308 20,311 20,312 20,313 19,316 18,318 16,319 15,318 14,317" style="fill: rgb(253,250,250)" /> - <polygon points="94,399 95,399 116,399 117,399 118,399 119,399 112,399 113,399 114,399 115,399 120,399 121,399 100,399 101,399 102,399 103,399 96,399 97,399 98,399 99,399 108,399 109,399 110,399 111,399 104,399 105,399 106,399 107,399" style="fill: rgb(96,86,84)" /> - <polygon points="275,208 276,205 277,207 278,209 278,211 276,210" style="fill: rgb(196,174,171)" /> - <polygon points="88,150 89,149 91,147 91,149 91,156 90,157 89,157 88,156" style="fill: rgb(119,107,108)" /> - <polygon points="40,204 43,206 46,208 46,212 46,214 44,213 41,211 40,205" style="fill: rgb(154,134,136)" /> - <polygon points="138,13 138,12 146,8 148,7 150,6 152,5 154,4 156,3 161,1 162,1 139,14" style="fill: rgb(214,193,190)" /> - <polygon points="206,327 206,326 209,323 214,324 215,325 216,328 215,329 208,328" style="fill: rgb(45,44,50)" /> - <polygon points="95,323 95,322 95,321 95,320 96,318 97,317 103,317 104,319 100,324 97,324 96,324" style="fill: rgb(119,107,108)" /> - <polygon points="141,136 142,135 144,134 145,134 146,134 147,134 148,134 149,134 153,135" style="fill: rgb(53,44,47)" /> - <polygon points="279,186 279,185 286,187 279,187 279,185 286,187 279,187 279,185 286,187 279,187 279,185" style="fill: rgb(253,250,250)" /> - <polygon points="83,241 84,239 85,240 86,248 86,249 86,251 86,253 85,254 83,242" style="fill: rgb(154,145,148)" /> - <polygon points="48,299 49,297 52,297 52,299 52,300 50,302 49,301" style="fill: rgb(133,121,114)" /> - <polygon points="264,125 265,123 267,123 267,128 266,128 265,127" style="fill: rgb(110,102,99)" /> - <polygon points="288,234 289,230 290,229 297,228 298,228 295,234 291,236 288,235" style="fill: rgb(154,134,136)" /> - <polygon points="328,399 333,392 334,397 333,399 329,399" style="fill: rgb(217,200,201)" /> - <polygon points="1,260 4,259 41,254 42,256 42,260 38,261 33,262 19,262 4,261" style="fill: rgb(96,86,84)" /> - <polygon points="347,212 354,209 361,214 362,215 361,218 355,218 350,217 349,216 348,215" style="fill: rgb(247,247,247)" /> - <polygon points="320,86 323,80 324,79 325,79 326,79 326,81 322,85 321,86" style="fill: rgb(110,102,99)" /> - <polygon points="284,274 284,272 287,267 288,268 288,270 287,276 285,279 284,275" style="fill: rgb(133,121,114)" /> - <polygon points="1,236 1,232 1,229 1,223 1,219 1,215 1,212 1,207 1,203 2,202 9,202 9,203 9,204 8,219 5,235 3,237 1,237" style="fill: rgb(96,86,84)" /> - <polygon points="130,285 131,283 133,282 134,283 136,291 136,292 136,293 134,293 133,293 130,287" style="fill: rgb(96,86,84)" /> - <polygon points="172,47 172,45 173,44 175,42 176,42 191,44 195,46 198,48 197,53 192,55 186,53 172,48" style="fill: rgb(110,102,99)" /> - <polygon points="107,28 108,27 119,33 118,33" style="fill: rgb(171,148,150)" /> - <polygon points="94,241 95,241 96,241 98,243 98,244 98,245 95,247 94,244" style="fill: rgb(133,121,114)" /> - <polygon points="131,48 134,46 138,44 137,46 133,50 132,50" style="fill: rgb(119,107,108)" /> - <polygon points="257,137 258,137 259,137 265,137 267,138 269,139 271,140 280,149 281,150 282,151 285,155 285,156 278,157" style="fill: rgb(96,86,84)" /> - <polygon points="71,359 72,357 73,356 74,356 74,357 74,358 71,361" style="fill: rgb(253,250,250)" /> - <polygon points="189,77 190,75 196,76 196,77 195,78" style="fill: rgb(133,121,114)" /> - <polygon points="238,16 240,17 248,22 252,25 256,28 259,31 260,32 250,25 243,20 239,17" style="fill: rgb(240,239,240)" /> - <polygon points="55,293 56,289 62,280 66,275 69,275 70,275 71,275 72,275 74,287 75,302 74,303 55,302" style="fill: rgb(119,107,108)" /> - <polygon points="240,246 243,243 257,234 260,238 255,248 246,249 245,249 242,248" style="fill: rgb(196,174,171)" /> - <polygon points="334,214 337,208 342,208 342,209 342,211 335,215" style="fill: rgb(226,226,230)" /> - <polygon points="26,324 30,325 39,328 39,329 37,329 32,328 29,327" style="fill: rgb(234,254,253)" /> - <polygon points="169,395 178,386 201,379 210,379 207,388 193,398 187,398 179,398 173,398 172,398 171,398 169,396" style="fill: rgb(53,44,47)" /> - <polygon points="312,206 353,222 357,225 375,239 376,240 378,243 377,243 376,243 366,240 360,237 331,222 320,216 319,215" style="fill: rgb(252,253,253)" /> - <polygon points="123,338 131,326 138,323 149,320 161,319 194,319 201,324 227,354 231,359 231,365 225,372 220,376 214,378 207,380 163,380 156,377 129,365 128,364 124,351" style="fill: rgb(35,34,40)" /> - <polygon points="83,1 87,1 89,1 89,4 89,7 89,8 89,9 88,10 87,11 86,11 85,10 84,6 83,2" style="fill: rgb(133,121,114)" /> - <polygon points="393,362 397,361 398,363 398,364 397,365 396,365 393,364" style="fill: rgb(171,148,150)" /> - <polygon points="64,241 69,239 65,246" style="fill: rgb(110,102,99)" /> - <polygon points="227,357 228,356 232,354 233,355 234,358 228,358" style="fill: rgb(86,72,72)" /> - <polygon points="8,398 9,396 10,394 11,394 11,399 10,399 8,399" style="fill: rgb(248,247,245)" /> - <polygon points="256,268 257,263 259,258 269,250 273,250 274,250 275,250 275,261 259,271 258,271 257,271 256,270" style="fill: rgb(133,121,114)" /> - <polygon points="167,37 172,35 176,35 179,37 179,39 169,39 168,39" style="fill: rgb(133,121,114)" /> - <polygon points="176,147 180,137 181,135 182,135 183,138 183,139 183,142 177,147" style="fill: rgb(64,55,56)" /> - <polygon points="225,0 226,0 231,0 239,0 242,0 243,0 244,0 245,0 259,14 258,18 257,22 235,10 225,1" style="fill: rgb(225,233,236)" /> - <polygon points="286,149 287,143 288,142 289,142 289,149 289,152" style="fill: rgb(119,107,108)" /> - <polygon points="303,105 309,98 310,98 311,98 312,99 309,103 305,107 304,108" style="fill: rgb(96,86,84)" /> - <polygon points="291,85 293,84 294,86 295,89 294,90 292,89" style="fill: rgb(248,247,245)" /> - <polygon points="64,222 65,220 68,215 70,213 71,213 72,215 72,216 72,217 72,218 72,219 72,220 72,221 72,222 68,227 67,227 65,224" style="fill: rgb(75,63,63)" /> - <polygon points="284,244 285,243 288,248 287,250 286,251 284,252" style="fill: rgb(144,128,130)" /> - <polygon points="253,0 258,4 261,7 257,4 253,1" style="fill: rgb(205,205,210)" /> - <polygon points="355,381 358,377 359,376 360,375 359,377 356,382" style="fill: rgb(172,166,165)" /> - <polygon points="236,361 237,359 240,354 241,353 242,353 241,361 240,362" style="fill: rgb(110,102,99)" /> - <polygon points="394,277 394,275 397,270 398,269 398,270 398,271 397,273 396,275" style="fill: rgb(202,194,191)" /> - <polygon points="251,393 252,392 257,395 257,396 256,398" style="fill: rgb(172,166,165)" /> - <polygon points="130,362 133,362 137,365 135,365 133,364 131,363" style="fill: rgb(64,55,56)" /> - <polygon points="55,193 56,192 57,192 57,194 57,196 55,195" style="fill: rgb(144,128,130)" /> - <polygon points="311,266 311,265 323,224 324,224 327,225 330,226 344,233 348,235 371,247 359,267 313,276 312,276 311,272" style="fill: rgb(167,158,154)" /> - <polygon points="159,180 160,179 161,178 162,177 171,179 162,181" style="fill: rgb(119,107,108)" /> - <polygon points="85,292 86,287 88,282 89,282 90,297 89,301 88,302 87,302 85,300" style="fill: rgb(138,130,128)" /> - <polygon points="376,340 376,339 376,338 376,335 379,328 385,330 385,331 384,333 383,335 380,338" style="fill: rgb(224,208,205)" /> - <polygon points="191,68 192,63 193,64 195,67 192,68" style="fill: rgb(119,107,108)" /> - <polygon points="70,248 70,245 71,243 72,243 72,248 72,249 72,250 70,251" style="fill: rgb(64,55,56)" /> - <polygon points="308,89 310,86 314,81 315,80 315,83 313,85 309,89 308,90" style="fill: rgb(169,179,170)" /> - <polygon points="169,148 172,140 176,137 179,136 180,141 177,145 176,146 175,147" style="fill: rgb(59,49,50)" /> - <polygon points="385,290 385,288 386,286 388,283 393,276 394,278 391,285 390,286 389,287" style="fill: rgb(205,205,210)" /> - <polygon points="296,210 298,206 300,209 300,210 300,211 300,212 297,211" style="fill: rgb(163,139,139)" /> - <polygon points="389,313 390,311 391,310 393,309 394,312 394,313 393,315 391,318 389,318" style="fill: rgb(235,221,221)" /> - <polygon points="218,282 220,279 226,281 228,282 225,284 224,284 223,284 219,283" style="fill: rgb(96,86,84)" /> - <polygon points="297,89 297,87 302,84 302,85 298,89" style="fill: rgb(224,208,205)" /> - <polygon points="332,216 332,215 336,216 338,218 337,218 336,218 334,217" style="fill: rgb(252,251,252)" /> - <polygon points="59,387 59,386 59,385 59,384 59,372 61,371 61,376 60,385 59,390" style="fill: rgb(248,247,245)" /> - <polygon points="131,136 132,136 133,136 136,140 136,141 135,141 133,140 132,139" style="fill: rgb(64,55,56)" /> - <polygon points="306,312 308,303 311,303 315,305 317,306 332,314 348,323 351,325 351,326 348,332 345,337 341,335 334,331 329,328 309,316 308,315 307,314" style="fill: rgb(214,193,190)" /> - <polygon points="64,210 65,207 66,204 68,199 69,197 70,198 70,203 70,204 70,205 69,206 64,211" style="fill: rgb(144,128,130)" /> - <polygon points="38,394 38,393 40,391 41,390 48,399 47,399 43,398 40,396" style="fill: rgb(252,253,253)" /> - <polygon points="301,225 301,224 302,219 303,218 304,219 305,222 302,226" style="fill: rgb(172,166,165)" /> - <polygon points="228,29 228,28 248,27 251,29 254,31 284,68 290,79 291,82 290,84 278,98 275,100 268,99 265,98 253,94 246,88 243,85 232,62 230,53 228,31" style="fill: rgb(252,251,252)" /> - <polygon points="66,248 66,246 68,242 70,240 71,239 72,239 70,252 67,252 66,251" style="fill: rgb(86,72,72)" /> - <polygon points="360,367 360,366 363,361 365,359 366,359 366,360 363,364 360,368" style="fill: rgb(214,193,190)" /> - <polygon points="78,292 80,292 81,296 81,297 81,300 79,298" style="fill: rgb(149,142,141)" /> - <polygon points="112,144 113,142 114,141 115,143 115,144 114,144 113,144" style="fill: rgb(75,63,63)" /> - <polygon points="118,351 118,350 119,335 122,337 124,345 125,353" style="fill: rgb(59,49,50)" /> - <polygon points="118,356 118,354 119,352 122,352 124,353 127,357 127,358 126,359 125,359 123,359 121,358 119,357" style="fill: rgb(75,63,63)" /> - <polygon points="297,162 298,160 302,158 301,161 300,163 297,164" style="fill: rgb(196,174,171)" /> - <polygon points="177,253 183,253 191,253 196,253 202,254 206,255 216,258 222,261 224,262 224,263 196,261 187,260 185,259 177,254" style="fill: rgb(64,55,56)" /> - <polygon points="275,102 276,101 280,100 281,100 282,102 276,102" style="fill: rgb(226,226,230)" /> - <polygon points="35,67 35,65 36,64 50,57 52,56 55,56 57,57 59,58 61,59 63,60 77,67 96,77 96,78 87,96 86,96 80,93 76,91 65,85 45,74 38,70" style="fill: rgb(196,174,171)" /> - <polygon points="290,249 292,245 295,247 295,248 294,257 292,270 290,270" style="fill: rgb(154,145,148)" /> - <polygon points="288,150 290,146 291,145 292,146 293,151 289,151" style="fill: rgb(110,102,99)" /> - <polygon points="239,246 239,245 240,242 243,241 244,241 245,241 241,247 240,247" style="fill: rgb(214,193,190)" /> - <polygon points="94,288 95,271 99,268 103,270 105,271 106,273 106,274 105,288 104,291 100,296 96,293" style="fill: rgb(110,102,99)" /> - <polygon points="275,395 275,388 289,398 287,398 286,398 285,398 284,398 283,398 277,397" style="fill: rgb(119,107,108)" /> - <polygon points="143,265 149,263 150,263 148,265 146,266 145,266 143,266" style="fill: rgb(64,55,56)" /> - <polygon points="96,240 96,239 97,236 99,239 99,242 97,242" style="fill: rgb(122,110,114)" /> - <polygon points="280,91 281,89 283,89 285,92 284,92" style="fill: rgb(253,250,250)" /> - <polygon points="384,18 386,15 387,14 388,13 395,6 387,15 386,16" style="fill: rgb(154,145,148)" /> - <polygon points="289,89 290,88 292,87 293,88 298,94 298,95 298,96 298,97 294,96" style="fill: rgb(225,233,236)" /> - <polygon points="266,171 270,167 271,167 269,170 268,171 267,172" style="fill: rgb(248,247,245)" /> - <polygon points="129,39 129,37 133,39 135,41 132,43" style="fill: rgb(171,148,150)" /> - <polygon points="118,6 119,6 120,6 121,10 119,11" style="fill: rgb(154,145,148)" /> - <polygon points="65,398 78,348 80,349 81,350 79,371 77,377 73,389 69,398" style="fill: rgb(133,121,114)" /> - <polygon points="178,261 181,260 183,260 185,261 184,262 182,262 181,262" style="fill: rgb(75,63,63)" /> - <polygon points="205,366 210,362 211,362 211,370 208,370 205,367" style="fill: rgb(35,34,40)" /> - <polygon points="9,244 9,242 10,237 11,234 11,236 10,241 9,245" style="fill: rgb(196,174,171)" /> - <polygon points="369,225 369,224 369,217 371,218 372,219" style="fill: rgb(247,247,247)" /> - <polygon points="0,310 26,289 43,338 43,339 43,340 40,363 39,369 38,375 37,381 35,388 33,388 25,387 14,380 0,371" style="fill: rgb(252,253,253)" /> - <polygon points="238,330 239,329 240,328 242,327 243,327 245,327 245,329" style="fill: rgb(96,86,84)" /> - <polygon points="324,399 324,398 343,369 354,353 363,340 366,336 368,334 369,333 370,332 371,331 371,332 369,339 364,347 327,399 326,399 325,399" style="fill: rgb(196,174,171)" /> - <polygon points="287,220 288,214 289,213 290,216 290,217 290,218 290,220 290,222" style="fill: rgb(133,121,114)" /> - <polygon points="52,294 52,293 53,293 60,293 60,294 57,295 55,295 54,295 53,295" style="fill: rgb(133,121,114)" /> - <polygon points="151,195 151,193 151,192 154,185 158,180 159,179 178,177 186,177 199,181 228,192 235,195 238,197 241,199 243,203 243,207 152,197" style="fill: rgb(75,63,63)" /> - <polygon points="85,198 85,197 86,195 87,194 91,194 89,197 86,199" style="fill: rgb(119,107,108)" /> - <polygon points="168,243 169,240 173,243 172,248 171,251 169,252" style="fill: rgb(86,72,72)" /> - <polygon points="42,212 42,210 44,206 45,207 45,210 43,214" style="fill: rgb(154,134,136)" /> - <polygon points="215,228 220,229 225,233 228,236 232,240 232,242 215,229" style="fill: rgb(253,250,250)" /> - <polygon points="327,84 330,77 331,76 334,76 334,77 330,81 329,82 328,83" style="fill: rgb(122,110,114)" /> - <polygon points="152,322 152,321 152,320 157,317 160,317 161,317 160,321 154,322 153,322" style="fill: rgb(64,55,56)" /> - <polygon points="231,284 232,284 237,284 238,285 239,286 237,287 236,287 235,287" style="fill: rgb(119,107,108)" /> - <polygon points="309,46 309,45 332,62 335,65 335,66 311,48 310,47" style="fill: rgb(219,220,224)" /> - <polygon points="314,68 318,69 321,71 322,72 322,73 321,73 319,72 316,70 315,69" style="fill: rgb(225,233,236)" /> - <polygon points="46,111 48,117 53,132 56,146 56,147 55,145 49,124 47,117 46,113" style="fill: rgb(154,134,136)" /> - <polygon points="213,21 214,20 215,20 218,22 221,24 220,24" style="fill: rgb(225,233,236)" /> - <polygon points="156,135 170,131 175,131 176,132 178,135 179,138 177,140 176,141 173,142 167,142 157,137" style="fill: rgb(59,49,50)" /> - <polygon points="236,188 236,187 237,187 239,189 240,190 242,193 242,194 240,193" style="fill: rgb(253,250,250)" /> - <polygon points="350,344 351,341 354,335 358,333 360,332 362,331 364,330 364,334 364,337 363,338 357,342 354,344 353,344 352,344" style="fill: rgb(217,200,201)" /> - <polygon points="266,326 268,323 270,320 271,322 270,324 269,326 268,327 267,327" style="fill: rgb(110,102,99)" /> - <polygon points="181,293 184,289 189,293 189,294 187,297 186,297 183,297 182,297" style="fill: rgb(38,38,44)" /> - <polygon points="235,23 235,22 236,22 246,33 246,34 245,34 244,34 243,34 239,32 236,28 235,26" style="fill: rgb(247,247,247)" /> - <polygon points="231,345 234,343 235,343 237,344 232,347 231,346" style="fill: rgb(96,86,84)" /> - <polygon points="157,365 157,364 157,363 157,362 158,362 165,362 165,363 162,366 161,366" style="fill: rgb(38,38,44)" /> - <polygon points="172,0 174,0 185,6 186,7 183,6 175,2 173,1" style="fill: rgb(231,214,217)" /> - <polygon points="223,270 226,271 233,277 232,278 230,277 224,273 223,271" style="fill: rgb(167,158,154)" /> - <polygon points="127,131 131,129 134,128 145,126 151,125 152,125 159,126 162,128 161,131 155,132 133,135 132,135 131,135" style="fill: rgb(86,72,72)" /> - <polygon points="221,76 222,75 223,75 224,75 225,76 226,77 224,77 223,77" style="fill: rgb(138,130,128)" /> - <polygon points="43,275 48,274 49,275 50,276 49,277 48,277 43,277" style="fill: rgb(119,107,108)" /> - <polygon points="386,339 386,338 387,335 392,326 397,319 398,320 399,322 399,347 398,347 393,345 391,344 388,342" style="fill: rgb(252,253,253)" /> - <polygon points="314,282 314,281 315,279 317,278 323,276 327,275 328,275 330,276 336,279 338,280 358,291 367,296 362,306 360,308 359,308 357,307 355,306 327,290 317,284" style="fill: rgb(214,193,190)" /> - <polygon points="389,266 391,262 392,260 396,258 397,258 390,266 389,267" style="fill: rgb(219,220,224)" /> - <polygon points="174,28 176,27 177,27 179,28 177,29 174,29" style="fill: rgb(172,166,165)" /> - <polygon points="223,398 232,393 235,393 236,395 232,397 228,398" style="fill: rgb(196,174,171)" /> - <polygon points="18,278 19,278 22,278 23,278 24,279 20,279 18,279" style="fill: rgb(133,121,114)" /> - <polygon points="376,238 388,244 390,245 391,246 390,246 388,246 387,246 383,244 377,239" style="fill: rgb(234,254,253)" /> - <polygon points="236,353 238,343 241,341 242,349 242,350 238,353" style="fill: rgb(86,72,72)" /> - <polygon points="84,233 84,232 87,233 87,243 86,247 84,238" style="fill: rgb(144,128,130)" /> - <polygon points="84,339 85,340 86,341 87,342 88,343 87,343 86,343 85,342 84,340" style="fill: rgb(96,86,84)" /> - <polygon points="181,33 182,31 183,30 184,30 185,30 189,30 192,31 189,33" style="fill: rgb(154,145,148)" /> - <polygon points="139,394 141,394 147,397 143,397 139,395" style="fill: rgb(64,55,56)" /> - <polygon points="245,153 246,152 247,151 248,151 249,152 250,154 249,155 248,155 247,155 246,155" style="fill: rgb(59,49,50)" /> - <polygon points="57,313 62,317 63,318 64,319 65,320 64,320 60,317" style="fill: rgb(219,220,224)" /> - <polygon points="104,359 105,359 107,360 110,362 110,364 107,362 106,361" style="fill: rgb(59,49,50)" /> - <polygon points="279,109 281,106 282,109 282,111 282,112 281,112" style="fill: rgb(226,223,225)" /> - <polygon points="114,364 118,363 124,363 136,369 144,373 135,374 117,366 115,365" style="fill: rgb(64,55,56)" /> - <polygon points="282,259 285,252 286,252 287,252 289,257 287,263 284,265 283,265" style="fill: rgb(122,110,114)" /> - <polygon points="125,394 126,385 127,381 128,380 129,380 130,380 149,383 152,384 171,391 167,398 163,398 162,398 160,398 159,398 157,398 156,398 155,398 154,398 153,398 152,398 150,398 144,398 142,398 140,398 139,398 136,398 131,398" style="fill: rgb(59,49,50)" /> - <polygon points="58,27 58,26 59,23 60,25 61,28 61,29 59,31" style="fill: rgb(138,130,128)" /> - <polygon points="259,41 261,37 262,36 267,36 273,39 285,47 310,64 311,66 311,67 310,70 305,83 303,85 296,88" style="fill: rgb(224,208,205)" /> - <polygon points="259,146 261,146 267,149 269,150 273,152 272,153 265,155 263,154 260,150 259,148" style="fill: rgb(110,102,99)" /> - <polygon points="301,183 302,182 303,181 304,181 305,186 305,187" style="fill: rgb(235,221,221)" /> - <polygon points="230,384 238,372 247,368 250,367 250,369 249,374 239,383 231,385" style="fill: rgb(167,158,154)" /> - <polygon points="273,166 275,165 276,165 276,167 276,168 273,168" style="fill: rgb(253,250,250)" /> - <polygon points="235,394 236,393 241,392 242,392 240,394" style="fill: rgb(163,139,139)" /> - <polygon points="200,182 201,182 202,182 204,182 206,183 206,184" style="fill: rgb(110,102,99)" /> - <polygon points="122,378 122,377 122,376 128,377 128,378 124,379" style="fill: rgb(59,49,50)" /> - <polygon points="305,240 305,238 306,236 308,235 309,235 310,235 313,235 315,236 319,238 321,239 340,249 341,260 341,261 325,269 321,270 308,250" style="fill: rgb(167,158,154)" /> - <polygon points="202,39 204,39 206,40 212,46 213,51 209,51 208,51 206,51 205,51 204,50 202,40" style="fill: rgb(138,130,128)" /> - <polygon points="84,138 86,137 87,137 86,139 85,140 84,140" style="fill: rgb(154,134,136)" /> - <polygon points="300,119 307,115 308,115 303,133 302,135 301,129" style="fill: rgb(169,179,170)" /> - <polygon points="1,114 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174 8,155 5,143 2,126 1,115 1,106 2,65 3,59 6,55 10,53 27,60 58,195 59,205 59,206 59,208 58,208 33,192 15,174" style="fill: rgb(154,134,136)" /> - <polygon points="238,21 239,21 244,24 241,24" style="fill: rgb(247,247,247)" /> - <polygon points="230,37 230,34 231,34 233,35 234,36 234,37 233,37 231,37" style="fill: rgb(247,247,247)" /> - <polygon points="1,372 7,373 13,379 13,380 6,376 1,373" style="fill: rgb(253,250,250)" /> - <polygon points="57,54 58,53 70,45 84,37 112,24 114,25 125,35 127,38 115,57 99,74 98,75 97,75 96,75 92,73 62,57" style="fill: rgb(196,174,171)" /> - <polygon points="61,388 61,387 61,386 61,384 62,380 64,379 63,388 62,389 61,389" style="fill: rgb(245,254,253)" /> - <polygon points="339,253 341,251 342,251 344,254 346,259 346,260 346,261 346,262 344,263 343,262 339,255" style="fill: rgb(149,142,141)" /> - <polygon points="124,371 125,370 131,373 135,375 137,376 138,377 135,377 125,372" style="fill: rgb(53,44,47)" /> - <polygon points="303,149 303,145 303,141 303,140 304,133 324,93 325,91 326,89 327,87 329,84 371,39 386,23 392,17 393,16 394,15 395,14 396,13 397,12 398,11 399,13 399,17 399,149 399,185 399,217 399,221 399,222 399,223 398,226 383,219 377,216 361,208 353,204 307,179 306,178 305,176 304,174" style="fill: rgb(181,220,243)" /> - <polygon points="161,211 229,199 230,199 234,201 236,203 237,206 231,217 175,222 174,222" style="fill: rgb(45,44,50)" /> - <polygon points="230,296 230,293 231,291 237,290 238,290 238,296 238,297 237,297" style="fill: rgb(86,72,72)" /> - <polygon points="26,339 26,338 26,337 30,339 31,340 31,342 30,343" style="fill: rgb(245,254,253)" /> - <polygon points="115,142 115,141 118,139 119,139 122,140 116,143" style="fill: rgb(64,55,56)" /> - <polygon points="93,272 94,271 95,270 96,270 101,272 101,273 101,274 98,278 97,279 94,274" style="fill: rgb(119,107,108)" /> - <polygon points="192,127 192,126 194,125 196,124 196,125 194,127 193,127" style="fill: rgb(86,72,72)" /> - <polygon points="293,106 295,104 298,104 300,105 301,107 300,107" style="fill: rgb(207,194,195)" /> - <polygon points="67,250 68,246 69,246 69,248 69,249 69,250 69,251 67,251" style="fill: rgb(75,63,63)" /> - <polygon points="216,276 223,277 226,280 227,281 225,282 224,282 221,281 217,277" style="fill: rgb(110,102,99)" /> - <polygon points="0,43 15,5 17,0 20,0 19,3 16,11 8,32 6,37 4,42 0,52" style="fill: rgb(196,174,171)" /> - <polygon points="291,194 293,189 294,190 295,191 297,193 296,196" style="fill: rgb(196,174,171)" /> - <polygon points="40,379 42,365 49,319 50,315 51,314 52,314 69,332 69,339 69,340 69,341 69,342 69,344 69,345 68,349 67,353 66,355 61,361 42,382" style="fill: rgb(252,253,253)" /> - <polygon points="234,399 245,390 247,390 245,398 243,399" style="fill: rgb(196,174,171)" /> - <polygon points="146,40 148,39 154,38 154,40 153,42 149,43 148,42" style="fill: rgb(110,102,99)" /> - <polygon points="394,384 395,383 396,383 397,383 398,383 398,384 398,387 395,385" style="fill: rgb(122,110,114)" /> - <polygon points="236,384 241,378 242,378 243,379 238,383" style="fill: rgb(171,148,150)" /> - <polygon points="292,235 293,231 298,230 299,231 297,238 296,241 294,242 293,241 292,236" style="fill: rgb(171,148,150)" /> - <polygon points="158,145 158,144 159,142 162,140 162,142 162,144 161,145 160,145 159,145" style="fill: rgb(86,72,72)" /> - <polygon points="174,2 175,0 177,0 214,1 212,6 209,13 207,17 204,16 178,4" style="fill: rgb(224,208,205)" /> - <polygon points="259,3 259,2 261,3 265,6 271,11 272,12 272,13 271,13 266,9 260,4" style="fill: rgb(154,145,148)" /> - <polygon points="298,114 299,113 300,113 301,113 302,118 302,119 300,118 299,117 298,115" style="fill: rgb(196,174,171)" /> - <polygon points="5,44 6,41 10,31 12,26 13,26 12,29 11,32 8,40 6,45" style="fill: rgb(86,72,72)" /> - <polygon points="391,346 398,350 399,351 398,351 392,348 391,347" style="fill: rgb(196,174,171)" /> - <polygon points="368,355 368,353 371,342 375,335 376,334 377,333 378,332 394,350 393,357" style="fill: rgb(214,193,190)" /> - <polygon points="126,177 126,176 126,175 127,174 128,173 130,175 129,176 128,177 127,177" style="fill: rgb(86,72,72)" /> - <polygon points="80,399 81,399 82,399 83,399 92,399 93,399 88,399 89,399 90,399 91,399 84,399 85,399 86,399 87,399" style="fill: rgb(110,102,99)" /> - <polygon points="314,398 316,394 330,367 362,308 366,301 367,300 368,303 368,304 360,319 320,394 318,397 317,398 315,399 314,399" style="fill: rgb(133,121,114)" /> - <polygon points="150,43 158,41 161,41 169,43 170,44 169,46 160,46 159,46 155,45" style="fill: rgb(110,102,99)" /> - <polygon points="63,255 64,252 70,254 69,255" style="fill: rgb(122,110,114)" /> - <polygon points="162,288 163,284 172,286 172,294 171,295 168,296 167,296 166,295" style="fill: rgb(59,49,50)" /> - <polygon points="74,236 74,232 75,202 76,199 81,220 83,261 83,263 83,264 82,265 77,260 74,250" style="fill: rgb(167,158,154)" /> - <polygon points="0,145 0,149 0,141 0,146 0,150 0,142 0,147 0,151 0,143 0,148 0,144" style="fill: rgb(154,134,136)" /> - <polygon points="168,288 169,287 175,287 176,287 177,287 178,287 181,288 182,289 194,303 194,304 194,305 192,306 187,306 175,299 168,292" style="fill: rgb(45,44,50)" /> - <polygon points="142,357 144,355 147,353 147,354 145,357" style="fill: rgb(35,34,40)" /> - <polygon points="188,387 218,377 218,378 208,397 205,398 204,398 203,398 202,398 201,398 195,398 194,398 190,397 189,396" style="fill: rgb(64,55,56)" /> - <polygon points="242,237 248,228 249,227 251,228 252,233 246,237 245,237 244,237" style="fill: rgb(247,247,247)" /> - <polygon points="295,279 296,278 304,270 305,271 305,274 305,275 304,276 302,277 299,278 296,279" style="fill: rgb(172,166,165)" /> - <polygon points="159,33 160,32 163,31 164,32 162,34 160,34" style="fill: rgb(167,158,154)" /> - <polygon points="186,197 187,197 188,197 196,199 199,200 208,204 208,205 207,206 206,206 205,206 204,206 203,206 202,206 190,206 189,206 186,200" style="fill: rgb(64,55,56)" /> - <polygon points="298,215 298,214 301,211 302,211 303,211 303,215 301,218 299,219" style="fill: rgb(171,148,150)" /> - <polygon points="123,255 124,252 125,252 126,254 124,259" style="fill: rgb(96,86,84)" /> - <polygon points="172,237 172,236 178,235 184,236 184,237 183,238 177,241 176,241 174,240 172,238" style="fill: rgb(86,72,72)" /> - <polygon points="287,133 287,131 290,132 292,140 291,141 289,140 288,139" style="fill: rgb(110,102,99)" /> - <polygon points="319,207 322,209 323,210 324,211 324,212 322,213 321,212 319,208" style="fill: rgb(247,247,247)" /> - <polygon points="71,396 72,391 84,341 85,343 90,354 88,371 81,391 78,395 75,398 74,398 73,398 72,398 71,397" style="fill: rgb(110,102,99)" /> - <polygon points="245,342 246,334 247,334 248,335 249,342 249,344" style="fill: rgb(133,121,114)" /> - <polygon points="70,191 70,187 71,188 74,193 71,197 70,193" style="fill: rgb(110,102,99)" /> - <polygon points="71,3 71,1 73,0 74,3 75,6 79,20 80,24 80,25 79,26 77,25 76,22 73,11" style="fill: rgb(214,193,190)" /> - <polygon points="1,199 1,195 1,191 1,187 1,178 1,177 2,176 30,194 29,198 26,199 13,203 12,203 11,203 1,200 1,195 1,191 1,187 1,178 1,177 2,176 30,194 29,198 26,199 13,203 12,203 11,203 1,200 1,195 1,191 1,187 1,178 1,177 2,176 30,194 29,198 26,199 13,203 12,203 11,203 1,200 1,195 1,191 1,187 1,178 1,177 2,176 30,194 29,198 26,199 13,203 12,203 11,203 1,200 1,195 1,191 1,187 1,178 1,177 2,176 30,194 29,198 26,199 13,203 12,203 11,203 1,200 1,195 1,191 1,187 1,178 1,177 2,176 30,194 29,198 26,199 13,203 12,203 11,203 1,200 1,195 1,191 1,187 1,178 1,177 2,176 30,194 29,198 26,199 13,203 12,203 11,203 1,200 1,195 1,191 1,187 1,178 1,177 2,176 30,194 29,198 26,199 13,203 12,203 11,203 1,200 1,195 1,191 1,187 1,178 1,177 2,176 30,194 29,198 26,199 13,203 12,203 11,203 1,200 1,195 1,191 1,187 1,178 1,177 2,176 30,194 29,198 26,199 13,203 12,203 11,203 1,200 1,195 1,191 1,187 1,178 1,177 2,176 30,194 29,198 26,199 13,203 12,203 11,203 1,200 1,195 1,191 1,187 1,178 1,177 2,176 30,194 29,198 26,199 13,203 12,203 11,203 1,200 1,195 1,191 1,187 1,178 1,177 2,176 30,194 29,198 26,199 13,203 12,203 11,203 1,200 1,195 1,191 1,187 1,178 1,177 2,176 30,194 29,198 26,199 13,203 12,203 11,203 1,200 1,195 1,191 1,187 1,178 1,177 2,176 30,194 29,198 26,199 13,203 12,203 11,203 1,200 1,195 1,191 1,187 1,178 1,177 2,176 30,194 29,198 26,199 13,203 12,203 11,203 1,200 1,195 1,191 1,187 1,178 1,177 2,176 30,194 29,198 26,199 13,203 12,203 11,203 1,200 1,195 1,191 1,187 1,178 1,177 2,176 30,194 29,198 26,199 13,203 12,203 11,203 1,200 1,195 1,191 1,187 1,178 1,177 2,176 30,194 29,198 26,199 13,203 12,203 11,203 1,200 1,195 1,191 1,187 1,178 1,177 2,176 30,194 29,198 26,199 13,203 12,203 11,203 1,200 1,195 1,191 1,187 1,178 1,177 2,176 30,194 29,198 26,199 13,203 12,203 11,203 1,200 1,195 1,191 1,187 1,178 1,177 2,176 30,194 29,198 26,199 13,203 12,203 11,203 1,200 1,195 1,191 1,187 1,178 1,177 2,176 30,194 29,198 26,199 13,203 12,203 11,203 1,200 1,195 1,191 1,187 1,178 1,177 2,176 30,194 29,198" style="fill: rgb(110,102,99)" /> - <polygon points="228,150 229,138 231,138 237,147 236,148 235,149 232,150" style="fill: rgb(59,49,50)" /> - <polygon points="110,4 111,1 112,3 113,5 118,18 117,20 115,21 114,19 111,8" style="fill: rgb(217,200,201)" /> - <polygon points="276,319 277,318 278,318 279,318 284,321 285,322 284,322" style="fill: rgb(167,158,154)" /> - <polygon points="61,2 63,1 66,1 67,2 70,7 71,10 72,14 71,15 70,15" style="fill: rgb(119,107,108)" /> - <polygon points="59,312 60,312 69,320 71,322 65,318 61,315 60,314" style="fill: rgb(167,158,154)" /> - <polygon points="68,307 69,307 73,311 76,315 72,315 68,314" style="fill: rgb(122,110,114)" /> - <polygon points="221,344 222,343 224,343 229,345 230,350 222,350" style="fill: rgb(86,72,72)" /> - <polygon points="226,265 232,269 233,270 233,271 231,270 228,268 227,267" style="fill: rgb(75,63,63)" /> - <polygon points="41,391 42,389 43,388 49,382 49,384 49,385 49,387 48,392 44,393 42,393 41,392" style="fill: rgb(252,251,252)" /> - <polygon points="68,385 68,384 69,383 70,384 69,386 68,388" style="fill: rgb(253,250,250)" /> - <polygon points="171,289 175,288 177,288 206,290 207,291 207,292 207,293 203,298 192,305 191,305 189,304 176,296 173,293" style="fill: rgb(45,44,50)" /> - <polygon points="276,187 277,187 278,187 283,188 281,189 279,189" style="fill: rgb(252,251,252)" /> - <polygon points="276,42 277,42 280,43 280,45 279,45" style="fill: rgb(217,200,201)" /> - <polygon points="194,31 194,30 197,30 198,30 200,30 202,32 200,33 198,33 194,32" style="fill: rgb(149,142,141)" /> - <polygon points="231,228 238,220 239,220 242,222 247,227 248,231 246,233 242,234 237,233" style="fill: rgb(252,253,253)" /> - <polygon points="251,179 251,178 252,178 261,181 262,182 263,183 264,184 265,188 264,190 259,190 258,190 254,185" style="fill: rgb(252,253,253)" /> - <polygon points="33,377 35,368 35,372 34,376" style="fill: rgb(245,254,253)" /> - <polygon points="88,253 89,250 91,255 91,256 90,256 89,256 88,255" style="fill: rgb(133,121,114)" /> - <polygon points="74,273 74,268 74,267 77,262 78,266 78,268 78,270 77,286 76,285 75,284" style="fill: rgb(167,158,154)" /> - <polygon points="120,146 124,142 127,142 128,144 128,145 127,146 126,146" style="fill: rgb(96,86,84)" /> - <polygon points="78,151 79,151 81,153 80,159 79,162 78,164 78,155" style="fill: rgb(154,134,136)" /> - <polygon points="194,3 194,2 194,1 195,1 196,1 199,1 207,1 211,1 211,5 210,6 209,7 205,11 194,4" style="fill: rgb(231,214,217)" /> - <polygon points="93,152 111,89 117,70 120,65 128,54 142,46 149,44 153,44 171,45 186,50 216,69 266,108 269,111 270,112 271,113 276,119 268,138 113,352 111,351 107,348 106,347 105,346 104,345 93,189" style="fill: rgb(75,63,63)" /> - <polygon points="85,185 86,185 87,185 89,185 89,186 87,192 86,190" style="fill: rgb(133,121,114)" /> - <polygon points="1,201 24,198 25,198 25,199 8,217 1,202" style="fill: rgb(110,102,99)" /> - <polygon points="201,353 202,350 203,350 205,351 205,353 201,354" style="fill: rgb(35,34,40)" /> - <polygon points="238,287 238,283 238,282 241,283 247,287 247,288 247,289 246,293 244,295 241,295 240,294" style="fill: rgb(110,102,99)" /> - <polygon points="102,121 102,117 103,117 104,119 103,122" style="fill: rgb(119,107,108)" /> - <polygon points="1,58 1,56 1,54 4,46 5,47 5,48 5,49" style="fill: rgb(86,72,72)" /> - <polygon points="93,7 94,1 95,1 99,1 100,1 103,10 100,11 99,11 98,11 94,8" style="fill: rgb(149,142,141)" /> - <polygon points="91,117 91,113 94,113 94,114 94,119 93,121 92,121" style="fill: rgb(138,130,128)" /> - <polygon points="191,370 191,369 191,368 192,365 193,365 194,365 199,366 201,368 204,374 203,375" style="fill: rgb(35,34,40)" /> - <polygon points="243,59 243,58 244,58 245,58 246,58 247,61 247,63 247,65 245,67 244,67 243,66" style="fill: rgb(240,239,240)" /> - <polygon points="2,256 4,245 11,211 12,208 13,207 15,206 19,204 21,203 28,200 31,200 44,214 44,216 44,218 44,219 43,227 42,235 40,247 39,251 38,253 37,255 36,257 6,257" style="fill: rgb(96,86,84)" /> - <polygon points="166,27 166,26 169,25 175,23 176,23 178,23 176,25 167,27" style="fill: rgb(214,193,190)" /> - <polygon points="251,365 253,357 254,354 255,351 256,348 259,344 261,343 263,345 272,377 273,381 274,385 274,386 272,390 271,391 270,391 265,386 256,376" style="fill: rgb(154,134,136)" /> - <polygon points="379,336 380,331 381,329 386,328 382,335 381,336 380,336" style="fill: rgb(231,214,217)" /> - <polygon points="245,360 246,359 247,358 251,356 252,356 251,361 250,362 247,363 246,362" style="fill: rgb(196,174,171)" /> - <polygon points="123,357 123,356 124,355 125,355 126,355 127,356 128,357 128,358 128,359 128,360 128,361 126,361 125,360 124,359" style="fill: rgb(75,63,63)" /> - <polygon points="240,214 242,214 246,215 250,221 250,222 250,224 248,223 242,218 240,215" style="fill: rgb(110,102,99)" /> - <polygon points="204,393 204,392 213,380 217,379 218,379 218,381 213,395 209,398 208,398 207,398 206,398 205,396" style="fill: rgb(75,63,63)" /> - <polygon points="190,269 191,265 192,264 199,264 200,264 201,264 202,264 204,275 195,273" style="fill: rgb(110,102,99)" /> - <polygon points="322,84 324,82 327,79 329,77 331,75 333,73 323,83 325,81 326,80 328,78 330,76 332,74" style="fill: rgb(133,121,114)" /> - <polygon points="196,320 198,319 200,319 200,321 197,321 196,321" style="fill: rgb(45,44,50)" /> - <polygon points="85,259 85,258 86,254 87,251 90,262 87,263 85,260" style="fill: rgb(138,130,128)" /> - <polygon points="333,221 334,220 337,219 337,220 337,222 336,222 335,222 334,222" style="fill: rgb(245,254,253)" /> - <polygon points="45,0 49,0 57,28 58,32 58,33 57,34 55,35 54,32 52,25" style="fill: rgb(196,174,171)" /> - <polygon points="0,91 0,75 0,108 0,92 0,109 0,76 0,93 0,77 0,110 0,94 0,78 0,111 0,95 0,79 0,112 0,96 0,113 0,80 0,97 0,81 0,114 0,65 0,98 0,82 0,115 0,66 0,99 0,83 0,116 0,67 0,100 0,117 0,84 0,101 0,68 0,85 0,118 0,69 0,102 0,86 0,119 0,70 0,103 0,87 0,120 0,71 0,104 0,88 0,105 0,72 0,89 0,73 0,106 0,90 0,74 0,107" style="fill: rgb(163,139,139)" /> - <polygon points="220,377 222,373 226,371 227,374 225,376" style="fill: rgb(75,63,63)" /> - <polygon points="388,282 389,279 390,276 391,274 393,270 396,269 392,277 390,280 389,281" style="fill: rgb(181,220,243)" /> - <polygon points="1,36 1,35 2,32 4,26 8,16 9,14 10,12 10,13 8,19 1,37" style="fill: rgb(96,86,84)" /> - <polygon points="74,223 74,221 76,225 76,226 76,227 76,228 76,229 75,228" style="fill: rgb(167,158,154)" /> - <polygon points="393,233 394,231 396,231 397,231 399,234 395,234 394,234" style="fill: rgb(247,247,247)" /> - <polygon points="15,211 15,209 16,208 28,202 29,202 25,206" style="fill: rgb(171,148,150)" /> - <polygon points="279,294 283,291 283,292 282,297 280,297 279,296" style="fill: rgb(110,102,99)" /> - <polygon points="384,292 386,289 392,281 394,279 393,281 387,290 386,291" style="fill: rgb(205,205,210)" /> - <polygon points="162,248 165,245 166,246 167,248 167,249 167,250 166,250" style="fill: rgb(86,72,72)" /> - <polygon points="135,151 143,146 159,146 174,148 173,149 163,153 162,153 161,153 160,153 136,152" style="fill: rgb(64,55,56)" /> - <polygon points="24,324 25,309 28,298 41,324 43,332 43,333 43,334 43,335 43,336 42,337 37,334 29,329 26,327 25,326" style="fill: rgb(234,254,253)" /> - <polygon points="246,263 246,262 247,262 252,267 254,270 251,272 250,272" style="fill: rgb(86,72,72)" /> - <polygon points="0,2 0,1 1,0 2,0 3,0 4,0 5,0 6,0 7,0 8,0 9,0 10,0 11,0 12,0 13,0 0,37 0,18 0,1 1,0 2,0 3,0 4,0 5,0 6,0 7,0 8,0 9,0 10,0 11,0 12,0 13,0 0,37 0,18 0,1 1,0 2,0 3,0 4,0 5,0 6,0 7,0 8,0 9,0 10,0 11,0 12,0 13,0 0,37 0,18 0,1" style="fill: rgb(110,102,99)" /> - <polygon points="262,35 263,33 264,33 266,34 266,35 265,36" style="fill: rgb(217,200,201)" /> - <polygon points="76,293 76,292 77,291 80,290 81,292 83,297 84,300 85,306 80,308 79,308 77,300" style="fill: rgb(149,142,141)" /> - <polygon points="117,143 118,142 121,141 122,141 123,141 124,141 122,143 121,143 120,143" style="fill: rgb(75,63,63)" /> - <polygon points="294,214 296,211 299,212 300,213 298,216 296,216 295,215" style="fill: rgb(163,139,139)" /> - <polygon points="90,253 90,252 90,251 92,247 94,246 95,255 95,260 95,263 94,265 93,263 92,260" style="fill: rgb(110,102,99)" /> - <polygon points="75,286 75,285 78,261 79,261 80,261 84,266 79,292 76,290" style="fill: rgb(163,139,139)" /> - <polygon points="278,249 279,245 282,245 283,247 284,250 283,252" style="fill: rgb(122,110,114)" /> - <polygon points="385,281 385,280 385,276 394,260 399,258 399,265 399,266 386,284 385,284" style="fill: rgb(225,233,236)" /> - <polygon points="48,210 48,207 49,207 51,207 54,209 52,210 50,210" style="fill: rgb(110,102,99)" /> - <polygon points="269,232 269,231 270,229 271,229 272,230 273,231 269,233" style="fill: rgb(163,139,139)" /> - <polygon points="152,262 152,261 154,260 157,259 158,259 159,259 157,261 154,262 153,262" style="fill: rgb(75,63,63)" /> - <polygon points="87,130 87,126 88,127 88,130 88,132 87,132 87,127 87,126 88,127 88,130 88,132 87,132" style="fill: rgb(154,134,136)" /> - <polygon points="278,20 281,22 286,26 290,30 281,23 279,21" style="fill: rgb(205,205,210)" /> - <polygon points="1,248 1,244 1,238 2,234 4,234 4,236 4,237 4,238 2,248 1,249" style="fill: rgb(110,102,99)" /> - <polygon points="153,148 155,147 159,147 163,148 162,149 153,149" style="fill: rgb(75,63,63)" /> - <polygon points="179,321 180,319 184,318 190,317 191,319 191,321 188,324 180,322" style="fill: rgb(59,49,50)" /> - <polygon points="122,335 123,333 124,332 125,331 126,331 126,332 125,334 124,335" style="fill: rgb(45,44,50)" /> - <polygon points="75,395 86,346 88,345 92,346 94,348 95,356 95,359 95,363 95,375 93,382 89,394 88,397 87,398 86,398 85,398 84,398 78,398 77,398 76,398" style="fill: rgb(96,86,84)" /> - <polygon points="115,22 117,19 125,12 132,8 151,0 154,0 158,1 146,7 132,14" style="fill: rgb(224,208,205)" /> - <polygon points="218,324 218,323 219,321 221,321 226,327 226,329 226,330 220,327 218,326" style="fill: rgb(45,44,50)" /> - <polygon points="195,208 199,207 205,208 199,209" style="fill: rgb(53,44,47)" /> - <polygon points="128,1 129,1 130,1 131,1 132,1 133,2 134,4 134,5" style="fill: rgb(149,142,141)" /> - <polygon points="120,360 121,359 129,359 130,363 125,363 121,361" style="fill: rgb(59,49,50)" /> - <polygon points="153,206 156,198 157,198 159,199 163,203 163,204 163,205 159,210 156,210 153,207" style="fill: rgb(64,55,56)" /> - <polygon points="59,192 59,191 59,190 60,184 60,189 60,190 59,193" style="fill: rgb(86,72,72)" /> - <polygon points="62,370 63,368 64,366 65,371 64,376 63,376 62,376" style="fill: rgb(245,254,253)" /> - <polygon points="228,183 228,182 229,182 231,182 233,183 235,185 233,185 231,185 229,184" style="fill: rgb(240,239,240)" /> - <polygon points="285,228 289,227 290,227 290,228 289,229 287,230" style="fill: rgb(154,134,136)" /> - <polygon points="309,108 310,105 311,104 312,104 313,104 313,105 310,108" style="fill: rgb(205,205,210)" /> - <polygon points="287,212 288,211 291,209 293,211 294,212" style="fill: rgb(163,139,139)" /> - <polygon points="300,117 301,111 303,112 303,114 302,117" style="fill: rgb(196,174,171)" /> - <polygon points="181,27 184,26 187,26 186,27" style="fill: rgb(172,166,165)" /> - <polygon points="181,380 189,377 190,377 197,378 197,379 197,380 196,381 194,382 192,382 185,382 183,381" style="fill: rgb(59,49,50)" /> - <polygon points="159,39 161,35 162,35 164,36 164,37 164,38 162,39 161,39 160,39" style="fill: rgb(133,121,114)" /> - <polygon points="294,102 294,100 296,98 299,104 297,104 296,104 294,103" style="fill: rgb(217,200,201)" /> - <polygon points="17,13 18,10 21,2 22,1 22,3 19,11 18,13" style="fill: rgb(96,86,84)" /> - <polygon points="116,329 132,308 156,281 160,282 164,291 164,292 164,293 162,300 158,311 157,312 155,314 120,335 118,335 116,334" style="fill: rgb(75,63,63)" /> - <polygon points="246,1 250,0 252,0 266,11 300,38 305,42 307,44 306,45 272,23 269,21 254,9" style="fill: rgb(219,220,224)" /> - <polygon points="102,346 103,346 113,354 114,357 110,354 104,349" style="fill: rgb(64,55,56)" /> - <polygon points="240,238 250,233 252,232 253,233 252,236 251,237 248,238 243,239 242,239" style="fill: rgb(253,250,250)" /> - <polygon points="85,211 87,209 91,205 93,206 93,208 93,210 91,215 89,215 86,214" style="fill: rgb(122,110,114)" /> - <polygon points="200,43 200,42 201,39 204,40 205,41 206,42 205,44" style="fill: rgb(133,121,114)" /> - <polygon points="44,336 44,335 45,326 47,312 49,312 49,313 48,321 47,328 46,335 45,339 44,343" style="fill: rgb(225,233,236)" /> - <polygon points="81,308 82,308 87,311 89,313 90,316 90,317 89,317 88,317 87,316 82,310" style="fill: rgb(138,130,128)" /> - <polygon points="229,25 233,17 237,20 233,26 232,27 230,27 229,26" style="fill: rgb(226,226,230)" /> - <polygon points="296,240 297,239 298,239 298,240 298,244 296,244" style="fill: rgb(167,158,154)" /> - <polygon points="40,393 47,384 55,376 56,375 65,375 65,376 65,379 65,380 65,383 64,394 63,396 60,399 50,399 42,396 41,395 40,394" style="fill: rgb(252,253,253)" /> - <polygon points="202,151 202,150 203,145 205,144 209,143 263,169 262,170 257,174 255,175 239,179 238,179" style="fill: rgb(96,86,84)" /> - <polygon points="55,306 56,306 57,306 64,311 64,312 64,313 63,313 58,311" style="fill: rgb(133,121,114)" /> - <polygon points="184,25 185,25 186,25 187,25 189,25 190,25 191,25 200,25 201,25 197,26 196,26 188,26" style="fill: rgb(202,194,191)" /> - <polygon points="202,335 202,334 204,335 206,336 212,340 206,341 205,341" style="fill: rgb(64,55,56)" /> - <polygon points="83,202 83,201 86,201 89,201 94,205 94,208 94,210 94,212 93,219 92,222 89,224 88,224 85,219" style="fill: rgb(122,110,114)" /> - <polygon points="257,323 261,325 261,330 259,330 258,329" style="fill: rgb(96,86,84)" /> - <polygon points="85,31 92,30 89,35 87,36 86,35 85,32" style="fill: rgb(214,193,190)" /> - <polygon points="373,342 374,340 375,338 376,336 379,339 378,340 374,343 373,343" style="fill: rgb(217,200,201)" /> - <polygon points="62,177 64,176 65,176 66,176 67,176 76,179 75,188 74,192 66,185 65,184 62,178" style="fill: rgb(96,86,84)" /> - <polygon points="292,268 293,259 295,256 295,257 295,259 294,263 293,267" style="fill: rgb(154,145,148)" /> - <polygon points="283,109 285,106 287,106 289,108 290,110 290,111 290,112 289,113 285,111" style="fill: rgb(235,221,221)" /> - <polygon points="309,188 311,186 315,186 317,187 315,190 314,191 312,190" style="fill: rgb(247,247,247)" /> - <polygon points="126,327 127,325 157,286 160,283 174,280 194,282 201,283 223,287 229,313 228,314 223,317 215,321 206,324 129,328 128,328" style="fill: rgb(59,49,50)" /> - <polygon points="146,273 147,272 148,272 150,273 151,274 153,276 154,277 148,277" style="fill: rgb(110,102,99)" /> - <polygon points="247,397 247,396 248,393 250,394 253,397 253,398 252,398 251,398 250,398 249,398 248,398" style="fill: rgb(110,102,99)" /> - <polygon points="166,39 176,38 187,39 189,40 189,43 188,44 183,44 182,44 181,44 180,44 168,40" style="fill: rgb(122,110,114)" /> - <polygon points="340,244 340,243 344,245 346,246 355,251 356,252 356,253 343,246" style="fill: rgb(196,174,171)" /> - <polygon points="233,243 233,241 234,241 235,241 236,244 235,244 234,244" style="fill: rgb(240,239,240)" /> - <polygon points="175,172 176,172 177,172 178,172 179,172 180,172 179,176 176,177 175,175" style="fill: rgb(133,121,114)" /> - <polygon points="368,297 369,295 373,288 376,283 377,282 378,283 378,285 374,293 370,300 369,299" style="fill: rgb(133,121,114)" /> - <polygon points="234,19 234,17 234,16 236,12 238,14 240,16 237,19" style="fill: rgb(219,210,214)" /> - <polygon points="262,181 268,186 269,187 269,188 269,189 265,187 264,186" style="fill: rgb(252,251,252)" /> - <polygon points="324,195 324,190 326,191 333,195 334,199 334,200 332,199 326,196" style="fill: rgb(252,253,253)" /> - <polygon points="163,369 164,368 165,368 166,369 167,372 167,373 166,373 164,372" style="fill: rgb(35,34,40)" /> - <polygon points="55,282 55,281 56,279 58,278 60,280 60,282 56,283 55,283" style="fill: rgb(110,102,99)" /> - <polygon points="281,244 283,243 287,248 284,248" style="fill: rgb(133,121,114)" /> - <polygon points="231,331 235,330 236,331 236,332 233,335" style="fill: rgb(96,86,84)" /> - <polygon points="224,92 224,88 225,88 229,90 229,91 228,92 225,93" style="fill: rgb(110,102,99)" /> - <polygon points="319,399 320,397 328,382 350,341 353,336 367,334 359,346 325,396 324,397 323,398" style="fill: rgb(214,193,190)" /> - <polygon points="36,385 40,364 41,365 41,366 41,367 41,368 41,369 39,385" style="fill: rgb(248,247,245)" /> - <polygon points="162,43 162,42 163,40 165,39 173,40 174,42 174,43 172,44 171,44" style="fill: rgb(119,107,108)" /> - <polygon points="60,33 61,31 62,34 62,36 61,37 60,34" style="fill: rgb(138,130,128)" /> - <polygon points="82,120 83,115 89,111 89,116 88,123 82,121" style="fill: rgb(154,134,136)" /> - <polygon points="233,91 236,89 237,89 241,93 243,96 242,97 241,98 240,98 234,92" style="fill: rgb(110,102,99)" /> - <polygon points="132,0 133,0 134,0 135,0 136,0 137,0 138,0 139,0 140,0 141,0 142,0 143,0 144,0 145,0 146,0 147,0" style="fill: rgb(169,179,170)" /> - <polygon points="208,39 208,38 210,35 211,34 212,34 213,35 214,36 216,38 215,39 213,40 212,40 210,40" style="fill: rgb(149,142,141)" /> - <polygon points="281,97 286,95 287,96 288,97 287,98 283,102" style="fill: rgb(247,247,247)" /> - <polygon points="360,216 361,215 362,214 368,216 368,218 368,219 368,221 367,221 366,221 365,221 363,221 361,221" style="fill: rgb(240,239,240)" /> - <polygon points="0,62 4,54 5,52 6,51 8,50 10,51 10,56 10,57 9,64 8,64 2,64 0,63" style="fill: rgb(144,128,130)" /> - <polygon points="81,210 84,215 87,224 89,233 87,234 85,232 84,231 81,212" style="fill: rgb(149,142,141)" /> - <polygon points="235,73 237,71 240,75 239,77 236,74" style="fill: rgb(248,247,245)" /> - <polygon points="0,276 1,274 2,274 4,275 7,277 16,285 17,286 19,288 20,290 20,292 20,293 20,296 20,297 19,307 18,314 17,317 16,317 0,305" style="fill: rgb(245,254,253)" /> - <polygon points="87,231 90,226 91,227 93,231 93,233 92,235 88,232" style="fill: rgb(133,121,114)" /> - <polygon points="381,313 381,312 385,303 386,302 387,302 392,305 392,306 386,323 384,324 381,323" style="fill: rgb(224,208,205)" /> - <polygon points="211,225 212,223 234,219 235,219 234,220 225,227 219,227" style="fill: rgb(96,86,84)" /> - <polygon points="88,238 90,235 93,234 97,234 96,235 91,238" style="fill: rgb(133,121,114)" /> - <polygon points="380,326 381,324 382,323 388,324 386,327 385,328 384,329 382,329 380,328" style="fill: rgb(231,214,217)" /> - <polygon points="144,38 145,37 149,35 150,35 149,36 148,37" style="fill: rgb(154,134,136)" /> - <polygon points="230,284 232,285 234,287 234,288 232,289 231,287" style="fill: rgb(86,72,72)" /> - <polygon points="277,36 277,35 278,34 279,34 283,37 286,41 284,41 282,40 279,38" style="fill: rgb(225,233,236)" /> - <polygon points="85,325 86,326 87,327 88,328 102,351 102,353 98,351 96,349 91,341 86,332 85,326" style="fill: rgb(96,86,84)" /> - <polygon points="111,112 114,110 118,111 116,112 113,113" style="fill: rgb(86,72,72)" /> - <polygon points="321,92 322,91 323,90 325,90 323,94 322,94" style="fill: rgb(169,179,170)" /> - <polygon points="199,289 200,289 204,290 205,291 205,292 200,291" style="fill: rgb(53,44,47)" /> - <polygon points="166,188 168,187 171,187 174,188 175,189" style="fill: rgb(75,63,63)" /> - <polygon points="32,356 32,364 32,357 32,365 32,358 32,359 32,360 32,361 32,362 32,363" style="fill: rgb(245,254,253)" /> - <polygon points="302,133 302,132 303,134 303,139 302,139" style="fill: rgb(202,194,191)" /> - <polygon points="300,192 301,191 303,189 304,191 305,193 305,194 305,195 305,196 304,196" style="fill: rgb(217,200,201)" /> - <polygon points="83,324 84,322 88,327 99,350 98,350 95,348 91,345 90,344 89,343 86,335 85,332" style="fill: rgb(110,102,99)" /> - <polygon points="0,156 1,116 3,116 5,117 34,190 34,191 31,191 21,185 10,178 7,176 6,175 5,173 0,157" style="fill: rgb(133,121,114)" /> - <polygon points="308,117 317,98 320,95 316,104 311,114 309,118" style="fill: rgb(225,233,236)" /> - <polygon points="211,72 212,67 213,67 215,68 215,71 215,74" style="fill: rgb(110,102,99)" /> - <polygon points="174,31 180,29 187,28 188,28 194,28 195,28 196,30 193,31 182,33 175,33 174,32" style="fill: rgb(149,142,141)" /> - <polygon points="286,112 287,111 292,112 293,113 293,114 293,115 291,116 289,115 288,114" style="fill: rgb(235,221,221)" /> - <polygon points="356,354 360,348 363,344 363,346 358,352 357,353" style="fill: rgb(196,174,171)" /> - <polygon points="355,217 357,212 359,212 360,213 358,215" style="fill: rgb(240,239,240)" /> - <polygon points="306,215 307,214 308,214 310,215 313,217 313,218 306,219" style="fill: rgb(214,193,190)" /> - <polygon points="271,320 276,313 280,309 278,313 277,315 276,317 275,319 273,321 272,322 271,321" style="fill: rgb(133,121,114)" /> - <polygon points="69,375 70,368 71,362 72,359 73,358 73,359 73,360 73,363 72,370 71,376 70,382 69,382" style="fill: rgb(252,253,253)" /> - <polygon points="202,25 203,23 205,22 213,23 218,26 220,29 219,29" style="fill: rgb(202,194,191)" /> - <polygon points="276,307 279,306 279,307 279,308 279,309 278,310 277,310 276,308" style="fill: rgb(138,130,128)" /> - <polygon points="293,44 293,43 293,42 294,40 297,40 303,44 309,48 324,58 333,64 334,67 333,69 331,72 329,73 327,72 324,70 313,62 305,56 300,52 295,48 294,47 293,45" style="fill: rgb(225,233,236)" /> - <polygon points="235,272 236,272 238,272 259,273 259,274 259,275 259,276 258,280 255,288 254,288 253,288 250,288 244,286 240,284 239,283" style="fill: rgb(75,63,63)" /> - <polygon points="265,191 266,191 267,192 268,193 269,194 266,195 265,192" style="fill: rgb(253,250,250)" /> - <polygon points="276,260 277,260 281,261 279,263 278,263 276,261" style="fill: rgb(122,110,114)" /> - <polygon points="269,178 270,176 274,181 274,182 274,183 274,184 274,185 269,179" style="fill: rgb(248,247,245)" /> - <polygon points="31,291 32,289 35,288 37,288 38,288 35,291 34,291" style="fill: rgb(133,121,114)" /> - <polygon points="149,353 151,350 152,349 154,348 155,348 156,349 156,350 151,354 149,354" style="fill: rgb(45,44,50)" /> - <polygon points="214,351 214,350 214,349 217,349 220,350 222,352 222,353 220,354 215,353" style="fill: rgb(38,38,44)" /> - <polygon points="214,78 214,77 216,76 218,75 222,79 220,83 216,81" style="fill: rgb(110,102,99)" /> - <polygon points="241,288 242,288 243,288 244,288 245,291 245,292 244,293 243,293 241,289" style="fill: rgb(119,107,108)" /> - <polygon points="4,399 5,391 7,389 10,393 8,397 7,398 5,399" style="fill: rgb(252,253,253)" /> - <polygon points="2,269 4,269 6,269 7,269 8,270 8,271 4,271 3,270" style="fill: rgb(133,121,114)" /> - <polygon points="241,29 242,25 244,25 245,25 245,31 244,31 243,31" style="fill: rgb(240,253,253)" /> - <polygon points="358,45 363,40 364,40 361,43 359,45" style="fill: rgb(110,102,99)" /> - <polygon points="95,253 95,252 95,249 97,250 98,251 99,258 99,259 97,261 96,259" style="fill: rgb(133,121,114)" /> - <polygon points="43,345 43,343 45,340 45,342 45,343 44,345 43,346" style="fill: rgb(240,239,240)" /> - <polygon points="141,135 145,135 146,135 149,135 149,136 148,138 142,136" style="fill: rgb(45,44,50)" /> - <polygon points="0,378 1,378 3,379 9,382 28,393 29,394 27,397 26,398 25,399 21,399 17,399 16,399 2,399 0,399" style="fill: rgb(252,253,253)" /> - <polygon points="271,115 271,112 272,112 276,116 277,119 277,120 275,119 271,116" style="fill: rgb(110,102,99)" /> - <polygon points="392,311 394,308 395,307 396,310 395,312 393,312" style="fill: rgb(231,214,217)" /> - <polygon points="206,152 210,151 212,151 218,155 219,156 222,159 221,159 207,153" style="fill: rgb(119,107,108)" /> - <polygon points="395,395 396,394 398,393 398,394 398,395 398,396 397,398 396,398 395,396" style="fill: rgb(133,121,114)" /> - <polygon points="145,380 153,376 202,380 203,381 199,390 198,391 196,392 170,398 169,398 168,398 165,397 163,396 158,393 155,391" style="fill: rgb(53,44,47)" /> - <polygon points="52,6 53,4 55,10 56,13 58,19 58,20 57,22 56,21 52,7" style="fill: rgb(138,130,128)" /> - <polygon points="204,35 204,32 212,35 213,36 207,41 205,39 204,38" style="fill: rgb(138,130,128)" /> - <polygon points="113,345 113,343 114,335 116,335 117,335 118,336 118,339 118,340 115,348 114,350" style="fill: rgb(96,86,84)" /> - <polygon points="306,38 309,40 313,43 318,47 319,48 320,49 314,45 310,42" style="fill: rgb(225,233,236)" /> - <polygon points="29,290 29,287 34,288 30,291" style="fill: rgb(133,121,114)" /> - <polygon points="310,185 311,185 312,185 313,185 318,189 317,189" style="fill: rgb(226,226,230)" /> - <polygon points="139,13 157,2 162,0 164,0 188,11 190,12 194,14 200,17 200,20 166,28 163,28 162,28 161,28 140,14" style="fill: rgb(214,193,190)" /> - <polygon points="136,127 138,126 143,125 144,125 145,125 146,125 147,125 148,125 149,125 150,125 148,126 139,127" style="fill: rgb(75,63,63)" /> - <polygon points="294,276 294,275 294,271 299,271 298,275" style="fill: rgb(138,130,128)" /> - <polygon points="241,259 244,256 245,256 262,262 273,272 274,273 275,275 275,276 274,288 272,310 266,331 254,349 248,355 247,355" style="fill: rgb(86,72,72)" /> - <polygon points="202,30 203,30 204,30 214,33 213,34 209,35" style="fill: rgb(172,166,165)" /> - <polygon points="37,291 40,288 46,292 47,293 48,297 47,298 45,299 38,295 37,294" style="fill: rgb(122,110,114)" /> - <polygon points="282,103 283,103 288,105 286,106 283,105" style="fill: rgb(252,251,252)" /> - <polygon points="64,215 64,214 66,210 68,208 71,207 71,208 69,211" style="fill: rgb(96,86,84)" /> - <polygon points="2,75 2,71 3,69 4,68 9,69 5,74 3,75" style="fill: rgb(154,134,136)" /> - <polygon points="387,251 387,248 399,245 399,248 399,249 398,256 397,256 393,254" style="fill: rgb(252,253,253)" /> - <polygon points="293,182 300,179 299,181 298,182 294,183 293,183" style="fill: rgb(252,251,252)" /> - <polygon points="85,220 87,220 88,221 88,223 87,223 86,222" style="fill: rgb(133,121,114)" /> - <polygon points="192,170 194,165 195,163 197,162 197,168 197,169 197,173 197,175 196,175 194,174" style="fill: rgb(163,139,139)" /> - <polygon points="350,265 350,264 352,260 353,258 354,258 351,266" style="fill: rgb(224,208,205)" /> - <polygon points="182,53 184,51 185,52 185,53 185,57 184,58 183,58" style="fill: rgb(122,110,114)" /> - <polygon points="125,335 126,328 130,326 132,328 126,335" style="fill: rgb(59,49,50)" /> - <polygon points="204,235 205,232 206,232 208,234 205,235" style="fill: rgb(86,72,72)" /> - <polygon points="77,1 79,0 84,15 85,22 85,24 81,17 80,14 79,10 78,6 77,2" style="fill: rgb(214,193,190)" /> - <polygon points="341,69 343,66 344,65 347,62 348,61 347,63 345,65" style="fill: rgb(110,102,99)" /> - <polygon points="257,41 263,45 268,49 271,52 270,52 260,44 258,42" style="fill: rgb(252,253,253)" /> - <polygon points="55,137 55,135 55,134 57,135 71,143 76,146 77,147 76,166 75,168 74,168 72,167 65,163 62,161 61,159 60,156 55,138" style="fill: rgb(196,174,171)" /> - <polygon points="202,261 203,261 204,261 205,261 206,261 207,261 216,261 217,261 218,261 208,261 209,261 210,261 211,261 212,261 213,261 214,261 215,261" style="fill: rgb(64,55,56)" /> - <polygon points="122,139 124,138 125,138 126,138 131,139 137,142 137,143 136,143" style="fill: rgb(53,44,47)" /> - <polygon points="197,66 199,64 202,64 199,69" style="fill: rgb(149,142,141)" /> - <polygon points="216,390 217,386 218,383 228,377 230,377 232,378 227,386 223,392" style="fill: rgb(96,86,84)" /> - <polygon points="226,364 227,362 228,362 229,364 229,365 228,367" style="fill: rgb(45,44,50)" /> - <polygon points="259,0 270,0 278,0 286,0 294,0 302,0 310,0 318,0 326,0 334,0 342,0 350,0 358,0 364,0 378,0 398,0 390,9 364,37 351,51 350,52 342,60 340,62 339,63 338,63 336,62 320,50 311,43 292,28 260,1" style="fill: rgb(181,220,243)" /> - <polygon points="35,69 49,77 50,78 36,73" style="fill: rgb(163,139,139)" /> - <polygon points="284,243 285,242 292,241 293,243 291,247 290,248 289,249" style="fill: rgb(154,134,136)" /> - <polygon points="178,36 184,33 186,35 187,36 184,38 180,39 179,38" style="fill: rgb(149,142,141)" /> - <polygon points="148,340 154,337 159,337 160,342 160,343 160,344 152,344 149,343 148,342" style="fill: rgb(45,44,50)" /> - <polygon points="62,111 62,110 64,111 66,112 71,115 71,116 69,115" style="fill: rgb(171,148,150)" /> - <polygon points="118,333 118,331 121,329 124,329 125,330 122,333 119,333" style="fill: rgb(75,63,63)" /> - <polygon points="267,174 270,170 272,168 280,164 284,164 290,165 295,170 298,174 300,178 299,179 290,185 287,186 277,186 275,185 267,175" style="fill: rgb(252,253,253)" /> - <polygon points="302,245 302,237 303,234 306,229 307,228 308,228 310,229 312,230 303,247" style="fill: rgb(214,193,190)" /> - <polygon points="11,253 11,252 15,230 18,215 19,213 30,208 31,208 32,208 34,209 36,210 37,211 40,221 40,222 40,224 40,225 38,236 36,247 35,252 34,254 12,254 11,254" style="fill: rgb(86,72,72)" /> - <polygon points="54,303 66,293 71,289 74,288 75,292 76,296 78,307 78,315 77,319 76,320 66,315 54,305" style="fill: rgb(133,121,114)" /> - <polygon points="122,185 122,184 123,184 124,184 125,184 125,185 124,186 123,186 122,186" style="fill: rgb(86,72,72)" /> - <polygon points="88,166 89,154 102,78 105,69 116,58 117,57 119,55 122,53 139,44 145,41 148,40 149,40 150,40 149,46 105,270 104,270 100,262 92,227 88,193" style="fill: rgb(96,86,84)" /> - <polygon points="232,267 232,266 235,265 237,265 238,265 239,265 241,266 242,267 242,269 239,270 238,270 236,269" style="fill: rgb(38,38,44)" /> - <polygon points="65,178 66,177 67,177 68,177 71,178 72,179 72,182 71,182 66,182 65,181" style="fill: rgb(96,86,84)" /> - <polygon points="75,266 76,263 76,266 76,268 76,269 75,269" style="fill: rgb(172,166,165)" /> - <polygon points="264,107 265,107 266,107 267,108 268,109 268,111 266,111" style="fill: rgb(96,86,84)" /> - <polygon points="273,267 277,267 283,272 278,279 276,280 275,279 273,268" style="fill: rgb(119,107,108)" /> - <polygon points="298,91 300,89 302,87 304,85 303,93 299,92" style="fill: rgb(226,223,225)" /> - <polygon points="94,135 95,129 97,124 98,122 101,127 98,134 95,136" style="fill: rgb(110,102,99)" /> - <polygon points="277,399 278,399 279,399 280,399 281,399 283,399 284,399 285,399 286,399 287,399 288,399 282,399" style="fill: rgb(138,130,128)" /> - <polygon points="171,354 173,351 192,350 197,351 206,362 206,363 190,365 189,365 188,365 187,365 172,360" style="fill: rgb(35,34,40)" /> - <polygon points="76,191 77,191 78,193 77,206 76,195" style="fill: rgb(163,139,139)" /> - <polygon points="209,17 209,16 212,10 217,0 219,0 223,0 224,0 229,4 234,8 235,11 234,14 229,27 223,27 210,19" style="fill: rgb(240,239,240)" /> - <polygon points="389,298 391,289 395,279 399,272 399,273 399,274 397,283 390,297" style="fill: rgb(217,200,201)" /> - <polygon points="211,58 213,55 214,56 214,58 214,64 212,64 211,64" style="fill: rgb(133,121,114)" /> - <polygon points="169,2 170,1 177,4 176,5 175,5" style="fill: rgb(167,158,154)" /> - <polygon points="131,399 132,399 133,399 134,399 135,399 152,399 153,399 154,399 155,399 156,399 157,399 158,399 159,399 144,399 145,399 146,399 147,399 148,399 149,399 150,399 151,399 200,399 201,399 202,399 192,399 193,399 194,399 195,399 196,399 197,399 198,399 199,399 168,399 169,399 170,399 171,399 172,399 173,399 174,399 175,399 160,399 161,399 162,399 163,399 164,399 165,399 166,399 167,399 184,399 185,399 186,399 187,399 188,399 189,399 190,399 191,399 176,399 177,399 178,399 179,399 180,399 181,399 182,399 183,399 136,399 137,399 138,399 139,399 140,399 141,399 142,399 143,399" style="fill: rgb(86,72,72)" /> - <polygon points="167,196 169,191 172,192 181,196 182,197 183,199 183,202 177,203 169,201 168,199" style="fill: rgb(35,34,40)" /> - <polygon points="232,380 233,379 236,377 237,378 235,380" style="fill: rgb(167,158,154)" /> - <polygon points="61,185 61,184 62,183 67,187 68,189 68,190 66,200 65,203 64,205 61,194" style="fill: rgb(53,44,47)" /> - <polygon points="86,184 88,178 90,177 91,182 91,185 91,187" style="fill: rgb(122,110,114)" /> - <polygon points="298,221 301,220 301,223 300,224 299,224 298,222" style="fill: rgb(171,148,150)" /> - <polygon points="312,95 314,93 316,91 318,89 320,87 313,95" style="fill: rgb(119,107,108)" /> - <polygon points="93,237 93,236 93,230 96,228 97,231 97,232 97,233" style="fill: rgb(119,107,108)" /> - <polygon points="86,106 86,105 87,102 90,101 91,101 92,102 93,117 93,118 91,122 90,123 89,123 88,122 86,110" style="fill: rgb(154,134,136)" /> - <polygon points="162,145 163,140 165,142 165,143 164,144" style="fill: rgb(75,63,63)" /> - <polygon points="371,324 371,323 371,322 371,321 372,319 373,319 374,319 373,322 372,324" style="fill: rgb(235,221,221)" /> - <polygon points="62,360 62,359 62,358 62,357 62,356 63,356 66,356 65,357 64,358" style="fill: rgb(252,253,253)" /> - <polygon points="159,196 161,192 165,190 177,209 175,211 174,211 164,208" style="fill: rgb(45,44,50)" /> - <polygon points="263,339 290,284 312,277 342,268 349,266 350,266 351,267 352,268 367,294 367,295 361,308 352,325 328,370 313,398 302,399 295,399 283,391 277,387 276,386 274,380 268,360 266,353 263,342" style="fill: rgb(214,193,190)" /> - <polygon points="167,202 215,201 223,201 224,201 225,201 226,202 226,206 225,208 223,209 213,211 203,211 179,210 170,206" style="fill: rgb(45,44,50)" /> - <polygon points="373,215 375,216 389,223 391,224 392,225 384,221 374,216" style="fill: rgb(234,254,253)" /> - <polygon points="288,274 289,273 290,274 290,276 289,278 288,278" style="fill: rgb(154,145,148)" /> - <polygon points="84,110 85,105 86,103 86,104 85,112" style="fill: rgb(154,134,136)" /> - <polygon points="178,173 184,166 185,167 187,171 189,177 189,178 181,177 178,174" style="fill: rgb(133,121,114)" /> - <polygon points="78,344 79,340 79,347 78,346 78,345" style="fill: rgb(144,128,130)" /> - <polygon points="175,170 175,169 180,155 182,152 199,135 201,133 207,130 209,130 273,157 274,162 274,163 259,171 251,173 249,173 248,173 247,173 176,171" style="fill: rgb(110,102,99)" /> - <polygon points="287,203 288,200 289,201 290,202 289,207 288,207 287,204" style="fill: rgb(196,174,171)" /> - <polygon points="212,22 213,22 214,22 217,23 220,25 221,26 223,28 222,28 219,27" style="fill: rgb(210,206,208)" /> - <polygon points="102,302 102,298 104,293 105,294 106,299 103,302" style="fill: rgb(119,107,108)" /> - <polygon points="315,96 317,94 321,90 323,88 316,95 318,93 320,91 322,89 324,87 319,92" style="fill: rgb(149,142,141)" /> - <polygon points="292,55 292,50 301,55 311,62 312,63 312,64 309,63 303,61" style="fill: rgb(214,193,190)" /> - <polygon points="57,41 57,40 78,28 81,27 83,35 83,38 75,42 71,44 67,46 60,49 59,49" style="fill: rgb(133,121,114)" /> - <polygon points="275,155 284,156 286,157 287,158 286,159 285,160 278,160" style="fill: rgb(96,86,84)" /> - <polygon points="191,206 191,205 193,204 194,204 199,205 206,207 194,207" style="fill: rgb(59,49,50)" /> - <polygon points="266,294 266,265 266,264 268,261 270,260 271,260 275,263 282,276 278,297 277,300 269,309 268,309 267,306 266,296" style="fill: rgb(96,86,84)" /> - <polygon points="282,299 283,298 283,299 283,300 283,301 283,302 283,303 282,303" style="fill: rgb(154,134,136)" /> - <polygon points="192,43 192,41 194,34 197,34 202,36 205,45 205,49 203,54 202,54 199,52 192,44" style="fill: rgb(119,107,108)" /> - <polygon points="96,302 97,297 98,296 106,302 107,303 107,304 101,314 100,315 99,316 98,315 97,310" style="fill: rgb(119,107,108)" /> - <polygon points="308,94 309,92 316,85 317,86 314,89 310,93" style="fill: rgb(225,233,236)" /> - <polygon points="300,157 301,153 301,157 301,158 300,160" style="fill: rgb(172,166,165)" /> - <polygon points="32,368 33,362 34,363 34,364 34,365 34,366 34,367 33,375 32,375" style="fill: rgb(240,239,240)" /> - <polygon points="355,334 357,329 358,327 381,283 383,284 383,287 380,300 373,325 370,329 365,335 363,337 361,337" style="fill: rgb(224,208,205)" /> - <polygon points="309,291 309,290 309,289 309,288 309,287 310,287 311,287 312,287 313,287 314,287 315,287 318,288 320,289 342,301 351,306 358,310 359,311 358,313 357,315 353,322 352,323 350,322 343,318 321,305 315,301 311,298 310,296 309,293" style="fill: rgb(214,193,190)" /> - <polygon points="96,335 101,338 103,341 103,343 100,341 98,339" style="fill: rgb(119,107,108)" /> - <polygon points="114,351 115,344 116,343 118,341 120,341 121,342 118,349 117,351 116,351" style="fill: rgb(75,63,63)" /> - <polygon points="389,386 390,383 391,386 392,389 392,390 392,391 389,387" style="fill: rgb(214,193,190)" /> - <polygon points="78,138 79,130 80,134 79,137 78,140" style="fill: rgb(167,158,154)" /> - <polygon points="275,257 275,256 276,252 280,258 280,259 280,260 280,262 276,259 275,258" style="fill: rgb(110,102,99)" /> - <polygon points="304,249 305,250 306,252 310,266 310,267 309,267 304,250" style="fill: rgb(202,194,191)" /> - <polygon points="196,158 197,156 201,154 202,154 203,154 203,155 201,157" style="fill: rgb(122,110,114)" /> - <polygon points="34,354 35,355 35,356 35,357 35,358 34,362" style="fill: rgb(240,239,240)" /> - <polygon points="328,385 331,382 333,380 332,383 331,384 330,385 328,386" style="fill: rgb(217,200,201)" /> - <polygon points="270,190 270,189 271,190 272,191 273,192 273,193 273,194 272,194" style="fill: rgb(247,247,247)" /> - <polygon points="78,26 80,26 81,30 79,30 78,27" style="fill: rgb(217,200,201)" /> - <polygon points="208,212 217,200 219,199 223,199 228,199 232,201 234,203 235,205 235,206 234,207 222,214 217,215 209,213" style="fill: rgb(45,44,50)" /> - <polygon points="49,294 49,291 51,293 52,296 51,296 50,296 49,295" style="fill: rgb(119,107,108)" /> - <polygon points="14,219 15,215 16,214 16,215 16,216 16,217 15,223" style="fill: rgb(207,194,195)" /> - <polygon points="200,300 207,290 209,290 211,290 212,291 212,292 211,295 209,300 205,301" style="fill: rgb(53,44,47)" /> - <polygon points="337,250 338,250 340,250 341,250 338,254" style="fill: rgb(154,145,148)" /> - <polygon points="98,78 100,75 101,74 102,73 104,71 105,71 105,83 104,88 102,91 101,92 98,81" style="fill: rgb(119,107,108)" /> - <polygon points="61,206 61,205 61,204 61,203 61,202 62,205 62,206 62,212 61,214 61,205 61,204 61,203 61,202 62,205 62,206 62,212" style="fill: rgb(75,63,63)" /> - <polygon points="80,167 80,166 82,157 83,158 84,164 83,165" style="fill: rgb(144,128,130)" /> - <polygon points="79,163 79,161 81,160 81,163 81,164 80,165" style="fill: rgb(154,134,136)" /> - <polygon points="115,329 115,328 123,322 126,321 128,323 124,327 119,329 116,330" style="fill: rgb(96,86,84)" /> - <polygon points="306,223 306,220 307,217 310,216 323,222 326,224 323,233 321,232 308,225" style="fill: rgb(217,200,201)" /> - <polygon points="248,388 249,388 251,389 254,391 256,393 255,393 252,391" style="fill: rgb(163,139,139)" /> - <polygon points="77,145 80,125 81,120 82,116 84,116 85,131 85,133 84,144 82,149 79,149 78,149" style="fill: rgb(163,139,139)" /> - <polygon points="126,49 128,47 129,46 136,42 145,38 150,37 151,37 152,38 130,49" style="fill: rgb(133,121,114)" /> - <polygon points="304,242 306,248 309,257 309,258 309,260 308,258 306,251 304,244" style="fill: rgb(214,193,190)" /> - <polygon points="239,8 242,1 246,0 247,0 248,0 249,0 308,45 322,56 322,57 299,52 296,50 290,46 255,21 247,15 240,9" style="fill: rgb(225,233,236)" /> - <polygon points="293,31 296,32 301,36 312,45 313,47 296,34" style="fill: rgb(169,179,170)" /> - <polygon points="87,183 87,179 87,178 88,177 89,177 90,182 89,183 88,183" style="fill: rgb(122,110,114)" /> - <polygon points="43,303 47,306 47,309 47,310 46,309" style="fill: rgb(219,220,224)" /> - <polygon points="35,324 40,310 45,312 46,313 46,317 46,319 44,331 43,331 42,331" style="fill: rgb(240,253,253)" /> - <polygon points="298,183 301,180 302,180 303,180 300,184 298,185" style="fill: rgb(247,247,247)" /> - <polygon points="9,384 10,383 11,383 25,391 26,392 23,392 19,391" style="fill: rgb(252,253,253)" /> - <polygon points="272,367 274,368 288,377 291,379 292,380 290,379 288,378 276,371 273,369 272,368" style="fill: rgb(167,158,154)" /> - <polygon points="3,365 4,362 10,364 10,366 9,368 8,368 4,366" style="fill: rgb(248,247,245)" /> - <polygon points="388,382 390,382 391,382 391,389 391,390 390,389" style="fill: rgb(196,174,171)" /> - <polygon points="234,335 234,333 240,330 240,331 237,337 234,336 234,333 240,330 240,331 237,337 234,336 234,333 240,330 240,331 237,337 234,336" style="fill: rgb(86,72,72)" /> - <polygon points="114,352 115,352 116,352 117,352 118,352 121,356 121,357 120,357 116,355 115,354 114,353" style="fill: rgb(86,72,72)" /> - <polygon points="110,193 112,188 117,187 118,187 120,188 121,189 121,191 113,193 112,193" style="fill: rgb(96,86,84)" /> - <polygon points="209,267 210,266 213,265 214,265 215,266 214,269" style="fill: rgb(253,250,250)" /> - <polygon points="259,278 262,277 262,278 262,279 262,280 262,281 262,282 262,283 261,284" style="fill: rgb(110,102,99)" /> - <polygon points="75,326 76,326 77,327 76,330 75,330 75,329" style="fill: rgb(252,253,253)" /> - <polygon points="246,194 247,194 249,194 252,195 253,196 255,199 255,201 254,201 253,201 251,200" style="fill: rgb(110,102,99)" /> - <polygon points="172,261 173,261 174,261 175,261 188,263 188,268 188,269 187,269 185,269 184,269 178,269 172,262" style="fill: rgb(96,86,84)" /> - <polygon points="230,372 232,367 233,365 234,363 237,364 238,366 235,372 233,373 231,373" style="fill: rgb(96,86,84)" /> - <polygon points="80,289 81,284 83,280 87,273 89,275 91,278 86,296 84,299 82,294" style="fill: rgb(144,128,130)" /> - <polygon points="82,20 82,19 83,20 86,25 88,31 86,31 85,30" style="fill: rgb(217,200,201)" /> - <polygon points="265,154 266,151 271,149 271,150 271,151 271,153 266,155" style="fill: rgb(86,72,72)" /> - <polygon points="80,316 82,312 83,316 83,318 80,322" style="fill: rgb(138,130,128)" /> - <polygon points="180,366 184,364 184,368 183,368 182,368" style="fill: rgb(45,44,50)" /> - <polygon points="1,112 1,110 1,108 2,108 2,113 1,113" style="fill: rgb(133,121,114)" /> - <polygon points="69,277 73,272 73,274 73,278 73,280 73,282 72,282" style="fill: rgb(133,121,114)" /> - <polygon points="115,23 125,18 127,17 134,14 137,15 139,16 116,24" style="fill: rgb(196,174,171)" /> - <polygon points="298,199 299,196 302,194 305,201 305,215 305,218 305,219 305,220 305,221 303,221 298,200" style="fill: rgb(172,166,165)" /> - <polygon points="293,137 293,135 294,135 296,137 295,138 294,138" style="fill: rgb(154,145,148)" /> - <polygon points="20,308 20,307 20,306 20,300 21,291 23,291 23,293 23,294 21,306 20,309 20,306 20,300 21,291 23,291 23,293 23,294 21,306 20,309 20,306 20,300 21,291 23,291 23,293 23,294 21,306 20,309 20,306 20,300 21,291 23,291 23,293 23,294 21,306 20,309 20,306" style="fill: rgb(248,247,245)" /> - <polygon points="209,166 209,159 209,158 210,158 211,158 213,159 220,163 222,166 236,189 236,190 235,190 231,189 222,185 211,178 210,176 209,167" style="fill: rgb(252,253,253)" /> - <polygon points="73,266 73,265 73,260 73,268 73,267 73,262 73,270 73,261 73,269 73,264 73,263" style="fill: rgb(133,121,114)" /> - <polygon points="152,134 165,127 178,121 179,122 179,123 178,129 177,131 168,135 165,136 164,136" style="fill: rgb(64,55,56)" /> - <polygon points="288,141 288,140 290,141 291,142 288,146" style="fill: rgb(122,110,114)" /> - <polygon points="399,376 399,363 399,372 399,373 399,374 399,375 399,368 399,369 399,370 399,371 399,364 399,365 399,366 399,367" style="fill: rgb(167,158,154)" /> - <polygon points="286,91 288,87 289,85 290,87 288,90" style="fill: rgb(248,247,245)" /> - <polygon points="236,11 243,16 245,18 243,17 241,16 237,13" style="fill: rgb(219,220,224)" /> - <polygon points="223,332 223,330 234,326 237,326 238,327 238,329 237,330 223,334" style="fill: rgb(75,63,63)" /> - <polygon points="52,79 53,79 62,84 63,85 61,84 53,80" style="fill: rgb(171,148,150)" /> - <polygon points="61,262 71,262 72,266 72,268 71,268 67,267 62,263" style="fill: rgb(122,110,114)" /> - <polygon points="393,238 394,236 395,237 399,242 398,242 394,239" style="fill: rgb(247,247,247)" /> - <polygon points="80,356 80,348 82,349 83,351 82,353" style="fill: rgb(122,110,114)" /> - <polygon points="394,306 397,302 398,301 399,301 399,302 399,303 399,304 399,305 396,309 395,309 394,307" style="fill: rgb(235,221,221)" /> - <polygon points="60,163 60,162 60,161 60,160 61,162 63,169 64,173 64,174 63,173 62,170" style="fill: rgb(133,121,114)" /> - <polygon points="183,24 184,23 190,22 192,22 193,22 190,23" style="fill: rgb(231,214,217)" /> - <polygon points="4,186 6,185 7,185 10,185 10,186 10,190 4,187" style="fill: rgb(110,102,99)" /> - <polygon points="296,174 296,171 297,171 299,174 299,175 296,178 296,171 297,171 299,174 299,175 296,178 296,171 297,171 299,174 299,175" style="fill: rgb(252,251,252)" /> - <polygon points="136,361 137,344 147,330 155,325 177,326 192,330 212,345 218,355 224,366 224,367 221,372 217,375 211,377 210,377 199,377 178,377 169,377 160,374 142,367 136,362" style="fill: rgb(35,34,40)" /> - <polygon points="289,145 289,144 290,143 291,143 291,144 290,148 289,147 289,144 290,143 291,143" style="fill: rgb(110,102,99)" /> - <polygon points="382,398 382,397 382,396 382,395 386,398 387,399 385,399" style="fill: rgb(133,121,114)" /> - <polygon points="374,272 375,270 378,266 381,264 387,260 388,262 388,263 386,269 384,273 382,277 381,277 380,277 375,273" style="fill: rgb(235,221,221)" /> - <polygon points="399,285 399,286 399,279 399,287 399,280 399,288 399,289 399,281 399,290 399,282 399,283 399,284" style="fill: rgb(235,221,221)" /> - <polygon points="161,169 163,166 171,160 173,161 177,164 173,170 168,172 167,172 164,171" style="fill: rgb(96,86,84)" /> - <polygon points="123,136 123,135 125,133 126,132 132,131 136,131 137,132 135,133 133,134 128,136 127,136 126,136 124,136" style="fill: rgb(96,86,84)" /> - <polygon points="102,148 103,144 115,102 117,99 123,95 125,94 132,92 136,91 145,89 157,87 161,87 162,87 211,93 247,103 259,107 267,113 268,116 272,157 238,254 211,279 131,320 129,321 125,318 124,316 121,305 107,250 102,149" style="fill: rgb(86,72,72)" /> - <polygon points="153,41 153,38 155,37 158,36 159,36 160,36 160,37 159,40 156,41 155,41 154,41" style="fill: rgb(122,110,114)" /> - <polygon points="210,398 210,395 211,392 215,382 229,366 233,366 234,373 232,377 222,393 220,396 218,398 217,398 216,398 215,398 214,398 213,398 212,398 211,398" style="fill: rgb(86,72,72)" /> - <polygon points="133,261 135,259 136,264 135,265 134,265 133,264" style="fill: rgb(53,44,47)" /> - <polygon points="83,248 84,247 85,248 85,249 85,251 85,253 84,255" style="fill: rgb(154,145,148)" /> - <polygon points="114,139 115,138 117,137 119,137 120,137 120,138 116,140" style="fill: rgb(75,63,63)" /> - <polygon points="60,297 60,291 61,291 62,291 65,292 65,297 64,297 62,297 61,297" style="fill: rgb(119,107,108)" /> - <polygon points="260,130 261,128 262,127 263,127 263,128 263,129 263,130 263,131 261,131" style="fill: rgb(110,102,99)" /> - <polygon points="181,171 181,169 181,168 186,163 183,169" style="fill: rgb(96,86,84)" /> - <polygon points="296,93 297,91 301,92 302,93 302,98 302,99 299,101 298,100" style="fill: rgb(226,226,230)" /> - <polygon points="226,226 228,223 233,221 232,223 228,226 227,226" style="fill: rgb(110,102,99)" /> - <polygon points="384,335 386,330 388,328 387,331 386,333" style="fill: rgb(214,193,190)" /> - <polygon points="246,179 247,178 248,178 249,178 252,180 252,181 252,182 247,182" style="fill: rgb(252,253,253)" /> - <polygon points="80,1 81,3 83,9 83,10 83,12 80,5" style="fill: rgb(202,194,191)" /> - <polygon points="244,239 245,239 246,239 247,239 250,242 247,242" style="fill: rgb(231,214,217)" /> - <polygon points="80,306 81,304 86,300 87,301 87,306 87,307 87,310 86,310 85,310 83,309 80,307" style="fill: rgb(154,134,136)" /> - <polygon points="248,87 250,88 252,89 252,91 252,92 249,91" style="fill: rgb(240,239,240)" /> - <polygon points="87,169 88,168 89,170 89,171 89,173 88,175" style="fill: rgb(122,110,114)" /> - <polygon points="293,148 295,146 297,148 296,150 294,151" style="fill: rgb(154,134,136)" /> - <polygon points="223,342 223,341 224,340 227,342 227,345 225,345" style="fill: rgb(45,44,50)" /> - <polygon points="285,238 286,234 287,234 288,236 288,240 287,241 286,240 285,239" style="fill: rgb(163,139,139)" /> - <polygon points="178,346 179,345 181,344 181,347 179,347" style="fill: rgb(35,34,40)" /> - <polygon points="281,238 282,238 288,241 288,242 287,243 282,240" style="fill: rgb(163,139,139)" /> - <polygon points="161,196 161,195 162,193 165,191 168,190 169,190 170,190 171,190 172,190 173,190 174,190 176,191 179,193 185,200 185,203 184,206 182,207 173,205 170,204 164,200 161,197" style="fill: rgb(35,34,40)" /> - <polygon points="267,248 269,247 272,249 270,252 269,253" style="fill: rgb(119,107,108)" /> - <polygon points="168,33 172,33 174,34 171,35 169,35 168,35" style="fill: rgb(138,130,128)" /> - <polygon points="1,4 1,3 1,1 4,1 5,1 6,1 7,1 8,1 9,1 10,1 11,1 12,1 13,1 14,4 2,35 1,34" style="fill: rgb(110,102,99)" /> - <polygon points="138,258 139,257 140,256 143,255 144,255 146,256 148,259 147,260 144,261 140,262 139,262 138,262" style="fill: rgb(35,34,40)" /> - <polygon points="233,344 233,342 234,342 235,342 236,342 237,342 238,344 238,345 238,349 238,350 237,352 235,351" style="fill: rgb(96,86,84)" /> - <polygon points="261,274 267,270 268,273 266,276 264,276 261,275" style="fill: rgb(96,86,84)" /> - <polygon points="200,238 200,236 200,234 203,234 209,235 208,236 206,237" style="fill: rgb(110,102,99)" /> - <polygon points="118,358 119,358 124,361 127,363 126,363 124,362 122,361 119,359" style="fill: rgb(59,49,50)" /> - <polygon points="196,61 196,60 197,59 202,60 198,62" style="fill: rgb(138,130,128)" /> - <polygon points="121,136 122,135 123,134 124,134 126,137 122,137 121,137" style="fill: rgb(86,72,72)" /> - <polygon points="352,265 358,249 359,248 360,247 364,245 372,248 390,257 391,258 392,259 382,283 368,275 354,267 353,266" style="fill: rgb(231,214,217)" /> - <polygon points="65,194 66,192 68,191 68,192 68,193 68,194 67,197 66,196" style="fill: rgb(53,44,47)" /> - <polygon points="239,152 239,151 240,149 242,150 242,153 241,153 240,153" style="fill: rgb(96,86,84)" /> - <polygon points="269,143 271,143 275,146 278,149 279,150 280,152 280,153 280,154 280,155 279,155 276,153 269,144" style="fill: rgb(110,102,99)" /> - <polygon points="80,342 81,337 82,340 83,344 83,345 83,346 80,347" style="fill: rgb(133,121,114)" /> - <polygon points="26,323 26,319 26,318 26,315 26,314 30,299 32,300 37,304 44,310 45,311 39,327 36,327 34,327 32,327 28,325 27,324" style="fill: rgb(234,254,253)" /> - <polygon points="134,136 141,134 142,134 143,134 151,136 153,137 155,138 151,139 144,140 136,139 134,137" style="fill: rgb(45,44,50)" /> - <polygon points="384,220 385,220 399,224 399,226 399,227 398,227 395,226 393,225" style="fill: rgb(225,233,236)" /> - <polygon points="200,57 201,55 202,55 209,57 209,58 205,58" style="fill: rgb(154,134,136)" /> - <polygon points="31,292 33,290 39,288 38,291 36,293 34,294" style="fill: rgb(133,121,114)" /> - <polygon points="240,355 240,353 241,352 242,352 244,353 244,357 242,359" style="fill: rgb(96,86,84)" /> - <polygon points="264,263 267,260 270,263 271,264 265,264" style="fill: rgb(119,107,108)" /> - <polygon points="2,88 3,79 4,77 10,71 23,61 24,61 30,64 31,65 32,66 53,134 55,141 57,148 59,155 62,171 62,173 62,175 57,190 55,190 54,190 44,185 32,168 15,131 13,126" style="fill: rgb(154,134,136)" /> - <polygon points="274,56 280,62 283,66 283,67 282,67 274,57" style="fill: rgb(252,253,253)" /> - <polygon points="79,207 80,183 81,166 87,100 92,87 94,83 95,82 98,83 99,92 99,94 98,118 87,218 85,218 80,209" style="fill: rgb(133,121,114)" /> - <polygon points="151,196 156,190 160,187 165,184 167,183 172,181 188,180 234,197 241,201 242,203 242,206 242,209 240,213 239,214 235,218 151,201" style="fill: rgb(75,63,63)" /> - <polygon points="207,353 207,350 207,343 207,341 208,340 209,340 216,342 218,347 217,354 216,355 215,355 214,355 209,355 207,354" style="fill: rgb(45,44,50)" /> - <polygon points="192,261 199,261 199,262 193,262" style="fill: rgb(75,63,63)" /> - <polygon points="134,267 136,265 137,264 141,263 146,262 147,262 147,263 134,268" style="fill: rgb(59,49,50)" /> - <polygon points="375,319 376,317 379,312 381,309 382,308 383,307 382,309 381,311 379,315 376,319" style="fill: rgb(219,220,224)" /> - <polygon points="306,268 308,269 310,276 307,279" style="fill: rgb(110,102,99)" /> - <polygon points="64,369 66,366 67,366 67,367 66,373 65,373" style="fill: rgb(252,251,252)" /> - <polygon points="178,29 180,28 187,27 188,27 189,27 193,27 194,27 195,27 197,28 198,29 197,29 196,29 190,29" style="fill: rgb(172,166,165)" /> - <polygon points="207,32 207,31 208,30 214,31 215,32 222,39 221,42 218,44 217,44 215,42" style="fill: rgb(154,145,148)" /> - <polygon points="75,170 76,170 79,172 79,174 79,175 79,176 79,177 79,178 78,186 77,187" style="fill: rgb(163,139,139)" /> - <polygon points="237,221 237,220 238,218 239,218 241,220 241,222" style="fill: rgb(252,251,252)" /> - <polygon points="368,227 368,226 372,224 373,224 374,226 371,232" style="fill: rgb(247,247,247)" /> - <polygon points="288,51 290,50 291,50 302,58 305,61 302,63 291,59 290,58" style="fill: rgb(224,208,205)" /> - <polygon points="37,73 38,73 40,74 59,84 74,92 85,98 86,99 81,117 80,119 79,119 68,113 45,100 44,99 40,85" style="fill: rgb(196,174,171)" /> - <polygon points="183,62 187,55 190,50 192,47 195,50 197,54 193,63 192,64 189,66 188,66 185,65" style="fill: rgb(122,110,114)" /> - <polygon points="0,306 4,292 6,287 14,291 15,294 15,299 14,304 11,313 6,310" style="fill: rgb(245,254,253)" /> - <polygon points="16,196 19,194 21,194 21,196 20,197 18,198 17,198 16,198" style="fill: rgb(96,86,84)" /> - <polygon points="226,263 239,262 243,267 243,270 242,270 241,270 231,267 226,264" style="fill: rgb(53,44,47)" /> - <polygon points="57,258 60,258 61,258 63,259 61,259 60,259 59,259 58,259" style="fill: rgb(119,107,108)" /> - <polygon points="383,326 383,325 383,324 388,318 390,319 390,320 390,321 389,323 383,327" style="fill: rgb(231,214,217)" /> - <polygon points="28,296 28,294 29,293 33,296 34,297 29,297" style="fill: rgb(225,233,236)" /> - <polygon points="92,316 92,315 92,314 92,312 92,311 93,311 96,313 97,314 99,317 97,325 96,325 95,324 94,323 92,318" style="fill: rgb(119,107,108)" /> - <polygon points="119,135 120,134 123,132 126,130 130,128 132,127 133,128 121,135" style="fill: rgb(75,63,63)" /> - <polygon points="312,381 313,378 318,380 321,382 318,387 314,388" style="fill: rgb(214,193,190)" /> - <polygon points="156,31 161,29 168,27 172,26 181,25 183,26 180,27 173,29 159,31" style="fill: rgb(202,194,191)" /> - <polygon points="87,35 103,1 104,1 105,2 106,4 108,11 111,22 111,23 109,25 103,28 101,29 91,34 88,35" style="fill: rgb(144,128,130)" /> - <polygon points="213,368 213,367 213,366 214,365 218,363 221,364 219,370 214,371 213,371" style="fill: rgb(35,34,40)" /> - <polygon points="375,315 376,313 380,307 382,304 384,301 385,302 377,313" style="fill: rgb(219,210,214)" /> - <polygon points="186,227 187,226 188,226 192,227 192,229 191,229" style="fill: rgb(96,86,84)" /> - <polygon points="65,255 71,253 72,260 72,262 72,264 72,265 71,265 70,265 69,265 67,261" style="fill: rgb(119,107,108)" /> - <polygon points="140,370 142,369 143,369 146,371 145,372" style="fill: rgb(53,44,47)" /> - <polygon points="68,283 69,279 70,279 71,280 71,281 70,283" style="fill: rgb(122,110,114)" /> - <polygon points="304,130 311,117 311,118 311,119 309,123 307,127 306,129 305,130 304,131" style="fill: rgb(205,205,210)" /> - <polygon points="94,289 97,287 98,287 98,288 98,289 97,291" style="fill: rgb(122,110,114)" /> - <polygon points="225,336 226,332 229,330 231,333 229,336" style="fill: rgb(64,55,56)" /> - <polygon points="34,237 35,236 36,235 37,238 37,239 37,240 36,246 34,241" style="fill: rgb(86,72,72)" /> - <polygon points="127,334 127,333 128,331 132,333 132,334 130,335 128,336" style="fill: rgb(64,55,56)" /> - <polygon points="224,143 227,138 229,137 231,136 235,135 236,135 268,156 265,157 256,158 255,158 254,158 253,158 233,156 231,155 230,154 228,152 227,151 226,150" style="fill: rgb(86,72,72)" /> -</svg> diff --git a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/gunit/test_006.svg b/svg/src/test/resources/com/itextpdf/svg/renderers/impl/gunit/test_006.svg deleted file mode 100644 index 3abe147056..0000000000 --- a/svg/src/test/resources/com/itextpdf/svg/renderers/impl/gunit/test_006.svg +++ /dev/null @@ -1,1328 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<svg xmlns="http://www.w3.org/2000/svg" width="300" height="300" version="1.1" baseprofile="full"> - <polygon points="0,0 65,0 73,0 81,0 89,0 97,0 105,0 113,0 121,0 130,0 146,0 162,0 178,0 194,0 210,0 226,0 242,0 260,0 292,0 293,0 294,0 295,0 296,0 297,0 298,0 299,0 299,143 299,175 299,207 299,239 299,255 299,256 299,269 299,270 299,271 299,272 0,241" style="fill: rgb(239,244,248)" /> - <polygon points="115,217 115,216 115,215 116,212 117,210 118,209 119,208 120,207 121,206 123,205 125,204 128,203 136,203 137,203 138,203 139,203 140,203 143,204 145,205 147,206 150,208 151,209 152,211 153,213 153,214 153,215 153,216 153,217 153,218 151,219 121,225 120,224 119,223 118,222 117,221" style="fill: rgb(178,201,219)" /> - <polygon points="150,276 150,275 150,274 151,270 152,267 155,262 159,258 164,253 165,252 171,247 217,220 218,220 284,258 290,262 294,266 295,267 297,270 298,273 299,277 299,281 299,285 299,289 299,290 299,291 294,299 290,299 273,299 257,299 156,299 150,283" style="fill: rgb(119,114,120)" /> - <polygon points="76,207 76,206 77,204 78,202 80,202 83,204 84,206 84,207 77,207 76,206 77,204 78,202 80,202 83,204 84,206 84,207 77,207 76,206 77,204 78,202 80,202 83,204 84,206 84,207 77,207 76,206 77,204 78,202 80,202" style="fill: rgb(238,179,181)" /> - <polygon points="112,236 112,235 112,234 112,233 112,232 117,231 179,223 215,220 216,220 215,223 214,225 175,297 174,298 155,299 154,299 152,299 148,299 147,299 146,299 145,299 144,299 138,299 136,299 135,299" style="fill: rgb(65,77,99)" /> - <polygon points="53,254 53,253 56,250 57,250 58,250 78,297 78,298 76,299 75,299 74,299 73,299 72,299 71,299 70,299 69,299 68,299 67,298 62,291 59,284 57,279 56,276 53,264" style="fill: rgb(65,77,99)" /> - <polygon points="107,70 107,69 107,68 108,65 111,72 111,74 110,74 109,74 108,73 107,72 107,68 108,65 111,72 111,74 110,74 109,74 108,73 107,72 107,68 108,65 111,72" style="fill: rgb(119,88,86)" /> - <polygon points="57,249 58,248 96,225 100,223 119,225 121,226 124,228 125,229 145,263 145,264 145,265 144,285 142,296 134,299 129,299 128,299 78,299 77,299 64,281 61,276 58,258" style="fill: rgb(119,114,120)" /> - <polygon points="193,45 193,43 196,45 201,51 201,52 196,50 193,46 193,44 193,43 196,45 201,51 201,52 196,50 193,46 193,44 193,43 196,45 201,51 201,52 196,50" style="fill: rgb(58,47,51)" /> - <polygon points="195,286 195,282 198,281 206,283 211,286 214,288 221,294 222,297 222,298 221,299 220,299 219,299 217,299 216,299 215,299 214,299 202,298 199,295 195,289" style="fill: rgb(65,77,99)" /> - <polygon points="132,121 133,120 134,120 135,120 136,120 137,120 138,120 139,120 140,120 141,120 142,120 143,120 147,120 148,120 149,120 149,124 136,131 132,128" style="fill: rgb(213,149,150)" /> - <polygon points="27,242 27,241 30,237 31,236 41,230 43,229 45,228 47,230 49,232 50,233 53,237 53,238 53,239 48,245 44,249 38,253 35,250" style="fill: rgb(242,202,203)" /> - <polygon points="129,244 135,231 138,230 143,229 144,229 145,230 146,231 147,232 148,233 149,234 151,237 157,250 157,251 148,261 147,261 131,247 129,245" style="fill: rgb(119,114,120)" /> - <polygon points="24,285 24,283 25,281 40,261 53,251 54,251 67,299 55,299 54,299 53,299 52,299 51,299 50,299 49,299 48,299 36,296 26,288" style="fill: rgb(119,114,120)" /> - <polygon points="109,123 109,122 110,112 123,111 124,111 125,112 131,125 129,139 128,141 125,144 124,145 120,147 119,147 117,146 115,144 111,138 109,124" style="fill: rgb(230,174,177)" /> - <polygon points="104,297 104,296 113,283 114,282 117,280 121,279 126,280 127,281 121,295 116,299 113,299 108,299 107,299 106,299 105,299 104,299" style="fill: rgb(65,77,99)" /> - <polygon points="124,119 124,118 125,111 140,99 152,94 180,97 185,99 186,100 187,107 187,108 186,109 131,124 127,123 126,122 125,121 124,120" style="fill: rgb(226,165,164)" /> - <polygon points="107,115 107,114 107,113 108,114 108,115 108,119 108,123 108,124 107,118 107,114 107,113 108,114 108,115 108,119 108,123 108,124" style="fill: rgb(179,146,141)" /> - <polygon points="0,276 15,250 16,250 43,262 47,275 48,279 48,285 48,286 48,287 48,288 48,289 48,290 47,299 46,299 1,299 0,299" style="fill: rgb(65,77,99)" /> - <polygon points="59,243 59,242 62,237 65,234 68,231 70,230 73,229 77,228 77,229 76,231 71,238 70,239 66,242 61,245 60,245 59,244" style="fill: rgb(213,149,150)" /> - <polygon points="80,173 81,173 82,173 83,173 84,173 85,173 86,173 87,173 88,173 89,173 90,173 95,174 97,175 97,176 97,177 87,175" style="fill: rgb(226,165,164)" /> - <polygon points="199,125 199,121 199,117 199,113 199,124 199,120 199,116 199,112 199,123 199,119 199,115 199,111 199,122 199,118 199,114" style="fill: rgb(153,115,106)" /> - <polygon points="150,144 151,144 152,144 153,144 154,144 155,144 156,144 157,144 158,144 159,144 160,144 163,145 160,146 156,147 155,147" style="fill: rgb(214,116,115)" /> - <polygon points="176,153 176,152 179,96 191,86 192,87 193,90 196,103 196,107 196,109 196,110 195,125 190,149 189,150 183,154 180,155" style="fill: rgb(230,174,177)" /> - <polygon points="160,204 160,203 160,202 161,200 184,178 188,176 189,176 189,179 189,181 189,183 188,195 168,210 166,210 165,210 160,207" style="fill: rgb(232,184,182)" /> - <polygon points="167,125 168,122 173,116 176,114 177,114 182,119 183,122 183,123 183,124 183,125 175,136 174,137 171,134 169,131 167,126" style="fill: rgb(244,194,193)" /> - <polygon points="124,82 125,72 130,65 132,64 143,63 148,63 165,63 166,63 176,65 183,70 184,71 188,83 188,88 133,83" style="fill: rgb(237,189,185)" /> - <polygon points="112,144 112,143 112,142 112,141 112,140 112,139 112,138 113,139 118,147 118,148 117,149 114,151 113,151 112,145" style="fill: rgb(200,169,167)" /> - <polygon points="137,84 149,83 150,83 151,84 150,86 149,87 146,90 145,90 144,90 143,90 142,90 139,89 138,88 137,85" style="fill: rgb(242,202,203)" /> - <polygon points="72,239 73,237 89,214 91,214 94,215 96,216 97,217 98,218 99,219 100,221 99,222 92,227 76,237 74,238" style="fill: rgb(239,244,248)" /> - <polygon points="145,112 145,111 146,111 147,111 154,113 160,118 162,120 163,121 163,122 163,123 162,124 157,126 154,127 152,125" style="fill: rgb(213,149,150)" /> - <polygon points="170,123 173,122 178,122 179,123 182,129 179,136 178,136 177,136 176,136 174,135 173,134 172,133 171,131 170,127" style="fill: rgb(242,202,203)" /> - <polygon points="175,229 175,228 175,227 176,225 177,223 178,222 181,236 181,239 181,241 180,243 179,244 177,241 176,238 175,234" style="fill: rgb(119,114,120)" /> - <polygon points="0,243 1,242 9,237 18,232 19,232 16,247 14,256 13,260 12,263 10,266 8,269 7,270 3,273 0,275" style="fill: rgb(119,114,120)" /> - <polygon points="32,247 60,197 61,196 62,195 68,191 69,191 69,192 55,239 43,254 39,256 35,257 34,256 32,248" style="fill: rgb(234,196,195)" /> - <polygon points="166,120 172,111 174,110 175,110 176,110 188,114 189,116 189,117 189,118 188,130 187,137 168,124 166,122" style="fill: rgb(237,189,185)" /> - <polygon points="187,104 187,102 188,99 189,100 190,101 190,102 190,103 187,105 187,102 188,99 189,100 190,101 190,102" style="fill: rgb(227,181,184)" /> - <polygon points="17,290 20,287 21,286 24,291 25,294 26,297 25,299 24,299 23,299 22,299 20,299 18,298 17,292" style="fill: rgb(119,114,120)" /> - <polygon points="156,104 156,100 168,105 168,106 167,106 166,106 165,106 164,106 163,106 162,106 161,106 160,106 158,106" style="fill: rgb(214,116,115)" /> - <polygon points="165,158 165,157 169,132 170,133 173,136 174,149 174,150 172,155 171,156 169,158 167,160 166,161 165,159" style="fill: rgb(237,189,185)" /> - <polygon points="151,104 154,101 179,97 183,100 184,101 185,104 185,105 184,106 182,107 164,109 163,109 156,107 153,106" style="fill: rgb(213,149,150)" /> - <polygon points="57,227 58,220 59,217 60,215 62,212 63,211 74,214 74,216 74,217 72,219 71,220 63,226 58,228" style="fill: rgb(244,194,193)" /> - <polygon points="126,73 129,68 130,67 131,66 134,65 168,65 179,70 181,74 181,75 181,76 181,77 180,79 130,74" style="fill: rgb(244,194,193)" /> - <polygon points="80,189 81,189 82,189 83,189 84,189 97,194 99,195 101,197 101,198 98,198 87,194 81,190" style="fill: rgb(242,202,203)" /> - <polygon points="84,181 85,180 87,179 98,181 100,182 101,183 101,184 100,186 99,186 95,185 88,183 85,182" style="fill: rgb(242,202,203)" /> - <polygon points="97,230 98,226 101,223 102,224 108,232 109,237 109,242 105,240 103,238 101,236 100,235 97,231" style="fill: rgb(65,77,99)" /> - <polygon points="164,179 166,168 167,166 171,161 179,158 196,154 197,155 195,159 179,177 175,178 167,180 165,180" style="fill: rgb(179,146,141)" /> - <polygon points="166,60 167,60 168,60 169,60 170,60 171,60 172,60 173,60 174,60 175,60 176,60 177,60" style="fill: rgb(179,146,141)" /> - <polygon points="228,239 228,238 228,237 230,239 232,243 233,246 234,249 235,252 235,253 233,251 231,247 228,240" style="fill: rgb(65,77,99)" /> - <polygon points="52,221 52,219 53,218 55,217 57,219 59,223 59,224 59,225 58,226 55,228 54,227 52,224" style="fill: rgb(242,202,203)" /> - <polygon points="64,223 64,220 65,219 67,217 68,217 69,217 70,219 70,220 67,224 66,224 65,224 64,224" style="fill: rgb(242,202,203)" /> - <polygon points="203,55 203,54 205,53 206,55 209,62 210,67 210,74 210,79 209,80 205,76 204,72 203,56" style="fill: rgb(58,47,51)" /> - <polygon points="191,51 191,49 191,47 192,46 195,46 205,56 208,63 208,64 198,64 196,63 194,60 192,55" style="fill: rgb(34,28,28)" /> - <polygon points="146,145 147,145 148,145 149,145 150,145 151,145 152,145 153,145 154,145 156,145 155,146 154,147" style="fill: rgb(213,149,150)" /> - <polygon points="127,210 137,209 140,209 143,210 144,211 145,212 146,213 146,214 145,215 144,216 140,217 128,213" style="fill: rgb(200,169,167)" /> - <polygon points="167,82 169,63 173,62 181,64 185,68 186,70 191,87 191,88 191,89 191,90 191,91 190,91" style="fill: rgb(232,184,182)" /> - <polygon points="173,138 175,119 176,116 177,115 180,114 184,117 185,121 185,122 185,133 182,139 174,143 173,143" style="fill: rgb(234,196,195)" /> - <polygon points="118,127 119,126 121,124 125,126 128,131 128,132 128,133 126,136 125,137 121,134 120,133 118,128" style="fill: rgb(232,184,182)" /> - <polygon points="94,193 95,192 97,193 99,194 102,196 103,197 103,199 102,199 101,199 100,199 99,199" style="fill: rgb(244,194,193)" /> - <polygon points="165,178 165,177 166,170 171,165 179,164 181,164 187,166 186,167 185,168 181,171 166,178" style="fill: rgb(153,115,106)" /> - <polygon points="192,247 212,220 214,220 214,221 214,222 214,223 211,228 207,233 194,246 193,247 192,248" style="fill: rgb(22,39,69)" /> - <polygon points="110,46 110,45 111,44 116,40 119,40 120,40 121,40 122,40 122,41 112,47 110,47" style="fill: rgb(87,76,74)" /> - <polygon points="204,120 205,119 206,118 208,120 209,122 211,126 211,128 210,130 209,131 208,131 207,131" style="fill: rgb(214,116,115)" /> - <polygon points="152,224 156,219 179,197 180,197 188,203 188,204 188,208 170,222 157,231 156,231 155,231" style="fill: rgb(234,196,195)" /> - <polygon points="104,63 104,61 105,59 106,59 106,61 105,64 104,64 104,61 105,59 106,59 106,61" style="fill: rgb(179,146,141)" /> - <polygon points="136,52 144,46 145,47 146,48 146,49 146,53 146,54 145,55 140,55 137,54 136,53" style="fill: rgb(34,28,28)" /> - <polygon points="66,211 66,202 68,184 69,182 73,184 75,185 97,205 96,210 73,220 67,215 66,214" style="fill: rgb(238,179,181)" /> - <polygon points="134,143 140,140 150,139 152,139 153,139 157,140 160,141 144,144 143,144 142,144 141,144" style="fill: rgb(214,116,115)" /> - <polygon points="148,55 148,54 154,46 160,46 163,48 164,50 164,51 164,52 164,53 163,54 160,55" style="fill: rgb(34,28,28)" /> - <polygon points="188,239 188,228 188,225 189,224 193,224 193,225 193,231 193,234 193,235 191,237 190,238" style="fill: rgb(65,77,99)" /> - <polygon points="156,247 166,229 170,225 173,223 172,238 171,246 170,247 168,249 166,251 165,251 157,249" style="fill: rgb(179,146,141)" /> - <polygon points="177,39 182,41 182,43 182,44 179,41 179,40 182,41 182,43 182,44 179,41 179,40" style="fill: rgb(87,76,74)" /> - <polygon points="162,261 181,243 181,245 179,247 177,249 175,251 173,253 171,255 170,256 166,259 163,261" style="fill: rgb(22,39,69)" /> - <polygon points="170,112 170,110 170,109 173,110 171,114 170,114 170,109 173,110 171,114 170,114 170,109" style="fill: rgb(238,179,181)" /> - <polygon points="133,43 133,42 134,40 135,40 137,41 138,45 138,47 138,48 137,48 136,47 135,46" style="fill: rgb(58,47,51)" /> - <polygon points="135,82 139,81 146,80 157,79 158,79 159,79 165,79 168,80 166,81 153,83 136,84" style="fill: rgb(244,194,193)" /> - <polygon points="202,88 202,87 202,84 212,69 213,69 214,72 214,77 213,101 211,101 210,100 202,91" style="fill: rgb(87,76,74)" /> - <polygon points="128,79 129,78 130,78 131,78 132,78 133,78 134,78 135,78 136,78 137,79 136,79" style="fill: rgb(238,179,181)" /> - <polygon points="75,193 75,192 76,191 80,191 83,193 94,201 95,202 91,203 90,203 81,200 80,199" style="fill: rgb(226,165,164)" /> - <polygon points="84,168 85,168 86,168 87,168 92,168 93,168 94,168 95,168 89,169 88,169 87,169" style="fill: rgb(230,174,177)" /> - <polygon points="133,109 137,91 138,93 139,97 139,104 139,105 139,106 139,107 139,112 135,116 134,116" style="fill: rgb(213,149,150)" /> - <polygon points="284,299 285,290 286,285 289,275 290,275 291,278 292,283 292,290 291,296 290,298 289,299" style="fill: rgb(65,77,99)" /> - <polygon points="60,238 60,237 60,236 75,219 77,217 79,216 80,217 80,218 80,219 79,224 78,226" style="fill: rgb(226,165,164)" /> - <polygon points="124,42 124,41 125,40 129,41 132,42 134,45 134,46 131,47 130,47 125,45 124,44" style="fill: rgb(34,28,28)" /> - <polygon points="67,212 69,209 71,208 72,208 73,209 74,210 74,211 73,212 69,214 68,214 67,213" style="fill: rgb(230,174,177)" /> - <polygon points="161,85 162,85 163,85 164,85 165,85 166,85 167,85 168,85 169,85 170,85 171,85" style="fill: rgb(153,115,106)" /> - <polygon points="126,233 126,232 127,230 129,230 130,231 131,233 132,239 132,240 132,241 130,239 128,236" style="fill: rgb(22,39,69)" /> - <polygon points="188,55 189,55 190,55 191,56 191,57 191,58 191,59 191,60 191,61 188,56" style="fill: rgb(74,64,62)" /> - <polygon points="132,229 133,229 134,229 135,229 138,229 139,229 140,229 141,229 137,230 135,230" style="fill: rgb(178,201,219)" /> - <polygon points="155,239 162,230 163,229 164,228 162,234 161,236 160,237 159,238 156,240 155,240" style="fill: rgb(230,174,177)" /> - <polygon points="148,297 149,288 150,286 153,285 155,285 155,286 154,291 153,295 150,299 149,298" style="fill: rgb(119,114,120)" /> - <polygon points="177,110 188,104 189,104 190,104 192,107 192,108 191,120 190,122 188,123 186,124" style="fill: rgb(232,184,182)" /> - <polygon points="0,255 2,253 8,248 9,248 10,248 11,248 11,249 9,252 3,255 0,256" style="fill: rgb(179,146,141)" /> - <polygon points="115,78 117,75 127,69 127,79 126,80 123,82 119,83 118,83 116,81 115,79" style="fill: rgb(232,184,182)" /> - <polygon points="86,167 87,167 92,167 93,167 94,167 95,167 88,167 89,167 90,167 91,167" style="fill: rgb(242,202,203)" /> - <polygon points="179,196 180,195 182,194 183,194 187,195 188,196 191,204 191,206 189,208 188,207" style="fill: rgb(228,193,189)" /> - <polygon points="166,202 166,201 169,195 172,195 172,196 172,198 172,200 172,202 172,203 171,203" style="fill: rgb(227,181,184)" /> - <polygon points="89,189 96,191 98,192 100,193 104,196 105,197 105,199 103,201 102,201 90,190" style="fill: rgb(238,179,181)" /> - <polygon points="81,201 83,200 92,202 96,203 99,204 100,205 102,212 102,213 102,214 100,213" style="fill: rgb(230,174,177)" /> - <polygon points="118,43 119,42 123,42 128,44 128,45 128,46 125,48 123,47 120,45 119,44" style="fill: rgb(58,47,51)" /> - <polygon points="154,268 154,267 155,266 157,266 158,267 158,270 157,271 156,271 155,271 154,270" style="fill: rgb(178,201,219)" /> - <polygon points="173,212 173,211 174,210 175,209 178,208 180,209 181,212 179,214 174,217 173,217" style="fill: rgb(242,202,203)" /> - <polygon points="58,206 58,205 58,204 58,203 61,197 62,197 63,198 63,201 62,204 60,206" style="fill: rgb(242,202,203)" /> - <polygon points="121,129 122,127 126,126 129,127 129,128 129,129 127,133 125,134 124,133 123,132" style="fill: rgb(237,189,185)" /> - <polygon points="46,223 48,209 53,195 56,192 57,191 60,193 60,194 58,200 54,211 47,223" style="fill: rgb(228,193,189)" /> - <polygon points="106,209 106,208 107,209 108,210 112,215 116,223 116,224 116,225 115,225 114,225" style="fill: rgb(76,48,47)" /> - <polygon points="152,126 161,113 162,113 164,116 165,127 165,128 159,132 157,132 153,131 152,127" style="fill: rgb(226,165,164)" /> - <polygon points="162,191 163,187 165,184 182,176 182,177 179,185 176,192 174,193 168,194 163,192" style="fill: rgb(226,165,164)" /> - <polygon points="143,132 144,131 145,131 146,132 147,133 147,134 146,135 145,135 144,135 143,135" style="fill: rgb(232,184,182)" /> - <polygon points="114,46 115,45 116,45 124,55 124,56 123,56 119,55 115,52 114,49 114,48" style="fill: rgb(34,28,28)" /> - <polygon points="170,160 196,121 197,120 202,130 202,131 202,132 197,152 194,155 187,160 174,163" style="fill: rgb(210,158,160)" /> - <polygon points="161,127 164,118 166,115 170,115 171,115 169,134 168,134 164,132 163,131 162,129" style="fill: rgb(238,179,181)" /> - <polygon points="63,189 63,188 63,187 63,186 67,187 70,189 70,190 70,191 70,192 63,191" style="fill: rgb(244,194,193)" /> - <polygon points="200,108 200,107 202,92 206,83 208,84 209,87 211,93 211,105 210,107 201,116" style="fill: rgb(74,64,62)" /> - <polygon points="111,116 111,115 111,114 119,111 120,111 121,111 122,111 113,122 112,121 111,120" style="fill: rgb(226,165,164)" /> - <polygon points="129,204 130,204 131,204 132,204 135,204 143,205 145,206 148,208 148,209 147,209" style="fill: rgb(200,169,167)" /> - <polygon points="164,215 165,212 166,211 170,207 173,206 174,206 173,208 172,210 170,212 167,214" style="fill: rgb(228,193,189)" /> - <polygon points="141,108 142,106 147,101 148,101 148,105 148,106 146,108 144,109 142,109" style="fill: rgb(230,174,177)" /> - <polygon points="49,248 51,245 53,242 55,240 55,241 54,243 51,247 50,248 49,249" style="fill: rgb(227,181,184)" /> - <polygon points="150,41 156,39 158,39 159,40 160,42 159,43 158,43 156,43 155,43" style="fill: rgb(58,47,51)" /> - <polygon points="198,84 198,83 198,82 199,82 200,82 200,84 200,87 199,87 198,87" style="fill: rgb(58,47,51)" /> - <polygon points="157,244 157,241 165,228 169,225 170,241 170,242 167,249 166,249 157,246" style="fill: rgb(210,158,160)" /> - <polygon points="194,116 196,106 197,106 197,113 197,114 197,117 197,119 196,123 195,123" style="fill: rgb(226,165,164)" /> - <polygon points="143,95 144,95 145,95 146,95 148,96 149,97 148,98 144,97 143,96" style="fill: rgb(242,202,203)" /> - <polygon points="156,113 158,110 159,110 163,111 165,112 166,113 167,114 167,115 164,120" style="fill: rgb(230,174,177)" /> - <polygon points="175,204 175,203 175,202 176,200 177,199 180,199 180,200 180,201 177,204" style="fill: rgb(228,193,189)" /> - <polygon points="70,181 71,181 72,181 73,181 74,181 79,184 78,184 72,183 71,182" style="fill: rgb(226,165,164)" /> - <polygon points="176,59 177,59 178,59 182,60 185,61 189,68 191,72 193,82 193,84" style="fill: rgb(153,115,106)" /> - <polygon points="165,31 166,30 167,30 168,30 169,30 172,31 174,41 171,39 165,32" style="fill: rgb(87,76,74)" /> - <polygon points="104,50 108,45 108,47 108,49 108,50 107,51 106,51 105,51 104,51" style="fill: rgb(178,201,219)" /> - <polygon points="84,186 85,185 100,177 105,176 107,179 108,183 107,198 106,202 105,203" style="fill: rgb(226,165,164)" /> - <polygon points="152,137 153,132 159,126 162,126 163,127 168,136 169,139 162,139 155,138" style="fill: rgb(230,174,177)" /> - <polygon points="62,192 70,188 71,188 71,190 71,191 71,192 70,193 69,194 64,194" style="fill: rgb(237,189,185)" /> - <polygon points="174,204 176,205 176,206 174,208 174,203 176,205 176,206 174,208 174,203" style="fill: rgb(237,189,185)" /> - <polygon points="128,136 131,126 132,126 135,134 135,135 135,136 133,140 130,140 129,138" style="fill: rgb(226,165,164)" /> - <polygon points="134,138 136,134 139,129 140,133 139,138 138,139 137,140 135,141 134,141" style="fill: rgb(230,174,177)" /> - <polygon points="207,118 208,116 211,116 213,119 214,126 214,127 213,131 212,131 211,131" style="fill: rgb(226,165,164)" /> - <polygon points="127,97 128,97 129,97 130,97 131,97 132,97 131,99 130,99 129,99" style="fill: rgb(153,115,106)" /> - <polygon points="194,195 194,194 195,194 196,195 196,197 196,198 196,199 196,200 195,199" style="fill: rgb(200,169,167)" /> - <polygon points="184,150 192,126 196,125 196,127 193,145 192,149 190,152 186,155 184,152" style="fill: rgb(226,165,164)" /> - <polygon points="173,146 173,145 173,144 174,145 174,146 174,148 173,148 173,144 174,145" style="fill: rgb(244,194,193)" /> - <polygon points="68,170 69,168 75,168 76,169 78,172 73,173 72,173 71,173 68,172" style="fill: rgb(226,165,164)" /> - <polygon points="176,104 176,96 179,98 180,99 182,103 180,104 179,104 178,104 177,104" style="fill: rgb(179,146,141)" /> - <polygon points="179,218 197,196 198,196 199,197 200,198 215,219 208,228 190,248 185,242" style="fill: rgb(119,114,120)" /> - <polygon points="69,173 79,172 80,172 81,172 82,172 83,172 76,176 73,175 71,174" style="fill: rgb(230,174,177)" /> - <polygon points="185,188 190,168 192,164 193,163 194,164 194,201 193,204 192,206 191,207" style="fill: rgb(223,185,184)" /> - <polygon points="157,215 158,212 161,212 162,212 163,212 161,215 160,216 159,217 158,217" style="fill: rgb(228,193,189)" /> - <polygon points="180,140 185,134 186,135 186,136 186,138 185,142 184,143 183,143 182,143" style="fill: rgb(228,193,189)" /> - <polygon points="66,229 68,226 69,225 74,220 75,222 74,225 73,226 72,227 66,230" style="fill: rgb(230,174,177)" /> - <polygon points="168,183 170,181 171,180 188,168 186,171 176,183 175,184 174,184 173,184" style="fill: rgb(210,158,160)" /> - <polygon points="160,147 166,138 168,139 169,140 170,142 170,146 170,148 163,151 162,151" style="fill: rgb(226,165,164)" /> - <polygon points="156,149 158,148 159,148 160,148 161,148 162,148 164,150 164,155 163,155" style="fill: rgb(230,174,177)" /> - <polygon points="166,53 168,45 169,43 170,42 172,43 172,51 172,52 172,53 167,54" style="fill: rgb(34,28,28)" /> - <polygon points="103,82 103,78 104,78 104,82 103,83 103,79 103,78 104,78 104,82" style="fill: rgb(87,76,74)" /> - <polygon points="156,99 158,97 162,95 163,95 164,95 162,103 161,104 160,104 157,103" style="fill: rgb(153,115,106)" /> - <polygon points="86,208 101,202 102,203 103,206 105,216 105,217 105,218 105,221 86,209" style="fill: rgb(213,149,150)" /> - <polygon points="154,42 155,42 156,42 157,43 158,44 158,47 157,47 154,43" style="fill: rgb(66,55,53)" /> - <polygon points="124,110 125,110 126,110 132,110 131,111 129,112 128,112 127,112" style="fill: rgb(210,158,160)" /> - <polygon points="57,243 58,241 61,236 68,230 70,229 73,228 59,245 57,245" style="fill: rgb(210,158,160)" /> - <polygon points="129,102 129,101 130,101 131,102 131,103 130,104 129,105 129,101" style="fill: rgb(179,146,141)" /> - <polygon points="191,85 193,87 194,90 196,96 196,97 196,101 196,102 192,99" style="fill: rgb(230,174,177)" /> - <polygon points="193,53 195,52 197,52 198,52 198,56 197,57 195,56 193,54" style="fill: rgb(17,11,15)" /> - <polygon points="104,81 104,80 107,83 107,86 107,87 106,89 105,88 104,87" style="fill: rgb(74,64,62)" /> - <polygon points="188,241 189,240 190,240 191,241 191,244 190,244 189,244 188,242" style="fill: rgb(178,201,219)" /> - <polygon points="82,259 82,258 86,259 96,265 108,275 111,278 106,284 104,284" style="fill: rgb(65,77,99)" /> - <polygon points="170,84 171,84 172,84 173,84 174,84 175,84 176,84 177,84" style="fill: rgb(179,146,141)" /> - <polygon points="64,176 68,173 80,174 84,175 86,176 87,177 75,181 64,179" style="fill: rgb(238,179,181)" /> - <polygon points="91,198 92,198 93,198 95,199 96,200 96,201 94,200 92,199" style="fill: rgb(214,116,115)" /> - <polygon points="153,35 154,35 155,35 158,35 159,36 159,38 158,38 157,38" style="fill: rgb(87,76,74)" /> - <polygon points="141,131 142,129 144,128 145,129 145,130 145,133 145,134 141,137" style="fill: rgb(237,189,185)" /> - <polygon points="58,189 58,188 59,182 60,179 73,180 71,183 60,191 59,191" style="fill: rgb(230,174,177)" /> - <polygon points="73,190 73,189 73,183 82,183 83,186 76,195 74,193 73,191" style="fill: rgb(230,174,177)" /> - <polygon points="115,127 117,122 120,121 121,135 120,137 117,136 115,130 115,128" style="fill: rgb(227,181,184)" /> - <polygon points="170,159 174,154 175,153 180,153 180,154 180,156 177,158 172,159" style="fill: rgb(226,165,164)" /> - <polygon points="179,32 179,31 183,31 184,31 186,32 187,33 188,37 179,33" style="fill: rgb(74,64,62)" /> - <polygon points="183,40 185,40 188,41 188,42 188,43 188,44 184,42 183,41" style="fill: rgb(34,28,28)" /> - <polygon points="124,97 129,93 135,94 137,96 137,97 137,98 137,99 125,98" style="fill: rgb(214,116,115)" /> - <polygon points="295,299 295,298 295,293 296,286 297,283 298,283 299,292 299,299" style="fill: rgb(65,77,99)" /> - <polygon points="215,86 215,88 215,84 215,90 215,85 215,87 215,83 215,89" style="fill: rgb(200,169,167)" /> - <polygon points="164,30 168,26 172,25 173,25 175,27 178,34 175,34 167,34" style="fill: rgb(104,87,80)" /> - <polygon points="164,154 164,153 164,152 164,151 165,150 168,150 167,153 165,154" style="fill: rgb(238,179,181)" /> - <polygon points="128,92 132,86 133,87 134,88 135,91 134,93 133,93 130,93" style="fill: rgb(153,115,106)" /> - <polygon points="197,77 199,75 203,78 204,79 206,87 206,88 205,88 198,79" style="fill: rgb(74,64,62)" /> - <polygon points="171,187 171,186 172,185 176,184 177,184 177,185 175,191 171,188" style="fill: rgb(213,149,150)" /> - <polygon points="198,96 198,101 198,103 198,97 198,99 198,102 198,98 198,100" style="fill: rgb(153,115,106)" /> - <polygon points="97,214 106,213 111,228 111,230 110,231 109,231 108,230 99,217" style="fill: rgb(153,115,106)" /> - <polygon points="147,78 152,76 161,75 165,75 170,76 172,77 173,79 172,79" style="fill: rgb(238,179,181)" /> - <polygon points="50,230 51,228 61,227 61,229 59,231 56,231 55,231 53,231" style="fill: rgb(237,189,185)" /> - <polygon points="39,260 54,248 55,248 49,254 48,255 46,257 42,260 40,260" style="fill: rgb(227,181,184)" /> - <polygon points="224,292 225,292 227,292 233,294 239,299 230,299 229,299 226,296" style="fill: rgb(65,77,99)" /> - <polygon points="157,299 157,295 157,294 158,294 162,295 163,296 163,297 158,299" style="fill: rgb(65,77,99)" /> - <polygon points="138,51 139,46 140,45 141,45 145,48 142,50 139,52 138,52" style="fill: rgb(17,11,15)" /> - <polygon points="30,247 30,245 32,244 31,247 30,249 30,245 32,244 31,247" style="fill: rgb(232,184,182)" /> - <polygon points="94,208 94,207 95,206 97,206 98,206 98,209 97,209 96,209" style="fill: rgb(244,194,193)" /> - <polygon points="101,58 101,56 102,54 103,54 106,55 104,59 102,59 101,59" style="fill: rgb(178,201,219)" /> - <polygon points="105,68 106,62 107,60 109,63 112,70 110,78 109,80 105,75" style="fill: rgb(104,87,80)" /> - <polygon points="147,39 150,38 153,38 153,39 152,40 149,41 148,41 147,40" style="fill: rgb(34,28,28)" /> - <polygon points="165,245 166,243 167,242 168,242 169,244 168,248 167,248 166,247" style="fill: rgb(226,165,164)" /> - <polygon points="20,249 24,238 26,233 27,233 27,234 25,253 21,251 20,250" style="fill: rgb(179,146,141)" /> - <polygon points="165,36 166,36 167,36 168,36 169,36 170,37 170,38 166,37" style="fill: rgb(123,102,107)" /> - <polygon points="110,68 110,65 112,66 113,67 113,68 113,69 112,69 111,69" style="fill: rgb(87,76,74)" /> - <polygon points="36,256 42,254 42,255 41,257 39,257 38,257 37,257 36,257" style="fill: rgb(228,193,189)" /> - <polygon points="149,61 160,60 161,60 162,60 163,60 164,60 165,60 159,61" style="fill: rgb(153,115,106)" /> - <polygon points="81,171 91,170 92,170 100,171 101,172 100,172 99,172 90,172" style="fill: rgb(234,196,195)" /> - <polygon points="132,37 133,35 134,35 135,36 135,37 135,38 133,38 132,38" style="fill: rgb(123,102,107)" /> - <polygon points="172,154 176,143 177,142 178,142 179,142 180,142 181,142 180,147" style="fill: rgb(232,184,182)" /> - <polygon points="204,70 204,69 205,68 206,68 208,69 208,70 206,71 205,71" style="fill: rgb(34,28,28)" /> - <polygon points="1,268 1,261 2,261 3,262 4,264 4,265 3,267 2,268" style="fill: rgb(178,201,219)" /> - <polygon points="36,258 46,250 47,250 46,253 45,255 41,259 40,259 38,259" style="fill: rgb(227,181,184)" /> - <polygon points="138,121 139,121 140,121 141,121 142,121 143,121 144,122 143,123" style="fill: rgb(214,116,115)" /> - <polygon points="113,78 114,76 115,74 116,73 129,64 129,65 124,71 113,79" style="fill: rgb(226,165,164)" /> - <polygon points="164,181 164,180 176,177 176,179 174,183 169,184 168,184 165,182" style="fill: rgb(213,149,150)" /> - <polygon points="106,211 108,215 110,223 110,225 109,223 108,220 107,216 106,212" style="fill: rgb(130,84,87)" /> - <polygon points="164,236 164,233 165,231 170,238 170,239 170,240 166,238 165,237" style="fill: rgb(213,149,150)" /> - <polygon points="162,194 163,193 164,193 165,193 166,193 167,193 165,194 164,194" style="fill: rgb(227,181,184)" /> - <polygon points="152,228 153,225 166,224 167,224 159,234 157,235 156,235 154,233" style="fill: rgb(228,193,189)" /> - <polygon points="146,288 146,287 147,277 148,276 148,278 148,279 147,294 146,296" style="fill: rgb(22,39,69)" /> - <polygon points="167,43 168,42 170,41 173,41 174,42 173,43 169,45 167,44" style="fill: rgb(58,47,51)" /> - <polygon points="47,224 48,219 51,210 52,207 56,206 56,210 56,213 48,223" style="fill: rgb(228,193,189)" /> - <polygon points="51,202 52,200 54,200 56,201 56,203 54,206 53,206 52,205" style="fill: rgb(227,181,184)" /> - <polygon points="57,190 59,189 61,188 61,189 61,191 60,192 59,193 58,193" style="fill: rgb(227,181,184)" /> - <polygon points="77,212 78,211 79,212 79,213 79,214 78,214 77,213" style="fill: rgb(244,194,193)" /> - <polygon points="122,51 123,50 128,48 129,49 130,51 130,52 127,53" style="fill: rgb(87,76,74)" /> - <polygon points="136,42 138,42 142,44 142,45 142,46 139,49 137,50" style="fill: rgb(34,28,28)" /> - <polygon points="117,69 117,68 118,66 119,65 121,64 122,64 122,68" style="fill: rgb(179,146,141)" /> - <polygon points="126,56 126,55 139,57 139,58 138,59 127,61 126,61" style="fill: rgb(97,66,61)" /> - <polygon points="44,299 44,298 44,297 46,290 47,290 46,297 45,299" style="fill: rgb(22,39,69)" /> - <polygon points="161,51 161,52 161,49 161,50 161,47 161,48 161,46" style="fill: rgb(17,11,15)" /> - <polygon points="132,144 133,144 134,144 135,144 136,144 137,144 138,144" style="fill: rgb(200,169,167)" /> - <polygon points="177,118 177,117 178,117 179,117 181,118 179,119 178,119" style="fill: rgb(242,202,203)" /> - <polygon points="165,93 166,92 167,92 168,92 169,92 169,93 168,93" style="fill: rgb(226,165,164)" /> - <polygon points="148,60 149,60 150,60 151,60 152,60 153,60 154,60" style="fill: rgb(119,88,86)" /> - <polygon points="152,237 153,236 160,235 160,236 159,237 156,238 155,238" style="fill: rgb(227,181,184)" /> - <polygon points="32,294 33,295 34,297 34,298 34,299 33,299 32,296" style="fill: rgb(22,39,69)" /> - <polygon points="130,40 131,40 133,40 134,41 135,42 136,43 137,44" style="fill: rgb(66,55,53)" /> - <polygon points="185,46 189,43 190,44 191,46 192,56 188,54 187,53" style="fill: rgb(58,47,51)" /> - <polygon points="136,37 138,36 143,35 146,35 147,35 148,35 136,39" style="fill: rgb(104,87,80)" /> - <polygon points="198,125 198,121 198,120 202,129 201,131 200,130 199,128" style="fill: rgb(179,146,141)" /> - <polygon points="108,110 108,109 109,98 112,96 113,96 113,97 110,111" style="fill: rgb(200,169,167)" /> - <polygon points="159,26 168,27 167,29 164,32 163,32 162,32 159,27" style="fill: rgb(74,64,62)" /> - <polygon points="114,75 114,74 119,66 129,63 125,68 123,70 121,72" style="fill: rgb(213,149,150)" /> - <polygon points="158,249 160,246 162,246 163,248 164,250 164,252 158,250" style="fill: rgb(153,115,106)" /> - <polygon points="200,94 201,96 201,97 201,99 201,100 200,97 200,95" style="fill: rgb(34,28,28)" /> - <polygon points="68,212 70,210 73,210 73,211 72,212 70,213 68,213" style="fill: rgb(226,165,164)" /> - <polygon points="199,72 200,71 202,70 203,76 201,76 200,75 199,73" style="fill: rgb(104,87,80)" /> - <polygon points="180,181 184,176 189,171 190,174 188,180 181,185 180,182" style="fill: rgb(227,181,184)" /> - <polygon points="104,190 104,189 108,184 109,183 108,186 106,191 105,191" style="fill: rgb(213,149,150)" /> - <polygon points="175,57 177,55 178,54 183,52 185,53 187,59 188,62" style="fill: rgb(97,66,61)" /> - <polygon points="202,138 202,136 203,134 204,134 207,137 204,140 203,139" style="fill: rgb(232,184,182)" /> - <polygon points="169,229 169,228 174,222 174,223 173,238 172,245 169,230" style="fill: rgb(153,115,106)" /> - <polygon points="31,232 32,230 34,227 37,225 37,226 34,231 32,232" style="fill: rgb(226,165,164)" /> - <polygon points="109,58 110,57 116,56 118,58 115,61 114,61 111,61" style="fill: rgb(87,76,74)" /> - <polygon points="133,131 134,130 138,129 137,132 135,133 134,133 133,132" style="fill: rgb(210,158,160)" /> - <polygon points="116,53 121,51 124,54 122,57 121,57 119,56 117,55" style="fill: rgb(58,47,51)" /> - <polygon points="152,229 161,231 160,234 159,236 154,241 153,239 152,236" style="fill: rgb(223,185,184)" /> - <polygon points="143,55 145,51 146,50 147,51 147,55 145,56 143,56" style="fill: rgb(58,47,51)" /> - <polygon points="141,117 141,115 143,114 145,114 145,116 145,117 142,117" style="fill: rgb(244,194,193)" /> - <polygon points="108,82 108,84 108,86 108,81 108,83 108,85 108,87" style="fill: rgb(97,66,61)" /> - <polygon points="192,163 197,156 197,157 197,158 196,179 195,189 194,191" style="fill: rgb(200,169,167)" /> - <polygon points="186,73 187,71 190,82 190,83 188,80 187,77 186,74" style="fill: rgb(226,165,164)" /> - <polygon points="189,75 189,72 190,74 193,85 192,84 190,80 189,76" style="fill: rgb(179,146,141)" /> - <polygon points="145,128 147,127 148,127 149,128 151,130 151,131 146,129" style="fill: rgb(232,184,182)" /> - <polygon points="117,90 117,89 119,88 120,88 121,88 122,88 119,90" style="fill: rgb(74,64,62)" /> - <polygon points="61,173 62,172 63,172 64,172 65,173 65,174 62,177" style="fill: rgb(242,202,203)" /> - <polygon points="51,248 52,245 56,240 57,240 56,242 53,246 52,247" style="fill: rgb(230,174,177)" /> - <polygon points="159,35 164,36 168,38 168,39 167,40 162,43 159,37" style="fill: rgb(87,76,74)" /> - <polygon points="112,185 112,189 112,188 112,187 112,191 112,186 112,190" style="fill: rgb(228,193,189)" /> - <polygon points="18,249 23,238 24,237 23,244 22,247 21,248 19,250" style="fill: rgb(153,115,106)" /> - <polygon points="132,47 132,45 136,49 136,50 135,52 134,52 133,51" style="fill: rgb(17,11,15)" /> - <polygon points="78,170 79,170 80,170 81,170 82,170 80,171 79,171" style="fill: rgb(237,189,185)" /> - <polygon points="5,299 6,297 13,294 15,297 16,299 9,299 8,299" style="fill: rgb(119,114,120)" /> - <polygon points="64,184 65,183 66,183 67,186 66,187 65,188 64,189" style="fill: rgb(242,202,203)" /> - <polygon points="141,99 151,97 152,99 146,106 144,108 143,107 142,105" style="fill: rgb(238,179,181)" /> - <polygon points="115,59 116,58 118,57 122,58 121,59 118,61 116,60" style="fill: rgb(97,66,61)" /> - <polygon points="17,248 22,240 22,241 22,243 22,244 18,248 17,249" style="fill: rgb(130,84,87)" /> - <polygon points="98,179 99,179 101,180 104,182 106,184 105,185 102,187" style="fill: rgb(238,179,181)" /> - <polygon points="202,113 202,111 203,113 203,115 202,114 202,112 202,111" style="fill: rgb(58,47,51)" /> - <polygon points="139,53 140,52 144,49 144,50 143,53 141,53 140,53" style="fill: rgb(29,19,18)" /> - <polygon points="151,91 152,90 166,91 165,94 155,99 154,98 151,93" style="fill: rgb(213,149,150)" /> - <polygon points="161,198 161,197 165,191 177,191 177,195 173,200 161,199" style="fill: rgb(230,174,177)" /> - <polygon points="84,188 85,188 92,191 94,192 93,192 90,191 87,190" style="fill: rgb(237,189,185)" /> - <polygon points="72,243 78,239 87,249 88,252 88,253 86,252 75,245" style="fill: rgb(65,77,99)" /> - <polygon points="139,90 150,87 150,97 149,98 147,99 146,99 142,98" style="fill: rgb(244,194,193)" /> - <polygon points="155,29 155,28 156,28 157,29 159,33 156,31 155,30" style="fill: rgb(104,87,80)" /> - <polygon points="172,162 174,160 176,161 176,162 175,165 174,164 173,163" style="fill: rgb(213,149,150)" /> - <polygon points="25,250 25,249 25,246 25,244 27,248 26,253 25,252" style="fill: rgb(213,149,150)" /> - <polygon points="142,78 143,78 144,78 145,78 145,79 144,79 143,79" style="fill: rgb(238,179,181)" /> - <polygon points="147,32 148,31 152,32 153,33 148,34 147,34 147,33" style="fill: rgb(87,76,74)" /> - <polygon points="76,208 78,207 81,207 81,208 81,209 79,210 76,210" style="fill: rgb(232,184,182)" /> - <polygon points="44,253 44,252 44,251 50,244 50,245 50,246 44,254" style="fill: rgb(228,193,189)" /> - <polygon points="34,230 35,228 37,224 39,224 39,225 37,230 35,231" style="fill: rgb(230,174,177)" /> - <polygon points="39,227 40,223 43,219 44,218 47,218 46,222 45,224" style="fill: rgb(232,184,182)" /> - <polygon points="198,113 198,109 198,111 198,114 198,110 198,112 198,108" style="fill: rgb(213,149,150)" /> - <polygon points="81,179 84,178 85,178 86,178 87,178 88,178 83,179" style="fill: rgb(237,189,185)" /> - <polygon points="172,29 173,29 178,33 179,36 179,38 178,37 174,32" style="fill: rgb(119,88,86)" /> - <polygon points="185,126 190,126 190,130 189,133 188,136 187,134 186,130" style="fill: rgb(232,184,182)" /> - <polygon points="140,137 140,136 147,135 148,135 148,138 141,138 140,138" style="fill: rgb(238,179,181)" /> - <polygon points="62,245 65,240 66,239 68,238 70,238 69,241 68,242" style="fill: rgb(179,146,141)" /> - <polygon points="123,39 125,39 129,39 132,40 131,41 130,42 124,40" style="fill: rgb(58,47,51)" /> - <polygon points="137,39 137,38 138,37 139,37 142,37 141,38 137,40" style="fill: rgb(87,76,74)" /> - <polygon points="98,210 99,209 100,209 100,210 100,211 99,212 98,211" style="fill: rgb(238,179,181)" /> - <polygon points="118,98 121,97 122,97 123,97 124,98 119,100 118,100" style="fill: rgb(179,146,141)" /> - <polygon points="225,235 225,234 225,233 225,232 226,233 226,235 226,237" style="fill: rgb(65,77,99)" /> - <polygon points="216,115 216,117 216,119 216,121 216,116 216,118 216,120" style="fill: rgb(213,149,150)" /> - <polygon points="108,192 108,191 109,187 109,188 109,189 109,190 109,191" style="fill: rgb(130,84,87)" /> - <polygon points="130,61 131,61 132,61 133,61 134,61 135,61 136,61" style="fill: rgb(153,115,106)" /> - <polygon points="184,120 184,119 185,117 186,117 187,118 187,119 185,120" style="fill: rgb(244,194,193)" /> - <polygon points="100,204 101,205 102,206 102,209 102,210 102,211 101,208" style="fill: rgb(226,165,164)" /> - <polygon points="189,214 189,213 190,212 191,211 192,211 193,211 190,214" style="fill: rgb(65,77,99)" /> - <polygon points="64,210 65,203 68,203 70,205 69,207 65,213 64,211" style="fill: rgb(237,189,185)" /> - <polygon points="76,180 77,178 79,178 80,182 80,183 78,182 76,181" style="fill: rgb(237,189,185)" /> - <polygon points="123,38 133,31 134,31 135,32 135,33 129,37 126,38" style="fill: rgb(104,87,80)" /> - <polygon points="56,238 56,233 56,232 66,228 65,230 58,239 57,239" style="fill: rgb(227,181,184)" /> - <polygon points="182,146 182,145 187,138 188,138 187,144 185,146 183,148" style="fill: rgb(232,184,182)" /> - <polygon points="210,109 211,109 212,109 213,109 214,109 211,111 210,111" style="fill: rgb(153,115,106)" /> - <polygon points="191,192 192,180 193,177 195,200 195,201 193,200 192,199" style="fill: rgb(230,174,177)" /> - <polygon points="0,265 0,261 2,262 3,264 3,265 2,267 0,268" style="fill: rgb(239,244,248)" /> - <polygon points="132,62 133,62 134,62 135,62 136,62 137,62 138,62" style="fill: rgb(210,158,160)" /> - <polygon points="111,103 113,95 115,94 116,95 115,113 112,115 111,113" style="fill: rgb(210,158,160)" /> - <polygon points="105,208 105,206 110,201 111,205 111,209 111,210 110,210" style="fill: rgb(130,84,87)" /> - <polygon points="172,44 174,45 176,47 177,49 177,50 176,51 173,53" style="fill: rgb(17,11,15)" /> - <polygon points="194,71 194,69 196,66 200,68 199,71 197,74 194,76" style="fill: rgb(87,76,74)" /> - <polygon points="144,39 148,37 150,36 153,37 154,38 147,42 146,41" style="fill: rgb(58,47,51)" /> - <polygon points="85,175 85,174 98,175 104,176 107,183 106,183 87,176" style="fill: rgb(230,174,177)" /> - <polygon points="170,92 177,91 178,92 173,93 172,93 171,93 170,93" style="fill: rgb(230,174,177)" /> - <polygon points="127,94 128,94 129,94 130,95 129,95 128,95" style="fill: rgb(213,149,150)" /> - <polygon points="158,244 158,243 160,242 163,243 163,244 158,245" style="fill: rgb(213,149,150)" /> - <polygon points="83,210 85,206 88,206 92,209 84,213 83,212" style="fill: rgb(230,174,177)" /> - <polygon points="17,245 19,241 21,237 21,238 19,243 18,244" style="fill: rgb(76,48,47)" /> - <polygon points="151,260 153,260 154,261 153,263 152,264 151,262" style="fill: rgb(22,39,69)" /> - <polygon points="42,259 48,252 49,251 50,252 47,255 46,256" style="fill: rgb(200,169,167)" /> - <polygon points="147,126 148,126 149,126 150,126 151,126 151,127" style="fill: rgb(230,174,177)" /> - <polygon points="152,89 153,87 154,86 156,93 155,93 153,92" style="fill: rgb(179,146,141)" /> - <polygon points="46,218 46,213 47,211 48,213 48,214 47,217" style="fill: rgb(228,193,189)" /> - <polygon points="108,201 108,202 108,199 108,203 108,200 108,204" style="fill: rgb(214,116,115)" /> - <polygon points="247,238 249,239 251,240 252,241 250,240 248,239" style="fill: rgb(178,201,219)" /> - <polygon points="131,100 132,98 133,98 135,100 135,102 135,103" style="fill: rgb(130,84,87)" /> - <polygon points="160,212 161,211 163,210 164,210 165,213 164,214" style="fill: rgb(223,185,184)" /> - <polygon points="192,43 192,42 193,42 194,42 194,43 194,44" style="fill: rgb(66,55,53)" /> - <polygon points="169,55 170,54 171,54 175,55 172,56 171,56" style="fill: rgb(58,47,51)" /> - <polygon points="183,138 183,137 183,136 184,137 184,138 183,139" style="fill: rgb(237,189,185)" /> - <polygon points="163,47 163,45 163,44 166,47 166,48 164,49" style="fill: rgb(58,47,51)" /> - <polygon points="140,39 143,38 144,38 145,38 146,42 141,41" style="fill: rgb(66,55,53)" /> - <polygon points="145,144 152,142 161,142 164,144 162,144 161,144" style="fill: rgb(130,84,87)" /> - <polygon points="187,162 188,162 190,163 189,164 188,164 187,164" style="fill: rgb(153,115,106)" /> - <polygon points="27,235 28,232 29,231 33,228 30,233 27,237" style="fill: rgb(210,158,160)" /> - <polygon points="225,224 230,228 231,229 229,228 228,227 227,226" style="fill: rgb(178,201,219)" /> - <polygon points="88,188 89,188 90,188 95,190 93,190 90,189" style="fill: rgb(230,174,177)" /> - <polygon points="69,232 75,231 74,233 71,235 70,235 69,233" style="fill: rgb(179,146,141)" /> - <polygon points="196,180 196,184 196,185 196,181 196,182 196,183" style="fill: rgb(223,185,184)" /> - <polygon points="178,62 179,62 180,62 182,63 184,65 179,63" style="fill: rgb(226,165,164)" /> - <polygon points="176,28 176,27 178,28 182,30 182,31 178,31" style="fill: rgb(87,76,74)" /> - <polygon points="118,144 118,141 119,141 120,142 120,144 119,144" style="fill: rgb(227,181,184)" /> - <polygon points="205,132 206,128 206,129 206,130 206,131 206,132" style="fill: rgb(226,165,164)" /> - <polygon points="121,66 122,65 126,64 125,66 123,67 122,67" style="fill: rgb(214,116,115)" /> - <polygon points="100,181 102,182 102,184 102,185 101,186 100,187" style="fill: rgb(242,202,203)" /> - <polygon points="53,229 54,230 57,234 57,235 56,237 53,234" style="fill: rgb(237,189,185)" /> - <polygon points="84,232 85,231 88,229 90,228 91,228 86,231" style="fill: rgb(178,201,219)" /> - <polygon points="214,86 214,82 214,84 214,85 214,81 214,83" style="fill: rgb(104,87,80)" /> - <polygon points="101,88 101,87 105,96 105,97 103,94 101,89" style="fill: rgb(178,201,219)" /> - <polygon points="195,82 196,81 197,81 198,81 197,84 196,85" style="fill: rgb(74,64,62)" /> - <polygon points="211,113 212,114 213,116 214,119 214,120 212,118" style="fill: rgb(213,149,150)" /> - <polygon points="97,169 98,169 99,169 100,169 101,169 102,170" style="fill: rgb(230,174,177)" /> - <polygon points="145,126 147,125 148,125 149,125 150,125 146,126" style="fill: rgb(226,165,164)" /> - <polygon points="181,61 182,61 183,62 184,63 185,64 186,65" style="fill: rgb(179,146,141)" /> - <polygon points="175,152 178,146 182,147 182,148 182,150 177,152" style="fill: rgb(232,184,182)" /> - <polygon points="114,103 114,102 117,99 118,99 118,101 114,105" style="fill: rgb(153,115,106)" /> - <polygon points="58,199 59,197 60,195 61,194 61,195 59,199" style="fill: rgb(228,193,189)" /> - <polygon points="17,246 20,242 20,244 19,245 18,246 17,247" style="fill: rgb(97,66,61)" /> - <polygon points="151,35 152,35 155,36 157,37 156,38 155,39" style="fill: rgb(74,64,62)" /> - <polygon points="107,201 107,199 108,195 108,197 108,198 107,203" style="fill: rgb(213,149,150)" /> - <polygon points="156,88 159,86 160,86 165,90 158,90 156,89" style="fill: rgb(97,66,61)" /> - <polygon points="26,244 27,245 28,247 28,251 28,253 26,245" style="fill: rgb(226,165,164)" /> - <polygon points="185,45 186,44 187,44 188,46 188,47 187,47" style="fill: rgb(66,55,53)" /> - <polygon points="185,92 187,91 188,92 188,93 187,93 186,93" style="fill: rgb(179,146,141)" /> - <polygon points="158,102 158,101 159,100 160,99 160,100 159,102" style="fill: rgb(130,84,87)" /> - <polygon points="174,196 175,195 177,196 176,197 175,197 174,197" style="fill: rgb(227,181,184)" /> - <polygon points="112,103 131,110 129,111 116,113 113,112 112,109" style="fill: rgb(213,149,150)" /> - <polygon points="160,83 160,82 161,82 162,82 163,82 164,82" style="fill: rgb(237,189,185)" /> - <polygon points="86,207 87,207 88,207 89,208 90,209 88,208" style="fill: rgb(226,165,164)" /> - <polygon points="102,82 102,84 102,86 102,83 102,85 102,87" style="fill: rgb(119,114,120)" /> - <polygon points="155,63 156,63 157,63 158,63 159,63 160,63" style="fill: rgb(230,174,177)" /> - <polygon points="148,231 150,227 151,227 151,232 150,232 149,232" style="fill: rgb(230,174,177)" /> - <polygon points="171,146 171,145 171,149 171,148 171,144 171,147" style="fill: rgb(232,184,182)" /> - <polygon points="143,41 144,41 148,43 146,44 145,44 143,42" style="fill: rgb(87,76,74)" /> - <polygon points="60,231 62,227 63,227 64,227 64,228 63,230" style="fill: rgb(237,189,185)" /> - <polygon points="181,207 181,206 181,205 182,203 183,204 182,207" style="fill: rgb(242,202,203)" /> - <polygon points="137,35 138,35 139,35 140,35 141,35 142,35" style="fill: rgb(123,102,107)" /> - <polygon points="148,133 148,130 150,131 151,132 150,134 148,134" style="fill: rgb(238,179,181)" /> - <polygon points="213,63 213,62 214,61 215,65 216,69 215,69" style="fill: rgb(178,201,219)" /> - <polygon points="182,39 187,37 189,37 189,38 187,40 186,40" style="fill: rgb(58,47,51)" /> - <polygon points="144,28 144,27 145,26 147,25 149,26 150,27" style="fill: rgb(178,201,219)" /> - <polygon points="139,42 139,39 140,40 143,43 141,43 140,43" style="fill: rgb(74,64,62)" /> - <polygon points="65,225 70,221 71,221 71,222 70,223 67,226" style="fill: rgb(234,196,195)" /> - <polygon points="179,220 180,220 181,221 180,224 179,222 179,221" style="fill: rgb(22,39,69)" /> - <polygon points="78,180 80,179 85,179 87,183 85,183 80,181" style="fill: rgb(244,194,193)" /> - <polygon points="140,60 142,59 143,59 144,59 146,60 144,60" style="fill: rgb(153,115,106)" /> - <polygon points="138,50 142,49 143,49 143,50 142,51 140,51" style="fill: rgb(25,16,19)" /> - <polygon points="148,52 149,51 150,50 150,51 150,53 148,53" style="fill: rgb(29,19,18)" /> - <polygon points="100,76 101,81 101,82 101,84 101,85 100,81" style="fill: rgb(178,201,219)" /> - <polygon points="159,252 161,251 162,252 162,253 160,253 159,253" style="fill: rgb(97,66,61)" /> - <polygon points="164,56 167,55 176,55 175,56 172,57 170,57" style="fill: rgb(76,48,47)" /> - <polygon points="184,221 185,220 186,223 186,224 186,226 185,226" style="fill: rgb(65,77,99)" /> - <polygon points="54,193 54,192 55,190 56,189 56,191 54,194" style="fill: rgb(228,193,189)" /> - <polygon points="120,103 126,107 125,108 123,108 122,108 121,108" style="fill: rgb(179,146,141)" /> - <polygon points="67,170 67,169 68,168 68,169 67,172 67,169" style="fill: rgb(230,174,177)" /> - <polygon points="180,35 180,34 181,33 182,33 184,34 185,37" style="fill: rgb(58,47,51)" /> - <polygon points="104,223 105,225 107,229 107,230 106,229 104,224" style="fill: rgb(130,84,87)" /> - <polygon points="154,89 154,88 160,91 158,92 156,92 154,91" style="fill: rgb(153,115,106)" /> - <polygon points="109,217 109,216 110,219 110,221 110,222 109,220" style="fill: rgb(97,66,61)" /> - <polygon points="174,225 175,223 175,224 175,225 174,232 174,227" style="fill: rgb(119,88,86)" /> - <polygon points="176,94 178,91 181,92 182,93 183,94 183,95" style="fill: rgb(227,181,184)" /> - <polygon points="150,124 153,120 154,120 155,121 157,125 154,125" style="fill: rgb(214,116,115)" /> - <polygon points="80,298 80,296 80,295 81,295 81,299 80,299" style="fill: rgb(65,77,99)" /> - <polygon points="37,229 38,227 39,226 40,227 40,228 39,229" style="fill: rgb(227,181,184)" /> - <polygon points="172,109 173,109 174,109 175,109 176,109 177,109" style="fill: rgb(230,174,177)" /> - <polygon points="189,154 190,150 192,152 193,153 194,154 191,155" style="fill: rgb(200,169,167)" /> - <polygon points="104,209 104,208 105,212 105,213 104,211 104,208" style="fill: rgb(214,116,115)" /> - <polygon points="132,216 133,216 135,216 138,216 138,217 134,217" style="fill: rgb(200,169,167)" /> - <polygon points="150,137 150,136 151,134 152,135 152,136 151,137" style="fill: rgb(238,179,181)" /> - <polygon points="177,299 177,297 177,296 178,294 179,294 179,299" style="fill: rgb(65,77,99)" /> - <polygon points="202,109 202,108 204,110 204,112 204,113 204,115" style="fill: rgb(69,54,51)" /> - <polygon points="171,220 171,219 171,218 173,218 172,220 171,221" style="fill: rgb(228,193,189)" /> - <polygon points="106,224 108,224 110,228 110,230 109,230 107,226" style="fill: rgb(214,116,115)" /> - <polygon points="177,105 180,100 181,100 183,103 183,104 181,105" style="fill: rgb(153,115,106)" /> - <polygon points="180,146 180,145 180,144 181,143 183,144 181,146" style="fill: rgb(223,185,184)" /> - <polygon points="171,104 171,103 175,101 176,105 173,105 172,105" style="fill: rgb(179,146,141)" /> - <polygon points="202,66 202,65 204,65 204,66 202,68 202,65" style="fill: rgb(34,28,28)" /> - <polygon points="203,83 206,77 210,80 209,81 205,84 204,84" style="fill: rgb(66,55,53)" /> - <polygon points="137,118 137,117 140,113 141,112 142,112 143,112" style="fill: rgb(230,174,177)" /> - <polygon points="211,112 212,110 215,112 215,115 215,117 214,118" style="fill: rgb(214,116,115)" /> - <polygon points="109,94 109,93 115,93 116,93 110,97 109,96" style="fill: rgb(179,146,141)" /> - <polygon points="183,244 184,242 189,249 189,250 188,251 187,251" style="fill: rgb(22,39,69)" /> - <polygon points="122,243 125,243 126,243 126,245 125,247 124,247" style="fill: rgb(119,114,120)" /> - <polygon points="110,216 111,216 112,219 113,223 113,224 112,224" style="fill: rgb(34,28,28)" /> - <polygon points="63,208 66,205 67,206 67,208 66,209 64,209" style="fill: rgb(244,194,193)" /> - <polygon points="165,53 165,52 165,51 165,49 166,49 166,51" style="fill: rgb(69,54,51)" /> - <polygon points="190,38 193,39 193,40 192,41 190,40 190,39" style="fill: rgb(87,76,74)" /> - <polygon points="117,66 118,64 120,63 126,63 125,64 117,67" style="fill: rgb(153,115,106)" /> - <polygon points="112,74 112,73 113,72 115,71 113,74 112,75" style="fill: rgb(153,115,106)" /> - <polygon points="115,47 116,46 117,47 119,50 118,51 116,49" style="fill: rgb(17,11,15)" /> - <polygon points="207,132 209,132 210,133 211,135 209,138 208,138" style="fill: rgb(226,165,164)" /> - <polygon points="174,54 176,45 180,48 181,49 179,51 176,54" style="fill: rgb(17,11,15)" /> - <polygon points="197,143 197,142 198,142 199,146 198,149 197,145" style="fill: rgb(200,169,167)" /> - <polygon points="180,230 181,229 183,227 183,234 183,237 183,239" style="fill: rgb(22,39,69)" /> - <polygon points="167,186 168,185 170,186 172,188 171,189 168,188" style="fill: rgb(210,158,160)" /> - <polygon points="108,92 108,94 108,96 108,97 108,93 108,95" style="fill: rgb(153,115,106)" /> - <polygon points="144,137 148,136 149,136 149,137 147,138 145,138" style="fill: rgb(237,189,185)" /> - <polygon points="127,109 135,105 136,105 134,107 133,108 132,109" style="fill: rgb(214,116,115)" /> - <polygon points="111,63 112,61 114,60 123,58 124,59 114,69" style="fill: rgb(104,87,80)" /> - <polygon points="103,230 103,228 107,232 107,233 106,235 105,235" style="fill: rgb(119,114,120)" /> - <polygon points="118,95 120,94 121,94 122,94 123,94 119,95" style="fill: rgb(223,185,184)" /> - <polygon points="114,98 115,97 116,96 117,96 117,97 116,98" style="fill: rgb(226,165,164)" /> - <polygon points="103,86 103,85 105,89 105,91 105,92 103,87" style="fill: rgb(87,76,74)" /> - <polygon points="174,144 175,142 176,140 177,141 176,145 175,147" style="fill: rgb(237,189,185)" /> - <polygon points="197,45 203,47 211,59 210,62 207,60 198,47" style="fill: rgb(74,64,62)" /> - <polygon points="214,88 214,90 214,92 214,93 214,89 214,91" style="fill: rgb(123,102,107)" /> - <polygon points="203,128 204,123 205,123 206,126 206,127 205,130" style="fill: rgb(226,165,164)" /> - <polygon points="119,117 120,114 121,113 123,115 121,117 119,118" style="fill: rgb(232,184,182)" /> - <polygon points="161,83 162,83 163,83 164,83 165,83" style="fill: rgb(228,193,189)" /> - <polygon points="29,251 29,250 30,254 30,255 29,254" style="fill: rgb(230,174,177)" /> - <polygon points="110,197 110,198 110,199 110,196 110,200" style="fill: rgb(97,66,61)" /> - <polygon points="168,94 169,94 170,94 171,94 172,94" style="fill: rgb(213,149,150)" /> - <polygon points="107,103 107,105 107,107 107,104 107,106" style="fill: rgb(178,201,219)" /> - <polygon points="152,49 154,48 158,55 157,56 155,56" style="fill: rgb(58,47,51)" /> - <polygon points="125,214 126,214 128,215 128,216 125,215" style="fill: rgb(200,169,167)" /> - <polygon points="186,57 189,56 190,60 190,61 189,61" style="fill: rgb(69,54,51)" /> - <polygon points="129,142 131,142 133,143 131,144 129,144" style="fill: rgb(213,149,150)" /> - <polygon points="207,73 209,74 210,75 209,75 208,74" style="fill: rgb(34,28,28)" /> - <polygon points="176,87 180,87 181,87 181,88 177,88" style="fill: rgb(97,66,61)" /> - <polygon points="106,221 107,222 107,223 107,224 106,223" style="fill: rgb(179,146,141)" /> - <polygon points="125,90 128,87 130,90 130,91 125,91" style="fill: rgb(97,66,61)" /> - <polygon points="200,45 201,45 202,45 203,45 204,45" style="fill: rgb(179,146,141)" /> - <polygon points="180,51 183,50 183,51 182,52 181,52" style="fill: rgb(74,64,62)" /> - <polygon points="164,45 164,44 165,44 166,44 166,46" style="fill: rgb(34,28,28)" /> - <polygon points="131,58 131,57 131,56 134,58 132,58" style="fill: rgb(119,88,86)" /> - <polygon points="120,61 121,61 126,62 124,62 122,62" style="fill: rgb(119,88,86)" /> - <polygon points="150,43 151,43 152,43 151,45 150,44" style="fill: rgb(87,76,74)" /> - <polygon points="130,39 130,37 130,35 131,36 131,39" style="fill: rgb(66,55,53)" /> - <polygon points="199,48 200,47 201,49 201,50 199,49" style="fill: rgb(66,55,53)" /> - <polygon points="132,30 133,29 134,29 135,29 136,29" style="fill: rgb(178,201,219)" /> - <polygon points="132,83 135,85 136,87 135,86 133,84" style="fill: rgb(230,174,177)" /> - <polygon points="91,207 91,206 92,206 94,206 93,208" style="fill: rgb(237,189,185)" /> - <polygon points="127,106 131,104 136,103 133,107 128,107" style="fill: rgb(153,115,106)" /> - <polygon points="180,116 181,115 183,116 183,117 182,117" style="fill: rgb(244,194,193)" /> - <polygon points="58,210 58,209 60,208 60,210 59,211" style="fill: rgb(237,189,185)" /> - <polygon points="116,104 117,103 120,101 118,103 117,104" style="fill: rgb(76,48,47)" /> - <polygon points="169,49 170,50 170,51 170,52 169,52" style="fill: rgb(34,28,28)" /> - <polygon points="136,33 137,32 138,32 139,32 140,32" style="fill: rgb(66,55,53)" /> - <polygon points="189,65 190,65 194,68 192,68 190,67" style="fill: rgb(97,66,61)" /> - <polygon points="184,53 185,54 186,55 186,56 185,55" style="fill: rgb(74,64,62)" /> - <polygon points="91,172 92,171 105,173 105,174 103,175" style="fill: rgb(242,202,203)" /> - <polygon points="130,87 131,88 132,89 131,89 130,88" style="fill: rgb(153,115,106)" /> - <polygon points="206,122 207,122 208,124 208,125 208,126" style="fill: rgb(130,84,87)" /> - <polygon points="138,212 142,211 143,211 142,212 141,213" style="fill: rgb(179,146,141)" /> - <polygon points="100,74 100,72 100,71 102,69 103,68" style="fill: rgb(178,201,219)" /> - <polygon points="42,225 43,225 44,225 44,226 42,227" style="fill: rgb(227,181,184)" /> - <polygon points="85,189 92,192 89,192 87,191 86,190" style="fill: rgb(244,194,193)" /> - <polygon points="143,33 145,31 147,30 145,33 144,34" style="fill: rgb(58,47,51)" /> - <polygon points="151,62 152,62 153,62 154,62 155,62" style="fill: rgb(179,146,141)" /> - <polygon points="159,251 160,249 161,249 163,251 163,252" style="fill: rgb(130,84,87)" /> - <polygon points="31,251 32,253 32,254 32,255 31,255" style="fill: rgb(232,184,182)" /> - <polygon points="190,69 190,68 192,71 193,73 193,75" style="fill: rgb(119,88,86)" /> - <polygon points="59,239 59,238 59,237 59,236 60,235" style="fill: rgb(230,174,177)" /> - <polygon points="113,105 113,103 113,102 114,101 116,99" style="fill: rgb(179,146,141)" /> - <polygon points="126,131 126,130 127,128 128,128 128,129" style="fill: rgb(244,194,193)" /> - <polygon points="184,35 185,34 186,35 187,38 186,38" style="fill: rgb(34,28,28)" /> - <polygon points="199,81 200,81 202,81 203,81 201,82" style="fill: rgb(66,55,53)" /> - <polygon points="161,196 161,195 161,194 163,194 163,195" style="fill: rgb(223,185,184)" /> - <polygon points="163,96 166,94 167,94 171,95 171,96" style="fill: rgb(214,116,115)" /> - <polygon points="143,140 144,140 145,140 146,140 147,140" style="fill: rgb(213,149,150)" /> - <polygon points="154,30 155,31 156,32 155,32 154,32" style="fill: rgb(123,102,107)" /> - <polygon points="215,72 215,74 215,76 215,73 215,75" style="fill: rgb(179,146,141)" /> - <polygon points="172,35 173,35 174,35 175,36 174,36" style="fill: rgb(34,28,28)" /> - <polygon points="164,207 166,205 167,205 166,208 165,209" style="fill: rgb(227,181,184)" /> - <polygon points="61,177 65,171 67,174 67,175 62,178" style="fill: rgb(244,194,193)" /> - <polygon points="147,270 148,269 149,269 149,270 147,271" style="fill: rgb(22,39,69)" /> - <polygon points="0,270 1,270 2,271 3,272 2,272" style="fill: rgb(179,146,141)" /> - <polygon points="173,97 175,95 177,96 178,99 175,98" style="fill: rgb(179,146,141)" /> - <polygon points="153,58 157,55 159,55 161,57 156,58" style="fill: rgb(76,48,47)" /> - <polygon points="123,90 125,89 127,88 126,89 124,90" style="fill: rgb(74,64,62)" /> - <polygon points="117,64 118,63 119,62 120,62 121,62" style="fill: rgb(130,84,87)" /> - <polygon points="162,299 166,296 166,297 166,298 166,299" style="fill: rgb(119,114,120)" /> - <polygon points="146,45 147,44 150,42 148,47 147,47" style="fill: rgb(74,64,62)" /> - <polygon points="103,71 104,70 106,68 106,70 104,71" style="fill: rgb(74,64,62)" /> - <polygon points="81,224 81,225 81,223 81,222 81,221" style="fill: rgb(153,115,106)" /> - <polygon points="190,64 191,64 192,64 192,66 191,65" style="fill: rgb(119,88,86)" /> - <polygon points="141,98 141,96 145,99 144,100 143,100" style="fill: rgb(237,189,185)" /> - <polygon points="178,188 179,181 180,183 181,186 180,188" style="fill: rgb(230,174,177)" /> - <polygon points="57,232 60,229 62,231 60,232 58,232" style="fill: rgb(234,196,195)" /> - <polygon points="13,247 14,245 15,245 15,246 13,249" style="fill: rgb(179,146,141)" /> - <polygon points="177,95 178,95 179,95 180,95 181,95" style="fill: rgb(226,165,164)" /> - <polygon points="165,175 165,174 165,173 165,172 165,176" style="fill: rgb(179,146,141)" /> - <polygon points="149,146 150,146 151,146 152,146 152,147" style="fill: rgb(230,174,177)" /> - <polygon points="38,258 43,255 44,255 42,257 41,258" style="fill: rgb(228,193,189)" /> - <polygon points="135,122 137,122 138,124 137,124 135,123" style="fill: rgb(76,48,47)" /> - <polygon points="184,92 188,94 188,95 187,95 186,95" style="fill: rgb(210,158,160)" /> - <polygon points="72,202 73,201 75,201 75,202 73,205" style="fill: rgb(230,174,177)" /> - <polygon points="50,250 52,248 52,249 51,250 50,251" style="fill: rgb(210,158,160)" /> - <polygon points="161,214 162,213 163,213 163,215 162,215" style="fill: rgb(237,189,185)" /> - <polygon points="112,53 115,53 116,54 113,54 112,54" style="fill: rgb(69,54,51)" /> - <polygon points="274,252 276,253 278,254 277,254 275,253" style="fill: rgb(178,201,219)" /> - <polygon points="85,233 85,232 87,231 88,231 87,232" style="fill: rgb(179,146,141)" /> - <polygon points="135,93 135,89 136,90 137,95 136,95" style="fill: rgb(179,146,141)" /> - <polygon points="192,201 192,200 194,200 194,202 194,203" style="fill: rgb(227,181,184)" /> - <polygon points="172,91 173,91 174,91 175,91 176,91" style="fill: rgb(210,158,160)" /> - <polygon points="173,241 173,240 174,243 173,243 173,242" style="fill: rgb(130,84,87)" /> - <polygon points="164,98 166,99 167,100 167,103 166,102" style="fill: rgb(119,114,120)" /> - <polygon points="107,208 112,212 113,215 113,216 109,211" style="fill: rgb(97,66,61)" /> - <polygon points="166,89 168,87 170,87 169,88 167,89" style="fill: rgb(76,48,47)" /> - <polygon points="121,78 121,76 122,76 123,76 122,77" style="fill: rgb(230,174,177)" /> - <polygon points="110,94 112,93 115,92 124,92 111,94" style="fill: rgb(153,115,106)" /> - <polygon points="69,201 72,195 72,199 70,204 69,204" style="fill: rgb(244,194,193)" /> - <polygon points="180,194 182,190 183,189 187,194 184,194" style="fill: rgb(232,184,182)" /> - <polygon points="183,57 185,56 187,57 186,58 185,58" style="fill: rgb(76,48,47)" /> - <polygon points="53,235 54,235 55,235 56,235 55,238" style="fill: rgb(237,189,185)" /> - <polygon points="197,101 197,103 197,99 197,102 197,100" style="fill: rgb(210,158,160)" /> - <polygon points="200,76 203,71 204,75 205,79 202,79" style="fill: rgb(87,76,74)" /> - <polygon points="192,78 192,77 193,79 193,80 193,81" style="fill: rgb(123,102,107)" /> - <polygon points="150,49 150,48 151,49 151,50 151,51" style="fill: rgb(17,11,15)" /> - <polygon points="196,243 200,239 199,240 198,241 197,242" style="fill: rgb(25,16,19)" /> - <polygon points="9,236 10,235 14,233 18,231 17,232" style="fill: rgb(178,201,219)" /> - <polygon points="174,240 175,241 176,242 176,243 175,244" style="fill: rgb(119,88,86)" /> - <polygon points="148,32 149,29 150,29 151,31 149,32" style="fill: rgb(104,87,80)" /> - <polygon points="204,135 205,134 206,134 206,135 206,137" style="fill: rgb(237,189,185)" /> - <polygon points="114,45 115,44 116,44 117,45 118,46" style="fill: rgb(58,47,51)" /> - <polygon points="192,109 193,108 194,108 193,111 192,112" style="fill: rgb(227,181,184)" /> - <polygon points="164,35 165,35 166,35 167,35 168,35" style="fill: rgb(119,88,86)" /> - <polygon points="199,63 201,64 201,66 201,67 199,65" style="fill: rgb(58,47,51)" /> - <polygon points="31,235 32,234 36,232 35,233 34,234" style="fill: rgb(237,189,185)" /> - <polygon points="138,29 140,29 141,29 142,29 139,30" style="fill: rgb(178,201,219)" /> - <polygon points="17,240 17,239 19,237 20,237 18,241" style="fill: rgb(34,28,28)" /> - <polygon points="113,107 113,106 117,108 116,108 114,108" style="fill: rgb(214,116,115)" /> - <polygon points="172,26 175,28 176,29 177,31 174,30" style="fill: rgb(123,102,107)" /> - <polygon points="189,134 190,131 190,134 190,136 189,138" style="fill: rgb(227,181,184)" /> - <polygon points="100,219 101,217 102,218 104,221 101,220" style="fill: rgb(179,146,141)" /> - <polygon points="61,193 61,192 64,193 63,194 62,194" style="fill: rgb(232,184,182)" /> - <polygon points="144,119 148,116 148,117 147,118 146,119" style="fill: rgb(238,179,181)" /> - <polygon points="196,210 197,208 200,204 202,211 197,212" style="fill: rgb(65,77,99)" /> - <polygon points="194,65 195,66 196,68 196,69 194,67" style="fill: rgb(153,115,106)" /> - <polygon points="139,139 140,139 141,139 142,139 143,139" style="fill: rgb(226,165,164)" /> - <polygon points="114,106 115,102 117,102 118,105 118,106" style="fill: rgb(130,84,87)" /> - <polygon points="132,101 133,101 134,102 134,103 133,103" style="fill: rgb(97,66,61)" /> - <polygon points="67,188 68,185 68,186 68,187 68,188" style="fill: rgb(242,202,203)" /> - <polygon points="94,214 95,213 96,214 97,215 98,216" style="fill: rgb(179,146,141)" /> - <polygon points="126,39 127,37 128,37 128,38 127,39" style="fill: rgb(74,64,62)" /> - <polygon points="110,55 111,54 113,55 114,56 112,56" style="fill: rgb(58,47,51)" /> - <polygon points="156,98 156,97 157,96 160,95 161,95" style="fill: rgb(214,116,115)" /> - <polygon points="152,28 153,28 154,28 154,29 153,30" style="fill: rgb(119,114,120)" /> - <polygon points="20,233 21,233 22,233 23,234 21,236" style="fill: rgb(58,47,51)" /> - <polygon points="146,113 155,118 156,119 156,120 147,119" style="fill: rgb(226,165,164)" /> - <polygon points="141,39 142,38 143,37 143,40 142,42" style="fill: rgb(74,64,62)" /> - <polygon points="184,154 184,153 185,154 185,155 184,155" style="fill: rgb(200,169,167)" /> - <polygon points="119,114 120,113 121,112 122,112 123,112" style="fill: rgb(227,181,184)" /> - <polygon points="67,199 68,196 69,196 69,199 67,202" style="fill: rgb(230,174,177)" /> - <polygon points="209,92 210,88 213,88 213,95 210,93" style="fill: rgb(104,87,80)" /> - <polygon points="83,218 83,217 84,217 85,218 84,219" style="fill: rgb(97,66,61)" /> - <polygon points="174,63 175,62 177,62 178,63 177,63" style="fill: rgb(230,174,177)" /> - <polygon points="55,247 56,246 57,246 58,246 56,247" style="fill: rgb(213,149,150)" /> - <polygon points="110,88 113,80 117,82 118,84 114,86" style="fill: rgb(230,174,177)" /> - <polygon points="168,59 169,59 170,59 171,59 172,59" style="fill: rgb(153,115,106)" /> - <polygon points="53,247 54,245 57,241 58,240 56,245" style="fill: rgb(226,165,164)" /> - <polygon points="197,201 197,197 197,198 197,199 197,200" style="fill: rgb(123,102,107)" /> - <polygon points="155,244 156,243 156,244 156,245 156,246" style="fill: rgb(200,169,167)" /> - <polygon points="199,92 201,89 201,92 201,94 201,95" style="fill: rgb(58,47,51)" /> - <polygon points="121,39 122,38 123,37 126,36 125,37" style="fill: rgb(104,87,80)" /> - <polygon points="136,57 136,56 137,56 138,56 139,56" style="fill: rgb(69,54,51)" /> - <polygon points="137,136 138,133 139,134 139,135 138,136" style="fill: rgb(230,174,177)" /> - <polygon points="213,76 214,76 214,78 214,79 213,77" style="fill: rgb(104,87,80)" /> - <polygon points="134,98 135,97 136,98 136,100 135,101" style="fill: rgb(153,115,106)" /> - <polygon points="155,33 157,32 163,35 161,35 155,34" style="fill: rgb(123,102,107)" /> - <polygon points="134,126 136,127 136,128 135,128 134,127" style="fill: rgb(214,116,115)" /> - <polygon points="7,241 8,240 10,238 10,240 9,241" style="fill: rgb(179,146,141)" /> - <polygon points="112,62 117,63 116,66 115,66 114,65" style="fill: rgb(119,88,86)" /> - <polygon points="124,60 127,59 128,59 129,59 124,61" style="fill: rgb(76,48,47)" /> - <polygon points="115,76 116,74 117,74 116,76 115,77" style="fill: rgb(230,174,177)" /> - <polygon points="130,86 131,86 133,89 133,91 132,90" style="fill: rgb(123,102,107)" /> - <polygon points="182,178 183,176 184,175 185,174 185,175" style="fill: rgb(230,174,177)" /> - <polygon points="205,139 208,135 208,139 208,140 205,141" style="fill: rgb(230,174,177)" /> - <polygon points="114,119 115,117 118,117 118,118 117,119" style="fill: rgb(227,181,184)" /> - <polygon points="111,52 113,50 114,51 114,53 111,53" style="fill: rgb(74,64,62)" /> - <polygon points="18,250 24,253 28,255 29,256 19,251" style="fill: rgb(119,114,120)" /> - <polygon points="199,105 199,107 199,103 199,106 199,104" style="fill: rgb(119,88,86)" /> - <polygon points="138,63 139,63 140,63 141,63 142,63" style="fill: rgb(232,184,182)" /> - <polygon points="21,249 23,245 24,247 23,248 22,249" style="fill: rgb(153,115,106)" /> - <polygon points="70,167 71,167 72,167 73,167 74,167" style="fill: rgb(227,181,184)" /> - <polygon points="164,43 164,42 165,42 166,42 165,43" style="fill: rgb(74,64,62)" /> - <polygon points="202,52 203,51 204,53 204,54 203,53" style="fill: rgb(66,55,53)" /> - <polygon points="131,54 132,52 138,54 139,55 135,56" style="fill: rgb(58,47,51)" /> - <polygon points="106,206 109,195 110,206 110,207 109,207" style="fill: rgb(153,115,106)" /> - <polygon points="164,145 165,145 169,147 167,147 166,147" style="fill: rgb(213,149,150)" /> - <polygon points="75,238 79,235 78,236 77,237 76,238" style="fill: rgb(239,244,248)" /> - <polygon points="76,170 76,168 78,168 78,169 77,171" style="fill: rgb(230,174,177)" /> - <polygon points="201,117 202,115 203,118 203,119 202,119" style="fill: rgb(69,54,51)" /> - <polygon points="195,78 197,78 199,79 199,80 195,81" style="fill: rgb(87,76,74)" /> - <polygon points="217,117 217,119 217,116 217,118 217,120" style="fill: rgb(242,202,203)" /> - <polygon points="9,263 11,260 12,260 11,262 10,263" style="fill: rgb(119,114,120)" /> - <polygon points="205,47 211,52 211,55 210,54 207,50" style="fill: rgb(178,201,219)" /> - <polygon points="105,80 105,79 106,78 107,77 107,82" style="fill: rgb(69,54,51)" /> - <polygon points="191,69 192,69 193,69 194,70 193,72" style="fill: rgb(104,87,80)" /> - <polygon points="160,140 163,136 164,135 165,136 163,140" style="fill: rgb(227,181,184)" /> - <polygon points="188,73 188,72 189,78 189,79 188,77" style="fill: rgb(210,158,160)" /> - <polygon points="81,168 82,168 83,168 86,169 83,169" style="fill: rgb(227,181,184)" /> - <polygon points="118,45 118,44 122,47 123,49 122,50" style="fill: rgb(74,64,62)" /> - <polygon points="118,74 122,74 124,75 120,76 118,75" style="fill: rgb(238,179,181)" /> - <polygon points="32,252 32,251 33,252 33,253 33,254" style="fill: rgb(237,189,185)" /> - <polygon points="149,59 164,57 166,57 167,58 158,59" style="fill: rgb(97,66,61)" /> - <polygon points="29,243 31,243 34,243 34,244 33,246" style="fill: rgb(244,194,193)" /> - <polygon points="153,146 154,146 157,148 154,148 153,147" style="fill: rgb(226,165,164)" /> - <polygon points="195,55 195,54 198,59 198,60 196,57" style="fill: rgb(25,16,19)" /> - <polygon points="46,254 47,251 48,250 49,250 47,253" style="fill: rgb(230,174,177)" /> - <polygon points="203,94 204,94 204,95 204,96 203,96" style="fill: rgb(87,76,74)" /> - <polygon points="180,221 181,222 182,225 182,229 182,230" style="fill: rgb(17,11,15)" /> - <polygon points="142,118 143,118 144,118 145,118 146,118" style="fill: rgb(238,179,181)" /> - <polygon points="292,262 294,264 296,267 295,266 294,265" style="fill: rgb(178,201,219)" /> - <polygon points="158,30 159,28 161,29 161,31 160,32" style="fill: rgb(58,47,51)" /> - <polygon points="122,90 122,89 123,87 124,87 124,88" style="fill: rgb(69,54,51)" /> - <polygon points="151,138 152,138 153,138 156,139 154,139" style="fill: rgb(213,149,150)" /> - <polygon points="75,218 76,216 77,216 78,216 77,219" style="fill: rgb(230,174,177)" /> - <polygon points="78,167 79,167 80,167 81,167 82,167" style="fill: rgb(228,193,189)" /> - <polygon points="128,278 130,277 131,277 131,278 130,280" style="fill: rgb(65,77,99)" /> - <polygon points="258,298 259,297 260,297 260,298 259,298" style="fill: rgb(65,77,99)" /> - <polygon points="26,239 28,236 28,237 27,238" style="fill: rgb(210,158,160)" /> - <polygon points="105,76 107,76 108,77 106,77" style="fill: rgb(87,76,74)" /> - <polygon points="26,243 29,245 29,247 29,248" style="fill: rgb(230,174,177)" /> - <polygon points="104,227 105,228 105,229 104,228" style="fill: rgb(97,66,61)" /> - <polygon points="177,190 178,189 179,189 178,191" style="fill: rgb(227,181,184)" /> - <polygon points="155,268 156,268 156,270 155,270" style="fill: rgb(239,244,248)" /> - <polygon points="210,119 212,121 211,122 210,120" style="fill: rgb(238,179,181)" /> - <polygon points="194,207 198,202 198,203 197,205" style="fill: rgb(65,77,99)" /> - <polygon points="78,195 79,195 79,199 78,197" style="fill: rgb(230,174,177)" /> - <polygon points="192,62 192,59 194,61 194,63" style="fill: rgb(69,54,51)" /> - <polygon points="75,228 79,225 79,226 78,228" style="fill: rgb(210,158,160)" /> - <polygon points="158,42 160,40 160,41 159,42" style="fill: rgb(58,47,51)" /> - <polygon points="176,163 177,163 177,164 176,165" style="fill: rgb(210,158,160)" /> - <polygon points="82,219 82,218 82,217 83,216" style="fill: rgb(153,115,106)" /> - <polygon points="162,86 164,86 165,87 163,89" style="fill: rgb(69,54,51)" /> - <polygon points="119,52 120,49 121,50 120,51" style="fill: rgb(34,28,28)" /> - <polygon points="164,139 165,138 169,142 169,143" style="fill: rgb(213,149,150)" /> - <polygon points="185,233 185,236 185,235 185,234" style="fill: rgb(119,114,120)" /> - <polygon points="110,89 112,87 113,86 113,87" style="fill: rgb(223,185,184)" /> - <polygon points="107,100 108,98 108,99 108,100" style="fill: rgb(87,76,74)" /> - <polygon points="106,90 107,88 107,90 106,91" style="fill: rgb(66,55,53)" /> - <polygon points="103,226 103,227 103,224 103,225" style="fill: rgb(104,87,80)" /> - <polygon points="88,174 89,174 90,174 91,174" style="fill: rgb(210,158,160)" /> - <polygon points="199,101 199,99 199,102 199,100" style="fill: rgb(104,87,80)" /> - <polygon points="187,172 188,170 188,171 188,172" style="fill: rgb(226,165,164)" /> - <polygon points="192,58 194,57 194,58 193,59" style="fill: rgb(58,47,51)" /> - <polygon points="116,290 117,290 118,291 116,291" style="fill: rgb(119,114,120)" /> - <polygon points="195,192 195,193 195,190 195,191" style="fill: rgb(210,158,160)" /> - <polygon points="195,59 196,58 197,61 196,61" style="fill: rgb(29,19,18)" /> - <polygon points="33,256 33,255 34,254 34,257" style="fill: rgb(228,193,189)" /> - <polygon points="64,229 65,227 66,227 67,227" style="fill: rgb(232,184,182)" /> - <polygon points="164,89 164,88 166,87 166,88" style="fill: rgb(74,64,62)" /> - <polygon points="182,55 184,56 185,57 182,56" style="fill: rgb(58,47,51)" /> - <polygon points="182,222 183,223 183,225 183,226" style="fill: rgb(25,16,19)" /> - <polygon points="215,101 216,99 216,100 215,103" style="fill: rgb(178,201,219)" /> - <polygon points="151,278 152,278 152,279 151,279" style="fill: rgb(65,77,99)" /> - <polygon points="129,141 132,137 132,141 132,142" style="fill: rgb(210,158,160)" /> - <polygon points="214,121 215,121 215,122 214,123" style="fill: rgb(214,116,115)" /> - <polygon points="172,246 173,244 174,244 173,245" style="fill: rgb(123,102,107)" /> - <polygon points="160,53 163,55 161,55 160,54" style="fill: rgb(58,47,51)" /> - <polygon points="166,149 167,149 168,149 169,149" style="fill: rgb(230,174,177)" /> - <polygon points="106,172 107,172 108,172 109,172" style="fill: rgb(200,169,167)" /> - <polygon points="163,186 163,185 164,182 166,183" style="fill: rgb(210,158,160)" /> - <polygon points="148,122 149,121 150,121 149,122" style="fill: rgb(97,66,61)" /> - <polygon points="100,222 100,220 101,221 101,222" style="fill: rgb(239,244,248)" /> - <polygon points="110,184 111,184 111,185 111,186" style="fill: rgb(200,169,167)" /> - <polygon points="212,112 213,112 214,113 214,114" style="fill: rgb(130,84,87)" /> - <polygon points="0,251 2,249 1,250 3,248" style="fill: rgb(119,114,120)" /> - <polygon points="160,25 161,25 162,25 163,25" style="fill: rgb(179,146,141)" /> - <polygon points="108,51 109,50 109,51 108,52" style="fill: rgb(200,169,167)" /> - <polygon points="164,138 164,137 164,136 165,137" style="fill: rgb(210,158,160)" /> - <polygon points="132,55 133,55 134,55 134,56" style="fill: rgb(34,28,28)" /> - <polygon points="209,68 211,69 211,70 210,71" style="fill: rgb(66,55,53)" /> - <polygon points="125,94 126,94 127,95 126,95" style="fill: rgb(226,165,164)" /> - <polygon points="152,133 152,131 153,133 153,134" style="fill: rgb(227,181,184)" /> - <polygon points="185,147 186,146 187,145 186,147" style="fill: rgb(227,181,184)" /> - <polygon points="127,102 128,101 128,104 128,105" style="fill: rgb(119,114,120)" /> - <polygon points="174,241 175,242 175,243 174,242" style="fill: rgb(119,88,86)" /> - <polygon points="138,108 139,108 140,111 139,110" style="fill: rgb(210,158,160)" /> - <polygon points="172,95 173,95 174,95 175,96" style="fill: rgb(214,116,115)" /> - <polygon points="56,188 56,187 57,185 57,189" style="fill: rgb(223,185,184)" /> - <polygon points="200,86 201,86 201,87 201,88" style="fill: rgb(66,55,53)" /> - <polygon points="155,87 156,86 157,86 155,90" style="fill: rgb(130,84,87)" /> - <polygon points="137,61 142,60 143,60 148,61" style="fill: rgb(179,146,141)" /> - <polygon points="133,122 133,121 134,124 133,123" style="fill: rgb(214,116,115)" /> - <polygon points="159,208 164,208 164,209 160,209" style="fill: rgb(230,174,177)" /> - <polygon points="90,212 91,212 93,213 92,213" style="fill: rgb(153,115,106)" /> - <polygon points="125,52 126,53 125,54 125,53" style="fill: rgb(74,64,62)" /> - <polygon points="188,39 190,41 189,41 188,40" style="fill: rgb(66,55,53)" /> - <polygon points="135,140 136,139 137,139 136,140" style="fill: rgb(227,181,184)" /> - <polygon points="120,91 121,91 122,91 123,91" style="fill: rgb(104,87,80)" /> - <polygon points="126,65 127,63 129,62 130,62" style="fill: rgb(179,146,141)" /> - <polygon points="145,229 146,230 147,231 148,232" style="fill: rgb(179,146,141)" /> - <polygon points="161,208 161,207 162,207 162,208" style="fill: rgb(227,181,184)" /> - <polygon points="209,109 210,108 211,108 209,110" style="fill: rgb(130,84,87)" /> - <polygon points="44,217 45,216 46,216 45,217" style="fill: rgb(223,185,184)" /> - <polygon points="161,237 162,237 161,239 161,238" style="fill: rgb(226,165,164)" /> - <polygon points="108,176 109,176 109,177 109,178" style="fill: rgb(76,48,47)" /> - <polygon points="154,75 154,74 155,73 155,74" style="fill: rgb(244,194,193)" /> - <polygon points="127,84 128,84 129,84 130,84" style="fill: rgb(230,174,177)" /> - <polygon points="117,222 119,224 120,225 118,223" style="fill: rgb(179,146,141)" /> - <polygon points="131,83 132,84 133,85 131,84" style="fill: rgb(226,165,164)" /> - <polygon points="29,230 30,229 31,228 32,227" style="fill: rgb(239,244,248)" /> - <polygon points="200,128 202,127 202,128 201,129" style="fill: rgb(153,115,106)" /> - <polygon points="184,45 187,49 186,52 184,47" style="fill: rgb(34,28,28)" /> - <polygon points="110,66 110,64 111,64 113,66" style="fill: rgb(87,76,74)" /> - <polygon points="121,102 127,105 124,105 122,103" style="fill: rgb(104,87,80)" /> - <polygon points="192,174 193,173 193,176 192,175" style="fill: rgb(227,181,184)" /> - <polygon points="195,92 195,91 196,93 196,95" style="fill: rgb(210,158,160)" /> - <polygon points="184,229 186,231 186,237 184,241" style="fill: rgb(65,77,99)" /> - <polygon points="108,105 108,107 108,104 108,106" style="fill: rgb(179,146,141)" /> - <polygon points="211,66 212,65 212,66 212,67" style="fill: rgb(87,76,74)" /> - <polygon points="197,115 198,115 198,116 197,116" style="fill: rgb(210,158,160)" /> - <polygon points="184,174 185,173 187,171 186,173" style="fill: rgb(226,165,164)" /> - <polygon points="114,226 117,224 117,225 116,226" style="fill: rgb(76,48,47)" /> - <polygon points="203,290 204,290 205,290 205,291" style="fill: rgb(119,114,120)" /> - <polygon points="156,241 158,239 160,238 159,239" style="fill: rgb(200,169,167)" /> - <polygon points="282,256 284,257 285,258 283,257" style="fill: rgb(178,201,219)" /> - <polygon points="194,51 195,51 196,52 194,52" style="fill: rgb(25,16,19)" /> - <polygon points="41,275 41,273 41,274 41,272" style="fill: rgb(65,77,99)" /> - <polygon points="131,37 133,39 132,39 131,38" style="fill: rgb(87,76,74)" /> - <polygon points="185,110 187,109 187,110 185,111" style="fill: rgb(230,174,177)" /> - <polygon points="167,113 169,111 170,111 170,113" style="fill: rgb(230,174,177)" /> - <polygon points="134,34 135,34 136,34 135,35" style="fill: rgb(104,87,80)" /> - <polygon points="101,171 102,171 103,171 104,171" style="fill: rgb(237,189,185)" /> - <polygon points="109,54 112,57 111,57 109,56" style="fill: rgb(74,64,62)" /> - <polygon points="179,89 180,89 182,90 181,90" style="fill: rgb(153,115,106)" /> - <polygon points="71,223 72,220 73,219 72,222" style="fill: rgb(237,189,185)" /> - <polygon points="125,93 126,93 127,93 128,93" style="fill: rgb(179,146,141)" /> - <polygon points="114,107 119,104 120,107 120,108" style="fill: rgb(153,115,106)" /> - <polygon points="155,233 156,233 157,234 156,234" style="fill: rgb(234,196,195)" /> - <polygon points="125,101 126,101 126,102 126,103" style="fill: rgb(25,16,19)" /> - <polygon points="176,141 177,140 178,140 178,141" style="fill: rgb(228,193,189)" /> - <polygon points="136,31 137,31 138,31 139,31" style="fill: rgb(123,102,107)" /> - <polygon points="110,41 111,41 111,42 110,42" style="fill: rgb(179,146,141)" /> - <polygon points="163,228 166,225 172,221 169,224" style="fill: rgb(223,185,184)" /> - <polygon points="153,127 155,127 156,127 155,130" style="fill: rgb(210,158,160)" /> - <polygon points="184,91 185,89 186,90 186,91" style="fill: rgb(123,102,107)" /> - <polygon points="180,175 181,174 181,175 180,176" style="fill: rgb(213,149,150)" /> - <polygon points="196,164 196,165 196,166 196,167" style="fill: rgb(179,146,141)" /> - <polygon points="110,131 110,132 110,129 110,130" style="fill: rgb(227,181,184)" /> - <polygon points="106,217 106,218 106,219 106,220" style="fill: rgb(214,116,115)" /> - <polygon points="105,54 108,53 107,55 106,56" style="fill: rgb(179,146,141)" /> - <polygon points="204,105 204,103 205,105 205,106" style="fill: rgb(87,76,74)" /> - <polygon points="127,50 129,53 128,54 127,52" style="fill: rgb(104,87,80)" /> - <polygon points="195,64 200,67 201,68 198,68" style="fill: rgb(74,64,62)" /> - <polygon points="185,199 185,198 185,197 187,197" style="fill: rgb(237,189,185)" /> - <polygon points="189,169 189,168 190,166 191,165" style="fill: rgb(227,181,184)" /> - <polygon points="104,279 106,277 107,278 107,279" style="fill: rgb(65,77,99)" /> - <polygon points="181,51 181,50 182,50 182,51" style="fill: rgb(58,47,51)" /> - <polygon points="117,94 118,94 118,96 117,95" style="fill: rgb(230,174,177)" /> - <polygon points="111,180 111,181 111,182 111,183" style="fill: rgb(179,146,141)" /> - <polygon points="104,65 105,63 106,64 105,65" style="fill: rgb(179,146,141)" /> - <polygon points="92,180 93,180 94,180 95,180" style="fill: rgb(234,196,195)" /> - <polygon points="210,72 212,70 212,71 211,72" style="fill: rgb(74,64,62)" /> - <polygon points="202,99 202,101 202,100 202,102" style="fill: rgb(66,55,53)" /> - <polygon points="138,91 139,92 139,94 139,95" style="fill: rgb(213,149,150)" /> - <polygon points="86,197 87,197 92,197 91,199" style="fill: rgb(213,149,150)" /> - <polygon points="81,185 82,184 83,184 82,185" style="fill: rgb(226,165,164)" /> - <polygon points="62,234 62,233 63,232 64,232" style="fill: rgb(230,174,177)" /> - <polygon points="18,237 20,235 21,234 19,236" style="fill: rgb(34,28,28)" /> - <polygon points="161,141 162,141 163,141 164,141" style="fill: rgb(213,149,150)" /> - <polygon points="56,298 57,298 57,299 56,299" style="fill: rgb(65,77,99)" /> - <polygon points="158,45 160,45 159,46 158,46" style="fill: rgb(58,47,51)" /> - <polygon points="166,62 168,61 169,61 167,62" style="fill: rgb(226,165,164)" /> - <polygon points="81,183 81,182 82,182 83,183" style="fill: rgb(238,179,181)" /> - <polygon points="178,43 178,41 179,42 179,44" style="fill: rgb(104,87,80)" /> - <polygon points="152,57 153,56 154,55 153,57" style="fill: rgb(97,66,61)" /> - <polygon points="207,94 209,95 208,97 207,98" style="fill: rgb(66,55,53)" /> - <polygon points="201,108 203,106 204,107 204,109" style="fill: rgb(66,55,53)" /> - <polygon points="93,227 94,226 96,224 95,225" style="fill: rgb(239,244,248)" /> - <polygon points="147,230 149,229 149,230 149,231" style="fill: rgb(226,165,164)" /> - <polygon points="163,156 166,154 165,156 164,157" style="fill: rgb(232,184,182)" /> - <polygon points="57,187 58,184 58,185 58,187" style="fill: rgb(223,185,184)" /> - <polygon points="162,56 163,56 163,57 162,57" style="fill: rgb(66,55,53)" /> - <polygon points="222,226 222,227 222,228 222,225" style="fill: rgb(65,77,99)" /> - <polygon points="188,64 189,63 190,63 191,63" style="fill: rgb(104,87,80)" /> - <polygon points="164,222 164,221 166,220 166,221" style="fill: rgb(242,202,203)" /> - <polygon points="206,113 207,110 208,110 206,114" style="fill: rgb(153,115,106)" /> - <polygon points="119,84 121,83 122,83 123,84" style="fill: rgb(230,174,177)" /> - <polygon points="111,47 112,48 112,50 111,51" style="fill: rgb(104,87,80)" /> - <polygon points="193,76 196,77 196,78 194,80" style="fill: rgb(104,87,80)" /> - <polygon points="155,86 156,85 157,85 158,85" style="fill: rgb(153,115,106)" /> - <polygon points="193,192 194,192 194,193 193,193" style="fill: rgb(226,165,164)" /> - <polygon points="142,127 143,127 144,127 145,127" style="fill: rgb(230,174,177)" /> - <polygon points="89,178 90,178 92,179 91,179" style="fill: rgb(244,194,193)" /> - <polygon points="196,287 197,287 197,288 196,288" style="fill: rgb(119,114,120)" /> - <polygon points="167,90 174,89 176,90 168,90" style="fill: rgb(87,76,74)" /> - <polygon points="156,223 158,222 157,224 156,224" style="fill: rgb(237,189,185)" /> - <polygon points="165,33 166,33 166,34 165,34" style="fill: rgb(123,102,107)" /> - <polygon points="113,206 113,209 113,208 113,207" style="fill: rgb(179,146,141)" /> - <polygon points="148,51 148,50 149,47 149,50" style="fill: rgb(34,28,28)" /> - <polygon points="72,170 73,170 75,171 74,171" style="fill: rgb(210,158,160)" /> - <polygon points="107,189 108,187 108,188 107,190" style="fill: rgb(214,116,115)" /> - <polygon points="182,92 183,92 185,94 183,93" style="fill: rgb(200,169,167)" /> - <polygon points="149,55 151,54 151,55 151,56" style="fill: rgb(58,47,51)" /> - <polygon points="123,239 124,240 124,243 123,243" style="fill: rgb(178,201,219)" /> - <polygon points="181,44 182,45 183,49 181,47" style="fill: rgb(104,87,80)" /> - <polygon points="126,231 126,230 126,229 127,229" style="fill: rgb(65,77,99)" /> - <polygon points="200,213 201,213 201,214 201,215" style="fill: rgb(65,77,99)" /> - <polygon points="115,55 116,55 117,56 115,56" style="fill: rgb(74,64,62)" /> - <polygon points="188,60 189,58 190,59 189,60" style="fill: rgb(69,54,51)" /> - <polygon points="178,229 178,228 179,228 180,228" style="fill: rgb(119,114,120)" /> - <polygon points="141,30 142,30 143,30 144,30" style="fill: rgb(123,102,107)" /> - <polygon points="90,177 91,177 96,178 92,178" style="fill: rgb(238,179,181)" /> - <polygon points="140,115 142,113 143,113 142,114" style="fill: rgb(237,189,185)" /> - <polygon points="54,250 56,248 58,247 57,248" style="fill: rgb(153,115,106)" /> - <polygon points="80,169 80,168 82,169 83,170" style="fill: rgb(232,184,182)" /> - <polygon points="25,239 26,236 26,237 26,238" style="fill: rgb(179,146,141)" /> - <polygon points="175,58 177,57 178,57 176,58" style="fill: rgb(104,87,80)" /> - <polygon points="210,124 211,124 212,126 212,127" style="fill: rgb(213,149,150)" /> - <polygon points="158,23 159,23 159,24 158,24" style="fill: rgb(178,201,219)" /> - <polygon points="128,73 130,71 134,71 134,72" style="fill: rgb(242,202,203)" /> - <polygon points="180,217 181,216 182,215 181,217" style="fill: rgb(123,102,107)" /> - <polygon points="203,287 204,287 205,288 204,288" style="fill: rgb(119,114,120)" /> - <polygon points="0,248 0,247 2,244 4,244" style="fill: rgb(179,146,141)" /> - <polygon points="93,179 94,179 95,179 96,179" style="fill: rgb(237,189,185)" /> - <polygon points="212,103 212,102 213,102 213,103" style="fill: rgb(104,87,80)" /> - <polygon points="123,89 125,88 126,88 124,89" style="fill: rgb(66,55,53)" /> - <polygon points="166,41 169,39 168,40 167,41" style="fill: rgb(104,87,80)" /> - <polygon points="119,43 120,42 120,43 120,44" style="fill: rgb(34,28,28)" /> - <polygon points="146,116 146,115 147,116 146,117" style="fill: rgb(242,202,203)" /> - <polygon points="117,109 118,108 119,108 119,109" style="fill: rgb(179,146,141)" /> - <polygon points="203,132 204,131 205,131 204,132" style="fill: rgb(214,116,115)" /> - <polygon points="168,152 168,151 169,150 169,151" style="fill: rgb(232,184,182)" /> - <polygon points="118,121 119,120 120,120 119,121" style="fill: rgb(232,184,182)" /> - <polygon points="189,243 189,242 190,241 190,243" style="fill: rgb(239,244,248)" /> - <polygon points="17,235 19,233 20,232 21,232" style="fill: rgb(65,77,99)" /> - <polygon points="117,288 118,286 119,286 118,288" style="fill: rgb(119,114,120)" /> - <polygon points="180,65 181,65 182,66 181,66" style="fill: rgb(237,189,185)" /> - <polygon points="151,225 152,225 152,226 152,227" style="fill: rgb(223,185,184)" /> - <polygon points="81,187 82,187 83,187 84,187" style="fill: rgb(232,184,182)" /> - <polygon points="109,46 110,50 110,51 109,52" style="fill: rgb(119,114,120)" /> - <polygon points="146,229 147,228 148,228 148,229" style="fill: rgb(210,158,160)" /> - <polygon points="161,34 162,33 164,33 164,34" style="fill: rgb(104,87,80)" /> - <polygon points="37,231 38,230 40,229 39,230" style="fill: rgb(232,184,182)" /> - <polygon points="182,244 182,243 183,241 183,243" style="fill: rgb(17,11,15)" /> - <polygon points="157,137 159,136 161,139 159,139" style="fill: rgb(227,181,184)" /> - <polygon points="153,222 155,219 155,220 154,221" style="fill: rgb(239,244,248)" /> - <polygon points="148,93 148,92 149,91 149,93" style="fill: rgb(238,179,181)" /> - <polygon points="164,199 165,198 167,198 166,199" style="fill: rgb(228,193,189)" /> - <polygon points="95,215 96,215 97,216 98,217" style="fill: rgb(178,201,219)" /> - <polygon points="66,178 66,176 67,177 67,178" style="fill: rgb(238,179,181)" /> - <polygon points="85,172 86,172 87,172 88,172" style="fill: rgb(232,184,182)" /> - <polygon points="167,102 170,102 169,103 168,103" style="fill: rgb(104,87,80)" /> - <polygon points="61,179 61,178 63,178 63,179" style="fill: rgb(237,189,185)" /> - <polygon points="150,35 153,32 154,33 154,34" style="fill: rgb(104,87,80)" /> - <polygon points="109,119 109,121 109,118 109,120" style="fill: rgb(227,181,184)" /> - <polygon points="120,105 120,104 122,106 121,106" style="fill: rgb(200,169,167)" /> - <polygon points="130,57 130,58 130,55 130,56" style="fill: rgb(104,87,80)" /> - <polygon points="177,102 178,101 179,102 178,102" style="fill: rgb(97,66,61)" /> - <polygon points="149,45 150,46 151,47 149,46" style="fill: rgb(58,47,51)" /> - <polygon points="162,37 165,37 165,38 163,38" style="fill: rgb(87,76,74)" /> - <polygon points="200,105 200,103 201,104 201,105" style="fill: rgb(87,76,74)" /> - <polygon points="78,203 79,203 80,203 78,204" style="fill: rgb(244,194,193)" /> - <polygon points="204,141 206,141 207,141 205,142" style="fill: rgb(226,165,164)" /> - <polygon points="111,211 112,207 112,210 112,211" style="fill: rgb(130,84,87)" /> - <polygon points="174,61 175,61 176,61 177,61" style="fill: rgb(210,158,160)" /> - <polygon points="165,86 166,86 167,86 168,86" style="fill: rgb(97,66,61)" /> - <polygon points="111,193 112,192 112,194 111,194" style="fill: rgb(178,201,219)" /> - <polygon points="210,64 211,64 211,65 210,65" style="fill: rgb(74,64,62)" /> - <polygon points="104,201 105,200 105,202 104,203" style="fill: rgb(230,174,177)" /> - <polygon points="104,56 105,56 106,57 105,58" style="fill: rgb(200,169,167)" /> - <polygon points="183,44 183,42 185,43 183,46" style="fill: rgb(69,54,51)" /> - <polygon points="135,43 136,44 136,45 135,44" style="fill: rgb(74,64,62)" /> - <polygon points="202,67 203,66 204,67 203,68" style="fill: rgb(29,19,18)" /> - <polygon points="54,197 54,195 55,194 55,195" style="fill: rgb(227,181,184)" /> - <polygon points="167,165 167,164 170,163 168,165" style="fill: rgb(210,158,160)" /> - <polygon points="100,202 103,204 103,205 100,203" style="fill: rgb(214,116,115)" /> - <polygon points="191,35 194,37 193,37 192,36" style="fill: rgb(178,201,219)" /> - <polygon points="130,48 131,48 131,49 131,50" style="fill: rgb(58,47,51)" /> - <polygon points="210,131 211,129 212,132 211,133" style="fill: rgb(213,149,150)" /> - <polygon points="79,227 80,224 80,225 80,226" style="fill: rgb(210,158,160)" /> - <polygon points="76,211 77,210 78,210 76,212" style="fill: rgb(237,189,185)" /> - <polygon points="177,125 179,125 179,126 178,126" style="fill: rgb(244,194,193)" /> - <polygon points="167,49 167,47 167,46 168,46" style="fill: rgb(17,11,15)" /> - <polygon points="157,50 157,49 157,48 158,49" style="fill: rgb(58,47,51)" /> - <polygon points="213,107 213,106 214,104 214,105" style="fill: rgb(123,102,107)" /> - <polygon points="160,61 161,61 162,61 163,61" style="fill: rgb(179,146,141)" /> - <polygon points="175,85 176,85 177,85 178,85" style="fill: rgb(153,115,106)" /> - <polygon points="167,128 167,127 169,130 168,130" style="fill: rgb(237,189,185)" /> - <polygon points="165,160 166,159 167,158 167,159" style="fill: rgb(234,196,195)" /> - <polygon points="198,105 198,107 198,106 198,104" style="fill: rgb(179,146,141)" /> - <polygon points="205,108 206,107 208,107 208,108" style="fill: rgb(97,66,61)" /> - <polygon points="126,47 127,46 129,47 126,48" style="fill: rgb(66,55,53)" /> - <polygon points="139,117 140,116 141,116 140,117" style="fill: rgb(242,202,203)" /> - <polygon points="67,196 68,195 69,195 67,198" style="fill: rgb(227,181,184)" /> - <polygon points="80,188 81,188 82,188 83,188" style="fill: rgb(234,196,195)" /> - <polygon points="101,214 103,213 103,214 102,215" style="fill: rgb(226,165,164)" /> - <polygon points="181,38 182,36 184,37 183,38" style="fill: rgb(74,64,62)" /> - <polygon points="114,39 114,37 115,36 116,39" style="fill: rgb(119,114,120)" /> - <polygon points="176,222 177,221 178,220 178,221" style="fill: rgb(87,76,74)" /> - <polygon points="99,188 104,186 103,187 102,188" style="fill: rgb(238,179,181)" /> - <polygon points="173,246 174,245 176,246 174,248" style="fill: rgb(119,114,120)" /> - <polygon points="67,182 67,183 67,184 67,185" style="fill: rgb(244,194,193)" /> - <polygon points="172,48 173,47 173,49 173,50" style="fill: rgb(29,19,18)" /> - <polygon points="166,135 169,138 168,137 167,136" style="fill: rgb(227,181,184)" /> - <polygon points="211,104 212,104 213,104 212,106" style="fill: rgb(87,76,74)" /> - <polygon points="175,42 176,43 177,44 176,44" style="fill: rgb(74,64,62)" /> - <polygon points="136,102 137,103 136,104 136,101" style="fill: rgb(153,115,106)" /> - <polygon points="194,197 194,196 195,198 194,198" style="fill: rgb(226,165,164)" /> - <polygon points="168,112 168,109 169,109 169,110" style="fill: rgb(230,174,177)" /> - <polygon points="200,113 200,111 200,110 200,112" style="fill: rgb(87,76,74)" /> - <polygon points="169,159 170,158 171,157 172,156" style="fill: rgb(237,189,185)" /> - <polygon points="211,60 211,63 211,61 211,62" style="fill: rgb(87,76,74)" /> - <polygon points="113,198 113,197 113,196 113,199" style="fill: rgb(178,201,219)" /> - <polygon points="163,40 166,39 167,39 163,41" style="fill: rgb(123,102,107)" /> - <polygon points="144,57 146,56 145,57" style="fill: rgb(58,47,51)" /> - <polygon points="103,76 104,75 103,77" style="fill: rgb(66,55,53)" /> - <polygon points="191,116 192,116 192,117" style="fill: rgb(227,181,184)" /> - <polygon points="110,188 110,189 110,190" style="fill: rgb(76,48,47)" /> - <polygon points="189,166 190,165 191,164" style="fill: rgb(210,158,160)" /> - <polygon points="107,94 107,93 107,95" style="fill: rgb(69,54,51)" /> - <polygon points="205,58 207,57 206,59" style="fill: rgb(66,55,53)" /> - <polygon points="189,184 190,184 190,185" style="fill: rgb(227,181,184)" /> - <polygon points="202,44 203,44 204,44" style="fill: rgb(178,201,219)" /> - <polygon points="141,31 142,31 141,32" style="fill: rgb(74,64,62)" /> - <polygon points="129,85 130,85 131,85" style="fill: rgb(179,146,141)" /> - <polygon points="102,172 103,172 102,173" style="fill: rgb(244,194,193)" /> - <polygon points="173,87 175,86 176,88" style="fill: rgb(87,76,74)" /> - <polygon points="132,34 133,33 134,33" style="fill: rgb(74,64,62)" /> - <polygon points="178,178 178,177 178,176" style="fill: rgb(213,149,150)" /> - <polygon points="108,113 108,111 108,112" style="fill: rgb(210,158,160)" /> - <polygon points="169,105 170,104 171,105" style="fill: rgb(153,115,106)" /> - <polygon points="164,142 165,141 166,140" style="fill: rgb(214,116,115)" /> - <polygon points="46,214 47,213 48,215" style="fill: rgb(237,189,185)" /> - <polygon points="142,252 144,255 142,253" style="fill: rgb(65,77,99)" /> - <polygon points="203,141 204,142 203,142" style="fill: rgb(210,158,160)" /> - <polygon points="206,82 206,80 206,81" style="fill: rgb(58,47,51)" /> - <polygon points="200,55 201,54 200,56" style="fill: rgb(58,47,51)" /> - <polygon points="214,125 214,124 215,123" style="fill: rgb(213,149,150)" /> - <polygon points="132,104 133,104 132,105" style="fill: rgb(130,84,87)" /> - <polygon points="202,41 202,42 202,40" style="fill: rgb(178,201,219)" /> - <polygon points="216,72 216,71 216,73" style="fill: rgb(178,201,219)" /> - <polygon points="98,214 99,215 100,216" style="fill: rgb(214,116,115)" /> - <polygon points="175,88 177,89 176,89" style="fill: rgb(87,76,74)" /> - <polygon points="186,49 188,50 187,50" style="fill: rgb(34,28,28)" /> - <polygon points="111,201 111,202 111,200" style="fill: rgb(76,48,47)" /> - <polygon points="83,167 84,167 85,167" style="fill: rgb(234,196,195)" /> - <polygon points="208,59 209,59 209,60" style="fill: rgb(87,76,74)" /> - <polygon points="114,80 114,79 115,80" style="fill: rgb(230,174,177)" /> - <polygon points="150,233 152,231 153,234" style="fill: rgb(227,181,184)" /> - <polygon points="84,235 85,235 85,236" style="fill: rgb(179,146,141)" /> - <polygon points="140,127 143,128 141,128" style="fill: rgb(238,179,181)" /> - <polygon points="111,76 111,75 112,76" style="fill: rgb(130,84,87)" /> - <polygon points="123,144 123,143 124,144" style="fill: rgb(227,181,184)" /> - <polygon points="139,119 140,119 141,119" style="fill: rgb(230,174,177)" /> - <polygon points="124,96 125,96 126,96" style="fill: rgb(213,149,150)" /> - <polygon points="198,117 198,119 198,118" style="fill: rgb(213,149,150)" /> - <polygon points="161,213 163,214 162,214" style="fill: rgb(237,189,185)" /> - <polygon points="30,251 30,253 30,252" style="fill: rgb(227,181,184)" /> - <polygon points="179,141 180,141 181,141" style="fill: rgb(237,189,185)" /> - <polygon points="92,186 93,186 94,186" style="fill: rgb(230,174,177)" /> - <polygon points="97,191 98,191 99,192" style="fill: rgb(230,174,177)" /> - <polygon points="151,29 154,31 153,31" style="fill: rgb(123,102,107)" /> - <polygon points="194,165 194,166 194,167" style="fill: rgb(230,174,177)" /> - <polygon points="152,87 154,85 153,86" style="fill: rgb(210,158,160)" /> - <polygon points="20,291 22,291 21,291" style="fill: rgb(65,77,99)" /> - <polygon points="119,48 120,48 121,49" style="fill: rgb(58,47,51)" /> - <polygon points="141,57 143,58 142,58" style="fill: rgb(87,76,74)" /> - <polygon points="112,40 113,39 112,41" style="fill: rgb(178,201,219)" /> - <polygon points="140,128 141,130 140,132" style="fill: rgb(227,181,184)" /> - <polygon points="206,121 206,119 207,121" style="fill: rgb(97,66,61)" /> - <polygon points="174,220 175,219 174,221" style="fill: rgb(179,146,141)" /> - <polygon points="169,146 169,145 169,144" style="fill: rgb(214,116,115)" /> - <polygon points="116,87 117,87 118,87" style="fill: rgb(153,115,106)" /> - <polygon points="133,232 133,233 133,231" style="fill: rgb(22,39,69)" /> - <polygon points="207,105 207,104 209,107" style="fill: rgb(87,76,74)" /> - <polygon points="136,35 137,36 136,36" style="fill: rgb(119,88,86)" /> - <polygon points="108,125 109,126 109,128" style="fill: rgb(228,193,189)" /> - <polygon points="168,25 169,24 169,25" style="fill: rgb(178,201,219)" /> - <polygon points="107,123 107,122 107,124" style="fill: rgb(178,201,219)" /> - <polygon points="149,44 150,45 151,46" style="fill: rgb(66,55,53)" /> - <polygon points="188,34 189,36 188,36" style="fill: rgb(87,76,74)" /> - <polygon points="147,62 148,62 149,62" style="fill: rgb(210,158,160)" /> - <polygon points="197,72 198,73 197,73" style="fill: rgb(74,64,62)" /> - <polygon points="198,57 199,58 198,58" style="fill: rgb(29,19,18)" /> - <polygon points="200,123 200,125 200,124" style="fill: rgb(104,87,80)" /> - <polygon points="109,213 110,214 109,214" style="fill: rgb(34,28,28)" /> - <polygon points="150,234 151,235 151,236" style="fill: rgb(65,77,99)" /> - <polygon points="172,85 173,85 174,85" style="fill: rgb(130,84,87)" /> - <polygon points="190,36 191,37 192,38" style="fill: rgb(119,114,120)" /> - <polygon points="208,55 209,57 208,56" style="fill: rgb(87,76,74)" /> - <polygon points="69,178 70,177 73,178" style="fill: rgb(237,189,185)" /> - <polygon points="164,61 165,61 166,61" style="fill: rgb(213,149,150)" /> - <polygon points="169,137 170,138 170,139" style="fill: rgb(227,181,184)" /> - <polygon points="117,223 118,224 118,225" style="fill: rgb(74,64,62)" /> - <polygon points="151,44 153,44 152,47" style="fill: rgb(104,87,80)" /> - <polygon points="182,110 183,110 184,110" style="fill: rgb(227,181,184)" /> - <polygon points="80,216 81,216 81,217" style="fill: rgb(213,149,150)" /> - <polygon points="196,64 200,66 198,66" style="fill: rgb(69,54,51)" /> - <polygon points="130,92 132,91 132,92" style="fill: rgb(104,87,80)" /> - <polygon points="163,62 164,62 165,62" style="fill: rgb(230,174,177)" /> - <polygon points="31,257 33,258 32,258" style="fill: rgb(179,146,141)" /> - <polygon points="61,186 62,185 62,186" style="fill: rgb(230,174,177)" /> - <polygon points="129,33 130,33 131,33" style="fill: rgb(179,146,141)" /> - <polygon points="196,86 197,85 198,85" style="fill: rgb(66,55,53)" /> - <polygon points="117,50 118,52 117,51" style="fill: rgb(25,16,19)" /> - <polygon points="34,226 35,225 36,224" style="fill: rgb(228,193,189)" /> - <polygon points="205,109 205,111 205,110" style="fill: rgb(74,64,62)" /> - <polygon points="183,63 184,64 185,65" style="fill: rgb(210,158,160)" /> - <polygon points="170,62 171,62 172,62" style="fill: rgb(230,174,177)" /> - <polygon points="115,86 116,85 117,85" style="fill: rgb(230,174,177)" /> - <polygon points="119,74 123,72 121,74" style="fill: rgb(226,165,164)" /> - <polygon points="160,276 161,276 160,277" style="fill: rgb(65,77,99)" /> - <polygon points="67,173 68,174 68,175" style="fill: rgb(244,194,193)" /> - <polygon points="171,34 172,34 173,34" style="fill: rgb(58,47,51)" /> - <polygon points="96,180 97,180 98,180" style="fill: rgb(244,194,193)" /> - <polygon points="176,103 177,103 178,103" style="fill: rgb(130,84,87)" /> - <polygon points="145,28 146,27 147,26" style="fill: rgb(200,169,167)" /> - <polygon points="126,248 127,248 128,248" style="fill: rgb(22,39,69)" /> - <polygon points="96,211 97,211 98,212" style="fill: rgb(230,174,177)" /> - <polygon points="203,125 203,127 203,126" style="fill: rgb(210,158,160)" /> - <polygon points="108,194 110,193 109,194" style="fill: rgb(179,146,141)" /> - <polygon points="191,62 194,64 193,64" style="fill: rgb(87,76,74)" /> - <polygon points="147,130 147,131 147,132" style="fill: rgb(230,174,177)" /> - <polygon points="174,237 174,239 174,238" style="fill: rgb(119,88,86)" /> - <polygon points="166,163 167,162 166,164" style="fill: rgb(223,185,184)" /> - <polygon points="105,204 106,203 106,204" style="fill: rgb(226,165,164)" /> - <polygon points="32,249 33,251 32,250" style="fill: rgb(228,193,189)" /> - <polygon points="26,250 27,249 27,253" style="fill: rgb(210,158,160)" /> - <polygon points="157,114 158,114 159,115" style="fill: rgb(238,179,181)" /> - <polygon points="62,182 64,181 63,182" style="fill: rgb(230,174,177)" /> - <polygon points="31,229 33,227 32,228" style="fill: rgb(223,185,184)" /> - <polygon points="175,237 175,236 175,235" style="fill: rgb(104,87,80)" /> - <polygon points="193,206 195,204 194,205" style="fill: rgb(179,146,141)" /> - <polygon points="137,60 138,60 139,60" style="fill: rgb(130,84,87)" /> - <polygon points="90,169 96,168 96,169" style="fill: rgb(230,174,177)" /> - <polygon points="209,56 210,57 211,58" style="fill: rgb(104,87,80)" /> - <polygon points="169,206 170,206 171,206" style="fill: rgb(223,185,184)" /> - <polygon points="198,74 198,76 198,75" style="fill: rgb(66,55,53)" /> - <polygon points="182,75 182,74 182,76" style="fill: rgb(234,196,195)" /> - <polygon points="111,203 112,201 112,206" style="fill: rgb(97,66,61)" /> - <polygon points="162,271 162,270 163,269" style="fill: rgb(119,114,120)" /> - <polygon points="196,188 196,186 196,187" style="fill: rgb(228,193,189)" /> - <polygon points="196,70 197,69 197,70" style="fill: rgb(119,88,86)" /> - <polygon points="175,169 177,169 176,171" style="fill: rgb(123,102,107)" /> - <polygon points="127,40 128,39 129,38" style="fill: rgb(66,55,53)" /> - <polygon points="169,23 170,24 171,25" style="fill: rgb(119,114,120)" /> - <polygon points="215,82 215,80 215,81" style="fill: rgb(179,146,141)" /> - <polygon points="113,41 114,40 115,39" style="fill: rgb(123,102,107)" /> - <polygon points="202,135 202,134 203,136" style="fill: rgb(230,174,177)" /> - <polygon points="154,37 155,38 154,39" style="fill: rgb(58,47,51)" /> - <polygon points="104,86 105,85 105,86" style="fill: rgb(58,47,51)" /> - <polygon points="202,94 202,93 202,95" style="fill: rgb(66,55,53)" /> - <polygon points="160,44 161,42 161,44" style="fill: rgb(74,64,62)" /> - <polygon points="198,88 199,88 200,88" style="fill: rgb(34,28,28)" /> - <polygon points="183,114 184,116 183,115" style="fill: rgb(228,193,189)" /> - <polygon points="166,96 167,96 168,96" style="fill: rgb(153,115,106)" /> - <polygon points="104,226 104,225 105,227" style="fill: rgb(119,88,86)" /> - <polygon points="70,224 72,223 71,225" style="fill: rgb(232,184,182)" /> - <polygon points="108,180 109,182 108,182" style="fill: rgb(210,158,160)" /> - <polygon points="159,211 159,209 162,210" style="fill: rgb(232,184,182)" /> - <polygon points="149,94 150,94 150,96" style="fill: rgb(237,189,185)" /> - <polygon points="119,242 121,244 120,243" style="fill: rgb(22,39,69)" /> - <polygon points="168,41 169,40 170,40" style="fill: rgb(74,64,62)" /> - <polygon points="207,61 208,61 209,61" style="fill: rgb(66,55,53)" /> - <polygon points="201,119 202,120 201,120" style="fill: rgb(76,48,47)" /> - <polygon points="108,59 108,60 108,61" style="fill: rgb(74,64,62)" /> - <polygon points="205,133 206,133 207,133" style="fill: rgb(230,174,177)" /> - <polygon points="111,82 111,80 111,81" style="fill: rgb(179,146,141)" /> - <polygon points="111,222 111,223 111,224" style="fill: rgb(76,48,47)" /> - <polygon points="122,42 123,40 123,41" style="fill: rgb(87,76,74)" /> - <polygon points="160,62 161,62 162,62" style="fill: rgb(210,158,160)" /> - <polygon points="162,91 163,91 164,91" style="fill: rgb(153,115,106)" /> - <polygon points="164,103 165,102 165,103" style="fill: rgb(242,202,203)" /> - <polygon points="124,101 124,103 124,102" style="fill: rgb(65,77,99)" /> - <polygon points="145,37 146,37 147,37" style="fill: rgb(74,64,62)" /> - <polygon points="297,269 298,270 298,271" style="fill: rgb(119,114,120)" /> - <polygon points="125,145 126,145 127,145" style="fill: rgb(223,185,184)" /> - <polygon points="208,81 210,81 209,82" style="fill: rgb(74,64,62)" /> - <polygon points="177,203 177,202 178,202" style="fill: rgb(237,189,185)" /> - <polygon points="103,195 104,195 105,196" style="fill: rgb(230,174,177)" /> - <polygon points="165,55 166,54 166,55" style="fill: rgb(76,48,47)" /> - <polygon points="165,104 166,103 166,104" style="fill: rgb(200,169,167)" /> - <polygon points="193,41 194,40 194,41" style="fill: rgb(87,76,74)" /> - <polygon points="116,43 117,43 117,44" style="fill: rgb(66,55,53)" /> - <polygon points="215,97 215,99 215,98" style="fill: rgb(200,169,167)" /> - <polygon points="167,134 168,135 167,135" style="fill: rgb(232,184,182)" /> - <polygon points="191,41 192,45 191,45" style="fill: rgb(74,64,62)" /> - <polygon points="112,91 113,90 114,91" style="fill: rgb(97,66,61)" /> - <polygon points="148,139 150,138 149,139" style="fill: rgb(230,174,177)" /> - <polygon points="166,162 168,160 168,161" style="fill: rgb(228,193,189)" /> - <polygon points="132,81 133,81 133,82" style="fill: rgb(244,194,193)" /> - <polygon points="106,58 107,57 107,59" style="fill: rgb(119,114,120)" /> - <polygon points="199,89 200,89 200,90" style="fill: rgb(29,19,18)" /> - <polygon points="135,114 135,112 135,113" style="fill: rgb(210,158,160)" /> - <polygon points="168,100 168,99 169,101" style="fill: rgb(25,16,19)" /> - <polygon points="192,51 192,49 193,48" style="fill: rgb(25,16,19)" /> - <polygon points="62,189 62,188 62,190" style="fill: rgb(237,189,185)" /> - <polygon points="14,242 15,241 15,242" style="fill: rgb(119,114,120)" /> - <polygon points="148,99 150,98 149,99" style="fill: rgb(244,194,193)" /> - <polygon points="148,58 150,57 150,58" style="fill: rgb(69,54,51)" /> - <polygon points="109,59 109,60 109,61" style="fill: rgb(66,55,53)" /> - <polygon points="174,40 176,39 176,40" style="fill: rgb(87,76,74)" /> - <polygon points="125,83 126,83 127,83" style="fill: rgb(228,193,189)" /> - <polygon points="141,143 142,143 143,143" style="fill: rgb(130,84,87)" /> - <polygon points="187,51 188,51 188,52" style="fill: rgb(25,16,19)" /> - <polygon points="177,53 178,52 177,54" style="fill: rgb(58,47,51)" /> - <polygon points="120,39 120,38 122,37" style="fill: rgb(119,114,120)" /> - <polygon points="206,115 207,113 207,114" style="fill: rgb(153,115,106)" /> - <polygon points="195,84 196,84 195,85" style="fill: rgb(97,66,61)" /> - <polygon points="163,231 163,230 164,229" style="fill: rgb(200,169,167)" /> - <polygon points="178,159 180,160 179,160" style="fill: rgb(179,146,141)" /> - <polygon points="116,91 117,91 118,91" style="fill: rgb(104,87,80)" /> - <polygon points="197,94 197,96 197,95" style="fill: rgb(179,146,141)" /> - <polygon points="169,245 169,247 169,246" style="fill: rgb(210,158,160)" /> - <polygon points="100,75 101,76 101,77" style="fill: rgb(178,201,219)" /> - <polygon points="209,101 209,99 210,101" style="fill: rgb(66,55,53)" /> - <polygon points="90,195 91,195 92,195" style="fill: rgb(244,194,193)" /> - <polygon points="95,201 97,202 96,202" style="fill: rgb(214,116,115)" /> - <polygon points="85,217 86,215 86,216" style="fill: rgb(76,48,47)" /> - <polygon points="126,49 127,47 127,48" style="fill: rgb(66,55,53)" /> - <polygon points="191,121 193,119 192,120" style="fill: rgb(227,181,184)" /> - <polygon points="197,88 197,87 198,86" style="fill: rgb(69,54,51)" /> - <polygon points="162,26 163,26 163,27" style="fill: rgb(123,102,107)" /> - <polygon points="117,93 118,93 119,93" style="fill: rgb(213,149,150)" /> - <polygon points="119,89 120,89 120,90" style="fill: rgb(69,54,51)" /> - <polygon points="110,82 110,81 110,83" style="fill: rgb(153,115,106)" /> - <polygon points="146,32 146,33 146,34" style="fill: rgb(74,64,62)" /> - <polygon points="185,125 187,126 186,126" style="fill: rgb(230,174,177)" /> - <polygon points="113,101 114,99 115,99" style="fill: rgb(213,149,150)" /> - <polygon points="181,84 182,84 183,85" style="fill: rgb(227,181,184)" /> - <polygon points="127,247 128,246 128,247" style="fill: rgb(22,39,69)" /> - <polygon points="146,57 147,57 147,58" style="fill: rgb(97,66,61)" /> - <polygon points="140,76 141,76 142,76" style="fill: rgb(244,194,193)" /> - <polygon points="92,212 93,212 94,213" style="fill: rgb(214,116,115)" /> - <polygon points="104,205 104,206 104,207" style="fill: rgb(153,115,106)" /> - <polygon points="146,36 147,36 148,36" style="fill: rgb(87,76,74)" /> - <polygon points="66,196 66,197 66,198" style="fill: rgb(228,193,189)" /> - <polygon points="125,242 125,241 125,240" style="fill: rgb(179,146,141)" /> - <polygon points="157,67 158,67 159,67" style="fill: rgb(238,179,181)" /> - <polygon points="103,88 104,89 104,90" style="fill: rgb(119,114,120)" /> - <polygon points="198,247 199,247 200,248" style="fill: rgb(65,77,99)" /> - <polygon points="83,214 83,213 84,212" style="fill: rgb(227,181,184)" /> - <polygon points="147,93 147,91 148,91" style="fill: rgb(237,189,185)" /> - <polygon points="173,233 173,232 174,233" style="fill: rgb(123,102,107)" /> - <polygon points="136,116 138,114 137,115" style="fill: rgb(210,158,160)" /> - <polygon points="144,120 145,120 146,120" style="fill: rgb(210,158,160)" /> - <polygon points="144,43 145,42 144,44" style="fill: rgb(74,64,62)" /> - <polygon points="138,41 139,40 139,41" style="fill: rgb(104,87,80)" /> - <polygon points="159,152 161,154 160,153" style="fill: rgb(242,202,203)" /> - <polygon points="200,121 200,119 200,120" style="fill: rgb(97,66,61)" /> - <polygon points="82,220 82,222 82,221" style="fill: rgb(130,84,87)" /> - <polygon points="107,192 109,193 108,193" style="fill: rgb(130,84,87)" /> - <polygon points="150,30 151,30 152,31" style="fill: rgb(119,88,86)" /> - <polygon points="155,27 157,25 158,25" style="fill: rgb(179,146,141)" /> - <polygon points="57,231 58,230 58,231" style="fill: rgb(237,189,185)" /> - <polygon points="126,144 126,143 128,142" style="fill: rgb(226,165,164)" /> - <polygon points="178,58 181,59 179,59" style="fill: rgb(119,88,86)" /> - <polygon points="106,205 107,204 107,205" style="fill: rgb(210,158,160)" /> - <polygon points="17,237 18,236 17,238" style="fill: rgb(25,16,19)" /> - <polygon points="80,220 80,222 80,221" style="fill: rgb(210,158,160)" /> - <polygon points="176,169 177,170 177,171" style="fill: rgb(123,102,107)" /> - <polygon points="213,110 214,110 214,111" style="fill: rgb(213,149,150)" /> - <polygon points="96,208 97,207 97,208" style="fill: rgb(244,194,193)" /> - <polygon points="182,87 184,89 183,89" style="fill: rgb(119,88,86)" /> - <polygon points="159,212 159,210 160,211" style="fill: rgb(227,181,184)" /> - <polygon points="142,32 143,31 143,32" style="fill: rgb(74,64,62)" /> - <polygon points="157,52 159,51 158,52" style="fill: rgb(69,54,51)" /> - <polygon points="214,94 214,96 214,95" style="fill: rgb(119,114,120)" /> - <polygon points="82,210 82,209 83,209" style="fill: rgb(238,179,181)" /> - <polygon points="84,215 87,211 87,212" style="fill: rgb(210,158,160)" /> - <polygon points="139,126 139,128 139,127" style="fill: rgb(226,165,164)" /> - <polygon points="208,111 209,112 208,112" style="fill: rgb(213,149,150)" /> - <polygon points="199,143 201,142 199,145" style="fill: rgb(179,146,141)" /> - <polygon points="141,34 142,33 143,34" style="fill: rgb(66,55,53)" /> - <polygon points="114,41 115,41 116,41" style="fill: rgb(74,64,62)" /> - <polygon points="58,202 59,200 59,201" style="fill: rgb(228,193,189)" /> - <polygon points="14,234 17,233 15,237" style="fill: rgb(179,146,141)" /> - <polygon points="188,63 189,62 189,64" style="fill: rgb(87,76,74)" /> - <polygon points="107,56 109,57 108,57" style="fill: rgb(87,76,74)" /> - <polygon points="137,57 138,58 137,58" style="fill: rgb(66,55,53)" /> - <polygon points="196,161 196,162 196,163" style="fill: rgb(210,158,160)" /> - <polygon points="169,91 170,91 171,91" style="fill: rgb(213,149,150)" /> - <polygon points="20,234 22,234 21,235" style="fill: rgb(25,16,19)" /> - <polygon points="196,192 196,193 196,191" style="fill: rgb(227,181,184)" /> - <polygon points="89,196 90,196 91,196" style="fill: rgb(230,174,177)" /> - <polygon points="127,144 128,143 128,144" style="fill: rgb(226,165,164)" /> - <polygon points="159,44 160,43 159,45" style="fill: rgb(74,64,62)" /> - <polygon points="192,74 192,73 192,75" style="fill: rgb(123,102,107)" /> - <polygon points="202,63 203,65 202,64" style="fill: rgb(25,16,19)" /> - <polygon points="140,93 140,92 140,94" style="fill: rgb(237,189,185)" /> - <polygon points="153,114 154,115 153,115" style="fill: rgb(214,116,115)" /> - <polygon points="110,191 111,189 111,190" style="fill: rgb(76,48,47)" /> - <polygon points="83,215 84,214 85,213" style="fill: rgb(200,169,167)" /> - <polygon points="107,191 108,189 108,190" style="fill: rgb(214,116,115)" /> - <polygon points="55,198 56,197 57,196" style="fill: rgb(228,193,189)" /> - <polygon points="79,211 81,212 80,212" style="fill: rgb(237,189,185)" /> - <polygon points="137,141 138,140 139,140" style="fill: rgb(213,149,150)" /> - <polygon points="261,246 263,247 262,247" style="fill: rgb(239,244,248)" /> - <polygon points="64,226 65,226 66,226" style="fill: rgb(237,189,185)" /> - <polygon points="6,252 7,251 7,252" style="fill: rgb(179,146,141)" /> - <polygon points="200,70 200,69 201,69" style="fill: rgb(119,88,86)" /> - <polygon points="173,89 174,88 175,89" style="fill: rgb(123,102,107)" /> - <polygon points="173,229 173,228 173,230" style="fill: rgb(123,102,107)" /> - <polygon points="208,104 210,103 209,104" style="fill: rgb(74,64,62)" /> - <polygon points="191,159 193,160 192,160" style="fill: rgb(179,146,141)" /> - <polygon points="78,186 79,186 78,187" style="fill: rgb(238,179,181)" /> - <polygon points="84,170 85,170 86,170" style="fill: rgb(237,189,185)" /> - <polygon points="150,129 152,128 151,129" style="fill: rgb(223,185,184)" /> - <polygon points="82,223 83,222 84,221" style="fill: rgb(123,102,107)" /> - <polygon points="163,143 166,142 167,143" style="fill: rgb(153,115,106)" /> - <polygon points="38,223 41,221 39,223" style="fill: rgb(223,185,184)" /> - <polygon points="192,48 193,49 193,50" style="fill: rgb(25,16,19)" /> - <polygon points="96,186 97,186 98,186" style="fill: rgb(244,194,193)" /> - <polygon points="123,226 125,227 124,227" style="fill: rgb(239,244,248)" /> - <polygon points="12,250 12,248 13,250" style="fill: rgb(178,201,219)" /> - <polygon points="199,135 199,136 199,134" style="fill: rgb(200,169,167)" /> - <polygon points="197,159 197,160 197,161" style="fill: rgb(223,185,184)" /> - <polygon points="199,90 200,91 199,91" style="fill: rgb(34,28,28)" /> - <polygon points="91,292 91,291 92,292" style="fill: rgb(65,77,99)" /> - <polygon points="109,41 109,42 109,43" style="fill: rgb(178,201,219)" /> - <polygon points="167,63 168,62 168,63" style="fill: rgb(226,165,164)" /> - <polygon points="99,170 102,169 101,170" style="fill: rgb(230,174,177)" /> - <polygon points="175,37 176,36 178,39" style="fill: rgb(66,55,53)" /> - <polygon points="200,117 200,116 200,118" style="fill: rgb(87,76,74)" /> - <polygon points="134,60 135,60 136,60" style="fill: rgb(119,88,86)" /> - <polygon points="212,84 212,85 212,83" style="fill: rgb(104,87,80)" /> - <polygon points="159,30 160,30 160,31" style="fill: rgb(34,28,28)" /> - <polygon points="215,119 215,118 215,120" style="fill: rgb(130,84,87)" /> - <polygon points="291,262 293,264 292,263" style="fill: rgb(200,169,167)" /> - <polygon points="217,287 218,287 218,288" style="fill: rgb(65,77,99)" /> - <polygon points="12,251 13,251 12,252" style="fill: rgb(179,146,141)" /> - <polygon points="192,65 194,66 193,66" style="fill: rgb(123,102,107)" /> - <polygon points="81,174 82,174 83,174" style="fill: rgb(230,174,177)" /> - <polygon points="17,241 18,242 17,243" style="fill: rgb(58,47,51)" /> - <polygon points="138,118 138,117 139,118" style="fill: rgb(234,196,195)" /> - <polygon points="205,113 205,114 205,112" style="fill: rgb(97,66,61)" /> - <polygon points="153,45 154,44 155,45" style="fill: rgb(87,76,74)" /> - <polygon points="112,71 115,70 114,71" style="fill: rgb(119,88,86)" /> - <polygon points="158,266 159,267 159,270" style="fill: rgb(178,201,219)" /> - <polygon points="119,85 120,85 121,85" style="fill: rgb(210,158,160)" /> - <polygon points="52,242 53,241 52,243" style="fill: rgb(228,193,189)" /> - <polygon points="157,216 157,217 157,218" style="fill: rgb(237,189,185)" /> - <polygon points="202,133 203,133 204,133" style="fill: rgb(226,165,164)" /> - <polygon points="167,83 168,83 169,83" style="fill: rgb(230,174,177)" /> - <polygon points="127,82 128,81 129,82" style="fill: rgb(244,194,193)" /> - <polygon points="293,274 294,275 293,275" style="fill: rgb(65,77,99)" /> - <polygon points="32,245 33,244 32,246" style="fill: rgb(237,189,185)" /> - <polygon points="82,241 82,240 83,240" style="fill: rgb(65,77,99)" /> - <polygon points="107,101 108,102 108,103" style="fill: rgb(200,169,167)" /> - <polygon points="217,219 218,219 219,220" style="fill: rgb(178,201,219)" /> - <polygon points="118,39 119,38 119,39" style="fill: rgb(119,114,120)" /> - <polygon points="190,95 190,94 190,96" style="fill: rgb(227,181,184)" /> - <polygon points="167,37 168,37 169,37" style="fill: rgb(153,115,106)" /> - <polygon points="104,74 104,73 105,72" style="fill: rgb(58,47,51)" /> - <polygon points="184,52 185,50 187,55" style="fill: rgb(69,54,51)" /> - <polygon points="185,74 186,75 186,77" style="fill: rgb(232,184,182)" /> - <polygon points="31,233 33,232 32,233" style="fill: rgb(226,165,164)" /> - <polygon points="102,65 103,62 104,66" style="fill: rgb(178,201,219)" /> - <polygon points="178,170 178,169 179,170" style="fill: rgb(119,88,86)" /> - <polygon points="105,297 106,297 105,298" style="fill: rgb(119,114,120)" /> - <polygon points="105,209 105,210 105,211" style="fill: rgb(153,115,106)" /> - <polygon points="119,86 120,86 121,86" style="fill: rgb(179,146,141)" /> - <polygon points="200,139 201,139 202,140" style="fill: rgb(213,149,150)" /> - <polygon points="30,297 30,296 30,295" style="fill: rgb(119,114,120)" /> - <polygon points="88,179 89,179 90,179" style="fill: rgb(234,196,195)" /> - <polygon points="110,43 111,43 112,43" style="fill: rgb(119,114,120)" /> - <polygon points="158,211 158,209 158,210" style="fill: rgb(223,185,184)" /> - <polygon points="148,56 149,56 150,56" style="fill: rgb(76,48,47)" /> - <polygon points="123,57 124,57 125,57" style="fill: rgb(69,54,51)" /> - <polygon points="157,147 158,147 159,147" style="fill: rgb(213,149,150)" /> - <polygon points="150,93 151,94 151,96" style="fill: rgb(237,189,185)" /> - <polygon points="179,43 180,43 180,44" style="fill: rgb(119,88,86)" /> - <polygon points="113,108 115,109 114,109" style="fill: rgb(214,116,115)" /> - <polygon points="104,291 104,290 104,292" style="fill: rgb(65,77,99)" /> - <polygon points="146,122 148,123 146,123" style="fill: rgb(214,116,115)" /> - <polygon points="171,61 172,61 173,61" style="fill: rgb(226,165,164)" /> - <polygon points="80,177 80,176 81,177" style="fill: rgb(230,174,177)" /> - <polygon points="162,59 163,59 164,59" style="fill: rgb(119,88,86)" /> - <polygon points="185,183 185,182 185,184" style="fill: rgb(223,185,184)" /> - <polygon points="78,188 80,187 79,188" style="fill: rgb(232,184,182)" /> - <polygon points="124,83 126,84 125,84" style="fill: rgb(228,193,189)" /> - <polygon points="113,70 115,69 114,70" style="fill: rgb(104,87,80)" /> - <polygon points="207,82 207,80 207,81" style="fill: rgb(69,54,51)" /> - <polygon points="126,108 127,107 132,108" style="fill: rgb(153,115,106)" /> - <polygon points="109,91 111,89 110,90" style="fill: rgb(200,169,167)" /> - <polygon points="178,61 179,61 180,61" style="fill: rgb(213,149,150)" /> - <polygon points="167,145 168,143 168,146" style="fill: rgb(153,115,106)" /> - <polygon points="108,62 109,62 108,63" style="fill: rgb(87,76,74)" /> - <polygon points="154,242 155,241 155,242" style="fill: rgb(223,185,184)" /> - <polygon points="203,129 204,130 203,130" style="fill: rgb(230,174,177)" /> -</svg>